Diff
Modified: trunk/ChangeLog (105848 => 105849)
--- trunk/ChangeLog 2012-01-25 06:08:41 UTC (rev 105848)
+++ trunk/ChangeLog 2012-01-25 06:48:26 UTC (rev 105849)
@@ -1,3 +1,14 @@
+2012-01-25 Roland Steiner <[email protected]>
+
+ <style scoped>: Implement registering of <style scoped> with the scoping element
+ https://bugs.webkit.org/show_bug.cgi?id=67790
+
+ windows.internals updates
+
+ Reviewed by Dimitri Glazkov.
+
+ * Source/autotools/symbols.filter:
+
2012-01-24 Mark Rowe <[email protected]>
Death to _javascript_Glue.
Modified: trunk/LayoutTests/ChangeLog (105848 => 105849)
--- trunk/LayoutTests/ChangeLog 2012-01-25 06:08:41 UTC (rev 105848)
+++ trunk/LayoutTests/ChangeLog 2012-01-25 06:48:26 UTC (rev 105849)
@@ -1,3 +1,16 @@
+2012-01-25 Roland Steiner <[email protected]>
+
+ <style scoped>: Implement registering of <style scoped> with the scoping element
+ https://bugs.webkit.org/show_bug.cgi?id=67790
+
+ Tests that registration of <style scoped> with its parent is performed correctly
+ in various circumstances.
+
+ Reviewed by Dimitri Glazkov.
+
+ * fast/css/style-scoped/registering-expected.txt: Added.
+ * fast/css/style-scoped/registering.html: Added.
+
2012-01-24 Adam Barth <[email protected]>
Mark test as flaky.
Added: trunk/LayoutTests/fast/css/style-scoped/registering-expected.txt (0 => 105849)
--- trunk/LayoutTests/fast/css/style-scoped/registering-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/style-scoped/registering-expected.txt 2012-01-25 06:48:26 UTC (rev 105849)
@@ -0,0 +1,59 @@
+Test [un]registering a <style scoped> element from its parent
+
+--- Initial ---
+PASS internals.numberOfScopedHTMLStyleChildren(scope1) is 1
+PASS internals.numberOfScopedHTMLStyleChildren(scope2) is 0
+PASS internals.numberOfScopedHTMLStyleChildren(scope3) is 0
+--- Attaching ---
+PASS internals.numberOfScopedHTMLStyleChildren(scope1) is 1
+PASS internals.numberOfScopedHTMLStyleChildren(scope2) is 1
+PASS internals.numberOfScopedHTMLStyleChildren(scope3) is 0
+--- Unsetting @scoped ---
+PASS internals.numberOfScopedHTMLStyleChildren(scope1) is 0
+PASS internals.numberOfScopedHTMLStyleChildren(scope2) is 0
+PASS internals.numberOfScopedHTMLStyleChildren(scope3) is 0
+--- Re-setting @scoped ---
+PASS internals.numberOfScopedHTMLStyleChildren(scope1) is 1
+PASS internals.numberOfScopedHTMLStyleChildren(scope2) is 1
+PASS internals.numberOfScopedHTMLStyleChildren(scope3) is 0
+--- Inserting/removing scope elements from document ---
+PASS internals.numberOfScopedHTMLStyleChildren(scope1) is 1
+PASS internals.numberOfScopedHTMLStyleChildren(scope2) is 0
+PASS internals.numberOfScopedHTMLStyleChildren(scope3) is 1
+--- Multiple scoped style elements within single scope ---
+PASS internals.numberOfScopedHTMLStyleChildren(scope1) is 3
+PASS internals.numberOfScopedHTMLStyleChildren(scope2) is 0
+PASS internals.numberOfScopedHTMLStyleChildren(scope3) is 0
+--- Removing scoping element from document ---
+PASS internals.numberOfScopedHTMLStyleChildren(scope1) is 0
+PASS internals.numberOfScopedHTMLStyleChildren(scope2) is 0
+PASS internals.numberOfScopedHTMLStyleChildren(scope3) is 0
+--- Inserting scope within other scope ---
+PASS internals.numberOfScopedHTMLStyleChildren(scope1) is 2
+PASS internals.numberOfScopedHTMLStyleChildren(scope2) is 1
+PASS internals.numberOfScopedHTMLStyleChildren(scope3) is 0
+--- Cloning <style scoped> and parents ---
+PASS internals.numberOfScopedHTMLStyleChildren(scope1) is 2
+PASS internals.numberOfScopedHTMLStyleChildren(scope2) is 1
+PASS internals.numberOfScopedHTMLStyleChildren(scope3) is 0
+PASS internals.numberOfScopedHTMLStyleChildren(clonescope1deep) is 0
+PASS internals.numberOfScopedHTMLStyleChildren(clonescope1shallow) is 0
+PASS internals.numberOfScopedHTMLStyleChildren(clonescope2deep) is 0
+PASS internals.numberOfScopedHTMLStyleChildren(clonescope2shallow) is 0
+--- inserting clones into single parent ---
+PASS internals.numberOfScopedHTMLStyleChildren(scope1) is 2
+PASS internals.numberOfScopedHTMLStyleChildren(scope2) is 1
+PASS internals.numberOfScopedHTMLStyleChildren(scope3) is 4
+PASS internals.numberOfScopedHTMLStyleChildren(clonescope1deep) is 2
+PASS internals.numberOfScopedHTMLStyleChildren(clonescope1shallow) is 0
+PASS internals.numberOfScopedHTMLStyleChildren(clonescope2deep) is 1
+PASS internals.numberOfScopedHTMLStyleChildren(clonescope2shallow) is 0
+--- Unsetting @scoped in nested scope ---
+PASS internals.numberOfScopedHTMLStyleChildren(scope1) is 1
+PASS internals.numberOfScopedHTMLStyleChildren(scope2) is 0
+PASS internals.numberOfScopedHTMLStyleChildren(scope3) is 4
+--- DONE ---
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/css/style-scoped/registering.html (0 => 105849)
--- trunk/LayoutTests/fast/css/style-scoped/registering.html (rev 0)
+++ trunk/LayoutTests/fast/css/style-scoped/registering.html 2012-01-25 06:48:26 UTC (rev 105849)
@@ -0,0 +1,144 @@
+<html>
+<head>
+ <link rel="stylesheet" href=""
+ <script src=""
+</head>
+<body>
+ <p>Test [un]registering a <style scoped> element from its parent</p>
+ <div id="scope1">
+ <style id="global1"></style>
+ <style scoped='scoped1' id="scoped1"></style>
+ </div>
+ <div id="scope2">
+ </div>
+
+ <div id="console"></div>
+
+ <script>
+ if (!window.internals || !window.internals.numberOfScopedHTMLStyleChildren)
+ debug("windows.internals.numberOfScopedHTMLStyleChildren not found!");
+ else {
+ var scope1 = document.getElementById('scope1');
+ var scope2 = document.getElementById('scope2');
+ var scope3 = document.createElement('div');
+
+ var global1 = document.getElementById('global1');
+ var scoped1 = document.getElementById('scoped1');
+
+ var global2 = document.createElement('style');
+ var scoped2 = document.createElement('style');
+ scoped2.setAttribute('scoped', 'scoped');
+ var scoped3 = document.createElement('style');
+ scoped3.scoped = true;
+
+ /* NOTE: <style scoped> outside the document is NOT registered! */
+ debug("--- Initial ---");
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope1)", "1"); /* in tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope2)", "0"); /* out of tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope3)", "0"); /* out of tree */
+
+ debug("--- Attaching ---");
+ scope2.appendChild(scoped2);
+ scope2.appendChild(global2);
+ scope3.appendChild(scoped3);
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope1)", "1"); /* in tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope2)", "1"); /* in tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope3)", "0"); /* out of tree */
+
+ debug("--- Unsetting @scoped ---");
+ scoped1.scoped = false;
+ scoped2.scoped = false;
+ scoped3.removeAttribute('scoped');
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope1)", "0"); /* in tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope2)", "0"); /* in tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope3)", "0"); /* out of tree */
+
+ debug("--- Re-setting @scoped ---");
+ scoped1.scoped = true;
+ scoped2.setAttribute('scoped', 'scoped');
+ scoped3.setAttribute('scoped', '');
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope1)", "1"); /* in tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope2)", "1"); /* in tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope3)", "0"); /* out of tree */
+
+ debug("--- Inserting/removing scope elements from document ---");
+ document.body.insertBefore(scope3, scope2);
+ document.body.removeChild(scope2);
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope1)", "1"); /* in tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope2)", "0"); /* out of tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope3)", "1"); /* in tree */
+
+ debug("--- Multiple scoped style elements within single scope ---");
+ scope2.removeChild(scoped2);
+ scope2.removeChild(global2);
+ scope3.removeChild(scoped3);
+ scope1.appendChild(scoped3);
+ scope1.appendChild(scoped2);
+ scope1.appendChild(global2);
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope1)", "3"); /* in tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope2)", "0"); /* out of tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope3)", "0"); /* in tree */
+
+ debug("--- Removing scoping element from document ---");
+ document.body.removeChild(scope1);
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope1)", "0"); /* out of tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope2)", "0"); /* out of tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope3)", "0"); /* in tree */
+
+ debug("--- Inserting scope within other scope ---");
+ document.body.insertBefore(scope2, scope3);
+ scope1.removeChild(scoped2);
+ scope2.appendChild(scoped2);
+ scope2.appendChild(scope1);
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope1)", "2"); /* in tree, child of scope2 */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope2)", "1"); /* in tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope3)", "0"); /* in tree */
+
+ debug("--- Cloning <style scoped> and parents ---");
+ var clonescope1deep = scope1.cloneNode(true);
+ var clonescope1shallow = scope1.cloneNode(false);
+ var clonescope2deep = scope2.cloneNode(true);
+ var clonescope2shallow = scope2.cloneNode(false);
+ var clonescoped1deep = scoped1.cloneNode(true);
+ var clonescoped1shallow = scoped1.cloneNode(false);
+ var clonescoped2deep = scoped2.cloneNode(true);
+ var clonescoped2shallow = scoped2.cloneNode(false);
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope1)", "2"); /* in tree, child of scope2 */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope2)", "1"); /* in tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope3)", "0"); /* in tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(clonescope1deep)", "0"); /* out of tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(clonescope1shallow)", "0"); /* out of tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(clonescope2deep)", "0"); /* out of tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(clonescope2shallow)", "0"); /* out of tree */
+
+ debug("--- inserting clones into single parent ---");
+ scope3.appendChild(clonescope1deep);
+ scope3.appendChild(clonescope1shallow);
+ scope3.appendChild(clonescope2deep);
+ scope3.appendChild(clonescope2shallow);
+ scope3.appendChild(clonescoped1deep);
+ scope3.appendChild(clonescoped1shallow);
+ scope3.appendChild(clonescoped2deep);
+ scope3.appendChild(clonescoped2shallow);
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope1)", "2"); /* in tree, child of scope2 */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope2)", "1"); /* in tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope3)", "4"); /* in tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(clonescope1deep)", "2"); /* in tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(clonescope1shallow)", "0"); /* in tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(clonescope2deep)", "1"); /* in tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(clonescope2shallow)", "0"); /* in tree */
+
+ debug("--- Unsetting @scoped in nested scope ---");
+ scoped1.scoped = false;
+ scoped2.removeAttribute('scoped');
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope1)", "1"); /* in tree, child of scope2 */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope2)", "0"); /* in tree */
+ shouldBe("internals.numberOfScopedHTMLStyleChildren(scope3)", "4"); /* in tree */
+
+ debug("--- DONE ---");
+ }
+ var successfullyParsed = true;
+ </script>
+ <script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (105848 => 105849)
--- trunk/Source/WebCore/ChangeLog 2012-01-25 06:08:41 UTC (rev 105848)
+++ trunk/Source/WebCore/ChangeLog 2012-01-25 06:48:26 UTC (rev 105849)
@@ -1,3 +1,46 @@
+2012-01-25 Roland Steiner <[email protected]>
+
+ <style scoped>: Implement registering of <style scoped> with the scoping element
+ https://bugs.webkit.org/show_bug.cgi?id=67790
+
+ Implement registering of a <style> element with its parent element if the 'scoped' attribute is set.
+ Update the registration whenever the 'scoped' attribute is changed,
+ or the <style> element eneters or leaves the tree.
+
+ Also, extend windows.internals to allow for testing of the registration ref-counting.
+
+ Reviewed by Dimitri Glazkov.
+
+ Test: fast/css/style-scoped/registering.html
+
+ * WebCore.exp.in:
+ * dom/Element.cpp:
+ (WebCore::Element::hasScopedHTMLStyleChild):
+ (WebCore::Element::numberOfScopedHTMLStyleChildren):
+ (WebCore::Element::registerScopedHTMLStyleChild):
+ (WebCore::Element::unregisterScopedHTMLStyleChild):
+ * dom/Element.h:
+ * dom/ElementRareData.h:
+ (WebCore::ElementRareData::ElementRareData):
+ (WebCore::ElementRareData::registerScopedHTMLStyleChild):
+ (WebCore::ElementRareData::unregisterScopedHTMLStyleChild):
+ (WebCore::ElementRareData::hasScopedHTMLStyleChild):
+ (WebCore::ElementRareData::numberOfScopedHTMLStyleChildren):
+ * html/HTMLStyleElement.cpp:
+ (WebCore::HTMLStyleElement::HTMLStyleElement):
+ (WebCore::HTMLStyleElement::~HTMLStyleElement):
+ (WebCore::HTMLStyleElement::parseMappedAttribute):
+ (WebCore::HTMLStyleElement::registerWithScopingNode):
+ (WebCore::HTMLStyleElement::unregisterWithScopingNode):
+ (WebCore::HTMLStyleElement::insertedIntoDocument):
+ (WebCore::HTMLStyleElement::removedFromDocument):
+ (WebCore::HTMLStyleElement::willRemove):
+ * html/HTMLStyleElement.h:
+ * testing/Internals.cpp:
+ (WebCore::Internals::numberOfScopedHTMLStyleChildren):
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
2012-01-24 Daniel Bates <[email protected]>
Attempt to fix Mac build after changeset <http://trac.webkit.org/changeset/105843>
Modified: trunk/Source/WebCore/WebCore.exp.in (105848 => 105849)
--- trunk/Source/WebCore/WebCore.exp.in 2012-01-25 06:08:41 UTC (rev 105848)
+++ trunk/Source/WebCore/WebCore.exp.in 2012-01-25 06:48:26 UTC (rev 105849)
@@ -2068,3 +2068,7 @@
#endif
#endif
+
+#if ENABLE(STYLE_SCOPED)
+__ZNK7WebCore7Element31numberOfScopedHTMLStyleChildrenEv
+#endif
Modified: trunk/Source/WebCore/dom/Element.cpp (105848 => 105849)
--- trunk/Source/WebCore/dom/Element.cpp 2012-01-25 06:08:41 UTC (rev 105848)
+++ trunk/Source/WebCore/dom/Element.cpp 2012-01-25 06:48:26 UTC (rev 105849)
@@ -1756,6 +1756,30 @@
return count;
}
+#if ENABLE(STYLE_SCOPED)
+bool Element::hasScopedHTMLStyleChild() const
+{
+ return hasRareData() && rareData()->hasScopedHTMLStyleChild();
+}
+
+size_t Element::numberOfScopedHTMLStyleChildren() const
+{
+ return hasRareData() ? rareData()->numberOfScopedHTMLStyleChildren() : 0;
+}
+
+void Element::registerScopedHTMLStyleChild()
+{
+ ensureRareData()->registerScopedHTMLStyleChild();
+}
+
+void Element::unregisterScopedHTMLStyleChild()
+{
+ ASSERT(hasRareData());
+ if (hasRareData())
+ rareData()->unregisterScopedHTMLStyleChild();
+}
+#endif
+
bool Element::webkitMatchesSelector(const String& selector, ExceptionCode& ec)
{
if (selector.isEmpty()) {
Modified: trunk/Source/WebCore/dom/Element.h (105848 => 105849)
--- trunk/Source/WebCore/dom/Element.h 2012-01-25 06:08:41 UTC (rev 105848)
+++ trunk/Source/WebCore/dom/Element.h 2012-01-25 06:48:26 UTC (rev 105849)
@@ -302,6 +302,13 @@
Element* nextElementSibling() const;
unsigned childElementCount() const;
+#if ENABLE(STYLE_SCOPED)
+ void registerScopedHTMLStyleChild();
+ void unregisterScopedHTMLStyleChild();
+ bool hasScopedHTMLStyleChild() const;
+ size_t numberOfScopedHTMLStyleChildren() const;
+#endif
+
bool webkitMatchesSelector(const String& selectors, ExceptionCode&);
DOMTokenList* classList();
Modified: trunk/Source/WebCore/dom/ElementRareData.h (105848 => 105849)
--- trunk/Source/WebCore/dom/ElementRareData.h 2012-01-25 06:08:41 UTC (rev 105848)
+++ trunk/Source/WebCore/dom/ElementRareData.h 2012-01-25 06:48:26 UTC (rev 105849)
@@ -40,6 +40,13 @@
void resetComputedStyle();
+#if ENABLE(STYLE_SCOPED)
+ void registerScopedHTMLStyleChild();
+ void unregisterScopedHTMLStyleChild();
+ bool hasScopedHTMLStyleChild() const;
+ size_t numberOfScopedHTMLStyleChildren() const;
+#endif
+
using NodeRareData::needsFocusAppearanceUpdateSoonAfterAttach;
using NodeRareData::setNeedsFocusAppearanceUpdateSoonAfterAttach;
@@ -68,6 +75,10 @@
ShadowRoot* m_shadowRoot;
AtomicString m_shadowPseudoId;
+#if ENABLE(STYLE_SCOPED)
+ size_t m_numberOfScopedHTMLStyleChildren;
+#endif
+
OwnPtr<DatasetDOMStringMap> m_datasetDOMStringMap;
OwnPtr<ClassList> m_classList;
@@ -86,6 +97,9 @@
inline ElementRareData::ElementRareData()
: m_minimumSizeForResizing(defaultMinimumSizeForResizing())
, m_shadowRoot(0)
+#if ENABLE(STYLE_SCOPED)
+ , m_numberOfScopedHTMLStyleChildren(0)
+#endif
, m_styleAffectedByEmpty(false)
#if ENABLE(FULLSCREEN_API)
, m_containsFullScreenElement(false)
@@ -103,5 +117,29 @@
m_computedStyle.clear();
}
+#if ENABLE(STYLE_SCOPED)
+inline void ElementRareData::registerScopedHTMLStyleChild()
+{
+ ++m_numberOfScopedHTMLStyleChildren;
}
+
+inline void ElementRareData::unregisterScopedHTMLStyleChild()
+{
+ ASSERT(m_numberOfScopedHTMLStyleChildren > 0);
+ if (m_numberOfScopedHTMLStyleChildren > 0)
+ --m_numberOfScopedHTMLStyleChildren;
+}
+
+inline bool ElementRareData::hasScopedHTMLStyleChild() const
+{
+ return m_numberOfScopedHTMLStyleChildren;
+}
+
+inline size_t ElementRareData::numberOfScopedHTMLStyleChildren() const
+{
+ return m_numberOfScopedHTMLStyleChildren;
+}
+#endif
+
+}
#endif // ElementRareData_h
Modified: trunk/Source/WebCore/html/HTMLStyleElement.cpp (105848 => 105849)
--- trunk/Source/WebCore/html/HTMLStyleElement.cpp 2012-01-25 06:08:41 UTC (rev 105848)
+++ trunk/Source/WebCore/html/HTMLStyleElement.cpp 2012-01-25 06:48:26 UTC (rev 105849)
@@ -38,12 +38,17 @@
inline HTMLStyleElement::HTMLStyleElement(const QualifiedName& tagName, Document* document, bool createdByParser)
: HTMLElement(tagName, document)
, StyleElement(document, createdByParser)
+#if ENABLE(STYLE_SCOPED)
+ , m_isRegisteredWithScopingNode(false)
+#endif
{
ASSERT(hasTagName(styleTag));
}
HTMLStyleElement::~HTMLStyleElement()
{
+ // During tear-down, willRemove isn't called, so m_isRegisteredWithScopingNode may still be set here.
+ // Therefore we can't ASSERT(!m_isRegisteredWithScopingNode).
StyleElement::clearDocumentData(document(), this);
}
@@ -56,6 +61,15 @@
{
if (attr->name() == titleAttr && m_sheet)
m_sheet->setTitle(attr->value());
+#if ENABLE(STYLE_SCOPED)
+ else if (attr->name() == scopedAttr) {
+ if (!attr->isNull() && !m_isRegisteredWithScopingNode && inDocument())
+ registerWithScopingNode();
+ else if (attr->isNull() && m_isRegisteredWithScopingNode)
+ unregisterWithScopingNode();
+
+ }
+#endif
else
HTMLElement::parseMappedAttribute(attr);
}
@@ -66,18 +80,82 @@
HTMLElement::finishParsingChildren();
}
+#if ENABLE(STYLE_SCOPED)
+void HTMLStyleElement::registerWithScopingNode()
+{
+ // Note: We cannot rely on the 'scoped' element already being present when this method is invoked.
+ // Therefore we cannot rely on scoped()!
+ ASSERT(!m_isRegisteredWithScopingNode);
+ ASSERT(inDocument());
+ if (!m_isRegisteredWithScopingNode) {
+ Element* scope = parentElement();
+ if (!scope)
+ return;
+
+ scope->registerScopedHTMLStyleChild();
+ scope->setNeedsStyleRecalc();
+ if (inDocument() && !document()->parsing() && document()->renderer())
+ document()->styleSelectorChanged(DeferRecalcStyle);
+
+ m_isRegisteredWithScopingNode = true;
+ }
+}
+
+void HTMLStyleElement::unregisterWithScopingNode()
+{
+ // Note: We cannot rely on the 'scoped' element still being present when this method is invoked.
+ // Therefore we cannot rely on scoped()!
+ ASSERT(m_isRegisteredWithScopingNode);
+ if (m_isRegisteredWithScopingNode) {
+ Element* scope = parentElement();
+ ASSERT(scope);
+ if (scope) {
+ ASSERT(scope->hasScopedHTMLStyleChild());
+ scope->unregisterScopedHTMLStyleChild();
+ scope->setNeedsStyleRecalc();
+ }
+ if (inDocument() && !document()->parsing() && document()->renderer())
+ document()->styleSelectorChanged(DeferRecalcStyle);
+
+ m_isRegisteredWithScopingNode = false;
+ }
+}
+#endif
+
void HTMLStyleElement::insertedIntoDocument()
{
HTMLElement::insertedIntoDocument();
StyleElement::insertedIntoDocument(document(), this);
+#if ENABLE(STYLE_SCOPED)
+ if (scoped() && !m_isRegisteredWithScopingNode)
+ registerWithScopingNode();
+#endif
}
void HTMLStyleElement::removedFromDocument()
{
+#if ENABLE(STYLE_SCOPED)
+ ASSERT(!m_isRegisteredWithScopingNode);
+#endif
HTMLElement::removedFromDocument();
StyleElement::removedFromDocument(document(), this);
}
+
+#if ENABLE(STYLE_SCOPED)
+void HTMLStyleElement::willRemove()
+{
+ // In the current implementation, <style scoped> is only registered if the node is in the document.
+ // That is, because willRemove() is also called if an ancestor is removed from the document.
+ // Now, if we want to register <style scoped> even if it's not inDocument,
+ // we'd need to find a way to discern whether that is the case, or whether <style scoped> itself is about to be removed.
+ ASSERT(!scoped() || !inDocument() || m_isRegisteredWithScopingNode);
+ if (m_isRegisteredWithScopingNode)
+ unregisterWithScopingNode();
+ HTMLElement::willRemove();
+}
+#endif
+
void HTMLStyleElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
{
StyleElement::childrenChanged(this);
Modified: trunk/Source/WebCore/html/HTMLStyleElement.h (105848 => 105849)
--- trunk/Source/WebCore/html/HTMLStyleElement.h 2012-01-25 06:08:41 UTC (rev 105848)
+++ trunk/Source/WebCore/html/HTMLStyleElement.h 2012-01-25 06:48:26 UTC (rev 105849)
@@ -55,6 +55,9 @@
virtual void parseMappedAttribute(Attribute*);
virtual void insertedIntoDocument();
virtual void removedFromDocument();
+#if ENABLE(STYLE_SCOPED)
+ virtual void willRemove();
+#endif
virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
virtual void finishParsingChildren();
@@ -67,6 +70,11 @@
virtual const AtomicString& media() const;
virtual const AtomicString& type() const;
+
+ void registerWithScopingNode();
+ void unregisterWithScopingNode();
+
+ bool m_isRegisteredWithScopingNode;
};
} //namespace
Modified: trunk/Source/WebCore/testing/Internals.cpp (105848 => 105849)
--- trunk/Source/WebCore/testing/Internals.cpp 2012-01-25 06:08:41 UTC (rev 105848)
+++ trunk/Source/WebCore/testing/Internals.cpp 2012-01-25 06:48:26 UTC (rev 105849)
@@ -164,6 +164,19 @@
return representation;
}
+size_t Internals::numberOfScopedHTMLStyleChildren(const Element* element, ExceptionCode& ec) const
+{
+ if (element)
+#if ENABLE(STYLE_SCOPED)
+ return element->numberOfScopedHTMLStyleChildren();
+#else
+ return 0;
+#endif
+
+ ec = INVALID_ACCESS_ERR;
+ return 0;
+}
+
Internals::ShadowRootIfShadowDOMEnabledOrNode* Internals::ensureShadowRoot(Element* host, ExceptionCode& ec)
{
if (!host) {
Modified: trunk/Source/WebCore/testing/Internals.h (105848 => 105849)
--- trunk/Source/WebCore/testing/Internals.h 2012-01-25 06:08:41 UTC (rev 105848)
+++ trunk/Source/WebCore/testing/Internals.h 2012-01-25 06:48:26 UTC (rev 105849)
@@ -55,6 +55,8 @@
bool isPreloaded(Document*, const String& url);
+ size_t numberOfScopedHTMLStyleChildren(const Element*, ExceptionCode&) const;
+
#if ENABLE(SHADOW_DOM)
typedef ShadowRoot ShadowRootIfShadowDOMEnabledOrNode;
#else
Modified: trunk/Source/WebCore/testing/Internals.idl (105848 => 105849)
--- trunk/Source/WebCore/testing/Internals.idl 2012-01-25 06:08:41 UTC (rev 105848)
+++ trunk/Source/WebCore/testing/Internals.idl 2012-01-25 06:48:26 UTC (rev 105849)
@@ -30,6 +30,8 @@
DOMString elementRenderTreeAsText(in Element element) raises(DOMException);
boolean isPreloaded(in Document document, in DOMString url);
+ unsigned long numberOfScopedHTMLStyleChildren(in Element element) raises(DOMException);
+
#if defined(ENABLE_SHADOW_DOM)
ShadowRoot ensureShadowRoot(in Element host) raises (DOMException);
ShadowRoot shadowRoot(in Element host) raises (DOMException);
@@ -37,7 +39,6 @@
Node ensureShadowRoot(in Element host) raises (DOMException);
Node shadowRoot(in Element host) raises (DOMException);
#endif
-
Element includerFor(in Node node) raises (DOMException);
void removeShadowRoot(in Element host) raises (DOMException);
DOMString shadowPseudoId(in Element element) raises (DOMException);
Modified: trunk/Source/WebKit2/ChangeLog (105848 => 105849)
--- trunk/Source/WebKit2/ChangeLog 2012-01-25 06:08:41 UTC (rev 105848)
+++ trunk/Source/WebKit2/ChangeLog 2012-01-25 06:48:26 UTC (rev 105849)
@@ -1,3 +1,15 @@
+2012-01-25 Roland Steiner <[email protected]>
+
+ <style scoped>: Implement registering of <style scoped> with the scoping element
+ https://bugs.webkit.org/show_bug.cgi?id=67790
+
+ Add symbols for windows.internals.numberOfScopedHTMLStyleChildren
+
+ Reviewed by Dimitri Glazkov.
+
+ * win/WebKit2.def:
+ * win/WebKit2CFLite.def:
+
2012-01-24 Beth Dakin <[email protected]>
https://bugs.webkit.org/show_bug.cgi?id=76928
Modified: trunk/Source/WebKit2/win/WebKit2.def (105848 => 105849)
--- trunk/Source/WebKit2/win/WebKit2.def 2012-01-25 06:08:41 UTC (rev 105848)
+++ trunk/Source/WebKit2/win/WebKit2.def 2012-01-25 06:48:26 UTC (rev 105849)
@@ -168,6 +168,7 @@
?markersFor@DocumentMarkerController@WebCore@@QAE?AV?$Vector@PAVDocumentMarker@WebCore@@$0A@@WTF@@PAVNode@2@VMarkerTypes@DocumentMarker@2@@Z
?observeFrame@FrameDestructionObserver@WebCore@@IAEXPAVFrame@2@@Z
?overrideUserPreferredLanguages@WebCore@@YAXABV?$Vector@VString@WTF@@$0A@@WTF@@@Z
+ ; ?numberOfScopedHTMLStyleChildren@Element@WebCore@@QBEIXZ
?page@Document@WebCore@@QBEPAVPage@2@XZ
?paintControlTints@FrameView@WebCore@@AAEXXZ
?rangeFromLocationAndLength@TextIterator@WebCore@@SA?AV?$PassRefPtr@VRange@WebCore@@@WTF@@PAVElement@2@HH_N@Z
Modified: trunk/Source/WebKit2/win/WebKit2CFLite.def (105848 => 105849)
--- trunk/Source/WebKit2/win/WebKit2CFLite.def 2012-01-25 06:08:41 UTC (rev 105848)
+++ trunk/Source/WebKit2/win/WebKit2CFLite.def 2012-01-25 06:48:26 UTC (rev 105849)
@@ -162,6 +162,7 @@
?markersFor@DocumentMarkerController@WebCore@@QAE?AV?$Vector@PAVDocumentMarker@WebCore@@$0A@@WTF@@PAVNode@2@VMarkerTypes@DocumentMarker@2@@Z
?observeFrame@FrameDestructionObserver@WebCore@@IAEXPAVFrame@2@@Z
?overrideUserPreferredLanguages@WebCore@@YAXABV?$Vector@VString@WTF@@$0A@@WTF@@@Z
+ ; ?numberOfScopedHTMLStyleChildren@Element@WebCore@@QBEIXZ
?page@Document@WebCore@@QBEPAVPage@2@XZ
?paintControlTints@FrameView@WebCore@@AAEXXZ
?rangeFromLocationAndLength@TextIterator@WebCore@@SA?AV?$PassRefPtr@VRange@WebCore@@@WTF@@PAVElement@2@HH_N@Z
Modified: trunk/Source/autotools/symbols.filter (105848 => 105849)
--- trunk/Source/autotools/symbols.filter 2012-01-25 06:08:41 UTC (rev 105848)
+++ trunk/Source/autotools/symbols.filter 2012-01-25 06:48:26 UTC (rev 105849)
@@ -78,6 +78,7 @@
_ZNK7WebCore5Frame8settingsEv;
_ZNK7WebCore6JSNode21pushEventHandlerScopeEPN3JSC9ExecStateEPNS1_14ScopeChainNodeE;
_ZNK7WebCore7Element10shadowRootEv;
+_ZNK7WebCore7Element31numberOfScopedHTMLStyleChildrenEv;
_ZNK7WebCore8Document4pageEv;
_ZNK7WebCore8Document8settingsEv;
_ZNK7WebCore8Document4viewEv;