Changeset 154746 in webkit
- Timestamp:
- Aug 28, 2013, 7:41:12 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
style/StyleResolveTree.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r154745 r154746 1 2013-08-28 Antti Koivisto <antti@apple.com> 2 3 Share attach loops between Elements and ShadowRoots 4 https://bugs.webkit.org/show_bug.cgi?id=120414 5 6 Reviewed Andreas Kling. 7 8 * style/StyleResolveTree.cpp: 9 (WebCore::Style::attachChildren): 10 (WebCore::Style::attachShadowRoot): 11 (WebCore::Style::detachChildren): 12 (WebCore::Style::detachShadowRoot): 13 1 14 2013-08-28 Anders Carlsson <andersca@apple.com> 2 15 -
trunk/Source/WebCore/style/StyleResolveTree.cpp
r154738 r154746 288 288 } 289 289 290 291 static void attachShadowRoot(ShadowRoot* shadowRoot, const AttachContext& context)292 {293 if (shadowRoot->attached())294 return;295 StyleResolver& styleResolver = shadowRoot->document()->ensureStyleResolver();296 styleResolver.pushParentShadowRoot(shadowRoot);297 298 Style::AttachContext childrenContext(context);299 childrenContext.resolvedStyle = 0;300 for (Node* child = shadowRoot->firstChild(); child; child = child->nextSibling()) {301 if (child->isTextNode()) {302 attachTextRenderer(*toText(child));303 continue;304 }305 if (child->isElementNode())306 attachRenderTree(toElement(child), childrenContext);307 }308 styleResolver.popParentShadowRoot(shadowRoot);309 310 shadowRoot->clearNeedsStyleRecalc();311 shadowRoot->setAttached(true);312 }313 314 290 #ifndef NDEBUG 315 static bool childAttachedAllowedWhenAttachingChildren(ContainerNode *node)316 { 317 if (node ->isShadowRoot())291 static bool childAttachedAllowedWhenAttachingChildren(ContainerNode& node) 292 { 293 if (node.isShadowRoot()) 318 294 return true; 319 if (node ->isInsertionPoint())295 if (node.isInsertionPoint()) 320 296 return true; 321 if (node ->isElementNode() && toElement(node)->shadowRoot())297 if (node.isElementNode() && toElement(&node)->shadowRoot()) 322 298 return true; 323 299 return false; … … 325 301 #endif 326 302 327 static void attachChildren( Element*current, const AttachContext& context)303 static void attachChildren(ContainerNode& current, const AttachContext& context) 328 304 { 329 305 AttachContext childrenContext(context); 330 306 childrenContext.resolvedStyle = 0; 331 307 332 for (Node* child = current ->firstChild(); child; child = child->nextSibling()) {308 for (Node* child = current.firstChild(); child; child = child->nextSibling()) { 333 309 ASSERT(!child->attached() || childAttachedAllowedWhenAttachingChildren(current)); 334 310 if (child->attached()) … … 343 319 } 344 320 321 static void attachShadowRoot(ShadowRoot& shadowRoot, const AttachContext& context) 322 { 323 if (shadowRoot.attached()) 324 return; 325 StyleResolver& styleResolver = shadowRoot.document()->ensureStyleResolver(); 326 styleResolver.pushParentShadowRoot(&shadowRoot); 327 328 attachChildren(shadowRoot, context); 329 330 styleResolver.popParentShadowRoot(&shadowRoot); 331 332 shadowRoot.clearNeedsStyleRecalc(); 333 shadowRoot.setAttached(true); 334 } 335 345 336 void attachRenderTree(Element* current, const AttachContext& context) 346 337 { … … 363 354 if (ShadowRoot* shadowRoot = current->shadowRoot()) { 364 355 parentPusher.push(); 365 attachShadowRoot( shadowRoot, context);356 attachShadowRoot(*shadowRoot, context); 366 357 } else if (current->firstChild()) 367 358 parentPusher.push(); 368 359 369 attachChildren( current, context);360 attachChildren(*current, context); 370 361 371 362 Node* sibling = current->nextSibling(); … … 389 380 } 390 381 391 static void detachShadowRoot(ShadowRoot* shadowRoot, const AttachContext& context) 392 { 393 if (!shadowRoot->attached()) 394 return; 395 Style::AttachContext childrenContext(context); 382 static void detachChildren(ContainerNode& current, const AttachContext& context) 383 { 384 AttachContext childrenContext(context); 396 385 childrenContext.resolvedStyle = 0; 397 for (Node* child = shadowRoot->firstChild(); child; child = child->nextSibling()) { 386 387 for (Node* child = current.firstChild(); child; child = child->nextSibling()) { 398 388 if (child->isTextNode()) { 399 389 Style::detachTextRenderer(*toText(child)); … … 401 391 } 402 392 if (child->isElementNode()) 403 detachRenderTree(toElement(child), context);404 }405 shadowRoot->clearChildNeedsStyleRecalc();406 shadowRoot->setAttached(false);407 }408 409 static void detachChildren(Element* current, const AttachContext& context)410 {411 AttachContext childrenContext(context);412 childrenContext.resolvedStyle = 0;413 414 for (Node* child = current->firstChild(); child; child = child->nextSibling()) {415 if (child->isTextNode()) {416 Style::detachTextRenderer(*toText(child));417 continue;418 }419 if (child->isElementNode())420 393 detachRenderTree(toElement(child), childrenContext); 421 394 } 422 current->clearChildNeedsStyleRecalc(); 395 current.clearChildNeedsStyleRecalc(); 396 } 397 398 static void detachShadowRoot(ShadowRoot& shadowRoot, const AttachContext& context) 399 { 400 if (!shadowRoot.attached()) 401 return; 402 detachChildren(shadowRoot, context); 403 404 shadowRoot.setAttached(false); 423 405 } 424 406 … … 438 420 439 421 if (ShadowRoot* shadowRoot = current->shadowRoot()) 440 detachShadowRoot( shadowRoot, context);441 442 detachChildren( current, context);422 detachShadowRoot(*shadowRoot, context); 423 424 detachChildren(*current, context); 443 425 444 426 if (current->renderer())
Note:
See TracChangeset
for help on using the changeset viewer.