Changeset 129750 in webkit


Ignore:
Timestamp:
Sep 27, 2012 4:12:11 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Unify event handling of middle mouse button.
https://bugs.webkit.org/show_bug.cgi?id=97690

Patch by Allan Sandfeld Jensen <allan.jensen@digia.com> on 2012-09-27
Reviewed by Tony Chang.

Source/WebCore:

Implement a unified version of middle mouse button press that can be shared between
all the ports with X11 support.

  • page/EventHandler.cpp:

(WebCore::EventHandler::handleMousePressEventSingleClick):
(WebCore::EventHandler::handleMouseReleaseEvent):
(WebCore::EventHandler::handlePasteGlobalSelection):

  • page/EventHandler.h:

(EventHandler):

Source/WebKit/chromium:

Remove port specific handling of middle mouse button press.

  • src/WebViewImpl.cpp:

(WebKit::WebViewImpl::handleMouseUp):

Source/WebKit/gtk:

Remove port specific handling of middle mouse button press.

  • WebCoreSupport/EditorClientGtk.cpp:

(WebKit::EditorClient::supportsGlobalSelection):

  • WebCoreSupport/EditorClientGtk.h:

(EditorClient):

  • webkit/webkitwebview.cpp:

(webkit_web_view_button_press_event):

Source/WebKit/qt:

Remove port specific handling of middle mouse button press.

  • Api/qwebpage.cpp:

(QWebPagePrivate::mouseReleaseEvent):

  • Api/qwebpage_p.h:

(QWebPagePrivate):

Source/WebKit2:

Remove Qt and GTK port specific handling of middle mouse button press.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::handleMouseEvent):

  • WebProcess/WebPage/WebPage.h:

(WebPage):

  • WebProcess/WebPage/gtk/WebPageGtk.cpp:

(WebKit):

  • WebProcess/WebPage/qt/WebPageQt.cpp:
Location:
trunk/Source
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r129749 r129750  
     12012-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
    1182012-09-27  Tommy Widenflycht  <tommyw@google.com>
    219
  • trunk/Source/WebCore/page/EventHandler.cpp

    r128999 r129750  
    22 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
    33 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
     4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    4041#include "DragState.h"
    4142#include "Editor.h"
     43#include "EditorClient.h"
    4244#include "EventNames.h"
    4345#include "FloatPoint.h"
     
    560562        newSelection = VisibleSelection(visiblePos);
    561563   
    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;
    563571}
    564572
     
    904912
    905913    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    }
    906919
    907920    return handled;
     
    18971910}
    18981911
     1912bool 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
    18991947#if ENABLE(DRAG_SUPPORT)
    19001948bool EventHandler::dispatchDragEvent(const AtomicString& eventType, Node* dragTarget, const PlatformMouseEvent& event, Clipboard* clipboard)
  • trunk/Source/WebCore/page/EventHandler.h

    r128403 r129750  
    161161    bool handleWheelEvent(const PlatformWheelEvent&);
    162162    void defaultWheelEventHandler(Node*, WheelEvent*);
     163    bool handlePasteGlobalSelection(const PlatformMouseEvent&);
    163164
    164165#if ENABLE(GESTURE_EVENTS)
  • trunk/Source/WebKit/chromium/ChangeLog

    r129749 r129750  
     12012-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
    1132012-09-27  Tommy Widenflycht  <tommyw@google.com>
    214
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r129545 r129750  
    9393#include "PagePopupClient.h"
    9494#include "PageWidgetDelegate.h"
    95 #include "Pasteboard.h"
    9695#include "PlatformContextSkia.h"
    9796#include "PlatformKeyboardEvent.h"
     
    623622void WebViewImpl::handleMouseUp(Frame& mainFrame, const WebMouseEvent& event)
    624623{
    625 #if OS(UNIX) && !OS(DARWIN)
    626     // If the event was a middle click, attempt to copy text into the focused
    627     // frame. We execute this before we let the page have a go at the event
    628     // 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 putting
    631     // 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.2
    636     //
    637     // There is something of a webcompat angle to this well, as highlighted by
    638     // crbug.com/14608. Pages can clear text boxes 'onclick' and, if we paste on
    639     // down then the text is pasted just before the onclick handler runs and
    640     // clears the text box. So it's important this happens after the
    641     // handleMouseReleaseEvent() earlier in this function
    642     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 a
    649         // link (which will navigate later in the code).  The main scrollbars
    650         // 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 #endif
    657 
    658624    PageWidgetEventHandler::handleMouseUp(mainFrame, event);
    659625
  • trunk/Source/WebKit/gtk/ChangeLog

    r129724 r129750  
     12012-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
    1172012-09-26  Gustavo Noronha Silva  <gns@gnome.org>
    218
  • trunk/Source/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp

    r124177 r129750  
    561561}
    562562
    563 }
     563bool 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  
    135135        virtual bool shouldShowUnicodeMenu();
    136136
     137        virtual bool supportsGlobalSelection() OVERRIDE;
     138
    137139    private:
    138140#if ENABLE(SPELLCHECK)
  • trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp

    r129724 r129750  
    746746    priv->imFilter.notifyMouseButtonPress();
    747747    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 #endif
    763748
    764749    return result;
  • trunk/Source/WebKit/qt/Api/qwebpage.cpp

    r129545 r129750  
    758758}
    759759
    760 void QWebPagePrivate::handleClipboard(QEvent* ev, Qt::MouseButton button)
    761 {
    762 #ifndef QT_NO_CLIPBOARD
    763     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 #endif
    773 }
    774 
    775760template<class T>
    776761void QWebPagePrivate::mouseReleaseEvent(T *ev)
     
    788773    ev->setAccepted(accepted);
    789774
    790     if (!ev->isAccepted())
    791         handleClipboard(ev, ev->button());
    792775    handleSoftwareInputPanel(ev->button(), QPointF(ev->pos()).toPoint());
    793776}
  • trunk/Source/WebKit/qt/Api/qwebpage_p.h

    r127757 r129750  
    128128    void shortcutOverrideEvent(QKeyEvent*);
    129129    void leaveEvent(QEvent*);
    130     void handleClipboard(QEvent*, Qt::MouseButton);
    131130    void handleSoftwareInputPanel(Qt::MouseButton, const QPoint&);
    132131    bool handleScrolling(QKeyEvent*, WebCore::Frame*);
  • trunk/Source/WebKit/qt/ChangeLog

    r129609 r129750  
     12012-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
    1152012-09-26  Simon Hausmann  <simon.hausmann@digia.com>
    216
  • trunk/Source/WebKit2/ChangeLog

    r129743 r129750  
     12012-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
    1182012-09-27  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
    219
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r129596 r129750  
    13651365                handled = handleContextMenuEvent(platformMouseEvent, page);
    13661366#endif
    1367 #if PLATFORM(GTK)
    1368             bool gtkMouseButtonPressHandled = page->handleMousePressedEvent(platformMouseEvent);
    1369             handled = handled || gtkMouseButtonPressHandled;
    1370 #endif
    1371 
    13721367            return handled;
    13731368        }
    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
    13821372        case PlatformEvent::MouseMoved:
    13831373            if (onlyUpdateScrollbars)
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r129651 r129750  
    458458#elif PLATFORM(GTK)
    459459    void updateAccessibilityTree();
    460     bool handleMousePressedEvent(const WebCore::PlatformMouseEvent&);
    461460#if USE(TEXTURE_MAPPER_GL)
    462461    void setAcceleratedCompositingWindowId(int64_t nativeWindowHandle);
    463462#endif
    464 #endif
    465 
    466 #if PLATFORM(QT)
    467     bool handleMouseReleaseEvent(const WebCore::PlatformMouseEvent&);
    468463#endif
    469464
  • trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp

    r129651 r129750  
    163163#endif
    164164
    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 #endif
    186 
    187     return returnValue;
    188 }
    189 
    190165} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp

    r128040 r129750  
    441441}
    442442
    443 bool WebPage::handleMouseReleaseEvent(const PlatformMouseEvent& platformMouseEvent)
    444 {
    445 #ifndef QT_NO_CLIPBOARD
    446     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 #endif
    457     return false;
    458 }
    459 
    460443} // namespace WebKit
Note: See TracChangeset for help on using the changeset viewer.