Changeset 129750 in webkit
- Timestamp:
- Sep 27, 2012 4:12:11 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r129749 r129750 1 2012-09-27 Allan Sandfeld Jensen <allan.jensen@digia.com> 2 3 Unify event handling of middle mouse button. 4 https://bugs.webkit.org/show_bug.cgi?id=97690 5 6 Reviewed by Tony Chang. 7 8 Implement a unified version of middle mouse button press that can be shared between 9 all the ports with X11 support. 10 11 * page/EventHandler.cpp: 12 (WebCore::EventHandler::handleMousePressEventSingleClick): 13 (WebCore::EventHandler::handleMouseReleaseEvent): 14 (WebCore::EventHandler::handlePasteGlobalSelection): 15 * page/EventHandler.h: 16 (EventHandler): 17 1 18 2012-09-27 Tommy Widenflycht <tommyw@google.com> 2 19 -
trunk/Source/WebCore/page/EventHandler.cpp
r128999 r129750 2 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 5 * 5 6 * Redistribution and use in source and binary forms, with or without … … 40 41 #include "DragState.h" 41 42 #include "Editor.h" 43 #include "EditorClient.h" 42 44 #include "EventNames.h" 43 45 #include "FloatPoint.h" … … 560 562 newSelection = VisibleSelection(visiblePos); 561 563 562 return updateSelectionForMouseDownDispatchingSelectStart(innerNode, newSelection, granularity); 564 bool handled = updateSelectionForMouseDownDispatchingSelectStart(innerNode, newSelection, granularity); 565 566 if (event.event().button() == MiddleButton) { 567 // Ignore handled, since we want to paste to where the caret was placed anyway. 568 handled = handlePasteGlobalSelection(event.event()) || handled; 569 } 570 return handled; 563 571 } 564 572 … … 904 912 905 913 m_frame->selection()->selectFrameElementInParentIfFullySelected(); 914 915 if (event.event().button() == MiddleButton) { 916 // Ignore handled, since we want to paste to where the caret was placed anyway. 917 handled = handlePasteGlobalSelection(event.event()) || handled; 918 } 906 919 907 920 return handled; … … 1897 1910 } 1898 1911 1912 bool EventHandler::handlePasteGlobalSelection(const PlatformMouseEvent& mouseEvent) 1913 { 1914 // If the event was a middle click, attempt to copy global selection in after 1915 // the newly set caret position. 1916 // 1917 // This code is called from either the mouse up or mouse down handling. There 1918 // is some debate about when the global selection is pasted: 1919 // xterm: pastes on up. 1920 // GTK: pastes on down. 1921 // Qt: pastes on up. 1922 // Firefox: pastes on up. 1923 // Chromium: pastes on up. 1924 // 1925 // There is something of a webcompat angle to this well, as highlighted by 1926 // crbug.com/14608. Pages can clear text boxes 'onclick' and, if we paste on 1927 // down then the text is pasted just before the onclick handler runs and 1928 // clears the text box. So it's important this happens after the event 1929 // handlers have been fired. 1930 #if PLATFORM(GTK) 1931 if (mouseEvent.type() != PlatformEvent::MousePressed) 1932 return false; 1933 #else 1934 if (mouseEvent.type() != PlatformEvent::MouseReleased) 1935 return false; 1936 #endif 1937 1938 Frame* focusFrame = m_frame->page()->focusController()->focusedOrMainFrame(); 1939 // Do not paste here if the focus was moved somewhere else. 1940 if (m_frame == focusFrame && m_frame->editor()->client()->supportsGlobalSelection()) 1941 return m_frame->editor()->command(AtomicString("PasteGlobalSelection")).execute(); 1942 1943 return false; 1944 } 1945 1946 1899 1947 #if ENABLE(DRAG_SUPPORT) 1900 1948 bool EventHandler::dispatchDragEvent(const AtomicString& eventType, Node* dragTarget, const PlatformMouseEvent& event, Clipboard* clipboard) -
trunk/Source/WebCore/page/EventHandler.h
r128403 r129750 161 161 bool handleWheelEvent(const PlatformWheelEvent&); 162 162 void defaultWheelEventHandler(Node*, WheelEvent*); 163 bool handlePasteGlobalSelection(const PlatformMouseEvent&); 163 164 164 165 #if ENABLE(GESTURE_EVENTS) -
trunk/Source/WebKit/chromium/ChangeLog
r129749 r129750 1 2012-09-27 Allan Sandfeld Jensen <allan.jensen@digia.com> 2 3 Unify event handling of middle mouse button. 4 https://bugs.webkit.org/show_bug.cgi?id=97690 5 6 Reviewed by Tony Chang. 7 8 Remove port specific handling of middle mouse button press. 9 10 * src/WebViewImpl.cpp: 11 (WebKit::WebViewImpl::handleMouseUp): 12 1 13 2012-09-27 Tommy Widenflycht <tommyw@google.com> 2 14 -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r129545 r129750 93 93 #include "PagePopupClient.h" 94 94 #include "PageWidgetDelegate.h" 95 #include "Pasteboard.h"96 95 #include "PlatformContextSkia.h" 97 96 #include "PlatformKeyboardEvent.h" … … 623 622 void WebViewImpl::handleMouseUp(Frame& mainFrame, const WebMouseEvent& event) 624 623 { 625 #if OS(UNIX) && !OS(DARWIN)626 // If the event was a middle click, attempt to copy text into the focused627 // frame. We execute this before we let the page have a go at the event628 // because the page may change what is focused during in its event handler.629 //630 // This code is in the mouse up handler. There is some debate about putting631 // this here, as opposed to the mouse down handler.632 // xterm: pastes on up.633 // GTK: pastes on down.634 // Firefox: pastes on up.635 // Midori: couldn't paste at all with 0.1.2636 //637 // There is something of a webcompat angle to this well, as highlighted by638 // crbug.com/14608. Pages can clear text boxes 'onclick' and, if we paste on639 // down then the text is pasted just before the onclick handler runs and640 // clears the text box. So it's important this happens after the641 // handleMouseReleaseEvent() earlier in this function642 if (event.button == WebMouseEvent::ButtonMiddle) {643 Frame* focused = focusedWebCoreFrame();644 FrameView* view = m_page->mainFrame()->view();645 IntPoint clickPoint(m_lastMouseDownPoint.x, m_lastMouseDownPoint.y);646 IntPoint contentPoint = view->windowToContents(clickPoint);647 HitTestResult hitTestResult = focused->eventHandler()->hitTestResultAtPoint(contentPoint, false, false, ShouldHitTestScrollbars);648 // We don't want to send a paste when middle clicking a scroll bar or a649 // link (which will navigate later in the code). The main scrollbars650 // have to be handled separately.651 if (!hitTestResult.scrollbar() && !hitTestResult.isLiveLink() && focused && !view->scrollbarAtPoint(clickPoint)) {652 Editor* editor = focused->editor();653 editor->command(AtomicString("PasteGlobalSelection")).execute();654 }655 }656 #endif657 658 624 PageWidgetEventHandler::handleMouseUp(mainFrame, event); 659 625 -
trunk/Source/WebKit/gtk/ChangeLog
r129724 r129750 1 2012-09-27 Allan Sandfeld Jensen <allan.jensen@digia.com> 2 3 Unify event handling of middle mouse button. 4 https://bugs.webkit.org/show_bug.cgi?id=97690 5 6 Reviewed by Tony Chang. 7 8 Remove port specific handling of middle mouse button press. 9 10 * WebCoreSupport/EditorClientGtk.cpp: 11 (WebKit::EditorClient::supportsGlobalSelection): 12 * WebCoreSupport/EditorClientGtk.h: 13 (EditorClient): 14 * webkit/webkitwebview.cpp: 15 (webkit_web_view_button_press_event): 16 1 17 2012-09-26 Gustavo Noronha Silva <gns@gnome.org> 2 18 -
trunk/Source/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp
r124177 r129750 561 561 } 562 562 563 } 563 bool EditorClient::supportsGlobalSelection() 564 { 565 #if PLATFORM(X11) 566 return true; 567 #else 568 return false; 569 #endif 570 } 571 572 } -
trunk/Source/WebKit/gtk/WebCoreSupport/EditorClientGtk.h
r118010 r129750 135 135 virtual bool shouldShowUnicodeMenu(); 136 136 137 virtual bool supportsGlobalSelection() OVERRIDE; 138 137 139 private: 138 140 #if ENABLE(SPELLCHECK) -
trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp
r129724 r129750 746 746 priv->imFilter.notifyMouseButtonPress(); 747 747 gboolean result = frame->eventHandler()->handleMousePressEvent(platformEvent); 748 749 #if PLATFORM(X11)750 /* Copy selection to the X11 selection clipboard */751 if (event->button == 2) {752 PasteboardHelper* helper = PasteboardHelper::defaultPasteboardHelper();753 bool wasUsingPrimary = helper->usePrimarySelectionClipboard();754 helper->setUsePrimarySelectionClipboard(true);755 756 Editor* editor = webView->priv->corePage->focusController()->focusedOrMainFrame()->editor();757 result = result || editor->canPaste() || editor->canDHTMLPaste();758 editor->paste();759 760 helper->setUsePrimarySelectionClipboard(wasUsingPrimary);761 }762 #endif763 748 764 749 return result; -
trunk/Source/WebKit/qt/Api/qwebpage.cpp
r129545 r129750 758 758 } 759 759 760 void QWebPagePrivate::handleClipboard(QEvent* ev, Qt::MouseButton button)761 {762 #ifndef QT_NO_CLIPBOARD763 if (QApplication::clipboard()->supportsSelection()) {764 WebCore::Frame* focusFrame = page->focusController()->focusedOrMainFrame();765 if (button == Qt::MidButton) {766 if (focusFrame) {767 focusFrame->editor()->command(AtomicString("PasteGlobalSelection")).execute();768 ev->setAccepted(true);769 }770 }771 }772 #endif773 }774 775 760 template<class T> 776 761 void QWebPagePrivate::mouseReleaseEvent(T *ev) … … 788 773 ev->setAccepted(accepted); 789 774 790 if (!ev->isAccepted())791 handleClipboard(ev, ev->button());792 775 handleSoftwareInputPanel(ev->button(), QPointF(ev->pos()).toPoint()); 793 776 } -
trunk/Source/WebKit/qt/Api/qwebpage_p.h
r127757 r129750 128 128 void shortcutOverrideEvent(QKeyEvent*); 129 129 void leaveEvent(QEvent*); 130 void handleClipboard(QEvent*, Qt::MouseButton);131 130 void handleSoftwareInputPanel(Qt::MouseButton, const QPoint&); 132 131 bool handleScrolling(QKeyEvent*, WebCore::Frame*); -
trunk/Source/WebKit/qt/ChangeLog
r129609 r129750 1 2012-09-27 Allan Sandfeld Jensen <allan.jensen@digia.com> 2 3 Unify event handling of middle mouse button. 4 https://bugs.webkit.org/show_bug.cgi?id=97690 5 6 Reviewed by Tony Chang. 7 8 Remove port specific handling of middle mouse button press. 9 10 * Api/qwebpage.cpp: 11 (QWebPagePrivate::mouseReleaseEvent): 12 * Api/qwebpage_p.h: 13 (QWebPagePrivate): 14 1 15 2012-09-26 Simon Hausmann <simon.hausmann@digia.com> 2 16 -
trunk/Source/WebKit2/ChangeLog
r129743 r129750 1 2012-09-27 Allan Sandfeld Jensen <allan.jensen@digia.com> 2 3 Unify event handling of middle mouse button. 4 https://bugs.webkit.org/show_bug.cgi?id=97690 5 6 Reviewed by Tony Chang. 7 8 Remove Qt and GTK port specific handling of middle mouse button press. 9 10 * WebProcess/WebPage/WebPage.cpp: 11 (WebKit::handleMouseEvent): 12 * WebProcess/WebPage/WebPage.h: 13 (WebPage): 14 * WebProcess/WebPage/gtk/WebPageGtk.cpp: 15 (WebKit): 16 * WebProcess/WebPage/qt/WebPageQt.cpp: 17 1 18 2012-09-27 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> 2 19 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r129596 r129750 1365 1365 handled = handleContextMenuEvent(platformMouseEvent, page); 1366 1366 #endif 1367 #if PLATFORM(GTK)1368 bool gtkMouseButtonPressHandled = page->handleMousePressedEvent(platformMouseEvent);1369 handled = handled || gtkMouseButtonPressHandled;1370 #endif1371 1372 1367 return handled; 1373 1368 } 1374 case PlatformEvent::MouseReleased: { 1375 bool handled = frame->eventHandler()->handleMouseReleaseEvent(platformMouseEvent); 1376 #if PLATFORM(QT) 1377 if (!handled) 1378 handled = page->handleMouseReleaseEvent(platformMouseEvent); 1379 #endif 1380 return handled; 1381 } 1369 case PlatformEvent::MouseReleased: 1370 return frame->eventHandler()->handleMouseReleaseEvent(platformMouseEvent); 1371 1382 1372 case PlatformEvent::MouseMoved: 1383 1373 if (onlyUpdateScrollbars) -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r129651 r129750 458 458 #elif PLATFORM(GTK) 459 459 void updateAccessibilityTree(); 460 bool handleMousePressedEvent(const WebCore::PlatformMouseEvent&);461 460 #if USE(TEXTURE_MAPPER_GL) 462 461 void setAcceleratedCompositingWindowId(int64_t nativeWindowHandle); 463 462 #endif 464 #endif465 466 #if PLATFORM(QT)467 bool handleMouseReleaseEvent(const WebCore::PlatformMouseEvent&);468 463 #endif 469 464 -
trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp
r129651 r129750 163 163 #endif 164 164 165 bool WebPage::handleMousePressedEvent(const PlatformMouseEvent& platformMouseEvent)166 {167 bool returnValue = false;168 if (platformMouseEvent.button() != WebCore::MiddleButton)169 return returnValue;170 171 #if PLATFORM(X11)172 Frame* frame = m_page->focusController()->focusedOrMainFrame();173 if (!frame)174 return returnValue;175 176 PasteboardHelper* pasteboardHelper = PasteboardHelper::defaultPasteboardHelper();177 bool wasUsingPrimary = pasteboardHelper->usePrimarySelectionClipboard();178 pasteboardHelper->setUsePrimarySelectionClipboard(true);179 180 Editor* editor = frame->editor();181 returnValue = editor->canPaste() || editor->canDHTMLPaste();182 editor->paste();183 184 pasteboardHelper->setUsePrimarySelectionClipboard(wasUsingPrimary);185 #endif186 187 return returnValue;188 }189 190 165 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp
r128040 r129750 441 441 } 442 442 443 bool WebPage::handleMouseReleaseEvent(const PlatformMouseEvent& platformMouseEvent)444 {445 #ifndef QT_NO_CLIPBOARD446 if (platformMouseEvent.button() != WebCore::MiddleButton)447 return false;448 449 if (qApp->clipboard()->supportsSelection()) {450 WebCore::Frame* focusFrame = m_page->focusController()->focusedOrMainFrame();451 if (focusFrame) {452 focusFrame->editor()->command(AtomicString("PasteGlobalSelection")).execute();453 return true;454 }455 }456 #endif457 return false;458 }459 460 443 } // namespace WebKit
Note: See TracChangeset
for help on using the changeset viewer.