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

Side by Side Diff: Source/core/frame/FrameView.cpp

Issue 1158673006: Replace various ScrollableArea scroll methods with setScrollPosition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 // really mess things up if an anchor scroll comes at a bad moment. 1492 // really mess things up if an anchor scroll comes at a bad moment.
1493 m_frame->document()->updateLayoutTreeIfNeeded(); 1493 m_frame->document()->updateLayoutTreeIfNeeded();
1494 // Only do a layout if changes have occurred that make it necessary. 1494 // Only do a layout if changes have occurred that make it necessary.
1495 LayoutView* layoutView = this->layoutView(); 1495 LayoutView* layoutView = this->layoutView();
1496 if (layoutView && layoutView->needsLayout()) 1496 if (layoutView && layoutView->needsLayout())
1497 layout(); 1497 layout();
1498 else 1498 else
1499 scrollToAnchor(); 1499 scrollToAnchor();
1500 } 1500 }
1501 1501
1502 void FrameView::setScrollPosition(const DoublePoint& scrollPoint, ScrollBehavior scrollBehavior) 1502 void FrameView::setScrollPosition(const DoublePoint& scrollPoint, ScrollType scr ollType, ScrollBehavior scrollBehavior)
1503 { 1503 {
1504 cancelProgrammaticScrollAnimation(); 1504 cancelProgrammaticScrollAnimation();
1505 m_maintainScrollPositionAnchor = nullptr; 1505 m_maintainScrollPositionAnchor = nullptr;
1506 1506
1507 DoublePoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint) ; 1507 DoublePoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint) ;
1508 if (newScrollPosition == scrollPositionDouble()) 1508 if (newScrollPosition == scrollPositionDouble())
1509 return; 1509 return;
1510 1510
1511 if (scrollBehavior == ScrollBehaviorAuto) 1511 if (scrollBehavior == ScrollBehaviorAuto)
1512 scrollBehavior = scrollBehaviorStyle(); 1512 scrollBehavior = scrollBehaviorStyle();
1513 1513
1514 if (scrollBehavior == ScrollBehaviorInstant) { 1514 if (scrollBehavior == ScrollBehaviorInstant) {
1515 DoubleSize newOffset(newScrollPosition.x(), newScrollPosition.y()); 1515 DoubleSize newOffset(newScrollPosition.x(), newScrollPosition.y());
1516 // TODO(bokan): Why do we need to go through updateScrollbars? If not, w e can
1517 // just delete this whole method and use the base version.
1516 updateScrollbars(newOffset); 1518 updateScrollbars(newOffset);
1517 } else { 1519 } else {
1518 programmaticallyScrollSmoothlyToOffset(toFloatPoint(newScrollPosition)); 1520 ScrollableArea::setScrollPosition(newScrollPosition, ProgrammaticScroll, ScrollBehaviorSmooth);
1519 } 1521 }
1520 } 1522 }
1521 1523
1522 void FrameView::setElasticOverscroll(const FloatSize& elasticOverscroll) 1524 void FrameView::setElasticOverscroll(const FloatSize& elasticOverscroll)
1523 { 1525 {
1524 m_elasticOverscroll = elasticOverscroll; 1526 m_elasticOverscroll = elasticOverscroll;
1525 if (m_horizontalScrollbar) { 1527 if (m_horizontalScrollbar) {
1526 float delta = elasticOverscroll.width() - m_horizontalScrollbar->elastic Overscroll(); 1528 float delta = elasticOverscroll.width() - m_horizontalScrollbar->elastic Overscroll();
1527 if (delta != 0) { 1529 if (delta != 0) {
1528 m_horizontalScrollbar->setElasticOverscroll(elasticOverscroll.width( )); 1530 m_horizontalScrollbar->setElasticOverscroll(elasticOverscroll.width( ));
(...skipping 1677 matching lines...) Expand 10 before | Expand all | Expand 10 after
3206 // If no scrollbars are present, the content may still be scrollable. 3208 // If no scrollbars are present, the content may still be scrollable.
3207 if (!scrollbar) { 3209 if (!scrollbar) {
3208 IntSize scrollSize = m_contentsSize - visibleContentRect().size(); 3210 IntSize scrollSize = m_contentsSize - visibleContentRect().size();
3209 scrollSize.clampNegativeToZero(); 3211 scrollSize.clampNegativeToZero();
3210 return orientation == HorizontalScrollbar ? scrollSize.width() : scrollS ize.height(); 3212 return orientation == HorizontalScrollbar ? scrollSize.width() : scrollS ize.height();
3211 } 3213 }
3212 3214
3213 return scrollbar->totalSize() - scrollbar->visibleSize(); 3215 return scrollbar->totalSize() - scrollbar->visibleSize();
3214 } 3216 }
3215 3217
3216 void FrameView::setScrollOffset(const IntPoint& offset) 3218 void FrameView::setScrollOffset(const IntPoint& offset, ScrollType)
3217 { 3219 {
3218 scrollTo(DoublePoint(adjustScrollPositionWithinRange(offset))); 3220 scrollTo(DoublePoint(adjustScrollPositionWithinRange(offset)));
3219 } 3221 }
3220 3222
3221 void FrameView::setScrollOffset(const DoublePoint& offset) 3223 void FrameView::setScrollOffset(const DoublePoint& offset, ScrollType)
3222 { 3224 {
3223 scrollTo(adjustScrollPositionWithinRange(offset)); 3225 scrollTo(adjustScrollPositionWithinRange(offset));
3224 } 3226 }
3225 3227
3226 void FrameView::windowResizerRectChanged() 3228 void FrameView::windowResizerRectChanged()
3227 { 3229 {
3228 updateScrollbars(scrollOffsetDouble()); 3230 updateScrollbars(scrollOffsetDouble());
3229 } 3231 }
3230 3232
3231 bool FrameView::hasOverlayScrollbars() const 3233 bool FrameView::hasOverlayScrollbars() const
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
3453 setScrollOffsetFromUpdateScrollbars(desiredOffset); 3455 setScrollOffsetFromUpdateScrollbars(desiredOffset);
3454 } 3456 }
3455 3457
3456 void FrameView::setScrollOffsetFromUpdateScrollbars(const DoubleSize& offset) 3458 void FrameView::setScrollOffsetFromUpdateScrollbars(const DoubleSize& offset)
3457 { 3459 {
3458 DoublePoint adjustedScrollPosition = DoublePoint(offset); 3460 DoublePoint adjustedScrollPosition = DoublePoint(offset);
3459 3461
3460 adjustedScrollPosition = adjustScrollPositionWithinRange(adjustedScrollPosit ion); 3462 adjustedScrollPosition = adjustScrollPositionWithinRange(adjustedScrollPosit ion);
3461 3463
3462 if (adjustedScrollPosition != scrollPositionDouble() || scrollOriginChanged( )) { 3464 if (adjustedScrollPosition != scrollPositionDouble() || scrollOriginChanged( )) {
3463 ScrollableArea::scrollToOffsetWithoutAnimation(toFloatPoint(adjustedScro llPosition)); 3465 ScrollableArea::setScrollPosition(adjustedScrollPosition, ProgrammaticSc roll);
3464 resetScrollOriginChanged(); 3466 resetScrollOriginChanged();
3465 } 3467 }
3466 } 3468 }
3467 3469
3468 const int panIconSizeLength = 16; 3470 const int panIconSizeLength = 16;
3469 3471
3470 IntRect FrameView::rectToCopyOnScroll() const 3472 IntRect FrameView::rectToCopyOnScroll() const
3471 { 3473 {
3472 IntRect scrollViewRect = convertToContainingWindow(IntRect((shouldPlaceVerti calScrollbarOnLeft() && verticalScrollbar()) ? verticalScrollbar()->width() : 0, 0, visibleWidth(), visibleHeight())); 3474 IntRect scrollViewRect = convertToContainingWindow(IntRect((shouldPlaceVerti calScrollbarOnLeft() && verticalScrollbar()) ? verticalScrollbar()->width() : 0, 0, visibleWidth(), visibleHeight()));
3473 if (hasOverlayScrollbars()) { 3475 if (hasOverlayScrollbars()) {
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
3739 } 3741 }
3740 3742
3741 LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent, const Scro llAlignment& alignX, const ScrollAlignment& alignY) 3743 LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent, const Scro llAlignment& alignX, const ScrollAlignment& alignY)
3742 { 3744 {
3743 LayoutRect viewRect(visibleContentRect()); 3745 LayoutRect viewRect(visibleContentRect());
3744 LayoutRect exposeRect = ScrollAlignment::getRectToExpose(viewRect, rectInCon tent, alignX, alignY); 3746 LayoutRect exposeRect = ScrollAlignment::getRectToExpose(viewRect, rectInCon tent, alignX, alignY);
3745 3747
3746 double xOffset = exposeRect.x(); 3748 double xOffset = exposeRect.x();
3747 double yOffset = exposeRect.y(); 3749 double yOffset = exposeRect.y();
3748 3750
3749 setScrollPosition(DoublePoint(xOffset, yOffset)); 3751 setScrollPosition(DoublePoint(xOffset, yOffset), ProgrammaticScroll);
3750 3752
3751 // Scrolling the FrameView cannot change the input rect's location relative to the document. 3753 // Scrolling the FrameView cannot change the input rect's location relative to the document.
3752 return rectInContent; 3754 return rectInContent;
3753 } 3755 }
3754 3756
3755 IntRect FrameView::scrollCornerRect() const 3757 IntRect FrameView::scrollCornerRect() const
3756 { 3758 {
3757 IntRect cornerRect; 3759 IntRect cornerRect;
3758 3760
3759 if (hasOverlayScrollbars()) 3761 if (hasOverlayScrollbars())
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
4020 4022
4021 if (!graphicsLayer) 4023 if (!graphicsLayer)
4022 return; 4024 return;
4023 4025
4024 DeprecatedPaintLayer::mapRectToPaintInvalidationBacking(localFrame->contentL ayoutObject(), paintInvalidationContainer, viewRect); 4026 DeprecatedPaintLayer::mapRectToPaintInvalidationBacking(localFrame->contentL ayoutObject(), paintInvalidationContainer, viewRect);
4025 4027
4026 graphicsLayerTimingRequests.add(graphicsLayer, Vector<std::pair<int64_t, Web Rect>>()).storedValue->value.append(std::make_pair(m_frame->frameID(), enclosing IntRect(viewRect))); 4028 graphicsLayerTimingRequests.add(graphicsLayer, Vector<std::pair<int64_t, Web Rect>>()).storedValue->value.append(std::make_pair(m_frame->frameID(), enclosing IntRect(viewRect)));
4027 } 4029 }
4028 4030
4029 } // namespace blink 4031 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698