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

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: Use VisibleUnit functions and add test cases Created 6 years, 1 month 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 969308a48948c4f1c0b89325b2afe979700cab12..5acc9f8689c2d8c7b685503c576446c61d220175 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();
}
+bool FrameSelection::selectWordAroundPosition(const VisiblePosition& position)
+{
+ EWordSide wordSideList[2] = { RightWordIfOnBoundary, LeftWordIfOnBoundary };
+ for (auto& wordSide : wordSideList) {
yosin_UTC9 2014/11/14 04:19:51 Q: Do we need |&|?
yoichio 2014/11/14 04:50:21 Used EWordSide instead. http://chromium-cpp.appspo
+ VisiblePosition start = startOfWord(position, wordSide);
+ VisiblePosition end = endOfWord(position, wordSide);
+
yosin_UTC9 2014/11/14 04:19:51 nit: We don't need to have a blank line.
yoichio 2014/11/14 04:50:22 Done.
+ String text = plainText(start.deepEquivalent(), end.deepEquivalent());
+
yosin_UTC9 2014/11/14 04:19:51 nit: We don't need to have a blank line.
yoichio 2014/11/14 04:50:21 Done.
+ if (!text.isEmpty() && !isSeparator(text.characterStartingAt(0))) {
+ setSelection(VisibleSelection(start, end), WordGranularity);
+ return true;
+ }
+ }
+
+ return false;
+}
+
}
#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