2020-08-01 03:07:00 +01:00
|
|
|
/*
|
2021-04-28 22:46:44 +02:00
|
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
2020-08-01 03:07:00 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-01 03:07:00 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <LibWeb/HTML/HTMLElement.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
|
|
|
|
|
class HTMLSourceElement final : public HTMLElement {
|
2022-08-28 13:42:07 +02:00
|
|
|
WEB_PLATFORM_OBJECT(HTMLSourceElement, HTMLElement);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(HTMLSourceElement);
|
2022-08-28 13:42:07 +02:00
|
|
|
|
2020-08-01 03:07:00 +01:00
|
|
|
public:
|
2022-08-28 13:42:07 +02:00
|
|
|
virtual ~HTMLSourceElement() override;
|
2020-08-01 03:07:00 +01:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
private:
|
2022-02-18 21:00:52 +01:00
|
|
|
HTMLSourceElement(DOM::Document&, DOM::QualifiedName);
|
2023-01-10 06:28:20 -05:00
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2023-05-12 15:04:58 -04:00
|
|
|
|
|
|
|
|
virtual void inserted() override;
|
2026-04-16 20:04:54 +01:00
|
|
|
virtual void removed_from(IsSubtreeRoot, DOM::Node* old_ancestor, DOM::Node& old_root) override;
|
|
|
|
|
virtual void moved_from(IsSubtreeRoot, GC::Ptr<Node> old_ancestor) override;
|
LibWeb: Re-evaluate picture source set on source mutations
The img inside a <picture> has to re-run "update the image data" when
nearby <source> elements change, so script-driven swaps of srcset (and
the other dimension/media attributes) actually take effect.
Per the HTML spec, the relevant mutations for an img element include:
"The element's parent is a picture element and a source element that
is a previous sibling has its srcset, sizes, media, type, width or
height attributes set, changed, or removed."
The same applies to source insertion, moving, and removal.
Fixes image loading on https://www.apple.com/mac/
2026-04-26 15:52:55 +02:00
|
|
|
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
|
2020-08-01 03:07:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|