Moves constants to avoid dependency on PDFView

This commit is contained in:
Yury Delendik 2014-09-15 15:46:01 -05:00
parent f1851c6393
commit a1eca2084d
6 changed files with 44 additions and 25 deletions

View File

@ -14,10 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*globals CLEANUP_TIMEOUT */
'use strict';
var CLEANUP_TIMEOUT = 30000;
var RenderingStates = {
INITIAL: 0,
RUNNING: 1,

View File

@ -15,9 +15,9 @@
* limitations under the License.
*/
/*globals watchScroll, Cache, DEFAULT_CACHE_SIZE, PageView, UNKNOWN_SCALE,
IGNORE_CURRENT_POSITION_ON_ZOOM, SCROLLBAR_PADDING, VERTICAL_PADDING,
MAX_AUTO_SCALE, getVisibleElements, RenderingStates, Promise,
CSS_UNITS, PDFJS, TextLayerBuilder */
SCROLLBAR_PADDING, VERTICAL_PADDING, MAX_AUTO_SCALE, CSS_UNITS,
getVisibleElements, RenderingStates, Promise,
PDFJS, TextLayerBuilder, PDFRenderingQueue */
'use strict';
@ -28,13 +28,27 @@ var PresentationModeState = {
FULLSCREEN: 3,
};
var IGNORE_CURRENT_POSITION_ON_ZOOM = false;
//#include pdf_rendering_queue.js
//#include page_view.js
//#include text_layer_builder.js
var PDFViewer = (function pdfViewer() {
function PDFViewer(options) {
this.container = options.container;
this.viewer = options.viewer;
this.renderingQueue = options.renderingQueue;
this.viewer = options.viewer || options.container.firstElementChild;
this.linkService = options.linkService;
this.defaultRenderingQueue = !options.renderingQueue;
if (this.defaultRenderingQueue) {
// Custom rendering queue is not specified, using default one
this.renderingQueue = new PDFRenderingQueue();
this.renderingQueue.setViewer(this);
} else {
this.renderingQueue = options.renderingQueue;
}
this.scroll = watchScroll(this.container, this._scrollUpdate.bind(this));
this.lastScroll = 0;
this.updateInProgress = false;
@ -162,6 +176,10 @@ var PDFViewer = (function pdfViewer() {
resolvePagesPromise();
}
});
if (this.defaultRenderingQueue) {
firstPagePromise.then(this.update.bind(this));
}
}.bind(this));
},
@ -206,7 +224,7 @@ var PDFViewer = (function pdfViewer() {
this.presentationModeState === PresentationModeState.CHANGING ||
this.presentationModeState === PresentationModeState.FULLSCREEN;
if (this.location && !inPresentationMode &&
!IGNORE_CURRENT_POSITION_ON_ZOOM) {
!IGNORE_CURRENT_POSITION_ON_ZOOM) {
page = this.location.pageNumber;
dest = [null, { name: 'XYZ' }, this.location.left,
this.location.top, null];

View File

@ -14,11 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals mozL10n, RenderingStates, THUMBNAIL_SCROLL_MARGIN, Promise,
watchScroll, getVisibleElements, scrollIntoView, PDFPageSource */
/* globals mozL10n, RenderingStates, Promise, scrollIntoView, PDFPageSource,
watchScroll, getVisibleElements */
'use strict';
var THUMBNAIL_SCROLL_MARGIN = -19;
var ThumbnailView = function thumbnailView(container, id, defaultViewport,
linkService, renderingQueue,
pageSource) {

View File

@ -16,6 +16,14 @@
'use strict';
var CSS_UNITS = 96.0 / 72.0;
var DEFAULT_SCALE = 'auto';
var UNKNOWN_SCALE = 0;
var MAX_AUTO_SCALE = 1.25;
var SCROLLBAR_PADDING = 40;
var VERTICAL_PADDING = 5;
var DEFAULT_CACHE_SIZE = 10;
// optimised CSS custom property getter/setter
var CustomStyle = (function CustomStyleClosure() {

View File

@ -70,9 +70,9 @@ http://sourceforge.net/adobe/cmap/wiki/License/
<script src="view_history.js"></script>
<script src="pdf_rendering_queue.js"></script>
<script src="page_view.js"></script>
<script src="text_layer_builder.js"></script>
<script src="pdf_viewer.js"></script>
<script src="thumbnail_view.js"></script>
<script src="text_layer_builder.js"></script>
<script src="document_outline_view.js"></script>
<script src="document_attachments_view.js"></script>
<script src="pdf_find_bar.js"></script>

View File

@ -21,27 +21,20 @@
PasswordPrompt, PresentationMode, HandTool, Promise,
DocumentProperties, DocumentOutlineView, DocumentAttachmentsView,
OverlayManager, PDFFindController, PDFFindBar, getVisibleElements,
watchScroll, PDFViewer, PDFRenderingQueue, PresentationModeState */
watchScroll, PDFViewer, PDFRenderingQueue, PresentationModeState,
DEFAULT_SCALE, UNKNOWN_SCALE,
IGNORE_CURRENT_POSITION_ON_ZOOM: true */
'use strict';
var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
var DEFAULT_SCALE = 'auto';
var DEFAULT_SCALE_DELTA = 1.1;
var UNKNOWN_SCALE = 0;
var DEFAULT_CACHE_SIZE = 10;
var CSS_UNITS = 96.0 / 72.0;
var SCROLLBAR_PADDING = 40;
var VERTICAL_PADDING = 5;
var MAX_AUTO_SCALE = 1.25;
var MIN_SCALE = 0.25;
var MAX_SCALE = 10.0;
var VIEW_HISTORY_MEMORY = 20;
var SCALE_SELECT_CONTAINER_PADDING = 8;
var SCALE_SELECT_PADDING = 22;
var THUMBNAIL_SCROLL_MARGIN = -19;
var CLEANUP_TIMEOUT = 30000;
var IGNORE_CURRENT_POSITION_ON_ZOOM = false;
//#if B2G
//PDFJS.useOnlyCssZoom = true;
//PDFJS.disableTextLayer = true;
@ -90,6 +83,7 @@ var mozL10n = document.mozL10n || document.webL10n;
//#include overlay_manager.js
//#include password_prompt.js
//#include document_properties.js
//#include pdf_viewer.js
var PDFView = {
initialBookmark: document.location.hash.substring(1),
@ -1363,11 +1357,7 @@ var PDFView = {
}
};
//#include pdf_rendering_queue.js
//#include page_view.js
//#include pdf_viewer.js
//#include thumbnail_view.js
//#include text_layer_builder.js
//#include document_outline_view.js
//#include document_attachments_view.js