| Index: Source/core/dom/Text.cpp
|
| diff --git a/Source/core/dom/Text.cpp b/Source/core/dom/Text.cpp
|
| index b1eda88c9f801fe8428a1c31aac2059d95dec355..cbe43473484023544e5c5095819cd984c78a5cf2 100644
|
| --- a/Source/core/dom/Text.cpp
|
| +++ b/Source/core/dom/Text.cpp
|
| @@ -245,25 +245,25 @@
|
| LayoutObject* child = parent.slowFirstChild();
|
| if (!child || !child->isAnonymous())
|
| return false;
|
| - if (child->isTableCell())
|
| - return true;
|
| + if (child->isTableCell()) {
|
| + LayoutObject* firstChild = child->slowFirstChild();
|
| + // Ignore the anonymous table cell if it is wrapping a table cell element (e.g. because of <td style="display:block;">).
|
| + return !firstChild || !firstChild->node() || !isHTMLTableCellElement(firstChild->node());
|
| + }
|
| if (child->isTableSection() || child->isTableRow())
|
| return hasGeneratedAnonymousTableCells(*child);
|
| return false;
|
| }
|
|
|
| -static inline bool nodeAllowsAdjacentWhitespace(Node* node)
|
| -{
|
| - if (!node)
|
| - return true;
|
| - const ComputedStyle* style = node->ensureComputedStyle();
|
| - return style && style->originalDisplay() != TABLE_CELL && !isHTMLTableCellElement(node);
|
| -}
|
| -
|
| -static inline bool canHaveWhitespaceChildren(const LayoutObject& parent, Text* text)
|
| +static inline bool canHaveWhitespaceChildren(const LayoutObject& parent)
|
| {
|
| // <button> should allow whitespace even though LayoutFlexibleBox doesn't.
|
| if (parent.isLayoutButton())
|
| + return true;
|
| +
|
| + // 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 true;
|
|
|
| if (parent.isTable() || parent.isTableRow() || parent.isTableSection()
|
| @@ -272,13 +272,8 @@
|
| || parent.isSVGRoot()
|
| || parent.isSVGContainer()
|
| || parent.isSVGImage()
|
| - || 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;
|
| - }
|
| + || parent.isSVGShape())
|
| + return false;
|
| return true;
|
| }
|
|
|
| @@ -299,7 +294,7 @@
|
| if (!containsOnlyWhitespace())
|
| return true;
|
|
|
| - if (!canHaveWhitespaceChildren(parent, this))
|
| + if (!canHaveWhitespaceChildren(parent))
|
| return false;
|
|
|
| // pre-wrap in SVG never makes layoutObject.
|
|
|