| Index: third_party/WebKit/Source/core/dom/Text.cpp
|
| diff --git a/third_party/WebKit/Source/core/dom/Text.cpp b/third_party/WebKit/Source/core/dom/Text.cpp
|
| index 04845a1644e032a15a674bbc13771da76953f6ad..1e87792813ed10ae22ece3343ba8fafb276c9143 100644
|
| --- a/third_party/WebKit/Source/core/dom/Text.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/Text.cpp
|
| @@ -254,6 +254,8 @@ static inline bool canHaveWhitespaceChildren(const LayoutObject& parent) {
|
|
|
| bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style,
|
| const LayoutObject& parent) const {
|
| + DCHECK(!document().childNeedsDistributionRecalc());
|
| +
|
| if (!parent.canHaveChildren())
|
| return false;
|
|
|
| @@ -280,11 +282,6 @@ bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style,
|
| if (style.preserveNewline())
|
| return true;
|
|
|
| - // childNeedsDistributionRecalc() here is rare, only happens JS calling
|
| - // surroundContents() etc. from DOMNodeInsertedIntoDocument etc.
|
| - if (document().childNeedsDistributionRecalc())
|
| - return true;
|
| -
|
| // Avoiding creation of a layoutObject for the text node is a non-essential
|
| // memory optimization. So to avoid blowing up on very wide DOMs, we limit
|
| // the number of siblings to visit.
|
| @@ -423,9 +420,14 @@ static bool shouldUpdateLayoutByReattaching(const Text& textNode,
|
| DCHECK_EQ(textNode.layoutObject(), textLayoutObject);
|
| if (!textLayoutObject)
|
| return true;
|
| - if (!textNode.textLayoutObjectIsNeeded(*textLayoutObject->style(),
|
| - *textLayoutObject->parent()))
|
| + // In general we do not want to branch on lifecycle states such as
|
| + // |childNeedsDistributionRecalc|, but this code tries to figure out if we can
|
| + // use an optimized code path that avoids reattach.
|
| + if (!textNode.document().childNeedsDistributionRecalc() &&
|
| + !textNode.textLayoutObjectIsNeeded(*textLayoutObject->style(),
|
| + *textLayoutObject->parent())) {
|
| return true;
|
| + }
|
| if (textLayoutObject->isTextFragment()) {
|
| // Changes of |textNode| may change first letter part, so we should
|
| // reattach.
|
|
|