From 16d9ea1ee3cdef718644e7b009697f1d60343a6b Mon Sep 17 00:00:00 2001 From: "disttsc%bart.nl" Date: Wed, 6 Sep 2000 20:39:29 +0000 Subject: [PATCH] Make nsXULElement inherit directly from nsXMLElement and remove dead internal code ((Get|Set)NameSpacePrefix from nsIXMLContent.h, nsIXULContent.h, nsXMLElement.h, nsGenericXMLElement.(h|cpp) and nsXULElement.(h|cpp). Hints & tips by jst (thanks!), r=jst, a=brendan. --- content/xml/content/public/nsIXMLContent.h | 4 +- content/xml/content/src/nsXMLElement.h | 7 +- content/xul/content/public/nsIXULContent.h | 5 +- content/xul/content/src/nsXULElement.cpp | 24 +--- content/xul/content/src/nsXULElement.h | 7 +- layout/xml/content/public/nsIXMLContent.h | 4 +- .../xml/content/src/nsGenericXMLElement.cpp | 21 +--- layout/xml/content/src/nsGenericXMLElement.h | 100 --------------- layout/xml/content/src/nsXMLElement.h | 7 +- rdf/content/public/nsIXULContent.h | 114 ------------------ rdf/content/src/nsXULElement.cpp | 24 +--- rdf/content/src/nsXULElement.h | 7 +- 12 files changed, 14 insertions(+), 310 deletions(-) diff --git a/content/xml/content/public/nsIXMLContent.h b/content/xml/content/public/nsIXMLContent.h index 47815a42e61..e5bf2cc6341 100644 --- a/content/xml/content/public/nsIXMLContent.h +++ b/content/xml/content/public/nsIXMLContent.h @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): + * Peter Annema */ #ifndef nsIXMLContent_h___ @@ -44,9 +45,6 @@ public: NS_IMETHOD SetContainingNameSpace(nsINameSpace* aNameSpace) = 0; NS_IMETHOD GetContainingNameSpace(nsINameSpace*& aNameSpace) const = 0; - NS_IMETHOD SetNameSpacePrefix(nsIAtom* aNameSpace) = 0; - NS_IMETHOD GetNameSpacePrefix(nsIAtom*& aNameSpace) const = 0; - /** * Give this element a change to fire its links that should be fired * automatically when loaded. If the element was an autoloading link diff --git a/content/xml/content/src/nsXMLElement.h b/content/xml/content/src/nsXMLElement.h index 71b1cc102a5..fd4fd161020 100644 --- a/content/xml/content/src/nsXMLElement.h +++ b/content/xml/content/src/nsXMLElement.h @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): + * Peter Annema */ #ifndef nsXMLElement_h___ @@ -213,12 +214,6 @@ public: NS_IMETHOD GetContainingNameSpace(nsINameSpace*& aNameSpace) const { return mInner.GetContainingNameSpace(aNameSpace); } - NS_IMETHOD SetNameSpacePrefix(nsIAtom* aNameSpace) { - return mInner.SetNameSpacePrefix(aNameSpace); - } - NS_IMETHOD GetNameSpacePrefix(nsIAtom*& aNameSpace) const { - return mInner.GetNameSpacePrefix(aNameSpace); - } NS_IMETHOD MaybeTriggerAutoLink(nsIWebShell *aShell); // nsIStyledContent diff --git a/content/xul/content/public/nsIXULContent.h b/content/xul/content/public/nsIXULContent.h index ccd46311625..970c65004b9 100644 --- a/content/xul/content/public/nsIXULContent.h +++ b/content/xul/content/public/nsIXULContent.h @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): + * Peter Annema */ /* @@ -29,7 +30,7 @@ #ifndef nsIXULContent_h__ #define nsIXULContent_h__ -#include "nsISupports.h" +#include "nsIXMLContent.h" class nsIAtom; class nsIRDFCompositeDataSource; class nsIXULTemplateBuilder; @@ -40,7 +41,7 @@ class nsString; { 0x39c5ecc0, 0x5c47, 0x11d3, { 0xbe, 0x36, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } } -class nsIXULContent : public nsISupports +class nsIXULContent : public nsIXMLContent { public: static const nsIID& GetIID() { static nsIID iid = NS_IXULCONTENT_IID; return iid; } diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 4feaf2e86d3..003426976f0 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -22,6 +22,7 @@ * * Contributor(s): * Pierre Phaneuf + * Peter Annema * * * This Original Code has been modified by IBM Corporation. @@ -91,7 +92,6 @@ #include "nsIStyledContent.h" #include "nsISupportsArray.h" #include "nsIURL.h" -#include "nsIXMLContent.h" #include "nsIXULContent.h" #include "nsIXULContentUtils.h" #include "nsIXULDocument.h" @@ -1605,28 +1605,6 @@ nsXULElement::GetContainingNameSpace(nsINameSpace*& aNameSpace) const return NS_OK; } -NS_IMETHODIMP -nsXULElement::SetNameSpacePrefix(nsIAtom* aNameSpacePrefix) -{ - nsresult rv; - - rv = EnsureSlots(); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr newNodeInfo; - mSlots->mNodeInfo->PrefixChanged(aNameSpacePrefix, - *getter_AddRefs(newNodeInfo)); - - mSlots->mNodeInfo = newNodeInfo; - return NS_OK; -} - -NS_IMETHODIMP -nsXULElement::GetNameSpacePrefix(nsIAtom*& aNameSpacePrefix) const -{ - return NodeInfo()->GetPrefixAtom(aNameSpacePrefix); -} - NS_IMETHODIMP nsXULElement::MaybeTriggerAutoLink(nsIWebShell *aShell) { diff --git a/content/xul/content/src/nsXULElement.h b/content/xul/content/src/nsXULElement.h index 04650b51d1e..7a4471f5c6c 100644 --- a/content/xul/content/src/nsXULElement.h +++ b/content/xul/content/src/nsXULElement.h @@ -21,6 +21,7 @@ * Chris Waterson * * Contributor(s): + * Peter Annema */ /* @@ -56,7 +57,6 @@ #include "nsIBindingManager.h" #include "nsIXBLBinding.h" #include "nsIURI.h" -#include "nsIXMLContent.h" #include "nsIXULContent.h" #include "nsIBoxObject.h" #include "nsXULAttributes.h" @@ -311,8 +311,7 @@ public: */ -class nsXULElement : public nsIXMLContent, - public nsIXULContent, +class nsXULElement : public nsIXULContent, public nsIDOMXULElement, public nsIDOMEventReceiver, public nsIScriptEventHandlerOwner, @@ -393,8 +392,6 @@ public: // nsIXMLContent NS_IMETHOD SetContainingNameSpace(nsINameSpace* aNameSpace); NS_IMETHOD GetContainingNameSpace(nsINameSpace*& aNameSpace) const; - NS_IMETHOD SetNameSpacePrefix(nsIAtom* aNameSpace); - NS_IMETHOD GetNameSpacePrefix(nsIAtom*& aNameSpace) const; NS_IMETHOD MaybeTriggerAutoLink(nsIWebShell *aShell); // nsIStyledContent diff --git a/layout/xml/content/public/nsIXMLContent.h b/layout/xml/content/public/nsIXMLContent.h index 47815a42e61..e5bf2cc6341 100644 --- a/layout/xml/content/public/nsIXMLContent.h +++ b/layout/xml/content/public/nsIXMLContent.h @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): + * Peter Annema */ #ifndef nsIXMLContent_h___ @@ -44,9 +45,6 @@ public: NS_IMETHOD SetContainingNameSpace(nsINameSpace* aNameSpace) = 0; NS_IMETHOD GetContainingNameSpace(nsINameSpace*& aNameSpace) const = 0; - NS_IMETHOD SetNameSpacePrefix(nsIAtom* aNameSpace) = 0; - NS_IMETHOD GetNameSpacePrefix(nsIAtom*& aNameSpace) const = 0; - /** * Give this element a change to fire its links that should be fired * automatically when loaded. If the element was an autoloading link diff --git a/layout/xml/content/src/nsGenericXMLElement.cpp b/layout/xml/content/src/nsGenericXMLElement.cpp index e308b751f34..ab65f40169d 100644 --- a/layout/xml/content/src/nsGenericXMLElement.cpp +++ b/layout/xml/content/src/nsGenericXMLElement.cpp @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): + * Peter Annema */ #include "nsGenericXMLElement.h" @@ -175,26 +176,6 @@ nsGenericXMLElement::GetScriptObject(nsIScriptContext* aContext, return res; } -nsresult -nsGenericXMLElement::SetNameSpacePrefix(nsIAtom* aNameSpacePrefix) -{ - nsINodeInfo *newNodeInfo; - - nsresult rv = mNodeInfo->PrefixChanged(aNameSpacePrefix, newNodeInfo); - NS_ENSURE_SUCCESS(rv, rv); - - NS_RELEASE(mNodeInfo); - mNodeInfo = newNodeInfo; - - return NS_OK; -} - -nsresult -nsGenericXMLElement::GetNameSpacePrefix(nsIAtom*& aNameSpacePrefix) const -{ - return mNodeInfo->GetPrefixAtom(aNameSpacePrefix); -} - nsresult nsGenericXMLElement::GetNameSpaceID(PRInt32& aNameSpaceID) const { diff --git a/layout/xml/content/src/nsGenericXMLElement.h b/layout/xml/content/src/nsGenericXMLElement.h index 302287cb6f2..e69de29bb2d 100644 --- a/layout/xml/content/src/nsGenericXMLElement.h +++ b/layout/xml/content/src/nsGenericXMLElement.h @@ -1,100 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ -#ifndef nsGenericXMLElement_h___ -#define nsGenericXMLElement_h___ - -#include "nsGenericElement.h" -#include "nsIDOMHTMLElement.h" -#include "nsIContent.h" -#include "nsVoidArray.h" -#include "nsIJSScriptObject.h" -#include "nsINameSpaceManager.h" // for kNameSpaceID_HTML -#include "nsINameSpace.h" - -class nsIWebShell; - -class nsGenericXMLElement : public nsGenericContainerElement { -public: - nsGenericXMLElement(); - ~nsGenericXMLElement(); - - nsresult CopyInnerTo(nsIContent* aSrcContent, - nsGenericXMLElement* aDest, - PRBool aDeep); - - nsresult GetNodeName(nsAWritableString& aNodeName); - nsresult GetLocalName(nsAWritableString& aLocalName); - - // Implementation for nsIDOMElement - nsresult GetAttribute(const nsAReadableString& aName, nsAWritableString& aReturn) - { - return nsGenericContainerElement::GetAttribute(aName, aReturn); - } - nsresult SetAttribute(const nsAReadableString& aName, const nsAReadableString& aValue) - { - return nsGenericContainerElement::SetAttribute(aName, aValue); - } - - // nsIContent - nsresult SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAReadableString& aValue, - PRBool aNotify) - { - return nsGenericContainerElement::SetAttribute(aNameSpaceID, aName, - aValue, aNotify); - } - nsresult SetAttribute(nsINodeInfo *aNodeInfo, - const nsAReadableString& aValue, - PRBool aNotify) - { - return nsGenericContainerElement::SetAttribute(aNodeInfo, aValue, aNotify); - } - nsresult GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, - nsAWritableString& aResult) const - { - return nsGenericContainerElement::GetAttribute(aNameSpaceID, aName, - aResult); - } - nsresult GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, - nsIAtom*& aPrefix, nsAWritableString& aResult) const - { - return nsGenericContainerElement::GetAttribute(aNameSpaceID, aName, - aPrefix, aResult); - } - - // nsIXMLContent - nsresult SetContainingNameSpace(nsINameSpace* aNameSpace); - nsresult GetContainingNameSpace(nsINameSpace*& aNameSpace) const; - - nsresult SetNameSpacePrefix(nsIAtom* aNameSpace); - nsresult GetNameSpacePrefix(nsIAtom*& aNameSpace) const; - nsresult GetNameSpaceID(PRInt32& aNameSpaceID) const; - nsresult MaybeTriggerAutoLink(nsIWebShell *aShell); - - // nsIScriptObjectOwner - nsresult GetScriptObject(nsIScriptContext* aContext, - void** aScriptObject); - - nsINameSpace* mNameSpace; -}; - -#endif /* nsGenericXMLElement_h__ */ diff --git a/layout/xml/content/src/nsXMLElement.h b/layout/xml/content/src/nsXMLElement.h index 71b1cc102a5..fd4fd161020 100644 --- a/layout/xml/content/src/nsXMLElement.h +++ b/layout/xml/content/src/nsXMLElement.h @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): + * Peter Annema */ #ifndef nsXMLElement_h___ @@ -213,12 +214,6 @@ public: NS_IMETHOD GetContainingNameSpace(nsINameSpace*& aNameSpace) const { return mInner.GetContainingNameSpace(aNameSpace); } - NS_IMETHOD SetNameSpacePrefix(nsIAtom* aNameSpace) { - return mInner.SetNameSpacePrefix(aNameSpace); - } - NS_IMETHOD GetNameSpacePrefix(nsIAtom*& aNameSpace) const { - return mInner.GetNameSpacePrefix(aNameSpace); - } NS_IMETHOD MaybeTriggerAutoLink(nsIWebShell *aShell); // nsIStyledContent diff --git a/rdf/content/public/nsIXULContent.h b/rdf/content/public/nsIXULContent.h index ccd46311625..e69de29bb2d 100644 --- a/rdf/content/public/nsIXULContent.h +++ b/rdf/content/public/nsIXULContent.h @@ -1,114 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -/* - - Private interface to XUL content. - -*/ - -#ifndef nsIXULContent_h__ -#define nsIXULContent_h__ - -#include "nsISupports.h" -class nsIAtom; -class nsIRDFCompositeDataSource; -class nsIXULTemplateBuilder; -class nsString; - -// {39C5ECC0-5C47-11d3-BE36-00104BDE6048} -#define NS_IXULCONTENT_IID \ -{ 0x39c5ecc0, 0x5c47, 0x11d3, { 0xbe, 0x36, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } } - - -class nsIXULContent : public nsISupports -{ -public: - static const nsIID& GetIID() { static nsIID iid = NS_IXULCONTENT_IID; return iid; } - - /** - * Peek at a XUL element's child count without forcing children to be - * instantiated. - */ - NS_IMETHOD PeekChildCount(PRInt32& aCount) const = 0; - - /** - * These flags are used to maintain bookkeeping information for partially- - * constructed content. - * - * eChildrenMustBeRebuilt - * The element's children are invalid or unconstructed, and should - * be reconstructed. - * - * eTemplateContentsBuilt - * Child content that is built from a XUL template has been - * constructed. - * - * eContainerContentsBuilt - * Child content that is built by following the ``containment'' - * property in a XUL template has been built. - */ - enum { - eChildrenMustBeRebuilt = 0x1, - eTemplateContentsBuilt = 0x2, - eContainerContentsBuilt = 0x4 - }; - - /** - * Set one or more ``lazy state'' flags. - * @aFlags a mask of flags to set - */ - NS_IMETHOD SetLazyState(PRInt32 aFlags) = 0; - - /** - * Clear one or more ``lazy state'' flags. - * @aFlags a mask of flags to clear - */ - NS_IMETHOD ClearLazyState(PRInt32 aFlags) = 0; - - /** - * Get the value of a single ``lazy state'' flag. - * @aFlag a flag to test - * @aResult the result - */ - NS_IMETHOD GetLazyState(PRInt32 aFlag, PRBool& aResult) = 0; - - /** - * Add a script event listener to the element. - */ - NS_IMETHOD AddScriptEventListener(nsIAtom* aName, const nsAReadableString& aValue, REFNSIID aIID) = 0; - - /** - * Evil rotten hack to make mailnews work. They assume that we - * keep a reference to their resource objects. If you think you - * should call this method, think again. You shouldn't. - */ - NS_IMETHOD ForceElementToOwnResource(PRBool aForce) = 0; - - /** - * Initialize the root element in a XUL template - */ - NS_IMETHOD InitTemplateRoot(nsIRDFCompositeDataSource* aDatabase, - nsIXULTemplateBuilder* aBuilder) = 0; -}; - -#endif // nsIXULContent_h__ diff --git a/rdf/content/src/nsXULElement.cpp b/rdf/content/src/nsXULElement.cpp index 4feaf2e86d3..003426976f0 100644 --- a/rdf/content/src/nsXULElement.cpp +++ b/rdf/content/src/nsXULElement.cpp @@ -22,6 +22,7 @@ * * Contributor(s): * Pierre Phaneuf + * Peter Annema * * * This Original Code has been modified by IBM Corporation. @@ -91,7 +92,6 @@ #include "nsIStyledContent.h" #include "nsISupportsArray.h" #include "nsIURL.h" -#include "nsIXMLContent.h" #include "nsIXULContent.h" #include "nsIXULContentUtils.h" #include "nsIXULDocument.h" @@ -1605,28 +1605,6 @@ nsXULElement::GetContainingNameSpace(nsINameSpace*& aNameSpace) const return NS_OK; } -NS_IMETHODIMP -nsXULElement::SetNameSpacePrefix(nsIAtom* aNameSpacePrefix) -{ - nsresult rv; - - rv = EnsureSlots(); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr newNodeInfo; - mSlots->mNodeInfo->PrefixChanged(aNameSpacePrefix, - *getter_AddRefs(newNodeInfo)); - - mSlots->mNodeInfo = newNodeInfo; - return NS_OK; -} - -NS_IMETHODIMP -nsXULElement::GetNameSpacePrefix(nsIAtom*& aNameSpacePrefix) const -{ - return NodeInfo()->GetPrefixAtom(aNameSpacePrefix); -} - NS_IMETHODIMP nsXULElement::MaybeTriggerAutoLink(nsIWebShell *aShell) { diff --git a/rdf/content/src/nsXULElement.h b/rdf/content/src/nsXULElement.h index 04650b51d1e..7a4471f5c6c 100644 --- a/rdf/content/src/nsXULElement.h +++ b/rdf/content/src/nsXULElement.h @@ -21,6 +21,7 @@ * Chris Waterson * * Contributor(s): + * Peter Annema */ /* @@ -56,7 +57,6 @@ #include "nsIBindingManager.h" #include "nsIXBLBinding.h" #include "nsIURI.h" -#include "nsIXMLContent.h" #include "nsIXULContent.h" #include "nsIBoxObject.h" #include "nsXULAttributes.h" @@ -311,8 +311,7 @@ public: */ -class nsXULElement : public nsIXMLContent, - public nsIXULContent, +class nsXULElement : public nsIXULContent, public nsIDOMXULElement, public nsIDOMEventReceiver, public nsIScriptEventHandlerOwner, @@ -393,8 +392,6 @@ public: // nsIXMLContent NS_IMETHOD SetContainingNameSpace(nsINameSpace* aNameSpace); NS_IMETHOD GetContainingNameSpace(nsINameSpace*& aNameSpace) const; - NS_IMETHOD SetNameSpacePrefix(nsIAtom* aNameSpace); - NS_IMETHOD GetNameSpacePrefix(nsIAtom*& aNameSpace) const; NS_IMETHOD MaybeTriggerAutoLink(nsIWebShell *aShell); // nsIStyledContent