Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(576)

Unified Diff: Source/core/dom/Text.cpp

Issue 1280123004: Don't allow whitespace between elements with display:table-cell (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/platform/linux/tables/mozilla/bugs/bug2479-1-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Text.cpp
diff --git a/Source/core/dom/Text.cpp b/Source/core/dom/Text.cpp
index cbe43473484023544e5c5095819cd984c78a5cf2..b1eda88c9f801fe8428a1c31aac2059d95dec355 100644
--- a/Source/core/dom/Text.cpp
+++ b/Source/core/dom/Text.cpp
@@ -245,25 +245,25 @@ 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 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()
@@ -272,8 +272,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;
}
@@ -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.
« no previous file with comments | « LayoutTests/platform/linux/tables/mozilla/bugs/bug2479-1-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698