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

Unified Diff: third_party/WebKit/Source/core/testing/Internals.cpp

Issue 2457523003: Support 'insertReplacementText' for spellcheck (Closed)
Patch Set: dtapuska's comment addressed Created 4 years, 1 month 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/testing/Internals.cpp
diff --git a/third_party/WebKit/Source/core/testing/Internals.cpp b/third_party/WebKit/Source/core/testing/Internals.cpp
index 1dd34866f725d64668bf7815fc52753f20e36e10..e6b24584e8b8a0b0d735f0d811f83e0936a3e520 100644
--- a/third_party/WebKit/Source/core/testing/Internals.cpp
+++ b/third_party/WebKit/Source/core/testing/Internals.cpp
@@ -1795,25 +1795,66 @@ StaticNodeList* Internals::nodesFromRect(Document* document,
return StaticNodeList::adopt(matches);
}
-bool Internals::hasSpellingMarker(Document* document, int from, int length) {
- ASSERT(document);
- if (!document->frame())
+void Internals::setSpellingMarker(Document* document,
yosin_UTC9 2016/11/10 01:49:52 It is better that |setSepllingMarker| to take |Ran
Xiaocheng 2016/11/10 02:35:53 Agreed. In fact, that would help us a lot by simpl
yosin_UTC9 2016/11/10 03:25:46 As usual, it is better to have another patch conta
+ ExceptionState& exceptionState) {
+ if (!document || !document->frame()) {
+ exceptionState.throwDOMException(
+ InvalidAccessError,
+ "No frame can be obtained from the provided document.");
+ return;
+ }
+
+ document->updateStyleAndLayoutIgnorePendingStylesheets();
+ EphemeralRange range =
+ document->frame()->selection().selection().toNormalizedEphemeralRange();
+ document->markers().addMarker(range.startPosition(), range.endPosition(),
+ DocumentMarker::Spelling);
+}
+
+bool Internals::hasSpellingMarker(Document* document,
+ int from,
+ int length,
+ ExceptionState& exceptionState) {
+ if (!document || !document->frame()) {
+ exceptionState.throwDOMException(
+ InvalidAccessError,
+ "No frame can be obtained from the provided document.");
return false;
+ }
document->updateStyleAndLayoutIgnorePendingStylesheets();
return document->frame()->spellChecker().selectionStartHasMarkerFor(
DocumentMarker::Spelling, from, length);
}
-void Internals::setSpellCheckingEnabled(bool enabled) {
- if (!contextDocument() || !contextDocument()->frame())
+void Internals::setSpellCheckingEnabled(bool enabled,
+ ExceptionState& exceptionState) {
+ if (!contextDocument() || !contextDocument()->frame()) {
+ exceptionState.throwDOMException(
+ InvalidAccessError,
+ "No frame can be obtained from the provided document.");
return;
+ }
if (enabled !=
contextDocument()->frame()->spellChecker().isSpellCheckingEnabled())
contextDocument()->frame()->spellChecker().toggleSpellCheckingEnabled();
}
+void Internals::replaceMisspelled(Document* document,
+ const String& replacement,
+ ExceptionState& exceptionState) {
+ if (!document || !document->frame()) {
+ exceptionState.throwDOMException(
+ InvalidAccessError,
+ "No frame can be obtained from the provided document.");
+ return;
+ }
+
+ document->updateStyleAndLayoutIgnorePendingStylesheets();
+ document->frame()->spellChecker().replaceMisspelledRange(replacement);
+}
+
bool Internals::canHyphenate(const AtomicString& locale) {
return LayoutLocale::valueOrDefault(LayoutLocale::get(locale))
.getHyphenation();
@@ -1851,10 +1892,16 @@ String Internals::dumpRefCountedInstanceCounts() const {
return WTF::dumpRefCountedInstanceCounts();
}
-bool Internals::hasGrammarMarker(Document* document, int from, int length) {
- ASSERT(document);
- if (!document->frame())
+bool Internals::hasGrammarMarker(Document* document,
+ int from,
+ int length,
+ ExceptionState& exceptionState) {
+ if (!document || !document->frame()) {
+ exceptionState.throwDOMException(
+ InvalidAccessError,
+ "No frame can be obtained from the provided document.");
return false;
+ }
document->updateStyleAndLayoutIgnorePendingStylesheets();
return document->frame()->spellChecker().selectionStartHasMarkerFor(

Powered by Google App Engine
This is Rietveld 408576698