Closed Bug 585069 Opened 14 years ago Closed 13 years ago

xul images should support ratio scaling

Categories

(Core :: XUL, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla8
Tracking Status
firefox8 + ---

People

(Reporter: enndeakin, Assigned: enndeakin)

References

Details

(Keywords: dev-doc-complete, Whiteboard: [qa-])

Attachments

(1 file, 2 obsolete files)

Such that:

<image src="image.png" maxwidth="400" maxheight="300"/>

can specify maximum sizes and the image will shrink down with the same ratio in both directions.
Attached patch patch with reftests (obsolete) — Splinter Review
Assignee: nobody → enndeakin
Attachment #463557 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #517458 - Flags: review?
Attachment #517458 - Flags: review? → review?(dbaron)
Comment on attachment 517458 [details] [diff] [review]
patch with reftests

Sorry for taking so long to get to this (though for a while I was
postponing it because your bugzilla name said you were on vacation).

'width' and 'height' should not be inputs to
nsLayoutUtils::ComputeAutoSizeWithIntrinsicDimensions; they should
just be local variables inside of it.  (Or, alternatively, they
could be out params and the function could return void, but it's
probably better returning nsSize as you have it.)

In nsLayoutUtils.h, ComputeAutoSizeWithIntrinsicDimensions should
give a better explanation of tentWidth and tentHeight:  it should
describe them as the result of applying the rules for handling
intrinsic sizes and ratios.

The way you use this in nsImageBoxFrame seems to me to all be off by
border+padding.  In particular, the code in nsLayoutUtils that
you're using intends to deal with content-box sizes, but you're
giving it border-box sizes for the min and max sizes (and for the
ignored first two parameters), though you're giving it content box
sizes for the important last 2 parameters.  I *think* that's going
to yield the wrong results.  Then the code in nsLayoutUtils returns
a content box size, but you're returning it directly from
GetPrefSize which is supposed to return a border-box size.

The hand-written code in nsImageBoxFrame seems likewise incorrect in
the presence of border and/or padding.

I didn't look closely at your tests, but I think you need a bunch
with border and padding; you don't seem to have any.
Attachment #517458 - Flags: review?(dbaron) → review-
This patch subtracts off and adds on the border/padding as needed.
Attachment #517458 - Attachment is obsolete: true
Attachment #537208 - Flags: review?(dbaron)
Comment on attachment 537208 [details] [diff] [review]
patch with proper border/padding handling

I recommend also having tests with asymmetric padding and border, e.g.,
with padding: 1px 2px 4px 8px.

+    if (size.width != NS_INTRINSICSIZE)
+      size.width += borderPadding.LeftRight();
+    if (size.height != NS_INTRINSICSIZE)
+      size.height += borderPadding.TopBottom();

It shouldn't be possible for these to be NS_INTRINSICSIZE, unless
I'm missing something (which I think would also mean things are
pretty broken).

+      nscoord height = size.height;
+      if (height != NS_INTRINSICSIZE)
+        height -= borderPadding.TopBottom();

Same here.

+      nscoord width = size.width;
+      if (width != NS_INTRINSICSIZE)
+        width -= borderPadding.LeftRight();

And here.

Instead of these tests, could you assert that |size| doesn't have
NS_INTRINSICSIZE components both after AddCSSPrefSize and after
ComputeAutoSizeWithIntrinsicDimensions?

r=dbaron with that

Sorry for the delay getting to this.
Attachment #537208 - Flags: review?(dbaron) → review+
http://hg.mozilla.org/mozilla-central/rev/7fece42cb99a
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla8
Flags: in-testsuite+
Depends on: 677087
Depends on: 677091
Depends on: 677886
(tracking-8+ since we might need to back this out on aurora if bug 677091 and related issues don't get fixed)
This patch added tests to the reftest directory layout/xul/base/reftest/ (originally added in bug 442228) which was not listed in the toplevel manifest, so they were never run in our automated testing.  I just did that:
https://hg.mozilla.org/integration/mozilla-inbound/rev/139eed687d77
Do we know yet whether this will make Firefox 7? I see there's some concern about possibly backing it out.
The regression problems were fixed so it should be staying in.
Can anyone tell me how can this be verified?
Whiteboard: [qa?]
This bug changes the following behaviour. Given an example such as:

<image src="image.png" maxwidth="200"/>

where image.png is a large image such as a photo, the old behaviour was to shrink the width down to the maximum allowed of 200 but keep the height the same. The new behaviour aligns more with the html img tag and shrinks both the width and height down proportionally.

An automated test also verifies the behaviour.
Given this is covered by automation, I don't think there is much QA can do to verify this is fixed. Simona, if you feel like you have time, you can code an example like in comment 11 (test it in a previous build and the current build to compare).
Whiteboard: [qa?] → [qa-]
Moving to Core:XUL per https://bugzilla.mozilla.org/show_bug.cgi?id=1455336
Component: XP Toolkit/Widgets: XUL → XUL
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: