| 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 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 bool needsHorizontalScrollbar; | 919 bool needsHorizontalScrollbar; |
| 920 bool needsVerticalScrollbar; | 920 bool needsVerticalScrollbar; |
| 921 // We add auto scrollbars only during layout to prevent spurious activations. | 921 // We add auto scrollbars only during layout to prevent spurious activations. |
| 922 computeScrollbarExistence(needsHorizontalScrollbar, needsVerticalScrollbar, | 922 computeScrollbarExistence(needsHorizontalScrollbar, needsVerticalScrollbar, |
| 923 ForbidAddingAutoBars); | 923 ForbidAddingAutoBars); |
| 924 | 924 |
| 925 // Avoid some unnecessary computation if there were and will be no scrollbars. | 925 // Avoid some unnecessary computation if there were and will be no scrollbars. |
| 926 if (!hasScrollbar() && !needsHorizontalScrollbar && !needsVerticalScrollbar) | 926 if (!hasScrollbar() && !needsHorizontalScrollbar && !needsVerticalScrollbar) |
| 927 return; | 927 return; |
| 928 | 928 |
| 929 setHasHorizontalScrollbar(needsHorizontalScrollbar); | 929 bool horizontalScrollbarChanged = |
| 930 setHasVerticalScrollbar(needsVerticalScrollbar); | 930 setHasHorizontalScrollbar(needsHorizontalScrollbar); |
| 931 bool verticalScrollbarChanged = |
| 932 setHasVerticalScrollbar(needsVerticalScrollbar); |
| 933 |
| 934 if (box().isLayoutBlock() && |
| 935 (horizontalScrollbarChanged || verticalScrollbarChanged)) { |
| 936 toLayoutBlock(box()).scrollbarsChanged( |
| 937 horizontalScrollbarChanged, verticalScrollbarChanged, |
| 938 LayoutBlock::ScrollbarChangeContext::StyleChange); |
| 939 } |
| 931 | 940 |
| 932 // With overflow: scroll, scrollbars are always visible but may be disabled. | 941 // With overflow: scroll, scrollbars are always visible but may be disabled. |
| 933 // When switching to another value, we need to re-enable them (see bug 11985). | 942 // When switching to another value, we need to re-enable them (see bug 11985). |
| 934 if (hasHorizontalScrollbar() && oldStyle && | 943 if (hasHorizontalScrollbar() && oldStyle && |
| 935 oldStyle->overflowX() == OverflowScroll && | 944 oldStyle->overflowX() == OverflowScroll && |
| 936 box().style()->overflowX() != OverflowScroll) { | 945 box().style()->overflowX() != OverflowScroll) { |
| 937 horizontalScrollbar()->setEnabled(true); | 946 horizontalScrollbar()->setEnabled(true); |
| 938 } | 947 } |
| 939 | 948 |
| 940 if (hasVerticalScrollbar() && oldStyle && | 949 if (hasVerticalScrollbar() && oldStyle && |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 frameView->calculateScrollbarModes(hMode, vMode); | 1176 frameView->calculateScrollbarModes(hMode, vMode); |
| 1168 if (hMode == ScrollbarAlwaysOn) | 1177 if (hMode == ScrollbarAlwaysOn) |
| 1169 needsHorizontalScrollbar = true; | 1178 needsHorizontalScrollbar = true; |
| 1170 if (vMode == ScrollbarAlwaysOn) | 1179 if (vMode == ScrollbarAlwaysOn) |
| 1171 needsVerticalScrollbar = true; | 1180 needsVerticalScrollbar = true; |
| 1172 } | 1181 } |
| 1173 } | 1182 } |
| 1174 } | 1183 } |
| 1175 } | 1184 } |
| 1176 | 1185 |
| 1177 void PaintLayerScrollableArea::setHasHorizontalScrollbar(bool hasScrollbar) { | 1186 bool PaintLayerScrollableArea::setHasHorizontalScrollbar(bool hasScrollbar) { |
| 1178 if (FreezeScrollbarsScope::scrollbarsAreFrozen()) | 1187 if (FreezeScrollbarsScope::scrollbarsAreFrozen()) |
| 1179 return; | 1188 return false; |
| 1180 | 1189 |
| 1181 if (hasScrollbar == hasHorizontalScrollbar()) | 1190 if (hasScrollbar == hasHorizontalScrollbar()) |
| 1182 return; | 1191 return false; |
| 1183 | 1192 |
| 1184 setScrollbarNeedsPaintInvalidation(HorizontalScrollbar); | 1193 setScrollbarNeedsPaintInvalidation(HorizontalScrollbar); |
| 1185 | 1194 |
| 1186 m_scrollbarManager.setHasHorizontalScrollbar(hasScrollbar); | 1195 m_scrollbarManager.setHasHorizontalScrollbar(hasScrollbar); |
| 1187 | 1196 |
| 1188 updateScrollOrigin(); | 1197 updateScrollOrigin(); |
| 1189 | 1198 |
| 1190 // Destroying or creating one bar can cause our scrollbar corner to come and | 1199 // Destroying or creating one bar can cause our scrollbar corner to come and |
| 1191 // go. We need to update the opposite scrollbar's style. | 1200 // go. We need to update the opposite scrollbar's style. |
| 1192 if (hasHorizontalScrollbar()) | 1201 if (hasHorizontalScrollbar()) |
| 1193 horizontalScrollbar()->styleChanged(); | 1202 horizontalScrollbar()->styleChanged(); |
| 1194 if (hasVerticalScrollbar()) | 1203 if (hasVerticalScrollbar()) |
| 1195 verticalScrollbar()->styleChanged(); | 1204 verticalScrollbar()->styleChanged(); |
| 1196 | 1205 |
| 1197 setScrollCornerNeedsPaintInvalidation(); | 1206 setScrollCornerNeedsPaintInvalidation(); |
| 1198 | 1207 |
| 1199 // Force an update since we know the scrollbars have changed things. | 1208 // Force an update since we know the scrollbars have changed things. |
| 1200 if (box().document().hasAnnotatedRegions()) | 1209 if (box().document().hasAnnotatedRegions()) |
| 1201 box().document().setAnnotatedRegionsDirty(true); | 1210 box().document().setAnnotatedRegionsDirty(true); |
| 1211 return true; |
| 1202 } | 1212 } |
| 1203 | 1213 |
| 1204 void PaintLayerScrollableArea::setHasVerticalScrollbar(bool hasScrollbar) { | 1214 bool PaintLayerScrollableArea::setHasVerticalScrollbar(bool hasScrollbar) { |
| 1205 if (FreezeScrollbarsScope::scrollbarsAreFrozen()) | 1215 if (FreezeScrollbarsScope::scrollbarsAreFrozen()) |
| 1206 return; | 1216 return false; |
| 1207 | 1217 |
| 1208 if (hasScrollbar == hasVerticalScrollbar()) | 1218 if (hasScrollbar == hasVerticalScrollbar()) |
| 1209 return; | 1219 return false; |
| 1210 | 1220 |
| 1211 setScrollbarNeedsPaintInvalidation(VerticalScrollbar); | 1221 setScrollbarNeedsPaintInvalidation(VerticalScrollbar); |
| 1212 | 1222 |
| 1213 m_scrollbarManager.setHasVerticalScrollbar(hasScrollbar); | 1223 m_scrollbarManager.setHasVerticalScrollbar(hasScrollbar); |
| 1214 | 1224 |
| 1215 updateScrollOrigin(); | 1225 updateScrollOrigin(); |
| 1216 | 1226 |
| 1217 // Destroying or creating one bar can cause our scrollbar corner to come and | 1227 // Destroying or creating one bar can cause our scrollbar corner to come and |
| 1218 // go. We need to update the opposite scrollbar's style. | 1228 // go. We need to update the opposite scrollbar's style. |
| 1219 if (hasHorizontalScrollbar()) | 1229 if (hasHorizontalScrollbar()) |
| 1220 horizontalScrollbar()->styleChanged(); | 1230 horizontalScrollbar()->styleChanged(); |
| 1221 if (hasVerticalScrollbar()) | 1231 if (hasVerticalScrollbar()) |
| 1222 verticalScrollbar()->styleChanged(); | 1232 verticalScrollbar()->styleChanged(); |
| 1223 | 1233 |
| 1224 setScrollCornerNeedsPaintInvalidation(); | 1234 setScrollCornerNeedsPaintInvalidation(); |
| 1225 | 1235 |
| 1226 // Force an update since we know the scrollbars have changed things. | 1236 // Force an update since we know the scrollbars have changed things. |
| 1227 if (box().document().hasAnnotatedRegions()) | 1237 if (box().document().hasAnnotatedRegions()) |
| 1228 box().document().setAnnotatedRegionsDirty(true); | 1238 box().document().setAnnotatedRegionsDirty(true); |
| 1239 return true; |
| 1229 } | 1240 } |
| 1230 | 1241 |
| 1231 int PaintLayerScrollableArea::verticalScrollbarWidth( | 1242 int PaintLayerScrollableArea::verticalScrollbarWidth( |
| 1232 OverlayScrollbarClipBehavior overlayScrollbarClipBehavior) const { | 1243 OverlayScrollbarClipBehavior overlayScrollbarClipBehavior) const { |
| 1233 if (!hasVerticalScrollbar()) | 1244 if (!hasVerticalScrollbar()) |
| 1234 return 0; | 1245 return 0; |
| 1235 if (verticalScrollbar()->isOverlayScrollbar() && | 1246 if (verticalScrollbar()->isOverlayScrollbar() && |
| 1236 (overlayScrollbarClipBehavior == IgnoreOverlayScrollbarSize || | 1247 (overlayScrollbarClipBehavior == IgnoreOverlayScrollbarSize || |
| 1237 !verticalScrollbar()->shouldParticipateInHitTesting())) | 1248 !verticalScrollbar()->shouldParticipateInHitTesting())) |
| 1238 return 0; | 1249 return 0; |
| (...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2002 | 2013 |
| 2003 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: | 2014 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: |
| 2004 clampScrollableAreas() { | 2015 clampScrollableAreas() { |
| 2005 for (auto& scrollableArea : *s_needsClamp) | 2016 for (auto& scrollableArea : *s_needsClamp) |
| 2006 scrollableArea->clampScrollOffsetsAfterLayout(); | 2017 scrollableArea->clampScrollOffsetsAfterLayout(); |
| 2007 delete s_needsClamp; | 2018 delete s_needsClamp; |
| 2008 s_needsClamp = nullptr; | 2019 s_needsClamp = nullptr; |
| 2009 } | 2020 } |
| 2010 | 2021 |
| 2011 } // namespace blink | 2022 } // namespace blink |
| OLD | NEW |