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