From 5cee9b1889360ee3bf70c87cd7904dc49e401706 Mon Sep 17 00:00:00 2001 From: "sfraser%netscape.com" Date: Mon, 15 May 2000 20:25:02 +0000 Subject: [PATCH] Make XBL work for HTML elements. r=hyatt git-svn-id: svn://10.0.0.236/trunk@69833 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsCSSFrameConstructor.cpp | 206 ++++++++++-------- mozilla/layout/base/nsCSSFrameConstructor.h | 11 +- .../html/style/src/nsCSSFrameConstructor.cpp | 206 ++++++++++-------- .../html/style/src/nsCSSFrameConstructor.h | 11 +- 4 files changed, 260 insertions(+), 174 deletions(-) diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index ed69dfcb644..9135eb88ccb 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -5312,7 +5312,6 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, nsIAtom* aTag, nsIStyleContext* aStyleContext, nsFrameItems& aFrameItems, - PRBool aXBLBaseTag, PRBool& aHaltProcessing) { PRBool primaryFrameSet = PR_FALSE; @@ -5342,42 +5341,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, if (NS_SUCCEEDED(aContent->GetNameSpaceID(nameSpaceID)) && nameSpaceID == nsXULAtoms::nameSpaceID) { - // The following code allows the user to specify the base tag - // of a XUL object using XBL. XUL objects (like boxes, menus, etc.) - // can then be extended arbitrarily. - if (!aXBLBaseTag) { - const nsStyleUserInterface* ui= (const nsStyleUserInterface*) - aStyleContext->GetStyleData(eStyleStruct_UserInterface); - - // Ensure that our XBL bindings are installed. - if (!ui->mBehavior.IsEmpty()) { - // Get the XBL loader. - nsresult rv; - NS_WITH_SERVICE(nsIXBLService, xblService, "component://netscape/xbl", &rv); - if (!xblService) - return rv; - - // Load the bindings. - xblService->LoadBindings(aContent, ui->mBehavior); - - nsCOMPtr baseTag; - xblService->ResolveTag(aContent, getter_AddRefs(baseTag)); - - if (baseTag.get() != aTag) { - // Construct the frame using the XBL base tag. - return ConstructXULFrame( aPresShell, - aPresContext, - aState, - aContent, - aParentFrame, - baseTag, - aStyleContext, - aFrameItems, - PR_TRUE, - aHaltProcessing ); - } - } - } +// was here // See if the element is absolutely positioned const nsStylePosition* position = (const nsStylePosition*) @@ -5929,12 +5893,13 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, // if there are any anonymous children create frames for them + /* Not sure why we did this nsCOMPtr tag(aTag); if (aXBLBaseTag) { aContent->GetTag(*getter_AddRefs(tag)); } - - CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, newFrame, + */ + CreateAnonymousFrames(aPresShell, aPresContext, aTag, aState, aContent, newFrame, childItems); // Set the frame's initial child list @@ -7193,59 +7158,128 @@ nsCSSFrameConstructor::ConstructFrame(nsIPresShell* aPresShell, if (NS_STYLE_DISPLAY_NONE == display->mDisplay) { aState.mFrameManager->SetUndisplayedContent(aContent, styleContext); } - else { - nsIFrame* lastChild = aFrameItems.lastChild; - - // Handle specific frame types - rv = ConstructFrameByTag(aPresShell, aPresContext, aState, aContent, aParentFrame, - tag, styleContext, aFrameItems); - -#ifdef INCLUDE_XUL - // Failing to find a matching HTML frame, try creating a specialized - // XUL frame. This is temporary, pending planned factoring of this - // whole process into separate, pluggable steps. - if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || - (lastChild == aFrameItems.lastChild))) { - PRBool haltProcessing = PR_FALSE; - rv = ConstructXULFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, - tag, styleContext, aFrameItems, PR_FALSE, haltProcessing); - if (haltProcessing) { - return rv; - } - } -#endif - -// MathML Mod - RBS -#ifdef MOZ_MATHML - if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || - (lastChild == aFrameItems.lastChild))) { - rv = ConstructMathMLFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, - tag, styleContext, aFrameItems); - } -#endif - -// SVG -#ifdef MOZ_SVG - if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || - (lastChild == aFrameItems.lastChild))) { - rv = ConstructSVGFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, - tag, styleContext, aFrameItems); - } -#endif - - if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || - (lastChild == aFrameItems.lastChild))) { - // When there is no explicit frame to create, assume it's a - // container and let display style dictate the rest - rv = ConstructFrameByDisplayType(aPresShell, aPresContext, aState, display, aContent, - aParentFrame, styleContext, aFrameItems); - } + else + { + rv = ConstructFrameInternal(aPresShell, + aPresContext, + aState, + aContent, + aParentFrame, + tag, + styleContext, + aFrameItems, + PR_FALSE); } } return rv; } + +nsresult +nsCSSFrameConstructor::ConstructFrameInternal( nsIPresShell* aPresShell, + nsIPresContext* aPresContext, + nsFrameConstructorState& aState, + nsIContent* aContent, + nsIFrame* aParentFrame, + nsIAtom* aTag, + nsIStyleContext* aStyleContext, + nsFrameItems& aFrameItems, + PRBool aXBLBaseTag) +{ + // The following code allows the user to specify the base tag + // of a XUL object using XBL. XUL objects (like boxes, menus, etc.) + // can then be extended arbitrarily. + if (!aXBLBaseTag) + { + const nsStyleUserInterface* ui= (const nsStyleUserInterface*) + aStyleContext->GetStyleData(eStyleStruct_UserInterface); + + // Ensure that our XBL bindings are installed. + if (!ui->mBehavior.IsEmpty()) { + // Get the XBL loader. + nsresult rv; + NS_WITH_SERVICE(nsIXBLService, xblService, "component://netscape/xbl", &rv); + if (!xblService) + return rv; + + // Load the bindings. + xblService->LoadBindings(aContent, ui->mBehavior); + + nsCOMPtr baseTag; + xblService->ResolveTag(aContent, getter_AddRefs(baseTag)); + + if (baseTag.get() != aTag) { + // Construct the frame using the XBL base tag. + return ConstructFrameInternal( aPresShell, + aPresContext, + aState, + aContent, + aParentFrame, + baseTag, + aStyleContext, + aFrameItems, + PR_TRUE); + } + } + } + + + nsIFrame* lastChild = aFrameItems.lastChild; + + // Handle specific frame types + nsresult rv = ConstructFrameByTag(aPresShell, aPresContext, aState, aContent, aParentFrame, + aTag, aStyleContext, aFrameItems); + +#ifdef INCLUDE_XUL + // Failing to find a matching HTML frame, try creating a specialized + // XUL frame. This is temporary, pending planned factoring of this + // whole process into separate, pluggable steps. + if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || + (lastChild == aFrameItems.lastChild))) { + PRBool haltProcessing = PR_FALSE; + rv = ConstructXULFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, + aTag, aStyleContext, aFrameItems, haltProcessing); + if (haltProcessing) { + return rv; + } + } +#endif + +// MathML Mod - RBS +#ifdef MOZ_MATHML + if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || + (lastChild == aFrameItems.lastChild))) { + rv = ConstructMathMLFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, + tag, styleContext, aFrameItems); + } +#endif + +// SVG +#ifdef MOZ_SVG + if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || + (lastChild == aFrameItems.lastChild))) { + rv = ConstructSVGFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, + tag, styleContext, aFrameItems); + } +#endif + + if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || + (lastChild == aFrameItems.lastChild))) { + // When there is no explicit frame to create, assume it's a + // container and let display style dictate the rest + const nsStyleDisplay* display = (const nsStyleDisplay*) + aStyleContext->GetStyleData(eStyleStruct_Display); + + rv = ConstructFrameByDisplayType(aPresShell, aPresContext, aState, display, aContent, + aParentFrame, aStyleContext, aFrameItems); + } + + return rv; +} + + + NS_IMETHODIMP nsCSSFrameConstructor::ReconstructDocElementHierarchy(nsIPresContext* aPresContext) { diff --git a/mozilla/layout/base/nsCSSFrameConstructor.h b/mozilla/layout/base/nsCSSFrameConstructor.h index c4a022f6bae..4536e7112f0 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.h +++ b/mozilla/layout/base/nsCSSFrameConstructor.h @@ -493,6 +493,16 @@ protected: nsIStyleContext* aStyleContext, nsFrameItems& aFrameItems); + nsresult ConstructFrameInternal( nsIPresShell* aPresShell, + nsIPresContext* aPresContext, + nsFrameConstructorState& aState, + nsIContent* aContent, + nsIFrame* aParentFrame, + nsIAtom* aTag, + nsIStyleContext* aStyleContext, + nsFrameItems& aFrameItems, + PRBool aXBLBaseTag); + nsresult CreateAnonymousFrames(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsIAtom* aTag, @@ -539,7 +549,6 @@ protected: nsIAtom* aTag, nsIStyleContext* aStyleContext, nsFrameItems& aFrameItems, - PRBool aXBLBaseTag, PRBool& aHaltProcessing); #endif diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index ed69dfcb644..9135eb88ccb 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -5312,7 +5312,6 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, nsIAtom* aTag, nsIStyleContext* aStyleContext, nsFrameItems& aFrameItems, - PRBool aXBLBaseTag, PRBool& aHaltProcessing) { PRBool primaryFrameSet = PR_FALSE; @@ -5342,42 +5341,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, if (NS_SUCCEEDED(aContent->GetNameSpaceID(nameSpaceID)) && nameSpaceID == nsXULAtoms::nameSpaceID) { - // The following code allows the user to specify the base tag - // of a XUL object using XBL. XUL objects (like boxes, menus, etc.) - // can then be extended arbitrarily. - if (!aXBLBaseTag) { - const nsStyleUserInterface* ui= (const nsStyleUserInterface*) - aStyleContext->GetStyleData(eStyleStruct_UserInterface); - - // Ensure that our XBL bindings are installed. - if (!ui->mBehavior.IsEmpty()) { - // Get the XBL loader. - nsresult rv; - NS_WITH_SERVICE(nsIXBLService, xblService, "component://netscape/xbl", &rv); - if (!xblService) - return rv; - - // Load the bindings. - xblService->LoadBindings(aContent, ui->mBehavior); - - nsCOMPtr baseTag; - xblService->ResolveTag(aContent, getter_AddRefs(baseTag)); - - if (baseTag.get() != aTag) { - // Construct the frame using the XBL base tag. - return ConstructXULFrame( aPresShell, - aPresContext, - aState, - aContent, - aParentFrame, - baseTag, - aStyleContext, - aFrameItems, - PR_TRUE, - aHaltProcessing ); - } - } - } +// was here // See if the element is absolutely positioned const nsStylePosition* position = (const nsStylePosition*) @@ -5929,12 +5893,13 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, // if there are any anonymous children create frames for them + /* Not sure why we did this nsCOMPtr tag(aTag); if (aXBLBaseTag) { aContent->GetTag(*getter_AddRefs(tag)); } - - CreateAnonymousFrames(aPresShell, aPresContext, tag, aState, aContent, newFrame, + */ + CreateAnonymousFrames(aPresShell, aPresContext, aTag, aState, aContent, newFrame, childItems); // Set the frame's initial child list @@ -7193,59 +7158,128 @@ nsCSSFrameConstructor::ConstructFrame(nsIPresShell* aPresShell, if (NS_STYLE_DISPLAY_NONE == display->mDisplay) { aState.mFrameManager->SetUndisplayedContent(aContent, styleContext); } - else { - nsIFrame* lastChild = aFrameItems.lastChild; - - // Handle specific frame types - rv = ConstructFrameByTag(aPresShell, aPresContext, aState, aContent, aParentFrame, - tag, styleContext, aFrameItems); - -#ifdef INCLUDE_XUL - // Failing to find a matching HTML frame, try creating a specialized - // XUL frame. This is temporary, pending planned factoring of this - // whole process into separate, pluggable steps. - if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || - (lastChild == aFrameItems.lastChild))) { - PRBool haltProcessing = PR_FALSE; - rv = ConstructXULFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, - tag, styleContext, aFrameItems, PR_FALSE, haltProcessing); - if (haltProcessing) { - return rv; - } - } -#endif - -// MathML Mod - RBS -#ifdef MOZ_MATHML - if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || - (lastChild == aFrameItems.lastChild))) { - rv = ConstructMathMLFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, - tag, styleContext, aFrameItems); - } -#endif - -// SVG -#ifdef MOZ_SVG - if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || - (lastChild == aFrameItems.lastChild))) { - rv = ConstructSVGFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, - tag, styleContext, aFrameItems); - } -#endif - - if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || - (lastChild == aFrameItems.lastChild))) { - // When there is no explicit frame to create, assume it's a - // container and let display style dictate the rest - rv = ConstructFrameByDisplayType(aPresShell, aPresContext, aState, display, aContent, - aParentFrame, styleContext, aFrameItems); - } + else + { + rv = ConstructFrameInternal(aPresShell, + aPresContext, + aState, + aContent, + aParentFrame, + tag, + styleContext, + aFrameItems, + PR_FALSE); } } return rv; } + +nsresult +nsCSSFrameConstructor::ConstructFrameInternal( nsIPresShell* aPresShell, + nsIPresContext* aPresContext, + nsFrameConstructorState& aState, + nsIContent* aContent, + nsIFrame* aParentFrame, + nsIAtom* aTag, + nsIStyleContext* aStyleContext, + nsFrameItems& aFrameItems, + PRBool aXBLBaseTag) +{ + // The following code allows the user to specify the base tag + // of a XUL object using XBL. XUL objects (like boxes, menus, etc.) + // can then be extended arbitrarily. + if (!aXBLBaseTag) + { + const nsStyleUserInterface* ui= (const nsStyleUserInterface*) + aStyleContext->GetStyleData(eStyleStruct_UserInterface); + + // Ensure that our XBL bindings are installed. + if (!ui->mBehavior.IsEmpty()) { + // Get the XBL loader. + nsresult rv; + NS_WITH_SERVICE(nsIXBLService, xblService, "component://netscape/xbl", &rv); + if (!xblService) + return rv; + + // Load the bindings. + xblService->LoadBindings(aContent, ui->mBehavior); + + nsCOMPtr baseTag; + xblService->ResolveTag(aContent, getter_AddRefs(baseTag)); + + if (baseTag.get() != aTag) { + // Construct the frame using the XBL base tag. + return ConstructFrameInternal( aPresShell, + aPresContext, + aState, + aContent, + aParentFrame, + baseTag, + aStyleContext, + aFrameItems, + PR_TRUE); + } + } + } + + + nsIFrame* lastChild = aFrameItems.lastChild; + + // Handle specific frame types + nsresult rv = ConstructFrameByTag(aPresShell, aPresContext, aState, aContent, aParentFrame, + aTag, aStyleContext, aFrameItems); + +#ifdef INCLUDE_XUL + // Failing to find a matching HTML frame, try creating a specialized + // XUL frame. This is temporary, pending planned factoring of this + // whole process into separate, pluggable steps. + if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || + (lastChild == aFrameItems.lastChild))) { + PRBool haltProcessing = PR_FALSE; + rv = ConstructXULFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, + aTag, aStyleContext, aFrameItems, haltProcessing); + if (haltProcessing) { + return rv; + } + } +#endif + +// MathML Mod - RBS +#ifdef MOZ_MATHML + if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || + (lastChild == aFrameItems.lastChild))) { + rv = ConstructMathMLFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, + tag, styleContext, aFrameItems); + } +#endif + +// SVG +#ifdef MOZ_SVG + if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || + (lastChild == aFrameItems.lastChild))) { + rv = ConstructSVGFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, + tag, styleContext, aFrameItems); + } +#endif + + if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || + (lastChild == aFrameItems.lastChild))) { + // When there is no explicit frame to create, assume it's a + // container and let display style dictate the rest + const nsStyleDisplay* display = (const nsStyleDisplay*) + aStyleContext->GetStyleData(eStyleStruct_Display); + + rv = ConstructFrameByDisplayType(aPresShell, aPresContext, aState, display, aContent, + aParentFrame, aStyleContext, aFrameItems); + } + + return rv; +} + + + NS_IMETHODIMP nsCSSFrameConstructor::ReconstructDocElementHierarchy(nsIPresContext* aPresContext) { diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.h b/mozilla/layout/html/style/src/nsCSSFrameConstructor.h index c4a022f6bae..4536e7112f0 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.h +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.h @@ -493,6 +493,16 @@ protected: nsIStyleContext* aStyleContext, nsFrameItems& aFrameItems); + nsresult ConstructFrameInternal( nsIPresShell* aPresShell, + nsIPresContext* aPresContext, + nsFrameConstructorState& aState, + nsIContent* aContent, + nsIFrame* aParentFrame, + nsIAtom* aTag, + nsIStyleContext* aStyleContext, + nsFrameItems& aFrameItems, + PRBool aXBLBaseTag); + nsresult CreateAnonymousFrames(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsIAtom* aTag, @@ -539,7 +549,6 @@ protected: nsIAtom* aTag, nsIStyleContext* aStyleContext, nsFrameItems& aFrameItems, - PRBool aXBLBaseTag, PRBool& aHaltProcessing); #endif