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

Simplify B2G viewer #5947

Merged
merged 2 commits into from
Jun 30, 2015
Merged

Simplify B2G viewer #5947

merged 2 commits into from
Jun 30, 2015

Conversation

yurydelendik
Copy link
Contributor

... also extracts PDFLinkService and PDFHistory APIs

@Snuffleupagus
Copy link
Collaborator

The (standard) preview and the extension is still not working: ReferenceError: PDFLinkService is not defined; it appears that viewer.js is missing the line //#include pdf_link_service.js.

@timvandermeij
Copy link
Contributor

It seems like the locale stuff has been removed. Is that because of #3518? I think it would be nice if we could also use the localizations in the B2G viewer, but if that is out of scope for this refactoring we can also do that in a separate PR that addresses #3518.

document.getElementById('activityTitle').textContent = title;
},

get pagesCount() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that we have a link service here and this function (and the other two below this one) are also implemented there, can't we make use of the ones in the link service instead to avoid duplication?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is nice to have those functions on the PDFViewerApplication level as well.

@timvandermeij
Copy link
Contributor

This is a really nice refactoring! I think we can make the code in viewer.js even better by removing the B2G mentions now that we have extensions/b2g/viewer.js, but other than that and the nits above, this is looking really good. If the comments above are addressed, we should try running this on the actual device :)

container.addEventListener('pagesinit', function () {
// we can use pdfViewer now, e.g. let's change default scale.
pdfViewer.currentScaleValue = 'page-width';
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just asking: did you intend to change the initial zoom level from auto to page-width, or is it a result of copy-pasting from the simpleviewer component?

@Snuffleupagus
Copy link
Collaborator

I'd still like to think through the class dependencies, between e.g. PDFLinkService/PDFHistory, that these patches introduces a bit more; but so far the general structure of the code looks good!

One small request on my part though: Can we please try and land PR #5699 before this one? That one has been open for quite some time, and it's already been bit-rotten a couple of times. This patch would cause even more merge conflicts, so I'd really appreciate if it could go first :-)


This PR removes both Preferences and ViewHistory from the B2G viewer, but I think that's mostly fine!

  • Regarding Preferences: Considering first of all the simplicity of the B2G viewer, and secondly the lack of any (easy) way for users to change them, I cannot see that we're loosing any functionality by removing it.
  • Regarding ViewHistory: This is included in the current B2G viewer, and I've just confirmed that it does work on an actual devices (a Flame, running Firefox OS 3.0 with the latest Nightly). Though I'm not sure if remembering/restoring the last position is a very important function in the B2G viewer. Thoughts/Opinions?

this.pdfHistory.initialize(pdfDocument.fingerprint);
}.bind(this), function (error) {
// TODO handle and localize loading error?
console.error('PDF loading error: ' + error)
Copy link
Contributor

Choose a reason for hiding this comment

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

We're missing a semicolon here at the end (Travis also appears to be complaining about that).

@timvandermeij
Copy link
Contributor

@yurydelendik Now that #5971 has landed, could you rebase the PR so I can play with it more, also on an actual Flame?

@Snuffleupagus
Copy link
Collaborator

A quick visual glitch that I noticed in the UI:
The loading bar is now constantly visible in the B2G viewer, and since there's no longer any JavaScript code for it, it will never be filled.
Considering the way that the B2G viewer works, and how files are opened with it, do we actually need a loading bar?

@Snuffleupagus
Copy link
Collaborator

Also, is the errorWrapper div, see https://github.com/mozilla/pdf.js/pull/5947/files#diff-5dba6a2f9a0235d9e5b2b75ef5a6f774L66, necessary any more?

@timvandermeij
Copy link
Contributor

There appears to be a problem with the "zoom in" functionality. To reproduce, open http://107.21.233.14:8877/a5bae2087f5c8d3/extensions/b2g/content/web/viewer.html and click the Zoom In button (plus icon) in the bottom right. Notice the page not zooming in and notice that the following message is printed in the console:

"pdfViewSetScale: '0' is an unknown zoom value."

Zooming out zooms out to the minimal scale so it seems, which is also not correct, but after that zooming appears to work properly. Any idea what is causing this?

@yurydelendik yurydelendik force-pushed the b2g-viewer branch 2 times, most recently from e144bd5 to a801cf0 Compare June 5, 2015 15:40
@Snuffleupagus
Copy link
Collaborator

Question: How about instead using https://github.com/gaia-components/gaia-progress, similar to the other gaia-components used in the B2G viewer, for the loading bar?
This way we'd have a more "native" look, and less JS/CSS code in the B2G viewer.


var DEFAULT_SCALE_DELTA = 1.1;
var MIN_SCALE = 0.25;
var MAX_SCALE = 10.0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it make sense to move these constants into ui_utils.js instead (i.e. move them from web/viewer.js), to reduce duplication?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I'm expecting those to be different for B2G.

@yurydelendik
Copy link
Contributor Author

How about instead using https://github.com/gaia-components/gaia-progress, similar to the other gaia-components used in the B2G viewer, for the loading bar?

Maybe. But at the moment I want to split viewer.js from B2G code. Supporting Firefox OS things shall fall on the shoulders of the professionals :) See also bug 1171998

@timvandermeij
Copy link
Contributor

These commits still have the errorWrapper that @Snuffleupagus reported earlier. I have also found some accompanying CSS at https://github.com/yurydelendik/pdf.js/blob/fff086645b7a3fa5daeefe6e44f9ac5b5ab5abad/extensions/b2g/viewer.css#L215-L241. I also think that we do not need it on B2G. @yurydelendik What do you think?

On desktop I also notice that in the new preview the Gaia header is somewhat broken. It had a white background with black text and a 'x' sign, but now it is a gray background with white text and without the 'x' sign. I'm not yet sure what broke this though (probably we are not getting here: yurydelendik@fff0866#diff-af61da45d81c12dd8e6859e95eba2cc4R358). I have also not had time to test this on an actual Flame because I'm busy until the June 12th. I will do those tests after that time though.

@yurydelendik
Copy link
Contributor Author

These commits still have the errorWrapper that @Snuffleupagus reported earlier.

I decided to keep them in case if PDF file will be corrupted. Therefore I added proper error handling.

@yurydelendik
Copy link
Contributor Author

On desktop I also notice that in the new preview the Gaia header is somewhat broken.

It will be. The gaia project keep changing/reorganizing UI dependencies and l10n support. That's why we need to phase out the support of this viewer in this repo.

@timvandermeij
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/e4fdc7bfa4fb412/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/f207f3bbe4aa073/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/f207f3bbe4aa073/output.txt

Total script time: 18.11 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/e4fdc7bfa4fb412/output.txt

Total script time: 18.22 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

<!-- <link rel="stylesheet" type="text/css" href="/shared/elements/gaia-icons/style.css" /> -->
<script type="text/javascript" src="/shared/elements/config.js"></script>
<script type="text/javascript" src="/shared/elements/gaia-header/dist/script.js"></script>
<link rel="stylesheet" type="text/css" href="/shared/elements/gaia-theme/gaia-theme.css" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove / at the end: end it with gaia-theme.css">

pdfViewer: null,
pdfHistory: null,
pdfLinkService: null,
loading: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: this line is unused and can be removed (#6140).

@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/397d75075264a93/output.txt

@timvandermeij
Copy link
Contributor

/botio lint

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/d91f0eb88f9f40d/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/70f3339a1385d0b/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/70f3339a1385d0b/output.txt

Total script time: 0.77 mins

  • Lint: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/d91f0eb88f9f40d/output.txt

Total script time: 1.04 mins

  • Lint: Passed

timvandermeij added a commit that referenced this pull request Jun 30, 2015
@timvandermeij timvandermeij merged commit 0a744fb into mozilla:master Jun 30, 2015
@timvandermeij
Copy link
Contributor

Great 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