mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 21:59:07 +00:00
LibWeb/Painting: Keep alpha for inset/outset border colors
Also return the original color when needed, instead of reconstructing it from HSV.
This commit is contained in:
parent
408694ab4f
commit
c7166527ce
Notes:
github-actions[bot]
2025-07-02 13:17:10 +00:00
Author: https://github.com/AtkinsSJ
Commit: c7166527ce
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5271
Reviewed-by: https://github.com/gmta ✅
3 changed files with 44 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Andreas Kling <andreas@ladybird.org>
|
* Copyright (c) 2020, Andreas Kling <andreas@ladybird.org>
|
||||||
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
* Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
|
||||||
* Copyright (c) 2022, MacDue <macdue@dueutil.tech>
|
* Copyright (c) 2022, MacDue <macdue@dueutil.tech>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
@ -20,16 +20,20 @@ static Color light_color_for_inset_and_outset(Color const& color)
|
||||||
{
|
{
|
||||||
auto hsv = color.to_hsv();
|
auto hsv = color.to_hsv();
|
||||||
if (hsv.value >= dark_light_absolute_value_difference)
|
if (hsv.value >= dark_light_absolute_value_difference)
|
||||||
return Color::from_hsv(hsv);
|
return color;
|
||||||
return Color::from_hsv({ hsv.hue, hsv.saturation, hsv.value + dark_light_absolute_value_difference });
|
auto result = Color::from_hsv({ hsv.hue, hsv.saturation, hsv.value + dark_light_absolute_value_difference });
|
||||||
|
result.set_alpha(color.alpha());
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Color dark_color_for_inset_and_outset(Color const& color)
|
static Color dark_color_for_inset_and_outset(Color const& color)
|
||||||
{
|
{
|
||||||
auto hsv = color.to_hsv();
|
auto hsv = color.to_hsv();
|
||||||
if (hsv.value < dark_light_absolute_value_difference)
|
if (hsv.value < dark_light_absolute_value_difference)
|
||||||
return Color::from_hsv(hsv);
|
return color;
|
||||||
return Color::from_hsv({ hsv.hue, hsv.saturation, hsv.value - dark_light_absolute_value_difference });
|
auto result = Color::from_hsv({ hsv.hue, hsv.saturation, hsv.value - dark_light_absolute_value_difference });
|
||||||
|
result.set_alpha(color.alpha());
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::Color border_color(BorderEdge edge, BordersDataDevicePixels const& borders_data)
|
Gfx::Color border_color(BorderEdge edge, BordersDataDevicePixels const& borders_data)
|
||||||
|
|
17
Tests/LibWeb/Ref/expected/css/transparent-borders-ref.html
Normal file
17
Tests/LibWeb/Ref/expected/css/transparent-borders-ref.html
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<link rel="match" href="../../expected/css/transparent-borders-ref.html" />
|
||||||
|
<style>
|
||||||
|
.example {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
background: orange;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="example"></div>
|
||||||
|
<div class="example"></div>
|
||||||
|
<div class="example"></div>
|
||||||
|
<div class="example"></div>
|
||||||
|
<div class="example"></div>
|
||||||
|
<div class="example"></div>
|
||||||
|
<div class="example"></div>
|
18
Tests/LibWeb/Ref/input/css/transparent-borders.html
Normal file
18
Tests/LibWeb/Ref/input/css/transparent-borders.html
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<link rel="match" href="../../expected/css/transparent-borders-ref.html" />
|
||||||
|
<style>
|
||||||
|
.example {
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
background: orange;
|
||||||
|
border: 20px solid transparent;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="example" style="border-style: dotted"></div>
|
||||||
|
<div class="example" style="border-style: dashed"></div>
|
||||||
|
<div class="example" style="border-style: solid"></div>
|
||||||
|
<div class="example" style="border-style: groove"></div>
|
||||||
|
<div class="example" style="border-style: ridge"></div>
|
||||||
|
<div class="example" style="border-style: inset"></div>
|
||||||
|
<div class="example" style="border-style: outset"></div>
|
Loading…
Add table
Add a link
Reference in a new issue