From 19bedc8578c0bbfc93affb90e31a22c2dddd688a Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Fri, 19 Nov 1999 15:46:20 +0000 Subject: [PATCH] added bool parm to is DoneAddinContent r=dcone bug 18241 git-svn-id: svn://10.0.0.236/trunk@54006 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/forms/nsComboboxControlFrame.h | 2 +- mozilla/layout/forms/nsListControlFrame.cpp | 78 +++++++++++++++---- mozilla/layout/forms/nsListControlFrame.h | 4 +- .../html/forms/src/nsComboboxControlFrame.h | 2 +- .../html/forms/src/nsListControlFrame.cpp | 78 +++++++++++++++---- .../html/forms/src/nsListControlFrame.h | 4 +- .../forms/src/nsNativeSelectControlFrame.cpp | 4 +- 7 files changed, 134 insertions(+), 38 deletions(-) diff --git a/mozilla/layout/forms/nsComboboxControlFrame.h b/mozilla/layout/forms/nsComboboxControlFrame.h index 63cedddc925..4eb394a8e54 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.h +++ b/mozilla/layout/forms/nsComboboxControlFrame.h @@ -149,7 +149,7 @@ public: NS_IMETHOD RemoveOption(nsIPresContext* aPresContext, PRInt32 index); NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue); NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue); - NS_IMETHOD DoneAddingContent(); + NS_IMETHOD DoneAddingContent(PRBool aIsDone); //nsIDOMEventListener virtual nsresult MouseDown(nsIDOMEvent* aMouseEvent); diff --git a/mozilla/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index ceb49bef74a..073683dff58 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -193,6 +193,9 @@ nsListControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) //--------------------------------------------------------- nsresult nsListControlFrame::CountAllChild(nsIDOMNode * aNode, PRInt32& aCount) { + nsCOMPtr presShell; + mPresContext->GetShell(getter_AddRefs(presShell)); + nsresult status = NS_OK; nsIDOMNode * child; aNode->GetFirstChild(&child); @@ -205,6 +208,13 @@ nsresult nsListControlFrame::CountAllChild(nsIDOMNode * aNode, PRInt32& aCount) if (optGroup) { aCount++; + nsIFrame * frame; + nsCOMPtr content(do_QueryInterface(child)); + nsresult rvv = presShell->GetPrimaryFrameFor(content, &frame); + if (NS_FAILED(rvv) || nsnull == frame) { + return NS_ERROR_FAILURE; + } + // check for children PRBool hasChildren; status = child->HasChildNodes(&hasChildren); @@ -225,6 +235,27 @@ nsresult nsListControlFrame::CountAllChild(nsIDOMNode * aNode, PRInt32& aCount) child->QueryInterface(nsCOMTypeInfo::GetIID(),(void**) &option); if (option) { aCount++; + nsIFrame * frame; + nsCOMPtr content(do_QueryInterface(child)); + nsresult rvv = presShell->GetPrimaryFrameFor(content, &frame); + if (NS_FAILED(rvv) || nsnull == frame) { + return NS_ERROR_FAILURE; + } + } else { + // check for children + PRBool hasChildren; + status = child->HasChildNodes(&hasChildren); + if (NS_FAILED(status)) { + NS_RELEASE(child); + return status; + } + if (hasChildren) { + status = CountAllChild(child, aCount); + if (NS_FAILED(status)) { + NS_RELEASE(child); + return status; + } + } } } @@ -288,6 +319,19 @@ nsListControlFrame::Reflow(nsIPresContext& aPresContext, mHasBeenInitialized = PR_TRUE; InitSelectionCache(-1); // Reset sel cache so as not to send event Reset(mPresContext); + nsCOMPtr cmd; + nsresult rv = NS_NewHTMLReflowCommand(getter_AddRefs(cmd), this, nsIReflowCommand::StyleChanged); + if (NS_FAILED(rv)) { return rv; } + if (!cmd) { return NS_ERROR_NULL_POINTER; } + nsCOMPtr shell; + rv = mPresContext->GetShell(getter_AddRefs(shell)); + if (NS_FAILED(rv)) { return rv; } + if (!shell) { return NS_ERROR_NULL_POINTER; } + rv = shell->EnterReflowLock(); + if (NS_FAILED(rv)) { return rv; } + rv = shell->AppendReflowCommand(cmd); + // must do this next line regardless of result of AppendReflowCommand + shell->ExitReflowLock(PR_TRUE, PR_TRUE); } } @@ -1054,7 +1098,7 @@ nsListControlFrame::SetInitialChildList(nsIPresContext& aPresContext, // If all the content is here now check // to see if all the frames have been created - if (mIsAllContentHere) { + /*if (mIsAllContentHere) { // If all content and frames are here // the reset/initialize if (CheckIfAllFramesHere()) { @@ -1062,7 +1106,7 @@ nsListControlFrame::SetInitialChildList(nsIPresContext& aPresContext, Reset(&aPresContext); mHasBeenInitialized = PR_TRUE; } - } + }*/ return rv; } @@ -1750,7 +1794,7 @@ nsListControlFrame::ToggleSelected(PRInt32 aIndex) PRBool nsListControlFrame::CheckIfAllFramesHere() { // Get the number of optgroups and options - PRInt32 numContentItems = 0; +/* PRInt32 numContentItems = 0; nsCOMPtr node(do_QueryInterface(mContent)); if (node) { CountAllChild(node, numContentItems); @@ -1773,26 +1817,28 @@ PRBool nsListControlFrame::CheckIfAllFramesHere() child->GetNextSibling(&child); } } + */ // now make sure we have a frame each piece of content - mIsAllFramesHere = numFrames == numContentItems; + mIsAllFramesHere = PR_TRUE;//numFrames == numContentItems; return mIsAllFramesHere; } NS_IMETHODIMP -nsListControlFrame::DoneAddingContent() +nsListControlFrame::DoneAddingContent(PRBool aIsDone) { - mIsAllContentHere = PR_TRUE; - - // Here we check to see if all the frames have been created - // for all the content. - // If so, then we can initialize; - if (mIsAllFramesHere == PR_FALSE) { - // if all the frames are now present we can initalize - if (CheckIfAllFramesHere() && mPresContext) { - mHasBeenInitialized = PR_TRUE; - InitSelectionCache(-1); // Reset select cache so as not to send event - Reset(mPresContext); + mIsAllContentHere = aIsDone; + if (mIsAllContentHere) { + // Here we check to see if all the frames have been created + // for all the content. + // If so, then we can initialize; + if (mIsAllFramesHere == PR_FALSE) { + // if all the frames are now present we can initalize + if (CheckIfAllFramesHere() && mPresContext) { + mHasBeenInitialized = PR_TRUE; + InitSelectionCache(-1); // Reset select cache so as not to send event + Reset(mPresContext); + } } } return NS_OK; diff --git a/mozilla/layout/forms/nsListControlFrame.h b/mozilla/layout/forms/nsListControlFrame.h index adc81d7d61a..e533631e03b 100644 --- a/mozilla/layout/forms/nsListControlFrame.h +++ b/mozilla/layout/forms/nsListControlFrame.h @@ -129,7 +129,7 @@ public: NS_IMETHOD RemoveOption(nsIPresContext* aPresContext, PRInt32 index); NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue); NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue); - NS_IMETHOD DoneAddingContent(); + NS_IMETHOD DoneAddingContent(PRBool aIsDone); //nsIStatefulFrame NS_IMETHOD GetStateType(nsIPresContext* aPresContext, nsIStatefulFrame::StateType* aStateType); @@ -245,6 +245,8 @@ protected: PRBool mIsAllFramesHere; PRBool mHasBeenInitialized; + nsIFrame * mMainChild; + nsIPresContext* mPresContext; // XXX: Remove the need to cache the pres context. // XXX temprary only until full system mouse capture works diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.h b/mozilla/layout/html/forms/src/nsComboboxControlFrame.h index 63cedddc925..4eb394a8e54 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.h +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.h @@ -149,7 +149,7 @@ public: NS_IMETHOD RemoveOption(nsIPresContext* aPresContext, PRInt32 index); NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue); NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue); - NS_IMETHOD DoneAddingContent(); + NS_IMETHOD DoneAddingContent(PRBool aIsDone); //nsIDOMEventListener virtual nsresult MouseDown(nsIDOMEvent* aMouseEvent); diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.cpp b/mozilla/layout/html/forms/src/nsListControlFrame.cpp index ceb49bef74a..073683dff58 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsListControlFrame.cpp @@ -193,6 +193,9 @@ nsListControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) //--------------------------------------------------------- nsresult nsListControlFrame::CountAllChild(nsIDOMNode * aNode, PRInt32& aCount) { + nsCOMPtr presShell; + mPresContext->GetShell(getter_AddRefs(presShell)); + nsresult status = NS_OK; nsIDOMNode * child; aNode->GetFirstChild(&child); @@ -205,6 +208,13 @@ nsresult nsListControlFrame::CountAllChild(nsIDOMNode * aNode, PRInt32& aCount) if (optGroup) { aCount++; + nsIFrame * frame; + nsCOMPtr content(do_QueryInterface(child)); + nsresult rvv = presShell->GetPrimaryFrameFor(content, &frame); + if (NS_FAILED(rvv) || nsnull == frame) { + return NS_ERROR_FAILURE; + } + // check for children PRBool hasChildren; status = child->HasChildNodes(&hasChildren); @@ -225,6 +235,27 @@ nsresult nsListControlFrame::CountAllChild(nsIDOMNode * aNode, PRInt32& aCount) child->QueryInterface(nsCOMTypeInfo::GetIID(),(void**) &option); if (option) { aCount++; + nsIFrame * frame; + nsCOMPtr content(do_QueryInterface(child)); + nsresult rvv = presShell->GetPrimaryFrameFor(content, &frame); + if (NS_FAILED(rvv) || nsnull == frame) { + return NS_ERROR_FAILURE; + } + } else { + // check for children + PRBool hasChildren; + status = child->HasChildNodes(&hasChildren); + if (NS_FAILED(status)) { + NS_RELEASE(child); + return status; + } + if (hasChildren) { + status = CountAllChild(child, aCount); + if (NS_FAILED(status)) { + NS_RELEASE(child); + return status; + } + } } } @@ -288,6 +319,19 @@ nsListControlFrame::Reflow(nsIPresContext& aPresContext, mHasBeenInitialized = PR_TRUE; InitSelectionCache(-1); // Reset sel cache so as not to send event Reset(mPresContext); + nsCOMPtr cmd; + nsresult rv = NS_NewHTMLReflowCommand(getter_AddRefs(cmd), this, nsIReflowCommand::StyleChanged); + if (NS_FAILED(rv)) { return rv; } + if (!cmd) { return NS_ERROR_NULL_POINTER; } + nsCOMPtr shell; + rv = mPresContext->GetShell(getter_AddRefs(shell)); + if (NS_FAILED(rv)) { return rv; } + if (!shell) { return NS_ERROR_NULL_POINTER; } + rv = shell->EnterReflowLock(); + if (NS_FAILED(rv)) { return rv; } + rv = shell->AppendReflowCommand(cmd); + // must do this next line regardless of result of AppendReflowCommand + shell->ExitReflowLock(PR_TRUE, PR_TRUE); } } @@ -1054,7 +1098,7 @@ nsListControlFrame::SetInitialChildList(nsIPresContext& aPresContext, // If all the content is here now check // to see if all the frames have been created - if (mIsAllContentHere) { + /*if (mIsAllContentHere) { // If all content and frames are here // the reset/initialize if (CheckIfAllFramesHere()) { @@ -1062,7 +1106,7 @@ nsListControlFrame::SetInitialChildList(nsIPresContext& aPresContext, Reset(&aPresContext); mHasBeenInitialized = PR_TRUE; } - } + }*/ return rv; } @@ -1750,7 +1794,7 @@ nsListControlFrame::ToggleSelected(PRInt32 aIndex) PRBool nsListControlFrame::CheckIfAllFramesHere() { // Get the number of optgroups and options - PRInt32 numContentItems = 0; +/* PRInt32 numContentItems = 0; nsCOMPtr node(do_QueryInterface(mContent)); if (node) { CountAllChild(node, numContentItems); @@ -1773,26 +1817,28 @@ PRBool nsListControlFrame::CheckIfAllFramesHere() child->GetNextSibling(&child); } } + */ // now make sure we have a frame each piece of content - mIsAllFramesHere = numFrames == numContentItems; + mIsAllFramesHere = PR_TRUE;//numFrames == numContentItems; return mIsAllFramesHere; } NS_IMETHODIMP -nsListControlFrame::DoneAddingContent() +nsListControlFrame::DoneAddingContent(PRBool aIsDone) { - mIsAllContentHere = PR_TRUE; - - // Here we check to see if all the frames have been created - // for all the content. - // If so, then we can initialize; - if (mIsAllFramesHere == PR_FALSE) { - // if all the frames are now present we can initalize - if (CheckIfAllFramesHere() && mPresContext) { - mHasBeenInitialized = PR_TRUE; - InitSelectionCache(-1); // Reset select cache so as not to send event - Reset(mPresContext); + mIsAllContentHere = aIsDone; + if (mIsAllContentHere) { + // Here we check to see if all the frames have been created + // for all the content. + // If so, then we can initialize; + if (mIsAllFramesHere == PR_FALSE) { + // if all the frames are now present we can initalize + if (CheckIfAllFramesHere() && mPresContext) { + mHasBeenInitialized = PR_TRUE; + InitSelectionCache(-1); // Reset select cache so as not to send event + Reset(mPresContext); + } } } return NS_OK; diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.h b/mozilla/layout/html/forms/src/nsListControlFrame.h index adc81d7d61a..e533631e03b 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.h +++ b/mozilla/layout/html/forms/src/nsListControlFrame.h @@ -129,7 +129,7 @@ public: NS_IMETHOD RemoveOption(nsIPresContext* aPresContext, PRInt32 index); NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue); NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue); - NS_IMETHOD DoneAddingContent(); + NS_IMETHOD DoneAddingContent(PRBool aIsDone); //nsIStatefulFrame NS_IMETHOD GetStateType(nsIPresContext* aPresContext, nsIStatefulFrame::StateType* aStateType); @@ -245,6 +245,8 @@ protected: PRBool mIsAllFramesHere; PRBool mHasBeenInitialized; + nsIFrame * mMainChild; + nsIPresContext* mPresContext; // XXX: Remove the need to cache the pres context. // XXX temprary only until full system mouse capture works diff --git a/mozilla/layout/html/forms/src/nsNativeSelectControlFrame.cpp b/mozilla/layout/html/forms/src/nsNativeSelectControlFrame.cpp index 342520241ab..28e8df8b30b 100644 --- a/mozilla/layout/html/forms/src/nsNativeSelectControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsNativeSelectControlFrame.cpp @@ -157,7 +157,7 @@ public: NS_IMETHOD RemoveOption(nsIPresContext* aPresContext, PRInt32 aIndex); NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue); NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue); - NS_IMETHOD DoneAddingContent(); + NS_IMETHOD DoneAddingContent(PRBool aIsDone); //nsIStatefulFrame NS_IMETHOD GetStateType(nsIPresContext* aPresContext, nsIStatefulFrame::StateType* aStateType); @@ -1162,7 +1162,7 @@ nsNativeSelectControlFrame::ControlChanged(nsIPresContext* aPresContext) } NS_IMETHODIMP -nsNativeSelectControlFrame::DoneAddingContent() +nsNativeSelectControlFrame::DoneAddingContent(PRBool aIsDone) { return NS_OK; }