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 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 } | 846 } |
847 | 847 |
848 void PaintLayerScrollableArea::updateAfterStyleChange( | 848 void PaintLayerScrollableArea::updateAfterStyleChange( |
849 const ComputedStyle* oldStyle) { | 849 const ComputedStyle* oldStyle) { |
850 // Don't do this on first style recalc, before layout has ever happened. | 850 // Don't do this on first style recalc, before layout has ever happened. |
851 if (!overflowRect().size().isZero()) { | 851 if (!overflowRect().size().isZero()) { |
852 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || | 852 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || |
853 hasScrollableVerticalOverflow()); | 853 hasScrollableVerticalOverflow()); |
854 } | 854 } |
855 | 855 |
| 856 // Whenever background changes on the scrollable element, the scroll bar |
| 857 // overlay style might need to be changed to have contrast against the |
| 858 // background. |
| 859 // Skip the need scrollbar check, because we dont know do we need a scrollbar |
| 860 // when this method get called. |
| 861 Color oldBackground; |
| 862 if (oldStyle) { |
| 863 oldBackground = oldStyle->visitedDependentColor(CSSPropertyBackgroundColor); |
| 864 } |
| 865 Color newBackground = |
| 866 box().style()->visitedDependentColor(CSSPropertyBackgroundColor); |
| 867 |
| 868 if (newBackground != oldBackground) { |
| 869 recalculateScrollbarOverlayColorTheme(newBackground); |
| 870 } |
| 871 |
856 bool needsHorizontalScrollbar; | 872 bool needsHorizontalScrollbar; |
857 bool needsVerticalScrollbar; | 873 bool needsVerticalScrollbar; |
858 // We add auto scrollbars only during layout to prevent spurious activations. | 874 // We add auto scrollbars only during layout to prevent spurious activations. |
859 computeScrollbarExistence(needsHorizontalScrollbar, needsVerticalScrollbar, | 875 computeScrollbarExistence(needsHorizontalScrollbar, needsVerticalScrollbar, |
860 ForbidAddingAutoBars); | 876 ForbidAddingAutoBars); |
861 | 877 |
862 // Avoid some unnecessary computation if there were and will be no scrollbars. | 878 // Avoid some unnecessary computation if there were and will be no scrollbars. |
863 if (!hasScrollbar() && !needsHorizontalScrollbar && !needsVerticalScrollbar) | 879 if (!hasScrollbar() && !needsHorizontalScrollbar && !needsVerticalScrollbar) |
864 return; | 880 return; |
865 | 881 |
(...skipping 17 matching lines...) Expand all Loading... |
883 // FIXME: Need to detect a swap from custom to native scrollbars (and vice | 899 // FIXME: Need to detect a swap from custom to native scrollbars (and vice |
884 // versa). | 900 // versa). |
885 if (horizontalScrollbar()) | 901 if (horizontalScrollbar()) |
886 horizontalScrollbar()->styleChanged(); | 902 horizontalScrollbar()->styleChanged(); |
887 if (verticalScrollbar()) | 903 if (verticalScrollbar()) |
888 verticalScrollbar()->styleChanged(); | 904 verticalScrollbar()->styleChanged(); |
889 | 905 |
890 updateScrollCornerStyle(); | 906 updateScrollCornerStyle(); |
891 updateResizerAreaSet(); | 907 updateResizerAreaSet(); |
892 updateResizerStyle(); | 908 updateResizerStyle(); |
893 | |
894 // Whenever background changes on the scrollable element, the scroll bar | |
895 // overlay style might need to be changed to have contrast against the | |
896 // background. | |
897 Color oldBackground; | |
898 if (oldStyle) { | |
899 oldBackground = oldStyle->visitedDependentColor(CSSPropertyBackgroundColor); | |
900 } | |
901 Color newBackground = | |
902 box().style()->visitedDependentColor(CSSPropertyBackgroundColor); | |
903 | |
904 if (newBackground != oldBackground) { | |
905 recalculateScrollbarOverlayStyle(newBackground); | |
906 } | |
907 } | 909 } |
908 | 910 |
909 bool PaintLayerScrollableArea::updateAfterCompositingChange() { | 911 bool PaintLayerScrollableArea::updateAfterCompositingChange() { |
910 layer()->updateScrollingStateAfterCompositingChange(); | 912 layer()->updateScrollingStateAfterCompositingChange(); |
911 const bool layersChanged = m_topmostScrollChild != m_nextTopmostScrollChild; | 913 const bool layersChanged = m_topmostScrollChild != m_nextTopmostScrollChild; |
912 m_topmostScrollChild = m_nextTopmostScrollChild; | 914 m_topmostScrollChild = m_nextTopmostScrollChild; |
913 m_nextTopmostScrollChild = nullptr; | 915 m_nextTopmostScrollChild = nullptr; |
914 return layersChanged; | 916 return layersChanged; |
915 } | 917 } |
916 | 918 |
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1947 | 1949 |
1948 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: | 1950 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: |
1949 clampScrollableAreas() { | 1951 clampScrollableAreas() { |
1950 for (auto& scrollableArea : *s_needsClamp) | 1952 for (auto& scrollableArea : *s_needsClamp) |
1951 scrollableArea->clampScrollOffsetsAfterLayout(); | 1953 scrollableArea->clampScrollOffsetsAfterLayout(); |
1952 delete s_needsClamp; | 1954 delete s_needsClamp; |
1953 s_needsClamp = nullptr; | 1955 s_needsClamp = nullptr; |
1954 } | 1956 } |
1955 | 1957 |
1956 } // namespace blink | 1958 } // namespace blink |
OLD | NEW |