| Index: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
|
| diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
|
| index ce48c55fb9b17b064537b3b24b6160eee2b6f83b..be5d4a156f1491fc17e23dab4682692afa355fdc 100644
|
| --- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
|
| +++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
|
| @@ -309,9 +309,10 @@ IntRect PaintLayerScrollableArea::ScrollCornerRect() const {
|
| bool has_vertical_bar = VerticalScrollbar();
|
| bool has_resizer = Box().Style()->Resize() != RESIZE_NONE;
|
| if ((has_horizontal_bar && has_vertical_bar) ||
|
| - (has_resizer && (has_horizontal_bar || has_vertical_bar)))
|
| + (has_resizer && (has_horizontal_bar || has_vertical_bar))) {
|
| return CornerRect(Box(), HorizontalScrollbar(), VerticalScrollbar(),
|
| - Box().PixelSnappedBorderBoxRect());
|
| + IntRect(IntPoint(), layer_.size()));
|
| + }
|
| return IntRect();
|
| }
|
|
|
| @@ -555,6 +556,29 @@ int PaintLayerScrollableArea::VisibleWidth() const {
|
| return Layer()->size().Width();
|
| }
|
|
|
| +LayoutSize PaintLayerScrollableArea::ClientSize() const {
|
| + if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
|
| + bool is_main_frame_root_layer =
|
| + layer_.IsRootLayer() && Box().GetDocument().GetFrame()->IsMainFrame();
|
| + if (is_main_frame_root_layer) {
|
| + return LayoutSize(Box().GetFrameView()->GetLayoutSize());
|
| + }
|
| + }
|
| + return LayoutSize(Box().ClientWidth(), Box().ClientHeight());
|
| +}
|
| +
|
| +IntSize PaintLayerScrollableArea::PixelSnappedClientSize() const {
|
| + if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
|
| + bool is_main_frame_root_layer =
|
| + layer_.IsRootLayer() && Box().GetDocument().GetFrame()->IsMainFrame();
|
| + if (is_main_frame_root_layer) {
|
| + return Box().GetFrameView()->GetLayoutSize();
|
| + }
|
| + }
|
| + return IntSize(Box().PixelSnappedClientWidth(),
|
| + Box().PixelSnappedClientHeight());
|
| +}
|
| +
|
| IntSize PaintLayerScrollableArea::ContentsSize() const {
|
| return IntSize(PixelSnappedScrollWidth(), PixelSnappedScrollHeight());
|
| }
|
| @@ -609,7 +633,9 @@ bool PaintLayerScrollableArea::ScrollbarsCanBeActive() const {
|
| }
|
|
|
| IntRect PaintLayerScrollableArea::ScrollableAreaBoundingBox() const {
|
| - return Box().AbsoluteBoundingBoxRect(kTraverseDocumentBoundaries);
|
| + FloatQuad quad(FloatRect(FloatPoint(), FloatSize(layer_.size())));
|
| + quad = Box().LocalToAbsoluteQuad(quad, kTraverseDocumentBoundaries);
|
| + return quad.EnclosingBoundingBox();
|
| }
|
|
|
| void PaintLayerScrollableArea::RegisterForAnimation() {
|
| @@ -659,9 +685,14 @@ bool PaintLayerScrollableArea::ShouldPlaceVerticalScrollbarOnLeft() const {
|
| }
|
|
|
| int PaintLayerScrollableArea::PageStep(ScrollbarOrientation orientation) const {
|
| + // Note: For the root layer of the main frame, pageStep() will not be based
|
| + // on the scrollable area size (which matches the layout viewport), but
|
| + // instead on the initial containing block size. It's unclear whether this
|
| + // is "correct" behavior; there is no spec guidance on the scroll distance
|
| + // of page scrolling in this circumstance.
|
| int length = (orientation == kHorizontalScrollbar)
|
| - ? Box().PixelSnappedClientWidth()
|
| - : Box().PixelSnappedClientHeight();
|
| + ? PixelSnappedClientSize().Width()
|
| + : PixelSnappedClientSize().Height();
|
| int min_page_step = static_cast<float>(length) *
|
| ScrollableArea::MinFractionToStepWhenPaging();
|
| int page_step =
|
| @@ -827,12 +858,12 @@ void PaintLayerScrollableArea::UpdateAfterLayout() {
|
|
|
| // Set up the range (and page step/line step).
|
| if (Scrollbar* horizontal_scrollbar = this->HorizontalScrollbar()) {
|
| - int client_width = Box().PixelSnappedClientWidth();
|
| + int client_width = PixelSnappedClientSize().Width();
|
| horizontal_scrollbar->SetProportion(client_width,
|
| OverflowRect().Width().ToInt());
|
| }
|
| if (Scrollbar* vertical_scrollbar = this->VerticalScrollbar()) {
|
| - int client_height = Box().PixelSnappedClientHeight();
|
| + int client_height = PixelSnappedClientSize().Height();
|
| vertical_scrollbar->SetProportion(client_height,
|
| OverflowRect().Height().ToInt());
|
| }
|
| @@ -929,14 +960,14 @@ bool PaintLayerScrollableArea::HasHorizontalOverflow() const {
|
| // converse problem seems to happen much less frequently in practice, so we
|
| // bias the logic towards preventing unwanted horizontal scrollbars, which
|
| // are more common and annoying.
|
| - int client_width = Box().PixelSnappedClientWidth();
|
| + int client_width = PixelSnappedClientSize().Width();
|
| if (NeedsRelayout() && !HadVerticalScrollbarBeforeRelayout())
|
| client_width += VerticalScrollbarWidth();
|
| return PixelSnappedScrollWidth() > client_width;
|
| }
|
|
|
| bool PaintLayerScrollableArea::HasVerticalOverflow() const {
|
| - return PixelSnappedScrollHeight() > Box().PixelSnappedClientHeight();
|
| + return PixelSnappedScrollHeight() > PixelSnappedClientSize().Height();
|
| }
|
|
|
| bool PaintLayerScrollableArea::HasScrollableHorizontalOverflow() const {
|
| @@ -1044,12 +1075,12 @@ bool PaintLayerScrollableArea::UpdateAfterCompositingChange() {
|
| void PaintLayerScrollableArea::UpdateAfterOverflowRecalc() {
|
| UpdateScrollDimensions();
|
| if (Scrollbar* horizontal_scrollbar = this->HorizontalScrollbar()) {
|
| - int client_width = Box().PixelSnappedClientWidth();
|
| + int client_width = PixelSnappedClientSize().Width();
|
| horizontal_scrollbar->SetProportion(client_width,
|
| OverflowRect().Width().ToInt());
|
| }
|
| if (Scrollbar* vertical_scrollbar = this->VerticalScrollbar()) {
|
| - int client_height = Box().PixelSnappedClientHeight();
|
| + int client_height = PixelSnappedClientSize().Height();
|
| vertical_scrollbar->SetProportion(client_height,
|
| OverflowRect().Height().ToInt());
|
| }
|
| @@ -1128,15 +1159,15 @@ int PaintLayerScrollableArea::HorizontalScrollbarStart(int min_x) const {
|
| IntSize PaintLayerScrollableArea::ScrollbarOffset(
|
| const Scrollbar& scrollbar) const {
|
| if (&scrollbar == VerticalScrollbar()) {
|
| - return IntSize(VerticalScrollbarStart(0, Box().Size().Width().ToInt()),
|
| + return IntSize(VerticalScrollbarStart(0, layer_.size().Width()),
|
| Box().BorderTop().ToInt());
|
| }
|
|
|
| - if (&scrollbar == HorizontalScrollbar())
|
| - return IntSize(
|
| - HorizontalScrollbarStart(0),
|
| - (Box().Size().Height() - Box().BorderBottom() - scrollbar.Height())
|
| - .ToInt());
|
| + if (&scrollbar == HorizontalScrollbar()) {
|
| + return IntSize(HorizontalScrollbarStart(0),
|
| + layer_.size().Height() - Box().BorderBottom().ToInt() -
|
| + scrollbar.Height());
|
| + }
|
|
|
| ASSERT_NOT_REACHED();
|
| return IntSize();
|
| @@ -1365,20 +1396,23 @@ void PaintLayerScrollableArea::PositionOverflowControls() {
|
| if (!HasScrollbar() && !Box().CanResize())
|
| return;
|
|
|
| - const IntRect border_box = Box().PixelSnappedBorderBoxRect();
|
| + const IntRect layer_bounds(IntPoint(), layer_.size());
|
| if (Scrollbar* vertical_scrollbar = this->VerticalScrollbar())
|
| - vertical_scrollbar->SetFrameRect(RectForVerticalScrollbar(border_box));
|
| + vertical_scrollbar->SetFrameRect(RectForVerticalScrollbar(layer_bounds));
|
|
|
| - if (Scrollbar* horizontal_scrollbar = this->HorizontalScrollbar())
|
| - horizontal_scrollbar->SetFrameRect(RectForHorizontalScrollbar(border_box));
|
| + if (Scrollbar* horizontal_scrollbar = this->HorizontalScrollbar()) {
|
| + horizontal_scrollbar->SetFrameRect(
|
| + RectForHorizontalScrollbar(layer_bounds));
|
| + }
|
|
|
| const IntRect& scroll_corner = ScrollCornerRect();
|
| if (scroll_corner_)
|
| scroll_corner_->SetFrameRect(LayoutRect(scroll_corner));
|
|
|
| - if (resizer_)
|
| + if (resizer_) {
|
| resizer_->SetFrameRect(
|
| - LayoutRect(ResizerCornerRect(border_box, kResizerForPointer)));
|
| + LayoutRect(ResizerCornerRect(layer_bounds, kResizerForPointer)));
|
| + }
|
|
|
| // FIXME, this should eventually be removed, once we are certain that
|
| // composited controls get correctly positioned on a compositor update. For
|
| @@ -1421,7 +1455,7 @@ bool PaintLayerScrollableArea::HitTestOverflowControls(
|
|
|
| IntRect resize_control_rect;
|
| if (Box().Style()->Resize() != RESIZE_NONE) {
|
| - resize_control_rect = ResizerCornerRect(Box().PixelSnappedBorderBoxRect(),
|
| + resize_control_rect = ResizerCornerRect(IntRect(IntPoint(), layer_.size()),
|
| kResizerForPointer);
|
| if (resize_control_rect.Contains(local_point))
|
| return true;
|
| @@ -1433,7 +1467,7 @@ bool PaintLayerScrollableArea::HitTestOverflowControls(
|
| LayoutRect v_bar_rect(
|
| VerticalScrollbarStart(0, Box().Size().Width().ToInt()),
|
| Box().BorderTop().ToInt(), VerticalScrollbar()->ScrollbarThickness(),
|
| - Box().Size().Height().ToInt() -
|
| + layer_.size().Height() -
|
| (Box().BorderTop() + Box().BorderBottom()).ToInt() -
|
| (HasHorizontalScrollbar()
|
| ? HorizontalScrollbar()->ScrollbarThickness()
|
| @@ -1450,10 +1484,10 @@ bool PaintLayerScrollableArea::HitTestOverflowControls(
|
| // TODO(crbug.com/638981): Are the conversions to int intentional?
|
| LayoutRect h_bar_rect(
|
| HorizontalScrollbarStart(0),
|
| - (Box().Size().Height() - Box().BorderBottom() -
|
| + (layer_.size().Height() - Box().BorderBottom() -
|
| HorizontalScrollbar()->ScrollbarThickness())
|
| .ToInt(),
|
| - (Box().Size().Width() - (Box().BorderLeft() + Box().BorderRight()) -
|
| + (layer_.size().Width() - (Box().BorderLeft() + Box().BorderRight()) -
|
| (HasVerticalScrollbar() ? VerticalScrollbar()->ScrollbarThickness()
|
| : resize_control_size))
|
| .ToInt(),
|
| @@ -1509,8 +1543,7 @@ bool PaintLayerScrollableArea::IsPointInResizeControl(
|
|
|
| IntPoint local_point =
|
| RoundedIntPoint(Box().AbsoluteToLocal(absolute_point, kUseTransforms));
|
| - IntRect local_bounds(0, 0, Box().PixelSnappedWidth(),
|
| - Box().PixelSnappedHeight());
|
| + IntRect local_bounds(IntPoint(), layer_.size());
|
| return ResizerCornerRect(local_bounds, resizer_hit_test_type)
|
| .Contains(local_point);
|
| }
|
| @@ -1704,10 +1737,9 @@ LayoutRect PaintLayerScrollableArea::ScrollIntoView(
|
| .AbsoluteToLocalQuad(FloatQuad(FloatRect(rect)), kUseTransforms)
|
| .BoundingBox());
|
| local_expose_rect.Move(-Box().BorderLeft(), -Box().BorderTop());
|
| - LayoutRect layer_bounds(
|
| - LayoutPoint(), LayoutSize(Box().ClientWidth(), Box().ClientHeight()));
|
| + LayoutRect visible_rect(LayoutPoint(), ClientSize());
|
| LayoutRect r = ScrollAlignment::GetRectToExpose(
|
| - layer_bounds, local_expose_rect, align_x, align_y);
|
| + visible_rect, local_expose_rect, align_x, align_y);
|
|
|
| ScrollOffset old_scroll_offset = GetScrollOffset();
|
| ScrollOffset new_scroll_offset(ClampScrollOffset(RoundedIntSize(
|
| @@ -1717,8 +1749,8 @@ LayoutRect PaintLayerScrollableArea::ScrollIntoView(
|
| local_expose_rect.Move(-LayoutSize(scroll_offset_difference));
|
|
|
| LayoutRect intersect =
|
| - LocalToAbsolute(Box(), Intersection(layer_bounds, local_expose_rect));
|
| - if (intersect.IsEmpty() && !layer_bounds.IsEmpty() &&
|
| + LocalToAbsolute(Box(), Intersection(visible_rect, local_expose_rect));
|
| + if (intersect.IsEmpty() && !visible_rect.IsEmpty() &&
|
| !local_expose_rect.IsEmpty()) {
|
| return LocalToAbsolute(Box(), local_expose_rect);
|
| }
|
|
|