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

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

Issue 1461773002: Ensure text nodes get an object if we're unsure that they will be collapsed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 5 years, 1 month 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
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 0ee207e66957876b84cb5180c3794fa65e837715..0efb8cb95186d32a05251a509e1e21f271f4e922 100644
--- a/third_party/WebKit/Source/core/dom/Text.cpp
+++ b/third_party/WebKit/Source/core/dom/Text.cpp
@@ -307,6 +307,12 @@ bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style, const LayoutObje
while (first && first->isFloatingOrOutOfFlowPositioned() && maxSiblingsToVisit--)
first = first->nextSibling();
if (!first || first == layoutObject() || LayoutTreeBuilderTraversal::nextSiblingLayoutObject(*this) == first) {
+ // If we're adding children to this flow our previous siblings are not in the layout tree yet so we
+ // cannot know if we will be the first child in the line and collapse away. We have to assume we need a layout object.
+ Node* firstChildNode = parent.node() ? LayoutTreeBuilderTraversal::firstChild(*parent.node()) : nullptr;
esprehn 2015/12/03 07:03:32 this doesn't work if your parent is anonymous, are
rhogan 2015/12/03 19:45:32 Right enough, I hadn't thought of that but in the
+ if (first && first == layoutObject() && firstChildNode && !firstChildNode->layoutObject())
esprehn 2015/12/03 07:03:32 This is saying "if we're the first in flow layout
rhogan 2015/12/03 19:45:32 Sure, and in that situation we would create a text
+ return true;
+
// Whitespace at the start of a block just goes away. Don't even
// make a layout object for this text.
return false;

Powered by Google App Engine
This is Rietveld 408576698