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

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

Issue 165233003: Replace WebDocument::focusedNode to focusedElement (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased with latest Created 6 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/platform/WebString.h" 10 #include "third_party/WebKit/public/platform/WebString.h"
(...skipping 28 matching lines...) Expand all
39 return WebInputElement(); 39 return WebInputElement();
40 const WebInputElement* input = blink::toWebInputElement(&element); 40 const WebInputElement* input = blink::toWebInputElement(&element);
41 if (!autofill::IsTextInput(input)) 41 if (!autofill::IsTextInput(input))
42 return WebInputElement(); 42 return WebInputElement();
43 return *input; 43 return *input;
44 } 44 }
45 45
46 // Checks to see if a text field was the previously selected node and is now 46 // Checks to see if a text field was the previously selected node and is now
47 // losing its focus. 47 // losing its focus.
48 bool DidSelectedTextFieldLoseFocus(const WebNode& newly_clicked_node) { 48 bool DidSelectedTextFieldLoseFocus(const WebNode& newly_clicked_node) {
49 blink::WebNode focused_node = newly_clicked_node.document().focusedNode(); 49 blink::WebNode focused_node = newly_clicked_node.document().focusedElement();
jam 2014/02/26 17:48:54 nit: rename to focused_element?
50 50
51 if (focused_node.isNull() || GetTextWebInputElement(focused_node).isNull()) 51 if (focused_node.isNull() || GetTextWebInputElement(focused_node).isNull())
52 return false; 52 return false;
53 53
54 return focused_node != newly_clicked_node; 54 return focused_node != newly_clicked_node;
55 } 55 }
56 56
57 } // namespace 57 } // namespace
58 58
59 namespace autofill { 59 namespace autofill {
(...skipping 19 matching lines...) Expand all
79 last_node_clicked_.isNull()) { 79 last_node_clicked_.isNull()) {
80 return; 80 return;
81 } 81 }
82 82
83 // We are only interested in text field clicks. 83 // We are only interested in text field clicks.
84 const WebInputElement input_element = 84 const WebInputElement input_element =
85 GetTextWebInputElement(last_node_clicked_); 85 GetTextWebInputElement(last_node_clicked_);
86 if (input_element.isNull()) 86 if (input_element.isNull())
87 return; 87 return;
88 88
89 bool is_focused = (last_node_clicked_ == render_view()->GetFocusedNode()); 89 bool is_focused = (last_node_clicked_ == render_view()->GetFocusedElement());
90 listener_->InputElementClicked(input_element, was_focused_, is_focused); 90 listener_->InputElementClicked(input_element, was_focused_, is_focused);
91 } 91 }
92 92
93 void PageClickTracker::DidFinishDocumentLoad(blink::WebFrame* frame) { 93 void PageClickTracker::DidFinishDocumentLoad(blink::WebFrame* frame) {
94 tracked_frames_.push_back(frame); 94 tracked_frames_.push_back(frame);
95 frame->document().addEventListener("mousedown", this, false); 95 frame->document().addEventListener("mousedown", this, false);
96 } 96 }
97 97
98 void PageClickTracker::FrameDetached(blink::WebFrame* frame) { 98 void PageClickTracker::FrameDetached(blink::WebFrame* frame) {
99 std::vector<blink::WebFrame*>::iterator iter = 99 std::vector<blink::WebFrame*>::iterator iter =
(...skipping 27 matching lines...) Expand all
127 // tree and the tree has been rebuilt due to an earlier event. 127 // tree and the tree has been rebuilt due to an earlier event.
128 return; 128 return;
129 129
130 HandleTextFieldMaybeLosingFocus(node); 130 HandleTextFieldMaybeLosingFocus(node);
131 131
132 // We are only interested in text field clicks. 132 // We are only interested in text field clicks.
133 if (GetTextWebInputElement(node).isNull()) 133 if (GetTextWebInputElement(node).isNull())
134 return; 134 return;
135 135
136 last_node_clicked_ = node; 136 last_node_clicked_ = node;
137 was_focused_ = (node.document().focusedNode() == last_node_clicked_); 137 was_focused_ = (node.document().focusedElement() == last_node_clicked_);
138 } 138 }
139 139
140 void PageClickTracker::HandleTextFieldMaybeLosingFocus( 140 void PageClickTracker::HandleTextFieldMaybeLosingFocus(
141 const WebNode& newly_clicked_node) { 141 const WebNode& newly_clicked_node) {
142 if (DidSelectedTextFieldLoseFocus(newly_clicked_node)) 142 if (DidSelectedTextFieldLoseFocus(newly_clicked_node))
143 listener_->InputElementLostFocus(); 143 listener_->InputElementLostFocus();
144 } 144 }
145 145
146 } // namespace autofill 146 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698