Changeset 20506 in webkit


Ignore:
Timestamp:
Mar 27, 2007 1:03:58 AM (17 years ago)
Author:
antti
Message:

WebCore:

Reviewed by Darin.


On Mac, support fine grained wheel events generated by trackpad and Mighty Mouse.
http://bugs.webkit.org/show_bug.cgi?id=13134
<rdar://problem/5076249?

  • WebCore.exp:

Export _wkGetWheelEventDeltas

  • page/EventHandler.cpp: (WebCore::EventHandler::handleWheelEvent):

Remove (0, 0) scroll event hack, it is not needed anymore.
Do per-pixel scrolling for fine grained events.

  • platform/PlatformWheelEvent.h: (WebCore::PlatformWheelEvent::isContinuous):

Add new m_isContinuous boolean to indicate fine grained wheel events.

  • platform/ScrollBar.cpp: (WebCore::Scrollbar::Scrollbar): (WebCore::Scrollbar::setValue): (WebCore::Scrollbar::setSteps): (WebCore::Scrollbar::scroll):
  • platform/ScrollBar.h: (WebCore::Scrollbar::value):

Use float to represent current position to support finer grained scrolling.
Add ScrollByPixel, remove ScrollByWheel (which was same as ScrollByLine anyway)

  • platform/ScrollTypes.h: (WebCore::):
  • platform/gdk/WheelEventGdk.cpp: (WebCore::PlatformWheelEvent::PlatformWheelEvent):

Initalize m_isContinuous

  • platform/mac/WebCoreSystemInterface.h:
  • platform/mac/WebCoreSystemInterface.mm:

Add wkGetWheelEventDeltas for getting fine grained wheel events

  • platform/mac/WheelEventMac.mm: (WebCore::PlatformWheelEvent::PlatformWheelEvent):

Get the wheel deltas using new wkGetWheelEventDeltas interface

  • platform/qt/WheelEventQt.cpp: (WebCore::PlatformWheelEvent::PlatformWheelEvent):

Initalize m_isContinuous

  • rendering/RenderListBox.cpp: (WebCore::RenderListBox::calcHeight):

Pass item height to scrollbar

WebKit:

Reviewed by Darin.


On Mac, support fine grained wheel events generated by trackpad and Mighty Mouse.
http://bugs.webkit.org/show_bug.cgi?id=13134
<rdar://problem/5076249?

  • WebCoreSupport/WebSystemInterface.m: (InitWebCoreSystemInterface): Expose GetWheelEventDeltas()

WebKitLibraries:

Reviewed by Darin.


Added wkGetWheelEventDeltas

  • WebKitSystemInterface.h:
  • libWebKitSystemInterface.a:
Location:
trunk
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r20505 r20506  
     12007-03-26  Antti Koivisto  <antti@apple.com>
     2
     3        Reviewed by Darin.
     4       
     5        On Mac, support fine grained wheel events generated by trackpad and Mighty Mouse.
     6        http://bugs.webkit.org/show_bug.cgi?id=13134
     7        <rdar://problem/5076249?
     8
     9        * WebCore.exp:
     10            Export _wkGetWheelEventDeltas
     11        * page/EventHandler.cpp:
     12        (WebCore::EventHandler::handleWheelEvent):
     13            Remove (0, 0) scroll event hack, it is not needed anymore.
     14            Do per-pixel scrolling for fine grained events.
     15        * platform/PlatformWheelEvent.h:
     16        (WebCore::PlatformWheelEvent::isContinuous):
     17            Add new m_isContinuous boolean to indicate fine grained wheel events.
     18        * platform/ScrollBar.cpp:
     19        (WebCore::Scrollbar::Scrollbar):
     20        (WebCore::Scrollbar::setValue):
     21        (WebCore::Scrollbar::setSteps):
     22        (WebCore::Scrollbar::scroll):
     23        * platform/ScrollBar.h:
     24        (WebCore::Scrollbar::value):
     25            Use float to represent current position to support finer grained scrolling.
     26            Add ScrollByPixel, remove ScrollByWheel (which was same as ScrollByLine anyway)
     27        * platform/ScrollTypes.h:
     28        (WebCore::):
     29        * platform/gdk/WheelEventGdk.cpp:
     30        (WebCore::PlatformWheelEvent::PlatformWheelEvent):
     31            Initalize m_isContinuous
     32        * platform/mac/WebCoreSystemInterface.h:
     33        * platform/mac/WebCoreSystemInterface.mm:
     34            Add wkGetWheelEventDeltas for getting fine grained wheel events
     35        * platform/mac/WheelEventMac.mm:
     36        (WebCore::PlatformWheelEvent::PlatformWheelEvent):
     37            Get the wheel deltas using new wkGetWheelEventDeltas interface
     38        * platform/qt/WheelEventQt.cpp:
     39        (WebCore::PlatformWheelEvent::PlatformWheelEvent):
     40            Initalize m_isContinuous
     41        * rendering/RenderListBox.cpp:
     42        (WebCore::RenderListBox::calcHeight):
     43            Pass item height to scrollbar
     44
    1452007-03-26  Geoffrey Garen  <ggaren@apple.com>
    246
  • trunk/WebCore/WebCore.exp

    r20317 r20506  
    663663_wkGetNSURLResponseMustRevalidate
    664664_wkGetPreferredExtensionForMIMEType
     665_wkGetWheelEventDeltas
    665666_wkInitializeGlyphVector
    666667_wkNSURLProtocolClassForReqest
  • trunk/WebCore/page/EventHandler.cpp

    r20490 r20506  
    11731173           
    11741174        if (node->renderer()) {
    1175 #if PLATFORM(MAC)
    1176             if (!e.deltaX() && !e.deltaY() && node->renderer()->isScrollable())
    1177                 // smooth scroll events on mac may have (0,0) deltas
    1178                 // they need to be eaten until we start supporting them
    1179                 e.accept();
    1180 #endif
    1181        
    11821175            // Just break up into two scrolls if we need to.  Diagonal movement on
    11831176            // a MacBook pro is an example of a 2-dimensional mouse wheel event (where both deltaX and deltaY can be set).
    1184             if (e.deltaX() && node->renderer()->scroll(e.deltaX() < 0 ? ScrollRight : ScrollLeft, ScrollByWheel,
     1177            if (e.deltaX() && node->renderer()->scroll(e.deltaX() < 0 ? ScrollRight : ScrollLeft, e.isContinuous() ? ScrollByPixel : ScrollByLine,
    11851178                                                       e.deltaX() < 0 ? -e.deltaX() : e.deltaX()))
    11861179                e.accept();
    1187             if (e.deltaY() && node->renderer()->scroll(e.deltaY() < 0 ? ScrollDown : ScrollUp, ScrollByWheel,
     1180            if (e.deltaY() && node->renderer()->scroll(e.deltaY() < 0 ? ScrollDown : ScrollUp, e.isContinuous() ? ScrollByPixel : ScrollByLine,
    11881181                                                       e.deltaY() < 0 ? -e.deltaY() : e.deltaY()))
    11891182                e.accept();
  • trunk/WebCore/platform/PlatformWheelEvent.h

    r19116 r20506  
    7474        void accept() { m_isAccepted = true; }
    7575        void ignore() { m_isAccepted = false; }
     76       
     77        bool isContinuous() const { return m_isContinuous; }
    7678
    7779#if PLATFORM(MAC)
     
    98100        bool m_altKey;
    99101        bool m_metaKey;
     102        bool m_isContinuous;
    100103    };
    101104
  • trunk/WebCore/platform/ScrollBar.cpp

    r18066 r20506  
    3838    , m_lineStep(0)
    3939    , m_pageStep(0)
     40    , m_pixelStep(1)
    4041{
    4142}
     
    4849    if (v < 0)
    4950        v = 0;
    50     if (m_currentPos == v)
     51    if (value() == v)
    5152        return false; // Our value stayed the same.
    5253    m_currentPos = v;
     
    7172}
    7273
    73 void Scrollbar::setSteps(int lineStep, int pageStep)
     74void Scrollbar::setSteps(int lineStep, int pageStep, int pixelsPerStep)
    7475{
    7576    m_lineStep = lineStep;
    7677    m_pageStep = pageStep;
     78    m_pixelStep = 1.0f / pixelsPerStep;
    7779}
    7880
    7981bool Scrollbar::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
    8082{
    81     float delta = 0.0;
    82     if ((direction == ScrollUp && m_orientation == VerticalScrollbar) || (direction == ScrollLeft && m_orientation == HorizontalScrollbar)) {
    83         if (granularity == ScrollByLine) {
    84             delta = -m_lineStep;
    85         } else if (granularity == ScrollByPage) {
    86             delta = -m_pageStep;
    87         } else if (granularity == ScrollByDocument) {
    88             delta = -m_currentPos;
    89         } else if (granularity == ScrollByWheel) {
    90             delta = -m_lineStep;
    91         }
    92     } else if ((direction == ScrollDown && m_orientation == VerticalScrollbar) || (direction == ScrollRight && m_orientation == HorizontalScrollbar)) {
    93         if (granularity == ScrollByLine) {
    94             delta = m_lineStep;
    95         } else if (granularity == ScrollByPage) {
    96             delta = m_pageStep;
    97         } else if (granularity == ScrollByDocument) {
    98             delta = m_totalSize - m_visibleSize - m_currentPos;
    99         } else if (granularity == ScrollByWheel) {
    100             delta = m_lineStep;
    101         }
    102     }
    103     int newPos = (int)(m_currentPos + (delta * multiplier));
    104     return setValue(newPos);
     83    float step = 0;
     84    if ((direction == ScrollUp && m_orientation == VerticalScrollbar) || (direction == ScrollLeft && m_orientation == HorizontalScrollbar))
     85        step = -1;
     86    else if ((direction == ScrollDown && m_orientation == VerticalScrollbar) || (direction == ScrollRight && m_orientation == HorizontalScrollbar))
     87        step = 1;
     88   
     89    if (granularity == ScrollByLine)
     90        step *= m_lineStep;
     91    else if (granularity == ScrollByPage)
     92        step *= m_pageStep;
     93    else if (granularity == ScrollByDocument)
     94        step *= m_totalSize;
     95    else if (granularity == ScrollByPixel)
     96        step *= m_pixelStep;
     97       
     98    float newPos = m_currentPos + step * multiplier;
     99    float maxPos = m_totalSize - m_visibleSize;
     100    if (newPos < 0)
     101        newPos = 0;
     102    if (newPos > maxPos)
     103        newPos = maxPos;
     104    if (newPos == m_currentPos)
     105        return false;
     106   
     107    int oldValue = value();
     108    m_currentPos = newPos;
     109    updateThumbPosition();
     110   
     111    if (value() != oldValue && client())
     112        client()->valueChanged(this);
     113   
     114    // return true even if the integer value did not change so that scroll event gets eaten
     115    return true;
    105116}
    106 
    107117}
  • trunk/WebCore/platform/ScrollBar.h

    r18874 r20506  
    6262
    6363    ScrollbarOrientation orientation() const { return m_orientation; }
    64     int value() const { return m_currentPos; }
     64    int value() const { return lroundf(m_currentPos); }
    6565   
    6666    ScrollbarControlSize controlSize() const { return m_controlSize; }
    6767
    68     void setSteps(int lineStep, int pageStep);
     68    void setSteps(int lineStep, int pageStep, int pixelsPerStep = 1);
    6969   
    7070    bool setValue(int);
     
    103103    int m_visibleSize;
    104104    int m_totalSize;
    105     int m_currentPos;
     105    float m_currentPos;
    106106    int m_lineStep;
    107107    int m_pageStep;
     108    float m_pixelStep;
    108109};
    109110
  • trunk/WebCore/platform/ScrollTypes.h

    r17770 r20506  
    4040        ScrollByPage,
    4141        ScrollByDocument,
    42         ScrollByWheel
     42        ScrollByPixel
    4343    };
    4444
  • trunk/WebCore/platform/gdk/WheelEventGdk.cpp

    r16733 r20506  
    5454    m_altKey = event->button.state & GDK_MOD1_MASK;
    5555    m_metaKey = event->button.state & GDK_MOD2_MASK;
     56    m_isContinuous = false;
    5657}
    5758
  • trunk/WebCore/platform/mac/WebCoreSystemInterface.h

    r19764 r20506  
    4141
    4242#ifdef __OBJC__
     43@class NSEvent;
    4344@class NSFont;
    4445@class NSMutableURLRequest;
     
    4748typedef struct NSArray NSArray;
    4849typedef struct NSDate NSDate;
     50typedef struct NSEvent NSEvent;
    4951typedef struct NSFont NSFont;
    5052typedef struct NSImage NSImage;
     
    105107extern NSDate *(*wkGetNSURLResponseLastModifiedDate)(NSURLResponse *response);
    106108extern BOOL (*wkGetNSURLResponseMustRevalidate)(NSURLResponse *response);
     109extern void (*wkGetWheelEventDeltas)(NSEvent*, float* deltaX, float* deltaY, BOOL* continuous);
    107110extern OSStatus (*wkInitializeGlyphVector)(int count, void* glyphs);
    108111extern NSString* (*wkPathFromFont)(NSFont*);
  • trunk/WebCore/platform/mac/WebCoreSystemInterface.mm

    r19764 r20506  
    5454NSDate *(*wkGetNSURLResponseLastModifiedDate)(NSURLResponse *response);
    5555BOOL (*wkGetNSURLResponseMustRevalidate)(NSURLResponse *response);
     56void (*wkGetWheelEventDeltas)(NSEvent*, float* deltaX, float* deltaY, BOOL* continuous);
    5657OSStatus (*wkInitializeGlyphVector)(int count, void* glyphs);
    5758NSString* (*wkPathFromFont)(NSFont*);
     
    7980Class (*wkNSURLProtocolClassForReqest)(NSURLRequest *);
    8081float (*wkSecondsSinceLastInputEvent)(void);
    81 
  • trunk/WebCore/platform/mac/WheelEventMac.mm

    r17631 r20506  
    2828
    2929#import "PlatformMouseEvent.h"
     30#import "WebCoreSystemInterface.h"
    3031
    3132namespace WebCore {
     
    3435    : m_position(pointForEvent(event))
    3536    , m_globalPosition(globalPointForEvent(event))
    36     , m_deltaX([event deltaX])
    37     , m_deltaY([event deltaY])
    3837    , m_isAccepted(false)
    3938    , m_shiftKey([event modifierFlags] & NSShiftKeyMask)
     
    4241    , m_metaKey([event modifierFlags] & NSCommandKeyMask)
    4342{
     43    BOOL continuous;
     44    wkGetWheelEventDeltas(event, &m_deltaX, &m_deltaY, &continuous);
     45    m_isContinuous = continuous;
    4446}
    4547
  • trunk/WebCore/platform/qt/WheelEventQt.cpp

    r19116 r20506  
    4040    , m_altKey(e->modifiers() & Qt::AltModifier)
    4141    , m_metaKey(e->modifiers() & Qt::MetaModifier)
     42    , m_isContinuous(false)
    4243{
    4344}
  • trunk/WebCore/rendering/RenderListBox.cpp

    r20349 r20506  
    230230    if (m_vBar) {
    231231        m_vBar->setEnabled(numVisibleItems() < numItems());
    232         m_vBar->setSteps(1, min(1, numVisibleItems() - 1));
     232        m_vBar->setSteps(1, min(1, numVisibleItems() - 1), itemHeight);
    233233        m_vBar->setProportion(numVisibleItems(), numItems());
    234234    }
  • trunk/WebKit/ChangeLog

    r20498 r20506  
     12007-03-26  Antti Koivisto  <antti@apple.com>
     2
     3        Reviewed by Darin.
     4       
     5        On Mac, support fine grained wheel events generated by trackpad and Mighty Mouse.
     6        http://bugs.webkit.org/show_bug.cgi?id=13134
     7        <rdar://problem/5076249?
     8
     9        * WebCoreSupport/WebSystemInterface.m:
     10        (InitWebCoreSystemInterface): Expose GetWheelEventDeltas()
     11
    1122007-03-26  John Sullivan  <sullivan@apple.com>
    213
  • trunk/WebKit/WebCoreSupport/WebSystemInterface.m

    r19764 r20506  
    6969    INIT(GetNSURLResponseMustRevalidate);
    7070    INIT(GetPreferredExtensionForMIMEType);
     71    INIT(GetWheelEventDeltas);
    7172    INIT(InitializeGlyphVector);
    7273    INIT(NSURLProtocolClassForReqest);
  • trunk/WebKitLibraries/ChangeLog

    r20005 r20506  
     12007-03-27  Antti Koivisto  <antti@apple.com>
     2
     3        Reviewed by Darin.
     4       
     5        Added wkGetWheelEventDeltas
     6
     7        * WebKitSystemInterface.h:
     8        * libWebKitSystemInterface.a:
     9
    1102007-03-07  Mark Rowe  <mrowe@apple.com>
    211
  • trunk/WebKitLibraries/WebKitSystemInterface.h

    r19781 r20506  
    146146BOOL WKCGContextIsBitmapContext(CGContextRef context);
    147147
     148void WKGetWheelEventDeltas(NSEvent *, float *deltaX, float *deltaY, BOOL *continuous);
     149
    148150#ifdef __cplusplus
    149151}
Note: See TracChangeset for help on using the changeset viewer.