A shadow element in ShadowDOM of a button element does not work.
authorshinyak@chromium.org <shinyak@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Aug 2012 01:47:20 +0000 (01:47 +0000)
committershinyak@chromium.org <shinyak@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Aug 2012 01:47:20 +0000 (01:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=91486

Reviewed by Dimitri Glazkov.

Source/WebCore:

Since a button element is extended from an HTMLFormControlElement, it creates a UserAgentShadowDOM
just before adding an AuthorShadowDOM. However, actually a button element does not need any UserAgentShadowDOM.
So we have to prevent it from creating UserAgentShadowDOM.

Test: fast/dom/shadow/shadowdom-for-button.html

* html/HTMLButtonElement.cpp:
(WebCore::HTMLButtonElement::willAddAuthorShadowRoot):
(WebCore):
* html/HTMLButtonElement.h:

LayoutTests:

* fast/dom/shadow/shadowdom-for-button-expected.html: Added.
* fast/dom/shadow/shadowdom-for-button.html: Added.
* fast/dom/shadow/shadowdom-for-form-associated-element-useragent-expected.txt:
* fast/dom/shadow/shadowdom-for-form-associated-element-useragent.html: a button element
does not have user agent shadow dom anymore.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@126248 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/dom/shadow/shadowdom-for-button-expected.html [new file with mode: 0644]
LayoutTests/fast/dom/shadow/shadowdom-for-button.html [new file with mode: 0644]
LayoutTests/fast/dom/shadow/shadowdom-for-form-associated-element-useragent-expected.txt
LayoutTests/fast/dom/shadow/shadowdom-for-form-associated-element-useragent.html
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLButtonElement.cpp
Source/WebCore/html/HTMLButtonElement.h

index 43a56f9..417309f 100644 (file)
@@ -1,3 +1,16 @@
+2012-08-21  Shinya Kawanaka  <shinyak@chromium.org>
+
+        A shadow element in ShadowDOM of a button element does not work.
+        https://bugs.webkit.org/show_bug.cgi?id=91486
+
+        Reviewed by Dimitri Glazkov.
+
+        * fast/dom/shadow/shadowdom-for-button-expected.html: Added.
+        * fast/dom/shadow/shadowdom-for-button.html: Added.
+        * fast/dom/shadow/shadowdom-for-form-associated-element-useragent-expected.txt:
+        * fast/dom/shadow/shadowdom-for-form-associated-element-useragent.html: a button element
+        does not have user agent shadow dom anymore.
+
 2012-08-21  Kenneth Russell  <kbr@google.com>
 
         Unreviewed Chromium gardening. Suppress crashes of new test.
diff --git a/LayoutTests/fast/dom/shadow/shadowdom-for-button-expected.html b/LayoutTests/fast/dom/shadow/shadowdom-for-button-expected.html
new file mode 100644 (file)
index 0000000..b8e57e2
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+
+<html>
+<body>
+<script src="resources/polyfill.js"></script>
+
+<p>When a button element has a shadow dom having a shadow element, it should get the children of the button element.</p>
+
+<button>Kotori Otonashi</button>
+<button>FOO foo Kotori bar BAR</button>
+
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/shadow/shadowdom-for-button.html b/LayoutTests/fast/dom/shadow/shadowdom-for-button.html
new file mode 100644 (file)
index 0000000..504603c
--- /dev/null
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+
+<html>
+<body>
+<script src="resources/polyfill.js"></script>
+
+<p>When a button element has a shadow dom having a shadow element, it should get the children of the button element.</p>
+
+<button id="host1">Kotori</button>
+<button id="host2">Kotori</button>
+
+<script>
+var shadowRoot1 = new WebKitShadowRoot(host1);
+shadowRoot1.innerHTML = "<shadow></shadow> Otonashi";
+
+var shadowRoot2 = new WebKitShadowRoot(host2);
+shadowRoot2.innerHTML = "foo <shadow></shadow> bar";
+var shadowRoot3 = new WebKitShadowRoot(host2);
+shadowRoot3.innerHTML = "FOO <shadow></shadow> BAR";
+</script>
+
+</body>
+</html>
index 03b6199..ed54363 100644 (file)
@@ -6,8 +6,6 @@ PASS oldestShadowRoot is not shadowRoot
 PASS youngerShadowRoot is shadowRoot
 PASS oldestShadowRoot is not shadowRoot
 PASS youngerShadowRoot is shadowRoot
-PASS oldestShadowRoot is not shadowRoot
-PASS youngerShadowRoot is shadowRoot
 PASS successfullyParsed is true
 
 TEST COMPLETE
index f7ae799..c486e08 100644 (file)
@@ -7,7 +7,6 @@
 <p>When a AuthorShadowRoot is added, UserAgentShadowRoot should exists as the oldest Shadow Root.</p>
 <div id='container'>
     <form>
-        <button id='button'>72</button>
         <select id='select'><option>hoge</option></select>
         <output id='output'></output>
         <keygen id='keygen'></keygen>
@@ -21,7 +20,7 @@
 
 <script>
 var elems = [
-    "button", "select", "keygen", "fieldset"
+    "select", "keygen", "fieldset"
 ];
 
 var shadowRoot;
index 7f70868..4c06cf5 100644 (file)
@@ -1,3 +1,21 @@
+2012-08-21  Shinya Kawanaka  <shinyak@chromium.org>
+
+        A shadow element in ShadowDOM of a button element does not work.
+        https://bugs.webkit.org/show_bug.cgi?id=91486
+
+        Reviewed by Dimitri Glazkov.
+
+        Since a button element is extended from an HTMLFormControlElement, it creates a UserAgentShadowDOM
+        just before adding an AuthorShadowDOM. However, actually a button element does not need any UserAgentShadowDOM.
+        So we have to prevent it from creating UserAgentShadowDOM.
+
+        Test: fast/dom/shadow/shadowdom-for-button.html
+
+        * html/HTMLButtonElement.cpp:
+        (WebCore::HTMLButtonElement::willAddAuthorShadowRoot):
+        (WebCore):
+        * html/HTMLButtonElement.h:
+
 2012-08-21  Sukolsak Sakshuwong  <sukolsak@google.com>
 
         Remove UndoManager's undoscope content attribute
index ecb4a21..cbd1f29 100644 (file)
@@ -63,6 +63,10 @@ RenderObject* HTMLButtonElement::createRenderer(RenderArena* arena, RenderStyle*
     return new (arena) RenderButton(this);
 }
 
+void HTMLButtonElement::willAddAuthorShadowRoot()
+{
+}
+
 const AtomicString& HTMLButtonElement::formControlType() const
 {
     switch (m_type) {
index 92ca0a3..74a5735 100644 (file)
@@ -47,6 +47,8 @@ private:
         
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
 
+    virtual void willAddAuthorShadowRoot() OVERRIDE;
+
     virtual void parseAttribute(const Attribute&) OVERRIDE;
     virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
     virtual void defaultEventHandler(Event*);