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

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

Issue 2773593005: Move logic of recording main thread scrolling reasons from cc to blink::ScrollManager (Closed)
Patch Set: Bug fix Created 3 years, 9 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 m_rebuildHorizontalScrollbarLayer(false), 108 m_rebuildHorizontalScrollbarLayer(false),
109 m_rebuildVerticalScrollbarLayer(false), 109 m_rebuildVerticalScrollbarLayer(false),
110 m_needsScrollOffsetClamp(false), 110 m_needsScrollOffsetClamp(false),
111 m_needsRelayout(false), 111 m_needsRelayout(false),
112 m_hadHorizontalScrollbarBeforeRelayout(false), 112 m_hadHorizontalScrollbarBeforeRelayout(false),
113 m_hadVerticalScrollbarBeforeRelayout(false), 113 m_hadVerticalScrollbarBeforeRelayout(false),
114 m_scrollbarManager(*this), 114 m_scrollbarManager(*this),
115 m_scrollCorner(nullptr), 115 m_scrollCorner(nullptr),
116 m_resizer(nullptr), 116 m_resizer(nullptr),
117 m_scrollAnchor(this), 117 m_scrollAnchor(this),
118 m_reasons(0) 118 m_nonCompositedMainThreadScrollingReasons(0)
119 #if DCHECK_IS_ON() 119 #if DCHECK_IS_ON()
120 , 120 ,
121 m_hasBeenDisposed(false) 121 m_hasBeenDisposed(false)
122 #endif 122 #endif
123 { 123 {
124 Node* node = box().node(); 124 Node* node = box().node();
125 if (node && node->isElementNode()) { 125 if (node && node->isElementNode()) {
126 // We save and restore only the scrollOffset as the other scroll values are 126 // We save and restore only the scrollOffset as the other scroll values are
127 // recalculated. 127 // recalculated.
128 Element* element = toElement(node); 128 Element* element = toElement(node);
(...skipping 17 matching lines...) Expand all
146 frame->eventHandler().resizeScrollableAreaDestroyed(); 146 frame->eventHandler().resizeScrollableAreaDestroyed();
147 } 147 }
148 148
149 if (LocalFrame* frame = box().frame()) { 149 if (LocalFrame* frame = box().frame()) {
150 if (FrameView* frameView = frame->view()) { 150 if (FrameView* frameView = frame->view()) {
151 frameView->removeScrollableArea(this); 151 frameView->removeScrollableArea(this);
152 frameView->removeAnimatingScrollableArea(this); 152 frameView->removeAnimatingScrollableArea(this);
153 } 153 }
154 } 154 }
155 155
156 removeStyleRelatedMainThreadScrollingReasons(); 156 m_nonCompositedMainThreadScrollingReasons = 0;
157 157
158 if (ScrollingCoordinator* scrollingCoordinator = getScrollingCoordinator()) 158 if (ScrollingCoordinator* scrollingCoordinator = getScrollingCoordinator())
159 scrollingCoordinator->willDestroyScrollableArea(this); 159 scrollingCoordinator->willDestroyScrollableArea(this);
160 160
161 if (!box().documentBeingDestroyed()) { 161 if (!box().documentBeingDestroyed()) {
162 Node* node = box().node(); 162 Node* node = box().node();
163 // FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/414283. 163 // FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/414283.
164 if (node && node->isElementNode()) 164 if (node && node->isElementNode())
165 toElement(node)->setSavedLayerScrollOffset(m_scrollOffset); 165 toElement(node)->setSavedLayerScrollOffset(m_scrollOffset);
166 } 166 }
(...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 if (LocalFrame* frame = box().frame()) { 1767 if (LocalFrame* frame = box().frame()) {
1768 if (frame->view()->mainThreadScrollingReasons()) 1768 if (frame->view()->mainThreadScrollingReasons())
1769 return true; 1769 return true;
1770 } 1770 }
1771 return ScrollableArea::shouldScrollOnMainThread(); 1771 return ScrollableArea::shouldScrollOnMainThread();
1772 } 1772 }
1773 1773
1774 bool PaintLayerScrollableArea::computeNeedsCompositedScrolling( 1774 bool PaintLayerScrollableArea::computeNeedsCompositedScrolling(
1775 const LCDTextMode mode, 1775 const LCDTextMode mode,
1776 const PaintLayer* layer) { 1776 const PaintLayer* layer) {
1777 // Clear all non composited main thread scrolling reasons, if any,
1778 // before continuing computeNeedsCompositedScrolling
bokan 2017/03/28 15:30:16 Comment unneeded.
1779 m_nonCompositedMainThreadScrollingReasons = 0;
1777 if (!layer->scrollsOverflow()) 1780 if (!layer->scrollsOverflow())
1778 return false; 1781 return false;
1779 1782
1780 Node* node = layer->enclosingNode(); 1783 Node* node = layer->enclosingNode();
1781 if (node && node->isElementNode() && 1784 if (node && node->isElementNode() &&
1782 (toElement(node)->compositorMutableProperties() & 1785 (toElement(node)->compositorMutableProperties() &
1783 (CompositorMutableProperty::kScrollTop | 1786 (CompositorMutableProperty::kScrollTop |
1784 CompositorMutableProperty::kScrollLeft))) 1787 CompositorMutableProperty::kScrollLeft)))
1785 return true; 1788 return true;
1786 1789
1787 if (layer->size().isEmpty()) 1790 if (layer->size().isEmpty())
1788 return false; 1791 return false;
1789 1792
1790 bool needsCompositedScrolling = true; 1793 bool needsCompositedScrolling = true;
1791 uint32_t mainThreadScrollingReasons = 0;
1792 1794
1793 // TODO(flackr): Allow integer transforms as long as all of the ancestor 1795 // TODO(flackr): Allow integer transforms as long as all of the ancestor
1794 // transforms are also integer. 1796 // transforms are also integer.
1795 bool backgroundSupportsLCDText = 1797 bool backgroundSupportsLCDText =
1796 RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled() && 1798 RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled() &&
1797 layer->layoutObject().style()->isStackingContext() && 1799 layer->layoutObject().style()->isStackingContext() &&
1798 layer->backgroundPaintLocation(&mainThreadScrollingReasons) & 1800 layer->backgroundPaintLocation(
1801 &m_nonCompositedMainThreadScrollingReasons) &
1799 BackgroundPaintInScrollingContents && 1802 BackgroundPaintInScrollingContents &&
1800 layer->backgroundIsKnownToBeOpaqueInRect( 1803 layer->backgroundIsKnownToBeOpaqueInRect(
1801 toLayoutBox(layer->layoutObject()).paddingBoxRect()) && 1804 toLayoutBox(layer->layoutObject()).paddingBoxRect()) &&
1802 !layer->compositesWithTransform() && !layer->compositesWithOpacity(); 1805 !layer->compositesWithTransform() && !layer->compositesWithOpacity();
1803 1806
1804 if (mode == PaintLayerScrollableArea::ConsiderLCDText && 1807 if (mode == PaintLayerScrollableArea::ConsiderLCDText &&
1805 !layer->compositor()->preferCompositingToLCDTextEnabled() && 1808 !layer->compositor()->preferCompositingToLCDTextEnabled() &&
1806 !backgroundSupportsLCDText) { 1809 !backgroundSupportsLCDText) {
1807 if (layer->compositesWithOpacity()) { 1810 if (layer->compositesWithOpacity()) {
1808 mainThreadScrollingReasons |= 1811 m_nonCompositedMainThreadScrollingReasons |=
1809 MainThreadScrollingReason::kHasOpacityAndLCDText; 1812 MainThreadScrollingReason::kHasOpacityAndLCDText;
1810 } 1813 }
1811 if (layer->compositesWithTransform()) { 1814 if (layer->compositesWithTransform()) {
1812 mainThreadScrollingReasons |= 1815 m_nonCompositedMainThreadScrollingReasons |=
1813 MainThreadScrollingReason::kHasTransformAndLCDText; 1816 MainThreadScrollingReason::kHasTransformAndLCDText;
1814 } 1817 }
1815 if (!layer->backgroundIsKnownToBeOpaqueInRect( 1818 if (!layer->backgroundIsKnownToBeOpaqueInRect(
1816 toLayoutBox(layer->layoutObject()).paddingBoxRect())) { 1819 toLayoutBox(layer->layoutObject()).paddingBoxRect())) {
1817 mainThreadScrollingReasons |= 1820 m_nonCompositedMainThreadScrollingReasons |=
1818 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText; 1821 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText;
1819 } 1822 }
1820 1823
1821 needsCompositedScrolling = false; 1824 needsCompositedScrolling = false;
1822 } 1825 }
1823 1826
1824 // TODO(schenney) Tests fail if we do not also exclude 1827 // TODO(schenney) Tests fail if we do not also exclude
1825 // layer->layoutObject().style()->hasBorderDecoration() (missing background 1828 // layer->layoutObject().style()->hasBorderDecoration() (missing background
1826 // behind dashed borders). Resolve this case, or not, and update this check 1829 // behind dashed borders). Resolve this case, or not, and update this check
1827 // with the results. 1830 // with the results.
1828 if (layer->layoutObject().style()->hasBorderRadius()) { 1831 if (layer->layoutObject().style()->hasBorderRadius()) {
1829 mainThreadScrollingReasons |= MainThreadScrollingReason::kHasBorderRadius; 1832 m_nonCompositedMainThreadScrollingReasons |=
1833 MainThreadScrollingReason::kHasBorderRadius;
1830 needsCompositedScrolling = false; 1834 needsCompositedScrolling = false;
1831 } 1835 }
1832 if (layer->layoutObject().hasClip() || layer->hasDescendantWithClipPath() || 1836 if (layer->layoutObject().hasClip() || layer->hasDescendantWithClipPath() ||
1833 layer->hasAncestorWithClipPath()) { 1837 layer->hasAncestorWithClipPath()) {
1834 mainThreadScrollingReasons |= 1838 m_nonCompositedMainThreadScrollingReasons |=
1835 MainThreadScrollingReason::kHasClipRelatedProperty; 1839 MainThreadScrollingReason::kHasClipRelatedProperty;
1836 needsCompositedScrolling = false; 1840 needsCompositedScrolling = false;
1837 } 1841 }
1838 1842
1839 if (mainThreadScrollingReasons) {
1840 addStyleRelatedMainThreadScrollingReasons(mainThreadScrollingReasons);
1841 }
1842
1843 return needsCompositedScrolling; 1843 return needsCompositedScrolling;
1844 } 1844 }
1845 1845
1846 void PaintLayerScrollableArea::addStyleRelatedMainThreadScrollingReasons(
1847 const uint32_t reasons) {
1848 LocalFrame* frame = box().frame();
1849 if (!frame)
1850 return;
1851 FrameView* frameView = frame->view();
1852 if (!frameView)
1853 return;
1854
1855 for (uint32_t reason = 1;
1856 reason < 1 << MainThreadScrollingReason::kMainThreadScrollingReasonCount;
1857 reason <<= 1) {
1858 if (reasons & reason) {
1859 frameView->adjustStyleRelatedMainThreadScrollingReasons(reason, true);
1860 m_reasons |= reason;
1861 }
1862 }
1863 }
1864
1865 void PaintLayerScrollableArea::removeStyleRelatedMainThreadScrollingReasons() {
1866 LocalFrame* frame = box().frame();
1867 if (!frame)
1868 return;
1869 FrameView* frameView = frame->view();
1870 if (!frameView)
1871 return;
1872
1873 // Decrease the number of layers that have any main thread
1874 // scrolling reasons stored in FrameView
1875 for (uint32_t i = 0;
1876 i < MainThreadScrollingReason::kMainThreadScrollingReasonCount; ++i) {
1877 uint32_t reason = 1 << i;
1878 if (hasMainThreadScrollingReason(reason)) {
1879 m_reasons &= ~reason;
1880 frameView->adjustStyleRelatedMainThreadScrollingReasons(reason, false);
1881 }
1882 }
1883 }
1884
1885 void PaintLayerScrollableArea::updateNeedsCompositedScrolling( 1846 void PaintLayerScrollableArea::updateNeedsCompositedScrolling(
1886 LCDTextMode mode) { 1847 LCDTextMode mode) {
1887 // Clear all style related main thread scrolling reasons, if any,
1888 // before calling computeNeedsCompositedScrolling
1889 removeStyleRelatedMainThreadScrollingReasons();
1890 const bool needsCompositedScrolling = 1848 const bool needsCompositedScrolling =
1891 computeNeedsCompositedScrolling(mode, layer()); 1849 computeNeedsCompositedScrolling(mode, layer());
1892 1850
1893 if (static_cast<bool>(m_needsCompositedScrolling) != 1851 if (static_cast<bool>(m_needsCompositedScrolling) !=
1894 needsCompositedScrolling) { 1852 needsCompositedScrolling) {
1895 m_needsCompositedScrolling = needsCompositedScrolling; 1853 m_needsCompositedScrolling = needsCompositedScrolling;
1896 layer()->didUpdateNeedsCompositedScrolling(); 1854 layer()->didUpdateNeedsCompositedScrolling();
1897 } 1855 }
1898 } 1856 }
1899 1857
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
2151 2109
2152 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: 2110 void PaintLayerScrollableArea::DelayScrollOffsetClampScope::
2153 clampScrollableAreas() { 2111 clampScrollableAreas() {
2154 for (auto& scrollableArea : *s_needsClamp) 2112 for (auto& scrollableArea : *s_needsClamp)
2155 scrollableArea->clampScrollOffsetAfterOverflowChange(); 2113 scrollableArea->clampScrollOffsetAfterOverflowChange();
2156 delete s_needsClamp; 2114 delete s_needsClamp;
2157 s_needsClamp = nullptr; 2115 s_needsClamp = nullptr;
2158 } 2116 }
2159 2117
2160 } // namespace blink 2118 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698