Bug 44009 - Use SVGPathParser logic to traverse states of a Path
Summary: Use SVGPathParser logic to traverse states of a Path
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 12047
  Show dependency treegraph
 
Reported: 2010-08-14 07:20 PDT by Dirk Schulze
Modified: 2010-08-18 06:21 PDT (History)
2 users (show)

See Also:


Attachments
Patch (29.65 KB, patch)
2010-08-14 09:36 PDT, Dirk Schulze
no flags Details | Formatted Diff | Diff
Patch (29.51 KB, patch)
2010-08-14 10:11 PDT, Dirk Schulze
no flags Details | Formatted Diff | Diff
Patch (29.58 KB, patch)
2010-08-16 06:16 PDT, Dirk Schulze
zimmermann: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Schulze 2010-08-14 07:20:41 PDT
Use SVGPathParser logic to traverse states of a Path.
Comment 1 Dirk Schulze 2010-08-14 09:36:49 PDT
Created attachment 64417 [details]
Patch
Comment 2 Eric Seidel (no email) 2010-08-14 09:52:49 PDT
Attachment 64417 [details] did not build on mac:
Build output: http://queues.webkit.org/results/3772165
Comment 3 Dirk Schulze 2010-08-14 10:08:43 PDT
(In reply to comment #2)
> Attachment 64417 [details] did not build on mac:
> Build output: http://queues.webkit.org/results/3772165

Hah, just tried the debug build on Mac :-)
Comment 4 Dirk Schulze 2010-08-14 10:11:52 PDT
Created attachment 64420 [details]
Patch
Comment 5 Nikolas Zimmermann 2010-08-15 13:33:37 PDT
Comment on attachment 64420 [details]
Patch

Hi Dirk, good job, some comments:

WebCore/ChangeLog:8
 +          Move the getPathSegAtLength logic from SVGPathSegList to a new SVGPathParser Consumer.
Move the getPathsegAtLength logic from SVGPathSegList into a new SVGPathConsumer class: SVGPathTraversalStateBuilder.

WebCore/ChangeLog:9-10
 +          This allows us to get a SVGPathSeg at a given length of SVGPathByteStreams, as
 +          well as of SVGPathSegLists.
This allows us to get a SVGPathSeg at a given length for SVGPathByteStreams and SVGPathSegLists.

WebCore/svg/SVGPathBuilder.h:39
 +      virtual void nextPathSegment() { }
nextPathSegment sounds like it would give you the next path segment type or something.
suggestion: "pathSegmentStarted". (wrong, see below :-)
Just saw that you're calling it after the segment has been processed, so "incrementPathSegmentCount" sounds even better.


WebCore/svg/SVGPathBuilder.h:40
 +      virtual bool quitEarlier() { return false; }
I'd name it "continueConsuming" return true by default.

WebCore/svg/SVGPathElement.idl:40
 +          unsigned long getPathSegAtLength(in float distance);
Ok, just checked SVG 1.1, this is indeed correct, getPathSegAtLength doesn't raise exceptions, so fine with me.

WebCore/svg/SVGPathParserFactory.cpp:79
 +  static SVGPathTraversalStateBuilder* globalSVGPathTraversalStateBuilder(PathTraversalState* traversalState, float length)
Take a PathTraversalState& reference here.

WebCore/svg/SVGPathParserFactory.cpp:85
 +      s_builder->setCurrentTraversalState(traversalState);
Use &traversalState.

WebCore/svg/SVGPathParserFactory.cpp:275
 +      OwnPtr<PathTraversalState> traversalState = adoptPtr(new PathTraversalState(PathTraversalState::TraversalSegmentAtLength));
Don't create this on the heap - there's no gain in doing so, just create it on the stack.

WebCore/svg/SVGPathTraversalStateBuilder.cpp:70
 +      return (m_traversalState->m_totalLength >= m_traversalState->m_desiredLength);
Useless braces.

WebCore/svg/SVGPathTraversalStateBuilder.cpp:76
 +      m_traversalState->m_segmentIndex++;
++m_traversalState->m_segmentIndex.
Comment 6 Dirk Schulze 2010-08-15 22:47:25 PDT
(In reply to comment #5)
> WebCore/svg/SVGPathElement.idl:40
>  +          unsigned long getPathSegAtLength(in float distance);
> Ok, just checked SVG 1.1, this is indeed correct, getPathSegAtLength doesn't raise exceptions, so fine with me.

Sure, I wouldn't change IDL's if they are not wrong :-)
Working on the other issues.
Comment 7 Dirk Schulze 2010-08-16 06:16:15 PDT
Created attachment 64488 [details]
Patch
Comment 8 Nikolas Zimmermann 2010-08-18 01:19:52 PDT
Comment on attachment 64488 [details]
Patch

r=me, with two small suggestions:

WebCore/ChangeLog:8
 +          Move the getPathsegAtLength logic from SVGPathSegList into a new SVGPathConsumer
s/Pathseg/PathSeg/

WebCore/svg/SVGPathTraversalStateBuilder.h:35
 +      unsigned long getSVGPathSeg();
s/getSVGPathSeg/pathSegmentIndex/
Comment 9 Dirk Schulze 2010-08-18 06:21:30 PDT
Committed r65605: <http://trac.webkit.org/changeset/65605>