2011-01-07 Rafael Weinstein <rafaelw@chromium.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Jan 2011 23:48:52 +0000 (23:48 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Jan 2011 23:48:52 +0000 (23:48 +0000)
        Reviewed by Eric Seidel.

        Cleanup: Fold shadowParentNode into shadowHost
        https://bugs.webkit.org/show_bug.cgi?id=51059

        Replaces all uses of shadowParentNode.

        No new tests because no behavior has changed.

        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::initForStyleResolve):
        * dom/Node.cpp:
        (WebCore::Node::shadowHost):
        (WebCore::Node::shadowAncestorNode):
        (WebCore::eventTargetRespectingSVGTargetRules):
        (WebCore::Node::getEventAncestors):
        * dom/Node.h:
        * editing/Editor.cpp:
        (WebCore::Editor::findString):
        * page/DragController.cpp:
        (WebCore::asFileInput):
        * page/EventHandler.cpp:
        (WebCore::EventHandler::handleMousePressEvent):
        (WebCore::instanceAssociatedWithShadowTreeElement):
        (WebCore::EventHandler::dispatchMouseEvent):
        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::hasLineIfEmpty):
        * rendering/RenderSVGShadowTreeRootContainer.cpp:
        (WebCore::RenderSVGShadowTreeRootContainer::updateFromElement):
        * svg/SVGStyledElement.cpp:
        (WebCore::SVGStyledElement::title):

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

WebCore/ChangeLog
WebCore/css/CSSStyleSelector.cpp
WebCore/dom/Node.cpp
WebCore/dom/Node.h
WebCore/editing/Editor.cpp
WebCore/page/DragController.cpp
WebCore/page/EventHandler.cpp
WebCore/rendering/RenderBlock.cpp
WebCore/rendering/RenderSVGShadowTreeRootContainer.cpp
WebCore/svg/SVGStyledElement.cpp

index 742c3ce..c1e3094 100644 (file)
@@ -1,3 +1,37 @@
+2011-01-07  Rafael Weinstein  <rafaelw@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        Cleanup: Fold shadowParentNode into shadowHost
+        https://bugs.webkit.org/show_bug.cgi?id=51059
+
+        Replaces all uses of shadowParentNode.
+
+        No new tests because no behavior has changed.
+
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::initForStyleResolve):
+        * dom/Node.cpp:
+        (WebCore::Node::shadowHost):
+        (WebCore::Node::shadowAncestorNode):
+        (WebCore::eventTargetRespectingSVGTargetRules):
+        (WebCore::Node::getEventAncestors):
+        * dom/Node.h:
+        * editing/Editor.cpp:
+        (WebCore::Editor::findString):
+        * page/DragController.cpp:
+        (WebCore::asFileInput):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleMousePressEvent):
+        (WebCore::instanceAssociatedWithShadowTreeElement):
+        (WebCore::EventHandler::dispatchMouseEvent):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::hasLineIfEmpty):
+        * rendering/RenderSVGShadowTreeRootContainer.cpp:
+        (WebCore::RenderSVGShadowTreeRootContainer::updateFromElement):
+        * svg/SVGStyledElement.cpp:
+        (WebCore::SVGStyledElement::title):
+
 2011-01-07  Chris Marrin  <cmarrin@apple.com>
 
         Unreviewed.
index fd9da77..96da74c 100644 (file)
@@ -820,7 +820,7 @@ inline void CSSStyleSelector::initForStyleResolve(Element* e, RenderStyle* paren
 
 #if ENABLE(SVG)
     if (!m_parentNode && e && e->isSVGElement() && e->isShadowRoot())
-        m_parentNode = e->shadowParentNode();
+        m_parentNode = e->shadowHost();
 #endif
 
     if (parentStyle)
index db36e5e..a589282 100644 (file)
@@ -487,7 +487,7 @@ NodeRareData* Node::createRareData()
 
 Element* Node::shadowHost() const
 {
-    return toElement(shadowParentNode());
+    return toElement(getFlag(IsShadowRootFlag) ? parent() : 0);
 }
 
 void Node::setShadowHost(Element* host)
@@ -1467,7 +1467,7 @@ Node* Node::shadowAncestorNode()
 
     Node* root = shadowTreeRootNode();
     if (root)
-        return root->shadowParentNode();
+        return root->shadowHost();
     return this;
 }
 
@@ -2543,7 +2543,7 @@ static inline EventTarget* eventTargetRespectingSVGTargetRules(Node* referenceNo
         if (!n->isShadowRoot() || !n->isSVGElement())
             continue;
 
-        ContainerNode* shadowTreeParentElement = n->shadowParentNode();
+        Element* shadowTreeParentElement = n->shadowHost();
         ASSERT(shadowTreeParentElement->hasTagName(SVGNames::useTag));
 
         if (SVGElementInstance* instance = static_cast<SVGUseElement*>(shadowTreeParentElement)->instanceForShadowTreeElement(referenceNode))
@@ -2566,7 +2566,7 @@ void Node::getEventAncestors(Vector<EventContext>& ancestors, EventTarget* origi
         if (ancestor->isShadowRoot()) {
             if (behavior == StayInsideShadowDOM)
                 return;
-            ancestor = ancestor->shadowParentNode();
+            ancestor = ancestor->shadowHost();
             if (!shouldSkipNextAncestor)
                 target = ancestor;
         } else
index 46b7424..92ba9d3 100644 (file)
@@ -206,14 +206,12 @@ public:
     virtual bool isCharacterDataNode() const { return false; }
     bool isDocumentNode() const;
     bool isShadowRoot() const { return getFlag(IsShadowRootFlag); }
-    // FIXME: Eliminate all uses, fold into shadowHost.
-    ContainerNode* shadowParentNode() const;
     Node* shadowAncestorNode();
     Node* shadowTreeRootNode();
     bool isInShadowTree();
     // Node's parent or shadow tree host.
     ContainerNode* parentOrHostNode() const;
-    // Use when it's guaranteed to that shadowParentNode is 0.
+    // Use when it's guaranteed to that shadowHost is 0.
     ContainerNode* parentNodeGuaranteedHostFree() const;
 
     Element* shadowHost() const;
@@ -728,11 +726,6 @@ inline ContainerNode* Node::parentNodeGuaranteedHostFree() const
     return parentOrHostNode();
 }
 
-inline ContainerNode* Node::shadowParentNode() const
-{
-    return getFlag(IsShadowRootFlag) ? parent() : 0;
-}
-
 } //namespace
 
 #ifndef NDEBUG
index 4433b45..a24e7c6 100644 (file)
@@ -3309,9 +3309,9 @@ bool Editor::findString(const String& target, FindOptions options)
     if (resultRange->collapsed(exception) && shadowTreeRoot) {
         searchRange = rangeOfContents(m_frame->document());
         if (forward)
-            searchRange->setStartAfter(shadowTreeRoot->shadowParentNode(), exception);
+            searchRange->setStartAfter(shadowTreeRoot->shadowHost(), exception);
         else
-            searchRange->setEndBefore(shadowTreeRoot->shadowParentNode(), exception);
+            searchRange->setEndBefore(shadowTreeRoot->shadowHost(), exception);
 
         resultRange = findPlainText(searchRange.get(), target, options);
     }
index 8ee5a8d..d0e9a8c 100644 (file)
@@ -256,7 +256,7 @@ static HTMLInputElement* asFileInput(Node* node)
     // In order to get around this problem we assume any non-FILE input element
     // is this internal button, and try querying the shadow parent node.
     if (node->hasTagName(HTMLNames::inputTag) && node->isShadowRoot() && !static_cast<HTMLInputElement*>(node)->isFileUpload())
-        node = node->shadowParentNode();
+        node = node->shadowHost();
 
     if (!node || !node->hasTagName(HTMLNames::inputTag))
         return 0;
index 0c5071e..048a3cc 100644 (file)
@@ -1383,7 +1383,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
         // 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 (mev.targetNode()->isShadowRoot() && mev.targetNode()->shadowParentNode()->hasTagName(inputTag)) {
+        if (mev.targetNode()->isShadowRoot() && mev.targetNode()->shadowHost()->hasTagName(inputTag)) {
             HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
             mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mouseEvent);
         }
@@ -1795,7 +1795,7 @@ static inline SVGElementInstance* instanceAssociatedWithShadowTreeElement(Node*
     if (!shadowTreeElement)
         return 0;
 
-    Node* shadowTreeParentElement = shadowTreeElement->shadowParentNode();
+    Element* shadowTreeParentElement = shadowTreeElement->shadowHost();
     if (!shadowTreeParentElement)
         return 0;
 
@@ -1913,7 +1913,7 @@ bool EventHandler::dispatchMouseEvent(const AtomicString& eventType, Node* targe
                 // focused if the user does a mouseup over it, however, because the mouseup
                 // will set a selection inside it, which will call setFocuseNodeIfNeeded.
                 ExceptionCode ec = 0;
-                Node* n = node->isShadowRoot() ? node->shadowParentNode() : node;
+                Node* n = node->isShadowRoot() ? node->shadowHost() : node;
                 if (m_frame->selection()->isRange()
                     && m_frame->selection()->toNormalizedRange()->compareNode(n, ec) == Range::NODE_INSIDE
                     && n->isDescendantOf(m_frame->document()->focusedNode()))
index 8895c68..7eba470 100644 (file)
@@ -4927,7 +4927,7 @@ bool RenderBlock::hasLineIfEmpty() const
     if (node()->isContentEditable() && node()->rootEditableElement() == node())
         return true;
     
-    if (node()->isShadowRoot() && (node()->shadowParentNode()->hasTagName(inputTag)))
+    if (node()->isShadowRoot() && (node()->shadowHost()->hasTagName(inputTag)))
         return true;
     
     return false;
index c5430ed..11b398a 100644 (file)
@@ -59,7 +59,7 @@ void RenderSVGShadowTreeRootContainer::updateFromElement()
         useElement->buildPendingResource();
     }
 
-    ASSERT(m_shadowRoot->shadowParentNode() == useElement);
+    ASSERT(m_shadowRoot->shadowHost() == useElement);
 
     bool shouldRecreateTree = m_recreateTree;
     if (m_recreateTree) {
index a9fadb6..58248d8 100644 (file)
@@ -86,7 +86,7 @@ String SVGStyledElement::title() const
         }
         
         // Get the <use> element.
-        ContainerNode* shadowParent = parent->shadowParentNode();
+        Element* shadowParent = parent->shadowHost();
         if (shadowParent && shadowParent->isSVGElement() && shadowParent->hasTagName(SVGNames::useTag)) {
             SVGUseElement* useElement = static_cast<SVGUseElement*>(shadowParent);
             // If the <use> title is not empty we found the title to use.