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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 IntRect PaintLayerScrollableArea::ScrollCornerRect() const { | 302 IntRect PaintLayerScrollableArea::ScrollCornerRect() const { |
303 // We have a scrollbar corner when a scrollbar is visible and not filling the | 303 // We have a scrollbar corner when a scrollbar is visible and not filling the |
304 // entire length of the box. | 304 // entire length of the box. |
305 // This happens when: | 305 // This happens when: |
306 // (a) A resizer is present and at least one scrollbar is present | 306 // (a) A resizer is present and at least one scrollbar is present |
307 // (b) Both scrollbars are present. | 307 // (b) Both scrollbars are present. |
308 bool has_horizontal_bar = HorizontalScrollbar(); | 308 bool has_horizontal_bar = HorizontalScrollbar(); |
309 bool has_vertical_bar = VerticalScrollbar(); | 309 bool has_vertical_bar = VerticalScrollbar(); |
310 bool has_resizer = Box().Style()->Resize() != RESIZE_NONE; | 310 bool has_resizer = Box().Style()->Resize() != RESIZE_NONE; |
311 if ((has_horizontal_bar && has_vertical_bar) || | 311 if ((has_horizontal_bar && has_vertical_bar) || |
312 (has_resizer && (has_horizontal_bar || has_vertical_bar))) | 312 (has_resizer && (has_horizontal_bar || has_vertical_bar))) { |
313 return CornerRect(Box(), HorizontalScrollbar(), VerticalScrollbar(), | 313 return CornerRect(Box(), HorizontalScrollbar(), VerticalScrollbar(), |
314 Box().PixelSnappedBorderBoxRect()); | 314 IntRect(IntPoint(), layer_.size())); |
| 315 } |
315 return IntRect(); | 316 return IntRect(); |
316 } | 317 } |
317 | 318 |
318 IntRect PaintLayerScrollableArea::ConvertFromScrollbarToContainingFrameViewBase( | 319 IntRect PaintLayerScrollableArea::ConvertFromScrollbarToContainingFrameViewBase( |
319 const Scrollbar& scrollbar, | 320 const Scrollbar& scrollbar, |
320 const IntRect& scrollbar_rect) const { | 321 const IntRect& scrollbar_rect) const { |
321 LayoutView* view = Box().View(); | 322 LayoutView* view = Box().View(); |
322 if (!view) | 323 if (!view) |
323 return scrollbar_rect; | 324 return scrollbar_rect; |
324 | 325 |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 } | 628 } |
628 | 629 |
629 bool PaintLayerScrollableArea::ScrollbarsCanBeActive() const { | 630 bool PaintLayerScrollableArea::ScrollbarsCanBeActive() const { |
630 LayoutView* view = Box().View(); | 631 LayoutView* view = Box().View(); |
631 if (!view) | 632 if (!view) |
632 return false; | 633 return false; |
633 return view->GetFrameView()->ScrollbarsCanBeActive(); | 634 return view->GetFrameView()->ScrollbarsCanBeActive(); |
634 } | 635 } |
635 | 636 |
636 IntRect PaintLayerScrollableArea::ScrollableAreaBoundingBox() const { | 637 IntRect PaintLayerScrollableArea::ScrollableAreaBoundingBox() const { |
637 return Box().AbsoluteBoundingBoxRect(kTraverseDocumentBoundaries); | 638 FloatQuad quad(FloatRect(FloatPoint(), FloatSize(layer_.size()))); |
| 639 quad = Box().LocalToAbsoluteQuad(quad, kTraverseDocumentBoundaries); |
| 640 return quad.EnclosingBoundingBox(); |
638 } | 641 } |
639 | 642 |
640 void PaintLayerScrollableArea::RegisterForAnimation() { | 643 void PaintLayerScrollableArea::RegisterForAnimation() { |
641 if (LocalFrame* frame = Box().GetFrame()) { | 644 if (LocalFrame* frame = Box().GetFrame()) { |
642 if (FrameView* frame_view = frame->View()) | 645 if (FrameView* frame_view = frame->View()) |
643 frame_view->AddAnimatingScrollableArea(this); | 646 frame_view->AddAnimatingScrollableArea(this); |
644 } | 647 } |
645 } | 648 } |
646 | 649 |
647 void PaintLayerScrollableArea::DeregisterForAnimation() { | 650 void PaintLayerScrollableArea::DeregisterForAnimation() { |
(...skipping 29 matching lines...) Expand all Loading... |
677 return (overflow_style == EOverflow::kScroll || | 680 return (overflow_style == EOverflow::kScroll || |
678 overflow_style == EOverflow::kAuto || | 681 overflow_style == EOverflow::kAuto || |
679 overflow_style == EOverflow::kOverlay); | 682 overflow_style == EOverflow::kOverlay); |
680 } | 683 } |
681 | 684 |
682 bool PaintLayerScrollableArea::ShouldPlaceVerticalScrollbarOnLeft() const { | 685 bool PaintLayerScrollableArea::ShouldPlaceVerticalScrollbarOnLeft() const { |
683 return Box().ShouldPlaceBlockDirectionScrollbarOnLogicalLeft(); | 686 return Box().ShouldPlaceBlockDirectionScrollbarOnLogicalLeft(); |
684 } | 687 } |
685 | 688 |
686 int PaintLayerScrollableArea::PageStep(ScrollbarOrientation orientation) const { | 689 int PaintLayerScrollableArea::PageStep(ScrollbarOrientation orientation) const { |
| 690 // Note: For the root layer of the main frame, pageStep() will not be based |
| 691 // on the scrollable area size (which matches the layout viewport), but |
| 692 // instead on the initial containing block size. It's unclear whether this |
| 693 // is "correct" behavior; there is no spec guidance on the scroll distance |
| 694 // of page scrolling in this circumstance. |
687 int length = (orientation == kHorizontalScrollbar) | 695 int length = (orientation == kHorizontalScrollbar) |
688 ? Box().PixelSnappedClientWidth() | 696 ? PixelSnappedClientSize().Width() |
689 : Box().PixelSnappedClientHeight(); | 697 : PixelSnappedClientSize().Height(); |
690 int min_page_step = static_cast<float>(length) * | 698 int min_page_step = static_cast<float>(length) * |
691 ScrollableArea::MinFractionToStepWhenPaging(); | 699 ScrollableArea::MinFractionToStepWhenPaging(); |
692 int page_step = | 700 int page_step = |
693 max(min_page_step, length - ScrollableArea::MaxOverlapBetweenPages()); | 701 max(min_page_step, length - ScrollableArea::MaxOverlapBetweenPages()); |
694 | 702 |
695 return max(page_step, 1); | 703 return max(page_step, 1); |
696 } | 704 } |
697 | 705 |
698 LayoutBox& PaintLayerScrollableArea::Box() const { | 706 LayoutBox& PaintLayerScrollableArea::Box() const { |
699 return *layer_.GetLayoutBox(); | 707 return *layer_.GetLayoutBox(); |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 ? VerticalScrollbar()->ScrollbarThickness() | 1154 ? VerticalScrollbar()->ScrollbarThickness() |
1147 : ResizerCornerRect(Box().PixelSnappedBorderBoxRect(), | 1155 : ResizerCornerRect(Box().PixelSnappedBorderBoxRect(), |
1148 kResizerForPointer) | 1156 kResizerForPointer) |
1149 .Width(); | 1157 .Width(); |
1150 return x; | 1158 return x; |
1151 } | 1159 } |
1152 | 1160 |
1153 IntSize PaintLayerScrollableArea::ScrollbarOffset( | 1161 IntSize PaintLayerScrollableArea::ScrollbarOffset( |
1154 const Scrollbar& scrollbar) const { | 1162 const Scrollbar& scrollbar) const { |
1155 if (&scrollbar == VerticalScrollbar()) { | 1163 if (&scrollbar == VerticalScrollbar()) { |
1156 return IntSize(VerticalScrollbarStart(0, Box().Size().Width().ToInt()), | 1164 return IntSize(VerticalScrollbarStart(0, layer_.size().Width()), |
1157 Box().BorderTop().ToInt()); | 1165 Box().BorderTop().ToInt()); |
1158 } | 1166 } |
1159 | 1167 |
1160 if (&scrollbar == HorizontalScrollbar()) | 1168 if (&scrollbar == HorizontalScrollbar()) { |
1161 return IntSize( | 1169 return IntSize(HorizontalScrollbarStart(0), |
1162 HorizontalScrollbarStart(0), | 1170 layer_.size().Height() - Box().BorderBottom().ToInt() - |
1163 (Box().Size().Height() - Box().BorderBottom() - scrollbar.Height()) | 1171 scrollbar.Height()); |
1164 .ToInt()); | 1172 } |
1165 | 1173 |
1166 NOTREACHED(); | 1174 NOTREACHED(); |
1167 return IntSize(); | 1175 return IntSize(); |
1168 } | 1176 } |
1169 | 1177 |
1170 static inline const LayoutObject& ScrollbarStyleSource( | 1178 static inline const LayoutObject& ScrollbarStyleSource( |
1171 const LayoutObject& layout_object) { | 1179 const LayoutObject& layout_object) { |
1172 if (Node* node = layout_object.GetNode()) { | 1180 if (Node* node = layout_object.GetNode()) { |
1173 if (layout_object.IsLayoutView()) { | 1181 if (layout_object.IsLayoutView()) { |
1174 Document& doc = node->GetDocument(); | 1182 Document& doc = node->GetDocument(); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 HorizontalScrollbar()->IsOverlayScrollbar()) { | 1391 HorizontalScrollbar()->IsOverlayScrollbar()) { |
1384 return 0; | 1392 return 0; |
1385 } | 1393 } |
1386 return HorizontalScrollbar()->ScrollbarThickness(); | 1394 return HorizontalScrollbar()->ScrollbarThickness(); |
1387 } | 1395 } |
1388 | 1396 |
1389 void PaintLayerScrollableArea::PositionOverflowControls() { | 1397 void PaintLayerScrollableArea::PositionOverflowControls() { |
1390 if (!HasScrollbar() && !Box().CanResize()) | 1398 if (!HasScrollbar() && !Box().CanResize()) |
1391 return; | 1399 return; |
1392 | 1400 |
1393 const IntRect border_box = Box().PixelSnappedBorderBoxRect(); | 1401 const IntRect layer_bounds(IntPoint(), layer_.size()); |
1394 if (Scrollbar* vertical_scrollbar = this->VerticalScrollbar()) | 1402 if (Scrollbar* vertical_scrollbar = this->VerticalScrollbar()) |
1395 vertical_scrollbar->SetFrameRect(RectForVerticalScrollbar(border_box)); | 1403 vertical_scrollbar->SetFrameRect(RectForVerticalScrollbar(layer_bounds)); |
1396 | 1404 |
1397 if (Scrollbar* horizontal_scrollbar = this->HorizontalScrollbar()) | 1405 if (Scrollbar* horizontal_scrollbar = this->HorizontalScrollbar()) { |
1398 horizontal_scrollbar->SetFrameRect(RectForHorizontalScrollbar(border_box)); | 1406 horizontal_scrollbar->SetFrameRect( |
| 1407 RectForHorizontalScrollbar(layer_bounds)); |
| 1408 } |
1399 | 1409 |
1400 const IntRect& scroll_corner = ScrollCornerRect(); | 1410 const IntRect& scroll_corner = ScrollCornerRect(); |
1401 if (scroll_corner_) | 1411 if (scroll_corner_) |
1402 scroll_corner_->SetFrameRect(LayoutRect(scroll_corner)); | 1412 scroll_corner_->SetFrameRect(LayoutRect(scroll_corner)); |
1403 | 1413 |
1404 if (resizer_) | 1414 if (resizer_) { |
1405 resizer_->SetFrameRect( | 1415 resizer_->SetFrameRect( |
1406 LayoutRect(ResizerCornerRect(border_box, kResizerForPointer))); | 1416 LayoutRect(ResizerCornerRect(layer_bounds, kResizerForPointer))); |
| 1417 } |
1407 | 1418 |
1408 // FIXME, this should eventually be removed, once we are certain that | 1419 // FIXME, this should eventually be removed, once we are certain that |
1409 // composited controls get correctly positioned on a compositor update. For | 1420 // composited controls get correctly positioned on a compositor update. For |
1410 // now, conservatively leaving this unchanged. | 1421 // now, conservatively leaving this unchanged. |
1411 if (Layer()->HasCompositedLayerMapping()) | 1422 if (Layer()->HasCompositedLayerMapping()) |
1412 Layer()->GetCompositedLayerMapping()->PositionOverflowControlsLayers(); | 1423 Layer()->GetCompositedLayerMapping()->PositionOverflowControlsLayers(); |
1413 } | 1424 } |
1414 | 1425 |
1415 void PaintLayerScrollableArea::UpdateScrollCornerStyle() { | 1426 void PaintLayerScrollableArea::UpdateScrollCornerStyle() { |
1416 if (!scroll_corner_ && !HasScrollbar()) | 1427 if (!scroll_corner_ && !HasScrollbar()) |
(...skipping 22 matching lines...) Expand all Loading... |
1439 } | 1450 } |
1440 | 1451 |
1441 bool PaintLayerScrollableArea::HitTestOverflowControls( | 1452 bool PaintLayerScrollableArea::HitTestOverflowControls( |
1442 HitTestResult& result, | 1453 HitTestResult& result, |
1443 const IntPoint& local_point) { | 1454 const IntPoint& local_point) { |
1444 if (!HasScrollbar() && !Box().CanResize()) | 1455 if (!HasScrollbar() && !Box().CanResize()) |
1445 return false; | 1456 return false; |
1446 | 1457 |
1447 IntRect resize_control_rect; | 1458 IntRect resize_control_rect; |
1448 if (Box().Style()->Resize() != RESIZE_NONE) { | 1459 if (Box().Style()->Resize() != RESIZE_NONE) { |
1449 resize_control_rect = ResizerCornerRect(Box().PixelSnappedBorderBoxRect(), | 1460 resize_control_rect = ResizerCornerRect(IntRect(IntPoint(), layer_.size()), |
1450 kResizerForPointer); | 1461 kResizerForPointer); |
1451 if (resize_control_rect.Contains(local_point)) | 1462 if (resize_control_rect.Contains(local_point)) |
1452 return true; | 1463 return true; |
1453 } | 1464 } |
1454 | 1465 |
1455 int resize_control_size = max(resize_control_rect.Height(), 0); | 1466 int resize_control_size = max(resize_control_rect.Height(), 0); |
1456 if (HasVerticalScrollbar() && | 1467 if (HasVerticalScrollbar() && |
1457 VerticalScrollbar()->ShouldParticipateInHitTesting()) { | 1468 VerticalScrollbar()->ShouldParticipateInHitTesting()) { |
1458 LayoutRect v_bar_rect( | 1469 LayoutRect v_bar_rect( |
1459 VerticalScrollbarStart(0, Box().Size().Width().ToInt()), | 1470 VerticalScrollbarStart(0, Box().Size().Width().ToInt()), |
1460 Box().BorderTop().ToInt(), VerticalScrollbar()->ScrollbarThickness(), | 1471 Box().BorderTop().ToInt(), VerticalScrollbar()->ScrollbarThickness(), |
1461 Box().Size().Height().ToInt() - | 1472 layer_.size().Height() - |
1462 (Box().BorderTop() + Box().BorderBottom()).ToInt() - | 1473 (Box().BorderTop() + Box().BorderBottom()).ToInt() - |
1463 (HasHorizontalScrollbar() | 1474 (HasHorizontalScrollbar() |
1464 ? HorizontalScrollbar()->ScrollbarThickness() | 1475 ? HorizontalScrollbar()->ScrollbarThickness() |
1465 : resize_control_size)); | 1476 : resize_control_size)); |
1466 if (v_bar_rect.Contains(local_point)) { | 1477 if (v_bar_rect.Contains(local_point)) { |
1467 result.SetScrollbar(VerticalScrollbar()); | 1478 result.SetScrollbar(VerticalScrollbar()); |
1468 return true; | 1479 return true; |
1469 } | 1480 } |
1470 } | 1481 } |
1471 | 1482 |
1472 resize_control_size = max(resize_control_rect.Width(), 0); | 1483 resize_control_size = max(resize_control_rect.Width(), 0); |
1473 if (HasHorizontalScrollbar() && | 1484 if (HasHorizontalScrollbar() && |
1474 HorizontalScrollbar()->ShouldParticipateInHitTesting()) { | 1485 HorizontalScrollbar()->ShouldParticipateInHitTesting()) { |
1475 // TODO(crbug.com/638981): Are the conversions to int intentional? | 1486 // TODO(crbug.com/638981): Are the conversions to int intentional? |
1476 LayoutRect h_bar_rect( | 1487 LayoutRect h_bar_rect( |
1477 HorizontalScrollbarStart(0), | 1488 HorizontalScrollbarStart(0), |
1478 (Box().Size().Height() - Box().BorderBottom() - | 1489 (layer_.size().Height() - Box().BorderBottom() - |
1479 HorizontalScrollbar()->ScrollbarThickness()) | 1490 HorizontalScrollbar()->ScrollbarThickness()) |
1480 .ToInt(), | 1491 .ToInt(), |
1481 (Box().Size().Width() - (Box().BorderLeft() + Box().BorderRight()) - | 1492 (layer_.size().Width() - (Box().BorderLeft() + Box().BorderRight()) - |
1482 (HasVerticalScrollbar() ? VerticalScrollbar()->ScrollbarThickness() | 1493 (HasVerticalScrollbar() ? VerticalScrollbar()->ScrollbarThickness() |
1483 : resize_control_size)) | 1494 : resize_control_size)) |
1484 .ToInt(), | 1495 .ToInt(), |
1485 HorizontalScrollbar()->ScrollbarThickness()); | 1496 HorizontalScrollbar()->ScrollbarThickness()); |
1486 if (h_bar_rect.Contains(local_point)) { | 1497 if (h_bar_rect.Contains(local_point)) { |
1487 result.SetScrollbar(HorizontalScrollbar()); | 1498 result.SetScrollbar(HorizontalScrollbar()); |
1488 return true; | 1499 return true; |
1489 } | 1500 } |
1490 } | 1501 } |
1491 | 1502 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1527 } | 1538 } |
1528 | 1539 |
1529 bool PaintLayerScrollableArea::IsPointInResizeControl( | 1540 bool PaintLayerScrollableArea::IsPointInResizeControl( |
1530 const IntPoint& absolute_point, | 1541 const IntPoint& absolute_point, |
1531 ResizerHitTestType resizer_hit_test_type) const { | 1542 ResizerHitTestType resizer_hit_test_type) const { |
1532 if (!Box().CanResize()) | 1543 if (!Box().CanResize()) |
1533 return false; | 1544 return false; |
1534 | 1545 |
1535 IntPoint local_point = | 1546 IntPoint local_point = |
1536 RoundedIntPoint(Box().AbsoluteToLocal(absolute_point, kUseTransforms)); | 1547 RoundedIntPoint(Box().AbsoluteToLocal(absolute_point, kUseTransforms)); |
1537 IntRect local_bounds(0, 0, Box().PixelSnappedWidth(), | 1548 IntRect local_bounds(IntPoint(), layer_.size()); |
1538 Box().PixelSnappedHeight()); | |
1539 return ResizerCornerRect(local_bounds, resizer_hit_test_type) | 1549 return ResizerCornerRect(local_bounds, resizer_hit_test_type) |
1540 .Contains(local_point); | 1550 .Contains(local_point); |
1541 } | 1551 } |
1542 | 1552 |
1543 bool PaintLayerScrollableArea::HitTestResizerInFragments( | 1553 bool PaintLayerScrollableArea::HitTestResizerInFragments( |
1544 const PaintLayerFragments& layer_fragments, | 1554 const PaintLayerFragments& layer_fragments, |
1545 const HitTestLocation& hit_test_location) const { | 1555 const HitTestLocation& hit_test_location) const { |
1546 if (!Box().CanResize()) | 1556 if (!Box().CanResize()) |
1547 return false; | 1557 return false; |
1548 | 1558 |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2177 | 2187 |
2178 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: | 2188 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: |
2179 ClampScrollableAreas() { | 2189 ClampScrollableAreas() { |
2180 for (auto& scrollable_area : *needs_clamp_) | 2190 for (auto& scrollable_area : *needs_clamp_) |
2181 scrollable_area->ClampScrollOffsetAfterOverflowChange(); | 2191 scrollable_area->ClampScrollOffsetAfterOverflowChange(); |
2182 delete needs_clamp_; | 2192 delete needs_clamp_; |
2183 needs_clamp_ = nullptr; | 2193 needs_clamp_ = nullptr; |
2184 } | 2194 } |
2185 | 2195 |
2186 } // namespace blink | 2196 } // namespace blink |
OLD | NEW |