Changeset 84225 in webkit
- Timestamp:
- Apr 18, 2011 10:44:15 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r84224 r84225 1 2011-04-18 Dominic Cooney <dominicc@chromium.org> 2 3 Reviewed by Dimitri Glazkov. 4 5 Makes SVG shadow roots and DOM shadow roots distinct. 6 https://bugs.webkit.org/show_bug.cgi?id=52788 7 8 Not a functional change. Covered by existing SVG tests. 9 10 * dom/EventDispatcher.cpp: 11 (WebCore::findElementInstance): 12 (WebCore::EventDispatcher::adjustToShadowBoundaries): 13 (WebCore::EventDispatcher::adjustRelatedTarget): 14 (WebCore::EventDispatcher::ensureEventAncestors): 15 * dom/Node.cpp: 16 (WebCore::Node::setShadowHost): 17 (WebCore::Node::svgShadowHost): 18 (WebCore::Node::shadowTreeRootNode): 19 * dom/Node.h: 20 (WebCore::Node::isSVGShadowRoot): 21 (WebCore::Node::parentNode): 22 (WebCore::Node::parentNodeGuaranteedHostFree): 23 * rendering/svg/RenderSVGShadowTreeRootContainer.cpp: 24 (WebCore::RenderSVGShadowTreeRootContainer::~RenderSVGShadowTreeRootContainer): 25 (WebCore::RenderSVGShadowTreeRootContainer::updateFromElement): 26 * rendering/svg/SVGShadowTreeElements.cpp: 27 (WebCore::SVGShadowTreeRootElement::SVGShadowTreeRootElement): 28 (WebCore::SVGShadowTreeRootElement::create): 29 (WebCore::SVGShadowTreeRootElement::attachElement): 30 (WebCore::SVGShadowTreeRootElement::clearSVGShadowHost): 31 * rendering/svg/SVGShadowTreeElements.h: 32 (WebCore::SVGShadowTreeRootElement::isSVGShadowRoot): 33 * svg/SVGStyledElement.cpp: 34 (WebCore::SVGStyledElement::title): 35 1 36 2011-04-18 Taiju TSUIKI <develop@tzik.jp> 2 37 -
trunk/Source/WebCore/dom/EventDispatcher.cpp
r83386 r84225 66 66 // as a deeply cloned child of the 'use' element, except that events are dispatched to the SVGElementInstance objects 67 67 for (Node* n = referenceNode; n; n = n->parentNode()) { 68 if (!n->isS hadowRoot() || !n->isSVGElement())68 if (!n->isSVGShadowRoot() || !n->isSVGElement()) 69 69 continue; 70 70 71 Element* shadowTreeParentElement = n->s hadowHost();71 Element* shadowTreeParentElement = n->svgShadowHost(); 72 72 ASSERT(shadowTreeParentElement->hasTagName(SVGNames::useTag)); 73 73 … … 123 123 } 124 124 125 static inline bool isShadowRootOrSVGShadowRoot(const Node* node) 126 { 127 return node->isShadowRoot() || node->isSVGShadowRoot(); 128 } 129 125 130 PassRefPtr<EventTarget> EventDispatcher::adjustToShadowBoundaries(PassRefPtr<Node> relatedTarget, const Vector<Node*> relatedTargetAncestors) 126 131 { … … 134 139 for (Vector<Node*>::const_iterator i = relatedTargetAncestors.end() - 1; i >= relatedTargetAncestors.begin(); --i) { 135 140 if (diverged) { 136 if ( (*i)->isShadowRoot()) {141 if (isShadowRootOrSVGShadowRoot(*i)) { 137 142 firstDivergentBoundary = i + 1; 138 143 break; … … 148 153 targetAncestor--; 149 154 150 if ( (*i)->isShadowRoot())155 if (isShadowRootOrSVGShadowRoot(*i)) 151 156 lowestCommonBoundary = targetAncestor; 152 157 … … 157 162 if (!diverged) { 158 163 // The relatedTarget is a parent or shadowHost of the target. 159 if ( m_node->isShadowRoot())164 if (isShadowRootOrSVGShadowRoot(m_node.get())) 160 165 lowestCommonBoundary = m_ancestors.begin(); 161 166 } else if ((*firstDivergentBoundary) == m_node.get()) { … … 204 209 Node* outermostShadowBoundary = relatedTarget.get(); 205 210 for (Node* n = outermostShadowBoundary; n; n = n->parentOrHostNode()) { 206 if ( n->isShadowRoot())211 if (isShadowRootOrSVGShadowRoot(n)) 207 212 outermostShadowBoundary = n->parentOrHostNode(); 208 213 if (!noCommonBoundary) … … 241 246 bool shouldSkipNextAncestor = false; 242 247 while (true) { 243 if (ancestor->isShadowRoot()) { 248 bool isSVGShadowRoot = ancestor->isSVGShadowRoot(); 249 if (isSVGShadowRoot || ancestor->isShadowRoot()) { 244 250 if (behavior == StayInsideShadowDOM) 245 251 return; 246 ancestor = ancestor->shadowHost();252 ancestor = isSVGShadowRoot ? ancestor->svgShadowHost() : ancestor->shadowHost(); 247 253 if (!shouldSkipNextAncestor) 248 254 target = ancestor; … … 255 261 #if ENABLE(SVG) 256 262 // Skip SVGShadowTreeRootElement. 257 shouldSkipNextAncestor = ancestor->isSVG Element() && ancestor->isShadowRoot();263 shouldSkipNextAncestor = ancestor->isSVGShadowRoot(); 258 264 if (shouldSkipNextAncestor) 259 265 continue; -
trunk/Source/WebCore/dom/Node.cpp
r84050 r84225 549 549 void Node::setShadowHost(Element* host) 550 550 { 551 ASSERT(!parentNode() );551 ASSERT(!parentNode() && !isSVGShadowRoot()); 552 552 if (host) 553 553 setFlag(IsShadowRootFlag); … … 1603 1603 } 1604 1604 1605 #if ENABLE(SVG) 1606 SVGUseElement* Node::svgShadowHost() const 1607 { 1608 return isSVGShadowRoot() ? static_cast<SVGUseElement*>(parent()) : 0; 1609 } 1610 #endif 1611 1605 1612 Node* Node::shadowAncestorNode() 1606 1613 { … … 1624 1631 Node* root = this; 1625 1632 while (root) { 1626 if (root->isShadowRoot() )1633 if (root->isShadowRoot() || root->isSVGShadowRoot()) 1627 1634 return root; 1628 1635 root = root->parentNodeGuaranteedHostFree(); -
trunk/Source/WebCore/dom/Node.h
r84050 r84225 72 72 class RenderObject; 73 73 class RenderStyle; 74 #if ENABLE(SVG) 75 class SVGUseElement; 76 #endif 74 77 class TagNodeList; 75 78 class TreeScope; … … 192 195 193 196 bool isSVGElement() const { return getFlag(IsSVGFlag); } 197 virtual bool isSVGShadowRoot() const { return false; } 198 #if ENABLE(SVG) 199 SVGUseElement* svgShadowHost() const; 200 #endif 194 201 195 202 #if ENABLE(WML) … … 214 221 Node* shadowTreeRootNode(); 215 222 bool isInShadowTree(); 216 // Node's parent or shadow tree host.223 // Node's parent, shadow tree host, or SVG use. 217 224 ContainerNode* parentOrHostNode() const; 218 // Use when it's guaranteed to that shadowHost is 0 .225 // Use when it's guaranteed to that shadowHost is 0 and svgShadowHost is 0. 219 226 ContainerNode* parentNodeGuaranteedHostFree() const; 220 227 … … 734 741 inline ContainerNode* Node::parentNode() const 735 742 { 736 return getFlag(IsShadowRootFlag) ? 0 : parent();743 return getFlag(IsShadowRootFlag) || isSVGShadowRoot() ? 0 : parent(); 737 744 } 738 745 … … 744 751 inline ContainerNode* Node::parentNodeGuaranteedHostFree() const 745 752 { 746 ASSERT(!getFlag(IsShadowRootFlag) );753 ASSERT(!getFlag(IsShadowRootFlag) && !isSVGShadowRoot()); 747 754 return parentOrHostNode(); 748 755 } -
trunk/Source/WebCore/rendering/svg/RenderSVGShadowTreeRootContainer.cpp
r75350 r84225 39 39 if (m_shadowRoot && m_shadowRoot->attached()) { 40 40 m_shadowRoot->detach(); 41 m_shadowRoot->clearS hadowHost();41 m_shadowRoot->clearSVGShadowHost(); 42 42 } 43 43 } … … 60 60 } 61 61 62 ASSERT(m_shadowRoot->s hadowHost() == useElement);62 ASSERT(m_shadowRoot->svgShadowHost() == useElement); 63 63 64 64 bool shouldRecreateTree = m_recreateTree; -
trunk/Source/WebCore/rendering/svg/SVGShadowTreeElements.cpp
r82242 r84225 54 54 // SVGShadowTreeRootElement 55 55 56 inline SVGShadowTreeRootElement::SVGShadowTreeRootElement(Document* document, SVGUseElement* shadowParent)56 inline SVGShadowTreeRootElement::SVGShadowTreeRootElement(Document* document, SVGUseElement* host) 57 57 : SVGShadowTreeContainerElement(document) 58 58 { 59 set ShadowHost(shadowParent);59 setParent(host); 60 60 setInDocument(); 61 61 } 62 62 63 PassRefPtr<SVGShadowTreeRootElement> SVGShadowTreeRootElement::create(Document* document, SVGUseElement* shadowParent)63 PassRefPtr<SVGShadowTreeRootElement> SVGShadowTreeRootElement::create(Document* document, SVGUseElement* host) 64 64 { 65 return adoptRef(new SVGShadowTreeRootElement(document, shadowParent));65 return adoptRef(new SVGShadowTreeRootElement(document, host)); 66 66 } 67 67 68 68 void SVGShadowTreeRootElement::attachElement(PassRefPtr<RenderStyle> style, RenderArena* arena) 69 69 { 70 ASSERT(s hadowHost());70 ASSERT(svgShadowHost()); 71 71 72 72 // Create the renderer with the specified style … … 82 82 // Add the renderer to the render tree 83 83 if (renderer) 84 s hadowHost()->renderer()->addChild(renderer);84 svgShadowHost()->renderer()->addChild(renderer); 85 85 } 86 86 87 void SVGShadowTreeRootElement::clearS hadowHost()87 void SVGShadowTreeRootElement::clearSVGShadowHost() 88 88 { 89 set ShadowHost(0);89 setParent(0); 90 90 } 91 91 -
trunk/Source/WebCore/rendering/svg/SVGShadowTreeElements.h
r82242 r84225 54 54 class SVGShadowTreeRootElement : public SVGShadowTreeContainerElement { 55 55 public: 56 static PassRefPtr<SVGShadowTreeRootElement> create(Document*, SVGUseElement* shadowParent);56 static PassRefPtr<SVGShadowTreeRootElement> create(Document*, SVGUseElement* host); 57 57 58 58 void attachElement(PassRefPtr<RenderStyle>, RenderArena*); 59 void clearShadowHost(); 59 void clearSVGShadowHost(); 60 61 virtual bool isSVGShadowRoot() const { return true; } 60 62 61 63 private: 62 SVGShadowTreeRootElement(Document*, SVGUseElement* shadowParent);64 SVGShadowTreeRootElement(Document*, SVGUseElement* host); 63 65 }; 64 66 -
trunk/Source/WebCore/svg/SVGStyledElement.cpp
r78543 r84225 82 82 Node* parent = const_cast<SVGStyledElement*>(this); 83 83 while (parent) { 84 if (!parent->isS hadowRoot()) {84 if (!parent->isSVGShadowRoot()) { 85 85 parent = parent->parentNodeGuaranteedHostFree(); 86 86 continue; … … 88 88 89 89 // Get the <use> element. 90 Element* shadowParent = parent->s hadowHost();90 Element* shadowParent = parent->svgShadowHost(); 91 91 if (shadowParent && shadowParent->isSVGElement() && shadowParent->hasTagName(SVGNames::useTag)) { 92 92 SVGUseElement* useElement = static_cast<SVGUseElement*>(shadowParent);
Note: See TracChangeset
for help on using the changeset viewer.