mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:17:35 +00:00
LibWeb: Generalize ImageBox and ImagePaintable for any ImageProvider
They currently assume the DOM node is an HTMLImageElement with respect to handling the alt attribute. The HTMLInputElement will require the same behavior.
This commit is contained in:
parent
c4295edc81
commit
45a47cb32b
10 changed files with 45 additions and 8 deletions
|
@ -109,7 +109,7 @@ void HTMLImageElement::form_associated_element_attribute_changed(FlyString const
|
|||
|
||||
if (name == HTML::AttributeNames::alt) {
|
||||
if (layout_node())
|
||||
verify_cast<Layout::ImageBox>(*layout_node()).dom_node_did_update_alt_text({});
|
||||
did_update_alt_text(verify_cast<Layout::ImageBox>(*layout_node()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,6 +130,11 @@ RefPtr<Gfx::Bitmap const> HTMLImageElement::bitmap() const
|
|||
return {};
|
||||
}
|
||||
|
||||
bool HTMLImageElement::is_image_available() const
|
||||
{
|
||||
return m_current_request && m_current_request->is_available();
|
||||
}
|
||||
|
||||
Optional<CSSPixels> HTMLImageElement::intrinsic_width() const
|
||||
{
|
||||
if (auto image_data = m_current_request->image_data())
|
||||
|
|
|
@ -85,6 +85,7 @@ public:
|
|||
void upgrade_pending_request_to_current_request();
|
||||
|
||||
// ^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;
|
||||
|
|
|
@ -369,6 +369,11 @@ JS::GCPtr<DecodedImageData> HTMLObjectElement::image_data() const
|
|||
return m_image_request->image_data();
|
||||
}
|
||||
|
||||
bool HTMLObjectElement::is_image_available() const
|
||||
{
|
||||
return image_data() != nullptr;
|
||||
}
|
||||
|
||||
Optional<CSSPixels> HTMLObjectElement::intrinsic_width() const
|
||||
{
|
||||
if (auto image_data = this->image_data())
|
||||
|
|
|
@ -75,6 +75,7 @@ private:
|
|||
virtual i32 default_tab_index_value() const override;
|
||||
|
||||
// ^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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue