[Pkg-javascript-commits] [pdf.js] 116/204: Moves constants to avoid dependency on PDFView
David Prévot
taffit at moszumanska.debian.org
Sat Oct 25 18:50:40 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit a1eca2084d0379ba5aa71ae97ec01967f7070a1a
Author: Yury Delendik <ydelendik at mozilla.com>
Date: Mon Sep 15 15:46:01 2014 -0500
Moves constants to avoid dependency on PDFView
---
web/pdf_rendering_queue.js | 3 ++-
web/pdf_viewer.js | 30 ++++++++++++++++++++++++------
web/thumbnail_view.js | 6 ++++--
web/ui_utils.js | 8 ++++++++
web/viewer.html | 2 +-
web/viewer.js | 20 +++++---------------
6 files changed, 44 insertions(+), 25 deletions(-)
diff --git a/web/pdf_rendering_queue.js b/web/pdf_rendering_queue.js
index 58424b7..65d30b7 100644
--- a/web/pdf_rendering_queue.js
+++ b/web/pdf_rendering_queue.js
@@ -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,
diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js
index e5f49d2..1ea61bb 100644
--- a/web/pdf_viewer.js
+++ b/web/pdf_viewer.js
@@ -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];
diff --git a/web/thumbnail_view.js b/web/thumbnail_view.js
index efd10a9..313b233 100644
--- a/web/thumbnail_view.js
+++ b/web/thumbnail_view.js
@@ -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) {
diff --git a/web/ui_utils.js b/web/ui_utils.js
index 04805c0..1779b60 100644
--- a/web/ui_utils.js
+++ b/web/ui_utils.js
@@ -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() {
diff --git a/web/viewer.html b/web/viewer.html
index 96af7b4..471d036 100644
--- a/web/viewer.html
+++ b/web/viewer.html
@@ -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>
diff --git a/web/viewer.js b/web/viewer.js
index 4d01548..3d93ea9 100644
--- a/web/viewer.js
+++ b/web/viewer.js
@@ -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
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list