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: https://svn.webkit.org/repository/webkit/trunk@20506
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+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.
_wkGetNSURLResponseLastModifiedDate
_wkGetNSURLResponseMustRevalidate
_wkGetPreferredExtensionForMIMEType
+_wkGetWheelEventDeltas
_wkInitializeGlyphVector
_wkNSURLProtocolClassForReqest
_wkPathFromFont
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();
}
void accept() { m_isAccepted = true; }
void ignore() { m_isAccepted = false; }
+
+ bool isContinuous() const { return m_isContinuous; }
#if PLATFORM(MAC)
PlatformWheelEvent(NSEvent*);
bool m_ctrlKey;
bool m_altKey;
bool m_metaKey;
+ bool m_isContinuous;
};
} // namespace WebCore
, m_currentPos(0)
, m_lineStep(0)
, m_pageStep(0)
+ , m_pixelStep(1)
{
}
v = maxPos;
if (v < 0)
v = 0;
- if (m_currentPos == v)
+ if (value() == v)
return false; // Our value stayed the same.
m_currentPos = v;
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;
}
-
}
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);
ScrollbarControlSize m_controlSize;
int m_visibleSize;
int m_totalSize;
- int m_currentPos;
+ float m_currentPos;
int m_lineStep;
int m_pageStep;
+ float m_pixelStep;
};
}
ScrollByLine,
ScrollByPage,
ScrollByDocument,
- ScrollByWheel
+ ScrollByPixel
};
enum ScrollbarOrientation { HorizontalScrollbar, VerticalScrollbar };
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;
}
}
#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;
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*);
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*);
BOOL (*wkSupportsMultipartXMixedReplace)(NSMutableURLRequest *);
Class (*wkNSURLProtocolClassForReqest)(NSURLRequest *);
float (*wkSecondsSinceLastInputEvent)(void);
-
#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
, m_ctrlKey(e->modifiers() & Qt::ControlModifier)
, m_altKey(e->modifiers() & Qt::AltModifier)
, m_metaKey(e->modifiers() & Qt::MetaModifier)
+ , m_isContinuous(false)
{
}
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
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.
BOOL WKCGContextIsBitmapContext(CGContextRef context);
+void WKGetWheelEventDeltas(NSEvent *, float *deltaX, float *deltaY, BOOL *continuous);
+
#ifdef __cplusplus
}
#endif