Title: [109721] trunk
Revision
109721
Author
[email protected]
Date
2012-03-05 00:37:51 -0800 (Mon, 05 Mar 2012)

Log Message

Internally used HTMLContentElement subclasses should have correct wrapper.
https://bugs.webkit.org/show_bug.cgi?id=80237

Reviewed by Kent Tamura.

Source/WebCore:

DetailsContentElement and DetailsSummaryElement used to use
<div> as their tag name. But this means they are wrapped by
wrapper objects for HTMLDivElement, which is wrong. This happened
to work though because HTMLDivElement has no extra state or API.

This change introduces "noConstructor" keyword for make_name.pl
sources.  This keyword allows a tag name to specify its own
wrapper without making the tag name visible from the parser, or
HTMLElementFactory in precise.

Following this addition, this change also adds a new tag name
"webkitShadowContent" for DetailsContentElement and DetailsSummaryElement,
which has no constructor, and whose wrapper type is HTMLElement.

This change isn't visible from the page author and only matters for testing.

Test: fast/dom/shadow/content-element-user-agent-shadow.html

* dom/make_names.pl:
(defaultTagPropertyHash):
(buildConstructorMap):
(printConstructors):
(printFunctionInits):
* html/HTMLDetailsElement.cpp:
(WebCore::DetailsContentElement::DetailsContentElement):
(WebCore::DetailsSummaryElement::DetailsSummaryElement):
* html/HTMLTagNames.in:
* html/shadow/HTMLContentElement.cpp:
(WebCore::contentTagName):

LayoutTests:

* fast/dom/shadow/content-element-user-agent-shadow-expected.txt: Added.
* fast/dom/shadow/content-element-user-agent-shadow.html: Added.
* platform/chromium-win/fast/html/details-remove-summary-1-and-click-expected.txt:
* platform/chromium-win/fast/html/details-remove-summary-4-and-click-expected.txt:
* platform/gtk/fast/html/details-remove-summary-1-and-click-expected.txt:
* platform/gtk/fast/html/details-remove-summary-4-and-click-expected.txt:
* platform/mac/fast/html/details-remove-summary-1-and-click-expected.txt:
* platform/mac/fast/html/details-remove-summary-4-and-click-expected.txt:
* platform/qt/fast/html/details-remove-summary-1-and-click-expected.txt:
* platform/qt/fast/html/details-remove-summary-4-and-click-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (109720 => 109721)


--- trunk/LayoutTests/ChangeLog	2012-03-05 08:35:15 UTC (rev 109720)
+++ trunk/LayoutTests/ChangeLog	2012-03-05 08:37:51 UTC (rev 109721)
@@ -1,3 +1,21 @@
+2012-03-04  MORITA Hajime  <[email protected]>
+
+        Internally used HTMLContentElement subclasses should have correct wrapper.
+        https://bugs.webkit.org/show_bug.cgi?id=80237
+
+        Reviewed by Kent Tamura.
+
+        * fast/dom/shadow/content-element-user-agent-shadow-expected.txt: Added.
+        * fast/dom/shadow/content-element-user-agent-shadow.html: Added.
+        * platform/chromium-win/fast/html/details-remove-summary-1-and-click-expected.txt:
+        * platform/chromium-win/fast/html/details-remove-summary-4-and-click-expected.txt:
+        * platform/gtk/fast/html/details-remove-summary-1-and-click-expected.txt:
+        * platform/gtk/fast/html/details-remove-summary-4-and-click-expected.txt:
+        * platform/mac/fast/html/details-remove-summary-1-and-click-expected.txt:
+        * platform/mac/fast/html/details-remove-summary-4-and-click-expected.txt:
+        * platform/qt/fast/html/details-remove-summary-1-and-click-expected.txt:
+        * platform/qt/fast/html/details-remove-summary-4-and-click-expected.txt:
+
 2012-03-04  Martin Robinson  <[email protected]>
 
         [GTK] REGRESSION: r108278 broke some tests that expect focus

Added: trunk/LayoutTests/fast/dom/shadow/content-element-user-agent-shadow-expected.txt (0 => 109721)


--- trunk/LayoutTests/fast/dom/shadow/content-element-user-agent-shadow-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/content-element-user-agent-shadow-expected.txt	2012-03-05 08:37:51 UTC (rev 109721)
@@ -0,0 +1,8 @@
+PASS parsedElementShouldBeUnknown.tagName is 'WEBKITSHADOWCONTENT'
+PASS 0 < parsedElementShouldBeUnknown.constructor.toString().indexOf('HTMLUnknownElement') is true
+PASS contentInuserAgentShadow.tagName is 'WEBKITSHADOWCONTENT'
+PASS 0 < contentInuserAgentShadow.constructor.toString().indexOf('HTMLElement') is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/fast/dom/shadow/content-element-user-agent-shadow-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/dom/shadow/content-element-user-agent-shadow.html (0 => 109721)


--- trunk/LayoutTests/fast/dom/shadow/content-element-user-agent-shadow.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/content-element-user-agent-shadow.html	2012-03-05 08:37:51 UTC (rev 109721)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="container"></div>
+<script src=""
+<script><!--
+(function()
+{
+    if (!window.internals)
+        return;
+
+    // Parser should build HTMLUnknownElement for <webkitShadowContent>.
+    container = document.getElementById("container");
+    container.innerHTML = "<div><webkitShadowContent id='shouldBeUnknown'></webkitShadowContent></div>";
+    parsedElementShouldBeUnknown = document.getElementById("shouldBeUnknown");
+    shouldBe("parsedElementShouldBeUnknown.tagName", "'WEBKITSHADOWCONTENT'");
+    shouldBeTrue("0 < parsedElementShouldBeUnknown.constructor.toString().indexOf('HTMLUnknownElement')");
+
+    container.innerHTML = "<details id='details'><summary></summary></details>";
+    details = document.getElementById("details");
+
+    // The user agent shadow for <details> has HTMLContentElement with tagName "webkitShadowContent".
+    // This element should be wrapped as an HTMLElement because it isn't HTMLUnknownElement and
+    // HTMLContentElement wrapper is unavailable unless SHADOW_DOM is enabled.
+    shadow = internals.shadowRoot(details);
+    contentInuserAgentShadow = shadow.firstChild;
+    shouldBe("contentInuserAgentShadow.tagName", "'WEBKITSHADOWCONTENT'");
+    shouldBeTrue("0 < contentInuserAgentShadow.constructor.toString().indexOf('HTMLElement')");
+})();
+--></script>
+<script src=""
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/dom/shadow/content-element-user-agent-shadow.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/LayoutTests/platform/chromium-win/fast/html/details-remove-summary-1-and-click-expected.txt (109720 => 109721)


--- trunk/LayoutTests/platform/chromium-win/fast/html/details-remove-summary-1-and-click-expected.txt	2012-03-05 08:35:15 UTC (rev 109720)
+++ trunk/LayoutTests/platform/chromium-win/fast/html/details-remove-summary-1-and-click-expected.txt	2012-03-05 08:37:51 UTC (rev 109721)
@@ -8,4 +8,4 @@
           RenderDetailsMarker {DIV} at (0,5) size 10x10: down
           RenderText {#text} at (16,0) size 41x19
             text run at (16,0) width 41: "Details"
-caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {DIV} of {#shadow-root} of child 1 {DETAILS} of body
+caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {WEBKITSHADOWCONTENT} of {#shadow-root} of child 1 {DETAILS} of body

Modified: trunk/LayoutTests/platform/chromium-win/fast/html/details-remove-summary-4-and-click-expected.txt (109720 => 109721)


--- trunk/LayoutTests/platform/chromium-win/fast/html/details-remove-summary-4-and-click-expected.txt	2012-03-05 08:35:15 UTC (rev 109720)
+++ trunk/LayoutTests/platform/chromium-win/fast/html/details-remove-summary-4-and-click-expected.txt	2012-03-05 08:37:51 UTC (rev 109721)
@@ -8,4 +8,4 @@
           RenderDetailsMarker {DIV} at (0,5) size 10x10: right
           RenderText {#text} at (16,0) size 41x19
             text run at (16,0) width 41: "Details"
-caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {DIV} of {#shadow-root} of child 1 {DETAILS} of body
+caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {WEBKITSHADOWCONTENT} of {#shadow-root} of child 1 {DETAILS} of body

Modified: trunk/LayoutTests/platform/gtk/fast/html/details-remove-summary-1-and-click-expected.txt (109720 => 109721)


--- trunk/LayoutTests/platform/gtk/fast/html/details-remove-summary-1-and-click-expected.txt	2012-03-05 08:35:15 UTC (rev 109720)
+++ trunk/LayoutTests/platform/gtk/fast/html/details-remove-summary-1-and-click-expected.txt	2012-03-05 08:37:51 UTC (rev 109721)
@@ -8,4 +8,4 @@
           RenderDetailsMarker {DIV} at (0,4) size 10x10: down
           RenderText {#text} at (16,0) size 46x17
             text run at (16,0) width 46: "Details"
-caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {DIV} of {#shadow-root} of child 1 {DETAILS} of body
+caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {WEBKITSHADOWCONTENT} of {#shadow-root} of child 1 {DETAILS} of body

Modified: trunk/LayoutTests/platform/gtk/fast/html/details-remove-summary-4-and-click-expected.txt (109720 => 109721)


--- trunk/LayoutTests/platform/gtk/fast/html/details-remove-summary-4-and-click-expected.txt	2012-03-05 08:35:15 UTC (rev 109720)
+++ trunk/LayoutTests/platform/gtk/fast/html/details-remove-summary-4-and-click-expected.txt	2012-03-05 08:37:51 UTC (rev 109721)
@@ -8,4 +8,4 @@
           RenderDetailsMarker {DIV} at (0,4) size 10x10: right
           RenderText {#text} at (16,0) size 46x17
             text run at (16,0) width 46: "Details"
-caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {DIV} of {#shadow-root} of child 1 {DETAILS} of body
+caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {WEBKITSHADOWCONTENT} of {#shadow-root} of child 1 {DETAILS} of body

Modified: trunk/LayoutTests/platform/mac/fast/html/details-remove-summary-1-and-click-expected.txt (109720 => 109721)


--- trunk/LayoutTests/platform/mac/fast/html/details-remove-summary-1-and-click-expected.txt	2012-03-05 08:35:15 UTC (rev 109720)
+++ trunk/LayoutTests/platform/mac/fast/html/details-remove-summary-1-and-click-expected.txt	2012-03-05 08:37:51 UTC (rev 109721)
@@ -8,4 +8,4 @@
           RenderDetailsMarker {DIV} at (0,4) size 10x10: down
           RenderText {#text} at (16,0) size 44x18
             text run at (16,0) width 44: "Details"
-caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {DIV} of {#shadow-root} of child 1 {DETAILS} of body
+caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {WEBKITSHADOWCONTENT} of {#shadow-root} of child 1 {DETAILS} of body

Modified: trunk/LayoutTests/platform/mac/fast/html/details-remove-summary-4-and-click-expected.txt (109720 => 109721)


--- trunk/LayoutTests/platform/mac/fast/html/details-remove-summary-4-and-click-expected.txt	2012-03-05 08:35:15 UTC (rev 109720)
+++ trunk/LayoutTests/platform/mac/fast/html/details-remove-summary-4-and-click-expected.txt	2012-03-05 08:37:51 UTC (rev 109721)
@@ -8,4 +8,4 @@
           RenderDetailsMarker {DIV} at (0,4) size 10x10: right
           RenderText {#text} at (16,0) size 44x18
             text run at (16,0) width 44: "Details"
-caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {DIV} of {#shadow-root} of child 1 {DETAILS} of body
+caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {WEBKITSHADOWCONTENT} of {#shadow-root} of child 1 {DETAILS} of body

Modified: trunk/LayoutTests/platform/qt/fast/html/details-remove-summary-1-and-click-expected.txt (109720 => 109721)


--- trunk/LayoutTests/platform/qt/fast/html/details-remove-summary-1-and-click-expected.txt	2012-03-05 08:35:15 UTC (rev 109720)
+++ trunk/LayoutTests/platform/qt/fast/html/details-remove-summary-1-and-click-expected.txt	2012-03-05 08:37:51 UTC (rev 109721)
@@ -8,4 +8,4 @@
           RenderDetailsMarker {DIV} at (0,6) size 10x10: down
           RenderText {#text} at (16,0) size 50x21
             text run at (16,0) width 50: "Details"
-caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {DIV} of {#shadow-root} of child 1 {DETAILS} of body
+caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {WEBKITSHADOWCONTENT} of {#shadow-root} of child 1 {DETAILS} of body

Modified: trunk/LayoutTests/platform/qt/fast/html/details-remove-summary-4-and-click-expected.txt (109720 => 109721)


--- trunk/LayoutTests/platform/qt/fast/html/details-remove-summary-4-and-click-expected.txt	2012-03-05 08:35:15 UTC (rev 109720)
+++ trunk/LayoutTests/platform/qt/fast/html/details-remove-summary-4-and-click-expected.txt	2012-03-05 08:37:51 UTC (rev 109721)
@@ -8,4 +8,4 @@
           RenderDetailsMarker {DIV} at (0,6) size 10x10: right
           RenderText {#text} at (16,0) size 50x21
             text run at (16,0) width 50: "Details"
-caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {DIV} of {#shadow-root} of child 1 {DETAILS} of body
+caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {WEBKITSHADOWCONTENT} of {#shadow-root} of child 1 {DETAILS} of body

Modified: trunk/Source/WebCore/ChangeLog (109720 => 109721)


--- trunk/Source/WebCore/ChangeLog	2012-03-05 08:35:15 UTC (rev 109720)
+++ trunk/Source/WebCore/ChangeLog	2012-03-05 08:37:51 UTC (rev 109721)
@@ -1,3 +1,40 @@
+2012-03-04  MORITA Hajime  <[email protected]>
+
+        Internally used HTMLContentElement subclasses should have correct wrapper.
+        https://bugs.webkit.org/show_bug.cgi?id=80237
+
+        Reviewed by Kent Tamura.
+
+        DetailsContentElement and DetailsSummaryElement used to use
+        <div> as their tag name. But this means they are wrapped by
+        wrapper objects for HTMLDivElement, which is wrong. This happened
+        to work though because HTMLDivElement has no extra state or API.
+
+        This change introduces "noConstructor" keyword for make_name.pl
+        sources.  This keyword allows a tag name to specify its own
+        wrapper without making the tag name visible from the parser, or
+        HTMLElementFactory in precise.
+
+        Following this addition, this change also adds a new tag name
+        "webkitShadowContent" for DetailsContentElement and DetailsSummaryElement,
+        which has no constructor, and whose wrapper type is HTMLElement.
+
+        This change isn't visible from the page author and only matters for testing.
+
+        Test: fast/dom/shadow/content-element-user-agent-shadow.html
+
+        * dom/make_names.pl:
+        (defaultTagPropertyHash):
+        (buildConstructorMap):
+        (printConstructors):
+        (printFunctionInits):
+        * html/HTMLDetailsElement.cpp:
+        (WebCore::DetailsContentElement::DetailsContentElement):
+        (WebCore::DetailsSummaryElement::DetailsSummaryElement):
+        * html/HTMLTagNames.in:
+        * html/shadow/HTMLContentElement.cpp:
+        (WebCore::contentTagName):
+
 2012-03-05  Shinya Kawanaka  <[email protected]>
 
         Refactoring: Move HTMLContentElement::attach to InsertionPoint::attach.

Modified: trunk/Source/WebCore/dom/make_names.pl (109720 => 109721)


--- trunk/Source/WebCore/dom/make_names.pl	2012-03-05 08:35:15 UTC (rev 109720)
+++ trunk/Source/WebCore/dom/make_names.pl	2012-03-05 08:37:51 UTC (rev 109721)
@@ -179,6 +179,7 @@
     return (
         'constructorNeedsCreatedByParser' => 0,
         'constructorNeedsFormElement' => 0,
+        'noConstructor' => 0,
         'interfaceName' => defaultInterfaceName($_[0]),
         # By default, the JSInterfaceName is the same as the interfaceName.
         'JSInterfaceName' => defaultInterfaceName($_[0]),
@@ -393,6 +394,10 @@
         # Ignore the mapped tag
         # FIXME: It could be moved inside this loop but was split for readibility.
         next if (defined($uniqueTags{$interfaceName}) || $enabledTags{$tagName}{mapToTagName});
+        # Tags can have wrappers without constructors.
+        # This is useful to make user-agent shadow elements internally testable
+        # while keeping them from being avaialble in the HTML markup.
+        next if $enabledTags{$tagName}{noConstructor};
 
         $uniqueTags{$interfaceName} = '1';
 
@@ -426,6 +431,7 @@
     my %tagConstructorMap = %$tagConstructorMap;
 
     for my $tagName (sort keys %tagConstructorMap) {
+        next if $enabledTags{$tagName}{noConstructor};
 
         my $conditional = $enabledTags{$tagName}{conditional};
         if ($conditional) {

Modified: trunk/Source/WebCore/html/HTMLDetailsElement.cpp (109720 => 109721)


--- trunk/Source/WebCore/html/HTMLDetailsElement.cpp	2012-03-05 08:35:15 UTC (rev 109720)
+++ trunk/Source/WebCore/html/HTMLDetailsElement.cpp	2012-03-05 08:37:51 UTC (rev 109721)
@@ -50,7 +50,7 @@
 
 private:
     DetailsContentElement(Document* document)
-        : HTMLContentElement(HTMLNames::divTag, document)
+        : HTMLContentElement(HTMLNames::webkitShadowContentTag, document)
     {
     }
 };
@@ -72,7 +72,7 @@
 
 private:
     DetailsSummaryElement(Document* document)
-        : HTMLContentElement(HTMLNames::divTag, document)
+        : HTMLContentElement(HTMLNames::webkitShadowContentTag, document)
     {
         setSelect(summaryQuerySelector());
     }

Modified: trunk/Source/WebCore/html/HTMLTagNames.in (109720 => 109721)


--- trunk/Source/WebCore/html/HTMLTagNames.in	2012-03-05 08:35:15 UTC (rev 109720)
+++ trunk/Source/WebCore/html/HTMLTagNames.in	2012-03-05 08:37:51 UTC (rev 109721)
@@ -32,6 +32,7 @@
 colgroup interfaceName=HTMLTableColElement
 command interfaceName=HTMLElement
 content interfaceName=HTMLContentElement, conditional=SHADOW_DOM
+webkitShadowContent interfaceName=HTMLElement, noConstructor
 datalist interfaceName=HTMLDataListElement, conditional=DATALIST
 dd interfaceName=HTMLElement
 del interfaceName=HTMLModElement

Modified: trunk/Source/WebCore/html/shadow/HTMLContentElement.cpp (109720 => 109721)


--- trunk/Source/WebCore/html/shadow/HTMLContentElement.cpp	2012-03-05 08:35:15 UTC (rev 109720)
+++ trunk/Source/WebCore/html/shadow/HTMLContentElement.cpp	2012-03-05 08:37:51 UTC (rev 109721)
@@ -44,8 +44,7 @@
 #if ENABLE(SHADOW_DOM)
     return HTMLNames::contentTag;
 #else
-    DEFINE_STATIC_LOCAL(QualifiedName, tagName, (nullAtom, "webkitShadowContent", HTMLNames::divTag.namespaceURI()));
-    return tagName;
+    return HTMLNames::webkitShadowContentTag
 #endif
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to