pdf.js/src/core/pattern.js

990 lines
30 KiB
JavaScript
Raw Normal View History

/* 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.
*/
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
assert,
FormatError,
info,
unreachable,
UNSUPPORTED_FEATURES,
Util,
warn,
} from "../shared/util.js";
import { ColorSpace } from "./colorspace.js";
import { isStream } from "./primitives.js";
import { MissingDataException } from "./core_utils.js";
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const ShadingType = {
2014-01-27 22:17:14 +09:00
FUNCTION_BASED: 1,
AXIAL: 2,
2014-01-27 22:17:14 +09:00
RADIAL: 3,
FREE_FORM_MESH: 4,
LATTICE_FORM_MESH: 5,
COONS_PATCH_MESH: 6,
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on *Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.* 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/core/evaluator.js b/src/core/evaluator.js index abab9027..dcd3594b 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() { t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, }; t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, }; t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, }; - t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, }; + t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, + variableArgs: false, }; t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, }; t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, }; t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, }; diff --git a/src/core/jbig2.js b/src/core/jbig2.js index 5a17d482..71671541 100644 --- a/src/core/jbig2.js +++ b/src/core/jbig2.js @@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() { { x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, }, { x: -1, y: 0, }], [{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, }, - { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }] + { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, + { x: -1, y: 0, }] ]; var RefinementTemplates = [ { coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }], - reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, - { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }], + reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, + { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, }, + { x: 0, y: 1, }, { x: 1, y: 1, }], }, { - coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }], - reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, }, - { x: 0, y: 1, }, { x: 1, y: 1, }], + coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, + { x: -1, y: 0, }], + reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, + { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }], } ]; ```
2017-06-02 18:16:24 +09:00
TENSOR_PATCH_MESH: 7,
};
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const Pattern = (function PatternClosure() {
// Constructor should define this.getPattern
// eslint-disable-next-line no-shadow
function 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
unreachable("should not call Pattern constructor");
}
Pattern.prototype = {
// Input: current Canvas context
// Output: the appropriate fillStyle or strokeStyle
getPattern: function Pattern_getPattern(ctx) {
unreachable(`Should not call Pattern.getStyle: ${ctx}`);
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on *Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.* 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/core/evaluator.js b/src/core/evaluator.js index abab9027..dcd3594b 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() { t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, }; t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, }; t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, }; - t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, }; + t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, + variableArgs: false, }; t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, }; t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, }; t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, }; diff --git a/src/core/jbig2.js b/src/core/jbig2.js index 5a17d482..71671541 100644 --- a/src/core/jbig2.js +++ b/src/core/jbig2.js @@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() { { x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, }, { x: -1, y: 0, }], [{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, }, - { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }] + { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, + { x: -1, y: 0, }] ]; var RefinementTemplates = [ { coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }], - reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, - { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }], + reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, + { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, }, + { x: 0, y: 1, }, { x: 1, y: 1, }], }, { - coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }], - reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, }, - { x: 0, y: 1, }, { x: 1, y: 1, }], + coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, + { x: -1, y: 0, }], + reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, + { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }], } ]; ```
2017-06-02 18:16:24 +09:00
},
};
Pattern.parseShading = function (
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
shading,
matrix,
xref,
res,
handler,
pdfFunctionFactory,
localColorSpaceCache
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
) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const dict = isStream(shading) ? shading.dict : shading;
const type = dict.get("ShadingType");
try {
switch (type) {
case ShadingType.AXIAL:
case ShadingType.RADIAL:
// Both radial and axial shadings are handled by RadialAxial shading.
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 new Shadings.RadialAxial(
dict,
matrix,
xref,
res,
pdfFunctionFactory,
localColorSpaceCache
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 ShadingType.FREE_FORM_MESH:
case ShadingType.LATTICE_FORM_MESH:
case ShadingType.COONS_PATCH_MESH:
case ShadingType.TENSOR_PATCH_MESH:
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 new Shadings.Mesh(
shading,
matrix,
xref,
res,
pdfFunctionFactory,
localColorSpaceCache
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
);
default:
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 FormatError("Unsupported ShadingType: " + type);
}
} catch (ex) {
if (ex instanceof MissingDataException) {
throw ex;
}
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
handler.send("UnsupportedFeature", {
featureId: UNSUPPORTED_FEATURES.shadingPattern,
});
warn(ex);
return new Shadings.Dummy();
}
};
return Pattern;
})();
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const Shadings = {};
// A small number to offset the first/last color stops so we can insert ones to
// support extend. Number.MIN_VALUE is too small and breaks the extend.
Shadings.SMALL_NUMBER = 1e-6;
// Radial and axial shading have very similar implementations
// If needed, the implementations can be broken into two classes
Shadings.RadialAxial = (function RadialAxialClosure() {
function RadialAxial(
dict,
matrix,
xref,
resources,
pdfFunctionFactory,
localColorSpaceCache
) {
this.matrix = matrix;
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.coordsArr = dict.getArray("Coords");
this.shadingType = dict.get("ShadingType");
this.type = "Pattern";
const cs = ColorSpace.parse({
cs: dict.getRaw("ColorSpace") || dict.getRaw("CS"),
xref,
resources,
pdfFunctionFactory,
localColorSpaceCache,
});
this.cs = cs;
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 bbox = dict.getArray("BBox");
if (Array.isArray(bbox) && bbox.length === 4) {
this.bbox = Util.normalizeRect(bbox);
} else {
this.bbox = null;
}
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
let t0 = 0.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
t1 = 1.0;
if (dict.has("Domain")) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const domainArr = dict.getArray("Domain");
t0 = domainArr[0];
t1 = domainArr[1];
}
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
let extendStart = false,
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
extendEnd = false;
if (dict.has("Extend")) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const extendArr = dict.getArray("Extend");
extendStart = extendArr[0];
extendEnd = extendArr[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
if (
this.shadingType === ShadingType.RADIAL &&
(!extendStart || !extendEnd)
) {
// Radial gradient only currently works if either circle is fully within
// the other circle.
const [x1, y1, r1, x2, y2, r2] = this.coordsArr;
const distance = Math.hypot(x1 - x2, y1 - y2);
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 (r1 <= r2 + distance && r2 <= r1 + distance) {
warn("Unsupported radial gradient.");
}
}
this.extendStart = extendStart;
this.extendEnd = extendEnd;
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const fnObj = dict.getRaw("Function");
const fn = pdfFunctionFactory.createFromArray(fnObj);
// 10 samples seems good enough for now, but probably won't work
// if there are sharp color changes. Ideally, we would implement
// the spec faithfully and add lossless optimizations.
const NUMBER_OF_SAMPLES = 10;
const step = (t1 - t0) / NUMBER_OF_SAMPLES;
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const colorStops = (this.colorStops = []);
// Protect against bad domains.
if (t0 >= t1 || step <= 0) {
// Acrobat doesn't seem to handle these cases so we'll ignore for
// now.
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("Bad shading domain.");
return;
}
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const color = new Float32Array(cs.numComps),
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
ratio = new Float32Array(1);
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
let rgbColor;
for (let i = 0; i <= NUMBER_OF_SAMPLES; i++) {
ratio[0] = t0 + i * step;
fn(ratio, 0, color, 0);
rgbColor = cs.getRgb(color, 0);
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const cssColor = Util.makeHexColor(rgbColor[0], rgbColor[1], rgbColor[2]);
colorStops.push([i / NUMBER_OF_SAMPLES, cssColor]);
}
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
let background = "transparent";
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 (dict.has("Background")) {
rgbColor = cs.getRgb(dict.get("Background"), 0);
background = Util.makeHexColor(rgbColor[0], rgbColor[1], rgbColor[2]);
}
if (!extendStart) {
// Insert a color stop at the front and offset the first real color stop
// so it doesn't conflict with the one we insert.
colorStops.unshift([0, background]);
colorStops[1][0] += Shadings.SMALL_NUMBER;
}
if (!extendEnd) {
// Same idea as above in extendStart but for the end.
colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
colorStops.push([1, background]);
}
this.colorStops = colorStops;
}
RadialAxial.prototype = {
getIR: function RadialAxial_getIR() {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const coordsArr = this.coordsArr;
const shadingType = this.shadingType;
let type, p0, p1, r0, r1;
if (shadingType === ShadingType.AXIAL) {
p0 = [coordsArr[0], coordsArr[1]];
p1 = [coordsArr[2], coordsArr[3]];
r0 = null;
r1 = 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
type = "axial";
} else if (shadingType === ShadingType.RADIAL) {
p0 = [coordsArr[0], coordsArr[1]];
p1 = [coordsArr[3], coordsArr[4]];
r0 = coordsArr[2];
r1 = coordsArr[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
type = "radial";
} else {
2017-06-29 05:51:31 +09:00
unreachable(`getPattern type unknown: ${shadingType}`);
}
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const matrix = this.matrix;
if (matrix) {
p0 = Util.applyTransform(p0, matrix);
p1 = Util.applyTransform(p1, matrix);
if (shadingType === ShadingType.RADIAL) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const scale = Util.singularValueDecompose2dScale(matrix);
r0 *= scale[0];
r1 *= scale[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
return ["RadialAxial", type, this.bbox, this.colorStops, p0, p1, r0, r1];
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on *Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.* 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/core/evaluator.js b/src/core/evaluator.js index abab9027..dcd3594b 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() { t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, }; t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, }; t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, }; - t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, }; + t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, + variableArgs: false, }; t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, }; t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, }; t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, }; diff --git a/src/core/jbig2.js b/src/core/jbig2.js index 5a17d482..71671541 100644 --- a/src/core/jbig2.js +++ b/src/core/jbig2.js @@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() { { x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, }, { x: -1, y: 0, }], [{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, }, - { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }] + { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, + { x: -1, y: 0, }] ]; var RefinementTemplates = [ { coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }], - reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, - { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }], + reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, + { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, }, + { x: 0, y: 1, }, { x: 1, y: 1, }], }, { - coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }], - reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, }, - { x: 0, y: 1, }, { x: 1, y: 1, }], + coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, + { x: -1, y: 0, }], + reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, + { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }], } ]; ```
2017-06-02 18:16:24 +09:00
},
};
return RadialAxial;
})();
2014-01-27 22:17:14 +09:00
// All mesh shading. For now, they will be presented as set of the triangles
// to be drawn on the canvas and rgb color for each vertex.
Shadings.Mesh = (function MeshClosure() {
function MeshStreamReader(stream, context) {
this.stream = stream;
this.context = context;
this.buffer = 0;
this.bufferLength = 0;
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const numComps = context.numComps;
this.tmpCompsBuf = new Float32Array(numComps);
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const csNumComps = context.colorSpace.numComps;
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.tmpCsCompsBuf = context.colorFn
? new Float32Array(csNumComps)
: this.tmpCompsBuf;
2014-01-27 22:17:14 +09:00
}
MeshStreamReader.prototype = {
get hasData() {
if (this.stream.end) {
return this.stream.pos < this.stream.end;
}
if (this.bufferLength > 0) {
return true;
}
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const nextByte = this.stream.getByte();
2014-01-27 22:17:14 +09:00
if (nextByte < 0) {
return false;
}
this.buffer = nextByte;
this.bufferLength = 8;
return true;
},
readBits: function MeshStreamReader_readBits(n) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
let buffer = this.buffer;
let bufferLength = this.bufferLength;
2014-01-27 22:17:14 +09:00
if (n === 32) {
if (bufferLength === 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
return (
((this.stream.getByte() << 24) |
(this.stream.getByte() << 16) |
(this.stream.getByte() << 8) |
this.stream.getByte()) >>>
0
);
2014-01-27 22:17: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
buffer =
(buffer << 24) |
(this.stream.getByte() << 16) |
(this.stream.getByte() << 8) |
this.stream.getByte();
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const nextByte = this.stream.getByte();
2014-01-27 22:17:14 +09:00
this.buffer = nextByte & ((1 << bufferLength) - 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
return (
((buffer << (8 - bufferLength)) |
((nextByte & 0xff) >> bufferLength)) >>>
0
);
2014-01-27 22:17:14 +09:00
}
if (n === 8 && bufferLength === 0) {
return this.stream.getByte();
}
while (bufferLength < n) {
buffer = (buffer << 8) | this.stream.getByte();
bufferLength += 8;
}
bufferLength -= n;
this.bufferLength = bufferLength;
this.buffer = buffer & ((1 << bufferLength) - 1);
return buffer >> bufferLength;
},
align: function MeshStreamReader_align() {
this.buffer = 0;
this.bufferLength = 0;
},
readFlag: function MeshStreamReader_readFlag() {
return this.readBits(this.context.bitsPerFlag);
},
readCoordinate: function MeshStreamReader_readCoordinate() {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const bitsPerCoordinate = this.context.bitsPerCoordinate;
const xi = this.readBits(bitsPerCoordinate);
const yi = this.readBits(bitsPerCoordinate);
const decode = this.context.decode;
const 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
bitsPerCoordinate < 32
? 1 / ((1 << bitsPerCoordinate) - 1)
: 2.3283064365386963e-10; // 2 ^ -32
2014-01-27 22:17:14 +09:00
return [
xi * scale * (decode[1] - decode[0]) + decode[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
yi * scale * (decode[3] - decode[2]) + decode[2],
2014-01-27 22:17:14 +09:00
];
},
readComponents: function MeshStreamReader_readComponents() {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const numComps = this.context.numComps;
const bitsPerComponent = this.context.bitsPerComponent;
const 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
bitsPerComponent < 32
? 1 / ((1 << bitsPerComponent) - 1)
: 2.3283064365386963e-10; // 2 ^ -32
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const decode = this.context.decode;
const components = this.tmpCompsBuf;
for (let i = 0, j = 4; i < numComps; i++, j += 2) {
const ci = this.readBits(bitsPerComponent);
components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
2014-01-27 22:17:14 +09:00
}
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const color = this.tmpCsCompsBuf;
2014-01-27 22:17:14 +09:00
if (this.context.colorFn) {
this.context.colorFn(components, 0, color, 0);
2014-01-27 22:17:14 +09:00
}
return this.context.colorSpace.getRgb(color, 0);
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on *Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.* 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/core/evaluator.js b/src/core/evaluator.js index abab9027..dcd3594b 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() { t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, }; t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, }; t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, }; - t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, }; + t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, + variableArgs: false, }; t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, }; t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, }; t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, }; diff --git a/src/core/jbig2.js b/src/core/jbig2.js index 5a17d482..71671541 100644 --- a/src/core/jbig2.js +++ b/src/core/jbig2.js @@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() { { x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, }, { x: -1, y: 0, }], [{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, }, - { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }] + { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, + { x: -1, y: 0, }] ]; var RefinementTemplates = [ { coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }], - reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, - { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }], + reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, + { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, }, + { x: 0, y: 1, }, { x: 1, y: 1, }], }, { - coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }], - reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, }, - { x: 0, y: 1, }, { x: 1, y: 1, }], + coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, + { x: -1, y: 0, }], + reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, + { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }], } ]; ```
2017-06-02 18:16:24 +09:00
},
2014-01-27 22:17:14 +09:00
};
function decodeType4Shading(mesh, reader) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const coords = mesh.coords;
const colors = mesh.colors;
const operators = [];
const ps = []; // not maintaining cs since that will match ps
let verticesLeft = 0; // assuming we have all data to start a new triangle
2014-01-27 22:17:14 +09:00
while (reader.hasData) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const f = reader.readFlag();
const coord = reader.readCoordinate();
const color = reader.readComponents();
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 (verticesLeft === 0) {
// ignoring flags if we started a triangle
if (!(0 <= f && f <= 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
throw new FormatError("Unknown type4 flag");
}
2014-01-27 22:17:14 +09:00
switch (f) {
case 0:
verticesLeft = 3;
break;
case 1:
ps.push(ps[ps.length - 2], ps[ps.length - 1]);
verticesLeft = 1;
break;
case 2:
ps.push(ps[ps.length - 3], ps[ps.length - 1]);
verticesLeft = 1;
break;
}
operators.push(f);
}
ps.push(coords.length);
coords.push(coord);
colors.push(color);
verticesLeft--;
reader.align();
}
mesh.figures.push({
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
type: "triangles",
coords: new Int32Array(ps),
colors: new Int32Array(ps),
2014-01-27 22:17:14 +09:00
});
}
function decodeType5Shading(mesh, reader, verticesPerRow) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const coords = mesh.coords;
const colors = mesh.colors;
const ps = []; // not maintaining cs since that will match ps
2014-01-27 22:17:14 +09:00
while (reader.hasData) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const coord = reader.readCoordinate();
const color = reader.readComponents();
2014-01-27 22:17:14 +09:00
ps.push(coords.length);
coords.push(coord);
colors.push(color);
}
mesh.figures.push({
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
type: "lattice",
coords: new Int32Array(ps),
colors: new Int32Array(ps),
verticesPerRow,
2014-01-27 22:17:14 +09:00
});
}
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
const MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const TRIANGLE_DENSITY = 20; // count of triangles per entire mesh bounds
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const getB = (function getBClosure() {
function buildB(count) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const lut = [];
for (let i = 0; i <= count; i++) {
const t = i / count,
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
t_ = 1 - t;
lut.push(
new Float32Array([
t_ * t_ * t_,
3 * t * t_ * t_,
3 * t * t * t_,
t * t * t,
])
);
}
return lut;
2014-01-27 22:17:14 +09:00
}
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const cache = [];
// eslint-disable-next-line no-shadow
return function getB(count) {
if (!cache[count]) {
cache[count] = buildB(count);
}
return cache[count];
};
2014-01-27 22:17:14 +09:00
})();
function buildFigureFromPatch(mesh, index) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const figure = mesh.figures[index];
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
assert(figure.type === "patch", "Unexpected patch mesh figure");
2014-01-27 22:17:14 +09:00
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const coords = mesh.coords,
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
colors = mesh.colors;
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const pi = figure.coords;
const ci = figure.colors;
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const figureMinX = Math.min(
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
coords[pi[0]][0],
coords[pi[3]][0],
coords[pi[12]][0],
coords[pi[15]][0]
);
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const figureMinY = Math.min(
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
coords[pi[0]][1],
coords[pi[3]][1],
coords[pi[12]][1],
coords[pi[15]][1]
);
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const figureMaxX = Math.max(
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
coords[pi[0]][0],
coords[pi[3]][0],
coords[pi[12]][0],
coords[pi[15]][0]
);
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const figureMaxY = Math.max(
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
coords[pi[0]][1],
coords[pi[3]][1],
coords[pi[12]][1],
coords[pi[15]][1]
);
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
let splitXBy = Math.ceil(
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
((figureMaxX - figureMinX) * TRIANGLE_DENSITY) /
(mesh.bounds[2] - mesh.bounds[0])
);
splitXBy = Math.max(
MIN_SPLIT_PATCH_CHUNKS_AMOUNT,
Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy)
);
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
let splitYBy = Math.ceil(
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
((figureMaxY - figureMinY) * TRIANGLE_DENSITY) /
(mesh.bounds[3] - mesh.bounds[1])
);
splitYBy = Math.max(
MIN_SPLIT_PATCH_CHUNKS_AMOUNT,
Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy)
);
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const verticesPerRow = splitXBy + 1;
const figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
const figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
let k = 0;
const cl = new Uint8Array(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
cr = new Uint8Array(3);
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const c0 = colors[ci[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
c1 = colors[ci[1]],
c2 = colors[ci[2]],
c3 = colors[ci[3]];
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const bRow = getB(splitYBy),
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
bCol = getB(splitXBy);
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
for (let row = 0; row <= splitYBy; row++) {
cl[0] = ((c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy) | 0;
cl[1] = ((c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy) | 0;
cl[2] = ((c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy) | 0;
cr[0] = ((c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy) | 0;
cr[1] = ((c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy) | 0;
cr[2] = ((c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy) | 0;
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
for (let col = 0; col <= splitXBy; col++, 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 (
(row === 0 || row === splitYBy) &&
(col === 0 || col === splitXBy)
) {
2014-01-27 22:17:14 +09:00
continue;
}
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
let x = 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
y = 0;
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
let q = 0;
for (let i = 0; i <= 3; i++) {
for (let j = 0; j <= 3; j++, q++) {
const m = bRow[row][i] * bCol[col][j];
2014-01-27 22:17:14 +09:00
x += coords[pi[q]][0] * m;
y += coords[pi[q]][1] * m;
}
}
figureCoords[k] = coords.length;
coords.push([x, y]);
figureColors[k] = colors.length;
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const newColor = new Uint8Array(3);
newColor[0] = ((cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy) | 0;
newColor[1] = ((cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy) | 0;
newColor[2] = ((cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy) | 0;
2014-01-27 22:17:14 +09:00
colors.push(newColor);
}
}
figureCoords[0] = pi[0];
figureColors[0] = ci[0];
figureCoords[splitXBy] = pi[3];
figureColors[splitXBy] = ci[1];
figureCoords[verticesPerRow * splitYBy] = pi[12];
figureColors[verticesPerRow * splitYBy] = ci[2];
figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
mesh.figures[index] = {
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
type: "lattice",
2014-01-27 22:17:14 +09:00
coords: figureCoords,
colors: figureColors,
verticesPerRow,
};
2014-01-27 22:17:14 +09:00
}
function decodeType6Shading(mesh, reader) {
// A special case of Type 7. The p11, p12, p21, p22 automatically filled
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const coords = mesh.coords;
const colors = mesh.colors;
const ps = new Int32Array(16); // p00, p10, ..., p30, p01, ..., p33
const cs = new Int32Array(4); // c00, c30, c03, c33
2014-01-27 22:17:14 +09:00
while (reader.hasData) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const f = reader.readFlag();
if (!(0 <= f && f <= 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
throw new FormatError("Unknown type6 flag");
}
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const pi = coords.length;
for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
2014-01-27 22:17:14 +09:00
coords.push(reader.readCoordinate());
}
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const ci = colors.length;
for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
2014-01-27 22:17:14 +09:00
colors.push(reader.readComponents());
}
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
let tmp1, tmp2, tmp3, tmp4;
2014-01-27 22:17:14 +09:00
switch (f) {
// prettier-ignore
2014-01-27 22:17:14 +09:00
case 0:
ps[12] = pi + 3; ps[13] = pi + 4; ps[14] = pi + 5; ps[15] = pi + 6;
ps[ 8] = pi + 2; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 7;
ps[ 4] = pi + 1; /* calculated below */ ps[ 7] = pi + 8;
ps[ 0] = pi; ps[ 1] = pi + 11; ps[ 2] = pi + 10; ps[ 3] = pi + 9;
cs[2] = ci + 1; cs[3] = ci + 2;
cs[0] = ci; cs[1] = ci + 3;
break;
// prettier-ignore
2014-01-27 22:17:14 +09:00
case 1:
tmp1 = ps[12]; tmp2 = ps[13]; tmp3 = ps[14]; tmp4 = ps[15];
ps[12] = tmp4; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
ps[ 8] = tmp3; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 3;
ps[ 4] = tmp2; /* calculated below */ ps[ 7] = pi + 4;
ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
2014-01-27 22:17:14 +09:00
tmp1 = cs[2]; tmp2 = cs[3];
cs[2] = tmp2; cs[3] = ci;
cs[0] = tmp1; cs[1] = ci + 1;
2014-01-27 22:17:14 +09:00
break;
// prettier-ignore
2014-01-27 22:17:14 +09:00
case 2:
tmp1 = ps[15];
tmp2 = ps[11];
ps[12] = ps[3]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
ps[ 8] = ps[7]; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 3;
ps[ 4] = tmp2; /* calculated below */ ps[ 7] = pi + 4;
ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
tmp1 = cs[3];
cs[2] = cs[1]; cs[3] = ci;
cs[0] = tmp1; cs[1] = ci + 1;
2014-01-27 22:17:14 +09:00
break;
// prettier-ignore
2014-01-27 22:17:14 +09:00
case 3:
ps[12] = ps[0]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
ps[ 8] = ps[1]; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 3;
ps[ 4] = ps[2]; /* calculated below */ ps[ 7] = pi + 4;
ps[ 0] = ps[3]; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
cs[2] = cs[0]; cs[3] = ci;
cs[0] = cs[1]; cs[1] = ci + 1;
2014-01-27 22:17:14 +09:00
break;
}
// set p11, p12, p21, p22
ps[5] = coords.length;
coords.push([
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
(-4 * coords[ps[0]][0] -
coords[ps[15]][0] +
2014-01-27 22:17:14 +09:00
6 * (coords[ps[4]][0] + coords[ps[1]][0]) -
2 * (coords[ps[12]][0] + coords[ps[3]][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
3 * (coords[ps[13]][0] + coords[ps[7]][0])) /
9,
(-4 * coords[ps[0]][1] -
coords[ps[15]][1] +
2014-01-27 22:17:14 +09:00
6 * (coords[ps[4]][1] + coords[ps[1]][1]) -
2 * (coords[ps[12]][1] + coords[ps[3]][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
3 * (coords[ps[13]][1] + coords[ps[7]][1])) /
9,
2014-01-27 22:17:14 +09:00
]);
ps[6] = coords.length;
coords.push([
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
(-4 * coords[ps[3]][0] -
coords[ps[12]][0] +
2014-01-27 22:17:14 +09:00
6 * (coords[ps[2]][0] + coords[ps[7]][0]) -
2 * (coords[ps[0]][0] + coords[ps[15]][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
3 * (coords[ps[4]][0] + coords[ps[14]][0])) /
9,
(-4 * coords[ps[3]][1] -
coords[ps[12]][1] +
2014-01-27 22:17:14 +09:00
6 * (coords[ps[2]][1] + coords[ps[7]][1]) -
2 * (coords[ps[0]][1] + coords[ps[15]][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
3 * (coords[ps[4]][1] + coords[ps[14]][1])) /
9,
2014-01-27 22:17:14 +09:00
]);
ps[9] = coords.length;
coords.push([
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
(-4 * coords[ps[12]][0] -
coords[ps[3]][0] +
2014-01-27 22:17:14 +09:00
6 * (coords[ps[8]][0] + coords[ps[13]][0]) -
2 * (coords[ps[0]][0] + coords[ps[15]][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
3 * (coords[ps[11]][0] + coords[ps[1]][0])) /
9,
(-4 * coords[ps[12]][1] -
coords[ps[3]][1] +
2014-01-27 22:17:14 +09:00
6 * (coords[ps[8]][1] + coords[ps[13]][1]) -
2 * (coords[ps[0]][1] + coords[ps[15]][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
3 * (coords[ps[11]][1] + coords[ps[1]][1])) /
9,
2014-01-27 22:17:14 +09:00
]);
ps[10] = coords.length;
coords.push([
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
(-4 * coords[ps[15]][0] -
coords[ps[0]][0] +
2014-01-27 22:17:14 +09:00
6 * (coords[ps[11]][0] + coords[ps[14]][0]) -
2 * (coords[ps[12]][0] + coords[ps[3]][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
3 * (coords[ps[2]][0] + coords[ps[8]][0])) /
9,
(-4 * coords[ps[15]][1] -
coords[ps[0]][1] +
2014-01-27 22:17:14 +09:00
6 * (coords[ps[11]][1] + coords[ps[14]][1]) -
2 * (coords[ps[12]][1] + coords[ps[3]][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
3 * (coords[ps[2]][1] + coords[ps[8]][1])) /
9,
2014-01-27 22:17:14 +09:00
]);
mesh.figures.push({
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
type: "patch",
coords: new Int32Array(ps), // making copies of ps and cs
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on *Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.* 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/core/evaluator.js b/src/core/evaluator.js index abab9027..dcd3594b 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() { t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, }; t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, }; t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, }; - t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, }; + t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, + variableArgs: false, }; t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, }; t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, }; t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, }; diff --git a/src/core/jbig2.js b/src/core/jbig2.js index 5a17d482..71671541 100644 --- a/src/core/jbig2.js +++ b/src/core/jbig2.js @@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() { { x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, }, { x: -1, y: 0, }], [{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, }, - { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }] + { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, + { x: -1, y: 0, }] ]; var RefinementTemplates = [ { coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }], - reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, - { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }], + reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, + { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, }, + { x: 0, y: 1, }, { x: 1, y: 1, }], }, { - coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }], - reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, }, - { x: 0, y: 1, }, { x: 1, y: 1, }], + coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, + { x: -1, y: 0, }], + reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, + { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }], } ]; ```
2017-06-02 18:16:24 +09:00
colors: new Int32Array(cs),
});
2014-01-27 22:17:14 +09:00
}
}
function decodeType7Shading(mesh, reader) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const coords = mesh.coords;
const colors = mesh.colors;
const ps = new Int32Array(16); // p00, p10, ..., p30, p01, ..., p33
const cs = new Int32Array(4); // c00, c30, c03, c33
2014-01-27 22:17:14 +09:00
while (reader.hasData) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const f = reader.readFlag();
if (!(0 <= f && f <= 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
throw new FormatError("Unknown type7 flag");
}
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const pi = coords.length;
for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
2014-01-27 22:17:14 +09:00
coords.push(reader.readCoordinate());
}
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const ci = colors.length;
for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
2014-01-27 22:17:14 +09:00
colors.push(reader.readComponents());
}
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
let tmp1, tmp2, tmp3, tmp4;
2014-01-27 22:17:14 +09:00
switch (f) {
// prettier-ignore
2014-01-27 22:17:14 +09:00
case 0:
ps[12] = pi + 3; ps[13] = pi + 4; ps[14] = pi + 5; ps[15] = pi + 6;
ps[ 8] = pi + 2; ps[ 9] = pi + 13; ps[10] = pi + 14; ps[11] = pi + 7;
ps[ 4] = pi + 1; ps[ 5] = pi + 12; ps[ 6] = pi + 15; ps[ 7] = pi + 8;
ps[ 0] = pi; ps[ 1] = pi + 11; ps[ 2] = pi + 10; ps[ 3] = pi + 9;
cs[2] = ci + 1; cs[3] = ci + 2;
cs[0] = ci; cs[1] = ci + 3;
break;
// prettier-ignore
2014-01-27 22:17:14 +09:00
case 1:
tmp1 = ps[12]; tmp2 = ps[13]; tmp3 = ps[14]; tmp4 = ps[15];
ps[12] = tmp4; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
ps[ 8] = tmp3; ps[ 9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3;
ps[ 4] = tmp2; ps[ 5] = pi + 8; ps[ 6] = pi + 11; ps[ 7] = pi + 4;
ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
2014-01-27 22:17:14 +09:00
tmp1 = cs[2]; tmp2 = cs[3];
cs[2] = tmp2; cs[3] = ci;
cs[0] = tmp1; cs[1] = ci + 1;
2014-01-27 22:17:14 +09:00
break;
// prettier-ignore
2014-01-27 22:17:14 +09:00
case 2:
tmp1 = ps[15];
tmp2 = ps[11];
ps[12] = ps[3]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
ps[ 8] = ps[7]; ps[ 9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3;
ps[ 4] = tmp2; ps[ 5] = pi + 8; ps[ 6] = pi + 11; ps[ 7] = pi + 4;
ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
tmp1 = cs[3];
cs[2] = cs[1]; cs[3] = ci;
cs[0] = tmp1; cs[1] = ci + 1;
2014-01-27 22:17:14 +09:00
break;
// prettier-ignore
2014-01-27 22:17:14 +09:00
case 3:
ps[12] = ps[0]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
ps[ 8] = ps[1]; ps[ 9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3;
ps[ 4] = ps[2]; ps[ 5] = pi + 8; ps[ 6] = pi + 11; ps[ 7] = pi + 4;
ps[ 0] = ps[3]; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
cs[2] = cs[0]; cs[3] = ci;
cs[0] = cs[1]; cs[1] = ci + 1;
2014-01-27 22:17:14 +09:00
break;
}
mesh.figures.push({
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
type: "patch",
coords: new Int32Array(ps), // making copies of ps and cs
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on *Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.* 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/core/evaluator.js b/src/core/evaluator.js index abab9027..dcd3594b 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() { t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, }; t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, }; t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, }; - t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, }; + t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, + variableArgs: false, }; t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, }; t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, }; t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, }; diff --git a/src/core/jbig2.js b/src/core/jbig2.js index 5a17d482..71671541 100644 --- a/src/core/jbig2.js +++ b/src/core/jbig2.js @@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() { { x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, }, { x: -1, y: 0, }], [{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, }, - { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }] + { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, + { x: -1, y: 0, }] ]; var RefinementTemplates = [ { coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }], - reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, - { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }], + reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, + { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, }, + { x: 0, y: 1, }, { x: 1, y: 1, }], }, { - coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }], - reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, }, - { x: 0, y: 1, }, { x: 1, y: 1, }], + coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, + { x: -1, y: 0, }], + reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, + { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }], } ]; ```
2017-06-02 18:16:24 +09:00
colors: new Int32Array(cs),
});
2014-01-27 22:17:14 +09:00
}
}
function updateBounds(mesh) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
let minX = mesh.coords[0][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
minY = mesh.coords[0][1],
maxX = minX,
maxY = minY;
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
for (let i = 1, ii = mesh.coords.length; i < ii; i++) {
const x = mesh.coords[i][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
y = mesh.coords[i][1];
minX = minX > x ? x : minX;
minY = minY > y ? y : minY;
maxX = maxX < x ? x : maxX;
maxY = maxY < y ? y : maxY;
}
mesh.bounds = [minX, minY, maxX, maxY];
}
function packData(mesh) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
let i, ii, j, jj;
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const coords = mesh.coords;
const coordsPacked = new Float32Array(coords.length * 2);
for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const xy = coords[i];
coordsPacked[j++] = xy[0];
coordsPacked[j++] = xy[1];
}
mesh.coords = coordsPacked;
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const colors = mesh.colors;
const colorsPacked = new Uint8Array(colors.length * 3);
for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const c = colors[i];
colorsPacked[j++] = c[0];
colorsPacked[j++] = c[1];
colorsPacked[j++] = c[2];
}
mesh.colors = colorsPacked;
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const figures = mesh.figures;
for (i = 0, ii = figures.length; i < ii; i++) {
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const figure = figures[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
ps = figure.coords,
cs = figure.colors;
for (j = 0, jj = ps.length; j < jj; j++) {
ps[j] *= 2;
cs[j] *= 3;
}
}
}
function Mesh(
stream,
matrix,
xref,
resources,
pdfFunctionFactory,
localColorSpaceCache
) {
if (!isStream(stream)) {
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 FormatError("Mesh data is not a stream");
}
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const dict = stream.dict;
2014-01-27 22:17:14 +09:00
this.matrix = matrix;
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.shadingType = dict.get("ShadingType");
this.type = "Pattern";
const bbox = dict.getArray("BBox");
if (Array.isArray(bbox) && bbox.length === 4) {
this.bbox = Util.normalizeRect(bbox);
} else {
this.bbox = null;
}
const cs = ColorSpace.parse({
cs: dict.getRaw("ColorSpace") || dict.getRaw("CS"),
xref,
resources,
pdfFunctionFactory,
localColorSpaceCache,
});
2014-01-27 22:17:14 +09:00
this.cs = cs;
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.background = dict.has("Background")
? cs.getRgb(dict.get("Background"), 0)
: null;
2014-01-27 22:17:14 +09:00
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const fnObj = dict.getRaw("Function");
const fn = fnObj ? pdfFunctionFactory.createFromArray(fnObj) : null;
2014-01-27 22:17:14 +09:00
this.coords = [];
this.colors = [];
this.figures = [];
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const decodeContext = {
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
bitsPerCoordinate: dict.get("BitsPerCoordinate"),
bitsPerComponent: dict.get("BitsPerComponent"),
bitsPerFlag: dict.get("BitsPerFlag"),
decode: dict.getArray("Decode"),
2014-01-27 22:17:14 +09:00
colorFn: fn,
colorSpace: cs,
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on *Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.* 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/core/evaluator.js b/src/core/evaluator.js index abab9027..dcd3594b 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() { t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, }; t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, }; t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, }; - t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, }; + t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, + variableArgs: false, }; t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, }; t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, }; t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, }; diff --git a/src/core/jbig2.js b/src/core/jbig2.js index 5a17d482..71671541 100644 --- a/src/core/jbig2.js +++ b/src/core/jbig2.js @@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() { { x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, }, { x: -1, y: 0, }], [{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, }, - { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }] + { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, + { x: -1, y: 0, }] ]; var RefinementTemplates = [ { coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }], - reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, - { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }], + reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, + { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, }, + { x: 0, y: 1, }, { x: 1, y: 1, }], }, { - coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }], - reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, }, - { x: 0, y: 1, }, { x: 1, y: 1, }], + coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, + { x: -1, y: 0, }], + reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, + { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }], } ]; ```
2017-06-02 18:16:24 +09:00
numComps: fn ? 1 : cs.numComps,
2014-01-27 22:17:14 +09:00
};
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const reader = new MeshStreamReader(stream, decodeContext);
2014-01-27 22:17:14 +09:00
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
let patchMesh = false;
2014-01-27 22:17:14 +09:00
switch (this.shadingType) {
case ShadingType.FREE_FORM_MESH:
2014-01-27 22:17:14 +09:00
decodeType4Shading(this, reader);
break;
case ShadingType.LATTICE_FORM_MESH:
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
const verticesPerRow = dict.get("VerticesPerRow") | 0;
if (verticesPerRow < 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
throw new FormatError("Invalid VerticesPerRow");
}
2014-01-27 22:17:14 +09:00
decodeType5Shading(this, reader, verticesPerRow);
break;
case ShadingType.COONS_PATCH_MESH:
2014-01-27 22:17:14 +09:00
decodeType6Shading(this, reader);
patchMesh = true;
2014-01-27 22:17:14 +09:00
break;
case ShadingType.TENSOR_PATCH_MESH:
2014-01-27 22:17:14 +09:00
decodeType7Shading(this, reader);
patchMesh = true;
2014-01-27 22:17:14 +09:00
break;
default:
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("Unsupported mesh type.");
2014-01-27 22:17:14 +09:00
break;
}
if (patchMesh) {
// dirty bounds calculation for determining, how dense shall be triangles
updateBounds(this);
Enable the `no-var` linting rule for `src/core/pattern.js` This is mostly done using `gulp lint --fix` with a few manual changes in the following diff: ```diff diff --git a/src/core/pattern.js b/src/core/pattern.js index 365491ed3..eedd8b686 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() { return Pattern; })(); -var Shadings = {}; +const Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE is too small and breaks the extend. @@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type6 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() { if (!(0 <= f && f <= 3)) { throw new FormatError("Unknown type7 flag"); } - var i, ii; const pi = coords.length; - for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) { coords.push(reader.readCoordinate()); } const ci = colors.length; - for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { + for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) { colors.push(reader.readComponents()); } - var tmp1, tmp2, tmp3, tmp4; + let tmp1, tmp2, tmp3, tmp4; switch (f) { // prettier-ignore case 0: @@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() { decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: - var verticesPerRow = dict.get("VerticesPerRow") | 0; + const verticesPerRow = dict.get("VerticesPerRow") | 0; if (verticesPerRow < 2) { throw new FormatError("Invalid VerticesPerRow"); } ```
2021-03-14 01:54:52 +09:00
for (let i = 0, ii = this.figures.length; i < ii; i++) {
buildFigureFromPatch(this, i);
}
2014-01-27 22:17:14 +09:00
}
// calculate bounds
updateBounds(this);
packData(this);
2014-01-27 22:17:14 +09:00
}
Mesh.prototype = {
getIR: function Mesh_getIR() {
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 [
"Mesh",
this.shadingType,
this.coords,
this.colors,
this.figures,
this.bounds,
this.matrix,
this.bbox,
this.background,
];
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on *Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.* 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/core/evaluator.js b/src/core/evaluator.js index abab9027..dcd3594b 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() { t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, }; t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, }; t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, }; - t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, }; + t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, + variableArgs: false, }; t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, }; t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, }; t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, }; diff --git a/src/core/jbig2.js b/src/core/jbig2.js index 5a17d482..71671541 100644 --- a/src/core/jbig2.js +++ b/src/core/jbig2.js @@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() { { x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, }, { x: -1, y: 0, }], [{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, }, - { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }] + { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, + { x: -1, y: 0, }] ]; var RefinementTemplates = [ { coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }], - reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, - { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }], + reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, + { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, }, + { x: 0, y: 1, }, { x: 1, y: 1, }], }, { - coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }], - reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, }, - { x: 0, y: 1, }, { x: 1, y: 1, }], + coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, + { x: -1, y: 0, }], + reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, + { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }], } ]; ```
2017-06-02 18:16:24 +09:00
},
2014-01-27 22:17:14 +09:00
};
return Mesh;
})();
Shadings.Dummy = (function DummyClosure() {
function Dummy() {
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.type = "Pattern";
}
Dummy.prototype = {
getIR: function Dummy_getIR() {
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 ["Dummy"];
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on *Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.* 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/core/evaluator.js b/src/core/evaluator.js index abab9027..dcd3594b 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() { t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, }; t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, }; t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, }; - t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, }; + t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, + variableArgs: false, }; t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, }; t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, }; t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, }; diff --git a/src/core/jbig2.js b/src/core/jbig2.js index 5a17d482..71671541 100644 --- a/src/core/jbig2.js +++ b/src/core/jbig2.js @@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() { { x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, }, { x: -1, y: 0, }], [{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, }, - { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }] + { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, + { x: -1, y: 0, }] ]; var RefinementTemplates = [ { coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }], - reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, - { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }], + reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, + { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, }, + { x: 0, y: 1, }, { x: 1, y: 1, }], }, { - coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }], - reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, }, - { x: 0, y: 1, }, { x: 1, y: 1, }], + coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, + { x: -1, y: 0, }], + reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, + { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }], } ]; ```
2017-06-02 18:16:24 +09:00
},
};
return Dummy;
})();
Add local caching of TilingPatterns in `PartialEvaluator.getOperatorList` (issue 2765 and 8473) In practice it's not uncommon for PDF documents to re-use the same TilingPatterns more than once, and parsing them is essentially equal to parsing of a (small) page since a `getOperatorList` call is required. By caching the internal TilingPattern representation we can thus avoid having to re-parse the same data over and over, and there's also *less* asynchronous parsing required for repeated TilingPatterns. Initially I had intended to include (standard) benchmark results with this patch, however it's not entirely clear that this is actually necessary here given the preliminary results. When testing this manually in the development viewer, using `pdfBug=Stats`, the following (approximate) reduction in rendering times were observed when comparing `master` against this patch: - http://pubs.usgs.gov/sim/3067/pdf/sim3067sheet-2.pdf (from issue 2765): `6800 ms` -> `4100 ms`. - https://github.com/mozilla/pdf.js/files/1046131/stepped.pdf (from issue 8473): `54000 ms` -> `13000 ms` - https://github.com/mozilla/pdf.js/files/1046130/proof.pdf (from issue 8473): `5900 ms` -> `2500 ms` As always, whenever you're dealing with documents which are "slow", there's usually a certain level of subjectivity involved with regards to what's deemed acceptable performance. Hence it's not clear to me that we want to regard any of the referenced issues as fixed, however the improvements are significant enough to warrant caching of TilingPatterns in my opinion.
2020-10-09 00:33:23 +09:00
function getTilingPatternIR(operatorList, dict, color) {
const matrix = dict.getArray("Matrix");
const bbox = Util.normalizeRect(dict.getArray("BBox"));
const xstep = dict.get("XStep");
const ystep = dict.get("YStep");
const paintType = dict.get("PaintType");
const tilingType = dict.get("TilingType");
// Ensure that the pattern has a non-zero width and height, to prevent errors
// in `pattern_helper.js` (fixes issue8330.pdf).
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 (bbox[2] - bbox[0] === 0 || bbox[3] - bbox[1] === 0) {
2017-06-29 05:51:31 +09:00
throw new FormatError(`Invalid getTilingPatternIR /BBox array: [${bbox}].`);
}
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
"TilingPattern",
Add local caching of TilingPatterns in `PartialEvaluator.getOperatorList` (issue 2765 and 8473) In practice it's not uncommon for PDF documents to re-use the same TilingPatterns more than once, and parsing them is essentially equal to parsing of a (small) page since a `getOperatorList` call is required. By caching the internal TilingPattern representation we can thus avoid having to re-parse the same data over and over, and there's also *less* asynchronous parsing required for repeated TilingPatterns. Initially I had intended to include (standard) benchmark results with this patch, however it's not entirely clear that this is actually necessary here given the preliminary results. When testing this manually in the development viewer, using `pdfBug=Stats`, the following (approximate) reduction in rendering times were observed when comparing `master` against this patch: - http://pubs.usgs.gov/sim/3067/pdf/sim3067sheet-2.pdf (from issue 2765): `6800 ms` -> `4100 ms`. - https://github.com/mozilla/pdf.js/files/1046131/stepped.pdf (from issue 8473): `54000 ms` -> `13000 ms` - https://github.com/mozilla/pdf.js/files/1046130/proof.pdf (from issue 8473): `5900 ms` -> `2500 ms` As always, whenever you're dealing with documents which are "slow", there's usually a certain level of subjectivity involved with regards to what's deemed acceptable performance. Hence it's not clear to me that we want to regard any of the referenced issues as fixed, however the improvements are significant enough to warrant caching of TilingPatterns in my opinion.
2020-10-09 00:33:23 +09:00
color,
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,
matrix,
bbox,
xstep,
ystep,
paintType,
tilingType,
];
}
export { getTilingPatternIR, Pattern };