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

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: fix incorrect test for android devices Created 3 years, 8 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 rebuild_horizontal_scrollbar_layer_(false), 107 rebuild_horizontal_scrollbar_layer_(false),
108 rebuild_vertical_scrollbar_layer_(false), 108 rebuild_vertical_scrollbar_layer_(false),
109 needs_scroll_offset_clamp_(false), 109 needs_scroll_offset_clamp_(false),
110 needs_relayout_(false), 110 needs_relayout_(false),
111 had_horizontal_scrollbar_before_relayout_(false), 111 had_horizontal_scrollbar_before_relayout_(false),
112 had_vertical_scrollbar_before_relayout_(false), 112 had_vertical_scrollbar_before_relayout_(false),
113 scrollbar_manager_(*this), 113 scrollbar_manager_(*this),
114 scroll_corner_(nullptr), 114 scroll_corner_(nullptr),
115 resizer_(nullptr), 115 resizer_(nullptr),
116 scroll_anchor_(this), 116 scroll_anchor_(this),
117 reasons_(0) 117 non_composited_main_thread_scrolling_reasons_(0)
118 #if DCHECK_IS_ON() 118 #if DCHECK_IS_ON()
119 , 119 ,
120 has_been_disposed_(false) 120 has_been_disposed_(false)
121 #endif 121 #endif
122 { 122 {
123 Node* node = Box().GetNode(); 123 Node* node = Box().GetNode();
124 if (node && node->IsElementNode()) { 124 if (node && node->IsElementNode()) {
125 // We save and restore only the scrollOffset as the other scroll values are 125 // We save and restore only the scrollOffset as the other scroll values are
126 // recalculated. 126 // recalculated.
127 Element* element = ToElement(node); 127 Element* element = ToElement(node);
(...skipping 17 matching lines...) Expand all
145 frame->GetEventHandler().ResizeScrollableAreaDestroyed(); 145 frame->GetEventHandler().ResizeScrollableAreaDestroyed();
146 } 146 }
147 147
148 if (LocalFrame* frame = Box().GetFrame()) { 148 if (LocalFrame* frame = Box().GetFrame()) {
149 if (FrameView* frame_view = frame->View()) { 149 if (FrameView* frame_view = frame->View()) {
150 frame_view->RemoveScrollableArea(this); 150 frame_view->RemoveScrollableArea(this);
151 frame_view->RemoveAnimatingScrollableArea(this); 151 frame_view->RemoveAnimatingScrollableArea(this);
152 } 152 }
153 } 153 }
154 154
155 RemoveStyleRelatedMainThreadScrollingReasons(); 155 non_composited_main_thread_scrolling_reasons_ = 0;
156 156
157 if (ScrollingCoordinator* scrolling_coordinator = GetScrollingCoordinator()) 157 if (ScrollingCoordinator* scrolling_coordinator = GetScrollingCoordinator())
158 scrolling_coordinator->WillDestroyScrollableArea(this); 158 scrolling_coordinator->WillDestroyScrollableArea(this);
159 159
160 if (!Box().DocumentBeingDestroyed()) { 160 if (!Box().DocumentBeingDestroyed()) {
161 Node* node = Box().GetNode(); 161 Node* node = Box().GetNode();
162 // FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/414283. 162 // FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/414283.
163 if (node && node->IsElementNode()) 163 if (node && node->IsElementNode())
164 ToElement(node)->SetSavedLayerScrollOffset(scroll_offset_); 164 ToElement(node)->SetSavedLayerScrollOffset(scroll_offset_);
165 } 165 }
(...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after
1789 if (LocalFrame* frame = Box().GetFrame()) { 1789 if (LocalFrame* frame = Box().GetFrame()) {
1790 if (frame->View()->GetMainThreadScrollingReasons()) 1790 if (frame->View()->GetMainThreadScrollingReasons())
1791 return true; 1791 return true;
1792 } 1792 }
1793 return ScrollableArea::ShouldScrollOnMainThread(); 1793 return ScrollableArea::ShouldScrollOnMainThread();
1794 } 1794 }
1795 1795
1796 bool PaintLayerScrollableArea::ComputeNeedsCompositedScrolling( 1796 bool PaintLayerScrollableArea::ComputeNeedsCompositedScrolling(
1797 const LCDTextMode mode, 1797 const LCDTextMode mode,
1798 const PaintLayer* layer) { 1798 const PaintLayer* layer) {
1799 non_composited_main_thread_scrolling_reasons_ = 0;
1799 if (!layer->ScrollsOverflow()) 1800 if (!layer->ScrollsOverflow())
1800 return false; 1801 return false;
1801 1802
1802 Node* node = layer->EnclosingNode(); 1803 Node* node = layer->EnclosingNode();
1803 if (node && node->IsElementNode() && 1804 if (node && node->IsElementNode() &&
1804 (ToElement(node)->CompositorMutableProperties() & 1805 (ToElement(node)->CompositorMutableProperties() &
1805 (CompositorMutableProperty::kScrollTop | 1806 (CompositorMutableProperty::kScrollTop |
1806 CompositorMutableProperty::kScrollLeft))) 1807 CompositorMutableProperty::kScrollLeft)))
1807 return true; 1808 return true;
1808 1809
1809 if (layer->size().IsEmpty()) 1810 if (layer->size().IsEmpty())
1810 return false; 1811 return false;
1811 1812
1812 bool needs_composited_scrolling = true; 1813 bool needs_composited_scrolling = true;
1813 uint32_t main_thread_scrolling_reasons = 0;
1814 1814
1815 // TODO(flackr): Allow integer transforms as long as all of the ancestor 1815 // TODO(flackr): Allow integer transforms as long as all of the ancestor
1816 // transforms are also integer. 1816 // transforms are also integer.
1817 bool background_supports_lcd_text = 1817 bool background_supports_lcd_text =
1818 RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled() && 1818 RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled() &&
1819 layer->GetLayoutObject().Style()->IsStackingContext() && 1819 layer->GetLayoutObject().Style()->IsStackingContext() &&
1820 layer->GetBackgroundPaintLocation(&main_thread_scrolling_reasons) & 1820 layer->GetBackgroundPaintLocation(
1821 &non_composited_main_thread_scrolling_reasons_) &
1821 kBackgroundPaintInScrollingContents && 1822 kBackgroundPaintInScrollingContents &&
1822 layer->BackgroundIsKnownToBeOpaqueInRect( 1823 layer->BackgroundIsKnownToBeOpaqueInRect(
1823 ToLayoutBox(layer->GetLayoutObject()).PaddingBoxRect()) && 1824 ToLayoutBox(layer->GetLayoutObject()).PaddingBoxRect()) &&
1824 !layer->CompositesWithTransform() && !layer->CompositesWithOpacity(); 1825 !layer->CompositesWithTransform() && !layer->CompositesWithOpacity();
1825 1826
1826 if (mode == PaintLayerScrollableArea::kConsiderLCDText && 1827 if (mode == PaintLayerScrollableArea::kConsiderLCDText &&
1827 !layer->Compositor()->PreferCompositingToLCDTextEnabled() && 1828 !layer->Compositor()->PreferCompositingToLCDTextEnabled() &&
1828 !background_supports_lcd_text) { 1829 !background_supports_lcd_text) {
1829 if (layer->CompositesWithOpacity()) { 1830 if (layer->CompositesWithOpacity()) {
1830 main_thread_scrolling_reasons |= 1831 non_composited_main_thread_scrolling_reasons_ |=
1831 MainThreadScrollingReason::kHasOpacityAndLCDText; 1832 MainThreadScrollingReason::kHasOpacityAndLCDText;
1832 } 1833 }
1833 if (layer->CompositesWithTransform()) { 1834 if (layer->CompositesWithTransform()) {
1834 main_thread_scrolling_reasons |= 1835 non_composited_main_thread_scrolling_reasons_ |=
1835 MainThreadScrollingReason::kHasTransformAndLCDText; 1836 MainThreadScrollingReason::kHasTransformAndLCDText;
1836 } 1837 }
1837 if (!layer->BackgroundIsKnownToBeOpaqueInRect( 1838 if (!layer->BackgroundIsKnownToBeOpaqueInRect(
1838 ToLayoutBox(layer->GetLayoutObject()).PaddingBoxRect())) { 1839 ToLayoutBox(layer->GetLayoutObject()).PaddingBoxRect())) {
1839 main_thread_scrolling_reasons |= 1840 non_composited_main_thread_scrolling_reasons_ |=
1840 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText; 1841 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText;
1841 } 1842 }
1842 1843
1843 needs_composited_scrolling = false; 1844 needs_composited_scrolling = false;
1844 } 1845 }
1845 1846
1846 // TODO(schenney) Tests fail if we do not also exclude 1847 // TODO(schenney) Tests fail if we do not also exclude
1847 // layer->layoutObject().style()->hasBorderDecoration() (missing background 1848 // layer->layoutObject().style()->hasBorderDecoration() (missing background
1848 // behind dashed borders). Resolve this case, or not, and update this check 1849 // behind dashed borders). Resolve this case, or not, and update this check
1849 // with the results. 1850 // with the results.
1850 if (layer->GetLayoutObject().Style()->HasBorderRadius()) { 1851 if (layer->GetLayoutObject().Style()->HasBorderRadius()) {
1851 main_thread_scrolling_reasons |= 1852 non_composited_main_thread_scrolling_reasons_ |=
1852 MainThreadScrollingReason::kHasBorderRadius; 1853 MainThreadScrollingReason::kHasBorderRadius;
1853 needs_composited_scrolling = false; 1854 needs_composited_scrolling = false;
1854 } 1855 }
1855 if (layer->GetLayoutObject().HasClip() || 1856 if (layer->GetLayoutObject().HasClip() ||
1856 layer->HasDescendantWithClipPath() || layer->HasAncestorWithClipPath()) { 1857 layer->HasDescendantWithClipPath() || layer->HasAncestorWithClipPath()) {
1857 main_thread_scrolling_reasons |= 1858 non_composited_main_thread_scrolling_reasons_ |=
1858 MainThreadScrollingReason::kHasClipRelatedProperty; 1859 MainThreadScrollingReason::kHasClipRelatedProperty;
1859 needs_composited_scrolling = false; 1860 needs_composited_scrolling = false;
1860 } 1861 }
1861 1862
1862 if (main_thread_scrolling_reasons) { 1863 DCHECK(!(non_composited_main_thread_scrolling_reasons_ &
1863 AddStyleRelatedMainThreadScrollingReasons(main_thread_scrolling_reasons); 1864 ~MainThreadScrollingReason::kNonCompositedReasons));
1864 }
1865
1866 return needs_composited_scrolling; 1865 return needs_composited_scrolling;
1867 } 1866 }
1868 1867
1869 void PaintLayerScrollableArea::AddStyleRelatedMainThreadScrollingReasons(
1870 const uint32_t reasons) {
1871 LocalFrame* frame = Box().GetFrame();
1872 if (!frame)
1873 return;
1874 FrameView* frame_view = frame->View();
1875 if (!frame_view)
1876 return;
1877
1878 for (uint32_t reason = 1;
1879 reason < 1 << MainThreadScrollingReason::kMainThreadScrollingReasonCount;
1880 reason <<= 1) {
1881 if (reasons & reason) {
1882 frame_view->AdjustStyleRelatedMainThreadScrollingReasons(reason, true);
1883 reasons_ |= reason;
1884 }
1885 }
1886 }
1887
1888 void PaintLayerScrollableArea::RemoveStyleRelatedMainThreadScrollingReasons() {
1889 LocalFrame* frame = Box().GetFrame();
1890 if (!frame)
1891 return;
1892 FrameView* frame_view = frame->View();
1893 if (!frame_view)
1894 return;
1895
1896 // Decrease the number of layers that have any main thread
1897 // scrolling reasons stored in FrameView
1898 for (uint32_t i = 0;
1899 i < MainThreadScrollingReason::kMainThreadScrollingReasonCount; ++i) {
1900 uint32_t reason = 1 << i;
1901 if (HasMainThreadScrollingReason(reason)) {
1902 reasons_ &= ~reason;
1903 frame_view->AdjustStyleRelatedMainThreadScrollingReasons(reason, false);
1904 }
1905 }
1906 }
1907
1908 void PaintLayerScrollableArea::UpdateNeedsCompositedScrolling( 1868 void PaintLayerScrollableArea::UpdateNeedsCompositedScrolling(
1909 LCDTextMode mode) { 1869 LCDTextMode mode) {
1910 // Clear all style related main thread scrolling reasons, if any,
1911 // before calling computeNeedsCompositedScrolling
1912 RemoveStyleRelatedMainThreadScrollingReasons();
1913 const bool needs_composited_scrolling = 1870 const bool needs_composited_scrolling =
1914 ComputeNeedsCompositedScrolling(mode, Layer()); 1871 ComputeNeedsCompositedScrolling(mode, Layer());
1915 1872
1916 if (static_cast<bool>(needs_composited_scrolling_) != 1873 if (static_cast<bool>(needs_composited_scrolling_) !=
1917 needs_composited_scrolling) { 1874 needs_composited_scrolling) {
1918 needs_composited_scrolling_ = needs_composited_scrolling; 1875 needs_composited_scrolling_ = needs_composited_scrolling;
1919 Layer()->DidUpdateNeedsCompositedScrolling(); 1876 Layer()->DidUpdateNeedsCompositedScrolling();
1920 } 1877 }
1921 } 1878 }
1922 1879
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
2176 2133
2177 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: 2134 void PaintLayerScrollableArea::DelayScrollOffsetClampScope::
2178 ClampScrollableAreas() { 2135 ClampScrollableAreas() {
2179 for (auto& scrollable_area : *needs_clamp_) 2136 for (auto& scrollable_area : *needs_clamp_)
2180 scrollable_area->ClampScrollOffsetAfterOverflowChange(); 2137 scrollable_area->ClampScrollOffsetAfterOverflowChange();
2181 delete needs_clamp_; 2138 delete needs_clamp_;
2182 needs_clamp_ = nullptr; 2139 needs_clamp_ = nullptr;
2183 } 2140 }
2184 2141
2185 } // namespace blink 2142 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698