Skip to content

Commit 8884dd6

Browse files
author
Swarup Ukil
committed
Bug 1956140 - Implement active-view-transition pseudo class. r=view-transitions-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D253061
1 parent c853ad4 commit 8884dd6

10 files changed

Lines changed: 21 additions & 8 deletions

File tree

dom/base/Document.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18494,6 +18494,12 @@ already_AddRefed<ViewTransition> Document::StartViewTransition(
1849418494
// Step 6: Set document's active view transition to transition.
1849518495
mActiveViewTransition = transition;
1849618496

18497+
// Enable :active-view-transition to allow associated styles to
18498+
// be applied during the view transition.
18499+
if (auto* root = this->GetRootElement()) {
18500+
root->AddStates(ElementState::ACTIVE_VIEW_TRANSITION);
18501+
}
18502+
1849718503
EnsureViewTransitionOperationsHappen();
1849818504

1849918505
// Step 7: return transition

dom/base/rust/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ bitflags! {
137137
/// https://drafts.csswg.org/selectors-4/#open-state
138138
/// Match whether an openable element is currently open
139139
const OPEN = 1u64 << 49;
140+
/// For :active-view-transition.
141+
/// <https://www.w3.org/TR/css-view-transitions-2/#the-active-view-transition-pseudo>
142+
const ACTIVE_VIEW_TRANSITION = 1u64 << 50;
140143

141144
/// Some convenience unions.
142145
const DIR_STATES = Self::LTR.bits() | Self::RTL.bits();

dom/view-transitions/ViewTransition.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,12 @@ void ViewTransition::ClearActiveTransition(bool aIsDocumentHidden) {
14741474
MOZ_ASSERT(mDocument);
14751475
MOZ_ASSERT(mDocument->GetActiveViewTransition() == this);
14761476

1477+
// Ensure that any styles associated with :active-view-transition no longer
1478+
// apply.
1479+
if (auto* root = mDocument->GetRootElement()) {
1480+
root->RemoveStates(ElementState::ACTIVE_VIEW_TRANSITION);
1481+
}
1482+
14771483
// Step 3
14781484
ClearNamedElements();
14791485

servo/components/style/gecko/non_ts_pseudo_class_list.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ macro_rules! apply_non_ts_list {
4545
("focus-visible", FocusVisible, FOCUSRING, _),
4646
("has-slotted", HasSlotted, HAS_SLOTTED, _),
4747
("hover", Hover, HOVER, _),
48+
("active-view-transition", ActiveViewTransition, ACTIVE_VIEW_TRANSITION, _),
4849
("-moz-drag-over", MozDragOver, DRAGOVER, _),
4950
("target", Target, URLTARGET, _),
5051
("indeterminate", Indeterminate, INDETERMINATE, _),

servo/components/style/gecko/selector_parser.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ impl NonTSPseudoClass {
157157
if matches!(*self, Self::HasSlotted) {
158158
return static_prefs::pref!("layout.css.has-slotted-selector.enabled");
159159
}
160+
if matches!(*self, Self::ActiveViewTransition) {
161+
return static_prefs::pref!("dom.viewTransitions.enabled");
162+
}
160163
!self.has_any_flag(NonTSPseudoClassFlag::PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME)
161164
}
162165

servo/components/style/gecko/wrapper.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,6 +2098,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
20982098
NonTSPseudoClass::HasSlotted |
20992099
NonTSPseudoClass::MozAutofillPreview |
21002100
NonTSPseudoClass::MozRevealed |
2101+
NonTSPseudoClass::ActiveViewTransition |
21012102
NonTSPseudoClass::MozValueEmpty => self.state().intersects(pseudo_class.state_flag()),
21022103
NonTSPseudoClass::Dir(ref dir) => self.state().intersects(dir.element_state()),
21032104
NonTSPseudoClass::AnyLink => self.is_link(),
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
prefs: [layout.css.details-content.enabled:true]
1+
prefs: [layout.css.details-content.enabled:true, dom.viewTransitions.enabled:true]

testing/web-platform/meta/css/css-shadow-parts/pseudo-classes-after-part.html.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,5 @@
2020
["::part(mypart):has(:hover)" should be an invalid selector]
2121
expected: FAIL
2222

23-
["::part(mypart):active-view-transition" should be a valid selector]
24-
expected: FAIL
25-
2623
["::part(mypart):active-view-transition-type(mytype)" should be a valid selector]
2724
expected: FAIL

testing/web-platform/meta/css/css-view-transitions/active-view-transition-on-non-root.html.ini

Lines changed: 0 additions & 2 deletions
This file was deleted.

testing/web-platform/meta/css/css-view-transitions/active-view-transition-pseudo-class-match.html.ini

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)