Bug 801280 - Update pdf.js to version 0.6.39. r=dtownsend

This commit is contained in:
Ryan VanderMeulen 2012-10-17 15:33:58 -04:00
parent 61a7b4fefd
commit 4dc8993a0c
15 changed files with 1422 additions and 381 deletions

View File

@ -1,4 +1,4 @@
This is the pdf.js project output, https://github.com/mozilla/pdf.js
Current extension version is: 0.5.184
Current extension version is: 0.6.39

View File

@ -31,8 +31,6 @@ const PREF_PREFIX = 'pdfjs';
const PDF_VIEWER_WEB_PAGE = 'resource://pdf.js/web/viewer.html';
const MAX_DATABASE_LENGTH = 4096;
const FIREFOX_ID = '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}';
const SEAMONKEY_ID = '{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}';
const METRO_ID = '{99bceaaa-e3c6-48c1-b981-ef9b46b67d60}';
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import('resource://gre/modules/Services.jsm');
@ -41,20 +39,28 @@ Cu.import('resource://gre/modules/NetUtil.jsm');
let appInfo = Cc['@mozilla.org/xre/app-info;1']
.getService(Ci.nsIXULAppInfo);
let privateBrowsing, inPrivateBrowsing;
let Svc = {};
XPCOMUtils.defineLazyServiceGetter(Svc, 'mime',
'@mozilla.org/mime;1',
'nsIMIMEService');
let isInPrivateBrowsing;
if (appInfo.ID === FIREFOX_ID) {
privateBrowsing = Cc['@mozilla.org/privatebrowsing;1']
.getService(Ci.nsIPrivateBrowsingService);
inPrivateBrowsing = privateBrowsing.privateBrowsingEnabled;
} else if (appInfo.ID === SEAMONKEY_ID ||
appInfo.ID === METRO_ID) {
privateBrowsing = null;
inPrivateBrowsing = false;
let privateBrowsing = Cc['@mozilla.org/privatebrowsing;1']
.getService(Ci.nsIPrivateBrowsingService);
isInPrivateBrowsing = function getInPrivateBrowsing() {
return privateBrowsing.privateBrowsingEnabled;
};
} else {
isInPrivateBrowsing = function() { return false; };
}
function getChromeWindow(domWindow) {
var containingBrowser = domWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell)
.chromeEventHandler;
return containingBrowser.ownerDocument.defaultView;
}
function getBoolPref(pref, def) {
@ -273,7 +279,7 @@ ChromeActions.prototype = {
});
},
setDatabase: function(data) {
if (inPrivateBrowsing)
if (isInPrivateBrowsing())
return;
// Protect against something sending tons of data to setDatabase.
if (data.length > MAX_DATABASE_LENGTH)
@ -281,7 +287,7 @@ ChromeActions.prototype = {
setStringPref(PREF_PREFIX + '.database', data);
},
getDatabase: function() {
if (inPrivateBrowsing)
if (isInPrivateBrowsing())
return '{}';
return getStringPref(PREF_PREFIX + '.database', '{}');
},
@ -336,8 +342,11 @@ ChromeActions.prototype = {
pdfBugEnabled: function() {
return getBoolPref(PREF_PREFIX + '.pdfBugEnabled', false);
},
searchEnabled: function() {
return getBoolPref(PREF_PREFIX + '.searchEnabled', false);
supportsIntegratedFind: function() {
// Integrated find is only supported when we're not in a frame and when the
// new find events code exists.
return this.domWindow.frameElement === null &&
'updateControlState' in getChromeWindow(this.domWindow).gFindBar;
},
fallback: function(url, sendResponse) {
var self = this;
@ -391,6 +400,20 @@ ChromeActions.prototype = {
if (!sentResponse)
sendResponse(false);
});
},
updateFindControlState: function(data) {
if (!this.supportsIntegratedFind())
return;
// Verify what we're sending to the findbar.
var result = data.result;
var findPrevious = data.findPrevious;
var findPreviousType = typeof findPrevious;
if ((typeof result !== 'number' || result < 0 || result > 3) ||
(findPreviousType !== 'undefined' && findPreviousType !== 'boolean')) {
return;
}
getChromeWindow(this.domWindow).gFindBar
.updateControlState(result, findPrevious);
}
};
@ -431,6 +454,57 @@ RequestListener.prototype.receive = function(event) {
}
};
// Forwards events from the eventElement to the contentWindow only if the
// content window matches the currently selected browser window.
function FindEventManager(eventElement, contentWindow, chromeWindow) {
this.types = ['find',
'findagain',
'findhighlightallchange',
'findcasesensitivitychange'];
this.chromeWindow = chromeWindow;
this.contentWindow = contentWindow;
this.eventElement = eventElement;
}
FindEventManager.prototype.bind = function() {
var unload = function(e) {
this.unbind();
this.contentWindow.removeEventListener(e.type, unload);
}.bind(this);
this.contentWindow.addEventListener('unload', unload);
for (var i = 0; i < this.types.length; i++) {
var type = this.types[i];
this.eventElement.addEventListener(type, this, true);
}
};
FindEventManager.prototype.handleEvent = function(e) {
var chromeWindow = this.chromeWindow;
var contentWindow = this.contentWindow;
// Only forward the events if they are for our dom window.
if (chromeWindow.gBrowser.selectedBrowser.contentWindow === contentWindow) {
var detail = e.detail;
detail.__exposedProps__ = {
query: 'r',
caseSensitive: 'r',
highlightAll: 'r',
findPrevious: 'r'
};
var forward = contentWindow.document.createEvent('CustomEvent');
forward.initCustomEvent(e.type, true, true, detail);
contentWindow.dispatchEvent(forward);
e.preventDefault();
}
};
FindEventManager.prototype.unbind = function() {
for (var i = 0; i < this.types.length; i++) {
var type = this.types[i];
this.eventElement.removeEventListener(type, this, true);
}
};
function PdfStreamConverter() {
}
@ -543,6 +617,13 @@ PdfStreamConverter.prototype = {
domWindow.addEventListener(PDFJS_EVENT_ID, function(event) {
requestListener.receive(event);
}, false, true);
if (actions.supportsIntegratedFind()) {
var chromeWindow = getChromeWindow(domWindow);
var findEventManager = new FindEventManager(chromeWindow.gFindBar,
domWindow,
chromeWindow);
findEventManager.bind();
}
}
listener.onStopRequest.apply(listener, arguments);
}
@ -557,7 +638,8 @@ PdfStreamConverter.prototype = {
var securityManager = Cc['@mozilla.org/scriptsecuritymanager;1']
.getService(Ci.nsIScriptSecurityManager);
var uri = ioService.newURI(PDF_VIEWER_WEB_PAGE, null, null);
// FF16 and below had getCodebasePrincipal (bug 774585)
// FF16 and below had getCodebasePrincipal, it was replaced by
// getNoAppCodebasePrincipal (bug 758258).
var resourcePrincipal = 'getNoAppCodebasePrincipal' in securityManager ?
securityManager.getNoAppCodebasePrincipal(uri) :
securityManager.getCodebasePrincipal(uri);

View File

@ -23,10 +23,12 @@ const Cu = Components.utils;
const PREF_PREFIX = 'pdfjs';
const PREF_DISABLED = PREF_PREFIX + '.disabled';
const PREF_FIRST_RUN = PREF_PREFIX + '.firstRun';
const PREF_MIGRATION_VERSION = PREF_PREFIX + '.migrationVersion';
const PREF_PREVIOUS_ACTION = PREF_PREFIX + '.previousHandler.preferredAction';
const PREF_PREVIOUS_ASK = PREF_PREFIX + '.previousHandler.alwaysAskBeforeHandling';
const PREF_DISABLED_PLUGIN_TYPES = 'plugin.disable_full_page_plugin_for_types';
const TOPIC_PDFJS_HANDLER_CHANGED = 'pdfjs:handlerChanged';
const PDF_CONTENT_TYPE = 'application/pdf';
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import('resource://gre/modules/Services.jsm');
@ -45,6 +47,14 @@ function getBoolPref(aPref, aDefaultValue) {
}
}
function getIntPref(aPref, aDefaultValue) {
try {
return Services.prefs.getIntPref(aPref);
} catch (ex) {
return aDefaultValue;
}
}
// Register/unregister a constructor as a component.
let Factory = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory]),
@ -84,24 +94,8 @@ let PdfJs = {
_registered: false,
init: function init() {
// On first run make pdf.js the default handler.
if (!getBoolPref(PREF_DISABLED, true) && getBoolPref(PREF_FIRST_RUN, false)) {
Services.prefs.setBoolPref(PREF_FIRST_RUN, false);
let handlerInfo = Svc.mime.getFromTypeAndExtension('application/pdf', 'pdf');
// Store the previous settings of preferredAction and
// alwaysAskBeforeHandling in case we need to revert them in a hotfix that
// would turn pdf.js off.
Services.prefs.setIntPref(PREF_PREVIOUS_ACTION, handlerInfo.preferredAction);
Services.prefs.setBoolPref(PREF_PREVIOUS_ASK, handlerInfo.alwaysAskBeforeHandling);
let handlerService = Cc['@mozilla.org/uriloader/handler-service;1'].
getService(Ci.nsIHandlerService);
// Change and save mime handler settings.
handlerInfo.alwaysAskBeforeHandling = false;
handlerInfo.preferredAction = Ci.nsIHandlerInfo.handleInternally;
handlerService.store(handlerInfo);
if (!getBoolPref(PREF_DISABLED, true)) {
this._migrate();
}
if (this.enabled)
@ -115,6 +109,55 @@ let PdfJs = {
Services.obs.addObserver(this, TOPIC_PDFJS_HANDLER_CHANGED, false);
},
_migrate: function migrate() {
const VERSION = 1;
var currentVersion = getIntPref(PREF_MIGRATION_VERSION, 0);
if (currentVersion >= VERSION) {
return;
}
// Make pdf.js the default pdf viewer on the first migration.
if (currentVersion < 2) {
this._becomeHandler();
}
Services.prefs.setIntPref(PREF_MIGRATION_VERSION, VERSION);
},
_becomeHandler: function _becomeHandler() {
let handlerInfo = Svc.mime.getFromTypeAndExtension(PDF_CONTENT_TYPE, 'pdf');
let prefs = Services.prefs;
if (handlerInfo.preferredAction !== Ci.nsIHandlerInfo.handleInternally &&
handlerInfo.preferredAction !== false) {
// Store the previous settings of preferredAction and
// alwaysAskBeforeHandling in case we need to revert them in a hotfix that
// would turn pdf.js off.
prefs.setIntPref(PREF_PREVIOUS_ACTION, handlerInfo.preferredAction);
prefs.setBoolPref(PREF_PREVIOUS_ASK, handlerInfo.alwaysAskBeforeHandling);
}
let handlerService = Cc['@mozilla.org/uriloader/handler-service;1'].
getService(Ci.nsIHandlerService);
// Change and save mime handler settings.
handlerInfo.alwaysAskBeforeHandling = false;
handlerInfo.preferredAction = Ci.nsIHandlerInfo.handleInternally;
handlerService.store(handlerInfo);
// Also disable any plugins for pdfs.
var stringTypes = '';
var types = [];
if (prefs.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES)) {
stringTypes = prefs.getCharPref(PREF_DISABLED_PLUGIN_TYPES);
}
if (stringTypes !== '') {
types = stringTypes.split(',');
}
if (types.indexOf(PDF_CONTENT_TYPE) === -1) {
types.push(PDF_CONTENT_TYPE);
}
prefs.setCharPref(PREF_DISABLED_PLUGIN_TYPES, types.join(','));
},
// nsIObserver
observe: function observe(aSubject, aTopic, aData) {
if (this.enabled)

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

View File

@ -44,38 +44,52 @@ select {
#viewerContainer:-webkit-full-screen {
top: 0px;
border-top: 5px solid transparent;
border-top: 2px solid transparent;
background-color: #404040;
background-image: url(images/texture.png);
width: 100%;
height: 100%;
overflow: hidden;
cursor: none;
}
#viewerContainer:-moz-full-screen {
top: 0px;
border-top: 5px solid transparent;
border-top: 2px solid transparent;
background-color: #404040;
background-image: url(images/texture.png);
width: 100%;
height: 100%;
overflow: hidden;
cursor: none;
}
:-webkit-full-screen .page:last-child {
margin-bottom: 40px;
}
:-moz-full-screen .page:last-child {
margin-bottom: 40px;
}
#viewerContainer:full-screen {
#viewerContainer:fullscreen {
top: 0px;
border-top: 2px solid transparent;
background-color: #404040;
background-image: url(images/texture.png);
width: 100%;
height: 100%;
overflow: hidden;
cursor: none;
}
:-webkit-full-screen .page {
margin-bottom: 100%;
}
:-moz-full-screen .page {
margin-bottom: 100%;
}
:fullscreen .page {
margin-bottom: 100%;
}
#viewerContainer.presentationControls {
cursor: default;
}
/* outer/inner center provides horizontal center */
@ -204,7 +218,6 @@ html[dir='rtl'] #sidebarContent {
#viewerContainer {
overflow: auto;
box-shadow: inset 1px 0 0 hsla(0,0%,100%,.05);
padding-top: 30px;
position: absolute;
top: 32px;
right: 0;
@ -245,7 +258,7 @@ html[dir='rtl'] #sidebarContent {
0 1px 1px hsla(0,0%,0%,.1);
}
#toolbarViewer {
#toolbarViewer, .findbar {
position: relative;
height: 32px;
background-image: url(images/texture.png),
@ -265,6 +278,94 @@ html[dir='rtl'] #sidebarContent {
0 1px 0 hsla(0,0%,0%,.15),
0 1px 1px hsla(0,0%,0%,.1);
}
.findbar {
top: 32px;
position: absolute;
z-index: 10000;
height: 32px;
min-width: 16px;
padding: 0px 6px 0px 6px;
margin: 4px 2px 4px 2px;
color: hsl(0,0%,85%);
font-size: 12px;
line-height: 14px;
text-align: left;
cursor: default;
}
html[dir='ltr'] .findbar {
left: 68px;
}
html[dir='rtl'] .findbar {
right: 68px;
}
.findbar label {
-webkit-user-select:none;
-moz-user-select:none;
}
#findInput[data-status="pending"] {
background-image: url(images/loading-small.png);
background-repeat: no-repeat;
background-position: right;
}
.doorHanger {
border: 1px solid hsla(0,0%,0%,.5);
border-radius: 2px;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.doorHanger:after, .doorHanger:before {
bottom: 100%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.doorHanger:after {
border-bottom-color: hsla(0,0%,32%,.99);
border-width: 8px;
}
.doorHanger:before {
border-bottom-color: hsla(0,0%,0%,.5);
border-width: 9px;
}
html[dir='ltr'] .doorHanger:after {
left: 16px;
margin-left: -8px;
}
html[dir='ltr'] .doorHanger:before {
left: 16px;
margin-left: -9px;
}
html[dir='rtl'] .doorHanger:after {
right: 16px;
margin-right: -8px;
}
html[dir='rtl'] .doorHanger:before {
right: 16px;
margin-right: -9px;
}
#findMsg {
font-style: italic;
color: #A6B7D0;
}
.notFound {
background-color: rgb(255, 137, 153);
}
html[dir='ltr'] #toolbarViewerLeft {
margin-left: -1px;
}
@ -287,12 +388,14 @@ html[dir='rtl'] #toolbarViewerLeft {
}
html[dir='ltr'] #toolbarViewerLeft > *,
html[dir='ltr'] #toolbarViewerMiddle > *,
html[dir='ltr'] #toolbarViewerRight > * {
html[dir='ltr'] #toolbarViewerRight > *,
html[dir='ltr'] .findbar > * {
float: left;
}
html[dir='rtl'] #toolbarViewerLeft > *,
html[dir='rtl'] #toolbarViewerMiddle > *,
html[dir='rtl'] #toolbarViewerRight > * {
html[dir='rtl'] #toolbarViewerRight > *,
html[dir='rtl'] .findbar > * {
float: right;
}
@ -630,6 +733,26 @@ html[dir='rtl'] .toolbarButton:first-child {
content: url(images/toolbarButton-sidebarToggle.png);
}
html[dir='ltr'] .toolbarButton.findPrevious::before {
display: inline-block;
content: url(images/findbarButton-previous.png);
}
html[dir='rtl'] .toolbarButton.findPrevious::before {
display: inline-block;
content: url(images/findbarButton-previous-rtl.png);
}
html[dir='ltr'] .toolbarButton.findNext::before {
display: inline-block;
content: url(images/findbarButton-next.png);
}
html[dir='rtl'] .toolbarButton.findNext::before {
display: inline-block;
content: url(images/findbarButton-next-rtl.png);
}
html[dir='ltr'] .toolbarButton.pageUp::before {
display: inline-block;
content: url(images/toolbarButton-pageUp.png);
@ -702,7 +825,7 @@ html[dir='rtl'] .toolbarButton.pageDown::before {
content: url(images/toolbarButton-viewOutline.png);
}
#viewSearch.toolbarButton::before {
#viewFind.toolbarButton::before {
display: inline-block;
content: url(images/toolbarButton-search.png);
}
@ -729,6 +852,11 @@ html[dir='rtl'] .toolbarButton.pageDown::before {
-moz-transition-timing-function: ease;
}
.toolbarField[type=checkbox] {
display: inline-block;
margin: 8px 0px;
}
.toolbarField.pageNumber {
min-width: 16px;
text-align: right;
@ -844,8 +972,7 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
margin-left: 20px;
}
.outlineItem > a,
#searchResults > a {
.outlineItem > a {
text-decoration: none;
display: inline-block;
min-width: 95%;
@ -861,8 +988,7 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
white-space: nowrap;
}
.outlineItem > a:hover,
#searchResults > a:hover {
.outlineItem > a:hover {
background-color: hsla(0,0%,100%,.02);
background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
background-clip: padding-box;
@ -889,7 +1015,7 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
font-style: italic;
}
#searchScrollView {
#findScrollView {
position: absolute;
top: 10px;
bottom: 10px;
@ -897,36 +1023,6 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
width: 280px;
}
#searchToolbar {
padding-left: 0px;
right: 0px;
padding-top: 0px;
padding-bottom: 5px;
}
#searchToolbar > input {
margin-left: 4px;
width: 124px;
}
#searchToolbar button {
width: auto;
margin: 0;
padding: 0 6px;
height: 22px;
}
#searchResults {
overflow: auto;
position: absolute;
top: 30px;
bottom: 0px;
left: 0px;
right: 0;
padding: 4px 4px 0;
font-size: smaller;
}
#sidebarControls {
position:absolute;
width: 180px;
@ -1069,6 +1165,30 @@ canvas {
white-space:pre;
}
.textLayer .highlight {
margin: -1px;
padding: 1px;
background-color: rgba(180, 0, 170, 0.2);
border-radius: 4px;
}
.textLayer .highlight.begin {
border-radius: 4px 0px 0px 4px;
}
.textLayer .highlight.end {
border-radius: 0px 4px 4px 0px;
}
.textLayer .highlight.middle {
border-radius: 0px;
}
.textLayer .highlight.selected {
background-color: rgba(0, 100, 0, 0.2);
}
/* TODO: file FF bug to support ::-moz-selection:window-inactive
so we can override the opaque grey background when the window is inactive;
see https://bugzilla.mozilla.org/show_bug.cgi?id=706209 */
@ -1291,7 +1411,7 @@ canvas {
}
@media all and (max-width: 600px) {
#toolbarViewerRight {
#toolbarViewerRight, #findbar, #viewFind {
display: none;
}
}

View File

@ -51,7 +51,7 @@ var PDFJS = {};
'use strict';
PDFJS.build =
'e98eba1';
'c8cf445';
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
@ -357,8 +357,17 @@ var Page = (function PageClosure() {
case 'GoTo':
item.dest = a.get('D');
break;
case 'GoToR':
var url = a.get('F');
// TODO: pdf reference says that GoToR
// can also have 'NewWindow' attribute
if (!isValidUrl(url))
url = '';
item.url = url;
item.dest = a.get('D');
break;
default:
TODO('other link types');
TODO('unrecognized link type: ' + a.get('S').name);
}
} else if (annotation.has('Dest')) {
// simple destination link
@ -638,8 +647,6 @@ var PDFDocument = (function PDFDocumentClosure() {
var log = (function() {
if ('console' in globalScope && 'log' in globalScope['console']) {
return globalScope['console']['log'].bind(globalScope['console']);
} else if ('print' in globalScope) {
return globalScope['print'].bind(globalScope);
} else {
return function nop() {
};
@ -902,7 +909,7 @@ var PageViewport = PDFJS.PageViewport = (function PageViewportClosure() {
var centerX = (viewBox[2] + viewBox[0]) / 2;
var centerY = (viewBox[3] + viewBox[1]) / 2;
var rotateA, rotateB, rotateC, rotateD;
switch (rotate) {
switch (rotate % 360) {
case -180:
case 180:
rotateA = -1; rotateB = 0; rotateC = 0; rotateD = 1;
@ -1955,7 +1962,8 @@ var TextRenderingMode = {
FILL_ADD_TO_PATH: 4,
STROKE_ADD_TO_PATH: 5,
FILL_STROKE_ADD_TO_PATH: 6,
ADD_TO_PATH: 7
ADD_TO_PATH: 7,
ADD_TO_PATH_FLAG: 4
};
// Minimal font size that would be used during canvas fillText operations.
@ -2341,6 +2349,10 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.current = old.clone();
},
restore: function CanvasGraphics_restore() {
if ('textClipLayers' in this) {
this.completeTextClipping();
}
var prev = this.stateStack.pop();
if (prev) {
this.current = prev;
@ -2470,6 +2482,64 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.current.y = this.current.lineY = 0;
},
endText: function CanvasGraphics_endText() {
if ('textClipLayers' in this) {
this.swapImageForTextClipping();
}
},
getCurrentTextClipping: function CanvasGraphics_getCurrentTextClipping() {
var ctx = this.ctx;
var transform = ctx.mozCurrentTransform;
if ('textClipLayers' in this) {
// we need to reset only font and transform
var maskCtx = this.textClipLayers.maskCtx;
maskCtx.setTransform.apply(maskCtx, transform);
maskCtx.font = ctx.font;
return maskCtx;
}
var canvasWidth = ctx.canvas.width;
var canvasHeight = ctx.canvas.height;
// keeping track of the text clipping of the separate canvas
var maskCanvas = createScratchCanvas(canvasWidth, canvasHeight);
var maskCtx = maskCanvas.getContext('2d');
maskCtx.setTransform.apply(maskCtx, transform);
maskCtx.font = ctx.font;
var textClipLayers = {
maskCanvas: maskCanvas,
maskCtx: maskCtx
};
this.textClipLayers = textClipLayers;
return maskCtx;
},
swapImageForTextClipping:
function CanvasGraphics_swapImageForTextClipping() {
var ctx = this.ctx;
var canvasWidth = ctx.canvas.width;
var canvasHeight = ctx.canvas.height;
// saving current image content and clearing whole canvas
ctx.save();
ctx.setTransform(1, 0, 0, 1, 0, 0);
var data = ctx.getImageData(0, 0, canvasWidth, canvasHeight);
this.textClipLayers.imageData = data;
ctx.clearRect(0, 0, canvasWidth, canvasHeight);
ctx.restore();
},
completeTextClipping: function CanvasGraphics_completeTextClipping() {
var ctx = this.ctx;
// applying mask to the image (result is saved in maskCanvas)
var maskCtx = this.textClipLayers.maskCtx;
maskCtx.setTransform(1, 0, 0, 1, 0, 0);
maskCtx.globalCompositeOperation = 'source-in';
maskCtx.drawImage(ctx.canvas, 0, 0);
// restoring image data and applying the result of masked drawing
ctx.save();
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.putImageData(this.textClipLayers.imageData, 0, 0);
ctx.drawImage(this.textClipLayers.maskCanvas, 0, 0);
ctx.restore();
delete this.textClipLayers;
},
setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
this.current.charSpacing = spacing;
@ -2537,8 +2607,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.ctx.font = rule;
},
setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
if (mode >= TextRenderingMode.FILL_ADD_TO_PATH)
TODO('unsupported text rendering mode: ' + mode);
this.current.textRenderingMode = mode;
},
setTextRise: function CanvasGraphics_setTextRise(rise) {
@ -2573,7 +2641,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
ctx.transform.apply(ctx, fontMatrix);
ctx.scale(textHScale, 1);
},
getTextGeometry: function CanvasGraphics_getTextGeometry() {
createTextGeometry: function CanvasGraphics_createTextGeometry() {
var geometry = {};
var ctx = this.ctx;
var font = this.current.font;
@ -2587,6 +2655,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
geometry.vScale = tr[1] - bl[1];
}
geometry.spaceWidth = font.spaceWidth;
geometry.fontName = font.loadedName;
geometry.fontFamily = font.fallbackName;
geometry.fontSize = this.current.fontSize;
return geometry;
},
@ -2620,7 +2691,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
if (textSelection) {
this.save();
ctx.scale(1, -1);
geom = this.getTextGeometry();
geom = this.createTextGeometry();
this.restore();
}
for (var i = 0; i < glyphsLength; ++i) {
@ -2661,7 +2732,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
lineWidth /= scale;
if (textSelection)
geom = this.getTextGeometry();
geom = this.createTextGeometry();
if (fontSizeScale != 1.0) {
ctx.scale(fontSizeScale, fontSizeScale);
@ -2701,8 +2772,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
ctx.strokeText(character, scaledX, 0);
break;
case TextRenderingMode.INVISIBLE:
case TextRenderingMode.ADD_TO_PATH:
break;
}
if (textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG) {
var clipCtx = this.getCurrentTextClipping();
clipCtx.fillText(character, scaledX, 0);
}
}
x += charWidth;
@ -2719,7 +2795,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
if (textSelection) {
geom.canvasWidth = canvasWidth;
this.textLayer.appendText(font.fallbackName, fontSize, geom);
this.textLayer.appendText(geom);
}
return canvasWidth;
@ -2748,7 +2824,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
ctx.scale(textHScale, 1);
} else
this.applyTextTransforms();
geom = this.getTextGeometry();
geom = this.createTextGeometry();
ctx.restore();
}
@ -2772,7 +2848,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
if (textSelection) {
geom.canvasWidth = canvasWidth;
this.textLayer.appendText(font.fallbackName, fontSize, geom);
this.textLayer.appendText(geom);
}
},
nextLineShowText: function CanvasGraphics_nextLineShowText(text) {
@ -3113,8 +3189,22 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.restore();
},
putBinaryImageData: function CanvasGraphics_putBinaryImageData() {
//
putBinaryImageData: function CanvasGraphics_putBinaryImageData(ctx, imgData,
w, h) {
var tmpImgData = 'createImageData' in ctx ? ctx.createImageData(w, h) :
ctx.getImageData(0, 0, w, h);
var tmpImgDataPixels = tmpImgData.data;
var data = imgData.data;
if ('set' in tmpImgDataPixels)
tmpImgDataPixels.set(data);
else {
// Copy over the imageData pixel by pixel.
for (var i = 0, ii = tmpImgDataPixels.length; i < ii; i++)
tmpImgDataPixels[i] = data[i];
}
ctx.putImageData(tmpImgData, 0, 0);
},
// Marked content
@ -3181,47 +3271,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
return CanvasGraphics;
})();
function checkPutBinaryImageDataCompatibility() {
// Feature detection if the browser can use an Uint8Array directly as imgData.
var canvas = document.createElement('canvas');
canvas.width = 1;
canvas.height = 1;
var ctx = canvas.getContext('2d');
try {
ctx.putImageData({
width: 1,
height: 1,
data: new Uint8Array(4)
}, 0, 0);
CanvasGraphics.prototype.putBinaryImageData =
function CanvasGraphicsPutBinaryImageDataNative(ctx, imgData) {
ctx.putImageData(imgData, 0, 0);
};
} catch (e) {
CanvasGraphics.prototype.putBinaryImageData =
function CanvasGraphicsPutBinaryImageDataShim(ctx, imgData, w, h) {
var tmpImgData = 'createImageData' in ctx ? ctx.createImageData(w, h) :
ctx.getImageData(0, 0, w, h);
var tmpImgDataPixels = tmpImgData.data;
var data = imgData.data;
if ('set' in tmpImgDataPixels)
tmpImgDataPixels.set(data);
else {
// Copy over the imageData pixel by pixel.
for (var i = 0, ii = tmpImgDataPixels.length; i < ii; i++)
tmpImgDataPixels[i] = data[i];
}
ctx.putImageData(tmpImgData, 0, 0);
};
}
}
if (!isWorker) {
checkPutBinaryImageDataCompatibility();
}
var Name = (function NameClosure() {
@ -13270,10 +13319,16 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
assert(fontRes, 'fontRes not available');
font = xref.fetchIfRef(font) || fontRes.get(fontName);
assertWellFormed(isDict(font));
++this.fontIdCounter;
font = xref.fetchIfRef(font) || fontRes.get(fontName);
if (!isDict(font)) {
return {
translated: new ErrorFont('Font ' + fontName + ' is not available'),
loadedName: 'font_' + this.uniquePrefix + this.fontIdCounter
};
}
var loadedName = font.loadedName;
if (!loadedName) {
// keep track of each font we translated so the caller can
@ -13286,7 +13341,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
translated = this.translateFont(font, xref, resources,
dependency);
} catch (e) {
translated = { error: e };
translated = new ErrorFont(e instanceof Error ? e.message : e);
}
font.translated = translated;
@ -13334,10 +13389,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var loadedName = font.loadedName;
if (!font.sent) {
var data = font.translated;
if (data instanceof Font)
data = data.exportData();
var data = font.translated.exportData();
handler.send('obj', [
loadedName,
@ -13635,6 +13687,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
getTextContent: function partialEvaluatorGetIRQueue(
stream, resources, state) {
var bidiTexts;
var kSpaceFactor = 0.35;
var kMultipleSpaceFactor = 1.5;
if (!state) {
bidiTexts = [];
@ -13676,8 +13730,13 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
if (typeof items[j] === 'string') {
chunk += fontCharsToUnicode(items[j], font);
} else if (items[j] < 0 && font.spaceWidth > 0) {
var numFakeSpaces = Math.round(-items[j] / font.spaceWidth);
if (numFakeSpaces > 0) {
var fakeSpaces = -items[j] / font.spaceWidth;
if (fakeSpaces > kMultipleSpaceFactor) {
fakeSpaces = Math.round(fakeSpaces);
while (fakeSpaces--) {
chunk += ' ';
}
} else if (fakeSpaces > kSpaceFactor) {
chunk += ' ';
}
}
@ -16509,7 +16568,8 @@ var Font = (function FontClosure() {
'\x00\x01' + // encodingID
string32(4 + numTables * 8); // start of the table record
var segCount = ranges.length + 1;
var trailingRangesCount = ranges[ranges.length - 1][1] < 0xFFFF ? 1 : 0;
var segCount = ranges.length + trailingRangesCount;
var segCount2 = segCount * 2;
var searchRange = getMaxPower2(segCount) * 2;
var searchEntry = Math.log(segCount) / Math.log(2);
@ -16524,7 +16584,7 @@ var Font = (function FontClosure() {
var bias = 0;
if (deltas) {
for (var i = 0; i < segCount - 1; i++) {
for (var i = 0, ii = ranges.length; i < ii; i++) {
var range = ranges[i];
var start = range[0];
var end = range[1];
@ -16541,7 +16601,7 @@ var Font = (function FontClosure() {
glyphsIds += string16(deltas[codes[j]]);
}
} else {
for (var i = 0; i < segCount - 1; i++) {
for (var i = 0, ii = ranges.length; i < ii; i++) {
var range = ranges[i];
var start = range[0];
var end = range[1];
@ -16554,10 +16614,12 @@ var Font = (function FontClosure() {
}
}
endCount += '\xFF\xFF';
startCount += '\xFF\xFF';
idDeltas += '\x00\x01';
idRangeOffsets += '\x00\x00';
if (trailingRangesCount > 0) {
endCount += '\xFF\xFF';
startCount += '\xFF\xFF';
idDeltas += '\x00\x01';
idRangeOffsets += '\x00\x00';
}
var format314 = '\x00\x00' + // language
string16(segCount2) +
@ -17238,6 +17300,9 @@ var Font = (function FontClosure() {
var requiredTables = ['OS/2', 'cmap', 'head', 'hhea',
'hmtx', 'maxp', 'name', 'post'];
var optionalTables = ['cvt ', 'fpgm', 'glyf', 'loca', 'prep',
'CFF ', 'VORG', 'vhea', 'vmtx'];
var header = readOpenTypeHeader(font);
var numTables = header.numTables;
@ -17263,6 +17328,9 @@ var Font = (function FontClosure() {
os2 = table;
requiredTables.splice(index, 1);
} else if (optionalTables.indexOf(table.tag) < 0) {
// skipping table if it's not a required or optional table
continue;
} else {
if (table.tag == 'vmtx')
vmtx = table;
@ -17568,6 +17636,12 @@ var Font = (function FontClosure() {
this.glyphNameMap = properties.glyphNameMap;
}
if (glyphs.length === 0) {
// defines at least one glyph
glyphs.push({ unicode: 0xF000, code: 0xF000, glyph: '.notdef' });
ids.push(0);
}
// Converting glyphs and ids into font's cmap table
cmap.data = createCMapTable(glyphs, ids);
var unicodeIsEnabled = [];
@ -18080,6 +18154,9 @@ var ErrorFont = (function ErrorFontClosure() {
ErrorFont.prototype = {
charsToGlyphs: function ErrorFont_charsToGlyphs() {
return [];
},
exportData: function ErrorFont_exportData() {
return {error: this.error};
}
};
@ -18303,6 +18380,21 @@ var Type1Parser = function type1Parser() {
assert(argc == 0, 'callothersubr with arguments is not supported');
charstring.push(new CallothersubrCmd(index));
continue;
} else if (escape == 7) { // sbw
var args = breakUpArgs(charstring, 4);
var arg0 = args[0];
var arg1 = args[1];
var arg2 = args[2];
lsb = arg0.value;
width = arg2.value;
// To convert to type2 we have to move the width value to the first
// part of the charstring and then use rmoveto with (dx, dy).
// The height argument will not be used for vmtx and vhea tables
// reconstruction -- ignoring it.
charstring = arg2.arg;
charstring = charstring.concat(arg0.arg, arg1.arg);
charstring.push('rmoveto');
continue;
} else if (escape == 17 || escape == 33) {
// pop or setcurrentpoint commands can be ignored
// since we are not doing callothersubr
@ -19110,10 +19202,9 @@ var CFFFont = (function CFFFontClosure() {
inverseEncoding[encoding[charcode]] = charcode | 0;
else
inverseEncoding = charsets;
for (var i = 0, ii = charsets.length; i < ii; i++) {
var i = charsets[0] == '.notdef' ? 1 : 0;
for (var ii = charsets.length; i < ii; i++) {
var glyph = charsets[i];
if (glyph == '.notdef')
continue;
var code = inverseEncoding[i];
if (!code || isSpecialUnicode(code)) {
@ -31245,6 +31336,7 @@ function MessageHandler(name, comObj) {
}];
} else {
ah['console_error'] = [function ahConsoleError(data) {
log.apply(null, data);
}];
}
ah['_warn'] = [function ah_Warn(data) {
@ -35960,35 +36052,45 @@ var JpegImage = (function jpegImage() {
<button id="viewOutline" class="toolbarButton group" title="Show Document Outline" tabindex="2" data-l10n-id="outline">
<span data-l10n-id="outline_label">Document Outline</span>
</button>
<button id="viewSearch" class="toolbarButton group hidden" title="Search Document" tabindex="3" data-l10n-id="search_panel">
<span data-l10n-id="search_panel_label">Search Document</span>
</button>
</div>
<div id="sidebarContent">
<div id="thumbnailView">
</div>
<div id="outlineView" class="hidden">
</div>
<div id="searchView" class="hidden">
<div id="searchToolbar">
<input id="searchTermsInput" class="toolbarField">
<button id="searchButton" class="textButton toolbarButton" data-l10n-id="search">Find</button>
</div>
<div id="searchResults"></div>
</div>
</div>
</div> <!-- sidebarContainer -->
<div id="mainContainer">
<div class="findbar hidden doorHanger" id="findbar">
<label for="findInput" class="toolbarLabel" data-l10n-id="find_label">Find:</label>
<input id="findInput" class="toolbarField" tabindex="20">
<div class="splitToolbarButton">
<button class="toolbarButton findPrevious" title="" id="findPrevious" tabindex="21" data-l10n-id="find_previous">
<span data-l10n-id="find_previous_label">Previous</span>
</button>
<div class="splitToolbarButtonSeparator"></div>
<button class="toolbarButton findNext" title="" id="findNext" tabindex="22" data-l10n-id="find_next">
<span data-l10n-id="find_next_label">Next</span>
</button>
</div>
<input type="checkbox" id="findHighlightAll" class="toolbarField">
<label for="findHighlightAll" class="toolbarLabel" tabindex="23" data-l10n-id="find_highlight">Highlight all</label>
<input type="checkbox" id="findMatchCase" class="toolbarField">
<label for="findMatchCase" class="toolbarLabel" tabindex="24" data-l10n-id="find_match_case_label">Match case</label>
<span id="findMsg" class="toolbarLabel"></span>
</div>
<div class="toolbar">
<div id="toolbarContainer">
<div id="toolbarViewer">
<div id="toolbarViewerLeft">
<button id="sidebarToggle" class="toolbarButton" title="Toggle Sidebar" tabindex="4" data-l10n-id="toggle_slider">
<button id="sidebarToggle" class="toolbarButton" title="Toggle Sidebar" tabindex="3" data-l10n-id="toggle_slider">
<span data-l10n-id="toggle_slider_label">Toggle Sidebar</span>
</button>
<div class="toolbarButtonSpacer"></div>
<button id="viewFind" class="toolbarButton group" title="Find in Document" tabindex="4" data-l10n-id="findbar">
<span data-l10n-id="findbar_label">Find</span>
</button>
<div class="splitToolbarButton">
<button class="toolbarButton pageUp" title="Previous Page" id="previous" tabindex="5" data-l10n-id="previous">
<span data-l10n-id="previous_label">Previous</span>
@ -36058,6 +36160,10 @@ var JpegImage = (function jpegImage() {
</div>
<menu type="context" id="viewerContextMenu">
<menuitem label="First Page" id="first_page"
data-l10n-id="first_page" ></menuitem>
<menuitem label="Last Page" id="last_page"
data-l10n-id="last_page" ></menuitem>
<menuitem label="Rotate Counter-Clockwise" id="page_rotate_ccw"
data-l10n-id="page_rotate_ccw" ></menuitem>
<menuitem label="Rotate Clockwise" id="page_rotate_cw"

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,12 @@ content/web/debugger.js
content/web/images/annotation-check.svg
content/web/images/annotation-comment.svg
content/web/images/annotation-text.svg
content/web/images/findbarButton-next-rtl.png
content/web/images/findbarButton-next.png
content/web/images/findbarButton-previous-rtl.png
content/web/images/findbarButton-previous.png
content/web/images/loading-icon.gif
content/web/images/loading-small.png
content/web/images/texture.png
content/web/images/toolbarButton-bookmark.png
content/web/images/toolbarButton-download.png

View File

@ -1,7 +1,3 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Chrome notification bar messages and buttons
unsupported_feature=This PDF document might not be displayed correctly.
open_with_different_viewer=Open With Different Viewer

View File

@ -1,7 +1,3 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Main toolbar buttons (tooltips and alt text for images)
previous.title=Previous Page
previous_label=Previous
@ -40,8 +36,8 @@ outline.title=Show Document Outline
outline_label=Document Outline
thumbs.title=Show Thumbnails
thumbs_label=Thumbnails
search_panel.title=Search Document
search_panel_label=Search
findbar.title=Find in Document
findbar_label=Find
# Document outline messages
no_outline=No Outline Available
@ -55,12 +51,22 @@ thumb_page_title=Page {{page}}
thumb_page_canvas=Thumbnail of Page {{page}}
# Context menu
first_page.label=Go to First Page
last_page.label=Go to Last Page
page_rotate_cw.label=Rotate Clockwise
page_rotate_ccw.label=Rotate Counter-Clockwise
page_rotate_ccw.label=Rotate Counterclockwise
# Search panel button title and messages
search=Find
search_terms_not_found=(Not found)
# Find panel button title and messages
find_label=Find:
find_previous.title=Find the previous occurrence of the phrase
find_previous_label=Previous
find_next.title=Find the next occurrence of the phrase
find_next_label=Next
find_highlight=Highlight all
find_match_case_label=Match case
find_wrapped_to_bottom=Reached end of page, continued from bottom
find_wrapped_to_top=Reached end of page, continued from top
find_not_found=Phrase not found
# Error panel labels
error_more_info=More Information