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

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

Issue 2680463003: Remove branch on childNeedsDistributionRecalc (Closed)
Patch Set: rune nit: Fix typo in the comment Created 3 years, 10 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/LayoutTests/shadow-dom/crashes/character-data-set-data-crash.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 04845a1644e032a15a674bbc13771da76953f6ad..1e87792813ed10ae22ece3343ba8fafb276c9143 100644
--- a/third_party/WebKit/Source/core/dom/Text.cpp
+++ b/third_party/WebKit/Source/core/dom/Text.cpp
@@ -254,6 +254,8 @@ static inline bool canHaveWhitespaceChildren(const LayoutObject& parent) {
bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style,
const LayoutObject& parent) const {
+ DCHECK(!document().childNeedsDistributionRecalc());
+
if (!parent.canHaveChildren())
return false;
@@ -280,11 +282,6 @@ bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style,
if (style.preserveNewline())
return true;
- // childNeedsDistributionRecalc() here is rare, only happens JS calling
- // surroundContents() etc. from DOMNodeInsertedIntoDocument etc.
- 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.
@@ -423,9 +420,14 @@ static bool shouldUpdateLayoutByReattaching(const Text& textNode,
DCHECK_EQ(textNode.layoutObject(), textLayoutObject);
if (!textLayoutObject)
return true;
- if (!textNode.textLayoutObjectIsNeeded(*textLayoutObject->style(),
- *textLayoutObject->parent()))
+ // In general we do not want to branch on lifecycle states such as
+ // |childNeedsDistributionRecalc|, but this code tries to figure out if we can
+ // use an optimized code path that avoids reattach.
+ if (!textNode.document().childNeedsDistributionRecalc() &&
+ !textNode.textLayoutObjectIsNeeded(*textLayoutObject->style(),
+ *textLayoutObject->parent())) {
return true;
+ }
if (textLayoutObject->isTextFragment()) {
// Changes of |textNode| may change first letter part, so we should
// reattach.
« no previous file with comments | « third_party/WebKit/LayoutTests/shadow-dom/crashes/character-data-set-data-crash.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698