mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
78
Libraries/LibWeb/SVG/SVGLength.cpp
Normal file
78
Libraries/LibWeb/SVG/SVGLength.cpp
Normal file
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/SVGLengthPrototype.h>
|
||||
#include <LibWeb/CSS/PercentageOr.h>
|
||||
#include <LibWeb/SVG/SVGLength.h>
|
||||
|
||||
namespace Web::SVG {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(SVGLength);
|
||||
|
||||
JS::NonnullGCPtr<SVGLength> SVGLength::create(JS::Realm& realm, u8 unit_type, float value)
|
||||
{
|
||||
return realm.heap().allocate<SVGLength>(realm, realm, unit_type, value);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<SVGLength> SVGLength::from_length_percentage(JS::Realm& realm, CSS::LengthPercentage const& length_percentage)
|
||||
{
|
||||
// FIXME: We can't tell if a CSS::LengthPercentage was a unitless length.
|
||||
(void)SVG_LENGTHTYPE_NUMBER;
|
||||
if (length_percentage.is_percentage())
|
||||
return SVGLength::create(realm, SVG_LENGTHTYPE_PERCENTAGE, length_percentage.percentage().value());
|
||||
if (length_percentage.is_length())
|
||||
return SVGLength::create(
|
||||
realm, [&] {
|
||||
switch (length_percentage.length().type()) {
|
||||
case CSS::Length::Type::Em:
|
||||
return SVG_LENGTHTYPE_EMS;
|
||||
case CSS::Length::Type::Ex:
|
||||
return SVG_LENGTHTYPE_EXS;
|
||||
case CSS::Length::Type::Px:
|
||||
return SVG_LENGTHTYPE_PX;
|
||||
case CSS::Length::Type::Cm:
|
||||
return SVG_LENGTHTYPE_CM;
|
||||
case CSS::Length::Type::Mm:
|
||||
return SVG_LENGTHTYPE_MM;
|
||||
case CSS::Length::Type::In:
|
||||
return SVG_LENGTHTYPE_IN;
|
||||
case CSS::Length::Type::Pt:
|
||||
return SVG_LENGTHTYPE_PT;
|
||||
case CSS::Length::Type::Pc:
|
||||
return SVG_LENGTHTYPE_PC;
|
||||
default:
|
||||
return SVG_LENGTHTYPE_UNKNOWN;
|
||||
}
|
||||
}(),
|
||||
length_percentage.length().raw_value());
|
||||
return SVGLength::create(realm, SVG_LENGTHTYPE_UNKNOWN, 0);
|
||||
}
|
||||
|
||||
SVGLength::SVGLength(JS::Realm& realm, u8 unit_type, float value)
|
||||
: PlatformObject(realm)
|
||||
, m_unit_type(unit_type)
|
||||
, m_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
void SVGLength::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGLength);
|
||||
}
|
||||
|
||||
SVGLength::~SVGLength() = default;
|
||||
|
||||
// https://www.w3.org/TR/SVG11/types.html#__svg__SVGLength__value
|
||||
WebIDL::ExceptionOr<void> SVGLength::set_value(float value)
|
||||
{
|
||||
// FIXME: Raise an exception if this <length> is read-only.
|
||||
m_value = value;
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue