summaryrefslogtreecommitdiff
path: root/third-party/pdfjs/epiphany-pdfjs-changes.patch
blob: dd5b52518ba68eab32750466a4bba3c2de9ef695 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
diff --git a/third-party/pdfjs/epiphany-pdfjs-changes.patch b/third-party/pdfjs/epiphany-pdfjs-changes.patch
index 69f488516..e69de29bb 100644
--- a/third-party/pdfjs/epiphany-pdfjs-changes.patch
+++ b/third-party/pdfjs/epiphany-pdfjs-changes.patch
@@ -1,143 +0,0 @@
-diff -urN web2/viewer.css web/viewer.css
---- web2/viewer.css	2020-09-03 23:18:08.000000000 +0200
-+++ web/viewer.css	2021-04-05 11:25:24.181448360 +0200
-@@ -1,4 +1,5 @@
- /* 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 @@
- }
- 
- .dropdownToolbarButton > select {
-+  -webkit-appearance: none;
-   width: 162px;
-   height: 28px;
-   font-size: 12px;
-@@ -3132,6 +3134,7 @@
- }
- 
- .toolbarField.pageNumber {
-+  -webkit-appearance: none;
-   -moz-appearance: textfield; /* hides the spinner in moz */
-   min-width: 16px;
-   text-align: right;
-diff -urN web2/viewer.html web/viewer.html
---- web2/viewer.html	2020-09-03 23:18:08.000000000 +0200
-+++ web/viewer.html	2021-04-05 11:25:24.181448360 +0200
-@@ -1,6 +1,7 @@
- <!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 @@
- 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">
- 
- 
-@@ -124,7 +125,7 @@
-               <span data-l10n-id="download_label">Download</span>
-             </button>
- 
--            <a href="#" id="secondaryViewBookmark" class="secondaryToolbarButton bookmark visibleSmallView" title="Current view (copy or open in new window)" tabindex="55" data-l10n-id="bookmark">
-+            <a href="#" id="secondaryViewBookmark" class="secondaryToolbarButton bookmark hidden" title="Current view (copy or open in new window)" tabindex="55" data-l10n-id="bookmark">
-               <span data-l10n-id="bookmark_label">Current View</span>
-             </a>
- 
-@@ -226,7 +227,7 @@
-                 <button id="download" class="toolbarButton download hiddenMediumView" title="Download" tabindex="34" data-l10n-id="download">
-                   <span data-l10n-id="download_label">Download</span>
-                 </button>
--                <a href="#" id="viewBookmark" class="toolbarButton bookmark hiddenSmallView" title="Current view (copy or open in new window)" tabindex="35" data-l10n-id="bookmark">
-+                <a href="#" id="viewBookmark" class="toolbarButton bookmark hidden" title="Current view (copy or open in new window)" tabindex="35" data-l10n-id="bookmark">
-                   <span data-l10n-id="bookmark_label">Current View</span>
-                 </a>
- 
-diff -urN web2/viewer.js web/viewer.js
---- web2/viewer.js	2020-09-03 23:18:20.000000000 +0200
-+++ web/viewer.js	2021-04-05 11:25:24.184448405 +0200
-@@ -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 @@
-   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 @@
-   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 @@
-     }
-   }, 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 @@
-       }
-     }
- 
-+    // FIXME: This currently breaks Epiphany due to rewriting history with baseUrl
-+    return;
-     if (shouldReplace) {
-       window.history.replaceState(newState, "", newUrl);
-     } else {
-@@ -13897,4 +13905,4 @@
- 
- /***/ })
- /******/ ]);
--//# sourceMappingURL=viewer.js.map
-\ Kein Zeilenumbruch am Dateiende.
-+//# sourceMappingURL=viewer.js.map
diff --git a/third-party/pdfjs/web/viewer.css b/third-party/pdfjs/web/viewer.css
index e35bdda4b..5261568a8 100644
--- a/third-party/pdfjs/web/viewer.css
+++ b/third-party/pdfjs/web/viewer.css
@@ -1,4 +1,5 @@
 /* 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.
@@ -1613,6 +1614,7 @@ html[dir="rtl"] .dropdownToolbarButton::after {
 }
 
 .dropdownToolbarButton > select {
+  -webkit-appearance: none;
   width: 162px;
   height: 28px;
   font-size: 12px;
@@ -1986,6 +1988,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;
diff --git a/third-party/pdfjs/web/viewer.html b/third-party/pdfjs/web/viewer.html
index 503b810ba..db9b7427a 100644
--- a/third-party/pdfjs/web/viewer.html
+++ b/third-party/pdfjs/web/viewer.html
@@ -1,6 +1,7 @@
 <!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,13 +22,13 @@ 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">
     <title>PDF.js viewer</title>
 
-
+    <base href="ephy-resource:///org/gnome/epiphany/pdfjs/web/">
     <link rel="stylesheet" href="viewer.css">
 
 
@@ -135,7 +136,7 @@ See https://github.com/adobe-type-tools/cmap-resources
               <span data-l10n-id="download_label">Download</span>
             </button>
 
-            <a href="#" id="secondaryViewBookmark" class="secondaryToolbarButton bookmark visibleSmallView" title="Current view (copy or open in new window)" tabindex="55" data-l10n-id="bookmark">
+            <a href="#" id="secondaryViewBookmark" class="secondaryToolbarButton bookmark hidden" title="Current view (copy or open in new window)" tabindex="55" data-l10n-id="bookmark">
               <span data-l10n-id="bookmark_label">Current View</span>
             </a>
 
@@ -237,7 +238,7 @@ See https://github.com/adobe-type-tools/cmap-resources
                 <button id="download" class="toolbarButton download hiddenMediumView" title="Download" tabindex="34" data-l10n-id="download">
                   <span data-l10n-id="download_label">Download</span>
                 </button>
-                <a href="#" id="viewBookmark" class="toolbarButton bookmark hiddenSmallView" title="Current view (copy or open in new window)" tabindex="35" data-l10n-id="bookmark">
+                <a href="#" id="viewBookmark" class="toolbarButton bookmark hidden" title="Current view (copy or open in new window)" tabindex="35" data-l10n-id="bookmark">
                   <span data-l10n-id="bookmark_label">Current View</span>
                 </a>
 
diff --git a/third-party/pdfjs/web/viewer.js b/third-party/pdfjs/web/viewer.js
index 1d013ebfe..d0064cf18 100644
--- a/third-party/pdfjs/web/viewer.js
+++ b/third-party/pdfjs/web/viewer.js
@@ -3,6 +3,7 @@
  * Javascript code in this page
  *
  * Copyright 2021 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.
@@ -2244,8 +2245,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";
@@ -2253,12 +2253,8 @@ function webViewerInitialized() {
   fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
   document.body.appendChild(fileInput);
 
-  if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
-    appConfig.toolbar.openFile.hidden = true;
-    appConfig.secondaryToolbar.openFileButton.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;
@@ -2320,8 +2316,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").then(msg => {
       PDFViewerApplication._documentError(msg, reason);
@@ -6381,6 +6387,8 @@ class PDFHistory {
       }
     }
 
+    // FIXME: This currently breaks Epiphany due to rewriting history with baseUrl
+    return;
     if (shouldReplace) {
       window.history.replaceState(newState, "", newUrl);
     } else {
@@ -15403,4 +15411,4 @@ if (document.readyState === "interactive" || document.readyState === "complete")
 
 /******/ })()
 ;
-//# sourceMappingURL=viewer.js.map
\ No newline at end of file
+//# sourceMappingURL=viewer.js.map