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