mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-19 10:20:22 +00:00
Previously, some StyleValues created a large number of intermediate strings during serialization. Passing a StringBUilder into the serialization function allows us to avoid a large number of these unnecessary allocations.
31 lines
851 B
C++
31 lines
851 B
C++
/*
|
|
* Copyright (c) 2025, Callum Law <callumlaw1709@outlook.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/CSS/StyleValues/TextUnderlinePositionStyleValue.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
void TextUnderlinePositionStyleValue::serialize(StringBuilder& builder, SerializationMode) const
|
|
{
|
|
if (m_horizontal == TextUnderlinePositionHorizontal::Auto && m_vertical == TextUnderlinePositionVertical::Auto) {
|
|
builder.append("auto"sv);
|
|
return;
|
|
}
|
|
|
|
if (m_vertical == TextUnderlinePositionVertical::Auto) {
|
|
builder.append(CSS::to_string(m_horizontal));
|
|
return;
|
|
}
|
|
|
|
if (m_horizontal == TextUnderlinePositionHorizontal::Auto) {
|
|
builder.append(CSS::to_string(m_vertical));
|
|
return;
|
|
}
|
|
|
|
builder.appendff("{} {}", CSS::to_string(m_horizontal), CSS::to_string(m_vertical));
|
|
}
|
|
|
|
}
|