Commit bde26372 authored by Vladimir Levin's avatar Vladimir Levin Committed by Commit Bot

Refactor UpdateLifecyclePhasesInternal.

This patch splits ups the four major components of lifecycle updates:
- Style and layout
- Compositing
- PrePaint
- Paint

into separate functions, named similarly to indicate that they are a
part of lifecycle updates.

It also separates various checks and state set up to be in a wrapper
function around UpdateLifecyclePhasesInternal to ensure that the
lifecycle updates themselves are easy to follow.

Also adds comments throughout.

R=chrishtr@chromium.org

Change-Id: I5fb23bd48757866bdb42e49b6d35fa99fa9f8d41
Reviewed-on: https://chromium-review.googlesource.com/1136882
Commit-Queue: vmpstr <vmpstr@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579116}
parent 1352fa13
...@@ -655,6 +655,34 @@ class CORE_EXPORT LocalFrameView final ...@@ -655,6 +655,34 @@ class CORE_EXPORT LocalFrameView final
void NotifyFrameRectsChangedIfNeeded(); void NotifyFrameRectsChangedIfNeeded();
private: private:
#if DCHECK_IS_ON()
class DisallowLayoutInvalidationScope {
public:
DisallowLayoutInvalidationScope(LocalFrameView* view)
: local_frame_view_(view) {
local_frame_view_->allows_layout_invalidation_after_layout_clean_ = false;
local_frame_view_->ForAllChildLocalFrameViews(
[](LocalFrameView& frame_view) {
if (!frame_view.ShouldThrottleRendering())
frame_view.CheckDoesNotNeedLayout();
frame_view.allows_layout_invalidation_after_layout_clean_ = false;
});
}
~DisallowLayoutInvalidationScope() {
local_frame_view_->allows_layout_invalidation_after_layout_clean_ = true;
local_frame_view_->ForAllChildLocalFrameViews(
[](LocalFrameView& frame_view) {
if (!frame_view.ShouldThrottleRendering())
frame_view.CheckDoesNotNeedLayout();
frame_view.allows_layout_invalidation_after_layout_clean_ = true;
});
}
private:
UntracedMember<LocalFrameView> local_frame_view_;
};
#endif
explicit LocalFrameView(LocalFrame&, IntRect); explicit LocalFrameView(LocalFrame&, IntRect);
void PaintInternal(GraphicsContext&, void PaintInternal(GraphicsContext&,
...@@ -669,10 +697,24 @@ class CORE_EXPORT LocalFrameView final ...@@ -669,10 +697,24 @@ class CORE_EXPORT LocalFrameView final
void SetupPrintContext(); void SetupPrintContext();
void ClearPrintContext(); void ClearPrintContext();
// Returns whethre the lifecycle was succesfully updated to the // Returns whether the lifecycle was succesfully updated to the
// target state. // target state.
bool UpdateLifecyclePhasesInternal( bool UpdateLifecyclePhases(DocumentLifecycle::LifecycleState target_state);
// The internal version that does the work after the proper context and checks
// have passed in the above function call.
void UpdateLifecyclePhasesInternal(
DocumentLifecycle::LifecycleState target_state);
// Four lifecycle phases helper functions corresponding to StyleAndLayout,
// Compositing, PrePaint, and Paint phases. If the return value is true, it
// means further lifecycle phases need to be run. This is used to abort
// earlier if we don't need to run future lifecycle phases.
bool RunStyleAndLayoutLifecyclePhases(
DocumentLifecycle::LifecycleState target_state);
bool RunCompositingLifecyclePhase(
DocumentLifecycle::LifecycleState target_state);
bool RunPrePaintLifecyclePhase(
DocumentLifecycle::LifecycleState target_state); DocumentLifecycle::LifecycleState target_state);
void RunPaintLifecyclePhase();
void NotifyFrameRectsChangedIfNeededRecursive(); void NotifyFrameRectsChangedIfNeededRecursive();
void UpdateStyleAndLayoutIfNeededRecursive(); void UpdateStyleAndLayoutIfNeededRecursive();
...@@ -867,8 +909,11 @@ class CORE_EXPORT LocalFrameView final ...@@ -867,8 +909,11 @@ class CORE_EXPORT LocalFrameView final
AnchoringAdjustmentQueue anchoring_adjustment_queue_; AnchoringAdjustmentQueue anchoring_adjustment_queue_;
bool suppress_adjust_view_size_; bool suppress_adjust_view_size_;
bool allows_layout_invalidation_after_layout_clean_; #if DCHECK_IS_ON()
// In DCHECK on builds, this is set to false when we're running lifecycle
// phases past layout to ensure that phases after layout don't dirty layout.
bool allows_layout_invalidation_after_layout_clean_ = true;
#endif
IntersectionObservationState intersection_observation_state_; IntersectionObservationState intersection_observation_state_;
bool needs_forced_compositing_update_; bool needs_forced_compositing_update_;
......
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