Title: [234530] trunk/Source/WebKit
- Revision
- 234530
- Author
- [email protected]
- Date
- 2018-08-02 18:11:46 -0700 (Thu, 02 Aug 2018)
Log Message
PDFPlugin: Context menus in RTL are left-aligned
https://bugs.webkit.org/show_bug.cgi?id=188292
<rdar://problem/32293787>
Reviewed by Simon Fraser.
* 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.
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (234529 => 234530)
--- trunk/Source/WebKit/ChangeLog 2018-08-03 00:24:13 UTC (rev 234529)
+++ trunk/Source/WebKit/ChangeLog 2018-08-03 01:11:46 UTC (rev 234530)
@@ -1,3 +1,22 @@
+2018-08-02 Tim Horton <[email protected]>
+
+ PDFPlugin: Context menus in RTL are left-aligned
+ https://bugs.webkit.org/show_bug.cgi?id=188292
+ <rdar://problem/32293787>
+
+ Reviewed by Simon Fraser.
+
+ * 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 Chris Dumez <[email protected]>
Regression(r234486): assertion hit in ~CallbackAggregator()
Modified: trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h (234529 => 234530)
--- trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h 2018-08-03 00:24:13 UTC (rev 234529)
+++ trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h 2018-08-03 01:11:46 UTC (rev 234530)
@@ -101,6 +101,9 @@
- (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;
Modified: trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm (234529 => 234530)
--- trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm 2018-08-03 00:24:13 UTC (rev 234529)
+++ trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm 2018-08-03 01:11:46 UTC (rev 234530)
@@ -1588,34 +1588,41 @@
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)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (234529 => 234530)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2018-08-03 00:24:13 UTC (rev 234529)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2018-08-03 01:11:46 UTC (rev 234530)
@@ -1086,6 +1086,8 @@
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&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes