Changeset 166173 in webkit
- Timestamp:
- Mar 24, 2014, 9:49:39 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/Source/WebCore/ChangeLog ¶
r166172 r166173 1 2014-03-24 Antti Koivisto <antti@apple.com> 2 3 Invalidate sibling text node style when needed instead of attaching synchronously 4 https://bugs.webkit.org/show_bug.cgi?id=130590 5 6 Reviewed by Andreas Kling. 7 8 Make things simpler. 9 10 * style/StyleResolveTree.cpp: 11 (WebCore::Style::invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded): 12 13 Just invalidate instead of calling attach directly. 14 Rename to match. 15 16 (WebCore::Style::textRendererIsNeeded): 17 (WebCore::Style::createTextRendererIfNeeded): 18 19 Move all testing to textRendererIsNeeded. 20 21 (WebCore::Style::updateTextRendererAfterContentChange): 22 23 Call resolveTextNode instead of re-implementing the same thing. 24 25 (WebCore::Style::resolveLocal): 26 (WebCore::Style::resolveTextNode): 27 28 Avoid unnecessary reattaching. 29 Rename for consistency. 30 31 (WebCore::Style::resolveShadowTree): 32 (WebCore::Style::resolveTree): 33 1 34 2014-03-24 Zsolt Borbely <zsborbely.u-szeged@partner.samsung.com> 2 35 -
TabularUnified trunk/Source/WebCore/style/StyleResolveTree.cpp ¶
r166144 r166173 65 65 static void attachTextRenderer(Text&, ContainerNode& renderingParentNode); 66 66 static void detachRenderTree(Element&, DetachType); 67 static void resolveTextNode(Text&, ContainerNode& renderingParentNode); 67 68 static void resolveTree(Element&, ContainerNode& renderingParentNode, Change); 68 69 … … 295 296 } 296 297 297 static void reattachTextRenderersForWhitespaceOnlySiblingsAfterAttachIfNeeded(Node& current, ContainerNode& renderingParentNode)298 static void invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(Node& current) 298 299 { 299 300 if (isInsertionPoint(current)) … … 302 303 // the current node gaining or losing the renderer. This can only affect white space text nodes. 303 304 for (Node* sibling = current.nextSibling(); sibling; sibling = sibling->nextSibling()) { 304 // Siblings haven't been attached yet. They will be handled normally when they are. 305 if (sibling->styleChangeType() == ReconstructRenderTree) 305 if (sibling->needsStyleRecalc()) 306 306 return; 307 307 if (sibling->isElementNode()) { … … 313 313 if (!sibling->isTextNode()) 314 314 continue; 315 Text& textSibling = *toText(sibling); 316 if (!textSibling.length() || !textSibling.containsOnlyWhitespace()) 317 return; 318 Text& whitespaceTextSibling = textSibling; 319 bool hadRenderer = whitespaceTextSibling.renderer(); 320 detachTextRenderer(whitespaceTextSibling); 321 attachTextRenderer(whitespaceTextSibling, renderingParentNode); 322 // No changes, futher renderers can't be affected. 323 if (hadRenderer == !!whitespaceTextSibling.renderer()) 324 return; 325 } 326 } 327 328 static bool textRendererIsNeeded(const Text& textNode, const RenderObject& parentRenderer, const RenderStyle& style) 329 { 315 Text& textSibling = toText(*sibling); 316 if (!textSibling.containsOnlyWhitespace()) 317 continue; 318 textSibling.setNeedsStyleRecalc(); 319 } 320 } 321 322 static bool textRendererIsNeeded(const Text& textNode, ContainerNode& renderingParentNode) 323 { 324 if (!renderingParentNode.renderer()) 325 return false; 326 RenderElement& parentRenderer = *renderingParentNode.renderer(); 327 if (!parentRenderer.canHaveChildren()) 328 return false; 329 if (!renderingParentNode.childShouldCreateRenderer(textNode)) 330 return false; 331 330 332 if (textNode.isEditingText()) 331 333 return true; 332 334 if (!textNode.length()) 333 335 return false; 334 if ( style.display() == NONE)336 if (parentRenderer.style().display() == NONE) 335 337 return false; 336 338 if (!textNode.containsOnlyWhitespace()) … … 339 341 if (parentRenderer.isTable() || parentRenderer.isTableRow() || parentRenderer.isTableSection() || parentRenderer.isRenderTableCol() || parentRenderer.isFrameSet()) 340 342 return false; 341 if ( style.preserveNewline()) // pre/pre-wrap/pre-line always make renderers.343 if (parentRenderer.style().preserveNewline()) // pre/pre-wrap/pre-line always make renderers. 342 344 return true; 343 345 … … 354 356 return false; 355 357 356 RenderObject* first = toRenderElement(parentRenderer).firstChild();358 RenderObject* first = parentRenderer.firstChild(); 357 359 while (first && first->isFloatingOrOutOfFlowPositioned()) 358 360 first = first->nextSibling(); … … 370 372 ASSERT(!textNode.renderer()); 371 373 372 RenderElement* parentRenderer = renderingParentNode.renderer(); 373 if (!parentRenderer || !parentRenderer->canHaveChildren()) 374 return; 375 if (!renderingParentNode.childShouldCreateRenderer(textNode)) 376 return; 377 378 const auto& style = parentRenderer->style(); 379 380 if (!textRendererIsNeeded(textNode, *parentRenderer, style)) 381 return; 374 if (!textRendererIsNeeded(textNode, renderingParentNode)) 375 return; 376 RenderElement& parentRenderer = *renderingParentNode.renderer(); 377 const auto& style = parentRenderer.style(); 382 378 383 379 auto newRenderer = textNode.createTextRenderer(style); 384 380 ASSERT(newRenderer); 385 381 386 if (!parentRenderer ->isChildAllowed(*newRenderer, style))382 if (!parentRenderer.isChildAllowed(*newRenderer, style)) 387 383 return; 388 384 389 385 // Make sure the RenderObject already knows it is going to be added to a RenderFlowThread before we set the style 390 386 // for the first time. Otherwise code using inRenderFlowThread() in the styleWillChange and styleDidChange will fail. 391 newRenderer->setFlowThreadState(parentRenderer ->flowThreadState());387 newRenderer->setFlowThreadState(parentRenderer.flowThreadState()); 392 388 393 389 RenderObject* nextRenderer = nextSiblingRenderer(textNode, renderingParentNode); 394 390 textNode.setRenderer(newRenderer.get()); 395 391 // Parent takes care of the animations, no need to call setAnimatableStyle. 396 parentRenderer ->addChild(newRenderer.leakPtr(), nextRenderer);392 parentRenderer.addChild(newRenderer.leakPtr(), nextRenderer); 397 393 } 398 394 … … 413 409 void updateTextRendererAfterContentChange(Text& textNode, unsigned offsetOfReplacedData, unsigned lengthOfReplacedData) 414 410 { 415 RenderText* textRenderer = textNode.renderer();416 411 ContainerNode* renderingParentNode = NodeRenderingTraversal::parent(&textNode); 417 412 if (!renderingParentNode) 418 413 return; 419 if (!textRenderer) { 420 attachTextRenderer(textNode, *renderingParentNode); 421 reattachTextRenderersForWhitespaceOnlySiblingsAfterAttachIfNeeded(textNode, *renderingParentNode); 422 return; 423 } 424 if (!textRendererIsNeeded(textNode, *renderingParentNode->renderer(), textRenderer->style())) { 425 detachTextRenderer(textNode); 426 attachTextRenderer(textNode, *renderingParentNode); 427 reattachTextRenderersForWhitespaceOnlySiblingsAfterAttachIfNeeded(textNode, *renderingParentNode); 428 return; 429 } 430 textRenderer->setTextWithOffset(textNode.dataImpl(), offsetOfReplacedData, lengthOfReplacedData); 414 415 bool hadRenderer = textNode.renderer(); 416 resolveTextNode(textNode, *renderingParentNode); 417 418 if (hadRenderer && textNode.renderer()) 419 textNode.renderer()->setTextWithOffset(textNode.dataImpl(), offsetOfReplacedData, lengthOfReplacedData); 431 420 } 432 421 … … 679 668 detachRenderTree(current, ReattachDetach); 680 669 attachRenderTree(current, renderingParentNode, newStyle.release()); 681 reattachTextRenderersForWhitespaceOnlySiblingsAfterAttachIfNeeded(current, renderingParentNode);670 invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(current); 682 671 683 672 return Detach; … … 710 699 } 711 700 712 static void updateTextStyle(Text& text, ContainerNode& renderingParentNode) 713 { 714 RenderText* renderer = text.renderer(); 715 716 if (!text.needsStyleRecalc()) 717 return; 718 if (renderer) 719 renderer->setText(text.dataImpl()); 720 else { 721 attachTextRenderer(text, renderingParentNode); 722 reattachTextRenderersForWhitespaceOnlySiblingsAfterAttachIfNeeded(text, renderingParentNode); 723 } 701 void resolveTextNode(Text& text, ContainerNode& renderingParentNode) 702 { 724 703 text.clearNeedsStyleRecalc(); 704 705 bool hasRenderer = text.renderer(); 706 bool needsRenderer = textRendererIsNeeded(text, renderingParentNode); 707 if (hasRenderer) { 708 if (needsRenderer) 709 return; 710 detachTextRenderer(text); 711 invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(text); 712 return; 713 } 714 if (!needsRenderer) 715 return; 716 attachTextRenderer(text, renderingParentNode); 717 invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(text); 725 718 } 726 719 … … 728 721 { 729 722 for (Node* child = shadowRoot.firstChild(); child; child = child->nextSibling()) { 730 if (child->isTextNode() ) {731 updateTextStyle(*toText(child), *shadowRoot.hostElement());723 if (child->isTextNode() && child->needsStyleRecalc()) { 724 resolveTextNode(*toText(child), *shadowRoot.hostElement()); 732 725 continue; 733 726 } … … 845 838 bool forceCheckOfAnyElementSibling = false; 846 839 for (Node* child = current.firstChild(); child; child = child->nextSibling()) { 847 if (child->isTextNode() ) {848 updateTextStyle(*toText(child), current);840 if (child->isTextNode() && child->needsStyleRecalc()) { 841 resolveTextNode(*toText(child), current); 849 842 continue; 850 843 }
Note:
See TracChangeset
for help on using the changeset viewer.