From 740634d0f30a3b76e9da166ac2fa8835fcc073ab Mon Sep 17 00:00:00 2001 From: Justin Novosad Date: Wed, 2 Mar 2016 17:30:55 -0500 Subject: [PATCH] Remove CanvasProxy along with related concepts and complexities The CanvasProxy feature is being removed to make room for a newer incarnation known as OffscreenCanvas, which will be added soon. Draft Proposal: https://wiki.whatwg.org/wiki/OffscreenCanvas. There are currently no known implementations of CanvasProxy. Summary of changes: * Remove CanvasProxy and all canvas methods related to CanvasProxy * Remove the notion of a CanvasRenderingContext2D being in a proxied state. * Remove the notion of a CanvasRenderingContext2D being in an indirect state. * Remove the notion of a "scratch bitmap" from CanvasRenderingContext2D and use a single concept of an "output bitmap" everywhere. * Remove the notion of a "list of pending user interface actions" * Remove the notion canvas context binding: no more standalone contexts, no more setContext method on canvas. * Remove the commit() method of CanvasRenderingContext2D. * Remove the CanvasRenderingContext2D constructor. * Remove the notion of concept-canvas-context-bitmap-mode, canvii now always behave as what was previous described as "fixed" mode. * Rename bitmap modes "direct-2d" and "direct-webgl" to just "2d" and "webgl" respectively. * The hit region list, alpha flag, and origin-clean flag are now internal attributes of CanvasRenderingContext2D, rather than attributes of the scratch/output bitmaps. * CanvasRenderingContext2D and its sub-interfaces are no longer exposed in Workers. PR: https://github.com/whatwg/html/pull/790 --- source | 867 +++++++++++++-------------------------------------------- 1 file changed, 188 insertions(+), 679 deletions(-) diff --git a/source b/source index ac1f813aadf..f2959a9636f 100644 --- a/source +++ b/source @@ -59454,9 +59454,6 @@ interface HTMLCanvasElement : HTMLElement { RenderingContext? getContext(DOMString contextId, any... arguments); boolean probablySupportsContext(DOMString contextId, any... arguments); - void setContext(RenderingContext context); - CanvasProxy transferControlToProxy(); - DOMString toDataURL(optional DOMString type, any... arguments); void toBlob(BlobCallback _callback, optional DOMString type, any... arguments); }; @@ -59476,7 +59473,7 @@ callback BlobCallback = void (Blob? blob);

When authors use the canvas element, they must also provide content that, when presented to the user, conveys essentially the same function or purpose as the - canvas' bitmap. This content may be placed as content of the canvas + canvas's bitmap. This content may be placed as content of the canvas element. The contents of the canvas element, if any, are the element's fallback content.

@@ -59554,10 +59551,8 @@ callback BlobCallback = void (Blob? blob); what kind of rendering context it is, a canvas also has a canvas context mode, which is initially none but can be changed to either direct-2d, direct-webgl, indirect, or proxied by algorithms defined in this specification.

+ data-x="concept-canvas-2d">2d or webgl by algorithms defined in this specification.

When its canvas context mode is none, a canvas element has no rendering context, @@ -59575,11 +59570,9 @@ callback BlobCallback = void (Blob? blob); data-x="attr-canvas-height">height content attributes are set, removed, changed, or redundantly set to the value they already have, if the canvas context mode is direct-2d, the user agent must set bitmap dimensions to the numeric values of - the width and 2d, the user agent must set bitmap dimensions to the numeric values + of the width and height content attributes.

The width and height IDL attributes must reflect the @@ -59609,11 +59602,6 @@ callback BlobCallback = void (Blob? blob); data-x="canvas-context-2d">2d" context after getting a "webgl" context).

-

Throws an InvalidStateError exception if the setContext() or transferControlToProxy() methods have been - used.

-
supported = canvas . probablySupportsContext(contextId [, ... ] )
@@ -59627,63 +59615,24 @@ callback BlobCallback = void (Blob? blob); data-x="dom-canvas-getContext">getContext() will or will not return an object, as conditions (e.g. availability of system resources) can vary over time.

-

Throws an InvalidStateError exception if the setContext() or transferControlToProxy() methods have been - used.

- - - -
canvas . setContext(context)
- -
- -

Sets the canvas' rendering context to the given object.

- -

Throws an InvalidStateError exception if the getContext() or transferControlToProxy() methods have been - used.

-
-

There are two ways for a canvas element to acquire a rendering context: the - canvas element can provide one via the getContext() method, and one can be assigned to it via the - setContext() method. In addition, the whole issue of a - rendering context can be taken out of the canvas element's hands and passed to a - CanvasProxy object, which itself can then be assigned a rendering context using its - setContext() method.

- -

These three methods are mutually exclusive; calling any of the three makes the other two start - throwing InvalidStateError exceptions when called.

- -

Each rendering context has a context bitmap - mode, which is one of fixed, unbound, or bound. - Initially, rendering contexts must be in the unbound - mode.

- -
-

The getContext(contextId, arguments...) method of the canvas element, when invoked, must run the steps in the cell of the following table whose column header describes the - canvas element's canvas context mode - and whose row header describes the method's first argument.

+ canvas element's canvas context + mode and whose row header describes the method's first argument.

none - direct-2d - direct-webgl - indirect - proxied + 2d + webgl
"2d" @@ -59691,23 +59640,17 @@ callback BlobCallback = void (Blob? blob); Follow the 2D context creation algorithm defined in the section below, passing it the - canvas element and the method's arguments..., to obtain a CanvasRenderingContext2D object; - if this does not throw an exception, then + canvas element and the method's arguments..., to obtain a + CanvasRenderingContext2D object; if this does not throw an exception, then set the canvas element's context - mode to direct-2d, set - the CanvasRenderingContext2D object's context bitmap mode to - fixed, and return the - CanvasRenderingContext2D object + mode to 2d, and return the + CanvasRenderingContext2D object. Return the same object as was return the last time the method was invoked with this same first argument. Return null. - - Throw an InvalidStateError exception. - - Throw an InvalidStateError exception.
"webgl", if the user agent supports the WebGL feature in its current configuration @@ -59715,12 +59658,9 @@ callback BlobCallback = void (Blob? blob); Follow the instructions given in the WebGL specification's Context Creation section to obtain either a WebGLRenderingContext or null; if the returned value is null, - then return null and abort these steps, otherwise, set the canvas element's context mode to direct-webgl, set the new - WebGLRenderingContext object's context bitmap mode to fixed, and return the WebGLRenderingContext + then return null and abort these steps, otherwise, set the canvas element's + context mode to webgl, and return the WebGLRenderingContext object @@ -59728,10 +59668,6 @@ callback BlobCallback = void (Blob? blob); Return the same object as was return the last time the method was invoked with this same first argument. - - Throw an InvalidStateError exception. - - Throw an InvalidStateError exception.
A vendor-specific extension* @@ -59741,10 +59677,6 @@ callback BlobCallback = void (Blob? blob); Behave as defined for the extension. Behave as defined for the extension. - - Throw an InvalidStateError exception. - - Throw an InvalidStateError exception.
An unsupported value† @@ -59754,10 +59686,6 @@ callback BlobCallback = void (Blob? blob); Return null. Return null. - - Throw an InvalidStateError exception. - - Throw an InvalidStateError exception.
@@ -59779,36 +59707,6 @@ callback BlobCallback = void (Blob? blob);
-

The setContext(context) method of the canvas element, when invoked, must - run the following steps:

- -
    - -
  1. If the canvas element's canvas - context mode is neither none nor indirect, throw an InvalidStateError - exception and abort these steps.

  2. - -
  3. If context's context - bitmap mode is fixed, then throw an - InvalidStateError exception and abort these steps.

  4. - -
  5. If context's context - bitmap mode is bound, then run context's unbinding steps and - set its context's context - bitmap mode to unbound.

  6. - -
  7. Run context's binding - steps to bind it to this canvas element.

  8. - -
  9. Set the canvas element's context - mode to indirect and the context's context bitmap - mode to bound.

  10. - -
- -
-
@@ -59921,156 +59819,6 @@ callback BlobCallback = void (Blob? blob); - - -
Proxying canvases to workers
- -

Since DOM nodes cannot be accessed across worker boundaries, a proxy object is needed to enable - workers to render to canvas elements in Documents.

- -
[Exposed=(Window,Worker)]
-interface CanvasProxy {
-  void setContext(RenderingContext context);
-};
- -
- -
canvasProxy = canvas . transferControlToProxy()
- -
- -

Returns a CanvasProxy object that can be used to transfer control for this - canvas over to another document (e.g. an iframe from another origin) - or to a worker.

- -

Throws an InvalidStateError exception if the getContext() or setContext() methods have been used.

- -
- -
canvasProxy . setContext(context)
- -
- -

Sets the CanvasProxy object's canvas element's rendering context to - the given object.

- -

Throws an InvalidStateError exception if the CanvasProxy has been - transferred.

- -
- -
- -
- -

The transferControlToProxy() - method of the canvas element, when invoked, must run the following steps:

- -
    - -
  1. If the canvas element's canvas - context mode is not none, throw an - InvalidStateError exception and abort these steps.

  2. - -
  3. Set the canvas element's context - mode to proxied.

  4. - -
  5. Return a CanvasProxy object bound to this canvas - element.

  6. - -
- -

Each CanvasProxy object has a [[Detached]] internal slot (like any - transferable object).

- -

Each CanvasProxy object can be disabled, meaning it can no longer be bound to - rendering contexts. When first created, a CanvasProxy object must not be disabled.

- -

A CanvasProxy is created with a link to a canvas element. A - CanvasProxy object that has not been disabled must have a strong reference to its canvas - element.

- -

The setContext(context) method of CanvasProxy objects, when invoked, - must run the following steps:

- -
    - -
  1. If the CanvasProxy object has been disabled, throw an InvalidStateError - exception and abort these steps.

  2. - -
  3. Set CanvasProxy object's [[Detached]] internal slot value to - true.

  4. - -
  5. If context's context - bitmap mode is fixed, then throw an - InvalidStateError exception and abort these steps.

  6. - -
  7. If context's context - bitmap mode is bound, then run context's unbinding steps and - set its context's context - bitmap mode to unbound.

  8. - -
  9. Run context's binding - steps to bind it to this CanvasProxy object's canvas - element.

  10. - -
  11. Set the context's context bitmap mode to bound.

  12. - -
- -

Each CanvasProxy object's [[Transfer]] - internal method, given a targetRealm, must run these steps:

- -
    -
  1. Let new be a new CanvasProxy object in targetRealm, - linked to the same canvas element as this.

  2. - -
  3. Set this's [[Detached]] internal slot value to true.

  4. - -
  5. Disable this.

  6. - -
  7. Return new.

  8. -
- -
- -

Here is a clock implemented on a worker. First, the main page:

- -
<!DOCTYPE HTML>
-<title>Clock</title>
-<canvas></canvas> 
-<script>
-  var canvas = document.getElementsByTagName('canvas')[0];
-  var proxy = canvas.transferControlToProxy();
-  var worker = new Worker('clock.js');
-  worker.postMessage(proxy, [proxy]);
-</script>
- -

Second, the worker:

- -
onmessage = function (event) {
-  var context = new CanvasRenderingContext2D();
-  event.data.setContext(context); // event.data is the CanvasProxy object
-  setInterval(function () {
-    context.clearRect(0, 0, context.width, context.height);
-    context.fillText(new Date(), 0, 100);
-    context.commit();
-  }, 1000);
-};
- -
- - - -
The 2D rendering context
@@ -60089,26 +59837,13 @@ dictionary CanvasRenderingContext2DSettings { enum ImageSmoothingQuality { "low", "medium", "high" }; -[Constructor(), - Constructor(unsigned long width, unsigned long height), - Exposed=(Window,Worker)] interface CanvasRenderingContext2D { - // back-reference to the canvas readonly attribute HTMLCanvasElement canvas; // canvas dimensions attribute unsigned long width; attribute unsigned long height; - - // for contexts that aren't directly fixed to a specific canvas - void commit(); // push the image to the output bitmap - }; CanvasRenderingContext2D implements CanvasState; CanvasRenderingContext2D implements CanvasTransform; @@ -60127,14 +59862,14 @@ interface CanvasRenderingContext2D { CanvasRenderingContext2D implements CanvasTextDrawingStyles; CanvasRenderingContext2D implements CanvasPath; -[NoInterfaceObject, Exposed=(Window,Worker)] +[NoInterfaceObject] interface CanvasState { // state void save(); // push state on state stack void restore(); // pop state stack and restore state }; -[NoInterfaceObject, Exposed=(Window,Worker)] +[NoInterfaceObject] interface CanvasTransform { // transformations (default transform is the identity matrix) void scale(unrestricted double x, unrestricted double y); @@ -60153,14 +59888,14 @@ interface CanvasTransform { --> }; -[NoInterfaceObject, Exposed=(Window,Worker)] +[NoInterfaceObject] interface CanvasCompositing { // compositing attribute unrestricted double globalAlpha; // (default 1.0) attribute DOMString globalCompositeOperation; // (default source-over) }; -[NoInterfaceObject, Exposed=(Window,Worker)] +[NoInterfaceObject] interface CanvasImageSmoothing { // image smoothing attribute boolean imageSmoothingEnabled; // (default true) @@ -60176,7 +59911,7 @@ interface CanvasImageSmoothing { --> }; -[NoInterfaceObject, Exposed=(Window,Worker)] +[NoInterfaceObject] interface CanvasFillStrokeStyles { // colours and styles (see also the CanvasPathDrawingStyles and CanvasTextDrawingStyles interfaces) attribute (DOMString or CanvasGradient or CanvasPattern) strokeStyle; // (default black) @@ -60190,7 +59925,7 @@ interface CanvasFillStrokeStyles { --> }; -[NoInterfaceObject, Exposed=(Window,Worker)] +[NoInterfaceObject] interface CanvasShadowStyles { // shadows attribute unrestricted double shadowOffsetX; // (default 0) @@ -60199,7 +59934,7 @@ interface CanvasShadowStyles { attribute DOMString shadowColor; // (default transparent black) }; -[NoInterfaceObject, Exposed=(Window,Worker)] +[NoInterfaceObject] interface CanvasRect { // rects void clearRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h); @@ -60207,7 +59942,7 @@ interface CanvasRect { void strokeRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h); }; -[NoInterfaceObject, Exposed=(Window,Worker)] +[NoInterfaceObject] interface CanvasDrawPath { // path API (see also CanvasPath) void beginPath(); @@ -60224,7 +59959,7 @@ interface CanvasDrawPath { boolean isPointInStroke(Path2D path, unrestricted double x, unrestricted double y); }; -[NoInterfaceObject, Exposed=(Window,Worker)] +[NoInterfaceObject] interface CanvasUserInterface { void drawFocusIfNeeded(Element element); void drawFocusIfNeeded(Path2D path, Element element); @@ -60232,7 +59967,7 @@ interface CanvasUserInterface { void scrollPathIntoView(Path2D path); }; -[NoInterfaceObject, Exposed=(Window,Worker)] +[NoInterfaceObject] interface CanvasText { // text (see also the CanvasPathDrawingStyles and CanvasTextDrawingStyles interfaces) void fillText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth); @@ -60242,7 +59977,7 @@ interface CanvasText { TextMetrics measureText(DOMString text); }; -[NoInterfaceObject, Exposed=(Window,Worker)] +[NoInterfaceObject] interface CanvasDrawImage { // drawing images void drawImage(CanvasImageSource image, unrestricted double dx, unrestricted double dy); @@ -60250,7 +59985,7 @@ interface CanvasDrawImage { 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); }; -[NoInterfaceObject, Exposed=(Window,Worker)] +[NoInterfaceObject] interface CanvasHitRegion { // hit regions void addHitRegion(optional HitRegionOptions options); @@ -60258,7 +59993,7 @@ interface CanvasHitRegion { void clearHitRegions(); }; -[NoInterfaceObject, Exposed=(Window,Worker)] +[NoInterfaceObject] interface CanvasImageData { // pixel manipulation ImageData createImageData(double sw, double sh); @@ -60274,7 +60009,7 @@ enum CanvasTextAlign { "CanvasTextBaseline { "top", "hanging", "middle", "alphabetic", "ideographic", "bottom" }; enum CanvasDirection { "ltr", "rtl", "inherit" }; -[NoInterfaceObject, Exposed=(Window,Worker)] +[NoInterfaceObject] interface CanvasPathDrawingStyles { // line caps/joins attribute unrestricted double lineWidth; // (default 1) @@ -60288,7 +60023,7 @@ interface CanvasPathDrawingStyles { attribute unrestricted double lineDashOffset; }; -[NoInterfaceObject, Exposed=(Window,Worker)] +[NoInterfaceObject] interface CanvasTextDrawingStyles { // text attribute DOMString font; // (default 10px sans-serif) @@ -60312,19 +60047,16 @@ interface CanvasPath { void ellipse(unrestricted double x, unrestricted double y, unrestricted double radiusX, unrestricted double radiusY, unrestricted double rotation, unrestricted double startAngle, unrestricted double endAngle, optional boolean anticlockwise = false); }; -[Exposed=(Window,Worker)] interface CanvasGradient { // opaque object void addColorStop(double offset, DOMString color); }; -[Exposed=(Window,Worker)] interface CanvasPattern { // opaque object void setTransform(DOMMatrix transform); }; -[Exposed=(Window,Worker)] interface TextMetrics { // x-direction readonly attribute double width; // advance width @@ -60399,21 +60131,11 @@ interface Path2D { -
context = new CanvasRenderingContext2D( [ width, height ] )
- -
- -

Returns an unbound CanvasRenderingContext2D object with an implied bitmap with - the given dimensions in CSS pixels (300x150, if the arguments are omitted).

- -
-
context . canvas
-

Returns the canvas element, if the rendering context was obtained using the - getContext() method.

+

Returns the canvas element.

@@ -60424,16 +60146,8 @@ interface Path2D {

Return the dimensions of the bitmap, in CSS pixels.

-

Can be set, to update the bitmap's dimensions. If the rendering context is bound to a canvas, - this will also update the canvas' intrinsic dimensions.

- - - -
context . commit()
- -
- -

If the rendering context is bound to a canvas, display the current frame.

+

Can be set, to update the bitmap's dimensions. This will also update the canvas's + intrinsic dimensions.

@@ -60441,52 +60155,37 @@ interface Path2D {
-

A CanvasRenderingContext2D object can be obtained in two ways: the getContext() method on a canvas element (which - invokes the 2D context creation algorithm), and the CanvasRenderingContext2D() constructor.

- -

A CanvasRenderingContext2D object has a scratch bitmap and can be bound - to an output bitmap. These are initialised when the object is created, and can be - subsequently adjusted when the rendering context is bound or unbound. In some cases, these bitmaps are the same - underlying bitmap. In general, the scratch bitmap is what scripts interact with, and - the output bitmap is what is being displayed. These bitmaps always have the same - dimensions.

+

A CanvasRenderingContext2D object has an output bitmap that + is initialised when the object is created.

-

Each such bitmap has an origin-clean flag, - which can be set to true or false. Initially, when one of these bitmaps is created, its The output bitmap has an origin-clean flag, which can be set to true or false. + Initially, when one of these bitmaps is created, its origin-clean flag must be set to true.

-

These bitmaps also have a hit region list, which is described in a later section. - Initially, this list is empty.

- -

Scratch bitmaps have a - list of pending interface actions, which can contain instructions to draw the user's - attention to a location on the bitmap, and instructions to scroll to a location on the bitmap. - Initially, this list is also empty.

- -

Scratch bitmaps also have an alpha flag, which can be set to true or false. Initially, when - one of these bitmaps is created, its alpha flag must be - set to true. When a scratch bitmap has its alpha flag set to false, then its alpha channel must be fixed - to 1.0 (fully opaque) for all pixels, and attempts to change the alpha component of any pixel must - be silently ignored.

- -

Thus, such a bitmap starts off as fully-opaque black instead of fully-transparent - black; clearRect() always results in fully-opaque - black pixels, every fourth byte from The CanvasRenderingContext2D object also has a hit region list, + which is described in a later section. Initially, this list is empty.

+ +

The CanvasRenderingContext2D object also has an alpha flag, which can be set to true or false. Initially, + when the context is created, its alpha flag must be + set to true. When a CanvasRenderingContext2D object has its alpha flag set to false, then its alpha channel must be + fixed to 1.0 (fully opaque) for all pixels, and attempts to change the alpha component of any + pixel must be silently ignored.

+ +

Thus, the bitmap of such a context starts off as fully-opaque black instead of + fully-transparent black; clearRect() always + results in fully-opaque black pixels, every fourth byte from getImageData() is always 255, the putImageData() method effectively ignores every fourth - byte in its input, and so on. However, the alpha component of styles and images drawn onto the - canvas are still honoured up to the point where they would impact the scratch + data-x="dom-context-2d-putImageData">putImageData() method effectively ignores every + fourth byte in its input, and so on. However, the alpha component of styles and images drawn + onto the canvas are still honoured up to the point where they would impact the output bitmap's alpha channel; for instance, drawing a 50% transparent white square on a freshly - created scratch bitmap with its alpha flag - set to false will result in a fully-opaque gray square.

+ created output bitmap with its alpha + flag set to false will result in a fully-opaque gray square.


@@ -60494,9 +60193,9 @@ interface Path2D { Cartesian surface whose origin (0,0) is at the top left corner, with the coordinate space having x values increasing when going right, and y values increasing when going down. The x-coordinate of the right-most edge is equal to - the width of the rendering context's scratch bitmap in CSS pixels; similarly, the + the width of the rendering context's output bitmap in CSS pixels; similarly, the y-coordinate of the bottom-most edge is equal to the height of the rendering - context's scratch bitmap in CSS pixels.

+ context's output bitmap in CSS pixels.

The size of the coordinate space does not necessarily represent the size of the actual bitmaps that the user agent will use internally or during rendering. On high-definition displays, for @@ -60508,7 +60207,8 @@ interface Path2D {


The 2D context creation algorithm, which is passed a target (a - canvas element) and optionally some arguments, consists of running the following steps:

+ canvas element) and optionally some arguments, consists of running the following + steps:

    @@ -60523,9 +60223,8 @@ interface Path2D {
  1. Initialise its canvas attribute to point to target.

  2. -
  3. Let the new CanvasRenderingContext2D object's output bitmap and - scratch bitmap both be the same bitmap as target's bitmap (so - that they are shared).

  4. +
  5. Let the new CanvasRenderingContext2D object's output bitmap be + the same bitmap as target's bitmap (so that they are shared).

  6. Set bitmap dimensions to the numeric values of target's width and @@ -60552,35 +60251,6 @@ interface Path2D {


    -

    The CanvasRenderingContext2D() constructor, when - invoked, must run the following steps:

    - -
      - -
    1. Create a new CanvasRenderingContext2D object.

    2. - -
    3. Initialise its canvas attribute to - null.

    4. - -
    5. Let the new CanvasRenderingContext2D object's scratch bitmap be - a new bitmap.

    6. - -
    7. If the constructor was called with arguments, let width and height be the first and second arguments, respectively. Otherwise, let width and height be 300 and 150, respectively.

    8. - -
    9. Set bitmap dimensions to width and height.

    10. - -
    11. Let the new CanvasRenderingContext2D object have no output - bitmap.

    12. - - - -
    13. Return the new CanvasRenderingContext2D object.

    14. - -
    -

    When a user agent is required to coerce context arguments for 2D, it must run the @@ -60604,111 +60274,6 @@ interface Path2D {


    -

    When the user agent is required to commit the scratch bitmap for a rendering - context, it must run the following steps: - -

      - -
    1. Let bitmap copy be a copy of the rendering context's scratch - bitmap.

    2. - - -
    3. Let origin-clean flag copy be a copy of the rendering context's - scratch bitmap's origin-clean - flag.

    4. - - -
    5. Let hit region list copy be a copy of the rendering context's - scratch bitmap's hit region list.

    6. - -
    7. Let list of pending interface actions copy be a copy of the rendering - context's scratch bitmap's list of pending interface actions.

    8. - -
    9. Empty the scratch bitmap's list of pending interface actions.

    10. - -
    11. If the rendering context has no output bitmap, abort these steps.

    12. - -
    13. Let output bitmap be the rendering context's output - bitmap.

    14. - -
    15. Let canvas be the canvas element to which the rendering - context was most recently bound.

    16. - -
    17. - -

      Queue a task associated with canvas' Document - to perform the following substeps:

      - -
        - -
      1. Overwrite output bitmap with bitmap - copy.

      2. - - -
      3. Overwrite output bitmap's origin-clean flag with origin-clean - flag copy.

      4. - - -
      5. Overwrite output bitmap's hit region list with hit region list copy.

      6. - -
      7. Follow the directions in the list of pending interface actions - copy.

      8. - -
      - -
    18. - -
    - -

    The algorithm above must use the canvas updating task source (which is just used by - this algorithm).

    - - - -

    The commit() method must run the - following steps:

    - -
      - -
    1. If the rendering context's context bitmap - mode is fixed, throw an - InvalidStateError exception and abort these steps.

    2. - -
    3. Commit the scratch bitmap for the rendering context.

    4. - -
    - -

    The scratch bitmap is only committed when the commit() method is - called. (This doesn't matter for canvas elements in direct-2d mode, since there the scratch - bitmap is also the canvas element's bitmap so every drawing operation is - immediately drawn.)

    - -
    -

    When the user agent is to set bitmap dimensions to width and height, it must run the following steps:

    @@ -60717,43 +60282,23 @@ interface Path2D {
  7. Reset the rendering context to its default state.

  8. -
  9. Clear the scratch bitmap's hit region list and its list of - pending interface actions.

  10. - -
  11. Resize the scratch bitmap to the new width and height and clear it to fully transparent black.

  12. +
  13. Clear the rendering context's hit region list.

  14. -
  15. If the rendering context has an output bitmap, and the scratch - bitmap is a different bitmap than the output bitmap, then resize the - output bitmap to the new width and height +

  16. Resize the output bitmap to the new width and height and clear it to fully transparent black.

  17. -
  18. - -

    If the rendering context's context bitmap - mode is fixed, then run these substeps:

    - -
      - -
    1. Let canvas be the canvas element to which the rendering - context's canvas attribute was initialised.

    2. - -
    3. If the rendering context's context - bitmap mode is fixed and the numeric value of - the canvas' width content attribute - differs from width, then set canvas' width content attribute to the shortest possible string - representing width as a valid non-negative integer.

    4. - -
    5. If the rendering context's context - bitmap mode is fixed and the numeric value of - the canvas' height content attribute - differs from height, then set canvas' height content attribute to the shortest possible string - representing height as a valid non-negative integer.

    6. +
    7. Let canvas be the canvas element to which the rendering + context's canvas attribute was initialised.

    8. -
    +
  19. If the numeric value of canvas's width + content attribute differs from width, then set canvas's width content attribute to the shortest possible string + representing width as a valid non-negative integer.

  20. - +
  21. If the numeric value of canvas's height + content attribute differs from height, then set canvas's height content attribute to the shortest possible string + representing height as a valid non-negative integer.

@@ -60777,14 +60322,14 @@ context.fillRect(100,0,50,50); // only this square remains
  • Reset the rendering context to its default state.

  • -
  • Clear the scratch bitmap's hit region list and its list of - pending interface actions.

  • +
  • Clear the CanvasRenderingContext2D object's hit region + list.

  • -
  • Clear the CanvasRenderingContext2D object's scratch bitmap to a +

  • Clear the CanvasRenderingContext2D object's output bitmap to a transparent black.

  • -
  • Set the CanvasRenderingContext2D object's scratch bitmap's

    Set the CanvasRenderingContext2D object's origin-clean flag to true.

  • @@ -60801,15 +60346,14 @@ context.fillRect(100,0,50,50); // only this square remains
  • Reset the rendering context to its default state.

  • -
  • Clear the scratch bitmap's hit region list and its list of - pending interface actions.

  • +
  • Clear the CanvasRenderingContext2D object's hit region + list.

  • -
  • Resize the CanvasRenderingContext2D object's scratch bitmap to - the dimensions of target's bitmap and clear it to fully transparent - black.

  • +
  • Resize the CanvasRenderingContext2D object's output bitmap to + the dimensions of target's bitmap and clear it to fully transparent black.

  • -
  • Set the CanvasRenderingContext2D object's scratch bitmap's

    Set the CanvasRenderingContext2D object's origin-clean flag to true.

  • @@ -60823,15 +60367,15 @@ context.fillRect(100,0,50,50); // only this square remains value it was initialised to when the object was created.

    The width attribute, on getting, must - return the width of the rendering context's scratch bitmap, in CSS pixels. On + return the width of the rendering context's output bitmap, in CSS pixels. On setting, it must set bitmap dimensions - to the new value and the current height of the rendering context's scratch bitmap in + to the new value and the current height of the rendering context's output bitmap in CSS pixels, respectively.

    The height attribute, on getting, must - return the height of the rendering context's scratch bitmap, in CSS pixels. On + return the height of the rendering context's output bitmap, in CSS pixels. On setting, it must set bitmap dimensions - to the current width of the rendering context's scratch bitmap in CSS pixels and the + to the current width of the rendering context's output bitmap in CSS pixels and the new value, respectively.


    @@ -60859,17 +60403,16 @@ context.fillRect(100,0,50,50); // only this square remains
    -
    If the rendering context's context bitmap - mode is fixed and the canvas - element is being rendered
    +
    If the canvas element is being rendered

    The "computed value of the 'color' property" for the purposes of determining the computed value of the currentColor keyword is the computed value of the 'color' property on the canvas element at the - time that the colour is specified (e.g. when the appropriate attribute is set, or when the method - is called; not when the colour is rendered or otherwise used).

    + time that the colour is specified (e.g. when the appropriate attribute is set, or when the + method is called; not when the colour is rendered or otherwise used).

    -
    In all other cases
    +
    If the canvas element is not being rendered

    The "computed value of the 'color' property" for the purposes of determining the computed value of the currentColor keyword is fully @@ -60944,19 +60487,12 @@ context.fillRect(100,0,50,50); // only this square remains -

    Although the way the specification is written it might sound like an implementation needs to - track up to four bitmaps per canvas or rendering context — one scratch bitmap, - one output bitmap for the rendering context, one bitmap for the canvas, - and one bitmap for the actually currently rendered image — user agents can in fact generally - optimise this to only one or two.

    - -

    The scratch bitmap, when it isn't the same bitmap as the output - bitmap, is only directly observable if it is read, and therefore implementations can, - instead of updating this bitmap, merely remember the sequence of drawing operations that have been - applied to it until such time as the bitmap's actual data is needed (for example because of a call - to commit(), drawImage(), or the createImageBitmap() - factory method). In many cases, this will be more memory efficient.

    +

    The output bitmap, when it is not directly displayed by the user agent, + implementations can, instead of updating this bitmap, merely remember the sequence of drawing + operations that have been applied to it until such time as the bitmap's actual data is needed + (for example because of a call to drawImage(), or + the createImageBitmap() factory method). In many + cases, this will be more memory efficient.

    The bitmap of a canvas element is the one bitmap that's pretty much always going to be needed in practice. The output bitmap of a rendering context, when it has one, @@ -60964,11 +60500,8 @@ context.fillRect(100,0,50,50); // only this square remains

    Additional bitmaps are sometimes needed, e.g. to enable fast drawing when the canvas is being painted at a different size than its intrinsic size, - or to enable double buffering so that the rendering commands from the scratch bitmap - can be applied without the rendering being updated midway.

    - - - + or to enable double buffering so that graphics updates, like page scrolling for example, can be + processed concurrently while canvas draw commands are being executed.

    The canvas state
    @@ -61574,13 +61107,11 @@ transform. ack Shaun Morris. -->

    Objects that implement the CanvasTextDrawingStyles interface have attributes (defined in this section) that control how text is laid out (rasterised or outlined) by the object. Such objects can also have a font style source object. For - CanvasRenderingContext2D objects whose context bitmap mode is fixed, this is their canvas element; for other - CanvasRenderingContext2D objects, if the object lives in a window, the object's - font style source object is the - Window object's newest Document object; otherwise the object - lives in a worker and the font style source object is the worker.

    + CanvasRenderingContext2D objects, this is the canvas element + referenced by the context's canvas property.

    + +

    The font IDL attribute, on setting, must be parsed as a CSS <'font'> value (but without supporting property-independent @@ -62928,8 +62459,9 @@ try {

    When a CanvasImageSource object represents an HTMLCanvasElement, the element's bitmap must be used as the source image.

    -

    When a CanvasImageSource object represents a CanvasRenderingContext2D, the - object's scratch bitmap must be used as the source image.

    +

    When a CanvasImageSource object represents a + CanvasRenderingContext2D, the object's output bitmap must be used as + the source image.

    When a CanvasImageSource object represents an element that is being rendered and that element has been resized, the original image data of the source image @@ -62947,7 +62479,7 @@ try { the same as the origin specified by the entry settings object, or if it is an HTMLCanvasElement whose bitmap's origin-clean flag is false, or if it is a - CanvasRenderingContext2D object whose scratch bitmap's CanvasRenderingContext2D object whose origin-clean flag is false.

    @@ -63024,9 +62556,9 @@ try { value. If the new value is a CanvasPattern object that is marked as not origin-clean, then the scratch - bitmap's origin-clean flag must be set to - false. + data-x="concept-canvas-pattern-not-origin-clean">not origin-clean, then the + CanvasRenderingContext2D's origin-clean flag must be set to false.

    @@ -63401,7 +62933,7 @@ try { previous image.

  • Clear regions that cover the pixels in pixels on the - scratch bitmap.

  • + output bitmap.

    @@ -63526,9 +63058,10 @@ try {
  • If the text preparation algorithm used a font that has an origin that is not the same as the origin specified by the entry settings object (even if "using a font" means just checking if that font - has a particular glyph in it before falling back to another font), then set the scratch - bitmap's origin-clean flag to - false.

  • @@ -64131,29 +63664,9 @@ v6DVT (also check for '- -' bits in the part above) --> -
  • - -

    Optionally, run the appropriate step from the following list:

    - -
    - -
    If the CanvasRenderingContext2D object's context bitmap mode is fixed
    - -

    Inform the user that the focus is at the location given by the - intended path. User agents may wait until the next time the event loop reaches its - update the rendering step to optionally inform the user.

    - -
    Otherwise
    - -

    Add instructions to the scratch bitmap's list of pending interface - actions that inform the user that the focus is at the location of - the bitmap given by the intended path.

    - -
    - -
  • +
  • Inform the user that the focus is at the location given by the + intended path. User agents may wait until the next time the event loop reaches its + update the rendering step to optionally inform the user.

  • @@ -64169,11 +63682,7 @@ v6DVT (also check for '- -' bits in the part above) -->

    The scrollPathIntoView() - method, when invoked, if the CanvasRenderingContext2D object's context bitmap mode is fixed, must run the following steps; and otherwise, must add - instructions to the scratch bitmap's list of pending interface actions - that run the following steps:

    + method, when invoked, must run the following steps:

      @@ -64188,11 +63697,8 @@ v6DVT (also check for '- -' bits in the part above) --> view with the align to top flag set.

    1. Optionally, inform the user that the caret or selection (or both) - cover the specified rectangle of the canvas. If the - CanvasRenderingContext2D object's context bitmap mode was fixed when the method was invoked, the user agent may wait - until the next time the event loop reaches its update the rendering step to + cover the specified rectangle of the canvas. The user agent may wait until the next + time the event loop reaches its update the rendering step to optionally inform the user.

    @@ -64262,7 +63768,7 @@ v6DVT (also check for '- -' bits in the part above) -->

    If not specified, the dw and dh arguments must default to the values of sw and sh, interpreted such that one CSS pixel in the image is treated as - one unit in the scratch bitmap's coordinate space. If the sx, + one unit in the output bitmap's coordinate space. If the sx, sy, sw, and sh arguments are omitted, they must default to 0, 0, the image's intrinsic width in image pixels, and the image's intrinsic height in image pixels, respectively. If the image has no intrinsic @@ -64270,7 +63776,7 @@ v6DVT (also check for '- -' bits in the part above) --> the CSS "Concrete Object Size Resolution" algorithm, with the specified size having neither a definite width nor height, nor any additional constraints, the object's intrinsic properties being those of the image - argument, and the default object size being the size of the scratch + argument, and the default object size being the size of the output bitmap.

    The source rectangle is the rectangle whose corners are the four points (sx, sy), (sx+sw, sy), (sx+sw, sy+sh), @@ -64283,9 +63789,9 @@ v6DVT (also check for '- -' bits in the part above) --> to the source image and the destination rectangle must be clipped in the same proportion.

    When the destination rectangle is outside the destination image (the - scratch bitmap), the pixels that land outside the scratch bitmap are + output bitmap), the pixels that land outside the output bitmap are discarded, as if the destination was an infinite canvas whose rendering was clipped to the - dimensions of the scratch bitmap.

    + dimensions of the output bitmap.

    @@ -64295,7 +63801,7 @@ v6DVT (also check for '- -' bits in the part above) -->
  • Paint the region of the image argument specified by the source rectangle - on the region of the rendering context's scratch bitmap specified by the + on the region of the rendering context's output bitmap specified by the destination rectangle, after applying the current transformation matrix to the destination rectangle.

    @@ -64319,7 +63825,7 @@ v6DVT (also check for '- -' bits in the part above) -->

    When a canvas or CanvasRenderingContext2D object is drawn onto itself, the drawing model requires the source to be copied before the - image is drawn, so it is possible to copy parts of a canvas or scratch + image is drawn, so it is possible to copy parts of a canvas or output bitmap onto overlapping parts of itself.

    If the original image data is a bitmap image, the value painted at a point in the destination @@ -64350,8 +63856,8 @@ v6DVT (also check for '- -' bits in the part above) -->

  • If the image argument is not origin-clean, set the - scratch bitmap's origin-clean flag - to false.

  • + CanvasRenderingContext2D's origin-clean flag to false.

    @@ -64660,8 +64166,7 @@ v6DVT (also check for '- -' bits in the part above) -->

    Adding a new region and calling clearRect() are the two ways this clearing algorithm can be invoked. The hit region list itself is also reset when the rendering context is - reset, e.g. when a CanvasRenderingContext2D object is bound to or unbound from a - canvas, or when the dimensions of the bitmap are changed.

    + reset, e.g. when the dimensions of the bitmap are changed.


    @@ -64748,9 +64253,9 @@ v6DVT (also check for '- -' bits in the part above) -->
  • If the arguments object's id member is not null, then let previous region for this ID be the region identified by the ID given by the id member's value in this scratch bitmap, if - any. If the id member is null or no such region - currently exists, let previous region for this ID be null.

  • + data-x="dom-HitRegionOptions-id">id member's value in this + CanvasRenderingContext2D, if any. If the id member is null or no such region currently exists, let previous region for this ID be null.

  • If the arguments object's parentID member is the empty string, let it be null @@ -64758,10 +64263,10 @@ v6DVT (also check for '- -' bits in the part above) -->

  • If the arguments object's parentID member is not null, then let parent region be the region identified by the ID given by the parentID member's value in the scratch - bitmap, if any. If the parentID member - is null or no such region currently exists, let parent region be - null.

  • + data-x="dom-HitRegionOptions-parentID">parentID member's value in the + CanvasRenderingContext2D, if any. If the parentID member is null or no such region + currently exists, let parent region be null.

  • If the arguments object's label member is the empty string, let it be null @@ -64928,19 +64433,20 @@ v6DVT (also check for '- -' bits in the part above) -->

  • If there is a previous region with this ID, remove it, and all hit regions for which it is an ancestor region, from the - scratch bitmap's hit region list; then, if it had a parent region, decrement that hit region's child count by - one.

  • + CanvasRenderingContext2D's hit region list; then, if it had a parent region, decrement that hit region's child + count by one.

  • If there is a parent region, increment its hit region's child count by one.

  • Clear regions that cover the pixels in region's set of pixels on this scratch - bitmap.

  • + data-x="hit region's set of pixels">set of pixels on this + CanvasRenderingContext2D.

    + -
  • Add region to the scratch bitmap's element's hit - region list.

  • +
  • Add region to the CanvasRenderingContext2D's hit region + list.

  • @@ -64952,27 +64458,27 @@ v6DVT (also check for '- -' bits in the part above) -->
  • Let region be the region identified by the ID given by the - method's argument in the rendering context's scratch bitmap. If no such region - currently exists, abort these steps.

    + method's argument in the CanvasRenderingContext2D's hit region list. + If no such region currently exists, abort these steps.

    If the method's argument is the empty string, then no region will match.

  • Remove region, and all hit regions for - which it is an ancestor region, from the rendering context's scratch - bitmap's hit region list; then, if it had a parent region, decrement that hit region's child count by - one.

  • + which it is an ancestor region, from the CanvasRenderingContext2D's + hit region list; then, if it had a parent + region, decrement that hit region's child count by one.

    + -
  • Garbage-collect the regions of the rendering context's scratch - bitmap.

  • +
  • Garbage-collect the regions of the + CanvasRenderingContext2D.

  • When the clearHitRegions() - method is invoked, the user agent must remove all the hit regions - from the rendering context's scratch bitmap's hit region list.

    + method is invoked, the user agent must remove all the hit + regions from the CanvasRenderingContext2D's hit region list.

    @@ -65373,19 +64879,20 @@ partial dictionary MouseEventInit { if either the sw or sh arguments are zero, throw an IndexSizeError exception; otherwise, - if the scratch bitmap's origin-clean - flag is set to false, it must throw a SecurityError exception; + if the CanvasRenderingContext2D's origin-clean flag is set to false, it must throw a + SecurityError exception; otherwise, it must create an ImageData object, with parameter pixelsPerRow set to sw, and parameter rows set to sh. Set the pixel values of the image data of the newly created ImageData object to - represent the scratch bitmap for the area of that bitmap denoted by the rectangle + represent the output bitmap for the area of that bitmap denoted by the rectangle whose corners are the four points (sx, sy), (sx+sw, sy), (sx+sw, sy+sh), (sx, sy+sh), in the bitmap's coordinate space units. - Pixels outside the scratch bitmap must be set to transparent black. Pixel values + Pixels outside the output bitmap must be set to transparent black. Pixel values must not be premultiplied by alpha.

    When the user agent is required to create an ImageData object, given @@ -65434,8 +64941,9 @@ partial dictionary MouseEventInit { component.

    The putImageData() method writes - data from ImageData structures back to the rendering context's scratch - bitmap. Its arguments are: imagedata, dx, dy, dirtyX, dirtyY, dirtyWidth, and dirtyHeight.

    + data from ImageData structures back to the rendering context's output + bitmap. Its arguments are: imagedata, dx, dy, + dirtyX, dirtyY, dirtyWidth, and dirtyHeight.

    When the last four arguments to this method are omitted, they must be assumed to have the values 0, 0, the width member of the imagedata structure, and the height @@ -65499,7 +65007,7 @@ partial dictionary MouseEventInit { the imagedata data structure's Canvas Pixel ArrayBuffer to the pixel with coordinate (dx+x, dy+y) - in the rendering context's scratch bitmap.

    + in the rendering context's output bitmap.

    @@ -65667,17 +65175,18 @@ function AddCloud(data, x, y) { ... }

    The globalAlpha attribute gives an - alpha value that is applied to shapes and images before they are composited onto the scratch - bitmap. The value must be in the range from 0.0 (fully transparent) to 1.0 (no additional - transparency). If an attempt is made to set the attribute to a value outside this range, including - Infinity and Not-a-Number (NaN) values, the attribute must retain its previous value. When the - context is created, the globalAlpha attribute must - initially have the value 1.0.

    + alpha value that is applied to shapes and images before they are composited onto the + output bitmap. The value must be in the range from 0.0 (fully transparent) to 1.0 + (no additional transparency). If an attempt is made to set the attribute to a value outside this + range, including Infinity and Not-a-Number (NaN) values, the attribute must retain its previous + value. When the context is created, the globalAlpha attribute must initially have the value + 1.0.

    The globalCompositeOperation attribute sets the current composition operator, which controls how shapes and images are drawn onto the - scratch bitmap, once they have had output bitmap, once they have had globalAlpha and the current transformation matrix applied. The possible values are those defined in the Compositing and Blending specification, and include the values

  • When shadows are drawn, multiply the alpha component of every pixel in B by globalAlpha.

  • When shadows are drawn, composite B within the - clipping region over the current scratch bitmap using the current + clipping region over the current output bitmap using the current composition operator.

  • Multiply the alpha component of every pixel in A by globalAlpha.

  • Composite A within the clipping region over the current - scratch bitmap using the current composition operator.

  • + output bitmap using the current composition operator.

    -

    When compositing onto the scratch bitmap, pixels that would fall outside of the - scratch bitmap must be discarded.

    +

    When compositing onto the output bitmap, pixels that would fall outside of the + output bitmap must be discarded.

    @@ -90802,21 +90311,21 @@ interface ImageBitmapFactories {
  • If either the sw or sh arguments are specified but zero, return a promise rejected with an IndexSizeError exception and abort these steps.

  • -
  • If the CanvasRenderingContext2D object's scratch bitmap has - either a horizontal dimension or a vertical dimension equal to zero, then return a promise rejected with an - InvalidStateError exception and abort these steps.

  • +
  • If the CanvasRenderingContext2D object's output bitmap has + either a horizontal dimension or a vertical dimension equal to zero, then return a promise + rejected with an InvalidStateError exception and abort these steps.

  • Create a new ImageBitmap object.

  • Let the ImageBitmap object's bitmap data be a copy of the - CanvasRenderingContext2D object's scratch bitmap, cropped to + CanvasRenderingContext2D object's output bitmap, cropped to the source rectangle with formatting.

  • Set the origin-clean flag of the ImageBitmap object's bitmap to the same value as the origin-clean flag of the - CanvasRenderingContext2D object's scratch bitmap

  • + CanvasRenderingContext2D object.

  • Return a new promise, but continue running these steps in parallel.

  • @@ -107704,8 +107213,8 @@ br[clear=all i], br[clear=both i] { clear: both; } described in the non-normative note to this effect in CSS2.1.

    The initial value for the 'color' property is expected to be black. The initial value for the - 'background-color' property is expected to be 'transparent'. The canvas' background is expected to - be white.

    + 'background-color' property is expected to be 'transparent'. The canvas's background is expected + to be white.