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

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: nit 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 resetStyleRelatedMainThreadScrollingReasons();
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 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 if (node && node->isElementNode() && 1781 if (node && node->isElementNode() &&
1782 (toElement(node)->compositorMutableProperties() & 1782 (toElement(node)->compositorMutableProperties() &
1783 (CompositorMutableProperty::kScrollTop | 1783 (CompositorMutableProperty::kScrollTop |
1784 CompositorMutableProperty::kScrollLeft))) 1784 CompositorMutableProperty::kScrollLeft)))
1785 return true; 1785 return true;
1786 1786
1787 if (layer->size().isEmpty()) 1787 if (layer->size().isEmpty())
1788 return false; 1788 return false;
1789 1789
1790 bool needsCompositedScrolling = true; 1790 bool needsCompositedScrolling = true;
1791 uint32_t mainThreadScrollingReasons = 0;
1792 1791
1793 // TODO(flackr): Allow integer transforms as long as all of the ancestor 1792 // TODO(flackr): Allow integer transforms as long as all of the ancestor
1794 // transforms are also integer. 1793 // transforms are also integer.
1795 bool backgroundSupportsLCDText = 1794 bool backgroundSupportsLCDText =
1796 RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled() && 1795 RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled() &&
1797 layer->layoutObject().style()->isStackingContext() && 1796 layer->layoutObject().style()->isStackingContext() &&
1798 layer->backgroundPaintLocation(&mainThreadScrollingReasons) & 1797 layer->backgroundPaintLocation(&m_reasons) &
1799 BackgroundPaintInScrollingContents && 1798 BackgroundPaintInScrollingContents &&
1800 layer->backgroundIsKnownToBeOpaqueInRect( 1799 layer->backgroundIsKnownToBeOpaqueInRect(
1801 toLayoutBox(layer->layoutObject()).paddingBoxRect()) && 1800 toLayoutBox(layer->layoutObject()).paddingBoxRect()) &&
1802 !layer->compositesWithTransform() && !layer->compositesWithOpacity(); 1801 !layer->compositesWithTransform() && !layer->compositesWithOpacity();
1803 1802
1804 if (mode == PaintLayerScrollableArea::ConsiderLCDText && 1803 if (mode == PaintLayerScrollableArea::ConsiderLCDText &&
1805 !layer->compositor()->preferCompositingToLCDTextEnabled() && 1804 !layer->compositor()->preferCompositingToLCDTextEnabled() &&
1806 !backgroundSupportsLCDText) { 1805 !backgroundSupportsLCDText) {
1807 if (layer->compositesWithOpacity()) { 1806 if (layer->compositesWithOpacity()) {
1808 mainThreadScrollingReasons |= 1807 m_reasons |= MainThreadScrollingReason::kHasOpacityAndLCDText;
1809 MainThreadScrollingReason::kHasOpacityAndLCDText;
1810 } 1808 }
1811 if (layer->compositesWithTransform()) { 1809 if (layer->compositesWithTransform()) {
1812 mainThreadScrollingReasons |= 1810 m_reasons |= MainThreadScrollingReason::kHasTransformAndLCDText;
1813 MainThreadScrollingReason::kHasTransformAndLCDText;
1814 } 1811 }
1815 if (!layer->backgroundIsKnownToBeOpaqueInRect( 1812 if (!layer->backgroundIsKnownToBeOpaqueInRect(
1816 toLayoutBox(layer->layoutObject()).paddingBoxRect())) { 1813 toLayoutBox(layer->layoutObject()).paddingBoxRect())) {
1817 mainThreadScrollingReasons |= 1814 m_reasons |=
1818 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText; 1815 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText;
1819 } 1816 }
1820 1817
1821 needsCompositedScrolling = false; 1818 needsCompositedScrolling = false;
1822 } 1819 }
1823 1820
1824 // TODO(schenney) Tests fail if we do not also exclude 1821 // TODO(schenney) Tests fail if we do not also exclude
1825 // layer->layoutObject().style()->hasBorderDecoration() (missing background 1822 // layer->layoutObject().style()->hasBorderDecoration() (missing background
1826 // behind dashed borders). Resolve this case, or not, and update this check 1823 // behind dashed borders). Resolve this case, or not, and update this check
1827 // with the results. 1824 // with the results.
1828 if (layer->layoutObject().style()->hasBorderRadius()) { 1825 if (layer->layoutObject().style()->hasBorderRadius()) {
1829 mainThreadScrollingReasons |= MainThreadScrollingReason::kHasBorderRadius; 1826 m_reasons |= MainThreadScrollingReason::kHasBorderRadius;
1830 needsCompositedScrolling = false; 1827 needsCompositedScrolling = false;
1831 } 1828 }
1832 if (layer->layoutObject().hasClip() || layer->hasDescendantWithClipPath() || 1829 if (layer->layoutObject().hasClip() || layer->hasDescendantWithClipPath() ||
1833 layer->hasAncestorWithClipPath()) { 1830 layer->hasAncestorWithClipPath()) {
1834 mainThreadScrollingReasons |= 1831 m_reasons |= MainThreadScrollingReason::kHasClipRelatedProperty;
1835 MainThreadScrollingReason::kHasClipRelatedProperty;
1836 needsCompositedScrolling = false; 1832 needsCompositedScrolling = false;
1837 } 1833 }
1838 1834
1839 if (mainThreadScrollingReasons) {
1840 addStyleRelatedMainThreadScrollingReasons(mainThreadScrollingReasons);
1841 }
1842
1843 return needsCompositedScrolling; 1835 return needsCompositedScrolling;
1844 } 1836 }
1845 1837
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( 1838 void PaintLayerScrollableArea::updateNeedsCompositedScrolling(
1886 LCDTextMode mode) { 1839 LCDTextMode mode) {
1887 // Clear all style related main thread scrolling reasons, if any, 1840 // Clear all style related main thread scrolling reasons, if any,
1888 // before calling computeNeedsCompositedScrolling 1841 // before calling computeNeedsCompositedScrolling
1889 removeStyleRelatedMainThreadScrollingReasons(); 1842 resetStyleRelatedMainThreadScrollingReasons();
bokan 2017/03/24 17:55:54 We should reset the reasons inside computeNeedsCom
yigu 2017/03/27 21:02:07 Done.
1890 const bool needsCompositedScrolling = 1843 const bool needsCompositedScrolling =
1891 computeNeedsCompositedScrolling(mode, layer()); 1844 computeNeedsCompositedScrolling(mode, layer());
1892 1845
1893 if (static_cast<bool>(m_needsCompositedScrolling) != 1846 if (static_cast<bool>(m_needsCompositedScrolling) !=
1894 needsCompositedScrolling) { 1847 needsCompositedScrolling) {
1895 m_needsCompositedScrolling = needsCompositedScrolling; 1848 m_needsCompositedScrolling = needsCompositedScrolling;
1896 layer()->didUpdateNeedsCompositedScrolling(); 1849 layer()->didUpdateNeedsCompositedScrolling();
1897 } 1850 }
1898 } 1851 }
1899 1852
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
2151 2104
2152 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: 2105 void PaintLayerScrollableArea::DelayScrollOffsetClampScope::
2153 clampScrollableAreas() { 2106 clampScrollableAreas() {
2154 for (auto& scrollableArea : *s_needsClamp) 2107 for (auto& scrollableArea : *s_needsClamp)
2155 scrollableArea->clampScrollOffsetAfterOverflowChange(); 2108 scrollableArea->clampScrollOffsetAfterOverflowChange();
2156 delete s_needsClamp; 2109 delete s_needsClamp;
2157 s_needsClamp = nullptr; 2110 s_needsClamp = nullptr;
2158 } 2111 }
2159 2112
2160 } // namespace blink 2113 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698