WebKit Bugzilla
Attachment 346434 Details for
Bug 188292
: PDFPlugin: Context menus in RTL are left-aligned
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188292-20180802172011.patch (text/plain), 5.91 KB, created by
Tim Horton
on 2018-08-02 17:20:11 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tim Horton
Created:
2018-08-02 17:20:11 PDT
Size:
5.91 KB
patch
obsolete
>Subversion Revision: 234504 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 6f895f39bb34f1553974dcb9d302043c25f8d919..48c15267e86311e86d753bada000f4b4bf539057 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,22 @@ >+2018-08-02 Tim Horton <timothy_horton@apple.com> >+ >+ PDFPlugin: Context menus in RTL are left-aligned >+ https://bugs.webkit.org/show_bug.cgi?id=188292 >+ <rdar://problem/32293787> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebProcess/Plugins/PDF/PDFLayerControllerSPI.h: >+ Add some SPI. >+ >+ * WebProcess/Plugins/PDF/PDFPlugin.mm: >+ (WebKit::PDFPlugin::handleContextMenuEvent): >+ Translate UI layout direction back into the platform enum, and pass it to PDFKit. >+ >+ * WebProcess/WebPage/WebPage.h: >+ (WebKit::WebPage::userInterfaceLayoutDirection const): >+ Add a getter for UI layout direction. >+ > 2018-08-02 Wenson Hsieh <wenson_hsieh@apple.com> > > [iOS] Keyboard becomes unresponsive after pressing delete while pressing down on a character key with accents >diff --git a/Source/WebKit/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h b/Source/WebKit/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h >index 8fafcf60b9681ab976dffd76c8145d0a9251ec4f..5bfc261e94b90686acadad9568f23cd981590f83 100644 >--- a/Source/WebKit/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h >+++ b/Source/WebKit/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h >@@ -101,6 +101,9 @@ typedef NS_ENUM(NSInteger, PDFLayerControllerCursorType) { > - (void)mouseEntered:(NSEvent *)event; > - (void)mouseExited:(NSEvent *)event; > >+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 >+- (NSMenu *)menuForEvent:(NSEvent *)event withUserInterfaceLayoutDirection:(NSUserInterfaceLayoutDirection)direction; >+#endif > - (NSMenu *)menuForEvent:(NSEvent *)event; > > - (NSArray *)findString:(NSString *)string caseSensitive:(BOOL)isCaseSensitive highlightMatches:(BOOL)shouldHighlightMatches; >diff --git a/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm b/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm >index 9f0d9484cdda0836b6ec309bfb58ea2b73f954c8..3c895bcb1c3f98956fce1b16b5a04a5a2fa68a71 100644 >--- a/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm >+++ b/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm >@@ -1588,34 +1588,41 @@ bool PDFPlugin::showContextMenuAtPoint(const IntPoint& point) > > bool PDFPlugin::handleContextMenuEvent(const WebMouseEvent& event) > { >+ if (!webFrame()->page()) >+ return false; >+ >+ WebPage* webPage = webFrame()->page(); > FrameView* frameView = webFrame()->coreFrame()->view(); > IntPoint point = frameView->contentsToScreen(IntRect(frameView->windowToContents(event.position()), IntSize())).location(); > >- if (NSMenu *nsMenu = [m_pdfLayerController menuForEvent:nsEventForWebMouseEvent(event)]) { >- Vector<PDFContextMenuItem> items; >- auto itemCount = [nsMenu numberOfItems]; >- for (int i = 0; i < itemCount; i++) { >- auto item = [nsMenu itemAtIndex:i]; >- if ([item submenu]) >- continue; >- PDFContextMenuItem menuItem { String([item title]), !![item isEnabled], !![item isSeparatorItem], static_cast<int>([item state]), [item action], i }; >- items.append(WTFMove(menuItem)); >- } >- PDFContextMenu contextMenu { point, WTFMove(items) }; >+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 >+ NSUserInterfaceLayoutDirection uiLayoutDirection = webPage->userInterfaceLayoutDirection() == UserInterfaceLayoutDirection::LTR ? NSUserInterfaceLayoutDirectionLeftToRight : NSUserInterfaceLayoutDirectionRightToLeft; >+ NSMenu *nsMenu = [m_pdfLayerController menuForEvent:nsEventForWebMouseEvent(event) withUserInterfaceLayoutDirection:uiLayoutDirection]; >+#else >+ NSMenu *nsMenu = [m_pdfLayerController menuForEvent:nsEventForWebMouseEvent(event)]; >+#endif > >- if (!webFrame()->page()) >- return false; >+ if (!nsMenu) >+ return false; >+ >+ Vector<PDFContextMenuItem> items; >+ auto itemCount = [nsMenu numberOfItems]; >+ for (int i = 0; i < itemCount; i++) { >+ auto item = [nsMenu itemAtIndex:i]; >+ if ([item submenu]) >+ continue; >+ PDFContextMenuItem menuItem { String([item title]), !![item isEnabled], !![item isSeparatorItem], static_cast<int>([item state]), [item action], i }; >+ items.append(WTFMove(menuItem)); >+ } >+ PDFContextMenu contextMenu { point, WTFMove(items) }; > >- std::optional<int> selectedIndex = -1; >- webFrame()->page()->sendSync(Messages::WebPageProxy::ShowPDFContextMenu(contextMenu), Messages::WebPageProxy::ShowPDFContextMenu::Reply(selectedIndex)); >+ std::optional<int> selectedIndex = -1; >+ webPage->sendSync(Messages::WebPageProxy::ShowPDFContextMenu(contextMenu), Messages::WebPageProxy::ShowPDFContextMenu::Reply(selectedIndex)); > >- if (selectedIndex && *selectedIndex >= 0 && *selectedIndex < itemCount) >- [nsMenu performActionForItemAtIndex:*selectedIndex]; >+ if (selectedIndex && *selectedIndex >= 0 && *selectedIndex < itemCount) >+ [nsMenu performActionForItemAtIndex:*selectedIndex]; > >- return true; >- } >- >- return false; >+ return true; > } > > bool PDFPlugin::handleKeyboardEvent(const WebKeyboardEvent& event) >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h >index 827ad6c37daefbf522b89327d929b44577e6510c..cbbc48cdd26b256728e70406998421b8f41dafb8 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.h >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h >@@ -1086,6 +1086,8 @@ public: > > UserContentControllerIdentifier userContentControllerIdentifier() const { return m_userContentController->identifier(); } > >+ WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() const { return m_userInterfaceLayoutDirection; } >+ > bool isSuspended() const { return m_isSuspended; } > > void didReceiveWebPageMessage(IPC::Connection&, IPC::Decoder&);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188292
: 346434