| Index: sdk/lib/html/dartium/html_dartium.dart
|
| diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
|
| index e7587818a025e7a311b351dc0ce6dcfb3466e925..f27bb86e36cf0725a5ac1a8abb04c495dbd36f78 100644
|
| --- a/sdk/lib/html/dartium/html_dartium.dart
|
| +++ b/sdk/lib/html/dartium/html_dartium.dart
|
| @@ -805,12 +805,12 @@ abstract class AbstractWorker extends DartHtmlDomObject implements EventTarget {
|
| */
|
| @DomName('AbstractWorker.errorEvent')
|
| @DocsEditable()
|
| - static const EventStreamProvider<ErrorEvent> errorEvent = const EventStreamProvider<ErrorEvent>('error');
|
| + static const EventStreamProvider<Event> errorEvent = const EventStreamProvider<Event>('error');
|
|
|
| /// Stream of `error` events handled by this [AbstractWorker].
|
| @DomName('AbstractWorker.onerror')
|
| @DocsEditable()
|
| - Stream<ErrorEvent> get onError => errorEvent.forTarget(this);
|
| + Stream<Event> get onError => errorEvent.forTarget(this);
|
| }
|
| // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| @@ -4591,7 +4591,7 @@ class CompositorWorker extends EventTarget implements AbstractWorker {
|
| @DomName('CompositorWorker.errorEvent')
|
| @DocsEditable()
|
| @Experimental() // untriaged
|
| - static const EventStreamProvider<ErrorEvent> errorEvent = const EventStreamProvider<ErrorEvent>('error');
|
| + static const EventStreamProvider<Event> errorEvent = const EventStreamProvider<Event>('error');
|
|
|
| @DomName('CompositorWorker.messageEvent')
|
| @DocsEditable()
|
| @@ -4629,7 +4629,7 @@ class CompositorWorker extends EventTarget implements AbstractWorker {
|
| @DomName('CompositorWorker.onerror')
|
| @DocsEditable()
|
| @Experimental() // untriaged
|
| - Stream<ErrorEvent> get onError => errorEvent.forTarget(this);
|
| + Stream<Event> get onError => errorEvent.forTarget(this);
|
|
|
| @DomName('CompositorWorker.onmessage')
|
| @DocsEditable()
|
| @@ -11023,7 +11023,7 @@ class DocumentFragment extends Node implements NonElementParentNode, ParentNode
|
|
|
| set children(List<Element> value) {
|
| // Copy list first since we don't want liveness during iteration.
|
| - List copy = new List.from(value);
|
| + var copy = value.toList();
|
| var children = this.children;
|
| children.clear();
|
| children.addAll(copy);
|
| @@ -12480,7 +12480,7 @@ class _ChildrenElementList extends ListBase<Element>
|
| _filter(test, true);
|
| }
|
|
|
| - void _filter(bool test(var element), bool retainMatching) {
|
| + void _filter(bool test(Element element), bool retainMatching) {
|
| var removed;
|
| if (retainMatching) {
|
| removed = _element.children.where((e) => !test(e));
|
| @@ -13926,7 +13926,7 @@ class Element extends Node implements NonDocumentTypeChildNode, GlobalEventHandl
|
|
|
| set children(List<Element> value) {
|
| // Copy list first since we don't want liveness during iteration.
|
| - List copy = new List.from(value);
|
| + var copy = value.toList();
|
| var children = this.children;
|
| children.clear();
|
| children.addAll(copy);
|
| @@ -14161,15 +14161,14 @@ class Element extends Node implements NonDocumentTypeChildNode, GlobalEventHandl
|
| throw new ArgumentError("The frames parameter should be a List of Maps "
|
| "with frame information");
|
| }
|
| - var convertedFrames = frames;
|
| - if (convertedFrames is Iterable) {
|
| + var convertedFrames;
|
| + if (frames is Iterable) {
|
| convertedFrames = convertDartToNative_List(
|
| frames.map(convertDartToNative_Dictionary).toList());
|
| + } else {
|
| + convertedFrames = frames;
|
| }
|
| - var convertedTiming = timing;
|
| - if (convertedTiming is Map) {
|
| - convertedTiming = convertDartToNative_Dictionary(convertedTiming);
|
| - }
|
| + var convertedTiming = timing is Map ? convertDartToNative_Dictionary(timing) : timing;
|
| return convertedTiming == null
|
| ? _animate(convertedFrames)
|
| : _animate(convertedFrames, convertedTiming);
|
| @@ -18704,7 +18703,10 @@ class Geolocation extends DartHtmlDomObject {
|
| }
|
|
|
| int watchId;
|
| - var controller;
|
| + // TODO(jacobr): it seems like a bug that we have to specifiy the static
|
| + // type here for controller.stream to have the right type.
|
| + // dartbug.com/26278
|
| + StreamController<Geoposition> controller;
|
| controller = new StreamController<Geoposition>(sync: true,
|
| onListen: () {
|
| assert(watchId == null);
|
| @@ -19755,11 +19757,11 @@ class HtmlCollection extends DartHtmlDomObject with ListMixin<Node>, ImmutableLi
|
|
|
| @DomName('HTMLCollection.item')
|
| @DocsEditable()
|
| - Element item(int index) => _blink.BlinkHTMLCollection.instance.item_Callback_1_(this, index);
|
| + Node item(int index) => _blink.BlinkHTMLCollection.instance.item_Callback_1_(this, index);
|
|
|
| @DomName('HTMLCollection.namedItem')
|
| @DocsEditable()
|
| - Element namedItem(String name) => _blink.BlinkHTMLCollection.instance.namedItem_Callback_1_(this, name);
|
| + Object namedItem(String name) => (_blink.BlinkHTMLCollection.instance.namedItem_Callback_1_(this, name));
|
|
|
| }
|
| // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| @@ -19891,59 +19893,6 @@ class HtmlDocument extends Document {
|
| _webkitExitFullscreen();
|
| }
|
|
|
| - /**
|
| - * Returns the element, if any, that is currently displayed in fullscreen.
|
| - *
|
| - * Returns null if there is currently no fullscreen element. You can use
|
| - * this to determine if the page is in fullscreen mode.
|
| - *
|
| - * myVideo = new VideoElement();
|
| - * if (document.fullscreenElement == null) {
|
| - * myVideo.requestFullscreen();
|
| - * print(document.fullscreenElement == myVideo); // true
|
| - * }
|
| - *
|
| - * ## Other resources
|
| - *
|
| - * * [Using the fullscreen
|
| - * API](http://docs.webplatform.org/wiki/tutorials/using_the_full-screen_api)
|
| - * from WebPlatform.org.
|
| - * * [Fullscreen specification](http://www.w3.org/TR/fullscreen/) from W3C.
|
| - */
|
| - @DomName('Document.webkitFullscreenElement')
|
| - @SupportedBrowser(SupportedBrowser.CHROME)
|
| - @SupportedBrowser(SupportedBrowser.SAFARI)
|
| - @Experimental()
|
| - Element get fullscreenElement => _webkitFullscreenElement;
|
| -
|
| - /**
|
| - * Returns true if this document can display elements in fullscreen mode.
|
| - *
|
| - * ## Other resources
|
| - *
|
| - * * [Using the fullscreen
|
| - * API](http://docs.webplatform.org/wiki/tutorials/using_the_full-screen_api)
|
| - * from WebPlatform.org.
|
| - * * [Fullscreen specification](http://www.w3.org/TR/fullscreen/) from W3C.
|
| - */
|
| - @DomName('Document.webkitFullscreenEnabled')
|
| - @SupportedBrowser(SupportedBrowser.CHROME)
|
| - @SupportedBrowser(SupportedBrowser.SAFARI)
|
| - @Experimental()
|
| - bool get fullscreenEnabled => _webkitFullscreenEnabled;
|
| -
|
| - @DomName('Document.webkitHidden')
|
| - @SupportedBrowser(SupportedBrowser.CHROME)
|
| - @SupportedBrowser(SupportedBrowser.SAFARI)
|
| - @Experimental()
|
| - bool get hidden => _webkitHidden;
|
| -
|
| - @DomName('Document.visibilityState')
|
| - @SupportedBrowser(SupportedBrowser.CHROME)
|
| - @SupportedBrowser(SupportedBrowser.FIREFOX)
|
| - @SupportedBrowser(SupportedBrowser.IE, '10')
|
| - @Experimental()
|
| - String get visibilityState => _webkitVisibilityState;
|
|
|
| /**
|
| * Internal routine to find the DOM JS class name being extended for custom
|
| @@ -21398,7 +21347,7 @@ class HttpRequest extends HttpRequestEventTarget {
|
| */
|
| @DomName('XMLHttpRequest.readystatechangeEvent')
|
| @DocsEditable()
|
| - static const EventStreamProvider<ProgressEvent> readyStateChangeEvent = const EventStreamProvider<ProgressEvent>('readystatechange');
|
| + static const EventStreamProvider<Event> readyStateChangeEvent = const EventStreamProvider<Event>('readystatechange');
|
|
|
| /**
|
| * General constructor for any type of request (GET, POST, etc).
|
| @@ -21754,7 +21703,7 @@ class HttpRequest extends HttpRequestEventTarget {
|
| */
|
| @DomName('XMLHttpRequest.onreadystatechange')
|
| @DocsEditable()
|
| - Stream<ProgressEvent> get onReadyStateChange => readyStateChangeEvent.forTarget(this);
|
| + Stream<Event> get onReadyStateChange => readyStateChangeEvent.forTarget(this);
|
|
|
| }
|
| // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| @@ -22328,7 +22277,7 @@ class InputElement extends HtmlElement implements
|
| ButtonInputElement {
|
|
|
| factory InputElement({String type}) {
|
| - var e = document.createElement("input");
|
| + InputElement e = document.createElement("input");
|
| if (type != null) {
|
| try {
|
| // IE throws an exception for unknown types.
|
| @@ -25903,7 +25852,7 @@ class MessageEvent extends Event {
|
| factory MessageEvent(String type,
|
| {bool canBubble: false, bool cancelable: false, Object data,
|
| String origin, String lastEventId,
|
| - Window source, List messagePorts}) {
|
| + Window source, List<MessagePort> messagePorts}) {
|
| if (source == null) {
|
| source = window;
|
| }
|
| @@ -27782,7 +27731,7 @@ class Node extends EventTarget {
|
| set nodes(Iterable<Node> value) {
|
| // Copy list first since we don't want liveness during iteration.
|
| // TODO(jacobr): there is a better way to do this.
|
| - List copy = new List.from(value);
|
| + var copy = value.toList();
|
| text = '';
|
| for (Node node in copy) {
|
| append(node);
|
| @@ -32910,8 +32859,7 @@ class SelectElement extends HtmlElement {
|
| // Override default options, since IE returns SelectElement itself and it
|
| // does not operate as a List.
|
| List<OptionElement> get options {
|
| - var options = this.querySelectorAll('option').where(
|
| - (e) => e is OptionElement).toList();
|
| + var options = new List<OptionElement>.from(this.querySelectorAll('option'));
|
| return new UnmodifiableListView(options);
|
| }
|
|
|
| @@ -33695,7 +33643,7 @@ class SharedWorker extends EventTarget implements AbstractWorker {
|
| @DomName('SharedWorker.errorEvent')
|
| @DocsEditable()
|
| @Experimental() // untriaged
|
| - static const EventStreamProvider<ErrorEvent> errorEvent = const EventStreamProvider<ErrorEvent>('error');
|
| + static const EventStreamProvider<Event> errorEvent = const EventStreamProvider<Event>('error');
|
|
|
| @DomName('SharedWorker.SharedWorker')
|
| @DocsEditable()
|
| @@ -33723,7 +33671,7 @@ class SharedWorker extends EventTarget implements AbstractWorker {
|
| @DomName('SharedWorker.onerror')
|
| @DocsEditable()
|
| @Experimental() // untriaged
|
| - Stream<ErrorEvent> get onError => errorEvent.forTarget(this);
|
| + Stream<Event> get onError => errorEvent.forTarget(this);
|
|
|
| }
|
| // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| @@ -35116,11 +35064,11 @@ class Storage extends DartHtmlDomObject
|
| }
|
|
|
| // TODO(nweiz): update this when maps support lazy iteration
|
| - bool containsValue(String value) => values.any((e) => e == value);
|
| + bool containsValue(Object value) => values.any((e) => e == value);
|
|
|
| - bool containsKey(String key) => _getItem(key) != null;
|
| + bool containsKey(Object key) => _getItem(key) != null;
|
|
|
| - String operator [](String key) => _getItem(key);
|
| + String operator [](Object key) => _getItem(key);
|
|
|
| void operator []=(String key, String value) { _setItem(key, value); }
|
|
|
| @@ -35129,7 +35077,7 @@ class Storage extends DartHtmlDomObject
|
| return this[key];
|
| }
|
|
|
| - String remove(String key) {
|
| + String remove(Object key) {
|
| final value = this[key];
|
| _removeItem(key);
|
| return value;
|
| @@ -35147,13 +35095,13 @@ class Storage extends DartHtmlDomObject
|
| }
|
|
|
| Iterable<String> get keys {
|
| - final keys = [];
|
| + final keys = <String>[];
|
| forEach((k, v) => keys.add(k));
|
| return keys;
|
| }
|
|
|
| Iterable<String> get values {
|
| - final values = [];
|
| + final values = <String>[];
|
| forEach((k, v) => values.add(v));
|
| return values;
|
| }
|
| @@ -40994,7 +40942,7 @@ class Worker extends EventTarget implements AbstractWorker {
|
| @DomName('Worker.errorEvent')
|
| @DocsEditable()
|
| @Experimental() // untriaged
|
| - static const EventStreamProvider<ErrorEvent> errorEvent = const EventStreamProvider<ErrorEvent>('error');
|
| + static const EventStreamProvider<Event> errorEvent = const EventStreamProvider<Event>('error');
|
|
|
| /**
|
| * Static factory designed to expose `message` events to event
|
| @@ -41040,7 +40988,7 @@ class Worker extends EventTarget implements AbstractWorker {
|
| @DomName('Worker.onerror')
|
| @DocsEditable()
|
| @Experimental() // untriaged
|
| - Stream<ErrorEvent> get onError => errorEvent.forTarget(this);
|
| + Stream<Event> get onError => errorEvent.forTarget(this);
|
|
|
| /// Stream of `message` events handled by this [Worker].
|
| @DomName('Worker.onmessage')
|
| @@ -41734,16 +41682,6 @@ class _Attr extends Node {
|
| @Experimental() // untriaged
|
| String get nodeValue => _blink.BlinkAttr.instance.nodeValue_Getter_(this);
|
|
|
| - @DomName('Attr.textContent')
|
| - @DocsEditable()
|
| - @Experimental() // untriaged
|
| - String get text => _blink.BlinkAttr.instance.textContent_Getter_(this);
|
| -
|
| - @DomName('Attr.textContent')
|
| - @DocsEditable()
|
| - @Experimental() // untriaged
|
| - set text(String value) => _blink.BlinkAttr.instance.textContent_Setter_(this, value);
|
| -
|
| @DomName('Attr.value')
|
| @DocsEditable()
|
| String get value => _blink.BlinkAttr.instance.value_Getter_(this);
|
| @@ -43341,7 +43279,7 @@ abstract class _AttributeMap implements Map<String, String> {
|
| other.forEach((k, v) { this[k] = v; });
|
| }
|
|
|
| - bool containsValue(String value) {
|
| + bool containsValue(Object value) {
|
| for (var v in this.values) {
|
| if (value == v) {
|
| return true;
|
| @@ -43373,10 +43311,11 @@ abstract class _AttributeMap implements Map<String, String> {
|
| Iterable<String> get keys {
|
| // TODO: generate a lazy collection instead.
|
| var attributes = _element._attributes;
|
| - var keys = new List<String>();
|
| + var keys = <String>[];
|
| for (int i = 0, len = attributes.length; i < len; i++) {
|
| - if (_matches(attributes[i])) {
|
| - keys.add(attributes[i].name);
|
| + _Attr attr = attributes[i];
|
| + if (_matches(attr)) {
|
| + keys.add(attr.name);
|
| }
|
| }
|
| return keys;
|
| @@ -43385,10 +43324,11 @@ abstract class _AttributeMap implements Map<String, String> {
|
| Iterable<String> get values {
|
| // TODO: generate a lazy collection instead.
|
| var attributes = _element._attributes;
|
| - var values = new List<String>();
|
| + var values = <String>[];
|
| for (int i = 0, len = attributes.length; i < len; i++) {
|
| - if (_matches(attributes[i])) {
|
| - values.add(attributes[i].value);
|
| + _Attr attr = attributes[i];
|
| + if (_matches(attr)) {
|
| + values.add(attr.value);
|
| }
|
| }
|
| return values;
|
| @@ -43419,11 +43359,11 @@ class _ElementAttributeMap extends _AttributeMap {
|
|
|
| _ElementAttributeMap(Element element): super(element);
|
|
|
| - bool containsKey(String key) {
|
| + bool containsKey(Object key) {
|
| return _element._hasAttribute(key);
|
| }
|
|
|
| - String operator [](String key) {
|
| + String operator [](Object key) {
|
| return _element.getAttribute(key);
|
| }
|
|
|
| @@ -43431,7 +43371,7 @@ class _ElementAttributeMap extends _AttributeMap {
|
| _element.setAttribute(key, value);
|
| }
|
|
|
| - String remove(String key) {
|
| + String remove(Object key) {
|
| String value = _element.getAttribute(key);
|
| _element._removeAttribute(key);
|
| return value;
|
| @@ -43456,11 +43396,11 @@ class _NamespacedAttributeMap extends _AttributeMap {
|
|
|
| _NamespacedAttributeMap(Element element, this._namespace): super(element);
|
|
|
| - bool containsKey(String key) {
|
| + bool containsKey(Object key) {
|
| return _element._hasAttributeNS(_namespace, key);
|
| }
|
|
|
| - String operator [](String key) {
|
| + String operator [](Object key) {
|
| return _element.getAttributeNS(_namespace, key);
|
| }
|
|
|
| @@ -43468,7 +43408,7 @@ class _NamespacedAttributeMap extends _AttributeMap {
|
| _element.setAttributeNS(_namespace, key, value);
|
| }
|
|
|
| - String remove(String key) {
|
| + String remove(Object key) {
|
| String value = this[key];
|
| _element._removeAttributeNS(_namespace, key);
|
| return value;
|
| @@ -43502,11 +43442,11 @@ class _DataAttributeMap implements Map<String, String> {
|
| }
|
|
|
| // TODO: Use lazy iterator when it is available on Map.
|
| - bool containsValue(String value) => values.any((v) => v == value);
|
| + bool containsValue(Object value) => values.any((v) => v == value);
|
|
|
| - bool containsKey(String key) => _attributes.containsKey(_attr(key));
|
| + bool containsKey(Object key) => _attributes.containsKey(_attr(key));
|
|
|
| - String operator [](String key) => _attributes[_attr(key)];
|
| + String operator [](Object key) => _attributes[_attr(key)];
|
|
|
| void operator []=(String key, String value) {
|
| _attributes[_attr(key)] = value;
|
| @@ -43515,7 +43455,7 @@ class _DataAttributeMap implements Map<String, String> {
|
| String putIfAbsent(String key, String ifAbsent()) =>
|
| _attributes.putIfAbsent(_attr(key), ifAbsent);
|
|
|
| - String remove(String key) => _attributes.remove(_attr(key));
|
| + String remove(Object key) => _attributes.remove(_attr(key));
|
|
|
| void clear() {
|
| // Needs to operate on a snapshot since we are mutating the collection.
|
| @@ -43533,7 +43473,7 @@ class _DataAttributeMap implements Map<String, String> {
|
| }
|
|
|
| Iterable<String> get keys {
|
| - final keys = new List<String>();
|
| + final keys = <String>[];
|
| _attributes.forEach((String key, String value) {
|
| if (_matches(key)) {
|
| keys.add(_strip(key));
|
| @@ -43543,7 +43483,7 @@ class _DataAttributeMap implements Map<String, String> {
|
| }
|
|
|
| Iterable<String> get values {
|
| - final values = new List<String>();
|
| + final values = <String>[];
|
| _attributes.forEach((String key, String value) {
|
| if (_matches(key)) {
|
| values.add(value);
|
| @@ -43774,7 +43714,7 @@ abstract class WindowBase implements EventTarget {
|
| * * [Cross-document messaging](https://html.spec.whatwg.org/multipage/comms.html#web-messaging)
|
| * from WHATWG.
|
| */
|
| - void postMessage(var message, String targetOrigin, [List messagePorts]);
|
| + void postMessage(var message, String targetOrigin, [List<MessagePort> messagePorts]);
|
| }
|
|
|
| abstract class LocationBase {
|
| @@ -43828,7 +43768,7 @@ abstract class CssClassSet implements Set<String> {
|
| * [value] must be a valid 'token' representing a single class, i.e. a
|
| * non-empty string containing no whitespace.
|
| */
|
| - bool contains(String value);
|
| + bool contains(Object value);
|
|
|
| /**
|
| * Add the class [value] to element.
|
| @@ -43880,7 +43820,7 @@ abstract class CssClassSet implements Set<String> {
|
| * Each element of [iterable] must be a valid 'token' representing a single
|
| * class, i.e. a non-empty string containing no whitespace.
|
| */
|
| - void removeAll(Iterable<String> iterable);
|
| + void removeAll(Iterable<Object> iterable);
|
|
|
| /**
|
| * Toggles all classes specified in [iterable] on element.
|
| @@ -43996,7 +43936,7 @@ class _ElementCssClassSet extends CssClassSetImpl {
|
| */
|
| class _ContentCssRect extends CssRect {
|
|
|
| - _ContentCssRect(element) : super(element);
|
| + _ContentCssRect(Element element) : super(element);
|
|
|
| num get height => _element.offsetHeight +
|
| _addOrSubtractToBoxModel(_HEIGHT, _CONTENT);
|
| @@ -44017,9 +43957,11 @@ class _ContentCssRect extends CssRect {
|
| if (newHeight is Dimension) {
|
| if (newHeight.value < 0) newHeight = new Dimension.px(0);
|
| _element.style.height = newHeight.toString();
|
| - } else {
|
| + } else if (newHeight is num) {
|
| if (newHeight < 0) newHeight = 0;
|
| _element.style.height = '${newHeight}px';
|
| + } else {
|
| + throw new ArgumentError("newHeight is not a Dimension or num");
|
| }
|
| }
|
|
|
| @@ -44035,9 +43977,11 @@ class _ContentCssRect extends CssRect {
|
| if (newWidth is Dimension) {
|
| if (newWidth.value < 0) newWidth = new Dimension.px(0);
|
| _element.style.width = newWidth.toString();
|
| - } else {
|
| + } else if (newWidth is num) {
|
| if (newWidth < 0) newWidth = 0;
|
| _element.style.width = '${newWidth}px';
|
| + } else {
|
| + throw new ArgumentError("newWidth is not a Dimension or num");
|
| }
|
| }
|
|
|
| @@ -44054,7 +43998,7 @@ class _ContentCssRect extends CssRect {
|
| class _ContentCssListRect extends _ContentCssRect {
|
| List<Element> _elementList;
|
|
|
| - _ContentCssListRect(elementList) : super(elementList.first) {
|
| + _ContentCssListRect(List<Element> elementList) : super(elementList.first) {
|
| _elementList = elementList;
|
| }
|
|
|
| @@ -44143,10 +44087,10 @@ class _MarginCssRect extends CssRect {
|
| * animation frame is discouraged. See also:
|
| * [Browser Reflow](https://developers.google.com/speed/articles/reflow)
|
| */
|
| -abstract class CssRect extends MutableRectangle<num> {
|
| +abstract class CssRect implements Rectangle<num> {
|
| Element _element;
|
|
|
| - CssRect(this._element) : super(0, 0, 0, 0);
|
| + CssRect(this._element);
|
|
|
| num get left;
|
|
|
| @@ -44239,6 +44183,102 @@ abstract class CssRect extends MutableRectangle<num> {
|
| }
|
| return val;
|
| }
|
| +
|
| + // TODO(jacobr): these methods are duplicated from _RectangleBase in dart:math
|
| + // Ideally we would provide a RectangleMixin class that provides this implementation.
|
| + // In an ideal world we would exp
|
| + /** The x-coordinate of the right edge. */
|
| + num get right => left + width;
|
| + /** The y-coordinate of the bottom edge. */
|
| + num get bottom => top + height;
|
| +
|
| + String toString() {
|
| + return 'Rectangle ($left, $top) $width x $height';
|
| + }
|
| +
|
| + bool operator ==(other) {
|
| + if (other is !Rectangle) return false;
|
| + return left == other.left && top == other.top && right == other.right &&
|
| + bottom == other.bottom;
|
| + }
|
| +
|
| + int get hashCode => _JenkinsSmiHash.hash4(left.hashCode, top.hashCode,
|
| + right.hashCode, bottom.hashCode);
|
| +
|
| + /**
|
| + * Computes the intersection of `this` and [other].
|
| + *
|
| + * The intersection of two axis-aligned rectangles, if any, is always another
|
| + * axis-aligned rectangle.
|
| + *
|
| + * Returns the intersection of this and `other`, or `null` if they don't
|
| + * intersect.
|
| + */
|
| + Rectangle<num> intersection(Rectangle<num> other) {
|
| + var x0 = max(left, other.left);
|
| + var x1 = min(left + width, other.left + other.width);
|
| +
|
| + if (x0 <= x1) {
|
| + var y0 = max(top, other.top);
|
| + var y1 = min(top + height, other.top + other.height);
|
| +
|
| + if (y0 <= y1) {
|
| + return new Rectangle<num>(x0, y0, x1 - x0, y1 - y0);
|
| + }
|
| + }
|
| + return null;
|
| + }
|
| +
|
| +
|
| + /**
|
| + * Returns true if `this` intersects [other].
|
| + */
|
| + bool intersects(Rectangle<num> other) {
|
| + return (left <= other.left + other.width &&
|
| + other.left <= left + width &&
|
| + top <= other.top + other.height &&
|
| + other.top <= top + height);
|
| + }
|
| +
|
| + /**
|
| + * Returns a new rectangle which completely contains `this` and [other].
|
| + */
|
| + Rectangle<num> boundingBox(Rectangle<num> other) {
|
| + var right = max(this.left + this.width, other.left + other.width);
|
| + var bottom = max(this.top + this.height, other.top + other.height);
|
| +
|
| + var left = min(this.left, other.left);
|
| + var top = min(this.top, other.top);
|
| +
|
| + return new Rectangle<num>(left, top, right - left, bottom - top);
|
| + }
|
| +
|
| + /**
|
| + * Tests whether `this` entirely contains [another].
|
| + */
|
| + bool containsRectangle(Rectangle<num> another) {
|
| + return left <= another.left &&
|
| + left + width >= another.left + another.width &&
|
| + top <= another.top &&
|
| + top + height >= another.top + another.height;
|
| + }
|
| +
|
| + /**
|
| + * Tests whether [another] is inside or along the edges of `this`.
|
| + */
|
| + bool containsPoint(Point<num> another) {
|
| + return another.x >= left &&
|
| + another.x <= left + width &&
|
| + another.y >= top &&
|
| + another.y <= top + height;
|
| + }
|
| +
|
| + Point<num> get topLeft => new Point<num>(this.left, this.top);
|
| + Point<num> get topRight => new Point<num>(this.left + this.width, this.top);
|
| + Point<num> get bottomRight => new Point<num>(this.left + this.width,
|
| + this.top + this.height);
|
| + Point<num> get bottomLeft => new Point<num>(this.left,
|
| + this.top + this.height);
|
| }
|
|
|
| final _HEIGHT = ['top', 'bottom'];
|
| @@ -44369,7 +44409,7 @@ class EventStreamProvider<T extends Event> {
|
| * [addEventListener](http://docs.webplatform.org/wiki/dom/methods/addEventListener)
|
| */
|
| Stream<T> forTarget(EventTarget e, {bool useCapture: false}) =>
|
| - new _EventStream(e, _eventType, useCapture);
|
| + new _EventStream<T>(e, _eventType, useCapture);
|
|
|
| /**
|
| * Gets an [ElementEventStream] for this event type, on the specified element.
|
| @@ -44393,7 +44433,7 @@ class EventStreamProvider<T extends Event> {
|
| * [addEventListener](http://docs.webplatform.org/wiki/dom/methods/addEventListener)
|
| */
|
| ElementStream<T> forElement(Element e, {bool useCapture: false}) {
|
| - return new _ElementEventStreamImpl(e, _eventType, useCapture);
|
| + return new _ElementEventStreamImpl<T>(e, _eventType, useCapture);
|
| }
|
|
|
| /**
|
| @@ -44464,8 +44504,8 @@ class _EventStream<T extends Event> extends Stream<T> {
|
| _EventStream(this._target, this._eventType, this._useCapture);
|
|
|
| // DOM events are inherently multi-subscribers.
|
| - Stream<T> asBroadcastStream({void onListen(StreamSubscription subscription),
|
| - void onCancel(StreamSubscription subscription)})
|
| + Stream<T> asBroadcastStream({void onListen(StreamSubscription<T> subscription),
|
| + void onCancel(StreamSubscription<T> subscription)})
|
| => this;
|
| bool get isBroadcast => true;
|
|
|
| @@ -44479,6 +44519,11 @@ class _EventStream<T extends Event> extends Stream<T> {
|
| }
|
| }
|
|
|
| +bool _matchesWithAncestors(Event event, String selector) {
|
| + var target = event.target;
|
| + return target is Element ? target.matchesWithAncestors(selector) : false;
|
| +}
|
| +
|
| /**
|
| * Adapter for exposing DOM Element events as streams, while also allowing
|
| * event delegation.
|
| @@ -44489,7 +44534,7 @@ class _ElementEventStreamImpl<T extends Event> extends _EventStream<T>
|
| super(target, eventType, useCapture);
|
|
|
| Stream<T> matches(String selector) => this.where(
|
| - (event) => event.target.matchesWithAncestors(selector)).map((e) {
|
| + (event) => _matchesWithAncestors(event, selector)).map((e) {
|
| e._selector = selector;
|
| return e;
|
| });
|
| @@ -44513,7 +44558,7 @@ class _ElementListEventStreamImpl<T extends Event> extends Stream<T>
|
| this._targetList, this._eventType, this._useCapture);
|
|
|
| Stream<T> matches(String selector) => this.where(
|
| - (event) => event.target.matchesWithAncestors(selector)).map((e) {
|
| + (event) => _matchesWithAncestors(event, selector)).map((e) {
|
| e._selector = selector;
|
| return e;
|
| });
|
| @@ -44523,37 +44568,46 @@ class _ElementListEventStreamImpl<T extends Event> extends Stream<T>
|
| { Function onError,
|
| void onDone(),
|
| bool cancelOnError}) {
|
| - var pool = new _StreamPool.broadcast();
|
| + var pool = new _StreamPool<T>.broadcast();
|
| for (var target in _targetList) {
|
| - pool.add(new _EventStream(target, _eventType, _useCapture));
|
| + pool.add(new _EventStream<T>(target, _eventType, _useCapture));
|
| }
|
| return pool.stream.listen(onData, onError: onError, onDone: onDone,
|
| cancelOnError: cancelOnError);
|
| }
|
|
|
| StreamSubscription<T> capture(void onData(T event)) {
|
| - var pool = new _StreamPool.broadcast();
|
| + var pool = new _StreamPool<T>.broadcast();
|
| for (var target in _targetList) {
|
| - pool.add(new _EventStream(target, _eventType, true));
|
| + pool.add(new _EventStream<T>(target, _eventType, true));
|
| }
|
| return pool.stream.listen(onData);
|
| }
|
|
|
| - Stream<T> asBroadcastStream({void onListen(StreamSubscription subscription),
|
| - void onCancel(StreamSubscription subscription)})
|
| + Stream<T> asBroadcastStream({void onListen(StreamSubscription<T> subscription),
|
| + void onCancel(StreamSubscription<T> subscription)})
|
| => this;
|
| bool get isBroadcast => true;
|
| }
|
|
|
| +// We would like this to just be EventListener<T> but that typdef cannot
|
| +// use generics until dartbug/26276 is fixed.
|
| +typedef _EventListener<T extends Event>(T event);
|
| +
|
| class _EventStreamSubscription<T extends Event> extends StreamSubscription<T> {
|
| int _pauseCount = 0;
|
| EventTarget _target;
|
| final String _eventType;
|
| - var _onData;
|
| + EventListener _onData;
|
| final bool _useCapture;
|
|
|
| - _EventStreamSubscription(this._target, this._eventType, onData,
|
| - this._useCapture) : _onData = _wrapZone(onData) {
|
| + // TODO(jacobr): for full strong mode correctness we should write
|
| + // _onData = onData == null ? null : _wrapZone/*<Event, dynamic>*/((e) => onData(e as T))
|
| + // but that breaks 114 co19 tests as well as multiple html tests as it is reasonable
|
| + // to pass the wrong type of event object to an event listener as part of a
|
| + // test.
|
| + _EventStreamSubscription(this._target, this._eventType, void onData(T event),
|
| + this._useCapture) : _onData = _wrapZone/*<Event, dynamic>*/(onData) {
|
| _tryResume();
|
| }
|
|
|
| @@ -44575,8 +44629,7 @@ class _EventStreamSubscription<T extends Event> extends StreamSubscription<T> {
|
| }
|
| // Remove current event listener.
|
| _unlisten();
|
| -
|
| - _onData = _wrapZone(handleData);
|
| + _onData = _wrapZone/*<Event, dynamic>*/(handleData);
|
| _tryResume();
|
| }
|
|
|
| @@ -44655,8 +44708,8 @@ class _CustomEventStreamImpl<T extends Event> extends Stream<T>
|
| onDone: onDone, cancelOnError: cancelOnError);
|
| }
|
|
|
| - Stream<T> asBroadcastStream({void onListen(StreamSubscription subscription),
|
| - void onCancel(StreamSubscription subscription)})
|
| + Stream<T> asBroadcastStream({void onListen(StreamSubscription<T> subscription),
|
| + void onCancel(StreamSubscription<T> subscription)})
|
| => _streamController.stream;
|
|
|
| bool get isBroadcast => true;
|
| @@ -44747,16 +44800,16 @@ class _CustomEventStreamProvider<T extends Event>
|
| const _CustomEventStreamProvider(this._eventTypeGetter);
|
|
|
| Stream<T> forTarget(EventTarget e, {bool useCapture: false}) {
|
| - return new _EventStream(e, _eventTypeGetter(e), useCapture);
|
| + return new _EventStream<T>(e, _eventTypeGetter(e), useCapture);
|
| }
|
|
|
| ElementStream<T> forElement(Element e, {bool useCapture: false}) {
|
| - return new _ElementEventStreamImpl(e, _eventTypeGetter(e), useCapture);
|
| + return new _ElementEventStreamImpl<T>(e, _eventTypeGetter(e), useCapture);
|
| }
|
|
|
| ElementStream<T> _forElementList(ElementList e,
|
| {bool useCapture: false}) {
|
| - return new _ElementListEventStreamImpl(e, _eventTypeGetter(e), useCapture);
|
| + return new _ElementListEventStreamImpl<T>(e, _eventTypeGetter(e), useCapture);
|
| }
|
|
|
| String getEventType(EventTarget target) {
|
| @@ -46135,7 +46188,7 @@ class _KeyboardEventHandler extends EventStreamProvider<KeyEvent> {
|
| * The set of keys that have been pressed down without seeing their
|
| * corresponding keyup event.
|
| */
|
| - final List<KeyboardEvent> _keyDownList = <KeyboardEvent>[];
|
| + final List<KeyEvent> _keyDownList = <KeyEvent>[];
|
|
|
| /** The type of KeyEvent we are tracking (keyup, keydown, keypress). */
|
| final String _type;
|
| @@ -46194,8 +46247,9 @@ class _KeyboardEventHandler extends EventStreamProvider<KeyEvent> {
|
| * General constructor, performs basic initialization for our improved
|
| * KeyboardEvent controller.
|
| */
|
| - _KeyboardEventHandler(this._type): super(_EVENT_TYPE),
|
| - _stream = new _CustomKeyEventStreamImpl('event'), _target = null;
|
| + _KeyboardEventHandler(this._type):
|
| + _stream = new _CustomKeyEventStreamImpl('event'), _target = null,
|
| + super(_EVENT_TYPE);
|
|
|
| /**
|
| * Hook up all event listeners under the covers so we can estimate keycodes
|
| @@ -46656,16 +46710,10 @@ class NodeValidatorBuilder implements NodeValidator {
|
| Iterable<String> uriAttributes}) {
|
|
|
| var tagNameUpper = tagName.toUpperCase();
|
| - var attrs;
|
| - if (attributes != null) {
|
| - attrs =
|
| - attributes.map((name) => '$tagNameUpper::${name.toLowerCase()}');
|
| - }
|
| - var uriAttrs;
|
| - if (uriAttributes != null) {
|
| - uriAttrs =
|
| - uriAttributes.map((name) => '$tagNameUpper::${name.toLowerCase()}');
|
| - }
|
| + var attrs = attributes != null ?
|
| + attributes.map/*<String>*/((name) => '$tagNameUpper::${name.toLowerCase()}') : null;
|
| + var uriAttrs = uriAttributes != null ?
|
| + uriAttributes.map/*<String>*/((name) => '$tagNameUpper::${name.toLowerCase()}') : null;
|
| if (uriPolicy == null) {
|
| uriPolicy = new UriPolicy();
|
| }
|
| @@ -46694,16 +46742,8 @@ class NodeValidatorBuilder implements NodeValidator {
|
|
|
| var baseNameUpper = baseName.toUpperCase();
|
| var tagNameUpper = tagName.toUpperCase();
|
| - var attrs;
|
| - if (attributes != null) {
|
| - attrs =
|
| - attributes.map((name) => '$baseNameUpper::${name.toLowerCase()}');
|
| - }
|
| - var uriAttrs;
|
| - if (uriAttributes != null) {
|
| - uriAttrs =
|
| - uriAttributes.map((name) => '$baseNameUpper::${name.toLowerCase()}');
|
| - }
|
| + var attrs = attributes != null ? attributes.map/*<String>*/((name) => '$baseNameUpper::${name.toLowerCase()}') : null;
|
| + var uriAttrs = uriAttributes != null ? uriAttributes.map/*<String>*/((name) => '$baseNameUpper::${name.toLowerCase()}') : null;
|
| if (uriPolicy == null) {
|
| uriPolicy = new UriPolicy();
|
| }
|
| @@ -46889,13 +46929,12 @@ class _CustomElementNodeValidator extends _SimpleNodeValidator {
|
| Iterable<String> allowedUriAttributes,
|
| bool allowTypeExtension,
|
| bool allowCustomTag):
|
| -
|
| + this.allowTypeExtension = allowTypeExtension == true,
|
| + this.allowCustomTag = allowCustomTag == true,
|
| super(uriPolicy,
|
| allowedElements: allowedElements,
|
| allowedAttributes: allowedAttributes,
|
| - allowedUriAttributes: allowedUriAttributes),
|
| - this.allowTypeExtension = allowTypeExtension == true,
|
| - this.allowCustomTag = allowCustomTag == true;
|
| + allowedUriAttributes: allowedUriAttributes);
|
|
|
| bool allowsElement(Element element) {
|
| if (allowTypeExtension) {
|
| @@ -46927,12 +46966,12 @@ class _TemplatingNodeValidator extends _SimpleNodeValidator {
|
| final Set<String> _templateAttrs;
|
|
|
| _TemplatingNodeValidator():
|
| + _templateAttrs = new Set<String>.from(_TEMPLATE_ATTRS),
|
| super(null,
|
| allowedElements: [
|
| 'TEMPLATE'
|
| ],
|
| - allowedAttributes: _TEMPLATE_ATTRS.map((attr) => 'TEMPLATE::$attr')),
|
| - _templateAttrs = new Set<String>.from(_TEMPLATE_ATTRS) {
|
| + allowedAttributes: _TEMPLATE_ATTRS.map((attr) => 'TEMPLATE::$attr')) {
|
| }
|
|
|
| bool allowsAttribute(Element element, String attributeName, String value) {
|
| @@ -47308,7 +47347,7 @@ class _ValidatingTreeSanitizer implements NodeTreeSanitizer {
|
| */
|
| class _WrappedList<E extends Node> extends ListBase<E>
|
| implements NodeListWrapper {
|
| - final List _list;
|
| + final List<Node> _list;
|
|
|
| _WrappedList(this._list);
|
|
|
| @@ -47328,13 +47367,13 @@ class _WrappedList<E extends Node> extends ListBase<E>
|
|
|
| // List APIs
|
|
|
| - E operator [](int index) => _list[index];
|
| + E operator [](int index) => _list[index] as E;
|
|
|
| void operator []=(int index, E value) { _list[index] = value; }
|
|
|
| set length(int newLength) { _list.length = newLength; }
|
|
|
| - void sort([int compare(E a, E b)]) { _list.sort(compare); }
|
| + void sort([int compare(E a, E b)]) { _list.sort((Node a, Node b) => compare(a as E, b as E)); }
|
|
|
| int indexOf(Object element, [int start = 0]) => _list.indexOf(element, start);
|
|
|
| @@ -47342,7 +47381,7 @@ class _WrappedList<E extends Node> extends ListBase<E>
|
|
|
| void insert(int index, E element) => _list.insert(index, element);
|
|
|
| - E removeAt(int index) => _list.removeAt(index);
|
| + E removeAt(int index) => _list.removeAt(index) as E;
|
|
|
| void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) {
|
| _list.setRange(start, end, iterable, skipCount);
|
| @@ -47365,7 +47404,7 @@ class _WrappedList<E extends Node> extends ListBase<E>
|
| * Iterator wrapper for _WrappedList.
|
| */
|
| class _WrappedIterator<E> implements Iterator<E> {
|
| - Iterator _iterator;
|
| + Iterator<Node> _iterator;
|
|
|
| _WrappedIterator(this._iterator);
|
|
|
| @@ -47373,7 +47412,7 @@ class _WrappedIterator<E> implements Iterator<E> {
|
| return _iterator.moveNext();
|
| }
|
|
|
| - E get current => _iterator.current;
|
| + E get current => _iterator.current as E;
|
| }
|
| // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| @@ -47815,17 +47854,25 @@ class _WrappedEvent implements Event {
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
| -_wrapZone(callback(arg)) {
|
| +// TODO(jacobr): remove these typedefs when dart:async supports generic types.
|
| +typedef R _wrapZoneCallback<A, R>(A a);
|
| +typedef R _wrapZoneBinaryCallback<A, B, R>(A a, B b);
|
| +
|
| +_wrapZoneCallback/*<A, R>*/ _wrapZone/*<A, R>*/(_wrapZoneCallback/*<A, R>*/ callback) {
|
| // For performance reasons avoid wrapping if we are in the root zone.
|
| if (Zone.current == Zone.ROOT) return callback;
|
| if (callback == null) return null;
|
| - return Zone.current.bindUnaryCallback(callback, runGuarded: true);
|
| + // TODO(jacobr): we cast to _wrapZoneCallback/*<A, R>*/ to hack around missing
|
| + // generic method support in zones.
|
| + return Zone.current.bindUnaryCallback(callback, runGuarded: true) as _wrapZoneCallback/*<A, R>*/;
|
| }
|
|
|
| -_wrapBinaryZone(callback(arg1, arg2)) {
|
| +_wrapZoneBinaryCallback/*<A, B, R>*/ _wrapBinaryZone/*<A, B, R>*/(_wrapZoneBinaryCallback/*<A, B, R>*/ callback) {
|
| if (Zone.current == Zone.ROOT) return callback;
|
| if (callback == null) return null;
|
| - return Zone.current.bindBinaryCallback(callback, runGuarded: true);
|
| + // We cast to _wrapZoneBinaryCallback/*<A, B, R>*/ to hack around missing
|
| + // generic method support in zones.
|
| + return Zone.current.bindBinaryCallback(callback, runGuarded: true) as _wrapZoneBinaryCallback/*<A, B, R>*/;
|
| }
|
|
|
| /**
|
|
|