Title: [107178] trunk/Source/WebCore
Revision
107178
Author
[email protected]
Date
2012-02-08 21:46:57 -0800 (Wed, 08 Feb 2012)

Log Message

Stop calling Element::ensureShadowRoot() if it is used in construction phase.
https://bugs.webkit.org/show_bug.cgi?id=77929

Patch by Shinya Kawanaka <[email protected]> on 2012-02-08
Reviewed by Hajime Morita.

ShadowRoot's life cycle can be consufing If Element::ensureShadowRoot() is used.
So we want to remove Element::ensureShadowRoot().
This patch replaces Element::ensureShadowRoot() if it is used in object construction phase.

No new tests, no change in behavior.

* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::create):
  Initialize exception code before calling appendChild.
* html/HTMLDetailsElement.cpp:
(WebCore::HTMLDetailsElement::createShadowSubtree):
* html/HTMLKeygenElement.cpp:
(WebCore::HTMLKeygenElement::HTMLKeygenElement):
* html/HTMLMeterElement.cpp:
(WebCore::HTMLMeterElement::createShadowSubtree):
* html/HTMLProgressElement.cpp:
(WebCore::HTMLProgressElement::createShadowSubtree):
* html/HTMLSummaryElement.cpp:
(WebCore::HTMLSummaryElement::createShadowSubtree):
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::createShadowSubtree):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (107177 => 107178)


--- trunk/Source/WebCore/ChangeLog	2012-02-09 05:26:00 UTC (rev 107177)
+++ trunk/Source/WebCore/ChangeLog	2012-02-09 05:46:57 UTC (rev 107178)
@@ -1,3 +1,32 @@
+2012-02-08  Shinya Kawanaka  <[email protected]>
+
+        Stop calling Element::ensureShadowRoot() if it is used in construction phase.
+        https://bugs.webkit.org/show_bug.cgi?id=77929
+
+        Reviewed by Hajime Morita.
+
+        ShadowRoot's life cycle can be consufing If Element::ensureShadowRoot() is used.
+        So we want to remove Element::ensureShadowRoot().
+        This patch replaces Element::ensureShadowRoot() if it is used in object construction phase.
+
+        No new tests, no change in behavior.
+
+        * dom/ShadowRoot.cpp:
+        (WebCore::ShadowRoot::create):
+          Initialize exception code before calling appendChild.
+        * html/HTMLDetailsElement.cpp:
+        (WebCore::HTMLDetailsElement::createShadowSubtree):
+        * html/HTMLKeygenElement.cpp:
+        (WebCore::HTMLKeygenElement::HTMLKeygenElement):
+        * html/HTMLMeterElement.cpp:
+        (WebCore::HTMLMeterElement::createShadowSubtree):
+        * html/HTMLProgressElement.cpp:
+        (WebCore::HTMLProgressElement::createShadowSubtree):
+        * html/HTMLSummaryElement.cpp:
+        (WebCore::HTMLSummaryElement::createShadowSubtree):
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::createShadowSubtree):
+
 2012-02-08  David Reveman  <[email protected]>
 
         [Chromium] Avoid unnecessary full tile updates without breaking atomicity of commits.

Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (107177 => 107178)


--- trunk/Source/WebCore/dom/ShadowRoot.cpp	2012-02-09 05:26:00 UTC (rev 107177)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp	2012-02-09 05:46:57 UTC (rev 107178)
@@ -66,9 +66,12 @@
         return 0;
     }
     RefPtr<ShadowRoot> shadowRoot = create(element->document());
+
+    ec = 0;
     element->setShadowRoot(shadowRoot, ec);
     if (ec)
         return 0;
+
     return shadowRoot.release();
 }
 

Modified: trunk/Source/WebCore/html/HTMLDetailsElement.cpp (107177 => 107178)


--- trunk/Source/WebCore/html/HTMLDetailsElement.cpp	2012-02-09 05:26:00 UTC (rev 107177)
+++ trunk/Source/WebCore/html/HTMLDetailsElement.cpp	2012-02-09 05:46:57 UTC (rev 107178)
@@ -109,8 +109,10 @@
 void HTMLDetailsElement::createShadowSubtree()
 {
     ASSERT(!shadowRoot());
-    ensureShadowRoot()->appendChild(DetailsSummaryElement::create(document()), ASSERT_NO_EXCEPTION, true);
-    ensureShadowRoot()->appendChild(DetailsContentElement::create(document()), ASSERT_NO_EXCEPTION, true);
+
+    RefPtr<ShadowRoot> root = ShadowRoot::create(this, ASSERT_NO_EXCEPTION);
+    root->appendChild(DetailsSummaryElement::create(document()), ASSERT_NO_EXCEPTION, true);
+    root->appendChild(DetailsContentElement::create(document()), ASSERT_NO_EXCEPTION, true);
 }
 
 Element* HTMLDetailsElement::findMainSummary() const

Modified: trunk/Source/WebCore/html/HTMLKeygenElement.cpp (107177 => 107178)


--- trunk/Source/WebCore/html/HTMLKeygenElement.cpp	2012-02-09 05:26:00 UTC (rev 107177)
+++ trunk/Source/WebCore/html/HTMLKeygenElement.cpp	2012-02-09 05:46:57 UTC (rev 107178)
@@ -85,7 +85,9 @@
         option->appendChild(Text::create(document, keys[i]), ec);
     }
 
-    ensureShadowRoot()->appendChild(select, ec);
+    ASSERT(!shadowRoot());
+    RefPtr<ShadowRoot> root = ShadowRoot::create(this, ASSERT_NO_EXCEPTION);
+    root->appendChild(select, ec);
 }
 
 PassRefPtr<HTMLKeygenElement> HTMLKeygenElement::create(const QualifiedName& tagName, Document* document, HTMLFormElement* form)

Modified: trunk/Source/WebCore/html/HTMLMeterElement.cpp (107177 => 107178)


--- trunk/Source/WebCore/html/HTMLMeterElement.cpp	2012-02-09 05:26:00 UTC (rev 107177)
+++ trunk/Source/WebCore/html/HTMLMeterElement.cpp	2012-02-09 05:46:57 UTC (rev 107178)
@@ -234,11 +234,15 @@
 
 void HTMLMeterElement::createShadowSubtree()
 {
+    ASSERT(!shadowRoot());
+
     RefPtr<MeterBarElement> bar = MeterBarElement::create(document());
     m_value = MeterValueElement::create(document());
     ExceptionCode ec = 0;
     bar->appendChild(m_value, ec);
-    ensureShadowRoot()->appendChild(bar, ec);
+
+    RefPtr<ShadowRoot> root = ShadowRoot::create(this, ASSERT_NO_EXCEPTION);
+    root->appendChild(bar, ec);
 }
 
 } // namespace

Modified: trunk/Source/WebCore/html/HTMLProgressElement.cpp (107177 => 107178)


--- trunk/Source/WebCore/html/HTMLProgressElement.cpp	2012-02-09 05:26:00 UTC (rev 107177)
+++ trunk/Source/WebCore/html/HTMLProgressElement.cpp	2012-02-09 05:46:57 UTC (rev 107178)
@@ -153,11 +153,14 @@
 
 void HTMLProgressElement::createShadowSubtree()
 {
+    ASSERT(!shadowRoot());
+
     RefPtr<ProgressBarElement> bar = ProgressBarElement::create(document());
     m_value = ProgressValueElement::create(document());
-    ExceptionCode ec = 0;
-    bar->appendChild(m_value, ec);
-    ensureShadowRoot()->appendChild(bar, ec);
+    bar->appendChild(m_value, ASSERT_NO_EXCEPTION);
+
+    RefPtr<ShadowRoot> root = ShadowRoot::create(this, ASSERT_NO_EXCEPTION);
+    root->appendChild(bar, ASSERT_NO_EXCEPTION);
 }
 
 } // namespace

Modified: trunk/Source/WebCore/html/HTMLSummaryElement.cpp (107177 => 107178)


--- trunk/Source/WebCore/html/HTMLSummaryElement.cpp	2012-02-09 05:26:00 UTC (rev 107177)
+++ trunk/Source/WebCore/html/HTMLSummaryElement.cpp	2012-02-09 05:46:57 UTC (rev 107178)
@@ -73,9 +73,10 @@
 
 void HTMLSummaryElement::createShadowSubtree()
 {
-    ExceptionCode ec = 0;
-    ensureShadowRoot()->appendChild(DetailsMarkerControl::create(document()), ec, true);
-    ensureShadowRoot()->appendChild(SummaryContentElement::create(document()), ec, true);
+    ASSERT(!shadowRoot());
+    RefPtr<ShadowRoot> root = ShadowRoot::create(this, ASSERT_NO_EXCEPTION);
+    root->appendChild(DetailsMarkerControl::create(document()), ASSERT_NO_EXCEPTION, true);
+    root->appendChild(SummaryContentElement::create(document()), ASSERT_NO_EXCEPTION, true);
 }
 
 HTMLDetailsElement* HTMLSummaryElement::detailsElement() const

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (107177 => 107178)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2012-02-09 05:26:00 UTC (rev 107177)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2012-02-09 05:46:57 UTC (rev 107178)
@@ -84,8 +84,9 @@
 
 void HTMLTextAreaElement::createShadowSubtree()
 {
-    ExceptionCode ec = 0;
-    ensureShadowRoot()->appendChild(TextControlInnerTextElement::create(document()), ec);
+    ASSERT(!shadowRoot());
+    RefPtr<ShadowRoot> root = ShadowRoot::create(this, ASSERT_NO_EXCEPTION);
+    root->appendChild(TextControlInnerTextElement::create(document()), ASSERT_NO_EXCEPTION);
 }
 
 const AtomicString& HTMLTextAreaElement::formControlType() const
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to