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 "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 30 matching lines...) Expand all Loading... | |
41 return WebInputElement(); | 41 return WebInputElement(); |
42 const WebInputElement* input = blink::toWebInputElement(&element); | 42 const WebInputElement* input = blink::toWebInputElement(&element); |
43 if (!autofill::IsTextInput(input)) | 43 if (!autofill::IsTextInput(input)) |
44 return WebInputElement(); | 44 return WebInputElement(); |
45 return *input; | 45 return *input; |
46 } | 46 } |
47 | 47 |
48 // Casts |node| to a WebTextAreaElement. | 48 // Casts |node| to a WebTextAreaElement. |
49 // Returns an empty (isNull()) WebTextAreaElement if |node| is not a | 49 // Returns an empty (isNull()) WebTextAreaElement if |node| is not a |
50 // textarea field. | 50 // textarea field. |
51 const WebTextAreaElement GetTextWebTextAreaElement(const WebNode& node) { | 51 const WebTextAreaElement GetTextWebTextAreaElement(const WebNode& node) { |
Ilya Sherman
2014/05/19 08:41:21
nit: While you're here, would you mind updating th
| |
52 if (!node.isElementNode()) | 52 if (!node.isElementNode()) |
53 return WebTextAreaElement(); | 53 return WebTextAreaElement(); |
54 const WebElement element = node.toConst<WebElement>(); | 54 const WebElement element = node.toConst<WebElement>(); |
55 if (!element.hasTagName("textarea")) | 55 const WebTextAreaElement* textarea_element = |
56 blink::toWebTextAreaElement(&element); | |
57 if (!textarea_element) | |
56 return WebTextAreaElement(); | 58 return WebTextAreaElement(); |
57 return element.toConst<WebTextAreaElement>(); | 59 return *textarea_element; |
58 } | 60 } |
59 | 61 |
60 // Checks to see if a text field was the previously selected node and is now | 62 // Checks to see if a text field was the previously selected node and is now |
61 // losing its focus. | 63 // losing its focus. |
62 bool DidSelectedTextFieldLoseFocus(const WebNode& newly_clicked_node) { | 64 bool DidSelectedTextFieldLoseFocus(const WebNode& newly_clicked_node) { |
63 blink::WebElement focused_element = | 65 blink::WebElement focused_element = |
64 newly_clicked_node.document().focusedElement(); | 66 newly_clicked_node.document().focusedElement(); |
65 | 67 |
66 if (focused_element.isNull() || | 68 if (focused_element.isNull() || |
67 (GetTextWebInputElement(focused_element).isNull() && | 69 (GetTextWebInputElement(focused_element).isNull() && |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 was_focused_ = (node.document().focusedElement() == last_node_clicked_); | 161 was_focused_ = (node.document().focusedElement() == last_node_clicked_); |
160 } | 162 } |
161 | 163 |
162 void PageClickTracker::HandleTextFieldMaybeLosingFocus( | 164 void PageClickTracker::HandleTextFieldMaybeLosingFocus( |
163 const WebNode& newly_clicked_node) { | 165 const WebNode& newly_clicked_node) { |
164 if (DidSelectedTextFieldLoseFocus(newly_clicked_node)) | 166 if (DidSelectedTextFieldLoseFocus(newly_clicked_node)) |
165 listener_->FormControlElementLostFocus(); | 167 listener_->FormControlElementLostFocus(); |
166 } | 168 } |
167 | 169 |
168 } // namespace autofill | 170 } // namespace autofill |
OLD | NEW |