mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-15 20:49:41 +00:00
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
63 lines
1.6 KiB
C++
63 lines
1.6 KiB
C++
/*
|
|
* Copyright (c) 2025, Callum Law <callumlaw1709@outlook.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include "SuperellipseStyleValue.h"
|
|
|
|
namespace Web::CSS {
|
|
|
|
String SuperellipseStyleValue::to_string(SerializationMode mode) const
|
|
{
|
|
if (mode == SerializationMode::ResolvedValue && m_parameter->is_number()) {
|
|
auto number = m_parameter->as_number().number();
|
|
|
|
if (number == 1)
|
|
return "round"_string;
|
|
|
|
if (number == 2)
|
|
return "squircle"_string;
|
|
|
|
if (number == AK::Infinity<double>)
|
|
return "square"_string;
|
|
|
|
if (number == 0)
|
|
return "bevel"_string;
|
|
|
|
if (number == -1)
|
|
return "scoop"_string;
|
|
|
|
if (number == -AK::Infinity<double>)
|
|
return "notch"_string;
|
|
}
|
|
|
|
auto stringified_parameter = [&] {
|
|
if (!m_parameter->is_number())
|
|
return m_parameter->to_string(mode);
|
|
|
|
auto number = m_parameter->as_number().number();
|
|
|
|
if (number == AK::Infinity<double>)
|
|
return "infinity"_string;
|
|
|
|
if (number == -AK::Infinity<double>)
|
|
return "-infinity"_string;
|
|
|
|
return m_parameter->to_string(mode);
|
|
}();
|
|
|
|
return MUST(String::formatted("superellipse({})", stringified_parameter));
|
|
}
|
|
|
|
ValueComparingNonnullRefPtr<StyleValue const> SuperellipseStyleValue::absolutized(ComputationContext const& computation_context) const
|
|
{
|
|
auto const& absolutized_parameter = m_parameter->absolutized(computation_context);
|
|
|
|
if (absolutized_parameter == m_parameter)
|
|
return *this;
|
|
|
|
return SuperellipseStyleValue::create(absolutized_parameter);
|
|
}
|
|
|
|
}
|