Changeset 48735 in webkit


Ignore:
Timestamp:
Sep 24, 2009 2:58:59 PM (15 years ago)
Author:
kov@webkit.org
Message:

Implement correct horizontal scrollbar behavior for GTK+

WebCore

2009-09-24 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>

Reviewed by Oliver Hunt.

Implement correct horizontal scrollbar behavior for GTK+ also on
styled scrollbars.

https://bugs.webkit.org/show_bug.cgi?id=29348
[Gtk] Scrollwheel on horizontal scrollbars should slide horizontally

Test: platform/gtk/scrollbars/overflow-scrollbar-horizontal-wheel-scroll.html

  • page/EventHandler.cpp: (WebCore::EventHandler::handleWheelEvent): on GTK+, when using the wheel with the pointer on the horizontal scrollbar, scroll horizontally;
  • platform/PlatformWheelEvent.h:
  • platform/gtk/WheelEventGtk.cpp: (WebCore::PlatformWheelEvent::swapOrientation): allow adding a vertical scroll to the horizontal one;

WebKitTools

2009-09-24 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>

Reviewed by Oliver Hunt.

Add support for DRT to send mouse wheel events.

https://bugs.webkit.org/show_bug.cgi?id=29348
[Gtk] Scrollwheel on horizontal scrollbars should slide horizontally

  • DumpRenderTree/gtk/EventSender.cpp: (mouseWheelToCallback):

LayoutTests

2009-09-24 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>

Reviewed by Oliver Hunt.

Test for correct wheel scrolling behavior.

https://bugs.webkit.org/show_bug.cgi?id=29348
[Gtk] Scrollwheel on horizontal scrollbars should slide horizontally

  • platform/gtk/scrollbars/overflow-scrollbar-horizontal-wheel-scroll.html: Added.
  • platform/gtk/scrollbars/overflow-scrollbar-horizontal-wheel-scroll-expected.txt: Added.
Location:
trunk
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r48724 r48735  
     12009-09-24  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Test for correct wheel scrolling behavior.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=29348
     8        [Gtk] Scrollwheel on horizontal scrollbars should slide horizontally
     9
     10        * platform/gtk/scrollbars/overflow-scrollbar-horizontal-wheel-scroll.html: Added.
     11        * platform/gtk/scrollbars/overflow-scrollbar-horizontal-wheel-scroll-expected.txt: Added.
     12
    1132009-09-24  Philippe Normand  <pnormand@igalia.com>
    214
  • trunk/WebCore/ChangeLog

    r48734 r48735  
     12009-09-24  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Implement correct horizontal scrollbar behavior for GTK+ also on
     6        styled scrollbars.
     7
     8        https://bugs.webkit.org/show_bug.cgi?id=29348
     9        [Gtk] Scrollwheel on horizontal scrollbars should slide horizontally
     10
     11        Test: platform/gtk/scrollbars/overflow-scrollbar-horizontal-wheel-scroll.html
     12
     13        * page/EventHandler.cpp:
     14        (WebCore::EventHandler::handleWheelEvent): on GTK+, when using the
     15        wheel with the pointer on the horizontal scrollbar, scroll
     16        horizontally;
     17        * platform/PlatformWheelEvent.h:
     18        * platform/gtk/WheelEventGtk.cpp:
     19        (WebCore::PlatformWheelEvent::swapOrientation): allow adding a
     20        vertical scroll to the horizontal one;
     21
    1222009-09-24  Jeremy Orlow  <jorlow@chromium.org>
    223
  • trunk/WebCore/page/EventHandler.cpp

    r48701 r48735  
    17591759}
    17601760
     1761#if !PLATFORM(GTK)
     1762bool EventHandler::shouldTurnVerticalTicksIntoHorizontal(const HitTestResult& result) const
     1763{
     1764    return false;
     1765}
     1766#endif
     1767
    17611768bool EventHandler::handleWheelEvent(PlatformWheelEvent& e)
    17621769{
     
    17781785    bool didSetLatchedNode = false;
    17791786
     1787    HitTestRequest request(HitTestRequest::ReadOnly);
     1788    HitTestResult result(vPoint);
     1789    doc->renderView()->layer()->hitTest(request, result);
     1790
    17801791    if (m_useLatchedWheelEventNode) {
    17811792        if (!m_latchedWheelEventNode) {
    1782             HitTestRequest request(HitTestRequest::ReadOnly);
    1783             HitTestResult result(vPoint);
    1784             doc->renderView()->layer()->hitTest(request, result);
    17851793            m_latchedWheelEventNode = result.innerNode();
    17861794            m_widgetIsLatched = result.isOverWidget();
     
    17961804            m_previousWheelScrolledNode = 0;
    17971805
    1798         HitTestRequest request(HitTestRequest::ReadOnly);
    1799         HitTestResult result(vPoint);
    1800         doc->renderView()->layer()->hitTest(request, result);
    18011806        node = result.innerNode();
    18021807        isOverWidget = result.isOverWidget();
    18031808    }
     1809
     1810    if (shouldTurnVerticalTicksIntoHorizontal(result))
     1811        e.turnVerticalTicksIntoHorizontal();
    18041812
    18051813    if (node) {
  • trunk/WebCore/page/EventHandler.h

    r48683 r48735  
    126126#endif
    127127
     128    bool shouldTurnVerticalTicksIntoHorizontal(const HitTestResult&) const;
     129
    128130    bool tabsToLinks(KeyboardEvent*) const;
    129131    bool tabsToAllControls(KeyboardEvent*) const;
  • trunk/WebCore/page/gtk/EventHandlerGtk.cpp

    r46592 r48735  
    123123}
    124124
     125// GTK+ must scroll horizontally if the mouse pointer is on top of the
     126// horizontal scrollbar while scrolling with the wheel; we need to
     127// add the deltas and ticks here so that this behavior is consistent
     128// for styled scrollbars.
     129bool EventHandler::shouldTurnVerticalTicksIntoHorizontal(const HitTestResult& result) const
     130{
     131    return result.scrollbar() && result.scrollbar()->orientation() == HorizontalScrollbar;
    125132}
     133
     134}
  • trunk/WebCore/platform/PlatformWheelEvent.h

    r48177 r48735  
    9494        void ignore() { m_isAccepted = false; }
    9595
     96        void turnVerticalTicksIntoHorizontal()
     97        {
     98            m_deltaX = m_deltaY;
     99            m_deltaY = 0;
     100
     101            m_wheelTicksX = m_wheelTicksY;
     102            m_wheelTicksY = 0;
     103        }
     104
    96105#if PLATFORM(GTK)
    97106        PlatformWheelEvent(GdkEventScroll*);
  • trunk/WebKitTools/ChangeLog

    r48730 r48735  
     12009-09-24  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Add support for DRT to send mouse wheel events.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=29348
     8        [Gtk] Scrollwheel on horizontal scrollbars should slide horizontally
     9
     10        * DumpRenderTree/gtk/EventSender.cpp:
     11        (mouseWheelToCallback):
     12
    1132009-09-17  Eric Seidel  <eric@webkit.org>
    214
  • trunk/WebKitTools/DumpRenderTree/gtk/EventSender.cpp

    r48343 r48735  
    228228        gboolean return_val;
    229229        g_signal_emit_by_name(view, "motion_notify_event", &event, &return_val);
     230    }
     231
     232    return JSValueMakeUndefined(context);
     233}
     234
     235static JSValueRef mouseWheelToCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     236{
     237    WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
     238    if (!view)
     239        return JSValueMakeUndefined(context);
     240
     241    if (argumentCount < 2)
     242        return JSValueMakeUndefined(context);
     243
     244    int horizontal = (int)JSValueToNumber(context, arguments[0], exception);
     245    g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context));
     246    int vertical = (int)JSValueToNumber(context, arguments[1], exception);
     247    g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context));
     248
     249    // GTK+ doesn't support multiple direction scrolls in the same event!
     250    g_return_val_if_fail((!vertical || !horizontal), JSValueMakeUndefined(context));
     251
     252    GdkEvent event;
     253    event.type = GDK_SCROLL;
     254    event.scroll.x = lastMousePositionX;
     255    event.scroll.y = lastMousePositionY;
     256    event.scroll.time = GDK_CURRENT_TIME;
     257    event.scroll.window = GTK_WIDGET(view)->window;
     258
     259    if (horizontal < 0)
     260        event.scroll.direction = GDK_SCROLL_LEFT;
     261    else if (horizontal > 0)
     262        event.scroll.direction = GDK_SCROLL_RIGHT;
     263    else if (vertical < 0)
     264        event.scroll.direction = GDK_SCROLL_UP;
     265    else if (vertical > 0)
     266        event.scroll.direction = GDK_SCROLL_DOWN;
     267    else
     268        g_assert_not_reached();
     269
     270    if (dragMode && down && !replayingSavedEvents) {
     271        msgQueue[endOfQueue].event = event;
     272        msgQueue[endOfQueue++].isDragEvent = true;
     273    } else {
     274        webkit_web_frame_layout(mainFrame);
     275        gtk_main_do_event(&event);
    230276    }
    231277
     
    444490
    445491static JSStaticFunction staticFunctions[] = {
     492    { "mouseWheelTo", mouseWheelToCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    446493    { "contextClick", contextClickCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    447494    { "mouseDown", mouseDownCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
Note: See TracChangeset for help on using the changeset viewer.