Title: [221605] trunk/Source/WebCore
Revision
221605
Author
[email protected]
Date
2017-09-04 20:39:45 -0700 (Mon, 04 Sep 2017)

Log Message

[Canvas] Move non-standard functionality/aliases back to CanvasRenderingContext2D.idl
https://bugs.webkit.org/show_bug.cgi?id=176340

Patch by Sam Weinig <[email protected]> on 2017-09-04
Reviewed by Darin Adler.

In r221598 (https://webkit.org/b/176276), the CanvasRenderingContext2D was split out into
separate interfaces to the match the spec and prepare for implementing OffscreenCanvas. While
doing that, related non-standard functionality and aliases were moved as well. In retrospect,
that doesn't really makes sense, as we don't want to add these legacy properties to any new
interfaces that happen to implement/use the broken out interfaces. Since they are specific
to CanvasRenderingContext2D, let's move them back.

* html/canvas/CanvasCompositing.idl:
* html/canvas/CanvasDrawImage.idl:
* html/canvas/CanvasFillStrokeStyles.idl:
* html/canvas/CanvasImageData.idl:
* html/canvas/CanvasImageSmoothing.idl:
* html/canvas/CanvasPathDrawingStyles.idl:
* html/canvas/CanvasShadowStyles.idl:
* html/canvas/CanvasRenderingContext2D.idl:

    Move non-standard operation and attributes back to CanvasRenderingContext2D.idl.

    * html/canvas/CanvasRenderingContext2D.h:
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::stringForCanvasFillRule): Deleted.

    Remove unused function.

(WebCore::CanvasRenderingContext2D::setAlpha): Deleted.
(WebCore::CanvasRenderingContext2D::setCompositeOperation): Deleted.

    Removed. Instead, the IDL uses [ImplementedAs] to forward to the
    underlying setGlobalAlpha/setGlobalCompositeOperation. This reduces
    code and makes it clear they are strict aliases.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (221604 => 221605)


--- trunk/Source/WebCore/ChangeLog	2017-09-05 03:31:20 UTC (rev 221604)
+++ trunk/Source/WebCore/ChangeLog	2017-09-05 03:39:45 UTC (rev 221605)
@@ -1,3 +1,41 @@
+2017-09-04  Sam Weinig  <[email protected]>
+
+        [Canvas] Move non-standard functionality/aliases back to CanvasRenderingContext2D.idl
+        https://bugs.webkit.org/show_bug.cgi?id=176340
+
+        Reviewed by Darin Adler.
+
+        In r221598 (https://webkit.org/b/176276), the CanvasRenderingContext2D was split out into
+        separate interfaces to the match the spec and prepare for implementing OffscreenCanvas. While
+        doing that, related non-standard functionality and aliases were moved as well. In retrospect,
+        that doesn't really makes sense, as we don't want to add these legacy properties to any new
+        interfaces that happen to implement/use the broken out interfaces. Since they are specific
+        to CanvasRenderingContext2D, let's move them back.
+
+        * html/canvas/CanvasCompositing.idl:
+        * html/canvas/CanvasDrawImage.idl:
+        * html/canvas/CanvasFillStrokeStyles.idl:
+        * html/canvas/CanvasImageData.idl:
+        * html/canvas/CanvasImageSmoothing.idl:
+        * html/canvas/CanvasPathDrawingStyles.idl:
+        * html/canvas/CanvasShadowStyles.idl:
+        * html/canvas/CanvasRenderingContext2D.idl:
+
+            Move non-standard operation and attributes back to CanvasRenderingContext2D.idl.
+
+            * html/canvas/CanvasRenderingContext2D.h:
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::stringForCanvasFillRule): Deleted.
+            
+            Remove unused function.
+
+        (WebCore::CanvasRenderingContext2D::setAlpha): Deleted.
+        (WebCore::CanvasRenderingContext2D::setCompositeOperation): Deleted.
+
+            Removed. Instead, the IDL uses [ImplementedAs] to forward to the 
+            underlying setGlobalAlpha/setGlobalCompositeOperation. This reduces
+            code and makes it clear they are strict aliases.
+
 2017-09-03  Darin Adler  <[email protected]>
 
         Fix a few minor problems found while working toward removing unneeded calls to updateStyle

Modified: trunk/Source/WebCore/html/canvas/CanvasCompositing.idl (221604 => 221605)


--- trunk/Source/WebCore/html/canvas/CanvasCompositing.idl	2017-09-05 03:31:20 UTC (rev 221604)
+++ trunk/Source/WebCore/html/canvas/CanvasCompositing.idl	2017-09-05 03:39:45 UTC (rev 221605)
@@ -32,9 +32,4 @@
     // compositing
     attribute unrestricted float globalAlpha; // (default 1.0)
     attribute DOMString globalCompositeOperation; // (default source-over)
-
-
-    // Non-standard legacy functionality
-    void setAlpha(optional unrestricted float alpha = NaN);
-    void setCompositeOperation(optional DOMString compositeOperation = "undefined"); // FIXME: Using "undefined" as default parameter value is wrong.
 };

Modified: trunk/Source/WebCore/html/canvas/CanvasDrawImage.idl (221604 => 221605)


--- trunk/Source/WebCore/html/canvas/CanvasDrawImage.idl	2017-09-05 03:31:20 UTC (rev 221604)
+++ trunk/Source/WebCore/html/canvas/CanvasDrawImage.idl	2017-09-05 03:39:45 UTC (rev 221605)
@@ -40,11 +40,4 @@
     [MayThrowException] void drawImage(CanvasImageSource image, unrestricted double dx, unrestricted double dy);
     [MayThrowException] void drawImage(CanvasImageSource image, unrestricted double dx, unrestricted double dy, unrestricted double dw, unrestricted double dh);
     [MayThrowException] void drawImage(CanvasImageSource image, unrestricted double sx, unrestricted double sy, unrestricted double sw, unrestricted double sh, unrestricted double dx, unrestricted double dy, unrestricted double dw, unrestricted double dh);
-
-
-    // Non-standard legacy functionality.
-    void drawImageFromRect(HTMLImageElement image,
-        optional unrestricted float sx = 0, optional unrestricted float sy = 0, optional unrestricted float sw = 0, optional unrestricted float sh = 0,
-        optional unrestricted float dx = 0, optional unrestricted float dy = 0, optional unrestricted float dw = 0, optional unrestricted float dh = 0,
-        optional DOMString compositeOperation = "");
 };

Modified: trunk/Source/WebCore/html/canvas/CanvasFillStrokeStyles.idl (221604 => 221605)


--- trunk/Source/WebCore/html/canvas/CanvasFillStrokeStyles.idl	2017-09-05 03:31:20 UTC (rev 221604)
+++ trunk/Source/WebCore/html/canvas/CanvasFillStrokeStyles.idl	2017-09-05 03:39:45 UTC (rev 221605)
@@ -42,15 +42,4 @@
     [MayThrowException] CanvasGradient createLinearGradient(float x0, float y0, float x1, float y1);
     [MayThrowException] CanvasGradient createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1);
     [MayThrowException] CanvasPattern? createPattern(CanvasImageSource image, [TreatNullAs=EmptyString] DOMString repetition);
-
-
-    // Non-standard legacy aliases.
-    void setStrokeColor(DOMString color, optional unrestricted float alpha);
-    void setStrokeColor(unrestricted float grayLevel, optional float alpha = 1);
-    void setStrokeColor(unrestricted float r, unrestricted float g, unrestricted float b, unrestricted float a);
-    void setStrokeColor(unrestricted float c, unrestricted float m, unrestricted float y, unrestricted float k, unrestricted float a);
-    void setFillColor(DOMString color, optional unrestricted float alpha);
-    void setFillColor(unrestricted float grayLevel, optional unrestricted float alpha = 1);
-    void setFillColor(unrestricted float r, unrestricted float g, unrestricted float b, unrestricted float a);
-    void setFillColor(unrestricted float c, unrestricted float m, unrestricted float y, unrestricted float k, unrestricted float a);
 };

Modified: trunk/Source/WebCore/html/canvas/CanvasImageData.idl (221604 => 221605)


--- trunk/Source/WebCore/html/canvas/CanvasImageData.idl	2017-09-05 03:31:20 UTC (rev 221604)
+++ trunk/Source/WebCore/html/canvas/CanvasImageData.idl	2017-09-05 03:39:45 UTC (rev 221605)
@@ -35,10 +35,4 @@
     [MayThrowException] ImageData getImageData(float sx, float sy, float sw, float sh);
     void putImageData(ImageData imagedata, float dx, float dy);
     void putImageData(ImageData imagedata, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight);
-
-
-    // Non-standard functionality.
-    [MayThrowException] ImageData webkitGetImageDataHD(float sx, float sy, float sw, float sh);
-    void webkitPutImageDataHD(ImageData imagedata, float dx, float dy);
-    void webkitPutImageDataHD(ImageData imagedata, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight);
 };

Modified: trunk/Source/WebCore/html/canvas/CanvasImageSmoothing.idl (221604 => 221605)


--- trunk/Source/WebCore/html/canvas/CanvasImageSmoothing.idl	2017-09-05 03:31:20 UTC (rev 221604)
+++ trunk/Source/WebCore/html/canvas/CanvasImageSmoothing.idl	2017-09-05 03:39:45 UTC (rev 221605)
@@ -30,7 +30,4 @@
     // image smoothing
     attribute boolean imageSmoothingEnabled; // (default true)
     attribute ImageSmoothingQuality imageSmoothingQuality; // (default low)
-
-    // Non-standard legacy alias.
-    [ImplementedAs=imageSmoothingEnabled] attribute boolean webkitImageSmoothingEnabled;
 };

Modified: trunk/Source/WebCore/html/canvas/CanvasPathDrawingStyles.idl (221604 => 221605)


--- trunk/Source/WebCore/html/canvas/CanvasPathDrawingStyles.idl	2017-09-05 03:31:20 UTC (rev 221604)
+++ trunk/Source/WebCore/html/canvas/CanvasPathDrawingStyles.idl	2017-09-05 03:39:45 UTC (rev 221605)
@@ -39,13 +39,4 @@
     void setLineDash(sequence<unrestricted float> segments); // default empty
     sequence<unrestricted float> getLineDash();
     attribute unrestricted float lineDashOffset;
-
-
-    // Non-standard legacy aliases.
-    void setLineWidth(optional unrestricted float width = NaN);
-    void setLineCap(optional DOMString cap = "undefined"); // FIXME: Using "undefined" as default parameter value is wrong.
-    void setLineJoin(optional DOMString join = "undefined"); // FIXME: Using "undefined" as default parameter value is wrong.
-    void setMiterLimit(optional unrestricted float limit = NaN);
-    attribute sequence<unrestricted float> webkitLineDash;
-    [ImplementedAs=lineDashOffset] attribute unrestricted float webkitLineDashOffset;
 };

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (221604 => 221605)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2017-09-05 03:31:20 UTC (rev 221604)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2017-09-05 03:39:45 UTC (rev 221605)
@@ -1050,19 +1050,6 @@
     return rule == CanvasFillRule::Nonzero ? RULE_NONZERO : RULE_EVENODD;
 }
 
-String CanvasRenderingContext2D::stringForCanvasFillRule(CanvasFillRule windingRule)
-{
-    switch (windingRule) {
-    case CanvasFillRule::Nonzero:
-        return ASCIILiteral("nonzero");
-    case CanvasFillRule::Evenodd:
-        return ASCIILiteral("evenodd");
-    }
-
-    ASSERT_NOT_REACHED();
-    return String();
-}
-
 void CanvasRenderingContext2D::fill(CanvasFillRule windingRule)
 {
     fillInternal(m_path, windingRule);
@@ -1685,16 +1672,6 @@
     drawImage(imageElement, FloatRect { sx, sy, sw, sh }, FloatRect { dx, dy, dw, dh }, op, BlendModeNormal);
 }
 
-void CanvasRenderingContext2D::setAlpha(float alpha)
-{
-    setGlobalAlpha(alpha);
-}
-
-void CanvasRenderingContext2D::setCompositeOperation(const String& operation)
-{
-    setGlobalCompositeOperation(operation);
-}
-
 void CanvasRenderingContext2D::clearCanvas()
 {
     auto* c = drawingContext();

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h (221604 => 221605)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h	2017-09-05 03:31:20 UTC (rev 221604)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h	2017-09-05 03:39:45 UTC (rev 221605)
@@ -143,8 +143,6 @@
 
     void beginPath();
 
-    static String stringForCanvasFillRule(CanvasFillRule);
-
     void fill(CanvasFillRule = CanvasFillRule::Nonzero);
     void stroke();
     void clip(CanvasFillRule = CanvasFillRule::Nonzero);
@@ -176,10 +174,6 @@
 
     void drawImageFromRect(HTMLImageElement&, float sx = 0, float sy = 0, float sw = 0, float sh = 0, float dx = 0, float dy = 0, float dw = 0, float dh = 0, const String& compositeOperation = emptyString());
 
-    void setAlpha(float);
-
-    void setCompositeOperation(const String&);
-
     using Style = Variant<String, RefPtr<CanvasGradient>, RefPtr<CanvasPattern>>;
     Style strokeStyle() const;
     void setStrokeStyle(Style&&);

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl (221604 => 221605)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl	2017-09-05 03:31:20 UTC (rev 221604)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl	2017-09-05 03:39:45 UTC (rev 221605)
@@ -35,9 +35,52 @@
     // FIXME: This has been moved to OffscreenCanvasRenderingContext2D in the latest standard.
     void commit();
 
-    // Non-standard functionality.
+
+    // Non-standard legacy aliases (Compositing).
+    [ImplementedAs=setGlobalAlpha] void setAlpha(optional unrestricted float alpha = NaN);
+    [ImplementedAs=setGlobalCompositeOperation] void setCompositeOperation(optional DOMString compositeOperation = "undefined"); // FIXME: Using "undefined" as default parameter value is wrong.
+
+    // Non-standard functionality (CanvasDrawImage).
+    void drawImageFromRect(HTMLImageElement image,
+        optional unrestricted float sx = 0, optional unrestricted float sy = 0, optional unrestricted float sw = 0, optional unrestricted float sh = 0,
+        optional unrestricted float dx = 0, optional unrestricted float dy = 0, optional unrestricted float dw = 0, optional unrestricted float dh = 0,
+        optional DOMString compositeOperation = "");
+
+    // Non-standard legacy aliases (CanvasFillStrokeStyles).
+    void setStrokeColor(DOMString color, optional unrestricted float alpha);
+    void setStrokeColor(unrestricted float grayLevel, optional float alpha = 1);
+    void setStrokeColor(unrestricted float r, unrestricted float g, unrestricted float b, unrestricted float a);
+    void setStrokeColor(unrestricted float c, unrestricted float m, unrestricted float y, unrestricted float k, unrestricted float a);
+    void setFillColor(DOMString color, optional unrestricted float alpha);
+    void setFillColor(unrestricted float grayLevel, optional unrestricted float alpha = 1);
+    void setFillColor(unrestricted float r, unrestricted float g, unrestricted float b, unrestricted float a);
+    void setFillColor(unrestricted float c, unrestricted float m, unrestricted float y, unrestricted float k, unrestricted float a);
+
+    // Non-standard functionality (CanvasImageData).
     readonly attribute float webkitBackingStorePixelRatio;
+    [MayThrowException] ImageData webkitGetImageDataHD(float sx, float sy, float sw, float sh);
+    void webkitPutImageDataHD(ImageData imagedata, float dx, float dy);
+    void webkitPutImageDataHD(ImageData imagedata, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight);
 
+    // Non-standard legacy alias (CanvasImageSmoothing).
+    [ImplementedAs=imageSmoothingEnabled] attribute boolean webkitImageSmoothingEnabled;
+
+    // Non-standard legacy aliases (CanvasPathDrawingStyles).
+    void setLineWidth(optional unrestricted float width = NaN);
+    void setLineCap(optional DOMString cap = "undefined"); // FIXME: Using "undefined" as default parameter value is wrong.
+    void setLineJoin(optional DOMString join = "undefined"); // FIXME: Using "undefined" as default parameter value is wrong.
+    void setMiterLimit(optional unrestricted float limit = NaN);
+    attribute sequence<unrestricted float> webkitLineDash;
+    [ImplementedAs=lineDashOffset] attribute unrestricted float webkitLineDashOffset;
+
+    // Non-standard legacy aliases (CanvasShadowStyles).
+    void setShadow(unrestricted float width, unrestricted float height, unrestricted float blur, optional DOMString color, optional unrestricted float alpha);
+    void setShadow(unrestricted float width, unrestricted float height, unrestricted float blur, unrestricted float grayLevel, optional unrestricted float alpha = 1);
+    void setShadow(unrestricted float width, unrestricted float height, unrestricted float blur, unrestricted float r, unrestricted float g, unrestricted float b, unrestricted float a);
+    void setShadow(float width, unrestricted float height, unrestricted float blur, unrestricted float c, unrestricted float m, unrestricted float y, unrestricted float k, unrestricted float a);
+    void clearShadow();
+
+    // Inspector-only.
     [EnabledAtRuntime=InspectorAdditions] void setPath(Path2D path);
     [EnabledAtRuntime=InspectorAdditions, NewObject] Path2D getPath();
 };

Modified: trunk/Source/WebCore/html/canvas/CanvasShadowStyles.idl (221604 => 221605)


--- trunk/Source/WebCore/html/canvas/CanvasShadowStyles.idl	2017-09-05 03:31:20 UTC (rev 221604)
+++ trunk/Source/WebCore/html/canvas/CanvasShadowStyles.idl	2017-09-05 03:39:45 UTC (rev 221605)
@@ -34,12 +34,4 @@
     attribute unrestricted double shadowOffsetY; // (default 0)
     attribute unrestricted double shadowBlur; // (default 0)
     attribute DOMString shadowColor; // (default transparent black)
-
-
-    // Non-standard legacy aliases.
-    void setShadow(unrestricted float width, unrestricted float height, unrestricted float blur, optional DOMString color, optional unrestricted float alpha);
-    void setShadow(unrestricted float width, unrestricted float height, unrestricted float blur, unrestricted float grayLevel, optional unrestricted float alpha = 1);
-    void setShadow(unrestricted float width, unrestricted float height, unrestricted float blur, unrestricted float r, unrestricted float g, unrestricted float b, unrestricted float a);
-    void setShadow(float width, unrestricted float height, unrestricted float blur, unrestricted float c, unrestricted float m, unrestricted float y, unrestricted float k, unrestricted float a);
-    void clearShadow();
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to