From 13ef91147a24af8087b60a52647b2f02abcb5fb7 Mon Sep 17 00:00:00 2001 From: "troy%netscape.com" Date: Fri, 13 Nov 1998 03:43:15 +0000 Subject: [PATCH] Cleaned up ConstructXMLRootFrame() and added some XXX comments git-svn-id: svn://10.0.0.236/trunk@14581 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/style/src/nsHTMLStyleSheet.cpp | 26 +++++++++++-------- .../html/style/src/nsHTMLStyleSheet.cpp | 26 +++++++++++-------- mozilla/layout/style/nsHTMLStyleSheet.cpp | 26 +++++++++++-------- 3 files changed, 45 insertions(+), 33 deletions(-) diff --git a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp index 0ee21ceef1b..e12af883a6a 100644 --- a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp @@ -1215,11 +1215,19 @@ HTMLStyleSheetImpl::ConstructXMLRootFrame(nsIPresContext* aPresContext, nsIStyleContext* aStyleContext, nsIFrame*& aNewFrame) { - // Create the root frame. It gets a special pseudo element style + // Create the root frame. It gets a special pseudo element style. + // XXX It's wrong that the document element's style context (which is + // passed in) isn't based on the xml-root pseudo element style context + // we create below. That means that things like font information defined + // in the ua.css don't get properly inherited. We could re-resolve the + // style context, or change the flow of control so we create the style + // context rather than pass it in... nsIStyleContext* rootPseudoStyle; rootPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, nsHTMLAtoms::xmlRootPseudo, nsnull); + // XXX It would be nice if we didn't need this and we made the scroll + // frame (or the body wrapper frame) the root of the frame hierarchy nsresult rv = NS_NewHTMLFrame(nsnull, nsnull, aNewFrame); if (NS_SUCCEEDED(rv)) { @@ -1236,12 +1244,15 @@ HTMLStyleSheetImpl::ConstructXMLRootFrame(nsIPresContext* aPresContext, // Set the style context aNewFrame->SetStyleContext(aPresContext, rootPseudoStyle); - // Wrap the document element in a scroll frame + // Create a scroll frame. + // XXX Use the rootPseudoStyle overflow style information to decide whether + // we create a scroll frame or just a body wrapper frame... nsIFrame* scrollFrame; if (NS_SUCCEEDED(NS_NewScrollFrame(nsnull, aNewFrame, scrollFrame))) { - // The scroll frame gets the original style context, and the scrolled + // The scroll frame gets the root pseudo style context, and the scrolled // frame gets a SCROLLED-CONTENT pseudo element style context. + // XXX We should probably use a different pseudo style context... scrollFrame->SetStyleContext(aPresContext, rootPseudoStyle); nsIStyleContext* scrolledPseudoStyle; @@ -1255,18 +1266,11 @@ HTMLStyleSheetImpl::ConstructXMLRootFrame(nsIPresContext* aPresContext, NS_NewBodyFrame(nsnull, scrollFrame, wrapperFrame, NS_BODY_SHRINK_WRAP); wrapperFrame->SetStyleContext(aPresContext, scrolledPseudoStyle); - // Construct a frame for the document element + // Construct a frame for the document element and process its children nsIFrame* docElementFrame; ConstructFrame(aPresContext, aContent, wrapperFrame, docElementFrame); wrapperFrame->SetInitialChildList(*aPresContext, nsnull, docElementFrame); -#if 0 - // Process the child content, and set the frame's initial child list - nsIFrame* childList; - rv = ProcessChildren(aPresContext, wrapperFrame, aContent, childList); - wrapperFrame->SetInitialChildList(*aPresContext, nsnull, childList); -#endif - // Set the scroll frame's initial child list scrollFrame->SetInitialChildList(*aPresContext, nsnull, wrapperFrame); } diff --git a/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp index 0ee21ceef1b..e12af883a6a 100644 --- a/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp @@ -1215,11 +1215,19 @@ HTMLStyleSheetImpl::ConstructXMLRootFrame(nsIPresContext* aPresContext, nsIStyleContext* aStyleContext, nsIFrame*& aNewFrame) { - // Create the root frame. It gets a special pseudo element style + // Create the root frame. It gets a special pseudo element style. + // XXX It's wrong that the document element's style context (which is + // passed in) isn't based on the xml-root pseudo element style context + // we create below. That means that things like font information defined + // in the ua.css don't get properly inherited. We could re-resolve the + // style context, or change the flow of control so we create the style + // context rather than pass it in... nsIStyleContext* rootPseudoStyle; rootPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, nsHTMLAtoms::xmlRootPseudo, nsnull); + // XXX It would be nice if we didn't need this and we made the scroll + // frame (or the body wrapper frame) the root of the frame hierarchy nsresult rv = NS_NewHTMLFrame(nsnull, nsnull, aNewFrame); if (NS_SUCCEEDED(rv)) { @@ -1236,12 +1244,15 @@ HTMLStyleSheetImpl::ConstructXMLRootFrame(nsIPresContext* aPresContext, // Set the style context aNewFrame->SetStyleContext(aPresContext, rootPseudoStyle); - // Wrap the document element in a scroll frame + // Create a scroll frame. + // XXX Use the rootPseudoStyle overflow style information to decide whether + // we create a scroll frame or just a body wrapper frame... nsIFrame* scrollFrame; if (NS_SUCCEEDED(NS_NewScrollFrame(nsnull, aNewFrame, scrollFrame))) { - // The scroll frame gets the original style context, and the scrolled + // The scroll frame gets the root pseudo style context, and the scrolled // frame gets a SCROLLED-CONTENT pseudo element style context. + // XXX We should probably use a different pseudo style context... scrollFrame->SetStyleContext(aPresContext, rootPseudoStyle); nsIStyleContext* scrolledPseudoStyle; @@ -1255,18 +1266,11 @@ HTMLStyleSheetImpl::ConstructXMLRootFrame(nsIPresContext* aPresContext, NS_NewBodyFrame(nsnull, scrollFrame, wrapperFrame, NS_BODY_SHRINK_WRAP); wrapperFrame->SetStyleContext(aPresContext, scrolledPseudoStyle); - // Construct a frame for the document element + // Construct a frame for the document element and process its children nsIFrame* docElementFrame; ConstructFrame(aPresContext, aContent, wrapperFrame, docElementFrame); wrapperFrame->SetInitialChildList(*aPresContext, nsnull, docElementFrame); -#if 0 - // Process the child content, and set the frame's initial child list - nsIFrame* childList; - rv = ProcessChildren(aPresContext, wrapperFrame, aContent, childList); - wrapperFrame->SetInitialChildList(*aPresContext, nsnull, childList); -#endif - // Set the scroll frame's initial child list scrollFrame->SetInitialChildList(*aPresContext, nsnull, wrapperFrame); } diff --git a/mozilla/layout/style/nsHTMLStyleSheet.cpp b/mozilla/layout/style/nsHTMLStyleSheet.cpp index 0ee21ceef1b..e12af883a6a 100644 --- a/mozilla/layout/style/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/style/nsHTMLStyleSheet.cpp @@ -1215,11 +1215,19 @@ HTMLStyleSheetImpl::ConstructXMLRootFrame(nsIPresContext* aPresContext, nsIStyleContext* aStyleContext, nsIFrame*& aNewFrame) { - // Create the root frame. It gets a special pseudo element style + // Create the root frame. It gets a special pseudo element style. + // XXX It's wrong that the document element's style context (which is + // passed in) isn't based on the xml-root pseudo element style context + // we create below. That means that things like font information defined + // in the ua.css don't get properly inherited. We could re-resolve the + // style context, or change the flow of control so we create the style + // context rather than pass it in... nsIStyleContext* rootPseudoStyle; rootPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull, nsHTMLAtoms::xmlRootPseudo, nsnull); + // XXX It would be nice if we didn't need this and we made the scroll + // frame (or the body wrapper frame) the root of the frame hierarchy nsresult rv = NS_NewHTMLFrame(nsnull, nsnull, aNewFrame); if (NS_SUCCEEDED(rv)) { @@ -1236,12 +1244,15 @@ HTMLStyleSheetImpl::ConstructXMLRootFrame(nsIPresContext* aPresContext, // Set the style context aNewFrame->SetStyleContext(aPresContext, rootPseudoStyle); - // Wrap the document element in a scroll frame + // Create a scroll frame. + // XXX Use the rootPseudoStyle overflow style information to decide whether + // we create a scroll frame or just a body wrapper frame... nsIFrame* scrollFrame; if (NS_SUCCEEDED(NS_NewScrollFrame(nsnull, aNewFrame, scrollFrame))) { - // The scroll frame gets the original style context, and the scrolled + // The scroll frame gets the root pseudo style context, and the scrolled // frame gets a SCROLLED-CONTENT pseudo element style context. + // XXX We should probably use a different pseudo style context... scrollFrame->SetStyleContext(aPresContext, rootPseudoStyle); nsIStyleContext* scrolledPseudoStyle; @@ -1255,18 +1266,11 @@ HTMLStyleSheetImpl::ConstructXMLRootFrame(nsIPresContext* aPresContext, NS_NewBodyFrame(nsnull, scrollFrame, wrapperFrame, NS_BODY_SHRINK_WRAP); wrapperFrame->SetStyleContext(aPresContext, scrolledPseudoStyle); - // Construct a frame for the document element + // Construct a frame for the document element and process its children nsIFrame* docElementFrame; ConstructFrame(aPresContext, aContent, wrapperFrame, docElementFrame); wrapperFrame->SetInitialChildList(*aPresContext, nsnull, docElementFrame); -#if 0 - // Process the child content, and set the frame's initial child list - nsIFrame* childList; - rv = ProcessChildren(aPresContext, wrapperFrame, aContent, childList); - wrapperFrame->SetInitialChildList(*aPresContext, nsnull, childList); -#endif - // Set the scroll frame's initial child list scrollFrame->SetInitialChildList(*aPresContext, nsnull, wrapperFrame); }