Skip to content

Commit

Permalink
Make :-webkit-full-screen-document an internal pseudo-class
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=268234
rdar://121816310

Reviewed by Darin Adler.

The main use of this is the UA stylesheet. Websites can use `:root:is(:fullscreen, :has(:fullscreen))` to achieve the same effect.

Let's attempt to unexpose this pseudo-class.

Also change 'full-screen' to 'fullscreen' for consistency with spec language.

* LayoutTests/fullscreen/full-screen-css.html:
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/parsing/invalid-pseudos-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/parsing/invalid-pseudos.html:
* ManualTests/fullscreen/full-screen-flash.html:
* Source/WebCore/Modules/modern-media-controls/controls/media-controls.css:
(:host(:-internal-animating-fullscreen-transition) .media-controls):
(:host(:-internal-animating-full-screen-transition) .media-controls): Deleted.
* Source/WebCore/css/CSSPseudoSelectors.json:
* Source/WebCore/css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOne const):
* Source/WebCore/css/SelectorCheckerTestFunctions.h:
(WebCore::matchesAnimatingFullscreenTransitionPseudoClass):
(WebCore::matchesFullscreenDocumentPseudoClass):
(WebCore::matchesFullScreenAnimatingFullScreenTransitionPseudoClass): Deleted.
(WebCore::matchesFullScreenDocumentPseudoClass): Deleted.
* Source/WebCore/css/fullscreen.css:
(*|*:root:-internal-fullscreen-document:not(:fullscreen)):
(*|*:root:-webkit-full-screen-document:not(:fullscreen)): Deleted.
* Source/WebCore/css/process-css-pseudo-selectors.py:
* Source/WebCore/cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::JSC_DEFINE_JIT_OPERATION):
(WebCore::SelectorCompiler::addPseudoClassType):
* Source/WebCore/dom/FullscreenManager.cpp:
(WebCore::FullscreenManager::setAnimatingFullscreen):
* Source/WebCore/html/shadow/imageOverlay.css:
(:host(:not(img)) div#image-overlay:-internal-fullscreen-document):
(:host(:not(img)) div#image-overlay:-webkit-full-screen-document): Deleted.

Canonical link: https://commits.webkit.org/273639@main
  • Loading branch information
nt1m committed Jan 29, 2024
1 parent afcd2a1 commit 7057889
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 33 deletions.
2 changes: 1 addition & 1 deletion LayoutTests/fullscreen/full-screen-css.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<script src="full-screen-test.js"></script>
<style>
:-webkit-full-screen { background: lime; }
:-webkit-full-screen-document { color: blue; }
:root:is(:fullscreen, :has(:fullscreen)) { color: blue; }
</style>
<span></span>
<script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@

PASS ":-internal-animating-full-screen-transition" should be an invalid selector
PASS ":-internal-fullscreen-document" should be an invalid selector
PASS ":-internal-html-document" should be an invalid selector
PASS ":-internal-media-document" should be an invalid selector
PASS ":-khtml-drag" should be an invalid selector
PASS ":-webkit-animating-full-screen-transition" should be an invalid selector
PASS ":-webkit-full-page-media" should be an invalid selector
PASS ":-webkit-full-screen-ancestor" should be an invalid selector
PASS ":-webkit-full-screen-controls-hidden" should be an invalid selector
PASS ":-webkit-full-screen-document" should be an invalid selector
PASS "::-apple-attachment-controls-container" should be an invalid selector
PASS "::-internal-loading-auto-fill-button" should be an invalid selector

Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@
<script>
// Pseudo-classes
test_invalid_selector(":-internal-animating-full-screen-transition");
test_invalid_selector(":-internal-fullscreen-document");
test_invalid_selector(":-internal-html-document");
test_invalid_selector(":-internal-media-document");
test_invalid_selector(":-khtml-drag");
test_invalid_selector(":-webkit-animating-full-screen-transition");
test_invalid_selector(":-webkit-full-page-media");
test_invalid_selector(":-webkit-full-screen-ancestor");
test_invalid_selector(":-webkit-full-screen-controls-hidden");
test_invalid_selector(":-webkit-full-screen-document");

// Pseudo-elements
test_invalid_selector("::-apple-attachment-controls-container");
Expand Down
2 changes: 1 addition & 1 deletion ManualTests/fullscreen/full-screen-flash.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<style>
body { background: green; color: white; }
document:-webkit-full-screen-document > body { background: red; }
:root:has(:fullscreen) > body { background: red; }
span { text-decoration: underline; cursor: hand; }
div {
background: blue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
transform-origin: 0 0;
}

:host(:-internal-animating-full-screen-transition) .media-controls {
:host(:-internal-animating-fullscreen-transition) .media-controls {
display: none;
}

Expand Down
10 changes: 4 additions & 6 deletions Source/WebCore/css/CSSPseudoSelectors.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
"conditional": "ENABLE(ATTACHMENT_ELEMENT)",
"settings-flag": "DeprecatedGlobalSettings::attachmentElementEnabled"
},
"-internal-animating-full-screen-transition": {
"-internal-animating-fullscreen-transition": {
"conditional": "ENABLE(FULLSCREEN_API)"
},
"-internal-fullscreen-document": {
"conditional": "ENABLE(FULLSCREEN_API)"
},
"-internal-html-document": {},
Expand All @@ -68,11 +71,6 @@
"comment": "Currently has no standard equivalent.",
"status": "non-standard"
},
"-webkit-full-screen-document": {
"comment": "For UA stylesheet use.",
"conditional": "ENABLE(FULLSCREEN_API)",
"status": "non-standard"
},
"active": {},
"any-link": {
"aliases": [
Expand Down
8 changes: 4 additions & 4 deletions Source/WebCore/css/SelectorChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1051,10 +1051,10 @@ bool SelectorChecker::checkOne(CheckingContext& checkingContext, const LocalCont
#if ENABLE(FULLSCREEN_API)
case CSSSelector::PseudoClass::Fullscreen:
return matchesFullscreenPseudoClass(element);
case CSSSelector::PseudoClass::InternalAnimatingFullScreenTransition:
return matchesFullScreenAnimatingFullScreenTransitionPseudoClass(element);
case CSSSelector::PseudoClass::WebKitFullScreenDocument:
return matchesFullScreenDocumentPseudoClass(element);
case CSSSelector::PseudoClass::InternalAnimatingFullscreenTransition:
return matchesAnimatingFullscreenTransitionPseudoClass(element);
case CSSSelector::PseudoClass::InternalFullscreenDocument:
return matchesFullscreenDocumentPseudoClass(element);
#endif
#if ENABLE(PICTURE_IN_PICTURE_API)
case CSSSelector::PseudoClass::PictureInPicture:
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/css/SelectorCheckerTestFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,15 +416,15 @@ ALWAYS_INLINE bool matchesFullscreenPseudoClass(const Element& element)
return false;
}

ALWAYS_INLINE bool matchesFullScreenAnimatingFullScreenTransitionPseudoClass(const Element& element)
ALWAYS_INLINE bool matchesAnimatingFullscreenTransitionPseudoClass(const Element& element)
{
CheckedPtr fullscreenManager = element.document().fullscreenManagerIfExists();
if (!fullscreenManager || &element != fullscreenManager->currentFullscreenElement())
return false;
return fullscreenManager->isAnimatingFullscreen();
}

ALWAYS_INLINE bool matchesFullScreenDocumentPseudoClass(const Element& element)
ALWAYS_INLINE bool matchesFullscreenDocumentPseudoClass(const Element& element)
{
// While a Document is in the fullscreen state, the 'full-screen-document' pseudoclass applies
// to all elements of that Document.
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/css/fullscreen.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
object-fit: contain;
}

*|*:root:-webkit-full-screen-document:not(:fullscreen) {
*|*:root:-internal-fullscreen-document:not(:fullscreen) {
overflow: hidden !important;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/css/process-css-pseudo-selectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
# - an `-internal-` prefix for things only meant to be styled in the user agent stylesheet
# - an `-apple-` prefix only exposed to certain Apple clients (there is a settings-flag requirement for using this prefix)
WEBKIT_PREFIX_COUNTS_DO_NOT_INCREASE = {
'pseudo-classes': 6,
'pseudo-classes': 5,
'pseudo-elements': 59,
}

Expand Down
28 changes: 14 additions & 14 deletions Source/WebCore/cssjit/SelectorCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ using PseudoClassesSet = HashSet<CSSSelector::PseudoClass, IntHash<CSSSelector::
v(operationIsValid) \
v(operationIsWindowInactive) \
v(operationMatchesFullscreenPseudoClass) \
v(operationMatchesFullScreenDocumentPseudoClass) \
v(operationMatchesFullScreenAnimatingFullScreenTransitionPseudoClass) \
v(operationMatchesFullscreenDocumentPseudoClass) \
v(operationMatchesAnimatingFullscreenTransitionPseudoClass) \
v(operationMatchesPictureInPicturePseudoClass) \
v(operationMatchesFutureCuePseudoClass) \
v(operationMatchesPastCuePseudoClass) \
Expand Down Expand Up @@ -255,8 +255,8 @@ static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationMatchesDir, bool,
static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationMatchesLangPseudoClass, bool, (const Element&, const FixedVector<PossiblyQuotedIdentifier>&));
#if ENABLE(FULLSCREEN_API)
static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationMatchesFullscreenPseudoClass, bool, (const Element&));
static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationMatchesFullScreenDocumentPseudoClass, bool, (const Element&));
static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationMatchesFullScreenAnimatingFullScreenTransitionPseudoClass, bool, (const Element&));
static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationMatchesFullscreenDocumentPseudoClass, bool, (const Element&));
static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationMatchesAnimatingFullscreenTransitionPseudoClass, bool, (const Element&));
#endif
#if ENABLE(PICTURE_IN_PICTURE_API)
static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationMatchesPictureInPicturePseudoClass, bool, (const Element&));
Expand Down Expand Up @@ -897,16 +897,16 @@ JSC_DEFINE_JIT_OPERATION(operationMatchesFullscreenPseudoClass, bool, (const Ele
return matchesFullscreenPseudoClass(element);
}

JSC_DEFINE_JIT_OPERATION(operationMatchesFullScreenDocumentPseudoClass, bool, (const Element& element))
JSC_DEFINE_JIT_OPERATION(operationMatchesFullscreenDocumentPseudoClass, bool, (const Element& element))
{
COUNT_SELECTOR_OPERATION(operationMatchesFullScreenDocumentPseudoClass);
return matchesFullScreenDocumentPseudoClass(element);
COUNT_SELECTOR_OPERATION(operationMatchesFullscreenDocumentPseudoClass);
return matchesFullscreenDocumentPseudoClass(element);
}

JSC_DEFINE_JIT_OPERATION(operationMatchesFullScreenAnimatingFullScreenTransitionPseudoClass, bool, (const Element& element))
JSC_DEFINE_JIT_OPERATION(operationMatchesAnimatingFullscreenTransitionPseudoClass, bool, (const Element& element))
{
COUNT_SELECTOR_OPERATION(operationMatchesFullScreenAnimatingFullScreenTransitionPseudoClass);
return matchesFullScreenAnimatingFullScreenTransitionPseudoClass(element);
COUNT_SELECTOR_OPERATION(operationMatchesAnimatingFullscreenTransitionPseudoClass);
return matchesAnimatingFullscreenTransitionPseudoClass(element);
}
#endif

Expand Down Expand Up @@ -1100,11 +1100,11 @@ static inline FunctionType addPseudoClassType(const CSSSelector& selector, Selec
case CSSSelector::PseudoClass::Fullscreen:
fragment.unoptimizedPseudoClasses.append(CodePtr<JSC::OperationPtrTag>(operationMatchesFullscreenPseudoClass));
return FunctionType::SimpleSelectorChecker;
case CSSSelector::PseudoClass::WebKitFullScreenDocument:
fragment.unoptimizedPseudoClasses.append(CodePtr<JSC::OperationPtrTag>(operationMatchesFullScreenDocumentPseudoClass));
case CSSSelector::PseudoClass::InternalFullscreenDocument:
fragment.unoptimizedPseudoClasses.append(CodePtr<JSC::OperationPtrTag>(operationMatchesFullscreenDocumentPseudoClass));
return FunctionType::SimpleSelectorChecker;
case CSSSelector::PseudoClass::InternalAnimatingFullScreenTransition:
fragment.unoptimizedPseudoClasses.append(CodePtr<JSC::OperationPtrTag>(operationMatchesFullScreenAnimatingFullScreenTransitionPseudoClass));
case CSSSelector::PseudoClass::InternalAnimatingFullscreenTransition:
fragment.unoptimizedPseudoClasses.append(CodePtr<JSC::OperationPtrTag>(operationMatchesAnimatingFullscreenTransitionPseudoClass));
return FunctionType::SimpleSelectorChecker;
#endif

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/dom/FullscreenManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ void FullscreenManager::setAnimatingFullscreen(bool flag)

std::optional<Style::PseudoClassChangeInvalidation> styleInvalidation;
if (m_fullscreenElement)
emplace(styleInvalidation, *m_fullscreenElement, { { CSSSelector::PseudoClass::InternalAnimatingFullScreenTransition, flag } });
emplace(styleInvalidation, *m_fullscreenElement, { { CSSSelector::PseudoClass::InternalAnimatingFullscreenTransition, flag } });
m_isAnimatingFullscreen = flag;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/html/shadow/imageOverlay.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ div#image-overlay {
font-family: system-ui;
}

:host(:not(img)) div#image-overlay:-webkit-full-screen-document {
:host(:not(img)) div#image-overlay:-internal-fullscreen-document {
display: none;
}

Expand Down

0 comments on commit 7057889

Please sign in to comment.