diff options
author | Timothy Flynn <trflynn89@pm.me> | 2022-03-21 14:20:48 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-21 21:04:39 +0100 |
commit | ebf3829f1cfc7f19f53bae46a42fcf130952250c (patch) | |
tree | b95e8ba3298e90c7960a0f5a8d1b0f6b4a233dab /Userland/Libraries/LibWeb/SVG/SVGLength.cpp | |
parent | 3ebc5cc58e82aa9fe31cf371dab80112454e1ac0 (diff) | |
download | serenity-ebf3829f1cfc7f19f53bae46a42fcf130952250c.zip |
LibWeb: Begin implementing the SVGLength type
There are a few unimplemented features for this type:
1. The value setter should throw a DOMException if it is invoked on an
SVGLength that was declared readonly in another IDL file.
2. SVG::AttributeParser does not parse unit types when it parses lengths
so all SVGLength will have an "unknown" unit for now.
3. Due to (2), methods which convert between units are unimplemented.
Diffstat (limited to 'Userland/Libraries/LibWeb/SVG/SVGLength.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/SVG/SVGLength.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/SVG/SVGLength.cpp b/Userland/Libraries/LibWeb/SVG/SVGLength.cpp new file mode 100644 index 0000000000..11c3865479 --- /dev/null +++ b/Userland/Libraries/LibWeb/SVG/SVGLength.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include <LibWeb/SVG/SVGLength.h> + +namespace Web::SVG { + +NonnullRefPtr<SVGLength> SVGLength::create(u8 unit_type, float value) +{ + return adopt_ref(*new SVGLength(unit_type, value)); +} + +SVGLength::SVGLength(u8 unit_type, float value) + : m_unit_type(unit_type) + , m_value(value) +{ +} + +// https://www.w3.org/TR/SVG11/types.html#__svg__SVGLength__value +DOM::ExceptionOr<void> SVGLength::set_value(float value) +{ + // FIXME: Raise an exception if this <length> is read-only. + m_value = value; + return {}; +} + +} |