diff --git a/source b/source index 941d6a09993..b66f55a31b7 100644 --- a/source +++ b/source @@ -4371,6 +4371,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • SVG title element
  • SVG use element
  • SVG text-rendering property
  • +
  • core attribute
  • +
  • presentation attribute
  • @@ -4382,6 +4384,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute @@ -63555,8 +63560,9 @@ callback BlobCallback = undefined (Blob? blob);
    Uses HTMLCanvasElement.
    -

    The canvas element provides scripts with a resolution-dependent bitmap canvas, - which can be used for rendering graphs, game graphics, art, or other visual images on the fly.

    +

    The canvas element provides scripts with a resolution-dependent bitmap canvas, which can be used for rendering graphs, game graphics, + art, or other visual images on the fly.

    Authors should not use the canvas element in a document when a more suitable element is available. For example, it is inappropriate to use a canvas element to @@ -63566,23 +63572,25 @@ callback BlobCallback = undefined (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'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.

    + 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.


    In interactive visual media, if scripting is enabled for the canvas element, and if support for canvas elements has been enabled, then the canvas element represents embedded content - consisting of a dynamically created image, the element's bitmap.

    + consisting of a dynamically created image, the element's + bitmap.

    In non-interactive, static, visual media, if the canvas element has been previously associated with a rendering context (e.g. if the page was viewed in an interactive visual medium and is now being printed, or if some script that ran during the page layout process painted on the element), then the canvas element represents - embedded content with the element's current bitmap and size. Otherwise, the element - represents its fallback content instead.

    + embedded content with the element's current + bitmap and size. Otherwise, the element represents its fallback content + instead.

    In non-visual media, and in visual media if scripting is disabled for the canvas element or if support for canvas elements @@ -63605,16 +63613,16 @@ callback BlobCallback = undefined (Blob? blob);


    -

    The canvas element has two attributes to control the size of the element's bitmap: - width and height. These attributes, - when specified, must have values that are valid - non-negative integers. The rules for parsing non-negative - integers must be used to obtain their numeric - values. If an attribute is missing, or if parsing its value returns an error, then the - default value must be used instead. The width - attribute defaults to 300, and the height attribute - defaults to 150.

    +

    The canvas element has two attributes to control the size of the element's bitmap: width and height. These attributes, when specified, must have + values that are valid non-negative integers. + The rules for parsing non-negative integers must be used to obtain their numeric values. If an attribute is missing, or + if parsing its value returns an error, then the default value must be used instead. The + width attribute defaults to 300, and the height attribute defaults to 150.

    When setting the value of the width or height attribute, if the BlobCallback = undefined (Blob? blob);

    The natural dimensions of the canvas element when it represents embedded content are equal to the dimensions of the - element's bitmap.

    + element's bitmap.

    The user agent must use a square pixel density consisting of one pixel of image data per - coordinate space unit for the bitmaps of a canvas and its rendering contexts.

    + coordinate space unit for the bitmaps of a canvas + and its rendering contexts.

    A canvas element can be sized arbitrarily by a style sheet, its - bitmap is then subject to the 'object-fit' CSS property.

    + bitmap is then subject to the 'object-fit' CSS + property.


    -

    The bitmaps of canvas elements, the bitmaps of ImageBitmap objects, - as well as some of the bitmaps of rendering contexts, such as those described in the sections on - the CanvasRenderingContext2D and ImageBitmapRenderingContext objects - below, have an origin-clean flag, which can be - set to true or false. Initially, when the canvas element or ImageBitmap +

    The bitmaps of canvas elements, the bitmaps of + ImageBitmap objects, as well as some of the bitmaps of rendering contexts, such as + those described in the sections on the CanvasRenderingContext2D and + ImageBitmapRenderingContext objects below, have an origin-clean flag, which can be set to true or false. + Initially, when the canvas element or ImageBitmap object is created, its bitmap's origin-clean flag must be set to true.

    @@ -63659,13 +63670,13 @@ callback BlobCallback = undefined (Blob? blob);

    When its canvas context mode is none, a canvas element has no rendering context, - and its bitmap must be transparent black with a natural width equal - to the numeric value of the element's width attribute and a natural height equal to - the numeric value of the element's height attribute, those values being interpreted in CSS pixels, and being updated as the attributes are set, changed, or - removed.

    + and its bitmap must be transparent black with a + natural width equal to the numeric value + of the element's width attribute and a natural + height equal to the numeric value of the + element's height attribute, those values being + interpreted in CSS pixels, and being updated as the attributes are set, + changed, or removed.

    When its canvas context mode is placeholder, a canvas element has no @@ -63676,7 +63687,8 @@ callback BlobCallback = undefined (Blob? blob);

    When a canvas element represents embedded content, it provides a paint source whose width is the element's natural width, whose height - is the element's natural height, and whose appearance is the element's bitmap.

    + is the element's natural height, and whose appearance is the element's bitmap.

    Whenever the width and height content attributes are set, removed, changed, or @@ -63982,13 +63994,17 @@ callback BlobCallback = undefined (Blob? blob); when invoked, must run these steps:

      -
    1. If this canvas element's bitmap's

      If the rendering context associated with this canvas element has a layer count different than zero, then throw an + "InvalidStateError" DOMException.

      + +
    2. If this canvas element's bitmap's origin-clean flag is set to false, then throw a "SecurityError" DOMException.

      -
    3. If this canvas element's bitmap has no pixels (i.e. either its horizontal - dimension or its vertical dimension is zero) then return the string "data:,". (This is the shortest canvas element's bitmap has no + pixels (i.e. either its horizontal dimension or its vertical dimension is zero) then return the + string "data:,". (This is the shortest data: URL; it represents the empty string in a text/plain resource.)

    4. @@ -64010,15 +64026,20 @@ callback BlobCallback = undefined (Blob? blob); quality) method, when invoked, must run these steps:

        -
      1. If this canvas element's bitmap's

        If the rendering context associated with this canvas element has a layer count different than zero, then throw an + "InvalidStateError" DOMException.

        + +
      2. If this canvas element's bitmap's origin-clean flag is set to false, then throw a "SecurityError" DOMException.

      3. Let result be null.

      4. -
      5. If this canvas element's bitmap has pixels (i.e., neither its horizontal - dimension nor its vertical dimension is zero), then set result to a copy of this - canvas element's bitmap. +

      6. If this canvas element's bitmap has + pixels (i.e., neither its horizontal dimension nor its vertical dimension is zero), then set + result to a copy of this canvas element's + bitmap.

      7. Run these steps in parallel:

        @@ -64109,6 +64130,7 @@ interface CanvasRenderingContext2D { CanvasRenderingContext2DSettings getContextAttributes(); }; CanvasRenderingContext2D includes CanvasState; +CanvasRenderingContext2D includes CanvasLayers; CanvasRenderingContext2D includes CanvasTransform; CanvasRenderingContext2D includes CanvasCompositing; CanvasRenderingContext2D includes CanvasImageSmoothing; @@ -64133,6 +64155,12 @@ interface mixin CanvasState { boolean isContextLost(); // return whether context is lost }; +interface mixin CanvasLayers { + // layers + undefined beginLayer(); + undefined endLayer(); +}; + interface mixin CanvasTransform { // transformations (default transform is the identity matrix) undefined scale(unrestricted double x, unrestricted double y); @@ -64418,12 +64446,26 @@ interface Path2D {
        -

        A CanvasRenderingContext2D object has an output bitmap that - is initialized when the object is created.

        +

        A CanvasRenderingContext2D object has a top level output bitmap and a + current output bitmap which both originally refer to the same output bitmap + that is initialized when the CanvasRenderingContext2D is created. The + top level output bitmap is an alias for the canvas element's bitmap and is the bitmap that gets + presented to the user in the update the + rendering step of the event loop. The current output bitmap is + the bitmap to which most CanvasRenderingContext2D operations are drawing.

        + +

        The CanvasRenderingContext2D's current output bitmap can be replaced + and restored by calls to beginLayer() and endLayer(), with the drawing state stack + keeping track of all active nested output bitmaps. The + CanvasRenderingContext2D object has a layer count integer that is initially set to zero, + keeping track of the number of opened nested layers.

        -

        The output bitmap has an The output bitmap objects have 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.

        The CanvasRenderingContext2D object also has an Path2D { always results in 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 output - bitmap's alpha channel; for instance, drawing a 50% transparent white square on a freshly - created output bitmap with its alpha set - to false will result in a fully-opaque gray square.

        + fourth byte in its input, and so on. However, the alpha component of styles, images, and layers + drawn onto the canvas are still honored up to the point where they would impact the top + level output bitmap's alpha channel; for instance, drawing a 50% transparent white square + on a freshly created top level output bitmap with its alpha set to false will result in a fully-opaque gray + square.

        The CanvasRenderingContext2D object also has a desynchronized boolean. When a @@ -64473,9 +64516,9 @@ interface Path2D { may optimize the canvas for readback operations.

        On most devices the user agent needs to decide whether to store the canvas's - output bitmap on the GPU (this is also called "hardware accelerated"), or on the CPU - (also called "software"). Most rendering operations are more performant for accelerated canvases, - with the major exception being readback with output bitmaps on the GPU (this is also called "hardware + accelerated"), or on the CPU (also called "software"). Most rendering operations are more + performant for accelerated canvases, with the major exception being readback with getImageData(), toDataURL(), or toBlob(). CanvasRenderingContext2D objects with @@ -64487,7 +64530,7 @@ interface Path2D { data-x="concept-canvas-color-space">color space setting of type PredefinedColorSpace. The CanvasRenderingContext2D object's color space indicates the color space for the - output bitmap.

        + context's output bitmaps.

        The getContextAttributes() method @@ -64507,9 +64550,10 @@ 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 output bitmap in CSS pixels; similarly, the - y-coordinate of the bottom-most edge is equal to the height of the rendering context's - output bitmap in CSS pixels.

        + context's top level output bitmap in CSS pixels; + similarly, the y-coordinate of the bottom-most edge is equal to the height of the + rendering context's top level 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 @@ -64520,13 +64564,13 @@ interface Path2D {

        Using CSS pixels to describe the size of a rendering context's - output bitmap does not mean that when rendered the canvas will cover an equivalent - area in CSS pixels. CSS pixels are reused - for ease of integration with CSS features, such as text layout.

        + top level output bitmap does not mean that when rendered the canvas will cover an + equivalent area in CSS pixels. CSS pixels + are reused for ease of integration with CSS features, such as text layout.

        In other words, the canvas element below's rendering context has a 200x200 - output bitmap (which internally uses CSS pixels as a - unit for ease of integration with CSS) and is rendered as 100x100 CSS + top level output bitmap (which internally uses CSS pixels + as a unit for ease of integration with CSS) and is rendered as 100x100 CSS pixels:

        <canvas width=200 height=200 style=width:100px;height:100px>
        @@ -64547,8 +64591,9 @@ interface Path2D {
      8. Initialize context's canvas attribute to point to target.

      9. -
      10. Set context's output bitmap to the same bitmap as - target's bitmap (so that they are shared).

      11. +
      12. Set context's top level output bitmap and current output + bitmap to the same bitmap as target's + bitmap (so that they are shared).

      13. Set bitmap dimensions to the numeric values of target's Path2D {

        1. Reset the rendering context to its default state.

        2. -
        3. Resize the output bitmap to the new width and +

        4. Resize the top level output bitmap to the new width and height.

        5. Let canvas be the canvas element to which the rendering @@ -64696,16 +64741,23 @@ context.fillRect(100,0,50,50); // only this square remains -

          The output bitmap, when it is not directly displayed by the user agent, +

          The top level 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, - is always just an alias to a canvas element's bitmap.

          +

          The bitmap of a canvas element is the one + bitmap that's pretty much always going to be needed in practice. The top level output + bitmap of a rendering context, when it has one, is always just an alias to a + canvas element's bitmap. When layers are opened, + draw calls operate on a separate current output bitmap that gets composited to the + parent output bitmap when the layer is closed. If the canvas element's bitmap needs to be presented to the user while layers are opened, the + top level output bitmap is used, meaning that the content of unclosed layers will not + be presented. They will be presented in a later frame, if and when the layers are closed.

          Additional bitmaps are sometimes needed, e.g. to enable fast drawing when the canvas is being painted at a different size than its natural size, @@ -64714,11 +64766,13 @@ context.fillRect(100,0,50,50); // only this square remains

          The canvas state
          -

          Objects that implement the CanvasState interface maintain a stack of drawing - states. Drawing states consist of:

          +

          Objects that implement the CanvasState interface maintain a stack of drawing states. Drawing states consist of:

            -
          • The current transformation matrix.
          • +
          • The current transformation matrix and parents transformation + matrix.
          • The current clipping region.
          • The current letter spacing, word @@ -64748,10 +64802,13 @@ context.fillRect(100,0,50,50); // only this square remains data-x="dom-context-2d-imageSmoothingEnabled">imageSmoothingEnabled, imageSmoothingQuality.
          • The current dash list.
          • +
          • An optional canvas layer state, defaults to null if not specified.
          -

          The rendering context's bitmaps are not part of the drawing state, as they - depend on whether and how the rendering context is bound to a canvas element.

          +

          The rendering context's bitmaps are not part of the drawing state + (with the exception of layer's parent output bitmap held in the canvas layer + state), as they depend on whether and how the rendering context is bound to a + canvas element.

          Objects that implement the CanvasState mixin have a context lost boolean, that is initialized to false @@ -64760,14 +64817,15 @@ context.fillRect(100,0,50,50); // only this square remains

          context.save()
          -

          Pushes the current state onto the stack.

          +

          Pushes the current state onto the stack.

          context.restore()
          -

          Pops the top state on the stack, restoring the context to that state.

          +

          Pops the top state on the stack, restoring the context to + that state.

          context.reset()
          -

          Resets the rendering context, which includes the backing buffer, the drawing state stack, - path, and styles.

          +

          Resets the rendering context, which includes the backing buffer, the drawing state + stack, path, and styles.

          context.isContextLost()

          Returns true if the rendering context was lost. Context loss can occur due to driver @@ -64778,11 +64836,26 @@ context.fillRect(100,0,50,50); // only this square remains

          The save() method - steps are to push a copy of the current drawing state onto the drawing state stack.

          + steps are to push a copy of the current drawing state onto this's + drawing state stack.

          The restore() - method steps are to pop the top entry in the drawing state stack, and reset the drawing state it - describes. If there is no saved state, then the method must do nothing.

          + method steps are:

          + +
            +
          1. If this's drawing state stack is + empty, then return.

          2. + +
          3. If this's drawing state stack's last item's canvas layer + state is not null, then throw an "InvalidStateError" + DOMException.

          4. + +
          5. Let previousDrawingStates be the result of popping the drawing state stack.

          6. + +
          7. Set all of this's current drawing states + to the values they have in previousDrawingStates.

          8. +

          The reset() method steps are to reset the rendering context to its default state.

          @@ -64790,11 +64863,20 @@ context.fillRect(100,0,50,50); // only this square remains

          To reset the rendering context to its default state:

            -
          1. Clear canvas's bitmap to transparent black.

          2. +
          3. Clear this's drawing state stack.

          4. -
          5. Empty the list of subpaths in context's current default path.

          6. +
          7. Set this's current output bitmap to be a reference to + this's top level output bitmap.

          8. + +
          9. Clear the top level output bitmap to transparent black.

          10. -
          11. Clear the context's drawing state stack.

          12. +
          13. Set this's top level output bitmap's origin-clean flag to true.

          14. + +
          15. Set this's layer count to + zero.

          16. + +
          17. Empty the list of subpaths in context's current default path.

          18. Reset everything that drawing state consists of to their initial values.

          19. @@ -64806,6 +64888,185 @@ context.fillRect(100,0,50,50); // only this square remains
          +
          Layers
          + +

          Objects that implement the CanvasLayers mixin have methods (defined in this + section) for managing a stack of output bitmaps.

          + +

          Layers are opened and closed using beginLayer() + and endLayer(). When a layer is opened, the context's + current output bitmap is aliased to that layer's output bitmap, such + that all draw calls performed while the layer is active will effectively render onto the layer's + output bitmap. When endLayer() is + called, the layer's output bitmap gets composited in the parent's output + bitmap using the layer rendering states.

          + +
          + +

          The drawing state stack keeps track of opened layers by holding canvas layer + state structs containing the following item:

          + +
            +
          • parent output bitmap, the layer's parent output bitmap.
          • +
          + +
          + +

          The layer rendering states are the subset of the drawing states that are applied to a layer's + output bitmap when it's drawn to its parent output bitmap. The + layer rendering states are:

          +
            +
          • The current transformation matrix.
          • + +
          • The current clipping region.
          • + +
          • The current filter, global alpha, and compositing and blending operator.
          • + +
          • The current values of the following attributes: + shadowOffsetX, + shadowOffsetY, + shadowBlur, + shadowColor
          • +
          + +
          +

          Because the layer rendering states are applied on the layer's output, + they cannot also be applied to the layer's content, or else, they would be applied twice. These + states are therefore set to their default value when opening a layer.

          + +

          The current transformation matrix can conceptually be considered as applying + to the layer's output, as if the layer's output bitmap was transformed by the + parent's current transformation matrix and then drawn to the parent's output + bitmap when the layer is closed. In practice however, the current transformation + matrix doesn't need to be applied on the layer's output since shapes and images are always + drawn using the total transformation matrix, in particular those drawn using the + current default path, which is always pre-transformed.

          + +

          imageSmoothingEnabled is not part + of the layer rendering states because layers's output + bitmaps are not resampled when drawn to their parent output bitmap. If they + were resampled, the picture quality would lower for every nested layer subject to a non-identity + transform. Instead, pixels are drawn in layers at the exact coordinates they'll have in the + top level output bitmap, thus making sure that layers's pixels have a one-to-one + correspondance with their parent's.

          +
          + +
          +
          context.beginLayer()
          +

          Pushes the current state onto the stack and starts a new layer. While a layer is active, + all draw calls are performed on a separate surface, which will later be drawn as a whole to the + canvas (or parent layer) when the layer is closed.

          + +
          context.endLayer()
          +

          Pops the top state off the stack, restores the context to that state and draws the layer's + resulting texture to the parent surface (the canvas or the parent layer) using the global + rendering states as they were when beginLayer() + was called.

          +
          + +
          + +

          The beginLayer(options) method steps + are:

          +
            +
          1. Let currentOutputBitmap be this's + current output bitmap.

          2. + +
          3. Let layerOutputBitmap be a newly created output bitmap, + initialized with an origin-clean flag set to + true.

          4. + +
          5. Let layerState be a new canvas layer state object, initialized + with parent output bitmap set to currentOutputBitmap.

          6. + +
          7. Push a copy of the current drawing state + onto this's drawing state stack.

          8. + +
          9. Reset this's layer rendering states to their default + value.

          10. + +
          11. Set this's drawing state stack's last item's canvas layer + state to layerState.

          12. + +
          13. Set this's current output bitmap to + layerOutputBitmap.

          14. + +
          15. Set this's parents transformation matrix to total transformation + matrix.

          16. + +
          17. Increment this's layer count + by one.

          18. +
          + +

          The endLayer() method steps are:

          +
            +
          1. If this's drawing state stack is + empty, then throw an "InvalidStateError" + DOMException.

          2. + +
          3. Let layerState be this's drawing state stack's last + item's canvas layer state.

          4. + +
          5. If layerState is null, throw an "InvalidStateError" + DOMException.

          6. + +
          7. Let layerOutputBitmap be this's current output + bitmap.

          8. + +
          9. Let parentOutputBitmap be + layerState's parent output bitmap.

          10. + +
          11. If layerOutputBitmap is marked as not origin-clean, then set the origin-clean flag of parentOutputBitmap + to false.

          12. + +
          13. Set this's current output bitmap to + parentOutputBitmap.

          14. + +
          15. Let parentDrawingStates be the result of popping this's drawing state stack.

          16. + +
          17. Set all of this's current drawing states + to the values they have in parentDrawingStates.

          18. + +
          19. Draw layerOutputBitmap onto this's current output + bitmap using the steps outlined in the drawing model.

          20. + +
          21. Decrement this's layer count + by one.

          22. +
          + +
          + +
          +

          As described in the drawing model, shapes and images are subjected to the + total transformation matrix and are therefore written to layers at the final pixel + position they'll have in the top level output bitmap. Thus, when layers are closed, + pixels from the layer's output bitmap have a one to one correspondence with the + pixels in the parent's output bitmap and can therefore be directly drawn to the + parent without further transforms or resampling.

          + +

          For legacy reasons, calling restore() when the + drawing state stack is empty is a no-op. The addition of the layer API however + introduced several new potential pitfalls. For instance, scripts like context.save(); context.endLayer(); or context.beginLayer(); + context.restore(); are problematic. They are symptomatic of web page bugs and user agents + cannot silently fix these bugs on behalf of the page (e.g. did the page intend to call + endLayer() instead of restore(), or is there a missing save()?) For that reason, invalid API sequences involving + layers throw exceptions to make the issue clear to web developers.

          +
          +
          Line styles
          @@ -66386,9 +66647,8 @@ try {

          For objects implementing the CanvasDrawPath and CanvasTransform interfaces, the points passed to the methods, and the resulting lines added to current - default path by these methods, must be transformed according to the current transformation matrix before being added to - the path.

          + default path by these methods, must be transformed according to the total + transformation matrix before being added to the path.

          The moveTo(x, y) method, when invoked, must run these steps:

          @@ -66488,9 +66748,8 @@ try { DOMException.

        6. Let the point (x0, y0) be the last point in the subpath, transformed - by the inverse of the current transformation - matrix (so that it is in the same coordinate system as the points passed to the - method).

        7. + by the inverse of the total transformation matrix (so that it is in the same + coordinate system as the points passed to the method).

        8. If the point (x0, y0) is equal to the point (x1, y1), or if the point (x1, y1) is equal to the point @@ -66864,14 +67123,26 @@ try {

    -
    Transformations
    +
    Transformations

    Objects that implement the CanvasTransform interface have a current - transformation matrix, as well as methods (described in this section) to manipulate it. When - an object implementing the CanvasTransform interface is created, its transformation - matrix must be initialized to the identity matrix.

    - -

    The current transformation matrix is applied to coordinates when creating the + transformation matrix, a parents transformation matrix and a total + transformation matrix, as well as methods (described in this section) to manipulate the + current transformation matrix. The current transformation matrix + corresponds to the transformation local to the current layer. The parents transformation + matrix is the multiplication of the transforms of all the ancestors of the current layer. + The total transformation matrix encompases all transforms mapping drawn shapes and + images to the top level output bitmap and is always equals to the results of + multiplying the parents transformation matrix with the current transformation + matrix.

    + +

    When an object implementing the CanvasTransform interface is created, its + current transformation matrix and parents transformation matrix must be + initialized to the identity matrix. For objects not implementing the CanvasLayers + interface, the parents transformation matrix is always equal to the identity + matrix.

    + +

    The total transformation matrix is applied to coordinates when creating the current default path, and when painting text, shapes, and Path2D objects, on objects implementing the CanvasTransform interface.

    @@ -66990,7 +67261,7 @@ try {
  • If any of the arguments are infinite or NaN, then return.

  • Replace the current transformation matrix with the result of multiplying the - current transformation matrix with the matrix described by:

  • + current transformation matrix with the matrix described by:

    @@ -67160,9 +67431,15 @@ try {
    HTMLCanvasElement
    OffscreenCanvas
    -

    If image has either a horizontal dimension or a vertical dimension - equal to zero, then throw an "InvalidStateError" - DOMException.

    +
    +

    If the rendering context associated with image has a layer count different than zero, then throw an + "InvalidStateError" DOMException.

    + +

    If image has either a horizontal dimension or a vertical dimension + equal to zero, then throw an "InvalidStateError" + DOMException.

    +
    ImageBitmap
    VideoFrame
    @@ -67195,7 +67472,7 @@ try { (i.e., after any aspect-ratio correction has been applied).

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

    + element's 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 @@ -67332,8 +67609,8 @@ try {

  • If the given value is a CanvasPattern object that is marked as not origin-clean, then set - this's origin-clean flag to - false.

  • + this's current output bitmap's origin-clean flag to false.

  • Set this's fill style to the given value.

  • @@ -67374,8 +67651,8 @@ try {
  • If the given value is a CanvasPattern object that is marked as not origin-clean, then set - this's origin-clean flag to - false.

  • + this's current output bitmap's origin-clean flag to false.

  • Set this's stroke style to the given value.

  • @@ -67496,8 +67773,8 @@ try {

    Linear gradients must be rendered such that all points on a line perpendicular to the line that crosses the start and end points have the color at the point where those two lines cross (with the colors coming from the interpolation and extrapolation described - above). The points in the linear gradient must be transformed as described by the current transformation matrix when rendering.

    + above). The points in the linear gradient must be transformed as described by the total + transformation matrix when rendering.

    If x0 = x1 and y0 = y1, then the linear @@ -67543,8 +67820,8 @@ try { of the first offset, the part of the cone after the end circle (1.0) using the color of the last offset, and areas outside the cone untouched by the gradient (transparent black).

    -

    The resulting radial gradient must then be transformed as described by the current transformation matrix when rendering.

    +

    The resulting radial gradient must then be transformed as described by the total + transformation matrix when rendering.

    The createConicGradient(startAngle, @@ -67686,8 +67963,8 @@ try {

  • Transform the resulting bitmap according to the pattern's transformation matrix.

  • -
  • Transform the resulting bitmap again, this time according to the current transformation matrix.

  • +
  • Transform the resulting bitmap again, this time according to the total + transformation matrix.

  • Replace any part of the image outside the area in which the pattern is to be rendered with transparent black.

  • @@ -67711,16 +67988,19 @@ try {
    Drawing rectangles to the bitmap

    Objects that implement the CanvasRect interface provide the following methods for - immediately drawing rectangles to the bitmap. The methods each take four arguments; the first two - give the x and y coordinates of the top left of the rectangle, and the - second two give the width w and height h of the rectangle, respectively.

    + immediately drawing rectangles to the current output bitmap. The methods each take + four arguments; the first two give the x and y coordinates of the top left + of the rectangle, and the second two give the width w and height h of the + rectangle, respectively.

    -

    The current transformation matrix must be - applied to the following four coordinates, which form the path that must then be closed to get the - specified rectangle: (x, y), (x+w, y), (x+w, y+h), (x, y+h).

    +

    The total transformation matrix must be applied to the following four + coordinates, which form the path that must then be closed to get the specified rectangle: (x, y), (x+w, + y), (x+w, + y+h), (x, + y+h).

    Shapes are painted without affecting the current default path, and are subject to the clipping region, and, with the exception of

    context.clearRect(x, y, w, h)
    -

    Clears all pixels on the bitmap in the given rectangle to transparent - black.

    +

    Clears all pixels on the current output bitmap in the given rectangle to + transparent black.

    context.fillRect(x, y, w, h)
    -

    Paints the given rectangle onto the bitmap, using the current fill style.

    +

    Paints the given rectangle onto the current output bitmap, using the current + fill style.

    context.strokeRect(x, y, w, h)
    -

    Paints the box that outlines the given rectangle onto the bitmap, using the current stroke - style.

    +

    Paints the box that outlines the given rectangle onto the current output bitmap, + using the current stroke style.

    @@ -67875,10 +68156,9 @@ try { pixels.

  • -

    Paint the shapes given in glyphs, as transformed by the current transformation matrix, with each CSS pixel in the coordinate space of glyphs mapped to one - coordinate space unit.

    +

    Paint the shapes given in glyphs, as transformed by the total + transformation matrix, with each CSS pixel in the coordinate + space of glyphs mapped to one coordinate space unit.

    For fillText(), this's fill style must be applied to the @@ -68110,13 +68390,12 @@ try { Path2D object, or the current default path otherwise.

    When the intended path is a Path2D object, the coordinates and lines - of its subpaths must be transformed according to the current transformation matrix on the object - implementing the CanvasTransform interface when used by these methods (without - affecting the Path2D object itself). When the intended path is the current - default path, it is not affected by the transform. (This is because transformations - already affect the current default path when it is constructed, so applying it when - it is painted as well would result in a double transformation.)

    + of its subpaths must be transformed according to the total transformation matrix on + the object implementing the CanvasTransform interface when used by these methods + (without affecting the Path2D object itself). When the intended path is the + current default path, it is not affected by the transform. (This is because + transformations already affect the current default path when it is constructed, so + applying it when it is painted as well would result in a double transformation.)

    The fill(fillRule) method steps are to run the @@ -68216,7 +68495,7 @@ try {

  • If x or y are infinite or NaN, then return false.

  • If the point given by the x and y coordinates, when treated as - coordinates in the canvas coordinate space unaffected by the current transformation, is inside + coordinates in the canvas coordinate space unaffected by transformations, is inside the intended path for path as determined by the fill rule indicated by fillRule, then return true. Open subpaths must be implicitly closed when computing the area inside the path, without affecting the actual subpaths. Points on the path @@ -68245,7 +68524,7 @@ try {

  • If x or y are infinite or NaN, then return false.

  • If the point given by the x and y coordinates, when treated as - coordinates in the canvas coordinate space unaffected by the current transformation, is inside + coordinates in the canvas coordinate space unaffected by transformations, is inside the path that results from tracing the intended path for path, using the nonzero winding rule, and using @@ -68392,7 +68671,8 @@ try { data-x="concept-CanvasFillStrokeStyles-stroke-style">stroke style, or any of the members in the CanvasPathDrawingStyles, CanvasTextDrawingStyles interfaces, but should be subject to the clipping region. (The effect of - transformations is described above and varies based on which path is being used.)

    + transformations is described above and varies based on which path is being + used.)

  • Inform the user that the focus is at the location given by the @@ -68495,16 +68775,16 @@ try {

    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 output bitmap's coordinate space. If the - sx, sy, sw, and sh arguments are omitted, then they - must default to 0, 0, the image's natural width in image pixels, and the image's - natural height in image pixels, respectively. If the image has no natural - dimensions, then the concrete object size must be used instead, as determined - using 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 natural properties being those of the - image argument, and the default object size being the size of the - output bitmap. CSSIMAGES

    + in the image is treated as one unit in the current output bitmap's coordinate + space. If the sx, sy, sw, and sh arguments are + omitted, then they must default to 0, 0, the image's natural width in image pixels, + and the image's natural height in image pixels, respectively. If the image has no + natural dimensions, then the concrete object size must be used instead, as + determined using 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 natural properties being those of + the image argument, and the default object size being the size of the + current output bitmap. CSSIMAGES

    The source rectangle is the rectangle whose corners are the four points (sx, sy), (sx+sw, sy), (sx+sw, sy+sh), (sx, sy+sh).

    @@ -68516,9 +68796,9 @@ try { 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 - 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 output bitmap.

    + current output bitmap), the pixels that land outside the current output + bitmap are discarded, as if the destination was an infinite canvas whose rendering was + clipped to the dimensions of the current output bitmap.

  • If one of the sw or sh arguments is zero, then return. Nothing is @@ -68526,9 +68806,9 @@ try {

  • Paint the region of the image argument specified by the source rectangle - 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.

    + on the region of the rendering context's current output bitmap specified by the + destination rectangle, after applying the total transformation matrix to the + destination rectangle.

    The image data must be processed in the original direction, even if the dimensions given are negative.

    The global alpha value gives an alpha value - that is applied to shapes and images before they are composited onto the output bitmap. - The value ranges from 0.0 (fully transparent) to 1.0 (no additional transparency). It must - initially have the value 1.0.

    + that is applied to shapes and images before they are composited onto the current output + bitmap. The value ranges from 0.0 (fully transparent) to 1.0 (no additional transparency). + It must initially have the value 1.0.

    The globalAlpha getter steps are to return @@ -69157,8 +69446,8 @@ console.log(pixels.data[2]);

    The current compositing and blending operator value controls how shapes and images - are drawn onto the output bitmap, once they have had the global alpha and the current transformation + are drawn onto the current output bitmap, once they have had the global alpha and the total transformation matrix applied. Initially, it must be set to "source-over".

    @@ -69284,7 +69573,9 @@ console.log(pixels.data[2]); for="CanvasShadowStyles">shadowOffsetY attributes specify the distance that the shadow will be offset in the positive horizontal and positive vertical distance respectively. Their values are in coordinate space units. They are not - affected by the current transformation matrix.

    + affected by the current transformation matrix but are affected by the parents + transformation matrix (for objects implementing the CanvasLayers + interface), as described in the drawing model.

    When the context is created, the shadow offset attributes must initially have the value 0.

    @@ -69295,8 +69586,10 @@ console.log(pixels.data[2]);

    The shadowBlur attribute specifies the level of the - blurring effect. (The units do not map to coordinate space units, and are not affected by the - current transformation matrix.)

    + blurring effect. The units do not map to coordinate space units. They are not affected by the + current transformation matrix but are affected by the parents transformation + matrix (for objects implementing the CanvasLayers interface), as described in + the drawing model.

    When the context is created, the shadowBlur attribute must initially have the value 0.

    @@ -69419,10 +69712,9 @@ console.log(pixels.data[2]);

    Coordinates used in the value of the current filter are interpreted such that one pixel is equivalent to one SVG user space unit and to - one canvas coordinate space unit. Filter coordinates are not affected by the current transformation matrix. The current - transformation matrix affects only the input to the filter. Filters are applied in the - output bitmap's coordinate space.

    + one canvas coordinate space unit. The total transformation matrix affects the input + to the filter but the filter itself is applied in layer coordinate space and thus, + filter coordinates are only affected by the parents transformation matrix.

    @@ -69470,8 +69762,8 @@ console.log(pixels.data[2]);
    1. Render the shape or image onto an infinite transparent black bitmap, creating image A, as described in the previous sections. For shapes, the current fill, stroke, - and line styles must be honored, and the stroke must itself also be subjected to the current - transformation matrix.

    2. + and line styles must be honored, and the stroke must itself also be subjected to the + total transformation matrix.

    3. When the current filter is set to a @@ -69480,31 +69772,50 @@ console.log(pixels.data[2]); the input to the current filter, creating image B. If the current filter is a string parseable as a <filter-value-list>, then draw using the current filter in the same manner as SVG.

      + data-x="concept-canvas-current-filter">current filter in the same manner as SVG. The + filter is always applied in layer coordinate space.

      Otherwise, let B be an alias for A.

    4. -
    5. When shadows are drawn, render the shadow from image B, - using the current shadow styles, creating image C.

    6. +
    7. When shadows are drawn, render the shadow from image B in + layer coordinate space, using the current shadow styles, creating image + C.

    8. When shadows are drawn, multiply the alpha component of every pixel in C by global alpha.

    9. When shadows are drawn, composite C within the - clipping region over the current output bitmap using the current + clipping region over the current output bitmap using the current compositing and blending operator.

    10. Multiply the alpha component of every pixel in B by global alpha.

    11. -
    12. Composite B within the clipping region over the current - output bitmap using the current compositing and blending - operator.

    13. +
    14. Composite B within the clipping region over the current + output bitmap using the current compositing and blending operator.

    -

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

    +

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

    + +

    To apply a shadow or filter on an image A in layer coordinate space, user + agents must follow these steps (or act as if they do):

    + +
      +
    1. Let inverseParentsTransform be the result of inverting the parents + transformation matrix.

    2. + +
    3. Transform image A using inverseParentsTransform, creating image + B.

    4. + +
    5. Apply the shadow or filter on image B, creating image C.

    6. + +
    7. Transform image C using parents transformation matrix, creating + image D.

    8. + +
    9. Return image D.

    10. +
    @@ -69832,7 +70143,8 @@ dictionary ImageBitmapRenderingContextSettings {
  • Set context's output bitmap to the same - bitmap as target's bitmap (so that they are shared).

  • + bitmap as target's bitmap (so that they are + shared).

  • Run the steps to set an ImageBitmapRenderingContext's output bitmap with context.

  • @@ -70269,6 +70581,13 @@ interface OffscreenCanvas : EventTarget { internal slot is set to true, then return a promise rejected with an "InvalidStateError" DOMException.

    +
  • If this OffscreenCanvas object's context mode is 2d and the rendering context's layer count is not zero, then return a promise + rejected with an "InvalidStateError" + DOMException.

    +
  • If this OffscreenCanvas object's context mode is 2d and the rendering context's OffscreenCanvas : EventTarget { data-x="offscreencanvas-context-none">none, then throw an "InvalidStateError" DOMException.

  • +
  • If this OffscreenCanvas object's context mode is 2d and the rendering context's layer count is not zero, then throw an + "InvalidStateError" DOMException.

  • +
  • Let image be a newly created ImageBitmap object that references the same underlying bitmap data as this OffscreenCanvas object's bitmap.

  • @@ -70372,6 +70697,7 @@ interface OffscreenCanvasRenderingContext2D { }; OffscreenCanvasRenderingContext2D includes CanvasState; +OffscreenCanvasRenderingContext2D includes CanvasLayers; OffscreenCanvasRenderingContext2D includes CanvasTransform; OffscreenCanvasRenderingContext2D includes CanvasCompositing; OffscreenCanvasRenderingContext2D includes CanvasImageSmoothing; @@ -70404,7 +70730,8 @@ interface OffscreenCanvasRenderingContext2D {

    An OffscreenCanvasRenderingContext2D object has a bitmap that is initialized when the object is - created.

    + created. This bitmap plays the same role as + CanvasRenderingContext2D's top level output bitmap.

    The bitmap has an origin-clean flag, which can be set to true or @@ -70477,7 +70804,8 @@ interface OffscreenCanvasRenderingContext2D { created bitmap with the dimensions specified by the width and height attributes of target, and set - target's bitmap to the same bitmap (so that they are shared).

    + target's bitmap to the same bitmap (so that they + are shared).

  • If context's alpha flag is set to true, initialize all the pixels of context's OffscreenCanvasRenderingContext2D {

    Queue an element task on the DOM manipulation task source given the placeholder canvas element to set the placeholder canvas - element's output bitmap to be a reference to image.

    + element's top level output bitmap to be a reference to + image.

    If image has different dimensions than the bitmap previously referenced as the placeholder canvas - element's output bitmap, then this task will result in a change in - the placeholder canvas + element's top level output bitmap, then this task will result in a change + in the placeholder canvas element's natural size, which can affect document layout.

  • @@ -140878,6 +141207,7 @@ INSERT INTERFACES HERE Jasper Bryant-Greene, Jasper St. Pierre, Jatinder Mann, + Jean-Philippe Gravel, Jean-Yves Avenard, Jed Hartman, Jeff Balogh,