SVG not properly respecting max-width.
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jul 2012 06:12:54 +0000 (06:12 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jul 2012 06:12:54 +0000 (06:12 +0000)
commitf5b35910f101f218a816097a7823cea4f3e0f7b0
tree06fef051f40766e774cd9c03c8114b17445ccc54
parentcc4bd2c0014e6050bbe37597d75eba8b81992b25
SVG not properly respecting max-width.
https://bugs.webkit.org/show_bug.cgi?id=91474

Source/WebCore:

My previous checkin for 91474 accidentally inverted width and height in the division case for
the computation of height. When I fixed this inversion, I discovered that <object> elements
are in fact also broken with max-width handling, and that furthermore, trying to apply the same
max-width fix by calling RenderBox::computeReplacedLogicalWidth/Height failed because those methods
call intrinsicLogicalWidth()/Height(). Becuase m_intrinsicSize is out-of-date and does not reflect
the values we just obtained from the contentRenderer, we use the default 300x150 values for object
and fail to render.

In order to both fix SVG/<object> with max-width constraints and to keep <object> rendering correctly
even when there are no max-width constraints, I was forced to update the m_intrinsicSize immediately
in order to make sure that the RenderBox methods returned the right values when computing the width/height
constrained to max/min-width/height values.

Reviewed by Dan Bernstein.

Added two new tests in svg/as-image. One test covers non-rectangular images to test for the inversion
mistake I made. The second test applies a max-width to <object> and shows that we have never gotten
this right before. An existing test in svg/as-image/ already covers basic <object> use (and tests that
the intrinsic size of 300x150 is not used when an explicit non-percentage size is specified on the SVG
itself).

* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::computeAspectRatioInformationForRenderBox):
Add a check to update m_intrinsicSize when we know it should apply, so that the calls to check against
min/max-width fetch this correct size.

* rendering/RenderReplaced.h:
(RenderReplaced):
Make m_intrinsicSize mutable because of the mutation that occurs during the method above. It may be
that we should re-evaluate whether all of these methods should be const, but this would impact RenderBox
methods as well, so I chose to hold off going down that rabbit hole.

LayoutTests:

Reviewed by Dan Bernstein.

* svg/as-image/svg-intrinsic-size-rectangular-expected.html: Added.
* svg/as-image/svg-intrinsic-size-rectangular.html: Added.
* svg/as-image/svg-object-intrinsic-size-expected.html: Added.
* svg/as-image/svg-object-intrinsic-size.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@123183 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/svg/as-image/svg-intrinsic-size-rectangular-expected.html [new file with mode: 0644]
LayoutTests/svg/as-image/svg-intrinsic-size-rectangular.html [new file with mode: 0644]
LayoutTests/svg/as-image/svg-non-integer-scaled-image-expected.txt
LayoutTests/svg/as-image/svg-object-intrinsic-size-expected.html [new file with mode: 0644]
LayoutTests/svg/as-image/svg-object-intrinsic-size.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderReplaced.cpp
Source/WebCore/rendering/RenderReplaced.h