From 6776efe491a111fbd7666812e591e3d6d9fd9190 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 14 Mar 2022 13:55:05 +0100 Subject: [PATCH 1/2] [gulpfile.js] Remove the `cleanup` parameter in `preprocessCSS` helper function Every single call-site has always passed in `true` for this parameter, ever since the function was first added back in PR 8023. Hence the parameter appears to be completely unnecessary, which is why it's removed and the function is updated to *unconditionally* strip out any license headers (in the middle of the file). --- gulpfile.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 149386447..48fe10288 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -801,16 +801,15 @@ gulp.task("cmaps", function (done) { done(); }); -function preprocessCSS(source, mode, defines, cleanup) { +function preprocessCSS(source, mode, defines) { const outName = getTempFile("~preprocess", ".css"); builder.preprocessCSS(mode, source, outName); let out = fs.readFileSync(outName).toString(); fs.unlinkSync(outName); - if (cleanup) { - // Strip out all license headers in the middle. - const reg = /\n\/\* Copyright(.|\n)*?Mozilla Foundation(.|\n)*?\*\//g; - out = out.replace(reg, ""); - } + + // Strip out all license headers in the middle. + const reg = /\n\/\* Copyright(.|\n)*?Mozilla Foundation(.|\n)*?\*\//g; + out = out.replace(reg, ""); const i = source.lastIndexOf("/"); return createStringSource(source.substr(i + 1), out); @@ -849,7 +848,7 @@ function buildGeneric(defines, dir) { createStandardFontBundle().pipe(gulp.dest(dir + "web/standard_fonts")), preprocessHTML("web/viewer.html", defines).pipe(gulp.dest(dir + "web")), - preprocessCSS("web/viewer.css", "generic", defines, true) + preprocessCSS("web/viewer.css", "generic", defines) .pipe(postcss([calc(), autoprefixer(AUTOPREFIXER_CONFIG)])) .pipe(gulp.dest(dir + "web")), @@ -925,7 +924,7 @@ function buildComponents(defines, dir) { return merge([ createComponentsBundle(defines).pipe(gulp.dest(dir)), gulp.src(COMPONENTS_IMAGES).pipe(gulp.dest(dir + "images")), - preprocessCSS("web/pdf_viewer.css", "components", defines, true) + preprocessCSS("web/pdf_viewer.css", "components", defines) .pipe(postcss([calc(), autoprefixer(AUTOPREFIXER_CONFIG)])) .pipe(gulp.dest(dir)), ]); @@ -1015,7 +1014,7 @@ function buildMinified(defines, dir) { createStandardFontBundle().pipe(gulp.dest(dir + "web/standard_fonts")), preprocessHTML("web/viewer.html", defines).pipe(gulp.dest(dir + "web")), - preprocessCSS("web/viewer.css", "minified", defines, true) + preprocessCSS("web/viewer.css", "minified", defines) .pipe(postcss([calc(), autoprefixer(AUTOPREFIXER_CONFIG)])) .pipe(gulp.dest(dir + "web")), @@ -1252,7 +1251,7 @@ gulp.task( preprocessHTML("web/viewer.html", defines).pipe( gulp.dest(MOZCENTRAL_CONTENT_DIR + "web") ), - preprocessCSS("web/viewer.css", "mozcentral", defines, true) + preprocessCSS("web/viewer.css", "mozcentral", defines) .pipe( postcss([ autoprefixer({ @@ -1344,7 +1343,7 @@ gulp.task( preprocessHTML("web/viewer.html", defines).pipe( gulp.dest(CHROME_BUILD_CONTENT_DIR + "web") ), - preprocessCSS("web/viewer.css", "chrome", defines, true) + preprocessCSS("web/viewer.css", "chrome", defines) .pipe( postcss([autoprefixer({ overrideBrowserslist: ["Chrome >= 73"] })]) ) From ee2896dd1ebc5f19563f98b74faa2f0acc57f1c2 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 14 Mar 2022 14:36:38 +0100 Subject: [PATCH 2/2] Remove the custom `grab`/`grabbing` cursor image files According to the MDN compatibility data, see https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#browser_compatibility, all browsers that we now support should have these cursors available natively. --- gulpfile.js | 11 ++--------- web/images/grab.cur | Bin 326 -> 0 bytes web/images/grabbing.cur | Bin 326 -> 0 bytes web/viewer.css | 2 -- 4 files changed, 2 insertions(+), 11 deletions(-) delete mode 100644 web/images/grab.cur delete mode 100644 web/images/grabbing.cur diff --git a/gulpfile.js b/gulpfile.js index 48fe10288..c4d54996e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -63,7 +63,7 @@ const DIST_DIR = BUILD_DIR + "dist/"; const TYPES_DIR = BUILD_DIR + "types/"; const TMP_DIR = BUILD_DIR + "tmp/"; const TYPESTEST_DIR = BUILD_DIR + "typestest/"; -const COMMON_WEB_FILES = ["web/images/*.{png,svg,gif,cur}", "web/debugger.js"]; +const COMMON_WEB_FILES = ["web/images/*.{png,svg,gif}", "web/debugger.js"]; const MOZCENTRAL_DIFF_FILE = "mozcentral.diff"; const REPO = "git@github.com:mozilla/pdf.js.git"; @@ -1215,13 +1215,6 @@ gulp.task( const version = versionJSON.version, commit = versionJSON.commit; - // Ignore the fallback cursor images, since they're unnecessary in - // Firefox. - const MOZCENTRAL_COMMON_WEB_FILES = [ - ...COMMON_WEB_FILES, - "!web/images/*.cur", - ]; - return merge([ createMainBundle(defines).pipe( gulp.dest(MOZCENTRAL_CONTENT_DIR + "build") @@ -1239,7 +1232,7 @@ gulp.task( gulp.dest(MOZCENTRAL_CONTENT_DIR + "web") ), gulp - .src(MOZCENTRAL_COMMON_WEB_FILES, { base: "web/" }) + .src(COMMON_WEB_FILES, { base: "web/" }) .pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "web")), createCMapBundle().pipe( gulp.dest(MOZCENTRAL_CONTENT_DIR + "web/cmaps") diff --git a/web/images/grab.cur b/web/images/grab.cur deleted file mode 100644 index db7ad5aed3ef958aa13903afa769386382a87ad3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmajZAr8Vo5QX7?si;7#!yvj6Nx}i(CG{p)>hLyxD99 z76ej)=-vic0UL9~!GgO~9_MsOnufoUx`QHG)5E@a!o?nT8@#*2`fMlI9X~2&%Qwtd fAElzRww7{H`T9z)QIL|gUwP@h-(DMO`2YPI1=f8x diff --git a/web/images/grabbing.cur b/web/images/grabbing.cur deleted file mode 100644 index e0dfd04e4d3fcbaa6588c8cbb9e9065609bcb862..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmZQzU}9ioP*7lC;0HnjMg|5k1_lNVAO;FCH~=vt5Q0Dhn8YOh|NoCEh)sn30RsaF z^8>N`2L=Xv5dHz=L$Uk|1_tQ_266z<4TQl5{{R0$_yG_fVE_NW0fd=>Y#@FBr9t9P K<`XsxO$7j30D*Y` diff --git a/web/viewer.css b/web/viewer.css index 84d1cd1e2..2f658eaaf 100644 --- a/web/viewer.css +++ b/web/viewer.css @@ -1699,7 +1699,6 @@ html[dir="rtl"] .treeItemToggler::before { } .grab-to-pan-grab { - cursor: url("images/grab.cur"), move !important; cursor: grab !important; } .grab-to-pan-grab @@ -1708,7 +1707,6 @@ html[dir="rtl"] .treeItemToggler::before { } .grab-to-pan-grab:active, .grab-to-pan-grabbing { - cursor: url("images/grabbing.cur"), move !important; cursor: grabbing !important; position: fixed; background: rgba(0, 0, 0, 0);