mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-01 20:07:22 +02:00
Move the SVG_NS definition into src/shared/util.js
This constant is already defined in both the `src/core/` and `src/display/` folders, and in a few spots the same string was also inlined.
This commit is contained in:
parent
d27b9ab5fa
commit
7c5087cc16
@ -102,13 +102,12 @@ import {
|
|||||||
getStringOption,
|
getStringOption,
|
||||||
HTMLResult,
|
HTMLResult,
|
||||||
} from "./utils.js";
|
} from "./utils.js";
|
||||||
import { Util, warn } from "../../shared/util.js";
|
import { SVG_NS, Util, warn } from "../../shared/util.js";
|
||||||
import { getMetrics } from "./fonts.js";
|
import { getMetrics } from "./fonts.js";
|
||||||
import { recoverJsURL } from "../core_utils.js";
|
import { recoverJsURL } from "../core_utils.js";
|
||||||
import { searchNode } from "./som.js";
|
import { searchNode } from "./som.js";
|
||||||
|
|
||||||
const TEMPLATE_NS_ID = NamespaceIds.template.id;
|
const TEMPLATE_NS_ID = NamespaceIds.template.id;
|
||||||
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
||||||
|
|
||||||
// In case of lr-tb (and rl-tb) layouts, we try:
|
// In case of lr-tb (and rl-tb) layouts, we try:
|
||||||
// - to put the container at the end of a line
|
// - to put the container at the end of a line
|
||||||
|
|||||||
@ -38,6 +38,7 @@ import {
|
|||||||
LINE_FACTOR,
|
LINE_FACTOR,
|
||||||
makeArr,
|
makeArr,
|
||||||
shadow,
|
shadow,
|
||||||
|
SVG_NS,
|
||||||
unreachable,
|
unreachable,
|
||||||
Util,
|
Util,
|
||||||
warn,
|
warn,
|
||||||
@ -666,8 +667,7 @@ class AnnotationElement {
|
|||||||
style.borderWidth = 0;
|
style.borderWidth = 0;
|
||||||
svgBuffer = [
|
svgBuffer = [
|
||||||
"url('data:image/svg+xml;utf8,",
|
"url('data:image/svg+xml;utf8,",
|
||||||
`<svg xmlns="http://www.w3.org/2000/svg"`,
|
`<svg xmlns="${SVG_NS}" preserveAspectRatio="none" viewBox="0 0 1 1">`,
|
||||||
` preserveAspectRatio="none" viewBox="0 0 1 1">`,
|
|
||||||
`<g fill="transparent" stroke="${borderColor}" stroke-width="${borderWidth}">`,
|
`<g fill="transparent" stroke="${borderColor}" stroke-width="${borderWidth}">`,
|
||||||
];
|
];
|
||||||
this.container.classList.add("hasBorder");
|
this.container.classList.add("hasBorder");
|
||||||
|
|||||||
@ -25,8 +25,6 @@ import { MathClamp } from "../shared/math_clamp.js";
|
|||||||
import { PageViewport } from "./page_viewport.js";
|
import { PageViewport } from "./page_viewport.js";
|
||||||
import { XfaLayer } from "./xfa_layer.js";
|
import { XfaLayer } from "./xfa_layer.js";
|
||||||
|
|
||||||
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
||||||
|
|
||||||
class PixelsPerInch {
|
class PixelsPerInch {
|
||||||
static CSS = 96.0;
|
static CSS = 96.0;
|
||||||
|
|
||||||
@ -844,5 +842,4 @@ export {
|
|||||||
StatTimer,
|
StatTimer,
|
||||||
stopEvent,
|
stopEvent,
|
||||||
SupportedImageMimeTypes,
|
SupportedImageMimeTypes,
|
||||||
SVG_NS,
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import {
|
|||||||
FeatureTest,
|
FeatureTest,
|
||||||
getUuid,
|
getUuid,
|
||||||
shadow,
|
shadow,
|
||||||
|
SVG_NS,
|
||||||
Util,
|
Util,
|
||||||
warn,
|
warn,
|
||||||
} from "../../shared/util.js";
|
} from "../../shared/util.js";
|
||||||
@ -170,7 +171,7 @@ class ImageManager {
|
|||||||
// The "workaround" is to append "svgView(preserveAspectRatio(none))" to the
|
// The "workaround" is to append "svgView(preserveAspectRatio(none))" to the
|
||||||
// url, but according to comment #15, it seems that it leads to unexpected
|
// url, but according to comment #15, it seems that it leads to unexpected
|
||||||
// behavior in Safari.
|
// behavior in Safari.
|
||||||
const svg = `data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>`;
|
const svg = `data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${SVG_NS}"><rect width="1" height="1" style="fill:red;"/></svg>`;
|
||||||
const canvas = new OffscreenCanvas(1, 3);
|
const canvas = new OffscreenCanvas(1, 3);
|
||||||
const ctx = canvas.getContext("2d", { willReadFrequently: true });
|
const ctx = canvas.getContext("2d", { willReadFrequently: true });
|
||||||
const image = new Image();
|
const image = new Image();
|
||||||
|
|||||||
@ -13,8 +13,14 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { getRGB, isDataScheme, SVG_NS } from "./display_utils.js";
|
import { getRGB, isDataScheme } from "./display_utils.js";
|
||||||
import { unreachable, updateUrlHash, Util, warn } from "../shared/util.js";
|
import {
|
||||||
|
SVG_NS,
|
||||||
|
unreachable,
|
||||||
|
updateUrlHash,
|
||||||
|
Util,
|
||||||
|
warn,
|
||||||
|
} from "../shared/util.js";
|
||||||
|
|
||||||
class BaseFilterFactory {
|
class BaseFilterFactory {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|||||||
@ -13,8 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { SVG_NS } from "./display_utils.js";
|
import { SVG_NS, unreachable } from "../shared/util.js";
|
||||||
import { unreachable } from "../shared/util.js";
|
|
||||||
|
|
||||||
class BaseSVGFactory {
|
class BaseSVGFactory {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|||||||
@ -36,6 +36,8 @@ const LINE_FACTOR = 1.35;
|
|||||||
const LINE_DESCENT_FACTOR = 0.35;
|
const LINE_DESCENT_FACTOR = 0.35;
|
||||||
const BASELINE_FACTOR = LINE_DESCENT_FACTOR / LINE_FACTOR;
|
const BASELINE_FACTOR = LINE_DESCENT_FACTOR / LINE_FACTOR;
|
||||||
|
|
||||||
|
const SVG_NS = "http://www.w3.org/2000/svg";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refer to the `WorkerTransport.getRenderingIntent`-method in the API, to see
|
* Refer to the `WorkerTransport.getRenderingIntent`-method in the API, to see
|
||||||
* how these flags are being used:
|
* how these flags are being used:
|
||||||
@ -1237,6 +1239,7 @@ export {
|
|||||||
stringToBytes,
|
stringToBytes,
|
||||||
stringToUTF8String,
|
stringToUTF8String,
|
||||||
stripPath,
|
stripPath,
|
||||||
|
SVG_NS,
|
||||||
TextRenderingMode,
|
TextRenderingMode,
|
||||||
UnknownErrorException,
|
UnknownErrorException,
|
||||||
unreachable,
|
unreachable,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user