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

Unified Diff: third_party/WebKit/Source/core/editing/spellcheck/TextCheckingParagraph.cpp

Issue 2271603002: Force expandToParagraphBoundary to return a valid EphemeralRange (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use position comparison Created 4 years, 4 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 | « no previous file | 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/editing/spellcheck/TextCheckingParagraph.cpp
diff --git a/third_party/WebKit/Source/core/editing/spellcheck/TextCheckingParagraph.cpp b/third_party/WebKit/Source/core/editing/spellcheck/TextCheckingParagraph.cpp
index a2825b04f562f3900a4e90cc0bf4222c3ab219ca..e011035f8cb15deb26915b7fdd3e659f82ec6f2c 100644
--- a/third_party/WebKit/Source/core/editing/spellcheck/TextCheckingParagraph.cpp
+++ b/third_party/WebKit/Source/core/editing/spellcheck/TextCheckingParagraph.cpp
@@ -37,15 +37,22 @@ static EphemeralRange expandToParagraphBoundary(const EphemeralRange& range)
{
const VisiblePosition& start = createVisiblePosition(range.startPosition());
DCHECK(start.isNotNull()) << range.startPosition();
- const VisiblePosition& paragraphStart = startOfParagraph(start);
+ const Position& paragraphStart = startOfParagraph(start).deepEquivalent();
DCHECK(paragraphStart.isNotNull()) << range.startPosition();
const VisiblePosition& end = createVisiblePosition(range.endPosition());
DCHECK(end.isNotNull()) << range.endPosition();
- const VisiblePosition& paragraphEnd = endOfParagraph(end);
+ const Position& paragraphEnd = endOfParagraph(end).deepEquivalent();
DCHECK(paragraphEnd.isNotNull()) << range.endPosition();
- return EphemeralRange(paragraphStart.deepEquivalent(), paragraphEnd.deepEquivalent());
+ // TODO(xiaochengh): There are some cases (crbug.com/640112) where we get
+ // |paragraphStart > paragraphEnd|, which is the reason we cannot directly
+ // return |EphemeralRange(paragraphStart, paragraphEnd)|. This is not
+ // desired, though. We should do more investigation to ensure that why
+ // |paragraphStart <= paragraphEnd| is violated.
+ const Position& resultStart = paragraphStart.isNotNull() && paragraphStart <= range.startPosition() ? paragraphStart : range.startPosition();
+ const Position& resultEnd = paragraphEnd.isNotNull() && paragraphEnd >= range.endPosition() ? paragraphEnd : range.endPosition();
+ return EphemeralRange(resultStart, resultEnd);
}
TextCheckingParagraph::TextCheckingParagraph(const EphemeralRange& checkingRange)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698