Chromium Code Reviews| Index: Source/core/editing/Editor.cpp |
| diff --git a/Source/core/editing/Editor.cpp b/Source/core/editing/Editor.cpp |
| index 9bbc1f14ce565e3967f4f96271cb57016a02d0d6..1fea8536fc7ad22cd8fd8e60de939b8bd791018b 100644 |
| --- a/Source/core/editing/Editor.cpp |
| +++ b/Source/core/editing/Editor.cpp |
| @@ -62,6 +62,7 @@ |
| #include "core/editing/htmlediting.h" |
| #include "core/editing/markup.h" |
| #include "core/html/HTMLImageElement.h" |
| +#include "core/html/HTMLInputElement.h" |
| #include "core/html/HTMLTextAreaElement.h" |
| #include "core/loader/cache/ResourceFetcher.h" |
| #include "core/page/EditorClient.h" |
| @@ -87,6 +88,16 @@ using namespace HTMLNames; |
| using namespace WTF; |
| using namespace Unicode; |
| +namespace { |
| + |
| +bool isSelectionInTextField(const VisibleSelection& selection) |
| +{ |
| + HTMLTextFormControlElement* textControl = enclosingTextFormControl(selection.start()); |
| + return textControl && textControl->hasTagName(inputTag) && toHTMLInputElement(textControl)->isTextField(); |
| +} |
| + |
| +} // namespace |
| + |
| // When an event handler has moved the selection outside of a text control |
| // we should use the target control's selection for this editing operation. |
| VisibleSelection Editor::selectionForCommand(Event* event) |
| @@ -2075,8 +2086,30 @@ void Editor::computeAndSetTypingStyle(StylePropertySet* style, EditAction editin |
| m_frame->selection()->setTypingStyle(typingStyle); |
| } |
| + |
| +void Editor::textFieldDidBeginEditing(Element* e) |
| +{ |
| + if (isContinuousSpellCheckingEnabled()) { |
| + Element* element = toHTMLTextFormControlElement(e)->innerTextElement(); |
| + VisibleSelection selection = VisibleSelection::selectionFromContentsOfNode(element); |
| + markMisspellingsAndBadGrammar(selection); |
| + } |
| +} |
| + |
| void Editor::textFieldDidEndEditing(Element* e) |
| { |
| + // Remove markers when deactivating a selection in an <input type="text"/>. |
| + // Prevent new ones from appearing too. |
| + m_spellChecker->cancelProcessingRequest(); |
| + HTMLTextFormControlElement* textFormControlElement = toHTMLTextFormControlElement(e); |
| + HTMLElement* innerText = textFormControlElement->innerTextElement(); |
| + DocumentMarker::MarkerTypes markerTypes(DocumentMarker::Spelling); |
| + if (isGrammarCheckingEnabled()) |
|
please use gerrit instead
2013/07/30 21:32:00
Also check for unified spellchecker setting. If un
|
| + markerTypes.add(DocumentMarker::Grammar); |
| + for (Node* node = innerText; node; node = NodeTraversal::next(node, innerText)) { |
| + m_frame->document()->markers()->removeMarkers(node, markerTypes); |
| + } |
| + |
| if (client()) |
| client()->textFieldDidEndEditing(e); |
| } |
| @@ -2252,7 +2285,8 @@ void Editor::respondToChangedSelection(const VisibleSelection& oldSelection, Fra |
| // When typing we check spelling elsewhere, so don't redo it here. |
| // If this is a change in selection resulting from a delete operation, |
| // oldSelection may no longer be in the document. |
| - if (shouldCheckSpellingAndGrammar && closeTyping && oldSelection.isContentEditable() && oldSelection.start().deprecatedNode() && oldSelection.start().anchorNode()->inDocument()) { |
| + if (shouldCheckSpellingAndGrammar && closeTyping && oldSelection.isContentEditable() && oldSelection.start().deprecatedNode() && oldSelection.start().anchorNode()->inDocument() |
| + && !isSelectionInTextField(oldSelection)) { |
|
please use gerrit instead
2013/07/30 21:32:00
We don't go through code looking for style violati
pstanek
2013/07/30 21:50:39
Been there. && and || on the right is something pr
please use gerrit instead
2013/07/30 21:57:01
Presubmit checks are usually correct. Do what they
|
| VisiblePosition oldStart(oldSelection.visibleStart()); |
| VisibleSelection oldAdjacentWords = VisibleSelection(startOfWord(oldStart, LeftWordIfOnBoundary), endOfWord(oldStart, RightWordIfOnBoundary)); |
| if (oldAdjacentWords != newAdjacentWords) { |