Rename ShadowRoot::hostElement to shadowRoot::host to match the latest spec
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Sep 2015 00:54:43 +0000 (00:54 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Sep 2015 00:54:43 +0000 (00:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148694

Reviewed by Chris Dumez.

Renamed ShadowRoot::hostElement to ShadowRoot::host to match the latest shadow DOM spec.
This will help us implementing shadow DOM in near future.

* dom/ContainerNodeAlgorithms.cpp:
(WebCore::ChildNodeInsertionNotifier::notifyDescendantInsertedIntoDocument):
(WebCore::ChildNodeRemovalNotifier::notifyDescendantRemovedFromDocument):
* dom/Element.cpp:
(WebCore::Element::addShadowRoot):
(WebCore::Element::removeShadowRoot):
* dom/EventDispatcher.cpp:
(WebCore::EventRelatedNodeResolver::moveToParentOrShadowHost):
(WebCore::EventRelatedNodeResolver::findHostOfTreeScopeInTargetTreeScope):
(WebCore::shouldEventCrossShadowBoundary):
(WebCore::EventPath::EventPath):
* dom/Node.cpp:
(WebCore::Node::shadowHost):
(WebCore::Node::deprecatedShadowAncestorNode):
(WebCore::Node::parentOrShadowHostElement):
* dom/NodeRenderingTraversal.cpp:
(WebCore::NodeRenderingTraversal::traverseParent):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::setInnerHTML):
(WebCore::ShadowRoot::setResetStyleInheritance):
* dom/ShadowRoot.h:
(WebCore::Node::parentOrShadowHostNode):
* dom/Text.cpp:
(WebCore::isSVGShadowText):
* dom/TreeScope.cpp:
(WebCore::TreeScope::focusedElement):
* html/shadow/ContentDistributor.cpp:
(WebCore::ContentDistributor::ensureDistribution):
* html/shadow/InsertionPoint.cpp:
(WebCore::InsertionPoint::insertedInto):
(WebCore::InsertionPoint::removedFrom):
* page/DragController.cpp:
(WebCore::asFileInput):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMousePressEvent):
* page/FocusController.cpp:
(WebCore::FocusNavigationScope::owner):
* rendering/RenderLayer.cpp:
(WebCore::rendererForScrollbar):
* style/StyleResolveTree.cpp:
(WebCore::Style::attachShadowRoot):
(WebCore::Style::resolveShadowTree):
* svg/SVGElement.cpp:
(WebCore::SVGElement::correspondingUseElement):

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

18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/ContainerNodeAlgorithms.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/EventDispatcher.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/NodeRenderingTraversal.cpp
Source/WebCore/dom/ShadowRoot.cpp
Source/WebCore/dom/ShadowRoot.h
Source/WebCore/dom/Text.cpp
Source/WebCore/dom/TreeScope.cpp
Source/WebCore/html/shadow/ContentDistributor.cpp
Source/WebCore/html/shadow/InsertionPoint.cpp
Source/WebCore/page/DragController.cpp
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/FocusController.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/style/StyleResolveTree.cpp
Source/WebCore/svg/SVGElement.cpp

index f2d6e5f..08105d6 100644 (file)
@@ -1,3 +1,58 @@
+2015-09-01  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Rename ShadowRoot::hostElement to shadowRoot::host to match the latest spec
+        https://bugs.webkit.org/show_bug.cgi?id=148694
+
+        Reviewed by Chris Dumez.
+
+        Renamed ShadowRoot::hostElement to ShadowRoot::host to match the latest shadow DOM spec.
+        This will help us implementing shadow DOM in near future.
+
+        * dom/ContainerNodeAlgorithms.cpp:
+        (WebCore::ChildNodeInsertionNotifier::notifyDescendantInsertedIntoDocument):
+        (WebCore::ChildNodeRemovalNotifier::notifyDescendantRemovedFromDocument):
+        * dom/Element.cpp:
+        (WebCore::Element::addShadowRoot):
+        (WebCore::Element::removeShadowRoot):
+        * dom/EventDispatcher.cpp:
+        (WebCore::EventRelatedNodeResolver::moveToParentOrShadowHost):
+        (WebCore::EventRelatedNodeResolver::findHostOfTreeScopeInTargetTreeScope):
+        (WebCore::shouldEventCrossShadowBoundary):
+        (WebCore::EventPath::EventPath):
+        * dom/Node.cpp:
+        (WebCore::Node::shadowHost):
+        (WebCore::Node::deprecatedShadowAncestorNode):
+        (WebCore::Node::parentOrShadowHostElement):
+        * dom/NodeRenderingTraversal.cpp:
+        (WebCore::NodeRenderingTraversal::traverseParent):
+        * dom/ShadowRoot.cpp:
+        (WebCore::ShadowRoot::setInnerHTML):
+        (WebCore::ShadowRoot::setResetStyleInheritance):
+        * dom/ShadowRoot.h:
+        (WebCore::Node::parentOrShadowHostNode):
+        * dom/Text.cpp:
+        (WebCore::isSVGShadowText):
+        * dom/TreeScope.cpp:
+        (WebCore::TreeScope::focusedElement):
+        * html/shadow/ContentDistributor.cpp:
+        (WebCore::ContentDistributor::ensureDistribution):
+        * html/shadow/InsertionPoint.cpp:
+        (WebCore::InsertionPoint::insertedInto):
+        (WebCore::InsertionPoint::removedFrom):
+        * page/DragController.cpp:
+        (WebCore::asFileInput):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleMousePressEvent):
+        * page/FocusController.cpp:
+        (WebCore::FocusNavigationScope::owner):
+        * rendering/RenderLayer.cpp:
+        (WebCore::rendererForScrollbar):
+        * style/StyleResolveTree.cpp:
+        (WebCore::Style::attachShadowRoot):
+        (WebCore::Style::resolveShadowTree):
+        * svg/SVGElement.cpp:
+        (WebCore::SVGElement::correspondingUseElement):
+
 2015-09-01  Chris Dumez  <cdumez@apple.com>
 
         NodeFilter should be a callback interface
index 503de3e..21c7439 100644 (file)
@@ -44,7 +44,7 @@ void ChildNodeInsertionNotifier::notifyDescendantInsertedIntoDocument(ContainerN
         return;
 
     if (RefPtr<ShadowRoot> root = downcast<Element>(node).shadowRoot()) {
-        if (node.inDocument() && root->hostElement() == &node)
+        if (node.inDocument() && root->host() == &node)
             notifyNodeInsertedIntoDocument(*root, postInsertionNotificationTargets);
     }
 }
@@ -78,7 +78,7 @@ void ChildNodeRemovalNotifier::notifyDescendantRemovedFromDocument(ContainerNode
         node.document().setCSSTarget(0);
 
     if (RefPtr<ShadowRoot> root = downcast<Element>(node).shadowRoot()) {
-        if (!node.inDocument() && root->hostElement() == &node)
+        if (!node.inDocument() && root->host() == &node)
             notifyNodeRemovedFromDocument(*root.get());
     }
 }
index fb2ec3e..7fb20c7 100644 (file)
@@ -1631,7 +1631,7 @@ void Element::addShadowRoot(Ref<ShadowRoot>&& newShadowRoot)
     ShadowRoot& shadowRoot = newShadowRoot.get();
     ensureElementRareData().setShadowRoot(WTF::move(newShadowRoot));
 
-    shadowRoot.setHostElement(this);
+    shadowRoot.setHost(this);
     shadowRoot.setParentTreeScope(&treeScope());
     shadowRoot.distributor().didShadowBoundaryChange(this);
 
@@ -1660,7 +1660,7 @@ void Element::removeShadowRoot()
 
     elementRareData()->clearShadowRoot();
 
-    oldRoot->setHostElement(0);
+    oldRoot->setHost(0);
     oldRoot->setParentTreeScope(&document());
 
     ChildNodeRemovalNotifier(*this).notify(*oldRoot);
index 7ca7c34..a51ccb8 100644 (file)
@@ -143,7 +143,7 @@ public:
 
         if (m_currentTreeScope) {
             ASSERT(is<ShadowRoot>(m_currentTreeScope->rootNode()));
-            ASSERT(&newTarget == downcast<ShadowRoot>(m_currentTreeScope->rootNode()).hostElement());
+            ASSERT(&newTarget == downcast<ShadowRoot>(m_currentTreeScope->rootNode()).host());
             ASSERT(m_currentTreeScope->parentTreeScope() == &newTreeScope);
         }
 
@@ -184,7 +184,7 @@ public:
                 return previousHost;
             }
             if (is<ShadowRoot>(scope->rootNode()))
-                previousHost = downcast<ShadowRoot>(scope->rootNode()).hostElement();
+                previousHost = downcast<ShadowRoot>(scope->rootNode()).host();
             else
                 ASSERT_WITH_SECURITY_IMPLICATION(!scope->parentTreeScope());
         }
@@ -385,7 +385,7 @@ static inline bool shouldEventCrossShadowBoundary(Event& event, ShadowRoot& shad
         if (Element* element = targetNode->document().webkitCurrentFullScreenElement()) {
             // FIXME: We assume that if the full screen element is a media element that it's
             // the video-only full screen. Both here and elsewhere. But that is probably wrong.
-            if (element->isMediaElement() && shadowRoot.hostElement() == element)
+            if (element->isMediaElement() && shadowRoot.host() == element)
                 return false;
         }
     }
@@ -444,7 +444,7 @@ EventPath::EventPath(Node& targetNode, Event& event)
         }
         if (!node || !shouldEventCrossShadowBoundary(event, downcast<ShadowRoot>(*node), *target))
             return;
-        node = downcast<ShadowRoot>(*node).hostElement();
+        node = downcast<ShadowRoot>(*node).host();
     }
 }
 
index eeb92a6..e25396a 100644 (file)
@@ -1034,14 +1034,14 @@ bool Node::canStartSelection() const
 Element* Node::shadowHost() const
 {
     if (ShadowRoot* root = containingShadowRoot())
-        return root->hostElement();
+        return root->host();
     return 0;
 }
 
 Node* Node::deprecatedShadowAncestorNode() const
 {
     if (ShadowRoot* root = containingShadowRoot())
-        return root->hostElement();
+        return root->host();
 
     return const_cast<Node*>(this);
 }
@@ -1086,7 +1086,7 @@ Element* Node::parentOrShadowHostElement() const
         return nullptr;
 
     if (is<ShadowRoot>(*parent))
-        return downcast<ShadowRoot>(*parent).hostElement();
+        return downcast<ShadowRoot>(*parent).host();
 
     if (!is<Element>(*parent))
         return nullptr;
index d507bc1..c509cd9 100644 (file)
@@ -133,7 +133,7 @@ static ContainerNode* traverseParent(const Node* node, ShadowRootCrossing shadow
         return nullptr;
 
     if (is<ShadowRoot>(*parent))
-        return shadowRootCrossing == CrossShadowRoot ? downcast<ShadowRoot>(parent)->hostElement() : parent;
+        return shadowRootCrossing == CrossShadowRoot ? downcast<ShadowRoot>(parent)->host() : parent;
 
     if (is<InsertionPoint>(*parent)) {
         const InsertionPoint& insertionPoint = downcast<InsertionPoint>(*parent);
index e93fdbf..ea79b15 100644 (file)
@@ -91,7 +91,7 @@ void ShadowRoot::setInnerHTML(const String& markup, ExceptionCode& ec)
         return;
     }
 
-    if (RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(markup, hostElement(), AllowScriptingContent, ec))
+    if (RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(markup, host(), AllowScriptingContent, ec))
         replaceChildrenWithFragment(*this, fragment.release(), ec);
 }
 
@@ -117,7 +117,7 @@ void ShadowRoot::setResetStyleInheritance(bool value)
 
     if (value != m_resetStyleInheritance) {
         m_resetStyleInheritance = value;
-        if (hostElement())
+        if (host())
             setNeedsStyleRecalc();
     }
 }
index cd10f1b..3d45c59 100644 (file)
@@ -53,8 +53,8 @@ public:
     bool resetStyleInheritance() const { return m_resetStyleInheritance; }
     void setResetStyleInheritance(bool);
 
-    Element* hostElement() const { return m_hostElement; }
-    void setHostElement(Element* hostElement) { m_hostElement = hostElement; }
+    Element* host() const { return m_hostElement; }
+    void setHost(Element* hostElement) { m_hostElement = hostElement; }
 
     String innerHTML() const;
     void setInnerHTML(const String&, ExceptionCode&);
@@ -66,7 +66,7 @@ public:
     PassRefPtr<Node> cloneNode(bool, ExceptionCode&);
 
     ContentDistributor& distributor() { return m_distributor; }
-    void invalidateDistribution() { m_distributor.invalidateDistribution(hostElement()); }
+    void invalidateDistribution() { m_distributor.invalidateDistribution(m_hostElement); }
 
     virtual void removeAllEventListeners() override;
 
@@ -79,7 +79,7 @@ private:
     virtual RefPtr<Node> cloneNodeInternal(Document&, CloningOperation) override;
 
     // FIXME: This shouldn't happen. https://bugs.webkit.org/show_bug.cgi?id=88834
-    bool isOrphan() const { return !hostElement(); }
+    bool isOrphan() const { return !m_hostElement; }
 
     unsigned m_resetStyleInheritance : 1;
     unsigned m_type : 1;
@@ -105,7 +105,7 @@ inline ContainerNode* Node::parentOrShadowHostNode() const
 {
     ASSERT(isMainThreadOrGCThread());
     if (is<ShadowRoot>(*this))
-        return downcast<ShadowRoot>(*this).hostElement();
+        return downcast<ShadowRoot>(*this).host();
     return parentNode();
 }
 
index 12b3fc1..b1171d7 100644 (file)
@@ -175,7 +175,7 @@ static bool isSVGShadowText(Text* text)
 {
     Node* parentNode = text->parentNode();
     ASSERT(parentNode);
-    return is<ShadowRoot>(*parentNode) && downcast<ShadowRoot>(*parentNode).hostElement()->hasTagName(SVGNames::trefTag);
+    return is<ShadowRoot>(*parentNode) && downcast<ShadowRoot>(*parentNode).host()->hasTagName(SVGNames::trefTag);
 }
 
 static bool isSVGText(Text* text)
index 26e9fbb..8a1efaa 100644 (file)
@@ -313,7 +313,7 @@ Element* TreeScope::focusedElement()
         return nullptr;
     TreeScope* treeScope = &element->treeScope();
     while (treeScope != this && treeScope != &document) {
-        element = downcast<ShadowRoot>(treeScope->rootNode()).hostElement();
+        element = downcast<ShadowRoot>(treeScope->rootNode()).host();
         treeScope = &element->treeScope();
     }
     if (this != treeScope)
index 8e867e8..c518ef3 100644 (file)
@@ -126,7 +126,7 @@ void ContentDistributor::ensureDistribution(ShadowRoot* shadowRoot)
     ASSERT(shadowRoot);
 
     Vector<ShadowRoot*, 8> shadowRoots;
-    for (Element* current = shadowRoot->hostElement(); current; current = current->shadowHost()) {
+    for (Element* current = shadowRoot->host(); current; current = current->shadowHost()) {
         ShadowRoot* currentRoot = current->shadowRoot();
         if (!currentRoot->distributor().needsDistribution())
             break;
@@ -134,7 +134,7 @@ void ContentDistributor::ensureDistribution(ShadowRoot* shadowRoot)
     }
 
     for (size_t i = shadowRoots.size(); i > 0; --i)
-        shadowRoots[i - 1]->distributor().distribute(shadowRoots[i - 1]->hostElement());
+        shadowRoots[i - 1]->distributor().distribute(shadowRoots[i - 1]->host());
 }
 
 void ContentDistributor::invalidateDistribution(Element* host)
index 102c8f2..9cce214 100644 (file)
@@ -85,7 +85,7 @@ Node::InsertionNotificationRequest InsertionPoint::insertedInto(ContainerNode& i
     HTMLElement::insertedInto(insertionPoint);
 
     if (ShadowRoot* root = containingShadowRoot()) {
-        root->distributor().didShadowBoundaryChange(root->hostElement());
+        root->distributor().didShadowBoundaryChange(root->host());
         root->distributor().invalidateInsertionPointList();
     }
 
@@ -98,7 +98,7 @@ void InsertionPoint::removedFrom(ContainerNode& insertionPoint)
     if (!root)
         root = insertionPoint.containingShadowRoot();
 
-    if (root && root->hostElement()) {
+    if (root && root->host()) {
         root->invalidateDistribution();
         root->distributor().invalidateInsertionPointList();
     }
index 8b9e73a..ceb4aa1 100644 (file)
@@ -290,7 +290,7 @@ static HTMLInputElement* asFileInput(Node* node)
 
     // If this is a button inside of the a file input, move up to the file input.
     if (inputElement && inputElement->isTextButton() && is<ShadowRoot>(inputElement->treeScope().rootNode()))
-        inputElement = downcast<ShadowRoot>(inputElement->treeScope().rootNode()).hostElement()->toInputElement();
+        inputElement = downcast<ShadowRoot>(inputElement->treeScope().rootNode()).host()->toInputElement();
 
     return inputElement && inputElement->isFileUpload() ? inputElement : 0;
 }
index 96012dd..c0b1f5d 100644 (file)
@@ -1816,7 +1816,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& platformMouse
         // If a mouse event handler changes the input element type to one that has a widget associated,
         // we'd like to EventHandler::handleMousePressEvent to pass the event to the widget and thus the
         // event target node can't still be the shadow node.
-        if (is<ShadowRoot>(*mouseEvent.targetNode()) && is<HTMLInputElement>(*downcast<ShadowRoot>(*mouseEvent.targetNode()).hostElement()))
+        if (is<ShadowRoot>(*mouseEvent.targetNode()) && is<HTMLInputElement>(*downcast<ShadowRoot>(*mouseEvent.targetNode()).host()))
             mouseEvent = m_frame.document()->prepareMouseEvent(HitTestRequest(), documentPoint, platformMouseEvent);
 
         FrameView* view = m_frame.view();
index 50323de..309a028 100644 (file)
@@ -83,7 +83,7 @@ Element* FocusNavigationScope::owner() const
 {
     ContainerNode* root = rootNode();
     if (is<ShadowRoot>(*root))
-        return downcast<ShadowRoot>(*root).hostElement();
+        return downcast<ShadowRoot>(*root).host();
     if (Frame* frame = root->document().frame())
         return frame->ownerElement();
     return nullptr;
index 74309fd..3797a76 100644 (file)
@@ -3063,7 +3063,7 @@ static inline RenderElement* rendererForScrollbar(RenderLayerModelObject& render
     if (Element* element = renderer.element()) {
         if (ShadowRoot* shadowRoot = element->containingShadowRoot()) {
             if (shadowRoot->type() == ShadowRoot::UserAgentShadowRoot)
-                return shadowRoot->hostElement()->renderer();
+                return shadowRoot->host()->renderer();
         }
     }
 
index aca5cb7..2d85484 100644 (file)
@@ -385,10 +385,10 @@ static void attachDistributedChildren(InsertionPoint& insertionPoint, RenderStyl
 
 static void attachShadowRoot(ShadowRoot& shadowRoot)
 {
-    ASSERT(shadowRoot.hostElement());
-    ASSERT(shadowRoot.hostElement()->renderer());
+    ASSERT(shadowRoot.host());
+    ASSERT(shadowRoot.host()->renderer());
 
-    auto& renderer = *shadowRoot.hostElement()->renderer();
+    auto& renderer = *shadowRoot.host()->renderer();
     RenderTreePosition renderTreePosition(renderer);
     attachChildren(shadowRoot, renderer.style(), renderTreePosition);
 
@@ -678,7 +678,7 @@ void resolveTextNode(Text& text, RenderTreePosition& renderTreePosition)
 
 static void resolveShadowTree(ShadowRoot& shadowRoot, Element& host, Style::Change change)
 {
-    ASSERT(shadowRoot.hostElement() == &host);
+    ASSERT(shadowRoot.host() == &host);
     ASSERT(host.renderer());
     RenderTreePosition renderTreePosition(*host.renderer());
     for (Node* child = shadowRoot.firstChild(); child; child = child->nextSibling()) {
index 51fc6fe..cac76d6 100644 (file)
@@ -490,7 +490,7 @@ SVGUseElement* SVGElement::correspondingUseElement() const
         return nullptr;
     if (root->type() != ShadowRoot::UserAgentShadowRoot)
         return nullptr;
-    auto* host = root->hostElement();
+    auto* host = root->host();
     if (!is<SVGUseElement>(host))
         return nullptr;
     return &downcast<SVGUseElement>(*host);