Bug 15146. Brutal content model sharing, Phase II. XUL content sink now constructs prototype documents; 'real' content model constructed from walking prototype. Landed XUL_SHARING_19991027_BRANCH (derived from XUL_SHARING_19991022_BRANCH). See branch comments for details. r=hyatt.

git-svn-id: svn://10.0.0.236/trunk@52160 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
waterson%netscape.com 1999-10-29 01:21:15 +00:00
parent 19573259fb
commit 6d0e00cdd4
45 changed files with 8418 additions and 5962 deletions

View File

@ -52,8 +52,84 @@ static NS_DEFINE_CID(kCSSParserCID, NS_CSSPARSER_CID);
static NS_DEFINE_CID(kICSSParserIID, NS_ICSS_PARSER_IID);
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
//
// nsClassList
//
PRBool
nsClassList::HasClass(nsClassList* aList, nsIAtom* aClass)
{
const nsClassList* classList = aList;
while (nsnull != classList) {
if (classList->mAtom.get() == aClass) {
return PR_TRUE;
}
classList = classList->mNext;
}
return PR_FALSE;
}
nsresult
nsClassList::GetClasses(nsClassList* aList, nsVoidArray& aArray)
{
aArray.Clear();
const nsClassList* classList = aList;
while (nsnull != classList) {
aArray.AppendElement(classList->mAtom); // NOTE atom is not addrefed
classList = classList->mNext;
}
return NS_OK;
}
nsresult
nsClassList::ParseClasses(nsClassList** aList, const nsString& aClassString)
{
static const PRUnichar kNullCh = PRUnichar('\0');
if (*aList != nsnull) {
delete *aList;
*aList = nsnull;
}
if (aClassString.Length() > 0) {
nsAutoString classStr(aClassString); // copy to work buffer
classStr.Append(kNullCh); // put an extra null at the end
PRUnichar* start = (PRUnichar*)(const PRUnichar*)classStr.GetUnicode();
PRUnichar* end = start;
while (kNullCh != *start) {
while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space
start++;
}
end = start;
while ((kNullCh != *end) && (PR_FALSE == nsString::IsSpace(*end))) { // look for space or end
end++;
}
*end = kNullCh; // end string here
if (start < end) {
*aList = new nsClassList(NS_NewAtom(start));
aList = &((*aList)->mNext);
}
start = ++end;
}
}
return NS_OK;
}
//----------------------------------------------------------------------
//
// nsXULAttribute
//
nsXULAttribute::nsXULAttribute(nsIContent* aContent,
@ -356,8 +432,10 @@ nsXULAttribute::GetQualifiedName(nsString& aQualifiedName)
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
//
// nsXULAttributes
//
nsXULAttributes::nsXULAttributes(nsIContent* aContent)
: mContent(aContent),
@ -547,40 +625,18 @@ nsXULAttributes::SetScriptObject(void *aScriptObject)
nsresult
nsXULAttributes::GetClasses(nsVoidArray& aArray) const
{
aArray.Clear();
const nsClassList* classList = mClassList;
while (nsnull != classList) {
aArray.AppendElement(classList->mAtom); // NOTE atom is not addrefed
classList = classList->mNext;
}
return NS_OK;
return nsClassList::GetClasses(mClassList, aArray);
}
nsresult
nsXULAttributes::HasClass(nsIAtom* aClass) const
{
const nsClassList* classList = mClassList;
while (nsnull != classList) {
if (classList->mAtom.get() == aClass) {
return NS_OK;
}
classList = classList->mNext;
}
return NS_COMFALSE;
return nsClassList::HasClass(mClassList, aClass) ? NS_OK : NS_COMFALSE;
}
nsresult nsXULAttributes::UpdateClassList(const nsString& aValue)
{
if (mClassList != nsnull)
{
delete mClassList;
mClassList = nsnull;
}
if (aValue != "")
ParseClasses(aValue, &mClassList);
return NS_OK;
return nsClassList::ParseClasses(&mClassList, aValue);
}
nsresult nsXULAttributes::UpdateStyleRule(nsIURI* aDocURL, const nsString& aValue)
@ -630,37 +686,3 @@ nsresult nsXULAttributes::GetInlineStyleRule(nsIStyleRule*& aRule)
return result;
}
void
nsXULAttributes::ParseClasses(const nsString& aClassString, nsClassList** aClassList)
{
static const PRUnichar kNullCh = PRUnichar('\0');
NS_ASSERTION(nsnull == *aClassList, "non null start list");
nsAutoString classStr(aClassString); // copy to work buffer
classStr.Append(kNullCh); // put an extra null at the end
PRUnichar* start = (PRUnichar*)(const PRUnichar*)classStr.GetUnicode();
PRUnichar* end = start;
while (kNullCh != *start) {
while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space
start++;
}
end = start;
while ((kNullCh != *end) && (PR_FALSE == nsString::IsSpace(*end))) { // look for space or end
end++;
}
*end = kNullCh; // end string here
if (start < end) {
*aClassList = new nsClassList(NS_NewAtom(start));
aClassList = &((*aClassList)->mNext);
}
start = ++end;
}
}

View File

@ -37,7 +37,7 @@
class nsIURI;
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
class nsClassList {
public:
@ -60,6 +60,15 @@ public:
nsCOMPtr<nsIAtom> mAtom;
nsClassList* mNext;
static PRBool
HasClass(nsClassList* aList, nsIAtom* aClass);
static nsresult
GetClasses(nsClassList* aList, nsVoidArray& aArray);
static nsresult
ParseClasses(nsClassList** aList, const nsString& aValue);
private:
nsClassList& operator=(const nsClassList& aClassList) { return *this; } // not to be implemented
};
@ -152,9 +161,6 @@ protected:
nsXULAttributes(nsIContent* aContent);
virtual ~nsXULAttributes();
static void
ParseClasses(const nsString& aClassString, nsClassList** aClassList);
nsIContent* mContent;
nsClassList* mClassList;
nsIStyleRule* mStyleRule;

View File

@ -43,6 +43,7 @@
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMScriptObjectFactory.h"
#include "nsIDOMXULElement.h"
@ -67,15 +68,6 @@
#include "nsStyleConsts.h"
#include "nsIStyleSheet.h"
#include "nsIHTMLStyleSheet.h"
#include "nsIDOMMouseListener.h"
#include "nsIDOMMouseMotionListener.h"
#include "nsIDOMLoadListener.h"
#include "nsIDOMFocusListener.h"
#include "nsIDOMPaintListener.h"
#include "nsIDOMKeyListener.h"
#include "nsIDOMFormListener.h"
#include "nsIDOMMenuListener.h"
#include "nsIDOMDragListener.h"
#include "nsIScriptContextOwner.h"
#include "nsIStyledContent.h"
#include "nsIStyleContext.h"
@ -106,7 +98,7 @@ static const char kXULNameSpaceURI[] = XUL_NAMESPACE_URI;
static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI;
// End of XUL interface includes
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
@ -134,18 +126,9 @@ static NS_DEFINE_CID(kXULContentUtilsCID, NS_XULCONTENTUTILS_CID);
static NS_DEFINE_IID(kIXULPopupListenerIID, NS_IXULPOPUPLISTENER_IID);
static NS_DEFINE_CID(kXULPopupListenerCID, NS_XULPOPUPLISTENER_CID);
static NS_DEFINE_IID(kIDOMMouseListenerIID, NS_IDOMMOUSELISTENER_IID);
static NS_DEFINE_IID(kIDOMKeyListenerIID, NS_IDOMKEYLISTENER_IID);
static NS_DEFINE_IID(kIDOMMouseMotionListenerIID, NS_IDOMMOUSEMOTIONLISTENER_IID);
static NS_DEFINE_IID(kIDOMFocusListenerIID, NS_IDOMFOCUSLISTENER_IID);
static NS_DEFINE_IID(kIDOMFormListenerIID, NS_IDOMFORMLISTENER_IID);
static NS_DEFINE_IID(kIDOMLoadListenerIID, NS_IDOMLOADLISTENER_IID);
static NS_DEFINE_IID(kIDOMPaintListenerIID, NS_IDOMPAINTLISTENER_IID);
static NS_DEFINE_IID(kIDOMMenuListenerIID, NS_IDOMMENULISTENER_IID);
static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
struct XULBroadcastListener
{
@ -229,7 +212,7 @@ struct XULBroadcastListener
}
};
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
nsrefcnt nsXULElement::gRefCnt;
nsIRDFService* nsXULElement::gRDFService;
@ -255,101 +238,9 @@ nsIAtom* nsXULElement::kTreeColAtom;
nsIAtom* nsXULElement::kTreeItemAtom;
nsIAtom* nsXULElement::kTreeRowAtom;
nsIAtom* nsXULElement::kEditorAtom;
nsIAtom* nsXULElement::kWindowAtom;
// This is a simple datastructure that maps an event handler attribute
// name to an appropriate IID. Atoms are computed to improve
// comparison efficiency. We do this because SetAttribute() ends up
// being a pretty hot method.
struct EventHandlerMapEntry {
const char* mAttributeName;
nsIAtom* mAttributeAtom;
const nsIID* mHandlerIID;
};
static EventHandlerMapEntry kEventHandlerMap[] = {
{ "onclick", nsnull, &kIDOMMouseListenerIID },
{ "ondblclick", nsnull, &kIDOMMouseListenerIID },
{ "onmousedown", nsnull, &kIDOMMouseListenerIID },
{ "onmouseup", nsnull, &kIDOMMouseListenerIID },
{ "onmouseover", nsnull, &kIDOMMouseListenerIID },
{ "onmouseout", nsnull, &kIDOMMouseListenerIID },
{ "onmousemove", nsnull, &kIDOMMouseMotionListenerIID },
{ "onkeydown", nsnull, &kIDOMKeyListenerIID },
{ "onkeyup", nsnull, &kIDOMKeyListenerIID },
{ "onkeypress", nsnull, &kIDOMKeyListenerIID },
{ "onload", nsnull, &kIDOMLoadListenerIID },
{ "onunload", nsnull, &kIDOMLoadListenerIID },
{ "onabort", nsnull, &kIDOMLoadListenerIID },
{ "onerror", nsnull, &kIDOMLoadListenerIID },
{ "oncreate", nsnull, &kIDOMMenuListenerIID },
{ "ondestroy", nsnull, &kIDOMMenuListenerIID },
{ "oncommand", nsnull, &kIDOMMenuListenerIID },
{ "onbroadcast", nsnull, &kIDOMMenuListenerIID },
{ "oncommandupdate", nsnull, &kIDOMMenuListenerIID },
{ "onfocus", nsnull, &kIDOMFocusListenerIID },
{ "onblur", nsnull, &kIDOMFocusListenerIID },
{ "onsubmit", nsnull, &kIDOMFormListenerIID },
{ "onreset", nsnull, &kIDOMFormListenerIID },
{ "onchange", nsnull, &kIDOMFormListenerIID },
{ "onselect", nsnull, &kIDOMFormListenerIID },
{ "oninput", nsnull, &kIDOMFormListenerIID },
{ "onpaint", nsnull, &kIDOMPaintListenerIID },
{ "ondragenter", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ "ondragover", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ "ondragexit", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ "ondragdrop", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ "ondraggesture", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ nsnull, nsnull, nsnull }
};
////////////////////////////////////////////////////////////////////////
nsForwardReference::Result
nsXULElement::ObserverForwardReference::Resolve()
{
nsresult rv;
nsCOMPtr<nsIContent> content = do_QueryInterface(mListener);
if (! content)
return eResolveError;
nsCOMPtr<nsIDocument> doc;
rv = content->GetDocument(*getter_AddRefs(doc));
if (NS_FAILED(rv)) return eResolveError;
nsCOMPtr<nsIDOMXULDocument> xuldoc = do_QueryInterface(doc);
if (! xuldoc)
return eResolveError;
nsCOMPtr<nsIDOMElement> target;
rv = xuldoc->GetElementById(mTargetID, getter_AddRefs(target));
if (NS_FAILED(rv)) return eResolveError;
if (! target)
return eResolveLater;
nsCOMPtr<nsIDOMXULElement> broadcaster = do_QueryInterface(target);
if (! broadcaster)
return eResolveError;
rv = broadcaster->AddBroadcastListener(mAttributes, mListener);
if (NS_FAILED(rv)) return eResolveError;
return eResolveSucceeded;
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsXULElement
@ -394,12 +285,7 @@ nsXULElement::Init()
kTreeItemAtom = NS_NewAtom("treeitem");
kTreeRowAtom = NS_NewAtom("treerow");
kEditorAtom = NS_NewAtom("editor");
EventHandlerMapEntry* entry = kEventHandlerMap;
while (entry->mAttributeName) {
entry->mAttributeAtom = NS_NewAtom(entry->mAttributeName);
++entry;
}
kWindowAtom = NS_NewAtom("window");
rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID,
nsnull,
@ -469,6 +355,7 @@ nsXULElement::~nsXULElement()
NS_IF_RELEASE(kTreeItemAtom);
NS_IF_RELEASE(kTreeRowAtom);
NS_IF_RELEASE(kEditorAtom);
NS_IF_RELEASE(kWindowAtom);
NS_IF_RELEASE(gNameSpaceManager);
@ -476,20 +363,24 @@ nsXULElement::~nsXULElement()
nsServiceManager::ReleaseService(kXULContentUtilsCID, gXULUtils);
gXULUtils = nsnull;
}
EventHandlerMapEntry* entry = kEventHandlerMap;
while (entry->mAttributeName) {
NS_IF_RELEASE(entry->mAttributeAtom);
++entry;
}
}
}
nsresult
nsXULElement::Create(nsXULPrototypeElement* aPrototype, nsIContent** aResult)
nsXULElement::Create(nsXULPrototypeElement* aPrototype,
nsIDocument* aDocument,
nsIContent** aResult)
{
// Create an nsXULElement from a prototype
NS_PRECONDITION(aPrototype != nsnull, "null ptr");
if (! aPrototype)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aDocument != nsnull, "null ptr");
if (! aDocument)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aResult != nsnull, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
@ -507,6 +398,35 @@ nsXULElement::Create(nsXULPrototypeElement* aPrototype, nsIContent** aResult)
if (NS_FAILED(rv)) return rv;
element->mPrototype = aPrototype;
element->mDocument = aDocument;
// Check each attribute on the prototype to see if we need to do
// any additional processing and hookup that would otherwise be
// done 'automagically' by SetAttribute().
for (PRInt32 i = 0; i < aPrototype->mNumAttributes; ++i) {
nsXULPrototypeAttribute* attr = &(aPrototype->mAttributes[i]);
if (attr->mNameSpaceID == kNameSpaceID_None) {
// Check for an event handler
nsIID iid;
PRBool found;
rv = gXULUtils->GetEventHandlerIID(attr->mName, &iid, &found);
if (NS_FAILED(rv)) return rv;
if (found) {
rv = element->AddScriptEventListener(attr->mName, attr->mValue, iid);
if (NS_FAILED(rv)) return rv;
}
// Check for popup attributes
if ((attr->mName.get() == kPopupAtom) ||
(attr->mName.get() == kTooltipAtom) ||
(attr->mName.get() == kContextAtom)) {
rv = element->AddPopupListener(attr->mName);
if (NS_FAILED(rv)) return rv;
}
}
}
*aResult = NS_REINTERPRET_CAST(nsIStyledContent*, element);
NS_ADDREF(*aResult);
@ -544,7 +464,7 @@ nsXULElement::Create(PRInt32 aNameSpaceID, nsIAtom* aTag, nsIContent** aResult)
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsISupports interface
NS_IMPL_ADDREF(nsXULElement);
@ -633,7 +553,7 @@ nsXULElement::QueryInterface(REFNSIID iid, void** result)
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsIDOMNode interface
NS_IMETHODIMP
@ -1023,7 +943,7 @@ nsXULElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsIDOMElement interface
NS_IMETHODIMP
@ -1205,7 +1125,7 @@ nsXULElement::Normalize()
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsIXMLContent interface
NS_IMETHODIMP
@ -1297,7 +1217,7 @@ nsXULElement::SetNameSpaceID(PRInt32 aNameSpaceID)
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsIXULContent interface
NS_IMETHODIMP
@ -1342,6 +1262,56 @@ nsXULElement::GetLazyState(PRInt32 aFlag, PRBool& aResult)
}
NS_IMETHODIMP
nsXULElement::AddScriptEventListener(nsIAtom* aName, const nsString& aValue, REFNSIID aIID)
{
if (! mDocument)
return NS_OK; // XXX
nsresult rv;
nsCOMPtr<nsIScriptContext> context;
{
nsCOMPtr<nsIScriptContextOwner> owner =
dont_AddRef( mDocument->GetScriptContextOwner() );
// This can happen normally as part of teardown code.
if (! owner)
return NS_OK;
rv = owner->GetScriptContext(getter_AddRefs(context));
if (NS_FAILED(rv)) return rv;
}
if (Tag() == kWindowAtom) {
nsCOMPtr<nsIScriptGlobalObject> global = context->GetGlobalObject();
if (! global)
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIDOMEventReceiver> receiver = do_QueryInterface(global);
if (! receiver)
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIEventListenerManager> manager;
rv = receiver->GetListenerManager(getter_AddRefs(manager));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIScriptObjectOwner> owner = do_QueryInterface(global);
rv = manager->AddScriptEventListener(context, owner, aName, aValue, aIID);
}
else {
nsCOMPtr<nsIEventListenerManager> manager;
rv = GetListenerManager(getter_AddRefs(manager));
if (NS_FAILED(rv)) return rv;
rv = manager->AddScriptEventListener(context, this, aName, aValue, aIID);
}
return rv;
}
NS_IMETHODIMP
nsXULElement::ForceElementToOwnResource(PRBool aForce)
{
@ -1362,7 +1332,7 @@ nsXULElement::ForceElementToOwnResource(PRBool aForce)
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsIDOMEventReceiver interface
NS_IMETHODIMP
@ -1452,7 +1422,7 @@ nsXULElement::GetNewListenerManager(nsIEventListenerManager **aResult)
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsIScriptObjectOwner interface
NS_IMETHODIMP
@ -1516,7 +1486,7 @@ nsXULElement::SetScriptObject(void *aScriptObject)
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsIJSScriptObject interface
PRBool
@ -1576,7 +1546,7 @@ nsXULElement::Finalize(JSContext *aContext)
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsIContent interface
//
// Just to say this again (I said it in the header file), none of
@ -1687,61 +1657,7 @@ nsXULElement::GetParent(nsIContent*& aResult) const
NS_IMETHODIMP
nsXULElement::SetParent(nsIContent* aParent)
{
nsCOMPtr<nsIAtom> tagName;
GetTag(*getter_AddRefs(tagName));
mParent = aParent; // no refcount
// If we're an observes node, then we need to add our parent element
// as a broadcast listener.
if (mDocument && tagName && tagName.get() == kObservesAtom) {
// Find the node that we're supposed to be
// observing and perform the hookup.
nsAutoString elementValue;
nsAutoString attributeValue;
GetAttribute("element",
elementValue);
GetAttribute("attribute",
attributeValue);
nsCOMPtr<nsIDOMXULDocument> xulDocument( do_QueryInterface(mDocument) );
NS_ASSERTION(xulDocument != nsnull, "not in a XUL document");
if (! xulDocument)
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIDOMElement> listener( do_QueryInterface(aParent) );
if (! listener)
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIDOMElement> domElement;
xulDocument->GetElementById(elementValue, getter_AddRefs(domElement));
if (domElement) {
// We have a DOM element to bind to. Add a broadcast
// listener to that element, but only if it's a XUL element.
// XXX: Handle context nodes.
nsCOMPtr<nsIDOMXULElement> broadcaster( do_QueryInterface(domElement) );
if (broadcaster) {
broadcaster->AddBroadcastListener(attributeValue, listener);
}
}
else {
nsCOMPtr<nsIXULDocument> rdfdoc = do_QueryInterface(mDocument);
if (! rdfdoc)
return NS_ERROR_UNEXPECTED;
ObserverForwardReference* fwdref =
new ObserverForwardReference(listener, elementValue, attributeValue);
if (! fwdref)
return NS_ERROR_OUT_OF_MEMORY;
rdfdoc->AddForwardReference(fwdref);
}
}
return NS_OK;
}
@ -2103,62 +2019,32 @@ nsXULElement::SetAttribute(PRInt32 aNameSpaceID,
rv = EnsureSlots();
if (NS_FAILED(rv)) return rv;
rv = nsXULAttributes::Create(NS_STATIC_CAST(nsIStyledContent*, this), &(mSlots->mAttributes));
if (NS_FAILED(rv)) return rv;
// Since EnsureSlots() may have triggered mSlots->mAttributes construction,
// we need to check _again_ before creating attributes.
if (! Attributes()) {
rv = nsXULAttributes::Create(NS_STATIC_CAST(nsIStyledContent*, this), &(mSlots->mAttributes));
if (NS_FAILED(rv)) return rv;
}
}
// XXX Class and Style attribute setting should be checking for the XUL namespace!
// Check to see if the CLASS attribute is being set. If so, we need to rebuild our
// class list.
if (mDocument && (aNameSpaceID == kNameSpaceID_None) && aName == kClassAtom) {
if (mDocument && (aNameSpaceID == kNameSpaceID_None) && (aName == kClassAtom)) {
Attributes()->UpdateClassList(aValue);
}
// Check to see if the STYLE attribute is being set. If so, we need to create a new
// style rule based off the value of this attribute, and we need to let the document
// know about the StyleRule change.
if (mDocument && (aNameSpaceID == kNameSpaceID_None) && aName == kStyleAtom) {
if (mDocument && (aNameSpaceID == kNameSpaceID_None) && (aName == kStyleAtom)) {
nsCOMPtr <nsIURI> docURL;
if (nsnull != mDocument) {
mDocument->GetBaseURL(*getter_AddRefs(docURL));
}
mDocument->GetBaseURL(*getter_AddRefs(docURL));
Attributes()->UpdateStyleRule(docURL, aValue);
// XXX Some kind of special document update might need to happen here.
}
// Check to see if the OBSERVES attribute is being set. If so, we need to attach
// to the observed broadcaster.
if (mDocument && (aNameSpaceID == kNameSpaceID_None) &&
(aName == kObservesAtom))
{
// Do a getElementById to retrieve the broadcaster.
nsCOMPtr<nsIDOMElement> broadcaster;
nsCOMPtr<nsIDOMXULDocument> domDoc = do_QueryInterface(mDocument);
domDoc->GetElementById(aValue, getter_AddRefs(broadcaster));
if (broadcaster) {
nsCOMPtr<nsIDOMXULElement> xulBroadcaster = do_QueryInterface(broadcaster);
if (xulBroadcaster) {
xulBroadcaster->AddBroadcastListener("*", this);
}
}
else {
nsCOMPtr<nsIXULDocument> rdfdoc = do_QueryInterface(mDocument);
if (! rdfdoc)
return NS_ERROR_UNEXPECTED;
ObserverForwardReference* fwdref =
new ObserverForwardReference(this, aValue, nsAutoString("*"));
if (! fwdref)
return NS_ERROR_OUT_OF_MEMORY;
rdfdoc->AddForwardReference(fwdref);
}
}
// Need to check for the SELECTED attribute
// being set. If we're a <treeitem>, <treerow>, or <treecell>, the act of
// setting these attributes forces us to update our selected arrays.
@ -2197,37 +2083,7 @@ nsXULElement::SetAttribute(PRInt32 aNameSpaceID,
if (mDocument && (aNameSpaceID == kNameSpaceID_None) &&
(aName == kPopupAtom || aName == kTooltipAtom || aName == kContextAtom))
{
// Do a create instance of our popup listener.
nsIXULPopupListener* popupListener;
rv = nsComponentManager::CreateInstance(kXULPopupListenerCID,
nsnull,
kIXULPopupListenerIID,
(void**) &popupListener);
if (NS_FAILED(rv))
{
NS_ERROR("Unable to create an instance of the popup listener object.");
return rv;
}
XULPopupType popupType = eXULPopupType_popup;
if (aName == kTooltipAtom)
popupType = eXULPopupType_tooltip;
else if (aName == kContextAtom)
popupType = eXULPopupType_context;
// Add a weak reference to the node.
popupListener->Init(this, popupType);
// Add the popup as a listener on this element.
nsCOMPtr<nsIDOMEventListener> eventListener = do_QueryInterface(popupListener);
if (popupType == eXULPopupType_tooltip) {
AddEventListener("mouseout", eventListener, PR_FALSE);
AddEventListener("mousemove", eventListener, PR_FALSE);
}
else AddEventListener("mousedown", eventListener, PR_FALSE);
NS_IF_RELEASE(popupListener);
AddPopupListener(aName);
}
// XXX need to check if they're changing an event handler: if so, then we need
@ -2255,14 +2111,18 @@ nsXULElement::SetAttribute(PRInt32 aNameSpaceID,
Attributes()->AppendElement(attr);
}
// Check for event handlers and add a script listener if necessary.
EventHandlerMapEntry* entry = kEventHandlerMap;
while (entry->mAttributeAtom) {
if (entry->mAttributeAtom == aName) {
AddScriptEventListener(aName, aValue, *entry->mHandlerIID);
break;
// Check to see if this is an event handler, and add a script
// listener if necessary.
{
nsIID iid;
PRBool found;
rv = gXULUtils->GetEventHandlerIID(aName, &iid, &found);
if (NS_FAILED(rv)) return rv;
if (found) {
rv = AddScriptEventListener(aName, aValue, iid);
if (NS_FAILED(rv)) return rv;
}
++entry;
}
// Notify any broadcasters that are listening to this node.
@ -2292,64 +2152,6 @@ nsXULElement::SetAttribute(PRInt32 aNameSpaceID,
return rv;
}
nsresult
nsXULElement::AddScriptEventListener(nsIAtom* aName, const nsString& aValue, REFNSIID aIID)
{
if (! mDocument)
return NS_OK; // XXX
nsresult ret = NS_OK;
nsIScriptContext* context;
nsIScriptContextOwner* owner;
owner = mDocument->GetScriptContextOwner();
// This can happen normally as part of teardown code.
if (! owner)
return NS_OK;
nsAutoString tagStr;
Tag()->ToString(tagStr);
if (NS_OK == owner->GetScriptContext(&context)) {
if (tagStr == "window") {
nsIDOMEventReceiver *receiver;
nsIScriptGlobalObject *global = context->GetGlobalObject();
if (nsnull != global && NS_OK == global->QueryInterface(kIDOMEventReceiverIID, (void**)&receiver)) {
nsIEventListenerManager *manager;
if (NS_OK == receiver->GetListenerManager(&manager)) {
nsIScriptObjectOwner *mObjectOwner;
if (NS_OK == global->QueryInterface(kIScriptObjectOwnerIID, (void**)&mObjectOwner)) {
ret = manager->AddScriptEventListener(context, mObjectOwner, aName, aValue, aIID);
NS_RELEASE(mObjectOwner);
}
NS_RELEASE(manager);
}
NS_RELEASE(receiver);
}
NS_IF_RELEASE(global);
}
else {
nsIEventListenerManager *manager;
if (NS_OK == GetListenerManager(&manager)) {
nsIScriptObjectOwner* owner2;
if (NS_OK == QueryInterface(kIScriptObjectOwnerIID,
(void**) &owner2)) {
ret = manager->AddScriptEventListener(context, owner2,
aName, aValue, aIID);
NS_RELEASE(owner2);
}
NS_RELEASE(manager);
}
NS_RELEASE(context);
}
}
NS_RELEASE(owner);
return ret;
}
NS_IMETHODIMP
nsXULElement::GetAttribute(PRInt32 aNameSpaceID,
nsIAtom* aName,
@ -2383,7 +2185,7 @@ nsXULElement::GetAttribute(PRInt32 aNameSpaceID,
if (((attr->mNameSpaceID == aNameSpaceID) ||
(aNameSpaceID == kNameSpaceID_Unknown) ||
(aNameSpaceID == kNameSpaceID_None)) &&
(attr->mName == aName)) {
(attr->mName.get() == aName)) {
aResult = attr->mValue;
rv = aResult.Length() ? NS_CONTENT_ATTR_HAS_VALUE : NS_CONTENT_ATTR_NO_VALUE;
break;
@ -2543,8 +2345,8 @@ nsXULElement::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotif
NS_IMETHODIMP
nsXULElement::GetAttributeNameAt(PRInt32 aIndex,
PRInt32& aNameSpaceID,
nsIAtom*& aName) const
PRInt32& aNameSpaceID,
nsIAtom*& aName) const
{
if (Attributes()) {
nsXULAttribute* attr = NS_REINTERPRET_CAST(nsXULAttribute*, Attributes()->ElementAt(aIndex));
@ -2555,6 +2357,16 @@ nsXULElement::GetAttributeNameAt(PRInt32 aIndex,
return NS_OK;
}
}
else if (mPrototype) {
if (aIndex >= 0 && aIndex < mPrototype->mNumAttributes) {
nsXULPrototypeAttribute* attr = &(mPrototype->mAttributes[aIndex]);
aNameSpaceID = attr->mNameSpaceID;
aName = attr->mName;
NS_IF_ADDREF(aName);
return NS_OK;
}
}
aNameSpaceID = kNameSpaceID_None;
aName = nsnull;
return NS_ERROR_ILLEGAL_VALUE;
@ -2567,8 +2379,8 @@ nsXULElement::GetAttributeCount(PRInt32& aResult) const
if (Attributes()) {
aResult = Attributes()->Count();
}
else {
aResult = 0;
else if (mPrototype) {
aResult = mPrototype->mNumAttributes;
}
return rv;
@ -2588,16 +2400,30 @@ nsXULElement::List(FILE* out, PRInt32 aIndent) const
nsresult rv;
{
nsIAtom* tag;
if (NS_FAILED(rv = GetTag(tag)))
return rv;
rdf_Indent(out, aIndent);
fputs("[RDF ", out);
fputs("<XUL", out);
if (mSlots) fputs("*", out);
fputs(" ", out);
if (NameSpaceID() == kNameSpaceID_XUL) {
fputs("xul:", out);
}
else if (NameSpaceID() == kNameSpaceID_HTML) {
fputs("html:", out);
}
else if (NameSpaceID() == kNameSpaceID_None) {
fputs("none:", out);
}
else if (NameSpaceID() == kNameSpaceID_Unknown) {
fputs("unknown:", out);
}
else {
fputs("?:", out);
}
nsAutoString as;
tag->ToString(as);
Tag()->ToString(as);
fputs(as, out);
NS_RELEASE(tag);
}
{
@ -2609,7 +2435,6 @@ nsXULElement::List(FILE* out, PRInt32 aIndent) const
PRInt32 nameSpaceID;
GetAttributeNameAt(i, nameSpaceID, attr);
nsAutoString v;
GetAttribute(nameSpaceID, attr, v);
@ -2628,7 +2453,7 @@ nsXULElement::List(FILE* out, PRInt32 aIndent) const
return rv;
}
fputs("]\n", out);
fputs(">\n", out);
{
PRInt32 nchildren;
@ -2829,7 +2654,7 @@ nsXULElement::GetRangeList(nsVoidArray*& aResult) const
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsIDOMXULElement interface
NS_IMETHODIMP
@ -2996,7 +2821,7 @@ nsXULElement::SetDatabase(nsIRDFCompositeDataSource* aDatabase)
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// Implementation methods
nsresult
@ -3295,8 +3120,7 @@ nsXULElement::GetClasses(nsVoidArray& aArray) const
rv = Attributes()->GetClasses(aArray);
}
else if (mPrototype) {
//XXXwaterson check prototype for class list
NS_NOTYETIMPLEMENTED("write this");
rv = nsClassList::GetClasses(mPrototype->mClassList, aArray);
}
return rv;
}
@ -3309,8 +3133,7 @@ nsXULElement::HasClass(nsIAtom* aClass) const
rv = Attributes()->HasClass(aClass);
}
else if (mPrototype) {
//XXXwaterson check prototype for class list
NS_NOTYETIMPLEMENTED("write this");
rv = nsClassList::HasClass(mPrototype->mClassList, aClass) ? NS_OK : NS_COMFALSE;
}
return rv;
}
@ -3342,18 +3165,18 @@ nsXULElement::GetInlineStyleRules(nsISupportsArray* aRules)
{
// Fetch the cached style rule from the attributes.
nsresult result = NS_ERROR_NULL_POINTER;
nsIStyleRule* rule = nsnull;
nsCOMPtr<nsIStyleRule> rule;
if (aRules) {
if (Attributes()) {
result = Attributes()->GetInlineStyleRule(rule);
result = Attributes()->GetInlineStyleRule(*getter_AddRefs(rule));
}
else if (mPrototype) {
else if (mPrototype && mPrototype->mInlineStyleRule) {
rule = mPrototype->mInlineStyleRule;
result = NS_OK;
}
}
if (rule) {
aRules->AppendElement(rule);
NS_RELEASE(rule);
}
return result;
}
@ -3601,7 +3424,51 @@ nsXULElement::ParseNumericValue(const nsString& aString,
return PR_FALSE;
}
////////////////////////////////////////////////////////////////////////
nsresult
nsXULElement::AddPopupListener(nsIAtom* aName)
{
// Add a popup listener to the element
nsresult rv;
nsCOMPtr<nsIXULPopupListener> popupListener;
rv = nsComponentManager::CreateInstance(kXULPopupListenerCID,
nsnull,
kIXULPopupListenerIID,
getter_AddRefs(popupListener));
NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to create an instance of the popup listener object.");
if (NS_FAILED(rv)) return rv;
XULPopupType popupType;
if (aName == kTooltipAtom) {
popupType = eXULPopupType_tooltip;
}
else if (aName == kContextAtom) {
popupType = eXULPopupType_context;
}
else {
popupType = eXULPopupType_popup;
}
// Add a weak reference to the node.
popupListener->Init(this, popupType);
// Add the popup as a listener on this element.
nsCOMPtr<nsIDOMEventListener> eventListener = do_QueryInterface(popupListener);
if (popupType == eXULPopupType_tooltip) {
AddEventListener("mouseout", eventListener, PR_FALSE);
AddEventListener("mousemove", eventListener, PR_FALSE);
}
else {
AddEventListener("mousedown", eventListener, PR_FALSE);
}
return NS_OK;
}
//----------------------------------------------------------------------
nsresult
nsXULElement::EnsureSlots()
@ -3638,27 +3505,20 @@ nsXULElement::EnsureSlots()
for (PRInt32 i = 0; i < mPrototype->mNumAttributes; ++i) {
nsXULPrototypeAttribute* proto = &(mPrototype->mAttributes[i]);
// Create a CBufDescriptor to avoid copying the attribute's
// value just to set it.
CBufDescriptor desc(proto->mValue, PR_FALSE, nsCRT::strlen(proto->mValue), 0);
nsXULAttribute* attr;
rv = nsXULAttribute::Create(NS_STATIC_CAST(nsIStyledContent*, this),
proto->mNameSpaceID,
proto->mName,
nsAutoString(desc),
&attr);
// It's safe for us to call SetAttribute() now, because we
// won't re-enter. Plus, this saves us the hassle of copying
// all the crappy logic in SetAttribute() yet another time.
rv = SetAttribute(proto->mNameSpaceID, proto->mName, proto->mValue, PR_FALSE);
if (NS_FAILED(rv)) return rv;
// transfer ownership of the nsXULAttribute object
mSlots->mAttributes->AppendElement(attr);
}
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
//
// nsXULElement::Slots
//
nsXULElement::Slots::Slots(nsXULElement* aElement)
: mElement(aElement),
@ -3693,3 +3553,24 @@ nsXULElement::Slots::~Slots()
// Delete the aggregated interface, if one exists.
delete mInnerXULElement;
}
//----------------------------------------------------------------------
//
// nsXULPrototypeElement
//
nsresult
nsXULPrototypeElement::GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aValue)
{
for (PRInt32 i = 0; i < mNumAttributes; ++i) {
if ((mAttributes[i].mName.get() == aName) &&
(mAttributes[i].mNameSpaceID == aNameSpaceID)) {
aValue = mAttributes[i].mValue;
return aValue.Length() ? NS_CONTENT_ATTR_HAS_VALUE : NS_CONTENT_ATTR_NO_VALUE;
}
}
return NS_CONTENT_ATTR_NOT_THERE;
}

View File

@ -42,24 +42,26 @@
#include "nsIFocusableContent.h"
#include "nsIJSScriptObject.h"
#include "nsINameSpace.h"
#include "nsINameSpaceManager.h"
#include "nsIRDFCompositeDataSource.h"
#include "nsIRDFResource.h"
#include "nsIScriptObjectOwner.h"
#include "nsIStyleRule.h"
#include "nsIStyledContent.h"
#include "nsIURI.h"
#include "nsIXMLContent.h"
#include "nsIXULContent.h"
#include "nsXULAttributes.h"
class nsClassList;
class nsIDocument;
class nsIRDFService;
class nsISupportsArray;
class nsIXULContentUtils;
class nsIXULPrototypeDocument;
class nsRDFDOMNodeList;
class nsString;
class nsVoidArray;
class nsXULAttributes;
class nsXULPrototypeDocument;
////////////////////////////////////////////////////////////////////////
@ -69,11 +71,14 @@ class nsXULPrototypeDocument;
*/
struct nsXULPrototypeAttribute
class nsXULPrototypeAttribute
{
PRInt32 mNameSpaceID;
nsIAtom* mName;
PRUnichar* mValue;
public:
nsXULPrototypeAttribute() : mNameSpaceID(kNameSpaceID_Unknown) {}
PRInt32 mNameSpaceID;
nsCOMPtr<nsIAtom> mName;
nsString mValue;
};
@ -86,22 +91,109 @@ struct nsXULPrototypeAttribute
*/
struct nsXULPrototypeElement
{
nsXULPrototypeDocument* mDocument; // [OWNER] because doc is refcounted
PRInt32 mNumChildren;
nsXULPrototypeElement* mChildren; // [OWNER]
class nsXULPrototypeElement;
nsINameSpace* mNameSpace; // [OWNER]
nsIAtom* mNameSpacePrefix; // [OWNER]
class nsXULPrototypeNode
{
public:
enum Type { eType_Element, eType_Script, eType_Text };
Type mType;
PRInt32 mLineNo;
virtual ~nsXULPrototypeNode()
{
MOZ_COUNT_CTOR(nsXULPrototypeNode);
}
protected:
nsXULPrototypeNode(Type aType, PRInt32 aLineNo)
: mType(aType), mLineNo(aLineNo)
{
MOZ_COUNT_DTOR(nsXULPrototypeNode);
}
};
class nsXULPrototypeElement : public nsXULPrototypeNode
{
public:
nsXULPrototypeElement(PRInt32 aLineNo)
: nsXULPrototypeNode(eType_Element, aLineNo),
mDocument(nsnull),
mNumChildren(0),
mChildren(nsnull),
mNumAttributes(0),
mAttributes(nsnull),
mClassList(nsnull)
{
MOZ_COUNT_CTOR(nsXULPrototypeElement);
}
virtual ~nsXULPrototypeElement()
{
MOZ_COUNT_DTOR(nsXULPrototypeElement);
delete[] mAttributes;
delete mClassList;
for (PRInt32 i = mNumChildren - 1; i >= 0; --i)
delete mChildren[i];
delete[] mChildren;
}
nsIXULPrototypeDocument* mDocument; // [WEAK] because doc is refcounted
PRInt32 mNumChildren;
nsXULPrototypeNode** mChildren; // [OWNER]
nsCOMPtr<nsINameSpace> mNameSpace; // [OWNER]
nsCOMPtr<nsIAtom> mNameSpacePrefix; // [OWNER]
PRInt32 mNameSpaceID;
nsIAtom* mTag; // [OWNER]
nsCOMPtr<nsIAtom> mTag; // [OWNER]
PRInt32 mNumAttributes;
nsXULPrototypeAttribute* mAttributes; // [OWNER]
nsIStyleRule* mInlineStyleRule; // [OWNER]
nsCOMPtr<nsIStyleRule> mInlineStyleRule; // [OWNER]
nsClassList* mClassList;
nsresult GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aValue);
};
class nsXULPrototypeScript : public nsXULPrototypeNode
{
public:
nsXULPrototypeScript(PRInt32 aLineNo)
: nsXULPrototypeNode(eType_Script, aLineNo)
{
MOZ_COUNT_CTOR(nsXULPrototypeScript);
}
virtual ~nsXULPrototypeScript()
{
MOZ_COUNT_DTOR(nsXULPrototypeScript);
}
nsCOMPtr<nsIURI> mSrcURI;
nsString mInlineScript;
};
class nsXULPrototypeText : public nsXULPrototypeNode
{
public:
nsXULPrototypeText(PRInt32 aLineNo)
: nsXULPrototypeNode(eType_Text, aLineNo)
{
MOZ_COUNT_CTOR(nsXULPrototypeText);
}
virtual ~nsXULPrototypeText()
{
MOZ_COUNT_DTOR(nsXULPrototypeText);
}
nsString mValue;
};
@ -185,10 +277,11 @@ protected:
static nsIAtom* kTreeItemAtom;
static nsIAtom* kTreeRowAtom;
static nsIAtom* kEditorAtom;
static nsIAtom* kWindowAtom;
public:
static nsresult
Create(nsXULPrototypeElement* aPrototype, nsIContent** aResult);
Create(nsXULPrototypeElement* aPrototype, nsIDocument* aDocument, nsIContent** aResult);
static nsresult
Create(PRInt32 aNameSpaceID, nsIAtom* aTag, nsIContent** aResult);
@ -260,6 +353,7 @@ public:
NS_IMETHOD SetLazyState(PRInt32 aFlags);
NS_IMETHOD ClearLazyState(PRInt32 aFlags);
NS_IMETHOD GetLazyState(PRInt32 aFlag, PRBool& aValue);
NS_IMETHOD AddScriptEventListener(nsIAtom* aName, const nsString& aValue, REFNSIID aIID);
NS_IMETHOD ForceElementToOwnResource(PRBool aForce);
// nsIFocusableContent interface
@ -317,8 +411,6 @@ protected:
// Implementation methods
nsresult EnsureContentsGenerated(void) const;
nsresult AddScriptEventListener(nsIAtom* aName, const nsString& aValue, REFNSIID aIID);
nsresult ExecuteOnBroadcastHandler(nsIDOMElement* anElement, const nsString& attrName);
PRBool ElementIsInDocument();
@ -332,6 +424,7 @@ protected:
float& aFloatValue,
nsHTMLUnit& aValueUnit);
// Static helpers
static nsresult
GetElementsByTagName(nsIDOMNode* aNode,
const nsString& aTagName,
@ -350,6 +443,8 @@ protected:
PRBool IsFocusableContent();
nsresult AddPopupListener(nsIAtom* aName);
protected:
// Required fields
nsXULPrototypeElement* mPrototype;
@ -396,9 +491,9 @@ protected:
// appropriate default values if there are no slots defined in the
// delegate.
PRInt32 NameSpaceID() const { return mSlots ? mSlots->mNameSpaceID : mPrototype->mNameSpaceID; }
nsINameSpace* NameSpace() const { return mSlots ? mSlots->mNameSpace.get() : mPrototype->mNameSpace; }
nsIAtom* NameSpacePrefix() const { return mSlots ? mSlots->mNameSpacePrefix.get() : mPrototype->mNameSpacePrefix; }
nsIAtom* Tag() const { return mSlots ? mSlots->mTag.get() : mPrototype->mTag; }
nsINameSpace* NameSpace() const { return mSlots ? mSlots->mNameSpace.get() : mPrototype->mNameSpace.get(); }
nsIAtom* NameSpacePrefix() const { return mSlots ? mSlots->mNameSpacePrefix.get() : mPrototype->mNameSpacePrefix.get(); }
nsIAtom* Tag() const { return mSlots ? mSlots->mTag.get() : mPrototype->mTag.get(); }
void* ScriptObject() const { return mSlots ? mSlots->mScriptObject : nsnull; }
nsIEventListenerManager* ListenerManager() const { return mSlots ? mSlots->mListenerManager.get() : nsnull; }
nsVoidArray* BroadcastListeners() const { return mSlots ? mSlots->mBroadcastListeners : nsnull; }
@ -409,30 +504,6 @@ protected:
nsXULAttributes* Attributes() const { return mSlots ? mSlots->mAttributes : nsnull; }
nsXULAggregateElement* InnerXULElement() const { return mSlots ? mSlots->mInnerXULElement : nsnull; }
protected:
// XXX Move to nsXULContentSink?
class ObserverForwardReference : public nsForwardReference
{
protected:
nsCOMPtr<nsIDOMElement> mListener;
nsString mTargetID;
nsString mAttributes;
public:
ObserverForwardReference(nsIDOMElement* aListener,
const nsString& aTargetID,
const nsString& aAttributes) :
mListener(aListener),
mTargetID(aTargetID),
mAttributes(aAttributes) {}
virtual ~ObserverForwardReference() {}
virtual Result Resolve();
};
friend class ObserverForwardReference;
};

View File

@ -24,7 +24,7 @@
#include "nsIXMLContentSink.h"
class nsIDocument;
class nsIRDFDataSource;
class nsIXULPrototypeDocument;
// {E49AA620-C16C-11d2-A6AA-00104BDE6048}
#define NS_IXULCONTENTSINK_IID \
@ -36,11 +36,12 @@ class nsIXULContentSink : public nsIXMLContentSink
public:
static const nsIID& GetIID() { static nsIID iid = NS_IXULCONTENTSINK_IID; return iid; }
NS_IMETHOD Init(nsIDocument* aDocument) = 0;
NS_IMETHOD UnblockNextOverlay() = 0;
NS_IMETHOD UpdateOverlayCounters(PRInt32 aDelta) = 0;
/**
* Initialize the content sink, giving it an nsIDocument object
* with which to communicate with the outside world, and an
* nsIXULPrototypeDocument to build.
*/
NS_IMETHOD Init(nsIDocument* aDocument, nsIXULPrototypeDocument* aPrototype) = 0;
};

View File

@ -0,0 +1,51 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 nsIXULPrototypeCache_h__
#define nsIXULPrototypeCache_h__
#include "nsISupports.h"
class nsIURI;
class nsIXULPrototypeDocument;
// {3A0A0FC0-8349-11d3-BE47-00104BDE6048}
#define NS_IXULPROTOTYPECACHE_IID \
{ 0x3a0a0fc0, 0x8349, 0x11d3, { 0xbe, 0x47, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
class nsIXULPrototypeCache : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IXULPROTOTYPECACHE_IID);
NS_IMETHOD Get(nsIURI* aURI, nsIXULPrototypeDocument** _result) = 0;
NS_IMETHOD Put(nsIURI* aURI, nsIXULPrototypeDocument* aDocument) = 0;
};
extern NS_IMETHODIMP
NS_NewXULPrototypeCache(nsISupports* aOuter, REFNSIID aIID, void** aResult);
#endif // nsIXULPrototypeCache_h__

View File

@ -28,10 +28,51 @@ protected:
public:
virtual ~nsForwardReference() {}
/**
* Priority codes returned from GetPriority()
*/
enum Priority {
/** The initial pass, after which the content model will be
fully built */
ePriority_Construction,
/** A second pass, after which all 'magic attribute' hookup
will have been performed */
ePriority_Hookup,
/** A dummy marker, used in kPasses to indicate termination */
ePriority_Done
};
/**
* Forward references are categorized by 'priority', and all
* forward references in a higher priority are resolved before any
* reference in a lower priority. This variable specifies this
* ordering. The last Priority is guaranteed to be ePriority_Done.
*/
static const Priority kPasses[];
/**
* Get the priority of the forward reference. 'ePriority_Construction'
* references are all resolved before 'ePriority_Hookup' references
* are resolved.
*
* @return the Priority of the reference
*/
virtual Priority GetPriority() = 0;
/**
* Result codes returned from Resolve()
*/
enum Result {
eResolveSucceeded, // resolution succeeded, i'm done
eResolveLater, // couldn't resolve, try me later
eResolveError // something bad happened, don't try again
/** Resolution succeeded, I'm done. */
eResolve_Succeeded,
/** Couldn't resolve, but try me later. */
eResolve_Later,
/** Something bad happened, don't try again. */
eResolve_Error
};
/**

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,717 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 nsXULDocument_h__
#define nsXULDocument_h__
#include "nsCOMPtr.h"
#include "nsElementMap.h"
#include "nsForwardReference.h"
#include "nsIArena.h"
#include "nsICSSLoader.h"
#include "nsIContent.h"
#include "nsIDOMEventCapturer.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsIDOMNSDocument.h"
#include "nsIDOMSelection.h"
#include "nsIDOMXULCommandDispatcher.h"
#include "nsIDOMXULDocument.h"
#include "nsIDocument.h"
#include "nsIEventListenerManager.h"
#include "nsIHTMLCSSStyleSheet.h"
#include "nsIHTMLContentContainer.h"
#include "nsIHTMLStyleSheet.h"
#include "nsIJSScriptObject.h"
#include "nsILineBreakerFactory.h"
#include "nsINameSpaceManager.h"
#include "nsIParser.h"
#include "nsIPrincipal.h"
#include "nsIRDFDataSource.h"
#include "nsIScriptObjectOwner.h"
#include "nsIStreamLoadableDocument.h"
#include "nsISupportsArray.h"
#include "nsIURI.h"
#include "nsIWordBreakerFactory.h"
#include "nsIXULDocument.h"
#include "nsIXULPrototypeDocument.h"
#include "nsRDFDOMNodeList.h"
#include "nsVoidArray.h"
#include "nsWeakPtr.h"
#include "nsWeakReference.h"
class nsIAtom;
class nsIHTMLElementFactory;
class nsILoadGroup;
class nsIRDFResource;
class nsIRDFService;
class nsIScriptContextOwner;
class nsIUnicharStreamLoader;
class nsIXMLElementFactory;
class nsIXULContentUtils;
class nsIXULPrototypeCache;
struct PRLogModuleInfo;
/**
* The XUL document class
*/
class nsXULDocument : public nsIDocument,
public nsIXULDocument,
public nsIStreamLoadableDocument,
public nsIDOMXULDocument,
public nsIDOMNSDocument,
public nsIDOMEventCapturer,
public nsIJSScriptObject,
public nsIScriptObjectOwner,
public nsIHTMLContentContainer,
public nsSupportsWeakReference
{
public:
nsXULDocument();
virtual ~nsXULDocument();
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIDocument interface
virtual nsIArena* GetArena();
NS_IMETHOD GetContentType(nsString& aContentType) const;
NS_IMETHOD StartDocumentLoad(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsIContentViewerContainer* aContainer,
nsIStreamListener **aDocListener);
virtual const nsString* GetDocumentTitle() const;
virtual nsIURI* GetDocumentURL() const;
virtual nsIPrincipal* GetDocumentPrincipal();
NS_IMETHOD GetDocumentLoadGroup(nsILoadGroup **aGroup) const;
NS_IMETHOD GetBaseURL(nsIURI*& aURL) const;
NS_IMETHOD GetDocumentCharacterSet(nsString& oCharSetID);
NS_IMETHOD SetDocumentCharacterSet(const nsString& aCharSetID);
NS_IMETHOD GetLineBreaker(nsILineBreaker** aResult) ;
NS_IMETHOD SetLineBreaker(nsILineBreaker* aLineBreaker) ;
NS_IMETHOD GetWordBreaker(nsIWordBreaker** aResult) ;
NS_IMETHOD SetWordBreaker(nsIWordBreaker* aWordBreaker) ;
NS_IMETHOD GetHeaderData(nsIAtom* aHeaderField, nsString& aData) const;
NS_IMETHOD SetHeaderData(nsIAtom* aheaderField, const nsString& aData);
NS_IMETHOD CreateShell(nsIPresContext* aContext,
nsIViewManager* aViewManager,
nsIStyleSet* aStyleSet,
nsIPresShell** aInstancePtrResult);
virtual PRBool DeleteShell(nsIPresShell* aShell);
virtual PRInt32 GetNumberOfShells();
virtual nsIPresShell* GetShellAt(PRInt32 aIndex);
virtual nsIDocument* GetParentDocument();
virtual void SetParentDocument(nsIDocument* aParent);
virtual void AddSubDocument(nsIDocument* aSubDoc);
virtual PRInt32 GetNumberOfSubDocuments();
virtual nsIDocument* GetSubDocumentAt(PRInt32 aIndex);
virtual nsIContent* GetRootContent();
virtual void SetRootContent(nsIContent* aRoot);
NS_IMETHOD AppendToProlog(nsIContent* aContent);
NS_IMETHOD AppendToEpilog(nsIContent* aContent);
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const;
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const;
NS_IMETHOD GetChildCount(PRInt32& aCount);
virtual PRInt32 GetNumberOfStyleSheets();
virtual nsIStyleSheet* GetStyleSheetAt(PRInt32 aIndex);
virtual PRInt32 GetIndexOfStyleSheet(nsIStyleSheet* aSheet);
virtual void AddStyleSheet(nsIStyleSheet* aSheet);
NS_IMETHOD InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex, PRBool aNotify);
virtual void SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
PRBool mDisabled);
NS_IMETHOD GetCSSLoader(nsICSSLoader*& aLoader);
virtual nsIScriptContextOwner *GetScriptContextOwner();
virtual void SetScriptContextOwner(nsIScriptContextOwner *aScriptContextOwner);
NS_IMETHOD GetNameSpaceManager(nsINameSpaceManager*& aManager);
virtual void AddObserver(nsIDocumentObserver* aObserver);
virtual PRBool RemoveObserver(nsIDocumentObserver* aObserver);
NS_IMETHOD BeginLoad();
NS_IMETHOD EndLoad();
NS_IMETHOD ContentChanged(nsIContent* aContent,
nsISupports* aSubContent);
NS_IMETHOD ContentStatesChanged(nsIContent* aContent1, nsIContent* aContent2);
NS_IMETHOD AttributeChanged(nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aHint); // See nsStyleConsts fot hint values
NS_IMETHOD ContentAppended(nsIContent* aContainer,
PRInt32 aNewIndexInContainer);
NS_IMETHOD ContentInserted(nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer);
NS_IMETHOD ContentReplaced(nsIContent* aContainer,
nsIContent* aOldChild,
nsIContent* aNewChild,
PRInt32 aIndexInContainer);
NS_IMETHOD ContentRemoved(nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer);
NS_IMETHOD StyleRuleChanged(nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule,
PRInt32 aHint); // See nsStyleConsts fot hint values
NS_IMETHOD StyleRuleAdded(nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule);
NS_IMETHOD StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule);
NS_IMETHOD GetSelection(nsIDOMSelection** aSelection);
NS_IMETHOD SelectAll();
NS_IMETHOD FindNext(const nsString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound);
NS_IMETHOD CreateXIF(nsString & aBuffer, nsIDOMSelection* aSelection);
NS_IMETHOD ToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
virtual void BeginConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
virtual void ConvertChildrenToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
virtual void FinishConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
virtual PRBool IsInRange(const nsIContent *aStartContent, const nsIContent* aEndContent, const nsIContent* aContent) const;
virtual PRBool IsBefore(const nsIContent *aNewContent, const nsIContent* aCurrentContent) const;
virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const;
virtual nsIContent* GetPrevContent(const nsIContent *aContent) const;
virtual nsIContent* GetNextContent(const nsIContent *aContent) const;
virtual void SetDisplaySelection(PRBool aToggle);
virtual PRBool GetDisplaySelection() const;
NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
nsEventStatus& aEventStatus);
// nsIXMLDocument interface
NS_IMETHOD GetContentById(const nsString& aName, nsIContent** aContent);
#ifdef XSL
NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator);
#endif
// nsIXULDocument interface
NS_IMETHOD AddElementForID(const nsString& aID, nsIContent* aElement);
NS_IMETHOD RemoveElementForID(const nsString& aID, nsIContent* aElement);
NS_IMETHOD GetElementsForID(const nsString& aID, nsISupportsArray* aElements);
NS_IMETHOD CreateContents(nsIContent* aElement);
NS_IMETHOD AddContentModelBuilder(nsIRDFContentModelBuilder* aBuilder);
NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm);
NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm);
NS_IMETHOD AddForwardReference(nsForwardReference* aRef);
NS_IMETHOD ResolveForwardReferences();
NS_IMETHOD CreateFromPrototype(const char* aCommand,
nsIXULPrototypeDocument* aPrototype,
nsIPrincipal* aPrincipal,
nsIContentViewerContainer* aContainer);
// nsIStreamLoadableDocument interface
NS_IMETHOD LoadFromStream(nsIInputStream& xulStream,
nsIContentViewerContainer* aContainer,
const char* aCommand );
// nsIDOMEventCapturer interface
NS_IMETHOD CaptureEvent(const nsString& aType);
NS_IMETHOD ReleaseEvent(const nsString& aType);
// nsIDOMEventReceiver interface (yuck. inherited from nsIDOMEventCapturer)
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
NS_IMETHOD RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
NS_IMETHOD GetNewListenerManager(nsIEventListenerManager **aInstancePtrResult);
// nsIDOMEventTarget interface
NS_IMETHOD AddEventListener(const nsString& aType, nsIDOMEventListener* aListener,
PRBool aUseCapture);
NS_IMETHOD RemoveEventListener(const nsString& aType, nsIDOMEventListener* aListener,
PRBool aUseCapture);
// nsIDOMDocument interface
NS_IMETHOD GetDoctype(nsIDOMDocumentType** aDoctype);
NS_IMETHOD GetImplementation(nsIDOMDOMImplementation** aImplementation);
NS_IMETHOD GetDocumentElement(nsIDOMElement** aDocumentElement);
NS_IMETHOD CreateElement(const nsString& aTagName, nsIDOMElement** aReturn);
NS_IMETHOD CreateDocumentFragment(nsIDOMDocumentFragment** aReturn);
NS_IMETHOD CreateTextNode(const nsString& aData, nsIDOMText** aReturn);
NS_IMETHOD CreateComment(const nsString& aData, nsIDOMComment** aReturn);
NS_IMETHOD CreateCDATASection(const nsString& aData, nsIDOMCDATASection** aReturn);
NS_IMETHOD CreateProcessingInstruction(const nsString& aTarget, const nsString& aData, nsIDOMProcessingInstruction** aReturn);
NS_IMETHOD CreateAttribute(const nsString& aName, nsIDOMAttr** aReturn);
NS_IMETHOD CreateEntityReference(const nsString& aName, nsIDOMEntityReference** aReturn);
NS_IMETHOD GetElementsByTagName(const nsString& aTagname, nsIDOMNodeList** aReturn);
// nsIDOMNSDocument interface
NS_IMETHOD GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets);
NS_IMETHOD CreateElementWithNameSpace(const nsString& aTagName, const nsString& aNameSpace, nsIDOMElement** aResult);
NS_IMETHOD CreateRange(nsIDOMRange** aRange);
NS_IMETHOD GetWidth(PRInt32* aWidth);
NS_IMETHOD GetHeight(PRInt32* aHeight);
// nsIDOMXULDocument interface
NS_DECL_IDOMXULDOCUMENT
// 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 GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
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);
// nsIJSScriptObject interface
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);
// nsIScriptObjectOwner interface
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
NS_IMETHOD SetScriptObject(void *aScriptObject);
// nsIHTMLContentContainer interface
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult);
NS_IMETHOD GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult);
protected:
// Implementation methods
friend nsresult
NS_NewXULDocument(nsIXULDocument** aResult);
nsresult Init(void);
nsresult StartLayout(void);
nsresult OpenWidgetItem(nsIContent* aElement);
nsresult CloseWidgetItem(nsIContent* aElement);
nsresult RebuildWidgetItem(nsIContent* aElement);
nsresult
AddSubtreeToDocument(nsIContent* aElement);
nsresult
RemoveSubtreeFromDocument(nsIContent* aElement);
nsresult
AddElementToMap(nsIContent* aElement);
nsresult
RemoveElementFromMap(nsIContent* aElement);
static PRIntn
RemoveElementsFromMapByContent(const nsString& aID,
nsIContent* aElement,
void* aClosure);
static nsresult
GetElementsByTagName(nsIDOMNode* aNode,
const nsString& aTagName,
nsRDFDOMNodeList* aElements);
static nsresult
GetElementsByAttribute(nsIDOMNode* aNode,
const nsString& aAttribute,
const nsString& aValue,
nsRDFDOMNodeList* aElements);
nsresult
ParseTagString(const nsString& aTagName, nsIAtom*& aName, PRInt32& aNameSpaceID);
NS_IMETHOD PrepareStyleSheets(nsIURI* anURL);
void SetDocumentURLAndGroup(nsIURI* anURL);
void SetIsPopup(PRBool isPopup) { mIsPopup = isPopup; };
nsresult CreateElement(PRInt32 aNameSpaceID,
nsIAtom* aTag,
nsIContent** aResult);
nsresult PrepareToLoad(nsIContentViewerContainer* aContainer,
const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsIParser** aResult);
nsresult
PrepareToLoadPrototype(nsIURI* aURI,
const char* aCommand,
nsIParser** aResult);
nsresult ApplyPersistentAttributes();
nsresult ApplyPersistentAttributesToElements(nsIRDFResource* aResource, nsISupportsArray* aElements);
protected:
// pseudo constants
static PRInt32 gRefCnt;
static nsIAtom* kAttributeAtom;
static nsIAtom* kCommandUpdaterAtom;
static nsIAtom* kDataSourcesAtom;
static nsIAtom* kElementAtom;
static nsIAtom* kIdAtom;
static nsIAtom* kKeysetAtom;
static nsIAtom* kObservesAtom;
static nsIAtom* kOpenAtom;
static nsIAtom* kOverlayAtom;
static nsIAtom* kPersistAtom;
static nsIAtom* kPositionAtom;
static nsIAtom* kRefAtom;
static nsIAtom* kRuleAtom;
static nsIAtom* kTemplateAtom;
static nsIAtom** kIdentityAttrs[];
static nsIRDFService* gRDFService;
static nsIRDFResource* kNC_persist;
static nsIRDFResource* kNC_attribute;
static nsIRDFResource* kNC_value;
static nsIHTMLElementFactory* gHTMLElementFactory;
static nsIXMLElementFactory* gXMLElementFactory;
static nsINameSpaceManager* gNameSpaceManager;
static PRInt32 kNameSpaceID_XUL;
static nsIXULContentUtils* gXULUtils;
static nsIXULPrototypeCache* gXULPrototypeCache;
static PRLogModuleInfo* gXULLog;
nsIContent*
FindContent(const nsIContent* aStartNode,
const nsIContent* aTest1,
const nsIContent* aTest2) const;
nsresult
Persist(nsIContent* aElement, PRInt32 aNameSpaceID, nsIAtom* aAttribute);
nsresult
DestroyForwardReferences();
// IMPORTANT: The ownership implicit in the following member variables has been
// explicitly checked and set using nsCOMPtr for owning pointers and raw COM interface
// pointers for weak (ie, non owning) references. If you add any members to this
// class, please make the ownership explicit (pinkerton, scc).
// NOTE, THIS IS STILL IN PROGRESS, TALK TO PINK OR SCC BEFORE CHANGING
nsCOMPtr<nsIArena> mArena;
nsVoidArray mObservers;
nsAutoString mDocumentTitle;
nsCOMPtr<nsIURI> mDocumentURL; // [OWNER] ??? compare with loader
nsWeakPtr mDocumentLoadGroup; // [WEAK] leads to loader
nsCOMPtr<nsIPrincipal> mDocumentPrincipal; // [OWNER]
nsCOMPtr<nsIContent> mRootContent; // [OWNER]
nsIDocument* mParentDocument; // [WEAK]
nsIScriptContextOwner* mScriptContextOwner; // [WEAK] it owns me! (indirectly)
void* mScriptObject; // ????
nsString mCharSetID;
nsVoidArray mStyleSheets;
nsCOMPtr<nsIDOMSelection> mSelection; // [OWNER]
PRBool mDisplaySelection;
nsVoidArray mPresShells;
nsCOMPtr<nsIEventListenerManager> mListenerManager; // [OWNER]
nsCOMPtr<nsINameSpaceManager> mNameSpaceManager; // [OWNER]
nsCOMPtr<nsIHTMLStyleSheet> mAttrStyleSheet; // [OWNER]
nsCOMPtr<nsIHTMLCSSStyleSheet> mInlineStyleSheet; // [OWNER]
nsCOMPtr<nsICSSLoader> mCSSLoader; // [OWNER]
nsElementMap mElementMap;
nsCOMPtr<nsISupportsArray> mBuilders; // [OWNER] of array, elements shouldn't own this, but they do
nsCOMPtr<nsIRDFDataSource> mLocalStore;
nsCOMPtr<nsILineBreaker> mLineBreaker; // [OWNER]
nsCOMPtr<nsIWordBreaker> mWordBreaker; // [OWNER]
nsIContentViewerContainer* mContentViewerContainer; // [WEAK] it owns me! (indirectly)
nsString mCommand;
nsVoidArray mSubDocuments; // [OWNER] of subelements
PRBool mIsPopup;
nsCOMPtr<nsIDOMHTMLFormElement> mHiddenForm; // [OWNER] of this content element
nsCOMPtr<nsIDOMXULCommandDispatcher> mCommandDispatcher; // [OWNER] of the focus tracker
nsVoidArray mForwardReferences;
PRBool mForwardReferencesResolved;
// The following are pointers into the content model which provide access to
// the objects triggering either a popup or a tooltip. These are marked as
// [OWNER] only because someone could, through DOM calls, delete the object from the
// content model while the popup/tooltip was visible. If we didn't have a reference
// to it, the object would go away and we'd be left pointing to garbage. This
// does not introduce cycles into the ownership model because this is still
// parent/child ownership. Just wanted the reader to know hyatt and I had thought about
// this (pinkerton).
nsCOMPtr<nsIDOMNode> mPopupNode; // [OWNER] element triggering the popup
nsCOMPtr<nsIDOMNode> mTooltipNode; // [OWNER] element triggering the tooltip
/**
* Context stack, which maintains the state of the Builder and allows
* it to be interrupted.
*/
class ContextStack {
protected:
struct Entry {
nsXULPrototypeElement* mPrototype;
nsIContent* mElement;
PRInt32 mIndex;
Entry* mNext;
};
Entry* mTop;
PRInt32 mDepth;
public:
ContextStack();
~ContextStack();
PRInt32 Depth() { return mDepth; }
nsresult Push(nsXULPrototypeElement* aPrototype, nsIContent* aElement);
nsresult Pop();
nsresult Peek(nsXULPrototypeElement** aPrototype, nsIContent** aElement, PRInt32* aIndex);
nsresult SetTopIndex(PRInt32 aIndex);
PRBool IsInsideXULTemplate();
};
friend class ContextStack;
ContextStack mContextStack;
enum State { eState_Master, eState_Overlay };
State mState;
/**
* An array of overlay nsIURIs that have yet to be resolved. The
* order of the array is significant: overlays at the _end_ of the
* array are resolved before overlays earlier in the array (i.e.,
* it is a stack).
*/
nsCOMPtr<nsISupportsArray> mUnloadedOverlays;
/**
* Load the transcluded script at the specified URI. If the
* prototype construction must 'block' until the load has
* completed, aBlock will be set to true.
*/
nsresult LoadScript(nsIURI* aURI, PRBool* aBlock);
/**
* Evaluate the script text in aScript. aURL and aLineNo
* specify meta-information about the script in order to
* provide useful error messages.
*/
nsresult EvaluateScript(nsIURI* aURL, const nsString& aScript, PRInt32 aLinenNo);
/**
* Create a delegate content model element from a prototype.
*/
nsresult CreateElement(nsXULPrototypeElement* aPrototype, nsIContent** aResult);
/**
* Create a temporary 'overlay' element to which content nodes
* can be attached for later resolution.
*/
nsresult CreateOverlayElement(nsXULPrototypeElement* aPrototype, nsIContent** aResult);
/**
* Add attributes from the prototype to the element.
*/
nsresult AddAttributes(nsXULPrototypeElement* aPrototype, nsIContent* aElement);
/**
* Callback invoked when a transcluded script completes loading.
*/
static nsresult
DoneLoadingScript(nsIUnicharStreamLoader* aLoader,
nsString& aData,
void* aRef,
nsresult aStatus);
/**
* The URL of the current transcluded script that is being loaded
*/
nsCOMPtr<nsIURI> mCurrentScriptURL;
/**
* Create a XUL template builder on the specified node if a 'datasources'
* attribute is present.
*/
static nsresult
CheckTemplateBuilder(nsIContent* aElement);
/**
* Check the specified node and perform broadcaster/observer hookup,
* if necessary.
*/
nsresult CheckBroadcasterHookup(nsIContent* aElement);
/**
* Used to resolve broadcaster references
*/
class BroadcasterHookup : public nsForwardReference
{
protected:
nsCOMPtr<nsIContent> mObservesElement;
PRBool mResolved;
public:
BroadcasterHookup(nsIContent* aObservesElement) :
mObservesElement(aObservesElement), mResolved(PR_FALSE) {}
virtual ~BroadcasterHookup();
virtual Priority GetPriority() { return ePriority_Hookup; }
virtual Result Resolve();
};
friend class BroadcasterHookup;
/**
* Used to hook up overlays
*/
class OverlayForwardReference : public nsForwardReference
{
protected:
nsCOMPtr<nsIContent> mOverlay;
PRBool mResolved;
nsresult Merge(nsIContent* aTargetNode, nsIContent* aOverlayNode);
public:
OverlayForwardReference(nsIContent* aOverlay)
: mOverlay(aOverlay), mResolved(PR_FALSE) {}
virtual ~OverlayForwardReference();
virtual Priority GetPriority() { return ePriority_Construction; }
virtual Result Resolve();
};
friend class OverlayForwardReference;
static
nsresult
InsertElement(nsIContent* aParent, nsIContent* aChild);
static
nsresult
ProcessCommonAttributes(nsIContent* aElement);
/**
* The current prototype that we are walking to construct the
* content model.
*/
nsCOMPtr<nsIXULPrototypeDocument> mCurrentPrototype;
/**
* Owning references to all of the prototype documents that were
* used to construct this document.
*/
nsCOMPtr<nsISupportsArray> mPrototypes;
/**
* Prepare to walk the current prototype.
*/
nsresult PrepareToWalk();
/**
* Add overlays from the chrome registry to the set of unprocessed
* overlays still to do.
*/
nsresult AddChromeOverlays();
/**
* Resume (or initiate) an interrupted (or newly prepared)
* prototype walk.
*/
nsresult ResumeWalk();
};
#endif // nsXULDocument_h__

View File

@ -0,0 +1,157 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 "nsCOMPtr.h"
#include "nsXPIDLString.h"
#include "nsIXULPrototypeCache.h"
#include "nsIXULPrototypeDocument.h"
#include "nsIURI.h"
#include "plhash.h"
class nsXULPrototypeCache : public nsIXULPrototypeCache
{
public:
// nsISupports
NS_DECL_ISUPPORTS
NS_IMETHOD Get(nsIURI* aURI, nsIXULPrototypeDocument** _result);
NS_IMETHOD Put(nsIURI* aURI, nsIXULPrototypeDocument* aDocument);
protected:
friend NS_IMETHODIMP
NS_NewXULPrototypeCache(nsISupports* aOuter, REFNSIID aIID, void** aResult);
nsXULPrototypeCache();
virtual ~nsXULPrototypeCache();
static PRIntn ReleaseTableEntry(PLHashEntry* aHashEntry, PRIntn aIndex, void* aClosure);
nsresult Init();
static PLHashNumber Hash(const void* aKey);
static PRIntn CompareKeys(const void* aKey1, const void* aKey2);
PLHashTable* mTable;
};
nsXULPrototypeCache::nsXULPrototypeCache()
{
NS_INIT_REFCNT();
}
nsXULPrototypeCache::~nsXULPrototypeCache()
{
if (mTable) {
PL_HashTableEnumerateEntries(mTable, ReleaseTableEntry, nsnull);
PL_HashTableDestroy(mTable);
}
}
PRIntn
nsXULPrototypeCache::ReleaseTableEntry(PLHashEntry* aHashEntry, PRIntn aIndex, void* aClosure)
{
nsIURI* key = NS_REINTERPRET_CAST(nsIURI*, NS_CONST_CAST(void*, aHashEntry->key));
NS_RELEASE(key);
nsIXULPrototypeDocument* value = NS_REINTERPRET_CAST(nsIXULPrototypeDocument*, aHashEntry->value);
NS_RELEASE(value);
return HT_ENUMERATE_REMOVE;
}
nsresult
nsXULPrototypeCache::Init()
{
mTable = PL_NewHashTable(16, Hash, CompareKeys, PL_CompareValues, nsnull, nsnull);
if (! mTable)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMPL_ISUPPORTS1(nsXULPrototypeCache, nsIXULPrototypeCache);
NS_IMETHODIMP
NS_NewXULPrototypeCache(nsISupports* aOuter, REFNSIID aIID, void** aResult)
{
NS_PRECONDITION(! aOuter, "no aggregation");
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsXULPrototypeCache* result = new nsXULPrototypeCache();
if (! result)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv;
rv = result->Init();
if (NS_FAILED(rv)) {
delete result;
return rv;
}
NS_ADDREF(result);
rv = result->QueryInterface(aIID, aResult);
NS_RELEASE(result);
return rv;
}
PLHashNumber
nsXULPrototypeCache::Hash(const void* aKey)
{
nsIURI* uri = NS_REINTERPRET_CAST(nsIURI*, NS_CONST_CAST(void*, aKey));
nsXPIDLCString spec;
uri->GetSpec(getter_Copies(spec));
return PL_HashString(spec);
}
PRIntn
nsXULPrototypeCache::CompareKeys(const void* aKey1, const void* aKey2)
{
nsIURI* uri1 = NS_REINTERPRET_CAST(nsIURI*, NS_CONST_CAST(void*, aKey1));
nsIURI* uri2 = NS_REINTERPRET_CAST(nsIURI*, NS_CONST_CAST(void*, aKey2));
PRBool eq;
uri1->Equals(uri2, &eq);
return eq;
}
NS_IMETHODIMP
nsXULPrototypeCache::Get(nsIURI* aURI, nsIXULPrototypeDocument** _result)
{
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeCache::Put(nsIURI* aURI, nsIXULPrototypeDocument* aDocument)
{
return NS_OK;
}

View File

@ -0,0 +1,252 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 "nsCOMPtr.h"
#include "nsISupportsArray.h"
#include "nsIStyleSheet.h"
#include "nsIXULPrototypeDocument.h"
#include "nsIURI.h"
#include "nsString2.h"
#include "nsVoidArray.h"
#include "nsXULElement.h"
class nsXULPrototypeDocument : public nsIXULPrototypeDocument
{
public:
static nsresult
Create(nsIURI* aURI, nsXULPrototypeDocument** aResult);
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIXULPrototypeDocument interface
NS_IMETHOD GetURI(nsIURI** aResult);
NS_IMETHOD SetURI(nsIURI* aURI);
NS_IMETHOD GetRootElement(nsXULPrototypeElement** aResult);
NS_IMETHOD SetRootElement(nsXULPrototypeElement* aElement);
NS_IMETHOD AddStyleSheet(nsIStyleSheet* aStyleSheet);
NS_IMETHOD GetStyleSheets(nsVoidArray& aResult);
NS_IMETHOD AddOverlayReference(nsIURI* aURI);
NS_IMETHOD GetOverlayReferences(nsVoidArray& aResult);
NS_IMETHOD GetHeaderData(nsIAtom* aField, nsString& aData) const;
NS_IMETHOD SetHeaderData(nsIAtom* aField, const nsString& aData);
protected:
nsCOMPtr<nsIURI> mURI;
nsXULPrototypeElement* mRoot;
nsCOMPtr<nsISupportsArray> mStyleSheets;
nsCOMPtr<nsISupportsArray> mOverlayReferences;
nsXULPrototypeDocument();
virtual ~nsXULPrototypeDocument();
nsresult Init();
friend NS_IMETHODIMP
NS_NewXULPrototypeDocument(nsISupports* aOuter, REFNSIID aIID, void** aResult);
};
//----------------------------------------------------------------------
nsXULPrototypeDocument::nsXULPrototypeDocument()
: mRoot(nsnull)
{
NS_INIT_REFCNT();
}
nsresult
nsXULPrototypeDocument::Init()
{
nsresult rv;
rv = NS_NewISupportsArray(getter_AddRefs(mStyleSheets));
if (NS_FAILED(rv)) return rv;
rv = NS_NewISupportsArray(getter_AddRefs(mOverlayReferences));
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
nsXULPrototypeDocument::~nsXULPrototypeDocument()
{
delete mRoot;
}
NS_IMPL_ISUPPORTS1(nsXULPrototypeDocument, nsIXULPrototypeDocument);
NS_IMETHODIMP
NS_NewXULPrototypeDocument(nsISupports* aOuter, REFNSIID aIID, void** aResult)
{
NS_PRECONDITION(aOuter == nsnull, "no aggregation");
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsXULPrototypeDocument* result = new nsXULPrototypeDocument();
if (! result)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv;
rv = result->Init();
if (NS_FAILED(rv)) {
delete result;
return rv;
}
NS_ADDREF(result);
rv = result->QueryInterface(aIID, aResult);
NS_RELEASE(result);
return rv;
}
//----------------------------------------------------------------------
NS_IMETHODIMP
nsXULPrototypeDocument::GetURI(nsIURI** aResult)
{
*aResult = mURI;
NS_IF_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeDocument::SetURI(nsIURI* aURI)
{
mURI = aURI;
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeDocument::GetRootElement(nsXULPrototypeElement** aResult)
{
*aResult = mRoot;
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeDocument::SetRootElement(nsXULPrototypeElement* aElement)
{
mRoot = aElement;
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeDocument::AddStyleSheet(nsIStyleSheet* aStyleSheet)
{
NS_PRECONDITION(aStyleSheet != nsnull, "null ptr");
if (! aStyleSheet)
return NS_ERROR_NULL_POINTER;
mStyleSheets->AppendElement(aStyleSheet);
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeDocument::GetStyleSheets(nsVoidArray& aResult)
{
nsresult rv;
aResult.Clear();
PRUint32 cnt;
rv = mStyleSheets->Count(&cnt);
if (NS_FAILED(rv)) return rv;
for (PRInt32 i = 0; i < PRInt32(cnt); ++i) {
nsIStyleSheet* sheet = NS_REINTERPRET_CAST(nsIStyleSheet*, mStyleSheets->ElementAt(i));
aResult.AppendElement(sheet);
NS_RELEASE(sheet);
}
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeDocument::AddOverlayReference(nsIURI* aURI)
{
NS_PRECONDITION(aURI != nsnull, "null ptr");
if (! aURI)
return NS_ERROR_NULL_POINTER;
mOverlayReferences->AppendElement(aURI);
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeDocument::GetOverlayReferences(nsVoidArray& aResult)
{
nsresult rv;
aResult.Clear();
PRUint32 cnt;
rv = mOverlayReferences->Count(&cnt);
if (NS_FAILED(rv)) return rv;
for (PRInt32 i = 0; i < PRInt32(cnt); ++i) {
nsIURI* ref = NS_REINTERPRET_CAST(nsIURI*, mOverlayReferences->ElementAt(i));
aResult.AppendElement(ref);
NS_RELEASE(ref);
}
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeDocument::GetHeaderData(nsIAtom* aField, nsString& aData) const
{
// XXX Not implemented
aData.Truncate();
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeDocument::SetHeaderData(nsIAtom* aField, const nsString& aData)
{
// XXX Not implemented
return NS_OK;
}

View File

@ -31,6 +31,15 @@
#include "nsIDOMElement.h"
#include "nsIDOMXULCommandDispatcher.h"
#include "nsIDOMXULDocument.h"
#include "nsIDOMMouseListener.h"
#include "nsIDOMMouseMotionListener.h"
#include "nsIDOMLoadListener.h"
#include "nsIDOMFocusListener.h"
#include "nsIDOMPaintListener.h"
#include "nsIDOMKeyListener.h"
#include "nsIDOMFormListener.h"
#include "nsIDOMMenuListener.h"
#include "nsIDOMDragListener.h"
#include "nsIRDFNode.h"
#include "nsINameSpace.h"
#include "nsINameSpaceManager.h"
@ -96,6 +105,14 @@ protected:
static nsIAtom* kEventsAtom;
static nsIAtom* kTargetsAtom;
struct EventHandlerMapEntry {
const char* mAttributeName;
nsIAtom* mAttributeAtom;
const nsIID* mHandlerIID;
};
static EventHandlerMapEntry kEventHandlerMap[];
public:
// nsISupports methods
NS_DECL_ISUPPORTS
@ -150,6 +167,9 @@ public:
NS_IMETHOD
SetCommandUpdater(nsIDocument* aDocument, nsIContent* aElement);
NS_IMETHOD
GetEventHandlerIID(nsIAtom* aName, nsIID* aIID, PRBool* aFound);
};
nsrefcnt nsXULContentUtils::gRefCnt;
@ -160,6 +180,53 @@ nsIDateTimeFormat* nsXULContentUtils::gFormat;
nsIAtom* nsXULContentUtils::kEventsAtom;
nsIAtom* nsXULContentUtils::kTargetsAtom;
nsXULContentUtils::EventHandlerMapEntry
nsXULContentUtils::kEventHandlerMap[] = {
{ "onclick", nsnull, &NS_GET_IID(nsIDOMMouseListener) },
{ "ondblclick", nsnull, &NS_GET_IID(nsIDOMMouseListener) },
{ "onmousedown", nsnull, &NS_GET_IID(nsIDOMMouseListener) },
{ "onmouseup", nsnull, &NS_GET_IID(nsIDOMMouseListener) },
{ "onmouseover", nsnull, &NS_GET_IID(nsIDOMMouseListener) },
{ "onmouseout", nsnull, &NS_GET_IID(nsIDOMMouseListener) },
{ "onmousemove", nsnull, &NS_GET_IID(nsIDOMMouseMotionListener) },
{ "onkeydown", nsnull, &NS_GET_IID(nsIDOMKeyListener) },
{ "onkeyup", nsnull, &NS_GET_IID(nsIDOMKeyListener) },
{ "onkeypress", nsnull, &NS_GET_IID(nsIDOMKeyListener) },
{ "onload", nsnull, &NS_GET_IID(nsIDOMLoadListener) },
{ "onunload", nsnull, &NS_GET_IID(nsIDOMLoadListener) },
{ "onabort", nsnull, &NS_GET_IID(nsIDOMLoadListener) },
{ "onerror", nsnull, &NS_GET_IID(nsIDOMLoadListener) },
{ "oncreate", nsnull, &NS_GET_IID(nsIDOMMenuListener) },
{ "ondestroy", nsnull, &NS_GET_IID(nsIDOMMenuListener) },
{ "oncommand", nsnull, &NS_GET_IID(nsIDOMMenuListener) },
{ "onbroadcast", nsnull, &NS_GET_IID(nsIDOMMenuListener) },
{ "oncommandupdate", nsnull, &NS_GET_IID(nsIDOMMenuListener) },
{ "onfocus", nsnull, &NS_GET_IID(nsIDOMFocusListener) },
{ "onblur", nsnull, &NS_GET_IID(nsIDOMFocusListener) },
{ "onsubmit", nsnull, &NS_GET_IID(nsIDOMFormListener) },
{ "onreset", nsnull, &NS_GET_IID(nsIDOMFormListener) },
{ "onchange", nsnull, &NS_GET_IID(nsIDOMFormListener) },
{ "onselect", nsnull, &NS_GET_IID(nsIDOMFormListener) },
{ "oninput", nsnull, &NS_GET_IID(nsIDOMFormListener) },
{ "onpaint", nsnull, &NS_GET_IID(nsIDOMPaintListener) },
{ "ondragenter", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ "ondragover", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ "ondragexit", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ "ondragdrop", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ "ondraggesture", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ nsnull, nsnull, nsnull }
};
//------------------------------------------------------------------------
// Constructors n' stuff
@ -194,6 +261,12 @@ nsXULContentUtils::Init()
kEventsAtom = NS_NewAtom("events");
kTargetsAtom = NS_NewAtom("targets");
EventHandlerMapEntry* entry = kEventHandlerMap;
while (entry->mAttributeName) {
entry->mAttributeAtom = NS_NewAtom(entry->mAttributeName);
++entry;
}
}
return NS_OK;
}
@ -216,6 +289,12 @@ nsXULContentUtils::~nsXULContentUtils()
NS_IF_RELEASE(kEventsAtom);
NS_IF_RELEASE(kTargetsAtom);
EventHandlerMapEntry* entry = kEventHandlerMap;
while (entry->mAttributeName) {
NS_IF_RELEASE(entry->mAttributeAtom);
++entry;
}
}
}
@ -852,3 +931,20 @@ nsXULContentUtils::SetCommandUpdater(nsIDocument* aDocument, nsIContent* aElemen
return NS_OK;
}
NS_IMETHODIMP
nsXULContentUtils::GetEventHandlerIID(nsIAtom* aName, nsIID* aIID, PRBool* aFound)
{
*aFound = PR_FALSE;
EventHandlerMapEntry* entry = kEventHandlerMap;
while (entry->mAttributeAtom) {
if (entry->mAttributeAtom == aName) {
*aIID = *entry->mHandlerIID;
*aFound = PR_TRUE;
break;
}
++entry;
}
return NS_OK;
}

View File

@ -1658,17 +1658,19 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
nsXPIDLCString resourceCStr;
rv = aChild->GetValue(getter_Copies(resourceCStr));
if (NS_FAILED(rv)) return rv;
const PRUnichar *unicodeString;
tag->GetUnicode(&unicodeString);
nsAutoString tagStr(unicodeString);
char* tagCStr = tagStr.ToNewCString();
nsAutoString tagstr;
tag->ToString(tagstr);
nsAutoString templatestr;
aTemplateNode->GetAttribute(kNameSpaceID_None, kIdAtom, templatestr);
PR_LOG(gLog, PR_LOG_DEBUG,
("rdfgeneric[%p] build-content-from-template %s [%s]",
this, tagCStr, (const char*) resourceCStr));
nsCRT::free(tagCStr);
("rdfgeneric[%p] build-content-from-template %s (template='%s') [%s]",
this,
(const char*) nsCAutoString(tagstr),
(const char*) nsCAutoString(templatestr),
(const char*) resourceCStr));
}
#endif

View File

@ -86,10 +86,6 @@
#define NS_XULDOCUMENT_CID \
{ 0x541afcb2, 0xa9a3, 0x11d2, { 0x8e, 0xc5, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
// {F53279E1-D7A4-11d2-BF86-00105A1B0627}
#define NS_XULDOCUMENTINFO_CID \
{ 0xf53279e1, 0xd7a4, 0x11d2, { 0xbf, 0x86, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
// {1EAAFD60-D596-11d2-80BE-006097B76B8E}
#define NS_RDFHISTORYDATASOURCE_CID \
{ 0x1eaafd60, 0xd596, 0x11d2, { 0x80, 0xbe, 0x0, 0x60, 0x97, 0xb7, 0x6b, 0x8e } }
@ -128,4 +124,8 @@
#define NS_DLGDEFAULTKEYS_CID \
{ 0xdaedcb43, 0x1dd1, 0x11b2, { 0xb1, 0xd2, 0xca, 0xf0, 0x6c, 0xb4, 0x3, 0x87 } }
// {3A0A0FC1-8349-11d3-BE47-00104BDE6048}
#define NS_XULPROTOTYPECACHE_CID \
{ 0x3a0a0fc1, 0x8349, 0x11d3, { 0xbe, 0x47, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
#endif // nsRDFCID_h__

View File

@ -27,6 +27,7 @@
#include "nsIRDFContentSink.h"
#include "nsIRDFService.h"
#include "nsIXULContentSink.h"
#include "nsIXULPrototypeCache.h"
#include "nsISupports.h"
#include "nsRDFBaseDataSources.h"
#include "nsRDFBuiltInDataSources.h"
@ -37,7 +38,6 @@
#include "nsIXULContentUtils.h"
#include "nsIXULDocument.h"
#include "nsIXULSortService.h"
#include "nsIXULDocumentInfo.h"
#include "nsIXULPopupListener.h"
#include "nsIXULKeyListener.h"
#include "nsIXULCommandDispatcher.h"
@ -66,8 +66,8 @@ static NS_DEFINE_CID(kXULContentSinkCID, NS_XULCONTENTSINK_CID)
static NS_DEFINE_CID(kXULContentUtilsCID, NS_XULCONTENTUTILS_CID);
static NS_DEFINE_CID(kXULDocumentCID, NS_XULDOCUMENT_CID);
static NS_DEFINE_CID(kXULSortServiceCID, NS_XULSORTSERVICE_CID);
static NS_DEFINE_CID(kXULDocumentInfoCID, NS_XULDOCUMENTINFO_CID);
static NS_DEFINE_CID(kXULPopupListenerCID, NS_XULPOPUPLISTENER_CID);
static NS_DEFINE_CID(kXULPrototypeCacheCID, NS_XULPROTOTYPECACHE_CID);
static NS_DEFINE_CID(kXULKeyListenerCID, NS_XULKEYLISTENER_CID);
static NS_DEFINE_CID(kXULCommandDispatcherCID, NS_XULCOMMANDDISPATCHER_CID);
static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
@ -125,7 +125,6 @@ MAKE_CTOR(RDFContainer,RDFContainer,RDFContainer)
MAKE_CTOR(RDFContainerUtils,RDFContainerUtils,RDFContainerUtils)
MAKE_CTOR(XULDocument,XULDocument,XULDocument)
MAKE_CTOR(XULDocumentInfo,XULDocumentInfo,XULDocumentInfo)
MAKE_CTOR(XULTemplateBuilder,XULTemplateBuilder,RDFContentModelBuilder)
MAKE_CTOR(RDFContentSink,RDFContentSink,RDFContentSink)
@ -238,9 +237,6 @@ nsRDFModule::GetClassObject(nsIComponentManager *aCompMgr,
else if (aClass.Equals(kXULDocumentCID)) {
rv = NS_NewGenericFactory(getter_AddRefs(fact), CreateNewXULDocument);
}
else if (aClass.Equals(kXULDocumentInfoCID)) {
rv = NS_NewGenericFactory(getter_AddRefs(fact), CreateNewXULDocumentInfo);
}
else if (aClass.Equals(kXULPopupListenerCID)) {
rv = NS_NewGenericFactory(getter_AddRefs(fact), CreateNewXULPopupListener);
}
@ -256,6 +252,9 @@ nsRDFModule::GetClassObject(nsIComponentManager *aCompMgr,
else if (aClass.Equals(kXULContentUtilsCID)) {
rv = NS_NewGenericFactory(getter_AddRefs(fact), NS_NewXULContentUtils);
}
else if (aClass.Equals(kXULPrototypeCacheCID)) {
rv = NS_NewGenericFactory(getter_AddRefs(fact), NS_NewXULPrototypeCache);
}
else {
rv = NS_ERROR_FACTORY_NOT_REGISTERED;
#ifdef DEBUG
@ -318,8 +317,6 @@ static Components gComponents[] = {
NS_RDF_PROGID "/xul-content-sink", },
{ "XUL Document", &kXULDocumentCID,
NS_RDF_PROGID "/xul-document", },
{ "XUL Document Info", &kXULDocumentInfoCID,
NS_RDF_PROGID "/xul-document-info", },
{ "XUL PopupListener", &kXULPopupListenerCID,
NS_RDF_PROGID "/xul-popup-listener", },
{ "XUL KeyListener", &kXULKeyListenerCID,
@ -330,6 +327,8 @@ static Components gComponents[] = {
NS_RDF_PROGID "/xul-controllers", },
{ "XUL Content Utilities", &kXULContentUtilsCID,
NS_RDF_PROGID "/xul-content-utils", },
{ "XUL Prototype Cache", &kXULPrototypeCacheCID,
NS_RDF_PROGID "/xul-prototype-cache", },
};
#define NUM_COMPONENTS (sizeof(gComponents) / sizeof(gComponents[0]))

View File

@ -3,12 +3,10 @@ nsIDOMXULDocument.h
nsIDOMXULElement.h
nsIDOMXULTreeElement.h
nsIDOMXULEditorElement.h
nsIXULParentDocument.h
nsIXULChildDocument.h
nsIXULContentSink.h
nsIXULContentUtils.h
nsIXULDocumentInfo.h
nsIXULPopupListener.h
nsIXULPrototypeCache.h
nsIXULCommandDispatcher.h
nsIXULKeyListener.h
nsIStreamLoadableDocument.h

View File

@ -29,11 +29,9 @@ EXPORTS = \
nsIDOMXULElement.h \
nsIDOMXULTreeElement.h \
nsIDOMXULEditorElement.h \
nsIXULParentDocument.h \
nsIXULChildDocument.h \
nsIXULContentSink.h \
nsIXULDocumentInfo.h \
nsIXULPopupListener.h \
nsIXULPrototypeCache.h \
nsIDOMXULCommandDispatcher.h \
nsIXULContentUtils.h \
nsIXULCommandDispatcher.h \

View File

@ -24,12 +24,10 @@ EXPORTS = \
nsIDOMXULDocument.h \
nsIDOMXULElement.h \
nsIDOMXULTreeElement.h \
nsIDOMXULEditorElement.h \
nsIXULParentDocument.h \
nsIXULChildDocument.h \
nsIDOMXULEditorElement.h \
nsIXULContentSink.h \
nsIXULDocumentInfo.h \
nsIXULPopupListener.h \
nsIXULPrototypeCache.h \
nsIDOMXULCommandDispatcher.h \
nsIXULCommandDispatcher.h \
nsIXULContentUtils.h \

View File

@ -1,38 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
#ifndef nsIXULChildDocument_h__
#define nsIXULChildDocument_h__
#include "nsString.h"
// {7B75C621-D641-11d2-BF86-00105A1B0627}
#define NS_IXULCHILDDOCUMENT_IID \
{ 0x7b75c621, 0xd641, 0x11d2, { 0xbf, 0x86, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
class nsIXULContentSink;
class nsIXULChildDocument: public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IXULCHILDDOCUMENT_IID; return iid; }
NS_IMETHOD SetContentSink(nsIXULContentSink* aContentSink) = 0;
NS_IMETHOD GetContentSink(nsIXULContentSink** aContentSink) = 0;
};
#endif // nsIXULChildDocument_h__

View File

@ -24,7 +24,7 @@
#include "nsIXMLContentSink.h"
class nsIDocument;
class nsIRDFDataSource;
class nsIXULPrototypeDocument;
// {E49AA620-C16C-11d2-A6AA-00104BDE6048}
#define NS_IXULCONTENTSINK_IID \
@ -36,11 +36,12 @@ class nsIXULContentSink : public nsIXMLContentSink
public:
static const nsIID& GetIID() { static nsIID iid = NS_IXULCONTENTSINK_IID; return iid; }
NS_IMETHOD Init(nsIDocument* aDocument) = 0;
NS_IMETHOD UnblockNextOverlay() = 0;
NS_IMETHOD UpdateOverlayCounters(PRInt32 aDelta) = 0;
/**
* Initialize the content sink, giving it an nsIDocument object
* with which to communicate with the outside world, and an
* nsIXULPrototypeDocument to build.
*/
NS_IMETHOD Init(nsIDocument* aDocument, nsIXULPrototypeDocument* aPrototype) = 0;
};

View File

@ -95,6 +95,9 @@ public:
NS_IMETHOD
SetCommandUpdater(nsIDocument* aDocument, nsIContent* aElement) = 0;
NS_IMETHOD
GetEventHandlerIID(nsIAtom* aName, nsIID* aIID, PRBool* aFound) = 0;
};

View File

@ -1,50 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
/*
The sort service interface. This is a singleton object, and should be
obtained from the <tt>nsServiceManager</tt>.
*/
#ifndef nsIXULDocumentInfo_h__
#define nsIXULDocumentInfo_h__
#include "nsISupports.h"
// {798E24A1-D7A5-11d2-BF86-00105A1B0627}
#define NS_IXULDOCUMENTINFO_IID \
{ 0x798e24a1, 0xd7a5, 0x11d2, { 0xbf, 0x86, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
class nsIDocument;
class nsIXULContentSink;
class nsIXULDocumentInfo : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IXULDOCUMENTINFO_IID; return iid; }
NS_IMETHOD Init(nsIDocument* aParentDoc, nsIXULContentSink* aParentSink) = 0;
NS_IMETHOD GetDocument(nsIDocument** aResult) = 0;
NS_IMETHOD GetContentSink(nsIXULContentSink** aResult) = 0;
};
extern nsresult
NS_NewXULDocumentInfo(nsIXULDocumentInfo** result);
#endif // nsIXULDocumentInfo_h__

View File

@ -1,39 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
#ifndef nsIXULParentDocument_h__
#define nsIXULParentDocument_h__
#include "nsString.h"
// {9878C881-D63C-11d2-BF86-00105A1B0627}
#define NS_IXULPARENTDOCUMENT_IID \
{ 0x9878c881, 0xd63c, 0x11d2, { 0xbf, 0x86, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
class nsIContentViewerContainer;
class nsIXULParentDocument: public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IXULPARENTDOCUMENT_IID; return iid; }
// Used for XUL fragment child documents
NS_IMETHOD GetContentViewerContainer(nsIContentViewerContainer** aContainer) = 0;
NS_IMETHOD GetCommand(nsString& aCommand) = 0;
};
#endif // nsIXULParentDocument_h__

View File

@ -0,0 +1,51 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 nsIXULPrototypeCache_h__
#define nsIXULPrototypeCache_h__
#include "nsISupports.h"
class nsIURI;
class nsIXULPrototypeDocument;
// {3A0A0FC0-8349-11d3-BE47-00104BDE6048}
#define NS_IXULPROTOTYPECACHE_IID \
{ 0x3a0a0fc0, 0x8349, 0x11d3, { 0xbe, 0x47, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
class nsIXULPrototypeCache : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IXULPROTOTYPECACHE_IID);
NS_IMETHOD Get(nsIURI* aURI, nsIXULPrototypeDocument** _result) = 0;
NS_IMETHOD Put(nsIURI* aURI, nsIXULPrototypeDocument* aDocument) = 0;
};
extern NS_IMETHODIMP
NS_NewXULPrototypeCache(nsISupports* aOuter, REFNSIID aIID, void** aResult);
#endif // nsIXULPrototypeCache_h__

View File

@ -42,13 +42,14 @@ CPPSRCS = \
nsXULContentUtils.cpp \
nsXULDocument.cpp \
nsXULSortService.cpp \
nsXULDocumentInfo.cpp \
nsXULPopupListener.cpp \
nsXULCommandDispatcher.cpp \
nsXULControllers.cpp \
nsXULKeyListener.cpp \
nsXULTreeElement.cpp \
nsXULEditorElement.cpp \
nsXULPrototypeDocument.cpp \
nsXULPrototypeCache.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib.

View File

@ -34,6 +34,8 @@ CPP_OBJS=\
.\$(OBJDIR)\nsXULCommandDispatcher.obj \
.\$(OBJDIR)\nsXULControllers.obj \
.\$(OBJDIR)\nsXULPopupListener.obj \
.\$(OBJDIR)\nsXULPrototypeDocument.obj \
.\$(OBJDIR)\nsXULPrototypeCache.obj \
.\$(OBJDIR)\nsJSXULDocument.obj \
.\$(OBJDIR)\nsJSXULElement.obj \
.\$(OBJDIR)\nsJSXULTreeElement.obj \
@ -43,11 +45,10 @@ CPP_OBJS=\
.\$(OBJDIR)\nsXULContentUtils.obj \
.\$(OBJDIR)\nsXULContentSink.obj \
.\$(OBJDIR)\nsXULDocument.obj \
.\$(OBJDIR)\nsXULDocumentInfo.obj \
.\$(OBJDIR)\nsXULKeyListener.obj \
.\$(OBJDIR)\nsXULSortService.obj \
.\$(OBJDIR)\nsXULTreeElement.obj \
.\$(OBJDIR)\nsXULEditorElement.obj \
.\$(OBJDIR)\nsXULEditorElement.obj \
$(NULL)
# XXX we are including layout\html\base\src to get HTML elements

View File

@ -28,10 +28,51 @@ protected:
public:
virtual ~nsForwardReference() {}
/**
* Priority codes returned from GetPriority()
*/
enum Priority {
/** The initial pass, after which the content model will be
fully built */
ePriority_Construction,
/** A second pass, after which all 'magic attribute' hookup
will have been performed */
ePriority_Hookup,
/** A dummy marker, used in kPasses to indicate termination */
ePriority_Done
};
/**
* Forward references are categorized by 'priority', and all
* forward references in a higher priority are resolved before any
* reference in a lower priority. This variable specifies this
* ordering. The last Priority is guaranteed to be ePriority_Done.
*/
static const Priority kPasses[];
/**
* Get the priority of the forward reference. 'ePriority_Construction'
* references are all resolved before 'ePriority_Hookup' references
* are resolved.
*
* @return the Priority of the reference
*/
virtual Priority GetPriority() = 0;
/**
* Result codes returned from Resolve()
*/
enum Result {
eResolveSucceeded, // resolution succeeded, i'm done
eResolveLater, // couldn't resolve, try me later
eResolveError // something bad happened, don't try again
/** Resolution succeeded, I'm done. */
eResolve_Succeeded,
/** Couldn't resolve, but try me later. */
eResolve_Later,
/** Something bad happened, don't try again. */
eResolve_Error
};
/**

View File

@ -27,6 +27,8 @@
#define nsIXULContent_h__
#include "nsISupports.h"
class nsIAtom;
class nsString;
// {39C5ECC0-5C47-11d3-BE36-00104BDE6048}
#define NS_IXULCONTENT_IID \
@ -85,6 +87,11 @@ public:
*/
NS_IMETHOD GetLazyState(PRInt32 aFlag, PRBool& aResult) = 0;
/**
* Add a script event listener to the element.
*/
NS_IMETHOD AddScriptEventListener(nsIAtom* aName, const nsString& aValue, REFNSIID aIID) = 0;
/**
* Evil rotten hack to make mailnews work. They assume that we
* keep a reference to their resource objects. If you think you

View File

@ -36,14 +36,14 @@ class nsIContent; // XXX nsIXMLDocument.h is bad and doesn't declare this class.
class nsForwardReference;
class nsIAtom;
class nsIRDFCompositeDataSource;
class nsIRDFContent;
class nsIRDFContentModelBuilder;
class nsISupportsArray;
class nsIRDFResource;
class nsIContentViewerContainer;
class nsIDOMElement;
class nsIDOMHTMLFormElement;
class nsIChannel;
class nsIPrincipal;
class nsIRDFContentModelBuilder;
class nsIRDFResource;
class nsISupportsArray;
class nsIXULPrototypeDocument;
// {954F0811-81DC-11d2-B52A-000000000000}
#define NS_IRDFDOCUMENT_IID \
@ -101,7 +101,13 @@ public:
NS_IMETHOD ResolveForwardReferences() = 0;
NS_IMETHOD GetChannel(nsIChannel **aResult) = 0;
/**
* Create a XUL document from a prototype
*/
NS_IMETHOD CreateFromPrototype(const char* aCommand,
nsIXULPrototypeDocument* aPrototype,
nsIPrincipal* aPrincipal,
nsIContentViewerContainer* aContainer) = 0;
};
// factory functions

View File

@ -0,0 +1,74 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 nsIXULPrototypeDocument_h__
#define nsIXULPrototypeDocument_h__
#include "nsISupports.h"
class nsIAtom;
class nsIURI;
class nsIStyleSheet;
class nsString;
class nsVoidArray;
class nsXULPrototypeElement;
// {187A63D0-8337-11d3-BE47-00104BDE6048}
#define NS_IXULPROTOTYPEDOCUMENT_IID \
{ 0x187a63d0, 0x8337, 0x11d3, { 0xbe, 0x47, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
class nsIXULPrototypeDocument : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IXULPROTOTYPEDOCUMENT_IID);
/**
* Retrieve the URI of the document
*/
NS_IMETHOD SetURI(nsIURI* aURI) = 0;
NS_IMETHOD GetURI(nsIURI** aResult) = 0;
/**
* Retrieve the root XULPrototype element of the document.
*/
NS_IMETHOD GetRootElement(nsXULPrototypeElement** aResult) = 0;
NS_IMETHOD SetRootElement(nsXULPrototypeElement* aElement) = 0;
NS_IMETHOD AddStyleSheet(nsIStyleSheet* aStyleSheet) = 0;
NS_IMETHOD GetStyleSheets(nsVoidArray& aResult) = 0;
NS_IMETHOD AddOverlayReference(nsIURI* aURI) = 0;
NS_IMETHOD GetOverlayReferences(nsVoidArray& aResult) = 0;
NS_IMETHOD GetHeaderData(nsIAtom* aField, nsString& aData) const = 0;
NS_IMETHOD SetHeaderData(nsIAtom* aField, const nsString& aData) = 0;
};
extern NS_IMETHODIMP
NS_NewXULPrototypeDocument(nsISupports* aOuter, REFNSIID aIID, void** aResult);
#endif // nsIXULPrototypeDocument_h__

View File

@ -1658,17 +1658,19 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
nsXPIDLCString resourceCStr;
rv = aChild->GetValue(getter_Copies(resourceCStr));
if (NS_FAILED(rv)) return rv;
const PRUnichar *unicodeString;
tag->GetUnicode(&unicodeString);
nsAutoString tagStr(unicodeString);
char* tagCStr = tagStr.ToNewCString();
nsAutoString tagstr;
tag->ToString(tagstr);
nsAutoString templatestr;
aTemplateNode->GetAttribute(kNameSpaceID_None, kIdAtom, templatestr);
PR_LOG(gLog, PR_LOG_DEBUG,
("rdfgeneric[%p] build-content-from-template %s [%s]",
this, tagCStr, (const char*) resourceCStr));
nsCRT::free(tagCStr);
("rdfgeneric[%p] build-content-from-template %s (template='%s') [%s]",
this,
(const char*) nsCAutoString(tagstr),
(const char*) nsCAutoString(templatestr),
(const char*) resourceCStr));
}
#endif

View File

@ -52,8 +52,84 @@ static NS_DEFINE_CID(kCSSParserCID, NS_CSSPARSER_CID);
static NS_DEFINE_CID(kICSSParserIID, NS_ICSS_PARSER_IID);
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
//
// nsClassList
//
PRBool
nsClassList::HasClass(nsClassList* aList, nsIAtom* aClass)
{
const nsClassList* classList = aList;
while (nsnull != classList) {
if (classList->mAtom.get() == aClass) {
return PR_TRUE;
}
classList = classList->mNext;
}
return PR_FALSE;
}
nsresult
nsClassList::GetClasses(nsClassList* aList, nsVoidArray& aArray)
{
aArray.Clear();
const nsClassList* classList = aList;
while (nsnull != classList) {
aArray.AppendElement(classList->mAtom); // NOTE atom is not addrefed
classList = classList->mNext;
}
return NS_OK;
}
nsresult
nsClassList::ParseClasses(nsClassList** aList, const nsString& aClassString)
{
static const PRUnichar kNullCh = PRUnichar('\0');
if (*aList != nsnull) {
delete *aList;
*aList = nsnull;
}
if (aClassString.Length() > 0) {
nsAutoString classStr(aClassString); // copy to work buffer
classStr.Append(kNullCh); // put an extra null at the end
PRUnichar* start = (PRUnichar*)(const PRUnichar*)classStr.GetUnicode();
PRUnichar* end = start;
while (kNullCh != *start) {
while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space
start++;
}
end = start;
while ((kNullCh != *end) && (PR_FALSE == nsString::IsSpace(*end))) { // look for space or end
end++;
}
*end = kNullCh; // end string here
if (start < end) {
*aList = new nsClassList(NS_NewAtom(start));
aList = &((*aList)->mNext);
}
start = ++end;
}
}
return NS_OK;
}
//----------------------------------------------------------------------
//
// nsXULAttribute
//
nsXULAttribute::nsXULAttribute(nsIContent* aContent,
@ -356,8 +432,10 @@ nsXULAttribute::GetQualifiedName(nsString& aQualifiedName)
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
//
// nsXULAttributes
//
nsXULAttributes::nsXULAttributes(nsIContent* aContent)
: mContent(aContent),
@ -547,40 +625,18 @@ nsXULAttributes::SetScriptObject(void *aScriptObject)
nsresult
nsXULAttributes::GetClasses(nsVoidArray& aArray) const
{
aArray.Clear();
const nsClassList* classList = mClassList;
while (nsnull != classList) {
aArray.AppendElement(classList->mAtom); // NOTE atom is not addrefed
classList = classList->mNext;
}
return NS_OK;
return nsClassList::GetClasses(mClassList, aArray);
}
nsresult
nsXULAttributes::HasClass(nsIAtom* aClass) const
{
const nsClassList* classList = mClassList;
while (nsnull != classList) {
if (classList->mAtom.get() == aClass) {
return NS_OK;
}
classList = classList->mNext;
}
return NS_COMFALSE;
return nsClassList::HasClass(mClassList, aClass) ? NS_OK : NS_COMFALSE;
}
nsresult nsXULAttributes::UpdateClassList(const nsString& aValue)
{
if (mClassList != nsnull)
{
delete mClassList;
mClassList = nsnull;
}
if (aValue != "")
ParseClasses(aValue, &mClassList);
return NS_OK;
return nsClassList::ParseClasses(&mClassList, aValue);
}
nsresult nsXULAttributes::UpdateStyleRule(nsIURI* aDocURL, const nsString& aValue)
@ -630,37 +686,3 @@ nsresult nsXULAttributes::GetInlineStyleRule(nsIStyleRule*& aRule)
return result;
}
void
nsXULAttributes::ParseClasses(const nsString& aClassString, nsClassList** aClassList)
{
static const PRUnichar kNullCh = PRUnichar('\0');
NS_ASSERTION(nsnull == *aClassList, "non null start list");
nsAutoString classStr(aClassString); // copy to work buffer
classStr.Append(kNullCh); // put an extra null at the end
PRUnichar* start = (PRUnichar*)(const PRUnichar*)classStr.GetUnicode();
PRUnichar* end = start;
while (kNullCh != *start) {
while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space
start++;
}
end = start;
while ((kNullCh != *end) && (PR_FALSE == nsString::IsSpace(*end))) { // look for space or end
end++;
}
*end = kNullCh; // end string here
if (start < end) {
*aClassList = new nsClassList(NS_NewAtom(start));
aClassList = &((*aClassList)->mNext);
}
start = ++end;
}
}

View File

@ -37,7 +37,7 @@
class nsIURI;
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
class nsClassList {
public:
@ -60,6 +60,15 @@ public:
nsCOMPtr<nsIAtom> mAtom;
nsClassList* mNext;
static PRBool
HasClass(nsClassList* aList, nsIAtom* aClass);
static nsresult
GetClasses(nsClassList* aList, nsVoidArray& aArray);
static nsresult
ParseClasses(nsClassList** aList, const nsString& aValue);
private:
nsClassList& operator=(const nsClassList& aClassList) { return *this; } // not to be implemented
};
@ -152,9 +161,6 @@ protected:
nsXULAttributes(nsIContent* aContent);
virtual ~nsXULAttributes();
static void
ParseClasses(const nsString& aClassString, nsClassList** aClassList);
nsIContent* mContent;
nsClassList* mClassList;
nsIStyleRule* mStyleRule;

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,15 @@
#include "nsIDOMElement.h"
#include "nsIDOMXULCommandDispatcher.h"
#include "nsIDOMXULDocument.h"
#include "nsIDOMMouseListener.h"
#include "nsIDOMMouseMotionListener.h"
#include "nsIDOMLoadListener.h"
#include "nsIDOMFocusListener.h"
#include "nsIDOMPaintListener.h"
#include "nsIDOMKeyListener.h"
#include "nsIDOMFormListener.h"
#include "nsIDOMMenuListener.h"
#include "nsIDOMDragListener.h"
#include "nsIRDFNode.h"
#include "nsINameSpace.h"
#include "nsINameSpaceManager.h"
@ -96,6 +105,14 @@ protected:
static nsIAtom* kEventsAtom;
static nsIAtom* kTargetsAtom;
struct EventHandlerMapEntry {
const char* mAttributeName;
nsIAtom* mAttributeAtom;
const nsIID* mHandlerIID;
};
static EventHandlerMapEntry kEventHandlerMap[];
public:
// nsISupports methods
NS_DECL_ISUPPORTS
@ -150,6 +167,9 @@ public:
NS_IMETHOD
SetCommandUpdater(nsIDocument* aDocument, nsIContent* aElement);
NS_IMETHOD
GetEventHandlerIID(nsIAtom* aName, nsIID* aIID, PRBool* aFound);
};
nsrefcnt nsXULContentUtils::gRefCnt;
@ -160,6 +180,53 @@ nsIDateTimeFormat* nsXULContentUtils::gFormat;
nsIAtom* nsXULContentUtils::kEventsAtom;
nsIAtom* nsXULContentUtils::kTargetsAtom;
nsXULContentUtils::EventHandlerMapEntry
nsXULContentUtils::kEventHandlerMap[] = {
{ "onclick", nsnull, &NS_GET_IID(nsIDOMMouseListener) },
{ "ondblclick", nsnull, &NS_GET_IID(nsIDOMMouseListener) },
{ "onmousedown", nsnull, &NS_GET_IID(nsIDOMMouseListener) },
{ "onmouseup", nsnull, &NS_GET_IID(nsIDOMMouseListener) },
{ "onmouseover", nsnull, &NS_GET_IID(nsIDOMMouseListener) },
{ "onmouseout", nsnull, &NS_GET_IID(nsIDOMMouseListener) },
{ "onmousemove", nsnull, &NS_GET_IID(nsIDOMMouseMotionListener) },
{ "onkeydown", nsnull, &NS_GET_IID(nsIDOMKeyListener) },
{ "onkeyup", nsnull, &NS_GET_IID(nsIDOMKeyListener) },
{ "onkeypress", nsnull, &NS_GET_IID(nsIDOMKeyListener) },
{ "onload", nsnull, &NS_GET_IID(nsIDOMLoadListener) },
{ "onunload", nsnull, &NS_GET_IID(nsIDOMLoadListener) },
{ "onabort", nsnull, &NS_GET_IID(nsIDOMLoadListener) },
{ "onerror", nsnull, &NS_GET_IID(nsIDOMLoadListener) },
{ "oncreate", nsnull, &NS_GET_IID(nsIDOMMenuListener) },
{ "ondestroy", nsnull, &NS_GET_IID(nsIDOMMenuListener) },
{ "oncommand", nsnull, &NS_GET_IID(nsIDOMMenuListener) },
{ "onbroadcast", nsnull, &NS_GET_IID(nsIDOMMenuListener) },
{ "oncommandupdate", nsnull, &NS_GET_IID(nsIDOMMenuListener) },
{ "onfocus", nsnull, &NS_GET_IID(nsIDOMFocusListener) },
{ "onblur", nsnull, &NS_GET_IID(nsIDOMFocusListener) },
{ "onsubmit", nsnull, &NS_GET_IID(nsIDOMFormListener) },
{ "onreset", nsnull, &NS_GET_IID(nsIDOMFormListener) },
{ "onchange", nsnull, &NS_GET_IID(nsIDOMFormListener) },
{ "onselect", nsnull, &NS_GET_IID(nsIDOMFormListener) },
{ "oninput", nsnull, &NS_GET_IID(nsIDOMFormListener) },
{ "onpaint", nsnull, &NS_GET_IID(nsIDOMPaintListener) },
{ "ondragenter", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ "ondragover", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ "ondragexit", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ "ondragdrop", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ "ondraggesture", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ nsnull, nsnull, nsnull }
};
//------------------------------------------------------------------------
// Constructors n' stuff
@ -194,6 +261,12 @@ nsXULContentUtils::Init()
kEventsAtom = NS_NewAtom("events");
kTargetsAtom = NS_NewAtom("targets");
EventHandlerMapEntry* entry = kEventHandlerMap;
while (entry->mAttributeName) {
entry->mAttributeAtom = NS_NewAtom(entry->mAttributeName);
++entry;
}
}
return NS_OK;
}
@ -216,6 +289,12 @@ nsXULContentUtils::~nsXULContentUtils()
NS_IF_RELEASE(kEventsAtom);
NS_IF_RELEASE(kTargetsAtom);
EventHandlerMapEntry* entry = kEventHandlerMap;
while (entry->mAttributeName) {
NS_IF_RELEASE(entry->mAttributeAtom);
++entry;
}
}
}
@ -852,3 +931,20 @@ nsXULContentUtils::SetCommandUpdater(nsIDocument* aDocument, nsIContent* aElemen
return NS_OK;
}
NS_IMETHODIMP
nsXULContentUtils::GetEventHandlerIID(nsIAtom* aName, nsIID* aIID, PRBool* aFound)
{
*aFound = PR_FALSE;
EventHandlerMapEntry* entry = kEventHandlerMap;
while (entry->mAttributeAtom) {
if (entry->mAttributeAtom == aName) {
*aIID = *entry->mHandlerIID;
*aFound = PR_TRUE;
break;
}
++entry;
}
return NS_OK;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,717 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 nsXULDocument_h__
#define nsXULDocument_h__
#include "nsCOMPtr.h"
#include "nsElementMap.h"
#include "nsForwardReference.h"
#include "nsIArena.h"
#include "nsICSSLoader.h"
#include "nsIContent.h"
#include "nsIDOMEventCapturer.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsIDOMNSDocument.h"
#include "nsIDOMSelection.h"
#include "nsIDOMXULCommandDispatcher.h"
#include "nsIDOMXULDocument.h"
#include "nsIDocument.h"
#include "nsIEventListenerManager.h"
#include "nsIHTMLCSSStyleSheet.h"
#include "nsIHTMLContentContainer.h"
#include "nsIHTMLStyleSheet.h"
#include "nsIJSScriptObject.h"
#include "nsILineBreakerFactory.h"
#include "nsINameSpaceManager.h"
#include "nsIParser.h"
#include "nsIPrincipal.h"
#include "nsIRDFDataSource.h"
#include "nsIScriptObjectOwner.h"
#include "nsIStreamLoadableDocument.h"
#include "nsISupportsArray.h"
#include "nsIURI.h"
#include "nsIWordBreakerFactory.h"
#include "nsIXULDocument.h"
#include "nsIXULPrototypeDocument.h"
#include "nsRDFDOMNodeList.h"
#include "nsVoidArray.h"
#include "nsWeakPtr.h"
#include "nsWeakReference.h"
class nsIAtom;
class nsIHTMLElementFactory;
class nsILoadGroup;
class nsIRDFResource;
class nsIRDFService;
class nsIScriptContextOwner;
class nsIUnicharStreamLoader;
class nsIXMLElementFactory;
class nsIXULContentUtils;
class nsIXULPrototypeCache;
struct PRLogModuleInfo;
/**
* The XUL document class
*/
class nsXULDocument : public nsIDocument,
public nsIXULDocument,
public nsIStreamLoadableDocument,
public nsIDOMXULDocument,
public nsIDOMNSDocument,
public nsIDOMEventCapturer,
public nsIJSScriptObject,
public nsIScriptObjectOwner,
public nsIHTMLContentContainer,
public nsSupportsWeakReference
{
public:
nsXULDocument();
virtual ~nsXULDocument();
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIDocument interface
virtual nsIArena* GetArena();
NS_IMETHOD GetContentType(nsString& aContentType) const;
NS_IMETHOD StartDocumentLoad(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsIContentViewerContainer* aContainer,
nsIStreamListener **aDocListener);
virtual const nsString* GetDocumentTitle() const;
virtual nsIURI* GetDocumentURL() const;
virtual nsIPrincipal* GetDocumentPrincipal();
NS_IMETHOD GetDocumentLoadGroup(nsILoadGroup **aGroup) const;
NS_IMETHOD GetBaseURL(nsIURI*& aURL) const;
NS_IMETHOD GetDocumentCharacterSet(nsString& oCharSetID);
NS_IMETHOD SetDocumentCharacterSet(const nsString& aCharSetID);
NS_IMETHOD GetLineBreaker(nsILineBreaker** aResult) ;
NS_IMETHOD SetLineBreaker(nsILineBreaker* aLineBreaker) ;
NS_IMETHOD GetWordBreaker(nsIWordBreaker** aResult) ;
NS_IMETHOD SetWordBreaker(nsIWordBreaker* aWordBreaker) ;
NS_IMETHOD GetHeaderData(nsIAtom* aHeaderField, nsString& aData) const;
NS_IMETHOD SetHeaderData(nsIAtom* aheaderField, const nsString& aData);
NS_IMETHOD CreateShell(nsIPresContext* aContext,
nsIViewManager* aViewManager,
nsIStyleSet* aStyleSet,
nsIPresShell** aInstancePtrResult);
virtual PRBool DeleteShell(nsIPresShell* aShell);
virtual PRInt32 GetNumberOfShells();
virtual nsIPresShell* GetShellAt(PRInt32 aIndex);
virtual nsIDocument* GetParentDocument();
virtual void SetParentDocument(nsIDocument* aParent);
virtual void AddSubDocument(nsIDocument* aSubDoc);
virtual PRInt32 GetNumberOfSubDocuments();
virtual nsIDocument* GetSubDocumentAt(PRInt32 aIndex);
virtual nsIContent* GetRootContent();
virtual void SetRootContent(nsIContent* aRoot);
NS_IMETHOD AppendToProlog(nsIContent* aContent);
NS_IMETHOD AppendToEpilog(nsIContent* aContent);
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const;
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const;
NS_IMETHOD GetChildCount(PRInt32& aCount);
virtual PRInt32 GetNumberOfStyleSheets();
virtual nsIStyleSheet* GetStyleSheetAt(PRInt32 aIndex);
virtual PRInt32 GetIndexOfStyleSheet(nsIStyleSheet* aSheet);
virtual void AddStyleSheet(nsIStyleSheet* aSheet);
NS_IMETHOD InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex, PRBool aNotify);
virtual void SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
PRBool mDisabled);
NS_IMETHOD GetCSSLoader(nsICSSLoader*& aLoader);
virtual nsIScriptContextOwner *GetScriptContextOwner();
virtual void SetScriptContextOwner(nsIScriptContextOwner *aScriptContextOwner);
NS_IMETHOD GetNameSpaceManager(nsINameSpaceManager*& aManager);
virtual void AddObserver(nsIDocumentObserver* aObserver);
virtual PRBool RemoveObserver(nsIDocumentObserver* aObserver);
NS_IMETHOD BeginLoad();
NS_IMETHOD EndLoad();
NS_IMETHOD ContentChanged(nsIContent* aContent,
nsISupports* aSubContent);
NS_IMETHOD ContentStatesChanged(nsIContent* aContent1, nsIContent* aContent2);
NS_IMETHOD AttributeChanged(nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aHint); // See nsStyleConsts fot hint values
NS_IMETHOD ContentAppended(nsIContent* aContainer,
PRInt32 aNewIndexInContainer);
NS_IMETHOD ContentInserted(nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer);
NS_IMETHOD ContentReplaced(nsIContent* aContainer,
nsIContent* aOldChild,
nsIContent* aNewChild,
PRInt32 aIndexInContainer);
NS_IMETHOD ContentRemoved(nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer);
NS_IMETHOD StyleRuleChanged(nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule,
PRInt32 aHint); // See nsStyleConsts fot hint values
NS_IMETHOD StyleRuleAdded(nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule);
NS_IMETHOD StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule);
NS_IMETHOD GetSelection(nsIDOMSelection** aSelection);
NS_IMETHOD SelectAll();
NS_IMETHOD FindNext(const nsString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound);
NS_IMETHOD CreateXIF(nsString & aBuffer, nsIDOMSelection* aSelection);
NS_IMETHOD ToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
virtual void BeginConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
virtual void ConvertChildrenToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
virtual void FinishConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
virtual PRBool IsInRange(const nsIContent *aStartContent, const nsIContent* aEndContent, const nsIContent* aContent) const;
virtual PRBool IsBefore(const nsIContent *aNewContent, const nsIContent* aCurrentContent) const;
virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const;
virtual nsIContent* GetPrevContent(const nsIContent *aContent) const;
virtual nsIContent* GetNextContent(const nsIContent *aContent) const;
virtual void SetDisplaySelection(PRBool aToggle);
virtual PRBool GetDisplaySelection() const;
NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
nsEventStatus& aEventStatus);
// nsIXMLDocument interface
NS_IMETHOD GetContentById(const nsString& aName, nsIContent** aContent);
#ifdef XSL
NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator);
#endif
// nsIXULDocument interface
NS_IMETHOD AddElementForID(const nsString& aID, nsIContent* aElement);
NS_IMETHOD RemoveElementForID(const nsString& aID, nsIContent* aElement);
NS_IMETHOD GetElementsForID(const nsString& aID, nsISupportsArray* aElements);
NS_IMETHOD CreateContents(nsIContent* aElement);
NS_IMETHOD AddContentModelBuilder(nsIRDFContentModelBuilder* aBuilder);
NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm);
NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm);
NS_IMETHOD AddForwardReference(nsForwardReference* aRef);
NS_IMETHOD ResolveForwardReferences();
NS_IMETHOD CreateFromPrototype(const char* aCommand,
nsIXULPrototypeDocument* aPrototype,
nsIPrincipal* aPrincipal,
nsIContentViewerContainer* aContainer);
// nsIStreamLoadableDocument interface
NS_IMETHOD LoadFromStream(nsIInputStream& xulStream,
nsIContentViewerContainer* aContainer,
const char* aCommand );
// nsIDOMEventCapturer interface
NS_IMETHOD CaptureEvent(const nsString& aType);
NS_IMETHOD ReleaseEvent(const nsString& aType);
// nsIDOMEventReceiver interface (yuck. inherited from nsIDOMEventCapturer)
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
NS_IMETHOD RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
NS_IMETHOD GetNewListenerManager(nsIEventListenerManager **aInstancePtrResult);
// nsIDOMEventTarget interface
NS_IMETHOD AddEventListener(const nsString& aType, nsIDOMEventListener* aListener,
PRBool aUseCapture);
NS_IMETHOD RemoveEventListener(const nsString& aType, nsIDOMEventListener* aListener,
PRBool aUseCapture);
// nsIDOMDocument interface
NS_IMETHOD GetDoctype(nsIDOMDocumentType** aDoctype);
NS_IMETHOD GetImplementation(nsIDOMDOMImplementation** aImplementation);
NS_IMETHOD GetDocumentElement(nsIDOMElement** aDocumentElement);
NS_IMETHOD CreateElement(const nsString& aTagName, nsIDOMElement** aReturn);
NS_IMETHOD CreateDocumentFragment(nsIDOMDocumentFragment** aReturn);
NS_IMETHOD CreateTextNode(const nsString& aData, nsIDOMText** aReturn);
NS_IMETHOD CreateComment(const nsString& aData, nsIDOMComment** aReturn);
NS_IMETHOD CreateCDATASection(const nsString& aData, nsIDOMCDATASection** aReturn);
NS_IMETHOD CreateProcessingInstruction(const nsString& aTarget, const nsString& aData, nsIDOMProcessingInstruction** aReturn);
NS_IMETHOD CreateAttribute(const nsString& aName, nsIDOMAttr** aReturn);
NS_IMETHOD CreateEntityReference(const nsString& aName, nsIDOMEntityReference** aReturn);
NS_IMETHOD GetElementsByTagName(const nsString& aTagname, nsIDOMNodeList** aReturn);
// nsIDOMNSDocument interface
NS_IMETHOD GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets);
NS_IMETHOD CreateElementWithNameSpace(const nsString& aTagName, const nsString& aNameSpace, nsIDOMElement** aResult);
NS_IMETHOD CreateRange(nsIDOMRange** aRange);
NS_IMETHOD GetWidth(PRInt32* aWidth);
NS_IMETHOD GetHeight(PRInt32* aHeight);
// nsIDOMXULDocument interface
NS_DECL_IDOMXULDOCUMENT
// 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 GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
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);
// nsIJSScriptObject interface
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);
// nsIScriptObjectOwner interface
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
NS_IMETHOD SetScriptObject(void *aScriptObject);
// nsIHTMLContentContainer interface
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult);
NS_IMETHOD GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult);
protected:
// Implementation methods
friend nsresult
NS_NewXULDocument(nsIXULDocument** aResult);
nsresult Init(void);
nsresult StartLayout(void);
nsresult OpenWidgetItem(nsIContent* aElement);
nsresult CloseWidgetItem(nsIContent* aElement);
nsresult RebuildWidgetItem(nsIContent* aElement);
nsresult
AddSubtreeToDocument(nsIContent* aElement);
nsresult
RemoveSubtreeFromDocument(nsIContent* aElement);
nsresult
AddElementToMap(nsIContent* aElement);
nsresult
RemoveElementFromMap(nsIContent* aElement);
static PRIntn
RemoveElementsFromMapByContent(const nsString& aID,
nsIContent* aElement,
void* aClosure);
static nsresult
GetElementsByTagName(nsIDOMNode* aNode,
const nsString& aTagName,
nsRDFDOMNodeList* aElements);
static nsresult
GetElementsByAttribute(nsIDOMNode* aNode,
const nsString& aAttribute,
const nsString& aValue,
nsRDFDOMNodeList* aElements);
nsresult
ParseTagString(const nsString& aTagName, nsIAtom*& aName, PRInt32& aNameSpaceID);
NS_IMETHOD PrepareStyleSheets(nsIURI* anURL);
void SetDocumentURLAndGroup(nsIURI* anURL);
void SetIsPopup(PRBool isPopup) { mIsPopup = isPopup; };
nsresult CreateElement(PRInt32 aNameSpaceID,
nsIAtom* aTag,
nsIContent** aResult);
nsresult PrepareToLoad(nsIContentViewerContainer* aContainer,
const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsIParser** aResult);
nsresult
PrepareToLoadPrototype(nsIURI* aURI,
const char* aCommand,
nsIParser** aResult);
nsresult ApplyPersistentAttributes();
nsresult ApplyPersistentAttributesToElements(nsIRDFResource* aResource, nsISupportsArray* aElements);
protected:
// pseudo constants
static PRInt32 gRefCnt;
static nsIAtom* kAttributeAtom;
static nsIAtom* kCommandUpdaterAtom;
static nsIAtom* kDataSourcesAtom;
static nsIAtom* kElementAtom;
static nsIAtom* kIdAtom;
static nsIAtom* kKeysetAtom;
static nsIAtom* kObservesAtom;
static nsIAtom* kOpenAtom;
static nsIAtom* kOverlayAtom;
static nsIAtom* kPersistAtom;
static nsIAtom* kPositionAtom;
static nsIAtom* kRefAtom;
static nsIAtom* kRuleAtom;
static nsIAtom* kTemplateAtom;
static nsIAtom** kIdentityAttrs[];
static nsIRDFService* gRDFService;
static nsIRDFResource* kNC_persist;
static nsIRDFResource* kNC_attribute;
static nsIRDFResource* kNC_value;
static nsIHTMLElementFactory* gHTMLElementFactory;
static nsIXMLElementFactory* gXMLElementFactory;
static nsINameSpaceManager* gNameSpaceManager;
static PRInt32 kNameSpaceID_XUL;
static nsIXULContentUtils* gXULUtils;
static nsIXULPrototypeCache* gXULPrototypeCache;
static PRLogModuleInfo* gXULLog;
nsIContent*
FindContent(const nsIContent* aStartNode,
const nsIContent* aTest1,
const nsIContent* aTest2) const;
nsresult
Persist(nsIContent* aElement, PRInt32 aNameSpaceID, nsIAtom* aAttribute);
nsresult
DestroyForwardReferences();
// IMPORTANT: The ownership implicit in the following member variables has been
// explicitly checked and set using nsCOMPtr for owning pointers and raw COM interface
// pointers for weak (ie, non owning) references. If you add any members to this
// class, please make the ownership explicit (pinkerton, scc).
// NOTE, THIS IS STILL IN PROGRESS, TALK TO PINK OR SCC BEFORE CHANGING
nsCOMPtr<nsIArena> mArena;
nsVoidArray mObservers;
nsAutoString mDocumentTitle;
nsCOMPtr<nsIURI> mDocumentURL; // [OWNER] ??? compare with loader
nsWeakPtr mDocumentLoadGroup; // [WEAK] leads to loader
nsCOMPtr<nsIPrincipal> mDocumentPrincipal; // [OWNER]
nsCOMPtr<nsIContent> mRootContent; // [OWNER]
nsIDocument* mParentDocument; // [WEAK]
nsIScriptContextOwner* mScriptContextOwner; // [WEAK] it owns me! (indirectly)
void* mScriptObject; // ????
nsString mCharSetID;
nsVoidArray mStyleSheets;
nsCOMPtr<nsIDOMSelection> mSelection; // [OWNER]
PRBool mDisplaySelection;
nsVoidArray mPresShells;
nsCOMPtr<nsIEventListenerManager> mListenerManager; // [OWNER]
nsCOMPtr<nsINameSpaceManager> mNameSpaceManager; // [OWNER]
nsCOMPtr<nsIHTMLStyleSheet> mAttrStyleSheet; // [OWNER]
nsCOMPtr<nsIHTMLCSSStyleSheet> mInlineStyleSheet; // [OWNER]
nsCOMPtr<nsICSSLoader> mCSSLoader; // [OWNER]
nsElementMap mElementMap;
nsCOMPtr<nsISupportsArray> mBuilders; // [OWNER] of array, elements shouldn't own this, but they do
nsCOMPtr<nsIRDFDataSource> mLocalStore;
nsCOMPtr<nsILineBreaker> mLineBreaker; // [OWNER]
nsCOMPtr<nsIWordBreaker> mWordBreaker; // [OWNER]
nsIContentViewerContainer* mContentViewerContainer; // [WEAK] it owns me! (indirectly)
nsString mCommand;
nsVoidArray mSubDocuments; // [OWNER] of subelements
PRBool mIsPopup;
nsCOMPtr<nsIDOMHTMLFormElement> mHiddenForm; // [OWNER] of this content element
nsCOMPtr<nsIDOMXULCommandDispatcher> mCommandDispatcher; // [OWNER] of the focus tracker
nsVoidArray mForwardReferences;
PRBool mForwardReferencesResolved;
// The following are pointers into the content model which provide access to
// the objects triggering either a popup or a tooltip. These are marked as
// [OWNER] only because someone could, through DOM calls, delete the object from the
// content model while the popup/tooltip was visible. If we didn't have a reference
// to it, the object would go away and we'd be left pointing to garbage. This
// does not introduce cycles into the ownership model because this is still
// parent/child ownership. Just wanted the reader to know hyatt and I had thought about
// this (pinkerton).
nsCOMPtr<nsIDOMNode> mPopupNode; // [OWNER] element triggering the popup
nsCOMPtr<nsIDOMNode> mTooltipNode; // [OWNER] element triggering the tooltip
/**
* Context stack, which maintains the state of the Builder and allows
* it to be interrupted.
*/
class ContextStack {
protected:
struct Entry {
nsXULPrototypeElement* mPrototype;
nsIContent* mElement;
PRInt32 mIndex;
Entry* mNext;
};
Entry* mTop;
PRInt32 mDepth;
public:
ContextStack();
~ContextStack();
PRInt32 Depth() { return mDepth; }
nsresult Push(nsXULPrototypeElement* aPrototype, nsIContent* aElement);
nsresult Pop();
nsresult Peek(nsXULPrototypeElement** aPrototype, nsIContent** aElement, PRInt32* aIndex);
nsresult SetTopIndex(PRInt32 aIndex);
PRBool IsInsideXULTemplate();
};
friend class ContextStack;
ContextStack mContextStack;
enum State { eState_Master, eState_Overlay };
State mState;
/**
* An array of overlay nsIURIs that have yet to be resolved. The
* order of the array is significant: overlays at the _end_ of the
* array are resolved before overlays earlier in the array (i.e.,
* it is a stack).
*/
nsCOMPtr<nsISupportsArray> mUnloadedOverlays;
/**
* Load the transcluded script at the specified URI. If the
* prototype construction must 'block' until the load has
* completed, aBlock will be set to true.
*/
nsresult LoadScript(nsIURI* aURI, PRBool* aBlock);
/**
* Evaluate the script text in aScript. aURL and aLineNo
* specify meta-information about the script in order to
* provide useful error messages.
*/
nsresult EvaluateScript(nsIURI* aURL, const nsString& aScript, PRInt32 aLinenNo);
/**
* Create a delegate content model element from a prototype.
*/
nsresult CreateElement(nsXULPrototypeElement* aPrototype, nsIContent** aResult);
/**
* Create a temporary 'overlay' element to which content nodes
* can be attached for later resolution.
*/
nsresult CreateOverlayElement(nsXULPrototypeElement* aPrototype, nsIContent** aResult);
/**
* Add attributes from the prototype to the element.
*/
nsresult AddAttributes(nsXULPrototypeElement* aPrototype, nsIContent* aElement);
/**
* Callback invoked when a transcluded script completes loading.
*/
static nsresult
DoneLoadingScript(nsIUnicharStreamLoader* aLoader,
nsString& aData,
void* aRef,
nsresult aStatus);
/**
* The URL of the current transcluded script that is being loaded
*/
nsCOMPtr<nsIURI> mCurrentScriptURL;
/**
* Create a XUL template builder on the specified node if a 'datasources'
* attribute is present.
*/
static nsresult
CheckTemplateBuilder(nsIContent* aElement);
/**
* Check the specified node and perform broadcaster/observer hookup,
* if necessary.
*/
nsresult CheckBroadcasterHookup(nsIContent* aElement);
/**
* Used to resolve broadcaster references
*/
class BroadcasterHookup : public nsForwardReference
{
protected:
nsCOMPtr<nsIContent> mObservesElement;
PRBool mResolved;
public:
BroadcasterHookup(nsIContent* aObservesElement) :
mObservesElement(aObservesElement), mResolved(PR_FALSE) {}
virtual ~BroadcasterHookup();
virtual Priority GetPriority() { return ePriority_Hookup; }
virtual Result Resolve();
};
friend class BroadcasterHookup;
/**
* Used to hook up overlays
*/
class OverlayForwardReference : public nsForwardReference
{
protected:
nsCOMPtr<nsIContent> mOverlay;
PRBool mResolved;
nsresult Merge(nsIContent* aTargetNode, nsIContent* aOverlayNode);
public:
OverlayForwardReference(nsIContent* aOverlay)
: mOverlay(aOverlay), mResolved(PR_FALSE) {}
virtual ~OverlayForwardReference();
virtual Priority GetPriority() { return ePriority_Construction; }
virtual Result Resolve();
};
friend class OverlayForwardReference;
static
nsresult
InsertElement(nsIContent* aParent, nsIContent* aChild);
static
nsresult
ProcessCommonAttributes(nsIContent* aElement);
/**
* The current prototype that we are walking to construct the
* content model.
*/
nsCOMPtr<nsIXULPrototypeDocument> mCurrentPrototype;
/**
* Owning references to all of the prototype documents that were
* used to construct this document.
*/
nsCOMPtr<nsISupportsArray> mPrototypes;
/**
* Prepare to walk the current prototype.
*/
nsresult PrepareToWalk();
/**
* Add overlays from the chrome registry to the set of unprocessed
* overlays still to do.
*/
nsresult AddChromeOverlays();
/**
* Resume (or initiate) an interrupted (or newly prepared)
* prototype walk.
*/
nsresult ResumeWalk();
};
#endif // nsXULDocument_h__

View File

@ -1,126 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
/*
This file provides the implementation for the XUL Document Info.
*/
#include "nsIXULDocumentInfo.h"
#include "nsIDocument.h"
#include "nsIXULContentSink.h"
#include "nsRDFCID.h"
////////////////////////////////////////////////////////////////////////
static NS_DEFINE_IID(kXULDocumentInfoCID, NS_XULDOCUMENTINFO_CID);
static NS_DEFINE_IID(kIXULDocumentInfoIID, NS_IXULDOCUMENTINFO_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
////////////////////////////////////////////////////////////////////////
// DocumentInfoImpl
//
// This is the document info object passed to the doc loader
//
class XULDocumentInfoImpl : public nsIXULDocumentInfo
{
public:
XULDocumentInfoImpl(void);
virtual ~XULDocumentInfoImpl(void);
// nsISupports
NS_DECL_ISUPPORTS
// nsIDocumentInfo
NS_IMETHOD Init(nsIDocument* aDocument, nsIXULContentSink* aResource);
NS_IMETHOD GetDocument(nsIDocument** aDocument);
NS_IMETHOD GetContentSink(nsIXULContentSink** aContentSink);
private:
nsIDocument* mParentDocument;
nsIXULContentSink* mContentSink;
};
////////////////////////////////////////////////////////////////////////
XULDocumentInfoImpl::XULDocumentInfoImpl(void)
:mParentDocument(nsnull), mContentSink(nsnull)
{
NS_INIT_REFCNT();
}
XULDocumentInfoImpl::~XULDocumentInfoImpl(void)
{
#ifdef DEBUG_REFS
--gInstanceCount;
fprintf(stdout, "%d - RDF: XULDocumentInfoImpl\n", gInstanceCount);
#endif
NS_IF_RELEASE(mParentDocument);
NS_IF_RELEASE(mContentSink);
}
nsresult
XULDocumentInfoImpl::Init(nsIDocument* aDocument, nsIXULContentSink* aContentSink) {
NS_IF_RELEASE(mParentDocument);
NS_IF_RELEASE(mContentSink);
mParentDocument = aDocument;
mContentSink = aContentSink;
NS_IF_ADDREF(mParentDocument);
NS_IF_ADDREF(mContentSink);
return NS_OK;
}
nsresult
XULDocumentInfoImpl::GetDocument(nsIDocument** aDocument) {
*aDocument = mParentDocument;
NS_IF_ADDREF(mParentDocument);
return NS_OK;
}
nsresult
XULDocumentInfoImpl::GetContentSink(nsIXULContentSink** aContentSink) {
*aContentSink = mContentSink;
NS_IF_ADDREF(mContentSink);
return NS_OK;
}
NS_IMPL_ADDREF(XULDocumentInfoImpl);
NS_IMPL_RELEASE(XULDocumentInfoImpl);
NS_IMPL_QUERY_INTERFACE(XULDocumentInfoImpl, kIXULDocumentInfoIID);
////////////////////////////////////////////////////////////////////////
nsresult
NS_NewXULDocumentInfo(nsIXULDocumentInfo** aResult)
{
XULDocumentInfoImpl* info = new XULDocumentInfoImpl();
NS_ADDREF(info);
*aResult = info;
return NS_OK;
}

View File

@ -43,6 +43,7 @@
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMScriptObjectFactory.h"
#include "nsIDOMXULElement.h"
@ -67,15 +68,6 @@
#include "nsStyleConsts.h"
#include "nsIStyleSheet.h"
#include "nsIHTMLStyleSheet.h"
#include "nsIDOMMouseListener.h"
#include "nsIDOMMouseMotionListener.h"
#include "nsIDOMLoadListener.h"
#include "nsIDOMFocusListener.h"
#include "nsIDOMPaintListener.h"
#include "nsIDOMKeyListener.h"
#include "nsIDOMFormListener.h"
#include "nsIDOMMenuListener.h"
#include "nsIDOMDragListener.h"
#include "nsIScriptContextOwner.h"
#include "nsIStyledContent.h"
#include "nsIStyleContext.h"
@ -106,7 +98,7 @@ static const char kXULNameSpaceURI[] = XUL_NAMESPACE_URI;
static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI;
// End of XUL interface includes
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
@ -134,18 +126,9 @@ static NS_DEFINE_CID(kXULContentUtilsCID, NS_XULCONTENTUTILS_CID);
static NS_DEFINE_IID(kIXULPopupListenerIID, NS_IXULPOPUPLISTENER_IID);
static NS_DEFINE_CID(kXULPopupListenerCID, NS_XULPOPUPLISTENER_CID);
static NS_DEFINE_IID(kIDOMMouseListenerIID, NS_IDOMMOUSELISTENER_IID);
static NS_DEFINE_IID(kIDOMKeyListenerIID, NS_IDOMKEYLISTENER_IID);
static NS_DEFINE_IID(kIDOMMouseMotionListenerIID, NS_IDOMMOUSEMOTIONLISTENER_IID);
static NS_DEFINE_IID(kIDOMFocusListenerIID, NS_IDOMFOCUSLISTENER_IID);
static NS_DEFINE_IID(kIDOMFormListenerIID, NS_IDOMFORMLISTENER_IID);
static NS_DEFINE_IID(kIDOMLoadListenerIID, NS_IDOMLOADLISTENER_IID);
static NS_DEFINE_IID(kIDOMPaintListenerIID, NS_IDOMPAINTLISTENER_IID);
static NS_DEFINE_IID(kIDOMMenuListenerIID, NS_IDOMMENULISTENER_IID);
static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
struct XULBroadcastListener
{
@ -229,7 +212,7 @@ struct XULBroadcastListener
}
};
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
nsrefcnt nsXULElement::gRefCnt;
nsIRDFService* nsXULElement::gRDFService;
@ -255,101 +238,9 @@ nsIAtom* nsXULElement::kTreeColAtom;
nsIAtom* nsXULElement::kTreeItemAtom;
nsIAtom* nsXULElement::kTreeRowAtom;
nsIAtom* nsXULElement::kEditorAtom;
nsIAtom* nsXULElement::kWindowAtom;
// This is a simple datastructure that maps an event handler attribute
// name to an appropriate IID. Atoms are computed to improve
// comparison efficiency. We do this because SetAttribute() ends up
// being a pretty hot method.
struct EventHandlerMapEntry {
const char* mAttributeName;
nsIAtom* mAttributeAtom;
const nsIID* mHandlerIID;
};
static EventHandlerMapEntry kEventHandlerMap[] = {
{ "onclick", nsnull, &kIDOMMouseListenerIID },
{ "ondblclick", nsnull, &kIDOMMouseListenerIID },
{ "onmousedown", nsnull, &kIDOMMouseListenerIID },
{ "onmouseup", nsnull, &kIDOMMouseListenerIID },
{ "onmouseover", nsnull, &kIDOMMouseListenerIID },
{ "onmouseout", nsnull, &kIDOMMouseListenerIID },
{ "onmousemove", nsnull, &kIDOMMouseMotionListenerIID },
{ "onkeydown", nsnull, &kIDOMKeyListenerIID },
{ "onkeyup", nsnull, &kIDOMKeyListenerIID },
{ "onkeypress", nsnull, &kIDOMKeyListenerIID },
{ "onload", nsnull, &kIDOMLoadListenerIID },
{ "onunload", nsnull, &kIDOMLoadListenerIID },
{ "onabort", nsnull, &kIDOMLoadListenerIID },
{ "onerror", nsnull, &kIDOMLoadListenerIID },
{ "oncreate", nsnull, &kIDOMMenuListenerIID },
{ "ondestroy", nsnull, &kIDOMMenuListenerIID },
{ "oncommand", nsnull, &kIDOMMenuListenerIID },
{ "onbroadcast", nsnull, &kIDOMMenuListenerIID },
{ "oncommandupdate", nsnull, &kIDOMMenuListenerIID },
{ "onfocus", nsnull, &kIDOMFocusListenerIID },
{ "onblur", nsnull, &kIDOMFocusListenerIID },
{ "onsubmit", nsnull, &kIDOMFormListenerIID },
{ "onreset", nsnull, &kIDOMFormListenerIID },
{ "onchange", nsnull, &kIDOMFormListenerIID },
{ "onselect", nsnull, &kIDOMFormListenerIID },
{ "oninput", nsnull, &kIDOMFormListenerIID },
{ "onpaint", nsnull, &kIDOMPaintListenerIID },
{ "ondragenter", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ "ondragover", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ "ondragexit", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ "ondragdrop", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ "ondraggesture", nsnull, &NS_GET_IID(nsIDOMDragListener) },
{ nsnull, nsnull, nsnull }
};
////////////////////////////////////////////////////////////////////////
nsForwardReference::Result
nsXULElement::ObserverForwardReference::Resolve()
{
nsresult rv;
nsCOMPtr<nsIContent> content = do_QueryInterface(mListener);
if (! content)
return eResolveError;
nsCOMPtr<nsIDocument> doc;
rv = content->GetDocument(*getter_AddRefs(doc));
if (NS_FAILED(rv)) return eResolveError;
nsCOMPtr<nsIDOMXULDocument> xuldoc = do_QueryInterface(doc);
if (! xuldoc)
return eResolveError;
nsCOMPtr<nsIDOMElement> target;
rv = xuldoc->GetElementById(mTargetID, getter_AddRefs(target));
if (NS_FAILED(rv)) return eResolveError;
if (! target)
return eResolveLater;
nsCOMPtr<nsIDOMXULElement> broadcaster = do_QueryInterface(target);
if (! broadcaster)
return eResolveError;
rv = broadcaster->AddBroadcastListener(mAttributes, mListener);
if (NS_FAILED(rv)) return eResolveError;
return eResolveSucceeded;
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsXULElement
@ -394,12 +285,7 @@ nsXULElement::Init()
kTreeItemAtom = NS_NewAtom("treeitem");
kTreeRowAtom = NS_NewAtom("treerow");
kEditorAtom = NS_NewAtom("editor");
EventHandlerMapEntry* entry = kEventHandlerMap;
while (entry->mAttributeName) {
entry->mAttributeAtom = NS_NewAtom(entry->mAttributeName);
++entry;
}
kWindowAtom = NS_NewAtom("window");
rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID,
nsnull,
@ -469,6 +355,7 @@ nsXULElement::~nsXULElement()
NS_IF_RELEASE(kTreeItemAtom);
NS_IF_RELEASE(kTreeRowAtom);
NS_IF_RELEASE(kEditorAtom);
NS_IF_RELEASE(kWindowAtom);
NS_IF_RELEASE(gNameSpaceManager);
@ -476,20 +363,24 @@ nsXULElement::~nsXULElement()
nsServiceManager::ReleaseService(kXULContentUtilsCID, gXULUtils);
gXULUtils = nsnull;
}
EventHandlerMapEntry* entry = kEventHandlerMap;
while (entry->mAttributeName) {
NS_IF_RELEASE(entry->mAttributeAtom);
++entry;
}
}
}
nsresult
nsXULElement::Create(nsXULPrototypeElement* aPrototype, nsIContent** aResult)
nsXULElement::Create(nsXULPrototypeElement* aPrototype,
nsIDocument* aDocument,
nsIContent** aResult)
{
// Create an nsXULElement from a prototype
NS_PRECONDITION(aPrototype != nsnull, "null ptr");
if (! aPrototype)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aDocument != nsnull, "null ptr");
if (! aDocument)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aResult != nsnull, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
@ -507,6 +398,35 @@ nsXULElement::Create(nsXULPrototypeElement* aPrototype, nsIContent** aResult)
if (NS_FAILED(rv)) return rv;
element->mPrototype = aPrototype;
element->mDocument = aDocument;
// Check each attribute on the prototype to see if we need to do
// any additional processing and hookup that would otherwise be
// done 'automagically' by SetAttribute().
for (PRInt32 i = 0; i < aPrototype->mNumAttributes; ++i) {
nsXULPrototypeAttribute* attr = &(aPrototype->mAttributes[i]);
if (attr->mNameSpaceID == kNameSpaceID_None) {
// Check for an event handler
nsIID iid;
PRBool found;
rv = gXULUtils->GetEventHandlerIID(attr->mName, &iid, &found);
if (NS_FAILED(rv)) return rv;
if (found) {
rv = element->AddScriptEventListener(attr->mName, attr->mValue, iid);
if (NS_FAILED(rv)) return rv;
}
// Check for popup attributes
if ((attr->mName.get() == kPopupAtom) ||
(attr->mName.get() == kTooltipAtom) ||
(attr->mName.get() == kContextAtom)) {
rv = element->AddPopupListener(attr->mName);
if (NS_FAILED(rv)) return rv;
}
}
}
*aResult = NS_REINTERPRET_CAST(nsIStyledContent*, element);
NS_ADDREF(*aResult);
@ -544,7 +464,7 @@ nsXULElement::Create(PRInt32 aNameSpaceID, nsIAtom* aTag, nsIContent** aResult)
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsISupports interface
NS_IMPL_ADDREF(nsXULElement);
@ -633,7 +553,7 @@ nsXULElement::QueryInterface(REFNSIID iid, void** result)
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsIDOMNode interface
NS_IMETHODIMP
@ -1023,7 +943,7 @@ nsXULElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsIDOMElement interface
NS_IMETHODIMP
@ -1205,7 +1125,7 @@ nsXULElement::Normalize()
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsIXMLContent interface
NS_IMETHODIMP
@ -1297,7 +1217,7 @@ nsXULElement::SetNameSpaceID(PRInt32 aNameSpaceID)
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsIXULContent interface
NS_IMETHODIMP
@ -1342,6 +1262,56 @@ nsXULElement::GetLazyState(PRInt32 aFlag, PRBool& aResult)
}
NS_IMETHODIMP
nsXULElement::AddScriptEventListener(nsIAtom* aName, const nsString& aValue, REFNSIID aIID)
{
if (! mDocument)
return NS_OK; // XXX
nsresult rv;
nsCOMPtr<nsIScriptContext> context;
{
nsCOMPtr<nsIScriptContextOwner> owner =
dont_AddRef( mDocument->GetScriptContextOwner() );
// This can happen normally as part of teardown code.
if (! owner)
return NS_OK;
rv = owner->GetScriptContext(getter_AddRefs(context));
if (NS_FAILED(rv)) return rv;
}
if (Tag() == kWindowAtom) {
nsCOMPtr<nsIScriptGlobalObject> global = context->GetGlobalObject();
if (! global)
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIDOMEventReceiver> receiver = do_QueryInterface(global);
if (! receiver)
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIEventListenerManager> manager;
rv = receiver->GetListenerManager(getter_AddRefs(manager));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIScriptObjectOwner> owner = do_QueryInterface(global);
rv = manager->AddScriptEventListener(context, owner, aName, aValue, aIID);
}
else {
nsCOMPtr<nsIEventListenerManager> manager;
rv = GetListenerManager(getter_AddRefs(manager));
if (NS_FAILED(rv)) return rv;
rv = manager->AddScriptEventListener(context, this, aName, aValue, aIID);
}
return rv;
}
NS_IMETHODIMP
nsXULElement::ForceElementToOwnResource(PRBool aForce)
{
@ -1362,7 +1332,7 @@ nsXULElement::ForceElementToOwnResource(PRBool aForce)
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsIDOMEventReceiver interface
NS_IMETHODIMP
@ -1452,7 +1422,7 @@ nsXULElement::GetNewListenerManager(nsIEventListenerManager **aResult)
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsIScriptObjectOwner interface
NS_IMETHODIMP
@ -1516,7 +1486,7 @@ nsXULElement::SetScriptObject(void *aScriptObject)
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsIJSScriptObject interface
PRBool
@ -1576,7 +1546,7 @@ nsXULElement::Finalize(JSContext *aContext)
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsIContent interface
//
// Just to say this again (I said it in the header file), none of
@ -1687,61 +1657,7 @@ nsXULElement::GetParent(nsIContent*& aResult) const
NS_IMETHODIMP
nsXULElement::SetParent(nsIContent* aParent)
{
nsCOMPtr<nsIAtom> tagName;
GetTag(*getter_AddRefs(tagName));
mParent = aParent; // no refcount
// If we're an observes node, then we need to add our parent element
// as a broadcast listener.
if (mDocument && tagName && tagName.get() == kObservesAtom) {
// Find the node that we're supposed to be
// observing and perform the hookup.
nsAutoString elementValue;
nsAutoString attributeValue;
GetAttribute("element",
elementValue);
GetAttribute("attribute",
attributeValue);
nsCOMPtr<nsIDOMXULDocument> xulDocument( do_QueryInterface(mDocument) );
NS_ASSERTION(xulDocument != nsnull, "not in a XUL document");
if (! xulDocument)
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIDOMElement> listener( do_QueryInterface(aParent) );
if (! listener)
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIDOMElement> domElement;
xulDocument->GetElementById(elementValue, getter_AddRefs(domElement));
if (domElement) {
// We have a DOM element to bind to. Add a broadcast
// listener to that element, but only if it's a XUL element.
// XXX: Handle context nodes.
nsCOMPtr<nsIDOMXULElement> broadcaster( do_QueryInterface(domElement) );
if (broadcaster) {
broadcaster->AddBroadcastListener(attributeValue, listener);
}
}
else {
nsCOMPtr<nsIXULDocument> rdfdoc = do_QueryInterface(mDocument);
if (! rdfdoc)
return NS_ERROR_UNEXPECTED;
ObserverForwardReference* fwdref =
new ObserverForwardReference(listener, elementValue, attributeValue);
if (! fwdref)
return NS_ERROR_OUT_OF_MEMORY;
rdfdoc->AddForwardReference(fwdref);
}
}
return NS_OK;
}
@ -2103,62 +2019,32 @@ nsXULElement::SetAttribute(PRInt32 aNameSpaceID,
rv = EnsureSlots();
if (NS_FAILED(rv)) return rv;
rv = nsXULAttributes::Create(NS_STATIC_CAST(nsIStyledContent*, this), &(mSlots->mAttributes));
if (NS_FAILED(rv)) return rv;
// Since EnsureSlots() may have triggered mSlots->mAttributes construction,
// we need to check _again_ before creating attributes.
if (! Attributes()) {
rv = nsXULAttributes::Create(NS_STATIC_CAST(nsIStyledContent*, this), &(mSlots->mAttributes));
if (NS_FAILED(rv)) return rv;
}
}
// XXX Class and Style attribute setting should be checking for the XUL namespace!
// Check to see if the CLASS attribute is being set. If so, we need to rebuild our
// class list.
if (mDocument && (aNameSpaceID == kNameSpaceID_None) && aName == kClassAtom) {
if (mDocument && (aNameSpaceID == kNameSpaceID_None) && (aName == kClassAtom)) {
Attributes()->UpdateClassList(aValue);
}
// Check to see if the STYLE attribute is being set. If so, we need to create a new
// style rule based off the value of this attribute, and we need to let the document
// know about the StyleRule change.
if (mDocument && (aNameSpaceID == kNameSpaceID_None) && aName == kStyleAtom) {
if (mDocument && (aNameSpaceID == kNameSpaceID_None) && (aName == kStyleAtom)) {
nsCOMPtr <nsIURI> docURL;
if (nsnull != mDocument) {
mDocument->GetBaseURL(*getter_AddRefs(docURL));
}
mDocument->GetBaseURL(*getter_AddRefs(docURL));
Attributes()->UpdateStyleRule(docURL, aValue);
// XXX Some kind of special document update might need to happen here.
}
// Check to see if the OBSERVES attribute is being set. If so, we need to attach
// to the observed broadcaster.
if (mDocument && (aNameSpaceID == kNameSpaceID_None) &&
(aName == kObservesAtom))
{
// Do a getElementById to retrieve the broadcaster.
nsCOMPtr<nsIDOMElement> broadcaster;
nsCOMPtr<nsIDOMXULDocument> domDoc = do_QueryInterface(mDocument);
domDoc->GetElementById(aValue, getter_AddRefs(broadcaster));
if (broadcaster) {
nsCOMPtr<nsIDOMXULElement> xulBroadcaster = do_QueryInterface(broadcaster);
if (xulBroadcaster) {
xulBroadcaster->AddBroadcastListener("*", this);
}
}
else {
nsCOMPtr<nsIXULDocument> rdfdoc = do_QueryInterface(mDocument);
if (! rdfdoc)
return NS_ERROR_UNEXPECTED;
ObserverForwardReference* fwdref =
new ObserverForwardReference(this, aValue, nsAutoString("*"));
if (! fwdref)
return NS_ERROR_OUT_OF_MEMORY;
rdfdoc->AddForwardReference(fwdref);
}
}
// Need to check for the SELECTED attribute
// being set. If we're a <treeitem>, <treerow>, or <treecell>, the act of
// setting these attributes forces us to update our selected arrays.
@ -2197,37 +2083,7 @@ nsXULElement::SetAttribute(PRInt32 aNameSpaceID,
if (mDocument && (aNameSpaceID == kNameSpaceID_None) &&
(aName == kPopupAtom || aName == kTooltipAtom || aName == kContextAtom))
{
// Do a create instance of our popup listener.
nsIXULPopupListener* popupListener;
rv = nsComponentManager::CreateInstance(kXULPopupListenerCID,
nsnull,
kIXULPopupListenerIID,
(void**) &popupListener);
if (NS_FAILED(rv))
{
NS_ERROR("Unable to create an instance of the popup listener object.");
return rv;
}
XULPopupType popupType = eXULPopupType_popup;
if (aName == kTooltipAtom)
popupType = eXULPopupType_tooltip;
else if (aName == kContextAtom)
popupType = eXULPopupType_context;
// Add a weak reference to the node.
popupListener->Init(this, popupType);
// Add the popup as a listener on this element.
nsCOMPtr<nsIDOMEventListener> eventListener = do_QueryInterface(popupListener);
if (popupType == eXULPopupType_tooltip) {
AddEventListener("mouseout", eventListener, PR_FALSE);
AddEventListener("mousemove", eventListener, PR_FALSE);
}
else AddEventListener("mousedown", eventListener, PR_FALSE);
NS_IF_RELEASE(popupListener);
AddPopupListener(aName);
}
// XXX need to check if they're changing an event handler: if so, then we need
@ -2255,14 +2111,18 @@ nsXULElement::SetAttribute(PRInt32 aNameSpaceID,
Attributes()->AppendElement(attr);
}
// Check for event handlers and add a script listener if necessary.
EventHandlerMapEntry* entry = kEventHandlerMap;
while (entry->mAttributeAtom) {
if (entry->mAttributeAtom == aName) {
AddScriptEventListener(aName, aValue, *entry->mHandlerIID);
break;
// Check to see if this is an event handler, and add a script
// listener if necessary.
{
nsIID iid;
PRBool found;
rv = gXULUtils->GetEventHandlerIID(aName, &iid, &found);
if (NS_FAILED(rv)) return rv;
if (found) {
rv = AddScriptEventListener(aName, aValue, iid);
if (NS_FAILED(rv)) return rv;
}
++entry;
}
// Notify any broadcasters that are listening to this node.
@ -2292,64 +2152,6 @@ nsXULElement::SetAttribute(PRInt32 aNameSpaceID,
return rv;
}
nsresult
nsXULElement::AddScriptEventListener(nsIAtom* aName, const nsString& aValue, REFNSIID aIID)
{
if (! mDocument)
return NS_OK; // XXX
nsresult ret = NS_OK;
nsIScriptContext* context;
nsIScriptContextOwner* owner;
owner = mDocument->GetScriptContextOwner();
// This can happen normally as part of teardown code.
if (! owner)
return NS_OK;
nsAutoString tagStr;
Tag()->ToString(tagStr);
if (NS_OK == owner->GetScriptContext(&context)) {
if (tagStr == "window") {
nsIDOMEventReceiver *receiver;
nsIScriptGlobalObject *global = context->GetGlobalObject();
if (nsnull != global && NS_OK == global->QueryInterface(kIDOMEventReceiverIID, (void**)&receiver)) {
nsIEventListenerManager *manager;
if (NS_OK == receiver->GetListenerManager(&manager)) {
nsIScriptObjectOwner *mObjectOwner;
if (NS_OK == global->QueryInterface(kIScriptObjectOwnerIID, (void**)&mObjectOwner)) {
ret = manager->AddScriptEventListener(context, mObjectOwner, aName, aValue, aIID);
NS_RELEASE(mObjectOwner);
}
NS_RELEASE(manager);
}
NS_RELEASE(receiver);
}
NS_IF_RELEASE(global);
}
else {
nsIEventListenerManager *manager;
if (NS_OK == GetListenerManager(&manager)) {
nsIScriptObjectOwner* owner2;
if (NS_OK == QueryInterface(kIScriptObjectOwnerIID,
(void**) &owner2)) {
ret = manager->AddScriptEventListener(context, owner2,
aName, aValue, aIID);
NS_RELEASE(owner2);
}
NS_RELEASE(manager);
}
NS_RELEASE(context);
}
}
NS_RELEASE(owner);
return ret;
}
NS_IMETHODIMP
nsXULElement::GetAttribute(PRInt32 aNameSpaceID,
nsIAtom* aName,
@ -2383,7 +2185,7 @@ nsXULElement::GetAttribute(PRInt32 aNameSpaceID,
if (((attr->mNameSpaceID == aNameSpaceID) ||
(aNameSpaceID == kNameSpaceID_Unknown) ||
(aNameSpaceID == kNameSpaceID_None)) &&
(attr->mName == aName)) {
(attr->mName.get() == aName)) {
aResult = attr->mValue;
rv = aResult.Length() ? NS_CONTENT_ATTR_HAS_VALUE : NS_CONTENT_ATTR_NO_VALUE;
break;
@ -2543,8 +2345,8 @@ nsXULElement::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotif
NS_IMETHODIMP
nsXULElement::GetAttributeNameAt(PRInt32 aIndex,
PRInt32& aNameSpaceID,
nsIAtom*& aName) const
PRInt32& aNameSpaceID,
nsIAtom*& aName) const
{
if (Attributes()) {
nsXULAttribute* attr = NS_REINTERPRET_CAST(nsXULAttribute*, Attributes()->ElementAt(aIndex));
@ -2555,6 +2357,16 @@ nsXULElement::GetAttributeNameAt(PRInt32 aIndex,
return NS_OK;
}
}
else if (mPrototype) {
if (aIndex >= 0 && aIndex < mPrototype->mNumAttributes) {
nsXULPrototypeAttribute* attr = &(mPrototype->mAttributes[aIndex]);
aNameSpaceID = attr->mNameSpaceID;
aName = attr->mName;
NS_IF_ADDREF(aName);
return NS_OK;
}
}
aNameSpaceID = kNameSpaceID_None;
aName = nsnull;
return NS_ERROR_ILLEGAL_VALUE;
@ -2567,8 +2379,8 @@ nsXULElement::GetAttributeCount(PRInt32& aResult) const
if (Attributes()) {
aResult = Attributes()->Count();
}
else {
aResult = 0;
else if (mPrototype) {
aResult = mPrototype->mNumAttributes;
}
return rv;
@ -2588,16 +2400,30 @@ nsXULElement::List(FILE* out, PRInt32 aIndent) const
nsresult rv;
{
nsIAtom* tag;
if (NS_FAILED(rv = GetTag(tag)))
return rv;
rdf_Indent(out, aIndent);
fputs("[RDF ", out);
fputs("<XUL", out);
if (mSlots) fputs("*", out);
fputs(" ", out);
if (NameSpaceID() == kNameSpaceID_XUL) {
fputs("xul:", out);
}
else if (NameSpaceID() == kNameSpaceID_HTML) {
fputs("html:", out);
}
else if (NameSpaceID() == kNameSpaceID_None) {
fputs("none:", out);
}
else if (NameSpaceID() == kNameSpaceID_Unknown) {
fputs("unknown:", out);
}
else {
fputs("?:", out);
}
nsAutoString as;
tag->ToString(as);
Tag()->ToString(as);
fputs(as, out);
NS_RELEASE(tag);
}
{
@ -2609,7 +2435,6 @@ nsXULElement::List(FILE* out, PRInt32 aIndent) const
PRInt32 nameSpaceID;
GetAttributeNameAt(i, nameSpaceID, attr);
nsAutoString v;
GetAttribute(nameSpaceID, attr, v);
@ -2628,7 +2453,7 @@ nsXULElement::List(FILE* out, PRInt32 aIndent) const
return rv;
}
fputs("]\n", out);
fputs(">\n", out);
{
PRInt32 nchildren;
@ -2829,7 +2654,7 @@ nsXULElement::GetRangeList(nsVoidArray*& aResult) const
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// nsIDOMXULElement interface
NS_IMETHODIMP
@ -2996,7 +2821,7 @@ nsXULElement::SetDatabase(nsIRDFCompositeDataSource* aDatabase)
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
// Implementation methods
nsresult
@ -3295,8 +3120,7 @@ nsXULElement::GetClasses(nsVoidArray& aArray) const
rv = Attributes()->GetClasses(aArray);
}
else if (mPrototype) {
//XXXwaterson check prototype for class list
NS_NOTYETIMPLEMENTED("write this");
rv = nsClassList::GetClasses(mPrototype->mClassList, aArray);
}
return rv;
}
@ -3309,8 +3133,7 @@ nsXULElement::HasClass(nsIAtom* aClass) const
rv = Attributes()->HasClass(aClass);
}
else if (mPrototype) {
//XXXwaterson check prototype for class list
NS_NOTYETIMPLEMENTED("write this");
rv = nsClassList::HasClass(mPrototype->mClassList, aClass) ? NS_OK : NS_COMFALSE;
}
return rv;
}
@ -3342,18 +3165,18 @@ nsXULElement::GetInlineStyleRules(nsISupportsArray* aRules)
{
// Fetch the cached style rule from the attributes.
nsresult result = NS_ERROR_NULL_POINTER;
nsIStyleRule* rule = nsnull;
nsCOMPtr<nsIStyleRule> rule;
if (aRules) {
if (Attributes()) {
result = Attributes()->GetInlineStyleRule(rule);
result = Attributes()->GetInlineStyleRule(*getter_AddRefs(rule));
}
else if (mPrototype) {
else if (mPrototype && mPrototype->mInlineStyleRule) {
rule = mPrototype->mInlineStyleRule;
result = NS_OK;
}
}
if (rule) {
aRules->AppendElement(rule);
NS_RELEASE(rule);
}
return result;
}
@ -3601,7 +3424,51 @@ nsXULElement::ParseNumericValue(const nsString& aString,
return PR_FALSE;
}
////////////////////////////////////////////////////////////////////////
nsresult
nsXULElement::AddPopupListener(nsIAtom* aName)
{
// Add a popup listener to the element
nsresult rv;
nsCOMPtr<nsIXULPopupListener> popupListener;
rv = nsComponentManager::CreateInstance(kXULPopupListenerCID,
nsnull,
kIXULPopupListenerIID,
getter_AddRefs(popupListener));
NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to create an instance of the popup listener object.");
if (NS_FAILED(rv)) return rv;
XULPopupType popupType;
if (aName == kTooltipAtom) {
popupType = eXULPopupType_tooltip;
}
else if (aName == kContextAtom) {
popupType = eXULPopupType_context;
}
else {
popupType = eXULPopupType_popup;
}
// Add a weak reference to the node.
popupListener->Init(this, popupType);
// Add the popup as a listener on this element.
nsCOMPtr<nsIDOMEventListener> eventListener = do_QueryInterface(popupListener);
if (popupType == eXULPopupType_tooltip) {
AddEventListener("mouseout", eventListener, PR_FALSE);
AddEventListener("mousemove", eventListener, PR_FALSE);
}
else {
AddEventListener("mousedown", eventListener, PR_FALSE);
}
return NS_OK;
}
//----------------------------------------------------------------------
nsresult
nsXULElement::EnsureSlots()
@ -3638,27 +3505,20 @@ nsXULElement::EnsureSlots()
for (PRInt32 i = 0; i < mPrototype->mNumAttributes; ++i) {
nsXULPrototypeAttribute* proto = &(mPrototype->mAttributes[i]);
// Create a CBufDescriptor to avoid copying the attribute's
// value just to set it.
CBufDescriptor desc(proto->mValue, PR_FALSE, nsCRT::strlen(proto->mValue), 0);
nsXULAttribute* attr;
rv = nsXULAttribute::Create(NS_STATIC_CAST(nsIStyledContent*, this),
proto->mNameSpaceID,
proto->mName,
nsAutoString(desc),
&attr);
// It's safe for us to call SetAttribute() now, because we
// won't re-enter. Plus, this saves us the hassle of copying
// all the crappy logic in SetAttribute() yet another time.
rv = SetAttribute(proto->mNameSpaceID, proto->mName, proto->mValue, PR_FALSE);
if (NS_FAILED(rv)) return rv;
// transfer ownership of the nsXULAttribute object
mSlots->mAttributes->AppendElement(attr);
}
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------
//
// nsXULElement::Slots
//
nsXULElement::Slots::Slots(nsXULElement* aElement)
: mElement(aElement),
@ -3693,3 +3553,24 @@ nsXULElement::Slots::~Slots()
// Delete the aggregated interface, if one exists.
delete mInnerXULElement;
}
//----------------------------------------------------------------------
//
// nsXULPrototypeElement
//
nsresult
nsXULPrototypeElement::GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aValue)
{
for (PRInt32 i = 0; i < mNumAttributes; ++i) {
if ((mAttributes[i].mName.get() == aName) &&
(mAttributes[i].mNameSpaceID == aNameSpaceID)) {
aValue = mAttributes[i].mValue;
return aValue.Length() ? NS_CONTENT_ATTR_HAS_VALUE : NS_CONTENT_ATTR_NO_VALUE;
}
}
return NS_CONTENT_ATTR_NOT_THERE;
}

View File

@ -42,24 +42,26 @@
#include "nsIFocusableContent.h"
#include "nsIJSScriptObject.h"
#include "nsINameSpace.h"
#include "nsINameSpaceManager.h"
#include "nsIRDFCompositeDataSource.h"
#include "nsIRDFResource.h"
#include "nsIScriptObjectOwner.h"
#include "nsIStyleRule.h"
#include "nsIStyledContent.h"
#include "nsIURI.h"
#include "nsIXMLContent.h"
#include "nsIXULContent.h"
#include "nsXULAttributes.h"
class nsClassList;
class nsIDocument;
class nsIRDFService;
class nsISupportsArray;
class nsIXULContentUtils;
class nsIXULPrototypeDocument;
class nsRDFDOMNodeList;
class nsString;
class nsVoidArray;
class nsXULAttributes;
class nsXULPrototypeDocument;
////////////////////////////////////////////////////////////////////////
@ -69,11 +71,14 @@ class nsXULPrototypeDocument;
*/
struct nsXULPrototypeAttribute
class nsXULPrototypeAttribute
{
PRInt32 mNameSpaceID;
nsIAtom* mName;
PRUnichar* mValue;
public:
nsXULPrototypeAttribute() : mNameSpaceID(kNameSpaceID_Unknown) {}
PRInt32 mNameSpaceID;
nsCOMPtr<nsIAtom> mName;
nsString mValue;
};
@ -86,22 +91,109 @@ struct nsXULPrototypeAttribute
*/
struct nsXULPrototypeElement
{
nsXULPrototypeDocument* mDocument; // [OWNER] because doc is refcounted
PRInt32 mNumChildren;
nsXULPrototypeElement* mChildren; // [OWNER]
class nsXULPrototypeElement;
nsINameSpace* mNameSpace; // [OWNER]
nsIAtom* mNameSpacePrefix; // [OWNER]
class nsXULPrototypeNode
{
public:
enum Type { eType_Element, eType_Script, eType_Text };
Type mType;
PRInt32 mLineNo;
virtual ~nsXULPrototypeNode()
{
MOZ_COUNT_CTOR(nsXULPrototypeNode);
}
protected:
nsXULPrototypeNode(Type aType, PRInt32 aLineNo)
: mType(aType), mLineNo(aLineNo)
{
MOZ_COUNT_DTOR(nsXULPrototypeNode);
}
};
class nsXULPrototypeElement : public nsXULPrototypeNode
{
public:
nsXULPrototypeElement(PRInt32 aLineNo)
: nsXULPrototypeNode(eType_Element, aLineNo),
mDocument(nsnull),
mNumChildren(0),
mChildren(nsnull),
mNumAttributes(0),
mAttributes(nsnull),
mClassList(nsnull)
{
MOZ_COUNT_CTOR(nsXULPrototypeElement);
}
virtual ~nsXULPrototypeElement()
{
MOZ_COUNT_DTOR(nsXULPrototypeElement);
delete[] mAttributes;
delete mClassList;
for (PRInt32 i = mNumChildren - 1; i >= 0; --i)
delete mChildren[i];
delete[] mChildren;
}
nsIXULPrototypeDocument* mDocument; // [WEAK] because doc is refcounted
PRInt32 mNumChildren;
nsXULPrototypeNode** mChildren; // [OWNER]
nsCOMPtr<nsINameSpace> mNameSpace; // [OWNER]
nsCOMPtr<nsIAtom> mNameSpacePrefix; // [OWNER]
PRInt32 mNameSpaceID;
nsIAtom* mTag; // [OWNER]
nsCOMPtr<nsIAtom> mTag; // [OWNER]
PRInt32 mNumAttributes;
nsXULPrototypeAttribute* mAttributes; // [OWNER]
nsIStyleRule* mInlineStyleRule; // [OWNER]
nsCOMPtr<nsIStyleRule> mInlineStyleRule; // [OWNER]
nsClassList* mClassList;
nsresult GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aValue);
};
class nsXULPrototypeScript : public nsXULPrototypeNode
{
public:
nsXULPrototypeScript(PRInt32 aLineNo)
: nsXULPrototypeNode(eType_Script, aLineNo)
{
MOZ_COUNT_CTOR(nsXULPrototypeScript);
}
virtual ~nsXULPrototypeScript()
{
MOZ_COUNT_DTOR(nsXULPrototypeScript);
}
nsCOMPtr<nsIURI> mSrcURI;
nsString mInlineScript;
};
class nsXULPrototypeText : public nsXULPrototypeNode
{
public:
nsXULPrototypeText(PRInt32 aLineNo)
: nsXULPrototypeNode(eType_Text, aLineNo)
{
MOZ_COUNT_CTOR(nsXULPrototypeText);
}
virtual ~nsXULPrototypeText()
{
MOZ_COUNT_DTOR(nsXULPrototypeText);
}
nsString mValue;
};
@ -185,10 +277,11 @@ protected:
static nsIAtom* kTreeItemAtom;
static nsIAtom* kTreeRowAtom;
static nsIAtom* kEditorAtom;
static nsIAtom* kWindowAtom;
public:
static nsresult
Create(nsXULPrototypeElement* aPrototype, nsIContent** aResult);
Create(nsXULPrototypeElement* aPrototype, nsIDocument* aDocument, nsIContent** aResult);
static nsresult
Create(PRInt32 aNameSpaceID, nsIAtom* aTag, nsIContent** aResult);
@ -260,6 +353,7 @@ public:
NS_IMETHOD SetLazyState(PRInt32 aFlags);
NS_IMETHOD ClearLazyState(PRInt32 aFlags);
NS_IMETHOD GetLazyState(PRInt32 aFlag, PRBool& aValue);
NS_IMETHOD AddScriptEventListener(nsIAtom* aName, const nsString& aValue, REFNSIID aIID);
NS_IMETHOD ForceElementToOwnResource(PRBool aForce);
// nsIFocusableContent interface
@ -317,8 +411,6 @@ protected:
// Implementation methods
nsresult EnsureContentsGenerated(void) const;
nsresult AddScriptEventListener(nsIAtom* aName, const nsString& aValue, REFNSIID aIID);
nsresult ExecuteOnBroadcastHandler(nsIDOMElement* anElement, const nsString& attrName);
PRBool ElementIsInDocument();
@ -332,6 +424,7 @@ protected:
float& aFloatValue,
nsHTMLUnit& aValueUnit);
// Static helpers
static nsresult
GetElementsByTagName(nsIDOMNode* aNode,
const nsString& aTagName,
@ -350,6 +443,8 @@ protected:
PRBool IsFocusableContent();
nsresult AddPopupListener(nsIAtom* aName);
protected:
// Required fields
nsXULPrototypeElement* mPrototype;
@ -396,9 +491,9 @@ protected:
// appropriate default values if there are no slots defined in the
// delegate.
PRInt32 NameSpaceID() const { return mSlots ? mSlots->mNameSpaceID : mPrototype->mNameSpaceID; }
nsINameSpace* NameSpace() const { return mSlots ? mSlots->mNameSpace.get() : mPrototype->mNameSpace; }
nsIAtom* NameSpacePrefix() const { return mSlots ? mSlots->mNameSpacePrefix.get() : mPrototype->mNameSpacePrefix; }
nsIAtom* Tag() const { return mSlots ? mSlots->mTag.get() : mPrototype->mTag; }
nsINameSpace* NameSpace() const { return mSlots ? mSlots->mNameSpace.get() : mPrototype->mNameSpace.get(); }
nsIAtom* NameSpacePrefix() const { return mSlots ? mSlots->mNameSpacePrefix.get() : mPrototype->mNameSpacePrefix.get(); }
nsIAtom* Tag() const { return mSlots ? mSlots->mTag.get() : mPrototype->mTag.get(); }
void* ScriptObject() const { return mSlots ? mSlots->mScriptObject : nsnull; }
nsIEventListenerManager* ListenerManager() const { return mSlots ? mSlots->mListenerManager.get() : nsnull; }
nsVoidArray* BroadcastListeners() const { return mSlots ? mSlots->mBroadcastListeners : nsnull; }
@ -409,30 +504,6 @@ protected:
nsXULAttributes* Attributes() const { return mSlots ? mSlots->mAttributes : nsnull; }
nsXULAggregateElement* InnerXULElement() const { return mSlots ? mSlots->mInnerXULElement : nsnull; }
protected:
// XXX Move to nsXULContentSink?
class ObserverForwardReference : public nsForwardReference
{
protected:
nsCOMPtr<nsIDOMElement> mListener;
nsString mTargetID;
nsString mAttributes;
public:
ObserverForwardReference(nsIDOMElement* aListener,
const nsString& aTargetID,
const nsString& aAttributes) :
mListener(aListener),
mTargetID(aTargetID),
mAttributes(aAttributes) {}
virtual ~ObserverForwardReference() {}
virtual Result Resolve();
};
friend class ObserverForwardReference;
};

View File

@ -0,0 +1,157 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 "nsCOMPtr.h"
#include "nsXPIDLString.h"
#include "nsIXULPrototypeCache.h"
#include "nsIXULPrototypeDocument.h"
#include "nsIURI.h"
#include "plhash.h"
class nsXULPrototypeCache : public nsIXULPrototypeCache
{
public:
// nsISupports
NS_DECL_ISUPPORTS
NS_IMETHOD Get(nsIURI* aURI, nsIXULPrototypeDocument** _result);
NS_IMETHOD Put(nsIURI* aURI, nsIXULPrototypeDocument* aDocument);
protected:
friend NS_IMETHODIMP
NS_NewXULPrototypeCache(nsISupports* aOuter, REFNSIID aIID, void** aResult);
nsXULPrototypeCache();
virtual ~nsXULPrototypeCache();
static PRIntn ReleaseTableEntry(PLHashEntry* aHashEntry, PRIntn aIndex, void* aClosure);
nsresult Init();
static PLHashNumber Hash(const void* aKey);
static PRIntn CompareKeys(const void* aKey1, const void* aKey2);
PLHashTable* mTable;
};
nsXULPrototypeCache::nsXULPrototypeCache()
{
NS_INIT_REFCNT();
}
nsXULPrototypeCache::~nsXULPrototypeCache()
{
if (mTable) {
PL_HashTableEnumerateEntries(mTable, ReleaseTableEntry, nsnull);
PL_HashTableDestroy(mTable);
}
}
PRIntn
nsXULPrototypeCache::ReleaseTableEntry(PLHashEntry* aHashEntry, PRIntn aIndex, void* aClosure)
{
nsIURI* key = NS_REINTERPRET_CAST(nsIURI*, NS_CONST_CAST(void*, aHashEntry->key));
NS_RELEASE(key);
nsIXULPrototypeDocument* value = NS_REINTERPRET_CAST(nsIXULPrototypeDocument*, aHashEntry->value);
NS_RELEASE(value);
return HT_ENUMERATE_REMOVE;
}
nsresult
nsXULPrototypeCache::Init()
{
mTable = PL_NewHashTable(16, Hash, CompareKeys, PL_CompareValues, nsnull, nsnull);
if (! mTable)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMPL_ISUPPORTS1(nsXULPrototypeCache, nsIXULPrototypeCache);
NS_IMETHODIMP
NS_NewXULPrototypeCache(nsISupports* aOuter, REFNSIID aIID, void** aResult)
{
NS_PRECONDITION(! aOuter, "no aggregation");
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsXULPrototypeCache* result = new nsXULPrototypeCache();
if (! result)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv;
rv = result->Init();
if (NS_FAILED(rv)) {
delete result;
return rv;
}
NS_ADDREF(result);
rv = result->QueryInterface(aIID, aResult);
NS_RELEASE(result);
return rv;
}
PLHashNumber
nsXULPrototypeCache::Hash(const void* aKey)
{
nsIURI* uri = NS_REINTERPRET_CAST(nsIURI*, NS_CONST_CAST(void*, aKey));
nsXPIDLCString spec;
uri->GetSpec(getter_Copies(spec));
return PL_HashString(spec);
}
PRIntn
nsXULPrototypeCache::CompareKeys(const void* aKey1, const void* aKey2)
{
nsIURI* uri1 = NS_REINTERPRET_CAST(nsIURI*, NS_CONST_CAST(void*, aKey1));
nsIURI* uri2 = NS_REINTERPRET_CAST(nsIURI*, NS_CONST_CAST(void*, aKey2));
PRBool eq;
uri1->Equals(uri2, &eq);
return eq;
}
NS_IMETHODIMP
nsXULPrototypeCache::Get(nsIURI* aURI, nsIXULPrototypeDocument** _result)
{
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeCache::Put(nsIURI* aURI, nsIXULPrototypeDocument* aDocument)
{
return NS_OK;
}

View File

@ -0,0 +1,252 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 "nsCOMPtr.h"
#include "nsISupportsArray.h"
#include "nsIStyleSheet.h"
#include "nsIXULPrototypeDocument.h"
#include "nsIURI.h"
#include "nsString2.h"
#include "nsVoidArray.h"
#include "nsXULElement.h"
class nsXULPrototypeDocument : public nsIXULPrototypeDocument
{
public:
static nsresult
Create(nsIURI* aURI, nsXULPrototypeDocument** aResult);
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIXULPrototypeDocument interface
NS_IMETHOD GetURI(nsIURI** aResult);
NS_IMETHOD SetURI(nsIURI* aURI);
NS_IMETHOD GetRootElement(nsXULPrototypeElement** aResult);
NS_IMETHOD SetRootElement(nsXULPrototypeElement* aElement);
NS_IMETHOD AddStyleSheet(nsIStyleSheet* aStyleSheet);
NS_IMETHOD GetStyleSheets(nsVoidArray& aResult);
NS_IMETHOD AddOverlayReference(nsIURI* aURI);
NS_IMETHOD GetOverlayReferences(nsVoidArray& aResult);
NS_IMETHOD GetHeaderData(nsIAtom* aField, nsString& aData) const;
NS_IMETHOD SetHeaderData(nsIAtom* aField, const nsString& aData);
protected:
nsCOMPtr<nsIURI> mURI;
nsXULPrototypeElement* mRoot;
nsCOMPtr<nsISupportsArray> mStyleSheets;
nsCOMPtr<nsISupportsArray> mOverlayReferences;
nsXULPrototypeDocument();
virtual ~nsXULPrototypeDocument();
nsresult Init();
friend NS_IMETHODIMP
NS_NewXULPrototypeDocument(nsISupports* aOuter, REFNSIID aIID, void** aResult);
};
//----------------------------------------------------------------------
nsXULPrototypeDocument::nsXULPrototypeDocument()
: mRoot(nsnull)
{
NS_INIT_REFCNT();
}
nsresult
nsXULPrototypeDocument::Init()
{
nsresult rv;
rv = NS_NewISupportsArray(getter_AddRefs(mStyleSheets));
if (NS_FAILED(rv)) return rv;
rv = NS_NewISupportsArray(getter_AddRefs(mOverlayReferences));
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
nsXULPrototypeDocument::~nsXULPrototypeDocument()
{
delete mRoot;
}
NS_IMPL_ISUPPORTS1(nsXULPrototypeDocument, nsIXULPrototypeDocument);
NS_IMETHODIMP
NS_NewXULPrototypeDocument(nsISupports* aOuter, REFNSIID aIID, void** aResult)
{
NS_PRECONDITION(aOuter == nsnull, "no aggregation");
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsXULPrototypeDocument* result = new nsXULPrototypeDocument();
if (! result)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv;
rv = result->Init();
if (NS_FAILED(rv)) {
delete result;
return rv;
}
NS_ADDREF(result);
rv = result->QueryInterface(aIID, aResult);
NS_RELEASE(result);
return rv;
}
//----------------------------------------------------------------------
NS_IMETHODIMP
nsXULPrototypeDocument::GetURI(nsIURI** aResult)
{
*aResult = mURI;
NS_IF_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeDocument::SetURI(nsIURI* aURI)
{
mURI = aURI;
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeDocument::GetRootElement(nsXULPrototypeElement** aResult)
{
*aResult = mRoot;
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeDocument::SetRootElement(nsXULPrototypeElement* aElement)
{
mRoot = aElement;
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeDocument::AddStyleSheet(nsIStyleSheet* aStyleSheet)
{
NS_PRECONDITION(aStyleSheet != nsnull, "null ptr");
if (! aStyleSheet)
return NS_ERROR_NULL_POINTER;
mStyleSheets->AppendElement(aStyleSheet);
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeDocument::GetStyleSheets(nsVoidArray& aResult)
{
nsresult rv;
aResult.Clear();
PRUint32 cnt;
rv = mStyleSheets->Count(&cnt);
if (NS_FAILED(rv)) return rv;
for (PRInt32 i = 0; i < PRInt32(cnt); ++i) {
nsIStyleSheet* sheet = NS_REINTERPRET_CAST(nsIStyleSheet*, mStyleSheets->ElementAt(i));
aResult.AppendElement(sheet);
NS_RELEASE(sheet);
}
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeDocument::AddOverlayReference(nsIURI* aURI)
{
NS_PRECONDITION(aURI != nsnull, "null ptr");
if (! aURI)
return NS_ERROR_NULL_POINTER;
mOverlayReferences->AppendElement(aURI);
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeDocument::GetOverlayReferences(nsVoidArray& aResult)
{
nsresult rv;
aResult.Clear();
PRUint32 cnt;
rv = mOverlayReferences->Count(&cnt);
if (NS_FAILED(rv)) return rv;
for (PRInt32 i = 0; i < PRInt32(cnt); ++i) {
nsIURI* ref = NS_REINTERPRET_CAST(nsIURI*, mOverlayReferences->ElementAt(i));
aResult.AppendElement(ref);
NS_RELEASE(ref);
}
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeDocument::GetHeaderData(nsIAtom* aField, nsString& aData) const
{
// XXX Not implemented
aData.Truncate();
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeDocument::SetHeaderData(nsIAtom* aField, const nsString& aData)
{
// XXX Not implemented
return NS_OK;
}

View File

@ -1658,17 +1658,19 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
nsXPIDLCString resourceCStr;
rv = aChild->GetValue(getter_Copies(resourceCStr));
if (NS_FAILED(rv)) return rv;
const PRUnichar *unicodeString;
tag->GetUnicode(&unicodeString);
nsAutoString tagStr(unicodeString);
char* tagCStr = tagStr.ToNewCString();
nsAutoString tagstr;
tag->ToString(tagstr);
nsAutoString templatestr;
aTemplateNode->GetAttribute(kNameSpaceID_None, kIdAtom, templatestr);
PR_LOG(gLog, PR_LOG_DEBUG,
("rdfgeneric[%p] build-content-from-template %s [%s]",
this, tagCStr, (const char*) resourceCStr));
nsCRT::free(tagCStr);
("rdfgeneric[%p] build-content-from-template %s (template='%s') [%s]",
this,
(const char*) nsCAutoString(tagstr),
(const char*) nsCAutoString(templatestr),
(const char*) resourceCStr));
}
#endif

Binary file not shown.