From 5c811dfbf34111fa1bd2d3632977c6d1ec1e2540 Mon Sep 17 00:00:00 2001 From: "heikki%netscape.com" Date: Mon, 19 Feb 2001 21:50:04 +0000 Subject: [PATCH] Splitting layout into two libraries, layout and content. r=jst@netscape.com, sr=waterson@netscape.com --- Makefile.in | 1 + allmakefiles.sh | 64 ++- content/shared/public/nsStyleCoord.h | 252 ++++++++- content/shared/src/nsXULAtoms.cpp | 4 +- content/xul/content/src/nsXULElement.cpp | 1 + content/xul/document/src/nsXULDocument.cpp | 1 + dom/src/base/nsWindowRoot.cpp | 1 + layout/Makefile.in | 4 +- layout/base/Makefile.in | 4 - layout/base/nsCSSFrameConstructor.cpp | 59 +- layout/base/nsCSSFrameConstructor.h | 4 +- layout/base/nsFrameTraversal.cpp | 36 ++ layout/base/nsFrameTraversal.h | 17 +- layout/base/nsPresContext.cpp | 8 +- layout/base/nsPresShell.cpp | 15 +- layout/base/public/MANIFEST | 58 +- layout/base/public/Makefile.in | 32 +- layout/base/public/makefile.win | 32 +- layout/base/public/nsFrameTraversal.h | 17 +- layout/base/public/nsIStyleContext.h | 504 ++++++++++++++++-- .../base/public/nsIStyleFrameConstruction.h | 2 + layout/base/public/nsStyleCoord.h | 252 ++++++++- layout/base/src/Makefile.in | 28 - layout/base/src/makefile.win | 67 +-- layout/base/src/nsFrameTraversal.cpp | 36 ++ layout/base/src/nsPresContext.cpp | 8 +- layout/base/src/nsStyleCoord.cpp | 263 +-------- layout/base/tests/makefile.win | 2 +- layout/build/Makefile.in | 6 - layout/build/dlldeps.cpp | 8 - layout/build/makefile.win | 32 +- layout/build/nsLayoutCID.h | 26 +- layout/build/nsLayoutDLF.cpp | 17 +- layout/build/nsLayoutFactory.cpp | 328 ++---------- layout/build/nsLayoutModule.cpp | 70 +-- layout/forms/nsComboboxControlFrame.cpp | 25 +- layout/forms/nsFileControlFrame.cpp | 23 +- layout/forms/nsGfxButtonControlFrame.cpp | 5 +- layout/forms/nsIsIndexFrame.cpp | 37 +- layout/generic/nsGfxScrollFrame.cpp | 2 - layout/generic/nsImageFrame.cpp | 40 +- layout/generic/nsImageFrame.h | 12 +- layout/generic/nsObjectFrame.cpp | 67 ++- layout/generic/nsObjectFrame.h | 14 +- layout/html/Makefile.in | 2 +- layout/html/base/src/MANIFEST | 1 + layout/html/base/src/makefile.win | 2 +- layout/html/base/src/nsGfxScrollFrame.cpp | 2 - layout/html/base/src/nsImageFrame.cpp | 40 +- layout/html/base/src/nsImageFrame.h | 12 +- layout/html/base/src/nsObjectFrame.cpp | 67 ++- layout/html/base/src/nsObjectFrame.h | 14 +- layout/html/base/src/nsPresShell.cpp | 15 +- layout/html/document/Makefile.in | 2 +- layout/html/document/makefile.win | 2 +- layout/html/document/src/Makefile.in | 12 - layout/html/document/src/makefile.win | 17 +- layout/html/forms/public/MANIFEST | 1 + layout/html/forms/src/makefile.win | 2 +- .../html/forms/src/nsComboboxControlFrame.cpp | 25 +- layout/html/forms/src/nsFileControlFrame.cpp | 23 +- .../forms/src/nsGfxButtonControlFrame.cpp | 5 +- .../html/forms/src/nsGfxTextControlFrame.cpp | 20 +- .../html/forms/src/nsGfxTextControlFrame2.cpp | 18 +- layout/html/forms/src/nsIsIndexFrame.cpp | 37 +- layout/html/makefile.win | 2 +- layout/html/style/public/MANIFEST | 9 - layout/html/style/public/Makefile.in | 8 - layout/html/style/public/makefile.win | 2 +- layout/html/style/src/Makefile.in | 34 +- layout/html/style/src/makefile.win | 54 +- .../html/style/src/nsCSSFrameConstructor.cpp | 59 +- layout/html/style/src/nsCSSFrameConstructor.h | 4 +- layout/html/style/src/nsIHTMLStyleSheet.h | 2 + layout/html/table/src/makefile.win | 2 +- layout/html/tests/Makefile.in | 14 +- layout/html/tests/makefile.win | 47 +- .../TableContentTest/TableContentTest.cpp | 7 +- layout/makefile.win | 4 - layout/mathml/base/src/makefile.win | 2 +- layout/mathml/content/src/makefile.win | 2 +- layout/mathml/content/src/nsMathMLAtoms.cpp | 16 +- layout/style/nsStyleCoord.h | 252 ++++++++- layout/svg/base/src/makefile.win | 2 +- layout/svg/base/src/nsSVGContainerFrame.cpp | 1 - layout/svg/content/src/makefile.win | 2 +- layout/svg/content/src/nsSVGAtoms.cpp | 14 +- layout/xul/base/src/makefile.win | 2 +- layout/xul/base/src/nsScrollbarFrame.cpp | 129 ----- layout/xul/base/src/nsSplitterFrame.cpp | 52 +- layout/xul/content/src/makefile.win | 2 +- layout/xul/content/src/nsXULAtoms.cpp | 4 +- makefile.win | 1 + rdf/content/src/nsXULDocument.cpp | 1 + rdf/content/src/nsXULElement.cpp | 1 + xpinstall/src/Makefile.in | 5 +- xpinstall/src/makefile.win | 4 +- xpinstall/src/nsJSFile.cpp | 1 - xpinstall/src/nsJSFile.h | 1 - xpinstall/src/nsJSFileSpecObj.cpp | 15 +- xpinstall/src/nsJSInstall.cpp | 1 - xpinstall/src/nsJSInstallTriggerGlobal.cpp | 39 +- xpinstall/src/nsJSInstallVersion.cpp | 67 +-- 103 files changed, 2101 insertions(+), 1566 deletions(-) diff --git a/Makefile.in b/Makefile.in index bbe0a7cae9a7..5141938b79c6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -102,6 +102,7 @@ DIRS += \ dom \ view \ widget \ + content \ layout \ db \ rdf \ diff --git a/allmakefiles.sh b/allmakefiles.sh index b7ed2ec11584..bec41c85084f 100755 --- a/allmakefiles.sh +++ b/allmakefiles.sh @@ -230,6 +230,47 @@ js/src/xpconnect/tools/idl/Makefile js/src/xpconnect/tools/idl/Makefile " +MAKEFILES_content=" +content/Makefile +content/base/Makefile +content/base/public/Makefile +content/base/src/Makefile +content/build/Makefile +content/events/Makefile +content/events/public/Makefile +content/events/src/Makefile +content/html/Makefile +content/html/base/Makefile +content/html/base/src/Makefile +content/html/content/Makefile +content/html/content/public/Makefile +content/html/content/src/Makefile +content/html/document/Makefile +content/html/document/public/Makefile +content/html/document/src/Makefile +content/html/style/Makefile +content/html/style/public/Makefile +content/html/style/src/Makefile +content/xml/Makefile +content/xml/content/Makefile +content/xml/content/public/Makefile +content/xml/content/src/Makefile +content/xml/document/Makefile +content/xml/document/public/Makefile +content/xml/document/src/Makefile +content/xul/Makefile +content/xul/content/Makefile +content/xul/content/src/Makefile +content/xbl/Makefile +content/xbl/public/Makefile +content/xbl/src/Makefile +content/xbl/builtin/Makefile +content/xbl/builtin/os2/Makefile +content/xsl/Makefile +content/xsl/document/Makefile +content/xsl/document/src/Makefile +" + MAKEFILES_layout=" layout/Makefile layout/base/Makefile @@ -237,17 +278,10 @@ layout/base/public/Makefile layout/base/src/Makefile layout/base/tests/Makefile layout/build/Makefile -layout/events/Makefile -layout/events/public/Makefile -layout/events/src/Makefile layout/html/Makefile layout/html/base/Makefile layout/html/base/src/Makefile -layout/html/content/Makefile -layout/html/content/public/Makefile -layout/html/content/src/Makefile layout/html/document/Makefile -layout/html/document/public/Makefile layout/html/document/src/Makefile layout/html/forms/Makefile layout/html/forms/public/Makefile @@ -260,27 +294,12 @@ layout/html/table/public/Makefile layout/html/table/src/Makefile layout/html/tests/Makefile layout/tools/Makefile -layout/xml/Makefile -layout/xml/content/Makefile -layout/xml/content/public/Makefile -layout/xml/content/src/Makefile -layout/xml/document/Makefile -layout/xml/document/public/Makefile -layout/xml/document/src/Makefile layout/xul/Makefile layout/xul/base/Makefile layout/xul/base/public/Makefile layout/xul/base/src/Makefile layout/xul/content/Makefile layout/xul/content/src/Makefile -layout/xbl/Makefile -layout/xbl/public/Makefile -layout/xbl/src/Makefile -layout/xbl/builtin/Makefile -layout/xbl/builtin/os2/Makefile -layout/xsl/Makefile -layout/xsl/document/Makefile -layout/xsl/document/src/Makefile " MAKEFILES_mpfilelocprovider=" @@ -986,6 +1005,7 @@ $MAKEFILES_js $MAKEFILES_l10n $MAKEFILES_l10n_lang $MAKEFILES_langpacks +$MAKEFILES_content $MAKEFILES_layout $MAKEFILES_libreg $MAKEFILES_libimg diff --git a/content/shared/public/nsStyleCoord.h b/content/shared/public/nsStyleCoord.h index bb97cd0a9cd1..067e0b3112c1 100644 --- a/content/shared/public/nsStyleCoord.h +++ b/content/shared/public/nsStyleCoord.h @@ -25,7 +25,7 @@ #include "nscore.h" #include "nsCoord.h" #include "nsCRT.h" -class nsString; +#include "nsString.h" enum nsStyleUnit { eStyleUnit_Null = 0, // (no value) value is not specified @@ -48,15 +48,86 @@ typedef union { class nsStyleCoord { public: - nsStyleCoord(nsStyleUnit aUnit = eStyleUnit_Null); - nsStyleCoord(nscoord aValue); - nsStyleCoord(PRInt32 aValue, nsStyleUnit aUnit); - nsStyleCoord(float aValue, nsStyleUnit aUnit); - nsStyleCoord(const nsStyleCoord& aCopy); + nsStyleCoord(nsStyleUnit aUnit = eStyleUnit_Null) + : mUnit(aUnit) { + NS_ASSERTION(aUnit < eStyleUnit_Percent, "not a valueless unit"); + if (aUnit >= eStyleUnit_Percent) { + mUnit = eStyleUnit_Null; + } + mValue.mInt = 0; + } - nsStyleCoord& operator=(const nsStyleCoord& aCopy); - PRBool operator==(const nsStyleCoord& aOther) const; - PRBool operator!=(const nsStyleCoord& aOther) const; + nsStyleCoord(nscoord aValue) + : mUnit(eStyleUnit_Coord) { + mValue.mInt = aValue; + } + + nsStyleCoord(PRInt32 aValue, nsStyleUnit aUnit) + : mUnit(aUnit) { + //if you want to pass in eStyleUnit_Coord, don't. instead, use the + //constructor just above this one... MMP + NS_ASSERTION((aUnit == eStyleUnit_Proportional) || + (aUnit == eStyleUnit_Enumerated) || + (aUnit == eStyleUnit_Integer), "not an int value"); + if ((aUnit == eStyleUnit_Proportional) || + (aUnit == eStyleUnit_Enumerated) || + (aUnit == eStyleUnit_Integer)) { + mValue.mInt = aValue; + } + else { + mUnit = eStyleUnit_Null; + mValue.mInt = 0; + } + } + + nsStyleCoord(float aValue, nsStyleUnit aUnit) + : mUnit(aUnit) { + NS_ASSERTION((aUnit == eStyleUnit_Percent) || + (aUnit == eStyleUnit_Factor), "not a float value"); + if ((aUnit == eStyleUnit_Percent) || + (aUnit == eStyleUnit_Factor)) { + mValue.mFloat = aValue; + } + else { + mUnit = eStyleUnit_Null; + mValue.mInt = 0; + } + } + + nsStyleCoord(const nsStyleCoord& aCopy) + : mUnit(aCopy.mUnit) { + if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) { + mValue.mFloat = aCopy.mValue.mFloat; + } + else { + mValue.mInt = aCopy.mValue.mInt; + } + } + + nsStyleCoord& operator=(const nsStyleCoord& aCopy) { + mUnit = aCopy.mUnit; + if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) { + mValue.mFloat = aCopy.mValue.mFloat; + } + else { + mValue.mInt = aCopy.mValue.mInt; + } + return *this; + } + + PRBool operator==(const nsStyleCoord& aOther) const { + if (mUnit == aOther.mUnit) { + if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) { + return PRBool(mValue.mFloat == aOther.mValue.mFloat); + } + else { + return PRBool(mValue.mInt == aOther.mValue.mInt); + } + } + return PR_FALSE; + } + + PRBool operator!=(const nsStyleCoord& aOther) const; nsStyleUnit GetUnit(void) const { return mUnit; } nscoord GetCoordValue(void) const; @@ -65,18 +136,98 @@ public: float GetFactorValue(void) const; void GetUnionValue(nsStyleUnion& aValue) const; - void Reset(void); // sets to null - void SetCoordValue(nscoord aValue); - void SetIntValue(PRInt32 aValue, nsStyleUnit aUnit); - void SetPercentValue(float aValue); - void SetFactorValue(float aValue); - void SetNormalValue(void); - void SetAutoValue(void); - void SetInheritValue(void); - void SetUnionValue(const nsStyleUnion& aValue, nsStyleUnit aUnit); + void Reset(void) { + mUnit = eStyleUnit_Null; + mValue.mInt = 0; + } - void AppendToString(nsString& aBuffer) const; - void ToString(nsString& aBuffer) const; + void SetCoordValue(nscoord aValue) { + mUnit = eStyleUnit_Coord; + mValue.mInt = aValue; + } + + void SetIntValue(PRInt32 aValue, nsStyleUnit aUnit) { + if ((aUnit == eStyleUnit_Proportional) || + (aUnit == eStyleUnit_Enumerated) || + (aUnit == eStyleUnit_Chars) || + (aUnit == eStyleUnit_Integer)) { + mUnit = aUnit; + mValue.mInt = aValue; + } + else { + NS_WARNING("not an int value"); + Reset(); + } + } + + void SetPercentValue(float aValue) { + mUnit = eStyleUnit_Percent; + mValue.mFloat = aValue; + } + + void SetFactorValue(float aValue) { + mUnit = eStyleUnit_Factor; + mValue.mFloat = aValue; + } + + void SetNormalValue(void) { + mUnit = eStyleUnit_Normal; + mValue.mInt = 0; + } + + void SetAutoValue(void) { + mUnit = eStyleUnit_Auto; + mValue.mInt = 0; + } + + void SetInheritValue(void) { + mUnit = eStyleUnit_Inherit; + mValue.mInt = 0; + } + + void SetUnionValue(const nsStyleUnion& aValue, nsStyleUnit aUnit) { + mUnit = aUnit; +#if PR_BYTES_PER_INT == PR_BYTES_PER_FLOAT + mValue.mInt = aValue.mInt; +#else + nsCRT::memcpy(&mValue, &aValue, sizeof(nsStyleUnion)); +#endif + } + + void AppendToString(nsString& aBuffer) const { + if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) { + aBuffer.AppendFloat(mValue.mFloat); + } + else if ((eStyleUnit_Coord == mUnit) || + (eStyleUnit_Proportional == mUnit) || + (eStyleUnit_Enumerated == mUnit) || + (eStyleUnit_Integer == mUnit)) { + aBuffer.AppendInt(mValue.mInt, 10); + aBuffer.AppendWithConversion("[0x"); + aBuffer.AppendInt(mValue.mInt, 16); + aBuffer.AppendWithConversion(']'); + } + + switch (mUnit) { + case eStyleUnit_Null: aBuffer.AppendWithConversion("Null"); break; + case eStyleUnit_Coord: aBuffer.AppendWithConversion("tw"); break; + case eStyleUnit_Percent: aBuffer.AppendWithConversion("%"); break; + case eStyleUnit_Factor: aBuffer.AppendWithConversion("f"); break; + case eStyleUnit_Normal: aBuffer.AppendWithConversion("Normal"); break; + case eStyleUnit_Auto: aBuffer.AppendWithConversion("Auto"); break; + case eStyleUnit_Inherit: aBuffer.AppendWithConversion("Inherit"); break; + case eStyleUnit_Proportional: aBuffer.AppendWithConversion("*"); break; + case eStyleUnit_Enumerated: aBuffer.AppendWithConversion("enum"); break; + case eStyleUnit_Integer: aBuffer.AppendWithConversion("int"); break; + case eStyleUnit_Chars: aBuffer.AppendWithConversion("chars"); break; + } + aBuffer.AppendWithConversion(' '); + } + + void ToString(nsString& aBuffer) const { + aBuffer.Truncate(); + AppendToString(aBuffer); + } public: nsStyleUnit mUnit; @@ -84,12 +235,38 @@ public: }; +#define COMPARE_SIDE(side) \ + if ((eStyleUnit_Percent <= m##side##Unit) && \ + (m##side##Unit < eStyleUnit_Coord)) { \ + if (m##side##Value.mFloat != aOther.m##side##Value.mFloat) \ + return PR_FALSE; \ + } \ + else { \ + if (m##side##Value.mInt != aOther.m##side##Value.mInt) \ + return PR_FALSE; \ + } + class nsStyleSides { public: - nsStyleSides(void); + nsStyleSides(void) { + nsCRT::memset(this, 0x00, sizeof(nsStyleSides)); + } // nsStyleSides& operator=(const nsStyleSides& aCopy); // use compiler's version - PRBool operator==(const nsStyleSides& aOther) const; + PRBool operator==(const nsStyleSides& aOther) const { + if ((mLeftUnit == aOther.mLeftUnit) && + (mTopUnit == aOther.mTopUnit) && + (mRightUnit == aOther.mRightUnit) && + (mBottomUnit == aOther.mBottomUnit)) { + COMPARE_SIDE(Left); + COMPARE_SIDE(Top); + COMPARE_SIDE(Right); + COMPARE_SIDE(Bottom); + return PR_TRUE; + } + return PR_FALSE; + } + PRBool operator!=(const nsStyleSides& aOther) const; nsStyleUnit GetLeftUnit(void) const; @@ -102,14 +279,39 @@ public: nsStyleCoord& GetRight(nsStyleCoord& aCoord) const; nsStyleCoord& GetBottom(nsStyleCoord& aCoord) const; - void Reset(void); + void Reset(void) { + nsCRT::memset(this, 0x00, sizeof(nsStyleSides)); + } + void SetLeft(const nsStyleCoord& aCoord); void SetTop(const nsStyleCoord& aCoord); void SetRight(const nsStyleCoord& aCoord); void SetBottom(const nsStyleCoord& aCoord); - void AppendToString(nsString& aBuffer) const; - void ToString(nsString& aBuffer) const; + void AppendToString(nsString& aBuffer) const { + nsStyleCoord temp; + + GetLeft(temp); + aBuffer.AppendWithConversion("left: "); + temp.AppendToString(aBuffer); + + GetTop(temp); + aBuffer.AppendWithConversion("top: "); + temp.AppendToString(aBuffer); + + GetRight(temp); + aBuffer.AppendWithConversion("right: "); + temp.AppendToString(aBuffer); + + GetBottom(temp); + aBuffer.AppendWithConversion("bottom: "); + temp.AppendToString(aBuffer); + } + + void ToString(nsString& aBuffer) const { + aBuffer.Truncate(); + AppendToString(aBuffer); + } protected: PRUint8 mLeftUnit; diff --git a/content/shared/src/nsXULAtoms.cpp b/content/shared/src/nsXULAtoms.cpp index 653e4f1f20c0..0f7f2441a0e8 100644 --- a/content/shared/src/nsXULAtoms.cpp +++ b/content/shared/src/nsXULAtoms.cpp @@ -25,6 +25,8 @@ #include "nsString.h" #include "nsINameSpaceManager.h" #include "nsXULAtoms.h" +#include "nsContentCID.h" +static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); static const char kXULNameSpace[] = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; @@ -45,7 +47,7 @@ void nsXULAtoms::AddRefAtoms() { /* XUL Atoms registers the XUL name space ID because it's a convenient place to do this, if you don't want a permanent, "well-known" ID. */ - if (NS_SUCCEEDED(NS_NewNameSpaceManager(&gNameSpaceManager))) { + if (NS_SUCCEEDED(nsComponentManager::CreateInstance(kNameSpaceManagerCID,nsnull,NS_GET_IID(nsINameSpaceManager),(void**)&gNameSpaceManager))) { // gNameSpaceManager->CreateRootNameSpace(namespace); nsAutoString nameSpace; nameSpace.AssignWithConversion(kXULNameSpace); gNameSpaceManager->RegisterNameSpace(nameSpace, nameSpaceID); diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 906f0f494f65..479f0cebd1b6 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -101,6 +101,7 @@ #include "nsIXULTemplateBuilder.h" #include "nsIXBLService.h" #include "nsLayoutCID.h" +#include "nsContentCID.h" #include "nsRDFCID.h" #include "nsRDFDOMNodeList.h" #include "nsStyleConsts.h" diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 17c60632f230..ff011a1eaca7 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -106,6 +106,7 @@ #include "nsIXULPrototypeCache.h" #include "nsLWBrkCIID.h" #include "nsLayoutCID.h" +#include "nsContentCID.h" #include "nsNetUtil.h" #include "nsParserCIID.h" #include "nsPIBoxObject.h" diff --git a/dom/src/base/nsWindowRoot.cpp b/dom/src/base/nsWindowRoot.cpp index 110d68c55667..9a23e70e97ea 100644 --- a/dom/src/base/nsWindowRoot.cpp +++ b/dom/src/base/nsWindowRoot.cpp @@ -29,6 +29,7 @@ #include "nsIPresShell.h" #include "nsIPresContext.h" #include "nsLayoutCID.h" +#include "nsContentCID.h" #include "nsIEventStateManager.h" #include "nsIPrivateDOMEvent.h" #include "nsIDOMWindowInternal.h" diff --git a/layout/Makefile.in b/layout/Makefile.in index 6e016e431dd8..b86bdbf56744 100644 --- a/layout/Makefile.in +++ b/layout/Makefile.in @@ -26,7 +26,7 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -DIRS = base html xml xul xbl xsl +DIRS = base html xul ifdef MOZ_MATHML DIRS += mathml @@ -36,7 +36,7 @@ ifdef MOZ_SVG DIRS += svg endif -DIRS += events build +DIRS += build ifdef ENABLE_TESTS DIRS += html/tests diff --git a/layout/base/Makefile.in b/layout/base/Makefile.in index 1423ebbebb8f..c7532e842ebf 100644 --- a/layout/base/Makefile.in +++ b/layout/base/Makefile.in @@ -28,9 +28,5 @@ include $(DEPTH)/config/autoconf.mk DIRS = public src -#ifdef ENABLE_TESTS -#DIRS += tests -#endif - include $(topsrcdir)/config/rules.mk diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 557f04b13c31..e8c56e08402d 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -37,7 +37,6 @@ #include "nsIPresContext.h" #include "nsILinkHandler.h" #include "nsIDocument.h" -#include "nsIHTMLTableCellElement.h" #include "nsTableColGroupFrame.h" #include "nsTableColFrame.h" #include "nsHTMLIIDs.h" @@ -80,6 +79,13 @@ #include "nsBoxLayoutState.h" #include "nsIBindingManager.h" #include "nsIXBLBinding.h" +#include "nsIElementFactory.h" +#include "nsContentCID.h" + +static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); +static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); +static NS_DEFINE_CID(kHTMLImageElementCID, NS_HTMLIMAGEELEMENT_CID); +static NS_DEFINE_CID(kAttributeContentCID, NS_ATTRIBUTECONTENT_CID); #include "nsIDOMWindowInternal.h" #include "nsPIDOMWindow.h" @@ -859,6 +865,22 @@ PRBool GetCaptionAdjustedParent(nsIFrame* aParentFrame, return haveCaption; } +nsresult NS_CreateCSSFrameConstructor(nsICSSFrameConstructor **aResult) +{ + NS_ENSURE_ARG_POINTER(aResult); + *aResult = nsnull; + + nsCSSFrameConstructor *c = new nsCSSFrameConstructor(); + if (!c) + return NS_ERROR_OUT_OF_MEMORY; + + NS_ADDREF(c); + nsresult rv = c->QueryInterface(NS_GET_IID(nsICSSFrameConstructor),(void**)aResult); + NS_RELEASE(c); + + return rv; +} + nsCSSFrameConstructor::nsCSSFrameConstructor(void) : nsIStyleFrameConstruction(), mDocument(nsnull), @@ -886,7 +908,7 @@ nsCSSFrameConstructor::~nsCSSFrameConstructor(void) { } -NS_IMPL_ISUPPORTS(nsCSSFrameConstructor, kIStyleFrameConstructionIID); +NS_IMPL_ISUPPORTS2(nsCSSFrameConstructor, nsIStyleFrameConstruction,nsICSSFrameConstructor); NS_IMETHODIMP nsCSSFrameConstructor::Init(nsIDocument* aDocument) @@ -1268,8 +1290,6 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex aPresContext->GetShell(getter_AddRefs(shell)); if (eStyleContentType_URL == type) { - nsIHTMLContent* imageContent; - // Create an HTML image content object, and set the SRC. // XXX Check if it's an image type we can handle... @@ -1281,7 +1301,16 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex nimgr->GetNodeInfo(nsHTMLAtoms::img, nsnull, kNameSpaceID_None, *getter_AddRefs(nodeInfo)); - NS_NewHTMLImageElement(&imageContent, nodeInfo); + nsCOMPtr ef(do_CreateInstance(kHTMLElementFactoryCID,&rv)); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr content; + rv = ef->CreateInstanceByTag(nodeInfo,getter_AddRefs(content)); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr imageContent(do_QueryInterface(content,&rv)); + NS_ENSURE_SUCCESS(rv, rv); + imageContent->SetHTMLAttribute(nsHTMLAtoms::src, contentString, PR_FALSE); // Set aContent as the parent content and set the document object. This @@ -1293,7 +1322,6 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex nsIFrame* imageFrame; NS_NewImageFrame(shell, &imageFrame); imageFrame->Init(aPresContext, imageContent, aParentFrame, aStyleContext, nsnull); - NS_RELEASE(imageContent); // Return the image frame *aFrame = imageFrame; @@ -1326,10 +1354,9 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex // Creates the content and frame and return if successful nsresult rv = NS_ERROR_FAILURE; if (nsnull != attrName) { - nsCOMPtr content; nsIFrame* textFrame = nsnull; - NS_NewAttributeContent(getter_AddRefs(content)); - if (nsnull != content) { + nsCOMPtr content(do_CreateInstance(kAttributeContentCID)); + if (content) { nsCOMPtr attrContent(do_QueryInterface(content)); if (attrContent) { attrContent->Init(aContent, attrNameSpace, attrName); @@ -1394,11 +1421,11 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex // Create a text content node - nsIContent* textContent = nsnull; nsIDOMCharacterData* domData; nsIFrame* textFrame = nsnull; - - NS_NewTextNode(&textContent); + + nsCOMPtr textContent(do_CreateInstance(kTextNodeCID)); + if (textContent) { // Set the text textContent->QueryInterface(NS_GET_IID(nsIDOMCharacterData), (void**)&domData); @@ -1413,8 +1440,6 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex // Create a text frame and initialize it NS_NewTextFrame(shell, &textFrame); textFrame->Init(aPresContext, textContent, aParentFrame, aStyleContext, nsnull); - - NS_RELEASE(textContent); } // Return the text frame @@ -9946,6 +9971,7 @@ nsCSSFrameConstructor::ConstructAlternateFrame(nsIPresShell* aPresShell, nsIFrame* aParentFrame, nsIFrame*& aFrame) { + nsresult rv; nsAutoString altText; // Initialize OUT parameter @@ -9957,8 +9983,9 @@ nsCSSFrameConstructor::ConstructAlternateFrame(nsIPresShell* aPresShell, GetAlternateTextFor(aContent, tag, altText); // Create a text content element for the alternate text - nsCOMPtr altTextContent; - NS_NewTextNode(getter_AddRefs(altTextContent)); + nsCOMPtr altTextContent(do_CreateInstance(kTextNodeCID,&rv)); + if (NS_FAILED(rv)) + return rv; // Set the content's text nsIDOMCharacterData* domData; diff --git a/layout/base/nsCSSFrameConstructor.h b/layout/base/nsCSSFrameConstructor.h index 874965219f73..74b111d34c8d 100644 --- a/layout/base/nsCSSFrameConstructor.h +++ b/layout/base/nsCSSFrameConstructor.h @@ -22,6 +22,7 @@ #ifndef nsCSSFrameConstructor_h___ #define nsCSSFrameConstructor_h___ +#include "nsICSSFrameConstructor.h" #include "nsIStyleFrameConstruction.h" #include "nslayout.h" #include "nsIPresContext.h" @@ -44,7 +45,7 @@ class nsFrameConstructorState; class nsIDOMHTMLSelectElement; class nsIXBLService; -class nsCSSFrameConstructor : public nsIStyleFrameConstruction { +class nsCSSFrameConstructor : public nsIStyleFrameConstruction, public nsICSSFrameConstructor { public: nsCSSFrameConstructor(void); virtual ~nsCSSFrameConstructor(void); @@ -57,6 +58,7 @@ private: public: NS_DECL_ISUPPORTS + // nsICSSFrameConstructor NS_IMETHOD Init(nsIDocument* aDocument); // nsIStyleFrameConstruction API diff --git a/layout/base/nsFrameTraversal.cpp b/layout/base/nsFrameTraversal.cpp index 4b4c4d5f67f2..42663595dfb0 100644 --- a/layout/base/nsFrameTraversal.cpp +++ b/layout/base/nsFrameTraversal.cpp @@ -96,6 +96,21 @@ private : /************IMPLEMENTATIONS**************/ +nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult) +{ + NS_ENSURE_ARG_POINTER(aResult); + *aResult = nsnull; + + nsCOMPtr t(new nsFrameTraversal()); + if (!t) + return NS_ERROR_OUT_OF_MEMORY; + + *aResult = t; + NS_ADDREF(*aResult); + + return NS_OK; +} + nsresult NS_NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator, nsTraversalType aType, @@ -141,6 +156,27 @@ NS_NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator, } +nsFrameTraversal::nsFrameTraversal() +{ + NS_INIT_ISUPPORTS(); +} + +nsFrameTraversal::~nsFrameTraversal() +{ +} + +NS_IMPL_ISUPPORTS1(nsFrameTraversal,nsIFrameTraversal); + +NS_IMETHODIMP +nsFrameTraversal::NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator, + PRUint32 aType, + nsIPresContext* aPresContext, + nsIFrame *aStart) +{ + return NS_NewFrameTraversal(aEnumerator, NS_STATIC_CAST(nsTraversalType, + aType), + aPresContext, aStart); +} /*********nsFrameIterator************/ NS_IMPL_ISUPPORTS2(nsFrameIterator, nsIEnumerator, nsIBidirectionalEnumerator) diff --git a/layout/base/nsFrameTraversal.h b/layout/base/nsFrameTraversal.h index 085451969ba0..e18c1e984548 100644 --- a/layout/base/nsFrameTraversal.h +++ b/layout/base/nsFrameTraversal.h @@ -24,12 +24,27 @@ #include "nsIEnumerator.h" #include "nsIFrame.h" +#include "nsIFrameTraversal.h" -enum nsTraversalType{LEAF, EXTENSIVE, FASTEST}; nsresult NS_NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator, nsTraversalType aType, nsIPresContext* aPresContext, nsIFrame *aStart); +nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult); + +class nsFrameTraversal : public nsIFrameTraversal +{ +public: + nsFrameTraversal(); + virtual ~nsFrameTraversal(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator, + PRUint32 aType, + nsIPresContext* aPresContext, + nsIFrame *aStart); +}; #endif //NSFRAMETRAVERSAL_H diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index bbdd96a06dba..99d7d05ecda8 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -44,7 +44,6 @@ #include "nsIContent.h" #include "nsIFrame.h" #include "nsIRenderingContext.h" -#include "nsEventStateManager.h" #include "nsIURL.h" #include "nsIDocument.h" #include "nsIStyleContext.h" @@ -73,6 +72,8 @@ PrefChangedCallback(const char* aPrefName, void* instance_data) } static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); +#include "nsContentCID.h" +static NS_DEFINE_CID(kEventStateManagerCID, NS_EVENTSTATEMANAGER_CID); nsPresContext::nsPresContext() : mDefaultFont("serif", NS_FONT_STYLE_NORMAL, @@ -1270,8 +1271,9 @@ nsPresContext::GetEventStateManager(nsIEventStateManager** aManager) } if (!mEventManager) { - nsresult rv = NS_NewEventStateManager(getter_AddRefs(mEventManager)); - if (NS_OK != rv) { + nsresult rv; + mEventManager = do_CreateInstance(kEventStateManagerCID,&rv); + if (NS_FAILED(rv)) { return rv; } } diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index fe253ae61434..18527d22e629 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -135,6 +135,10 @@ // SubShell map #include "nsDST.h" +#include "nsContentCID.h" +static NS_DEFINE_CID(kCSSStyleSheetCID, NS_CSS_STYLESHEET_CID); +static NS_DEFINE_CID(kStyleSetCID, NS_STYLESET_CID); + // supporting bugs 31816, 20760, 22963 // define USE_OVERRIDE to put prefs in as an override stylesheet // otherwise they go in as a Backstop stylesheets @@ -1813,7 +1817,7 @@ nsresult PresShell::CreatePreferenceStyleSheet(void) NS_ASSERTION(mPrefStyleSheet==nsnull, "prefStyleSheet already exists"); nsresult result = NS_OK; - result = NS_NewCSSStyleSheet(&mPrefStyleSheet); + result = nsComponentManager::CreateInstance(kCSSStyleSheetCID,nsnull,NS_GET_IID(nsICSSStyleSheet),(void**)&mPrefStyleSheet); if (NS_SUCCEEDED(result)) { NS_ASSERTION(mPrefStyleSheet, "null but no error"); nsCOMPtr uri; @@ -3608,7 +3612,7 @@ PresShell::DoCopy() rv = nsCopySupport::HTMLCopy(sel, doc, nsIClipboard::kGlobalClipboard); if (NS_FAILED(rv)) return rv; - + // Now that we have copied, update the Paste menu item nsCOMPtr globalObject; doc->GetScriptGlobalObject(getter_AddRefs(globalObject)); @@ -5170,8 +5174,8 @@ PresShell::SetReflowEventStatus(PRBool aPending) nsresult PresShell::CloneStyleSet(nsIStyleSet* aSet, nsIStyleSet** aResult) { - nsIStyleSet* clone; - nsresult rv = NS_NewStyleSet(&clone); + nsresult rv; + nsCOMPtr clone(do_CreateInstance(kStyleSetCID,&rv)); if (NS_FAILED(rv)) { return rv; } @@ -5206,7 +5210,8 @@ PresShell::CloneStyleSet(nsIStyleSet* aSet, nsIStyleSet** aResult) NS_RELEASE(ss); } } - *aResult = clone; + *aResult = clone.get(); + NS_ADDREF(*aResult); return NS_OK; } diff --git a/layout/base/public/MANIFEST b/layout/base/public/MANIFEST index 9c440c7de587..24637cfa8406 100644 --- a/layout/base/public/MANIFEST +++ b/layout/base/public/MANIFEST @@ -1,31 +1,22 @@ # # This is a list of local files which get copied to the mozilla:dist:layout directory # -nslayout.h +nsFrameList.h +nsFrameTraversal.h nsHTMLReflowState.h nsIAutoCopy.h nsICaret.h -nsIContent.h -nsIContentIterator.h -nsContentPolicyUtils.h -nsIDocument.h -nsIDocumentContainer.h -nsIDocumentEncoder.h -nsIDocumentObserver.h -nsIDocumentViewer.h -nsIElementFactory.h nsIFocusTracker.h nsIFrame.h nsIFrameDebug.h -nsIFrameSelection.h -nsIFrameUtil.h nsIFrameImageLoader.h nsIFrameManager.h +nsIFrameSelection.h +nsIFrameUtil.h nsIIndependentSelection.h nsILayoutDebugger.h -nsINameSpace.h -nsINameSpaceManager.h -nsINodeInfo.h +nsILayoutHistoryState.h +nsIMutableStyleContext.h nsIPageSequenceFrame.h nsIPresContext.h nsIPresShell.h @@ -33,32 +24,21 @@ nsIPresState.h nsIPrintContext.h nsIReflowCallback.h nsIReflowCommand.h +nsIScrollableFrame.h +nsIScrollableViewProvider.h nsISpaceManager.h -nsFrameList.h -nsFrameTraversal.h -nsLayoutAtoms.h +nsIStatefulFrame.h +nsIStyleContext.h +nsIStyleSet.h +nslayout.h nsLayoutAtomList.h +nsLayoutAtoms.h nsLayoutUtils.h nsStyleChangeList.h -nsStyleCoord.h -nsStyleStruct.h nsStyleConsts.h -nsIStyledContent.h -nsIStyleContext.h -nsIMutableStyleContext.h -nsIStyleRule.h -nsIStyleRuleSupplier.h -nsIStyleSet.h -nsIStyleSheet.h -nsIStyleSheetLinkingElement.h -nsIStyleRuleProcessor.h -nsITextContent.h -nsTextFragment.h -nsIAnonymousContent.h -nsILayoutHistoryState.h -nsIStatefulFrame.h -nsIScrollableFrame.h -nsIPrivateDOMImplementation.h -nsIContentSerializer.h -nsIHTMLToTextSink.h -nsIScrollableViewProvider.h +nsStyleCoord.h +nsIStyleFrameConstruction.h +nsStyleStruct.h +nsIFrameTraversal.h +nsIObjectFrame.h +nsIImageFrame.h diff --git a/layout/base/public/Makefile.in b/layout/base/public/Makefile.in index 1d25f2c38708..84d0ca0471bb 100644 --- a/layout/base/public/Makefile.in +++ b/layout/base/public/Makefile.in @@ -34,25 +34,16 @@ nslayout.h \ nsHTMLReflowState.h \ nsIAutoCopy.h \ nsICaret.h \ -nsIContent.h \ -nsIContentIterator.h \ -nsContentPolicyUtils.h \ -nsIDocument.h \ -nsIDocumentContainer.h \ -nsIDocumentEncoder.h \ -nsIDocumentObserver.h \ -nsIDocumentViewer.h \ -nsIElementFactory.h \ nsIFocusTracker.h \ nsIFrame.h \ +nsIImageFrame.h \ +nsIObjectFrame.h \ +nsIFrameTraversal.h \ nsIFrameDebug.h \ nsIFrameImageLoader.h \ nsIFrameManager.h \ nsIIndependentSelection.h \ nsILayoutDebugger.h \ -nsINameSpace.h \ -nsINameSpaceManager.h \ -nsINodeInfo.h \ nsIFrameUtil.h \ nsIPageSequenceFrame.h \ nsIPresContext.h \ @@ -63,17 +54,10 @@ nsIReflowCallback.h \ nsIReflowCommand.h \ nsIFrameSelection.h \ nsISpaceManager.h \ -nsIStyledContent.h \ nsIStyleContext.h \ nsIMutableStyleContext.h \ nsIStyleFrameConstruction.h \ -nsIStyleRule.h \ -nsIStyleRuleSupplier.h \ nsIStyleSet.h \ -nsIStyleSheet.h \ -nsIStyleSheetLinkingElement.h \ -nsIStyleRuleProcessor.h \ -nsITextContent.h \ nsLayoutAtoms.h \ nsLayoutAtomList.h \ nsLayoutUtils.h \ @@ -83,24 +67,14 @@ nsStyleChangeList.h \ nsStyleConsts.h \ nsStyleCoord.h \ nsStyleStruct.h \ -nsTextFragment.h \ nsILayoutHistoryState.h \ nsIStatefulFrame.h \ nsIScrollableFrame.h \ -nsIPrivateDOMImplementation.h \ -nsIContentSerializer.h \ -nsIHTMLToTextSink.h \ nsIScrollableViewProvider.h \ $(NULL) XPIDLSRCS = \ nsIChromeEventHandler.idl \ - nsIContentPolicy.idl \ - nsIDiskDocument.idl \ - nsISelectionController.idl \ - nsISelectionListener.idl \ - nsISelection.idl \ - nsISelectionPrivate.idl \ nsIPrintListener.idl \ $(NULL) diff --git a/layout/base/public/makefile.win b/layout/base/public/makefile.win index fa7df78c56a5..948610c8e546 100644 --- a/layout/base/public/makefile.win +++ b/layout/base/public/makefile.win @@ -23,28 +23,19 @@ DEPTH=..\..\.. EXPORTS = \ nslayout.h \ - nsContentPolicyUtils.h \ nsHTMLReflowState.h \ nsIAutoCopy.h \ nsICaret.h \ - nsIContent.h \ - nsIContentIterator.h \ - nsIDocument.h \ - nsIDocumentContainer.h \ - nsIDocumentEncoder.h \ - nsIDocumentObserver.h \ - nsIDocumentViewer.h \ - nsIElementFactory.h \ nsIFocusTracker.h \ nsIFrame.h \ + nsIObjectFrame.h \ + nsIImageFrame.h \ + nsIFrameTraversal.h \ nsIFrameDebug.h \ nsIFrameImageLoader.h \ nsIFrameManager.h \ nsIIndependentSelection.h \ nsILayoutDebugger.h \ - nsINameSpace.h \ - nsINameSpaceManager.h \ - nsINodeInfo.h \ nsIFrameUtil.h \ nsIPageSequenceFrame.h \ nsIPresContext.h \ @@ -54,17 +45,10 @@ EXPORTS = \ nsIReflowCommand.h \ nsIFrameSelection.h \ nsISpaceManager.h \ - nsIStyledContent.h \ nsIStyleContext.h \ nsIMutableStyleContext.h \ nsIStyleFrameConstruction.h \ - nsIStyleRule.h \ - nsIStyleRuleSupplier.h \ nsIStyleSet.h \ - nsIStyleSheet.h \ - nsIStyleSheetLinkingElement.h \ - nsIStyleRuleProcessor.h \ - nsITextContent.h \ nsLayoutAtoms.h \ nsLayoutAtomList.h \ nsLayoutUtils.h \ @@ -74,13 +58,9 @@ EXPORTS = \ nsStyleConsts.h \ nsStyleCoord.h \ nsStyleStruct.h \ - nsTextFragment.h \ nsILayoutHistoryState.h \ nsIStatefulFrame.h \ nsIScrollableFrame.h \ - nsIPrivateDOMImplementation.h \ - nsIContentSerializer.h \ - nsIHTMLToTextSink.h \ nsIScrollableViewProvider.h \ nsIPrintContext.h \ $(NULL) @@ -89,12 +69,6 @@ MODULE=layout_base XPIDLSRCS= \ .\nsIChromeEventHandler.idl \ - .\nsIContentPolicy.idl \ - .\nsIDiskDocument.idl \ - .\nsISelectionController.idl \ - .\nsISelectionListener.idl \ - .\nsISelection.idl \ - .\nsISelectionPrivate.idl \ .\nsIPrintListener.idl \ $(NULL) diff --git a/layout/base/public/nsFrameTraversal.h b/layout/base/public/nsFrameTraversal.h index 085451969ba0..e18c1e984548 100644 --- a/layout/base/public/nsFrameTraversal.h +++ b/layout/base/public/nsFrameTraversal.h @@ -24,12 +24,27 @@ #include "nsIEnumerator.h" #include "nsIFrame.h" +#include "nsIFrameTraversal.h" -enum nsTraversalType{LEAF, EXTENSIVE, FASTEST}; nsresult NS_NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator, nsTraversalType aType, nsIPresContext* aPresContext, nsIFrame *aStart); +nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult); + +class nsFrameTraversal : public nsIFrameTraversal +{ +public: + nsFrameTraversal(); + virtual ~nsFrameTraversal(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator, + PRUint32 aType, + nsIPresContext* aPresContext, + nsIFrame *aStart); +}; #endif //NSFRAMETRAVERSAL_H diff --git a/layout/base/public/nsIStyleContext.h b/layout/base/public/nsIStyleContext.h index 22cee29a463d..939c7c35ab8c 100644 --- a/layout/base/public/nsIStyleContext.h +++ b/layout/base/public/nsIStyleContext.h @@ -36,12 +36,20 @@ #include "nsIStyleSet.h" #include "nsCOMPtr.h" #include "nsILanguageAtom.h" +#include "nsIFrame.h" class nsISizeOfHandler; class nsIFrame; class nsIPresContext; class nsISupportsArray; +class nsIStyleContext; + + +inline void CalcSidesFor(const nsIFrame* aFrame, const nsStyleSides& aSides, + PRUint8 aSpacing, + const nscoord* aEnumTable, PRInt32 aNumEnums, + nsMargin& aResult); #define SHARE_STYLECONTEXTS @@ -49,8 +57,13 @@ class nsISupportsArray; // The lifetime of these objects is managed by the nsIStyleContext. struct nsStyleFont : public nsStyleStruct { - nsStyleFont(void); - ~nsStyleFont(void); + nsStyleFont(void) + : mFont(nsnull, NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, + NS_FONT_WEIGHT_NORMAL, NS_FONT_DECORATION_NONE, 0), + mFixedFont(nsnull, NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, + NS_FONT_WEIGHT_NORMAL, NS_FONT_DECORATION_NONE, 0) + {} + ~nsStyleFont(void) {}; nsFont mFont; // [inherited] nsFont mFixedFont; // [inherited] @@ -62,8 +75,8 @@ protected: }; struct nsStyleColor : public nsStyleStruct { - nsStyleColor(void); - ~nsStyleColor(void); + nsStyleColor(void) {} + ~nsStyleColor(void) {} nscolor mColor; // [inherited] @@ -86,16 +99,39 @@ struct nsStyleColor : public nsStyleStruct { }; +#define BORDER_COLOR_DEFINED 0x80 +#define BORDER_COLOR_SPECIAL 0x40 +#define BORDER_STYLE_MASK 0x3F + +#define NS_SPACING_MARGIN 0 +#define NS_SPACING_PADDING 1 +#define NS_SPACING_BORDER 2 + + struct nsStyleMargin: public nsStyleStruct { - nsStyleMargin(void); - ~nsStyleMargin(void); + nsStyleMargin(void) {}; + ~nsStyleMargin(void) {}; nsStyleSides mMargin; // [reset] length, percent, auto, inherit - PRBool GetMargin(nsMargin& aMargin) const; + PRBool GetMargin(nsMargin& aMargin) const + { + if (mHasCachedMargin) { + aMargin = mCachedMargin; + return PR_TRUE; + } + return PR_FALSE; + } -// XXX this is a deprecated method - void CalcMarginFor(const nsIFrame* aFrame, nsMargin& aMargin) const; + // XXX this is a deprecated method + void CalcMarginFor(const nsIFrame* aFrame, nsMargin& aMargin) const + { + if (mHasCachedMargin) { + aMargin = mCachedMargin; + } else { + CalcSidesFor(aFrame, mMargin, NS_SPACING_MARGIN, nsnull, 0, aMargin); + } + } protected: PRPackedBool mHasCachedMargin; @@ -104,15 +140,29 @@ protected: struct nsStylePadding: public nsStyleStruct { - nsStylePadding(void); - ~nsStylePadding(void); + nsStylePadding(void) {}; + ~nsStylePadding(void) {}; nsStyleSides mPadding; // [reset] length, percent, inherit - PRBool GetPadding(nsMargin& aPadding) const; + PRBool GetPadding(nsMargin& aPadding) const + { + if (mHasCachedPadding) { + aPadding = mCachedPadding; + return PR_TRUE; + } + return PR_FALSE; + } -// XXX this is a deprecated method - void CalcPaddingFor(const nsIFrame* aFrame, nsMargin& aPadding) const; + // XXX this is a deprecated method + void CalcPaddingFor(const nsIFrame* aFrame, nsMargin& aPadding) const + { + if (mHasCachedPadding) { + aPadding = mCachedPadding; + } else { + CalcSidesFor(aFrame, mPadding, NS_SPACING_PADDING, nsnull, 0, aPadding); + } + } protected: PRPackedBool mHasCachedPadding; @@ -121,24 +171,76 @@ protected: struct nsStyleBorder: public nsStyleStruct { - nsStyleBorder(void); - ~nsStyleBorder(void); + nsStyleBorder(void) {}; + ~nsStyleBorder(void) {}; nsStyleSides mBorder; // [reset] length, enum (see nsStyleConsts.h) nsStyleSides mBorderRadius; // [reset] length, percent, inherit PRUint8 mFloatEdge; // [reset] see nsStyleConsts.h - PRBool GetBorder(nsMargin& aBorder) const; + PRBool GetBorder(nsMargin& aBorder) const + { + if (mHasCachedBorder) { + aBorder = mCachedBorder; + return PR_TRUE; + } + return PR_FALSE; + } - PRUint8 GetBorderStyle(PRUint8 aSide) const; - void SetBorderStyle(PRUint8 aSide, PRUint8 aStyle); - PRBool GetBorderColor(PRUint8 aSide, nscolor& aColor) const; // PR_FALSE means TRANSPARENT - void SetBorderColor(PRUint8 aSide, nscolor aColor); - void SetBorderTransparent(PRUint8 aSide); - void UnsetBorderColor(PRUint8 aSide); + PRUint8 GetBorderStyle(PRUint8 aSide) const + { + NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side"); + return (mBorderStyle[aSide] & BORDER_STYLE_MASK); + } -// XXX these are deprecated methods - void CalcBorderFor(const nsIFrame* aFrame, nsMargin& aBorder) const; + void SetBorderStyle(PRUint8 aSide, PRUint8 aStyle) + { + NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side"); + mBorderStyle[aSide] &= ~BORDER_STYLE_MASK; + mBorderStyle[aSide] |= (aStyle & BORDER_STYLE_MASK); + + } + + // PR_FALSE means TRANSPARENT + PRBool GetBorderColor(PRUint8 aSide, nscolor& aColor) const + { + NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side"); + if ((mBorderStyle[aSide] & BORDER_COLOR_SPECIAL) == 0) { + aColor = mBorderColor[aSide]; + return PR_TRUE; + } + return PR_FALSE; + } + + void SetBorderColor(PRUint8 aSide, nscolor aColor) + { + NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side"); + mBorderColor[aSide] = aColor; + mBorderStyle[aSide] &= ~BORDER_COLOR_SPECIAL; + mBorderStyle[aSide] |= BORDER_COLOR_DEFINED; + } + + void SetBorderTransparent(PRUint8 aSide) + { + NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side"); + mBorderStyle[aSide] |= (BORDER_COLOR_DEFINED | BORDER_COLOR_SPECIAL); + } + + void UnsetBorderColor(PRUint8 aSide) + { + NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side"); + mBorderStyle[aSide] &= BORDER_STYLE_MASK; + } + + // XXX these are deprecated methods + void CalcBorderFor(const nsIFrame* aFrame, nsMargin& aBorder) const + { + if (mHasCachedBorder) { + aBorder = mCachedBorder; + } else { + CalcSidesFor(aFrame, mBorder, NS_SPACING_BORDER, mBorderWidths, 3, aBorder); + } + } protected: PRPackedBool mHasCachedBorder; @@ -146,15 +248,29 @@ protected: PRUint8 mBorderStyle[4]; // [reset] See nsStyleConsts.h nscolor mBorderColor[4]; // [reset] + + // XXX remove with deprecated methods + nscoord mBorderWidths[3]; }; struct nsStyleBorderPadding: public nsStyleStruct { - nsStyleBorderPadding(void); - ~nsStyleBorderPadding(void); + nsStyleBorderPadding(void) { mHasCachedBorderPadding = PR_FALSE; }; + ~nsStyleBorderPadding(void) {}; + + PRBool GetBorderPadding(nsMargin& aBorderPadding) const { + if (mHasCachedBorderPadding) { + aBorderPadding = mCachedBorderPadding; + return PR_TRUE; + } + return PR_FALSE; + } + + void SetBorderPadding(nsMargin aBorderPadding) { + mCachedBorderPadding = aBorderPadding; + mHasCachedBorderPadding = PR_TRUE; + } - PRBool GetBorderPadding(nsMargin& aBorderPadding) const; - void SetBorderPadding(nsMargin aBorderPadding); protected: nsMargin mCachedBorderPadding; PRPackedBool mHasCachedBorderPadding; @@ -162,21 +278,55 @@ protected: struct nsStyleOutline: public nsStyleStruct { - nsStyleOutline(void); - ~nsStyleOutline(void); + nsStyleOutline(void) {}; + ~nsStyleOutline(void) {}; nsStyleSides mOutlineRadius; // [reset] length, percent, inherit // (top=topLeft, right=topRight, bottom=bottomRight, left=bottomLeft) nsStyleCoord mOutlineWidth; // [reset] length, enum (see nsStyleConsts.h) - PRBool GetOutlineWidth(nscoord& aWidth) const; // PR_TRUE if pre-computed - PRUint8 GetOutlineStyle(void) const; - void SetOutlineStyle(PRUint8 aStyle); - PRBool GetOutlineColor(nscolor& aColor) const; // PR_FALSE means INVERT - void SetOutlineColor(nscolor aColor); - void SetOutlineInvert(void); + PRBool GetOutlineWidth(nscoord& aWidth) const + { + if (mHasCachedOutline) { + aWidth = mCachedOutlineWidth; + return PR_TRUE; + } + return PR_FALSE; + } + PRUint8 GetOutlineStyle(void) const + { + return (mOutlineStyle & BORDER_STYLE_MASK); + } + + void SetOutlineStyle(PRUint8 aStyle) + { + mOutlineStyle &= ~BORDER_STYLE_MASK; + mOutlineStyle |= (aStyle & BORDER_STYLE_MASK); + } + + // PR_FALSE means INVERT + PRBool GetOutlineColor(nscolor& aColor) const + { + if ((mOutlineStyle & BORDER_COLOR_SPECIAL) == 0) { + aColor = mOutlineColor; + return PR_TRUE; + } + return PR_FALSE; + } + + void SetOutlineColor(nscolor aColor) + { + mOutlineColor = aColor; + mOutlineStyle &= ~BORDER_COLOR_SPECIAL; + mOutlineStyle |= BORDER_COLOR_DEFINED; + } + + void SetOutlineInvert(void) + { + mOutlineStyle |= (BORDER_COLOR_DEFINED | BORDER_COLOR_SPECIAL); + } protected: PRPackedBool mHasCachedOutline; @@ -184,6 +334,9 @@ protected: PRUint8 mOutlineStyle; // [reset] See nsStyleConsts.h nscolor mOutlineColor; // [reset] + + // XXX remove with deprecated methods + nscoord mBorderWidths[3]; }; @@ -241,8 +394,8 @@ struct nsStyleText : public nsStyleStruct { }; struct nsStyleDisplay : public nsStyleStruct { - nsStyleDisplay(void); - ~nsStyleDisplay(void); + nsStyleDisplay(void) {}; + ~nsStyleDisplay(void) {}; PRUint8 mDirection; // [inherited] see nsStyleConsts.h NS_STYLE_DIRECTION_* PRUint8 mDisplay; // [reset] see nsStyleConsts.h NS_STYLE_DISPLAY_* @@ -322,31 +475,157 @@ struct nsStyleCounterData { PRInt32 mValue; }; + +#define DELETE_ARRAY_IF(array) if (array) { delete[] array; array = nsnull; } + struct nsStyleContent: public nsStyleStruct { nsStyleContent(void); ~nsStyleContent(void); PRUint32 ContentCount(void) const { return mContentCount; } // [reset] - nsresult GetContentAt(PRUint32 aIndex, nsStyleContentType& aType, nsString& aContent) const; - nsresult AllocateContents(PRUint32 aCount); - nsresult SetContentAt(PRUint32 aIndex, nsStyleContentType aType, const nsString& aContent); + nsresult GetContentAt(PRUint32 aIndex, nsStyleContentType& aType, nsString& aContent) const { + if (aIndex < mContentCount) { + aType = mContents[aIndex].mType; + aContent = mContents[aIndex].mContent; + return NS_OK; + } + return NS_ERROR_ILLEGAL_VALUE; + } + + nsresult AllocateContents(PRUint32 aCount) { + if (aCount != mContentCount) { + DELETE_ARRAY_IF(mContents); + if (aCount) { + mContents = new nsStyleContentData[aCount]; + if (! mContents) { + mContentCount = 0; + return NS_ERROR_OUT_OF_MEMORY; + } + } + mContentCount = aCount; + } + return NS_OK; + } + + nsresult SetContentAt(PRUint32 aIndex, nsStyleContentType aType, const nsString& aContent) { + if (aIndex < mContentCount) { + mContents[aIndex].mType = aType; + if (aType < eStyleContentType_OpenQuote) { + mContents[aIndex].mContent = aContent; + } + else { + mContents[aIndex].mContent.Truncate(); + } + return NS_OK; + } + return NS_ERROR_ILLEGAL_VALUE; + } PRUint32 CounterIncrementCount(void) const { return mIncrementCount; } // [reset] - nsresult GetCounterIncrementAt(PRUint32 aIndex, nsString& aCounter, PRInt32& aIncrement) const; - nsresult AllocateCounterIncrements(PRUint32 aCount); - nsresult SetCounterIncrementAt(PRUint32 aIndex, const nsString& aCounter, PRInt32 aIncrement); + nsresult GetCounterIncrementAt(PRUint32 aIndex, nsString& aCounter, PRInt32& aIncrement) const { + if (aIndex < mIncrementCount) { + aCounter = mIncrements[aIndex].mCounter; + aIncrement = mIncrements[aIndex].mValue; + return NS_OK; + } + return NS_ERROR_ILLEGAL_VALUE; + } + + nsresult AllocateCounterIncrements(PRUint32 aCount) { + if (aCount != mIncrementCount) { + DELETE_ARRAY_IF(mIncrements); + if (aCount) { + mIncrements = new nsStyleCounterData[aCount]; + if (! mIncrements) { + mIncrementCount = 0; + return NS_ERROR_OUT_OF_MEMORY; + } + } + mIncrementCount = aCount; + } + return NS_OK; + } + + nsresult SetCounterIncrementAt(PRUint32 aIndex, const nsString& aCounter, PRInt32 aIncrement) { + if (aIndex < mIncrementCount) { + mIncrements[aIndex].mCounter = aCounter; + mIncrements[aIndex].mValue = aIncrement; + return NS_OK; + } + return NS_ERROR_ILLEGAL_VALUE; + } PRUint32 CounterResetCount(void) const { return mResetCount; } // [reset] - nsresult GetCounterResetAt(PRUint32 aIndex, nsString& aCounter, PRInt32& aValue) const; - nsresult AllocateCounterResets(PRUint32 aCount); - nsresult SetCounterResetAt(PRUint32 aIndex, const nsString& aCounter, PRInt32 aValue); + nsresult GetCounterResetAt(PRUint32 aIndex, nsString& aCounter, PRInt32& aValue) const { + if (aIndex < mResetCount) { + aCounter = mResets[aIndex].mCounter; + aValue = mResets[aIndex].mValue; + return NS_OK; + } + return NS_ERROR_ILLEGAL_VALUE; + } + + nsresult AllocateCounterResets(PRUint32 aCount) { + if (aCount != mResetCount) { + DELETE_ARRAY_IF(mResets); + if (aCount) { + mResets = new nsStyleCounterData[aCount]; + if (! mResets) { + mResetCount = 0; + return NS_ERROR_OUT_OF_MEMORY; + } + } + mResetCount = aCount; + } + return NS_OK; + } + + nsresult SetCounterResetAt(PRUint32 aIndex, const nsString& aCounter, PRInt32 aValue) { + if (aIndex < mResetCount) { + mResets[aIndex].mCounter = aCounter; + mResets[aIndex].mValue = aValue; + return NS_OK; + } + return NS_ERROR_ILLEGAL_VALUE; + } nsStyleCoord mMarkerOffset; // [reset] PRUint32 QuotesCount(void) const { return mQuotesCount; } // [inherited] - nsresult GetQuotesAt(PRUint32 aIndex, nsString& aOpen, nsString& aClose) const; - nsresult AllocateQuotes(PRUint32 aCount); - nsresult SetQuotesAt(PRUint32 aIndex, const nsString& aOpen, const nsString& aClose); + nsresult GetQuotesAt(PRUint32 aIndex, nsString& aOpen, nsString& aClose) const { + if (aIndex < mQuotesCount) { + aIndex *= 2; + aOpen = mQuotes[aIndex]; + aClose = mQuotes[++aIndex]; + return NS_OK; + } + return NS_ERROR_ILLEGAL_VALUE; + } + + nsresult AllocateQuotes(PRUint32 aCount) { + if (aCount != mQuotesCount) { + DELETE_ARRAY_IF(mQuotes); + if (aCount) { + mQuotes = new nsString[aCount * 2]; + if (! mQuotes) { + mQuotesCount = 0; + return NS_ERROR_OUT_OF_MEMORY; + } + } + mQuotesCount = aCount; + } + return NS_OK; + } + + nsresult SetQuotesAt(PRUint32 aIndex, const nsString& aOpen, const nsString& aClose) { + if (aIndex < mQuotesCount) { + aIndex *= 2; + mQuotes[aIndex] = aOpen; + mQuotes[++aIndex] = aClose; + return NS_OK; + } + return NS_ERROR_ILLEGAL_VALUE; + } protected: PRUint32 mContentCount; @@ -508,6 +787,128 @@ public: virtual void CalcBorderPaddingFor(const nsIFrame* aFrame, nsMargin& aBorderPadding) const = 0; }; + +// XXX this is here to support deprecated calc spacing methods only +inline nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord, + PRUint8 aSpacing, PRUint8 aSide, + const nscoord* aEnumTable, PRInt32 aNumEnums) +{ + nscoord result = 0; + + switch (aCoord.GetUnit()) { + case eStyleUnit_Auto: + // Auto margins are handled by layout + break; + + case eStyleUnit_Inherit: + nsIFrame* parentFrame; + aFrame->GetParent(&parentFrame); // XXX may not be direct parent... + if (nsnull != parentFrame) { + nsIStyleContext* parentContext; + parentFrame->GetStyleContext(&parentContext); + if (nsnull != parentContext) { + nsMargin parentSpacing; + switch (aSpacing) { + case NS_SPACING_MARGIN: + { + const nsStyleMargin* parentMargin = (const nsStyleMargin*)parentContext->GetStyleData(eStyleStruct_Margin); + parentMargin->CalcMarginFor(parentFrame, parentSpacing); + } + + break; + case NS_SPACING_PADDING: + { + const nsStylePadding* parentPadding = (const nsStylePadding*)parentContext->GetStyleData(eStyleStruct_Padding); + parentPadding->CalcPaddingFor(parentFrame, parentSpacing); + } + + break; + case NS_SPACING_BORDER: + { + const nsStyleBorder* parentBorder = (const nsStyleBorder*)parentContext->GetStyleData(eStyleStruct_Border); + parentBorder->CalcBorderFor(parentFrame, parentSpacing); + } + + break; + } + switch (aSide) { + case NS_SIDE_LEFT: result = parentSpacing.left; break; + case NS_SIDE_TOP: result = parentSpacing.top; break; + case NS_SIDE_RIGHT: result = parentSpacing.right; break; + case NS_SIDE_BOTTOM: result = parentSpacing.bottom; break; + } + NS_RELEASE(parentContext); + } + } + break; + + case eStyleUnit_Percent: + { + nscoord baseWidth = 0; + PRBool isBase = PR_FALSE; + nsIFrame* frame; + aFrame->GetParent(&frame); + while (nsnull != frame) { + frame->IsPercentageBase(isBase); + if (isBase) { + nsSize size; + frame->GetSize(size); + baseWidth = size.width; // not really width, need to subtract out padding... + break; + } + frame->GetParent(&frame); + } + result = (nscoord)((float)baseWidth * aCoord.GetPercentValue()); + } + break; + + case eStyleUnit_Coord: + result = aCoord.GetCoordValue(); + break; + + case eStyleUnit_Enumerated: + if (nsnull != aEnumTable) { + PRInt32 value = aCoord.GetIntValue(); + if ((0 <= value) && (value < aNumEnums)) { + return aEnumTable[aCoord.GetIntValue()]; + } + } + break; + + case eStyleUnit_Null: + case eStyleUnit_Normal: + case eStyleUnit_Integer: + case eStyleUnit_Proportional: + default: + result = 0; + break; + } + if ((NS_SPACING_PADDING == aSpacing) || (NS_SPACING_BORDER == aSpacing)) { + if (result < 0) { + result = 0; + } + } + return result; +} + +inline void CalcSidesFor(const nsIFrame* aFrame, const nsStyleSides& aSides, + PRUint8 aSpacing, + const nscoord* aEnumTable, PRInt32 aNumEnums, + nsMargin& aResult) +{ + nsStyleCoord coord; + + aResult.left = CalcSideFor(aFrame, aSides.GetLeft(coord), aSpacing, NS_SIDE_LEFT, + aEnumTable, aNumEnums); + aResult.top = CalcSideFor(aFrame, aSides.GetTop(coord), aSpacing, NS_SIDE_TOP, + aEnumTable, aNumEnums); + aResult.right = CalcSideFor(aFrame, aSides.GetRight(coord), aSpacing, NS_SIDE_RIGHT, + aEnumTable, aNumEnums); + aResult.bottom = CalcSideFor(aFrame, aSides.GetBottom(coord), aSpacing, NS_SIDE_BOTTOM, + aEnumTable, aNumEnums); +} + + // this is private to nsStyleSet, don't call it extern NS_LAYOUT nsresult NS_NewStyleContext(nsIStyleContext** aInstancePtrResult, @@ -516,4 +917,5 @@ extern NS_LAYOUT nsresult nsISupportsArray* aRules, nsIPresContext* aPresContext); + #endif /* nsIStyleContext_h___ */ diff --git a/layout/base/public/nsIStyleFrameConstruction.h b/layout/base/public/nsIStyleFrameConstruction.h index 732dc6a79aea..93577a2b1774 100644 --- a/layout/base/public/nsIStyleFrameConstruction.h +++ b/layout/base/public/nsIStyleFrameConstruction.h @@ -47,6 +47,8 @@ class nsILayoutHistoryState; */ class nsIStyleFrameConstruction : public nsISupports { public: + NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISTYLE_FRAME_CONSTRUCTION_IID) + /** * Create frames for the root content element and its child content. * diff --git a/layout/base/public/nsStyleCoord.h b/layout/base/public/nsStyleCoord.h index bb97cd0a9cd1..067e0b3112c1 100644 --- a/layout/base/public/nsStyleCoord.h +++ b/layout/base/public/nsStyleCoord.h @@ -25,7 +25,7 @@ #include "nscore.h" #include "nsCoord.h" #include "nsCRT.h" -class nsString; +#include "nsString.h" enum nsStyleUnit { eStyleUnit_Null = 0, // (no value) value is not specified @@ -48,15 +48,86 @@ typedef union { class nsStyleCoord { public: - nsStyleCoord(nsStyleUnit aUnit = eStyleUnit_Null); - nsStyleCoord(nscoord aValue); - nsStyleCoord(PRInt32 aValue, nsStyleUnit aUnit); - nsStyleCoord(float aValue, nsStyleUnit aUnit); - nsStyleCoord(const nsStyleCoord& aCopy); + nsStyleCoord(nsStyleUnit aUnit = eStyleUnit_Null) + : mUnit(aUnit) { + NS_ASSERTION(aUnit < eStyleUnit_Percent, "not a valueless unit"); + if (aUnit >= eStyleUnit_Percent) { + mUnit = eStyleUnit_Null; + } + mValue.mInt = 0; + } - nsStyleCoord& operator=(const nsStyleCoord& aCopy); - PRBool operator==(const nsStyleCoord& aOther) const; - PRBool operator!=(const nsStyleCoord& aOther) const; + nsStyleCoord(nscoord aValue) + : mUnit(eStyleUnit_Coord) { + mValue.mInt = aValue; + } + + nsStyleCoord(PRInt32 aValue, nsStyleUnit aUnit) + : mUnit(aUnit) { + //if you want to pass in eStyleUnit_Coord, don't. instead, use the + //constructor just above this one... MMP + NS_ASSERTION((aUnit == eStyleUnit_Proportional) || + (aUnit == eStyleUnit_Enumerated) || + (aUnit == eStyleUnit_Integer), "not an int value"); + if ((aUnit == eStyleUnit_Proportional) || + (aUnit == eStyleUnit_Enumerated) || + (aUnit == eStyleUnit_Integer)) { + mValue.mInt = aValue; + } + else { + mUnit = eStyleUnit_Null; + mValue.mInt = 0; + } + } + + nsStyleCoord(float aValue, nsStyleUnit aUnit) + : mUnit(aUnit) { + NS_ASSERTION((aUnit == eStyleUnit_Percent) || + (aUnit == eStyleUnit_Factor), "not a float value"); + if ((aUnit == eStyleUnit_Percent) || + (aUnit == eStyleUnit_Factor)) { + mValue.mFloat = aValue; + } + else { + mUnit = eStyleUnit_Null; + mValue.mInt = 0; + } + } + + nsStyleCoord(const nsStyleCoord& aCopy) + : mUnit(aCopy.mUnit) { + if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) { + mValue.mFloat = aCopy.mValue.mFloat; + } + else { + mValue.mInt = aCopy.mValue.mInt; + } + } + + nsStyleCoord& operator=(const nsStyleCoord& aCopy) { + mUnit = aCopy.mUnit; + if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) { + mValue.mFloat = aCopy.mValue.mFloat; + } + else { + mValue.mInt = aCopy.mValue.mInt; + } + return *this; + } + + PRBool operator==(const nsStyleCoord& aOther) const { + if (mUnit == aOther.mUnit) { + if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) { + return PRBool(mValue.mFloat == aOther.mValue.mFloat); + } + else { + return PRBool(mValue.mInt == aOther.mValue.mInt); + } + } + return PR_FALSE; + } + + PRBool operator!=(const nsStyleCoord& aOther) const; nsStyleUnit GetUnit(void) const { return mUnit; } nscoord GetCoordValue(void) const; @@ -65,18 +136,98 @@ public: float GetFactorValue(void) const; void GetUnionValue(nsStyleUnion& aValue) const; - void Reset(void); // sets to null - void SetCoordValue(nscoord aValue); - void SetIntValue(PRInt32 aValue, nsStyleUnit aUnit); - void SetPercentValue(float aValue); - void SetFactorValue(float aValue); - void SetNormalValue(void); - void SetAutoValue(void); - void SetInheritValue(void); - void SetUnionValue(const nsStyleUnion& aValue, nsStyleUnit aUnit); + void Reset(void) { + mUnit = eStyleUnit_Null; + mValue.mInt = 0; + } - void AppendToString(nsString& aBuffer) const; - void ToString(nsString& aBuffer) const; + void SetCoordValue(nscoord aValue) { + mUnit = eStyleUnit_Coord; + mValue.mInt = aValue; + } + + void SetIntValue(PRInt32 aValue, nsStyleUnit aUnit) { + if ((aUnit == eStyleUnit_Proportional) || + (aUnit == eStyleUnit_Enumerated) || + (aUnit == eStyleUnit_Chars) || + (aUnit == eStyleUnit_Integer)) { + mUnit = aUnit; + mValue.mInt = aValue; + } + else { + NS_WARNING("not an int value"); + Reset(); + } + } + + void SetPercentValue(float aValue) { + mUnit = eStyleUnit_Percent; + mValue.mFloat = aValue; + } + + void SetFactorValue(float aValue) { + mUnit = eStyleUnit_Factor; + mValue.mFloat = aValue; + } + + void SetNormalValue(void) { + mUnit = eStyleUnit_Normal; + mValue.mInt = 0; + } + + void SetAutoValue(void) { + mUnit = eStyleUnit_Auto; + mValue.mInt = 0; + } + + void SetInheritValue(void) { + mUnit = eStyleUnit_Inherit; + mValue.mInt = 0; + } + + void SetUnionValue(const nsStyleUnion& aValue, nsStyleUnit aUnit) { + mUnit = aUnit; +#if PR_BYTES_PER_INT == PR_BYTES_PER_FLOAT + mValue.mInt = aValue.mInt; +#else + nsCRT::memcpy(&mValue, &aValue, sizeof(nsStyleUnion)); +#endif + } + + void AppendToString(nsString& aBuffer) const { + if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) { + aBuffer.AppendFloat(mValue.mFloat); + } + else if ((eStyleUnit_Coord == mUnit) || + (eStyleUnit_Proportional == mUnit) || + (eStyleUnit_Enumerated == mUnit) || + (eStyleUnit_Integer == mUnit)) { + aBuffer.AppendInt(mValue.mInt, 10); + aBuffer.AppendWithConversion("[0x"); + aBuffer.AppendInt(mValue.mInt, 16); + aBuffer.AppendWithConversion(']'); + } + + switch (mUnit) { + case eStyleUnit_Null: aBuffer.AppendWithConversion("Null"); break; + case eStyleUnit_Coord: aBuffer.AppendWithConversion("tw"); break; + case eStyleUnit_Percent: aBuffer.AppendWithConversion("%"); break; + case eStyleUnit_Factor: aBuffer.AppendWithConversion("f"); break; + case eStyleUnit_Normal: aBuffer.AppendWithConversion("Normal"); break; + case eStyleUnit_Auto: aBuffer.AppendWithConversion("Auto"); break; + case eStyleUnit_Inherit: aBuffer.AppendWithConversion("Inherit"); break; + case eStyleUnit_Proportional: aBuffer.AppendWithConversion("*"); break; + case eStyleUnit_Enumerated: aBuffer.AppendWithConversion("enum"); break; + case eStyleUnit_Integer: aBuffer.AppendWithConversion("int"); break; + case eStyleUnit_Chars: aBuffer.AppendWithConversion("chars"); break; + } + aBuffer.AppendWithConversion(' '); + } + + void ToString(nsString& aBuffer) const { + aBuffer.Truncate(); + AppendToString(aBuffer); + } public: nsStyleUnit mUnit; @@ -84,12 +235,38 @@ public: }; +#define COMPARE_SIDE(side) \ + if ((eStyleUnit_Percent <= m##side##Unit) && \ + (m##side##Unit < eStyleUnit_Coord)) { \ + if (m##side##Value.mFloat != aOther.m##side##Value.mFloat) \ + return PR_FALSE; \ + } \ + else { \ + if (m##side##Value.mInt != aOther.m##side##Value.mInt) \ + return PR_FALSE; \ + } + class nsStyleSides { public: - nsStyleSides(void); + nsStyleSides(void) { + nsCRT::memset(this, 0x00, sizeof(nsStyleSides)); + } // nsStyleSides& operator=(const nsStyleSides& aCopy); // use compiler's version - PRBool operator==(const nsStyleSides& aOther) const; + PRBool operator==(const nsStyleSides& aOther) const { + if ((mLeftUnit == aOther.mLeftUnit) && + (mTopUnit == aOther.mTopUnit) && + (mRightUnit == aOther.mRightUnit) && + (mBottomUnit == aOther.mBottomUnit)) { + COMPARE_SIDE(Left); + COMPARE_SIDE(Top); + COMPARE_SIDE(Right); + COMPARE_SIDE(Bottom); + return PR_TRUE; + } + return PR_FALSE; + } + PRBool operator!=(const nsStyleSides& aOther) const; nsStyleUnit GetLeftUnit(void) const; @@ -102,14 +279,39 @@ public: nsStyleCoord& GetRight(nsStyleCoord& aCoord) const; nsStyleCoord& GetBottom(nsStyleCoord& aCoord) const; - void Reset(void); + void Reset(void) { + nsCRT::memset(this, 0x00, sizeof(nsStyleSides)); + } + void SetLeft(const nsStyleCoord& aCoord); void SetTop(const nsStyleCoord& aCoord); void SetRight(const nsStyleCoord& aCoord); void SetBottom(const nsStyleCoord& aCoord); - void AppendToString(nsString& aBuffer) const; - void ToString(nsString& aBuffer) const; + void AppendToString(nsString& aBuffer) const { + nsStyleCoord temp; + + GetLeft(temp); + aBuffer.AppendWithConversion("left: "); + temp.AppendToString(aBuffer); + + GetTop(temp); + aBuffer.AppendWithConversion("top: "); + temp.AppendToString(aBuffer); + + GetRight(temp); + aBuffer.AppendWithConversion("right: "); + temp.AppendToString(aBuffer); + + GetBottom(temp); + aBuffer.AppendWithConversion("bottom: "); + temp.AppendToString(aBuffer); + } + + void ToString(nsString& aBuffer) const { + aBuffer.Truncate(); + AppendToString(aBuffer); + } protected: PRUint8 mLeftUnit; diff --git a/layout/base/src/Makefile.in b/layout/base/src/Makefile.in index 125641becb99..9a960e32ffd2 100644 --- a/layout/base/src/Makefile.in +++ b/layout/base/src/Makefile.in @@ -33,51 +33,23 @@ REQUIRES = xpcom dom widget view locale timer htmlparser js webshell necko caps CPPSRCS = \ nsAutoCopy.cpp \ nsCaret.cpp \ - nsCommentNode.cpp \ - nsContentIterator.cpp \ - nsContentList.cpp \ - nsContentPolicy.cpp \ nsCopySupport.cpp \ - nsDocument.cpp \ - nsDocumentEncoder.cpp \ - nsDocumentFragment.cpp \ - nsDocumentViewer.cpp \ - nsDOMAttribute.cpp \ - nsDOMAttributeMap.cpp \ - nsDOMDocumentType.cpp \ nsFrameImageLoader.cpp \ nsFrameList.cpp \ nsFrameTraversal.cpp \ nsFrameUtil.cpp \ nsGalleyContext.cpp \ - nsGeneratedIterator.cpp \ - nsGenericDOMDataNode.cpp \ - nsGenericDOMNodeList.cpp \ - nsGenericElement.cpp \ nsLayoutAtoms.cpp \ nsLayoutDebugger.cpp \ nsLayoutUtils.cpp \ - nsNameSpaceManager.cpp \ - nsNodeInfo.cpp \ - nsNodeInfoManager.cpp \ nsPresContext.cpp \ nsPresState.cpp \ nsPrintContext.cpp \ nsPrintPreviewContext.cpp \ - nsRange.cpp \ - nsSelection.cpp \ nsSpaceManager.cpp \ nsStyleChangeList.cpp \ nsStyleCoord.cpp \ - nsStyleContext.cpp \ - nsStyleSet.cpp \ - nsTextContentChangeData.cpp \ - nsTextFragment.cpp \ - nsTextNode.cpp \ nsLayoutHistoryState.cpp \ - nsXMLContentSerializer.cpp \ - nsHTMLContentSerializer.cpp \ - nsPlainTextSerializer.cpp \ $(NULL) # we don't want the shared lib, but we want to force the creation of a static lib. diff --git a/layout/base/src/makefile.win b/layout/base/src/makefile.win index 23d38c5cbb15..581bd71371d1 100644 --- a/layout/base/src/makefile.win +++ b/layout/base/src/makefile.win @@ -21,7 +21,7 @@ DEPTH=..\..\.. -LIBRARY_NAME=raptorlayout_s +LIBRARY_NAME=layoutbase_s DEFINES=-D_IMPL_NS_LAYOUT -DWIN32_LEAN_AND_MEAN !if defined(XP_NEW_SELECTION) DEFINES = $(DEFINES) -DXP_NEW_SELECTION @@ -29,112 +29,51 @@ DEFINES = $(DEFINES) -DXP_NEW_SELECTION CPPSRCS = \ nsAutoCopy.cpp \ - nsCommentNode.cpp \ - nsGenericElement.cpp \ - nsGenericDOMDataNode.cpp \ - nsGenericDOMNodeList.cpp \ - nsContentList.cpp \ - nsContentIterator.cpp \ - nsContentPolicy.cpp \ nsCopySupport.cpp \ - nsDocument.cpp \ - nsDocumentEncoder.cpp \ - nsDocumentFragment.cpp \ - nsDocumentViewer.cpp \ - nsDOMAttribute.cpp \ - nsDOMAttributeMap.cpp \ - nsDOMDocumentType.cpp \ nsFrameImageLoader.cpp \ nsFrameList.cpp \ nsFrameTraversal.cpp \ nsFrameUtil.cpp \ nsGalleyContext.cpp \ - nsGeneratedIterator.cpp \ - nsNameSpaceManager.cpp \ - nsNodeInfo.cpp \ - nsNodeInfoManager.cpp \ nsPresContext.cpp \ nsPresState.cpp \ nsPrintContext.cpp \ nsPrintPreviewContext.cpp \ nsSpaceManager.cpp \ - nsStyleContext.cpp \ nsStyleChangeList.cpp \ - nsStyleCoord.cpp \ - nsStyleSet.cpp \ - nsTextFragment.cpp \ - nsSelection.cpp \ nsLayoutAtoms.cpp \ nsLayoutDebugger.cpp \ nsLayoutUtils.cpp \ nsCaret.cpp \ - nsRange.cpp \ - nsTextContentChangeData.cpp \ - nsTextNode.cpp \ nsLayoutHistoryState.cpp \ - nsXMLContentSerializer.cpp \ - nsHTMLContentSerializer.cpp \ - nsPlainTextSerializer.cpp \ $(NULL) MODULE=raptor CPP_OBJS= \ .\$(OBJDIR)\nsAutoCopy.obj \ - .\$(OBJDIR)\nsCommentNode.obj \ - .\$(OBJDIR)\nsGenericDOMDataNode.obj \ - .\$(OBJDIR)\nsGenericDOMNodeList.obj \ - .\$(OBJDIR)\nsGenericElement.obj \ - .\$(OBJDIR)\nsContentList.obj \ - .\$(OBJDIR)\nsContentIterator.obj \ - .\$(OBJDIR)\nsContentPolicy.obj \ .\$(OBJDIR)\nsCopySupport.obj \ - .\$(OBJDIR)\nsDocument.obj \ - .\$(OBJDIR)\nsDocumentEncoder.obj \ - .\$(OBJDIR)\nsDocumentFragment.obj \ - .\$(OBJDIR)\nsDocumentViewer.obj \ - .\$(OBJDIR)\nsDOMAttribute.obj \ - .\$(OBJDIR)\nsDOMAttributeMap.obj \ - .\$(OBJDIR)\nsDOMDocumentType.obj \ .\$(OBJDIR)\nsFrameImageLoader.obj \ .\$(OBJDIR)\nsFrameList.obj \ .\$(OBJDIR)\nsFrameTraversal.obj \ .\$(OBJDIR)\nsFrameUtil.obj \ .\$(OBJDIR)\nsGalleyContext.obj \ - .\$(OBJDIR)\nsGeneratedIterator.obj \ - .\$(OBJDIR)\nsNameSpaceManager.obj \ - .\$(OBJDIR)\nsNodeInfo.obj \ - .\$(OBJDIR)\nsNodeInfoManager.obj \ .\$(OBJDIR)\nsPresContext.obj \ .\$(OBJDIR)\nsPresState.obj \ .\$(OBJDIR)\nsPrintContext.obj \ .\$(OBJDIR)\nsPrintPreviewContext.obj \ .\$(OBJDIR)\nsSpaceManager.obj \ - .\$(OBJDIR)\nsStyleContext.obj \ .\$(OBJDIR)\nsStyleChangeList.obj \ - .\$(OBJDIR)\nsStyleCoord.obj \ - .\$(OBJDIR)\nsStyleSet.obj \ - .\$(OBJDIR)\nsTextFragment.obj \ - .\$(OBJDIR)\nsSelection.obj \ .\$(OBJDIR)\nsLayoutAtoms.obj \ .\$(OBJDIR)\nsLayoutDebugger.obj \ .\$(OBJDIR)\nsLayoutUtils.obj \ .\$(OBJDIR)\nsCaret.obj \ - .\$(OBJDIR)\nsRange.obj \ - .\$(OBJDIR)\nsTextContentChangeData.obj \ - .\$(OBJDIR)\nsTextNode.obj \ .\$(OBJDIR)\nsLayoutHistoryState.obj \ - .\$(OBJDIR)\nsXMLContentSerializer.obj \ - .\$(OBJDIR)\nsHTMLContentSerializer.obj \ - .\$(OBJDIR)\nsPlainTextSerializer.obj \ $(NULL) -LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \ - -I$(PUBLIC)\dom -I$(PUBLIC)\js -I$(PUBLIC)\netlib \ - -I$(PUBLIC)\pref -I..\..\html\base\src -I..\..\html\style\src \ +LINCS=-I..\..\html\base\src -I..\..\html\style\src \ -I..\..\xul\base\src -I..\..\xul\content\src \ - -I..\..\events\src \ - -I$(PUBLIC)\lwbrk -I$(PUBLIC)\plugin + -I..\..\events\src LCFLAGS = \ $(LCFLAGS) \ diff --git a/layout/base/src/nsFrameTraversal.cpp b/layout/base/src/nsFrameTraversal.cpp index 4b4c4d5f67f2..42663595dfb0 100644 --- a/layout/base/src/nsFrameTraversal.cpp +++ b/layout/base/src/nsFrameTraversal.cpp @@ -96,6 +96,21 @@ private : /************IMPLEMENTATIONS**************/ +nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult) +{ + NS_ENSURE_ARG_POINTER(aResult); + *aResult = nsnull; + + nsCOMPtr t(new nsFrameTraversal()); + if (!t) + return NS_ERROR_OUT_OF_MEMORY; + + *aResult = t; + NS_ADDREF(*aResult); + + return NS_OK; +} + nsresult NS_NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator, nsTraversalType aType, @@ -141,6 +156,27 @@ NS_NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator, } +nsFrameTraversal::nsFrameTraversal() +{ + NS_INIT_ISUPPORTS(); +} + +nsFrameTraversal::~nsFrameTraversal() +{ +} + +NS_IMPL_ISUPPORTS1(nsFrameTraversal,nsIFrameTraversal); + +NS_IMETHODIMP +nsFrameTraversal::NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator, + PRUint32 aType, + nsIPresContext* aPresContext, + nsIFrame *aStart) +{ + return NS_NewFrameTraversal(aEnumerator, NS_STATIC_CAST(nsTraversalType, + aType), + aPresContext, aStart); +} /*********nsFrameIterator************/ NS_IMPL_ISUPPORTS2(nsFrameIterator, nsIEnumerator, nsIBidirectionalEnumerator) diff --git a/layout/base/src/nsPresContext.cpp b/layout/base/src/nsPresContext.cpp index bbdd96a06dba..99d7d05ecda8 100644 --- a/layout/base/src/nsPresContext.cpp +++ b/layout/base/src/nsPresContext.cpp @@ -44,7 +44,6 @@ #include "nsIContent.h" #include "nsIFrame.h" #include "nsIRenderingContext.h" -#include "nsEventStateManager.h" #include "nsIURL.h" #include "nsIDocument.h" #include "nsIStyleContext.h" @@ -73,6 +72,8 @@ PrefChangedCallback(const char* aPrefName, void* instance_data) } static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); +#include "nsContentCID.h" +static NS_DEFINE_CID(kEventStateManagerCID, NS_EVENTSTATEMANAGER_CID); nsPresContext::nsPresContext() : mDefaultFont("serif", NS_FONT_STYLE_NORMAL, @@ -1270,8 +1271,9 @@ nsPresContext::GetEventStateManager(nsIEventStateManager** aManager) } if (!mEventManager) { - nsresult rv = NS_NewEventStateManager(getter_AddRefs(mEventManager)); - if (NS_OK != rv) { + nsresult rv; + mEventManager = do_CreateInstance(kEventStateManagerCID,&rv); + if (NS_FAILED(rv)) { return rv; } } diff --git a/layout/base/src/nsStyleCoord.cpp b/layout/base/src/nsStyleCoord.cpp index 7d5263e5ab57..8710c09d8f1a 100644 --- a/layout/base/src/nsStyleCoord.cpp +++ b/layout/base/src/nsStyleCoord.cpp @@ -20,265 +20,4 @@ * Contributor(s): */ -#include "nsStyleCoord.h" -#include "nsString.h" -#include "nsCRT.h" - -nsStyleCoord::nsStyleCoord(nsStyleUnit aUnit) - : mUnit(aUnit) -{ - NS_ASSERTION(aUnit < eStyleUnit_Percent, "not a valueless unit"); - if (aUnit >= eStyleUnit_Percent) { - mUnit = eStyleUnit_Null; - } - mValue.mInt = 0; -} - -nsStyleCoord::nsStyleCoord(nscoord aValue) - : mUnit(eStyleUnit_Coord) -{ - mValue.mInt = aValue; -} - -nsStyleCoord::nsStyleCoord(PRInt32 aValue, nsStyleUnit aUnit) - : mUnit(aUnit) -{ - //if you want to pass in eStyleUnit_Coord, don't. instead, use the - //constructor just above this one... MMP - NS_ASSERTION((aUnit == eStyleUnit_Proportional) || - (aUnit == eStyleUnit_Enumerated) || - (aUnit == eStyleUnit_Integer), "not an int value"); - if ((aUnit == eStyleUnit_Proportional) || - (aUnit == eStyleUnit_Enumerated) || - (aUnit == eStyleUnit_Integer)) { - mValue.mInt = aValue; - } - else { - mUnit = eStyleUnit_Null; - mValue.mInt = 0; - } -} - -nsStyleCoord::nsStyleCoord(float aValue, nsStyleUnit aUnit) - : mUnit(aUnit) -{ - NS_ASSERTION((aUnit == eStyleUnit_Percent) || - (aUnit == eStyleUnit_Factor), "not a float value"); - if ((aUnit == eStyleUnit_Percent) || - (aUnit == eStyleUnit_Factor)) { - mValue.mFloat = aValue; - } - else { - mUnit = eStyleUnit_Null; - mValue.mInt = 0; - } -} - -nsStyleCoord::nsStyleCoord(const nsStyleCoord& aCopy) - : mUnit(aCopy.mUnit) -{ - if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) { - mValue.mFloat = aCopy.mValue.mFloat; - } - else { - mValue.mInt = aCopy.mValue.mInt; - } -} - -nsStyleCoord& nsStyleCoord::operator=(const nsStyleCoord& aCopy) -{ - mUnit = aCopy.mUnit; - if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) { - mValue.mFloat = aCopy.mValue.mFloat; - } - else { - mValue.mInt = aCopy.mValue.mInt; - } - return *this; -} - -PRBool nsStyleCoord::operator==(const nsStyleCoord& aOther) const -{ - if (mUnit == aOther.mUnit) { - if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) { - return PRBool(mValue.mFloat == aOther.mValue.mFloat); - } - else { - return PRBool(mValue.mInt == aOther.mValue.mInt); - } - } - return PR_FALSE; -} - -void nsStyleCoord::Reset(void) -{ - mUnit = eStyleUnit_Null; - mValue.mInt = 0; -} - -void nsStyleCoord::SetCoordValue(nscoord aValue) -{ - mUnit = eStyleUnit_Coord; - mValue.mInt = aValue; -} - -void nsStyleCoord::SetIntValue(PRInt32 aValue, nsStyleUnit aUnit) -{ - NS_ASSERTION((aUnit == eStyleUnit_Proportional) || - (aUnit == eStyleUnit_Enumerated) || - (aUnit == eStyleUnit_Chars) || - (aUnit == eStyleUnit_Integer), "not an int value"); - if ((aUnit == eStyleUnit_Proportional) || - (aUnit == eStyleUnit_Enumerated) || - (aUnit == eStyleUnit_Chars) || - (aUnit == eStyleUnit_Integer)) { - mUnit = aUnit; - mValue.mInt = aValue; - } - else { - Reset(); - } -} - -void nsStyleCoord::SetPercentValue(float aValue) -{ - mUnit = eStyleUnit_Percent; - mValue.mFloat = aValue; -} - -void nsStyleCoord::SetFactorValue(float aValue) -{ - mUnit = eStyleUnit_Factor; - mValue.mFloat = aValue; -} - -void nsStyleCoord::SetNormalValue(void) -{ - mUnit = eStyleUnit_Normal; - mValue.mInt = 0; -} - -void nsStyleCoord::SetAutoValue(void) -{ - mUnit = eStyleUnit_Auto; - mValue.mInt = 0; -} - -void nsStyleCoord::SetInheritValue(void) -{ - mUnit = eStyleUnit_Inherit; - mValue.mInt = 0; -} - -void nsStyleCoord::SetUnionValue(const nsStyleUnion& aValue, nsStyleUnit aUnit) -{ - mUnit = aUnit; -#if PR_BYTES_PER_INT == PR_BYTES_PER_FLOAT - mValue.mInt = aValue.mInt; -#else - nsCRT::memcpy(&mValue, &aValue, sizeof(nsStyleUnion)); -#endif -} - -void nsStyleCoord::AppendToString(nsString& aBuffer) const -{ - if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) { - aBuffer.AppendFloat(mValue.mFloat); - } - else if ((eStyleUnit_Coord == mUnit) || - (eStyleUnit_Proportional == mUnit) || - (eStyleUnit_Enumerated == mUnit) || - (eStyleUnit_Integer == mUnit)) { - aBuffer.AppendInt(mValue.mInt, 10); - aBuffer.AppendWithConversion("[0x"); - aBuffer.AppendInt(mValue.mInt, 16); - aBuffer.AppendWithConversion(']'); - } - - switch (mUnit) { - case eStyleUnit_Null: aBuffer.AppendWithConversion("Null"); break; - case eStyleUnit_Coord: aBuffer.AppendWithConversion("tw"); break; - case eStyleUnit_Percent: aBuffer.AppendWithConversion("%"); break; - case eStyleUnit_Factor: aBuffer.AppendWithConversion("f"); break; - case eStyleUnit_Normal: aBuffer.AppendWithConversion("Normal"); break; - case eStyleUnit_Auto: aBuffer.AppendWithConversion("Auto"); break; - case eStyleUnit_Inherit: aBuffer.AppendWithConversion("Inherit"); break; - case eStyleUnit_Proportional: aBuffer.AppendWithConversion("*"); break; - case eStyleUnit_Enumerated: aBuffer.AppendWithConversion("enum"); break; - case eStyleUnit_Integer: aBuffer.AppendWithConversion("int"); break; - case eStyleUnit_Chars: aBuffer.AppendWithConversion("chars"); break; - } - aBuffer.AppendWithConversion(' '); -} - -void nsStyleCoord::ToString(nsString& aBuffer) const -{ - aBuffer.Truncate(); - AppendToString(aBuffer); -} - - - - -nsStyleSides::nsStyleSides(void) -{ - nsCRT::memset(this, 0x00, sizeof(nsStyleSides)); -} - -#define COMPARE_SIDE(side) \ - if ((eStyleUnit_Percent <= m##side##Unit) && (m##side##Unit < eStyleUnit_Coord)) { \ - if (m##side##Value.mFloat != aOther.m##side##Value.mFloat) \ - return PR_FALSE; \ - } \ - else { \ - if (m##side##Value.mInt != aOther.m##side##Value.mInt) \ - return PR_FALSE; \ - } - -PRBool nsStyleSides::operator==(const nsStyleSides& aOther) const -{ - if ((mLeftUnit == aOther.mLeftUnit) && - (mTopUnit == aOther.mTopUnit) && - (mRightUnit == aOther.mRightUnit) && - (mBottomUnit == aOther.mBottomUnit)) { - COMPARE_SIDE(Left); - COMPARE_SIDE(Top); - COMPARE_SIDE(Right); - COMPARE_SIDE(Bottom); - return PR_TRUE; - } - return PR_FALSE; -} - -void nsStyleSides::Reset(void) -{ - nsCRT::memset(this, 0x00, sizeof(nsStyleSides)); -} - -void nsStyleSides::AppendToString(nsString& aBuffer) const -{ - nsStyleCoord temp; - - GetLeft(temp); - aBuffer.AppendWithConversion("left: "); - temp.AppendToString(aBuffer); - - GetTop(temp); - aBuffer.AppendWithConversion("top: "); - temp.AppendToString(aBuffer); - - GetRight(temp); - aBuffer.AppendWithConversion("right: "); - temp.AppendToString(aBuffer); - - GetBottom(temp); - aBuffer.AppendWithConversion("bottom: "); - temp.AppendToString(aBuffer); -} - -void nsStyleSides::ToString(nsString& aBuffer) const -{ - aBuffer.Truncate(); - AppendToString(aBuffer); -} - +// Empty file, remove! \ No newline at end of file diff --git a/layout/base/tests/makefile.win b/layout/base/tests/makefile.win index a39a10cc3ebc..39b852afce30 100644 --- a/layout/base/tests/makefile.win +++ b/layout/base/tests/makefile.win @@ -27,7 +27,7 @@ PROGRAMS = $(PROG1) LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I..\src LLIBS= \ - $(DIST)\lib\raptorlayout_s.lib \ + $(DIST)\lib\layoutbase_s.lib \ $(DIST)\lib\gkgfxwin.lib \ $(DIST)\lib\xpcom.lib \ $(DIST)\lib\jsdom.lib \ diff --git a/layout/build/Makefile.in b/layout/build/Makefile.in index 8bb02ef90593..dba270b33d69 100644 --- a/layout/build/Makefile.in +++ b/layout/build/Makefile.in @@ -48,19 +48,13 @@ endif EXPORTS = nsLayoutCID.h $(BUILD_DATE) SHARED_LIBRARY_LIBS = \ - $(DIST)/lib/libgkevents_s.$(LIB_SUFFIX) \ $(DIST)/lib/libgkhtmlbase_s.$(LIB_SUFFIX) \ - $(DIST)/lib/libgkhtmlcon_s.$(LIB_SUFFIX) \ $(DIST)/lib/libgkhtmldoc_s.$(LIB_SUFFIX) \ $(DIST)/lib/libgkhtmlforms_s.$(LIB_SUFFIX) \ $(DIST)/lib/libgkhtmlstyle_s.$(LIB_SUFFIX) \ $(DIST)/lib/libgkhtmltable_s.$(LIB_SUFFIX) \ - $(DIST)/lib/libgkxmlcon_s.$(LIB_SUFFIX) \ - $(DIST)/lib/libgkxmldoc_s.$(LIB_SUFFIX) \ - $(DIST)/lib/libgkxsldoc_s.$(LIB_SUFFIX) \ $(DIST)/lib/libgkxulcon_s.$(LIB_SUFFIX) \ $(DIST)/lib/libgkxulbase_s.$(LIB_SUFFIX) \ - $(DIST)/lib/libgkxbl_s.$(LIB_SUFFIX) \ $(DIST)/lib/libgkbase_s.$(LIB_SUFFIX) \ $(NULL) diff --git a/layout/build/dlldeps.cpp b/layout/build/dlldeps.cpp index ac9b7cfe57fc..b6cc499f56e0 100644 --- a/layout/build/dlldeps.cpp +++ b/layout/build/dlldeps.cpp @@ -41,11 +41,6 @@ void XXXNeverCalled() NS_NewGalleyContext(&cx); NS_NewPrintPreviewContext(&cx); NS_NewPrintContext(&px); - nsIStyleSet* ss; - NS_NewStyleSet(&ss); - nsIDocument* doc; - NS_NewHTMLDocument(&doc); - NS_NewImageDocument(&doc); nsIFrame* f; NS_NewTextFrame(ps, &f); NS_NewInlineFrame(ps, &f); @@ -58,7 +53,4 @@ void XXXNeverCalled() NS_NewCanvasFrame(ps, &f); NS_NewScrollFrame(ps, &f); NS_NewSimplePageSequenceFrame(ps, &f); - nsINameSpaceManager* nsm; - NS_NewNameSpaceManager(&nsm); - NS_CreateHTMLElement(nsnull, nsnull); } diff --git a/layout/build/makefile.win b/layout/build/makefile.win index 63b5a0c22ba7..7f31b010796e 100644 --- a/layout/build/makefile.win +++ b/layout/build/makefile.win @@ -42,7 +42,7 @@ EXPORTS=nsLayoutCID.h $(BUILD_DATE) MAKE_OBJ_TYPE = DLL -DLLNAME = gkhtml +DLLNAME = gklayout DLL=.\$(OBJDIR)\$(DLLNAME).dll LCFLAGS = \ @@ -65,28 +65,22 @@ LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\dom \ # These are the libraries we need to link with to create the dll LLIBS= \ - $(DIST)\lib\raptorlayout_s.lib \ - $(DIST)\lib\raptorhtmlbase_s.lib \ - $(DIST)\lib\nglhtmlcon_s.lib \ - $(DIST)\lib\raptorhtmldoc_s.lib \ - $(DIST)\lib\raptorhtmlforms_s.lib \ - $(DIST)\lib\raptorhtmlstyle_s.lib \ - $(DIST)\lib\raptorhtmltable_s.lib \ - $(DIST)\lib\raptorxmlcontent_s.lib \ - $(DIST)\lib\raptorxmldoc_s.lib \ - $(DIST)\lib\raptorxsldoc_s.lib \ - $(DIST)\lib\raptorxulbase_s.lib \ - $(DIST)\lib\raptorxulcontent_s.lib \ - $(DIST)\lib\raptorxbl_s.lib \ + $(DIST)\lib\layoutbase_s.lib \ + $(DIST)\lib\layouthtmlbase_s.lib \ + $(DIST)\lib\layouthtmldoc_s.lib \ + $(DIST)\lib\layouthtmlforms_s.lib \ + $(DIST)\lib\layouthtmlstyle_s.lib \ + $(DIST)\lib\layouthtmltable_s.lib \ + $(DIST)\lib\layoutxulbase_s.lib \ + $(DIST)\lib\layoutxulcontent_s.lib \ !ifdef MOZ_MATHML - $(DIST)\lib\raptormathmlbase_s.lib \ - $(DIST)\lib\raptormathmlcontent_s.lib \ + $(DIST)\lib\layoutmathmlbase_s.lib \ + $(DIST)\lib\layoutmathmlcontent_s.lib \ !endif !ifdef MOZ_SVG - $(DIST)\lib\raptorsvgbase_s.lib \ - $(DIST)\lib\raptorsvgcontent_s.lib \ + $(DIST)\lib\layoutsvgbase_s.lib \ + $(DIST)\lib\layoutsvgcontent_s.lib \ !endif - $(DIST)\lib\raptorevents_s.lib \ $(DIST)\lib\xpcom.lib \ $(DIST)\lib\gkgfxwin.lib \ $(DIST)\lib\timer_s.lib \ diff --git a/layout/build/nsLayoutCID.h b/layout/build/nsLayoutCID.h index b649059f54c6..ea2e99a9d979 100644 --- a/layout/build/nsLayoutCID.h +++ b/layout/build/nsLayoutCID.h @@ -27,6 +27,14 @@ #include "nsIFactory.h" #include "nsIComponentManager.h" +// {1691E1F5-EE41-11d4-9885-00C04FA0CF4B} +#define NS_CSSFRAMECONSTRUCTOR_CID \ +{ 0x1691e1f5, 0xee41, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } } + +// {1691E1F4-EE41-11d4-9885-00C04FA0CF4B} +#define NS_FRAMETRAVERSAL_CID \ +{ 0x1691e1f4, 0xee41, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } } + /* a6cf90fa-15b3-11d2-932e-00805f8add32 */ #define NS_LAYOUT_DOCUMENT_LOADER_FACTORY_CID \ { 0xa6cf90fa, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} @@ -91,9 +99,17 @@ #define NS_PRESSHELL_CID \ { 0xe6fd9940, 0x899d, 0x11d2, { 0x8e, 0xae, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } } -// {96882B70-8A27-11d2-8EAF-00805F29F370} -#define NS_HTMLSTYLESHEET_CID \ -{ 0x96882b70, 0x8a27, 0x11d2, { 0x8e, 0xaf, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } } +// {A1FDE861-E802-11d4-9885-00C04FA0CF4B} +#define NS_PRESSTATE_CID \ +{ 0xa1fde861, 0xe802, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } } + +// {A1FDE85E-E802-11d4-9885-00C04FA0CF4B} +#define NS_GALLEYCONTEXT_CID \ +{ 0xa1fde85e, 0xe802, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } } + +// {A1FDE85F-E802-11d4-9885-00C04FA0CF4B} +#define NS_PRINTCONTEXT_CID \ +{ 0xa1fde85f, 0xe802, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } } // {95F46161-D177-11d2-BF86-00105A1B0627} #define NS_HTML_CSS_STYLESHEET_CID \ @@ -139,10 +155,6 @@ {/* {a6cf90e5-15b3-11d2-932e-00805f8add32}*/ \ 0xa6cf90e5, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } -// {09F689E0-B4DA-11d2-A68B-00104BDE6048} -#define NS_EVENTLISTENERMANAGER_CID \ -{ 0x9f689e0, 0xb4da, 0x11d2, { 0xa6, 0x8b, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } } - /* a6cf90f7-15b3-11d2-932e-00805f8add32 */ #define NS_PRINT_PREVIEW_CONTEXT_CID \ { 0xa6cf90f7, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} diff --git a/layout/build/nsLayoutDLF.cpp b/layout/build/nsLayoutDLF.cpp index 9418a9ca6498..0efe85c99774 100644 --- a/layout/build/nsLayoutDLF.cpp +++ b/layout/build/nsLayoutDLF.cpp @@ -40,6 +40,10 @@ #include "nsIStreamLoadableDocument.h" #include "nsIDocStreamLoaderFactory.h" +#include "nsContentCID.h" +static NS_DEFINE_CID(kDocumentViewerCID, NS_DOCUMENT_VIEWER_CID); +static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID); + #define VIEW_SOURCE_HTML // URL for the "user agent" style sheet @@ -54,8 +58,6 @@ static NS_DEFINE_IID(kXMLDocumentCID, NS_XMLDOCUMENT_CID); static NS_DEFINE_IID(kImageDocumentCID, NS_IMAGEDOCUMENT_CID); static NS_DEFINE_IID(kXULDocumentCID, NS_XULDOCUMENT_CID); -extern nsresult NS_NewDocumentViewer(nsIDocumentViewer** aResult); - static char* gHTMLTypes[] = { "text/html", "text/plain", @@ -227,8 +229,7 @@ nsLayoutDLF::CreateInstance(const char *aCommand, nsCOMPtr uaURL; rv = NS_NewURI(getter_AddRefs(uaURL), UA_CSS_URL); if (NS_SUCCEEDED(rv)) { - nsCOMPtr cssLoader; - rv = NS_NewCSSLoader(getter_AddRefs(cssLoader)); + nsCOMPtr cssLoader(do_CreateInstance(kCSSLoaderCID,&rv)); if (cssLoader) { PRBool complete; rv = cssLoader->LoadAgentSheet(uaURL, nsLayoutModule::gUAStyleSheet, complete, @@ -316,9 +317,7 @@ nsLayoutDLF::CreateInstanceForDocument(nsISupports* aContainer, nsresult rv = NS_ERROR_FAILURE; do { - nsCOMPtr docv; - // Create the document viewer - rv = NS_NewDocumentViewer(getter_AddRefs(docv)); + nsCOMPtr docv(do_CreateInstance(kDocumentViewerCID,&rv)); if (NS_FAILED(rv)) break; docv->SetUAStyleSheet(nsLayoutDLF::GetUAStyleSheet()); @@ -367,7 +366,7 @@ nsLayoutDLF::CreateDocument(const char* aCommand, break; // Create the document viewer XXX: could reuse document viewer here! - rv = NS_NewDocumentViewer(getter_AddRefs(docv)); + docv = do_CreateInstance(kDocumentViewerCID,&rv); if (NS_FAILED(rv)) break; docv->SetUAStyleSheet(nsLayoutDLF::GetUAStyleSheet()); @@ -429,7 +428,7 @@ nsLayoutDLF::CreateRDFDocument(nsISupports* aExtraInfo, if (NS_FAILED(rv)) return rv; // Create the image content viewer... - rv = NS_NewDocumentViewer(getter_AddRefs(*docv)); + rv = nsComponentManager::CreateInstance(kDocumentViewerCID,nsnull,NS_GET_IID(nsIDocumentViewer),getter_AddRefs(*docv)); if (NS_FAILED(rv)) return rv; // Load the UA style sheet if we haven't already done that diff --git a/layout/build/nsLayoutFactory.cpp b/layout/build/nsLayoutFactory.cpp index 5f197f4092fa..cd2cfbce4c0f 100644 --- a/layout/build/nsLayoutFactory.cpp +++ b/layout/build/nsLayoutFactory.cpp @@ -28,20 +28,17 @@ #include "nsIHTMLContent.h" #include "nsITextContent.h" #include "nsIPresShell.h" +#include "nsIPresState.h" #include "nsIPresContext.h" -#include "nsISelection.h" +#include "nsIPrintContext.h" #include "nsIFrameUtil.h" #include "nsHTMLAtoms.h" #include "nsHTMLParts.h" #include "nsDOMCID.h" #include "nsIServiceManager.h" -#include "nsICSSParser.h" #include "nsIHTMLStyleSheet.h" -#include "nsIHTMLCSSStyleSheet.h" -#include "nsICSSLoader.h" #include "nsIDOMRange.h" -#include "nsIContentIterator.h" #include "nsINameSpaceManager.h" #include "nsIScriptNameSetRegistry.h" #include "nsIScriptNameSpaceManager.h" @@ -51,69 +48,34 @@ #include "nsIElementFactory.h" #include "nsIDocumentEncoder.h" #include "nsCOMPtr.h" -#include "nsIFrameSelection.h" -#include "nsIDOMDOMImplementation.h" -#include "nsIPrivateDOMImplementation.h" - -#include "nsIXBLService.h" -#include "nsIBindingManager.h" #include "nsIBoxObject.h" #include "nsIAutoCopy.h" -#include "nsContentPolicyUtils.h" - -#include "nsXMLContentSerializer.h" -#include "nsHTMLContentSerializer.h" -#include "nsPlainTextSerializer.h" #include "nsINodeInfo.h" -#include "nsIComputedDOMStyle.h" +#include "nsIFrameTraversal.h" +#include "nsICSSFrameConstructor.h" class nsIDocumentLoaderFactory; static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); -static NS_DEFINE_IID(kHTMLDocumentCID, NS_HTMLDOCUMENT_CID); -static NS_DEFINE_IID(kXMLDocumentCID, NS_XMLDOCUMENT_CID); -static NS_DEFINE_CID(kXMLElementFactoryCID, NS_XML_ELEMENT_FACTORY_CID); -static NS_DEFINE_IID(kImageDocumentCID, NS_IMAGEDOCUMENT_CID); -static NS_DEFINE_IID(kCSSParserCID, NS_CSSPARSER_CID); -static NS_DEFINE_CID(kHTMLStyleSheetCID, NS_HTMLSTYLESHEET_CID); -static NS_DEFINE_CID(kHTMLCSSStyleSheetCID, NS_HTML_CSS_STYLESHEET_CID); -static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID); -static NS_DEFINE_IID(kHTMLImageElementCID, NS_HTMLIMAGEELEMENT_CID); -static NS_DEFINE_IID(kHTMLOptionElementCID, NS_HTMLOPTIONELEMENT_CID); - -static NS_DEFINE_CID(kSelectionCID, NS_SELECTION_CID); -static NS_DEFINE_IID(kFrameSelectionCID, NS_FRAMESELECTION_CID); -static NS_DEFINE_IID(kDOMSelectionCID, NS_DOMSELECTION_CID); - static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID); -static NS_DEFINE_IID(kContentIteratorCID, NS_CONTENTITERATOR_CID); -static NS_DEFINE_IID(kGeneratedContentIteratorCID, NS_GENERATEDCONTENTITERATOR_CID); -static NS_DEFINE_IID(kGeneratedSubtreeIteratorCID, NS_GENERATEDSUBTREEITERATOR_CID); -static NS_DEFINE_IID(kSubtreeIteratorCID, NS_SUBTREEITERATOR_CID); static NS_DEFINE_CID(kPresShellCID, NS_PRESSHELL_CID); +static NS_DEFINE_CID(kPresStateCID, NS_PRESSTATE_CID); +static NS_DEFINE_CID(kGalleyContextCID, NS_GALLEYCONTEXT_CID); +static NS_DEFINE_CID(kPrintContextCID, NS_PRINTCONTEXT_CID); static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); static NS_DEFINE_CID(kFrameUtilCID, NS_FRAME_UTIL_CID); -static NS_DEFINE_CID(kEventListenerManagerCID, NS_EVENTLISTENERMANAGER_CID); +static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID); +static NS_DEFINE_CID(kCSSFrameConstructorCID, NS_CSSFRAMECONSTRUCTOR_CID); static NS_DEFINE_CID(kPrintPreviewContextCID, NS_PRINT_PREVIEW_CONTEXT_CID); static NS_DEFINE_CID(kLayoutDocumentLoaderFactoryCID, NS_LAYOUT_DOCUMENT_LOADER_FACTORY_CID); static NS_DEFINE_CID(kLayoutDebuggerCID, NS_LAYOUT_DEBUGGER_CID); -static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); -static NS_DEFINE_CID(kTextEncoderCID, NS_TEXT_ENCODER_CID); -static NS_DEFINE_CID(kHTMLCopyTextEncoderCID, NS_HTMLCOPY_TEXT_ENCODER_CID); - -static NS_DEFINE_CID(kXMLContentSerializerCID, NS_XMLCONTENTSERIALIZER_CID); -static NS_DEFINE_CID(kHTMLContentSerializerCID, NS_HTMLCONTENTSERIALIZER_CID); -static NS_DEFINE_CID(kPlainTextSerializerCID, NS_PLAINTEXTSERIALIZER_CID); - -static NS_DEFINE_CID(kXBLServiceCID, NS_XBLSERVICE_CID); -static NS_DEFINE_CID(kBindingManagerCID, NS_BINDINGMANAGER_CID); static NS_DEFINE_CID(kBoxObjectCID, NS_BOXOBJECT_CID); static NS_DEFINE_CID(kTreeBoxObjectCID, NS_TREEBOXOBJECT_CID); @@ -124,35 +86,13 @@ static NS_DEFINE_CID(kBrowserBoxObjectCID, NS_BROWSERBOXOBJECT_CID); static NS_DEFINE_CID(kEditorBoxObjectCID, NS_EDITORBOXOBJECT_CID); static NS_DEFINE_CID(kIFrameBoxObjectCID, NS_IFRAMEBOXOBJECT_CID); -static NS_DEFINE_CID(kDOMImplementationCID, NS_DOM_IMPLEMENTATION_CID); -static NS_DEFINE_CID(kNodeInfoManagerCID, NS_NODEINFOMANAGER_CID); static NS_DEFINE_CID(kAutoCopyServiceCID, NS_AUTOCOPYSERVICE_CID); -static NS_DEFINE_CID(kContentPolicyCID, NS_CONTENTPOLICY_CID); -static NS_DEFINE_CID(kComputedDOMStyleCID, NS_COMPUTEDDOMSTYLE_CID); - - -extern nsresult NS_NewSelection(nsIFrameSelection** aResult); -extern nsresult NS_NewDomSelection(nsISelection** aResult); -extern nsresult NS_NewRange(nsIDOMRange** aResult); -extern nsresult NS_NewContentIterator(nsIContentIterator** aResult); -extern nsresult NS_NewGenRegularIterator(nsIContentIterator** aResult); -extern nsresult NS_NewContentSubtreeIterator(nsIContentIterator** aResult); -extern nsresult NS_NewGenSubtreeIterator(nsIContentIterator** aInstancePtrResult); extern nsresult NS_NewLayoutDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult); #ifdef NS_DEBUG extern nsresult NS_NewFrameUtil(nsIFrameUtil** aResult); extern nsresult NS_NewLayoutDebugger(nsILayoutDebugger** aResult); #endif -extern nsresult NS_NewHTMLElementFactory(nsIElementFactory** aResult); -extern nsresult NS_NewXMLElementFactory(nsIElementFactory** aResult); - -extern nsresult NS_NewHTMLCopyTextEncoder(nsIDocumentEncoder** aResult); -extern nsresult NS_NewTextEncoder(nsIDocumentEncoder** aResult); - -extern nsresult NS_NewXBLService(nsIXBLService** aResult); - -extern nsresult NS_NewBindingManager(nsIBindingManager** aResult); extern nsresult NS_NewBoxObject(nsIBoxObject** aResult); extern nsresult NS_NewTreeBoxObject(nsIBoxObject** aResult); @@ -163,11 +103,16 @@ extern nsresult NS_NewPopupSetBoxObject(nsIBoxObject** aResult); extern nsresult NS_NewBrowserBoxObject(nsIBoxObject** aResult); extern nsresult NS_NewIFrameBoxObject(nsIBoxObject** aResult); -extern nsresult NS_NewNodeInfoManager(nsINodeInfoManager** aResult); - extern nsresult NS_NewAutoCopyService(nsIAutoCopyService** aResult); -extern nsresult NS_NewContentPolicy(nsIContentPolicy** aResult); +extern nsresult NS_NewGalleyContext(nsIPresContext** aResult); + +extern nsresult NS_NewPresShell(nsIPresShell** aResult); +extern nsresult NS_NewPresState(nsIPresState** aResult); +extern nsresult NS_NewPrintContext(nsIPrintContext** aResult); + +extern nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult); +extern nsresult NS_CreateCSSFrameConstructor(nsICSSFrameConstructor** aResult); //---------------------------------------------------------------------- @@ -221,47 +166,10 @@ nsLayoutFactory::CreateInstance(nsISupports *aOuter, nsISupports *inst = nsnull; // XXX ClassID check happens here - if (mClassID.Equals(kHTMLDocumentCID)) { - res = NS_NewHTMLDocument((nsIDocument **)&inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewHTMLDocument", res); - return res; - } - } - else if (mClassID.Equals(kXMLDocumentCID)) { - res = NS_NewXMLDocument((nsIDocument **)&inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewXMLDocument", res); - return res; - } - } - else if (mClassID.Equals(kImageDocumentCID)) { - res = NS_NewImageDocument((nsIDocument **)&inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewImageDocument", res); - return res; - } - } #if 1 // XXX replace these with nsIElementFactory calls - else if (mClassID.Equals(kHTMLImageElementCID)) { - // Note! NS_NewHTMLImageElement is special cased to handle a null nodeinfo - res = NS_NewHTMLImageElement((nsIHTMLContent**)&inst, nsnull); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewHTMLImageElement", res); - return res; - } - } - else if (mClassID.Equals(kHTMLOptionElementCID)) { - // Note! NS_NewHTMLOptionElement is special cased to handle a null nodeinfo - res = NS_NewHTMLOptionElement((nsIHTMLContent**)&inst, nsnull); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewHTMLOptionElement", res); - return res; - } - } // XXX why the heck is this exported???? bad bad bad bad - else if (mClassID.Equals(kPresShellCID)) { + if (mClassID.Equals(kPresShellCID)) { res = NS_NewPresShell((nsIPresShell**) &inst); if (NS_FAILED(res)) { LOG_NEW_FAILURE("NS_NewPresShell", res); @@ -269,101 +177,24 @@ nsLayoutFactory::CreateInstance(nsISupports *aOuter, } } #endif - else if (mClassID.Equals(kFrameSelectionCID)) { - res = NS_NewSelection((nsIFrameSelection**)&inst); + else if (mClassID.Equals(kPresStateCID)) { + res = NS_NewPresState((nsIPresState**) &inst); if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewSelection", res); + LOG_NEW_FAILURE("NS_NewPresState", res); return res; } } - else if (mClassID.Equals(kDOMSelectionCID)) { - res = NS_NewDomSelection((nsISelection**)&inst); + else if (mClassID.Equals(kFrameTraversalCID)) { + res = NS_CreateFrameTraversal((nsIFrameTraversal**)&inst); if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewDomSelection", res); + LOG_NEW_FAILURE("NS_CreateFrameTraversal", res); return res; } } - else if (mClassID.Equals(kRangeCID)) { - res = NS_NewRange((nsIDOMRange **)&inst); + else if (mClassID.Equals(kCSSFrameConstructorCID)) { + res = NS_CreateCSSFrameConstructor((nsICSSFrameConstructor**)&inst); if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewRange", res); - return res; - } - } - else if (mClassID.Equals(kContentIteratorCID)) { - res = NS_NewContentIterator((nsIContentIterator **)&inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewContentIterator", res); - return res; - } - } - else if (mClassID.Equals(kGeneratedContentIteratorCID)) { - res = NS_NewGenRegularIterator((nsIContentIterator **)&inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewGenRegularIterator", res); - return res; - } - } - else if (mClassID.Equals(kSubtreeIteratorCID)) { - res = NS_NewContentSubtreeIterator((nsIContentIterator **)&inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewContentSubtreeIterator", res); - return res; - } - } - else if (mClassID.Equals(kGeneratedSubtreeIteratorCID)) { - res = NS_NewGenSubtreeIterator((nsIContentIterator **)&inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewGenSubtreeIterator", res); - return res; - } - } - else if (mClassID.Equals(kCSSParserCID)) { - res = NS_NewCSSParser((nsICSSParser**)&inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewCSSParser", res); - return res; - } - } - else if (mClassID.Equals(kHTMLStyleSheetCID)) { - res = NS_NewHTMLStyleSheet((nsIHTMLStyleSheet**)&inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewHTMLStyleSheet", res); - return res; - } - } - else if (mClassID.Equals(kHTMLCSSStyleSheetCID)) { - res = NS_NewHTMLCSSStyleSheet((nsIHTMLCSSStyleSheet**)&inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewHTMLCSSStyleSheet", res); - return res; - } - } - else if (mClassID.Equals(kCSSLoaderCID)) { - res = NS_NewCSSLoader((nsICSSLoader**)&inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewCSSLoader", res); - return res; - } - } - else if (mClassID.Equals(kTextNodeCID)) { - res = NS_NewTextNode((nsIContent**) &inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewTextNode", res); - return res; - } - } - else if (mClassID.Equals(kNameSpaceManagerCID)) { - res = NS_NewNameSpaceManager((nsINameSpaceManager**)&inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewNameSpaceManager", res); - return res; - } - } - else if (mClassID.Equals(kEventListenerManagerCID)) { - res = NS_NewEventListenerManager((nsIEventListenerManager**) &inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewEventListenerManager", res); + LOG_NEW_FAILURE("NS_CreateCSSFrameConstructor", res); return res; } } @@ -374,6 +205,20 @@ nsLayoutFactory::CreateInstance(nsISupports *aOuter, return res; } } + else if (mClassID.Equals(kPrintContextCID)) { + res = NS_NewPrintContext((nsIPrintContext**) &inst); + if (NS_FAILED(res)) { + LOG_NEW_FAILURE("NS_NewPrintContext", res); + return res; + } + } + else if (mClassID.Equals(kGalleyContextCID)) { + res = NS_NewGalleyContext((nsIPresContext**) &inst); + if (NS_FAILED(res)) { + LOG_NEW_FAILURE("NS_NewGalleyContext", res); + return res; + } + } else if (mClassID.Equals(kLayoutDocumentLoaderFactoryCID)) { res = NS_NewLayoutDocumentLoaderFactory((nsIDocumentLoaderFactory**)&inst); if (NS_FAILED(res)) { @@ -397,69 +242,6 @@ nsLayoutFactory::CreateInstance(nsISupports *aOuter, } } #endif - else if (mClassID.Equals(kHTMLElementFactoryCID)) { - res = NS_NewHTMLElementFactory((nsIElementFactory**) &inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewHTMLElementFactory", res); - return res; - } - } - else if (mClassID.Equals(kXMLElementFactoryCID)) { - res = NS_NewXMLElementFactory((nsIElementFactory**) &inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewXMLElementFactory", res); - return res; - } - } - else if (mClassID.Equals(kTextEncoderCID)) { - res = NS_NewTextEncoder((nsIDocumentEncoder**) &inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewTextEncoder", res); - return res; - } - } - else if (mClassID.Equals(kHTMLCopyTextEncoderCID)) { - res = NS_NewHTMLCopyTextEncoder((nsIDocumentEncoder**) &inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewHTMLCopyTextEncoder", res); - return res; - } - } - else if (mClassID.Equals(kXMLContentSerializerCID)) { - res = NS_NewXMLContentSerializer((nsIContentSerializer**) &inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewXMLContentSerializer", res); - return res; - } - } - else if (mClassID.Equals(kHTMLContentSerializerCID)) { - res = NS_NewHTMLContentSerializer((nsIContentSerializer**) &inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewHTMLContentSerializer", res); - return res; - } - } - else if (mClassID.Equals(kPlainTextSerializerCID)) { - res = NS_NewPlainTextSerializer((nsIContentSerializer**) &inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewPlainTextSerializer", res); - return res; - } - } - else if (mClassID.Equals(kXBLServiceCID)) { - res = NS_NewXBLService((nsIXBLService**) &inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewXBLService", res); - return res; - } - } - else if (mClassID.Equals(kBindingManagerCID)) { - res = NS_NewBindingManager((nsIBindingManager**) &inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewBindingManager", res); - return res; - } - } else if (mClassID.Equals(kBoxObjectCID)) { res = NS_NewBoxObject((nsIBoxObject**) &inst); if (NS_FAILED(res)) { @@ -509,13 +291,6 @@ nsLayoutFactory::CreateInstance(nsISupports *aOuter, return res; } } - else if (mClassID.Equals(kNodeInfoManagerCID)) { - res = NS_NewNodeInfoManager((nsINodeInfoManager**) &inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewNodeInfoManager", res); - return res; - } - } else if (mClassID.Equals(kAutoCopyServiceCID)) { res = NS_NewAutoCopyService((nsIAutoCopyService**) &inst); if (NS_FAILED(res)) { @@ -523,27 +298,6 @@ nsLayoutFactory::CreateInstance(nsISupports *aOuter, return res; } } - else if (mClassID.Equals(kDOMImplementationCID)) { - res = NS_NewDOMImplementation((nsIDOMDOMImplementation**) &inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewDOMImplementation", res); - return res; - } - } - else if (mClassID.Equals(kContentPolicyCID)) { - res = NS_NewContentPolicy((nsIContentPolicy**) &inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewContentPolicy", res); - return res; - } - } - else if (mClassID.Equals(kComputedDOMStyleCID)) { - res = NS_NewComputedDOMStyle((nsIComputedDOMStyle**) &inst); - if (NS_FAILED(res)) { - LOG_NEW_FAILURE("NS_NewComputedDOMStyle", res); - return res; - } - } else if (mClassID.Equals(kScrollBoxObjectCID)) { res = NS_NewScrollBoxObject((nsIBoxObject**) &inst); if (NS_FAILED(res)) { diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp index 177268f3e34c..49955d2dbcb4 100644 --- a/layout/build/nsLayoutModule.cpp +++ b/layout/build/nsLayoutModule.cpp @@ -28,7 +28,6 @@ #include "nsIComponentManager.h" #include "nsNetUtil.h" #include "nsICSSStyleSheet.h" -#include "nsICSSLoader.h" #include "nsHTMLAtoms.h" #include "nsCSSKeywords.h" // to addref/release table #include "nsCSSProps.h" // to addref/release table @@ -68,8 +67,6 @@ #include "nsIServiceManager.h" #include "nsTextTransformer.h" -#include "nsRange.h" -#include "nsGenericElement.h" #ifdef INCLUDE_XUL #include "nsBulletinBoardLayout.h" #include "nsRepeatService.h" @@ -264,9 +261,6 @@ nsLayoutModule::Shutdown() nsStackLayout::Shutdown(); #endif - nsRange::Shutdown(); - nsGenericElement::Shutdown(); - // Release all of our atoms nsColorNames::ReleaseTable(); nsCSSProps::ReleaseTable(); @@ -276,7 +270,7 @@ nsLayoutModule::Shutdown() nsLayoutAtoms::ReleaseAtoms(); #ifdef INCLUDE_XUL nsXULAtoms::ReleaseAtoms(); -#endif +#endif //MathML Mod - RBS #ifdef MOZ_MATHML nsMathMLOperators::ReleaseTable(); @@ -328,66 +322,20 @@ struct Components { // The list of components we register static Components gComponents[] = { - { "Namespace manager", NS_NAMESPACEMANAGER_CID, nsnull, }, - { "Event listener manager", NS_EVENTLISTENERMANAGER_CID, nsnull, }, { "Frame utility", NS_FRAME_UTIL_CID, nsnull, }, { "Print preview context", NS_PRINT_PREVIEW_CONTEXT_CID, nsnull, }, { "Layout debugger", NS_LAYOUT_DEBUGGER_CID, nsnull, }, - { "HTML document", NS_HTMLDOCUMENT_CID, nsnull, }, - { "HTML style sheet", NS_HTMLSTYLESHEET_CID, nsnull, }, - { "HTML-CSS style sheet", NS_HTML_CSS_STYLESHEET_CID, nsnull, }, - - { "DOM implementation", NS_DOM_IMPLEMENTATION_CID, nsnull, }, - - { "XML document", NS_XMLDOCUMENT_CID, nsnull, }, - { "Image document", NS_IMAGEDOCUMENT_CID, nsnull, }, - - { "CSS parser", NS_CSSPARSER_CID, nsnull, }, - { "CSS loader", NS_CSS_LOADER_CID, nsnull, }, - - { "HTML element factory", NS_HTML_ELEMENT_FACTORY_CID, NS_HTML_ELEMENT_FACTORY_CONTRACTID, }, - { "Text element", NS_TEXTNODE_CID, nsnull, }, - - { "XML element factory", NS_XML_ELEMENT_FACTORY_CID, NS_XML_ELEMENT_FACTORY_CONTRACTID, }, - - { "Selection", NS_SELECTION_CID, nsnull, }, - { "Frame selection", NS_FRAMESELECTION_CID, nsnull, }, - { "Dom selection", NS_DOMSELECTION_CID, nsnull, }, - { "Range", NS_RANGE_CID, nsnull, }, - { "Content iterator", NS_CONTENTITERATOR_CID, nsnull, }, - { "Generated Content iterator", NS_GENERATEDCONTENTITERATOR_CID, nsnull, }, - { "Generated Subtree iterator", NS_GENERATEDSUBTREEITERATOR_CID, nsnull, }, - { "Subtree iterator", NS_SUBTREEITERATOR_CID, nsnull, }, + { "CSS Frame Constructor", NS_CSSFRAMECONSTRUCTOR_CID, nsnull, }, + { "Frame Traversal", NS_FRAMETRAVERSAL_CID, nsnull, }, // XXX ick - { "HTML image element", NS_HTMLIMAGEELEMENT_CID, nsnull, }, - { "HTML option element", NS_HTMLOPTIONELEMENT_CID, nsnull, }, { "Presentation shell", NS_PRESSHELL_CID, nsnull, }, + { "Presentation state", NS_PRESSTATE_CID, nsnull, }, + { "Galley context", NS_GALLEYCONTEXT_CID, nsnull, }, + { "Print context", NS_PRINTCONTEXT_CID, nsnull, }, // XXX end ick - { "XML document encoder", NS_TEXT_ENCODER_CID, - NS_DOC_ENCODER_CONTRACTID_BASE "text/xml", }, - { "HTML document encoder", NS_TEXT_ENCODER_CID, - NS_DOC_ENCODER_CONTRACTID_BASE "text/html", }, - { "Plaintext document encoder", NS_TEXT_ENCODER_CID, - NS_DOC_ENCODER_CONTRACTID_BASE "text/plain", }, - { "HTML copy encoder", NS_HTMLCOPY_TEXT_ENCODER_CID, - NS_HTMLCOPY_ENCODER_CONTRACTID, }, - { "XML content serializer", NS_XMLCONTENTSERIALIZER_CID, - NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "text/xml", }, - { "HTML content serializer", NS_HTMLCONTENTSERIALIZER_CID, - NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "text/html", }, - { "XUL content serializer", NS_XMLCONTENTSERIALIZER_CID, - NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "text/xul", }, - { "plaintext content serializer", NS_PLAINTEXTSERIALIZER_CID, - NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "text/plain", }, - { "plaintext sink", NS_PLAINTEXTSERIALIZER_CID, - NS_PLAINTEXTSINK_CONTRACTID, }, - - { "XBL Service", NS_XBLSERVICE_CID, "@mozilla.org/xbl;1" }, - { "XBL Binding Manager", NS_BINDINGMANAGER_CID, "@mozilla.org/xbl/binding-manager;1" }, - { "XUL Box Object", NS_BOXOBJECT_CID, "@mozilla.org/layout/xul-boxobject;1" }, { "XUL Tree Box Object", NS_TREEBOXOBJECT_CID, "@mozilla.org/layout/xul-boxobject-tree;1" }, { "XUL Menu Box Object", NS_MENUBOXOBJECT_CID, "@mozilla.org/layout/xul-boxobject-menu;1" }, @@ -397,11 +345,7 @@ static Components gComponents[] = { { "XUL Iframe Object", NS_IFRAMEBOXOBJECT_CID, "@mozilla.org/layout/xul-boxobject-iframe;1" }, { "XUL ScrollBox Object", NS_SCROLLBOXOBJECT_CID, "@mozilla.org/layout/xul-boxobject-scrollbox;1" }, - { "AutoCopy Service", NS_AUTOCOPYSERVICE_CID, "@mozilla.org/autocopy;1" }, - { "Content policy service", NS_CONTENTPOLICY_CID, NS_CONTENTPOLICY_CONTRACTID }, - { "NodeInfoManager", NS_NODEINFOMANAGER_CID, NS_NODEINFOMANAGER_CONTRACTID }, - { "DOM CSS Computed Style Declaration", NS_COMPUTEDDOMSTYLE_CID, - "@mozilla.org/DOM/Level2/CSS/computedStyleDeclaration;1" } + { "AutoCopy Service", NS_AUTOCOPYSERVICE_CID, "@mozilla.org/autocopy;1" } }; #define NUM_COMPONENTS (sizeof(gComponents) / sizeof(gComponents[0])) diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 33f45ae2194d..9032a0b5f550 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -60,7 +60,10 @@ #include "nsINodeInfo.h" #include "nsIScrollableFrame.h" #include "nsIScrollableView.h" - +#include "nsIElementFactory.h" +#include "nsContentCID.h" +static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); +static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); #include "nsIXULDocument.h" // Temporary fix for Bug 36558 @@ -2159,8 +2162,8 @@ nsComboboxControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, //nsIAtom* tag = NS_NewAtom("mozcombodisplay"); // Add a child text content node for the label - nsCOMPtr labelContent; - nsresult result = NS_NewTextNode(getter_AddRefs(labelContent)); + nsresult result; + nsCOMPtr labelContent(do_CreateInstance(kTextNodeCID,&result)); nsAutoString value; value.AssignWithConversion("X"); if (NS_SUCCEEDED(result) && labelContent) { // set the value of the text node @@ -2185,11 +2188,17 @@ nsComboboxControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, aChildList.AppendElement(labelContent); // create button which drops the list down - nsCOMPtr btnContent; - result = NS_NewHTMLInputElement(getter_AddRefs(btnContent), nodeInfo); - if (NS_SUCCEEDED(result) && btnContent) { - btnContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, NS_ConvertASCIItoUCS2("button"), PR_FALSE); - aChildList.AppendElement(btnContent); + nsCOMPtr ef(do_CreateInstance(kHTMLElementFactoryCID)); + if (ef) { + nsCOMPtr content; + result = ef->CreateInstanceByTag(nodeInfo,getter_AddRefs(content)); + if (NS_SUCCEEDED(result)) { + nsCOMPtr btnContent(do_QueryInterface(content)); + if (btnContent) { + btnContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, NS_ConvertASCIItoUCS2("button"), PR_FALSE); + aChildList.AppendElement(btnContent); + } + } } } diff --git a/layout/forms/nsFileControlFrame.cpp b/layout/forms/nsFileControlFrame.cpp index 03744aeeb807..c050d389a063 100644 --- a/layout/forms/nsFileControlFrame.cpp +++ b/layout/forms/nsFileControlFrame.cpp @@ -24,7 +24,7 @@ #include "nsFormFrame.h" - +#include "nsIElementFactory.h" #include "nsIContent.h" #include "prtypes.h" #include "nsIAtom.h" @@ -58,7 +58,8 @@ #include "nsIDOMEventReceiver.h" #include "nsIScriptGlobalObject.h" - +#include "nsContentCID.h" +static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); nsresult NS_NewFileControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) @@ -122,7 +123,16 @@ nsFileControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None, *getter_AddRefs(nodeInfo)); - if (NS_OK == NS_NewHTMLInputElement(&mTextContent, nodeInfo)) { + nsCOMPtr ef(do_CreateInstance(kHTMLElementFactoryCID,&rv)); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr content; + rv = ef->CreateInstanceByTag(nodeInfo,getter_AddRefs(content)); + NS_ENSURE_SUCCESS(rv, rv); + + rv = content->QueryInterface(NS_GET_IID(nsIHTMLContent),(void**)&mTextContent); + + if (NS_SUCCEEDED(rv)) { mTextContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, NS_ConvertASCIItoUCS2("text"), PR_FALSE); if (nsFormFrame::GetDisabled(this)) { nsCOMPtr textControl = do_QueryInterface(mTextContent); @@ -134,7 +144,12 @@ nsFileControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, } // create browse button - if (NS_OK == NS_NewHTMLInputElement(getter_AddRefs(mBrowse), nodeInfo)) { + rv = ef->CreateInstanceByTag(nodeInfo,getter_AddRefs(content)); + NS_ENSURE_SUCCESS(rv, rv); + + mBrowse = do_QueryInterface(content,&rv); + + if (NS_SUCCEEDED(rv)) { mBrowse->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, NS_ConvertASCIItoUCS2("button"), PR_FALSE); //browse->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, nsAutoString("browse..."), PR_FALSE); diff --git a/layout/forms/nsGfxButtonControlFrame.cpp b/layout/forms/nsGfxButtonControlFrame.cpp index 6cf267e33c7a..c898dd97e220 100644 --- a/layout/forms/nsGfxButtonControlFrame.cpp +++ b/layout/forms/nsGfxButtonControlFrame.cpp @@ -27,6 +27,8 @@ #include "nsFormControlFrame.h" #include "nsISupportsArray.h" #include "nsINameSpaceManager.h" +#include "nsContentCID.h" +static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); // Saving PresState #include "nsIPresState.h" @@ -395,8 +397,7 @@ nsGfxButtonControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, } // Add a child text content node for the label - nsCOMPtr labelContent; - result = NS_NewTextNode(getter_AddRefs(labelContent)); + nsCOMPtr labelContent(do_CreateInstance(kTextNodeCID,&result)); if (NS_SUCCEEDED(result) && labelContent) { // set the value of the text node and add it to the child list mTextContent = do_QueryInterface(labelContent, &result); diff --git a/layout/forms/nsIsIndexFrame.cpp b/layout/forms/nsIsIndexFrame.cpp index d2c76dd1c954..cf9697803cf8 100644 --- a/layout/forms/nsIsIndexFrame.cpp +++ b/layout/forms/nsIsIndexFrame.cpp @@ -60,6 +60,11 @@ #include "nsIFormControlFrame.h" #include "nsINodeInfo.h" #include "nsIDOMEventReceiver.h" +#include "nsIElementFactory.h" +#include "nsContentCID.h" + +static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); +static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID); @@ -206,22 +211,28 @@ nsIsIndexFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nsCOMPtr doc; mContent->GetDocument(*getter_AddRefs(doc)); nsCOMPtr nimgr; - nsresult rv = doc->GetNodeInfoManager(*getter_AddRefs(nimgr)); - NS_ENSURE_SUCCESS(rv, rv); + result = doc->GetNodeInfoManager(*getter_AddRefs(nimgr)); + NS_ENSURE_SUCCESS(result, result); + + nsCOMPtr ef(do_CreateInstance(kHTMLElementFactoryCID,&result)); + NS_ENSURE_SUCCESS(result, result); // Create an hr nsCOMPtr hrInfo; - nsCOMPtr prehr; nimgr->GetNodeInfo(nsHTMLAtoms::hr, nsnull, kNameSpaceID_None, *getter_AddRefs(hrInfo)); - if (NS_OK == NS_NewHTMLHRElement(getter_AddRefs(prehr), hrInfo)) { + nsCOMPtr content; + result = ef->CreateInstanceByTag(hrInfo,getter_AddRefs(content)); + NS_ENSURE_SUCCESS(result, result); + + nsCOMPtr prehr(do_QueryInterface(content,&result)); + if (NS_SUCCEEDED(result)) { result = aChildList.AppendElement(prehr); } // Add a child text content node for the label if (NS_SUCCEEDED(result)) { - nsCOMPtr labelContent; - result = NS_NewTextNode(getter_AddRefs(labelContent)); + nsCOMPtr labelContent(do_CreateInstance(kTextNodeCID,&result)); if (NS_SUCCEEDED(result) && labelContent) { // set the value of the text node and add it to the child list result = labelContent->QueryInterface(NS_GET_IID(nsITextContent),(void**)&mTextContent); @@ -237,7 +248,12 @@ nsIsIndexFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None, *getter_AddRefs(inputInfo)); - if (NS_OK == NS_NewHTMLInputElement(&mInputContent, inputInfo)) { + result = ef->CreateInstanceByTag(inputInfo,getter_AddRefs(content)); + NS_ENSURE_SUCCESS(result, result); + + result = content->QueryInterface(NS_GET_IID(nsIHTMLContent),(void**)&mInputContent); + + if (NS_SUCCEEDED(result)) { mInputContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, NS_ConvertASCIItoUCS2("text"), PR_FALSE); aChildList.AppendElement(mInputContent); @@ -247,8 +263,11 @@ nsIsIndexFrame::CreateAnonymousContent(nsIPresContext* aPresContext, } // Create an hr - nsCOMPtr posthr; - if (NS_OK == NS_NewHTMLHRElement(getter_AddRefs(posthr), hrInfo)) { + result = ef->CreateInstanceByTag(hrInfo,getter_AddRefs(content)); + NS_ENSURE_SUCCESS(result, result); + + nsCOMPtr posthr(do_QueryInterface(content,&result)); + if (NS_SUCCEEDED(result)) { aChildList.AppendElement(posthr); } diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 8ccf87c61fa4..a9d8fcc13858 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -377,8 +377,6 @@ nsGfxScrollFrame::GetScrollbarBox(PRBool aVertical, nsIBox** aResult) return NS_OK; } -nsresult NS_CreateAnonymousNode(nsIContent* aParent, nsIAtom* aTag, PRInt32 aNameSpaceId, nsCOMPtr& aNewNode); - NS_IMETHODIMP nsGfxScrollFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nsISupportsArray& aAnonymousChildren) diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index b9b621db5eea..a55aea0d56d9 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -107,7 +107,45 @@ nsImageFrame::~nsImageFrame() } } -NS_METHOD +NS_IMETHODIMP +nsImageFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) +{ + NS_ENSURE_ARG_POINTER(aInstancePtr); + *aInstancePtr = nsnull; + +#ifdef DEBUG + if (aIID.Equals(NS_GET_IID(nsIFrameDebug))) { + *aInstancePtr = NS_STATIC_CAST(nsIFrameDebug*,this); + return NS_OK; + } +#endif + + if (aIID.Equals(NS_GET_IID(nsIImageFrame))) { + *aInstancePtr = NS_STATIC_CAST(nsIImageFrame*,this); + return NS_OK; + } else if (aIID.Equals(NS_GET_IID(nsIFrame))) { + *aInstancePtr = NS_STATIC_CAST(nsIFrame*,this); + return NS_OK; + } else if (aIID.Equals(NS_GET_IID(nsISupports))) { + *aInstancePtr = NS_STATIC_CAST(nsIImageFrame*,this); + return NS_OK; + } + return NS_NOINTERFACE; +} + +NS_IMETHODIMP_(nsrefcnt) nsImageFrame::AddRef(void) +{ + NS_WARNING("not supported for frames"); + return 1; +} + +NS_IMETHODIMP_(nsrefcnt) nsImageFrame::Release(void) +{ + NS_WARNING("not supported for frames"); + return 1; +} + +NS_IMETHODIMP nsImageFrame::Destroy(nsIPresContext* aPresContext) { // Tell our image map, if there is one, to clean up diff --git a/layout/generic/nsImageFrame.h b/layout/generic/nsImageFrame.h index 3911fe1d5c5e..eecf35e8262e 100644 --- a/layout/generic/nsImageFrame.h +++ b/layout/generic/nsImageFrame.h @@ -26,6 +26,7 @@ #include "nsString.h" #include "nsIPresContext.h" #include "nsHTMLImageLoader.h" +#include "nsIImageFrame.h" class nsIFrame; class nsImageMap; @@ -37,10 +38,13 @@ struct nsSize; #define ImageFrameSuper nsLeafFrame -class nsImageFrame : public ImageFrameSuper { +class nsImageFrame : public ImageFrameSuper, public nsIImageFrame { public: nsImageFrame(); + // nsISupports + NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + NS_IMETHOD Destroy(nsIPresContext* aPresContext); NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, @@ -58,7 +62,7 @@ public: NS_IMETHOD GetContentForEvent(nsIPresContext* aPresContext, nsEvent* aEvent, nsIContent** aContent); - NS_METHOD HandleEvent(nsIPresContext* aPresContext, + NS_IMETHOD HandleEvent(nsIPresContext* aPresContext, nsGUIEvent* aEvent, nsEventStatus* aEventStatus); NS_IMETHOD GetCursor(nsIPresContext* aPresContext, @@ -82,6 +86,10 @@ public: #endif protected: + // nsISupports + NS_IMETHOD_(nsrefcnt) AddRef(void); + NS_IMETHOD_(nsrefcnt) Release(void); + virtual ~nsImageFrame(); virtual void GetDesiredSize(nsIPresContext* aPresContext, diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index 283ece4242f9..3b20b136c1d4 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -60,7 +60,7 @@ #include "nsIDOMEventReceiver.h" #include "nsIPrivateDOMEvent.h" #include "nsIDocumentEncoder.h" -#include "nsRange.h" +#include "nsIDOMRange.h" // XXX For temporary paint code #include "nsIStyleContext.h" @@ -69,7 +69,11 @@ #include "nsMimeTypes.h" #include "nsObjectFrame.h" +#include "nsIObjectFrame.h" +#include "nsContentCID.h" +static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID); + /* X headers suck */ #ifdef KeyPress #undef KeyPress @@ -247,7 +251,44 @@ nsObjectFrame::~nsObjectFrame() } -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +NS_IMETHODIMP +nsObjectFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) +{ + NS_ENSURE_ARG_POINTER(aInstancePtr); + *aInstancePtr = nsnull; + +#ifdef DEBUG + if (aIID.Equals(NS_GET_IID(nsIFrameDebug))) { + *aInstancePtr = NS_STATIC_CAST(nsIFrameDebug*,this); + return NS_OK; + } +#endif + + if (aIID.Equals(NS_GET_IID(nsIObjectFrame))) { + *aInstancePtr = NS_STATIC_CAST(nsIObjectFrame*,this); + return NS_OK; + } else if (aIID.Equals(NS_GET_IID(nsIFrame))) { + *aInstancePtr = NS_STATIC_CAST(nsIFrame*,this); + return NS_OK; + } else if (aIID.Equals(NS_GET_IID(nsISupports))) { + *aInstancePtr = NS_STATIC_CAST(nsIObjectFrame*,this); + return NS_OK; + } + return NS_NOINTERFACE; +} + +NS_IMETHODIMP_(nsrefcnt) nsObjectFrame::AddRef(void) +{ + NS_WARNING("not supported for frames"); + return 1; +} + +NS_IMETHODIMP_(nsrefcnt) nsObjectFrame::Release(void) +{ + NS_WARNING("not supported for frames"); + return 1; +} + static NS_DEFINE_IID(kViewCID, NS_VIEW_CID); static NS_DEFINE_IID(kWidgetCID, NS_CHILD_CID); static NS_DEFINE_IID(kCAppShellCID, NS_APPSHELL_CID); @@ -1429,20 +1470,6 @@ NS_NewObjectFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) return NS_OK; } -// TODO: put this in a header file. -extern nsresult NS_GetObjectFramePluginInstance(nsIFrame* aFrame, nsIPluginInstance*& aPluginInstance); - -nsresult -NS_GetObjectFramePluginInstance(nsIFrame* aFrame, nsIPluginInstance*& aPluginInstance) -{ - if(aFrame == nsnull) - return NS_ERROR_NULL_POINTER; - - // TODO: any way to determine this cast is safe? - nsObjectFrame* objectFrame = NS_STATIC_CAST(nsObjectFrame*, aFrame); - return objectFrame->GetPluginInstance(aPluginInstance); -} - //plugin instance owner nsPluginInstanceOwner::nsPluginInstanceOwner() @@ -1612,7 +1639,7 @@ nsresult nsPluginInstanceOwner::QueryInterface(const nsIID& aIID, return NS_OK; } - if (aIID.Equals(kISupportsIID)) + if (aIID.Equals(NS_GET_IID(nsISupports))) { *aInstancePtrResult = (void *)((nsISupports *)((nsIPluginTagInfo *)this)); AddRef(); @@ -1980,9 +2007,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetTagText(const char* *result) if (NS_FAILED(rv)) return rv; - nsCOMPtr range(new nsRange); - if (!range) - return NS_ERROR_OUT_OF_MEMORY; + nsCOMPtr range(do_CreateInstance(kRangeCID,&rv)); + if (NS_FAILED(rv)) + return rv; rv = range->SelectNode(node); if (NS_FAILED(rv)) diff --git a/layout/generic/nsObjectFrame.h b/layout/generic/nsObjectFrame.h index dcd5b9b47afe..eed75f89c9f2 100644 --- a/layout/generic/nsObjectFrame.h +++ b/layout/generic/nsObjectFrame.h @@ -28,13 +28,17 @@ #include "nsIPresShell.h" #include "nsIPluginHost.h" #include "nsplugin.h" +#include "nsIObjectFrame.h" class nsPluginInstanceOwner; #define nsObjectFrameSuper nsHTMLContainerFrame -class nsObjectFrame : public nsObjectFrameSuper { +class nsObjectFrame : public nsObjectFrameSuper, public nsIObjectFrame { public: + // nsISupports + NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext, nsIAtom* aListName, nsIFrame* aChildList); @@ -69,18 +73,22 @@ public: NS_IMETHOD ContentChanged(nsIPresContext* aPresContext, nsIContent* aChild, nsISupports* aSubContent); + NS_IMETHOD GetPluginInstance(nsIPluginInstance*& aPluginInstance); + //local methods nsresult CreateWidget(nsIPresContext* aPresContext, nscoord aWidth, nscoord aHeight, PRBool aViewOnly); nsresult GetFullURL(nsIURI*& aFullURL); - - nsresult GetPluginInstance(nsIPluginInstance*& aPluginInstance); void IsSupportedImage(nsIContent* aContent, PRBool* aImage); protected: + // nsISupports + NS_IMETHOD_(nsrefcnt) AddRef(void); + NS_IMETHOD_(nsrefcnt) Release(void); + virtual ~nsObjectFrame(); virtual PRIntn GetSkipSides() const; diff --git a/layout/html/Makefile.in b/layout/html/Makefile.in index 3ab4fe76456d..50cc407da5ca 100644 --- a/layout/html/Makefile.in +++ b/layout/html/Makefile.in @@ -26,6 +26,6 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -DIRS = base content document forms style table +DIRS = base document forms style table include $(topsrcdir)/config/rules.mk diff --git a/layout/html/base/src/MANIFEST b/layout/html/base/src/MANIFEST index adf0e1af91dd..86a8536850c4 100644 --- a/layout/html/base/src/MANIFEST +++ b/layout/html/base/src/MANIFEST @@ -4,3 +4,4 @@ nsILineIterator.h nsIHTMLContent.h +nsHTMLParts.h diff --git a/layout/html/base/src/makefile.win b/layout/html/base/src/makefile.win index d5616950b7c0..e634772fbf04 100644 --- a/layout/html/base/src/makefile.win +++ b/layout/html/base/src/makefile.win @@ -21,7 +21,7 @@ DEPTH=..\..\..\.. -LIBRARY_NAME=raptorhtmlbase_s +LIBRARY_NAME=layouthtmlbase_s MODULE=raptor DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN !if defined(XP_NEW_SELECTION) diff --git a/layout/html/base/src/nsGfxScrollFrame.cpp b/layout/html/base/src/nsGfxScrollFrame.cpp index 8ccf87c61fa4..a9d8fcc13858 100644 --- a/layout/html/base/src/nsGfxScrollFrame.cpp +++ b/layout/html/base/src/nsGfxScrollFrame.cpp @@ -377,8 +377,6 @@ nsGfxScrollFrame::GetScrollbarBox(PRBool aVertical, nsIBox** aResult) return NS_OK; } -nsresult NS_CreateAnonymousNode(nsIContent* aParent, nsIAtom* aTag, PRInt32 aNameSpaceId, nsCOMPtr& aNewNode); - NS_IMETHODIMP nsGfxScrollFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nsISupportsArray& aAnonymousChildren) diff --git a/layout/html/base/src/nsImageFrame.cpp b/layout/html/base/src/nsImageFrame.cpp index b9b621db5eea..a55aea0d56d9 100644 --- a/layout/html/base/src/nsImageFrame.cpp +++ b/layout/html/base/src/nsImageFrame.cpp @@ -107,7 +107,45 @@ nsImageFrame::~nsImageFrame() } } -NS_METHOD +NS_IMETHODIMP +nsImageFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) +{ + NS_ENSURE_ARG_POINTER(aInstancePtr); + *aInstancePtr = nsnull; + +#ifdef DEBUG + if (aIID.Equals(NS_GET_IID(nsIFrameDebug))) { + *aInstancePtr = NS_STATIC_CAST(nsIFrameDebug*,this); + return NS_OK; + } +#endif + + if (aIID.Equals(NS_GET_IID(nsIImageFrame))) { + *aInstancePtr = NS_STATIC_CAST(nsIImageFrame*,this); + return NS_OK; + } else if (aIID.Equals(NS_GET_IID(nsIFrame))) { + *aInstancePtr = NS_STATIC_CAST(nsIFrame*,this); + return NS_OK; + } else if (aIID.Equals(NS_GET_IID(nsISupports))) { + *aInstancePtr = NS_STATIC_CAST(nsIImageFrame*,this); + return NS_OK; + } + return NS_NOINTERFACE; +} + +NS_IMETHODIMP_(nsrefcnt) nsImageFrame::AddRef(void) +{ + NS_WARNING("not supported for frames"); + return 1; +} + +NS_IMETHODIMP_(nsrefcnt) nsImageFrame::Release(void) +{ + NS_WARNING("not supported for frames"); + return 1; +} + +NS_IMETHODIMP nsImageFrame::Destroy(nsIPresContext* aPresContext) { // Tell our image map, if there is one, to clean up diff --git a/layout/html/base/src/nsImageFrame.h b/layout/html/base/src/nsImageFrame.h index 3911fe1d5c5e..eecf35e8262e 100644 --- a/layout/html/base/src/nsImageFrame.h +++ b/layout/html/base/src/nsImageFrame.h @@ -26,6 +26,7 @@ #include "nsString.h" #include "nsIPresContext.h" #include "nsHTMLImageLoader.h" +#include "nsIImageFrame.h" class nsIFrame; class nsImageMap; @@ -37,10 +38,13 @@ struct nsSize; #define ImageFrameSuper nsLeafFrame -class nsImageFrame : public ImageFrameSuper { +class nsImageFrame : public ImageFrameSuper, public nsIImageFrame { public: nsImageFrame(); + // nsISupports + NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + NS_IMETHOD Destroy(nsIPresContext* aPresContext); NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, @@ -58,7 +62,7 @@ public: NS_IMETHOD GetContentForEvent(nsIPresContext* aPresContext, nsEvent* aEvent, nsIContent** aContent); - NS_METHOD HandleEvent(nsIPresContext* aPresContext, + NS_IMETHOD HandleEvent(nsIPresContext* aPresContext, nsGUIEvent* aEvent, nsEventStatus* aEventStatus); NS_IMETHOD GetCursor(nsIPresContext* aPresContext, @@ -82,6 +86,10 @@ public: #endif protected: + // nsISupports + NS_IMETHOD_(nsrefcnt) AddRef(void); + NS_IMETHOD_(nsrefcnt) Release(void); + virtual ~nsImageFrame(); virtual void GetDesiredSize(nsIPresContext* aPresContext, diff --git a/layout/html/base/src/nsObjectFrame.cpp b/layout/html/base/src/nsObjectFrame.cpp index 283ece4242f9..3b20b136c1d4 100644 --- a/layout/html/base/src/nsObjectFrame.cpp +++ b/layout/html/base/src/nsObjectFrame.cpp @@ -60,7 +60,7 @@ #include "nsIDOMEventReceiver.h" #include "nsIPrivateDOMEvent.h" #include "nsIDocumentEncoder.h" -#include "nsRange.h" +#include "nsIDOMRange.h" // XXX For temporary paint code #include "nsIStyleContext.h" @@ -69,7 +69,11 @@ #include "nsMimeTypes.h" #include "nsObjectFrame.h" +#include "nsIObjectFrame.h" +#include "nsContentCID.h" +static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID); + /* X headers suck */ #ifdef KeyPress #undef KeyPress @@ -247,7 +251,44 @@ nsObjectFrame::~nsObjectFrame() } -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +NS_IMETHODIMP +nsObjectFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) +{ + NS_ENSURE_ARG_POINTER(aInstancePtr); + *aInstancePtr = nsnull; + +#ifdef DEBUG + if (aIID.Equals(NS_GET_IID(nsIFrameDebug))) { + *aInstancePtr = NS_STATIC_CAST(nsIFrameDebug*,this); + return NS_OK; + } +#endif + + if (aIID.Equals(NS_GET_IID(nsIObjectFrame))) { + *aInstancePtr = NS_STATIC_CAST(nsIObjectFrame*,this); + return NS_OK; + } else if (aIID.Equals(NS_GET_IID(nsIFrame))) { + *aInstancePtr = NS_STATIC_CAST(nsIFrame*,this); + return NS_OK; + } else if (aIID.Equals(NS_GET_IID(nsISupports))) { + *aInstancePtr = NS_STATIC_CAST(nsIObjectFrame*,this); + return NS_OK; + } + return NS_NOINTERFACE; +} + +NS_IMETHODIMP_(nsrefcnt) nsObjectFrame::AddRef(void) +{ + NS_WARNING("not supported for frames"); + return 1; +} + +NS_IMETHODIMP_(nsrefcnt) nsObjectFrame::Release(void) +{ + NS_WARNING("not supported for frames"); + return 1; +} + static NS_DEFINE_IID(kViewCID, NS_VIEW_CID); static NS_DEFINE_IID(kWidgetCID, NS_CHILD_CID); static NS_DEFINE_IID(kCAppShellCID, NS_APPSHELL_CID); @@ -1429,20 +1470,6 @@ NS_NewObjectFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) return NS_OK; } -// TODO: put this in a header file. -extern nsresult NS_GetObjectFramePluginInstance(nsIFrame* aFrame, nsIPluginInstance*& aPluginInstance); - -nsresult -NS_GetObjectFramePluginInstance(nsIFrame* aFrame, nsIPluginInstance*& aPluginInstance) -{ - if(aFrame == nsnull) - return NS_ERROR_NULL_POINTER; - - // TODO: any way to determine this cast is safe? - nsObjectFrame* objectFrame = NS_STATIC_CAST(nsObjectFrame*, aFrame); - return objectFrame->GetPluginInstance(aPluginInstance); -} - //plugin instance owner nsPluginInstanceOwner::nsPluginInstanceOwner() @@ -1612,7 +1639,7 @@ nsresult nsPluginInstanceOwner::QueryInterface(const nsIID& aIID, return NS_OK; } - if (aIID.Equals(kISupportsIID)) + if (aIID.Equals(NS_GET_IID(nsISupports))) { *aInstancePtrResult = (void *)((nsISupports *)((nsIPluginTagInfo *)this)); AddRef(); @@ -1980,9 +2007,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetTagText(const char* *result) if (NS_FAILED(rv)) return rv; - nsCOMPtr range(new nsRange); - if (!range) - return NS_ERROR_OUT_OF_MEMORY; + nsCOMPtr range(do_CreateInstance(kRangeCID,&rv)); + if (NS_FAILED(rv)) + return rv; rv = range->SelectNode(node); if (NS_FAILED(rv)) diff --git a/layout/html/base/src/nsObjectFrame.h b/layout/html/base/src/nsObjectFrame.h index dcd5b9b47afe..eed75f89c9f2 100644 --- a/layout/html/base/src/nsObjectFrame.h +++ b/layout/html/base/src/nsObjectFrame.h @@ -28,13 +28,17 @@ #include "nsIPresShell.h" #include "nsIPluginHost.h" #include "nsplugin.h" +#include "nsIObjectFrame.h" class nsPluginInstanceOwner; #define nsObjectFrameSuper nsHTMLContainerFrame -class nsObjectFrame : public nsObjectFrameSuper { +class nsObjectFrame : public nsObjectFrameSuper, public nsIObjectFrame { public: + // nsISupports + NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext, nsIAtom* aListName, nsIFrame* aChildList); @@ -69,18 +73,22 @@ public: NS_IMETHOD ContentChanged(nsIPresContext* aPresContext, nsIContent* aChild, nsISupports* aSubContent); + NS_IMETHOD GetPluginInstance(nsIPluginInstance*& aPluginInstance); + //local methods nsresult CreateWidget(nsIPresContext* aPresContext, nscoord aWidth, nscoord aHeight, PRBool aViewOnly); nsresult GetFullURL(nsIURI*& aFullURL); - - nsresult GetPluginInstance(nsIPluginInstance*& aPluginInstance); void IsSupportedImage(nsIContent* aContent, PRBool* aImage); protected: + // nsISupports + NS_IMETHOD_(nsrefcnt) AddRef(void); + NS_IMETHOD_(nsrefcnt) Release(void); + virtual ~nsObjectFrame(); virtual PRIntn GetSkipSides() const; diff --git a/layout/html/base/src/nsPresShell.cpp b/layout/html/base/src/nsPresShell.cpp index fe253ae61434..18527d22e629 100644 --- a/layout/html/base/src/nsPresShell.cpp +++ b/layout/html/base/src/nsPresShell.cpp @@ -135,6 +135,10 @@ // SubShell map #include "nsDST.h" +#include "nsContentCID.h" +static NS_DEFINE_CID(kCSSStyleSheetCID, NS_CSS_STYLESHEET_CID); +static NS_DEFINE_CID(kStyleSetCID, NS_STYLESET_CID); + // supporting bugs 31816, 20760, 22963 // define USE_OVERRIDE to put prefs in as an override stylesheet // otherwise they go in as a Backstop stylesheets @@ -1813,7 +1817,7 @@ nsresult PresShell::CreatePreferenceStyleSheet(void) NS_ASSERTION(mPrefStyleSheet==nsnull, "prefStyleSheet already exists"); nsresult result = NS_OK; - result = NS_NewCSSStyleSheet(&mPrefStyleSheet); + result = nsComponentManager::CreateInstance(kCSSStyleSheetCID,nsnull,NS_GET_IID(nsICSSStyleSheet),(void**)&mPrefStyleSheet); if (NS_SUCCEEDED(result)) { NS_ASSERTION(mPrefStyleSheet, "null but no error"); nsCOMPtr uri; @@ -3608,7 +3612,7 @@ PresShell::DoCopy() rv = nsCopySupport::HTMLCopy(sel, doc, nsIClipboard::kGlobalClipboard); if (NS_FAILED(rv)) return rv; - + // Now that we have copied, update the Paste menu item nsCOMPtr globalObject; doc->GetScriptGlobalObject(getter_AddRefs(globalObject)); @@ -5170,8 +5174,8 @@ PresShell::SetReflowEventStatus(PRBool aPending) nsresult PresShell::CloneStyleSet(nsIStyleSet* aSet, nsIStyleSet** aResult) { - nsIStyleSet* clone; - nsresult rv = NS_NewStyleSet(&clone); + nsresult rv; + nsCOMPtr clone(do_CreateInstance(kStyleSetCID,&rv)); if (NS_FAILED(rv)) { return rv; } @@ -5206,7 +5210,8 @@ PresShell::CloneStyleSet(nsIStyleSet* aSet, nsIStyleSet** aResult) NS_RELEASE(ss); } } - *aResult = clone; + *aResult = clone.get(); + NS_ADDREF(*aResult); return NS_OK; } diff --git a/layout/html/document/Makefile.in b/layout/html/document/Makefile.in index 8e79579887a6..0b4d2a90ab5d 100644 --- a/layout/html/document/Makefile.in +++ b/layout/html/document/Makefile.in @@ -26,7 +26,7 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -DIRS = public src +DIRS = src include $(topsrcdir)/config/rules.mk diff --git a/layout/html/document/makefile.win b/layout/html/document/makefile.win index 52fadc942654..a0bd40e9b8e8 100644 --- a/layout/html/document/makefile.win +++ b/layout/html/document/makefile.win @@ -21,6 +21,6 @@ DEPTH=..\..\.. -DIRS=public src +DIRS=src include <$(DEPTH)\config\rules.mak> diff --git a/layout/html/document/src/Makefile.in b/layout/html/document/src/Makefile.in index 49aa3cd3a4d2..be99e1634b06 100644 --- a/layout/html/document/src/Makefile.in +++ b/layout/html/document/src/Makefile.in @@ -31,22 +31,10 @@ LIBRARY_NAME = gkhtmldoc_s REQUIRES = xpcom widget dom necko htmlparser locale view js intl webshell docshell cookie caps util timer uconv pref uriloader rdf chardet appshell nkcache shistory appcomps lwbrk CPPSRCS = \ - nsHTMLContentSink.cpp \ - nsHTMLFragmentContentSink.cpp \ - nsHTMLDocument.cpp \ nsFrameFrame.cpp \ nsFrameSetFrame.cpp \ - nsImageDocument.cpp \ - nsMarkupDocument.cpp \ $(NULL) -EXPORTS = \ - nsIHTMLDocument.h \ - nsIHTMLContentContainer.h \ - $(NULL) - -EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) - # we don't want the shared lib, but we want to force the creation of a static lib. override NO_SHARED_LIB=1 override NO_STATIC_LIB= diff --git a/layout/html/document/src/makefile.win b/layout/html/document/src/makefile.win index d8d6ef0bab5c..e4d5d021b101 100644 --- a/layout/html/document/src/makefile.win +++ b/layout/html/document/src/makefile.win @@ -21,7 +21,7 @@ DEPTH=..\..\..\.. -LIBRARY_NAME=raptorhtmldoc_s +LIBRARY_NAME=layouthtmldoc_s MODULE=raptor DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN @@ -30,28 +30,13 @@ DEFINES = $(DEFINES) -DXP_NEW_SELECTION !endif CPPSRCS= \ - nsHTMLContentSink.cpp \ - nsHTMLDocument.cpp \ - nsHTMLFragmentContentSink.cpp \ nsFrameFrame.cpp \ nsFrameSetFrame.cpp \ - nsImageDocument.cpp \ - nsMarkupDocument.cpp \ $(NULL) CPP_OBJS= \ - .\$(OBJDIR)\nsHTMLContentSink.obj \ - .\$(OBJDIR)\nsHTMLDocument.obj \ - .\$(OBJDIR)\nsHTMLFragmentContentSink.obj \ .\$(OBJDIR)\nsFrameFrame.obj \ .\$(OBJDIR)\nsFrameSetFrame.obj \ - .\$(OBJDIR)\nsImageDocument.obj \ - .\$(OBJDIR)\nsMarkupDocument.obj \ - $(NULL) - -EXPORTS = \ - nsIHTMLDocument.h \ - nsIHTMLContentContainer.h \ $(NULL) LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \ diff --git a/layout/html/forms/public/MANIFEST b/layout/html/forms/public/MANIFEST index e10a1ffc2247..366d233da6c5 100644 --- a/layout/html/forms/public/MANIFEST +++ b/layout/html/forms/public/MANIFEST @@ -11,3 +11,4 @@ nsIFormSubmitObserver.h nsIFormProcessor.h nsISelectControlFrame.h nsIGfxTextControlFrame.h +nsIFormManager.h diff --git a/layout/html/forms/src/makefile.win b/layout/html/forms/src/makefile.win index 70970e73d3df..e1a4e8022c44 100644 --- a/layout/html/forms/src/makefile.win +++ b/layout/html/forms/src/makefile.win @@ -21,7 +21,7 @@ DEPTH=..\..\..\.. -LIBRARY_NAME=raptorhtmlforms_s +LIBRARY_NAME=layouthtmlforms_s DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN MODULE=raptor diff --git a/layout/html/forms/src/nsComboboxControlFrame.cpp b/layout/html/forms/src/nsComboboxControlFrame.cpp index 33f45ae2194d..9032a0b5f550 100644 --- a/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -60,7 +60,10 @@ #include "nsINodeInfo.h" #include "nsIScrollableFrame.h" #include "nsIScrollableView.h" - +#include "nsIElementFactory.h" +#include "nsContentCID.h" +static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); +static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); #include "nsIXULDocument.h" // Temporary fix for Bug 36558 @@ -2159,8 +2162,8 @@ nsComboboxControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, //nsIAtom* tag = NS_NewAtom("mozcombodisplay"); // Add a child text content node for the label - nsCOMPtr labelContent; - nsresult result = NS_NewTextNode(getter_AddRefs(labelContent)); + nsresult result; + nsCOMPtr labelContent(do_CreateInstance(kTextNodeCID,&result)); nsAutoString value; value.AssignWithConversion("X"); if (NS_SUCCEEDED(result) && labelContent) { // set the value of the text node @@ -2185,11 +2188,17 @@ nsComboboxControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, aChildList.AppendElement(labelContent); // create button which drops the list down - nsCOMPtr btnContent; - result = NS_NewHTMLInputElement(getter_AddRefs(btnContent), nodeInfo); - if (NS_SUCCEEDED(result) && btnContent) { - btnContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, NS_ConvertASCIItoUCS2("button"), PR_FALSE); - aChildList.AppendElement(btnContent); + nsCOMPtr ef(do_CreateInstance(kHTMLElementFactoryCID)); + if (ef) { + nsCOMPtr content; + result = ef->CreateInstanceByTag(nodeInfo,getter_AddRefs(content)); + if (NS_SUCCEEDED(result)) { + nsCOMPtr btnContent(do_QueryInterface(content)); + if (btnContent) { + btnContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, NS_ConvertASCIItoUCS2("button"), PR_FALSE); + aChildList.AppendElement(btnContent); + } + } } } diff --git a/layout/html/forms/src/nsFileControlFrame.cpp b/layout/html/forms/src/nsFileControlFrame.cpp index 03744aeeb807..c050d389a063 100644 --- a/layout/html/forms/src/nsFileControlFrame.cpp +++ b/layout/html/forms/src/nsFileControlFrame.cpp @@ -24,7 +24,7 @@ #include "nsFormFrame.h" - +#include "nsIElementFactory.h" #include "nsIContent.h" #include "prtypes.h" #include "nsIAtom.h" @@ -58,7 +58,8 @@ #include "nsIDOMEventReceiver.h" #include "nsIScriptGlobalObject.h" - +#include "nsContentCID.h" +static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); nsresult NS_NewFileControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) @@ -122,7 +123,16 @@ nsFileControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None, *getter_AddRefs(nodeInfo)); - if (NS_OK == NS_NewHTMLInputElement(&mTextContent, nodeInfo)) { + nsCOMPtr ef(do_CreateInstance(kHTMLElementFactoryCID,&rv)); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr content; + rv = ef->CreateInstanceByTag(nodeInfo,getter_AddRefs(content)); + NS_ENSURE_SUCCESS(rv, rv); + + rv = content->QueryInterface(NS_GET_IID(nsIHTMLContent),(void**)&mTextContent); + + if (NS_SUCCEEDED(rv)) { mTextContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, NS_ConvertASCIItoUCS2("text"), PR_FALSE); if (nsFormFrame::GetDisabled(this)) { nsCOMPtr textControl = do_QueryInterface(mTextContent); @@ -134,7 +144,12 @@ nsFileControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, } // create browse button - if (NS_OK == NS_NewHTMLInputElement(getter_AddRefs(mBrowse), nodeInfo)) { + rv = ef->CreateInstanceByTag(nodeInfo,getter_AddRefs(content)); + NS_ENSURE_SUCCESS(rv, rv); + + mBrowse = do_QueryInterface(content,&rv); + + if (NS_SUCCEEDED(rv)) { mBrowse->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, NS_ConvertASCIItoUCS2("button"), PR_FALSE); //browse->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, nsAutoString("browse..."), PR_FALSE); diff --git a/layout/html/forms/src/nsGfxButtonControlFrame.cpp b/layout/html/forms/src/nsGfxButtonControlFrame.cpp index 6cf267e33c7a..c898dd97e220 100644 --- a/layout/html/forms/src/nsGfxButtonControlFrame.cpp +++ b/layout/html/forms/src/nsGfxButtonControlFrame.cpp @@ -27,6 +27,8 @@ #include "nsFormControlFrame.h" #include "nsISupportsArray.h" #include "nsINameSpaceManager.h" +#include "nsContentCID.h" +static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); // Saving PresState #include "nsIPresState.h" @@ -395,8 +397,7 @@ nsGfxButtonControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, } // Add a child text content node for the label - nsCOMPtr labelContent; - result = NS_NewTextNode(getter_AddRefs(labelContent)); + nsCOMPtr labelContent(do_CreateInstance(kTextNodeCID,&result)); if (NS_SUCCEEDED(result) && labelContent) { // set the value of the text node and add it to the child list mTextContent = do_QueryInterface(labelContent, &result); diff --git a/layout/html/forms/src/nsGfxTextControlFrame.cpp b/layout/html/forms/src/nsGfxTextControlFrame.cpp index 5c800f74b8c9..2c7c52983674 100644 --- a/layout/html/forms/src/nsGfxTextControlFrame.cpp +++ b/layout/html/forms/src/nsGfxTextControlFrame.cpp @@ -89,7 +89,7 @@ #include "nsIEventStateManager.h" #include "nsStyleUtil.h" #include "nsLinebreakConverter.h" -#include "nsRange.h" +#include "nsIDOMRange.h" // for anonymous content and frames #include "nsHTMLParts.h" @@ -106,6 +106,10 @@ #include "nsINodeInfo.h" #include "nsLayoutAtoms.h" +#include "nsContentCID.h" + +static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); +static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID); static NS_DEFINE_IID(kTextCID, NS_TEXTFIELD_CID); @@ -575,9 +579,9 @@ nsGfxTextControlFrame::SetSelectionEndPoints(PRInt32 aSelStart, PRInt32 aSelEnd) // remove existing ranges selection->ClearSelection(); - nsCOMPtr selectionRange; - NS_NewRange(getter_AddRefs(selectionRange)); - if (!selectionRange) return NS_ERROR_OUT_OF_MEMORY; + nsCOMPtr selectionRange(do_CreateInstance(kRangeCID,&rv)); + if (NS_FAILED(rv)) + return rv; selectionRange->SetStart(firstTextNode, aSelStart); selectionRange->SetEnd(firstTextNode, aSelEnd); @@ -600,8 +604,9 @@ nsGfxTextControlFrame::SetSelectionEndPoints(PRInt32 aSelStart, PRInt32 aSelEnd) else { // no range. Make a new one. - NS_NewRange(getter_AddRefs(firstRange)); - if (!firstRange) return NS_ERROR_OUT_OF_MEMORY; + firstRange = do_CreateInstance(kRangeCID,&rv); + if (NS_FAILED(rv)) + return rv; mustAdd = PR_TRUE; } @@ -2562,8 +2567,7 @@ nsGfxTextControlFrame::Reflow(nsIPresContext* aPresContext, { // single line text controls get a display frame rather than a subdoc. // the subdoc will be created when the frame first gets focus // create anonymous text content - nsCOMPtr content; - rv = NS_NewTextNode(getter_AddRefs(content)); + nsCOMPtr content(do_CreateInstance(kTextNodeCID,&result)); if (NS_FAILED(rv)) { return rv; } if (!content) { return NS_ERROR_NULL_POINTER; } nsIDocument* doc; diff --git a/layout/html/forms/src/nsGfxTextControlFrame2.cpp b/layout/html/forms/src/nsGfxTextControlFrame2.cpp index 8f220d6b7e84..4554e6edb396 100644 --- a/layout/html/forms/src/nsGfxTextControlFrame2.cpp +++ b/layout/html/forms/src/nsGfxTextControlFrame2.cpp @@ -87,9 +87,8 @@ #include "nsIDOMFocusListener.h" //onchange events #include "nsIDOMCharacterData.h" //for selection setting helper func -#include "nsIDOMNodeList.h" //for selection settting helper func -#include "nsIDOMRange.h" //for selection settting helper func -#include "nsRange.h" //for selection settting helper func (i cant believe this is exported!?) +#include "nsIDOMNodeList.h" //for selection setting helper func +#include "nsIDOMRange.h" //for selection setting helper func #include "nsIScriptGlobalObject.h" //needed for notify selection changed to update the menus ect. #include "nsIDOMWindowInternal.h" //needed for notify selection changed to update the menus ect. #include "nsITextContent.h" //needed to create initial text control content @@ -100,6 +99,8 @@ #define DEFAULT_COLUMN_WIDTH 20 #define GUESS_INPUT_SIZE 150 // 10 pixels wide +#include "nsContentCID.h" +static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID); static NS_DEFINE_CID(kTextEditorCID, NS_TEXTEDITOR_CID); static NS_DEFINE_CID(kFrameSelectionCID, NS_FRAMESELECTION_CID); @@ -2495,9 +2496,9 @@ nsGfxTextControlFrame2::SetSelectionEndPoints(PRInt32 aSelStart, PRInt32 aSelEnd // remove existing ranges selection->RemoveAllRanges(); - nsCOMPtr selectionRange; - NS_NewRange(getter_AddRefs(selectionRange)); - if (!selectionRange) return NS_ERROR_OUT_OF_MEMORY; + nsCOMPtr selectionRange(do_CreateInstance(kRangeCID,&rv)); + if (NS_FAILED(rv)) + return rv; selectionRange->SetStart(firstTextNode, aSelStart); selectionRange->SetEnd(firstTextNode, aSelEnd); @@ -2520,8 +2521,9 @@ nsGfxTextControlFrame2::SetSelectionEndPoints(PRInt32 aSelStart, PRInt32 aSelEnd else { // no range. Make a new one. - NS_NewRange(getter_AddRefs(firstRange)); - if (!firstRange) return NS_ERROR_OUT_OF_MEMORY; + firstRange = do_CreateInstance(kRangeCID,&rv); + if (NS_FAILED(rv)) + return rv; mustAdd = PR_TRUE; } diff --git a/layout/html/forms/src/nsIsIndexFrame.cpp b/layout/html/forms/src/nsIsIndexFrame.cpp index d2c76dd1c954..cf9697803cf8 100644 --- a/layout/html/forms/src/nsIsIndexFrame.cpp +++ b/layout/html/forms/src/nsIsIndexFrame.cpp @@ -60,6 +60,11 @@ #include "nsIFormControlFrame.h" #include "nsINodeInfo.h" #include "nsIDOMEventReceiver.h" +#include "nsIElementFactory.h" +#include "nsContentCID.h" + +static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); +static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID); @@ -206,22 +211,28 @@ nsIsIndexFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nsCOMPtr doc; mContent->GetDocument(*getter_AddRefs(doc)); nsCOMPtr nimgr; - nsresult rv = doc->GetNodeInfoManager(*getter_AddRefs(nimgr)); - NS_ENSURE_SUCCESS(rv, rv); + result = doc->GetNodeInfoManager(*getter_AddRefs(nimgr)); + NS_ENSURE_SUCCESS(result, result); + + nsCOMPtr ef(do_CreateInstance(kHTMLElementFactoryCID,&result)); + NS_ENSURE_SUCCESS(result, result); // Create an hr nsCOMPtr hrInfo; - nsCOMPtr prehr; nimgr->GetNodeInfo(nsHTMLAtoms::hr, nsnull, kNameSpaceID_None, *getter_AddRefs(hrInfo)); - if (NS_OK == NS_NewHTMLHRElement(getter_AddRefs(prehr), hrInfo)) { + nsCOMPtr content; + result = ef->CreateInstanceByTag(hrInfo,getter_AddRefs(content)); + NS_ENSURE_SUCCESS(result, result); + + nsCOMPtr prehr(do_QueryInterface(content,&result)); + if (NS_SUCCEEDED(result)) { result = aChildList.AppendElement(prehr); } // Add a child text content node for the label if (NS_SUCCEEDED(result)) { - nsCOMPtr labelContent; - result = NS_NewTextNode(getter_AddRefs(labelContent)); + nsCOMPtr labelContent(do_CreateInstance(kTextNodeCID,&result)); if (NS_SUCCEEDED(result) && labelContent) { // set the value of the text node and add it to the child list result = labelContent->QueryInterface(NS_GET_IID(nsITextContent),(void**)&mTextContent); @@ -237,7 +248,12 @@ nsIsIndexFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None, *getter_AddRefs(inputInfo)); - if (NS_OK == NS_NewHTMLInputElement(&mInputContent, inputInfo)) { + result = ef->CreateInstanceByTag(inputInfo,getter_AddRefs(content)); + NS_ENSURE_SUCCESS(result, result); + + result = content->QueryInterface(NS_GET_IID(nsIHTMLContent),(void**)&mInputContent); + + if (NS_SUCCEEDED(result)) { mInputContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, NS_ConvertASCIItoUCS2("text"), PR_FALSE); aChildList.AppendElement(mInputContent); @@ -247,8 +263,11 @@ nsIsIndexFrame::CreateAnonymousContent(nsIPresContext* aPresContext, } // Create an hr - nsCOMPtr posthr; - if (NS_OK == NS_NewHTMLHRElement(getter_AddRefs(posthr), hrInfo)) { + result = ef->CreateInstanceByTag(hrInfo,getter_AddRefs(content)); + NS_ENSURE_SUCCESS(result, result); + + nsCOMPtr posthr(do_QueryInterface(content,&result)); + if (NS_SUCCEEDED(result)) { aChildList.AppendElement(posthr); } diff --git a/layout/html/makefile.win b/layout/html/makefile.win index cde17b21df9a..baf4eb635290 100644 --- a/layout/html/makefile.win +++ b/layout/html/makefile.win @@ -21,7 +21,7 @@ DEPTH=..\.. -DIRS = base content document forms style table +DIRS = base document forms style table # tests is now done after we build layout/events include <$(DEPTH)\config\rules.mak> diff --git a/layout/html/style/public/MANIFEST b/layout/html/style/public/MANIFEST index 08cf9bbb8e96..86e446b40674 100644 --- a/layout/html/style/public/MANIFEST +++ b/layout/html/style/public/MANIFEST @@ -1,13 +1,4 @@ # # This is a list of local files which get copied to the mozilla:dist:layout directory # - -nsCSSAtoms.h -nsCSSAtomList.h -nsICSSLoader.h -nsICSSParser.h -nsICSSPseudoComparator.h -nsICSSStyleSheet.h nsStyleUtil.h -nsICSSLoaderObserver.h -nsIComputedDOMStyle.h diff --git a/layout/html/style/public/Makefile.in b/layout/html/style/public/Makefile.in index 5dd21ecfe501..3ff560b10b0b 100644 --- a/layout/html/style/public/Makefile.in +++ b/layout/html/style/public/Makefile.in @@ -29,15 +29,7 @@ include $(DEPTH)/config/autoconf.mk MODULE = layout EXPORTS = \ - nsCSSAtoms.h \ - nsCSSAtomList.h \ - nsICSSLoader.h \ - nsICSSParser.h \ - nsICSSPseudoComparator.h \ - nsICSSStyleSheet.h \ nsStyleUtil.h \ - nsICSSLoaderObserver.h \ - nsIComputedDOMStyle.h \ $(NULL) EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) diff --git a/layout/html/style/public/makefile.win b/layout/html/style/public/makefile.win index ab88e1f4dd89..8eb80d77533d 100644 --- a/layout/html/style/public/makefile.win +++ b/layout/html/style/public/makefile.win @@ -21,7 +21,7 @@ DEPTH=..\..\..\.. -EXPORTS=nsCSSAtoms.h nsCSSAtomList.h nsICSSLoader.h nsICSSParser.h nsICSSPseudoComparator.h nsICSSStyleSheet.h nsStyleUtil.h nsICSSLoaderObserver.h nsIComputedDOMStyle.h +EXPORTS=nsStyleUtil.h MODULE=raptor include <$(DEPTH)\config\rules.mak> diff --git a/layout/html/style/src/Makefile.in b/layout/html/style/src/Makefile.in index 9367e688d7b2..7fdc6c963468 100644 --- a/layout/html/style/src/Makefile.in +++ b/layout/html/style/src/Makefile.in @@ -33,47 +33,15 @@ REQUIRES = xpcom dom widget timer caps editor locale js view necko webshell pref CPPSRCS = \ nsCSSAtoms.cpp \ nsCSSKeywords.cpp \ - nsCSSDeclaration.cpp \ nsCSSFrameConstructor.cpp \ - nsCSSLoader.cpp \ - nsCSSParser.cpp \ nsCSSProps.cpp \ nsCSSRendering.cpp \ - nsCSSScanner.cpp \ - nsCSSRule.cpp \ - nsCSSStyleRule.cpp \ - nsCSSRules.cpp \ - nsCSSStyleSheet.cpp \ - nsCSSValue.cpp \ - nsDOMCSSDeclaration.cpp \ - nsHTMLAttributes.cpp \ - nsHTMLStyleSheet.cpp \ - nsHTMLCSSStyleSheet.cpp \ - nsHTMLValue.cpp \ nsStyleUtil.cpp \ - nsComputedDOMStyle.cpp \ - nsROCSSPrimitiveValue.cpp \ $(NULL) EXPORTS = \ - nsDOMCSSDeclaration.h \ - nsCSSKeywords.h \ - nsCSSKeywordList.h \ - nsCSSProps.h \ - nsCSSPropList.h \ - nsCSSValue.h \ - nsICSSStyleRuleProcessor.h \ - nsICSSRule.h \ - nsICSSGroupRule.h \ - nsICSSStyleRule.h \ - nsICSSCharsetRule.h \ - nsICSSImportRule.h \ - nsICSSMediaRule.h \ - nsICSSNameSpaceRule.h \ - nsICSSDeclaration.h \ - nsHTMLValue.h \ - nsIHTMLCSSStyleSheet.h \ nsIHTMLStyleSheet.h \ + nsICSSFrameConstructor.h \ $(NULL) EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) diff --git a/layout/html/style/src/makefile.win b/layout/html/style/src/makefile.win index e3d0e6776d7c..494f8d3593a8 100644 --- a/layout/html/style/src/makefile.win +++ b/layout/html/style/src/makefile.win @@ -21,80 +21,34 @@ DEPTH=..\..\..\.. -LIBRARY_NAME=raptorhtmlstyle_s +LIBRARY_NAME=layouthtmlstyle_s MODULE=raptor DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN EXPORTS = \ - nsCSSKeywords.h \ - nsCSSKeywordList.h \ - nsCSSProps.h \ - nsCSSPropList.h \ - nsCSSValue.h \ - nsICSSStyleRuleProcessor.h \ - nsICSSRule.h \ - nsICSSGroupRule.h \ - nsICSSStyleRule.h \ - nsICSSCharsetRule.h \ - nsICSSImportRule.h \ - nsICSSMediaRule.h \ - nsICSSNameSpaceRule.h \ - nsICSSDeclaration.h \ - nsIHTMLCSSStyleSheet.h \ nsIHTMLStyleSheet.h \ - nsHTMLValue.h \ - nsDOMCSSDeclaration.h \ + nsICSSFrameConstructor.h \ $(NULL) CPPSRCS= \ nsCSSAtoms.cpp \ nsCSSKeywords.cpp \ - nsCSSDeclaration.cpp \ nsCSSFrameConstructor.cpp \ - nsCSSLoader.cpp \ - nsCSSParser.cpp \ nsCSSProps.cpp \ nsCSSRendering.cpp \ - nsCSSScanner.cpp \ - nsCSSRule.cpp \ - nsCSSStyleRule.cpp \ - nsCSSRules.cpp \ - nsCSSStyleSheet.cpp \ - nsCSSValue.cpp \ - nsHTMLAttributes.cpp \ - nsHTMLStyleSheet.cpp \ - nsHTMLCSSStyleSheet.cpp \ - nsHTMLValue.cpp \ +# nsHTMLStyleSheet.cpp \ nsStyleUtil.cpp \ - nsDOMCSSDeclaration.cpp \ - nsComputedDOMStyle.cpp \ - nsROCSSPrimitiveValue.cpp \ $(NULL) CPP_OBJS = \ .\$(OBJDIR)\nsCSSAtoms.obj \ .\$(OBJDIR)\nsCSSKeywords.obj \ - .\$(OBJDIR)\nsCSSDeclaration.obj \ .\$(OBJDIR)\nsCSSFrameConstructor.obj \ - .\$(OBJDIR)\nsCSSLoader.obj \ - .\$(OBJDIR)\nsCSSParser.obj \ .\$(OBJDIR)\nsCSSProps.obj \ .\$(OBJDIR)\nsCSSRendering.obj \ - .\$(OBJDIR)\nsCSSScanner.obj \ - .\$(OBJDIR)\nsCSSRule.obj \ - .\$(OBJDIR)\nsCSSStyleRule.obj \ - .\$(OBJDIR)\nsCSSRules.obj \ - .\$(OBJDIR)\nsCSSStyleSheet.obj \ - .\$(OBJDIR)\nsCSSValue.obj \ - .\$(OBJDIR)\nsHTMLAttributes.obj \ - .\$(OBJDIR)\nsHTMLStyleSheet.obj \ - .\$(OBJDIR)\nsHTMLCSSStyleSheet.obj \ - .\$(OBJDIR)\nsHTMLValue.obj \ +# .\$(OBJDIR)\nsHTMLStyleSheet.obj \ .\$(OBJDIR)\nsStyleUtil.obj \ - .\$(OBJDIR)\nsDOMCSSDeclaration.obj \ - .\$(OBJDIR)\nsComputedDOMStyle.obj \ - .\$(OBJDIR)\nsROCSSPrimitiveValue.obj \ $(NULL) LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\netlib \ diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index 557f04b13c31..e8c56e08402d 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -37,7 +37,6 @@ #include "nsIPresContext.h" #include "nsILinkHandler.h" #include "nsIDocument.h" -#include "nsIHTMLTableCellElement.h" #include "nsTableColGroupFrame.h" #include "nsTableColFrame.h" #include "nsHTMLIIDs.h" @@ -80,6 +79,13 @@ #include "nsBoxLayoutState.h" #include "nsIBindingManager.h" #include "nsIXBLBinding.h" +#include "nsIElementFactory.h" +#include "nsContentCID.h" + +static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID); +static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID); +static NS_DEFINE_CID(kHTMLImageElementCID, NS_HTMLIMAGEELEMENT_CID); +static NS_DEFINE_CID(kAttributeContentCID, NS_ATTRIBUTECONTENT_CID); #include "nsIDOMWindowInternal.h" #include "nsPIDOMWindow.h" @@ -859,6 +865,22 @@ PRBool GetCaptionAdjustedParent(nsIFrame* aParentFrame, return haveCaption; } +nsresult NS_CreateCSSFrameConstructor(nsICSSFrameConstructor **aResult) +{ + NS_ENSURE_ARG_POINTER(aResult); + *aResult = nsnull; + + nsCSSFrameConstructor *c = new nsCSSFrameConstructor(); + if (!c) + return NS_ERROR_OUT_OF_MEMORY; + + NS_ADDREF(c); + nsresult rv = c->QueryInterface(NS_GET_IID(nsICSSFrameConstructor),(void**)aResult); + NS_RELEASE(c); + + return rv; +} + nsCSSFrameConstructor::nsCSSFrameConstructor(void) : nsIStyleFrameConstruction(), mDocument(nsnull), @@ -886,7 +908,7 @@ nsCSSFrameConstructor::~nsCSSFrameConstructor(void) { } -NS_IMPL_ISUPPORTS(nsCSSFrameConstructor, kIStyleFrameConstructionIID); +NS_IMPL_ISUPPORTS2(nsCSSFrameConstructor, nsIStyleFrameConstruction,nsICSSFrameConstructor); NS_IMETHODIMP nsCSSFrameConstructor::Init(nsIDocument* aDocument) @@ -1268,8 +1290,6 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex aPresContext->GetShell(getter_AddRefs(shell)); if (eStyleContentType_URL == type) { - nsIHTMLContent* imageContent; - // Create an HTML image content object, and set the SRC. // XXX Check if it's an image type we can handle... @@ -1281,7 +1301,16 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex nimgr->GetNodeInfo(nsHTMLAtoms::img, nsnull, kNameSpaceID_None, *getter_AddRefs(nodeInfo)); - NS_NewHTMLImageElement(&imageContent, nodeInfo); + nsCOMPtr ef(do_CreateInstance(kHTMLElementFactoryCID,&rv)); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr content; + rv = ef->CreateInstanceByTag(nodeInfo,getter_AddRefs(content)); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr imageContent(do_QueryInterface(content,&rv)); + NS_ENSURE_SUCCESS(rv, rv); + imageContent->SetHTMLAttribute(nsHTMLAtoms::src, contentString, PR_FALSE); // Set aContent as the parent content and set the document object. This @@ -1293,7 +1322,6 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex nsIFrame* imageFrame; NS_NewImageFrame(shell, &imageFrame); imageFrame->Init(aPresContext, imageContent, aParentFrame, aStyleContext, nsnull); - NS_RELEASE(imageContent); // Return the image frame *aFrame = imageFrame; @@ -1326,10 +1354,9 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex // Creates the content and frame and return if successful nsresult rv = NS_ERROR_FAILURE; if (nsnull != attrName) { - nsCOMPtr content; nsIFrame* textFrame = nsnull; - NS_NewAttributeContent(getter_AddRefs(content)); - if (nsnull != content) { + nsCOMPtr content(do_CreateInstance(kAttributeContentCID)); + if (content) { nsCOMPtr attrContent(do_QueryInterface(content)); if (attrContent) { attrContent->Init(aContent, attrNameSpace, attrName); @@ -1394,11 +1421,11 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex // Create a text content node - nsIContent* textContent = nsnull; nsIDOMCharacterData* domData; nsIFrame* textFrame = nsnull; - - NS_NewTextNode(&textContent); + + nsCOMPtr textContent(do_CreateInstance(kTextNodeCID)); + if (textContent) { // Set the text textContent->QueryInterface(NS_GET_IID(nsIDOMCharacterData), (void**)&domData); @@ -1413,8 +1440,6 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex // Create a text frame and initialize it NS_NewTextFrame(shell, &textFrame); textFrame->Init(aPresContext, textContent, aParentFrame, aStyleContext, nsnull); - - NS_RELEASE(textContent); } // Return the text frame @@ -9946,6 +9971,7 @@ nsCSSFrameConstructor::ConstructAlternateFrame(nsIPresShell* aPresShell, nsIFrame* aParentFrame, nsIFrame*& aFrame) { + nsresult rv; nsAutoString altText; // Initialize OUT parameter @@ -9957,8 +9983,9 @@ nsCSSFrameConstructor::ConstructAlternateFrame(nsIPresShell* aPresShell, GetAlternateTextFor(aContent, tag, altText); // Create a text content element for the alternate text - nsCOMPtr altTextContent; - NS_NewTextNode(getter_AddRefs(altTextContent)); + nsCOMPtr altTextContent(do_CreateInstance(kTextNodeCID,&rv)); + if (NS_FAILED(rv)) + return rv; // Set the content's text nsIDOMCharacterData* domData; diff --git a/layout/html/style/src/nsCSSFrameConstructor.h b/layout/html/style/src/nsCSSFrameConstructor.h index 874965219f73..74b111d34c8d 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.h +++ b/layout/html/style/src/nsCSSFrameConstructor.h @@ -22,6 +22,7 @@ #ifndef nsCSSFrameConstructor_h___ #define nsCSSFrameConstructor_h___ +#include "nsICSSFrameConstructor.h" #include "nsIStyleFrameConstruction.h" #include "nslayout.h" #include "nsIPresContext.h" @@ -44,7 +45,7 @@ class nsFrameConstructorState; class nsIDOMHTMLSelectElement; class nsIXBLService; -class nsCSSFrameConstructor : public nsIStyleFrameConstruction { +class nsCSSFrameConstructor : public nsIStyleFrameConstruction, public nsICSSFrameConstructor { public: nsCSSFrameConstructor(void); virtual ~nsCSSFrameConstructor(void); @@ -57,6 +58,7 @@ private: public: NS_DECL_ISUPPORTS + // nsICSSFrameConstructor NS_IMETHOD Init(nsIDocument* aDocument); // nsIStyleFrameConstruction API diff --git a/layout/html/style/src/nsIHTMLStyleSheet.h b/layout/html/style/src/nsIHTMLStyleSheet.h index 9ceea7880bb7..110f5e4d6339 100644 --- a/layout/html/style/src/nsIHTMLStyleSheet.h +++ b/layout/html/style/src/nsIHTMLStyleSheet.h @@ -40,6 +40,8 @@ class nsIDocument; class nsIHTMLStyleSheet : public nsIStyleSheet { public: + NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHTML_STYLE_SHEET_IID) + NS_IMETHOD Init(nsIURI* aURL, nsIDocument* aDocument) = 0; NS_IMETHOD Reset(nsIURI* aURL) = 0; NS_IMETHOD GetLinkColor(nscolor& aColor) = 0; diff --git a/layout/html/table/src/makefile.win b/layout/html/table/src/makefile.win index d299feae08e7..e5b2676feb7c 100644 --- a/layout/html/table/src/makefile.win +++ b/layout/html/table/src/makefile.win @@ -21,7 +21,7 @@ DEPTH=..\..\..\.. -LIBRARY_NAME=raptorhtmltable_s +LIBRARY_NAME=layouthtmltable_s MODULE=raptor DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN -DoffDEBUG_TABLE_REFLOW_TIMING -DoffDEBUG_TABLE_REFLOW_TIMING_DETAIL diff --git a/layout/html/tests/Makefile.in b/layout/html/tests/Makefile.in index 41c496defa7d..d72146069187 100644 --- a/layout/html/tests/Makefile.in +++ b/layout/html/tests/Makefile.in @@ -31,9 +31,7 @@ REQUIRES = xpcom layout necko unicharutil SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=$(BIN_SUFFIX)) CPPSRCS = \ - TestCSSParser.cpp \ TestCSSPropertyLookup.cpp \ - TestCSSScanner.cpp \ $(NULL) LOCAL_INCLUDES = -I$(srcdir)/../style/src @@ -43,16 +41,16 @@ EXTRA_DSO_LIBS += gkgfx EXTRA_DSO_LIBS += jsdom LIBS = \ - $(DIST)/lib/libgkhtmlcon_s.$(LIB_SUFFIX) \ - $(DIST)/lib/libgkhtmldoc_s.$(LIB_SUFFIX) \ + $(DIST)/lib/libgkconhtmlcon_s.$(LIB_SUFFIX) \ + $(DIST)/lib/libgkconhtmldoc_s.$(LIB_SUFFIX) \ $(DIST)/lib/libgkhtmlforms_s.$(LIB_SUFFIX) \ - $(DIST)/lib/libgkhtmlstyle_s.$(LIB_SUFFIX) \ + $(DIST)/lib/libgkconhtmlstyle_s.$(LIB_SUFFIX) \ $(DIST)/lib/libgkhtmltable_s.$(LIB_SUFFIX) \ $(DIST)/lib/libgkhtmlbase_s.$(LIB_SUFFIX) \ $(DIST)/lib/libgkbase_s.$(LIB_SUFFIX) \ - $(DIST)/lib/libgkevents_s.$(LIB_SUFFIX) \ - $(DIST)/lib/libgkxmlcon_s.$(LIB_SUFFIX) \ - $(DIST)/lib/libgkxmldoc_s.$(LIB_SUFFIX) \ + $(DIST)/lib/libgkconevents_s.$(LIB_SUFFIX) \ + $(DIST)/lib/libgkconxmlcon_s.$(LIB_SUFFIX) \ + $(DIST)/lib/libgkconxmldoc_s.$(LIB_SUFFIX) \ $(DIST)/lib/libgkxulbase_s.$(LIB_SUFFIX) \ $(DIST)/lib/libgkxulcon_s.$(LIB_SUFFIX) \ $(MOZ_JS_LIBS) \ diff --git a/layout/html/tests/makefile.win b/layout/html/tests/makefile.win index 6785fd7fb389..1680af633148 100644 --- a/layout/html/tests/makefile.win +++ b/layout/html/tests/makefile.win @@ -23,11 +23,8 @@ DEPTH=..\..\.. include <$(DEPTH)/config/config.mak> MAKE_OBJ_TYPE = EXE -PROG1 = .\$(OBJDIR)\TestCSSScanner.exe PROG2 = .\$(OBJDIR)\TestCSSPropertyLookup.exe -PROG3 = .\$(OBJDIR)\TestCSSParser.exe -PROG4 = .\$(OBJDIR)\TestAttributes.exe -PROGRAMS = $(PROG1) $(PROG2) $(PROG3) $(PROG4) +PROGRAMS = $(PROG2) DEFINES = -D_IMPL_NS_HTML @@ -48,29 +45,24 @@ LINCS= \ -I..\document\src LLIBS= \ - $(DIST)\lib\raptorhtmlbase_s.lib \ - $(DIST)\lib\nglhtmlcon_s.lib \ - $(DIST)\lib\raptorhtmldoc_s.lib \ - $(DIST)\lib\raptorhtmlforms_s.lib \ - $(DIST)\lib\raptorhtmlstyle_s.lib \ - $(DIST)\lib\raptorhtmltable_s.lib \ - $(DIST)\lib\raptorxmlcontent_s.lib \ - $(DIST)\lib\raptorxmldoc_s.lib \ + $(DIST)\lib\layouthtmlbase_s.lib \ + $(DIST)\lib\layouthtmldoc_s.lib \ + $(DIST)\lib\layouthtmlforms_s.lib \ + $(DIST)\lib\layouthtmlstyle_s.lib \ + $(DIST)\lib\layouthtmltable_s.lib \ $(DIST)\lib\gkparser.lib \ - $(DIST)\lib\raptorlayout_s.lib \ + $(DIST)\lib\layoutbase_s.lib \ $(DIST)\lib\gkgfxwin.lib \ - $(DIST)\lib\raptorevents_s.lib \ - $(DIST)\lib\raptorxulbase_s.lib \ - $(DIST)\lib\raptorxulcontent_s.lib \ + $(DIST)\lib\layoutxulbase_s.lib \ + $(DIST)\lib\layoutxulcontent_s.lib \ !ifdef MOZ_MATHML - $(DIST)\lib\raptormathmlbase_s.lib \ - $(DIST)\lib\raptormathmlcontent_s.lib \ + $(DIST)\lib\layoutmathmlbase_s.lib \ + $(DIST)\lib\layoutmathmlcontent_s.lib \ !endif !ifdef MOZ_SVG - $(DIST)\lib\raptorsvgbase_s.lib \ - $(DIST)\lib\raptorsvgcontent_s.lib \ + $(DIST)\lib\layoutsvgbase_s.lib \ + $(DIST)\lib\layoutsvgcontent_s.lib \ !endif - $(DIST)\lib\raptorxsldoc_s.lib \ $(DIST)\lib\img32$(VERSION_NUMBER).lib \ $(DIST)\lib\util.lib \ $(DIST)\lib\xpcom.lib \ @@ -82,22 +74,9 @@ LLIBS= \ include <$(DEPTH)\config\rules.mak> install:: $(PROGRAMS) - $(MAKE_INSTALL) $(PROG1) $(DIST)\bin $(MAKE_INSTALL) $(PROG2) $(DIST)\bin - $(MAKE_INSTALL) $(PROG3) $(DIST)\bin - $(MAKE_INSTALL) $(PROG4) $(DIST)\bin clobber:: - rm -f $(DIST)\bin\TestCSSScanner.exe rm -f $(DIST)\bin\TestCSSPropertyLookup.exe - rm -f $(DIST)\bin\TestCSSParser.exe - rm -f $(DIST)\bin\TestAttributes.exe - rm -f $(DIST)\bin\TestInlineFrame.exe - -$(PROG1): $(OBJDIR) TestCSSScanner.cpp $(PROG2): $(OBJDIR) TestCSSPropertyLookup.cpp - -$(PROG3): $(OBJDIR) TestCSSParser.cpp - -$(PROG4): $(OBJDIR) TestAttributes.cpp diff --git a/layout/html/tests/table/TableContentTest/TableContentTest.cpp b/layout/html/tests/table/TableContentTest/TableContentTest.cpp index 52898be09bb0..24260c60cd42 100644 --- a/layout/html/tests/table/TableContentTest/TableContentTest.cpp +++ b/layout/html/tests/table/TableContentTest/TableContentTest.cpp @@ -37,6 +37,8 @@ #include "nsIHTMLContent.h" #include "..\..\..\src\nsTablePart.h" +#include "nsContentCID.h" +static NS_DEFINE_CID(kStyleSetCID, NS_STYLESET_CID); static FILE * out; @@ -482,9 +484,8 @@ GeometryTest::GeometryTest(BasicTest *aDoc) vm->SetRootView(rootView); - nsIStyleSet * ss = nsnull; - status = NS_NewStyleSet(&ss); - if ((NS_FAILED(status)) || nsnull==ss) + nsCOMPtr ss(do_CreateInstance(kStyleSetCID,&status)); + if ((NS_FAILED(status))) { fprintf(out, "bad style set"); NS_ASSERTION(PR_FALSE, "bad style set"); diff --git a/layout/makefile.win b/layout/makefile.win index 353ba7d24612..4f7943bf142d 100644 --- a/layout/makefile.win +++ b/layout/makefile.win @@ -24,17 +24,13 @@ DEPTH=.. DIRS= \ base \ html \ - xml \ xul \ - xbl \ - xsl \ !ifdef MOZ_MATHML mathml \ !endif !ifdef MOZ_SVG svg \ !endif - events \ build \ !if !defined(DISABLE_TESTS) html\tests \ diff --git a/layout/mathml/base/src/makefile.win b/layout/mathml/base/src/makefile.win index e3e80cf18bc1..f54d0f7bebf2 100644 --- a/layout/mathml/base/src/makefile.win +++ b/layout/mathml/base/src/makefile.win @@ -22,7 +22,7 @@ DEPTH=..\..\..\.. -LIBRARY_NAME=raptormathmlbase_s +LIBRARY_NAME=layoutmathmlbase_s MODULE=raptor DEFINES= -DWIN32_LEAN_AND_MEAN diff --git a/layout/mathml/content/src/makefile.win b/layout/mathml/content/src/makefile.win index 7cfd4f93a927..65a51192e6cc 100644 --- a/layout/mathml/content/src/makefile.win +++ b/layout/mathml/content/src/makefile.win @@ -23,7 +23,7 @@ DEPTH=..\..\..\.. -LIBRARY_NAME=raptormathmlcontent_s +LIBRARY_NAME=layoutmathmlcontent_s MODULE=raptor DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN diff --git a/layout/mathml/content/src/nsMathMLAtoms.cpp b/layout/mathml/content/src/nsMathMLAtoms.cpp index dd1a634339ef..e407f2264653 100644 --- a/layout/mathml/content/src/nsMathMLAtoms.cpp +++ b/layout/mathml/content/src/nsMathMLAtoms.cpp @@ -23,6 +23,7 @@ #include "nsString.h" #include "nsINameSpaceManager.h" #include "nsMathMLAtoms.h" +#include "nsLayoutCID.h" static const char kMathMLNameSpace[] = "http://www.w3.org/1998/Math/MathML"; @@ -42,11 +43,20 @@ void nsMathMLAtoms::AddRefAtoms() { /* MathML Atoms registers the MathML name space ID because it's a convenient place to do this, if you don't want a permanent, "well-known" ID. */ - if (NS_SUCCEEDED(NS_NewNameSpaceManager(&gNameSpaceManager))) + NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); + nsCOMPtr nsmgr = + do_CreateInstance(kNameSpaceManagerCID); + + if (nsmgr) { // gNameSpaceManager->CreateRootNameSpace(namespace); - gNameSpaceManager->RegisterNameSpace(NS_ConvertASCIItoUCS2(kMathMLNameSpace), nameSpaceID); - else + nsmgr->RegisterNameSpace(NS_ConvertASCIItoUCS2(kMathMLNameSpace), + nameSpaceID); + + gNameSpaceManager = nsmgr; + NS_ADDREF(gNameSpaceManager); + } else { NS_ASSERTION(0, "failed to create MathML atoms namespace manager"); + } // now register the atoms #define MATHML_ATOM(_name, _value) _name = NS_NewAtom(_value); diff --git a/layout/style/nsStyleCoord.h b/layout/style/nsStyleCoord.h index bb97cd0a9cd1..067e0b3112c1 100644 --- a/layout/style/nsStyleCoord.h +++ b/layout/style/nsStyleCoord.h @@ -25,7 +25,7 @@ #include "nscore.h" #include "nsCoord.h" #include "nsCRT.h" -class nsString; +#include "nsString.h" enum nsStyleUnit { eStyleUnit_Null = 0, // (no value) value is not specified @@ -48,15 +48,86 @@ typedef union { class nsStyleCoord { public: - nsStyleCoord(nsStyleUnit aUnit = eStyleUnit_Null); - nsStyleCoord(nscoord aValue); - nsStyleCoord(PRInt32 aValue, nsStyleUnit aUnit); - nsStyleCoord(float aValue, nsStyleUnit aUnit); - nsStyleCoord(const nsStyleCoord& aCopy); + nsStyleCoord(nsStyleUnit aUnit = eStyleUnit_Null) + : mUnit(aUnit) { + NS_ASSERTION(aUnit < eStyleUnit_Percent, "not a valueless unit"); + if (aUnit >= eStyleUnit_Percent) { + mUnit = eStyleUnit_Null; + } + mValue.mInt = 0; + } - nsStyleCoord& operator=(const nsStyleCoord& aCopy); - PRBool operator==(const nsStyleCoord& aOther) const; - PRBool operator!=(const nsStyleCoord& aOther) const; + nsStyleCoord(nscoord aValue) + : mUnit(eStyleUnit_Coord) { + mValue.mInt = aValue; + } + + nsStyleCoord(PRInt32 aValue, nsStyleUnit aUnit) + : mUnit(aUnit) { + //if you want to pass in eStyleUnit_Coord, don't. instead, use the + //constructor just above this one... MMP + NS_ASSERTION((aUnit == eStyleUnit_Proportional) || + (aUnit == eStyleUnit_Enumerated) || + (aUnit == eStyleUnit_Integer), "not an int value"); + if ((aUnit == eStyleUnit_Proportional) || + (aUnit == eStyleUnit_Enumerated) || + (aUnit == eStyleUnit_Integer)) { + mValue.mInt = aValue; + } + else { + mUnit = eStyleUnit_Null; + mValue.mInt = 0; + } + } + + nsStyleCoord(float aValue, nsStyleUnit aUnit) + : mUnit(aUnit) { + NS_ASSERTION((aUnit == eStyleUnit_Percent) || + (aUnit == eStyleUnit_Factor), "not a float value"); + if ((aUnit == eStyleUnit_Percent) || + (aUnit == eStyleUnit_Factor)) { + mValue.mFloat = aValue; + } + else { + mUnit = eStyleUnit_Null; + mValue.mInt = 0; + } + } + + nsStyleCoord(const nsStyleCoord& aCopy) + : mUnit(aCopy.mUnit) { + if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) { + mValue.mFloat = aCopy.mValue.mFloat; + } + else { + mValue.mInt = aCopy.mValue.mInt; + } + } + + nsStyleCoord& operator=(const nsStyleCoord& aCopy) { + mUnit = aCopy.mUnit; + if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) { + mValue.mFloat = aCopy.mValue.mFloat; + } + else { + mValue.mInt = aCopy.mValue.mInt; + } + return *this; + } + + PRBool operator==(const nsStyleCoord& aOther) const { + if (mUnit == aOther.mUnit) { + if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) { + return PRBool(mValue.mFloat == aOther.mValue.mFloat); + } + else { + return PRBool(mValue.mInt == aOther.mValue.mInt); + } + } + return PR_FALSE; + } + + PRBool operator!=(const nsStyleCoord& aOther) const; nsStyleUnit GetUnit(void) const { return mUnit; } nscoord GetCoordValue(void) const; @@ -65,18 +136,98 @@ public: float GetFactorValue(void) const; void GetUnionValue(nsStyleUnion& aValue) const; - void Reset(void); // sets to null - void SetCoordValue(nscoord aValue); - void SetIntValue(PRInt32 aValue, nsStyleUnit aUnit); - void SetPercentValue(float aValue); - void SetFactorValue(float aValue); - void SetNormalValue(void); - void SetAutoValue(void); - void SetInheritValue(void); - void SetUnionValue(const nsStyleUnion& aValue, nsStyleUnit aUnit); + void Reset(void) { + mUnit = eStyleUnit_Null; + mValue.mInt = 0; + } - void AppendToString(nsString& aBuffer) const; - void ToString(nsString& aBuffer) const; + void SetCoordValue(nscoord aValue) { + mUnit = eStyleUnit_Coord; + mValue.mInt = aValue; + } + + void SetIntValue(PRInt32 aValue, nsStyleUnit aUnit) { + if ((aUnit == eStyleUnit_Proportional) || + (aUnit == eStyleUnit_Enumerated) || + (aUnit == eStyleUnit_Chars) || + (aUnit == eStyleUnit_Integer)) { + mUnit = aUnit; + mValue.mInt = aValue; + } + else { + NS_WARNING("not an int value"); + Reset(); + } + } + + void SetPercentValue(float aValue) { + mUnit = eStyleUnit_Percent; + mValue.mFloat = aValue; + } + + void SetFactorValue(float aValue) { + mUnit = eStyleUnit_Factor; + mValue.mFloat = aValue; + } + + void SetNormalValue(void) { + mUnit = eStyleUnit_Normal; + mValue.mInt = 0; + } + + void SetAutoValue(void) { + mUnit = eStyleUnit_Auto; + mValue.mInt = 0; + } + + void SetInheritValue(void) { + mUnit = eStyleUnit_Inherit; + mValue.mInt = 0; + } + + void SetUnionValue(const nsStyleUnion& aValue, nsStyleUnit aUnit) { + mUnit = aUnit; +#if PR_BYTES_PER_INT == PR_BYTES_PER_FLOAT + mValue.mInt = aValue.mInt; +#else + nsCRT::memcpy(&mValue, &aValue, sizeof(nsStyleUnion)); +#endif + } + + void AppendToString(nsString& aBuffer) const { + if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) { + aBuffer.AppendFloat(mValue.mFloat); + } + else if ((eStyleUnit_Coord == mUnit) || + (eStyleUnit_Proportional == mUnit) || + (eStyleUnit_Enumerated == mUnit) || + (eStyleUnit_Integer == mUnit)) { + aBuffer.AppendInt(mValue.mInt, 10); + aBuffer.AppendWithConversion("[0x"); + aBuffer.AppendInt(mValue.mInt, 16); + aBuffer.AppendWithConversion(']'); + } + + switch (mUnit) { + case eStyleUnit_Null: aBuffer.AppendWithConversion("Null"); break; + case eStyleUnit_Coord: aBuffer.AppendWithConversion("tw"); break; + case eStyleUnit_Percent: aBuffer.AppendWithConversion("%"); break; + case eStyleUnit_Factor: aBuffer.AppendWithConversion("f"); break; + case eStyleUnit_Normal: aBuffer.AppendWithConversion("Normal"); break; + case eStyleUnit_Auto: aBuffer.AppendWithConversion("Auto"); break; + case eStyleUnit_Inherit: aBuffer.AppendWithConversion("Inherit"); break; + case eStyleUnit_Proportional: aBuffer.AppendWithConversion("*"); break; + case eStyleUnit_Enumerated: aBuffer.AppendWithConversion("enum"); break; + case eStyleUnit_Integer: aBuffer.AppendWithConversion("int"); break; + case eStyleUnit_Chars: aBuffer.AppendWithConversion("chars"); break; + } + aBuffer.AppendWithConversion(' '); + } + + void ToString(nsString& aBuffer) const { + aBuffer.Truncate(); + AppendToString(aBuffer); + } public: nsStyleUnit mUnit; @@ -84,12 +235,38 @@ public: }; +#define COMPARE_SIDE(side) \ + if ((eStyleUnit_Percent <= m##side##Unit) && \ + (m##side##Unit < eStyleUnit_Coord)) { \ + if (m##side##Value.mFloat != aOther.m##side##Value.mFloat) \ + return PR_FALSE; \ + } \ + else { \ + if (m##side##Value.mInt != aOther.m##side##Value.mInt) \ + return PR_FALSE; \ + } + class nsStyleSides { public: - nsStyleSides(void); + nsStyleSides(void) { + nsCRT::memset(this, 0x00, sizeof(nsStyleSides)); + } // nsStyleSides& operator=(const nsStyleSides& aCopy); // use compiler's version - PRBool operator==(const nsStyleSides& aOther) const; + PRBool operator==(const nsStyleSides& aOther) const { + if ((mLeftUnit == aOther.mLeftUnit) && + (mTopUnit == aOther.mTopUnit) && + (mRightUnit == aOther.mRightUnit) && + (mBottomUnit == aOther.mBottomUnit)) { + COMPARE_SIDE(Left); + COMPARE_SIDE(Top); + COMPARE_SIDE(Right); + COMPARE_SIDE(Bottom); + return PR_TRUE; + } + return PR_FALSE; + } + PRBool operator!=(const nsStyleSides& aOther) const; nsStyleUnit GetLeftUnit(void) const; @@ -102,14 +279,39 @@ public: nsStyleCoord& GetRight(nsStyleCoord& aCoord) const; nsStyleCoord& GetBottom(nsStyleCoord& aCoord) const; - void Reset(void); + void Reset(void) { + nsCRT::memset(this, 0x00, sizeof(nsStyleSides)); + } + void SetLeft(const nsStyleCoord& aCoord); void SetTop(const nsStyleCoord& aCoord); void SetRight(const nsStyleCoord& aCoord); void SetBottom(const nsStyleCoord& aCoord); - void AppendToString(nsString& aBuffer) const; - void ToString(nsString& aBuffer) const; + void AppendToString(nsString& aBuffer) const { + nsStyleCoord temp; + + GetLeft(temp); + aBuffer.AppendWithConversion("left: "); + temp.AppendToString(aBuffer); + + GetTop(temp); + aBuffer.AppendWithConversion("top: "); + temp.AppendToString(aBuffer); + + GetRight(temp); + aBuffer.AppendWithConversion("right: "); + temp.AppendToString(aBuffer); + + GetBottom(temp); + aBuffer.AppendWithConversion("bottom: "); + temp.AppendToString(aBuffer); + } + + void ToString(nsString& aBuffer) const { + aBuffer.Truncate(); + AppendToString(aBuffer); + } protected: PRUint8 mLeftUnit; diff --git a/layout/svg/base/src/makefile.win b/layout/svg/base/src/makefile.win index 18b50037863b..4b82732ce253 100644 --- a/layout/svg/base/src/makefile.win +++ b/layout/svg/base/src/makefile.win @@ -21,7 +21,7 @@ DEPTH=..\..\..\.. -LIBRARY_NAME=raptorsvgbase_s +LIBRARY_NAME=layoutsvgbase_s MODULE=raptor DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN diff --git a/layout/svg/base/src/nsSVGContainerFrame.cpp b/layout/svg/base/src/nsSVGContainerFrame.cpp index 0d5ccff6a7f3..167838680821 100644 --- a/layout/svg/base/src/nsSVGContainerFrame.cpp +++ b/layout/svg/base/src/nsSVGContainerFrame.cpp @@ -36,7 +36,6 @@ #include "nsIViewManager.h" #include "nsIView.h" #include "nsIPresShell.h" -#include "nsGenericHTMLElement.h" #include "nsCSSRendering.h" #include "nsIPref.h" #include "nsIServiceManager.h" diff --git a/layout/svg/content/src/makefile.win b/layout/svg/content/src/makefile.win index d2a5e11884fa..853917001319 100644 --- a/layout/svg/content/src/makefile.win +++ b/layout/svg/content/src/makefile.win @@ -21,7 +21,7 @@ DEPTH=..\..\..\.. -LIBRARY_NAME=raptorsvgcontent_s +LIBRARY_NAME=layoutsvgcontent_s MODULE=raptor DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN diff --git a/layout/svg/content/src/nsSVGAtoms.cpp b/layout/svg/content/src/nsSVGAtoms.cpp index 241c65c4026b..b0a633cecf2e 100644 --- a/layout/svg/content/src/nsSVGAtoms.cpp +++ b/layout/svg/content/src/nsSVGAtoms.cpp @@ -25,6 +25,7 @@ #include "nsString.h" #include "nsINameSpaceManager.h" #include "nsSVGAtoms.h" +#include "nsLayoutCID.h" static const char kSVGNameSpace[] = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.svg"; @@ -45,8 +46,17 @@ void nsSVGAtoms::AddRefAtoms() { /* SVG Atoms registers the SVG name space ID because it's a convenient place to do this, if you don't want a permanent, "well-known" ID. */ - if (NS_SUCCEEDED(NS_NewNameSpaceManager(&gNameSpaceManager))) { - gNameSpaceManager->RegisterNameSpace(NS_ConvertASCIItoUCS2(kSVGNameSpace), nameSpaceID); + + NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); + nsCOMPtr nsmgr = + do_CreateInstance(kNameSpaceManagerCID); + + if (nsmgr) { + nsmgr->RegisterNameSpace(NS_ConvertASCIItoUCS2(kSVGNameSpace), + nameSpaceID); + + gNameSpaceManager = nsmgr; + NS_ADDREF(gNameSpaceManager); } else { NS_ASSERTION(0, "failed to create SVG atoms namespace manager"); } diff --git a/layout/xul/base/src/makefile.win b/layout/xul/base/src/makefile.win index 37450bf56ec9..777654bff20a 100644 --- a/layout/xul/base/src/makefile.win +++ b/layout/xul/base/src/makefile.win @@ -21,7 +21,7 @@ DEPTH=..\..\..\.. -LIBRARY_NAME=raptorxulbase_s +LIBRARY_NAME=layoutxulbase_s MODULE=raptor DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN diff --git a/layout/xul/base/src/nsScrollbarFrame.cpp b/layout/xul/base/src/nsScrollbarFrame.cpp index 401bd412ee5c..b69332c5a449 100644 --- a/layout/xul/base/src/nsScrollbarFrame.cpp +++ b/layout/xul/base/src/nsScrollbarFrame.cpp @@ -29,137 +29,9 @@ #include "nsScrollbarFrame.h" #include "nsScrollbarButtonFrame.h" -#include "nsXULAtoms.h" -#include "nsHTMLAtoms.h" -#include "nsISupportsArray.h" -#include "nsXULAtoms.h" -#include "nsHTMLAtoms.h" -#include "nsINameSpaceManager.h" -#include "nsIXMLContent.h" -#include "nsIDOMDocument.h" -#include "nsIDocument.h" -#include "nsIDOMElement.h" -#include "nsXMLElement.h" -#include "nsIStyledContent.h" -#include "nsIStyleRule.h" -#include "nsHTMLValue.h" -#include "nsIAnonymousContent.h" #include "nsIView.h" -class AnonymousElement : public nsXMLElement, public nsIAnonymousContent -{ -public: - AnonymousElement() {} - - // nsISupports - NS_DECL_ISUPPORTS_INHERITED - - NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, - nsEvent* aEvent, - nsIDOMEvent** aDOMEvent, - PRUint32 aFlags, - nsEventStatus* aEventStatus); -}; - -#if 0 -NS_IMETHODIMP -AnonymousElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const { - return this->nsXMLElement::SizeOf(aSizer, aResult); -} -#endif - -NS_IMETHODIMP -AnonymousElement::HandleDOMEvent(nsIPresContext* aPresContext, - nsEvent* aEvent, - nsIDOMEvent** aDOMEvent, - PRUint32 aFlags, - nsEventStatus* aEventStatus) -{ - /* - // if our parent is not anonymous then we don't want to bubble the event - // so lets set our parent in nsnull to prevent it. Then we will set it - // back. - nsIContent* parent = nsnull; - GetParent(parent); - - nsCOMPtr anonymousParent(do_QueryInterface(parent)); - - - if (!anonymousParent) - SetParent(nsnull); -*/ - - nsresult rv = nsXMLElement::HandleDOMEvent(aPresContext, aEvent, aDOMEvent, - aFlags, aEventStatus); - - /* - if (!anonymousParent) - SetParent(parent); -*/ - return rv; -} - -NS_IMPL_ADDREF_INHERITED(AnonymousElement, nsXMLElement) -NS_IMPL_RELEASE_INHERITED(AnonymousElement, nsXMLElement) - -// -// QueryInterface -// - -NS_INTERFACE_MAP_BEGIN(AnonymousElement) - NS_INTERFACE_MAP_ENTRY(nsIAnonymousContent) -NS_INTERFACE_MAP_END_INHERITING(nsXMLElement) - - -nsresult NS_CreateAnonymousNode(nsIContent* aParent, nsIAtom* aTag, PRInt32 aNameSpaceId, nsCOMPtr& aNewNode) -{ - NS_ENSURE_ARG_POINTER(aParent); - - // create the xml element - //NS_NewXMLElement(getter_AddRefs(content), aTag); - - nsCOMPtr doc; - aParent->GetDocument(*getter_AddRefs(doc)); - - nsCOMPtr nodeInfoManager; - doc->GetNodeInfoManager(*getter_AddRefs(nodeInfoManager)); - - nsCOMPtr nodeInfo; - nodeInfoManager->GetNodeInfo(aTag, nsnull, aNameSpaceId, - *getter_AddRefs(nodeInfo)); - - nsXMLElement *content = new AnonymousElement(); - - if (!content) - return NS_ERROR_OUT_OF_MEMORY; - - nsresult rv = content->Init(nodeInfo); - - if (NS_FAILED(rv)) { - delete content; - - return rv; - } - - aNewNode = content; - - /* - nsCOMPtr document; - aParent->GetDocument(*getter_AddRefs(document)); - - nsCOMPtr domDocument(do_QueryInterface(document)); - nsCOMPtr element; - nsString name; - aTag->ToString(name); - domDocument->CreateElement(name, getter_AddRefs(element)); - aNewNode = do_QueryInterface(element); -*/ - - return NS_OK; -} - - // // NS_NewToolbarFrame // @@ -181,7 +53,6 @@ NS_NewScrollbarFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame ) } // NS_NewScrollbarFrame - // // QueryInterface // diff --git a/layout/xul/base/src/nsSplitterFrame.cpp b/layout/xul/base/src/nsSplitterFrame.cpp index cdfe3b3ee8e5..9939d3a33217 100644 --- a/layout/xul/base/src/nsSplitterFrame.cpp +++ b/layout/xul/base/src/nsSplitterFrame.cpp @@ -57,6 +57,11 @@ #include "nsIXBLService.h" #include "nsIServiceManager.h" #include "nsHTMLContainerFrame.h" +#include "nsINodeInfo.h" +#include "nsIAnonymousContent.h" + +#include "nsContentCID.h" +static NS_DEFINE_IID(kAnonymousElementCID, NS_ANONYMOUSCONTENT_CID); const PRInt32 kMaxZ = 0x7fffffff; //XXX: Shouldn't there be a define somewhere for MaxInt for PRInt32 static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); @@ -260,7 +265,46 @@ NS_INTERFACE_MAP_BEGIN(nsSplitterFrame) NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame) -nsresult NS_CreateAnonymousNode(nsIContent* aParent, nsIAtom* aTag, PRInt32 aNameSpaceId, nsCOMPtr& aNewNode); +static nsresult CreateAnonymousNode(nsIContent* aParent, nsIAtom* aTag, PRInt32 aNameSpaceId, nsIContent **aNewNode) +{ + NS_ENSURE_ARG_POINTER(aParent); + NS_ENSURE_ARG_POINTER(aNewNode); + *aNewNode = nsnull; + + nsresult rv; + nsCOMPtr content(do_CreateInstance(kAnonymousElementCID,&rv)); + if (NS_FAILED(rv)) + return rv; + + nsCOMPtr doc; + rv = aParent->GetDocument(*getter_AddRefs(doc)); + if (NS_FAILED(rv)) + return rv; + + nsCOMPtr nodeInfoManager; + rv = doc->GetNodeInfoManager(*getter_AddRefs(nodeInfoManager)); + if (NS_FAILED(rv)) + return rv; + + nsCOMPtr nodeInfo; + rv = nodeInfoManager->GetNodeInfo(aTag, nsnull, aNameSpaceId, + *getter_AddRefs(nodeInfo)); + if (NS_FAILED(rv)) + return rv; + + nsCOMPtr anon(do_QueryInterface(content,&rv)); + if (NS_FAILED(rv)) + return rv; + + rv = anon->Init(nodeInfo); + if (NS_FAILED(rv)) + return rv; + + *aNewNode = content.get(); + NS_ADDREF(*aNewNode); + + return NS_OK; +} /** * Anonymous interface @@ -281,16 +325,16 @@ nsSplitterFrame::CreateAnonymousContent(nsIPresContext* aPresContext, { // create a spring nsCOMPtr content; - NS_CreateAnonymousNode(mContent, nsXULAtoms::spring, nsXULAtoms::nameSpaceID, content); + CreateAnonymousNode(mContent, nsXULAtoms::spring, nsXULAtoms::nameSpaceID, getter_AddRefs(content)); content->SetAttribute(kNameSpaceID_None, nsXULAtoms::flex, NS_ConvertASCIItoUCS2("100%"), PR_FALSE); aAnonymousChildren.AppendElement(content); // a grippy - NS_CreateAnonymousNode(mContent, nsXULAtoms::grippy, nsXULAtoms::nameSpaceID, content); + CreateAnonymousNode(mContent, nsXULAtoms::grippy, nsXULAtoms::nameSpaceID, getter_AddRefs(content)); aAnonymousChildren.AppendElement(content); // create a spring - NS_CreateAnonymousNode(mContent, nsXULAtoms::spring, nsXULAtoms::nameSpaceID, content); + CreateAnonymousNode(mContent, nsXULAtoms::spring, nsXULAtoms::nameSpaceID, getter_AddRefs(content)); content->SetAttribute(kNameSpaceID_None, nsXULAtoms::flex, NS_ConvertASCIItoUCS2("100%"), PR_FALSE); aAnonymousChildren.AppendElement(content); } diff --git a/layout/xul/content/src/makefile.win b/layout/xul/content/src/makefile.win index 2b32d18e7baa..b6b82fcc1173 100644 --- a/layout/xul/content/src/makefile.win +++ b/layout/xul/content/src/makefile.win @@ -21,7 +21,7 @@ DEPTH=..\..\..\.. -LIBRARY_NAME=raptorxulcontent_s +LIBRARY_NAME=layoutxulcontent_s MODULE=raptor DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN diff --git a/layout/xul/content/src/nsXULAtoms.cpp b/layout/xul/content/src/nsXULAtoms.cpp index 653e4f1f20c0..0f7f2441a0e8 100644 --- a/layout/xul/content/src/nsXULAtoms.cpp +++ b/layout/xul/content/src/nsXULAtoms.cpp @@ -25,6 +25,8 @@ #include "nsString.h" #include "nsINameSpaceManager.h" #include "nsXULAtoms.h" +#include "nsContentCID.h" +static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); static const char kXULNameSpace[] = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; @@ -45,7 +47,7 @@ void nsXULAtoms::AddRefAtoms() { /* XUL Atoms registers the XUL name space ID because it's a convenient place to do this, if you don't want a permanent, "well-known" ID. */ - if (NS_SUCCEEDED(NS_NewNameSpaceManager(&gNameSpaceManager))) { + if (NS_SUCCEEDED(nsComponentManager::CreateInstance(kNameSpaceManagerCID,nsnull,NS_GET_IID(nsINameSpaceManager),(void**)&gNameSpaceManager))) { // gNameSpaceManager->CreateRootNameSpace(namespace); nsAutoString nameSpace; nameSpace.AssignWithConversion(kXULNameSpace); gNameSpaceManager->RegisterNameSpace(nameSpace, nameSpaceID); diff --git a/makefile.win b/makefile.win index 886bdb6986a2..51d8c628f686 100644 --- a/makefile.win +++ b/makefile.win @@ -79,6 +79,7 @@ DIRS = \ widget \ dom \ view \ + content \ layout \ rdf \ docshell \ diff --git a/rdf/content/src/nsXULDocument.cpp b/rdf/content/src/nsXULDocument.cpp index 17c60632f230..ff011a1eaca7 100644 --- a/rdf/content/src/nsXULDocument.cpp +++ b/rdf/content/src/nsXULDocument.cpp @@ -106,6 +106,7 @@ #include "nsIXULPrototypeCache.h" #include "nsLWBrkCIID.h" #include "nsLayoutCID.h" +#include "nsContentCID.h" #include "nsNetUtil.h" #include "nsParserCIID.h" #include "nsPIBoxObject.h" diff --git a/rdf/content/src/nsXULElement.cpp b/rdf/content/src/nsXULElement.cpp index 906f0f494f65..479f0cebd1b6 100644 --- a/rdf/content/src/nsXULElement.cpp +++ b/rdf/content/src/nsXULElement.cpp @@ -101,6 +101,7 @@ #include "nsIXULTemplateBuilder.h" #include "nsIXBLService.h" #include "nsLayoutCID.h" +#include "nsContentCID.h" #include "nsRDFCID.h" #include "nsRDFDOMNodeList.h" #include "nsStyleConsts.h" diff --git a/xpinstall/src/Makefile.in b/xpinstall/src/Makefile.in index 1cfdada63900..6d6afe84c766 100644 --- a/xpinstall/src/Makefile.in +++ b/xpinstall/src/Makefile.in @@ -33,10 +33,7 @@ MODULE = xpinstall LIBRARY_NAME = xpinstall SHORT_LIBNAME = xpinstal IS_COMPONENT = 1 -REQUIRES = xpcom jar chrome necko intl locale libreg dom js pref appshell widget layout uriloader xpconnect rdf docshell - -EXTRA_DSO_LIBS = jsdom - +REQUIRES = xpcom jar chrome necko intl locale libreg js pref appshell widget layout uriloader xpconnect rdf docshell # XXX shouldn't need to export this EXPORTS = nsXPITriggerInfo.h diff --git a/xpinstall/src/makefile.win b/xpinstall/src/makefile.win index 9572990fcaec..541f0f0b3484 100644 --- a/xpinstall/src/makefile.win +++ b/xpinstall/src/makefile.win @@ -45,9 +45,7 @@ LCFLAGS = \ LLIBS = \ $(DIST)\lib\xpcom.lib \ $(DIST)\lib\js3250.lib \ - $(DIST)\lib\jsdombase_s.lib \ - $(DIST)\lib\jsdomevents_s.lib \ - $(DIST)\lib\zlib.lib \ + $(DIST)\lib\zlib.lib \ $(DIST)\lib\strres.lib \ $(LIBNSPR) \ $(DIST)\lib\mozreg.lib \ diff --git a/xpinstall/src/nsJSFile.cpp b/xpinstall/src/nsJSFile.cpp index 9c1225ab0708..6e21dd0edcad 100644 --- a/xpinstall/src/nsJSFile.cpp +++ b/xpinstall/src/nsJSFile.cpp @@ -21,7 +21,6 @@ */ #include "jsapi.h" -#include "nsJSUtils.h" #include "nscore.h" #include "nsIScriptContext.h" diff --git a/xpinstall/src/nsJSFile.h b/xpinstall/src/nsJSFile.h index f8041487d356..84e87b121fb0 100644 --- a/xpinstall/src/nsJSFile.h +++ b/xpinstall/src/nsJSFile.h @@ -24,7 +24,6 @@ #define __NS_JSFILE_H__ #include "jsapi.h" -#include "nsJSUtils.h" #include "nscore.h" diff --git a/xpinstall/src/nsJSFileSpecObj.cpp b/xpinstall/src/nsJSFileSpecObj.cpp index dbfe1cc50c29..c85ceca7b80a 100644 --- a/xpinstall/src/nsJSFileSpecObj.cpp +++ b/xpinstall/src/nsJSFileSpecObj.cpp @@ -17,7 +17,6 @@ */ #include "jsapi.h" -#include "nsJSUtils.h" #include "nscore.h" #include "nsIScriptContext.h" @@ -66,9 +65,17 @@ fso_ToString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) return JS_TRUE; } - if(NS_FAILED( nativeThis->ToString(&stringReturned))) - return JS_FALSE; - nsJSUtils::nsConvertStringToJSVal(stringReturned, cx, rval); + if(NS_FAILED( nativeThis->ToString(&stringReturned))) + return JS_FALSE; + + + JSString *jsstring = + JS_NewUCStringCopyN(cx, NS_REINTERPRET_CAST(const jschar*, + stringReturned.GetUnicode()), + stringReturned.Length()); + + // set the return value + *rval = STRING_TO_JSVAL(jsstring); return JS_TRUE; } diff --git a/xpinstall/src/nsJSInstall.cpp b/xpinstall/src/nsJSInstall.cpp index e7d26e53fb30..cf1e93f841b3 100644 --- a/xpinstall/src/nsJSInstall.cpp +++ b/xpinstall/src/nsJSInstall.cpp @@ -21,7 +21,6 @@ */ #include "jsapi.h" -#include "nsJSUtils.h" #include "nsJSFile.h" #include "nscore.h" #include "nsIScriptContext.h" diff --git a/xpinstall/src/nsJSInstallTriggerGlobal.cpp b/xpinstall/src/nsJSInstallTriggerGlobal.cpp index a32f5de6647e..47c19614db30 100644 --- a/xpinstall/src/nsJSInstallTriggerGlobal.cpp +++ b/xpinstall/src/nsJSInstallTriggerGlobal.cpp @@ -21,10 +21,8 @@ */ #include "jsapi.h" -#include "nsJSUtils.h" #include "nscore.h" #include "nsIScriptContext.h" -#include "nsIJSScriptObject.h" #include "nsIScriptObjectOwner.h" #include "nsIScriptGlobalObject.h" #include "nsCRT.h" @@ -56,22 +54,27 @@ extern PRBool ConvertJSValToObj(nsISupports** aSupports, JSContext* aContext, jsval aValue); -static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); -static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); -static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID); -static NS_DEFINE_IID(kIInstallTriggerGlobalIID, NS_IDOMINSTALLTRIGGERGLOBAL_IID); - // // InstallTriggerGlobal finalizer // PR_STATIC_CALLBACK(void) FinalizeInstallTriggerGlobal(JSContext *cx, JSObject *obj) { - nsJSUtils::nsGenericFinalize(cx, obj); -} + nsISupports *nativeThis = (nsISupports*)JS_GetPrivate(cx, obj); -static NS_DEFINE_IID(kIDOMInstallTriggerIID, NS_IDOMINSTALLTRIGGERGLOBAL_IID); -static NS_DEFINE_IID(kInstallTrigger_CID, NS_SoftwareUpdateInstallTrigger_CID); + if (nsnull != nativeThis) { + // get the js object + nsIScriptObjectOwner *owner = nsnull; + if (NS_OK == nativeThis->QueryInterface(NS_GET_IID(nsIScriptObjectOwner), + (void**)&owner)) { + owner->SetScriptObject(nsnull); + NS_RELEASE(owner); + } + + // The addref was part of JSObject construction + NS_RELEASE(nativeThis); + } +} static JSBool CreateNativeObject(JSContext *cx, JSObject *obj, nsIDOMInstallTriggerGlobal **aResult) { @@ -79,14 +82,18 @@ static JSBool CreateNativeObject(JSContext *cx, JSObject *obj, nsIDOMInstallTrig nsIScriptObjectOwner *owner = nsnull; nsIDOMInstallTriggerGlobal *nativeThis; + static NS_DEFINE_CID(kInstallTrigger_CID, + NS_SoftwareUpdateInstallTrigger_CID); + result = nsRepository::CreateInstance(kInstallTrigger_CID, nsnull, - kIDOMInstallTriggerIID, + NS_GET_IID(nsIDOMInstallTriggerGlobal), (void **)&nativeThis); if (NS_OK != result) return JS_FALSE; - result = nativeThis->QueryInterface(kIScriptObjectOwnerIID, (void **)&owner); + result = nativeThis->QueryInterface(NS_GET_IID(nsIScriptObjectOwner), + (void **)&owner); if (NS_OK != result) { @@ -640,7 +647,8 @@ extern "C" NS_DOM nsresult NS_NewScriptInstallTriggerGlobal(nsIScriptContext *aC if (nsnull == aParent) { parent = nsnull; } - else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { + else if (NS_OK == aParent->QueryInterface(NS_GET_IID(nsIScriptObjectOwner), + (void**)&owner)) { if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) { NS_RELEASE(owner); return NS_ERROR_FAILURE; @@ -655,7 +663,8 @@ extern "C" NS_DOM nsresult NS_NewScriptInstallTriggerGlobal(nsIScriptContext *aC return NS_ERROR_FAILURE; } - result = aSupports->QueryInterface(kIInstallTriggerGlobalIID, (void **)&aInstallTriggerGlobal); + result = aSupports->QueryInterface(NS_GET_IID(nsIDOMInstallTriggerGlobal), + (void **)&aInstallTriggerGlobal); if (NS_OK != result) { return result; } diff --git a/xpinstall/src/nsJSInstallVersion.cpp b/xpinstall/src/nsJSInstallVersion.cpp index 539d9bda1717..71d6b98490ac 100644 --- a/xpinstall/src/nsJSInstallVersion.cpp +++ b/xpinstall/src/nsJSInstallVersion.cpp @@ -22,10 +22,8 @@ /* AUTO-GENERATED. DO NOT EDIT!!! */ #include "jsapi.h" -#include "nsJSUtils.h" #include "nscore.h" #include "nsIScriptContext.h" -#include "nsIJSScriptObject.h" #include "nsIScriptObjectOwner.h" #include "nsIScriptGlobalObject.h" #include "nsString.h" @@ -57,11 +55,6 @@ extern PRBool ConvertJSValToObj(nsISupports** aSupports, void ConvertJSvalToVersionString(nsString& versionString, JSContext* cx, jsval* argument); -static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); -static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); -static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID); -static NS_DEFINE_IID(kIInstallVersionIID, NS_IDOMINSTALLVERSION_IID); - // // InstallVersion property ids // @@ -132,15 +125,10 @@ GetInstallVersionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) } break; } - default: - return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp); } } - else { - return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp); - } - return PR_TRUE; + return JS_TRUE; } /***********************************************************************/ @@ -223,15 +211,10 @@ SetInstallVersionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) break; } - default: - return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp); } } - else { - return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp); - } - return PR_TRUE; + return JS_TRUE; } @@ -241,7 +224,20 @@ SetInstallVersionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) PR_STATIC_CALLBACK(void) FinalizeInstallVersion(JSContext *cx, JSObject *obj) { - nsJSUtils::nsGenericFinalize(cx, obj); + nsISupports *nativeThis = (nsISupports*)JS_GetPrivate(cx, obj); + + if (nsnull != nativeThis) { + // get the js object + nsIScriptObjectOwner *owner = nsnull; + if (NS_OK == nativeThis->QueryInterface(NS_GET_IID(nsIScriptObjectOwner), + (void**)&owner)) { + owner->SetScriptObject(nsnull); + NS_RELEASE(owner); + } + + // The addref was part of JSObject construction + NS_RELEASE(nativeThis); + } } @@ -251,7 +247,7 @@ FinalizeInstallVersion(JSContext *cx, JSObject *obj) PR_STATIC_CALLBACK(JSBool) EnumerateInstallVersion(JSContext *cx, JSObject *obj) { - return nsJSUtils::nsGenericEnumerate(cx, obj, nsnull); + return JS_TRUE; } @@ -261,7 +257,7 @@ EnumerateInstallVersion(JSContext *cx, JSObject *obj) PR_STATIC_CALLBACK(JSBool) ResolveInstallVersion(JSContext *cx, JSObject *obj, jsval id) { - return nsJSUtils::nsGenericResolve(cx, obj, id, nsnull); + return JS_TRUE; } @@ -283,7 +279,11 @@ InstallVersionInit(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval if (argc == 1) { - nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]); + JSString *jsstring; + if ((jsstring = JS_ValueToString(cx, argv[0])) != nsnull) { + b0.Assign(NS_REINTERPRET_CAST(const PRUnichar*, + JS_GetStringChars(jsstring))); + } } else { @@ -321,7 +321,13 @@ InstallVersionToString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js return JS_FALSE; } - nsJSUtils::nsConvertStringToJSVal(nativeRet, cx, rval); + JSString *jsstring = + JS_NewUCStringCopyN(cx, NS_REINTERPRET_CAST(const jschar*, + nativeRet.GetUnicode()), + nativeRet.Length()); + + // set the return value + *rval = STRING_TO_JSVAL(jsstring); } else { JS_ReportError(cx, "Function toString requires 0 parameters"); @@ -402,7 +408,7 @@ InstallVersionCompareTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j nsCOMPtr versionObj; if(JS_FALSE == ConvertJSValToObj(getter_AddRefs(versionObj), - kIInstallVersionIID, + NS_GET_IID(nsIDOMInstallVersion), NS_ConvertASCIItoUCS2("InstallVersion"), cx, argv[0])) @@ -506,17 +512,17 @@ InstallVersion(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva nsIDOMInstallVersion *nativeThis; nsIScriptObjectOwner *owner = nsnull; - static NS_DEFINE_IID(kIDOMInstallVersionIID, NS_IDOMINSTALLVERSION_IID); static NS_DEFINE_IID(kInstallVersion_CID, NS_SoftwareUpdateInstallVersion_CID); result = nsRepository::CreateInstance(kInstallVersion_CID, nsnull, - kIDOMInstallVersionIID, + NS_GET_IID(nsIDOMInstallVersion), (void **)&nativeThis); if (NS_OK != result) return JS_FALSE; - result = nativeThis->QueryInterface(kIScriptObjectOwnerIID, (void **)&owner); + result = nativeThis->QueryInterface(NS_GET_IID(nsIScriptObjectOwner), + (void **)&owner); if (NS_OK != result) { NS_RELEASE(nativeThis); return JS_FALSE; @@ -616,7 +622,8 @@ extern "C" NS_DOM nsresult NS_NewScriptInstallVersion(nsIScriptContext *aContext if (nsnull == aParent) { parent = nsnull; } - else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { + else if (NS_OK == aParent->QueryInterface(NS_GET_IID(nsIScriptObjectOwner), + (void**)&owner)) { if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) { NS_RELEASE(owner); return NS_ERROR_FAILURE; @@ -631,7 +638,7 @@ extern "C" NS_DOM nsresult NS_NewScriptInstallVersion(nsIScriptContext *aContext return NS_ERROR_FAILURE; } - result = aSupports->QueryInterface(kIInstallVersionIID, (void **)&aInstallVersion); + result = aSupports->QueryInterface(NS_GET_IID(nsIDOMInstallVersion), (void **)&aInstallVersion); if (NS_OK != result) { return result; }