mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-09 12:42:54 +00:00
This attribute is used to define how the viewBox should be scaled. Previously the behaviour implemented was that of "xMidYMid meet", now all of them work (expect none :P). With this the Discord login backend is now correctly scaled/positioned. This also brings our SVG code a little closer to the spec! With spec comments and all :^) (Minor non-visible update to layout tests)
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2020, Matthew Olsson <matthewcolsson@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibGfx/Bitmap.h>
|
|
#include <LibWeb/SVG/AttributeParser.h>
|
|
#include <LibWeb/SVG/SVGGraphicsElement.h>
|
|
#include <LibWeb/SVG/ViewBox.h>
|
|
|
|
namespace Web::SVG {
|
|
|
|
class SVGSVGElement final : public SVGGraphicsElement {
|
|
WEB_PLATFORM_OBJECT(SVGSVGElement, SVGGraphicsElement);
|
|
|
|
public:
|
|
virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
|
|
|
|
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
|
|
|
|
virtual bool requires_svg_container() const override { return false; }
|
|
virtual bool is_svg_container() const override { return true; }
|
|
|
|
Optional<ViewBox> const& view_box() const { return m_view_box; }
|
|
Optional<PreserveAspectRatio> const& preserve_aspect_ratio() const { return m_preserve_aspect_ratio; }
|
|
|
|
private:
|
|
SVGSVGElement(DOM::Document&, DOM::QualifiedName);
|
|
|
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
|
|
|
virtual bool is_svg_svg_element() const override { return true; }
|
|
|
|
virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override;
|
|
|
|
Optional<ViewBox> m_view_box;
|
|
Optional<PreserveAspectRatio> m_preserve_aspect_ratio;
|
|
};
|
|
|
|
}
|
|
|
|
namespace Web::DOM {
|
|
|
|
template<>
|
|
inline bool Node::fast_is<SVG::SVGSVGElement>() const { return is_svg_svg_element(); }
|
|
|
|
}
|