Bug 33776 - Rewrite SVG <use> support in a modern-fashion
Summary: Rewrite SVG <use> support in a modern-fashion
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P1 Normal
Assignee: Nikolas Zimmermann
URL:
Keywords:
: 25035 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-01-17 16:49 PST by Nikolas Zimmermann
Modified: 2010-01-19 02:50 PST (History)
10 users (show)

See Also:


Attachments
Almost a patch (65.76 KB, patch)
2010-01-18 13:55 PST, Nikolas Zimmermann
no flags Details | Formatted Diff | Diff
Updated patch (248.55 KB, patch)
2010-01-18 16:33 PST, Nikolas Zimmermann
no flags Details | Formatted Diff | Diff
Updated patch v2 (248.74 KB, patch)
2010-01-18 17:36 PST, Nikolas Zimmermann
no flags Details | Formatted Diff | Diff
Updated patch v3 (250.02 KB, patch)
2010-01-18 17:41 PST, Nikolas Zimmermann
krit: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolas Zimmermann 2010-01-17 16:49:01 PST
SVGUseElement was designed in a time where our SVG render tree had zero integration with the rest and where the shadow tree concept has recently been introduced.
It suffers from several design problems. The most important thing to fix is the relationship between the render tree & SVGUseElement - who owns what, who reacts to style updates etc. (SVGUseElement was hacking around the fact there was no renderer managing the shadow tree -> fix that by introducing a RenderSVGShadowTreeContainer). Even more important is to recreate the shadow tree in a _lazy_ way. Currently every attribute change, of every element referenced by a <use> element causes a full recloning (just think about animations ;-)

I've rewritten the <use> support and it's __a lot__ faster now, and fixes tons of bugs, mostly related to relayouting <use> content with percentual values in-use.
Uploading a patch soon, after identifying which bug reports are fixed now :-)
Comment 1 Nikolas Zimmermann 2010-01-17 17:32:41 PST
*** Bug 25035 has been marked as a duplicate of this bug. ***
Comment 2 Nikolas Zimmermann 2010-01-17 17:33:14 PST
*** Bug 17424 has been marked as a duplicate of this bug. ***
Comment 3 Dirk Schulze 2010-01-18 09:21:46 PST
Still waiting for the patch ;-)
Comment 4 Nikolas Zimmermann 2010-01-18 13:55:17 PST
Created attachment 46843 [details]
Almost a patch

Adding the WebCore part, does not contain a ChangeLog, not marking for review yet. Just for Dirk to have a look before I proceed...
Comment 5 Nikolas Zimmermann 2010-01-18 16:33:34 PST
Created attachment 46860 [details]
Updated patch

A real patch, discussed with Dirk on IRC.
Comment 6 WebKit Review Bot 2010-01-18 16:39:14 PST
Attachment 46860 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebCore/svg/SVGUseElement.cpp:171:  Boolean expressions that span multiple lines should have their operators on the left side of the line instead of the right side.  [whitespace/operators] [4]
WebCore/svg/SVGUseElement.cpp:172:  Boolean expressions that span multiple lines should have their operators on the left side of the line instead of the right side.  [whitespace/operators] [4]
WebCore/rendering/RenderSVGTransformableContainer.cpp:28:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 3


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Nikolas Zimmermann 2010-01-18 17:36:07 PST
Created attachment 46869 [details]
Updated patch v2

Fix last-minute regressions, in changes I made on the fly while working on Dirks comments :/ Passes pixel tests without regressions with tolerance=0 here.
Testing SVG animations is a joke though, as the W3C-SVG-1.1 are dumped before the anim even starts - unfortunately Antti did not work on that while creating SVG animations support.. anyhow I've manually checked the anims work fine.
Comment 8 WebKit Review Bot 2010-01-18 17:40:51 PST
Attachment 46869 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebCore/rendering/RenderSVGTransformableContainer.cpp:28:  Alphabetical sorting problem.  [build/include_order] [4]
WebCore/rendering/RenderSVGTransformableContainer.cpp:54:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Total errors found: 2


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 9 Nikolas Zimmermann 2010-01-18 17:41:41 PST
Created attachment 46870 [details]
Updated patch v3
Comment 10 Dirk Schulze 2010-01-18 17:47:05 PST
Comment on attachment 46870 [details]
Updated patch v3

Niko an I had a long discussen and went through the code step by step. Niko already fixed all issues.
The zero check is neccessary here. Negative offsets are allowed. Niko will change the  alphabetic order before landing.
 r=me
Great patch Niko!
Comment 11 WebKit Review Bot 2010-01-18 17:47:28 PST
Attachment 46870 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebCore/rendering/RenderSVGTransformableContainer.cpp:28:  Alphabetical sorting problem.  [build/include_order] [4]
WebCore/rendering/RenderSVGTransformableContainer.cpp:54:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Total errors found: 2


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 12 Nikolas Zimmermann 2010-01-18 17:51:02 PST
(In reply to comment #11)
> Attachment 46870 [details] did not pass style-queue:
> 
> Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
> WebCore/rendering/RenderSVGTransformableContainer.cpp:28:  Alphabetical sorting
> problem.  [build/include_order] [4]

Will fix before landing.

> WebCore/rendering/RenderSVGTransformableContainer.cpp:54:  Tests for
> true/false, null/non-null, and zero/non-zero should all be done without
> equality comparisons.  [readability/comparison_to_zero] [5]

This is expected, we want to check for width/height exactly to be 0, they can be negative so !width, won't help. Shall I fix a bug? Eric?
Comment 13 Eric Seidel (no email) 2010-01-18 17:52:24 PST
I don't deal much with the style bot, but yes.  The general answer is you should always file a bug. :)  false positives are very-bad as they make people not trust the bot.
Comment 14 Nikolas Zimmermann 2010-01-18 18:18:02 PST
Committed r53446: <http://trac.webkit.org/changeset/53446>
Comment 15 Shinichiro Hamaji 2010-01-18 23:13:03 PST
> This is expected, we want to check for width/height exactly to be 0, they can
> be negative so !width, won't help. Shall I fix a bug? Eric?

I don't know well about this area well, but I tried the following code and I didn't see any difference between f==0 and !f . I guess we need to use signbit() to check if a float is a positive-zero.

#include <stdio.h>
#include <math.h>

void isPositiveZero(float f) {
  printf("=== %f ===\n", f);
  printf("f == 0: %d\n", f == 0);
  printf("f == 0.0f: %d\n", f == 0.0f);
  printf("f == 0.0: %d\n", f == 0.0);
  printf("!f: %d\n", !f);
  // The above 4 checks return 1 for both 0.0f and -0.0f.
  printf("!f && !signbit(f): %d\n", !f && !signbit(f));
}

int main() {
  isPositiveZero(0.0f);
  isPositiveZero(-0.0f);
}
Comment 16 Dirk Schulze 2010-01-19 02:50:14 PST
(In reply to comment #15)
> > This is expected, we want to check for width/height exactly to be 0, they can
> > be negative so !width, won't help. Shall I fix a bug? Eric?
> 
> I don't know well about this area well, but I tried the following code and I
> didn't see any difference between f==0 and !f . I guess we need to use
> signbit() to check if a float is a positive-zero.
> 
> #include <stdio.h>
> #include <math.h>
> 
> void isPositiveZero(float f) {
>   printf("=== %f ===\n", f);
>   printf("f == 0: %d\n", f == 0);
>   printf("f == 0.0f: %d\n", f == 0.0f);
>   printf("f == 0.0: %d\n", f == 0.0);
>   printf("!f: %d\n", !f);
>   // The above 4 checks return 1 for both 0.0f and -0.0f.
>   printf("!f && !signbit(f): %d\n", !f && !signbit(f));
> }
> 
> int main() {
>   isPositiveZero(0.0f);
>   isPositiveZero(-0.0f);
> }
You may have misunaderstood Niko. It's not the question of 0 or -0 or other combinations of zero. It's just, that we don't make something if the offset is zero, but make translations if the offset gets negative like (-3,-4). That is not covered with !offset. So the style bot is a bit to strict on this rule.