Diff
Modified: trunk/Source/WebCore/ChangeLog (122297 => 122298)
--- trunk/Source/WebCore/ChangeLog 2012-07-11 05:40:09 UTC (rev 122297)
+++ trunk/Source/WebCore/ChangeLog 2012-07-11 05:43:06 UTC (rev 122298)
@@ -1,3 +1,45 @@
+2012-07-10 Shinya Kawanaka <[email protected]>
+
+ ShadowRoot should know its type in debug build.
+ https://bugs.webkit.org/show_bug.cgi?id=90933
+
+ Reviewed by Hajime Morita.
+
+ For assertion, ShadowRoot should know its type is UserAgentShadowRoot or AuthorShadowRoot.
+
+ This patch also renames ShadowRootCreationPurpose to ShadowRootType, since it is suitable
+ name for ShadowRoot to have.
+
+ No new tests, since it is used only for assertion.
+
+ * dom/Element.cpp:
+ (WebCore::Element::ensureShadowRoot):
+ * dom/ShadowRoot.cpp:
+ (WebCore::ShadowRoot::create):
+ * dom/ShadowRoot.h:
+ (ShadowRoot):
+ (WebCore::ShadowRoot::type):
+ * html/HTMLDetailsElement.cpp:
+ (WebCore::HTMLDetailsElement::createShadowSubtree):
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::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):
+ * html/InputType.cpp:
+ (WebCore::InputType::destroyShadowSubtree): Asserts that ShadowRoot type is UserAgentShadowRoot.
+ * html/shadow/TextFieldDecorationElement.cpp:
+ (WebCore::getDecorationRootAndDecoratedRoot):
+ * svg/SVGTRefElement.cpp:
+ (WebCore::SVGTRefElement::createShadowSubtree):
+
2012-07-10 George Staikos <[email protected]>
Add missing binding type String for IndexedDB.
Modified: trunk/Source/WebCore/dom/Element.cpp (122297 => 122298)
--- trunk/Source/WebCore/dom/Element.cpp 2012-07-11 05:40:09 UTC (rev 122297)
+++ trunk/Source/WebCore/dom/Element.cpp 2012-07-11 05:43:06 UTC (rev 122298)
@@ -1181,7 +1181,7 @@
if (ElementShadow* shadow = this->shadow())
return shadow->oldestShadowRoot();
- return ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot).get();
+ return ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot).get();
}
const AtomicString& Element::shadowPseudoId() const
Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (122297 => 122298)
--- trunk/Source/WebCore/dom/ShadowRoot.cpp 2012-07-11 05:40:09 UTC (rev 122297)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp 2012-07-11 05:43:06 UTC (rev 122298)
@@ -99,10 +99,10 @@
PassRefPtr<ShadowRoot> ShadowRoot::create(Element* element, ExceptionCode& ec)
{
- return create(element, CreatingAuthorShadowRoot, ec);
+ return create(element, AuthorShadowRoot, ec);
}
-PassRefPtr<ShadowRoot> ShadowRoot::create(Element* element, ShadowRootCreationPurpose purpose, ExceptionCode& ec)
+PassRefPtr<ShadowRoot> ShadowRoot::create(Element* element, ShadowRootType type, ExceptionCode& ec)
{
if (!element) {
ec = HIERARCHY_REQUEST_ERR;
@@ -111,12 +111,15 @@
// Since some elements recreates shadow root dynamically, multiple shadow subtrees won't work well in that element.
// Until they are fixed, we disable adding author shadow root for them.
- if (purpose == CreatingAuthorShadowRoot && !allowsAuthorShadowRoot(element)) {
+ if (type == AuthorShadowRoot && !allowsAuthorShadowRoot(element)) {
ec = HIERARCHY_REQUEST_ERR;
return 0;
}
RefPtr<ShadowRoot> shadowRoot = adoptRef(new ShadowRoot(element->document()));
+#ifndef NDEBUG
+ shadowRoot->m_type = type;
+#endif
ec = 0;
element->ensureShadow()->addShadowRoot(element, shadowRoot, ec);
Modified: trunk/Source/WebCore/dom/ShadowRoot.h (122297 => 122298)
--- trunk/Source/WebCore/dom/ShadowRoot.h 2012-07-11 05:40:09 UTC (rev 122297)
+++ trunk/Source/WebCore/dom/ShadowRoot.h 2012-07-11 05:43:06 UTC (rev 122298)
@@ -51,11 +51,11 @@
// if a shadow root is dynamically created. So we prohibit multiple shadow subtrees
// in several elements for a while.
// See https://bugs.webkit.org/show_bug.cgi?id=77503 and related bugs.
- enum ShadowRootCreationPurpose {
- CreatingUserAgentShadowRoot,
- CreatingAuthorShadowRoot,
+ enum ShadowRootType {
+ UserAgentShadowRoot,
+ AuthorShadowRoot
};
- static PassRefPtr<ShadowRoot> create(Element*, ShadowRootCreationPurpose, ExceptionCode& = ASSERT_NO_EXCEPTION);
+ static PassRefPtr<ShadowRoot> create(Element*, ShadowRootType, ExceptionCode& = ASSERT_NO_EXCEPTION);
void recalcShadowTreeStyle(StyleChange);
@@ -89,6 +89,10 @@
InsertionPoint* assignedTo() const;
void setAssignedTo(InsertionPoint*);
+#ifndef NDEBUG
+ ShadowRootType type() const { return m_type; }
+#endif
+
private:
ShadowRoot(Document*);
virtual ~ShadowRoot();
@@ -102,6 +106,10 @@
bool m_applyAuthorStyles : 1;
bool m_resetStyleInheritance : 1;
InsertionPoint* m_insertionPointAssignedTo;
+
+#ifndef NDEBUG
+ ShadowRootType m_type;
+#endif
};
inline Element* ShadowRoot::host() const
Modified: trunk/Source/WebCore/html/HTMLDetailsElement.cpp (122297 => 122298)
--- trunk/Source/WebCore/html/HTMLDetailsElement.cpp 2012-07-11 05:40:09 UTC (rev 122297)
+++ trunk/Source/WebCore/html/HTMLDetailsElement.cpp 2012-07-11 05:43:06 UTC (rev 122298)
@@ -112,7 +112,7 @@
{
ASSERT(!shadow());
- RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot);
+ RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot);
root->appendChild(DetailsSummaryElement::create(document()), ASSERT_NO_EXCEPTION, true);
root->appendChild(DetailsContentElement::create(document()), ASSERT_NO_EXCEPTION, true);
}
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (122297 => 122298)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2012-07-11 05:40:09 UTC (rev 122297)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2012-07-11 05:43:06 UTC (rev 122298)
@@ -118,7 +118,7 @@
void HTMLInputElement::createShadowSubtree()
{
ASSERT(!shadow());
- ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot, ASSERT_NO_EXCEPTION);
+ ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot, ASSERT_NO_EXCEPTION);
m_inputType->createShadowSubtree();
}
Modified: trunk/Source/WebCore/html/HTMLKeygenElement.cpp (122297 => 122298)
--- trunk/Source/WebCore/html/HTMLKeygenElement.cpp 2012-07-11 05:40:09 UTC (rev 122297)
+++ trunk/Source/WebCore/html/HTMLKeygenElement.cpp 2012-07-11 05:43:06 UTC (rev 122298)
@@ -87,7 +87,7 @@
}
ASSERT(!shadow());
- RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot);
+ RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot);
root->appendChild(select, ec);
}
Modified: trunk/Source/WebCore/html/HTMLMeterElement.cpp (122297 => 122298)
--- trunk/Source/WebCore/html/HTMLMeterElement.cpp 2012-07-11 05:40:09 UTC (rev 122297)
+++ trunk/Source/WebCore/html/HTMLMeterElement.cpp 2012-07-11 05:43:06 UTC (rev 122298)
@@ -228,7 +228,7 @@
ExceptionCode ec = 0;
bar->appendChild(m_value, ec);
- RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot);
+ RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot);
root->appendChild(bar, ec);
}
Modified: trunk/Source/WebCore/html/HTMLProgressElement.cpp (122297 => 122298)
--- trunk/Source/WebCore/html/HTMLProgressElement.cpp 2012-07-11 05:40:09 UTC (rev 122297)
+++ trunk/Source/WebCore/html/HTMLProgressElement.cpp 2012-07-11 05:43:06 UTC (rev 122298)
@@ -151,7 +151,7 @@
m_value = ProgressValueElement::create(document());
bar->appendChild(m_value, ASSERT_NO_EXCEPTION);
- RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot, ASSERT_NO_EXCEPTION);
+ RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot, ASSERT_NO_EXCEPTION);
root->appendChild(bar, ASSERT_NO_EXCEPTION);
}
Modified: trunk/Source/WebCore/html/HTMLSummaryElement.cpp (122297 => 122298)
--- trunk/Source/WebCore/html/HTMLSummaryElement.cpp 2012-07-11 05:40:09 UTC (rev 122297)
+++ trunk/Source/WebCore/html/HTMLSummaryElement.cpp 2012-07-11 05:43:06 UTC (rev 122298)
@@ -81,7 +81,7 @@
void HTMLSummaryElement::createShadowSubtree()
{
ASSERT(!shadow());
- RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot);
+ RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot);
root->appendChild(DetailsMarkerControl::create(document()), ASSERT_NO_EXCEPTION, true);
root->appendChild(SummaryContentElement::create(document()), ASSERT_NO_EXCEPTION, true);
}
Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (122297 => 122298)
--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp 2012-07-11 05:40:09 UTC (rev 122297)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp 2012-07-11 05:43:06 UTC (rev 122298)
@@ -89,7 +89,7 @@
void HTMLTextAreaElement::createShadowSubtree()
{
ASSERT(!shadow());
- RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot);
+ RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot);
root->appendChild(TextControlInnerTextElement::create(document()), ASSERT_NO_EXCEPTION);
}
Modified: trunk/Source/WebCore/html/InputType.cpp (122297 => 122298)
--- trunk/Source/WebCore/html/InputType.cpp 2012-07-11 05:40:09 UTC (rev 122297)
+++ trunk/Source/WebCore/html/InputType.cpp 2012-07-11 05:43:06 UTC (rev 122298)
@@ -453,6 +453,7 @@
return;
ShadowRoot* root = shadow->oldestShadowRoot();
+ ASSERT(root->type() == ShadowRoot::UserAgentShadowRoot);
root->removeAllChildren();
// It's ok to clear contents of all other ShadowRoots because they must have
Modified: trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.cpp (122297 => 122298)
--- trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.cpp 2012-07-11 05:40:09 UTC (rev 122297)
+++ trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.cpp 2012-07-11 05:43:06 UTC (rev 122298)
@@ -89,7 +89,7 @@
if (newRoot)
newRoot->removeChild(newRoot->firstChild());
else
- newRoot = ShadowRoot::create(input, ShadowRoot::CreatingUserAgentShadowRoot, ASSERT_NO_EXCEPTION).get();
+ newRoot = ShadowRoot::create(input, ShadowRoot::UserAgentShadowRoot, ASSERT_NO_EXCEPTION).get();
decorationRoot = newRoot;
decoratedRoot = existingRoot;
}
Modified: trunk/Source/WebCore/svg/SVGTRefElement.cpp (122297 => 122298)
--- trunk/Source/WebCore/svg/SVGTRefElement.cpp 2012-07-11 05:40:09 UTC (rev 122297)
+++ trunk/Source/WebCore/svg/SVGTRefElement.cpp 2012-07-11 05:43:06 UTC (rev 122298)
@@ -155,7 +155,7 @@
void SVGTRefElement::createShadowSubtree()
{
- ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot, ASSERT_NO_EXCEPTION);
+ ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot, ASSERT_NO_EXCEPTION);
}
void SVGTRefElement::updateReferencedText()