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 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 if (!scrollbars_are_frozen && HasOverlayScrollbars()) { | 904 if (!scrollbars_are_frozen && HasOverlayScrollbars()) { |
905 if (!ScrollSize(kHorizontalScrollbar)) | 905 if (!ScrollSize(kHorizontalScrollbar)) |
906 SetHasHorizontalScrollbar(false); | 906 SetHasHorizontalScrollbar(false); |
907 if (!ScrollSize(kVerticalScrollbar)) | 907 if (!ScrollSize(kVerticalScrollbar)) |
908 SetHasVerticalScrollbar(false); | 908 SetHasVerticalScrollbar(false); |
909 } | 909 } |
910 | 910 |
911 ClampScrollOffsetAfterOverflowChange(); | 911 ClampScrollOffsetAfterOverflowChange(); |
912 | 912 |
913 if (!scrollbars_are_frozen) { | 913 if (!scrollbars_are_frozen) { |
914 UpdateScrollableAreaSet(HasScrollableHorizontalOverflow() || | 914 UpdateScrollableAreaSet(); |
915 HasScrollableVerticalOverflow()); | |
916 } | 915 } |
917 | 916 |
918 DisableCompositingQueryAsserts disabler; | 917 DisableCompositingQueryAsserts disabler; |
919 PositionOverflowControls(); | 918 PositionOverflowControls(); |
920 | 919 |
921 Node* node = Box().GetNode(); | 920 Node* node = Box().GetNode(); |
922 if (isHTMLSelectElement(node)) | 921 if (isHTMLSelectElement(node)) |
923 toHTMLSelectElement(node)->ScrollToOptionAfterLayout(*this); | 922 toHTMLSelectElement(node)->ScrollToOptionAfterLayout(*this); |
924 } | 923 } |
925 | 924 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 int client_width = PixelSnappedClientSize().Width(); | 1006 int client_width = PixelSnappedClientSize().Width(); |
1008 if (NeedsRelayout() && !HadVerticalScrollbarBeforeRelayout()) | 1007 if (NeedsRelayout() && !HadVerticalScrollbarBeforeRelayout()) |
1009 client_width += VerticalScrollbarWidth(); | 1008 client_width += VerticalScrollbarWidth(); |
1010 return PixelSnappedScrollWidth() > client_width; | 1009 return PixelSnappedScrollWidth() > client_width; |
1011 } | 1010 } |
1012 | 1011 |
1013 bool PaintLayerScrollableArea::HasVerticalOverflow() const { | 1012 bool PaintLayerScrollableArea::HasVerticalOverflow() const { |
1014 return PixelSnappedScrollHeight() > PixelSnappedClientSize().Height(); | 1013 return PixelSnappedScrollHeight() > PixelSnappedClientSize().Height(); |
1015 } | 1014 } |
1016 | 1015 |
1017 bool PaintLayerScrollableArea::HasScrollableHorizontalOverflow() const { | |
1018 return HasHorizontalOverflow() && Box().ScrollsOverflowX(); | |
1019 } | |
1020 | |
1021 bool PaintLayerScrollableArea::HasScrollableVerticalOverflow() const { | |
1022 return HasVerticalOverflow() && Box().ScrollsOverflowY(); | |
1023 } | |
1024 | |
1025 // This function returns true if the given box requires overflow scrollbars (as | 1016 // This function returns true if the given box requires overflow scrollbars (as |
1026 // opposed to the 'viewport' scrollbars managed by the PaintLayerCompositor). | 1017 // opposed to the 'viewport' scrollbars managed by the PaintLayerCompositor). |
1027 // FIXME: we should use the same scrolling machinery for both the viewport and | 1018 // FIXME: we should use the same scrolling machinery for both the viewport and |
1028 // overflow. Currently, we need to avoid producing scrollbars here if they'll be | 1019 // overflow. Currently, we need to avoid producing scrollbars here if they'll be |
1029 // handled externally in the RLC. | 1020 // handled externally in the RLC. |
1030 static bool CanHaveOverflowScrollbars(const LayoutBox& box) { | 1021 static bool CanHaveOverflowScrollbars(const LayoutBox& box) { |
1031 return (RuntimeEnabledFeatures::RootLayerScrollingEnabled() || | 1022 return (RuntimeEnabledFeatures::RootLayerScrollingEnabled() || |
1032 !box.IsLayoutView()) && | 1023 !box.IsLayoutView()) && |
1033 box.GetDocument().ViewportDefiningElement() != box.GetNode(); | 1024 box.GetDocument().ViewportDefiningElement() != box.GetNode(); |
1034 } | 1025 } |
1035 | 1026 |
1036 void PaintLayerScrollableArea::UpdateAfterStyleChange( | 1027 void PaintLayerScrollableArea::UpdateAfterStyleChange( |
1037 const ComputedStyle* old_style) { | 1028 const ComputedStyle* old_style) { |
1038 // Don't do this on first style recalc, before layout has ever happened. | 1029 // Don't do this on first style recalc, before layout has ever happened. |
1039 if (!OverflowRect().Size().IsZero()) { | 1030 if (!OverflowRect().Size().IsZero()) { |
1040 UpdateScrollableAreaSet(HasScrollableHorizontalOverflow() || | 1031 UpdateScrollableAreaSet(); |
1041 HasScrollableVerticalOverflow()); | |
1042 } | 1032 } |
1043 | 1033 |
1044 // Whenever background changes on the scrollable element, the scroll bar | 1034 // Whenever background changes on the scrollable element, the scroll bar |
1045 // overlay style might need to be changed to have contrast against the | 1035 // overlay style might need to be changed to have contrast against the |
1046 // background. | 1036 // background. |
1047 // Skip the need scrollbar check, because we dont know do we need a scrollbar | 1037 // Skip the need scrollbar check, because we dont know do we need a scrollbar |
1048 // when this method get called. | 1038 // when this method get called. |
1049 Color old_background; | 1039 Color old_background; |
1050 if (old_style) { | 1040 if (old_style) { |
1051 old_background = | 1041 old_background = |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1822 LayoutRect visible_rect(LayoutPoint(), ClientSize()); | 1812 LayoutRect visible_rect(LayoutPoint(), ClientSize()); |
1823 LayoutRect intersect = | 1813 LayoutRect intersect = |
1824 LocalToAbsolute(Box(), Intersection(visible_rect, local_expose_rect)); | 1814 LocalToAbsolute(Box(), Intersection(visible_rect, local_expose_rect)); |
1825 if (intersect.IsEmpty() && !visible_rect.IsEmpty() && | 1815 if (intersect.IsEmpty() && !visible_rect.IsEmpty() && |
1826 !local_expose_rect.IsEmpty()) { | 1816 !local_expose_rect.IsEmpty()) { |
1827 return LocalToAbsolute(Box(), local_expose_rect); | 1817 return LocalToAbsolute(Box(), local_expose_rect); |
1828 } | 1818 } |
1829 return intersect; | 1819 return intersect; |
1830 } | 1820 } |
1831 | 1821 |
1832 void PaintLayerScrollableArea::UpdateScrollableAreaSet(bool has_overflow) { | 1822 void PaintLayerScrollableArea::UpdateScrollableAreaSet() { |
1833 LocalFrame* frame = Box().GetFrame(); | 1823 LocalFrame* frame = Box().GetFrame(); |
1834 if (!frame) | 1824 if (!frame) |
1835 return; | 1825 return; |
1836 | 1826 |
1837 LocalFrameView* frame_view = frame->View(); | 1827 LocalFrameView* frame_view = frame->View(); |
1838 if (!frame_view) | 1828 if (!frame_view) |
1839 return; | 1829 return; |
1840 | 1830 |
| 1831 bool has_overflow = !Box().Size().IsZero() && |
| 1832 ((HasHorizontalOverflow() && Box().ScrollsOverflowX()) || |
| 1833 (HasVerticalOverflow() && Box().ScrollsOverflowY())); |
| 1834 |
1841 bool is_visible_to_hit_test = Box().Style()->VisibleToHitTesting(); | 1835 bool is_visible_to_hit_test = Box().Style()->VisibleToHitTesting(); |
1842 bool did_scroll_overflow = scrolls_overflow_; | 1836 bool did_scroll_overflow = scrolls_overflow_; |
1843 if (Box().IsLayoutView()) { | 1837 if (Box().IsLayoutView()) { |
1844 ScrollbarMode h_mode; | 1838 ScrollbarMode h_mode; |
1845 ScrollbarMode v_mode; | 1839 ScrollbarMode v_mode; |
1846 ToLayoutView(Box()).CalculateScrollbarModes(h_mode, v_mode); | 1840 ToLayoutView(Box()).CalculateScrollbarModes(h_mode, v_mode); |
1847 if (h_mode == kScrollbarAlwaysOff && v_mode == kScrollbarAlwaysOff) | 1841 if (h_mode == kScrollbarAlwaysOff && v_mode == kScrollbarAlwaysOff) |
1848 has_overflow = false; | 1842 has_overflow = false; |
1849 } | 1843 } |
1850 scrolls_overflow_ = has_overflow && is_visible_to_hit_test; | 1844 scrolls_overflow_ = has_overflow && is_visible_to_hit_test; |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2260 | 2254 |
2261 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: | 2255 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: |
2262 ClampScrollableAreas() { | 2256 ClampScrollableAreas() { |
2263 for (auto& scrollable_area : *needs_clamp_) | 2257 for (auto& scrollable_area : *needs_clamp_) |
2264 scrollable_area->ClampScrollOffsetAfterOverflowChange(); | 2258 scrollable_area->ClampScrollOffsetAfterOverflowChange(); |
2265 delete needs_clamp_; | 2259 delete needs_clamp_; |
2266 needs_clamp_ = nullptr; | 2260 needs_clamp_ = nullptr; |
2267 } | 2261 } |
2268 | 2262 |
2269 } // namespace blink | 2263 } // namespace blink |
OLD | NEW |