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

Unified Diff: Source/core/editing/Editor.cpp

Issue 21235009: Make sure the last selection gets spell checked when focusing different frame. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Check window.internals existence. Created 7 years, 5 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
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) {

Powered by Google App Engine
This is Rietveld 408576698