1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
enum CanvasDirection {"ltr", "rtl", "inherit"};
enum CanvasFontKerning {"auto", "normal", "none"};
enum CanvasFontStretch {"ultra-condensed", "extra-condensed", "condensed", "semi-condensed", "normal", "semi-expanded", "expanded", "extra-expanded", "ultra-expanded"};
enum CanvasFontVariantCaps {"normal", "small-caps", "all-small-caps", "petite-caps", "all-petite-caps", "unicase", "titling-caps"};
enum CanvasTextRendering {"auto", "optimizeSpeed", "optimizeLegibility", "geometricPrecision"};
interface mixin BaseRenderingContext2D {
// state
boolean isContextLost();
// text (see also the CanvasPathDrawingStyles and CanvasTextDrawingStyles interfaces)
[HighEntropy, MeasureAs=Canvas2DDrawText] void fillText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
[HighEntropy, MeasureAs=Canvas2DDrawText] void strokeText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
[HighEntropy, MeasureAs=Canvas2DMeasureText] TextMetrics measureText(DOMString text);
[RuntimeEnabled=ExtendedTextMetrics] void fillTextCluster(TextCluster textCluster, double x, double y);
[RuntimeEnabled=ExtendedTextMetrics] void fillTextCluster(TextCluster textCluster, double x, double y, TextClusterOptions options);
[RuntimeEnabled=ExtendedTextMetrics] void strokeTextCluster(TextCluster textCluster, double x, double y);
[RuntimeEnabled=ExtendedTextMetrics] void strokeTextCluster(TextCluster textCluster, double x, double y, TextClusterOptions options);
// pixel manipulation
[RaisesException] ImageData createImageData(ImageData imagedata);
[RaisesException] ImageData createImageData([EnforceRange] long sw, [EnforceRange] long sh);
[RaisesException] ImageData createImageData([EnforceRange] long sw, [EnforceRange] long sh, ImageDataSettings imageDataSettings);
[HighEntropy, MeasureAs=Canvas2DGetImageData, RaisesException] ImageData getImageData([EnforceRange] long sx, [EnforceRange] long sy, [EnforceRange] long sw, [EnforceRange] long sh);
[HighEntropy, MeasureAs=Canvas2DGetImageData, RaisesException] ImageData getImageData([EnforceRange] long sx, [EnforceRange] long sy, [EnforceRange] long sw, [EnforceRange] long sh, ImageDataSettings imageDataSettings);
[NoAllocDirectCall, RaisesException] void putImageData(ImageData imagedata, [EnforceRange] long dx, [EnforceRange] long dy);
[NoAllocDirectCall, RaisesException] void putImageData(ImageData imagedata, [EnforceRange] long dx, [EnforceRange] long dy, [EnforceRange] long dirtyX, [EnforceRange] long dirtyY, [EnforceRange] long dirtyWidth, [EnforceRange] long dirtyHeight);
// text
[RuntimeEnabled=CanvasTextLang] attribute DOMString lang; // (default: "inherit")
[HighEntropy] attribute DOMString font; // (default 10px sans-serif)
attribute CanvasTextAlign textAlign; // "start", "end", "left", "right", "center" (default: "start")
attribute CanvasTextBaseline textBaseline; // "top", "hanging", "middle", "alphabetic", "ideographic", "bottom" (default: "alphabetic")
attribute CanvasDirection direction; // "inherit", "rtl", "ltr" (default: "inherit")
attribute CanvasFontKerning fontKerning; // "auto", "normal", "none" (default: "auto")
attribute CanvasFontStretch fontStretch; // "ultra-condensed", "extra-condensed", "condensed", "semi-condensed", "normal", "semi-expanded", "expanded", "extra-expanded", "ultra-expanded" (default: normal)
attribute CanvasFontVariantCaps fontVariantCaps; // "normal", "small-caps", "all-small-caps", "petite-caps", "all-petite-caps", "unicase", "titling-caps" (default: "normal")
attribute DOMString letterSpacing; // length in pixel (default: "0px")
attribute CanvasTextRendering textRendering; // "auto", "optimizeSpeed", "optimizeLegibility", "geometricPrecision" (default: "auto")
attribute DOMString wordSpacing; // length in pixel (default: "0px")
};
|