mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Added XML display support. Split nsGenericHTMLElement into generic and HTML-specific components. Minor style modification. New XML classes and interfaces.
This commit is contained in:
parent
c11e2c8964
commit
8723f8326b
@ -36,6 +36,7 @@ class nsVoidArray;
|
||||
class nsXIFConverter;
|
||||
class nsIDOMEvent;
|
||||
class nsIContent;
|
||||
class nsISupportsArray;
|
||||
|
||||
// IID for the nsIContent interface
|
||||
#define NS_ICONTENT_IID \
|
||||
@ -118,6 +119,40 @@ public:
|
||||
*/
|
||||
NS_IMETHOD GetAttribute(const nsString& aName, nsString& aResult) const = 0;
|
||||
|
||||
/**
|
||||
* Remove an attribute so that it is no longer explicitly specified.
|
||||
*
|
||||
* @param aAttribute the name of the attribute to unset
|
||||
*
|
||||
* @param aNotify specifies whether or not the document should be
|
||||
* notified of the attribute change
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of all specified attribute. The returned array
|
||||
* contains nsIAtom's representing the attribute names.
|
||||
*
|
||||
* @param aArray an array to be filled in with attribute names
|
||||
*
|
||||
* @param aCountResult an out parameter to be filled in with
|
||||
* the number of attributes
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray,
|
||||
PRInt32& aCountResult) const = 0;
|
||||
|
||||
/**
|
||||
* Get the number of all specified attributes.
|
||||
*
|
||||
* @param aCountResult an out parameter to be filled in with
|
||||
* the number of attributes
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aCountResult) const = 0;
|
||||
|
||||
/**
|
||||
* List the content (and anything it contains) out to the given
|
||||
* file stream. Use aIndent as the base indent during formatting.
|
||||
|
@ -240,6 +240,9 @@ public:
|
||||
extern NS_LAYOUT nsresult
|
||||
NS_NewHTMLDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
extern NS_LAYOUT nsresult
|
||||
NS_NewXMLDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
extern NS_LAYOUT nsresult
|
||||
NS_NewImageDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
|
@ -275,6 +275,34 @@ nsIArena* nsDocument::GetArena()
|
||||
return mArena;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::StartDocumentLoad(nsIURL *aURL,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener)
|
||||
{
|
||||
// Delete references to style sheets - this should be done in superclass...
|
||||
PRInt32 index = mStyleSheets.Count();
|
||||
while (--index >= 0) {
|
||||
nsIStyleSheet* sheet = (nsIStyleSheet*) mStyleSheets.ElementAt(index);
|
||||
NS_RELEASE(sheet);
|
||||
}
|
||||
mStyleSheets.Clear();
|
||||
|
||||
NS_IF_RELEASE(mDocumentURL);
|
||||
NS_IF_RELEASE(mDocumentURLGroup);
|
||||
if (nsnull != mDocumentTitle) {
|
||||
delete mDocumentTitle;
|
||||
mDocumentTitle = nsnull;
|
||||
}
|
||||
|
||||
mDocumentURL = aURL;
|
||||
NS_ADDREF(aURL);
|
||||
|
||||
mDocumentURLGroup = aURL->GetURLGroup();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const nsString* nsDocument::GetDocumentTitle() const
|
||||
{
|
||||
return mDocumentTitle;
|
||||
|
@ -58,6 +58,10 @@ public:
|
||||
|
||||
virtual nsIArena* GetArena();
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(nsIURL *aUrl,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener);
|
||||
|
||||
/**
|
||||
* Return the title of the document. May return null.
|
||||
*/
|
||||
|
@ -27,6 +27,12 @@
|
||||
#include "nsIContent.h"
|
||||
#include "nsIStyleFrameConstruction.h"
|
||||
|
||||
// XXX Temporary fix to make sure that ua.css only gets applied
|
||||
// to HTML content. When this removed, remember to get rid of
|
||||
// the include dependency in the makefile.
|
||||
#include "nsIHTMLContent.h"
|
||||
static NS_DEFINE_IID(kIHTMLContentIID, NS_IHTMLCONTENT_IID);
|
||||
|
||||
static NS_DEFINE_IID(kIStyleSetIID, NS_ISTYLE_SET_IID);
|
||||
static NS_DEFINE_IID(kIStyleFrameConstructionIID, NS_ISTYLE_FRAME_CONSTRUCTION_IID);
|
||||
|
||||
@ -477,7 +483,13 @@ nsIStyleContext* StyleSetImpl::ResolveStyleFor(nsIPresContext* aPresContext,
|
||||
}
|
||||
|
||||
if (nsnull != rules) {
|
||||
PRInt32 ruleCount = RulesMatching(mBackstopSheets, aPresContext, aContent, aParentContext, rules);
|
||||
nsIHTMLContent *htmlContent;
|
||||
nsresult rv = aContent->QueryInterface(kIHTMLContentIID, (void **)&htmlContent);
|
||||
PRInt32 ruleCount = 0;
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
ruleCount += RulesMatching(mBackstopSheets, aPresContext, aContent, aParentContext, rules);
|
||||
NS_RELEASE(htmlContent);
|
||||
}
|
||||
PRInt32 backstopRules = ruleCount;
|
||||
ruleCount += RulesMatching(mDocSheets, aPresContext, aContent, aParentContext, rules);
|
||||
ruleCount += RulesMatching(mOverrideSheets, aPresContext, aContent, aParentContext, rules);
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "nsHTMLValue.h"
|
||||
class nsString;
|
||||
class nsIFrame;
|
||||
class nsISupportsArray;
|
||||
class nsIStyleRule;
|
||||
class nsIStyleContext;
|
||||
class nsIPresContext;
|
||||
@ -55,17 +54,12 @@ public:
|
||||
const nsHTMLValue& aValue,
|
||||
PRBool aNotify) = 0;
|
||||
|
||||
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify) = 0;
|
||||
|
||||
NS_IMETHOD GetAttribute(const nsString& aName,
|
||||
NS_IMETHOD GetAttribute(const nsString& aName,
|
||||
nsString& aResult) const = 0;
|
||||
NS_IMETHOD GetAttribute(nsIAtom *aAttribute,
|
||||
nsString &aResult) const = 0;
|
||||
NS_IMETHOD GetAttribute(nsIAtom* aAttribute,
|
||||
nsHTMLValue& aValue) const = 0;
|
||||
NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray,
|
||||
PRInt32& aCountResult) const = 0;
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aCountResult) const = 0;
|
||||
NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const = 0;
|
||||
|
||||
NS_IMETHOD SetID(nsIAtom* aID) = 0;
|
||||
|
@ -28,6 +28,7 @@ LIBRARY_NAME = nglhtmlcon_s
|
||||
CPPSRCS= \
|
||||
nsCommentNode.cpp \
|
||||
nsGenericDOMDataNode.cpp \
|
||||
nsGenericElement.cpp \
|
||||
nsGenericHTMLElement.cpp \
|
||||
nsHTMLAnchorElement.cpp \
|
||||
nsHTMLAppletElement.cpp \
|
||||
|
@ -25,6 +25,7 @@ DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
CPPSRCS= \
|
||||
nsCommentNode.cpp \
|
||||
nsGenericDOMDataNode.cpp \
|
||||
nsGenericElement.cpp \
|
||||
nsGenericHTMLElement.cpp \
|
||||
nsHTMLAnchorElement.cpp \
|
||||
nsHTMLAppletElement.cpp \
|
||||
@ -92,6 +93,7 @@ CPPSRCS= \
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsCommentNode.obj \
|
||||
.\$(OBJDIR)\nsGenericDOMDataNode.obj \
|
||||
.\$(OBJDIR)\nsGenericElement.obj \
|
||||
.\$(OBJDIR)\nsGenericHTMLElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLAnchorElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLAppletElement.obj \
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,20 +19,14 @@
|
||||
#ifndef nsGenericHTMLElement_h___
|
||||
#define nsGenericHTMLElement_h___
|
||||
|
||||
#include "nsGenericElement.h"
|
||||
#include "nsIDOMHTMLElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsHTMLValue.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
|
||||
extern const nsIID kIDOMNodeIID;
|
||||
extern const nsIID kIDOMElementIID;
|
||||
extern const nsIID kIDOMHTMLElementIID;
|
||||
extern const nsIID kIDOMEventReceiverIID;
|
||||
extern const nsIID kIScriptObjectOwnerIID;
|
||||
extern const nsIID kIJSScriptObjectIID;
|
||||
extern const nsIID kISupportsIID;
|
||||
extern const nsIID kIContentIID;
|
||||
extern const nsIID kIHTMLContentIID;
|
||||
|
||||
class nsIDOMAttr;
|
||||
@ -50,49 +44,11 @@ class nsChildContentList;
|
||||
class nsDOMCSSDeclaration;
|
||||
class nsIDOMCSSStyleDeclaration;
|
||||
|
||||
// There are a set of DOM- and scripting-specific instance variables
|
||||
// that may only be instantiated when a content object is accessed
|
||||
// through the DOM. Rather than burn actual slots in the content
|
||||
// objects for each of these instance variables, we put them off
|
||||
// in a side structure that's only allocated when the content is
|
||||
// accessed through the DOM.
|
||||
typedef struct {
|
||||
void *mScriptObject;
|
||||
nsChildContentList *mChildNodes;
|
||||
nsDOMCSSDeclaration *mStyle;
|
||||
} nsDOMSlots;
|
||||
|
||||
class nsGenericHTMLElement : public nsIJSScriptObject {
|
||||
class nsGenericHTMLElement : public nsGenericElement {
|
||||
public:
|
||||
nsGenericHTMLElement();
|
||||
~nsGenericHTMLElement();
|
||||
|
||||
void Init(nsIHTMLContent* aOuterContentObject, nsIAtom* aTag);
|
||||
|
||||
// Implementation for nsIDOMNode
|
||||
nsresult GetNodeName(nsString& aNodeName);
|
||||
nsresult GetNodeValue(nsString& aNodeValue);
|
||||
nsresult SetNodeValue(const nsString& aNodeValue);
|
||||
nsresult GetNodeType(PRUint16* aNodeType);
|
||||
nsresult GetParentNode(nsIDOMNode** aParentNode);
|
||||
nsresult GetAttributes(nsIDOMNamedNodeMap** aAttributes);
|
||||
nsresult GetPreviousSibling(nsIDOMNode** aPreviousSibling);
|
||||
nsresult GetNextSibling(nsIDOMNode** aNextSibling);
|
||||
nsresult GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
|
||||
|
||||
// Implementation for nsIDOMElement
|
||||
nsresult GetTagName(nsString& aTagName);
|
||||
nsresult GetDOMAttribute(const nsString& aName, nsString& aReturn);
|
||||
nsresult SetDOMAttribute(const nsString& aName, const nsString& aValue);
|
||||
nsresult RemoveAttribute(const nsString& aName);
|
||||
nsresult GetAttributeNode(const nsString& aName,
|
||||
nsIDOMAttr** aReturn);
|
||||
nsresult SetAttributeNode(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn);
|
||||
nsresult RemoveAttributeNode(nsIDOMAttr* aOldAttr, nsIDOMAttr** aReturn);
|
||||
nsresult GetElementsByTagName(const nsString& aTagname,
|
||||
nsIDOMNodeList** aReturn);
|
||||
nsresult Normalize();
|
||||
|
||||
// Implementation for nsIDOMHTMLElement
|
||||
nsresult GetId(nsString& aId);
|
||||
nsresult SetId(const nsString& aId);
|
||||
@ -106,36 +62,16 @@ public:
|
||||
nsresult SetClassName(const nsString& aClassName);
|
||||
nsresult GetStyle(nsIDOMCSSStyleDeclaration** aStyle);
|
||||
|
||||
// nsIDOMEventReceiver interface
|
||||
nsresult AddEventListener(nsIDOMEventListener *aListener, const nsIID& aIID);
|
||||
nsresult RemoveEventListener(nsIDOMEventListener* aListener,
|
||||
const nsIID& aIID);
|
||||
nsresult GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
nsresult GetNewListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
|
||||
// nsIScriptObjectOwner interface
|
||||
nsresult GetScriptObject(nsIScriptContext* aContext, void** aScriptObject);
|
||||
nsresult SetScriptObject(void *aScriptObject);
|
||||
|
||||
// Implementation for nsIContent
|
||||
nsresult GetDocument(nsIDocument*& aResult) const;
|
||||
nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep);
|
||||
nsresult GetParent(nsIContent*& aResult) const;
|
||||
nsresult SetParent(nsIContent* aParent);
|
||||
nsresult IsSynthetic(PRBool& aResult) {
|
||||
aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult GetTag(nsIAtom*& aResult) const;
|
||||
nsresult SetAttribute(const nsString& aName, const nsString& aValue,
|
||||
PRBool aNotify);
|
||||
nsresult GetAttribute(const nsString& aName, nsString& aResult) const;
|
||||
nsresult UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify);
|
||||
nsresult GetAllAttributeNames(nsISupportsArray* aArray,
|
||||
PRInt32& aCount) const;
|
||||
nsresult GetAttributeCount(PRInt32& aResult) const;
|
||||
nsresult List(FILE* out, PRInt32 aIndent) const;
|
||||
nsresult HandleDOMEvent(nsIPresContext& aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus& aEventStatus);
|
||||
|
||||
// Implementation for nsIHTMLContent
|
||||
nsresult Compact();
|
||||
@ -143,12 +79,8 @@ public:
|
||||
PRBool aNotify);
|
||||
nsresult SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue,
|
||||
PRBool aNotify);
|
||||
nsresult UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify);
|
||||
nsresult GetAttribute(nsIAtom *aAttribute, nsString &aResult) const;
|
||||
nsresult GetAttribute(nsIAtom* aAttribute, nsHTMLValue& aValue) const;
|
||||
nsresult GetAllAttributeNames(nsISupportsArray* aArray,
|
||||
PRInt32& aCount) const;
|
||||
nsresult GetAttributeCount(PRInt32& aResult) const;
|
||||
nsresult SetID(nsIAtom* aID);
|
||||
nsresult GetID(nsIAtom*& aResult) const;
|
||||
nsresult SetClass(nsIAtom* aClass);
|
||||
@ -157,41 +89,13 @@ public:
|
||||
nsresult ToHTMLString(nsString& aResult) const;
|
||||
nsresult ToHTML(FILE* out) const;
|
||||
|
||||
// Implementation for nsIJSScriptObject
|
||||
virtual PRBool AddProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
virtual PRBool DeleteProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
virtual PRBool GetProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
virtual PRBool SetProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
virtual PRBool EnumerateProperty(JSContext *aContext);
|
||||
virtual PRBool Resolve(JSContext *aContext, jsval aID);
|
||||
virtual PRBool Convert(JSContext *aContext, jsval aID);
|
||||
virtual void Finalize(JSContext *aContext);
|
||||
|
||||
// Implementation for nsISupports
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID,
|
||||
void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
nsresult RenderFrame();
|
||||
|
||||
nsresult AddScriptEventListener(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
REFNSIID aIID);
|
||||
|
||||
nsresult AttributeToString(nsIAtom* aAttribute,
|
||||
nsHTMLValue& aValue,
|
||||
nsString& aResult) const;
|
||||
|
||||
void ListAttributes(FILE* out) const;
|
||||
|
||||
void TriggerLink(nsIPresContext& aPresContext,
|
||||
const nsString& aBase,
|
||||
const nsString& aURLSpec,
|
||||
const nsString& aTargetSpec,
|
||||
PRBool aClick);
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
@ -308,24 +212,7 @@ public:
|
||||
const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
|
||||
static nsresult GetScriptObjectFactory(nsIDOMScriptObjectFactory **aFactory);
|
||||
|
||||
static nsIDOMScriptObjectFactory *gScriptObjectFactory;
|
||||
|
||||
nsDOMSlots *GetDOMSlots();
|
||||
|
||||
// Up pointer to the real content object that we are
|
||||
// supporting. Sometimes there is work that we just can't do
|
||||
// ourselves, so this is needed to ask the real object to do the
|
||||
// work.
|
||||
nsIHTMLContent* mContent;
|
||||
|
||||
nsIDocument* mDocument;
|
||||
nsIContent* mParent;
|
||||
nsIHTMLAttributes* mAttributes;
|
||||
nsIAtom* mTag;
|
||||
nsIEventListenerManager* mListenerManager;
|
||||
nsDOMSlots *mDOMSlots;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -335,7 +222,7 @@ public:
|
||||
nsGenericHTMLLeafElement();
|
||||
~nsGenericHTMLLeafElement();
|
||||
|
||||
nsresult CopyInnerTo(nsIHTMLContent* aSrcContent,
|
||||
nsresult CopyInnerTo(nsIContent* aSrcContent,
|
||||
nsGenericHTMLLeafElement* aDest);
|
||||
|
||||
// Remainder of nsIDOMHTMLElement (and nsIDOMNode)
|
||||
@ -368,13 +255,13 @@ public:
|
||||
}
|
||||
|
||||
// Remainder of nsIHTMLContent (and nsIContent)
|
||||
nsresult SizeOf(nsISizeOfHandler* aHandler) const;
|
||||
nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult ConvertContentToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult FinishConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult Compact() {
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult SizeOf(nsISizeOfHandler* aHandler) const;
|
||||
nsresult CanContainChildren(PRBool& aResult) const {
|
||||
aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
@ -412,7 +299,7 @@ public:
|
||||
nsGenericHTMLContainerElement();
|
||||
~nsGenericHTMLContainerElement();
|
||||
|
||||
nsresult CopyInnerTo(nsIHTMLContent* aSrcContent,
|
||||
nsresult CopyInnerTo(nsIContent* aSrcContent,
|
||||
nsGenericHTMLContainerElement* aDest);
|
||||
|
||||
// Remainder of nsIDOMHTMLElement (and nsIDOMNode)
|
||||
@ -420,6 +307,7 @@ public:
|
||||
nsresult HasChildNodes(PRBool* aHasChildNodes);
|
||||
nsresult GetFirstChild(nsIDOMNode** aFirstChild);
|
||||
nsresult GetLastChild(nsIDOMNode** aLastChild);
|
||||
|
||||
nsresult InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn);
|
||||
nsresult ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
||||
@ -428,11 +316,11 @@ public:
|
||||
nsresult AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn);
|
||||
|
||||
// Remainder of nsIHTMLContent (and nsIContent)
|
||||
nsresult SizeOf(nsISizeOfHandler* aHandler) const;
|
||||
nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult ConvertContentToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult FinishConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult Compact();
|
||||
nsresult SizeOf(nsISizeOfHandler* aHandler) const;
|
||||
nsresult CanContainChildren(PRBool& aResult) const;
|
||||
nsresult ChildCount(PRInt32& aResult) const;
|
||||
nsresult ChildAt(PRInt32 aIndex, nsIContent*& aResult) const;
|
||||
@ -447,106 +335,6 @@ public:
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Mostly implement the nsIDOMNode API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
* nsGenericHTMLContainerContent)
|
||||
*
|
||||
* Note that classes using this macro will need to implement:
|
||||
* NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
*/
|
||||
#define NS_IMPL_IDOMNODE_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetNodeName(nsString& aNodeName) { \
|
||||
return _g.GetNodeName(aNodeName); \
|
||||
} \
|
||||
NS_IMETHOD GetNodeValue(nsString& aNodeValue) { \
|
||||
return _g.GetNodeValue(aNodeValue); \
|
||||
} \
|
||||
NS_IMETHOD SetNodeValue(const nsString& aNodeValue) { \
|
||||
return _g.SetNodeValue(aNodeValue); \
|
||||
} \
|
||||
NS_IMETHOD GetNodeType(PRUint16* aNodeType) { \
|
||||
return _g.GetNodeType(aNodeType); \
|
||||
} \
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode) { \
|
||||
return _g.GetParentNode(aParentNode); \
|
||||
} \
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes) { \
|
||||
return _g.GetChildNodes(aChildNodes); \
|
||||
} \
|
||||
NS_IMETHOD HasChildNodes(PRBool* aHasChildNodes) { \
|
||||
return _g.HasChildNodes(aHasChildNodes); \
|
||||
} \
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild) { \
|
||||
return _g.GetFirstChild(aFirstChild); \
|
||||
} \
|
||||
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild) { \
|
||||
return _g.GetLastChild(aLastChild); \
|
||||
} \
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling) { \
|
||||
return _g.GetPreviousSibling(aPreviousSibling); \
|
||||
} \
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling) { \
|
||||
return _g.GetNextSibling(aNextSibling); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes) { \
|
||||
return _g.GetAttributes(aAttributes); \
|
||||
} \
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, \
|
||||
nsIDOMNode** aReturn) { \
|
||||
return _g.InsertBefore(aNewChild, aRefChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD AppendChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \
|
||||
return _g.AppendChild(aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, \
|
||||
nsIDOMNode** aReturn) { \
|
||||
return _g.ReplaceChild(aNewChild, aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \
|
||||
return _g.RemoveChild(aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument) { \
|
||||
return _g.GetOwnerDocument(aOwnerDocument); \
|
||||
} \
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
|
||||
/**
|
||||
* Implement the nsIDOMElement API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
* nsGenericHTMLContainerContent)
|
||||
*/
|
||||
#define NS_IMPL_IDOMELEMENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetTagName(nsString& aTagName) { \
|
||||
return _g.GetTagName(aTagName); \
|
||||
} \
|
||||
NS_IMETHOD GetDOMAttribute(const nsString& aName, nsString& aReturn) { \
|
||||
return _g.GetDOMAttribute(aName, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD SetDOMAttribute(const nsString& aName, const nsString& aValue) { \
|
||||
return _g.SetDOMAttribute(aName, aValue); \
|
||||
} \
|
||||
NS_IMETHOD RemoveAttribute(const nsString& aName) { \
|
||||
return _g.RemoveAttribute(aName); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeNode(const nsString& aName, \
|
||||
nsIDOMAttr** aReturn) { \
|
||||
return _g.GetAttributeNode(aName, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD SetAttributeNode(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn) { \
|
||||
return _g.SetAttributeNode(aNewAttr, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD RemoveAttributeNode(nsIDOMAttr* aOldAttr, nsIDOMAttr** aReturn) {\
|
||||
return _g.RemoveAttributeNode(aOldAttr, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD GetElementsByTagName(const nsString& aTagname, \
|
||||
nsIDOMNodeList** aReturn) { \
|
||||
return _g.GetElementsByTagName(aTagname, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD Normalize() { \
|
||||
return _g.Normalize(); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement the nsIDOMHTMLElement API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
@ -587,27 +375,6 @@ public:
|
||||
return _g.GetStyle(aStyle); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement the nsIDOMEventReceiver API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
* nsGenericHTMLContainerContent)
|
||||
*/
|
||||
#define NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(_g) \
|
||||
NS_IMETHOD AddEventListener(nsIDOMEventListener *aListener, \
|
||||
const nsIID& aIID) { \
|
||||
return _g.AddEventListener(aListener, aIID); \
|
||||
} \
|
||||
NS_IMETHOD RemoveEventListener(nsIDOMEventListener *aListener, \
|
||||
const nsIID& aIID) { \
|
||||
return _g.RemoveEventListener(aListener, aIID); \
|
||||
} \
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aResult) { \
|
||||
return _g.GetListenerManager(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetNewListenerManager(nsIEventListenerManager** aResult) { \
|
||||
return _g.GetNewListenerManager(aResult); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement the nsIScriptObjectOwner API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
@ -622,79 +389,6 @@ public:
|
||||
return _g.SetScriptObject(aScriptObject); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_ICONTENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \
|
||||
return _g.GetDocument(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { \
|
||||
return _g.SetDocument(aDocument, aDeep); \
|
||||
} \
|
||||
NS_IMETHOD GetParent(nsIContent*& aResult) const { \
|
||||
return _g.GetParent(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetParent(nsIContent* aParent) { \
|
||||
return _g.SetParent(aParent); \
|
||||
} \
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const { \
|
||||
return _g.CanContainChildren(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const { \
|
||||
return _g.ChildCount(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const { \
|
||||
return _g.ChildAt(aIndex, aResult); \
|
||||
} \
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const { \
|
||||
return _g.IndexOf(aPossibleChild, aResult); \
|
||||
} \
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, \
|
||||
PRBool aNotify) { \
|
||||
return _g.InsertChildAt(aKid, aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, \
|
||||
PRBool aNotify) { \
|
||||
return _g.ReplaceChildAt(aKid, aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) { \
|
||||
return _g.AppendChildTo(aKid, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { \
|
||||
return _g.RemoveChildAt(aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD IsSynthetic(PRBool& aResult) { \
|
||||
return _g.IsSynthetic(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const { \
|
||||
return _g.GetTag(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetAttribute(const nsString& aName, const nsString& aValue, \
|
||||
PRBool aNotify) { \
|
||||
return _g.SetAttribute(aName, aValue, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetAttribute(const nsString& aName, \
|
||||
nsString& aResult) const { \
|
||||
return _g.GetAttribute(aName, aResult); \
|
||||
} \
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const { \
|
||||
return _g.List(out, aIndent); \
|
||||
} \
|
||||
NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.BeginConvertToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.ConvertContentToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.FinishConvertToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const { \
|
||||
return _g.SizeOf(aHandler); \
|
||||
} \
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext, \
|
||||
nsEvent* aEvent, \
|
||||
nsIDOMEvent** aDOMEvent, \
|
||||
PRUint32 aFlags, \
|
||||
nsEventStatus& aEventStatus);
|
||||
|
||||
#define NS_IMPL_IHTMLCONTENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD Compact() { \
|
||||
@ -708,9 +402,6 @@ public:
|
||||
const nsHTMLValue& aValue, PRBool aNotify) { \
|
||||
return _g.SetAttribute(aAttribute, aValue, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify) { \
|
||||
return _g.UnsetAttribute(aAttribute, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetAttribute(nsIAtom *aAttribute, \
|
||||
nsString &aResult) const { \
|
||||
return _g.GetAttribute(aAttribute, aResult); \
|
||||
@ -719,13 +410,6 @@ public:
|
||||
nsHTMLValue& aValue) const { \
|
||||
return _g.GetAttribute(aAttribute, aValue); \
|
||||
} \
|
||||
NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, \
|
||||
PRInt32& aResult) const { \
|
||||
return _g.GetAllAttributeNames(aArray, aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { \
|
||||
return _g.GetAttributeCount(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetID(nsIAtom* aID) { \
|
||||
return _g.SetID(aID); \
|
||||
} \
|
||||
@ -767,9 +451,6 @@ public:
|
||||
const nsHTMLValue& aValue, PRBool aNotify) { \
|
||||
return _g.SetAttribute(aAttribute, aValue, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify) { \
|
||||
return _g.UnsetAttribute(aAttribute, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetAttribute(nsIAtom *aAttribute, \
|
||||
nsString &aResult) const { \
|
||||
return _g.GetAttribute(aAttribute, aResult); \
|
||||
@ -778,13 +459,6 @@ public:
|
||||
nsHTMLValue& aValue) const { \
|
||||
return _g.GetAttribute(aAttribute, aValue); \
|
||||
} \
|
||||
NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, \
|
||||
PRInt32& aResult) const { \
|
||||
return _g.GetAllAttributeNames(aArray, aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { \
|
||||
return _g.GetAttributeCount(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetID(nsIAtom* aID) { \
|
||||
return _g.SetID(aID); \
|
||||
} \
|
||||
@ -817,61 +491,19 @@ public:
|
||||
* generic to all html content objects.
|
||||
*/
|
||||
#define NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(_id, _iptr, _this) \
|
||||
if (_id.Equals(kISupportsIID)) { \
|
||||
nsIHTMLContent* tmp = _this; \
|
||||
nsISupports* tmp2 = tmp; \
|
||||
*_iptr = (void*) tmp2; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIDOMNodeIID)) { \
|
||||
nsIDOMNode* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIDOMElementIID)) { \
|
||||
nsIDOMElement* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMPL_CONTENT_QUERY_INTERFACE(_id, _iptr, _this, nsIHTMLContent) \
|
||||
if (_id.Equals(kIDOMHTMLElementIID)) { \
|
||||
nsIDOMHTMLElement* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIDOMEventReceiverIID)) { \
|
||||
nsIDOMEventReceiver* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIScriptObjectOwnerIID)) { \
|
||||
nsIScriptObjectOwner* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIContentIID)) { \
|
||||
nsIContent* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIHTMLContentIID)) { \
|
||||
nsIHTMLContent* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIJSScriptObjectIID)) { \
|
||||
nsIJSScriptObject* tmp = (nsIJSScriptObject*)&mInner; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given string
|
||||
|
@ -165,6 +165,7 @@ public:
|
||||
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
|
||||
NS_IMETHOD NotifyError(nsresult aErrorResult);
|
||||
NS_IMETHOD AddComment(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
|
||||
|
||||
@ -2393,3 +2394,12 @@ HTMLContentSink::LoadStyleSheet(nsIURL* aURL,
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLContentSink::NotifyError(nsresult aErrorResult)
|
||||
{
|
||||
// Errors in HTML? Who would have thought!
|
||||
// Why are you telling us, parser. Deal with it yourself.
|
||||
PR_ASSERT(0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -428,30 +428,16 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIWebShell* webShell;
|
||||
|
||||
// Delete references to style sheets - this should be done in superclass...
|
||||
PRInt32 index = mStyleSheets.Count();
|
||||
while (--index >= 0) {
|
||||
nsIStyleSheet* sheet = (nsIStyleSheet*) mStyleSheets.ElementAt(index);
|
||||
NS_RELEASE(sheet);
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aURL, aContainer,
|
||||
aDocListener);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mStyleSheets.Clear();
|
||||
|
||||
nsIWebShell* webShell;
|
||||
|
||||
NS_IF_RELEASE(mAttrStyleSheet);
|
||||
NS_IF_RELEASE(mStyleAttrStyleSheet);
|
||||
NS_IF_RELEASE(mDocumentURL);
|
||||
NS_IF_RELEASE(mDocumentURLGroup);
|
||||
if (nsnull != mDocumentTitle) {
|
||||
delete mDocumentTitle;
|
||||
mDocumentTitle = nsnull;
|
||||
}
|
||||
|
||||
mDocumentURL = aURL;
|
||||
NS_ADDREF(aURL);
|
||||
|
||||
mDocumentURLGroup = aURL->GetURLGroup();
|
||||
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsTableOuterFrame.h"
|
||||
#include "nsIXMLDocument.h"
|
||||
#include "nsIWebShell.h"
|
||||
|
||||
static NS_DEFINE_IID(kIHTMLStyleSheetIID, NS_IHTML_STYLE_SHEET_IID);
|
||||
@ -48,6 +49,7 @@ static NS_DEFINE_IID(kIStyleSheetIID, NS_ISTYLE_SHEET_IID);
|
||||
static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID);
|
||||
static NS_DEFINE_IID(kIStyleFrameConstructionIID, NS_ISTYLE_FRAME_CONSTRUCTION_IID);
|
||||
static NS_DEFINE_IID(kIHTMLTableCellElementIID, NS_IHTMLTABLECELLELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIXMLDocumentIID, NS_IXMLDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
||||
|
||||
class HTMLAnchorRule : public nsIStyleRule {
|
||||
@ -298,6 +300,11 @@ protected:
|
||||
nsIStyleContext* aStyleContext,
|
||||
nsIFrame*& aNewFrame);
|
||||
|
||||
nsresult ConstructXMLRootFrames(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIStyleContext* aStyleContext,
|
||||
nsIFrame*& aNewFrame);
|
||||
|
||||
nsresult ConstructTableFrame(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIFrame* aParentFrame,
|
||||
@ -1119,6 +1126,66 @@ HTMLStyleSheetImpl::ConstructRootFrame(nsIPresContext* aPresContext,
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
HTMLStyleSheetImpl::ConstructXMLRootFrames(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIStyleContext* aStyleContext,
|
||||
nsIFrame*& aNewFrame)
|
||||
{
|
||||
// Create the root frame
|
||||
nsresult rv = NS_NewHTMLFrame(aContent, nsnull, aNewFrame);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Bind root frame to root view (and root window)
|
||||
nsIPresShell* presShell = aPresContext->GetShell();
|
||||
nsIViewManager* viewManager = presShell->GetViewManager();
|
||||
nsIView* rootView;
|
||||
|
||||
NS_RELEASE(presShell);
|
||||
viewManager->GetRootView(rootView);
|
||||
aNewFrame->SetView(rootView);
|
||||
NS_RELEASE(viewManager);
|
||||
|
||||
// Set the style context
|
||||
aNewFrame->SetStyleContext(aPresContext, aStyleContext);
|
||||
|
||||
// Wrap the document element in a scroll frame
|
||||
nsIFrame* scrollFrame;
|
||||
|
||||
if (NS_SUCCEEDED(NS_NewScrollFrame(aContent, aNewFrame, scrollFrame))) {
|
||||
// The scroll frame gets the original style context, and the scrolled
|
||||
// frame gets a SCROLLED-CONTENT pseudo element style context.
|
||||
scrollFrame->SetStyleContext(aPresContext, aStyleContext);
|
||||
|
||||
nsIStyleContext* scrolledPseudoStyle;
|
||||
nsIFrame* wrapperFrame;
|
||||
|
||||
scrolledPseudoStyle = aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent,
|
||||
nsHTMLAtoms::scrolledContentPseudo,
|
||||
aStyleContext);
|
||||
|
||||
// Create a body frame to wrap the document element
|
||||
NS_NewBodyFrame(aContent, scrollFrame,
|
||||
wrapperFrame, NS_BODY_SHRINK_WRAP);
|
||||
wrapperFrame->SetStyleContext(aPresContext, scrolledPseudoStyle);
|
||||
|
||||
// Process the child content, and set the frame's initial child list
|
||||
nsIFrame* childList;
|
||||
rv = ProcessChildren(aPresContext, wrapperFrame, aContent, childList);
|
||||
wrapperFrame->SetInitialChildList(*aPresContext, nsnull, childList);
|
||||
|
||||
// Set the scroll frame's initial child list
|
||||
scrollFrame->SetInitialChildList(*aPresContext, nsnull, wrapperFrame);
|
||||
}
|
||||
|
||||
// initialize the root frame
|
||||
aNewFrame->SetInitialChildList(*aPresContext, nsnull, scrollFrame);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -1466,10 +1533,28 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
|
||||
else {
|
||||
// Create a frame.
|
||||
if (nsnull == aParentFrame) {
|
||||
// Construct the root frame object
|
||||
rv = ConstructRootFrame(aPresContext, aContent, styleContext,
|
||||
aFrameSubTree);
|
||||
|
||||
nsIDocument* document;
|
||||
rv = aContent->GetDocument(document);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(styleContext);
|
||||
return rv;
|
||||
}
|
||||
if (nsnull != document) {
|
||||
nsIXMLDocument* xmlDocument;
|
||||
rv = document->QueryInterface(kIXMLDocumentIID, (void **)&xmlDocument);
|
||||
if (NS_FAILED(rv)) {
|
||||
// Construct the root frame object
|
||||
rv = ConstructRootFrame(aPresContext, aContent, styleContext,
|
||||
aFrameSubTree);
|
||||
}
|
||||
else {
|
||||
// Construct the root frame object for XML
|
||||
rv = ConstructXMLRootFrames(aPresContext, aContent, styleContext,
|
||||
aFrameSubTree);
|
||||
NS_RELEASE(xmlDocument);
|
||||
}
|
||||
NS_RELEASE(document);
|
||||
}
|
||||
} else {
|
||||
// If the frame is a block-level frame and is scrollable then wrap it
|
||||
// in a scroll frame.
|
||||
|
29
content/xml/Makefile.in
Normal file
29
content/xml/Makefile.in
Normal file
@ -0,0 +1,29 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = content document
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
29
content/xml/content/Makefile.in
Normal file
29
content/xml/content/Makefile.in
Normal file
@ -0,0 +1,29 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
22
content/xml/content/makefile.win
Normal file
22
content/xml/content/makefile.win
Normal file
@ -0,0 +1,22 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
DIRS=src public
|
||||
|
||||
include <$(DEPTH)\layout\config\rules.mak>
|
35
content/xml/content/public/Makefile.in
Normal file
35
content/xml/content/public/Makefile.in
Normal file
@ -0,0 +1,35 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
EXPORTS = \
|
||||
nsIXMLContent.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
27
content/xml/content/public/makefile.win
Normal file
27
content/xml/content/public/makefile.win
Normal file
@ -0,0 +1,27 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
EXPORTS = \
|
||||
nsIXMLContent.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE=raptor
|
||||
|
||||
include <$(DEPTH)\layout\config\rules.mak>
|
||||
|
48
content/xml/content/public/nsIXMLContent.h
Normal file
48
content/xml/content/public/nsIXMLContent.h
Normal file
@ -0,0 +1,48 @@
|
||||
/* -*- 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.0 (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.
|
||||
*/
|
||||
|
||||
#ifndef nsIXMLContent_h___
|
||||
#define nsIXMLContent_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
#define gNameSpaceId_Unknown 0
|
||||
|
||||
#define NS_IXMLCONTENT_IID \
|
||||
{ 0xa6cf90cb, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
/**
|
||||
* XML content extensions to nsIContent
|
||||
*/
|
||||
class nsIXMLContent : public nsIContent {
|
||||
public:
|
||||
// XXX A convenience - the id can be used to get the namespace Atom
|
||||
NS_IMETHOD SetNameSpace(nsIAtom* aNameSpace)=0;
|
||||
NS_IMETHOD GetNameSpace(nsIAtom*& aNameSpace)=0;
|
||||
|
||||
NS_IMETHOD SetNameSpaceIdentifier(PRInt32 aNSIdentifier)=0;
|
||||
NS_IMETHOD GetNameSpaceIdentifier(PRInt32& aNSIdentifier)=0;
|
||||
};
|
||||
|
||||
extern nsresult
|
||||
NS_NewXMLElement(nsIXMLContent** aResult, nsIAtom* aTag);
|
||||
|
||||
#endif // nsIXMLContent_h___
|
64
content/xml/content/src/Makefile.in
Normal file
64
content/xml/content/src/Makefile.in
Normal file
@ -0,0 +1,64 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = raptorxmlcontent_s
|
||||
|
||||
DEFINES += -D_IMPL_NS_HTML
|
||||
|
||||
INCLUDES += \
|
||||
-I$(srcdir)/../../../html/base/src \
|
||||
-I$(srcdir)/../../../html/document/src \
|
||||
-I$(srcdir)/../../../html/content/src \
|
||||
-I$(srcdir)/../../../html/style/src \
|
||||
-I$(DIST)/public/raptor \
|
||||
$(NULL)
|
||||
|
||||
# Note the sophisticated alphabetical ordering :-|
|
||||
CPPSRCS = \
|
||||
nsXMLElement.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
REQUIRES = xpcom raptor dom netlib js pref
|
||||
|
||||
MKSHLIB :=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
export::
|
||||
|
||||
install:: $(TARGETS)
|
||||
|
||||
|
||||
clobber::
|
||||
|
53
content/xml/content/src/makefile.win
Normal file
53
content/xml/content/src/makefile.win
Normal file
@ -0,0 +1,53 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
LIBRARY_NAME=raptorxmlcontent_s
|
||||
MODULE=raptor
|
||||
REQUIRES=xpcom raptor pref
|
||||
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
CPPSRCS= \
|
||||
nsXMLElement.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsXMLElement.obj \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
|
||||
-I..\..\..\html\style\src -I..\..\..\html\base\src -I$(PUBLIC)\dom \
|
||||
-I..\..\..\html\content\src -I..\..\..\html\document\src \
|
||||
-I$(PUBLIC)\netlib -I..\..\..\base\src -I$(PUBLIC)\pref
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\layout\config\rules.mak>
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
184
content/xml/content/src/nsXMLElement.cpp
Normal file
184
content/xml/content/src/nsXMLElement.cpp
Normal file
@ -0,0 +1,184 @@
|
||||
/* -*- 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.0 (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.
|
||||
*/
|
||||
|
||||
#include "nsXMLElement.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIEventListenerManager.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
|
||||
//static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIXMLContentIID, NS_IXMLCONTENT_IID);
|
||||
|
||||
nsresult
|
||||
NS_NewXMLElement(nsIXMLContent** aInstancePtrResult, nsIAtom* aTag)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsIXMLContent* it = new nsXMLElement(aTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIXMLContentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
nsXMLElement::nsXMLElement(nsIAtom *aTag)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mInner.Init((nsIContent *)(nsIXMLContent *)this, aTag);
|
||||
mNameSpace = nsnull;
|
||||
mNameSpaceId = gNameSpaceId_Unknown;
|
||||
mScriptObject = nsnull;
|
||||
}
|
||||
|
||||
nsXMLElement::~nsXMLElement()
|
||||
{
|
||||
NS_IF_RELEASE(mNameSpace);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::QueryInterface(REFNSIID aIID,
|
||||
void** aInstancePtr)
|
||||
{
|
||||
NS_IMPL_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this, nsIXMLContent)
|
||||
if (aIID.Equals(kIXMLContentIID)) {
|
||||
nsIXMLContent* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsXMLElement)
|
||||
NS_IMPL_RELEASE(nsXMLElement)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::GetScriptObject(nsIScriptContext* aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
// XXX Yuck! Reaching into the generic content object isn't good.
|
||||
nsDOMSlots *slots = mInner.GetDOMSlots();
|
||||
if (nsnull == slots->mScriptObject) {
|
||||
nsIDOMScriptObjectFactory *factory;
|
||||
|
||||
res = nsGenericElement::GetScriptObjectFactory(&factory);
|
||||
if (NS_OK != res) {
|
||||
return res;
|
||||
}
|
||||
|
||||
nsAutoString tag;
|
||||
nsIContent* parent;
|
||||
|
||||
mInner.GetTagName(tag);
|
||||
mInner.GetParent(parent);
|
||||
|
||||
res = factory->NewScriptXMLElement(tag, aContext,
|
||||
(nsISupports *)(nsIDOMElement *)this,
|
||||
parent, (void**)&slots->mScriptObject);
|
||||
NS_IF_RELEASE(parent);
|
||||
NS_RELEASE(factory);
|
||||
|
||||
char tagBuf[50];
|
||||
tag.ToCString(tagBuf, sizeof(tagBuf));
|
||||
|
||||
nsIDocument *document;
|
||||
mInner.GetDocument(document);
|
||||
if (nsnull != document) {
|
||||
aContext->AddNamedReference((void *)&slots->mScriptObject,
|
||||
slots->mScriptObject,
|
||||
tagBuf);
|
||||
NS_RELEASE(document);
|
||||
}
|
||||
}
|
||||
*aScriptObject = slots->mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
return mInner.SetScriptObject(aScriptObject);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::SetNameSpace(nsIAtom* aNameSpace)
|
||||
{
|
||||
NS_IF_RELEASE(mNameSpace);
|
||||
|
||||
mNameSpace = aNameSpace;
|
||||
|
||||
NS_IF_ADDREF(mNameSpace);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::GetNameSpace(nsIAtom*& aNameSpace)
|
||||
{
|
||||
aNameSpace = mNameSpace;
|
||||
|
||||
NS_IF_ADDREF(mNameSpace);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::SetNameSpaceIdentifier(PRInt32 aNameSpaceId)
|
||||
{
|
||||
mNameSpaceId = aNameSpaceId;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::GetNameSpaceIdentifier(PRInt32& aNameSpaceId)
|
||||
{
|
||||
aNameSpaceId = mNameSpaceId;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsXMLElement* it = new nsXMLElement(mInner.mTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mInner.CopyInnerTo((nsIContent *)(nsIXMLContent *)this, &it->mInner);
|
||||
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
}
|
||||
|
104
content/xml/content/src/nsXMLElement.h
Normal file
104
content/xml/content/src/nsXMLElement.h
Normal file
@ -0,0 +1,104 @@
|
||||
/* -*- 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.0 (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.
|
||||
*/
|
||||
|
||||
#ifndef nsXMLElement_h___
|
||||
#define nsXMLElement_h___
|
||||
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIXMLContent.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsGenericElement.h"
|
||||
|
||||
class nsIDocument;
|
||||
class nsIAtom;
|
||||
class nsIEventListenerManager;
|
||||
class nsIHTMLAttributes;
|
||||
|
||||
class nsXMLElement : public nsIDOMElement,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIXMLContent,
|
||||
public nsIJSScriptObject
|
||||
{
|
||||
public:
|
||||
nsXMLElement(nsIAtom *aTag);
|
||||
~nsXMLElement();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNode
|
||||
NS_IMPL_IDOMNODE_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMElement
|
||||
NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
// nsIContent
|
||||
NS_IMPL_ICONTENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIXMLContent
|
||||
NS_IMETHOD SetNameSpace(nsIAtom* aNameSpace);
|
||||
NS_IMETHOD GetNameSpace(nsIAtom*& aNameSpace);
|
||||
NS_IMETHOD SetNameSpaceIdentifier(PRInt32 aNameSpaceId);
|
||||
NS_IMETHOD GetNameSpaceIdentifier(PRInt32& aNameSpeceId);
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIJSScriptObject
|
||||
virtual PRBool AddProperty(JSContext *aContext, jsval aID, jsval *aVp) {
|
||||
return mInner.AddProperty(aContext, aID, aVp);
|
||||
}
|
||||
virtual PRBool DeleteProperty(JSContext *aContext, jsval aID, jsval *aVp) {
|
||||
return mInner.DeleteProperty(aContext, aID, aVp);
|
||||
}
|
||||
virtual PRBool GetProperty(JSContext *aContext, jsval aID, jsval *aVp) {
|
||||
return mInner.GetProperty(aContext, aID, aVp);
|
||||
}
|
||||
virtual PRBool SetProperty(JSContext *aContext, jsval aID, jsval *aVp) {
|
||||
return mInner.SetProperty(aContext, aID, aVp);
|
||||
}
|
||||
virtual PRBool EnumerateProperty(JSContext *aContext) {
|
||||
return mInner.EnumerateProperty(aContext);
|
||||
}
|
||||
virtual PRBool Resolve(JSContext *aContext, jsval aID) {
|
||||
return mInner.Resolve(aContext, aID);
|
||||
}
|
||||
virtual PRBool Convert(JSContext *aContext, jsval aID) {
|
||||
return mInner.Convert(aContext, aID);
|
||||
}
|
||||
virtual void Finalize(JSContext *aContext) {
|
||||
mInner.Finalize(aContext);
|
||||
}
|
||||
|
||||
protected:
|
||||
nsGenericContainerElement mInner;
|
||||
|
||||
nsIAtom* mNameSpace;
|
||||
PRInt32 mNameSpaceId;
|
||||
void *mScriptObject;
|
||||
};
|
||||
|
||||
#endif // nsXMLElement_h___
|
29
content/xml/document/Makefile.in
Normal file
29
content/xml/document/Makefile.in
Normal file
@ -0,0 +1,29 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
22
content/xml/document/makefile.win
Normal file
22
content/xml/document/makefile.win
Normal file
@ -0,0 +1,22 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
DIRS=src public
|
||||
|
||||
include <$(DEPTH)\layout\config\rules.mak>
|
36
content/xml/document/public/Makefile.in
Normal file
36
content/xml/document/public/Makefile.in
Normal file
@ -0,0 +1,36 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
EXPORTS = \
|
||||
nsIXMLContentSink.h \
|
||||
nsIXMLDocument.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
28
content/xml/document/public/makefile.win
Normal file
28
content/xml/document/public/makefile.win
Normal file
@ -0,0 +1,28 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
EXPORTS = \
|
||||
nsIXMLContentSink.h \
|
||||
nsIXMLDocument.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE=raptor
|
||||
|
||||
include <$(DEPTH)\layout\config\rules.mak>
|
||||
|
122
content/xml/document/public/nsIXMLContentSink.h
Normal file
122
content/xml/document/public/nsIXMLContentSink.h
Normal file
@ -0,0 +1,122 @@
|
||||
/* -*- 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.0 (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.
|
||||
*/
|
||||
#ifndef nsIXMLContentSink_h___
|
||||
#define nsIXMLContentSink_h___
|
||||
|
||||
#include "nsIContentSink.h"
|
||||
#include "nsIParserNode.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIDocument;
|
||||
class nsIURL;
|
||||
class nsIWebShell;
|
||||
|
||||
#define NS_IXMLCONTENT_SINK_IID \
|
||||
{ 0xa6cf90c9, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
/**
|
||||
* This interface represents a content sink for generic XML files.
|
||||
* The goal of this sink is to deal with XML documents that do not
|
||||
* have pre-built semantics, though it may also be implemented for
|
||||
* cases in which semantics are hard-wired.
|
||||
*
|
||||
* The expectation is that the parser has already performed
|
||||
* well-formedness and validity checking.
|
||||
*
|
||||
* XXX The expectation is that entity expansion will be done by the sink
|
||||
* itself. This would require, however, that the sink has the ability
|
||||
* to query the parser for entity replacement text.
|
||||
*
|
||||
* XXX This interface does not contain a mechanism for the sink to
|
||||
* get specific schema/DTD information from the parser. This information
|
||||
* may be necessary for entity expansion. It is also necessary for
|
||||
* building the DOM portions that relate to the schema.
|
||||
*
|
||||
* XXX This interface does not deal with the presence of an external
|
||||
* subset. It seems possible that this could be dealt with completely
|
||||
* at the parser level.
|
||||
*/
|
||||
|
||||
class nsIXMLContentSink : public nsIContentSink {
|
||||
public:
|
||||
/**
|
||||
* This method is called by the parser when it encounters
|
||||
* the XML declaration for a document.
|
||||
*
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
*/
|
||||
NS_IMETHOD AddXMLDecl(const nsIParserNode& aNode)=0;
|
||||
|
||||
/**
|
||||
* This method is called by the parser when it encounters
|
||||
* a document type declaration.
|
||||
*
|
||||
* XXX Should the parser also part the internal subset?
|
||||
*
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
*/
|
||||
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode)=0;
|
||||
|
||||
/**
|
||||
* This method is called by the parser when it encounters
|
||||
* character data - either regular CDATA or a marked CDATA
|
||||
* section.
|
||||
*
|
||||
* XXX Could be removed in favor of nsIContentSink::AddLeaf
|
||||
*
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
*/
|
||||
NS_IMETHOD AddCharacterData(const nsIParserNode& aNode)=0;
|
||||
|
||||
/**
|
||||
* This method is called by the parser when it encounters
|
||||
* an unparsed entity (i.e. NDATA)
|
||||
*
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
*/
|
||||
NS_IMETHOD AddUnparsedEntity(const nsIParserNode& aNode)=0;
|
||||
|
||||
/**
|
||||
* This method is called by the parser when it encounters
|
||||
* a notation.
|
||||
*
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
*/
|
||||
NS_IMETHOD AddNotation(const nsIParserNode& aNode)=0;
|
||||
|
||||
/**
|
||||
* This method is called by the parser when it encounters
|
||||
* an entity reference. Note that the expectation is that
|
||||
* the content sink itself will expand the entity reference
|
||||
* in the content model.
|
||||
*
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
*/
|
||||
NS_IMETHOD AddEntityReference(const nsIParserNode& aNode)=0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
extern nsresult NS_NewXMLContentSink(nsIXMLContentSink** aInstancePtrResult,
|
||||
nsIDocument* aDoc,
|
||||
nsIURL* aURL,
|
||||
nsIWebShell* aWebShell);
|
||||
|
||||
#endif // nsIXMLContentSink_h___
|
57
content/xml/document/public/nsIXMLDocument.h
Normal file
57
content/xml/document/public/nsIXMLDocument.h
Normal file
@ -0,0 +1,57 @@
|
||||
/* -*- 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.0 (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.
|
||||
*/
|
||||
|
||||
#ifndef nsIXMLDocument_h___
|
||||
#define nsIXMLDocument_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIHTMLStyleSheet;
|
||||
|
||||
#define NS_IXMLDOCUMENT_IID \
|
||||
{ 0xa6cf90ca, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
/**
|
||||
* XML document extensions to nsIDocument
|
||||
*/
|
||||
class nsIXMLDocument : public nsISupports {
|
||||
public:
|
||||
// XXX A HTMLStyleSheet for attributes of HTML content within
|
||||
// this document
|
||||
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult)=0;
|
||||
|
||||
NS_IMETHOD RegisterNameSpace(nsIAtom* aPrefix, const nsString& aURI,
|
||||
PRInt32& aNameSpaceId)=0;
|
||||
|
||||
NS_IMETHOD GetNameSpaceURI(PRInt32 aNameSpaceId, nsString& aURI)=0;
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceId, nsIAtom*& aPrefix)=0;
|
||||
|
||||
NS_IMETHOD PrologElementAt(PRInt32 aOffset, nsIContent** aContent)=0;
|
||||
NS_IMETHOD PrologCount(PRInt32* aCount)=0;
|
||||
NS_IMETHOD AppendToProlog(nsIContent* aContent)=0;
|
||||
|
||||
NS_IMETHOD EpilogElementAt(PRInt32 aOffset, nsIContent** aContent)=0;
|
||||
NS_IMETHOD EpilogCount(PRInt32* aCount)=0;
|
||||
NS_IMETHOD AppendToEpilog(nsIContent* aContent)=0;
|
||||
};
|
||||
|
||||
#endif // nsIXMLDocument_h___
|
65
content/xml/document/src/Makefile.in
Normal file
65
content/xml/document/src/Makefile.in
Normal file
@ -0,0 +1,65 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = raptorxmldoc_s
|
||||
|
||||
DEFINES += -D_IMPL_NS_HTML
|
||||
|
||||
INCLUDES += \
|
||||
-I$(srcdir)/../../../html/base/src \
|
||||
-I$(srcdir)/../../../html/document/src \
|
||||
-I$(srcdir)/../../../html/content/src \
|
||||
-I$(srcdir)/../../../html/style/src \
|
||||
-I$(DIST)/public/raptor \
|
||||
$(NULL)
|
||||
|
||||
# Note the sophisticated alphabetical ordering :-|
|
||||
CPPSRCS = \
|
||||
nsXMLContentSink.cpp \
|
||||
nsXMLDocument.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
REQUIRES = xpcom raptor dom netlib js pref
|
||||
|
||||
MKSHLIB :=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
export::
|
||||
|
||||
install:: $(TARGETS)
|
||||
|
||||
|
||||
clobber::
|
||||
|
55
content/xml/document/src/makefile.win
Normal file
55
content/xml/document/src/makefile.win
Normal file
@ -0,0 +1,55 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
LIBRARY_NAME=raptorxmldoc_s
|
||||
MODULE=raptor
|
||||
REQUIRES=xpcom raptor pref
|
||||
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
CPPSRCS= \
|
||||
nsXMLContentSink.cpp \
|
||||
nsXMLDocument.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsXMLContentSink.obj \
|
||||
.\$(OBJDIR)\nsXMLDocument.obj \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
|
||||
-I..\..\..\html\style\src -I..\..\..\html\base\src -I$(PUBLIC)\dom \
|
||||
-I..\..\..\html\content\src -I..\..\..\html\document\src \
|
||||
-I$(PUBLIC)\netlib -I..\..\..\base\src -I$(PUBLIC)\pref
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\layout\config\rules.mak>
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
1096
content/xml/document/src/nsXMLContentSink.cpp
Normal file
1096
content/xml/document/src/nsXMLContentSink.cpp
Normal file
File diff suppressed because it is too large
Load Diff
125
content/xml/document/src/nsXMLContentSink.h
Normal file
125
content/xml/document/src/nsXMLContentSink.h
Normal file
@ -0,0 +1,125 @@
|
||||
/* -*- 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.0 (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.
|
||||
*/
|
||||
|
||||
#ifndef nsXMLContentSink_h__
|
||||
#define nsXMLContentSink_h__
|
||||
|
||||
#include "nsIXMLContentSink.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIScrollableView.h"
|
||||
|
||||
class nsIDocument;
|
||||
class nsIScriptObjectOwner;
|
||||
class nsIURL;
|
||||
class nsIWebShell;
|
||||
class nsIContent;
|
||||
class nsVoidArray;
|
||||
class nsIXMLDocument;
|
||||
class nsIUnicharInputStream;
|
||||
class nsIStyleSheet;
|
||||
|
||||
typedef enum {
|
||||
eXMLContentSinkState_InProlog,
|
||||
eXMLContentSinkState_InDocumentElement,
|
||||
eXMLContentSinkState_InEpilog
|
||||
} XMLContentSinkState;
|
||||
|
||||
|
||||
// XXX Till the parser knows a little bit more about XML,
|
||||
// this is a HTMLContentSink.
|
||||
class nsXMLContentSink : public nsIXMLContentSink {
|
||||
public:
|
||||
nsXMLContentSink();
|
||||
~nsXMLContentSink();
|
||||
|
||||
nsresult Init(nsIDocument* aDoc,
|
||||
nsIURL* aURL,
|
||||
nsIWebShell* aContainer);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIContentSink
|
||||
NS_IMETHOD WillBuildModel(void);
|
||||
NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel);
|
||||
NS_IMETHOD WillInterrupt(void);
|
||||
NS_IMETHOD WillResume(void);
|
||||
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddComment(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
|
||||
NS_IMETHOD NotifyError(nsresult aErrorResult);
|
||||
|
||||
// nsIXMLContentSink
|
||||
NS_IMETHOD AddXMLDecl(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddCharacterData(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddUnparsedEntity(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddNotation(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddEntityReference(const nsIParserNode& aNode);
|
||||
|
||||
protected:
|
||||
void StartLayout();
|
||||
|
||||
nsresult LoadStyleSheet(nsIURL* aURL,
|
||||
nsIUnicharInputStream* aUIN,
|
||||
PRBool aInline);
|
||||
nsresult FlushText(PRBool* aDidFlush=nsnull);
|
||||
|
||||
nsresult AddContentAsLeaf(nsIContent *aContent);
|
||||
void FindNameSpaceAttributes(const nsIParserNode& aNode);
|
||||
|
||||
PRInt32 OpenNameSpace(const nsString& aPrefix, const nsString& aURI);
|
||||
PRInt32 GetNameSpaceId(const nsString& aPrefix);
|
||||
void CloseNameSpacesAtNestLevel(PRInt32 mNestLevel);
|
||||
PRBool IsHTMLNameSpace(PRInt32 aId);
|
||||
|
||||
nsIContent* GetCurrentContent();
|
||||
PRInt32 PushContent(nsIContent *aContent);
|
||||
nsIContent* PopContent();
|
||||
PRInt32 GetCurrentNestLevel();
|
||||
|
||||
struct NameSpaceStruct {
|
||||
nsIAtom* mPrefix;
|
||||
PRInt32 mId;
|
||||
PRInt32 mNestLevel;
|
||||
};
|
||||
|
||||
nsIDocument* mDocument;
|
||||
nsIURL* mDocumentURL;
|
||||
nsIWebShell* mWebShell;
|
||||
|
||||
nsIContent* mRootElement;
|
||||
nsIContent* mDocElement;
|
||||
XMLContentSinkState mState;
|
||||
nsVoidArray* mNameSpaces;
|
||||
|
||||
PRInt32 mNestLevel;
|
||||
nsVoidArray* mContentStack;
|
||||
|
||||
nsIStyleSheet* mStyleSheet;
|
||||
nsScrollPreference mOriginalScrollPreference;
|
||||
|
||||
PRUnichar* mText;
|
||||
PRInt32 mTextLength;
|
||||
PRInt32 mTextSize;
|
||||
};
|
||||
|
||||
#endif // nsXMLContentSink_h__
|
423
content/xml/document/src/nsXMLDocument.cpp
Normal file
423
content/xml/document/src/nsXMLDocument.cpp
Normal file
@ -0,0 +1,423 @@
|
||||
/* -*- 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.0 (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.
|
||||
*/
|
||||
|
||||
|
||||
#include "nsXMLDocument.h"
|
||||
#include "nsWellFormedDTD.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsIXMLContent.h"
|
||||
#include "nsIXMLContentSink.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIContentViewerContainer.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIDocumentLoader.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsIHTMLStyleSheet.h"
|
||||
#include "nsRepository.h"
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMText.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIXMLDocumentIID, NS_IXMLDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
||||
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
|
||||
|
||||
|
||||
NS_LAYOUT nsresult
|
||||
NS_NewXMLDocument(nsIDocument** aInstancePtrResult)
|
||||
{
|
||||
nsXMLDocument* doc = new nsXMLDocument();
|
||||
return doc->QueryInterface(kIDocumentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
nsXMLDocument::nsXMLDocument()
|
||||
{
|
||||
mParser = nsnull;
|
||||
mNameSpaces = nsnull;
|
||||
mAttrStyleSheet = nsnull;
|
||||
mProlog = nsnull;
|
||||
mEpilog = nsnull;
|
||||
}
|
||||
|
||||
nsXMLDocument::~nsXMLDocument()
|
||||
{
|
||||
NS_IF_RELEASE(mParser);
|
||||
if (nsnull != mNameSpaces) {
|
||||
int i;
|
||||
for (i = 0; i < mNameSpaces->Count(); i++) {
|
||||
nsXMLNameSpace *ns = (nsXMLNameSpace *)mNameSpaces->ElementAt(i);
|
||||
|
||||
if (nsnull != ns) {
|
||||
NS_IF_RELEASE(ns->mPrefix);
|
||||
delete ns->mURI;
|
||||
delete ns;
|
||||
}
|
||||
}
|
||||
mNameSpaces = nsnull;
|
||||
}
|
||||
NS_IF_RELEASE(mAttrStyleSheet);
|
||||
if (nsnull != mProlog) {
|
||||
delete mProlog;
|
||||
}
|
||||
if (nsnull != mEpilog) {
|
||||
delete mProlog;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::QueryInterface(REFNSIID aIID,
|
||||
void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIXMLDocumentIID)) {
|
||||
NS_ADDREF_THIS();
|
||||
*aInstancePtr = (void**) (nsIXMLDocument *)this;
|
||||
return NS_OK;
|
||||
}
|
||||
return nsDocument::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
nsrefcnt nsXMLDocument::AddRef()
|
||||
{
|
||||
return nsDocument::AddRef();
|
||||
}
|
||||
|
||||
nsrefcnt nsXMLDocument::Release()
|
||||
{
|
||||
return nsDocument::Release();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::StartDocumentLoad(nsIURL *aUrl,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand)
|
||||
{
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aUrl, aContainer,
|
||||
aDocListener);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIWebShell* webShell;
|
||||
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
||||
rv = nsRepository::CreateInstance(kCParserCID,
|
||||
nsnull,
|
||||
kCParserIID,
|
||||
(void **)&mParser);
|
||||
if (NS_OK == rv) {
|
||||
nsIXMLContentSink* sink;
|
||||
|
||||
aContainer->QueryInterface(kIWebShellIID, (void**)&webShell);
|
||||
rv = NS_NewXMLContentSink(&sink, this, aUrl, webShell);
|
||||
NS_IF_RELEASE(webShell);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
// For the HTML content within a document
|
||||
if (NS_OK == NS_NewHTMLStyleSheet(&mAttrStyleSheet, aUrl)) {
|
||||
AddStyleSheet(mAttrStyleSheet); // tell the world about our new style sheet
|
||||
}
|
||||
|
||||
// Set the parser as the stream listener for the document loader...
|
||||
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
||||
rv = mParser->QueryInterface(kIStreamListenerIID, (void**)aDocListener);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
|
||||
nsIDTD* theDTD=0;
|
||||
// XXX For now, we'll use the HTML DTD
|
||||
NS_NewWellFormed_DTD(&theDTD);
|
||||
mParser->RegisterDTD(theDTD);
|
||||
|
||||
mParser->SetContentSink(sink);
|
||||
mParser->Parse(aUrl);
|
||||
}
|
||||
NS_RELEASE(sink);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::EndLoad()
|
||||
{
|
||||
NS_IF_RELEASE(mParser);
|
||||
return nsDocument::EndLoad();
|
||||
}
|
||||
|
||||
// XXX Currently a nsIHTMLDocument method. Should go into an interface
|
||||
// implemented for XML documents that hold HTML content.
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
||||
if (nsnull == aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aResult = mAttrStyleSheet;
|
||||
if (nsnull == mAttrStyleSheet) {
|
||||
return NS_ERROR_NOT_AVAILABLE; // probably not the right error...
|
||||
}
|
||||
else {
|
||||
NS_ADDREF(mAttrStyleSheet);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIDOMDocument interface
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::GetDoctype(nsIDOMDocumentType** aDocumentType)
|
||||
{
|
||||
// XXX TBI
|
||||
*aDocumentType = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateCDATASection(const nsString& aData, nsIDOMCDATASection** aReturn)
|
||||
{
|
||||
// XXX TBI
|
||||
*aReturn = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateEntityReference(const nsString& aName, nsIDOMEntityReference** aReturn)
|
||||
{
|
||||
// XXX TBI
|
||||
*aReturn = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateComment(const nsString& aData, nsIDOMComment** aReturn)
|
||||
{
|
||||
// XXX Should just be regular nsIContent
|
||||
nsIHTMLContent* comment = nsnull;
|
||||
nsresult rv = NS_NewCommentNode(&comment);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
rv = comment->QueryInterface(kIDOMCommentIID, (void**)aReturn);
|
||||
(*aReturn)->AppendData(aData);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateProcessingInstruction(const nsString& aTarget, const nsString& aData, nsIDOMProcessingInstruction** aReturn)
|
||||
{
|
||||
// XXX TBI
|
||||
*aReturn = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateAttribute(const nsString& aName, nsIDOMAttr** aReturn)
|
||||
{
|
||||
// XXX TBI
|
||||
*aReturn = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateElement(const nsString& aTagName,
|
||||
nsIDOMElement** aReturn)
|
||||
{
|
||||
nsIXMLContent* content;
|
||||
nsIAtom* tag = NS_NewAtom(aTagName);
|
||||
nsresult rv = NS_NewXMLElement(&content, tag);
|
||||
NS_RELEASE(tag);
|
||||
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
rv = content->QueryInterface(kIDOMElementIID, (void**)aReturn);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateTextNode(const nsString& aData, nsIDOMText** aReturn)
|
||||
{
|
||||
// XXX Should just be regular nsIContent
|
||||
nsIHTMLContent* text = nsnull;
|
||||
nsresult rv = NS_NewTextNode(&text);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
rv = text->QueryInterface(kIDOMTextIID, (void**)aReturn);
|
||||
(*aReturn)->AppendData(aData);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
// nsIXMLDocument interface
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::RegisterNameSpace(nsIAtom *aPrefix, const nsString& aURI,
|
||||
PRInt32& aNameSpaceId)
|
||||
{
|
||||
if (nsnull == mNameSpaces) {
|
||||
mNameSpaces = new nsVoidArray();
|
||||
if (nsnull == mNameSpaces) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
nsXMLNameSpace* ns = new nsXMLNameSpace;
|
||||
if (nsnull == ns) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
ns->mPrefix = aPrefix;
|
||||
NS_IF_ADDREF(ns->mPrefix);
|
||||
ns->mURI = new nsString(aURI);
|
||||
|
||||
mNameSpaces->AppendElement((void *)ns);
|
||||
aNameSpaceId = mNameSpaces->Count();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::GetNameSpaceURI(PRInt32 aNameSpaceId, nsString& aURI)
|
||||
{
|
||||
if (nsnull == mNameSpaces) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
nsXMLNameSpace *ns = (nsXMLNameSpace *)mNameSpaces->ElementAt(aNameSpaceId - 1);
|
||||
if (nsnull == ns) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
aURI.SetString(*ns->mURI);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::GetNameSpacePrefix(PRInt32 aNameSpaceId, nsIAtom*& aPrefix)
|
||||
{
|
||||
if (nsnull == mNameSpaces) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
nsXMLNameSpace *ns = (nsXMLNameSpace *)mNameSpaces->ElementAt(aNameSpaceId - 1);
|
||||
if (nsnull == ns) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
aPrefix = ns->mPrefix;
|
||||
NS_IF_ADDREF(aPrefix);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::PrologElementAt(PRInt32 aIndex, nsIContent** aContent)
|
||||
{
|
||||
if (nsnull == mProlog) {
|
||||
*aContent = nsnull;
|
||||
}
|
||||
else {
|
||||
*aContent = (nsIContent *)mProlog->ElementAt(aIndex);
|
||||
NS_ADDREF(*aContent);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::PrologCount(PRInt32* aCount)
|
||||
{
|
||||
if (nsnull == mProlog) {
|
||||
*aCount = 0;
|
||||
}
|
||||
else {
|
||||
*aCount = mProlog->Count();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::AppendToProlog(nsIContent* aContent)
|
||||
{
|
||||
if (nsnull == mProlog) {
|
||||
mProlog = new nsVoidArray();
|
||||
}
|
||||
|
||||
mProlog->AppendElement((void *)aContent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::EpilogElementAt(PRInt32 aIndex, nsIContent** aContent)
|
||||
{
|
||||
if (nsnull == mEpilog) {
|
||||
*aContent = nsnull;
|
||||
}
|
||||
else {
|
||||
*aContent = (nsIContent *)mEpilog->ElementAt(aIndex);
|
||||
NS_ADDREF(*aContent);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::EpilogCount(PRInt32* aCount)
|
||||
{
|
||||
if (nsnull == mEpilog) {
|
||||
*aCount = 0;
|
||||
}
|
||||
else {
|
||||
*aCount = mEpilog->Count();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::AppendToEpilog(nsIContent* aContent)
|
||||
{
|
||||
if (nsnull == mEpilog) {
|
||||
mEpilog = new nsVoidArray();
|
||||
}
|
||||
|
||||
mEpilog->AppendElement((void *)aContent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
95
content/xml/document/src/nsXMLDocument.h
Normal file
95
content/xml/document/src/nsXMLDocument.h
Normal file
@ -0,0 +1,95 @@
|
||||
/* -*- 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.0 (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.
|
||||
*/
|
||||
|
||||
#ifndef nsXMLDocument_h___
|
||||
#define nsXMLDocument_h___
|
||||
|
||||
#include "nsMarkupDocument.h"
|
||||
#include "nsIXMLDocument.h"
|
||||
#include "plhash.h"
|
||||
|
||||
class nsIParser;
|
||||
|
||||
typedef struct {
|
||||
nsIAtom *mPrefix;
|
||||
nsString *mURI;
|
||||
PRInt32 mId;
|
||||
} nsXMLNameSpace;
|
||||
|
||||
class nsXMLDocument : public nsMarkupDocument,
|
||||
public nsIXMLDocument
|
||||
{
|
||||
public:
|
||||
nsXMLDocument();
|
||||
virtual ~nsXMLDocument();
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(nsIURL *aUrl,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand);
|
||||
|
||||
NS_IMETHOD EndLoad();
|
||||
|
||||
// nsIDOMDocument interface
|
||||
NS_IMETHOD GetDoctype(nsIDOMDocumentType** aDocumentType);
|
||||
NS_IMETHOD CreateCDATASection(const nsString& aData, nsIDOMCDATASection** aReturn);
|
||||
NS_IMETHOD CreateEntityReference(const nsString& aName, nsIDOMEntityReference** aReturn);
|
||||
NS_IMETHOD CreateComment(const nsString& aData, nsIDOMComment** aReturn);
|
||||
NS_IMETHOD CreateProcessingInstruction(const nsString& aTarget, const nsString& aData, nsIDOMProcessingInstruction** aReturn);
|
||||
NS_IMETHOD CreateAttribute(const nsString& aName, nsIDOMAttr** aReturn);
|
||||
NS_IMETHOD CreateElement(const nsString& aTagName,
|
||||
nsIDOMElement** aReturn);
|
||||
NS_IMETHOD CreateTextNode(const nsString& aData, nsIDOMText** aReturn);
|
||||
|
||||
// nsIXMLDocument interface
|
||||
NS_IMETHOD RegisterNameSpace(nsIAtom *aPrefix, const nsString& aURI,
|
||||
PRInt32& aNameSpaceId);
|
||||
|
||||
NS_IMETHOD GetNameSpaceURI(PRInt32 aNameSpaceId, nsString& aURI);
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceId, nsIAtom*& aPrefix);
|
||||
|
||||
NS_IMETHOD PrologElementAt(PRInt32 aOffset, nsIContent** aContent);
|
||||
NS_IMETHOD PrologCount(PRInt32* aCount);
|
||||
NS_IMETHOD AppendToProlog(nsIContent* aContent);
|
||||
|
||||
NS_IMETHOD EpilogElementAt(PRInt32 aOffset, nsIContent** aContent);
|
||||
NS_IMETHOD EpilogCount(PRInt32* aCount);
|
||||
NS_IMETHOD AppendToEpilog(nsIContent* aContent);
|
||||
|
||||
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult);
|
||||
|
||||
protected:
|
||||
|
||||
// For HTML elements in our content model
|
||||
nsIHTMLStyleSheet* mAttrStyleSheet;
|
||||
|
||||
nsVoidArray *mProlog;
|
||||
nsVoidArray *mEpilog;
|
||||
|
||||
nsIParser *mParser;
|
||||
nsVoidArray *mNameSpaces;
|
||||
};
|
||||
|
||||
|
||||
#endif // nsXMLDocument_h___
|
22
content/xml/makefile.win
Normal file
22
content/xml/makefile.win
Normal file
@ -0,0 +1,22 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
DIRS = content document
|
||||
|
||||
include <$(DEPTH)\layout\config\rules.mak>
|
@ -17,7 +17,7 @@
|
||||
|
||||
DEPTH = ..
|
||||
|
||||
DIRS = base html events build
|
||||
DIRS = base html xml events build
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
|
@ -22,7 +22,7 @@ VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = base html events build
|
||||
DIRS = base html xml events build
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
|
@ -36,6 +36,7 @@ class nsVoidArray;
|
||||
class nsXIFConverter;
|
||||
class nsIDOMEvent;
|
||||
class nsIContent;
|
||||
class nsISupportsArray;
|
||||
|
||||
// IID for the nsIContent interface
|
||||
#define NS_ICONTENT_IID \
|
||||
@ -118,6 +119,40 @@ public:
|
||||
*/
|
||||
NS_IMETHOD GetAttribute(const nsString& aName, nsString& aResult) const = 0;
|
||||
|
||||
/**
|
||||
* Remove an attribute so that it is no longer explicitly specified.
|
||||
*
|
||||
* @param aAttribute the name of the attribute to unset
|
||||
*
|
||||
* @param aNotify specifies whether or not the document should be
|
||||
* notified of the attribute change
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of all specified attribute. The returned array
|
||||
* contains nsIAtom's representing the attribute names.
|
||||
*
|
||||
* @param aArray an array to be filled in with attribute names
|
||||
*
|
||||
* @param aCountResult an out parameter to be filled in with
|
||||
* the number of attributes
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray,
|
||||
PRInt32& aCountResult) const = 0;
|
||||
|
||||
/**
|
||||
* Get the number of all specified attributes.
|
||||
*
|
||||
* @param aCountResult an out parameter to be filled in with
|
||||
* the number of attributes
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aCountResult) const = 0;
|
||||
|
||||
/**
|
||||
* List the content (and anything it contains) out to the given
|
||||
* file stream. Use aIndent as the base indent during formatting.
|
||||
|
@ -240,6 +240,9 @@ public:
|
||||
extern NS_LAYOUT nsresult
|
||||
NS_NewHTMLDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
extern NS_LAYOUT nsresult
|
||||
NS_NewXMLDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
extern NS_LAYOUT nsresult
|
||||
NS_NewImageDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
|
@ -47,6 +47,8 @@ EXPORTS = \
|
||||
nsXIFConverter.h \
|
||||
$(NULL)
|
||||
|
||||
INCLUDES += -I../../html/base/src
|
||||
|
||||
REQUIRES = xpcom raptor dom netlib js pref
|
||||
|
||||
TARGETS = $(LIBRARY)
|
||||
|
@ -52,6 +52,8 @@ EXPORTS = \
|
||||
nsXIFConverter.h \
|
||||
$(NULL)
|
||||
|
||||
INCLUDES += -I../../html/base/src
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
REQUIRES = xpcom raptor dom netlib js pref
|
||||
|
@ -62,7 +62,7 @@ CPP_OBJS= \
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\dom -I$(PUBLIC)\js -I$(PUBLIC)\netlib \
|
||||
-I$(PUBLIC)\pref
|
||||
-I$(PUBLIC)\pref -I..\..\html\base\src
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
|
@ -275,6 +275,34 @@ nsIArena* nsDocument::GetArena()
|
||||
return mArena;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::StartDocumentLoad(nsIURL *aURL,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener)
|
||||
{
|
||||
// Delete references to style sheets - this should be done in superclass...
|
||||
PRInt32 index = mStyleSheets.Count();
|
||||
while (--index >= 0) {
|
||||
nsIStyleSheet* sheet = (nsIStyleSheet*) mStyleSheets.ElementAt(index);
|
||||
NS_RELEASE(sheet);
|
||||
}
|
||||
mStyleSheets.Clear();
|
||||
|
||||
NS_IF_RELEASE(mDocumentURL);
|
||||
NS_IF_RELEASE(mDocumentURLGroup);
|
||||
if (nsnull != mDocumentTitle) {
|
||||
delete mDocumentTitle;
|
||||
mDocumentTitle = nsnull;
|
||||
}
|
||||
|
||||
mDocumentURL = aURL;
|
||||
NS_ADDREF(aURL);
|
||||
|
||||
mDocumentURLGroup = aURL->GetURLGroup();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const nsString* nsDocument::GetDocumentTitle() const
|
||||
{
|
||||
return mDocumentTitle;
|
||||
|
@ -58,6 +58,10 @@ public:
|
||||
|
||||
virtual nsIArena* GetArena();
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(nsIURL *aUrl,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener);
|
||||
|
||||
/**
|
||||
* Return the title of the document. May return null.
|
||||
*/
|
||||
|
@ -27,6 +27,12 @@
|
||||
#include "nsIContent.h"
|
||||
#include "nsIStyleFrameConstruction.h"
|
||||
|
||||
// XXX Temporary fix to make sure that ua.css only gets applied
|
||||
// to HTML content. When this removed, remember to get rid of
|
||||
// the include dependency in the makefile.
|
||||
#include "nsIHTMLContent.h"
|
||||
static NS_DEFINE_IID(kIHTMLContentIID, NS_IHTMLCONTENT_IID);
|
||||
|
||||
static NS_DEFINE_IID(kIStyleSetIID, NS_ISTYLE_SET_IID);
|
||||
static NS_DEFINE_IID(kIStyleFrameConstructionIID, NS_ISTYLE_FRAME_CONSTRUCTION_IID);
|
||||
|
||||
@ -477,7 +483,13 @@ nsIStyleContext* StyleSetImpl::ResolveStyleFor(nsIPresContext* aPresContext,
|
||||
}
|
||||
|
||||
if (nsnull != rules) {
|
||||
PRInt32 ruleCount = RulesMatching(mBackstopSheets, aPresContext, aContent, aParentContext, rules);
|
||||
nsIHTMLContent *htmlContent;
|
||||
nsresult rv = aContent->QueryInterface(kIHTMLContentIID, (void **)&htmlContent);
|
||||
PRInt32 ruleCount = 0;
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
ruleCount += RulesMatching(mBackstopSheets, aPresContext, aContent, aParentContext, rules);
|
||||
NS_RELEASE(htmlContent);
|
||||
}
|
||||
PRInt32 backstopRules = ruleCount;
|
||||
ruleCount += RulesMatching(mDocSheets, aPresContext, aContent, aParentContext, rules);
|
||||
ruleCount += RulesMatching(mOverrideSheets, aPresContext, aContent, aParentContext, rules);
|
||||
|
@ -54,6 +54,8 @@ EXTRA_DSO_LDOPTS = \
|
||||
-lraptorhtmlstyle_s \
|
||||
-lraptorhtmltable_s \
|
||||
-lraptorlayout_s \
|
||||
-lraptorxmldoc_s \
|
||||
-lraptorxmlcontent_s \
|
||||
-lraptorevents_s \
|
||||
$(LD_NONE) \
|
||||
-L$(DIST)/bin \
|
||||
|
@ -55,6 +55,8 @@ EXTRA_DSO_LDOPTS = \
|
||||
-lraptorhtmlstyle_s \
|
||||
-lraptorhtmlbase_s \
|
||||
-lraptorhtmltable_s \
|
||||
-lraptorxmldoc_s \
|
||||
-lraptorxmlcontent_s \
|
||||
-lraptorlayout_s \
|
||||
-lraptorevents_s \
|
||||
-L$(DIST)/bin \
|
||||
|
@ -42,6 +42,8 @@ MISCDEP = \
|
||||
$(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\raptorevents_s.lib \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
@ -68,6 +70,8 @@ LLIBS= \
|
||||
$(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\raptorevents_s.lib \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
|
@ -28,6 +28,11 @@
|
||||
0x5d0fcdd0, 0x4daa, 0x11d2, \
|
||||
{0xb3, 0x28, 0x00, 0x80, 0x5f, 0x8a, 0x38, 0x59}}
|
||||
|
||||
#define NS_XMLDOCUMENT_CID \
|
||||
{ /* a6cf9063-15b3-11d2-932e-00805f8add32 */ \
|
||||
0xa6cf9063, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
#define NS_IMAGEDOCUMENT_CID \
|
||||
{ /* e11a6080-4daa-11d2-b328-00805f8a3859 */ \
|
||||
0xe11a6080, 0x4daa, 0x11d2, \
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
static NS_DEFINE_IID(kCHTMLDocumentCID, NS_HTMLDOCUMENT_CID);
|
||||
static NS_DEFINE_IID(kCXMLDocumentCID, NS_XMLDOCUMENT_CID);
|
||||
static NS_DEFINE_IID(kCImageDocumentCID, NS_IMAGEDOCUMENT_CID);
|
||||
static NS_DEFINE_IID(kCHTMLImageElementFactoryCID, NS_HTMLIMAGEELEMENTFACTORY_CID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLImageElementFactoryIID, NS_IDOMHTMLIMAGEELEMENTFACTORY_IID);
|
||||
@ -179,6 +180,13 @@ nsresult nsLayoutFactory::CreateInstance(nsISupports *aOuter,
|
||||
}
|
||||
refCounted = PR_TRUE;
|
||||
}
|
||||
if (mClassID.Equals(kCXMLDocumentCID)) {
|
||||
res = NS_NewXMLDocument((nsIDocument **)&inst);
|
||||
if (res != NS_OK) {
|
||||
return res;
|
||||
}
|
||||
refCounted = PR_TRUE;
|
||||
}
|
||||
if (mClassID.Equals(kCImageDocumentCID)) {
|
||||
res = NS_NewImageDocument((nsIDocument **)&inst);
|
||||
if (res != NS_OK) {
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "nsHTMLValue.h"
|
||||
class nsString;
|
||||
class nsIFrame;
|
||||
class nsISupportsArray;
|
||||
class nsIStyleRule;
|
||||
class nsIStyleContext;
|
||||
class nsIPresContext;
|
||||
@ -55,17 +54,12 @@ public:
|
||||
const nsHTMLValue& aValue,
|
||||
PRBool aNotify) = 0;
|
||||
|
||||
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify) = 0;
|
||||
|
||||
NS_IMETHOD GetAttribute(const nsString& aName,
|
||||
NS_IMETHOD GetAttribute(const nsString& aName,
|
||||
nsString& aResult) const = 0;
|
||||
NS_IMETHOD GetAttribute(nsIAtom *aAttribute,
|
||||
nsString &aResult) const = 0;
|
||||
NS_IMETHOD GetAttribute(nsIAtom* aAttribute,
|
||||
nsHTMLValue& aValue) const = 0;
|
||||
NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray,
|
||||
PRInt32& aCountResult) const = 0;
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aCountResult) const = 0;
|
||||
NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const = 0;
|
||||
|
||||
NS_IMETHOD SetID(nsIAtom* aID) = 0;
|
||||
|
@ -23,6 +23,7 @@ LIBRARY_NAME = nglhtmlcon_s
|
||||
CPPSRCS= \
|
||||
nsCommentNode.cpp \
|
||||
nsGenericDOMDataNode.cpp \
|
||||
nsGenericElement.cpp \
|
||||
nsGenericHTMLElement.cpp \
|
||||
nsHTMLAnchorElement.cpp \
|
||||
nsHTMLAppletElement.cpp \
|
||||
|
@ -28,6 +28,7 @@ LIBRARY_NAME = nglhtmlcon_s
|
||||
CPPSRCS= \
|
||||
nsCommentNode.cpp \
|
||||
nsGenericDOMDataNode.cpp \
|
||||
nsGenericElement.cpp \
|
||||
nsGenericHTMLElement.cpp \
|
||||
nsHTMLAnchorElement.cpp \
|
||||
nsHTMLAppletElement.cpp \
|
||||
|
@ -25,6 +25,7 @@ DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
CPPSRCS= \
|
||||
nsCommentNode.cpp \
|
||||
nsGenericDOMDataNode.cpp \
|
||||
nsGenericElement.cpp \
|
||||
nsGenericHTMLElement.cpp \
|
||||
nsHTMLAnchorElement.cpp \
|
||||
nsHTMLAppletElement.cpp \
|
||||
@ -92,6 +93,7 @@ CPPSRCS= \
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsCommentNode.obj \
|
||||
.\$(OBJDIR)\nsGenericDOMDataNode.obj \
|
||||
.\$(OBJDIR)\nsGenericElement.obj \
|
||||
.\$(OBJDIR)\nsGenericHTMLElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLAnchorElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLAppletElement.obj \
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsFrame.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
|
||||
|
||||
class nsCommentNode : public nsIDOMComment,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDOMEventReceiver,
|
||||
@ -91,6 +93,12 @@ NS_IMETHODIMP
|
||||
nsCommentNode::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_IMPL_DOM_DATA_QUERY_INTERFACE(aIID, aInstancePtr, this)
|
||||
if (aIID.Equals(kIDOMCommentIID)) {
|
||||
nsIDOMComment* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ nsGenericDOMDataNode::GetScriptObject(nsIScriptContext* aContext,
|
||||
if (nsnull == mScriptObject) {
|
||||
nsIDOMScriptObjectFactory *factory;
|
||||
|
||||
res = nsGenericHTMLElement::GetScriptObjectFactory(&factory);
|
||||
res = nsGenericElement::GetScriptObjectFactory(&factory);
|
||||
if (NS_OK != res) {
|
||||
return res;
|
||||
}
|
||||
|
1983
layout/html/content/src/nsGenericElement.cpp
Normal file
1983
layout/html/content/src/nsGenericElement.cpp
Normal file
File diff suppressed because it is too large
Load Diff
572
layout/html/content/src/nsGenericElement.h
Normal file
572
layout/html/content/src/nsGenericElement.h
Normal file
@ -0,0 +1,572 @@
|
||||
/* -*- 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.0 (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.
|
||||
*/
|
||||
#ifndef nsGenericElement_h___
|
||||
#define nsGenericElement_h___
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMNamedNodeMap.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
|
||||
extern const nsIID kIDOMNodeIID;
|
||||
extern const nsIID kIDOMElementIID;
|
||||
extern const nsIID kIDOMEventReceiverIID;
|
||||
extern const nsIID kIScriptObjectOwnerIID;
|
||||
extern const nsIID kIJSScriptObjectIID;
|
||||
extern const nsIID kISupportsIID;
|
||||
extern const nsIID kIContentIID;
|
||||
|
||||
class nsIDOMAttr;
|
||||
class nsIDOMEventListener;
|
||||
class nsIEventListenerManager;
|
||||
class nsIFrame;
|
||||
class nsISupportsArray;
|
||||
class nsIDOMScriptObjectFactory;
|
||||
class nsDOMCSSDeclaration;
|
||||
class nsIDOMCSSStyleDeclaration;
|
||||
class nsIHTMLAttributes;
|
||||
|
||||
// Attribute helper class used to wrap up an attribute with a dom
|
||||
// object that implements nsIDOMAttr and nsIDOMNode and
|
||||
// nsIScriptObjectOwner
|
||||
class nsDOMAttribute : public nsIDOMAttr, public nsIScriptObjectOwner {
|
||||
public:
|
||||
nsDOMAttribute(const nsString &aName, const nsString &aValue);
|
||||
~nsDOMAttribute();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
// nsIDOMAttr interface
|
||||
NS_IMETHOD GetSpecified(PRBool* aSpecified);
|
||||
NS_IMETHOD GetName(nsString& aReturn);
|
||||
NS_IMETHOD GetValue(nsString& aReturn);
|
||||
NS_IMETHOD SetValue(const nsString& aValue);
|
||||
|
||||
// nsIDOMNode interface
|
||||
NS_IMETHOD GetNodeName(nsString& aNodeName);
|
||||
NS_IMETHOD GetNodeValue(nsString& aNodeValue);
|
||||
NS_IMETHOD SetNodeValue(const nsString& aNodeValue);
|
||||
NS_IMETHOD GetNodeType(PRUint16* aNodeType);
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode);
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes);
|
||||
NS_IMETHOD HasChildNodes(PRBool* aHasChildNodes);
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild);
|
||||
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild);
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling);
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling);
|
||||
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes);
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn);
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
||||
nsIDOMNode** aReturn);
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
|
||||
|
||||
private:
|
||||
nsString mName;
|
||||
nsString mValue;
|
||||
void* mScriptObject;
|
||||
};
|
||||
|
||||
// Another helper class that implements the nsIDOMNamedNodeMap interface.
|
||||
class nsDOMAttributeMap : public nsIDOMNamedNodeMap,
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
public:
|
||||
nsDOMAttributeMap(nsIContent* aContent);
|
||||
~nsDOMAttributeMap();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
// nsIDOMNamedNodeMap interface
|
||||
NS_IMETHOD GetLength(PRUint32* aSize);
|
||||
NS_IMETHOD GetNamedItem(const nsString& aName, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD SetNamedItem(nsIDOMNode* aNode, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD RemoveNamedItem(const nsString& aName, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn);
|
||||
|
||||
private:
|
||||
nsIContent* mContent;
|
||||
void* mScriptObject;
|
||||
};
|
||||
|
||||
|
||||
// Class that holds the child list of a content element and also
|
||||
// implements the nsIDOMNodeList interface.
|
||||
class nsChildContentList : public nsIDOMNodeList,
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
public:
|
||||
nsChildContentList(nsIContent *aContent);
|
||||
~nsChildContentList() {}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
// nsIDOMNodeList interface
|
||||
NS_DECL_IDOMNODELIST
|
||||
|
||||
void DropReference();
|
||||
|
||||
private:
|
||||
nsIContent *mContent;
|
||||
void *mScriptObject;
|
||||
};
|
||||
|
||||
// There are a set of DOM- and scripting-specific instance variables
|
||||
// that may only be instantiated when a content object is accessed
|
||||
// through the DOM. Rather than burn actual slots in the content
|
||||
// objects for each of these instance variables, we put them off
|
||||
// in a side structure that's only allocated when the content is
|
||||
// accessed through the DOM.
|
||||
typedef struct {
|
||||
void *mScriptObject;
|
||||
nsChildContentList *mChildNodes;
|
||||
nsDOMCSSDeclaration *mStyle;
|
||||
} nsDOMSlots;
|
||||
|
||||
class nsGenericElement : public nsIJSScriptObject {
|
||||
public:
|
||||
nsGenericElement();
|
||||
~nsGenericElement();
|
||||
|
||||
void Init(nsIContent* aOuterContentObject, nsIAtom* aTag);
|
||||
|
||||
// Implementation for nsIDOMNode
|
||||
nsresult GetNodeName(nsString& aNodeName);
|
||||
nsresult GetNodeValue(nsString& aNodeValue);
|
||||
nsresult SetNodeValue(const nsString& aNodeValue);
|
||||
nsresult GetNodeType(PRUint16* aNodeType);
|
||||
nsresult GetParentNode(nsIDOMNode** aParentNode);
|
||||
nsresult GetAttributes(nsIDOMNamedNodeMap** aAttributes);
|
||||
nsresult GetPreviousSibling(nsIDOMNode** aPreviousSibling);
|
||||
nsresult GetNextSibling(nsIDOMNode** aNextSibling);
|
||||
nsresult GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
|
||||
|
||||
// Implementation for nsIDOMElement
|
||||
nsresult GetTagName(nsString& aTagName);
|
||||
nsresult GetDOMAttribute(const nsString& aName, nsString& aReturn);
|
||||
nsresult SetDOMAttribute(const nsString& aName, const nsString& aValue);
|
||||
nsresult RemoveAttribute(const nsString& aName);
|
||||
nsresult GetAttributeNode(const nsString& aName,
|
||||
nsIDOMAttr** aReturn);
|
||||
nsresult SetAttributeNode(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn);
|
||||
nsresult RemoveAttributeNode(nsIDOMAttr* aOldAttr, nsIDOMAttr** aReturn);
|
||||
nsresult GetElementsByTagName(const nsString& aTagname,
|
||||
nsIDOMNodeList** aReturn);
|
||||
nsresult Normalize();
|
||||
|
||||
// nsIDOMEventReceiver interface
|
||||
nsresult AddEventListener(nsIDOMEventListener *aListener, const nsIID& aIID);
|
||||
nsresult RemoveEventListener(nsIDOMEventListener* aListener,
|
||||
const nsIID& aIID);
|
||||
nsresult GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
nsresult GetNewListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
|
||||
// nsIScriptObjectOwner interface
|
||||
nsresult GetScriptObject(nsIScriptContext* aContext, void** aScriptObject);
|
||||
nsresult SetScriptObject(void *aScriptObject);
|
||||
|
||||
// Implementation for nsIContent
|
||||
nsresult GetDocument(nsIDocument*& aResult) const;
|
||||
nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep);
|
||||
nsresult GetParent(nsIContent*& aResult) const;
|
||||
nsresult SetParent(nsIContent* aParent);
|
||||
nsresult IsSynthetic(PRBool& aResult) {
|
||||
aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult GetTag(nsIAtom*& aResult) const;
|
||||
nsresult HandleDOMEvent(nsIPresContext& aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus& aEventStatus);
|
||||
|
||||
// Implementation for nsIJSScriptObject
|
||||
PRBool AddProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
PRBool DeleteProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
PRBool GetProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
PRBool SetProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
PRBool EnumerateProperty(JSContext *aContext);
|
||||
PRBool Resolve(JSContext *aContext, jsval aID);
|
||||
PRBool Convert(JSContext *aContext, jsval aID);
|
||||
void Finalize(JSContext *aContext);
|
||||
|
||||
// Implementation for nsISupports
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID,
|
||||
void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
nsresult RenderFrame();
|
||||
|
||||
nsresult AddScriptEventListener(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
REFNSIID aIID);
|
||||
|
||||
void TriggerLink(nsIPresContext& aPresContext,
|
||||
const nsString& aBase,
|
||||
const nsString& aURLSpec,
|
||||
const nsString& aTargetSpec,
|
||||
PRBool aClick);
|
||||
|
||||
static void SetDocumentInChildrenOf(nsIContent* aContent,
|
||||
nsIDocument* aDocument);
|
||||
|
||||
static nsresult GetScriptObjectFactory(nsIDOMScriptObjectFactory **aFactory);
|
||||
|
||||
static nsIDOMScriptObjectFactory *gScriptObjectFactory;
|
||||
|
||||
nsDOMSlots *GetDOMSlots();
|
||||
|
||||
// Up pointer to the real content object that we are
|
||||
// supporting. Sometimes there is work that we just can't do
|
||||
// ourselves, so this is needed to ask the real object to do the
|
||||
// work.
|
||||
nsIContent* mContent;
|
||||
|
||||
nsIDocument* mDocument;
|
||||
nsIContent* mParent;
|
||||
nsIAtom* mTag;
|
||||
nsIEventListenerManager* mListenerManager;
|
||||
nsDOMSlots *mDOMSlots;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class nsGenericContainerElement : public nsGenericElement {
|
||||
public:
|
||||
nsGenericContainerElement();
|
||||
~nsGenericContainerElement();
|
||||
|
||||
nsresult CopyInnerTo(nsIContent* aSrcContent,
|
||||
nsGenericContainerElement* aDest);
|
||||
|
||||
// Remainder of nsIDOMHTMLElement (and nsIDOMNode)
|
||||
nsresult GetChildNodes(nsIDOMNodeList** aChildNodes);
|
||||
nsresult HasChildNodes(PRBool* aHasChildNodes);
|
||||
nsresult GetFirstChild(nsIDOMNode** aFirstChild);
|
||||
nsresult GetLastChild(nsIDOMNode** aLastChild);
|
||||
|
||||
nsresult InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn);
|
||||
nsresult ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
||||
nsIDOMNode** aReturn);
|
||||
nsresult RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn);
|
||||
nsresult AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn);
|
||||
|
||||
// Remainder of nsIContent
|
||||
nsresult SetAttribute(const nsString& aName, const nsString& aValue,
|
||||
PRBool aNotify);
|
||||
nsresult GetAttribute(const nsString& aName, nsString& aResult) const;
|
||||
nsresult UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify);
|
||||
nsresult GetAllAttributeNames(nsISupportsArray* aArray,
|
||||
PRInt32& aCount) const;
|
||||
nsresult GetAttributeCount(PRInt32& aResult) const;
|
||||
nsresult List(FILE* out, PRInt32 aIndent) const;
|
||||
nsresult SizeOf(nsISizeOfHandler* aHandler) const;
|
||||
nsresult CanContainChildren(PRBool& aResult) const;
|
||||
nsresult ChildCount(PRInt32& aResult) const;
|
||||
nsresult ChildAt(PRInt32 aIndex, nsIContent*& aResult) const;
|
||||
nsresult IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const;
|
||||
nsresult InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify);
|
||||
nsresult ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify);
|
||||
nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify);
|
||||
nsresult RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
|
||||
nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult ConvertContentToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult FinishConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
|
||||
void ListAttributes(FILE* out) const;
|
||||
|
||||
nsIHTMLAttributes* mAttributes;
|
||||
nsVoidArray mChildren;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Mostly implement the nsIDOMNode API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
* nsGenericHTMLContainerContent)
|
||||
*
|
||||
* Note that classes using this macro will need to implement:
|
||||
* NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
*/
|
||||
#define NS_IMPL_IDOMNODE_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetNodeName(nsString& aNodeName) { \
|
||||
return _g.GetNodeName(aNodeName); \
|
||||
} \
|
||||
NS_IMETHOD GetNodeValue(nsString& aNodeValue) { \
|
||||
return _g.GetNodeValue(aNodeValue); \
|
||||
} \
|
||||
NS_IMETHOD SetNodeValue(const nsString& aNodeValue) { \
|
||||
return _g.SetNodeValue(aNodeValue); \
|
||||
} \
|
||||
NS_IMETHOD GetNodeType(PRUint16* aNodeType) { \
|
||||
return _g.GetNodeType(aNodeType); \
|
||||
} \
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode) { \
|
||||
return _g.GetParentNode(aParentNode); \
|
||||
} \
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes) { \
|
||||
return _g.GetChildNodes(aChildNodes); \
|
||||
} \
|
||||
NS_IMETHOD HasChildNodes(PRBool* aHasChildNodes) { \
|
||||
return _g.HasChildNodes(aHasChildNodes); \
|
||||
} \
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild) { \
|
||||
return _g.GetFirstChild(aFirstChild); \
|
||||
} \
|
||||
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild) { \
|
||||
return _g.GetLastChild(aLastChild); \
|
||||
} \
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling) { \
|
||||
return _g.GetPreviousSibling(aPreviousSibling); \
|
||||
} \
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling) { \
|
||||
return _g.GetNextSibling(aNextSibling); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes) { \
|
||||
return _g.GetAttributes(aAttributes); \
|
||||
} \
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, \
|
||||
nsIDOMNode** aReturn) { \
|
||||
return _g.InsertBefore(aNewChild, aRefChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD AppendChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \
|
||||
return _g.AppendChild(aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, \
|
||||
nsIDOMNode** aReturn) { \
|
||||
return _g.ReplaceChild(aNewChild, aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \
|
||||
return _g.RemoveChild(aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument) { \
|
||||
return _g.GetOwnerDocument(aOwnerDocument); \
|
||||
} \
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
|
||||
/**
|
||||
* Implement the nsIDOMElement API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
* nsGenericHTMLContainerContent)
|
||||
*/
|
||||
#define NS_IMPL_IDOMELEMENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetTagName(nsString& aTagName) { \
|
||||
return _g.GetTagName(aTagName); \
|
||||
} \
|
||||
NS_IMETHOD GetDOMAttribute(const nsString& aName, nsString& aReturn) { \
|
||||
return _g.GetDOMAttribute(aName, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD SetDOMAttribute(const nsString& aName, const nsString& aValue) { \
|
||||
return _g.SetDOMAttribute(aName, aValue); \
|
||||
} \
|
||||
NS_IMETHOD RemoveAttribute(const nsString& aName) { \
|
||||
return _g.RemoveAttribute(aName); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeNode(const nsString& aName, \
|
||||
nsIDOMAttr** aReturn) { \
|
||||
return _g.GetAttributeNode(aName, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD SetAttributeNode(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn) { \
|
||||
return _g.SetAttributeNode(aNewAttr, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD RemoveAttributeNode(nsIDOMAttr* aOldAttr, nsIDOMAttr** aReturn) {\
|
||||
return _g.RemoveAttributeNode(aOldAttr, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD GetElementsByTagName(const nsString& aTagname, \
|
||||
nsIDOMNodeList** aReturn) { \
|
||||
return _g.GetElementsByTagName(aTagname, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD Normalize() { \
|
||||
return _g.Normalize(); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement the nsIDOMEventReceiver API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
* nsGenericHTMLContainerContent)
|
||||
*/
|
||||
#define NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(_g) \
|
||||
NS_IMETHOD AddEventListener(nsIDOMEventListener *aListener, \
|
||||
const nsIID& aIID) { \
|
||||
return _g.AddEventListener(aListener, aIID); \
|
||||
} \
|
||||
NS_IMETHOD RemoveEventListener(nsIDOMEventListener *aListener, \
|
||||
const nsIID& aIID) { \
|
||||
return _g.RemoveEventListener(aListener, aIID); \
|
||||
} \
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aResult) { \
|
||||
return _g.GetListenerManager(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetNewListenerManager(nsIEventListenerManager** aResult) { \
|
||||
return _g.GetNewListenerManager(aResult); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_ICONTENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \
|
||||
return _g.GetDocument(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { \
|
||||
return _g.SetDocument(aDocument, aDeep); \
|
||||
} \
|
||||
NS_IMETHOD GetParent(nsIContent*& aResult) const { \
|
||||
return _g.GetParent(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetParent(nsIContent* aParent) { \
|
||||
return _g.SetParent(aParent); \
|
||||
} \
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const { \
|
||||
return _g.CanContainChildren(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const { \
|
||||
return _g.ChildCount(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const { \
|
||||
return _g.ChildAt(aIndex, aResult); \
|
||||
} \
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const { \
|
||||
return _g.IndexOf(aPossibleChild, aResult); \
|
||||
} \
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, \
|
||||
PRBool aNotify) { \
|
||||
return _g.InsertChildAt(aKid, aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, \
|
||||
PRBool aNotify) { \
|
||||
return _g.ReplaceChildAt(aKid, aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) { \
|
||||
return _g.AppendChildTo(aKid, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { \
|
||||
return _g.RemoveChildAt(aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD IsSynthetic(PRBool& aResult) { \
|
||||
return _g.IsSynthetic(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const { \
|
||||
return _g.GetTag(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetAttribute(const nsString& aName, const nsString& aValue, \
|
||||
PRBool aNotify) { \
|
||||
return _g.SetAttribute(aName, aValue, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetAttribute(const nsString& aName, \
|
||||
nsString& aResult) const { \
|
||||
return _g.GetAttribute(aName, aResult); \
|
||||
} \
|
||||
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify) { \
|
||||
return _g.UnsetAttribute(aAttribute, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, \
|
||||
PRInt32& aResult) const { \
|
||||
return _g.GetAllAttributeNames(aArray, aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { \
|
||||
return _g.GetAttributeCount(aResult); \
|
||||
} \
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const { \
|
||||
return _g.List(out, aIndent); \
|
||||
} \
|
||||
NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.BeginConvertToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.ConvertContentToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.FinishConvertToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const { \
|
||||
return _g.SizeOf(aHandler); \
|
||||
} \
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext, \
|
||||
nsEvent* aEvent, \
|
||||
nsIDOMEvent** aDOMEvent, \
|
||||
PRUint32 aFlags, \
|
||||
nsEventStatus& aEventStatus);
|
||||
|
||||
#define NS_IMPL_CONTENT_QUERY_INTERFACE(_id, _iptr, _this, _base) \
|
||||
if (_id.Equals(kISupportsIID)) { \
|
||||
_base* tmp = _this; \
|
||||
nsISupports* tmp2 = tmp; \
|
||||
*_iptr = (void*) tmp2; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIDOMNodeIID)) { \
|
||||
nsIDOMNode* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIDOMElementIID)) { \
|
||||
nsIDOMElement* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIDOMEventReceiverIID)) { \
|
||||
nsIDOMEventReceiver* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIScriptObjectOwnerIID)) { \
|
||||
nsIScriptObjectOwner* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIContentIID)) { \
|
||||
_base* tmp = _this; \
|
||||
nsIContent* tmp2 = tmp; \
|
||||
*_iptr = (void*) tmp2; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIJSScriptObjectIID)) { \
|
||||
nsIJSScriptObject* tmp = (nsIJSScriptObject*)&mInner; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
#endif /* nsGenericElement_h___ */
|
File diff suppressed because it is too large
Load Diff
@ -19,20 +19,14 @@
|
||||
#ifndef nsGenericHTMLElement_h___
|
||||
#define nsGenericHTMLElement_h___
|
||||
|
||||
#include "nsGenericElement.h"
|
||||
#include "nsIDOMHTMLElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsHTMLValue.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
|
||||
extern const nsIID kIDOMNodeIID;
|
||||
extern const nsIID kIDOMElementIID;
|
||||
extern const nsIID kIDOMHTMLElementIID;
|
||||
extern const nsIID kIDOMEventReceiverIID;
|
||||
extern const nsIID kIScriptObjectOwnerIID;
|
||||
extern const nsIID kIJSScriptObjectIID;
|
||||
extern const nsIID kISupportsIID;
|
||||
extern const nsIID kIContentIID;
|
||||
extern const nsIID kIHTMLContentIID;
|
||||
|
||||
class nsIDOMAttr;
|
||||
@ -50,49 +44,11 @@ class nsChildContentList;
|
||||
class nsDOMCSSDeclaration;
|
||||
class nsIDOMCSSStyleDeclaration;
|
||||
|
||||
// There are a set of DOM- and scripting-specific instance variables
|
||||
// that may only be instantiated when a content object is accessed
|
||||
// through the DOM. Rather than burn actual slots in the content
|
||||
// objects for each of these instance variables, we put them off
|
||||
// in a side structure that's only allocated when the content is
|
||||
// accessed through the DOM.
|
||||
typedef struct {
|
||||
void *mScriptObject;
|
||||
nsChildContentList *mChildNodes;
|
||||
nsDOMCSSDeclaration *mStyle;
|
||||
} nsDOMSlots;
|
||||
|
||||
class nsGenericHTMLElement : public nsIJSScriptObject {
|
||||
class nsGenericHTMLElement : public nsGenericElement {
|
||||
public:
|
||||
nsGenericHTMLElement();
|
||||
~nsGenericHTMLElement();
|
||||
|
||||
void Init(nsIHTMLContent* aOuterContentObject, nsIAtom* aTag);
|
||||
|
||||
// Implementation for nsIDOMNode
|
||||
nsresult GetNodeName(nsString& aNodeName);
|
||||
nsresult GetNodeValue(nsString& aNodeValue);
|
||||
nsresult SetNodeValue(const nsString& aNodeValue);
|
||||
nsresult GetNodeType(PRUint16* aNodeType);
|
||||
nsresult GetParentNode(nsIDOMNode** aParentNode);
|
||||
nsresult GetAttributes(nsIDOMNamedNodeMap** aAttributes);
|
||||
nsresult GetPreviousSibling(nsIDOMNode** aPreviousSibling);
|
||||
nsresult GetNextSibling(nsIDOMNode** aNextSibling);
|
||||
nsresult GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
|
||||
|
||||
// Implementation for nsIDOMElement
|
||||
nsresult GetTagName(nsString& aTagName);
|
||||
nsresult GetDOMAttribute(const nsString& aName, nsString& aReturn);
|
||||
nsresult SetDOMAttribute(const nsString& aName, const nsString& aValue);
|
||||
nsresult RemoveAttribute(const nsString& aName);
|
||||
nsresult GetAttributeNode(const nsString& aName,
|
||||
nsIDOMAttr** aReturn);
|
||||
nsresult SetAttributeNode(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn);
|
||||
nsresult RemoveAttributeNode(nsIDOMAttr* aOldAttr, nsIDOMAttr** aReturn);
|
||||
nsresult GetElementsByTagName(const nsString& aTagname,
|
||||
nsIDOMNodeList** aReturn);
|
||||
nsresult Normalize();
|
||||
|
||||
// Implementation for nsIDOMHTMLElement
|
||||
nsresult GetId(nsString& aId);
|
||||
nsresult SetId(const nsString& aId);
|
||||
@ -106,36 +62,16 @@ public:
|
||||
nsresult SetClassName(const nsString& aClassName);
|
||||
nsresult GetStyle(nsIDOMCSSStyleDeclaration** aStyle);
|
||||
|
||||
// nsIDOMEventReceiver interface
|
||||
nsresult AddEventListener(nsIDOMEventListener *aListener, const nsIID& aIID);
|
||||
nsresult RemoveEventListener(nsIDOMEventListener* aListener,
|
||||
const nsIID& aIID);
|
||||
nsresult GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
nsresult GetNewListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
|
||||
// nsIScriptObjectOwner interface
|
||||
nsresult GetScriptObject(nsIScriptContext* aContext, void** aScriptObject);
|
||||
nsresult SetScriptObject(void *aScriptObject);
|
||||
|
||||
// Implementation for nsIContent
|
||||
nsresult GetDocument(nsIDocument*& aResult) const;
|
||||
nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep);
|
||||
nsresult GetParent(nsIContent*& aResult) const;
|
||||
nsresult SetParent(nsIContent* aParent);
|
||||
nsresult IsSynthetic(PRBool& aResult) {
|
||||
aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult GetTag(nsIAtom*& aResult) const;
|
||||
nsresult SetAttribute(const nsString& aName, const nsString& aValue,
|
||||
PRBool aNotify);
|
||||
nsresult GetAttribute(const nsString& aName, nsString& aResult) const;
|
||||
nsresult UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify);
|
||||
nsresult GetAllAttributeNames(nsISupportsArray* aArray,
|
||||
PRInt32& aCount) const;
|
||||
nsresult GetAttributeCount(PRInt32& aResult) const;
|
||||
nsresult List(FILE* out, PRInt32 aIndent) const;
|
||||
nsresult HandleDOMEvent(nsIPresContext& aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus& aEventStatus);
|
||||
|
||||
// Implementation for nsIHTMLContent
|
||||
nsresult Compact();
|
||||
@ -143,12 +79,8 @@ public:
|
||||
PRBool aNotify);
|
||||
nsresult SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue,
|
||||
PRBool aNotify);
|
||||
nsresult UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify);
|
||||
nsresult GetAttribute(nsIAtom *aAttribute, nsString &aResult) const;
|
||||
nsresult GetAttribute(nsIAtom* aAttribute, nsHTMLValue& aValue) const;
|
||||
nsresult GetAllAttributeNames(nsISupportsArray* aArray,
|
||||
PRInt32& aCount) const;
|
||||
nsresult GetAttributeCount(PRInt32& aResult) const;
|
||||
nsresult SetID(nsIAtom* aID);
|
||||
nsresult GetID(nsIAtom*& aResult) const;
|
||||
nsresult SetClass(nsIAtom* aClass);
|
||||
@ -157,41 +89,13 @@ public:
|
||||
nsresult ToHTMLString(nsString& aResult) const;
|
||||
nsresult ToHTML(FILE* out) const;
|
||||
|
||||
// Implementation for nsIJSScriptObject
|
||||
virtual PRBool AddProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
virtual PRBool DeleteProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
virtual PRBool GetProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
virtual PRBool SetProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
virtual PRBool EnumerateProperty(JSContext *aContext);
|
||||
virtual PRBool Resolve(JSContext *aContext, jsval aID);
|
||||
virtual PRBool Convert(JSContext *aContext, jsval aID);
|
||||
virtual void Finalize(JSContext *aContext);
|
||||
|
||||
// Implementation for nsISupports
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID,
|
||||
void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
nsresult RenderFrame();
|
||||
|
||||
nsresult AddScriptEventListener(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
REFNSIID aIID);
|
||||
|
||||
nsresult AttributeToString(nsIAtom* aAttribute,
|
||||
nsHTMLValue& aValue,
|
||||
nsString& aResult) const;
|
||||
|
||||
void ListAttributes(FILE* out) const;
|
||||
|
||||
void TriggerLink(nsIPresContext& aPresContext,
|
||||
const nsString& aBase,
|
||||
const nsString& aURLSpec,
|
||||
const nsString& aTargetSpec,
|
||||
PRBool aClick);
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
@ -308,24 +212,7 @@ public:
|
||||
const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
|
||||
static nsresult GetScriptObjectFactory(nsIDOMScriptObjectFactory **aFactory);
|
||||
|
||||
static nsIDOMScriptObjectFactory *gScriptObjectFactory;
|
||||
|
||||
nsDOMSlots *GetDOMSlots();
|
||||
|
||||
// Up pointer to the real content object that we are
|
||||
// supporting. Sometimes there is work that we just can't do
|
||||
// ourselves, so this is needed to ask the real object to do the
|
||||
// work.
|
||||
nsIHTMLContent* mContent;
|
||||
|
||||
nsIDocument* mDocument;
|
||||
nsIContent* mParent;
|
||||
nsIHTMLAttributes* mAttributes;
|
||||
nsIAtom* mTag;
|
||||
nsIEventListenerManager* mListenerManager;
|
||||
nsDOMSlots *mDOMSlots;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -335,7 +222,7 @@ public:
|
||||
nsGenericHTMLLeafElement();
|
||||
~nsGenericHTMLLeafElement();
|
||||
|
||||
nsresult CopyInnerTo(nsIHTMLContent* aSrcContent,
|
||||
nsresult CopyInnerTo(nsIContent* aSrcContent,
|
||||
nsGenericHTMLLeafElement* aDest);
|
||||
|
||||
// Remainder of nsIDOMHTMLElement (and nsIDOMNode)
|
||||
@ -368,13 +255,13 @@ public:
|
||||
}
|
||||
|
||||
// Remainder of nsIHTMLContent (and nsIContent)
|
||||
nsresult SizeOf(nsISizeOfHandler* aHandler) const;
|
||||
nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult ConvertContentToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult FinishConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult Compact() {
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult SizeOf(nsISizeOfHandler* aHandler) const;
|
||||
nsresult CanContainChildren(PRBool& aResult) const {
|
||||
aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
@ -412,7 +299,7 @@ public:
|
||||
nsGenericHTMLContainerElement();
|
||||
~nsGenericHTMLContainerElement();
|
||||
|
||||
nsresult CopyInnerTo(nsIHTMLContent* aSrcContent,
|
||||
nsresult CopyInnerTo(nsIContent* aSrcContent,
|
||||
nsGenericHTMLContainerElement* aDest);
|
||||
|
||||
// Remainder of nsIDOMHTMLElement (and nsIDOMNode)
|
||||
@ -420,6 +307,7 @@ public:
|
||||
nsresult HasChildNodes(PRBool* aHasChildNodes);
|
||||
nsresult GetFirstChild(nsIDOMNode** aFirstChild);
|
||||
nsresult GetLastChild(nsIDOMNode** aLastChild);
|
||||
|
||||
nsresult InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn);
|
||||
nsresult ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
||||
@ -428,11 +316,11 @@ public:
|
||||
nsresult AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn);
|
||||
|
||||
// Remainder of nsIHTMLContent (and nsIContent)
|
||||
nsresult SizeOf(nsISizeOfHandler* aHandler) const;
|
||||
nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult ConvertContentToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult FinishConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult Compact();
|
||||
nsresult SizeOf(nsISizeOfHandler* aHandler) const;
|
||||
nsresult CanContainChildren(PRBool& aResult) const;
|
||||
nsresult ChildCount(PRInt32& aResult) const;
|
||||
nsresult ChildAt(PRInt32 aIndex, nsIContent*& aResult) const;
|
||||
@ -447,106 +335,6 @@ public:
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Mostly implement the nsIDOMNode API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
* nsGenericHTMLContainerContent)
|
||||
*
|
||||
* Note that classes using this macro will need to implement:
|
||||
* NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
*/
|
||||
#define NS_IMPL_IDOMNODE_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetNodeName(nsString& aNodeName) { \
|
||||
return _g.GetNodeName(aNodeName); \
|
||||
} \
|
||||
NS_IMETHOD GetNodeValue(nsString& aNodeValue) { \
|
||||
return _g.GetNodeValue(aNodeValue); \
|
||||
} \
|
||||
NS_IMETHOD SetNodeValue(const nsString& aNodeValue) { \
|
||||
return _g.SetNodeValue(aNodeValue); \
|
||||
} \
|
||||
NS_IMETHOD GetNodeType(PRUint16* aNodeType) { \
|
||||
return _g.GetNodeType(aNodeType); \
|
||||
} \
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode) { \
|
||||
return _g.GetParentNode(aParentNode); \
|
||||
} \
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes) { \
|
||||
return _g.GetChildNodes(aChildNodes); \
|
||||
} \
|
||||
NS_IMETHOD HasChildNodes(PRBool* aHasChildNodes) { \
|
||||
return _g.HasChildNodes(aHasChildNodes); \
|
||||
} \
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild) { \
|
||||
return _g.GetFirstChild(aFirstChild); \
|
||||
} \
|
||||
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild) { \
|
||||
return _g.GetLastChild(aLastChild); \
|
||||
} \
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling) { \
|
||||
return _g.GetPreviousSibling(aPreviousSibling); \
|
||||
} \
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling) { \
|
||||
return _g.GetNextSibling(aNextSibling); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes) { \
|
||||
return _g.GetAttributes(aAttributes); \
|
||||
} \
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, \
|
||||
nsIDOMNode** aReturn) { \
|
||||
return _g.InsertBefore(aNewChild, aRefChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD AppendChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \
|
||||
return _g.AppendChild(aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, \
|
||||
nsIDOMNode** aReturn) { \
|
||||
return _g.ReplaceChild(aNewChild, aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \
|
||||
return _g.RemoveChild(aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument) { \
|
||||
return _g.GetOwnerDocument(aOwnerDocument); \
|
||||
} \
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
|
||||
/**
|
||||
* Implement the nsIDOMElement API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
* nsGenericHTMLContainerContent)
|
||||
*/
|
||||
#define NS_IMPL_IDOMELEMENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetTagName(nsString& aTagName) { \
|
||||
return _g.GetTagName(aTagName); \
|
||||
} \
|
||||
NS_IMETHOD GetDOMAttribute(const nsString& aName, nsString& aReturn) { \
|
||||
return _g.GetDOMAttribute(aName, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD SetDOMAttribute(const nsString& aName, const nsString& aValue) { \
|
||||
return _g.SetDOMAttribute(aName, aValue); \
|
||||
} \
|
||||
NS_IMETHOD RemoveAttribute(const nsString& aName) { \
|
||||
return _g.RemoveAttribute(aName); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeNode(const nsString& aName, \
|
||||
nsIDOMAttr** aReturn) { \
|
||||
return _g.GetAttributeNode(aName, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD SetAttributeNode(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn) { \
|
||||
return _g.SetAttributeNode(aNewAttr, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD RemoveAttributeNode(nsIDOMAttr* aOldAttr, nsIDOMAttr** aReturn) {\
|
||||
return _g.RemoveAttributeNode(aOldAttr, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD GetElementsByTagName(const nsString& aTagname, \
|
||||
nsIDOMNodeList** aReturn) { \
|
||||
return _g.GetElementsByTagName(aTagname, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD Normalize() { \
|
||||
return _g.Normalize(); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement the nsIDOMHTMLElement API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
@ -587,27 +375,6 @@ public:
|
||||
return _g.GetStyle(aStyle); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement the nsIDOMEventReceiver API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
* nsGenericHTMLContainerContent)
|
||||
*/
|
||||
#define NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(_g) \
|
||||
NS_IMETHOD AddEventListener(nsIDOMEventListener *aListener, \
|
||||
const nsIID& aIID) { \
|
||||
return _g.AddEventListener(aListener, aIID); \
|
||||
} \
|
||||
NS_IMETHOD RemoveEventListener(nsIDOMEventListener *aListener, \
|
||||
const nsIID& aIID) { \
|
||||
return _g.RemoveEventListener(aListener, aIID); \
|
||||
} \
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aResult) { \
|
||||
return _g.GetListenerManager(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetNewListenerManager(nsIEventListenerManager** aResult) { \
|
||||
return _g.GetNewListenerManager(aResult); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement the nsIScriptObjectOwner API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
@ -622,79 +389,6 @@ public:
|
||||
return _g.SetScriptObject(aScriptObject); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_ICONTENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \
|
||||
return _g.GetDocument(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { \
|
||||
return _g.SetDocument(aDocument, aDeep); \
|
||||
} \
|
||||
NS_IMETHOD GetParent(nsIContent*& aResult) const { \
|
||||
return _g.GetParent(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetParent(nsIContent* aParent) { \
|
||||
return _g.SetParent(aParent); \
|
||||
} \
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const { \
|
||||
return _g.CanContainChildren(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const { \
|
||||
return _g.ChildCount(aResult); \
|
||||
} \
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const { \
|
||||
return _g.ChildAt(aIndex, aResult); \
|
||||
} \
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const { \
|
||||
return _g.IndexOf(aPossibleChild, aResult); \
|
||||
} \
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, \
|
||||
PRBool aNotify) { \
|
||||
return _g.InsertChildAt(aKid, aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, \
|
||||
PRBool aNotify) { \
|
||||
return _g.ReplaceChildAt(aKid, aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) { \
|
||||
return _g.AppendChildTo(aKid, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { \
|
||||
return _g.RemoveChildAt(aIndex, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD IsSynthetic(PRBool& aResult) { \
|
||||
return _g.IsSynthetic(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const { \
|
||||
return _g.GetTag(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetAttribute(const nsString& aName, const nsString& aValue, \
|
||||
PRBool aNotify) { \
|
||||
return _g.SetAttribute(aName, aValue, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetAttribute(const nsString& aName, \
|
||||
nsString& aResult) const { \
|
||||
return _g.GetAttribute(aName, aResult); \
|
||||
} \
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const { \
|
||||
return _g.List(out, aIndent); \
|
||||
} \
|
||||
NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.BeginConvertToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.ConvertContentToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const { \
|
||||
return _g.FinishConvertToXIF(aConverter); \
|
||||
} \
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const { \
|
||||
return _g.SizeOf(aHandler); \
|
||||
} \
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext, \
|
||||
nsEvent* aEvent, \
|
||||
nsIDOMEvent** aDOMEvent, \
|
||||
PRUint32 aFlags, \
|
||||
nsEventStatus& aEventStatus);
|
||||
|
||||
#define NS_IMPL_IHTMLCONTENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD Compact() { \
|
||||
@ -708,9 +402,6 @@ public:
|
||||
const nsHTMLValue& aValue, PRBool aNotify) { \
|
||||
return _g.SetAttribute(aAttribute, aValue, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify) { \
|
||||
return _g.UnsetAttribute(aAttribute, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetAttribute(nsIAtom *aAttribute, \
|
||||
nsString &aResult) const { \
|
||||
return _g.GetAttribute(aAttribute, aResult); \
|
||||
@ -719,13 +410,6 @@ public:
|
||||
nsHTMLValue& aValue) const { \
|
||||
return _g.GetAttribute(aAttribute, aValue); \
|
||||
} \
|
||||
NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, \
|
||||
PRInt32& aResult) const { \
|
||||
return _g.GetAllAttributeNames(aArray, aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { \
|
||||
return _g.GetAttributeCount(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetID(nsIAtom* aID) { \
|
||||
return _g.SetID(aID); \
|
||||
} \
|
||||
@ -767,9 +451,6 @@ public:
|
||||
const nsHTMLValue& aValue, PRBool aNotify) { \
|
||||
return _g.SetAttribute(aAttribute, aValue, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify) { \
|
||||
return _g.UnsetAttribute(aAttribute, aNotify); \
|
||||
} \
|
||||
NS_IMETHOD GetAttribute(nsIAtom *aAttribute, \
|
||||
nsString &aResult) const { \
|
||||
return _g.GetAttribute(aAttribute, aResult); \
|
||||
@ -778,13 +459,6 @@ public:
|
||||
nsHTMLValue& aValue) const { \
|
||||
return _g.GetAttribute(aAttribute, aValue); \
|
||||
} \
|
||||
NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, \
|
||||
PRInt32& aResult) const { \
|
||||
return _g.GetAllAttributeNames(aArray, aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { \
|
||||
return _g.GetAttributeCount(aResult); \
|
||||
} \
|
||||
NS_IMETHOD SetID(nsIAtom* aID) { \
|
||||
return _g.SetID(aID); \
|
||||
} \
|
||||
@ -817,61 +491,19 @@ public:
|
||||
* generic to all html content objects.
|
||||
*/
|
||||
#define NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(_id, _iptr, _this) \
|
||||
if (_id.Equals(kISupportsIID)) { \
|
||||
nsIHTMLContent* tmp = _this; \
|
||||
nsISupports* tmp2 = tmp; \
|
||||
*_iptr = (void*) tmp2; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIDOMNodeIID)) { \
|
||||
nsIDOMNode* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIDOMElementIID)) { \
|
||||
nsIDOMElement* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMPL_CONTENT_QUERY_INTERFACE(_id, _iptr, _this, nsIHTMLContent) \
|
||||
if (_id.Equals(kIDOMHTMLElementIID)) { \
|
||||
nsIDOMHTMLElement* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIDOMEventReceiverIID)) { \
|
||||
nsIDOMEventReceiver* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIScriptObjectOwnerIID)) { \
|
||||
nsIScriptObjectOwner* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIContentIID)) { \
|
||||
nsIContent* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIHTMLContentIID)) { \
|
||||
nsIHTMLContent* tmp = _this; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (_id.Equals(kIJSScriptObjectIID)) { \
|
||||
nsIJSScriptObject* tmp = (nsIJSScriptObject*)&mInner; \
|
||||
*_iptr = (void*) tmp; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given string
|
||||
|
@ -165,6 +165,7 @@ public:
|
||||
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
|
||||
NS_IMETHOD NotifyError(nsresult aErrorResult);
|
||||
NS_IMETHOD AddComment(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
|
||||
|
||||
@ -2393,3 +2394,12 @@ HTMLContentSink::LoadStyleSheet(nsIURL* aURL,
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLContentSink::NotifyError(nsresult aErrorResult)
|
||||
{
|
||||
// Errors in HTML? Who would have thought!
|
||||
// Why are you telling us, parser. Deal with it yourself.
|
||||
PR_ASSERT(0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -428,30 +428,16 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIWebShell* webShell;
|
||||
|
||||
// Delete references to style sheets - this should be done in superclass...
|
||||
PRInt32 index = mStyleSheets.Count();
|
||||
while (--index >= 0) {
|
||||
nsIStyleSheet* sheet = (nsIStyleSheet*) mStyleSheets.ElementAt(index);
|
||||
NS_RELEASE(sheet);
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aURL, aContainer,
|
||||
aDocListener);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mStyleSheets.Clear();
|
||||
|
||||
nsIWebShell* webShell;
|
||||
|
||||
NS_IF_RELEASE(mAttrStyleSheet);
|
||||
NS_IF_RELEASE(mStyleAttrStyleSheet);
|
||||
NS_IF_RELEASE(mDocumentURL);
|
||||
NS_IF_RELEASE(mDocumentURLGroup);
|
||||
if (nsnull != mDocumentTitle) {
|
||||
delete mDocumentTitle;
|
||||
mDocumentTitle = nsnull;
|
||||
}
|
||||
|
||||
mDocumentURL = aURL;
|
||||
NS_ADDREF(aURL);
|
||||
|
||||
mDocumentURLGroup = aURL->GetURLGroup();
|
||||
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsTableOuterFrame.h"
|
||||
#include "nsIXMLDocument.h"
|
||||
#include "nsIWebShell.h"
|
||||
|
||||
static NS_DEFINE_IID(kIHTMLStyleSheetIID, NS_IHTML_STYLE_SHEET_IID);
|
||||
@ -48,6 +49,7 @@ static NS_DEFINE_IID(kIStyleSheetIID, NS_ISTYLE_SHEET_IID);
|
||||
static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID);
|
||||
static NS_DEFINE_IID(kIStyleFrameConstructionIID, NS_ISTYLE_FRAME_CONSTRUCTION_IID);
|
||||
static NS_DEFINE_IID(kIHTMLTableCellElementIID, NS_IHTMLTABLECELLELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIXMLDocumentIID, NS_IXMLDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
||||
|
||||
class HTMLAnchorRule : public nsIStyleRule {
|
||||
@ -298,6 +300,11 @@ protected:
|
||||
nsIStyleContext* aStyleContext,
|
||||
nsIFrame*& aNewFrame);
|
||||
|
||||
nsresult ConstructXMLRootFrames(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIStyleContext* aStyleContext,
|
||||
nsIFrame*& aNewFrame);
|
||||
|
||||
nsresult ConstructTableFrame(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIFrame* aParentFrame,
|
||||
@ -1119,6 +1126,66 @@ HTMLStyleSheetImpl::ConstructRootFrame(nsIPresContext* aPresContext,
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
HTMLStyleSheetImpl::ConstructXMLRootFrames(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIStyleContext* aStyleContext,
|
||||
nsIFrame*& aNewFrame)
|
||||
{
|
||||
// Create the root frame
|
||||
nsresult rv = NS_NewHTMLFrame(aContent, nsnull, aNewFrame);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Bind root frame to root view (and root window)
|
||||
nsIPresShell* presShell = aPresContext->GetShell();
|
||||
nsIViewManager* viewManager = presShell->GetViewManager();
|
||||
nsIView* rootView;
|
||||
|
||||
NS_RELEASE(presShell);
|
||||
viewManager->GetRootView(rootView);
|
||||
aNewFrame->SetView(rootView);
|
||||
NS_RELEASE(viewManager);
|
||||
|
||||
// Set the style context
|
||||
aNewFrame->SetStyleContext(aPresContext, aStyleContext);
|
||||
|
||||
// Wrap the document element in a scroll frame
|
||||
nsIFrame* scrollFrame;
|
||||
|
||||
if (NS_SUCCEEDED(NS_NewScrollFrame(aContent, aNewFrame, scrollFrame))) {
|
||||
// The scroll frame gets the original style context, and the scrolled
|
||||
// frame gets a SCROLLED-CONTENT pseudo element style context.
|
||||
scrollFrame->SetStyleContext(aPresContext, aStyleContext);
|
||||
|
||||
nsIStyleContext* scrolledPseudoStyle;
|
||||
nsIFrame* wrapperFrame;
|
||||
|
||||
scrolledPseudoStyle = aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent,
|
||||
nsHTMLAtoms::scrolledContentPseudo,
|
||||
aStyleContext);
|
||||
|
||||
// Create a body frame to wrap the document element
|
||||
NS_NewBodyFrame(aContent, scrollFrame,
|
||||
wrapperFrame, NS_BODY_SHRINK_WRAP);
|
||||
wrapperFrame->SetStyleContext(aPresContext, scrolledPseudoStyle);
|
||||
|
||||
// Process the child content, and set the frame's initial child list
|
||||
nsIFrame* childList;
|
||||
rv = ProcessChildren(aPresContext, wrapperFrame, aContent, childList);
|
||||
wrapperFrame->SetInitialChildList(*aPresContext, nsnull, childList);
|
||||
|
||||
// Set the scroll frame's initial child list
|
||||
scrollFrame->SetInitialChildList(*aPresContext, nsnull, wrapperFrame);
|
||||
}
|
||||
|
||||
// initialize the root frame
|
||||
aNewFrame->SetInitialChildList(*aPresContext, nsnull, scrollFrame);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -1466,10 +1533,28 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
|
||||
else {
|
||||
// Create a frame.
|
||||
if (nsnull == aParentFrame) {
|
||||
// Construct the root frame object
|
||||
rv = ConstructRootFrame(aPresContext, aContent, styleContext,
|
||||
aFrameSubTree);
|
||||
|
||||
nsIDocument* document;
|
||||
rv = aContent->GetDocument(document);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(styleContext);
|
||||
return rv;
|
||||
}
|
||||
if (nsnull != document) {
|
||||
nsIXMLDocument* xmlDocument;
|
||||
rv = document->QueryInterface(kIXMLDocumentIID, (void **)&xmlDocument);
|
||||
if (NS_FAILED(rv)) {
|
||||
// Construct the root frame object
|
||||
rv = ConstructRootFrame(aPresContext, aContent, styleContext,
|
||||
aFrameSubTree);
|
||||
}
|
||||
else {
|
||||
// Construct the root frame object for XML
|
||||
rv = ConstructXMLRootFrames(aPresContext, aContent, styleContext,
|
||||
aFrameSubTree);
|
||||
NS_RELEASE(xmlDocument);
|
||||
}
|
||||
NS_RELEASE(document);
|
||||
}
|
||||
} else {
|
||||
// If the frame is a block-level frame and is scrollable then wrap it
|
||||
// in a scroll frame.
|
||||
|
@ -17,6 +17,6 @@
|
||||
|
||||
DEPTH=..
|
||||
|
||||
DIRS=base html events build
|
||||
DIRS=base html xml events build
|
||||
|
||||
include <$(DEPTH)\layout\config\rules.mak>
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsTableOuterFrame.h"
|
||||
#include "nsIXMLDocument.h"
|
||||
#include "nsIWebShell.h"
|
||||
|
||||
static NS_DEFINE_IID(kIHTMLStyleSheetIID, NS_IHTML_STYLE_SHEET_IID);
|
||||
@ -48,6 +49,7 @@ static NS_DEFINE_IID(kIStyleSheetIID, NS_ISTYLE_SHEET_IID);
|
||||
static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID);
|
||||
static NS_DEFINE_IID(kIStyleFrameConstructionIID, NS_ISTYLE_FRAME_CONSTRUCTION_IID);
|
||||
static NS_DEFINE_IID(kIHTMLTableCellElementIID, NS_IHTMLTABLECELLELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIXMLDocumentIID, NS_IXMLDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
||||
|
||||
class HTMLAnchorRule : public nsIStyleRule {
|
||||
@ -298,6 +300,11 @@ protected:
|
||||
nsIStyleContext* aStyleContext,
|
||||
nsIFrame*& aNewFrame);
|
||||
|
||||
nsresult ConstructXMLRootFrames(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIStyleContext* aStyleContext,
|
||||
nsIFrame*& aNewFrame);
|
||||
|
||||
nsresult ConstructTableFrame(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIFrame* aParentFrame,
|
||||
@ -1119,6 +1126,66 @@ HTMLStyleSheetImpl::ConstructRootFrame(nsIPresContext* aPresContext,
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
HTMLStyleSheetImpl::ConstructXMLRootFrames(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIStyleContext* aStyleContext,
|
||||
nsIFrame*& aNewFrame)
|
||||
{
|
||||
// Create the root frame
|
||||
nsresult rv = NS_NewHTMLFrame(aContent, nsnull, aNewFrame);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Bind root frame to root view (and root window)
|
||||
nsIPresShell* presShell = aPresContext->GetShell();
|
||||
nsIViewManager* viewManager = presShell->GetViewManager();
|
||||
nsIView* rootView;
|
||||
|
||||
NS_RELEASE(presShell);
|
||||
viewManager->GetRootView(rootView);
|
||||
aNewFrame->SetView(rootView);
|
||||
NS_RELEASE(viewManager);
|
||||
|
||||
// Set the style context
|
||||
aNewFrame->SetStyleContext(aPresContext, aStyleContext);
|
||||
|
||||
// Wrap the document element in a scroll frame
|
||||
nsIFrame* scrollFrame;
|
||||
|
||||
if (NS_SUCCEEDED(NS_NewScrollFrame(aContent, aNewFrame, scrollFrame))) {
|
||||
// The scroll frame gets the original style context, and the scrolled
|
||||
// frame gets a SCROLLED-CONTENT pseudo element style context.
|
||||
scrollFrame->SetStyleContext(aPresContext, aStyleContext);
|
||||
|
||||
nsIStyleContext* scrolledPseudoStyle;
|
||||
nsIFrame* wrapperFrame;
|
||||
|
||||
scrolledPseudoStyle = aPresContext->ResolvePseudoStyleContextFor
|
||||
(aContent,
|
||||
nsHTMLAtoms::scrolledContentPseudo,
|
||||
aStyleContext);
|
||||
|
||||
// Create a body frame to wrap the document element
|
||||
NS_NewBodyFrame(aContent, scrollFrame,
|
||||
wrapperFrame, NS_BODY_SHRINK_WRAP);
|
||||
wrapperFrame->SetStyleContext(aPresContext, scrolledPseudoStyle);
|
||||
|
||||
// Process the child content, and set the frame's initial child list
|
||||
nsIFrame* childList;
|
||||
rv = ProcessChildren(aPresContext, wrapperFrame, aContent, childList);
|
||||
wrapperFrame->SetInitialChildList(*aPresContext, nsnull, childList);
|
||||
|
||||
// Set the scroll frame's initial child list
|
||||
scrollFrame->SetInitialChildList(*aPresContext, nsnull, wrapperFrame);
|
||||
}
|
||||
|
||||
// initialize the root frame
|
||||
aNewFrame->SetInitialChildList(*aPresContext, nsnull, scrollFrame);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -1466,10 +1533,28 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
|
||||
else {
|
||||
// Create a frame.
|
||||
if (nsnull == aParentFrame) {
|
||||
// Construct the root frame object
|
||||
rv = ConstructRootFrame(aPresContext, aContent, styleContext,
|
||||
aFrameSubTree);
|
||||
|
||||
nsIDocument* document;
|
||||
rv = aContent->GetDocument(document);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(styleContext);
|
||||
return rv;
|
||||
}
|
||||
if (nsnull != document) {
|
||||
nsIXMLDocument* xmlDocument;
|
||||
rv = document->QueryInterface(kIXMLDocumentIID, (void **)&xmlDocument);
|
||||
if (NS_FAILED(rv)) {
|
||||
// Construct the root frame object
|
||||
rv = ConstructRootFrame(aPresContext, aContent, styleContext,
|
||||
aFrameSubTree);
|
||||
}
|
||||
else {
|
||||
// Construct the root frame object for XML
|
||||
rv = ConstructXMLRootFrames(aPresContext, aContent, styleContext,
|
||||
aFrameSubTree);
|
||||
NS_RELEASE(xmlDocument);
|
||||
}
|
||||
NS_RELEASE(document);
|
||||
}
|
||||
} else {
|
||||
// If the frame is a block-level frame and is scrollable then wrap it
|
||||
// in a scroll frame.
|
||||
|
@ -27,6 +27,12 @@
|
||||
#include "nsIContent.h"
|
||||
#include "nsIStyleFrameConstruction.h"
|
||||
|
||||
// XXX Temporary fix to make sure that ua.css only gets applied
|
||||
// to HTML content. When this removed, remember to get rid of
|
||||
// the include dependency in the makefile.
|
||||
#include "nsIHTMLContent.h"
|
||||
static NS_DEFINE_IID(kIHTMLContentIID, NS_IHTMLCONTENT_IID);
|
||||
|
||||
static NS_DEFINE_IID(kIStyleSetIID, NS_ISTYLE_SET_IID);
|
||||
static NS_DEFINE_IID(kIStyleFrameConstructionIID, NS_ISTYLE_FRAME_CONSTRUCTION_IID);
|
||||
|
||||
@ -477,7 +483,13 @@ nsIStyleContext* StyleSetImpl::ResolveStyleFor(nsIPresContext* aPresContext,
|
||||
}
|
||||
|
||||
if (nsnull != rules) {
|
||||
PRInt32 ruleCount = RulesMatching(mBackstopSheets, aPresContext, aContent, aParentContext, rules);
|
||||
nsIHTMLContent *htmlContent;
|
||||
nsresult rv = aContent->QueryInterface(kIHTMLContentIID, (void **)&htmlContent);
|
||||
PRInt32 ruleCount = 0;
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
ruleCount += RulesMatching(mBackstopSheets, aPresContext, aContent, aParentContext, rules);
|
||||
NS_RELEASE(htmlContent);
|
||||
}
|
||||
PRInt32 backstopRules = ruleCount;
|
||||
ruleCount += RulesMatching(mDocSheets, aPresContext, aContent, aParentContext, rules);
|
||||
ruleCount += RulesMatching(mOverrideSheets, aPresContext, aContent, aParentContext, rules);
|
||||
|
24
layout/xml/Makefile
Normal file
24
layout/xml/Makefile
Normal file
@ -0,0 +1,24 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../..
|
||||
|
||||
DIRS = content document
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
29
layout/xml/Makefile.in
Normal file
29
layout/xml/Makefile.in
Normal file
@ -0,0 +1,29 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = content document
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
24
layout/xml/content/Makefile
Normal file
24
layout/xml/content/Makefile
Normal file
@ -0,0 +1,24 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../..
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
29
layout/xml/content/Makefile.in
Normal file
29
layout/xml/content/Makefile.in
Normal file
@ -0,0 +1,29 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
22
layout/xml/content/makefile.win
Normal file
22
layout/xml/content/makefile.win
Normal file
@ -0,0 +1,22 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
DIRS=src public
|
||||
|
||||
include <$(DEPTH)\layout\config\rules.mak>
|
28
layout/xml/content/public/Makefile
Normal file
28
layout/xml/content/public/Makefile
Normal file
@ -0,0 +1,28 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../../..
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
EXPORTS = \
|
||||
nsIXMLContent.h \
|
||||
$(NULL)
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
35
layout/xml/content/public/Makefile.in
Normal file
35
layout/xml/content/public/Makefile.in
Normal file
@ -0,0 +1,35 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
EXPORTS = \
|
||||
nsIXMLContent.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
27
layout/xml/content/public/makefile.win
Normal file
27
layout/xml/content/public/makefile.win
Normal file
@ -0,0 +1,27 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
EXPORTS = \
|
||||
nsIXMLContent.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE=raptor
|
||||
|
||||
include <$(DEPTH)\layout\config\rules.mak>
|
||||
|
48
layout/xml/content/public/nsIXMLContent.h
Normal file
48
layout/xml/content/public/nsIXMLContent.h
Normal file
@ -0,0 +1,48 @@
|
||||
/* -*- 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.0 (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.
|
||||
*/
|
||||
|
||||
#ifndef nsIXMLContent_h___
|
||||
#define nsIXMLContent_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
#define gNameSpaceId_Unknown 0
|
||||
|
||||
#define NS_IXMLCONTENT_IID \
|
||||
{ 0xa6cf90cb, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
/**
|
||||
* XML content extensions to nsIContent
|
||||
*/
|
||||
class nsIXMLContent : public nsIContent {
|
||||
public:
|
||||
// XXX A convenience - the id can be used to get the namespace Atom
|
||||
NS_IMETHOD SetNameSpace(nsIAtom* aNameSpace)=0;
|
||||
NS_IMETHOD GetNameSpace(nsIAtom*& aNameSpace)=0;
|
||||
|
||||
NS_IMETHOD SetNameSpaceIdentifier(PRInt32 aNSIdentifier)=0;
|
||||
NS_IMETHOD GetNameSpaceIdentifier(PRInt32& aNSIdentifier)=0;
|
||||
};
|
||||
|
||||
extern nsresult
|
||||
NS_NewXMLElement(nsIXMLContent** aResult, nsIAtom* aTag);
|
||||
|
||||
#endif // nsIXMLContent_h___
|
57
layout/xml/content/src/Makefile
Normal file
57
layout/xml/content/src/Makefile
Normal file
@ -0,0 +1,57 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../../..
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = raptorxlmcontent_s
|
||||
|
||||
DEFINES += -D_IMPL_NS_HTML
|
||||
|
||||
INCLUDES += \
|
||||
-I../../../html/base/src \
|
||||
-I../../../html/document/src \
|
||||
-I../../../html/content/src \
|
||||
-I../../../html/style/src \
|
||||
-I$(DIST)/public/raptor \
|
||||
$(NULL)
|
||||
|
||||
# Note the sophisticated alphabetical ordering :-|
|
||||
CPPSRCS = \
|
||||
nsXMLElement.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
REQUIRES = xpcom raptor dom netlib js pref
|
||||
|
||||
MKSHLIB :=
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
|
||||
export::
|
||||
|
||||
install:: $(TARGETS)
|
||||
|
||||
|
||||
clobber::
|
||||
|
64
layout/xml/content/src/Makefile.in
Normal file
64
layout/xml/content/src/Makefile.in
Normal file
@ -0,0 +1,64 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = raptorxmlcontent_s
|
||||
|
||||
DEFINES += -D_IMPL_NS_HTML
|
||||
|
||||
INCLUDES += \
|
||||
-I$(srcdir)/../../../html/base/src \
|
||||
-I$(srcdir)/../../../html/document/src \
|
||||
-I$(srcdir)/../../../html/content/src \
|
||||
-I$(srcdir)/../../../html/style/src \
|
||||
-I$(DIST)/public/raptor \
|
||||
$(NULL)
|
||||
|
||||
# Note the sophisticated alphabetical ordering :-|
|
||||
CPPSRCS = \
|
||||
nsXMLElement.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
REQUIRES = xpcom raptor dom netlib js pref
|
||||
|
||||
MKSHLIB :=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
export::
|
||||
|
||||
install:: $(TARGETS)
|
||||
|
||||
|
||||
clobber::
|
||||
|
53
layout/xml/content/src/makefile.win
Normal file
53
layout/xml/content/src/makefile.win
Normal file
@ -0,0 +1,53 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
LIBRARY_NAME=raptorxmlcontent_s
|
||||
MODULE=raptor
|
||||
REQUIRES=xpcom raptor pref
|
||||
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
CPPSRCS= \
|
||||
nsXMLElement.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsXMLElement.obj \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
|
||||
-I..\..\..\html\style\src -I..\..\..\html\base\src -I$(PUBLIC)\dom \
|
||||
-I..\..\..\html\content\src -I..\..\..\html\document\src \
|
||||
-I$(PUBLIC)\netlib -I..\..\..\base\src -I$(PUBLIC)\pref
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\layout\config\rules.mak>
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
184
layout/xml/content/src/nsXMLElement.cpp
Normal file
184
layout/xml/content/src/nsXMLElement.cpp
Normal file
@ -0,0 +1,184 @@
|
||||
/* -*- 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.0 (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.
|
||||
*/
|
||||
|
||||
#include "nsXMLElement.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIEventListenerManager.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
|
||||
//static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIXMLContentIID, NS_IXMLCONTENT_IID);
|
||||
|
||||
nsresult
|
||||
NS_NewXMLElement(nsIXMLContent** aInstancePtrResult, nsIAtom* aTag)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsIXMLContent* it = new nsXMLElement(aTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIXMLContentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
nsXMLElement::nsXMLElement(nsIAtom *aTag)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mInner.Init((nsIContent *)(nsIXMLContent *)this, aTag);
|
||||
mNameSpace = nsnull;
|
||||
mNameSpaceId = gNameSpaceId_Unknown;
|
||||
mScriptObject = nsnull;
|
||||
}
|
||||
|
||||
nsXMLElement::~nsXMLElement()
|
||||
{
|
||||
NS_IF_RELEASE(mNameSpace);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::QueryInterface(REFNSIID aIID,
|
||||
void** aInstancePtr)
|
||||
{
|
||||
NS_IMPL_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this, nsIXMLContent)
|
||||
if (aIID.Equals(kIXMLContentIID)) {
|
||||
nsIXMLContent* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsXMLElement)
|
||||
NS_IMPL_RELEASE(nsXMLElement)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::GetScriptObject(nsIScriptContext* aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
// XXX Yuck! Reaching into the generic content object isn't good.
|
||||
nsDOMSlots *slots = mInner.GetDOMSlots();
|
||||
if (nsnull == slots->mScriptObject) {
|
||||
nsIDOMScriptObjectFactory *factory;
|
||||
|
||||
res = nsGenericElement::GetScriptObjectFactory(&factory);
|
||||
if (NS_OK != res) {
|
||||
return res;
|
||||
}
|
||||
|
||||
nsAutoString tag;
|
||||
nsIContent* parent;
|
||||
|
||||
mInner.GetTagName(tag);
|
||||
mInner.GetParent(parent);
|
||||
|
||||
res = factory->NewScriptXMLElement(tag, aContext,
|
||||
(nsISupports *)(nsIDOMElement *)this,
|
||||
parent, (void**)&slots->mScriptObject);
|
||||
NS_IF_RELEASE(parent);
|
||||
NS_RELEASE(factory);
|
||||
|
||||
char tagBuf[50];
|
||||
tag.ToCString(tagBuf, sizeof(tagBuf));
|
||||
|
||||
nsIDocument *document;
|
||||
mInner.GetDocument(document);
|
||||
if (nsnull != document) {
|
||||
aContext->AddNamedReference((void *)&slots->mScriptObject,
|
||||
slots->mScriptObject,
|
||||
tagBuf);
|
||||
NS_RELEASE(document);
|
||||
}
|
||||
}
|
||||
*aScriptObject = slots->mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
return mInner.SetScriptObject(aScriptObject);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::SetNameSpace(nsIAtom* aNameSpace)
|
||||
{
|
||||
NS_IF_RELEASE(mNameSpace);
|
||||
|
||||
mNameSpace = aNameSpace;
|
||||
|
||||
NS_IF_ADDREF(mNameSpace);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::GetNameSpace(nsIAtom*& aNameSpace)
|
||||
{
|
||||
aNameSpace = mNameSpace;
|
||||
|
||||
NS_IF_ADDREF(mNameSpace);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::SetNameSpaceIdentifier(PRInt32 aNameSpaceId)
|
||||
{
|
||||
mNameSpaceId = aNameSpaceId;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::GetNameSpaceIdentifier(PRInt32& aNameSpaceId)
|
||||
{
|
||||
aNameSpaceId = mNameSpaceId;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsXMLElement* it = new nsXMLElement(mInner.mTag);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mInner.CopyInnerTo((nsIContent *)(nsIXMLContent *)this, &it->mInner);
|
||||
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
}
|
||||
|
104
layout/xml/content/src/nsXMLElement.h
Normal file
104
layout/xml/content/src/nsXMLElement.h
Normal file
@ -0,0 +1,104 @@
|
||||
/* -*- 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.0 (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.
|
||||
*/
|
||||
|
||||
#ifndef nsXMLElement_h___
|
||||
#define nsXMLElement_h___
|
||||
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIXMLContent.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsGenericElement.h"
|
||||
|
||||
class nsIDocument;
|
||||
class nsIAtom;
|
||||
class nsIEventListenerManager;
|
||||
class nsIHTMLAttributes;
|
||||
|
||||
class nsXMLElement : public nsIDOMElement,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIXMLContent,
|
||||
public nsIJSScriptObject
|
||||
{
|
||||
public:
|
||||
nsXMLElement(nsIAtom *aTag);
|
||||
~nsXMLElement();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNode
|
||||
NS_IMPL_IDOMNODE_USING_GENERIC(mInner)
|
||||
|
||||
// nsIDOMElement
|
||||
NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
// nsIContent
|
||||
NS_IMPL_ICONTENT_USING_GENERIC(mInner)
|
||||
|
||||
// nsIXMLContent
|
||||
NS_IMETHOD SetNameSpace(nsIAtom* aNameSpace);
|
||||
NS_IMETHOD GetNameSpace(nsIAtom*& aNameSpace);
|
||||
NS_IMETHOD SetNameSpaceIdentifier(PRInt32 aNameSpaceId);
|
||||
NS_IMETHOD GetNameSpaceIdentifier(PRInt32& aNameSpeceId);
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner)
|
||||
|
||||
// nsIJSScriptObject
|
||||
virtual PRBool AddProperty(JSContext *aContext, jsval aID, jsval *aVp) {
|
||||
return mInner.AddProperty(aContext, aID, aVp);
|
||||
}
|
||||
virtual PRBool DeleteProperty(JSContext *aContext, jsval aID, jsval *aVp) {
|
||||
return mInner.DeleteProperty(aContext, aID, aVp);
|
||||
}
|
||||
virtual PRBool GetProperty(JSContext *aContext, jsval aID, jsval *aVp) {
|
||||
return mInner.GetProperty(aContext, aID, aVp);
|
||||
}
|
||||
virtual PRBool SetProperty(JSContext *aContext, jsval aID, jsval *aVp) {
|
||||
return mInner.SetProperty(aContext, aID, aVp);
|
||||
}
|
||||
virtual PRBool EnumerateProperty(JSContext *aContext) {
|
||||
return mInner.EnumerateProperty(aContext);
|
||||
}
|
||||
virtual PRBool Resolve(JSContext *aContext, jsval aID) {
|
||||
return mInner.Resolve(aContext, aID);
|
||||
}
|
||||
virtual PRBool Convert(JSContext *aContext, jsval aID) {
|
||||
return mInner.Convert(aContext, aID);
|
||||
}
|
||||
virtual void Finalize(JSContext *aContext) {
|
||||
mInner.Finalize(aContext);
|
||||
}
|
||||
|
||||
protected:
|
||||
nsGenericContainerElement mInner;
|
||||
|
||||
nsIAtom* mNameSpace;
|
||||
PRInt32 mNameSpaceId;
|
||||
void *mScriptObject;
|
||||
};
|
||||
|
||||
#endif // nsXMLElement_h___
|
24
layout/xml/document/Makefile
Normal file
24
layout/xml/document/Makefile
Normal file
@ -0,0 +1,24 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../..
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
29
layout/xml/document/Makefile.in
Normal file
29
layout/xml/document/Makefile.in
Normal file
@ -0,0 +1,29 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
22
layout/xml/document/makefile.win
Normal file
22
layout/xml/document/makefile.win
Normal file
@ -0,0 +1,22 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
DIRS=src public
|
||||
|
||||
include <$(DEPTH)\layout\config\rules.mak>
|
29
layout/xml/document/public/Makefile
Normal file
29
layout/xml/document/public/Makefile
Normal file
@ -0,0 +1,29 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../../..
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
EXPORTS = \
|
||||
nsIXMLContentSink.h \
|
||||
nsIXMLDocument.h \
|
||||
$(NULL)
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
36
layout/xml/document/public/Makefile.in
Normal file
36
layout/xml/document/public/Makefile.in
Normal file
@ -0,0 +1,36 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
EXPORTS = \
|
||||
nsIXMLContentSink.h \
|
||||
nsIXMLDocument.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
28
layout/xml/document/public/makefile.win
Normal file
28
layout/xml/document/public/makefile.win
Normal file
@ -0,0 +1,28 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
EXPORTS = \
|
||||
nsIXMLContentSink.h \
|
||||
nsIXMLDocument.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE=raptor
|
||||
|
||||
include <$(DEPTH)\layout\config\rules.mak>
|
||||
|
122
layout/xml/document/public/nsIXMLContentSink.h
Normal file
122
layout/xml/document/public/nsIXMLContentSink.h
Normal file
@ -0,0 +1,122 @@
|
||||
/* -*- 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.0 (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.
|
||||
*/
|
||||
#ifndef nsIXMLContentSink_h___
|
||||
#define nsIXMLContentSink_h___
|
||||
|
||||
#include "nsIContentSink.h"
|
||||
#include "nsIParserNode.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIDocument;
|
||||
class nsIURL;
|
||||
class nsIWebShell;
|
||||
|
||||
#define NS_IXMLCONTENT_SINK_IID \
|
||||
{ 0xa6cf90c9, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
/**
|
||||
* This interface represents a content sink for generic XML files.
|
||||
* The goal of this sink is to deal with XML documents that do not
|
||||
* have pre-built semantics, though it may also be implemented for
|
||||
* cases in which semantics are hard-wired.
|
||||
*
|
||||
* The expectation is that the parser has already performed
|
||||
* well-formedness and validity checking.
|
||||
*
|
||||
* XXX The expectation is that entity expansion will be done by the sink
|
||||
* itself. This would require, however, that the sink has the ability
|
||||
* to query the parser for entity replacement text.
|
||||
*
|
||||
* XXX This interface does not contain a mechanism for the sink to
|
||||
* get specific schema/DTD information from the parser. This information
|
||||
* may be necessary for entity expansion. It is also necessary for
|
||||
* building the DOM portions that relate to the schema.
|
||||
*
|
||||
* XXX This interface does not deal with the presence of an external
|
||||
* subset. It seems possible that this could be dealt with completely
|
||||
* at the parser level.
|
||||
*/
|
||||
|
||||
class nsIXMLContentSink : public nsIContentSink {
|
||||
public:
|
||||
/**
|
||||
* This method is called by the parser when it encounters
|
||||
* the XML declaration for a document.
|
||||
*
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
*/
|
||||
NS_IMETHOD AddXMLDecl(const nsIParserNode& aNode)=0;
|
||||
|
||||
/**
|
||||
* This method is called by the parser when it encounters
|
||||
* a document type declaration.
|
||||
*
|
||||
* XXX Should the parser also part the internal subset?
|
||||
*
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
*/
|
||||
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode)=0;
|
||||
|
||||
/**
|
||||
* This method is called by the parser when it encounters
|
||||
* character data - either regular CDATA or a marked CDATA
|
||||
* section.
|
||||
*
|
||||
* XXX Could be removed in favor of nsIContentSink::AddLeaf
|
||||
*
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
*/
|
||||
NS_IMETHOD AddCharacterData(const nsIParserNode& aNode)=0;
|
||||
|
||||
/**
|
||||
* This method is called by the parser when it encounters
|
||||
* an unparsed entity (i.e. NDATA)
|
||||
*
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
*/
|
||||
NS_IMETHOD AddUnparsedEntity(const nsIParserNode& aNode)=0;
|
||||
|
||||
/**
|
||||
* This method is called by the parser when it encounters
|
||||
* a notation.
|
||||
*
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
*/
|
||||
NS_IMETHOD AddNotation(const nsIParserNode& aNode)=0;
|
||||
|
||||
/**
|
||||
* This method is called by the parser when it encounters
|
||||
* an entity reference. Note that the expectation is that
|
||||
* the content sink itself will expand the entity reference
|
||||
* in the content model.
|
||||
*
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
*/
|
||||
NS_IMETHOD AddEntityReference(const nsIParserNode& aNode)=0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
extern nsresult NS_NewXMLContentSink(nsIXMLContentSink** aInstancePtrResult,
|
||||
nsIDocument* aDoc,
|
||||
nsIURL* aURL,
|
||||
nsIWebShell* aWebShell);
|
||||
|
||||
#endif // nsIXMLContentSink_h___
|
57
layout/xml/document/public/nsIXMLDocument.h
Normal file
57
layout/xml/document/public/nsIXMLDocument.h
Normal file
@ -0,0 +1,57 @@
|
||||
/* -*- 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.0 (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.
|
||||
*/
|
||||
|
||||
#ifndef nsIXMLDocument_h___
|
||||
#define nsIXMLDocument_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIHTMLStyleSheet;
|
||||
|
||||
#define NS_IXMLDOCUMENT_IID \
|
||||
{ 0xa6cf90ca, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
/**
|
||||
* XML document extensions to nsIDocument
|
||||
*/
|
||||
class nsIXMLDocument : public nsISupports {
|
||||
public:
|
||||
// XXX A HTMLStyleSheet for attributes of HTML content within
|
||||
// this document
|
||||
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult)=0;
|
||||
|
||||
NS_IMETHOD RegisterNameSpace(nsIAtom* aPrefix, const nsString& aURI,
|
||||
PRInt32& aNameSpaceId)=0;
|
||||
|
||||
NS_IMETHOD GetNameSpaceURI(PRInt32 aNameSpaceId, nsString& aURI)=0;
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceId, nsIAtom*& aPrefix)=0;
|
||||
|
||||
NS_IMETHOD PrologElementAt(PRInt32 aOffset, nsIContent** aContent)=0;
|
||||
NS_IMETHOD PrologCount(PRInt32* aCount)=0;
|
||||
NS_IMETHOD AppendToProlog(nsIContent* aContent)=0;
|
||||
|
||||
NS_IMETHOD EpilogElementAt(PRInt32 aOffset, nsIContent** aContent)=0;
|
||||
NS_IMETHOD EpilogCount(PRInt32* aCount)=0;
|
||||
NS_IMETHOD AppendToEpilog(nsIContent* aContent)=0;
|
||||
};
|
||||
|
||||
#endif // nsIXMLDocument_h___
|
58
layout/xml/document/src/Makefile
Normal file
58
layout/xml/document/src/Makefile
Normal file
@ -0,0 +1,58 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../../..
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = raptorxlmdoc_s
|
||||
|
||||
DEFINES += -D_IMPL_NS_HTML
|
||||
|
||||
INCLUDES += \
|
||||
-I../../../html/base/src \
|
||||
-I../../../html/document/src \
|
||||
-I../../../html/content/src \
|
||||
-I../../../html/style/src \
|
||||
-I$(DIST)/public/raptor \
|
||||
$(NULL)
|
||||
|
||||
# Note the sophisticated alphabetical ordering :-|
|
||||
CPPSRCS = \
|
||||
nsXMLContentSink.cpp \
|
||||
nsXMLDocument.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
REQUIRES = xpcom raptor dom netlib js pref
|
||||
|
||||
MKSHLIB :=
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
|
||||
export::
|
||||
|
||||
install:: $(TARGETS)
|
||||
|
||||
|
||||
clobber::
|
||||
|
65
layout/xml/document/src/Makefile.in
Normal file
65
layout/xml/document/src/Makefile.in
Normal file
@ -0,0 +1,65 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = raptorxmldoc_s
|
||||
|
||||
DEFINES += -D_IMPL_NS_HTML
|
||||
|
||||
INCLUDES += \
|
||||
-I$(srcdir)/../../../html/base/src \
|
||||
-I$(srcdir)/../../../html/document/src \
|
||||
-I$(srcdir)/../../../html/content/src \
|
||||
-I$(srcdir)/../../../html/style/src \
|
||||
-I$(DIST)/public/raptor \
|
||||
$(NULL)
|
||||
|
||||
# Note the sophisticated alphabetical ordering :-|
|
||||
CPPSRCS = \
|
||||
nsXMLContentSink.cpp \
|
||||
nsXMLDocument.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
REQUIRES = xpcom raptor dom netlib js pref
|
||||
|
||||
MKSHLIB :=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
export::
|
||||
|
||||
install:: $(TARGETS)
|
||||
|
||||
|
||||
clobber::
|
||||
|
55
layout/xml/document/src/makefile.win
Normal file
55
layout/xml/document/src/makefile.win
Normal file
@ -0,0 +1,55 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
LIBRARY_NAME=raptorxmldoc_s
|
||||
MODULE=raptor
|
||||
REQUIRES=xpcom raptor pref
|
||||
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
CPPSRCS= \
|
||||
nsXMLContentSink.cpp \
|
||||
nsXMLDocument.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsXMLContentSink.obj \
|
||||
.\$(OBJDIR)\nsXMLDocument.obj \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
|
||||
-I..\..\..\html\style\src -I..\..\..\html\base\src -I$(PUBLIC)\dom \
|
||||
-I..\..\..\html\content\src -I..\..\..\html\document\src \
|
||||
-I$(PUBLIC)\netlib -I..\..\..\base\src -I$(PUBLIC)\pref
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\layout\config\rules.mak>
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
1096
layout/xml/document/src/nsXMLContentSink.cpp
Normal file
1096
layout/xml/document/src/nsXMLContentSink.cpp
Normal file
File diff suppressed because it is too large
Load Diff
125
layout/xml/document/src/nsXMLContentSink.h
Normal file
125
layout/xml/document/src/nsXMLContentSink.h
Normal file
@ -0,0 +1,125 @@
|
||||
/* -*- 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.0 (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.
|
||||
*/
|
||||
|
||||
#ifndef nsXMLContentSink_h__
|
||||
#define nsXMLContentSink_h__
|
||||
|
||||
#include "nsIXMLContentSink.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIScrollableView.h"
|
||||
|
||||
class nsIDocument;
|
||||
class nsIScriptObjectOwner;
|
||||
class nsIURL;
|
||||
class nsIWebShell;
|
||||
class nsIContent;
|
||||
class nsVoidArray;
|
||||
class nsIXMLDocument;
|
||||
class nsIUnicharInputStream;
|
||||
class nsIStyleSheet;
|
||||
|
||||
typedef enum {
|
||||
eXMLContentSinkState_InProlog,
|
||||
eXMLContentSinkState_InDocumentElement,
|
||||
eXMLContentSinkState_InEpilog
|
||||
} XMLContentSinkState;
|
||||
|
||||
|
||||
// XXX Till the parser knows a little bit more about XML,
|
||||
// this is a HTMLContentSink.
|
||||
class nsXMLContentSink : public nsIXMLContentSink {
|
||||
public:
|
||||
nsXMLContentSink();
|
||||
~nsXMLContentSink();
|
||||
|
||||
nsresult Init(nsIDocument* aDoc,
|
||||
nsIURL* aURL,
|
||||
nsIWebShell* aContainer);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIContentSink
|
||||
NS_IMETHOD WillBuildModel(void);
|
||||
NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel);
|
||||
NS_IMETHOD WillInterrupt(void);
|
||||
NS_IMETHOD WillResume(void);
|
||||
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddComment(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
|
||||
NS_IMETHOD NotifyError(nsresult aErrorResult);
|
||||
|
||||
// nsIXMLContentSink
|
||||
NS_IMETHOD AddXMLDecl(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddCharacterData(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddUnparsedEntity(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddNotation(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddEntityReference(const nsIParserNode& aNode);
|
||||
|
||||
protected:
|
||||
void StartLayout();
|
||||
|
||||
nsresult LoadStyleSheet(nsIURL* aURL,
|
||||
nsIUnicharInputStream* aUIN,
|
||||
PRBool aInline);
|
||||
nsresult FlushText(PRBool* aDidFlush=nsnull);
|
||||
|
||||
nsresult AddContentAsLeaf(nsIContent *aContent);
|
||||
void FindNameSpaceAttributes(const nsIParserNode& aNode);
|
||||
|
||||
PRInt32 OpenNameSpace(const nsString& aPrefix, const nsString& aURI);
|
||||
PRInt32 GetNameSpaceId(const nsString& aPrefix);
|
||||
void CloseNameSpacesAtNestLevel(PRInt32 mNestLevel);
|
||||
PRBool IsHTMLNameSpace(PRInt32 aId);
|
||||
|
||||
nsIContent* GetCurrentContent();
|
||||
PRInt32 PushContent(nsIContent *aContent);
|
||||
nsIContent* PopContent();
|
||||
PRInt32 GetCurrentNestLevel();
|
||||
|
||||
struct NameSpaceStruct {
|
||||
nsIAtom* mPrefix;
|
||||
PRInt32 mId;
|
||||
PRInt32 mNestLevel;
|
||||
};
|
||||
|
||||
nsIDocument* mDocument;
|
||||
nsIURL* mDocumentURL;
|
||||
nsIWebShell* mWebShell;
|
||||
|
||||
nsIContent* mRootElement;
|
||||
nsIContent* mDocElement;
|
||||
XMLContentSinkState mState;
|
||||
nsVoidArray* mNameSpaces;
|
||||
|
||||
PRInt32 mNestLevel;
|
||||
nsVoidArray* mContentStack;
|
||||
|
||||
nsIStyleSheet* mStyleSheet;
|
||||
nsScrollPreference mOriginalScrollPreference;
|
||||
|
||||
PRUnichar* mText;
|
||||
PRInt32 mTextLength;
|
||||
PRInt32 mTextSize;
|
||||
};
|
||||
|
||||
#endif // nsXMLContentSink_h__
|
423
layout/xml/document/src/nsXMLDocument.cpp
Normal file
423
layout/xml/document/src/nsXMLDocument.cpp
Normal file
@ -0,0 +1,423 @@
|
||||
/* -*- 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.0 (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.
|
||||
*/
|
||||
|
||||
|
||||
#include "nsXMLDocument.h"
|
||||
#include "nsWellFormedDTD.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsIXMLContent.h"
|
||||
#include "nsIXMLContentSink.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIContentViewerContainer.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIDocumentLoader.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsIHTMLStyleSheet.h"
|
||||
#include "nsRepository.h"
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMText.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIXMLDocumentIID, NS_IXMLDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
||||
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
|
||||
|
||||
|
||||
NS_LAYOUT nsresult
|
||||
NS_NewXMLDocument(nsIDocument** aInstancePtrResult)
|
||||
{
|
||||
nsXMLDocument* doc = new nsXMLDocument();
|
||||
return doc->QueryInterface(kIDocumentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
nsXMLDocument::nsXMLDocument()
|
||||
{
|
||||
mParser = nsnull;
|
||||
mNameSpaces = nsnull;
|
||||
mAttrStyleSheet = nsnull;
|
||||
mProlog = nsnull;
|
||||
mEpilog = nsnull;
|
||||
}
|
||||
|
||||
nsXMLDocument::~nsXMLDocument()
|
||||
{
|
||||
NS_IF_RELEASE(mParser);
|
||||
if (nsnull != mNameSpaces) {
|
||||
int i;
|
||||
for (i = 0; i < mNameSpaces->Count(); i++) {
|
||||
nsXMLNameSpace *ns = (nsXMLNameSpace *)mNameSpaces->ElementAt(i);
|
||||
|
||||
if (nsnull != ns) {
|
||||
NS_IF_RELEASE(ns->mPrefix);
|
||||
delete ns->mURI;
|
||||
delete ns;
|
||||
}
|
||||
}
|
||||
mNameSpaces = nsnull;
|
||||
}
|
||||
NS_IF_RELEASE(mAttrStyleSheet);
|
||||
if (nsnull != mProlog) {
|
||||
delete mProlog;
|
||||
}
|
||||
if (nsnull != mEpilog) {
|
||||
delete mProlog;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::QueryInterface(REFNSIID aIID,
|
||||
void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIXMLDocumentIID)) {
|
||||
NS_ADDREF_THIS();
|
||||
*aInstancePtr = (void**) (nsIXMLDocument *)this;
|
||||
return NS_OK;
|
||||
}
|
||||
return nsDocument::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
nsrefcnt nsXMLDocument::AddRef()
|
||||
{
|
||||
return nsDocument::AddRef();
|
||||
}
|
||||
|
||||
nsrefcnt nsXMLDocument::Release()
|
||||
{
|
||||
return nsDocument::Release();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::StartDocumentLoad(nsIURL *aUrl,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand)
|
||||
{
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aUrl, aContainer,
|
||||
aDocListener);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIWebShell* webShell;
|
||||
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
||||
rv = nsRepository::CreateInstance(kCParserCID,
|
||||
nsnull,
|
||||
kCParserIID,
|
||||
(void **)&mParser);
|
||||
if (NS_OK == rv) {
|
||||
nsIXMLContentSink* sink;
|
||||
|
||||
aContainer->QueryInterface(kIWebShellIID, (void**)&webShell);
|
||||
rv = NS_NewXMLContentSink(&sink, this, aUrl, webShell);
|
||||
NS_IF_RELEASE(webShell);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
// For the HTML content within a document
|
||||
if (NS_OK == NS_NewHTMLStyleSheet(&mAttrStyleSheet, aUrl)) {
|
||||
AddStyleSheet(mAttrStyleSheet); // tell the world about our new style sheet
|
||||
}
|
||||
|
||||
// Set the parser as the stream listener for the document loader...
|
||||
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
||||
rv = mParser->QueryInterface(kIStreamListenerIID, (void**)aDocListener);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
|
||||
nsIDTD* theDTD=0;
|
||||
// XXX For now, we'll use the HTML DTD
|
||||
NS_NewWellFormed_DTD(&theDTD);
|
||||
mParser->RegisterDTD(theDTD);
|
||||
|
||||
mParser->SetContentSink(sink);
|
||||
mParser->Parse(aUrl);
|
||||
}
|
||||
NS_RELEASE(sink);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::EndLoad()
|
||||
{
|
||||
NS_IF_RELEASE(mParser);
|
||||
return nsDocument::EndLoad();
|
||||
}
|
||||
|
||||
// XXX Currently a nsIHTMLDocument method. Should go into an interface
|
||||
// implemented for XML documents that hold HTML content.
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
||||
if (nsnull == aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aResult = mAttrStyleSheet;
|
||||
if (nsnull == mAttrStyleSheet) {
|
||||
return NS_ERROR_NOT_AVAILABLE; // probably not the right error...
|
||||
}
|
||||
else {
|
||||
NS_ADDREF(mAttrStyleSheet);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIDOMDocument interface
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::GetDoctype(nsIDOMDocumentType** aDocumentType)
|
||||
{
|
||||
// XXX TBI
|
||||
*aDocumentType = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateCDATASection(const nsString& aData, nsIDOMCDATASection** aReturn)
|
||||
{
|
||||
// XXX TBI
|
||||
*aReturn = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateEntityReference(const nsString& aName, nsIDOMEntityReference** aReturn)
|
||||
{
|
||||
// XXX TBI
|
||||
*aReturn = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateComment(const nsString& aData, nsIDOMComment** aReturn)
|
||||
{
|
||||
// XXX Should just be regular nsIContent
|
||||
nsIHTMLContent* comment = nsnull;
|
||||
nsresult rv = NS_NewCommentNode(&comment);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
rv = comment->QueryInterface(kIDOMCommentIID, (void**)aReturn);
|
||||
(*aReturn)->AppendData(aData);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateProcessingInstruction(const nsString& aTarget, const nsString& aData, nsIDOMProcessingInstruction** aReturn)
|
||||
{
|
||||
// XXX TBI
|
||||
*aReturn = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateAttribute(const nsString& aName, nsIDOMAttr** aReturn)
|
||||
{
|
||||
// XXX TBI
|
||||
*aReturn = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateElement(const nsString& aTagName,
|
||||
nsIDOMElement** aReturn)
|
||||
{
|
||||
nsIXMLContent* content;
|
||||
nsIAtom* tag = NS_NewAtom(aTagName);
|
||||
nsresult rv = NS_NewXMLElement(&content, tag);
|
||||
NS_RELEASE(tag);
|
||||
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
rv = content->QueryInterface(kIDOMElementIID, (void**)aReturn);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateTextNode(const nsString& aData, nsIDOMText** aReturn)
|
||||
{
|
||||
// XXX Should just be regular nsIContent
|
||||
nsIHTMLContent* text = nsnull;
|
||||
nsresult rv = NS_NewTextNode(&text);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
rv = text->QueryInterface(kIDOMTextIID, (void**)aReturn);
|
||||
(*aReturn)->AppendData(aData);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
// nsIXMLDocument interface
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::RegisterNameSpace(nsIAtom *aPrefix, const nsString& aURI,
|
||||
PRInt32& aNameSpaceId)
|
||||
{
|
||||
if (nsnull == mNameSpaces) {
|
||||
mNameSpaces = new nsVoidArray();
|
||||
if (nsnull == mNameSpaces) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
nsXMLNameSpace* ns = new nsXMLNameSpace;
|
||||
if (nsnull == ns) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
ns->mPrefix = aPrefix;
|
||||
NS_IF_ADDREF(ns->mPrefix);
|
||||
ns->mURI = new nsString(aURI);
|
||||
|
||||
mNameSpaces->AppendElement((void *)ns);
|
||||
aNameSpaceId = mNameSpaces->Count();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::GetNameSpaceURI(PRInt32 aNameSpaceId, nsString& aURI)
|
||||
{
|
||||
if (nsnull == mNameSpaces) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
nsXMLNameSpace *ns = (nsXMLNameSpace *)mNameSpaces->ElementAt(aNameSpaceId - 1);
|
||||
if (nsnull == ns) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
aURI.SetString(*ns->mURI);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::GetNameSpacePrefix(PRInt32 aNameSpaceId, nsIAtom*& aPrefix)
|
||||
{
|
||||
if (nsnull == mNameSpaces) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
nsXMLNameSpace *ns = (nsXMLNameSpace *)mNameSpaces->ElementAt(aNameSpaceId - 1);
|
||||
if (nsnull == ns) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
aPrefix = ns->mPrefix;
|
||||
NS_IF_ADDREF(aPrefix);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::PrologElementAt(PRInt32 aIndex, nsIContent** aContent)
|
||||
{
|
||||
if (nsnull == mProlog) {
|
||||
*aContent = nsnull;
|
||||
}
|
||||
else {
|
||||
*aContent = (nsIContent *)mProlog->ElementAt(aIndex);
|
||||
NS_ADDREF(*aContent);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::PrologCount(PRInt32* aCount)
|
||||
{
|
||||
if (nsnull == mProlog) {
|
||||
*aCount = 0;
|
||||
}
|
||||
else {
|
||||
*aCount = mProlog->Count();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::AppendToProlog(nsIContent* aContent)
|
||||
{
|
||||
if (nsnull == mProlog) {
|
||||
mProlog = new nsVoidArray();
|
||||
}
|
||||
|
||||
mProlog->AppendElement((void *)aContent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::EpilogElementAt(PRInt32 aIndex, nsIContent** aContent)
|
||||
{
|
||||
if (nsnull == mEpilog) {
|
||||
*aContent = nsnull;
|
||||
}
|
||||
else {
|
||||
*aContent = (nsIContent *)mEpilog->ElementAt(aIndex);
|
||||
NS_ADDREF(*aContent);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::EpilogCount(PRInt32* aCount)
|
||||
{
|
||||
if (nsnull == mEpilog) {
|
||||
*aCount = 0;
|
||||
}
|
||||
else {
|
||||
*aCount = mEpilog->Count();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::AppendToEpilog(nsIContent* aContent)
|
||||
{
|
||||
if (nsnull == mEpilog) {
|
||||
mEpilog = new nsVoidArray();
|
||||
}
|
||||
|
||||
mEpilog->AppendElement((void *)aContent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
95
layout/xml/document/src/nsXMLDocument.h
Normal file
95
layout/xml/document/src/nsXMLDocument.h
Normal file
@ -0,0 +1,95 @@
|
||||
/* -*- 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.0 (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.
|
||||
*/
|
||||
|
||||
#ifndef nsXMLDocument_h___
|
||||
#define nsXMLDocument_h___
|
||||
|
||||
#include "nsMarkupDocument.h"
|
||||
#include "nsIXMLDocument.h"
|
||||
#include "plhash.h"
|
||||
|
||||
class nsIParser;
|
||||
|
||||
typedef struct {
|
||||
nsIAtom *mPrefix;
|
||||
nsString *mURI;
|
||||
PRInt32 mId;
|
||||
} nsXMLNameSpace;
|
||||
|
||||
class nsXMLDocument : public nsMarkupDocument,
|
||||
public nsIXMLDocument
|
||||
{
|
||||
public:
|
||||
nsXMLDocument();
|
||||
virtual ~nsXMLDocument();
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(nsIURL *aUrl,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand);
|
||||
|
||||
NS_IMETHOD EndLoad();
|
||||
|
||||
// nsIDOMDocument interface
|
||||
NS_IMETHOD GetDoctype(nsIDOMDocumentType** aDocumentType);
|
||||
NS_IMETHOD CreateCDATASection(const nsString& aData, nsIDOMCDATASection** aReturn);
|
||||
NS_IMETHOD CreateEntityReference(const nsString& aName, nsIDOMEntityReference** aReturn);
|
||||
NS_IMETHOD CreateComment(const nsString& aData, nsIDOMComment** aReturn);
|
||||
NS_IMETHOD CreateProcessingInstruction(const nsString& aTarget, const nsString& aData, nsIDOMProcessingInstruction** aReturn);
|
||||
NS_IMETHOD CreateAttribute(const nsString& aName, nsIDOMAttr** aReturn);
|
||||
NS_IMETHOD CreateElement(const nsString& aTagName,
|
||||
nsIDOMElement** aReturn);
|
||||
NS_IMETHOD CreateTextNode(const nsString& aData, nsIDOMText** aReturn);
|
||||
|
||||
// nsIXMLDocument interface
|
||||
NS_IMETHOD RegisterNameSpace(nsIAtom *aPrefix, const nsString& aURI,
|
||||
PRInt32& aNameSpaceId);
|
||||
|
||||
NS_IMETHOD GetNameSpaceURI(PRInt32 aNameSpaceId, nsString& aURI);
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceId, nsIAtom*& aPrefix);
|
||||
|
||||
NS_IMETHOD PrologElementAt(PRInt32 aOffset, nsIContent** aContent);
|
||||
NS_IMETHOD PrologCount(PRInt32* aCount);
|
||||
NS_IMETHOD AppendToProlog(nsIContent* aContent);
|
||||
|
||||
NS_IMETHOD EpilogElementAt(PRInt32 aOffset, nsIContent** aContent);
|
||||
NS_IMETHOD EpilogCount(PRInt32* aCount);
|
||||
NS_IMETHOD AppendToEpilog(nsIContent* aContent);
|
||||
|
||||
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult);
|
||||
|
||||
protected:
|
||||
|
||||
// For HTML elements in our content model
|
||||
nsIHTMLStyleSheet* mAttrStyleSheet;
|
||||
|
||||
nsVoidArray *mProlog;
|
||||
nsVoidArray *mEpilog;
|
||||
|
||||
nsIParser *mParser;
|
||||
nsVoidArray *mNameSpaces;
|
||||
};
|
||||
|
||||
|
||||
#endif // nsXMLDocument_h___
|
22
layout/xml/makefile.win
Normal file
22
layout/xml/makefile.win
Normal file
@ -0,0 +1,22 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
DIRS = content document
|
||||
|
||||
include <$(DEPTH)\layout\config\rules.mak>
|
Loading…
Reference in New Issue
Block a user