| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // TODO(jacobr): use Lists.dart to remove some of the duplicated functionality. | 5 // TODO(jacobr): use Lists.dart to remove some of the duplicated functionality. |
| 6 class _ChildrenElementList implements ElementList { | 6 class _ChildrenElementList implements ElementList { |
| 7 // Raw Element. | 7 // Raw Element. |
| 8 final _element; | 8 final _element; |
| 9 final _childElements; | 9 final _childElements; |
| 10 | 10 |
| 11 _ChildrenElementList._wrap(var element) | 11 _ChildrenElementList._wrap(var element) |
| 12 : _childElements = element.children, | 12 : _childElements = element.children, |
| 13 _element = element; | 13 _element = element; |
| 14 | 14 |
| 15 bool get _inDocument() => _nodeInDocument(_element); | |
| 16 List<Element> _toList() { | 15 List<Element> _toList() { |
| 17 final output = new List(_childElements.length); | 16 final output = new List(_childElements.length); |
| 18 for (int i = 0, len = _childElements.length; i < len; i++) { | 17 for (int i = 0, len = _childElements.length; i < len; i++) { |
| 19 output[i] = LevelDom.wrapElement(_childElements[i]); | 18 output[i] = LevelDom.wrapElement(_childElements[i]); |
| 20 } | 19 } |
| 21 return output; | 20 return output; |
| 22 } | 21 } |
| 23 | 22 |
| 24 Element get first() { | 23 Element get first() { |
| 25 return LevelDom.wrapElement(_element.firstElementChild); | 24 return LevelDom.wrapElement(_element.firstElementChild); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 55 | 54 |
| 56 int get length() { | 55 int get length() { |
| 57 return _childElements.length; | 56 return _childElements.length; |
| 58 } | 57 } |
| 59 | 58 |
| 60 Element operator [](int index) { | 59 Element operator [](int index) { |
| 61 return LevelDom.wrapElement(_childElements[index]); | 60 return LevelDom.wrapElement(_childElements[index]); |
| 62 } | 61 } |
| 63 | 62 |
| 64 void operator []=(int index, Element value) { | 63 void operator []=(int index, Element value) { |
| 65 assert(!_inMeasurementFrame || (!_inDocument && !value._inDocument)); | |
| 66 _element.replaceChild(LevelDom.unwrap(value), _childElements.item(index)); | 64 _element.replaceChild(LevelDom.unwrap(value), _childElements.item(index)); |
| 67 } | 65 } |
| 68 | 66 |
| 69 void set length(int newLength) { | 67 void set length(int newLength) { |
| 70 // TODO(jacobr): remove children when length is reduced. | 68 // TODO(jacobr): remove children when length is reduced. |
| 71 throw const UnsupportedOperationException(''); | 69 throw const UnsupportedOperationException(''); |
| 72 } | 70 } |
| 73 | 71 |
| 74 Element add(Element value) { | 72 Element add(Element value) { |
| 75 assert(!_inMeasurementFrame || (!_inDocument && !value._inDocument)); | |
| 76 _element.appendChild(LevelDom.unwrap(value)); | 73 _element.appendChild(LevelDom.unwrap(value)); |
| 77 return value; | 74 return value; |
| 78 } | 75 } |
| 79 | 76 |
| 80 Element addLast(Element value) => add(value); | 77 Element addLast(Element value) => add(value); |
| 81 | 78 |
| 82 Iterator<Element> iterator() => _toList().iterator(); | 79 Iterator<Element> iterator() => _toList().iterator(); |
| 83 | 80 |
| 84 void addAll(Collection<Element> collection) { | 81 void addAll(Collection<Element> collection) { |
| 85 assert(!_inMeasurementFrame || !_inDocument); | |
| 86 for (Element element in collection) { | 82 for (Element element in collection) { |
| 87 assert(!_inMeasurementFrame || !element._inDocument); | |
| 88 _element.appendChild(LevelDom.unwrap(element)); | 83 _element.appendChild(LevelDom.unwrap(element)); |
| 89 } | 84 } |
| 90 } | 85 } |
| 91 | 86 |
| 92 void sort(int compare(Element a, Element b)) { | 87 void sort(int compare(Element a, Element b)) { |
| 93 throw const UnsupportedOperationException('TODO(jacobr): should we impl?'); | 88 throw const UnsupportedOperationException('TODO(jacobr): should we impl?'); |
| 94 } | 89 } |
| 95 | 90 |
| 96 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { | 91 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { |
| 97 throw 'Not impl yet. todo(jacobr)'; | 92 throw 'Not impl yet. todo(jacobr)'; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 112 int indexOf(Element element, [int start = 0]) { | 107 int indexOf(Element element, [int start = 0]) { |
| 113 return Lists.indexOf(this, element, start, this.length); | 108 return Lists.indexOf(this, element, start, this.length); |
| 114 } | 109 } |
| 115 | 110 |
| 116 int lastIndexOf(Element element, [int start = null]) { | 111 int lastIndexOf(Element element, [int start = null]) { |
| 117 if (start === null) start = length - 1; | 112 if (start === null) start = length - 1; |
| 118 return Lists.lastIndexOf(this, element, start); | 113 return Lists.lastIndexOf(this, element, start); |
| 119 } | 114 } |
| 120 | 115 |
| 121 void clear() { | 116 void clear() { |
| 122 assert(!_inMeasurementFrame || !_inDocument); | |
| 123 // It is unclear if we want to keep non element nodes? | 117 // It is unclear if we want to keep non element nodes? |
| 124 _element.textContent = ''; | 118 _element.textContent = ''; |
| 125 } | 119 } |
| 126 | 120 |
| 127 Element removeLast() { | 121 Element removeLast() { |
| 128 assert(!_inMeasurementFrame || !_inDocument); | |
| 129 final last = this.last(); | 122 final last = this.last(); |
| 130 if (last != null) { | 123 if (last != null) { |
| 131 _element.removeChild(LevelDom.unwrap(last)); | 124 _element.removeChild(LevelDom.unwrap(last)); |
| 132 } | 125 } |
| 133 return last; | 126 return last; |
| 134 } | 127 } |
| 135 | 128 |
| 136 Element last() { | 129 Element last() { |
| 137 return LevelDom.wrapElement(_element.lastElementChild); | 130 return LevelDom.wrapElement(_element.lastElementChild); |
| 138 } | 131 } |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 _element.setAttribute(key, value); | 305 _element.setAttribute(key, value); |
| 313 } | 306 } |
| 314 | 307 |
| 315 String putIfAbsent(String key, String ifAbsent()) { | 308 String putIfAbsent(String key, String ifAbsent()) { |
| 316 if (!containsKey(key)) { | 309 if (!containsKey(key)) { |
| 317 this[key] = ifAbsent(); | 310 this[key] = ifAbsent(); |
| 318 } | 311 } |
| 319 } | 312 } |
| 320 | 313 |
| 321 String remove(String key) { | 314 String remove(String key) { |
| 322 assert(!_inMeasurementFrame || !_nodeInDocument(_element)); | |
| 323 _element.removeAttribute(key); | 315 _element.removeAttribute(key); |
| 324 } | 316 } |
| 325 | 317 |
| 326 void clear() { | 318 void clear() { |
| 327 assert(!_inMeasurementFrame || !_nodeInDocument(_element)); | |
| 328 final attributes = _element.attributes; | 319 final attributes = _element.attributes; |
| 329 for (int i = attributes.length - 1; i >= 0; i--) { | 320 for (int i = attributes.length - 1; i >= 0; i--) { |
| 330 _element.removeAttribute(attributes.item(i).name); | 321 _element.removeAttribute(attributes.item(i).name); |
| 331 } | 322 } |
| 332 } | 323 } |
| 333 | 324 |
| 334 void forEach(void f(String key, String value)) { | 325 void forEach(void f(String key, String value)) { |
| 335 final attributes = _element.attributes; | 326 final attributes = _element.attributes; |
| 336 for (int i = 0, len = attributes.length; i < len; i++) { | 327 for (int i = 0, len = attributes.length; i < len; i++) { |
| 337 final item = attributes.item(i); | 328 final item = attributes.item(i); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 const SimpleClientRect(this.left, this.top, this.width, this.height); | 427 const SimpleClientRect(this.left, this.top, this.width, this.height); |
| 437 | 428 |
| 438 bool operator ==(ClientRect other) { | 429 bool operator ==(ClientRect other) { |
| 439 return other !== null && left == other.left && top == other.top | 430 return other !== null && left == other.left && top == other.top |
| 440 && width == other.width && height == other.height; | 431 && width == other.width && height == other.height; |
| 441 } | 432 } |
| 442 | 433 |
| 443 String toString() => "($left, $top, $width, $height)"; | 434 String toString() => "($left, $top, $width, $height)"; |
| 444 } | 435 } |
| 445 | 436 |
| 437 // TODO(jacobr): we cannot currently be lazy about calculating the client |
| 438 // rects as we must perform all measurement queries at a safe point to avoid |
| 439 // triggering unneeded layouts. |
| 446 /** | 440 /** |
| 447 * All your element measurement needs in one place. | 441 * All your element measurement needs in one place |
| 448 * All members of this class can only be cassed when inside a measurement | |
| 449 * frame or when the element is not attached to the DOM. | |
| 450 * @domName none | 442 * @domName none |
| 451 */ | 443 */ |
| 452 class ElementRectWrappingImplementation implements ElementRect { | 444 class ElementRectWrappingImplementation implements ElementRect { |
| 453 final dom.HTMLElement _element; | 445 final ClientRect client; |
| 446 final ClientRect offset; |
| 447 final ClientRect scroll; |
| 454 | 448 |
| 455 ElementRectWrappingImplementation(this._element); | 449 // TODO(jacobr): should we move these outside of ElementRect to avoid the |
| 450 // overhead of computing them every time even though they are rarely used. |
| 451 // This should be type dom.ClientRect but that fails on dartium. b/5522629 |
| 452 final _boundingClientRect; |
| 453 // an exception due to a dartium bug. |
| 454 final _clientRects; // TODO(jacobr): should be dom.ClientRectList |
| 456 | 455 |
| 457 ClientRect get client() { | 456 ElementRectWrappingImplementation(dom.HTMLElement element) : |
| 458 assert(window.inMeasurementFrame || !_nodeInDocument(_element)); | 457 client = new SimpleClientRect(element.clientLeft, |
| 459 return new SimpleClientRect(_element.clientLeft, | 458 element.clientTop, |
| 460 _element.clientTop, | 459 element.clientWidth, |
| 461 _element.clientWidth, | 460 element.clientHeight), |
| 462 _element.clientHeight); | 461 offset = new SimpleClientRect(element.offsetLeft, |
| 463 } | 462 element.offsetTop, |
| 464 | 463 element.offsetWidth, |
| 465 ClientRect get offset() { | 464 element.offsetHeight), |
| 466 assert(window.inMeasurementFrame || !_nodeInDocument(_element)); | 465 scroll = new SimpleClientRect(element.scrollLeft, |
| 467 return new SimpleClientRect(_element.offsetLeft, | 466 element.scrollTop, |
| 468 _element.offsetTop, | 467 element.scrollWidth, |
| 469 _element.offsetWidth, | 468 element.scrollHeight), |
| 470 _element.offsetHeight); | 469 _boundingClientRect = element.getBoundingClientRect(), |
| 471 } | 470 _clientRects = element.getClientRects(); |
| 472 | 471 |
| 473 ClientRect get scroll() { | 472 ClientRect get bounding() => |
| 474 assert(window.inMeasurementFrame || !_nodeInDocument(_element)); | 473 LevelDom.wrapClientRect(_boundingClientRect); |
| 475 return new SimpleClientRect(_element.scrollLeft, | |
| 476 _element.scrollTop, | |
| 477 _element.scrollWidth, | |
| 478 _element.scrollHeight); | |
| 479 } | |
| 480 | |
| 481 ClientRect get bounding() { | |
| 482 assert(window.inMeasurementFrame || !_nodeInDocument(_element)); | |
| 483 return LevelDom.wrapClientRect(_element.getBoundingClientRect()); | |
| 484 } | |
| 485 | 474 |
| 486 List<ClientRect> get clientRects() { | 475 List<ClientRect> get clientRects() { |
| 487 assert(window.inMeasurementFrame || !_nodeInDocument(_element)); | 476 final out = new List(_clientRects.length); |
| 488 final clientRects = _element.getClientRects(); | 477 for (num i = 0; i < _clientRects.length; i++) { |
| 489 final out = new List(clientRects.length); | 478 out[i] = LevelDom.wrapClientRect(_clientRects.item(i)); |
| 490 for (num i = 0, len = clientRects.length; i < len; i++) { | |
| 491 out[i] = LevelDom.wrapClientRect(clientRects.item(i)); | |
| 492 } | 479 } |
| 493 return out; | 480 return out; |
| 494 } | 481 } |
| 495 } | 482 } |
| 496 | 483 |
| 497 final _START_TAG_REGEXP = const RegExp('<(\\w+)'); | 484 final _START_TAG_REGEXP = const RegExp('<(\\w+)'); |
| 498 | 485 |
| 499 /** @domName Element, HTMLElement */ | 486 /** @domName Element, HTMLElement */ |
| 500 class ElementWrappingImplementation extends NodeWrappingImplementation implement
s Element { | 487 class ElementWrappingImplementation extends NodeWrappingImplementation implement
s Element { |
| 501 | 488 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 * Element.removeAttribute | 552 * Element.removeAttribute |
| 566 */ | 553 */ |
| 567 Map<String, String> get attributes() { | 554 Map<String, String> get attributes() { |
| 568 if (_elementAttributeMap === null) { | 555 if (_elementAttributeMap === null) { |
| 569 _elementAttributeMap = new ElementAttributeMap._wrap(_ptr); | 556 _elementAttributeMap = new ElementAttributeMap._wrap(_ptr); |
| 570 } | 557 } |
| 571 return _elementAttributeMap; | 558 return _elementAttributeMap; |
| 572 } | 559 } |
| 573 | 560 |
| 574 void set attributes(Map<String, String> value) { | 561 void set attributes(Map<String, String> value) { |
| 575 assert(!_inMeasurementFrame || !_inDocument); | |
| 576 Map<String, String> attributes = this.attributes; | 562 Map<String, String> attributes = this.attributes; |
| 577 attributes.clear(); | 563 attributes.clear(); |
| 578 for (String key in value.getKeys()) { | 564 for (String key in value.getKeys()) { |
| 579 attributes[key] = value[key]; | 565 attributes[key] = value[key]; |
| 580 } | 566 } |
| 581 } | 567 } |
| 582 | 568 |
| 583 void set elements(Collection<Element> value) { | 569 void set elements(Collection<Element> value) { |
| 584 assert(!_inMeasurementFrame || !_inDocument); | |
| 585 final elements = this.elements; | 570 final elements = this.elements; |
| 586 elements.clear(); | 571 elements.clear(); |
| 587 elements.addAll(value); | 572 elements.addAll(value); |
| 588 } | 573 } |
| 589 | 574 |
| 590 /** | 575 /** |
| 591 * @domName childElementCount, firstElementChild, lastElementChild, | 576 * @domName childElementCount, firstElementChild, lastElementChild, |
| 592 * children, Node.appendChild | 577 * children, Node.appendChild |
| 593 */ | 578 */ |
| 594 ElementList get elements() { | 579 ElementList get elements() { |
| 595 if (_elements == null) { | 580 if (_elements == null) { |
| 596 _elements = new _ChildrenElementList._wrap(_ptr); | 581 _elements = new _ChildrenElementList._wrap(_ptr); |
| 597 } | 582 } |
| 598 return _elements; | 583 return _elements; |
| 599 } | 584 } |
| 600 | 585 |
| 601 /** @domName className, classList */ | 586 /** @domName className, classList */ |
| 602 Set<String> get classes() { | 587 Set<String> get classes() { |
| 603 if (_cssClassSet === null) { | 588 if (_cssClassSet === null) { |
| 604 _cssClassSet = new _CssClassSet(_ptr); | 589 _cssClassSet = new _CssClassSet(_ptr); |
| 605 } | 590 } |
| 606 return _cssClassSet; | 591 return _cssClassSet; |
| 607 } | 592 } |
| 608 | 593 |
| 609 void set classes(Collection<String> value) { | 594 void set classes(Collection<String> value) { |
| 610 assert(!_inMeasurementFrame || !_inDocument); | |
| 611 _CssClassSet classSet = classes; | 595 _CssClassSet classSet = classes; |
| 612 classSet.clear(); | 596 classSet.clear(); |
| 613 classSet.addAll(value); | 597 classSet.addAll(value); |
| 614 } | 598 } |
| 615 | 599 |
| 616 Map<String, String> get dataAttributes() { | 600 Map<String, String> get dataAttributes() { |
| 617 if (_dataAttributes === null) { | 601 if (_dataAttributes === null) { |
| 618 _dataAttributes = new _DataAttributeMap(attributes); | 602 _dataAttributes = new _DataAttributeMap(attributes); |
| 619 } | 603 } |
| 620 return _dataAttributes; | 604 return _dataAttributes; |
| 621 } | 605 } |
| 622 | 606 |
| 623 void set dataAttributes(Map<String, String> value) { | 607 void set dataAttributes(Map<String, String> value) { |
| 624 assert(!_inMeasurementFrame || !_inDocument); | |
| 625 Map<String, String> dataAttributes = this.dataAttributes; | 608 Map<String, String> dataAttributes = this.dataAttributes; |
| 626 dataAttributes.clear(); | 609 dataAttributes.clear(); |
| 627 for (String key in value.getKeys()) { | 610 for (String key in value.getKeys()) { |
| 628 dataAttributes[key] = value[key]; | 611 dataAttributes[key] = value[key]; |
| 629 } | 612 } |
| 630 } | 613 } |
| 631 | 614 |
| 632 String get contentEditable() => _ptr.contentEditable; | 615 String get contentEditable() => _ptr.contentEditable; |
| 633 | 616 |
| 634 void set contentEditable(String value) { | 617 void set contentEditable(String value) { _ptr.contentEditable = value; } |
| 635 assert(!_inMeasurementFrame || !_inDocument); | |
| 636 _ptr.contentEditable = value; | |
| 637 } | |
| 638 | 618 |
| 639 String get dir() => _ptr.dir; | 619 String get dir() => _ptr.dir; |
| 640 | 620 |
| 641 void set dir(String value) { | 621 void set dir(String value) { _ptr.dir = value; } |
| 642 assert(!_inMeasurementFrame || !_inDocument); | |
| 643 _ptr.dir = value; | |
| 644 } | |
| 645 | 622 |
| 646 bool get draggable() => _ptr.draggable; | 623 bool get draggable() => _ptr.draggable; |
| 647 | 624 |
| 648 void set draggable(bool value) { _ptr.draggable = value; } | 625 void set draggable(bool value) { _ptr.draggable = value; } |
| 649 | 626 |
| 650 Element get firstElementChild() => LevelDom.wrapElement(_ptr.firstElementChild
); | 627 Element get firstElementChild() => LevelDom.wrapElement(_ptr.firstElementChild
); |
| 651 | 628 |
| 652 bool get hidden() => _ptr.hidden; | 629 bool get hidden() => _ptr.hidden; |
| 653 | 630 |
| 654 void set hidden(bool value) { | 631 void set hidden(bool value) { _ptr.hidden = value; } |
| 655 assert(!_inMeasurementFrame || !_inDocument); | |
| 656 _ptr.hidden = value; | |
| 657 } | |
| 658 | 632 |
| 659 String get id() => _ptr.id; | 633 String get id() => _ptr.id; |
| 660 | 634 |
| 661 void set id(String value) { | 635 void set id(String value) { _ptr.id = value; } |
| 662 assert(!_inMeasurementFrame || !_inDocument); | |
| 663 _ptr.id = value; | |
| 664 } | |
| 665 | 636 |
| 666 String get innerHTML() => _ptr.innerHTML; | 637 String get innerHTML() => _ptr.innerHTML; |
| 667 | 638 |
| 668 void set innerHTML(String value) { | 639 void set innerHTML(String value) { _ptr.innerHTML = value; } |
| 669 assert(!_inMeasurementFrame || !_inDocument); | |
| 670 _ptr.innerHTML = value; | |
| 671 } | |
| 672 | 640 |
| 673 bool get isContentEditable() => _ptr.isContentEditable; | 641 bool get isContentEditable() => _ptr.isContentEditable; |
| 674 | 642 |
| 675 String get lang() => _ptr.lang; | 643 String get lang() => _ptr.lang; |
| 676 | 644 |
| 677 void set lang(String value) { | 645 void set lang(String value) { _ptr.lang = value; } |
| 678 assert(!_inMeasurementFrame || !_inDocument); | |
| 679 _ptr.lang = value; | |
| 680 } | |
| 681 | 646 |
| 682 Element get lastElementChild() => LevelDom.wrapElement(_ptr.lastElementChild); | 647 Element get lastElementChild() => LevelDom.wrapElement(_ptr.lastElementChild); |
| 683 | 648 |
| 684 Element get nextElementSibling() => LevelDom.wrapElement(_ptr.nextElementSibli
ng); | 649 Element get nextElementSibling() => LevelDom.wrapElement(_ptr.nextElementSibli
ng); |
| 685 | 650 |
| 686 Element get offsetParent() => LevelDom.wrapElement(_ptr.offsetParent); | 651 Element get offsetParent() => LevelDom.wrapElement(_ptr.offsetParent); |
| 687 | 652 |
| 688 String get outerHTML() => _ptr.outerHTML; | 653 String get outerHTML() => _ptr.outerHTML; |
| 689 | 654 |
| 690 Element get previousElementSibling() => LevelDom.wrapElement(_ptr.previousElem
entSibling); | 655 Element get previousElementSibling() => LevelDom.wrapElement(_ptr.previousElem
entSibling); |
| 691 | 656 |
| 692 bool get spellcheck() => _ptr.spellcheck; | 657 bool get spellcheck() => _ptr.spellcheck; |
| 693 | 658 |
| 694 void set spellcheck(bool value) { | 659 void set spellcheck(bool value) { _ptr.spellcheck = value; } |
| 695 assert(!_inMeasurementFrame || !_inDocument); | |
| 696 _ptr.spellcheck = value; | |
| 697 } | |
| 698 | 660 |
| 699 CSSStyleDeclaration get style() { | 661 CSSStyleDeclaration get style() => LevelDom.wrapCSSStyleDeclaration(_ptr.style
); |
| 700 // Changes to this CSSStyleDeclaration dirty the layout so we must pass | |
| 701 // the associated Element to the CSSStyleDeclaration constructor so that | |
| 702 // we can compute whether the current element is attached to the document | |
| 703 // which is required to decide whether modification inside a measurement | |
| 704 // frame is allowed. | |
| 705 final raw = _ptr.style; | |
| 706 return raw.dartObjectLocalStorage !== null ? | |
| 707 raw.dartObjectLocalStorage : | |
| 708 new CSSStyleDeclarationWrappingImplementation._wrapWithElement( | |
| 709 raw, this); | |
| 710 } | |
| 711 | 662 |
| 712 int get tabIndex() => _ptr.tabIndex; | 663 int get tabIndex() => _ptr.tabIndex; |
| 713 | 664 |
| 714 void set tabIndex(int value) { | 665 void set tabIndex(int value) { _ptr.tabIndex = value; } |
| 715 assert(!_inMeasurementFrame || !_inDocument); | |
| 716 _ptr.tabIndex = value; | |
| 717 } | |
| 718 | 666 |
| 719 String get tagName() => _ptr.tagName; | 667 String get tagName() => _ptr.tagName; |
| 720 | 668 |
| 721 String get title() => _ptr.title; | 669 String get title() => _ptr.title; |
| 722 | 670 |
| 723 void set title(String value) { | 671 void set title(String value) { _ptr.title = value; } |
| 724 assert(!_inMeasurementFrame || !_inDocument); | |
| 725 _ptr.title = value; | |
| 726 } | |
| 727 | 672 |
| 728 String get webkitdropzone() => _ptr.webkitdropzone; | 673 String get webkitdropzone() => _ptr.webkitdropzone; |
| 729 | 674 |
| 730 void set webkitdropzone(String value) { _ptr.webkitdropzone = value; } | 675 void set webkitdropzone(String value) { _ptr.webkitdropzone = value; } |
| 731 | 676 |
| 732 void blur() { | 677 void blur() { |
| 733 assert(!_inMeasurementFrame || !_inDocument); | |
| 734 _ptr.blur(); | 678 _ptr.blur(); |
| 735 } | 679 } |
| 736 | 680 |
| 737 bool contains(Node element) { | 681 bool contains(Node element) { |
| 738 return _ptr.contains(LevelDom.unwrap(element)); | 682 return _ptr.contains(LevelDom.unwrap(element)); |
| 739 } | 683 } |
| 740 | 684 |
| 741 void focus() { | 685 void focus() { |
| 742 assert(!_inMeasurementFrame || !_inDocument); | |
| 743 _ptr.focus(); | 686 _ptr.focus(); |
| 744 } | 687 } |
| 745 | 688 |
| 746 Element insertAdjacentElement([String where = null, Element element = null]) { | 689 Element insertAdjacentElement([String where = null, Element element = null]) { |
| 747 assert(!_inMeasurementFrame || !_inDocument); | |
| 748 return LevelDom.wrapElement(_ptr.insertAdjacentElement(where, LevelDom.unwra
p(element))); | 690 return LevelDom.wrapElement(_ptr.insertAdjacentElement(where, LevelDom.unwra
p(element))); |
| 749 } | 691 } |
| 750 | 692 |
| 751 void insertAdjacentHTML([String position_OR_where = null, String text = null])
{ | 693 void insertAdjacentHTML([String position_OR_where = null, String text = null])
{ |
| 752 assert(!_inMeasurementFrame || !_inDocument); | |
| 753 _ptr.insertAdjacentHTML(position_OR_where, text); | 694 _ptr.insertAdjacentHTML(position_OR_where, text); |
| 754 } | 695 } |
| 755 | 696 |
| 756 void insertAdjacentText([String where = null, String text = null]) { | 697 void insertAdjacentText([String where = null, String text = null]) { |
| 757 assert(!_inMeasurementFrame || !_inDocument); | |
| 758 _ptr.insertAdjacentText(where, text); | 698 _ptr.insertAdjacentText(where, text); |
| 759 } | 699 } |
| 760 | 700 |
| 761 /** @domName querySelector, Document.getElementById */ | 701 /** @domName querySelector, Document.getElementById */ |
| 762 Element query(String selectors) { | 702 Element query(String selectors) { |
| 763 // TODO(jacobr): scope fix. | 703 // TODO(jacobr): scope fix. |
| 764 return LevelDom.wrapElement(_ptr.querySelector(selectors)); | 704 return LevelDom.wrapElement(_ptr.querySelector(selectors)); |
| 765 } | 705 } |
| 766 | 706 |
| 767 /** | 707 /** |
| (...skipping 24 matching lines...) Expand all Loading... |
| 792 | 732 |
| 793 void set scrollLeft(int value) { _ptr.scrollLeft = value; } | 733 void set scrollLeft(int value) { _ptr.scrollLeft = value; } |
| 794 | 734 |
| 795 void set scrollTop(int value) { _ptr.scrollTop = value; } | 735 void set scrollTop(int value) { _ptr.scrollTop = value; } |
| 796 | 736 |
| 797 /** | 737 /** |
| 798 * @domName getClientRects, getBoundingClientRect, clientHeight, clientWidth, | 738 * @domName getClientRects, getBoundingClientRect, clientHeight, clientWidth, |
| 799 * clientTop, clientLeft, offsetHeight, offsetWidth, offsetTop, offsetLeft, | 739 * clientTop, clientLeft, offsetHeight, offsetWidth, offsetTop, offsetLeft, |
| 800 * scrollHeight, scrollWidth, scrollTop, scrollLeft | 740 * scrollHeight, scrollWidth, scrollTop, scrollLeft |
| 801 */ | 741 */ |
| 802 ElementRect get rect() { | 742 Future<ElementRect> get rect() { |
| 803 return new ElementRectWrappingImplementation(_ptr); | 743 return _createMeasurementFuture( |
| 744 () => new ElementRectWrappingImplementation(_ptr), |
| 745 new Completer<ElementRect>()); |
| 804 } | 746 } |
| 805 | 747 |
| 806 /** @domName Window.getComputedStyle */ | 748 /** @domName Window.getComputedStyle */ |
| 807 CSSStyleDeclaration get computedStyle() { | 749 Future<CSSStyleDeclaration> get computedStyle() { |
| 808 // TODO(jacobr): last param should be null, see b/5045788 | 750 // TODO(jacobr): last param should be null, see b/5045788 |
| 809 return getComputedStyle(''); | 751 return getComputedStyle(''); |
| 810 } | 752 } |
| 811 | 753 |
| 812 /** @domName Window.getComputedStyle */ | 754 /** @domName Window.getComputedStyle */ |
| 813 CSSStyleDeclaration getComputedStyle(String pseudoElement) { | 755 Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement) { |
| 814 assert(window.inMeasurementFrame || !_inDocument); | 756 return _createMeasurementFuture(() => |
| 815 return LevelDom.wrapCSSStyleDeclaration( | 757 LevelDom.wrapCSSStyleDeclaration( |
| 816 dom.window.getComputedStyle(_ptr, pseudoElement)); | 758 dom.window.getComputedStyle(_ptr, pseudoElement)), |
| 759 new Completer<CSSStyleDeclaration>()); |
| 817 } | 760 } |
| 818 | 761 |
| 819 ElementEvents get on() { | 762 ElementEvents get on() { |
| 820 if (_on === null) { | 763 if (_on === null) { |
| 821 _on = new ElementEventsImplementation._wrap(_ptr); | 764 _on = new ElementEventsImplementation._wrap(_ptr); |
| 822 } | 765 } |
| 823 return _on; | 766 return _on; |
| 824 } | 767 } |
| 825 | 768 |
| 826 Element clone(bool deep) => super.clone(deep); | 769 Element clone(bool deep) => super.clone(deep); |
| 827 } | 770 } |
| OLD | NEW |