mozilla-bmo1708709.patch
branchfirefox91
changeset 1161 36ae1e4f15eb
equal deleted inserted replaced
1160:b28cf22ff7cf 1161:36ae1e4f15eb
       
     1 Index: firefox-91.0.2/dom/xul/XULPopupElement.cpp
       
     2 ===================================================================
       
     3 --- firefox-91.0.2.orig/dom/xul/XULPopupElement.cpp
       
     4 +++ firefox-91.0.2/dom/xul/XULPopupElement.cpp
       
     5 @@ -271,8 +271,7 @@ already_AddRefed<DOMRect> XULPopupElemen
       
     6      // For native menus we can't query the true size. Use the anchor rect
       
     7      // instead, which at least has the position at which we were intending to
       
     8      // open the menu.
       
     9 -    screenRect = Some(CSSRect(
       
    10 -        CSSIntRect::FromUnknownRect(menuPopupFrame->GetScreenAnchorRect())));
       
    11 +    screenRect = Some(CSSRect(menuPopupFrame->GetScreenAnchorRect()));
       
    12    } else {
       
    13      // For non-native menus, query the bounds from the widget.
       
    14      if (nsView* view = menuPopupFrame->GetView()) {
       
    15 Index: firefox-91.0.2/layout/xul/nsMenuPopupFrame.h
       
    16 ===================================================================
       
    17 --- firefox-91.0.2.orig/layout/xul/nsMenuPopupFrame.h
       
    18 +++ firefox-91.0.2/layout/xul/nsMenuPopupFrame.h
       
    19 @@ -321,7 +321,7 @@ class nsMenuPopupFrame final : public ns
       
    20    // If aUpdateAttrs is true, and the popup already has left or top attributes,
       
    21    // then those attributes are updated to the new location.
       
    22    // The frame may be destroyed by this method.
       
    23 -  void MoveTo(const mozilla::CSSIntPoint& aPos, bool aUpdateAttrs);
       
    24 +  void MoveTo(const mozilla::CSSPoint& aPos, bool aUpdateAttrs);
       
    25  
       
    26    void MoveToAnchor(nsIContent* aAnchorContent, const nsAString& aPosition,
       
    27                      int32_t aXPos, int32_t aYPos, bool aAttributesOverride);
       
    28 @@ -370,7 +370,9 @@ class nsMenuPopupFrame final : public ns
       
    29  
       
    30    // Return the screen coordinates in CSS pixels of the popup,
       
    31    // or (-1, -1, 0, 0) if anchored.
       
    32 -  nsIntRect GetScreenAnchorRect() const { return mScreenRect; }
       
    33 +  mozilla::CSSIntRect GetScreenAnchorRect() const {
       
    34 +    return mozilla::CSSRect::FromAppUnitsRounded(mScreenRect);
       
    35 +  }
       
    36  
       
    37    mozilla::LayoutDeviceIntPoint GetLastClientOffset() const {
       
    38      return mLastClientOffset;
       
    39 @@ -557,7 +559,7 @@ class nsMenuPopupFrame final : public ns
       
    40    // override mXPos and mYPos.
       
    41    int32_t mXPos;
       
    42    int32_t mYPos;
       
    43 -  nsIntRect mScreenRect;
       
    44 +  nsRect mScreenRect;
       
    45    // Used for store rectangle which the popup is going to be anchored to,
       
    46    // we need that for Wayland
       
    47  #ifdef MOZ_WAYLAND
       
    48 Index: firefox-91.0.2/layout/xul/nsMenuPopupFrame.cpp
       
    49 ===================================================================
       
    50 --- firefox-91.0.2.orig/layout/xul/nsMenuPopupFrame.cpp
       
    51 +++ firefox-91.0.2/layout/xul/nsMenuPopupFrame.cpp
       
    52 @@ -868,8 +868,9 @@ void nsMenuPopupFrame::InitializePopup(n
       
    53        InitPositionFromAnchorAlign(anchor, align);
       
    54      }
       
    55    }
       
    56 -
       
    57 -  mScreenRect = nsIntRect(-1, -1, 0, 0);
       
    58 +  // When converted back to CSSIntRect it is (-1, -1, 0, 0) - as expected in
       
    59 +  // nsXULPopupManager::Rollup
       
    60 +  mScreenRect = nsRect(-AppUnitsPerCSSPixel(), -AppUnitsPerCSSPixel(), 0, 0);
       
    61  
       
    62    if (aAttributesOverride) {
       
    63      // Use |left| and |top| dimension attributes to position the popup if
       
    64 @@ -881,11 +882,13 @@ void nsMenuPopupFrame::InitializePopup(n
       
    65      nsresult err;
       
    66      if (!left.IsEmpty()) {
       
    67        int32_t x = left.ToInteger(&err);
       
    68 -      if (NS_SUCCEEDED(err)) mScreenRect.x = x;
       
    69 +      if (NS_SUCCEEDED(err))
       
    70 +        mScreenRect.x = nsPresContext::CSSPixelsToAppUnits(x);
       
    71      }
       
    72      if (!top.IsEmpty()) {
       
    73        int32_t y = top.ToInteger(&err);
       
    74 -      if (NS_SUCCEEDED(err)) mScreenRect.y = y;
       
    75 +      if (NS_SUCCEEDED(err))
       
    76 +        mScreenRect.y = nsPresContext::CSSPixelsToAppUnits(y);
       
    77      }
       
    78    }
       
    79  }
       
    80 @@ -900,7 +903,8 @@ void nsMenuPopupFrame::InitializePopupAt
       
    81    mPopupState = ePopupShowing;
       
    82    mAnchorContent = nullptr;
       
    83    mTriggerContent = aTriggerContent;
       
    84 -  mScreenRect = nsIntRect(aXPos, aYPos, 0, 0);
       
    85 +  mScreenRect = nsRect(nsPresContext::CSSPixelsToAppUnits(aXPos),
       
    86 +                       nsPresContext::CSSPixelsToAppUnits(aYPos), 0, 0);
       
    87    mXPos = 0;
       
    88    mYPos = 0;
       
    89    mFlip = FlipType_Default;
       
    90 @@ -920,7 +924,8 @@ void nsMenuPopupFrame::InitializePopupAs
       
    91    mTriggerContent = aTriggerContent;
       
    92    mPopupState = ePopupShowing;
       
    93    mAnchorContent = nullptr;
       
    94 -  mScreenRect = nsIntRect(aXPos, aYPos, 0, 0);
       
    95 +  mScreenRect = nsRect(nsPresContext::CSSPixelsToAppUnits(aXPos),
       
    96 +                       nsPresContext::CSSPixelsToAppUnits(aYPos), 0, 0);
       
    97    mXPos = 0;
       
    98    mYPos = 0;
       
    99    mFlip = FlipType_Default;
       
   100 @@ -941,7 +946,7 @@ void nsMenuPopupFrame::InitializePopupAt
       
   101                                               bool aAttributesOverride) {
       
   102    InitializePopup(nullptr, aTriggerContent, aPosition, 0, 0,
       
   103                    MenuPopupAnchorType_Rect, aAttributesOverride);
       
   104 -  mScreenRect = aRect;
       
   105 +  mScreenRect = ToAppUnits(aRect, AppUnitsPerCSSPixel());
       
   106  }
       
   107  
       
   108  void nsMenuPopupFrame::ShowPopup(bool aIsContextMenu) {
       
   109 @@ -1430,7 +1435,7 @@ nsresult nsMenuPopupFrame::SetPopupPosit
       
   110      // If anchored to a rectangle, use that rectangle. Otherwise, determine the
       
   111      // rectangle from the anchor.
       
   112      if (mAnchorType == MenuPopupAnchorType_Rect) {
       
   113 -      anchorRect = ToAppUnits(mScreenRect, AppUnitsPerCSSPixel());
       
   114 +      anchorRect = mScreenRect;
       
   115      } else {
       
   116        // if the frame is not specified, use the anchor node passed to OpenPopup.
       
   117        // If that wasn't specified either, use the root frame. Note that
       
   118 @@ -1539,10 +1544,8 @@ nsresult nsMenuPopupFrame::SetPopupPosit
       
   119        // Account for the margin that will end up being added to the screen
       
   120        // coordinate the next time SetPopupPosition is called.
       
   121        mAnchorType = MenuPopupAnchorType_Point;
       
   122 -      mScreenRect.x =
       
   123 -          nsPresContext::AppUnitsToIntCSSPixels(screenPoint.x - margin.left);
       
   124 -      mScreenRect.y =
       
   125 -          nsPresContext::AppUnitsToIntCSSPixels(screenPoint.y - margin.top);
       
   126 +      mScreenRect.x = screenPoint.x - margin.left;
       
   127 +      mScreenRect.y = screenPoint.y - margin.top;
       
   128      }
       
   129    } else {
       
   130      // The popup is positioned at a screen coordinate.
       
   131 @@ -1571,10 +1574,8 @@ nsresult nsMenuPopupFrame::SetPopupPosit
       
   132      }
       
   133  
       
   134      // next, convert into app units accounting for the zoom
       
   135 -    screenPoint.x = presContext->DevPixelsToAppUnits(
       
   136 -        nsPresContext::CSSPixelsToAppUnits(mScreenRect.x) / factor);
       
   137 -    screenPoint.y = presContext->DevPixelsToAppUnits(
       
   138 -        nsPresContext::CSSPixelsToAppUnits(mScreenRect.y) / factor);
       
   139 +    screenPoint.x = presContext->DevPixelsToAppUnits(mScreenRect.x / factor);
       
   140 +    screenPoint.y = presContext->DevPixelsToAppUnits(mScreenRect.y / factor);
       
   141      anchorRect = nsRect(screenPoint, nsSize(0, 0));
       
   142  
       
   143      // add the margins on the popup
       
   144 @@ -2377,9 +2378,10 @@ void nsMenuPopupFrame::DestroyFrom(nsIFr
       
   145    nsBoxFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
       
   146  }
       
   147  
       
   148 -void nsMenuPopupFrame::MoveTo(const CSSIntPoint& aPos, bool aUpdateAttrs) {
       
   149 +void nsMenuPopupFrame::MoveTo(const CSSPoint& aPos, bool aUpdateAttrs) {
       
   150    nsIWidget* widget = GetWidget();
       
   151 -  if ((mScreenRect.x == aPos.x && mScreenRect.y == aPos.y) &&
       
   152 +  nsPoint appUnitsPos = mozilla::CSSPixel::ToAppUnits(aPos);
       
   153 +  if ((mScreenRect.x == appUnitsPos.x && mScreenRect.y == appUnitsPos.y) &&
       
   154        (!widget || widget->GetClientOffset() == mLastClientOffset)) {
       
   155      return;
       
   156    }
       
   157 @@ -2400,8 +2402,8 @@ void nsMenuPopupFrame::MoveTo(const CSSI
       
   158    }
       
   159  
       
   160    mAnchorType = MenuPopupAnchorType_Point;
       
   161 -  mScreenRect.x = aPos.x - nsPresContext::AppUnitsToIntCSSPixels(margin.left);
       
   162 -  mScreenRect.y = aPos.y - nsPresContext::AppUnitsToIntCSSPixels(margin.top);
       
   163 +  mScreenRect.x = appUnitsPos.x - margin.left;
       
   164 +  mScreenRect.y = appUnitsPos.y - margin.top;
       
   165  
       
   166    SetPopupPosition(nullptr, true, false);
       
   167  
       
   168 @@ -2409,8 +2411,8 @@ void nsMenuPopupFrame::MoveTo(const CSSI
       
   169    if (aUpdateAttrs && (popup->HasAttr(kNameSpaceID_None, nsGkAtoms::left) ||
       
   170                         popup->HasAttr(kNameSpaceID_None, nsGkAtoms::top))) {
       
   171      nsAutoString left, top;
       
   172 -    left.AppendInt(aPos.x);
       
   173 -    top.AppendInt(aPos.y);
       
   174 +    left.AppendInt(RoundedToInt(aPos).x);
       
   175 +    top.AppendInt(RoundedToInt(aPos).y);
       
   176      popup->SetAttr(kNameSpaceID_None, nsGkAtoms::left, left, false);
       
   177      popup->SetAttr(kNameSpaceID_None, nsGkAtoms::top, top, false);
       
   178    }
       
   179 Index: firefox-91.0.2/layout/xul/nsXULPopupManager.cpp
       
   180 ===================================================================
       
   181 --- firefox-91.0.2.orig/layout/xul/nsXULPopupManager.cpp
       
   182 +++ firefox-91.0.2/layout/xul/nsXULPopupManager.cpp
       
   183 @@ -269,8 +269,7 @@ bool nsXULPopupManager::Rollup(uint32_t
       
   184        if (popupFrame->IsAnchored()) {
       
   185          // Check if the popup has a screen anchor rectangle. If not, get the
       
   186          // rectangle from the anchor element.
       
   187 -        anchorRect =
       
   188 -            CSSIntRect::FromUnknownRect(popupFrame->GetScreenAnchorRect());
       
   189 +        anchorRect = popupFrame->GetScreenAnchorRect();
       
   190          if (anchorRect.x == -1 || anchorRect.y == -1) {
       
   191            nsCOMPtr<nsIContent> anchor = popupFrame->GetAnchor();
       
   192  
       
   193 @@ -507,7 +506,7 @@ void nsXULPopupManager::PopupMoved(nsIFr
       
   194    } else {
       
   195      CSSPoint cssPos = LayoutDeviceIntPoint::FromUnknownPoint(aPnt) /
       
   196                        menuPopupFrame->PresContext()->CSSToDevPixelScale();
       
   197 -    menuPopupFrame->MoveTo(RoundedToInt(cssPos), false);
       
   198 +    menuPopupFrame->MoveTo(cssPos, false);
       
   199    }
       
   200  }
       
   201