Bug 11686 - WebKit draws Carto.net tabgroup example completely incorrectly (ff does fine)
Summary: WebKit draws Carto.net tabgroup example completely incorrectly (ff does fine)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
URL: http://www.carto.net/papers/svg/gui/t...
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-23 04:10 PST by Eric Seidel (no email)
Modified: 2006-12-05 17:45 PST (History)
0 users

See Also:


Attachments
First attempt (3.83 KB, patch)
2006-12-03 07:51 PST, Rob Buis
mitz: review-
Details | Formatted Diff | Diff
Improved patch (3.81 KB, patch)
2006-12-03 08:28 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Also test paths and images (6.92 KB, patch)
2006-12-03 10:17 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Improved testcase + patch (6.30 KB, patch)
2006-12-05 01:36 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Improved testcase (6.32 KB, patch)
2006-12-05 13:03 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Improved patch (6.27 KB, patch)
2006-12-05 13:32 PST, Rob Buis
mitz: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2006-11-23 04:10:27 PST
WebKit draws Carto.net tabgroup example completely incorrectly (ff does fine)

http://www.carto.net/papers/svg/gui/tabgroup/index.svg

It looks like there is an issue measuring the text which is causing the tabs to be so small.  Then some text drawing issues, as well as some hit detection issues. The hit detection issues might be related to the measuring.
Comment 1 Rob Buis 2006-12-02 08:19:29 PST
Hi Eric,

(In reply to comment #0)
> WebKit draws Carto.net tabgroup example completely incorrectly (ff does fine)
> 
> http://www.carto.net/papers/svg/gui/tabgroup/index.svg
> 
> It looks like there is an issue measuring the text which is causing the tabs to
> be so small.  Then some text drawing issues, as well as some hit detection
> issues. The hit detection issues might be related to the measuring.

I looked into it and getBBox is wrong on the text element that gets created dynamically. It is
basically an empty rect (0, 0, 0, 0), causing indeed measuring problems. It seems the render object
is created but not layouted. Not sure how to handle this yet...
Cheers,

Rob.
Comment 2 Eric Seidel (no email) 2006-12-02 10:40:02 PST
> I looked into it and getBBox is wrong on the text element that gets created
> dynamically. It is
> basically an empty rect (0, 0, 0, 0), causing indeed measuring problems. It
> seems the render object
> is created but not layouted. Not sure how to handle this yet...


I expect that getBBox just needs to force a layout, similar to how offsetTop works for HTML.
Comment 3 Rob Buis 2006-12-03 07:51:36 PST
Created attachment 11719 [details]
First attempt

This could be a hack, but it works. Hyatt mentioned layoutIfNeeded being used a lot like this, but I couldn't really find it. Also I dislike the const_casts. I am wondering whether html text has the same problem as svg text, where the text is not layouted yet but the text dimensions are queried.
Cheers,

Rob.
Comment 4 mitz 2006-12-03 08:15:06 PST
Comment on attachment 11719 [details]
First attempt

You shouldn't try to force layout of a subtree like that, nor should the check be pushed down to the renderer.

The way it's done in HTML is that the DOM method that needs layout information ensures that the document is laid out before querying the renderer. See Element::offsetTop() for example.
Comment 5 Rob Buis 2006-12-03 08:28:36 PST
Created attachment 11721 [details]
Improved patch

Just what I was looking for, thnx Mitz!
Cheers,

Rob.
Comment 6 Rob Buis 2006-12-03 10:17:34 PST
Created attachment 11722 [details]
Also test paths and images

Mitz was right, same problem can happen with images. This patch fixes it as well as does better testing.
Cheers,

Rob.
Comment 7 mitz 2006-12-03 23:04:50 PST
Comment on attachment 11722 [details]
Also test paths and images

I doubt that anything that doesn't apply to all SVGLocatables is correct and robust. For example, what if your element's renderer is a RenderSVGContainer? Can't it have text and image children? It could be my lack of familiarity with this code, but why would the straightforward solution of ensuring layout in SVGLocatable::getBBox not work?

Minor style comments: please avoid "layouted" and use Sentence capitalization in comments.
Comment 8 Rob Buis 2006-12-05 01:36:49 PST
Created attachment 11735 [details]
Improved testcase + patch

As Mitz pointed out, may as well make sure there is a layout done for all svg render objects.
Cheers,

Rob.
Comment 9 Rob Buis 2006-12-05 13:03:28 PST
Created attachment 11744 [details]
Improved testcase

This patch has a fix in the comment.
Furthermore it always performs the updateLayoutIgnorePendingStylesheets call, since potentially the element could have a parent that just had a display property changed from none.
Cheers,

Rob.
Comment 10 Rob Buis 2006-12-05 13:32:52 PST
Created attachment 11745 [details]
Improved patch

Moved the call back into the if since render style updating means the renderer() must be there.
Apart from that some rewording of the WebCore/ChangeLog.
Cheers,

Rob.
Comment 11 mitz 2006-12-05 13:38:32 PST
Comment on attachment 11745 [details]
Improved patch

r=me if you uppercase "svg" and change "are layout" to "are laid out" in the ChangeLog. I still don't like that sentence :-)
Comment 12 Mark Rowe (bdash) 2006-12-05 17:45:08 PST
Landed by Rob in r18032.