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

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: 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/text/whitespace-created-when-siblings-added-back-to-front-expected.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..226ffe39ac00b54926eb6553294b31910776ac45 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
rhogan 2015/11/20 19:33:13 More specifically, when we're doing an .innerHTML=
rhogan 2015/11/20 19:50:25 I knew as soon as I typed it that was daft. This a
+ // 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* firstChild = parent.node() ? LayoutTreeBuilderTraversal::firstChild(*parent.node()) : nullptr;
leviw_travelin_and_unemployed 2015/11/20 21:18:34 Nit: I'd probably call this firstChildNode
+ if (first && first == layoutObject() && firstChild && !firstChild->layoutObject() && firstChild->isTextNode())
leviw_travelin_and_unemployed 2015/11/20 21:18:34 Why are you checking firstChild->isTextNode() here
rhogan 2015/11/21 16:55:42 Right, it doesn't matter does it?
+ return true;
+
// Whitespace at the start of a block just goes away. Don't even
// make a layout object for this text.
return false;
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/text/whitespace-created-when-siblings-added-back-to-front-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698