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

Unified Diff: content/browser/renderer_host/input/stylus_text_selector.cc

Issue 2874183002: [Android] Fix Text selection with Stylus button pressed from Android M (Closed)
Patch Set: Add inline comments as suggested 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
« no previous file with comments | « no previous file | content/browser/renderer_host/input/stylus_text_selector_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/input/stylus_text_selector.cc
diff --git a/content/browser/renderer_host/input/stylus_text_selector.cc b/content/browser/renderer_host/input/stylus_text_selector.cc
index d4b0f0da248a709d754b4053292b62c11e76b323..65f8afbfa405fd078ca91ce55312ca4e1fa6d4aa 100644
--- a/content/browser/renderer_host/input/stylus_text_selector.cc
+++ b/content/browser/renderer_host/input/stylus_text_selector.cc
@@ -57,8 +57,11 @@ bool StylusTextSelector::OnTouchEvent(const MotionEvent& event) {
if (!text_selection_triggered_)
return false;
+ // For Android version < M, stylus button pressed state is BUTTON_SECONDARY.
+ // From Android M, this state has changed to BUTTON_STYLUS_PRIMARY.
secondary_button_pressed_ =
- event.GetButtonState() == MotionEvent::BUTTON_SECONDARY;
+ event.GetButtonState() == MotionEvent::BUTTON_SECONDARY ||
+ event.GetButtonState() == MotionEvent::BUTTON_STYLUS_PRIMARY;
switch (event.GetAction()) {
case MotionEvent::ACTION_DOWN:
@@ -140,8 +143,12 @@ bool StylusTextSelector::ShouldStartTextSelection(const MotionEvent& event) {
DCHECK_GT(event.GetPointerCount(), 0u);
// Currently we are supporting stylus-only cases.
const bool is_stylus = event.GetToolType(0) == MotionEvent::TOOL_TYPE_STYLUS;
+
+ // For Android version < M, stylus button pressed state is BUTTON_SECONDARY.
+ // From Android M, this state has changed to BUTTON_STYLUS_PRIMARY.
const bool is_only_secondary_button_pressed =
- event.GetButtonState() == MotionEvent::BUTTON_SECONDARY;
+ event.GetButtonState() == MotionEvent::BUTTON_SECONDARY ||
+ event.GetButtonState() == MotionEvent::BUTTON_STYLUS_PRIMARY;
return is_stylus && is_only_secondary_button_pressed;
}
« no previous file with comments | « no previous file | content/browser/renderer_host/input/stylus_text_selector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698