Chromium Code Reviews| Index: Source/core/dom/Text.cpp |
| diff --git a/Source/core/dom/Text.cpp b/Source/core/dom/Text.cpp |
| index ad796131d66ab9fb16c928cb0bfd4b6c74a6595b..92db5c2ab6d0bcc6ad625ade778ba9770d2b67f0 100644 |
| --- a/Source/core/dom/Text.cpp |
| +++ b/Source/core/dom/Text.cpp |
| @@ -274,7 +274,7 @@ bool Text::textRendererIsNeeded(const RenderStyle& style, const RenderObject& pa |
| unsigned maxSiblingsToVisit = 50; |
| RenderObject* first = parent.slowFirstChild(); |
| - while (first && first->isFloatingOrOutOfFlowPositioned() && maxSiblingsToVisit--) |
| + while (first && (first == renderer() || first->isFloatingOrOutOfFlowPositioned()) && maxSiblingsToVisit--) |
|
leviw_travelin_and_unemployed
2014/11/05 19:23:15
You still want to store renderer() in a local vari
Xianzhu
2014/11/05 20:15:33
Moved first==renderer() out of the loop into the f
|
| first = first->nextSibling(); |
| if (!first || NodeRenderingTraversal::nextSiblingRenderer(this) == first) |
| // Whitespace at the start of a block just goes away. Don't even |
| @@ -308,6 +308,26 @@ void Text::attach(const AttachContext& context) |
| CharacterData::attach(context); |
| } |
| +void Text::reattachIfNeeded(const AttachContext& context) |
| +{ |
| + RenderTreeBuilderForText treeBuilder(this); |
| + bool hadRenderer = !!renderer(); |
|
leviw_travelin_and_unemployed
2014/11/05 19:23:15
You shouldn't need the !! when assigning into a bo
Xianzhu
2014/11/05 20:15:33
Done.
|
| + bool rendererIsNeeded = treeBuilder.rendererIsNeeded(); |
| + if (rendererIsNeeded == hadRenderer) |
| + return; |
| + |
| + // The following is almost the same as Node::attach() except that we create renderer only if needed. |
| + // Not calling reattach() to avoid repeated calls to Text::textRendererIsNeeded(). |
| + AttachContext reattachContext(context); |
| + reattachContext.performingReattach = true; |
| + |
| + if (styleChangeType() < NeedsReattachStyleChange) |
| + detach(reattachContext); |
| + if (rendererIsNeeded) |
| + treeBuilder.createRenderer(); |
| + CharacterData::attach(reattachContext); |
| +} |
| + |
| void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) |
| { |
| if (RenderText* renderer = this->renderer()) { |
| @@ -319,7 +339,7 @@ void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) |
| } else if (needsStyleRecalc() || needsWhitespaceRenderer()) { |
| reattach(); |
| if (this->renderer()) |
| - reattachWhitespaceSiblings(nextTextSibling); |
| + reattachWhitespaceSiblingsIfNeeded(nextTextSibling); |
| } |
| } |