| OLD | NEW |
| 1 // Copyright (c) 2007-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2007-2009 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 "config.h" | 5 #include "config.h" |
| 6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 MSVC_PUSH_WARNING_LEVEL(0); | 9 MSVC_PUSH_WARNING_LEVEL(0); |
| 10 #include "CSSStyleSelector.h" | 10 #include "CSSStyleSelector.h" |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 return true; | 588 return true; |
| 589 | 589 |
| 590 Frame* frame = GetFocusedWebCoreFrame(); | 590 Frame* frame = GetFocusedWebCoreFrame(); |
| 591 if (!frame) | 591 if (!frame) |
| 592 return false; | 592 return false; |
| 593 | 593 |
| 594 EventHandler* handler = frame->eventHandler(); | 594 EventHandler* handler = frame->eventHandler(); |
| 595 if (!handler) | 595 if (!handler) |
| 596 return KeyEventDefault(event); | 596 return KeyEventDefault(event); |
| 597 | 597 |
| 598 #if defined(OS_WIN) | 598 #if defined(OS_WIN) || defined(OS_LINUX) |
| 599 // TODO(pinkerton): figure out these keycodes on non-windows | 599 if (((event.modifiers == 0) && (event.windowsKeyCode == VKEY_APPS)) || |
| 600 if (((event.modifiers == 0) && (event.windowsKeyCode == VK_APPS)) || | |
| 601 ((event.modifiers == WebInputEvent::ShiftKey) && | 600 ((event.modifiers == WebInputEvent::ShiftKey) && |
| 602 (event.windowsKeyCode == VK_F10))) { | 601 (event.windowsKeyCode == VKEY_F10))) { |
| 603 SendContextMenuEvent(event); | 602 SendContextMenuEvent(event); |
| 604 return true; | 603 return true; |
| 605 } | 604 } |
| 606 #endif | 605 #endif |
| 607 | 606 |
| 608 // It's not clear if we should continue after detecting a capslock keypress. | 607 // It's not clear if we should continue after detecting a capslock keypress. |
| 609 // I'll err on the side of continuing, which is the pre-existing behaviour. | 608 // I'll err on the side of continuing, which is the pre-existing behaviour. |
| 610 if (event.windowsKeyCode == base::VKEY_CAPITAL && | 609 if (event.windowsKeyCode == base::VKEY_CAPITAL && |
| 611 (event.type == WebInputEvent::KeyUp || | 610 (event.type == WebInputEvent::KeyUp || |
| 612 event.type == WebInputEvent::KeyDown)) { | 611 event.type == WebInputEvent::KeyDown)) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 * The WebViewImpl::SendContextMenuEvent function is based on the Webkit | 722 * The WebViewImpl::SendContextMenuEvent function is based on the Webkit |
| 724 * function | 723 * function |
| 725 * bool WebView::handleContextMenuEvent(WPARAM wParam, LPARAM lParam) in | 724 * bool WebView::handleContextMenuEvent(WPARAM wParam, LPARAM lParam) in |
| 726 * webkit\webkit\win\WebView.cpp. The only significant change in this | 725 * webkit\webkit\win\WebView.cpp. The only significant change in this |
| 727 * function is the code to convert from a Keyboard event to the Right | 726 * function is the code to convert from a Keyboard event to the Right |
| 728 * Mouse button up event. | 727 * Mouse button up event. |
| 729 * | 728 * |
| 730 * This function is an ugly copy/paste and should be cleaned up when the | 729 * This function is an ugly copy/paste and should be cleaned up when the |
| 731 * WebKitWin version is cleaned: https://bugs.webkit.org/show_bug.cgi?id=20438 | 730 * WebKitWin version is cleaned: https://bugs.webkit.org/show_bug.cgi?id=20438 |
| 732 */ | 731 */ |
| 733 #if defined(OS_WIN) | 732 #if defined(OS_WIN) || defined(OS_LINUX) |
| 734 // TODO(pinkerton): implement on non-windows | 733 // TODO(pinkerton): implement on non-windows |
| 735 bool WebViewImpl::SendContextMenuEvent(const WebKeyboardEvent& event) { | 734 bool WebViewImpl::SendContextMenuEvent(const WebKeyboardEvent& event) { |
| 736 static const int kContextMenuMargin = 1; | 735 static const int kContextMenuMargin = 1; |
| 737 Frame* main_frame = page()->mainFrame(); | 736 Frame* main_frame = page()->mainFrame(); |
| 738 FrameView* view = main_frame->view(); | 737 FrameView* view = main_frame->view(); |
| 739 if (!view) | 738 if (!view) |
| 740 return false; | 739 return false; |
| 741 | 740 |
| 742 IntPoint coords(-1, -1); | 741 IntPoint coords(-1, -1); |
| 742 #if defined(OS_WIN) |
| 743 int right_aligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT); | 743 int right_aligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT); |
| 744 #else |
| 745 int right_aligned = 0; |
| 746 #endif |
| 744 IntPoint location; | 747 IntPoint location; |
| 745 | 748 |
| 746 // The context menu event was generated from the keyboard, so show the | 749 // The context menu event was generated from the keyboard, so show the |
| 747 // context menu by the current selection. | 750 // context menu by the current selection. |
| 748 Position start = main_frame->selection()->selection().start(); | 751 Position start = main_frame->selection()->selection().start(); |
| 749 Position end = main_frame->selection()->selection().end(); | 752 Position end = main_frame->selection()->selection().end(); |
| 750 | 753 |
| 751 if (!start.node() || !end.node()) { | 754 if (!start.node() || !end.node()) { |
| 752 location = | 755 location = |
| 753 IntPoint(right_aligned ? view->contentsWidth() - kContextMenuMargin | 756 IntPoint(right_aligned ? view->contentsWidth() - kContextMenuMargin |
| (...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1946 | 1949 |
| 1947 return document->focusedNode(); | 1950 return document->focusedNode(); |
| 1948 } | 1951 } |
| 1949 | 1952 |
| 1950 HitTestResult WebViewImpl::HitTestResultForWindowPos(const IntPoint& pos) { | 1953 HitTestResult WebViewImpl::HitTestResultForWindowPos(const IntPoint& pos) { |
| 1951 IntPoint doc_point( | 1954 IntPoint doc_point( |
| 1952 page_->mainFrame()->view()->windowToContents(pos)); | 1955 page_->mainFrame()->view()->windowToContents(pos)); |
| 1953 return page_->mainFrame()->eventHandler()-> | 1956 return page_->mainFrame()->eventHandler()-> |
| 1954 hitTestResultAtPoint(doc_point, false); | 1957 hitTestResultAtPoint(doc_point, false); |
| 1955 } | 1958 } |
| OLD | NEW |