Changeset 65472 in webkit


Ignore:
Timestamp:
Aug 16, 2010 5:41:17 PM (14 years ago)
Author:
andreas.kling@nokia.com
Message:

2010-08-16 Andreas Kling <andreas.kling@nokia.com>

Reviewed by Ariya Hidayat.

[Qt] Path::closeSubpath() should only close the last subpath if it has >1 point
https://bugs.webkit.org/show_bug.cgi?id=44061

Spec link:
http://www.whatwg.org/specs/web-apps/current-work/#dom-context-2d-closepath

Test: fast/canvas/canvas-closePath-single-point.html

  • platform/graphics/Path.h: Add a Qt-only member to track the last subpath.
  • platform/graphics/qt/PathQt.cpp: (WebCore::Path::closeSubpath): Only close the last subpath if it has more than 1 point. Otherwise behave as moveTo(first point in last subpath) (WebCore::Path::Path): (WebCore::Path::operator=): (WebCore::Path::moveTo): (WebCore::Path::transform):

2010-08-16 Andreas Kling <andreas.kling@nokia.com>

Reviewed by Ariya Hidayat.

[Qt] Path::closeSubpath() should only close the last subpath if it has >1 point
https://bugs.webkit.org/show_bug.cgi?id=44061

Add a test to verify behavior of closePath() when path has only 1 point.

  • fast/canvas/canvas-closePath-single-point-expected.txt: Added.
  • fast/canvas/canvas-closePath-single-point.html: Added.
  • fast/canvas/script-tests/canvas-closePath-single-point.js: Added.
Location:
trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r65470 r65472  
     12010-08-16  Andreas Kling  <andreas.kling@nokia.com>
     2
     3        Reviewed by Ariya Hidayat.
     4
     5        [Qt] Path::closeSubpath() should only close the last subpath if it has >1 point
     6        https://bugs.webkit.org/show_bug.cgi?id=44061
     7
     8        Add a test to verify behavior of closePath() when path has only 1 point.
     9
     10        * fast/canvas/canvas-closePath-single-point-expected.txt: Added.
     11        * fast/canvas/canvas-closePath-single-point.html: Added.
     12        * fast/canvas/script-tests/canvas-closePath-single-point.js: Added.
     13
    1142010-08-16  Nate Chapin  <japhet@chromium.org>
    215
  • trunk/WebCore/ChangeLog

    r65469 r65472  
     12010-08-16  Andreas Kling  <andreas.kling@nokia.com>
     2
     3        Reviewed by Ariya Hidayat.
     4
     5        [Qt] Path::closeSubpath() should only close the last subpath if it has >1 point
     6        https://bugs.webkit.org/show_bug.cgi?id=44061
     7
     8        Spec link:
     9        http://www.whatwg.org/specs/web-apps/current-work/#dom-context-2d-closepath
     10
     11        Test: fast/canvas/canvas-closePath-single-point.html
     12
     13        * platform/graphics/Path.h: Add a Qt-only member to track the last subpath.
     14        * platform/graphics/qt/PathQt.cpp:
     15        (WebCore::Path::closeSubpath): Only close the last subpath if it
     16        has more than 1 point. Otherwise behave as moveTo(first point in last subpath)
     17        (WebCore::Path::Path):
     18        (WebCore::Path::operator=):
     19        (WebCore::Path::moveTo):
     20        (WebCore::Path::transform):
     21
    1222010-08-16  Nate Chapin  <japhet@chromium.org>
    223
  • trunk/WebCore/platform/graphics/Path.h

    r65021 r65472  
    157157    private:
    158158        PlatformPathPtr m_path;
     159
     160#if PLATFORM(QT)
     161        int m_lastMoveToIndex;
     162#endif
    159163    };
    160164
  • trunk/WebCore/platform/graphics/qt/PathQt.cpp

    r65376 r65472  
    5252
    5353Path::Path()
     54    : m_lastMoveToIndex(0)
    5455{
    5556}
     
    6162Path::Path(const Path& other)
    6263    : m_path(other.m_path)
     64    , m_lastMoveToIndex(other.m_lastMoveToIndex)
    6365{
    6466}
     
    6769{
    6870    m_path = other.m_path;
     71    m_lastMoveToIndex = other.m_lastMoveToIndex;
    6972    return *this;
    7073}
     
    181184void Path::moveTo(const FloatPoint& point)
    182185{
     186    m_lastMoveToIndex = m_path.elementCount();
    183187    m_path.moveTo(point);
    184188}
     
    261265void Path::closeSubpath()
    262266{
    263     m_path.closeSubpath();
     267    const int elementCount = m_path.elementCount();
     268
     269    if (!elementCount)
     270        return;
     271
     272    QPointF lastMoveToPoint = m_path.elementAt(m_lastMoveToIndex);
     273    int elementsInLastSubpath = 0;
     274
     275    for (int i = m_lastMoveToIndex; i < elementCount; ++i) {
     276        QPainterPath::Element element = m_path.elementAt(i);
     277        if (element.isLineTo() || element.isCurveTo()) {
     278            // All we need to know is if there are 1 or more elements in the last subpath.
     279            if (++elementsInLastSubpath == 2) {
     280                m_path.lineTo(lastMoveToPoint);
     281                return;
     282            }
     283        }
     284    }
     285
     286    moveTo(lastMoveToPoint);
    264287}
    265288
     
    441464    if (m_path.isEmpty() && m_path.elementCount()) {
    442465        QPointF point = qTransform.map(m_path.currentPosition());
    443         m_path.moveTo(point);
     466        moveTo(point);
    444467    } else
    445468#endif
Note: See TracChangeset for help on using the changeset viewer.