Skip to content

Commit

Permalink
- Fixed querySelectoryAll generic syntax to assert if types in list a…
Browse files Browse the repository at this point in the history
…ren't of the same type T.

- Fixes requestFullscreen to call operation webkitRequestFullscreen not requestFullscreen its only available when RuntimeEnabled=FullscreenUnprefixed.

Fixes #21919

R=vsm@google.com

Change-Id: Ib4c4140350d3cef096954e67010f922df9f2310a
Reviewed-on: https://dart-review.googlesource.com/60702
Commit-Queue: Terry Lucas <terry@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
  • Loading branch information
terrylucas authored and commit-bot@chromium.org committed Jun 25, 2018
1 parent 3640037 commit 5721d8a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 18 deletions.
24 changes: 19 additions & 5 deletions sdk/lib/html/dart2js/html_dart2js.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11641,7 +11641,10 @@ class _FrozenElementList<E extends Element> extends ListBase<E>
implements ElementList<E>, NodeListWrapper {
final List<Node> _nodeList;

_FrozenElementList._wrap(this._nodeList);
_FrozenElementList._wrap(this._nodeList) {
assert(this._nodeList.every((element) => element is E),
"Query expects only HTML elements of type $E but found ${this._nodeList.firstWhere((e) => e is! E)}");
}

int get length => _nodeList.length;

Expand Down Expand Up @@ -13958,8 +13961,6 @@ class Element extends Node
@JSName('removeAttributeNS')
void _removeAttributeNS(String namespaceURI, String localName) native;

void requestFullscreen() native;

void requestPointerLock() native;

void scroll([options_OR_x, num y]) {
Expand Down Expand Up @@ -14052,6 +14053,21 @@ class Element extends Node

void setPointerCapture(int pointerId) native;

@JSName('webkitRequestFullscreen')
/**
* Displays this element fullscreen.
*
* ## Other resources
*
* * [Using the fullscreen
* API](http://docs.webplatform.org/wiki/tutorials/using_the_full-screen_api)
* tutorial from WebPlatform.org.
* * [Fullscreen specification](http://www.w3.org/TR/fullscreen/) from W3C.
*/
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
void requestFullscreen() native;

// From ChildNode

void after(Object nodes) native;
Expand Down Expand Up @@ -27346,8 +27362,6 @@ class SpeechRecognitionResult extends Interceptor {

@Native("SpeechSynthesis")
class SpeechSynthesis extends EventTarget {
@DomName('SpeechSynthesis.getVoices')
@DocsEditable()
List<SpeechSynthesisVoice> getVoices() {
List<SpeechSynthesisVoice> voices = _getVoices();
if (voices.length > 0) applyExtension('SpeechSynthesisVoice', voices[0]);
Expand Down
9 changes: 3 additions & 6 deletions tests/lib_2/html/element_classes_svg_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@ topLevelQuerySelector() {
expect(noElementsTop.length, 0);
expect(noElementsTop is List, true);

var varWeird = querySelectorAll<svg.CircleElement>('path');
expect(varWeird.length, 1);
expect(varWeird is List, true);
expect(varWeird is List<svg.CircleElement>, true);
// Runtime error expected 'PathElement' is not a subtype of expected type 'CircleElement'.'
Expect.throwsTypeError(() => varWeird[0] is svg.CircleElement);
// Expect runtime error all elements in the list are not the proper type.
Expect.throwsAssertionError(() => querySelectorAll<svg.CircleElement>('path'),
'All elements not of type CircleElement');

var simpleElems = querySelectorAll('circle');
expect(simpleElems.length, 1);
Expand Down
5 changes: 2 additions & 3 deletions tools/dom/idl/dart/dart.idl
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,10 @@ interface AudioScheduledSourceNode {
[DartName=start2] void start(optional double when);
};

// Remove operations webkitRequestFullscreen replaced w/ requestFullscreen.
// Remove operation requestFullscreen only use webKitRequestFullscreen.
[DartSupplemental]
interface Element : Node {
[DartSuppress] void webkitRequestFullScreen([Default=Undefined] optional unsigned short flags);
[DartSuppress] void webkitRequestFullscreen();
[DartSuppress] void requestFullscreen();
};

[DartSupplemental]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
ElementList<T> querySelectorAll<T extends Element>(String selectors) =>
new _FrozenElementList<T>._wrap(_querySelectorAll(selectors));


String get innerHtml {
final e = new DivElement();
e.append(this.clone(true));
Expand Down
5 changes: 4 additions & 1 deletion tools/dom/templates/html/impl/impl_Element.darttemplate
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ class _FrozenElementList<E extends Element> extends ListBase<E>
implements ElementList<E>, NodeListWrapper {
final List<Node> _nodeList;

_FrozenElementList._wrap(this._nodeList);
_FrozenElementList._wrap(this._nodeList) {
assert(this._nodeList.every((element) => element is E),
"Query expects only HTML elements of type $E but found ${this._nodeList.firstWhere((e) => e is! E)}");
}

int get length => _nodeList.length;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ part of $LIBRARYNAME;

$(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS
{
@DomName('SpeechSynthesis.getVoices')
@DocsEditable()
List<SpeechSynthesisVoice> getVoices() {
List<SpeechSynthesisVoice> voices = _getVoices();
if (voices.length > 0)
Expand Down

0 comments on commit 5721d8a

Please sign in to comment.