зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1347504 - [jsplugins][UI] Support opening external links in PDF files. r=evelyn,lochang, f=lchang, f=lochang
MozReview-Commit-ID: CIrC4ise4Zs Hotkeys works like normal DOM links, except "Open in background tab" (which corresponds to ctrl/command + click) open tabs in foreground due to limitation from outside chrome process. --HG-- extra : rebase_source : 6a3b43c518e23c61fe3c48cc4317b813a39acc7a
This commit is contained in:
Родитель
a3baec363f
Коммит
2a6a2e2288
|
@ -1720,6 +1720,7 @@ class PPAPIInstance {
|
|||
let mouseEventInit = {
|
||||
altkey: event.altkey,
|
||||
button: event.button,
|
||||
buttons: event.buttons,
|
||||
clientX: event.clientX - rect.left,
|
||||
clientY: event.clientY - rect.top,
|
||||
ctrlKey: event.ctrlKey,
|
||||
|
@ -1820,6 +1821,12 @@ class PPAPIInstance {
|
|||
// We need permission for showing print dialog to get print settings
|
||||
this.mm.sendAsyncMessage("ppapipdf.js:getPrintSettings");
|
||||
break;
|
||||
case 'openLink':
|
||||
this.mm.sendAsyncMessage("ppapipdf.js:openLink", {
|
||||
url: message.url,
|
||||
disposition: message.disposition
|
||||
});
|
||||
break;
|
||||
case 'viewport':
|
||||
case 'rotateClockwise':
|
||||
case 'rotateCounterclockwise':
|
||||
|
@ -3126,25 +3133,37 @@ dump(`callFromJSON: < ${JSON.stringify(call)}\n`);
|
|||
|
||||
if (event instanceof KeyboardInputEvent) {
|
||||
if (event.domEvent.location == event.domEvent.DOM_KEY_LOCATION_NUMPAD) {
|
||||
modifiers &= PP_InputEvent_Modifier.PP_INPUTEVENT_MODIFIER_ISKEYPAD;
|
||||
modifiers |= PP_InputEvent_Modifier.PP_INPUTEVENT_MODIFIER_ISKEYPAD;
|
||||
} else if (event.domEvent.location & event.domEvent.DOM_KEY_LOCATION_LEFT) {
|
||||
modifiers &= PP_InputEvent_Modifier.PP_INPUTEVENT_MODIFIER_ISLEFT;
|
||||
modifiers |= PP_InputEvent_Modifier.PP_INPUTEVENT_MODIFIER_ISLEFT;
|
||||
} else if (event.domEvent.location & event.domEvent.DOM_KEY_LOCATION_RIGHT) {
|
||||
modifiers &= PP_InputEvent_Modifier.PP_INPUTEVENT_MODIFIER_ISRIGHT;
|
||||
modifiers |= PP_InputEvent_Modifier.PP_INPUTEVENT_MODIFIER_ISRIGHT;
|
||||
}
|
||||
|
||||
if (event.domEvent.repeat) {
|
||||
modifiers &= PP_InputEvent_Modifier.PP_INPUTEVENT_MODIFIER_ISAUTOREPEAT;
|
||||
modifiers |= PP_InputEvent_Modifier.PP_INPUTEVENT_MODIFIER_ISAUTOREPEAT;
|
||||
}
|
||||
} else if (event instanceof MouseInputEvent) {
|
||||
if (event.domEvent.buttons && 0x01) {
|
||||
modifiers &= PP_InputEvent_Modifier.PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN;
|
||||
if (event.domEvent.buttons & 0x01) {
|
||||
modifiers |= PP_InputEvent_Modifier.PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN;
|
||||
}
|
||||
if (event.domEvent.buttons && 0x04) {
|
||||
modifiers &= PP_InputEvent_Modifier.PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN;
|
||||
if (event.domEvent.buttons & 0x04) {
|
||||
modifiers |= PP_InputEvent_Modifier.PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN;
|
||||
}
|
||||
if (event.domEvent.buttons && 0x02) {
|
||||
modifiers &= PP_InputEvent_Modifier.PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN;
|
||||
if (event.domEvent.buttons & 0x02) {
|
||||
modifiers |= PP_InputEvent_Modifier.PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN;
|
||||
}
|
||||
if (event.domEvent.type == 'mouseup') {
|
||||
// mouseup event indicates the key released only in domEvent.button
|
||||
// rather than domEvent.buttons, but PDFium do use modifiers to
|
||||
// determine which button is released. So we make it up here.
|
||||
if (event.domEvent.button == 0) {
|
||||
modifiers |= PP_InputEvent_Modifier.PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN;
|
||||
} else if (event.domEvent.button == 1) {
|
||||
modifiers |= PP_InputEvent_Modifier.PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN;
|
||||
} else if (event.domEvent.button == 2) {
|
||||
modifiers |= PP_InputEvent_Modifier.PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -782,6 +782,13 @@ class Viewport {
|
|||
case 'goToPage':
|
||||
this.page = message.page;
|
||||
break;
|
||||
case 'navigate':
|
||||
this._doAction({
|
||||
type: 'openLink',
|
||||
url: message.url,
|
||||
disposition: message.disposition
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,6 +180,31 @@ mm.addMessageListener("ppapipdf.js:printPDF", ({ data }) => {
|
|||
});
|
||||
});
|
||||
|
||||
mm.addMessageListener("ppapipdf.js:openLink", ({data}) => {
|
||||
const PDFIUM_WINDOW_OPEN_DISPOSITION = {
|
||||
CURRENT_TAB: 1,
|
||||
NEW_FOREGROUND_TAB: 3,
|
||||
NEW_BACKGROUND_TAB: 4,
|
||||
NEW_WINDOW: 6,
|
||||
};
|
||||
switch(data.disposition) {
|
||||
case PDFIUM_WINDOW_OPEN_DISPOSITION.CURRENT_TAB:
|
||||
containerWindow.location.href = data.url;
|
||||
break;
|
||||
// We don't support opening in background tab for now. Just open it in
|
||||
// foreground tab.
|
||||
case PDFIUM_WINDOW_OPEN_DISPOSITION.NEW_FOREGROUND_TAB:
|
||||
case PDFIUM_WINDOW_OPEN_DISPOSITION.NEW_BACKGROUND_TAB:
|
||||
containerWindow.open(data.url);
|
||||
break;
|
||||
case PDFIUM_WINDOW_OPEN_DISPOSITION.NEW_WINDOW:
|
||||
containerWindow.open(data.url, "",
|
||||
"noopener=1,menubar=1,toolbar=1," +
|
||||
"location=1,personalbar=1,status=1,resizable");
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
mm.addMessageListener("ppapipdf.js:save", () => {
|
||||
let url = containerWindow.document.location;
|
||||
let filename = "document.pdf";
|
||||
|
|
Загрузка…
Ссылка в новой задаче