Changeset 73063 in webkit


Ignore:
Timestamp:
Dec 1, 2010, 1:31:50 PM (15 years ago)
Author:
hyatt@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=46645

Reviewed by Darin Adler.

Part 1 of making scrolling work with vertical text. This patch generalizes the scrollOriginX concept
recently added for horizontal RTL documents and applies it to writing modes as well. Now the
scrollOrigin is a point, since you can start off locked to the bottom or locked to the right.

This patch also fixes numerous bugs with the scrollOrigin code using native Mac NSScrollViews and
makes them behave the same as the cross-platform code (allowing for cross-platform results to be
landed).

WebCore:

  • page/FrameView.cpp:

(WebCore::FrameView::adjustViewSize):

  • page/mac/WebCoreFrameView.h:
  • platform/ScrollView.cpp:

(WebCore::ScrollView::ScrollView):
(WebCore::ScrollView::maximumScrollPosition):
(WebCore::ScrollView::minimumScrollPosition):
(WebCore::ScrollView::valueChanged):
(WebCore::ScrollView::updateScrollbars):
(WebCore::ScrollView::wheelEvent):

  • platform/ScrollView.h:

(WebCore::ScrollView::scrollOrigin):

  • platform/mac/ScrollViewMac.mm:

(WebCore::ScrollView::platformSetScrollPosition):
(WebCore::ScrollView::platformSetScrollOrigin):

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::paintRootBoxDecorations):

  • rendering/RenderView.cpp:

(WebCore::RenderView::layout):
(WebCore::RenderView::docTop):
(WebCore::RenderView::docHeight):
(WebCore::RenderView::docLeft):
(WebCore::RenderView::docWidth):

  • rendering/RenderView.h:

WebKit/mac:

  • WebView/WebDynamicScrollBarsView.mm:

(-[WebDynamicScrollBarsView adjustForScrollOriginChange]):
(-[WebDynamicScrollBarsView updateScrollers]):
(-[WebDynamicScrollBarsView reflectScrolledClipView:]):
(-[WebDynamicScrollBarsView setScrollOrigin:updatePosition:]):
(-[WebDynamicScrollBarsView scrollOrigin]):

  • WebView/WebFrameView.mm:

(-[WebFrameView _scrollToBeginningOfDocument]):
(-[WebFrameView _scrollToEndOfDocument]):

LayoutTests:

  • fast/dom/vertical-scrollbar-in-rtl-doesnt-fire-onscroll-expected.txt: Added.
  • fast/dom/vertical-scrollbar-in-rtl-doesnt-fire-onscroll.html: Added.
  • fast/dom/vertical-scrollbar-in-rtl-expected.txt: Added.
  • fast/dom/vertical-scrollbar-in-rtl.html: Added.
  • fast/dom/vertical-scrollbar-when-dir-change-expected.txt: Added.
  • fast/dom/vertical-scrollbar-when-dir-change.html: Added.
  • platform/mac/fast/dom/horizontal-scrollbar-in-rtl-expected.txt: Removed.
  • platform/mac/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt: Removed.
Location:
trunk
Files:
8 added
2 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r73061 r73063  
     12010-12-01  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=46645
     6       
     7        Part 1 of making scrolling work with vertical text. This patch generalizes the scrollOriginX concept
     8        recently added for horizontal RTL documents and applies it to writing modes as well.  Now the
     9        scrollOrigin is a point, since you can start off locked to the bottom or locked to the right.
     10       
     11        This patch also fixes numerous bugs with the scrollOrigin code using native Mac NSScrollViews and
     12        makes them behave the same as the cross-platform code (allowing for cross-platform results to be
     13        landed).
     14
     15        * fast/dom/vertical-scrollbar-in-rtl-doesnt-fire-onscroll-expected.txt: Added.
     16        * fast/dom/vertical-scrollbar-in-rtl-doesnt-fire-onscroll.html: Added.
     17        * fast/dom/vertical-scrollbar-in-rtl-expected.txt: Added.
     18        * fast/dom/vertical-scrollbar-in-rtl.html: Added.
     19        * fast/dom/vertical-scrollbar-when-dir-change-expected.txt: Added.
     20        * fast/dom/vertical-scrollbar-when-dir-change.html: Added.
     21        * platform/mac/fast/dom/horizontal-scrollbar-in-rtl-expected.txt: Removed.
     22        * platform/mac/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt: Removed.
     23
    1242010-12-01  Victor Wang  <victorw@chromium.org>
    225
  • trunk/WebCore/ChangeLog

    r73062 r73063  
     12010-12-01  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=46645
     6       
     7        Part 1 of making scrolling work with vertical text. This patch generalizes the scrollOriginX concept
     8        recently added for horizontal RTL documents and applies it to writing modes as well.  Now the
     9        scrollOrigin is a point, since you can start off locked to the bottom or locked to the right.
     10       
     11        This patch also fixes numerous bugs with the scrollOrigin code using native Mac NSScrollViews and
     12        makes them behave the same as the cross-platform code (allowing for cross-platform results to be
     13        landed).
     14
     15        * page/FrameView.cpp:
     16        (WebCore::FrameView::adjustViewSize):
     17        * page/mac/WebCoreFrameView.h:
     18        * platform/ScrollView.cpp:
     19        (WebCore::ScrollView::ScrollView):
     20        (WebCore::ScrollView::maximumScrollPosition):
     21        (WebCore::ScrollView::minimumScrollPosition):
     22        (WebCore::ScrollView::valueChanged):
     23        (WebCore::ScrollView::updateScrollbars):
     24        (WebCore::ScrollView::wheelEvent):
     25        * platform/ScrollView.h:
     26        (WebCore::ScrollView::scrollOrigin):
     27        * platform/mac/ScrollViewMac.mm:
     28        (WebCore::ScrollView::platformSetScrollPosition):
     29        (WebCore::ScrollView::platformSetScrollOrigin):
     30        * rendering/RenderBox.cpp:
     31        (WebCore::RenderBox::paintRootBoxDecorations):
     32        * rendering/RenderView.cpp:
     33        (WebCore::RenderView::layout):
     34        (WebCore::RenderView::docTop):
     35        (WebCore::RenderView::docHeight):
     36        (WebCore::RenderView::docLeft):
     37        (WebCore::RenderView::docWidth):
     38        * rendering/RenderView.h:
     39
    1402010-11-30  Steve Block  <steveblock@google.com>
    241
  • trunk/WebCore/page/FrameView.cpp

    r72852 r73063  
    436436        return;
    437437
    438     int prevScrollOriginX = scrollOriginX();
    439     ScrollView::setScrollOriginX(-root->leftLayoutOverflow());
    440     IntSize size = IntSize(root->rightLayoutOverflow() - root->leftLayoutOverflow(), root->bottomLayoutOverflow());
    441     // Take care of the case when contents remain but the RenderView's direction has changed.
    442     // In which case, we need to update scroller position, for example, from leftmost to
    443     // rightmost when direction changes from left-to-right to right-to-left.
    444     bool directionChanged = (!prevScrollOriginX || !scrollOriginX()) && (scrollOriginX() != prevScrollOriginX);
    445     if (size == contentsSize() && directionChanged)
    446         ScrollView::updateScrollbars();
     438    IntSize size = IntSize(root->rightLayoutOverflow() - root->leftLayoutOverflow(), root->bottomLayoutOverflow() - root->topLayoutOverflow());
     439
     440    ScrollView::setScrollOrigin(IntPoint(-root->leftLayoutOverflow(), -root->topLayoutOverflow()), size == contentsSize());
     441   
    447442    setContentsSize(size);
    448443}
  • trunk/WebCore/page/mac/WebCoreFrameView.h

    r72852 r73063  
    3434- (void)scrollingModes:(WebCore::ScrollbarMode*)hMode vertical:(WebCore::ScrollbarMode*)vMode;
    3535- (void)setScrollBarsSuppressed:(BOOL)suppressed repaintOnUnsuppress:(BOOL)repaint;
    36 - (void)setScrollOriginX:(int)scrollOriginX;
    37 - (int)scrollOriginX;
     36- (void)setScrollOrigin:(NSPoint)origin updatePosition:(BOOL)updatePosition;
     37- (NSPoint)scrollOrigin;
    3838@end
    3939
  • trunk/WebCore/platform/ScrollView.cpp

    r72931 r73063  
    5555    , m_paintsEntireContents(false)
    5656    , m_delegatesScrolling(false)
    57     , m_scrollOriginX(0)
    5857{
    5958    platformInit();
     
    280279IntPoint ScrollView::maximumScrollPosition() const
    281280{
    282     IntPoint maximumOffset(contentsWidth() - visibleWidth() - m_scrollOriginX, contentsHeight() - visibleHeight());
     281    IntPoint maximumOffset(contentsWidth() - visibleWidth() - m_scrollOrigin.x(), contentsHeight() - visibleHeight() - m_scrollOrigin.y());
    283282    maximumOffset.clampNegativeToZero();
    284283    return maximumOffset;
     
    287286IntPoint ScrollView::minimumScrollPosition() const
    288287{
    289     return IntPoint(-m_scrollOriginX, 0);
     288    return IntPoint(-m_scrollOrigin.x(), -m_scrollOrigin.y());
    290289}
    291290
     
    317316    if (scrollbar) {
    318317        if (scrollbar->orientation() == HorizontalScrollbar)
    319             newOffset.setWidth(scrollbar->value() - m_scrollOriginX);
     318            newOffset.setWidth(scrollbar->value() - m_scrollOrigin.x());
    320319        else if (scrollbar->orientation() == VerticalScrollbar)
    321             newOffset.setHeight(scrollbar->value());
     320            newOffset.setHeight(scrollbar->value() - m_scrollOrigin.y());
    322321    }
    323322
     
    504503        m_horizontalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
    505504        m_horizontalScrollbar->setProportion(clientWidth, contentsWidth());
    506         m_horizontalScrollbar->setValue(scroll.width() + m_scrollOriginX, Scrollbar::NotFromScrollAnimator);
     505        m_horizontalScrollbar->setValue(scroll.width() + m_scrollOrigin.x(), Scrollbar::NotFromScrollAnimator);
    507506        if (m_scrollbarsSuppressed)
    508507            m_horizontalScrollbar->setSuppressInvalidation(false);
     
    526525        m_verticalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
    527526        m_verticalScrollbar->setProportion(clientHeight, contentsHeight());
    528         m_verticalScrollbar->setValue(scroll.height(), Scrollbar::NotFromScrollAnimator);
     527        m_verticalScrollbar->setValue(scroll.height() + m_scrollOrigin.y(), Scrollbar::NotFromScrollAnimator);
    529528        if (m_scrollbarsSuppressed)
    530529            m_verticalScrollbar->setSuppressInvalidation(false);
     
    10281027}
    10291028
    1030 void ScrollView::setScrollOriginX(int x)
    1031 {
    1032     if (platformWidget())
    1033         platformSetScrollOriginX(x);
    1034 
    1035     m_scrollOriginX = x;
    1036 }
    1037 
    1038 void ScrollView::updateScrollbars()
    1039 {
    1040     if (!platformWidget())
     1029void ScrollView::setScrollOrigin(const IntPoint& origin, bool updatePosition)
     1030{
     1031    if (m_scrollOrigin == origin)
     1032        return;
     1033
     1034    m_scrollOrigin = origin;
     1035
     1036    if (platformWidget()) {
     1037        platformSetScrollOrigin(origin, updatePosition);
     1038        return;
     1039    }
     1040   
     1041    // Update if the scroll origin changes, since our position will be different if the content size did not change.
     1042    if (updatePosition)
    10411043        updateScrollbars(scrollOffset());
    1042     // FIXME: need corresponding functionality from platformWidget.
    10431044}
    10441045
     
    10731074}
    10741075
    1075 void ScrollView::platformSetScrollOriginX(int)
     1076void ScrollView::platformSetScrollOrigin(const IntPoint&, bool updatePosition)
    10761077{
    10771078}
  • trunk/WebCore/platform/ScrollView.h

    r72852 r73063  
    162162    IntPoint maximumScrollPosition() const; // The maximum position we can be scrolled to.
    163163    IntPoint minimumScrollPosition() const; // The minimum position we can be scrolled to.
    164     // Adjust the pass in scroll position within the minimum and maximum positions.
     164    // Adjust the passed in scroll position to keep it between the minimum and maximum positions.
    165165    IntPoint adjustScrollPositionWithinRange(const IntPoint&) const;
    166166    int scrollX() const { return scrollPosition().x(); }
     
    283283    virtual void scrollContentsSlowPath(const IntRect& updateRect);
    284284
    285     void setScrollOriginX(int);
    286     int scrollOriginX() { return m_scrollOriginX; }
    287     void updateScrollbars();
     285    void setScrollOrigin(const IntPoint&, bool updatePosition);
     286    IntPoint scrollOrigin() { return m_scrollOrigin; }
    288287
    289288private:
     
    322321    bool m_delegatesScrolling;
    323322
    324     // m_scrollOriginX is 0 for LTR page. And it is negative of left layout
    325     // overflow for RTL page. It is mainly used to set the horizontal scrollbar
    326     // position for RTL page.
    327     int m_scrollOriginX;
     323    // There are 8 possible combinations of writing mode and direction.  Scroll origin will be non-zero in the x or y axis
     324    // if there is any reversed direction or writing-mode.  The combinations are:
     325    // writing-mode / direction     scrollOrigin.x() set    scrollOrigin.y() set
     326    // horizontal-tb / ltr          NO                      NO
     327    // horizontal-tb / rtl          YES                     NO
     328    // horizontal-bt / ltr          NO                      YES
     329    // horizontal-bt / rtl          YES                     YES
     330    // vertical-lr / ltr            NO                      NO
     331    // vertical-lr / rtl            NO                      YES
     332    // vertical-rl / ltr            YES                     NO
     333    // vertical-rl / rtl            YES                     YES
     334    IntPoint m_scrollOrigin;
    328335
    329336    void init();
     
    355362    bool platformIsOffscreen() const;
    356363   
    357     void platformSetScrollOriginX(int);
     364    void platformSetScrollOrigin(const IntPoint&, bool updatePosition);
    358365
    359366#if PLATFORM(MAC) && defined __OBJC__
  • trunk/WebCore/platform/mac/ScrollViewMac.mm

    r72852 r73063  
    148148{
    149149    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    150     NSPoint tempPoint = { max(-[scrollView() scrollOriginX], scrollPoint.x()), max(0, scrollPoint.y()) };  // Don't use NSMakePoint to work around 4213314.
     150    NSPoint floatPoint = scrollPoint;
     151    NSPoint tempPoint = { max(-[scrollView() scrollOrigin].x, floatPoint.x), max(-[scrollView() scrollOrigin].y, floatPoint.y) };  // Don't use NSMakePoint to work around 4213314.
    151152    [documentView() scrollPoint:tempPoint];
    152153    END_BLOCK_OBJC_EXCEPTIONS;
     
    203204}
    204205
    205 void ScrollView::platformSetScrollOriginX(int x)
    206 {
    207     BEGIN_BLOCK_OBJC_EXCEPTIONS;
    208     [scrollView() setScrollOriginX:x];
     206void ScrollView::platformSetScrollOrigin(const IntPoint& origin, bool updatePosition)
     207{
     208    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     209    [scrollView() setScrollOrigin:origin updatePosition:updatePosition];
    209210    END_BLOCK_OBJC_EXCEPTIONS;
    210211}
  • trunk/WebCore/rendering/RenderBox.cpp

    r72852 r73063  
    774774    // its margins.
    775775    int bx = tx - marginLeft() + view()->leftLayoutOverflow();
    776     int by = ty - marginTop();
     776    int by = ty - marginTop() + view()->topLayoutOverflow();
    777777    int bw = max(w + marginLeft() + marginRight() + borderLeft() + borderRight(), rw);
    778778    int bh = max(h + marginTop() + marginBottom() + borderTop() + borderBottom(), rh);
  • trunk/WebCore/rendering/RenderView.cpp

    r72852 r73063  
    133133    m_overflow.clear();
    134134    int leftOverflow = docLeft();
    135     addLayoutOverflow(IntRect(leftOverflow, 0, docWidth(leftOverflow), docHeight()));
     135    int topOverflow = docTop();
     136    addLayoutOverflow(IntRect(leftOverflow, topOverflow, docWidth(leftOverflow), docHeight(topOverflow)));
    136137
    137138    ASSERT(layoutDelta() == IntSize());
     
    618619}
    619620
    620 int RenderView::docHeight() const
    621 {
    622     int h = lowestPosition();
     621int RenderView::docTop() const
     622{
     623    // Clip out top overflow in vertical LTR pages or horizontal-tb pages.
     624    if ((!style()->isHorizontalWritingMode() && style()->isLeftToRightDirection()) || style()->writingMode() == TopToBottomWritingMode)
     625        return 0;
     626    return std::min(0, topmostPosition());
     627}
     628
     629int RenderView::docHeight(int topOverflow) const
     630{
     631    int h = ((!style()->isHorizontalWritingMode() && style()->isLeftToRightDirection()) || style()->writingMode() == TopToBottomWritingMode) ?
     632                lowestPosition() : height() - topOverflow;
    623633
    624634    // FIXME: This doesn't do any margin collapsing.
     
    637647int RenderView::docLeft() const
    638648{
    639     // Clip out left overflow in LTR page.
    640     return style()->isLeftToRightDirection() ? 0 : std::min(0, leftmostPosition());
     649    // Clip out left overflow in horizontal LTR pages or vertical-lr pages.
     650    if ((style()->isHorizontalWritingMode() && style()->isLeftToRightDirection()) || style()->writingMode() == LeftToRightWritingMode)
     651        return 0;
     652    return std::min(0, leftmostPosition());
    641653}
    642654
    643655int RenderView::docWidth(int leftOverflow) const
    644656{
    645     int w = style()->isLeftToRightDirection() ? rightmostPosition() : width() - leftOverflow;
     657    int w = ((style()->isHorizontalWritingMode() && style()->isLeftToRightDirection()) || style()->writingMode() == LeftToRightWritingMode) ?
     658                rightmostPosition() : width() - leftOverflow;
    646659
    647660    for (RenderBox* c = firstChildBox(); c; c = c->nextSiblingBox()) {
  • trunk/WebCore/rendering/RenderView.h

    r72852 r73063  
    173173private:
    174174    bool shouldRepaint(const IntRect& r) const;
    175        
    176     int docHeight() const;
     175   
     176    int docTop() const;
     177    int docHeight(int topOverflow) const;
    177178    int docLeft() const;
    178179    int docWidth(int leftOverflow) const;
  • trunk/WebKit/mac/ChangeLog

    r72887 r73063  
     12010-12-01  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=46645
     6       
     7        Part 1 of making scrolling work with vertical text. This patch generalizes the scrollOriginX concept
     8        recently added for horizontal RTL documents and applies it to writing modes as well.  Now the
     9        scrollOrigin is a point, since you can start off locked to the bottom or locked to the right.
     10       
     11        This patch also fixes numerous bugs with the scrollOrigin code using native Mac NSScrollViews and
     12        makes them behave the same as the cross-platform code (allowing for cross-platform results to be
     13        landed).
     14
     15        * WebView/WebDynamicScrollBarsView.mm:
     16        (-[WebDynamicScrollBarsView adjustForScrollOriginChange]):
     17        (-[WebDynamicScrollBarsView updateScrollers]):
     18        (-[WebDynamicScrollBarsView reflectScrolledClipView:]):
     19        (-[WebDynamicScrollBarsView setScrollOrigin:updatePosition:]):
     20        (-[WebDynamicScrollBarsView scrollOrigin]):
     21        * WebView/WebFrameView.mm:
     22        (-[WebFrameView _scrollToBeginningOfDocument]):
     23        (-[WebFrameView _scrollToEndOfDocument]):
     24
    1252010-11-29  Dan Bernstein  <mitz@apple.com>
    226
  • trunk/WebKit/mac/WebView/WebDynamicScrollBarsView.mm

    r72852 r73063  
    6464    bool verticalScrollingAllowedButScrollerHidden;
    6565
    66     // scrollOriginX is 0 for LTR page and is the negative of left layout overflow value for RTL page.
    67     int scrollOriginX;
     66    // scrollOrigin is set for various combinations of writing mode and direction.
     67    // See the comment next to the corresponding member in ScrollView.h.
     68    NSPoint scrollOrigin;
    6869
    6970    // Flag to indicate that the scrollbar thumb's initial position needs to
    7071    // be manually set.
    71     bool setScrollbarThumbInitialPosition;
     72    bool scrollOriginChanged;
     73    NSPoint scrollPositionExcludingOrigin;
    7274
    7375    bool inProgrammaticScroll;
     
    216218}
    217219
    218 - (void)refreshInitialScrollbarPosition
    219 {
    220     if (_private->setScrollbarThumbInitialPosition) {
    221         NSView *documentView = [self documentView];
    222         NSRect documentRect = [documentView bounds];
    223 
    224         // If scrollOriginX is non-zero that means that there's a left overflow <=> this is an RTL document and thus
    225         // the initial position of the horizontal scrollbar thumb should be on the right.
    226         // FIXME: If knowledge of document directionality is ever propagated to the scroll view, it probably makes
    227         // more sense to use the directionality directly in the below if statement, rather than doing so indirectly
    228         // through scrollOriginX.
    229         if (_private->scrollOriginX != 0) {
    230             // The call to [NSView scrollPoint:] fires off notification the handler for which needs to know that
    231             // we're setting the initial scroll position so it doesn't interpret this as a user action and
    232             // fire off a JS event.
    233             _private->inProgrammaticScroll = true;
    234             [documentView scrollPoint:NSMakePoint(NSMaxX(documentRect) - NSWidth([self contentViewFrame]), 0)];
    235             _private->inProgrammaticScroll = false;
    236         }
    237         _private->setScrollbarThumbInitialPosition = false;
    238     }
     220- (void)adjustForScrollOriginChange
     221{
     222    if (!_private->scrollOriginChanged)
     223        return;
     224
     225    _private->scrollOriginChanged = false;
     226
     227    NSView *documentView = [self documentView];
     228    NSRect documentRect = [documentView bounds];
     229
     230    // The call to [NSView scrollPoint:] fires off notification the handler for which needs to know that
     231    // we're setting the initial scroll position so it doesn't interpret this as a user action and
     232    // fire off a JS event.
     233    _private->inProgrammaticScroll = true;
     234    [documentView scrollPoint:NSMakePoint(_private->scrollPositionExcludingOrigin.x + documentRect.origin.x, _private->scrollPositionExcludingOrigin.y + documentRect.origin.y)];
     235    _private->inProgrammaticScroll = false;
    239236}
    240237
     
    340337        _private->inUpdateScrollers = YES;
    341338        [self setHasHorizontalScroller:newHasHorizontalScroller];
    342        
    343         // For RTL documents, we need to set the initial position of the
    344         // horizontal scrollbar thumb to be on the right.
    345         if (newHasHorizontalScroller)
    346             _private->setScrollbarThumbInitialPosition = true;
    347        
    348339        _private->inUpdateScrollers = NO;
    349340        needsLayout = YES;
     341        NSView *documentView = [self documentView];
     342        NSRect documentRect = [documentView bounds];
     343        if (documentRect.origin.y < 0 && !newHasHorizontalScroller)
     344            [documentView setBoundsOrigin:NSMakePoint(documentRect.origin.x, documentRect.origin.y + 15)];
    350345    }
    351346
     
    355350        _private->inUpdateScrollers = NO;
    356351        needsLayout = YES;
     352        NSView *documentView = [self documentView];
     353        NSRect documentRect = [documentView bounds];
     354        if (documentRect.origin.x < 0 && !newHasVerticalScroller)
     355            [documentView setBoundsOrigin:NSMakePoint(documentRect.origin.x + 15, documentRect.origin.y)];
    357356    }
    358357
     
    411410    // position to 0 (the left) when the view is initially displayed.
    412411    // This call updates the initial position correctly.
    413     [self refreshInitialScrollbarPosition];
     412    [self adjustForScrollOriginChange];
    414413
    415414#if USE(ACCELERATED_COMPOSITING) && defined(BUILDING_ON_LEOPARD)
     
    574573}
    575574
    576 - (void)setScrollOriginX:(int)scrollOriginX
    577 {
    578     _private->scrollOriginX = scrollOriginX;
    579    
     575- (void)setScrollOrigin:(NSPoint)scrollOrigin updatePosition:(BOOL)updatePosition
     576{
     577    // The cross-platform ScrollView call already checked to see if the old/new scroll origins were the same or not
     578    // so we don't have to check for equivalence here.
     579    _private->scrollOrigin = scrollOrigin;
    580580    id docView = [self documentView];
    581     if (scrollOriginX != [docView bounds].origin.x) {
    582         // "-[self scrollOriginX]" is equal to the left layout overflow.
    583         // Make Document bounds origin x coordinate correspond to the left overflow so the entire canvas is covered by the document.
    584         [docView setBoundsOrigin:NSMakePoint(-scrollOriginX, [docView bounds].origin.y)];
    585     }
    586 
    587 }
    588 
    589 - (int)scrollOriginX
    590 {
    591     return _private->scrollOriginX;
     581    NSPoint docOrigin = [docView bounds].origin;
     582
     583    NSRect visibleRect = [self documentVisibleRect];
     584
     585    [docView setBoundsOrigin:NSMakePoint(-scrollOrigin.x, -scrollOrigin.y)];
     586
     587    _private->scrollOriginChanged = true;
     588
     589    // Maintain our original position in the presence of the new scroll origin.
     590    _private->scrollPositionExcludingOrigin = NSMakePoint(visibleRect.origin.x + scrollOrigin.x, visibleRect.origin.y + scrollOrigin.y);
     591
     592    if (updatePosition) // Otherwise we'll just let the snap happen when we update for the resize.
     593        [self adjustForScrollOriginChange];
     594}
     595
     596- (NSPoint)scrollOrigin
     597{
     598    return _private->scrollOrigin;
    592599}
    593600
  • trunk/WebKit/mac/WebView/WebFrameView.mm

    r72852 r73063  
    537537        return NO;
    538538    NSPoint point = [[[self _scrollView] documentView] frame].origin;
    539     point.x += [[self _scrollView] scrollOriginX];
     539    point.x += [[self _scrollView] scrollOrigin].x;
     540    point.y += [[self _scrollView] scrollOrigin].y;
    540541    return [[self _contentView] _scrollTo:&point animate:YES];
    541542}
     
    549550    NSRect frame = [[[self _scrollView] documentView] frame];
    550551    NSPoint point = NSMakePoint(frame.origin.x, NSMaxY(frame));
    551     point.x += [[self _scrollView] scrollOriginX];
     552    point.x += [[self _scrollView] scrollOrigin].x;
     553    point.y += [[self _scrollView] scrollOrigin].y;
    552554    return [[self _contentView] _scrollTo:&point animate:YES];
    553555}
Note: See TracChangeset for help on using the changeset viewer.