Commit 484efec4 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

[PE] Reduce copies of LayoutRect in PaintLayerClipper.

Bug: 798378
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: Ic3c0b29430b06e76a3c81e654bc780e4a969592d
Reviewed-on: https://chromium-review.googlesource.com/880403
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532031}
parent 1423331f
......@@ -1943,12 +1943,24 @@ PaintInvalidationReason LayoutBox::InvalidatePaint(
LayoutRect LayoutBox::OverflowClipRect(
const LayoutPoint& location,
OverlayScrollbarClipBehavior overlay_scrollbar_clip_behavior) const {
if (RootScrollerUtil::IsEffective(*this))
return View()->ViewRect();
LayoutRect clip_rect;
CalculateOverflowClipRect(location, overlay_scrollbar_clip_behavior,
clip_rect);
return clip_rect;
}
void LayoutBox::CalculateOverflowClipRect(
const LayoutPoint& location,
OverlayScrollbarClipBehavior overlay_scrollbar_clip_behavior,
LayoutRect& clip_rect) const {
if (RootScrollerUtil::IsEffective(*this)) {
clip_rect = View()->ViewRect();
return;
}
// FIXME: When overflow-clip (CSS3) is implemented, we'll obtain the property
// here.
LayoutRect clip_rect = BorderBoxRect();
clip_rect = BorderBoxRect();
clip_rect.SetLocation(location + clip_rect.Location() +
LayoutSize(BorderLeft(), BorderTop()));
clip_rect.SetSize(clip_rect.Size() -
......@@ -1959,8 +1971,6 @@ LayoutRect LayoutBox::OverflowClipRect(
if (HasControlClip())
clip_rect.Intersect(ControlClipRect(location));
return clip_rect;
}
void LayoutBox::ExcludeScrollbars(
......
......@@ -1046,12 +1046,18 @@ class CORE_EXPORT LayoutBox : public LayoutBoxModelObject {
// control clips or contain: paint.
virtual bool ShouldClipOverflow() const;
// Returns the intersection of all overflow clips which apply.
virtual LayoutRect OverflowClipRect(
// Returns same value as ApplyOverflowClipRect sets on its third argument.
LayoutRect OverflowClipRect(
const LayoutPoint& location,
OverlayScrollbarClipBehavior = kIgnorePlatformOverlayScrollbarSize) const;
LayoutRect ClipRect(const LayoutPoint& location) const;
// Sets |clip_rect| to be equal to the bounds of the element, intersected
// with all overflow clips which aply.
virtual void CalculateOverflowClipRect(const LayoutPoint& location,
OverlayScrollbarClipBehavior,
LayoutRect& clip_rect) const;
// Returns the combination of overflow clip, contain: paint clip and CSS clip
// for this object.
LayoutRect ClippingRect(const LayoutPoint& location) const;
......
......@@ -1473,19 +1473,21 @@ LayoutUnit LayoutTable::FirstLineBoxBaseline() const {
return LayoutUnit(-1);
}
LayoutRect LayoutTable::OverflowClipRect(
void LayoutTable::CalculateOverflowClipRect(
const LayoutPoint& location,
OverlayScrollbarClipBehavior overlay_scrollbar_clip_behavior) const {
OverlayScrollbarClipBehavior overlay_scrollbar_clip_behavior,
LayoutRect& rect) const {
if (ShouldCollapseBorders()) {
// Though the outer halves of the collapsed borders are considered as the
// the border area of the table by means of the box model, they are actually
// contents of the table and should not be clipped off. The overflow clip
// rect is BorderBoxRect() + location.
return LayoutRect(location, Size());
rect = LayoutRect(location, Size());
return;
}
LayoutRect rect =
LayoutBlock::OverflowClipRect(location, overlay_scrollbar_clip_behavior);
LayoutBlock::CalculateOverflowClipRect(location,
overlay_scrollbar_clip_behavior, rect);
// If we have a caption, expand the clip to include the caption.
// FIXME: Technically this is wrong, but it's virtually impossible to fix this
......@@ -1503,8 +1505,6 @@ LayoutRect LayoutTable::OverflowClipRect(
rect.SetX(location.X());
}
}
return rect;
}
bool LayoutTable::NodeAtPoint(HitTestResult& result,
......
......@@ -470,10 +470,9 @@ class CORE_EXPORT LayoutTable final : public LayoutBlock {
LayoutUnit ConvertStyleLogicalHeightToComputedHeight(
const Length& style_logical_height) const;
LayoutRect OverflowClipRect(
const LayoutPoint& location,
OverlayScrollbarClipBehavior =
kIgnorePlatformOverlayScrollbarSize) const override;
void CalculateOverflowClipRect(const LayoutPoint& location,
OverlayScrollbarClipBehavior,
LayoutRect&) const override;
void AddOverflowFromChildren() override;
......
......@@ -624,19 +624,20 @@ LayoutRect LayoutView::ViewRect() const {
return LayoutRect();
}
LayoutRect LayoutView::OverflowClipRect(
void LayoutView::CalculateOverflowClipRect(
const LayoutPoint& location,
OverlayScrollbarClipBehavior overlay_scrollbar_clip_behavior) const {
LayoutRect rect = ViewRect();
if (rect.IsEmpty())
return LayoutBox::OverflowClipRect(location,
overlay_scrollbar_clip_behavior);
OverlayScrollbarClipBehavior overlay_scrollbar_clip_behavior,
LayoutRect& rect) const {
rect = ViewRect();
if (rect.IsEmpty()) {
LayoutBox::CalculateOverflowClipRect(location,
overlay_scrollbar_clip_behavior, rect);
return;
}
rect.SetLocation(location);
if (HasOverflowClip())
ExcludeScrollbars(rect, overlay_scrollbar_clip_behavior);
return rect;
}
void LayoutView::CalculateScrollbarModes(ScrollbarMode& h_mode,
......
......@@ -153,10 +153,10 @@ class CORE_EXPORT LayoutView final : public LayoutBlockFlow {
MapCoordinatesFlags mode = 0) const override;
LayoutRect ViewRect() const override;
LayoutRect OverflowClipRect(
const LayoutPoint& location,
OverlayScrollbarClipBehavior =
kIgnorePlatformOverlayScrollbarSize) const override;
void CalculateOverflowClipRect(const LayoutPoint& location,
OverlayScrollbarClipBehavior,
LayoutRect&) const override;
void CalculateScrollbarModes(ScrollbarMode& h_mode,
ScrollbarMode& v_mode) const;
......
......@@ -50,6 +50,8 @@ class ClipRect {
has_radius_ = rect.HasRadius();
}
LayoutRect& MutableRect() { return rect_; }
const LayoutRect& Rect() const { return rect_; }
bool HasRadius() const { return has_radius_; }
......
......@@ -331,10 +331,10 @@ void PaintLayerClipper::CalculateRectsWithGeometryMapper(
if (ShouldClipOverflow(context)) {
LayoutBoxModelObject& layout_object = layer_.GetLayoutObject();
foreground_rect =
ToLayoutBox(layout_object)
.OverflowClipRect(layer_bounds.Location(),
context.overlay_scrollbar_clip_behavior);
ToLayoutBox(layout_object)
.CalculateOverflowClipRect(layer_bounds.Location(),
context.overlay_scrollbar_clip_behavior,
foreground_rect.MutableRect());
if (layout_object.StyleRef().HasBorderRadius())
foreground_rect.SetHasRadius(true);
foreground_rect.Intersect(background_rect);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment