mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:47:45 +00:00
LibWeb: Implement currentcolor
special value
The `currentcolor` identifier represents the current value of the `color` property. This is the default value for `border-color` and `text-decoration-color`, and is generally useful to have. :^)
This commit is contained in:
parent
86f78bff2a
commit
17bb913625
3 changed files with 9 additions and 0 deletions
|
@ -12,6 +12,7 @@
|
||||||
#g { background-color: rgba(0%, 100%, 0%, 1); }
|
#g { background-color: rgba(0%, 100%, 0%, 1); }
|
||||||
#h { background-color: hsl(120, 100%, 50%); }
|
#h { background-color: hsl(120, 100%, 50%); }
|
||||||
#i { background-color: hsla(120, 100%, 50%, 1); }
|
#i { background-color: hsla(120, 100%, 50%, 1); }
|
||||||
|
#j { color: lime; background-color: currentColor; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -25,5 +26,6 @@
|
||||||
<div id="g">This is green, using rgba(0%, 100%, 0%, 1).</div>
|
<div id="g">This is green, using rgba(0%, 100%, 0%, 1).</div>
|
||||||
<div id="h">This is green, using hsl(120, 100%, 50%).</div>
|
<div id="h">This is green, using hsl(120, 100%, 50%).</div>
|
||||||
<div id="i">This is green, using hsla(120, 100%, 50%, 1).</div>
|
<div id="i">This is green, using hsla(120, 100%, 50%, 1).</div>
|
||||||
|
<div id="j"><span style="color: black;">This is green, using currentcolor.</span></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -82,6 +82,7 @@
|
||||||
"context-menu",
|
"context-menu",
|
||||||
"copy",
|
"copy",
|
||||||
"crosshair",
|
"crosshair",
|
||||||
|
"currentcolor",
|
||||||
"cursive",
|
"cursive",
|
||||||
"dashed",
|
"dashed",
|
||||||
"decimal",
|
"decimal",
|
||||||
|
|
|
@ -33,6 +33,12 @@ String IdentifierStyleValue::to_string() const
|
||||||
|
|
||||||
Color IdentifierStyleValue::to_color(Layout::NodeWithStyle const& node) const
|
Color IdentifierStyleValue::to_color(Layout::NodeWithStyle const& node) const
|
||||||
{
|
{
|
||||||
|
if (id() == CSS::ValueID::Currentcolor) {
|
||||||
|
if (!node.has_style())
|
||||||
|
return Color::Black;
|
||||||
|
return node.computed_values().color();
|
||||||
|
}
|
||||||
|
|
||||||
auto& document = node.document();
|
auto& document = node.document();
|
||||||
if (id() == CSS::ValueID::LibwebLink)
|
if (id() == CSS::ValueID::LibwebLink)
|
||||||
return document.link_color();
|
return document.link_color();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue