| Index: chrome/renderer/page_click_tracker.cc
|
| ===================================================================
|
| --- chrome/renderer/page_click_tracker.cc (revision 86185)
|
| +++ chrome/renderer/page_click_tracker.cc (working copy)
|
| @@ -27,6 +27,26 @@
|
| using WebKit::WebString;
|
| using WebKit::WebView;
|
|
|
| +namespace {
|
| +
|
| +// Casts |node| to a WebInputElement.
|
| +// Returns an empty (isNull()) WebInputElement if |node| is not a text
|
| +// WebInputElement.
|
| +const WebInputElement GetTextWebInputElement(const WebNode& node) {
|
| + if (!node.isElementNode())
|
| + return WebInputElement();
|
| + const WebElement element = node.toConst<WebElement>();
|
| + if (!element.isFormControlElement())
|
| + return WebInputElement();
|
| + const WebFormControlElement control =
|
| + element.toConst<WebFormControlElement>();
|
| + if (control.formControlType() != WebString::fromUTF8("text"))
|
| + return WebInputElement();
|
| + return element.toConst<WebInputElement>();
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| PageClickTracker::PageClickTracker(RenderView* render_view)
|
| : RenderViewObserver(render_view),
|
| was_focused_(false) {
|
| @@ -48,18 +68,11 @@
|
| }
|
|
|
| // We are only interested in text field clicks.
|
| - if (!last_node_clicked_.isElementNode())
|
| + const WebInputElement input_element =
|
| + GetTextWebInputElement(last_node_clicked_);
|
| + if (input_element.isNull())
|
| return;
|
| - const WebElement& element = last_node_clicked_.toConst<WebElement>();
|
| - if (!element.isFormControlElement())
|
| - return;
|
| - const WebFormControlElement& control =
|
| - element.toConst<WebFormControlElement>();
|
| - if (control.formControlType() != WebString::fromUTF8("text"))
|
| - return;
|
|
|
| - const WebInputElement& input_element = element.toConst<WebInputElement>();
|
| -
|
| bool is_focused = (last_node_clicked_ == GetFocusedNode());
|
| ObserverListBase<PageClickListener>::Iterator it(listeners_);
|
| PageClickListener* listener;
|
| @@ -125,7 +138,12 @@
|
| // Remember which node has focus before the click is processed.
|
| // We'll get a notification once the mouse event has been processed
|
| // (DidHandleMouseEvent), we'll notify the listener at that point.
|
| - last_node_clicked_ = mouse_event.target();
|
| + WebNode node = mouse_event.target();
|
| + // We are only interested in text field clicks.
|
| + if (GetTextWebInputElement(node).isNull())
|
| + return;
|
| +
|
| + last_node_clicked_ = node;
|
| was_focused_ = (GetFocusedNode() == last_node_clicked_);
|
| }
|
|
|
|
|