Commit cd466ce0 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

Revert "Don't hold weak ref to ComputedStyle in BoxPainter."

This reverts commit f3a47f5b.

Reason for revert: landed a real fix https://chromium.googlesource.com/chromium/src/+/49b2e1c02da7073c6c86e7e591928fc58fd5de34

Original change's description:
> Don't hold weak ref to ComputedStyle in BoxPainter.
> 
> Currently we hold a const ref& to a ComputedStyle object in BoxPainter::
> PaintBoxDecorationBackgroundWithRect. However, this ref could be
> invalidated during theme painting, which would cause a dangling ref
> issue when we use the ref later on.
> 
> This patch removes the weak ref and instead uses StyleRef() to grab a
> fresh style ref each time.
> 
> Bug: 712933
> Change-Id: Id576005fe63ac3a014002ba5a68acbb6c88382b0
> Reviewed-on: https://chromium-review.googlesource.com/566198
> Reviewed-by: Stephen Chenney <schenney@chromium.org>
> Commit-Queue: Darren Shen <shend@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#486266}

TBR=chrishtr@chromium.org,shend@chromium.org,schenney@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 712933
Change-Id: Idbd2a663be78d52a1481a3bb04cb708bb1df3b3b
Reviewed-on: https://chromium-review.googlesource.com/574948Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarDarren Shen <shend@chromium.org>
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487377}
parent acf1d044
...@@ -90,12 +90,14 @@ void BoxPainter::PaintBoxDecorationBackgroundWithRect( ...@@ -90,12 +90,14 @@ void BoxPainter::PaintBoxDecorationBackgroundWithRect(
bool painting_overflow_contents = BoxModelObjectPainter:: bool painting_overflow_contents = BoxModelObjectPainter::
IsPaintingBackgroundOfPaintContainerIntoScrollingContentsLayer( IsPaintingBackgroundOfPaintContainerIntoScrollingContentsLayer(
&layout_box_, paint_info); &layout_box_, paint_info);
const ComputedStyle& style = layout_box_.StyleRef();
Optional<DisplayItemCacheSkipper> cache_skipper; Optional<DisplayItemCacheSkipper> cache_skipper;
// Disable cache in under-invalidation checking mode for MediaSliderPart // Disable cache in under-invalidation checking mode for MediaSliderPart
// because we always paint using the latest data (buffered ranges, current // because we always paint using the latest data (buffered ranges, current
// time and duration) which may be different from the cached data. // time and duration) which may be different from the cached data.
if ((RuntimeEnabledFeatures::PaintUnderInvalidationCheckingEnabled() && if ((RuntimeEnabledFeatures::PaintUnderInvalidationCheckingEnabled() &&
layout_box_.StyleRef().Appearance() == kMediaSliderPart) style.Appearance() == kMediaSliderPart)
// We may paint a delayed-invalidation object before it's actually // We may paint a delayed-invalidation object before it's actually
// invalidated. Note this would be handled for us by // invalidated. Note this would be handled for us by
// LayoutObjectDrawingRecorder but we have to use DrawingRecorder as we // LayoutObjectDrawingRecorder but we have to use DrawingRecorder as we
...@@ -127,12 +129,11 @@ void BoxPainter::PaintBoxDecorationBackgroundWithRect( ...@@ -127,12 +129,11 @@ void BoxPainter::PaintBoxDecorationBackgroundWithRect(
// FIXME: Should eventually give the theme control over whether the box // FIXME: Should eventually give the theme control over whether the box
// shadow should paint, since controls could have custom shadows of their // shadow should paint, since controls could have custom shadows of their
// own. // own.
PaintNormalBoxShadow(paint_info, paint_rect, layout_box_.StyleRef()); PaintNormalBoxShadow(paint_info, paint_rect, style);
if (BleedAvoidanceIsClipping(box_decoration_data.bleed_avoidance)) { if (BleedAvoidanceIsClipping(box_decoration_data.bleed_avoidance)) {
state_saver.Save(); state_saver.Save();
FloatRoundedRect border = FloatRoundedRect border = style.GetRoundedBorderFor(paint_rect);
layout_box_.StyleRef().GetRoundedBorderFor(paint_rect);
paint_info.context.ClipRoundedRect(border); paint_info.context.ClipRoundedRect(border);
if (box_decoration_data.bleed_avoidance == kBackgroundBleedClipLayer) if (box_decoration_data.bleed_avoidance == kBackgroundBleedClipLayer)
...@@ -162,7 +163,7 @@ void BoxPainter::PaintBoxDecorationBackgroundWithRect( ...@@ -162,7 +163,7 @@ void BoxPainter::PaintBoxDecorationBackgroundWithRect(
} }
if (!painting_overflow_contents) { if (!painting_overflow_contents) {
PaintInsetBoxShadow(paint_info, paint_rect, layout_box_.StyleRef()); PaintInsetBoxShadow(paint_info, paint_rect, style);
// The theme will tell us whether or not we should also paint the CSS // The theme will tell us whether or not we should also paint the CSS
// border. // border.
...@@ -174,8 +175,7 @@ void BoxPainter::PaintBoxDecorationBackgroundWithRect( ...@@ -174,8 +175,7 @@ void BoxPainter::PaintBoxDecorationBackgroundWithRect(
!(layout_box_.IsTable() && !(layout_box_.IsTable() &&
ToLayoutTable(&layout_box_)->ShouldCollapseBorders())) { ToLayoutTable(&layout_box_)->ShouldCollapseBorders())) {
PaintBorder(layout_box_, layout_box_.GetDocument(), GetNode(), paint_info, PaintBorder(layout_box_, layout_box_.GetDocument(), GetNode(), paint_info,
paint_rect, layout_box_.StyleRef(), paint_rect, style, box_decoration_data.bleed_avoidance);
box_decoration_data.bleed_avoidance);
} }
} }
......
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