2017-02-24 07:35:35 +09:00
|
|
|
/* Copyright 2017 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.
|
|
|
|
*/
|
|
|
|
/* eslint-disable no-extend-native */
|
2017-11-16 21:50:57 +09:00
|
|
|
/* globals PDFJS */
|
2017-02-24 07:35:35 +09:00
|
|
|
|
2017-04-02 20:14:36 +09:00
|
|
|
// Skip compatibility checks for the extensions and if we already ran
|
2017-02-24 07:35:35 +09:00
|
|
|
// this module.
|
|
|
|
if ((typeof PDFJSDev === 'undefined' ||
|
|
|
|
!PDFJSDev.test('FIREFOX || MOZCENTRAL || CHROME')) &&
|
|
|
|
(typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked)) {
|
|
|
|
|
2017-08-23 07:06:11 +09:00
|
|
|
var globalScope = require('./global_scope');
|
2017-02-24 07:35:35 +09:00
|
|
|
|
|
|
|
var userAgent = (typeof navigator !== 'undefined' && navigator.userAgent) || '';
|
|
|
|
var isAndroid = /Android/.test(userAgent);
|
|
|
|
var isIOSChrome = userAgent.indexOf('CriOS') >= 0;
|
|
|
|
var isIE = userAgent.indexOf('Trident') >= 0;
|
|
|
|
var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
|
|
|
|
var isSafari = /Safari\//.test(userAgent) &&
|
|
|
|
!/(Chrome\/|Android\s)/.test(userAgent);
|
|
|
|
|
|
|
|
var hasDOM = typeof window === 'object' && typeof document === 'object';
|
|
|
|
|
|
|
|
// Initializing PDFJS global object here, it case if we need to change/disable
|
|
|
|
// some PDF.js features, e.g. range requests
|
|
|
|
if (typeof PDFJS === 'undefined') {
|
|
|
|
globalScope.PDFJS = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
PDFJS.compatibilityChecked = true;
|
|
|
|
|
|
|
|
// Checks if possible to use URL.createObjectURL()
|
|
|
|
// Support: IE, Chrome on iOS
|
|
|
|
(function checkOnBlobSupport() {
|
|
|
|
// sometimes IE and Chrome on iOS loosing the data created with
|
|
|
|
// createObjectURL(), see #3977 and #8081
|
|
|
|
if (isIE || isIOSChrome) {
|
|
|
|
PDFJS.disableCreateObjectURL = true;
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
|
|
|
|
// Checks if navigator.language is supported
|
|
|
|
(function checkNavigatorLanguage() {
|
|
|
|
if (typeof navigator === 'undefined') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ('language' in navigator) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
PDFJS.locale = navigator.userLanguage || 'en-US';
|
|
|
|
})();
|
|
|
|
|
2017-11-13 01:43:07 +09:00
|
|
|
// Support: Safari 6.0+, iOS
|
2017-02-24 07:35:35 +09:00
|
|
|
(function checkRangeRequests() {
|
|
|
|
// Safari has issues with cached range requests see:
|
|
|
|
// https://github.com/mozilla/pdf.js/issues/3260
|
|
|
|
// Last tested with version 6.0.4.
|
2017-11-13 01:43:07 +09:00
|
|
|
if (isSafari || isIOS) {
|
2017-02-24 07:35:35 +09:00
|
|
|
PDFJS.disableRange = true;
|
|
|
|
PDFJS.disableStream = true;
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
|
|
|
|
// Support: Android, iOS
|
|
|
|
(function checkCanvasSizeLimitation() {
|
|
|
|
if (isIOS || isAndroid) {
|
|
|
|
// 5MP
|
|
|
|
PDFJS.maxCanvasPixels = 5242880;
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
|
|
|
|
// Disable fullscreen support for certain problematic configurations.
|
|
|
|
// Support: IE11+ (when embedded).
|
|
|
|
(function checkFullscreenSupport() {
|
|
|
|
if (!hasDOM) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (isIE && window.parent !== window) {
|
|
|
|
PDFJS.disableFullscreen = true;
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
|
|
|
|
// Provides document.currentScript support
|
|
|
|
// Support: IE, Chrome<29.
|
|
|
|
(function checkCurrentScript() {
|
|
|
|
if (!hasDOM) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ('currentScript' in document) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Object.defineProperty(document, 'currentScript', {
|
2017-04-25 23:07:59 +09:00
|
|
|
get() {
|
2017-02-24 07:35:35 +09:00
|
|
|
var scripts = document.getElementsByTagName('script');
|
|
|
|
return scripts[scripts.length - 1];
|
|
|
|
},
|
|
|
|
enumerable: true,
|
Fix inconsistent spacing and trailing commas in objects in remaining `src/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/display/canvas.js b/src/display/canvas.js
index 5739f6f2..4216b2d2 100644
--- a/src/display/canvas.js
+++ b/src/display/canvas.js
@@ -2071,7 +2071,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var map = [];
for (var i = 0, ii = positions.length; i < ii; i += 2) {
map.push({ transform: [scaleX, 0, 0, scaleY, positions[i],
- positions[i + 1]], x: 0, y: 0, w: width, h: height, });
+ positions[i + 1]], x: 0, y: 0, w: width, h: height, });
}
this.paintInlineImageXObjectGroup(imgData, map);
},
diff --git a/src/display/svg.js b/src/display/svg.js
index 9eb05dfa..2aa21482 100644
--- a/src/display/svg.js
+++ b/src/display/svg.js
@@ -458,7 +458,11 @@ SVGGraphics = (function SVGGraphicsClosure() {
for (var x = 0; x < fnArrayLen; x++) {
var fnId = fnArray[x];
- opList.push({ 'fnId': fnId, 'fn': REVOPS[fnId], 'args': argsArray[x], });
+ opList.push({
+ 'fnId': fnId,
+ 'fn': REVOPS[fnId],
+ 'args': argsArray[x],
+ });
}
return opListToTree(opList);
},
```
2017-06-02 18:26:37 +09:00
|
|
|
configurable: true,
|
2017-02-24 07:35:35 +09:00
|
|
|
});
|
|
|
|
})();
|
|
|
|
|
|
|
|
// Provides support for ChildNode.remove in legacy browsers.
|
|
|
|
// Support: IE.
|
|
|
|
(function checkChildNodeRemove() {
|
|
|
|
if (!hasDOM) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (typeof Element.prototype.remove !== 'undefined') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Element.prototype.remove = function () {
|
|
|
|
if (this.parentNode) {
|
|
|
|
this.parentNode.removeChild(this);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
})();
|
|
|
|
|
2017-10-16 16:09:08 +09:00
|
|
|
// Provides support for Object.values in legacy browsers.
|
|
|
|
// Support: IE.
|
|
|
|
(function checkObjectValues() {
|
|
|
|
if (Object.values) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Object.values = require('core-js/fn/object/values');
|
|
|
|
})();
|
|
|
|
|
|
|
|
// Provides support for Array.prototype.includes in legacy browsers.
|
|
|
|
// Support: IE.
|
|
|
|
(function checkArrayIncludes() {
|
|
|
|
if (Array.prototype.includes) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Array.prototype.includes = require('core-js/fn/array/includes');
|
|
|
|
})();
|
|
|
|
|
2017-12-10 01:24:31 +09:00
|
|
|
// Provides support for Math.log2 in legacy browsers.
|
|
|
|
// Support: IE.
|
|
|
|
(function checkMathLog2() {
|
|
|
|
if (Math.log2) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Math.log2 = require('core-js/fn/math/log2');
|
|
|
|
})();
|
2017-10-16 16:09:08 +09:00
|
|
|
|
2017-07-13 18:48:17 +09:00
|
|
|
// Provides support for Number.isNaN in legacy browsers.
|
|
|
|
// Support: IE.
|
|
|
|
(function checkNumberIsNaN() {
|
|
|
|
if (Number.isNaN) {
|
|
|
|
return;
|
|
|
|
}
|
2017-10-21 19:58:53 +09:00
|
|
|
Number.isNaN = require('core-js/fn/number/is-nan');
|
2017-07-13 18:48:17 +09:00
|
|
|
})();
|
|
|
|
|
|
|
|
// Provides support for Number.isInteger in legacy browsers.
|
|
|
|
// Support: IE.
|
|
|
|
(function checkNumberIsInteger() {
|
|
|
|
if (Number.isInteger) {
|
|
|
|
return;
|
|
|
|
}
|
2017-10-21 19:58:53 +09:00
|
|
|
Number.isInteger = require('core-js/fn/number/is-integer');
|
2017-07-13 18:48:17 +09:00
|
|
|
})();
|
|
|
|
|
2017-02-24 07:35:35 +09:00
|
|
|
(function checkPromise() {
|
|
|
|
if (globalScope.Promise) {
|
|
|
|
return;
|
|
|
|
}
|
2017-10-21 19:49:15 +09:00
|
|
|
globalScope.Promise = require('core-js/fn/promise');
|
2017-02-24 07:35:35 +09:00
|
|
|
})();
|
|
|
|
|
|
|
|
(function checkWeakMap() {
|
|
|
|
if (globalScope.WeakMap) {
|
|
|
|
return;
|
|
|
|
}
|
2017-10-15 17:22:06 +09:00
|
|
|
globalScope.WeakMap = require('core-js/fn/weak-map');
|
2017-02-24 07:35:35 +09:00
|
|
|
})();
|
|
|
|
|
|
|
|
// Polyfill from https://github.com/Polymer/URL
|
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
(function checkURLConstructor() {
|
|
|
|
// feature detect for URL constructor
|
|
|
|
var hasWorkingUrl = false;
|
|
|
|
try {
|
|
|
|
if (typeof URL === 'function' &&
|
|
|
|
typeof URL.prototype === 'object' &&
|
|
|
|
('origin' in URL.prototype)) {
|
|
|
|
var u = new URL('b', 'http://a');
|
|
|
|
u.pathname = 'c%20d';
|
|
|
|
hasWorkingUrl = u.href === 'http://a/c%20d';
|
|
|
|
}
|
|
|
|
} catch (e) { }
|
|
|
|
|
|
|
|
if (hasWorkingUrl) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var relative = Object.create(null);
|
|
|
|
relative['ftp'] = 21;
|
|
|
|
relative['file'] = 0;
|
|
|
|
relative['gopher'] = 70;
|
|
|
|
relative['http'] = 80;
|
|
|
|
relative['https'] = 443;
|
|
|
|
relative['ws'] = 80;
|
|
|
|
relative['wss'] = 443;
|
|
|
|
|
|
|
|
var relativePathDotMapping = Object.create(null);
|
|
|
|
relativePathDotMapping['%2e'] = '.';
|
|
|
|
relativePathDotMapping['.%2e'] = '..';
|
|
|
|
relativePathDotMapping['%2e.'] = '..';
|
|
|
|
relativePathDotMapping['%2e%2e'] = '..';
|
|
|
|
|
|
|
|
function isRelativeScheme(scheme) {
|
|
|
|
return relative[scheme] !== undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
function invalid() {
|
|
|
|
clear.call(this);
|
|
|
|
this._isInvalid = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function IDNAToASCII(h) {
|
|
|
|
if (h === '') {
|
|
|
|
invalid.call(this);
|
|
|
|
}
|
|
|
|
// XXX
|
|
|
|
return h.toLowerCase();
|
|
|
|
}
|
|
|
|
|
|
|
|
function percentEscape(c) {
|
|
|
|
var unicode = c.charCodeAt(0);
|
|
|
|
if (unicode > 0x20 &&
|
|
|
|
unicode < 0x7F &&
|
|
|
|
// " # < > ? `
|
|
|
|
[0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) === -1
|
|
|
|
) {
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
return encodeURIComponent(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
function percentEscapeQuery(c) {
|
|
|
|
// XXX This actually needs to encode c using encoding and then
|
|
|
|
// convert the bytes one-by-one.
|
|
|
|
|
|
|
|
var unicode = c.charCodeAt(0);
|
|
|
|
if (unicode > 0x20 &&
|
|
|
|
unicode < 0x7F &&
|
|
|
|
// " # < > ` (do not escape '?')
|
|
|
|
[0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) === -1
|
|
|
|
) {
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
return encodeURIComponent(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
var EOF, ALPHA = /[a-zA-Z]/,
|
|
|
|
ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
|
|
|
|
|
|
|
|
function parse(input, stateOverride, base) {
|
|
|
|
function err(message) {
|
|
|
|
errors.push(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
var state = stateOverride || 'scheme start',
|
|
|
|
cursor = 0,
|
|
|
|
buffer = '',
|
|
|
|
seenAt = false,
|
|
|
|
seenBracket = false,
|
|
|
|
errors = [];
|
|
|
|
|
|
|
|
loop: while ((input[cursor - 1] !== EOF || cursor === 0) &&
|
|
|
|
!this._isInvalid) {
|
|
|
|
var c = input[cursor];
|
|
|
|
switch (state) {
|
|
|
|
case 'scheme start':
|
|
|
|
if (c && ALPHA.test(c)) {
|
|
|
|
buffer += c.toLowerCase(); // ASCII-safe
|
|
|
|
state = 'scheme';
|
|
|
|
} else if (!stateOverride) {
|
|
|
|
buffer = '';
|
|
|
|
state = 'no scheme';
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
err('Invalid scheme.');
|
|
|
|
break loop;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'scheme':
|
|
|
|
if (c && ALPHANUMERIC.test(c)) {
|
|
|
|
buffer += c.toLowerCase(); // ASCII-safe
|
|
|
|
} else if (c === ':') {
|
|
|
|
this._scheme = buffer;
|
|
|
|
buffer = '';
|
|
|
|
if (stateOverride) {
|
|
|
|
break loop;
|
|
|
|
}
|
|
|
|
if (isRelativeScheme(this._scheme)) {
|
|
|
|
this._isRelative = true;
|
|
|
|
}
|
|
|
|
if (this._scheme === 'file') {
|
|
|
|
state = 'relative';
|
|
|
|
} else if (this._isRelative && base &&
|
|
|
|
base._scheme === this._scheme) {
|
|
|
|
state = 'relative or authority';
|
|
|
|
} else if (this._isRelative) {
|
|
|
|
state = 'authority first slash';
|
|
|
|
} else {
|
|
|
|
state = 'scheme data';
|
|
|
|
}
|
|
|
|
} else if (!stateOverride) {
|
|
|
|
buffer = '';
|
|
|
|
cursor = 0;
|
|
|
|
state = 'no scheme';
|
|
|
|
continue;
|
2017-03-07 00:50:22 +09:00
|
|
|
} else if (c === EOF) {
|
2017-02-24 07:35:35 +09:00
|
|
|
break loop;
|
|
|
|
} else {
|
|
|
|
err('Code point not allowed in scheme: ' + c);
|
|
|
|
break loop;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'scheme data':
|
|
|
|
if (c === '?') {
|
|
|
|
this._query = '?';
|
|
|
|
state = 'query';
|
|
|
|
} else if (c === '#') {
|
|
|
|
this._fragment = '#';
|
|
|
|
state = 'fragment';
|
|
|
|
} else {
|
|
|
|
// XXX error handling
|
2017-03-07 00:50:22 +09:00
|
|
|
if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
|
2017-02-24 07:35:35 +09:00
|
|
|
this._schemeData += percentEscape(c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'no scheme':
|
|
|
|
if (!base || !(isRelativeScheme(base._scheme))) {
|
|
|
|
err('Missing scheme.');
|
|
|
|
invalid.call(this);
|
|
|
|
} else {
|
|
|
|
state = 'relative';
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'relative or authority':
|
|
|
|
if (c === '/' && input[cursor + 1] === '/') {
|
|
|
|
state = 'authority ignore slashes';
|
|
|
|
} else {
|
|
|
|
err('Expected /, got: ' + c);
|
|
|
|
state = 'relative';
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'relative':
|
|
|
|
this._isRelative = true;
|
2017-03-07 00:50:22 +09:00
|
|
|
if (this._scheme !== 'file') {
|
2017-02-24 07:35:35 +09:00
|
|
|
this._scheme = base._scheme;
|
|
|
|
}
|
2017-03-07 00:50:22 +09:00
|
|
|
if (c === EOF) {
|
2017-02-24 07:35:35 +09:00
|
|
|
this._host = base._host;
|
|
|
|
this._port = base._port;
|
|
|
|
this._path = base._path.slice();
|
|
|
|
this._query = base._query;
|
|
|
|
this._username = base._username;
|
|
|
|
this._password = base._password;
|
|
|
|
break loop;
|
|
|
|
} else if (c === '/' || c === '\\') {
|
|
|
|
if (c === '\\') {
|
|
|
|
err('\\ is an invalid code point.');
|
|
|
|
}
|
|
|
|
state = 'relative slash';
|
|
|
|
} else if (c === '?') {
|
|
|
|
this._host = base._host;
|
|
|
|
this._port = base._port;
|
|
|
|
this._path = base._path.slice();
|
|
|
|
this._query = '?';
|
|
|
|
this._username = base._username;
|
|
|
|
this._password = base._password;
|
|
|
|
state = 'query';
|
|
|
|
} else if (c === '#') {
|
|
|
|
this._host = base._host;
|
|
|
|
this._port = base._port;
|
|
|
|
this._path = base._path.slice();
|
|
|
|
this._query = base._query;
|
|
|
|
this._fragment = '#';
|
|
|
|
this._username = base._username;
|
|
|
|
this._password = base._password;
|
|
|
|
state = 'fragment';
|
|
|
|
} else {
|
|
|
|
var nextC = input[cursor + 1];
|
|
|
|
var nextNextC = input[cursor + 2];
|
2017-03-07 00:50:22 +09:00
|
|
|
if (this._scheme !== 'file' || !ALPHA.test(c) ||
|
2017-02-24 07:35:35 +09:00
|
|
|
(nextC !== ':' && nextC !== '|') ||
|
2017-03-07 00:50:22 +09:00
|
|
|
(nextNextC !== EOF && nextNextC !== '/' && nextNextC !== '\\' &&
|
|
|
|
nextNextC !== '?' && nextNextC !== '#')) {
|
2017-02-24 07:35:35 +09:00
|
|
|
this._host = base._host;
|
|
|
|
this._port = base._port;
|
|
|
|
this._username = base._username;
|
|
|
|
this._password = base._password;
|
|
|
|
this._path = base._path.slice();
|
|
|
|
this._path.pop();
|
|
|
|
}
|
|
|
|
state = 'relative path';
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'relative slash':
|
|
|
|
if (c === '/' || c === '\\') {
|
|
|
|
if (c === '\\') {
|
|
|
|
err('\\ is an invalid code point.');
|
|
|
|
}
|
|
|
|
if (this._scheme === 'file') {
|
|
|
|
state = 'file host';
|
|
|
|
} else {
|
|
|
|
state = 'authority ignore slashes';
|
|
|
|
}
|
|
|
|
} else {
|
2017-03-07 00:50:22 +09:00
|
|
|
if (this._scheme !== 'file') {
|
2017-02-24 07:35:35 +09:00
|
|
|
this._host = base._host;
|
|
|
|
this._port = base._port;
|
|
|
|
this._username = base._username;
|
|
|
|
this._password = base._password;
|
|
|
|
}
|
|
|
|
state = 'relative path';
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'authority first slash':
|
|
|
|
if (c === '/') {
|
|
|
|
state = 'authority second slash';
|
|
|
|
} else {
|
|
|
|
err('Expected \'/\', got: ' + c);
|
|
|
|
state = 'authority ignore slashes';
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'authority second slash':
|
|
|
|
state = 'authority ignore slashes';
|
2017-03-07 00:50:22 +09:00
|
|
|
if (c !== '/') {
|
2017-02-24 07:35:35 +09:00
|
|
|
err('Expected \'/\', got: ' + c);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'authority ignore slashes':
|
2017-03-07 00:50:22 +09:00
|
|
|
if (c !== '/' && c !== '\\') {
|
2017-02-24 07:35:35 +09:00
|
|
|
state = 'authority';
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
err('Expected authority, got: ' + c);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'authority':
|
|
|
|
if (c === '@') {
|
|
|
|
if (seenAt) {
|
|
|
|
err('@ already seen.');
|
|
|
|
buffer += '%40';
|
|
|
|
}
|
|
|
|
seenAt = true;
|
|
|
|
for (var i = 0; i < buffer.length; i++) {
|
|
|
|
var cp = buffer[i];
|
|
|
|
if (cp === '\t' || cp === '\n' || cp === '\r') {
|
|
|
|
err('Invalid whitespace in authority.');
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// XXX check URL code points
|
|
|
|
if (cp === ':' && this._password === null) {
|
|
|
|
this._password = '';
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
var tempC = percentEscape(cp);
|
2017-03-07 00:50:22 +09:00
|
|
|
if (this._password !== null) {
|
2017-02-24 07:35:35 +09:00
|
|
|
this._password += tempC;
|
|
|
|
} else {
|
|
|
|
this._username += tempC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
buffer = '';
|
|
|
|
} else if (c === EOF || c === '/' || c === '\\' ||
|
|
|
|
c === '?' || c === '#') {
|
|
|
|
cursor -= buffer.length;
|
|
|
|
buffer = '';
|
|
|
|
state = 'host';
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
buffer += c;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'file host':
|
|
|
|
if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
|
|
|
|
if (buffer.length === 2 && ALPHA.test(buffer[0]) &&
|
|
|
|
(buffer[1] === ':' || buffer[1] === '|')) {
|
|
|
|
state = 'relative path';
|
|
|
|
} else if (buffer.length === 0) {
|
|
|
|
state = 'relative path start';
|
|
|
|
} else {
|
|
|
|
this._host = IDNAToASCII.call(this, buffer);
|
|
|
|
buffer = '';
|
|
|
|
state = 'relative path start';
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
} else if (c === '\t' || c === '\n' || c === '\r') {
|
|
|
|
err('Invalid whitespace in file host.');
|
|
|
|
} else {
|
|
|
|
buffer += c;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'host':
|
|
|
|
case 'hostname':
|
|
|
|
if (c === ':' && !seenBracket) {
|
|
|
|
// XXX host parsing
|
|
|
|
this._host = IDNAToASCII.call(this, buffer);
|
|
|
|
buffer = '';
|
|
|
|
state = 'port';
|
|
|
|
if (stateOverride === 'hostname') {
|
|
|
|
break loop;
|
|
|
|
}
|
|
|
|
} else if (c === EOF || c === '/' ||
|
|
|
|
c === '\\' || c === '?' || c === '#') {
|
|
|
|
this._host = IDNAToASCII.call(this, buffer);
|
|
|
|
buffer = '';
|
|
|
|
state = 'relative path start';
|
|
|
|
if (stateOverride) {
|
|
|
|
break loop;
|
|
|
|
}
|
|
|
|
continue;
|
2017-03-07 00:50:22 +09:00
|
|
|
} else if (c !== '\t' && c !== '\n' && c !== '\r') {
|
2017-02-24 07:35:35 +09:00
|
|
|
if (c === '[') {
|
|
|
|
seenBracket = true;
|
|
|
|
} else if (c === ']') {
|
|
|
|
seenBracket = false;
|
|
|
|
}
|
|
|
|
buffer += c;
|
|
|
|
} else {
|
|
|
|
err('Invalid code point in host/hostname: ' + c);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'port':
|
|
|
|
if (/[0-9]/.test(c)) {
|
|
|
|
buffer += c;
|
|
|
|
} else if (c === EOF || c === '/' || c === '\\' ||
|
|
|
|
c === '?' || c === '#' || stateOverride) {
|
2017-03-07 00:50:22 +09:00
|
|
|
if (buffer !== '') {
|
2017-02-24 07:35:35 +09:00
|
|
|
var temp = parseInt(buffer, 10);
|
|
|
|
if (temp !== relative[this._scheme]) {
|
|
|
|
this._port = temp + '';
|
|
|
|
}
|
|
|
|
buffer = '';
|
|
|
|
}
|
|
|
|
if (stateOverride) {
|
|
|
|
break loop;
|
|
|
|
}
|
|
|
|
state = 'relative path start';
|
|
|
|
continue;
|
|
|
|
} else if (c === '\t' || c === '\n' || c === '\r') {
|
|
|
|
err('Invalid code point in port: ' + c);
|
|
|
|
} else {
|
|
|
|
invalid.call(this);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'relative path start':
|
|
|
|
if (c === '\\') {
|
|
|
|
err('\'\\\' not allowed in path.');
|
|
|
|
}
|
|
|
|
state = 'relative path';
|
2017-03-07 00:50:22 +09:00
|
|
|
if (c !== '/' && c !== '\\') {
|
2017-02-24 07:35:35 +09:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'relative path':
|
|
|
|
if (c === EOF || c === '/' || c === '\\' ||
|
|
|
|
(!stateOverride && (c === '?' || c === '#'))) {
|
|
|
|
if (c === '\\') {
|
|
|
|
err('\\ not allowed in relative path.');
|
|
|
|
}
|
|
|
|
var tmp;
|
|
|
|
if ((tmp = relativePathDotMapping[buffer.toLowerCase()])) {
|
|
|
|
buffer = tmp;
|
|
|
|
}
|
|
|
|
if (buffer === '..') {
|
|
|
|
this._path.pop();
|
2017-03-07 00:50:22 +09:00
|
|
|
if (c !== '/' && c !== '\\') {
|
2017-02-24 07:35:35 +09:00
|
|
|
this._path.push('');
|
|
|
|
}
|
2017-03-07 00:50:22 +09:00
|
|
|
} else if (buffer === '.' && c !== '/' && c !== '\\') {
|
2017-02-24 07:35:35 +09:00
|
|
|
this._path.push('');
|
2017-03-07 00:50:22 +09:00
|
|
|
} else if (buffer !== '.') {
|
2017-02-24 07:35:35 +09:00
|
|
|
if (this._scheme === 'file' && this._path.length === 0 &&
|
|
|
|
buffer.length === 2 && ALPHA.test(buffer[0]) &&
|
|
|
|
buffer[1] === '|') {
|
|
|
|
buffer = buffer[0] + ':';
|
|
|
|
}
|
|
|
|
this._path.push(buffer);
|
|
|
|
}
|
|
|
|
buffer = '';
|
|
|
|
if (c === '?') {
|
|
|
|
this._query = '?';
|
|
|
|
state = 'query';
|
|
|
|
} else if (c === '#') {
|
|
|
|
this._fragment = '#';
|
|
|
|
state = 'fragment';
|
|
|
|
}
|
2017-03-07 00:50:22 +09:00
|
|
|
} else if (c !== '\t' && c !== '\n' && c !== '\r') {
|
2017-02-24 07:35:35 +09:00
|
|
|
buffer += percentEscape(c);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'query':
|
|
|
|
if (!stateOverride && c === '#') {
|
|
|
|
this._fragment = '#';
|
|
|
|
state = 'fragment';
|
2017-03-07 00:50:22 +09:00
|
|
|
} else if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
|
2017-02-24 07:35:35 +09:00
|
|
|
this._query += percentEscapeQuery(c);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'fragment':
|
2017-03-07 00:50:22 +09:00
|
|
|
if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
|
2017-02-24 07:35:35 +09:00
|
|
|
this._fragment += c;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
cursor++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function clear() {
|
|
|
|
this._scheme = '';
|
|
|
|
this._schemeData = '';
|
|
|
|
this._username = '';
|
|
|
|
this._password = null;
|
|
|
|
this._host = '';
|
|
|
|
this._port = '';
|
|
|
|
this._path = [];
|
|
|
|
this._query = '';
|
|
|
|
this._fragment = '';
|
|
|
|
this._isInvalid = false;
|
|
|
|
this._isRelative = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Does not process domain names or IP addresses.
|
|
|
|
// Does not handle encoding for the query parameter.
|
|
|
|
function JURL(url, base /* , encoding */) {
|
|
|
|
if (base !== undefined && !(base instanceof JURL)) {
|
|
|
|
base = new JURL(String(base));
|
|
|
|
}
|
|
|
|
|
|
|
|
this._url = url;
|
|
|
|
clear.call(this);
|
|
|
|
|
|
|
|
var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
|
|
|
|
// encoding = encoding || 'utf-8'
|
|
|
|
|
|
|
|
parse.call(this, input, null, base);
|
|
|
|
}
|
|
|
|
|
|
|
|
JURL.prototype = {
|
2017-04-25 23:07:59 +09:00
|
|
|
toString() {
|
2017-02-24 07:35:35 +09:00
|
|
|
return this.href;
|
|
|
|
},
|
|
|
|
get href() {
|
|
|
|
if (this._isInvalid) {
|
|
|
|
return this._url;
|
|
|
|
}
|
|
|
|
var authority = '';
|
2017-03-07 00:50:22 +09:00
|
|
|
if (this._username !== '' || this._password !== null) {
|
2017-02-24 07:35:35 +09:00
|
|
|
authority = this._username +
|
2017-03-07 00:50:22 +09:00
|
|
|
(this._password !== null ? ':' + this._password : '') + '@';
|
2017-02-24 07:35:35 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
return this.protocol +
|
|
|
|
(this._isRelative ? '//' + authority + this.host : '') +
|
|
|
|
this.pathname + this._query + this._fragment;
|
|
|
|
},
|
2017-06-19 21:27:04 +09:00
|
|
|
// The named parameter should be different from the setter's function name.
|
|
|
|
// Otherwise Safari 5 will throw an error (see issue 8541)
|
|
|
|
set href(value) {
|
2017-02-24 07:35:35 +09:00
|
|
|
clear.call(this);
|
2017-06-19 21:27:04 +09:00
|
|
|
parse.call(this, value);
|
2017-02-24 07:35:35 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
get protocol() {
|
|
|
|
return this._scheme + ':';
|
|
|
|
},
|
2017-06-19 21:27:04 +09:00
|
|
|
set protocol(value) {
|
2017-02-24 07:35:35 +09:00
|
|
|
if (this._isInvalid) {
|
|
|
|
return;
|
|
|
|
}
|
2017-06-19 21:27:04 +09:00
|
|
|
parse.call(this, value + ':', 'scheme start');
|
2017-02-24 07:35:35 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
get host() {
|
|
|
|
return this._isInvalid ? '' : this._port ?
|
|
|
|
this._host + ':' + this._port : this._host;
|
|
|
|
},
|
2017-06-19 21:27:04 +09:00
|
|
|
set host(value) {
|
2017-02-24 07:35:35 +09:00
|
|
|
if (this._isInvalid || !this._isRelative) {
|
|
|
|
return;
|
|
|
|
}
|
2017-06-19 21:27:04 +09:00
|
|
|
parse.call(this, value, 'host');
|
2017-02-24 07:35:35 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
get hostname() {
|
|
|
|
return this._host;
|
|
|
|
},
|
2017-06-19 21:27:04 +09:00
|
|
|
set hostname(value) {
|
2017-02-24 07:35:35 +09:00
|
|
|
if (this._isInvalid || !this._isRelative) {
|
|
|
|
return;
|
|
|
|
}
|
2017-06-19 21:27:04 +09:00
|
|
|
parse.call(this, value, 'hostname');
|
2017-02-24 07:35:35 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
get port() {
|
|
|
|
return this._port;
|
|
|
|
},
|
2017-06-19 21:27:04 +09:00
|
|
|
set port(value) {
|
2017-02-24 07:35:35 +09:00
|
|
|
if (this._isInvalid || !this._isRelative) {
|
|
|
|
return;
|
|
|
|
}
|
2017-06-19 21:27:04 +09:00
|
|
|
parse.call(this, value, 'port');
|
2017-02-24 07:35:35 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
get pathname() {
|
|
|
|
return this._isInvalid ? '' : this._isRelative ?
|
|
|
|
'/' + this._path.join('/') : this._schemeData;
|
|
|
|
},
|
2017-06-19 21:27:04 +09:00
|
|
|
set pathname(value) {
|
2017-02-24 07:35:35 +09:00
|
|
|
if (this._isInvalid || !this._isRelative) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this._path = [];
|
2017-06-19 21:27:04 +09:00
|
|
|
parse.call(this, value, 'relative path start');
|
2017-02-24 07:35:35 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
get search() {
|
|
|
|
return this._isInvalid || !this._query || this._query === '?' ?
|
|
|
|
'' : this._query;
|
|
|
|
},
|
2017-06-19 21:27:04 +09:00
|
|
|
set search(value) {
|
2017-02-24 07:35:35 +09:00
|
|
|
if (this._isInvalid || !this._isRelative) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this._query = '?';
|
2017-06-19 21:27:04 +09:00
|
|
|
if (value[0] === '?') {
|
|
|
|
value = value.slice(1);
|
2017-02-24 07:35:35 +09:00
|
|
|
}
|
2017-06-19 21:27:04 +09:00
|
|
|
parse.call(this, value, 'query');
|
2017-02-24 07:35:35 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
get hash() {
|
|
|
|
return this._isInvalid || !this._fragment || this._fragment === '#' ?
|
|
|
|
'' : this._fragment;
|
|
|
|
},
|
2017-06-19 21:27:04 +09:00
|
|
|
set hash(value) {
|
2017-02-24 07:35:35 +09:00
|
|
|
if (this._isInvalid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this._fragment = '#';
|
2017-06-19 21:27:04 +09:00
|
|
|
if (value[0] === '#') {
|
|
|
|
value = value.slice(1);
|
2017-02-24 07:35:35 +09:00
|
|
|
}
|
2017-06-19 21:27:04 +09:00
|
|
|
parse.call(this, value, 'fragment');
|
2017-02-24 07:35:35 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
get origin() {
|
|
|
|
var host;
|
|
|
|
if (this._isInvalid || !this._scheme) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
// javascript: Gecko returns String(""), WebKit/Blink String("null")
|
|
|
|
// Gecko throws error for "data://"
|
|
|
|
// data: Gecko returns "", Blink returns "data://", WebKit returns "null"
|
|
|
|
// Gecko returns String("") for file: mailto:
|
|
|
|
// WebKit/Blink returns String("SCHEME://") for file: mailto:
|
|
|
|
switch (this._scheme) {
|
|
|
|
case 'data':
|
|
|
|
case 'file':
|
|
|
|
case 'javascript':
|
|
|
|
case 'mailto':
|
|
|
|
return 'null';
|
2017-04-14 04:48:53 +09:00
|
|
|
case 'blob':
|
|
|
|
// Special case of blob: -- returns valid origin of _schemeData.
|
|
|
|
try {
|
|
|
|
return new JURL(this._schemeData).origin || 'null';
|
|
|
|
} catch (_) {
|
|
|
|
// Invalid _schemeData origin -- ignoring errors.
|
|
|
|
}
|
|
|
|
return 'null';
|
2017-02-24 07:35:35 +09:00
|
|
|
}
|
|
|
|
host = this.host;
|
|
|
|
if (!host) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
return this._scheme + '://' + host;
|
Fix inconsistent spacing and trailing commas in objects in remaining `src/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/display/canvas.js b/src/display/canvas.js
index 5739f6f2..4216b2d2 100644
--- a/src/display/canvas.js
+++ b/src/display/canvas.js
@@ -2071,7 +2071,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var map = [];
for (var i = 0, ii = positions.length; i < ii; i += 2) {
map.push({ transform: [scaleX, 0, 0, scaleY, positions[i],
- positions[i + 1]], x: 0, y: 0, w: width, h: height, });
+ positions[i + 1]], x: 0, y: 0, w: width, h: height, });
}
this.paintInlineImageXObjectGroup(imgData, map);
},
diff --git a/src/display/svg.js b/src/display/svg.js
index 9eb05dfa..2aa21482 100644
--- a/src/display/svg.js
+++ b/src/display/svg.js
@@ -458,7 +458,11 @@ SVGGraphics = (function SVGGraphicsClosure() {
for (var x = 0; x < fnArrayLen; x++) {
var fnId = fnArray[x];
- opList.push({ 'fnId': fnId, 'fn': REVOPS[fnId], 'args': argsArray[x], });
+ opList.push({
+ 'fnId': fnId,
+ 'fn': REVOPS[fnId],
+ 'args': argsArray[x],
+ });
}
return opListToTree(opList);
},
```
2017-06-02 18:26:37 +09:00
|
|
|
},
|
2017-02-24 07:35:35 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
// Copy over the static methods
|
|
|
|
var OriginalURL = globalScope.URL;
|
|
|
|
if (OriginalURL) {
|
|
|
|
JURL.createObjectURL = function(blob) {
|
|
|
|
// IE extension allows a second optional options argument.
|
|
|
|
// http://msdn.microsoft.com/en-us/library/ie/hh772302(v=vs.85).aspx
|
|
|
|
return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
|
|
|
|
};
|
|
|
|
JURL.revokeObjectURL = function(url) {
|
|
|
|
OriginalURL.revokeObjectURL(url);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
globalScope.URL = JURL;
|
|
|
|
})();
|
|
|
|
|
|
|
|
}
|