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

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

Issue 51613003: update ShadowDOM to 862dba015cb6bbe03a8b82e5ad43fe7177cf1bcc (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 throw Error('Cannot add more paths once started.'); 743 throw Error('Cannot add more paths once started.');
744 744
745 var path = path instanceof Path ? path : getPath(path); 745 var path = path instanceof Path ? path : getPath(path);
746 var value = path ? path.getValueFrom(object) : undefined; 746 var value = path ? path.getValueFrom(object) : undefined;
747 747
748 this.observed.push(object, path); 748 this.observed.push(object, path);
749 this.values.push(value); 749 this.values.push(value);
750 }, 750 },
751 751
752 start: function() { 752 start: function() {
753 this.started = true;
753 this.connect(); 754 this.connect();
754 this.sync(true); 755 this.sync(true);
755 }, 756 },
756 757
757 getValues: function() { 758 getValues: function() {
758 if (this.observedSet) 759 if (this.observedSet)
759 this.observedSet.reset(); 760 this.observedSet.reset();
760 761
761 var anyChanged = false; 762 var anyChanged = false;
762 for (var i = 0; i < this.observed.length; i = i+2) { 763 for (var i = 0; i < this.observed.length; i = i+2) {
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 get: function() {}, 1505 get: function() {},
1505 set: function(v) {}, 1506 set: function(v) {},
1506 configurable: true, 1507 configurable: true,
1507 enumerable: true 1508 enumerable: true
1508 }; 1509 };
1509 1510
1510 function isEventHandlerName(name) { 1511 function isEventHandlerName(name) {
1511 return /^on[a-z]+$/.test(name); 1512 return /^on[a-z]+$/.test(name);
1512 } 1513 }
1513 1514
1515 function isIdentifierName(name) {
1516 return /^\w[a-zA-Z_0-9]*$/.test(name);
1517 }
1518
1514 function getGetter(name) { 1519 function getGetter(name) {
1515 return hasEval ? 1520 return hasEval && isIdentifierName(name) ?
1516 new Function('return this.impl.' + name) : 1521 new Function('return this.impl.' + name) :
1517 function() { return this.impl[name]; }; 1522 function() { return this.impl[name]; };
1518 } 1523 }
1519 1524
1520 function getSetter(name) { 1525 function getSetter(name) {
1521 return hasEval ? 1526 return hasEval && isIdentifierName(name) ?
1522 new Function('v', 'this.impl.' + name + ' = v') : 1527 new Function('v', 'this.impl.' + name + ' = v') :
1523 function(v) { this.impl[name] = v; }; 1528 function(v) { this.impl[name] = v; };
1524 } 1529 }
1525 1530
1526 function getMethod(name) { 1531 function getMethod(name) {
1527 return hasEval ? 1532 return hasEval && isIdentifierName(name) ?
1528 new Function('return this.impl.' + name + 1533 new Function('return this.impl.' + name +
1529 '.apply(this.impl, arguments)') : 1534 '.apply(this.impl, arguments)') :
1530 function() { return this.impl[name].apply(this.impl, arguments); }; 1535 function() { return this.impl[name].apply(this.impl, arguments); };
1531 } 1536 }
1532 1537
1533 function installProperty(source, target, allowMethod) { 1538 function installProperty(source, target, allowMethod) {
1534 Object.getOwnPropertyNames(source).forEach(function(name) { 1539 Object.getOwnPropertyNames(source).forEach(function(name) {
1535 if (name in target) 1540 if (name in target)
1536 return; 1541 return;
1537 1542
(...skipping 2047 matching lines...) Expand 10 before | Expand all | Expand 10 after
3585 } 3590 }
3586 HTMLCanvasElement.prototype = Object.create(HTMLElement.prototype); 3591 HTMLCanvasElement.prototype = Object.create(HTMLElement.prototype);
3587 3592
3588 mixin(HTMLCanvasElement.prototype, { 3593 mixin(HTMLCanvasElement.prototype, {
3589 getContext: function() { 3594 getContext: function() {
3590 var context = this.impl.getContext.apply(this.impl, arguments); 3595 var context = this.impl.getContext.apply(this.impl, arguments);
3591 return context && wrap(context); 3596 return context && wrap(context);
3592 } 3597 }
3593 }); 3598 });
3594 3599
3595 registerWrapper(OriginalHTMLCanvasElement, HTMLCanvasElement); 3600 registerWrapper(OriginalHTMLCanvasElement, HTMLCanvasElement,
3601 document.createElement('canvas'));
3596 3602
3597 scope.wrappers.HTMLCanvasElement = HTMLCanvasElement; 3603 scope.wrappers.HTMLCanvasElement = HTMLCanvasElement;
3598 })(this.ShadowDOMPolyfill); 3604 })(this.ShadowDOMPolyfill);
3599 3605
3600 // Copyright 2013 The Polymer Authors. All rights reserved. 3606 // Copyright 2013 The Polymer Authors. All rights reserved.
3601 // Use of this source code is goverened by a BSD-style 3607 // Use of this source code is goverened by a BSD-style
3602 // license that can be found in the LICENSE file. 3608 // license that can be found in the LICENSE file.
3603 3609
3604 (function(scope) { 3610 (function(scope) {
3605 'use strict'; 3611 'use strict';
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3639 scope.wrappers.HTMLContentElement = HTMLContentElement; 3645 scope.wrappers.HTMLContentElement = HTMLContentElement;
3640 })(this.ShadowDOMPolyfill); 3646 })(this.ShadowDOMPolyfill);
3641 // Copyright 2013 The Polymer Authors. All rights reserved. 3647 // Copyright 2013 The Polymer Authors. All rights reserved.
3642 // Use of this source code is goverened by a BSD-style 3648 // Use of this source code is goverened by a BSD-style
3643 // license that can be found in the LICENSE file. 3649 // license that can be found in the LICENSE file.
3644 3650
3645 (function(scope) { 3651 (function(scope) {
3646 'use strict'; 3652 'use strict';
3647 3653
3648 var HTMLElement = scope.wrappers.HTMLElement; 3654 var HTMLElement = scope.wrappers.HTMLElement;
3655 var registerWrapper = scope.registerWrapper;
3656 var unwrap = scope.unwrap;
3657 var rewrap = scope.rewrap;
3658
3659 var OriginalHTMLImageElement = window.HTMLImageElement;
3660
3661 function HTMLImageElement(node) {
3662 HTMLElement.call(this, node);
3663 }
3664 HTMLImageElement.prototype = Object.create(HTMLElement.prototype);
3665
3666 registerWrapper(OriginalHTMLImageElement, HTMLImageElement,
3667 document.createElement('img'));
3668
3669 function Image(width, height) {
3670 if (!(this instanceof Image)) {
3671 throw new TypeError(
3672 'DOM object constructor cannot be called as a function.');
3673 }
3674
3675 var node = unwrap(document.createElement('img'));
3676 if (width !== undefined)
3677 node.width = width;
3678 if (height !== undefined)
3679 node.height = height;
3680 HTMLElement.call(this, node);
3681 rewrap(node, this);
3682 }
3683
3684 Image.prototype = HTMLImageElement.prototype;
3685
3686 scope.wrappers.HTMLImageElement = HTMLImageElement;
3687 scope.wrappers.Image = Image;
3688 })(this.ShadowDOMPolyfill);
3689
3690 // Copyright 2013 The Polymer Authors. All rights reserved.
3691 // Use of this source code is goverened by a BSD-style
3692 // license that can be found in the LICENSE file.
3693
3694 (function(scope) {
3695 'use strict';
3696
3697 var HTMLElement = scope.wrappers.HTMLElement;
3649 var mixin = scope.mixin; 3698 var mixin = scope.mixin;
3650 var registerWrapper = scope.registerWrapper; 3699 var registerWrapper = scope.registerWrapper;
3651 3700
3652 var OriginalHTMLShadowElement = window.HTMLShadowElement; 3701 var OriginalHTMLShadowElement = window.HTMLShadowElement;
3653 3702
3654 function HTMLShadowElement(node) { 3703 function HTMLShadowElement(node) {
3655 HTMLElement.call(this, node); 3704 HTMLElement.call(this, node);
3656 } 3705 }
3657 HTMLShadowElement.prototype = Object.create(HTMLElement.prototype); 3706 HTMLShadowElement.prototype = Object.create(HTMLElement.prototype);
3658 mixin(HTMLShadowElement.prototype, { 3707 mixin(HTMLShadowElement.prototype, {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
3783 // Copyright 2013 The Polymer Authors. All rights reserved. 3832 // Copyright 2013 The Polymer Authors. All rights reserved.
3784 // Use of this source code is goverened by a BSD-style 3833 // Use of this source code is goverened by a BSD-style
3785 // license that can be found in the LICENSE file. 3834 // license that can be found in the LICENSE file.
3786 3835
3787 (function(scope) { 3836 (function(scope) {
3788 'use strict'; 3837 'use strict';
3789 3838
3790 var mixin = scope.mixin; 3839 var mixin = scope.mixin;
3791 var registerWrapper = scope.registerWrapper; 3840 var registerWrapper = scope.registerWrapper;
3792 var unwrap = scope.unwrap; 3841 var unwrap = scope.unwrap;
3842 var unwrapIfNeeded = scope.unwrapIfNeeded;
3793 var wrap = scope.wrap; 3843 var wrap = scope.wrap;
3794 3844
3795 var OriginalCanvasRenderingContext2D = window.CanvasRenderingContext2D; 3845 var OriginalCanvasRenderingContext2D = window.CanvasRenderingContext2D;
3796 3846
3797 function CanvasRenderingContext2D(impl) { 3847 function CanvasRenderingContext2D(impl) {
3798 this.impl = impl; 3848 this.impl = impl;
3799 } 3849 }
3800 3850
3801 mixin(CanvasRenderingContext2D.prototype, { 3851 mixin(CanvasRenderingContext2D.prototype, {
3802 get canvas() { 3852 get canvas() {
3803 return wrap(this.impl.canvas); 3853 return wrap(this.impl.canvas);
3804 }, 3854 },
3805 3855
3806 drawImage: function() { 3856 drawImage: function() {
3807 arguments[0] = unwrap(arguments[0]); 3857 arguments[0] = unwrapIfNeeded(arguments[0]);
3808 this.impl.drawImage.apply(this.impl, arguments); 3858 this.impl.drawImage.apply(this.impl, arguments);
3809 }, 3859 },
3810 3860
3811 createPattern: function() { 3861 createPattern: function() {
3812 arguments[0] = unwrap(arguments[0]); 3862 arguments[0] = unwrap(arguments[0]);
3813 return this.impl.createPattern.apply(this.impl, arguments); 3863 return this.impl.createPattern.apply(this.impl, arguments);
3814 } 3864 }
3815 }); 3865 });
3816 3866
3817 registerWrapper(OriginalCanvasRenderingContext2D, CanvasRenderingContext2D); 3867 registerWrapper(OriginalCanvasRenderingContext2D, CanvasRenderingContext2D);
3818 3868
3819 scope.wrappers.CanvasRenderingContext2D = CanvasRenderingContext2D; 3869 scope.wrappers.CanvasRenderingContext2D = CanvasRenderingContext2D;
3820 })(this.ShadowDOMPolyfill); 3870 })(this.ShadowDOMPolyfill);
3821 3871
3822 // Copyright 2013 The Polymer Authors. All rights reserved. 3872 // Copyright 2013 The Polymer Authors. All rights reserved.
3823 // Use of this source code is goverened by a BSD-style 3873 // Use of this source code is goverened by a BSD-style
3824 // license that can be found in the LICENSE file. 3874 // license that can be found in the LICENSE file.
3825 3875
3826 (function(scope) { 3876 (function(scope) {
3827 'use strict'; 3877 'use strict';
3828 3878
3829 var mixin = scope.mixin; 3879 var mixin = scope.mixin;
3830 var registerWrapper = scope.registerWrapper; 3880 var registerWrapper = scope.registerWrapper;
3831 var unwrap = scope.unwrap; 3881 var unwrapIfNeeded = scope.unwrapIfNeeded;
3832 var wrap = scope.wrap; 3882 var wrap = scope.wrap;
3833 3883
3834 var OriginalWebGLRenderingContext = window.WebGLRenderingContext; 3884 var OriginalWebGLRenderingContext = window.WebGLRenderingContext;
3835 3885
3836 // IE10 does not have WebGL. 3886 // IE10 does not have WebGL.
3837 if (!OriginalWebGLRenderingContext) 3887 if (!OriginalWebGLRenderingContext)
3838 return; 3888 return;
3839 3889
3840 function WebGLRenderingContext(impl) { 3890 function WebGLRenderingContext(impl) {
3841 this.impl = impl; 3891 this.impl = impl;
3842 } 3892 }
3843 3893
3844 mixin(WebGLRenderingContext.prototype, { 3894 mixin(WebGLRenderingContext.prototype, {
3845 get canvas() { 3895 get canvas() {
3846 return wrap(this.impl.canvas); 3896 return wrap(this.impl.canvas);
3847 }, 3897 },
3848 3898
3849 texImage2D: function() { 3899 texImage2D: function() {
3850 arguments[5] = unwrap(arguments[5]); 3900 arguments[5] = unwrapIfNeeded(arguments[5]);
3851 this.impl.texImage2D.apply(this.impl, arguments); 3901 this.impl.texImage2D.apply(this.impl, arguments);
3852 }, 3902 },
3853 3903
3854 texSubImage2D: function() { 3904 texSubImage2D: function() {
3855 arguments[6] = unwrap(arguments[6]); 3905 arguments[6] = unwrapIfNeeded(arguments[6]);
3856 this.impl.texSubImage2D.apply(this.impl, arguments); 3906 this.impl.texSubImage2D.apply(this.impl, arguments);
3857 } 3907 }
3858 }); 3908 });
3859 3909
3860 registerWrapper(OriginalWebGLRenderingContext, WebGLRenderingContext); 3910 registerWrapper(OriginalWebGLRenderingContext, WebGLRenderingContext);
3861 3911
3862 scope.wrappers.WebGLRenderingContext = WebGLRenderingContext; 3912 scope.wrappers.WebGLRenderingContext = WebGLRenderingContext;
3863 })(this.ShadowDOMPolyfill); 3913 })(this.ShadowDOMPolyfill);
3864 3914
3865 // Copyright 2013 The Polymer Authors. All rights reserved. 3915 // Copyright 2013 The Polymer Authors. All rights reserved.
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after
5198 // for. 5248 // for.
5199 var elements = { 5249 var elements = {
5200 'a': 'HTMLAnchorElement', 5250 'a': 'HTMLAnchorElement',
5201 'applet': 'HTMLAppletElement', 5251 'applet': 'HTMLAppletElement',
5202 'area': 'HTMLAreaElement', 5252 'area': 'HTMLAreaElement',
5203 'audio': 'HTMLAudioElement', 5253 'audio': 'HTMLAudioElement',
5204 'br': 'HTMLBRElement', 5254 'br': 'HTMLBRElement',
5205 'base': 'HTMLBaseElement', 5255 'base': 'HTMLBaseElement',
5206 'body': 'HTMLBodyElement', 5256 'body': 'HTMLBodyElement',
5207 'button': 'HTMLButtonElement', 5257 'button': 'HTMLButtonElement',
5208 'canvas': 'HTMLCanvasElement',
5209 // 'command': 'HTMLCommandElement', // Not fully implemented in Gecko. 5258 // 'command': 'HTMLCommandElement', // Not fully implemented in Gecko.
5210 'dl': 'HTMLDListElement', 5259 'dl': 'HTMLDListElement',
5211 'datalist': 'HTMLDataListElement', 5260 'datalist': 'HTMLDataListElement',
5261 'data': 'HTMLDataElement',
5212 'dir': 'HTMLDirectoryElement', 5262 'dir': 'HTMLDirectoryElement',
5213 'div': 'HTMLDivElement', 5263 'div': 'HTMLDivElement',
5214 'embed': 'HTMLEmbedElement', 5264 'embed': 'HTMLEmbedElement',
5215 'fieldset': 'HTMLFieldSetElement', 5265 'fieldset': 'HTMLFieldSetElement',
5216 'font': 'HTMLFontElement', 5266 'font': 'HTMLFontElement',
5217 'form': 'HTMLFormElement', 5267 'form': 'HTMLFormElement',
5218 'frame': 'HTMLFrameElement', 5268 'frame': 'HTMLFrameElement',
5219 'frameset': 'HTMLFrameSetElement', 5269 'frameset': 'HTMLFrameSetElement',
5220 'hr': 'HTMLHRElement', 5270 'hr': 'HTMLHRElement',
5221 'head': 'HTMLHeadElement', 5271 'head': 'HTMLHeadElement',
5222 'h1': 'HTMLHeadingElement', 5272 'h1': 'HTMLHeadingElement',
5223 'html': 'HTMLHtmlElement', 5273 'html': 'HTMLHtmlElement',
5224 'iframe': 'HTMLIFrameElement', 5274 'iframe': 'HTMLIFrameElement',
5225
5226 // Uses HTMLSpanElement in Firefox.
5227 // https://bugzilla.mozilla.org/show_bug.cgi?id=843881
5228 // 'image',
5229
5230 'input': 'HTMLInputElement', 5275 'input': 'HTMLInputElement',
5231 'li': 'HTMLLIElement', 5276 'li': 'HTMLLIElement',
5232 'label': 'HTMLLabelElement', 5277 'label': 'HTMLLabelElement',
5233 'legend': 'HTMLLegendElement', 5278 'legend': 'HTMLLegendElement',
5234 'link': 'HTMLLinkElement', 5279 'link': 'HTMLLinkElement',
5235 'map': 'HTMLMapElement', 5280 'map': 'HTMLMapElement',
5281 'marquee': 'HTMLMarqueeElement',
5236 // 'media', Covered by audio and video 5282 // 'media', Covered by audio and video
5237 'menu': 'HTMLMenuElement', 5283 'menu': 'HTMLMenuElement',
5238 'menuitem': 'HTMLMenuItemElement', 5284 'menuitem': 'HTMLMenuItemElement',
5239 'meta': 'HTMLMetaElement', 5285 'meta': 'HTMLMetaElement',
5240 'meter': 'HTMLMeterElement', 5286 'meter': 'HTMLMeterElement',
5241 'del': 'HTMLModElement', 5287 'del': 'HTMLModElement',
5242 'ol': 'HTMLOListElement', 5288 'ol': 'HTMLOListElement',
5243 'object': 'HTMLObjectElement', 5289 'object': 'HTMLObjectElement',
5244 'optgroup': 'HTMLOptGroupElement', 5290 'optgroup': 'HTMLOptGroupElement',
5245 'option': 'HTMLOptionElement', 5291 'option': 'HTMLOptionElement',
5246 'output': 'HTMLOutputElement', 5292 'output': 'HTMLOutputElement',
5247 'p': 'HTMLParagraphElement', 5293 'p': 'HTMLParagraphElement',
5248 'param': 'HTMLParamElement', 5294 'param': 'HTMLParamElement',
5249 'pre': 'HTMLPreElement', 5295 'pre': 'HTMLPreElement',
5250 'progress': 'HTMLProgressElement', 5296 'progress': 'HTMLProgressElement',
5251 'q': 'HTMLQuoteElement', 5297 'q': 'HTMLQuoteElement',
5252 'script': 'HTMLScriptElement', 5298 'script': 'HTMLScriptElement',
5253 'select': 'HTMLSelectElement', 5299 'select': 'HTMLSelectElement',
5254 'source': 'HTMLSourceElement', 5300 'source': 'HTMLSourceElement',
5255 'span': 'HTMLSpanElement', 5301 'span': 'HTMLSpanElement',
5256 'style': 'HTMLStyleElement', 5302 'style': 'HTMLStyleElement',
5303 'time': 'HTMLTimeElement',
5257 'caption': 'HTMLTableCaptionElement', 5304 'caption': 'HTMLTableCaptionElement',
5258 // WebKit and Moz are wrong: 5305 // WebKit and Moz are wrong:
5259 // https://bugs.webkit.org/show_bug.cgi?id=111469 5306 // https://bugs.webkit.org/show_bug.cgi?id=111469
5260 // https://bugzilla.mozilla.org/show_bug.cgi?id=848096 5307 // https://bugzilla.mozilla.org/show_bug.cgi?id=848096
5261 // 'td': 'HTMLTableCellElement', 5308 // 'td': 'HTMLTableCellElement',
5262 'col': 'HTMLTableColElement', 5309 'col': 'HTMLTableColElement',
5263 'table': 'HTMLTableElement', 5310 'table': 'HTMLTableElement',
5264 'tr': 'HTMLTableRowElement', 5311 'tr': 'HTMLTableRowElement',
5265 'thead': 'HTMLTableSectionElement', 5312 'thead': 'HTMLTableSectionElement',
5266 'tbody': 'HTMLTableSectionElement', 5313 'tbody': 'HTMLTableSectionElement',
5267 'textarea': 'HTMLTextAreaElement', 5314 'textarea': 'HTMLTextAreaElement',
5315 'track': 'HTMLTrackElement',
5268 'title': 'HTMLTitleElement', 5316 'title': 'HTMLTitleElement',
5269 'ul': 'HTMLUListElement', 5317 'ul': 'HTMLUListElement',
5270 'video': 'HTMLVideoElement', 5318 'video': 'HTMLVideoElement',
5271 }; 5319 };
5272 5320
5273 function overrideConstructor(tagName) { 5321 function overrideConstructor(tagName) {
5274 var nativeConstructorName = elements[tagName]; 5322 var nativeConstructorName = elements[tagName];
5275 var nativeConstructor = window[nativeConstructorName]; 5323 var nativeConstructor = window[nativeConstructorName];
5276 if (!nativeConstructor) 5324 if (!nativeConstructor)
5277 return; 5325 return;
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
5935 var head = document.querySelector('head'); 5983 var head = document.querySelector('head');
5936 head.insertBefore(getSheet(), head.childNodes[0]); 5984 head.insertBefore(getSheet(), head.childNodes[0]);
5937 } 5985 }
5938 5986
5939 // exports 5987 // exports
5940 scope.ShadowCSS = ShadowCSS; 5988 scope.ShadowCSS = ShadowCSS;
5941 5989
5942 })(window.Platform); 5990 })(window.Platform);
5943 5991
5944 } 5992 }
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