Chromium Code Reviews| 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 f69b8552c899c41d59a2d26db83f4be95856723f..e34a38417bc776002d59c866bc88a719fc19265f 100644 |
| --- a/third_party/WebKit/Source/core/dom/Text.cpp |
| +++ b/third_party/WebKit/Source/core/dom/Text.cpp |
| @@ -252,6 +252,11 @@ static inline bool canHaveWhitespaceChildren(const LayoutObject& parent) { |
| return true; |
| } |
| +static inline bool emptyOrEndsWithWhitespace(const WTF::String& string) { |
| + unsigned len = string.length(); |
| + return !len || isASCIISpace(string[len - 1]); |
| +} |
| + |
| bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style, |
| const LayoutObject& parent) const { |
| DCHECK(!document().childNeedsDistributionRecalc()); |
| @@ -290,9 +295,21 @@ bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style, |
| const LayoutObject* prev = |
| LayoutTreeBuilderTraversal::previousSiblingLayoutObject( |
| *this, maxSiblingsToVisit); |
| + |
| + while (prev && prev->isOutOfFlowPositioned() && --maxSiblingsToVisit) |
| + prev = prev->previousSibling(); |
| + |
| + if (!maxSiblingsToVisit) |
| + return true; |
| + |
| if (prev && prev->isBR()) // <span><br/> <br/></span> |
| return false; |
| + // Collapse whitespace away. |
| + if (prev && prev->isText() && |
| + emptyOrEndsWithWhitespace(toLayoutText(prev)->text())) |
| + return false; |
| + |
| if (parent.isLayoutInline()) { |
| // <span><div/> <div/></span> |
| if (prev && !prev->isInline() && !prev->isOutOfFlowPositioned()) |
|
rune
2017/02/28 09:59:46
prev cannot be out-of-flow at this point since pre
|