Bug 674862 - nsResizerFrame may deanchor panels.
authorMarco Bonardo <mbonardo@mozilla.com>
Fri, 29 Jul 2011 11:38:39 +0200
changeset 73535 f839abc8f1503c22dbe2183ee568fae277f05b9d
parent 73534 acd21e50bd12c9a3260ad64848d80ed34ed25295
child 73536 880d9e9ab428fd331658b14c2c1d05a6fe3a41d0
push idunknown
push userunknown
push dateunknown
bugs674862
milestone8.0a1
Bug 674862 - nsResizerFrame may deanchor panels. r=enn
layout/xul/base/src/nsMenuPopupFrame.cpp
layout/xul/base/src/nsResizerFrame.cpp
--- a/layout/xul/base/src/nsMenuPopupFrame.cpp
+++ b/layout/xul/base/src/nsMenuPopupFrame.cpp
@@ -1158,20 +1158,18 @@ nsMenuPopupFrame::SetPopupPosition(nsIFr
   nsMargin margin(0, 0, 0, 0);
   GetStyleMargin()->GetMargin(margin);
 
   // the screen rectangle of the root frame, in dev pixels.
   nsRect rootScreenRect = rootFrame->GetScreenRectInAppUnits();
 
   nsDeviceContext* devContext = presContext->DeviceContext();
   nscoord offsetForContextMenu = 0;
-  // if mScreenXPos and mScreenYPos are -1, then we are anchored. If they
-  // have other values, then the popup appears unanchored at that screen
-  // coordinate.
-  if (mScreenXPos == -1 && mScreenYPos == -1) {
+
+  if (IsAnchored()) {
     // if we are anchored, there are certain things we don't want to do when
     // repositioning the popup to fit on the screen, such as end up positioned
     // over the anchor, for instance a popup appearing over the menu label.
     // When doing this reposition, we want to move the popup to the side with
     // the most room. The combination of anchor and alignment dictate if we 
     // readjust above/below or to the left/right.
     if (mAnchorContent) {
       // move the popup according to the anchor and alignment. This will also
--- a/layout/xul/base/src/nsResizerFrame.cpp
+++ b/layout/xul/base/src/nsResizerFrame.cpp
@@ -278,20 +278,19 @@ nsResizerFrame::HandleEvent(nsPresContex
           if (direction.mHorizontal) {
             contentToResize->SetAttr(kNameSpaceID_None, nsGkAtoms::width, widthstr, PR_TRUE);
           }
           if (direction.mVertical) {
             contentToResize->SetAttr(kNameSpaceID_None, nsGkAtoms::height, heightstr, PR_TRUE);
           }
 
           if (weakFrame.IsAlive() &&
-              (oldRect.x != rect.x || oldRect.y != rect.y)) {
-            // XXX This might go very wrong, since menu popups may add
-            // offsets (e.g. from margins) to this position, so the popup's
-            // widget won't end up at the desired position.
+              (oldRect.x != rect.x || oldRect.y != rect.y) &&
+              (!menuPopupFrame->IsAnchored() ||
+               menuPopupFrame->PopupLevel() != ePopupLevelParent)) {
             menuPopupFrame->MoveTo(rect.x, rect.y, PR_TRUE);
           }
         }
         else {
           nsCOMPtr<nsIDOMElementCSSInlineStyle> inlineStyleContent =
             do_QueryInterface(contentToResize);
           if (inlineStyleContent) {
             nsCOMPtr<nsIDOMCSSStyleDeclaration> decl;