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 29 matching lines...) Expand all Loading... |
54 | 55 |
55 int get length() { | 56 int get length() { |
56 return _childElements.length; | 57 return _childElements.length; |
57 } | 58 } |
58 | 59 |
59 Element operator [](int index) { | 60 Element operator [](int index) { |
60 return LevelDom.wrapElement(_childElements[index]); | 61 return LevelDom.wrapElement(_childElements[index]); |
61 } | 62 } |
62 | 63 |
63 void operator []=(int index, Element value) { | 64 void operator []=(int index, Element value) { |
| 65 assert(!_inMeasurementFrame || (!_inDocument && !value._inDocument)); |
64 _element.replaceChild(LevelDom.unwrap(value), _childElements.item(index)); | 66 _element.replaceChild(LevelDom.unwrap(value), _childElements.item(index)); |
65 } | 67 } |
66 | 68 |
67 void set length(int newLength) { | 69 void set length(int newLength) { |
68 // TODO(jacobr): remove children when length is reduced. | 70 // TODO(jacobr): remove children when length is reduced. |
69 throw const UnsupportedOperationException(''); | 71 throw const UnsupportedOperationException(''); |
70 } | 72 } |
71 | 73 |
72 Element add(Element value) { | 74 Element add(Element value) { |
| 75 assert(!_inMeasurementFrame || (!_inDocument && !value._inDocument)); |
73 _element.appendChild(LevelDom.unwrap(value)); | 76 _element.appendChild(LevelDom.unwrap(value)); |
74 return value; | 77 return value; |
75 } | 78 } |
76 | 79 |
77 Element addLast(Element value) => add(value); | 80 Element addLast(Element value) => add(value); |
78 | 81 |
79 Iterator<Element> iterator() => _toList().iterator(); | 82 Iterator<Element> iterator() => _toList().iterator(); |
80 | 83 |
81 void addAll(Collection<Element> collection) { | 84 void addAll(Collection<Element> collection) { |
| 85 assert(!_inMeasurementFrame || !_inDocument); |
82 for (Element element in collection) { | 86 for (Element element in collection) { |
| 87 assert(!_inMeasurementFrame || !element._inDocument); |
83 _element.appendChild(LevelDom.unwrap(element)); | 88 _element.appendChild(LevelDom.unwrap(element)); |
84 } | 89 } |
85 } | 90 } |
86 | 91 |
87 void sort(int compare(Element a, Element b)) { | 92 void sort(int compare(Element a, Element b)) { |
88 throw const UnsupportedOperationException('TODO(jacobr): should we impl?'); | 93 throw const UnsupportedOperationException('TODO(jacobr): should we impl?'); |
89 } | 94 } |
90 | 95 |
91 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { | 96 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { |
92 throw 'Not impl yet. todo(jacobr)'; | 97 throw 'Not impl yet. todo(jacobr)'; |
(...skipping 14 matching lines...) Expand all Loading... |
107 int indexOf(Element element, [int start = 0]) { | 112 int indexOf(Element element, [int start = 0]) { |
108 return Lists.indexOf(this, element, start, this.length); | 113 return Lists.indexOf(this, element, start, this.length); |
109 } | 114 } |
110 | 115 |
111 int lastIndexOf(Element element, [int start = null]) { | 116 int lastIndexOf(Element element, [int start = null]) { |
112 if (start === null) start = length - 1; | 117 if (start === null) start = length - 1; |
113 return Lists.lastIndexOf(this, element, start); | 118 return Lists.lastIndexOf(this, element, start); |
114 } | 119 } |
115 | 120 |
116 void clear() { | 121 void clear() { |
| 122 assert(!_inMeasurementFrame || !_inDocument); |
117 // It is unclear if we want to keep non element nodes? | 123 // It is unclear if we want to keep non element nodes? |
118 _element.textContent = ''; | 124 _element.textContent = ''; |
119 } | 125 } |
120 | 126 |
121 Element removeLast() { | 127 Element removeLast() { |
| 128 assert(!_inMeasurementFrame || !_inDocument); |
122 final last = this.last(); | 129 final last = this.last(); |
123 if (last != null) { | 130 if (last != null) { |
124 _element.removeChild(LevelDom.unwrap(last)); | 131 _element.removeChild(LevelDom.unwrap(last)); |
125 } | 132 } |
126 return last; | 133 return last; |
127 } | 134 } |
128 | 135 |
129 Element last() { | 136 Element last() { |
130 return LevelDom.wrapElement(_element.lastElementChild); | 137 return LevelDom.wrapElement(_element.lastElementChild); |
131 } | 138 } |
(...skipping 173 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, Node.appendChild | 592 * children, Node.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 |
617 void set contentEditable(String value) { _ptr.contentEditable = value; } | 634 void set contentEditable(String value) { |
| 635 assert(!_inMeasurementFrame || !_inDocument); |
| 636 _ptr.contentEditable = value; |
| 637 } |
618 | 638 |
619 String get dir() => _ptr.dir; | 639 String get dir() => _ptr.dir; |
620 | 640 |
621 void set dir(String value) { _ptr.dir = value; } | 641 void set dir(String value) { |
| 642 assert(!_inMeasurementFrame || !_inDocument); |
| 643 _ptr.dir = value; |
| 644 } |
622 | 645 |
623 bool get draggable() => _ptr.draggable; | 646 bool get draggable() => _ptr.draggable; |
624 | 647 |
625 void set draggable(bool value) { _ptr.draggable = value; } | 648 void set draggable(bool value) { _ptr.draggable = value; } |
626 | 649 |
627 Element get firstElementChild() => LevelDom.wrapElement(_ptr.firstElementChild
); | 650 Element get firstElementChild() => LevelDom.wrapElement(_ptr.firstElementChild
); |
628 | 651 |
629 bool get hidden() => _ptr.hidden; | 652 bool get hidden() => _ptr.hidden; |
630 | 653 |
631 void set hidden(bool value) { _ptr.hidden = value; } | 654 void set hidden(bool value) { |
| 655 assert(!_inMeasurementFrame || !_inDocument); |
| 656 _ptr.hidden = value; |
| 657 } |
632 | 658 |
633 String get id() => _ptr.id; | 659 String get id() => _ptr.id; |
634 | 660 |
635 void set id(String value) { _ptr.id = value; } | 661 void set id(String value) { |
| 662 assert(!_inMeasurementFrame || !_inDocument); |
| 663 _ptr.id = value; |
| 664 } |
636 | 665 |
637 String get innerHTML() => _ptr.innerHTML; | 666 String get innerHTML() => _ptr.innerHTML; |
638 | 667 |
639 void set innerHTML(String value) { _ptr.innerHTML = value; } | 668 void set innerHTML(String value) { |
| 669 assert(!_inMeasurementFrame || !_inDocument); |
| 670 _ptr.innerHTML = value; |
| 671 } |
640 | 672 |
641 bool get isContentEditable() => _ptr.isContentEditable; | 673 bool get isContentEditable() => _ptr.isContentEditable; |
642 | 674 |
643 String get lang() => _ptr.lang; | 675 String get lang() => _ptr.lang; |
644 | 676 |
645 void set lang(String value) { _ptr.lang = value; } | 677 void set lang(String value) { |
| 678 assert(!_inMeasurementFrame || !_inDocument); |
| 679 _ptr.lang = value; |
| 680 } |
646 | 681 |
647 Element get lastElementChild() => LevelDom.wrapElement(_ptr.lastElementChild); | 682 Element get lastElementChild() => LevelDom.wrapElement(_ptr.lastElementChild); |
648 | 683 |
649 Element get nextElementSibling() => LevelDom.wrapElement(_ptr.nextElementSibli
ng); | 684 Element get nextElementSibling() => LevelDom.wrapElement(_ptr.nextElementSibli
ng); |
650 | 685 |
651 Element get offsetParent() => LevelDom.wrapElement(_ptr.offsetParent); | 686 Element get offsetParent() => LevelDom.wrapElement(_ptr.offsetParent); |
652 | 687 |
653 String get outerHTML() => _ptr.outerHTML; | 688 String get outerHTML() => _ptr.outerHTML; |
654 | 689 |
655 Element get previousElementSibling() => LevelDom.wrapElement(_ptr.previousElem
entSibling); | 690 Element get previousElementSibling() => LevelDom.wrapElement(_ptr.previousElem
entSibling); |
656 | 691 |
657 bool get spellcheck() => _ptr.spellcheck; | 692 bool get spellcheck() => _ptr.spellcheck; |
658 | 693 |
659 void set spellcheck(bool value) { _ptr.spellcheck = value; } | 694 void set spellcheck(bool value) { |
| 695 assert(!_inMeasurementFrame || !_inDocument); |
| 696 _ptr.spellcheck = value; |
| 697 } |
660 | 698 |
661 CSSStyleDeclaration get style() => LevelDom.wrapCSSStyleDeclaration(_ptr.style
); | 699 CSSStyleDeclaration get 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 } |
662 | 711 |
663 int get tabIndex() => _ptr.tabIndex; | 712 int get tabIndex() => _ptr.tabIndex; |
664 | 713 |
665 void set tabIndex(int value) { _ptr.tabIndex = value; } | 714 void set tabIndex(int value) { |
| 715 assert(!_inMeasurementFrame || !_inDocument); |
| 716 _ptr.tabIndex = value; |
| 717 } |
666 | 718 |
667 String get tagName() => _ptr.tagName; | 719 String get tagName() => _ptr.tagName; |
668 | 720 |
669 String get title() => _ptr.title; | 721 String get title() => _ptr.title; |
670 | 722 |
671 void set title(String value) { _ptr.title = value; } | 723 void set title(String value) { |
| 724 assert(!_inMeasurementFrame || !_inDocument); |
| 725 _ptr.title = value; |
| 726 } |
672 | 727 |
673 String get webkitdropzone() => _ptr.webkitdropzone; | 728 String get webkitdropzone() => _ptr.webkitdropzone; |
674 | 729 |
675 void set webkitdropzone(String value) { _ptr.webkitdropzone = value; } | 730 void set webkitdropzone(String value) { _ptr.webkitdropzone = value; } |
676 | 731 |
677 void blur() { | 732 void blur() { |
| 733 assert(!_inMeasurementFrame || !_inDocument); |
678 _ptr.blur(); | 734 _ptr.blur(); |
679 } | 735 } |
680 | 736 |
681 bool contains(Node element) { | 737 bool contains(Node element) { |
682 return _ptr.contains(LevelDom.unwrap(element)); | 738 return _ptr.contains(LevelDom.unwrap(element)); |
683 } | 739 } |
684 | 740 |
685 void focus() { | 741 void focus() { |
| 742 assert(!_inMeasurementFrame || !_inDocument); |
686 _ptr.focus(); | 743 _ptr.focus(); |
687 } | 744 } |
688 | 745 |
689 Element insertAdjacentElement([String where = null, Element element = null]) { | 746 Element insertAdjacentElement([String where = null, Element element = null]) { |
| 747 assert(!_inMeasurementFrame || !_inDocument); |
690 return LevelDom.wrapElement(_ptr.insertAdjacentElement(where, LevelDom.unwra
p(element))); | 748 return LevelDom.wrapElement(_ptr.insertAdjacentElement(where, LevelDom.unwra
p(element))); |
691 } | 749 } |
692 | 750 |
693 void insertAdjacentHTML([String position_OR_where = null, String text = null])
{ | 751 void insertAdjacentHTML([String position_OR_where = null, String text = null])
{ |
| 752 assert(!_inMeasurementFrame || !_inDocument); |
694 _ptr.insertAdjacentHTML(position_OR_where, text); | 753 _ptr.insertAdjacentHTML(position_OR_where, text); |
695 } | 754 } |
696 | 755 |
697 void insertAdjacentText([String where = null, String text = null]) { | 756 void insertAdjacentText([String where = null, String text = null]) { |
| 757 assert(!_inMeasurementFrame || !_inDocument); |
698 _ptr.insertAdjacentText(where, text); | 758 _ptr.insertAdjacentText(where, text); |
699 } | 759 } |
700 | 760 |
701 /** @domName querySelector, Document.getElementById */ | 761 /** @domName querySelector, Document.getElementById */ |
702 Element query(String selectors) { | 762 Element query(String selectors) { |
703 // TODO(jacobr): scope fix. | 763 // TODO(jacobr): scope fix. |
704 return LevelDom.wrapElement(_ptr.querySelector(selectors)); | 764 return LevelDom.wrapElement(_ptr.querySelector(selectors)); |
705 } | 765 } |
706 | 766 |
707 /** | 767 /** |
(...skipping 24 matching lines...) Expand all Loading... |
732 | 792 |
733 void set scrollLeft(int value) { _ptr.scrollLeft = value; } | 793 void set scrollLeft(int value) { _ptr.scrollLeft = value; } |
734 | 794 |
735 void set scrollTop(int value) { _ptr.scrollTop = value; } | 795 void set scrollTop(int value) { _ptr.scrollTop = value; } |
736 | 796 |
737 /** | 797 /** |
738 * @domName getClientRects, getBoundingClientRect, clientHeight, clientWidth, | 798 * @domName getClientRects, getBoundingClientRect, clientHeight, clientWidth, |
739 * clientTop, clientLeft, offsetHeight, offsetWidth, offsetTop, offsetLeft, | 799 * clientTop, clientLeft, offsetHeight, offsetWidth, offsetTop, offsetLeft, |
740 * scrollHeight, scrollWidth, scrollTop, scrollLeft | 800 * scrollHeight, scrollWidth, scrollTop, scrollLeft |
741 */ | 801 */ |
742 Future<ElementRect> get rect() { | 802 ElementRect get rect() { |
743 return _createMeasurementFuture( | 803 return new ElementRectWrappingImplementation(_ptr); |
744 () => new ElementRectWrappingImplementation(_ptr), | |
745 new Completer<ElementRect>()); | |
746 } | 804 } |
747 | 805 |
748 /** @domName Window.getComputedStyle */ | 806 /** @domName Window.getComputedStyle */ |
749 Future<CSSStyleDeclaration> get computedStyle() { | 807 CSSStyleDeclaration get computedStyle() { |
750 // TODO(jacobr): last param should be null, see b/5045788 | 808 // TODO(jacobr): last param should be null, see b/5045788 |
751 return getComputedStyle(''); | 809 return getComputedStyle(''); |
752 } | 810 } |
753 | 811 |
754 /** @domName Window.getComputedStyle */ | 812 /** @domName Window.getComputedStyle */ |
755 Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement) { | 813 CSSStyleDeclaration getComputedStyle(String pseudoElement) { |
756 return _createMeasurementFuture(() => | 814 assert(window.inMeasurementFrame || !_inDocument); |
757 LevelDom.wrapCSSStyleDeclaration( | 815 return LevelDom.wrapCSSStyleDeclaration( |
758 dom.window.getComputedStyle(_ptr, pseudoElement)), | 816 dom.window.getComputedStyle(_ptr, pseudoElement)); |
759 new Completer<CSSStyleDeclaration>()); | |
760 } | 817 } |
761 | 818 |
762 ElementEvents get on() { | 819 ElementEvents get on() { |
763 if (_on === null) { | 820 if (_on === null) { |
764 _on = new ElementEventsImplementation._wrap(_ptr); | 821 _on = new ElementEventsImplementation._wrap(_ptr); |
765 } | 822 } |
766 return _on; | 823 return _on; |
767 } | 824 } |
768 | 825 |
769 Element clone(bool deep) => super.clone(deep); | 826 Element clone(bool deep) => super.clone(deep); |
770 } | 827 } |
OLD | NEW |