2012-09-01 07:48:21 +09:00
|
|
|
/* Copyright 2012 Mozilla Foundation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2011-10-26 10:18:22 +09:00
|
|
|
|
2017-04-02 21:25:33 +09:00
|
|
|
import {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
FONT_IDENTITY_MATRIX,
|
|
|
|
IDENTITY_MATRIX,
|
|
|
|
ImageKind,
|
|
|
|
info,
|
2020-02-10 17:38:33 +09:00
|
|
|
IsLittleEndianCached,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
isNum,
|
|
|
|
OPS,
|
|
|
|
shadow,
|
|
|
|
TextRenderingMode,
|
|
|
|
unreachable,
|
|
|
|
Util,
|
|
|
|
warn,
|
2020-01-02 20:00:16 +09:00
|
|
|
} from "../shared/util.js";
|
|
|
|
import { getShadingPatternFromIR, TilingPattern } from "./pattern_helper.js";
|
2015-11-22 01:32:47 +09:00
|
|
|
|
2011-10-28 03:51:10 +09:00
|
|
|
// <canvas> contexts store most of the state we need natively.
|
|
|
|
// However, PDF needs a bit more state, which we store here.
|
|
|
|
|
2012-02-05 05:42:07 +09:00
|
|
|
// Minimal font size that would be used during canvas fillText operations.
|
2013-04-17 00:18:07 +09:00
|
|
|
var MIN_FONT_SIZE = 16;
|
2014-10-25 10:48:31 +09:00
|
|
|
// Maximum font size that would be used during canvas fillText operations.
|
|
|
|
var MAX_FONT_SIZE = 100;
|
2014-02-13 22:01:45 +09:00
|
|
|
var MAX_GROUP_SIZE = 4096;
|
2012-02-05 03:45:18 +09:00
|
|
|
|
2014-04-12 03:19:39 +09:00
|
|
|
// Heuristic value used when enforcing minimum line widths.
|
|
|
|
var MIN_WIDTH_FACTOR = 0.65;
|
|
|
|
|
2013-05-11 12:50:14 +09:00
|
|
|
var COMPILE_TYPE3_GLYPHS = true;
|
2014-10-27 02:20:04 +09:00
|
|
|
var MAX_SIZE_TO_COMPILE = 1000;
|
|
|
|
|
|
|
|
var FULL_CHUNK_HEIGHT = 16;
|
2013-05-11 12:50:14 +09:00
|
|
|
|
2011-11-27 17:22:08 +09:00
|
|
|
function addContextCurrentTransform(ctx) {
|
2015-03-12 04:55:26 +09:00
|
|
|
// If the context doesn't expose a `mozCurrentTransform`, add a JS based one.
|
2011-11-23 05:00:04 +09:00
|
|
|
if (!ctx.mozCurrentTransform) {
|
|
|
|
ctx._originalSave = ctx.save;
|
|
|
|
ctx._originalRestore = ctx.restore;
|
|
|
|
ctx._originalRotate = ctx.rotate;
|
|
|
|
ctx._originalScale = ctx.scale;
|
|
|
|
ctx._originalTranslate = ctx.translate;
|
|
|
|
ctx._originalTransform = ctx.transform;
|
2013-05-01 02:01:01 +09:00
|
|
|
ctx._originalSetTransform = ctx.setTransform;
|
2011-11-23 05:00:04 +09:00
|
|
|
|
2015-03-12 04:55:26 +09:00
|
|
|
ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0];
|
2011-11-23 05:00:04 +09:00
|
|
|
ctx._transformStack = [];
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
Object.defineProperty(ctx, "mozCurrentTransform", {
|
2011-11-27 17:22:08 +09:00
|
|
|
get: function getCurrentTransform() {
|
|
|
|
return this._transformMatrix;
|
Fix inconsistent spacing and trailing commas in objects in remaining `src/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/display/canvas.js b/src/display/canvas.js
index 5739f6f2..4216b2d2 100644
--- a/src/display/canvas.js
+++ b/src/display/canvas.js
@@ -2071,7 +2071,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var map = [];
for (var i = 0, ii = positions.length; i < ii; i += 2) {
map.push({ transform: [scaleX, 0, 0, scaleY, positions[i],
- positions[i + 1]], x: 0, y: 0, w: width, h: height, });
+ positions[i + 1]], x: 0, y: 0, w: width, h: height, });
}
this.paintInlineImageXObjectGroup(imgData, map);
},
diff --git a/src/display/svg.js b/src/display/svg.js
index 9eb05dfa..2aa21482 100644
--- a/src/display/svg.js
+++ b/src/display/svg.js
@@ -458,7 +458,11 @@ SVGGraphics = (function SVGGraphicsClosure() {
for (var x = 0; x < fnArrayLen; x++) {
var fnId = fnArray[x];
- opList.push({ 'fnId': fnId, 'fn': REVOPS[fnId], 'args': argsArray[x], });
+ opList.push({
+ 'fnId': fnId,
+ 'fn': REVOPS[fnId],
+ 'args': argsArray[x],
+ });
}
return opListToTree(opList);
},
```
2017-06-02 18:26:37 +09:00
|
|
|
},
|
2011-11-23 05:00:04 +09:00
|
|
|
});
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
Object.defineProperty(ctx, "mozCurrentTransformInverse", {
|
2011-11-27 17:22:08 +09:00
|
|
|
get: function getCurrentTransformInverse() {
|
2011-11-23 05:00:04 +09:00
|
|
|
// Calculation done using WolframAlpha:
|
|
|
|
// http://www.wolframalpha.com/input/?
|
|
|
|
// i=Inverse+{{a%2C+c%2C+e}%2C+{b%2C+d%2C+f}%2C+{0%2C+0%2C+1}}
|
|
|
|
|
|
|
|
var m = this._transformMatrix;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var a = m[0],
|
|
|
|
b = m[1],
|
|
|
|
c = m[2],
|
|
|
|
d = m[3],
|
|
|
|
e = m[4],
|
|
|
|
f = m[5];
|
2011-11-23 05:00:04 +09:00
|
|
|
|
2011-11-27 17:22:08 +09:00
|
|
|
var ad_bc = a * d - b * c;
|
|
|
|
var bc_ad = b * c - a * d;
|
|
|
|
|
2011-11-23 05:00:04 +09:00
|
|
|
return [
|
2011-11-27 17:22:08 +09:00
|
|
|
d / ad_bc,
|
|
|
|
b / bc_ad,
|
|
|
|
c / bc_ad,
|
|
|
|
a / ad_bc,
|
|
|
|
(d * e - c * f) / bc_ad,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
(b * e - a * f) / ad_bc,
|
2011-11-23 05:00:04 +09:00
|
|
|
];
|
Fix inconsistent spacing and trailing commas in objects in remaining `src/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/display/canvas.js b/src/display/canvas.js
index 5739f6f2..4216b2d2 100644
--- a/src/display/canvas.js
+++ b/src/display/canvas.js
@@ -2071,7 +2071,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var map = [];
for (var i = 0, ii = positions.length; i < ii; i += 2) {
map.push({ transform: [scaleX, 0, 0, scaleY, positions[i],
- positions[i + 1]], x: 0, y: 0, w: width, h: height, });
+ positions[i + 1]], x: 0, y: 0, w: width, h: height, });
}
this.paintInlineImageXObjectGroup(imgData, map);
},
diff --git a/src/display/svg.js b/src/display/svg.js
index 9eb05dfa..2aa21482 100644
--- a/src/display/svg.js
+++ b/src/display/svg.js
@@ -458,7 +458,11 @@ SVGGraphics = (function SVGGraphicsClosure() {
for (var x = 0; x < fnArrayLen; x++) {
var fnId = fnArray[x];
- opList.push({ 'fnId': fnId, 'fn': REVOPS[fnId], 'args': argsArray[x], });
+ opList.push({
+ 'fnId': fnId,
+ 'fn': REVOPS[fnId],
+ 'args': argsArray[x],
+ });
}
return opListToTree(opList);
},
```
2017-06-02 18:26:37 +09:00
|
|
|
},
|
2011-11-27 17:22:08 +09:00
|
|
|
});
|
2011-11-23 05:00:04 +09:00
|
|
|
|
|
|
|
ctx.save = function ctxSave() {
|
|
|
|
var old = this._transformMatrix;
|
|
|
|
this._transformStack.push(old);
|
|
|
|
this._transformMatrix = old.slice(0, 6);
|
|
|
|
|
|
|
|
this._originalSave();
|
|
|
|
};
|
|
|
|
|
|
|
|
ctx.restore = function ctxRestore() {
|
|
|
|
var prev = this._transformStack.pop();
|
|
|
|
if (prev) {
|
|
|
|
this._transformMatrix = prev;
|
|
|
|
this._originalRestore();
|
|
|
|
}
|
2011-11-27 17:22:08 +09:00
|
|
|
};
|
2011-11-23 05:00:04 +09:00
|
|
|
|
|
|
|
ctx.translate = function ctxTranslate(x, y) {
|
|
|
|
var m = this._transformMatrix;
|
|
|
|
m[4] = m[0] * x + m[2] * y + m[4];
|
|
|
|
m[5] = m[1] * x + m[3] * y + m[5];
|
|
|
|
|
|
|
|
this._originalTranslate(x, y);
|
2011-11-27 17:22:08 +09:00
|
|
|
};
|
2011-11-23 05:00:04 +09:00
|
|
|
|
|
|
|
ctx.scale = function ctxScale(x, y) {
|
|
|
|
var m = this._transformMatrix;
|
|
|
|
m[0] = m[0] * x;
|
|
|
|
m[1] = m[1] * x;
|
|
|
|
m[2] = m[2] * y;
|
|
|
|
m[3] = m[3] * y;
|
|
|
|
|
|
|
|
this._originalScale(x, y);
|
2011-11-27 17:22:08 +09:00
|
|
|
};
|
2011-11-23 05:00:04 +09:00
|
|
|
|
|
|
|
ctx.transform = function ctxTransform(a, b, c, d, e, f) {
|
|
|
|
var m = this._transformMatrix;
|
|
|
|
this._transformMatrix = [
|
|
|
|
m[0] * a + m[2] * b,
|
|
|
|
m[1] * a + m[3] * b,
|
|
|
|
m[0] * c + m[2] * d,
|
|
|
|
m[1] * c + m[3] * d,
|
|
|
|
m[0] * e + m[2] * f + m[4],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
m[1] * e + m[3] * f + m[5],
|
2011-11-23 05:00:04 +09:00
|
|
|
];
|
|
|
|
|
|
|
|
ctx._originalTransform(a, b, c, d, e, f);
|
2011-11-27 17:22:08 +09:00
|
|
|
};
|
2011-11-23 05:00:04 +09:00
|
|
|
|
2013-05-01 02:01:01 +09:00
|
|
|
ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
|
|
|
|
this._transformMatrix = [a, b, c, d, e, f];
|
|
|
|
|
|
|
|
ctx._originalSetTransform(a, b, c, d, e, f);
|
|
|
|
};
|
|
|
|
|
2011-11-23 05:00:04 +09:00
|
|
|
ctx.rotate = function ctxRotate(angle) {
|
|
|
|
var cosValue = Math.cos(angle);
|
|
|
|
var sinValue = Math.sin(angle);
|
|
|
|
|
|
|
|
var m = this._transformMatrix;
|
|
|
|
this._transformMatrix = [
|
|
|
|
m[0] * cosValue + m[2] * sinValue,
|
|
|
|
m[1] * cosValue + m[3] * sinValue,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
m[0] * -sinValue + m[2] * cosValue,
|
|
|
|
m[1] * -sinValue + m[3] * cosValue,
|
2011-11-23 05:00:04 +09:00
|
|
|
m[4],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
m[5],
|
2011-11-23 05:00:04 +09:00
|
|
|
];
|
|
|
|
|
|
|
|
this._originalRotate(angle);
|
2011-11-27 17:22:08 +09:00
|
|
|
};
|
2011-11-23 05:00:04 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-31 09:42:26 +09:00
|
|
|
var CachedCanvases = (function CachedCanvasesClosure() {
|
2020-03-25 18:15:50 +09:00
|
|
|
// eslint-disable-next-line no-shadow
|
2017-01-28 02:58:39 +09:00
|
|
|
function CachedCanvases(canvasFactory) {
|
|
|
|
this.canvasFactory = canvasFactory;
|
2015-11-17 01:50:02 +09:00
|
|
|
this.cache = Object.create(null);
|
|
|
|
}
|
|
|
|
CachedCanvases.prototype = {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
getCanvas: function CachedCanvases_getCanvas(
|
|
|
|
id,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
trackTransform
|
|
|
|
) {
|
2013-08-16 23:50:48 +09:00
|
|
|
var canvasEntry;
|
2015-11-17 01:50:02 +09:00
|
|
|
if (this.cache[id] !== undefined) {
|
|
|
|
canvasEntry = this.cache[id];
|
2017-02-07 06:19:56 +09:00
|
|
|
this.canvasFactory.reset(canvasEntry, width, height);
|
2013-05-31 09:42:26 +09:00
|
|
|
// reset canvas transform for emulated mozCurrentTransform, if needed
|
2013-08-16 23:50:48 +09:00
|
|
|
canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
|
2013-05-31 09:42:26 +09:00
|
|
|
} else {
|
2017-02-07 06:19:56 +09:00
|
|
|
canvasEntry = this.canvasFactory.create(width, height);
|
|
|
|
this.cache[id] = canvasEntry;
|
|
|
|
}
|
|
|
|
if (trackTransform) {
|
|
|
|
addContextCurrentTransform(canvasEntry.context);
|
2013-05-31 09:42:26 +09:00
|
|
|
}
|
2013-08-16 23:50:48 +09:00
|
|
|
return canvasEntry;
|
2013-05-31 09:42:26 +09:00
|
|
|
},
|
2017-04-25 23:17:18 +09:00
|
|
|
clear() {
|
2015-11-17 01:50:02 +09:00
|
|
|
for (var id in this.cache) {
|
|
|
|
var canvasEntry = this.cache[id];
|
2017-02-07 06:19:56 +09:00
|
|
|
this.canvasFactory.destroy(canvasEntry);
|
2015-11-17 01:50:02 +09:00
|
|
|
delete this.cache[id];
|
2014-06-17 14:58:11 +09:00
|
|
|
}
|
Fix inconsistent spacing and trailing commas in objects in remaining `src/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/display/canvas.js b/src/display/canvas.js
index 5739f6f2..4216b2d2 100644
--- a/src/display/canvas.js
+++ b/src/display/canvas.js
@@ -2071,7 +2071,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var map = [];
for (var i = 0, ii = positions.length; i < ii; i += 2) {
map.push({ transform: [scaleX, 0, 0, scaleY, positions[i],
- positions[i + 1]], x: 0, y: 0, w: width, h: height, });
+ positions[i + 1]], x: 0, y: 0, w: width, h: height, });
}
this.paintInlineImageXObjectGroup(imgData, map);
},
diff --git a/src/display/svg.js b/src/display/svg.js
index 9eb05dfa..2aa21482 100644
--- a/src/display/svg.js
+++ b/src/display/svg.js
@@ -458,7 +458,11 @@ SVGGraphics = (function SVGGraphicsClosure() {
for (var x = 0; x < fnArrayLen; x++) {
var fnId = fnArray[x];
- opList.push({ 'fnId': fnId, 'fn': REVOPS[fnId], 'args': argsArray[x], });
+ opList.push({
+ 'fnId': fnId,
+ 'fn': REVOPS[fnId],
+ 'args': argsArray[x],
+ });
}
return opListToTree(opList);
},
```
2017-06-02 18:26:37 +09:00
|
|
|
},
|
2013-05-31 09:42:26 +09:00
|
|
|
};
|
2015-11-17 01:50:02 +09:00
|
|
|
return CachedCanvases;
|
2013-05-31 09:42:26 +09:00
|
|
|
})();
|
|
|
|
|
2013-05-11 12:50:14 +09:00
|
|
|
function compileType3Glyph(imgData) {
|
|
|
|
var POINT_TO_PROCESS_LIMIT = 1000;
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var width = imgData.width,
|
|
|
|
height = imgData.height;
|
|
|
|
var i,
|
|
|
|
j,
|
|
|
|
j0,
|
|
|
|
width1 = width + 1;
|
2013-06-12 04:01:10 +09:00
|
|
|
var points = new Uint8Array(width1 * (height + 1));
|
2019-12-25 23:54:34 +09:00
|
|
|
// prettier-ignore
|
2013-07-02 01:25:46 +09:00
|
|
|
var POINT_TYPES =
|
2013-06-12 04:01:10 +09:00
|
|
|
new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]);
|
2014-01-14 12:21:03 +09:00
|
|
|
|
|
|
|
// decodes bit-packed mask data
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var lineSize = (width + 7) & ~7,
|
|
|
|
data0 = imgData.data;
|
|
|
|
var data = new Uint8Array(lineSize * height),
|
|
|
|
pos = 0,
|
|
|
|
ii;
|
2014-01-14 12:21:03 +09:00
|
|
|
for (i = 0, ii = data0.length; i < ii; i++) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var mask = 128,
|
|
|
|
elem = data0[i];
|
2014-01-14 12:21:03 +09:00
|
|
|
while (mask > 0) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
data[pos++] = elem & mask ? 0 : 255;
|
2014-01-14 12:21:03 +09:00
|
|
|
mask >>= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-02 06:20:41 +09:00
|
|
|
// finding interesting points: every point is located between mask pixels,
|
2013-05-11 12:50:14 +09:00
|
|
|
// so there will be points of the (width + 1)x(height + 1) grid. Every point
|
|
|
|
// will have flags assigned based on neighboring mask pixels:
|
|
|
|
// 4 | 8
|
|
|
|
// --P--
|
|
|
|
// 2 | 1
|
|
|
|
// We are interested only in points with the flags:
|
|
|
|
// - outside corners: 1, 2, 4, 8;
|
|
|
|
// - inside corners: 7, 11, 13, 14;
|
|
|
|
// - and, intersections: 5, 10.
|
2014-01-14 12:21:03 +09:00
|
|
|
var count = 0;
|
|
|
|
pos = 0;
|
|
|
|
if (data[pos] !== 0) {
|
2013-06-11 22:40:26 +09:00
|
|
|
points[0] = 1;
|
2013-05-11 12:50:14 +09:00
|
|
|
++count;
|
|
|
|
}
|
|
|
|
for (j = 1; j < width; j++) {
|
2014-01-14 12:21:03 +09:00
|
|
|
if (data[pos] !== data[pos + 1]) {
|
2013-06-11 22:40:26 +09:00
|
|
|
points[j] = data[pos] ? 2 : 1;
|
2013-05-11 12:50:14 +09:00
|
|
|
++count;
|
|
|
|
}
|
2014-01-14 12:21:03 +09:00
|
|
|
pos++;
|
2013-05-11 12:50:14 +09:00
|
|
|
}
|
|
|
|
if (data[pos] !== 0) {
|
2013-06-11 22:40:26 +09:00
|
|
|
points[j] = 2;
|
2013-05-11 12:50:14 +09:00
|
|
|
++count;
|
|
|
|
}
|
|
|
|
for (i = 1; i < height; i++) {
|
2014-01-14 12:21:03 +09:00
|
|
|
pos = i * lineSize;
|
2013-06-12 04:01:10 +09:00
|
|
|
j0 = i * width1;
|
2013-05-11 12:50:14 +09:00
|
|
|
if (data[pos - lineSize] !== data[pos]) {
|
2013-06-11 22:40:26 +09:00
|
|
|
points[j0] = data[pos] ? 1 : 8;
|
2013-05-11 12:50:14 +09:00
|
|
|
++count;
|
|
|
|
}
|
2013-06-11 22:40:26 +09:00
|
|
|
// 'sum' is the position of the current pixel configuration in the 'TYPES'
|
|
|
|
// array (in order 8-1-2-4, so we can use '>>2' to shift the column).
|
|
|
|
var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
|
2013-05-11 12:50:14 +09:00
|
|
|
for (j = 1; j < width; j++) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
sum =
|
|
|
|
(sum >> 2) +
|
|
|
|
(data[pos + 1] ? 4 : 0) +
|
|
|
|
(data[pos - lineSize + 1] ? 8 : 0);
|
2013-07-02 01:25:46 +09:00
|
|
|
if (POINT_TYPES[sum]) {
|
2013-06-12 04:01:10 +09:00
|
|
|
points[j0 + j] = POINT_TYPES[sum];
|
2013-05-11 12:50:14 +09:00
|
|
|
++count;
|
|
|
|
}
|
2014-01-14 12:21:03 +09:00
|
|
|
pos++;
|
2013-05-11 12:50:14 +09:00
|
|
|
}
|
|
|
|
if (data[pos - lineSize] !== data[pos]) {
|
2013-06-11 22:40:26 +09:00
|
|
|
points[j0 + j] = data[pos] ? 2 : 4;
|
2013-05-11 12:50:14 +09:00
|
|
|
++count;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count > POINT_TO_PROCESS_LIMIT) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2013-06-12 04:01:10 +09:00
|
|
|
|
2014-01-14 12:21:03 +09:00
|
|
|
pos = lineSize * (height - 1);
|
2013-06-12 04:01:10 +09:00
|
|
|
j0 = i * width1;
|
2013-05-11 12:50:14 +09:00
|
|
|
if (data[pos] !== 0) {
|
2013-06-12 04:01:10 +09:00
|
|
|
points[j0] = 8;
|
2013-05-11 12:50:14 +09:00
|
|
|
++count;
|
|
|
|
}
|
|
|
|
for (j = 1; j < width; j++) {
|
2014-01-14 12:21:03 +09:00
|
|
|
if (data[pos] !== data[pos + 1]) {
|
2013-06-12 04:01:10 +09:00
|
|
|
points[j0 + j] = data[pos] ? 4 : 8;
|
2013-05-11 12:50:14 +09:00
|
|
|
++count;
|
|
|
|
}
|
2014-01-14 12:21:03 +09:00
|
|
|
pos++;
|
2013-05-11 12:50:14 +09:00
|
|
|
}
|
|
|
|
if (data[pos] !== 0) {
|
2013-06-12 04:01:10 +09:00
|
|
|
points[j0 + j] = 4;
|
2013-05-11 12:50:14 +09:00
|
|
|
++count;
|
|
|
|
}
|
|
|
|
if (count > POINT_TO_PROCESS_LIMIT) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
// building outlines
|
2013-06-12 04:01:10 +09:00
|
|
|
var steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
|
2013-06-11 22:40:26 +09:00
|
|
|
var outlines = [];
|
|
|
|
for (i = 0; count && i <= height; i++) {
|
|
|
|
var p = i * width1;
|
|
|
|
var end = p + width;
|
|
|
|
while (p < end && !points[p]) {
|
|
|
|
p++;
|
2013-05-11 12:50:14 +09:00
|
|
|
}
|
2013-06-11 22:40:26 +09:00
|
|
|
if (p === end) {
|
2013-05-11 12:50:14 +09:00
|
|
|
continue;
|
|
|
|
}
|
2013-06-12 04:01:10 +09:00
|
|
|
var coords = [p % width1, i];
|
2013-05-11 12:50:14 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var type = points[p],
|
|
|
|
p0 = p,
|
|
|
|
pp;
|
2013-05-11 12:50:14 +09:00
|
|
|
do {
|
2013-06-11 22:40:26 +09:00
|
|
|
var step = steps[type];
|
2014-03-14 21:11:11 +09:00
|
|
|
do {
|
|
|
|
p += step;
|
|
|
|
} while (!points[p]);
|
2013-07-02 01:25:46 +09:00
|
|
|
|
2013-06-12 04:01:10 +09:00
|
|
|
pp = points[p];
|
|
|
|
if (pp !== 5 && pp !== 10) {
|
2013-06-11 22:40:26 +09:00
|
|
|
// set new direction
|
2013-07-02 01:25:46 +09:00
|
|
|
type = pp;
|
2013-06-11 22:40:26 +09:00
|
|
|
// delete mark
|
2013-07-02 01:25:46 +09:00
|
|
|
points[p] = 0;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
} else {
|
|
|
|
// type is 5 or 10, ie, a crossing
|
2013-06-11 22:40:26 +09:00
|
|
|
// set new direction
|
2013-07-02 01:25:46 +09:00
|
|
|
type = pp & ((0x33 * type) >> 4);
|
2013-06-11 22:40:26 +09:00
|
|
|
// set new type for "future hit"
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
points[p] &= (type >> 2) | (type << 2);
|
2013-05-11 12:50:14 +09:00
|
|
|
}
|
|
|
|
|
2013-06-12 04:01:10 +09:00
|
|
|
coords.push(p % width1);
|
|
|
|
coords.push((p / width1) | 0);
|
2019-02-22 00:25:34 +09:00
|
|
|
|
|
|
|
if (!points[p]) {
|
|
|
|
--count;
|
|
|
|
}
|
2013-06-11 22:40:26 +09:00
|
|
|
} while (p0 !== p);
|
2013-06-12 04:01:10 +09:00
|
|
|
outlines.push(coords);
|
2013-05-11 12:50:14 +09:00
|
|
|
--i;
|
|
|
|
}
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
var drawOutline = function (c) {
|
2013-06-11 22:40:26 +09:00
|
|
|
c.save();
|
|
|
|
// the path shall be painted in [0..1]x[0..1] space
|
|
|
|
c.scale(1 / width, -1 / height);
|
|
|
|
c.translate(0, -height);
|
|
|
|
c.beginPath();
|
2020-03-21 07:00:36 +09:00
|
|
|
for (let k = 0, kk = outlines.length; k < kk; k++) {
|
|
|
|
var o = outlines[k];
|
2013-06-12 04:01:10 +09:00
|
|
|
c.moveTo(o[0], o[1]);
|
2020-03-21 07:00:36 +09:00
|
|
|
for (let l = 2, ll = o.length; l < ll; l += 2) {
|
|
|
|
c.lineTo(o[l], o[l + 1]);
|
2013-06-11 22:40:26 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
c.fill();
|
|
|
|
c.beginPath();
|
|
|
|
c.restore();
|
|
|
|
};
|
2013-07-02 01:25:46 +09:00
|
|
|
|
2013-06-11 22:40:26 +09:00
|
|
|
return drawOutline;
|
2013-05-11 12:50:14 +09:00
|
|
|
}
|
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
var CanvasExtraState = (function CanvasExtraStateClosure() {
|
2020-03-25 18:15:50 +09:00
|
|
|
// eslint-disable-next-line no-shadow
|
2017-05-24 00:57:26 +09:00
|
|
|
function CanvasExtraState() {
|
2012-04-05 05:43:26 +09:00
|
|
|
// Are soft masks and alpha values shapes or opacities?
|
|
|
|
this.alphaIsShape = false;
|
|
|
|
this.fontSize = 0;
|
|
|
|
this.fontSizeScale = 1;
|
|
|
|
this.textMatrix = IDENTITY_MATRIX;
|
2014-05-24 03:36:54 +09:00
|
|
|
this.textMatrixScale = 1;
|
2013-01-04 09:39:06 +09:00
|
|
|
this.fontMatrix = FONT_IDENTITY_MATRIX;
|
2012-04-05 05:43:26 +09:00
|
|
|
this.leading = 0;
|
|
|
|
// Current point (in user coordinates)
|
|
|
|
this.x = 0;
|
|
|
|
this.y = 0;
|
|
|
|
// Start of text line (in text coordinates)
|
|
|
|
this.lineX = 0;
|
|
|
|
this.lineY = 0;
|
|
|
|
// Character and word spacing
|
|
|
|
this.charSpacing = 0;
|
|
|
|
this.wordSpacing = 0;
|
|
|
|
this.textHScale = 1;
|
|
|
|
this.textRenderingMode = TextRenderingMode.FILL;
|
2012-08-02 05:10:48 +09:00
|
|
|
this.textRise = 0;
|
2012-04-05 05:43:26 +09:00
|
|
|
// Default fore and background colors
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.fillColor = "#000000";
|
|
|
|
this.strokeColor = "#000000";
|
2014-10-27 02:20:04 +09:00
|
|
|
this.patternFill = false;
|
2012-04-05 05:43:26 +09:00
|
|
|
// Note: fill alpha applies to all non-stroking operations
|
|
|
|
this.fillAlpha = 1;
|
|
|
|
this.strokeAlpha = 1;
|
|
|
|
this.lineWidth = 1;
|
2016-04-10 08:46:15 +09:00
|
|
|
this.activeSMask = null;
|
|
|
|
this.resumeSMaskCtx = null; // nonclonable field (see the save method below)
|
2020-08-17 15:49:19 +09:00
|
|
|
this.transferMaps = null;
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
CanvasExtraState.prototype = {
|
|
|
|
clone: function CanvasExtraState_clone() {
|
|
|
|
return Object.create(this);
|
|
|
|
},
|
|
|
|
setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
|
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
Fix inconsistent spacing and trailing commas in objects in remaining `src/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/display/canvas.js b/src/display/canvas.js
index 5739f6f2..4216b2d2 100644
--- a/src/display/canvas.js
+++ b/src/display/canvas.js
@@ -2071,7 +2071,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var map = [];
for (var i = 0, ii = positions.length; i < ii; i += 2) {
map.push({ transform: [scaleX, 0, 0, scaleY, positions[i],
- positions[i + 1]], x: 0, y: 0, w: width, h: height, });
+ positions[i + 1]], x: 0, y: 0, w: width, h: height, });
}
this.paintInlineImageXObjectGroup(imgData, map);
},
diff --git a/src/display/svg.js b/src/display/svg.js
index 9eb05dfa..2aa21482 100644
--- a/src/display/svg.js
+++ b/src/display/svg.js
@@ -458,7 +458,11 @@ SVGGraphics = (function SVGGraphicsClosure() {
for (var x = 0; x < fnArrayLen; x++) {
var fnId = fnArray[x];
- opList.push({ 'fnId': fnId, 'fn': REVOPS[fnId], 'args': argsArray[x], });
+ opList.push({
+ 'fnId': fnId,
+ 'fn': REVOPS[fnId],
+ 'args': argsArray[x],
+ });
}
return opListToTree(opList);
},
```
2017-06-02 18:26:37 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
};
|
|
|
|
return CanvasExtraState;
|
|
|
|
})();
|
|
|
|
|
2020-07-23 05:38:04 +09:00
|
|
|
/**
|
|
|
|
* @type {any}
|
|
|
|
*/
|
2011-12-09 07:18:43 +09:00
|
|
|
var CanvasGraphics = (function CanvasGraphicsClosure() {
|
2012-03-13 02:41:40 +09:00
|
|
|
// Defines the time the executeOperatorList is going to be executing
|
2011-10-25 08:55:23 +09:00
|
|
|
// before it stops and shedules a continue of execution.
|
2012-11-10 06:34:11 +09:00
|
|
|
var EXECUTION_TIME = 15;
|
2014-06-02 21:40:33 +09:00
|
|
|
// Defines the number of steps before checking the execution time
|
|
|
|
var EXECUTION_STEPS = 10;
|
2011-10-25 08:55:23 +09:00
|
|
|
|
2020-03-25 18:15:50 +09:00
|
|
|
// eslint-disable-next-line no-shadow
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
function CanvasGraphics(
|
|
|
|
canvasCtx,
|
|
|
|
commonObjs,
|
|
|
|
objs,
|
|
|
|
canvasFactory,
|
|
|
|
webGLContext,
|
2020-07-15 07:17:27 +09:00
|
|
|
imageLayer,
|
|
|
|
optionalContentConfig
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
) {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.ctx = canvasCtx;
|
|
|
|
this.current = new CanvasExtraState();
|
|
|
|
this.stateStack = [];
|
|
|
|
this.pendingClip = null;
|
2013-05-04 08:47:40 +09:00
|
|
|
this.pendingEOFill = false;
|
2011-10-25 08:55:23 +09:00
|
|
|
this.res = null;
|
|
|
|
this.xobjs = null;
|
2012-10-29 05:10:34 +09:00
|
|
|
this.commonObjs = commonObjs;
|
2011-10-25 08:55:23 +09:00
|
|
|
this.objs = objs;
|
2017-01-28 02:58:39 +09:00
|
|
|
this.canvasFactory = canvasFactory;
|
2017-11-02 00:32:22 +09:00
|
|
|
this.webGLContext = webGLContext;
|
2013-02-11 03:19:36 +09:00
|
|
|
this.imageLayer = imageLayer;
|
2013-03-13 09:20:38 +09:00
|
|
|
this.groupStack = [];
|
2013-05-11 12:50:14 +09:00
|
|
|
this.processingType3 = null;
|
2013-07-23 06:52:44 +09:00
|
|
|
// Patterns are painted relative to the initial page/form transform, see pdf
|
|
|
|
// spec 8.7.2 NOTE 1.
|
|
|
|
this.baseTransform = null;
|
|
|
|
this.baseTransformStack = [];
|
2013-08-16 23:50:48 +09:00
|
|
|
this.groupLevel = 0;
|
2014-01-24 02:13:32 +09:00
|
|
|
this.smaskStack = [];
|
|
|
|
this.smaskCounter = 0;
|
|
|
|
this.tempSMask = null;
|
2020-07-15 07:17:27 +09:00
|
|
|
this.contentVisible = true;
|
|
|
|
this.markedContentStack = [];
|
|
|
|
this.optionalContentConfig = optionalContentConfig;
|
2017-01-28 02:58:39 +09:00
|
|
|
this.cachedCanvases = new CachedCanvases(this.canvasFactory);
|
2011-11-23 05:00:04 +09:00
|
|
|
if (canvasCtx) {
|
2015-03-12 04:55:26 +09:00
|
|
|
// NOTE: if mozCurrentTransform is polyfilled, then the current state of
|
|
|
|
// the transformation must already be set in canvasCtx._transformMatrix.
|
2011-11-27 17:22:08 +09:00
|
|
|
addContextCurrentTransform(canvasCtx);
|
2011-11-23 05:00:04 +09:00
|
|
|
}
|
2018-09-03 03:31:24 +09:00
|
|
|
this._cachedGetSinglePixelWidth = null;
|
2011-10-25 08:55:23 +09:00
|
|
|
}
|
|
|
|
|
2020-08-17 15:49:19 +09:00
|
|
|
function putBinaryImageData(ctx, imgData, transferMaps = null) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (typeof ImageData !== "undefined" && imgData instanceof ImageData) {
|
2013-05-31 09:42:26 +09:00
|
|
|
ctx.putImageData(imgData, 0, 0);
|
|
|
|
return;
|
2012-12-08 03:19:43 +09:00
|
|
|
}
|
|
|
|
|
2014-01-17 09:59:22 +09:00
|
|
|
// Put the image data to the canvas in chunks, rather than putting the
|
|
|
|
// whole image at once. This saves JS memory, because the ImageData object
|
|
|
|
// is smaller. It also possibly saves C++ memory within the implementation
|
|
|
|
// of putImageData(). (E.g. in Firefox we make two short-lived copies of
|
|
|
|
// the data passed to putImageData()). |n| shouldn't be too small, however,
|
|
|
|
// because too many putImageData() calls will slow things down.
|
2014-01-23 09:47:51 +09:00
|
|
|
//
|
|
|
|
// Note: as written, if the last chunk is partial, the putImageData() call
|
|
|
|
// will (conceptually) put pixels past the bounds of the canvas. But
|
|
|
|
// that's ok; any such pixels are ignored.
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var height = imgData.height,
|
|
|
|
width = imgData.width;
|
2014-10-27 02:20:04 +09:00
|
|
|
var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
|
|
|
|
var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
|
|
|
|
var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
|
2014-01-23 09:47:51 +09:00
|
|
|
|
2014-10-27 02:20:04 +09:00
|
|
|
var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var srcPos = 0,
|
|
|
|
destPos;
|
2014-01-17 09:59:22 +09:00
|
|
|
var src = imgData.data;
|
2014-02-25 12:41:04 +09:00
|
|
|
var dest = chunkImgData.data;
|
2014-04-09 04:48:16 +09:00
|
|
|
var i, j, thisChunkHeight, elemsInThisChunk;
|
2014-01-17 09:59:22 +09:00
|
|
|
|
2020-08-17 15:49:19 +09:00
|
|
|
let transferMapRed, transferMapGreen, transferMapBlue, transferMapGray;
|
|
|
|
if (transferMaps) {
|
|
|
|
switch (transferMaps.length) {
|
|
|
|
case 1:
|
|
|
|
transferMapRed = transferMaps[0];
|
|
|
|
transferMapGreen = transferMaps[0];
|
|
|
|
transferMapBlue = transferMaps[0];
|
|
|
|
transferMapGray = transferMaps[0];
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
transferMapRed = transferMaps[0];
|
|
|
|
transferMapGreen = transferMaps[1];
|
|
|
|
transferMapBlue = transferMaps[2];
|
|
|
|
transferMapGray = transferMaps[3];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-23 09:47:51 +09:00
|
|
|
// There are multiple forms in which the pixel data can be passed, and
|
|
|
|
// imgData.kind tells us which one this is.
|
2014-02-26 08:11:15 +09:00
|
|
|
if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
|
2014-01-23 09:47:51 +09:00
|
|
|
// Grayscale, 1 bit per pixel (i.e. black-and-white).
|
2014-02-25 12:41:04 +09:00
|
|
|
var srcLength = src.byteLength;
|
2017-04-14 03:16:35 +09:00
|
|
|
var dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);
|
2014-03-21 00:57:11 +09:00
|
|
|
var dest32DataLength = dest32.length;
|
|
|
|
var fullSrcDiff = (width + 7) >> 3;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var white = 0xffffffff;
|
|
|
|
var black = IsLittleEndianCached.value ? 0xff000000 : 0x000000ff;
|
2020-08-17 15:49:19 +09:00
|
|
|
|
|
|
|
if (transferMapGray) {
|
|
|
|
if (transferMapGray[0] === 0xff && transferMapGray[0xff] === 0) {
|
|
|
|
[white, black] = [black, white];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-09 04:48:16 +09:00
|
|
|
for (i = 0; i < totalChunks; i++) {
|
|
|
|
thisChunkHeight =
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
|
2014-04-09 04:48:16 +09:00
|
|
|
destPos = 0;
|
|
|
|
for (j = 0; j < thisChunkHeight; j++) {
|
2014-03-21 00:57:11 +09:00
|
|
|
var srcDiff = srcLength - srcPos;
|
2020-08-17 15:49:19 +09:00
|
|
|
let k = 0;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
|
2014-03-21 00:57:11 +09:00
|
|
|
var kEndUnrolled = kEnd & ~7;
|
2014-01-23 09:47:51 +09:00
|
|
|
var mask = 0;
|
|
|
|
var srcByte = 0;
|
2014-03-21 00:57:11 +09:00
|
|
|
for (; k < kEndUnrolled; k += 8) {
|
|
|
|
srcByte = src[srcPos++];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
dest32[destPos++] = srcByte & 128 ? white : black;
|
|
|
|
dest32[destPos++] = srcByte & 64 ? white : black;
|
|
|
|
dest32[destPos++] = srcByte & 32 ? white : black;
|
|
|
|
dest32[destPos++] = srcByte & 16 ? white : black;
|
|
|
|
dest32[destPos++] = srcByte & 8 ? white : black;
|
|
|
|
dest32[destPos++] = srcByte & 4 ? white : black;
|
|
|
|
dest32[destPos++] = srcByte & 2 ? white : black;
|
|
|
|
dest32[destPos++] = srcByte & 1 ? white : black;
|
2014-03-21 00:57:11 +09:00
|
|
|
}
|
|
|
|
for (; k < kEnd; k++) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (mask === 0) {
|
|
|
|
srcByte = src[srcPos++];
|
|
|
|
mask = 128;
|
|
|
|
}
|
2014-01-23 09:47:51 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
dest32[destPos++] = srcByte & mask ? white : black;
|
2014-01-23 09:47:51 +09:00
|
|
|
mask >>= 1;
|
|
|
|
}
|
2014-01-17 09:59:22 +09:00
|
|
|
}
|
2014-03-21 00:57:11 +09:00
|
|
|
// We ran out of input. Make all remaining pixels transparent.
|
|
|
|
while (destPos < dest32DataLength) {
|
|
|
|
dest32[destPos++] = 0;
|
2014-01-30 04:10:34 +09:00
|
|
|
}
|
|
|
|
|
2014-10-27 02:20:04 +09:00
|
|
|
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
|
2014-01-17 09:59:22 +09:00
|
|
|
}
|
2014-02-26 08:11:15 +09:00
|
|
|
} else if (imgData.kind === ImageKind.RGBA_32BPP) {
|
2014-01-23 09:47:51 +09:00
|
|
|
// RGBA, 32-bits per pixel.
|
2020-08-17 15:49:19 +09:00
|
|
|
const hasTransferMaps = !!(
|
|
|
|
transferMapRed ||
|
|
|
|
transferMapGreen ||
|
|
|
|
transferMapBlue
|
|
|
|
);
|
2014-01-23 09:47:51 +09:00
|
|
|
|
2014-04-29 00:19:56 +09:00
|
|
|
j = 0;
|
2014-10-27 02:20:04 +09:00
|
|
|
elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
|
2014-04-29 00:19:56 +09:00
|
|
|
for (i = 0; i < fullChunks; i++) {
|
2014-03-11 12:18:37 +09:00
|
|
|
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
|
|
|
|
srcPos += elemsInThisChunk;
|
|
|
|
|
2020-08-17 15:49:19 +09:00
|
|
|
if (hasTransferMaps) {
|
|
|
|
for (let k = 0; k < elemsInThisChunk; k += 4) {
|
|
|
|
if (transferMapRed) {
|
|
|
|
dest[k + 0] = transferMapRed[dest[k + 0]];
|
|
|
|
}
|
|
|
|
if (transferMapGreen) {
|
|
|
|
dest[k + 1] = transferMapGreen[dest[k + 1]];
|
|
|
|
}
|
|
|
|
if (transferMapBlue) {
|
|
|
|
dest[k + 2] = transferMapBlue[dest[k + 2]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-29 00:19:56 +09:00
|
|
|
ctx.putImageData(chunkImgData, 0, j);
|
2014-10-27 02:20:04 +09:00
|
|
|
j += FULL_CHUNK_HEIGHT;
|
2014-04-29 00:19:56 +09:00
|
|
|
}
|
|
|
|
if (i < totalChunks) {
|
|
|
|
elemsInThisChunk = width * partialChunkHeight * 4;
|
|
|
|
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
|
2020-08-17 15:49:19 +09:00
|
|
|
|
|
|
|
if (hasTransferMaps) {
|
|
|
|
for (let k = 0; k < elemsInThisChunk; k += 4) {
|
|
|
|
if (transferMapRed) {
|
|
|
|
dest[k + 0] = transferMapRed[dest[k + 0]];
|
|
|
|
}
|
|
|
|
if (transferMapGreen) {
|
|
|
|
dest[k + 1] = transferMapGreen[dest[k + 1]];
|
|
|
|
}
|
|
|
|
if (transferMapBlue) {
|
|
|
|
dest[k + 2] = transferMapBlue[dest[k + 2]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-29 00:19:56 +09:00
|
|
|
ctx.putImageData(chunkImgData, 0, j);
|
2014-01-17 09:59:22 +09:00
|
|
|
}
|
2014-02-26 08:11:15 +09:00
|
|
|
} else if (imgData.kind === ImageKind.RGB_24BPP) {
|
2014-02-25 12:37:19 +09:00
|
|
|
// RGB, 24-bits per pixel.
|
2020-08-17 15:49:19 +09:00
|
|
|
const hasTransferMaps = !!(
|
|
|
|
transferMapRed ||
|
|
|
|
transferMapGreen ||
|
|
|
|
transferMapBlue
|
|
|
|
);
|
|
|
|
|
2014-10-27 02:20:04 +09:00
|
|
|
thisChunkHeight = FULL_CHUNK_HEIGHT;
|
2014-04-29 00:19:56 +09:00
|
|
|
elemsInThisChunk = width * thisChunkHeight;
|
2014-04-09 04:48:16 +09:00
|
|
|
for (i = 0; i < totalChunks; i++) {
|
2014-04-29 00:19:56 +09:00
|
|
|
if (i >= fullChunks) {
|
2014-10-27 02:20:04 +09:00
|
|
|
thisChunkHeight = partialChunkHeight;
|
2014-04-29 00:19:56 +09:00
|
|
|
elemsInThisChunk = width * thisChunkHeight;
|
|
|
|
}
|
|
|
|
|
2014-04-09 04:48:16 +09:00
|
|
|
destPos = 0;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
for (j = elemsInThisChunk; j--; ) {
|
2014-02-25 12:41:04 +09:00
|
|
|
dest[destPos++] = src[srcPos++];
|
|
|
|
dest[destPos++] = src[srcPos++];
|
|
|
|
dest[destPos++] = src[srcPos++];
|
|
|
|
dest[destPos++] = 255;
|
2014-02-25 12:37:19 +09:00
|
|
|
}
|
2020-08-17 15:49:19 +09:00
|
|
|
|
|
|
|
if (hasTransferMaps) {
|
|
|
|
for (let k = 0; k < destPos; k += 4) {
|
|
|
|
if (transferMapRed) {
|
|
|
|
dest[k + 0] = transferMapRed[dest[k + 0]];
|
|
|
|
}
|
|
|
|
if (transferMapGreen) {
|
|
|
|
dest[k + 1] = transferMapGreen[dest[k + 1]];
|
|
|
|
}
|
|
|
|
if (transferMapBlue) {
|
|
|
|
dest[k + 2] = transferMapBlue[dest[k + 2]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-27 02:20:04 +09:00
|
|
|
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
|
2014-02-25 12:37:19 +09:00
|
|
|
}
|
2014-01-23 09:47:51 +09:00
|
|
|
} else {
|
2017-06-29 05:51:31 +09:00
|
|
|
throw new Error(`bad image kind: ${imgData.kind}`);
|
2014-01-17 09:59:22 +09:00
|
|
|
}
|
2012-12-22 07:31:57 +09:00
|
|
|
}
|
|
|
|
|
2014-01-14 11:08:39 +09:00
|
|
|
function putBinaryImageMask(ctx, imgData) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var height = imgData.height,
|
|
|
|
width = imgData.width;
|
2014-10-27 02:20:04 +09:00
|
|
|
var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
|
|
|
|
var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
|
|
|
|
var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
|
2014-02-28 14:15:38 +09:00
|
|
|
|
2014-10-27 02:20:04 +09:00
|
|
|
var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
|
2014-02-28 14:15:38 +09:00
|
|
|
var srcPos = 0;
|
|
|
|
var src = imgData.data;
|
|
|
|
var dest = chunkImgData.data;
|
|
|
|
|
|
|
|
for (var i = 0; i < totalChunks; i++) {
|
|
|
|
var thisChunkHeight =
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
|
2014-02-28 14:15:38 +09:00
|
|
|
|
|
|
|
// Expand the mask so it can be used by the canvas. Any required
|
|
|
|
// inversion has already been handled.
|
|
|
|
var destPos = 3; // alpha component offset
|
|
|
|
for (var j = 0; j < thisChunkHeight; j++) {
|
|
|
|
var mask = 0;
|
|
|
|
for (var k = 0; k < width; k++) {
|
|
|
|
if (!mask) {
|
|
|
|
var elem = src[srcPos++];
|
|
|
|
mask = 128;
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
dest[destPos] = elem & mask ? 0 : 255;
|
2014-02-28 14:15:38 +09:00
|
|
|
destPos += 4;
|
|
|
|
mask >>= 1;
|
2014-01-14 11:08:39 +09:00
|
|
|
}
|
|
|
|
}
|
2014-10-27 02:20:04 +09:00
|
|
|
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
|
2014-01-14 11:08:39 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 09:20:38 +09:00
|
|
|
function copyCtxState(sourceCtx, destCtx) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var properties = [
|
|
|
|
"strokeStyle",
|
|
|
|
"fillStyle",
|
|
|
|
"fillRule",
|
|
|
|
"globalAlpha",
|
|
|
|
"lineWidth",
|
|
|
|
"lineCap",
|
|
|
|
"lineJoin",
|
|
|
|
"miterLimit",
|
|
|
|
"globalCompositeOperation",
|
|
|
|
"font",
|
|
|
|
];
|
2013-03-13 09:20:38 +09:00
|
|
|
for (var i = 0, ii = properties.length; i < ii; i++) {
|
|
|
|
var property = properties[i];
|
2014-10-27 02:20:04 +09:00
|
|
|
if (sourceCtx[property] !== undefined) {
|
2013-03-13 09:20:38 +09:00
|
|
|
destCtx[property] = sourceCtx[property];
|
|
|
|
}
|
|
|
|
}
|
2014-10-27 02:20:04 +09:00
|
|
|
if (sourceCtx.setLineDash !== undefined) {
|
2013-03-13 09:20:38 +09:00
|
|
|
destCtx.setLineDash(sourceCtx.getLineDash());
|
2016-12-10 22:28:27 +09:00
|
|
|
destCtx.lineDashOffset = sourceCtx.lineDashOffset;
|
2013-03-13 09:20:38 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-24 00:57:26 +09:00
|
|
|
function resetCtxToDefault(ctx) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
ctx.strokeStyle = "#000000";
|
|
|
|
ctx.fillStyle = "#000000";
|
|
|
|
ctx.fillRule = "nonzero";
|
2017-05-24 00:57:26 +09:00
|
|
|
ctx.globalAlpha = 1;
|
|
|
|
ctx.lineWidth = 1;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
ctx.lineCap = "butt";
|
|
|
|
ctx.lineJoin = "miter";
|
2017-05-24 00:57:26 +09:00
|
|
|
ctx.miterLimit = 10;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
ctx.globalCompositeOperation = "source-over";
|
|
|
|
ctx.font = "10px sans-serif";
|
2017-05-24 00:57:26 +09:00
|
|
|
if (ctx.setLineDash !== undefined) {
|
|
|
|
ctx.setLineDash([]);
|
|
|
|
ctx.lineDashOffset = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-02 21:54:40 +09:00
|
|
|
function composeSMaskBackdrop(bytes, r0, g0, b0) {
|
|
|
|
var length = bytes.length;
|
|
|
|
for (var i = 3; i < length; i += 4) {
|
|
|
|
var alpha = bytes[i];
|
|
|
|
if (alpha === 0) {
|
|
|
|
bytes[i - 3] = r0;
|
|
|
|
bytes[i - 2] = g0;
|
|
|
|
bytes[i - 1] = b0;
|
|
|
|
} else if (alpha < 255) {
|
|
|
|
var alpha_ = 255 - alpha;
|
|
|
|
bytes[i - 3] = (bytes[i - 3] * alpha + r0 * alpha_) >> 8;
|
|
|
|
bytes[i - 2] = (bytes[i - 2] * alpha + g0 * alpha_) >> 8;
|
|
|
|
bytes[i - 1] = (bytes[i - 1] * alpha + b0 * alpha_) >> 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-05 03:52:45 +09:00
|
|
|
function composeSMaskAlpha(maskData, layerData, transferMap) {
|
2014-06-02 21:54:40 +09:00
|
|
|
var length = maskData.length;
|
|
|
|
var scale = 1 / 255;
|
|
|
|
for (var i = 3; i < length; i += 4) {
|
2015-12-05 03:52:45 +09:00
|
|
|
var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
|
2014-06-02 21:54:40 +09:00
|
|
|
layerData[i] = (layerData[i] * alpha * scale) | 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-05 03:52:45 +09:00
|
|
|
function composeSMaskLuminosity(maskData, layerData, transferMap) {
|
2014-06-02 21:54:40 +09:00
|
|
|
var length = maskData.length;
|
|
|
|
for (var i = 3; i < length; i += 4) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var y =
|
|
|
|
maskData[i - 3] * 77 + // * 0.3 / 255 * 0x10000
|
|
|
|
maskData[i - 2] * 152 + // * 0.59 ....
|
|
|
|
maskData[i - 1] * 28; // * 0.11 ....
|
|
|
|
layerData[i] = transferMap
|
|
|
|
? (layerData[i] * transferMap[y >> 8]) >> 8
|
|
|
|
: (layerData[i] * y) >> 16;
|
2014-06-02 21:54:40 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
function genericComposeSMask(
|
|
|
|
maskCtx,
|
|
|
|
layerCtx,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
subtype,
|
|
|
|
backdrop,
|
|
|
|
transferMap
|
|
|
|
) {
|
2014-06-11 05:47:25 +09:00
|
|
|
var hasBackdrop = !!backdrop;
|
2014-06-02 21:54:40 +09:00
|
|
|
var r0 = hasBackdrop ? backdrop[0] : 0;
|
|
|
|
var g0 = hasBackdrop ? backdrop[1] : 0;
|
|
|
|
var b0 = hasBackdrop ? backdrop[2] : 0;
|
2014-01-24 02:13:32 +09:00
|
|
|
|
|
|
|
var composeFn;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (subtype === "Luminosity") {
|
2014-06-02 21:54:40 +09:00
|
|
|
composeFn = composeSMaskLuminosity;
|
2014-01-24 02:13:32 +09:00
|
|
|
} else {
|
2014-06-02 21:54:40 +09:00
|
|
|
composeFn = composeSMaskAlpha;
|
2014-01-24 02:13:32 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
// processing image in chunks to save memory
|
2014-12-03 18:25:53 +09:00
|
|
|
var PIXELS_TO_PROCESS = 1048576;
|
2014-02-13 23:37:19 +09:00
|
|
|
var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
|
2014-01-24 02:13:32 +09:00
|
|
|
for (var row = 0; row < height; row += chunkSize) {
|
|
|
|
var chunkHeight = Math.min(chunkSize, height - row);
|
|
|
|
var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
|
|
|
|
var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
|
|
|
|
|
2014-06-02 21:54:40 +09:00
|
|
|
if (hasBackdrop) {
|
|
|
|
composeSMaskBackdrop(maskData.data, r0, g0, b0);
|
|
|
|
}
|
2015-12-05 03:52:45 +09:00
|
|
|
composeFn(maskData.data, layerData.data, transferMap);
|
2014-01-24 02:13:32 +09:00
|
|
|
|
|
|
|
maskCtx.putImageData(layerData, 0, row);
|
|
|
|
}
|
2014-02-13 23:44:58 +09:00
|
|
|
}
|
|
|
|
|
2017-11-02 00:32:22 +09:00
|
|
|
function composeSMask(ctx, smask, layerCtx, webGLContext) {
|
2014-02-13 23:44:58 +09:00
|
|
|
var mask = smask.canvas;
|
|
|
|
var maskCtx = smask.context;
|
2014-01-24 02:13:32 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
ctx.setTransform(
|
|
|
|
smask.scaleX,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
smask.scaleY,
|
|
|
|
smask.offsetX,
|
|
|
|
smask.offsetY
|
|
|
|
);
|
2014-02-13 23:44:58 +09:00
|
|
|
|
2014-05-22 02:47:42 +09:00
|
|
|
var backdrop = smask.backdrop || null;
|
2017-11-02 00:32:22 +09:00
|
|
|
if (!smask.transferMap && webGLContext.isEnabled) {
|
2020-01-24 17:48:21 +09:00
|
|
|
const composed = webGLContext.composeSMask({
|
2017-11-02 00:32:22 +09:00
|
|
|
layer: layerCtx.canvas,
|
|
|
|
mask,
|
|
|
|
properties: {
|
|
|
|
subtype: smask.subtype,
|
|
|
|
backdrop,
|
|
|
|
},
|
|
|
|
});
|
2014-02-13 23:44:58 +09:00
|
|
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
|
|
ctx.drawImage(composed, smask.offsetX, smask.offsetY);
|
|
|
|
return;
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
genericComposeSMask(
|
|
|
|
maskCtx,
|
|
|
|
layerCtx,
|
|
|
|
mask.width,
|
|
|
|
mask.height,
|
|
|
|
smask.subtype,
|
|
|
|
backdrop,
|
|
|
|
smask.transferMap
|
|
|
|
);
|
2014-02-13 22:01:45 +09:00
|
|
|
ctx.drawImage(mask, 0, 0);
|
2014-01-24 02:13:32 +09:00
|
|
|
}
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var LINE_CAP_STYLES = ["butt", "round", "square"];
|
|
|
|
var LINE_JOIN_STYLES = ["miter", "round", "bevel"];
|
2011-10-25 08:55:23 +09:00
|
|
|
var NORMAL_CLIP = {};
|
|
|
|
var EO_CLIP = {};
|
|
|
|
|
2011-12-09 07:18:43 +09:00
|
|
|
CanvasGraphics.prototype = {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
beginDrawing({
|
|
|
|
transform,
|
|
|
|
viewport,
|
|
|
|
transparency = false,
|
|
|
|
background = null,
|
|
|
|
}) {
|
2013-03-30 05:26:25 +09:00
|
|
|
// For pdfs that use blend modes we have to clear the canvas else certain
|
|
|
|
// blend modes can look wrong since we'd be blending with a white
|
|
|
|
// backdrop. The problem with a transparent backdrop though is we then
|
2015-11-17 01:50:02 +09:00
|
|
|
// don't get sub pixel anti aliasing on text, creating temporary
|
|
|
|
// transparent canvas when we have blend modes.
|
2013-03-30 05:26:25 +09:00
|
|
|
var width = this.ctx.canvas.width;
|
|
|
|
var height = this.ctx.canvas.height;
|
2015-11-17 01:50:02 +09:00
|
|
|
|
|
|
|
this.ctx.save();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.ctx.fillStyle = background || "rgb(255, 255, 255)";
|
2015-11-17 01:50:02 +09:00
|
|
|
this.ctx.fillRect(0, 0, width, height);
|
|
|
|
this.ctx.restore();
|
|
|
|
|
2013-03-30 05:26:25 +09:00
|
|
|
if (transparency) {
|
2015-11-17 01:50:02 +09:00
|
|
|
var transparentCanvas = this.cachedCanvases.getCanvas(
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
"transparent",
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
true
|
|
|
|
);
|
2015-11-17 01:50:02 +09:00
|
|
|
this.compositeCtx = this.ctx;
|
|
|
|
this.transparentCanvas = transparentCanvas.canvas;
|
|
|
|
this.ctx = transparentCanvas.context;
|
2013-03-30 05:26:25 +09:00
|
|
|
this.ctx.save();
|
2015-11-17 01:50:02 +09:00
|
|
|
// The transform can be applied before rendering, transferring it to
|
|
|
|
// the new canvas.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.ctx.transform.apply(
|
|
|
|
this.ctx,
|
|
|
|
this.compositeCtx.mozCurrentTransform
|
|
|
|
);
|
2013-03-30 05:26:25 +09:00
|
|
|
}
|
|
|
|
|
2011-10-25 08:55:23 +09:00
|
|
|
this.ctx.save();
|
2017-05-24 00:57:26 +09:00
|
|
|
resetCtxToDefault(this.ctx);
|
2015-11-17 01:50:02 +09:00
|
|
|
if (transform) {
|
|
|
|
this.ctx.transform.apply(this.ctx, transform);
|
|
|
|
}
|
|
|
|
this.ctx.transform.apply(this.ctx, viewport.transform);
|
2011-12-19 03:53:30 +09:00
|
|
|
|
2014-01-27 22:17:14 +09:00
|
|
|
this.baseTransform = this.ctx.mozCurrentTransform.slice();
|
|
|
|
|
2013-02-11 03:19:36 +09:00
|
|
|
if (this.imageLayer) {
|
|
|
|
this.imageLayer.beginLayout();
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
executeOperatorList: function CanvasGraphics_executeOperatorList(
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
operatorList,
|
|
|
|
executionStartIdx,
|
|
|
|
continueCallback,
|
|
|
|
stepper
|
|
|
|
) {
|
2012-03-13 02:41:40 +09:00
|
|
|
var argsArray = operatorList.argsArray;
|
|
|
|
var fnArray = operatorList.fnArray;
|
2011-10-25 08:55:23 +09:00
|
|
|
var i = executionStartIdx || 0;
|
|
|
|
var argsArrayLen = argsArray.length;
|
|
|
|
|
2012-03-13 02:41:40 +09:00
|
|
|
// Sometimes the OperatorList to execute is empty.
|
2014-06-02 21:40:33 +09:00
|
|
|
if (argsArrayLen === i) {
|
2011-11-28 04:54:25 +09:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var chunkOperations =
|
|
|
|
argsArrayLen - i > EXECUTION_STEPS &&
|
|
|
|
typeof continueCallback === "function";
|
2014-06-02 21:40:33 +09:00
|
|
|
var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
|
|
|
|
var steps = 0;
|
2011-10-25 08:55:23 +09:00
|
|
|
|
2012-10-29 05:10:34 +09:00
|
|
|
var commonObjs = this.commonObjs;
|
2011-10-25 08:55:23 +09:00
|
|
|
var objs = this.objs;
|
2013-11-14 04:43:38 +09:00
|
|
|
var fnId;
|
2011-10-25 08:55:23 +09:00
|
|
|
|
2011-11-28 04:54:25 +09:00
|
|
|
while (true) {
|
2014-06-02 21:40:33 +09:00
|
|
|
if (stepper !== undefined && i === stepper.nextBreakPoint) {
|
2012-02-14 10:35:58 +09:00
|
|
|
stepper.breakIt(i, continueCallback);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2013-11-14 04:43:38 +09:00
|
|
|
fnId = fnArray[i];
|
2011-12-01 08:02:30 +09:00
|
|
|
|
2013-11-14 04:43:38 +09:00
|
|
|
if (fnId !== OPS.dependency) {
|
|
|
|
this[fnId].apply(this, argsArray[i]);
|
2011-11-28 04:54:25 +09:00
|
|
|
} else {
|
2019-04-11 19:26:15 +09:00
|
|
|
for (const depObjId of argsArray[i]) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const objsPool = depObjId.startsWith("g_") ? commonObjs : objs;
|
2011-11-28 04:54:25 +09:00
|
|
|
|
|
|
|
// If the promise isn't resolved yet, add the continueCallback
|
|
|
|
// to the promise and bail out.
|
2018-11-07 22:36:29 +09:00
|
|
|
if (!objsPool.has(depObjId)) {
|
2014-06-02 21:40:33 +09:00
|
|
|
objsPool.get(depObjId, continueCallback);
|
2012-10-29 05:10:34 +09:00
|
|
|
return i;
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
}
|
|
|
|
}
|
2011-12-01 08:02:30 +09:00
|
|
|
|
2011-11-28 04:54:25 +09:00
|
|
|
i++;
|
2011-10-25 08:55:23 +09:00
|
|
|
|
2012-03-13 02:41:40 +09:00
|
|
|
// If the entire operatorList was executed, stop as were done.
|
2014-06-02 21:40:33 +09:00
|
|
|
if (i === argsArrayLen) {
|
2011-10-25 08:55:23 +09:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2014-05-09 21:00:47 +09:00
|
|
|
// If the execution took longer then a certain amount of time and
|
|
|
|
// `continueCallback` is specified, interrupt the execution.
|
2014-06-02 21:40:33 +09:00
|
|
|
if (chunkOperations && ++steps > EXECUTION_STEPS) {
|
|
|
|
if (Date.now() > endTime) {
|
|
|
|
continueCallback();
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
steps = 0;
|
2011-10-25 08:55:23 +09:00
|
|
|
}
|
|
|
|
|
2012-03-13 02:41:40 +09:00
|
|
|
// If the operatorList isn't executed completely yet OR the execution
|
|
|
|
// time was short enough, do another execution round.
|
2011-11-28 04:54:25 +09:00
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
endDrawing: function CanvasGraphics_endDrawing() {
|
2016-04-10 08:50:11 +09:00
|
|
|
// Finishing all opened operations such as SMask group painting.
|
2020-09-12 23:15:33 +09:00
|
|
|
if (this.current.activeSMask !== null) {
|
|
|
|
this.endSMaskGroup();
|
2016-04-10 08:50:11 +09:00
|
|
|
}
|
|
|
|
|
2011-10-25 08:55:23 +09:00
|
|
|
this.ctx.restore();
|
2015-11-17 01:50:02 +09:00
|
|
|
|
|
|
|
if (this.transparentCanvas) {
|
|
|
|
this.ctx = this.compositeCtx;
|
2016-01-21 10:25:39 +09:00
|
|
|
this.ctx.save();
|
|
|
|
this.ctx.setTransform(1, 0, 0, 1, 0, 0); // Avoid apply transform twice
|
2015-11-17 01:50:02 +09:00
|
|
|
this.ctx.drawImage(this.transparentCanvas, 0, 0);
|
2016-01-21 10:25:39 +09:00
|
|
|
this.ctx.restore();
|
2015-11-17 01:50:02 +09:00
|
|
|
this.transparentCanvas = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.cachedCanvases.clear();
|
2017-11-02 00:32:22 +09:00
|
|
|
this.webGLContext.clear();
|
2011-10-29 06:37:55 +09:00
|
|
|
|
2013-02-11 03:19:36 +09:00
|
|
|
if (this.imageLayer) {
|
|
|
|
this.imageLayer.endLayout();
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
// Graphics state
|
2012-04-05 05:43:26 +09:00
|
|
|
setLineWidth: function CanvasGraphics_setLineWidth(width) {
|
2012-01-18 13:50:49 +09:00
|
|
|
this.current.lineWidth = width;
|
2011-10-25 08:55:23 +09:00
|
|
|
this.ctx.lineWidth = width;
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
setLineCap: function CanvasGraphics_setLineCap(style) {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.ctx.lineCap = LINE_CAP_STYLES[style];
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
setLineJoin: function CanvasGraphics_setLineJoin(style) {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.ctx.lineJoin = LINE_JOIN_STYLES[style];
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.ctx.miterLimit = limit;
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
|
2012-12-04 23:26:10 +09:00
|
|
|
var ctx = this.ctx;
|
2014-10-27 02:20:04 +09:00
|
|
|
if (ctx.setLineDash !== undefined) {
|
2012-12-04 23:26:10 +09:00
|
|
|
ctx.setLineDash(dashArray);
|
|
|
|
ctx.lineDashOffset = dashPhase;
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2019-03-24 07:05:12 +09:00
|
|
|
setRenderingIntent(intent) {
|
|
|
|
// This operation is ignored since we haven't found a use case for it yet.
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2019-03-24 07:05:12 +09:00
|
|
|
setFlatness(flatness) {
|
|
|
|
// This operation is ignored since we haven't found a use case for it yet.
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
setGState: function CanvasGraphics_setGState(states) {
|
2011-11-03 04:21:45 +09:00
|
|
|
for (var i = 0, ii = states.length; i < ii; i++) {
|
2011-10-25 08:55:23 +09:00
|
|
|
var state = states[i];
|
|
|
|
var key = state[0];
|
|
|
|
var value = state[1];
|
|
|
|
|
|
|
|
switch (key) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "LW":
|
2011-10-25 08:55:23 +09:00
|
|
|
this.setLineWidth(value);
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "LC":
|
2011-10-25 08:55:23 +09:00
|
|
|
this.setLineCap(value);
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "LJ":
|
2011-10-25 08:55:23 +09:00
|
|
|
this.setLineJoin(value);
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "ML":
|
2011-10-25 08:55:23 +09:00
|
|
|
this.setMiterLimit(value);
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "D":
|
2011-10-25 08:55:23 +09:00
|
|
|
this.setDash(value[0], value[1]);
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "RI":
|
2011-10-25 08:55:23 +09:00
|
|
|
this.setRenderingIntent(value);
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "FL":
|
2011-10-25 08:55:23 +09:00
|
|
|
this.setFlatness(value);
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "Font":
|
2013-08-01 03:17:36 +09:00
|
|
|
this.setFont(value[0], value[1]);
|
2011-10-25 08:55:23 +09:00
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "CA":
|
2011-10-29 06:10:10 +09:00
|
|
|
this.current.strokeAlpha = state[1];
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "ca":
|
2011-10-29 06:10:10 +09:00
|
|
|
this.current.fillAlpha = state[1];
|
|
|
|
this.ctx.globalAlpha = state[1];
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "BM":
|
2017-04-11 03:58:02 +09:00
|
|
|
this.ctx.globalCompositeOperation = value;
|
2013-03-12 02:23:47 +09:00
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "SMask":
|
2014-01-24 02:13:32 +09:00
|
|
|
if (this.current.activeSMask) {
|
2016-04-10 08:46:15 +09:00
|
|
|
// If SMask is currrenly used, it needs to be suspended or
|
|
|
|
// finished. Suspend only makes sense when at least one save()
|
|
|
|
// was performed and state needs to be reverted on restore().
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (
|
|
|
|
this.stateStack.length > 0 &&
|
|
|
|
this.stateStack[this.stateStack.length - 1].activeSMask ===
|
|
|
|
this.current.activeSMask
|
|
|
|
) {
|
2016-04-10 08:46:15 +09:00
|
|
|
this.suspendSMaskGroup();
|
|
|
|
} else {
|
|
|
|
this.endSMaskGroup();
|
|
|
|
}
|
2014-01-24 02:13:32 +09:00
|
|
|
}
|
|
|
|
this.current.activeSMask = value ? this.tempSMask : null;
|
|
|
|
if (this.current.activeSMask) {
|
|
|
|
this.beginSMaskGroup();
|
|
|
|
}
|
|
|
|
this.tempSMask = null;
|
|
|
|
break;
|
2020-08-17 15:49:19 +09:00
|
|
|
case "TR":
|
|
|
|
this.current.transferMaps = value;
|
2011-10-25 08:55:23 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-01-24 02:13:32 +09:00
|
|
|
beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
|
|
|
|
var activeSMask = this.current.activeSMask;
|
|
|
|
var drawnWidth = activeSMask.canvas.width;
|
|
|
|
var drawnHeight = activeSMask.canvas.height;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var cacheId = "smaskGroupAt" + this.groupLevel;
|
2015-11-17 01:50:02 +09:00
|
|
|
var scratchCanvas = this.cachedCanvases.getCanvas(
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
cacheId,
|
|
|
|
drawnWidth,
|
|
|
|
drawnHeight,
|
|
|
|
true
|
|
|
|
);
|
2014-01-24 02:13:32 +09:00
|
|
|
|
|
|
|
var currentCtx = this.ctx;
|
|
|
|
var currentTransform = currentCtx.mozCurrentTransform;
|
|
|
|
this.ctx.save();
|
|
|
|
|
|
|
|
var groupCtx = scratchCanvas.context;
|
2014-02-13 22:01:45 +09:00
|
|
|
groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
|
2014-01-24 02:13:32 +09:00
|
|
|
groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
|
|
|
|
groupCtx.transform.apply(groupCtx, currentTransform);
|
|
|
|
|
2016-04-10 08:46:15 +09:00
|
|
|
activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
|
|
|
|
|
2014-01-24 02:13:32 +09:00
|
|
|
copyCtxState(currentCtx, groupCtx);
|
|
|
|
this.ctx = groupCtx;
|
|
|
|
this.setGState([
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
["BM", "source-over"],
|
|
|
|
["ca", 1],
|
|
|
|
["CA", 1],
|
2014-01-24 02:13:32 +09:00
|
|
|
]);
|
|
|
|
this.groupStack.push(currentCtx);
|
|
|
|
this.groupLevel++;
|
|
|
|
},
|
2016-04-10 08:46:15 +09:00
|
|
|
suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
|
|
|
|
// Similar to endSMaskGroup, the intermediate canvas has to be composed
|
|
|
|
// and future ctx state restored.
|
|
|
|
var groupCtx = this.ctx;
|
|
|
|
this.groupLevel--;
|
|
|
|
this.ctx = this.groupStack.pop();
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
composeSMask(
|
|
|
|
this.ctx,
|
|
|
|
this.current.activeSMask,
|
|
|
|
groupCtx,
|
|
|
|
this.webGLContext
|
|
|
|
);
|
2016-04-10 08:46:15 +09:00
|
|
|
this.ctx.restore();
|
|
|
|
this.ctx.save(); // save is needed since SMask will be resumed.
|
|
|
|
copyCtxState(groupCtx, this.ctx);
|
|
|
|
|
|
|
|
// Saving state for resuming.
|
|
|
|
this.current.resumeSMaskCtx = groupCtx;
|
|
|
|
// Transform was changed in the SMask canvas, reflecting this change on
|
|
|
|
// this.ctx.
|
|
|
|
var deltaTransform = Util.transform(
|
|
|
|
this.current.activeSMask.startTransformInverse,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
groupCtx.mozCurrentTransform
|
|
|
|
);
|
2016-04-10 08:46:15 +09:00
|
|
|
this.ctx.transform.apply(this.ctx, deltaTransform);
|
|
|
|
|
|
|
|
// SMask was composed, the results at the groupCtx can be cleared.
|
|
|
|
groupCtx.save();
|
|
|
|
groupCtx.setTransform(1, 0, 0, 1, 0, 0);
|
|
|
|
groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
|
|
|
|
groupCtx.restore();
|
|
|
|
},
|
|
|
|
resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
|
|
|
|
// Resuming state saved by suspendSMaskGroup. We don't need to restore
|
|
|
|
// any groupCtx state since restore() command (the only caller) will do
|
|
|
|
// that for us. See also beginSMaskGroup.
|
|
|
|
var groupCtx = this.current.resumeSMaskCtx;
|
|
|
|
var currentCtx = this.ctx;
|
|
|
|
this.ctx = groupCtx;
|
|
|
|
this.groupStack.push(currentCtx);
|
|
|
|
this.groupLevel++;
|
|
|
|
},
|
2014-01-24 02:13:32 +09:00
|
|
|
endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
|
|
|
|
var groupCtx = this.ctx;
|
|
|
|
this.groupLevel--;
|
|
|
|
this.ctx = this.groupStack.pop();
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
composeSMask(
|
|
|
|
this.ctx,
|
|
|
|
this.current.activeSMask,
|
|
|
|
groupCtx,
|
|
|
|
this.webGLContext
|
|
|
|
);
|
2014-01-24 02:13:32 +09:00
|
|
|
this.ctx.restore();
|
2015-12-04 05:34:12 +09:00
|
|
|
copyCtxState(groupCtx, this.ctx);
|
2016-04-10 08:46:15 +09:00
|
|
|
// Transform was changed in the SMask canvas, reflecting this change on
|
|
|
|
// this.ctx.
|
|
|
|
var deltaTransform = Util.transform(
|
|
|
|
this.current.activeSMask.startTransformInverse,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
groupCtx.mozCurrentTransform
|
|
|
|
);
|
2016-04-10 08:46:15 +09:00
|
|
|
this.ctx.transform.apply(this.ctx, deltaTransform);
|
2014-01-24 02:13:32 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
save: function CanvasGraphics_save() {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.ctx.save();
|
|
|
|
var old = this.current;
|
|
|
|
this.stateStack.push(old);
|
|
|
|
this.current = old.clone();
|
2016-04-10 08:46:15 +09:00
|
|
|
this.current.resumeSMaskCtx = null;
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
restore: function CanvasGraphics_restore() {
|
2016-04-10 08:46:15 +09:00
|
|
|
// SMask was suspended, we just need to resume it.
|
|
|
|
if (this.current.resumeSMaskCtx) {
|
|
|
|
this.resumeSMaskGroup();
|
|
|
|
}
|
|
|
|
// SMask has to be finished once there is no states that are using the
|
|
|
|
// same SMask.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (
|
|
|
|
this.current.activeSMask !== null &&
|
|
|
|
(this.stateStack.length === 0 ||
|
2016-04-10 08:46:15 +09:00
|
|
|
this.stateStack[this.stateStack.length - 1].activeSMask !==
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.current.activeSMask)
|
|
|
|
) {
|
2016-04-10 08:46:15 +09:00
|
|
|
this.endSMaskGroup();
|
|
|
|
}
|
2014-01-24 02:13:32 +09:00
|
|
|
|
2016-04-10 08:46:15 +09:00
|
|
|
if (this.stateStack.length !== 0) {
|
2014-06-02 21:46:59 +09:00
|
|
|
this.current = this.stateStack.pop();
|
2011-10-25 08:55:23 +09:00
|
|
|
this.ctx.restore();
|
2014-04-12 03:19:39 +09:00
|
|
|
|
2015-09-04 00:35:32 +09:00
|
|
|
// Ensure that the clipping path is reset (fixes issue6413.pdf).
|
|
|
|
this.pendingClip = null;
|
|
|
|
|
2018-09-03 03:31:24 +09:00
|
|
|
this._cachedGetSinglePixelWidth = null;
|
2011-10-25 08:55:23 +09:00
|
|
|
}
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.ctx.transform(a, b, c, d, e, f);
|
2014-04-12 03:19:39 +09:00
|
|
|
|
2018-09-03 03:31:24 +09:00
|
|
|
this._cachedGetSinglePixelWidth = null;
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
// Path
|
2014-04-30 23:09:04 +09:00
|
|
|
constructPath: function CanvasGraphics_constructPath(ops, args) {
|
|
|
|
var ctx = this.ctx;
|
2011-10-25 08:55:23 +09:00
|
|
|
var current = this.current;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var x = current.x,
|
|
|
|
y = current.y;
|
2014-04-30 23:09:04 +09:00
|
|
|
for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
|
|
|
|
switch (ops[i] | 0) {
|
2014-06-24 05:07:31 +09:00
|
|
|
case OPS.rectangle:
|
|
|
|
x = args[j++];
|
|
|
|
y = args[j++];
|
|
|
|
var width = args[j++];
|
|
|
|
var height = args[j++];
|
2020-06-30 19:18:06 +09:00
|
|
|
if (width === 0 && ctx.lineWidth < this.getSinglePixelWidth()) {
|
2014-06-24 05:07:31 +09:00
|
|
|
width = this.getSinglePixelWidth();
|
|
|
|
}
|
2020-06-30 19:18:06 +09:00
|
|
|
if (height === 0 && ctx.lineWidth < this.getSinglePixelWidth()) {
|
2014-06-24 05:07:31 +09:00
|
|
|
height = this.getSinglePixelWidth();
|
|
|
|
}
|
|
|
|
var xw = x + width;
|
|
|
|
var yh = y + height;
|
2020-06-30 19:18:06 +09:00
|
|
|
ctx.moveTo(x, y);
|
|
|
|
ctx.lineTo(xw, y);
|
|
|
|
ctx.lineTo(xw, yh);
|
|
|
|
ctx.lineTo(x, yh);
|
|
|
|
ctx.lineTo(x, y);
|
|
|
|
ctx.closePath();
|
2014-06-24 05:07:31 +09:00
|
|
|
break;
|
2014-04-30 23:09:04 +09:00
|
|
|
case OPS.moveTo:
|
|
|
|
x = args[j++];
|
|
|
|
y = args[j++];
|
|
|
|
ctx.moveTo(x, y);
|
|
|
|
break;
|
|
|
|
case OPS.lineTo:
|
|
|
|
x = args[j++];
|
|
|
|
y = args[j++];
|
|
|
|
ctx.lineTo(x, y);
|
|
|
|
break;
|
|
|
|
case OPS.curveTo:
|
|
|
|
x = args[j + 4];
|
|
|
|
y = args[j + 5];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
ctx.bezierCurveTo(
|
|
|
|
args[j],
|
|
|
|
args[j + 1],
|
|
|
|
args[j + 2],
|
|
|
|
args[j + 3],
|
|
|
|
x,
|
|
|
|
y
|
|
|
|
);
|
2014-04-30 23:09:04 +09:00
|
|
|
j += 6;
|
|
|
|
break;
|
|
|
|
case OPS.curveTo2:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
ctx.bezierCurveTo(
|
|
|
|
x,
|
|
|
|
y,
|
|
|
|
args[j],
|
|
|
|
args[j + 1],
|
|
|
|
args[j + 2],
|
|
|
|
args[j + 3]
|
|
|
|
);
|
2014-04-30 23:09:04 +09:00
|
|
|
x = args[j + 2];
|
|
|
|
y = args[j + 3];
|
|
|
|
j += 4;
|
|
|
|
break;
|
|
|
|
case OPS.curveTo3:
|
|
|
|
x = args[j + 2];
|
|
|
|
y = args[j + 3];
|
2014-05-15 23:10:32 +09:00
|
|
|
ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
|
2014-04-30 23:09:04 +09:00
|
|
|
j += 4;
|
|
|
|
break;
|
|
|
|
case OPS.closePath:
|
|
|
|
ctx.closePath();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
current.setCurrentPoint(x, y);
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
closePath: function CanvasGraphics_closePath() {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.ctx.closePath();
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
stroke: function CanvasGraphics_stroke(consumePath) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
consumePath = typeof consumePath !== "undefined" ? consumePath : true;
|
2011-10-25 08:55:23 +09:00
|
|
|
var ctx = this.ctx;
|
|
|
|
var strokeColor = this.current.strokeColor;
|
2011-10-29 06:10:10 +09:00
|
|
|
// For stroke we want to temporarily change the global alpha to the
|
|
|
|
// stroking alpha.
|
|
|
|
ctx.globalAlpha = this.current.strokeAlpha;
|
2020-07-15 07:17:27 +09:00
|
|
|
if (this.contentVisible) {
|
|
|
|
if (
|
|
|
|
strokeColor &&
|
|
|
|
strokeColor.hasOwnProperty("type") &&
|
|
|
|
strokeColor.type === "Pattern"
|
|
|
|
) {
|
|
|
|
// for patterns, we transform to pattern space, calculate
|
|
|
|
// the pattern, call stroke, and restore to user space
|
|
|
|
ctx.save();
|
|
|
|
// The current transform will be replaced while building the pattern,
|
|
|
|
// but the line width needs to be adjusted by the current transform,
|
|
|
|
// so we must scale it. To properly fix this we should be using a
|
|
|
|
// pattern transform instead (see #10955).
|
|
|
|
const transform = ctx.mozCurrentTransform;
|
|
|
|
const scale = Util.singularValueDecompose2dScale(transform)[0];
|
|
|
|
ctx.strokeStyle = strokeColor.getPattern(ctx, this);
|
|
|
|
ctx.lineWidth = Math.max(
|
|
|
|
this.getSinglePixelWidth() * MIN_WIDTH_FACTOR,
|
|
|
|
this.current.lineWidth * scale
|
|
|
|
);
|
|
|
|
ctx.stroke();
|
|
|
|
ctx.restore();
|
|
|
|
} else {
|
|
|
|
// Prevent drawing too thin lines by enforcing a minimum line width.
|
|
|
|
ctx.lineWidth = Math.max(
|
|
|
|
this.getSinglePixelWidth() * MIN_WIDTH_FACTOR,
|
|
|
|
this.current.lineWidth
|
|
|
|
);
|
|
|
|
ctx.stroke();
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
}
|
2014-03-14 21:11:11 +09:00
|
|
|
if (consumePath) {
|
2011-10-29 06:10:10 +09:00
|
|
|
this.consumePath();
|
2014-03-14 21:11:11 +09:00
|
|
|
}
|
2011-10-29 06:10:10 +09:00
|
|
|
// Restore the global alpha to the fill alpha
|
|
|
|
ctx.globalAlpha = this.current.fillAlpha;
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
closeStroke: function CanvasGraphics_closeStroke() {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.closePath();
|
|
|
|
this.stroke();
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
fill: function CanvasGraphics_fill(consumePath) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
consumePath = typeof consumePath !== "undefined" ? consumePath : true;
|
2011-10-25 08:55:23 +09:00
|
|
|
var ctx = this.ctx;
|
|
|
|
var fillColor = this.current.fillColor;
|
2014-10-27 02:20:04 +09:00
|
|
|
var isPatternFill = this.current.patternFill;
|
2013-05-04 08:47:40 +09:00
|
|
|
var needRestore = false;
|
2011-10-25 08:55:23 +09:00
|
|
|
|
2014-10-27 02:20:04 +09:00
|
|
|
if (isPatternFill) {
|
2011-10-25 08:55:23 +09:00
|
|
|
ctx.save();
|
2015-11-25 16:44:06 +09:00
|
|
|
if (this.baseTransform) {
|
|
|
|
ctx.setTransform.apply(ctx, this.baseTransform);
|
|
|
|
}
|
2013-08-16 23:50:48 +09:00
|
|
|
ctx.fillStyle = fillColor.getPattern(ctx, this);
|
2013-05-04 08:47:40 +09:00
|
|
|
needRestore = true;
|
|
|
|
}
|
|
|
|
|
2020-07-15 07:17:27 +09:00
|
|
|
if (this.contentVisible) {
|
|
|
|
if (this.pendingEOFill) {
|
|
|
|
ctx.fill("evenodd");
|
|
|
|
this.pendingEOFill = false;
|
|
|
|
} else {
|
|
|
|
ctx.fill();
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
}
|
2013-05-04 08:47:40 +09:00
|
|
|
|
|
|
|
if (needRestore) {
|
|
|
|
ctx.restore();
|
|
|
|
}
|
|
|
|
if (consumePath) {
|
2011-10-29 06:10:10 +09:00
|
|
|
this.consumePath();
|
2013-05-04 08:47:40 +09:00
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
eoFill: function CanvasGraphics_eoFill() {
|
2013-05-04 08:47:40 +09:00
|
|
|
this.pendingEOFill = true;
|
2011-10-25 08:55:23 +09:00
|
|
|
this.fill();
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
fillStroke: function CanvasGraphics_fillStroke() {
|
2011-10-29 06:10:10 +09:00
|
|
|
this.fill(false);
|
|
|
|
this.stroke(false);
|
2011-10-25 08:55:23 +09:00
|
|
|
|
|
|
|
this.consumePath();
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
eoFillStroke: function CanvasGraphics_eoFillStroke() {
|
2013-05-04 08:47:40 +09:00
|
|
|
this.pendingEOFill = true;
|
2011-10-25 08:55:23 +09:00
|
|
|
this.fillStroke();
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
closeFillStroke: function CanvasGraphics_closeFillStroke() {
|
2011-10-28 20:34:56 +09:00
|
|
|
this.closePath();
|
|
|
|
this.fillStroke();
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
|
2013-05-04 08:47:40 +09:00
|
|
|
this.pendingEOFill = true;
|
2011-10-28 20:34:56 +09:00
|
|
|
this.closePath();
|
2011-10-25 08:55:23 +09:00
|
|
|
this.fillStroke();
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
endPath: function CanvasGraphics_endPath() {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.consumePath();
|
|
|
|
},
|
|
|
|
|
|
|
|
// Clipping
|
2012-04-05 05:43:26 +09:00
|
|
|
clip: function CanvasGraphics_clip() {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.pendingClip = NORMAL_CLIP;
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
eoClip: function CanvasGraphics_eoClip() {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.pendingClip = EO_CLIP;
|
|
|
|
},
|
|
|
|
|
|
|
|
// Text
|
2012-04-05 05:43:26 +09:00
|
|
|
beginText: function CanvasGraphics_beginText() {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.current.textMatrix = IDENTITY_MATRIX;
|
2014-05-24 03:36:54 +09:00
|
|
|
this.current.textMatrixScale = 1;
|
2011-10-25 08:55:23 +09:00
|
|
|
this.current.x = this.current.lineX = 0;
|
|
|
|
this.current.y = this.current.lineY = 0;
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
endText: function CanvasGraphics_endText() {
|
2013-05-16 05:57:27 +09:00
|
|
|
var paths = this.pendingTextPaths;
|
2012-10-13 12:33:56 +09:00
|
|
|
var ctx = this.ctx;
|
2014-05-15 23:25:12 +09:00
|
|
|
if (paths === undefined) {
|
|
|
|
ctx.beginPath();
|
|
|
|
return;
|
|
|
|
}
|
2012-10-13 12:33:56 +09:00
|
|
|
|
|
|
|
ctx.save();
|
2013-05-16 05:57:27 +09:00
|
|
|
ctx.beginPath();
|
|
|
|
for (var i = 0; i < paths.length; i++) {
|
|
|
|
var path = paths[i];
|
|
|
|
ctx.setTransform.apply(ctx, path.transform);
|
|
|
|
ctx.translate(path.x, path.y);
|
|
|
|
path.addToPath(ctx, path.fontSize);
|
|
|
|
}
|
2012-10-13 12:33:56 +09:00
|
|
|
ctx.restore();
|
2013-05-16 05:57:27 +09:00
|
|
|
ctx.clip();
|
|
|
|
ctx.beginPath();
|
|
|
|
delete this.pendingTextPaths;
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.current.charSpacing = spacing;
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.current.wordSpacing = spacing;
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
setHScale: function CanvasGraphics_setHScale(scale) {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.current.textHScale = scale / 100;
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
setLeading: function CanvasGraphics_setLeading(leading) {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.current.leading = -leading;
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
setFont: function CanvasGraphics_setFont(fontRefName, size) {
|
2012-10-29 05:10:34 +09:00
|
|
|
var fontObj = this.commonObjs.get(fontRefName);
|
2012-01-24 05:23:09 +09:00
|
|
|
var current = this.current;
|
2011-10-25 08:55:23 +09:00
|
|
|
|
2014-03-14 21:11:11 +09:00
|
|
|
if (!fontObj) {
|
2017-06-29 05:51:31 +09:00
|
|
|
throw new Error(`Can't find font for ${fontRefName}`);
|
2014-03-14 21:11:11 +09:00
|
|
|
}
|
2012-01-24 05:23:09 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
current.fontMatrix = fontObj.fontMatrix
|
|
|
|
? fontObj.fontMatrix
|
|
|
|
: FONT_IDENTITY_MATRIX;
|
2011-10-25 08:55:23 +09:00
|
|
|
|
2012-01-21 08:41:01 +09:00
|
|
|
// A valid matrix needs all main diagonal elements to be non-zero
|
|
|
|
// This also ensures we bypass FF bugzilla bug #719844.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
|
|
|
|
warn("Invalid font matrix for font " + fontRefName);
|
2012-01-21 04:55:52 +09:00
|
|
|
}
|
|
|
|
|
2012-01-21 08:41:01 +09:00
|
|
|
// The spec for Tf (setFont) says that 'size' specifies the font 'scale',
|
2012-01-24 05:23:09 +09:00
|
|
|
// and in some docs this can be negative (inverted x-y axes).
|
2012-01-21 08:41:01 +09:00
|
|
|
if (size < 0) {
|
|
|
|
size = -size;
|
2013-01-04 09:39:06 +09:00
|
|
|
current.fontDirection = -1;
|
|
|
|
} else {
|
|
|
|
current.fontDirection = 1;
|
2012-01-21 08:41:01 +09:00
|
|
|
}
|
|
|
|
|
2011-10-25 08:55:23 +09:00
|
|
|
this.current.font = fontObj;
|
|
|
|
this.current.fontSize = size;
|
|
|
|
|
2014-05-20 06:27:54 +09:00
|
|
|
if (fontObj.isType3Font) {
|
2012-02-05 03:45:18 +09:00
|
|
|
return; // we don't need ctx.font for Type3 fonts
|
2014-03-14 21:11:11 +09:00
|
|
|
}
|
2012-02-05 03:45:18 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var name = fontObj.loadedName || "sans-serif";
|
2020-01-13 03:47:13 +09:00
|
|
|
|
|
|
|
let bold = "normal";
|
|
|
|
if (fontObj.black) {
|
|
|
|
bold = "900";
|
|
|
|
} else if (fontObj.bold) {
|
|
|
|
bold = "bold";
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var italic = fontObj.italic ? "italic" : "normal";
|
2018-12-30 22:57:45 +09:00
|
|
|
var typeface = `"${name}", ${fontObj.fallbackName}`;
|
2012-02-05 03:45:18 +09:00
|
|
|
|
2012-02-14 13:35:42 +09:00
|
|
|
// Some font backends cannot handle fonts below certain size.
|
|
|
|
// Keeping the font at minimal size and using the fontSizeScale to change
|
|
|
|
// the current transformation matrix before the fillText/strokeText.
|
|
|
|
// See https://bugzilla.mozilla.org/show_bug.cgi?id=726227
|
2020-01-13 03:47:13 +09:00
|
|
|
let browserFontSize = size;
|
|
|
|
if (size < MIN_FONT_SIZE) {
|
|
|
|
browserFontSize = MIN_FONT_SIZE;
|
|
|
|
} else if (size > MAX_FONT_SIZE) {
|
|
|
|
browserFontSize = MAX_FONT_SIZE;
|
|
|
|
}
|
2014-10-25 10:48:31 +09:00
|
|
|
this.current.fontSizeScale = size / browserFontSize;
|
2012-02-05 03:45:18 +09:00
|
|
|
|
2018-12-30 22:57:45 +09:00
|
|
|
this.ctx.font = `${italic} ${bold} ${browserFontSize}px ${typeface}`;
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
|
2011-12-03 07:52:31 +09:00
|
|
|
this.current.textRenderingMode = mode;
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
setTextRise: function CanvasGraphics_setTextRise(rise) {
|
2012-08-02 05:10:48 +09:00
|
|
|
this.current.textRise = rise;
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
moveText: function CanvasGraphics_moveText(x, y) {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.current.x = this.current.lineX += x;
|
|
|
|
this.current.y = this.current.lineY += y;
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.setLeading(-y);
|
|
|
|
this.moveText(x, y);
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.current.textMatrix = [a, b, c, d, e, f];
|
2014-05-24 03:36:54 +09:00
|
|
|
this.current.textMatrixScale = Math.sqrt(a * a + b * b);
|
2011-10-25 08:55:23 +09:00
|
|
|
|
|
|
|
this.current.x = this.current.lineX = 0;
|
|
|
|
this.current.y = this.current.lineY = 0;
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
nextLine: function CanvasGraphics_nextLine() {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.moveText(0, this.current.leading);
|
|
|
|
},
|
2011-12-02 04:11:17 +09:00
|
|
|
|
2017-11-29 02:40:22 +09:00
|
|
|
paintChar(character, x, y, patternTransform) {
|
2013-05-16 05:57:27 +09:00
|
|
|
var ctx = this.ctx;
|
|
|
|
var current = this.current;
|
|
|
|
var font = current.font;
|
|
|
|
var textRenderingMode = current.textRenderingMode;
|
2014-05-24 03:36:54 +09:00
|
|
|
var fontSize = current.fontSize / current.fontSizeScale;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var fillStrokeMode =
|
|
|
|
textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
|
|
|
|
var isAddToPathSet = !!(
|
|
|
|
textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG
|
|
|
|
);
|
2020-04-23 20:04:57 +09:00
|
|
|
const patternFill = current.patternFill && !font.missingFile;
|
2013-05-16 05:57:27 +09:00
|
|
|
|
|
|
|
var addToPath;
|
2017-11-29 02:40:22 +09:00
|
|
|
if (font.disableFontFace || isAddToPathSet || patternFill) {
|
2013-08-20 08:33:20 +09:00
|
|
|
addToPath = font.getPathGenerator(this.commonObjs, character);
|
2013-05-16 05:57:27 +09:00
|
|
|
}
|
|
|
|
|
2017-11-29 02:40:22 +09:00
|
|
|
if (font.disableFontFace || patternFill) {
|
2013-05-16 05:57:27 +09:00
|
|
|
ctx.save();
|
|
|
|
ctx.translate(x, y);
|
|
|
|
ctx.beginPath();
|
|
|
|
addToPath(ctx, fontSize);
|
2017-11-29 02:40:22 +09:00
|
|
|
if (patternTransform) {
|
|
|
|
ctx.setTransform.apply(ctx, patternTransform);
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (
|
|
|
|
fillStrokeMode === TextRenderingMode.FILL ||
|
|
|
|
fillStrokeMode === TextRenderingMode.FILL_STROKE
|
|
|
|
) {
|
2013-05-16 05:57:27 +09:00
|
|
|
ctx.fill();
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (
|
|
|
|
fillStrokeMode === TextRenderingMode.STROKE ||
|
|
|
|
fillStrokeMode === TextRenderingMode.FILL_STROKE
|
|
|
|
) {
|
2013-05-16 05:57:27 +09:00
|
|
|
ctx.stroke();
|
|
|
|
}
|
|
|
|
ctx.restore();
|
|
|
|
} else {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (
|
|
|
|
fillStrokeMode === TextRenderingMode.FILL ||
|
|
|
|
fillStrokeMode === TextRenderingMode.FILL_STROKE
|
|
|
|
) {
|
2013-05-16 05:57:27 +09:00
|
|
|
ctx.fillText(character, x, y);
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (
|
|
|
|
fillStrokeMode === TextRenderingMode.STROKE ||
|
|
|
|
fillStrokeMode === TextRenderingMode.FILL_STROKE
|
|
|
|
) {
|
2013-05-16 05:57:27 +09:00
|
|
|
ctx.strokeText(character, x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isAddToPathSet) {
|
|
|
|
var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
|
|
|
|
paths.push({
|
|
|
|
transform: ctx.mozCurrentTransform,
|
2017-04-25 23:17:18 +09:00
|
|
|
x,
|
|
|
|
y,
|
|
|
|
fontSize,
|
|
|
|
addToPath,
|
2013-05-16 05:57:27 +09:00
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-01-15 08:31:23 +09:00
|
|
|
get isFontSubpixelAAEnabled() {
|
|
|
|
// Checks if anti-aliasing is enabled when scaled text is painted.
|
|
|
|
// On Windows GDI scaled fonts looks bad.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const { context: ctx } = this.cachedCanvases.getCanvas(
|
|
|
|
"isFontSubpixelAAEnabled",
|
|
|
|
10,
|
|
|
|
10
|
|
|
|
);
|
2014-01-15 08:31:23 +09:00
|
|
|
ctx.scale(1.5, 1);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
ctx.fillText("I", 0, 10);
|
2014-01-15 08:31:23 +09:00
|
|
|
var data = ctx.getImageData(0, 0, 10, 10).data;
|
|
|
|
var enabled = false;
|
|
|
|
for (var i = 3; i < data.length; i += 4) {
|
|
|
|
if (data[i] > 0 && data[i] < 255) {
|
|
|
|
enabled = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
return shadow(this, "isFontSubpixelAAEnabled", enabled);
|
2014-01-15 08:31:23 +09:00
|
|
|
},
|
|
|
|
|
2014-04-10 08:44:07 +09:00
|
|
|
showText: function CanvasGraphics_showText(glyphs) {
|
2011-10-25 08:55:23 +09:00
|
|
|
var current = this.current;
|
|
|
|
var font = current.font;
|
2014-05-24 03:36:54 +09:00
|
|
|
if (font.isType3Font) {
|
|
|
|
return this.showType3Text(glyphs);
|
|
|
|
}
|
|
|
|
|
2011-10-25 08:55:23 +09:00
|
|
|
var fontSize = current.fontSize;
|
2014-05-24 03:36:54 +09:00
|
|
|
if (fontSize === 0) {
|
2019-05-10 19:54:06 +09:00
|
|
|
return undefined;
|
2014-05-24 03:36:54 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
var ctx = this.ctx;
|
2012-02-05 03:45:18 +09:00
|
|
|
var fontSizeScale = current.fontSizeScale;
|
2011-10-25 08:55:23 +09:00
|
|
|
var charSpacing = current.charSpacing;
|
|
|
|
var wordSpacing = current.wordSpacing;
|
2014-05-24 03:36:54 +09:00
|
|
|
var fontDirection = current.fontDirection;
|
|
|
|
var textHScale = current.textHScale * fontDirection;
|
2011-10-25 08:55:23 +09:00
|
|
|
var glyphsLength = glyphs.length;
|
2013-02-08 21:29:22 +09:00
|
|
|
var vertical = font.vertical;
|
2015-08-28 20:42:01 +09:00
|
|
|
var spacingDir = vertical ? 1 : -1;
|
2013-02-08 21:29:22 +09:00
|
|
|
var defaultVMetrics = font.defaultVMetrics;
|
2014-05-24 03:36:54 +09:00
|
|
|
var widthAdvanceScale = fontSize * current.fontMatrix[0];
|
2011-11-09 05:27:03 +09:00
|
|
|
|
2014-05-24 03:36:54 +09:00
|
|
|
var simpleFillText =
|
|
|
|
current.textRenderingMode === TextRenderingMode.FILL &&
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
!font.disableFontFace &&
|
|
|
|
!current.patternFill;
|
2014-03-30 20:36:21 +09:00
|
|
|
|
2014-05-24 03:36:54 +09:00
|
|
|
ctx.save();
|
2017-11-29 02:40:22 +09:00
|
|
|
let patternTransform;
|
Apply Patterns, if necessary, when rendering text
Currently we're not applying Patterns for text, but only for graphics.
This patch is unfortunately not a complete solution, but rather a step on the way, since there are still some PDF files where the Patterns look more like a solid colour, rather than the intended gradient.
I've been unable to fix these issues completely, and I've not managed to determine if the remaining issues are caused either by the pattern code, the canvas code, or perhaps both.
However, given that even this simple patch improves the current situation quite a bit, I figured that it couldn't hurt to submit it as-is.
- Fixes 5804.
- Fixes 6130.
- Improves 3988 a lot, since the text is now visible. However, it looks like the text is *one* solid colour, instead of the correct gradient.
- Improves 5432, since the text is no longer gray. (This file also suffers from the same problem as the previous one.)
2015-12-30 01:57:10 +09:00
|
|
|
if (current.patternFill) {
|
2017-11-29 02:40:22 +09:00
|
|
|
// TODO: Patterns are not applied correctly to text if a non-embedded
|
|
|
|
// font is used. E.g. issue 8111 and ShowText-ShadingPattern.pdf.
|
|
|
|
ctx.save();
|
2020-01-24 17:48:21 +09:00
|
|
|
const pattern = current.fillColor.getPattern(ctx, this);
|
2017-11-29 02:40:22 +09:00
|
|
|
patternTransform = ctx.mozCurrentTransform;
|
|
|
|
ctx.restore();
|
|
|
|
ctx.fillStyle = pattern;
|
Apply Patterns, if necessary, when rendering text
Currently we're not applying Patterns for text, but only for graphics.
This patch is unfortunately not a complete solution, but rather a step on the way, since there are still some PDF files where the Patterns look more like a solid colour, rather than the intended gradient.
I've been unable to fix these issues completely, and I've not managed to determine if the remaining issues are caused either by the pattern code, the canvas code, or perhaps both.
However, given that even this simple patch improves the current situation quite a bit, I figured that it couldn't hurt to submit it as-is.
- Fixes 5804.
- Fixes 6130.
- Improves 3988 a lot, since the text is now visible. However, it looks like the text is *one* solid colour, instead of the correct gradient.
- Improves 5432, since the text is no longer gray. (This file also suffers from the same problem as the previous one.)
2015-12-30 01:57:10 +09:00
|
|
|
}
|
2017-11-29 02:40:22 +09:00
|
|
|
ctx.transform.apply(ctx, current.textMatrix);
|
|
|
|
ctx.translate(current.x, current.y + current.textRise);
|
Apply Patterns, if necessary, when rendering text
Currently we're not applying Patterns for text, but only for graphics.
This patch is unfortunately not a complete solution, but rather a step on the way, since there are still some PDF files where the Patterns look more like a solid colour, rather than the intended gradient.
I've been unable to fix these issues completely, and I've not managed to determine if the remaining issues are caused either by the pattern code, the canvas code, or perhaps both.
However, given that even this simple patch improves the current situation quite a bit, I figured that it couldn't hurt to submit it as-is.
- Fixes 5804.
- Fixes 6130.
- Improves 3988 a lot, since the text is now visible. However, it looks like the text is *one* solid colour, instead of the correct gradient.
- Improves 5432, since the text is no longer gray. (This file also suffers from the same problem as the previous one.)
2015-12-30 01:57:10 +09:00
|
|
|
|
2014-05-24 03:36:54 +09:00
|
|
|
if (fontDirection > 0) {
|
|
|
|
ctx.scale(textHScale, -1);
|
|
|
|
} else {
|
2011-12-02 11:56:26 +09:00
|
|
|
ctx.scale(textHScale, 1);
|
2014-05-24 03:36:54 +09:00
|
|
|
}
|
2011-12-13 12:32:20 +09:00
|
|
|
|
2014-05-24 03:36:54 +09:00
|
|
|
var lineWidth = current.lineWidth;
|
|
|
|
var scale = current.textMatrixScale;
|
|
|
|
if (scale === 0 || lineWidth === 0) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var fillStrokeMode =
|
|
|
|
current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
|
|
|
|
if (
|
|
|
|
fillStrokeMode === TextRenderingMode.STROKE ||
|
|
|
|
fillStrokeMode === TextRenderingMode.FILL_STROKE
|
|
|
|
) {
|
2018-09-03 03:31:24 +09:00
|
|
|
this._cachedGetSinglePixelWidth = null;
|
2014-04-12 03:19:39 +09:00
|
|
|
lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
|
|
|
|
}
|
2014-05-24 03:36:54 +09:00
|
|
|
} else {
|
|
|
|
lineWidth /= scale;
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
|
2014-08-01 19:39:56 +09:00
|
|
|
if (fontSizeScale !== 1.0) {
|
2014-05-24 03:36:54 +09:00
|
|
|
ctx.scale(fontSizeScale, fontSizeScale);
|
|
|
|
lineWidth /= fontSizeScale;
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
|
2014-05-24 03:36:54 +09:00
|
|
|
ctx.lineWidth = lineWidth;
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var x = 0,
|
|
|
|
i;
|
2014-05-24 03:36:54 +09:00
|
|
|
for (i = 0; i < glyphsLength; ++i) {
|
|
|
|
var glyph = glyphs[i];
|
2015-11-02 23:54:15 +09:00
|
|
|
if (isNum(glyph)) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
x += (spacingDir * glyph * fontSize) / 1000;
|
2014-05-24 03:36:54 +09:00
|
|
|
continue;
|
2011-10-25 08:55:23 +09:00
|
|
|
}
|
2012-01-18 13:50:49 +09:00
|
|
|
|
2014-05-24 03:36:54 +09:00
|
|
|
var restoreNeeded = false;
|
2015-11-02 23:54:15 +09:00
|
|
|
var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
|
2014-05-24 03:36:54 +09:00
|
|
|
var character = glyph.fontChar;
|
|
|
|
var accent = glyph.accent;
|
|
|
|
var scaledX, scaledY, scaledAccentX, scaledAccentY;
|
|
|
|
var width = glyph.width;
|
|
|
|
if (vertical) {
|
|
|
|
var vmetric, vx, vy;
|
|
|
|
vmetric = glyph.vmetric || defaultVMetrics;
|
|
|
|
vx = glyph.vmetric ? vmetric[1] : width * 0.5;
|
|
|
|
vx = -vx * widthAdvanceScale;
|
|
|
|
vy = vmetric[2] * widthAdvanceScale;
|
|
|
|
|
|
|
|
width = vmetric ? -vmetric[0] : width;
|
|
|
|
scaledX = vx / fontSizeScale;
|
|
|
|
scaledY = (x + vy) / fontSizeScale;
|
2014-03-14 21:11:11 +09:00
|
|
|
} else {
|
2014-05-24 03:36:54 +09:00
|
|
|
scaledX = x / fontSizeScale;
|
|
|
|
scaledY = 0;
|
2014-03-14 21:11:11 +09:00
|
|
|
}
|
2012-01-18 13:50:49 +09:00
|
|
|
|
2015-11-18 04:21:27 +09:00
|
|
|
if (font.remeasure && width > 0) {
|
|
|
|
// Some standard fonts may not have the exact width: rescale per
|
|
|
|
// character if measured width is greater than expected glyph width
|
|
|
|
// and subpixel-aa is enabled, otherwise just center the glyph.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var measuredWidth =
|
|
|
|
((ctx.measureText(character).width * 1000) / fontSize) *
|
|
|
|
fontSizeScale;
|
2015-11-18 04:21:27 +09:00
|
|
|
if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
|
|
|
|
var characterScaleX = width / measuredWidth;
|
|
|
|
restoreNeeded = true;
|
|
|
|
ctx.save();
|
|
|
|
ctx.scale(characterScaleX, 1);
|
|
|
|
scaledX /= characterScaleX;
|
|
|
|
} else if (width !== measuredWidth) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
scaledX +=
|
|
|
|
(((width - measuredWidth) / 2000) * fontSize) / fontSizeScale;
|
2015-11-18 04:21:27 +09:00
|
|
|
}
|
2012-02-14 12:12:55 +09:00
|
|
|
}
|
|
|
|
|
2016-02-25 03:48:02 +09:00
|
|
|
// Only attempt to draw the glyph if it is actually in the embedded font
|
|
|
|
// file or if there isn't a font file so the fallback font is shown.
|
2020-07-15 07:17:27 +09:00
|
|
|
if (this.contentVisible && (glyph.isInFont || font.missingFile)) {
|
2016-02-25 03:48:02 +09:00
|
|
|
if (simpleFillText && !accent) {
|
|
|
|
// common case
|
|
|
|
ctx.fillText(character, scaledX, scaledY);
|
|
|
|
} else {
|
2017-11-29 02:40:22 +09:00
|
|
|
this.paintChar(character, scaledX, scaledY, patternTransform);
|
2016-02-25 03:48:02 +09:00
|
|
|
if (accent) {
|
2020-08-24 02:48:10 +09:00
|
|
|
scaledAccentX =
|
|
|
|
scaledX + (fontSize * accent.offset.x) / fontSizeScale;
|
|
|
|
scaledAccentY =
|
|
|
|
scaledY - (fontSize * accent.offset.y) / fontSizeScale;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.paintChar(
|
|
|
|
accent.fontChar,
|
|
|
|
scaledAccentX,
|
|
|
|
scaledAccentY,
|
|
|
|
patternTransform
|
|
|
|
);
|
2016-02-25 03:48:02 +09:00
|
|
|
}
|
2014-02-12 03:27:09 +09:00
|
|
|
}
|
2014-05-24 03:36:54 +09:00
|
|
|
}
|
2014-02-12 03:27:09 +09:00
|
|
|
|
2020-01-27 11:03:27 +09:00
|
|
|
var charWidth;
|
|
|
|
if (vertical) {
|
|
|
|
charWidth = width * widthAdvanceScale - spacing * fontDirection;
|
|
|
|
} else {
|
|
|
|
charWidth = width * widthAdvanceScale + spacing * fontDirection;
|
|
|
|
}
|
2014-05-24 03:36:54 +09:00
|
|
|
x += charWidth;
|
2011-11-30 06:02:12 +09:00
|
|
|
|
2014-05-24 03:36:54 +09:00
|
|
|
if (restoreNeeded) {
|
|
|
|
ctx.restore();
|
2011-10-25 08:55:23 +09:00
|
|
|
}
|
|
|
|
}
|
2014-05-24 03:36:54 +09:00
|
|
|
if (vertical) {
|
2020-01-31 23:22:54 +09:00
|
|
|
current.y -= x;
|
2014-05-24 03:36:54 +09:00
|
|
|
} else {
|
|
|
|
current.x += x * textHScale;
|
|
|
|
}
|
|
|
|
ctx.restore();
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2014-05-24 03:36:54 +09:00
|
|
|
|
|
|
|
showType3Text: function CanvasGraphics_showType3Text(glyphs) {
|
|
|
|
// Type3 fonts - each glyph is a "mini-PDF"
|
|
|
|
var ctx = this.ctx;
|
2011-10-25 08:55:23 +09:00
|
|
|
var current = this.current;
|
2011-12-13 12:32:20 +09:00
|
|
|
var font = current.font;
|
2011-10-25 08:55:23 +09:00
|
|
|
var fontSize = current.fontSize;
|
2014-05-24 03:36:54 +09:00
|
|
|
var fontDirection = current.fontDirection;
|
2015-08-28 20:42:01 +09:00
|
|
|
var spacingDir = font.vertical ? 1 : -1;
|
2014-05-24 03:36:54 +09:00
|
|
|
var charSpacing = current.charSpacing;
|
|
|
|
var wordSpacing = current.wordSpacing;
|
|
|
|
var textHScale = current.textHScale * fontDirection;
|
|
|
|
var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
|
|
|
|
var glyphsLength = glyphs.length;
|
2014-10-19 05:29:21 +09:00
|
|
|
var isTextInvisible =
|
|
|
|
current.textRenderingMode === TextRenderingMode.INVISIBLE;
|
2015-08-28 20:42:01 +09:00
|
|
|
var i, glyph, width, spacingLength;
|
2011-11-30 06:02:12 +09:00
|
|
|
|
2014-10-19 05:29:21 +09:00
|
|
|
if (isTextInvisible || fontSize === 0) {
|
2014-05-24 03:36:54 +09:00
|
|
|
return;
|
|
|
|
}
|
2018-09-03 03:31:24 +09:00
|
|
|
this._cachedGetSinglePixelWidth = null;
|
2011-10-29 06:37:55 +09:00
|
|
|
|
2014-05-24 03:36:54 +09:00
|
|
|
ctx.save();
|
|
|
|
ctx.transform.apply(ctx, current.textMatrix);
|
|
|
|
ctx.translate(current.x, current.y);
|
|
|
|
|
2014-08-19 07:57:52 +09:00
|
|
|
ctx.scale(textHScale, fontDirection);
|
2014-05-24 03:36:54 +09:00
|
|
|
|
|
|
|
for (i = 0; i < glyphsLength; ++i) {
|
|
|
|
glyph = glyphs[i];
|
2015-11-02 23:54:15 +09:00
|
|
|
if (isNum(glyph)) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
spacingLength = (spacingDir * glyph * fontSize) / 1000;
|
2014-05-24 03:36:54 +09:00
|
|
|
this.ctx.translate(spacingLength, 0);
|
|
|
|
current.x += spacingLength * textHScale;
|
|
|
|
continue;
|
2013-02-08 21:29:22 +09:00
|
|
|
}
|
2014-05-24 03:36:54 +09:00
|
|
|
|
2015-11-02 23:54:15 +09:00
|
|
|
var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
|
2014-07-24 21:59:21 +09:00
|
|
|
var operatorList = font.charProcOperatorList[glyph.operatorListId];
|
|
|
|
if (!operatorList) {
|
2017-04-30 06:36:43 +09:00
|
|
|
warn(`Type3 character "${glyph.operatorListId}" is not available.`);
|
2014-07-24 21:59:21 +09:00
|
|
|
continue;
|
|
|
|
}
|
2020-07-15 07:17:27 +09:00
|
|
|
if (this.contentVisible) {
|
|
|
|
this.processingType3 = glyph;
|
|
|
|
this.save();
|
|
|
|
ctx.scale(fontSize, fontSize);
|
|
|
|
ctx.transform.apply(ctx, fontMatrix);
|
|
|
|
this.executeOperatorList(operatorList);
|
|
|
|
this.restore();
|
|
|
|
}
|
2014-05-24 03:36:54 +09:00
|
|
|
|
|
|
|
var transformed = Util.applyTransform([glyph.width, 0], fontMatrix);
|
2015-11-02 23:54:15 +09:00
|
|
|
width = transformed[0] * fontSize + spacing;
|
2014-05-24 03:36:54 +09:00
|
|
|
|
|
|
|
ctx.translate(width, 0);
|
|
|
|
current.x += width * textHScale;
|
2012-09-20 05:17:01 +09:00
|
|
|
}
|
2014-05-24 03:36:54 +09:00
|
|
|
ctx.restore();
|
|
|
|
this.processingType3 = null;
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
// Type3 fonts
|
2012-04-05 05:43:26 +09:00
|
|
|
setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
|
2011-10-25 08:55:23 +09:00
|
|
|
// We can safely ignore this since the width should be the same
|
|
|
|
// as the width in the Widths array.
|
|
|
|
},
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(
|
|
|
|
xWidth,
|
|
|
|
yWidth,
|
|
|
|
llx,
|
|
|
|
lly,
|
|
|
|
urx,
|
|
|
|
ury
|
|
|
|
) {
|
2011-10-25 08:55:23 +09:00
|
|
|
// TODO According to the spec we're also suppose to ignore any operators
|
|
|
|
// that set color or include images while processing this type3 font.
|
2014-06-24 05:07:31 +09:00
|
|
|
this.ctx.rect(llx, lly, urx - llx, ury - lly);
|
2011-10-25 08:55:23 +09:00
|
|
|
this.clip();
|
|
|
|
this.endPath();
|
|
|
|
},
|
|
|
|
|
|
|
|
// Color
|
2014-05-22 02:47:42 +09:00
|
|
|
getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
|
2014-04-09 04:48:16 +09:00
|
|
|
var pattern;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (IR[0] === "TilingPattern") {
|
2014-05-22 02:47:42 +09:00
|
|
|
var color = IR[1];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var baseTransform =
|
|
|
|
this.baseTransform || this.ctx.mozCurrentTransform.slice();
|
2015-11-22 01:32:47 +09:00
|
|
|
var canvasGraphicsFactory = {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
createCanvasGraphics: ctx => {
|
|
|
|
return new CanvasGraphics(
|
|
|
|
ctx,
|
|
|
|
this.commonObjs,
|
|
|
|
this.objs,
|
|
|
|
this.canvasFactory,
|
|
|
|
this.webGLContext
|
|
|
|
);
|
Fix inconsistent spacing and trailing commas in objects in remaining `src/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/display/canvas.js b/src/display/canvas.js
index 5739f6f2..4216b2d2 100644
--- a/src/display/canvas.js
+++ b/src/display/canvas.js
@@ -2071,7 +2071,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var map = [];
for (var i = 0, ii = positions.length; i < ii; i += 2) {
map.push({ transform: [scaleX, 0, 0, scaleY, positions[i],
- positions[i + 1]], x: 0, y: 0, w: width, h: height, });
+ positions[i + 1]], x: 0, y: 0, w: width, h: height, });
}
this.paintInlineImageXObjectGroup(imgData, map);
},
diff --git a/src/display/svg.js b/src/display/svg.js
index 9eb05dfa..2aa21482 100644
--- a/src/display/svg.js
+++ b/src/display/svg.js
@@ -458,7 +458,11 @@ SVGGraphics = (function SVGGraphicsClosure() {
for (var x = 0; x < fnArrayLen; x++) {
var fnId = fnArray[x];
- opList.push({ 'fnId': fnId, 'fn': REVOPS[fnId], 'args': argsArray[x], });
+ opList.push({
+ 'fnId': fnId,
+ 'fn': REVOPS[fnId],
+ 'args': argsArray[x],
+ });
}
return opListToTree(opList);
},
```
2017-06-02 18:26:37 +09:00
|
|
|
},
|
2015-11-22 01:32:47 +09:00
|
|
|
};
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
pattern = new TilingPattern(
|
|
|
|
IR,
|
|
|
|
color,
|
|
|
|
this.ctx,
|
|
|
|
canvasGraphicsFactory,
|
|
|
|
baseTransform
|
|
|
|
);
|
2011-10-25 08:55:23 +09:00
|
|
|
} else {
|
2014-04-09 04:48:16 +09:00
|
|
|
pattern = getShadingPatternFromIR(IR);
|
2011-10-25 08:55:23 +09:00
|
|
|
}
|
|
|
|
return pattern;
|
|
|
|
},
|
2017-01-20 00:26:32 +09:00
|
|
|
setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
|
2014-05-22 02:47:42 +09:00
|
|
|
this.current.strokeColor = this.getColorN_Pattern(arguments);
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2017-01-20 00:26:32 +09:00
|
|
|
setFillColorN: function CanvasGraphics_setFillColorN() {
|
2014-05-22 02:47:42 +09:00
|
|
|
this.current.fillColor = this.getColorN_Pattern(arguments);
|
2014-10-27 02:20:04 +09:00
|
|
|
this.current.patternFill = true;
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
|
2014-10-28 05:30:47 +09:00
|
|
|
var color = Util.makeCssRgb(r, g, b);
|
2011-10-25 08:55:23 +09:00
|
|
|
this.ctx.strokeStyle = color;
|
|
|
|
this.current.strokeColor = color;
|
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
|
2014-10-28 05:30:47 +09:00
|
|
|
var color = Util.makeCssRgb(r, g, b);
|
2011-10-25 08:55:23 +09:00
|
|
|
this.ctx.fillStyle = color;
|
|
|
|
this.current.fillColor = color;
|
2014-10-27 02:20:04 +09:00
|
|
|
this.current.patternFill = false;
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
shadingFill: function CanvasGraphics_shadingFill(patternIR) {
|
2020-07-15 07:17:27 +09:00
|
|
|
if (!this.contentVisible) {
|
|
|
|
return;
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
var ctx = this.ctx;
|
|
|
|
|
|
|
|
this.save();
|
2014-01-26 03:18:22 +09:00
|
|
|
var pattern = getShadingPatternFromIR(patternIR);
|
2014-01-27 22:17:14 +09:00
|
|
|
ctx.fillStyle = pattern.getPattern(ctx, this, true);
|
2011-10-25 08:55:23 +09:00
|
|
|
|
|
|
|
var inv = ctx.mozCurrentTransformInverse;
|
|
|
|
if (inv) {
|
|
|
|
var canvas = ctx.canvas;
|
|
|
|
var width = canvas.width;
|
|
|
|
var height = canvas.height;
|
|
|
|
|
|
|
|
var bl = Util.applyTransform([0, 0], inv);
|
2011-12-07 21:42:01 +09:00
|
|
|
var br = Util.applyTransform([0, height], inv);
|
|
|
|
var ul = Util.applyTransform([width, 0], inv);
|
|
|
|
var ur = Util.applyTransform([width, height], inv);
|
2011-10-25 08:55:23 +09:00
|
|
|
|
|
|
|
var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
|
|
|
|
var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
|
|
|
|
var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
|
|
|
|
var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
|
|
|
|
|
|
|
|
this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
|
|
|
|
} else {
|
|
|
|
// HACK to draw the gradient onto an infinite rectangle.
|
|
|
|
// PDF gradients are drawn across the entire image while
|
|
|
|
// Canvas only allows gradients to be drawn in a rectangle
|
|
|
|
// The following bug should allow us to remove this.
|
|
|
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=664884
|
|
|
|
|
|
|
|
this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.restore();
|
|
|
|
},
|
|
|
|
|
|
|
|
// Images
|
2012-04-05 05:43:26 +09:00
|
|
|
beginInlineImage: function CanvasGraphics_beginInlineImage() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
unreachable("Should not call beginInlineImage");
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
beginImageData: function CanvasGraphics_beginImageData() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
unreachable("Should not call beginImageData");
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(
|
|
|
|
matrix,
|
|
|
|
bbox
|
|
|
|
) {
|
2020-07-15 07:17:27 +09:00
|
|
|
if (!this.contentVisible) {
|
|
|
|
return;
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
this.save();
|
2013-07-23 06:52:44 +09:00
|
|
|
this.baseTransformStack.push(this.baseTransform);
|
2011-10-25 08:55:23 +09:00
|
|
|
|
2017-09-02 03:27:13 +09:00
|
|
|
if (Array.isArray(matrix) && matrix.length === 6) {
|
2011-10-25 08:55:23 +09:00
|
|
|
this.transform.apply(this, matrix);
|
2014-03-14 21:11:11 +09:00
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
|
2013-07-23 06:52:44 +09:00
|
|
|
this.baseTransform = this.ctx.mozCurrentTransform;
|
|
|
|
|
2018-10-16 22:23:14 +09:00
|
|
|
if (bbox) {
|
2011-10-25 08:55:23 +09:00
|
|
|
var width = bbox[2] - bbox[0];
|
|
|
|
var height = bbox[3] - bbox[1];
|
2014-06-24 05:07:31 +09:00
|
|
|
this.ctx.rect(bbox[0], bbox[1], width, height);
|
2011-10-25 08:55:23 +09:00
|
|
|
this.clip();
|
|
|
|
this.endPath();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
|
2020-07-15 07:17:27 +09:00
|
|
|
if (!this.contentVisible) {
|
|
|
|
return;
|
|
|
|
}
|
2014-01-17 22:16:52 +09:00
|
|
|
this.restore();
|
2013-07-23 06:52:44 +09:00
|
|
|
this.baseTransform = this.baseTransformStack.pop();
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
|
|
|
|
2013-03-13 09:20:38 +09:00
|
|
|
beginGroup: function CanvasGraphics_beginGroup(group) {
|
2020-07-15 07:17:27 +09:00
|
|
|
if (!this.contentVisible) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-13 09:20:38 +09:00
|
|
|
this.save();
|
|
|
|
var currentCtx = this.ctx;
|
|
|
|
// TODO non-isolated groups - according to Rik at adobe non-isolated
|
|
|
|
// group results aren't usually that different and they even have tools
|
2016-07-17 21:33:41 +09:00
|
|
|
// that ignore this setting. Notes from Rik on implementing:
|
2013-03-13 09:20:38 +09:00
|
|
|
// - When you encounter an transparency group, create a new canvas with
|
|
|
|
// the dimensions of the bbox
|
|
|
|
// - copy the content from the previous canvas to the new canvas
|
|
|
|
// - draw as usual
|
|
|
|
// - remove the backdrop alpha:
|
|
|
|
// alphaNew = 1 - (1 - alpha)/(1 - alphaBackdrop) with 'alpha' the alpha
|
|
|
|
// value of your transparency group and 'alphaBackdrop' the alpha of the
|
|
|
|
// backdrop
|
|
|
|
// - remove background color:
|
|
|
|
// colorNew = color - alphaNew *colorBackdrop /(1 - alphaNew)
|
|
|
|
if (!group.isolated) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
info("TODO: Support non-isolated groups.");
|
2013-03-13 09:20:38 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO knockout - supposedly possible with the clever use of compositing
|
|
|
|
// modes.
|
|
|
|
if (group.knockout) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
warn("Knockout groups not supported.");
|
2013-03-13 09:20:38 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
var currentTransform = currentCtx.mozCurrentTransform;
|
|
|
|
if (group.matrix) {
|
|
|
|
currentCtx.transform.apply(currentCtx, group.matrix);
|
|
|
|
}
|
2017-07-20 21:04:54 +09:00
|
|
|
if (!group.bbox) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Error("Bounding box is required.");
|
2017-07-20 21:04:54 +09:00
|
|
|
}
|
2013-03-13 09:20:38 +09:00
|
|
|
|
|
|
|
// Based on the current transform figure out how big the bounding box
|
|
|
|
// will actually be.
|
|
|
|
var bounds = Util.getAxialAlignedBoundingBox(
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
group.bbox,
|
|
|
|
currentCtx.mozCurrentTransform
|
|
|
|
);
|
2013-10-11 04:41:11 +09:00
|
|
|
// Clip the bounding box to the current canvas.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var canvasBounds = [
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
currentCtx.canvas.width,
|
|
|
|
currentCtx.canvas.height,
|
|
|
|
];
|
2013-11-05 02:16:33 +09:00
|
|
|
bounds = Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
|
2013-03-13 09:20:38 +09:00
|
|
|
// Use ceil in case we're between sizes so we don't create canvas that is
|
2013-04-12 03:19:42 +09:00
|
|
|
// too small and make the canvas at least 1x1 pixels.
|
2014-02-13 22:01:45 +09:00
|
|
|
var offsetX = Math.floor(bounds[0]);
|
|
|
|
var offsetY = Math.floor(bounds[1]);
|
|
|
|
var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
|
|
|
|
var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var scaleX = 1,
|
|
|
|
scaleY = 1;
|
2014-02-13 22:01:45 +09:00
|
|
|
if (drawnWidth > MAX_GROUP_SIZE) {
|
|
|
|
scaleX = drawnWidth / MAX_GROUP_SIZE;
|
|
|
|
drawnWidth = MAX_GROUP_SIZE;
|
|
|
|
}
|
|
|
|
if (drawnHeight > MAX_GROUP_SIZE) {
|
|
|
|
scaleY = drawnHeight / MAX_GROUP_SIZE;
|
|
|
|
drawnHeight = MAX_GROUP_SIZE;
|
|
|
|
}
|
2013-04-12 03:19:42 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var cacheId = "groupAt" + this.groupLevel;
|
2014-01-24 02:13:32 +09:00
|
|
|
if (group.smask) {
|
|
|
|
// Using two cache entries is case if masks are used one after another.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
cacheId += "_smask_" + (this.smaskCounter++ % 2);
|
2014-01-24 02:13:32 +09:00
|
|
|
}
|
2015-11-17 01:50:02 +09:00
|
|
|
var scratchCanvas = this.cachedCanvases.getCanvas(
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
cacheId,
|
|
|
|
drawnWidth,
|
|
|
|
drawnHeight,
|
|
|
|
true
|
|
|
|
);
|
2013-08-16 23:50:48 +09:00
|
|
|
var groupCtx = scratchCanvas.context;
|
2014-01-24 02:13:32 +09:00
|
|
|
|
2013-03-13 09:20:38 +09:00
|
|
|
// Since we created a new canvas that is just the size of the bounding box
|
|
|
|
// we have to translate the group ctx.
|
2014-02-13 22:01:45 +09:00
|
|
|
groupCtx.scale(1 / scaleX, 1 / scaleY);
|
2013-03-13 09:20:38 +09:00
|
|
|
groupCtx.translate(-offsetX, -offsetY);
|
|
|
|
groupCtx.transform.apply(groupCtx, currentTransform);
|
|
|
|
|
2014-01-24 02:13:32 +09:00
|
|
|
if (group.smask) {
|
|
|
|
// Saving state and cached mask to be used in setGState.
|
|
|
|
this.smaskStack.push({
|
|
|
|
canvas: scratchCanvas.canvas,
|
|
|
|
context: groupCtx,
|
2017-04-25 23:17:18 +09:00
|
|
|
offsetX,
|
|
|
|
offsetY,
|
|
|
|
scaleX,
|
|
|
|
scaleY,
|
2014-01-24 02:13:32 +09:00
|
|
|
subtype: group.smask.subtype,
|
2015-12-05 03:52:45 +09:00
|
|
|
backdrop: group.smask.backdrop,
|
2016-04-10 08:46:15 +09:00
|
|
|
transferMap: group.smask.transferMap || null,
|
|
|
|
startTransformInverse: null, // used during suspend operation
|
2014-01-24 02:13:32 +09:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// Setup the current ctx so when the group is popped we draw it at the
|
|
|
|
// right location.
|
|
|
|
currentCtx.setTransform(1, 0, 0, 1, 0, 0);
|
|
|
|
currentCtx.translate(offsetX, offsetY);
|
2014-02-13 22:01:45 +09:00
|
|
|
currentCtx.scale(scaleX, scaleY);
|
2014-01-24 02:13:32 +09:00
|
|
|
}
|
2013-03-13 09:20:38 +09:00
|
|
|
// The transparency group inherits all off the current graphics state
|
|
|
|
// except the blend mode, soft mask, and alpha constants.
|
|
|
|
copyCtxState(currentCtx, groupCtx);
|
|
|
|
this.ctx = groupCtx;
|
|
|
|
this.setGState([
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
["BM", "source-over"],
|
|
|
|
["ca", 1],
|
|
|
|
["CA", 1],
|
2013-03-13 09:20:38 +09:00
|
|
|
]);
|
|
|
|
this.groupStack.push(currentCtx);
|
2013-08-16 23:50:48 +09:00
|
|
|
this.groupLevel++;
|
2016-04-10 08:46:15 +09:00
|
|
|
|
|
|
|
// Reseting mask state, masks will be applied on restore of the group.
|
|
|
|
this.current.activeSMask = null;
|
2013-03-13 09:20:38 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
endGroup: function CanvasGraphics_endGroup(group) {
|
2020-07-15 07:17:27 +09:00
|
|
|
if (!this.contentVisible) {
|
|
|
|
return;
|
|
|
|
}
|
2013-08-16 23:50:48 +09:00
|
|
|
this.groupLevel--;
|
2013-03-13 09:20:38 +09:00
|
|
|
var groupCtx = this.ctx;
|
|
|
|
this.ctx = this.groupStack.pop();
|
|
|
|
// Turn off image smoothing to avoid sub pixel interpolation which can
|
|
|
|
// look kind of blurry for some pdfs.
|
2014-05-15 23:25:12 +09:00
|
|
|
if (this.ctx.imageSmoothingEnabled !== undefined) {
|
2013-03-13 09:20:38 +09:00
|
|
|
this.ctx.imageSmoothingEnabled = false;
|
|
|
|
} else {
|
|
|
|
this.ctx.mozImageSmoothingEnabled = false;
|
|
|
|
}
|
2014-01-24 02:13:32 +09:00
|
|
|
if (group.smask) {
|
|
|
|
this.tempSMask = this.smaskStack.pop();
|
|
|
|
} else {
|
|
|
|
this.ctx.drawImage(groupCtx.canvas, 0, 0);
|
|
|
|
}
|
2013-03-13 09:20:38 +09:00
|
|
|
this.restore();
|
|
|
|
},
|
|
|
|
|
2013-05-29 07:12:35 +09:00
|
|
|
beginAnnotations: function CanvasGraphics_beginAnnotations() {
|
|
|
|
this.save();
|
2015-12-28 22:10:30 +09:00
|
|
|
if (this.baseTransform) {
|
|
|
|
this.ctx.setTransform.apply(this.ctx, this.baseTransform);
|
|
|
|
}
|
2013-05-29 07:12:35 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
endAnnotations: function CanvasGraphics_endAnnotations() {
|
|
|
|
this.restore();
|
|
|
|
},
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
beginAnnotation: function CanvasGraphics_beginAnnotation(
|
|
|
|
rect,
|
|
|
|
transform,
|
|
|
|
matrix
|
|
|
|
) {
|
2013-03-14 04:24:55 +09:00
|
|
|
this.save();
|
2017-05-24 00:57:26 +09:00
|
|
|
resetCtxToDefault(this.ctx);
|
|
|
|
this.current = new CanvasExtraState();
|
2013-03-14 04:24:55 +09:00
|
|
|
|
2017-09-02 03:27:13 +09:00
|
|
|
if (Array.isArray(rect) && rect.length === 4) {
|
2013-03-14 04:24:55 +09:00
|
|
|
var width = rect[2] - rect[0];
|
|
|
|
var height = rect[3] - rect[1];
|
2014-06-24 05:07:31 +09:00
|
|
|
this.ctx.rect(rect[0], rect[1], width, height);
|
2013-03-14 04:24:55 +09:00
|
|
|
this.clip();
|
|
|
|
this.endPath();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.transform.apply(this, transform);
|
|
|
|
this.transform.apply(this, matrix);
|
|
|
|
},
|
|
|
|
|
|
|
|
endAnnotation: function CanvasGraphics_endAnnotation() {
|
|
|
|
this.restore();
|
|
|
|
},
|
|
|
|
|
2013-05-31 09:42:26 +09:00
|
|
|
paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
|
2020-07-15 07:17:27 +09:00
|
|
|
if (!this.contentVisible) {
|
|
|
|
return;
|
|
|
|
}
|
2012-12-08 03:19:43 +09:00
|
|
|
var ctx = this.ctx;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var width = img.width,
|
|
|
|
height = img.height;
|
2014-10-27 02:20:04 +09:00
|
|
|
var fillColor = this.current.fillColor;
|
|
|
|
var isPatternFill = this.current.patternFill;
|
2013-05-31 09:42:26 +09:00
|
|
|
|
2013-05-11 12:50:14 +09:00
|
|
|
var glyph = this.processingType3;
|
|
|
|
|
2014-10-27 02:20:04 +09:00
|
|
|
if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
|
2013-05-11 12:50:14 +09:00
|
|
|
if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
glyph.compiled = compileType3Glyph({ data: img.data, width, height });
|
2013-05-11 12:50:14 +09:00
|
|
|
} else {
|
|
|
|
glyph.compiled = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (glyph && glyph.compiled) {
|
|
|
|
glyph.compiled(ctx);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var maskCanvas = this.cachedCanvases.getCanvas(
|
|
|
|
"maskCanvas",
|
|
|
|
width,
|
|
|
|
height
|
|
|
|
);
|
2013-08-16 23:50:48 +09:00
|
|
|
var maskCtx = maskCanvas.context;
|
2013-05-31 09:42:26 +09:00
|
|
|
maskCtx.save();
|
2013-05-11 12:50:14 +09:00
|
|
|
|
2014-01-14 11:08:39 +09:00
|
|
|
putBinaryImageMask(maskCtx, img);
|
2013-05-31 09:42:26 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
maskCtx.globalCompositeOperation = "source-in";
|
2011-10-25 08:55:23 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
maskCtx.fillStyle = isPatternFill
|
|
|
|
? fillColor.getPattern(maskCtx, this)
|
|
|
|
: fillColor;
|
2013-05-31 09:42:26 +09:00
|
|
|
maskCtx.fillRect(0, 0, width, height);
|
2011-10-25 08:55:23 +09:00
|
|
|
|
2013-05-31 09:42:26 +09:00
|
|
|
maskCtx.restore();
|
2011-10-25 08:55:23 +09:00
|
|
|
|
2013-08-16 23:50:48 +09:00
|
|
|
this.paintInlineImageXObject(maskCanvas.canvas);
|
2012-12-08 03:19:43 +09:00
|
|
|
},
|
|
|
|
|
2020-06-20 18:34:41 +09:00
|
|
|
paintImageMaskXObjectRepeat(
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
imgData,
|
|
|
|
scaleX,
|
2020-06-20 18:34:41 +09:00
|
|
|
skewX = 0,
|
|
|
|
skewY = 0,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
scaleY,
|
|
|
|
positions
|
|
|
|
) {
|
2020-07-15 07:17:27 +09:00
|
|
|
if (!this.contentVisible) {
|
|
|
|
return;
|
|
|
|
}
|
2014-02-25 00:59:02 +09:00
|
|
|
var width = imgData.width;
|
|
|
|
var height = imgData.height;
|
2014-10-27 02:20:04 +09:00
|
|
|
var fillColor = this.current.fillColor;
|
|
|
|
var isPatternFill = this.current.patternFill;
|
2014-02-25 00:59:02 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var maskCanvas = this.cachedCanvases.getCanvas(
|
|
|
|
"maskCanvas",
|
|
|
|
width,
|
|
|
|
height
|
|
|
|
);
|
2014-02-25 00:59:02 +09:00
|
|
|
var maskCtx = maskCanvas.context;
|
|
|
|
maskCtx.save();
|
|
|
|
|
|
|
|
putBinaryImageMask(maskCtx, imgData);
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
maskCtx.globalCompositeOperation = "source-in";
|
2014-02-25 00:59:02 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
maskCtx.fillStyle = isPatternFill
|
|
|
|
? fillColor.getPattern(maskCtx, this)
|
|
|
|
: fillColor;
|
2014-02-25 00:59:02 +09:00
|
|
|
maskCtx.fillRect(0, 0, width, height);
|
|
|
|
|
|
|
|
maskCtx.restore();
|
|
|
|
|
2014-10-27 02:20:04 +09:00
|
|
|
var ctx = this.ctx;
|
2014-02-25 00:59:02 +09:00
|
|
|
for (var i = 0, ii = positions.length; i < ii; i += 2) {
|
|
|
|
ctx.save();
|
2020-06-20 18:34:41 +09:00
|
|
|
ctx.transform(
|
|
|
|
scaleX,
|
|
|
|
skewX,
|
|
|
|
skewY,
|
|
|
|
scaleY,
|
|
|
|
positions[i],
|
|
|
|
positions[i + 1]
|
|
|
|
);
|
2014-02-25 00:59:02 +09:00
|
|
|
ctx.scale(1, -1);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
|
2014-02-25 00:59:02 +09:00
|
|
|
ctx.restore();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(
|
|
|
|
images
|
|
|
|
) {
|
2020-07-15 07:17:27 +09:00
|
|
|
if (!this.contentVisible) {
|
|
|
|
return;
|
|
|
|
}
|
2012-12-08 03:19:43 +09:00
|
|
|
var ctx = this.ctx;
|
2013-05-31 09:42:26 +09:00
|
|
|
|
2014-10-27 02:20:04 +09:00
|
|
|
var fillColor = this.current.fillColor;
|
|
|
|
var isPatternFill = this.current.patternFill;
|
2012-12-08 03:19:43 +09:00
|
|
|
for (var i = 0, ii = images.length; i < ii; i++) {
|
|
|
|
var image = images[i];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var width = image.width,
|
|
|
|
height = image.height;
|
|
|
|
|
|
|
|
var maskCanvas = this.cachedCanvases.getCanvas(
|
|
|
|
"maskCanvas",
|
|
|
|
width,
|
|
|
|
height
|
|
|
|
);
|
2013-08-16 23:50:48 +09:00
|
|
|
var maskCtx = maskCanvas.context;
|
2013-05-31 09:42:26 +09:00
|
|
|
maskCtx.save();
|
2012-12-08 03:19:43 +09:00
|
|
|
|
2014-01-14 11:08:39 +09:00
|
|
|
putBinaryImageMask(maskCtx, image);
|
2012-12-08 03:19:43 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
maskCtx.globalCompositeOperation = "source-in";
|
2012-12-08 03:19:43 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
maskCtx.fillStyle = isPatternFill
|
|
|
|
? fillColor.getPattern(maskCtx, this)
|
|
|
|
: fillColor;
|
2013-05-31 09:42:26 +09:00
|
|
|
maskCtx.fillRect(0, 0, width, height);
|
|
|
|
|
|
|
|
maskCtx.restore();
|
2012-12-08 03:19:43 +09:00
|
|
|
|
|
|
|
ctx.save();
|
|
|
|
ctx.transform.apply(ctx, image.transform);
|
|
|
|
ctx.scale(1, -1);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
|
2012-12-08 03:19:43 +09:00
|
|
|
ctx.restore();
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
|
2020-07-15 07:17:27 +09:00
|
|
|
if (!this.contentVisible) {
|
|
|
|
return;
|
|
|
|
}
|
Attempt to cache repeated images at the document, rather than the page, level (issue 11878)
Currently image resources, as opposed to e.g. font resources, are handled exclusively on a page-specific basis. Generally speaking this makes sense, since pages are separate from each other, however there's PDF documents where many (or even all) pages actually references exactly the same image resources (through the XRef table). Hence, in some cases, we're decoding the *same* images over and over for every page which is obviously slow and wasting both CPU and memory resources better used elsewhere.[1]
Obviously we cannot simply treat all image resources as-if they're used throughout the entire PDF document, since that would end up increasing memory usage too much.[2]
However, by introducing a `GlobalImageCache` in the worker we can track image resources that appear on more than one page. Hence we can switch image resources from being page-specific to being document-specific, once the image resource has been seen on more than a certain number of pages.
In many cases, such as e.g. the referenced issue, this patch will thus lead to reduced memory usage for image resources. Scrolling through all pages of the document, there's now only a few main-thread copies of the same image data, as opposed to one for each rendered page (i.e. there could theoretically be *twenty* copies of the image data).
While this obviously benefit both CPU and memory usage in this case, for *very* large image data this patch *may* possibly increase persistent main-thread memory usage a tiny bit. Thus to avoid negatively affecting memory usage too much in general, particularly on the main-thread, the `GlobalImageCache` will *only* cache a certain number of image resources at the document level and simply fallback to the default behaviour.
Unfortunately the asynchronous nature of the code, with ranged/streamed loading of data, actually makes all of this much more complicated than if all data could be assumed to be immediately available.[3]
*Please note:* The patch will lead to *small* movement in some existing test-cases, since we're now using the built-in PDF.js JPEG decoder more. This was done in order to simplify the overall implementation, especially on the main-thread, by limiting it to only the `OPS.paintImageXObject` operator.
---
[1] There's e.g. PDF documents that use the same image as background on all pages.
[2] Given that data stored in the `commonObjs`, on the main-thread, are only cleared manually through `PDFDocumentProxy.cleanup`. This as opposed to data stored in the `objs` of each page, which is automatically removed when the page is cleaned-up e.g. by being evicted from the cache in the default viewer.
[3] If the latter case were true, we could simply check for repeat images *before* parsing started and thus avoid handling *any* duplicate image resources.
2020-05-18 21:17:56 +09:00
|
|
|
const imgData = objId.startsWith("g_")
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
? this.commonObjs.get(objId)
|
|
|
|
: this.objs.get(objId);
|
2014-02-24 23:00:08 +09:00
|
|
|
if (!imgData) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
warn("Dependent image isn't ready yet");
|
2014-04-15 05:22:35 +09:00
|
|
|
return;
|
2014-02-24 23:00:08 +09:00
|
|
|
}
|
2011-12-16 08:13:48 +09:00
|
|
|
|
2012-12-08 03:19:43 +09:00
|
|
|
this.paintInlineImageXObject(imgData);
|
2012-12-05 02:36:42 +09:00
|
|
|
},
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(
|
|
|
|
objId,
|
|
|
|
scaleX,
|
|
|
|
scaleY,
|
|
|
|
positions
|
|
|
|
) {
|
2020-07-15 07:17:27 +09:00
|
|
|
if (!this.contentVisible) {
|
|
|
|
return;
|
|
|
|
}
|
Attempt to cache repeated images at the document, rather than the page, level (issue 11878)
Currently image resources, as opposed to e.g. font resources, are handled exclusively on a page-specific basis. Generally speaking this makes sense, since pages are separate from each other, however there's PDF documents where many (or even all) pages actually references exactly the same image resources (through the XRef table). Hence, in some cases, we're decoding the *same* images over and over for every page which is obviously slow and wasting both CPU and memory resources better used elsewhere.[1]
Obviously we cannot simply treat all image resources as-if they're used throughout the entire PDF document, since that would end up increasing memory usage too much.[2]
However, by introducing a `GlobalImageCache` in the worker we can track image resources that appear on more than one page. Hence we can switch image resources from being page-specific to being document-specific, once the image resource has been seen on more than a certain number of pages.
In many cases, such as e.g. the referenced issue, this patch will thus lead to reduced memory usage for image resources. Scrolling through all pages of the document, there's now only a few main-thread copies of the same image data, as opposed to one for each rendered page (i.e. there could theoretically be *twenty* copies of the image data).
While this obviously benefit both CPU and memory usage in this case, for *very* large image data this patch *may* possibly increase persistent main-thread memory usage a tiny bit. Thus to avoid negatively affecting memory usage too much in general, particularly on the main-thread, the `GlobalImageCache` will *only* cache a certain number of image resources at the document level and simply fallback to the default behaviour.
Unfortunately the asynchronous nature of the code, with ranged/streamed loading of data, actually makes all of this much more complicated than if all data could be assumed to be immediately available.[3]
*Please note:* The patch will lead to *small* movement in some existing test-cases, since we're now using the built-in PDF.js JPEG decoder more. This was done in order to simplify the overall implementation, especially on the main-thread, by limiting it to only the `OPS.paintImageXObject` operator.
---
[1] There's e.g. PDF documents that use the same image as background on all pages.
[2] Given that data stored in the `commonObjs`, on the main-thread, are only cleared manually through `PDFDocumentProxy.cleanup`. This as opposed to data stored in the `objs` of each page, which is automatically removed when the page is cleaned-up e.g. by being evicted from the cache in the default viewer.
[3] If the latter case were true, we could simply check for repeat images *before* parsing started and thus avoid handling *any* duplicate image resources.
2020-05-18 21:17:56 +09:00
|
|
|
const imgData = objId.startsWith("g_")
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
? this.commonObjs.get(objId)
|
|
|
|
: this.objs.get(objId);
|
2014-02-25 00:59:02 +09:00
|
|
|
if (!imgData) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
warn("Dependent image isn't ready yet");
|
2014-04-15 05:22:35 +09:00
|
|
|
return;
|
2014-02-25 00:59:02 +09:00
|
|
|
}
|
2014-02-24 23:00:08 +09:00
|
|
|
|
2014-02-25 00:59:02 +09:00
|
|
|
var width = imgData.width;
|
|
|
|
var height = imgData.height;
|
|
|
|
var map = [];
|
|
|
|
for (var i = 0, ii = positions.length; i < ii; i += 2) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
map.push({
|
|
|
|
transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]],
|
|
|
|
x: 0,
|
|
|
|
y: 0,
|
|
|
|
w: width,
|
|
|
|
h: height,
|
|
|
|
});
|
2014-02-25 00:59:02 +09:00
|
|
|
}
|
|
|
|
this.paintInlineImageXObjectGroup(imgData, map);
|
2014-02-24 23:00:08 +09:00
|
|
|
},
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(
|
|
|
|
imgData
|
|
|
|
) {
|
2020-07-15 07:17:27 +09:00
|
|
|
if (!this.contentVisible) {
|
|
|
|
return;
|
|
|
|
}
|
2012-12-05 02:36:42 +09:00
|
|
|
var width = imgData.width;
|
|
|
|
var height = imgData.height;
|
2011-10-25 08:55:23 +09:00
|
|
|
var ctx = this.ctx;
|
2013-05-31 09:42:26 +09:00
|
|
|
|
2012-12-05 02:36:42 +09:00
|
|
|
this.save();
|
2011-10-25 08:55:23 +09:00
|
|
|
// scale the image to the unit square
|
2012-12-05 02:36:42 +09:00
|
|
|
ctx.scale(1 / width, -1 / height);
|
2011-10-25 08:55:23 +09:00
|
|
|
|
2012-12-05 02:36:42 +09:00
|
|
|
var currentTransform = ctx.mozCurrentTransformInverse;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var a = currentTransform[0],
|
|
|
|
b = currentTransform[1];
|
2013-05-31 09:42:26 +09:00
|
|
|
var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var c = currentTransform[2],
|
|
|
|
d = currentTransform[3];
|
2013-05-31 09:42:26 +09:00
|
|
|
var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
|
|
|
|
|
2014-04-09 04:48:16 +09:00
|
|
|
var imgToPaint, tmpCanvas;
|
2018-03-20 18:16:07 +09:00
|
|
|
// typeof check is needed due to node.js support, see issue #8489
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (
|
|
|
|
(typeof HTMLElement === "function" && imgData instanceof HTMLElement) ||
|
|
|
|
!imgData.data
|
|
|
|
) {
|
2013-05-31 09:42:26 +09:00
|
|
|
imgToPaint = imgData;
|
2012-12-05 02:36:42 +09:00
|
|
|
} else {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
|
2013-08-16 23:50:48 +09:00
|
|
|
var tmpCtx = tmpCanvas.context;
|
2020-08-17 15:49:19 +09:00
|
|
|
putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
|
2013-08-16 23:50:48 +09:00
|
|
|
imgToPaint = tmpCanvas.canvas;
|
2013-05-31 09:42:26 +09:00
|
|
|
}
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var paintWidth = width,
|
|
|
|
paintHeight = height;
|
|
|
|
var tmpCanvasId = "prescale1";
|
[api-minor] Decode all JPEG images with the built-in PDF.js decoder in `src/core/jpg.js`
Currently some JPEG images are decoded by the built-in PDF.js decoder in `src/core/jpg.js`, while others attempt to use the browser JPEG decoder. This inconsistency seem unfortunate for a number of reasons:
- It adds, compared to the other image formats supported in the PDF specification, a fair amount of code/complexity to the image handling in the PDF.js library.
- The PDF specification support JPEG images with features, e.g. certain ColorSpaces, that browsers are unable to decode natively. Hence, determining if a JPEG image is possible to decode natively in the browser require a non-trivial amount of parsing. In particular, we're parsing (part of) the raw JPEG data to extract certain marker data and we also need to parse the ColorSpace for the JPEG image.
- While some JPEG images may, for all intents and purposes, appear to be natively supported there's still cases where the browser may fail to decode some JPEG images. In order to support those cases, we've had to implement a fallback to the PDF.js JPEG decoder if there's any issues during the native decoding. This also means that it's no longer possible to simply send the JPEG image to the main-thread and continue parsing, but you now need to actually wait for the main-thread to indicate success/failure first.
In practice this means that there's a code-path where the worker-thread is forced to wait for the main-thread, while the reverse should *always* be the case.
- The native decoding, for anything except the *simplest* of JPEG images, result in increased peak memory usage because there's a handful of short-lived copies of the JPEG data (see PR 11707).
Furthermore this also leads to data being *parsed* on the main-thread, rather than the worker-thread, which you usually want to avoid for e.g. performance and UI-reponsiveness reasons.
- Not all environments, e.g. Node.js, fully support native JPEG decoding. This has, historically, lead to some issues and support requests.
- Different browsers may use different JPEG decoders, possibly leading to images being rendered slightly differently depending on the platform/browser where the PDF.js library is used.
Originally the implementation in `src/core/jpg.js` were unable to handle all of the JPEG images in the test-suite, but over the last couple of years I've fixed (hopefully) all of those issues.
At this point in time, there's two kinds of failure with this patch:
- Changes which are basically imperceivable to the naked eye, where some pixels in the images are essentially off-by-one (in all components), which could probably be attributed to things such as different rounding behaviour in the browser/PDF.js JPEG decoder.
This type of "failure" accounts for the *vast* majority of the total number of changes in the reference tests.
- Changes where the JPEG images now looks *ever so slightly* blurrier than with the native browser decoder. For quite some time I've just assumed that this pointed to a general deficiency in the `src/core/jpg.js` implementation, however I've discovered when comparing two viewers side-by-side that the differences vanish at higher zoom levels (usually around 200% is enough).
Basically if you disable [this downscaling in canvas.js](https://github.com/mozilla/pdf.js/blob/8fb82e939cf0c8618a4e775ff17fc96f726872b5/src/display/canvas.js#L2356-L2395), which is what happens when zooming in, the differences simply vanish!
Hence I'm pretty satisfied that there's no significant problems with the `src/core/jpg.js` implementation, and the problems are rather tied to the general quality of the downscaling algorithm used. It could even be seen as a positive that *all* images now share the same downscaling behaviour, since this actually fixes one old bug; see issue 7041.
2020-01-20 20:10:16 +09:00
|
|
|
// Vertical or horizontal scaling shall not be more than 2 to not lose the
|
2013-05-31 09:42:26 +09:00
|
|
|
// pixels during drawImage operation, painting on the temporary canvas(es)
|
[api-minor] Decode all JPEG images with the built-in PDF.js decoder in `src/core/jpg.js`
Currently some JPEG images are decoded by the built-in PDF.js decoder in `src/core/jpg.js`, while others attempt to use the browser JPEG decoder. This inconsistency seem unfortunate for a number of reasons:
- It adds, compared to the other image formats supported in the PDF specification, a fair amount of code/complexity to the image handling in the PDF.js library.
- The PDF specification support JPEG images with features, e.g. certain ColorSpaces, that browsers are unable to decode natively. Hence, determining if a JPEG image is possible to decode natively in the browser require a non-trivial amount of parsing. In particular, we're parsing (part of) the raw JPEG data to extract certain marker data and we also need to parse the ColorSpace for the JPEG image.
- While some JPEG images may, for all intents and purposes, appear to be natively supported there's still cases where the browser may fail to decode some JPEG images. In order to support those cases, we've had to implement a fallback to the PDF.js JPEG decoder if there's any issues during the native decoding. This also means that it's no longer possible to simply send the JPEG image to the main-thread and continue parsing, but you now need to actually wait for the main-thread to indicate success/failure first.
In practice this means that there's a code-path where the worker-thread is forced to wait for the main-thread, while the reverse should *always* be the case.
- The native decoding, for anything except the *simplest* of JPEG images, result in increased peak memory usage because there's a handful of short-lived copies of the JPEG data (see PR 11707).
Furthermore this also leads to data being *parsed* on the main-thread, rather than the worker-thread, which you usually want to avoid for e.g. performance and UI-reponsiveness reasons.
- Not all environments, e.g. Node.js, fully support native JPEG decoding. This has, historically, lead to some issues and support requests.
- Different browsers may use different JPEG decoders, possibly leading to images being rendered slightly differently depending on the platform/browser where the PDF.js library is used.
Originally the implementation in `src/core/jpg.js` were unable to handle all of the JPEG images in the test-suite, but over the last couple of years I've fixed (hopefully) all of those issues.
At this point in time, there's two kinds of failure with this patch:
- Changes which are basically imperceivable to the naked eye, where some pixels in the images are essentially off-by-one (in all components), which could probably be attributed to things such as different rounding behaviour in the browser/PDF.js JPEG decoder.
This type of "failure" accounts for the *vast* majority of the total number of changes in the reference tests.
- Changes where the JPEG images now looks *ever so slightly* blurrier than with the native browser decoder. For quite some time I've just assumed that this pointed to a general deficiency in the `src/core/jpg.js` implementation, however I've discovered when comparing two viewers side-by-side that the differences vanish at higher zoom levels (usually around 200% is enough).
Basically if you disable [this downscaling in canvas.js](https://github.com/mozilla/pdf.js/blob/8fb82e939cf0c8618a4e775ff17fc96f726872b5/src/display/canvas.js#L2356-L2395), which is what happens when zooming in, the differences simply vanish!
Hence I'm pretty satisfied that there's no significant problems with the `src/core/jpg.js` implementation, and the problems are rather tied to the general quality of the downscaling algorithm used. It could even be seen as a positive that *all* images now share the same downscaling behaviour, since this actually fixes one old bug; see issue 7041.
2020-01-20 20:10:16 +09:00
|
|
|
// that are twice smaller in size.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
while (
|
|
|
|
(widthScale > 2 && paintWidth > 1) ||
|
|
|
|
(heightScale > 2 && paintHeight > 1)
|
|
|
|
) {
|
|
|
|
var newWidth = paintWidth,
|
|
|
|
newHeight = paintHeight;
|
2013-05-31 09:42:26 +09:00
|
|
|
if (widthScale > 2 && paintWidth > 1) {
|
|
|
|
newWidth = Math.ceil(paintWidth / 2);
|
|
|
|
widthScale /= paintWidth / newWidth;
|
|
|
|
}
|
|
|
|
if (heightScale > 2 && paintHeight > 1) {
|
|
|
|
newHeight = Math.ceil(paintHeight / 2);
|
|
|
|
heightScale /= paintHeight / newHeight;
|
2012-12-05 02:36:42 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
tmpCanvas = this.cachedCanvases.getCanvas(
|
|
|
|
tmpCanvasId,
|
|
|
|
newWidth,
|
|
|
|
newHeight
|
|
|
|
);
|
2013-08-16 23:50:48 +09:00
|
|
|
tmpCtx = tmpCanvas.context;
|
2013-05-31 09:42:26 +09:00
|
|
|
tmpCtx.clearRect(0, 0, newWidth, newHeight);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
tmpCtx.drawImage(
|
|
|
|
imgToPaint,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
paintWidth,
|
|
|
|
paintHeight,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
newWidth,
|
|
|
|
newHeight
|
|
|
|
);
|
2013-08-16 23:50:48 +09:00
|
|
|
imgToPaint = tmpCanvas.canvas;
|
2013-05-31 09:42:26 +09:00
|
|
|
paintWidth = newWidth;
|
|
|
|
paintHeight = newHeight;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
tmpCanvasId = tmpCanvasId === "prescale1" ? "prescale2" : "prescale1";
|
|
|
|
}
|
|
|
|
ctx.drawImage(
|
|
|
|
imgToPaint,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
paintWidth,
|
|
|
|
paintHeight,
|
|
|
|
0,
|
|
|
|
-height,
|
|
|
|
width,
|
|
|
|
height
|
|
|
|
);
|
2013-02-11 03:19:36 +09:00
|
|
|
|
|
|
|
if (this.imageLayer) {
|
|
|
|
var position = this.getCanvasPosition(0, -height);
|
|
|
|
this.imageLayer.appendImage({
|
2017-04-25 23:17:18 +09:00
|
|
|
imgData,
|
2013-02-11 03:19:36 +09:00
|
|
|
left: position[0],
|
|
|
|
top: position[1],
|
2013-02-12 19:30:19 +09:00
|
|
|
width: width / currentTransform[0],
|
Fix inconsistent spacing and trailing commas in objects in remaining `src/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/display/canvas.js b/src/display/canvas.js
index 5739f6f2..4216b2d2 100644
--- a/src/display/canvas.js
+++ b/src/display/canvas.js
@@ -2071,7 +2071,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var map = [];
for (var i = 0, ii = positions.length; i < ii; i += 2) {
map.push({ transform: [scaleX, 0, 0, scaleY, positions[i],
- positions[i + 1]], x: 0, y: 0, w: width, h: height, });
+ positions[i + 1]], x: 0, y: 0, w: width, h: height, });
}
this.paintInlineImageXObjectGroup(imgData, map);
},
diff --git a/src/display/svg.js b/src/display/svg.js
index 9eb05dfa..2aa21482 100644
--- a/src/display/svg.js
+++ b/src/display/svg.js
@@ -458,7 +458,11 @@ SVGGraphics = (function SVGGraphicsClosure() {
for (var x = 0; x < fnArrayLen; x++) {
var fnId = fnArray[x];
- opList.push({ 'fnId': fnId, 'fn': REVOPS[fnId], 'args': argsArray[x], });
+ opList.push({
+ 'fnId': fnId,
+ 'fn': REVOPS[fnId],
+ 'args': argsArray[x],
+ });
}
return opListToTree(opList);
},
```
2017-06-02 18:26:37 +09:00
|
|
|
height: height / currentTransform[3],
|
2013-02-11 03:19:36 +09:00
|
|
|
});
|
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
this.restore();
|
|
|
|
},
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(
|
|
|
|
imgData,
|
|
|
|
map
|
|
|
|
) {
|
2020-07-15 07:17:27 +09:00
|
|
|
if (!this.contentVisible) {
|
|
|
|
return;
|
|
|
|
}
|
2012-12-08 03:19:43 +09:00
|
|
|
var ctx = this.ctx;
|
|
|
|
var w = imgData.width;
|
|
|
|
var h = imgData.height;
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", w, h);
|
2013-08-16 23:50:48 +09:00
|
|
|
var tmpCtx = tmpCanvas.context;
|
2020-08-17 15:49:19 +09:00
|
|
|
putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
|
2012-12-08 03:19:43 +09:00
|
|
|
|
|
|
|
for (var i = 0, ii = map.length; i < ii; i++) {
|
|
|
|
var entry = map[i];
|
|
|
|
ctx.save();
|
|
|
|
ctx.transform.apply(ctx, entry.transform);
|
|
|
|
ctx.scale(1, -1);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
ctx.drawImage(
|
|
|
|
tmpCanvas.canvas,
|
|
|
|
entry.x,
|
|
|
|
entry.y,
|
|
|
|
entry.w,
|
|
|
|
entry.h,
|
|
|
|
0,
|
|
|
|
-1,
|
|
|
|
1,
|
|
|
|
1
|
|
|
|
);
|
2013-02-11 03:19:36 +09:00
|
|
|
if (this.imageLayer) {
|
|
|
|
var position = this.getCanvasPosition(entry.x, entry.y);
|
|
|
|
this.imageLayer.appendImage({
|
2017-04-25 23:17:18 +09:00
|
|
|
imgData,
|
2013-02-11 03:19:36 +09:00
|
|
|
left: position[0],
|
|
|
|
top: position[1],
|
|
|
|
width: w,
|
Fix inconsistent spacing and trailing commas in objects in remaining `src/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/display/canvas.js b/src/display/canvas.js
index 5739f6f2..4216b2d2 100644
--- a/src/display/canvas.js
+++ b/src/display/canvas.js
@@ -2071,7 +2071,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var map = [];
for (var i = 0, ii = positions.length; i < ii; i += 2) {
map.push({ transform: [scaleX, 0, 0, scaleY, positions[i],
- positions[i + 1]], x: 0, y: 0, w: width, h: height, });
+ positions[i + 1]], x: 0, y: 0, w: width, h: height, });
}
this.paintInlineImageXObjectGroup(imgData, map);
},
diff --git a/src/display/svg.js b/src/display/svg.js
index 9eb05dfa..2aa21482 100644
--- a/src/display/svg.js
+++ b/src/display/svg.js
@@ -458,7 +458,11 @@ SVGGraphics = (function SVGGraphicsClosure() {
for (var x = 0; x < fnArrayLen; x++) {
var fnId = fnArray[x];
- opList.push({ 'fnId': fnId, 'fn': REVOPS[fnId], 'args': argsArray[x], });
+ opList.push({
+ 'fnId': fnId,
+ 'fn': REVOPS[fnId],
+ 'args': argsArray[x],
+ });
}
return opListToTree(opList);
},
```
2017-06-02 18:26:37 +09:00
|
|
|
height: h,
|
2013-02-11 03:19:36 +09:00
|
|
|
});
|
|
|
|
}
|
2012-12-08 03:19:43 +09:00
|
|
|
ctx.restore();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
|
2020-07-15 07:17:27 +09:00
|
|
|
if (!this.contentVisible) {
|
|
|
|
return;
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.ctx.fillRect(0, 0, 1, 1);
|
2014-03-17 00:17:13 +09:00
|
|
|
},
|
|
|
|
|
2011-10-25 08:55:23 +09:00
|
|
|
// Marked content
|
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
markPoint: function CanvasGraphics_markPoint(tag) {
|
2012-07-21 01:09:48 +09:00
|
|
|
// TODO Marked content.
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
|
2012-07-21 01:09:48 +09:00
|
|
|
// TODO Marked content.
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
|
2020-07-15 07:17:27 +09:00
|
|
|
this.markedContentStack.push({
|
|
|
|
visible: true,
|
|
|
|
});
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
tag,
|
|
|
|
properties
|
|
|
|
) {
|
2020-07-15 07:17:27 +09:00
|
|
|
if (tag === "OC") {
|
|
|
|
this.markedContentStack.push({
|
|
|
|
visible: this.optionalContentConfig.isVisible(properties),
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.markedContentStack.push({
|
|
|
|
visible: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
this.contentVisible = this.isContentVisible();
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
endMarkedContent: function CanvasGraphics_endMarkedContent() {
|
2020-07-15 07:17:27 +09:00
|
|
|
this.markedContentStack.pop();
|
|
|
|
this.contentVisible = this.isContentVisible();
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
// Compatibility
|
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
beginCompat: function CanvasGraphics_beginCompat() {
|
2013-02-06 03:57:59 +09:00
|
|
|
// TODO ignore undefined operators (should we do that anyway?)
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
endCompat: function CanvasGraphics_endCompat() {
|
2013-02-06 03:57:59 +09:00
|
|
|
// TODO stop ignoring undefined operators
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
// Helper functions
|
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
consumePath: function CanvasGraphics_consumePath() {
|
2014-05-15 23:25:12 +09:00
|
|
|
var ctx = this.ctx;
|
2011-10-25 08:55:23 +09:00
|
|
|
if (this.pendingClip) {
|
2014-06-02 21:46:59 +09:00
|
|
|
if (this.pendingClip === EO_CLIP) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
ctx.clip("evenodd");
|
2013-05-04 08:47:40 +09:00
|
|
|
} else {
|
2014-05-15 23:25:12 +09:00
|
|
|
ctx.clip();
|
2013-05-04 08:47:40 +09:00
|
|
|
}
|
2011-10-25 08:55:23 +09:00
|
|
|
this.pendingClip = null;
|
|
|
|
}
|
2014-05-15 23:25:12 +09:00
|
|
|
ctx.beginPath();
|
2011-10-25 08:55:23 +09:00
|
|
|
},
|
2018-09-03 03:31:24 +09:00
|
|
|
getSinglePixelWidth(scale) {
|
|
|
|
if (this._cachedGetSinglePixelWidth === null) {
|
|
|
|
const inverse = this.ctx.mozCurrentTransformInverse;
|
2014-04-12 03:19:39 +09:00
|
|
|
// max of the current horizontal and vertical scale
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this._cachedGetSinglePixelWidth = Math.sqrt(
|
|
|
|
Math.max(
|
|
|
|
inverse[0] * inverse[0] + inverse[1] * inverse[1],
|
|
|
|
inverse[2] * inverse[2] + inverse[3] * inverse[3]
|
|
|
|
)
|
|
|
|
);
|
2014-04-12 03:19:39 +09:00
|
|
|
}
|
2018-09-03 03:31:24 +09:00
|
|
|
return this._cachedGetSinglePixelWidth;
|
2013-02-11 03:19:36 +09:00
|
|
|
},
|
|
|
|
getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
|
2015-12-17 06:31:30 +09:00
|
|
|
var transform = this.ctx.mozCurrentTransform;
|
|
|
|
return [
|
|
|
|
transform[0] * x + transform[2] * y + transform[4],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
transform[1] * x + transform[3] * y + transform[5],
|
2015-12-17 06:31:30 +09:00
|
|
|
];
|
Fix inconsistent spacing and trailing commas in objects in remaining `src/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/display/canvas.js b/src/display/canvas.js
index 5739f6f2..4216b2d2 100644
--- a/src/display/canvas.js
+++ b/src/display/canvas.js
@@ -2071,7 +2071,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var map = [];
for (var i = 0, ii = positions.length; i < ii; i += 2) {
map.push({ transform: [scaleX, 0, 0, scaleY, positions[i],
- positions[i + 1]], x: 0, y: 0, w: width, h: height, });
+ positions[i + 1]], x: 0, y: 0, w: width, h: height, });
}
this.paintInlineImageXObjectGroup(imgData, map);
},
diff --git a/src/display/svg.js b/src/display/svg.js
index 9eb05dfa..2aa21482 100644
--- a/src/display/svg.js
+++ b/src/display/svg.js
@@ -458,7 +458,11 @@ SVGGraphics = (function SVGGraphicsClosure() {
for (var x = 0; x < fnArrayLen; x++) {
var fnId = fnArray[x];
- opList.push({ 'fnId': fnId, 'fn': REVOPS[fnId], 'args': argsArray[x], });
+ opList.push({
+ 'fnId': fnId,
+ 'fn': REVOPS[fnId],
+ 'args': argsArray[x],
+ });
}
return opListToTree(opList);
},
```
2017-06-02 18:26:37 +09:00
|
|
|
},
|
2020-07-15 07:17:27 +09:00
|
|
|
|
|
|
|
isContentVisible: function CanvasGraphics_isContentVisible() {
|
|
|
|
for (let i = this.markedContentStack.length - 1; i >= 0; i--) {
|
|
|
|
if (!this.markedContentStack[i].visible) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
},
|
2011-10-25 08:55:23 +09:00
|
|
|
};
|
|
|
|
|
2013-11-14 04:43:38 +09:00
|
|
|
for (var op in OPS) {
|
|
|
|
CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
|
|
|
|
}
|
|
|
|
|
2011-12-09 07:18:43 +09:00
|
|
|
return CanvasGraphics;
|
2011-10-25 08:55:23 +09:00
|
|
|
})();
|
2015-11-22 01:32:47 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
export { CanvasGraphics };
|