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

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
« no previous file with comments | « Source/core/editing/FrameSelection.h ('k') | Source/core/editing/FrameSelectionTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/FrameSelection.cpp
diff --git a/Source/core/editing/FrameSelection.cpp b/Source/core/editing/FrameSelection.cpp
index d0b791567ef11aceb89e683b02190abda475c313..da325395244caeec66b187adbad82d9d16e570df 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)
yosin_UTC9 2014/10/28 06:11:46 Can we use |Position| rather than |VisiblePosition
yoichio 2014/10/28 08:28:04 No, characterAfter and Before are VisiblePosition
+{
+ // 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())) {
yosin_UTC9 2014/10/28 06:11:46 How about this case "foo |,"?
yoichio 2014/10/28 08:28:04 To search far characters are too aggressive, I thi
+ selectWordAroundPosition(position.previous());
+ return;
+ }
+
+ VisibleSelection selection(position);
+ selection.expandUsingGranularity(WordGranularity);
+ String text = plainText(selection.start(), selection.end());
yosin_UTC9 2014/10/28 06:11:46 Should we check |isSeparator(c)| for character in
yoichio 2014/10/28 08:28:04 Done.
+ if (text.isEmpty())
+ return;
+
+ setSelection(selection);
yosin_UTC9 2014/10/28 06:11:46 Should we pass |WordGranuaryity| to |setSelection(
yoichio 2014/10/28 08:28:04 Done.
+}
+
}
#ifndef NDEBUG
« no previous file with comments | « Source/core/editing/FrameSelection.h ('k') | Source/core/editing/FrameSelectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698