Skip to content

Truly independent web browser

Meta: Update pdfjs to version 6.4.299#0

Timothy Flynnd09fe24a46ae
diff --git a/Meta/CMake/flatpak/org.ladybird.Ladybird.json b/Meta/CMake/flatpak/org.ladybird.Ladybird.json
index 2ed4322e798..035a313e249 100644
--- a/Meta/CMake/flatpak/org.ladybird.Ladybird.json
+++ b/Meta/CMake/flatpak/org.ladybird.Ladybird.json
@@ -705,13 +705,13 @@
{
"type": "git",
"url": "https://github.com/mozilla/pdf.js.git",
- "tag": "v5.6.205",
+ "tag": "v6.4.299",
"dest": "pdfjs-src"
},
{
"type": "archive",
- "url": "https://github.com/mozilla/pdf.js/releases/download/v5.6.205/pdfjs-5.6.205-dist.zip",
- "sha256": "0555ef47464e456125dcd0b9742cfa2aaed6d282e804e4dd1f1b99316b46ac00",
+ "url": "https://github.com/mozilla/pdf.js/releases/download/v6.4.299/pdfjs-6.4.299-dist.zip",
+ "sha256": "f2245eb7ef3f674c872fe568a177bfec15874f5c034613e55d8e307f93ebd86d",
"dest": ".",
"strip-components": 0
},
diff --git a/Meta/CMake/vcpkg/overlay-ports/pdfjs/0001-ladybird-embed.patch b/Meta/CMake/vcpkg/overlay-ports/pdfjs/0001-ladybird-embed.patch
index 806aede4860..cf56a979581 100644
--- a/Meta/CMake/vcpkg/overlay-ports/pdfjs/0001-ladybird-embed.patch
+++ b/Meta/CMake/vcpkg/overlay-ports/pdfjs/0001-ladybird-embed.patch
@@ -1,6 +1,6 @@
--- a/web/viewer.html
+++ b/web/viewer.html
-@@ -22,18 +22,19 @@
+@@ -22,6 +22,7 @@
-->
<html dir="ltr" mozdisallowselectionprint>
<head>
@@ -8,31 +8,37 @@
<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>
-
+@@ -29,16 +30,16 @@
+
+ <meta
+ http-equiv="Content-Security-Policy"
+- content="default-src 'none'; script-src 'self' 'wasm-unsafe-eval'; worker-src 'self' blob:; style-src 'self'; img-src 'self' blob: data:; media-src blob:; font-src 'self' data:; connect-src * blob: data:; base-uri 'none'; form-action 'none';"
++ content="default-src 'none'; script-src 'self' resource: 'wasm-unsafe-eval'; worker-src 'self' resource: blob:; style-src 'self' resource:; img-src 'self' resource: blob: data:; media-src blob:; font-src 'self' resource: data:; connect-src * resource: blob: data:; base-uri resource:; form-action 'none';"
+ />
+
<!-- This snippet is used in production (included from viewer.html) -->
-<link rel="resource" type="application/l10n" href="locale/locale.json" />
<script src="../build/pdf.mjs" type="module"></script>
-
+
<link rel="stylesheet" href="viewer.css" />
-
+
<script src="viewer.mjs" type="module"></script>
+ <script src="pdfjs-ladybird-transport.mjs" type="module"></script>
</head>
-
+
<body tabindex="0">
--- a/web/viewer.mjs
+++ b/web/viewer.mjs
-@@ -18255,7 +18255,7 @@
+@@ -19279,7 +19279,7 @@
let file;
const queryString = document.location.search.substring(1);
const params = parseQueryString(queryString);
- file = params.get("file") ?? AppOptions.get("defaultUrl");
+ file = params.get("file") ?? "";
- try {
- file = new URL(file).href;
- } catch {
-@@ -18886,7 +18886,6 @@
+ file = URL.parse(file)?.href ?? file.replaceAll("#", "%23");
+ validateFileURL(file);
+ const fileInput = this._openFileInput = document.createElement("input");
+@@ -19935,7 +19935,6 @@
this.metadata = metadata;
this._contentDispositionFilename ??= contentDispositionFilename;
this._contentLength ??= contentLength;
diff --git a/Meta/CMake/vcpkg/overlay-ports/pdfjs/portfile.cmake b/Meta/CMake/vcpkg/overlay-ports/pdfjs/portfile.cmake
index 3847dfa6fa2..f73b1d9733e 100644
--- a/Meta/CMake/vcpkg/overlay-ports/pdfjs/portfile.cmake
+++ b/Meta/CMake/vcpkg/overlay-ports/pdfjs/portfile.cmake
@@ -4,7 +4,7 @@ set(VCPKG_BUILD_TYPE release)
vcpkg_download_distfile(ARCHIVE
URLS "https://github.com/mozilla/pdf.js/releases/download/v${VERSION}/pdfjs-${VERSION}-dist.zip"
FILENAME "pdfjs-${VERSION}-dist.zip"
- SHA512 66fecdb8a80d013b592c361e85abd7eeea5bc35f0131b771cc25a1878d7737704458dc715670aace3c7d3437f85388dff04796fe117eef01be81fd0d192f73a2
+ SHA512 ed520ebaa60242f68c27c47eece48887fb862bea977f873212f1bf7556ef562adcb33e4a1daac9fbb63e5fe882dc16ba9226e29d467fda25ee0101ba2ea930de
)
vcpkg_extract_source_archive_ex(
@@ -13,7 +13,7 @@ vcpkg_extract_source_archive_ex(
NO_REMOVE_ONE_LEVEL
)
-# Patch viewer.mjs so the internal Ladybird PDF viewer origin is accepted.
+# Integrate the viewer with Ladybird's resource URLs and PDF transport.
z_vcpkg_apply_patches(
SOURCE_PATH "${SOURCE_PATH}"
PATCHES 0001-ladybird-embed.patch
diff --git a/Meta/CMake/vcpkg/overlay-ports/pdfjs/vcpkg.json b/Meta/CMake/vcpkg/overlay-ports/pdfjs/vcpkg.json
index c39d60c1743..2079a6ac361 100644
--- a/Meta/CMake/vcpkg/overlay-ports/pdfjs/vcpkg.json
+++ b/Meta/CMake/vcpkg/overlay-ports/pdfjs/vcpkg.json
@@ -1,5 +1,5 @@
{
"name": "pdfjs",
- "version": "5.6.205",
+ "version": "6.4.299",
"description": "PDF.js prebuilt web viewer assets"
}
diff --git a/Tests/LibWeb/Layout/expected/pdf-viewer.txt b/Tests/LibWeb/Layout/expected/pdf-viewer.txt
index 11948d02864..11c88c159e5 100644
--- a/Tests/LibWeb/Layout/expected/pdf-viewer.txt
+++ b/Tests/LibWeb/Layout/expected/pdf-viewer.txt
@@ -186,6 +186,8 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
TextNode <#text> (not painted)
TextNode <#text> (not painted)
TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
BlockContainer <div#editorHighlight.toolbarButtonWithContainer> at [585,2] positioned flex-item [0+0+0 28 0+0+0] [0+0+0 28 0+0+0] [BFC] children: not-inline
BlockContainer <(anonymous)> at [585,2] [0+0+0 28 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
@@ -335,7 +337,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
BlockContainer <div.page> at [233.5,42] positioned [224.5+9+0 333 0+9+224.5] [1+9+0 133 0+9+-8] children: not-inline
BlockContainer <div.canvasWrapper> at [233.5,42] [0+0+0 333 0+0+0] [0+0+0 133 0+0+0] [BFC] children: not-inline
CanvasBox <canvas> at [233.5,42] positioned [0+0+0 333 0+0+0] [0+0+0 133 0+0+0] children: not-inline
- BlockContainer <div.textLayer> at [233.5,42] positioned [0+0+0 333 0+0+0] [0+0+0 133 0+0+0] [BFC] children: not-inline
+ BlockContainer <div.textLayer.selectionRendering> at [233.5,42] positioned [0+0+0 333 0+0+0] [0+0+0 133 0+0+0] [BFC] children: not-inline
BlockContainer <span> at [316.75,64.9375] positioned [0+0+0 121.046875 0+0+0] [0+0+0 23.328125 0+0+0] [BFC] children: inline
frag 0 from TextNode start: 0, length: 9, rect: [316.75,64.609375 121.046875x24] baseline: 18.984375
"Hello PDF"
@@ -373,7 +375,7 @@ SC for Viewport<#document> [0,0 800x600] (z-index: auto)
SC for BlockContainer<HTML> [0,0 800x600] (z-index: auto)
SC for BlockContainer<DIV>#viewerContainer [0,32 800x568] (z-index: 0)
SC for CanvasBox<CANVAS> [233.5,42 333x133] (z-index: auto)
- SC for BlockContainer<DIV>.textLayer [233.5,42 333x133] (z-index: 0)
+ SC for BlockContainer<DIV>.textLayer.selectionRendering [233.5,42 333x133] (z-index: 0)
SC for BlockContainer<DIV>.endOfContent [233.5,175 333x0] (z-index: 0), has_transform
SC for BlockContainer<SPAN> [316.75,64.9375 121.046875x23.328125] (z-index: 1), has_transform
SC for BlockContainer<DIV>.toolbar [0,0 800x32] (z-index: 2)
diff --git a/vcpkg.json b/vcpkg.json
index d2df21639c2..60b4c14e603 100644
--- a/vcpkg.json
+++ b/vcpkg.json
@@ -368,7 +368,7 @@
},
{
"name": "pdfjs",
- "version": "5.6.205#0"
+ "version": "6.4.299#0"
},
{
"name": "pthread",