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

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 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 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 } 1715 }
1715 1716
1716 bool PaintLayerScrollableArea::shouldScrollOnMainThread() const { 1717 bool PaintLayerScrollableArea::shouldScrollOnMainThread() const {
1717 if (ScrollingCoordinator* scrollingCoordinator = getScrollingCoordinator()) { 1718 if (ScrollingCoordinator* scrollingCoordinator = getScrollingCoordinator()) {
1718 if (scrollingCoordinator->shouldUpdateScrollLayerPositionOnMainThread()) 1719 if (scrollingCoordinator->shouldUpdateScrollLayerPositionOnMainThread())
1719 return true; 1720 return true;
1720 } 1721 }
1721 return ScrollableArea::shouldScrollOnMainThread(); 1722 return ScrollableArea::shouldScrollOnMainThread();
1722 } 1723 }
1723 1724
1724 static bool layerNeedsCompositedScrolling( 1725 bool PaintLayerScrollableArea::layerNeedsCompositedScrolling(
1725 PaintLayerScrollableArea::LCDTextMode mode, 1726 const LCDTextMode mode,
1726 const PaintLayer* layer) { 1727 const PaintLayer* layer) {
1728 // Clear all style related main thread scrolling reasons, if any,
1729 // for current layer
1730 if (getScrollingCoordinator()) {
1731 getScrollingCoordinator()
bokan 2016/12/19 21:25:15 Doing this in here means that calling what looks l
yigu 2016/12/20 01:41:20 Agreed! Is it OK to use ScrollingCoordinator* scro
bokan 2016/12/20 15:53:15 Yah, unless I'm misunderstanding your question. My
1732 ->removeStyleRelatedMainThreadScrollingReasonsForLayer(this);
1733 }
1727 if (!layer->scrollsOverflow()) 1734 if (!layer->scrollsOverflow())
1728 return false; 1735 return false;
1729 1736
1730 Node* node = layer->enclosingNode(); 1737 Node* node = layer->enclosingNode();
1731 if (node && node->isElementNode() && 1738 if (node && node->isElementNode() &&
1732 (toElement(node)->compositorMutableProperties() & 1739 (toElement(node)->compositorMutableProperties() &
1733 (CompositorMutableProperty::kScrollTop | 1740 (CompositorMutableProperty::kScrollTop |
1734 CompositorMutableProperty::kScrollLeft))) 1741 CompositorMutableProperty::kScrollLeft)))
1735 return true; 1742 return true;
1736 1743
1737 // TODO(flackr): Allow integer transforms as long as all of the ancestor 1744 // TODO(flackr): Allow integer transforms as long as all of the ancestor
1738 // transforms are also integer. 1745 // transforms are also integer.
1739 bool backgroundSupportsLCDText = 1746 bool backgroundSupportsLCDText =
1740 RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled() && 1747 RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled() &&
1741 layer->layoutObject()->style()->isStackingContext() && 1748 layer->layoutObject()->style()->isStackingContext() &&
1742 layer->backgroundPaintLocation() & BackgroundPaintInScrollingContents && 1749 layer->backgroundPaintLocation() & BackgroundPaintInScrollingContents &&
1743 layer->backgroundIsKnownToBeOpaqueInRect( 1750 layer->backgroundIsKnownToBeOpaqueInRect(
1744 toLayoutBox(layer->layoutObject())->paddingBoxRect()) && 1751 toLayoutBox(layer->layoutObject())->paddingBoxRect()) &&
1745 !layer->compositesWithTransform() && !layer->compositesWithOpacity(); 1752 !layer->compositesWithTransform() && !layer->compositesWithOpacity();
1753
1746 if (mode == PaintLayerScrollableArea::ConsiderLCDText && 1754 if (mode == PaintLayerScrollableArea::ConsiderLCDText &&
1747 !layer->compositor()->preferCompositingToLCDTextEnabled() && 1755 !layer->compositor()->preferCompositingToLCDTextEnabled() &&
1748 !backgroundSupportsLCDText) 1756 !backgroundSupportsLCDText) {
1757 if (layer->compositesWithOpacity()) {
1758 addStyleRelatedMainThreadScrollingReasons(
1759 MainThreadScrollingReason::kHasOpacity);
1760 }
1749 return false; 1761 return false;
1762 }
1750 1763
1751 // TODO(schenney) Tests fail if we do not also exclude 1764 // TODO(schenney) Tests fail if we do not also exclude
1752 // layer->layoutObject()->style()->hasBorderDecoration() (missing background 1765 // layer->layoutObject()->style()->hasBorderDecoration() (missing background
1753 // behind dashed borders). Resolve this case, or not, and update this check 1766 // behind dashed borders). Resolve this case, or not, and update this check
1754 // with the results. 1767 // with the results.
1755 return !(layer->size().isEmpty() || layer->hasDescendantWithClipPath() || 1768 return !(layer->size().isEmpty() || layer->hasDescendantWithClipPath() ||
1756 layer->hasAncestorWithClipPath() || 1769 layer->hasAncestorWithClipPath() ||
1757 layer->layoutObject()->style()->hasBorderRadius()); 1770 layer->layoutObject()->style()->hasBorderRadius());
1758 } 1771 }
1759 1772
1773 // Check if current layer has layout object that contains properties that cause
bokan 2016/12/19 21:25:14 This comment is no longer accurate.
yigu 2016/12/20 01:41:20 Done.
1774 // main thread scrolling.
1775 void PaintLayerScrollableArea::addStyleRelatedMainThreadScrollingReasons(
1776 const uint32_t reason) {
1777 // If current layer has opacity and has not been recorded, add the layer into
bokan 2016/12/19 21:25:14 This comment can be removed, IMO.
yigu 2016/12/20 01:41:20 Done.
1778 // frameView.
1779 if (!getScrollingCoordinator())
1780 return;
1781 getScrollingCoordinator()->adjustStyleRelatedMainThreadScrollingReasons(
1782 reason, true);
1783
1784 flipMainThreadScrollingReason(reason);
bokan 2016/12/19 21:25:15 Rather than "flip", this should now be "set" and t
yigu 2016/12/20 01:41:20 I am not sure about this. Since we remove all exis
bokan 2016/12/20 15:53:15 That might be true today, but code often evolves i
1785 }
1786
1760 void PaintLayerScrollableArea::updateNeedsCompositedScrolling( 1787 void PaintLayerScrollableArea::updateNeedsCompositedScrolling(
1761 LCDTextMode mode) { 1788 LCDTextMode mode) {
1762 const bool needsCompositedScrolling = 1789 const bool needsCompositedScrolling =
1763 layerNeedsCompositedScrolling(mode, layer()); 1790 layerNeedsCompositedScrolling(mode, layer());
1791
1764 if (static_cast<bool>(m_needsCompositedScrolling) != 1792 if (static_cast<bool>(m_needsCompositedScrolling) !=
1765 needsCompositedScrolling) { 1793 needsCompositedScrolling) {
1766 m_needsCompositedScrolling = needsCompositedScrolling; 1794 m_needsCompositedScrolling = needsCompositedScrolling;
1767 layer()->didUpdateNeedsCompositedScrolling(); 1795 layer()->didUpdateNeedsCompositedScrolling();
1768 } 1796 }
1769 } 1797 }
1770 1798
1771 void PaintLayerScrollableArea::setTopmostScrollChild(PaintLayer* scrollChild) { 1799 void PaintLayerScrollableArea::setTopmostScrollChild(PaintLayer* scrollChild) {
1772 // We only want to track the topmost scroll child for scrollable areas with 1800 // We only want to track the topmost scroll child for scrollable areas with
1773 // overlay scrollbars. 1801 // overlay scrollbars.
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
2026 2054
2027 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: 2055 void PaintLayerScrollableArea::DelayScrollOffsetClampScope::
2028 clampScrollableAreas() { 2056 clampScrollableAreas() {
2029 for (auto& scrollableArea : *s_needsClamp) 2057 for (auto& scrollableArea : *s_needsClamp)
2030 scrollableArea->clampScrollOffsetAfterOverflowChange(); 2058 scrollableArea->clampScrollOffsetAfterOverflowChange();
2031 delete s_needsClamp; 2059 delete s_needsClamp;
2032 s_needsClamp = nullptr; 2060 s_needsClamp = nullptr;
2033 } 2061 }
2034 2062
2035 } // namespace blink 2063 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698