mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-04 08:01:51 +00:00
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macOS, macos-15, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, Linux, blacksmith-16vcpu-ubuntu-2404, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, Linux, blacksmith-16vcpu-ubuntu-2404, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, Linux, blacksmith-16vcpu-ubuntu-2404, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macOS, macOS-arm64, macos-15) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, Linux, Linux-x86_64, blacksmith-8vcpu-ubuntu-2404) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
For getComputedStyle(), we must return an absolute URL for image style values. We currently return the raw parsed URL. This fixes loading the marker icons on https://usermap.serenityos.org.
72 lines
2.4 KiB
C++
72 lines
2.4 KiB
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
|
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
|
|
* Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
|
|
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibJS/Heap/Cell.h>
|
|
#include <LibWeb/CSS/Enums.h>
|
|
#include <LibWeb/CSS/StyleValues/AbstractImageStyleValue.h>
|
|
#include <LibWeb/CSS/URL.h>
|
|
#include <LibWeb/Forward.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
class ImageStyleValue final
|
|
: public AbstractImageStyleValue
|
|
, public Weakable<ImageStyleValue> {
|
|
|
|
using Base = AbstractImageStyleValue;
|
|
|
|
public:
|
|
static ValueComparingNonnullRefPtr<ImageStyleValue const> create(URL const&);
|
|
static ValueComparingNonnullRefPtr<ImageStyleValue const> create(::URL::URL const&);
|
|
virtual ~ImageStyleValue() override;
|
|
|
|
virtual void visit_edges(JS::Cell::Visitor& visitor) const override;
|
|
|
|
virtual String to_string(SerializationMode) const override;
|
|
virtual bool equals(CSSStyleValue const& other) const override;
|
|
|
|
virtual void load_any_resources(DOM::Document&) override;
|
|
|
|
Optional<CSSPixels> natural_width() const override;
|
|
Optional<CSSPixels> natural_height() const override;
|
|
Optional<CSSPixelFraction> natural_aspect_ratio() const override;
|
|
|
|
virtual bool is_paintable() const override;
|
|
void paint(PaintContext& context, DevicePixelRect const& dest_rect, CSS::ImageRendering image_rendering) const override;
|
|
|
|
virtual Optional<Gfx::Color> color_if_single_pixel_bitmap() const override;
|
|
Gfx::ImmutableBitmap const* current_frame_bitmap(DevicePixelRect const& dest_rect) const;
|
|
|
|
mutable Function<void()> on_animate;
|
|
|
|
GC::Ptr<HTML::DecodedImageData> image_data() const;
|
|
|
|
private:
|
|
ImageStyleValue(URL const&);
|
|
|
|
virtual void set_style_sheet(GC::Ptr<CSSStyleSheet>) override;
|
|
virtual ValueComparingNonnullRefPtr<CSSStyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override;
|
|
|
|
void animate();
|
|
Gfx::ImmutableBitmap const* bitmap(size_t frame_index, Gfx::IntSize = {}) const;
|
|
|
|
GC::Ptr<HTML::SharedResourceRequest> m_resource_request;
|
|
GC::Ptr<CSSStyleSheet> m_style_sheet;
|
|
|
|
URL m_url;
|
|
WeakPtr<DOM::Document> m_document;
|
|
|
|
size_t m_current_frame_index { 0 };
|
|
size_t m_loops_completed { 0 };
|
|
GC::Ptr<Platform::Timer> m_timer;
|
|
};
|
|
|
|
}
|