mirror of
https://github.com/zebrajr/ladybird.git
synced 2026-01-15 12:15:15 +00:00
Some checks failed
CI / Linux, arm64, Sanitizer, Clang (push) Has been cancelled
CI / macOS, arm64, Sanitizer, Clang (push) Has been cancelled
CI / Linux, x86_64, All_Debug, Clang (push) Has been cancelled
CI / Linux, x86_64, Fuzzers, Clang (push) Has been cancelled
CI / Linux, x86_64, Sanitizer, GNU (push) Has been cancelled
CI / Linux, x86_64, Sanitizer, Clang (push) Has been cancelled
CI / Windows, x86_64, Windows_Sanitizer_CI, ClangCL (push) Has been cancelled
Build Dev Container Image / build (push) Has been cancelled
Package the js repl as a binary artifact / Linux, arm64 (push) Has been cancelled
Package the js repl as a binary artifact / macOS, arm64 (push) Has been cancelled
Package the js repl as a binary artifact / Linux, x86_64 (push) Has been cancelled
Run test262 and test-wasm / run_and_update_results (push) Has been cancelled
Lint Code / lint (push) Has been cancelled
Label PRs with merge conflicts / auto-labeler (push) Has been cancelled
Push notes / build (push) Has been cancelled
Nightly Lagom / Linux, arm64, Distribution, Clang (push) Has been cancelled
Nightly Lagom / macOS, arm64, Distribution, Clang (push) Has been cancelled
Nightly Lagom / Linux, arm64, Sanitizer, Clang (push) Has been cancelled
Nightly Lagom / macOS, arm64, Sanitizer, Swift (push) Has been cancelled
Nightly Lagom / Linux, x86_64, Distribution, GNU (push) Has been cancelled
Nightly Lagom / Linux, x86_64, Sanitizer, Swift (push) Has been cancelled
Nightly Lagom / Windows, x86_64, Windows_Sanitizer_CI, ClangCL (push) Has been cancelled
Nightly Lagom / Flatpak aarch64 (push) Has been cancelled
Nightly Lagom / Flatpak x86_64 (push) Has been cancelled
Nightly Android / CI (macos-14, Android) (push) Has been cancelled
Close stale PRs / stale (push) Has been cancelled
`EdgeStyleValues` which consist of an offset of a `calc()`s which resolves to 50% should be considered "centered" for `SerializationMode::ResolvedValue` for the purpose of omitting the position value from gradient serialization.
40 lines
1.5 KiB
C++
40 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
|
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
|
|
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
|
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include "PositionStyleValue.h"
|
|
|
|
namespace Web::CSS {
|
|
|
|
bool PositionStyleValue::is_center(SerializationMode mode) const
|
|
{
|
|
return edge_x()->is_center(mode) && edge_y()->is_center(mode);
|
|
}
|
|
|
|
CSSPixelPoint PositionStyleValue::resolved(Layout::Node const& node, CSSPixelRect const& rect) const
|
|
{
|
|
// Note: A preset + a none default x/y_relative_to is impossible in the syntax (and makes little sense)
|
|
CSSPixels x = LengthPercentage::from_style_value(m_properties.edge_x->offset()).to_px(node, rect.width());
|
|
CSSPixels y = LengthPercentage::from_style_value(m_properties.edge_y->offset()).to_px(node, rect.height());
|
|
return CSSPixelPoint { rect.x() + x, rect.y() + y };
|
|
}
|
|
|
|
ValueComparingNonnullRefPtr<StyleValue const> PositionStyleValue::absolutized(ComputationContext const& computation_context) const
|
|
{
|
|
return PositionStyleValue::create(
|
|
edge_x()->absolutized(computation_context)->as_edge(),
|
|
edge_y()->absolutized(computation_context)->as_edge());
|
|
}
|
|
|
|
String PositionStyleValue::to_string(SerializationMode mode) const
|
|
{
|
|
return MUST(String::formatted("{} {}", m_properties.edge_x->to_string(mode), m_properties.edge_y->to_string(mode)));
|
|
}
|
|
|
|
}
|