mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:28:12 +00:00
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.
This commit is contained in:
parent
3ebc5cc58e
commit
ebf3829f1c
5 changed files with 98 additions and 0 deletions
40
Userland/Libraries/LibWeb/SVG/SVGLength.h
Normal file
40
Userland/Libraries/LibWeb/SVG/SVGLength.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <LibWeb/Bindings/Wrappable.h>
|
||||
#include <LibWeb/DOM/ExceptionOr.h>
|
||||
|
||||
namespace Web::SVG {
|
||||
|
||||
// https://www.w3.org/TR/SVG11/types.html#InterfaceSVGLength
|
||||
class SVGLength
|
||||
: public RefCounted<SVGLength>
|
||||
, public Bindings::Wrappable
|
||||
, public Weakable<SVGLength> {
|
||||
public:
|
||||
using WrapperType = Bindings::SVGLengthWrapper;
|
||||
|
||||
static NonnullRefPtr<SVGLength> create(u8 unit_type, float value);
|
||||
virtual ~SVGLength() = default;
|
||||
|
||||
u8 unit_type() const { return m_unit_type; }
|
||||
|
||||
float value() const { return m_value; }
|
||||
DOM::ExceptionOr<void> set_value(float value);
|
||||
|
||||
private:
|
||||
SVGLength(u8 unit_type, float value);
|
||||
|
||||
u8 m_unit_type { 0 };
|
||||
float m_value { 0 };
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue