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

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

Issue 2785853002: Selection Action mode triggered like a context menu (Closed)
Patch Set: fixing tests Created 3 years, 7 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: third_party/WebKit/Source/core/editing/SelectionController.cpp
diff --git a/third_party/WebKit/Source/core/editing/SelectionController.cpp b/third_party/WebKit/Source/core/editing/SelectionController.cpp
index 83362c8305e04eee4226f6e287da66ccc37e856d..7dabdca6011180bf081e8921e518e63c5af51c09 100644
--- a/third_party/WebKit/Source/core/editing/SelectionController.cpp
+++ b/third_party/WebKit/Source/core/editing/SelectionController.cpp
@@ -41,12 +41,14 @@
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
+#include "core/input/EventHandler.h"
#include "core/layout/LayoutView.h"
#include "core/layout/api/LayoutViewItem.h"
#include "core/page/FocusController.h"
#include "core/page/Page.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/wtf/AutoReset.h"
+#include "public/web/WebMenuSourceType.h"
namespace blink {
SelectionController* SelectionController::Create(LocalFrame& frame) {
@@ -194,6 +196,8 @@ bool SelectionController::HandleSingleClick(
UpdateSelectionForMouseDownDispatchingSelectStart(
inner_node, selection, kCharacterGranularity,
HandleVisibility::kVisible);
+ frame_->GetEventHandler().ShowNonLocatedContextMenu(nullptr,
yosin_UTC9 2017/05/25 04:47:20 Since "selectionstart" event is cancelalbe, we sho
amaralp1 2017/05/25 07:11:56 Changed to only show context menu if |UpdateSelect
+ kMenuSourceTouch);
yosin_UTC9 2017/05/25 04:47:21 Could you tell me why we use |kMenuSourceTouch| ev
amaralp1 2017/05/25 07:11:56 |event.FromTouch()| has to be true or else we woul
return false;
}
}
@@ -543,10 +547,10 @@ void SelectionController::SelectClosestMisspellingFromHitTestResult(
kWordGranularity, HandleVisibility::kNotVisible);
}
-void SelectionController::SelectClosestWordFromMouseEvent(
+bool SelectionController::SelectClosestWordFromMouseEvent(
const MouseEventWithHitTestResults& result) {
if (!mouse_down_may_start_select_)
- return;
+ return false;
AppendTrailingWhitespace append_trailing_whitespace =
(result.Event().click_count == 2 &&
@@ -556,7 +560,7 @@ void SelectionController::SelectClosestWordFromMouseEvent(
DCHECK(!frame_->GetDocument()->NeedsLayoutTreeUpdate());
- SelectClosestWordFromHitTestResult(
+ return SelectClosestWordFromHitTestResult(
result.GetHitTestResult(), append_trailing_whitespace,
result.Event().FromTouch() ? SelectInputEventType::kTouch
: SelectInputEventType::kMouse);
@@ -577,8 +581,10 @@ void SelectionController::SelectClosestMisspellingFromMouseEvent(
void SelectionController::SelectClosestWordOrLinkFromMouseEvent(
const MouseEventWithHitTestResults& result) {
- if (!result.GetHitTestResult().IsLiveLink())
- return SelectClosestWordFromMouseEvent(result);
+ if (!result.GetHitTestResult().IsLiveLink()) {
+ SelectClosestWordFromMouseEvent(result);
+ return;
+ }
Node* inner_node = result.InnerNode();
@@ -763,7 +769,11 @@ bool SelectionController::HandleDoubleClick(
// from setting caret selection.
selection_state_ = SelectionState::kExtendedSelection;
} else {
- SelectClosestWordFromMouseEvent(event);
+ const bool did_select = SelectClosestWordFromMouseEvent(event);
+ if (did_select && Selection().IsHandleVisible()) {
+ frame_->GetEventHandler().ShowNonLocatedContextMenu(nullptr,
+ kMenuSourceTouch);
+ }
}
return true;
}
@@ -803,12 +813,17 @@ bool SelectionController::HandleTripleClick(
const bool is_handle_visible =
event.Event().FromTouch() && new_selection.IsRange();
- return UpdateSelectionForMouseDownDispatchingSelectStart(
+ const bool did_select = UpdateSelectionForMouseDownDispatchingSelectStart(
inner_node,
ExpandSelectionToRespectUserSelectAll(inner_node, new_selection),
kParagraphGranularity,
is_handle_visible ? HandleVisibility::kVisible
: HandleVisibility::kNotVisible);
+ if (did_select && Selection().IsHandleVisible()) {
yosin_UTC9 2017/05/25 04:47:20 early-return style is better. if (!did_selection)
amaralp1 2017/05/25 07:11:56 Done.
+ frame_->GetEventHandler().ShowNonLocatedContextMenu(nullptr,
+ kMenuSourceTouch);
+ }
+ return did_select;
}
bool SelectionController::HandleMousePressEvent(

Powered by Google App Engine
This is Rietveld 408576698