Changeset 20506 in webkit
- Timestamp:
- Mar 27, 2007 1:03:58 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r20505 r20506 1 2007-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 1 45 2007-03-26 Geoffrey Garen <ggaren@apple.com> 2 46 -
trunk/WebCore/WebCore.exp
r20317 r20506 663 663 _wkGetNSURLResponseMustRevalidate 664 664 _wkGetPreferredExtensionForMIMEType 665 _wkGetWheelEventDeltas 665 666 _wkInitializeGlyphVector 666 667 _wkNSURLProtocolClassForReqest -
trunk/WebCore/page/EventHandler.cpp
r20490 r20506 1173 1173 1174 1174 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) deltas1178 // they need to be eaten until we start supporting them1179 e.accept();1180 #endif1181 1182 1175 // Just break up into two scrolls if we need to. Diagonal movement on 1183 1176 // 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, 1185 1178 e.deltaX() < 0 ? -e.deltaX() : e.deltaX())) 1186 1179 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, 1188 1181 e.deltaY() < 0 ? -e.deltaY() : e.deltaY())) 1189 1182 e.accept(); -
trunk/WebCore/platform/PlatformWheelEvent.h
r19116 r20506 74 74 void accept() { m_isAccepted = true; } 75 75 void ignore() { m_isAccepted = false; } 76 77 bool isContinuous() const { return m_isContinuous; } 76 78 77 79 #if PLATFORM(MAC) … … 98 100 bool m_altKey; 99 101 bool m_metaKey; 102 bool m_isContinuous; 100 103 }; 101 104 -
trunk/WebCore/platform/ScrollBar.cpp
r18066 r20506 38 38 , m_lineStep(0) 39 39 , m_pageStep(0) 40 , m_pixelStep(1) 40 41 { 41 42 } … … 48 49 if (v < 0) 49 50 v = 0; 50 if ( m_currentPos== v)51 if (value() == v) 51 52 return false; // Our value stayed the same. 52 53 m_currentPos = v; … … 71 72 } 72 73 73 void Scrollbar::setSteps(int lineStep, int pageStep )74 void Scrollbar::setSteps(int lineStep, int pageStep, int pixelsPerStep) 74 75 { 75 76 m_lineStep = lineStep; 76 77 m_pageStep = pageStep; 78 m_pixelStep = 1.0f / pixelsPerStep; 77 79 } 78 80 79 81 bool Scrollbar::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier) 80 82 { 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; 105 116 } 106 107 117 } -
trunk/WebCore/platform/ScrollBar.h
r18874 r20506 62 62 63 63 ScrollbarOrientation orientation() const { return m_orientation; } 64 int value() const { return m_currentPos; }64 int value() const { return lroundf(m_currentPos); } 65 65 66 66 ScrollbarControlSize controlSize() const { return m_controlSize; } 67 67 68 void setSteps(int lineStep, int pageStep );68 void setSteps(int lineStep, int pageStep, int pixelsPerStep = 1); 69 69 70 70 bool setValue(int); … … 103 103 int m_visibleSize; 104 104 int m_totalSize; 105 int m_currentPos;105 float m_currentPos; 106 106 int m_lineStep; 107 107 int m_pageStep; 108 float m_pixelStep; 108 109 }; 109 110 -
trunk/WebCore/platform/ScrollTypes.h
r17770 r20506 40 40 ScrollByPage, 41 41 ScrollByDocument, 42 ScrollBy Wheel42 ScrollByPixel 43 43 }; 44 44 -
trunk/WebCore/platform/gdk/WheelEventGdk.cpp
r16733 r20506 54 54 m_altKey = event->button.state & GDK_MOD1_MASK; 55 55 m_metaKey = event->button.state & GDK_MOD2_MASK; 56 m_isContinuous = false; 56 57 } 57 58 -
trunk/WebCore/platform/mac/WebCoreSystemInterface.h
r19764 r20506 41 41 42 42 #ifdef __OBJC__ 43 @class NSEvent; 43 44 @class NSFont; 44 45 @class NSMutableURLRequest; … … 47 48 typedef struct NSArray NSArray; 48 49 typedef struct NSDate NSDate; 50 typedef struct NSEvent NSEvent; 49 51 typedef struct NSFont NSFont; 50 52 typedef struct NSImage NSImage; … … 105 107 extern NSDate *(*wkGetNSURLResponseLastModifiedDate)(NSURLResponse *response); 106 108 extern BOOL (*wkGetNSURLResponseMustRevalidate)(NSURLResponse *response); 109 extern void (*wkGetWheelEventDeltas)(NSEvent*, float* deltaX, float* deltaY, BOOL* continuous); 107 110 extern OSStatus (*wkInitializeGlyphVector)(int count, void* glyphs); 108 111 extern NSString* (*wkPathFromFont)(NSFont*); -
trunk/WebCore/platform/mac/WebCoreSystemInterface.mm
r19764 r20506 54 54 NSDate *(*wkGetNSURLResponseLastModifiedDate)(NSURLResponse *response); 55 55 BOOL (*wkGetNSURLResponseMustRevalidate)(NSURLResponse *response); 56 void (*wkGetWheelEventDeltas)(NSEvent*, float* deltaX, float* deltaY, BOOL* continuous); 56 57 OSStatus (*wkInitializeGlyphVector)(int count, void* glyphs); 57 58 NSString* (*wkPathFromFont)(NSFont*); … … 79 80 Class (*wkNSURLProtocolClassForReqest)(NSURLRequest *); 80 81 float (*wkSecondsSinceLastInputEvent)(void); 81 -
trunk/WebCore/platform/mac/WheelEventMac.mm
r17631 r20506 28 28 29 29 #import "PlatformMouseEvent.h" 30 #import "WebCoreSystemInterface.h" 30 31 31 32 namespace WebCore { … … 34 35 : m_position(pointForEvent(event)) 35 36 , m_globalPosition(globalPointForEvent(event)) 36 , m_deltaX([event deltaX])37 , m_deltaY([event deltaY])38 37 , m_isAccepted(false) 39 38 , m_shiftKey([event modifierFlags] & NSShiftKeyMask) … … 42 41 , m_metaKey([event modifierFlags] & NSCommandKeyMask) 43 42 { 43 BOOL continuous; 44 wkGetWheelEventDeltas(event, &m_deltaX, &m_deltaY, &continuous); 45 m_isContinuous = continuous; 44 46 } 45 47 -
trunk/WebCore/platform/qt/WheelEventQt.cpp
r19116 r20506 40 40 , m_altKey(e->modifiers() & Qt::AltModifier) 41 41 , m_metaKey(e->modifiers() & Qt::MetaModifier) 42 , m_isContinuous(false) 42 43 { 43 44 } -
trunk/WebCore/rendering/RenderListBox.cpp
r20349 r20506 230 230 if (m_vBar) { 231 231 m_vBar->setEnabled(numVisibleItems() < numItems()); 232 m_vBar->setSteps(1, min(1, numVisibleItems() - 1) );232 m_vBar->setSteps(1, min(1, numVisibleItems() - 1), itemHeight); 233 233 m_vBar->setProportion(numVisibleItems(), numItems()); 234 234 } -
trunk/WebKit/ChangeLog
r20498 r20506 1 2007-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 1 12 2007-03-26 John Sullivan <sullivan@apple.com> 2 13 -
trunk/WebKit/WebCoreSupport/WebSystemInterface.m
r19764 r20506 69 69 INIT(GetNSURLResponseMustRevalidate); 70 70 INIT(GetPreferredExtensionForMIMEType); 71 INIT(GetWheelEventDeltas); 71 72 INIT(InitializeGlyphVector); 72 73 INIT(NSURLProtocolClassForReqest); -
trunk/WebKitLibraries/ChangeLog
r20005 r20506 1 2007-03-27 Antti Koivisto <antti@apple.com> 2 3 Reviewed by Darin. 4 5 Added wkGetWheelEventDeltas 6 7 * WebKitSystemInterface.h: 8 * libWebKitSystemInterface.a: 9 1 10 2007-03-07 Mark Rowe <mrowe@apple.com> 2 11 -
trunk/WebKitLibraries/WebKitSystemInterface.h
r19781 r20506 146 146 BOOL WKCGContextIsBitmapContext(CGContextRef context); 147 147 148 void WKGetWheelEventDeltas(NSEvent *, float *deltaX, float *deltaY, BOOL *continuous); 149 148 150 #ifdef __cplusplus 149 151 }
Note: See TracChangeset
for help on using the changeset viewer.