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

Replace direct lookup of uniquePrefix/idCounters, in Page instances, with an idFactory containing an createObjId method instead #7941

Merged
merged 1 commit into from
Jan 9, 2017

Conversation

Snuffleupagus
Copy link
Collaborator

We're currently making use of uniquePrefix/idCounters in multiple files, to create unique object id's, and adding a new occurrence of them requires some care to ensure that an object id isn't accidentally reused.
Furthermore, having to pass around multiple parameters as we currently do seem like something you want to avoid.

Instead, this patch adds a factory which means that there's only one thing that needs to be passed around. And since it's now only necessary to call a method in order to obtain a unique object id, the details are thus abstracted away at the call-sites which avoids accidental reuse of object id's.

To test that this works as expected a very simple Page unit-test is added, and the existing Annotation layer tests are also adjusted slightly.

…nces, with an `idFactory` containing an `createObjId` method instead

We're currently making use of `uniquePrefix`/`idCounters` in multiple files, to create unique object id's, and adding a new occurrence of them requires some care to ensure that an object id isn't accidentally reused.
Furthermore, having to pass around multiple parameters as we currently do seem like something you want to avoid.

Instead, this patch adds a factory which means that there's only *one* thing that needs to be passed around. And since it's now only necessary to call a method in order to obtain a unique object id, the details are thus abstracted away at the call-sites which avoids accidental reuse of object id's.

To test that this works as expected a very simple `Page` unit-test is added, and the existing `Annotation layer` tests are also adjusted slightly.
@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Jan 9, 2017

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/070cab652124211/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jan 9, 2017

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/070cab652124211/output.txt

Total script time: 2.26 mins

Published

@timvandermeij
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Jan 9, 2017

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/095a61149ce7407/output.txt

@timvandermeij
Copy link
Contributor

/botio-linux test

@pdfjsbot
Copy link

pdfjsbot commented Jan 9, 2017

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/6ae1ed09efab31a/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jan 9, 2017

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/095a61149ce7407/output.txt

Total script time: 25.66 mins

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

@pdfjsbot
Copy link

pdfjsbot commented Jan 9, 2017

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/6ae1ed09efab31a/output.txt

Total script time: 27.39 mins

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

@timvandermeij timvandermeij merged commit f828f07 into mozilla:master Jan 9, 2017
@timvandermeij
Copy link
Contributor

Nice work!

@Snuffleupagus Snuffleupagus deleted the Page-idFactory branch January 10, 2017 09:41
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
Replace direct lookup of `uniquePrefix`/`idCounters`, in `Page` instances, with an `idFactory` containing an `createObjId` method instead
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