Skip to content

[feat] Improve speed to calculate page breaks#17

Open
lpagliari wants to merge 1 commit into1971-feat-paginationfrom
1971-feat-new_calculation
Open

[feat] Improve speed to calculate page breaks#17
lpagliari wants to merge 1 commit into1971-feat-paginationfrom
1971-feat-new_calculation

Conversation

@lpagliari
Copy link

@lpagliari lpagliari commented Sep 2, 2019

Don't clone lines on each pagination cycle; instead, use their line sized (provided by https://github.com/storytouch/ep_script_line_size/pull/1) to calculate page breaks on the fly. This allows us to remove a lot of code related to "cloned lines", "helper lines", etc.

Also:

  • optimize repagination: stop paginating when pagination cycle reaches a point where the existing page break is on the same spot of the calculated page break;
  • use Set (instead of an object) to store lines changed on paginationLinesChanged
  • create helper methods for tests:
    • waitToHaveAnyPageBreak
    • waitToHaveAnySplitPageBreak
    • waitToHaveAnyNonSplitPageBreak
    • waitToHaveNNonSplitPageBreaks
    • waitToHaveNSplitPageBreaks
  • un-pend tests and fix them so they can validate pagination again:
    • basicPagination.js: adjusted and all tests passing
    • calculatingPageNumber.js: adjusted and all tests passing
    • elementBlocks.js: not adjusted
    • enablePagination.js: adjusted and all tests passing
    • lineNumberHeight.js (should we remove this suite? We don't allow users to show line numbers anymore...): not adjusted
    • otherMoreContd.js: not adjusted
    • repaginate.js: adjusted, but with tests failing
    • scroll.js: not adjusted
    • splitElements.js: adjusted, but with tests failing
  • optimize tests: don't create a new pad for each test, use the same one and clean pad content before starting each test. This can be even more efficient if we use UNDO instead of cleaning the pad, but to do that we need to change the tests in a lot of places, so this is not done on this commit;
  • mark failing tests with // FIXME;

Implement part of https://trello.com/c/dJp83kE0/1971.

Full list of PRs of this feature:

Don't clone lines on each pagination cycle; instead, use their line
sized (provided by ep_script_line_size) to calculate page breaks on the
fly. This allows us to remove a lot of code related to "cloned lines",
"helper lines", etc.

Also:

- optimize repagination: stop paginating when pagination cycle reaches a
point where the existing page break is on the same spot of the
calculated page break;
- use Set (instead of an object) to store lines changed on
`paginationLinesChanged`
- create helper methods for tests:
  - waitToHaveAnyPageBreak
  - waitToHaveAnySplitPageBreak
  - waitToHaveAnyNonSplitPageBreak
  - waitToHaveNNonSplitPageBreaks
  - waitToHaveNSplitPageBreaks
- un-pend tests and fix them so they can validate pagination again:
  - [x] basicPagination.js: adjusted and all tests passing
  - [x] calculatingPageNumber.js: adjusted and all tests passing
  - [ ] elementBlocks.js: not adjusted
  - [x] enablePagination.js: adjusted and all tests passing
  - [-] lineNumberHeight.js (should we remove this suite? We don't allow
        users to show line numbers anymore...)
  - [ ] otherMoreContd.js: not adjusted
  - [ ] repaginate.js: adjusted, but with tests failing
  - [ ] scroll.js: not adjusted
  - [ ] splitElements.js: adjusted, but with tests failing
- optimize tests: don't create a new pad for each test, use the same one
and clean pad content before starting each test. This can be even more
efficient if we use UNDO instead of cleaning the pad, but to do that we
need to change the tests in a lot of places, so this is not done on this
commit;
- mark failing tests with `// FIXME`;

Implement part of https://trello.com/c/dJp83kE0/1971.
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.

2 participants