Index: Source/core/dom/Text.cpp |
diff --git a/Source/core/dom/Text.cpp b/Source/core/dom/Text.cpp |
index cbe43473484023544e5c5095819cd984c78a5cf2..52a37467f969b129e2d9dcec8d54709c92ec3ee5 100644 |
--- a/Source/core/dom/Text.cpp |
+++ b/Source/core/dom/Text.cpp |
@@ -245,17 +245,22 @@ static inline bool hasGeneratedAnonymousTableCells(const LayoutObject& parent) |
LayoutObject* child = parent.slowFirstChild(); |
if (!child || !child->isAnonymous()) |
return false; |
- 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->isTableCell()) |
+ return true; |
if (child->isTableSection() || child->isTableRow()) |
return hasGeneratedAnonymousTableCells(*child); |
return false; |
} |
-static inline bool canHaveWhitespaceChildren(const LayoutObject& parent) |
+static inline bool nodeAllowsWhitespace(Node* node) |
mstensho (USE GERRIT)
2015/08/26 18:45:56
How about nodeAllowsAdjacentWhitespace() or someth
|
+{ |
+ if (!node) |
+ return true; |
+ const ComputedStyle* style = node->ensureComputedStyle(); |
+ return style && style->originalDisplay() != TABLE_CELL && !isHTMLTableCellElement(node); |
+} |
+ |
+static inline bool canHaveWhitespaceChildren(const LayoutObject& parent, Node* node) |
mstensho (USE GERRIT)
2015/08/26 18:45:56
|node| should be of type Text* (and probably be na
|
{ |
// <button> should allow whitespace even though LayoutFlexibleBox doesn't. |
if (parent.isLayoutButton()) |
@@ -264,7 +269,7 @@ static inline bool canHaveWhitespaceChildren(const LayoutObject& parent) |
// 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)) |
mstensho (USE GERRIT)
2015/08/26 18:45:56
Can we move this block inside the "if (parent.isTa
|
- return true; |
+ return nodeAllowsWhitespace(node->previousSibling()) && nodeAllowsWhitespace(node->nextSibling()); |
if (parent.isTable() || parent.isTableRow() || parent.isTableSection() |
|| parent.isLayoutTableCol() || parent.isFrameSet() |
@@ -294,7 +299,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. |