Bug 11217 - Cleanup svg coding style
Summary: Cleanup svg coding style
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P3 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-08 08:16 PDT by Rob Buis
Modified: 2006-10-31 11:21 PST (History)
3 users (show)

See Also:


Attachments
Cleanup for svg filter code (63.25 KB, patch)
2006-10-08 08:38 PDT, Rob Buis
darin: review+
Details | Formatted Diff | Diff
Cleanup for svg SVGPath* code (70.13 KB, patch)
2006-10-08 09:15 PDT, Rob Buis
oliver: review+
Details | Formatted Diff | Diff
Cleanup for svg code in shape classes (28.25 KB, patch)
2006-10-08 12:23 PDT, Rob Buis
aroben: review+
Details | Formatted Diff | Diff
Cleaning up of anim* classes (14.93 KB, patch)
2006-10-09 07:32 PDT, Rob Buis
mitz: review-
Details | Formatted Diff | Diff
Improved patch (19.15 KB, patch)
2006-10-09 12:25 PDT, Rob Buis
mitz: review-
Details | Formatted Diff | Diff
New anim patch (19.58 KB, patch)
2006-10-10 01:11 PDT, Rob Buis
mitz: review+
Details | Formatted Diff | Diff
Cleanup for svg text code (21.16 KB, patch)
2006-10-10 13:52 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Improved patch (21.20 KB, patch)
2006-10-11 12:51 PDT, Rob Buis
mitz: review-
Details | Formatted Diff | Diff
Improved patch (21.17 KB, patch)
2006-10-12 01:07 PDT, Rob Buis
mitz: review+
Details | Formatted Diff | Diff
First attempt (41.33 KB, patch)
2006-10-12 13:09 PDT, Rob Buis
mitz: review-
Details | Formatted Diff | Diff
Improved patch (43.42 KB, patch)
2006-10-13 03:23 PDT, Rob Buis
mitz: review-
Details | Formatted Diff | Diff
Improved patch (43.96 KB, patch)
2006-10-13 04:44 PDT, Rob Buis
mitz: review+
Details | Formatted Diff | Diff
First attempt (37.68 KB, patch)
2006-10-13 12:11 PDT, Rob Buis
mitz: review-
Details | Formatted Diff | Diff
Improved patch (39.41 KB, patch)
2006-10-13 13:22 PDT, Rob Buis
mitz: review+
Details | Formatted Diff | Diff
First attempt (43.46 KB, patch)
2006-10-14 13:57 PDT, Rob Buis
mitz: review-
Details | Formatted Diff | Diff
Improved patch (44.10 KB, patch)
2006-10-15 00:16 PDT, Rob Buis
mitz: review+
Details | Formatted Diff | Diff
First attempt (19.73 KB, patch)
2006-10-16 12:31 PDT, Rob Buis
mitz: review-
Details | Formatted Diff | Diff
Improved patch (19.81 KB, patch)
2006-10-20 00:49 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Even better patch (19.65 KB, patch)
2006-10-20 01:24 PDT, 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 Rob Buis 2006-10-08 08:16:02 PDT
Svg code has the following style problems:

- use of if(, for(, while(, switch(
- unsorted inludes
- usage of * on the right, for instance Foo *foo instead of Foo* foo, same for &
- using namespace Webcore; instead of wrapping the implementation code in namespace WebCore { ... }
- unneeded includes, { not on the same line as if, incorrect use of whitespace
Comment 1 Rob Buis 2006-10-08 08:38:56 PDT
Created attachment 10979 [details]
Cleanup for svg filter code

Should be clear what this about looking at the description :)
Cheers,

Rob.
Comment 2 Rob Buis 2006-10-08 09:15:18 PDT
Created attachment 10980 [details]
Cleanup for svg SVGPath* code

This one is pretty straightforward.
Cheers,

Rob.
Comment 3 Rob Buis 2006-10-08 12:23:42 PDT
Created attachment 10986 [details]
Cleanup for svg code in shape classes

This time a cleanup for shape classes.
Cheers,

Rob.
Comment 4 Adam Roben (:aroben) 2006-10-08 13:08:46 PDT
Comment on attachment 10986 [details]
Cleanup for svg code in shape classes

r=me
Comment 5 Oliver Hunt 2006-10-08 13:30:10 PDT
Comment on attachment 10980 [details]
Cleanup for svg SVGPath* code

remove 

-    filterStyle->deref(view()->renderArena());
+    filterStyle->deref(document()->renderArena());

and associated bits before landing, as we discussed.
Comment 6 Darin Adler 2006-10-08 13:31:50 PDT
Comment on attachment 10979 [details]
Cleanup for svg filter code

Looks good.
Comment 7 Oliver Hunt 2006-10-08 13:48:42 PDT
Comment on attachment 10980 [details]
Cleanup for svg SVGPath* code

looks sane to me
Comment 8 Rob Buis 2006-10-09 07:32:46 PDT
Created attachment 10992 [details]
Cleaning up of anim* classes

Small patch this time, anim* classes...
Cheers,

Rob.
Comment 9 mitz 2006-10-09 10:23:44 PDT
Comment on attachment 10992 [details]
Cleaning up of anim* classes

             Node *target = parentNode();
-            while(target != 0) {
+            while (target != 0) {

Forgot to move the star there. Also, per the style guidelines, the second line should say just
+            while (target) {
Comment 10 mitz 2006-10-09 12:07:57 PDT
Comment on attachment 10992 [details]
Cleaning up of anim* classes

Rob is going to post an updated patch
Comment 11 Rob Buis 2006-10-09 12:25:09 PDT
Created attachment 10995 [details]
Improved patch

This one solves some issues with the previous, now obsoleted anim patch.
Cheers,

Rob.
Comment 12 mitz 2006-10-09 13:58:45 PDT
Comment on attachment 10995 [details]
Improved patch

I asked Rob to make a few more changes: change NULLs to 0s, keep the #include "SVGColor.h" in SVGAnimateColorElement.cpp, and move the open braces in switch statements to the same line.
Comment 13 Rob Buis 2006-10-10 01:11:04 PDT
Created attachment 11010 [details]
New anim patch

Addreessing Mitz' issues this time I hope :)
Cheers,

Rob.
Comment 14 mitz 2006-10-10 01:39:36 PDT
Comment on attachment 11010 [details]
New anim patch

r=me
Comment 15 Rob Buis 2006-10-10 13:52:32 PDT
Created attachment 11023 [details]
Cleanup for svg text code

This time a cleanup for text related classes.
Cheers,

Rob.
Comment 16 Rob Buis 2006-10-11 12:51:53 PDT
Created attachment 11035 [details]
Improved patch

New patch after olliej' text changes.
Cheers,

Rob.
Comment 17 mitz 2006-10-11 13:53:14 PDT
Comment on attachment 11035 [details]
Improved patch

There are several declarations (repeating in several headers) where you could drop the parameter names:

+        virtual void parseMappedAttribute(MappedAttribute* attr);
+        virtual RenderObject* createRenderer(RenderArena* arena, RenderStyle* style);
+        bool childShouldCreateRenderer(Node* child) const;
+        virtual void updateLocalTransform(SVGTransformList* localTransforms);

The second line here should be indented:

+SVGTSpanElement::SVGTSpanElement(const QualifiedName& tagName, Document* doc)
 : SVGTextPositioningElement(tagName, doc)
Comment 18 Rob Buis 2006-10-12 01:07:54 PDT
Created attachment 11042 [details]
Improved patch

Fixing the headers...
Cheers,

Rob.
Comment 19 mitz 2006-10-12 06:41:21 PDT
Comment on attachment 11042 [details]
Improved patch

r=me
Comment 20 Rob Buis 2006-10-12 13:09:54 PDT
Created attachment 11052 [details]
First attempt

Various style fixes for svg structure classes.
Cheers,

Rob.
Comment 21 mitz 2006-10-13 00:56:33 PDT
Comment on attachment 11052 [details]
First attempt

Unnecessary parameter names in
+        SVGDocument(DOMImplementation* i, FrameView* view);

These should be two lines each:
+    if (SVGLangSpace::parseMappedAttribute(attr)) return;
+    if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return;
+    if (SVGFitToViewBox::parseMappedAttribute(attr)) return;

I also discussed with Rob the commented-out code in SVGSVGElement.cpp. Those comments should be deleted and replaced with FIXMEs, preferably referring to bugs about the missing functionality.
Comment 22 Rob Buis 2006-10-13 03:23:43 PDT
Created attachment 11062 [details]
Improved patch

Now includes FIXMEs in SVGSVGElement referencing to bug numbers.
Cheers,

Rob.
Comment 23 mitz 2006-10-13 03:39:22 PDT
Comment on attachment 11062 [details]
Improved patch

Looks great!
+    //FIXME: implement me (see bug 11273)
1) There should be a space between // and FIXME.
2) You should use sentence capitalization for the part after "FIXME:", e.g. "// FIXME: Implement me (see bug 11273)". (This applies also to comments that you added that have the space after the //).
Comment 24 Rob Buis 2006-10-13 04:44:36 PDT
Created attachment 11065 [details]
Improved patch

Fixing remaining issues.
Cheers,

Rob.
Comment 25 mitz 2006-10-13 05:04:25 PDT
Comment on attachment 11065 [details]
Improved patch

Two stars remaining to be moved here:
         virtual bool rendererIsNeeded(RenderStyle *style) { return StyledElement::rendererIsNeeded(style); }
-        virtual RenderObject *createRenderer(RenderArena *arena, RenderStyle *style);
+        virtual RenderObject *createRenderer(RenderArena*, RenderStyle*);

You can fix this when landing. r=me
Comment 26 Rob Buis 2006-10-13 12:11:06 PDT
Created attachment 11073 [details]
First attempt

Cleaning up the house, err paint servers ;->
Cheers,

Rob.
Comment 27 mitz 2006-10-13 12:53:17 PDT
Comment on attachment 11073 [details]
First attempt

Redundant parameter names (some of these show up multiple times):

-        virtual void buildGradient(KRenderingPaintServerGradient *grad) const = 0;
+        virtual void buildGradient(KRenderingPaintServerGradient* grad) const = 0;

-        const SVGStyledElement *pushAttributeContext(const SVGStyledElement *context);
+        const SVGStyledElement* pushAttributeContext(const SVGStyledElement* context);

-        virtual void buildGradient(KRenderingPaintServerGradient *grad) const;
+        virtual void buildGradient(KRenderingPaintServerGradient* grad) const;

Don't need the "!= 0" here:

+    for (Node* n = target->firstChild(); n != 0; n = n->nextSibling()) {

Don't need the space before the > here (some of these show up multiple times):

         SVGStyledElement* e = static_cast<SVGStyledElement* >(elem);

         SVGStyledElement* styled = (current ? static_cast<SVGStyledElement* >(current->element()) : 0);

         m_paintServer->setListener(const_cast<SVGPatternElement* >(this));

-    KRenderingPaintServerRadialGradient *grad = static_cast<KRenderingPaintServerRadialGradient *>(_grad);
+    KRenderingPaintServerRadialGradient* grad = static_cast<KRenderingPaintServerRadialGradient* >(_grad);

-        KRenderingPaintServerGradient *gradient = static_cast<KRenderingPaintServerGradient *>(pserver);
+        KRenderingPaintServerGradient* gradient = static_cast<KRenderingPaintServerGradient* >(pserver);

+            KRenderingPaintServerRadialGradient* radial = static_cast<KRenderingPaintServerRadialGradient* >(pserver);
Comment 28 Rob Buis 2006-10-13 13:22:31 PDT
Created attachment 11077 [details]
Improved patch

This should address Mitz' issues.
Cheers,

Rob.
Comment 29 mitz 2006-10-13 13:50:40 PDT
Comment on attachment 11077 [details]
Improved patch

r=me
Comment 30 Rob Buis 2006-10-14 13:57:05 PDT
Created attachment 11089 [details]
First attempt

This time cleaning up basic datastructures.
Cheers,

Rob.
Comment 31 mitz 2006-10-14 14:32:26 PDT
Comment on attachment 11089 [details]
First attempt

My only comments are about lines that the patch doesn't touch:

The opening brace should go on the same line as the case:

         case SVG_LENGTHTYPE_EXS:
         {

This needs spaces after the semicolons:

     for (unsigned long i = 0;i < list->numberOfItems();i++) {

The way this is split into lines doesn't make sense. I think two lines with 4 parameters in each will suffice, but otherwise, it should be 2 parameters on each line:
+        SVGMatrix* getCTM(float logicX, float logicY,
                               float logicWidth, float logicHeight,
                               float physX, float physY, float physWidth,
                               float physHeight);
Comment 32 Rob Buis 2006-10-15 00:16:35 PDT
Created attachment 11092 [details]
Improved patch

This one should address Mitz' issues.
Cheers,

Rob.
Comment 33 mitz 2006-10-15 00:42:21 PDT
Comment on attachment 11092 [details]
Improved patch

r=me
Comment 34 Rob Buis 2006-10-16 12:31:02 PDT
Created attachment 11114 [details]
First attempt

This one should be easy to review :-)
Cheers,

Rob.
Comment 35 mitz 2006-10-20 00:18:29 PDT
Comment on attachment 11114 [details]
First attempt

Don't need "!= 0" here:
+    for (Node* n = firstChild(); n != 0; n = n->nextSibling()) {

Don't need the "angle" and "attr" parameter names: 
+        void setOrientToAngle(SVGAngle* angle);

         virtual void attributeChanged(Attribute* attr, bool preserveDecls);
Comment 36 Rob Buis 2006-10-20 00:49:59 PDT
Created attachment 11163 [details]
Improved patch

This patch should fix the remaining issues.
Cheers,

Rob.
Comment 37 Rob Buis 2006-10-20 01:24:36 PDT
Created attachment 11165 [details]
Even better patch

Mitz noted some problems with my previous patch, so I invalidated that one, this
one should be better.
Cheers,

Rob.
Comment 38 mitz 2006-10-20 01:44:17 PDT
Comment on attachment 11165 [details]
Even better patch

r=me
Comment 39 Mark Rowe (bdash) 2006-10-24 04:35:55 PDT
Do any of these patches remain to be landed?  It's still showing up in the pending commit queue, but it's not at all obvious which of these patches have been landed.
Comment 40 Rob Buis 2006-10-24 06:06:11 PDT
Hi,

(In reply to comment #39)
> Do any of these patches remain to be landed?  It's still showing up in the
> pending commit queue, but it's not at all obvious which of these patches have
> been landed.

All patches that have been appended are reviewed and okayed (sometimes not on the first try). I expect there is still one big patch and one or two small patches left before all of the svg code has been cleaned up, I plan to do the big one soon. Once these are done, the whole bug can be closed. I hope that clears things up a bit.
Cheers,

Rob.
Comment 41 Sam Weinig 2006-10-24 07:04:25 PDT
(In reply to comment #40)

Rob,
It would be helpful if you checked the "obsolete" check-mark for the patches that have been applied (or rejected) so that we can figure out what, if anything, is left to commit.  If it's possible, it would also be nice if you (or the commiter) noted what revision the patches were landed in.
Comment 42 Rob Buis 2006-10-24 07:31:25 PDT
Hi Sam,

(In reply to comment #41)
> (In reply to comment #40)
> 
> Rob,
> It would be helpful if you checked the "obsolete" check-mark for the patches
> that have been applied (or rejected) so that we can figure out what, if
> anything, is left to commit.  If it's possible, it would also be nice if you
> (or the commiter) noted what revision the patches were landed in.

I tried to obsolete some but I get an error after checking the obsolete flag.
Cheers,

Rob.
Comment 43 mitz 2006-10-31 11:09:50 PST
Comment on attachment 10986 [details]
Cleanup for svg code in shape classes

Landed in r16918
Comment 44 mitz 2006-10-31 11:11:26 PST
Comment on attachment 10980 [details]
Cleanup for svg SVGPath* code

Landed in r16920
Comment 45 mitz 2006-10-31 11:13:04 PST
Comment on attachment 11010 [details]
New anim patch

Landed in r16963
Comment 46 mitz 2006-10-31 11:14:41 PST
Comment on attachment 11042 [details]
Improved patch

Landed in r17008
Comment 47 mitz 2006-10-31 11:15:41 PST
Comment on attachment 11065 [details]
Improved patch

Landed in r17027
Comment 48 mitz 2006-10-31 11:16:42 PST
Comment on attachment 11077 [details]
Improved patch

Landed in r17041
Comment 49 mitz 2006-10-31 11:17:51 PST
Comment on attachment 11092 [details]
Improved patch

Landed in r17062
Comment 50 mitz 2006-10-31 11:18:19 PST
Comment on attachment 11165 [details]
Even better patch

Landed in r17158
Comment 51 mitz 2006-10-31 11:21:05 PST
I guess we're done here :-)