Coverage Report

Created: 2026-09-26 06:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibWeb/HTML/ImageBitmap.h
Line
Count
Source
1
/*
2
 * Copyright (c) 2024, Lucas Chollet <lucas.chollet@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#pragma once
8
9
#include <AK/OwnPtr.h>
10
#include <LibGfx/Bitmap.h>
11
#include <LibWeb/Bindings/PlatformObject.h>
12
#include <LibWeb/Bindings/Serializable.h>
13
#include <LibWeb/Bindings/Transferable.h>
14
#include <LibWeb/Forward.h>
15
#include <LibWeb/HTML/Canvas/CanvasDrawImage.h>
16
17
namespace Web::HTML {
18
19
using ImageBitmapSource = Variant<CanvasImageSource, JS::Handle<FileAPI::Blob>, JS::Handle<ImageData>>;
20
21
// https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#imagebitmapoptions
22
struct ImageBitmapOptions {
23
    // FIXME: Implement these fields
24
};
25
26
class ImageBitmap final : public Bindings::PlatformObject
27
    , public Web::Bindings::Serializable
28
    , public Web::Bindings::Transferable {
29
    WEB_PLATFORM_OBJECT(ImageBitmap, Bindings::PlatformObject);
30
    JS_DECLARE_ALLOCATOR(ImageBitmap);
31
32
public:
33
    static JS::NonnullGCPtr<ImageBitmap> create(JS::Realm&);
34
0
    virtual ~ImageBitmap() override = default;
35
36
    // ^Web::Bindings::Serializable
37
0
    virtual StringView interface_name() const override { return "ImageBitmap"sv; }
38
    virtual WebIDL::ExceptionOr<void> serialization_steps(HTML::SerializationRecord&, bool for_storage, HTML::SerializationMemory&) override;
39
    virtual WebIDL::ExceptionOr<void> deserialization_steps(ReadonlySpan<u32> const&, size_t& position, HTML::DeserializationMemory&) override;
40
41
    // ^Web::Bindings::Transferable
42
    virtual WebIDL::ExceptionOr<void> transfer_steps(HTML::TransferDataHolder&) override;
43
    virtual WebIDL::ExceptionOr<void> transfer_receiving_steps(HTML::TransferDataHolder&) override;
44
    virtual HTML::TransferType primary_interface() const override;
45
46
    WebIDL::UnsignedLong width() const;
47
    WebIDL::UnsignedLong height() const;
48
49
    void close();
50
51
    // Implementation specific:
52
    void set_bitmap(RefPtr<Gfx::Bitmap>);
53
    Gfx::Bitmap* bitmap() const;
54
55
private:
56
    explicit ImageBitmap(JS::Realm&);
57
58
    // FIXME: We don't implement this flag yet:
59
    // An ImageBitmap object's bitmap has an origin-clean flag, which indicates whether the bitmap is tainted by content
60
    // from a different origin. The flag is initially set to true and may be changed to false by the steps of
61
    // createImageBitmap().
62
63
    virtual void initialize(JS::Realm&) override;
64
    virtual void visit_edges(Cell::Visitor&) override;
65
66
    WebIDL::UnsignedLong m_width = 0;
67
    WebIDL::UnsignedLong m_height = 0;
68
69
    RefPtr<Gfx::Bitmap> m_bitmap { nullptr };
70
};
71
72
}