mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 14:48:08 +02:00
Add preprocessor directives for the extension; and refactor FirefoxCom callback
This commit is contained in:
parent
da93e65d8c
commit
68b037ffb0
2 changed files with 15 additions and 5 deletions
|
@ -161,15 +161,22 @@ function getLocalizedString(strings, id, property) {
|
|||
}
|
||||
|
||||
function makeContentReadable(obj, window) {
|
||||
//#if MOZCENTRAL
|
||||
return Cu.cloneInto(obj, window);
|
||||
//#else
|
||||
if (Cu.cloneInto) {
|
||||
return Cu.cloneInto(obj, window);
|
||||
}
|
||||
if (typeof obj !== 'object' || obj === null) {
|
||||
return obj;
|
||||
}
|
||||
var expose = {};
|
||||
for (let k in obj) {
|
||||
expose[k] = "r";
|
||||
}
|
||||
obj.__exposedProps__ = expose;
|
||||
return obj;
|
||||
//#endif
|
||||
}
|
||||
|
||||
// PDF data storage
|
||||
|
@ -698,7 +705,7 @@ var StandardChromeActions = (function StandardChromeActionsClosure() {
|
|||
return StandardChromeActions;
|
||||
})();
|
||||
|
||||
// Event listener to trigger chrome privedged code.
|
||||
// Event listener to trigger chrome privileged code.
|
||||
function RequestListener(actions) {
|
||||
this.actions = actions;
|
||||
}
|
||||
|
@ -719,7 +726,7 @@ RequestListener.prototype.receive = function(event) {
|
|||
event.detail.response = response;
|
||||
} else {
|
||||
var response;
|
||||
if (!event.detail.callback) {
|
||||
if (!event.detail.responseExpected) {
|
||||
doc.documentElement.removeChild(message);
|
||||
response = null;
|
||||
} else {
|
||||
|
|
|
@ -64,9 +64,12 @@ var FirefoxCom = (function FirefoxComClosure() {
|
|||
document.documentElement.appendChild(request);
|
||||
|
||||
var sender = document.createEvent('CustomEvent');
|
||||
sender.initCustomEvent('pdf.js.message', true, false,
|
||||
{action: action, data: data, sync: false,
|
||||
callback: callback});
|
||||
sender.initCustomEvent('pdf.js.message', true, false, {
|
||||
action: action,
|
||||
data: data,
|
||||
sync: false,
|
||||
responseExpected: !!callback
|
||||
});
|
||||
return request.dispatchEvent(sender);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue