Changeset 59213 in webkit


Ignore:
Timestamp:
May 12, 2010 1:19:18 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-05-12 Robin Qiu <robin.qiu@torchmobile.com.cn>

Reviewed by Dirk Schulze.

Fix a bug in SVGPathSegList::getPathSegAtLength().
This bug is just a misktake: almost all of the code is OK, but the
parameter is not used at all, therefore, this function always returns
"1".
And make a modification to return the last path segment if the distance
exceeds the actual path length.
https://bugs.webkit.org/show_bug.cgi?id=37515

  • svg/dom/svgpath-getPathSegAtLength-expected.txt: Added.
  • svg/dom/svgpath-getPathSegAtLength.html: Added.

2010-05-12 Robin Qiu <robin.qiu@torchmobile.com.cn>

Reviewed by Dirk Schulze.

Fix a bug in SVGPathSegList::getPathSegAtLength().
This bug is just a misktake: almost all of the code is OK, but the
parameter is not used at all, therefore, this function always returns
"1".
And make a modification to return the last path segment if the distance
exceeds the actual path length.
https://bugs.webkit.org/show_bug.cgi?id=37515

Test: svg/dom/svgpath-getPathSegAtLength.html

  • svg/SVGPathSegList.cpp: (WebCore::SVGPathSegList::getPathSegAtLength):
Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r59203 r59213  
     12010-05-12  Robin Qiu  <robin.qiu@torchmobile.com.cn>
     2
     3        Reviewed by Dirk Schulze.
     4
     5        Fix a bug in SVGPathSegList::getPathSegAtLength().
     6        This bug is just a misktake: almost all of the code is OK, but the
     7        parameter is not used at all, therefore, this function always returns
     8        "1".
     9        And make a modification to return the last path segment if the distance
     10        exceeds the actual path length.
     11        https://bugs.webkit.org/show_bug.cgi?id=37515
     12
     13        * svg/dom/svgpath-getPathSegAtLength-expected.txt: Added.
     14        * svg/dom/svgpath-getPathSegAtLength.html: Added.
     15
    1162010-05-11  Tony Chang  <tony@chromium.org>
    217
  • trunk/WebCore/ChangeLog

    r59211 r59213  
     12010-05-12  Robin Qiu  <robin.qiu@torchmobile.com.cn>
     2
     3        Reviewed by Dirk Schulze.
     4
     5        Fix a bug in SVGPathSegList::getPathSegAtLength().
     6        This bug is just a misktake: almost all of the code is OK, but the
     7        parameter is not used at all, therefore, this function always returns
     8        "1".
     9        And make a modification to return the last path segment if the distance
     10        exceeds the actual path length.
     11        https://bugs.webkit.org/show_bug.cgi?id=37515
     12
     13        Test: svg/dom/svgpath-getPathSegAtLength.html
     14
     15        * svg/SVGPathSegList.cpp:
     16        (WebCore::SVGPathSegList::getPathSegAtLength):
     17
    1182010-05-11  David Hyatt  <hyatt@apple.com>
    219
  • trunk/WebCore/svg/SVGPathSegList.cpp

    r56795 r59213  
    2727#include "SVGPathSegList.h"
    2828
     29#include "FloatConversion.h"
    2930#include "FloatPoint.h"
    3031#include "Path.h"
     
    5253}
    5354
    54 unsigned SVGPathSegList::getPathSegAtLength(double, ExceptionCode& ec)
     55unsigned SVGPathSegList::getPathSegAtLength(double length, ExceptionCode& ec)
    5556{
    5657    // FIXME : to be useful this will need to support non-normalized SVGPathSegLists
     
    5859    // FIXME: Eventually this will likely move to a "path applier"-like model, until then PathTraversalState is less useful as we could just use locals
    5960    PathTraversalState traversalState(PathTraversalState::TraversalSegmentAtLength);
     61    traversalState.m_desiredLength = narrowPrecisionToFloat(length);
    6062    for (int i = 0; i < len; ++i) {
    6163        SVGPathSeg* segment = getItem(i, ec).get();
     
    9395        traversalState.m_totalLength += segmentLength;
    9496        if ((traversalState.m_action == PathTraversalState::TraversalSegmentAtLength)
    95             && (traversalState.m_totalLength > traversalState.m_desiredLength)) {
     97            && (traversalState.m_totalLength >= traversalState.m_desiredLength)) {
    9698            return traversalState.m_segmentIndex;
    9799        }
    98100        traversalState.m_segmentIndex++;
    99101    }
    100    
    101     return 0; // The SVG spec is unclear as to what to return when the distance is not on the path   
     102
     103    // The SVG spec is unclear as to what to return when the distance is not on the path.
     104    // WebKit/Opera/FF all return the last path segment if the distance exceeds the actual path length:
     105    return traversalState.m_segmentIndex ? traversalState.m_segmentIndex - 1 : 0;
    102106}
    103107
Note: See TracChangeset for help on using the changeset viewer.