[webkit-changes] [WebKit/WebKit] 799678: [UnifiedPDF] Context menu should have "Next Page" ...

Sammy Gill noreply at github.com
Thu Feb 15 09:24:11 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 799678c6dd8cd120146f7acb293ba006761b569d
      https://github.com/WebKit/WebKit/commit/799678c6dd8cd120146f7acb293ba006761b569d
  Author: Sammy Gill <sammy.gill at apple.com>
  Date:   2024-02-15 (Thu, 15 Feb 2024)

  Changed paths:
    M Source/WebCore/platform/LocalizedStrings.cpp
    M Source/WebCore/platform/LocalizedStrings.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm

  Log Message:
  -----------
  [UnifiedPDF] Context menu should have "Next Page" and "Previous Page" navigation options.
https://bugs.webkit.org/show_bug.cgi?id=269347
rdar://122931085

Reviewed by Tim Horton.

Adds the next and previous page items to the context menu. The "Next
Page," option is only able to be selected if the current page that is
in the view is not the last page. Likewise, the "Previous Page," option
is only selectable if the current page is not the first page. Regardless
both of the options are shown but are disabled in those scenarios.

In order to determine which page we are on we take the very center of
the view and see which page that point is contained in. This code
currently works only for single page display modes so a follow up will
be needed to get it working for two page display modes.

For scrolling between the pages we take the layout bounds, convert them
to the contents space, subtract out the page margins, and then
perform a scroll without animation to that point. Modified
scrollToPointInPage to use this new helper function that subtracts out
the page margins instead of the document margins like it was before and
which I don't think was correct.

Also rearranged the context menu slightly so that the ordering of the
items matches the current order displayed with the legacy plugin.

* Source/WebCore/platform/LocalizedStrings.cpp:
(WebCore::contextMenuItemPDFActualSize):
(WebCore::contextMenuItemPDFAutoSize):
* Source/WebCore/platform/LocalizedStrings.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::indexForCurrentPageInView const):
(WebKit::UnifiedPDFPlugin::convertFromPageToContents const):
(WebKit::UnifiedPDFPlugin::convertFromDocumentToContents const):
(WebKit::UnifiedPDFPlugin::offsetContentsSpacePointByPageMargins const):
(WebKit::UnifiedPDFPlugin::scrollToPointInPage):
(WebKit::UnifiedPDFPlugin::scrollToPage):
(WebKit::UnifiedPDFPlugin::toContextMenuItemTag const):
(WebKit::UnifiedPDFPlugin::createContextMenu const):
(WebKit::UnifiedPDFPlugin::titleForContextMenuItemTag const):
(WebKit::UnifiedPDFPlugin::contextMenuItem const):
(WebKit::UnifiedPDFPlugin::navigationContextMenuItems const):
(WebKit::UnifiedPDFPlugin::performContextMenuAction):

Canonical link: https://commits.webkit.org/274737@main




More information about the webkit-changes mailing list