diff --git a/tools/dom/nnbd_src/AttributeMap.dart b/tools/dom/nnbd_src/AttributeMap.dart deleted file mode 100644 index 88f3bd406a1..00000000000 --- a/tools/dom/nnbd_src/AttributeMap.dart +++ /dev/null @@ -1,299 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -part of html; - -abstract class _AttributeMap extends MapBase { - final Element _element; - - _AttributeMap(this._element); - - void addAll(Map other) { - other.forEach((k, v) { - this[k] = v; - }); - } - - Map cast() => Map.castFrom(this); - bool containsValue(Object? value) { - for (var v in this.values) { - if (value == v) { - return true; - } - } - return false; - } - - String putIfAbsent(String key, String ifAbsent()) { - if (!containsKey(key)) { - this[key] = ifAbsent(); - } - return this[key] as String; - } - - void clear() { - for (var key in keys) { - remove(key); - } - } - - void forEach(void f(String key, String value)) { - for (var key in keys) { - var value = this[key]; - f(key, value as String); - } - } - - Iterable get keys { - // TODO: generate a lazy collection instead. - var attributes = _element._attributes; - var keys = []; - for (int i = 0, len = attributes.length; i < len; i++) { - _Attr attr = attributes[i] as _Attr; - if (_matches(attr)) { - keys.add(attr.name); - } - } - return keys; - } - - Iterable get values { - // TODO: generate a lazy collection instead. - var attributes = _element._attributes; - var values = []; - for (int i = 0, len = attributes.length; i < len; i++) { - _Attr attr = attributes[i] as _Attr; - if (_matches(attr)) { - values.add(attr.value); - } - } - return values; - } - - /** - * Returns true if there is no {key, value} pair in the map. - */ - bool get isEmpty { - return length == 0; - } - - /** - * Returns true if there is at least one {key, value} pair in the map. - */ - bool get isNotEmpty => !isEmpty; - - /** - * Checks to see if the node should be included in this map. - */ - bool _matches(_Attr node); -} - -/** - * Wrapper to expose [Element.attributes] as a typed map. - */ -class _ElementAttributeMap extends _AttributeMap { - _ElementAttributeMap(Element element) : super(element); - - bool containsKey(Object? key) { - return key is String && _element._hasAttribute(key); - } - - String? operator [](Object? key) { - return _element.getAttribute(key as String); - } - - void operator []=(String key, String value) { - _element.setAttribute(key, value); - } - - @pragma('dart2js:tryInline') - String? remove(Object? key) => key is String ? _remove(_element, key) : null; - - /** - * The number of {key, value} pairs in the map. - */ - int get length { - return keys.length; - } - - bool _matches(_Attr node) => node._namespaceUri == null; - - // Inline this because almost all call sites of [remove] do not use [value], - // and the annotations on the `getAttribute` call allow it to be removed. - @pragma('dart2js:tryInline') - static String? _remove(Element element, String key) { - String? value = JS( - // throws:null(1) is not accurate since [key] could be malformed, but - // [key] is checked again by `removeAttributeNS`. - 'returns:String|Null;depends:all;effects:none;throws:null(1)', - '#.getAttribute(#)', - element, - key); - JS('', '#.removeAttribute(#)', element, key); - return value; - } -} - -/** - * Wrapper to expose namespaced attributes as a typed map. - */ -class _NamespacedAttributeMap extends _AttributeMap { - final String? _namespace; - - _NamespacedAttributeMap(Element element, this._namespace) : super(element); - - bool containsKey(Object? key) { - return key is String && _element._hasAttributeNS(_namespace, key); - } - - String? operator [](Object? key) { - return _element.getAttributeNS(_namespace, key as String); - } - - void operator []=(String key, String value) { - _element.setAttributeNS(_namespace, key, value); - } - - @pragma('dart2js:tryInline') - String? remove(Object? key) => - key is String ? _remove(_namespace, _element, key) : null; - - /** - * The number of {key, value} pairs in the map. - */ - int get length { - return keys.length; - } - - bool _matches(_Attr node) => node._namespaceUri == _namespace; - - // Inline this because almost all call sites of [remove] do not use the - // returned [value], and the annotations on the `getAttributeNS` call allow it - // to be removed. - @pragma('dart2js:tryInline') - static String? _remove(String? namespace, Element element, String key) { - String? value = JS( - // throws:null(1) is not accurate since [key] could be malformed, but - // [key] is checked again by `removeAttributeNS`. - 'returns:String|Null;depends:all;effects:none;throws:null(1)', - '#.getAttributeNS(#, #)', - element, - namespace, - key); - JS('', '#.removeAttributeNS(#, #)', element, namespace, key); - return value; - } -} - -/** - * Provides a Map abstraction on top of data-* attributes, similar to the - * dataSet in the old DOM. - */ -class _DataAttributeMap extends MapBase { - final Map _attributes; - - _DataAttributeMap(this._attributes); - - // interface Map - - void addAll(Map other) { - other.forEach((k, v) { - this[k] = v; - }); - } - - Map cast() => Map.castFrom(this); - // TODO: Use lazy iterator when it is available on Map. - bool containsValue(Object? value) => values.any((v) => v == value); - - bool containsKey(Object? key) => - _attributes.containsKey(_attr(key as String)); - - String? operator [](Object? key) => _attributes[_attr(key as String)]; - - void operator []=(String key, String value) { - _attributes[_attr(key)] = value; - } - - String putIfAbsent(String key, String ifAbsent()) => - _attributes.putIfAbsent(_attr(key), ifAbsent); - - String? remove(Object? key) => _attributes.remove(_attr(key as String)); - - void clear() { - // Needs to operate on a snapshot since we are mutating the collection. - for (String key in keys) { - remove(key); - } - } - - void forEach(void f(String key, String value)) { - _attributes.forEach((String key, String value) { - if (_matches(key)) { - f(_strip(key), value); - } - }); - } - - Iterable get keys { - final keys = []; - _attributes.forEach((String key, String value) { - if (_matches(key)) { - keys.add(_strip(key)); - } - }); - return keys; - } - - Iterable get values { - final values = []; - _attributes.forEach((String key, String value) { - if (_matches(key)) { - values.add(value); - } - }); - return values; - } - - int get length => keys.length; - - // TODO: Use lazy iterator when it is available on Map. - bool get isEmpty => length == 0; - - bool get isNotEmpty => !isEmpty; - - // Helpers. - String _attr(String key) => 'data-${_toHyphenedName(key)}'; - bool _matches(String key) => key.startsWith('data-'); - String _strip(String key) => _toCamelCase(key.substring(5)); - - /** - * Converts a string name with hyphens into an identifier, by removing hyphens - * and capitalizing the following letter. Optionally [startUppercase] to - * capitalize the first letter. - */ - String _toCamelCase(String hyphenedName, {bool startUppercase: false}) { - var segments = hyphenedName.split('-'); - int start = startUppercase ? 0 : 1; - for (int i = start; i < segments.length; i++) { - var segment = segments[i]; - if (segment.length > 0) { - // Character between 'a'..'z' mapped to 'A'..'Z' - segments[i] = '${segment[0].toUpperCase()}${segment.substring(1)}'; - } - } - return segments.join(''); - } - - /** Reverse of [toCamelCase]. */ - String _toHyphenedName(String word) { - var sb = new StringBuffer(); - for (int i = 0; i < word.length; i++) { - var lower = word[i].toLowerCase(); - if (word[i] != lower && i > 0) sb.write('-'); - sb.write(lower); - } - return sb.toString(); - } -} diff --git a/tools/dom/nnbd_src/CanvasImageSource.dart b/tools/dom/nnbd_src/CanvasImageSource.dart deleted file mode 100644 index ffcd34a417b..00000000000 --- a/tools/dom/nnbd_src/CanvasImageSource.dart +++ /dev/null @@ -1,42 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -part of html; - -/** - * An object that can be drawn to a 2D canvas rendering context. - * - * The image drawn to the canvas depends on the type of this object: - * - * * If this object is an [ImageElement], then this element's image is - * drawn to the canvas. If this element is an animated image, then this - * element's poster frame is drawn. If this element has no poster frame, then - * the first frame of animation is drawn. - * - * * If this object is a [VideoElement], then the frame at this element's current - * playback position is drawn to the canvas. - * - * * If this object is a [CanvasElement], then this element's bitmap is drawn to - * the canvas. - * - * **Note:** Currently all versions of Internet Explorer do not support - * drawing a video element to a canvas. You may also encounter problems drawing - * a video to a canvas in Firefox if the source of the video is a data URL. - * - * ## See also - * - * * [CanvasRenderingContext2D.drawImage] - * * [CanvasRenderingContext2D.drawImageToRect] - * * [CanvasRenderingContext2D.drawImageScaled] - * * [CanvasRenderingContext2D.drawImageScaledFromSource] - * - * ## Other resources - * - * * [Image sources for 2D rendering - * contexts](https://html.spec.whatwg.org/multipage/scripting.html#image-sources-for-2d-rendering-contexts) - * from WHATWG. - * * [Drawing images](https://html.spec.whatwg.org/multipage/scripting.html#dom-context-2d-drawimage) - * from WHATWG. - */ -abstract class CanvasImageSource {} diff --git a/tools/dom/nnbd_src/CrossFrameTypes.dart b/tools/dom/nnbd_src/CrossFrameTypes.dart deleted file mode 100644 index 7d210a35f6b..00000000000 --- a/tools/dom/nnbd_src/CrossFrameTypes.dart +++ /dev/null @@ -1,156 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -part of html; - -/** - * Top-level container for a browser tab or window. - * - * In a web browser, a [WindowBase] object represents any browser window. This - * object contains the window's state and its relation to other - * windows, such as which window opened this window. - * - * **Note:** This class represents any window, while [Window] is - * used to access the properties and content of the current window or tab. - * - * ## See also - * - * * [Window] - * - * ## Other resources - * - * * [DOM Window](https://developer.mozilla.org/en-US/docs/DOM/window) from MDN. - * * [Window](http://www.w3.org/TR/Window/) from the W3C. - */ -abstract class WindowBase implements EventTarget { - // Fields. - - /** - * The current location of this window. - * - * Location currentLocation = window.location; - * print(currentLocation.href); // 'http://www.example.com:80/' - */ - LocationBase get location; - - /** - * The current session history for this window. - * - * ## Other resources - * - * * [Session history and navigation - * specification](https://html.spec.whatwg.org/multipage/browsers.html#history) - * from WHATWG. - */ - HistoryBase get history; - - /** - * Indicates whether this window has been closed. - * - * print(window.closed); // 'false' - * window.close(); - * print(window.closed); // 'true' - */ - bool get closed; - - /** - * A reference to the window that opened this one. - * - * Window thisWindow = window; - * WindowBase otherWindow = thisWindow.open('http://www.example.com/', 'foo'); - * print(otherWindow.opener == thisWindow); // 'true' - */ - WindowBase? get opener; - - /** - * A reference to the parent of this window. - * - * If this [WindowBase] has no parent, [parent] will return a reference to - * the [WindowBase] itself. - * - * IFrameElement myIFrame = new IFrameElement(); - * window.document.body.elements.add(myIFrame); - * print(myIframe.contentWindow.parent == window) // 'true' - * - * print(window.parent == window) // 'true' - */ - WindowBase? get parent; - - /** - * A reference to the topmost window in the window hierarchy. - * - * If this [WindowBase] is the topmost [WindowBase], [top] will return a - * reference to the [WindowBase] itself. - * - * // Add an IFrame to the current window. - * IFrameElement myIFrame = new IFrameElement(); - * window.document.body.elements.add(myIFrame); - * - * // Add an IFrame inside of the other IFrame. - * IFrameElement innerIFrame = new IFrameElement(); - * myIFrame.elements.add(innerIFrame); - * - * print(myIframe.contentWindow.top == window) // 'true' - * print(innerIFrame.contentWindow.top == window) // 'true' - * - * print(window.top == window) // 'true' - */ - WindowBase? get top; - - // Methods. - /** - * Closes the window. - * - * This method should only succeed if the [WindowBase] object is - * **script-closeable** and the window calling [close] is allowed to navigate - * the window. - * - * A window is script-closeable if it is either a window - * that was opened by another window, or if it is a window with only one - * document in its history. - * - * A window might not be allowed to navigate, and therefore close, another - * window due to browser security features. - * - * var other = window.open('http://www.example.com', 'foo'); - * // Closes other window, as it is script-closeable. - * other.close(); - * print(other.closed); // 'true' - * - * var newLocation = window.location - * ..href = 'http://www.mysite.com'; - * window.location = newLocation; - * // Does not close this window, as the history has changed. - * window.close(); - * print(window.closed); // 'false' - * - * See also: - * - * * [Window close discussion](http://www.w3.org/TR/html5/browsers.html#dom-window-close) from the W3C - */ - void close(); - - /** - * Sends a cross-origin message. - * - * ## Other resources - * - * * [window.postMessage](https://developer.mozilla.org/en-US/docs/Web/API/Window.postMessage) - * from MDN. - * * [Cross-document messaging](https://html.spec.whatwg.org/multipage/comms.html#web-messaging) - * from WHATWG. - */ - void postMessage(var message, String targetOrigin, - [List? messagePorts]); -} - -abstract class LocationBase { - void set href(String val); -} - -abstract class HistoryBase { - void back(); - void forward(); - void go(int distance); -} diff --git a/tools/dom/nnbd_src/CssClassSet.dart b/tools/dom/nnbd_src/CssClassSet.dart deleted file mode 100644 index 6a762020f68..00000000000 --- a/tools/dom/nnbd_src/CssClassSet.dart +++ /dev/null @@ -1,113 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -part of html; - -/** A Set that stores the CSS class names for an element. */ -abstract class CssClassSet implements Set { - /** - * Adds the class [value] to the element if it is not on it, removes it if it - * is. - * - * If [shouldAdd] is true, then we always add that [value] to the element. If - * [shouldAdd] is false then we always remove [value] from the element. - * - * If this corresponds to one element, returns `true` if [value] is present - * after the operation, and returns `false` if [value] is absent after the - * operation. - * - * If this CssClassSet corresponds to many elements, `false` is always - * returned. - * - * [value] must be a valid 'token' representing a single class, i.e. a - * non-empty string containing no whitespace. To toggle multiple classes, use - * [toggleAll]. - */ - bool toggle(String value, [bool? shouldAdd]); - - /** - * Returns [:true:] if classes cannot be added or removed from this - * [:CssClassSet:]. - */ - bool get frozen; - - /** - * Determine if this element contains the class [value]. - * - * This is the Dart equivalent of jQuery's - * [hasClass](http://api.jquery.com/hasClass/). - * - * [value] must be a valid 'token' representing a single class, i.e. a - * non-empty string containing no whitespace. - */ - bool contains(Object? value); - - /** - * Add the class [value] to element. - * - * [add] and [addAll] are the Dart equivalent of jQuery's - * [addClass](http://api.jquery.com/addClass/). - * - * If this CssClassSet corresponds to one element. Returns true if [value] was - * added to the set, otherwise false. - * - * If this CssClassSet corresponds to many elements, `false` is always - * returned. - * - * [value] must be a valid 'token' representing a single class, i.e. a - * non-empty string containing no whitespace. To add multiple classes use - * [addAll]. - */ - bool add(String value); - - /** - * Remove the class [value] from element, and return true on successful - * removal. - * - * [remove] and [removeAll] are the Dart equivalent of jQuery's - * [removeClass](http://api.jquery.com/removeClass/). - * - * [value] must be a valid 'token' representing a single class, i.e. a - * non-empty string containing no whitespace. To remove multiple classes, use - * [removeAll]. - */ - bool remove(Object? value); - - /** - * Add all classes specified in [iterable] to element. - * - * [add] and [addAll] are the Dart equivalent of jQuery's - * [addClass](http://api.jquery.com/addClass/). - * - * Each element of [iterable] must be a valid 'token' representing a single - * class, i.e. a non-empty string containing no whitespace. - */ - void addAll(Iterable iterable); - - /** - * Remove all classes specified in [iterable] from element. - * - * [remove] and [removeAll] are the Dart equivalent of jQuery's - * [removeClass](http://api.jquery.com/removeClass/). - * - * 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 iterable); - - /** - * Toggles all classes specified in [iterable] on element. - * - * Iterate through [iterable]'s items, and add it if it is not on it, or - * remove it if it is. This is the Dart equivalent of jQuery's - * [toggleClass](http://api.jquery.com/toggleClass/). - * If [shouldAdd] is true, then we always add all the classes in [iterable] - * element. If [shouldAdd] is false then we always remove all the classes in - * [iterable] from the element. - * - * Each element of [iterable] must be a valid 'token' representing a single - * class, i.e. a non-empty string containing no whitespace. - */ - void toggleAll(Iterable iterable, [bool? shouldAdd]); -} diff --git a/tools/dom/nnbd_src/CssRectangle.dart b/tools/dom/nnbd_src/CssRectangle.dart deleted file mode 100644 index d26aac734c7..00000000000 --- a/tools/dom/nnbd_src/CssRectangle.dart +++ /dev/null @@ -1,372 +0,0 @@ -// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -part of html; - -/** - * A rectangle representing all the content of the element in the - * [box model](http://www.w3.org/TR/CSS2/box.html). - */ -class _ContentCssRect extends CssRect { - _ContentCssRect(Element element) : super(element); - - num get height => - _element.offsetHeight + _addOrSubtractToBoxModel(_HEIGHT, _CONTENT); - - num get width => - _element.offsetWidth + _addOrSubtractToBoxModel(_WIDTH, _CONTENT); - - /** - * Set the height to `newHeight`. - * - * newHeight can be either a [num] representing the height in pixels or a - * [Dimension] object. Values of newHeight that are less than zero are - * converted to effectively setting the height to 0. This is equivalent to the - * `height` function in jQuery and the calculated `height` CSS value, - * converted to a num in pixels. - */ - set height(dynamic newHeight) { - if (newHeight is Dimension) { - Dimension newHeightAsDimension = newHeight; - if (newHeightAsDimension.value < 0) newHeight = new Dimension.px(0); - _element.style.height = newHeight.toString(); - } 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"); - } - } - - /** - * Set the current computed width in pixels of this element. - * - * newWidth can be either a [num] representing the width in pixels or a - * [Dimension] object. This is equivalent to the `width` function in jQuery - * and the calculated - * `width` CSS value, converted to a dimensionless num in pixels. - */ - set width(dynamic newWidth) { - if (newWidth is Dimension) { - Dimension newWidthAsDimension = newWidth; - if (newWidthAsDimension.value < 0) newWidth = new Dimension.px(0); - _element.style.width = newWidth.toString(); - } 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"); - } - } - - num get left => - _element.getBoundingClientRect().left - - _addOrSubtractToBoxModel(['left'], _CONTENT); - num get top => - _element.getBoundingClientRect().top - - _addOrSubtractToBoxModel(['top'], _CONTENT); -} - -/** - * A list of element content rectangles in the - * [box model](http://www.w3.org/TR/CSS2/box.html). - */ -class _ContentCssListRect extends _ContentCssRect { - List _elementList; - - _ContentCssListRect(List elementList) - : _elementList = elementList, - super(elementList.first); - - /** - * Set the height to `newHeight`. - * - * Values of newHeight that are less than zero are converted to effectively - * setting the height to 0. This is equivalent to the `height` - * function in jQuery and the calculated `height` CSS value, converted to a - * num in pixels. - */ - set height(newHeight) { - _elementList.forEach((e) => e.contentEdge.height = newHeight); - } - - /** - * Set the current computed width in pixels of this element. - * - * This is equivalent to the `width` function in jQuery and the calculated - * `width` CSS value, converted to a dimensionless num in pixels. - */ - set width(newWidth) { - _elementList.forEach((e) => e.contentEdge.width = newWidth); - } -} - -/** - * A rectangle representing the dimensions of the space occupied by the - * element's content + padding in the - * [box model](http://www.w3.org/TR/CSS2/box.html). - */ -class _PaddingCssRect extends CssRect { - _PaddingCssRect(element) : super(element); - num get height => - _element.offsetHeight + _addOrSubtractToBoxModel(_HEIGHT, _PADDING); - num get width => - _element.offsetWidth + _addOrSubtractToBoxModel(_WIDTH, _PADDING); - - num get left => - _element.getBoundingClientRect().left - - _addOrSubtractToBoxModel(['left'], _PADDING); - num get top => - _element.getBoundingClientRect().top - - _addOrSubtractToBoxModel(['top'], _PADDING); -} - -/** - * A rectangle representing the dimensions of the space occupied by the - * element's content + padding + border in the - * [box model](http://www.w3.org/TR/CSS2/box.html). - */ -class _BorderCssRect extends CssRect { - _BorderCssRect(element) : super(element); - num get height => _element.offsetHeight; - num get width => _element.offsetWidth; - - num get left => _element.getBoundingClientRect().left; - num get top => _element.getBoundingClientRect().top; -} - -/** - * A rectangle representing the dimensions of the space occupied by the - * element's content + padding + border + margin in the - * [box model](http://www.w3.org/TR/CSS2/box.html). - */ -class _MarginCssRect extends CssRect { - _MarginCssRect(element) : super(element); - num get height => - _element.offsetHeight + _addOrSubtractToBoxModel(_HEIGHT, _MARGIN); - num get width => - _element.offsetWidth + _addOrSubtractToBoxModel(_WIDTH, _MARGIN); - - num get left => - _element.getBoundingClientRect().left - - _addOrSubtractToBoxModel(['left'], _MARGIN); - num get top => - _element.getBoundingClientRect().top - - _addOrSubtractToBoxModel(['top'], _MARGIN); -} - -/** - * A class for representing CSS dimensions. - * - * In contrast to the more general purpose [Rectangle] class, this class's - * values are mutable, so one can change the height of an element - * programmatically. - * - * _Important_ _note_: use of these methods will perform CSS calculations that - * can trigger a browser reflow. Therefore, use of these properties _during_ an - * animation frame is discouraged. See also: - * [Browser Reflow](https://developers.google.com/speed/articles/reflow) - */ -abstract class CssRect implements Rectangle { - Element _element; - - CssRect(this._element); - - num get left; - - num get top; - - /** - * The height of this rectangle. - * - * This is equivalent to the `height` function in jQuery and the calculated - * `height` CSS value, converted to a dimensionless num in pixels. Unlike - * [getBoundingClientRect], `height` will return the same numerical width if - * the element is hidden or not. - */ - num get height; - - /** - * The width of this rectangle. - * - * This is equivalent to the `width` function in jQuery and the calculated - * `width` CSS value, converted to a dimensionless num in pixels. Unlike - * [getBoundingClientRect], `width` will return the same numerical width if - * the element is hidden or not. - */ - num get width; - - /** - * Set the height to `newHeight`. - * - * newHeight can be either a [num] representing the height in pixels or a - * [Dimension] object. Values of newHeight that are less than zero are - * converted to effectively setting the height to 0. This is equivalent to the - * `height` function in jQuery and the calculated `height` CSS value, - * converted to a num in pixels. - * - * Note that only the content height can actually be set via this method. - */ - set height(dynamic newHeight) { - throw new UnsupportedError("Can only set height for content rect."); - } - - /** - * Set the current computed width in pixels of this element. - * - * newWidth can be either a [num] representing the width in pixels or a - * [Dimension] object. This is equivalent to the `width` function in jQuery - * and the calculated - * `width` CSS value, converted to a dimensionless num in pixels. - * - * Note that only the content width can be set via this method. - */ - set width(dynamic newWidth) { - throw new UnsupportedError("Can only set width for content rect."); - } - - /** - * Return a value that is used to modify the initial height or width - * measurement of an element. Depending on the value (ideally an enum) passed - * to augmentingMeasurement, we may need to add or subtract margin, padding, - * or border values, depending on the measurement we're trying to obtain. - */ - num _addOrSubtractToBoxModel( - List dimensions, String augmentingMeasurement) { - // getComputedStyle always returns pixel values (hence, computed), so we're - // always dealing with pixels in this method. - var styles = _element.getComputedStyle(); - - num val = 0; - - for (String measurement in dimensions) { - // The border-box and default box model both exclude margin in the regular - // height/width calculation, so add it if we want it for this measurement. - if (augmentingMeasurement == _MARGIN) { - val += new Dimension.css( - styles.getPropertyValue('$augmentingMeasurement-$measurement')) - .value; - } - - // The border-box includes padding and border, so remove it if we want - // just the content itself. - if (augmentingMeasurement == _CONTENT) { - val -= new Dimension.css( - styles.getPropertyValue('${_PADDING}-$measurement')) - .value; - } - - // At this point, we don't wan't to augment with border or margin, - // so remove border. - if (augmentingMeasurement != _MARGIN) { - val -= new Dimension.css( - styles.getPropertyValue('border-${measurement}-width')) - .value; - } - } - 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) => - other is Rectangle && - 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? intersection(Rectangle 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(x0, y0, x1 - x0, y1 - y0); - } - } - return null; - } - - /** - * Returns true if `this` intersects [other]. - */ - bool intersects(Rectangle 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 boundingBox(Rectangle 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(left, top, right - left, bottom - top); - } - - /** - * Tests whether `this` entirely contains [another]. - */ - bool containsRectangle(Rectangle 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 another) { - return another.x >= left && - another.x <= left + width && - another.y >= top && - another.y <= top + height; - } - - Point get topLeft => new Point(this.left, this.top); - Point get topRight => new Point(this.left + this.width, this.top); - Point get bottomRight => - new Point(this.left + this.width, this.top + this.height); - Point get bottomLeft => - new Point(this.left, this.top + this.height); -} - -final _HEIGHT = ['top', 'bottom']; -final _WIDTH = ['right', 'left']; -final _CONTENT = 'content'; -final _PADDING = 'padding'; -final _MARGIN = 'margin'; diff --git a/tools/dom/nnbd_src/Dimension.dart b/tools/dom/nnbd_src/Dimension.dart deleted file mode 100644 index 7ed0219229f..00000000000 --- a/tools/dom/nnbd_src/Dimension.dart +++ /dev/null @@ -1,84 +0,0 @@ -part of html; - -/** - * Class representing a - * [length measurement](https://developer.mozilla.org/en-US/docs/Web/CSS/length) - * in CSS. - */ -class Dimension { - num _value; - String _unit; - - /** Set this CSS Dimension to a percentage `value`. */ - Dimension.percent(this._value) : _unit = '%'; - - /** Set this CSS Dimension to a pixel `value`. */ - Dimension.px(this._value) : _unit = 'px'; - - /** Set this CSS Dimension to a pica `value`. */ - Dimension.pc(this._value) : _unit = 'pc'; - - /** Set this CSS Dimension to a point `value`. */ - Dimension.pt(this._value) : _unit = 'pt'; - - /** Set this CSS Dimension to an inch `value`. */ - Dimension.inch(this._value) : _unit = 'in'; - - /** Set this CSS Dimension to a centimeter `value`. */ - Dimension.cm(this._value) : _unit = 'cm'; - - /** Set this CSS Dimension to a millimeter `value`. */ - Dimension.mm(this._value) : _unit = 'mm'; - - /** - * Set this CSS Dimension to the specified number of ems. - * - * 1em is equal to the current font size. (So 2ems is equal to double the font - * size). This is useful for producing website layouts that scale nicely with - * the user's desired font size. - */ - Dimension.em(this._value) : _unit = 'em'; - - /** - * Set this CSS Dimension to the specified number of x-heights. - * - * One ex is equal to the x-height of a font's baseline to its mean line, - * generally the height of the letter "x" in the font, which is usually about - * half the font-size. - */ - Dimension.ex(this._value) : _unit = 'ex'; - - /** - * Construct a Dimension object from the valid, simple CSS string `cssValue` - * that represents a distance measurement. - * - * This constructor is intended as a convenience method for working with - * simplistic CSS length measurements. Non-numeric values such as `auto` or - * `inherit` or invalid CSS will cause this constructor to throw a - * FormatError. - */ - Dimension.css(String cssValue) - : _unit = '', - _value = 0 { - if (cssValue == '') cssValue = '0px'; - if (cssValue.endsWith('%')) { - _unit = '%'; - } else { - _unit = cssValue.substring(cssValue.length - 2); - } - if (cssValue.contains('.')) { - _value = - double.parse(cssValue.substring(0, cssValue.length - _unit.length)); - } else { - _value = int.parse(cssValue.substring(0, cssValue.length - _unit.length)); - } - } - - /** Print out the CSS String representation of this value. */ - String toString() { - return '${_value}${_unit}'; - } - - /** Return a unitless, numerical value of this CSS value. */ - num get value => this._value; -} diff --git a/tools/dom/nnbd_src/EventListener.dart b/tools/dom/nnbd_src/EventListener.dart deleted file mode 100644 index 60b29f1fd3f..00000000000 --- a/tools/dom/nnbd_src/EventListener.dart +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -part of html; - -typedef EventListener(Event event); diff --git a/tools/dom/nnbd_src/EventStreamProvider.dart b/tools/dom/nnbd_src/EventStreamProvider.dart deleted file mode 100644 index fe01be9be79..00000000000 --- a/tools/dom/nnbd_src/EventStreamProvider.dart +++ /dev/null @@ -1,461 +0,0 @@ -// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -part of html; - -/** - * A factory to expose DOM events as Streams. - */ -class EventStreamProvider { - final String _eventType; - - const EventStreamProvider(this._eventType); - - /** - * Gets a [Stream] for this event type, on the specified target. - * - * This will always return a broadcast stream so multiple listeners can be - * used simultaneously. - * - * This may be used to capture DOM events: - * - * Element.keyDownEvent.forTarget(element, useCapture: true).listen(...); - * - * // Alternate method: - * Element.keyDownEvent.forTarget(element).capture(...); - * - * Or for listening to an event which will bubble through the DOM tree: - * - * MediaElement.pauseEvent.forTarget(document.body).listen(...); - * - * See also: - * - * * [EventTarget.addEventListener](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener) - * from MDN. - */ - Stream forTarget(EventTarget? e, {bool useCapture: false}) => - new _EventStream(e, _eventType, useCapture); - - /** - * Gets an [ElementEventStream] for this event type, on the specified element. - * - * This will always return a broadcast stream so multiple listeners can be - * used simultaneously. - * - * This may be used to capture DOM events: - * - * Element.keyDownEvent.forElement(element, useCapture: true).listen(...); - * - * // Alternate method: - * Element.keyDownEvent.forElement(element).capture(...); - * - * Or for listening to an event which will bubble through the DOM tree: - * - * MediaElement.pauseEvent.forElement(document.body).listen(...); - * - * See also: - * - * * [EventTarget.addEventListener](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener) - * from MDN. - */ - ElementStream forElement(Element e, {bool useCapture: false}) { - return new _ElementEventStreamImpl(e, _eventType, useCapture); - } - - /** - * Gets an [ElementEventStream] for this event type, on the list of elements. - * - * This will always return a broadcast stream so multiple listeners can be - * used simultaneously. - * - * This may be used to capture DOM events: - * - * Element.keyDownEvent._forElementList(element, useCapture: true).listen(...); - * - * See also: - * - * * [EventTarget.addEventListener](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener) - * from MDN. - */ - ElementStream _forElementList(ElementList e, - {bool useCapture: false}) { - return new _ElementListEventStreamImpl(e, _eventType, useCapture); - } - - /** - * Gets the type of the event which this would listen for on the specified - * event target. - * - * The target is necessary because some browsers may use different event names - * for the same purpose and the target allows differentiating browser support. - */ - String getEventType(EventTarget target) { - return _eventType; - } -} - -/** A specialized Stream available to [Element]s to enable event delegation. */ -abstract class ElementStream implements Stream { - /** - * Return a stream that only fires when the particular event fires for - * elements matching the specified CSS selector. - * - * This is the Dart equivalent to jQuery's - * [delegate](http://api.jquery.com/delegate/). - */ - Stream matches(String selector); - - /** - * Adds a capturing subscription to this stream. - * - * If the target of the event is a descendant of the element from which this - * stream derives then [onData] is called before the event propagates down to - * the target. This is the opposite of bubbling behavior, where the event - * is first processed for the event target and then bubbles upward. - * - * ## Other resources - * - * * [Event Capture](http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-flow-capture) - * from the W3C DOM Events specification. - */ - StreamSubscription capture(void onData(T event)); -} - -/** - * Adapter for exposing DOM events as Dart streams. - */ -class _EventStream extends Stream { - final EventTarget? _target; - final String _eventType; - final bool _useCapture; - - _EventStream(this._target, this._eventType, this._useCapture); - - // DOM events are inherently multi-subscribers. - Stream asBroadcastStream( - {void onListen(StreamSubscription subscription)?, - void onCancel(StreamSubscription subscription)?}) => - this; - bool get isBroadcast => true; - - // TODO(9757): Inlining should be smart and inline only when inlining would - // enable scalar replacement of an immediately allocated receiver. - @pragma('dart2js:tryInline') - StreamSubscription listen(void onData(T event)?, - {Function? onError, void onDone()?, bool? cancelOnError}) { - return new _EventStreamSubscription( - this._target, this._eventType, onData, this._useCapture); - } -} - -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. - */ -class _ElementEventStreamImpl extends _EventStream - implements ElementStream { - _ElementEventStreamImpl(target, eventType, useCapture) - : super(target, eventType, useCapture); - - Stream matches(String selector) => - this.where((event) => _matchesWithAncestors(event, selector)).map((e) { - e._selector = selector; - return e; - }); - - StreamSubscription capture(void onData(T event)) => - new _EventStreamSubscription( - this._target, this._eventType, onData, true); -} - -/** - * Adapter for exposing events on a collection of DOM Elements as streams, - * while also allowing event delegation. - */ -class _ElementListEventStreamImpl extends Stream - implements ElementStream { - final Iterable _targetList; - final bool _useCapture; - final String _eventType; - - _ElementListEventStreamImpl( - this._targetList, this._eventType, this._useCapture); - - Stream matches(String selector) => - this.where((event) => _matchesWithAncestors(event, selector)).map((e) { - e._selector = selector; - return e; - }); - - // Delegate all regular Stream behavior to a wrapped Stream. - StreamSubscription listen(void onData(T event)?, - {Function? onError, void onDone()?, bool? cancelOnError}) { - var pool = new _StreamPool.broadcast(); - for (var target in _targetList) { - pool.add(new _EventStream(target, _eventType, _useCapture)); - } - return pool.stream.listen(onData, - onError: onError, onDone: onDone, cancelOnError: cancelOnError); - } - - StreamSubscription capture(void onData(T event)) { - var pool = new _StreamPool.broadcast(); - for (var target in _targetList) { - pool.add(new _EventStream(target, _eventType, true)); - } - return pool.stream.listen(onData); - } - - Stream asBroadcastStream( - {void onListen(StreamSubscription subscription)?, - void onCancel(StreamSubscription subscription)?}) => - this; - bool get isBroadcast => true; -} - -// We would like this to just be EventListener but that typdef cannot -// use generics until dartbug/26276 is fixed. -typedef _EventListener(T event); - -class _EventStreamSubscription extends StreamSubscription { - int _pauseCount = 0; - EventTarget? _target; - final String _eventType; - EventListener? _onData; - final bool _useCapture; - - // TODO(leafp): It would be better to write this as - // _onData = onData == null ? null : - // onData is void Function(Event) - // ? _wrapZone(onData) - // : _wrapZone((e) => onData(e as T)) - // In order to support existing tests which pass the wrong type of events but - // use a more general listener, without causing as much slowdown for things - // which are typed correctly. But this currently runs afoul of restrictions - // on is checks for compatibility with the VM. - _EventStreamSubscription( - this._target, this._eventType, void onData(T event)?, this._useCapture) - : _onData = onData == null - ? null - : _wrapZone((e) => (onData as dynamic)(e)) { - _tryResume(); - } - - Future cancel() { - // Check for strong mode. This function can no longer return null in strong - // mode, so only return null in weak mode to preserve synchronous timing. - // See issue 41653 for more details. - dynamic emptyFuture = - typeAcceptsNull() ? null : Future.value(); - if (_canceled) return emptyFuture as Future; - - _unlisten(); - // Clear out the target to indicate this is complete. - _target = null; - _onData = null; - return emptyFuture as Future; - } - - bool get _canceled => _target == null; - - void onData(void handleData(T event)?) { - if (_canceled) { - throw new StateError("Subscription has been canceled."); - } - // Remove current event listener. - _unlisten(); - _onData = handleData == null - ? null - : _wrapZone((e) => (handleData as dynamic)(e)); - _tryResume(); - } - - /// Has no effect. - void onError(Function? handleError) {} - - /// Has no effect. - void onDone(void handleDone()?) {} - - void pause([Future? resumeSignal]) { - if (_canceled) return; - ++_pauseCount; - _unlisten(); - - if (resumeSignal != null) { - resumeSignal.whenComplete(resume); - } - } - - bool get isPaused => _pauseCount > 0; - - void resume() { - if (_canceled || !isPaused) return; - --_pauseCount; - _tryResume(); - } - - void _tryResume() { - if (_onData != null && !isPaused) { - _target!.addEventListener(_eventType, _onData, _useCapture); - } - } - - void _unlisten() { - if (_onData != null) { - _target!.removeEventListener(_eventType, _onData, _useCapture); - } - } - - Future asFuture([E? futureValue]) { - // We just need a future that will never succeed or fail. - var completer = new Completer(); - return completer.future; - } -} - -/** - * A stream of custom events, which enables the user to "fire" (add) their own - * custom events to a stream. - */ -abstract class CustomStream implements Stream { - /** - * Add the following custom event to the stream for dispatching to interested - * listeners. - */ - void add(T event); -} - -class _CustomEventStreamImpl extends Stream - implements CustomStream { - StreamController _streamController; - /** The type of event this stream is providing (e.g. "keydown"). */ - String _type; - - _CustomEventStreamImpl(String type) - : _type = type, - _streamController = new StreamController.broadcast(sync: true); - - // Delegate all regular Stream behavior to our wrapped Stream. - StreamSubscription listen(void onData(T event)?, - {Function? onError, void onDone()?, bool? cancelOnError}) { - return _streamController.stream.listen(onData, - onError: onError, onDone: onDone, cancelOnError: cancelOnError); - } - - Stream asBroadcastStream( - {void onListen(StreamSubscription subscription)?, - void onCancel(StreamSubscription subscription)?}) => - _streamController.stream; - - bool get isBroadcast => true; - - void add(T event) { - if (event.type == _type) _streamController.add(event); - } -} - -class _CustomKeyEventStreamImpl extends _CustomEventStreamImpl - implements CustomStream { - _CustomKeyEventStreamImpl(String type) : super(type); - - void add(KeyEvent event) { - if (event.type == _type) { - event.currentTarget!.dispatchEvent(event._parent); - _streamController.add(event); - } - } -} - -/** - * A pool of streams whose events are unified and emitted through a central - * stream. - */ -// TODO (efortuna): Remove this when Issue 12218 is addressed. -class _StreamPool { - StreamController? _controller; - - /// Subscriptions to the streams that make up the pool. - var _subscriptions = new Map, StreamSubscription>(); - - /** - * Creates a new stream pool where [stream] can be listened to more than - * once. - * - * Any events from buffered streams in the pool will be emitted immediately, - * regardless of whether [stream] has any subscribers. - */ - _StreamPool.broadcast() { - _controller = - new StreamController.broadcast(sync: true, onCancel: close); - } - - /** - * The stream through which all events from streams in the pool are emitted. - */ - Stream get stream => _controller!.stream; - - /** - * Adds [stream] as a member of this pool. - * - * Any events from [stream] will be emitted through [this.stream]. If - * [stream] is sync, they'll be emitted synchronously; if [stream] is async, - * they'll be emitted asynchronously. - */ - void add(Stream stream) { - if (_subscriptions.containsKey(stream)) return; - _subscriptions[stream] = stream.listen(_controller!.add, - onError: _controller!.addError, onDone: () => remove(stream)); - } - - /** Removes [stream] as a member of this pool. */ - void remove(Stream stream) { - var subscription = _subscriptions.remove(stream); - if (subscription != null) subscription.cancel(); - } - - /** Removes all streams from this pool and closes [stream]. */ - void close() { - for (var subscription in _subscriptions.values) { - subscription.cancel(); - } - _subscriptions.clear(); - _controller!.close(); - } -} - -/** - * A factory to expose DOM events as streams, where the DOM event name has to - * be determined on the fly (for example, mouse wheel events). - */ -class _CustomEventStreamProvider - implements EventStreamProvider { - final _eventTypeGetter; - const _CustomEventStreamProvider(this._eventTypeGetter); - - Stream forTarget(EventTarget? e, {bool useCapture: false}) { - return new _EventStream(e, _eventTypeGetter(e), useCapture); - } - - ElementStream forElement(Element e, {bool useCapture: false}) { - return new _ElementEventStreamImpl(e, _eventTypeGetter(e), useCapture); - } - - ElementStream _forElementList(ElementList e, - {bool useCapture: false}) { - return new _ElementListEventStreamImpl( - e, _eventTypeGetter(e), useCapture); - } - - String getEventType(EventTarget target) { - return _eventTypeGetter(target); - } - - String get _eventType => - throw new UnsupportedError('Access type through getEventType method.'); -} diff --git a/tools/dom/nnbd_src/Html5NodeValidator.dart b/tools/dom/nnbd_src/Html5NodeValidator.dart deleted file mode 100644 index e6bdede49f3..00000000000 --- a/tools/dom/nnbd_src/Html5NodeValidator.dart +++ /dev/null @@ -1,449 +0,0 @@ -// DO NOT EDIT- this file is generated from running tool/generator.sh. - -// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -part of dart.dom.html; - -/** - * A Dart DOM validator generated from Caja whitelists. - * - * This contains a whitelist of known HTML tagNames and attributes and will only - * accept known good values. - * - * See also: - * - * * - */ -class _Html5NodeValidator implements NodeValidator { - static final Set _allowedElements = new Set.from([ - 'A', - 'ABBR', - 'ACRONYM', - 'ADDRESS', - 'AREA', - 'ARTICLE', - 'ASIDE', - 'AUDIO', - 'B', - 'BDI', - 'BDO', - 'BIG', - 'BLOCKQUOTE', - 'BR', - 'BUTTON', - 'CANVAS', - 'CAPTION', - 'CENTER', - 'CITE', - 'CODE', - 'COL', - 'COLGROUP', - 'COMMAND', - 'DATA', - 'DATALIST', - 'DD', - 'DEL', - 'DETAILS', - 'DFN', - 'DIR', - 'DIV', - 'DL', - 'DT', - 'EM', - 'FIELDSET', - 'FIGCAPTION', - 'FIGURE', - 'FONT', - 'FOOTER', - 'FORM', - 'H1', - 'H2', - 'H3', - 'H4', - 'H5', - 'H6', - 'HEADER', - 'HGROUP', - 'HR', - 'I', - 'IFRAME', - 'IMG', - 'INPUT', - 'INS', - 'KBD', - 'LABEL', - 'LEGEND', - 'LI', - 'MAP', - 'MARK', - 'MENU', - 'METER', - 'NAV', - 'NOBR', - 'OL', - 'OPTGROUP', - 'OPTION', - 'OUTPUT', - 'P', - 'PRE', - 'PROGRESS', - 'Q', - 'S', - 'SAMP', - 'SECTION', - 'SELECT', - 'SMALL', - 'SOURCE', - 'SPAN', - 'STRIKE', - 'STRONG', - 'SUB', - 'SUMMARY', - 'SUP', - 'TABLE', - 'TBODY', - 'TD', - 'TEXTAREA', - 'TFOOT', - 'TH', - 'THEAD', - 'TIME', - 'TR', - 'TRACK', - 'TT', - 'U', - 'UL', - 'VAR', - 'VIDEO', - 'WBR', - ]); - - static const _standardAttributes = const [ - '*::class', - '*::dir', - '*::draggable', - '*::hidden', - '*::id', - '*::inert', - '*::itemprop', - '*::itemref', - '*::itemscope', - '*::lang', - '*::spellcheck', - '*::title', - '*::translate', - 'A::accesskey', - 'A::coords', - 'A::hreflang', - 'A::name', - 'A::shape', - 'A::tabindex', - 'A::target', - 'A::type', - 'AREA::accesskey', - 'AREA::alt', - 'AREA::coords', - 'AREA::nohref', - 'AREA::shape', - 'AREA::tabindex', - 'AREA::target', - 'AUDIO::controls', - 'AUDIO::loop', - 'AUDIO::mediagroup', - 'AUDIO::muted', - 'AUDIO::preload', - 'BDO::dir', - 'BODY::alink', - 'BODY::bgcolor', - 'BODY::link', - 'BODY::text', - 'BODY::vlink', - 'BR::clear', - 'BUTTON::accesskey', - 'BUTTON::disabled', - 'BUTTON::name', - 'BUTTON::tabindex', - 'BUTTON::type', - 'BUTTON::value', - 'CANVAS::height', - 'CANVAS::width', - 'CAPTION::align', - 'COL::align', - 'COL::char', - 'COL::charoff', - 'COL::span', - 'COL::valign', - 'COL::width', - 'COLGROUP::align', - 'COLGROUP::char', - 'COLGROUP::charoff', - 'COLGROUP::span', - 'COLGROUP::valign', - 'COLGROUP::width', - 'COMMAND::checked', - 'COMMAND::command', - 'COMMAND::disabled', - 'COMMAND::label', - 'COMMAND::radiogroup', - 'COMMAND::type', - 'DATA::value', - 'DEL::datetime', - 'DETAILS::open', - 'DIR::compact', - 'DIV::align', - 'DL::compact', - 'FIELDSET::disabled', - 'FONT::color', - 'FONT::face', - 'FONT::size', - 'FORM::accept', - 'FORM::autocomplete', - 'FORM::enctype', - 'FORM::method', - 'FORM::name', - 'FORM::novalidate', - 'FORM::target', - 'FRAME::name', - 'H1::align', - 'H2::align', - 'H3::align', - 'H4::align', - 'H5::align', - 'H6::align', - 'HR::align', - 'HR::noshade', - 'HR::size', - 'HR::width', - 'HTML::version', - 'IFRAME::align', - 'IFRAME::frameborder', - 'IFRAME::height', - 'IFRAME::marginheight', - 'IFRAME::marginwidth', - 'IFRAME::width', - 'IMG::align', - 'IMG::alt', - 'IMG::border', - 'IMG::height', - 'IMG::hspace', - 'IMG::ismap', - 'IMG::name', - 'IMG::usemap', - 'IMG::vspace', - 'IMG::width', - 'INPUT::accept', - 'INPUT::accesskey', - 'INPUT::align', - 'INPUT::alt', - 'INPUT::autocomplete', - 'INPUT::autofocus', - 'INPUT::checked', - 'INPUT::disabled', - 'INPUT::inputmode', - 'INPUT::ismap', - 'INPUT::list', - 'INPUT::max', - 'INPUT::maxlength', - 'INPUT::min', - 'INPUT::multiple', - 'INPUT::name', - 'INPUT::placeholder', - 'INPUT::readonly', - 'INPUT::required', - 'INPUT::size', - 'INPUT::step', - 'INPUT::tabindex', - 'INPUT::type', - 'INPUT::usemap', - 'INPUT::value', - 'INS::datetime', - 'KEYGEN::disabled', - 'KEYGEN::keytype', - 'KEYGEN::name', - 'LABEL::accesskey', - 'LABEL::for', - 'LEGEND::accesskey', - 'LEGEND::align', - 'LI::type', - 'LI::value', - 'LINK::sizes', - 'MAP::name', - 'MENU::compact', - 'MENU::label', - 'MENU::type', - 'METER::high', - 'METER::low', - 'METER::max', - 'METER::min', - 'METER::value', - 'OBJECT::typemustmatch', - 'OL::compact', - 'OL::reversed', - 'OL::start', - 'OL::type', - 'OPTGROUP::disabled', - 'OPTGROUP::label', - 'OPTION::disabled', - 'OPTION::label', - 'OPTION::selected', - 'OPTION::value', - 'OUTPUT::for', - 'OUTPUT::name', - 'P::align', - 'PRE::width', - 'PROGRESS::max', - 'PROGRESS::min', - 'PROGRESS::value', - 'SELECT::autocomplete', - 'SELECT::disabled', - 'SELECT::multiple', - 'SELECT::name', - 'SELECT::required', - 'SELECT::size', - 'SELECT::tabindex', - 'SOURCE::type', - 'TABLE::align', - 'TABLE::bgcolor', - 'TABLE::border', - 'TABLE::cellpadding', - 'TABLE::cellspacing', - 'TABLE::frame', - 'TABLE::rules', - 'TABLE::summary', - 'TABLE::width', - 'TBODY::align', - 'TBODY::char', - 'TBODY::charoff', - 'TBODY::valign', - 'TD::abbr', - 'TD::align', - 'TD::axis', - 'TD::bgcolor', - 'TD::char', - 'TD::charoff', - 'TD::colspan', - 'TD::headers', - 'TD::height', - 'TD::nowrap', - 'TD::rowspan', - 'TD::scope', - 'TD::valign', - 'TD::width', - 'TEXTAREA::accesskey', - 'TEXTAREA::autocomplete', - 'TEXTAREA::cols', - 'TEXTAREA::disabled', - 'TEXTAREA::inputmode', - 'TEXTAREA::name', - 'TEXTAREA::placeholder', - 'TEXTAREA::readonly', - 'TEXTAREA::required', - 'TEXTAREA::rows', - 'TEXTAREA::tabindex', - 'TEXTAREA::wrap', - 'TFOOT::align', - 'TFOOT::char', - 'TFOOT::charoff', - 'TFOOT::valign', - 'TH::abbr', - 'TH::align', - 'TH::axis', - 'TH::bgcolor', - 'TH::char', - 'TH::charoff', - 'TH::colspan', - 'TH::headers', - 'TH::height', - 'TH::nowrap', - 'TH::rowspan', - 'TH::scope', - 'TH::valign', - 'TH::width', - 'THEAD::align', - 'THEAD::char', - 'THEAD::charoff', - 'THEAD::valign', - 'TR::align', - 'TR::bgcolor', - 'TR::char', - 'TR::charoff', - 'TR::valign', - 'TRACK::default', - 'TRACK::kind', - 'TRACK::label', - 'TRACK::srclang', - 'UL::compact', - 'UL::type', - 'VIDEO::controls', - 'VIDEO::height', - 'VIDEO::loop', - 'VIDEO::mediagroup', - 'VIDEO::muted', - 'VIDEO::preload', - 'VIDEO::width', - ]; - - static const _uriAttributes = const [ - 'A::href', - 'AREA::href', - 'BLOCKQUOTE::cite', - 'BODY::background', - 'COMMAND::icon', - 'DEL::cite', - 'FORM::action', - 'IMG::src', - 'INPUT::src', - 'INS::cite', - 'Q::cite', - 'VIDEO::poster', - ]; - - final UriPolicy uriPolicy; - - static final Map _attributeValidators = {}; - - /** - * All known URI attributes will be validated against the UriPolicy, if - * [uriPolicy] is null then a default UriPolicy will be used. - */ - _Html5NodeValidator({UriPolicy? uriPolicy}) - : uriPolicy = uriPolicy ?? UriPolicy() { - if (_attributeValidators.isEmpty) { - for (var attr in _standardAttributes) { - _attributeValidators[attr] = _standardAttributeValidator; - } - - for (var attr in _uriAttributes) { - _attributeValidators[attr] = _uriAttributeValidator; - } - } - } - - bool allowsElement(Element element) { - return _allowedElements.contains(Element._safeTagName(element)); - } - - bool allowsAttribute(Element element, String attributeName, String value) { - var tagName = Element._safeTagName(element); - var validator = _attributeValidators['$tagName::$attributeName']; - if (validator == null) { - validator = _attributeValidators['*::$attributeName']; - } - if (validator == null) { - return false; - } - return validator(element, attributeName, value, this); - } - - static bool _standardAttributeValidator(Element element, String attributeName, - String value, _Html5NodeValidator context) { - return true; - } - - static bool _uriAttributeValidator(Element element, String attributeName, - String value, _Html5NodeValidator context) { - return context.uriPolicy.allowsUri(value); - } -} diff --git a/tools/dom/nnbd_src/ImmutableListMixin.dart b/tools/dom/nnbd_src/ImmutableListMixin.dart deleted file mode 100644 index 9910ebee48e..00000000000 --- a/tools/dom/nnbd_src/ImmutableListMixin.dart +++ /dev/null @@ -1,80 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -part of dart.dom.html; - -abstract class ImmutableListMixin implements List { - // From Iterable<$E>: - Iterator get iterator { - // Note: NodeLists are not fixed size. And most probably length shouldn't - // be cached in both iterator _and_ forEach method. For now caching it - // for consistency. - return new FixedSizeListIterator(this); - } - - // From List: - void add(E value) { - throw new UnsupportedError("Cannot add to immutable List."); - } - - void addAll(Iterable iterable) { - throw new UnsupportedError("Cannot add to immutable List."); - } - - void sort([int compare(E a, E b)?]) { - throw new UnsupportedError("Cannot sort immutable List."); - } - - void shuffle([Random? random]) { - throw new UnsupportedError("Cannot shuffle immutable List."); - } - - void insert(int index, E element) { - throw new UnsupportedError("Cannot add to immutable List."); - } - - void insertAll(int index, Iterable iterable) { - throw new UnsupportedError("Cannot add to immutable List."); - } - - void setAll(int index, Iterable iterable) { - throw new UnsupportedError("Cannot modify an immutable List."); - } - - E removeAt(int pos) { - throw new UnsupportedError("Cannot remove from immutable List."); - } - - E removeLast() { - throw new UnsupportedError("Cannot remove from immutable List."); - } - - bool remove(Object? object) { - throw new UnsupportedError("Cannot remove from immutable List."); - } - - void removeWhere(bool test(E element)) { - throw new UnsupportedError("Cannot remove from immutable List."); - } - - void retainWhere(bool test(E element)) { - throw new UnsupportedError("Cannot remove from immutable List."); - } - - void setRange(int start, int end, Iterable iterable, [int skipCount = 0]) { - throw new UnsupportedError("Cannot setRange on immutable List."); - } - - void removeRange(int start, int end) { - throw new UnsupportedError("Cannot removeRange on immutable List."); - } - - void replaceRange(int start, int end, Iterable iterable) { - throw new UnsupportedError("Cannot modify an immutable List."); - } - - void fillRange(int start, int end, [E? fillValue]) { - throw new UnsupportedError("Cannot modify an immutable List."); - } -} diff --git a/tools/dom/nnbd_src/KeyCode.dart b/tools/dom/nnbd_src/KeyCode.dart deleted file mode 100644 index a51d06273a1..00000000000 --- a/tools/dom/nnbd_src/KeyCode.dart +++ /dev/null @@ -1,331 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -part of html; - -/** - * Defines the keycode values for keys that are returned by - * KeyboardEvent.keyCode. - * - * Important note: There is substantial divergence in how different browsers - * handle keycodes and their variants in different locales/keyboard layouts. We - * provide these constants to help make code processing keys more readable. - */ -abstract class KeyCode { - // These constant names were borrowed from Closure's Keycode enumeration - // class. - // https://github.com/google/closure-library/blob/master/closure/goog/events/keycodes.js - static const int WIN_KEY_FF_LINUX = 0; - static const int MAC_ENTER = 3; - static const int BACKSPACE = 8; - static const int TAB = 9; - /** NUM_CENTER is also NUMLOCK for FF and Safari on Mac. */ - static const int NUM_CENTER = 12; - static const int ENTER = 13; - static const int SHIFT = 16; - static const int CTRL = 17; - static const int ALT = 18; - static const int PAUSE = 19; - static const int CAPS_LOCK = 20; - static const int ESC = 27; - static const int SPACE = 32; - static const int PAGE_UP = 33; - static const int PAGE_DOWN = 34; - static const int END = 35; - static const int HOME = 36; - static const int LEFT = 37; - static const int UP = 38; - static const int RIGHT = 39; - static const int DOWN = 40; - static const int NUM_NORTH_EAST = 33; - static const int NUM_SOUTH_EAST = 34; - static const int NUM_SOUTH_WEST = 35; - static const int NUM_NORTH_WEST = 36; - static const int NUM_WEST = 37; - static const int NUM_NORTH = 38; - static const int NUM_EAST = 39; - static const int NUM_SOUTH = 40; - static const int PRINT_SCREEN = 44; - static const int INSERT = 45; - static const int NUM_INSERT = 45; - static const int DELETE = 46; - static const int NUM_DELETE = 46; - static const int ZERO = 48; - static const int ONE = 49; - static const int TWO = 50; - static const int THREE = 51; - static const int FOUR = 52; - static const int FIVE = 53; - static const int SIX = 54; - static const int SEVEN = 55; - static const int EIGHT = 56; - static const int NINE = 57; - static const int FF_SEMICOLON = 59; - static const int FF_EQUALS = 61; - /** - * CAUTION: The question mark is for US-keyboard layouts. It varies - * for other locales and keyboard layouts. - */ - static const int QUESTION_MARK = 63; - static const int A = 65; - static const int B = 66; - static const int C = 67; - static const int D = 68; - static const int E = 69; - static const int F = 70; - static const int G = 71; - static const int H = 72; - static const int I = 73; - static const int J = 74; - static const int K = 75; - static const int L = 76; - static const int M = 77; - static const int N = 78; - static const int O = 79; - static const int P = 80; - static const int Q = 81; - static const int R = 82; - static const int S = 83; - static const int T = 84; - static const int U = 85; - static const int V = 86; - static const int W = 87; - static const int X = 88; - static const int Y = 89; - static const int Z = 90; - static const int META = 91; - static const int WIN_KEY_LEFT = 91; - static const int WIN_KEY_RIGHT = 92; - static const int CONTEXT_MENU = 93; - static const int NUM_ZERO = 96; - static const int NUM_ONE = 97; - static const int NUM_TWO = 98; - static const int NUM_THREE = 99; - static const int NUM_FOUR = 100; - static const int NUM_FIVE = 101; - static const int NUM_SIX = 102; - static const int NUM_SEVEN = 103; - static const int NUM_EIGHT = 104; - static const int NUM_NINE = 105; - static const int NUM_MULTIPLY = 106; - static const int NUM_PLUS = 107; - static const int NUM_MINUS = 109; - static const int NUM_PERIOD = 110; - static const int NUM_DIVISION = 111; - static const int F1 = 112; - static const int F2 = 113; - static const int F3 = 114; - static const int F4 = 115; - static const int F5 = 116; - static const int F6 = 117; - static const int F7 = 118; - static const int F8 = 119; - static const int F9 = 120; - static const int F10 = 121; - static const int F11 = 122; - static const int F12 = 123; - static const int NUMLOCK = 144; - static const int SCROLL_LOCK = 145; - - // OS-specific media keys like volume controls and browser controls. - static const int FIRST_MEDIA_KEY = 166; - static const int LAST_MEDIA_KEY = 183; - - /** - * CAUTION: This constant requires localization for other locales and keyboard - * layouts. - */ - static const int SEMICOLON = 186; - /** - * CAUTION: This constant requires localization for other locales and keyboard - * layouts. - */ - static const int DASH = 189; - /** - * CAUTION: This constant requires localization for other locales and keyboard - * layouts. - */ - static const int EQUALS = 187; - /** - * CAUTION: This constant requires localization for other locales and keyboard - * layouts. - */ - static const int COMMA = 188; - /** - * CAUTION: This constant requires localization for other locales and keyboard - * layouts. - */ - static const int PERIOD = 190; - /** - * CAUTION: This constant requires localization for other locales and keyboard - * layouts. - */ - static const int SLASH = 191; - /** - * CAUTION: This constant requires localization for other locales and keyboard - * layouts. - */ - static const int APOSTROPHE = 192; - /** - * CAUTION: This constant requires localization for other locales and keyboard - * layouts. - */ - static const int TILDE = 192; - /** - * CAUTION: This constant requires localization for other locales and keyboard - * layouts. - */ - static const int SINGLE_QUOTE = 222; - /** - * CAUTION: This constant requires localization for other locales and keyboard - * layouts. - */ - static const int OPEN_SQUARE_BRACKET = 219; - /** - * CAUTION: This constant requires localization for other locales and keyboard - * layouts. - */ - static const int BACKSLASH = 220; - /** - * CAUTION: This constant requires localization for other locales and keyboard - * layouts. - */ - static const int CLOSE_SQUARE_BRACKET = 221; - static const int WIN_KEY = 224; - static const int MAC_FF_META = 224; - static const int WIN_IME = 229; - - /** A sentinel value if the keycode could not be determined. */ - static const int UNKNOWN = -1; - - /** - * Returns true if the keyCode produces a (US keyboard) character. - * Note: This does not (yet) cover characters on non-US keyboards (Russian, - * Hebrew, etc.). - */ - static bool isCharacterKey(int keyCode) { - if ((keyCode >= ZERO && keyCode <= NINE) || - (keyCode >= NUM_ZERO && keyCode <= NUM_MULTIPLY) || - (keyCode >= A && keyCode <= Z)) { - return true; - } - - // Safari sends zero key code for non-latin characters. - if (Device.isWebKit && keyCode == 0) { - return true; - } - - return (keyCode == SPACE || - keyCode == QUESTION_MARK || - keyCode == NUM_PLUS || - keyCode == NUM_MINUS || - keyCode == NUM_PERIOD || - keyCode == NUM_DIVISION || - keyCode == SEMICOLON || - keyCode == FF_SEMICOLON || - keyCode == DASH || - keyCode == EQUALS || - keyCode == FF_EQUALS || - keyCode == COMMA || - keyCode == PERIOD || - keyCode == SLASH || - keyCode == APOSTROPHE || - keyCode == SINGLE_QUOTE || - keyCode == OPEN_SQUARE_BRACKET || - keyCode == BACKSLASH || - keyCode == CLOSE_SQUARE_BRACKET); - } - - /** - * Experimental helper function for converting keyCodes to keyNames for the - * keyIdentifier attribute still used in browsers not updated with current - * spec. This is an imperfect conversion! It will need to be refined, but - * hopefully it can just completely go away once all the browsers update to - * follow the DOM3 spec. - */ - static String _convertKeyCodeToKeyName(int keyCode) { - switch (keyCode) { - case KeyCode.ALT: - return _KeyName.ALT; - case KeyCode.BACKSPACE: - return _KeyName.BACKSPACE; - case KeyCode.CAPS_LOCK: - return _KeyName.CAPS_LOCK; - case KeyCode.CTRL: - return _KeyName.CONTROL; - case KeyCode.DELETE: - return _KeyName.DEL; - case KeyCode.DOWN: - return _KeyName.DOWN; - case KeyCode.END: - return _KeyName.END; - case KeyCode.ENTER: - return _KeyName.ENTER; - case KeyCode.ESC: - return _KeyName.ESC; - case KeyCode.F1: - return _KeyName.F1; - case KeyCode.F2: - return _KeyName.F2; - case KeyCode.F3: - return _KeyName.F3; - case KeyCode.F4: - return _KeyName.F4; - case KeyCode.F5: - return _KeyName.F5; - case KeyCode.F6: - return _KeyName.F6; - case KeyCode.F7: - return _KeyName.F7; - case KeyCode.F8: - return _KeyName.F8; - case KeyCode.F9: - return _KeyName.F9; - case KeyCode.F10: - return _KeyName.F10; - case KeyCode.F11: - return _KeyName.F11; - case KeyCode.F12: - return _KeyName.F12; - case KeyCode.HOME: - return _KeyName.HOME; - case KeyCode.INSERT: - return _KeyName.INSERT; - case KeyCode.LEFT: - return _KeyName.LEFT; - case KeyCode.META: - return _KeyName.META; - case KeyCode.NUMLOCK: - return _KeyName.NUM_LOCK; - case KeyCode.PAGE_DOWN: - return _KeyName.PAGE_DOWN; - case KeyCode.PAGE_UP: - return _KeyName.PAGE_UP; - case KeyCode.PAUSE: - return _KeyName.PAUSE; - case KeyCode.PRINT_SCREEN: - return _KeyName.PRINT_SCREEN; - case KeyCode.RIGHT: - return _KeyName.RIGHT; - case KeyCode.SCROLL_LOCK: - return _KeyName.SCROLL; - case KeyCode.SHIFT: - return _KeyName.SHIFT; - case KeyCode.SPACE: - return _KeyName.SPACEBAR; - case KeyCode.TAB: - return _KeyName.TAB; - case KeyCode.UP: - return _KeyName.UP; - case KeyCode.WIN_IME: - case KeyCode.WIN_KEY: - case KeyCode.WIN_KEY_LEFT: - case KeyCode.WIN_KEY_RIGHT: - return _KeyName.WIN; - default: - return _KeyName.UNIDENTIFIED; - } - return _KeyName.UNIDENTIFIED; - } -} diff --git a/tools/dom/nnbd_src/KeyLocation.dart b/tools/dom/nnbd_src/KeyLocation.dart deleted file mode 100644 index db4c423b406..00000000000 --- a/tools/dom/nnbd_src/KeyLocation.dart +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -part of html; - -/** - * Defines the standard key locations returned by - * KeyboardEvent.getKeyLocation. - */ -abstract class KeyLocation { - /** - * The event key is not distinguished as the left or right version - * of the key, and did not originate from the numeric keypad (or did not - * originate with a virtual key corresponding to the numeric keypad). - */ - static const int STANDARD = 0; - - /** - * The event key is in the left key location. - */ - static const int LEFT = 1; - - /** - * The event key is in the right key location. - */ - static const int RIGHT = 2; - - /** - * The event key originated on the numeric keypad or with a virtual key - * corresponding to the numeric keypad. - */ - static const int NUMPAD = 3; - - /** - * The event key originated on a mobile device, either on a physical - * keypad or a virtual keyboard. - */ - static const int MOBILE = 4; - - /** - * The event key originated on a game controller or a joystick on a mobile - * device. - */ - static const int JOYSTICK = 5; -} diff --git a/tools/dom/nnbd_src/KeyName.dart b/tools/dom/nnbd_src/KeyName.dart deleted file mode 100644 index 094d57ebb0d..00000000000 --- a/tools/dom/nnbd_src/KeyName.dart +++ /dev/null @@ -1,494 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -part of html; - -/** - * Defines the standard keyboard identifier names for keys that are returned - * by KeyboardEvent.getKeyboardIdentifier when the key does not have a direct - * unicode mapping. - */ -abstract class _KeyName { - /** The Accept (Commit, OK) key */ - static const String ACCEPT = "Accept"; - - /** The Add key */ - static const String ADD = "Add"; - - /** The Again key */ - static const String AGAIN = "Again"; - - /** The All Candidates key */ - static const String ALL_CANDIDATES = "AllCandidates"; - - /** The Alphanumeric key */ - static const String ALPHANUMERIC = "Alphanumeric"; - - /** The Alt (Menu) key */ - static const String ALT = "Alt"; - - /** The Alt-Graph key */ - static const String ALT_GRAPH = "AltGraph"; - - /** The Application key */ - static const String APPS = "Apps"; - - /** The ATTN key */ - static const String ATTN = "Attn"; - - /** The Browser Back key */ - static const String BROWSER_BACK = "BrowserBack"; - - /** The Browser Favorites key */ - static const String BROWSER_FAVORTIES = "BrowserFavorites"; - - /** The Browser Forward key */ - static const String BROWSER_FORWARD = "BrowserForward"; - - /** The Browser Home key */ - static const String BROWSER_NAME = "BrowserHome"; - - /** The Browser Refresh key */ - static const String BROWSER_REFRESH = "BrowserRefresh"; - - /** The Browser Search key */ - static const String BROWSER_SEARCH = "BrowserSearch"; - - /** The Browser Stop key */ - static const String BROWSER_STOP = "BrowserStop"; - - /** The Camera key */ - static const String CAMERA = "Camera"; - - /** The Caps Lock (Capital) key */ - static const String CAPS_LOCK = "CapsLock"; - - /** The Clear key */ - static const String CLEAR = "Clear"; - - /** The Code Input key */ - static const String CODE_INPUT = "CodeInput"; - - /** The Compose key */ - static const String COMPOSE = "Compose"; - - /** The Control (Ctrl) key */ - static const String CONTROL = "Control"; - - /** The Crsel key */ - static const String CRSEL = "Crsel"; - - /** The Convert key */ - static const String CONVERT = "Convert"; - - /** The Copy key */ - static const String COPY = "Copy"; - - /** The Cut key */ - static const String CUT = "Cut"; - - /** The Decimal key */ - static const String DECIMAL = "Decimal"; - - /** The Divide key */ - static const String DIVIDE = "Divide"; - - /** The Down Arrow key */ - static const String DOWN = "Down"; - - /** The diagonal Down-Left Arrow key */ - static const String DOWN_LEFT = "DownLeft"; - - /** The diagonal Down-Right Arrow key */ - static const String DOWN_RIGHT = "DownRight"; - - /** The Eject key */ - static const String EJECT = "Eject"; - - /** The End key */ - static const String END = "End"; - - /** - * The Enter key. Note: This key value must also be used for the Return - * (Macintosh numpad) key - */ - static const String ENTER = "Enter"; - - /** The Erase EOF key */ - static const String ERASE_EOF = "EraseEof"; - - /** The Execute key */ - static const String EXECUTE = "Execute"; - - /** The Exsel key */ - static const String EXSEL = "Exsel"; - - /** The Function switch key */ - static const String FN = "Fn"; - - /** The F1 key */ - static const String F1 = "F1"; - - /** The F2 key */ - static const String F2 = "F2"; - - /** The F3 key */ - static const String F3 = "F3"; - - /** The F4 key */ - static const String F4 = "F4"; - - /** The F5 key */ - static const String F5 = "F5"; - - /** The F6 key */ - static const String F6 = "F6"; - - /** The F7 key */ - static const String F7 = "F7"; - - /** The F8 key */ - static const String F8 = "F8"; - - /** The F9 key */ - static const String F9 = "F9"; - - /** The F10 key */ - static const String F10 = "F10"; - - /** The F11 key */ - static const String F11 = "F11"; - - /** The F12 key */ - static const String F12 = "F12"; - - /** The F13 key */ - static const String F13 = "F13"; - - /** The F14 key */ - static const String F14 = "F14"; - - /** The F15 key */ - static const String F15 = "F15"; - - /** The F16 key */ - static const String F16 = "F16"; - - /** The F17 key */ - static const String F17 = "F17"; - - /** The F18 key */ - static const String F18 = "F18"; - - /** The F19 key */ - static const String F19 = "F19"; - - /** The F20 key */ - static const String F20 = "F20"; - - /** The F21 key */ - static const String F21 = "F21"; - - /** The F22 key */ - static const String F22 = "F22"; - - /** The F23 key */ - static const String F23 = "F23"; - - /** The F24 key */ - static const String F24 = "F24"; - - /** The Final Mode (Final) key used on some asian keyboards */ - static const String FINAL_MODE = "FinalMode"; - - /** The Find key */ - static const String FIND = "Find"; - - /** The Full-Width Characters key */ - static const String FULL_WIDTH = "FullWidth"; - - /** The Half-Width Characters key */ - static const String HALF_WIDTH = "HalfWidth"; - - /** The Hangul (Korean characters) Mode key */ - static const String HANGUL_MODE = "HangulMode"; - - /** The Hanja (Korean characters) Mode key */ - static const String HANJA_MODE = "HanjaMode"; - - /** The Help key */ - static const String HELP = "Help"; - - /** The Hiragana (Japanese Kana characters) key */ - static const String HIRAGANA = "Hiragana"; - - /** The Home key */ - static const String HOME = "Home"; - - /** The Insert (Ins) key */ - static const String INSERT = "Insert"; - - /** The Japanese-Hiragana key */ - static const String JAPANESE_HIRAGANA = "JapaneseHiragana"; - - /** The Japanese-Katakana key */ - static const String JAPANESE_KATAKANA = "JapaneseKatakana"; - - /** The Japanese-Romaji key */ - static const String JAPANESE_ROMAJI = "JapaneseRomaji"; - - /** The Junja Mode key */ - static const String JUNJA_MODE = "JunjaMode"; - - /** The Kana Mode (Kana Lock) key */ - static const String KANA_MODE = "KanaMode"; - - /** - * The Kanji (Japanese name for ideographic characters of Chinese origin) - * Mode key - */ - static const String KANJI_MODE = "KanjiMode"; - - /** The Katakana (Japanese Kana characters) key */ - static const String KATAKANA = "Katakana"; - - /** The Start Application One key */ - static const String LAUNCH_APPLICATION_1 = "LaunchApplication1"; - - /** The Start Application Two key */ - static const String LAUNCH_APPLICATION_2 = "LaunchApplication2"; - - /** The Start Mail key */ - static const String LAUNCH_MAIL = "LaunchMail"; - - /** The Left Arrow key */ - static const String LEFT = "Left"; - - /** The Menu key */ - static const String MENU = "Menu"; - - /** - * The Meta key. Note: This key value shall be also used for the Apple - * Command key - */ - static const String META = "Meta"; - - /** The Media Next Track key */ - static const String MEDIA_NEXT_TRACK = "MediaNextTrack"; - - /** The Media Play Pause key */ - static const String MEDIA_PAUSE_PLAY = "MediaPlayPause"; - - /** The Media Previous Track key */ - static const String MEDIA_PREVIOUS_TRACK = "MediaPreviousTrack"; - - /** The Media Stop key */ - static const String MEDIA_STOP = "MediaStop"; - - /** The Mode Change key */ - static const String MODE_CHANGE = "ModeChange"; - - /** The Next Candidate function key */ - static const String NEXT_CANDIDATE = "NextCandidate"; - - /** The Nonconvert (Don't Convert) key */ - static const String NON_CONVERT = "Nonconvert"; - - /** The Number Lock key */ - static const String NUM_LOCK = "NumLock"; - - /** The Page Down (Next) key */ - static const String PAGE_DOWN = "PageDown"; - - /** The Page Up key */ - static const String PAGE_UP = "PageUp"; - - /** The Paste key */ - static const String PASTE = "Paste"; - - /** The Pause key */ - static const String PAUSE = "Pause"; - - /** The Play key */ - static const String PLAY = "Play"; - - /** - * The Power key. Note: Some devices may not expose this key to the - * operating environment - */ - static const String POWER = "Power"; - - /** The Previous Candidate function key */ - static const String PREVIOUS_CANDIDATE = "PreviousCandidate"; - - /** The Print Screen (PrintScrn, SnapShot) key */ - static const String PRINT_SCREEN = "PrintScreen"; - - /** The Process key */ - static const String PROCESS = "Process"; - - /** The Props key */ - static const String PROPS = "Props"; - - /** The Right Arrow key */ - static const String RIGHT = "Right"; - - /** The Roman Characters function key */ - static const String ROMAN_CHARACTERS = "RomanCharacters"; - - /** The Scroll Lock key */ - static const String SCROLL = "Scroll"; - - /** The Select key */ - static const String SELECT = "Select"; - - /** The Select Media key */ - static const String SELECT_MEDIA = "SelectMedia"; - - /** The Separator key */ - static const String SEPARATOR = "Separator"; - - /** The Shift key */ - static const String SHIFT = "Shift"; - - /** The Soft1 key */ - static const String SOFT_1 = "Soft1"; - - /** The Soft2 key */ - static const String SOFT_2 = "Soft2"; - - /** The Soft3 key */ - static const String SOFT_3 = "Soft3"; - - /** The Soft4 key */ - static const String SOFT_4 = "Soft4"; - - /** The Stop key */ - static const String STOP = "Stop"; - - /** The Subtract key */ - static const String SUBTRACT = "Subtract"; - - /** The Symbol Lock key */ - static const String SYMBOL_LOCK = "SymbolLock"; - - /** The Up Arrow key */ - static const String UP = "Up"; - - /** The diagonal Up-Left Arrow key */ - static const String UP_LEFT = "UpLeft"; - - /** The diagonal Up-Right Arrow key */ - static const String UP_RIGHT = "UpRight"; - - /** The Undo key */ - static const String UNDO = "Undo"; - - /** The Volume Down key */ - static const String VOLUME_DOWN = "VolumeDown"; - - /** The Volume Mute key */ - static const String VOLUMN_MUTE = "VolumeMute"; - - /** The Volume Up key */ - static const String VOLUMN_UP = "VolumeUp"; - - /** The Windows Logo key */ - static const String WIN = "Win"; - - /** The Zoom key */ - static const String ZOOM = "Zoom"; - - /** - * The Backspace (Back) key. Note: This key value shall be also used for the - * key labeled 'delete' MacOS keyboards when not modified by the 'Fn' key - */ - static const String BACKSPACE = "Backspace"; - - /** The Horizontal Tabulation (Tab) key */ - static const String TAB = "Tab"; - - /** The Cancel key */ - static const String CANCEL = "Cancel"; - - /** The Escape (Esc) key */ - static const String ESC = "Esc"; - - /** The Space (Spacebar) key: */ - static const String SPACEBAR = "Spacebar"; - - /** - * The Delete (Del) Key. Note: This key value shall be also used for the key - * labeled 'delete' MacOS keyboards when modified by the 'Fn' key - */ - static const String DEL = "Del"; - - /** The Combining Grave Accent (Greek Varia, Dead Grave) key */ - static const String DEAD_GRAVE = "DeadGrave"; - - /** - * The Combining Acute Accent (Stress Mark, Greek Oxia, Tonos, Dead Eacute) - * key - */ - static const String DEAD_EACUTE = "DeadEacute"; - - /** The Combining Circumflex Accent (Hat, Dead Circumflex) key */ - static const String DEAD_CIRCUMFLEX = "DeadCircumflex"; - - /** The Combining Tilde (Dead Tilde) key */ - static const String DEAD_TILDE = "DeadTilde"; - - /** The Combining Macron (Long, Dead Macron) key */ - static const String DEAD_MACRON = "DeadMacron"; - - /** The Combining Breve (Short, Dead Breve) key */ - static const String DEAD_BREVE = "DeadBreve"; - - /** The Combining Dot Above (Derivative, Dead Above Dot) key */ - static const String DEAD_ABOVE_DOT = "DeadAboveDot"; - - /** - * The Combining Diaeresis (Double Dot Abode, Umlaut, Greek Dialytika, - * Double Derivative, Dead Diaeresis) key - */ - static const String DEAD_UMLAUT = "DeadUmlaut"; - - /** The Combining Ring Above (Dead Above Ring) key */ - static const String DEAD_ABOVE_RING = "DeadAboveRing"; - - /** The Combining Double Acute Accent (Dead Doubleacute) key */ - static const String DEAD_DOUBLEACUTE = "DeadDoubleacute"; - - /** The Combining Caron (Hacek, V Above, Dead Caron) key */ - static const String DEAD_CARON = "DeadCaron"; - - /** The Combining Cedilla (Dead Cedilla) key */ - static const String DEAD_CEDILLA = "DeadCedilla"; - - /** The Combining Ogonek (Nasal Hook, Dead Ogonek) key */ - static const String DEAD_OGONEK = "DeadOgonek"; - - /** - * The Combining Greek Ypogegrammeni (Greek Non-Spacing Iota Below, Iota - * Subscript, Dead Iota) key - */ - static const String DEAD_IOTA = "DeadIota"; - - /** - * The Combining Katakana-Hiragana Voiced Sound Mark (Dead Voiced Sound) key - */ - static const String DEAD_VOICED_SOUND = "DeadVoicedSound"; - - /** - * The Combining Katakana-Hiragana Semi-Voiced Sound Mark (Dead Semivoiced - * Sound) key - */ - static const String DEC_SEMIVOICED_SOUND = "DeadSemivoicedSound"; - - /** - * Key value used when an implementation is unable to identify another key - * value, due to either hardware, platform, or software constraints - */ - static const String UNIDENTIFIED = "Unidentified"; -} diff --git a/tools/dom/nnbd_src/KeyboardEventStream.dart b/tools/dom/nnbd_src/KeyboardEventStream.dart deleted file mode 100644 index 399c03794c6..00000000000 --- a/tools/dom/nnbd_src/KeyboardEventStream.dart +++ /dev/null @@ -1,394 +0,0 @@ -// 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 -// BSD-style license that can be found in the LICENSE file. - -part of html; - -/** - * Internal class that does the actual calculations to determine keyCode and - * charCode for keydown, keypress, and keyup events for all browsers. - */ -class _KeyboardEventHandler extends EventStreamProvider { - // This code inspired by Closure's KeyHandling library. - // https://github.com/google/closure-library/blob/master/closure/goog/events/keyhandler.js - - /** - * The set of keys that have been pressed down without seeing their - * corresponding keyup event. - */ - final List _keyDownList = []; - - /** The type of KeyEvent we are tracking (keyup, keydown, keypress). */ - final String _type; - - /** The element we are watching for events to happen on. */ - final EventTarget? _target; - - // The distance to shift from upper case alphabet Roman letters to lower case. - static final int _ROMAN_ALPHABET_OFFSET = "a".codeUnits[0] - "A".codeUnits[0]; - - /** Custom Stream (Controller) to produce KeyEvents for the stream. */ - _CustomKeyEventStreamImpl _stream; - - static const _EVENT_TYPE = 'KeyEvent'; - - /** - * An enumeration of key identifiers currently part of the W3C draft for DOM3 - * and their mappings to keyCodes. - * https://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/keyset.html#KeySet-Set - */ - static const Map _keyIdentifier = const { - 'Up': KeyCode.UP, - 'Down': KeyCode.DOWN, - 'Left': KeyCode.LEFT, - 'Right': KeyCode.RIGHT, - 'Enter': KeyCode.ENTER, - 'F1': KeyCode.F1, - 'F2': KeyCode.F2, - 'F3': KeyCode.F3, - 'F4': KeyCode.F4, - 'F5': KeyCode.F5, - 'F6': KeyCode.F6, - 'F7': KeyCode.F7, - 'F8': KeyCode.F8, - 'F9': KeyCode.F9, - 'F10': KeyCode.F10, - 'F11': KeyCode.F11, - 'F12': KeyCode.F12, - 'U+007F': KeyCode.DELETE, - 'Home': KeyCode.HOME, - 'End': KeyCode.END, - 'PageUp': KeyCode.PAGE_UP, - 'PageDown': KeyCode.PAGE_DOWN, - 'Insert': KeyCode.INSERT - }; - - /** Return a stream for KeyEvents for the specified target. */ - // Note: this actually functions like a factory constructor. - CustomStream forTarget(EventTarget? e, {bool useCapture: false}) { - var handler = - new _KeyboardEventHandler.initializeAllEventListeners(_type, e); - return handler._stream; - } - - /** - * General constructor, performs basic initialization for our improved - * KeyboardEvent controller. - */ - _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 - * and charcodes when they are not provided. - */ - _KeyboardEventHandler.initializeAllEventListeners(this._type, this._target) - : _stream = new _CustomKeyEventStreamImpl(_type), - super(_EVENT_TYPE) { - Element.keyDownEvent - .forTarget(_target, useCapture: true) - .listen(processKeyDown); - Element.keyPressEvent - .forTarget(_target, useCapture: true) - .listen(processKeyPress); - Element.keyUpEvent - .forTarget(_target, useCapture: true) - .listen(processKeyUp); - } - - /** Determine if caps lock is one of the currently depressed keys. */ - bool get _capsLockOn => - _keyDownList.any((var element) => element.keyCode == KeyCode.CAPS_LOCK); - - /** - * Given the previously recorded keydown key codes, see if we can determine - * the keycode of this keypress [event]. (Generally browsers only provide - * charCode information for keypress events, but with a little - * reverse-engineering, we can also determine the keyCode.) Returns - * KeyCode.UNKNOWN if the keycode could not be determined. - */ - int _determineKeyCodeForKeypress(KeyboardEvent event) { - // Note: This function is a work in progress. We'll expand this function - // once we get more information about other keyboards. - for (var prevEvent in _keyDownList) { - if (prevEvent._shadowCharCode == event.charCode) { - return prevEvent.keyCode; - } - if ((event.shiftKey || _capsLockOn) && - event.charCode >= "A".codeUnits[0] && - event.charCode <= "Z".codeUnits[0] && - event.charCode + _ROMAN_ALPHABET_OFFSET == - prevEvent._shadowCharCode) { - return prevEvent.keyCode; - } - } - return KeyCode.UNKNOWN; - } - - /** - * Given the character code returned from a keyDown [event], try to ascertain - * and return the corresponding charCode for the character that was pressed. - * This information is not shown to the user, but used to help polyfill - * keypress events. - */ - int _findCharCodeKeyDown(KeyboardEvent event) { - if (event.location == 3) { - // Numpad keys. - switch (event.keyCode) { - case KeyCode.NUM_ZERO: - // Even though this function returns _charCodes_, for some cases the - // KeyCode == the charCode we want, in which case we use the keycode - // constant for readability. - return KeyCode.ZERO; - case KeyCode.NUM_ONE: - return KeyCode.ONE; - case KeyCode.NUM_TWO: - return KeyCode.TWO; - case KeyCode.NUM_THREE: - return KeyCode.THREE; - case KeyCode.NUM_FOUR: - return KeyCode.FOUR; - case KeyCode.NUM_FIVE: - return KeyCode.FIVE; - case KeyCode.NUM_SIX: - return KeyCode.SIX; - case KeyCode.NUM_SEVEN: - return KeyCode.SEVEN; - case KeyCode.NUM_EIGHT: - return KeyCode.EIGHT; - case KeyCode.NUM_NINE: - return KeyCode.NINE; - case KeyCode.NUM_MULTIPLY: - return 42; // Char code for * - case KeyCode.NUM_PLUS: - return 43; // + - case KeyCode.NUM_MINUS: - return 45; // - - case KeyCode.NUM_PERIOD: - return 46; // . - case KeyCode.NUM_DIVISION: - return 47; // / - } - } else if (event.keyCode >= 65 && event.keyCode <= 90) { - // Set the "char code" for key down as the lower case letter. Again, this - // will not show up for the user, but will be helpful in estimating - // keyCode locations and other information during the keyPress event. - return event.keyCode + _ROMAN_ALPHABET_OFFSET; - } - switch (event.keyCode) { - case KeyCode.SEMICOLON: - return KeyCode.FF_SEMICOLON; - case KeyCode.EQUALS: - return KeyCode.FF_EQUALS; - case KeyCode.COMMA: - return 44; // Ascii value for , - case KeyCode.DASH: - return 45; // - - case KeyCode.PERIOD: - return 46; // . - case KeyCode.SLASH: - return 47; // / - case KeyCode.APOSTROPHE: - return 96; // ` - case KeyCode.OPEN_SQUARE_BRACKET: - return 91; // [ - case KeyCode.BACKSLASH: - return 92; // \ - case KeyCode.CLOSE_SQUARE_BRACKET: - return 93; // ] - case KeyCode.SINGLE_QUOTE: - return 39; // ' - } - return event.keyCode; - } - - /** - * Returns true if the key fires a keypress event in the current browser. - */ - bool _firesKeyPressEvent(KeyEvent event) { - if (!Device.isIE && !Device.isWebKit) { - return true; - } - - if (Device.userAgent.contains('Mac') && event.altKey) { - return KeyCode.isCharacterKey(event.keyCode); - } - - // Alt but not AltGr which is represented as Alt+Ctrl. - if (event.altKey && !event.ctrlKey) { - return false; - } - - // Saves Ctrl or Alt + key for IE and WebKit, which won't fire keypress. - if (!event.shiftKey && - (_keyDownList.last.keyCode == KeyCode.CTRL || - _keyDownList.last.keyCode == KeyCode.ALT || - Device.userAgent.contains('Mac') && - _keyDownList.last.keyCode == KeyCode.META)) { - return false; - } - - // Some keys with Ctrl/Shift do not issue keypress in WebKit. - if (Device.isWebKit && - event.ctrlKey && - event.shiftKey && - (event.keyCode == KeyCode.BACKSLASH || - event.keyCode == KeyCode.OPEN_SQUARE_BRACKET || - event.keyCode == KeyCode.CLOSE_SQUARE_BRACKET || - event.keyCode == KeyCode.TILDE || - event.keyCode == KeyCode.SEMICOLON || - event.keyCode == KeyCode.DASH || - event.keyCode == KeyCode.EQUALS || - event.keyCode == KeyCode.COMMA || - event.keyCode == KeyCode.PERIOD || - event.keyCode == KeyCode.SLASH || - event.keyCode == KeyCode.APOSTROPHE || - event.keyCode == KeyCode.SINGLE_QUOTE)) { - return false; - } - - switch (event.keyCode) { - case KeyCode.ENTER: - // IE9 does not fire keypress on ENTER. - return !Device.isIE; - case KeyCode.ESC: - return !Device.isWebKit; - } - - return KeyCode.isCharacterKey(event.keyCode); - } - - /** - * Normalize the keycodes to the IE KeyCodes (this is what Chrome, IE, and - * Opera all use). - */ - int _normalizeKeyCodes(KeyboardEvent event) { - // Note: This may change once we get input about non-US keyboards. - if (Device.isFirefox) { - switch (event.keyCode) { - case KeyCode.FF_EQUALS: - return KeyCode.EQUALS; - case KeyCode.FF_SEMICOLON: - return KeyCode.SEMICOLON; - case KeyCode.MAC_FF_META: - return KeyCode.META; - case KeyCode.WIN_KEY_FF_LINUX: - return KeyCode.WIN_KEY; - } - } - return event.keyCode; - } - - /** Handle keydown events. */ - void processKeyDown(KeyboardEvent e) { - // Ctrl-Tab and Alt-Tab can cause the focus to be moved to another window - // before we've caught a key-up event. If the last-key was one of these - // we reset the state. - if (_keyDownList.length > 0 && - (_keyDownList.last.keyCode == KeyCode.CTRL && !e.ctrlKey || - _keyDownList.last.keyCode == KeyCode.ALT && !e.altKey || - Device.userAgent.contains('Mac') && - _keyDownList.last.keyCode == KeyCode.META && - !e.metaKey)) { - _keyDownList.clear(); - } - - var event = new KeyEvent.wrap(e); - event._shadowKeyCode = _normalizeKeyCodes(event); - // Technically a "keydown" event doesn't have a charCode. This is - // calculated nonetheless to provide us with more information in giving - // as much information as possible on keypress about keycode and also - // charCode. - event._shadowCharCode = _findCharCodeKeyDown(event); - if (_keyDownList.length > 0 && - event.keyCode != _keyDownList.last.keyCode && - !_firesKeyPressEvent(event)) { - // Some browsers have quirks not firing keypress events where all other - // browsers do. This makes them more consistent. - processKeyPress(e); - } - _keyDownList.add(event); - _stream.add(event); - } - - /** Handle keypress events. */ - void processKeyPress(KeyboardEvent event) { - var e = new KeyEvent.wrap(event); - // IE reports the character code in the keyCode field for keypress events. - // There are two exceptions however, Enter and Escape. - if (Device.isIE) { - if (e.keyCode == KeyCode.ENTER || e.keyCode == KeyCode.ESC) { - e._shadowCharCode = 0; - } else { - e._shadowCharCode = e.keyCode; - } - } else if (Device.isOpera) { - // Opera reports the character code in the keyCode field. - e._shadowCharCode = KeyCode.isCharacterKey(e.keyCode) ? e.keyCode : 0; - } - // Now we guesstimate about what the keycode is that was actually - // pressed, given previous keydown information. - e._shadowKeyCode = _determineKeyCodeForKeypress(e); - - // Correct the key value for certain browser-specific quirks. - if (e._shadowKeyIdentifier != null && - _keyIdentifier.containsKey(e._shadowKeyIdentifier)) { - // This is needed for Safari Windows because it currently doesn't give a - // keyCode/which for non printable keys. - e._shadowKeyCode = _keyIdentifier[e._shadowKeyIdentifier]!; - } - e._shadowAltKey = _keyDownList.any((var element) => element.altKey); - _stream.add(e); - } - - /** Handle keyup events. */ - void processKeyUp(KeyboardEvent event) { - var e = new KeyEvent.wrap(event); - KeyboardEvent? toRemove = null; - for (var key in _keyDownList) { - if (key.keyCode == e.keyCode) { - toRemove = key; - } - } - if (toRemove != null) { - _keyDownList.removeWhere((element) => element == toRemove); - } else if (_keyDownList.length > 0) { - // This happens when we've reached some international keyboard case we - // haven't accounted for or we haven't correctly eliminated all browser - // inconsistencies. Filing bugs on when this is reached is welcome! - _keyDownList.removeLast(); - } - _stream.add(e); - } -} - -/** - * Records KeyboardEvents that occur on a particular element, and provides a - * stream of outgoing KeyEvents with cross-browser consistent keyCode and - * charCode values despite the fact that a multitude of browsers that have - * varying keyboard default behavior. - * - * Example usage: - * - * KeyboardEventStream.onKeyDown(document.body).listen( - * keydownHandlerTest); - * - * This class is very much a work in progress, and we'd love to get information - * on how we can make this class work with as many international keyboards as - * possible. Bugs welcome! - */ -class KeyboardEventStream { - /** Named constructor to produce a stream for onKeyPress events. */ - static CustomStream onKeyPress(EventTarget target) => - new _KeyboardEventHandler('keypress').forTarget(target); - - /** Named constructor to produce a stream for onKeyUp events. */ - static CustomStream onKeyUp(EventTarget target) => - new _KeyboardEventHandler('keyup').forTarget(target); - - /** Named constructor to produce a stream for onKeyDown events. */ - static CustomStream onKeyDown(EventTarget target) => - new _KeyboardEventHandler('keydown').forTarget(target); -} diff --git a/tools/dom/nnbd_src/NodeValidatorBuilder.dart b/tools/dom/nnbd_src/NodeValidatorBuilder.dart deleted file mode 100644 index 59f2b27aafa..00000000000 --- a/tools/dom/nnbd_src/NodeValidatorBuilder.dart +++ /dev/null @@ -1,454 +0,0 @@ -// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -part of dart.dom.html; - -/** - * Class which helps construct standard node validation policies. - * - * By default this will not accept anything, but the 'allow*' functions can be - * used to expand what types of elements or attributes are allowed. - * - * All allow functions are additive- elements will be accepted if they are - * accepted by any specific rule. - * - * It is important to remember that sanitization is not just intended to prevent - * cross-site scripting attacks, but also to prevent information from being - * displayed in unexpected ways. For example something displaying basic - * formatted text may not expect `