| Differences between
and this patch
- WebCore/ChangeLog +53 lines
Lines 1-3 WebCore/ChangeLog_sec1
1
2009-12-11  Peter Kasting  <pkasting@google.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        Add smooth scrolling
6
        https://bugs.webkit.org/show_bug.cgi?id=32356
7
8
        * page/EventHandler.cpp: Plumb a way to avoid queueing scrolls from keyboard autorepeat.
9
        (WebCore::EventHandler::scrollOverflow):
10
        (WebCore::EventHandler::scrollRecursively):
11
        * page/EventHandler.h: Plumb a way to avoid queueing scrolls from keyboard autorepeat.
12
        * platform/ScrollView.cpp: Plumb a way to avoid queueing scrolls from keyboard autorepeat.
13
        (WebCore::ScrollView::scroll):
14
        (WebCore::ScrollView::wheelEvent):
15
        * platform/ScrollView.h: Plumb a way to avoid queueing scrolls from keyboard autorepeat.
16
        * platform/Scrollbar.cpp:
17
        (WebCore::Scrollbar::Scrollbar): Init newly-added variables.
18
        (WebCore::Scrollbar::~Scrollbar): Stop smooth scroll timer as well as existing autoscroll timer.
19
        (WebCore::Scrollbar::setValue): Stop smooth scrolling if a caller sets the scroll position directly.
20
        (WebCore::Scrollbar::scroll): Smooth scroll if desired.  Avoid queueing extra scrolls for keyboard autorepeat when smooth scrolling.
21
        (WebCore::Scrollbar::paint): Remove whitespace on empty line.
22
        (WebCore::Scrollbar::autoscrollPressedPart): Rename existing "timer" names to "autoscrollTimer".
23
        (WebCore::Scrollbar::startAutoscrollTimerIfNeeded): Rename existing "timer" names to "autoscrollTimer".  Autoscroll desired pos rather than current pos if smooth scrolling.
24
        (WebCore::Scrollbar::stopAutoscrollTimerIfNeeded): Rename existing "timer" names to "autoscrollTimer".
25
        (WebCore::Scrollbar::smoothScrollTimerFired): Callback to perform smooth scrolling on an animation timer.
26
        (WebCore::Scrollbar::stopSmoothScrollTimerIfNeeded): Parallel to stopAutoscrollTimerIfNeeded().
27
        (WebCore::Scrollbar::smoothScroll): Perform a single smooth scroll increment.
28
        (WebCore::Scrollbar::moveThumb): Stop smooth scrolling if the user moves the thumb manually.
29
        (WebCore::Scrollbar::setCurrentPos): Add hook to stop/reset smooth scrolling if desired.
30
        (WebCore::Scrollbar::setDesiredPos): Set up smooth scrolling variables and begin smooth scrolling.
31
        (WebCore::Scrollbar::mouseMoved): Stop smooth scrolling if the user snaps the thumb back.  Rename existing "timer" names to "autoscrollTimer".  Remove whitespace on empty line.
32
        (WebCore::Scrollbar::mouseUp): Rename existing "timer" names to "autoscrollTimer".
33
        (WebCore::Scrollbar::mouseDown): Remove whitespace on empty line.
34
        * platform/Scrollbar.h: Plumb a way to avoid queueing scrolls from keyboard autorepeat.  Rename existing "timer" names to "autoscrollTimer".  Add bits for smooth scrolling.
35
        * platform/ScrollbarTheme.h: Add platform-specific control hooks for smooth scrolling.
36
        (WebCore::ScrollbarTheme::smoothScroll):
37
        (WebCore::ScrollbarTheme::smoothScrollTimerDelay):
38
        (WebCore::ScrollbarTheme::smoothScrollAccelerationTime):
39
        * rendering/RenderBox.cpp: Plumb a way to avoid queueing scrolls from keyboard autorepeat.
40
        (WebCore::RenderBox::scroll):
41
        * rendering/RenderBox.h: Plumb a way to avoid queueing scrolls from keyboard autorepeat.
42
        * rendering/RenderLayer.cpp: Plumb a way to avoid queueing scrolls from keyboard autorepeat.
43
        (WebCore::RenderLayer::scroll):
44
        * rendering/RenderLayer.h: Plumb a way to avoid queueing scrolls from keyboard autorepeat.
45
        * rendering/RenderListBox.cpp: Plumb a way to avoid queueing scrolls from keyboard autorepeat.
46
        (WebCore::RenderListBox::scroll):
47
        * rendering/RenderListBox.h: Plumb a way to avoid queueing scrolls from keyboard autorepeat.
48
        * rendering/RenderScrollbarTheme.h: Add platform-specific control hooks for smooth scrolling.
49
        (WebCore::RenderScrollbarTheme::smoothScrollTimerDelay):
50
        * rendering/RenderTextControlSingleLine.cpp: Plumb a way to avoid queueing scrolls from keyboard autorepeat.
51
        (WebCore::RenderTextControlSingleLine::scroll):
52
        * rendering/RenderTextControlSingleLine.h: Plumb a way to avoid queueing scrolls from keyboard autorepeat.
53
1
2009-12-11  Shinichiro Hamaji  <hamaji@chromium.org>
54
2009-12-11  Shinichiro Hamaji  <hamaji@chromium.org>
2
55
3
        Reviewed by Darin Adler.
56
        Reviewed by Darin Adler.
- WebCore/page/EventHandler.cpp -5 / +5 lines
Lines 902-908 void EventHandler::setMousePressNode(Pas WebCore/page/EventHandler.cpp_sec1
902
    m_mousePressNode = node;
902
    m_mousePressNode = node;
903
}
903
}
904
904
905
bool EventHandler::scrollOverflow(ScrollDirection direction, ScrollGranularity granularity)
905
bool EventHandler::scrollOverflow(ScrollDirection direction, ScrollGranularity granularity, bool allowUnlimitedQueueing)
906
{
906
{
907
    Node* node = m_frame->document()->focusedNode();
907
    Node* node = m_frame->document()->focusedNode();
908
    if (!node)
908
    if (!node)
Lines 910-916 bool EventHandler::scrollOverflow(Scroll WebCore/page/EventHandler.cpp_sec2
910
    
910
    
911
    if (node) {
911
    if (node) {
912
        RenderObject* r = node->renderer();
912
        RenderObject* r = node->renderer();
913
        if (r && !r->isListBox() && r->enclosingBox()->scroll(direction, granularity)) {
913
        if (r && !r->isListBox() && r->enclosingBox()->scroll(direction, granularity, 1.0f, allowUnlimitedQueueing)) {
914
            setFrameWasScrolledByUser();
914
            setFrameWasScrolledByUser();
915
            return true;
915
            return true;
916
        }
916
        }
Lines 919-932 bool EventHandler::scrollOverflow(Scroll WebCore/page/EventHandler.cpp_sec3
919
    return false;
919
    return false;
920
}
920
}
921
921
922
bool EventHandler::scrollRecursively(ScrollDirection direction, ScrollGranularity granularity)
922
bool EventHandler::scrollRecursively(ScrollDirection direction, ScrollGranularity granularity, bool allowUnlimitedQueueing)
923
{
923
{
924
    bool handled = scrollOverflow(direction, granularity);
924
    bool handled = scrollOverflow(direction, granularity, allowUnlimitedQueueing);
925
    if (!handled) {
925
    if (!handled) {
926
        Frame* frame = m_frame;
926
        Frame* frame = m_frame;
927
        do {
927
        do {
928
            FrameView* view = frame->view();
928
            FrameView* view = frame->view();
929
            handled = view ? view->scroll(direction, granularity) : false;
929
            handled = view ? view->scroll(direction, granularity, allowUnlimitedQueueing) : false;
930
            frame = frame->tree()->parent();
930
            frame = frame->tree()->parent();
931
        } while (!handled && frame);
931
        } while (!handled && frame);
932
     }
932
     }
- WebCore/page/EventHandler.h -2 / +2 lines
Lines 120-128 public: WebCore/page/EventHandler.h_sec1
120
120
121
    static Frame* subframeForTargetNode(Node*);
121
    static Frame* subframeForTargetNode(Node*);
122
122
123
    bool scrollOverflow(ScrollDirection, ScrollGranularity);
123
    bool scrollOverflow(ScrollDirection, ScrollGranularity, bool allowUnlimitedQueueing = true);
124
124
125
    bool scrollRecursively(ScrollDirection, ScrollGranularity);
125
    bool scrollRecursively(ScrollDirection, ScrollGranularity, bool allowUnlimitedQueueing = true);
126
126
127
#if ENABLE(DRAG_SUPPORT)
127
#if ENABLE(DRAG_SUPPORT)
128
    bool shouldDragAutoNode(Node*, const IntPoint&) const; // -webkit-user-drag == auto
128
    bool shouldDragAutoNode(Node*, const IntPoint&) const; // -webkit-user-drag == auto
- WebCore/platform/ScrollView.cpp -4 / +9 lines
Lines 313-329 void ScrollView::setScrollPosition(const WebCore/platform/ScrollView.cpp_sec1
313
    updateScrollbars(IntSize(newScrollPosition.x(), newScrollPosition.y()));
313
    updateScrollbars(IntSize(newScrollPosition.x(), newScrollPosition.y()));
314
}
314
}
315
315
316
bool ScrollView::scroll(ScrollDirection direction, ScrollGranularity granularity)
316
bool ScrollView::scroll(ScrollDirection direction, ScrollGranularity granularity, bool allowUnlimitedQueueing)
317
{
317
{
318
    if (platformWidget())
318
    if (platformWidget())
319
        return platformScroll(direction, granularity);
319
        return platformScroll(direction, granularity);
320
320
321
    if (direction == ScrollUp || direction == ScrollDown) {
321
    if (direction == ScrollUp || direction == ScrollDown) {
322
        if (m_verticalScrollbar)
322
        if (m_verticalScrollbar)
323
            return m_verticalScrollbar->scroll(direction, granularity);
323
            return m_verticalScrollbar->scroll(direction, granularity, 1.0f, allowUnlimitedQueueing);
324
    } else {
324
    } else {
325
        if (m_horizontalScrollbar)
325
        if (m_horizontalScrollbar)
326
            return m_horizontalScrollbar->scroll(direction, granularity);
326
            return m_horizontalScrollbar->scroll(direction, granularity, 1.0f, allowUnlimitedQueueing);
327
    }
327
    }
328
    return false;
328
    return false;
329
}
329
}
Lines 677-683 void ScrollView::wheelEvent(PlatformWhee WebCore/platform/ScrollView.cpp_sec2
677
            if (negative)
677
            if (negative)
678
                deltaY = -deltaY;
678
                deltaY = -deltaY;
679
        }
679
        }
680
        scrollBy(IntSize(-deltaX, -deltaY));
680
681
        // Should we fall back on scrollBy() if there is no scrollbar for a non-zero delta?
682
        if (deltaY && m_verticalScrollbar)
683
            m_verticalScrollbar->scroll(ScrollUp, ScrollByPixel, deltaY);
684
        if (deltaY && m_horizontalScrollbar)
685
            m_horizontalScrollbar->scroll(ScrollLeft, ScrollByPixel, deltaX);
681
    }
686
    }
682
}
687
}
683
688
- WebCore/platform/ScrollView.h -1 / +1 lines
Lines 146-152 public: WebCore/platform/ScrollView.h_sec1
146
    void scrollRectIntoViewRecursively(const IntRect&);
146
    void scrollRectIntoViewRecursively(const IntRect&);
147
    
147
    
148
    // This method scrolls by lines, pages or pixels.
148
    // This method scrolls by lines, pages or pixels.
149
    bool scroll(ScrollDirection, ScrollGranularity);
149
    bool scroll(ScrollDirection, ScrollGranularity, bool allowUnlimitedQueueing = true);
150
        
150
        
151
    // Scroll the actual contents of the view (either blitting or invalidating as needed).
151
    // Scroll the actual contents of the view (either blitting or invalidating as needed).
152
    void scrollContents(const IntSize& scrollDelta);
152
    void scrollContents(const IntSize& scrollDelta);
- WebCore/platform/Scrollbar.cpp -34 / +189 lines
Lines 26-31 WebCore/platform/Scrollbar.cpp_sec1
26
#include "config.h"
26
#include "config.h"
27
#include "Scrollbar.h"
27
#include "Scrollbar.h"
28
28
29
#include "CurrentTime.h"
29
#include "EventHandler.h"
30
#include "EventHandler.h"
30
#include "Frame.h"
31
#include "Frame.h"
31
#include "FrameView.h"
32
#include "FrameView.h"
Lines 57-62 Scrollbar::Scrollbar(ScrollbarClient* cl WebCore/platform/Scrollbar.cpp_sec2
57
    , m_visibleSize(0)
58
    , m_visibleSize(0)
58
    , m_totalSize(0)
59
    , m_totalSize(0)
59
    , m_currentPos(0)
60
    , m_currentPos(0)
61
    , m_desiredPos(0)
62
    , m_smoothScrollCurrentVelocity(0)
63
    , m_smoothScrollDesiredVelocity(0)
60
    , m_dragOrigin(0)
64
    , m_dragOrigin(0)
61
    , m_lineStep(0)
65
    , m_lineStep(0)
62
    , m_pageStep(0)
66
    , m_pageStep(0)
Lines 65-71 Scrollbar::Scrollbar(ScrollbarClient* cl WebCore/platform/Scrollbar.cpp_sec3
65
    , m_pressedPart(NoPart)
69
    , m_pressedPart(NoPart)
66
    , m_pressedPos(0)
70
    , m_pressedPos(0)
67
    , m_enabled(true)
71
    , m_enabled(true)
68
    , m_scrollTimer(this, &Scrollbar::autoscrollTimerFired)
72
    , m_autoscrollTimer(this, &Scrollbar::autoscrollTimerFired)
73
    , m_smoothScrollTimer(this, &Scrollbar::smoothScrollTimerFired)
69
    , m_overlapsResizer(false)
74
    , m_overlapsResizer(false)
70
    , m_suppressInvalidation(false)
75
    , m_suppressInvalidation(false)
71
{
76
{
Lines 83-90 Scrollbar::Scrollbar(ScrollbarClient* cl WebCore/platform/Scrollbar.cpp_sec4
83
88
84
Scrollbar::~Scrollbar()
89
Scrollbar::~Scrollbar()
85
{
90
{
86
    stopTimerIfNeeded();
91
    stopAutoscrollTimerIfNeeded();
87
    
92
    stopSmoothScrollTimerIfNeeded();
93
88
    m_theme->unregisterScrollbar(this);
94
    m_theme->unregisterScrollbar(this);
89
}
95
}
90
96
Lines 93-99 bool Scrollbar::setValue(int v) WebCore/platform/Scrollbar.cpp_sec5
93
    v = max(min(v, m_totalSize - m_visibleSize), 0);
99
    v = max(min(v, m_totalSize - m_visibleSize), 0);
94
    if (value() == v)
100
    if (value() == v)
95
        return false; // Our value stayed the same.
101
        return false; // Our value stayed the same.
96
    setCurrentPos(v);
102
    setCurrentPos(v, true);
97
    return true;
103
    return true;
98
}
104
}
99
105
Lines 115-140 void Scrollbar::setSteps(int lineStep, i WebCore/platform/Scrollbar.cpp_sec6
115
    m_pixelStep = 1.0f / pixelsPerStep;
121
    m_pixelStep = 1.0f / pixelsPerStep;
116
}
122
}
117
123
118
bool Scrollbar::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
124
bool Scrollbar::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, bool allowUnlimitedQueueing)
119
{
125
{
120
    float step = 0;
126
    float step = 0;
121
    if ((direction == ScrollUp && m_orientation == VerticalScrollbar) || (direction == ScrollLeft && m_orientation == HorizontalScrollbar))
127
    if ((direction == ScrollUp && m_orientation == VerticalScrollbar) || (direction == ScrollLeft && m_orientation == HorizontalScrollbar))
122
        step = -1;
128
        step = -multiplier;
123
    else if ((direction == ScrollDown && m_orientation == VerticalScrollbar) || (direction == ScrollRight && m_orientation == HorizontalScrollbar)) 
129
    else if ((direction == ScrollDown && m_orientation == VerticalScrollbar) || (direction == ScrollRight && m_orientation == HorizontalScrollbar)) 
124
        step = 1;
130
        step = multiplier;
125
    
131
126
    if (granularity == ScrollByLine)
132
    float smoothScrollStep = 0;
127
        step *= m_lineStep;
133
    if (granularity == ScrollByDocument)
128
    else if (granularity == ScrollByPage)
129
        step *= m_pageStep;
130
    else if (granularity == ScrollByDocument)
131
        step *= m_totalSize;
134
        step *= m_totalSize;
132
    else if (granularity == ScrollByPixel)
135
    else if (granularity == ScrollByPixel)
133
        step *= m_pixelStep;
136
        step *= m_pixelStep;
134
        
137
    else {
135
    float newPos = m_currentPos + step * multiplier;
138
        if (granularity == ScrollByLine)
136
    float maxPos = m_totalSize - m_visibleSize;
139
            smoothScrollStep = m_lineStep;
137
    return setCurrentPos(max(min(newPos, maxPos), 0.0f));
140
        else if (granularity == ScrollByPage)
141
            smoothScrollStep = m_pageStep;
142
        step *= smoothScrollStep;
143
    }
144
145
    float newPos = max(min(m_desiredPos + step, static_cast<float>(m_totalSize) - m_visibleSize), 0.0f);
146
    // Don't smooth scroll jumping to the beginning or end of the document.
147
    if (!theme()->smoothScroll() || (granularity == ScrollByDocument))
148
        return setCurrentPos(newPos, true);
149
    // For keyboard autorepeat scrolling, don't queue up more than two scroll
150
    // increments in advance, lest when the user lifts up the key we continue
151
    // scrolling for a while to "catch up".  (Two increments is the minimum
152
    // cutoff we can have without risking scroll underflow; to be more precise,
153
    // for a key repeat delay of |x| * theme()->autoscrollTimerDelay(), we will
154
    // eventually underflow if we don't allow the new position to advance by at
155
    // least (|step| * |x| * 2)).
156
    if (!allowUnlimitedQueueing && (abs(newPos - m_currentPos) >= (abs(step) * 2)))
157
        return false;
158
    return setDesiredPos(newPos, smoothScrollStep);
138
}
159
}
139
160
140
void Scrollbar::updateThumbPosition()
161
void Scrollbar::updateThumbPosition()
Lines 153-159 void Scrollbar::paint(GraphicsContext* c WebCore/platform/Scrollbar.cpp_sec7
153
        invalidate();
174
        invalidate();
154
        return;
175
        return;
155
    }
176
    }
156
        
177
157
    if (context->paintingDisabled() || !frameRect().intersects(damageRect))
178
    if (context->paintingDisabled() || !frameRect().intersects(damageRect))
158
        return;
179
        return;
159
180
Lines 188-197 void Scrollbar::autoscrollPressedPart(do WebCore/platform/Scrollbar.cpp_sec8
188
209
189
    // Handle the arrows and track.
210
    // Handle the arrows and track.
190
    if (scroll(pressedPartScrollDirection(), pressedPartScrollGranularity()))
211
    if (scroll(pressedPartScrollDirection(), pressedPartScrollGranularity()))
191
        startTimerIfNeeded(delay);
212
        startAutoscrollTimerIfNeeded(delay);
192
}
213
}
193
214
194
void Scrollbar::startTimerIfNeeded(double delay)
215
void Scrollbar::startAutoscrollTimerIfNeeded(double delay)
195
{
216
{
196
    // Don't do anything for the thumb.
217
    // Don't do anything for the thumb.
197
    if (m_pressedPart == ThumbPart)
218
    if (m_pressedPart == ThumbPart)
Lines 208-227 void Scrollbar::startTimerIfNeeded(doubl WebCore/platform/Scrollbar.cpp_sec9
208
    // We can't scroll if we've hit the beginning or end.
229
    // We can't scroll if we've hit the beginning or end.
209
    ScrollDirection dir = pressedPartScrollDirection();
230
    ScrollDirection dir = pressedPartScrollDirection();
210
    if (dir == ScrollUp || dir == ScrollLeft) {
231
    if (dir == ScrollUp || dir == ScrollLeft) {
211
        if (m_currentPos == 0)
232
        if (!m_desiredPos)
212
            return;
233
            return;
213
    } else {
234
    } else {
214
        if (m_currentPos == maximum())
235
        if (m_desiredPos == maximum())
215
            return;
236
            return;
216
    }
237
    }
217
238
218
    m_scrollTimer.startOneShot(delay);
239
    m_autoscrollTimer.startOneShot(delay);
219
}
240
}
220
241
221
void Scrollbar::stopTimerIfNeeded()
242
void Scrollbar::stopAutoscrollTimerIfNeeded()
222
{
243
{
223
    if (m_scrollTimer.isActive())
244
    if (m_autoscrollTimer.isActive())
224
        m_scrollTimer.stop();
245
        m_autoscrollTimer.stop();
225
}
246
}
226
247
227
ScrollDirection Scrollbar::pressedPartScrollDirection()
248
ScrollDirection Scrollbar::pressedPartScrollDirection()
Lines 244-249 ScrollGranularity Scrollbar::pressedPart WebCore/platform/Scrollbar.cpp_sec10
244
    return ScrollByPage;
265
    return ScrollByPage;
245
}
266
}
246
267
268
void Scrollbar::smoothScrollTimerFired(Timer<Scrollbar>*)
269
{
270
    smoothScroll();
271
}
272
273
void Scrollbar::stopSmoothScrollTimerIfNeeded()
274
{
275
    if (m_smoothScrollTimer.isActive())
276
        m_smoothScrollTimer.stop();
277
}
278
279
void Scrollbar::smoothScroll()
280
{
281
    // Note on smooth scrolling perf versus non-smooth scrolling perf:
282
    // The total time to perform a complete scroll is equal to
283
    //   t0 + 0.5tA - tD + tS
284
    // Where
285
    //   t0 = The time to perform the scroll without smooth scrolling
286
    //   tA = theme()->smoothScrollAccelerationTime()
287
    //   tD = theme()->smoothScrollTimerDelay()
288
    //   tS = A value less than or equal to the time required to perform a
289
    //        single scroll increment, i.e. the work done due to calling
290
    //        client()->valueChanged() (~0 for simple pages, larger for complex
291
    //        pages).
292
    //
293
    // Because tA and tD are fairly small, the total lag (as users perceive it)
294
    // is ~0 (actually 15 ms by default) for simple pages and roughly tS for
295
    // complex pages.  Without knowing in advance how large tS is it's hard to
296
    // do better than this.  Perhaps we could try to remember previous values
297
    // and forward-compensate.
298
299
300
    // We want to update the scroll position based on the time it's been since
301
    // our last update.  This may be longer than our ideal time, especially if
302
    // the page is complex or the system is slow.
303
    double desiredScrollInterval = theme()->smoothScrollTimerDelay();
304
    // To avoid feeling laggy, if we've just started smooth scrolling we pretend
305
    // we've already accelerated for one ideal interval, so that we'll scroll at
306
    // least some distance immediately.
307
    double lastScrollInterval = m_smoothScrollCurrentVelocity ? (WTF::currentTime() - m_lastSmoothScrollTime) : desiredScrollInterval;
308
309
    // Figure out how far we've actually traveled and update our current
310
    // velocity.
311
    float distanceTraveled;
312
    if (m_smoothScrollCurrentVelocity < m_smoothScrollDesiredVelocity) {
313
        // We accelerate at a constant rate until we reach the desired velocity.
314
        // theme()->smoothScrollAccelerationTime() is the time we'll take to
315
        // accelerate from 0 to that velocity.  Increasing this value will
316
        // produce a more pronounced acceleration effect.
317
        float accelerationRate = m_smoothScrollDesiredVelocity / theme()->smoothScrollAccelerationTime();
318
319
        // Figure out whether contant acceleration has caused us to reach our
320
        // target velocity.
321
        float potentialVelocityChange = accelerationRate * lastScrollInterval;
322
        float potentialNewVelocity = m_smoothScrollCurrentVelocity + potentialVelocityChange;
323
        if (potentialNewVelocity > m_smoothScrollDesiredVelocity) {
324
            // We reached the target velocity at some point between our last
325
            // update and now.  The distance traveled can be calculated in two
326
            // pieces: the distance traveled while accelerating, and the
327
            // distance traveled after reaching the target velocity.
328
            float actualVelocityChange = m_smoothScrollDesiredVelocity - m_smoothScrollCurrentVelocity;
329
            float accelerationInterval = actualVelocityChange / accelerationRate;
330
            // The distance traveled under constant acceleration is the area
331
            // under a line segment with a constant rising slope.  Break this
332
            // into a triangular portion atop a rectangular portion and sum.
333
            distanceTraveled = ((m_smoothScrollCurrentVelocity + (actualVelocityChange / 2)) * accelerationInterval);
334
            // The distance traveled at the target velocity is simply
335
            // (target velocity) * (remaining time after accelerating).
336
            distanceTraveled += (m_smoothScrollDesiredVelocity * (lastScrollInterval - accelerationInterval));
337
            m_smoothScrollCurrentVelocity = m_smoothScrollDesiredVelocity;
338
        } else {
339
            // Constant acceleration through the entire time interval.
340
            distanceTraveled = (m_smoothScrollCurrentVelocity + (potentialVelocityChange / 2)) * lastScrollInterval;
341
            m_smoothScrollCurrentVelocity = potentialNewVelocity;
342
        }
343
    } else {
344
        // We've already reached the target velocity, so the distance we've
345
        // traveled is simply (current velocity) * (elapsed time).
346
        distanceTraveled = m_smoothScrollCurrentVelocity * lastScrollInterval;
347
        // If our desired velocity has decreased, drop the current velocity too.
348
        m_smoothScrollCurrentVelocity = m_smoothScrollDesiredVelocity;
349
    }
350
351
    // Now update the scroll position based on the distance traveled.
352
    if (distanceTraveled >= abs(m_desiredPos - m_currentPos)) {
353
        // We've traveled far enough to reach the desired position.  Stop smooth
354
        // scrolling.
355
        setCurrentPos(m_desiredPos, false);
356
        m_smoothScrollCurrentVelocity = 0;
357
    } else {
358
        // Not yet at the target position.  Travel towards it and set up the
359
        // next update.
360
        if (m_currentPos > m_desiredPos)
361
            distanceTraveled = -distanceTraveled;
362
        setCurrentPos(m_currentPos + distanceTraveled, false);
363
        m_smoothScrollTimer.startOneShot(desiredScrollInterval);
364
        m_lastSmoothScrollTime = WTF::currentTime();
365
    }
366
}
367
247
void Scrollbar::moveThumb(int pos)
368
void Scrollbar::moveThumb(int pos)
248
{
369
{
249
    // Drag the thumb.
370
    // Drag the thumb.
Lines 257-267 void Scrollbar::moveThumb(int pos) WebCore/platform/Scrollbar.cpp_sec11
257
    else if (delta < 0)
378
    else if (delta < 0)
258
        delta = max(-thumbPos, delta);
379
        delta = max(-thumbPos, delta);
259
    if (delta)
380
    if (delta)
260
        setCurrentPos(static_cast<float>(thumbPos + delta) * maximum() / (trackLen - thumbLen));
381
        setCurrentPos(static_cast<float>(thumbPos + delta) * maximum() / (trackLen - thumbLen), true);
261
}
382
}
262
383
263
bool Scrollbar::setCurrentPos(float pos)
384
bool Scrollbar::setCurrentPos(float pos, bool resetSmoothScroll)
264
{
385
{
386
    if (resetSmoothScroll) {
387
        stopSmoothScrollTimerIfNeeded();
388
        m_desiredPos = pos;
389
        m_smoothScrollCurrentVelocity = 0;
390
    }
391
265
    if (pos == m_currentPos)
392
    if (pos == m_currentPos)
266
        return false;
393
        return false;
267
394
Lines 277-282 bool Scrollbar::setCurrentPos(float pos) WebCore/platform/Scrollbar.cpp_sec12
277
    return true;
404
    return true;
278
}
405
}
279
406
407
bool Scrollbar::setDesiredPos(float pos, float step)
408
{
409
    if (pos == m_desiredPos)
410
        return false;
411
412
    m_desiredPos = pos;
413
    if (m_currentPos == m_desiredPos)
414
        return false;
415
416
    // For wheel scrolls, we set the target velocity based on how far away from
417
    // the target position we are.  This makes wheel scrolls feel similar to the
418
    // other types of scrolls, since in both cases we're setting the velocity
419
    // such that in theme()->autoscrollTimerDelay() seconds we'll reach the new
420
    // desired position (see below).
421
    if (!step)
422
        step = abs(m_desiredPos - m_currentPos);
423
424
    // When autoscrolling, |m_autoscrollTimer| will end up calling here to
425
    // increment |m_desiredPos| by |step| every
426
    // theme()->autoscrollTimerDelay() seconds.  If we set the desired velocity
427
    // to exactly this rate, smooth scrolling will neither race ahead (and then
428
    // have to slow down) nor lag behind.
429
    m_smoothScrollDesiredVelocity = step / theme()->autoscrollTimerDelay();
430
    if (!m_smoothScrollTimer.isActive())
431
        smoothScroll();
432
    return true;
433
}
434
280
void Scrollbar::setHoveredPart(ScrollbarPart part)
435
void Scrollbar::setHoveredPart(ScrollbarPart part)
281
{
436
{
282
    if (part == m_hoveredPart)
437
    if (part == m_hoveredPart)
Lines 306-312 bool Scrollbar::mouseMoved(const Platfor WebCore/platform/Scrollbar.cpp_sec13
306
{
461
{
307
    if (m_pressedPart == ThumbPart) {
462
    if (m_pressedPart == ThumbPart) {
308
        if (theme()->shouldSnapBackToDragOrigin(this, evt))
463
        if (theme()->shouldSnapBackToDragOrigin(this, evt))
309
            setCurrentPos(m_dragOrigin);
464
            setCurrentPos(m_dragOrigin, true);
310
        else {
465
        else {
311
            moveThumb(m_orientation == HorizontalScrollbar ? 
466
            moveThumb(m_orientation == HorizontalScrollbar ? 
312
                      convertFromContainingWindow(evt.pos()).x() :
467
                      convertFromContainingWindow(evt.pos()).x() :
Lines 324-339 bool Scrollbar::mouseMoved(const Platfor WebCore/platform/Scrollbar.cpp_sec14
324
            if (part == m_pressedPart) {
479
            if (part == m_pressedPart) {
325
                // The mouse is moving back over the pressed part.  We
480
                // The mouse is moving back over the pressed part.  We
326
                // need to start up the timer action again.
481
                // need to start up the timer action again.
327
                startTimerIfNeeded(theme()->autoscrollTimerDelay());
482
                startAutoscrollTimerIfNeeded(theme()->autoscrollTimerDelay());
328
                theme()->invalidatePart(this, m_pressedPart);
483
                theme()->invalidatePart(this, m_pressedPart);
329
            } else if (m_hoveredPart == m_pressedPart) {
484
            } else if (m_hoveredPart == m_pressedPart) {
330
                // The mouse is leaving the pressed part.  Kill our timer
485
                // The mouse is leaving the pressed part.  Kill our timer
331
                // if needed.
486
                // if needed.
332
                stopTimerIfNeeded();
487
                stopAutoscrollTimerIfNeeded();
333
                theme()->invalidatePart(this, m_pressedPart);
488
                theme()->invalidatePart(this, m_pressedPart);
334
            }
489
            }
335
        } 
490
        } 
336
        
491
337
        setHoveredPart(part);
492
        setHoveredPart(part);
338
    } 
493
    } 
339
494
Lines 350-356 bool Scrollbar::mouseUp() WebCore/platform/Scrollbar.cpp_sec15
350
{
505
{
351
    setPressedPart(NoPart);
506
    setPressedPart(NoPart);
352
    m_pressedPos = 0;
507
    m_pressedPos = 0;
353
    stopTimerIfNeeded();
508
    stopAutoscrollTimerIfNeeded();
354
509
355
    if (parent() && parent()->isFrameView())
510
    if (parent() && parent()->isFrameView())
356
        static_cast<FrameView*>(parent())->frame()->eventHandler()->setMousePressed(false);
511
        static_cast<FrameView*>(parent())->frame()->eventHandler()->setMousePressed(false);
Lines 366-372 bool Scrollbar::mouseDown(const Platform WebCore/platform/Scrollbar.cpp_sec16
366
521
367
    setPressedPart(theme()->hitTest(this, evt));
522
    setPressedPart(theme()->hitTest(this, evt));
368
    int pressedPos = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.pos()).x() : convertFromContainingWindow(evt.pos()).y());
523
    int pressedPos = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.pos()).x() : convertFromContainingWindow(evt.pos()).y());
369
    
524
370
    if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && theme()->shouldCenterOnThumb(this, evt)) {
525
    if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && theme()->shouldCenterOnThumb(this, evt)) {
371
        setHoveredPart(ThumbPart);
526
        setHoveredPart(ThumbPart);
372
        setPressedPart(ThumbPart);
527
        setPressedPart(ThumbPart);
- WebCore/platform/Scrollbar.h -5 / +15 lines
Lines 82-88 public: WebCore/platform/Scrollbar.h_sec1
82
    void setProportion(int visibleSize, int totalSize);
82
    void setProportion(int visibleSize, int totalSize);
83
    void setPressedPos(int p) { m_pressedPos = p; }
83
    void setPressedPos(int p) { m_pressedPos = p; }
84
84
85
    bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f);
85
    bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f, bool allowUnlimitedQueueing = true);
86
    
86
    
87
    virtual void paint(GraphicsContext*, const IntRect& damageRect);
87
    virtual void paint(GraphicsContext*, const IntRect& damageRect);
88
88
Lines 135-148 protected: WebCore/platform/Scrollbar.h_sec2
135
    virtual void updateThumbProportion();
135
    virtual void updateThumbProportion();
136
136
137
    void autoscrollTimerFired(Timer<Scrollbar>*);
137
    void autoscrollTimerFired(Timer<Scrollbar>*);
138
    void startTimerIfNeeded(double delay);
138
    void startAutoscrollTimerIfNeeded(double delay);
139
    void stopTimerIfNeeded();
139
    void stopAutoscrollTimerIfNeeded();
140
    void autoscrollPressedPart(double delay);
140
    void autoscrollPressedPart(double delay);
141
    ScrollDirection pressedPartScrollDirection();
141
    ScrollDirection pressedPartScrollDirection();
142
    ScrollGranularity pressedPartScrollGranularity();
142
    ScrollGranularity pressedPartScrollGranularity();
143
    
143
    
144
    void smoothScrollTimerFired(Timer<Scrollbar>*);
145
    void stopSmoothScrollTimerIfNeeded();
146
    void smoothScroll();
147
144
    void moveThumb(int pos);
148
    void moveThumb(int pos);
145
    bool setCurrentPos(float pos);
149
    bool setCurrentPos(float pos, bool resetSmoothScroll);
150
    bool setDesiredPos(float pos, float step);
146
151
147
    ScrollbarClient* m_client;
152
    ScrollbarClient* m_client;
148
    ScrollbarOrientation m_orientation;
153
    ScrollbarOrientation m_orientation;
Lines 152-157 protected: WebCore/platform/Scrollbar.h_sec3
152
    int m_visibleSize;
157
    int m_visibleSize;
153
    int m_totalSize;
158
    int m_totalSize;
154
    float m_currentPos;
159
    float m_currentPos;
160
    float m_desiredPos;
161
    float m_smoothScrollCurrentVelocity;  // In px/s
162
    float m_smoothScrollDesiredVelocity;  // In px/s
163
    double m_lastSmoothScrollTime;
155
    float m_dragOrigin;
164
    float m_dragOrigin;
156
    int m_lineStep;
165
    int m_lineStep;
157
    int m_pageStep;
166
    int m_pageStep;
Lines 163-169 protected: WebCore/platform/Scrollbar.h_sec4
163
    
172
    
164
    bool m_enabled;
173
    bool m_enabled;
165
174
166
    Timer<Scrollbar> m_scrollTimer;
175
    Timer<Scrollbar> m_autoscrollTimer;
176
    Timer<Scrollbar> m_smoothScrollTimer;
167
    bool m_overlapsResizer;
177
    bool m_overlapsResizer;
168
    
178
    
169
    bool m_suppressInvalidation;
179
    bool m_suppressInvalidation;
- WebCore/platform/ScrollbarTheme.h +4 lines
Lines 85-90 public: WebCore/platform/ScrollbarTheme.h_sec1
85
    virtual double initialAutoscrollTimerDelay() { return 0.25; }
85
    virtual double initialAutoscrollTimerDelay() { return 0.25; }
86
    virtual double autoscrollTimerDelay() { return 0.05; }
86
    virtual double autoscrollTimerDelay() { return 0.05; }
87
87
88
    virtual bool smoothScroll() { return true; }
89
    virtual double smoothScrollTimerDelay() { return 0.01; }
90
    virtual double smoothScrollAccelerationTime() { return autoscrollTimerDelay(); }
91
88
    virtual void registerScrollbar(Scrollbar*) {}
92
    virtual void registerScrollbar(Scrollbar*) {}
89
    virtual void unregisterScrollbar(Scrollbar*) {}
93
    virtual void unregisterScrollbar(Scrollbar*) {}
90
94
- WebCore/rendering/RenderBox.cpp -3 / +3 lines
Lines 402-411 int RenderBox::horizontalScrollbarHeight WebCore/rendering/RenderBox.cpp_sec1
402
    return includeHorizontalScrollbarSize() ? layer()->horizontalScrollbarHeight() : 0;
402
    return includeHorizontalScrollbarSize() ? layer()->horizontalScrollbarHeight() : 0;
403
}
403
}
404
404
405
bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Node** stopNode)
405
bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, bool allowUnlimitedQueueing, Node** stopNode)
406
{
406
{
407
    RenderLayer* l = layer();
407
    RenderLayer* l = layer();
408
    if (l && l->scroll(direction, granularity, multiplier)) {
408
    if (l && l->scroll(direction, granularity, multiplier, allowUnlimitedQueueing)) {
409
        if (stopNode)
409
        if (stopNode)
410
            *stopNode = node();
410
            *stopNode = node();
411
        return true;
411
        return true;
Lines 416-422 bool RenderBox::scroll(ScrollDirection d WebCore/rendering/RenderBox.cpp_sec2
416
416
417
    RenderBlock* b = containingBlock();
417
    RenderBlock* b = containingBlock();
418
    if (b && !b->isRenderView())
418
    if (b && !b->isRenderView())
419
        return b->scroll(direction, granularity, multiplier, stopNode);
419
        return b->scroll(direction, granularity, multiplier, allowUnlimitedQueueing, stopNode);
420
    return false;
420
    return false;
421
}
421
}
422
422
- WebCore/rendering/RenderBox.h -1 / +1 lines
Lines 245-251 public: WebCore/rendering/RenderBox.h_sec1
245
245
246
    virtual int verticalScrollbarWidth() const;
246
    virtual int verticalScrollbarWidth() const;
247
    int horizontalScrollbarHeight() const;
247
    int horizontalScrollbarHeight() const;
248
    virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f, Node** stopNode = 0);
248
    virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f, bool allowUnlimitedQueueing = true, Node** stopNode = 0);
249
    bool canBeScrolledAndHasScrollableArea() const;
249
    bool canBeScrolledAndHasScrollableArea() const;
250
    virtual bool canBeProgramaticallyScrolled(bool) const;
250
    virtual bool canBeProgramaticallyScrolled(bool) const;
251
    virtual void autoscroll();
251
    virtual void autoscroll();
- WebCore/rendering/RenderLayer.cpp -4 / +4 lines
Lines 2052-2058 bool RenderLayer::hitTestOverflowControl WebCore/rendering/RenderLayer.cpp_sec1
2052
    return false;
2052
    return false;
2053
}
2053
}
2054
2054
2055
bool RenderLayer::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
2055
bool RenderLayer::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, bool allowUnlimitedQueueing)
2056
{
2056
{
2057
    bool didHorizontalScroll = false;
2057
    bool didHorizontalScroll = false;
2058
    bool didVerticalScroll = false;
2058
    bool didVerticalScroll = false;
Lines 2061-2073 bool RenderLayer::scroll(ScrollDirection WebCore/rendering/RenderLayer.cpp_sec2
2061
        if (granularity == ScrollByDocument) {
2061
        if (granularity == ScrollByDocument) {
2062
            // Special-case for the ScrollByDocument granularity. A document scroll can only be up 
2062
            // Special-case for the ScrollByDocument granularity. A document scroll can only be up 
2063
            // or down and in both cases the horizontal bar goes all the way to the left.
2063
            // or down and in both cases the horizontal bar goes all the way to the left.
2064
            didHorizontalScroll = m_hBar->scroll(ScrollLeft, ScrollByDocument, multiplier);
2064
            didHorizontalScroll = m_hBar->scroll(ScrollLeft, ScrollByDocument, multiplier, allowUnlimitedQueueing);
2065
        } else
2065
        } else
2066
            didHorizontalScroll = m_hBar->scroll(direction, granularity, multiplier);
2066
            didHorizontalScroll = m_hBar->scroll(direction, granularity, multiplier, allowUnlimitedQueueing);
2067
    }
2067
    }
2068
2068
2069
    if (m_vBar)
2069
    if (m_vBar)
2070
        didVerticalScroll = m_vBar->scroll(direction, granularity, multiplier);
2070
        didVerticalScroll = m_vBar->scroll(direction, granularity, multiplier, allowUnlimitedQueueing);
2071
2071
2072
    return (didHorizontalScroll || didVerticalScroll);
2072
    return (didHorizontalScroll || didVerticalScroll);
2073
}
2073
}
- WebCore/rendering/RenderLayer.h -1 / +1 lines
Lines 273-279 public: WebCore/rendering/RenderLayer.h_sec1
273
273
274
    void updateScrollInfoAfterLayout();
274
    void updateScrollInfoAfterLayout();
275
275
276
    bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f);
276
    bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f, bool allowUnlimitedQueueing = true);
277
    void autoscroll();
277
    void autoscroll();
278
278
279
    void resize(const PlatformMouseEvent&, const IntSize&);
279
    void resize(const PlatformMouseEvent&, const IntSize&);
- WebCore/rendering/RenderListBox.cpp -2 / +2 lines
Lines 510-518 bool RenderListBox::listIndexIsVisible(i WebCore/rendering/RenderListBox.cpp_sec1
510
    return index >= m_indexOffset && index < m_indexOffset + numVisibleItems();
510
    return index >= m_indexOffset && index < m_indexOffset + numVisibleItems();
511
}
511
}
512
512
513
bool RenderListBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Node**)
513
bool RenderListBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, bool allowUnlimitedQueueing, Node**)
514
{
514
{
515
    return m_vBar && m_vBar->scroll(direction, granularity, multiplier);
515
    return m_vBar && m_vBar->scroll(direction, granularity, multiplier, allowUnlimitedQueueing);
516
}
516
}
517
517
518
void RenderListBox::valueChanged(unsigned listIndex)
518
void RenderListBox::valueChanged(unsigned listIndex)
- WebCore/rendering/RenderListBox.h -1 / +1 lines
Lines 68-74 private: WebCore/rendering/RenderListBox.h_sec1
68
68
69
    virtual bool isPointInOverflowControl(HitTestResult&, int x, int y, int tx, int ty);
69
    virtual bool isPointInOverflowControl(HitTestResult&, int x, int y, int tx, int ty);
70
70
71
    virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f, Node** stopNode = 0);
71
    virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f, bool allowUnlimitedQueueing = true, Node** stopNode = 0);
72
72
73
    virtual void calcPrefWidths();
73
    virtual void calcPrefWidths();
74
    virtual int baselinePosition(bool firstLine, bool isRootLineBox) const;
74
    virtual int baselinePosition(bool firstLine, bool isRootLineBox) const;
- WebCore/rendering/RenderScrollbarTheme.h +4 lines
Lines 51-56 public: WebCore/rendering/RenderScrollbarTheme.h_sec1
51
    virtual double initialAutoscrollTimerDelay() { return ScrollbarTheme::nativeTheme()->initialAutoscrollTimerDelay(); }
51
    virtual double initialAutoscrollTimerDelay() { return ScrollbarTheme::nativeTheme()->initialAutoscrollTimerDelay(); }
52
    virtual double autoscrollTimerDelay() { return ScrollbarTheme::nativeTheme()->autoscrollTimerDelay(); }
52
    virtual double autoscrollTimerDelay() { return ScrollbarTheme::nativeTheme()->autoscrollTimerDelay(); }
53
53
54
    virtual bool smoothScroll() { return ScrollbarTheme::nativeTheme()->smoothScroll(); }
55
    virtual double smoothScrollTimerDelay() { return ScrollbarTheme::nativeTheme()->smoothScrollTimerDelay(); }
56
    virtual double smoothScrollAccelerationTime() { return ScrollbarTheme::nativeTheme()->smoothScrollAccelerationTime(); }
57
54
    virtual void registerScrollbar(Scrollbar* scrollbar) { return ScrollbarTheme::nativeTheme()->registerScrollbar(scrollbar); }
58
    virtual void registerScrollbar(Scrollbar* scrollbar) { return ScrollbarTheme::nativeTheme()->registerScrollbar(scrollbar); }
55
    virtual void unregisterScrollbar(Scrollbar* scrollbar) { return ScrollbarTheme::nativeTheme()->unregisterScrollbar(scrollbar); }
59
    virtual void unregisterScrollbar(Scrollbar* scrollbar) { return ScrollbarTheme::nativeTheme()->unregisterScrollbar(scrollbar); }
56
60
- WebCore/rendering/RenderTextControlSingleLine.cpp -3 / +3 lines
Lines 808-819 void RenderTextControlSingleLine::setScr WebCore/rendering/RenderTextControlSingleLine.cpp_sec1
808
        innerTextElement()->setScrollTop(newTop);
808
        innerTextElement()->setScrollTop(newTop);
809
}
809
}
810
810
811
bool RenderTextControlSingleLine::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Node** stopNode)
811
bool RenderTextControlSingleLine::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, bool allowUnlimitedQueueing, Node** stopNode)
812
{
812
{
813
    RenderLayer* layer = innerTextElement()->renderBox()->layer();
813
    RenderLayer* layer = innerTextElement()->renderBox()->layer();
814
    if (layer && layer->scroll(direction, granularity, multiplier))
814
    if (layer && layer->scroll(direction, granularity, multiplier, allowUnlimitedQueueing))
815
        return true;
815
        return true;
816
    return RenderBlock::scroll(direction, granularity, multiplier, stopNode);
816
    return RenderBlock::scroll(direction, granularity, multiplier, allowUnlimitedQueueing, stopNode);
817
}
817
}
818
818
819
PassRefPtr<Scrollbar> RenderTextControlSingleLine::createScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize controlSize)
819
PassRefPtr<Scrollbar> RenderTextControlSingleLine::createScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize controlSize)
- WebCore/rendering/RenderTextControlSingleLine.h -1 / +1 lines
Lines 72-78 private: WebCore/rendering/RenderTextControlSingleLine.h_sec1
72
    virtual int scrollHeight() const;
72
    virtual int scrollHeight() const;
73
    virtual void setScrollLeft(int);
73
    virtual void setScrollLeft(int);
74
    virtual void setScrollTop(int);
74
    virtual void setScrollTop(int);
75
    virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f, Node** stopNode = 0);
75
    virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f, bool allowUnlimitedQueueing = true, Node** stopNode = 0);
76
76
77
    int textBlockWidth() const;
77
    int textBlockWidth() const;
78
    virtual int preferredContentWidth(float charWidth) const;
78
    virtual int preferredContentWidth(float charWidth) const;
- WebKit/chromium/ChangeLog +14 lines
Lines 1-3 WebKit/chromium/ChangeLog_sec1
1
2009-12-11  Peter Kasting  <pkasting@google.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        Add smooth scrolling
6
        https://bugs.webkit.org/show_bug.cgi?id=32356
7
8
        * src/WebViewImpl.cpp: Don't queue scrolls from keyboard autorepeat.
9
        (WebKit::WebViewImpl::scrollViewWithKeyboard):
10
        (WebKit::WebViewImpl::propagateScroll):
11
        * src/WebViewImpl.h: Don't queue scrolls from keyboard autorepeat.
12
        * src/win/WebInputEventFactory.cpp: Update comments now that we have smooth scrolling.
13
        (WebKit::WebInputEventFactory::mouseWheelEvent):
14
1
2009-12-11  Nate Chapin  <japhet@chromium.org>
15
2009-12-11  Nate Chapin  <japhet@chromium.org>
2
16
3
        Reviewed by Darin Fisher.
17
        Reviewed by Darin Fisher.
- WebKit/chromium/src/WebViewImpl.cpp -4 / +7 lines
Lines 732-742 bool WebViewImpl::scrollViewWithKeyboard WebKit/chromium/src/WebViewImpl.cpp_sec1
732
        return false;
732
        return false;
733
    }
733
    }
734
734
735
    return propagateScroll(scrollDirection, scrollGranularity);
735
    return propagateScroll(scrollDirection, scrollGranularity, false);
736
}
736
}
737
737
738
bool WebViewImpl::propagateScroll(ScrollDirection scrollDirection,
738
bool WebViewImpl::propagateScroll(ScrollDirection scrollDirection,
739
                                  ScrollGranularity scrollGranularity)
739
                                  ScrollGranularity scrollGranularity,
740
                                  bool allowUnlimitedQueueing)
740
{
741
{
741
    Frame* frame = focusedWebCoreFrame();
742
    Frame* frame = focusedWebCoreFrame();
742
    if (!frame)
743
    if (!frame)
Lines 744-754 bool WebViewImpl::propagateScroll(Scroll WebKit/chromium/src/WebViewImpl.cpp_sec2
744
745
745
    bool scrollHandled =
746
    bool scrollHandled =
746
        frame->eventHandler()->scrollOverflow(scrollDirection,
747
        frame->eventHandler()->scrollOverflow(scrollDirection,
747
                                              scrollGranularity);
748
                                              scrollGranularity,
749
                                              allowUnlimitedQueueing);
748
    Frame* currentFrame = frame;
750
    Frame* currentFrame = frame;
749
    while (!scrollHandled && currentFrame) {
751
    while (!scrollHandled && currentFrame) {
750
        scrollHandled = currentFrame->view()->scroll(scrollDirection,
752
        scrollHandled = currentFrame->view()->scroll(scrollDirection,
751
                                                     scrollGranularity);
753
                                                     scrollGranularity,
754
                                                     allowUnlimitedQueueing);
752
        currentFrame = currentFrame->tree()->parent();
755
        currentFrame = currentFrame->tree()->parent();
753
    }
756
    }
754
    return scrollHandled;
757
    return scrollHandled;
- WebKit/chromium/src/WebViewImpl.h -1 / +1 lines
Lines 265-271 public: WebKit/chromium/src/WebViewImpl.h_sec1
265
265
266
    // Tries to scroll a frame or any parent of a frame. Returns true if the view
266
    // Tries to scroll a frame or any parent of a frame. Returns true if the view
267
    // was scrolled.
267
    // was scrolled.
268
    bool propagateScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity);
268
    bool propagateScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity, bool allowUnlimitedQueueing = true);
269
269
270
    // HACK: currentInputEvent() is for ChromeClientImpl::show(), until we can
270
    // HACK: currentInputEvent() is for ChromeClientImpl::show(), until we can
271
    // fix WebKit to pass enough information up into ChromeClient::show() so we
271
    // fix WebKit to pass enough information up into ChromeClient::show() so we
- WebKit/chromium/src/win/WebInputEventFactory.cpp -7 / +10 lines
Lines 396-408 WebMouseWheelEvent WebInputEventFactory: WebKit/chromium/src/win/WebInputEventFactory.cpp_sec1
396
396
397
    // Convert wheel delta amount to a number of pixels to scroll.
397
    // Convert wheel delta amount to a number of pixels to scroll.
398
    //
398
    //
399
    // How many pixels should we scroll per line?  Gecko uses the height of the
399
    // How many pixels should we scroll per line?  Firefox uses the height of
400
    // current line, which means scroll distance changes as you go through the
400
    // the current line, which means scroll distance changes as you go through
401
    // page or go to different pages.  IE 7 is ~50 px/line, although the value
401
    // the page or go to different pages.  IE 8 is ~60 px/line, although the
402
    // seems to vary slightly by page and zoom level.  Since IE 7 has a smoothing
402
    // value seems to vary slightly by page and zoom level.  Also, IE defaults
403
    // algorithm on scrolling, it can get away with slightly larger scroll values
403
    // to smooth scrolling while Firefox doesn't, so it can get away with
404
    // without feeling jerky.  Here we use 100 px per three lines (the default
404
    // somewhat larger scroll values without feeling as jerky.  Here we use 100
405
    // scroll amount is three lines per wheel tick).
405
    // px per three lines (the default scroll amount is three lines per wheel
406
    // tick).  Even though we have smooth scrolling, we don't make this as large
407
    // as IE because subjectively IE feels like it scrolls farther than you want
408
    // while reading articles.
406
    static const float scrollbarPixelsPerLine = 100.0f / 3.0f;
409
    static const float scrollbarPixelsPerLine = 100.0f / 3.0f;
407
    wheelDelta /= WHEEL_DELTA;
410
    wheelDelta /= WHEEL_DELTA;
408
    float scrollDelta = wheelDelta;
411
    float scrollDelta = wheelDelta;
- WebKit/gtk/ChangeLog +10 lines
Lines 1-3 WebKit/gtk/ChangeLog_sec1
1
2009-12-11  Peter Kasting  <pkasting@google.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        Add smooth scrolling
6
        https://bugs.webkit.org/show_bug.cgi?id=32356
7
8
        * webkit/webkitwebview.cpp: Don't queue scrolls from keyboard autorepeat.
9
        (webkit_web_view_real_move_cursor):
10
1
2009-12-10  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
11
2009-12-10  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
2
12
3
        Reviewed by Xan Lopez.
13
        Reviewed by Xan Lopez.
- WebKit/gtk/webkit/webkitwebview.cpp -2 / +2 lines
Lines 953-960 static gboolean webkit_web_view_real_mov WebKit/gtk/webkit/webkitwebview.cpp_sec1
953
    }
953
    }
954
954
955
    Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
955
    Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
956
    if (!frame->eventHandler()->scrollOverflow(direction, granularity))
956
    if (!frame->eventHandler()->scrollOverflow(direction, granularity, false))
957
        frame->view()->scroll(direction, granularity);
957
        frame->view()->scroll(direction, granularity, false);
958
958
959
    return true;
959
    return true;
960
}
960
}
- WebKit/mac/ChangeLog +16 lines
Lines 1-3 WebKit/mac/ChangeLog_sec1
1
2009-12-11  Peter Kasting  <pkasting@google.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        Add smooth scrolling
6
        https://bugs.webkit.org/show_bug.cgi?id=32356
7
8
        * WebView/WebFrameView.mm: Don't queue scrolls from keyboard autorepeat.
9
        (-[WebFrameView _scrollOverflowInDirection:granularity:allowUnlimitedQueueing:]):
10
        (-[WebFrameView _scrollToBeginningOfDocument]):
11
        (-[WebFrameView _scrollToEndOfDocument]):
12
        (-[WebFrameView _pageVertically:]):
13
        (-[WebFrameView _pageHorizontally:]):
14
        (-[WebFrameView _scrollLineVertically:]):
15
        (-[WebFrameView _scrollLineHorizontally:]):
16
1
2009-12-10  Jon Honeycutt  <jhoneycutt@apple.com>
17
2009-12-10  Jon Honeycutt  <jhoneycutt@apple.com>
2
18
3
        Mac build fix. Unreviewed.
19
        Mac build fix. Unreviewed.
- WebKit/mac/WebView/WebFrameView.mm -8 / +8 lines
Lines 519-525 static inline void addTypesFromClass(NSM WebKit/mac/WebView/WebFrameView.mm_sec1
519
    [super viewDidMoveToWindow];
519
    [super viewDidMoveToWindow];
520
}
520
}
521
521
522
- (BOOL)_scrollOverflowInDirection:(ScrollDirection)direction granularity:(ScrollGranularity)granularity
522
- (BOOL)_scrollOverflowInDirection:(ScrollDirection)direction granularity:(ScrollGranularity)granularity allowUnlimitedQueueing:(BOOL)allowUnlimitedQueueing
523
{
523
{
524
    // scrolling overflows is only applicable if we're dealing with an WebHTMLView
524
    // scrolling overflows is only applicable if we're dealing with an WebHTMLView
525
    if (![[self documentView] isKindOfClass:[WebHTMLView class]])
525
    if (![[self documentView] isKindOfClass:[WebHTMLView class]])
Lines 527-538 static inline void addTypesFromClass(NSM WebKit/mac/WebView/WebFrameView.mm_sec2
527
    Frame* frame = core([self webFrame]);
527
    Frame* frame = core([self webFrame]);
528
    if (!frame)
528
    if (!frame)
529
        return NO;
529
        return NO;
530
    return frame->eventHandler()->scrollOverflow(direction, granularity);
530
    return frame->eventHandler()->scrollOverflow(direction, granularity, allowUnlimitedQueueing);
531
}
531
}
532
532
533
- (BOOL)_scrollToBeginningOfDocument
533
- (BOOL)_scrollToBeginningOfDocument
534
{
534
{
535
    if ([self _scrollOverflowInDirection:ScrollUp granularity:ScrollByDocument])
535
    if ([self _scrollOverflowInDirection:ScrollUp granularity:ScrollByDocument allowUnlimitedQueueing:YES])
536
        return YES;
536
        return YES;
537
    if (![self _hasScrollBars])
537
    if (![self _hasScrollBars])
538
        return NO;
538
        return NO;
Lines 542-548 static inline void addTypesFromClass(NSM WebKit/mac/WebView/WebFrameView.mm_sec3
542
542
543
- (BOOL)_scrollToEndOfDocument
543
- (BOOL)_scrollToEndOfDocument
544
{
544
{
545
    if ([self _scrollOverflowInDirection:ScrollDown granularity:ScrollByDocument])
545
    if ([self _scrollOverflowInDirection:ScrollDown granularity:ScrollByDocument allowUnlimitedQueueing:YES])
546
        return YES;
546
        return YES;
547
    if (![self _hasScrollBars])
547
    if (![self _hasScrollBars])
548
        return NO;
548
        return NO;
Lines 619-625 static inline void addTypesFromClass(NSM WebKit/mac/WebView/WebFrameView.mm_sec4
619
619
620
- (BOOL)_pageVertically:(BOOL)up
620
- (BOOL)_pageVertically:(BOOL)up
621
{
621
{
622
    if ([self _scrollOverflowInDirection:up ? ScrollUp : ScrollDown granularity:ScrollByPage])
622
    if ([self _scrollOverflowInDirection:up ? ScrollUp : ScrollDown granularity:ScrollByPage allowUnlimitedQueueing:NO])
623
        return YES;
623
        return YES;
624
    
624
    
625
    if (![self _hasScrollBars])
625
    if (![self _hasScrollBars])
Lines 631-637 static inline void addTypesFromClass(NSM WebKit/mac/WebView/WebFrameView.mm_sec5
631
631
632
- (BOOL)_pageHorizontally:(BOOL)left
632
- (BOOL)_pageHorizontally:(BOOL)left
633
{
633
{
634
    if ([self _scrollOverflowInDirection:left ? ScrollLeft : ScrollRight granularity:ScrollByPage])
634
    if ([self _scrollOverflowInDirection:left ? ScrollLeft : ScrollRight granularity:ScrollByPage allowUnlimitedQueueing:NO])
635
        return YES;
635
        return YES;
636
636
637
    if (![self _hasScrollBars])
637
    if (![self _hasScrollBars])
Lines 643-649 static inline void addTypesFromClass(NSM WebKit/mac/WebView/WebFrameView.mm_sec6
643
643
644
- (BOOL)_scrollLineVertically:(BOOL)up
644
- (BOOL)_scrollLineVertically:(BOOL)up
645
{
645
{
646
    if ([self _scrollOverflowInDirection:up ? ScrollUp : ScrollDown granularity:ScrollByLine])
646
    if ([self _scrollOverflowInDirection:up ? ScrollUp : ScrollDown granularity:ScrollByLine allowUnlimitedQueueing:NO])
647
        return YES;
647
        return YES;
648
648
649
    if (![self _hasScrollBars])
649
    if (![self _hasScrollBars])
Lines 655-661 static inline void addTypesFromClass(NSM WebKit/mac/WebView/WebFrameView.mm_sec7
655
655
656
- (BOOL)_scrollLineHorizontally:(BOOL)left
656
- (BOOL)_scrollLineHorizontally:(BOOL)left
657
{
657
{
658
    if ([self _scrollOverflowInDirection:left ? ScrollLeft : ScrollRight granularity:ScrollByLine])
658
    if ([self _scrollOverflowInDirection:left ? ScrollLeft : ScrollRight granularity:ScrollByLine allowUnlimitedQueueing:NO])
659
        return YES;
659
        return YES;
660
660
661
    if (![self _hasScrollBars])
661
    if (![self _hasScrollBars])
- WebKit/qt/Api/qwebpage.cpp -1 / +1 lines
Lines 1336-1342 bool QWebPagePrivate::handleScrolling(QK WebKit/qt/Api/qwebpage.cpp_sec1
1336
        }
1336
        }
1337
    }
1337
    }
1338
1338
1339
    return frame->eventHandler()->scrollRecursively(direction, granularity);
1339
    return frame->eventHandler()->scrollRecursively(direction, granularity, false);
1340
}
1340
}
1341
1341
1342
#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
1342
#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
- WebKit/qt/ChangeLog +10 lines
Lines 1-3 WebKit/qt/ChangeLog_sec1
1
2009-12-11  Peter Kasting  <pkasting@google.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        Add smooth scrolling
6
        https://bugs.webkit.org/show_bug.cgi?id=32356
7
8
        * Api/qwebpage.cpp: Don't queue scrolls from keyboard autorepeat.
9
        (QWebPagePrivate::handleScrolling):
10
1
2009-12-11  Girish Ramakrishnan  <girish@forwardbias.in>
11
2009-12-11  Girish Ramakrishnan  <girish@forwardbias.in>
2
12
3
        Reviewed by Tor Arne Vestbø.
13
        Reviewed by Tor Arne Vestbø.
- WebKit/win/ChangeLog +10 lines
Lines 1-3 WebKit/win/ChangeLog_sec1
1
2009-12-11  Peter Kasting  <pkasting@google.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        Add smooth scrolling
6
        https://bugs.webkit.org/show_bug.cgi?id=32356
7
8
        * WebView.cpp: Don't queue scrolls from keyboard autorepeat.
9
        (WebView::keyDown):
10
1
2009-12-11  Chris Marrin  <cmarrin@apple.com>
11
2009-12-11  Chris Marrin  <cmarrin@apple.com>
2
12
3
        Reviewed by Jon Honeycutt.
13
        Reviewed by Jon Honeycutt.
- WebKit/win/WebView.cpp -1 / +1 lines
Lines 1809-1815 bool WebView::keyDown(WPARAM virtualKeyC WebKit/win/WebView.cpp_sec1
1809
            return false;
1809
            return false;
1810
    }
1810
    }
1811
1811
1812
    return frame->eventHandler()->scrollRecursively(direction, granularity);
1812
    return frame->eventHandler()->scrollRecursively(direction, granularity, false);
1813
}
1813
}
1814
1814
1815
bool WebView::keyPress(WPARAM charCode, LPARAM keyData, bool systemKeyDown)
1815
bool WebView::keyPress(WPARAM charCode, LPARAM keyData, bool systemKeyDown)

Return to Bug 32356