Bug 42944 - SVG background doesn't resize properly when dimensions are changed
Summary: SVG background doesn't resize properly when dimensions are changed
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) OS X 10.6
: P2 Normal
Assignee: Nobody
Depends on: 47156
  Show dependency treegraph
Reported: 2010-07-25 03:35 PDT by Radek Pietruszewski
Modified: 2011-10-31 08:32 PDT (History)
6 users (show)

See Also:

Bug test (2.38 KB, application/zip)
2010-07-25 03:35 PDT, Radek Pietruszewski
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Radek Pietruszewski 2010-07-25 03:35:43 PDT
Created attachment 62522 [details]
Bug test


Given a div with SVG background and border, div's background doesn't resize when div's dimensions are changed (no matter if using JS animation, CSS transition, or just :hover)

Steps to reproduce:

1. Make a <div> with SVG background
2. Add a border or an outline to this <div> (bug won't appear without this)
3. Change its dimensions in some way (easiest way is to use :hover)

Actual results:

Border changes its dimensions, but background stays in the same position

Expected results:

Background changes its dimensions accordingly to div

Build Date & Platform:

Safari 5.0 (6533.16) - which is WebKit 533, right?

Additional Builds and Platforms:

Works just fine on Opera 10.60

Additional Information:

Sorry for my English ;)
Comment 1 Dirk Schulze 2010-07-26 23:48:03 PDT
I can't reproduce it locally with trunk. Have you tested it with a nightly?
Comment 2 Radek Pietruszewski 2010-07-27 00:08:02 PDT
(In reply to comment #1)
> I can't reproduce it locally with trunk. Have you tested it with a nightly?

No until now (sorry for that - I'm the new one), but I can reproduce it on nightly.
Comment 3 Nikolas Zimmermann 2010-07-30 00:13:51 PDT
CC'in Dan Bernstein.
Dan, do you know off-hand what might be the difference that the SVG background image doesn't resize anymore when a border is applied to the <div>? I'd be thankful for any hints.
Comment 4 Tim Horton 2011-06-21 11:14:56 PDT
As far as I can tell, this is a regression in r62922, which added RenderSVGRoot ::clippedOverflowRectForRepaint, which redirects the call to SVGRenderSupport instead of the superclass, RenderBox.

SVGRenderSupport's implementation uses the m_repaintBoundingBox on the RenderSVGRoot, which is calculated using computeContainerBoundingBoxes, which only takes into account the bounding boxes of the children of the container! (that is to say, ignores the bounding box of the RenderSVGRoot, which includes the background!)

We could fix this by making RenderSVGRoot::updateCachedBoundaries include the RenderSVGRoot's bounding box *in the case where it has a background*, but I'm not sure if that would break anything. Alternatively, we could just remove RenderSVGRoot::clippedOverflowRectForRepaint, leaving it to be forwarded to RenderBox, but I have a feeling it's done the way it is right now for performance reasons, so we should be careful with it.

Any ideas?

Comment 5 Tim Horton 2011-06-21 17:23:38 PDT
Nevermind! This is actually separate from the r62922 regression, which I'll file a separate bug for tomorrow because it needs some discussion. Sorry!
Comment 6 Nikolas Zimmermann 2011-07-23 05:01:39 PDT
47156 fixes this.
Comment 7 Nikolas Zimmermann 2011-10-31 08:32:27 PDT
Fixed in r98852. Thanks for the testcase!