Changeset 30060 in webkit


Ignore:
Timestamp:
Feb 6, 2008 8:12:36 PM (16 years ago)
Author:
kevino@webkit.org
Message:

Switch from directly handling wx scroll wheel events to handling the PlatformWheelEvent instead to give JS, etc. a chance to handle it.
http://bugs.webkit.org/show_bug.cgi?id=17179

Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r30059 r30060  
     12008-02-06  Kevin Ollivier  <kevino@theolliviers.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Rather than directly handing scroll wheel events, use
     6        PlatformWheelEvent to send them to WebCore first, so that
     7        mouse wheel scrolling info can be retrieved via JavaScript.
     8
     9        http://bugs.webkit.org/show_bug.cgi?id=17179
     10
     11        * platform/ScrollView.h:
     12        * platform/wx/MouseWheelEventWx.cpp:
     13        (WebCore::PlatformWheelEvent::PlatformWheelEvent):
     14        * platform/wx/ScrollViewWx.cpp:
     15        (WebCore::ScrollView::ScrollViewPrivate::bindEvents):
     16        (WebCore::ScrollView::wheelEvent):
     17        (WebCore::ScrollView::maximumScroll):
     18
    1192008-02-06  Mark Rowe  <mrowe@apple.com>
    220
  • trunk/WebCore/platform/ScrollView.h

    r29950 r30060  
    231231    private:
    232232        void adjustScrollbars(int x = -1, int y = -1, bool refresh = true);
     233        IntSize maximumScroll() const;
    233234
    234235        class ScrollViewPrivate;
  • trunk/WebCore/platform/wx/MouseWheelEventWx.cpp

    r29663 r30060  
    4040    , m_metaKey(event.MetaDown()) // FIXME: We'll have to test other browsers
    4141    , m_deltaX(0) // wx doesn't support horizontal mouse wheel scrolling
    42     , m_deltaY(event.GetWheelRotation())
     42    , m_deltaY(event.GetWheelRotation() / event.GetWheelDelta())
    4343{
    4444
  • trunk/WebCore/platform/wx/ScrollViewWx.cpp

    r29949 r30060  
    3030#include "IntRect.h"
    3131#include "NotImplemented.h"
     32#include "PlatformWheelEvent.h"
    3233#include "ScrollBar.h"
    3334
     
    6970        win->Connect(wxEVT_SCROLLWIN_THUMBRELEASE, wxScrollWinEventHandler(ScrollViewPrivate::OnScrollWinEvents), NULL, this);
    7071        win->Connect(wxEVT_SCROLLWIN_TOP,          wxScrollWinEventHandler(ScrollViewPrivate::OnScrollWinEvents), NULL, this);
    71         win->Connect(wxEVT_MOUSEWHEEL,             wxMouseEventHandler(ScrollViewPrivate::OnMouseWheelEvents), NULL, this);
    7272    }
    7373   
    74     void OnMouseWheelEvents(wxMouseEvent& event)
    75     {
    76         // TODO: Get wx to report X and Y rotation so we can support mighty mouse, etc.
    77         m_scrollView->scrollBy(0, -event.GetWheelRotation() * LINE_STEP);
    78     }
    79 
    8074    void OnScrollWinEvents(wxScrollWinEvent& e)
    8175    {
     
    112106    ScrollView* m_scrollView;
    113107
    114     IntSize scrollOffset;
    115     IntSize contentsSize;
    116108    HashSet<Widget*> m_children;
    117109    bool hasStaticBackground;
     
    165157        win->GetClientSize(&width, NULL);
    166158   
     159    ASSERT(width >= 0);
    167160    return width;
    168161}
     
    175168        win->GetClientSize(NULL, &height);
    176169   
     170    ASSERT(height >= 0);
    177171    return height;
    178172}
     
    240234int ScrollView::contentsX() const
    241235{
     236    ASSERT(m_data->viewStart.x >= 0);
    242237    return m_data->viewStart.x;
    243238}
     
    245240int ScrollView::contentsY() const
    246241{
     242    ASSERT(m_data->viewStart.y >= 0);
    247243    return m_data->viewStart.y;
    248244}
     
    254250    if (win)
    255251        win->GetVirtualSize(&width, NULL);
     252    ASSERT(width >= 0);
    256253    return width;
    257254}
     
    263260    if (win)
    264261        win->GetVirtualSize(NULL, &height);
     262    ASSERT(height >= 0);
    265263    return height;
    266264}
     
    405403}
    406404
    407 void ScrollView::wheelEvent(PlatformWheelEvent&)
    408 {
    409     // do nothing,
    410     // FIXME: not sure if any ports need to handle this, actually...
     405void ScrollView::wheelEvent(PlatformWheelEvent& e)
     406{
     407    // Determine how much we want to scroll.  If we can move at all, we will accept the event.
     408    IntSize maxScrollDelta = maximumScroll();
     409    if ((e.deltaX() < 0 && maxScrollDelta.width() > 0) ||
     410        (e.deltaX() > 0 && scrollOffset().width() > 0) ||
     411        (e.deltaY() < 0 && maxScrollDelta.height() > 0) ||
     412        (e.deltaY() > 0 && scrollOffset().height() > 0)) {
     413        e.accept();
     414        scrollBy(-e.deltaX() * LINE_STEP, -e.deltaY() * LINE_STEP);
     415    }
    411416}
    412417
     
    445450}
    446451
    447 
    448452PlatformScrollbar* ScrollView::scrollbarUnderMouse(const PlatformMouseEvent& mouseEvent)
    449453{
     
    453457}
    454458
    455 
    456 }
     459IntSize ScrollView::maximumScroll() const
     460{
     461    IntSize delta = (IntSize(contentsWidth(), contentsHeight()) - IntSize(visibleWidth(), visibleHeight())) - scrollOffset();
     462    delta.clampNegativeToZero();
     463    return delta;
     464}
     465
     466}
Note: See TracChangeset for help on using the changeset viewer.