mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibWeb: Preserve unit when serializing angle values
Previously, when serializing an angle value, we would always convert it to degrees. We now canonicalize the angle value only when serializing its computed value.
This commit is contained in:
parent
d0be5a0cdf
commit
5bfbb7abe6
Notes:
github-actions[bot]
2025-03-20 17:00:27 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/5bfbb7abe61 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4004 Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 20 additions and 19 deletions
|
@ -29,7 +29,7 @@ Angle Angle::percentage_of(Percentage const& percentage) const
|
|||
|
||||
String Angle::to_string() const
|
||||
{
|
||||
return MUST(String::formatted("{}deg", to_degrees()));
|
||||
return MUST(String::formatted("{}{}", raw_value(), unit_name()));
|
||||
}
|
||||
|
||||
double Angle::to_degrees() const
|
||||
|
|
|
@ -19,8 +19,10 @@ AngleStyleValue::AngleStyleValue(Angle angle)
|
|||
|
||||
AngleStyleValue::~AngleStyleValue() = default;
|
||||
|
||||
String AngleStyleValue::to_string(SerializationMode) const
|
||||
String AngleStyleValue::to_string(SerializationMode serialization_mode) const
|
||||
{
|
||||
if (serialization_mode == SerializationMode::ResolvedValue)
|
||||
return MUST(String::formatted("{}deg", m_angle.to_degrees()));
|
||||
return m_angle.to_string();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,22 +2,21 @@ Harness status: OK
|
|||
|
||||
Found 17 tests
|
||||
|
||||
2 Pass
|
||||
15 Fail
|
||||
17 Pass
|
||||
Pass e.style['rotate'] = "none" should set the property value
|
||||
Pass e.style['rotate'] = "0deg" should set the property value
|
||||
Fail e.style['rotate'] = "100 200 300 400grad" should set the property value
|
||||
Fail e.style['rotate'] = "400grad 100 200 300" should set the property value
|
||||
Fail e.style['rotate'] = "0 0 0 400grad" should set the property value
|
||||
Fail e.style['rotate'] = "x 400grad" should set the property value
|
||||
Fail e.style['rotate'] = "400grad x" should set the property value
|
||||
Fail e.style['rotate'] = "0.5 0 0 400grad" should set the property value
|
||||
Fail e.style['rotate'] = "1 0 0 400grad" should set the property value
|
||||
Fail e.style['rotate'] = "y 400grad" should set the property value
|
||||
Fail e.style['rotate'] = "400grad y" should set the property value
|
||||
Fail e.style['rotate'] = "0 0.5 0 400grad" should set the property value
|
||||
Fail e.style['rotate'] = "0 1 0 400grad" should set the property value
|
||||
Fail e.style['rotate'] = "400grad" should set the property value
|
||||
Fail e.style['rotate'] = "400grad z" should set the property value
|
||||
Fail e.style['rotate'] = "0 0 0.5 400grad" should set the property value
|
||||
Fail e.style['rotate'] = "0 0 1 400grad" should set the property value
|
||||
Pass e.style['rotate'] = "100 200 300 400grad" should set the property value
|
||||
Pass e.style['rotate'] = "400grad 100 200 300" should set the property value
|
||||
Pass e.style['rotate'] = "0 0 0 400grad" should set the property value
|
||||
Pass e.style['rotate'] = "x 400grad" should set the property value
|
||||
Pass e.style['rotate'] = "400grad x" should set the property value
|
||||
Pass e.style['rotate'] = "0.5 0 0 400grad" should set the property value
|
||||
Pass e.style['rotate'] = "1 0 0 400grad" should set the property value
|
||||
Pass e.style['rotate'] = "y 400grad" should set the property value
|
||||
Pass e.style['rotate'] = "400grad y" should set the property value
|
||||
Pass e.style['rotate'] = "0 0.5 0 400grad" should set the property value
|
||||
Pass e.style['rotate'] = "0 1 0 400grad" should set the property value
|
||||
Pass e.style['rotate'] = "400grad" should set the property value
|
||||
Pass e.style['rotate'] = "400grad z" should set the property value
|
||||
Pass e.style['rotate'] = "0 0 0.5 400grad" should set the property value
|
||||
Pass e.style['rotate'] = "0 0 1 400grad" should set the property value
|
Loading…
Add table
Reference in a new issue