xref: /aosp_15_r20/external/skia/modules/canvaskit/htmlcanvas/preamble.js (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1*c8dee2aaSAndroid Build Coastguard Worker// Adds compile-time JS functions to augment the CanvasKit interface.
2*c8dee2aaSAndroid Build Coastguard Worker// Specifically, the code that emulates the HTML Canvas interface
3*c8dee2aaSAndroid Build Coastguard Worker// (which is called HTMLCanvas or similar to avoid confusion with
4*c8dee2aaSAndroid Build Coastguard Worker// SkCanvas).
5*c8dee2aaSAndroid Build Coastguard Worker(function() {
6*c8dee2aaSAndroid Build Coastguard Worker
7*c8dee2aaSAndroid Build Coastguard Worker  // This allows us to expose internal functions (e.g. color
8*c8dee2aaSAndroid Build Coastguard Worker  // parsing) for unit-testing, even in the minified version.
9*c8dee2aaSAndroid Build Coastguard Worker  // Our tests are not minified like CanvasKit is, so the names
10*c8dee2aaSAndroid Build Coastguard Worker  // would get lost otherwise.
11*c8dee2aaSAndroid Build Coastguard Worker  CanvasKit._testing = {};
12*c8dee2aaSAndroid Build Coastguard Worker
13*c8dee2aaSAndroid Build Coastguard Worker// This intentionally dangles because we want all the htmlcanvas
14*c8dee2aaSAndroid Build Coastguard Worker// JS code to be in the same scope, but JS doesn't support
15*c8dee2aaSAndroid Build Coastguard Worker// namespaces like C++ does. Thus, we simply include this
16*c8dee2aaSAndroid Build Coastguard Worker// preamble.js file, all the source .js files and then postamble.js
17*c8dee2aaSAndroid Build Coastguard Worker// to bundle everything in the same scope.