diff --git a/LayoutTests/model-element/model-element-width-height-expected.txt b/LayoutTests/model-element/model-element-width-height-expected.txt new file mode 100644 index 0000000000000..de9640f0c70ec --- /dev/null +++ b/LayoutTests/model-element/model-element-width-height-expected.txt @@ -0,0 +1,9 @@ + +PASS HTMLModelElement has width and height properties +PASS HTMLModelElement width and height properties reflect width and height attribute values +PASS width and height attributes reflect HTMLModelElement width and height properties +PASS has default CSS size when no width or height attribute is used +PASS width and height attributes influence automatic size +PASS width and height attributes do not win over non-auto width and height property values +PASS size computation takes aspect-ratio property into account + diff --git a/LayoutTests/model-element/model-element-width-height-visual-expected.html b/LayoutTests/model-element/model-element-width-height-visual-expected.html new file mode 100644 index 0000000000000..436aee85b9d67 --- /dev/null +++ b/LayoutTests/model-element/model-element-width-height-visual-expected.html @@ -0,0 +1,2 @@ + + diff --git a/LayoutTests/model-element/model-element-width-height-visual.html b/LayoutTests/model-element/model-element-width-height-visual.html new file mode 100644 index 0000000000000..5fb19f722b41d --- /dev/null +++ b/LayoutTests/model-element/model-element-width-height-visual.html @@ -0,0 +1,2 @@ + + diff --git a/LayoutTests/model-element/model-element-width-height.html b/LayoutTests/model-element/model-element-width-height.html new file mode 100644 index 0000000000000..514bbba8babd9 --- /dev/null +++ b/LayoutTests/model-element/model-element-width-height.html @@ -0,0 +1,66 @@ + + + + + diff --git a/Source/WebCore/Modules/model-element/HTMLModelElement.cpp b/Source/WebCore/Modules/model-element/HTMLModelElement.cpp index a1f4ed03582a0..4a72e70ccb8c1 100644 --- a/Source/WebCore/Modules/model-element/HTMLModelElement.cpp +++ b/Source/WebCore/Modules/model-element/HTMLModelElement.cpp @@ -65,6 +65,8 @@ namespace WebCore { +using namespace HTMLNames; + WTF_MAKE_ISO_ALLOCATED_IMPL(HTMLModelElement); HTMLModelElement::HTMLModelElement(const QualifiedName& tagName, Document& document) @@ -678,6 +680,25 @@ String HTMLModelElement::inlinePreviewUUIDForTesting() const } #endif +void HTMLModelElement::collectPresentationalHintsForAttribute(const QualifiedName& name, const AtomString& value, MutableStyleProperties& style) +{ + if (name == widthAttr) { + addHTMLLengthToStyle(style, CSSPropertyWidth, value); + applyAspectRatioFromWidthAndHeightAttributesToStyle(value, attributeWithoutSynchronization(heightAttr), style); + } else if (name == heightAttr) { + addHTMLLengthToStyle(style, CSSPropertyHeight, value); + applyAspectRatioFromWidthAndHeightAttributesToStyle(attributeWithoutSynchronization(widthAttr), value, style); + } else + HTMLElement::collectPresentationalHintsForAttribute(name, value, style); +} + +bool HTMLModelElement::hasPresentationalHintsForAttribute(const QualifiedName& name) const +{ + if (name == widthAttr || name == heightAttr) + return true; + return HTMLElement::hasPresentationalHintsForAttribute(name); +} + } #endif // ENABLE(MODEL_ELEMENT) diff --git a/Source/WebCore/Modules/model-element/HTMLModelElement.h b/Source/WebCore/Modules/model-element/HTMLModelElement.h index 9854a4571997a..3cd617ddd5e92 100644 --- a/Source/WebCore/Modules/model-element/HTMLModelElement.h +++ b/Source/WebCore/Modules/model-element/HTMLModelElement.h @@ -134,6 +134,10 @@ class HTMLModelElement final : public HTMLElement, private CachedRawResourceClie void didMoveToNewDocument(Document& oldDocument, Document& newDocument) final; void attributeChanged(const QualifiedName&, const AtomString& oldValue, const AtomString& newValue, AttributeModificationReason) final; + // StyledElement + bool hasPresentationalHintsForAttribute(const QualifiedName&) const final; + void collectPresentationalHintsForAttribute(const QualifiedName&, const AtomString&, MutableStyleProperties&) final; + // Rendering overrides. RenderPtr createElementRenderer(RenderStyle&&, const RenderTreePosition&) final; void didAttachRenderers() final; diff --git a/Source/WebCore/Modules/model-element/HTMLModelElement.idl b/Source/WebCore/Modules/model-element/HTMLModelElement.idl index 03b75bc9b1f34..da0fe79f96a5c 100644 --- a/Source/WebCore/Modules/model-element/HTMLModelElement.idl +++ b/Source/WebCore/Modules/model-element/HTMLModelElement.idl @@ -30,6 +30,8 @@ Exposed=Window, JSGenerateToNativeObject ] interface HTMLModelElement : HTMLElement { + [CEReactions=NotNeeded, Reflect] attribute unsigned long width; + [CEReactions=NotNeeded, Reflect] attribute unsigned long height; [URL] readonly attribute USVString currentSrc; readonly attribute boolean complete;