| Index: client/html/generated/html/frog/Element.dart
|
| diff --git a/client/html/generated/html/frog/Element.dart b/client/html/generated/html/frog/Element.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..64c4faaa89480d75f93d6297ea7f93314eefc7e9
|
| --- /dev/null
|
| +++ b/client/html/generated/html/frog/Element.dart
|
| @@ -0,0 +1,687 @@
|
| +// 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.
|
| +
|
| +// TODO(jacobr): use Lists.dart to remove some of the duplicated functionality.
|
| +class _ChildrenElementList implements ElementList {
|
| + // Raw Element.
|
| + final _ElementJs _element;
|
| + final _HTMLCollectionJs _childElements;
|
| +
|
| + _ChildrenElementList._wrap(_ElementJs element)
|
| + : _childElements = element._children,
|
| + _element = element;
|
| +
|
| + List<Element> _toList() {
|
| + final output = new List(_childElements.length);
|
| + for (int i = 0, len = _childElements.length; i < len; i++) {
|
| + output[i] = _childElements[i];
|
| + }
|
| + return output;
|
| + }
|
| +
|
| + _ElementJs get first() {
|
| + return _element._firstElementChild;
|
| + }
|
| +
|
| + void forEach(void f(Element element)) {
|
| + for (_ElementJs element in _childElements) {
|
| + f(element);
|
| + }
|
| + }
|
| +
|
| + Collection<Element> filter(bool f(Element element)) {
|
| + List<Element> output = <Element>[];
|
| + forEach((Element element) {
|
| + if (f(element)) {
|
| + output.add(element);
|
| + }
|
| + });
|
| + return output;
|
| + }
|
| +
|
| + bool every(bool f(Element element)) {
|
| + for(Element element in this) {
|
| + if (!f(element)) {
|
| + return false;
|
| + }
|
| + };
|
| + return true;
|
| + }
|
| +
|
| + bool some(bool f(Element element)) {
|
| + for(Element element in this) {
|
| + if (f(element)) {
|
| + return true;
|
| + }
|
| + };
|
| + return false;
|
| + }
|
| +
|
| + bool isEmpty() {
|
| + return _element._firstElementChild !== null;
|
| + }
|
| +
|
| + int get length() {
|
| + return _childElements.length;
|
| + }
|
| +
|
| + _ElementJs operator [](int index) {
|
| + return _childElements[index];
|
| + }
|
| +
|
| + void operator []=(int index, _ElementJs value) {
|
| + _element._replaceChild(value, _childElements.item(index));
|
| + }
|
| +
|
| + void set length(int newLength) {
|
| + // TODO(jacobr): remove children when length is reduced.
|
| + throw const UnsupportedOperationException('');
|
| + }
|
| +
|
| + Element add(_ElementJs value) {
|
| + _element._appendChild(value);
|
| + return value;
|
| + }
|
| +
|
| + Element addLast(_ElementJs value) => add(value);
|
| +
|
| + Iterator<Element> iterator() => _toList().iterator();
|
| +
|
| + void addAll(Collection<_ElementJs> collection) {
|
| + for (_ElementJs element in collection) {
|
| + _element._appendChild(element);
|
| + }
|
| + }
|
| +
|
| + void sort(int compare(Element a, Element b)) {
|
| + throw const UnsupportedOperationException('TODO(jacobr): should we impl?');
|
| + }
|
| +
|
| + void copyFrom(List<Object> src, int srcStart, int dstStart, int count) {
|
| + throw 'Not impl yet. todo(jacobr)';
|
| + }
|
| +
|
| + void setRange(int start, int length, List from, [int startFrom = 0]) {
|
| + throw const NotImplementedException();
|
| + }
|
| +
|
| + void removeRange(int start, int length) {
|
| + throw const NotImplementedException();
|
| + }
|
| +
|
| + void insertRange(int start, int length, [initialValue = null]) {
|
| + throw const NotImplementedException();
|
| + }
|
| +
|
| + List getRange(int start, int length) {
|
| + throw const NotImplementedException();
|
| + }
|
| +
|
| + int indexOf(Element element, [int start = 0]) {
|
| + return _Lists.indexOf(this, element, start, this.length);
|
| + }
|
| +
|
| + int lastIndexOf(Element element, [int start = null]) {
|
| + if (start === null) start = length - 1;
|
| + return _Lists.lastIndexOf(this, element, start);
|
| + }
|
| +
|
| + void clear() {
|
| + // It is unclear if we want to keep non element nodes?
|
| + _element.text = '';
|
| + }
|
| +
|
| + Element removeLast() {
|
| + final last = this.last();
|
| + if (last != null) {
|
| + _element._removeChild(last);
|
| + }
|
| + return last;
|
| + }
|
| +
|
| + Element last() {
|
| + return _element.lastElementChild;
|
| + }
|
| +}
|
| +
|
| +class ElementAttributeMap implements Map<String, String> {
|
| +
|
| + final _ElementJs _element;
|
| +
|
| + ElementAttributeMap._wrap(this._element);
|
| +
|
| + bool containsValue(String value) {
|
| + final attributes = _element.attributes;
|
| + for (int i = 0, len = attributes.length; i < len; i++) {
|
| + if(value == attributes.item(i).value) {
|
| + return true;
|
| + }
|
| + }
|
| + return false;
|
| + }
|
| +
|
| + bool containsKey(String key) {
|
| + return _element._hasAttribute(key);
|
| + }
|
| +
|
| + String operator [](String key) {
|
| + return _element._getAttribute(key);
|
| + }
|
| +
|
| + void operator []=(String key, String value) {
|
| + _element._setAttribute(key, value);
|
| + }
|
| +
|
| + String putIfAbsent(String key, String ifAbsent()) {
|
| + if (!containsKey(key)) {
|
| + this[key] = ifAbsent();
|
| + }
|
| + }
|
| +
|
| + String remove(String key) {
|
| + _element._removeAttribute(key);
|
| + }
|
| +
|
| + void clear() {
|
| + final attributes = _element._attributes;
|
| + for (int i = attributes.length - 1; i >= 0; i--) {
|
| + remove(attributes.item(i).name);
|
| + }
|
| + }
|
| +
|
| + void forEach(void f(String key, String value)) {
|
| + final attributes = _element.attributes;
|
| + for (int i = 0, len = attributes.length; i < len; i++) {
|
| + final item = attributes.item(i);
|
| + f(item.name, item.value);
|
| + }
|
| + }
|
| +
|
| + Collection<String> getKeys() {
|
| + // TODO(jacobr): generate a lazy collection instead.
|
| + final attributes = _element.attributes;
|
| + final keys = new List<String>(attributes.length);
|
| + for (int i = 0, len = attributes.length; i < len; i++) {
|
| + keys[i] = attributes.item(i).name;
|
| + }
|
| + return keys;
|
| + }
|
| +
|
| + Collection<String> getValues() {
|
| + // TODO(jacobr): generate a lazy collection instead.
|
| + final attributes = _element.attributes;
|
| + final values = new List<String>(attributes.length);
|
| + for (int i = 0, len = attributes.length; i < len; i++) {
|
| + values[i] = attributes.item(i).value;
|
| + }
|
| + return values;
|
| + }
|
| +
|
| + /**
|
| + * The number of {key, value} pairs in the map.
|
| + */
|
| + int get length() {
|
| + return _element._attributes.length;
|
| + }
|
| +
|
| + /**
|
| + * Returns true if there is no {key, value} pair in the map.
|
| + */
|
| + bool isEmpty() {
|
| + return length == 0;
|
| + }
|
| +}
|
| +
|
| +class _SimpleClientRect implements ClientRect {
|
| + final num left;
|
| + final num top;
|
| + final num width;
|
| + final num height;
|
| + num get right() => left + width;
|
| + num get bottom() => top + height;
|
| +
|
| + const _SimpleClientRect(this.left, this.top, this.width, this.height);
|
| +
|
| + bool operator ==(ClientRect other) {
|
| + return other !== null && left == other.left && top == other.top
|
| + && width == other.width && height == other.height;
|
| + }
|
| +
|
| + String toString() => "($left, $top, $width, $height)";
|
| +}
|
| +
|
| +// TODO(jacobr): we cannot currently be lazy about calculating the client
|
| +// rects as we must perform all measurement queries at a safe point to avoid
|
| +// triggering unneeded layouts.
|
| +/**
|
| + * All your element measurement needs in one place
|
| + * @domName none
|
| + */
|
| +class _ElementRectImpl implements ElementRect {
|
| + final ClientRect client;
|
| + final ClientRect offset;
|
| + final ClientRect scroll;
|
| +
|
| + // TODO(jacobr): should we move these outside of ElementRect to avoid the
|
| + // overhead of computing them every time even though they are rarely used.
|
| + final _ClientRectJs _boundingClientRect;
|
| + final _ClientRectListJs _clientRects;
|
| +
|
| + _ElementRectImpl(_ElementJs element) :
|
| + client = new _SimpleClientRect(element._clientLeft,
|
| + element._clientTop,
|
| + element._clientWidth,
|
| + element._clientHeight),
|
| + offset = new _SimpleClientRect(element._offsetLeft,
|
| + element._offsetTop,
|
| + element._offsetWidth,
|
| + element._offsetHeight),
|
| + scroll = new _SimpleClientRect(element._scrollLeft,
|
| + element._scrollTop,
|
| + element._scrollWidth,
|
| + element._scrollHeight),
|
| + _boundingClientRect = element.getBoundingClientRect(),
|
| + _clientRects = element.getClientRects();
|
| +
|
| + _ClientRectJs get bounding() => _boundingClientRect;
|
| +
|
| + // TODO(jacobr): cleanup.
|
| + List<ClientRect> get clientRects() {
|
| + final out = new List(_clientRects.length);
|
| + for (num i = 0; i < _clientRects.length; i++) {
|
| + out[i] = _clientRects.item(i);
|
| + }
|
| + return out;
|
| + }
|
| +}
|
| +
|
| +final _START_TAG_REGEXP = const RegExp('<(\\w+)');
|
| +
|
| +class _ElementJs extends _NodeJs implements Element native "*Element" {
|
| +
|
| + static final _CUSTOM_PARENT_TAG_MAP = const {
|
| + 'body' : 'html',
|
| + 'head' : 'html',
|
| + 'caption' : 'table',
|
| + 'td': 'tr',
|
| + 'tbody': 'table',
|
| + 'colgroup': 'table',
|
| + 'col' : 'colgroup',
|
| + 'tr' : 'tbody',
|
| + 'tbody' : 'table',
|
| + 'tfoot' : 'table',
|
| + 'thead' : 'table',
|
| + 'track' : 'audio',
|
| + };
|
| +
|
| + /** @domName Document.createElement */
|
| + factory Element.html(String html) {
|
| + // TODO(jacobr): this method can be made more robust and performant.
|
| + // 1) Cache the dummy parent elements required to use innerHTML rather than
|
| + // creating them every call.
|
| + // 2) Verify that the html does not contain leading or trailing text nodes.
|
| + // 3) Verify that the html does not contain both <head> and <body> tags.
|
| + // 4) Detatch the created element from its dummy parent.
|
| + String parentTag = 'div';
|
| + String tag;
|
| + final match = _START_TAG_REGEXP.firstMatch(html);
|
| + if (match !== null) {
|
| + tag = match.group(1).toLowerCase();
|
| + if (_CUSTOM_PARENT_TAG_MAP.containsKey(tag)) {
|
| + parentTag = _CUSTOM_PARENT_TAG_MAP[tag];
|
| + }
|
| + }
|
| + _ElementJs temp = _document._createElement(parentTag);
|
| + temp.innerHTML = html;
|
| +
|
| + if (temp._childElementCount == 1) {
|
| + return temp._firstElementChild;
|
| + } else if (parentTag == 'html' && temp._childElementCount == 2) {
|
| + // Work around for edge case in WebKit and possibly other browsers where
|
| + // both body and head elements are created even though the inner html
|
| + // only contains a head or body element.
|
| + return temp.elements[tag == 'head' ? 0 : 1];
|
| + } else {
|
| + throw new IllegalArgumentException('HTML had ${temp._childElementCount} ' +
|
| + 'top level elements but 1 expected');
|
| + }
|
| + }
|
| +
|
| + /** @domName Document.createElement */
|
| + factory Element.tag(String tag) {
|
| + return _document._createElement(tag);
|
| + }
|
| +
|
| + // TODO(jacobr): caching these may hurt performance.
|
| + ElementAttributeMap _elementAttributeMap;
|
| + _CssClassSet _cssClassSet;
|
| + _DataAttributeMap _dataAttributes;
|
| +
|
| + // TODO(jacobr): remove these methods and let them be generated automatically
|
| + // once dart supports defining fields with the same name in an interface and
|
| + // its parent interface.
|
| + String get title() native "return this.parentNode.title;";
|
| + void set title(String value) native "this.parentNode.title = value;";
|
| +
|
| + /**
|
| + * @domName Element.hasAttribute, Element.getAttribute, Element.setAttribute,
|
| + * Element.removeAttribute
|
| + */
|
| + Map<String, String> get attributes() {
|
| + if (_elementAttributeMap === null) {
|
| + _elementAttributeMap = new ElementAttributeMap._wrap(this);
|
| + }
|
| + return _elementAttributeMap;
|
| + }
|
| +
|
| + void set attributes(Map<String, String> value) {
|
| + Map<String, String> attributes = this.attributes;
|
| + attributes.clear();
|
| + for (String key in value.getKeys()) {
|
| + attributes[key] = value[key];
|
| + }
|
| + }
|
| +
|
| + void set elements(Collection<Element> value) {
|
| + final elements = this.elements;
|
| + elements.clear();
|
| + elements.addAll(value);
|
| + }
|
| +
|
| + /**
|
| + * @domName childElementCount, firstElementChild, lastElementChild,
|
| + * children, Node.nodes.add
|
| + */
|
| + ElementList get elements() => new _ChildrenElementList._wrap(this);
|
| +
|
| + /** @domName querySelector, Document.getElementById */
|
| + Element query(String selectors) native "return this.querySelector(selectors);";
|
| +
|
| + /**
|
| + * @domName querySelectorAll, getElementsByClassName, getElementsByTagName,
|
| + * getElementsByTagNameNS
|
| + */
|
| + ElementList queryAll(String selectors) native "return this.querySelectorAll(selectors);";
|
| +
|
| + /** @domName className, classList */
|
| + Set<String> get classes() {
|
| + if (_cssClassSet === null) {
|
| + _cssClassSet = new _CssClassSet(this);
|
| + }
|
| + return _cssClassSet;
|
| + }
|
| +
|
| + void set classes(Collection<String> value) {
|
| + _CssClassSet classSet = classes;
|
| + classSet.clear();
|
| + classSet.addAll(value);
|
| + }
|
| +
|
| + Map<String, String> get dataAttributes() {
|
| + if (_dataAttributes === null) {
|
| + _dataAttributes = new _DataAttributeMap(attributes);
|
| + }
|
| + return _dataAttributes;
|
| + }
|
| +
|
| + void set dataAttributes(Map<String, String> value) {
|
| + Map<String, String> dataAttributes = this.dataAttributes;
|
| + dataAttributes.clear();
|
| + for (String key in value.getKeys()) {
|
| + dataAttributes[key] = value[key];
|
| + }
|
| + }
|
| +
|
| + bool matchesSelector(String selectors) native "return this.webkitMatchesSelector(selectors)";
|
| +
|
| + /**
|
| + * @domName getClientRects, getBoundingClientRect, clientHeight, clientWidth,
|
| + * clientTop, clientLeft, offsetHeight, offsetWidth, offsetTop, offsetLeft,
|
| + * scrollHeight, scrollWidth, scrollTop, scrollLeft
|
| + */
|
| + Future<ElementRect> get rect() {
|
| + return _createMeasurementFuture(
|
| + () => new _ElementRectImpl(this),
|
| + new Completer<ElementRect>());
|
| + }
|
| +
|
| + /** @domName Window.getComputedStyle */
|
| + Future<CSSStyleDeclaration> get computedStyle() {
|
| + // TODO(jacobr): last param should be null, see b/5045788
|
| + return getComputedStyle('');
|
| + }
|
| +
|
| + /** @domName Window.getComputedStyle */
|
| + Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement) {
|
| + return _createMeasurementFuture(() =>
|
| + _window._getComputedStyle(this, pseudoElement),
|
| + new Completer<CSSStyleDeclaration>());
|
| + }
|
| +
|
| + _ElementJs clone(bool deep) native;
|
| +
|
| + static final int ALLOW_KEYBOARD_INPUT = 1;
|
| +
|
| + int get _childElementCount() native "return this.childElementCount;";
|
| +
|
| + _HTMLCollectionJs get _children() native "return this.children;";
|
| +
|
| + final _DOMTokenListJs classList;
|
| +
|
| + String get _className() native "return this.className;";
|
| +
|
| + void set _className(String value) native "this.className = value;";
|
| +
|
| + int get _clientHeight() native "return this.clientHeight;";
|
| +
|
| + int get _clientLeft() native "return this.clientLeft;";
|
| +
|
| + int get _clientTop() native "return this.clientTop;";
|
| +
|
| + int get _clientWidth() native "return this.clientWidth;";
|
| +
|
| + String contentEditable;
|
| +
|
| + String dir;
|
| +
|
| + bool draggable;
|
| +
|
| + _ElementJs get _firstElementChild() native "return this.firstElementChild;";
|
| +
|
| + bool hidden;
|
| +
|
| + String id;
|
| +
|
| + String innerHTML;
|
| +
|
| + final bool isContentEditable;
|
| +
|
| + String lang;
|
| +
|
| + final _ElementJs lastElementChild;
|
| +
|
| + final _ElementJs nextElementSibling;
|
| +
|
| + int get _offsetHeight() native "return this.offsetHeight;";
|
| +
|
| + int get _offsetLeft() native "return this.offsetLeft;";
|
| +
|
| + final _ElementJs offsetParent;
|
| +
|
| + int get _offsetTop() native "return this.offsetTop;";
|
| +
|
| + int get _offsetWidth() native "return this.offsetWidth;";
|
| +
|
| + final String outerHTML;
|
| +
|
| + final _ElementJs previousElementSibling;
|
| +
|
| + int get _scrollHeight() native "return this.scrollHeight;";
|
| +
|
| + int get _scrollLeft() native "return this.scrollLeft;";
|
| +
|
| + void set _scrollLeft(int value) native "this.scrollLeft = value;";
|
| +
|
| + int get _scrollTop() native "return this.scrollTop;";
|
| +
|
| + void set _scrollTop(int value) native "this.scrollTop = value;";
|
| +
|
| + int get _scrollWidth() native "return this.scrollWidth;";
|
| +
|
| + bool spellcheck;
|
| +
|
| + final _CSSStyleDeclarationJs style;
|
| +
|
| + int tabIndex;
|
| +
|
| + final String tagName;
|
| +
|
| + String webkitdropzone;
|
| +
|
| + _ElementEventsImpl get on() =>
|
| + new _ElementEventsImpl(this);
|
| +
|
| + void blur() native;
|
| +
|
| + void focus() native;
|
| +
|
| + String _getAttribute(String name) native "return this.getAttribute(name);";
|
| +
|
| + _ClientRectJs getBoundingClientRect() native;
|
| +
|
| + _ClientRectListJs getClientRects() native;
|
| +
|
| + _NodeListJs getElementsByClassName(String name) native;
|
| +
|
| + _NodeListJs getElementsByTagName(String name) native;
|
| +
|
| + _NodeListJs getElementsByTagNameNS(String namespaceURI, String localName) native;
|
| +
|
| + bool _hasAttribute(String name) native "return this.hasAttribute(name);";
|
| +
|
| + _ElementJs insertAdjacentElement(String where, _ElementJs element) native;
|
| +
|
| + void insertAdjacentHTML(String where, String html) native;
|
| +
|
| + void insertAdjacentText(String where, String text) native;
|
| +
|
| + _ElementJs querySelector(String selectors) native;
|
| +
|
| + _NodeListJs querySelectorAll(String selectors) native;
|
| +
|
| + void _removeAttribute(String name) native "this.removeAttribute(name);";
|
| +
|
| + void scrollByLines(int lines) native;
|
| +
|
| + void scrollByPages(int pages) native;
|
| +
|
| + void scrollIntoView([bool alignWithTop = null]) native;
|
| +
|
| + void scrollIntoViewIfNeeded([bool centerIfNeeded = null]) native;
|
| +
|
| + void _setAttribute(String name, String value) native "this.setAttribute(name, value);";
|
| +
|
| + bool webkitMatchesSelector(String selectors) native;
|
| +
|
| + void webkitRequestFullScreen(int flags) native;
|
| +
|
| +}
|
| +
|
| +class _ElementEventsImpl extends _EventsImpl implements ElementEvents {
|
| + _ElementEventsImpl(_ptr) : super(_ptr);
|
| +
|
| + EventListenerList get abort() => _get('abort');
|
| +
|
| + EventListenerList get beforeCopy() => _get('beforecopy');
|
| +
|
| + EventListenerList get beforeCut() => _get('beforecut');
|
| +
|
| + EventListenerList get beforePaste() => _get('beforepaste');
|
| +
|
| + EventListenerList get blur() => _get('blur');
|
| +
|
| + EventListenerList get change() => _get('change');
|
| +
|
| + EventListenerList get click() => _get('click');
|
| +
|
| + EventListenerList get contextMenu() => _get('contextmenu');
|
| +
|
| + EventListenerList get copy() => _get('copy');
|
| +
|
| + EventListenerList get cut() => _get('cut');
|
| +
|
| + EventListenerList get doubleClick() => _get('dblclick');
|
| +
|
| + EventListenerList get drag() => _get('drag');
|
| +
|
| + EventListenerList get dragEnd() => _get('dragend');
|
| +
|
| + EventListenerList get dragEnter() => _get('dragenter');
|
| +
|
| + EventListenerList get dragLeave() => _get('dragleave');
|
| +
|
| + EventListenerList get dragOver() => _get('dragover');
|
| +
|
| + EventListenerList get dragStart() => _get('dragstart');
|
| +
|
| + EventListenerList get drop() => _get('drop');
|
| +
|
| + EventListenerList get error() => _get('error');
|
| +
|
| + EventListenerList get focus() => _get('focus');
|
| +
|
| + EventListenerList get fullScreenChange() => _get('webkitFullScreenChange');
|
| +
|
| + EventListenerList get fullScreenError() => _get('webkitFullScreenError');
|
| +
|
| + EventListenerList get input() => _get('input');
|
| +
|
| + EventListenerList get invalid() => _get('invalid');
|
| +
|
| + EventListenerList get keyDown() => _get('keydown');
|
| +
|
| + EventListenerList get keyPress() => _get('keypress');
|
| +
|
| + EventListenerList get keyUp() => _get('keyup');
|
| +
|
| + EventListenerList get load() => _get('load');
|
| +
|
| + EventListenerList get mouseDown() => _get('mousedown');
|
| +
|
| + EventListenerList get mouseMove() => _get('mousemove');
|
| +
|
| + EventListenerList get mouseOut() => _get('mouseout');
|
| +
|
| + EventListenerList get mouseOver() => _get('mouseover');
|
| +
|
| + EventListenerList get mouseUp() => _get('mouseup');
|
| +
|
| + EventListenerList get mouseWheel() => _get('mousewheel');
|
| +
|
| + EventListenerList get paste() => _get('paste');
|
| +
|
| + EventListenerList get reset() => _get('reset');
|
| +
|
| + EventListenerList get scroll() => _get('scroll');
|
| +
|
| + EventListenerList get search() => _get('search');
|
| +
|
| + EventListenerList get select() => _get('select');
|
| +
|
| + EventListenerList get selectStart() => _get('selectstart');
|
| +
|
| + EventListenerList get submit() => _get('submit');
|
| +
|
| + EventListenerList get touchCancel() => _get('touchcancel');
|
| +
|
| + EventListenerList get touchEnd() => _get('touchend');
|
| +
|
| + EventListenerList get touchLeave() => _get('touchleave');
|
| +
|
| + EventListenerList get touchMove() => _get('touchmove');
|
| +
|
| + EventListenerList get touchStart() => _get('touchstart');
|
| +
|
| + EventListenerList get transitionEnd() => _get('webkitTransitionEnd');
|
| +}
|
|
|