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

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

Issue 2379483002: Use the sibling limit to decide whether to create layout for whitespace (Closed)
Patch Set: Bring patch to head. Created 4 years, 2 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 | « third_party/WebKit/Source/core/dom/LayoutTreeBuilderTraversal.cpp ('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 be2d847be5126ca138a2ad9e51db4a8f2965841e..2f232f049d775ca332450479b5ec77960cbc16f0 100644
--- a/third_party/WebKit/Source/core/dom/Text.cpp
+++ b/third_party/WebKit/Source/core/dom/Text.cpp
@@ -286,8 +286,13 @@ bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style,
if (document().childNeedsDistributionRecalc())
return true;
+ // Avoiding creation of a layoutObject for the text node is a non-essential memory optimization.
+ // So to avoid blowing up on very wide DOMs, we limit the number of siblings to visit.
+ unsigned maxSiblingsToVisit = 50;
+
const LayoutObject* prev =
- LayoutTreeBuilderTraversal::previousSiblingLayoutObject(*this);
+ LayoutTreeBuilderTraversal::previousSiblingLayoutObject(
+ *this, maxSiblingsToVisit);
if (prev && prev->isBR()) // <span><br/> <br/></span>
return false;
@@ -306,11 +311,13 @@ bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style,
unsigned maxSiblingsToVisit = 50;
Nico 2016/10/06 15:13:45 did you mean to delete this here? (i'll send a cl
kojii 2016/10/07 03:22:54 Looks like a merge failure, PS3 removed this but n
LayoutObject* first = parent.slowFirstChild();
- while (first && first->isFloatingOrOutOfFlowPositioned() &&
- maxSiblingsToVisit--)
- first = first->nextSibling();
+ for (; first && first->isFloatingOrOutOfFlowPositioned() &&
+ maxSiblingsToVisit;
+ first = first->nextSibling(), --maxSiblingsToVisit) {
+ }
if (!first || first == layoutObject() ||
- LayoutTreeBuilderTraversal::nextSiblingLayoutObject(*this) == first) {
+ LayoutTreeBuilderTraversal::nextSiblingLayoutObject(
+ *this, maxSiblingsToVisit) == 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.
« no previous file with comments | « third_party/WebKit/Source/core/dom/LayoutTreeBuilderTraversal.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698