Skip to content

Commit 7b77fa2

Browse files
terrylucascommit-bot@chromium.org
authored andcommitted
Fixed callbacks typedef to be List instead of a generic typed List.
Fixed getLegacyStats - shouldn't have a JSName annotation. Fixes #33891 [email protected] Change-Id: Ie9761ad4f3c69fc875cdb1f0d096f48d1528671b Reviewed-on: https://dart-review.googlesource.com/66400 Reviewed-by: Sigmund Cherem <[email protected]> Commit-Queue: Terry Lucas <[email protected]>
1 parent eb4b4d3 commit 7b77fa2

File tree

5 files changed

+66
-9
lines changed

5 files changed

+66
-9
lines changed

sdk/lib/html/dart2js/html_dart2js.dart

+4-6
Original file line numberDiff line numberDiff line change
@@ -14504,7 +14504,7 @@ class EmbedElement extends HtmlElement {
1450414504

1450514505
// WARNING: Do not edit - generated code.
1450614506

14507-
typedef void _EntriesCallback(List<Entry> entries);
14507+
typedef void _EntriesCallback(List entries);
1450814508
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
1450914509
// for details. All rights reserved. Use of this source code is governed by a
1451014510
// BSD-style license that can be found in the LICENSE file.
@@ -18843,7 +18843,7 @@ class IntersectionObserver extends Interceptor {
1884318843
// WARNING: Do not edit - generated code.
1884418844

1884518845
typedef void IntersectionObserverCallback(
18846-
List<IntersectionObserverEntry> entries, IntersectionObserver observer);
18846+
List entries, IntersectionObserver observer);
1884718847
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
1884818848
// for details. All rights reserved. Use of this source code is governed by a
1884918849
// BSD-style license that can be found in the LICENSE file.
@@ -21179,8 +21179,7 @@ class MouseEvent extends UIEvent {
2117921179

2118021180
// WARNING: Do not edit - generated code.
2118121181

21182-
typedef void MutationCallback(
21183-
List<MutationRecord> mutations, MutationObserver observer);
21182+
typedef void MutationCallback(List mutations, MutationObserver observer);
2118421183
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2118521184
// for details. All rights reserved. Use of this source code is governed by a
2118621185
// BSD-style license that can be found in the LICENSE file.
@@ -25106,7 +25105,7 @@ class ReportingObserver extends Interceptor {
2510625105
// WARNING: Do not edit - generated code.
2510725106

2510825107
typedef void ReportingObserverCallback(
25109-
List<_Report> reports, ReportingObserver observer);
25108+
List reports, ReportingObserver observer);
2511025109
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2511125110
// for details. All rights reserved. Use of this source code is governed by a
2511225111
// BSD-style license that can be found in the LICENSE file.
@@ -25481,7 +25480,6 @@ class RtcPeerConnection extends EventTarget {
2548125480
* Temporarily exposes _getStats and old getStats as getLegacyStats until Chrome fully supports
2548225481
* new getStats API.
2548325482
*/
25484-
@JSName('getStats')
2548525483
Future<RtcStatsResponse> getLegacyStats([MediaStreamTrack selector]) {
2548625484
var completer = new Completer<RtcStatsResponse>();
2548725485
_getStats((value) {
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
library callback_list_test;
2+
3+
import 'dart:html';
4+
import 'dart:async';
5+
6+
import 'package:unittest/unittest.dart';
7+
import 'package:unittest/html_config.dart';
8+
9+
var callbackDone = false;
10+
bool isCallbackDone() => callbackDone;
11+
12+
Future waitUntilCallbackDone(bool test()) async {
13+
var completer = new Completer();
14+
check() {
15+
if (test()) {
16+
completer.complete();
17+
} else {
18+
new Timer(Duration.zero, check);
19+
}
20+
}
21+
22+
check();
23+
return completer.future;
24+
}
25+
26+
void main() async {
27+
useHtmlConfiguration();
28+
window.navigator.persistentStorage.requestQuota(1024 * 1024, _quotaHandler);
29+
30+
await waitUntilCallbackDone(isCallbackDone);
31+
expect(true, isCallbackDone());
32+
}
33+
34+
Future _quotaHandler(int byteCount) async {
35+
FileSystem filesystem =
36+
await window.requestFileSystem(1024 * 1024, persistent: true);
37+
DirectoryEntry dir = await filesystem.root;
38+
DirectoryReader dirReader = dir.createReader();
39+
await dirReader.readEntries();
40+
List<Entry> secondEntries = await dirReader.readEntries();
41+
callbackDone = true;
42+
}

tests/lib_2/lib_2_dart2js.status

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ html/no_linked_scripts_htmltest: Timeout, Pass # Issue 32262
8787
html/worker_test/functional: RuntimeError # Issue 32261
8888

8989
[ $compiler == dart2js && $runtime == chrome && $strong ]
90-
html/fileapi_directory_reader_test: RuntimeError
9190
html/interactive_media_test: RuntimeError
9291

9392
[ $compiler == dart2js && $runtime == chromeOnAndroid ]
@@ -117,6 +116,7 @@ html/audioelement_test: RuntimeError
117116
html/b_element_test: RuntimeError
118117
html/blob_constructor_test: RuntimeError
119118
html/cache_test: RuntimeError
119+
html/callback_list_test: RuntimeError
120120
html/callbacks_test: RuntimeError
121121
html/canvas_pixel_array_type_alias_test: RuntimeError
122122
html/canvas_test: RuntimeError

tools/dom/scripts/systemhtml.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@
137137
# constructor creation.
138138
_static_classes = set(['Url'])
139139

140+
# Callback typedefs with generic List (List<nnn>) convert to List
141+
_callback_list_generics_mapping = monitored.Set('systemhtml._callback_list_generics_mapping', [
142+
'List<Entry>',
143+
'List<IntersectionObserverEntry>',
144+
'List<MutationRecord>',
145+
'List<_Report>',
146+
])
147+
148+
140149
# Information for generating element constructors.
141150
#
142151
# TODO(sra): maybe remove all the argument complexity and use cascades.
@@ -524,10 +533,19 @@ def GenerateCallback(self):
524533
annotations = self._metadata.GetFormattedMetadata(self._library_name,
525534
self._interface)
526535

536+
params = info.ParametersAsDeclaration(self._DartType);
537+
538+
types = params.split()
539+
if len(types) > 0:
540+
mapType = types[0] in _callback_list_generics_mapping
541+
if mapType is True:
542+
types[0] = 'List'
543+
params = " ".join(types)
544+
527545
code.Emit('$(ANNOTATIONS)typedef void $NAME($PARAMS);\n',
528546
ANNOTATIONS=annotations,
529547
NAME=typedef_name,
530-
PARAMS=info.ParametersAsDeclaration(self._DartType))
548+
PARAMS=params)
531549
self._backend.GenerateCallback(info)
532550

533551
def GenerateInterface(self):

tools/dom/templates/html/impl/impl_RTCPeerConnection.darttemplate

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
5454
* Temporarily exposes _getStats and old getStats as getLegacyStats until Chrome fully supports
5555
* new getStats API.
5656
*/
57-
@JSName('getStats')
5857
Future<RtcStatsResponse> getLegacyStats([MediaStreamTrack selector]) {
5958
var completer = new Completer<RtcStatsResponse>();
6059
_getStats((value) {

0 commit comments

Comments
 (0)