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

Dispatch a sidebarviewchanged event in PDFSidebar when the view changes #7190

Merged
merged 2 commits into from
Apr 16, 2016
Merged

Dispatch a sidebarviewchanged event in PDFSidebar when the view changes #7190

merged 2 commits into from
Apr 16, 2016

Conversation

Snuffleupagus
Copy link
Collaborator

We cannot piggy-back on the updateviewarea event in order to update the stored sidebar state, since there're a number of cases where opening/switching the sidebar view won't fire a updateviewarea event.
Note that updateviewarea only fires when the position changes in the viewer, which means that it won't fire if e.g. the viewer is narrow, such that the sidebar overlays the document transparently; or when switching views, without the document position also changing.

This patch also moves the handling of forceOpen parameter in PDFSidebar_switchView, to prevent triggering back-to-back rendering and dispatching of events.

/cc @timvandermeij This ought to take care of the issues you pointed out in #7010.
I should probably just have added the event in #7038, but since there wasn't any consumer of it back then, it simply slipped my mind.

// Only update the storage when the document has been loaded *and* rendered.
return;
}
// store.initializedPromise.then(function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this code commented?

@Snuffleupagus
Copy link
Collaborator Author

There are parts of this PR, e.g. the writing to storage, that probably shouldn't land unless we also add support for getting/utilizing the sidebarView at the same time. Hence why I left some code commented out, since I didn't want to add unused code.

@timvandermeij One option could be that I append the commit from PR #7010 here, so that it can land all at once? I'm not sure if that makes testing more difficult though, so what do you think?

@@ -90,9 +90,6 @@ var PDFSidebar = (function PDFSidebarClosure() {
reset: function PDFSidebar_reset() {
this.isInitialViewSet = false;

this.close();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why were these lines removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, this is probably not entirely relevant to this PR, and it concerns an edge-case anyway.

When looking through the code in PDFSidebar, it struck me that forcibly closing the sidebar during PDFViewerApplication.close() may not be what the user expects. This really only matters in default viewer, when the "Open" functionality is present.

If you feel that we shouldn't change this at all, or that it doesn't belong in this PR (which I'd totally understand!), I'll re-add these two lines!

@timvandermeij
Copy link
Contributor

timvandermeij commented Apr 14, 2016

I think appending the commit (with the right author information) here should be fine. I think testing actually becomes easier because it allows me to test both patches at once, also since the other commit now depends on this patch.

Snuffleupagus and others added 2 commits April 16, 2016 10:10
…hanges

We cannot piggy-back on the `updateviewarea` event in order to update the stored sidebar state, since there're a number of cases where opening/switching the sidebar view won't fire a `updateviewarea` event.
Note that `updateviewarea` only fires when the position changes in the *viewer*, which means that it won't fire if e.g. the viewer is narrow, such that the sidebar overlays the document transparently; or when switching views, without the document position also changing.

This patch also moves the handling of `forceOpen` parameter in `PDFSidebar_switchView`, to prevent triggering back-to-back rendering and dispatching of events.
Persist the state of content sidebar while browsing away from viewer and
initializing the same on returning back to the viewer. The state is saved
in persistent store preferences and used upon viewer initialization.

Fixes #6935
@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/103f39b80368170/output.txt

@timvandermeij timvandermeij merged commit ff65c80 into mozilla:master Apr 16, 2016
@timvandermeij
Copy link
Contributor

Thank you!

@Snuffleupagus Snuffleupagus deleted the sidebarviewchanged-event branch April 16, 2016 13:52
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.

4 participants