Changeset 85214 in webkit
- Timestamp:
- Apr 28, 2011 11:37:33 AM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r85213 r85214 1 2011-04-28 Martin Robinson <mrobinson@igalia.com> 2 3 Reviewed by Xan Lopez. 4 5 [GTK] Click counting logic should be shared between WebKit1 and WebKit2 6 https://bugs.webkit.org/show_bug.cgi?id=59715 7 8 Added a GtkClickCounter class which is just the logic from WebKit1 pushed down 9 into WebCore so that WebKit1 and WebKit2 can share the code. 10 11 No new tests. This is covered by fast/events/click-count.html. 12 13 * GNUmakefile.list.am: Added new files. 14 * platform/gtk/GtkClickCounter.cpp: Added. 15 (WebCore::GtkClickCounter::GtkClickCounter): Added. 16 (WebCore::GtkClickCounter::reset): Added. 17 (WebCore::GtkClickCounter::shouldProcessButtonEvent): Added. 18 (WebCore::getEventTime): Added. 19 (WebCore::GtkClickCounter::clickCountForGdkButtonEvent): Added. 20 * platform/gtk/GtkClickCounter.h: Added. 21 1 22 2011-04-28 Dan Bernstein <mitz@apple.com> 2 23 -
trunk/Source/WebCore/GNUmakefile.list.am
r85180 r85214 3758 3758 Source/WebCore/platform/gtk/FileChooserGtk.cpp \ 3759 3759 Source/WebCore/platform/gtk/FileSystemGtk.cpp \ 3760 Source/WebCore/platform/gtk/GtkClickCounter.cpp \ 3761 Source/WebCore/platform/gtk/GtkClickCounter.h \ 3760 3762 Source/WebCore/platform/gtk/GeolocationServiceGtk.cpp \ 3761 3763 Source/WebCore/platform/gtk/GeolocationServiceGtk.h \ -
trunk/Source/WebKit/gtk/ChangeLog
r85066 r85214 1 2011-04-28 Martin Robinson <mrobinson@igalia.com> 2 3 Reviewed by Xan Lopez. 4 5 [GTK] Click counting logic should be shared between WebKit1 and WebKit2 6 https://bugs.webkit.org/show_bug.cgi?id=59715 7 8 Switch WebKit1 to use the new GtkClickCounter for counting > 3 clicks in a row. 9 This allows the code to be shared between WebKit1 and WebKit2. 10 11 * WebCoreSupport/DragClientGtk.cpp: 12 (WebKit::DragClient::startDrag): Call GtkClickCounter::reset instead of fiddling 13 the WebView private data directly. 14 * WebCoreSupport/FrameLoaderClientGtk.cpp: 15 (WebKit::postCommitFrameViewSetup): Ditto. 16 * webkit/webkitwebview.cpp: 17 (webkit_web_view_button_press_event): Call into GtkClickCounter now. 18 (webkit_web_view_init): Remove private member intialization. 19 * webkit/webkitwebviewprivate.h: Remove unneeded private members. 20 1 21 2011-04-27 Martin Robinson <mrobinson@igalia.com> 2 22 -
trunk/Source/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp
r77870 r85214 112 112 // A drag starting should prevent a double-click from happening. This might 113 113 // happen if a drag is followed very quickly by another click (like in the DRT). 114 webView->priv-> previousClickTime = 0;114 webView->priv->clickCounter.reset(); 115 115 116 116 // This strategy originally comes from Chromium: -
trunk/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
r84260 r85214 1375 1375 1376 1376 // Do not allow click counting between main frame loads. 1377 priv-> previousClickTime = 0;1377 priv->clickCounter.reset(); 1378 1378 } 1379 1379 -
trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp
r83153 r85214 758 758 } 759 759 760 static guint32 getEventTime(GdkEvent* event)761 {762 guint32 time = gdk_event_get_time(event);763 if (time)764 return time;765 766 // Real events always have a non-zero time, but events synthesized767 // by the DRT do not and we must calculate a time manually. This time768 // is not calculated in the DRT, because GTK+ does not work well with769 // anything other than GDK_CURRENT_TIME on synthesized events.770 GTimeVal timeValue;771 g_get_current_time(&timeValue);772 return (timeValue.tv_sec * 1000) + (timeValue.tv_usec / 1000);773 }774 775 760 static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventButton* event) 776 761 { … … 781 766 gtk_widget_grab_focus(widget); 782 767 783 // For double and triple clicks GDK sends both a normal button press event 784 // and a specific type (like GDK_2BUTTON_PRESS). If we detect a special press 785 // coming up, ignore this event as it certainly generated the double or triple 786 // click. The consequence of not eating this event is two DOM button press events 787 // are generated. 788 GOwnPtr<GdkEvent> nextEvent(gdk_event_peek()); 789 if (nextEvent && (nextEvent->any.type == GDK_2BUTTON_PRESS || nextEvent->any.type == GDK_3BUTTON_PRESS)) 768 if (!priv->clickCounter.shouldProcessButtonEvent(event)) 790 769 return TRUE; 791 770 792 gint doubleClickDistance = 250;793 gint doubleClickTime = 5;794 GtkSettings* settings = gtk_settings_get_for_screen(gtk_widget_get_screen(widget));795 g_object_get(settings,796 "gtk-double-click-distance", &doubleClickDistance,797 "gtk-double-click-time", &doubleClickTime, NULL);798 799 // GTK+ only counts up to triple clicks, but WebCore wants to know about800 // quadruple clicks, quintuple clicks, ad infinitum. Here, we replicate the801 // GDK logic for counting clicks.802 guint32 eventTime = getEventTime(reinterpret_cast<GdkEvent*>(event));803 if ((event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS)804 || ((abs(event->x - priv->previousClickPoint.x()) < doubleClickDistance)805 && (abs(event->y - priv->previousClickPoint.y()) < doubleClickDistance)806 && (eventTime - priv->previousClickTime < static_cast<guint>(doubleClickTime))807 && (event->button == priv->previousClickButton)))808 priv->currentClickCount++;809 else810 priv->currentClickCount = 1;811 812 771 PlatformMouseEvent platformEvent(event); 813 platformEvent.setClickCount(priv->currentClickCount); 814 priv->previousClickPoint = platformEvent.pos(); 815 priv->previousClickButton = event->button; 816 priv->previousClickTime = eventTime; 772 platformEvent.setClickCount(priv->clickCounter.clickCountForGdkButtonEvent(widget, event)); 817 773 818 774 if (event->button == 3) … … 3536 3492 priv->subResources = adoptGRef(g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref)); 3537 3493 3538 priv->currentClickCount = 0;3539 priv->previousClickButton = 0;3540 priv->previousClickTime = 0;3541 3494 gtk_drag_dest_set(GTK_WIDGET(webView), static_cast<GtkDestDefaults>(0), 0, 0, static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_PRIVATE)); 3542 3495 gtk_drag_dest_set_target_list(GTK_WIDGET(webView), pasteboardHelperInstance()->targetList()); -
trunk/Source/WebKit/gtk/webkit/webkitwebviewprivate.h
r79953 r85214 26 26 #include "DataObjectGtk.h" 27 27 #include "FullscreenVideoController.h" 28 #include "GtkClickCounter.h" 28 29 #include "GOwnPtr.h" 29 30 #include "ResourceHandle.h" … … 102 103 WebCore::IntRect tooltipArea; 103 104 104 int currentClickCount; 105 WebCore::IntPoint previousClickPoint; 106 guint previousClickButton; 107 guint32 previousClickTime; 105 WebCore::GtkClickCounter clickCounter; 108 106 HashMap<GdkDragContext*, RefPtr<WebCore::DataObjectGtk> > draggingDataObjects; 109 107 HashMap<GdkDragContext*, WebKit::DroppingContext*> droppingContexts; -
trunk/Source/WebKit2/ChangeLog
r85208 r85214 1 2011-04-28 Martin Robinson <mrobinson@igalia.com> 2 3 Reviewed by Xan Lopez. 4 5 [GTK] Click counting logic should be shared between WebKit1 and WebKit2 6 https://bugs.webkit.org/show_bug.cgi?id=59715 7 8 Use the GtkClickCounter instead of doing click counting manually. This means that 9 the code will now be shared between WebKit1 and WebKit2. 10 11 * UIProcess/API/gtk/WebKitWebViewBase.cpp: 12 (webkit_web_view_base_init): Remove private member initialization. 13 (webViewButtonPressEvent): Call into GtkClickCounter. 14 1 15 2011-04-28 Martin Robinson <mrobinson@igalia.com> 2 16 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
r85208 r85214 30 30 31 31 #include "GOwnPtrGtk.h" 32 #include "GtkClickCounter.h" 32 33 #include "GtkVersioning.h" 33 34 #include "NativeWebKeyboardEvent.h" … … 50 51 gboolean isPageActive; 51 52 GtkIMContext* imContext; 52 gint currentClickCount; 53 IntPoint previousClickPoint; 54 guint previousClickButton; 55 guint32 previousClickTime; 53 GtkClickCounter clickCounter; 56 54 }; 57 55 … … 144 142 gtk_widget_set_can_focus(GTK_WIDGET(webkitWebViewBase), TRUE); 145 143 priv->imContext = gtk_im_multicontext_new(); 146 147 priv->currentClickCount = 0;148 priv->previousClickButton = 0;149 priv->previousClickTime = 0;150 151 priv->pageClient = PageClientImpl::create(GTK_WIDGET(webkitWebViewBase));152 144 } 153 145 … … 242 234 } 243 235 244 // Copied from webkitwebview.cpp245 static guint32 getEventTime(GdkEvent* event)246 {247 guint32 time = gdk_event_get_time(event);248 if (time)249 return time;250 251 // Real events always have a non-zero time, but events synthesized252 // by the DRT do not and we must calculate a time manually. This time253 // is not calculated in the DRT, because GTK+ does not work well with254 // anything other than GDK_CURRENT_TIME on synthesized events.255 GTimeVal timeValue;256 g_get_current_time(&timeValue);257 return (timeValue.tv_sec * 1000) + (timeValue.tv_usec / 1000);258 }259 260 236 static gboolean webViewButtonPressEvent(GtkWidget* widget, GdkEventButton* buttonEvent) 261 237 { 262 if (buttonEvent->button == 3) { 263 // FIXME: [GTK] Add context menu support for Webkit2. 264 // https://bugs.webkit.org/show_bug.cgi?id=54827 265 notImplemented(); 266 return FALSE; 267 } 268 238 WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); 239 WebKitWebViewBasePrivate* priv = webViewBase->priv; 269 240 gtk_widget_grab_focus(widget); 270 241 271 // For double and triple clicks GDK sends both a normal button press event 272 // and a specific type (like GDK_2BUTTON_PRESS). If we detect a special press 273 // coming up, ignore this event as it certainly generated the double or triple 274 // click. The consequence of not eating this event is two DOM button press events 275 // are generated. 276 GOwnPtr<GdkEvent> nextEvent(gdk_event_peek()); 277 if (nextEvent && (nextEvent->any.type == GDK_2BUTTON_PRESS || nextEvent->any.type == GDK_3BUTTON_PRESS)) 242 if (!priv->clickCounter.shouldProcessButtonEvent(buttonEvent)) 278 243 return TRUE; 279 280 gint doubleClickDistance = 250; 281 gint doubleClickTime = 5; 282 GtkSettings* settings = gtk_settings_get_for_screen(gtk_widget_get_screen(widget)); 283 g_object_get(settings, 284 "gtk-double-click-distance", &doubleClickDistance, 285 "gtk-double-click-time", &doubleClickTime, NULL); 286 287 // GTK+ only counts up to triple clicks, but WebCore wants to know about 288 // quadruple clicks, quintuple clicks, ad infinitum. Here, we replicate the 289 // GDK logic for counting clicks. 290 GdkEvent* event(reinterpret_cast<GdkEvent*>(buttonEvent)); 291 guint32 eventTime = getEventTime(event); 292 WebKitWebViewBase* webkitWebViewBase = WEBKIT_WEB_VIEW_BASE(widget); 293 WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv; 294 if ((event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) 295 || ((abs(buttonEvent->x - priv->previousClickPoint.x()) < doubleClickDistance) 296 && (abs(buttonEvent->y - priv->previousClickPoint.y()) < doubleClickDistance) 297 && (eventTime - priv->previousClickTime < static_cast<guint>(doubleClickTime)) 298 && (buttonEvent->button == priv->previousClickButton))) 299 priv->currentClickCount++; 300 else 301 priv->currentClickCount = 1; 302 303 priv->page->handleMouseEvent(NativeWebMouseEvent(event, priv->currentClickCount)); 304 305 gdouble x, y; 306 gdk_event_get_coords(event, &x, &y); 307 priv->previousClickPoint = IntPoint(x, y); 308 priv->previousClickButton = buttonEvent->button; 309 priv->previousClickTime = eventTime; 310 244 priv->page->handleMouseEvent(NativeWebMouseEvent(reinterpret_cast<GdkEvent*>(buttonEvent), 245 priv->clickCounter.clickCountForGdkButtonEvent(widget, buttonEvent))); 311 246 return FALSE; 312 247 }
Note: See TracChangeset
for help on using the changeset viewer.