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

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

Issue 1391353002: Dartium typed js interop work dart repo side of the change. Also tries to get (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « tools/dom/templates/html/impl/impl_Document.darttemplate ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // WARNING: Do not edit - generated code. 5 // WARNING: Do not edit - generated code.
6 6
7 part of $LIBRARYNAME; 7 part of $LIBRARYNAME;
8 8
9 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS { 9 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS {
10 $!MEMBERS 10 $!MEMBERS
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 throw new DomException.jsInterop("HierarchyRequestError: Only HTML element s can be customized."); 363 throw new DomException.jsInterop("HierarchyRequestError: Only HTML element s can be customized.");
364 } 364 }
365 365
366 if (_hasCreatedConstructor(classMirror)) { 366 if (_hasCreatedConstructor(classMirror)) {
367 // Start the hookup the JS way create an <x-foo> element that extends the 367 // Start the hookup the JS way create an <x-foo> element that extends the
368 // <x-base> custom element. Inherit its prototype and signal what tag is 368 // <x-base> custom element. Inherit its prototype and signal what tag is
369 // inherited: 369 // inherited:
370 // 370 //
371 // var myProto = Object.create(HTMLElement.prototype); 371 // var myProto = Object.create(HTMLElement.prototype);
372 // var myElement = document.registerElement('x-foo', {prototype: myPro to}); 372 // var myElement = document.registerElement('x-foo', {prototype: myPro to});
373 var baseElement = js.context[jsClassName]; 373 var baseElement = js.JsNative.getProperty(js.context, jsClassName);
374 if (baseElement == null) { 374 if (baseElement == null) {
375 // Couldn't find the HTML element so use a generic one. 375 // Couldn't find the HTML element so use a generic one.
376 baseElement = js.context['HTMLElement']; 376 baseElement = js.JsNative.getProperty(js.context, 'HTMLElement');
377 } 377 }
378 var elemProto = js.context['Object'].callMethod("create", [baseElement['pr ototype']]); 378 var elemProto = js.JsNative.callMethod(js.JsNative.getProperty(js.context, 'Object'), "create", [js.JsNative.getProperty(baseElement, 'prototype')]);
379 379
380 // Remember for any upgrading done in wrap_jso. 380 // Remember for any upgrading done in wrap_jso.
381 _knownCustomeElements[tag] = customElementClass; 381 _knownCustomeElements[tag] = customElementClass;
382 382
383 // TODO(terry): Hack to stop recursion re-creating custom element when the 383 // TODO(terry): Hack to stop recursion re-creating custom element when the
384 // created() constructor of the custom element does e.g., 384 // created() constructor of the custom element does e.g.,
385 // 385 //
386 // MyElement.created() : super.created() { 386 // MyElement.created() : super.created() {
387 // this.innerHtml = "<b>I'm an x-foo-with-markup!</b>"; 387 // this.innerHtml = "<b>I'm an x-foo-with-markup!</b>";
388 // } 388 // }
389 // 389 //
390 // sanitizing causes custom element to created recursively 390 // sanitizing causes custom element to created recursively
391 // until stack overflow. 391 // until stack overflow.
392 // 392 //
393 // See https://github.com/dart-lang/sdk/issues/23666 393 // See https://github.com/dart-lang/sdk/issues/23666
394 int creating = 0; 394 int creating = 0;
395 elemProto['createdCallback'] = new js.JsFunction.withThis(($this) { 395 // TODO(jacobr): warning:
396 elemProto['createdCallback'] = js.JsNative.withThis(($this) {
396 if (_getJSClassName(reflectClass(customElementClass).superclass) != null && creating < 2) { 397 if (_getJSClassName(reflectClass(customElementClass).superclass) != null && creating < 2) {
397 creating++; 398 creating++;
398 399
399 var dartClass; 400 var dartClass;
400 try { 401 try {
401 dartClass = _blink.Blink_Utils.constructElement(customElementClass, $this); 402 dartClass = _blink.Blink_Utils.constructElement(customElementClass, $this);
402 } catch (e) { 403 } catch (e) {
403 dartClass = HtmlElement.internalCreateHtmlElement(); 404 dartClass = HtmlElement.internalCreateHtmlElement();
404 throw e; 405 throw e;
405 } finally { 406 } finally {
406 // Need to remember the Dart class that was created for this custom so 407 // Need to remember the Dart class that was created for this custom so
407 // return it and setup the blink_jsObject to the $this that we'll be working 408 // return it and setup the blink_jsObject to the $this that we'll be working
408 // with as we talk to blink. 409 // with as we talk to blink.
409 $this['dart_class'] = dartClass; 410 js.setDartHtmlWrapperFor($this, dartClass);
410 411
411 creating--; 412 creating--;
412 } 413 }
413 } 414 }
414 }); 415 });
415 elemProto['attributeChangedCallback'] = new js.JsFunction.withThis(($this, attrName, oldVal, newVal) { 416 elemProto['attributeChangedCallback'] = new js.JsFunction.withThis(($this, attrName, oldVal, newVal) {
416 if ($this["dart_class"] != null && $this['dart_class'].attributeChanged != null) { 417 $this.attributeChanged(attrName, oldVal, newVal);
417 $this['dart_class'].attributeChanged(attrName, oldVal, newVal);
418 }
419 }); 418 });
420 elemProto['attachedCallback'] = new js.JsFunction.withThis(($this) { 419 elemProto['attachedCallback'] = new js.JsFunction.withThis(($this) {
421 if ($this["dart_class"] != null && $this['dart_class'].attached != null) { 420 $this.attached();
422 $this['dart_class'].attached();
423 }
424 }); 421 });
425 elemProto['detachedCallback'] = new js.JsFunction.withThis(($this) { 422 elemProto['detachedCallback'] = new js.JsFunction.withThis(($this) {
426 if ($this["dart_class"] != null && $this['dart_class'].detached != null) { 423 $this.detached();
427 $this['dart_class'].detached();
428 }
429 }); 424 });
430 // document.registerElement('x-foo', {prototype: elemProto, extends: exten dsTag}); 425 // document.registerElement('x-foo', {prototype: elemProto, extends: exten dsTag});
431 var jsMap = new js.JsObject.jsify({'prototype': elemProto, 'extends': exte ndsTag}); 426 var jsMap = new js.JsObject.jsify({'prototype': elemProto, 'extends': exte ndsTag});
432 js.context['document'].callMethod('registerElement', [tag, jsMap]); 427 js.Jsnative.callMethod(js.JsNative.getProperty(js.context, 'document'), 'r egisterElement', [tag, jsMap]);
433 } 428 }
434 $endif 429 $endif
435 } 430 }
436 431
437 /** *Deprecated*: use [registerElement] instead. */ 432 /** *Deprecated*: use [registerElement] instead. */
438 @deprecated 433 @deprecated
439 @Experimental() 434 @Experimental()
440 void register(String tag, Type customElementClass, {String extendsTag}) { 435 void register(String tag, Type customElementClass, {String extendsTag}) {
441 return registerElement(tag, customElementClass, extendsTag: extendsTag); 436 return registerElement(tag, customElementClass, extendsTag: extendsTag);
442 } 437 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 /// parameter must be provided. 486 /// parameter must be provided.
492 @Experimental() 487 @Experimental()
493 ElementUpgrader createElementUpgrader(Type type, {String extendsTag}) { 488 ElementUpgrader createElementUpgrader(Type type, {String extendsTag}) {
494 $if DART2JS 489 $if DART2JS
495 return new _JSElementUpgrader(this, type, extendsTag); 490 return new _JSElementUpgrader(this, type, extendsTag);
496 $else 491 $else
497 return new _VMElementUpgrader(this, type, extendsTag); 492 return new _VMElementUpgrader(this, type, extendsTag);
498 $endif 493 $endif
499 } 494 }
500 } 495 }
OLDNEW
« no previous file with comments | « tools/dom/templates/html/impl/impl_Document.darttemplate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698