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

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

Issue 675413003: WebLocalFrameImpl::selectWordAroundPosition should select a word before space. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update Created 6 years, 2 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/FrameSelection.cpp
diff --git a/Source/core/editing/FrameSelection.cpp b/Source/core/editing/FrameSelection.cpp
index d0b791567ef11aceb89e683b02190abda475c313..289c51394d784a00f5015cf980733b94b3185136 100644
--- a/Source/core/editing/FrameSelection.cpp
+++ b/Source/core/editing/FrameSelection.cpp
@@ -72,6 +72,7 @@
#include "platform/SecureTextInput.h"
#include "platform/geometry/FloatQuad.h"
#include "platform/graphics/GraphicsContext.h"
+#include "platform/text/UnicodeUtilities.h"
#include "wtf/text/CString.h"
#include <stdio.h>
@@ -1930,6 +1931,24 @@ void FrameSelection::scheduleVisualUpdate() const
page->animator().scheduleVisualUpdate();
}
+void FrameSelection::selectWordAroundPosition(const VisiblePosition& position)
+{
+ // If you have a "foo| ", Selection::expandUsingGranularity selects space
+ // after the caret. To select "foo", move |position| to previous.
+ if (isSeparator(position.characterAfter()) && !isSeparator(position.characterBefore())) {
+ selectWordAroundPosition(position.previous());
+ return;
+ }
+
+ VisibleSelection selection(position);
+ selection.expandUsingGranularity(WordGranularity);
+ String text = plainText(selection.start(), selection.end());
+ if (text.isEmpty() || isSeparator(text.characterStartingAt(0)))
+ return;
+
+ setSelection(selection, WordGranularity);
+}
+
}
#ifndef NDEBUG

Powered by Google App Engine
This is Rietveld 408576698