Changeset 109203 in webkit
- Timestamp:
- Feb 29, 2012 12:07:16 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r109200 r109203 1 2012-02-28 MORITA Hajime <morrita@google.com> 2 3 [Refactoring] Shadow related attach paths should be in ShadowTree. 4 https://bugs.webkit.org/show_bug.cgi?id=79854 5 6 Reviewed by Ryosuke Niwa. 7 8 No new tests. No behavior change. 9 10 This change introduces ShadowTree::attachHost() and ShadowTree::detachHost() 11 and moves shadow-enabled attachment code from Element to ShadowRoot. 12 This also factored out small ContainerNode method to use it from ShadowTree. 13 14 Even after this change, the traveral order in ShadowTree 15 attachment has some unclear part. Coming changes will clarify 16 these. This change is aimed to be purely textural. 17 18 * dom/ContainerNode.cpp: 19 (WebCore::ContainerNode::attach): 20 (WebCore::ContainerNode::detach): 21 * dom/ContainerNode.h: 22 (ContainerNode): 23 (WebCore::ContainerNode::attachAsNode): Added. 24 (WebCore::ContainerNode::attachChildren): Added. 25 (WebCore::ContainerNode::attachChildrenIfNeeded): Added. 26 (WebCore::ContainerNode::attachChildrenLazily): Added. 27 (WebCore::ContainerNode::detachAsNode): Added. 28 (WebCore::ContainerNode::detachChildrenIfNeeded): Added. 29 (WebCore::ContainerNode::detachChildren): Added. 30 * dom/Element.cpp: 31 (WebCore::Element::attach): 32 (WebCore::Element::detach): 33 * dom/ShadowTree.cpp: 34 (WebCore::ShadowTree::addShadowRoot): 35 (WebCore::ShadowTree::removeAllShadowRoots): 36 (WebCore::ShadowTree::detachHost): 37 (WebCore): 38 (WebCore::ShadowTree::attachHost): 39 (WebCore::ShadowTree::reattachHostChildrenAndShadow): 40 * dom/ShadowTree.h: 41 (ShadowTree): 42 1 43 2012-02-28 Arko Saha <arko@motorola.com> 2 44 -
trunk/Source/WebCore/dom/ContainerNode.cpp
r109054 r109203 767 767 void ContainerNode::attach() 768 768 { 769 for (Node* child = m_firstChild; child; child = child->nextSibling()) 770 child->attach(); 769 attachChildren(); 771 770 Node::attach(); 772 771 } … … 774 773 void ContainerNode::detach() 775 774 { 776 for (Node* child = m_firstChild; child; child = child->nextSibling()) 777 child->detach(); 775 detachChildren(); 778 776 clearChildNeedsStyleRecalc(); 779 777 Node::detach(); -
trunk/Source/WebCore/dom/ContainerNode.h
r109026 r109203 95 95 virtual void childrenChanged(bool createdByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); 96 96 97 void attachAsNode(); 98 void attachChildren(); 99 void attachChildrenIfNeeded(); 100 void attachChildrenLazily(); 101 void detachAsNode(); 102 void detachChildren(); 103 void detachChildrenIfNeeded(); 104 97 105 protected: 98 106 ContainerNode(Document*, ConstructionType = CreateContainer); … … 147 155 } 148 156 157 inline void ContainerNode::attachAsNode() 158 { 159 Node::attach(); 160 } 161 162 inline void ContainerNode::attachChildren() 163 { 164 for (Node* child = firstChild(); child; child = child->nextSibling()) 165 child->attach(); 166 } 167 168 inline void ContainerNode::attachChildrenIfNeeded() 169 { 170 for (Node* child = firstChild(); child; child = child->nextSibling()) { 171 if (!child->attached()) 172 child->attach(); 173 } 174 } 175 176 inline void ContainerNode::attachChildrenLazily() 177 { 178 for (Node* child = firstChild(); child; child = child->nextSibling()) 179 if (!child->attached()) 180 child->lazyAttach(); 181 } 182 183 inline void ContainerNode::detachAsNode() 184 { 185 Node::detach(); 186 } 187 188 inline void ContainerNode::detachChildrenIfNeeded() 189 { 190 for (Node* child = firstChild(); child; child = child->nextSibling()) { 191 if (child->attached()) 192 child->detach(); 193 } 194 } 195 196 inline void ContainerNode::detachChildren() 197 { 198 for (Node* child = firstChild(); child; child = child->nextSibling()) 199 child->detach(); 200 } 201 149 202 inline unsigned Node::childNodeCount() const 150 203 { -
trunk/Source/WebCore/dom/Element.cpp
r109134 r109203 929 929 930 930 // When a shadow root exists, it does the work of attaching the children. 931 if ( hasShadowRoot()) {931 if (ShadowTree* tree = shadowTree()) { 932 932 parentPusher.push(); 933 shadowTree()->attach(); 934 935 // In a shadow tree, some of light children may be attached by <content> or <shadow>. 936 // However, when there is no content element or content element does not select 937 // all light children, we have to attach the rest of light children here. 938 for (Node* child = firstChild(); child; child = child->nextSibling()) { 939 if (!child->attached()) 940 child->attach(); 941 } 942 Node::attach(); 933 tree->attachHost(this); 943 934 } else { 944 935 if (firstChild()) … … 968 959 rareData()->resetComputedStyle(); 969 960 970 if (hasShadowRoot()) { 971 for (Node* child = firstChild(); child; child = child->nextSibling()) { 972 if (child->attached()) 973 child->detach(); 974 } 975 976 shadowTree()->detach(); 977 Node::detach(); 978 } else 961 if (ShadowTree* tree = shadowTree()) 962 tree->detachHost(this); 963 else 979 964 ContainerNode::detach(); 980 981 965 982 966 RenderWidget::resumeWidgetHierarchyUpdates(); -
trunk/Source/WebCore/dom/ShadowTree.cpp
r109096 r109203 87 87 shadowRoot->lazyAttach(); 88 88 detach(); 89 for (Node* child = shadowHost->firstChild(); child; child = child->nextSibling()) 90 child->detach(); 89 shadowHost->detachChildren(); 91 90 } 92 91 … … 119 118 } 120 119 121 if (shadowHost->attached()) { 122 for (Node* child = shadowHost->firstChild(); child; child = child->nextSibling()) { 123 if (!child->attached()) 124 child->lazyAttach(); 125 } 126 } 120 if (shadowHost->attached()) 121 shadowHost->attachChildrenLazily(); 127 122 } 128 123 … … 172 167 } 173 168 169 void ShadowTree::attachHost(Element* host) 170 { 171 attach(); 172 host->attachChildrenIfNeeded(); 173 host->attachAsNode(); 174 } 175 176 174 177 void ShadowTree::detach() 175 178 { … … 178 181 root->detach(); 179 182 } 183 } 184 185 void ShadowTree::detachHost(Element* host) 186 { 187 host->detachChildrenIfNeeded(); 188 detach(); 189 host->detachAsNode(); 180 190 } 181 191 … … 270 280 ASSERT(youngestShadowRoot()); 271 281 272 Node* hostNode = youngestShadowRoot()->host(); 273 if (!hostNode) 274 return; 275 276 for (Node* child = hostNode->firstChild(); child; child = child->nextSibling()) { 277 if (child->attached()) 278 child->detach(); 279 } 280 282 Element* hostNode = youngestShadowRoot()->host(); 283 hostNode->detachChildrenIfNeeded(); 281 284 reattach(); 282 283 for (Node* child = hostNode->firstChild(); child; child = child->nextSibling()) { 284 if (!child->attached()) 285 child->attach(); 286 } 285 hostNode->attachChildrenIfNeeded(); 287 286 } 288 287 -
trunk/Source/WebCore/dom/ShadowTree.h
r109084 r109203 63 63 void detach(); 64 64 void reattach(); 65 void attachHost(Element*); 66 void detachHost(Element*); 65 67 66 68 bool childNeedsStyleRecalc();
Note: See TracChangeset
for help on using the changeset viewer.