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

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

Issue 2273253002: Cleanup overloads of isSpellCheckingEnabledFor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@RestrictTextCheckingParagraph
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 | « third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.h ('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/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 135f97f4f7ab0c056a7b45e42005641a81b4f4f5..05d972bdb04912e73c99c2ba3d4bf4f502aa48c6 100644
--- a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
+++ b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
@@ -76,6 +76,23 @@ bool isSelectionInTextFormControl(const VisibleSelection& selection)
return !!enclosingTextFormControl(selection.start());
}
+static bool isSpellCheckingEnabledFor(const VisibleSelection& selection)
+{
+ if (selection.isNone())
+ return false;
+ // TODO(tkent): The following password type check should be done in
+ // HTMLElement::spellcheck(). crbug.com/371567
+ if (HTMLTextFormControlElement* textControl = enclosingTextFormControl(selection.start())) {
+ if (isHTMLInputElement(textControl) && toHTMLInputElement(textControl)->type() == InputTypeNames::password)
+ return false;
+ }
+ if (HTMLElement* element = Traversal<HTMLElement>::firstAncestorOrSelf(*selection.start().anchorNode())) {
+ if (element->isSpellCheckingEnabled())
+ return true;
+ }
+ return false;
+}
+
static EphemeralRange expandEndToSentenceBoundary(const EphemeralRange& range)
{
DCHECK(range.isNotNull());
@@ -298,7 +315,7 @@ void SpellChecker::clearMisspellingsAndBadGrammar(const VisibleSelection &moving
void SpellChecker::markMisspellingsAndBadGrammar(const VisibleSelection& selection)
{
- if (!isSpellCheckingEnabled())
+ if (!isSpellCheckingEnabled() || !isSpellCheckingEnabledFor(selection))
return;
const EphemeralRange& range = selection.toNormalizedEphemeralRange();
@@ -310,9 +327,6 @@ void SpellChecker::markMisspellingsAndBadGrammar(const VisibleSelection& selecti
if (!editableNode || !hasEditableStyle(*editableNode))
return;
- if (!isSpellCheckingEnabledFor(editableNode))
- return;
-
chunkAndMarkAllMisspellingsAndBadGrammar(range);
}
@@ -386,38 +400,17 @@ void SpellChecker::markMisspellingsAfterTypingToWord(const VisiblePosition &word
markMisspellingsAndBadGrammar(adjacentWords);
}
-bool SpellChecker::isSpellCheckingEnabledFor(const Node* node) const
+bool SpellChecker::isSpellCheckingEnabledInFocusedNode() const
{
- if (!node)
+ Node* focusedNode = frame().selection().start().anchorNode();
+ if (!focusedNode)
return false;
- const Element* focusedElement = node->isElementNode() ? toElement(node) : node->parentElement();
+ const Element* focusedElement = focusedNode->isElementNode() ? toElement(focusedNode) : focusedNode->parentElement();
if (!focusedElement)
return false;
return focusedElement->isSpellCheckingEnabled();
}
-bool SpellChecker::isSpellCheckingEnabledInFocusedNode() const
-{
- return isSpellCheckingEnabledFor(frame().selection().start().anchorNode());
-}
-
-bool SpellChecker::isSpellCheckingEnabledFor(const VisibleSelection& selection)
-{
- if (selection.isNone())
- return false;
- // TODO(tkent): The following password type check should be done in
- // HTMLElement::spellcheck(). crbug.com/371567
- if (HTMLTextFormControlElement* textControl = enclosingTextFormControl(selection.start())) {
- if (isHTMLInputElement(textControl) && toHTMLInputElement(textControl)->type() == InputTypeNames::password)
- return false;
- }
- if (HTMLElement* element = Traversal<HTMLElement>::firstAncestorOrSelf(*selection.start().anchorNode())) {
- if (element->spellcheck())
- return true;
- }
- return false;
-}
-
void SpellChecker::markMisspellingsAfterReplaceSelectionCommand(const ReplaceSelectionCommand& cmd)
{
TRACE_EVENT0("blink", "SpellChecker::markMisspellingsAfterReplaceSelectionCommand");
@@ -830,7 +823,7 @@ void SpellChecker::cancelCheck()
void SpellChecker::requestTextChecking(const Element& element)
{
- if (!isSpellCheckingEnabledFor(&element))
+ if (!element.isSpellCheckingEnabled())
return;
const EphemeralRange rangeToCheck = EphemeralRange::rangeOfContents(element);
m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextCheckingProcessBatch, rangeToCheck));
« no previous file with comments | « third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698