Merge pull request #11521 from Snuffleupagus/rm-supportsDocumentColors
Remove the `supportsDocumentColors` warning in MOZCENTRAL builds (bug 844349 follow-up)
This commit is contained in:
commit
918f0ff60b
@ -245,4 +245,3 @@ password_cancel=Cancel
|
|||||||
printing_not_supported=Warning: Printing is not fully supported by this browser.
|
printing_not_supported=Warning: Printing is not fully supported by this browser.
|
||||||
printing_not_ready=Warning: The PDF is not fully loaded for printing.
|
printing_not_ready=Warning: The PDF is not fully loaded for printing.
|
||||||
web_fonts_disabled=Web fonts are disabled: unable to use embedded PDF fonts.
|
web_fonts_disabled=Web fonts are disabled: unable to use embedded PDF fonts.
|
||||||
document_colors_not_allowed=PDF documents are not allowed to use their own colors: “Allow pages to choose their own colors” is deactivated in the browser.
|
|
||||||
|
87
web/app.js
87
web/app.js
@ -84,29 +84,48 @@ const ViewOnLoad = {
|
|||||||
INITIAL: 1,
|
INITIAL: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
const DefaultExternalServices = {
|
class DefaultExternalServices {
|
||||||
updateFindControlState(data) {},
|
constructor() {
|
||||||
updateFindMatchesCount(data) {},
|
throw new Error("Cannot initialize DefaultExternalServices.");
|
||||||
initPassiveLoading(callbacks) {},
|
}
|
||||||
fallback(data, callback) {},
|
|
||||||
reportTelemetry(data) {},
|
static updateFindControlState(data) {}
|
||||||
createDownloadManager(options) {
|
|
||||||
|
static updateFindMatchesCount(data) {}
|
||||||
|
|
||||||
|
static initPassiveLoading(callbacks) {}
|
||||||
|
|
||||||
|
static fallback(data, callback) {}
|
||||||
|
|
||||||
|
static reportTelemetry(data) {}
|
||||||
|
|
||||||
|
static createDownloadManager(options) {
|
||||||
throw new Error("Not implemented: createDownloadManager");
|
throw new Error("Not implemented: createDownloadManager");
|
||||||
},
|
}
|
||||||
createPreferences() {
|
|
||||||
|
static createPreferences() {
|
||||||
throw new Error("Not implemented: createPreferences");
|
throw new Error("Not implemented: createPreferences");
|
||||||
},
|
}
|
||||||
createL10n(options) {
|
|
||||||
|
static createL10n(options) {
|
||||||
throw new Error("Not implemented: createL10n");
|
throw new Error("Not implemented: createL10n");
|
||||||
},
|
}
|
||||||
supportsIntegratedFind: false,
|
|
||||||
supportsDocumentFonts: true,
|
static get supportsIntegratedFind() {
|
||||||
supportsDocumentColors: true,
|
return shadow(this, "supportsIntegratedFind", false);
|
||||||
supportedMouseWheelZoomModifierKeys: {
|
}
|
||||||
ctrlKey: true,
|
|
||||||
metaKey: true,
|
static get supportsDocumentFonts() {
|
||||||
},
|
return shadow(this, "supportsDocumentFonts", true);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
static get supportedMouseWheelZoomModifierKeys() {
|
||||||
|
return shadow(this, "supportedMouseWheelZoomModifierKeys", {
|
||||||
|
ctrlKey: true,
|
||||||
|
metaKey: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const PDFViewerApplication = {
|
const PDFViewerApplication = {
|
||||||
initialBookmark: document.location.hash.substring(1),
|
initialBookmark: document.location.hash.substring(1),
|
||||||
@ -547,10 +566,6 @@ const PDFViewerApplication = {
|
|||||||
return this.externalServices.supportsDocumentFonts;
|
return this.externalServices.supportsDocumentFonts;
|
||||||
},
|
},
|
||||||
|
|
||||||
get supportsDocumentColors() {
|
|
||||||
return this.externalServices.supportsDocumentColors;
|
|
||||||
},
|
|
||||||
|
|
||||||
get loadingBar() {
|
get loadingBar() {
|
||||||
const bar = new ProgressBar("#loadingBar");
|
const bar = new ProgressBar("#loadingBar");
|
||||||
return shadow(this, "loadingBar", bar);
|
return shadow(this, "loadingBar", bar);
|
||||||
@ -1586,7 +1601,6 @@ const PDFViewerApplication = {
|
|||||||
eventBus.on("beforeprint", _boundEvents.beforePrint);
|
eventBus.on("beforeprint", _boundEvents.beforePrint);
|
||||||
eventBus.on("afterprint", _boundEvents.afterPrint);
|
eventBus.on("afterprint", _boundEvents.afterPrint);
|
||||||
eventBus.on("pagerendered", webViewerPageRendered);
|
eventBus.on("pagerendered", webViewerPageRendered);
|
||||||
eventBus.on("textlayerrendered", webViewerTextLayerRendered);
|
|
||||||
eventBus.on("updateviewarea", webViewerUpdateViewarea);
|
eventBus.on("updateviewarea", webViewerUpdateViewarea);
|
||||||
eventBus.on("pagechanging", webViewerPageChanging);
|
eventBus.on("pagechanging", webViewerPageChanging);
|
||||||
eventBus.on("scalechanging", webViewerScaleChanging);
|
eventBus.on("scalechanging", webViewerScaleChanging);
|
||||||
@ -1661,7 +1675,6 @@ const PDFViewerApplication = {
|
|||||||
eventBus.off("beforeprint", _boundEvents.beforePrint);
|
eventBus.off("beforeprint", _boundEvents.beforePrint);
|
||||||
eventBus.off("afterprint", _boundEvents.afterPrint);
|
eventBus.off("afterprint", _boundEvents.afterPrint);
|
||||||
eventBus.off("pagerendered", webViewerPageRendered);
|
eventBus.off("pagerendered", webViewerPageRendered);
|
||||||
eventBus.off("textlayerrendered", webViewerTextLayerRendered);
|
|
||||||
eventBus.off("updateviewarea", webViewerUpdateViewarea);
|
eventBus.off("updateviewarea", webViewerUpdateViewarea);
|
||||||
eventBus.off("pagechanging", webViewerPageChanging);
|
eventBus.off("pagechanging", webViewerPageChanging);
|
||||||
eventBus.off("scalechanging", webViewerScaleChanging);
|
eventBus.off("scalechanging", webViewerScaleChanging);
|
||||||
@ -2002,28 +2015,6 @@ function webViewerPageRendered(evt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function webViewerTextLayerRendered(evt) {
|
|
||||||
if (
|
|
||||||
typeof PDFJSDev !== "undefined" &&
|
|
||||||
PDFJSDev.test("FIREFOX || MOZCENTRAL") &&
|
|
||||||
evt.numTextDivs > 0 &&
|
|
||||||
!PDFViewerApplication.supportsDocumentColors
|
|
||||||
) {
|
|
||||||
PDFViewerApplication.l10n
|
|
||||||
.get(
|
|
||||||
"document_colors_not_allowed",
|
|
||||||
null,
|
|
||||||
"PDF documents are not allowed to use their own colors: " +
|
|
||||||
"'Allow pages to choose their own colors' " +
|
|
||||||
"is deactivated in the browser."
|
|
||||||
)
|
|
||||||
.then(msg => {
|
|
||||||
console.error(msg);
|
|
||||||
});
|
|
||||||
PDFViewerApplication.fallback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function webViewerPageMode({ mode }) {
|
function webViewerPageMode({ mode }) {
|
||||||
// Handle the 'pagemode' hash parameter, see also `PDFLinkService_setHash`.
|
// Handle the 'pagemode' hash parameter, see also `PDFLinkService_setHash`.
|
||||||
let view;
|
let view;
|
||||||
|
@ -404,27 +404,30 @@ class ChromePreferences extends BasePreferences {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ChromeExternalServices = Object.create(DefaultExternalServices);
|
class ChromeExternalServices extends DefaultExternalServices {
|
||||||
ChromeExternalServices.initPassiveLoading = function(callbacks) {
|
static initPassiveLoading(callbacks) {
|
||||||
const { overlayManager } = PDFViewerApplication;
|
// defaultUrl is set in viewer.js
|
||||||
// defaultUrl is set in viewer.js
|
ChromeCom.resolvePDFFile(
|
||||||
ChromeCom.resolvePDFFile(
|
AppOptions.get("defaultUrl"),
|
||||||
AppOptions.get("defaultUrl"),
|
PDFViewerApplication.overlayManager,
|
||||||
overlayManager,
|
function(url, length, originalUrl) {
|
||||||
function(url, length, originalUrl) {
|
callbacks.onOpenWithURL(url, length, originalUrl);
|
||||||
callbacks.onOpenWithURL(url, length, originalUrl);
|
}
|
||||||
}
|
);
|
||||||
);
|
}
|
||||||
};
|
|
||||||
ChromeExternalServices.createDownloadManager = function(options) {
|
static createDownloadManager(options) {
|
||||||
return new DownloadManager(options);
|
return new DownloadManager(options);
|
||||||
};
|
}
|
||||||
ChromeExternalServices.createPreferences = function() {
|
|
||||||
return new ChromePreferences();
|
static createPreferences() {
|
||||||
};
|
return new ChromePreferences();
|
||||||
ChromeExternalServices.createL10n = function(options) {
|
}
|
||||||
return new GenericL10n(navigator.language);
|
|
||||||
};
|
static createL10n(options) {
|
||||||
|
return new GenericL10n(navigator.language);
|
||||||
|
}
|
||||||
|
}
|
||||||
PDFViewerApplication.externalServices = ChromeExternalServices;
|
PDFViewerApplication.externalServices = ChromeExternalServices;
|
||||||
|
|
||||||
export { ChromeCom };
|
export { ChromeCom };
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
|
|
||||||
import "../extensions/firefox/tools/l10n";
|
import "../extensions/firefox/tools/l10n";
|
||||||
import { createObjectURL, PDFDataRangeTransport, shadow } from "pdfjs-lib";
|
import { createObjectURL, PDFDataRangeTransport, shadow } from "pdfjs-lib";
|
||||||
|
import { DefaultExternalServices, PDFViewerApplication } from "./app.js";
|
||||||
import { BasePreferences } from "./preferences.js";
|
import { BasePreferences } from "./preferences.js";
|
||||||
import { DEFAULT_SCALE_VALUE } from "./ui_utils.js";
|
import { DEFAULT_SCALE_VALUE } from "./ui_utils.js";
|
||||||
import { PDFViewerApplication } from "./app.js";
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
typeof PDFJSDev === "undefined" ||
|
typeof PDFJSDev === "undefined" ||
|
||||||
@ -241,16 +241,16 @@ class FirefoxComDataRangeTransport extends PDFDataRangeTransport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PDFViewerApplication.externalServices = {
|
class FirefoxExternalServices extends DefaultExternalServices {
|
||||||
updateFindControlState(data) {
|
static updateFindControlState(data) {
|
||||||
FirefoxCom.request("updateFindControlState", data);
|
FirefoxCom.request("updateFindControlState", data);
|
||||||
},
|
}
|
||||||
|
|
||||||
updateFindMatchesCount(data) {
|
static updateFindMatchesCount(data) {
|
||||||
FirefoxCom.request("updateFindMatchesCount", data);
|
FirefoxCom.request("updateFindMatchesCount", data);
|
||||||
},
|
}
|
||||||
|
|
||||||
initPassiveLoading(callbacks) {
|
static initPassiveLoading(callbacks) {
|
||||||
let pdfDataRangeTransport;
|
let pdfDataRangeTransport;
|
||||||
|
|
||||||
window.addEventListener("message", function windowMessage(e) {
|
window.addEventListener("message", function windowMessage(e) {
|
||||||
@ -309,52 +309,48 @@ PDFViewerApplication.externalServices = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
FirefoxCom.requestSync("initPassiveLoading", null);
|
FirefoxCom.requestSync("initPassiveLoading", null);
|
||||||
},
|
}
|
||||||
|
|
||||||
fallback(data, callback) {
|
static fallback(data, callback) {
|
||||||
FirefoxCom.request("fallback", data, callback);
|
FirefoxCom.request("fallback", data, callback);
|
||||||
},
|
}
|
||||||
|
|
||||||
reportTelemetry(data) {
|
static reportTelemetry(data) {
|
||||||
FirefoxCom.request("reportTelemetry", JSON.stringify(data));
|
FirefoxCom.request("reportTelemetry", JSON.stringify(data));
|
||||||
},
|
}
|
||||||
|
|
||||||
createDownloadManager(options) {
|
static createDownloadManager(options) {
|
||||||
return new DownloadManager(options);
|
return new DownloadManager(options);
|
||||||
},
|
}
|
||||||
|
|
||||||
createPreferences() {
|
static createPreferences() {
|
||||||
return new FirefoxPreferences();
|
return new FirefoxPreferences();
|
||||||
},
|
}
|
||||||
|
|
||||||
createL10n(options) {
|
static createL10n(options) {
|
||||||
const mozL10n = document.mozL10n;
|
const mozL10n = document.mozL10n;
|
||||||
// TODO refactor mozL10n.setExternalLocalizerServices
|
// TODO refactor mozL10n.setExternalLocalizerServices
|
||||||
return new MozL10n(mozL10n);
|
return new MozL10n(mozL10n);
|
||||||
},
|
}
|
||||||
|
|
||||||
get supportsIntegratedFind() {
|
static get supportsIntegratedFind() {
|
||||||
const support = FirefoxCom.requestSync("supportsIntegratedFind");
|
const support = FirefoxCom.requestSync("supportsIntegratedFind");
|
||||||
return shadow(this, "supportsIntegratedFind", support);
|
return shadow(this, "supportsIntegratedFind", support);
|
||||||
},
|
}
|
||||||
|
|
||||||
get supportsDocumentFonts() {
|
static get supportsDocumentFonts() {
|
||||||
const support = FirefoxCom.requestSync("supportsDocumentFonts");
|
const support = FirefoxCom.requestSync("supportsDocumentFonts");
|
||||||
return shadow(this, "supportsDocumentFonts", support);
|
return shadow(this, "supportsDocumentFonts", support);
|
||||||
},
|
}
|
||||||
|
|
||||||
get supportsDocumentColors() {
|
static get supportedMouseWheelZoomModifierKeys() {
|
||||||
const support = FirefoxCom.requestSync("supportsDocumentColors");
|
|
||||||
return shadow(this, "supportsDocumentColors", support);
|
|
||||||
},
|
|
||||||
|
|
||||||
get supportedMouseWheelZoomModifierKeys() {
|
|
||||||
const support = FirefoxCom.requestSync(
|
const support = FirefoxCom.requestSync(
|
||||||
"supportedMouseWheelZoomModifierKeys"
|
"supportedMouseWheelZoomModifierKeys"
|
||||||
);
|
);
|
||||||
return shadow(this, "supportedMouseWheelZoomModifierKeys", support);
|
return shadow(this, "supportedMouseWheelZoomModifierKeys", support);
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
PDFViewerApplication.externalServices = FirefoxExternalServices;
|
||||||
|
|
||||||
// l10n.js for Firefox extension expects services to be set.
|
// l10n.js for Firefox extension expects services to be set.
|
||||||
document.mozL10n.setExternalLocalizerServices({
|
document.mozL10n.setExternalLocalizerServices({
|
||||||
|
@ -37,16 +37,19 @@ class GenericPreferences extends BasePreferences {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const GenericExternalServices = Object.create(DefaultExternalServices);
|
class GenericExternalServices extends DefaultExternalServices {
|
||||||
GenericExternalServices.createDownloadManager = function(options) {
|
static createDownloadManager(options) {
|
||||||
return new DownloadManager(options);
|
return new DownloadManager(options);
|
||||||
};
|
}
|
||||||
GenericExternalServices.createPreferences = function() {
|
|
||||||
return new GenericPreferences();
|
static createPreferences() {
|
||||||
};
|
return new GenericPreferences();
|
||||||
GenericExternalServices.createL10n = function({ locale = "en-US" }) {
|
}
|
||||||
return new GenericL10n(locale);
|
|
||||||
};
|
static createL10n({ locale = "en-US" }) {
|
||||||
|
return new GenericL10n(locale);
|
||||||
|
}
|
||||||
|
}
|
||||||
PDFViewerApplication.externalServices = GenericExternalServices;
|
PDFViewerApplication.externalServices = GenericExternalServices;
|
||||||
|
|
||||||
export { GenericCom };
|
export { GenericCom };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user