2014-10-01 02:22:38 +09:00
|
|
|
/* Copyright 2014 Mozilla Foundation
|
2014-09-21 02:21:49 +09:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2017-04-28 19:02:42 +09:00
|
|
|
/* eslint-disable no-unused-vars */
|
2014-09-21 02:21:49 +09:00
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @interface
|
|
|
|
*/
|
2017-05-08 05:01:49 +09:00
|
|
|
class IPDFLinkService {
|
2014-09-21 02:21:49 +09:00
|
|
|
/**
|
|
|
|
* @returns {number}
|
|
|
|
*/
|
2017-05-08 05:01:49 +09:00
|
|
|
get page() {}
|
|
|
|
|
2014-09-21 02:21:49 +09:00
|
|
|
/**
|
|
|
|
* @param {number} value
|
|
|
|
*/
|
2017-05-08 05:01:49 +09:00
|
|
|
set page(value) {}
|
|
|
|
|
2014-09-21 02:21:49 +09:00
|
|
|
/**
|
|
|
|
* @param dest - The PDF destination object.
|
|
|
|
*/
|
2017-05-08 05:01:49 +09:00
|
|
|
navigateTo(dest) {}
|
|
|
|
|
2014-09-21 02:21:49 +09:00
|
|
|
/**
|
|
|
|
* @param dest - The PDF destination object.
|
|
|
|
* @returns {string} The hyperlink to the PDF object.
|
|
|
|
*/
|
2017-05-08 05:01:49 +09:00
|
|
|
getDestinationHash(dest) {}
|
|
|
|
|
2014-09-21 02:21:49 +09:00
|
|
|
/**
|
|
|
|
* @param hash - The PDF parameters/hash.
|
|
|
|
* @returns {string} The hyperlink to the PDF object.
|
|
|
|
*/
|
2017-05-08 05:01:49 +09:00
|
|
|
getAnchorUrl(hash) {}
|
|
|
|
|
2014-09-22 20:41:17 +09:00
|
|
|
/**
|
|
|
|
* @param {string} hash
|
|
|
|
*/
|
2017-05-08 05:01:49 +09:00
|
|
|
setHash(hash) {}
|
|
|
|
|
2014-10-01 02:22:38 +09:00
|
|
|
/**
|
|
|
|
* @param {string} action
|
|
|
|
*/
|
2017-05-08 05:01:49 +09:00
|
|
|
executeNamedAction(action) {}
|
2015-04-28 00:25:32 +09:00
|
|
|
|
2017-07-14 23:30:25 +09:00
|
|
|
/**
|
|
|
|
* @param {Object} params
|
|
|
|
*/
|
|
|
|
onFileAttachmentAnnotation({ id, filename, content, }) {}
|
|
|
|
|
2015-04-28 00:25:32 +09:00
|
|
|
/**
|
|
|
|
* @param {number} pageNum - page number.
|
|
|
|
* @param {Object} pageRef - reference to the page.
|
|
|
|
*/
|
2017-05-08 05:01:49 +09:00
|
|
|
cachePageRef(pageNum, pageRef) {}
|
|
|
|
}
|
2014-09-21 02:21:49 +09:00
|
|
|
|
2015-04-27 23:04:11 +09:00
|
|
|
/**
|
|
|
|
* @interface
|
|
|
|
*/
|
2017-05-08 05:01:49 +09:00
|
|
|
class IPDFHistory {
|
Re-write `PDFHistory` from scratch
This patch completely re-implements `PDFHistory` to get rid of various bugs currently present, and to hopefully make maintenance slightly easier. Most of the interface is similar to the existing one, but it should be somewhat simplified.
The new implementation should be more robust against failure, compared to the old one. Previously, it was too easy to end up in a state which basically caused the browser history to lock-up, preventing the user from navigating back/forward. (In the new implementation, the browser history should not be updated rather than breaking if things go wrong.)
Given that the code has to deal with various edge-cases, it's still not as simple as I would have liked, but it should now be somewhat easier to deal with.
The main source of complication in the code is actually that we allow the user to change the hash of a already loaded document (we'll no longer try to navigate back-and-forth in this case, since the next commit contains a workaround).
In the new code, there's also *a lot* more comments (perhaps too many?) to attempt to explain the logic. This is something that the old implementation was serverly lacking, which is a one of the reasons why it was so difficult to maintain.
One particular thing to note is that the new code uses the `pagehide` event rather than `beforeunload`, since the latter seems to be a bad idea based on https://bugzilla.mozilla.org/show_bug.cgi?id=1336763.
2017-07-16 20:39:39 +09:00
|
|
|
/**
|
|
|
|
* @param {string} fingerprint - The PDF document's unique fingerprint.
|
|
|
|
* @param {boolean} resetHistory - (optional) Reset the browsing history.
|
|
|
|
*/
|
|
|
|
initialize(fingerprint, resetHistory = false) {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Object} params
|
|
|
|
*/
|
|
|
|
push({ namedDest, explicitDest, pageNumber, }) {}
|
2017-07-14 21:24:32 +09:00
|
|
|
|
Re-write `PDFHistory` from scratch
This patch completely re-implements `PDFHistory` to get rid of various bugs currently present, and to hopefully make maintenance slightly easier. Most of the interface is similar to the existing one, but it should be somewhat simplified.
The new implementation should be more robust against failure, compared to the old one. Previously, it was too easy to end up in a state which basically caused the browser history to lock-up, preventing the user from navigating back/forward. (In the new implementation, the browser history should not be updated rather than breaking if things go wrong.)
Given that the code has to deal with various edge-cases, it's still not as simple as I would have liked, but it should now be somewhat easier to deal with.
The main source of complication in the code is actually that we allow the user to change the hash of a already loaded document (we'll no longer try to navigate back-and-forth in this case, since the next commit contains a workaround).
In the new code, there's also *a lot* more comments (perhaps too many?) to attempt to explain the logic. This is something that the old implementation was serverly lacking, which is a one of the reasons why it was so difficult to maintain.
One particular thing to note is that the new code uses the `pagehide` event rather than `beforeunload`, since the latter seems to be a bad idea based on https://bugzilla.mozilla.org/show_bug.cgi?id=1336763.
2017-07-16 20:39:39 +09:00
|
|
|
pushCurrentPosition() {}
|
2017-07-14 21:24:32 +09:00
|
|
|
|
2017-05-08 05:01:49 +09:00
|
|
|
back() {}
|
2017-07-14 21:24:32 +09:00
|
|
|
|
|
|
|
forward() {}
|
2017-05-08 05:01:49 +09:00
|
|
|
}
|
2015-04-27 23:04:11 +09:00
|
|
|
|
2014-09-21 02:21:49 +09:00
|
|
|
/**
|
|
|
|
* @interface
|
|
|
|
*/
|
2017-05-08 05:01:49 +09:00
|
|
|
class IRenderableView {
|
2014-09-21 02:21:49 +09:00
|
|
|
/**
|
|
|
|
* @returns {string} - Unique ID for rendering queue.
|
|
|
|
*/
|
2017-05-08 05:01:49 +09:00
|
|
|
get renderingId() {}
|
|
|
|
|
2014-09-21 02:21:49 +09:00
|
|
|
/**
|
|
|
|
* @returns {RenderingStates}
|
|
|
|
*/
|
2017-05-08 05:01:49 +09:00
|
|
|
get renderingState() {}
|
|
|
|
|
2014-09-21 02:21:49 +09:00
|
|
|
/**
|
2014-12-18 05:47:14 +09:00
|
|
|
* @returns {Promise} Resolved on draw completion.
|
2014-09-21 02:21:49 +09:00
|
|
|
*/
|
2017-05-08 05:01:49 +09:00
|
|
|
draw() {}
|
|
|
|
|
|
|
|
resume() {}
|
|
|
|
}
|
2014-09-21 02:21:49 +09:00
|
|
|
|
2014-09-28 23:35:33 +09:00
|
|
|
/**
|
|
|
|
* @interface
|
|
|
|
*/
|
2017-05-08 05:01:49 +09:00
|
|
|
class IPDFTextLayerFactory {
|
2014-09-28 23:35:33 +09:00
|
|
|
/**
|
|
|
|
* @param {HTMLDivElement} textLayerDiv
|
|
|
|
* @param {number} pageIndex
|
|
|
|
* @param {PageViewport} viewport
|
2016-09-02 01:07:12 +09:00
|
|
|
* @param {boolean} enhanceTextSelection
|
2014-09-28 23:35:33 +09:00
|
|
|
* @returns {TextLayerBuilder}
|
|
|
|
*/
|
2017-04-28 19:02:42 +09:00
|
|
|
createTextLayerBuilder(textLayerDiv, pageIndex, viewport,
|
|
|
|
enhanceTextSelection = false) {}
|
2017-05-08 05:01:49 +09:00
|
|
|
}
|
2014-09-30 01:05:28 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @interface
|
|
|
|
*/
|
2017-04-28 19:02:42 +09:00
|
|
|
class IPDFAnnotationLayerFactory {
|
2014-09-30 01:05:28 +09:00
|
|
|
/**
|
|
|
|
* @param {HTMLDivElement} pageDiv
|
|
|
|
* @param {PDFPage} pdfPage
|
2017-05-04 10:05:53 +09:00
|
|
|
* @param {IL10n} l10n
|
2016-09-18 02:44:25 +09:00
|
|
|
* @param {boolean} renderInteractiveForms
|
2015-12-17 20:54:53 +09:00
|
|
|
* @returns {AnnotationLayerBuilder}
|
2014-09-30 01:05:28 +09:00
|
|
|
*/
|
2017-04-24 03:52:58 +09:00
|
|
|
createAnnotationLayerBuilder(pageDiv, pdfPage,
|
2017-05-04 10:05:53 +09:00
|
|
|
renderInteractiveForms = false,
|
|
|
|
l10n = undefined) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @interface
|
|
|
|
*/
|
|
|
|
class IL10n {
|
|
|
|
/**
|
|
|
|
* @returns {Promise<string>} - Resolves to 'rtl' or 'ltr'.
|
|
|
|
*/
|
|
|
|
getDirection() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Translates text identified by the key and adds/formats data using the args
|
|
|
|
* property bag. If the key was not found, translation falls back to the
|
|
|
|
* fallback text.
|
|
|
|
* @param {string} key
|
|
|
|
* @param {object} args
|
|
|
|
* @param {string} fallback
|
|
|
|
* @returns {Promise<string>}
|
|
|
|
*/
|
|
|
|
get(key, args, fallback) { }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Translates HTML element.
|
|
|
|
* @param {HTMLElement} element
|
|
|
|
* @returns {Promise<void>}
|
|
|
|
*/
|
|
|
|
translate(element) { }
|
2017-04-24 03:52:58 +09:00
|
|
|
}
|