Changeset 53718 in webkit


Ignore:
Timestamp:
Jan 22, 2010 2:17:17 PM (14 years ago)
Author:
pkasting@chromium.org
Message:

When scrolling by page, hold back 1/8th of the visible size instead of
40 px.
https://bugs.webkit.org/show_bug.cgi?id=32595

Reviewed by David Hyatt.

WebCore:

  • editing/EditorCommand.cpp:

(WebCore::verticalScrollDistance):

  • platform/ScrollView.cpp:

(WebCore::ScrollView::updateScrollbars):
(WebCore::ScrollView::wheelEvent):

  • platform/Scrollbar.h:
  • platform/wx/ScrollViewWx.cpp:

(WebCore::ScrollView::ScrollViewPrivate::OnScrollWinEvents):

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::updateScrollInfoAfterLayout):

WebKit/mac:

  • WebView/WebFrameView.mm:

(-[WebFrameView _verticalPageScrollDistance]):
(-[WebFrameView initWithFrame:]):
(-[WebFrameView _horizontalPageScrollDistance]):

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r53716 r53718  
     12010-01-22  Peter Kasting  <pkasting@google.com>
     2
     3        Reviewed by David Hyatt.
     4
     5        When scrolling by page, hold back 1/8th of the visible size instead of
     6        40 px.
     7        https://bugs.webkit.org/show_bug.cgi?id=32595
     8
     9        * editing/EditorCommand.cpp:
     10        (WebCore::verticalScrollDistance):
     11        * platform/ScrollView.cpp:
     12        (WebCore::ScrollView::updateScrollbars):
     13        (WebCore::ScrollView::wheelEvent):
     14        * platform/Scrollbar.h:
     15        * platform/wx/ScrollViewWx.cpp:
     16        (WebCore::ScrollView::ScrollViewPrivate::OnScrollWinEvents):
     17        * rendering/RenderLayer.cpp:
     18        (WebCore::RenderLayer::updateScrollInfoAfterLayout):
     19
    1202010-01-22  Peter Kasting  <pkasting@google.com>
    221
  • trunk/WebCore/editing/EditorCommand.cpp

    r52314 r53718  
    261261        return 0;
    262262    int height = toRenderBox(renderer)->clientHeight();
    263     return max((height + 1) / 2, height - cAmountToKeepWhenPaging);
     263    return max(height * cFractionToStepWhenPaging, 1.f);
    264264}
    265265
  • trunk/WebCore/platform/ScrollView.cpp

    r53713 r53718  
    426426        int clientWidth = visibleWidth();
    427427        m_horizontalScrollbar->setEnabled(contentsWidth() > clientWidth);
    428         int pageStep = (clientWidth - cAmountToKeepWhenPaging);
    429         if (pageStep < 0)
    430             pageStep = clientWidth;
     428        int pageStep = max(clientWidth * cFractionToStepWhenPaging, 1.f);
    431429        IntRect oldRect(m_horizontalScrollbar->frameRect());
    432430        IntRect hBarRect = IntRect(0,
     
    450448        int clientHeight = visibleHeight();
    451449        m_verticalScrollbar->setEnabled(contentsHeight() > clientHeight);
    452         int pageStep = (clientHeight - cAmountToKeepWhenPaging);
     450        int pageStep = max(clientHeight * cFractionToStepWhenPaging, 1.f);
    453451        if (pageStep < 0)
    454452            pageStep = clientHeight;
     
    666664            ASSERT(deltaX == 0);
    667665            bool negative = deltaY < 0;
    668             deltaY = max(0, visibleHeight() - cAmountToKeepWhenPaging);
     666            deltaY = max(visibleHeight() * cFractionToStepWhenPaging, 1.f);
    669667            if (negative)
    670668                deltaY = -deltaY;
  • trunk/WebCore/platform/Scrollbar.h

    r45679 r53718  
    4141class PlatformMouseEvent;
    4242
    43 // These match the numbers we use over in WebKit (WebFrameView.m).
    4443const int cScrollbarPixelsPerLineStep = 40;
    45 const int cAmountToKeepWhenPaging = 40;
     44const float cFractionToStepWhenPaging = 0.875f;
    4645
    4746class Scrollbar : public Widget {
  • trunk/WebCore/platform/wx/ScrollViewWx.cpp

    r43265 r53718  
    9797        else if (scrollType == wxEVT_SCROLLWIN_PAGEUP) {
    9898            if (horiz)
    99                 pos.x -= m_scrollView->visibleWidth() - cAmountToKeepWhenPaging;
    100             else       
    101                 pos.y -= m_scrollView->visibleHeight() - cAmountToKeepWhenPaging;
     99                pos.x -= m_scrollView->visibleWidth() * cFractionToStepWhenPaging;
     100            else       
     101                pos.y -= m_scrollView->visibleHeight() * cFractionToStepWhenPaging;
    102102        }
    103103        else if (scrollType == wxEVT_SCROLLWIN_PAGEDOWN) {
    104104            if (horiz)
    105                 pos.x += m_scrollView->visibleWidth() - cAmountToKeepWhenPaging;
    106             else       
    107                 pos.y += m_scrollView->visibleHeight() - cAmountToKeepWhenPaging;
     105                pos.x += m_scrollView->visibleWidth() * cFractionToStepWhenPaging;
     106            else       
     107                pos.y += m_scrollView->visibleHeight() * cFractionToStepWhenPaging;
    108108        }
    109109        else
  • trunk/WebCore/rendering/RenderLayer.cpp

    r53175 r53718  
    18961896    if (m_hBar) {
    18971897        int clientWidth = box->clientWidth();
    1898         int pageStep = (clientWidth - cAmountToKeepWhenPaging);
    1899         if (pageStep < 0) pageStep = clientWidth;
     1898        int pageStep = max(clientWidth * cFractionToStepWhenPaging, 1.f);
    19001899        m_hBar->setSteps(cScrollbarPixelsPerLineStep, pageStep);
    19011900        m_hBar->setProportion(clientWidth, m_scrollWidth);
     
    19121911    if (m_vBar) {
    19131912        int clientHeight = box->clientHeight();
    1914         int pageStep = (clientHeight - cAmountToKeepWhenPaging);
    1915         if (pageStep < 0) pageStep = clientHeight;
     1913        int pageStep = max(clientHeight * cFractionToStepWhenPaging, 1.f);
    19161914        m_vBar->setSteps(cScrollbarPixelsPerLineStep, pageStep);
    19171915        m_vBar->setProportion(clientHeight, m_scrollHeight);
  • trunk/WebKit/mac/ChangeLog

    r53574 r53718  
     12010-01-22  Peter Kasting  <pkasting@google.com>
     2
     3        Reviewed by David Hyatt.
     4
     5        When scrolling by page, hold back 1/8th of the visible size instead of
     6        40 px.
     7        https://bugs.webkit.org/show_bug.cgi?id=32595
     8
     9        * WebView/WebFrameView.mm:
     10        (-[WebFrameView _verticalPageScrollDistance]):
     11        (-[WebFrameView initWithFrame:]):
     12        (-[WebFrameView _horizontalPageScrollDistance]):
     13
    1142010-01-20  Jian Li  <jianli@chromium.org>
    215
  • trunk/WebKit/mac/WebView/WebFrameView.mm

    r52314 r53718  
    201201- (float)_verticalPageScrollDistance
    202202{
    203     float overlap = [self _verticalKeyboardScrollDistance];
    204203    float height = [[self _contentView] bounds].size.height;
    205     return (height < overlap) ? height / 2 : height - overlap;
     204    return max(height * cFractionToStepWhenPaging, 1.f);
    206205}
    207206
     
    344343    [scrollView setHasHorizontalScroller:NO];
    345344    [scrollView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
    346     [scrollView setLineScroll:40.0f];
     345    [scrollView setLineScroll:cScrollbarPixelsPerLineStep];
    347346    [self addSubview:scrollView];
    348347
     
    614613- (float)_horizontalPageScrollDistance
    615614{
    616     float overlap = [self _horizontalKeyboardScrollDistance];
    617615    float width = [[self _contentView] bounds].size.width;
    618     return (width < overlap) ? width / 2 : width - overlap;
     616    return max(width * cFractionToStepWhenPaging, 1.f);
    619617}
    620618
Note: See TracChangeset for help on using the changeset viewer.