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

Added more preferences for the available hash parameters. #4851

Merged
merged 1 commit into from
Jun 2, 2014

Conversation

Eyesonly88
Copy link

No description provided.

@@ -1727,7 +1741,7 @@ function webViewerInitialized() {
}

if ('useOnlyCssZoom' in hashParams) {
USE_ONLY_CSS_ZOOM = (hashParams['useOnlyCssZoom'] === 'true');
PDFJS.useCssZoom = (hashParams['useOnlyCssZoom'] === 'true');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given that the hash parameter is called useOnlyCssZoom, it seems a bit strange, and inconsistent, that the preference is then called useCssZoom.
If I understand correctly, the reason for the name useOnlyCssZoom would be that we use CSS zooming before re-rendering. But with the parameter set, we don't re-render and instead use only CSS zooming, hence the name.

Copy link
Contributor

Choose a reason for hiding this comment

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

I named it this way in #4792 :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see; but I don't really agree with that name ;-)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, do we actually need to introduce this property on PDFJS (given that it's only used in the viewer)?
If we keep this change, this needs to be changed as well: https://github.com/mozilla/pdf.js/blob/master/web/viewer.js#L46, otherwise we break the B2G viewer.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Snuffleupagus do we need to rename useOnlyCssZoom ?

Copy link
Author

Choose a reason for hiding this comment

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

Ok yep. I wasn't sure what B2G was. I will do the change.
I agree with you @Snuffleupagus that it is inconsistent. I have also noticed that enabledWebgl is also inconsistent because the hash param is actually just webgl ...

@yurydelendik
Copy link
Contributor

FIxes #4792

@yurydelendik
Copy link
Contributor

Could you add useCssZoom at https://github.com/mozilla/pdf.js/blob/master/src/display/api.js ? Also change line viewer.js at L45.

@Eyesonly88
Copy link
Author

Yep, ill do the above changes, just confirming if I should rename useCssZoom to useOnlyCssZoom or not?

@yurydelendik
Copy link
Contributor

I don't think it matters much, but let's rename hash parameter to useCssZoom.

@Eyesonly88
Copy link
Author

I think from @Snuffleupagus comment above it actually makes sense to me to call useOnlyCssZoom rather than useCssZoom. For a beginner like myself, I was able to know what css zooming did when i enabled it in my testing. I noticed that it stayed blurry after zooming in and realized that the code was not re-rendering. So I think the name helped me a bit to understand what's going on.

@@ -228,6 +227,21 @@ var PDFView = {
}, function rejected(reason) {}),
Preferences.get('sidebarViewOnLoad').then(function resolved(value) {
self.preferenceSidebarViewOnLoad = value;
}, function rejected(reason) {}),
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's move all .then(function resolved(value) { self.preferenceSidebarViewOnLoad = value; }, function rejected(reason) {}) after Promise.all(...)

Copy link
Author

Choose a reason for hiding this comment

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

You mean just move the sidebarViewOnLoad to be after the Promise.all call. Something like this?

var initializedPromise = Promise.all([
      Preferences.get('enableWebGL').then(function resolved(value) {
        PDFJS.disableWebGL = !value;
      }, function rejected(reason) {}),
      ......
      ......
      .....
      // TODO move more preferences and other async stuff here
    ]).Preferences.get('sidebarViewOnLoad').then(function resolved(value) {
        self.preferenceSidebarViewOnLoad = value;
    }, function rejected(reason) {});

I was also wondering if there is a way to specify the rejected fn for all the promises inside the Promise.all([...]) call rather than specifying it for each promise?

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry, I meant only reject part (too many then's):

var initializedPromise = Promise.all([
    Preferences.get('enableWebGL').then(function resolved(value) {
        PDFJS.disableWebGL = !value;
    }),
    Preferences.get('sidebarViewOnLoad').then(function resolved(value) {
        self.preferenceSidebarViewOnLoad = value;
    }),
   ....
]).catch(function (reason) { });

Copy link
Author

Choose a reason for hiding this comment

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

Yep that's what i was wondering about, thanks! Will do that change now.

@yurydelendik
Copy link
Contributor

okay, let's use useOnlyCssZoom

* @var {boolean}
*/
PDFJS.useOnlyCssZoom = (PDFJS.useOnlyCssZoom === undefined ?
false : PDFJS.useOnlyCssZoom);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: add two more spaces to the indentation.

@Snuffleupagus
Copy link
Collaborator

Unfortunately this will still not work in B2G, since the preference values will override the values set here: https://github.com/orionhealth/pdf.js/blob/4792-addprefhashparam/web/viewer.js#L44-L47.
The best way to fix this would be to add preprocessor tags to default_preferences.js, e.g. like this:

  var DEFAULT_PREFERENCES = {
    showPreviousViewOnLoad: true,
    defaultZoomValue: '',
    sidebarViewOnLoad: 0,
    enableHandToolOnLoad: false,
    enableWebGL: false,
    disableRange: false,
    disableAutoFetch: false,
    disableFontFace: false,
//#if B2G
//  disableTextLayer: true,
//  useOnlyCssZoom: true
//#else
    disableTextLayer: false
    useOnlyCssZoom: false
//#endif
  };

Edit: Once you have addressed the comments, please squash the commits. See https://github.com/mozilla/pdf.js/wiki/Squashing-Commits.

// TODO move more preferences and other async stuff here
]);
], function (reason) {});
Copy link
Collaborator

Choose a reason for hiding this comment

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

According to #4851 (comment), this should be:

]).catch(function (reason) {});

Copy link
Author

Choose a reason for hiding this comment

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

Yep, i will do the changes in the above comments and squash the commits.

@yurydelendik
Copy link
Contributor

/botio-windows preview

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

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

disableAutoFetch: false,
disableFontFace: false,
//#if B2G
// disableTextLayer: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: unindent by two space -- preprocessor replaces '//' with spaces. the same below

Copy link
Author

Choose a reason for hiding this comment

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

@yurydelendik Ok yep, will do that. To me it read better having them indented but ye I don't mind.
So this is how you reckon it should be?

//#if B2G
//disableTextLayer: true,
//useOnlyCssZoom: true
//#else
  disableTextLayer: false,
  useOnlyCssZoom: false
//#endif

Copy link
Contributor

Choose a reason for hiding this comment

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

yep

Copy link
Contributor

Choose a reason for hiding this comment

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

see line 318 at the generated code at http://107.22.172.223:8877/c0f700a3afeed34/web/viewer.js

@yurydelendik
Copy link
Contributor

Looks good with comment above addressed.

@timvandermeij
Copy link
Contributor

@Eyesonly88 Could you squash the commits again?

@Eyesonly88
Copy link
Author

yep ok, will do that now.

@timvandermeij
Copy link
Contributor

@yurydelendik Could you check/merge this?

@yurydelendik
Copy link
Contributor

Looks good. Thanks you for the patch

yurydelendik added a commit that referenced this pull request Jun 2, 2014
Added more preferences for the available hash parameters.
@yurydelendik yurydelendik merged commit c7c1639 into mozilla:master Jun 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants