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

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

Issue 1832713002: Optimize dartium dart:html bindings so real world application performance is acceptable. Improves d… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 static bool _hasCorruptedAttributesAdditionalCheck(Element element) { 1477 static bool _hasCorruptedAttributesAdditionalCheck(Element element) {
1478 return JS('bool', r'!(#.attributes instanceof NamedNodeMap)', element); 1478 return JS('bool', r'!(#.attributes instanceof NamedNodeMap)', element);
1479 } 1479 }
1480 $else 1480 $else
1481 1481
1482 static var _namedNodeMap = js.context["NamedNodeMap"]; 1482 static var _namedNodeMap = js.context["NamedNodeMap"];
1483 static var _htmlCollection = js.context["HTMLCollection"]; 1483 static var _htmlCollection = js.context["HTMLCollection"];
1484 static var _nodeList = js.context["NodeList"]; 1484 static var _nodeList = js.context["NodeList"];
1485 1485
1486 static bool _hasCorruptedAttributes(Element element) { 1486 static bool _hasCorruptedAttributes(Element element) {
1487 var attributes = unwrap_jso(element)["attributes"]; 1487 // We could support this method on Dartium but it does not seem worthwhile
Alan Knight 2016/03/25 21:39:09 They can be corrupted in a way that doesn't show u
Jacob 2016/03/30 00:19:00 I switched to a version of the cleaned up version
1488 if (!attributes.instanceof(_namedNodeMap)) { 1488 // given Dartium is a development platform and the checked method are
1489 return true; 1489 // implemented with C++ natives that cannot be corrupted.
1490 }
1491 var childNodes = unwrap_jso(element.childNodes);
1492 var length = childNodes["length"];
1493 var lastChild = unwrap_jso(element.lastChild);
1494 if (null != lastChild &&
1495 lastChild != childNodes[length - 1]) {
1496 return true;
1497 }
1498 var children = unwrap_jso(element._children);
1499 if (null != children) { // On Safari, children can apparently be null.
1500 if (!children.instanceof(_htmlCollection) ||
1501 children.instanceof(_nodeList)) {
1502 » return true;
1503 }
1504 }
1505 return false; 1490 return false;
1506 } 1491 }
1507 1492
1508 /// A secondary check for corruption, needed on IE 1493 /// A secondary check for corruption, needed on IE
1509 static bool _hasCorruptedAttributesAdditionalCheck(Element element) => false; 1494 static bool _hasCorruptedAttributesAdditionalCheck(Element element) => false;
1510 $endif 1495 $endif
1511 1496
1497 $if DART2JS
1512 static String _safeTagName(element) { 1498 static String _safeTagName(element) {
1513 String result = 'element tag unavailable'; 1499 String result = 'element tag unavailable';
1514 try { 1500 try {
1515 if (element.tagName is String) { 1501 if (element.tagName is String) {
1516 result = element.tagName; 1502 result = element.tagName;
1517 } 1503 }
1518 } catch (e) {} 1504 } catch (e) {}
1519 return result; 1505 return result;
1520 } 1506 }
1507 $else
1508 static String _safeTagName(element) {
1509 try {
Alan Knight 2016/03/25 21:39:09 Don't we need an implementation of this for Dartiu
Jacob 2016/03/30 00:19:00 not sure I understand. this is an implementation f
1510 // Safe as we plumb directly to a C++ native method.
1511 return element.tagName;
1512 } catch (e) {}
1513 return 'element tag unavailable';
1514 }
1515 $endif
1521 1516
1522 $if DART2JS 1517 $if DART2JS
1523 @DomName('Element.offsetParent') 1518 @DomName('Element.offsetParent')
1524 @DocsEditable() 1519 @DocsEditable()
1525 final Element offsetParent; 1520 final Element offsetParent;
1526 1521
1527 @DomName('Element.offsetHeight') 1522 @DomName('Element.offsetHeight')
1528 @DocsEditable() 1523 @DocsEditable()
1529 int get offsetHeight => JS('num', '#.offsetHeight', this).round(); 1524 int get offsetHeight => JS('num', '#.offsetHeight', this).round();
1530 1525
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 set scrollTop(int value) { 1558 set scrollTop(int value) {
1564 JS("void", "#.scrollTop = #", this, value.round()); 1559 JS("void", "#.scrollTop = #", this, value.round());
1565 } 1560 }
1566 1561
1567 @DomName('Element.scrollWidth') 1562 @DomName('Element.scrollWidth')
1568 @DocsEditable() 1563 @DocsEditable()
1569 int get scrollWidth => JS('num', '#.scrollWidth', this).round(); 1564 int get scrollWidth => JS('num', '#.scrollWidth', this).round();
1570 1565
1571 $else 1566 $else
1572 // Need to explicitly delegate because Element is no longer abstract for Darti um. 1567 // Need to explicitly delegate because Element is no longer abstract for Darti um.
1573 bool get isContentEditable => _blink.BlinkHTMLElement.instance.isContentEditab le_Getter_(unwrap_jso(this)); 1568 bool get isContentEditable => _blink.BlinkHTMLElement.instance.isContentEditab le_Getter_(this);
1574 void click() => _blink.BlinkHTMLElement.instance.click_Callback_0_(unwrap_jso( this)); 1569 void click() => _blink.BlinkHTMLElement.instance.click_Callback_0_(this);
1575 1570
1576 @DomName('Element.offsetParent') 1571 @DomName('Element.offsetParent')
1577 @DocsEditable() 1572 @DocsEditable()
1578 Element get offsetParent => wrap_jso(_blink.BlinkElement.instance.offsetParent _Getter_(unwrap_jso(this))); 1573 Element get offsetParent => _blink.BlinkElement.instance.offsetParent_Getter_( this);
1579 1574
1580 @DomName('Element.offsetHeight') 1575 @DomName('Element.offsetHeight')
1581 @DocsEditable() 1576 @DocsEditable()
1582 int get offsetHeight => _blink.BlinkElement.instance.offsetHeight_Getter_(unwr ap_jso(this)); 1577 int get offsetHeight => _blink.BlinkElement.instance.offsetHeight_Getter_(this );
1583 1578
1584 @DomName('Element.offsetLeft') 1579 @DomName('Element.offsetLeft')
1585 @DocsEditable() 1580 @DocsEditable()
1586 int get offsetLeft => _blink.BlinkElement.instance.offsetLeft_Getter_(unwrap_j so(this)); 1581 int get offsetLeft => _blink.BlinkElement.instance.offsetLeft_Getter_(this);
1587 1582
1588 @DomName('Element.offsetTop') 1583 @DomName('Element.offsetTop')
1589 @DocsEditable() 1584 @DocsEditable()
1590 int get offsetTop => _blink.BlinkElement.instance.offsetTop_Getter_(unwrap_jso (this)); 1585 int get offsetTop => _blink.BlinkElement.instance.offsetTop_Getter_(this);
1591 1586
1592 @DomName('Element.offsetWidth') 1587 @DomName('Element.offsetWidth')
1593 @DocsEditable() 1588 @DocsEditable()
1594 int get offsetWidth => _blink.BlinkElement.instance.offsetWidth_Getter_(unwrap _jso(this)); 1589 int get offsetWidth => _blink.BlinkElement.instance.offsetWidth_Getter_(this);
1595 1590
1596 @DomName('Element.scrollHeight') 1591 @DomName('Element.scrollHeight')
1597 @DocsEditable() 1592 @DocsEditable()
1598 int get scrollHeight => _blink.BlinkElement.instance.scrollHeight_Getter_(unwr ap_jso(this)).round(); 1593 int get scrollHeight => _blink.BlinkElement.instance.scrollHeight_Getter_(this ).round();
1599 1594
1600 @DomName('Element.scrollLeft') 1595 @DomName('Element.scrollLeft')
1601 @DocsEditable() 1596 @DocsEditable()
1602 int get scrollLeft => _blink.BlinkElement.instance.scrollLeft_Getter_(unwrap_j so(this)).round(); 1597 int get scrollLeft => _blink.BlinkElement.instance.scrollLeft_Getter_(this).ro und();
1603 1598
1604 @DomName('Element.scrollLeft') 1599 @DomName('Element.scrollLeft')
1605 @DocsEditable() 1600 @DocsEditable()
1606 set scrollLeft(int value) => _blink.BlinkElement.instance.scrollLeft_Setter_(u nwrap_jso(this), value.round()); 1601 set scrollLeft(int value) => _blink.BlinkElement.instance.scrollLeft_Setter_(t his, value.round());
1607 1602
1608 @DomName('Element.scrollTop') 1603 @DomName('Element.scrollTop')
1609 @DocsEditable() 1604 @DocsEditable()
1610 int get scrollTop => _blink.BlinkElement.instance.scrollTop_Getter_(unwrap_jso (this)).round(); 1605 int get scrollTop => _blink.BlinkElement.instance.scrollTop_Getter_(this).roun d();
1611 1606
1612 @DomName('Element.scrollTop') 1607 @DomName('Element.scrollTop')
1613 @DocsEditable() 1608 @DocsEditable()
1614 set scrollTop(int value) => _blink.BlinkElement.instance.scrollTop_Setter_(unw rap_jso(this), value.round()); 1609 set scrollTop(int value) => _blink.BlinkElement.instance.scrollTop_Setter_(thi s, value.round());
1615 1610
1616 @DomName('Element.scrollWidth') 1611 @DomName('Element.scrollWidth')
1617 @DocsEditable() 1612 @DocsEditable()
1618 int get scrollWidth => _blink.BlinkElement.instance.scrollWidth_Getter_(unwrap _jso(this)).round(); 1613 int get scrollWidth => _blink.BlinkElement.instance.scrollWidth_Getter_(this). round();
1619 $endif 1614 $endif
1620 1615
1621 $!MEMBERS 1616 $!MEMBERS
1622 } 1617 }
1623 1618
1624 1619
1625 class _ElementFactoryProvider { 1620 class _ElementFactoryProvider {
1626 1621
1627 @DomName('Document.createElement') 1622 @DomName('Document.createElement')
1628 $if DART2JS 1623 $if DART2JS
(...skipping 27 matching lines...) Expand all
1656 const ScrollAlignment._internal(this._value); 1651 const ScrollAlignment._internal(this._value);
1657 toString() => 'ScrollAlignment.$_value'; 1652 toString() => 'ScrollAlignment.$_value';
1658 1653
1659 /// Attempt to align the element to the top of the scrollable area. 1654 /// Attempt to align the element to the top of the scrollable area.
1660 static const TOP = const ScrollAlignment._internal('TOP'); 1655 static const TOP = const ScrollAlignment._internal('TOP');
1661 /// Attempt to center the element in the scrollable area. 1656 /// Attempt to center the element in the scrollable area.
1662 static const CENTER = const ScrollAlignment._internal('CENTER'); 1657 static const CENTER = const ScrollAlignment._internal('CENTER');
1663 /// Attempt to align the element to the bottom of the scrollable area. 1658 /// Attempt to align the element to the bottom of the scrollable area.
1664 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); 1659 static const BOTTOM = const ScrollAlignment._internal('BOTTOM');
1665 } 1660 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698