Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "components/autofill/content/renderer/form_autofill_util.h" | 8 #include "components/autofill/content/renderer/form_autofill_util.h" |
| 9 #include "components/autofill/content/renderer/page_click_listener.h" | 9 #include "components/autofill/content/renderer/page_click_listener.h" |
| 10 #include "components/autofill/core/common/autofill_switches.h" | 10 #include "components/autofill/core/common/autofill_switches.h" |
| 11 #include "content/public/renderer/render_frame.h" | 11 #include "content/public/renderer/render_frame.h" |
| 12 #include "content/public/renderer/render_view.h" | 12 #include "content/public/renderer/render_view.h" |
| 13 #include "third_party/WebKit/public/platform/WebPoint.h" | 13 #include "third_party/WebKit/public/platform/WebPoint.h" |
| 14 #include "third_party/WebKit/public/platform/WebSize.h" | 14 #include "third_party/WebKit/public/platform/WebSize.h" |
| 15 #include "third_party/WebKit/public/web/WebDocument.h" | 15 #include "third_party/WebKit/public/web/WebDocument.h" |
| 16 #include "third_party/WebKit/public/web/WebHitTestResult.h" | 16 #include "third_party/WebKit/public/web/WebHitTestResult.h" |
| 17 #include "third_party/WebKit/public/web/WebInputElement.h" | 17 #include "third_party/WebKit/public/web/WebInputElement.h" |
| 18 #include "third_party/WebKit/public/web/WebInputEvent.h" | 18 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 19 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 19 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 20 #include "third_party/WebKit/public/web/WebTextAreaElement.h" | 20 #include "third_party/WebKit/public/web/WebTextAreaElement.h" |
| 21 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | |
| 21 #include "third_party/WebKit/public/web/WebView.h" | 22 #include "third_party/WebKit/public/web/WebView.h" |
| 22 | 23 |
| 23 using blink::WebElement; | 24 using blink::WebElement; |
| 24 using blink::WebGestureEvent; | 25 using blink::WebGestureEvent; |
| 25 using blink::WebInputElement; | 26 using blink::WebInputElement; |
| 26 using blink::WebInputEvent; | 27 using blink::WebInputEvent; |
| 27 using blink::WebMouseEvent; | 28 using blink::WebMouseEvent; |
| 28 using blink::WebNode; | 29 using blink::WebNode; |
| 29 using blink::WebPoint; | 30 using blink::WebPoint; |
| 30 using blink::WebSize; | 31 using blink::WebSize; |
| 31 using blink::WebTextAreaElement; | 32 using blink::WebTextAreaElement; |
| 33 using blink::WebUserGestureIndicator; | |
| 32 | 34 |
| 33 namespace { | 35 namespace { |
| 34 | 36 |
| 35 // Casts |node| to a WebInputElement. | 37 // Casts |node| to a WebInputElement. |
| 36 // Returns an empty (isNull()) WebInputElement if |node| is not a text field. | 38 // Returns an empty (isNull()) WebInputElement if |node| is not a text field. |
| 37 const WebInputElement GetTextWebInputElement(const WebNode& node) { | 39 const WebInputElement GetTextWebInputElement(const WebNode& node) { |
| 38 if (!node.isElementNode()) | 40 if (!node.isElementNode()) |
| 39 return WebInputElement(); | 41 return WebInputElement(); |
| 40 const WebElement element = node.toConst<WebElement>(); | 42 const WebElement element = node.toConst<WebElement>(); |
| 41 if (!element.hasHTMLTagName("input")) | 43 if (!element.hasHTMLTagName("input")) |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 67 : content::RenderFrameObserver(render_frame), | 69 : content::RenderFrameObserver(render_frame), |
| 68 focused_node_was_last_clicked_(false), | 70 focused_node_was_last_clicked_(false), |
| 69 was_focused_before_now_(false), | 71 was_focused_before_now_(false), |
| 70 listener_(listener), | 72 listener_(listener), |
| 71 legacy_(this) { | 73 legacy_(this) { |
| 72 } | 74 } |
| 73 | 75 |
| 74 PageClickTracker::~PageClickTracker() { | 76 PageClickTracker::~PageClickTracker() { |
| 75 } | 77 } |
| 76 | 78 |
| 77 void PageClickTracker::OnMouseDown(const WebNode& mouse_down_node) { | 79 void PageClickTracker::OnMouseDown(const WebNode& mouse_down_node) { |
|
Evan Stade
2015/08/21 15:16:19
does a tap count as a "mouse down" here? if not wh
please use gerrit instead
2015/08/24 17:58:42
See http://crrev.com/1195473005 for context. Both
| |
| 80 if (!WebUserGestureIndicator::isProcessingUserGesture()) | |
|
Evan Stade
2015/08/21 15:16:19
schwa?
How can you have onmousedown that's not a
please use gerrit instead
2015/08/24 17:58:42
I expected document.getElementsByTagName('input')[
| |
| 81 return; | |
| 82 | |
| 78 focused_node_was_last_clicked_ = !mouse_down_node.isNull() && | 83 focused_node_was_last_clicked_ = !mouse_down_node.isNull() && |
| 79 mouse_down_node.focused(); | 84 mouse_down_node.focused(); |
| 85 | |
| 86 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 87 switches::kEnableAccessorySuggestionView)) { | |
| 88 DoFocusChangeComplete(); | |
|
Evan Stade
2015/08/21 15:16:19
remind me why we need different handling on androi
please use gerrit instead
2015/08/24 17:58:42
We need different handling for keyboard accessory
| |
| 89 } | |
| 80 } | 90 } |
| 81 | 91 |
| 82 void PageClickTracker::FocusedNodeChanged(const WebNode& node) { | 92 void PageClickTracker::FocusedNodeChanged(const WebNode& node) { |
| 93 if (!WebUserGestureIndicator::isProcessingUserGesture()) | |
| 94 return; | |
| 95 | |
| 83 was_focused_before_now_ = false; | 96 was_focused_before_now_ = false; |
| 84 | 97 |
| 85 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 98 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 86 switches::kEnableAccessorySuggestionView)) { | 99 switches::kEnableAccessorySuggestionView)) { |
| 87 focused_node_was_last_clicked_ = true; | 100 focused_node_was_last_clicked_ = true; |
| 88 DoFocusChangeComplete(); | 101 DoFocusChangeComplete(); |
| 89 } | 102 } |
| 90 } | 103 } |
| 91 | 104 |
| 92 void PageClickTracker::FocusChangeComplete() { | 105 void PageClickTracker::FocusChangeComplete() { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 | 145 |
| 133 void PageClickTracker::Legacy::OnMouseDown(const WebNode& mouse_down_node) { | 146 void PageClickTracker::Legacy::OnMouseDown(const WebNode& mouse_down_node) { |
| 134 tracker_->OnMouseDown(mouse_down_node); | 147 tracker_->OnMouseDown(mouse_down_node); |
| 135 } | 148 } |
| 136 | 149 |
| 137 void PageClickTracker::Legacy::FocusChangeComplete() { | 150 void PageClickTracker::Legacy::FocusChangeComplete() { |
| 138 tracker_->FocusChangeComplete(); | 151 tracker_->FocusChangeComplete(); |
| 139 } | 152 } |
| 140 | 153 |
| 141 } // namespace autofill | 154 } // namespace autofill |
| OLD | NEW |