2009-07-14 Dmitry Titov <dimich@chromium.org>
authorbfulgham@webkit.org <bfulgham@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Jul 2009 21:28:38 +0000 (21:28 +0000)
committerbfulgham@webkit.org <bfulgham@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Jul 2009 21:28:38 +0000 (21:28 +0000)
        Reviewed by Darin Adler.

        https://bugs.webkit.org/show_bug.cgi?id=27266
        Add hasCurrentPoint() to WebCore::Path.
        This fixes Skia-based Chromium regression caused by the fix for
        https://bugs.webkit.org/show_bug.cgi?id=27187.
        For Skia, the new method always returns 'true', pending actual implementation.
        This means Chromium still will differ from Gecko behavior, but at least its Canvas
        will not be completely broken.

        Existing Canvas Layout Tests should pass in Chromium after this change.

        * html/CanvasRenderingContext2D.cpp:
        (WebCore::CanvasRenderingContext2D::lineTo): insteand of Path::isEmpty() test for hasCurrentPoint().
        (WebCore::CanvasRenderingContext2D::quadraticCurveTo): ditto.
        (WebCore::CanvasRenderingContext2D::bezierCurveTo): ditto.

        * platform/graphics/Path.h:
        * platform/graphics/cairo/PathCairo.cpp:
        (WebCore::Path::hasCurrentPoint):
        * platform/graphics/cg/PathCG.cpp:
        (WebCore::Path::isEmpty):
        (WebCore::Path::hasCurrentPoint):
        * platform/graphics/qt/PathQt.cpp:
        (WebCore::Path::hasCurrentPoint):
        * platform/graphics/skia/PathSkia.cpp:
        (WebCore::Path::hasCurrentPoint):
        * platform/graphics/wx/PathWx.cpp:
        (WebCore::Path::hasCurrentPoint):
        All these files add a Path::hasCurrentPoint() for various platforms.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@45873 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/html/CanvasRenderingContext2D.cpp
WebCore/platform/graphics/Path.h
WebCore/platform/graphics/cairo/PathCairo.cpp
WebCore/platform/graphics/cg/PathCG.cpp
WebCore/platform/graphics/qt/PathQt.cpp
WebCore/platform/graphics/skia/PathSkia.cpp
WebCore/platform/graphics/wx/PathWx.cpp

index e5fc9b2..d13cc5b 100644 (file)
@@ -1,3 +1,36 @@
+2009-07-14  Dmitry Titov  <dimich@chromium.org>
+
+        Reviewed by Darin Adler.
+
+        https://bugs.webkit.org/show_bug.cgi?id=27266
+        Add hasCurrentPoint() to WebCore::Path.
+        This fixes Skia-based Chromium regression caused by the fix for
+        https://bugs.webkit.org/show_bug.cgi?id=27187.
+        For Skia, the new method always returns 'true', pending actual implementation.
+        This means Chromium still will differ from Gecko behavior, but at least its Canvas
+        will not be completely broken.
+
+        Existing Canvas Layout Tests should pass in Chromium after this change.
+
+        * html/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::lineTo): insteand of Path::isEmpty() test for hasCurrentPoint().
+        (WebCore::CanvasRenderingContext2D::quadraticCurveTo): ditto.
+        (WebCore::CanvasRenderingContext2D::bezierCurveTo): ditto.
+
+        * platform/graphics/Path.h:
+        * platform/graphics/cairo/PathCairo.cpp:
+        (WebCore::Path::hasCurrentPoint):
+        * platform/graphics/cg/PathCG.cpp:
+        (WebCore::Path::isEmpty):
+        (WebCore::Path::hasCurrentPoint):
+        * platform/graphics/qt/PathQt.cpp:
+        (WebCore::Path::hasCurrentPoint):
+        * platform/graphics/skia/PathSkia.cpp:
+        (WebCore::Path::hasCurrentPoint):
+        * platform/graphics/wx/PathWx.cpp:
+        (WebCore::Path::hasCurrentPoint):
+        All these files add a Path::hasCurrentPoint() for various platforms.
+
 2009-07-14  Nate Chapin  <japhet@chromium.org>
 
         Reviewed by Sam Weinig.
index 7a255d8..2286479 100644 (file)
@@ -546,7 +546,7 @@ void CanvasRenderingContext2D::lineTo(float x, float y)
         return;
     if (!state().m_invertibleCTM)
         return;
-    if (m_path.isEmpty())
+    if (!m_path.hasCurrentPoint())
         m_path.moveTo(FloatPoint(x, y));
     m_path.addLineTo(FloatPoint(x, y));
 }
@@ -557,7 +557,7 @@ void CanvasRenderingContext2D::quadraticCurveTo(float cpx, float cpy, float x, f
         return;
     if (!state().m_invertibleCTM)
         return;
-    if (m_path.isEmpty())
+    if (!m_path.hasCurrentPoint())
         m_path.moveTo(FloatPoint(cpx, cpy));
     m_path.addQuadCurveTo(FloatPoint(cpx, cpy), FloatPoint(x, y));
 }
@@ -568,7 +568,7 @@ void CanvasRenderingContext2D::bezierCurveTo(float cp1x, float cp1y, float cp2x,
         return;
     if (!state().m_invertibleCTM)
         return;
-    if (m_path.isEmpty())
+    if (!m_path.hasCurrentPoint())
         m_path.moveTo(FloatPoint(cp1x, cp1y));
     m_path.addBezierCurveTo(FloatPoint(cp1x, cp1y), FloatPoint(cp2x, cp2y), FloatPoint(x, y));
 }
index 9e2163b..0471724 100644 (file)
@@ -103,6 +103,9 @@ namespace WebCore {
 
         void clear();
         bool isEmpty() const;
+        // Gets the current point of the current path, which is conceptually the final point reached by the path so far.
+        // Note the Path can be empty (isEmpty() == true) and still have a current point.
+        bool hasCurrentPoint() const;
 
         void moveTo(const FloatPoint&);
         void addLineTo(const FloatPoint&);
index 13ca1e2..75681bd 100644 (file)
@@ -89,6 +89,11 @@ bool Path::isEmpty() const
 #endif
 }
 
+bool Path::hasCurrentPoint() const
+{
+    return !isEmpty();
+}
+
 void Path::translate(const FloatSize& p)
 {
     cairo_t* cr = platformPath()->m_cr;
index ebd0359..5812cea 100644 (file)
@@ -245,7 +245,12 @@ void Path::clear()
 bool Path::isEmpty() const
 {
     return CGPathIsEmpty(m_path);
- }
+}
+
+bool Path::hasCurrentPoint() const
+{
+    return !isEmpty();
+}
 
 static void CGPathToCFStringApplierFunction(void* info, const CGPathElement *element)
 {
index fde6ea3..777496c 100644 (file)
@@ -303,6 +303,11 @@ bool Path::isEmpty() const
     return m_path->elementCount() == 0;
 }
 
+bool Path::hasCurrentPoint() const
+{
+    return !isEmpty();
+}
+
 String Path::debugString() const
 {
     QString ret;
index 7de9530..1e5e3f1 100644 (file)
@@ -68,6 +68,11 @@ bool Path::isEmpty() const
     return m_path->isEmpty();
 }
 
+bool Path::hasCurrentPoint() const
+{
+    return true;
+}
+
 bool Path::contains(const FloatPoint& point, WindRule rule) const
 {
     return SkPathContainsPoint(m_path, point,
index 04a952d..cebc05a 100644 (file)
@@ -227,4 +227,9 @@ bool Path::isEmpty() const
     return true;
 }
 
+bool Path::hasCurrentPoint() const
+{
+    return !isEmpty();
+}
+
 }