зеркало из https://github.com/mozilla/gecko-dev.git
bug 1226 for form control with native widgets. Other controls are still not working.
This commit is contained in:
Родитель
581d6a571f
Коммит
cce53e947f
|
@ -52,7 +52,9 @@ static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
|
|||
static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
|
||||
static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
//static NS_DEFINE_IID(kIHTMLContentIID, NS_IHTMLCONTENT_IID);
|
||||
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
||||
static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
|
||||
|
||||
|
||||
nsFormControlFrame::nsFormControlFrame(nsIContent* aContent, nsIFrame* aParentFrame)
|
||||
: nsLeafFrame(aContent, aParentFrame)
|
||||
|
@ -218,21 +220,106 @@ nsFormControlFrame::SetInitialChildList(nsIPresContext& aPresContext,
|
|||
|
||||
NS_METHOD
|
||||
nsFormControlFrame::Reflow(nsIPresContext& aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
GetDesiredSize(&aPresContext, aReflowState, aDesiredSize, mWidgetSize);
|
||||
|
||||
if (!mDidInit) {
|
||||
nsIPresShell *presShell = aPresContext.GetShell(); // need to release
|
||||
nsIViewManager *viewMan = presShell->GetViewManager(); // need to release
|
||||
NS_RELEASE(presShell);
|
||||
nsRect boundBox(0, 0, aDesiredSize.width, aDesiredSize.height);
|
||||
|
||||
// absolutely positioned controls already have a view but not a widget
|
||||
nsIView* view = nsnull;
|
||||
GetView(view);
|
||||
if (nsnull == view) {
|
||||
result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view);
|
||||
if (!NS_SUCCEEDED(result)) {
|
||||
NS_ASSERTION(0, "Could not create view for form control");
|
||||
aStatus = NS_FRAME_NOT_COMPLETE;
|
||||
return result;
|
||||
}
|
||||
|
||||
nsIFrame* parWithView;
|
||||
nsIView *parView;
|
||||
|
||||
GetParentWithView(parWithView);
|
||||
parWithView->GetView(parView);
|
||||
|
||||
// initialize the view as hidden since we don't know the (x,y) until Paint
|
||||
result = view->Init(viewMan, boundBox, parView, nsnull, nsViewVisibility_kHide);
|
||||
if (NS_OK != result) {
|
||||
NS_ASSERTION(0, "view initialization failed");
|
||||
aStatus = NS_FRAME_NOT_COMPLETE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
SetView(view);
|
||||
}
|
||||
|
||||
const nsIID& id = GetCID();
|
||||
nsWidgetInitData* initData = GetWidgetInitData(aPresContext); // needs to be deleted
|
||||
view->CreateWidget(id, initData);
|
||||
|
||||
if (nsnull != initData) {
|
||||
delete(initData);
|
||||
}
|
||||
|
||||
// set our widget
|
||||
result = GetWidget(view, &mWidget);
|
||||
if ((NS_OK == result) && mWidget) { // keep the ref on mWidget
|
||||
nsIFormControl* formControl = nsnull;
|
||||
result = mContent->QueryInterface(kIFormControlIID, (void**)&formControl);
|
||||
if ((NS_OK == result) && formControl) {
|
||||
// set the content's widget, so it can get content modified by the widget
|
||||
formControl->SetWidget(mWidget);
|
||||
NS_RELEASE(formControl);
|
||||
}
|
||||
PostCreateWidget(&aPresContext, aDesiredSize.width, aDesiredSize.height);
|
||||
mDidInit = PR_TRUE;
|
||||
} else {
|
||||
NS_ASSERTION(0, "could not get widget");
|
||||
}
|
||||
|
||||
if ((aDesiredSize.width != boundBox.width) || (aDesiredSize.height != boundBox.height)) {
|
||||
viewMan->ResizeView(view, aDesiredSize.width, aDesiredSize.height);
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(viewMan);
|
||||
}
|
||||
|
||||
aDesiredSize.ascent = aDesiredSize.height;
|
||||
aDesiredSize.descent = 0;
|
||||
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
aDesiredSize.maxElementSize->width = aDesiredSize.width;
|
||||
aDesiredSize.maxElementSize->height = aDesiredSize.height;
|
||||
}
|
||||
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
NS_METHOD
|
||||
nsFormControlFrame::Reflow(nsIPresContext& aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
nsIView* view = nsnull;
|
||||
GetView(view);
|
||||
if (nsnull == view) {
|
||||
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
||||
static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
|
||||
|
||||
nsresult result =
|
||||
nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID,
|
||||
(void **)&view);
|
||||
nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view);
|
||||
if (NS_OK != result) {
|
||||
NS_ASSERTION(0, "Could not create view for button");
|
||||
NS_ASSERTION(0, "Could not create view for form control");
|
||||
aStatus = NS_FRAME_NOT_COMPLETE;
|
||||
return result;
|
||||
}
|
||||
|
@ -251,19 +338,19 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext,
|
|||
GetParentWithView(parWithView);
|
||||
parWithView->GetView(parView);
|
||||
|
||||
const nsIID& id = GetCID();
|
||||
nsWidgetInitData* initData = GetWidgetInitData(aPresContext); // needs to be deleted
|
||||
// initialize the view as hidden since we don't know the (x,y) until Paint
|
||||
result = view->Init(viewMan, boundBox, parView,
|
||||
nsnull, nsViewVisibility_kHide);
|
||||
if (NS_OK != result) {
|
||||
NS_ASSERTION(0, "widget initialization failed");
|
||||
NS_ASSERTION(0, "view initialization failed");
|
||||
aStatus = NS_FRAME_NOT_COMPLETE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
|
||||
const nsIID& id = GetCID();
|
||||
nsWidgetInitData* initData = GetWidgetInitData(aPresContext); // needs to be deleted
|
||||
view->CreateWidget(id, initData);
|
||||
|
||||
if (nsnull != initData) {
|
||||
|
@ -314,6 +401,8 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFormControlFrame::AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
|
|
|
@ -119,6 +119,7 @@ protected:
|
|||
nsCursor mPreviousCursor;
|
||||
PRBool mGotFocus;
|
||||
nsRect mTranslatedRect;
|
||||
PRBool mDidInit;
|
||||
};
|
||||
|
||||
nsresult
|
||||
|
@ -142,6 +143,7 @@ nsHTMLButtonControlFrame::nsHTMLButtonControlFrame(nsIContent* aContent,
|
|||
mPreviousCursor = eCursor_standard;
|
||||
mGotFocus = PR_FALSE;
|
||||
mTranslatedRect = nsRect(0,0,0,0);
|
||||
mDidInit = PR_FALSE;
|
||||
}
|
||||
|
||||
nsHTMLButtonControlFrame::~nsHTMLButtonControlFrame()
|
||||
|
@ -534,32 +536,6 @@ nsHTMLButtonControlFrame::SetInitialChildList(nsIPresContext& aPresContext,
|
|||
// add ourself as an nsIFormControlFrame
|
||||
nsFormFrame::AddFormControlFrame(aPresContext, *this);
|
||||
|
||||
// create our view, we need a view to grab the mouse
|
||||
nsIView* view;
|
||||
GetView(view);
|
||||
if (!view) {
|
||||
nsresult result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view);
|
||||
nsIPresShell *presShell = aPresContext.GetShell();
|
||||
nsIViewManager *viewMan = presShell->GetViewManager();
|
||||
NS_RELEASE(presShell);
|
||||
|
||||
nsIFrame* parWithView;
|
||||
nsIView *parView;
|
||||
GetParentWithView(parWithView);
|
||||
parWithView->GetView(parView);
|
||||
// the view's size is not know yet, but its size will be kept in synch with our frame.
|
||||
nsRect boundBox(0, 0, 500, 500);
|
||||
result = view->Init(viewMan, boundBox, parView, nsnull);
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
SetView(view);
|
||||
|
||||
const nsStyleColor* color = (const nsStyleColor*) mStyleContext->GetStyleData(eStyleStruct_Color);
|
||||
// set the opacity
|
||||
viewMan->SetViewOpacity(view, color->mOpacity);
|
||||
|
||||
NS_RELEASE(viewMan);
|
||||
}
|
||||
|
||||
// cache our display type
|
||||
const nsStyleDisplay* styleDisplay;
|
||||
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) styleDisplay);
|
||||
|
@ -627,6 +603,35 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext& aPresContext,
|
|||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
if (!mDidInit) {
|
||||
// create our view, we need a view to grab the mouse
|
||||
nsIView* view;
|
||||
GetView(view);
|
||||
if (!view) {
|
||||
nsresult result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view);
|
||||
nsIPresShell *presShell = aPresContext.GetShell();
|
||||
nsIViewManager *viewMan = presShell->GetViewManager();
|
||||
NS_RELEASE(presShell);
|
||||
|
||||
nsIFrame* parWithView;
|
||||
nsIView *parView;
|
||||
GetParentWithView(parWithView);
|
||||
parWithView->GetView(parView);
|
||||
// the view's size is not know yet, but its size will be kept in synch with our frame.
|
||||
nsRect boundBox(0, 0, 500, 500);
|
||||
result = view->Init(viewMan, boundBox, parView, nsnull);
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
SetView(view);
|
||||
|
||||
const nsStyleColor* color = (const nsStyleColor*) mStyleContext->GetStyleData(eStyleStruct_Color);
|
||||
// set the opacity
|
||||
viewMan->SetViewOpacity(view, color->mOpacity);
|
||||
|
||||
NS_RELEASE(viewMan);
|
||||
}
|
||||
mDidInit = PR_TRUE;
|
||||
}
|
||||
|
||||
nsSize availSize(aReflowState.maxSize);
|
||||
|
||||
// reflow the child
|
||||
|
|
|
@ -52,7 +52,9 @@ static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
|
|||
static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
|
||||
static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
//static NS_DEFINE_IID(kIHTMLContentIID, NS_IHTMLCONTENT_IID);
|
||||
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
||||
static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
|
||||
|
||||
|
||||
nsFormControlFrame::nsFormControlFrame(nsIContent* aContent, nsIFrame* aParentFrame)
|
||||
: nsLeafFrame(aContent, aParentFrame)
|
||||
|
@ -218,21 +220,106 @@ nsFormControlFrame::SetInitialChildList(nsIPresContext& aPresContext,
|
|||
|
||||
NS_METHOD
|
||||
nsFormControlFrame::Reflow(nsIPresContext& aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
GetDesiredSize(&aPresContext, aReflowState, aDesiredSize, mWidgetSize);
|
||||
|
||||
if (!mDidInit) {
|
||||
nsIPresShell *presShell = aPresContext.GetShell(); // need to release
|
||||
nsIViewManager *viewMan = presShell->GetViewManager(); // need to release
|
||||
NS_RELEASE(presShell);
|
||||
nsRect boundBox(0, 0, aDesiredSize.width, aDesiredSize.height);
|
||||
|
||||
// absolutely positioned controls already have a view but not a widget
|
||||
nsIView* view = nsnull;
|
||||
GetView(view);
|
||||
if (nsnull == view) {
|
||||
result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view);
|
||||
if (!NS_SUCCEEDED(result)) {
|
||||
NS_ASSERTION(0, "Could not create view for form control");
|
||||
aStatus = NS_FRAME_NOT_COMPLETE;
|
||||
return result;
|
||||
}
|
||||
|
||||
nsIFrame* parWithView;
|
||||
nsIView *parView;
|
||||
|
||||
GetParentWithView(parWithView);
|
||||
parWithView->GetView(parView);
|
||||
|
||||
// initialize the view as hidden since we don't know the (x,y) until Paint
|
||||
result = view->Init(viewMan, boundBox, parView, nsnull, nsViewVisibility_kHide);
|
||||
if (NS_OK != result) {
|
||||
NS_ASSERTION(0, "view initialization failed");
|
||||
aStatus = NS_FRAME_NOT_COMPLETE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
SetView(view);
|
||||
}
|
||||
|
||||
const nsIID& id = GetCID();
|
||||
nsWidgetInitData* initData = GetWidgetInitData(aPresContext); // needs to be deleted
|
||||
view->CreateWidget(id, initData);
|
||||
|
||||
if (nsnull != initData) {
|
||||
delete(initData);
|
||||
}
|
||||
|
||||
// set our widget
|
||||
result = GetWidget(view, &mWidget);
|
||||
if ((NS_OK == result) && mWidget) { // keep the ref on mWidget
|
||||
nsIFormControl* formControl = nsnull;
|
||||
result = mContent->QueryInterface(kIFormControlIID, (void**)&formControl);
|
||||
if ((NS_OK == result) && formControl) {
|
||||
// set the content's widget, so it can get content modified by the widget
|
||||
formControl->SetWidget(mWidget);
|
||||
NS_RELEASE(formControl);
|
||||
}
|
||||
PostCreateWidget(&aPresContext, aDesiredSize.width, aDesiredSize.height);
|
||||
mDidInit = PR_TRUE;
|
||||
} else {
|
||||
NS_ASSERTION(0, "could not get widget");
|
||||
}
|
||||
|
||||
if ((aDesiredSize.width != boundBox.width) || (aDesiredSize.height != boundBox.height)) {
|
||||
viewMan->ResizeView(view, aDesiredSize.width, aDesiredSize.height);
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(viewMan);
|
||||
}
|
||||
|
||||
aDesiredSize.ascent = aDesiredSize.height;
|
||||
aDesiredSize.descent = 0;
|
||||
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
aDesiredSize.maxElementSize->width = aDesiredSize.width;
|
||||
aDesiredSize.maxElementSize->height = aDesiredSize.height;
|
||||
}
|
||||
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
NS_METHOD
|
||||
nsFormControlFrame::Reflow(nsIPresContext& aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
nsIView* view = nsnull;
|
||||
GetView(view);
|
||||
if (nsnull == view) {
|
||||
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
||||
static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
|
||||
|
||||
nsresult result =
|
||||
nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID,
|
||||
(void **)&view);
|
||||
nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view);
|
||||
if (NS_OK != result) {
|
||||
NS_ASSERTION(0, "Could not create view for button");
|
||||
NS_ASSERTION(0, "Could not create view for form control");
|
||||
aStatus = NS_FRAME_NOT_COMPLETE;
|
||||
return result;
|
||||
}
|
||||
|
@ -251,19 +338,19 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext,
|
|||
GetParentWithView(parWithView);
|
||||
parWithView->GetView(parView);
|
||||
|
||||
const nsIID& id = GetCID();
|
||||
nsWidgetInitData* initData = GetWidgetInitData(aPresContext); // needs to be deleted
|
||||
// initialize the view as hidden since we don't know the (x,y) until Paint
|
||||
result = view->Init(viewMan, boundBox, parView,
|
||||
nsnull, nsViewVisibility_kHide);
|
||||
if (NS_OK != result) {
|
||||
NS_ASSERTION(0, "widget initialization failed");
|
||||
NS_ASSERTION(0, "view initialization failed");
|
||||
aStatus = NS_FRAME_NOT_COMPLETE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
|
||||
const nsIID& id = GetCID();
|
||||
nsWidgetInitData* initData = GetWidgetInitData(aPresContext); // needs to be deleted
|
||||
view->CreateWidget(id, initData);
|
||||
|
||||
if (nsnull != initData) {
|
||||
|
@ -314,6 +401,8 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFormControlFrame::AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
|
|
|
@ -119,6 +119,7 @@ protected:
|
|||
nsCursor mPreviousCursor;
|
||||
PRBool mGotFocus;
|
||||
nsRect mTranslatedRect;
|
||||
PRBool mDidInit;
|
||||
};
|
||||
|
||||
nsresult
|
||||
|
@ -142,6 +143,7 @@ nsHTMLButtonControlFrame::nsHTMLButtonControlFrame(nsIContent* aContent,
|
|||
mPreviousCursor = eCursor_standard;
|
||||
mGotFocus = PR_FALSE;
|
||||
mTranslatedRect = nsRect(0,0,0,0);
|
||||
mDidInit = PR_FALSE;
|
||||
}
|
||||
|
||||
nsHTMLButtonControlFrame::~nsHTMLButtonControlFrame()
|
||||
|
@ -534,32 +536,6 @@ nsHTMLButtonControlFrame::SetInitialChildList(nsIPresContext& aPresContext,
|
|||
// add ourself as an nsIFormControlFrame
|
||||
nsFormFrame::AddFormControlFrame(aPresContext, *this);
|
||||
|
||||
// create our view, we need a view to grab the mouse
|
||||
nsIView* view;
|
||||
GetView(view);
|
||||
if (!view) {
|
||||
nsresult result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view);
|
||||
nsIPresShell *presShell = aPresContext.GetShell();
|
||||
nsIViewManager *viewMan = presShell->GetViewManager();
|
||||
NS_RELEASE(presShell);
|
||||
|
||||
nsIFrame* parWithView;
|
||||
nsIView *parView;
|
||||
GetParentWithView(parWithView);
|
||||
parWithView->GetView(parView);
|
||||
// the view's size is not know yet, but its size will be kept in synch with our frame.
|
||||
nsRect boundBox(0, 0, 500, 500);
|
||||
result = view->Init(viewMan, boundBox, parView, nsnull);
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
SetView(view);
|
||||
|
||||
const nsStyleColor* color = (const nsStyleColor*) mStyleContext->GetStyleData(eStyleStruct_Color);
|
||||
// set the opacity
|
||||
viewMan->SetViewOpacity(view, color->mOpacity);
|
||||
|
||||
NS_RELEASE(viewMan);
|
||||
}
|
||||
|
||||
// cache our display type
|
||||
const nsStyleDisplay* styleDisplay;
|
||||
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) styleDisplay);
|
||||
|
@ -627,6 +603,35 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext& aPresContext,
|
|||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
if (!mDidInit) {
|
||||
// create our view, we need a view to grab the mouse
|
||||
nsIView* view;
|
||||
GetView(view);
|
||||
if (!view) {
|
||||
nsresult result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view);
|
||||
nsIPresShell *presShell = aPresContext.GetShell();
|
||||
nsIViewManager *viewMan = presShell->GetViewManager();
|
||||
NS_RELEASE(presShell);
|
||||
|
||||
nsIFrame* parWithView;
|
||||
nsIView *parView;
|
||||
GetParentWithView(parWithView);
|
||||
parWithView->GetView(parView);
|
||||
// the view's size is not know yet, but its size will be kept in synch with our frame.
|
||||
nsRect boundBox(0, 0, 500, 500);
|
||||
result = view->Init(viewMan, boundBox, parView, nsnull);
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
SetView(view);
|
||||
|
||||
const nsStyleColor* color = (const nsStyleColor*) mStyleContext->GetStyleData(eStyleStruct_Color);
|
||||
// set the opacity
|
||||
viewMan->SetViewOpacity(view, color->mOpacity);
|
||||
|
||||
NS_RELEASE(viewMan);
|
||||
}
|
||||
mDidInit = PR_TRUE;
|
||||
}
|
||||
|
||||
nsSize availSize(aReflowState.maxSize);
|
||||
|
||||
// reflow the child
|
||||
|
|
|
@ -101,6 +101,7 @@ protected:
|
|||
PRBool mControlIsInside;
|
||||
nsIFormControlFrame* mControlFrame;
|
||||
nsRect mTranslatedRect;
|
||||
PRBool mDidInit;
|
||||
};
|
||||
|
||||
nsresult
|
||||
|
@ -124,7 +125,8 @@ nsLabelFrame::nsLabelFrame(nsIContent* aContent,
|
|||
mPreviousCursor = eCursor_standard;
|
||||
mControlIsInside = PR_FALSE;
|
||||
mControlFrame = nsnull;
|
||||
mTranslatedRect = nsRect(0,0,0,0);
|
||||
mTranslatedRect = nsRect(0,0,0,0);
|
||||
mDidInit = PR_FALSE;
|
||||
}
|
||||
|
||||
nsLabelFrame::~nsLabelFrame()
|
||||
|
@ -400,28 +402,6 @@ nsLabelFrame::SetInitialChildList(nsIPresContext& aPresContext,
|
|||
nsIAtom* aListName,
|
||||
nsIFrame* aChildList)
|
||||
{
|
||||
// create our view, we need a view to grab the mouse
|
||||
nsIView* view;
|
||||
GetView(view);
|
||||
if (!view) {
|
||||
nsresult result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID,
|
||||
(void **)&view);
|
||||
nsIPresShell *presShell = aPresContext.GetShell();
|
||||
nsIViewManager *viewMan = presShell->GetViewManager();
|
||||
NS_RELEASE(presShell);
|
||||
|
||||
nsIFrame* parWithView;
|
||||
nsIView *parView;
|
||||
GetParentWithView(parWithView);
|
||||
parWithView->GetView(parView);
|
||||
// the view's size is not know yet, but its size will be kept in synch with our frame.
|
||||
nsRect boundBox(0, 0, 500, 500);
|
||||
result = view->Init(viewMan, boundBox, parView, nsnull);
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
SetView(view);
|
||||
NS_RELEASE(viewMan);
|
||||
}
|
||||
|
||||
// cache our display type
|
||||
const nsStyleDisplay* styleDisplay;
|
||||
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) styleDisplay);
|
||||
|
@ -460,6 +440,31 @@ nsLabelFrame::Reflow(nsIPresContext& aPresContext,
|
|||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
if (!mDidInit) {
|
||||
// create our view, we need a view to grab the mouse
|
||||
nsIView* view;
|
||||
GetView(view);
|
||||
if (!view) {
|
||||
nsresult result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID,
|
||||
(void **)&view);
|
||||
nsIPresShell *presShell = aPresContext.GetShell();
|
||||
nsIViewManager *viewMan = presShell->GetViewManager();
|
||||
NS_RELEASE(presShell);
|
||||
|
||||
nsIFrame* parWithView;
|
||||
nsIView *parView;
|
||||
GetParentWithView(parWithView);
|
||||
parWithView->GetView(parView);
|
||||
// the view's size is not know yet, but its size will be kept in synch with our frame.
|
||||
nsRect boundBox(0, 0, 500, 500);
|
||||
result = view->Init(viewMan, boundBox, parView, nsnull);
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
SetView(view);
|
||||
NS_RELEASE(viewMan);
|
||||
}
|
||||
mDidInit = PR_TRUE;
|
||||
}
|
||||
|
||||
if (nsnull == mControlFrame) {
|
||||
// check to see if a form control is referenced via the "for" attribute
|
||||
if (FindForControl(mControlFrame)) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче