Diff
Modified: trunk/LayoutTests/ChangeLog (136902 => 136903)
--- trunk/LayoutTests/ChangeLog 2012-12-06 23:31:39 UTC (rev 136902)
+++ trunk/LayoutTests/ChangeLog 2012-12-06 23:47:58 UTC (rev 136903)
@@ -1,3 +1,17 @@
+2012-12-06 Adam Klein <ad...@chromium.org>
+
+ [HTMLTemplateElement] make content readonly and cloneNode(deep) clone content
+ https://bugs.webkit.org/show_bug.cgi?id=104181
+
+ Reviewed by Adam Barth.
+
+ * fast/dom/HTMLTemplateElement/cloneNode-expected.txt:
+ * fast/dom/HTMLTemplateElement/cloneNode.html:
+ * fast/dom/HTMLTemplateElement/contentWrappers-expected.txt: Added.
+ * fast/dom/HTMLTemplateElement/contentWrappers.html: Added.
+ * fast/dom/HTMLTemplateElement/ownerDocument-expected.txt:
+ * fast/dom/HTMLTemplateElement/ownerDocument.html:
+
2012-12-06 Emil A Eklund <e...@chromium.org>
Unreviewed chromium rebaseline for r136885.
Modified: trunk/LayoutTests/fast/dom/HTMLTemplateElement/cloneNode-expected.txt (136902 => 136903)
--- trunk/LayoutTests/fast/dom/HTMLTemplateElement/cloneNode-expected.txt 2012-12-06 23:31:39 UTC (rev 136902)
+++ trunk/LayoutTests/fast/dom/HTMLTemplateElement/cloneNode-expected.txt 2012-12-06 23:47:58 UTC (rev 136903)
@@ -4,5 +4,10 @@
PASS template.content.childNodes.length is 1
-PASS clone.content.childNodes.length is 0
+PASS clone.content.childNodes.length is 1
+PASS clone.outerHTML is template.outerHTML
+PASS clone.content.firstChild is not template.content.firstChild
+PASS clone.content is not template.content
+PASS clone.firstChild.tagName is "DIV"
+PASS clone.firstChild is not div
Modified: trunk/LayoutTests/fast/dom/HTMLTemplateElement/cloneNode.html (136902 => 136903)
--- trunk/LayoutTests/fast/dom/HTMLTemplateElement/cloneNode.html 2012-12-06 23:31:39 UTC (rev 136902)
+++ trunk/LayoutTests/fast/dom/HTMLTemplateElement/cloneNode.html 2012-12-06 23:47:58 UTC (rev 136903)
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<template id="template">Contents</template>
+<template id="template"><span>Contents</span></template>
<script src=""
<script>
@@ -9,8 +9,15 @@
testFailed('This test requires ENABLE(TEMPLATE_ELEMENT)');
var template = document.getElementById('template');
+var div = template.appendChild(document.createElement('div'));
+
shouldBe('template.content.childNodes.length', '1');
var clone = template.cloneNode(true);
-shouldBe('clone.content.childNodes.length', '0');
+shouldBe('clone.content.childNodes.length', '1');
+shouldBe('clone.outerHTML', 'template.outerHTML');
+shouldNotBe('clone.content.firstChild', 'template.content.firstChild');
+shouldNotBe('clone.content', 'template.content');
+shouldBe('clone.firstChild.tagName', '"DIV"');
+shouldNotBe('clone.firstChild', 'div');
</script>
Added: trunk/LayoutTests/fast/dom/HTMLTemplateElement/contentWrappers-expected.txt (0 => 136903)
--- trunk/LayoutTests/fast/dom/HTMLTemplateElement/contentWrappers-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLTemplateElement/contentWrappers-expected.txt 2012-12-06 23:47:58 UTC (rev 136903)
@@ -0,0 +1,13 @@
+Test HTMLTemplateElement content node wrappers have the correct lifetime.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS span.tagName is "SPAN"
+PASS span.expando is "present"
+PASS span.tagName is "SPAN"
+PASS span.expando is "present"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/HTMLTemplateElement/contentWrappers.html (0 => 136903)
--- trunk/LayoutTests/fast/dom/HTMLTemplateElement/contentWrappers.html (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLTemplateElement/contentWrappers.html 2012-12-06 23:47:58 UTC (rev 136903)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<template id="template"><span></span></template>
+<script src=""
+<script>
+description('Test HTMLTemplateElement content node wrappers have the correct lifetime.');
+
+if (!window.HTMLTemplateElement)
+ testFailed('This test requires ENABLE(TEMPLATE_TAG)');
+
+var template = document.getElementById('template');
+var span = template.content.firstChild;
+shouldBe('span.tagName', '"SPAN"');
+
+span.expando = 'present';
+shouldBe('span.expando', '"present"');
+
+span = undefined;
+gc();
+span = template.content.firstChild;
+shouldBe('span.tagName', '"SPAN"');
+shouldBe('span.expando', '"present"');
+</script>
+<script src=""
Modified: trunk/LayoutTests/fast/dom/HTMLTemplateElement/ownerDocument-expected.txt (136902 => 136903)
--- trunk/LayoutTests/fast/dom/HTMLTemplateElement/ownerDocument-expected.txt 2012-12-06 23:31:39 UTC (rev 136902)
+++ trunk/LayoutTests/fast/dom/HTMLTemplateElement/ownerDocument-expected.txt 2012-12-06 23:47:58 UTC (rev 136903)
@@ -4,6 +4,7 @@
PASS template.ownerDocument is document
+PASS template.content is content
PASS templateContentOwnerDocument instanceof HTMLDocument is true
PASS document is not templateContentOwnerDocument
PASS template.content.firstChild.ownerDocument is templateContentOwnerDocument
@@ -12,13 +13,6 @@
PASS innerTemplate.ownerDocument instanceof HTMLDocument is true
PASS template2.ownerDocument is document
PASS template2.content.ownerDocument is templateContentOwnerDocument
-PASS df.ownerDocument is document
-PASS span.ownerDocument is document
-PASS df.ownerDocument is templateContentOwnerDocument
-PASS span.ownerDocument is templateContentOwnerDocument
-PASS template.content = document.createElement("span"); threw exception Error: TypeMismatchError: DOM Exception 17.
-PASS template.content = document.createTextNode("text"); threw exception Error: TypeMismatchError: DOM Exception 17.
-PASS template.content = new WebKitShadowRoot(div) threw exception Error: TypeMismatchError: DOM Exception 17.
PASS template3.ownerDocument is document
PASS template3.content.ownerDocument is templateContentOwnerDocument
PASS template3.content.firstChild.ownerDocument is templateContentOwnerDocument
Modified: trunk/LayoutTests/fast/dom/HTMLTemplateElement/ownerDocument.html (136902 => 136903)
--- trunk/LayoutTests/fast/dom/HTMLTemplateElement/ownerDocument.html 2012-12-06 23:31:39 UTC (rev 136902)
+++ trunk/LayoutTests/fast/dom/HTMLTemplateElement/ownerDocument.html 2012-12-06 23:47:58 UTC (rev 136903)
@@ -13,6 +13,11 @@
var template = document.getElementById('template');
shouldBe('template.ownerDocument', 'document');
+var content = template.content;
+var df = document.createDocumentFragment();
+template.content = df;
+shouldBe('template.content', 'content');
+
var templateContentOwnerDocument = template.content.ownerDocument;
shouldBeTrue('templateContentOwnerDocument instanceof HTMLDocument');
shouldNotBe('document', 'templateContentOwnerDocument');
@@ -27,23 +32,7 @@
shouldBe('template2.ownerDocument', 'document');
shouldBe('template2.content.ownerDocument', 'templateContentOwnerDocument');
-var df = document.createDocumentFragment();
-var span = df.appendChild(document.createElement('span'));
-shouldBe('df.ownerDocument', 'document');
-shouldBe('span.ownerDocument', 'document');
-
-template.content = df;
-shouldBe('df.ownerDocument', 'templateContentOwnerDocument');
-shouldBe('span.ownerDocument', 'templateContentOwnerDocument');
-
-shouldThrow('template.content = document.createElement("span");');
-shouldThrow('template.content = document.createTextNode("text");');
-if (window.WebKitShadowRoot) {
- var div = document.createElement('div');
- shouldThrow('template.content = new WebKitShadowRoot(div)');
-}
-
-var template3 = document.getElementById('template2');
+var template3 = document.getElementById('template3');
shouldBe('template3.ownerDocument', 'document');
shouldBe('template3.content.ownerDocument', 'templateContentOwnerDocument');
shouldBe('template3.content.firstChild.ownerDocument', 'templateContentOwnerDocument');
Modified: trunk/Source/WebCore/ChangeLog (136902 => 136903)
--- trunk/Source/WebCore/ChangeLog 2012-12-06 23:31:39 UTC (rev 136902)
+++ trunk/Source/WebCore/ChangeLog 2012-12-06 23:47:58 UTC (rev 136903)
@@ -1,3 +1,36 @@
+2012-12-06 Adam Klein <ad...@chromium.org>
+
+ [HTMLTemplateElement] make content readonly and cloneNode(deep) clone content
+ https://bugs.webkit.org/show_bug.cgi?id=104181
+
+ Reviewed by Adam Barth.
+
+ Note that this patch also adds IDL attributes/custom code to tie the lifetime
+ of the content DocumentFragment wrapper to the lifetime of the template element wrapper
+ via a hidden JS property.
+
+ Based on a patch by Rafael Weinstein.
+
+ Test: fast/dom/HTMLTemplateElement/contentWrappers.html
+
+ * DerivedSources.cpp:
+ * Target.pri:
+ * UseJSC.cmake:
+ * WebCore.gypi:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/JSBindingsAllInOne.cpp:
+ * bindings/js/JSHTMLTemplateElementCustom.cpp: Copied from Source/WebCore/html/HTMLTemplateElement.idl.
+ (WebCore):
+ (WebCore::JSHTMLTemplateElement::content):
+ * bindings/scripts/CodeGeneratorV8.pm: Add support for new V8CacheAttributeForGC attribute.
+ * dom/Element.h:
+ (Element): Annotate cloneNode() with OVERRIDE
+ * html/HTMLTemplateElement.cpp:
+ (WebCore::HTMLTemplateElement::cloneNode):
+ * html/HTMLTemplateElement.h:
+ (HTMLTemplateElement): override cloneNode
+ * html/HTMLTemplateElement.idl: Make content readonly and add custom attributes.
+
2012-12-06 Brent Fulgham <bfulg...@webkit.org>
[Windows, WinCairo] Unreviewed build correction.
Modified: trunk/Source/WebCore/DerivedSources.cpp (136902 => 136903)
--- trunk/Source/WebCore/DerivedSources.cpp 2012-12-06 23:31:39 UTC (rev 136902)
+++ trunk/Source/WebCore/DerivedSources.cpp 2012-12-06 23:47:58 UTC (rev 136903)
@@ -38,7 +38,7 @@
#include "JSCanvasPattern.cpp"
#include "JSCanvasRenderingContext.cpp"
#include "JSCanvasRenderingContext2D.cpp"
-#if ENABLE(WEBGL)
+#if ENABLE(WEBGL)
#include "JSWebGLRenderingContext.cpp"
#endif
#include "JSCDATASection.cpp"
@@ -211,6 +211,9 @@
#include "JSHTMLTableElement.cpp"
#include "JSHTMLTableRowElement.cpp"
#include "JSHTMLTableSectionElement.cpp"
+#if ENABLE(TEMPLATE_ELEMENT)
+#include "JSHTMLTemplateElement.cpp"
+#endif
#include "JSHTMLTextAreaElement.cpp"
#include "JSHTMLTitleElement.cpp"
#include "JSHTMLUnknownElement.cpp"
Modified: trunk/Source/WebCore/Target.pri (136902 => 136903)
--- trunk/Source/WebCore/Target.pri 2012-12-06 23:31:39 UTC (rev 136902)
+++ trunk/Source/WebCore/Target.pri 2012-12-06 23:47:58 UTC (rev 136903)
@@ -144,6 +144,7 @@
bindings/js/JSHTMLOutputElementCustom.cpp \
bindings/js/JSHTMLSelectElementCustom.cpp \
bindings/js/JSHTMLStyleElementCustom.cpp \
+ bindings/js/JSHTMLTemplateElementCustom.cpp \
bindings/js/JSHistoryCustom.cpp \
bindings/js/JSImageConstructor.cpp \
bindings/js/JSImageDataCustom.cpp \
Modified: trunk/Source/WebCore/UseJSC.cmake (136902 => 136903)
--- trunk/Source/WebCore/UseJSC.cmake 2012-12-06 23:31:39 UTC (rev 136902)
+++ trunk/Source/WebCore/UseJSC.cmake 2012-12-06 23:47:58 UTC (rev 136903)
@@ -96,6 +96,7 @@
bindings/js/JSHTMLOutputElementCustom.cpp
bindings/js/JSHTMLSelectElementCustom.cpp
bindings/js/JSHTMLStyleElementCustom.cpp
+ bindings/js/JSHTMLTemplateElementCustom.cpp
bindings/js/JSHistoryCustom.cpp
bindings/js/JSImageConstructor.cpp
bindings/js/JSImageDataCustom.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (136902 => 136903)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-12-06 23:31:39 UTC (rev 136902)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-12-06 23:47:58 UTC (rev 136903)
@@ -6020,10 +6020,15 @@
D630E2AC149BF344005B2F94 /* StatsCounter.h in Headers */ = {isa = PBXBuildFile; fileRef = D630E2AB149BF344005B2F94 /* StatsCounter.h */; };
D630E2AC149BF344005B2F95 /* MemoryUsageSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = D630E2AB149BF344005B2F95 /* MemoryUsageSupport.h */; };
D630E2AC149BF344005B2F96 /* EventTracer.h in Headers */ = {isa = PBXBuildFile; fileRef = D630E2AB149BF344005B2F96 /* EventTracer.h */; };
+ D6489D25166FFCF1007C031B /* JSHTMLTemplateElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D6489D23166FFCF1007C031B /* JSHTMLTemplateElement.cpp */; };
+ D6489D26166FFCF1007C031B /* JSHTMLTemplateElement.h in Headers */ = {isa = PBXBuildFile; fileRef = D6489D24166FFCF1007C031B /* JSHTMLTemplateElement.h */; };
+ D66817FA166FE6D700FA07B4 /* HTMLTemplateElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D6EFC0BB1666DF7A003D291E /* HTMLTemplateElement.cpp */; };
+ D66817FB166FE6D700FA07B4 /* HTMLTemplateElement.h in Headers */ = {isa = PBXBuildFile; fileRef = D6EFC0BC1666DF7A003D291E /* HTMLTemplateElement.h */; };
D6E276AF14637455001D280A /* MutationObserverRegistration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D6E276AD14637455001D280A /* MutationObserverRegistration.cpp */; };
D6E276B014637455001D280A /* MutationObserverRegistration.h in Headers */ = {isa = PBXBuildFile; fileRef = D6E276AE14637455001D280A /* MutationObserverRegistration.h */; };
D6E528A3149A926D00EFE1F3 /* MutationObserverInterestGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D6E528A1149A926D00EFE1F3 /* MutationObserverInterestGroup.cpp */; };
D6E528A4149A926D00EFE1F3 /* MutationObserverInterestGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = D6E528A2149A926D00EFE1F3 /* MutationObserverInterestGroup.h */; };
+ D6F7960D166FFECE0076DD18 /* JSHTMLTemplateElementCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D6F7960C166FFECE0076DD18 /* JSHTMLTemplateElementCustom.cpp */; };
D6FDAEF3149C06190037B1E1 /* HistogramSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D6FDAEF2149C06190037B1E1 /* HistogramSupport.cpp */; };
D6FDAEF3149C06190037B1E2 /* StatsCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D6FDAEF2149C06190037B1E2 /* StatsCounter.cpp */; };
D6FDAEF3149C06190037B1E3 /* MemoryUsageSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D6FDAEF2149C06190037B1E3 /* MemoryUsageSupport.cpp */; };
@@ -13466,6 +13471,8 @@
D630E2AB149BF344005B2F95 /* MemoryUsageSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryUsageSupport.h; sourceTree = "<group>"; };
D630E2AB149BF344005B2F96 /* EventTracer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventTracer.h; sourceTree = "<group>"; };
D630E2AB149BF344005B2F97 /* LayoutTestSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutTestSupport.h; sourceTree = "<group>"; };
+ D6489D23166FFCF1007C031B /* JSHTMLTemplateElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLTemplateElement.cpp; sourceTree = "<group>"; };
+ D6489D24166FFCF1007C031B /* JSHTMLTemplateElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLTemplateElement.h; sourceTree = "<group>"; };
D6E276AD14637455001D280A /* MutationObserverRegistration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MutationObserverRegistration.cpp; sourceTree = "<group>"; };
D6E276AE14637455001D280A /* MutationObserverRegistration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MutationObserverRegistration.h; sourceTree = "<group>"; };
D6E528A1149A926D00EFE1F3 /* MutationObserverInterestGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MutationObserverInterestGroup.cpp; sourceTree = "<group>"; };
@@ -13473,6 +13480,7 @@
D6EFC0BB1666DF7A003D291E /* HTMLTemplateElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLTemplateElement.cpp; sourceTree = "<group>"; };
D6EFC0BC1666DF7A003D291E /* HTMLTemplateElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLTemplateElement.h; sourceTree = "<group>"; };
D6EFC0BD1666DF7A003D291E /* HTMLTemplateElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLTemplateElement.idl; sourceTree = "<group>"; };
+ D6F7960C166FFECE0076DD18 /* JSHTMLTemplateElementCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLTemplateElementCustom.cpp; sourceTree = "<group>"; };
D6FDAEF2149C06190037B1E1 /* HistogramSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HistogramSupport.cpp; sourceTree = "<group>"; };
D6FDAEF2149C06190037B1E2 /* StatsCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatsCounter.cpp; sourceTree = "<group>"; };
D6FDAEF2149C06190037B1E3 /* MemoryUsageSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryUsageSupport.cpp; sourceTree = "<group>"; };
@@ -18649,6 +18657,8 @@
BC06ED9C0BFD660600856E9D /* JSHTMLTableRowElement.h */,
BC06ED040BFD5BAE00856E9D /* JSHTMLTableSectionElement.cpp */,
BC06ED050BFD5BAE00856E9D /* JSHTMLTableSectionElement.h */,
+ D6489D23166FFCF1007C031B /* JSHTMLTemplateElement.cpp */,
+ D6489D24166FFCF1007C031B /* JSHTMLTemplateElement.h */,
A80E7E940A1A83E3007FB8C5 /* JSHTMLTextAreaElement.cpp */,
A80E7E930A1A83E3007FB8C5 /* JSHTMLTextAreaElement.h */,
A80E7B090A19D606007FB8C5 /* JSHTMLTitleElement.cpp */,
@@ -20624,6 +20634,7 @@
BC17F9650B64EBB8004A65CB /* JSHTMLSelectElementCustom.cpp */,
AB4CB4EA0B8BDA3D009F40B0 /* JSHTMLSelectElementCustom.h */,
E1AD139D1295D96100ACA989 /* JSHTMLStyleElementCustom.cpp */,
+ D6F7960C166FFECE0076DD18 /* JSHTMLTemplateElementCustom.cpp */,
C585A65C11D4FAB2004C3E4B /* JSIDBAnyCustom.cpp */,
C585A65D11D4FAB2004C3E4B /* JSIDBKeyCustom.cpp */,
A7D0318D0E93540300E24ACD /* JSImageDataCustom.cpp */,
@@ -25876,6 +25887,8 @@
93F72AF31666EDFC002A02BD /* LayerPool.h in Headers */,
DEBCCDD216646E8200A452E1 /* RenderMediaControlElements.h in Headers */,
DEBCCDD416646EAF00A452E1 /* MediaControlElementTypes.h in Headers */,
+ D66817FB166FE6D700FA07B4 /* HTMLTemplateElement.h in Headers */,
+ D6489D26166FFCF1007C031B /* JSHTMLTemplateElement.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -28983,6 +28996,9 @@
86BA766E166427A8005BE5D1 /* FrameLoadRequest.cpp in Sources */,
93F72AF41666EDFC002A02BD /* LayerPool.mm in Sources */,
C375D7FD16639519006184AB /* TypeAhead.cpp in Sources */,
+ D66817FA166FE6D700FA07B4 /* HTMLTemplateElement.cpp in Sources */,
+ D6489D25166FFCF1007C031B /* JSHTMLTemplateElement.cpp in Sources */,
+ D6F7960D166FFECE0076DD18 /* JSHTMLTemplateElementCustom.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp (136902 => 136903)
--- trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp 2012-12-06 23:31:39 UTC (rev 136902)
+++ trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp 2012-12-06 23:47:58 UTC (rev 136903)
@@ -101,6 +101,7 @@
#include "JSHTMLOutputElementCustom.cpp"
#include "JSHTMLSelectElementCustom.cpp"
#include "JSHTMLStyleElementCustom.cpp"
+#include "JSHTMLTemplateElementCustom.cpp"
#include "JSHistoryCustom.cpp"
#include "JSImageConstructor.cpp"
#include "JSImageDataCustom.cpp"
Copied: trunk/Source/WebCore/bindings/js/JSHTMLTemplateElementCustom.cpp (from rev 136902, trunk/Source/WebCore/html/HTMLTemplateElement.idl) (0 => 136903)
--- trunk/Source/WebCore/bindings/js/JSHTMLTemplateElementCustom.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSHTMLTemplateElementCustom.cpp 2012-12-06 23:47:58 UTC (rev 136903)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(TEMPLATE_ELEMENT)
+
+#include "JSHTMLTemplateElement.h"
+
+#include "HTMLTemplateElement.h"
+#include "JSDocumentFragment.h"
+#include <runtime/JSObject.h>
+#include <runtime/PrivateName.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+JSValue JSHTMLTemplateElement::content(ExecState* exec) const
+{
+ JSLockHolder lock(exec);
+
+ HTMLTemplateElement* imp = static_cast<HTMLTemplateElement*>(impl());
+ DocumentFragment* content = imp->content();
+
+ JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), content);
+ if (wrapper)
+ return wrapper;
+
+ wrapper = CREATE_DOM_WRAPPER(exec, globalObject(), DocumentFragment, content);
+ PrivateName propertyName;
+ const_cast<JSHTMLTemplateElement*>(this)->putDirect(globalObject()->globalData(), propertyName, wrapper);
+ return wrapper;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(TEMPLATE_ELEMENT)
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (136902 => 136903)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-12-06 23:31:39 UTC (rev 136902)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-12-06 23:47:58 UTC (rev 136903)
@@ -1021,10 +1021,11 @@
# Special case for readonly or Replaceable attributes (with a few exceptions). This attempts to ensure that JS wrappers don't get
# garbage-collected prematurely when their lifetime is strongly tied to their owner. We accomplish this by inserting a reference to
# the newly created wrapper into an internal field of the holder object.
- if (!$codeGenerator->IsSubType($interface, "Node") && $attrName ne "self" && IsWrapperType($returnType) && (IsReadonly($attribute) || $attribute->signature->extendedAttributes->{"Replaceable"} || $attrName eq "location")
- && $returnType ne "EventTarget" && $returnType ne "SerializedScriptValue" && $returnType ne "DOMWindow"
- && $returnType ne "MessagePortArray"
- && $returnType !~ /SVG/ && $returnType !~ /HTML/ && !IsDOMNodeType($returnType)) {
+ if ((!$codeGenerator->IsSubType($interface, "Node") && $attrName ne "self" && IsWrapperType($returnType) && (IsReadonly($attribute) || $attribute->signature->extendedAttributes->{"Replaceable"} || $attrName eq "location")
+ && $returnType ne "EventTarget" && $returnType ne "SerializedScriptValue" && $returnType ne "DOMWindow"
+ && $returnType ne "MessagePortArray"
+ && $returnType !~ /SVG/ && $returnType !~ /HTML/ && !IsDOMNodeType($returnType))
+ || $attribute->signature->extendedAttributes->{"V8CacheAttributeForGC"}) {
my $arrayType = $codeGenerator->GetArrayType($returnType);
if ($arrayType) {
Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt (136902 => 136903)
--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt 2012-12-06 23:31:39 UTC (rev 136902)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt 2012-12-06 23:47:58 UTC (rev 136903)
@@ -108,6 +108,7 @@
TreatUndefinedAs=NullString
TypedArray=*
URL
+V8CacheAttributeForGC
V8Custom
V8CustomConstructor
V8CustomGetter
Modified: trunk/Source/WebCore/dom/Element.h (136902 => 136903)
--- trunk/Source/WebCore/dom/Element.h 2012-12-06 23:31:39 UTC (rev 136902)
+++ trunk/Source/WebCore/dom/Element.h 2012-12-06 23:47:58 UTC (rev 136903)
@@ -546,7 +546,7 @@
// cloneNode is private so that non-virtual cloneElementWithChildren and cloneElementWithoutChildren
// are used instead.
- virtual PassRefPtr<Node> cloneNode(bool deep);
+ virtual PassRefPtr<Node> cloneNode(bool deep) OVERRIDE;
virtual PassRefPtr<Element> cloneElementWithoutAttributesAndChildren();
QualifiedName m_tagName;
Modified: trunk/Source/WebCore/html/HTMLTemplateElement.cpp (136902 => 136903)
--- trunk/Source/WebCore/html/HTMLTemplateElement.cpp 2012-12-06 23:31:39 UTC (rev 136902)
+++ trunk/Source/WebCore/html/HTMLTemplateElement.cpp 2012-12-06 23:47:58 UTC (rev 136903)
@@ -57,6 +57,8 @@
return adoptRef(new HTMLTemplateElement(tagName, document));
}
+// FIXME: https://www.w3.org/Bugs/Public/show_bug.cgi?id=20127 (prevent DOM hierarchy cycles).
+// FIXME: https://www.w3.org/Bugs/Public/show_bug.cgi?id=20129 (extended adoptNode to consider template.content).
DocumentFragment* HTMLTemplateElement::content() const
{
if (!m_content)
@@ -65,24 +67,15 @@
return m_content.get();
}
-// FIXME: https://www.w3.org/Bugs/Public/show_bug.cgi?id=20127 (prevent DOM hierarchy cycles).
-// FIXME: https://www.w3.org/Bugs/Public/show_bug.cgi?id=20129 (extended adoptNode to consider template.content).
-void HTMLTemplateElement::setContent(PassRefPtr<DocumentFragment> prpContent, ExceptionCode& ec)
+PassRefPtr<Node> HTMLTemplateElement::cloneNode(bool deep)
{
- RefPtr<DocumentFragment> content = prpContent;
+ if (!deep)
+ return cloneElementWithoutChildren();
- if (!content || content->isShadowRoot()) {
- ec = TYPE_MISMATCH_ERR;
- return;
- }
-
- if (m_content.get() == content.get())
- return;
-
- if (content->ownerDocument() != ownerDocument()->templateContentsOwnerDocument())
- ownerDocument()->templateContentsOwnerDocument()->adoptNode(content, ASSERT_NO_EXCEPTION);
-
- m_content = content;
+ RefPtr<Node> clone = cloneElementWithChildren();
+ if (m_content)
+ content()->cloneChildNodes(toHTMLTemplateElement(clone.get())->content());
+ return clone.release();
}
#ifndef NDEBUG
Modified: trunk/Source/WebCore/html/HTMLTemplateElement.h (136902 => 136903)
--- trunk/Source/WebCore/html/HTMLTemplateElement.h 2012-12-06 23:31:39 UTC (rev 136902)
+++ trunk/Source/WebCore/html/HTMLTemplateElement.h 2012-12-06 23:47:58 UTC (rev 136903)
@@ -45,9 +45,9 @@
DocumentFragment* content() const;
- void setContent(PassRefPtr<DocumentFragment>, ExceptionCode&);
+private:
+ virtual PassRefPtr<Node> cloneNode(bool deep) OVERRIDE;
-private:
HTMLTemplateElement(const QualifiedName&, Document*);
mutable RefPtr<DocumentFragment> m_content;
Modified: trunk/Source/WebCore/html/HTMLTemplateElement.idl (136902 => 136903)
--- trunk/Source/WebCore/html/HTMLTemplateElement.idl 2012-12-06 23:31:39 UTC (rev 136902)
+++ trunk/Source/WebCore/html/HTMLTemplateElement.idl 2012-12-06 23:47:58 UTC (rev 136903)
@@ -31,6 +31,6 @@
[
Conditional=TEMPLATE_ELEMENT
] interface HTMLTemplateElement : HTMLElement {
- attribute DocumentFragment content setter raises (DOMException);
+ [JSCustom, V8CacheAttributeForGC] readonly attribute DocumentFragment content;
};