Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
ea47a49dd0
31
external/jpgjs/LICENSE
vendored
31
external/jpgjs/LICENSE
vendored
@ -1,24 +1,17 @@
|
|||||||
|
|
||||||
Copyright (C) 2011 by notmasteryet
|
Copyright (C) 2011 notmasteryet
|
||||||
|
|
||||||
Contributors: Yury Delendik
|
Contributors: Yury Delendik <ydelendik@mozilla.com>
|
||||||
Brendan Dahl <bdahl@mozilla.com>
|
Brendan Dahl <bdahl@mozilla.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
a copy of this software and associated documentation files (the
|
you may not use this file except in compliance with the License.
|
||||||
"Software"), to deal in the Software without restriction, including
|
You may obtain a copy of the License at
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
Unless required by applicable law or agreed to in writing, software
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
See the License for the specific language governing permissions and
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
limitations under the License.
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
27
external/jpgjs/jpg.js
vendored
27
external/jpgjs/jpg.js
vendored
@ -1,5 +1,20 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||||
|
/*
|
||||||
|
Copyright 2011 notmasteryet
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
// - The JPEG specification can be found in the ITU CCITT Recommendation T.81
|
// - The JPEG specification can be found in the ITU CCITT Recommendation T.81
|
||||||
// (www.w3.org/Graphics/JPEG/itu-t81.pdf)
|
// (www.w3.org/Graphics/JPEG/itu-t81.pdf)
|
||||||
@ -627,8 +642,9 @@ var JpegImage = (function jpegImage() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xFFDB: // DQT (Define Quantization Tables)
|
case 0xFFDB: // DQT (Define Quantization Tables)
|
||||||
var quantizationTableCount = Math.floor((readUint16() - 2) / 65);
|
var quantizationTablesLength = readUint16();
|
||||||
for (i = 0; i < quantizationTableCount; i++) {
|
var quantizationTablesEnd = quantizationTablesLength + offset - 2;
|
||||||
|
while (offset < quantizationTablesEnd) {
|
||||||
var quantizationTableSpec = data[offset++];
|
var quantizationTableSpec = data[offset++];
|
||||||
var tableData = new Int32Array(64);
|
var tableData = new Int32Array(64);
|
||||||
if ((quantizationTableSpec >> 4) === 0) { // 8 bit values
|
if ((quantizationTableSpec >> 4) === 0) { // 8 bit values
|
||||||
@ -721,6 +737,13 @@ var JpegImage = (function jpegImage() {
|
|||||||
offset += processed;
|
offset += processed;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if (data[offset - 3] == 0xFF &&
|
||||||
|
data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
|
||||||
|
// could be incorrect encoding -- last 0xFF byte of the previous
|
||||||
|
// block was eaten by the encoder
|
||||||
|
offset -= 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
throw "unknown JPEG marker " + fileMarker.toString(16);
|
throw "unknown JPEG marker " + fileMarker.toString(16);
|
||||||
}
|
}
|
||||||
fileMarker = readUint16();
|
fileMarker = readUint16();
|
||||||
|
11
make.js
11
make.js
@ -618,18 +618,18 @@ target.chrome = function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// If there was no chrome entry in the browser manifest, exit
|
// If there was no chrome entry in the browser manifest, exit
|
||||||
if(!executable) {
|
if (!executable) {
|
||||||
echo('There was no \'chrome\' entry in the browser manifest');
|
echo('There was no \'chrome\' entry in the browser manifest');
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're on a Darwin (Mac) OS, then let's check for an .app path
|
// If we're on a Darwin (Mac) OS, then let's check for an .app path
|
||||||
if (process.platform === 'darwin' && executable.indexOf('.app') !== -1) {
|
if (process.platform === 'darwin' && executable.indexOf('.app') !== -1) {
|
||||||
executable = executable + '/Contents/MacOS/Google Chrome');
|
executable = executable + '/Contents/MacOS/Google Chrome';
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the chrome executable doesn't exist
|
// If the chrome executable doesn't exist
|
||||||
if(!test('-f', executable)) {
|
if (!test('-f', executable)) {
|
||||||
echo('Incorrect executable path to chrome');
|
echo('Incorrect executable path to chrome');
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -765,7 +765,10 @@ target.lint = function() {
|
|||||||
echo();
|
echo();
|
||||||
echo('### Linting JS files (this can take a while!)');
|
echo('### Linting JS files (this can take a while!)');
|
||||||
|
|
||||||
var LINT_FILES = ['src/*.js',
|
var LINT_FILES = ['make.js',
|
||||||
|
'external/builder/*.js',
|
||||||
|
'external/crlfchecker/*.js',
|
||||||
|
'src/*.js',
|
||||||
'web/*.js',
|
'web/*.js',
|
||||||
'test/*.js',
|
'test/*.js',
|
||||||
'test/unit/*.js',
|
'test/unit/*.js',
|
||||||
|
126
src/fonts.js
126
src/fonts.js
@ -404,28 +404,15 @@ function mapPrivateUseChars(code) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var FontLoader = {
|
var FontLoader = {
|
||||||
listeningForFontLoad: false,
|
loadingContext: {
|
||||||
|
requests: [],
|
||||||
|
nextRequestId: 0
|
||||||
|
},
|
||||||
|
|
||||||
bind: function fontLoaderBind(fonts, callback) {
|
bind: function fontLoaderBind(fonts, callback) {
|
||||||
function checkFontsLoaded() {
|
assert(!isWorker, 'bind() shall be called from main thread');
|
||||||
for (var i = 0, ii = fonts.length; i < ii; i++) {
|
|
||||||
var fontObj = fonts[i];
|
|
||||||
if (fontObj.loading) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
document.documentElement.removeEventListener(
|
|
||||||
'pdfjsFontLoad', checkFontsLoaded, false);
|
|
||||||
|
|
||||||
// Use timeout to fix chrome intermittent failures on font loading.
|
|
||||||
setTimeout(callback, 0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var rules = [], names = [], fontsToLoad = [];
|
|
||||||
var fontCreateTimer = 0;
|
|
||||||
|
|
||||||
|
var rules = [], fontsToLoad = [];
|
||||||
for (var i = 0, ii = fonts.length; i < ii; i++) {
|
for (var i = 0, ii = fonts.length; i < ii; i++) {
|
||||||
var font = fonts[i];
|
var font = fonts[i];
|
||||||
|
|
||||||
@ -436,8 +423,6 @@ var FontLoader = {
|
|||||||
}
|
}
|
||||||
font.attached = true;
|
font.attached = true;
|
||||||
|
|
||||||
fontsToLoad.push(font);
|
|
||||||
|
|
||||||
var str = '';
|
var str = '';
|
||||||
var data = font.data;
|
var data = font.data;
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -448,28 +433,51 @@ var FontLoader = {
|
|||||||
var rule = font.bindDOM(str);
|
var rule = font.bindDOM(str);
|
||||||
if (rule) {
|
if (rule) {
|
||||||
rules.push(rule);
|
rules.push(rule);
|
||||||
names.push(font.loadedName);
|
fontsToLoad.push(font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.listeningForFontLoad = false;
|
var request = FontLoader.queueLoadingCallback(callback);
|
||||||
if (!isWorker && rules.length) {
|
if (rules.length > 0) {
|
||||||
FontLoader.prepareFontLoadEvent(rules, names, fontsToLoad);
|
FontLoader.prepareFontLoadEvent(rules, fontsToLoad, request);
|
||||||
}
|
} else {
|
||||||
|
request.complete();
|
||||||
if (!checkFontsLoaded()) {
|
|
||||||
document.documentElement.addEventListener(
|
|
||||||
'pdfjsFontLoad', checkFontsLoaded, false);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
queueLoadingCallback: function FontLoader_queueLoadingCallback(callback) {
|
||||||
|
function LoadLoader_completeRequest() {
|
||||||
|
assert(!request.end, 'completeRequest() cannot be called twice');
|
||||||
|
request.end = Date.now();
|
||||||
|
|
||||||
|
// sending all completed requests in order how they were queued
|
||||||
|
while (context.requests.length > 0 && context.requests[0].end) {
|
||||||
|
var otherRequest = context.requests.shift();
|
||||||
|
setTimeout(otherRequest.callback, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var context = FontLoader.loadingContext;
|
||||||
|
var requestId = 'pdfjs-font-loading-' + (context.nextRequestId++);
|
||||||
|
var request = {
|
||||||
|
id: requestId,
|
||||||
|
complete: LoadLoader_completeRequest,
|
||||||
|
callback: callback,
|
||||||
|
started: Date.now()
|
||||||
|
};
|
||||||
|
context.requests.push(request);
|
||||||
|
return request;
|
||||||
|
},
|
||||||
|
|
||||||
// Set things up so that at least one pdfjsFontLoad event is
|
// Set things up so that at least one pdfjsFontLoad event is
|
||||||
// dispatched when all the @font-face |rules| for |names| have been
|
// dispatched when all the @font-face |rules| for |fonts| have been
|
||||||
// loaded in a subdocument. It's expected that the load of |rules|
|
// loaded in a subdocument. It's expected that the load of |rules|
|
||||||
// has already started in this (outer) document, so that they should
|
// has already started in this (outer) document, so that they should
|
||||||
// be ordered before the load in the subdocument.
|
// be ordered before the load in the subdocument.
|
||||||
prepareFontLoadEvent: function fontLoaderPrepareFontLoadEvent(rules, names,
|
prepareFontLoadEvent: function fontLoaderPrepareFontLoadEvent(rules,
|
||||||
fonts) {
|
fonts,
|
||||||
|
request) {
|
||||||
/** Hack begin */
|
/** Hack begin */
|
||||||
// There's no event when a font has finished downloading so the
|
// There's no event when a font has finished downloading so the
|
||||||
// following code is a dirty hack to 'guess' when a font is
|
// following code is a dirty hack to 'guess' when a font is
|
||||||
@ -493,6 +501,20 @@ var FontLoader = {
|
|||||||
// The postMessage() hackery was added to work around chrome bug
|
// The postMessage() hackery was added to work around chrome bug
|
||||||
// 82402.
|
// 82402.
|
||||||
|
|
||||||
|
var requestId = request.id;
|
||||||
|
// Validate the requestId parameter -- the value used to construct HTML.
|
||||||
|
if (!/^[\w\-]+$/.test(requestId)) {
|
||||||
|
error('Invalid request id: ' + requestId);
|
||||||
|
|
||||||
|
// Normally the error-function throws. But if a malicious code
|
||||||
|
// intercepts the function call then the return is needed.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var names = [];
|
||||||
|
for (var i = 0, ii = fonts.length; i < ii; i++)
|
||||||
|
names.push(fonts[i].loadedName);
|
||||||
|
|
||||||
// Validate the names parameter -- the values can used to construct HTML.
|
// Validate the names parameter -- the values can used to construct HTML.
|
||||||
if (!/^\w+$/.test(names.join(''))) {
|
if (!/^\w+$/.test(names.join(''))) {
|
||||||
error('Invalid font name(s): ' + names.join());
|
error('Invalid font name(s): ' + names.join());
|
||||||
@ -514,22 +536,21 @@ var FontLoader = {
|
|||||||
div.innerHTML = html;
|
div.innerHTML = html;
|
||||||
document.body.appendChild(div);
|
document.body.appendChild(div);
|
||||||
|
|
||||||
if (!this.listeningForFontLoad) {
|
window.addEventListener(
|
||||||
window.addEventListener(
|
'message',
|
||||||
'message',
|
function fontLoaderMessage(e) {
|
||||||
function fontLoaderMessage(e) {
|
if (e.data !== requestId)
|
||||||
var fontNames = JSON.parse(e.data);
|
return;
|
||||||
for (var i = 0, ii = fonts.length; i < ii; ++i) {
|
for (var i = 0, ii = fonts.length; i < ii; ++i) {
|
||||||
var font = fonts[i];
|
var font = fonts[i];
|
||||||
font.loading = false;
|
font.loading = false;
|
||||||
}
|
}
|
||||||
var evt = document.createEvent('Events');
|
request.complete();
|
||||||
evt.initEvent('pdfjsFontLoad', true, false);
|
// cleanup
|
||||||
document.documentElement.dispatchEvent(evt);
|
document.body.removeChild(frame);
|
||||||
},
|
window.removeEventListener('message', fontLoaderMessage, false);
|
||||||
false);
|
},
|
||||||
this.listeningForFontLoad = true;
|
false);
|
||||||
}
|
|
||||||
|
|
||||||
// XXX we should have a time-out here too, and maybe fire
|
// XXX we should have a time-out here too, and maybe fire
|
||||||
// pdfjsFontLoadFailed?
|
// pdfjsFontLoadFailed?
|
||||||
@ -540,13 +561,8 @@ var FontLoader = {
|
|||||||
}
|
}
|
||||||
src += '</style>';
|
src += '</style>';
|
||||||
src += '<script type="application/javascript">';
|
src += '<script type="application/javascript">';
|
||||||
var fontNamesArray = '';
|
|
||||||
for (var i = 0, ii = names.length; i < ii; ++i) {
|
|
||||||
fontNamesArray += '"' + names[i] + '", ';
|
|
||||||
}
|
|
||||||
src += ' var fontNames=[' + fontNamesArray + '];\n';
|
|
||||||
src += ' window.onload = function fontLoaderOnload() {\n';
|
src += ' window.onload = function fontLoaderOnload() {\n';
|
||||||
src += ' parent.postMessage(JSON.stringify(fontNames), "*");\n';
|
src += ' parent.postMessage("' + requestId + '", "*");\n';
|
||||||
src += ' }';
|
src += ' }';
|
||||||
// Hack so the end script tag isn't counted if this is inline JS.
|
// Hack so the end script tag isn't counted if this is inline JS.
|
||||||
src += '</scr' + 'ipt></head><body>';
|
src += '</scr' + 'ipt></head><body>';
|
||||||
|
@ -29,29 +29,17 @@ select {
|
|||||||
|
|
||||||
#viewerContainer:-webkit-full-screen {
|
#viewerContainer:-webkit-full-screen {
|
||||||
top: 0px;
|
top: 0px;
|
||||||
padding-top: 6px;
|
border-top: 5px solid transparent;
|
||||||
padding-bottom: 24px;
|
|
||||||
background-color: #404040;
|
background-color: #404040;
|
||||||
background-image: url(images/texture.png);
|
background-image: url(images/texture.png);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
:-webkit-full-screen #viewer {
|
|
||||||
margin: 0pt;
|
|
||||||
padding: 0pt;
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
:-webkit-full-screen .page {
|
|
||||||
margin: 0px auto;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#viewerContainer:-moz-full-screen {
|
#viewerContainer:-moz-full-screen {
|
||||||
|
top: 0px;
|
||||||
|
border-top: 5px solid transparent;
|
||||||
background-color: #404040;
|
background-color: #404040;
|
||||||
background-image: url(images/texture.png);
|
background-image: url(images/texture.png);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -59,6 +47,10 @@ select {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:-webkit-full-screen .page:last-child {
|
||||||
|
margin-bottom: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
:-moz-full-screen .page:last-child {
|
:-moz-full-screen .page:last-child {
|
||||||
margin-bottom: 40px;
|
margin-bottom: 40px;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,17 @@ function getFileName(url) {
|
|||||||
return url.substring(url.lastIndexOf('/', end) + 1, end);
|
return url.substring(url.lastIndexOf('/', end) + 1, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function scrollIntoView(element, spot) {
|
||||||
|
var parent = element.offsetParent, offsetY = element.offsetTop;
|
||||||
|
while (parent.clientHeight == parent.scrollHeight) {
|
||||||
|
offsetY += parent.offsetTop;
|
||||||
|
parent = parent.offsetParent;
|
||||||
|
}
|
||||||
|
if (spot)
|
||||||
|
offsetY += spot.top;
|
||||||
|
parent.scrollTop = offsetY;
|
||||||
|
}
|
||||||
|
|
||||||
var Cache = function cacheCache(size) {
|
var Cache = function cacheCache(size) {
|
||||||
var data = [];
|
var data = [];
|
||||||
this.push = function cachePush(view) {
|
this.push = function cachePush(view) {
|
||||||
@ -1315,7 +1326,7 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
|||||||
|
|
||||||
this.scrollIntoView = function pageViewScrollIntoView(dest) {
|
this.scrollIntoView = function pageViewScrollIntoView(dest) {
|
||||||
if (!dest) {
|
if (!dest) {
|
||||||
div.scrollIntoView(true);
|
scrollIntoView(div);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1374,16 +1385,7 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
|||||||
var width = Math.abs(boundingRect[0][0] - boundingRect[1][0]);
|
var width = Math.abs(boundingRect[0][0] - boundingRect[1][0]);
|
||||||
var height = Math.abs(boundingRect[0][1] - boundingRect[1][1]);
|
var height = Math.abs(boundingRect[0][1] - boundingRect[1][1]);
|
||||||
|
|
||||||
// using temporary div to scroll it into view
|
scrollIntoView(div, {left: x, top: y, width: width, height: height});
|
||||||
var tempDiv = document.createElement('div');
|
|
||||||
tempDiv.style.position = 'absolute';
|
|
||||||
tempDiv.style.left = Math.floor(x) + 'px';
|
|
||||||
tempDiv.style.top = Math.floor(y) + 'px';
|
|
||||||
tempDiv.style.width = Math.ceil(width) + 'px';
|
|
||||||
tempDiv.style.height = Math.ceil(height) + 'px';
|
|
||||||
div.appendChild(tempDiv);
|
|
||||||
tempDiv.scrollIntoView(true);
|
|
||||||
div.removeChild(tempDiv);
|
|
||||||
}, 0);
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2084,7 +2086,7 @@ window.addEventListener('pagechange', function pagechange(evt) {
|
|||||||
var last = numVisibleThumbs > 1 ?
|
var last = numVisibleThumbs > 1 ?
|
||||||
visibleThumbs.last.id : first;
|
visibleThumbs.last.id : first;
|
||||||
if (page <= first || page >= last)
|
if (page <= first || page >= last)
|
||||||
thumbnail.scrollIntoView();
|
scrollIntoView(thumbnail);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user