OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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); | |
15 List<Element> _toList() { | 16 List<Element> _toList() { |
16 final output = new List(_childElements.length); | 17 final output = new List(_childElements.length); |
17 for (int i = 0, len = _childElements.length; i < len; i++) { | 18 for (int i = 0, len = _childElements.length; i < len; i++) { |
18 output[i] = LevelDom.wrapElement(_childElements[i]); | 19 output[i] = LevelDom.wrapElement(_childElements[i]); |
19 } | 20 } |
20 return output; | 21 return output; |
21 } | 22 } |
22 | 23 |
23 Element get first() { | 24 Element get first() { |
24 return LevelDom.wrapElement(_element.firstElementChild); | 25 return LevelDom.wrapElement(_element.firstElementChild); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 | 73 |
73 int get length() { | 74 int get length() { |
74 return _childElements.length; | 75 return _childElements.length; |
75 } | 76 } |
76 | 77 |
77 Element operator [](int index) { | 78 Element operator [](int index) { |
78 return LevelDom.wrapElement(_childElements[index]); | 79 return LevelDom.wrapElement(_childElements[index]); |
79 } | 80 } |
80 | 81 |
81 void operator []=(int index, Element value) { | 82 void operator []=(int index, Element value) { |
83 assert(!_inMeasurementFrame || (!_inDocument && !value._inDocument)); | |
82 _element.replaceChild(LevelDom.unwrap(value), _childElements.item(index)); | 84 _element.replaceChild(LevelDom.unwrap(value), _childElements.item(index)); |
83 } | 85 } |
84 | 86 |
85 void set length(int newLength) { | 87 void set length(int newLength) { |
86 // TODO(jacobr): remove children when length is reduced. | 88 // TODO(jacobr): remove children when length is reduced. |
87 throw const UnsupportedOperationException(''); | 89 throw const UnsupportedOperationException(''); |
88 } | 90 } |
89 | 91 |
90 Element add(Element value) { | 92 Element add(Element value) { |
93 assert(!_inMeasurementFrame || (!_inDocument && !value._inDocument)); | |
91 _element.appendChild(LevelDom.unwrap(value)); | 94 _element.appendChild(LevelDom.unwrap(value)); |
92 return value; | 95 return value; |
93 } | 96 } |
94 | 97 |
95 Element addLast(Element value) => add(value); | 98 Element addLast(Element value) => add(value); |
96 | 99 |
97 Iterator<Element> iterator() => _toList().iterator(); | 100 Iterator<Element> iterator() => _toList().iterator(); |
98 | 101 |
99 void addAll(Collection<Element> collection) { | 102 void addAll(Collection<Element> collection) { |
103 assert(!_inMeasurementFrame || !_inDocument); | |
100 for (Element element in collection) { | 104 for (Element element in collection) { |
105 assert(!_inMeasurementFrame || !element._inDocument); | |
101 _element.appendChild(LevelDom.unwrap(element)); | 106 _element.appendChild(LevelDom.unwrap(element)); |
102 } | 107 } |
103 } | 108 } |
104 | 109 |
105 void sort(int compare(Element a, Element b)) { | 110 void sort(int compare(Element a, Element b)) { |
106 throw const UnsupportedOperationException('TODO(jacobr): should we impl?'); | 111 throw const UnsupportedOperationException('TODO(jacobr): should we impl?'); |
107 } | 112 } |
108 | 113 |
109 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { | 114 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { |
110 throw 'Not impl yet. todo(jacobr)'; | 115 throw 'Not impl yet. todo(jacobr)'; |
(...skipping 18 matching lines...) Expand all Loading... | |
129 int indexOf(Element element, [int start = 0]) { | 134 int indexOf(Element element, [int start = 0]) { |
130 return _Lists.indexOf(this, element, start, this.length); | 135 return _Lists.indexOf(this, element, start, this.length); |
131 } | 136 } |
132 | 137 |
133 int lastIndexOf(Element element, [int start = null]) { | 138 int lastIndexOf(Element element, [int start = null]) { |
134 if (start === null) start = length - 1; | 139 if (start === null) start = length - 1; |
135 return _Lists.lastIndexOf(this, element, start); | 140 return _Lists.lastIndexOf(this, element, start); |
136 } | 141 } |
137 | 142 |
138 void clear() { | 143 void clear() { |
144 assert(!_inMeasurementFrame || !_inDocument); | |
139 // It is unclear if we want to keep non element nodes? | 145 // It is unclear if we want to keep non element nodes? |
140 _element.textContent = ''; | 146 _element.textContent = ''; |
141 } | 147 } |
142 | 148 |
143 Element removeLast() { | 149 Element removeLast() { |
150 assert(!_inMeasurementFrame || !_inDocument); | |
144 final last = this.last(); | 151 final last = this.last(); |
145 if (last != null) { | 152 if (last != null) { |
146 _element.removeChild(LevelDom.unwrap(last)); | 153 _element.removeChild(LevelDom.unwrap(last)); |
147 } | 154 } |
148 return last; | 155 return last; |
149 } | 156 } |
150 | 157 |
151 Element last() { | 158 Element last() { |
152 return LevelDom.wrapElement(_element.lastElementChild); | 159 return LevelDom.wrapElement(_element.lastElementChild); |
153 } | 160 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 _element.setAttribute(key, value); | 327 _element.setAttribute(key, value); |
321 } | 328 } |
322 | 329 |
323 String putIfAbsent(String key, String ifAbsent()) { | 330 String putIfAbsent(String key, String ifAbsent()) { |
324 if (!containsKey(key)) { | 331 if (!containsKey(key)) { |
325 this[key] = ifAbsent(); | 332 this[key] = ifAbsent(); |
326 } | 333 } |
327 } | 334 } |
328 | 335 |
329 String remove(String key) { | 336 String remove(String key) { |
337 assert(!_inMeasurementFrame || !_nodeInDocument(_element)); | |
330 _element.removeAttribute(key); | 338 _element.removeAttribute(key); |
331 } | 339 } |
332 | 340 |
333 void clear() { | 341 void clear() { |
342 assert(!_inMeasurementFrame || !_nodeInDocument(_element)); | |
334 final attributes = _element.attributes; | 343 final attributes = _element.attributes; |
335 for (int i = attributes.length - 1; i >= 0; i--) { | 344 for (int i = attributes.length - 1; i >= 0; i--) { |
336 _element.removeAttribute(attributes.item(i).name); | 345 _element.removeAttribute(attributes.item(i).name); |
337 } | 346 } |
338 } | 347 } |
339 | 348 |
340 void forEach(void f(String key, String value)) { | 349 void forEach(void f(String key, String value)) { |
341 final attributes = _element.attributes; | 350 final attributes = _element.attributes; |
342 for (int i = 0, len = attributes.length; i < len; i++) { | 351 for (int i = 0, len = attributes.length; i < len; i++) { |
343 final item = attributes.item(i); | 352 final item = attributes.item(i); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 const SimpleClientRect(this.left, this.top, this.width, this.height); | 451 const SimpleClientRect(this.left, this.top, this.width, this.height); |
443 | 452 |
444 bool operator ==(ClientRect other) { | 453 bool operator ==(ClientRect other) { |
445 return other !== null && left == other.left && top == other.top | 454 return other !== null && left == other.left && top == other.top |
446 && width == other.width && height == other.height; | 455 && width == other.width && height == other.height; |
447 } | 456 } |
448 | 457 |
449 String toString() => "($left, $top, $width, $height)"; | 458 String toString() => "($left, $top, $width, $height)"; |
450 } | 459 } |
451 | 460 |
452 // TODO(jacobr): we cannot currently be lazy about calculating the client | |
453 // rects as we must perform all measurement queries at a safe point to avoid | |
454 // triggering unneeded layouts. | |
455 /** | 461 /** |
456 * All your element measurement needs in one place | 462 * All your element measurement needs in one place. |
463 * All members of this class can only be cassed when inside a measurement | |
464 * frame or when the element is not attached to the DOM. | |
457 * @domName none | 465 * @domName none |
458 */ | 466 */ |
459 class ElementRectWrappingImplementation implements ElementRect { | 467 class ElementRectWrappingImplementation implements ElementRect { |
460 final ClientRect client; | 468 final dom.HTMLElement _element; |
461 final ClientRect offset; | |
462 final ClientRect scroll; | |
463 | 469 |
464 // TODO(jacobr): should we move these outside of ElementRect to avoid the | 470 ElementRectWrappingImplementation(this._element); |
465 // overhead of computing them every time even though they are rarely used. | |
466 // This should be type dom.ClientRect but that fails on dartium. b/5522629 | |
467 final _boundingClientRect; | |
468 // an exception due to a dartium bug. | |
469 final _clientRects; // TODO(jacobr): should be dom.ClientRectList | |
470 | 471 |
471 ElementRectWrappingImplementation(dom.HTMLElement element) : | 472 ClientRect get client() { |
472 client = new SimpleClientRect(element.clientLeft, | 473 assert(window.inMeasurementFrame || !_nodeInDocument(_element)); |
473 element.clientTop, | 474 return new SimpleClientRect(_element.clientLeft, |
474 element.clientWidth, | 475 _element.clientTop, |
475 element.clientHeight), | 476 _element.clientWidth, |
476 offset = new SimpleClientRect(element.offsetLeft, | 477 _element.clientHeight); |
477 element.offsetTop, | 478 } |
478 element.offsetWidth, | 479 |
479 element.offsetHeight), | 480 ClientRect get offset() { |
480 scroll = new SimpleClientRect(element.scrollLeft, | 481 assert(window.inMeasurementFrame || !_nodeInDocument(_element)); |
481 element.scrollTop, | 482 return new SimpleClientRect(_element.offsetLeft, |
482 element.scrollWidth, | 483 _element.offsetTop, |
483 element.scrollHeight), | 484 _element.offsetWidth, |
484 _boundingClientRect = element.getBoundingClientRect(), | 485 _element.offsetHeight); |
485 _clientRects = element.getClientRects(); | 486 } |
486 | 487 |
487 ClientRect get bounding() => | 488 ClientRect get scroll() { |
488 LevelDom.wrapClientRect(_boundingClientRect); | 489 assert(window.inMeasurementFrame || !_nodeInDocument(_element)); |
490 return new SimpleClientRect(_element.scrollLeft, | |
491 _element.scrollTop, | |
492 _element.scrollWidth, | |
493 _element.scrollHeight); | |
494 } | |
495 | |
496 ClientRect get bounding() { | |
497 assert(window.inMeasurementFrame || !_nodeInDocument(_element)); | |
498 return LevelDom.wrapClientRect(_element.getBoundingClientRect()); | |
499 } | |
489 | 500 |
490 List<ClientRect> get clientRects() { | 501 List<ClientRect> get clientRects() { |
491 final out = new List(_clientRects.length); | 502 assert(window.inMeasurementFrame || !_nodeInDocument(_element)); |
492 for (num i = 0; i < _clientRects.length; i++) { | 503 final clientRects = _element.getClientRects(); |
493 out[i] = LevelDom.wrapClientRect(_clientRects.item(i)); | 504 final out = new List(clientRects.length); |
505 for (num i = 0, len = clientRects.length; i < len; i++) { | |
506 out[i] = LevelDom.wrapClientRect(clientRects.item(i)); | |
494 } | 507 } |
495 return out; | 508 return out; |
496 } | 509 } |
497 } | 510 } |
498 | 511 |
499 final _START_TAG_REGEXP = const RegExp('<(\\w+)'); | 512 final _START_TAG_REGEXP = const RegExp('<(\\w+)'); |
500 | 513 |
501 /** @domName Element, HTMLElement */ | 514 /** @domName Element, HTMLElement */ |
502 class ElementWrappingImplementation extends NodeWrappingImplementation implement s Element { | 515 class ElementWrappingImplementation extends NodeWrappingImplementation implement s Element { |
503 | 516 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
567 * Element.removeAttribute | 580 * Element.removeAttribute |
568 */ | 581 */ |
569 Map<String, String> get attributes() { | 582 Map<String, String> get attributes() { |
570 if (_elementAttributeMap === null) { | 583 if (_elementAttributeMap === null) { |
571 _elementAttributeMap = new ElementAttributeMap._wrap(_ptr); | 584 _elementAttributeMap = new ElementAttributeMap._wrap(_ptr); |
572 } | 585 } |
573 return _elementAttributeMap; | 586 return _elementAttributeMap; |
574 } | 587 } |
575 | 588 |
576 void set attributes(Map<String, String> value) { | 589 void set attributes(Map<String, String> value) { |
590 assert(!_inMeasurementFrame || !_inDocument); | |
577 Map<String, String> attributes = this.attributes; | 591 Map<String, String> attributes = this.attributes; |
578 attributes.clear(); | 592 attributes.clear(); |
579 for (String key in value.getKeys()) { | 593 for (String key in value.getKeys()) { |
580 attributes[key] = value[key]; | 594 attributes[key] = value[key]; |
581 } | 595 } |
582 } | 596 } |
583 | 597 |
584 void set elements(Collection<Element> value) { | 598 void set elements(Collection<Element> value) { |
599 assert(!_inMeasurementFrame || !_inDocument); | |
585 final elements = this.elements; | 600 final elements = this.elements; |
586 elements.clear(); | 601 elements.clear(); |
587 elements.addAll(value); | 602 elements.addAll(value); |
588 } | 603 } |
589 | 604 |
590 /** | 605 /** |
591 * @domName childElementCount, firstElementChild, lastElementChild, | 606 * @domName childElementCount, firstElementChild, lastElementChild, |
592 * children, Node.appendChild | 607 * children, Node.appendChild |
593 */ | 608 */ |
594 ElementList get elements() { | 609 ElementList get elements() { |
595 if (_elements == null) { | 610 if (_elements == null) { |
596 _elements = new _ChildrenElementList._wrap(_ptr); | 611 _elements = new _ChildrenElementList._wrap(_ptr); |
597 } | 612 } |
598 return _elements; | 613 return _elements; |
599 } | 614 } |
600 | 615 |
601 /** @domName className, classList */ | 616 /** @domName className, classList */ |
602 Set<String> get classes() { | 617 Set<String> get classes() { |
603 if (_cssClassSet === null) { | 618 if (_cssClassSet === null) { |
604 _cssClassSet = new _CssClassSet(_ptr); | 619 _cssClassSet = new _CssClassSet(_ptr); |
605 } | 620 } |
606 return _cssClassSet; | 621 return _cssClassSet; |
607 } | 622 } |
608 | 623 |
609 void set classes(Collection<String> value) { | 624 void set classes(Collection<String> value) { |
625 assert(!_inMeasurementFrame || !_inDocument); | |
610 _CssClassSet classSet = classes; | 626 _CssClassSet classSet = classes; |
611 classSet.clear(); | 627 classSet.clear(); |
612 classSet.addAll(value); | 628 classSet.addAll(value); |
613 } | 629 } |
614 | 630 |
615 Map<String, String> get dataAttributes() { | 631 Map<String, String> get dataAttributes() { |
616 if (_dataAttributes === null) { | 632 if (_dataAttributes === null) { |
617 _dataAttributes = new _DataAttributeMap(attributes); | 633 _dataAttributes = new _DataAttributeMap(attributes); |
618 } | 634 } |
619 return _dataAttributes; | 635 return _dataAttributes; |
620 } | 636 } |
621 | 637 |
622 void set dataAttributes(Map<String, String> value) { | 638 void set dataAttributes(Map<String, String> value) { |
639 assert(!_inMeasurementFrame || !_inDocument); | |
623 Map<String, String> dataAttributes = this.dataAttributes; | 640 Map<String, String> dataAttributes = this.dataAttributes; |
624 dataAttributes.clear(); | 641 dataAttributes.clear(); |
625 for (String key in value.getKeys()) { | 642 for (String key in value.getKeys()) { |
626 dataAttributes[key] = value[key]; | 643 dataAttributes[key] = value[key]; |
627 } | 644 } |
628 } | 645 } |
629 | 646 |
630 String get contentEditable() => _ptr.contentEditable; | 647 String get contentEditable() => _ptr.contentEditable; |
631 | 648 |
649 // TODO(jacobr): does this dirty the layout? | |
arv (Not doing code reviews)
2012/01/17 20:25:00
Yes it does
Jacob
2012/01/21 03:01:25
Done.
| |
632 void set contentEditable(String value) { _ptr.contentEditable = value; } | 650 void set contentEditable(String value) { _ptr.contentEditable = value; } |
633 | 651 |
634 String get dir() => _ptr.dir; | 652 String get dir() => _ptr.dir; |
635 | 653 |
636 void set dir(String value) { _ptr.dir = value; } | 654 void set dir(String value) { |
655 assert(!_inMeasurementFrame || !_inDocument); | |
656 _ptr.dir = value; | |
657 } | |
637 | 658 |
638 bool get draggable() => _ptr.draggable; | 659 bool get draggable() => _ptr.draggable; |
639 | 660 |
640 void set draggable(bool value) { _ptr.draggable = value; } | 661 void set draggable(bool value) { _ptr.draggable = value; } |
641 | 662 |
642 Element get firstElementChild() => LevelDom.wrapElement(_ptr.firstElementChild ); | 663 Element get firstElementChild() => LevelDom.wrapElement(_ptr.firstElementChild ); |
643 | 664 |
644 bool get hidden() => _ptr.hidden; | 665 bool get hidden() => _ptr.hidden; |
645 | 666 |
646 void set hidden(bool value) { _ptr.hidden = value; } | 667 void set hidden(bool value) { |
668 assert(!_inMeasurementFrame || !_inDocument); | |
669 _ptr.hidden = value; | |
670 } | |
647 | 671 |
648 String get id() => _ptr.id; | 672 String get id() => _ptr.id; |
649 | 673 |
650 void set id(String value) { _ptr.id = value; } | 674 void set id(String value) { |
675 assert(!_inMeasurementFrame || !_inDocument); | |
676 _ptr.id = value; | |
677 } | |
651 | 678 |
652 String get innerHTML() => _ptr.innerHTML; | 679 String get innerHTML() => _ptr.innerHTML; |
653 | 680 |
654 void set innerHTML(String value) { _ptr.innerHTML = value; } | 681 void set innerHTML(String value) { |
682 assert(!_inMeasurementFrame || !_inDocument); | |
683 _ptr.innerHTML = value; | |
684 } | |
655 | 685 |
656 bool get isContentEditable() => _ptr.isContentEditable; | 686 bool get isContentEditable() => _ptr.isContentEditable; |
657 | 687 |
658 String get lang() => _ptr.lang; | 688 String get lang() => _ptr.lang; |
659 | 689 |
660 void set lang(String value) { _ptr.lang = value; } | 690 void set lang(String value) { |
691 assert(!_inMeasurementFrame || !_inDocument); | |
692 _ptr.lang = value; | |
693 } | |
661 | 694 |
662 Element get lastElementChild() => LevelDom.wrapElement(_ptr.lastElementChild); | 695 Element get lastElementChild() => LevelDom.wrapElement(_ptr.lastElementChild); |
663 | 696 |
664 Element get nextElementSibling() => LevelDom.wrapElement(_ptr.nextElementSibli ng); | 697 Element get nextElementSibling() => LevelDom.wrapElement(_ptr.nextElementSibli ng); |
665 | 698 |
666 Element get offsetParent() => LevelDom.wrapElement(_ptr.offsetParent); | 699 Element get offsetParent() => LevelDom.wrapElement(_ptr.offsetParent); |
667 | 700 |
668 String get outerHTML() => _ptr.outerHTML; | 701 String get outerHTML() => _ptr.outerHTML; |
669 | 702 |
670 Element get previousElementSibling() => LevelDom.wrapElement(_ptr.previousElem entSibling); | 703 Element get previousElementSibling() => LevelDom.wrapElement(_ptr.previousElem entSibling); |
671 | 704 |
672 bool get spellcheck() => _ptr.spellcheck; | 705 bool get spellcheck() => _ptr.spellcheck; |
673 | 706 |
674 void set spellcheck(bool value) { _ptr.spellcheck = value; } | 707 void set spellcheck(bool value) { |
708 assert(!_inMeasurementFrame || !_inDocument); | |
709 _ptr.spellcheck = value; | |
710 } | |
675 | 711 |
676 CSSStyleDeclaration get style() => LevelDom.wrapCSSStyleDeclaration(_ptr.style ); | 712 CSSStyleDeclaration get style() { |
713 // Changes to this CSSStyleDeclaration dirty the layout so we must pass | |
714 // the associated Element to the CSSStyleDeclaration constructor so that | |
715 // we can compute whether the current element is attached to the document | |
716 // which is required to decide whether modification inside a measurement | |
717 // frame is allowed. | |
718 final raw = _ptr.style; | |
719 return raw.dartObjectLocalStorage !== null ? | |
720 raw.dartObjectLocalStorage : | |
721 new CSSStyleDeclarationWrappingImplementation._wrapWithElement( | |
722 raw, this); | |
723 } | |
677 | 724 |
678 int get tabIndex() => _ptr.tabIndex; | 725 int get tabIndex() => _ptr.tabIndex; |
679 | 726 |
680 void set tabIndex(int value) { _ptr.tabIndex = value; } | 727 void set tabIndex(int value) { |
728 assert(!_inMeasurementFrame || !_inDocument); | |
729 _ptr.tabIndex = value; | |
730 } | |
681 | 731 |
682 String get tagName() => _ptr.tagName; | 732 String get tagName() => _ptr.tagName; |
683 | 733 |
684 String get title() => _ptr.title; | 734 String get title() => _ptr.title; |
685 | 735 |
686 void set title(String value) { _ptr.title = value; } | 736 void set title(String value) { |
737 assert(!_inMeasurementFrame || !_inDocument); | |
738 _ptr.title = value; | |
739 } | |
687 | 740 |
688 String get webkitdropzone() => _ptr.webkitdropzone; | 741 String get webkitdropzone() => _ptr.webkitdropzone; |
689 | 742 |
690 void set webkitdropzone(String value) { _ptr.webkitdropzone = value; } | 743 void set webkitdropzone(String value) { _ptr.webkitdropzone = value; } |
691 | 744 |
692 void blur() { | 745 void blur() { |
746 assert(!_inMeasurementFrame || !_inDocument); | |
693 _ptr.blur(); | 747 _ptr.blur(); |
694 } | 748 } |
695 | 749 |
696 bool contains(Node element) { | 750 bool contains(Node element) { |
697 return _ptr.contains(LevelDom.unwrap(element)); | 751 return _ptr.contains(LevelDom.unwrap(element)); |
698 } | 752 } |
699 | 753 |
700 void focus() { | 754 void focus() { |
755 assert(!_inMeasurementFrame || !_inDocument); | |
701 _ptr.focus(); | 756 _ptr.focus(); |
702 } | 757 } |
703 | 758 |
704 Element insertAdjacentElement([String where = null, Element element = null]) { | 759 Element insertAdjacentElement([String where = null, Element element = null]) { |
760 assert(!_inMeasurementFrame || !_inDocument); | |
705 return LevelDom.wrapElement(_ptr.insertAdjacentElement(where, LevelDom.unwra p(element))); | 761 return LevelDom.wrapElement(_ptr.insertAdjacentElement(where, LevelDom.unwra p(element))); |
706 } | 762 } |
707 | 763 |
708 void insertAdjacentHTML([String position_OR_where = null, String text = null]) { | 764 void insertAdjacentHTML([String position_OR_where = null, String text = null]) { |
765 assert(!_inMeasurementFrame || !_inDocument); | |
709 _ptr.insertAdjacentHTML(position_OR_where, text); | 766 _ptr.insertAdjacentHTML(position_OR_where, text); |
710 } | 767 } |
711 | 768 |
712 void insertAdjacentText([String where = null, String text = null]) { | 769 void insertAdjacentText([String where = null, String text = null]) { |
770 assert(!_inMeasurementFrame || !_inDocument); | |
713 _ptr.insertAdjacentText(where, text); | 771 _ptr.insertAdjacentText(where, text); |
714 } | 772 } |
715 | 773 |
716 /** @domName querySelector, Document.getElementById */ | 774 /** @domName querySelector, Document.getElementById */ |
717 Element query(String selectors) { | 775 Element query(String selectors) { |
718 // TODO(jacobr): scope fix. | 776 // TODO(jacobr): scope fix. |
719 return LevelDom.wrapElement(_ptr.querySelector(selectors)); | 777 return LevelDom.wrapElement(_ptr.querySelector(selectors)); |
720 } | 778 } |
721 | 779 |
722 /** | 780 /** |
(...skipping 24 matching lines...) Expand all Loading... | |
747 | 805 |
748 void set scrollLeft(int value) { _ptr.scrollLeft = value; } | 806 void set scrollLeft(int value) { _ptr.scrollLeft = value; } |
749 | 807 |
750 void set scrollTop(int value) { _ptr.scrollTop = value; } | 808 void set scrollTop(int value) { _ptr.scrollTop = value; } |
751 | 809 |
752 /** | 810 /** |
753 * @domName getClientRects, getBoundingClientRect, clientHeight, clientWidth, | 811 * @domName getClientRects, getBoundingClientRect, clientHeight, clientWidth, |
754 * clientTop, clientLeft, offsetHeight, offsetWidth, offsetTop, offsetLeft, | 812 * clientTop, clientLeft, offsetHeight, offsetWidth, offsetTop, offsetLeft, |
755 * scrollHeight, scrollWidth, scrollTop, scrollLeft | 813 * scrollHeight, scrollWidth, scrollTop, scrollLeft |
756 */ | 814 */ |
757 Future<ElementRect> get rect() { | 815 ElementRect get rect() { |
758 return _createMeasurementFuture( | 816 return new ElementRectWrappingImplementation(_ptr); |
759 () => new ElementRectWrappingImplementation(_ptr), | |
760 new Completer<ElementRect>()); | |
761 } | 817 } |
762 | 818 |
763 /** @domName Window.getComputedStyle */ | 819 /** @domName Window.getComputedStyle */ |
764 Future<CSSStyleDeclaration> get computedStyle() { | 820 CSSStyleDeclaration get computedStyle() { |
765 // TODO(jacobr): last param should be null, see b/5045788 | 821 // TODO(jacobr): last param should be null, see b/5045788 |
766 return getComputedStyle(''); | 822 return getComputedStyle(''); |
767 } | 823 } |
768 | 824 |
769 /** @domName Window.getComputedStyle */ | 825 /** @domName Window.getComputedStyle */ |
770 Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement) { | 826 CSSStyleDeclaration getComputedStyle(String pseudoElement) { |
771 return _createMeasurementFuture(() => | 827 assert(window.inMeasurementFrame || !_inDocument); |
772 LevelDom.wrapCSSStyleDeclaration( | 828 return LevelDom.wrapCSSStyleDeclaration( |
773 dom.window.getComputedStyle(_ptr, pseudoElement)), | 829 dom.window.getComputedStyle(_ptr, pseudoElement)); |
774 new Completer<CSSStyleDeclaration>()); | |
775 } | 830 } |
776 | 831 |
777 ElementEvents get on() { | 832 ElementEvents get on() { |
778 if (_on === null) { | 833 if (_on === null) { |
779 _on = new ElementEventsImplementation._wrap(_ptr); | 834 _on = new ElementEventsImplementation._wrap(_ptr); |
780 } | 835 } |
781 return _on; | 836 return _on; |
782 } | 837 } |
783 | 838 |
784 Element clone(bool deep) => super.clone(deep); | 839 Element clone(bool deep) => super.clone(deep); |
785 } | 840 } |
OLD | NEW |