OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/page_click_tracker.h" | 5 #include "chrome/renderer/page_click_tracker.h" |
6 | 6 |
7 #include "chrome/common/render_messages.h" | 7 #include "chrome/common/render_messages.h" |
8 #include "chrome/renderer/autofill/form_autofill_util.h" | 8 #include "chrome/renderer/autofill/form_autofill_util.h" |
9 #include "chrome/renderer/page_click_listener.h" | 9 #include "chrome/renderer/page_click_listener.h" |
10 #include "content/public/renderer/render_view.h" | 10 #include "content/public/renderer/render_view.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 const WebDOMMouseEvent mouse_event = event.toConst<WebDOMMouseEvent>(); | 126 const WebDOMMouseEvent mouse_event = event.toConst<WebDOMMouseEvent>(); |
127 DCHECK(mouse_event.buttonDown()); | 127 DCHECK(mouse_event.buttonDown()); |
128 if (mouse_event.button() != 0) | 128 if (mouse_event.button() != 0) |
129 return; // We are only interested in left clicks. | 129 return; // We are only interested in left clicks. |
130 | 130 |
131 // Remember which node has focus before the click is processed. | 131 // Remember which node has focus before the click is processed. |
132 // We'll get a notification once the mouse event has been processed | 132 // We'll get a notification once the mouse event has been processed |
133 // (DidHandleMouseEvent), we'll notify the listener at that point. | 133 // (DidHandleMouseEvent), we'll notify the listener at that point. |
134 WebNode node = mouse_event.target(); | 134 WebNode node = mouse_event.target(); |
| 135 if (node.isNull()) |
| 136 // Node may be null if the target was an SVG instance element from a <use> |
| 137 // tree and the tree has been rebuilt due to an earlier event. |
| 138 return; |
135 | 139 |
136 HandleTextFieldMaybeLosingFocus(node); | 140 HandleTextFieldMaybeLosingFocus(node); |
137 | 141 |
138 // We are only interested in text field clicks. | 142 // We are only interested in text field clicks. |
139 if (GetTextWebInputElement(node).isNull()) | 143 if (GetTextWebInputElement(node).isNull()) |
140 return; | 144 return; |
141 | 145 |
142 last_node_clicked_ = node; | 146 last_node_clicked_ = node; |
143 was_focused_ = (node.document().focusedNode() == last_node_clicked_); | 147 was_focused_ = (node.document().focusedNode() == last_node_clicked_); |
144 } | 148 } |
145 | 149 |
146 void PageClickTracker::HandleTextFieldMaybeLosingFocus( | 150 void PageClickTracker::HandleTextFieldMaybeLosingFocus( |
147 const WebNode& newly_clicked_node) { | 151 const WebNode& newly_clicked_node) { |
148 if (!DidSelectedTextFieldLoseFocus(newly_clicked_node)) | 152 if (!DidSelectedTextFieldLoseFocus(newly_clicked_node)) |
149 return; | 153 return; |
150 | 154 |
151 ObserverListBase<PageClickListener>::Iterator it(listeners_); | 155 ObserverListBase<PageClickListener>::Iterator it(listeners_); |
152 PageClickListener* listener; | 156 PageClickListener* listener; |
153 while ((listener = it.GetNext()) != NULL) { | 157 while ((listener = it.GetNext()) != NULL) { |
154 if (listener->InputElementLostFocus()) | 158 if (listener->InputElementLostFocus()) |
155 break; | 159 break; |
156 } | 160 } |
157 } | 161 } |
OLD | NEW |