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

Side by Side Diff: pkg/shadow_dom/lib/shadow_dom.debug.js

Issue 26662009: rebuild shadow_dom at 12db94a66c79aa203d2dd59d239c60a3b3d44ed0 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/shadow_dom/lib/shadow_dom.min.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 if (!HTMLElement.prototype.createShadowRoot 1 if (!HTMLElement.prototype.createShadowRoot
2 || window.__forceShadowDomPolyfill) { 2 || window.__forceShadowDomPolyfill) {
3 3
4 /* 4 /*
5 * Copyright 2013 The Polymer Authors. All rights reserved. 5 * Copyright 2013 The Polymer Authors. All rights reserved.
6 * Use of this source code is governed by a BSD-style 6 * Use of this source code is governed by a BSD-style
7 * license that can be found in the LICENSE file. 7 * license that can be found in the LICENSE file.
8 */ 8 */
9 (function() { 9 (function() {
10 // TODO(jmesserly): fix dart:html to use unprefixed name 10 // TODO(jmesserly): fix dart:html to use unprefixed name
(...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 function GeneratedWrapper(node) { 1631 function GeneratedWrapper(node) {
1632 superWrapperConstructor.call(this, node); 1632 superWrapperConstructor.call(this, node);
1633 } 1633 }
1634 GeneratedWrapper.prototype = 1634 GeneratedWrapper.prototype =
1635 Object.create(superWrapperConstructor.prototype); 1635 Object.create(superWrapperConstructor.prototype);
1636 GeneratedWrapper.prototype.constructor = GeneratedWrapper; 1636 GeneratedWrapper.prototype.constructor = GeneratedWrapper;
1637 1637
1638 return GeneratedWrapper; 1638 return GeneratedWrapper;
1639 } 1639 }
1640 1640
1641 var OriginalDOMImplementation = DOMImplementation; 1641 var OriginalDOMImplementation = window.DOMImplementation;
1642 var OriginalEvent = Event; 1642 var OriginalEvent = window.Event;
1643 var OriginalNode = Node; 1643 var OriginalNode = window.Node;
1644 var OriginalWindow = Window; 1644 var OriginalWindow = window.Window;
1645 var OriginalRange = Range; 1645 var OriginalRange = window.Range;
1646 var OriginalCanvasRenderingContext2D = window.CanvasRenderingContext2D;
1647 var OriginalWebGLRenderingContext = window.WebGLRenderingContext;
1646 1648
1647 function isWrapper(object) { 1649 function isWrapper(object) {
1648 return object instanceof wrappers.EventTarget || 1650 return object instanceof wrappers.EventTarget ||
1649 object instanceof wrappers.Event || 1651 object instanceof wrappers.Event ||
1650 object instanceof wrappers.Range || 1652 object instanceof wrappers.Range ||
1651 object instanceof wrappers.DOMImplementation; 1653 object instanceof wrappers.DOMImplementation ||
1654 object instanceof wrappers.CanvasRenderingContext2D ||
1655 wrappers.WebGLRenderingContext &&
1656 object instanceof wrappers.WebGLRenderingContext;
1652 } 1657 }
1653 1658
1654 function isNative(object) { 1659 function isNative(object) {
1655 return object instanceof OriginalNode || 1660 return object instanceof OriginalNode ||
1656 object instanceof OriginalEvent || 1661 object instanceof OriginalEvent ||
1657 object instanceof OriginalWindow || 1662 object instanceof OriginalWindow ||
1658 object instanceof OriginalRange || 1663 object instanceof OriginalRange ||
1659 object instanceof OriginalDOMImplementation; 1664 object instanceof OriginalDOMImplementation ||
1665 object instanceof OriginalCanvasRenderingContext2D ||
1666 OriginalWebGLRenderingContext &&
1667 object instanceof OriginalWebGLRenderingContext;
1660 } 1668 }
1661 1669
1662 /** 1670 /**
1663 * Wraps a node in a WrapperNode. If there already exists a wrapper for the 1671 * Wraps a node in a WrapperNode. If there already exists a wrapper for the
1664 * |node| that wrapper is returned instead. 1672 * |node| that wrapper is returned instead.
1665 * @param {Node} node 1673 * @param {Node} node
1666 * @return {WrapperNode} 1674 * @return {WrapperNode}
1667 */ 1675 */
1668 function wrap(impl) { 1676 function wrap(impl) {
1669 if (impl === null) 1677 if (impl === null)
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
2058 function invoke(tuple, event, phase) { 2066 function invoke(tuple, event, phase) {
2059 var target = tuple.target; 2067 var target = tuple.target;
2060 var currentTarget = tuple.currentTarget; 2068 var currentTarget = tuple.currentTarget;
2061 2069
2062 var listeners = listenersTable.get(currentTarget); 2070 var listeners = listenersTable.get(currentTarget);
2063 if (!listeners) 2071 if (!listeners)
2064 return true; 2072 return true;
2065 2073
2066 if ('relatedTarget' in event) { 2074 if ('relatedTarget' in event) {
2067 var originalEvent = unwrap(event); 2075 var originalEvent = unwrap(event);
2068 var relatedTarget = wrap(originalEvent.relatedTarget); 2076 // X-Tag sets relatedTarget on a CustomEvent. If they do that there is no
2077 // way to have relatedTarget return the adjusted target but worse is that
2078 // the originalEvent might not have a relatedTarget so we hit an assert
2079 // when we try to wrap it.
2080 if (originalEvent.relatedTarget) {
2081 var relatedTarget = wrap(originalEvent.relatedTarget);
2069 2082
2070 var adjusted = adjustRelatedTarget(currentTarget, relatedTarget); 2083 var adjusted = adjustRelatedTarget(currentTarget, relatedTarget);
2071 if (adjusted === target) 2084 if (adjusted === target)
2072 return true; 2085 return true;
2073 2086
2074 relatedTargetTable.set(event, adjusted); 2087 relatedTargetTable.set(event, adjusted);
2088 }
2075 } 2089 }
2076 2090
2077 eventPhaseTable.set(event, phase); 2091 eventPhaseTable.set(event, phase);
2078 var type = event.type; 2092 var type = event.type;
2079 2093
2080 var anyRemoved = false; 2094 var anyRemoved = false;
2081 targetTable.set(event, target); 2095 targetTable.set(event, target);
2082 currentTargetTable.set(event, currentTarget); 2096 currentTargetTable.set(event, currentTarget);
2083 2097
2084 for (var i = 0; i < listeners.length; i++) { 2098 for (var i = 0; i < listeners.length; i++) {
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
2407 } 2421 }
2408 } 2422 }
2409 2423
2410 if (found && count === 1) { 2424 if (found && count === 1) {
2411 var target = getTargetToListenAt(this); 2425 var target = getTargetToListenAt(this);
2412 target.removeEventListener_(type, dispatchOriginalEvent, true); 2426 target.removeEventListener_(type, dispatchOriginalEvent, true);
2413 } 2427 }
2414 }, 2428 },
2415 dispatchEvent: function(event) { 2429 dispatchEvent: function(event) {
2416 var target = getTargetToListenAt(this); 2430 var target = getTargetToListenAt(this);
2417 return target.dispatchEvent_(unwrap(event)); 2431 var nativeEvent = unwrap(event);
2432 // Allow dispatching the same event again. This is safe because if user
2433 // code calls this during an existing dispatch of the same event the
2434 // native dispatchEvent throws (that is required by the spec).
2435 handledEventsTable.set(nativeEvent, false);
2436 return target.dispatchEvent_(nativeEvent);
2418 } 2437 }
2419 }; 2438 };
2420 2439
2421 if (OriginalEventTarget) 2440 if (OriginalEventTarget)
2422 registerWrapper(OriginalEventTarget, EventTarget); 2441 registerWrapper(OriginalEventTarget, EventTarget);
2423 2442
2424 function wrapEventTargetMethods(constructors) { 2443 function wrapEventTargetMethods(constructors) {
2425 forwardMethodsToWrapper(constructors, methodNames); 2444 forwardMethodsToWrapper(constructors, methodNames);
2426 } 2445 }
2427 2446
2428
2429 var originalElementFromPoint = document.elementFromPoint; 2447 var originalElementFromPoint = document.elementFromPoint;
2430 2448
2431 function elementFromPoint(self, document, x, y) { 2449 function elementFromPoint(self, document, x, y) {
2432 scope.renderAllPending(); 2450 scope.renderAllPending();
2433 2451
2434 var element = wrap(originalElementFromPoint.call(document.impl, x, y)); 2452 var element = wrap(originalElementFromPoint.call(document.impl, x, y));
2435 var targets = retarget(element, this) 2453 var targets = retarget(element, this)
2436 for (var i = 0; i < targets.length; i++) { 2454 for (var i = 0; i < targets.length; i++) {
2437 var target = targets[i]; 2455 var target = targets[i];
2438 if (target.currentTarget === self) 2456 if (target.currentTarget === self)
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
2923 * the renderer as needed. 2941 * the renderer as needed.
2924 * @private 2942 * @private
2925 */ 2943 */
2926 nodeWasAdded_: function() { 2944 nodeWasAdded_: function() {
2927 for (var child = this.firstChild; child; child = child.nextSibling) { 2945 for (var child = this.firstChild; child; child = child.nextSibling) {
2928 child.nodeWasAdded_(); 2946 child.nodeWasAdded_();
2929 } 2947 }
2930 }, 2948 },
2931 2949
2932 hasChildNodes: function() { 2950 hasChildNodes: function() {
2933 return this.firstChild === null; 2951 return this.firstChild !== null;
2934 }, 2952 },
2935 2953
2936 /** @type {Node} */ 2954 /** @type {Node} */
2937 get parentNode() { 2955 get parentNode() {
2938 // If the parentNode has not been overridden, use the original parentNode. 2956 // If the parentNode has not been overridden, use the original parentNode.
2939 return this.parentNode_ !== undefined ? 2957 return this.parentNode_ !== undefined ?
2940 this.parentNode_ : wrap(this.impl.parentNode); 2958 this.parentNode_ : wrap(this.impl.parentNode);
2941 }, 2959 },
2942 2960
2943 /** @type {Node} */ 2961 /** @type {Node} */
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
3475 }, 3493 },
3476 set outerHTML(value) { 3494 set outerHTML(value) {
3477 var p = this.parentNode; 3495 var p = this.parentNode;
3478 if (p) { 3496 if (p) {
3479 p.invalidateShadowRenderer(); 3497 p.invalidateShadowRenderer();
3480 this.impl.outerHTML = value; 3498 this.impl.outerHTML = value;
3481 } 3499 }
3482 } 3500 }
3483 }); 3501 });
3484 3502
3485 function getterRequiresRendering(name) { 3503 function getter(name) {
3486 defineGetter(HTMLElement, name, function() { 3504 return function() {
3487 scope.renderAllPending(); 3505 scope.renderAllPending();
3488 return this.impl[name]; 3506 return this.impl[name];
3489 }); 3507 };
3508 }
3509
3510 function getterRequiresRendering(name) {
3511 defineGetter(HTMLElement, name, getter(name));
3490 } 3512 }
3491 3513
3492 [ 3514 [
3493 'clientHeight', 3515 'clientHeight',
3494 'clientLeft', 3516 'clientLeft',
3495 'clientTop', 3517 'clientTop',
3496 'clientWidth', 3518 'clientWidth',
3497 'offsetHeight', 3519 'offsetHeight',
3498 'offsetLeft', 3520 'offsetLeft',
3499 'offsetTop', 3521 'offsetTop',
3500 'offsetWidth', 3522 'offsetWidth',
3501 'scrollHeight', 3523 'scrollHeight',
3524 'scrollWidth',
3525 ].forEach(getterRequiresRendering);
3526
3527 function getterAndSetterRequiresRendering(name) {
3528 Object.defineProperty(HTMLElement.prototype, name, {
3529 get: getter(name),
3530 set: function(v) {
3531 scope.renderAllPending();
3532 this.impl[name] = v;
3533 },
3534 configurable: true,
3535 enumerable: true
3536 });
3537 }
3538
3539 [
3502 'scrollLeft', 3540 'scrollLeft',
3503 'scrollTop', 3541 'scrollTop',
3504 'scrollWidth', 3542 ].forEach(getterAndSetterRequiresRendering);
3505 ].forEach(getterRequiresRendering);
3506 3543
3507 function methodRequiresRendering(name) { 3544 function methodRequiresRendering(name) {
3508 Object.defineProperty(HTMLElement.prototype, name, { 3545 Object.defineProperty(HTMLElement.prototype, name, {
3509 value: function() { 3546 value: function() {
3510 scope.renderAllPending(); 3547 scope.renderAllPending();
3511 return this.impl[name].apply(this.impl, arguments); 3548 return this.impl[name].apply(this.impl, arguments);
3512 }, 3549 },
3513 configurable: true, 3550 configurable: true,
3514 enumerable: true 3551 enumerable: true
3515 }); 3552 });
(...skipping 18 matching lines...) Expand all
3534 // Copyright 2013 The Polymer Authors. All rights reserved. 3571 // Copyright 2013 The Polymer Authors. All rights reserved.
3535 // Use of this source code is goverened by a BSD-style 3572 // Use of this source code is goverened by a BSD-style
3536 // license that can be found in the LICENSE file. 3573 // license that can be found in the LICENSE file.
3537 3574
3538 (function(scope) { 3575 (function(scope) {
3539 'use strict'; 3576 'use strict';
3540 3577
3541 var HTMLElement = scope.wrappers.HTMLElement; 3578 var HTMLElement = scope.wrappers.HTMLElement;
3542 var mixin = scope.mixin; 3579 var mixin = scope.mixin;
3543 var registerWrapper = scope.registerWrapper; 3580 var registerWrapper = scope.registerWrapper;
3581 var wrap = scope.wrap;
3582
3583 var OriginalHTMLCanvasElement = window.HTMLCanvasElement;
3584
3585 function HTMLCanvasElement(node) {
3586 HTMLElement.call(this, node);
3587 }
3588 HTMLCanvasElement.prototype = Object.create(HTMLElement.prototype);
3589
3590 mixin(HTMLCanvasElement.prototype, {
3591 getContext: function() {
3592 var context = this.impl.getContext.apply(this.impl, arguments);
3593 return context && wrap(context);
3594 }
3595 });
3596
3597 registerWrapper(OriginalHTMLCanvasElement, HTMLCanvasElement);
3598
3599 scope.wrappers.HTMLCanvasElement = HTMLCanvasElement;
3600 })(this.ShadowDOMPolyfill);
3601
3602 // Copyright 2013 The Polymer Authors. All rights reserved.
3603 // Use of this source code is goverened by a BSD-style
3604 // license that can be found in the LICENSE file.
3605
3606 (function(scope) {
3607 'use strict';
3608
3609 var HTMLElement = scope.wrappers.HTMLElement;
3610 var mixin = scope.mixin;
3611 var registerWrapper = scope.registerWrapper;
3544 3612
3545 var OriginalHTMLContentElement = window.HTMLContentElement; 3613 var OriginalHTMLContentElement = window.HTMLContentElement;
3546 3614
3547 function HTMLContentElement(node) { 3615 function HTMLContentElement(node) {
3548 HTMLElement.call(this, node); 3616 HTMLElement.call(this, node);
3549 } 3617 }
3550 HTMLContentElement.prototype = Object.create(HTMLElement.prototype); 3618 HTMLContentElement.prototype = Object.create(HTMLElement.prototype);
3551 mixin(HTMLContentElement.prototype, { 3619 mixin(HTMLContentElement.prototype, {
3552 get select() { 3620 get select() {
3553 return this.getAttribute('select'); 3621 return this.getAttribute('select');
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
3714 registerWrapper(OriginalHTMLUnknownElement, HTMLUnknownElement); 3782 registerWrapper(OriginalHTMLUnknownElement, HTMLUnknownElement);
3715 scope.wrappers.HTMLUnknownElement = HTMLUnknownElement; 3783 scope.wrappers.HTMLUnknownElement = HTMLUnknownElement;
3716 })(this.ShadowDOMPolyfill); 3784 })(this.ShadowDOMPolyfill);
3717 // Copyright 2013 The Polymer Authors. All rights reserved. 3785 // Copyright 2013 The Polymer Authors. All rights reserved.
3718 // Use of this source code is goverened by a BSD-style 3786 // Use of this source code is goverened by a BSD-style
3719 // license that can be found in the LICENSE file. 3787 // license that can be found in the LICENSE file.
3720 3788
3721 (function(scope) { 3789 (function(scope) {
3722 'use strict'; 3790 'use strict';
3723 3791
3792 var mixin = scope.mixin;
3793 var registerWrapper = scope.registerWrapper;
3794 var unwrap = scope.unwrap;
3795 var wrap = scope.wrap;
3796
3797 var OriginalCanvasRenderingContext2D = window.CanvasRenderingContext2D;
3798
3799 function CanvasRenderingContext2D(impl) {
3800 this.impl = impl;
3801 }
3802
3803 mixin(CanvasRenderingContext2D.prototype, {
3804 get canvas() {
3805 return wrap(this.impl.canvas);
3806 },
3807
3808 drawImage: function() {
3809 arguments[0] = unwrap(arguments[0]);
3810 this.impl.drawImage.apply(this.impl, arguments);
3811 },
3812
3813 createPattern: function() {
3814 arguments[0] = unwrap(arguments[0]);
3815 return this.impl.createPattern.apply(this.impl, arguments);
3816 }
3817 });
3818
3819 registerWrapper(OriginalCanvasRenderingContext2D, CanvasRenderingContext2D);
3820
3821 scope.wrappers.CanvasRenderingContext2D = CanvasRenderingContext2D;
3822 })(this.ShadowDOMPolyfill);
3823
3824 // Copyright 2013 The Polymer Authors. All rights reserved.
3825 // Use of this source code is goverened by a BSD-style
3826 // license that can be found in the LICENSE file.
3827
3828 (function(scope) {
3829 'use strict';
3830
3831 var mixin = scope.mixin;
3832 var registerWrapper = scope.registerWrapper;
3833 var unwrap = scope.unwrap;
3834 var wrap = scope.wrap;
3835
3836 var OriginalWebGLRenderingContext = window.WebGLRenderingContext;
3837
3838 // IE10 does not have WebGL.
3839 if (!OriginalWebGLRenderingContext)
3840 return;
3841
3842 function WebGLRenderingContext(impl) {
3843 this.impl = impl;
3844 }
3845
3846 mixin(WebGLRenderingContext.prototype, {
3847 get canvas() {
3848 return wrap(this.impl.canvas);
3849 },
3850
3851 texImage2D: function() {
3852 arguments[5] = unwrap(arguments[5]);
3853 this.impl.texImage2D.apply(this.impl, arguments);
3854 },
3855
3856 texSubImage2D: function() {
3857 arguments[6] = unwrap(arguments[6]);
3858 this.impl.texSubImage2D.apply(this.impl, arguments);
3859 }
3860 });
3861
3862 registerWrapper(OriginalWebGLRenderingContext, WebGLRenderingContext);
3863
3864 scope.wrappers.WebGLRenderingContext = WebGLRenderingContext;
3865 })(this.ShadowDOMPolyfill);
3866
3867 // Copyright 2013 The Polymer Authors. All rights reserved.
3868 // Use of this source code is goverened by a BSD-style
3869 // license that can be found in the LICENSE file.
3870
3871 (function(scope) {
3872 'use strict';
3873
3724 var GetElementsByInterface = scope.GetElementsByInterface; 3874 var GetElementsByInterface = scope.GetElementsByInterface;
3725 var ParentNodeInterface = scope.ParentNodeInterface; 3875 var ParentNodeInterface = scope.ParentNodeInterface;
3726 var SelectorsInterface = scope.SelectorsInterface; 3876 var SelectorsInterface = scope.SelectorsInterface;
3727 var mixin = scope.mixin; 3877 var mixin = scope.mixin;
3728 var registerObject = scope.registerObject; 3878 var registerObject = scope.registerObject;
3729 3879
3730 var DocumentFragment = registerObject(document.createDocumentFragment()); 3880 var DocumentFragment = registerObject(document.createDocumentFragment());
3731 mixin(DocumentFragment.prototype, ParentNodeInterface); 3881 mixin(DocumentFragment.prototype, ParentNodeInterface);
3732 mixin(DocumentFragment.prototype, SelectorsInterface); 3882 mixin(DocumentFragment.prototype, SelectorsInterface);
3733 mixin(DocumentFragment.prototype, GetElementsByInterface); 3883 mixin(DocumentFragment.prototype, GetElementsByInterface);
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
4654 for (var i = prototypes.length - 1; i >= 0; i--) { 4804 for (var i = prototypes.length - 1; i >= 0; i--) {
4655 newPrototype = Object.create(newPrototype); 4805 newPrototype = Object.create(newPrototype);
4656 } 4806 }
4657 4807
4658 // Add callbacks if present. 4808 // Add callbacks if present.
4659 // Names are taken from: 4809 // Names are taken from:
4660 // https://code.google.com/p/chromium/codesearch#chromium/src/third_part y/WebKit/Source/bindings/v8/CustomElementConstructorBuilder.cpp&sq=package:chrom ium&type=cs&l=156 4810 // https://code.google.com/p/chromium/codesearch#chromium/src/third_part y/WebKit/Source/bindings/v8/CustomElementConstructorBuilder.cpp&sq=package:chrom ium&type=cs&l=156
4661 // and not from the spec since the spec is out of date. 4811 // and not from the spec since the spec is out of date.
4662 [ 4812 [
4663 'createdCallback', 4813 'createdCallback',
4664 'enteredDocumentCallback', 4814 'enteredViewCallback',
4665 'leftDocumentCallback', 4815 'leftViewCallback',
4666 'attributeChangedCallback', 4816 'attributeChangedCallback',
4667 ].forEach(function(name) { 4817 ].forEach(function(name) {
4668 var f = prototype[name]; 4818 var f = prototype[name];
4669 if (!f) 4819 if (!f)
4670 return; 4820 return;
4671 newPrototype[name] = function() { 4821 newPrototype[name] = function() {
4672 f.apply(wrap(this), arguments); 4822 f.apply(wrap(this), arguments);
4673 }; 4823 };
4674 }); 4824 });
4675 4825
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
5730 css.push(cssRules[i].cssText); 5880 css.push(cssRules[i].cssText);
5731 } 5881 }
5732 return css.join('\n\n'); 5882 return css.join('\n\n');
5733 } 5883 }
5734 5884
5735 // exports 5885 // exports
5736 scope.ShadowCSS.shimShadowDOMStyling2 = shimShadowDOMStyling2; 5886 scope.ShadowCSS.shimShadowDOMStyling2 = shimShadowDOMStyling2;
5737 })(window.Platform); 5887 })(window.Platform);
5738 5888
5739 } 5889 }
OLDNEW
« no previous file with comments | « no previous file | pkg/shadow_dom/lib/shadow_dom.min.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698