Changeset 117723 in webkit
- Timestamp:
- May 20, 2012 7:41:58 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r117721 r117723 1 2012-05-20 Shinya Kawanaka <shinyak@chromium.org> 2 3 [Refactoring] Node::shadowHost() and Node::setShadowHost() can be moved to ShadowRoot. 4 https://bugs.webkit.org/show_bug.cgi?id=86585 5 6 Reviewed by Hajime Morita. 7 8 Since Node::shadowHost() and Node::setShadowHost() are valid only if Node is ShadowRoot, 9 they should be moved to ShadowRoot. 10 11 However, Node::setParent cannot be called from ShadowRoot, we add Node::setParentOrHostNode 12 to call it as Node::parentOrHostNode() calls Node::parent(). Node::setParent() is now private. 13 We also add SVGElementInstance::setParentOrHostNode() to share ContainerNodeAlgorithm. 14 15 No new tests, no change in behavior. 16 17 * dom/Attr.cpp: 18 (WebCore::Attr::createTextChild): 19 * dom/ContainerNode.cpp: 20 (WebCore::ContainerNode::insertBeforeCommon): 21 (WebCore::ContainerNode::removeBetween): 22 (WebCore::ContainerNode::removeChildren): 23 * dom/ContainerNodeAlgorithms.h: 24 (WebCore::appendChildToContainer): 25 (WebCore::Private::addChildNodesToDeletionQueue): 26 * dom/ElementShadow.cpp: 27 (WebCore::validateShadowRoot): 28 (WebCore::ElementShadow::addShadowRoot): 29 (WebCore::ElementShadow::removeAllShadowRoots): 30 * dom/EventDispatcher.cpp: 31 (WebCore::eventTargetRespectingSVGTargetRules): 32 (WebCore::EventDispatcher::ensureEventAncestors): 33 (WebCore::EventDispatcher::determineDispatchBehavior): 34 * dom/EventDispatcher.h: 35 (WebCore): 36 (EventDispatcher): 37 * dom/Node.cpp: 38 (WebCore::Node::parentOrHostElement): 39 * dom/Node.h: 40 (Node): 41 (WebCore::Node::setParentOrHostNode): 42 (WebCore): 43 * dom/NodeRenderingContext.cpp: 44 (WebCore::NodeRenderingContext::NodeRenderingContext): 45 * dom/ShadowRoot.h: 46 (WebCore::ShadowRoot::host): 47 (WebCore): 48 (WebCore::ShadowRoot::setHost): 49 * dom/TreeScope.cpp: 50 (WebCore::TreeScope::focusedNode): 51 * html/shadow/ContentSelectorQuery.cpp: 52 (WebCore::ContentSelectorQuery::matches): 53 * page/DragController.cpp: 54 (WebCore::asFileInput): 55 * page/EventHandler.cpp: 56 (WebCore::EventHandler::handleMousePressEvent): 57 (WebCore::instanceAssociatedWithShadowTreeElement): 58 (WebCore::EventHandler::dispatchMouseEvent): 59 * page/FocusController.cpp: 60 (WebCore::FocusScope::owner): 61 * rendering/RenderBlock.cpp: 62 (WebCore::RenderBlock::hasLineIfEmpty): 63 * svg/SVGElementInstance.h: 64 (WebCore::SVGElementInstance::setParentOrHostNode): 65 (SVGElementInstance): 66 * svg/SVGStyledElement.cpp: 67 (WebCore::SVGStyledElement::title): 68 * svg/SVGTRefElement.cpp: 69 (WebCore::SVGShadowText::willRecalcTextStyle): 70 1 71 2012-05-20 Joe Thomas <joethomas@motorola.com> 2 72 -
trunk/Source/WebCore/dom/Attr.cpp
r117353 r117723 82 82 // This does everything appendChild() would do in this situation (assuming m_ignoreChildrenChanged was set), 83 83 // but much more efficiently. 84 textNode->setParent (this);84 textNode->setParentOrHostNode(this); 85 85 setFirstChild(textNode.get()); 86 86 setLastChild(textNode.get()); -
trunk/Source/WebCore/dom/ContainerNode.cpp
r117224 r117723 187 187 ASSERT(!newChild->nextSibling()); 188 188 ASSERT(!newChild->previousSibling()); 189 ASSERT(!newChild->isShadowRoot()); 189 190 190 191 forbidEventDispatch(); … … 200 201 m_firstChild = newChild; 201 202 } 202 newChild->setParent (this);203 newChild->setParentOrHostNode(this); 203 204 newChild->setPreviousSibling(prev); 204 205 newChild->setNextSibling(nextChild); … … 429 430 oldChild->setPreviousSibling(0); 430 431 oldChild->setNextSibling(0); 431 oldChild->setParent (0);432 oldChild->setParentOrHostNode(0); 432 433 433 434 document()->adoptIfNeeded(oldChild); … … 482 483 n->setPreviousSibling(0); 483 484 n->setNextSibling(0); 484 n->setParent (0);485 n->setParentOrHostNode(0); 485 486 document()->adoptIfNeeded(n.get()); 486 487 -
trunk/Source/WebCore/dom/ContainerNodeAlgorithms.h
r117242 r117723 106 106 inline void appendChildToContainer(GenericNode* child, GenericNodeContainer* container) 107 107 { 108 child->setParent (container);108 child->setParentOrHostNode(container); 109 109 110 110 GenericNode* lastChild = container->lastChild(); … … 162 162 n->setPreviousSibling(0); 163 163 n->setNextSibling(0); 164 n->setParent (0);164 n->setParentOrHostNode(0); 165 165 166 166 if (!n->refCount()) { -
trunk/Source/WebCore/dom/ElementShadow.cpp
r117044 r117723 54 54 return true; 55 55 56 if (shadowRoot-> shadowHost()) {56 if (shadowRoot->host()) { 57 57 ec = HIERARCHY_REQUEST_ERR; 58 58 return false; … … 75 75 return; 76 76 77 shadowRoot->set ShadowHost(shadowHost);77 shadowRoot->setHost(shadowHost); 78 78 ChildNodeInsertionNotifier(shadowHost).notify(shadowRoot.get()); 79 79 … … 100 100 oldRoot->detach(); 101 101 102 oldRoot->set ShadowHost(0);102 oldRoot->setHost(0); 103 103 oldRoot->setPrev(0); 104 104 oldRoot->setNext(0); -
trunk/Source/WebCore/dom/EventDispatcher.cpp
r117394 r117723 37 37 #include "MouseEvent.h" 38 38 #include "ScopedEventQueue.h" 39 #include "ShadowRoot.h" 39 40 #include "WindowEventContext.h" 40 41 #include <wtf/RefPtr.h> … … 126 127 // Spec: The event handling for the non-exposed tree works as if the referenced element had been textually included 127 128 // as a deeply cloned child of the 'use' element, except that events are dispatched to the SVGElementInstance objects 128 Element* shadowHostElement = referenceNode->treeScope()->rootNode()->shadowHost();129 Element* shadowHostElement = toShadowRoot(referenceNode->treeScope()->rootNode())->host(); 129 130 // At this time, SVG nodes are not allowed in non-<use> shadow trees, so any shadow root we do 130 131 // have should be a use. The assert and following test is here to catch future shadow DOM changes … … 177 178 } 178 179 179 180 180 void EventDispatcher::adjustRelatedTarget(Event* event, PassRefPtr<EventTarget> prpRelatedTarget) 181 181 { … … 217 217 while (true) { 218 218 if (ancestorWalker.get()->isShadowRoot()) { 219 if (determineDispatchBehavior(event, ancestorWalker.get()) == StayInsideShadowDOM)219 if (determineDispatchBehavior(event, toShadowRoot(ancestorWalker.get())) == StayInsideShadowDOM) 220 220 return; 221 221 ancestorWalker.parentIncludingInsertionPointAndShadowRoot(); … … 348 348 } 349 349 350 EventDispatchBehavior EventDispatcher::determineDispatchBehavior(Event* event, Node* shadowRoot)350 EventDispatchBehavior EventDispatcher::determineDispatchBehavior(Event* event, ShadowRoot* shadowRoot) 351 351 { 352 352 #if ENABLE(FULLSCREEN_API) && ENABLE(VIDEO) … … 356 356 // FIXME: We assume that if the full screen element is a media element that it's 357 357 // the video-only full screen. Both here and elsewhere. But that is probably wrong. 358 if (element->isMediaElement() && shadowRoot && shadowRoot-> shadowHost() == element)358 if (element->isMediaElement() && shadowRoot && shadowRoot->host() == element) 359 359 return StayInsideShadowDOM; 360 360 } -
trunk/Source/WebCore/dom/EventDispatcher.h
r117394 r117723 41 41 class PlatformKeyboardEvent; 42 42 class PlatformMouseEvent; 43 class PlatformWheelEvent;43 class ShadowRoot; 44 44 class TreeScope; 45 45 … … 76 76 EventDispatcher(Node*); 77 77 78 EventDispatchBehavior determineDispatchBehavior(Event*, Node* shadowRoot); 78 EventDispatchBehavior determineDispatchBehavior(Event*, ShadowRoot*); 79 79 80 void ensureEventAncestors(Event*); 80 81 const EventContext* topEventContext(); -
trunk/Source/WebCore/dom/Node.cpp
r117417 r117723 498 498 } 499 499 500 Element* Node::shadowHost() const501 {502 return toElement(isShadowRoot() ? parent() : 0);503 }504 505 void Node::setShadowHost(Element* host)506 {507 ASSERT(!parentNode() && isShadowRoot());508 setParent(host);509 }510 511 500 Node* Node::toNode() 512 501 { … … 1553 1542 1554 1543 if (parent->isShadowRoot()) 1555 return parent->shadowHost();1544 return toShadowRoot(parent)->host(); 1556 1545 1557 1546 if (!parent->isElementNode()) -
trunk/Source/WebCore/dom/Node.h
r117417 r117723 230 230 ContainerNode* parentOrHostNode() const; 231 231 Element* parentOrHostElement() const; 232 void setParentOrHostNode(ContainerNode*); 232 233 Node* highestAncestor() const; 233 234 … … 236 237 // Returns the parent node, but 0 if the parent node is a ShadowRoot. 237 238 ContainerNode* nonShadowBoundaryParentNode() const; 238 239 Element* shadowHost() const;240 void setShadowHost(Element*);241 239 242 240 bool selfOrAncestorHasDirAutoAttribute() const { return getFlag(SelfOrAncestorHasDirAutoFlag); } … … 777 775 // don't follow this rule. 778 776 using TreeShared<ContainerNode>::parent; 777 using TreeShared<ContainerNode>::setParent; 779 778 780 779 void trackForDebugging(); … … 834 833 } 835 834 835 inline void Node::setParentOrHostNode(ContainerNode* parent) 836 { 837 setParent(parent); 838 } 839 836 840 inline ContainerNode* Node::parentOrHostNode() const 837 841 { -
trunk/Source/WebCore/dom/NodeRenderingContext.cpp
r117210 r117723 67 67 if (parent->isShadowRoot() && toShadowRoot(parent)->isYoungest()) { 68 68 m_phase = AttachingShadowChild; 69 m_parentNodeForRenderingAndStyle = parent->shadowHost();69 m_parentNodeForRenderingAndStyle = toShadowRoot(parent)->host(); 70 70 return; 71 71 } -
trunk/Source/WebCore/dom/ShadowRoot.h
r117421 r117723 28 28 #define ShadowRoot_h 29 29 30 #include "ContainerNode.h" 30 31 #include "Document.h" 31 32 #include "DocumentFragment.h" … … 69 70 void setApplyAuthorStyles(bool); 70 71 71 Element* host() const { return shadowHost(); } 72 Element* host() const; 73 void setHost(Element*); 72 74 ElementShadow* owner() const; 73 75 … … 104 106 InsertionPoint* m_insertionPointAssignedTo; 105 107 }; 108 109 inline Element* ShadowRoot::host() const 110 { 111 return toElement(parentOrHostNode()); 112 } 113 114 inline void ShadowRoot::setHost(Element* host) 115 { 116 setParentOrHostNode(host); 117 } 106 118 107 119 inline InsertionPoint* ShadowRoot::assignedTo() const -
trunk/Source/WebCore/dom/TreeScope.cpp
r117420 r117723 40 40 #include "Page.h" 41 41 #include "RuntimeEnabledFeatures.h" 42 #include "ShadowRoot.h" 42 43 #include "TreeScopeAdopter.h" 43 44 #include <wtf/text/AtomicString.h> … … 222 223 223 224 while (treeScope != this && treeScope != document) { 224 node = t reeScope->rootNode()->shadowHost();225 node = toShadowRoot(treeScope->rootNode())->host(); 225 226 treeScope = node->treeScope(); 226 227 } -
trunk/Source/WebCore/html/shadow/ContentSelectorQuery.cpp
r117210 r117723 65 65 return false; 66 66 67 ASSERT(node->parentNode() == m_insertionPoint->shadowRoot()-> shadowHost());67 ASSERT(node->parentNode() == m_insertionPoint->shadowRoot()->host()); 68 68 69 69 if (m_insertionPoint->select().isNull() || m_insertionPoint->select().isEmpty()) -
trunk/Source/WebCore/page/DragController.cpp
r117327 r117723 64 64 #include "SecurityOrigin.h" 65 65 #include "Settings.h" 66 #include "ShadowRoot.h" 66 67 #include "StylePropertySet.h" 67 68 #include "Text.h" … … 277 278 // If this is a button inside of the a file input, move up to the file input. 278 279 if (inputElement && inputElement->isTextButton() && inputElement->treeScope()->rootNode()->isShadowRoot()) 279 inputElement = inputElement->treeScope()->rootNode()->shadowHost()->toInputElement();280 inputElement = toShadowRoot(inputElement->treeScope()->rootNode())->host()->toInputElement(); 280 281 281 282 return inputElement && inputElement->isFileUpload() ? inputElement : 0; -
trunk/Source/WebCore/page/EventHandler.cpp
r117210 r117723 1600 1600 // we'd like to EventHandler::handleMousePressEvent to pass the event to the widget and thus the 1601 1601 // event target node can't still be the shadow node. 1602 if (targetNode(mev)->isShadowRoot() && t argetNode(mev)->shadowHost()->hasTagName(inputTag)) {1602 if (targetNode(mev)->isShadowRoot() && toShadowRoot(targetNode(mev))->host()->hasTagName(inputTag)) { 1603 1603 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active); 1604 1604 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mouseEvent); … … 2093 2093 return 0; 2094 2094 2095 Node* shadowTreeElement = referenceNode->shadowRoot();2096 if (!shadow TreeElement)2095 ShadowRoot* shadowRoot = referenceNode->shadowRoot(); 2096 if (!shadowRoot) 2097 2097 return 0; 2098 2098 2099 Element* shadowTreeParentElement = shadow TreeElement->shadowHost();2099 Element* shadowTreeParentElement = shadowRoot->host(); 2100 2100 if (!shadowTreeParentElement) 2101 2101 return 0; … … 2251 2251 // will set a selection inside it, which will call setFocuseNodeIfNeeded. 2252 2252 ExceptionCode ec = 0; 2253 Node* n = node->isShadowRoot() ? node->shadowHost() : node;2253 Node* n = node->isShadowRoot() ? toShadowRoot(node)->host() : node; 2254 2254 if (m_frame->selection()->isRange() 2255 2255 && m_frame->selection()->toNormalizedRange()->compareNode(n, ec) == Range::NODE_INSIDE -
trunk/Source/WebCore/page/FocusController.cpp
r116798 r117723 111 111 Node* root = rootNode(); 112 112 if (root->isShadowRoot()) 113 return root->shadowHost();113 return toShadowRoot(root)->host(); 114 114 if (Frame* frame = root->document()->frame()) 115 115 return frame->ownerElement(); -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r117659 r117723 59 59 #include "Settings.h" 60 60 #include "SVGTextRunRenderingContext.h" 61 #include "ShadowRoot.h" 61 62 #include "TransformState.h" 62 63 #include <wtf/StdLibExtras.h> … … 5774 5775 return true; 5775 5776 5776 if (node()->isShadowRoot() && (node()->shadowHost()->hasTagName(inputTag)))5777 if (node()->isShadowRoot() && toShadowRoot(node())->host()->hasTagName(inputTag)) 5777 5778 return true; 5778 5779 -
trunk/Source/WebCore/svg/SVGElementInstance.h
r111380 r117723 48 48 49 49 virtual ~SVGElementInstance(); 50 51 void setParentOrHostNode(SVGElementInstance* instance) { setParent(instance); } 50 52 51 53 virtual const AtomicString& interfaceName() const; … … 144 146 private: 145 147 friend class SVGUseElement; 148 using TreeShared<SVGElementInstance>::parent; 149 using TreeShared<SVGElementInstance>::setParent; 146 150 147 151 SVGElementInstance(SVGUseElement*, SVGUseElement*, PassRefPtr<SVGElement> originalElement); -
trunk/Source/WebCore/svg/SVGStyledElement.cpp
r117195 r117723 43 43 #include "SVGSVGElement.h" 44 44 #include "SVGUseElement.h" 45 #include "ShadowRoot.h" 45 46 #include <wtf/Assertions.h> 46 47 #include <wtf/HashMap.h> … … 91 92 // Walk up the tree, to find out whether we're inside a <use> shadow tree, to find the right title. 92 93 if (isInShadowTree()) { 93 Element* shadowHostElement = t reeScope()->rootNode()->shadowHost();94 Element* shadowHostElement = toShadowRoot(treeScope()->rootNode())->host(); 94 95 // At this time, SVG nodes are not allowed in non-<use> shadow trees, so any shadow root we do 95 96 // have should be a use. The assert and following test is here to catch future shadow DOM changes -
trunk/Source/WebCore/svg/SVGTRefElement.cpp
r117242 r117723 143 143 void SVGShadowText::willRecalcTextStyle(StyleChange change) 144 144 { 145 if (change != NoChange && parentNode()-> shadowHost()) {145 if (change != NoChange && parentNode()->isShadowRoot()) { 146 146 if (renderer()) 147 renderer()->setStyle( parentNode()->shadowHost()->renderer()->style());147 renderer()->setStyle(toShadowRoot(parentNode())->host()->renderer()->style()); 148 148 } 149 149 }
Note: See TracChangeset
for help on using the changeset viewer.