OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
reserved. |
3 * | 3 * |
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
5 * | 5 * |
6 * Other contributors: | 6 * Other contributors: |
7 * Robert O'Callahan <roc+@cs.cmu.edu> | 7 * Robert O'Callahan <roc+@cs.cmu.edu> |
8 * David Baron <dbaron@fas.harvard.edu> | 8 * David Baron <dbaron@fas.harvard.edu> |
9 * Christian Biesinger <cbiesinger@gmail.com> | 9 * Christian Biesinger <cbiesinger@gmail.com> |
10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 return -scrollOrigin() + (contentSize - visibleSize); | 483 return -scrollOrigin() + (contentSize - visibleSize); |
484 } | 484 } |
485 | 485 |
486 IntRect PaintLayerScrollableArea::visibleContentRect( | 486 IntRect PaintLayerScrollableArea::visibleContentRect( |
487 IncludeScrollbarsInRect scrollbarInclusion) const { | 487 IncludeScrollbarsInRect scrollbarInclusion) const { |
488 int verticalScrollbarWidth = 0; | 488 int verticalScrollbarWidth = 0; |
489 int horizontalScrollbarHeight = 0; | 489 int horizontalScrollbarHeight = 0; |
490 if (scrollbarInclusion == IncludeScrollbars) { | 490 if (scrollbarInclusion == IncludeScrollbars) { |
491 verticalScrollbarWidth = | 491 verticalScrollbarWidth = |
492 (verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar()) | 492 (verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar()) |
493 ? verticalScrollbar()->width() | 493 ? verticalScrollbar()->scrollbarThickness() |
494 : 0; | 494 : 0; |
495 horizontalScrollbarHeight = | 495 horizontalScrollbarHeight = |
496 (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar()) | 496 (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar()) |
497 ? horizontalScrollbar()->height() | 497 ? horizontalScrollbar()->scrollbarThickness() |
498 : 0; | 498 : 0; |
499 } | 499 } |
500 | 500 |
501 return IntRect( | 501 return IntRect( |
502 IntPoint(scrollXOffset(), scrollYOffset()), | 502 IntPoint(scrollXOffset(), scrollYOffset()), |
503 IntSize(max(0, layer()->size().width() - verticalScrollbarWidth), | 503 IntSize(max(0, layer()->size().width() - verticalScrollbarWidth), |
504 max(0, layer()->size().height() - horizontalScrollbarHeight))); | 504 max(0, layer()->size().height() - horizontalScrollbarHeight))); |
505 } | 505 } |
506 | 506 |
507 int PaintLayerScrollableArea::visibleHeight() const { | 507 int PaintLayerScrollableArea::visibleHeight() const { |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 | 995 |
996 IntRect PaintLayerScrollableArea::rectForHorizontalScrollbar( | 996 IntRect PaintLayerScrollableArea::rectForHorizontalScrollbar( |
997 const IntRect& borderBoxRect) const { | 997 const IntRect& borderBoxRect) const { |
998 if (!hasHorizontalScrollbar()) | 998 if (!hasHorizontalScrollbar()) |
999 return IntRect(); | 999 return IntRect(); |
1000 | 1000 |
1001 const IntRect& scrollCorner = scrollCornerRect(); | 1001 const IntRect& scrollCorner = scrollCornerRect(); |
1002 | 1002 |
1003 return IntRect(horizontalScrollbarStart(borderBoxRect.x()), | 1003 return IntRect(horizontalScrollbarStart(borderBoxRect.x()), |
1004 borderBoxRect.maxY() - box().borderBottom() - | 1004 borderBoxRect.maxY() - box().borderBottom() - |
1005 horizontalScrollbar()->height(), | 1005 horizontalScrollbar()->scrollbarThickness(), |
1006 borderBoxRect.width() - | 1006 borderBoxRect.width() - |
1007 (box().borderLeft() + box().borderRight()) - | 1007 (box().borderLeft() + box().borderRight()) - |
1008 scrollCorner.width(), | 1008 scrollCorner.width(), |
1009 horizontalScrollbar()->scrollbarThickness()); | 1009 horizontalScrollbar()->scrollbarThickness()); |
1010 } | 1010 } |
1011 | 1011 |
1012 IntRect PaintLayerScrollableArea::rectForVerticalScrollbar( | 1012 IntRect PaintLayerScrollableArea::rectForVerticalScrollbar( |
1013 const IntRect& borderBoxRect) const { | 1013 const IntRect& borderBoxRect) const { |
1014 if (!hasVerticalScrollbar()) | 1014 if (!hasVerticalScrollbar()) |
1015 return IntRect(); | 1015 return IntRect(); |
1016 | 1016 |
1017 const IntRect& scrollCorner = scrollCornerRect(); | 1017 const IntRect& scrollCorner = scrollCornerRect(); |
1018 | 1018 |
1019 return IntRect( | 1019 return IntRect( |
1020 verticalScrollbarStart(borderBoxRect.x(), borderBoxRect.maxX()), | 1020 verticalScrollbarStart(borderBoxRect.x(), borderBoxRect.maxX()), |
1021 borderBoxRect.y() + box().borderTop(), | 1021 borderBoxRect.y() + box().borderTop(), |
1022 verticalScrollbar()->scrollbarThickness(), | 1022 verticalScrollbar()->scrollbarThickness(), |
1023 borderBoxRect.height() - (box().borderTop() + box().borderBottom()) - | 1023 borderBoxRect.height() - (box().borderTop() + box().borderBottom()) - |
1024 scrollCorner.height()); | 1024 scrollCorner.height()); |
1025 } | 1025 } |
1026 | 1026 |
1027 int PaintLayerScrollableArea::verticalScrollbarStart(int minX, int maxX) const { | 1027 int PaintLayerScrollableArea::verticalScrollbarStart(int minX, int maxX) const { |
1028 if (box().shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 1028 if (box().shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
1029 return minX + box().borderLeft(); | 1029 return minX + box().borderLeft(); |
1030 return maxX - box().borderRight() - verticalScrollbar()->width(); | 1030 return maxX - box().borderRight() - verticalScrollbar()->scrollbarThickness(); |
1031 } | 1031 } |
1032 | 1032 |
1033 int PaintLayerScrollableArea::horizontalScrollbarStart(int minX) const { | 1033 int PaintLayerScrollableArea::horizontalScrollbarStart(int minX) const { |
1034 int x = minX + box().borderLeft(); | 1034 int x = minX + box().borderLeft(); |
1035 if (box().shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 1035 if (box().shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
1036 x += hasVerticalScrollbar() | 1036 x += hasVerticalScrollbar() |
1037 ? verticalScrollbar()->width() | 1037 ? verticalScrollbar()->scrollbarThickness() |
1038 : resizerCornerRect(box().pixelSnappedBorderBoxRect(), | 1038 : resizerCornerRect(box().pixelSnappedBorderBoxRect(), |
1039 ResizerForPointer) | 1039 ResizerForPointer) |
1040 .width(); | 1040 .width(); |
1041 return x; | 1041 return x; |
1042 } | 1042 } |
1043 | 1043 |
1044 IntSize PaintLayerScrollableArea::scrollbarOffset( | 1044 IntSize PaintLayerScrollableArea::scrollbarOffset( |
1045 const Scrollbar& scrollbar) const { | 1045 const Scrollbar& scrollbar) const { |
1046 if (&scrollbar == verticalScrollbar()) | 1046 if (&scrollbar == verticalScrollbar()) |
1047 return IntSize(verticalScrollbarStart(0, box().size().width().toInt()), | 1047 return IntSize(verticalScrollbarStart(0, box().size().width().toInt()), |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 } | 1184 } |
1185 | 1185 |
1186 int PaintLayerScrollableArea::verticalScrollbarWidth( | 1186 int PaintLayerScrollableArea::verticalScrollbarWidth( |
1187 OverlayScrollbarClipBehavior overlayScrollbarClipBehavior) const { | 1187 OverlayScrollbarClipBehavior overlayScrollbarClipBehavior) const { |
1188 if (!hasVerticalScrollbar()) | 1188 if (!hasVerticalScrollbar()) |
1189 return 0; | 1189 return 0; |
1190 if (verticalScrollbar()->isOverlayScrollbar() && | 1190 if (verticalScrollbar()->isOverlayScrollbar() && |
1191 (overlayScrollbarClipBehavior == IgnoreOverlayScrollbarSize || | 1191 (overlayScrollbarClipBehavior == IgnoreOverlayScrollbarSize || |
1192 !verticalScrollbar()->shouldParticipateInHitTesting())) | 1192 !verticalScrollbar()->shouldParticipateInHitTesting())) |
1193 return 0; | 1193 return 0; |
1194 return verticalScrollbar()->width(); | 1194 return verticalScrollbar()->scrollbarThickness(); |
1195 } | 1195 } |
1196 | 1196 |
1197 int PaintLayerScrollableArea::horizontalScrollbarHeight( | 1197 int PaintLayerScrollableArea::horizontalScrollbarHeight( |
1198 OverlayScrollbarClipBehavior overlayScrollbarClipBehavior) const { | 1198 OverlayScrollbarClipBehavior overlayScrollbarClipBehavior) const { |
1199 if (!hasHorizontalScrollbar()) | 1199 if (!hasHorizontalScrollbar()) |
1200 return 0; | 1200 return 0; |
1201 if (horizontalScrollbar()->isOverlayScrollbar() && | 1201 if (horizontalScrollbar()->isOverlayScrollbar() && |
1202 (overlayScrollbarClipBehavior == IgnoreOverlayScrollbarSize || | 1202 (overlayScrollbarClipBehavior == IgnoreOverlayScrollbarSize || |
1203 !horizontalScrollbar()->shouldParticipateInHitTesting())) | 1203 !horizontalScrollbar()->shouldParticipateInHitTesting())) |
1204 return 0; | 1204 return 0; |
1205 return horizontalScrollbar()->height(); | 1205 return horizontalScrollbar()->scrollbarThickness(); |
1206 } | 1206 } |
1207 | 1207 |
1208 void PaintLayerScrollableArea::positionOverflowControls() { | 1208 void PaintLayerScrollableArea::positionOverflowControls() { |
1209 if (!hasScrollbar() && !box().canResize()) | 1209 if (!hasScrollbar() && !box().canResize()) |
1210 return; | 1210 return; |
1211 | 1211 |
1212 const IntRect borderBox = box().pixelSnappedBorderBoxRect(); | 1212 const IntRect borderBox = box().pixelSnappedBorderBoxRect(); |
1213 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) | 1213 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) |
1214 verticalScrollbar->setFrameRect(rectForVerticalScrollbar(borderBox)); | 1214 verticalScrollbar->setFrameRect(rectForVerticalScrollbar(borderBox)); |
1215 | 1215 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1267 if (box().style()->resize() != RESIZE_NONE) { | 1267 if (box().style()->resize() != RESIZE_NONE) { |
1268 resizeControlRect = | 1268 resizeControlRect = |
1269 resizerCornerRect(box().pixelSnappedBorderBoxRect(), ResizerForPointer); | 1269 resizerCornerRect(box().pixelSnappedBorderBoxRect(), ResizerForPointer); |
1270 if (resizeControlRect.contains(localPoint)) | 1270 if (resizeControlRect.contains(localPoint)) |
1271 return true; | 1271 return true; |
1272 } | 1272 } |
1273 | 1273 |
1274 int resizeControlSize = max(resizeControlRect.height(), 0); | 1274 int resizeControlSize = max(resizeControlRect.height(), 0); |
1275 if (hasVerticalScrollbar() && | 1275 if (hasVerticalScrollbar() && |
1276 verticalScrollbar()->shouldParticipateInHitTesting()) { | 1276 verticalScrollbar()->shouldParticipateInHitTesting()) { |
1277 LayoutRect vBarRect( | 1277 LayoutRect vBarRect(verticalScrollbarStart(0, box().size().width().toInt()), |
1278 verticalScrollbarStart(0, box().size().width().toInt()), | 1278 box().borderTop(), |
1279 box().borderTop(), verticalScrollbar()->width(), | 1279 verticalScrollbar()->scrollbarThickness(), |
1280 box().size().height().toInt() - | 1280 box().size().height().toInt() - |
1281 (box().borderTop() + box().borderBottom()) - | 1281 (box().borderTop() + box().borderBottom()) - |
1282 (hasHorizontalScrollbar() ? horizontalScrollbar()->height() | 1282 (hasHorizontalScrollbar() |
1283 : resizeControlSize)); | 1283 ? horizontalScrollbar()->scrollbarThickness() |
| 1284 : resizeControlSize)); |
1284 if (vBarRect.contains(localPoint)) { | 1285 if (vBarRect.contains(localPoint)) { |
1285 result.setScrollbar(verticalScrollbar()); | 1286 result.setScrollbar(verticalScrollbar()); |
1286 return true; | 1287 return true; |
1287 } | 1288 } |
1288 } | 1289 } |
1289 | 1290 |
1290 resizeControlSize = max(resizeControlRect.width(), 0); | 1291 resizeControlSize = max(resizeControlRect.width(), 0); |
1291 if (hasHorizontalScrollbar() && | 1292 if (hasHorizontalScrollbar() && |
1292 horizontalScrollbar()->shouldParticipateInHitTesting()) { | 1293 horizontalScrollbar()->shouldParticipateInHitTesting()) { |
1293 // TODO(crbug.com/638981): Are the conversions to int intentional? | 1294 // TODO(crbug.com/638981): Are the conversions to int intentional? |
1294 LayoutRect hBarRect( | 1295 LayoutRect hBarRect( |
1295 horizontalScrollbarStart(0), | 1296 horizontalScrollbarStart(0), |
1296 (box().size().height() - box().borderBottom() - | 1297 (box().size().height() - box().borderBottom() - |
1297 horizontalScrollbar()->height()) | 1298 horizontalScrollbar()->scrollbarThickness()) |
1298 .toInt(), | 1299 .toInt(), |
1299 (box().size().width() - (box().borderLeft() + box().borderRight()) - | 1300 (box().size().width() - (box().borderLeft() + box().borderRight()) - |
1300 (hasVerticalScrollbar() ? verticalScrollbar()->width() | 1301 (hasVerticalScrollbar() ? verticalScrollbar()->scrollbarThickness() |
1301 : resizeControlSize)) | 1302 : resizeControlSize)) |
1302 .toInt(), | 1303 .toInt(), |
1303 horizontalScrollbar()->height()); | 1304 horizontalScrollbar()->scrollbarThickness()); |
1304 if (hBarRect.contains(localPoint)) { | 1305 if (hBarRect.contains(localPoint)) { |
1305 result.setScrollbar(horizontalScrollbar()); | 1306 result.setScrollbar(horizontalScrollbar()); |
1306 return true; | 1307 return true; |
1307 } | 1308 } |
1308 } | 1309 } |
1309 | 1310 |
1310 // FIXME: We should hit test the m_scrollCorner and pass it back through the r
esult. | 1311 // FIXME: We should hit test the m_scrollCorner and pass it back through the r
esult. |
1311 | 1312 |
1312 return false; | 1313 return false; |
1313 } | 1314 } |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1951 | 1952 |
1952 void PaintLayerScrollableArea::DelayScrollPositionClampScope:: | 1953 void PaintLayerScrollableArea::DelayScrollPositionClampScope:: |
1953 clampScrollableAreas() { | 1954 clampScrollableAreas() { |
1954 for (auto& scrollableArea : *s_needsClamp) | 1955 for (auto& scrollableArea : *s_needsClamp) |
1955 scrollableArea->clampScrollPositionsAfterLayout(); | 1956 scrollableArea->clampScrollPositionsAfterLayout(); |
1956 delete s_needsClamp; | 1957 delete s_needsClamp; |
1957 s_needsClamp = nullptr; | 1958 s_needsClamp = nullptr; |
1958 } | 1959 } |
1959 | 1960 |
1960 } // namespace blink | 1961 } // namespace blink |
OLD | NEW |