Skip to content
Permalink
Browse files
<style scoped>: Allow <style scoped> as a direct child of a ShadowRoot
https://bugs.webkit.org/show_bug.cgi?id=77853

.:

numberOfScopedHTMLStyleChildren got moved from Element into Node.

Reviewed by Dimitri Glazkov.

* Source/autotools/symbols.filter:

Source/WebCore:

Moved registration code from Element to Node. updated Internals and build files accordingly.
Moved registration data members from ElementRareData to NodeRareData.
Forward willRemove() from host element into shadow DOM tree.

Reviewed by Dimitri Glazkov.

Test: fast/css/style-scoped/registering-shadowroot.html

* WebCore.exp.in:
* dom/Element.cpp:
(WebCore::Element::willRemove):
* dom/Element.h:
(Element):
* dom/ElementRareData.h:
(ElementRareData):
(WebCore::ElementRareData::ElementRareData):
* dom/Node.cpp:
(WebCore):
(WebCore::Node::hasScopedHTMLStyleChild):
(WebCore::Node::numberOfScopedHTMLStyleChildren):
(WebCore::Node::registerScopedHTMLStyleChild):
(WebCore::Node::unregisterScopedHTMLStyleChild):
* dom/Node.h:
(Node):
* dom/NodeRareData.h:
(WebCore::NodeRareData::NodeRareData):
(NodeRareData):
(WebCore::NodeRareData::registerScopedHTMLStyleChild):
(WebCore::NodeRareData::unregisterScopedHTMLStyleChild):
(WebCore::NodeRareData::hasScopedHTMLStyleChild):
(WebCore::NodeRareData::numberOfScopedHTMLStyleChildren):
* dom/ShadowRootList.cpp:
(WebCore::ShadowRootList::willRemove):
(WebCore):
* dom/ShadowRootList.h:
(ShadowRootList):
* html/HTMLStyleElement.cpp:
(WebCore::HTMLStyleElement::registerWithScopingNode):
(WebCore::HTMLStyleElement::unregisterWithScopingNode):
* testing/Internals.cpp:
(WebCore::Internals::numberOfScopedHTMLStyleChildren):
* testing/Internals.h:
(Internals):
* testing/Internals.idl:

Source/WebKit2:

numberOfScopedHTMLStyleChildren got moved from Element into Node.

Reviewed by Dimitri Glazkov.

* win/WebKit2.def:
* win/WebKit2CFLite.def:

LayoutTests:

Test registration of <style scoped> as a direct child of a ShadowRoot.

Reviewed by Dimitri Glazkov.

* fast/css/style-scoped/registering-shadowroot-expected.txt: Added.
* fast/css/style-scoped/registering-shadowroot.html: Added.

Canonical link: https://commits.webkit.org/95635@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@107793 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Roland Steiner committed Feb 15, 2012
1 parent d55db58 commit 01904e62216b7fe56af9424cfe41ced32d34eb58
@@ -1,3 +1,14 @@
2012-02-15 Roland Steiner <rolandsteiner@chromium.org>

<style scoped>: Allow <style scoped> as a direct child of a ShadowRoot
https://bugs.webkit.org/show_bug.cgi?id=77853

numberOfScopedHTMLStyleChildren got moved from Element into Node.

Reviewed by Dimitri Glazkov.

* Source/autotools/symbols.filter:

2012-02-13 Raphael Kubo da Costa <kubo@profusion.mobi>

[CMake] Merge WebKitEfl.cmake into FindEFL.cmake.
@@ -1,3 +1,15 @@
2012-02-15 Roland Steiner <rolandsteiner@chromium.org>

<style scoped>: Allow <style scoped> as a direct child of a ShadowRoot
https://bugs.webkit.org/show_bug.cgi?id=77853

Test registration of <style scoped> as a direct child of a ShadowRoot.

Reviewed by Dimitri Glazkov.

* fast/css/style-scoped/registering-shadowroot-expected.txt: Added.
* fast/css/style-scoped/registering-shadowroot.html: Added.

2012-02-14 Pavel Feldman <pfeldman@chromium.org>

Web Inspector: implement redo for DOM actions.
@@ -0,0 +1,31 @@
Test having a <style scoped> element as a direct child of a ShadowRoot.

--- Initial ---
PASS internals.numberOfScopedHTMLStyleChildren(host) is 0
PASS internals.numberOfScopedHTMLStyleChildren(sr) is 0
--- Attaching <style scoped> ---
PASS internals.numberOfScopedHTMLStyleChildren(host) is 0
PASS internals.numberOfScopedHTMLStyleChildren(sr) is 1
--- Removing host ---
PASS internals.numberOfScopedHTMLStyleChildren(host) is 0
PASS internals.numberOfScopedHTMLStyleChildren(sr) is 0
--- Inserting host ---
PASS internals.numberOfScopedHTMLStyleChildren(host) is 0
PASS internals.numberOfScopedHTMLStyleChildren(sr) is 1
--- Unsetting @scoped ---
PASS internals.numberOfScopedHTMLStyleChildren(host) is 0
PASS internals.numberOfScopedHTMLStyleChildren(sr) is 0
--- Setting @scoped ---
PASS internals.numberOfScopedHTMLStyleChildren(host) is 0
PASS internals.numberOfScopedHTMLStyleChildren(sr) is 1
--- Detaching <style scoped> ---
PASS internals.numberOfScopedHTMLStyleChildren(host) is 0
PASS internals.numberOfScopedHTMLStyleChildren(sr) is 0
--- Attaching <style scoped> under host ---
PASS internals.numberOfScopedHTMLStyleChildren(host) is 1
PASS internals.numberOfScopedHTMLStyleChildren(sr) is 0
--- DONE ---
PASS successfullyParsed is true

TEST COMPLETE

@@ -0,0 +1,74 @@
<html>
<head>
<link rel="stylesheet" href="../../js/resources/js-test-style.css">
<script src="../../js/resources/js-test-pre.js"></script>
</head>
<body>
<p>Test having a &lt;style scoped&gt; element as a direct child of a ShadowRoot.</p>
<div id="host">
</div>
<div id="ref">
</div>

<div id="console"></div>

<script>
if (!window.internals)
debug("windows.internals not found!");
else if (!window.internals.ensureShadowRoot)
debug("windows.internals.ensureShadowRoot not found!");
else if (!window.internals.numberOfScopedHTMLStyleChildren)
debug("windows.internals.numberOfScopedHTMLStyleChildren not found!");
else {
var ref = document.getElementById('ref');
var host = document.getElementById('host');
var sr = internals.ensureShadowRoot(host);
var style = document.createElement('style');
style.setAttribute('scoped', 'scoped');

debug("--- Initial ---");
shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0");
shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "0"); /* <style> out of document, scoped */

debug("--- Attaching &lt;style scoped&gt; ---");
sr.appendChild(style);
shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0");
shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "1"); /* <style> in shadow, scoped */

debug("--- Removing host ---");
host.parentNode.removeChild(host);
shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0");
shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "0"); /* <style> out of document, scoped */

debug("--- Inserting host ---");
ref.parentNode.insertBefore(host, ref);
shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0");
shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "1"); /* <style> in shadow, scoped */

debug("--- Unsetting @scoped ---");
style.scoped = false;
shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0");
shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "0"); /* <style> in shadow, not scoped */

debug("--- Setting @scoped ---");
style.scoped = true;
shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0");
shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "1"); /* <style> in shadow, scoped */

debug("--- Detaching &lt;style scoped&gt; ---");
sr.removeChild(style);
shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0");
shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "0"); /* <style> out of document, scoped */

debug("--- Attaching &lt;style scoped&gt; under host ---");
host.appendChild(style);
shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "1");
shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "0"); /* <style> in tree, scoped */

debug("--- DONE ---");
}
var successfullyParsed = true;
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
@@ -1,3 +1,53 @@
2012-02-15 Roland Steiner <rolandsteiner@chromium.org>

<style scoped>: Allow <style scoped> as a direct child of a ShadowRoot
https://bugs.webkit.org/show_bug.cgi?id=77853

Moved registration code from Element to Node. updated Internals and build files accordingly.
Moved registration data members from ElementRareData to NodeRareData.
Forward willRemove() from host element into shadow DOM tree.

Reviewed by Dimitri Glazkov.

Test: fast/css/style-scoped/registering-shadowroot.html

* WebCore.exp.in:
* dom/Element.cpp:
(WebCore::Element::willRemove):
* dom/Element.h:
(Element):
* dom/ElementRareData.h:
(ElementRareData):
(WebCore::ElementRareData::ElementRareData):
* dom/Node.cpp:
(WebCore):
(WebCore::Node::hasScopedHTMLStyleChild):
(WebCore::Node::numberOfScopedHTMLStyleChildren):
(WebCore::Node::registerScopedHTMLStyleChild):
(WebCore::Node::unregisterScopedHTMLStyleChild):
* dom/Node.h:
(Node):
* dom/NodeRareData.h:
(WebCore::NodeRareData::NodeRareData):
(NodeRareData):
(WebCore::NodeRareData::registerScopedHTMLStyleChild):
(WebCore::NodeRareData::unregisterScopedHTMLStyleChild):
(WebCore::NodeRareData::hasScopedHTMLStyleChild):
(WebCore::NodeRareData::numberOfScopedHTMLStyleChildren):
* dom/ShadowRootList.cpp:
(WebCore::ShadowRootList::willRemove):
(WebCore):
* dom/ShadowRootList.h:
(ShadowRootList):
* html/HTMLStyleElement.cpp:
(WebCore::HTMLStyleElement::registerWithScopingNode):
(WebCore::HTMLStyleElement::unregisterWithScopingNode):
* testing/Internals.cpp:
(WebCore::Internals::numberOfScopedHTMLStyleChildren):
* testing/Internals.h:
(Internals):
* testing/Internals.idl:

2012-02-14 Pavel Feldman <pfeldman@chromium.org>

Web Inspector: implement redo for DOM actions.
@@ -2088,6 +2088,4 @@ __ZN7WebCore4Page20scrollingCoordinatorEv
__ZNK7WebCore20ScrollingCoordinator13scrollingTreeEv
#endif

#if ENABLE(STYLE_SCOPED)
__ZNK7WebCore7Element31numberOfScopedHTMLStyleChildrenEv
#endif
__ZNK7WebCore4Node31numberOfScopedHTMLStyleChildrenEv
@@ -865,6 +865,8 @@ void Element::willRemove()
if (containsFullScreenElement())
setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false);
#endif
if (ShadowRootList* shadowRoots = shadowRootList())
shadowRoots->willRemove();
ContainerNode::willRemove();
}

@@ -1764,30 +1766,6 @@ unsigned Element::childElementCount() const
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()) {
@@ -326,13 +326,6 @@ class Element : public ContainerNode {
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();
@@ -39,13 +39,6 @@ class ElementRareData : public NodeRareData {

void resetComputedStyle();

#if ENABLE(STYLE_SCOPED)
void registerScopedHTMLStyleChild();
void unregisterScopedHTMLStyleChild();
bool hasScopedHTMLStyleChild() const;
size_t numberOfScopedHTMLStyleChildren() const;
#endif

using NodeRareData::needsFocusAppearanceUpdateSoonAfterAttach;
using NodeRareData::setNeedsFocusAppearanceUpdateSoonAfterAttach;

@@ -74,10 +67,6 @@ class ElementRareData : public NodeRareData {
ShadowRootList m_shadowRootList;
AtomicString m_shadowPseudoId;

#if ENABLE(STYLE_SCOPED)
size_t m_numberOfScopedHTMLStyleChildren;
#endif

OwnPtr<DatasetDOMStringMap> m_datasetDOMStringMap;
OwnPtr<ClassList> m_classList;

@@ -94,10 +83,8 @@ inline IntSize defaultMinimumSizeForResizing()
}

inline ElementRareData::ElementRareData()
: m_minimumSizeForResizing(defaultMinimumSizeForResizing())
#if ENABLE(STYLE_SCOPED)
, m_numberOfScopedHTMLStyleChildren(0)
#endif
: NodeRareData()
, m_minimumSizeForResizing(defaultMinimumSizeForResizing())
, m_styleAffectedByEmpty(false)
#if ENABLE(FULLSCREEN_API)
, m_containsFullScreenElement(false)
@@ -115,29 +102,5 @@ inline void ElementRareData::resetComputedStyle()
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
@@ -2717,6 +2717,39 @@ void Node::notifyMutationObserversNodeWillDetach()
}
#endif // ENABLE(MUTATION_OBSERVERS)

#if ENABLE(STYLE_SCOPED)
bool Node::hasScopedHTMLStyleChild() const
{
return hasRareData() && rareData()->hasScopedHTMLStyleChild();
}

size_t Node::numberOfScopedHTMLStyleChildren() const
{
return hasRareData() ? rareData()->numberOfScopedHTMLStyleChildren() : 0;
}

void Node::registerScopedHTMLStyleChild()
{
ensureRareData()->registerScopedHTMLStyleChild();
}

void Node::unregisterScopedHTMLStyleChild()
{
ASSERT(hasRareData());
if (hasRareData())
rareData()->unregisterScopedHTMLStyleChild();
}
#else
bool Node::hasScopedHTMLStyleChild() const
{
return 0;
}

size_t Node::numberOfScopedHTMLStyleChildren() const
{
return 0;
}
#endif

void Node::handleLocalEvents(Event* event)
{
@@ -638,6 +638,13 @@ class Node : public EventTarget, public ScriptWrappable, public TreeShared<Conta
void notifyMutationObserversNodeWillDetach();
#endif // ENABLE(MUTATION_OBSERVERS)

#if ENABLE(STYLE_SCOPED)
void registerScopedHTMLStyleChild();
void unregisterScopedHTMLStyleChild();
#endif
bool hasScopedHTMLStyleChild() const;
size_t numberOfScopedHTMLStyleChildren() const;

private:
enum NodeFlags {
IsTextFlag = 1,

0 comments on commit 01904e6

Please sign in to comment.