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..70e2d6219cb6c5c73f460dc05cf3657470f5136f 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) |
| @@ -2285,6 +2296,30 @@ void Editor::respondToChangedSelection(const VisibleSelection& oldSelection, Fra |
| notifyComponentsOnChangedSelection(oldSelection, options); |
| } |
| +void Editor::respondToChangedFocusedOrActiveState(bool activeAndFocused) |
| +{ |
| + if (!activeAndFocused) { |
|
tony
2013/08/02 20:35:03
Nit: It's a little easier to read if you early ret
|
| + if (!m_frame->selection()->selection().isContentEditable()) |
| + return; |
| + |
| + if (isSelectionInTextField(m_frame->selection()->selection())) { |
| + // textFieldDidEndEditing() and textFieldDidBeginEditing() handle this. |
| + return; |
| + } |
| + |
| + // Make sure a current selection gets spell checked when unfocusing an editable element |
| + // by activating different frame. |
|
tony
2013/08/02 20:35:03
This is a 'what' comment, which we normally avoid
|
| + VisiblePosition start(m_frame->selection()->selection().visibleStart()); |
|
tony
2013/08/02 20:35:03
This code seems similar to the code in respondToCh
|
| + VisibleSelection adjacentWords = VisibleSelection(startOfWord(start, LeftWordIfOnBoundary), endOfWord(start, RightWordIfOnBoundary)); |
| + if (isContinuousSpellCheckingEnabled() && isGrammarCheckingEnabled()) { |
| + VisibleSelection selectedSentence = VisibleSelection(startOfSentence(start), endOfSentence(start)); |
| + markMisspellingsAndBadGrammar(adjacentWords, true, selectedSentence); |
|
tony
2013/08/02 20:35:03
A good cleanup change would be converting the bool
pstanek
2013/08/04 00:00:06
Sure but note I'm not doing this within this bug f
|
| + } else { |
| + markMisspellingsAndBadGrammar(adjacentWords, false, adjacentWords); |
| + } |
| + } |
| +} |
| + |
| static Node* findFirstMarkable(Node* node) |
| { |
| while (node) { |