Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 visitor->trace(m_frame); | 217 visitor->trace(m_frame); |
| 218 visitor->trace(m_fragmentAnchor); | 218 visitor->trace(m_fragmentAnchor); |
| 219 visitor->trace(m_scrollableAreas); | 219 visitor->trace(m_scrollableAreas); |
| 220 visitor->trace(m_animatingScrollableAreas); | 220 visitor->trace(m_animatingScrollableAreas); |
| 221 visitor->trace(m_autoSizeInfo); | 221 visitor->trace(m_autoSizeInfo); |
| 222 visitor->trace(m_horizontalScrollbar); | 222 visitor->trace(m_horizontalScrollbar); |
| 223 visitor->trace(m_verticalScrollbar); | 223 visitor->trace(m_verticalScrollbar); |
| 224 visitor->trace(m_children); | 224 visitor->trace(m_children); |
| 225 visitor->trace(m_viewportScrollableArea); | 225 visitor->trace(m_viewportScrollableArea); |
| 226 visitor->trace(m_scrollAnchor); | 226 visitor->trace(m_scrollAnchor); |
| 227 visitor->trace(m_anchoringAdjustmentQueue); | |
| 227 Widget::trace(visitor); | 228 Widget::trace(visitor); |
| 228 ScrollableArea::trace(visitor); | 229 ScrollableArea::trace(visitor); |
| 229 } | 230 } |
| 230 | 231 |
| 231 void FrameView::reset() { | 232 void FrameView::reset() { |
| 232 m_hasPendingLayout = false; | 233 m_hasPendingLayout = false; |
| 233 m_layoutSchedulingEnabled = true; | 234 m_layoutSchedulingEnabled = true; |
| 234 m_inSynchronousPostLayout = false; | 235 m_inSynchronousPostLayout = false; |
| 235 m_layoutCount = 0; | 236 m_layoutCount = 0; |
| 236 m_nestedLayoutCount = 0; | 237 m_nestedLayoutCount = 0; |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 839 document->styleResolver()->mediaQueryAffectedByDeviceChange())) { | 840 document->styleResolver()->mediaQueryAffectedByDeviceChange())) { |
| 840 document->mediaQueryAffectingValueChanged(); | 841 document->mediaQueryAffectingValueChanged(); |
| 841 } else if (wasResized) { | 842 } else if (wasResized) { |
| 842 document->evaluateMediaQueryList(); | 843 document->evaluateMediaQueryList(); |
| 843 } | 844 } |
| 844 | 845 |
| 845 document->updateStyleAndLayoutTree(); | 846 document->updateStyleAndLayoutTree(); |
| 846 lifecycle().advanceTo(DocumentLifecycle::StyleClean); | 847 lifecycle().advanceTo(DocumentLifecycle::StyleClean); |
| 847 | 848 |
| 848 if (shouldPerformScrollAnchoring()) | 849 if (shouldPerformScrollAnchoring()) |
| 849 m_scrollAnchor.save(); | 850 m_scrollAnchor.notifyBeforeLayout(); |
| 850 } | 851 } |
| 851 | 852 |
| 852 bool FrameView::shouldPerformScrollAnchoring() const { | 853 bool FrameView::shouldPerformScrollAnchoring() const { |
| 853 return RuntimeEnabledFeatures::scrollAnchoringEnabled() && | 854 return RuntimeEnabledFeatures::scrollAnchoringEnabled() && |
| 854 !RuntimeEnabledFeatures::rootLayerScrollingEnabled() && | 855 !RuntimeEnabledFeatures::rootLayerScrollingEnabled() && |
| 855 m_scrollAnchor.hasScroller() && | 856 m_scrollAnchor.hasScroller() && |
| 856 layoutBox()->style()->overflowAnchor() != AnchorNone; | 857 layoutBox()->style()->overflowAnchor() != AnchorNone; |
| 857 } | 858 } |
| 858 | 859 |
| 859 static inline void layoutFromRootObject(LayoutObject& root) { | 860 static inline void layoutFromRootObject(LayoutObject& root) { |
| (...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2215 // Plugins could have torn down the page inside updateWidgetGeometries(). | 2216 // Plugins could have torn down the page inside updateWidgetGeometries(). |
| 2216 if (layoutViewItem().isNull()) | 2217 if (layoutViewItem().isNull()) |
| 2217 return; | 2218 return; |
| 2218 | 2219 |
| 2219 scheduleUpdateWidgetsIfNecessary(); | 2220 scheduleUpdateWidgetsIfNecessary(); |
| 2220 | 2221 |
| 2221 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) | 2222 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) |
| 2222 scrollingCoordinator->notifyGeometryChanged(); | 2223 scrollingCoordinator->notifyGeometryChanged(); |
| 2223 | 2224 |
| 2224 scrollToFragmentAnchor(); | 2225 scrollToFragmentAnchor(); |
| 2225 // TODO(skobes): Figure out interactions between scroll anchor, fragment | |
| 2226 // anchor, and history restoration. | |
| 2227 if (shouldPerformScrollAnchoring()) | |
| 2228 m_scrollAnchor.restore(); | |
| 2229 | |
| 2230 sendResizeEventIfNeeded(); | 2226 sendResizeEventIfNeeded(); |
| 2231 } | 2227 } |
| 2232 | 2228 |
| 2233 bool FrameView::wasViewportResized() { | 2229 bool FrameView::wasViewportResized() { |
| 2234 ASSERT(m_frame); | 2230 ASSERT(m_frame); |
| 2235 LayoutViewItem layoutViewItem = this->layoutViewItem(); | 2231 LayoutViewItem layoutViewItem = this->layoutViewItem(); |
| 2236 if (layoutViewItem.isNull()) | 2232 if (layoutViewItem.isNull()) |
| 2237 return false; | 2233 return false; |
| 2238 ASSERT(layoutViewItem.style()); | 2234 ASSERT(layoutViewItem.style()); |
| 2239 return (layoutSize(IncludeScrollbars) != m_lastViewportSize || | 2235 return (layoutSize(IncludeScrollbars) != m_lastViewportSize || |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2646 } | 2642 } |
| 2647 | 2643 |
| 2648 updateStyleAndLayoutIfNeededRecursive(); | 2644 updateStyleAndLayoutIfNeededRecursive(); |
| 2649 DCHECK(lifecycle().state() >= DocumentLifecycle::LayoutClean); | 2645 DCHECK(lifecycle().state() >= DocumentLifecycle::LayoutClean); |
| 2650 | 2646 |
| 2651 if (targetState == DocumentLifecycle::LayoutClean) { | 2647 if (targetState == DocumentLifecycle::LayoutClean) { |
| 2652 updateViewportIntersectionsForSubtree(targetState); | 2648 updateViewportIntersectionsForSubtree(targetState); |
| 2653 return; | 2649 return; |
| 2654 } | 2650 } |
| 2655 | 2651 |
| 2652 forAllNonThrottledFrameViews([](FrameView& frameView) { | |
|
szager1
2016/10/13 17:54:49
Shouldn't this happen before updateViewportInterse
skobes
2016/10/13 18:00:31
It does. For targetState > LayoutClean, the call
szager1
2016/10/13 18:50:56
Ah, I see, thanks.
| |
| 2653 frameView.performScrollAnchoringAdjustments(); | |
| 2654 }); | |
| 2655 | |
| 2656 if (targetState == DocumentLifecycle::PaintClean) { | 2656 if (targetState == DocumentLifecycle::PaintClean) { |
| 2657 forAllNonThrottledFrameViews( | 2657 forAllNonThrottledFrameViews( |
| 2658 [](FrameView& frameView) { frameView.notifyResizeObservers(); }); | 2658 [](FrameView& frameView) { frameView.notifyResizeObservers(); }); |
| 2659 } | 2659 } |
| 2660 | 2660 |
| 2661 if (LayoutViewItem view = layoutViewItem()) { | 2661 if (LayoutViewItem view = layoutViewItem()) { |
| 2662 forAllNonThrottledFrameViews([](FrameView& frameView) { | 2662 forAllNonThrottledFrameViews([](FrameView& frameView) { |
| 2663 frameView.checkDoesNotNeedLayout(); | 2663 frameView.checkDoesNotNeedLayout(); |
| 2664 frameView.m_allowsLayoutInvalidationAfterLayoutClean = false; | 2664 frameView.m_allowsLayoutInvalidationAfterLayoutClean = false; |
| 2665 }); | 2665 }); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2713 | 2713 |
| 2714 forAllNonThrottledFrameViews([](FrameView& frameView) { | 2714 forAllNonThrottledFrameViews([](FrameView& frameView) { |
| 2715 frameView.checkDoesNotNeedLayout(); | 2715 frameView.checkDoesNotNeedLayout(); |
| 2716 frameView.m_allowsLayoutInvalidationAfterLayoutClean = true; | 2716 frameView.m_allowsLayoutInvalidationAfterLayoutClean = true; |
| 2717 }); | 2717 }); |
| 2718 } | 2718 } |
| 2719 | 2719 |
| 2720 updateViewportIntersectionsForSubtree(targetState); | 2720 updateViewportIntersectionsForSubtree(targetState); |
| 2721 } | 2721 } |
| 2722 | 2722 |
| 2723 void FrameView::enqueueScrollAnchoringAdjustment( | |
| 2724 ScrollableArea* scrollableArea) { | |
| 2725 m_anchoringAdjustmentQueue.add(scrollableArea); | |
| 2726 } | |
| 2727 | |
| 2728 void FrameView::performScrollAnchoringAdjustments() { | |
| 2729 for (WeakMember<ScrollableArea>& scroller : m_anchoringAdjustmentQueue) { | |
| 2730 if (scroller) | |
| 2731 scroller->scrollAnchor()->adjust(); | |
| 2732 } | |
| 2733 m_anchoringAdjustmentQueue.clear(); | |
| 2734 } | |
| 2735 | |
| 2723 void FrameView::updatePaintProperties() { | 2736 void FrameView::updatePaintProperties() { |
| 2724 TRACE_EVENT0("blink", "FrameView::updatePaintProperties"); | 2737 TRACE_EVENT0("blink", "FrameView::updatePaintProperties"); |
| 2725 | 2738 |
| 2726 if (!m_paintController) | 2739 if (!m_paintController) |
| 2727 m_paintController = PaintController::create(); | 2740 m_paintController = PaintController::create(); |
| 2728 | 2741 |
| 2729 forAllNonThrottledFrameViews([](FrameView& frameView) { | 2742 forAllNonThrottledFrameViews([](FrameView& frameView) { |
| 2730 frameView.lifecycle().advanceTo(DocumentLifecycle::InPrePaint); | 2743 frameView.lifecycle().advanceTo(DocumentLifecycle::InPrePaint); |
| 2731 }); | 2744 }); |
| 2732 | 2745 |
| (...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3603 cache->handleScrollPositionChanged(this); | 3616 cache->handleScrollPositionChanged(this); |
| 3604 | 3617 |
| 3605 frame().loader().saveScrollState(); | 3618 frame().loader().saveScrollState(); |
| 3606 didChangeScrollOffset(); | 3619 didChangeScrollOffset(); |
| 3607 | 3620 |
| 3608 if (scrollType == CompositorScroll && m_frame->isMainFrame()) { | 3621 if (scrollType == CompositorScroll && m_frame->isMainFrame()) { |
| 3609 if (DocumentLoader* documentLoader = m_frame->loader().documentLoader()) | 3622 if (DocumentLoader* documentLoader = m_frame->loader().documentLoader()) |
| 3610 documentLoader->initialScrollState().wasScrolledByUser = true; | 3623 documentLoader->initialScrollState().wasScrolledByUser = true; |
| 3611 } | 3624 } |
| 3612 | 3625 |
| 3613 if (scrollType != AnchoringScroll) | 3626 if (scrollType != AnchoringScroll && scrollType != ClampingScroll) |
| 3614 clearScrollAnchor(); | 3627 clearScrollAnchor(); |
| 3615 } | 3628 } |
| 3616 | 3629 |
| 3617 void FrameView::didChangeScrollOffset() { | 3630 void FrameView::didChangeScrollOffset() { |
| 3618 frame().loader().client()->didChangeScrollOffset(); | 3631 frame().loader().client()->didChangeScrollOffset(); |
| 3619 if (frame().isMainFrame()) | 3632 if (frame().isMainFrame()) |
| 3620 frame().host()->chromeClient().mainFrameScrollOffsetChanged(); | 3633 frame().host()->chromeClient().mainFrameScrollOffsetChanged(); |
| 3621 } | 3634 } |
| 3622 | 3635 |
| 3623 void FrameView::clearScrollAnchor() { | 3636 void FrameView::clearScrollAnchor() { |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3831 frameRectsChanged(); | 3844 frameRectsChanged(); |
| 3832 positionScrollbarLayers(); | 3845 positionScrollbarLayers(); |
| 3833 updateScrollCorner(); | 3846 updateScrollCorner(); |
| 3834 } | 3847 } |
| 3835 | 3848 |
| 3836 adjustScrollOffsetFromUpdateScrollbars(); | 3849 adjustScrollOffsetFromUpdateScrollbars(); |
| 3837 } | 3850 } |
| 3838 | 3851 |
| 3839 void FrameView::adjustScrollOffsetFromUpdateScrollbars() { | 3852 void FrameView::adjustScrollOffsetFromUpdateScrollbars() { |
| 3840 ScrollOffset clamped = clampScrollOffset(scrollOffset()); | 3853 ScrollOffset clamped = clampScrollOffset(scrollOffset()); |
| 3841 // Restore before clamping because clamping clears the scroll anchor. | |
| 3842 // TODO(ymalik): This same logic exists in PaintLayerScrollableArea. | |
| 3843 // Remove when root-layer-scrolls is enabled. | |
| 3844 if (clamped != scrollOffset() && shouldPerformScrollAnchoring()) { | |
| 3845 m_scrollAnchor.restore(); | |
| 3846 clamped = clampScrollOffset(scrollOffset()); | |
| 3847 } | |
| 3848 if (clamped != scrollOffset() || scrollOriginChanged()) { | 3854 if (clamped != scrollOffset() || scrollOriginChanged()) { |
| 3849 ScrollableArea::setScrollOffset(clamped, ProgrammaticScroll); | 3855 ScrollableArea::setScrollOffset(clamped, ClampingScroll); |
| 3850 resetScrollOriginChanged(); | 3856 resetScrollOriginChanged(); |
| 3851 } | 3857 } |
| 3852 } | 3858 } |
| 3853 | 3859 |
| 3854 void FrameView::scrollContentsIfNeeded() { | 3860 void FrameView::scrollContentsIfNeeded() { |
| 3855 if (m_pendingScrollDelta.isZero()) | 3861 if (m_pendingScrollDelta.isZero()) |
| 3856 return; | 3862 return; |
| 3857 ScrollOffset scrollDelta = m_pendingScrollDelta; | 3863 ScrollOffset scrollDelta = m_pendingScrollDelta; |
| 3858 m_pendingScrollDelta = ScrollOffset(); | 3864 m_pendingScrollDelta = ScrollOffset(); |
| 3859 // FIXME: Change scrollContents() to take DoubleSize. crbug.com/414283. | 3865 // FIXME: Change scrollContents() to take DoubleSize. crbug.com/414283. |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4473 } | 4479 } |
| 4474 | 4480 |
| 4475 bool FrameView::canThrottleRendering() const { | 4481 bool FrameView::canThrottleRendering() const { |
| 4476 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) | 4482 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) |
| 4477 return false; | 4483 return false; |
| 4478 return m_subtreeThrottled || | 4484 return m_subtreeThrottled || |
| 4479 (m_hiddenForThrottling && m_crossOriginForThrottling); | 4485 (m_hiddenForThrottling && m_crossOriginForThrottling); |
| 4480 } | 4486 } |
| 4481 | 4487 |
| 4482 } // namespace blink | 4488 } // namespace blink |
| OLD | NEW |