Commit dca5ac43 authored by Stefan Zager's avatar Stefan Zager Committed by Commit Bot

Fix for ScrollableArea pre-finalizer CHECK failure

PaintLayer holds a persistent pointer to PaintLayerScrollableArea, so
it's guaranteed that the PaintLayer will be destructed before the PLSA
pre-finalizer is called. PLSA::Dispose is called by the PaintLayer
destructor to clean up state, and this is the appropriate time to run
complex finalizer code such as RunScrollCompleteCallbacks.

The other ScrollableArea sub-classes are RootFrameViewport and
VisualViewport. They only get destructed when the entire page is being
torn down, in which case it's pointless to try and run scroll complete
callbacks; so remove that code path for those classes.

BUG=983809
R=omerkatz@chromium.org,pdr@chromium.org

Change-Id: I28bee057db042ba92bacea62aeeae130b7594fdb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1713593Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Stefan Zager <szager@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680633}
parent 8a896dcc
...@@ -1226,7 +1226,6 @@ void VisualViewport::DisposeImpl() { ...@@ -1226,7 +1226,6 @@ void VisualViewport::DisposeImpl() {
scroll_node_.reset(); scroll_node_.reset();
horizontal_scrollbar_effect_node_.reset(); horizontal_scrollbar_effect_node_.reset();
vertical_scrollbar_effect_node_.reset(); vertical_scrollbar_effect_node_.reset();
ScrollableArea::DisposeImpl();
} }
} // namespace blink } // namespace blink
...@@ -159,7 +159,9 @@ void PaintLayerScrollableArea::DidScroll(const FloatPoint& position) { ...@@ -159,7 +159,9 @@ void PaintLayerScrollableArea::DidScroll(const FloatPoint& position) {
CHECK(!HasBeenDisposed()); CHECK(!HasBeenDisposed());
} }
void PaintLayerScrollableArea::Dispose() { void PaintLayerScrollableArea::DisposeImpl() {
rare_data_.reset();
if (InResizeMode() && !GetLayoutBox()->DocumentBeingDestroyed()) { if (InResizeMode() && !GetLayoutBox()->DocumentBeingDestroyed()) {
if (LocalFrame* frame = GetLayoutBox()->GetFrame()) if (LocalFrame* frame = GetLayoutBox()->GetFrame())
frame->GetEventHandler().ResizeScrollableAreaDestroyed(); frame->GetEventHandler().ResizeScrollableAreaDestroyed();
...@@ -212,11 +214,9 @@ void PaintLayerScrollableArea::Dispose() { ...@@ -212,11 +214,9 @@ void PaintLayerScrollableArea::Dispose() {
if (SmoothScrollSequencer* sequencer = GetSmoothScrollSequencer()) if (SmoothScrollSequencer* sequencer = GetSmoothScrollSequencer())
sequencer->DidDisposeScrollableArea(*this); sequencer->DidDisposeScrollableArea(*this);
layer_ = nullptr; RunScrollCompleteCallbacks();
}
bool PaintLayerScrollableArea::HasBeenDisposed() const { layer_ = nullptr;
return !layer_;
} }
void PaintLayerScrollableArea::Trace(blink::Visitor* visitor) { void PaintLayerScrollableArea::Trace(blink::Visitor* visitor) {
...@@ -2929,11 +2929,4 @@ bool PaintLayerScrollableArea::ScrollingBackgroundDisplayItemClient:: ...@@ -2929,11 +2929,4 @@ bool PaintLayerScrollableArea::ScrollingBackgroundDisplayItemClient::
->PaintedOutputOfObjectHasNoEffectRegardlessOfSize(); ->PaintedOutputOfObjectHasNoEffectRegardlessOfSize();
} }
void PaintLayerScrollableArea::DisposeImpl() {
if (!HasBeenDisposed())
Dispose();
rare_data_.reset();
ScrollableArea::DisposeImpl();
}
} // namespace blink } // namespace blink
...@@ -249,8 +249,6 @@ class CORE_EXPORT PaintLayerScrollableArea final ...@@ -249,8 +249,6 @@ class CORE_EXPORT PaintLayerScrollableArea final
explicit PaintLayerScrollableArea(PaintLayer&); explicit PaintLayerScrollableArea(PaintLayer&);
~PaintLayerScrollableArea() override; ~PaintLayerScrollableArea() override;
void Dispose();
bool HasBeenDisposed() const override;
void ForceVerticalScrollbarForFirstLayout() { SetHasVerticalScrollbar(true); } void ForceVerticalScrollbarForFirstLayout() { SetHasVerticalScrollbar(true); }
bool HasHorizontalScrollbar() const { return HorizontalScrollbar(); } bool HasHorizontalScrollbar() const { return HorizontalScrollbar(); }
...@@ -545,7 +543,7 @@ class CORE_EXPORT PaintLayerScrollableArea final ...@@ -545,7 +543,7 @@ class CORE_EXPORT PaintLayerScrollableArea final
} }
void DisposeImpl() override; void DisposeImpl() override;
private: private:
bool NeedsScrollbarReconstruction() const; bool NeedsScrollbarReconstruction() const;
......
...@@ -138,10 +138,7 @@ class MockScrollableAreaForAnimatorTest ...@@ -138,10 +138,7 @@ class MockScrollableAreaForAnimatorTest
ScrollableArea::Trace(visitor); ScrollableArea::Trace(visitor);
} }
void DisposeImpl() override { void DisposeImpl() override { timer_task_runner_.reset(); }
timer_task_runner_.reset();
ScrollableArea::DisposeImpl();
}
private: private:
bool scroll_animator_enabled_; bool scroll_animator_enabled_;
......
...@@ -90,18 +90,18 @@ ScrollableArea::ScrollableArea() ...@@ -90,18 +90,18 @@ ScrollableArea::ScrollableArea()
scrollbars_hidden_if_overlay_(true), scrollbars_hidden_if_overlay_(true),
scrollbar_captured_(false), scrollbar_captured_(false),
mouse_over_scrollbar_(false), mouse_over_scrollbar_(false),
has_been_disposed_(false),
needs_show_scrollbar_layers_(false), needs_show_scrollbar_layers_(false),
uses_composited_scrolling_(false) {} uses_composited_scrolling_(false) {}
ScrollableArea::~ScrollableArea() = default; ScrollableArea::~ScrollableArea() = default;
void ScrollableArea::Dispose() { void ScrollableArea::Dispose() {
if (HasBeenDisposed())
return;
DisposeImpl(); DisposeImpl();
}
void ScrollableArea::DisposeImpl() {
RunScrollCompleteCallbacks();
fade_overlay_scrollbars_timer_.reset(); fade_overlay_scrollbars_timer_.reset();
has_been_disposed_ = true;
} }
void ScrollableArea::ClearScrollableArea() { void ScrollableArea::ClearScrollableArea() {
...@@ -431,6 +431,7 @@ void ScrollableArea::UpdateScrollOffsetFromInternals(const IntSize& offset) { ...@@ -431,6 +431,7 @@ void ScrollableArea::UpdateScrollOffsetFromInternals(const IntSize& offset) {
} }
void ScrollableArea::RegisterScrollCompleteCallback(ScrollCallback callback) { void ScrollableArea::RegisterScrollCompleteCallback(ScrollCallback callback) {
DCHECK(!HasBeenDisposed());
pending_scroll_complete_callbacks_.push_back(std::move(callback)); pending_scroll_complete_callbacks_.push_back(std::move(callback));
} }
......
...@@ -351,7 +351,7 @@ class CORE_EXPORT ScrollableArea : public GarbageCollectedMixin { ...@@ -351,7 +351,7 @@ class CORE_EXPORT ScrollableArea : public GarbageCollectedMixin {
virtual ~ScrollableArea(); virtual ~ScrollableArea();
void Dispose(); void Dispose();
virtual void DisposeImpl(); virtual void DisposeImpl() {}
// Called when any of horizontal scrollbar, vertical scrollbar and scroll // Called when any of horizontal scrollbar, vertical scrollbar and scroll
// corner is setNeedsPaintInvalidation. // corner is setNeedsPaintInvalidation.
...@@ -465,7 +465,7 @@ class CORE_EXPORT ScrollableArea : public GarbageCollectedMixin { ...@@ -465,7 +465,7 @@ class CORE_EXPORT ScrollableArea : public GarbageCollectedMixin {
// then reset to alpha, causing spurrious "visibilityChanged" calls. // then reset to alpha, causing spurrious "visibilityChanged" calls.
virtual void ScrollbarVisibilityChanged() {} virtual void ScrollbarVisibilityChanged() {}
virtual bool HasBeenDisposed() const { return false; } bool HasBeenDisposed() const { return has_been_disposed_; }
private: private:
FRIEND_TEST_ALL_PREFIXES(ScrollableAreaTest, FRIEND_TEST_ALL_PREFIXES(ScrollableAreaTest,
...@@ -504,6 +504,7 @@ class CORE_EXPORT ScrollableArea : public GarbageCollectedMixin { ...@@ -504,6 +504,7 @@ class CORE_EXPORT ScrollableArea : public GarbageCollectedMixin {
unsigned scrollbars_hidden_if_overlay_ : 1; unsigned scrollbars_hidden_if_overlay_ : 1;
unsigned scrollbar_captured_ : 1; unsigned scrollbar_captured_ : 1;
unsigned mouse_over_scrollbar_ : 1; unsigned mouse_over_scrollbar_ : 1;
unsigned has_been_disposed_ : 1;
// Indicates that the next compositing update needs to call // Indicates that the next compositing update needs to call
// cc::Layer::ShowScrollbars() on our scroll layer. Ignored if not composited. // cc::Layer::ShowScrollbars() on our scroll layer. Ignored if not composited.
......
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