Commit 5a08dab0 authored by Michael Catanzaro's avatar Michael Catanzaro Committed by Alexander Mikhaylenko
Browse files

Reapply Epiphany customizations to PDF.js

parent 65cd3706
......@@ -4,7 +4,7 @@ This directory contains an official pdf.js release version, distributed at: http
## Update process
Grab a new official release (*-dist.zip) distributed at github and extract everything except viewer.[html/js/css] and map files into this directory.
Then recreate the resource xml file with `python pdfjs-generate-resource.py`
Then recreate the resource xml file with `python ./pdfjs_generate_resource.py`
The additional files within this directory are modified for Epiphany and shouldn't be changed automatically.
......@@ -62,6 +62,9 @@ Here are two small changes for webkit specific layout:
For easier updating to a newer version there is a patch file `epiphany-pdfjs-changes.patch` containing the necessary changes to the viewer files.
## Note
Do not add map files to this bundle (webinspector will complain about it), but they are not needed here and would increase our storage size otherwise.
# Documentation created by Jan-Michael Brummer <jan.brummer@tabos.org>
diff --git a/third-party/pdfjs/web/viewer.css b/third-party/pdfjs/web/viewer.css
index 595660ad3..8711953bf 100644
index 605cad57e..21af9931d 100644
--- a/third-party/pdfjs/web/viewer.css
+++ b/third-party/pdfjs/web/viewer.css
@@ -1,4 +1,5 @@
......@@ -8,15 +8,15 @@ index 595660ad3..8711953bf 100644
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1192,6 +1193,7 @@ html[dir='rtl'] .dropdownToolbarButton::after {
@@ -2361,6 +2362,7 @@ html[dir="rtl"] .dropdownToolbarButton::after {
}
.dropdownToolbarButton > select {
+ -webkit-appearance: none;
width: 162px;
height: 23px;
height: 28px;
font-size: 12px;
@@ -1524,6 +1526,7 @@ html[dir='rtl'] .verticalToolbarSeparator {
@@ -3132,6 +3134,7 @@ html[dir="rtl"] .toolbarField[type="checkbox"] {
}
.toolbarField.pageNumber {
......@@ -25,7 +25,7 @@ index 595660ad3..8711953bf 100644
min-width: 16px;
text-align: right;
diff --git a/third-party/pdfjs/web/viewer.html b/third-party/pdfjs/web/viewer.html
index 1730b09b7..db8517b1a 100644
index 123a47d2c..61f1a0e21 100644
--- a/third-party/pdfjs/web/viewer.html
+++ b/third-party/pdfjs/web/viewer.html
@@ -1,6 +1,7 @@
......@@ -36,7 +36,7 @@ index 1730b09b7..db8517b1a 100644
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -21,7 +22,7 @@ Adobe CMap resources are covered by their own copyright but the same license:
@@ -21,14 +22,14 @@ Adobe CMap resources are covered by their own copyright but the same license:
See https://github.com/adobe-type-tools/cmap-resources
-->
<html dir="ltr" mozdisallowselectionprint>
......@@ -45,16 +45,16 @@ index 1730b09b7..db8517b1a 100644
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="google" content="notranslate">
@@ -29,6 +30,7 @@ See https://github.com/adobe-type-tools/cmap-resources
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>PDF.js viewer</title>
-
+ <base href="ephy-resource:///org/gnome/epiphany/pdfjs/web/">
<link rel="stylesheet" href="viewer.css">
diff --git a/third-party/pdfjs/web/viewer.js b/third-party/pdfjs/web/viewer.js
index 3cf8beed8..e7a792006 100644
index d89902345..1d54e92c7 100644
--- a/third-party/pdfjs/web/viewer.js
+++ b/third-party/pdfjs/web/viewer.js
@@ -3,6 +3,7 @@
......@@ -65,7 +65,7 @@ index 3cf8beed8..e7a792006 100644
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1836,8 +1837,7 @@ function webViewerInitialized() {
@@ -1973,8 +1974,7 @@ function webViewerInitialized() {
let file;
const queryString = document.location.search.substring(1);
const params = (0, _ui_utils.parseQueryString)(queryString);
......@@ -75,7 +75,7 @@ index 3cf8beed8..e7a792006 100644
const fileInput = document.createElement("input");
fileInput.id = appConfig.openFileInputName;
fileInput.className = "fileInput";
@@ -1845,12 +1845,10 @@ function webViewerInitialized() {
@@ -1982,12 +1982,8 @@ function webViewerInitialized() {
fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
document.body.appendChild(fileInput);
......@@ -87,12 +87,10 @@ index 3cf8beed8..e7a792006 100644
- }
+ appConfig.toolbar.openFile.setAttribute('hidden', 'true');
+ appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
+
+ appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
fileInput.addEventListener("change", function (evt) {
const files = evt.target.files;
@@ -1912,8 +1910,18 @@ function webViewerInitialized() {
@@ -2049,8 +2045,18 @@ function webViewerInitialized() {
}
}, true);
......@@ -112,7 +110,7 @@ index 3cf8beed8..e7a792006 100644
} catch (reason) {
PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(msg => {
PDFViewerApplication.error(msg, reason);
@@ -6520,6 +6528,8 @@ class PDFHistory {
@@ -6877,6 +6883,8 @@ class PDFHistory {
}
}
......@@ -121,7 +119,7 @@ index 3cf8beed8..e7a792006 100644
if (shouldReplace) {
window.history.replaceState(newState, "", newUrl);
} else {
@@ -13276,4 +13286,4 @@ _app.PDFPrintServiceFactory.instance = {
@@ -13897,4 +13905,4 @@ _app.PDFPrintServiceFactory.instance = {
/***/ })
/******/ ]);
......
This diff is collapsed.
/* Copyright 2014 Mozilla Foundation
* Modifications made for Epiphany by Jan-Michael Brummer <jan.brummer@tabos.org>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -2361,6 +2362,7 @@ html[dir="rtl"] .dropdownToolbarButton::after {
}
.dropdownToolbarButton > select {
-webkit-appearance: none;
width: 162px;
height: 28px;
font-size: 12px;
......@@ -3132,6 +3134,7 @@ html[dir="rtl"] .toolbarField[type="checkbox"] {
}
.toolbarField.pageNumber {
-webkit-appearance: none;
-moz-appearance: textfield; /* hides the spinner in moz */
min-width: 16px;
text-align: right;
......
<!DOCTYPE html>
<!--
Copyright 2012 Mozilla Foundation
Modifications made for Epiphany by Jan-Michael Brummer <jan.brummer@tabos.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......@@ -21,14 +22,14 @@ Adobe CMap resources are covered by their own copyright but the same license:
See https://github.com/adobe-type-tools/cmap-resources
-->
<html dir="ltr" mozdisallowselectionprint>
<head>
<head pdf_data="%s" pdf_name="%s">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="google" content="notranslate">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>PDF.js viewer</title>
<base href="ephy-resource:///org/gnome/epiphany/pdfjs/web/">
<link rel="stylesheet" href="viewer.css">
......
......@@ -3,6 +3,7 @@
* Javascript code in this page
*
* Copyright 2020 Mozilla Foundation
* Modifications made for Epiphany by Jan-Michael Brummer <jan.brummer@tabos.org>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -1973,8 +1974,7 @@ function webViewerInitialized() {
let file;
const queryString = document.location.search.substring(1);
const params = (0, _ui_utils.parseQueryString)(queryString);
file = "file" in params ? params.file : _app_options.AppOptions.get("defaultUrl");
validateFileURL(file);
file = '';
const fileInput = document.createElement("input");
fileInput.id = appConfig.openFileInputName;
fileInput.className = "fileInput";
......@@ -1982,12 +1982,8 @@ function webViewerInitialized() {
fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
document.body.appendChild(fileInput);
if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
appConfig.toolbar.openFile.setAttribute("hidden", "true");
appConfig.secondaryToolbar.openFileButton.setAttribute("hidden", "true");
} else {
fileInput.value = null;
}
appConfig.toolbar.openFile.setAttribute('hidden', 'true');
appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
fileInput.addEventListener("change", function (evt) {
const files = evt.target.files;
......@@ -2049,8 +2045,18 @@ function webViewerInitialized() {
}
}, true);
var file_name = document.head.getAttribute('pdf_name')
var raw = atob(document.head.getAttribute('pdf_data'));
var raw_length = raw.length;
var array = new Uint8Array(new ArrayBuffer(raw_length));
for(var i = 0; i < raw_length; i++) {
array[i] = raw.charCodeAt(i);
}
try {
webViewerOpenFileViaURL(file);
PDFViewerApplication.open(array);
PDFViewerApplication.setTitleUsingUrl(file_name);
} catch (reason) {
PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(msg => {
PDFViewerApplication.error(msg, reason);
......@@ -6877,6 +6883,8 @@ class PDFHistory {
}
}
// FIXME: This currently breaks Epiphany due to rewriting history with baseUrl
return;
if (shouldReplace) {
window.history.replaceState(newState, "", newUrl);
} else {
......@@ -13897,4 +13905,4 @@ _app.PDFPrintServiceFactory.instance = {
/***/ })
/******/ ]);
//# sourceMappingURL=viewer.js.map
\ No newline at end of file
//# sourceMappingURL=viewer.js.map
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment