[PATCH 1/4] Add JavaScript Event Object handling
ClosedPublic

Authored by aheinecke on Jan 24 2018, 12:23 PM.

Details

Summary

This adds a new data object "Event" that can be used
to carry information in and out of JavaScript execution
contexts. The Event Object is defined in the Adobe JavaScript
scripting reference.

The implementation now adds handling for the FieldCalculate
Event. It should be extensible enough so that in the future
more events could be supported.

Diff Detail

Repository
R223 Okular
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
aacid added a subscriber: aacid.Feb 7 2018, 11:16 PM
aacid added inline comments.
core/script/kjs_field.cpp
222 ↗(On Diff #25874)

You really want ot use the verison with the page so refreshPixmaps happens

aheinecke updated this revision to Diff 26760.Feb 8 2018, 1:44 PM
aheinecke marked an inline comment as done.

Carried the source / target page through to have it available when the kjs_fields are created.

aheinecke added inline comments.Feb 8 2018, 1:45 PM
core/script/kjs_field.cpp
222 ↗(On Diff #25874)

Indeed I want that now. :-)

This required an ugly const cast though as the kjs_field API works with a non const Page pointer. Maybe that could / should be changed?

aacid added inline comments.Feb 9 2018, 11:52 PM
core/script/kjs_field.cpp
222 ↗(On Diff #25874)

Or just don't store the page as const pointer?

aheinecke added inline comments.Feb 15 2018, 2:29 PM
core/script/kjs_field.cpp
222 ↗(On Diff #25874)

I passed it as const as I only saw API in document to get a const page reference and recalculateForms also used a const reference.
But yes I see now that document private can easily access a non const page reference thorugh the page vector.

I'll change it.

aheinecke updated this revision to Diff 27264.Feb 15 2018, 2:37 PM

Use non const page refs for source and target page.

aacid added inline comments.Feb 19 2018, 11:40 PM
core/script/kjs_field.cpp
217 ↗(On Diff #27264)

Why the new if?

aheinecke added inline comments.Feb 20 2018, 12:38 PM
core/script/kjs_field.cpp
217 ↗(On Diff #27264)

It is not assured in kjs_event.cpp eventGetSource and eventGetTarget that the targetPage / sourcePage is not null. This depends a how the event object is set up.

Although I think that sourcePage "should" be set when source is set and targetPage should be set if target is set there is no guarantee for this and so I think a check here is warranted.

aacid added inline comments.Feb 20 2018, 11:06 PM
core/script/kjs_field.cpp
217 ↗(On Diff #27264)

No, no check is warranted, if page is null is because the code is wrong and it should crash so we can fix it not silently do nothing.

aheinecke updated this revision to Diff 27658.Feb 21 2018, 7:55 AM

Removed check for page in field wrapping.

aacid accepted this revision.Feb 21 2018, 11:18 PM
This revision is now accepted and ready to land.Feb 21 2018, 11:18 PM
This revision was automatically updated to reflect the committed changes.