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

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 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 // really mess things up if an anchor scroll comes at a bad moment. 1478 // really mess things up if an anchor scroll comes at a bad moment.
1479 m_frame->document()->updateLayoutTreeIfNeeded(); 1479 m_frame->document()->updateLayoutTreeIfNeeded();
1480 // Only do a layout if changes have occurred that make it necessary. 1480 // Only do a layout if changes have occurred that make it necessary.
1481 LayoutView* layoutView = this->layoutView(); 1481 LayoutView* layoutView = this->layoutView();
1482 if (layoutView && layoutView->needsLayout()) 1482 if (layoutView && layoutView->needsLayout())
1483 layout(); 1483 layout();
1484 else 1484 else
1485 scrollToAnchor(); 1485 scrollToAnchor();
1486 } 1486 }
1487 1487
1488 void FrameView::setScrollPosition(const DoublePoint& scrollPoint, ScrollBehavior scrollBehavior) 1488 void FrameView::setScrollPosition(const DoublePoint& scrollPoint, ScrollType scr ollType, ScrollBehavior scrollBehavior)
1489 { 1489 {
1490 cancelProgrammaticScrollAnimation(); 1490 cancelProgrammaticScrollAnimation();
1491 m_maintainScrollPositionAnchor = nullptr; 1491 m_maintainScrollPositionAnchor = nullptr;
1492 1492
1493 DoublePoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint) ; 1493 DoublePoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint) ;
1494 if (newScrollPosition == scrollPositionDouble()) 1494 if (newScrollPosition == scrollPositionDouble())
1495 return; 1495 return;
1496 1496
1497 if (scrollBehavior == ScrollBehaviorAuto) 1497 if (scrollBehavior == ScrollBehaviorAuto)
1498 scrollBehavior = scrollBehaviorStyle(); 1498 scrollBehavior = scrollBehaviorStyle();
1499 1499
1500 if (scrollBehavior == ScrollBehaviorInstant) { 1500 if (scrollBehavior == ScrollBehaviorInstant) {
1501 DoubleSize newOffset(newScrollPosition.x(), newScrollPosition.y()); 1501 DoubleSize newOffset(newScrollPosition.x(), newScrollPosition.y());
1502 // TODO(bokan): Why do we need to go through updateScrollbars? If not, w e can
1503 // just delete this whole method and use the base version.
1502 updateScrollbars(newOffset); 1504 updateScrollbars(newOffset);
1503 } else { 1505 } else {
1504 programmaticallyScrollSmoothlyToOffset(toFloatPoint(newScrollPosition)); 1506 ScrollableArea::setScrollPosition(newScrollPosition, ProgrammaticScroll, ScrollBehaviorSmooth);
1505 } 1507 }
1506 } 1508 }
1507 1509
1508 void FrameView::setElasticOverscroll(const FloatSize& elasticOverscroll) 1510 void FrameView::setElasticOverscroll(const FloatSize& elasticOverscroll)
1509 { 1511 {
1510 m_elasticOverscroll = elasticOverscroll; 1512 m_elasticOverscroll = elasticOverscroll;
1511 if (m_horizontalScrollbar) { 1513 if (m_horizontalScrollbar) {
1512 float delta = elasticOverscroll.width() - m_horizontalScrollbar->elastic Overscroll(); 1514 float delta = elasticOverscroll.width() - m_horizontalScrollbar->elastic Overscroll();
1513 if (delta != 0) { 1515 if (delta != 0) {
1514 m_horizontalScrollbar->setElasticOverscroll(elasticOverscroll.width( )); 1516 m_horizontalScrollbar->setElasticOverscroll(elasticOverscroll.width( ));
(...skipping 1677 matching lines...) Expand 10 before | Expand all | Expand 10 after
3192 // If no scrollbars are present, the content may still be scrollable. 3194 // If no scrollbars are present, the content may still be scrollable.
3193 if (!scrollbar) { 3195 if (!scrollbar) {
3194 IntSize scrollSize = m_contentsSize - visibleContentRect().size(); 3196 IntSize scrollSize = m_contentsSize - visibleContentRect().size();
3195 scrollSize.clampNegativeToZero(); 3197 scrollSize.clampNegativeToZero();
3196 return orientation == HorizontalScrollbar ? scrollSize.width() : scrollS ize.height(); 3198 return orientation == HorizontalScrollbar ? scrollSize.width() : scrollS ize.height();
3197 } 3199 }
3198 3200
3199 return scrollbar->totalSize() - scrollbar->visibleSize(); 3201 return scrollbar->totalSize() - scrollbar->visibleSize();
3200 } 3202 }
3201 3203
3202 void FrameView::setScrollOffset(const IntPoint& offset) 3204 void FrameView::setScrollOffset(const IntPoint& offset, ScrollType)
3203 { 3205 {
3204 scrollTo(DoublePoint(adjustScrollPositionWithinRange(offset))); 3206 scrollTo(DoublePoint(adjustScrollPositionWithinRange(offset)));
3205 } 3207 }
3206 3208
3207 void FrameView::setScrollOffset(const DoublePoint& offset) 3209 void FrameView::setScrollOffset(const DoublePoint& offset, ScrollType)
3208 { 3210 {
3209 scrollTo(adjustScrollPositionWithinRange(offset)); 3211 scrollTo(adjustScrollPositionWithinRange(offset));
3210 } 3212 }
3211 3213
3212 void FrameView::windowResizerRectChanged() 3214 void FrameView::windowResizerRectChanged()
3213 { 3215 {
3214 updateScrollbars(scrollOffsetDouble()); 3216 updateScrollbars(scrollOffsetDouble());
3215 } 3217 }
3216 3218
3217 bool FrameView::hasOverlayScrollbars() const 3219 bool FrameView::hasOverlayScrollbars() const
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
3439 setScrollOffsetFromUpdateScrollbars(desiredOffset); 3441 setScrollOffsetFromUpdateScrollbars(desiredOffset);
3440 } 3442 }
3441 3443
3442 void FrameView::setScrollOffsetFromUpdateScrollbars(const DoubleSize& offset) 3444 void FrameView::setScrollOffsetFromUpdateScrollbars(const DoubleSize& offset)
3443 { 3445 {
3444 DoublePoint adjustedScrollPosition = DoublePoint(offset); 3446 DoublePoint adjustedScrollPosition = DoublePoint(offset);
3445 3447
3446 adjustedScrollPosition = adjustScrollPositionWithinRange(adjustedScrollPosit ion); 3448 adjustedScrollPosition = adjustScrollPositionWithinRange(adjustedScrollPosit ion);
3447 3449
3448 if (adjustedScrollPosition != scrollPositionDouble() || scrollOriginChanged( )) { 3450 if (adjustedScrollPosition != scrollPositionDouble() || scrollOriginChanged( )) {
3449 ScrollableArea::scrollToOffsetWithoutAnimation(toFloatPoint(adjustedScro llPosition)); 3451 ScrollableArea::setScrollPosition(adjustedScrollPosition, ProgrammaticSc roll);
3450 resetScrollOriginChanged(); 3452 resetScrollOriginChanged();
3451 } 3453 }
3452 } 3454 }
3453 3455
3454 const int panIconSizeLength = 16; 3456 const int panIconSizeLength = 16;
3455 3457
3456 IntRect FrameView::rectToCopyOnScroll() const 3458 IntRect FrameView::rectToCopyOnScroll() const
3457 { 3459 {
3458 IntRect scrollViewRect = convertToContainingWindow(IntRect((shouldPlaceVerti calScrollbarOnLeft() && verticalScrollbar()) ? verticalScrollbar()->width() : 0, 0, visibleWidth(), visibleHeight())); 3460 IntRect scrollViewRect = convertToContainingWindow(IntRect((shouldPlaceVerti calScrollbarOnLeft() && verticalScrollbar()) ? verticalScrollbar()->width() : 0, 0, visibleWidth(), visibleHeight()));
3459 if (hasOverlayScrollbars()) { 3461 if (hasOverlayScrollbars()) {
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
3725 } 3727 }
3726 3728
3727 LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent, const Scro llAlignment& alignX, const ScrollAlignment& alignY) 3729 LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent, const Scro llAlignment& alignX, const ScrollAlignment& alignY)
3728 { 3730 {
3729 LayoutRect viewRect(visibleContentRect()); 3731 LayoutRect viewRect(visibleContentRect());
3730 LayoutRect exposeRect = ScrollAlignment::getRectToExpose(viewRect, rectInCon tent, alignX, alignY); 3732 LayoutRect exposeRect = ScrollAlignment::getRectToExpose(viewRect, rectInCon tent, alignX, alignY);
3731 3733
3732 double xOffset = exposeRect.x(); 3734 double xOffset = exposeRect.x();
3733 double yOffset = exposeRect.y(); 3735 double yOffset = exposeRect.y();
3734 3736
3735 setScrollPosition(DoublePoint(xOffset, yOffset)); 3737 setScrollPosition(DoublePoint(xOffset, yOffset), ProgrammaticScroll);
3736 3738
3737 // Scrolling the FrameView cannot change the input rect's location relative to the document. 3739 // Scrolling the FrameView cannot change the input rect's location relative to the document.
3738 return rectInContent; 3740 return rectInContent;
3739 } 3741 }
3740 3742
3741 IntRect FrameView::scrollCornerRect() const 3743 IntRect FrameView::scrollCornerRect() const
3742 { 3744 {
3743 IntRect cornerRect; 3745 IntRect cornerRect;
3744 3746
3745 if (hasOverlayScrollbars()) 3747 if (hasOverlayScrollbars())
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
4006 4008
4007 if (!graphicsLayer) 4009 if (!graphicsLayer)
4008 return; 4010 return;
4009 4011
4010 DeprecatedPaintLayer::mapRectToPaintInvalidationBacking(localFrame->contentL ayoutObject(), paintInvalidationContainer, viewRect); 4012 DeprecatedPaintLayer::mapRectToPaintInvalidationBacking(localFrame->contentL ayoutObject(), paintInvalidationContainer, viewRect);
4011 4013
4012 graphicsLayerTimingRequests.add(graphicsLayer, Vector<std::pair<int64_t, Web Rect>>()).storedValue->value.append(std::make_pair(m_frame->frameID(), enclosing IntRect(viewRect))); 4014 graphicsLayerTimingRequests.add(graphicsLayer, Vector<std::pair<int64_t, Web Rect>>()).storedValue->value.append(std::make_pair(m_frame->frameID(), enclosing IntRect(viewRect)));
4013 } 4015 }
4014 4016
4015 } // namespace blink 4017 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698