From cc9970fac017be27aacf16f5ba3ac659e01df341 Mon Sep 17 00:00:00 2001 From: "troy%netscape.com" Date: Wed, 11 Nov 1998 04:43:13 +0000 Subject: [PATCH] Eliminated the hack where the scroll frame was creating a BODY wrapper for the scrolled frame. Now the frame construction code creates the wrapper frame git-svn-id: svn://10.0.0.236/trunk@14413 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/style/src/nsHTMLStyleSheet.cpp | 49 +++++++++++++++---- .../layout/html/base/src/nsScrollFrame.cpp | 27 ---------- .../html/style/src/nsHTMLStyleSheet.cpp | 49 +++++++++++++++---- mozilla/layout/style/nsHTMLStyleSheet.cpp | 49 +++++++++++++++---- 4 files changed, 117 insertions(+), 57 deletions(-) diff --git a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp index ffa5697b695..c3158cf8cac 100644 --- a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp @@ -1476,25 +1476,49 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext, // XXX Applies to replaced elements, too, but how to tell if the element // is replaced? nsIFrame* scrollFrame = nsnull; + nsIFrame* wrapperFrame = nsnull; // If we're paginated then don't ever make the BODY scrollable - // XXX Use a special BODY rule for paged media + // XXX Use a special BODY rule for paged media... if (!(aPresContext->IsPaginated() && (nsHTMLAtoms::body == tag))) { if (display->IsBlockLevel() && IsScrollable(aPresContext, display)) { // Create a scroll frame which will wrap the frame that needs to // be scrolled if NS_SUCCEEDED(NS_NewScrollFrame(aContent, aParentFrame, scrollFrame)) { + nsIStyleContext* scrolledPseudoStyle; + // The scroll frame gets the original style context, and the scrolled - // frame gets a SCROLLED-CONTENT pseudo element style context. + // frame gets a SCROLLED-CONTENT pseudo element style context that + // inherits the background properties scrollFrame->SetStyleContext(aPresContext, styleContext); - - nsIStyleContext* pseudoStyle; - pseudoStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsHTMLAtoms::scrolledContentPseudo, - styleContext); + scrolledPseudoStyle = aPresContext->ResolvePseudoStyleContextFor + (aContent, nsHTMLAtoms::scrolledContentPseudo, + styleContext); NS_RELEASE(styleContext); - styleContext = pseudoStyle; - aParentFrame = scrollFrame; + + // If the content element can contain children then wrap it in a + // BODY frame. Don't do this for the BODY element, though... + PRBool isContainer; + aContent->CanContainChildren(isContainer); + if (isContainer && (tag != nsHTMLAtoms::body)) { + NS_NewBodyFrame(aContent, scrollFrame, wrapperFrame, NS_BODY_SHRINK_WRAP); + wrapperFrame->SetStyleContext(aPresContext, scrolledPseudoStyle); + + // The wrapped frame also gets a pseudo style context, but it doesn't + // inherit any background properties + // XXX We should define something like :WRAPPED-FRAME in ua.css + nsIStyleContext* wrappedPseudoStyle; + wrappedPseudoStyle = aPresContext->ResolvePseudoStyleContextFor + (aContent, nsHTMLAtoms::columnPseudo, + scrolledPseudoStyle); + NS_RELEASE(scrolledPseudoStyle); + aParentFrame = wrapperFrame; + styleContext = wrappedPseudoStyle; + + } else { + aParentFrame = scrollFrame; + styleContext = scrolledPseudoStyle; + } } } } @@ -1514,7 +1538,12 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext, // Set the scroll frame's initial child list and return the scroll frame // as the frame sub-tree if (nsnull != scrollFrame) { - scrollFrame->SetInitialChildList(*aPresContext, nsnull, aFrameSubTree); + if (nsnull != wrapperFrame) { + wrapperFrame->SetInitialChildList(*aPresContext, nsnull, aFrameSubTree); + scrollFrame->SetInitialChildList(*aPresContext, nsnull, wrapperFrame); + } else { + scrollFrame->SetInitialChildList(*aPresContext, nsnull, aFrameSubTree); + } aFrameSubTree = scrollFrame; } } diff --git a/mozilla/layout/html/base/src/nsScrollFrame.cpp b/mozilla/layout/html/base/src/nsScrollFrame.cpp index 80ca4e408e1..8ed37c9bd63 100644 --- a/mozilla/layout/html/base/src/nsScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsScrollFrame.cpp @@ -48,10 +48,6 @@ class nsScrollFrame : public nsHTMLContainerFrame { public: nsScrollFrame(nsIContent* aContent, nsIFrame* aParent); - NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext, - nsIAtom* aListName, - nsIFrame* aChildList); - NS_IMETHOD DidReflow(nsIPresContext& aPresContext, nsDidReflowStatus aStatus); @@ -78,29 +74,6 @@ nsScrollFrame::nsScrollFrame(nsIContent* aContent, nsIFrame* aParent) { } -NS_IMETHODIMP -nsScrollFrame::SetInitialChildList(nsIPresContext& aPresContext, - nsIAtom* aListName, - nsIFrame* aChildList) -{ - NS_PRECONDITION(nsnull != aChildList, "no child frame"); - NS_PRECONDITION(LengthOf(aChildList) == 1, "wrong number child frames"); - - // Unless it's already a body frame, scrolled frames that are a container - // need to be wrapped in a body frame. - // XXX It would be nice to have a cleaner way to do this... - nsIAbsoluteItems* absoluteItems; - if (NS_FAILED(aChildList->QueryInterface(kIAbsoluteItemsIID, (void**)&absoluteItems))) { - nsIFrame* wrapperFrame; - if (CreateWrapperFrame(aPresContext, aChildList, wrapperFrame)) { - aChildList = wrapperFrame; - } - } - - mFirstChild = aChildList; - return NS_OK; -} - NS_IMETHODIMP nsScrollFrame::DidReflow(nsIPresContext& aPresContext, nsDidReflowStatus aStatus) diff --git a/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp index ffa5697b695..c3158cf8cac 100644 --- a/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp @@ -1476,25 +1476,49 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext, // XXX Applies to replaced elements, too, but how to tell if the element // is replaced? nsIFrame* scrollFrame = nsnull; + nsIFrame* wrapperFrame = nsnull; // If we're paginated then don't ever make the BODY scrollable - // XXX Use a special BODY rule for paged media + // XXX Use a special BODY rule for paged media... if (!(aPresContext->IsPaginated() && (nsHTMLAtoms::body == tag))) { if (display->IsBlockLevel() && IsScrollable(aPresContext, display)) { // Create a scroll frame which will wrap the frame that needs to // be scrolled if NS_SUCCEEDED(NS_NewScrollFrame(aContent, aParentFrame, scrollFrame)) { + nsIStyleContext* scrolledPseudoStyle; + // The scroll frame gets the original style context, and the scrolled - // frame gets a SCROLLED-CONTENT pseudo element style context. + // frame gets a SCROLLED-CONTENT pseudo element style context that + // inherits the background properties scrollFrame->SetStyleContext(aPresContext, styleContext); - - nsIStyleContext* pseudoStyle; - pseudoStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsHTMLAtoms::scrolledContentPseudo, - styleContext); + scrolledPseudoStyle = aPresContext->ResolvePseudoStyleContextFor + (aContent, nsHTMLAtoms::scrolledContentPseudo, + styleContext); NS_RELEASE(styleContext); - styleContext = pseudoStyle; - aParentFrame = scrollFrame; + + // If the content element can contain children then wrap it in a + // BODY frame. Don't do this for the BODY element, though... + PRBool isContainer; + aContent->CanContainChildren(isContainer); + if (isContainer && (tag != nsHTMLAtoms::body)) { + NS_NewBodyFrame(aContent, scrollFrame, wrapperFrame, NS_BODY_SHRINK_WRAP); + wrapperFrame->SetStyleContext(aPresContext, scrolledPseudoStyle); + + // The wrapped frame also gets a pseudo style context, but it doesn't + // inherit any background properties + // XXX We should define something like :WRAPPED-FRAME in ua.css + nsIStyleContext* wrappedPseudoStyle; + wrappedPseudoStyle = aPresContext->ResolvePseudoStyleContextFor + (aContent, nsHTMLAtoms::columnPseudo, + scrolledPseudoStyle); + NS_RELEASE(scrolledPseudoStyle); + aParentFrame = wrapperFrame; + styleContext = wrappedPseudoStyle; + + } else { + aParentFrame = scrollFrame; + styleContext = scrolledPseudoStyle; + } } } } @@ -1514,7 +1538,12 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext, // Set the scroll frame's initial child list and return the scroll frame // as the frame sub-tree if (nsnull != scrollFrame) { - scrollFrame->SetInitialChildList(*aPresContext, nsnull, aFrameSubTree); + if (nsnull != wrapperFrame) { + wrapperFrame->SetInitialChildList(*aPresContext, nsnull, aFrameSubTree); + scrollFrame->SetInitialChildList(*aPresContext, nsnull, wrapperFrame); + } else { + scrollFrame->SetInitialChildList(*aPresContext, nsnull, aFrameSubTree); + } aFrameSubTree = scrollFrame; } } diff --git a/mozilla/layout/style/nsHTMLStyleSheet.cpp b/mozilla/layout/style/nsHTMLStyleSheet.cpp index ffa5697b695..c3158cf8cac 100644 --- a/mozilla/layout/style/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/style/nsHTMLStyleSheet.cpp @@ -1476,25 +1476,49 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext, // XXX Applies to replaced elements, too, but how to tell if the element // is replaced? nsIFrame* scrollFrame = nsnull; + nsIFrame* wrapperFrame = nsnull; // If we're paginated then don't ever make the BODY scrollable - // XXX Use a special BODY rule for paged media + // XXX Use a special BODY rule for paged media... if (!(aPresContext->IsPaginated() && (nsHTMLAtoms::body == tag))) { if (display->IsBlockLevel() && IsScrollable(aPresContext, display)) { // Create a scroll frame which will wrap the frame that needs to // be scrolled if NS_SUCCEEDED(NS_NewScrollFrame(aContent, aParentFrame, scrollFrame)) { + nsIStyleContext* scrolledPseudoStyle; + // The scroll frame gets the original style context, and the scrolled - // frame gets a SCROLLED-CONTENT pseudo element style context. + // frame gets a SCROLLED-CONTENT pseudo element style context that + // inherits the background properties scrollFrame->SetStyleContext(aPresContext, styleContext); - - nsIStyleContext* pseudoStyle; - pseudoStyle = aPresContext->ResolvePseudoStyleContextFor(aContent, - nsHTMLAtoms::scrolledContentPseudo, - styleContext); + scrolledPseudoStyle = aPresContext->ResolvePseudoStyleContextFor + (aContent, nsHTMLAtoms::scrolledContentPseudo, + styleContext); NS_RELEASE(styleContext); - styleContext = pseudoStyle; - aParentFrame = scrollFrame; + + // If the content element can contain children then wrap it in a + // BODY frame. Don't do this for the BODY element, though... + PRBool isContainer; + aContent->CanContainChildren(isContainer); + if (isContainer && (tag != nsHTMLAtoms::body)) { + NS_NewBodyFrame(aContent, scrollFrame, wrapperFrame, NS_BODY_SHRINK_WRAP); + wrapperFrame->SetStyleContext(aPresContext, scrolledPseudoStyle); + + // The wrapped frame also gets a pseudo style context, but it doesn't + // inherit any background properties + // XXX We should define something like :WRAPPED-FRAME in ua.css + nsIStyleContext* wrappedPseudoStyle; + wrappedPseudoStyle = aPresContext->ResolvePseudoStyleContextFor + (aContent, nsHTMLAtoms::columnPseudo, + scrolledPseudoStyle); + NS_RELEASE(scrolledPseudoStyle); + aParentFrame = wrapperFrame; + styleContext = wrappedPseudoStyle; + + } else { + aParentFrame = scrollFrame; + styleContext = scrolledPseudoStyle; + } } } } @@ -1514,7 +1538,12 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext, // Set the scroll frame's initial child list and return the scroll frame // as the frame sub-tree if (nsnull != scrollFrame) { - scrollFrame->SetInitialChildList(*aPresContext, nsnull, aFrameSubTree); + if (nsnull != wrapperFrame) { + wrapperFrame->SetInitialChildList(*aPresContext, nsnull, aFrameSubTree); + scrollFrame->SetInitialChildList(*aPresContext, nsnull, wrapperFrame); + } else { + scrollFrame->SetInitialChildList(*aPresContext, nsnull, aFrameSubTree); + } aFrameSubTree = scrollFrame; } }