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

Unified Diff: third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp

Issue 1909343003: TextIteratorAlgorithm should not force layout update in constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
Index: third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
index a924e23eeae7b3b45b5b30e696e29ed528362a02..4b6aece17b33f3da1816d7ca5bedd72e5678b862 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
@@ -146,9 +146,13 @@ TextIteratorAlgorithm<Strategy>::TextIteratorAlgorithm(const PositionTemplate<St
{
DCHECK(start.isNotNull());
DCHECK(end.isNotNull());
- // Updates layout here since, |Position.compareTo()| and |initialize()|
- // assume layout tree is up-to-date.
- start.document()->updateLayoutIgnorePendingStylesheets();
+
+
+ // TODO(dglazkov): TextIterator should not be created for documents that don't have a frame,
+ // but it currently still happens in some cases. See http://crbug.com/591877 for details.
+ DCHECK(!start.document()->view() || !start.document()->view()->needsLayout());
+ DCHECK(!start.document()->needsLayoutTreeUpdate());
+
if (start.compareTo(end) > 0) {
initialize(end.computeContainerNode(), end.computeOffsetInContainerNode(), start.computeContainerNode(), start.computeOffsetInContainerNode());
return;
@@ -1091,6 +1095,10 @@ PositionTemplate<Strategy> TextIteratorAlgorithm<Strategy>::endPositionInCurrent
template<typename Strategy>
int TextIteratorAlgorithm<Strategy>::rangeLength(const PositionTemplate<Strategy>& start, const PositionTemplate<Strategy>& end, bool forSelectionPreservation)
{
+ // TODO(dglazkov): The use of updateLayoutIgnorePendingStylesheets needs to be audited.
+ // see http://crbug.com/590369 for more details.
+ start.document()->updateLayoutIgnorePendingStylesheets();
+
int length = 0;
TextIteratorBehaviorFlags behaviorFlags = TextIteratorEmitsObjectReplacementCharacter;
if (forSelectionPreservation)
@@ -1145,6 +1153,11 @@ static String createPlainText(const EphemeralRangeTemplate<Strategy>& range, Tex
if (range.isNull())
return emptyString();
+
+ // TODO(dglazkov): The use of updateLayoutIgnorePendingStylesheets needs to be audited.
+ // see http://crbug.com/590369 for more details.
+ range.startPosition().document()->updateLayoutIgnorePendingStylesheets();
+
TextIteratorAlgorithm<Strategy> it(range.startPosition(), range.endPosition(), behavior);
if (it.atEnd())

Powered by Google App Engine
This is Rietveld 408576698