Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1059)

Side by Side Diff: tools/dom/templates/html/impl/impl_Element.darttemplate

Issue 1173403004: Changed to use JSInterop (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Re-gen'd somehow diffs stopped showing up in CL Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, 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 part of $LIBRARYNAME; 5 part of $LIBRARYNAME;
6 6
7 class _ChildrenElementList extends ListBase<Element> 7 class _ChildrenElementList extends ListBase<Element>
8 implements NodeListWrapper { 8 implements NodeListWrapper {
9 // Raw Element. 9 // Raw Element.
10 final Element _element; 10 final Element _element;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 // Wrapper over an immutable NodeList to make it implement ElementList. 256 // Wrapper over an immutable NodeList to make it implement ElementList.
257 // 257 //
258 // Clients are {`Document`, `DocumentFragment`}.`querySelectorAll` which are 258 // Clients are {`Document`, `DocumentFragment`}.`querySelectorAll` which are
259 // declared to return `ElementList`. This provides all the static analysis 259 // declared to return `ElementList`. This provides all the static analysis
260 // benefit so there is no need for this class have a constrained type parameter. 260 // benefit so there is no need for this class have a constrained type parameter.
261 // 261 //
262 class _FrozenElementList extends ListBase 262 class _FrozenElementList extends ListBase
263 implements ElementList, NodeListWrapper { 263 implements ElementList, NodeListWrapper {
264 final List<Node> _nodeList; 264 final List<Node> _nodeList;
265 265
266 $if JSINTEROP
267 var dartClass_instance;
268
269 _FrozenElementList._wrap(this._nodeList) {
270 this.dartClass_instance = this._nodeList;
271 }
272 $else
266 _FrozenElementList._wrap(this._nodeList); 273 _FrozenElementList._wrap(this._nodeList);
274 $endif
267 275
268 int get length => _nodeList.length; 276 int get length => _nodeList.length;
269 277
270 Element operator [](int index) => _nodeList[index]; 278 Element operator [](int index) => _nodeList[index];
271 279
272 void operator []=(int index, Element value) { 280 void operator []=(int index, Element value) {
273 throw new UnsupportedError('Cannot modify list'); 281 throw new UnsupportedError('Cannot modify list');
274 } 282 }
275 283
276 void set length(int newLength) { 284 void set length(int newLength) {
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 * 573 *
566 * This collection can be used to add and remove elements from the document. 574 * This collection can be used to add and remove elements from the document.
567 * 575 *
568 * var item = new DivElement(); 576 * var item = new DivElement();
569 * item.text = 'Something'; 577 * item.text = 'Something';
570 * document.body.children.add(item) // Item is now displayed on the page. 578 * document.body.children.add(item) // Item is now displayed on the page.
571 * for (var element in document.body.children) { 579 * for (var element in document.body.children) {
572 * element.style.background = 'red'; // Turns every child of body red. 580 * element.style.background = 'red'; // Turns every child of body red.
573 * } 581 * }
574 */ 582 */
583 $if DART2JS
575 List<Element> get children => new _ChildrenElementList._wrap(this); 584 List<Element> get children => new _ChildrenElementList._wrap(this);
585 $else
586 $if JSINTEROP
587 List<Element> get children => new FilteredElementList(this);
588 $else
589 List<Element> get children => new _ChildrenElementList._wrap(this);
590 $endif
591 $endif
576 592
577 void set children(List<Element> value) { 593 void set children(List<Element> value) {
578 // Copy list first since we don't want liveness during iteration. 594 // Copy list first since we don't want liveness during iteration.
579 List copy = new List.from(value); 595 List copy = new List.from(value);
580 var children = this.children; 596 var children = this.children;
581 children.clear(); 597 children.clear();
582 children.addAll(copy); 598 children.addAll(copy);
583 } 599 }
584 600
585 /** 601 /**
586 * Finds all descendent elements of this element that match the specified 602 * Finds all descendent elements of this element that match the specified
587 * group of selectors. 603 * group of selectors.
588 * 604 *
589 * [selectors] should be a string using CSS selector syntax. 605 * [selectors] should be a string using CSS selector syntax.
590 * 606 *
591 * var items = element.querySelectorAll('.itemClassName'); 607 * var items = element.querySelectorAll('.itemClassName');
592 * 608 *
593 * For details about CSS selector syntax, see the 609 * For details about CSS selector syntax, see the
594 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). 610 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
595 */ 611 */
596 @DomName('Element.querySelectorAll') 612 @DomName('Element.querySelectorAll')
597 ElementList<Element> querySelectorAll(String selectors) => 613 ElementList<Element> querySelectorAll(String selectors) =>
614 $if JSINTEROP
615 _querySelectorAll(selectors);
616 $else
598 new _FrozenElementList._wrap(_querySelectorAll(selectors)); 617 new _FrozenElementList._wrap(_querySelectorAll(selectors));
618 $endif
599 619
600 /** 620 /**
601 * Alias for [querySelector]. Note this function is deprecated because its 621 * Alias for [querySelector]. Note this function is deprecated because its
602 * semantics will be changing in the future. 622 * semantics will be changing in the future.
603 */ 623 */
604 @deprecated 624 @deprecated
605 @DomName('Element.querySelector') 625 @DomName('Element.querySelector')
606 @Experimental() 626 @Experimental()
607 Element query(String relativeSelectors) => querySelector(relativeSelectors); 627 Element query(String relativeSelectors) => querySelector(relativeSelectors);
608 628
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 @DocsEditable() 1500 @DocsEditable()
1481 void set scrollTop(int value) { 1501 void set scrollTop(int value) {
1482 JS("void", "#.scrollTop = #", this, value.round()); 1502 JS("void", "#.scrollTop = #", this, value.round());
1483 } 1503 }
1484 1504
1485 @DomName('Element.scrollWidth') 1505 @DomName('Element.scrollWidth')
1486 @DocsEditable() 1506 @DocsEditable()
1487 int get scrollWidth => JS('num', '#.scrollWidth', this).round(); 1507 int get scrollWidth => JS('num', '#.scrollWidth', this).round();
1488 1508
1489 $else 1509 $else
1510 $if JSINTEROP
1490 @DomName('Element.offsetHeight') 1511 @DomName('Element.offsetHeight')
1491 @DocsEditable() 1512 @DocsEditable()
1492 int get offsetHeight => _blink.BlinkElement.offsetHeight_Getter(this).round(); 1513 int get offsetHeight => _blink.BlinkElement.instance.offsetHeight_Getter_(unwr ap_jso(this)).round();
1493 1514
1494 @DomName('Element.offsetLeft') 1515 @DomName('Element.offsetLeft')
1495 @DocsEditable() 1516 @DocsEditable()
1496 int get offsetLeft => _blink.BlinkElement.offsetLeft_Getter(this).round(); 1517 int get offsetLeft => _blink.BlinkElement.instance.offsetLeft_Getter_(unwrap_j so(this)).round();
1497 1518
1498 @DomName('Element.offsetTop') 1519 @DomName('Element.offsetTop')
1499 @DocsEditable() 1520 @DocsEditable()
1500 int get offsetTop => _blink.BlinkElement.offsetTop_Getter(this).round(); 1521 int get offsetTop => _blink.BlinkElement.instance.offsetTop_Getter_(unwrap_jso (this)).round();
1501 1522
1502 @DomName('Element.offsetWidth') 1523 @DomName('Element.offsetWidth')
1503 @DocsEditable() 1524 @DocsEditable()
1504 int get offsetWidth => _blink.BlinkElement.offsetWidth_Getter(this).round(); 1525 int get offsetWidth => _blink.BlinkElement.instance.offsetWidth_Getter_(unwrap _jso(this)).round();
1505 1526
1506 @DomName('Element.clientHeight') 1527 @DomName('Element.clientHeight')
1507 @DocsEditable() 1528 @DocsEditable()
1508 int get clientHeight => _blink.BlinkElement.clientHeight_Getter(this).round(); 1529 int get clientHeight => _blink.BlinkElement.instance.clientHeight_Getter_(unwr ap_jso(this)).round();
1509 1530
1510 @DomName('Element.clientLeft') 1531 @DomName('Element.clientLeft')
1511 @DocsEditable() 1532 @DocsEditable()
1512 int get clientLeft => _blink.BlinkElement.clientLeft_Getter(this).round(); 1533 int get clientLeft => _blink.BlinkElement.instance.clientLeft_Getter_(unwrap_j so(this)).round();
1513 1534
1514 @DomName('Element.clientTop') 1535 @DomName('Element.clientTop')
1515 @DocsEditable() 1536 @DocsEditable()
1516 int get clientTop => _blink.BlinkElement.clientTop_Getter(this).round(); 1537 int get clientTop => _blink.BlinkElement.instance.clientTop_Getter_(unwrap_jso (this)).round();
1517 1538
1518 @DomName('Element.clientWidth') 1539 @DomName('Element.clientWidth')
1519 @DocsEditable() 1540 @DocsEditable()
1520 int get clientWidth => _blink.BlinkElement.clientWidth_Getter(this).round(); 1541 int get clientWidth => _blink.BlinkElement.instance.clientWidth_Getter_(unwrap _jso(this)).round();
1521 1542
1522 @DomName('Element.scrollHeight') 1543 @DomName('Element.scrollHeight')
1523 @DocsEditable() 1544 @DocsEditable()
1524 int get scrollHeight => _blink.BlinkElement.scrollHeight_Getter(this).round(); 1545 int get scrollHeight => _blink.BlinkElement.instance.scrollHeight_Getter_(unwr ap_jso(this)).round();
1525 1546
1526 @DomName('Element.scrollLeft') 1547 @DomName('Element.scrollLeft')
1527 @DocsEditable() 1548 @DocsEditable()
1528 int get scrollLeft => _blink.BlinkElement.scrollLeft_Getter(this).round(); 1549 int get scrollLeft => _blink.BlinkElement.instance.scrollLeft_Getter_(unwrap_j so(this)).round();
1529 1550
1530 @DomName('Element.scrollLeft') 1551 @DomName('Element.scrollLeft')
1531 @DocsEditable() 1552 @DocsEditable()
1532 void set scrollLeft(int value) => _blink.BlinkElement.scrollLeft_Setter(this, value.round()); 1553 void set scrollLeft(int value) => _blink.BlinkElement.instance.scrollLeft_Sett er_(unwrap_jso(this), value.round());
1533 1554
1534 @DomName('Element.scrollTop') 1555 @DomName('Element.scrollTop')
1535 @DocsEditable() 1556 @DocsEditable()
1536 int get scrollTop => _blink.BlinkElement.scrollTop_Getter(this).round(); 1557 int get scrollTop => _blink.BlinkElement.instance.scrollTop_Getter_(unwrap_jso (this)).round();
1537 1558
1538 @DomName('Element.scrollTop') 1559 @DomName('Element.scrollTop')
1539 @DocsEditable() 1560 @DocsEditable()
1540 void set scrollTop(int value) => _blink.BlinkElement.scrollTop_Setter(this, va lue.round()); 1561 void set scrollTop(int value) => _blink.BlinkElement.instance.scrollTop_Setter _(unwrap_jso(this), value.round());
1541 1562
1542 @DomName('Element.scrollWidth') 1563 @DomName('Element.scrollWidth')
1543 @DocsEditable() 1564 @DocsEditable()
1544 int get scrollWidth => _blink.BlinkElement.scrollWidth_Getter(this).round(); 1565 int get scrollWidth => _blink.BlinkElement.instance.scrollWidth_Getter_(unwrap _jso(this)).round();
1566 $else
1567 @DomName('Element.offsetHeight')
1568 @DocsEditable()
1569 int get offsetHeight => _blink.BlinkElement.offsetHeight_Getter_(this).round() ;
1570
1571 @DomName('Element.offsetLeft')
1572 @DocsEditable()
1573 int get offsetLeft => _blink.BlinkElement.offsetLeft_Getter_(this).round();
1574
1575 @DomName('Element.offsetTop')
1576 @DocsEditable()
1577 int get offsetTop => _blink.BlinkElement.offsetTop_Getter_(thi)).round();
1578
1579 @DomName('Element.offsetWidth')
1580 @DocsEditable()
1581 int get offsetWidth => _blink.BlinkElement.offsetWidth_Getter_(this).round();
1582
1583 @DomName('Element.clientHeight')
1584 @DocsEditable()
1585 int get clientHeight => _blink.BlinkElement.clientHeight_Getter_(this).round() ;
1586
1587 @DomName('Element.clientLeft')
1588 @DocsEditable()
1589 int get clientLeft => _blink.BlinkElement.clientLeft_Getter_(this).round();
1590
1591 @DomName('Element.clientTop')
1592 @DocsEditable()
1593 int get clientTop => _blink.BlinkElement.clientTop_Getter_(this).round();
1594
1595 @DomName('Element.clientWidth')
1596 @DocsEditable()
1597 int get clientWidth => _blink.BlinkElement.clientWidth_Getter_(this).round();
1598
1599 @DomName('Element.scrollHeight')
1600 @DocsEditable()
1601 int get scrollHeight => _blink.BlinkElement.scrollHeight_Getter_(this).round() ;
1602
1603 @DomName('Element.scrollLeft')
1604 @DocsEditable()
1605 int get scrollLeft => _blink.BlinkElement.scrollLeft_Getter_(this).round();
1606
1607 @DomName('Element.scrollLeft')
1608 @DocsEditable()
1609 void set scrollLeft(int value) => _blink.BlinkElement.scrollLeft_Setter_(this, value.round());
1610
1611 @DomName('Element.scrollTop')
1612 @DocsEditable()
1613 int get scrollTop => _blink.BlinkElement.scrollTop_Getter_(this).round();
1614
1615 @DomName('Element.scrollTop')
1616 @DocsEditable()
1617 void set scrollTop(int value) => _blink.BlinkElement.scrollTop_Setter_(this, v alue.round());
1618
1619 @DomName('Element.scrollWidth')
1620 @DocsEditable()
1621 int get scrollWidth => _blink.BlinkElement.scrollWidth_Getter_(this).round();
1622 $endif
1545 $endif 1623 $endif
1546 1624
1547 $!MEMBERS 1625 $!MEMBERS
1548 } 1626 }
1549 1627
1550 1628
1551 class _ElementFactoryProvider { 1629 class _ElementFactoryProvider {
1552 1630
1553 @DomName('Document.createElement') 1631 @DomName('Document.createElement')
1554 $if DART2JS 1632 $if DART2JS
(...skipping 27 matching lines...) Expand all
1582 const ScrollAlignment._internal(this._value); 1660 const ScrollAlignment._internal(this._value);
1583 toString() => 'ScrollAlignment.$_value'; 1661 toString() => 'ScrollAlignment.$_value';
1584 1662
1585 /// Attempt to align the element to the top of the scrollable area. 1663 /// Attempt to align the element to the top of the scrollable area.
1586 static const TOP = const ScrollAlignment._internal('TOP'); 1664 static const TOP = const ScrollAlignment._internal('TOP');
1587 /// Attempt to center the element in the scrollable area. 1665 /// Attempt to center the element in the scrollable area.
1588 static const CENTER = const ScrollAlignment._internal('CENTER'); 1666 static const CENTER = const ScrollAlignment._internal('CENTER');
1589 /// Attempt to align the element to the bottom of the scrollable area. 1667 /// Attempt to align the element to the bottom of the scrollable area.
1590 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); 1668 static const BOTTOM = const ScrollAlignment._internal('BOTTOM');
1591 } 1669 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698