Bug 128658 - Refactor SVGPreserveAspectRatio::parse()
Summary: Refactor SVGPreserveAspectRatio::parse()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Gyuyoung Kim
URL:
Keywords: BlinkMergeCandidate
Depends on:
Blocks:
 
Reported: 2014-02-11 23:59 PST by Gyuyoung Kim
Modified: 2014-02-18 01:37 PST (History)
11 users (show)

See Also:


Attachments
Patch (6.21 KB, patch)
2014-02-12 00:02 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
Patch (6.21 KB, patch)
2014-02-12 00:04 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from webkit-ews-12 for mac-mountainlion-wk2 (1.05 MB, application/zip)
2014-02-12 01:10 PST, Build Bot
no flags Details
Archive of layout-test-results from webkit-ews-01 for mac-mountainlion (1.07 MB, application/zip)
2014-02-12 01:29 PST, Build Bot
no flags Details
Archive of layout-test-results from webkit-ews-04 for mac-mountainlion (1.13 MB, application/zip)
2014-02-12 01:39 PST, Build Bot
no flags Details
Patch (6.35 KB, patch)
2014-02-12 17:48 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
Patch (7.04 KB, patch)
2014-02-14 02:30 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
Patch (8.42 KB, patch)
2014-02-14 22:18 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
Patch (8.51 KB, patch)
2014-02-14 22:30 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from webkit-ews-14 for mac-mountainlion-wk2 (456.68 KB, application/zip)
2014-02-14 23:22 PST, Build Bot
no flags Details
Archive of layout-test-results from webkit-ews-03 for mac-mountainlion (494.68 KB, application/zip)
2014-02-15 00:01 PST, Build Bot
no flags Details
Archive of layout-test-results from webkit-ews-05 for mac-mountainlion (487.33 KB, application/zip)
2014-02-15 00:56 PST, Build Bot
no flags Details
Patch (8.10 KB, patch)
2014-02-16 23:50 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gyuyoung Kim 2014-02-11 23:59:53 PST
This cl removes "goto" and replaces it with local variables, and fixes poor coding style.
Comment 1 Gyuyoung Kim 2014-02-12 00:02:06 PST
Created attachment 223945 [details]
Patch
Comment 2 Gyuyoung Kim 2014-02-12 00:04:33 PST
Created attachment 223946 [details]
Patch
Comment 3 Build Bot 2014-02-12 01:10:27 PST
Comment on attachment 223946 [details]
Patch

Attachment 223946 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/6255577655148544

New failing tests:
svg/animations/svgPreserveAspectRatio-animation-1.html
svg/dom/preserve-aspect-ratio-parser.html
http/tests/misc/object-embedding-svg-delayed-size-negotiation-2.htm
svg/W3C-SVG-1.1/coords-viewattr-01-b.svg
svg/zoom/text/zoom-coords-viewattr-01-b.svg
svg/dynamic-updates/SVGFEImageElement-svgdom-preserveAspectRatio-prop.html
svg/zoom/page/zoom-coords-viewattr-01-b.svg
svg/dom/SVGViewSpec.html
Comment 4 Build Bot 2014-02-12 01:10:30 PST
Created attachment 223951 [details]
Archive of layout-test-results from webkit-ews-12 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-12  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.5
Comment 5 Build Bot 2014-02-12 01:29:17 PST
Comment on attachment 223946 [details]
Patch

Attachment 223946 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/5510968301846528

New failing tests:
svg/animations/svgPreserveAspectRatio-animation-1.html
svg/dom/preserve-aspect-ratio-parser.html
http/tests/misc/object-embedding-svg-delayed-size-negotiation-2.htm
svg/W3C-SVG-1.1/coords-viewattr-01-b.svg
svg/zoom/text/zoom-coords-viewattr-01-b.svg
svg/dynamic-updates/SVGFEImageElement-svgdom-preserveAspectRatio-prop.html
svg/zoom/page/zoom-coords-viewattr-01-b.svg
svg/dom/SVGViewSpec.html
Comment 6 Build Bot 2014-02-12 01:29:20 PST
Created attachment 223953 [details]
Archive of layout-test-results from webkit-ews-01 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-01  Port: mac-mountainlion  Platform: Mac OS X 10.8.5
Comment 7 Build Bot 2014-02-12 01:39:08 PST
Comment on attachment 223946 [details]
Patch

Attachment 223946 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/5752005356158976

New failing tests:
svg/animations/svgPreserveAspectRatio-animation-1.html
svg/dom/preserve-aspect-ratio-parser.html
http/tests/misc/object-embedding-svg-delayed-size-negotiation-2.htm
svg/W3C-SVG-1.1/coords-viewattr-01-b.svg
svg/zoom/text/zoom-coords-viewattr-01-b.svg
svg/dynamic-updates/SVGFEImageElement-svgdom-preserveAspectRatio-prop.html
svg/zoom/page/zoom-coords-viewattr-01-b.svg
svg/dom/SVGViewSpec.html
Comment 8 Build Bot 2014-02-12 01:39:11 PST
Created attachment 223954 [details]
Archive of layout-test-results from webkit-ews-04 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-04  Port: mac-mountainlion  Platform: Mac OS X 10.8.5
Comment 9 Andreas Kling 2014-02-12 10:59:29 PST
Comment on attachment 223946 [details]
Patch

EWS says this has bugs. Also, what are we fixing here?
Comment 10 Gyuyoung Kim 2014-02-12 15:29:16 PST
(In reply to comment #9)
> (From update of attachment 223946 [details])
> EWS says this has bugs. Also, what are we fixing here?

Though this patch is trivial, I think it is better not to use "goto" in function. That's why I replace "goto" with local variable.
Comment 11 Gyuyoung Kim 2014-02-12 17:48:52 PST
Created attachment 224035 [details]
Patch
Comment 12 Gyuyoung Kim 2014-02-12 17:49:38 PST
(In reply to comment #10)
> (In reply to comment #9)
> > (From update of attachment 223946 [details] [details])
> > EWS says this has bugs. Also, what are we fixing here?
> 
> Though this patch is trivial, I think it is better not to use "goto" in function. That's why I replace "goto" with local variable.

Fixed the failing tests.
Comment 13 Dirk Schulze 2014-02-13 04:50:08 PST
(In reply to comment #12)
> (In reply to comment #10)
> > (In reply to comment #9)
> > > (From update of attachment 223946 [details] [details] [details])
> > > EWS says this has bugs. Also, what are we fixing here?
> > 
> > Though this patch is trivial, I think it is better not to use "goto" in function. That's why I replace "goto" with local variable.
> 
> Fixed the failing tests.

I am curious. You landed the patch in Blink first. Did you land a different patch there, or did the tests not trigger problems there?
Comment 14 Dirk Schulze 2014-02-13 04:55:20 PST
Comment on attachment 224035 [details]
Patch

Looks good in general. It is sad that we set align and meetOrSlice twice on successful parsing. Who is calling ::parse here? If it is an internal function, can we pass a reference to align and meetOrSlice into an inline function instead?

Also, if we return flaw ein your code, do we give a warning on the console like for the other attributes?
Comment 15 Gyuyoung Kim 2014-02-13 20:45:42 PST
(In reply to comment #13)
> (In reply to comment #12)
> > (In reply to comment #10)
> > > (In reply to comment #9)
> > > > (From update of attachment 223946 [details] [details] [details] [details])
> > > > EWS says this has bugs. Also, what are we fixing here?
> > > 
> > > Though this patch is trivial, I think it is better not to use "goto" in function. That's why I replace "goto" with local variable.
> > 
> > Fixed the failing tests.
> 
> I am curious. You landed the patch in Blink first. Did you land a different patch there, or did the tests not trigger problems there?

No, almost is same. I just missed to use local variable in first patch. There is no difference between them except for checking the exception code in setAlign() and setMeetOrSlice().
Comment 16 Gyuyoung Kim 2014-02-13 21:03:28 PST
(In reply to comment #14)
> (From update of attachment 224035 [details])
> Looks good in general. It is sad that we set align and meetOrSlice twice on successful parsing. Who is calling ::parse here? If it is an internal function, can we pass a reference to align and meetOrSlice into an inline function instead?
> 
> Also, if we return flaw ein your code, do we give a warning on the console like for the other attributes?

Let me try to adjust your suggestion to this patch.
Comment 17 Gyuyoung Kim 2014-02-14 01:58:54 PST
(In reply to comment #14)
> (From update of attachment 224035 [details])
> Looks good in general. It is sad that we set align and meetOrSlice twice on successful parsing. Who is calling ::parse here? If it is an internal function, can we pass a reference to align and meetOrSlice into an inline function instead?

It is a public function. And also, It is invoked by SVGViewSpec.cpp.
https://trac.webkit.org/browser/trunk/Source/WebCore/svg/SVGViewSpec.cpp#L266

> Also, if we return flaw ein your code, do we give a warning on the console like for the other attributes?

It looks we may print some warning messages using LOG_ERROR. Do you agree to use LOG_ERROR to print a warning ?  Besides I think it would be good to use it only for key points.
Comment 18 Gyuyoung Kim 2014-02-14 02:06:23 PST
(In reply to comment #17)
 
> > Also, if we return flaw ein your code, do we give a warning on the console like for the other attributes?
> 
> It looks we may print some warning messages using LOG_ERROR. Do you agree to use LOG_ERROR to print a warning ?  Besides I think it would be good to use it only for key points.

Or, did you mean that we give a warning when the exception code value is not 0 ?
Comment 19 Gyuyoung Kim 2014-02-14 02:30:37 PST
Created attachment 224185 [details]
Patch
Comment 20 Dirk Schulze 2014-02-14 03:45:43 PST
Comment on attachment 224185 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=224185&action=review

> Source/WebCore/svg/SVGPreserveAspectRatio.cpp:72
> +    setAlign(align, ec);
> +    setMeetOrSlice(meetOrSlice, ec);

You set the initial values here and if the parsing is successful at the end again. I didn't check if the two values are pure enums, or if there is more that needs to be done (update DOM stack). A solutions would be to pass align and meetOrSlice into this function as reference.

You say that parse is a public function. Who else is calling SVGPreserveAspectRatio::parse? Is it somewhere outside of SVGPreserveAspectRatio?
Comment 21 Gyuyoung Kim 2014-02-14 22:18:21 PST
Created attachment 224286 [details]
Patch
Comment 22 Gyuyoung Kim 2014-02-14 22:21:16 PST
(In reply to comment #20)
> (From update of attachment 224185 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=224185&action=review
> 
> > Source/WebCore/svg/SVGPreserveAspectRatio.cpp:72
> > +    setAlign(align, ec);
> > +    setMeetOrSlice(meetOrSlice, ec);
> 
> You set the initial values here and if the parsing is successful at the end again. I didn't check if the two values are pure enums, or if there is more that needs to be done (update DOM stack). A solutions would be to pass align and meetOrSlice into this function as reference.

To hide concrete parse() function, I change the existing parse() with parseInternal(), and add parse() to support existing usage. How do you think about this suggestion ?
 
> You say that parse is a public function. Who else is calling SVGPreserveAspectRatio::parse? Is it somewhere outside of SVGPreserveAspectRatio?

As mentioned in comment #17, this is being used by SVGViewSpec::parseViewSpec().
https://trac.webkit.org/browser/trunk/Source/WebCore/svg/SVGViewSpec.cpp#L266
Comment 23 Gyuyoung Kim 2014-02-14 22:30:09 PST
Created attachment 224287 [details]
Patch
Comment 24 Build Bot 2014-02-14 23:22:09 PST
Comment on attachment 224287 [details]
Patch

Attachment 224287 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/5176014002978816

New failing tests:
svg/dom/preserve-aspect-ratio-parser.html
Comment 25 Build Bot 2014-02-14 23:22:12 PST
Created attachment 224288 [details]
Archive of layout-test-results from webkit-ews-14 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-14  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.5
Comment 26 Gyuyoung Kim 2014-02-14 23:45:51 PST
(In reply to comment #24)
> (From update of attachment 224287 [details])
> Attachment 224287 [details] did not pass mac-wk2-ews (mac-wk2):
> Output: http://webkit-queues.appspot.com/results/5176014002978816
> 
> New failing tests:
> svg/dom/preserve-aspect-ratio-parser.html

Let me fix this fail.
Comment 27 Build Bot 2014-02-15 00:01:10 PST
Comment on attachment 224287 [details]
Patch

Attachment 224287 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/5505548321554432

New failing tests:
svg/dom/preserve-aspect-ratio-parser.html
Comment 28 Build Bot 2014-02-15 00:01:17 PST
Created attachment 224289 [details]
Archive of layout-test-results from webkit-ews-03 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-03  Port: mac-mountainlion  Platform: Mac OS X 10.8.5
Comment 29 Build Bot 2014-02-15 00:56:10 PST
Comment on attachment 224287 [details]
Patch

Attachment 224287 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/5288826150846464

New failing tests:
svg/dom/preserve-aspect-ratio-parser.html
Comment 30 Build Bot 2014-02-15 00:56:15 PST
Created attachment 224290 [details]
Archive of layout-test-results from webkit-ews-05 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-05  Port: mac-mountainlion  Platform: Mac OS X 10.8.5
Comment 31 Gyuyoung Kim 2014-02-16 23:50:13 PST
Created attachment 224338 [details]
Patch
Comment 32 Gyuyoung Kim 2014-02-17 00:02:32 PST
(In reply to comment #31)
> Created an attachment (id=224338) [details]
> Patch

>> A solutions would be to pass align and meetOrSlice into this function as reference.

In new patch, I change the parse() with parseInternal(). And, existing parse() calls the parseInternal(). If we pass references of align and meetOrSlice, it looks caller needs to set the reference to m_align, m_meetOrSlice as below,

void SVGPreserveAspectRatio::parse(const String& value)
{
     SVGPreserveAspectRatioType align = SVG_PRESERVEASPECTRATIO_XMIDYMID;
     SVGMeetOrSliceType meetOrSlice = SVG_MEETORSLICE_MEET;

     const UChar* begin = value.deprecatedCharacters();
     parse(begin, begin + value.length(), true);
     parseInternal(begin, begin + value.length(), true, align, meetOrSlice);
     m_align = align;
     m_meetOrSlice = meetOrSlice;
}

It seems the work is a little overhead for caller. I think it would be nicer to handle it inside parseInternal() itself. So, latest patch just sets m_align and m_meetOrSlice in beginning/end of parseInternal(). I think it is not big overhead. Dirk, How do you think ?
Comment 33 Gyuyoung Kim 2014-02-17 14:47:02 PST
(In reply to comment #32)
> (In reply to comment #31)
> > Created an attachment (id=224338) [details] [details]
> > Patch
> 
> >> A solutions would be to pass align and meetOrSlice into this function as reference.
> 
> In new patch, I change the parse() with parseInternal(). And, existing parse() calls the parseInternal(). If we pass references of align and meetOrSlice, it looks caller needs to set the reference to m_align, m_meetOrSlice as below,
> 
> void SVGPreserveAspectRatio::parse(const String& value)
> {
>      SVGPreserveAspectRatioType align = SVG_PRESERVEASPECTRATIO_XMIDYMID;
>      SVGMeetOrSliceType meetOrSlice = SVG_MEETORSLICE_MEET;
> 
>      const UChar* begin = value.deprecatedCharacters();
>      parse(begin, begin + value.length(), true);
>      parseInternal(begin, begin + value.length(), true, align, meetOrSlice);
>      m_align = align;
>      m_meetOrSlice = meetOrSlice;
> }
> 
> It seems the work is a little overhead for caller. I think it would be nicer to handle it inside parseInternal() itself. So, latest patch just sets m_align and m_meetOrSlice in beginning/end of parseInternal(). I think it is not big overhead. Dirk, How do you think ?

Dirk, what do you think about latest patch ?
Comment 34 Dirk Schulze 2014-02-18 01:05:17 PST
Comment on attachment 224338 [details]
Patch

LGTM. r=me.
Comment 35 Gyuyoung Kim 2014-02-18 01:07:33 PST
Comment on attachment 224338 [details]
Patch

Thanks !
Comment 36 WebKit Commit Bot 2014-02-18 01:37:30 PST
Comment on attachment 224338 [details]
Patch

Clearing flags on attachment: 224338

Committed r164276: <http://trac.webkit.org/changeset/164276>
Comment 37 WebKit Commit Bot 2014-02-18 01:37:36 PST
All reviewed patches have been landed.  Closing bug.