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

Side by Side Diff: components/autofill/content/renderer/page_click_tracker.cc

Issue 884583002: [autofill] Show autofill popup when focusing a field by tapping near its edge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bounds-change
Patch Set: Add a test Created 5 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/content/renderer/page_click_tracker.h" 5 #include "components/autofill/content/renderer/page_click_tracker.h"
6 6
7 #include "components/autofill/content/renderer/form_autofill_util.h" 7 #include "components/autofill/content/renderer/form_autofill_util.h"
8 #include "components/autofill/content/renderer/page_click_listener.h" 8 #include "components/autofill/content/renderer/page_click_listener.h"
9 #include "content/public/renderer/render_view.h" 9 #include "content/public/renderer/render_view.h"
10 #include "third_party/WebKit/public/web/WebDocument.h" 10 #include "third_party/WebKit/public/web/WebDocument.h"
11 #include "third_party/WebKit/public/web/WebInputElement.h" 11 #include "third_party/WebKit/public/web/WebInputElement.h"
12 #include "third_party/WebKit/public/web/WebInputEvent.h" 12 #include "third_party/WebKit/public/web/WebInputEvent.h"
13 #include "third_party/WebKit/public/web/WebLocalFrame.h" 13 #include "third_party/WebKit/public/web/WebLocalFrame.h"
14 #include "third_party/WebKit/public/web/WebTextAreaElement.h" 14 #include "third_party/WebKit/public/web/WebTextAreaElement.h"
15 #include "third_party/WebKit/public/web/WebView.h" 15 #include "third_party/WebKit/public/web/WebView.h"
16 #include "ui/gfx/geometry/rect_f.h"
16 17
17 using blink::WebElement; 18 using blink::WebElement;
18 using blink::WebGestureEvent; 19 using blink::WebGestureEvent;
19 using blink::WebInputElement; 20 using blink::WebInputElement;
20 using blink::WebInputEvent; 21 using blink::WebInputEvent;
21 using blink::WebMouseEvent; 22 using blink::WebMouseEvent;
22 using blink::WebNode; 23 using blink::WebNode;
23 using blink::WebTextAreaElement; 24 using blink::WebTextAreaElement;
24 25
25 namespace { 26 namespace {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 void PageClickTracker::OnDestruct() { 68 void PageClickTracker::OnDestruct() {
68 // No-op. Don't delete |this|. 69 // No-op. Don't delete |this|.
69 } 70 }
70 71
71 void PageClickTracker::DidHandleMouseEvent(const WebMouseEvent& event) { 72 void PageClickTracker::DidHandleMouseEvent(const WebMouseEvent& event) {
72 if (event.type != WebInputEvent::MouseDown || 73 if (event.type != WebInputEvent::MouseDown ||
73 event.button != WebMouseEvent::ButtonLeft) { 74 event.button != WebMouseEvent::ButtonLeft) {
74 return; 75 return;
75 } 76 }
76 77
77 PotentialActivationAt(event.x, event.y); 78 PotentialActivationAt(gfx::RectF(event.x, event.y, 1, 1));
78 } 79 }
79 80
80 void PageClickTracker::DidHandleGestureEvent(const WebGestureEvent& event) { 81 void PageClickTracker::DidHandleGestureEvent(const WebGestureEvent& event) {
81 if (event.type != WebGestureEvent::GestureTap) 82 if (event.type != WebGestureEvent::GestureTap)
82 return; 83 return;
83 84
84 PotentialActivationAt(event.x, event.y); 85 PotentialActivationAt(gfx::RectF(event.x - event.data.tap.width / 2.0,
86 event.y - event.data.tap.height / 2.0,
87 event.data.tap.width,
88 event.data.tap.height));
85 } 89 }
86 90
87 void PageClickTracker::FocusedNodeChanged(const WebNode& node) { 91 void PageClickTracker::FocusedNodeChanged(const WebNode& node) {
88 was_focused_before_now_ = false; 92 was_focused_before_now_ = false;
89 } 93 }
90 94
91 void PageClickTracker::FocusChangeComplete() { 95 void PageClickTracker::FocusChangeComplete() {
Evan Stade 2015/01/29 00:34:04 also please change the name of this
please use gerrit instead 2015/01/29 01:47:04 https://codereview.chromium.org/886663002/
92 if (!clicked_node_.isNull()) { 96 if (!clicked_node_.isNull()) {
93 const WebInputElement input_element = GetTextWebInputElement(clicked_node_); 97 const WebInputElement input_element = GetTextWebInputElement(clicked_node_);
94 if (!input_element.isNull()) { 98 if (!input_element.isNull()) {
95 listener_->FormControlElementClicked(input_element, 99 listener_->FormControlElementClicked(input_element,
96 was_focused_before_now_); 100 was_focused_before_now_);
97 } else { 101 } else {
98 const WebTextAreaElement textarea_element = 102 const WebTextAreaElement textarea_element =
99 GetWebTextAreaElement(clicked_node_); 103 GetWebTextAreaElement(clicked_node_);
100 if (!textarea_element.isNull()) { 104 if (!textarea_element.isNull()) {
101 listener_->FormControlElementClicked(textarea_element, 105 listener_->FormControlElementClicked(textarea_element,
102 was_focused_before_now_); 106 was_focused_before_now_);
103 } 107 }
104 } 108 }
105 } 109 }
106 110
107 clicked_node_.reset(); 111 clicked_node_.reset();
108 was_focused_before_now_ = true; 112 was_focused_before_now_ = true;
109 } 113 }
110 114
111 void PageClickTracker::PotentialActivationAt(int x, int y) { 115 void PageClickTracker::PotentialActivationAt(const gfx::RectF& region) {
112 WebElement focused_element = render_view()->GetFocusedElement(); 116 WebElement focused_element = render_view()->GetFocusedElement();
113 if (focused_element.isNull()) 117 if (focused_element.isNull())
114 return; 118 return;
115 119
116 if (!GetScaledBoundingBox(render_view()->GetWebView()->pageScaleFactor(), 120 if (!GetScaledBoundingBox(render_view()->GetWebView()->pageScaleFactor(),
117 &focused_element).Contains(x, y)) { 121 &focused_element).Intersects(region)) {
118 return; 122 return;
119 } 123 }
120 124
121 clicked_node_ = focused_element; 125 clicked_node_ = focused_element;
122 } 126 }
123 127
124 } // namespace autofill 128 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698