Commit 8a4614cf authored by antti's avatar antti

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:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@20506 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0d143db6
2007-03-26 Antti Koivisto <antti@apple.com>
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
2007-03-26 Geoffrey Garen <ggaren@apple.com>
Reviewed by Darin Adler.
......
......@@ -662,6 +662,7 @@ _wkGetNSURLResponseCalculatedExpiration
_wkGetNSURLResponseLastModifiedDate
_wkGetNSURLResponseMustRevalidate
_wkGetPreferredExtensionForMIMEType
_wkGetWheelEventDeltas
_wkInitializeGlyphVector
_wkNSURLProtocolClassForReqest
_wkPathFromFont
......
......@@ -1172,19 +1172,12 @@ bool EventHandler::handleWheelEvent(PlatformWheelEvent& e)
return true;
if (node->renderer()) {
#if PLATFORM(MAC)
if (!e.deltaX() && !e.deltaY() && node->renderer()->isScrollable())
// smooth scroll events on mac may have (0,0) deltas
// they need to be eaten until we start supporting them
e.accept();
#endif
// Just break up into two scrolls if we need to. Diagonal movement on
// a MacBook pro is an example of a 2-dimensional mouse wheel event (where both deltaX and deltaY can be set).
if (e.deltaX() && node->renderer()->scroll(e.deltaX() < 0 ? ScrollRight : ScrollLeft, ScrollByWheel,
if (e.deltaX() && node->renderer()->scroll(e.deltaX() < 0 ? ScrollRight : ScrollLeft, e.isContinuous() ? ScrollByPixel : ScrollByLine,
e.deltaX() < 0 ? -e.deltaX() : e.deltaX()))
e.accept();
if (e.deltaY() && node->renderer()->scroll(e.deltaY() < 0 ? ScrollDown : ScrollUp, ScrollByWheel,
if (e.deltaY() && node->renderer()->scroll(e.deltaY() < 0 ? ScrollDown : ScrollUp, e.isContinuous() ? ScrollByPixel : ScrollByLine,
e.deltaY() < 0 ? -e.deltaY() : e.deltaY()))
e.accept();
}
......
......@@ -73,6 +73,8 @@ namespace WebCore {
void accept() { m_isAccepted = true; }
void ignore() { m_isAccepted = false; }
bool isContinuous() const { return m_isContinuous; }
#if PLATFORM(MAC)
PlatformWheelEvent(NSEvent*);
......@@ -97,6 +99,7 @@ namespace WebCore {
bool m_ctrlKey;
bool m_altKey;
bool m_metaKey;
bool m_isContinuous;
};
} // namespace WebCore
......
......@@ -37,6 +37,7 @@ Scrollbar::Scrollbar(ScrollbarClient* client, ScrollbarOrientation orientation,
, m_currentPos(0)
, m_lineStep(0)
, m_pageStep(0)
, m_pixelStep(1)
{
}
......@@ -47,7 +48,7 @@ bool Scrollbar::setValue(int v)
v = maxPos;
if (v < 0)
v = 0;
if (m_currentPos == v)
if (value() == v)
return false; // Our value stayed the same.
m_currentPos = v;
......@@ -70,38 +71,47 @@ void Scrollbar::setProportion(int visibleSize, int totalSize)
updateThumbProportion();
}
void Scrollbar::setSteps(int lineStep, int pageStep)
void Scrollbar::setSteps(int lineStep, int pageStep, int pixelsPerStep)
{
m_lineStep = lineStep;
m_pageStep = pageStep;
m_pixelStep = 1.0f / pixelsPerStep;
}
bool Scrollbar::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
{
float delta = 0.0;
if ((direction == ScrollUp && m_orientation == VerticalScrollbar) || (direction == ScrollLeft && m_orientation == HorizontalScrollbar)) {
if (granularity == ScrollByLine) {
delta = -m_lineStep;
} else if (granularity == ScrollByPage) {
delta = -m_pageStep;
} else if (granularity == ScrollByDocument) {
delta = -m_currentPos;
} else if (granularity == ScrollByWheel) {
delta = -m_lineStep;
}
} else if ((direction == ScrollDown && m_orientation == VerticalScrollbar) || (direction == ScrollRight && m_orientation == HorizontalScrollbar)) {
if (granularity == ScrollByLine) {
delta = m_lineStep;
} else if (granularity == ScrollByPage) {
delta = m_pageStep;
} else if (granularity == ScrollByDocument) {
delta = m_totalSize - m_visibleSize - m_currentPos;
} else if (granularity == ScrollByWheel) {
delta = m_lineStep;
}
}
int newPos = (int)(m_currentPos + (delta * multiplier));
return setValue(newPos);
float step = 0;
if ((direction == ScrollUp && m_orientation == VerticalScrollbar) || (direction == ScrollLeft && m_orientation == HorizontalScrollbar))
step = -1;
else if ((direction == ScrollDown && m_orientation == VerticalScrollbar) || (direction == ScrollRight && m_orientation == HorizontalScrollbar))
step = 1;
if (granularity == ScrollByLine)
step *= m_lineStep;
else if (granularity == ScrollByPage)
step *= m_pageStep;
else if (granularity == ScrollByDocument)
step *= m_totalSize;
else if (granularity == ScrollByPixel)
step *= m_pixelStep;
float newPos = m_currentPos + step * multiplier;
float maxPos = m_totalSize - m_visibleSize;
if (newPos < 0)
newPos = 0;
if (newPos > maxPos)
newPos = maxPos;
if (newPos == m_currentPos)
return false;
int oldValue = value();
m_currentPos = newPos;
updateThumbPosition();
if (value() != oldValue && client())
client()->valueChanged(this);
// return true even if the integer value did not change so that scroll event gets eaten
return true;
}
}
......@@ -61,11 +61,11 @@ public:
virtual bool isWidget() const = 0;
ScrollbarOrientation orientation() const { return m_orientation; }
int value() const { return m_currentPos; }
int value() const { return lroundf(m_currentPos); }
ScrollbarControlSize controlSize() const { return m_controlSize; }
void setSteps(int lineStep, int pageStep);
void setSteps(int lineStep, int pageStep, int pixelsPerStep = 1);
bool setValue(int);
void setProportion(int visibleSize, int totalSize);
......@@ -102,9 +102,10 @@ protected:
ScrollbarControlSize m_controlSize;
int m_visibleSize;
int m_totalSize;
int m_currentPos;
float m_currentPos;
int m_lineStep;
int m_pageStep;
float m_pixelStep;
};
}
......
......@@ -39,7 +39,7 @@ namespace WebCore {
ScrollByLine,
ScrollByPage,
ScrollByDocument,
ScrollByWheel
ScrollByPixel
};
enum ScrollbarOrientation { HorizontalScrollbar, VerticalScrollbar };
......
......@@ -53,6 +53,7 @@ PlatformWheelEvent::PlatformWheelEvent(GdkEvent* event)
m_ctrlKey = event->button.state & GDK_CONTROL_MASK;
m_altKey = event->button.state & GDK_MOD1_MASK;
m_metaKey = event->button.state & GDK_MOD2_MASK;
m_isContinuous = false;
}
}
......@@ -40,12 +40,14 @@ typedef struct _NSRect NSRect;
#endif
#ifdef __OBJC__
@class NSEvent;
@class NSFont;
@class NSMutableURLRequest;
@class NSURLRequest;
#else
typedef struct NSArray NSArray;
typedef struct NSDate NSDate;
typedef struct NSEvent NSEvent;
typedef struct NSFont NSFont;
typedef struct NSImage NSImage;
typedef struct NSMenu NSMenu;
......@@ -104,6 +106,7 @@ extern ATSUFontID (*wkGetNSFontATSUFontId)(NSFont*);
extern double (*wkGetNSURLResponseCalculatedExpiration)(NSURLResponse *response);
extern NSDate *(*wkGetNSURLResponseLastModifiedDate)(NSURLResponse *response);
extern BOOL (*wkGetNSURLResponseMustRevalidate)(NSURLResponse *response);
extern void (*wkGetWheelEventDeltas)(NSEvent*, float* deltaX, float* deltaY, BOOL* continuous);
extern OSStatus (*wkInitializeGlyphVector)(int count, void* glyphs);
extern NSString* (*wkPathFromFont)(NSFont*);
extern void (*wkPopupMenu)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*);
......
......@@ -53,6 +53,7 @@ ATSUFontID (*wkGetNSFontATSUFontId)(NSFont*);
NSTimeInterval (*wkGetNSURLResponseCalculatedExpiration)(NSURLResponse *response);
NSDate *(*wkGetNSURLResponseLastModifiedDate)(NSURLResponse *response);
BOOL (*wkGetNSURLResponseMustRevalidate)(NSURLResponse *response);
void (*wkGetWheelEventDeltas)(NSEvent*, float* deltaX, float* deltaY, BOOL* continuous);
OSStatus (*wkInitializeGlyphVector)(int count, void* glyphs);
NSString* (*wkPathFromFont)(NSFont*);
void (*wkPopupMenu)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*);
......@@ -78,4 +79,3 @@ id (*wkCreateNSURLConnectionDelegateProxy)(void);
BOOL (*wkSupportsMultipartXMixedReplace)(NSMutableURLRequest *);
Class (*wkNSURLProtocolClassForReqest)(NSURLRequest *);
float (*wkSecondsSinceLastInputEvent)(void);
......@@ -27,20 +27,22 @@
#import "PlatformWheelEvent.h"
#import "PlatformMouseEvent.h"
#import "WebCoreSystemInterface.h"
namespace WebCore {
PlatformWheelEvent::PlatformWheelEvent(NSEvent* event)
: m_position(pointForEvent(event))
, m_globalPosition(globalPointForEvent(event))
, m_deltaX([event deltaX])
, m_deltaY([event deltaY])
, m_isAccepted(false)
, m_shiftKey([event modifierFlags] & NSShiftKeyMask)
, m_ctrlKey([event modifierFlags] & NSControlKeyMask)
, m_altKey([event modifierFlags] & NSAlternateKeyMask)
, m_metaKey([event modifierFlags] & NSCommandKeyMask)
{
BOOL continuous;
wkGetWheelEventDeltas(event, &m_deltaX, &m_deltaY, &continuous);
m_isContinuous = continuous;
}
} // namespace WebCore
......@@ -39,6 +39,7 @@ PlatformWheelEvent::PlatformWheelEvent(QWheelEvent* e)
, m_ctrlKey(e->modifiers() & Qt::ControlModifier)
, m_altKey(e->modifiers() & Qt::AltModifier)
, m_metaKey(e->modifiers() & Qt::MetaModifier)
, m_isContinuous(false)
{
}
......
......@@ -229,7 +229,7 @@ void RenderListBox::calcHeight()
if (m_vBar) {
m_vBar->setEnabled(numVisibleItems() < numItems());
m_vBar->setSteps(1, min(1, numVisibleItems() - 1));
m_vBar->setSteps(1, min(1, numVisibleItems() - 1), itemHeight);
m_vBar->setProportion(numVisibleItems(), numItems());
}
}
......
2007-03-26 Antti Koivisto <antti@apple.com>
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()
2007-03-26 John Sullivan <sullivan@apple.com>
Reviewed by Dave Harrison
......
......@@ -68,6 +68,7 @@ void InitWebCoreSystemInterface(void)
INIT(GetNSURLResponseLastModifiedDate);
INIT(GetNSURLResponseMustRevalidate);
INIT(GetPreferredExtensionForMIMEType);
INIT(GetWheelEventDeltas);
INIT(InitializeGlyphVector);
INIT(NSURLProtocolClassForReqest);
INIT(PathFromFont);
......
2007-03-27 Antti Koivisto <antti@apple.com>
Reviewed by Darin.
Added wkGetWheelEventDeltas
* WebKitSystemInterface.h:
* libWebKitSystemInterface.a:
2007-03-07 Mark Rowe <mrowe@apple.com>
Build fix. Rebuild against 10.4 SDK.
......
......@@ -145,6 +145,8 @@ NSString* WKPathFromFont(NSFont *font);
BOOL WKCGContextIsBitmapContext(CGContextRef context);
void WKGetWheelEventDeltas(NSEvent *, float *deltaX, float *deltaY, BOOL *continuous);
#ifdef __cplusplus
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment