Browse Source

Simple restructuring PageView into PDFPageView

Yury Delendik 11 years ago
parent
commit
f68678086d
  1. 3
      web/pdf_find_controller.js
  2. 1053
      web/pdf_page_view.js
  3. 24
      web/pdf_viewer.js
  4. 3
      web/viewer.js

3
web/pdf_find_controller.js

@ -197,8 +197,6 @@ var PDFFindController = (function PDFFindControllerClosure() {
}, },
updatePage: function PDFFindController_updatePage(index) { updatePage: function PDFFindController_updatePage(index) {
var page = this.pdfViewer.getPageView(index);
if (this.selected.pageIdx === index) { if (this.selected.pageIdx === index) {
// If the page is selected, scroll the page into view, which triggers // If the page is selected, scroll the page into view, which triggers
// rendering the page, which adds the textLayer. Once the textLayer is // rendering the page, which adds the textLayer. Once the textLayer is
@ -206,6 +204,7 @@ var PDFFindController = (function PDFFindControllerClosure() {
this.pdfViewer.scrollPageIntoView(index + 1); this.pdfViewer.scrollPageIntoView(index + 1);
} }
var page = this.pdfViewer.getPageView(index);
if (page.textLayer) { if (page.textLayer) {
page.textLayer.updateMatches(); page.textLayer.updateMatches();
} }

1053
web/pdf_page_view.js

File diff suppressed because it is too large Load Diff

24
web/pdf_viewer.js

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/*globals watchScroll, Cache, DEFAULT_CACHE_SIZE, PageView, UNKNOWN_SCALE, /*globals watchScroll, Cache, DEFAULT_CACHE_SIZE, PDFPageView, UNKNOWN_SCALE,
SCROLLBAR_PADDING, VERTICAL_PADDING, MAX_AUTO_SCALE, CSS_UNITS, SCROLLBAR_PADDING, VERTICAL_PADDING, MAX_AUTO_SCALE, CSS_UNITS,
DEFAULT_SCALE, scrollIntoView, getVisibleElements, RenderingStates, DEFAULT_SCALE, scrollIntoView, getVisibleElements, RenderingStates,
PDFJS, Promise, TextLayerBuilder, PDFRenderingQueue */ PDFJS, Promise, TextLayerBuilder, PDFRenderingQueue */
@ -236,10 +236,17 @@ var PDFViewer = (function pdfViewer() {
var viewport = pdfPage.getViewport(scale * CSS_UNITS); var viewport = pdfPage.getViewport(scale * CSS_UNITS);
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) { for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
var pageSource = new PDFPageSource(pdfDocument, pageNum); var pageSource = new PDFPageSource(pdfDocument, pageNum);
var pageView = new PageView(this.viewer, pageNum, scale, var pageView = new PDFPageView({
viewport.clone(), this.linkService, container: this.viewer,
this.renderingQueue, this.cache, id: pageNum,
pageSource, this); scale: scale,
defaultViewport: viewport.clone(),
linkService: this.linkService,
renderingQueue: this.renderingQueue,
cache: this.cache,
pageSource: pageSource,
viewer: this
});
bindOnAfterDraw(pageView); bindOnAfterDraw(pageView);
this.pages.push(pageView); this.pages.push(pageView);
} }
@ -398,7 +405,6 @@ var PDFViewer = (function pdfViewer() {
scrollPageIntoView: function PDFViewer_scrollPageIntoView(pageNumber, scrollPageIntoView: function PDFViewer_scrollPageIntoView(pageNumber,
dest) { dest) {
var pageView = this.pages[pageNumber - 1]; var pageView = this.pages[pageNumber - 1];
var pageViewDiv = pageView.el;
if (this.presentationModeState === if (this.presentationModeState ===
PresentationModeState.FULLSCREEN) { PresentationModeState.FULLSCREEN) {
@ -412,7 +418,7 @@ var PDFViewer = (function pdfViewer() {
this._setScale(this.currentScaleValue, true); this._setScale(this.currentScaleValue, true);
} }
if (!dest) { if (!dest) {
scrollIntoView(pageViewDiv); scrollIntoView(pageView.div);
return; return;
} }
@ -475,7 +481,7 @@ var PDFViewer = (function pdfViewer() {
} }
if (scale === 'page-fit' && !dest[4]) { if (scale === 'page-fit' && !dest[4]) {
scrollIntoView(pageViewDiv); scrollIntoView(pageView.div);
return; return;
} }
@ -486,7 +492,7 @@ var PDFViewer = (function pdfViewer() {
var left = Math.min(boundingRect[0][0], boundingRect[1][0]); var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
var top = Math.min(boundingRect[0][1], boundingRect[1][1]); var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
scrollIntoView(pageViewDiv, { left: left, top: top }); scrollIntoView(pageView.div, { left: left, top: top });
}, },
_updateLocation: function (firstPage) { _updateLocation: function (firstPage) {

3
web/viewer.js

@ -16,7 +16,7 @@
*/ */
/* globals PDFJS, PDFBug, FirefoxCom, Stats, Cache, ProgressBar, /* globals PDFJS, PDFBug, FirefoxCom, Stats, Cache, ProgressBar,
DownloadManager, getFileName, scrollIntoView, getPDFFileNameFromURL, DownloadManager, getFileName, scrollIntoView, getPDFFileNameFromURL,
PDFHistory, Preferences, SidebarView, ViewHistory, PageView, PDFHistory, Preferences, SidebarView, ViewHistory,
PDFThumbnailViewer, URL, noContextMenuHandler, SecondaryToolbar, PDFThumbnailViewer, URL, noContextMenuHandler, SecondaryToolbar,
PasswordPrompt, PresentationMode, HandTool, Promise, PasswordPrompt, PresentationMode, HandTool, Promise,
DocumentProperties, DocumentOutlineView, DocumentAttachmentsView, DocumentProperties, DocumentOutlineView, DocumentAttachmentsView,
@ -1353,7 +1353,6 @@ var PDFViewerApplication = {
rotatePages: function pdfViewRotatePages(delta) { rotatePages: function pdfViewRotatePages(delta) {
var pageNumber = this.page; var pageNumber = this.page;
this.pageRotation = (this.pageRotation + 360 + delta) % 360; this.pageRotation = (this.pageRotation + 360 + delta) % 360;
this.pdfViewer.pagesRotation = this.pageRotation; this.pdfViewer.pagesRotation = this.pageRotation;
this.pdfThumbnailViewer.pagesRotation = this.pageRotation; this.pdfThumbnailViewer.pagesRotation = this.pageRotation;

Loading…
Cancel
Save