| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 } | 549 } |
| 549 | 550 |
| 550 int PaintLayerScrollableArea::VisibleHeight() const { | 551 int PaintLayerScrollableArea::VisibleHeight() const { |
| 551 return Layer()->size().Height(); | 552 return Layer()->size().Height(); |
| 552 } | 553 } |
| 553 | 554 |
| 554 int PaintLayerScrollableArea::VisibleWidth() const { | 555 int PaintLayerScrollableArea::VisibleWidth() const { |
| 555 return Layer()->size().Width(); | 556 return Layer()->size().Width(); |
| 556 } | 557 } |
| 557 | 558 |
| 559 LayoutSize PaintLayerScrollableArea::ClientSize() const { |
| 560 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 561 bool is_main_frame_root_layer = |
| 562 layer_.IsRootLayer() && Box().GetDocument().GetFrame()->IsMainFrame(); |
| 563 if (is_main_frame_root_layer) { |
| 564 return LayoutSize(Box().GetFrameView()->GetLayoutSize()); |
| 565 } |
| 566 } |
| 567 return LayoutSize(Box().ClientWidth(), Box().ClientHeight()); |
| 568 } |
| 569 |
| 570 IntSize PaintLayerScrollableArea::PixelSnappedClientSize() const { |
| 571 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 572 bool is_main_frame_root_layer = |
| 573 layer_.IsRootLayer() && Box().GetDocument().GetFrame()->IsMainFrame(); |
| 574 if (is_main_frame_root_layer) { |
| 575 return Box().GetFrameView()->GetLayoutSize(); |
| 576 } |
| 577 } |
| 578 return IntSize(Box().PixelSnappedClientWidth(), |
| 579 Box().PixelSnappedClientHeight()); |
| 580 } |
| 581 |
| 558 IntSize PaintLayerScrollableArea::ContentsSize() const { | 582 IntSize PaintLayerScrollableArea::ContentsSize() const { |
| 559 return IntSize(PixelSnappedScrollWidth(), PixelSnappedScrollHeight()); | 583 return IntSize(PixelSnappedScrollWidth(), PixelSnappedScrollHeight()); |
| 560 } | 584 } |
| 561 | 585 |
| 562 void PaintLayerScrollableArea::ContentsResized() { | 586 void PaintLayerScrollableArea::ContentsResized() { |
| 563 ScrollableArea::ContentsResized(); | 587 ScrollableArea::ContentsResized(); |
| 564 // Need to update the bounds of the scroll property. | 588 // Need to update the bounds of the scroll property. |
| 565 Box().SetNeedsPaintPropertyUpdate(); | 589 Box().SetNeedsPaintPropertyUpdate(); |
| 566 } | 590 } |
| 567 | 591 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 } | 626 } |
| 603 | 627 |
| 604 bool PaintLayerScrollableArea::ScrollbarsCanBeActive() const { | 628 bool PaintLayerScrollableArea::ScrollbarsCanBeActive() const { |
| 605 LayoutView* view = Box().View(); | 629 LayoutView* view = Box().View(); |
| 606 if (!view) | 630 if (!view) |
| 607 return false; | 631 return false; |
| 608 return view->GetFrameView()->ScrollbarsCanBeActive(); | 632 return view->GetFrameView()->ScrollbarsCanBeActive(); |
| 609 } | 633 } |
| 610 | 634 |
| 611 IntRect PaintLayerScrollableArea::ScrollableAreaBoundingBox() const { | 635 IntRect PaintLayerScrollableArea::ScrollableAreaBoundingBox() const { |
| 612 return Box().AbsoluteBoundingBoxRect(kTraverseDocumentBoundaries); | 636 FloatQuad quad(FloatRect(FloatPoint(), FloatSize(layer_.size()))); |
| 637 quad = Box().LocalToAbsoluteQuad(quad, kTraverseDocumentBoundaries); |
| 638 return quad.EnclosingBoundingBox(); |
| 613 } | 639 } |
| 614 | 640 |
| 615 void PaintLayerScrollableArea::RegisterForAnimation() { | 641 void PaintLayerScrollableArea::RegisterForAnimation() { |
| 616 if (LocalFrame* frame = Box().GetFrame()) { | 642 if (LocalFrame* frame = Box().GetFrame()) { |
| 617 if (FrameView* frame_view = frame->View()) | 643 if (FrameView* frame_view = frame->View()) |
| 618 frame_view->AddAnimatingScrollableArea(this); | 644 frame_view->AddAnimatingScrollableArea(this); |
| 619 } | 645 } |
| 620 } | 646 } |
| 621 | 647 |
| 622 void PaintLayerScrollableArea::DeregisterForAnimation() { | 648 void PaintLayerScrollableArea::DeregisterForAnimation() { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 652 return (overflow_style == EOverflow::kScroll || | 678 return (overflow_style == EOverflow::kScroll || |
| 653 overflow_style == EOverflow::kAuto || | 679 overflow_style == EOverflow::kAuto || |
| 654 overflow_style == EOverflow::kOverlay); | 680 overflow_style == EOverflow::kOverlay); |
| 655 } | 681 } |
| 656 | 682 |
| 657 bool PaintLayerScrollableArea::ShouldPlaceVerticalScrollbarOnLeft() const { | 683 bool PaintLayerScrollableArea::ShouldPlaceVerticalScrollbarOnLeft() const { |
| 658 return Box().ShouldPlaceBlockDirectionScrollbarOnLogicalLeft(); | 684 return Box().ShouldPlaceBlockDirectionScrollbarOnLogicalLeft(); |
| 659 } | 685 } |
| 660 | 686 |
| 661 int PaintLayerScrollableArea::PageStep(ScrollbarOrientation orientation) const { | 687 int PaintLayerScrollableArea::PageStep(ScrollbarOrientation orientation) const { |
| 688 // Note: For the root layer of the main frame, pageStep() will not be based |
| 689 // on the scrollable area size (which matches the layout viewport), but |
| 690 // instead on the initial containing block size. It's unclear whether this |
| 691 // is "correct" behavior; there is no spec guidance on the scroll distance |
| 692 // of page scrolling in this circumstance. |
| 662 int length = (orientation == kHorizontalScrollbar) | 693 int length = (orientation == kHorizontalScrollbar) |
| 663 ? Box().PixelSnappedClientWidth() | 694 ? PixelSnappedClientSize().Width() |
| 664 : Box().PixelSnappedClientHeight(); | 695 : PixelSnappedClientSize().Height(); |
| 665 int min_page_step = static_cast<float>(length) * | 696 int min_page_step = static_cast<float>(length) * |
| 666 ScrollableArea::MinFractionToStepWhenPaging(); | 697 ScrollableArea::MinFractionToStepWhenPaging(); |
| 667 int page_step = | 698 int page_step = |
| 668 max(min_page_step, length - ScrollableArea::MaxOverlapBetweenPages()); | 699 max(min_page_step, length - ScrollableArea::MaxOverlapBetweenPages()); |
| 669 | 700 |
| 670 return max(page_step, 1); | 701 return max(page_step, 1); |
| 671 } | 702 } |
| 672 | 703 |
| 673 LayoutBox& PaintLayerScrollableArea::Box() const { | 704 LayoutBox& PaintLayerScrollableArea::Box() const { |
| 674 return *layer_.GetLayoutBox(); | 705 return *layer_.GetLayoutBox(); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 | 851 |
| 821 { | 852 { |
| 822 // Hits in | 853 // Hits in |
| 823 // compositing/overflow/automatically-opt-into-composited-scrolling-after-st
yle-change.html. | 854 // compositing/overflow/automatically-opt-into-composited-scrolling-after-st
yle-change.html. |
| 824 DisableCompositingQueryAsserts disabler; | 855 DisableCompositingQueryAsserts disabler; |
| 825 | 856 |
| 826 UpdateScrollbarEnabledState(); | 857 UpdateScrollbarEnabledState(); |
| 827 | 858 |
| 828 // Set up the range (and page step/line step). | 859 // Set up the range (and page step/line step). |
| 829 if (Scrollbar* horizontal_scrollbar = this->HorizontalScrollbar()) { | 860 if (Scrollbar* horizontal_scrollbar = this->HorizontalScrollbar()) { |
| 830 int client_width = Box().PixelSnappedClientWidth(); | 861 int client_width = PixelSnappedClientSize().Width(); |
| 831 horizontal_scrollbar->SetProportion(client_width, | 862 horizontal_scrollbar->SetProportion(client_width, |
| 832 OverflowRect().Width().ToInt()); | 863 OverflowRect().Width().ToInt()); |
| 833 } | 864 } |
| 834 if (Scrollbar* vertical_scrollbar = this->VerticalScrollbar()) { | 865 if (Scrollbar* vertical_scrollbar = this->VerticalScrollbar()) { |
| 835 int client_height = Box().PixelSnappedClientHeight(); | 866 int client_height = PixelSnappedClientSize().Height(); |
| 836 vertical_scrollbar->SetProportion(client_height, | 867 vertical_scrollbar->SetProportion(client_height, |
| 837 OverflowRect().Height().ToInt()); | 868 OverflowRect().Height().ToInt()); |
| 838 } | 869 } |
| 839 } | 870 } |
| 840 | 871 |
| 841 if (!scrollbars_are_frozen && HasOverlayScrollbars()) { | 872 if (!scrollbars_are_frozen && HasOverlayScrollbars()) { |
| 842 if (!ScrollSize(kHorizontalScrollbar)) | 873 if (!ScrollSize(kHorizontalScrollbar)) |
| 843 SetHasHorizontalScrollbar(false); | 874 SetHasHorizontalScrollbar(false); |
| 844 if (!ScrollSize(kVerticalScrollbar)) | 875 if (!ScrollSize(kVerticalScrollbar)) |
| 845 SetHasVerticalScrollbar(false); | 876 SetHasVerticalScrollbar(false); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 | 953 |
| 923 bool PaintLayerScrollableArea::HasHorizontalOverflow() const { | 954 bool PaintLayerScrollableArea::HasHorizontalOverflow() const { |
| 924 // TODO(szager): Make the algorithm for adding/subtracting overflow:auto | 955 // TODO(szager): Make the algorithm for adding/subtracting overflow:auto |
| 925 // scrollbars memoryless (crbug.com/625300). This clientWidth hack will | 956 // scrollbars memoryless (crbug.com/625300). This clientWidth hack will |
| 926 // prevent the spurious horizontal scrollbar, but it can cause a converse | 957 // prevent the spurious horizontal scrollbar, but it can cause a converse |
| 927 // problem: it can leave a sliver of horizontal overflow hidden behind the | 958 // problem: it can leave a sliver of horizontal overflow hidden behind the |
| 928 // vertical scrollbar without creating a horizontal scrollbar. This | 959 // vertical scrollbar without creating a horizontal scrollbar. This |
| 929 // converse problem seems to happen much less frequently in practice, so we | 960 // converse problem seems to happen much less frequently in practice, so we |
| 930 // bias the logic towards preventing unwanted horizontal scrollbars, which | 961 // bias the logic towards preventing unwanted horizontal scrollbars, which |
| 931 // are more common and annoying. | 962 // are more common and annoying. |
| 932 int client_width = Box().PixelSnappedClientWidth(); | 963 int client_width = PixelSnappedClientSize().Width(); |
| 933 if (NeedsRelayout() && !HadVerticalScrollbarBeforeRelayout()) | 964 if (NeedsRelayout() && !HadVerticalScrollbarBeforeRelayout()) |
| 934 client_width += VerticalScrollbarWidth(); | 965 client_width += VerticalScrollbarWidth(); |
| 935 return PixelSnappedScrollWidth() > client_width; | 966 return PixelSnappedScrollWidth() > client_width; |
| 936 } | 967 } |
| 937 | 968 |
| 938 bool PaintLayerScrollableArea::HasVerticalOverflow() const { | 969 bool PaintLayerScrollableArea::HasVerticalOverflow() const { |
| 939 return PixelSnappedScrollHeight() > Box().PixelSnappedClientHeight(); | 970 return PixelSnappedScrollHeight() > PixelSnappedClientSize().Height(); |
| 940 } | 971 } |
| 941 | 972 |
| 942 bool PaintLayerScrollableArea::HasScrollableHorizontalOverflow() const { | 973 bool PaintLayerScrollableArea::HasScrollableHorizontalOverflow() const { |
| 943 return HasHorizontalOverflow() && Box().ScrollsOverflowX(); | 974 return HasHorizontalOverflow() && Box().ScrollsOverflowX(); |
| 944 } | 975 } |
| 945 | 976 |
| 946 bool PaintLayerScrollableArea::HasScrollableVerticalOverflow() const { | 977 bool PaintLayerScrollableArea::HasScrollableVerticalOverflow() const { |
| 947 return HasVerticalOverflow() && Box().ScrollsOverflowY(); | 978 return HasVerticalOverflow() && Box().ScrollsOverflowY(); |
| 948 } | 979 } |
| 949 | 980 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 const bool layers_changed = | 1068 const bool layers_changed = |
| 1038 topmost_scroll_child_ != next_topmost_scroll_child_; | 1069 topmost_scroll_child_ != next_topmost_scroll_child_; |
| 1039 topmost_scroll_child_ = next_topmost_scroll_child_; | 1070 topmost_scroll_child_ = next_topmost_scroll_child_; |
| 1040 next_topmost_scroll_child_ = nullptr; | 1071 next_topmost_scroll_child_ = nullptr; |
| 1041 return layers_changed; | 1072 return layers_changed; |
| 1042 } | 1073 } |
| 1043 | 1074 |
| 1044 void PaintLayerScrollableArea::UpdateAfterOverflowRecalc() { | 1075 void PaintLayerScrollableArea::UpdateAfterOverflowRecalc() { |
| 1045 UpdateScrollDimensions(); | 1076 UpdateScrollDimensions(); |
| 1046 if (Scrollbar* horizontal_scrollbar = this->HorizontalScrollbar()) { | 1077 if (Scrollbar* horizontal_scrollbar = this->HorizontalScrollbar()) { |
| 1047 int client_width = Box().PixelSnappedClientWidth(); | 1078 int client_width = PixelSnappedClientSize().Width(); |
| 1048 horizontal_scrollbar->SetProportion(client_width, | 1079 horizontal_scrollbar->SetProportion(client_width, |
| 1049 OverflowRect().Width().ToInt()); | 1080 OverflowRect().Width().ToInt()); |
| 1050 } | 1081 } |
| 1051 if (Scrollbar* vertical_scrollbar = this->VerticalScrollbar()) { | 1082 if (Scrollbar* vertical_scrollbar = this->VerticalScrollbar()) { |
| 1052 int client_height = Box().PixelSnappedClientHeight(); | 1083 int client_height = PixelSnappedClientSize().Height(); |
| 1053 vertical_scrollbar->SetProportion(client_height, | 1084 vertical_scrollbar->SetProportion(client_height, |
| 1054 OverflowRect().Height().ToInt()); | 1085 OverflowRect().Height().ToInt()); |
| 1055 } | 1086 } |
| 1056 | 1087 |
| 1057 bool needs_horizontal_scrollbar; | 1088 bool needs_horizontal_scrollbar; |
| 1058 bool needs_vertical_scrollbar; | 1089 bool needs_vertical_scrollbar; |
| 1059 ComputeScrollbarExistence(needs_horizontal_scrollbar, | 1090 ComputeScrollbarExistence(needs_horizontal_scrollbar, |
| 1060 needs_vertical_scrollbar); | 1091 needs_vertical_scrollbar); |
| 1061 | 1092 |
| 1062 bool horizontal_scrollbar_should_change = | 1093 bool horizontal_scrollbar_should_change = |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 ? VerticalScrollbar()->ScrollbarThickness() | 1152 ? VerticalScrollbar()->ScrollbarThickness() |
| 1122 : ResizerCornerRect(Box().PixelSnappedBorderBoxRect(), | 1153 : ResizerCornerRect(Box().PixelSnappedBorderBoxRect(), |
| 1123 kResizerForPointer) | 1154 kResizerForPointer) |
| 1124 .Width(); | 1155 .Width(); |
| 1125 return x; | 1156 return x; |
| 1126 } | 1157 } |
| 1127 | 1158 |
| 1128 IntSize PaintLayerScrollableArea::ScrollbarOffset( | 1159 IntSize PaintLayerScrollableArea::ScrollbarOffset( |
| 1129 const Scrollbar& scrollbar) const { | 1160 const Scrollbar& scrollbar) const { |
| 1130 if (&scrollbar == VerticalScrollbar()) { | 1161 if (&scrollbar == VerticalScrollbar()) { |
| 1131 return IntSize(VerticalScrollbarStart(0, Box().Size().Width().ToInt()), | 1162 return IntSize(VerticalScrollbarStart(0, layer_.size().Width()), |
| 1132 Box().BorderTop().ToInt()); | 1163 Box().BorderTop().ToInt()); |
| 1133 } | 1164 } |
| 1134 | 1165 |
| 1135 if (&scrollbar == HorizontalScrollbar()) | 1166 if (&scrollbar == HorizontalScrollbar()) { |
| 1136 return IntSize( | 1167 return IntSize(HorizontalScrollbarStart(0), |
| 1137 HorizontalScrollbarStart(0), | 1168 layer_.size().Height() - Box().BorderBottom().ToInt() - |
| 1138 (Box().Size().Height() - Box().BorderBottom() - scrollbar.Height()) | 1169 scrollbar.Height()); |
| 1139 .ToInt()); | 1170 } |
| 1140 | 1171 |
| 1141 ASSERT_NOT_REACHED(); | 1172 ASSERT_NOT_REACHED(); |
| 1142 return IntSize(); | 1173 return IntSize(); |
| 1143 } | 1174 } |
| 1144 | 1175 |
| 1145 static inline const LayoutObject& ScrollbarStyleSource( | 1176 static inline const LayoutObject& ScrollbarStyleSource( |
| 1146 const LayoutObject& layout_object) { | 1177 const LayoutObject& layout_object) { |
| 1147 if (Node* node = layout_object.GetNode()) { | 1178 if (Node* node = layout_object.GetNode()) { |
| 1148 if (layout_object.IsLayoutView()) { | 1179 if (layout_object.IsLayoutView()) { |
| 1149 Document& doc = node->GetDocument(); | 1180 Document& doc = node->GetDocument(); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1358 HorizontalScrollbar()->IsOverlayScrollbar()) { | 1389 HorizontalScrollbar()->IsOverlayScrollbar()) { |
| 1359 return 0; | 1390 return 0; |
| 1360 } | 1391 } |
| 1361 return HorizontalScrollbar()->ScrollbarThickness(); | 1392 return HorizontalScrollbar()->ScrollbarThickness(); |
| 1362 } | 1393 } |
| 1363 | 1394 |
| 1364 void PaintLayerScrollableArea::PositionOverflowControls() { | 1395 void PaintLayerScrollableArea::PositionOverflowControls() { |
| 1365 if (!HasScrollbar() && !Box().CanResize()) | 1396 if (!HasScrollbar() && !Box().CanResize()) |
| 1366 return; | 1397 return; |
| 1367 | 1398 |
| 1368 const IntRect border_box = Box().PixelSnappedBorderBoxRect(); | 1399 const IntRect layer_bounds(IntPoint(), layer_.size()); |
| 1369 if (Scrollbar* vertical_scrollbar = this->VerticalScrollbar()) | 1400 if (Scrollbar* vertical_scrollbar = this->VerticalScrollbar()) |
| 1370 vertical_scrollbar->SetFrameRect(RectForVerticalScrollbar(border_box)); | 1401 vertical_scrollbar->SetFrameRect(RectForVerticalScrollbar(layer_bounds)); |
| 1371 | 1402 |
| 1372 if (Scrollbar* horizontal_scrollbar = this->HorizontalScrollbar()) | 1403 if (Scrollbar* horizontal_scrollbar = this->HorizontalScrollbar()) { |
| 1373 horizontal_scrollbar->SetFrameRect(RectForHorizontalScrollbar(border_box)); | 1404 horizontal_scrollbar->SetFrameRect( |
| 1405 RectForHorizontalScrollbar(layer_bounds)); |
| 1406 } |
| 1374 | 1407 |
| 1375 const IntRect& scroll_corner = ScrollCornerRect(); | 1408 const IntRect& scroll_corner = ScrollCornerRect(); |
| 1376 if (scroll_corner_) | 1409 if (scroll_corner_) |
| 1377 scroll_corner_->SetFrameRect(LayoutRect(scroll_corner)); | 1410 scroll_corner_->SetFrameRect(LayoutRect(scroll_corner)); |
| 1378 | 1411 |
| 1379 if (resizer_) | 1412 if (resizer_) { |
| 1380 resizer_->SetFrameRect( | 1413 resizer_->SetFrameRect( |
| 1381 LayoutRect(ResizerCornerRect(border_box, kResizerForPointer))); | 1414 LayoutRect(ResizerCornerRect(layer_bounds, kResizerForPointer))); |
| 1415 } |
| 1382 | 1416 |
| 1383 // FIXME, this should eventually be removed, once we are certain that | 1417 // FIXME, this should eventually be removed, once we are certain that |
| 1384 // composited controls get correctly positioned on a compositor update. For | 1418 // composited controls get correctly positioned on a compositor update. For |
| 1385 // now, conservatively leaving this unchanged. | 1419 // now, conservatively leaving this unchanged. |
| 1386 if (Layer()->HasCompositedLayerMapping()) | 1420 if (Layer()->HasCompositedLayerMapping()) |
| 1387 Layer()->GetCompositedLayerMapping()->PositionOverflowControlsLayers(); | 1421 Layer()->GetCompositedLayerMapping()->PositionOverflowControlsLayers(); |
| 1388 } | 1422 } |
| 1389 | 1423 |
| 1390 void PaintLayerScrollableArea::UpdateScrollCornerStyle() { | 1424 void PaintLayerScrollableArea::UpdateScrollCornerStyle() { |
| 1391 if (!scroll_corner_ && !HasScrollbar()) | 1425 if (!scroll_corner_ && !HasScrollbar()) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1414 } | 1448 } |
| 1415 | 1449 |
| 1416 bool PaintLayerScrollableArea::HitTestOverflowControls( | 1450 bool PaintLayerScrollableArea::HitTestOverflowControls( |
| 1417 HitTestResult& result, | 1451 HitTestResult& result, |
| 1418 const IntPoint& local_point) { | 1452 const IntPoint& local_point) { |
| 1419 if (!HasScrollbar() && !Box().CanResize()) | 1453 if (!HasScrollbar() && !Box().CanResize()) |
| 1420 return false; | 1454 return false; |
| 1421 | 1455 |
| 1422 IntRect resize_control_rect; | 1456 IntRect resize_control_rect; |
| 1423 if (Box().Style()->Resize() != RESIZE_NONE) { | 1457 if (Box().Style()->Resize() != RESIZE_NONE) { |
| 1424 resize_control_rect = ResizerCornerRect(Box().PixelSnappedBorderBoxRect(), | 1458 resize_control_rect = ResizerCornerRect(IntRect(IntPoint(), layer_.size()), |
| 1425 kResizerForPointer); | 1459 kResizerForPointer); |
| 1426 if (resize_control_rect.Contains(local_point)) | 1460 if (resize_control_rect.Contains(local_point)) |
| 1427 return true; | 1461 return true; |
| 1428 } | 1462 } |
| 1429 | 1463 |
| 1430 int resize_control_size = max(resize_control_rect.Height(), 0); | 1464 int resize_control_size = max(resize_control_rect.Height(), 0); |
| 1431 if (HasVerticalScrollbar() && | 1465 if (HasVerticalScrollbar() && |
| 1432 VerticalScrollbar()->ShouldParticipateInHitTesting()) { | 1466 VerticalScrollbar()->ShouldParticipateInHitTesting()) { |
| 1433 LayoutRect v_bar_rect( | 1467 LayoutRect v_bar_rect( |
| 1434 VerticalScrollbarStart(0, Box().Size().Width().ToInt()), | 1468 VerticalScrollbarStart(0, Box().Size().Width().ToInt()), |
| 1435 Box().BorderTop().ToInt(), VerticalScrollbar()->ScrollbarThickness(), | 1469 Box().BorderTop().ToInt(), VerticalScrollbar()->ScrollbarThickness(), |
| 1436 Box().Size().Height().ToInt() - | 1470 layer_.size().Height() - |
| 1437 (Box().BorderTop() + Box().BorderBottom()).ToInt() - | 1471 (Box().BorderTop() + Box().BorderBottom()).ToInt() - |
| 1438 (HasHorizontalScrollbar() | 1472 (HasHorizontalScrollbar() |
| 1439 ? HorizontalScrollbar()->ScrollbarThickness() | 1473 ? HorizontalScrollbar()->ScrollbarThickness() |
| 1440 : resize_control_size)); | 1474 : resize_control_size)); |
| 1441 if (v_bar_rect.Contains(local_point)) { | 1475 if (v_bar_rect.Contains(local_point)) { |
| 1442 result.SetScrollbar(VerticalScrollbar()); | 1476 result.SetScrollbar(VerticalScrollbar()); |
| 1443 return true; | 1477 return true; |
| 1444 } | 1478 } |
| 1445 } | 1479 } |
| 1446 | 1480 |
| 1447 resize_control_size = max(resize_control_rect.Width(), 0); | 1481 resize_control_size = max(resize_control_rect.Width(), 0); |
| 1448 if (HasHorizontalScrollbar() && | 1482 if (HasHorizontalScrollbar() && |
| 1449 HorizontalScrollbar()->ShouldParticipateInHitTesting()) { | 1483 HorizontalScrollbar()->ShouldParticipateInHitTesting()) { |
| 1450 // TODO(crbug.com/638981): Are the conversions to int intentional? | 1484 // TODO(crbug.com/638981): Are the conversions to int intentional? |
| 1451 LayoutRect h_bar_rect( | 1485 LayoutRect h_bar_rect( |
| 1452 HorizontalScrollbarStart(0), | 1486 HorizontalScrollbarStart(0), |
| 1453 (Box().Size().Height() - Box().BorderBottom() - | 1487 (layer_.size().Height() - Box().BorderBottom() - |
| 1454 HorizontalScrollbar()->ScrollbarThickness()) | 1488 HorizontalScrollbar()->ScrollbarThickness()) |
| 1455 .ToInt(), | 1489 .ToInt(), |
| 1456 (Box().Size().Width() - (Box().BorderLeft() + Box().BorderRight()) - | 1490 (layer_.size().Width() - (Box().BorderLeft() + Box().BorderRight()) - |
| 1457 (HasVerticalScrollbar() ? VerticalScrollbar()->ScrollbarThickness() | 1491 (HasVerticalScrollbar() ? VerticalScrollbar()->ScrollbarThickness() |
| 1458 : resize_control_size)) | 1492 : resize_control_size)) |
| 1459 .ToInt(), | 1493 .ToInt(), |
| 1460 HorizontalScrollbar()->ScrollbarThickness()); | 1494 HorizontalScrollbar()->ScrollbarThickness()); |
| 1461 if (h_bar_rect.Contains(local_point)) { | 1495 if (h_bar_rect.Contains(local_point)) { |
| 1462 result.SetScrollbar(HorizontalScrollbar()); | 1496 result.SetScrollbar(HorizontalScrollbar()); |
| 1463 return true; | 1497 return true; |
| 1464 } | 1498 } |
| 1465 } | 1499 } |
| 1466 | 1500 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1502 } | 1536 } |
| 1503 | 1537 |
| 1504 bool PaintLayerScrollableArea::IsPointInResizeControl( | 1538 bool PaintLayerScrollableArea::IsPointInResizeControl( |
| 1505 const IntPoint& absolute_point, | 1539 const IntPoint& absolute_point, |
| 1506 ResizerHitTestType resizer_hit_test_type) const { | 1540 ResizerHitTestType resizer_hit_test_type) const { |
| 1507 if (!Box().CanResize()) | 1541 if (!Box().CanResize()) |
| 1508 return false; | 1542 return false; |
| 1509 | 1543 |
| 1510 IntPoint local_point = | 1544 IntPoint local_point = |
| 1511 RoundedIntPoint(Box().AbsoluteToLocal(absolute_point, kUseTransforms)); | 1545 RoundedIntPoint(Box().AbsoluteToLocal(absolute_point, kUseTransforms)); |
| 1512 IntRect local_bounds(0, 0, Box().PixelSnappedWidth(), | 1546 IntRect local_bounds(IntPoint(), layer_.size()); |
| 1513 Box().PixelSnappedHeight()); | |
| 1514 return ResizerCornerRect(local_bounds, resizer_hit_test_type) | 1547 return ResizerCornerRect(local_bounds, resizer_hit_test_type) |
| 1515 .Contains(local_point); | 1548 .Contains(local_point); |
| 1516 } | 1549 } |
| 1517 | 1550 |
| 1518 bool PaintLayerScrollableArea::HitTestResizerInFragments( | 1551 bool PaintLayerScrollableArea::HitTestResizerInFragments( |
| 1519 const PaintLayerFragments& layer_fragments, | 1552 const PaintLayerFragments& layer_fragments, |
| 1520 const HitTestLocation& hit_test_location) const { | 1553 const HitTestLocation& hit_test_location) const { |
| 1521 if (!Box().CanResize()) | 1554 if (!Box().CanResize()) |
| 1522 return false; | 1555 return false; |
| 1523 | 1556 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1697 LayoutRect PaintLayerScrollableArea::ScrollIntoView( | 1730 LayoutRect PaintLayerScrollableArea::ScrollIntoView( |
| 1698 const LayoutRect& rect, | 1731 const LayoutRect& rect, |
| 1699 const ScrollAlignment& align_x, | 1732 const ScrollAlignment& align_x, |
| 1700 const ScrollAlignment& align_y, | 1733 const ScrollAlignment& align_y, |
| 1701 ScrollType scroll_type) { | 1734 ScrollType scroll_type) { |
| 1702 LayoutRect local_expose_rect( | 1735 LayoutRect local_expose_rect( |
| 1703 Box() | 1736 Box() |
| 1704 .AbsoluteToLocalQuad(FloatQuad(FloatRect(rect)), kUseTransforms) | 1737 .AbsoluteToLocalQuad(FloatQuad(FloatRect(rect)), kUseTransforms) |
| 1705 .BoundingBox()); | 1738 .BoundingBox()); |
| 1706 local_expose_rect.Move(-Box().BorderLeft(), -Box().BorderTop()); | 1739 local_expose_rect.Move(-Box().BorderLeft(), -Box().BorderTop()); |
| 1707 LayoutRect layer_bounds( | 1740 LayoutRect visible_rect(LayoutPoint(), ClientSize()); |
| 1708 LayoutPoint(), LayoutSize(Box().ClientWidth(), Box().ClientHeight())); | |
| 1709 LayoutRect r = ScrollAlignment::GetRectToExpose( | 1741 LayoutRect r = ScrollAlignment::GetRectToExpose( |
| 1710 layer_bounds, local_expose_rect, align_x, align_y); | 1742 visible_rect, local_expose_rect, align_x, align_y); |
| 1711 | 1743 |
| 1712 ScrollOffset old_scroll_offset = GetScrollOffset(); | 1744 ScrollOffset old_scroll_offset = GetScrollOffset(); |
| 1713 ScrollOffset new_scroll_offset(ClampScrollOffset(RoundedIntSize( | 1745 ScrollOffset new_scroll_offset(ClampScrollOffset(RoundedIntSize( |
| 1714 ToScrollOffset(FloatPoint(r.Location()) + old_scroll_offset)))); | 1746 ToScrollOffset(FloatPoint(r.Location()) + old_scroll_offset)))); |
| 1715 SetScrollOffset(new_scroll_offset, scroll_type, kScrollBehaviorInstant); | 1747 SetScrollOffset(new_scroll_offset, scroll_type, kScrollBehaviorInstant); |
| 1716 ScrollOffset scroll_offset_difference = GetScrollOffset() - old_scroll_offset; | 1748 ScrollOffset scroll_offset_difference = GetScrollOffset() - old_scroll_offset; |
| 1717 local_expose_rect.Move(-LayoutSize(scroll_offset_difference)); | 1749 local_expose_rect.Move(-LayoutSize(scroll_offset_difference)); |
| 1718 | 1750 |
| 1719 LayoutRect intersect = | 1751 LayoutRect intersect = |
| 1720 LocalToAbsolute(Box(), Intersection(layer_bounds, local_expose_rect)); | 1752 LocalToAbsolute(Box(), Intersection(visible_rect, local_expose_rect)); |
| 1721 if (intersect.IsEmpty() && !layer_bounds.IsEmpty() && | 1753 if (intersect.IsEmpty() && !visible_rect.IsEmpty() && |
| 1722 !local_expose_rect.IsEmpty()) { | 1754 !local_expose_rect.IsEmpty()) { |
| 1723 return LocalToAbsolute(Box(), local_expose_rect); | 1755 return LocalToAbsolute(Box(), local_expose_rect); |
| 1724 } | 1756 } |
| 1725 return intersect; | 1757 return intersect; |
| 1726 } | 1758 } |
| 1727 | 1759 |
| 1728 void PaintLayerScrollableArea::UpdateScrollableAreaSet(bool has_overflow) { | 1760 void PaintLayerScrollableArea::UpdateScrollableAreaSet(bool has_overflow) { |
| 1729 LocalFrame* frame = Box().GetFrame(); | 1761 LocalFrame* frame = Box().GetFrame(); |
| 1730 if (!frame) | 1762 if (!frame) |
| 1731 return; | 1763 return; |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2149 | 2181 |
| 2150 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: | 2182 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: |
| 2151 ClampScrollableAreas() { | 2183 ClampScrollableAreas() { |
| 2152 for (auto& scrollable_area : *needs_clamp_) | 2184 for (auto& scrollable_area : *needs_clamp_) |
| 2153 scrollable_area->ClampScrollOffsetAfterOverflowChange(); | 2185 scrollable_area->ClampScrollOffsetAfterOverflowChange(); |
| 2154 delete needs_clamp_; | 2186 delete needs_clamp_; |
| 2155 needs_clamp_ = nullptr; | 2187 needs_clamp_ = nullptr; |
| 2156 } | 2188 } |
| 2157 | 2189 |
| 2158 } // namespace blink | 2190 } // namespace blink |
| OLD | NEW |