Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp

Issue 1867693002: Better scrolling fix (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: refined Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@gmail.com> 9 * Christian Biesinger <cbiesinger@gmail.com>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 } 589 }
590 590
591 void PaintLayerScrollableArea::computeScrollDimensions() 591 void PaintLayerScrollableArea::computeScrollDimensions()
592 { 592 {
593 m_overflowRect = box().layoutOverflowRect(); 593 m_overflowRect = box().layoutOverflowRect();
594 box().flipForWritingMode(m_overflowRect); 594 box().flipForWritingMode(m_overflowRect);
595 595
596 int scrollableLeftOverflow = m_overflowRect.x() - box().borderLeft() - (box( ).shouldPlaceBlockDirectionScrollbarOnLogicalLeft() ? box().verticalScrollbarWid th() : 0); 596 int scrollableLeftOverflow = m_overflowRect.x() - box().borderLeft() - (box( ).shouldPlaceBlockDirectionScrollbarOnLogicalLeft() ? box().verticalScrollbarWid th() : 0);
597 int scrollableTopOverflow = m_overflowRect.y() - box().borderTop(); 597 int scrollableTopOverflow = m_overflowRect.y() - box().borderTop();
598 setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow)); 598 setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow));
599 fprintf(stderr, "origin=%i,%i\n", scrollOrigin().x(), scrollOrigin().y());
600 fprintf(stderr, "........overflowRect x = %f width = %f layoutRect x = % f width = %f\n", m_overflowRect.x().toFloat(), m_overflowRect.width().toFloat(), box().location().x().toFloat(), box().size().width().toFloat());
601 fprintf(stderr, "offset=%f,%f\n", m_scrollOffset.width(), m_scrollOffset.hei ght());
599 } 602 }
600 603
601 void PaintLayerScrollableArea::scrollToPosition(const DoublePoint& scrollPositio n, ScrollOffsetClamping clamp, ScrollBehavior scrollBehavior, ScrollType scrollT ype) 604 void PaintLayerScrollableArea::scrollToPosition(const DoublePoint& scrollPositio n, ScrollOffsetClamping clamp, ScrollBehavior scrollBehavior, ScrollType scrollT ype)
602 { 605 {
603 cancelProgrammaticScrollAnimation(); 606 cancelProgrammaticScrollAnimation();
604 607
605 DoublePoint newScrollPosition = clamp == ScrollOffsetClamped ? clampScrollPo sition(scrollPosition) : scrollPosition; 608 DoublePoint newScrollPosition = clamp == ScrollOffsetClamped ? clampScrollPo sition(scrollPosition) : scrollPosition;
606 if (newScrollPosition != scrollPositionDouble()) 609 if (newScrollPosition != scrollPositionDouble())
607 ScrollableArea::setScrollPosition(newScrollPosition, scrollType, scrollB ehavior); 610 ScrollableArea::setScrollPosition(newScrollPosition, scrollType, scrollB ehavior);
608 } 611 }
609 612
613 void PaintLayerScrollableArea::clampPositionAfterLayout()
614 {
615 // Layout may cause us to be at an invalid scroll position. In this case we need
616 // to pull our scroll offsets back to the max (or push them up to the min).
617 DoublePoint clampedScrollPosition = clampScrollPosition(scrollPositionDouble ());
618 if (clampedScrollPosition != scrollPositionDouble())
619 scrollToPosition(clampedScrollPosition);
620 }
621
610 bool PaintLayerScrollableArea::updateAfterLayout(SubtreeLayoutScope* delayedLayo utScope) 622 bool PaintLayerScrollableArea::updateAfterLayout(SubtreeLayoutScope* delayedLayo utScope)
611 { 623 {
612 ASSERT(box().hasOverflowClip()); 624 ASSERT(box().hasOverflowClip());
613 625
614 bool didMarkForDelayedLayout = false; 626 bool didMarkForDelayedLayout = false;
615 627
616 if (needsScrollbarReconstruction()) { 628 if (needsScrollbarReconstruction()) {
617 m_scrollbarManager.setCanDetachScrollbars(false); 629 m_scrollbarManager.setCanDetachScrollbars(false);
618 setHasHorizontalScrollbar(false); 630 setHasHorizontalScrollbar(false);
619 setHasVerticalScrollbar(false); 631 setHasVerticalScrollbar(false);
620 } 632 }
621 633
622 m_scrollbarManager.setCanDetachScrollbars(true); 634 m_scrollbarManager.setCanDetachScrollbars(true);
623 635
624 IntPoint originalOrigin = scrollOrigin(); 636 IntPoint originalOrigin = scrollOrigin();
625 computeScrollDimensions(); 637 computeScrollDimensions();
626 638
627 // Layout may cause us to be at an invalid scroll position. In this case we need 639 fprintf(stderr, "updateAfterLayout -- origin is %i,%i offset %f,%f\n", scrol lOrigin().x(), scrollOrigin().y(), scrollPositionDouble().x(), scrollPositionDou ble().y());
628 // to pull our scroll offsets back to the max (or push them up to the min). 640
629 DoublePoint clampedScrollPosition = clampScrollPosition(scrollPositionDouble ()); 641 IntPoint newOrigin(scrollOrigin());
630 if (clampedScrollPosition != scrollPositionDouble()) { 642 if (originalOrigin != newOrigin) {
631 scrollToPosition(clampedScrollPosition);
632 } else if (originalOrigin != scrollOrigin()) {
633 // TODO: We should be able to use scrollOriginChanged() here, but we can 't because 643 // TODO: We should be able to use scrollOriginChanged() here, but we can 't because
634 // PaintLayerScrollableArea does not maintain that flag: it gets set, bu t it never 644 // PaintLayerScrollableArea does not maintain that flag: it gets set, bu t it never
635 // gets unset. We should unset the flag after layout. 645 // gets unset. We should unset the flag after layout.
636 scrollPositionChanged(scrollPositionDouble(), ProgrammaticScroll); 646 DoubleSize originDiff(newOrigin - originalOrigin);
647 /*
648 if (originDiff.width() < 0)
649 originDiff.setWidth(0);
650 if (originDiff.height() < 0)
651 originDiff.setHeight(0);
652 */
653 scrollPositionChanged(scrollPositionDouble() + originDiff, ProgrammaticS croll);
654 fprintf(stderr, " adjusting position by %f,%f\n", originDiff.width(), originDiff.height());
637 } 655 }
638 656
657
639 m_scrollbarManager.setCanDetachScrollbars(false); 658 m_scrollbarManager.setCanDetachScrollbars(false);
640 659
641 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); 660 bool hasHorizontalOverflow = this->hasHorizontalOverflow();
642 bool hasVerticalOverflow = this->hasVerticalOverflow(); 661 bool hasVerticalOverflow = this->hasVerticalOverflow();
643 662
644 { 663 {
645 // Hits in compositing/overflow/automatically-opt-into-composited-scroll ing-after-style-change.html. 664 // Hits in compositing/overflow/automatically-opt-into-composited-scroll ing-after-style-change.html.
646 DisableCompositingQueryAsserts disabler; 665 DisableCompositingQueryAsserts disabler;
647 666
648 // overflow:scroll should just enable/disable. 667 // overflow:scroll should just enable/disable.
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 } 1605 }
1587 1606
1588 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager) 1607 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager)
1589 { 1608 {
1590 visitor->trace(m_scrollableArea); 1609 visitor->trace(m_scrollableArea);
1591 visitor->trace(m_hBar); 1610 visitor->trace(m_hBar);
1592 visitor->trace(m_vBar); 1611 visitor->trace(m_vBar);
1593 } 1612 }
1594 1613
1595 } // namespace blink 1614 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698