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

SubtreeVisibility: Allow scoped force locks to force the same lock.

This patch allows the existing locks to be forced multiple times by
keeping count of how many times to force them.

R=cbiesinger@chromium.org, chrishtr@chromium.org

Change-Id: Ieccb60f9698edcb5aad2b57792a53f164563fae4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2144618Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Commit-Queue: vmpstr <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758835}
parent 1e651190
...@@ -449,31 +449,33 @@ bool DisplayLockContext::ShouldCommitForActivation( ...@@ -449,31 +449,33 @@ bool DisplayLockContext::ShouldCommitForActivation(
DisplayLockContext::ScopedForcedUpdate DisplayLockContext::ScopedForcedUpdate
DisplayLockContext::GetScopedForcedUpdate() { DisplayLockContext::GetScopedForcedUpdate() {
if (!is_locked_) ++update_forced_;
return ScopedForcedUpdate(nullptr); if (update_forced_ == 1) {
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(
DCHECK(!update_forced_); TRACE_DISABLED_BY_DEFAULT("blink.debug.display_lock"), "LockForced",
update_forced_ = true; TRACE_ID_LOCAL(this));
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0( }
TRACE_DISABLED_BY_DEFAULT("blink.debug.display_lock"), "LockForced",
TRACE_ID_LOCAL(this)); if (IsLocked()) {
// Now that the update is forced, we should ensure that style layout, and
// Now that the update is forced, we should ensure that style layout, and // prepaint code can reach it via dirty bits. Note that paint isn't a part
// prepaint code can reach it via dirty bits. Note that paint isn't a part of // of this, since |update_forced_| doesn't force paint to happen. See
// this, since |update_forced_| doesn't force paint to happen. See // ShouldPaint().
// ShouldPaint(). MarkForStyleRecalcIfNeeded();
MarkForStyleRecalcIfNeeded(); MarkForLayoutIfNeeded();
MarkForLayoutIfNeeded(); MarkAncestorsForPrePaintIfNeeded();
MarkAncestorsForPrePaintIfNeeded(); }
return ScopedForcedUpdate(this); return ScopedForcedUpdate(this);
} }
void DisplayLockContext::NotifyForcedUpdateScopeEnded() { void DisplayLockContext::NotifyForcedUpdateScopeEnded() {
DCHECK(update_forced_); DCHECK(update_forced_);
update_forced_ = false; --update_forced_;
TRACE_EVENT_NESTABLE_ASYNC_END0( if (update_forced_ == 0) {
TRACE_DISABLED_BY_DEFAULT("blink.debug.display_lock"), "LockForced", TRACE_EVENT_NESTABLE_ASYNC_END0(
TRACE_ID_LOCAL(this)); TRACE_DISABLED_BY_DEFAULT("blink.debug.display_lock"), "LockForced",
TRACE_ID_LOCAL(this));
}
} }
void DisplayLockContext::Unlock() { void DisplayLockContext::Unlock() {
...@@ -605,7 +607,7 @@ bool DisplayLockContext::MarkForLayoutIfNeeded() { ...@@ -605,7 +607,7 @@ bool DisplayLockContext::MarkForLayoutIfNeeded() {
if (IsElementDirtyForLayout()) { if (IsElementDirtyForLayout()) {
// Forces the marking of ancestors to happen, even if // Forces the marking of ancestors to happen, even if
// |DisplayLockContext::ShouldLayout()| returns false. // |DisplayLockContext::ShouldLayout()| returns false.
base::AutoReset<bool> scoped_force(&update_forced_, true); base::AutoReset<int> scoped_force(&update_forced_, update_forced_ + 1);
if (child_layout_was_blocked_) { if (child_layout_was_blocked_) {
// We've previously blocked a child traversal when doing self-layout for // We've previously blocked a child traversal when doing self-layout for
// the locked element, so we're marking it with child-needs-layout so that // the locked element, so we're marking it with child-needs-layout so that
......
...@@ -328,7 +328,8 @@ class CORE_EXPORT DisplayLockContext final ...@@ -328,7 +328,8 @@ class CORE_EXPORT DisplayLockContext final
// style recalc on them. // style recalc on them.
HeapHashSet<Member<Element>> whitespace_reattach_set_; HeapHashSet<Member<Element>> whitespace_reattach_set_;
bool update_forced_ = false; // If non-zero, then the update has been forced.
int update_forced_ = 0;
StyleType blocked_style_traversal_type_ = kStyleUpdateNotRequired; StyleType blocked_style_traversal_type_ = kStyleUpdateNotRequired;
// Signifies whether we've blocked a layout tree reattachment on |element_|'s // Signifies whether we've blocked a layout tree reattachment on |element_|'s
......
...@@ -51,8 +51,6 @@ bool UpdateStyleAndLayoutForRangeIfNeeded(const EphemeralRangeInFlatTree& range, ...@@ -51,8 +51,6 @@ bool UpdateStyleAndLayoutForRangeIfNeeded(const EphemeralRangeInFlatTree& range,
reason)) { reason)) {
DCHECK(locked_activatable_ancestor->GetDisplayLockContext()); DCHECK(locked_activatable_ancestor->GetDisplayLockContext());
DCHECK(locked_activatable_ancestor->GetDisplayLockContext()->IsLocked()); DCHECK(locked_activatable_ancestor->GetDisplayLockContext()->IsLocked());
DCHECK(!locked_activatable_ancestor->GetDisplayLockContext()
->UpdateForced());
scoped_forced_update_list_.push_back( scoped_forced_update_list_.push_back(
locked_activatable_ancestor->GetDisplayLockContext() locked_activatable_ancestor->GetDisplayLockContext()
->GetScopedForcedUpdate()); ->GetScopedForcedUpdate());
...@@ -212,10 +210,8 @@ DisplayLockUtilities::ScopedChainForcedUpdate::ScopedChainForcedUpdate( ...@@ -212,10 +210,8 @@ DisplayLockUtilities::ScopedChainForcedUpdate::ScopedChainForcedUpdate(
auto* ancestor_node = DynamicTo<Element>(ancestor); auto* ancestor_node = DynamicTo<Element>(ancestor);
if (!ancestor_node) if (!ancestor_node)
continue; continue;
if (auto* context = ancestor_node->GetDisplayLockContext()) { if (auto* context = ancestor_node->GetDisplayLockContext())
DCHECK(!context->UpdateForced());
scoped_update_forced_list_.push_back(context->GetScopedForcedUpdate()); scoped_update_forced_list_.push_back(context->GetScopedForcedUpdate());
}
} }
} }
......
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