Changeset 73063 in webkit
- Timestamp:
- Dec 1, 2010, 1:31:50 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 2 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r73061 r73063 1 2010-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 1 24 2010-12-01 Victor Wang <victorw@chromium.org> 2 25 -
trunk/WebCore/ChangeLog
r73062 r73063 1 2010-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 1 40 2010-11-30 Steve Block <steveblock@google.com> 2 41 -
trunk/WebCore/page/FrameView.cpp
r72852 r73063 436 436 return; 437 437 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 447 442 setContentsSize(size); 448 443 } -
trunk/WebCore/page/mac/WebCoreFrameView.h
r72852 r73063 34 34 - (void)scrollingModes:(WebCore::ScrollbarMode*)hMode vertical:(WebCore::ScrollbarMode*)vMode; 35 35 - (void)setScrollBarsSuppressed:(BOOL)suppressed repaintOnUnsuppress:(BOOL)repaint; 36 - (void)setScrollOrigin X:(int)scrollOriginX;37 - ( int)scrollOriginX;36 - (void)setScrollOrigin:(NSPoint)origin updatePosition:(BOOL)updatePosition; 37 - (NSPoint)scrollOrigin; 38 38 @end 39 39 -
trunk/WebCore/platform/ScrollView.cpp
r72931 r73063 55 55 , m_paintsEntireContents(false) 56 56 , m_delegatesScrolling(false) 57 , m_scrollOriginX(0)58 57 { 59 58 platformInit(); … … 280 279 IntPoint ScrollView::maximumScrollPosition() const 281 280 { 282 IntPoint maximumOffset(contentsWidth() - visibleWidth() - m_scrollOrigin X, contentsHeight() - visibleHeight());281 IntPoint maximumOffset(contentsWidth() - visibleWidth() - m_scrollOrigin.x(), contentsHeight() - visibleHeight() - m_scrollOrigin.y()); 283 282 maximumOffset.clampNegativeToZero(); 284 283 return maximumOffset; … … 287 286 IntPoint ScrollView::minimumScrollPosition() const 288 287 { 289 return IntPoint(-m_scrollOrigin X, 0);288 return IntPoint(-m_scrollOrigin.x(), -m_scrollOrigin.y()); 290 289 } 291 290 … … 317 316 if (scrollbar) { 318 317 if (scrollbar->orientation() == HorizontalScrollbar) 319 newOffset.setWidth(scrollbar->value() - m_scrollOrigin X);318 newOffset.setWidth(scrollbar->value() - m_scrollOrigin.x()); 320 319 else if (scrollbar->orientation() == VerticalScrollbar) 321 newOffset.setHeight(scrollbar->value() );320 newOffset.setHeight(scrollbar->value() - m_scrollOrigin.y()); 322 321 } 323 322 … … 504 503 m_horizontalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); 505 504 m_horizontalScrollbar->setProportion(clientWidth, contentsWidth()); 506 m_horizontalScrollbar->setValue(scroll.width() + m_scrollOrigin X, Scrollbar::NotFromScrollAnimator);505 m_horizontalScrollbar->setValue(scroll.width() + m_scrollOrigin.x(), Scrollbar::NotFromScrollAnimator); 507 506 if (m_scrollbarsSuppressed) 508 507 m_horizontalScrollbar->setSuppressInvalidation(false); … … 526 525 m_verticalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); 527 526 m_verticalScrollbar->setProportion(clientHeight, contentsHeight()); 528 m_verticalScrollbar->setValue(scroll.height() , Scrollbar::NotFromScrollAnimator);527 m_verticalScrollbar->setValue(scroll.height() + m_scrollOrigin.y(), Scrollbar::NotFromScrollAnimator); 529 528 if (m_scrollbarsSuppressed) 530 529 m_verticalScrollbar->setSuppressInvalidation(false); … … 1028 1027 } 1029 1028 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()) 1029 void 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) 1041 1043 updateScrollbars(scrollOffset()); 1042 // FIXME: need corresponding functionality from platformWidget.1043 1044 } 1044 1045 … … 1073 1074 } 1074 1075 1075 void ScrollView::platformSetScrollOrigin X(int)1076 void ScrollView::platformSetScrollOrigin(const IntPoint&, bool updatePosition) 1076 1077 { 1077 1078 } -
trunk/WebCore/platform/ScrollView.h
r72852 r73063 162 162 IntPoint maximumScrollPosition() const; // The maximum position we can be scrolled to. 163 163 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. 165 165 IntPoint adjustScrollPositionWithinRange(const IntPoint&) const; 166 166 int scrollX() const { return scrollPosition().x(); } … … 283 283 virtual void scrollContentsSlowPath(const IntRect& updateRect); 284 284 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; } 288 287 289 288 private: … … 322 321 bool m_delegatesScrolling; 323 322 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; 328 335 329 336 void init(); … … 355 362 bool platformIsOffscreen() const; 356 363 357 void platformSetScrollOrigin X(int);364 void platformSetScrollOrigin(const IntPoint&, bool updatePosition); 358 365 359 366 #if PLATFORM(MAC) && defined __OBJC__ -
trunk/WebCore/platform/mac/ScrollViewMac.mm
r72852 r73063 148 148 { 149 149 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. 151 152 [documentView() scrollPoint:tempPoint]; 152 153 END_BLOCK_OBJC_EXCEPTIONS; … … 203 204 } 204 205 205 void ScrollView::platformSetScrollOrigin X(int x)206 { 207 BEGIN_BLOCK_OBJC_EXCEPTIONS; 208 [scrollView() setScrollOrigin X:x];206 void ScrollView::platformSetScrollOrigin(const IntPoint& origin, bool updatePosition) 207 { 208 BEGIN_BLOCK_OBJC_EXCEPTIONS; 209 [scrollView() setScrollOrigin:origin updatePosition:updatePosition]; 209 210 END_BLOCK_OBJC_EXCEPTIONS; 210 211 } -
trunk/WebCore/rendering/RenderBox.cpp
r72852 r73063 774 774 // its margins. 775 775 int bx = tx - marginLeft() + view()->leftLayoutOverflow(); 776 int by = ty - marginTop() ;776 int by = ty - marginTop() + view()->topLayoutOverflow(); 777 777 int bw = max(w + marginLeft() + marginRight() + borderLeft() + borderRight(), rw); 778 778 int bh = max(h + marginTop() + marginBottom() + borderTop() + borderBottom(), rh); -
trunk/WebCore/rendering/RenderView.cpp
r72852 r73063 133 133 m_overflow.clear(); 134 134 int leftOverflow = docLeft(); 135 addLayoutOverflow(IntRect(leftOverflow, 0, docWidth(leftOverflow), docHeight())); 135 int topOverflow = docTop(); 136 addLayoutOverflow(IntRect(leftOverflow, topOverflow, docWidth(leftOverflow), docHeight(topOverflow))); 136 137 137 138 ASSERT(layoutDelta() == IntSize()); … … 618 619 } 619 620 620 int RenderView::docHeight() const 621 { 622 int h = lowestPosition(); 621 int 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 629 int RenderView::docHeight(int topOverflow) const 630 { 631 int h = ((!style()->isHorizontalWritingMode() && style()->isLeftToRightDirection()) || style()->writingMode() == TopToBottomWritingMode) ? 632 lowestPosition() : height() - topOverflow; 623 633 624 634 // FIXME: This doesn't do any margin collapsing. … … 637 647 int RenderView::docLeft() const 638 648 { 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()); 641 653 } 642 654 643 655 int RenderView::docWidth(int leftOverflow) const 644 656 { 645 int w = style()->isLeftToRightDirection() ? rightmostPosition() : width() - leftOverflow; 657 int w = ((style()->isHorizontalWritingMode() && style()->isLeftToRightDirection()) || style()->writingMode() == LeftToRightWritingMode) ? 658 rightmostPosition() : width() - leftOverflow; 646 659 647 660 for (RenderBox* c = firstChildBox(); c; c = c->nextSiblingBox()) { -
trunk/WebCore/rendering/RenderView.h
r72852 r73063 173 173 private: 174 174 bool shouldRepaint(const IntRect& r) const; 175 176 int docHeight() const; 175 176 int docTop() const; 177 int docHeight(int topOverflow) const; 177 178 int docLeft() const; 178 179 int docWidth(int leftOverflow) const; -
trunk/WebKit/mac/ChangeLog
r72887 r73063 1 2010-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 1 25 2010-11-29 Dan Bernstein <mitz@apple.com> 2 26 -
trunk/WebKit/mac/WebView/WebDynamicScrollBarsView.mm
r72852 r73063 64 64 bool verticalScrollingAllowedButScrollerHidden; 65 65 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; 68 69 69 70 // Flag to indicate that the scrollbar thumb's initial position needs to 70 71 // be manually set. 71 bool setScrollbarThumbInitialPosition; 72 bool scrollOriginChanged; 73 NSPoint scrollPositionExcludingOrigin; 72 74 73 75 bool inProgrammaticScroll; … … 216 218 } 217 219 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; 239 236 } 240 237 … … 340 337 _private->inUpdateScrollers = YES; 341 338 [self setHasHorizontalScroller:newHasHorizontalScroller]; 342 343 // For RTL documents, we need to set the initial position of the344 // horizontal scrollbar thumb to be on the right.345 if (newHasHorizontalScroller)346 _private->setScrollbarThumbInitialPosition = true;347 348 339 _private->inUpdateScrollers = NO; 349 340 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)]; 350 345 } 351 346 … … 355 350 _private->inUpdateScrollers = NO; 356 351 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)]; 357 356 } 358 357 … … 411 410 // position to 0 (the left) when the view is initially displayed. 412 411 // This call updates the initial position correctly. 413 [self refreshInitialScrollbarPosition];412 [self adjustForScrollOriginChange]; 414 413 415 414 #if USE(ACCELERATED_COMPOSITING) && defined(BUILDING_ON_LEOPARD) … … 574 573 } 575 574 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; 580 580 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; 592 599 } 593 600 -
trunk/WebKit/mac/WebView/WebFrameView.mm
r72852 r73063 537 537 return NO; 538 538 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; 540 541 return [[self _contentView] _scrollTo:&point animate:YES]; 541 542 } … … 549 550 NSRect frame = [[[self _scrollView] documentView] frame]; 550 551 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; 552 554 return [[self _contentView] _scrollTo:&point animate:YES]; 553 555 }
Note:
See TracChangeset
for help on using the changeset viewer.