| 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 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 non_composited_main_thread_scrolling_reasons_(0) | 117 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 Loading... |
| 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 non_composited_main_thread_scrolling_reasons_ = 0; | 155 RemoveStyleRelatedMainThreadScrollingReasons(); |
| 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 Loading... |
| 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; | |
| 1800 if (!layer->ScrollsOverflow()) | 1799 if (!layer->ScrollsOverflow()) |
| 1801 return false; | 1800 return false; |
| 1802 | 1801 |
| 1803 Node* node = layer->EnclosingNode(); | 1802 Node* node = layer->EnclosingNode(); |
| 1804 if (node && node->IsElementNode() && | 1803 if (node && node->IsElementNode() && |
| 1805 (ToElement(node)->CompositorMutableProperties() & | 1804 (ToElement(node)->CompositorMutableProperties() & |
| 1806 (CompositorMutableProperty::kScrollTop | | 1805 (CompositorMutableProperty::kScrollTop | |
| 1807 CompositorMutableProperty::kScrollLeft))) | 1806 CompositorMutableProperty::kScrollLeft))) |
| 1808 return true; | 1807 return true; |
| 1809 | 1808 |
| 1810 if (layer->size().IsEmpty()) | 1809 if (layer->size().IsEmpty()) |
| 1811 return false; | 1810 return false; |
| 1812 | 1811 |
| 1813 bool needs_composited_scrolling = true; | 1812 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( | 1820 layer->GetBackgroundPaintLocation(&main_thread_scrolling_reasons) & |
| 1821 &non_composited_main_thread_scrolling_reasons_) & | |
| 1822 kBackgroundPaintInScrollingContents && | 1821 kBackgroundPaintInScrollingContents && |
| 1823 layer->BackgroundIsKnownToBeOpaqueInRect( | 1822 layer->BackgroundIsKnownToBeOpaqueInRect( |
| 1824 ToLayoutBox(layer->GetLayoutObject()).PaddingBoxRect()) && | 1823 ToLayoutBox(layer->GetLayoutObject()).PaddingBoxRect()) && |
| 1825 !layer->CompositesWithTransform() && !layer->CompositesWithOpacity(); | 1824 !layer->CompositesWithTransform() && !layer->CompositesWithOpacity(); |
| 1826 | 1825 |
| 1827 if (mode == PaintLayerScrollableArea::kConsiderLCDText && | 1826 if (mode == PaintLayerScrollableArea::kConsiderLCDText && |
| 1828 !layer->Compositor()->PreferCompositingToLCDTextEnabled() && | 1827 !layer->Compositor()->PreferCompositingToLCDTextEnabled() && |
| 1829 !background_supports_lcd_text) { | 1828 !background_supports_lcd_text) { |
| 1830 if (layer->CompositesWithOpacity()) { | 1829 if (layer->CompositesWithOpacity()) { |
| 1831 non_composited_main_thread_scrolling_reasons_ |= | 1830 main_thread_scrolling_reasons |= |
| 1832 MainThreadScrollingReason::kHasOpacityAndLCDText; | 1831 MainThreadScrollingReason::kHasOpacityAndLCDText; |
| 1833 } | 1832 } |
| 1834 if (layer->CompositesWithTransform()) { | 1833 if (layer->CompositesWithTransform()) { |
| 1835 non_composited_main_thread_scrolling_reasons_ |= | 1834 main_thread_scrolling_reasons |= |
| 1836 MainThreadScrollingReason::kHasTransformAndLCDText; | 1835 MainThreadScrollingReason::kHasTransformAndLCDText; |
| 1837 } | 1836 } |
| 1838 if (!layer->BackgroundIsKnownToBeOpaqueInRect( | 1837 if (!layer->BackgroundIsKnownToBeOpaqueInRect( |
| 1839 ToLayoutBox(layer->GetLayoutObject()).PaddingBoxRect())) { | 1838 ToLayoutBox(layer->GetLayoutObject()).PaddingBoxRect())) { |
| 1840 non_composited_main_thread_scrolling_reasons_ |= | 1839 main_thread_scrolling_reasons |= |
| 1841 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText; | 1840 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText; |
| 1842 } | 1841 } |
| 1843 | 1842 |
| 1844 needs_composited_scrolling = false; | 1843 needs_composited_scrolling = false; |
| 1845 } | 1844 } |
| 1846 | 1845 |
| 1847 // TODO(schenney) Tests fail if we do not also exclude | 1846 // TODO(schenney) Tests fail if we do not also exclude |
| 1848 // layer->layoutObject().style()->hasBorderDecoration() (missing background | 1847 // layer->layoutObject().style()->hasBorderDecoration() (missing background |
| 1849 // behind dashed borders). Resolve this case, or not, and update this check | 1848 // behind dashed borders). Resolve this case, or not, and update this check |
| 1850 // with the results. | 1849 // with the results. |
| 1851 if (layer->GetLayoutObject().Style()->HasBorderRadius()) { | 1850 if (layer->GetLayoutObject().Style()->HasBorderRadius()) { |
| 1852 non_composited_main_thread_scrolling_reasons_ |= | 1851 main_thread_scrolling_reasons |= |
| 1853 MainThreadScrollingReason::kHasBorderRadius; | 1852 MainThreadScrollingReason::kHasBorderRadius; |
| 1854 needs_composited_scrolling = false; | 1853 needs_composited_scrolling = false; |
| 1855 } | 1854 } |
| 1856 if (layer->GetLayoutObject().HasClip() || | 1855 if (layer->GetLayoutObject().HasClip() || |
| 1857 layer->HasDescendantWithClipPath() || layer->HasAncestorWithClipPath()) { | 1856 layer->HasDescendantWithClipPath() || layer->HasAncestorWithClipPath()) { |
| 1858 non_composited_main_thread_scrolling_reasons_ |= | 1857 main_thread_scrolling_reasons |= |
| 1859 MainThreadScrollingReason::kHasClipRelatedProperty; | 1858 MainThreadScrollingReason::kHasClipRelatedProperty; |
| 1860 needs_composited_scrolling = false; | 1859 needs_composited_scrolling = false; |
| 1861 } | 1860 } |
| 1862 | 1861 |
| 1863 DCHECK(!(non_composited_main_thread_scrolling_reasons_ & | 1862 if (main_thread_scrolling_reasons) { |
| 1864 ~MainThreadScrollingReason::kNonCompositedReasons)); | 1863 AddStyleRelatedMainThreadScrollingReasons(main_thread_scrolling_reasons); |
| 1864 } |
| 1865 |
| 1865 return needs_composited_scrolling; | 1866 return needs_composited_scrolling; |
| 1866 } | 1867 } |
| 1867 | 1868 |
| 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 |
| 1868 void PaintLayerScrollableArea::UpdateNeedsCompositedScrolling( | 1908 void PaintLayerScrollableArea::UpdateNeedsCompositedScrolling( |
| 1869 LCDTextMode mode) { | 1909 LCDTextMode mode) { |
| 1910 // Clear all style related main thread scrolling reasons, if any, |
| 1911 // before calling computeNeedsCompositedScrolling |
| 1912 RemoveStyleRelatedMainThreadScrollingReasons(); |
| 1870 const bool needs_composited_scrolling = | 1913 const bool needs_composited_scrolling = |
| 1871 ComputeNeedsCompositedScrolling(mode, Layer()); | 1914 ComputeNeedsCompositedScrolling(mode, Layer()); |
| 1872 | 1915 |
| 1873 if (static_cast<bool>(needs_composited_scrolling_) != | 1916 if (static_cast<bool>(needs_composited_scrolling_) != |
| 1874 needs_composited_scrolling) { | 1917 needs_composited_scrolling) { |
| 1875 needs_composited_scrolling_ = needs_composited_scrolling; | 1918 needs_composited_scrolling_ = needs_composited_scrolling; |
| 1876 Layer()->DidUpdateNeedsCompositedScrolling(); | 1919 Layer()->DidUpdateNeedsCompositedScrolling(); |
| 1877 } | 1920 } |
| 1878 } | 1921 } |
| 1879 | 1922 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2133 | 2176 |
| 2134 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: | 2177 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: |
| 2135 ClampScrollableAreas() { | 2178 ClampScrollableAreas() { |
| 2136 for (auto& scrollable_area : *needs_clamp_) | 2179 for (auto& scrollable_area : *needs_clamp_) |
| 2137 scrollable_area->ClampScrollOffsetAfterOverflowChange(); | 2180 scrollable_area->ClampScrollOffsetAfterOverflowChange(); |
| 2138 delete needs_clamp_; | 2181 delete needs_clamp_; |
| 2139 needs_clamp_ = nullptr; | 2182 needs_clamp_ = nullptr; |
| 2140 } | 2183 } |
| 2141 | 2184 |
| 2142 } // namespace blink | 2185 } // namespace blink |
| OLD | NEW |