| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2007 Google Inc. All Rights Reserved. | 2 * Copyright 2007 Google Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Portions Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 4 * Portions Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * ***** BEGIN LICENSE BLOCK ***** | 6 * ***** BEGIN LICENSE BLOCK ***** |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 #include "base/gfx/rect.h" | 82 #include "base/gfx/rect.h" |
| 83 #include "base/keyboard_codes.h" | 83 #include "base/keyboard_codes.h" |
| 84 #include "base/logging.h" | 84 #include "base/logging.h" |
| 85 #include "base/message_loop.h" | 85 #include "base/message_loop.h" |
| 86 #include "base/string_util.h" | 86 #include "base/string_util.h" |
| 87 #include "webkit/glue/chrome_client_impl.h" | 87 #include "webkit/glue/chrome_client_impl.h" |
| 88 #include "webkit/glue/clipboard_conversion.h" | 88 #include "webkit/glue/clipboard_conversion.h" |
| 89 #include "webkit/glue/context_menu_client_impl.h" | 89 #include "webkit/glue/context_menu_client_impl.h" |
| 90 #include "webkit/glue/webdevtoolsagent_impl.h" | 90 #include "webkit/glue/webdevtoolsagent_impl.h" |
| 91 #include "webkit/glue/dom_operations.h" |
| 91 #include "webkit/glue/dragclient_impl.h" | 92 #include "webkit/glue/dragclient_impl.h" |
| 92 #include "webkit/glue/editor_client_impl.h" | 93 #include "webkit/glue/editor_client_impl.h" |
| 93 #include "webkit/glue/event_conversion.h" | 94 #include "webkit/glue/event_conversion.h" |
| 94 #include "webkit/glue/glue_serialize.h" | 95 #include "webkit/glue/glue_serialize.h" |
| 95 #include "webkit/glue/glue_util.h" | 96 #include "webkit/glue/glue_util.h" |
| 96 #include "webkit/glue/image_resource_fetcher.h" | 97 #include "webkit/glue/image_resource_fetcher.h" |
| 97 #include "webkit/glue/inspector_client_impl.h" | 98 #include "webkit/glue/inspector_client_impl.h" |
| 98 #include "webkit/glue/searchable_form_data.h" | 99 #include "webkit/glue/searchable_form_data.h" |
| 99 #include "webkit/glue/webdropdata.h" | 100 #include "webkit/glue/webdropdata.h" |
| 100 #include "webkit/glue/webhistoryitem_impl.h" | 101 #include "webkit/glue/webhistoryitem_impl.h" |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 | 418 |
| 418 main_frame()->frame()->eventHandler()->handleMouseMoveEvent( | 419 main_frame()->frame()->eventHandler()->handleMouseMoveEvent( |
| 419 MakePlatformMouseEvent(main_frame()->frameview(), event)); | 420 MakePlatformMouseEvent(main_frame()->frameview(), event)); |
| 420 } | 421 } |
| 421 | 422 |
| 422 void WebViewImpl::MouseDown(const WebMouseEvent& event) { | 423 void WebViewImpl::MouseDown(const WebMouseEvent& event) { |
| 423 if (!main_frame() || !main_frame()->frameview()) | 424 if (!main_frame() || !main_frame()->frameview()) |
| 424 return; | 425 return; |
| 425 | 426 |
| 426 last_mouse_down_point_ = gfx::Point(event.x, event.y); | 427 last_mouse_down_point_ = gfx::Point(event.x, event.y); |
| 427 // We need to remember who has focus, as if the user left-clicks an already | 428 |
| 428 // focused text-field, we may want to show the auto-fill popup. | 429 // If a text field that has focus is clicked again, we should display the |
| 429 RefPtr<Node> focused_node; | 430 // autocomplete popup. |
| 430 if (event.button == WebMouseEvent::BUTTON_LEFT) | 431 RefPtr<Node> clicked_node; |
| 431 focused_node = GetFocusedNode(); | 432 if (event.button == WebMouseEvent::BUTTON_LEFT) { |
| 433 RefPtr<Node> focused_node = GetFocusedNode(); |
| 434 if (focused_node.get() && |
| 435 webkit_glue::NodeToHTMLInputElement(focused_node.get())) { |
| 436 IntPoint point(event.x, event.y); |
| 437 HitTestResult result(point); |
| 438 result = page_->mainFrame()->eventHandler()->hitTestResultAtPoint(point, |
| 439 false); |
| 440 if (result.innerNonSharedNode() == focused_node) { |
| 441 // Already focused text field was clicked, let's remember this. If |
| 442 // focus has not changed after the mouse event is processed, we'll |
| 443 // trigger the autocomplete. |
| 444 clicked_node = focused_node; |
| 445 } |
| 446 } |
| 447 } |
| 432 | 448 |
| 433 main_frame()->frame()->eventHandler()->handleMousePressEvent( | 449 main_frame()->frame()->eventHandler()->handleMousePressEvent( |
| 434 MakePlatformMouseEvent(main_frame()->frameview(), event)); | 450 MakePlatformMouseEvent(main_frame()->frameview(), event)); |
| 435 | 451 |
| 436 if (focused_node.get() && focused_node == GetFocusedNode()) { | 452 if (clicked_node.get() && clicked_node == GetFocusedNode()) { |
| 437 // Already focused node was clicked, ShowAutofillForNode will determine | 453 // Focus has not changed, show the autocomplete popup. |
| 438 // whether to show the autofill (typically, if the node is a text-field and | |
| 439 // is empty). | |
| 440 static_cast<EditorClientImpl*>(page_->editorClient())-> | 454 static_cast<EditorClientImpl*>(page_->editorClient())-> |
| 441 ShowAutofillForNode(focused_node.get()); | 455 ShowAutofillForNode(clicked_node.get()); |
| 442 } | 456 } |
| 443 } | 457 } |
| 444 | 458 |
| 445 void WebViewImpl::MouseContextMenu(const WebMouseEvent& event) { | 459 void WebViewImpl::MouseContextMenu(const WebMouseEvent& event) { |
| 446 if (!main_frame() || !main_frame()->frameview()) | 460 if (!main_frame() || !main_frame()->frameview()) |
| 447 return; | 461 return; |
| 448 | 462 |
| 449 page_->contextMenuController()->clearContextMenu(); | 463 page_->contextMenuController()->clearContextMenu(); |
| 450 | 464 |
| 451 MakePlatformMouseEvent pme(main_frame()->frameview(), event); | 465 MakePlatformMouseEvent pme(main_frame()->frameview(), event); |
| (...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1740 | 1754 |
| 1741 return document->focusedNode(); | 1755 return document->focusedNode(); |
| 1742 } | 1756 } |
| 1743 | 1757 |
| 1744 HitTestResult WebViewImpl::HitTestResultForWindowPos(const IntPoint& pos) { | 1758 HitTestResult WebViewImpl::HitTestResultForWindowPos(const IntPoint& pos) { |
| 1745 IntPoint doc_point( | 1759 IntPoint doc_point( |
| 1746 page_->mainFrame()->view()->windowToContents(pos)); | 1760 page_->mainFrame()->view()->windowToContents(pos)); |
| 1747 return page_->mainFrame()->eventHandler()-> | 1761 return page_->mainFrame()->eventHandler()-> |
| 1748 hitTestResultAtPoint(doc_point, false); | 1762 hitTestResultAtPoint(doc_point, false); |
| 1749 } | 1763 } |
| OLD | NEW |