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

DL: Classify tab focus/selection as viewport activations.

This patch updates the activation reasons to classify tab focus and
selection as being viewport activations.

This implements the resolution from:
https://github.com/WICG/display-locking/issues/87

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

Change-Id: I9202713a5b375775a7ac5fd3348d949d8f4a3cdb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1864821
Commit-Queue: vmpstr <vmpstr@chromium.org>
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Auto-Submit: vmpstr <vmpstr@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706657}
parent 8c005939
...@@ -100,7 +100,8 @@ bool DisplayLockUtilities::ActivateSelectionRangeIfNeeded( ...@@ -100,7 +100,8 @@ bool DisplayLockUtilities::ActivateSelectionRangeIfNeeded(
elements_to_activate.insert(nearest_locked_ancestor); elements_to_activate.insert(nearest_locked_ancestor);
} }
for (Element* element : elements_to_activate) { for (Element* element : elements_to_activate) {
element->ActivateDisplayLockIfNeeded(DisplayLockActivationReason::kUser); element->ActivateDisplayLockIfNeeded(
DisplayLockActivationReason::kViewport);
} }
return !elements_to_activate.IsEmpty(); return !elements_to_activate.IsEmpty();
} }
......
...@@ -4041,7 +4041,12 @@ void Element::focus(const FocusParams& params) { ...@@ -4041,7 +4041,12 @@ void Element::focus(const FocusParams& params) {
return; return;
} }
} }
ActivateDisplayLockIfNeeded(DisplayLockActivationReason::kUser); // If script called focus(), then the type would be none. This means we are
// activating because of a script action (kUser). Otherwise, this is a
// viewport activation (kViewport).
ActivateDisplayLockIfNeeded(params.type == kWebFocusTypeNone
? DisplayLockActivationReason::kUser
: DisplayLockActivationReason::kViewport);
DispatchActivateInvisibleEventIfNeeded(); DispatchActivateInvisibleEventIfNeeded();
if (IsInsideInvisibleSubtree()) { if (IsInsideInvisibleSubtree()) {
// The element stays invisible because the default event action is // The element stays invisible because the default event action is
...@@ -4195,7 +4200,7 @@ bool Element::IsKeyboardFocusable() const { ...@@ -4195,7 +4200,7 @@ bool Element::IsKeyboardFocusable() const {
((SupportsFocus() && tabIndex() >= 0) || ((SupportsFocus() && tabIndex() >= 0) ||
(RuntimeEnabledFeatures::KeyboardFocusableScrollersEnabled() && (RuntimeEnabledFeatures::KeyboardFocusableScrollersEnabled() &&
IsScrollableNode(this))) && IsScrollableNode(this))) &&
!DisplayLockPreventsActivation(DisplayLockActivationReason::kUser); !DisplayLockPreventsActivation(DisplayLockActivationReason::kViewport);
} }
bool Element::IsMouseFocusable() const { bool Element::IsMouseFocusable() const {
...@@ -4204,7 +4209,7 @@ bool Element::IsMouseFocusable() const { ...@@ -4204,7 +4209,7 @@ bool Element::IsMouseFocusable() const {
DCHECK(!GetDocument().IsActive() || DCHECK(!GetDocument().IsActive() ||
!GetDocument().NeedsLayoutTreeUpdateForNode(*this)); !GetDocument().NeedsLayoutTreeUpdateForNode(*this));
return isConnected() && !IsInert() && IsFocusableStyle() && SupportsFocus() && return isConnected() && !IsInert() && IsFocusableStyle() && SupportsFocus() &&
!DisplayLockPreventsActivation(DisplayLockActivationReason::kUser); !DisplayLockPreventsActivation(DisplayLockActivationReason::kViewport);
} }
bool Element::IsAutofocusable() const { bool Element::IsAutofocusable() const {
......
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