mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-05 01:42:54 +00:00
LibWeb: Parse "width" and "height" presentation attributes on <img>
These are HTML lengths that map to CSS width and height respectively.
This commit is contained in:
parent
5a7e57457e
commit
a3feb46ad7
Notes:
sideshowbarker
2024-07-19 04:40:43 +09:00
Author: https://github.com/awesomekling
Commit: a3feb46ad7
2 changed files with 18 additions and 0 deletions
|
@ -33,6 +33,7 @@
|
||||||
#include <LibWeb/DOM/HTMLImageElement.h>
|
#include <LibWeb/DOM/HTMLImageElement.h>
|
||||||
#include <LibWeb/Layout/LayoutImage.h>
|
#include <LibWeb/Layout/LayoutImage.h>
|
||||||
#include <LibWeb/Loader/ResourceLoader.h>
|
#include <LibWeb/Loader/ResourceLoader.h>
|
||||||
|
#include <LibWeb/Parser/CSSParser.h>
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
|
@ -60,6 +61,21 @@ HTMLImageElement::~HTMLImageElement()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HTMLImageElement::apply_presentational_hints(StyleProperties& style) const
|
||||||
|
{
|
||||||
|
for_each_attribute([&](auto& name, auto& value) {
|
||||||
|
if (name == HTML::AttributeNames::width) {
|
||||||
|
if (auto parsed_value = parse_html_length(document(), value)) {
|
||||||
|
style.set_property(CSS::PropertyID::Width, parsed_value.release_nonnull());
|
||||||
|
}
|
||||||
|
} else if (name == HTML::AttributeNames::height) {
|
||||||
|
if (auto parsed_value = parse_html_length(document(), value)) {
|
||||||
|
style.set_property(CSS::PropertyID::Height, parsed_value.release_nonnull());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void HTMLImageElement::parse_attribute(const FlyString& name, const String& value)
|
void HTMLImageElement::parse_attribute(const FlyString& name, const String& value)
|
||||||
{
|
{
|
||||||
HTMLElement::parse_attribute(name, value);
|
HTMLElement::parse_attribute(name, value);
|
||||||
|
|
|
@ -51,6 +51,8 @@ public:
|
||||||
const Gfx::Bitmap* bitmap() const;
|
const Gfx::Bitmap* bitmap() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
virtual void apply_presentational_hints(StyleProperties&) const override;
|
||||||
|
|
||||||
void animate();
|
void animate();
|
||||||
|
|
||||||
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override;
|
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue