[WIP] Support animated PDF
AbandonedPublic

Authored by joaonetto on May 13 2019, 11:56 PM.

Details

Reviewers
aacid
Group Reviewers
Okular
Commits
R223:a3628c1f97e9: Revert "mend"
Summary

Implemented the unit tests and the functions needed for the JavaScript to work.

The buttons along with the animations are now working, but still have a grey field above them since I can only use them when I click "Show Forms". I'll tackle them next.

Test Plan

Diff Detail

Repository
R223 Okular
Branch
gsoc2019_animatedpdf
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 12319
Build 12337: arc lint + arc unit
joaonetto created this revision.May 13 2019, 11:56 PM
Restricted Application added a project: Okular. · View Herald TranscriptMay 13 2019, 11:56 PM
Restricted Application added a subscriber: okular-devel. · View Herald Transcript
joaonetto requested review of this revision.May 13 2019, 11:56 PM
joaonetto updated this revision to Diff 58043.May 14 2019, 12:05 AM

Fixed copyright

sander added a subscriber: sander.May 14 2019, 3:56 AM
sander added inline comments.
core/script/kjs_document.cpp
277 ↗(On Diff #58043)

Please use a range-based for loop.

joaonetto updated this revision to Diff 58077.May 14 2019, 1:32 PM

Changed for to range based loops

joaonetto edited the summary of this revision. (Show Details)May 14 2019, 1:36 PM
aacid added inline comments.May 15 2019, 10:06 PM
core/script/kjs_document.cpp
137 ↗(On Diff #58077)

you don't need this anymore?

joaonetto updated this revision to Diff 58154.May 15 2019, 10:19 PM
joaonetto edited the summary of this revision. (Show Details)

Removed useless iterator

sander added inline comments.May 16 2019, 4:53 AM
core/script/kjs_document.cpp
139 ↗(On Diff #58154)

As you were using const iterators before: Shouldn't this be qAsConst(doc->m_pagesVector) to avoid unnecessary detaching?

142 ↗(On Diff #58154)

Why not simply numFields += pIt->formFields() ?

anthonyfieroni added inline comments.
core/script/kjs_display.cpp
19 ↗(On Diff #58154)

use unique_ptr

35–38 ↗(On Diff #58154)
if (g_displayProto)
    return;
40 ↗(On Diff #58154)
g_displayProto.reset(new KJSPrototype);
pino added a subscriber: pino.May 16 2019, 6:27 AM
pino added inline comments.
core/script/kjs_document.cpp
275–286 ↗(On Diff #58154)

This convoluted for loop basically get the i-th element of a QLinkedList, which is not designed for index accessing (and that is why there is no at(int) method).
IMHO a better way is:

  • get the list of form fields
  • compare the wanted index with the count of the form fields: if it is out of boundaries, return KJSUndefined directly
  • otherwise, create an iterator fromthe begin, and increment it by the wanted index to get to the wanted element
joaonetto updated this revision to Diff 58162.May 16 2019, 11:41 AM
joaonetto marked 4 inline comments as done.

Loops now use const and more efficient way of acessing LinkedList

joaonetto added inline comments.May 16 2019, 11:42 AM
core/script/kjs_display.cpp
19 ↗(On Diff #58154)

Are we talking about the std::unique_ptr?

I followed the template in the other classes, why should we use unique_ptr?

35–38 ↗(On Diff #58154)

Then we get rid of the initialized bool?

40 ↗(On Diff #58154)

And this does not compile

core/script/kjs_document.cpp
275–286 ↗(On Diff #58154)

I still have to check for all the pages.

But my new implementation looks more like with what you described

core/script/kjs_display.cpp
35–38 ↗(On Diff #58154)

Yep, also unique_ptr will clear the allocated memory, if you run valgrind, it will point a leak which is not good.

joaonetto updated this revision to Diff 58163.May 16 2019, 11:47 AM

Remove unintentionally left qDebug()

joaonetto updated this revision to Diff 58165.May 16 2019, 12:00 PM
joaonetto marked 3 inline comments as done.

Declared g_displayProto as std::unique_ptr

sander added inline comments.May 16 2019, 12:50 PM
core/script/kjs_display.cpp
40 ↗(On Diff #58154)

g_displayProto needs to be a std::unique_ptr for this to compile.

aacid added a comment.May 16 2019, 8:55 PM

Do you have some files that exercise this?

Who would we autotest this?

Do you have some files that exercise this?

Who would we autotest this?

I intend to test this when all the functions needed to work are implemented.

Or would you like a test for every function?

aacid added a comment.May 21 2019, 9:23 PM

Do you have some files that exercise this?

Who would we autotest this?

I intend to test this when all the functions needed to work are implemented.

Or would you like a test for every function?

Having as much test coverage as possible is the best. If you think you need some more building blocks for this to be more easily autotestable, that's also a valid answer

joaonetto updated this revision to Diff 58487.May 22 2019, 5:09 PM

Implemented setInterval/clearInterval. WidgetScripts are now supported on pageOpening/Closing.

joaonetto retitled this revision from Added basic JavaScript functions to support animated PDF to [WIP] Support animated PDF.May 22 2019, 5:11 PM
joaonetto edited the summary of this revision. (Show Details)
joaonetto edited the test plan for this revision. (Show Details)
joaonetto updated this revision to Diff 58488.May 22 2019, 5:16 PM

Documentation and fixing spaces

joaonetto updated this revision to Diff 58984.Jun 1 2019, 2:59 PM

Updating revision to match the current branch

joaonetto edited the summary of this revision. (Show Details)Jun 1 2019, 3:02 PM
joaonetto edited the test plan for this revision. (Show Details)
aacid added a comment.Jun 2 2019, 9:25 PM

The diff shown here is wrong. We want the diff from your branch against master, not the last change in your branch against itself

joaonetto updated this revision to Diff 59045.Jun 3 2019, 1:01 AM
joaonetto edited the test plan for this revision. (Show Details)

Updated Diff to track changes based on master

joaonetto edited the summary of this revision. (Show Details)Jun 3 2019, 1:03 AM
joaonetto edited the test plan for this revision. (Show Details)
joaonetto updated this revision to Diff 59100.Jun 4 2019, 12:51 AM
joaonetto edited the summary of this revision. (Show Details)

Changed button code to be transparent when there's no text.

This revision was not accepted when it landed; it landed in state Needs Review.Jun 4 2019, 1:31 AM
Closed by commit R223:a3628c1f97e9: Revert "mend" (authored by joaonetto). · Explain Why
This revision was automatically updated to reflect the committed changes.
joaonetto reopened this revision.Jun 4 2019, 1:35 AM

Wasn't supposed to be closed. It closed with a wrong commit on my side branch.

joaonetto updated this revision to Diff 59102.Jun 4 2019, 1:38 AM

Updated with the code against master

joaonetto updated this revision to Diff 59257.Jun 6 2019, 12:56 PM

Implemented buttonGetIcon and buttonSetIcon

joaonetto abandoned this revision.Aug 27 2019, 10:28 PM

This was merged on invent.kde.org.