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(
DisplayLockContext::ScopedForcedUpdate
DisplayLockContext::GetScopedForcedUpdate() {
if (!is_locked_)
return ScopedForcedUpdate(nullptr);
DCHECK(!update_forced_);
update_forced_ = true;
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(
TRACE_DISABLED_BY_DEFAULT("blink.debug.display_lock"), "LockForced",
TRACE_ID_LOCAL(this));
// 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 of
// this, since |update_forced_| doesn't force paint to happen. See
// ShouldPaint().
MarkForStyleRecalcIfNeeded();
MarkForLayoutIfNeeded();
MarkAncestorsForPrePaintIfNeeded();
++update_forced_;
if (update_forced_ == 1) {
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
// prepaint code can reach it via dirty bits. Note that paint isn't a part
// of this, since |update_forced_| doesn't force paint to happen. See
// ShouldPaint().
MarkForStyleRecalcIfNeeded();
MarkForLayoutIfNeeded();
MarkAncestorsForPrePaintIfNeeded();
}
return ScopedForcedUpdate(this);
}
void DisplayLockContext::NotifyForcedUpdateScopeEnded() {
DCHECK(update_forced_);
update_forced_ = false;
TRACE_EVENT_NESTABLE_ASYNC_END0(
TRACE_DISABLED_BY_DEFAULT("blink.debug.display_lock"), "LockForced",
TRACE_ID_LOCAL(this));
--update_forced_;
if (update_forced_ == 0) {
TRACE_EVENT_NESTABLE_ASYNC_END0(
TRACE_DISABLED_BY_DEFAULT("blink.debug.display_lock"), "LockForced",
TRACE_ID_LOCAL(this));
}
}
void DisplayLockContext::Unlock() {
......@@ -605,7 +607,7 @@ bool DisplayLockContext::MarkForLayoutIfNeeded() {
if (IsElementDirtyForLayout()) {
// Forces the marking of ancestors to happen, even if
// |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_) {
// 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
......
......@@ -328,7 +328,8 @@ class CORE_EXPORT DisplayLockContext final
// style recalc on them.
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;
// Signifies whether we've blocked a layout tree reattachment on |element_|'s
......
......@@ -51,8 +51,6 @@ bool UpdateStyleAndLayoutForRangeIfNeeded(const EphemeralRangeInFlatTree& range,
reason)) {
DCHECK(locked_activatable_ancestor->GetDisplayLockContext());
DCHECK(locked_activatable_ancestor->GetDisplayLockContext()->IsLocked());
DCHECK(!locked_activatable_ancestor->GetDisplayLockContext()
->UpdateForced());
scoped_forced_update_list_.push_back(
locked_activatable_ancestor->GetDisplayLockContext()
->GetScopedForcedUpdate());
......@@ -212,10 +210,8 @@ DisplayLockUtilities::ScopedChainForcedUpdate::ScopedChainForcedUpdate(
auto* ancestor_node = DynamicTo<Element>(ancestor);
if (!ancestor_node)
continue;
if (auto* context = ancestor_node->GetDisplayLockContext()) {
DCHECK(!context->UpdateForced());
if (auto* context = ancestor_node->GetDisplayLockContext())
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