Title: [129750] trunk/Source
Revision
129750
Author
commit-qu...@webkit.org
Date
2012-09-27 04:12:11 -0700 (Thu, 27 Sep 2012)

Log Message

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

Patch by Allan Sandfeld Jensen <allan.jen...@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:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (129749 => 129750)


--- trunk/Source/WebCore/ChangeLog	2012-09-27 11:07:12 UTC (rev 129749)
+++ trunk/Source/WebCore/ChangeLog	2012-09-27 11:12:11 UTC (rev 129750)
@@ -1,3 +1,20 @@
+2012-09-27  Allan Sandfeld Jensen  <allan.jen...@digia.com>
+
+        Unify event handling of middle mouse button.
+        https://bugs.webkit.org/show_bug.cgi?id=97690
+
+        Reviewed by Tony Chang.
+
+        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):
+
 2012-09-27  Tommy Widenflycht  <tom...@google.com>
 
         MediaStream API: Update getUserMedia to match the latest specification

Modified: trunk/Source/WebCore/page/EventHandler.cpp (129749 => 129750)


--- trunk/Source/WebCore/page/EventHandler.cpp	2012-09-27 11:07:12 UTC (rev 129749)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2012-09-27 11:12:11 UTC (rev 129750)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
  * Copyright (C) 2006 Alexey Proskuryakov (a...@webkit.org)
+ * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -39,6 +40,7 @@
 #include "DragController.h"
 #include "DragState.h"
 #include "Editor.h"
+#include "EditorClient.h"
 #include "EventNames.h"
 #include "FloatPoint.h"
 #include "FloatRect.h"
@@ -559,7 +561,13 @@
     } else
         newSelection = VisibleSelection(visiblePos);
     
-    return updateSelectionForMouseDownDispatchingSelectStart(innerNode, newSelection, granularity);
+    bool handled = updateSelectionForMouseDownDispatchingSelectStart(innerNode, newSelection, granularity);
+
+    if (event.event().button() == MiddleButton) {
+        // Ignore handled, since we want to paste to where the caret was placed anyway.
+        handled = handlePasteGlobalSelection(event.event()) || handled;
+    }
+    return handled;
 }
 
 static inline bool canMouseDownStartSelect(Node* node)
@@ -904,6 +912,11 @@
 
     m_frame->selection()->selectFrameElementInParentIfFullySelected();
 
+    if (event.event().button() == MiddleButton) {
+        // Ignore handled, since we want to paste to where the caret was placed anyway.
+        handled = handlePasteGlobalSelection(event.event()) || handled;
+    }
+
     return handled;
 }
 
@@ -1896,6 +1909,41 @@
     return swallowMouseUpEvent || swallowClickEvent || swallowMouseReleaseEvent;
 }
 
+bool EventHandler::handlePasteGlobalSelection(const PlatformMouseEvent& mouseEvent)
+{
+    // If the event was a middle click, attempt to copy global selection in after
+    // the newly set caret position.
+    //
+    // This code is called from either the mouse up or mouse down handling. There
+    // is some debate about when the global selection is pasted:
+    //   xterm: pastes on up.
+    //   GTK: pastes on down.
+    //   Qt: pastes on up.
+    //   Firefox: pastes on up.
+    //   Chromium: pastes on up.
+    //
+    // There is something of a webcompat angle to this well, as highlighted by
+    // crbug.com/14608. Pages can clear text boxes 'onclick' and, if we paste on
+    // down then the text is pasted just before the onclick handler runs and
+    // clears the text box. So it's important this happens after the event
+    // handlers have been fired.
+#if PLATFORM(GTK)
+    if (mouseEvent.type() != PlatformEvent::MousePressed)
+        return false;
+#else
+    if (mouseEvent.type() != PlatformEvent::MouseReleased)
+        return false;
+#endif
+
+    Frame* focusFrame = m_frame->page()->focusController()->focusedOrMainFrame();
+    // Do not paste here if the focus was moved somewhere else.
+    if (m_frame == focusFrame && m_frame->editor()->client()->supportsGlobalSelection())
+        return m_frame->editor()->command(AtomicString("PasteGlobalSelection")).execute();
+
+    return false;
+}
+
+
 #if ENABLE(DRAG_SUPPORT)
 bool EventHandler::dispatchDragEvent(const AtomicString& eventType, Node* dragTarget, const PlatformMouseEvent& event, Clipboard* clipboard)
 {

Modified: trunk/Source/WebCore/page/EventHandler.h (129749 => 129750)


--- trunk/Source/WebCore/page/EventHandler.h	2012-09-27 11:07:12 UTC (rev 129749)
+++ trunk/Source/WebCore/page/EventHandler.h	2012-09-27 11:12:11 UTC (rev 129750)
@@ -160,6 +160,7 @@
     bool handleMouseReleaseEvent(const PlatformMouseEvent&);
     bool handleWheelEvent(const PlatformWheelEvent&);
     void defaultWheelEventHandler(Node*, WheelEvent*);
+    bool handlePasteGlobalSelection(const PlatformMouseEvent&);
 
 #if ENABLE(GESTURE_EVENTS)
     bool handleGestureEvent(const PlatformGestureEvent&);

Modified: trunk/Source/WebKit/chromium/ChangeLog (129749 => 129750)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-09-27 11:07:12 UTC (rev 129749)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-09-27 11:12:11 UTC (rev 129750)
@@ -1,3 +1,15 @@
+2012-09-27  Allan Sandfeld Jensen  <allan.jen...@digia.com>
+
+        Unify event handling of middle mouse button.
+        https://bugs.webkit.org/show_bug.cgi?id=97690
+
+        Reviewed by Tony Chang.
+
+        Remove port specific handling of middle mouse button press.
+
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::handleMouseUp):
+
 2012-09-27  Tommy Widenflycht  <tom...@google.com>
 
         MediaStream API: Update getUserMedia to match the latest specification

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (129749 => 129750)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-09-27 11:07:12 UTC (rev 129749)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-09-27 11:12:11 UTC (rev 129750)
@@ -92,7 +92,6 @@
 #include "PageGroupLoadDeferrer.h"
 #include "PagePopupClient.h"
 #include "PageWidgetDelegate.h"
-#include "Pasteboard.h"
 #include "PlatformContextSkia.h"
 #include "PlatformKeyboardEvent.h"
 #include "PlatformMouseEvent.h"
@@ -622,39 +621,6 @@
 
 void WebViewImpl::handleMouseUp(Frame& mainFrame, const WebMouseEvent& event)
 {
-#if OS(UNIX) && !OS(DARWIN)
-    // If the event was a middle click, attempt to copy text into the focused
-    // frame. We execute this before we let the page have a go at the event
-    // because the page may change what is focused during in its event handler.
-    //
-    // This code is in the mouse up handler. There is some debate about putting
-    // this here, as opposed to the mouse down handler.
-    //   xterm: pastes on up.
-    //   GTK: pastes on down.
-    //   Firefox: pastes on up.
-    //   Midori: couldn't paste at all with 0.1.2
-    //
-    // There is something of a webcompat angle to this well, as highlighted by
-    // crbug.com/14608. Pages can clear text boxes 'onclick' and, if we paste on
-    // down then the text is pasted just before the onclick handler runs and
-    // clears the text box. So it's important this happens after the
-    // handleMouseReleaseEvent() earlier in this function
-    if (event.button == WebMouseEvent::ButtonMiddle) {
-        Frame* focused = focusedWebCoreFrame();
-        FrameView* view = m_page->mainFrame()->view();
-        IntPoint clickPoint(m_lastMouseDownPoint.x, m_lastMouseDownPoint.y);
-        IntPoint contentPoint = view->windowToContents(clickPoint);
-        HitTestResult hitTestResult = focused->eventHandler()->hitTestResultAtPoint(contentPoint, false, false, ShouldHitTestScrollbars);
-        // We don't want to send a paste when middle clicking a scroll bar or a
-        // link (which will navigate later in the code).  The main scrollbars
-        // have to be handled separately.
-        if (!hitTestResult.scrollbar() && !hitTestResult.isLiveLink() && focused && !view->scrollbarAtPoint(clickPoint)) {
-            Editor* editor = focused->editor();
-            editor->command(AtomicString("PasteGlobalSelection")).execute();
-        }
-    }
-#endif
-
     PageWidgetEventHandler::handleMouseUp(mainFrame, event);
 
 #if OS(WINDOWS)

Modified: trunk/Source/WebKit/gtk/ChangeLog (129749 => 129750)


--- trunk/Source/WebKit/gtk/ChangeLog	2012-09-27 11:07:12 UTC (rev 129749)
+++ trunk/Source/WebKit/gtk/ChangeLog	2012-09-27 11:12:11 UTC (rev 129750)
@@ -1,3 +1,19 @@
+2012-09-27  Allan Sandfeld Jensen  <allan.jen...@digia.com>
+
+        Unify event handling of middle mouse button.
+        https://bugs.webkit.org/show_bug.cgi?id=97690
+
+        Reviewed by Tony Chang.
+
+        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):
+
 2012-09-26  Gustavo Noronha Silva  <g...@gnome.org>
 
         Unreviewed build fix after 129707.

Modified: trunk/Source/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp (129749 => 129750)


--- trunk/Source/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp	2012-09-27 11:07:12 UTC (rev 129749)
+++ trunk/Source/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp	2012-09-27 11:12:11 UTC (rev 129750)
@@ -560,4 +560,13 @@
     return false;
 }
 
+bool EditorClient::supportsGlobalSelection()
+{
+#if PLATFORM(X11)
+    return true;
+#else
+    return false;
+#endif
 }
+
+}

Modified: trunk/Source/WebKit/gtk/WebCoreSupport/EditorClientGtk.h (129749 => 129750)


--- trunk/Source/WebKit/gtk/WebCoreSupport/EditorClientGtk.h	2012-09-27 11:07:12 UTC (rev 129749)
+++ trunk/Source/WebKit/gtk/WebCoreSupport/EditorClientGtk.h	2012-09-27 11:12:11 UTC (rev 129750)
@@ -134,6 +134,8 @@
 
         virtual bool shouldShowUnicodeMenu();
 
+        virtual bool supportsGlobalSelection() OVERRIDE;
+
     private:
 #if ENABLE(SPELLCHECK)
         TextCheckerClientGtk m_textCheckerClient;

Modified: trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp (129749 => 129750)


--- trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp	2012-09-27 11:07:12 UTC (rev 129749)
+++ trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp	2012-09-27 11:12:11 UTC (rev 129750)
@@ -746,21 +746,6 @@
     priv->imFilter.notifyMouseButtonPress();
     gboolean result = frame->eventHandler()->handleMousePressEvent(platformEvent);
 
-#if PLATFORM(X11)
-    /* Copy selection to the X11 selection clipboard */
-    if (event->button == 2) {
-        PasteboardHelper* helper = PasteboardHelper::defaultPasteboardHelper();
-        bool wasUsingPrimary = helper->usePrimarySelectionClipboard();
-        helper->setUsePrimarySelectionClipboard(true);
-
-        Editor* editor = webView->priv->corePage->focusController()->focusedOrMainFrame()->editor();
-        result = result || editor->canPaste() || editor->canDHTMLPaste();
-        editor->paste();
-
-        helper->setUsePrimarySelectionClipboard(wasUsingPrimary);
-    }
-#endif
-
     return result;
 }
 

Modified: trunk/Source/WebKit/qt/Api/qwebpage.cpp (129749 => 129750)


--- trunk/Source/WebKit/qt/Api/qwebpage.cpp	2012-09-27 11:07:12 UTC (rev 129749)
+++ trunk/Source/WebKit/qt/Api/qwebpage.cpp	2012-09-27 11:12:11 UTC (rev 129750)
@@ -757,21 +757,6 @@
     ev->setAccepted(accepted);
 }
 
-void QWebPagePrivate::handleClipboard(QEvent* ev, Qt::MouseButton button)
-{
-#ifndef QT_NO_CLIPBOARD
-    if (QApplication::clipboard()->supportsSelection()) {
-        WebCore::Frame* focusFrame = page->focusController()->focusedOrMainFrame();
-        if (button == Qt::MidButton) {
-            if (focusFrame) {
-                focusFrame->editor()->command(AtomicString("PasteGlobalSelection")).execute();
-                ev->setAccepted(true);
-            }
-        }
-    }
-#endif
-}
-
 template<class T>
 void QWebPagePrivate::mouseReleaseEvent(T *ev)
 {
@@ -787,8 +772,6 @@
         accepted = frame->eventHandler()->handleMouseReleaseEvent(mev);
     ev->setAccepted(accepted);
 
-    if (!ev->isAccepted())
-        handleClipboard(ev, ev->button());
     handleSoftwareInputPanel(ev->button(), QPointF(ev->pos()).toPoint());
 }
 

Modified: trunk/Source/WebKit/qt/Api/qwebpage_p.h (129749 => 129750)


--- trunk/Source/WebKit/qt/Api/qwebpage_p.h	2012-09-27 11:07:12 UTC (rev 129749)
+++ trunk/Source/WebKit/qt/Api/qwebpage_p.h	2012-09-27 11:12:11 UTC (rev 129750)
@@ -127,7 +127,6 @@
 
     void shortcutOverrideEvent(QKeyEvent*);
     void leaveEvent(QEvent*);
-    void handleClipboard(QEvent*, Qt::MouseButton);
     void handleSoftwareInputPanel(Qt::MouseButton, const QPoint&);
     bool handleScrolling(QKeyEvent*, WebCore::Frame*);
 

Modified: trunk/Source/WebKit/qt/ChangeLog (129749 => 129750)


--- trunk/Source/WebKit/qt/ChangeLog	2012-09-27 11:07:12 UTC (rev 129749)
+++ trunk/Source/WebKit/qt/ChangeLog	2012-09-27 11:12:11 UTC (rev 129750)
@@ -1,3 +1,17 @@
+2012-09-27  Allan Sandfeld Jensen  <allan.jen...@digia.com>
+
+        Unify event handling of middle mouse button.
+        https://bugs.webkit.org/show_bug.cgi?id=97690
+
+        Reviewed by Tony Chang.
+
+        Remove port specific handling of middle mouse button press.
+
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::mouseReleaseEvent):
+        * Api/qwebpage_p.h:
+        (QWebPagePrivate):
+
 2012-09-26  Simon Hausmann  <simon.hausm...@digia.com>
 
         [Qt] Remove Qt Quick 1 support

Modified: trunk/Source/WebKit2/ChangeLog (129749 => 129750)


--- trunk/Source/WebKit2/ChangeLog	2012-09-27 11:07:12 UTC (rev 129749)
+++ trunk/Source/WebKit2/ChangeLog	2012-09-27 11:12:11 UTC (rev 129750)
@@ -1,3 +1,20 @@
+2012-09-27  Allan Sandfeld Jensen  <allan.jen...@digia.com>
+
+        Unify event handling of middle mouse button.
+        https://bugs.webkit.org/show_bug.cgi?id=97690
+
+        Reviewed by Tony Chang.
+
+        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:
+
 2012-09-27  Mikhail Pozdnyakov  <mikhail.pozdnya...@intel.com>
 
         [WK2] Injected bundle API implementation should use toWTFString()

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (129749 => 129750)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-09-27 11:07:12 UTC (rev 129749)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-09-27 11:12:11 UTC (rev 129750)
@@ -1364,21 +1364,11 @@
             if (isContextClick(platformMouseEvent))
                 handled = handleContextMenuEvent(platformMouseEvent, page);
 #endif
-#if PLATFORM(GTK)
-            bool gtkMouseButtonPressHandled = page->handleMousePressedEvent(platformMouseEvent);
-            handled = handled || gtkMouseButtonPressHandled;
-#endif
-
             return handled;
         }
-        case PlatformEvent::MouseReleased: {
-            bool handled = frame->eventHandler()->handleMouseReleaseEvent(platformMouseEvent);
-#if PLATFORM(QT)
-            if (!handled)
-                handled = page->handleMouseReleaseEvent(platformMouseEvent);
-#endif
-            return handled;
-        }
+        case PlatformEvent::MouseReleased:
+            return frame->eventHandler()->handleMouseReleaseEvent(platformMouseEvent);
+
         case PlatformEvent::MouseMoved:
             if (onlyUpdateScrollbars)
                 return frame->eventHandler()->passMouseMovedEventToScrollbars(platformMouseEvent);

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (129749 => 129750)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2012-09-27 11:07:12 UTC (rev 129749)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2012-09-27 11:12:11 UTC (rev 129750)
@@ -457,16 +457,11 @@
 
 #elif PLATFORM(GTK)
     void updateAccessibilityTree();
-    bool handleMousePressedEvent(const WebCore::PlatformMouseEvent&);
 #if USE(TEXTURE_MAPPER_GL)
     void setAcceleratedCompositingWindowId(int64_t nativeWindowHandle);
 #endif
 #endif
 
-#if PLATFORM(QT)
-    bool handleMouseReleaseEvent(const WebCore::PlatformMouseEvent&);
-#endif
-
     void setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length);
     bool hasCompositionForTesting();
     void confirmCompositionForTesting(const String& compositionString);

Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp (129749 => 129750)


--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp	2012-09-27 11:07:12 UTC (rev 129749)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp	2012-09-27 11:12:11 UTC (rev 129750)
@@ -162,29 +162,4 @@
 }
 #endif
 
-bool WebPage::handleMousePressedEvent(const PlatformMouseEvent& platformMouseEvent)
-{
-    bool returnValue = false;
-    if (platformMouseEvent.button() != WebCore::MiddleButton)
-        return returnValue;
-
-#if PLATFORM(X11)
-    Frame* frame = m_page->focusController()->focusedOrMainFrame();
-    if (!frame)
-        return returnValue;
-
-    PasteboardHelper* pasteboardHelper = PasteboardHelper::defaultPasteboardHelper();
-    bool wasUsingPrimary = pasteboardHelper->usePrimarySelectionClipboard();
-    pasteboardHelper->setUsePrimarySelectionClipboard(true);
-
-    Editor* editor = frame->editor();
-    returnValue = editor->canPaste() || editor->canDHTMLPaste();
-    editor->paste();
-
-    pasteboardHelper->setUsePrimarySelectionClipboard(wasUsingPrimary);
-#endif
-
-    return returnValue;
-}
-
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp (129749 => 129750)


--- trunk/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp	2012-09-27 11:07:12 UTC (rev 129749)
+++ trunk/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp	2012-09-27 11:12:11 UTC (rev 129750)
@@ -440,21 +440,4 @@
     m_activePopupMenu = 0;
 }
 
-bool WebPage::handleMouseReleaseEvent(const PlatformMouseEvent& platformMouseEvent)
-{
-#ifndef QT_NO_CLIPBOARD
-    if (platformMouseEvent.button() != WebCore::MiddleButton)
-        return false;
-
-    if (qApp->clipboard()->supportsSelection()) {
-        WebCore::Frame* focusFrame = m_page->focusController()->focusedOrMainFrame();
-        if (focusFrame) {
-            focusFrame->editor()->command(AtomicString("PasteGlobalSelection")).execute();
-            return true;
-        }
-    }
-#endif
-    return false;
-}
-
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to