Bug 177612 - :-webkit-full-screen fails when there are other fullscreen-selectors in the same rule
Summary: :-webkit-full-screen fails when there are other fullscreen-selectors in the s...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Mac macOS 10.12
: P2 Normal
Assignee: Nobody
URL: https://codepen.io/anon/pen/WZjYbR
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-09-28 11:42 PDT by Oliver
Modified: 2022-07-15 14:18 PDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver 2017-09-28 11:42:24 PDT
The :-webkit-full-screen pseudo-class only works when the rule that contains it has no other fullscreen-related selectors. Consider the following HTML code:

<div id="el">This should be green in fullscreen mode</div>
<button onclick="document.getElementById('el').webkitRequestFullScreen()">Switch to full screen</button>

along with the following CSS code:

div#el {
  background: red;
}

div#el:-webkit-full-screen {
  background: green;
}

This works just fine. When switching to fullscreen, the DIV turns green as expected. Now we add another selector:

div#el:-webkit-full-screen, div#el:fullscreen {
  background: green;
}

Upon entering fullscreen, the DIV will remain red, the rule has no effect anymore. The following, however, will work:

div#el:-webkit-full-screen {
  background: green;
}

div#el:fullscreen {
  background: green;
}

For further reference, I've added a list below of CSS rules that will fail and some more that will succeed. There is also a Codepen with this code: https://codepen.io/anon/pen/WZjYbR

Since browser support is not yet consistent (i.e. -webkit-full-screen for Webkit/Edge, -moz-full-screen for Gecko, -ms-fullscreen for IE/Edge, :fullscreen as the W3C standard), it is very common to have all selectors in one rule so as not to repeat code. I would suggest that this be fixed or, better even, that the W3C suggestion be implemented.

More failure modes:

---
div#el:-webkit-full-screen, div#el:-moz-full-screen {
  background: green;
}
---
div#el:-webkit-full-screen, div#el:-ms-fullscreen {
  background: green;
}
---
div#el:-webkit-full-screen, div#el:fullscreen, div#el:-ms-fullscreen {
  background: green;
}
---

But this works:

---
div#el:-webkit-full-screen, div#el:hover {
  background: green;
}
---
div#el:-webkit-full-screen, button {
  background: green;
}
---
Comment 1 Brent Fulgham 2022-07-15 14:17:55 PDT
This doesn't work properly in Safari 15.5+.
Comment 2 Radar WebKit Bug Importer 2022-07-15 14:18:05 PDT
<rdar://problem/97093881>