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

Unified Diff: tools/dom/templates/html/impl/impl_Element.darttemplate

Issue 1327083002: Revert "Patched in Dartium JsInterop" (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: tools/dom/templates/html/impl/impl_Element.darttemplate
diff --git a/tools/dom/templates/html/impl/impl_Element.darttemplate b/tools/dom/templates/html/impl/impl_Element.darttemplate
index 86cc33ef7bb1461707bb9ebdd6d3682b21020771..6f5ae1b2cb8c68f4074eba8b89d93f64ab0d8b46 100644
--- a/tools/dom/templates/html/impl/impl_Element.darttemplate
+++ b/tools/dom/templates/html/impl/impl_Element.darttemplate
@@ -33,7 +33,7 @@ class _ChildrenElementList extends ListBase<Element>
_element._replaceChild(value, _childElements[index]);
}
- set length(int newLength) {
+ void set length(int newLength) {
// TODO(jacobr): remove children when length is reduced.
throw new UnsupportedError('Cannot resize element lists');
}
@@ -97,12 +97,7 @@ class _ChildrenElementList extends ListBase<Element>
bool remove(Object object) {
if (object is Element) {
Element element = object;
-$if JSINTEROP
- // We aren't preserving identity of nodes in JSINTEROP mode
- if (element.parentNode == _element) {
-$else
if (identical(element.parentNode, _element)) {
-$endif
_element._removeChild(element);
return true;
}
@@ -286,7 +281,7 @@ $endif
throw new UnsupportedError('Cannot modify list');
}
- set length(int newLength) {
+ void set length(int newLength) {
throw new UnsupportedError('Cannot modify list');
}
@@ -309,7 +304,7 @@ $endif
CssStyleDeclarationBase get style =>
new _CssStyleDeclarationSet(this);
- set classes(Iterable<String> value) {
+ void set classes(Iterable<String> value) {
// TODO(sra): This might be faster for Sets:
//
// new _MultiElementCssClassSet(this).writeClasses(value)
@@ -333,7 +328,7 @@ $!ELEMENT_STREAM_GETTERS
}
@DocsEditable()
-$(ANNOTATIONS)$(NATIVESPEC)class $CLASSNAME$EXTENDS$IMPLEMENTS {
+$(ANNOTATIONS)$(NATIVESPEC)abstract class $CLASSNAME$EXTENDS$IMPLEMENTS {
/**
* Creates an HTML element from a valid fragment of HTML.
@@ -380,7 +375,11 @@ $(ANNOTATIONS)$(NATIVESPEC)class $CLASSNAME$EXTENDS$IMPLEMENTS {
* }
* document.registerElement('x-custom', CustomElement);
*/
- Element.created() : super._created();
+ Element.created() : super._created() {
+ // Validate that this is a custom element & perform any additional
+ // initialization.
+ _initializeCustomElement(this);
+ }
/**
* Creates the HTML element specified by the tag name.
@@ -561,7 +560,7 @@ $(ANNOTATIONS)$(NATIVESPEC)class $CLASSNAME$EXTENDS$IMPLEMENTS {
*/
Map<String, String> get attributes => new _ElementAttributeMap(this);
- set attributes(Map<String, String> value) {
+ void set attributes(Map<String, String> value) {
Map<String, String> attributes = this.attributes;
attributes.clear();
for (String key in value.keys) {
@@ -581,9 +580,17 @@ $(ANNOTATIONS)$(NATIVESPEC)class $CLASSNAME$EXTENDS$IMPLEMENTS {
* element.style.background = 'red'; // Turns every child of body red.
* }
*/
+$if DART2JS
+ List<Element> get children => new _ChildrenElementList._wrap(this);
+$else
+ $if JSINTEROP
+ List<Element> get children => new FilteredElementList(this);
+ $else
List<Element> get children => new _ChildrenElementList._wrap(this);
+ $endif
+$endif
- set children(List<Element> value) {
+ void set children(List<Element> value) {
// Copy list first since we don't want liveness during iteration.
List copy = new List.from(value);
var children = this.children;
@@ -604,7 +611,11 @@ $(ANNOTATIONS)$(NATIVESPEC)class $CLASSNAME$EXTENDS$IMPLEMENTS {
*/
@DomName('Element.querySelectorAll')
ElementList<Element> querySelectorAll(String selectors) =>
+$if JSINTEROP
+ _querySelectorAll(selectors);
+$else
new _FrozenElementList._wrap(_querySelectorAll(selectors));
+$endif
/**
* Alias for [querySelector]. Note this function is deprecated because its
@@ -637,7 +648,7 @@ $(ANNOTATIONS)$(NATIVESPEC)class $CLASSNAME$EXTENDS$IMPLEMENTS {
*/
CssClassSet get classes => new _ElementCssClassSet(this);
- set classes(Iterable<String> value) {
+ void set classes(Iterable<String> value) {
// TODO(sra): Do this without reading the classes in clear() and addAll(),
// or writing the classes in clear().
CssClassSet classSet = classes;
@@ -671,7 +682,7 @@ $(ANNOTATIONS)$(NATIVESPEC)class $CLASSNAME$EXTENDS$IMPLEMENTS {
Map<String, String> get dataset =>
new _DataAttributeMap(attributes);
- set dataset(Map<String, String> value) {
+ void set dataset(Map<String, String> value) {
final data = this.dataset;
data.clear();
for (String key in value.keys) {
@@ -790,6 +801,7 @@ $(ANNOTATIONS)$(NATIVESPEC)class $CLASSNAME$EXTENDS$IMPLEMENTS {
@deprecated
void leftView() {}
+$if DART2JS
/**
* Creates a new AnimationEffect object whose target element is the object
* on which the method is called, and calls the play() method of the
@@ -804,14 +816,17 @@ $(ANNOTATIONS)$(NATIVESPEC)class $CLASSNAME$EXTENDS$IMPLEMENTS {
* var animation = elem.animate([
* {"transform": "translate(100px, -100%)"},
* {"transform" : "translate(400px, 500px)"}
- * ], 1500);
+ * ], 1500);
*
* The [frames] parameter is an Iterable<Map>, where the
* map entries specify CSS animation effects. The
* [timing] paramter can be a double, representing the number of milliseconds
* for the transition, or a Map with fields corresponding to those
* of the [Timing] object.
+ *
+ * This is not yet supported in Dartium.
**/
+// TODO(alanknight): Correct above comment once it works in Dartium.
@Experimental
@SupportedBrowser(SupportedBrowser.CHROME, '36')
AnimationPlayer animate(Iterable<Map<String, dynamic>> frames, [timing]) {
@@ -821,8 +836,7 @@ $(ANNOTATIONS)$(NATIVESPEC)class $CLASSNAME$EXTENDS$IMPLEMENTS {
}
var convertedFrames = frames;
if (convertedFrames is Iterable) {
- convertedFrames = convertDartToNative_List(
- frames.map(convertDartToNative_Dictionary).toList());
+ convertedFrames = frames.map(convertDartToNative_Dictionary).toList();
}
var convertedTiming = timing;
if (convertedTiming is Map) {
@@ -833,7 +847,6 @@ $(ANNOTATIONS)$(NATIVESPEC)class $CLASSNAME$EXTENDS$IMPLEMENTS {
: _animate(convertedFrames, convertedTiming);
}
-$if DART2JS
@DomName('Element.animate')
@JSName('animate')
@Experimental() // untriaged
@@ -867,7 +880,7 @@ $endif
// members of the component are used. The actual type is a subtype of Element.
get xtag => _xtag != null ? _xtag : this;
- set xtag(Element value) {
+ void set xtag(Element value) {
_xtag = value;
}
@@ -993,7 +1006,7 @@ $if DART2JS
@JSName('insertAdjacentText')
void _insertAdjacentText(String where, String text) native;
-
+
$else
$endif
@@ -1256,13 +1269,8 @@ $endif
// offsetParent, "tops out" at BODY. But people could conceivably pass in
// the document.documentElement and I want it to return an absolute offset,
// so we have the special case checking for HTML.
-$if JSINTEROP
- bool sameAsParent = current == parent;
-$else
- bool sameAsParent = identical(current, parent);
-$endif
- bool foundAsParent = sameAsParent || parent.tagName == 'HTML';
- if (current == null || sameAsParent) {
+ bool foundAsParent = identical(current, parent) || parent.tagName == 'HTML';
+ if (current == null || identical(current, parent)) {
if (foundAsParent) return new Point(0, 0);
throw new ArgumentError("Specified element is not a transitive offset "
"parent of this element.");
@@ -1320,11 +1328,11 @@ $endif
if (_parseDocument == null) {
_parseDocument = document.implementation.createHtmlDocument('');
_parseRange = _parseDocument.createRange();
-
+
// Workaround for Safari bug. Was also previously Chrome bug 229142
- // - URIs are not resolved in new doc.
- var base = _parseDocument.createElement('base');
- base.href = document.baseUri;
+ // - URIs are not resolved in new doc.
+ var base = _parseDocument.createElement('base');
+ base.href = document.baseUri;
_parseDocument.head.append(base);
}
var contextElement;
@@ -1382,7 +1390,7 @@ $endif
* This uses the default sanitization behavior to sanitize the HTML fragment,
* use [setInnerHtml] to override the default behavior.
*/
- set innerHtml(String html) {
+ void set innerHtml(String html) {
this.setInnerHtml(html);
}
@@ -1424,7 +1432,7 @@ $endif
* used when an explicit accessor is not available.
*/
ElementEvents get on => new ElementEvents(this);
-
+
/**
* Verify if any of the attributes that we use in the sanitizer look unexpected,
* possibly indicating DOM clobbering attacks.
@@ -1453,44 +1461,10 @@ $if DART2JS
})(#)''', element);
}
$else
-
- static var _namedNodeMap = js.context["NamedNodeMap"];
- static var _htmlCollection = js.context["HTMLCollection"];
- static var _nodeList = js.context["NodeList"];
-
- static bool _hasCorruptedAttributes(Element element) {
- var attributes = unwrap_jso(element)["attributes"];
- if (!attributes.instanceof(_namedNodeMap)) {
- return true;
- }
- var childNodes = unwrap_jso(element.childNodes);
- var length = childNodes["length"];
- var lastChild = unwrap_jso(element.lastChild);
- if (null != lastChild &&
- lastChild != childNodes[length - 1]) {
- return true;
- }
- var children = unwrap_jso(element._children);
- if (null != children) { // On Safari, children can apparently be null.
- if (!children.instanceof(_htmlCollection) ||
- children.instanceof(_nodeList)) {
- return true;
- }
- }
- return false;
- }
+ // Dartium isn't affected by these attacks, because it goes directly to the C++ API.
+ static bool _hasCorruptedAttributes(Element element) => false;
$endif
- String get _safeTagName {
- String result = 'element tag unavailable';
- try {
- if (tagName is String) {
- result = tagName;
- }
- } catch (e) {}
- return result;
- }
-
$if DART2JS
@DomName('Element.offsetHeight')
@DocsEditable()
@@ -1534,7 +1508,7 @@ $if DART2JS
@DomName('Element.scrollLeft')
@DocsEditable()
- set scrollLeft(int value) {
+ void set scrollLeft(int value) {
JS("void", "#.scrollLeft = #", this, value.round());
}
@@ -1544,7 +1518,7 @@ $if DART2JS
@DomName('Element.scrollTop')
@DocsEditable()
- set scrollTop(int value) {
+ void set scrollTop(int value) {
JS("void", "#.scrollTop = #", this, value.round());
}
@@ -1596,7 +1570,7 @@ $else
@DomName('Element.scrollLeft')
@DocsEditable()
- set scrollLeft(int value) => _blink.BlinkElement.instance.scrollLeft_Setter_(unwrap_jso(this), value.round());
+ void set scrollLeft(int value) => _blink.BlinkElement.instance.scrollLeft_Setter_(unwrap_jso(this), value.round());
@DomName('Element.scrollTop')
@DocsEditable()
@@ -1604,7 +1578,7 @@ $else
@DomName('Element.scrollTop')
@DocsEditable()
- set scrollTop(int value) => _blink.BlinkElement.instance.scrollTop_Setter_(unwrap_jso(this), value.round());
+ void set scrollTop(int value) => _blink.BlinkElement.instance.scrollTop_Setter_(unwrap_jso(this), value.round());
@DomName('Element.scrollWidth')
@DocsEditable()
@@ -1652,7 +1626,7 @@ $else
@DomName('Element.scrollLeft')
@DocsEditable()
- set scrollLeft(int value) => _blink.BlinkElement.scrollLeft_Setter(this, value.round());
+ void set scrollLeft(int value) => _blink.BlinkElement.scrollLeft_Setter(this, value.round());
@DomName('Element.scrollTop')
@DocsEditable()
@@ -1660,7 +1634,7 @@ $else
@DomName('Element.scrollTop')
@DocsEditable()
- set scrollTop(int value) => _blink.BlinkElement.scrollTop_Setter(this, value.round());
+ void set scrollTop(int value) => _blink.BlinkElement.scrollTop_Setter(this, value.round());
@DomName('Element.scrollWidth')
@DocsEditable()

Powered by Google App Engine
This is Rietveld 408576698