Chromium Code Reviews| 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 |