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

Convert the Catalog class, in src/core/obj.js, to ES6 syntax #9990

Merged
merged 2 commits into from
Aug 25, 2018

Conversation

timvandermeij
Copy link
Contributor

@timvandermeij timvandermeij commented Aug 19, 2018

This patch is much easier to review with the ?w=1 flag: https://github.com/mozilla/pdf.js/pull/9990/files?w=1.

@Snuffleupagus Would you, time permitting of course, be willing to review this?

@timvandermeij
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.215.176.217:8877/ec727e4dc3438ec/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/136a7ca6bc078c0/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/ec727e4dc3438ec/output.txt

Total script time: 30.58 mins

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

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/136a7ca6bc078c0/output.txt

Total script time: 35.92 mins

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

src/core/obj.js Outdated
throw e;
}
info('Skipping invalid metadata.');
const stream = this.xref.fetch(streamRef, !encryptMetadata);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You're obviously just touching old code here, but this looks a bit convoluted. How about, in a separate commit, updating this to be a bit easier to read?

const suppressEncryption = !(this.xref.encrypt &&
                             this.xref.encrypt.encryptMetadata);
const stream = this.xref.fetch(streamRef, suppressEncryption);

src/core/obj.js Outdated
var prefix = '';
const pageLabels = new Array(this.numPages);
let style = null;
let prefix = '';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: These can probably just go on one line instead, i.e. let style = null, prefix = ''; (since that's how e.g. currentLabel/currentIndex below is already formatted in the old code).

src/core/obj.js Outdated
return total;
}
const count = args[0];
const parentRef = args[1];
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should be able to use array destructuring instead, i.e. const [count, parentRef] = args;.

src/core/obj.js Outdated
// Attempt to recover valid URLs from 'JS' entries with certain
// white-listed formats, e.g.
// Attempt to recover valid URLs from `JS` entries with certain
// white-listed formats, e.g.:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: It might be a personal preference, but I find that a colon after a period looks really ugly; can we please not do that :-)

src/core/obj.js Outdated
get attachments() {
let attachments = null, nameTreeRef;
const obj = this.catDict.get('Names');
if (obj) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is another potential for clean-up (again in a separate commit).
It looks like this code was basically copy-pasted from an older version of the destinations getter, but it could probably be changed to e.g.

 get attachments() {
   const obj = this.catDict.get('Names');
   let attachments = null;

   if (obj && obj.has('EmbeddedFiles')) {
     const nameTree = new NameTree(obj.getRaw('EmbeddedFiles'), this.xref);
     const names = nameTree.getAll();
     for (let name in names) {
       const fs = new FileSpec(names[name], this.xref);
       if (!attachments) {
         attachments = Object.create(null);
       }
       attachments[stringToPDFString(name)] = fs.serializable;
     }
   }
   return shadow(this, 'attachments', attachments);
}

@timvandermeij
Copy link
Contributor Author

/botio-windows test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.215.176.217:8877/c46e060530532dc/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.215.176.217:8877/c46e060530532dc/output.txt

Total script time: 24.44 mins

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

Image differences available at: http://54.215.176.217:8877/c46e060530532dc/reftest-analyzer.html#web=eq.log

@timvandermeij timvandermeij merged commit 7b7cd6d into mozilla:master Aug 25, 2018
@timvandermeij timvandermeij deleted the catalog branch August 25, 2018 15:11
@timvandermeij
Copy link
Contributor Author

Thank you for the review, @Snuffleupagus! The failure above is an intermittent one.

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.

3 participants