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

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

Issue 2200833007: Change return value of FrameSelection::modify() to prevent unnecessary window scrolling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-08-05T13:02:14 Created 4 years, 4 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 | « no previous file | third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/FrameSelection.cpp
diff --git a/third_party/WebKit/Source/core/editing/FrameSelection.cpp b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
index b179f6169ea68ec30846fb7b92807c9e86bea756..8c7f0a8448b37586d6d33161c389506e1f954ff7 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
@@ -72,6 +72,7 @@
#include "core/page/FocusController.h"
#include "core/page/FrameTree.h"
#include "core/page/Page.h"
+#include "core/page/SpatialNavigation.h"
#include "core/paint/PaintLayer.h"
#include "platform/SecureTextInput.h"
#include "platform/geometry/FloatQuad.h"
@@ -610,6 +611,12 @@ static DispatchEventResult dispatchSelectStart(const VisibleSelection& selection
return selectStartTarget->dispatchEvent(Event::createCancelableBubble(EventTypeNames::selectstart));
}
+// The return value of |FrameSelection::modify()| is different based on
+// value of |userTriggered| parameter.
+// When |userTriggered| is |userTriggered|, |modify()| returns false if
+// "selectstart" event is dispatched and canceled, otherwise returns true.
+// When |userTriggered| is |NotUserTrigged|, return value specifies whether
+// selection is modified or not.
bool FrameSelection::modify(EAlteration alter, SelectionDirection direction, TextGranularity granularity, EUserTriggered userTriggered)
{
SelectionModifier selectionModifier(*frame(), selection(), m_xPosForVerticalArrowNavigation);
@@ -620,8 +627,17 @@ bool FrameSelection::modify(EAlteration alter, SelectionDirection direction, Tex
&& dispatchSelectStart(selection()) != DispatchEventResult::NotCanceled) {
return false;
}
- if (!modified)
- return false;
+ if (!modified) {
+ if (userTriggered == NotUserTriggered)
+ return false;
+ // If spatial navigation enabled, focus navigator will move focus to
+ // another element. See snav-input.html and snav-textarea.html
+ if (isSpatialNavigationEnabled(m_frame))
+ return false;
+ // Even if selection isn't changed, we prevent to default action, e.g.
+ // scroll window when caret is at end of content editable.
+ return true;
+ }
const SetSelectionOptions options = CloseTyping | ClearTypingStyle | userTriggered;
setSelection(selectionModifier.selection(), options);
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698