Commit 3229bc37 authored by Omer Katz's avatar Omer Katz Committed by Commit Bot

Converting Scrollbar and ScrollableArea from EagerSweeping to PreFinalizer

Replaced Scrollbar destructor with equivalent prefinalizer.

Prefinalizer of ScrollableArea calls RunScrollCompleteCallbacks to
Release the callbacks, and resets uniqueptr to TaskRunnerTimer.

Bug: 981043
Change-Id: I45d35928eef440bc079de77364ac2d4d0ed6ecb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1688968Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#675589}
parent b92969ad
......@@ -1207,4 +1207,25 @@ std::unique_ptr<TracedValue> VisualViewport::ViewportToTracedValue() const {
return value;
}
void VisualViewport::PreFinalize() {
root_transform_layer_.reset();
inner_viewport_container_layer_.reset();
overscroll_elasticity_layer_.reset();
page_scale_layer_.reset();
inner_viewport_scroll_layer_.reset();
// scrollbar_layer_group_* are referenced from overlay_scrollbar_*, thus
// overlay_scrollbar_* must be destroyed before scrollbar_layer_group_*.
overlay_scrollbar_horizontal_.reset();
overlay_scrollbar_vertical_.reset();
scrollbar_layer_group_horizontal_.reset();
scrollbar_layer_group_vertical_.reset();
device_emulation_transform_node_.reset();
overscroll_elasticity_transform_node_.reset();
scale_transform_node_.reset();
translation_transform_node_.reset();
scroll_node_.reset();
horizontal_scrollbar_effect_node_.reset();
vertical_scrollbar_effect_node_.reset();
}
} // namespace blink
......@@ -274,6 +274,8 @@ class CORE_EXPORT VisualViewport final
void SetNeedsPaintPropertyUpdate() { needs_paint_property_update_ = true; }
bool NeedsPaintPropertyUpdate() const { return needs_paint_property_update_; }
void PreFinalize() override;
private:
bool DidSetScaleOrLocation(float scale,
bool is_pinch_gesture_active,
......
......@@ -2912,4 +2912,10 @@ bool PaintLayerScrollableArea::ScrollingBackgroundDisplayItemClient::
->PaintedOutputOfObjectHasNoEffectRegardlessOfSize();
}
void PaintLayerScrollableArea::PreFinalize() {
if (!HasBeenDisposed())
Dispose();
rare_data_.reset();
}
} // namespace blink
......@@ -551,6 +551,8 @@ class CORE_EXPORT PaintLayerScrollableArea final
return scrolling_background_display_item_client_;
}
void PreFinalize() override;
private:
bool NeedsScrollbarReconstruction() const;
......
......@@ -139,6 +139,10 @@ class MockScrollableAreaForAnimatorTest
ScrollableArea::Trace(visitor);
}
virtual void PreFinalize() {
timer_task_runner_.reset();
}
private:
bool scroll_animator_enabled_;
ScrollOffset min_offset_;
......
......@@ -93,10 +93,16 @@ ScrollableArea::ScrollableArea()
needs_show_scrollbar_layers_(false),
uses_composited_scrolling_(false) {}
ScrollableArea::~ScrollableArea() {
ScrollableArea::~ScrollableArea() = default;
void ScrollableArea::Dispose() {
RunScrollCompleteCallbacks();
fade_overlay_scrollbars_timer_.reset();
PreFinalize();
}
void ScrollableArea::PreFinalize() {}
void ScrollableArea::ClearScrollableArea() {
#if defined(OS_MACOSX)
if (scroll_animator_)
......
......@@ -67,6 +67,7 @@ enum IncludeScrollbarsInRect {
class CORE_EXPORT ScrollableArea : public GarbageCollectedMixin {
DISALLOW_COPY_AND_ASSIGN(ScrollableArea);
USING_PRE_FINALIZER(ScrollableArea, Dispose);
public:
using ScrollCallback = base::OnceClosure;
......@@ -349,6 +350,9 @@ class CORE_EXPORT ScrollableArea : public GarbageCollectedMixin {
virtual ~ScrollableArea();
void Dispose();
virtual void PreFinalize();
// Called when any of horizontal scrollbar, vertical scrollbar and scroll
// corner is setNeedsPaintInvalidation.
virtual void ScrollControlWasSetNeedsPaintInvalidation() = 0;
......@@ -389,8 +393,6 @@ class CORE_EXPORT ScrollableArea : public GarbageCollectedMixin {
// for layout movements (bit.ly/scroll-anchoring).
virtual bool ShouldPerformScrollAnchoring() const { return false; }
// Need to promptly let go of owned animator objects.
EAGERLY_FINALIZE();
void Trace(blink::Visitor*) override;
virtual void ClearScrollableArea();
......
......@@ -83,7 +83,9 @@ Scrollbar::Scrollbar(ScrollableArea* scrollable_area,
current_pos_ = ScrollableAreaCurrentPos();
}
Scrollbar::~Scrollbar() {
Scrollbar::~Scrollbar() =default;
void Scrollbar::Dispose() {
theme_.UnregisterScrollbar(*this);
}
......
......@@ -47,6 +47,7 @@ class WebMouseEvent;
class CORE_EXPORT Scrollbar : public GarbageCollectedFinalized<Scrollbar>,
public DisplayItemClient {
USING_PRE_FINALIZER(Scrollbar, Dispose);
public:
// Theme object ownership remains with the caller and it must outlive the
// scrollbar.
......@@ -191,7 +192,7 @@ class CORE_EXPORT Scrollbar : public GarbageCollectedFinalized<Scrollbar>,
// Promptly unregister from the theme manager + run finalizers of derived
// Scrollbars.
EAGERLY_FINALIZE();
void Dispose();
virtual void Trace(blink::Visitor*);
protected:
......
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