Bug 251501. Refactor handling where frames get inserted on content insertion. r+sr=dbaron

This commit is contained in:
roc+%cs.cmu.edu 2004-07-18 12:02:53 +00:00
parent 63bcb7774f
commit b751c53c83
20 changed files with 100 additions and 120 deletions

View File

@ -7364,59 +7364,10 @@ nsCSSFrameConstructor::GetFrameFor(nsIPresShell* aPresShell,
nsIFrame* frame;
aPresShell->GetPrimaryFrameFor(aContent, &frame);
if (nsnull != frame) {
// Check to see if the content is a select and
// then if it has a drop down (thus making it a combobox)
// The drop down is a ListControlFrame derived from a
// nsHTMLScrollFrame then get the area frame and that will be the parent
// What is unclear here, is if any of this fails, should it return
// the nsComboboxControlFrame or null?
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement;
nsresult res = aContent->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement),
(void**)getter_AddRefs(selectElement));
if (NS_SUCCEEDED(res) && selectElement) {
nsIComboboxControlFrame * comboboxFrame;
res = frame->QueryInterface(NS_GET_IID(nsIComboboxControlFrame),
(void**)&comboboxFrame);
nsIFrame * listFrame;
if (NS_SUCCEEDED(res) && comboboxFrame) {
comboboxFrame->GetDropDown(&listFrame);
} else {
listFrame = frame;
}
if (!frame)
return nsnull;
if (listFrame != nsnull) {
nsIListControlFrame * list;
res = listFrame->QueryInterface(NS_GET_IID(nsIListControlFrame),
(void**)&list);
if (NS_SUCCEEDED(res) && list) {
list->GetOptionsContainer(aPresContext, &frame);
}
}
} else {
// If the primary frame is a scroll frame, then get the scrolled frame.
// That's the frame that gets the reflow command
const nsStyleDisplay* display = frame->GetStyleDisplay();
// If the primary frame supports IScrollableFrame, then get the scrolled frame.
// That's the frame that gets the reflow command
nsIScrollableFrame *pScrollableFrame = nsnull;
if (NS_SUCCEEDED( frame->QueryInterface(NS_GET_IID(nsIScrollableFrame),
(void **)&pScrollableFrame) ))
{
pScrollableFrame->GetScrolledFrame( aPresContext, frame );
}
// if we get an outer table frame use its 1st child which is a table inner frame
// if we get a table cell frame use its 1st child which is an area frame
else if ((NS_STYLE_DISPLAY_TABLE == display->mDisplay) ||
(NS_STYLE_DISPLAY_TABLE_CELL == display->mDisplay)) {
frame = frame->GetFirstChild(nsnull);
}
}
}
return frame;
return frame->GetContentInsertionFrame();
}
nsIFrame*

View File

@ -549,6 +549,11 @@ public:
*/
nsIContent* GetContent() const { return mContent; }
/**
* Get the frame that should be the parent for the frames of child elements
*/
virtual nsIFrame* GetContentInsertionFrame() { return this; }
/**
* Get the offsets of the frame. most will be 0,0
*

View File

@ -1962,6 +1962,10 @@ nsComboboxControlFrame::GetProperty(nsIAtom* aName, nsAString& aValue)
return result;
}
nsIFrame*
nsComboboxControlFrame::GetContentInsertionFrame() {
return mDropdownFrame->GetContentInsertionFrame();
}
NS_IMETHODIMP
nsComboboxControlFrame::CreateDisplayFrame(nsIPresContext* aPresContext)

View File

@ -138,6 +138,8 @@ public:
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame);
virtual nsIFrame* GetContentInsertionFrame();
// nsIFormControlFrame
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
NS_IMETHOD GetName(nsAString* aName);

View File

@ -1441,6 +1441,12 @@ nsListControlFrame::IsOptionElement(nsIContent* aContent)
return result;
}
nsIFrame*
nsListControlFrame::GetContentInsertionFrame() {
nsIFrame* frame;
GetOptionsContainer(GetPresContext(), &frame);
return frame->GetContentInsertionFrame();
}
//---------------------------------------------------------
// Starts at the passed in content object and walks up the

View File

@ -119,6 +119,8 @@ public:
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags = 0);
virtual nsIFrame* GetContentInsertionFrame();
/**
* Get the "type" of the frame
*

View File

@ -102,10 +102,8 @@ nsHTMLScrollFrame::nsHTMLScrollFrame(nsIPresShell* aShell, PRBool aIsRoot)
NS_IMETHODIMP
nsHTMLScrollFrame::GetScrolledFrame(nsIPresContext* aPresContext, nsIFrame *&aScrolledFrame) const
{
nsIBox* child = nsnull;
mInner.mScrollAreaBox->GetChildBox(&child);
child->GetFrame(&aScrolledFrame);
return NS_OK;
aScrolledFrame = mInner.GetScrolledFrame();
return NS_OK;
}
NS_IMETHODIMP
@ -644,10 +642,8 @@ nsXULScrollFrame::nsXULScrollFrame(nsIPresShell* aShell, PRBool aIsRoot)
NS_IMETHODIMP
nsXULScrollFrame::GetScrolledFrame(nsIPresContext* aPresContext, nsIFrame *&aScrolledFrame) const
{
nsIBox* child = nsnull;
mInner.mScrollAreaBox->GetChildBox(&child);
child->GetFrame(&aScrolledFrame);
return NS_OK;
aScrolledFrame = mInner.GetScrolledFrame();
return NS_OK;
}
NS_IMETHODIMP

View File

@ -112,6 +112,14 @@ public:
nsIScrollableView* GetScrollableView() const;
nsIFrame* GetScrolledFrame() const {
nsIBox* childBox;
nsIFrame* frame;
mScrollAreaBox->GetChildBox(&childBox);
childBox->GetFrame(&frame);
return frame;
}
void ScrollbarChanged(nsIPresContext* aPresContext, nscoord aX, nscoord aY, PRUint32 aFlags);
void SetScrollbarVisibility(nsIBox* aScrollbar, PRBool aVisible);
@ -207,6 +215,10 @@ public:
PRInt32& aContentOffsetEnd,
PRBool& aBeginFrameContent);
virtual nsIFrame* GetContentInsertionFrame() {
return mInner.GetScrolledFrame()->GetContentInsertionFrame();
}
// nsIAnonymousContentCreator
NS_IMETHOD CreateAnonymousContent(nsIPresContext* aPresContext,
nsISupportsArray& aAnonymousItems);
@ -330,6 +342,10 @@ public:
PRInt32& aContentOffsetEnd,
PRBool& aBeginFrameContent);
virtual nsIFrame* GetContentInsertionFrame() {
return mInner.GetScrolledFrame()->GetContentInsertionFrame();
}
// nsIAnonymousContentCreator
NS_IMETHOD CreateAnonymousContent(nsIPresContext* aPresContext,
nsISupportsArray& aAnonymousItems);

View File

@ -549,6 +549,11 @@ public:
*/
nsIContent* GetContent() const { return mContent; }
/**
* Get the frame that should be the parent for the frames of child elements
*/
virtual nsIFrame* GetContentInsertionFrame() { return this; }
/**
* Get the offsets of the frame. most will be 0,0
*

View File

@ -102,10 +102,8 @@ nsHTMLScrollFrame::nsHTMLScrollFrame(nsIPresShell* aShell, PRBool aIsRoot)
NS_IMETHODIMP
nsHTMLScrollFrame::GetScrolledFrame(nsIPresContext* aPresContext, nsIFrame *&aScrolledFrame) const
{
nsIBox* child = nsnull;
mInner.mScrollAreaBox->GetChildBox(&child);
child->GetFrame(&aScrolledFrame);
return NS_OK;
aScrolledFrame = mInner.GetScrolledFrame();
return NS_OK;
}
NS_IMETHODIMP
@ -644,10 +642,8 @@ nsXULScrollFrame::nsXULScrollFrame(nsIPresShell* aShell, PRBool aIsRoot)
NS_IMETHODIMP
nsXULScrollFrame::GetScrolledFrame(nsIPresContext* aPresContext, nsIFrame *&aScrolledFrame) const
{
nsIBox* child = nsnull;
mInner.mScrollAreaBox->GetChildBox(&child);
child->GetFrame(&aScrolledFrame);
return NS_OK;
aScrolledFrame = mInner.GetScrolledFrame();
return NS_OK;
}
NS_IMETHODIMP

View File

@ -112,6 +112,14 @@ public:
nsIScrollableView* GetScrollableView() const;
nsIFrame* GetScrolledFrame() const {
nsIBox* childBox;
nsIFrame* frame;
mScrollAreaBox->GetChildBox(&childBox);
childBox->GetFrame(&frame);
return frame;
}
void ScrollbarChanged(nsIPresContext* aPresContext, nscoord aX, nscoord aY, PRUint32 aFlags);
void SetScrollbarVisibility(nsIBox* aScrollbar, PRBool aVisible);
@ -207,6 +215,10 @@ public:
PRInt32& aContentOffsetEnd,
PRBool& aBeginFrameContent);
virtual nsIFrame* GetContentInsertionFrame() {
return mInner.GetScrolledFrame()->GetContentInsertionFrame();
}
// nsIAnonymousContentCreator
NS_IMETHOD CreateAnonymousContent(nsIPresContext* aPresContext,
nsISupportsArray& aAnonymousItems);
@ -330,6 +342,10 @@ public:
PRInt32& aContentOffsetEnd,
PRBool& aBeginFrameContent);
virtual nsIFrame* GetContentInsertionFrame() {
return mInner.GetScrolledFrame()->GetContentInsertionFrame();
}
// nsIAnonymousContentCreator
NS_IMETHOD CreateAnonymousContent(nsIPresContext* aPresContext,
nsISupportsArray& aAnonymousItems);

View File

@ -1962,6 +1962,10 @@ nsComboboxControlFrame::GetProperty(nsIAtom* aName, nsAString& aValue)
return result;
}
nsIFrame*
nsComboboxControlFrame::GetContentInsertionFrame() {
return mDropdownFrame->GetContentInsertionFrame();
}
NS_IMETHODIMP
nsComboboxControlFrame::CreateDisplayFrame(nsIPresContext* aPresContext)

View File

@ -138,6 +138,8 @@ public:
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame);
virtual nsIFrame* GetContentInsertionFrame();
// nsIFormControlFrame
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
NS_IMETHOD GetName(nsAString* aName);

View File

@ -1441,6 +1441,12 @@ nsListControlFrame::IsOptionElement(nsIContent* aContent)
return result;
}
nsIFrame*
nsListControlFrame::GetContentInsertionFrame() {
nsIFrame* frame;
GetOptionsContainer(GetPresContext(), &frame);
return frame->GetContentInsertionFrame();
}
//---------------------------------------------------------
// Starts at the passed in content object and walks up the

View File

@ -119,6 +119,8 @@ public:
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags = 0);
virtual nsIFrame* GetContentInsertionFrame();
/**
* Get the "type" of the frame
*

View File

@ -7364,59 +7364,10 @@ nsCSSFrameConstructor::GetFrameFor(nsIPresShell* aPresShell,
nsIFrame* frame;
aPresShell->GetPrimaryFrameFor(aContent, &frame);
if (nsnull != frame) {
// Check to see if the content is a select and
// then if it has a drop down (thus making it a combobox)
// The drop down is a ListControlFrame derived from a
// nsHTMLScrollFrame then get the area frame and that will be the parent
// What is unclear here, is if any of this fails, should it return
// the nsComboboxControlFrame or null?
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement;
nsresult res = aContent->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement),
(void**)getter_AddRefs(selectElement));
if (NS_SUCCEEDED(res) && selectElement) {
nsIComboboxControlFrame * comboboxFrame;
res = frame->QueryInterface(NS_GET_IID(nsIComboboxControlFrame),
(void**)&comboboxFrame);
nsIFrame * listFrame;
if (NS_SUCCEEDED(res) && comboboxFrame) {
comboboxFrame->GetDropDown(&listFrame);
} else {
listFrame = frame;
}
if (!frame)
return nsnull;
if (listFrame != nsnull) {
nsIListControlFrame * list;
res = listFrame->QueryInterface(NS_GET_IID(nsIListControlFrame),
(void**)&list);
if (NS_SUCCEEDED(res) && list) {
list->GetOptionsContainer(aPresContext, &frame);
}
}
} else {
// If the primary frame is a scroll frame, then get the scrolled frame.
// That's the frame that gets the reflow command
const nsStyleDisplay* display = frame->GetStyleDisplay();
// If the primary frame supports IScrollableFrame, then get the scrolled frame.
// That's the frame that gets the reflow command
nsIScrollableFrame *pScrollableFrame = nsnull;
if (NS_SUCCEEDED( frame->QueryInterface(NS_GET_IID(nsIScrollableFrame),
(void **)&pScrollableFrame) ))
{
pScrollableFrame->GetScrolledFrame( aPresContext, frame );
}
// if we get an outer table frame use its 1st child which is a table inner frame
// if we get a table cell frame use its 1st child which is an area frame
else if ((NS_STYLE_DISPLAY_TABLE == display->mDisplay) ||
(NS_STYLE_DISPLAY_TABLE_CELL == display->mDisplay)) {
frame = frame->GetFirstChild(nsnull);
}
}
}
return frame;
return frame->GetContentInsertionFrame();
}
nsIFrame*

View File

@ -116,6 +116,10 @@ public:
nsIAtom* aListName,
nsIFrame* aOldFrame);
virtual nsIFrame* GetContentInsertionFrame() {
return GetFirstChild(nsnull)->GetContentInsertionFrame();
}
virtual void NotifyPercentHeight(const nsHTMLReflowState& aReflowState);
virtual PRBool NeedsToObserve(const nsHTMLReflowState& aReflowState);

View File

@ -122,6 +122,10 @@ public:
nsIAtom* aListName,
nsIFrame* aOldFrame);
virtual nsIFrame* GetContentInsertionFrame() {
return GetFirstChild(nsnull)->GetContentInsertionFrame();
}
#ifdef ACCESSIBILITY
NS_IMETHOD GetAccessible(nsIAccessible** aAccessible);
#endif

View File

@ -116,6 +116,10 @@ public:
nsIAtom* aListName,
nsIFrame* aOldFrame);
virtual nsIFrame* GetContentInsertionFrame() {
return GetFirstChild(nsnull)->GetContentInsertionFrame();
}
virtual void NotifyPercentHeight(const nsHTMLReflowState& aReflowState);
virtual PRBool NeedsToObserve(const nsHTMLReflowState& aReflowState);

View File

@ -122,6 +122,10 @@ public:
nsIAtom* aListName,
nsIFrame* aOldFrame);
virtual nsIFrame* GetContentInsertionFrame() {
return GetFirstChild(nsnull)->GetContentInsertionFrame();
}
#ifdef ACCESSIBILITY
NS_IMETHOD GetAccessible(nsIAccessible** aAccessible);
#endif