forked from mirrors/gecko-dev
Bug 1901769 - ESR patch. a=diannaS
Differential Revision: https://phabricator.services.mozilla.com/D221481
This commit is contained in:
parent
d33c92b950
commit
4250f32f46
8 changed files with 88 additions and 88 deletions
|
|
@ -63,7 +63,7 @@ add_task(async function test_paste_button_clickjacking() {
|
||||||
);
|
);
|
||||||
|
|
||||||
const pasteButtonIsHidden = promisePasteButtonIsHidden();
|
const pasteButtonIsHidden = promisePasteButtonIsHidden();
|
||||||
EventUtils.synthesizeKey(accesskey, {}, window);
|
pastePopup.activateItem(pasteButton);
|
||||||
await pasteButtonIsHidden;
|
await pasteButtonIsHidden;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,9 @@ function promisePasteButtonIsHidden() {
|
||||||
|
|
||||||
function promiseClickPasteButton() {
|
function promiseClickPasteButton() {
|
||||||
const pasteButton = document.getElementById(kPasteMenuItemId);
|
const pasteButton = document.getElementById(kPasteMenuItemId);
|
||||||
let promise = BrowserTestUtils.waitForEvent(pasteButton, "click");
|
const popup = document.getElementById(kPasteMenuPopupId);
|
||||||
EventUtils.synthesizeMouseAtCenter(pasteButton, {});
|
let promise = BrowserTestUtils.waitForEvent(pasteButton, "command");
|
||||||
|
popup.activateItem(pasteButton);
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,8 +96,8 @@ function getMouseCoordsRelativeToScreenInDevicePixels() {
|
||||||
|
|
||||||
function isCloselyLeftOnTopOf(aCoordsP1, aCoordsP2, aDelta = 10) {
|
function isCloselyLeftOnTopOf(aCoordsP1, aCoordsP2, aDelta = 10) {
|
||||||
return (
|
return (
|
||||||
Math.abs(aCoordsP2.x - aCoordsP1.x) < aDelta &&
|
Math.abs(aCoordsP2.x - aCoordsP1.x) <= aDelta &&
|
||||||
Math.abs(aCoordsP2.y - aCoordsP1.y) < aDelta
|
Math.abs(aCoordsP2.y - aCoordsP1.y) <= aDelta
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,20 +66,20 @@ void XULPopupElement::OpenPopup(Element* aAnchorElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
||||||
if (pm) {
|
if (!pm) {
|
||||||
// As a special case for popups that are menus when no anchor or position
|
return;
|
||||||
// are specified, open the popup with ShowMenu instead of ShowPopup so that
|
|
||||||
// the popup is aligned with the menu.
|
|
||||||
if (!aAnchorElement && position.IsEmpty() && GetPrimaryFrame()) {
|
|
||||||
if (auto* menu = GetContainingMenu()) {
|
|
||||||
pm->ShowMenu(menu, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pm->ShowPopup(this, aAnchorElement, position, aXPos, aYPos, aIsContextMenu,
|
|
||||||
aAttributesOverride, false, aTriggerEvent);
|
|
||||||
}
|
}
|
||||||
|
// As a special case for popups that are menus when no anchor or position
|
||||||
|
// are specified, open the popup with ShowMenu instead of ShowPopup so that
|
||||||
|
// the popup is aligned with the menu.
|
||||||
|
if (!aAnchorElement && position.IsEmpty() && GetPrimaryFrame()) {
|
||||||
|
if (auto* menu = GetContainingMenu()) {
|
||||||
|
pm->ShowMenu(menu, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pm->ShowPopup(this, aAnchorElement, position, aXPos, aYPos, aIsContextMenu,
|
||||||
|
aAttributesOverride, false, aTriggerEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XULPopupElement::OpenPopupAtScreen(int32_t aXPos, int32_t aYPos,
|
void XULPopupElement::OpenPopupAtScreen(int32_t aXPos, int32_t aYPos,
|
||||||
|
|
|
||||||
|
|
@ -480,7 +480,7 @@ void nsMenuPopupFrame::TweakMinPrefISize(nscoord& aSize) {
|
||||||
if (nsIFrame* menuList = GetInFlowParent()) {
|
if (nsIFrame* menuList = GetInFlowParent()) {
|
||||||
menuListOrAnchorWidth = menuList->GetRect().width;
|
menuListOrAnchorWidth = menuList->GetRect().width;
|
||||||
}
|
}
|
||||||
if (mAnchorType == MenuPopupAnchorType_Rect) {
|
if (mAnchorType == MenuPopupAnchorType::Rect) {
|
||||||
menuListOrAnchorWidth = std::max(menuListOrAnchorWidth, mScreenRect.width);
|
menuListOrAnchorWidth = std::max(menuListOrAnchorWidth, mScreenRect.width);
|
||||||
}
|
}
|
||||||
// Input margin doesn't have contents, so account for it for popup sizing
|
// Input margin doesn't have contents, so account for it for popup sizing
|
||||||
|
|
@ -768,9 +768,22 @@ void nsMenuPopupFrame::InitializePopup(nsIContent* aAnchorContent,
|
||||||
|
|
||||||
mPopupState = ePopupShowing;
|
mPopupState = ePopupShowing;
|
||||||
mAnchorContent = aAnchorContent;
|
mAnchorContent = aAnchorContent;
|
||||||
|
mAnchorType = aAnchorType;
|
||||||
|
const nscoord auPerCssPx = AppUnitsPerCSSPixel();
|
||||||
|
const nsPoint pos = CSSPixel::ToAppUnits(CSSIntPoint(aXPos, aYPos));
|
||||||
|
// When converted back to CSSIntRect it is (-1, -1, 0, 0) - as expected in
|
||||||
|
// nsXULPopupManager::Rollup
|
||||||
|
mScreenRect = nsRect(-auPerCssPx, -auPerCssPx, 0, 0);
|
||||||
|
mExtraMargin = pos;
|
||||||
|
// If we have no anchor node, anchor to the given position instead.
|
||||||
|
if (mAnchorType == MenuPopupAnchorType::Node && !aAnchorContent) {
|
||||||
|
mAnchorType = MenuPopupAnchorType::Point;
|
||||||
|
mScreenRect = nsRect(
|
||||||
|
pos + PresShell()->GetRootFrame()->GetScreenRectInAppUnits().TopLeft(),
|
||||||
|
nsSize());
|
||||||
|
mExtraMargin = {};
|
||||||
|
}
|
||||||
mTriggerContent = aTriggerContent;
|
mTriggerContent = aTriggerContent;
|
||||||
mXPos = aXPos;
|
|
||||||
mYPos = aYPos;
|
|
||||||
mIsNativeMenu = false;
|
mIsNativeMenu = false;
|
||||||
mIsTopLevelContextMenu = false;
|
mIsTopLevelContextMenu = false;
|
||||||
mVFlip = false;
|
mVFlip = false;
|
||||||
|
|
@ -780,12 +793,10 @@ void nsMenuPopupFrame::InitializePopup(nsIContent* aAnchorContent,
|
||||||
mPositionedOffset = 0;
|
mPositionedOffset = 0;
|
||||||
mPositionedByMoveToRect = false;
|
mPositionedByMoveToRect = false;
|
||||||
|
|
||||||
mAnchorType = aAnchorType;
|
|
||||||
|
|
||||||
// if aAttributesOverride is true, then the popupanchor, popupalign and
|
// if aAttributesOverride is true, then the popupanchor, popupalign and
|
||||||
// position attributes on the <menupopup> override those values passed in.
|
// position attributes on the <menupopup> override those values passed in.
|
||||||
// If false, those attributes are only used if the values passed in are empty
|
// If false, those attributes are only used if the values passed in are empty
|
||||||
if (aAnchorContent || aAnchorType == MenuPopupAnchorType_Rect) {
|
if (aAnchorContent || aAnchorType == MenuPopupAnchorType::Rect) {
|
||||||
nsAutoString anchor, align, position;
|
nsAutoString anchor, align, position;
|
||||||
mContent->AsElement()->GetAttr(nsGkAtoms::popupanchor, anchor);
|
mContent->AsElement()->GetAttr(nsGkAtoms::popupanchor, anchor);
|
||||||
mContent->AsElement()->GetAttr(nsGkAtoms::popupalign, align);
|
mContent->AsElement()->GetAttr(nsGkAtoms::popupalign, align);
|
||||||
|
|
@ -796,8 +807,6 @@ void nsMenuPopupFrame::InitializePopup(nsIContent* aAnchorContent,
|
||||||
// the offset is used to adjust the position from the anchor point
|
// the offset is used to adjust the position from the anchor point
|
||||||
if (anchor.IsEmpty() && align.IsEmpty() && position.IsEmpty())
|
if (anchor.IsEmpty() && align.IsEmpty() && position.IsEmpty())
|
||||||
position.Assign(aPosition);
|
position.Assign(aPosition);
|
||||||
else
|
|
||||||
mXPos = mYPos = 0;
|
|
||||||
} else if (!aPosition.IsEmpty()) {
|
} else if (!aPosition.IsEmpty()) {
|
||||||
position.Assign(aPosition);
|
position.Assign(aPosition);
|
||||||
}
|
}
|
||||||
|
|
@ -855,9 +864,6 @@ void nsMenuPopupFrame::InitializePopup(nsIContent* aAnchorContent,
|
||||||
InitPositionFromAnchorAlign(anchor, align);
|
InitPositionFromAnchorAlign(anchor, align);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// When converted back to CSSIntRect it is (-1, -1, 0, 0) - as expected in
|
|
||||||
// nsXULPopupManager::Rollup
|
|
||||||
mScreenRect = nsRect(-AppUnitsPerCSSPixel(), -AppUnitsPerCSSPixel(), 0, 0);
|
|
||||||
|
|
||||||
if (aAttributesOverride) {
|
if (aAttributesOverride) {
|
||||||
// Use |left| and |top| dimension attributes to position the popup if
|
// Use |left| and |top| dimension attributes to position the popup if
|
||||||
|
|
@ -893,9 +899,8 @@ void nsMenuPopupFrame::InitializePopupAtScreen(nsIContent* aTriggerContent,
|
||||||
mAnchorContent = nullptr;
|
mAnchorContent = nullptr;
|
||||||
mTriggerContent = aTriggerContent;
|
mTriggerContent = aTriggerContent;
|
||||||
mScreenRect =
|
mScreenRect =
|
||||||
nsRect(CSSPixel::ToAppUnits(aXPos), CSSPixel::ToAppUnits(aYPos), 0, 0);
|
nsRect(CSSPixel::ToAppUnits(CSSIntPoint(aXPos, aYPos)), nsSize());
|
||||||
mXPos = 0;
|
mExtraMargin = {};
|
||||||
mYPos = 0;
|
|
||||||
mFlip = FlipFromAttribute(this);
|
mFlip = FlipFromAttribute(this);
|
||||||
mPopupAnchor = POPUPALIGNMENT_NONE;
|
mPopupAnchor = POPUPALIGNMENT_NONE;
|
||||||
mPopupAlignment = POPUPALIGNMENT_NONE;
|
mPopupAlignment = POPUPALIGNMENT_NONE;
|
||||||
|
|
@ -903,7 +908,7 @@ void nsMenuPopupFrame::InitializePopupAtScreen(nsIContent* aTriggerContent,
|
||||||
mIsContextMenu = aIsContextMenu;
|
mIsContextMenu = aIsContextMenu;
|
||||||
mIsTopLevelContextMenu = aIsContextMenu;
|
mIsTopLevelContextMenu = aIsContextMenu;
|
||||||
mIsNativeMenu = false;
|
mIsNativeMenu = false;
|
||||||
mAnchorType = MenuPopupAnchorType_Point;
|
mAnchorType = MenuPopupAnchorType::Point;
|
||||||
mPositionedOffset = 0;
|
mPositionedOffset = 0;
|
||||||
mPositionedByMoveToRect = false;
|
mPositionedByMoveToRect = false;
|
||||||
}
|
}
|
||||||
|
|
@ -914,9 +919,8 @@ void nsMenuPopupFrame::InitializePopupAsNativeContextMenu(
|
||||||
mPopupState = ePopupShowing;
|
mPopupState = ePopupShowing;
|
||||||
mAnchorContent = nullptr;
|
mAnchorContent = nullptr;
|
||||||
mScreenRect =
|
mScreenRect =
|
||||||
nsRect(CSSPixel::ToAppUnits(aXPos), CSSPixel::ToAppUnits(aYPos), 0, 0);
|
nsRect(CSSPixel::ToAppUnits(CSSIntPoint(aXPos, aYPos)), nsSize());
|
||||||
mXPos = 0;
|
mExtraMargin = {};
|
||||||
mYPos = 0;
|
|
||||||
mFlip = FlipType_Default;
|
mFlip = FlipType_Default;
|
||||||
mPopupAnchor = POPUPALIGNMENT_NONE;
|
mPopupAnchor = POPUPALIGNMENT_NONE;
|
||||||
mPopupAlignment = POPUPALIGNMENT_NONE;
|
mPopupAlignment = POPUPALIGNMENT_NONE;
|
||||||
|
|
@ -924,7 +928,7 @@ void nsMenuPopupFrame::InitializePopupAsNativeContextMenu(
|
||||||
mIsContextMenu = true;
|
mIsContextMenu = true;
|
||||||
mIsTopLevelContextMenu = true;
|
mIsTopLevelContextMenu = true;
|
||||||
mIsNativeMenu = true;
|
mIsNativeMenu = true;
|
||||||
mAnchorType = MenuPopupAnchorType_Point;
|
mAnchorType = MenuPopupAnchorType::Point;
|
||||||
mPositionedOffset = 0;
|
mPositionedOffset = 0;
|
||||||
mPositionedByMoveToRect = false;
|
mPositionedByMoveToRect = false;
|
||||||
}
|
}
|
||||||
|
|
@ -934,7 +938,7 @@ void nsMenuPopupFrame::InitializePopupAtRect(nsIContent* aTriggerContent,
|
||||||
const nsIntRect& aRect,
|
const nsIntRect& aRect,
|
||||||
bool aAttributesOverride) {
|
bool aAttributesOverride) {
|
||||||
InitializePopup(nullptr, aTriggerContent, aPosition, 0, 0,
|
InitializePopup(nullptr, aTriggerContent, aPosition, 0, 0,
|
||||||
MenuPopupAnchorType_Rect, aAttributesOverride);
|
MenuPopupAnchorType::Rect, aAttributesOverride);
|
||||||
mScreenRect = ToAppUnits(aRect, AppUnitsPerCSSPixel());
|
mScreenRect = ToAppUnits(aRect, AppUnitsPerCSSPixel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1447,7 +1451,7 @@ auto nsMenuPopupFrame::GetRects(const nsSize& aPrefSize) const -> Rects {
|
||||||
result.mAnchorRect = result.mUntransformedAnchorRect = [&] {
|
result.mAnchorRect = result.mUntransformedAnchorRect = [&] {
|
||||||
// If anchored to a rectangle, use that rectangle. Otherwise, determine
|
// If anchored to a rectangle, use that rectangle. Otherwise, determine
|
||||||
// the rectangle from the anchor.
|
// the rectangle from the anchor.
|
||||||
if (mAnchorType == MenuPopupAnchorType_Rect) {
|
if (mAnchorType == MenuPopupAnchorType::Rect) {
|
||||||
return mScreenRect;
|
return mScreenRect;
|
||||||
}
|
}
|
||||||
// if the frame is not specified, use the anchor node passed to OpenPopup.
|
// if the frame is not specified, use the anchor node passed to OpenPopup.
|
||||||
|
|
@ -1455,7 +1459,7 @@ auto nsMenuPopupFrame::GetRects(const nsSize& aPrefSize) const -> Rects {
|
||||||
// mAnchorContent might be a different document so its presshell must be
|
// mAnchorContent might be a different document so its presshell must be
|
||||||
// used.
|
// used.
|
||||||
nsIFrame* anchorFrame = GetAnchorFrame();
|
nsIFrame* anchorFrame = GetAnchorFrame();
|
||||||
if (!anchorFrame) {
|
if (NS_WARN_IF(!anchorFrame)) {
|
||||||
return rootScreenRect;
|
return rootScreenRect;
|
||||||
}
|
}
|
||||||
return ComputeAnchorRect(rootPc, anchorFrame);
|
return ComputeAnchorRect(rootPc, anchorFrame);
|
||||||
|
|
@ -1467,7 +1471,7 @@ auto nsMenuPopupFrame::GetRects(const nsSize& aPrefSize) const -> Rects {
|
||||||
// When doing this reposition, we want to move the popup to the side with
|
// 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
|
// the most room. The combination of anchor and alignment dictate if we
|
||||||
// readjust above/below or to the left/right.
|
// readjust above/below or to the left/right.
|
||||||
if (mAnchorContent || mAnchorType == MenuPopupAnchorType_Rect) {
|
if (mAnchorContent || mAnchorType == MenuPopupAnchorType::Rect) {
|
||||||
// move the popup according to the anchor and alignment. This will also
|
// move the popup according to the anchor and alignment. This will also
|
||||||
// tell us which axis the popup is flush against in case we have to move
|
// tell us which axis the popup is flush against in case we have to move
|
||||||
// it around later. The AdjustPositionForAnchorAlign method accounts for
|
// it around later. The AdjustPositionForAnchorAlign method accounts for
|
||||||
|
|
@ -1479,20 +1483,6 @@ auto nsMenuPopupFrame::GetRects(const nsSize& aPrefSize) const -> Rects {
|
||||||
result.mUsedRect.MoveTo(result.mAnchorRect.TopLeft() +
|
result.mUsedRect.MoveTo(result.mAnchorRect.TopLeft() +
|
||||||
nsPoint(margin.left, margin.top));
|
nsPoint(margin.left, margin.top));
|
||||||
}
|
}
|
||||||
|
|
||||||
// mXPos and mYPos specify an additional offset passed to OpenPopup that
|
|
||||||
// should be added to the position. We also add the offset to the anchor
|
|
||||||
// pos so a later flip/resize takes the offset into account.
|
|
||||||
// FIXME(emilio): Wayland doesn't seem to be accounting for this offset
|
|
||||||
// anywhere, and it probably should.
|
|
||||||
{
|
|
||||||
nsPoint offset(CSSPixel::ToAppUnits(mXPos), CSSPixel::ToAppUnits(mYPos));
|
|
||||||
if (IsDirectionRTL()) {
|
|
||||||
offset.x = -offset.x;
|
|
||||||
}
|
|
||||||
result.mUsedRect.MoveBy(offset);
|
|
||||||
result.mAnchorRect.MoveBy(offset);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Not anchored, use mScreenRect
|
// Not anchored, use mScreenRect
|
||||||
result.mUsedRect.MoveTo(mScreenRect.TopLeft());
|
result.mUsedRect.MoveTo(mScreenRect.TopLeft());
|
||||||
|
|
@ -1730,12 +1720,12 @@ void nsMenuPopupFrame::PerformMove(const Rects& aRects) {
|
||||||
// by the anchor are lost, but this is super-old behavior.
|
// by the anchor are lost, but this is super-old behavior.
|
||||||
const bool fixPositionToPoint =
|
const bool fixPositionToPoint =
|
||||||
IsNoAutoHide() && (GetPopupLevel() != PopupLevel::Parent ||
|
IsNoAutoHide() && (GetPopupLevel() != PopupLevel::Parent ||
|
||||||
mAnchorType == MenuPopupAnchorType_Rect);
|
mAnchorType == MenuPopupAnchorType::Rect);
|
||||||
if (fixPositionToPoint) {
|
if (fixPositionToPoint) {
|
||||||
// Account for the margin that will end up being added to the screen
|
// Account for the margin that will end up being added to the screen
|
||||||
// coordinate the next time SetPopupPosition is called.
|
// coordinate the next time SetPopupPosition is called.
|
||||||
const auto& margin = GetMargin();
|
const auto& margin = GetMargin();
|
||||||
mAnchorType = MenuPopupAnchorType_Point;
|
mAnchorType = MenuPopupAnchorType::Point;
|
||||||
mScreenRect.x = aRects.mUsedRect.x - margin.left;
|
mScreenRect.x = aRects.mUsedRect.x - margin.left;
|
||||||
mScreenRect.y = aRects.mUsedRect.y - margin.top;
|
mScreenRect.y = aRects.mUsedRect.y - margin.top;
|
||||||
}
|
}
|
||||||
|
|
@ -1743,8 +1733,8 @@ void nsMenuPopupFrame::PerformMove(const Rects& aRects) {
|
||||||
// For anchored popups that shouldn't follow the anchor, fix the original
|
// For anchored popups that shouldn't follow the anchor, fix the original
|
||||||
// anchor rect.
|
// anchor rect.
|
||||||
if (IsAnchored() && !ShouldFollowAnchor() && !mUsedScreenRect.IsEmpty() &&
|
if (IsAnchored() && !ShouldFollowAnchor() && !mUsedScreenRect.IsEmpty() &&
|
||||||
mAnchorType != MenuPopupAnchorType_Rect) {
|
mAnchorType != MenuPopupAnchorType::Rect) {
|
||||||
mAnchorType = MenuPopupAnchorType_Rect;
|
mAnchorType = MenuPopupAnchorType::Rect;
|
||||||
mScreenRect = aRects.mUntransformedAnchorRect;
|
mScreenRect = aRects.mUntransformedAnchorRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2179,6 +2169,19 @@ nsMargin nsMenuPopupFrame::GetMargin() const {
|
||||||
margin.top += auOffset;
|
margin.top += auOffset;
|
||||||
margin.bottom += auOffset;
|
margin.bottom += auOffset;
|
||||||
}
|
}
|
||||||
|
// TODO(emilio): We should consider make these properly mirrored (that is,
|
||||||
|
// changing -= to += here, and removing the rtl special case), but some tests
|
||||||
|
// rely on the old behavior of the anchor moving physically regardless of
|
||||||
|
// alignment...
|
||||||
|
margin.top += mExtraMargin.y;
|
||||||
|
margin.bottom -= mExtraMargin.y;
|
||||||
|
if (IsDirectionRTL()) {
|
||||||
|
margin.left -= mExtraMargin.x;
|
||||||
|
margin.right += mExtraMargin.x;
|
||||||
|
} else {
|
||||||
|
margin.left += mExtraMargin.x;
|
||||||
|
margin.right -= mExtraMargin.x;
|
||||||
|
}
|
||||||
return margin;
|
return margin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2212,19 +2215,16 @@ void nsMenuPopupFrame::MoveTo(const CSSPoint& aPos, bool aUpdateAttrs,
|
||||||
|
|
||||||
mPositionedByMoveToRect = aByMoveToRect;
|
mPositionedByMoveToRect = aByMoveToRect;
|
||||||
mScreenRect.MoveTo(appUnitsPos);
|
mScreenRect.MoveTo(appUnitsPos);
|
||||||
if (mAnchorType == MenuPopupAnchorType_Rect) {
|
if (mAnchorType == MenuPopupAnchorType::Rect) {
|
||||||
// This ensures that the anchor width is still honored, to prevent it from
|
// This ensures that the anchor width is still honored, to prevent it from
|
||||||
// changing spuriously.
|
// changing spuriously.
|
||||||
mScreenRect.height = 0;
|
mScreenRect.height = 0;
|
||||||
// But we still need to make sure that our top left position ends up in
|
// But we still need to make sure that our top left position ends up in
|
||||||
// appUnitsPos.
|
// appUnitsPos.
|
||||||
|
|
||||||
mPopupAlignment = rtl ? POPUPALIGNMENT_TOPRIGHT : POPUPALIGNMENT_TOPLEFT;
|
mPopupAlignment = rtl ? POPUPALIGNMENT_TOPRIGHT : POPUPALIGNMENT_TOPLEFT;
|
||||||
mPopupAnchor = rtl ? POPUPALIGNMENT_BOTTOMRIGHT : POPUPALIGNMENT_BOTTOMLEFT;
|
mPopupAnchor = rtl ? POPUPALIGNMENT_BOTTOMRIGHT : POPUPALIGNMENT_BOTTOMLEFT;
|
||||||
mXPos = mYPos = 0;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
mAnchorType = MenuPopupAnchorType_Point;
|
mAnchorType = MenuPopupAnchorType::Point;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetPopupPosition(true);
|
SetPopupPosition(true);
|
||||||
|
|
@ -2248,7 +2248,7 @@ void nsMenuPopupFrame::MoveToAnchor(nsIContent* aAnchorContent,
|
||||||
|
|
||||||
nsPopupState oldstate = mPopupState;
|
nsPopupState oldstate = mPopupState;
|
||||||
InitializePopup(aAnchorContent, mTriggerContent, aPosition, aXPos, aYPos,
|
InitializePopup(aAnchorContent, mTriggerContent, aPosition, aXPos, aYPos,
|
||||||
MenuPopupAnchorType_Node, aAttributesOverride);
|
MenuPopupAnchorType::Node, aAttributesOverride);
|
||||||
// InitializePopup changed the state so reset it.
|
// InitializePopup changed the state so reset it.
|
||||||
mPopupState = oldstate;
|
mPopupState = oldstate;
|
||||||
|
|
||||||
|
|
@ -2344,7 +2344,7 @@ void nsMenuPopupFrame::CreatePopupView() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nsMenuPopupFrame::ShouldFollowAnchor() const {
|
bool nsMenuPopupFrame::ShouldFollowAnchor() const {
|
||||||
if (mAnchorType != MenuPopupAnchorType_Node || !mAnchorContent) {
|
if (mAnchorType != MenuPopupAnchorType::Node || !mAnchorContent) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,10 +63,10 @@ enum FlipType {
|
||||||
FlipType_Slide = 3 // allow the arrow to "slide" instead of resizing
|
FlipType_Slide = 3 // allow the arrow to "slide" instead of resizing
|
||||||
};
|
};
|
||||||
|
|
||||||
enum MenuPopupAnchorType {
|
enum class MenuPopupAnchorType : uint8_t {
|
||||||
MenuPopupAnchorType_Node = 0, // anchored to a node
|
Node = 0, // anchored to a node
|
||||||
MenuPopupAnchorType_Point = 1, // unanchored and positioned at a screen point
|
Point = 1, // unanchored, and positioned at a screen point
|
||||||
MenuPopupAnchorType_Rect = 2, // anchored at a screen rectangle
|
Rect = 2, // anchored at a screen rectangle
|
||||||
};
|
};
|
||||||
|
|
||||||
// values are selected so that the direction can be flipped just by
|
// values are selected so that the direction can be flipped just by
|
||||||
|
|
@ -382,7 +382,7 @@ class nsMenuPopupFrame final : public nsBlockFrame {
|
||||||
void PerformMove(const Rects&);
|
void PerformMove(const Rects&);
|
||||||
|
|
||||||
// Return true if the popup is positioned relative to an anchor.
|
// Return true if the popup is positioned relative to an anchor.
|
||||||
bool IsAnchored() const { return mAnchorType != MenuPopupAnchorType_Point; }
|
bool IsAnchored() const { return mAnchorType != MenuPopupAnchorType::Point; }
|
||||||
|
|
||||||
// Return the anchor if there is one.
|
// Return the anchor if there is one.
|
||||||
nsIContent* GetAnchor() const { return mAnchorContent; }
|
nsIContent* GetAnchor() const { return mAnchorContent; }
|
||||||
|
|
@ -565,11 +565,11 @@ class nsMenuPopupFrame final : public nsBlockFrame {
|
||||||
// would be before resizing. Computations are performed using this size.
|
// would be before resizing. Computations are performed using this size.
|
||||||
nsSize mPrefSize{-1, -1};
|
nsSize mPrefSize{-1, -1};
|
||||||
|
|
||||||
// The position of the popup, in CSS pixels.
|
// A point with extra offsets to apply in the horizontal and vertical axes. We
|
||||||
// The screen coordinates, if set to values other than -1,
|
// don't use an nsMargin because the values would be the same for the same
|
||||||
// override mXPos and mYPos.
|
// axis.
|
||||||
int32_t mXPos = 0;
|
nsPoint mExtraMargin;
|
||||||
int32_t mYPos = 0;
|
|
||||||
nsRect mScreenRect;
|
nsRect mScreenRect;
|
||||||
// Used for store rectangle which the popup is going to be anchored to, we
|
// Used for store rectangle which the popup is going to be anchored to, we
|
||||||
// need that for Wayland. It's important that this rect is unflipped, and
|
// need that for Wayland. It's important that this rect is unflipped, and
|
||||||
|
|
@ -634,7 +634,7 @@ class nsMenuPopupFrame final : public nsBlockFrame {
|
||||||
mutable nscoord mPositionedOffset = 0;
|
mutable nscoord mPositionedOffset = 0;
|
||||||
|
|
||||||
// How the popup is anchored.
|
// How the popup is anchored.
|
||||||
MenuPopupAnchorType mAnchorType = MenuPopupAnchorType_Node;
|
MenuPopupAnchorType mAnchorType = MenuPopupAnchorType::Node;
|
||||||
|
|
||||||
nsRect mOverrideConstraintRect;
|
nsRect mOverrideConstraintRect;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -855,7 +855,7 @@ void nsXULPopupManager::ShowMenu(nsIContent* aMenu, bool aSelectFirstItem) {
|
||||||
|
|
||||||
// there is no trigger event for menus
|
// there is no trigger event for menus
|
||||||
popupFrame->InitializePopup(aMenu, nullptr, position, 0, 0,
|
popupFrame->InitializePopup(aMenu, nullptr, position, 0, 0,
|
||||||
MenuPopupAnchorType_Node, true);
|
MenuPopupAnchorType::Node, true);
|
||||||
PendingPopup pendingPopup(&popupFrame->PopupElement(), nullptr);
|
PendingPopup pendingPopup(&popupFrame->PopupElement(), nullptr);
|
||||||
BeginShowingPopup(pendingPopup, parentIsContextMenu, aSelectFirstItem);
|
BeginShowingPopup(pendingPopup, parentIsContextMenu, aSelectFirstItem);
|
||||||
}
|
}
|
||||||
|
|
@ -897,7 +897,7 @@ void nsXULPopupManager::ShowPopup(Element* aPopup, nsIContent* aAnchorContent,
|
||||||
nsCOMPtr<nsIContent> triggerContent = pendingPopup.GetTriggerContent();
|
nsCOMPtr<nsIContent> triggerContent = pendingPopup.GetTriggerContent();
|
||||||
|
|
||||||
popupFrame->InitializePopup(aAnchorContent, triggerContent, aPosition, aXPos,
|
popupFrame->InitializePopup(aAnchorContent, triggerContent, aPosition, aXPos,
|
||||||
aYPos, MenuPopupAnchorType_Node,
|
aYPos, MenuPopupAnchorType::Node,
|
||||||
aAttributesOverride);
|
aAttributesOverride);
|
||||||
|
|
||||||
BeginShowingPopup(pendingPopup, aIsContextMenu, aSelectFirstItem);
|
BeginShowingPopup(pendingPopup, aIsContextMenu, aSelectFirstItem);
|
||||||
|
|
|
||||||
|
|
@ -135,13 +135,12 @@ export var ClipboardContextMenu = {
|
||||||
// on the same `_menupopup` object. If the popup is already open,
|
// on the same `_menupopup` object. If the popup is already open,
|
||||||
// `openPopup` is a no-op. When the popup is clicked or dismissed both
|
// `openPopup` is a no-op. When the popup is clicked or dismissed both
|
||||||
// actor parents will receive the corresponding event.
|
// actor parents will receive the corresponding event.
|
||||||
this._menupopup.openPopup(
|
this._menupopup.openPopup(null, {
|
||||||
null,
|
isContextMenu: true,
|
||||||
"overlap" /* options */,
|
position: "overlap",
|
||||||
mouseXInCSSPixels.value,
|
x: mouseXInCSSPixels.value,
|
||||||
mouseYInCSSPixels.value,
|
y: mouseYInCSSPixels.value,
|
||||||
true /* isContextMenu */
|
});
|
||||||
);
|
|
||||||
|
|
||||||
this._refreshDelayTimer(document);
|
this._refreshDelayTimer(document);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,8 @@ async function waitForPasteContextMenu() {
|
||||||
function promiseClickPasteButton() {
|
function promiseClickPasteButton() {
|
||||||
info("Wait for clicking paste contextmenu");
|
info("Wait for clicking paste contextmenu");
|
||||||
const pasteButton = document.getElementById(kPasteMenuItemId);
|
const pasteButton = document.getElementById(kPasteMenuItemId);
|
||||||
let promise = BrowserTestUtils.waitForEvent(pasteButton, "click");
|
let promise = BrowserTestUtils.waitForEvent(pasteButton, "command");
|
||||||
EventUtils.synthesizeMouseAtCenter(pasteButton, {});
|
document.getElementById(kPasteMenuPopupId).activateItem(pasteButton);
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue