[canvaskit] Refactor Canvas2D JS into own files
Rather than one monolithic file, we now have one monolithic
file (canvascontext2d) and several smaller files (one per class,
and some helpers).
This should make the code navigation a little easier.
Bug: skia:
Change-Id: Ia191c2db778591af21d2a6126f053c17c4f677f1
Reviewed-on: https://skia-review.googlesource.com/c/175996
Reviewed-by: Florin Malita <fmalita@chromium.org>
diff --git a/experimental/canvaskit/htmlcanvas/preamble.js b/experimental/canvaskit/htmlcanvas/preamble.js
new file mode 100644
index 0000000..4ee1fe1
--- /dev/null
+++ b/experimental/canvaskit/htmlcanvas/preamble.js
@@ -0,0 +1,17 @@
+// Adds compile-time JS functions to augment the CanvasKit interface.
+// Specifically, the code that emulates the HTML Canvas interface
+// (which is called HTMLCanvas or similar to avoid confusion with
+// SkCanvas).
+(function(CanvasKit) {
+
+ // This allows us to expose internal functions (e.g. color
+ // parsing) for unit-testing, even in the minified version.
+ // Our tests are not minified like CanvasKit is, so the names
+ // would get lost otherwise.
+ CanvasKit._testing = {};
+
+// This intentionally dangles because we want all the htmlcanvas
+// JS code to be in the same scope, but JS doesn't support
+// namespaces like C++ does. Thus, we simply include this
+// preamble.js file, all the source .js files and then postamble.js
+// to bundle everything in the same scope.
\ No newline at end of file