Changeset 54345 in webkit


Ignore:
Timestamp:
Feb 4, 2010 9:35:58 AM (14 years ago)
Author:
mitz@apple.com
Message:

REGRESSION (r53718): When scrolling a tall window by page, the overlap between pages is too big
https://bugs.webkit.org/show_bug.cgi?id=34371

Reviewed by Simon Fraser.

WebCore:

Allow ScrollbarTheme to cap the overlap between pages, and set a cap of
40 in ScrollbarThemeMac.

  • WebCore.base.exp: Export Scrollbar::maxOverlapBetweenPages().
  • editing/EditorCommand.cpp:

(WebCore::verticalScrollDistance): Use Scrollbar methods instead of
constants, and cap the scroll distance if needed.

  • platform/ScrollView.cpp:

(WebCore::ScrollView::updateScrollbars): Ditto.
(WebCore::ScrollView::wheelEvent): Ditto.

  • platform/Scrollbar.cpp:

(WebCore::Scrollbar::maxOverlapBetweenPages): Added. Returns the
value from the native scrollbar theme.

  • platform/Scrollbar.h: Replaced scroll amount constants with static methods.

(WebCore::Scrollbar::pixelsPerLineStep): Replaces cScrollbarPixelsPerLineStep.
(WebCore::Scrollbar::minFractionToStepWhenPaging): Replaces cFractionToStepWhenPaging.

  • platform/ScrollbarTheme.h:

(WebCore::ScrollbarTheme::maxOverlapBetweenPages): A base implementation
that returns the largest int.

  • platform/gtk/WheelEventGtk.cpp:

(WebCore::PlatformWheelEvent::PlatformWheelEvent): Use Scrollbar methods instead of
constants.

  • platform/haiku/PlatformWheelEventHaiku.cpp:

(WebCore::PlatformWheelEvent::PlatformWheelEvent): Use Scrollbar methods instead of
constants.

  • platform/mac/ScrollbarThemeMac.h:

(WebCore::ScrollbarThemeMac::maxOverlapBetweenPages): An override
that returns 40.

  • platform/mac/WheelEventMac.mm:

(WebCore::PlatformWheelEvent::PlatformWheelEvent): Use
Scrollbar::pixelsPerLineStep() instead of cScrollbarPixelsPerLineStep.

  • platform/wx/MouseWheelEventWx.cpp:

(WebCore::PlatformWheelEvent::PlatformWheelEvent): Use Scrollbar methods instead of
constants.

  • platform/wx/ScrollViewWx.cpp:

(WebCore::ScrollView::ScrollViewPrivate::OnScrollWinEvents): Use Scrollbar
methods instead of constants, and cap the scroll distance if needed.

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::updateScrollInfoAfterLayout): Ditto.

WebKit/mac:

  • WebView/WebFrameView.mm:

(-[WebFrameView _verticalPageScrollDistance]): Use Scrollbar methods instead of
constants, and cap the scroll distance.
(-[WebFrameView initWithFrame:]): Use Scrollbar::pixelsPerLineStep() instead of
cScrollbarPixelsPerLineStep.
(-[WebFrameView _horizontalPageScrollDistance]):Use Scrollbar methods instead of
constants, and cap the scroll distance.

WebKit/wx:

  • WebView.cpp:

(wxWebView::OnKeyEvents): Use Scrollbar method instead of constant.

Location:
trunk
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r54344 r54345  
     12010-02-04  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        REGRESSION (r53718): When scrolling a tall window by page, the overlap between pages is too big
     6        https://bugs.webkit.org/show_bug.cgi?id=34371
     7
     8        Allow ScrollbarTheme to cap the overlap between pages, and set a cap of
     9        40 in ScrollbarThemeMac.
     10
     11        * WebCore.base.exp: Export Scrollbar::maxOverlapBetweenPages().
     12        * editing/EditorCommand.cpp:
     13        (WebCore::verticalScrollDistance): Use Scrollbar methods instead of
     14        constants, and cap the scroll distance if needed.
     15        * platform/ScrollView.cpp:
     16        (WebCore::ScrollView::updateScrollbars): Ditto.
     17        (WebCore::ScrollView::wheelEvent): Ditto.
     18        * platform/Scrollbar.cpp:
     19        (WebCore::Scrollbar::maxOverlapBetweenPages): Added. Returns the
     20        value from the native scrollbar theme.
     21        * platform/Scrollbar.h: Replaced scroll amount constants with static methods.
     22        (WebCore::Scrollbar::pixelsPerLineStep): Replaces cScrollbarPixelsPerLineStep.
     23        (WebCore::Scrollbar::minFractionToStepWhenPaging): Replaces cFractionToStepWhenPaging.
     24        * platform/ScrollbarTheme.h:
     25        (WebCore::ScrollbarTheme::maxOverlapBetweenPages): A base implementation
     26        that returns the largest int.
     27        * platform/gtk/WheelEventGtk.cpp:
     28        (WebCore::PlatformWheelEvent::PlatformWheelEvent): Use Scrollbar methods instead of
     29        constants.
     30        * platform/haiku/PlatformWheelEventHaiku.cpp:
     31        (WebCore::PlatformWheelEvent::PlatformWheelEvent): Use Scrollbar methods instead of
     32        constants.
     33        * platform/mac/ScrollbarThemeMac.h:
     34        (WebCore::ScrollbarThemeMac::maxOverlapBetweenPages): An override
     35        that returns 40.
     36        * platform/mac/WheelEventMac.mm:
     37        (WebCore::PlatformWheelEvent::PlatformWheelEvent): Use
     38        Scrollbar::pixelsPerLineStep() instead of cScrollbarPixelsPerLineStep.
     39        * platform/wx/MouseWheelEventWx.cpp:
     40        (WebCore::PlatformWheelEvent::PlatformWheelEvent): Use Scrollbar methods instead of
     41        constants.
     42        * platform/wx/ScrollViewWx.cpp:
     43        (WebCore::ScrollView::ScrollViewPrivate::OnScrollWinEvents): Use Scrollbar
     44        methods instead of constants, and cap the scroll distance if needed.
     45        * rendering/RenderLayer.cpp:
     46        (WebCore::RenderLayer::updateScrollInfoAfterLayout): Ditto.
     47
    1482010-02-04  No'am Rosenthal  <noam.rosenthal@nokia.com>
    249
  • trunk/WebCore/WebCore.base.exp

    r54205 r54345  
     1
    12.objc_class_name_DOMAbstractView
    23.objc_class_name_DOMAttr
     
    761762__ZN7WebCore9PageGroup30removeUserStyleSheetsFromWorldEPNS_15DOMWrapperWorldE
    762763__ZN7WebCore9PageGroup9pageGroupERKNS_6StringE
     764__ZN7WebCore9Scrollbar22maxOverlapBetweenPagesEv
    763765__ZN7WebCore9TimerBase4stopEv
    764766__ZN7WebCore9TimerBase5startEdd
     
    10581060_wkSignalCFReadStreamError
    10591061_wkSignalCFReadStreamHasBytes
    1060 
  • trunk/WebCore/editing/EditorCommand.cpp

    r53718 r54345  
    261261        return 0;
    262262    int height = toRenderBox(renderer)->clientHeight();
    263     return max(height * cFractionToStepWhenPaging, 1.f);
     263    return max(max<int>(height * Scrollbar::minFractionToStepWhenPaging(), height - Scrollbar::maxOverlapBetweenPages()), 1);
    264264}
    265265
  • trunk/WebCore/platform/ScrollView.cpp

    r53877 r54345  
    426426        int clientWidth = visibleWidth();
    427427        m_horizontalScrollbar->setEnabled(contentsWidth() > clientWidth);
    428         int pageStep = max(clientWidth * cFractionToStepWhenPaging, 1.f);
     428        int pageStep = max(max<int>(clientWidth * Scrollbar::minFractionToStepWhenPaging(), clientWidth - Scrollbar::maxOverlapBetweenPages()), 1);
    429429        IntRect oldRect(m_horizontalScrollbar->frameRect());
    430430        IntRect hBarRect = IntRect(0,
     
    438438        if (m_scrollbarsSuppressed)
    439439            m_horizontalScrollbar->setSuppressInvalidation(true);
    440         m_horizontalScrollbar->setSteps(cScrollbarPixelsPerLineStep, pageStep);
     440        m_horizontalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
    441441        m_horizontalScrollbar->setProportion(clientWidth, contentsWidth());
    442442        m_horizontalScrollbar->setValue(scroll.width());
     
    448448        int clientHeight = visibleHeight();
    449449        m_verticalScrollbar->setEnabled(contentsHeight() > clientHeight);
    450         int pageStep = max(clientHeight * cFractionToStepWhenPaging, 1.f);
     450        int pageStep = max(max<int>(clientHeight * Scrollbar::minFractionToStepWhenPaging(), clientHeight - Scrollbar::maxOverlapBetweenPages()), 1);
    451451        if (pageStep < 0)
    452452            pageStep = clientHeight;
     
    462462        if (m_scrollbarsSuppressed)
    463463            m_verticalScrollbar->setSuppressInvalidation(true);
    464         m_verticalScrollbar->setSteps(cScrollbarPixelsPerLineStep, pageStep);
     464        m_verticalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
    465465        m_verticalScrollbar->setProportion(clientHeight, contentsHeight());
    466466        m_verticalScrollbar->setValue(scroll.height());
     
    664664            ASSERT(deltaX == 0);
    665665            bool negative = deltaY < 0;
    666             deltaY = max(visibleHeight() * cFractionToStepWhenPaging, 1.f);
     666            deltaY = max(max<int>(visibleHeight() * Scrollbar::minFractionToStepWhenPaging(), visibleHeight() - Scrollbar::maxOverlapBetweenPages()), 1);
    667667            if (negative)
    668668                deltaY = -deltaY;
  • trunk/WebCore/platform/Scrollbar.cpp

    r53651 r54345  
    3939#include <algorithm>
    4040
    41 using std::max;
    42 using std::min;
     41using namespace std;
    4342
    4443namespace WebCore {
     
    5049}
    5150#endif
     51
     52int Scrollbar::maxOverlapBetweenPages()
     53{
     54    static int maxOverlapBetweenPages = ScrollbarTheme::nativeTheme()->maxOverlapBetweenPages();
     55    return maxOverlapBetweenPages;
     56}
    5257
    5358Scrollbar::Scrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize controlSize,
  • trunk/WebCore/platform/Scrollbar.h

    r53718 r54345  
    4141class PlatformMouseEvent;
    4242
    43 const int cScrollbarPixelsPerLineStep = 40;
    44 const float cFractionToStepWhenPaging = 0.875f;
    45 
    4643class Scrollbar : public Widget {
    47 protected:
    48     Scrollbar(ScrollbarClient*, ScrollbarOrientation, ScrollbarControlSize, ScrollbarTheme* = 0);
    49 
    5044public:
    5145    virtual ~Scrollbar();
     
    5347    // Must be implemented by platforms that can't simply use the Scrollbar base class.  Right now the only platform that is not using the base class is GTK.
    5448    static PassRefPtr<Scrollbar> createNativeScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize size);
    55    
     49
     50    static int pixelsPerLineStep() { return 40; }
     51    static float minFractionToStepWhenPaging() { return 0.875f; }
     52    static int maxOverlapBetweenPages();
     53
    5654    void setClient(ScrollbarClient* client) { m_client = client; }
    5755    ScrollbarClient* client() const { return m_client; }
     
    131129
    132130protected:
     131    Scrollbar(ScrollbarClient*, ScrollbarOrientation, ScrollbarControlSize, ScrollbarTheme* = 0);
     132
    133133    virtual void updateThumbPosition();
    134134    virtual void updateThumbProportion();
  • trunk/WebCore/platform/ScrollbarTheme.h

    r51466 r54345  
    8282    virtual int trackPosition(Scrollbar*) { return 0; } // The position of the track relative to the scrollbar.
    8383    virtual int trackLength(Scrollbar*) { return 0; } // The length of the track along the axis of the scrollbar.
    84    
     84
     85    virtual int maxOverlapBetweenPages() { return std::numeric_limits<int>::max(); }
     86
    8587    virtual double initialAutoscrollTimerDelay() { return 0.25; }
    8688    virtual double autoscrollTimerDelay() { return 0.05; }
  • trunk/WebCore/platform/gtk/WheelEventGtk.cpp

    r42199 r54345  
    7070
    7171    // FIXME: retrieve the user setting for the number of lines to scroll on each wheel event
    72     m_deltaX *= static_cast<float>(cScrollbarPixelsPerLineStep);
    73     m_deltaY *= static_cast<float>(cScrollbarPixelsPerLineStep);
     72    m_deltaX *= static_cast<float>(Scrollbar::pixelsPerLineStep());
     73    m_deltaY *= static_cast<float>(Scrollbar::pixelsPerLineStep());
    7474}
    7575
  • trunk/WebCore/platform/haiku/PlatformWheelEventHaiku.cpp

    r46934 r54345  
    5555    m_wheelTicksY = m_deltaY;
    5656
    57     m_deltaX *= -cScrollbarPixelsPerLineStep;
    58     m_deltaY *= -cScrollbarPixelsPerLineStep;
     57    m_deltaX *= -Scrollbar::pixelsPerLineStep();
     58    m_deltaY *= -Scrollbar::pixelsPerLineStep();
    5959}
    6060
  • trunk/WebCore/platform/mac/ScrollbarThemeMac.h

    r37118 r54345  
    5858    virtual IntRect trackRect(Scrollbar*, bool painting = false);
    5959
     60    virtual int maxOverlapBetweenPages() { return 40; }
     61
    6062    virtual int minimumThumbLength(Scrollbar*);
    6163   
  • trunk/WebCore/platform/mac/WheelEventMac.mm

    r44379 r54345  
    4646    wkGetWheelEventDeltas(event, &m_deltaX, &m_deltaY, &continuous);
    4747    if (continuous) {
    48         m_wheelTicksX = m_deltaX / static_cast<float>(cScrollbarPixelsPerLineStep);
    49         m_wheelTicksY = m_deltaY / static_cast<float>(cScrollbarPixelsPerLineStep);
     48        m_wheelTicksX = m_deltaX / static_cast<float>(Scrollbar::pixelsPerLineStep());
     49        m_wheelTicksY = m_deltaY / static_cast<float>(Scrollbar::pixelsPerLineStep());
    5050    } else {
    5151        m_wheelTicksX = m_deltaX;
    5252        m_wheelTicksY = m_deltaY;
    53         m_deltaX *= static_cast<float>(cScrollbarPixelsPerLineStep);
    54         m_deltaY *= static_cast<float>(cScrollbarPixelsPerLineStep);
     53        m_deltaX *= static_cast<float>(Scrollbar::pixelsPerLineStep());
     54        m_deltaY *= static_cast<float>(Scrollbar::pixelsPerLineStep());
    5555    }
    5656}
  • trunk/WebCore/platform/wx/MouseWheelEventWx.cpp

    r41779 r54345  
    4848{
    4949    // FIXME: retrieve the user setting for the number of lines to scroll on each wheel event
    50     m_deltaY *= static_cast<float>(cScrollbarPixelsPerLineStep);
     50    m_deltaY *= static_cast<float>(Scrollbar::pixelsPerLineStep());
    5151}
    5252
  • trunk/WebCore/platform/wx/ScrollViewWx.cpp

    r53718 r54345  
    8585        else if (scrollType == wxEVT_SCROLLWIN_LINEDOWN) {
    8686            if (horiz)
    87                 pos.x += cScrollbarPixelsPerLineStep;
    88             else       
    89                 pos.y += cScrollbarPixelsPerLineStep;
     87                pos.x += Scrollbar::pixelsPerLineStep();
     88            else       
     89                pos.y += Scrollbar::pixelsPerLineStep();
    9090        }
    9191        else if (scrollType == wxEVT_SCROLLWIN_LINEUP) {
    9292            if (horiz)
    93                 pos.x -= cScrollbarPixelsPerLineStep;
    94             else       
    95                 pos.y -= cScrollbarPixelsPerLineStep;
     93                pos.x -= Scrollbar::pixelsPerLineStep();
     94            else       
     95                pos.y -= Scrollbar::pixelsPerLineStep();
    9696        }
    9797        else if (scrollType == wxEVT_SCROLLWIN_PAGEUP) {
    9898            if (horiz)
    99                 pos.x -= m_scrollView->visibleWidth() * cFractionToStepWhenPaging;
    100             else       
    101                 pos.y -= m_scrollView->visibleHeight() * cFractionToStepWhenPaging;
     99                pos.x -= max<int>(m_scrollView->visibleWidth() * Scrollbar::minFractionToStepWhenPaging(), m_scrollView->visibleWidth() - Scrollbar::maxOverlapBetweenPages());
     100            else       
     101                pos.y -= max<int>(m_scrollView->visibleHeight() * Scrollbar::minFractionToStepWhenPaging(), m_scrollView->visibleHeight() - Scrollbar::maxOverlapBetweenPages());
    102102        }
    103103        else if (scrollType == wxEVT_SCROLLWIN_PAGEDOWN) {
    104104            if (horiz)
    105                 pos.x += m_scrollView->visibleWidth() * cFractionToStepWhenPaging;
    106             else       
    107                 pos.y += m_scrollView->visibleHeight() * cFractionToStepWhenPaging;
     105                pos.x += max<int>(m_scrollView->visibleWidth() * Scrollbar::minFractionToStepWhenPaging(), m_scrollView->visibleWidth() - Scrollbar::maxOverlapBetweenPages());
     106            else       
     107                pos.y += max<int>(m_scrollView->visibleHeight() * Scrollbar::minFractionToStepWhenPaging(), m_scrollView->visibleHeight() - Scrollbar::maxOverlapBetweenPages());
    108108        }
    109109        else
  • trunk/WebCore/rendering/RenderLayer.cpp

    r54006 r54345  
    19351935    if (m_hBar) {
    19361936        int clientWidth = box->clientWidth();
    1937         int pageStep = max(clientWidth * cFractionToStepWhenPaging, 1.f);
    1938         m_hBar->setSteps(cScrollbarPixelsPerLineStep, pageStep);
     1937        int pageStep = max(max<int>(clientWidth * Scrollbar::minFractionToStepWhenPaging(), clientWidth - Scrollbar::maxOverlapBetweenPages()), 1);
     1938        m_hBar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
    19391939        m_hBar->setProportion(clientWidth, m_scrollWidth);
    19401940        // Explicitly set the horizontal scroll value.  This ensures that when a
     
    19501950    if (m_vBar) {
    19511951        int clientHeight = box->clientHeight();
    1952         int pageStep = max(clientHeight * cFractionToStepWhenPaging, 1.f);
    1953         m_vBar->setSteps(cScrollbarPixelsPerLineStep, pageStep);
     1952        int pageStep = max(max<int>(clientHeight * Scrollbar::minFractionToStepWhenPaging(), clientHeight - Scrollbar::maxOverlapBetweenPages()), 1);
     1953        m_vBar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
    19541954        m_vBar->setProportion(clientHeight, m_scrollHeight);
    19551955    }
  • trunk/WebKit/mac/ChangeLog

    r54268 r54345  
     12010-02-04  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        REGRESSION (r53718): When scrolling a tall window by page, the overlap between pages is too big
     6        https://bugs.webkit.org/show_bug.cgi?id=34371
     7
     8        * WebView/WebFrameView.mm:
     9        (-[WebFrameView _verticalPageScrollDistance]): Use Scrollbar methods instead of
     10        constants, and cap the scroll distance.
     11        (-[WebFrameView initWithFrame:]): Use Scrollbar::pixelsPerLineStep() instead of
     12        cScrollbarPixelsPerLineStep.
     13        (-[WebFrameView _horizontalPageScrollDistance]):Use Scrollbar methods instead of
     14        constants, and cap the scroll distance.
     15
    1162010-02-01  Shinichiro Hamaji  <hamaji@chromium.org>
    217
  • trunk/WebKit/mac/WebView/WebFrameView.mm

    r53718 r54345  
    202202{
    203203    float height = [[self _contentView] bounds].size.height;
    204     return max(height * cFractionToStepWhenPaging, 1.f);
     204    return max<float>(height * Scrollbar::minFractionToStepWhenPaging(), height - Scrollbar::maxOverlapBetweenPages());
    205205}
    206206
     
    343343    [scrollView setHasHorizontalScroller:NO];
    344344    [scrollView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
    345     [scrollView setLineScroll:cScrollbarPixelsPerLineStep];
     345    [scrollView setLineScroll:Scrollbar::pixelsPerLineStep()];
    346346    [self addSubview:scrollView];
    347347
     
    614614{
    615615    float width = [[self _contentView] bounds].size.width;
    616     return max(width * cFractionToStepWhenPaging, 1.f);
     616    return max<float>(width * Scrollbar::minFractionToStepWhenPaging(), width - Scrollbar::maxOverlapBetweenPages());
    617617}
    618618
  • trunk/WebKit/wx/ChangeLog

    r54309 r54345  
     12010-02-04  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        REGRESSION (r53718): When scrolling a tall window by page, the overlap between pages is too big
     6        https://bugs.webkit.org/show_bug.cgi?id=34371
     7
     8        * WebView.cpp:
     9        (wxWebView::OnKeyEvents): Use Scrollbar method instead of constant.
     10
    1112010-02-03  Kevin Watters  <kevinwatters@gmail.com>
    212
  • trunk/WebKit/wx/WebView.cpp

    r54105 r54345  
    798798        case WXK_LEFT:
    799799        case WXK_NUMPAD_LEFT:
    800             frame->view()->scrollBy(WebCore::IntSize(-WebCore::cScrollbarPixelsPerLineStep, 0));
     800            frame->view()->scrollBy(WebCore::IntSize(-WebCore::Scrollbar::pixelsPerLineStep(), 0));
    801801            return;
    802802        case WXK_UP:
    803803        case WXK_NUMPAD_UP:
    804             frame->view()->scrollBy(WebCore::IntSize(0, -WebCore::cScrollbarPixelsPerLineStep));
     804            frame->view()->scrollBy(WebCore::IntSize(0, -WebCore::Scrollbar::pixelsPerLineStep()));
    805805            return;
    806806        case WXK_RIGHT:
    807807        case WXK_NUMPAD_RIGHT:
    808             frame->view()->scrollBy(WebCore::IntSize(WebCore::cScrollbarPixelsPerLineStep, 0));
     808            frame->view()->scrollBy(WebCore::IntSize(WebCore::Scrollbar::pixelsPerLineStep(), 0));
    809809            return;
    810810        case WXK_DOWN:
    811811        case WXK_NUMPAD_DOWN:
    812             frame->view()->scrollBy(WebCore::IntSize(0, WebCore::cScrollbarPixelsPerLineStep));
     812            frame->view()->scrollBy(WebCore::IntSize(0, WebCore::Scrollbar::pixelsPerLineStep()));
    813813            return;
    814814        case WXK_END:
     
    822822        case WXK_PAGEUP:
    823823        case WXK_NUMPAD_PAGEUP:
    824             frame->view()->scrollBy(WebCore::IntSize(0, -frame->view()->visibleHeight() * WebCore::cFractionToStepWhenPaging));
     824            frame->view()->scrollBy(WebCore::IntSize(0, -frame->view()->visibleHeight() * WebCore::ScrollBar::minFractionToStepWhenPaging()));
    825825            return;
    826826        case WXK_PAGEDOWN:
    827827        case WXK_NUMPAD_PAGEDOWN:
    828             frame->view()->scrollBy(WebCore::IntSize(0, frame->view()->visibleHeight() * WebCore::cFractionToStepWhenPaging));
     828            frame->view()->scrollBy(WebCore::IntSize(0, frame->view()->visibleHeight() * WebCore::ScrollBar::minFractionToStepWhenPaging()));
    829829            return;
    830830        //These we don't want turning into char events, stuff 'em
Note: See TracChangeset for help on using the changeset viewer.