mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 18:08:58 +00:00
Backed out changeset 8b346c50a44c (bug 1720551) for causing bc failures on browser_test_clipboardcache.js. CLOSED TREE
This commit is contained in:
parent
68dacf122d
commit
75fa983116
@ -481,6 +481,21 @@ class nsMenuPopupFrame final : public nsBoxFrame,
|
||||
// attributes.
|
||||
void MoveToAttributePosition();
|
||||
|
||||
/**
|
||||
* Return whether the popup direction should be RTL.
|
||||
* If the popup has an anchor, its direction is the anchor direction.
|
||||
* Otherwise, its the general direction of the UI.
|
||||
*
|
||||
* Return whether the popup direction should be RTL.
|
||||
*/
|
||||
bool IsDirectionRTL() const {
|
||||
return mAnchorContent && mAnchorContent->GetPrimaryFrame()
|
||||
? mAnchorContent->GetPrimaryFrame()
|
||||
->StyleVisibility()
|
||||
->mDirection == mozilla::StyleDirection::Rtl
|
||||
: StyleVisibility()->mDirection == mozilla::StyleDirection::Rtl;
|
||||
}
|
||||
|
||||
// Create a popup view for this frame. The view is added a child of the root
|
||||
// view, and is initially hidden.
|
||||
void CreatePopupView();
|
||||
@ -497,21 +512,6 @@ class nsMenuPopupFrame final : public nsBoxFrame,
|
||||
bool ShouldFollowAnchor();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Return whether the popup direction should be RTL.
|
||||
* If the popup has an anchor, its direction is the anchor direction.
|
||||
* Otherwise, its the general direction of the UI.
|
||||
*
|
||||
* Return whether the popup direction should be RTL.
|
||||
*/
|
||||
bool IsDirectionRTL() const {
|
||||
return mAnchorContent && mAnchorContent->GetPrimaryFrame()
|
||||
? mAnchorContent->GetPrimaryFrame()
|
||||
->StyleVisibility()
|
||||
->mDirection == mozilla::StyleDirection::Rtl
|
||||
: StyleVisibility()->mDirection == mozilla::StyleDirection::Rtl;
|
||||
}
|
||||
|
||||
bool ShouldFollowAnchor(nsRect& aRect);
|
||||
|
||||
// Returns parent menu widget for submenus that are in the same
|
||||
|
@ -2115,31 +2115,6 @@ static GdkGravity PopupAlignmentToGdkGravity(int8_t aAlignment) {
|
||||
return GDK_GRAVITY_STATIC;
|
||||
}
|
||||
|
||||
static GdkGravity PopupGetHorizontallyFlippedAnchor(GdkGravity anchor) {
|
||||
switch (anchor) {
|
||||
case GDK_GRAVITY_STATIC:
|
||||
case GDK_GRAVITY_NORTH_WEST:
|
||||
return GDK_GRAVITY_NORTH_EAST;
|
||||
case GDK_GRAVITY_NORTH:
|
||||
return GDK_GRAVITY_NORTH;
|
||||
case GDK_GRAVITY_NORTH_EAST:
|
||||
return GDK_GRAVITY_NORTH_WEST;
|
||||
case GDK_GRAVITY_WEST:
|
||||
return GDK_GRAVITY_EAST;
|
||||
case GDK_GRAVITY_CENTER:
|
||||
return GDK_GRAVITY_CENTER;
|
||||
case GDK_GRAVITY_EAST:
|
||||
return GDK_GRAVITY_WEST;
|
||||
case GDK_GRAVITY_SOUTH_WEST:
|
||||
return GDK_GRAVITY_SOUTH_EAST;
|
||||
case GDK_GRAVITY_SOUTH:
|
||||
return GDK_GRAVITY_SOUTH;
|
||||
case GDK_GRAVITY_SOUTH_EAST:
|
||||
return GDK_GRAVITY_SOUTH_WEST;
|
||||
}
|
||||
return anchor;
|
||||
}
|
||||
|
||||
void nsWindow::NativeMoveResizeWaylandPopup(GdkPoint* aPosition,
|
||||
GdkRectangle* aSize) {
|
||||
LOG_POPUP(("nsWindow::NativeMoveResizeWaylandPopup [%p] %d,%d -> %d x %d\n",
|
||||
@ -2266,8 +2241,14 @@ void nsWindow::WaylandPopupMove(bool aUseMoveToRect) {
|
||||
FlipType flipType = FlipType_Default;
|
||||
int8_t position = -1;
|
||||
if (mPopupContextMenu && !mPopupAnchored) {
|
||||
rectAnchor = GDK_GRAVITY_SOUTH_EAST;
|
||||
menuAnchor = GDK_GRAVITY_NORTH_WEST;
|
||||
if (GetTextDirection() == GTK_TEXT_DIR_RTL) {
|
||||
rectAnchor = GDK_GRAVITY_SOUTH_WEST;
|
||||
menuAnchor = GDK_GRAVITY_NORTH_EAST;
|
||||
|
||||
} else {
|
||||
rectAnchor = GDK_GRAVITY_SOUTH_EAST;
|
||||
menuAnchor = GDK_GRAVITY_NORTH_WEST;
|
||||
}
|
||||
} else {
|
||||
rectAnchor = PopupAlignmentToGdkGravity(popupFrame->GetPopupAnchor());
|
||||
menuAnchor = PopupAlignmentToGdkGravity(popupFrame->GetPopupAlignment());
|
||||
@ -2275,11 +2256,6 @@ void nsWindow::WaylandPopupMove(bool aUseMoveToRect) {
|
||||
position = popupFrame->GetAlignmentPosition();
|
||||
}
|
||||
|
||||
if (popupFrame->IsDirectionRTL()) {
|
||||
rectAnchor = PopupGetHorizontallyFlippedAnchor(rectAnchor);
|
||||
menuAnchor = PopupGetHorizontallyFlippedAnchor(menuAnchor);
|
||||
}
|
||||
|
||||
LOG_POPUP((" parentRect gravity: %d anchor gravity: %d\n", rectAnchor,
|
||||
menuAnchor));
|
||||
|
||||
@ -2322,17 +2298,15 @@ void nsWindow::WaylandPopupMove(bool aUseMoveToRect) {
|
||||
// we don't want to slide menus to fit the screen rather resize them
|
||||
hints = GdkAnchorHints(hints | GDK_ANCHOR_SLIDE);
|
||||
}
|
||||
|
||||
// Inspired by nsMenuPopupFrame::AdjustPositionForAnchorAlign
|
||||
nsPoint cursorOffset(0, 0);
|
||||
#ifdef MOZ_WAYLAND
|
||||
// Offset is already computed to the tooltips
|
||||
if (hasAnchorRect && mPopupType != ePopupTypeTooltip) {
|
||||
nsMargin margin(0, 0, 0, 0);
|
||||
popupFrame->StyleMargin()->GetMargin(margin);
|
||||
int8_t popupAlign(popupFrame->GetPopupAlignment());
|
||||
if (popupFrame->IsDirectionRTL()) {
|
||||
popupAlign = -popupAlign;
|
||||
}
|
||||
switch (popupAlign) {
|
||||
switch (popupFrame->GetPopupAlignment()) {
|
||||
case POPUPALIGNMENT_TOPRIGHT:
|
||||
cursorOffset.MoveBy(-margin.right, margin.top);
|
||||
break;
|
||||
@ -2348,6 +2322,7 @@ void nsWindow::WaylandPopupMove(bool aUseMoveToRect) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!g_signal_handler_find(gdkWindow, G_SIGNAL_MATCH_FUNC, 0, 0, nullptr,
|
||||
FuncToGpointer(NativeMoveResizeCallback), this)) {
|
||||
@ -9382,6 +9357,16 @@ void nsWindow::ForceTitlebarRedraw(void) {
|
||||
}
|
||||
}
|
||||
|
||||
GtkTextDirection nsWindow::GetTextDirection() {
|
||||
nsIFrame* frame = GetFrame();
|
||||
if (!frame) {
|
||||
return GTK_TEXT_DIR_LTR;
|
||||
}
|
||||
|
||||
WritingMode wm = frame->GetWritingMode();
|
||||
return wm.IsPhysicalLTR() ? GTK_TEXT_DIR_LTR : GTK_TEXT_DIR_RTL;
|
||||
}
|
||||
|
||||
void nsWindow::LockAspectRatio(bool aShouldLock) {
|
||||
if (!gUseAspectRatio) {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user