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

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

Issue 2274183003: Force expandEnd/RangeToSentenceBoundary to return a valid EphemeralRange (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/SpellChecker.cpp
diff --git a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
index 05d972bdb04912e73c99c2ba3d4bf4f502aa48c6..fda3d8289bfbf7a2b9e8d79c052c995c42fe76a2 100644
--- a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
+++ b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
@@ -99,10 +99,10 @@ static EphemeralRange expandEndToSentenceBoundary(const EphemeralRange& range)
const VisiblePosition& visibleEnd = createVisiblePosition(range.endPosition());
DCHECK(visibleEnd.isNotNull());
const Position& sentenceEnd = endOfSentence(visibleEnd).deepEquivalent();
- // TODO(xiaochengh): |sentenceEnd < range.startPosition()| seems possible,
- // which would trigger a DCHECK in EphemeralRange's constructor. Need more
- // investigation, and if that is really the case, fix it.
- return EphemeralRange(range.startPosition(), sentenceEnd.isNotNull() ? sentenceEnd : range.endPosition());
+ // TODO(xiaochengh): |sentenceEnd < range.endPosition()| is possible,
+ // which would trigger a DCHECK in EphemeralRange's constructor if we return
+ // it directly. However, this shouldn't happen and needs to be fixed.
+ return EphemeralRange(range.startPosition(), sentenceEnd.isNotNull() && sentenceEnd > range.endPosition() ? sentenceEnd : range.endPosition());
}
static EphemeralRange expandRangeToSentenceBoundary(const EphemeralRange& range)
@@ -111,10 +111,10 @@ static EphemeralRange expandRangeToSentenceBoundary(const EphemeralRange& range)
const VisiblePosition& visibleStart = createVisiblePosition(range.startPosition());
DCHECK(visibleStart.isNotNull());
const Position& sentenceStart = startOfSentence(visibleStart).deepEquivalent();
- const VisiblePosition& visibleEnd = createVisiblePosition(range.endPosition());
- DCHECK(visibleStart.isNotNull());
- const Position& sentenceEnd = endOfSentence(visibleEnd).deepEquivalent();
- return EphemeralRange(sentenceStart.isNull() ? range.startPosition() : sentenceStart, sentenceEnd.isNull() ? range.endPosition() : sentenceEnd);
+ // TODO(xiaochengh): |sentenceStart > range.startPosition()| is possible,
+ // which would trigger a DCHECK in EphemeralRange's constructor if we return
+ // it directly. However, this shouldn't happen and needs to be fixed.
+ return expandEndToSentenceBoundary(EphemeralRange(sentenceStart.isNotNull() && sentenceStart < range.startPosition() ? sentenceStart : range.startPosition(), range.endPosition()));
}
} // namespace
« 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