LadybirdBrowser / ladybird

Truly independent web browser
https://ladybird.org
BSD 2-Clause "Simplified" License
21.2k stars 921 forks source link

@media with content tag not implemented yet. #362

Open tomFlowee opened 3 months ago

tomFlowee commented 3 months ago

A html file with:

<img src="black.png" id="myImage"/>

and a CSS with:

@media (prefers-color-scheme:dark) {
img#myImage { content: url("white.png"); }
}

The switching of dark or non-dark mode should cause the img tag to load the appropriate image. This does not today happen.

You can see this on a real website on flowee DOT org/index.html (the product logos at the right).

I hope this is a helpful issue report!

AtkinsSJ commented 3 months ago

Hi there!

To clarify, our support for the content CSS property is quite limited. The code that generates an element's contents based on content is here: https://github.com/LadybirdBrowser/ladybird/blob/6c9069fa5d3344f5237b6f734f19c0563fcf6dce/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp#L692

Basically, we support strings, and the quotes-related keywords, but that's all. Definitely needs work! :^)