Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the thumbnail code #5673

Merged
merged 7 commits into from
Jan 26, 2015
Merged

Refactor the thumbnail code #5673

merged 7 commits into from
Jan 26, 2015

Conversation

Snuffleupagus
Copy link
Collaborator

This PR rewrites part of the thumbnail code to achieve the following goals:

  • Change the ThumbnailView implementation to be class-like.
  • Refactor the ThumbnailView code to be more in-line with the corresponding Page code. (Even though the Page code has evolved quite a bit, the Thumbnail code hasn't usually followed suite.)
  • Remove some dead code, and add a few memory related optimizations when discarding canvases.

To actually make it feasible to review this, I've divided the PR into multiple patches. The commit messages should hopefully be clear enough to explain what is going on. Also, for some of the larger patches, using the ?w=1 URL flag should help.

I've made sure that at every point in the patch series, the code actually works. However, before landing this, I'm assuming that we might want to merge a few of the (smaller) commits together. But in order to make it somewhat easier to deal with any (hopefully non-existent) regressions, landing this as one big patch is probably not the best idea.

@timvandermeij
Copy link
Contributor

Review progress:

  • Move PDFThumbnailViewer to its own file
  • Fix function names in PDFThumbnailViewer
  • Rename the thumbnail_view.js file
  • Rename ThumbnailView to PDFThumbnailView and refactor it to be more class-like
  • Refactor PDFThumbnailView to look more similar to PDFPageView
  • Enable cancelling of thumbnail drawing
  • Remove dead code from PDFThumbnailView

/**
* @typedef {Object} PDFThumbnailViewOptions
* @property {HTMLDivElement} container - The viewer element.
* @property {number} id - The thumbnail unique ID (normally its number).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The thumbnail_'s_ unique ID

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

This includes an optimization to zero the height and width of existing thumbnail canvases, when they are removed and recreated during rotation of the document. (Credit goes to nnethercote, who initially found this in PR 4920.)
This is useful if thumbnails are being rendered when the document is rotated, since it let us abort the current rendering.
@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/2c4a232f9f32c32/output.txt

@yurydelendik
Copy link
Contributor

file and symbols dependencies look good

timvandermeij added a commit that referenced this pull request Jan 26, 2015
@timvandermeij timvandermeij merged commit a544aed into mozilla:master Jan 26, 2015
@timvandermeij
Copy link
Contributor

Awesome work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants