Commit 5888f3e7 authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Reset intrinsic size when embeddee's intrinsic dimensions change

The embedding LayoutObjects intrinsic size may be left as the old stale
size if the new dimensions are not fully defined - which means that it
qualifies as having a size and and aspect ratio (where having the former
implies having the latter in most cases).

Call IntrinsicSizeChanged() instead of just
SetNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(...), since
the former also resets the intrinsic size to 300x150 (incorporating
zoom).

Clean up HTMLPlugInElement::GetLayoutEmbeddedObject a little bit while
at it.

Bug: 971647
Change-Id: I5c165d1ae18888b6368c9011bc6752b599629118
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1660341
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#670024}
parent 8c7f87ac
......@@ -294,10 +294,8 @@ void HTMLPlugInElement::AttachLayoutTree(AttachContext& context) {
}
void HTMLPlugInElement::IntrinsicSizingInfoChanged() {
if (auto* layout_object = GetLayoutObject()) {
layout_object->SetNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
layout_invalidation_reason::kUnknown);
}
if (auto* embedded_object = GetLayoutEmbeddedObject())
embedded_object->IntrinsicSizeChanged();
}
void HTMLPlugInElement::UpdatePlugin() {
......@@ -602,11 +600,9 @@ bool HTMLPlugInElement::IsImageType() const {
}
LayoutEmbeddedObject* HTMLPlugInElement::GetLayoutEmbeddedObject() const {
// HTMLObjectElement and HTMLEmbedElement may return arbitrary layoutObjects
// HTMLObjectElement and HTMLEmbedElement may return arbitrary LayoutObjects
// when using fallback content.
if (!GetLayoutObject() || !GetLayoutObject()->IsEmbeddedObject())
return nullptr;
return ToLayoutEmbeddedObject(GetLayoutObject());
return ToLayoutEmbeddedObjectOrNull(GetLayoutObject());
}
// We don't use url_, as it may not be the final URL that the object loads,
......
......@@ -99,6 +99,13 @@ class CORE_EXPORT LayoutReplaced : public LayoutBox {
// intrinsic size in LayoutNG.
virtual void ComputeIntrinsicSizingInfo(IntrinsicSizingInfo&) const;
// This callback is invoked whenever the intrinsic size changed.
//
// The intrinsic size can change due to the network (from the default
// intrinsic size [see above] to the actual intrinsic size) or to some
// CSS properties like 'zoom' or 'image-orientation'.
virtual void IntrinsicSizeChanged();
protected:
void WillBeDestroyed() override;
......@@ -132,13 +139,6 @@ class CORE_EXPORT LayoutReplaced : public LayoutBox {
intrinsic_size_ = intrinsic_size;
}
// This callback is invoked whenever the intrinsic size changed.
//
// The intrinsic size can change due to the network (from the default
// intrinsic size [see above] to the actual intrinsic size) or to some
// CSS properties like 'zoom' or 'image-orientation'.
virtual void IntrinsicSizeChanged();
PositionWithAffinity PositionForPoint(const PhysicalOffset&) const override;
bool IsOfType(LayoutObjectType type) const override {
......
This is a testharness.js-based test.
PASS no sizing attributes set
PASS specified width
PASS modified specified width
PASS specified width and height
PASS specified width and modified specified height
FAIL specified height assert_equals: checking width. expected 300 but got 400
FAIL modified specified height assert_equals: checking width. expected 300 but got 400
FAIL no specified sizing attrs (after setting & removing them) assert_equals: checking width. expected 300 but got 400
PASS set a 10x8 viewBox
PASS modified viewBox to 50x20
PASS adding specified width, in presence of specified viewBox
PASS modifiying specified viewBox, in presence of specified width
PASS removing specified width, in presence of specified viewBox
PASS adding specified height, in presence of specified viewBox
PASS modifiying specified viewBox, in presence of specified height
Harness: the test ran to completion.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment