| Index: Source/core/dom/Text.cpp
|
| diff --git a/Source/core/dom/Text.cpp b/Source/core/dom/Text.cpp
|
| index 71ce46fafe31b261b867f458704327e75b04cf5b..ebf787adbfae94595a2cc94387cf321c8cd5901b 100644
|
| --- a/Source/core/dom/Text.cpp
|
| +++ b/Source/core/dom/Text.cpp
|
| @@ -251,15 +251,18 @@ static inline bool hasGeneratedAnonymousTableCells(const LayoutObject& parent)
|
| return false;
|
| }
|
|
|
| -static inline bool canHaveWhitespaceChildren(const LayoutObject& parent)
|
| +static inline bool nodeAllowsAdjacentWhitespace(Node* node)
|
| {
|
| - // <button> should allow whitespace even though LayoutFlexibleBox doesn't.
|
| - if (parent.isLayoutButton())
|
| + if (!node)
|
| return true;
|
| + const ComputedStyle* style = node->ensureComputedStyle();
|
| + return style && style->originalDisplay() != TABLE_CELL && !isHTMLTableCellElement(node);
|
| +}
|
|
|
| - // Allow whitespace when the text is inside a table, section or row element that
|
| - // has generated anonymous table cells to hold its contents.
|
| - if (hasGeneratedAnonymousTableCells(parent))
|
| +static inline bool canHaveWhitespaceChildren(const LayoutObject& parent, Text* text)
|
| +{
|
| + // <button> should allow whitespace even though LayoutFlexibleBox doesn't.
|
| + if (parent.isLayoutButton())
|
| return true;
|
|
|
| if (parent.isTable() || parent.isTableRow() || parent.isTableSection()
|
| @@ -268,8 +271,13 @@ static inline bool canHaveWhitespaceChildren(const LayoutObject& parent)
|
| || parent.isSVGRoot()
|
| || parent.isSVGContainer()
|
| || parent.isSVGImage()
|
| - || parent.isSVGShape())
|
| + || parent.isSVGShape()) {
|
| + // Allow whitespace when the text is inside a table, section or row element that
|
| + // has generated anonymous table cells to hold its contents.
|
| + if (hasGeneratedAnonymousTableCells(parent))
|
| + return nodeAllowsAdjacentWhitespace(text->previousSibling()) && nodeAllowsAdjacentWhitespace(text->nextSibling());
|
| return false;
|
| + }
|
| return true;
|
| }
|
|
|
| @@ -290,7 +298,7 @@ bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style, const LayoutObje
|
| if (!containsOnlyWhitespace())
|
| return true;
|
|
|
| - if (!canHaveWhitespaceChildren(parent))
|
| + if (!canHaveWhitespaceChildren(parent, this))
|
| return false;
|
|
|
| // pre-wrap in SVG never makes layoutObject.
|
|
|