[Pkg-javascript-commits] [pdf.js] 04/116: Creates IPDFTextLayerFactory interface
David Prévot
taffit at moszumanska.debian.org
Fri Mar 6 16:19:54 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit 7663942ee5ac344326b4b32a1e6e333209ab1e34
Author: Yury Delendik <ydelendik at mozilla.com>
Date: Sun Sep 28 09:35:33 2014 -0500
Creates IPDFTextLayerFactory interface
---
web/interfaces.js | 14 ++++++++++++++
web/pdf_page_view.js | 14 +++++++-------
web/pdf_viewer.js | 12 ++++++++----
3 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/web/interfaces.js b/web/interfaces.js
index 5f0ad04..91ac65d 100644
--- a/web/interfaces.js
+++ b/web/interfaces.js
@@ -83,3 +83,17 @@ ILastScrollSource.prototype = {
*/
get lastScroll() {},
};
+
+/**
+ * @interface
+ */
+function IPDFTextLayerFactory() {}
+IPDFTextLayerFactory.prototype = {
+ /**
+ * @param {HTMLDivElement} textLayerDiv
+ * @param {number} pageIndex
+ * @param {PageViewport} viewport
+ * @returns {TextLayerBuilder}
+ */
+ createTextLayerBuilder: function (textLayerDiv, pageIndex, viewport) {}
+};
diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js
index 7e6aa17..d0a0818 100644
--- a/web/pdf_page_view.js
+++ b/web/pdf_page_view.js
@@ -29,7 +29,7 @@
* @property {PDFRenderingQueue} renderingQueue - The rendering queue object.
* @property {Cache} cache - The page cache.
* @property {PDFPageSource} pageSource
- * @property {PDFViewer} viewer
+ * @property {IPDFTextLayerFactory} textLayerFactory
*/
/**
@@ -50,7 +50,7 @@ var PDFPageView = (function PDFPageViewClosure() {
var renderingQueue = options.renderingQueue;
var cache = options.cache;
var pageSource = options.pageSource;
- var viewer = options.viewer;
+ var textLayerFactory = options.textLayerFactory;
this.id = id;
this.renderingId = 'page' + id;
@@ -65,7 +65,7 @@ var PDFPageView = (function PDFPageViewClosure() {
this.renderingQueue = renderingQueue;
this.cache = cache;
this.pageSource = pageSource;
- this.viewer = viewer;
+ this.textLayerFactory = textLayerFactory;
this.renderingState = RenderingStates.INITIAL;
this.resume = null;
@@ -454,7 +454,7 @@ var PDFPageView = (function PDFPageViewClosure() {
var textLayerDiv = null;
var textLayer = null;
- if (!PDFJS.disableTextLayer) {
+ if (this.textLayerFactory) {
textLayerDiv = document.createElement('div');
textLayerDiv.className = 'textLayer';
textLayerDiv.style.width = canvas.style.width;
@@ -466,9 +466,9 @@ var PDFPageView = (function PDFPageViewClosure() {
div.appendChild(textLayerDiv);
}
- textLayer = this.viewer.createTextLayerBuilder(textLayerDiv,
- this.id - 1,
- this.viewport);
+ textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv,
+ this.id - 1,
+ this.viewport);
}
this.textLayer = textLayer;
diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js
index bd87a94..292d765 100644
--- a/web/pdf_viewer.js
+++ b/web/pdf_viewer.js
@@ -236,6 +236,10 @@ var PDFViewer = (function pdfViewer() {
var viewport = pdfPage.getViewport(scale * CSS_UNITS);
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
var pageSource = new PDFPageSource(pdfDocument, pageNum);
+ var textLayerFactory = null;
+ if (!PDFJS.disableTextLayer) {
+ textLayerFactory = this;
+ }
var pageView = new PDFPageView({
container: this.viewer,
id: pageNum,
@@ -245,7 +249,7 @@ var PDFViewer = (function pdfViewer() {
renderingQueue: this.renderingQueue,
cache: this.cache,
pageSource: pageSource,
- viewer: this
+ textLayerFactory: textLayerFactory
});
bindOnAfterDraw(pageView);
this.pages.push(pageView);
@@ -629,9 +633,9 @@ var PDFViewer = (function pdfViewer() {
},
/**
- * @param textLayerDiv {HTMLDivElement}
- * @param pageIndex {number}
- * @param viewport {PageViewport}
+ * @param {HTMLDivElement} textLayerDiv
+ * @param {number} pageIndex
+ * @param {PageViewport} viewport
* @returns {TextLayerBuilder}
*/
createTextLayerBuilder: function (textLayerDiv, pageIndex, viewport) {
--
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