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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp

Issue 2565223002: Add more specific metrics for main thread scrolling reasons (Closed)
Patch Set: Refactoring && merging master Created 3 years, 12 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) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
6 * 6 *
7 * Other contributors: 7 * Other contributors:
8 * Robert O'Callahan <roc+@cs.cmu.edu> 8 * Robert O'Callahan <roc+@cs.cmu.edu>
9 * David Baron <dbaron@fas.harvard.edu> 9 * David Baron <dbaron@fas.harvard.edu>
10 * Christian Biesinger <cbiesinger@gmail.com> 10 * Christian Biesinger <cbiesinger@gmail.com>
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 m_needsCompositedScrolling(false), 99 m_needsCompositedScrolling(false),
100 m_rebuildHorizontalScrollbarLayer(false), 100 m_rebuildHorizontalScrollbarLayer(false),
101 m_rebuildVerticalScrollbarLayer(false), 101 m_rebuildVerticalScrollbarLayer(false),
102 m_needsScrollOffsetClamp(false), 102 m_needsScrollOffsetClamp(false),
103 m_needsRelayout(false), 103 m_needsRelayout(false),
104 m_hadHorizontalScrollbarBeforeRelayout(false), 104 m_hadHorizontalScrollbarBeforeRelayout(false),
105 m_hadVerticalScrollbarBeforeRelayout(false), 105 m_hadVerticalScrollbarBeforeRelayout(false),
106 m_scrollbarManager(*this), 106 m_scrollbarManager(*this),
107 m_scrollCorner(nullptr), 107 m_scrollCorner(nullptr),
108 m_resizer(nullptr), 108 m_resizer(nullptr),
109 m_scrollAnchor(this) 109 m_scrollAnchor(this),
110 m_reasons(0)
110 #if DCHECK_IS_ON() 111 #if DCHECK_IS_ON()
111 , 112 ,
112 m_hasBeenDisposed(false) 113 m_hasBeenDisposed(false)
113 #endif 114 #endif
114 { 115 {
115 Node* node = box().node(); 116 Node* node = box().node();
116 if (node && node->isElementNode()) { 117 if (node && node->isElementNode()) {
117 // We save and restore only the scrollOffset as the other scroll values are 118 // We save and restore only the scrollOffset as the other scroll values are
118 // recalculated. 119 // recalculated.
119 Element* element = toElement(node); 120 Element* element = toElement(node);
(...skipping 17 matching lines...) Expand all
137 frame->eventHandler().resizeScrollableAreaDestroyed(); 138 frame->eventHandler().resizeScrollableAreaDestroyed();
138 } 139 }
139 140
140 if (LocalFrame* frame = box().frame()) { 141 if (LocalFrame* frame = box().frame()) {
141 if (FrameView* frameView = frame->view()) { 142 if (FrameView* frameView = frame->view()) {
142 frameView->removeScrollableArea(this); 143 frameView->removeScrollableArea(this);
143 frameView->removeAnimatingScrollableArea(this); 144 frameView->removeAnimatingScrollableArea(this);
144 } 145 }
145 } 146 }
146 147
148 removeStyleRelatedMainThreadScrollingReasons();
149
147 if (ScrollingCoordinator* scrollingCoordinator = getScrollingCoordinator()) 150 if (ScrollingCoordinator* scrollingCoordinator = getScrollingCoordinator())
148 scrollingCoordinator->willDestroyScrollableArea(this); 151 scrollingCoordinator->willDestroyScrollableArea(this);
149 152
150 if (!box().documentBeingDestroyed()) { 153 if (!box().documentBeingDestroyed()) {
151 Node* node = box().node(); 154 Node* node = box().node();
152 // FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/414283. 155 // FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/414283.
153 if (node && node->isElementNode()) 156 if (node && node->isElementNode())
154 toElement(node)->setSavedLayerScrollOffset(m_scrollOffset); 157 toElement(node)->setSavedLayerScrollOffset(m_scrollOffset);
155 } 158 }
156 159
(...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 } 1717 }
1715 1718
1716 bool PaintLayerScrollableArea::shouldScrollOnMainThread() const { 1719 bool PaintLayerScrollableArea::shouldScrollOnMainThread() const {
1717 if (LocalFrame* frame = box().frame()) { 1720 if (LocalFrame* frame = box().frame()) {
1718 if (frame->view()->mainThreadScrollingReasons()) 1721 if (frame->view()->mainThreadScrollingReasons())
1719 return true; 1722 return true;
1720 } 1723 }
1721 return ScrollableArea::shouldScrollOnMainThread(); 1724 return ScrollableArea::shouldScrollOnMainThread();
1722 } 1725 }
1723 1726
1724 static bool layerNeedsCompositedScrolling( 1727 bool PaintLayerScrollableArea::layerNeedsCompositedScrolling(
1725 PaintLayerScrollableArea::LCDTextMode mode, 1728 const LCDTextMode mode,
1726 const PaintLayer* layer) { 1729 const PaintLayer* layer) {
1727 if (!layer->scrollsOverflow()) 1730 if (!layer->scrollsOverflow())
1728 return false; 1731 return false;
1729 1732
1730 Node* node = layer->enclosingNode(); 1733 Node* node = layer->enclosingNode();
1731 if (node && node->isElementNode() && 1734 if (node && node->isElementNode() &&
1732 (toElement(node)->compositorMutableProperties() & 1735 (toElement(node)->compositorMutableProperties() &
1733 (CompositorMutableProperty::kScrollTop | 1736 (CompositorMutableProperty::kScrollTop |
1734 CompositorMutableProperty::kScrollLeft))) 1737 CompositorMutableProperty::kScrollLeft)))
1735 return true; 1738 return true;
1736 1739
1737 // TODO(flackr): Allow integer transforms as long as all of the ancestor 1740 // TODO(flackr): Allow integer transforms as long as all of the ancestor
1738 // transforms are also integer. 1741 // transforms are also integer.
1739 bool backgroundSupportsLCDText = 1742 bool backgroundSupportsLCDText =
1740 RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled() && 1743 RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled() &&
1741 layer->layoutObject()->style()->isStackingContext() && 1744 layer->layoutObject()->style()->isStackingContext() &&
1742 layer->backgroundPaintLocation() & BackgroundPaintInScrollingContents && 1745 layer->backgroundPaintLocation() & BackgroundPaintInScrollingContents &&
1743 layer->backgroundIsKnownToBeOpaqueInRect( 1746 layer->backgroundIsKnownToBeOpaqueInRect(
1744 toLayoutBox(layer->layoutObject())->paddingBoxRect()) && 1747 toLayoutBox(layer->layoutObject())->paddingBoxRect()) &&
1745 !layer->compositesWithTransform() && !layer->compositesWithOpacity(); 1748 !layer->compositesWithTransform() && !layer->compositesWithOpacity();
1749
1746 if (mode == PaintLayerScrollableArea::ConsiderLCDText && 1750 if (mode == PaintLayerScrollableArea::ConsiderLCDText &&
1747 !layer->compositor()->preferCompositingToLCDTextEnabled() && 1751 !layer->compositor()->preferCompositingToLCDTextEnabled() &&
1748 !backgroundSupportsLCDText) 1752 !backgroundSupportsLCDText) {
1753 if (layer->compositesWithOpacity()) {
1754 addStyleRelatedMainThreadScrollingReasons(
bokan 2016/12/20 19:35:53 This still has the issue I brought up in the last
yigu 2016/12/20 19:59:31 Renamed the method to computeNeedsCompositedScroll
1755 MainThreadScrollingReason::kHasOpacity);
1756 }
1749 return false; 1757 return false;
1758 }
1750 1759
1751 // TODO(schenney) Tests fail if we do not also exclude 1760 // TODO(schenney) Tests fail if we do not also exclude
1752 // layer->layoutObject()->style()->hasBorderDecoration() (missing background 1761 // layer->layoutObject()->style()->hasBorderDecoration() (missing background
1753 // behind dashed borders). Resolve this case, or not, and update this check 1762 // behind dashed borders). Resolve this case, or not, and update this check
1754 // with the results. 1763 // with the results.
1755 return !(layer->size().isEmpty() || layer->hasDescendantWithClipPath() || 1764 return !(layer->size().isEmpty() || layer->hasDescendantWithClipPath() ||
1756 layer->hasAncestorWithClipPath() || 1765 layer->hasAncestorWithClipPath() ||
1757 layer->layoutObject()->style()->hasBorderRadius()); 1766 layer->layoutObject()->style()->hasBorderRadius());
1758 } 1767 }
1759 1768
1769 void PaintLayerScrollableArea::addStyleRelatedMainThreadScrollingReasons(
1770 const uint32_t reason) {
1771 LocalFrame* frame = box().frame();
1772 if (!frame)
1773 return;
1774 FrameView* frameView = frame->view();
1775 if (!frameView)
1776 return;
1777
1778 frameView->adjustStyleRelatedMainThreadScrollingReasons(reason, true);
1779
1780 setMainThreadScrollingReason(reason);
1781 }
1782
1783 void PaintLayerScrollableArea::removeStyleRelatedMainThreadScrollingReasons() {
1784 LocalFrame* frame = box().frame();
1785 if (!frame)
1786 return;
1787 FrameView* frameView = frame->view();
1788 if (!frameView)
1789 return;
1790
1791 // Decrese the number of layers that have any main thread
1792 // scrolling reasons stored in FrameView
1793 for (uint32_t i = 0;
1794 i < MainThreadScrollingReason::kMainThreadScrollingReasonCount; ++i) {
1795 uint32_t reason = 1 << i;
1796 if (hasMainThreadScrollingReason(reason)) {
1797 resetMainThreadScrollingReason(reason);
1798 frameView->adjustStyleRelatedMainThreadScrollingReasons(reason, false);
1799 }
1800 }
1801 }
1802
1760 void PaintLayerScrollableArea::updateNeedsCompositedScrolling( 1803 void PaintLayerScrollableArea::updateNeedsCompositedScrolling(
1761 LCDTextMode mode) { 1804 LCDTextMode mode) {
1805 // Clear all style related main thread scrolling reasons, if any,
1806 // before calling layerNeedsCompositedScrolling
1807 removeStyleRelatedMainThreadScrollingReasons();
1762 const bool needsCompositedScrolling = 1808 const bool needsCompositedScrolling =
1763 layerNeedsCompositedScrolling(mode, layer()); 1809 layerNeedsCompositedScrolling(mode, layer());
1810
1764 if (static_cast<bool>(m_needsCompositedScrolling) != 1811 if (static_cast<bool>(m_needsCompositedScrolling) !=
1765 needsCompositedScrolling) { 1812 needsCompositedScrolling) {
1766 m_needsCompositedScrolling = needsCompositedScrolling; 1813 m_needsCompositedScrolling = needsCompositedScrolling;
1767 layer()->didUpdateNeedsCompositedScrolling(); 1814 layer()->didUpdateNeedsCompositedScrolling();
1768 } 1815 }
1769 } 1816 }
1770 1817
1771 void PaintLayerScrollableArea::setTopmostScrollChild(PaintLayer* scrollChild) { 1818 void PaintLayerScrollableArea::setTopmostScrollChild(PaintLayer* scrollChild) {
1772 // We only want to track the topmost scroll child for scrollable areas with 1819 // We only want to track the topmost scroll child for scrollable areas with
1773 // overlay scrollbars. 1820 // overlay scrollbars.
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
2026 2073
2027 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: 2074 void PaintLayerScrollableArea::DelayScrollOffsetClampScope::
2028 clampScrollableAreas() { 2075 clampScrollableAreas() {
2029 for (auto& scrollableArea : *s_needsClamp) 2076 for (auto& scrollableArea : *s_needsClamp)
2030 scrollableArea->clampScrollOffsetAfterOverflowChange(); 2077 scrollableArea->clampScrollOffsetAfterOverflowChange();
2031 delete s_needsClamp; 2078 delete s_needsClamp;
2032 s_needsClamp = nullptr; 2079 s_needsClamp = nullptr;
2033 } 2080 }
2034 2081
2035 } // namespace blink 2082 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698