Bug 821283, anchor for popup should be flipped for horizontal centred positions, as this was causing the arrow on the arrow panel to appear reversed in rtl, r=neil
authorNeil Deakin <neil@mozilla.com>
Tue, 18 Dec 2012 12:08:08 -0500
changeset 125520 72ccbd7bc1087c9b9cb9e91210bd5cb8a0c0128b
parent 125519 cd66c58db0f77ee1585ef53bec3ac03710e53fb4
child 125521 d2ee611a3e2362105784134ce1a6704ade3fc5ea
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersneil
bugs821283
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 821283, anchor for popup should be flipped for horizontal centred positions, as this was causing the arrow on the arrow panel to appear reversed in rtl, r=neil
layout/xul/base/src/nsMenuPopupFrame.cpp
layout/xul/base/src/nsMenuPopupFrame.h
--- a/layout/xul/base/src/nsMenuPopupFrame.cpp
+++ b/layout/xul/base/src/nsMenuPopupFrame.cpp
@@ -874,18 +874,18 @@ nsMenuPopupFrame::GetRootViewForPopup(ns
 nsPoint
 nsMenuPopupFrame::AdjustPositionForAnchorAlign(nsRect& anchorRect,
                                                FlipStyle& aHFlip, FlipStyle& aVFlip)
 {
   // flip the anchor and alignment for right-to-left
   int8_t popupAnchor(mPopupAnchor);
   int8_t popupAlign(mPopupAlignment);
   if (IsDirectionRTL()) {
-    // no need to flip the centered anchor types
-    if (popupAnchor < POPUPALIGNMENT_LEFTCENTER) {
+    // no need to flip the centered anchor types vertically
+    if (popupAnchor <= POPUPALIGNMENT_LEFTCENTER) {
       popupAnchor = -popupAnchor;
     }
     popupAlign = -popupAlign;
   }
 
   // first, determine at which corner of the anchor the popup should appear
   nsPoint pnt;
   switch (popupAnchor) {
@@ -955,36 +955,39 @@ nsMenuPopupFrame::AdjustPositionForAncho
   // vertically as well.
   // If we are flipping in both directions, we want to set a flip style both
   // horizontally and vertically. However, we want to flip on the inside edge
   // of the anchor. Consider the example of a typical dropdown menu.
   // Vertically, we flip the popup on the outside edges of the anchor menu,
   // however horizontally, we want to to use the inside edges so the popup
   // still appears underneath the anchor menu instead of floating off the
   // side of the menu.
-  if (popupAnchor >= POPUPALIGNMENT_LEFTCENTER) {
-    if (popupAnchor == POPUPALIGNMENT_LEFTCENTER ||
-        popupAnchor == POPUPALIGNMENT_RIGHTCENTER) {
+  switch (popupAnchor) {
+    case POPUPALIGNMENT_LEFTCENTER:
+    case POPUPALIGNMENT_RIGHTCENTER:
       aHFlip = FlipStyle_Outside;
       aVFlip = FlipStyle_Inside;
-    }
-    else {
+      break;
+    case POPUPALIGNMENT_TOPCENTER:
+    case POPUPALIGNMENT_BOTTOMCENTER:
       aHFlip = FlipStyle_Inside;
       aVFlip = FlipStyle_Outside;
+      break;
+    default:
+    {
+      FlipStyle anchorEdge = mFlipBoth ? FlipStyle_Inside : FlipStyle_None;
+      aHFlip = (popupAnchor == -popupAlign) ? FlipStyle_Outside : anchorEdge;
+      if (((popupAnchor > 0) == (popupAlign > 0)) ||
+          (popupAnchor == POPUPALIGNMENT_TOPLEFT && popupAlign == POPUPALIGNMENT_TOPLEFT))
+        aVFlip = FlipStyle_Outside;
+      else
+        aVFlip = anchorEdge;
+      break;
     }
   }
-  else {
-    FlipStyle anchorEdge = mFlipBoth ? FlipStyle_Inside : FlipStyle_None;
-    aHFlip = (popupAnchor == -popupAlign) ? FlipStyle_Outside : anchorEdge;
-    if (((popupAnchor > 0) == (popupAlign > 0)) ||
-        (popupAnchor == POPUPALIGNMENT_TOPLEFT && popupAlign == POPUPALIGNMENT_TOPLEFT))
-      aVFlip = FlipStyle_Outside;
-    else
-      aVFlip = anchorEdge;
-  }
 
   return pnt;
 }
 
 nscoord
 nsMenuPopupFrame::FlipOrResize(nscoord& aScreenPoint, nscoord aSize, 
                                nscoord aScreenBegin, nscoord aScreenEnd,
                                nscoord aAnchorBegin, nscoord aAnchorEnd,
--- a/layout/xul/base/src/nsMenuPopupFrame.h
+++ b/layout/xul/base/src/nsMenuPopupFrame.h
@@ -70,19 +70,19 @@ enum FlipStyle {
 // changing the sign
 #define POPUPALIGNMENT_NONE 0
 #define POPUPALIGNMENT_TOPLEFT 1
 #define POPUPALIGNMENT_TOPRIGHT -1
 #define POPUPALIGNMENT_BOTTOMLEFT 2
 #define POPUPALIGNMENT_BOTTOMRIGHT -2
 
 #define POPUPALIGNMENT_LEFTCENTER 16
-#define POPUPALIGNMENT_RIGHTCENTER 17
-#define POPUPALIGNMENT_TOPCENTER 18
-#define POPUPALIGNMENT_BOTTOMCENTER 19
+#define POPUPALIGNMENT_RIGHTCENTER -16
+#define POPUPALIGNMENT_TOPCENTER 17
+#define POPUPALIGNMENT_BOTTOMCENTER 18
 
 // The constants here are selected so that horizontally and vertically flipping
 // can be easily handled using the two flip macros below.
 #define POPUPPOSITION_UNKNOWN -1
 #define POPUPPOSITION_BEFORESTART 0
 #define POPUPPOSITION_BEFOREEND 1
 #define POPUPPOSITION_AFTERSTART 2
 #define POPUPPOSITION_AFTEREND 3