RTL: recent searches popover is displayed in incorrect location
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Apr 2017 20:52:15 +0000 (20:52 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Apr 2017 20:52:15 +0000 (20:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=171338
<rdar://problem/31377807>

Reviewed by Dean Jackson.

Source/WebCore:

Compute the absolute coordinates for the popup the same way we do for the select dropdown.

* rendering/RenderSearchField.cpp:
(WebCore::RenderSearchField::showPopup):

Source/WebKit/mac:

Add RTL support for the pop-under branch.

* WebCoreSupport/PopupMenuMac.mm:
(PopupMenuMac::show):

Source/WebKit2:

Add RTL support for the pop-under branch.

* UIProcess/mac/WebPopupMenuProxyMac.mm:
(WebKit::WebPopupMenuProxyMac::showPopupMenu):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215830 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderSearchField.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/PopupMenuMac.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm

index 775f47d..bb7446c 100644 (file)
@@ -1,3 +1,16 @@
+2017-04-26  Zalan Bujtas  <zalan@apple.com>
+
+        RTL: recent searches popover is displayed in incorrect location
+        https://bugs.webkit.org/show_bug.cgi?id=171338
+        <rdar://problem/31377807>
+
+        Reviewed by Dean Jackson.
+
+        Compute the absolute coordinates for the popup the same way we do for the select dropdown.
+
+        * rendering/RenderSearchField.cpp:
+        (WebCore::RenderSearchField::showPopup):
+
 2017-04-26  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         Restrict WebKit image formats to a known whitelist
index 052ba7f..e34c183 100644 (file)
@@ -134,7 +134,10 @@ void RenderSearchField::showPopup()
         m_searchPopup->saveRecentSearches(name, m_recentSearches);
     }
 
-    m_searchPopup->popupMenu()->show(snappedIntRect(absoluteBoundingBoxRect()), &view().frameView(), -1);
+    FloatPoint absTopLeft = localToAbsolute(FloatPoint(), UseTransforms);
+    IntRect absBounds = absoluteBoundingBoxRectIgnoringTransforms();
+    absBounds.setLocation(roundedIntPoint(absTopLeft));
+    m_searchPopup->popupMenu()->show(absBounds, &view().frameView(), -1);
 }
 
 void RenderSearchField::hidePopup()
index 5b22424..40577f3 100644 (file)
@@ -1,3 +1,16 @@
+2017-04-26  Zalan Bujtas  <zalan@apple.com>
+
+        RTL: recent searches popover is displayed in incorrect location
+        https://bugs.webkit.org/show_bug.cgi?id=171338
+        <rdar://problem/31377807>
+
+        Reviewed by Dean Jackson.
+
+        Add RTL support for the pop-under branch.
+
+        * WebCoreSupport/PopupMenuMac.mm:
+        (PopupMenuMac::show):
+
 2017-04-25  Brent Fulgham  <bfulgham@apple.com>
 
         Limit allowed size of document.title to avoid locking WebKit clients
index 56797b0..14c5f90 100644 (file)
@@ -173,13 +173,20 @@ void PopupMenuMac::show(const IntRect& r, FrameView* v, int index)
         if (textDirection == LTR)
             location = NSMakePoint(NSMinX(r) + popOverHorizontalAdjust, NSMaxY(r) - vertOffset);
         else
-            location = NSMakePoint(NSMinX(r) - popOverHorizontalAdjust, NSMaxY(r) - vertOffset);
+            location = NSMakePoint(NSMaxX(r) - popOverHorizontalAdjust, NSMaxY(r) - vertOffset);
 #else
         location = NSMakePoint(NSMinX(r) + popOverHorizontalAdjust, NSMaxY(r) - vertOffset);
 #endif
-    } else
-        location = NSMakePoint(NSMinX(r) + popUnderHorizontalAdjust, NSMaxY(r) + popUnderVerticalAdjust);    
-
+    } else {
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+        if (textDirection == LTR)
+            location = NSMakePoint(NSMinX(r) + popUnderHorizontalAdjust, NSMaxY(r) + popUnderVerticalAdjust);
+        else
+            location = NSMakePoint(NSMaxX(r) - popUnderHorizontalAdjust, NSMaxY(r) + popUnderVerticalAdjust);
+#else
+        location = NSMakePoint(NSMinX(r) + popUnderHorizontalAdjust, NSMaxY(r) + popUnderVerticalAdjust);
+#endif
+    }
     // Save the current event that triggered the popup, so we can clean up our event
     // state after the NSMenu goes away.
     Ref<Frame> frame(v->frame());
@@ -188,6 +195,7 @@ void PopupMenuMac::show(const IntRect& r, FrameView* v, int index)
     Ref<PopupMenuMac> protector(*this);
 
     RetainPtr<NSView> dummyView = adoptNS([[NSView alloc] initWithFrame:r]);
+    [dummyView.get() setUserInterfaceLayoutDirection:textDirection == LTR ? NSUserInterfaceLayoutDirectionLeftToRight : NSUserInterfaceLayoutDirectionRightToLeft];
     [view addSubview:dummyView.get()];
     location = [dummyView convertPoint:location fromView:view];
     
index 3476c71..6f17ed6 100644 (file)
@@ -1,3 +1,16 @@
+2017-04-26  Zalan Bujtas  <zalan@apple.com>
+
+        RTL: recent searches popover is displayed in incorrect location
+        https://bugs.webkit.org/show_bug.cgi?id=171338
+        <rdar://problem/31377807>
+
+        Reviewed by Dean Jackson.
+
+        Add RTL support for the pop-under branch.
+
+        * UIProcess/mac/WebPopupMenuProxyMac.mm:
+        (WebKit::WebPopupMenuProxyMac::showPopupMenu):
+
 2017-04-26  Antti Koivisto  <antti@apple.com>
 
         Enable expired-only reload policy on Mac and iOS
index d30194d..4f72df1 100644 (file)
@@ -138,9 +138,16 @@ void WebPopupMenuProxyMac::showPopupMenu(const IntRect& rect, TextDirection text
         location = NSMakePoint(NSMinX(rect) + popOverHorizontalAdjust, NSMaxY(rect) - verticalOffset);
 #endif
 
-    } else
-        location = NSMakePoint(NSMinX(rect) + popUnderHorizontalAdjust, NSMaxY(rect) + popUnderVerticalAdjust);  
-
+    } else {
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+        if (textDirection == LTR)
+            location = NSMakePoint(NSMinX(rect) + popUnderHorizontalAdjust, NSMaxY(rect) + popUnderVerticalAdjust);
+        else
+            location = NSMakePoint(NSMaxX(rect) - popUnderHorizontalAdjust, NSMaxY(rect) + popUnderVerticalAdjust);
+#else
+        location = NSMakePoint(NSMinX(rect) + popUnderHorizontalAdjust, NSMaxY(rect) + popUnderVerticalAdjust);
+#endif
+    }
     RetainPtr<NSView> dummyView = adoptNS([[NSView alloc] initWithFrame:rect]);
     [dummyView.get() setUserInterfaceLayoutDirection:textDirection == LTR ? NSUserInterfaceLayoutDirectionLeftToRight : NSUserInterfaceLayoutDirectionRightToLeft];
     [m_webView addSubview:dummyView.get()];