From feedaa098618b63fb4fef6fa2537669526b48663 Mon Sep 17 00:00:00 2001 From: Neil Deakin Date: Mon, 24 Dec 2012 14:47:34 -0500 Subject: [PATCH] Bug 798226, backout cd66c58db0f7 until the issue of the os adjusting the popup to fit onscreen can be solved. --- layout/xul/base/public/nsIPopupBoxObject.idl | 7 +- layout/xul/base/src/nsMenuPopupFrame.cpp | 59 ------ layout/xul/base/src/nsMenuPopupFrame.h | 22 --- layout/xul/base/src/nsPopupBoxObject.cpp | 50 ----- .../content/tests/chrome/test_arrowpanel.xul | 182 ++++++++---------- toolkit/content/widgets/popup.xml | 147 ++++++++++---- 6 files changed, 188 insertions(+), 279 deletions(-) diff --git a/layout/xul/base/public/nsIPopupBoxObject.idl b/layout/xul/base/public/nsIPopupBoxObject.idl index 6bff30c8a82a..f4548629963c 100644 --- a/layout/xul/base/public/nsIPopupBoxObject.idl +++ b/layout/xul/base/public/nsIPopupBoxObject.idl @@ -10,7 +10,7 @@ interface nsIDOMNode; interface nsIDOMEvent; interface nsIDOMClientRect; -[scriptable, uuid(DF60BA02-005B-4F61-AB1C-5632D0779DB4)] +[scriptable, uuid(ACCEA57B-C3D8-4B6E-9101-90F04EE9DEA0)] interface nsIPopupBoxObject : nsISupports { /** @@ -166,11 +166,6 @@ interface nsIPopupBoxObject : nsISupports in AString position, in long x, in long y, in boolean attributesOverride); - - /** Returns the alignment position where the popup has appeared relative to its - * anchor node or point, accounting for any flipping that occurred. - */ - readonly attribute AString alignmentPosition; }; %{C++ diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index 36ad276839fd..9d6c7259cfcb 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -82,7 +82,6 @@ nsMenuPopupFrame::nsMenuPopupFrame(nsIPresShell* aShell, nsStyleContext* aContex mPopupState(ePopupClosed), mPopupAlignment(POPUPALIGNMENT_NONE), mPopupAnchor(POPUPALIGNMENT_NONE), - mPosition(POPUPPOSITION_UNKNOWN), mConsumeRollupEvent(nsIPopupBoxObject::ROLLUP_DEFAULT), mFlipBoth(false), mIsOpenChanged(false), @@ -535,8 +534,6 @@ nsMenuPopupFrame::InitPositionFromAnchorAlign(const nsAString& aAnchor, mPopupAlignment = POPUPALIGNMENT_BOTTOMRIGHT; else mPopupAlignment = POPUPALIGNMENT_NONE; - - mPosition = POPUPPOSITION_UNKNOWN; } void @@ -554,7 +551,6 @@ nsMenuPopupFrame::InitializePopup(nsIContent* aAnchorContent, mXPos = aXPos; mYPos = aYPos; mAdjustOffsetForContextMenu = false; - mPosition = POPUPPOSITION_UNKNOWN; // if aAttributesOverride is true, then the popupanchor, popupalign and // position attributes on the override those values passed in. @@ -590,52 +586,42 @@ nsMenuPopupFrame::InitializePopup(nsIContent* aAnchorContent, else if (position.EqualsLiteral("before_start")) { mPopupAnchor = POPUPALIGNMENT_TOPLEFT; mPopupAlignment = POPUPALIGNMENT_BOTTOMLEFT; - mPosition = POPUPPOSITION_BEFORESTART; } else if (position.EqualsLiteral("before_end")) { mPopupAnchor = POPUPALIGNMENT_TOPRIGHT; mPopupAlignment = POPUPALIGNMENT_BOTTOMRIGHT; - mPosition = POPUPPOSITION_BEFOREEND; } else if (position.EqualsLiteral("after_start")) { mPopupAnchor = POPUPALIGNMENT_BOTTOMLEFT; mPopupAlignment = POPUPALIGNMENT_TOPLEFT; - mPosition = POPUPPOSITION_AFTERSTART; } else if (position.EqualsLiteral("after_end")) { mPopupAnchor = POPUPALIGNMENT_BOTTOMRIGHT; mPopupAlignment = POPUPALIGNMENT_TOPRIGHT; - mPosition = POPUPPOSITION_AFTEREND; } else if (position.EqualsLiteral("start_before")) { mPopupAnchor = POPUPALIGNMENT_TOPLEFT; mPopupAlignment = POPUPALIGNMENT_TOPRIGHT; - mPosition = POPUPPOSITION_STARTBEFORE; } else if (position.EqualsLiteral("start_after")) { mPopupAnchor = POPUPALIGNMENT_BOTTOMLEFT; mPopupAlignment = POPUPALIGNMENT_BOTTOMRIGHT; - mPosition = POPUPPOSITION_STARTAFTER; } else if (position.EqualsLiteral("end_before")) { mPopupAnchor = POPUPALIGNMENT_TOPRIGHT; mPopupAlignment = POPUPALIGNMENT_TOPLEFT; - mPosition = POPUPPOSITION_ENDBEFORE; } else if (position.EqualsLiteral("end_after")) { mPopupAnchor = POPUPALIGNMENT_BOTTOMRIGHT; mPopupAlignment = POPUPALIGNMENT_BOTTOMLEFT; - mPosition = POPUPPOSITION_ENDAFTER; } else if (position.EqualsLiteral("overlap")) { mPopupAnchor = POPUPALIGNMENT_TOPLEFT; mPopupAlignment = POPUPALIGNMENT_TOPLEFT; - mPosition = POPUPPOSITION_OVERLAP; } else if (position.EqualsLiteral("after_pointer")) { mPopupAnchor = POPUPALIGNMENT_TOPLEFT; mPopupAlignment = POPUPALIGNMENT_TOPLEFT; - mPosition = POPUPPOSITION_AFTERPOINTER; // XXXndeakin this is supposed to anchor vertically after, but with the // horizontal position as the mouse pointer. mYPos += 21; @@ -1922,51 +1908,6 @@ nsMenuPopupFrame::SetConsumeRollupEvent(uint32_t aConsumeMode) mConsumeRollupEvent = aConsumeMode; } -int8_t -nsMenuPopupFrame::GetAlignmentPosition() const -{ - // The code below handles most cases of alignment, anchor and position values. Those that are - // not handled just return POPUPPOSITION_UNKNOWN. - - if (mPosition == POPUPPOSITION_OVERLAP || mPosition == POPUPPOSITION_AFTERPOINTER) - return mPosition; - - int8_t position = mPosition; - - if (position == POPUPPOSITION_UNKNOWN) { - switch (mPopupAnchor) { - case POPUPALIGNMENT_BOTTOMCENTER: - position = mPopupAlignment == POPUPALIGNMENT_TOPRIGHT ? - POPUPPOSITION_AFTEREND : POPUPPOSITION_AFTERSTART; - break; - case POPUPALIGNMENT_TOPCENTER: - position = mPopupAlignment == POPUPALIGNMENT_BOTTOMRIGHT ? - POPUPPOSITION_BEFOREEND : POPUPPOSITION_BEFORESTART; - break; - case POPUPALIGNMENT_LEFTCENTER: - position = mPopupAlignment == POPUPALIGNMENT_BOTTOMRIGHT ? - POPUPPOSITION_STARTAFTER : POPUPPOSITION_STARTBEFORE; - break; - case POPUPALIGNMENT_RIGHTCENTER: - position = mPopupAlignment == POPUPALIGNMENT_BOTTOMLEFT ? - POPUPPOSITION_ENDAFTER : POPUPPOSITION_ENDBEFORE; - break; - default: - break; - } - } - - if (mHFlip) { - position = POPUPPOSITION_HFLIP(position); - } - - if (mVFlip) { - position = POPUPPOSITION_VFLIP(position); - } - - return position; -} - /** * KEEP THIS IN SYNC WITH nsContainerFrame::CreateViewForFrame * as much as possible. Until we get rid of views finally... diff --git a/layout/xul/base/src/nsMenuPopupFrame.h b/layout/xul/base/src/nsMenuPopupFrame.h index c96575026440..c7aa8c9c2cc7 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.h +++ b/layout/xul/base/src/nsMenuPopupFrame.h @@ -79,23 +79,6 @@ enum FlipStyle { #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 -#define POPUPPOSITION_STARTBEFORE 4 -#define POPUPPOSITION_ENDBEFORE 5 -#define POPUPPOSITION_STARTAFTER 6 -#define POPUPPOSITION_ENDAFTER 7 -#define POPUPPOSITION_OVERLAP 8 -#define POPUPPOSITION_AFTERPOINTER 9 - -#define POPUPPOSITION_HFLIP(v) (v ^ 1) -#define POPUPPOSITION_VFLIP(v) (v ^ 2) - #define INC_TYP_INTERVAL 1000 // 1s. If the interval between two keypresses is shorter than this, // treat as a continue typing // XXX, kyle.yuan@sun.com, there are 4 definitions for the same purpose: @@ -332,9 +315,6 @@ public: nsIntPoint GetLastClientOffset() const { return mLastClientOffset; } - // Return the alignment of the popup - int8_t GetAlignmentPosition() const; - protected: // returns the popup's level. @@ -430,8 +410,6 @@ protected: // popup alignment relative to the anchor node int8_t mPopupAlignment; int8_t mPopupAnchor; - int8_t mPosition; - // One of nsIPopupBoxObject::ROLLUP_DEFAULT/ROLLUP_CONSUME/ROLLUP_NO_CONSUME int8_t mConsumeRollupEvent; bool mFlipBoth; // flip in both directions diff --git a/layout/xul/base/src/nsPopupBoxObject.cpp b/layout/xul/base/src/nsPopupBoxObject.cpp index 0962c81cd68e..4266ba1d7858 100644 --- a/layout/xul/base/src/nsPopupBoxObject.cpp +++ b/layout/xul/base/src/nsPopupBoxObject.cpp @@ -307,56 +307,6 @@ nsPopupBoxObject::GetOuterScreenRect(nsIDOMClientRect** aRect) return NS_OK; } -NS_IMETHODIMP -nsPopupBoxObject::GetAlignmentPosition(nsAString& positionStr) -{ - positionStr.Truncate(); - - // This needs to flush layout. - nsMenuPopupFrame *menuPopupFrame = do_QueryFrame(GetFrame(true)); - if (!menuPopupFrame) - return NS_OK; - - int8_t position = menuPopupFrame->GetAlignmentPosition(); - switch (position) { - case POPUPPOSITION_AFTERSTART: - positionStr.AssignLiteral("after_start"); - break; - case POPUPPOSITION_AFTEREND: - positionStr.AssignLiteral("after_end"); - break; - case POPUPPOSITION_BEFORESTART: - positionStr.AssignLiteral("before_start"); - break; - case POPUPPOSITION_BEFOREEND: - positionStr.AssignLiteral("before_end"); - break; - case POPUPPOSITION_STARTBEFORE: - positionStr.AssignLiteral("start_before"); - break; - case POPUPPOSITION_ENDBEFORE: - positionStr.AssignLiteral("end_before"); - break; - case POPUPPOSITION_STARTAFTER: - positionStr.AssignLiteral("start_after"); - break; - case POPUPPOSITION_ENDAFTER: - positionStr.AssignLiteral("end_after"); - break; - case POPUPPOSITION_OVERLAP: - positionStr.AssignLiteral("overlap"); - break; - case POPUPPOSITION_AFTERPOINTER: - positionStr.AssignLiteral("after_pointer"); - break; - default: - // Leave as an empty string. - break; - } - - return NS_OK; -} - // Creation Routine /////////////////////////////////////////////////////////////////////// nsresult diff --git a/toolkit/content/tests/chrome/test_arrowpanel.xul b/toolkit/content/tests/chrome/test_arrowpanel.xul index 53b35ce4367b..43480bef3c43 100644 --- a/toolkit/content/tests/chrome/test_arrowpanel.xul +++ b/toolkit/content/tests/chrome/test_arrowpanel.xul @@ -25,7 +25,7 @@