Title: [279093] trunk/Source/WebCore
Revision
279093
Author
cdu...@apple.com
Date
2021-06-21 17:22:44 -0700 (Mon, 21 Jun 2021)

Log Message

Use double instead of float where appropriate in HTML Canvas IDL
https://bugs.webkit.org/show_bug.cgi?id=227238

Reviewed by Sam Weinig.

There are a lot of places in our HTML Canvas IDL where we're using float type, even though
the specification is using double. This patch fixes those.

* html/canvas/CanvasCompositing.idl:
* html/canvas/CanvasDrawImage.idl:
* html/canvas/CanvasDrawPath.idl:
* html/canvas/CanvasGradient.cpp:
(WebCore::CanvasGradient::addColorStop):
* html/canvas/CanvasGradient.h:
* html/canvas/CanvasGradient.idl:
* html/canvas/CanvasPathDrawingStyles.idl:
* html/canvas/CanvasRect.idl:
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::fillText):
(WebCore::CanvasRenderingContext2D::strokeText):
(WebCore::CanvasRenderingContext2D::drawTextInternal):
* html/canvas/CanvasRenderingContext2D.h:
* html/canvas/CanvasRenderingContext2D.idl:
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::setLineWidth):
(WebCore::CanvasRenderingContext2DBase::setMiterLimit):
(WebCore::lineDashSequenceIsValid):
(WebCore::CanvasRenderingContext2DBase::setLineDash):
(WebCore::CanvasRenderingContext2DBase::setWebkitLineDash):
(WebCore::CanvasRenderingContext2DBase::setLineDashOffset):
(WebCore::CanvasRenderingContext2DBase::setGlobalAlpha):
(WebCore::CanvasRenderingContext2DBase::scale):
(WebCore::CanvasRenderingContext2DBase::rotate):
(WebCore::CanvasRenderingContext2DBase::translate):
(WebCore::CanvasRenderingContext2DBase::transform):
(WebCore::CanvasRenderingContext2DBase::setTransform):
(WebCore::validateRectForCanvas):
(WebCore::CanvasRenderingContext2DBase::isPointInPath):
(WebCore::CanvasRenderingContext2DBase::isPointInStroke):
(WebCore::CanvasRenderingContext2DBase::isPointInPathInternal):
(WebCore::CanvasRenderingContext2DBase::isPointInStrokeInternal):
(WebCore::CanvasRenderingContext2DBase::clearRect):
(WebCore::CanvasRenderingContext2DBase::fillRect):
(WebCore::CanvasRenderingContext2DBase::strokeRect):
(WebCore::CanvasRenderingContext2DBase::canDrawText):
(WebCore::CanvasRenderingContext2DBase::drawText):
(WebCore::CanvasRenderingContext2DBase::drawTextUnchecked):
* html/canvas/CanvasRenderingContext2DBase.h:
(WebCore::CanvasRenderingContext2DBase::lineWidth const):
(WebCore::CanvasRenderingContext2DBase::miterLimit const):
(WebCore::CanvasRenderingContext2DBase::getLineDash const):
(WebCore::CanvasRenderingContext2DBase::webkitLineDash const):
(WebCore::CanvasRenderingContext2DBase::lineDashOffset const):
(WebCore::CanvasRenderingContext2DBase::globalAlpha const):
* html/canvas/CanvasShadowStyles.idl:
* html/canvas/CanvasText.idl:
* html/canvas/CanvasTransform.idl:
* html/canvas/OffscreenCanvasRenderingContext2D.cpp:
(WebCore::OffscreenCanvasRenderingContext2D::fillText):
(WebCore::OffscreenCanvasRenderingContext2D::strokeText):
* html/canvas/OffscreenCanvasRenderingContext2D.h:
* inspector/InspectorCanvas.cpp:
(WebCore::InspectorCanvas::processArgument):
* inspector/InspectorCanvasCallTracer.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (279092 => 279093)


--- trunk/Source/WebCore/ChangeLog	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/ChangeLog	2021-06-22 00:22:44 UTC (rev 279093)
@@ -1,3 +1,70 @@
+2021-06-21  Chris Dumez  <cdu...@apple.com>
+
+        Use double instead of float where appropriate in HTML Canvas IDL
+        https://bugs.webkit.org/show_bug.cgi?id=227238
+
+        Reviewed by Sam Weinig.
+
+        There are a lot of places in our HTML Canvas IDL where we're using float type, even though
+        the specification is using double. This patch fixes those.
+
+        * html/canvas/CanvasCompositing.idl:
+        * html/canvas/CanvasDrawImage.idl:
+        * html/canvas/CanvasDrawPath.idl:
+        * html/canvas/CanvasGradient.cpp:
+        (WebCore::CanvasGradient::addColorStop):
+        * html/canvas/CanvasGradient.h:
+        * html/canvas/CanvasGradient.idl:
+        * html/canvas/CanvasPathDrawingStyles.idl:
+        * html/canvas/CanvasRect.idl:
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::fillText):
+        (WebCore::CanvasRenderingContext2D::strokeText):
+        (WebCore::CanvasRenderingContext2D::drawTextInternal):
+        * html/canvas/CanvasRenderingContext2D.h:
+        * html/canvas/CanvasRenderingContext2D.idl:
+        * html/canvas/CanvasRenderingContext2DBase.cpp:
+        (WebCore::CanvasRenderingContext2DBase::setLineWidth):
+        (WebCore::CanvasRenderingContext2DBase::setMiterLimit):
+        (WebCore::lineDashSequenceIsValid):
+        (WebCore::CanvasRenderingContext2DBase::setLineDash):
+        (WebCore::CanvasRenderingContext2DBase::setWebkitLineDash):
+        (WebCore::CanvasRenderingContext2DBase::setLineDashOffset):
+        (WebCore::CanvasRenderingContext2DBase::setGlobalAlpha):
+        (WebCore::CanvasRenderingContext2DBase::scale):
+        (WebCore::CanvasRenderingContext2DBase::rotate):
+        (WebCore::CanvasRenderingContext2DBase::translate):
+        (WebCore::CanvasRenderingContext2DBase::transform):
+        (WebCore::CanvasRenderingContext2DBase::setTransform):
+        (WebCore::validateRectForCanvas):
+        (WebCore::CanvasRenderingContext2DBase::isPointInPath):
+        (WebCore::CanvasRenderingContext2DBase::isPointInStroke):
+        (WebCore::CanvasRenderingContext2DBase::isPointInPathInternal):
+        (WebCore::CanvasRenderingContext2DBase::isPointInStrokeInternal):
+        (WebCore::CanvasRenderingContext2DBase::clearRect):
+        (WebCore::CanvasRenderingContext2DBase::fillRect):
+        (WebCore::CanvasRenderingContext2DBase::strokeRect):
+        (WebCore::CanvasRenderingContext2DBase::canDrawText):
+        (WebCore::CanvasRenderingContext2DBase::drawText):
+        (WebCore::CanvasRenderingContext2DBase::drawTextUnchecked):
+        * html/canvas/CanvasRenderingContext2DBase.h:
+        (WebCore::CanvasRenderingContext2DBase::lineWidth const):
+        (WebCore::CanvasRenderingContext2DBase::miterLimit const):
+        (WebCore::CanvasRenderingContext2DBase::getLineDash const):
+        (WebCore::CanvasRenderingContext2DBase::webkitLineDash const):
+        (WebCore::CanvasRenderingContext2DBase::lineDashOffset const):
+        (WebCore::CanvasRenderingContext2DBase::globalAlpha const):
+        * html/canvas/CanvasShadowStyles.idl:
+        * html/canvas/CanvasText.idl:
+        * html/canvas/CanvasTransform.idl:
+        * html/canvas/OffscreenCanvasRenderingContext2D.cpp:
+        (WebCore::OffscreenCanvasRenderingContext2D::fillText):
+        (WebCore::OffscreenCanvasRenderingContext2D::strokeText):
+        * html/canvas/OffscreenCanvasRenderingContext2D.h:
+        * inspector/InspectorCanvas.cpp:
+        (WebCore::InspectorCanvas::processArgument):
+        * inspector/InspectorCanvasCallTracer.h:
+
 2021-06-21  Fujii Hironori  <hironori.fu...@sony.com>
 
         [WinCairo] Turn ENABLE_SHAREABLE_RESOURCE on

Modified: trunk/Source/WebCore/html/canvas/CanvasCompositing.idl (279092 => 279093)


--- trunk/Source/WebCore/html/canvas/CanvasCompositing.idl	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/html/canvas/CanvasCompositing.idl	2021-06-22 00:22:44 UTC (rev 279093)
@@ -25,9 +25,7 @@
 
 // https://html.spec.whatwg.org/multipage/canvas.html#canvascompositing
 interface mixin CanvasCompositing {
-    // FIXME: All the unrestricted float attributes below should be unrestricted doubles.
-
     // compositing
-    attribute unrestricted float globalAlpha; // (default 1.0)
+    attribute unrestricted double globalAlpha; // (default 1.0)
     attribute DOMString globalCompositeOperation; // (default source-over)
 };

Modified: trunk/Source/WebCore/html/canvas/CanvasDrawImage.idl (279092 => 279093)


--- trunk/Source/WebCore/html/canvas/CanvasDrawImage.idl	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/html/canvas/CanvasDrawImage.idl	2021-06-22 00:22:44 UTC (rev 279093)
@@ -38,8 +38,6 @@
 
 // https://html.spec.whatwg.org/multipage/canvas.html#canvasdrawimage
 interface mixin CanvasDrawImage {
-    // FIXME: All the unrestricted float arguments below should be unrestricted doubles.
-
     // drawing images
     undefined drawImage(CanvasImageSource image, unrestricted double dx, unrestricted double dy);
     undefined drawImage(CanvasImageSource image, unrestricted double dx, unrestricted double dy, unrestricted double dw, unrestricted double dh);

Modified: trunk/Source/WebCore/html/canvas/CanvasDrawPath.idl (279092 => 279093)


--- trunk/Source/WebCore/html/canvas/CanvasDrawPath.idl	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/html/canvas/CanvasDrawPath.idl	2021-06-22 00:22:44 UTC (rev 279093)
@@ -36,9 +36,8 @@
     // FIXME: Implement resetClip.
     // undefined resetClip();
 
-    // FIXME: All the unrestricted float parameters below should be unrestricted doubles.
-    boolean isPointInPath(unrestricted float x, unrestricted float y, optional CanvasFillRule fillRule = "nonzero");
-    boolean isPointInPath(Path2D path, unrestricted float x, unrestricted float y, optional CanvasFillRule fillRule = "nonzero");
-    boolean isPointInStroke(unrestricted float x, unrestricted float y);
-    boolean isPointInStroke(Path2D path, unrestricted float x, unrestricted float y);
+    boolean isPointInPath(unrestricted double x, unrestricted double y, optional CanvasFillRule fillRule = "nonzero");
+    boolean isPointInPath(Path2D path, unrestricted double x, unrestricted double y, optional CanvasFillRule fillRule = "nonzero");
+    boolean isPointInStroke(unrestricted double x, unrestricted double y);
+    boolean isPointInStroke(Path2D path, unrestricted double x, unrestricted double y);
 };

Modified: trunk/Source/WebCore/html/canvas/CanvasGradient.cpp (279092 => 279093)


--- trunk/Source/WebCore/html/canvas/CanvasGradient.cpp	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/html/canvas/CanvasGradient.cpp	2021-06-22 00:22:44 UTC (rev 279093)
@@ -68,7 +68,7 @@
 
 CanvasGradient::~CanvasGradient() = default;
 
-ExceptionOr<void> CanvasGradient::addColorStop(float value, const String& colorString)
+ExceptionOr<void> CanvasGradient::addColorStop(double value, const String& colorString)
 {
     if (!(value >= 0 && value <= 1))
         return Exception { IndexSizeError };
@@ -78,7 +78,7 @@
     if (!color.isValid())
         return Exception { SyntaxError };
 
-    m_gradient->addColorStop({ value, WTFMove(color) });
+    m_gradient->addColorStop({ static_cast<float>(value), WTFMove(color) });
     return { };
 }
 

Modified: trunk/Source/WebCore/html/canvas/CanvasGradient.h (279092 => 279093)


--- trunk/Source/WebCore/html/canvas/CanvasGradient.h	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/html/canvas/CanvasGradient.h	2021-06-22 00:22:44 UTC (rev 279093)
@@ -44,7 +44,7 @@
     Gradient& gradient() { return m_gradient; }
     const Gradient& gradient() const { return m_gradient; }
 
-    ExceptionOr<void> addColorStop(float value, const String& color);
+    ExceptionOr<void> addColorStop(double value, const String& color);
 
 private:
     CanvasGradient(const FloatPoint& p0, const FloatPoint& p1, CanvasBase&);

Modified: trunk/Source/WebCore/html/canvas/CanvasGradient.idl (279092 => 279093)


--- trunk/Source/WebCore/html/canvas/CanvasGradient.idl	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/html/canvas/CanvasGradient.idl	2021-06-22 00:22:44 UTC (rev 279093)
@@ -28,8 +28,6 @@
     Exposed=(Window,Worker),
     ImplementationLacksVTable
 ] interface CanvasGradient {
-    // FIXME: The float parameters below should be a double.
-
     // opaque object
-    undefined addColorStop(float offset, DOMString color);
+    undefined addColorStop(double offset, DOMString color);
 };

Modified: trunk/Source/WebCore/html/canvas/CanvasPathDrawingStyles.idl (279092 => 279093)


--- trunk/Source/WebCore/html/canvas/CanvasPathDrawingStyles.idl	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/html/canvas/CanvasPathDrawingStyles.idl	2021-06-22 00:22:44 UTC (rev 279093)
@@ -25,16 +25,14 @@
 
 // https://html.spec.whatwg.org/multipage/canvas.html#canvaspathdrawingstyles
 interface mixin CanvasPathDrawingStyles {
-    // FIXME: All the unrestricted float arguments / attributes below should be unrestricted doubles.
-
     // line caps/joins
-    attribute unrestricted float lineWidth; // (default 1)
+    attribute unrestricted double lineWidth; // (default 1)
     attribute CanvasLineCap lineCap; // (default "butt")
     attribute CanvasLineJoin lineJoin; // (default "miter")
-    attribute unrestricted float miterLimit; // (default 10)
+    attribute unrestricted double miterLimit; // (default 10)
 
     // dashed lines
-    undefined setLineDash(sequence<unrestricted float> segments); // default empty
-    sequence<unrestricted float> getLineDash();
-    attribute unrestricted float lineDashOffset;
+    undefined setLineDash(sequence<unrestricted double> segments); // default empty
+    sequence<unrestricted double> getLineDash();
+    attribute unrestricted double lineDashOffset;
 };

Modified: trunk/Source/WebCore/html/canvas/CanvasRect.idl (279092 => 279093)


--- trunk/Source/WebCore/html/canvas/CanvasRect.idl	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/html/canvas/CanvasRect.idl	2021-06-22 00:22:44 UTC (rev 279093)
@@ -25,10 +25,8 @@
 
 // https://html.spec.whatwg.org/multipage/canvas.html#canvasrect
 interface mixin CanvasRect {
-    // FIXME: All the unrestricted float parameters below should be unrestricted doubles.
-
     // rects
-    undefined clearRect(unrestricted float x, unrestricted float y, unrestricted float w, unrestricted float h);
-    undefined fillRect(unrestricted float x, unrestricted float y, unrestricted float w, unrestricted float h);
-    undefined strokeRect(unrestricted float x, unrestricted float y, unrestricted float w, unrestricted float h);
+    undefined clearRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
+    undefined fillRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
+    undefined strokeRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
 };

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (279092 => 279093)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2021-06-22 00:22:44 UTC (rev 279093)
@@ -181,12 +181,12 @@
     return toTextDirection(state().direction) == TextDirection::RTL ? CanvasDirection::Rtl : CanvasDirection::Ltr;
 }
 
-void CanvasRenderingContext2D::fillText(const String& text, float x, float y, std::optional<float> maxWidth)
+void CanvasRenderingContext2D::fillText(const String& text, double x, double y, std::optional<double> maxWidth)
 {
     drawTextInternal(text, x, y, true, maxWidth);
 }
 
-void CanvasRenderingContext2D::strokeText(const String& text, float x, float y, std::optional<float> maxWidth)
+void CanvasRenderingContext2D::strokeText(const String& text, double x, double y, std::optional<double> maxWidth)
 {
     drawTextInternal(text, x, y, false, maxWidth);
 }
@@ -224,7 +224,7 @@
     return &state().font;
 }
 
-void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, float y, bool fill, std::optional<float> maxWidth)
+void CanvasRenderingContext2D::drawTextInternal(const String& text, double x, double y, bool fill, std::optional<double> maxWidth)
 {
     downcast<HTMLCanvasElement>(canvasBase()).document().updateStyleIfNeeded();
 

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h (279092 => 279093)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h	2021-06-22 00:22:44 UTC (rev 279093)
@@ -49,8 +49,8 @@
 
     CanvasDirection direction() const;
 
-    void fillText(const String& text, float x, float y, std::optional<float> maxWidth = std::nullopt);
-    void strokeText(const String& text, float x, float y, std::optional<float> maxWidth = std::nullopt);
+    void fillText(const String& text, double x, double y, std::optional<double> maxWidth = std::nullopt);
+    void strokeText(const String& text, double x, double y, std::optional<double> maxWidth = std::nullopt);
     Ref<TextMetrics> measureText(const String& text);
 
 private:
@@ -61,7 +61,7 @@
 
     void setFontWithoutUpdatingStyle(const String&);
 
-    void drawTextInternal(const String& text, float x, float y, bool fill, std::optional<float> maxWidth = std::nullopt);
+    void drawTextInternal(const String& text, double x, double y, bool fill, std::optional<double> maxWidth = std::nullopt);
 
     void drawFocusIfNeededInternal(const Path&, Element&);
 

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl (279092 => 279093)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl	2021-06-22 00:22:44 UTC (rev 279093)
@@ -64,8 +64,8 @@
     undefined setLineCap(optional DOMString cap);
     undefined setLineJoin(optional DOMString join);
     undefined setMiterLimit(optional unrestricted float limit = NaN);
-    attribute sequence<unrestricted float> webkitLineDash;
-    [ImplementedAs=lineDashOffset] attribute unrestricted float webkitLineDashOffset;
+    attribute sequence<unrestricted double> webkitLineDash;
+    [ImplementedAs=lineDashOffset] attribute unrestricted double webkitLineDashOffset;
 
     // Non-standard legacy aliases (CanvasShadowStyles).
     undefined setShadow(unrestricted float width, unrestricted float height, unrestricted float blur, optional DOMString color, optional unrestricted float alpha);

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp (279092 => 279093)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp	2021-06-22 00:22:44 UTC (rev 279093)
@@ -515,7 +515,7 @@
     state.unparsedFillColor = String();
 }
 
-void CanvasRenderingContext2DBase::setLineWidth(float width)
+void CanvasRenderingContext2DBase::setLineWidth(double width)
 {
     if (!(std::isfinite(width) && width > 0))
         return;
@@ -585,7 +585,7 @@
     setLineJoin(join);
 }
 
-void CanvasRenderingContext2DBase::setMiterLimit(float limit)
+void CanvasRenderingContext2DBase::setMiterLimit(double limit)
 {
     if (!(std::isfinite(limit) && limit > 0))
         return;
@@ -644,7 +644,7 @@
     applyShadow();
 }
 
-static bool lineDashSequenceIsValid(const Vector<float>& dash)
+static bool lineDashSequenceIsValid(const Vector<double>& dash)
 {
     for (size_t i = 0; i < dash.size(); i++) {
         if (!std::isfinite(dash[i]) || dash[i] < 0)
@@ -653,7 +653,7 @@
     return true;
 }
 
-void CanvasRenderingContext2DBase::setLineDash(const Vector<float>& dash)
+void CanvasRenderingContext2DBase::setLineDash(const Vector<double>& dash)
 {
     if (!lineDashSequenceIsValid(dash))
         return;
@@ -668,7 +668,7 @@
     applyLineDash();
 }
 
-void CanvasRenderingContext2DBase::setWebkitLineDash(const Vector<float>& dash)
+void CanvasRenderingContext2DBase::setWebkitLineDash(const Vector<double>& dash)
 {
     if (!lineDashSequenceIsValid(dash))
         return;
@@ -679,7 +679,7 @@
     applyLineDash();
 }
 
-void CanvasRenderingContext2DBase::setLineDashOffset(float offset)
+void CanvasRenderingContext2DBase::setLineDashOffset(double offset)
 {
     if (!std::isfinite(offset) || state().lineDashOffset == offset)
         return;
@@ -700,7 +700,7 @@
     c->setLineDash(convertedLineDash, state().lineDashOffset);
 }
 
-void CanvasRenderingContext2DBase::setGlobalAlpha(float alpha)
+void CanvasRenderingContext2DBase::setGlobalAlpha(double alpha)
 {
     if (!(alpha >= 0 && alpha <= 1))
         return;
@@ -731,7 +731,7 @@
     c->setCompositeOperation(op, blendMode);
 }
 
-void CanvasRenderingContext2DBase::scale(float sx, float sy)
+void CanvasRenderingContext2DBase::scale(double sx, double sy)
 {
     GraphicsContext* c = drawingContext();
     if (!c)
@@ -759,7 +759,7 @@
     m_path.transform(AffineTransform().scaleNonUniform(1.0 / sx, 1.0 / sy));
 }
 
-void CanvasRenderingContext2DBase::rotate(float angleInRadians)
+void CanvasRenderingContext2DBase::rotate(double angleInRadians)
 {
     GraphicsContext* c = drawingContext();
     if (!c)
@@ -782,7 +782,7 @@
     m_path.transform(AffineTransform().rotate(-angleInRadians / piDouble * 180.0));
 }
 
-void CanvasRenderingContext2DBase::translate(float tx, float ty)
+void CanvasRenderingContext2DBase::translate(double tx, double ty)
 {
     GraphicsContext* c = drawingContext();
     if (!c)
@@ -805,7 +805,7 @@
     m_path.transform(AffineTransform().translate(-tx, -ty));
 }
 
-void CanvasRenderingContext2DBase::transform(float m11, float m12, float m21, float m22, float dx, float dy)
+void CanvasRenderingContext2DBase::transform(double m11, double m12, double m21, double m22, double dx, double dy)
 {
     GraphicsContext* c = drawingContext();
     if (!c)
@@ -837,7 +837,7 @@
     return DOMMatrix::create(state().transform.toTransformationMatrix(), DOMMatrixReadOnly::Is2D::Yes);
 }
 
-void CanvasRenderingContext2DBase::setTransform(float m11, float m12, float m21, float m22, float dx, float dy)
+void CanvasRenderingContext2DBase::setTransform(double m11, double m12, double m21, double m22, double dx, double dy)
 {
     GraphicsContext* c = drawingContext();
     if (!c)
@@ -965,7 +965,7 @@
     m_path.clear();
 }
 
-static bool validateRectForCanvas(float& x, float& y, float& width, float& height)
+static bool validateRectForCanvas(double& x, double& y, double& width, double& height)
 {
     if (!std::isfinite(x) | !std::isfinite(y) | !std::isfinite(width) | !std::isfinite(height))
         return false;
@@ -1137,27 +1137,27 @@
 #endif
 }
 
-bool CanvasRenderingContext2DBase::isPointInPath(float x, float y, CanvasFillRule windingRule)
+bool CanvasRenderingContext2DBase::isPointInPath(double x, double y, CanvasFillRule windingRule)
 {
     return isPointInPathInternal(m_path, x, y, windingRule);
 }
 
-bool CanvasRenderingContext2DBase::isPointInStroke(float x, float y)
+bool CanvasRenderingContext2DBase::isPointInStroke(double x, double y)
 {
     return isPointInStrokeInternal(m_path, x, y);
 }
 
-bool CanvasRenderingContext2DBase::isPointInPath(Path2D& path, float x, float y, CanvasFillRule windingRule)
+bool CanvasRenderingContext2DBase::isPointInPath(Path2D& path, double x, double y, CanvasFillRule windingRule)
 {
     return isPointInPathInternal(path.path(), x, y, windingRule);
 }
 
-bool CanvasRenderingContext2DBase::isPointInStroke(Path2D& path, float x, float y)
+bool CanvasRenderingContext2DBase::isPointInStroke(Path2D& path, double x, double y)
 {
     return isPointInStrokeInternal(path.path(), x, y);
 }
 
-bool CanvasRenderingContext2DBase::isPointInPathInternal(const Path& path, float x, float y, CanvasFillRule windingRule)
+bool CanvasRenderingContext2DBase::isPointInPathInternal(const Path& path, double x, double y, CanvasFillRule windingRule)
 {
     if (!drawingContext())
         return false;
@@ -1172,7 +1172,7 @@
     return path.contains(transformedPoint, toWindRule(windingRule));
 }
 
-bool CanvasRenderingContext2DBase::isPointInStrokeInternal(const Path& path, float x, float y)
+bool CanvasRenderingContext2DBase::isPointInStrokeInternal(const Path& path, double x, double y)
 {
     if (!drawingContext())
         return false;
@@ -1197,7 +1197,7 @@
     });
 }
 
-void CanvasRenderingContext2DBase::clearRect(float x, float y, float width, float height)
+void CanvasRenderingContext2DBase::clearRect(double x, double y, double width, double height)
 {
     if (!validateRectForCanvas(x, y, width, height))
         return;
@@ -1234,7 +1234,7 @@
     didDraw(rect);
 }
 
-void CanvasRenderingContext2DBase::fillRect(float x, float y, float width, float height)
+void CanvasRenderingContext2DBase::fillRect(double x, double y, double width, double height)
 {
     if (!validateRectForCanvas(x, y, width, height))
         return;
@@ -1278,7 +1278,7 @@
         didDraw(rect);
 }
 
-void CanvasRenderingContext2DBase::strokeRect(float x, float y, float width, float height)
+void CanvasRenderingContext2DBase::strokeRect(double x, double y, double width, double height)
 {
     if (!validateRectForCanvas(x, y, width, height))
         return;
@@ -2352,7 +2352,7 @@
     modifiableState().direction = direction;
 }
 
-bool CanvasRenderingContext2DBase::canDrawText(float x, float y, bool fill, std::optional<float> maxWidth)
+bool CanvasRenderingContext2DBase::canDrawText(double x, double y, bool fill, std::optional<double> maxWidth)
 {
     if (!fontProxy()->realized())
         return false;
@@ -2409,7 +2409,7 @@
     return String::adopt(WTFMove(charVector));
 }
 
-void CanvasRenderingContext2DBase::drawText(const String& text, float x, float y, bool fill, std::optional<float> maxWidth)
+void CanvasRenderingContext2DBase::drawText(const String& text, double x, double y, bool fill, std::optional<double> maxWidth)
 {
     if (!canDrawText(x, y, fill, maxWidth))
         return;
@@ -2420,7 +2420,7 @@
     drawTextUnchecked(textRun, x, y, fill, maxWidth);
 }
 
-void CanvasRenderingContext2DBase::drawTextUnchecked(const TextRun& textRun, float x, float y, bool fill, std::optional<float> maxWidth)
+void CanvasRenderingContext2DBase::drawTextUnchecked(const TextRun& textRun, double x, double y, bool fill, std::optional<double> maxWidth)
 {
     auto* c = drawingContext();
     auto& fontProxy = *this->fontProxy();

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h (279092 => 279093)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h	2021-06-22 00:22:44 UTC (rev 279093)
@@ -87,8 +87,8 @@
 
     const CanvasRenderingContext2DSettings& getContextAttributes() const { return m_settings; }
 
-    float lineWidth() const { return state().lineWidth; }
-    void setLineWidth(float);
+    double lineWidth() const { return state().lineWidth; }
+    void setLineWidth(double);
 
     CanvasLineCap lineCap() const { return state().canvasLineCap(); }
     void setLineCap(CanvasLineCap);
@@ -98,17 +98,17 @@
     void setLineJoin(CanvasLineJoin);
     void setLineJoin(const String&);
 
-    float miterLimit() const { return state().miterLimit; }
-    void setMiterLimit(float);
+    double miterLimit() const { return state().miterLimit; }
+    void setMiterLimit(double);
 
-    const Vector<float>& getLineDash() const { return state().lineDash; }
-    void setLineDash(const Vector<float>&);
+    const Vector<double>& getLineDash() const { return state().lineDash; }
+    void setLineDash(const Vector<double>&);
 
-    const Vector<float>& webkitLineDash() const { return getLineDash(); }
-    void setWebkitLineDash(const Vector<float>&);
+    const Vector<double>& webkitLineDash() const { return getLineDash(); }
+    void setWebkitLineDash(const Vector<double>&);
 
-    float lineDashOffset() const { return state().lineDashOffset; }
-    void setLineDashOffset(float);
+    double lineDashOffset() const { return state().lineDashOffset; }
+    void setLineDashOffset(double);
 
     float shadowOffsetX() const { return state().shadowOffset.width(); }
     void setShadowOffsetX(float);
@@ -122,8 +122,8 @@
     String shadowColor() const { return state().shadowColorString(); }
     void setShadowColor(const String&);
 
-    float globalAlpha() const { return state().globalAlpha; }
-    void setGlobalAlpha(float);
+    double globalAlpha() const { return state().globalAlpha; }
+    void setGlobalAlpha(double);
 
     String globalCompositeOperation() const { return state().globalCompositeOperationString(); }
     void setGlobalCompositeOperation(const String&);
@@ -131,13 +131,13 @@
     void save() { ++m_unrealizedSaveCount; }
     void restore();
 
-    void scale(float sx, float sy);
-    void rotate(float angleInRadians);
-    void translate(float tx, float ty);
-    void transform(float m11, float m12, float m21, float m22, float dx, float dy);
+    void scale(double sx, double sy);
+    void rotate(double angleInRadians);
+    void translate(double tx, double ty);
+    void transform(double m11, double m12, double m21, double m22, double dx, double dy);
 
     Ref<DOMMatrix> getTransform() const;
-    void setTransform(float m11, float m12, float m21, float m22, float dx, float dy);
+    void setTransform(double m11, double m12, double m21, double m22, double dx, double dy);
     ExceptionOr<void> setTransform(DOMMatrix2DInit&&);
     void resetTransform();
 
@@ -159,15 +159,15 @@
     void stroke(Path2D&);
     void clip(Path2D&, CanvasFillRule = CanvasFillRule::Nonzero);
 
-    bool isPointInPath(float x, float y, CanvasFillRule = CanvasFillRule::Nonzero);
-    bool isPointInStroke(float x, float y);
+    bool isPointInPath(double x, double y, CanvasFillRule = CanvasFillRule::Nonzero);
+    bool isPointInStroke(double x, double y);
 
-    bool isPointInPath(Path2D&, float x, float y, CanvasFillRule = CanvasFillRule::Nonzero);
-    bool isPointInStroke(Path2D&, float x, float y);
+    bool isPointInPath(Path2D&, double x, double y, CanvasFillRule = CanvasFillRule::Nonzero);
+    bool isPointInStroke(Path2D&, double x, double y);
 
-    void clearRect(float x, float y, float width, float height);
-    void fillRect(float x, float y, float width, float height);
-    void strokeRect(float x, float y, float width, float height);
+    void clearRect(double x, double y, double width, double height);
+    void fillRect(double x, double y, double width, double height);
+    void strokeRect(double x, double y, double width, double height);
 
     void setShadow(float width, float height, float blur, const String& color = String(), std::optional<float> alpha = std::nullopt);
     void setShadow(float width, float height, float blur, float grayLevel, float alpha = 1.0);
@@ -257,20 +257,20 @@
         String unparsedFillColor;
         CanvasStyle strokeStyle;
         CanvasStyle fillStyle;
-        float lineWidth;
+        double lineWidth;
         LineCap lineCap;
         LineJoin lineJoin;
-        float miterLimit;
+        double miterLimit;
         FloatSize shadowOffset;
         float shadowBlur;
         Color shadowColor;
-        float globalAlpha;
+        double globalAlpha;
         CompositeOperator globalComposite;
         BlendMode globalBlend;
         AffineTransform transform;
         bool hasInvertibleTransform;
-        Vector<float> lineDash;
-        float lineDashOffset;
+        Vector<double> lineDash;
+        double lineDashOffset;
         bool imageSmoothingEnabled;
         ImageSmoothingQuality imageSmoothingQuality;
         TextAlign textAlign;
@@ -302,9 +302,9 @@
 
     static String normalizeSpaces(const String&);
 
-    void drawText(const String& text, float x, float y, bool fill, std::optional<float> maxWidth = std::nullopt);
-    bool canDrawText(float x, float y, bool fill, std::optional<float> maxWidth = std::nullopt);
-    void drawTextUnchecked(const TextRun&, float x, float y, bool fill, std::optional<float> maxWidth = std::nullopt);
+    void drawText(const String& text, double x, double y, bool fill, std::optional<double> maxWidth = std::nullopt);
+    bool canDrawText(double x, double y, bool fill, std::optional<double> maxWidth = std::nullopt);
+    void drawTextUnchecked(const TextRun&, double x, double y, bool fill, std::optional<double> maxWidth = std::nullopt);
 
     Ref<TextMetrics> measureTextInternal(const TextRun&);
     Ref<TextMetrics> measureTextInternal(const String& text);
@@ -371,8 +371,8 @@
     void strokeInternal(const Path&);
     void clipInternal(const Path&, CanvasFillRule);
 
-    bool isPointInPathInternal(const Path&, float x, float y, CanvasFillRule);
-    bool isPointInStrokeInternal(const Path&, float x, float y);
+    bool isPointInPathInternal(const Path&, double x, double y, CanvasFillRule);
+    bool isPointInStrokeInternal(const Path&, double x, double y);
 
     Path transformAreaToDevice(const Path&) const;
     Path transformAreaToDevice(const FloatRect&) const;

Modified: trunk/Source/WebCore/html/canvas/CanvasShadowStyles.idl (279092 => 279093)


--- trunk/Source/WebCore/html/canvas/CanvasShadowStyles.idl	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/html/canvas/CanvasShadowStyles.idl	2021-06-22 00:22:44 UTC (rev 279093)
@@ -25,8 +25,6 @@
 
 // https://html.spec.whatwg.org/multipage/canvas.html#canvasshadowstyles
 interface mixin CanvasShadowStyles {
-    // FIXME: All the unrestricted float attributes below should be unrestricted doubles.
-
     // shadows
     attribute unrestricted double shadowOffsetX; // (default 0)
     attribute unrestricted double shadowOffsetY; // (default 0)

Modified: trunk/Source/WebCore/html/canvas/CanvasText.idl (279092 => 279093)


--- trunk/Source/WebCore/html/canvas/CanvasText.idl	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/html/canvas/CanvasText.idl	2021-06-22 00:22:44 UTC (rev 279093)
@@ -25,10 +25,8 @@
 
 // https://html.spec.whatwg.org/multipage/canvas.html#canvastext
 interface mixin CanvasText {
-    // FIXME: All the unrestricted float parameters below should be unrestricted doubles.
-
     // text (see also the CanvasPathDrawingStyles and CanvasTextDrawingStyles interfaces)
-    undefined fillText(DOMString text, unrestricted float x, unrestricted float y, optional unrestricted float maxWidth);
-    undefined strokeText(DOMString text, unrestricted float x, unrestricted float y, optional unrestricted float maxWidth);
+    undefined fillText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
+    undefined strokeText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
     TextMetrics measureText(DOMString text);
 };

Modified: trunk/Source/WebCore/html/canvas/CanvasTransform.idl (279092 => 279093)


--- trunk/Source/WebCore/html/canvas/CanvasTransform.idl	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/html/canvas/CanvasTransform.idl	2021-06-22 00:22:44 UTC (rev 279093)
@@ -25,16 +25,14 @@
 
 // https://html.spec.whatwg.org/multipage/canvas.html#canvastransform
 interface mixin CanvasTransform {
-    // FIXME: All the unrestricted float parameters below should be unrestricted doubles.
-
     // transformations (default transform is the identity matrix)
-    undefined scale(unrestricted float x, unrestricted float y);
-    undefined rotate(unrestricted float angle);
-    undefined translate(unrestricted float x, unrestricted float y);
-    undefined transform(unrestricted float a, unrestricted float b, unrestricted float c, unrestricted float d, unrestricted float e, unrestricted float f);
+    undefined scale(unrestricted double x, unrestricted double y);
+    undefined rotate(unrestricted double angle);
+    undefined translate(unrestricted double x, unrestricted double y);
+    undefined transform(unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f);
 
     [NewObject] DOMMatrix getTransform();
-    undefined setTransform(unrestricted float a, unrestricted float b, unrestricted float c, unrestricted float d, unrestricted float e, unrestricted float f);
+    undefined setTransform(unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f);
     undefined setTransform(optional DOMMatrix2DInit transform);
     undefined resetTransform();
 };

Modified: trunk/Source/WebCore/html/canvas/OffscreenCanvasRenderingContext2D.cpp (279092 => 279093)


--- trunk/Source/WebCore/html/canvas/OffscreenCanvasRenderingContext2D.cpp	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/html/canvas/OffscreenCanvasRenderingContext2D.cpp	2021-06-22 00:22:44 UTC (rev 279093)
@@ -126,12 +126,12 @@
     return &state().font;
 }
 
-void OffscreenCanvasRenderingContext2D::fillText(const String& text, float x, float y, std::optional<float> maxWidth)
+void OffscreenCanvasRenderingContext2D::fillText(const String& text, double x, double y, std::optional<double> maxWidth)
 {
     drawText(text, x, y, true, maxWidth);
 }
 
-void OffscreenCanvasRenderingContext2D::strokeText(const String& text, float x, float y, std::optional<float> maxWidth)
+void OffscreenCanvasRenderingContext2D::strokeText(const String& text, double x, double y, std::optional<double> maxWidth)
 {
     drawText(text, x, y, false, maxWidth);
 }

Modified: trunk/Source/WebCore/html/canvas/OffscreenCanvasRenderingContext2D.h (279092 => 279093)


--- trunk/Source/WebCore/html/canvas/OffscreenCanvasRenderingContext2D.h	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/html/canvas/OffscreenCanvasRenderingContext2D.h	2021-06-22 00:22:44 UTC (rev 279093)
@@ -47,8 +47,8 @@
 
     void setFont(const String&);
     CanvasDirection direction() const;
-    void fillText(const String& text, float x, float y, std::optional<float> maxWidth = std::nullopt);
-    void strokeText(const String& text, float x, float y, std::optional<float> maxWidth = std::nullopt);
+    void fillText(const String& text, double x, double y, std::optional<double> maxWidth = std::nullopt);
+    void strokeText(const String& text, double x, double y, std::optional<double> maxWidth = std::nullopt);
     Ref<TextMetrics> measureText(const String& text);
 
 private:

Modified: trunk/Source/WebCore/inspector/InspectorCanvas.cpp (279092 => 279093)


--- trunk/Source/WebCore/inspector/InspectorCanvas.cpp	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/inspector/InspectorCanvas.cpp	2021-06-22 00:22:44 UTC (rev 279093)
@@ -438,6 +438,13 @@
     return {{ valueIndexForData(convertEnumerationToString(argument)), RecordingSwizzleType::String }};
 }
 
+std::optional<InspectorCanvasCallTracer::ProcessedArgument> InspectorCanvas::processArgument(std::optional<double>& argument)
+{
+    if (!argument)
+        return std::nullopt;
+    return {{ JSON::Value::create(*argument), RecordingSwizzleType::Number }};
+}
+
 std::optional<InspectorCanvasCallTracer::ProcessedArgument> InspectorCanvas::processArgument(std::optional<float>& argument)
 {
     if (!argument)
@@ -536,6 +543,11 @@
     return {{ buildArrayForVector(WTFMove(deduplicated)), RecordingSwizzleType::String }};
 }
 
+std::optional<InspectorCanvasCallTracer::ProcessedArgument> InspectorCanvas::processArgument(Vector<double>& argument)
+{
+    return {{ buildArrayForVector(argument), RecordingSwizzleType::Array }};
+}
+
 std::optional<InspectorCanvasCallTracer::ProcessedArgument> InspectorCanvas::processArgument(Vector<float>& argument)
 {
     return {{ buildArrayForVector(argument), RecordingSwizzleType::Array }};

Modified: trunk/Source/WebCore/inspector/InspectorCanvasCallTracer.h (279092 => 279093)


--- trunk/Source/WebCore/inspector/InspectorCanvasCallTracer.h	2021-06-22 00:01:54 UTC (rev 279092)
+++ trunk/Source/WebCore/inspector/InspectorCanvasCallTracer.h	2021-06-22 00:22:44 UTC (rev 279093)
@@ -153,6 +153,7 @@
     macro(ImageDataSettings&) \
     macro(ImageSmoothingQuality) \
     macro(std::optional<float>&) \
+    macro(std::optional<double>&) \
     macro(Path2D*) \
     macro(RefPtr<CanvasGradient>&) \
     macro(RefPtr<CanvasPattern>&) \
@@ -168,6 +169,7 @@
     macro(String&) \
     macro(Vector<String>&) \
     macro(Vector<float>&) \
+    macro(Vector<double>&) \
     macro(Vector<uint32_t>&) \
     macro(Vector<int32_t>&) \
     macro(double) \
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to