Commit 620f0cb1 authored by Stefan Zager's avatar Stefan Zager Committed by Chromium LUCI CQ

Get rid of redundant LocalFrameView::in_lifecycle_update_

Change-Id: I4febb376c13fe82fe2ffcb3efc2dc4a315665b1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2583185Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Stefan Zager <szager@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835550}
parent e2b8f31a
...@@ -256,14 +256,12 @@ LocalFrameView::LocalFrameView(LocalFrame& frame, IntRect frame_rect) ...@@ -256,14 +256,12 @@ LocalFrameView::LocalFrameView(LocalFrame& frame, IntRect frame_rect)
// updates. We can't throttle it here or it seems the root compositor // updates. We can't throttle it here or it seems the root compositor
// doesn't get setup properly. // doesn't get setup properly.
lifecycle_updates_throttled_(!GetFrame().IsMainFrame()), lifecycle_updates_throttled_(!GetFrame().IsMainFrame()),
current_update_lifecycle_phases_target_state_( target_state_(DocumentLifecycle::kUninitialized),
DocumentLifecycle::kUninitialized),
past_layout_lifecycle_update_(false), past_layout_lifecycle_update_(false),
suppress_adjust_view_size_(false), suppress_adjust_view_size_(false),
intersection_observation_state_(kNotNeeded), intersection_observation_state_(kNotNeeded),
needs_forced_compositing_update_(false), needs_forced_compositing_update_(false),
needs_focus_on_fragment_(false), needs_focus_on_fragment_(false),
in_lifecycle_update_(false),
main_thread_scrolling_reasons_(0), main_thread_scrolling_reasons_(0),
forced_layout_stack_depth_(0), forced_layout_stack_depth_(0),
forced_layout_start_time_(base::TimeTicks()), forced_layout_start_time_(base::TimeTicks()),
...@@ -2300,8 +2298,7 @@ bool LocalFrameView::UpdateLifecycleToLayoutClean(DocumentUpdateReason reason) { ...@@ -2300,8 +2298,7 @@ bool LocalFrameView::UpdateLifecycleToLayoutClean(DocumentUpdateReason reason) {
void LocalFrameView::ScheduleVisualUpdateForPaintInvalidationIfNeeded() { void LocalFrameView::ScheduleVisualUpdateForPaintInvalidationIfNeeded() {
LocalFrame& local_frame_root = GetFrame().LocalFrameRoot(); LocalFrame& local_frame_root = GetFrame().LocalFrameRoot();
// We need a full lifecycle update to clear pending paint invalidations. // We need a full lifecycle update to clear pending paint invalidations.
if (local_frame_root.View()->current_update_lifecycle_phases_target_state_ < if (local_frame_root.View()->target_state_ < DocumentLifecycle::kPaintClean ||
DocumentLifecycle::kPaintClean ||
Lifecycle().GetState() >= DocumentLifecycle::kPrePaintClean) { Lifecycle().GetState() >= DocumentLifecycle::kPrePaintClean) {
// Schedule visual update to process the paint invalidation in the next // Schedule visual update to process the paint invalidation in the next
// cycle. // cycle.
...@@ -2412,7 +2409,7 @@ bool LocalFrameView::UpdateLifecyclePhases( ...@@ -2412,7 +2409,7 @@ bool LocalFrameView::UpdateLifecyclePhases(
// with the current lifecycle state to determine which phases are yet to run // with the current lifecycle state to determine which phases are yet to run
// in this cycle. // in this cycle.
base::AutoReset<DocumentLifecycle::LifecycleState> target_state_scope( base::AutoReset<DocumentLifecycle::LifecycleState> target_state_scope(
&current_update_lifecycle_phases_target_state_, target_state); &target_state_, target_state);
// This is used to check if we're within a lifecycle update but have passed // This is used to check if we're within a lifecycle update but have passed
// the layout update phase. Note there is a bit of a subtlety here: it's not // the layout update phase. Note there is a bit of a subtlety here: it's not
// sufficient for us to check the current lifecycle state, since it can be // sufficient for us to check the current lifecycle state, since it can be
...@@ -2422,7 +2419,6 @@ bool LocalFrameView::UpdateLifecyclePhases( ...@@ -2422,7 +2419,6 @@ bool LocalFrameView::UpdateLifecyclePhases(
// separate bool. // separate bool.
base::AutoReset<bool> past_layout_lifecycle_resetter( base::AutoReset<bool> past_layout_lifecycle_resetter(
&past_layout_lifecycle_update_, false); &past_layout_lifecycle_update_, false);
base::AutoReset<bool> in_lifecycle_scope(&in_lifecycle_update_, true);
// If we're throttling, then we don't need to update lifecycle phases. The // If we're throttling, then we don't need to update lifecycle phases. The
// throttling status will get updated in RunPostLifecycleSteps(). // throttling status will get updated in RunPostLifecycleSteps().
...@@ -2673,7 +2669,6 @@ bool LocalFrameView::RunStyleAndLayoutLifecyclePhases( ...@@ -2673,7 +2669,6 @@ bool LocalFrameView::RunStyleAndLayoutLifecyclePhases(
return false; return false;
// This will be reset by AutoReset in the calling function // This will be reset by AutoReset in the calling function
// (UpdateLifecyclePhases()).
past_layout_lifecycle_update_ = true; past_layout_lifecycle_update_ = true;
// After layout and the |past_layout_lifecycle_update_| update, the value of // After layout and the |past_layout_lifecycle_update_| update, the value of
...@@ -4431,7 +4426,7 @@ void LocalFrameView::RenderThrottlingStatusChanged() { ...@@ -4431,7 +4426,7 @@ void LocalFrameView::RenderThrottlingStatusChanged() {
} else if (GetFrame().IsLocalRoot()) { } else if (GetFrame().IsLocalRoot()) {
// By this point, every frame in the local frame tree has become throttled, // By this point, every frame in the local frame tree has become throttled,
// so painting the tree should just clear the previous painted output. // so painting the tree should just clear the previous painted output.
DCHECK(!in_lifecycle_update_); DCHECK(!IsUpdatingLifecycle());
AllowThrottlingScope allow_throtting(*this); AllowThrottlingScope allow_throtting(*this);
RunPaintLifecyclePhase(); RunPaintLifecyclePhase();
} }
...@@ -4525,7 +4520,7 @@ bool LocalFrameView::ShouldThrottleRendering() const { ...@@ -4525,7 +4520,7 @@ bool LocalFrameView::ShouldThrottleRendering() const {
// throttle lifecycle states after layout. Outside of lifecycle updates, // throttle lifecycle states after layout. Outside of lifecycle updates,
// the frame should be considered throttled because it is not fully updating // the frame should be considered throttled because it is not fully updating
// the lifecycle. // the lifecycle.
return !local_frame_root_view->in_lifecycle_update_ || return !local_frame_root_view->IsUpdatingLifecycle() ||
local_frame_root_view->past_layout_lifecycle_update_; local_frame_root_view->past_layout_lifecycle_update_;
} }
......
...@@ -349,8 +349,7 @@ class CORE_EXPORT LocalFrameView final ...@@ -349,8 +349,7 @@ class CORE_EXPORT LocalFrameView final
void WillBeRemovedFromFrame(); void WillBeRemovedFromFrame();
bool IsUpdatingLifecycle() { bool IsUpdatingLifecycle() {
return current_update_lifecycle_phases_target_state_ != return target_state_ != DocumentLifecycle::kUninitialized;
DocumentLifecycle::kUninitialized;
} }
// Run all needed lifecycle stages. After calling this method, all frames will // Run all needed lifecycle stages. After calling this method, all frames will
...@@ -402,7 +401,9 @@ class CORE_EXPORT LocalFrameView final ...@@ -402,7 +401,9 @@ class CORE_EXPORT LocalFrameView final
// desired state. // desired state.
bool UpdateLifecycleToLayoutClean(DocumentUpdateReason reason); bool UpdateLifecycleToLayoutClean(DocumentUpdateReason reason);
void SetInLifecycleUpdateForTest(bool val) { in_lifecycle_update_ = val; } void SetTargetStateForTest(DocumentLifecycle::LifecycleState state) {
target_state_ = state;
}
// This for doing work that needs to run synchronously at the end of lifecyle // This for doing work that needs to run synchronously at the end of lifecyle
// updates, but needs to happen outside of the lifecycle code. It's OK to // updates, but needs to happen outside of the lifecycle code. It's OK to
...@@ -1072,8 +1073,7 @@ class CORE_EXPORT LocalFrameView final ...@@ -1072,8 +1073,7 @@ class CORE_EXPORT LocalFrameView final
bool allow_throttling_ = false; bool allow_throttling_ = false;
// This is set on the local root frame view only. // This is set on the local root frame view only.
DocumentLifecycle::LifecycleState DocumentLifecycle::LifecycleState target_state_;
current_update_lifecycle_phases_target_state_;
bool past_layout_lifecycle_update_; bool past_layout_lifecycle_update_;
using AnchoringAdjustmentQueue = using AnchoringAdjustmentQueue =
...@@ -1092,7 +1092,6 @@ class CORE_EXPORT LocalFrameView final ...@@ -1092,7 +1092,6 @@ class CORE_EXPORT LocalFrameView final
bool needs_forced_compositing_update_; bool needs_forced_compositing_update_;
bool needs_focus_on_fragment_; bool needs_focus_on_fragment_;
bool in_lifecycle_update_;
// True if the frame has deferred commits at least once per document load. // True if the frame has deferred commits at least once per document load.
// We won't defer again for the same document. // We won't defer again for the same document.
......
...@@ -197,10 +197,12 @@ TEST_P(FrameThrottlingTest, IntersectionObservationOverridesThrottling) { ...@@ -197,10 +197,12 @@ TEST_P(FrameThrottlingTest, IntersectionObservationOverridesThrottling) {
inner_frame_document->View()->SetIntersectionObservationState( inner_frame_document->View()->SetIntersectionObservationState(
LocalFrameView::kRequired); LocalFrameView::kRequired);
{ {
GetDocument().GetFrame()->View()->SetInLifecycleUpdateForTest(true); GetDocument().GetFrame()->View()->SetTargetStateForTest(
DocumentLifecycle::kPaintClean);
EXPECT_FALSE( EXPECT_FALSE(
inner_frame_document->View()->ShouldThrottleRenderingForTest()); inner_frame_document->View()->ShouldThrottleRenderingForTest());
GetDocument().GetFrame()->View()->SetInLifecycleUpdateForTest(false); GetDocument().GetFrame()->View()->SetTargetStateForTest(
DocumentLifecycle::kUninitialized);
} }
inner_frame_document->View()->ScheduleAnimation(); inner_frame_document->View()->ScheduleAnimation();
...@@ -353,9 +355,11 @@ TEST_P(FrameThrottlingTest, ...@@ -353,9 +355,11 @@ TEST_P(FrameThrottlingTest,
LocalFrameView::kRequired); LocalFrameView::kRequired);
EXPECT_TRUE(frame_document->View()->ShouldThrottleRenderingForTest()); EXPECT_TRUE(frame_document->View()->ShouldThrottleRenderingForTest());
{ {
GetDocument().GetFrame()->View()->SetInLifecycleUpdateForTest(true); GetDocument().GetFrame()->View()->SetTargetStateForTest(
DocumentLifecycle::kPaintClean);
EXPECT_FALSE(frame_document->View()->ShouldThrottleRenderingForTest()); EXPECT_FALSE(frame_document->View()->ShouldThrottleRenderingForTest());
GetDocument().GetFrame()->View()->SetInLifecycleUpdateForTest(false); GetDocument().GetFrame()->View()->SetTargetStateForTest(
DocumentLifecycle::kUninitialized);
} }
// A lifecycle update can update the throttled frame to just LayoutClean but // A lifecycle update can update the throttled frame to just LayoutClean but
......
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