Changed to use a scroll frame for the BODY
git-svn-id: svn://10.0.0.236/trunk@13686 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -332,6 +332,8 @@ protected:
|
||||
|
||||
PRBool IsScrollable(nsIFrame* aFrame, const nsStyleDisplay* aDisplay);
|
||||
|
||||
nsIFrame* GetFrameFor(nsIPresShell* aPresShell, nsIContent* aContent);
|
||||
|
||||
protected:
|
||||
PRUint32 mInHeap : 1;
|
||||
PRUint32 mRefCnt : 31;
|
||||
@@ -1530,6 +1532,10 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
|
||||
aFrameSubTree->SetStyleContext(aPresContext, pseudoStyle);
|
||||
NS_RELEASE(pseudoStyle);
|
||||
|
||||
// Reset the scrolled frame's geometric and content parent
|
||||
aFrameSubTree->SetGeometricParent(scrollFrame);
|
||||
aFrameSubTree->SetContentParent(scrollFrame);
|
||||
|
||||
// Initialize the scroll frame
|
||||
scrollFrame->Init(*aPresContext, aFrameSubTree);
|
||||
aFrameSubTree = scrollFrame;
|
||||
@@ -1545,13 +1551,32 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
HTMLStyleSheetImpl::GetFrameFor(nsIPresShell* aPresShell, nsIContent* aContent)
|
||||
{
|
||||
nsIFrame* frame = aPresShell->FindFrameWithContent(aContent);
|
||||
|
||||
if (nsnull != frame) {
|
||||
// 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->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display);
|
||||
|
||||
if (display->IsBlockLevel() && IsScrollable(frame, display)) {
|
||||
frame->FirstChild(frame);
|
||||
}
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::ContentAppended(nsIPresContext* aPresContext,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{
|
||||
nsIPresShell* shell = aPresContext->GetShell();
|
||||
nsIFrame* parentFrame = shell->FindFrameWithContent(aContainer);
|
||||
nsIFrame* parentFrame = GetFrameFor(shell, aContainer);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
if (nsnull == parentFrame) {
|
||||
@@ -1595,7 +1620,7 @@ HTMLStyleSheetImpl::ContentAppended(nsIPresContext* aPresContext,
|
||||
NS_RELEASE(child);
|
||||
}
|
||||
|
||||
// adjust parent frame for table inner/outer frame
|
||||
// Adjust parent frame for table inner/outer frame
|
||||
// we need to do this here because we need both the parent frame and the constructed frame
|
||||
nsresult result = NS_OK;
|
||||
nsIFrame *adjustedParentFrame=parentFrame;
|
||||
|
||||
@@ -106,6 +106,7 @@ RootFrame::RootFrame(nsIContent* aContent)
|
||||
NS_IMETHODIMP
|
||||
RootFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList)
|
||||
{
|
||||
#if 0
|
||||
// Construct the root content frame and set its style context
|
||||
mFirstChild = new RootContentFrame(mContent, this);
|
||||
nsIStyleContext* pseudoStyleContext =
|
||||
@@ -121,6 +122,10 @@ RootFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList)
|
||||
|
||||
// Queue up the frames for the root content frame
|
||||
return mFirstChild->Init(aPresContext, aChildList);
|
||||
#else
|
||||
mFirstChild = aChildList;
|
||||
return NS_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -155,6 +160,11 @@ RootFrame::Reflow(nsIPresContext& aPresContext,
|
||||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState,
|
||||
aReflowState.maxSize);
|
||||
// XXX HACK
|
||||
kidReflowState.widthConstraint = eHTMLFrameConstraint_Fixed;
|
||||
kidReflowState.minWidth = aReflowState.maxSize.width;
|
||||
kidReflowState.heightConstraint = eHTMLFrameConstraint_Fixed;
|
||||
kidReflowState.minHeight = aReflowState.maxSize.height;
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
|
||||
if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
|
||||
@@ -106,6 +106,7 @@ RootFrame::RootFrame(nsIContent* aContent)
|
||||
NS_IMETHODIMP
|
||||
RootFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList)
|
||||
{
|
||||
#if 0
|
||||
// Construct the root content frame and set its style context
|
||||
mFirstChild = new RootContentFrame(mContent, this);
|
||||
nsIStyleContext* pseudoStyleContext =
|
||||
@@ -121,6 +122,10 @@ RootFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList)
|
||||
|
||||
// Queue up the frames for the root content frame
|
||||
return mFirstChild->Init(aPresContext, aChildList);
|
||||
#else
|
||||
mFirstChild = aChildList;
|
||||
return NS_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -155,6 +160,11 @@ RootFrame::Reflow(nsIPresContext& aPresContext,
|
||||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState,
|
||||
aReflowState.maxSize);
|
||||
// XXX HACK
|
||||
kidReflowState.widthConstraint = eHTMLFrameConstraint_Fixed;
|
||||
kidReflowState.minWidth = aReflowState.maxSize.width;
|
||||
kidReflowState.heightConstraint = eHTMLFrameConstraint_Fixed;
|
||||
kidReflowState.minHeight = aReflowState.maxSize.height;
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
|
||||
if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
|
||||
@@ -187,10 +187,12 @@ nsScrollFrame::CreateScrollingView()
|
||||
view->QueryInterface(kScrollViewIID, (void**)&scrollingView);
|
||||
|
||||
// Set the scroll prefrence
|
||||
#if 0
|
||||
nsScrollPreference scrollPref = (NS_STYLE_OVERFLOW_SCROLL == display->mOverflow)
|
||||
? nsScrollPreference_kAlwaysScroll :
|
||||
nsScrollPreference_kAuto;
|
||||
scrollingView->SetScrollPreference(scrollPref);
|
||||
#endif
|
||||
|
||||
// Set the scrolling view's insets to whatever our border is
|
||||
nsMargin border;
|
||||
@@ -293,6 +295,11 @@ nsScrollFrame::Reflow(nsIPresContext& aPresContext,
|
||||
// The reflow state width reflects space for the content area only, so don't
|
||||
// subtract for borders...
|
||||
scrollAreaSize.width = aReflowState.minWidth;
|
||||
|
||||
if (eHTMLFrameConstraint_Fixed == aReflowState.widthConstraint) {
|
||||
scrollAreaSize.width -= border.left + border.right;
|
||||
scrollAreaSize.width -= NSToCoordRound(sbWidth);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Use the max width in the reflow state
|
||||
@@ -311,6 +318,16 @@ nsScrollFrame::Reflow(nsIPresContext& aPresContext,
|
||||
// The reflow state height reflects space for the content area only, so don't
|
||||
// subtract for borders...
|
||||
scrollAreaSize.height = aReflowState.minHeight;
|
||||
|
||||
if (eHTMLFrameConstraint_Fixed == aReflowState.heightConstraint) {
|
||||
scrollAreaSize.height -= border.top + border.bottom;
|
||||
|
||||
// If scrollbars are always visible then subtract for the
|
||||
// height of the horizontal scrollbar
|
||||
if (NS_STYLE_OVERFLOW_SCROLL == display->mOverflow) {
|
||||
scrollAreaSize.height -= NSToCoordRound(sbHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Use the max height in the reflow state
|
||||
@@ -340,7 +357,7 @@ nsScrollFrame::Reflow(nsIPresContext& aPresContext,
|
||||
|
||||
// Make sure the scrolled frame fills the entire scroll area along a
|
||||
// fixed dimension
|
||||
if (aReflowState.HaveConstrainedHeight()) {
|
||||
if ((eHTMLFrameConstraint_Fixed == aReflowState.heightConstraint) || aReflowState.HaveConstrainedHeight()) {
|
||||
if (kidDesiredSize.height < scrollAreaSize.height) {
|
||||
kidDesiredSize.height = scrollAreaSize.height;
|
||||
}
|
||||
@@ -354,7 +371,7 @@ nsScrollFrame::Reflow(nsIPresContext& aPresContext,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aReflowState.HaveConstrainedWidth()) {
|
||||
if ((eHTMLFrameConstraint_Fixed == aReflowState.widthConstraint) || aReflowState.HaveConstrainedWidth()) {
|
||||
if (kidDesiredSize.width < scrollAreaSize.width) {
|
||||
kidDesiredSize.width = scrollAreaSize.width;
|
||||
}
|
||||
@@ -378,14 +395,14 @@ nsScrollFrame::Reflow(nsIPresContext& aPresContext,
|
||||
|
||||
// Compute our desired size. If our size was fixed then use the fixed size;
|
||||
// otherwise, shrink wrap around the scrolled frame
|
||||
if (aReflowState.HaveConstrainedWidth()) {
|
||||
if ((eHTMLFrameConstraint_Fixed == aReflowState.widthConstraint) || aReflowState.HaveConstrainedWidth()) {
|
||||
aDesiredSize.width = scrollAreaSize.width;
|
||||
} else {
|
||||
aDesiredSize.width = kidDesiredSize.width;
|
||||
}
|
||||
aDesiredSize.width += border.left + border.right + NSToCoordRound(sbWidth);
|
||||
|
||||
if (aReflowState.HaveConstrainedHeight()) {
|
||||
if ((eHTMLFrameConstraint_Fixed == aReflowState.heightConstraint) || aReflowState.HaveConstrainedHeight()) {
|
||||
aDesiredSize.height = scrollAreaSize.height;
|
||||
} else {
|
||||
aDesiredSize.height = kidDesiredSize.height;
|
||||
|
||||
@@ -27,7 +27,7 @@ BODY {
|
||||
line-height: normal;
|
||||
//XXX not yet... margin: 8px;
|
||||
padding: 8px;
|
||||
overflow: auto;
|
||||
overflow: scroll;
|
||||
}
|
||||
|
||||
FRAMESET {
|
||||
|
||||
@@ -332,6 +332,8 @@ protected:
|
||||
|
||||
PRBool IsScrollable(nsIFrame* aFrame, const nsStyleDisplay* aDisplay);
|
||||
|
||||
nsIFrame* GetFrameFor(nsIPresShell* aPresShell, nsIContent* aContent);
|
||||
|
||||
protected:
|
||||
PRUint32 mInHeap : 1;
|
||||
PRUint32 mRefCnt : 31;
|
||||
@@ -1530,6 +1532,10 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
|
||||
aFrameSubTree->SetStyleContext(aPresContext, pseudoStyle);
|
||||
NS_RELEASE(pseudoStyle);
|
||||
|
||||
// Reset the scrolled frame's geometric and content parent
|
||||
aFrameSubTree->SetGeometricParent(scrollFrame);
|
||||
aFrameSubTree->SetContentParent(scrollFrame);
|
||||
|
||||
// Initialize the scroll frame
|
||||
scrollFrame->Init(*aPresContext, aFrameSubTree);
|
||||
aFrameSubTree = scrollFrame;
|
||||
@@ -1545,13 +1551,32 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
HTMLStyleSheetImpl::GetFrameFor(nsIPresShell* aPresShell, nsIContent* aContent)
|
||||
{
|
||||
nsIFrame* frame = aPresShell->FindFrameWithContent(aContent);
|
||||
|
||||
if (nsnull != frame) {
|
||||
// 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->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display);
|
||||
|
||||
if (display->IsBlockLevel() && IsScrollable(frame, display)) {
|
||||
frame->FirstChild(frame);
|
||||
}
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::ContentAppended(nsIPresContext* aPresContext,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{
|
||||
nsIPresShell* shell = aPresContext->GetShell();
|
||||
nsIFrame* parentFrame = shell->FindFrameWithContent(aContainer);
|
||||
nsIFrame* parentFrame = GetFrameFor(shell, aContainer);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
if (nsnull == parentFrame) {
|
||||
@@ -1595,7 +1620,7 @@ HTMLStyleSheetImpl::ContentAppended(nsIPresContext* aPresContext,
|
||||
NS_RELEASE(child);
|
||||
}
|
||||
|
||||
// adjust parent frame for table inner/outer frame
|
||||
// Adjust parent frame for table inner/outer frame
|
||||
// we need to do this here because we need both the parent frame and the constructed frame
|
||||
nsresult result = NS_OK;
|
||||
nsIFrame *adjustedParentFrame=parentFrame;
|
||||
|
||||
@@ -332,6 +332,8 @@ protected:
|
||||
|
||||
PRBool IsScrollable(nsIFrame* aFrame, const nsStyleDisplay* aDisplay);
|
||||
|
||||
nsIFrame* GetFrameFor(nsIPresShell* aPresShell, nsIContent* aContent);
|
||||
|
||||
protected:
|
||||
PRUint32 mInHeap : 1;
|
||||
PRUint32 mRefCnt : 31;
|
||||
@@ -1530,6 +1532,10 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
|
||||
aFrameSubTree->SetStyleContext(aPresContext, pseudoStyle);
|
||||
NS_RELEASE(pseudoStyle);
|
||||
|
||||
// Reset the scrolled frame's geometric and content parent
|
||||
aFrameSubTree->SetGeometricParent(scrollFrame);
|
||||
aFrameSubTree->SetContentParent(scrollFrame);
|
||||
|
||||
// Initialize the scroll frame
|
||||
scrollFrame->Init(*aPresContext, aFrameSubTree);
|
||||
aFrameSubTree = scrollFrame;
|
||||
@@ -1545,13 +1551,32 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
HTMLStyleSheetImpl::GetFrameFor(nsIPresShell* aPresShell, nsIContent* aContent)
|
||||
{
|
||||
nsIFrame* frame = aPresShell->FindFrameWithContent(aContent);
|
||||
|
||||
if (nsnull != frame) {
|
||||
// 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->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display);
|
||||
|
||||
if (display->IsBlockLevel() && IsScrollable(frame, display)) {
|
||||
frame->FirstChild(frame);
|
||||
}
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::ContentAppended(nsIPresContext* aPresContext,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{
|
||||
nsIPresShell* shell = aPresContext->GetShell();
|
||||
nsIFrame* parentFrame = shell->FindFrameWithContent(aContainer);
|
||||
nsIFrame* parentFrame = GetFrameFor(shell, aContainer);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
if (nsnull == parentFrame) {
|
||||
@@ -1595,7 +1620,7 @@ HTMLStyleSheetImpl::ContentAppended(nsIPresContext* aPresContext,
|
||||
NS_RELEASE(child);
|
||||
}
|
||||
|
||||
// adjust parent frame for table inner/outer frame
|
||||
// Adjust parent frame for table inner/outer frame
|
||||
// we need to do this here because we need both the parent frame and the constructed frame
|
||||
nsresult result = NS_OK;
|
||||
nsIFrame *adjustedParentFrame=parentFrame;
|
||||
|
||||
@@ -27,7 +27,7 @@ BODY {
|
||||
line-height: normal;
|
||||
//XXX not yet... margin: 8px;
|
||||
padding: 8px;
|
||||
overflow: auto;
|
||||
overflow: scroll;
|
||||
}
|
||||
|
||||
FRAMESET {
|
||||
|
||||
Reference in New Issue
Block a user