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_util.h" | 10 #include "components/autofill/core/common/autofill_util.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 28 matching lines...) Expand all Loading... | |
| 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) { |
| 78 focused_node_was_last_clicked_ = !mouse_down_node.isNull() && | 80 focused_node_was_last_clicked_ = !mouse_down_node.isNull() && |
| 79 mouse_down_node.focused(); | 81 mouse_down_node.focused(); |
| 82 | |
| 83 if (IsKeyboardAccessoryEnabled()) | |
| 84 DoFocusChangeComplete(); | |
| 80 } | 85 } |
| 81 | 86 |
| 82 void PageClickTracker::FocusedNodeChanged(const WebNode& node) { | 87 void PageClickTracker::FocusedNodeChanged(const WebNode& node) { |
| 88 if (!WebUserGestureIndicator::isProcessingUserGesture()) | |
| 89 return; | |
|
Evan Stade
2015/09/08 18:13:01
I don't think it's right to early return before yo
please use gerrit instead
2015/09/08 21:18:08
Moved the early return before changing was_focused
| |
| 90 | |
| 83 was_focused_before_now_ = false; | 91 was_focused_before_now_ = false; |
| 84 | 92 |
| 85 if (IsKeyboardAccessoryEnabled()) { | 93 if (IsKeyboardAccessoryEnabled()) { |
| 86 focused_node_was_last_clicked_ = true; | 94 focused_node_was_last_clicked_ = true; |
| 87 DoFocusChangeComplete(); | 95 DoFocusChangeComplete(); |
| 88 } | 96 } |
| 89 } | 97 } |
| 90 | 98 |
| 91 void PageClickTracker::FocusChangeComplete() { | 99 void PageClickTracker::FocusChangeComplete() { |
| 92 if (IsKeyboardAccessoryEnabled()) | 100 if (IsKeyboardAccessoryEnabled()) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 | 137 |
| 130 void PageClickTracker::Legacy::OnMouseDown(const WebNode& mouse_down_node) { | 138 void PageClickTracker::Legacy::OnMouseDown(const WebNode& mouse_down_node) { |
| 131 tracker_->OnMouseDown(mouse_down_node); | 139 tracker_->OnMouseDown(mouse_down_node); |
| 132 } | 140 } |
| 133 | 141 |
| 134 void PageClickTracker::Legacy::FocusChangeComplete() { | 142 void PageClickTracker::Legacy::FocusChangeComplete() { |
| 135 tracker_->FocusChangeComplete(); | 143 tracker_->FocusChangeComplete(); |
| 136 } | 144 } |
| 137 | 145 |
| 138 } // namespace autofill | 146 } // namespace autofill |
| OLD | NEW |