mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 653131. nsBoxFrame::CreateViewForFrame is only used for menu popups, so simplify it and move it there. r=roc
This commit is contained in:
parent
91f2e27dba
commit
ba639fd0f4
@ -1842,63 +1842,6 @@ nsBoxFrame::GetFrameSizeWithMargin(nsIBox* aBox, nsSize& aSize)
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Boxed don't support fixed positionioning of their children.
|
||||
* KEEP THIS IN SYNC WITH nsContainerFrame::CreateViewForFrame
|
||||
* as much as possible. Until we get rid of views finally...
|
||||
*/
|
||||
nsresult
|
||||
nsBoxFrame::CreateViewForFrame(nsPresContext* aPresContext,
|
||||
nsIFrame* aFrame,
|
||||
nsStyleContext* aStyleContext,
|
||||
PRBool aForce,
|
||||
PRBool aIsPopup)
|
||||
{
|
||||
NS_ASSERTION(aForce, "We only get called to force view creation now");
|
||||
// If we don't yet have a view, see if we need a view
|
||||
if (!aFrame->HasView()) {
|
||||
nsViewVisibility visibility = nsViewVisibility_kShow;
|
||||
PRInt32 zIndex = 0;
|
||||
PRBool autoZIndex = PR_FALSE;
|
||||
|
||||
if (aForce) {
|
||||
nsIView* parentView;
|
||||
nsIViewManager* viewManager = aPresContext->GetPresShell()->GetViewManager();
|
||||
NS_ASSERTION(nsnull != viewManager, "null view manager");
|
||||
|
||||
// Create a view
|
||||
if (aIsPopup) {
|
||||
parentView = viewManager->GetRootView();
|
||||
visibility = nsViewVisibility_kHide;
|
||||
zIndex = PR_INT32_MAX;
|
||||
}
|
||||
else {
|
||||
parentView = aFrame->GetParent()->GetClosestView();
|
||||
}
|
||||
|
||||
NS_ASSERTION(parentView, "no parent view");
|
||||
|
||||
// Create a view
|
||||
nsIView *view = viewManager->CreateView(aFrame->GetRect(), parentView, visibility);
|
||||
if (view) {
|
||||
viewManager->SetViewZIndex(view, autoZIndex, zIndex);
|
||||
// XXX put view last in document order until we can do better
|
||||
viewManager->InsertChild(parentView, view, nsnull, PR_TRUE);
|
||||
}
|
||||
|
||||
// Remember our view
|
||||
aFrame->SetView(view);
|
||||
|
||||
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
|
||||
("nsBoxFrame::CreateViewForFrame: frame=%p view=%p",
|
||||
aFrame));
|
||||
if (!view)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// If you make changes to this function, check its counterparts
|
||||
// in nsTextBoxFrame and nsXULLabelFrame
|
||||
nsresult
|
||||
|
@ -180,14 +180,6 @@ public:
|
||||
|
||||
nsBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, PRBool aIsRoot = PR_FALSE, nsIBoxLayout* aLayoutManager = nsnull);
|
||||
|
||||
// if aIsPopup is true, then the view is for a popup. In this case,
|
||||
// the view is added a child of the root view, and is initially hidden
|
||||
static nsresult CreateViewForFrame(nsPresContext* aPresContext,
|
||||
nsIFrame* aChild,
|
||||
nsStyleContext* aStyleContext,
|
||||
PRBool aForce,
|
||||
PRBool aIsPopup = PR_FALSE);
|
||||
|
||||
// virtual so nsStackFrame, nsButtonBoxFrame, nsSliderFrame and nsMenuFrame
|
||||
// can override it
|
||||
NS_IMETHOD BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
|
||||
|
@ -151,7 +151,7 @@ nsMenuPopupFrame::Init(nsIContent* aContent,
|
||||
GetMetric(nsILookAndFeel::eMetric_MenusCanOverlapOSBar, tempBool);
|
||||
mMenuCanOverlapOSBar = tempBool;
|
||||
|
||||
rv = CreateViewForFrame(presContext, this, GetStyleContext(), PR_TRUE, PR_TRUE);
|
||||
rv = CreatePopupViewForFrame();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// XXX Hack. The popup's view should float above all other views,
|
||||
@ -1872,3 +1872,49 @@ nsMenuPopupFrame::SetConsumeRollupEvent(PRUint32 aConsumeMode)
|
||||
{
|
||||
mConsumeRollupEvent = aConsumeMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* KEEP THIS IN SYNC WITH nsContainerFrame::CreateViewForFrame
|
||||
* as much as possible. Until we get rid of views finally...
|
||||
*/
|
||||
nsresult
|
||||
nsMenuPopupFrame::CreatePopupViewForFrame()
|
||||
{
|
||||
if (HasView()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsViewVisibility visibility = nsViewVisibility_kShow;
|
||||
PRInt32 zIndex = 0;
|
||||
PRBool autoZIndex = PR_FALSE;
|
||||
|
||||
nsIView* parentView;
|
||||
nsIViewManager* viewManager = PresContext()->GetPresShell()->GetViewManager();
|
||||
NS_ASSERTION(nsnull != viewManager, "null view manager");
|
||||
|
||||
// Create a view
|
||||
parentView = viewManager->GetRootView();
|
||||
visibility = nsViewVisibility_kHide;
|
||||
zIndex = PR_INT32_MAX;
|
||||
|
||||
NS_ASSERTION(parentView, "no parent view");
|
||||
|
||||
// Create a view
|
||||
nsIView *view = viewManager->CreateView(GetRect(), parentView, visibility);
|
||||
if (view) {
|
||||
viewManager->SetViewZIndex(view, autoZIndex, zIndex);
|
||||
// XXX put view last in document order until we can do better
|
||||
viewManager->InsertChild(parentView, view, nsnull, PR_TRUE);
|
||||
}
|
||||
|
||||
// Remember our view
|
||||
SetView(view);
|
||||
|
||||
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
|
||||
("nsMenuPopupFrame::CreatePopupViewForFrame: frame=%p view=%p", this, view));
|
||||
|
||||
if (!view)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -400,6 +400,10 @@ protected:
|
||||
: GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
|
||||
}
|
||||
|
||||
// Create a popup view for this frame. The view is added a child of the root
|
||||
// view, and is initially hidden.
|
||||
nsresult CreatePopupViewForFrame();
|
||||
|
||||
nsString mIncrementalString; // for incremental typing navigation
|
||||
|
||||
// the content that the popup is anchored to, if any, which may be in a
|
||||
|
Loading…
Reference in New Issue
Block a user