mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 02:59:45 +00:00
LibWeb/SVG: Implement SVGImageElement
This element allows images to be embedded within SVGs.
This commit is contained in:
parent
267420d5aa
commit
03bbc2b111
Notes:
github-actions[bot]
2024-08-29 04:29:33 +00:00
Author: https://github.com/tcl3
Commit: 03bbc2b111
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1198
17 changed files with 490 additions and 8 deletions
65
Userland/Libraries/LibWeb/SVG/SVGImageElement.h
Normal file
65
Userland/Libraries/LibWeb/SVG/SVGImageElement.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Tim Ledbetter <tim.ledbetter@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibWeb/Layout/ImageProvider.h>
|
||||
#include <LibWeb/SVG/SVGAnimatedLength.h>
|
||||
#include <LibWeb/SVG/SVGGraphicsElement.h>
|
||||
|
||||
namespace Web::SVG {
|
||||
|
||||
class SVGImageElement
|
||||
: public SVGGraphicsElement
|
||||
, public SVGURIReferenceMixin<SupportsXLinkHref::Yes>
|
||||
, public Layout::ImageProvider {
|
||||
WEB_PLATFORM_OBJECT(SVGImageElement, SVGElement);
|
||||
|
||||
public:
|
||||
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value) override;
|
||||
|
||||
JS::NonnullGCPtr<SVG::SVGAnimatedLength> x();
|
||||
JS::NonnullGCPtr<SVG::SVGAnimatedLength> y();
|
||||
JS::NonnullGCPtr<SVG::SVGAnimatedLength> width();
|
||||
JS::NonnullGCPtr<SVG::SVGAnimatedLength> height();
|
||||
|
||||
Gfx::Rect<CSSPixels> bounding_box() const;
|
||||
|
||||
// ^Layout::ImageProvider
|
||||
virtual bool is_image_available() const override;
|
||||
virtual Optional<CSSPixels> intrinsic_width() const override;
|
||||
virtual Optional<CSSPixels> intrinsic_height() const override;
|
||||
virtual Optional<CSSPixelFraction> intrinsic_aspect_ratio() const override;
|
||||
virtual RefPtr<Gfx::ImmutableBitmap> current_image_bitmap(Gfx::IntSize = {}) const override;
|
||||
virtual void set_visible_in_viewport(bool) override { }
|
||||
virtual JS::NonnullGCPtr<DOM::Element const> to_html_element() const override { return *this; }
|
||||
|
||||
protected:
|
||||
SVGImageElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
void process_the_url(Optional<String> const& href);
|
||||
void fetch_the_document(URL::URL const& url);
|
||||
|
||||
private:
|
||||
virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
|
||||
|
||||
JS::GCPtr<SVG::SVGAnimatedLength> m_x;
|
||||
JS::GCPtr<SVG::SVGAnimatedLength> m_y;
|
||||
JS::GCPtr<SVG::SVGAnimatedLength> m_width;
|
||||
JS::GCPtr<SVG::SVGAnimatedLength> m_height;
|
||||
|
||||
URL::URL m_href;
|
||||
|
||||
JS::GCPtr<HTML::SharedResourceRequest> m_resource_request;
|
||||
Optional<DOM::DocumentLoadEventDelayer> m_load_event_delayer;
|
||||
JS::GCPtr<DOM::DocumentObserver> m_document_observer;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue