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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 216 |
217 DEFINE_TRACE(FrameView) { | 217 DEFINE_TRACE(FrameView) { |
218 visitor->trace(m_frame); | 218 visitor->trace(m_frame); |
219 visitor->trace(m_fragmentAnchor); | 219 visitor->trace(m_fragmentAnchor); |
220 visitor->trace(m_scrollableAreas); | 220 visitor->trace(m_scrollableAreas); |
221 visitor->trace(m_animatingScrollableAreas); | 221 visitor->trace(m_animatingScrollableAreas); |
222 visitor->trace(m_autoSizeInfo); | 222 visitor->trace(m_autoSizeInfo); |
223 visitor->trace(m_children); | 223 visitor->trace(m_children); |
224 visitor->trace(m_viewportScrollableArea); | 224 visitor->trace(m_viewportScrollableArea); |
225 visitor->trace(m_scrollAnchor); | 225 visitor->trace(m_scrollAnchor); |
| 226 visitor->trace(m_anchoringAdjustmentQueue); |
226 visitor->trace(m_scrollbarManager); | 227 visitor->trace(m_scrollbarManager); |
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; |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 document->styleResolver()->mediaQueryAffectedByDeviceChange())) { | 903 document->styleResolver()->mediaQueryAffectedByDeviceChange())) { |
903 document->mediaQueryAffectingValueChanged(); | 904 document->mediaQueryAffectingValueChanged(); |
904 } else if (wasResized) { | 905 } else if (wasResized) { |
905 document->evaluateMediaQueryList(); | 906 document->evaluateMediaQueryList(); |
906 } | 907 } |
907 | 908 |
908 document->updateStyleAndLayoutTree(); | 909 document->updateStyleAndLayoutTree(); |
909 lifecycle().advanceTo(DocumentLifecycle::StyleClean); | 910 lifecycle().advanceTo(DocumentLifecycle::StyleClean); |
910 | 911 |
911 if (shouldPerformScrollAnchoring()) | 912 if (shouldPerformScrollAnchoring()) |
912 m_scrollAnchor.save(); | 913 m_scrollAnchor.notifyBeforeLayout(); |
913 } | 914 } |
914 | 915 |
915 bool FrameView::shouldPerformScrollAnchoring() const { | 916 bool FrameView::shouldPerformScrollAnchoring() const { |
916 return RuntimeEnabledFeatures::scrollAnchoringEnabled() && | 917 return RuntimeEnabledFeatures::scrollAnchoringEnabled() && |
917 !RuntimeEnabledFeatures::rootLayerScrollingEnabled() && | 918 !RuntimeEnabledFeatures::rootLayerScrollingEnabled() && |
918 m_scrollAnchor.hasScroller() && | 919 m_scrollAnchor.hasScroller() && |
919 layoutBox()->style()->overflowAnchor() != AnchorNone && | 920 layoutBox()->style()->overflowAnchor() != AnchorNone && |
920 !m_frame->document()->finishingOrIsPrinting(); | 921 !m_frame->document()->finishingOrIsPrinting(); |
921 } | 922 } |
922 | 923 |
(...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2279 // Plugins could have torn down the page inside updateWidgetGeometries(). | 2280 // Plugins could have torn down the page inside updateWidgetGeometries(). |
2280 if (layoutViewItem().isNull()) | 2281 if (layoutViewItem().isNull()) |
2281 return; | 2282 return; |
2282 | 2283 |
2283 scheduleUpdateWidgetsIfNecessary(); | 2284 scheduleUpdateWidgetsIfNecessary(); |
2284 | 2285 |
2285 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) | 2286 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) |
2286 scrollingCoordinator->notifyGeometryChanged(); | 2287 scrollingCoordinator->notifyGeometryChanged(); |
2287 | 2288 |
2288 scrollToFragmentAnchor(); | 2289 scrollToFragmentAnchor(); |
2289 // TODO(skobes): Figure out interactions between scroll anchor, fragment | |
2290 // anchor, and history restoration. | |
2291 if (shouldPerformScrollAnchoring()) | |
2292 m_scrollAnchor.restore(); | |
2293 | |
2294 sendResizeEventIfNeeded(); | 2290 sendResizeEventIfNeeded(); |
2295 } | 2291 } |
2296 | 2292 |
2297 bool FrameView::wasViewportResized() { | 2293 bool FrameView::wasViewportResized() { |
2298 ASSERT(m_frame); | 2294 ASSERT(m_frame); |
2299 LayoutViewItem layoutViewItem = this->layoutViewItem(); | 2295 LayoutViewItem layoutViewItem = this->layoutViewItem(); |
2300 if (layoutViewItem.isNull()) | 2296 if (layoutViewItem.isNull()) |
2301 return false; | 2297 return false; |
2302 ASSERT(layoutViewItem.style()); | 2298 ASSERT(layoutViewItem.style()); |
2303 return (layoutSize(IncludeScrollbars) != m_lastViewportSize || | 2299 return (layoutSize(IncludeScrollbars) != m_lastViewportSize || |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2710 } | 2706 } |
2711 | 2707 |
2712 updateStyleAndLayoutIfNeededRecursive(); | 2708 updateStyleAndLayoutIfNeededRecursive(); |
2713 DCHECK(lifecycle().state() >= DocumentLifecycle::LayoutClean); | 2709 DCHECK(lifecycle().state() >= DocumentLifecycle::LayoutClean); |
2714 | 2710 |
2715 if (targetState == DocumentLifecycle::LayoutClean) { | 2711 if (targetState == DocumentLifecycle::LayoutClean) { |
2716 updateViewportIntersectionsForSubtree(targetState); | 2712 updateViewportIntersectionsForSubtree(targetState); |
2717 return; | 2713 return; |
2718 } | 2714 } |
2719 | 2715 |
| 2716 forAllNonThrottledFrameViews([](FrameView& frameView) { |
| 2717 frameView.performScrollAnchoringAdjustments(); |
| 2718 }); |
| 2719 |
2720 if (targetState == DocumentLifecycle::PaintClean) { | 2720 if (targetState == DocumentLifecycle::PaintClean) { |
2721 forAllNonThrottledFrameViews( | 2721 forAllNonThrottledFrameViews( |
2722 [](FrameView& frameView) { frameView.notifyResizeObservers(); }); | 2722 [](FrameView& frameView) { frameView.notifyResizeObservers(); }); |
2723 } | 2723 } |
2724 | 2724 |
2725 if (LayoutViewItem view = layoutViewItem()) { | 2725 if (LayoutViewItem view = layoutViewItem()) { |
2726 forAllNonThrottledFrameViews([](FrameView& frameView) { | 2726 forAllNonThrottledFrameViews([](FrameView& frameView) { |
2727 frameView.checkDoesNotNeedLayout(); | 2727 frameView.checkDoesNotNeedLayout(); |
2728 frameView.m_allowsLayoutInvalidationAfterLayoutClean = false; | 2728 frameView.m_allowsLayoutInvalidationAfterLayoutClean = false; |
2729 }); | 2729 }); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2777 | 2777 |
2778 forAllNonThrottledFrameViews([](FrameView& frameView) { | 2778 forAllNonThrottledFrameViews([](FrameView& frameView) { |
2779 frameView.checkDoesNotNeedLayout(); | 2779 frameView.checkDoesNotNeedLayout(); |
2780 frameView.m_allowsLayoutInvalidationAfterLayoutClean = true; | 2780 frameView.m_allowsLayoutInvalidationAfterLayoutClean = true; |
2781 }); | 2781 }); |
2782 } | 2782 } |
2783 | 2783 |
2784 updateViewportIntersectionsForSubtree(targetState); | 2784 updateViewportIntersectionsForSubtree(targetState); |
2785 } | 2785 } |
2786 | 2786 |
| 2787 void FrameView::enqueueScrollAnchoringAdjustment( |
| 2788 ScrollableArea* scrollableArea) { |
| 2789 m_anchoringAdjustmentQueue.add(scrollableArea); |
| 2790 } |
| 2791 |
| 2792 void FrameView::performScrollAnchoringAdjustments() { |
| 2793 for (WeakMember<ScrollableArea>& scroller : m_anchoringAdjustmentQueue) { |
| 2794 if (scroller) { |
| 2795 DCHECK(scroller->scrollAnchor()); |
| 2796 scroller->scrollAnchor()->adjust(); |
| 2797 } |
| 2798 } |
| 2799 m_anchoringAdjustmentQueue.clear(); |
| 2800 } |
| 2801 |
2787 void FrameView::updatePaintProperties() { | 2802 void FrameView::updatePaintProperties() { |
2788 TRACE_EVENT0("blink", "FrameView::updatePaintProperties"); | 2803 TRACE_EVENT0("blink", "FrameView::updatePaintProperties"); |
2789 | 2804 |
2790 if (!m_paintController) | 2805 if (!m_paintController) |
2791 m_paintController = PaintController::create(); | 2806 m_paintController = PaintController::create(); |
2792 | 2807 |
2793 forAllNonThrottledFrameViews([](FrameView& frameView) { | 2808 forAllNonThrottledFrameViews([](FrameView& frameView) { |
2794 frameView.lifecycle().advanceTo(DocumentLifecycle::InPrePaint); | 2809 frameView.lifecycle().advanceTo(DocumentLifecycle::InPrePaint); |
2795 }); | 2810 }); |
2796 | 2811 |
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3623 cache->handleScrollPositionChanged(this); | 3638 cache->handleScrollPositionChanged(this); |
3624 | 3639 |
3625 frame().loader().saveScrollState(); | 3640 frame().loader().saveScrollState(); |
3626 didChangeScrollOffset(); | 3641 didChangeScrollOffset(); |
3627 | 3642 |
3628 if (scrollType == CompositorScroll && m_frame->isMainFrame()) { | 3643 if (scrollType == CompositorScroll && m_frame->isMainFrame()) { |
3629 if (DocumentLoader* documentLoader = m_frame->loader().documentLoader()) | 3644 if (DocumentLoader* documentLoader = m_frame->loader().documentLoader()) |
3630 documentLoader->initialScrollState().wasScrolledByUser = true; | 3645 documentLoader->initialScrollState().wasScrolledByUser = true; |
3631 } | 3646 } |
3632 | 3647 |
3633 if (scrollType != AnchoringScroll) | 3648 if (scrollType != AnchoringScroll && scrollType != ClampingScroll) |
3634 clearScrollAnchor(); | 3649 clearScrollAnchor(); |
3635 } | 3650 } |
3636 | 3651 |
3637 void FrameView::didChangeScrollOffset() { | 3652 void FrameView::didChangeScrollOffset() { |
3638 frame().loader().client()->didChangeScrollOffset(); | 3653 frame().loader().client()->didChangeScrollOffset(); |
3639 if (frame().isMainFrame()) | 3654 if (frame().isMainFrame()) |
3640 frame().host()->chromeClient().mainFrameScrollOffsetChanged(); | 3655 frame().host()->chromeClient().mainFrameScrollOffsetChanged(); |
3641 } | 3656 } |
3642 | 3657 |
3643 void FrameView::clearScrollAnchor() { | 3658 void FrameView::clearScrollAnchor() { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3851 frameRectsChanged(); | 3866 frameRectsChanged(); |
3852 positionScrollbarLayers(); | 3867 positionScrollbarLayers(); |
3853 updateScrollCorner(); | 3868 updateScrollCorner(); |
3854 } | 3869 } |
3855 | 3870 |
3856 adjustScrollOffsetFromUpdateScrollbars(); | 3871 adjustScrollOffsetFromUpdateScrollbars(); |
3857 } | 3872 } |
3858 | 3873 |
3859 void FrameView::adjustScrollOffsetFromUpdateScrollbars() { | 3874 void FrameView::adjustScrollOffsetFromUpdateScrollbars() { |
3860 ScrollOffset clamped = clampScrollOffset(scrollOffset()); | 3875 ScrollOffset clamped = clampScrollOffset(scrollOffset()); |
3861 // Restore before clamping because clamping clears the scroll anchor. | |
3862 // TODO(ymalik): This same logic exists in PaintLayerScrollableArea. | |
3863 // Remove when root-layer-scrolls is enabled. | |
3864 if (clamped != scrollOffset() && shouldPerformScrollAnchoring()) { | |
3865 m_scrollAnchor.restore(); | |
3866 clamped = clampScrollOffset(scrollOffset()); | |
3867 } | |
3868 if (clamped != scrollOffset() || scrollOriginChanged()) { | 3876 if (clamped != scrollOffset() || scrollOriginChanged()) { |
3869 ScrollableArea::setScrollOffset(clamped, ProgrammaticScroll); | 3877 ScrollableArea::setScrollOffset(clamped, ClampingScroll); |
3870 resetScrollOriginChanged(); | 3878 resetScrollOriginChanged(); |
3871 } | 3879 } |
3872 } | 3880 } |
3873 | 3881 |
3874 void FrameView::scrollContentsIfNeeded() { | 3882 void FrameView::scrollContentsIfNeeded() { |
3875 if (m_pendingScrollDelta.isZero()) | 3883 if (m_pendingScrollDelta.isZero()) |
3876 return; | 3884 return; |
3877 ScrollOffset scrollDelta = m_pendingScrollDelta; | 3885 ScrollOffset scrollDelta = m_pendingScrollDelta; |
3878 m_pendingScrollDelta = ScrollOffset(); | 3886 m_pendingScrollDelta = ScrollOffset(); |
3879 // FIXME: Change scrollContents() to take DoubleSize. crbug.com/414283. | 3887 // FIXME: Change scrollContents() to take DoubleSize. crbug.com/414283. |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4530 DCHECK(m_frame->isMainFrame()); | 4538 DCHECK(m_frame->isMainFrame()); |
4531 return m_initialViewportSize.width(); | 4539 return m_initialViewportSize.width(); |
4532 } | 4540 } |
4533 | 4541 |
4534 int FrameView::initialViewportHeight() const { | 4542 int FrameView::initialViewportHeight() const { |
4535 DCHECK(m_frame->isMainFrame()); | 4543 DCHECK(m_frame->isMainFrame()); |
4536 return m_initialViewportSize.height(); | 4544 return m_initialViewportSize.height(); |
4537 } | 4545 } |
4538 | 4546 |
4539 } // namespace blink | 4547 } // namespace blink |
OLD | NEW |