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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp

Issue 2417303002: Refactor PLSA scrollbar existence calculation. (Closed)
Patch Set: Sync + rebaseline invalidation tests. Created 4 years, 2 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
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 bool scrollbarsAreFrozen = 660 bool scrollbarsAreFrozen =
661 m_inOverflowRelayout || FreezeScrollbarsScope::scrollbarsAreFrozen(); 661 m_inOverflowRelayout || FreezeScrollbarsScope::scrollbarsAreFrozen();
662 662
663 if (needsScrollbarReconstruction()) { 663 if (needsScrollbarReconstruction()) {
664 setHasHorizontalScrollbar(false); 664 setHasHorizontalScrollbar(false);
665 setHasVerticalScrollbar(false); 665 setHasVerticalScrollbar(false);
666 } 666 }
667 667
668 updateScrollDimensions(); 668 updateScrollDimensions();
669 669
670 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); 670 bool hadHorizontalScrollbar = hasHorizontalScrollbar();
671 bool hasVerticalOverflow = this->hasVerticalOverflow(); 671 bool hadVerticalScrollbar = hasVerticalScrollbar();
672 672
673 // Don't add auto scrollbars if the box contents aren't visible. 673 bool needsHorizontalScrollbar;
674 bool shouldHaveAutoHorizontalScrollbar = 674 bool needsVerticalScrollbar;
675 hasHorizontalOverflow && box().pixelSnappedClientHeight(); 675 computeScrollbarExistence(needsHorizontalScrollbar, needsVerticalScrollbar);
676 bool shouldHaveAutoVerticalScrollbar =
677 hasVerticalOverflow && box().pixelSnappedClientWidth();
678 676
679 { 677 bool horizontalScrollbarShouldChange =
680 // Hits in 678 needsHorizontalScrollbar != hadHorizontalScrollbar;
681 // compositing/overflow/automatically-opt-into-composited-scrolling-after-st yle-change.html. 679 bool verticalScrollbarShouldChange =
682 DisableCompositingQueryAsserts disabler; 680 needsVerticalScrollbar != hadVerticalScrollbar;
683 681
684 // overflow:scroll should just enable/disable.
685 if (box().style()->overflowX() == OverflowScroll && horizontalScrollbar())
686 horizontalScrollbar()->setEnabled(hasHorizontalOverflow);
687 if (box().style()->overflowY() == OverflowScroll && verticalScrollbar())
688 verticalScrollbar()->setEnabled(hasVerticalOverflow);
689 }
690
691 // We need to layout again if scrollbars are added or removed by
692 // overflow:auto, or by changing between native and custom.
693 DCHECK(box().frame()->settings());
694 bool horizontalScrollbarShouldChange =
695 ((box().hasAutoHorizontalScrollbar() &&
696 (hasHorizontalScrollbar() != shouldHaveAutoHorizontalScrollbar)) ||
697 (box().style()->overflowX() == OverflowScroll &&
698 !horizontalScrollbar())) &&
699 (!box().frame()->settings()->hideScrollbars() ||
700 hasHorizontalScrollbar());
701 bool verticalScrollbarShouldChange =
702 ((box().hasAutoVerticalScrollbar() &&
703 (hasVerticalScrollbar() != shouldHaveAutoVerticalScrollbar)) ||
704 (box().style()->overflowY() == OverflowScroll &&
705 !verticalScrollbar())) &&
706 (!box().frame()->settings()->hideScrollbars() || hasVerticalScrollbar());
707 bool scrollbarsWillChange = 682 bool scrollbarsWillChange =
708 !scrollbarsAreFrozen && !visualViewportSuppliesScrollbars() && 683 !scrollbarsAreFrozen &&
709 (horizontalScrollbarShouldChange || verticalScrollbarShouldChange); 684 (horizontalScrollbarShouldChange || verticalScrollbarShouldChange);
710
711 if (scrollbarsWillChange) { 685 if (scrollbarsWillChange) {
712 bool hadHorizontalScrollbar = hasHorizontalScrollbar(); 686 setHasHorizontalScrollbar(needsHorizontalScrollbar);
713 bool hadVerticalScrollbar = hasVerticalScrollbar(); 687 setHasVerticalScrollbar(needsVerticalScrollbar);
714 if (box().hasAutoHorizontalScrollbar())
715 setHasHorizontalScrollbar(shouldHaveAutoHorizontalScrollbar);
716 else if (box().style()->overflowX() == OverflowScroll)
717 setHasHorizontalScrollbar(true);
718 if (box().hasAutoVerticalScrollbar())
719 setHasVerticalScrollbar(shouldHaveAutoVerticalScrollbar);
720 else if (box().style()->overflowY() == OverflowScroll)
721 setHasVerticalScrollbar(true);
722 688
723 if (hasScrollbar()) 689 if (hasScrollbar())
724 updateScrollCornerStyle(); 690 updateScrollCornerStyle();
725 691
726 layer()->updateSelfPaintingLayer(); 692 layer()->updateSelfPaintingLayer();
727 693
728 // Force an update since we know the scrollbars have changed things. 694 // Force an update since we know the scrollbars have changed things.
729 if (box().document().hasAnnotatedRegions()) 695 if (box().document().hasAnnotatedRegions())
730 box().document().setAnnotatedRegionsDirty(true); 696 box().document().setAnnotatedRegionsDirty(true);
731 697
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 if (parent && parent->isFlexibleBox()) 732 if (parent && parent->isFlexibleBox())
767 toLayoutFlexibleBox(parent)->clearCachedMainSizeForChild(box()); 733 toLayoutFlexibleBox(parent)->clearCachedMainSizeForChild(box());
768 } 734 }
769 } 735 }
770 736
771 { 737 {
772 // Hits in 738 // Hits in
773 // compositing/overflow/automatically-opt-into-composited-scrolling-after-st yle-change.html. 739 // compositing/overflow/automatically-opt-into-composited-scrolling-after-st yle-change.html.
774 DisableCompositingQueryAsserts disabler; 740 DisableCompositingQueryAsserts disabler;
775 741
742 // overflow:scroll should just enable/disable.
743 if (box().style()->overflowX() == OverflowScroll && horizontalScrollbar())
744 horizontalScrollbar()->setEnabled(hasHorizontalOverflow());
745 if (box().style()->overflowY() == OverflowScroll && verticalScrollbar())
746 verticalScrollbar()->setEnabled(hasVerticalOverflow());
747
776 // Set up the range (and page step/line step). 748 // Set up the range (and page step/line step).
777 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { 749 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) {
778 int clientWidth = box().pixelSnappedClientWidth(); 750 int clientWidth = box().pixelSnappedClientWidth();
779 horizontalScrollbar->setProportion(clientWidth, 751 horizontalScrollbar->setProportion(clientWidth,
780 overflowRect().width().toInt()); 752 overflowRect().width().toInt());
781 } 753 }
782 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) { 754 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) {
783 int clientHeight = box().pixelSnappedClientHeight(); 755 int clientHeight = box().pixelSnappedClientHeight();
784 verticalScrollbar->setProportion(clientHeight, 756 verticalScrollbar->setProportion(clientHeight,
785 overflowRect().height().toInt()); 757 overflowRect().height().toInt());
786 } 758 }
787 } 759 }
788 760
789 if (!scrollbarsAreFrozen && hasOverlayScrollbars()) { 761 if (!scrollbarsAreFrozen && hasOverlayScrollbars()) {
790 if (!scrollSize(HorizontalScrollbar)) 762 if (!scrollSize(HorizontalScrollbar))
791 setHasHorizontalScrollbar(false); 763 setHasHorizontalScrollbar(false);
792 if (!scrollSize(VerticalScrollbar)) 764 if (!scrollSize(VerticalScrollbar))
793 setHasVerticalScrollbar(false); 765 setHasVerticalScrollbar(false);
794 } 766 }
795 767
796 clampScrollOffsetsAfterLayout(); 768 clampScrollOffsetsAfterLayout();
797 769
798 if (!scrollbarsAreFrozen) { 770 if (!scrollbarsAreFrozen) {
799 bool hasOverflow = 771 updateScrollableAreaSet(hasScrollableHorizontalOverflow() ||
800 hasScrollableHorizontalOverflow() || hasScrollableVerticalOverflow(); 772 hasScrollableVerticalOverflow());
801 updateScrollableAreaSet(hasOverflow);
802 } 773 }
803 774
804 DisableCompositingQueryAsserts disabler; 775 DisableCompositingQueryAsserts disabler;
805 positionOverflowControls(); 776 positionOverflowControls();
806 } 777 }
807 778
808 void PaintLayerScrollableArea::clampScrollOffsetsAfterLayout() { 779 void PaintLayerScrollableArea::clampScrollOffsetsAfterLayout() {
809 // If a vertical scrollbar was removed, the min/max scroll offsets may have 780 // If a vertical scrollbar was removed, the min/max scroll offsets may have
810 // changed, so the scroll offsets needs to be clamped. If the scroll offset 781 // changed, so the scroll offsets needs to be clamped. If the scroll offset
811 // did not change, but the scroll origin *did* change, we still need to notify 782 // did not change, but the scroll origin *did* change, we still need to notify
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 } 832 }
862 833
863 bool PaintLayerScrollableArea::hasScrollableHorizontalOverflow() const { 834 bool PaintLayerScrollableArea::hasScrollableHorizontalOverflow() const {
864 return hasHorizontalOverflow() && box().scrollsOverflowX(); 835 return hasHorizontalOverflow() && box().scrollsOverflowX();
865 } 836 }
866 837
867 bool PaintLayerScrollableArea::hasScrollableVerticalOverflow() const { 838 bool PaintLayerScrollableArea::hasScrollableVerticalOverflow() const {
868 return hasVerticalOverflow() && box().scrollsOverflowY(); 839 return hasVerticalOverflow() && box().scrollsOverflowY();
869 } 840 }
870 841
871 static bool overflowRequiresScrollbar(EOverflow overflow) {
872 return overflow == OverflowScroll;
873 }
874
875 static bool overflowDefinesAutomaticScrollbar(EOverflow overflow) {
876 return overflow == OverflowAuto || overflow == OverflowOverlay;
877 }
878
879 // This function returns true if the given box requires overflow scrollbars (as 842 // This function returns true if the given box requires overflow scrollbars (as
880 // opposed to the 'viewport' scrollbars managed by the PaintLayerCompositor). 843 // opposed to the 'viewport' scrollbars managed by the PaintLayerCompositor).
881 // FIXME: we should use the same scrolling machinery for both the viewport and 844 // FIXME: we should use the same scrolling machinery for both the viewport and
882 // overflow. Currently, we need to avoid producing scrollbars here if they'll be 845 // overflow. Currently, we need to avoid producing scrollbars here if they'll be
883 // handled externally in the RLC. 846 // handled externally in the RLC.
884 static bool canHaveOverflowScrollbars(const LayoutBox& box) { 847 static bool canHaveOverflowScrollbars(const LayoutBox& box) {
885 return (RuntimeEnabledFeatures::rootLayerScrollingEnabled() || 848 return (RuntimeEnabledFeatures::rootLayerScrollingEnabled() ||
886 !box.isLayoutView()) && 849 !box.isLayoutView()) &&
887 box.document().viewportDefiningElement() != box.node(); 850 box.document().viewportDefiningElement() != box.node();
888 } 851 }
889 852
890 void PaintLayerScrollableArea::updateAfterStyleChange( 853 void PaintLayerScrollableArea::updateAfterStyleChange(
891 const ComputedStyle* oldStyle) { 854 const ComputedStyle* oldStyle) {
892 // Don't do this on first style recalc, before layout has ever happened. 855 // Don't do this on first style recalc, before layout has ever happened.
893 if (!overflowRect().size().isZero()) 856 if (!overflowRect().size().isZero()) {
894 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || 857 updateScrollableAreaSet(hasScrollableHorizontalOverflow() ||
895 hasScrollableVerticalOverflow()); 858 hasScrollableVerticalOverflow());
896
897 if (!canHaveOverflowScrollbars(box()))
898 return;
899
900 // Avoid drawing two sets of scrollbars when one is provided by the visual
901 // viewport.
902 if (visualViewportSuppliesScrollbars()) {
903 setHasHorizontalScrollbar(false);
904 setHasVerticalScrollbar(false);
905 return;
906 } 859 }
907 860
908 EOverflow overflowX = box().style()->overflowX(); 861 bool needsHorizontalScrollbar;
909 EOverflow overflowY = box().style()->overflowY(); 862 bool needsVerticalScrollbar;
863 // We add auto scrollbars only during layout to prevent spurious activations.
864 computeScrollbarExistence(needsHorizontalScrollbar, needsVerticalScrollbar,
865 ForbidAddingAutoBars);
910 866
911 bool needsHorizontalScrollbar = 867 // Avoid some unnecessary computation if there were and will be no scrollbars.
912 (hasHorizontalScrollbar() && 868 if (!hasScrollbar() && !needsHorizontalScrollbar && !needsVerticalScrollbar)
913 overflowDefinesAutomaticScrollbar(overflowX)) || 869 return;
914 overflowRequiresScrollbar(overflowX);
915 bool needsVerticalScrollbar =
916 (hasVerticalScrollbar() &&
917 overflowDefinesAutomaticScrollbar(overflowY)) ||
918 overflowRequiresScrollbar(overflowY);
919
920 // Look for the scrollbarModes and reset the needs Horizontal & vertical
921 // Scrollbar values based on scrollbarModes, as during force style change
922 // StyleResolver::styleForDocument returns documentStyle with no overflow
923 // values, due to which we are destorying the scrollbars that was already
924 // present.
925 if (box().isLayoutView()) {
926 if (LocalFrame* frame = box().frame()) {
927 if (FrameView* frameView = frame->view()) {
928 ScrollbarMode hMode;
929 ScrollbarMode vMode;
930 frameView->calculateScrollbarModes(hMode, vMode);
931 if (hMode == ScrollbarAlwaysOn && !needsHorizontalScrollbar)
932 needsHorizontalScrollbar = true;
933 if (vMode == ScrollbarAlwaysOn && !needsVerticalScrollbar)
934 needsVerticalScrollbar = true;
935 }
936 }
937 }
938 870
939 setHasHorizontalScrollbar(needsHorizontalScrollbar); 871 setHasHorizontalScrollbar(needsHorizontalScrollbar);
940 setHasVerticalScrollbar(needsVerticalScrollbar); 872 setHasVerticalScrollbar(needsVerticalScrollbar);
941 873
942 // With overflow: scroll, scrollbars are always visible but may be disabled. 874 // With overflow: scroll, scrollbars are always visible but may be disabled.
943 // When switching to another value, we need to re-enable them (see bug 11985). 875 // When switching to another value, we need to re-enable them (see bug 11985).
944 if (hasHorizontalScrollbar() && oldStyle && 876 if (hasHorizontalScrollbar() && oldStyle &&
945 oldStyle->overflowX() == OverflowScroll && overflowX != OverflowScroll) { 877 oldStyle->overflowX() == OverflowScroll &&
878 box().style()->overflowX() != OverflowScroll) {
946 horizontalScrollbar()->setEnabled(true); 879 horizontalScrollbar()->setEnabled(true);
947 } 880 }
948 881
949 if (hasVerticalScrollbar() && oldStyle && 882 if (hasVerticalScrollbar() && oldStyle &&
950 oldStyle->overflowY() == OverflowScroll && overflowY != OverflowScroll) { 883 oldStyle->overflowY() == OverflowScroll &&
884 box().style()->overflowY() != OverflowScroll) {
951 verticalScrollbar()->setEnabled(true); 885 verticalScrollbar()->setEnabled(true);
952 } 886 }
953 887
954 // FIXME: Need to detect a swap from custom to native scrollbars (and vice 888 // FIXME: Need to detect a swap from custom to native scrollbars (and vice
955 // versa). 889 // versa).
956 if (horizontalScrollbar()) 890 if (horizontalScrollbar())
957 horizontalScrollbar()->styleChanged(); 891 horizontalScrollbar()->styleChanged();
958 if (verticalScrollbar()) 892 if (verticalScrollbar())
959 verticalScrollbar()->styleChanged(); 893 verticalScrollbar()->styleChanged();
960 894
(...skipping 30 matching lines...) Expand all
991 int clientWidth = box().pixelSnappedClientWidth(); 925 int clientWidth = box().pixelSnappedClientWidth();
992 horizontalScrollbar->setProportion(clientWidth, 926 horizontalScrollbar->setProportion(clientWidth,
993 overflowRect().width().toInt()); 927 overflowRect().width().toInt());
994 } 928 }
995 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) { 929 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) {
996 int clientHeight = box().pixelSnappedClientHeight(); 930 int clientHeight = box().pixelSnappedClientHeight();
997 verticalScrollbar->setProportion(clientHeight, 931 verticalScrollbar->setProportion(clientHeight,
998 overflowRect().height().toInt()); 932 overflowRect().height().toInt());
999 } 933 }
1000 934
1001 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); 935 bool needsHorizontalScrollbar;
1002 bool hasVerticalOverflow = this->hasVerticalOverflow(); 936 bool needsVerticalScrollbar;
1003 bool autoHorizontalScrollbarChanged = 937 computeScrollbarExistence(needsHorizontalScrollbar, needsVerticalScrollbar);
1004 box().hasAutoHorizontalScrollbar() && 938
1005 (hasHorizontalScrollbar() != hasHorizontalOverflow); 939 bool horizontalScrollbarShouldChange =
1006 bool autoVerticalScrollbarChanged = 940 needsHorizontalScrollbar != hasHorizontalScrollbar();
1007 box().hasAutoVerticalScrollbar() && 941 bool verticalScrollbarShouldChange =
1008 (hasVerticalScrollbar() != hasVerticalOverflow); 942 needsVerticalScrollbar != hasVerticalScrollbar();
1009 if (autoHorizontalScrollbarChanged || autoVerticalScrollbarChanged) 943
944 if ((box().hasAutoHorizontalScrollbar() && horizontalScrollbarShouldChange) ||
945 (box().hasAutoVerticalScrollbar() && verticalScrollbarShouldChange)) {
1010 box().setNeedsLayoutAndFullPaintInvalidation( 946 box().setNeedsLayoutAndFullPaintInvalidation(
1011 LayoutInvalidationReason::Unknown); 947 LayoutInvalidationReason::Unknown);
948 }
1012 } 949 }
1013 950
1014 IntRect PaintLayerScrollableArea::rectForHorizontalScrollbar( 951 IntRect PaintLayerScrollableArea::rectForHorizontalScrollbar(
1015 const IntRect& borderBoxRect) const { 952 const IntRect& borderBoxRect) const {
1016 if (!hasHorizontalScrollbar()) 953 if (!hasHorizontalScrollbar())
1017 return IntRect(); 954 return IntRect();
1018 955
1019 const IntRect& scrollCorner = scrollCornerRect(); 956 const IntRect& scrollCorner = scrollCornerRect();
1020 957
1021 return IntRect(horizontalScrollbarStart(borderBoxRect.x()), 958 return IntRect(horizontalScrollbarStart(borderBoxRect.x()),
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 if (actualLayoutObject != 1071 if (actualLayoutObject !=
1135 toLayoutScrollbar(verticalScrollbar())->owningLayoutObject()) 1072 toLayoutScrollbar(verticalScrollbar())->owningLayoutObject())
1136 didCustomScrollbarOwnerChanged = true; 1073 didCustomScrollbarOwnerChanged = true;
1137 } 1074 }
1138 1075
1139 return hasAnyScrollbar && 1076 return hasAnyScrollbar &&
1140 ((shouldUseCustom != hasCustom) || 1077 ((shouldUseCustom != hasCustom) ||
1141 (shouldUseCustom && didCustomScrollbarOwnerChanged)); 1078 (shouldUseCustom && didCustomScrollbarOwnerChanged));
1142 } 1079 }
1143 1080
1081 void PaintLayerScrollableArea::computeScrollbarExistence(
1082 bool& needsHorizontalScrollbar,
1083 bool& needsVerticalScrollbar,
1084 ComputeScrollbarExistenceOption option) const {
1085 // Scrollbars may be hidden or provided by visual viewport or frame instead.
1086 DCHECK(box().frame()->settings());
1087 if (visualViewportSuppliesScrollbars() || !canHaveOverflowScrollbars(box()) ||
1088 box().frame()->settings()->hideScrollbars()) {
1089 needsHorizontalScrollbar = false;
1090 needsVerticalScrollbar = false;
1091 return;
1092 }
1093
1094 needsHorizontalScrollbar = box().scrollsOverflowX();
1095 needsVerticalScrollbar = box().scrollsOverflowY();
1096
1097 // Don't add auto scrollbars if the box contents aren't visible.
1098 if (box().hasAutoHorizontalScrollbar()) {
1099 if (option == ForbidAddingAutoBars)
1100 needsHorizontalScrollbar &= hasHorizontalScrollbar();
1101 needsHorizontalScrollbar &= box().isRooted() &&
1102 this->hasHorizontalOverflow() &&
1103 box().pixelSnappedClientHeight();
1104 }
1105
1106 if (box().hasAutoVerticalScrollbar()) {
1107 if (option == ForbidAddingAutoBars)
1108 needsVerticalScrollbar &= hasVerticalScrollbar();
1109 needsVerticalScrollbar &= box().isRooted() && this->hasVerticalOverflow() &&
1110 box().pixelSnappedClientWidth();
1111 }
1112
1113 // Look for the scrollbarModes and reset the needs Horizontal & vertical
1114 // Scrollbar values based on scrollbarModes, as during force style change
1115 // StyleResolver::styleForDocument returns documentStyle with no overflow
1116 // values, due to which we are destroying the scrollbars that were already
1117 // present.
1118 if (box().isLayoutView()) {
1119 if (LocalFrame* frame = box().frame()) {
1120 if (FrameView* frameView = frame->view()) {
1121 ScrollbarMode hMode;
1122 ScrollbarMode vMode;
1123 frameView->calculateScrollbarModes(hMode, vMode);
1124 if (hMode == ScrollbarAlwaysOn)
1125 needsHorizontalScrollbar = true;
1126 if (vMode == ScrollbarAlwaysOn)
1127 needsVerticalScrollbar = true;
1128 }
1129 }
1130 }
1131 }
1132
1144 void PaintLayerScrollableArea::setHasHorizontalScrollbar(bool hasScrollbar) { 1133 void PaintLayerScrollableArea::setHasHorizontalScrollbar(bool hasScrollbar) {
1145 if (FreezeScrollbarsScope::scrollbarsAreFrozen()) 1134 if (FreezeScrollbarsScope::scrollbarsAreFrozen())
1146 return; 1135 return;
1147 1136
1148 DCHECK(box().frame()->settings());
1149 if (box().frame()->settings()->hideScrollbars())
1150 hasScrollbar = false;
1151
1152 if (hasScrollbar == hasHorizontalScrollbar()) 1137 if (hasScrollbar == hasHorizontalScrollbar())
1153 return; 1138 return;
1154 1139
1155 setScrollbarNeedsPaintInvalidation(HorizontalScrollbar); 1140 setScrollbarNeedsPaintInvalidation(HorizontalScrollbar);
1156 1141
1157 m_scrollbarManager.setHasHorizontalScrollbar(hasScrollbar); 1142 m_scrollbarManager.setHasHorizontalScrollbar(hasScrollbar);
1158 1143
1159 updateScrollOrigin(); 1144 updateScrollOrigin();
1160 1145
1161 // Destroying or creating one bar can cause our scrollbar corner to come and 1146 // Destroying or creating one bar can cause our scrollbar corner to come and
1162 // go. We need to update the opposite scrollbar's style. 1147 // go. We need to update the opposite scrollbar's style.
1163 if (hasHorizontalScrollbar()) 1148 if (hasHorizontalScrollbar())
1164 horizontalScrollbar()->styleChanged(); 1149 horizontalScrollbar()->styleChanged();
1165 if (hasVerticalScrollbar()) 1150 if (hasVerticalScrollbar())
1166 verticalScrollbar()->styleChanged(); 1151 verticalScrollbar()->styleChanged();
1167 1152
1168 setScrollCornerNeedsPaintInvalidation(); 1153 setScrollCornerNeedsPaintInvalidation();
1169 1154
1170 // Force an update since we know the scrollbars have changed things. 1155 // Force an update since we know the scrollbars have changed things.
1171 if (box().document().hasAnnotatedRegions()) 1156 if (box().document().hasAnnotatedRegions())
1172 box().document().setAnnotatedRegionsDirty(true); 1157 box().document().setAnnotatedRegionsDirty(true);
1173 } 1158 }
1174 1159
1175 void PaintLayerScrollableArea::setHasVerticalScrollbar(bool hasScrollbar) { 1160 void PaintLayerScrollableArea::setHasVerticalScrollbar(bool hasScrollbar) {
1176 if (FreezeScrollbarsScope::scrollbarsAreFrozen()) 1161 if (FreezeScrollbarsScope::scrollbarsAreFrozen())
1177 return; 1162 return;
1178 1163
1179 DCHECK(box().frame()->settings());
1180 if (box().frame()->settings()->hideScrollbars())
1181 hasScrollbar = false;
1182
1183 if (hasScrollbar == hasVerticalScrollbar()) 1164 if (hasScrollbar == hasVerticalScrollbar())
1184 return; 1165 return;
1185 1166
1186 setScrollbarNeedsPaintInvalidation(VerticalScrollbar); 1167 setScrollbarNeedsPaintInvalidation(VerticalScrollbar);
1187 1168
1188 m_scrollbarManager.setHasVerticalScrollbar(hasScrollbar); 1169 m_scrollbarManager.setHasVerticalScrollbar(hasScrollbar);
1189 1170
1190 updateScrollOrigin(); 1171 updateScrollOrigin();
1191 1172
1192 // Destroying or creating one bar can cause our scrollbar corner to come and 1173 // Destroying or creating one bar can cause our scrollbar corner to come and
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1983 1964
1984 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: 1965 void PaintLayerScrollableArea::DelayScrollOffsetClampScope::
1985 clampScrollableAreas() { 1966 clampScrollableAreas() {
1986 for (auto& scrollableArea : *s_needsClamp) 1967 for (auto& scrollableArea : *s_needsClamp)
1987 scrollableArea->clampScrollOffsetsAfterLayout(); 1968 scrollableArea->clampScrollOffsetsAfterLayout();
1988 delete s_needsClamp; 1969 delete s_needsClamp;
1989 s_needsClamp = nullptr; 1970 s_needsClamp = nullptr;
1990 } 1971 }
1991 1972
1992 } // namespace blink 1973 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698