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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 m_hiddenForThrottling(false), | 187 m_hiddenForThrottling(false), |
| 188 m_subtreeThrottled(false), | 188 m_subtreeThrottled(false), |
| 189 m_lifecycleUpdatesThrottled(false), | 189 m_lifecycleUpdatesThrottled(false), |
| 190 m_needsPaintPropertyUpdate(true), | 190 m_needsPaintPropertyUpdate(true), |
| 191 m_currentUpdateLifecyclePhasesTargetState( | 191 m_currentUpdateLifecyclePhasesTargetState( |
| 192 DocumentLifecycle::Uninitialized), | 192 DocumentLifecycle::Uninitialized), |
| 193 m_scrollAnchor(this), | 193 m_scrollAnchor(this), |
| 194 m_scrollbarManager(*this), | 194 m_scrollbarManager(*this), |
| 195 m_needsScrollbarsUpdate(false), | 195 m_needsScrollbarsUpdate(false), |
| 196 m_suppressAdjustViewSize(false), | 196 m_suppressAdjustViewSize(false), |
| 197 m_allowsLayoutInvalidationAfterLayoutClean(true) { | 197 m_allowsLayoutInvalidationAfterLayoutClean(true), |
| 198 m_lastMainThreadScrollingReasons(0) { | |
| 198 init(); | 199 init(); |
| 199 } | 200 } |
| 200 | 201 |
| 201 FrameView* FrameView::create(LocalFrame& frame) { | 202 FrameView* FrameView::create(LocalFrame& frame) { |
| 202 FrameView* view = new FrameView(frame); | 203 FrameView* view = new FrameView(frame); |
| 203 view->show(); | 204 view->show(); |
| 204 return view; | 205 return view; |
| 205 } | 206 } |
| 206 | 207 |
| 207 FrameView* FrameView::create(LocalFrame& frame, const IntSize& initialSize) { | 208 FrameView* FrameView::create(LocalFrame& frame, const IntSize& initialSize) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 m_firstLayout = true; | 251 m_firstLayout = true; |
| 251 m_safeToPropagateScrollToParent = true; | 252 m_safeToPropagateScrollToParent = true; |
| 252 m_lastViewportSize = IntSize(); | 253 m_lastViewportSize = IntSize(); |
| 253 m_lastZoomFactor = 1.0f; | 254 m_lastZoomFactor = 1.0f; |
| 254 m_trackedObjectPaintInvalidations = WTF::wrapUnique( | 255 m_trackedObjectPaintInvalidations = WTF::wrapUnique( |
| 255 s_initialTrackAllPaintInvalidations ? new Vector<ObjectPaintInvalidation> | 256 s_initialTrackAllPaintInvalidations ? new Vector<ObjectPaintInvalidation> |
| 256 : nullptr); | 257 : nullptr); |
| 257 m_visuallyNonEmptyCharacterCount = 0; | 258 m_visuallyNonEmptyCharacterCount = 0; |
| 258 m_visuallyNonEmptyPixelCount = 0; | 259 m_visuallyNonEmptyPixelCount = 0; |
| 259 m_isVisuallyNonEmpty = false; | 260 m_isVisuallyNonEmpty = false; |
| 261 m_lastMainThreadScrollingReasons = 0; | |
| 260 m_layoutObjectCounter.reset(); | 262 m_layoutObjectCounter.reset(); |
| 261 clearFragmentAnchor(); | 263 clearFragmentAnchor(); |
| 262 m_viewportConstrainedObjects.reset(); | 264 m_viewportConstrainedObjects.reset(); |
| 263 m_layoutSubtreeRootList.clear(); | 265 m_layoutSubtreeRootList.clear(); |
| 264 m_orthogonalWritingModeRootList.clear(); | 266 m_orthogonalWritingModeRootList.clear(); |
| 265 } | 267 } |
| 266 | 268 |
| 267 // Call function for each non-throttled frame view in pre tree order. | 269 // Call function for each non-throttled frame view in pre tree order. |
| 268 // Note it needs a null check of the frame's layoutView to access it in case of | 270 // Note it needs a null check of the frame's layoutView to access it in case of |
| 269 // detached frames. | 271 // detached frames. |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 817 LayoutViewItem layoutView = this->layoutViewItem(); | 819 LayoutViewItem layoutView = this->layoutViewItem(); |
| 818 if (layoutView.isNull()) | 820 if (layoutView.isNull()) |
| 819 return false; | 821 return false; |
| 820 if (m_frame->settings() && | 822 if (m_frame->settings() && |
| 821 m_frame->settings()->preferCompositingToLCDTextEnabled()) | 823 m_frame->settings()->preferCompositingToLCDTextEnabled()) |
| 822 return layoutView.compositor()->inCompositingMode(); | 824 return layoutView.compositor()->inCompositingMode(); |
| 823 return false; | 825 return false; |
| 824 } | 826 } |
| 825 | 827 |
| 826 bool FrameView::shouldScrollOnMainThread() const { | 828 bool FrameView::shouldScrollOnMainThread() const { |
| 827 if (ScrollingCoordinator* sc = scrollingCoordinator()) { | 829 if (mainThreadScrollingReasons()) |
| 828 if (sc->shouldUpdateScrollLayerPositionOnMainThread()) | 830 return true; |
| 829 return true; | |
| 830 } | |
| 831 return ScrollableArea::shouldScrollOnMainThread(); | 831 return ScrollableArea::shouldScrollOnMainThread(); |
| 832 } | 832 } |
| 833 | 833 |
| 834 GraphicsLayer* FrameView::layerForScrolling() const { | 834 GraphicsLayer* FrameView::layerForScrolling() const { |
| 835 LayoutViewItem layoutView = this->layoutViewItem(); | 835 LayoutViewItem layoutView = this->layoutViewItem(); |
| 836 if (layoutView.isNull()) | 836 if (layoutView.isNull()) |
| 837 return nullptr; | 837 return nullptr; |
| 838 return layoutView.compositor()->frameScrollLayer(); | 838 return layoutView.compositor()->frameScrollLayer(); |
| 839 } | 839 } |
| 840 | 840 |
| (...skipping 3831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4672 int FrameView::initialViewportWidth() const { | 4672 int FrameView::initialViewportWidth() const { |
| 4673 DCHECK(m_frame->isMainFrame()); | 4673 DCHECK(m_frame->isMainFrame()); |
| 4674 return m_initialViewportSize.width(); | 4674 return m_initialViewportSize.width(); |
| 4675 } | 4675 } |
| 4676 | 4676 |
| 4677 int FrameView::initialViewportHeight() const { | 4677 int FrameView::initialViewportHeight() const { |
| 4678 DCHECK(m_frame->isMainFrame()); | 4678 DCHECK(m_frame->isMainFrame()); |
| 4679 return m_initialViewportSize.height(); | 4679 return m_initialViewportSize.height(); |
| 4680 } | 4680 } |
| 4681 | 4681 |
| 4682 bool FrameView::hasVisibleSlowRepaintViewportConstrainedObjects( | |
|
pdr.
2016/12/17 05:50:16
Nit: I don't think you need to pass in frameView h
yigu
2016/12/18 17:57:11
Done.
| |
| 4683 const FrameView& frameView) const { | |
| 4684 const ViewportConstrainedObjectSet* viewportConstrainedObjects = | |
| 4685 frameView.viewportConstrainedObjects(); | |
| 4686 if (!viewportConstrainedObjects) | |
| 4687 return false; | |
| 4688 | |
| 4689 for (const LayoutObject* layoutObject : *viewportConstrainedObjects) { | |
| 4690 DCHECK(layoutObject->isBoxModelObject() && layoutObject->hasLayer()); | |
| 4691 DCHECK(layoutObject->style()->position() == FixedPosition || | |
| 4692 layoutObject->style()->position() == StickyPosition); | |
| 4693 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer(); | |
| 4694 | |
| 4695 // Whether the Layer sticks to the viewport is a tree-depenent | |
| 4696 // property and our viewportConstrainedObjects collection is maintained | |
| 4697 // with only LayoutObject-level information. | |
| 4698 if (!layer->sticksToViewport()) | |
| 4699 continue; | |
| 4700 | |
| 4701 // If the whole subtree is invisible, there's no reason to scroll on | |
| 4702 // the main thread because we don't need to generate invalidations | |
| 4703 // for invisible content. | |
| 4704 if (layer->subtreeIsInvisible()) | |
| 4705 continue; | |
| 4706 | |
| 4707 // We're only smart enough to scroll viewport-constrainted objects | |
| 4708 // in the compositor if they have their own backing or they paint | |
| 4709 // into a grouped back (which necessarily all have the same viewport | |
| 4710 // constraints). | |
| 4711 CompositingState compositingState = layer->compositingState(); | |
| 4712 if (compositingState != PaintsIntoOwnBacking && | |
| 4713 compositingState != PaintsIntoGroupedBacking) | |
| 4714 return true; | |
| 4715 } | |
| 4716 return false; | |
| 4717 } | |
| 4718 | |
| 4719 void FrameView::updateSubFrameScrollOnMainReason( | |
| 4720 const Frame& frame, | |
| 4721 MainThreadScrollingReasons parentReason) { | |
| 4722 MainThreadScrollingReasons reasons = parentReason; | |
| 4723 | |
| 4724 if (!page()->settings().threadedScrollingEnabled()) | |
| 4725 reasons |= MainThreadScrollingReason::kThreadedScrollingDisabled; | |
| 4726 | |
| 4727 if (!frame.isLocalFrame()) | |
| 4728 return; | |
| 4729 | |
| 4730 if (!toLocalFrame(frame).view()->layerForScrolling()) | |
| 4731 return; | |
| 4732 | |
| 4733 reasons |= mainThreadScrollingReasonsPerFrame(*toLocalFrame(&frame)); | |
| 4734 if (WebLayer* scrollLayer = | |
| 4735 toLocalFrame(frame).view()->layerForScrolling()->platformLayer()) { | |
| 4736 if (reasons) { | |
| 4737 scrollLayer->addMainThreadScrollingReasons(reasons); | |
| 4738 } else { | |
| 4739 scrollLayer->clearMainThreadScrollingReasons( | |
| 4740 ~0 & ~MainThreadScrollingReason::kHandlingScrollFromMainThread); | |
|
pdr.
2016/12/17 05:50:16
What is ~0 for?
yigu
2016/12/18 17:57:11
That was silly..
| |
| 4741 } | |
| 4742 } | |
| 4743 | |
| 4744 Frame* child = frame.tree().firstChild(); | |
| 4745 while (child) { | |
| 4746 updateSubFrameScrollOnMainReason(*child, reasons); | |
| 4747 child = child->tree().nextSibling(); | |
| 4748 } | |
| 4749 | |
| 4750 if (frame.isMainFrame()) | |
| 4751 m_lastMainThreadScrollingReasons = reasons; | |
| 4752 } | |
| 4753 | |
| 4754 MainThreadScrollingReasons FrameView::mainThreadScrollingReasonsPerFrame( | |
|
pdr.
2016/12/17 05:50:16
Is "const LocalFrame& frame" needed? Similar to ha
yigu
2016/12/18 17:57:11
Done.
| |
| 4755 const LocalFrame& frame) const { | |
| 4756 MainThreadScrollingReasons reasons = | |
| 4757 static_cast<MainThreadScrollingReasons>(0); | |
| 4758 | |
| 4759 FrameView* frameView = frame.view(); | |
| 4760 if (!frameView || frameView->shouldThrottleRendering()) | |
| 4761 return reasons; | |
| 4762 | |
| 4763 if (frameView->hasBackgroundAttachmentFixedObjects()) | |
| 4764 reasons |= MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects; | |
| 4765 ScrollingReasons scrollingReasons = frameView->getScrollingReasons(); | |
| 4766 const bool mayBeScrolledByInput = (scrollingReasons == Scrollable); | |
| 4767 const bool mayBeScrolledByScript = | |
| 4768 mayBeScrolledByInput || | |
| 4769 (scrollingReasons == NotScrollableExplicitlyDisabled); | |
| 4770 | |
| 4771 // TODO(awoloszyn) Currently crbug.com/304810 will let certain | |
| 4772 // overflow:hidden elements scroll on the compositor thread, so we should | |
| 4773 // not let this move there path as an optimization, when we have | |
| 4774 // slow-repaint elements. | |
| 4775 if (mayBeScrolledByScript && | |
| 4776 hasVisibleSlowRepaintViewportConstrainedObjects(*frameView)) { | |
| 4777 reasons |= | |
| 4778 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects; | |
| 4779 } | |
| 4780 return reasons; | |
| 4781 } | |
| 4782 | |
| 4783 MainThreadScrollingReasons FrameView::mainThreadScrollingReasons() const { | |
| 4784 MainThreadScrollingReasons reasons = | |
| 4785 static_cast<MainThreadScrollingReasons>(0); | |
| 4786 | |
| 4787 if (!page()->settings().threadedScrollingEnabled()) | |
| 4788 reasons |= MainThreadScrollingReason::kThreadedScrollingDisabled; | |
| 4789 | |
| 4790 if (!page()->mainFrame()->isLocalFrame()) | |
| 4791 return reasons; | |
| 4792 | |
| 4793 // TODO(alexmos,kenrb): For OOPIF, local roots that are different from | |
| 4794 // the main frame can't be used in the calculation, since they use | |
| 4795 // different compositors with unrelated state, which breaks some of the | |
| 4796 // calculations below. | |
| 4797 if (m_frame->localFrameRoot() != page()->mainFrame()) | |
| 4798 return reasons; | |
| 4799 | |
| 4800 // Walk through the subtree from the target frame to root. Use the gathered | |
|
pdr.
2016/12/17 05:50:16
Nit: Update this to reflect that the function is n
yigu
2016/12/18 17:57:11
Done.
| |
| 4801 // reasons to determine whether the target frame should be scrolled on main | |
| 4802 // thread regardless other subframes on the same page. | |
| 4803 for (Frame* frame = m_frame; frame; frame = frame->tree().parent()) { | |
| 4804 if (!frame->isLocalFrame()) | |
| 4805 continue; | |
| 4806 reasons |= mainThreadScrollingReasonsPerFrame(*toLocalFrame(frame)); | |
| 4807 } | |
| 4808 | |
| 4809 return reasons; | |
| 4810 } | |
| 4811 | |
| 4812 String FrameView::mainThreadScrollingReasonsAsText() const { | |
| 4813 DCHECK(lifecycle().state() >= DocumentLifecycle::CompositingClean); | |
| 4814 if (layerForScrolling() && layerForScrolling()->platformLayer()) { | |
| 4815 String result( | |
| 4816 MainThreadScrollingReason::mainThreadScrollingReasonsAsText( | |
| 4817 layerForScrolling()->platformLayer()->mainThreadScrollingReasons()) | |
| 4818 .c_str()); | |
| 4819 return result; | |
| 4820 } | |
| 4821 | |
| 4822 String result(MainThreadScrollingReason::mainThreadScrollingReasonsAsText( | |
| 4823 m_lastMainThreadScrollingReasons) | |
| 4824 .c_str()); | |
| 4825 return result; | |
| 4826 } | |
| 4827 | |
| 4682 } // namespace blink | 4828 } // namespace blink |
| OLD | NEW |