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

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

Issue 2258523006: Convert Settings::rootLayerScrolls to RuntimeEnabledFeatures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase & fix mistake Created 4 years, 3 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 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 m_scrollAnchor.setScroller(scroller); 841 m_scrollAnchor.setScroller(scroller);
842 } 842 }
843 843
844 if (shouldPerformScrollAnchoring()) 844 if (shouldPerformScrollAnchoring())
845 m_scrollAnchor.save(); 845 m_scrollAnchor.save();
846 } 846 }
847 847
848 bool FrameView::shouldPerformScrollAnchoring() const 848 bool FrameView::shouldPerformScrollAnchoring() const
849 { 849 {
850 return RuntimeEnabledFeatures::scrollAnchoringEnabled() 850 return RuntimeEnabledFeatures::scrollAnchoringEnabled()
851 && m_frame->settings() && !m_frame->settings()->rootLayerScrolls() 851 && !RuntimeEnabledFeatures::rootLayerScrollingEnabled()
852 && m_scrollAnchor.hasScroller() 852 && m_scrollAnchor.hasScroller()
853 && layoutBox()->style()->overflowAnchor() != AnchorNone; 853 && layoutBox()->style()->overflowAnchor() != AnchorNone;
854 } 854 }
855 855
856 static inline void layoutFromRootObject(LayoutObject& root) 856 static inline void layoutFromRootObject(LayoutObject& root)
857 { 857 {
858 LayoutState layoutState(root); 858 LayoutState layoutState(root);
859 root.layout(); 859 root.layout();
860 } 860 }
861 861
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 #if ENABLE(ASSERT) 1145 #if ENABLE(ASSERT)
1146 layoutView()->assertSubtreeClearedPaintInvalidationFlags(); 1146 layoutView()->assertSubtreeClearedPaintInvalidationFlags();
1147 #endif 1147 #endif
1148 1148
1149 lifecycle().advanceTo(DocumentLifecycle::PaintInvalidationClean); 1149 lifecycle().advanceTo(DocumentLifecycle::PaintInvalidationClean);
1150 } 1150 }
1151 1151
1152 void FrameView::invalidatePaintIfNeeded(const PaintInvalidationState& paintInval idationState) 1152 void FrameView::invalidatePaintIfNeeded(const PaintInvalidationState& paintInval idationState)
1153 { 1153 {
1154 RELEASE_ASSERT(!layoutViewItem().isNull()); 1154 RELEASE_ASSERT(!layoutViewItem().isNull());
1155 if (!m_frame->settings() || !m_frame->settings()->rootLayerScrolls()) 1155 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled())
1156 invalidatePaintOfScrollControlsIfNeeded(paintInvalidationState); 1156 invalidatePaintOfScrollControlsIfNeeded(paintInvalidationState);
1157 1157
1158 if (m_frame->selection().isCaretBoundsDirty()) 1158 if (m_frame->selection().isCaretBoundsDirty())
1159 m_frame->selection().invalidateCaretRect(); 1159 m_frame->selection().invalidateCaretRect();
1160 1160
1161 // Temporary callback for crbug.com/487345,402044 1161 // Temporary callback for crbug.com/487345,402044
1162 // TODO(ojan): Make this more general to be used by PositionObserver 1162 // TODO(ojan): Make this more general to be used by PositionObserver
1163 // and rAF throttling. 1163 // and rAF throttling.
1164 IntRect visibleRect = rootFrameToContents(computeVisibleArea()); 1164 IntRect visibleRect = rootFrameToContents(computeVisibleArea());
1165 layoutViewItem().sendMediaPositionChangeNotifications(visibleRect); 1165 layoutViewItem().sendMediaPositionChangeNotifications(visibleRect);
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 1369
1370 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordina tor()) 1370 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordina tor())
1371 scrollingCoordinator->frameViewFixedObjectsDidChange(this); 1371 scrollingCoordinator->frameViewFixedObjectsDidChange(this);
1372 } 1372 }
1373 } 1373 }
1374 1374
1375 void FrameView::viewportSizeChanged(bool widthChanged, bool heightChanged) 1375 void FrameView::viewportSizeChanged(bool widthChanged, bool heightChanged)
1376 { 1376 {
1377 DCHECK(widthChanged || heightChanged); 1377 DCHECK(widthChanged || heightChanged);
1378 1378
1379 if (m_frame->settings() && m_frame->settings()->rootLayerScrolls()) { 1379 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
1380 // The background must be repainted when the FrameView is resized, even if the initial 1380 // The background must be repainted when the FrameView is resized, even if the initial
1381 // containing block does not change (so we can't rely on layout to issue the invalidation). 1381 // containing block does not change (so we can't rely on layout to issue the invalidation).
1382 // This is because the background fills the main GraphicsLayer, which ta kes the size of the 1382 // This is because the background fills the main GraphicsLayer, which ta kes the size of the
1383 // layout viewport. 1383 // layout viewport.
1384 // TODO(skobes): Paint non-fixed backgrounds into the scrolling contents layer and avoid 1384 // TODO(skobes): Paint non-fixed backgrounds into the scrolling contents layer and avoid
1385 // this invalidation (http://crbug.com/568847). 1385 // this invalidation (http://crbug.com/568847).
1386 LayoutViewItem lvi = layoutViewItem(); 1386 LayoutViewItem lvi = layoutViewItem();
1387 if (!lvi.isNull()) 1387 if (!lvi.isNull())
1388 lvi.setShouldDoFullPaintInvalidation(); 1388 lvi.setShouldDoFullPaintInvalidation();
1389 } 1389 }
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
2032 2032
2033 // Scrolling is disabled during updateScrollbars (see isProgrammaticallyScro llable). 2033 // Scrolling is disabled during updateScrollbars (see isProgrammaticallyScro llable).
2034 // Bail now to avoid clearing m_fragmentAnchor before we actually have a cha nce to scroll. 2034 // Bail now to avoid clearing m_fragmentAnchor before we actually have a cha nce to scroll.
2035 if (m_inUpdateScrollbars) 2035 if (m_inUpdateScrollbars)
2036 return; 2036 return;
2037 2037
2038 if (anchorNode->layoutObject()) { 2038 if (anchorNode->layoutObject()) {
2039 LayoutRect rect; 2039 LayoutRect rect;
2040 if (anchorNode != m_frame->document()) { 2040 if (anchorNode != m_frame->document()) {
2041 rect = anchorNode->boundingBox(); 2041 rect = anchorNode->boundingBox();
2042 } else if (m_frame->settings() && m_frame->settings()->rootLayerScrolls( )) { 2042 } else if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
2043 if (Element* documentElement = m_frame->document()->documentElement( )) 2043 if (Element* documentElement = m_frame->document()->documentElement( ))
2044 rect = documentElement->boundingBox(); 2044 rect = documentElement->boundingBox();
2045 } 2045 }
2046 2046
2047 Frame* boundaryFrame = m_frame->findUnsafeParentScrollPropagationBoundar y(); 2047 Frame* boundaryFrame = m_frame->findUnsafeParentScrollPropagationBoundar y();
2048 2048
2049 // FIXME: Handle RemoteFrames 2049 // FIXME: Handle RemoteFrames
2050 if (boundaryFrame && boundaryFrame->isLocalFrame()) 2050 if (boundaryFrame && boundaryFrame->isLocalFrame())
2051 toLocalFrame(boundaryFrame)->view()->setSafeToPropagateScrollToParen t(false); 2051 toLocalFrame(boundaryFrame)->view()->setSafeToPropagateScrollToParen t(false);
2052 2052
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after
3426 { 3426 {
3427 // TODO(skobes): We shouldn't have to clamp here; instead we should update c allers 3427 // TODO(skobes): We shouldn't have to clamp here; instead we should update c allers
3428 // ScrollableArea::scrollPositionChanged to only pass clamped offsets. 3428 // ScrollableArea::scrollPositionChanged to only pass clamped offsets.
3429 DoublePoint newPosition = clampScrollPosition(offset); 3429 DoublePoint newPosition = clampScrollPosition(offset);
3430 3430
3431 DoublePoint oldPosition = m_scrollPosition; 3431 DoublePoint oldPosition = m_scrollPosition;
3432 DoubleSize scrollDelta = newPosition - oldPosition; 3432 DoubleSize scrollDelta = newPosition - oldPosition;
3433 if (scrollDelta.isZero()) 3433 if (scrollDelta.isZero())
3434 return; 3434 return;
3435 3435
3436 if (m_frame->settings() && m_frame->settings()->rootLayerScrolls()) { 3436 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
3437 // Don't scroll the FrameView! 3437 // Don't scroll the FrameView!
3438 ASSERT_NOT_REACHED(); 3438 ASSERT_NOT_REACHED();
3439 } 3439 }
3440 3440
3441 m_scrollPosition = newPosition; 3441 m_scrollPosition = newPosition;
3442 3442
3443 if (!scrollbarsSuppressed()) 3443 if (!scrollbarsSuppressed())
3444 m_pendingScrollDelta += scrollDelta; 3444 m_pendingScrollDelta += scrollDelta;
3445 3445
3446 clearFragmentAnchor(); 3446 clearFragmentAnchor();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3499 } 3499 }
3500 3500
3501 void FrameView::computeScrollbarExistence(bool& newHasHorizontalScrollbar, bool& newHasVerticalScrollbar, const IntSize& docSize, ComputeScrollbarExistenceOptio n option) const 3501 void FrameView::computeScrollbarExistence(bool& newHasHorizontalScrollbar, bool& newHasVerticalScrollbar, const IntSize& docSize, ComputeScrollbarExistenceOptio n option) const
3502 { 3502 {
3503 bool hasHorizontalScrollbar = m_horizontalScrollbar; 3503 bool hasHorizontalScrollbar = m_horizontalScrollbar;
3504 bool hasVerticalScrollbar = m_verticalScrollbar; 3504 bool hasVerticalScrollbar = m_verticalScrollbar;
3505 3505
3506 newHasHorizontalScrollbar = hasHorizontalScrollbar; 3506 newHasHorizontalScrollbar = hasHorizontalScrollbar;
3507 newHasVerticalScrollbar = hasVerticalScrollbar; 3507 newHasVerticalScrollbar = hasVerticalScrollbar;
3508 3508
3509 if (m_frame->settings() && m_frame->settings()->rootLayerScrolls()) 3509 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
3510 return; 3510 return;
3511 3511
3512 ScrollbarMode hScroll = m_horizontalScrollbarMode; 3512 ScrollbarMode hScroll = m_horizontalScrollbarMode;
3513 ScrollbarMode vScroll = m_verticalScrollbarMode; 3513 ScrollbarMode vScroll = m_verticalScrollbarMode;
3514 3514
3515 if (hScroll != ScrollbarAuto) 3515 if (hScroll != ScrollbarAuto)
3516 newHasHorizontalScrollbar = (hScroll == ScrollbarAlwaysOn); 3516 newHasHorizontalScrollbar = (hScroll == ScrollbarAlwaysOn);
3517 if (vScroll != ScrollbarAuto) 3517 if (vScroll != ScrollbarAuto)
3518 newHasVerticalScrollbar = (vScroll == ScrollbarAlwaysOn); 3518 newHasVerticalScrollbar = (vScroll == ScrollbarAlwaysOn);
3519 3519
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
3662 void FrameView::updateScrollbarsIfNeeded() 3662 void FrameView::updateScrollbarsIfNeeded()
3663 { 3663 {
3664 if (m_needsScrollbarsUpdate || needsScrollbarReconstruction() || scrollOrigi nChanged()) 3664 if (m_needsScrollbarsUpdate || needsScrollbarReconstruction() || scrollOrigi nChanged())
3665 updateScrollbars(); 3665 updateScrollbars();
3666 } 3666 }
3667 3667
3668 void FrameView::updateScrollbars() 3668 void FrameView::updateScrollbars()
3669 { 3669 {
3670 m_needsScrollbarsUpdate = false; 3670 m_needsScrollbarsUpdate = false;
3671 3671
3672 if (m_frame->settings() && m_frame->settings()->rootLayerScrolls()) 3672 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
3673 return; 3673 return;
3674 3674
3675 // Avoid drawing two sets of scrollbars when visual viewport is enabled. 3675 // Avoid drawing two sets of scrollbars when visual viewport is enabled.
3676 if (visualViewportSuppliesScrollbars()) { 3676 if (visualViewportSuppliesScrollbars()) {
3677 setHasHorizontalScrollbar(false); 3677 setHasHorizontalScrollbar(false);
3678 setHasVerticalScrollbar(false); 3678 setHasVerticalScrollbar(false);
3679 adjustScrollPositionFromUpdateScrollbars(); 3679 adjustScrollPositionFromUpdateScrollbars();
3680 return; 3680 return;
3681 } 3681 }
3682 3682
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
3926 positionScrollCornerLayer(layerForScrollCorner(), scrollCornerRect()); 3926 positionScrollCornerLayer(layerForScrollCorner(), scrollCornerRect());
3927 } 3927 }
3928 3928
3929 bool FrameView::userInputScrollable(ScrollbarOrientation orientation) const 3929 bool FrameView::userInputScrollable(ScrollbarOrientation orientation) const
3930 { 3930 {
3931 Document* document = frame().document(); 3931 Document* document = frame().document();
3932 Element* fullscreenElement = Fullscreen::fullscreenElementFrom(*document); 3932 Element* fullscreenElement = Fullscreen::fullscreenElementFrom(*document);
3933 if (fullscreenElement && fullscreenElement != document->documentElement()) 3933 if (fullscreenElement && fullscreenElement != document->documentElement())
3934 return false; 3934 return false;
3935 3935
3936 if (frame().settings() && frame().settings()->rootLayerScrolls()) 3936 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
3937 return false; 3937 return false;
3938 3938
3939 ScrollbarMode mode = (orientation == HorizontalScrollbar) ? 3939 ScrollbarMode mode = (orientation == HorizontalScrollbar) ?
3940 m_horizontalScrollbarMode : m_verticalScrollbarMode; 3940 m_horizontalScrollbarMode : m_verticalScrollbarMode;
3941 3941
3942 return mode == ScrollbarAuto || mode == ScrollbarAlwaysOn; 3942 return mode == ScrollbarAuto || mode == ScrollbarAlwaysOn;
3943 } 3943 }
3944 3944
3945 bool FrameView::shouldPlaceVerticalScrollbarOnLeft() const 3945 bool FrameView::shouldPlaceVerticalScrollbarOnLeft() const
3946 { 3946 {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
4140 ScrollableArea* FrameView::getScrollableArea() 4140 ScrollableArea* FrameView::getScrollableArea()
4141 { 4141 {
4142 if (m_viewportScrollableArea) 4142 if (m_viewportScrollableArea)
4143 return m_viewportScrollableArea.get(); 4143 return m_viewportScrollableArea.get();
4144 4144
4145 return layoutViewportScrollableArea(); 4145 return layoutViewportScrollableArea();
4146 } 4146 }
4147 4147
4148 ScrollableArea* FrameView::layoutViewportScrollableArea() 4148 ScrollableArea* FrameView::layoutViewportScrollableArea()
4149 { 4149 {
4150 Settings* settings = frame().settings(); 4150 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled())
4151 if (!settings || !settings->rootLayerScrolls())
4152 return this; 4151 return this;
4153 4152
4154 LayoutViewItem layoutViewItem = this->layoutViewItem(); 4153 LayoutViewItem layoutViewItem = this->layoutViewItem();
4155 return layoutViewItem.isNull() ? nullptr : layoutViewItem.getScrollableArea( ); 4154 return layoutViewItem.isNull() ? nullptr : layoutViewItem.getScrollableArea( );
4156 } 4155 }
4157 4156
4158 RootFrameViewport* FrameView::getRootFrameViewport() 4157 RootFrameViewport* FrameView::getRootFrameViewport()
4159 { 4158 {
4160 return m_viewportScrollableArea.get(); 4159 return m_viewportScrollableArea.get();
4161 } 4160 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
4337 } 4336 }
4338 4337
4339 bool FrameView::canThrottleRendering() const 4338 bool FrameView::canThrottleRendering() const
4340 { 4339 {
4341 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) 4340 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled())
4342 return false; 4341 return false;
4343 return m_subtreeThrottled || (m_hiddenForThrottling && m_crossOriginForThrot tling); 4342 return m_subtreeThrottled || (m_hiddenForThrottling && m_crossOriginForThrot tling);
4344 } 4343 }
4345 4344
4346 } // namespace blink 4345 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698