mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 02:25:34 +00:00
Content model whackage. Remove all code that tried to keep the graph in sync with DOM changes. Regenerate JS from newer idlc compiler. Fix bug 12177. Fix miscellaneous breakage with templates.
This commit is contained in:
parent
cfb7be6cd2
commit
6e2ab0076d
40
content/xul/content/src/nsIRDFNodeList.h
Normal file
40
content/xul/content/src/nsIRDFNodeList.h
Normal file
@ -0,0 +1,40 @@
|
||||
/* -*- 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 nsIRDFNodeList_h__
|
||||
#define nsIRDFNodeList_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
// {661D1971-5CD2-11d3-BE36-00104BDE6048}
|
||||
#define NS_IRDFNODELIST_IID \
|
||||
{ 0x661d1971, 0x5cd2, 0x11d3, { 0xbe, 0x36, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
|
||||
|
||||
class nsIRDFNodeList : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFNODELIST_IID; return iid; }
|
||||
|
||||
NS_IMETHOD AppendNode(nsIDOMNode* aNode) = 0;
|
||||
NS_IMETHOD RemoveNode(nsIDOMNode* aNode) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // nsIRDFNodeList_h__
|
||||
|
44
content/xul/content/src/nsIXULTreeContent.h
Normal file
44
content/xul/content/src/nsIXULTreeContent.h
Normal file
@ -0,0 +1,44 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
A private interface to the tree element
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIXULTreeContent_h__
|
||||
#define nsIXULTreeContent_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
// {661D1970-5CD2-11d3-BE36-00104BDE6048}
|
||||
#define NS_IXULTREECONTENT_IID \
|
||||
{ 0x661d1970, 0x5cd2, 0x11d3, { 0xbe, 0x36, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
|
||||
|
||||
|
||||
class nsIXULTreeContent : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IXULTREECONTENT_IID; return iid; }
|
||||
|
||||
NS_IMETHOD FireOnSelectHandler() = 0;
|
||||
};
|
||||
|
||||
#endif // nsIXULTreeContent_h__
|
@ -101,18 +101,23 @@ static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(nsIDOMNodeList::GetIID()) ||
|
||||
if (aIID.Equals(nsCOMTypeInfo<nsIDOMNodeList>::GetIID()) ||
|
||||
aIID.Equals(kISupportsIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIDOMNodeList*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(nsCOMTypeInfo<nsIRDFNodeList>::GetIID())) {
|
||||
*aResult = NS_STATIC_CAST(nsIRDFNodeList*, this);
|
||||
}
|
||||
else if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIScriptObjectOwner*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
else {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@ -206,7 +211,7 @@ nsRDFDOMNodeList::Init(void)
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
NS_IMETHODIMP
|
||||
nsRDFDOMNodeList::AppendNode(nsIDOMNode* aNode)
|
||||
{
|
||||
NS_PRECONDITION(aNode != nsnull, "null ptr");
|
||||
@ -216,7 +221,7 @@ nsRDFDOMNodeList::AppendNode(nsIDOMNode* aNode)
|
||||
return mElements->AppendElement(aNode);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_IMETHODIMP
|
||||
nsRDFDOMNodeList::RemoveNode(nsIDOMNode* aNode)
|
||||
{
|
||||
NS_PRECONDITION(aNode != nsnull, "null ptr");
|
||||
|
@ -21,11 +21,13 @@
|
||||
#define nsRDFDOMNodeList_h__
|
||||
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIRDFNodeList.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
class nsIDOMNode;
|
||||
class nsISupportsArray;
|
||||
|
||||
class nsRDFDOMNodeList : public nsIDOMNodeList,
|
||||
public nsIRDFNodeList,
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
private:
|
||||
@ -51,8 +53,8 @@ public:
|
||||
NS_IMETHOD SetScriptObject(void* aScriptObject);
|
||||
|
||||
// Implementation methods
|
||||
nsresult AppendNode(nsIDOMNode* aNode);
|
||||
nsresult RemoveNode(nsIDOMNode* aNode);
|
||||
NS_IMETHOD AppendNode(nsIDOMNode* aNode);
|
||||
NS_IMETHOD RemoveNode(nsIDOMNode* aNode);
|
||||
};
|
||||
|
||||
#endif // nsRDFDOMNodeList_h__
|
||||
|
@ -41,10 +41,8 @@
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMElementObserver.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMNodeObserver.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsIDOMXULElement.h"
|
||||
#include "nsIDocument.h"
|
||||
@ -80,6 +78,7 @@
|
||||
#include "nsIFocusableContent.h"
|
||||
#include "nsIStyleRule.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIXULContent.h"
|
||||
#include "nsXULTreeElement.h"
|
||||
#include "rdfutil.h"
|
||||
#include "prlog.h"
|
||||
@ -227,6 +226,7 @@ class RDFElementImpl : public nsIDOMXULElement,
|
||||
public nsIJSScriptObject,
|
||||
public nsIStyledContent,
|
||||
public nsIXMLContent,
|
||||
public nsIXULContent,
|
||||
public nsIFocusableContent
|
||||
{
|
||||
public:
|
||||
@ -311,6 +311,9 @@ public:
|
||||
NS_IMETHOD GetNameSpacePrefix(nsIAtom*& aNameSpace) const;
|
||||
NS_IMETHOD SetNameSpaceID(PRInt32 aNameSpaceID);
|
||||
|
||||
// nsIXULContent
|
||||
NS_IMETHOD PeekChildCount(PRInt32& aCount) const;
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
|
||||
NS_IMETHOD RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
|
||||
@ -677,6 +680,9 @@ RDFElementImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
else if (iid.Equals(nsIXMLContent::GetIID())) {
|
||||
*result = NS_STATIC_CAST(nsIXMLContent*, this);
|
||||
}
|
||||
else if (iid.Equals(nsCOMTypeInfo<nsIXULContent>::GetIID())) {
|
||||
*result = NS_STATIC_CAST(nsIXULContent*, this);
|
||||
}
|
||||
else if (iid.Equals(nsIDOMXULElement::GetIID()) ||
|
||||
iid.Equals(kIDOMElementIID) ||
|
||||
iid.Equals(kIDOMNodeIID)) {
|
||||
@ -699,7 +705,8 @@ RDFElementImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
IsFocusableContent()) {
|
||||
*result = NS_STATIC_CAST(nsIFocusableContent*, this);
|
||||
}
|
||||
else if (iid.Equals(nsIDOMXULTreeElement::GetIID()) &&
|
||||
else if ((iid.Equals(nsIDOMXULTreeElement::GetIID()) ||
|
||||
iid.Equals(nsIXULTreeContent::GetIID())) &&
|
||||
(mNameSpaceID == kNameSpaceID_XUL) &&
|
||||
(mTag == kTreeAtom)) {
|
||||
// We delegate XULTreeElement APIs to an aggregate object
|
||||
@ -944,21 +951,68 @@ RDFElementImpl::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
NS_PRECONDITION(aNewChild != nsnull, "null ptr");
|
||||
if (! aNewChild)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// It's possible that mDocument will be null for an element that's
|
||||
// not in the content model (e.g., somebody is working on a
|
||||
// "scratch" element that has been removed from the content tree).
|
||||
if (mDocument) {
|
||||
nsIDOMNodeObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMNodeObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnInsertBefore(this, aNewChild, aRefChild);
|
||||
NS_RELEASE(obs);
|
||||
// aRefChild may be null; that means "append".
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIContent> newcontent = do_QueryInterface(aNewChild);
|
||||
NS_ASSERTION(newcontent != nsnull, "not an nsIContent");
|
||||
if (! newcontent)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
// First, check to see if the content was already parented
|
||||
// somewhere. If so, remove it.
|
||||
nsCOMPtr<nsIContent> oldparent;
|
||||
rv = newcontent->GetParent(*getter_AddRefs(oldparent));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (oldparent) {
|
||||
PRInt32 oldindex;
|
||||
rv = oldparent->IndexOf(newcontent, oldindex);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to determine index of aNewChild in old parent");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_ASSERTION(oldindex >= 0, "old parent didn't think aNewChild was a child");
|
||||
|
||||
if (oldindex >= 0) {
|
||||
rv = oldparent->RemoveChildAt(oldindex, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// Now, insert the element into the content model under 'this'
|
||||
if (aRefChild) {
|
||||
nsCOMPtr<nsIContent> refcontent = do_QueryInterface(aRefChild);
|
||||
NS_ASSERTION(refcontent != nsnull, "not an nsIContent");
|
||||
if (! refcontent)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
PRInt32 pos;
|
||||
rv = IndexOf(refcontent, pos);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to determine index of aRefChild");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (pos >= 0) {
|
||||
rv = InsertChildAt(newcontent, pos, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to insert aNewChild");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// XXX Hmm. There's a case here that we handle ambiguously, I
|
||||
// think. If aRefChild _isn't_ actually one of our kids, then
|
||||
// pos == -1, and we'll never insert the new kid. Should we
|
||||
// just append it?
|
||||
}
|
||||
else {
|
||||
rv = AppendChildTo(newcontent, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to append a aNewChild");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
NS_ADDREF(aNewChild);
|
||||
*aReturn = aNewChild;
|
||||
return NS_OK;
|
||||
@ -968,18 +1022,32 @@ RDFElementImpl::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDO
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
NS_PRECONDITION(aNewChild != nsnull, "null ptr");
|
||||
if (! aNewChild)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// It's possible that mDocument will be null for an element that's
|
||||
// not in the content model (e.g., somebody is working on a
|
||||
// "scratch" element that has been removed from the content tree).
|
||||
if (mDocument) {
|
||||
nsIDOMNodeObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMNodeObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnReplaceChild(this, aNewChild, aOldChild);
|
||||
NS_RELEASE(obs);
|
||||
NS_PRECONDITION(aOldChild != nsnull, "null ptr");
|
||||
if (! aOldChild)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIContent> oldelement = do_QueryInterface(aOldChild);
|
||||
NS_ASSERTION(oldelement != nsnull, "not an nsIContent");
|
||||
|
||||
if (oldelement) {
|
||||
PRInt32 pos;
|
||||
rv = IndexOf(oldelement, pos);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to determine index of aOldChild");
|
||||
|
||||
if (NS_SUCCEEDED(rv) && (pos >= 0)) {
|
||||
nsCOMPtr<nsIContent> newelement = do_QueryInterface(aNewChild);
|
||||
NS_ASSERTION(newelement != nsnull, "not an nsIContent");
|
||||
|
||||
if (newelement) {
|
||||
rv = ReplaceChildAt(newelement, pos, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to replace old child");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -992,18 +1060,23 @@ RDFElementImpl::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDO
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
NS_PRECONDITION(aOldChild != nsnull, "null ptr");
|
||||
if (! aOldChild)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// It's possible that mDocument will be null for an element that's
|
||||
// not in the content model (e.g., somebody is working on a
|
||||
// "scratch" element that has been removed from the content tree).
|
||||
if (mDocument) {
|
||||
nsIDOMNodeObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMNodeObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnRemoveChild(this, aOldChild);
|
||||
NS_RELEASE(obs);
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIContent> element = do_QueryInterface(aOldChild);
|
||||
NS_ASSERTION(element != nsnull, "not an nsIContent");
|
||||
|
||||
if (element) {
|
||||
PRInt32 pos;
|
||||
rv = IndexOf(element, pos);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to determine index of aOldChild");
|
||||
|
||||
if (NS_SUCCEEDED(rv) && (pos >= 0)) {
|
||||
rv = RemoveChildAt(pos, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to remove old child");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1016,24 +1089,7 @@ RDFElementImpl::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// It's possible that mDocument will be null for an element that's
|
||||
// not in the content model (e.g., somebody is working on a
|
||||
// "scratch" element that has been removed from the content tree).
|
||||
if (mDocument) {
|
||||
nsIDOMNodeObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMNodeObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnAppendChild(this, aNewChild);
|
||||
NS_RELEASE(obs);
|
||||
}
|
||||
}
|
||||
|
||||
NS_ADDREF(aNewChild);
|
||||
*aReturn = aNewChild;
|
||||
return NS_OK;
|
||||
return InsertBefore(aNewChild, nsnull, aReturn);
|
||||
}
|
||||
|
||||
|
||||
@ -1094,11 +1150,19 @@ RDFElementImpl::GetAttribute(const nsString& aName, nsString& aReturn)
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::SetAttribute(const nsString& aName, const nsString& aValue)
|
||||
{
|
||||
nsIDOMElementObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMElementObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnSetAttribute(this, aName, aValue);
|
||||
NS_RELEASE(obs);
|
||||
nsresult rv;
|
||||
|
||||
PRInt32 nameSpaceID;
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
|
||||
rv = ParseAttributeString(aName, *getter_AddRefs(tag), nameSpaceID);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to parse attribute name");
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = SetAttribute(nameSpaceID, tag, aValue, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set attribute");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1106,11 +1170,19 @@ RDFElementImpl::SetAttribute(const nsString& aName, const nsString& aValue)
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::RemoveAttribute(const nsString& aName)
|
||||
{
|
||||
nsIDOMElementObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMElementObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnRemoveAttribute(this, aName);
|
||||
NS_RELEASE(obs);
|
||||
nsresult rv;
|
||||
|
||||
PRInt32 nameSpaceID;
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
|
||||
rv = ParseAttributeString(aName, *getter_AddRefs(tag), nameSpaceID);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to parse attribute name");
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = UnsetAttribute(nameSpaceID, tag, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to remove attribute");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1142,15 +1214,12 @@ RDFElementImpl::GetAttributeNode(const nsString& aName, nsIDOMAttr** aReturn)
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::SetAttributeNode(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
NS_PRECONDITION(aNewAttr != nsnull, "null ptr");
|
||||
if (! aNewAttr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIDOMElementObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMElementObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnSetAttributeNode(this, aNewAttr);
|
||||
NS_RELEASE(obs);
|
||||
}
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
|
||||
NS_ADDREF(aNewAttr);
|
||||
*aReturn = aNewAttr;
|
||||
return NS_OK;
|
||||
@ -1160,15 +1229,12 @@ RDFElementImpl::SetAttributeNode(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn)
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::RemoveAttributeNode(nsIDOMAttr* aOldAttr, nsIDOMAttr** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
NS_PRECONDITION(aOldAttr != nsnull, "null ptr");
|
||||
if (! aOldAttr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIDOMElementObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMElementObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnRemoveAttributeNode(this, aOldAttr);
|
||||
NS_RELEASE(obs);
|
||||
}
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
|
||||
NS_ADDREF(aOldAttr);
|
||||
*aReturn = aOldAttr;
|
||||
return NS_OK;
|
||||
@ -1303,6 +1369,27 @@ RDFElementImpl::SetNameSpaceID(PRInt32 aNameSpaceID)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIXULContent interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::PeekChildCount(PRInt32& aCount) const
|
||||
{
|
||||
if (mChildren) {
|
||||
PRUint32 cnt;
|
||||
|
||||
nsresult rv;
|
||||
rv = mChildren->Count(&cnt);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
aCount = PRInt32(cnt);
|
||||
}
|
||||
else {
|
||||
aCount = 0;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIDOMEventReceiver interface
|
||||
@ -1718,15 +1805,7 @@ RDFElementImpl::ChildCount(PRInt32& aResult) const
|
||||
if (NS_FAILED(rv = EnsureContentsGenerated()))
|
||||
return rv;
|
||||
|
||||
if (mChildren) {
|
||||
PRUint32 cnt;
|
||||
rv = mChildren->Count(&cnt);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
aResult = cnt;
|
||||
}
|
||||
else
|
||||
aResult = 0;
|
||||
return NS_OK;
|
||||
return PeekChildCount(aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1824,14 +1903,6 @@ RDFElementImpl::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify)
|
||||
if (oldKid.get() == aKid)
|
||||
return NS_OK;
|
||||
|
||||
// Make sure that we're not trying to insert the same child
|
||||
// twice. If we do, the DOM APIs (e.g., GetNextSibling()), will
|
||||
// freak out.
|
||||
PRInt32 i = mChildren->IndexOf(aKid);
|
||||
NS_ASSERTION(i < 0, "element is already a child");
|
||||
if (i >= 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRBool replaceOk = mChildren->ReplaceElementAt(aKid, aIndex);
|
||||
if (replaceOk) {
|
||||
aKid->SetParent(NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
@ -1859,14 +1930,6 @@ RDFElementImpl::AppendChildTo(nsIContent* aKid, PRBool aNotify)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// Make sure that we're not trying to insert the same child
|
||||
// twice. If we do, the DOM APIs (e.g., GetNextSibling()), will
|
||||
// freak out.
|
||||
PRInt32 i = mChildren->IndexOf(aKid);
|
||||
NS_ASSERTION(i < 0, "element is already a child");
|
||||
if (i >= 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRBool appendOk = mChildren->AppendElement(aKid);
|
||||
if (appendOk) {
|
||||
aKid->SetParent(NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
@ -1913,16 +1976,12 @@ RDFElementImpl::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
// This is the nasty case. We have (potentially) a slew of selected items
|
||||
// and cells going away.
|
||||
// First, retrieve the tree.
|
||||
nsRDFDOMNodeList* itemList = nsnull;
|
||||
nsRDFDOMNodeList* cellList = nsnull;
|
||||
nsCOMPtr<nsIDOMXULTreeElement> treeElement;
|
||||
GetParentTree(getter_AddRefs(treeElement));
|
||||
rv = GetParentTree(getter_AddRefs(treeElement));
|
||||
if (treeElement) {
|
||||
nsCOMPtr<nsIDOMNodeList> nodes;
|
||||
treeElement->GetSelectedItems(getter_AddRefs(nodes));
|
||||
itemList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar.
|
||||
treeElement->GetSelectedCells(getter_AddRefs(nodes));
|
||||
cellList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar.
|
||||
nsCOMPtr<nsIDOMNodeList> itemList;
|
||||
treeElement->GetSelectedItems(getter_AddRefs(itemList));
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parentKid = do_QueryInterface(oldKid);
|
||||
PRBool fireSelectionHandler = PR_FALSE;
|
||||
if (itemList) {
|
||||
@ -1942,6 +2001,10 @@ RDFElementImpl::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNodeList> cellList;
|
||||
treeElement->GetSelectedCells(getter_AddRefs(cellList));
|
||||
|
||||
if (cellList) {
|
||||
// Iterate over all of the items and find out if they are contained inside
|
||||
// the removed subtree.
|
||||
@ -1961,8 +2024,10 @@ RDFElementImpl::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
}
|
||||
|
||||
if (fireSelectionHandler) {
|
||||
nsXULTreeElement* tree = (nsXULTreeElement*)(treeElement.get()); // XXX Yes, I am evil.
|
||||
tree->FireOnSelectHandler();
|
||||
nsCOMPtr<nsIXULTreeContent> tree = do_QueryInterface(treeElement);
|
||||
if (tree) {
|
||||
tree->FireOnSelectHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2131,14 +2196,14 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
|
||||
GetTag(*getter_AddRefs(tag));
|
||||
if (mDocument && (aNameSpaceID == kNameSpaceID_None)) {
|
||||
// See if we're a treeitem atom.
|
||||
nsRDFDOMNodeList* nodeList = nsnull;
|
||||
nsCOMPtr<nsIRDFNodeList> nodeList;
|
||||
if (tag && (tag.get() == kTreeItemAtom) && (aName == kSelectedAtom)) {
|
||||
nsCOMPtr<nsIDOMXULTreeElement> treeElement;
|
||||
GetParentTree(getter_AddRefs(treeElement));
|
||||
if (treeElement) {
|
||||
nsCOMPtr<nsIDOMNodeList> nodes;
|
||||
treeElement->GetSelectedItems(getter_AddRefs(nodes));
|
||||
nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar.
|
||||
nodeList = do_QueryInterface(nodes);
|
||||
}
|
||||
}
|
||||
else if (tag && (tag.get() == kTreeCellAtom) && (aName == kSelectedAtom)) {
|
||||
@ -2147,7 +2212,7 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
|
||||
if (treeElement) {
|
||||
nsCOMPtr<nsIDOMNodeList> nodes;
|
||||
treeElement->GetSelectedCells(getter_AddRefs(nodes));
|
||||
nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar.
|
||||
nodeList = do_QueryInterface(nodes);
|
||||
}
|
||||
}
|
||||
if (nodeList) {
|
||||
@ -2193,18 +2258,23 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
|
||||
// Check to see if the REF attribute is being set. If so, we need
|
||||
// to update the element map. First, remove the old mapping, if
|
||||
// necessary...
|
||||
if (mDocument && (aNameSpaceID == kNameSpaceID_None) && (aName == kRefAtom)) {
|
||||
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
|
||||
if (rdfdoc) {
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
|
||||
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
|
||||
if (rdfdoc && (aNameSpaceID == kNameSpaceID_None)) {
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
if (aName == kRefAtom) {
|
||||
GetRefResource(getter_AddRefs(resource));
|
||||
if (resource) {
|
||||
rdfdoc->RemoveElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
}
|
||||
}
|
||||
else if (aName == kIdAtom) {
|
||||
GetIdResource(getter_AddRefs(resource));
|
||||
}
|
||||
|
||||
if (resource) {
|
||||
rdfdoc->RemoveElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// XXX need to check if they're changing an event handler: if so, then we need
|
||||
// to unhook the old one.
|
||||
|
||||
@ -2231,15 +2301,17 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
|
||||
|
||||
// Check for REF attribute, part deux. Add the new REF to the map,
|
||||
// if appropriate.
|
||||
if (mDocument && (aNameSpaceID == kNameSpaceID_None) && (aName == kRefAtom)) {
|
||||
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
|
||||
if (rdfdoc) {
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
|
||||
if (rdfdoc && (aNameSpaceID == kNameSpaceID_None)) {
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
if (aName == kRefAtom) {
|
||||
GetRefResource(getter_AddRefs(resource));
|
||||
if (resource) {
|
||||
rdfdoc->AddElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
}
|
||||
}
|
||||
else if (aName == kIdAtom) {
|
||||
GetIdResource(getter_AddRefs(resource));
|
||||
}
|
||||
|
||||
if (resource) {
|
||||
rdfdoc->AddElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2374,6 +2446,7 @@ RDFElementImpl::GetAttribute(PRInt32 aNameSpaceID,
|
||||
else {
|
||||
rv = NS_CONTENT_ATTR_NO_VALUE;
|
||||
}
|
||||
#if 0
|
||||
if ((aNameSpaceID == kNameSpaceID_None) &&
|
||||
(attr->mName == kIdAtom))
|
||||
{
|
||||
@ -2384,6 +2457,7 @@ RDFElementImpl::GetAttribute(PRInt32 aNameSpaceID,
|
||||
nsRDFContentUtils::MakeElementID(mDocument, attr->mValue, aResult);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2427,14 +2501,14 @@ RDFElementImpl::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNot
|
||||
// doing it anyway. Need to make an nsIRDFNodeList interface that
|
||||
// I can QI to for additions and removals of nodes. For now
|
||||
// do an evil cast.
|
||||
nsRDFDOMNodeList* nodeList = nsnull;
|
||||
nsCOMPtr<nsIRDFNodeList> nodeList;
|
||||
if (tag && (tag.get() == kTreeItemAtom) && (aName == kSelectedAtom)) {
|
||||
nsCOMPtr<nsIDOMXULTreeElement> treeElement;
|
||||
GetParentTree(getter_AddRefs(treeElement));
|
||||
if (treeElement) {
|
||||
nsCOMPtr<nsIDOMNodeList> nodes;
|
||||
treeElement->GetSelectedItems(getter_AddRefs(nodes));
|
||||
nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar.
|
||||
nodeList = do_QueryInterface(nodes);
|
||||
}
|
||||
}
|
||||
else if (tag && (tag.get() == kTreeCellAtom) && (aName == kSelectedAtom)) {
|
||||
@ -2443,7 +2517,7 @@ RDFElementImpl::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNot
|
||||
if (treeElement) {
|
||||
nsCOMPtr<nsIDOMNodeList> nodes;
|
||||
treeElement->GetSelectedCells(getter_AddRefs(nodes));
|
||||
nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar.
|
||||
nodeList = do_QueryInterface(nodes);
|
||||
}
|
||||
}
|
||||
if (nodeList) {
|
||||
@ -2944,7 +3018,7 @@ RDFElementImpl::GetIdResource(nsIRDFResource** aResource)
|
||||
const nsXULAttribute* attr = (const nsXULAttribute*) mAttributes->ElementAt(i);
|
||||
if ((attr->mNameSpaceID == kNameSpaceID_None) &&
|
||||
(attr->mName == kIdAtom)) {
|
||||
return gRDFService->GetUnicodeResource(attr->mValue.GetUnicode(), aResource);
|
||||
return nsRDFContentUtils::MakeElementResource(mDocument, attr->mValue.GetUnicode(), aResource);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2970,7 +3044,7 @@ RDFElementImpl::GetRefResource(nsIRDFResource** aResource)
|
||||
|
||||
if (attr->mName != kRefAtom)
|
||||
continue;
|
||||
|
||||
#if 0
|
||||
// Found it!
|
||||
nsresult rv;
|
||||
|
||||
@ -2983,6 +3057,9 @@ RDFElementImpl::GetRefResource(nsIRDFResource** aResource)
|
||||
|
||||
// ...then, setup the new mapping.
|
||||
return gRDFService->GetUnicodeResource(uri.GetUnicode(), aResource);
|
||||
#else
|
||||
return nsRDFContentUtils::MakeElementResource(mDocument, attr->mValue.GetUnicode(), aResource);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
@ -36,7 +36,30 @@
|
||||
nsIAtom* nsXULTreeElement::kSelectedAtom;
|
||||
int nsXULTreeElement::gRefCnt = 0;
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsXULTreeElement, nsXULElement, nsIDOMXULTreeElement);
|
||||
NS_IMPL_ADDREF_INHERITED(nsXULTreeElement, nsXULElement);
|
||||
NS_IMPL_RELEASE_INHERITED(nsXULTreeElement, nsXULElement);
|
||||
|
||||
nsresult
|
||||
nsXULTreeElement::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(nsCOMTypeInfo<nsIDOMXULTreeElement>::GetIID())) {
|
||||
*aResult = NS_STATIC_CAST(nsIDOMXULTreeElement*, this);
|
||||
}
|
||||
else if (aIID.Equals(nsCOMTypeInfo<nsIXULTreeContent>::GetIID())) {
|
||||
*aResult = NS_STATIC_CAST(nsIXULTreeContent*, this);
|
||||
}
|
||||
else {
|
||||
return nsXULElement::QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
NS_ADDREF(NS_REINTERPRET_CAST(nsISupports*, *aResult));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsXULTreeElement::nsXULTreeElement(nsIDOMXULElement* aOuter)
|
||||
:nsXULElement(aOuter)
|
||||
@ -306,7 +329,7 @@ nsXULTreeElement::InvertSelection()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsresult
|
||||
nsXULTreeElement::FireOnSelectHandler()
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mOuter);
|
||||
@ -319,7 +342,7 @@ nsXULTreeElement::FireOnSelectHandler()
|
||||
nsAutoString value;
|
||||
content->GetAttribute(kNameSpaceID_None, kSuppressSelectChange, value);
|
||||
if (value == "true")
|
||||
return;
|
||||
return NS_OK;
|
||||
|
||||
PRInt32 count = document->GetNumberOfShells();
|
||||
for (PRInt32 i = 0; i < count; i++) {
|
||||
@ -340,5 +363,7 @@ nsXULTreeElement::FireOnSelectHandler()
|
||||
|
||||
content->HandleDOMEvent(*aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -28,10 +28,12 @@
|
||||
|
||||
#include "nsXULElement.h"
|
||||
#include "nsIDOMXULTreeElement.h"
|
||||
#include "nsIXULTreeContent.h"
|
||||
#include "nsRDFDOMNodeList.h"
|
||||
|
||||
class nsXULTreeElement : public nsXULElement,
|
||||
public nsIDOMXULTreeElement
|
||||
public nsIDOMXULTreeElement,
|
||||
public nsIXULTreeContent
|
||||
{
|
||||
public:
|
||||
nsXULTreeElement(nsIDOMXULElement* aOuter);
|
||||
@ -51,11 +53,12 @@ public:
|
||||
// nsIDOMXULTreeElement interface
|
||||
NS_DECL_IDOMXULTREEELEMENT
|
||||
|
||||
// nsIXULTreeContent interface
|
||||
NS_IMETHOD FireOnSelectHandler();
|
||||
|
||||
static nsIAtom* kSelectedAtom;
|
||||
static int gRefCnt;
|
||||
|
||||
void FireOnSelectHandler();
|
||||
|
||||
protected:
|
||||
// Helpers
|
||||
void ClearItemSelectionInternal();
|
||||
|
@ -190,6 +190,10 @@ XULCommandDispatcherImpl::SetFocusedWindow(nsIDOMWindow* aElement)
|
||||
NS_IMETHODIMP
|
||||
XULCommandDispatcherImpl::AddCommand(nsIDOMElement* aElement)
|
||||
{
|
||||
NS_PRECONDITION(aElement != nsnull, "null ptr");
|
||||
if (! aElement)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (!mFocusListeners) {
|
||||
mFocusListeners = new nsVoidArray();
|
||||
mFocusListeners->AppendElement((void*)aElement); // Weak ref to element.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,9 +25,7 @@
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMElementObserver.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeObserver.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIRDFContentModelBuilder.h"
|
||||
|
@ -39,9 +39,7 @@
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMElementObserver.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeObserver.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
@ -390,12 +388,6 @@ RDFGenericBuilderImpl::QueryInterface(REFNSIID iid, void** aResult)
|
||||
else if (iid.Equals(kIRDFObserverIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIRDFObserver*, this);
|
||||
}
|
||||
else if (iid.Equals(nsIDOMNodeObserver::GetIID())) {
|
||||
*aResult = NS_STATIC_CAST(nsIDOMNodeObserver*, this);
|
||||
}
|
||||
else if (iid.Equals(nsIDOMElementObserver::GetIID())) {
|
||||
*aResult = NS_STATIC_CAST(nsIDOMElementObserver*, this);
|
||||
}
|
||||
else {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
@ -539,22 +531,38 @@ RDFGenericBuilderImpl::CreateElement(PRInt32 aNameSpaceID,
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> doc( do_QueryInterface(mDocument) );
|
||||
|
||||
if (aResource) {
|
||||
const char *uri;
|
||||
const char *uri;
|
||||
rv = aResource->GetValueConst(&uri);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource URI");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = result->SetAttribute(kNameSpaceID_None, kIdAtom, (const char*) uri, PR_FALSE);
|
||||
nsAutoString id;
|
||||
rv = nsRDFContentUtils::MakeElementID(doc, nsAutoString(uri), id);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = result->SetAttribute(kNameSpaceID_None, kIdAtom, id, PR_FALSE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set id attribute");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> doc( do_QueryInterface(mDocument) );
|
||||
rv = result->SetDocument(doc, PR_FALSE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set element's document");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (aResource && aNameSpaceID == kNameSpaceID_HTML) {
|
||||
// If this is an HTML element, then explicitly add it to the
|
||||
// map. (XUL elements don't have to do this because their
|
||||
// SetDocument() call does the magic.) Don't worry: the
|
||||
// document observer methods are on the lookout to update the
|
||||
// map for "attribute changed" calls that monkey with the 'id'
|
||||
// or 'ref' parameters.
|
||||
rv = mDocument->AddElementForResource(aResource, result);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
*aResult = result;
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
@ -628,15 +636,17 @@ RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource,
|
||||
// child to this node.
|
||||
|
||||
// XXX Bug 10818.
|
||||
PRBool notify;
|
||||
if (IsTreeWidgetItem(element) && !IsReflowScheduled()) {
|
||||
notify = PR_TRUE;
|
||||
|
||||
rv = ScheduleReflow();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else {
|
||||
notify = PR_FALSE;
|
||||
PRBool notify = PR_TRUE;
|
||||
if (IsTreeWidgetItem(element)) {
|
||||
if (!IsReflowScheduled()) {
|
||||
rv = ScheduleReflow();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else {
|
||||
// a reflow has been scheduled. we'll add the
|
||||
// element but won't notify right now.
|
||||
notify = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
rv = CreateWidgetItem(element, aProperty, resource, 0, notify);
|
||||
@ -676,9 +686,6 @@ RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource,
|
||||
// this node was created by a XUL template, so update it accordingly
|
||||
rv = SynchronizeUsingTemplate(templateNode, element, eSet, aProperty, aTarget);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PersistProperty(element, aProperty, aTarget, eSet);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -790,9 +797,6 @@ RDFGenericBuilderImpl::OnUnassert(nsIRDFResource* aSource,
|
||||
// this node was created by a XUL template, so update it accordingly
|
||||
rv = SynchronizeUsingTemplate(templateNode, element, eClear, aProperty, aTarget);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PersistProperty(element, aProperty, aTarget, eClear);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -907,9 +911,6 @@ RDFGenericBuilderImpl::OnChange(nsIRDFResource* aSource,
|
||||
// this node was created by a XUL template, so update it accordingly
|
||||
rv = SynchronizeUsingTemplate(templateNode, element, eSet, aProperty, aNewTarget);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PersistProperty(element, aProperty, aNewTarget, eSet);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -928,55 +929,7 @@ RDFGenericBuilderImpl::OnMove(nsIRDFResource* aOldSource,
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIDOMNodeObserver interface
|
||||
//
|
||||
// XXX Any of these methods that can't be implemented in a generic
|
||||
// way should become pure virtual on this class.
|
||||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnSetNodeValue(nsIDOMNode* aNode, const nsString& aValue)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnInsertBefore(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aRefChild)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnReplaceChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aOldChild)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnRemoveChild(nsIDOMNode* aParent, nsIDOMNode* aOldChild)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnAppendChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIDOMElementObserver interface
|
||||
|
||||
|
||||
#if 0
|
||||
PRBool
|
||||
RDFGenericBuilderImpl::IsAttributePersisent(nsIContent *element, PRInt32 aNameSpaceID, nsIAtom *aAtom)
|
||||
{
|
||||
@ -1151,361 +1104,7 @@ RDFGenericBuilderImpl::PersistProperty(nsIContent *element, nsIRDFResource *aPro
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnSetAttribute(nsIDOMElement* aElement, const nsString& aName, const nsString& aValue)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
if (NS_FAILED(rv = GetDOMNodeResource(aElement, getter_AddRefs(resource)))) {
|
||||
// XXX it's not a resource element, so there's no assertions
|
||||
// we need to make on the back-end. Should we just do the
|
||||
// update?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get the nsIContent interface, it's a bit more utilitarian
|
||||
nsCOMPtr<nsIContent> element( do_QueryInterface(aElement) );
|
||||
if (! element) {
|
||||
NS_ERROR("element doesn't support nsIContent");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// Make sure that the element is in the widget. XXX Even this may be
|
||||
// a bit too promiscuous: an element may also be a XUL element...
|
||||
if (!IsElementInWidget(element))
|
||||
return NS_OK;
|
||||
|
||||
// Split the element into its namespace and tag components
|
||||
PRInt32 elementNameSpaceID;
|
||||
if (NS_FAILED(rv = element->GetNameSpaceID(elementNameSpaceID))) {
|
||||
NS_ERROR("unable to get element namespace ID");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> elementNameAtom;
|
||||
if (NS_FAILED(rv = element->GetTag( *getter_AddRefs(elementNameAtom) ))) {
|
||||
NS_ERROR("unable to get element tag");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Split the property name into its namespace and tag components
|
||||
PRInt32 attrNameSpaceID;
|
||||
nsCOMPtr<nsIAtom> attrNameAtom;
|
||||
if (NS_FAILED(rv = element->ParseAttributeString(aName, *getter_AddRefs(attrNameAtom), attrNameSpaceID))) {
|
||||
NS_ERROR("unable to parse attribute string");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Now do the work to change the attribute. There are a couple of
|
||||
// special cases that we need to check for here...
|
||||
if ((elementNameSpaceID == kNameSpaceID_XUL) &&
|
||||
IsResourceElement(element) && // XXX IsResourceElement(): is this what we really mean?
|
||||
(attrNameSpaceID == kNameSpaceID_None) &&
|
||||
(attrNameAtom.get() == kOpenAtom)) {
|
||||
|
||||
// We are (possibly) changing the value of the "open"
|
||||
// attribute. This may require us to generate or destroy
|
||||
// content in the widget. See what the old value was...
|
||||
nsAutoString attrValue;
|
||||
if (NS_FAILED(rv = element->GetAttribute(kNameSpaceID_None, kOpenAtom, attrValue))) {
|
||||
NS_ERROR("unable to get current open state");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if ((rv == NS_CONTENT_ATTR_NO_VALUE) || (rv == NS_CONTENT_ATTR_NOT_THERE) ||
|
||||
((rv == NS_CONTENT_ATTR_HAS_VALUE) && (! attrValue.EqualsIgnoreCase(aValue))) ||
|
||||
PR_TRUE // XXX just always allow this to fire.
|
||||
) {
|
||||
// Okay, it's really changing.
|
||||
|
||||
// This is a "transient" property, so we _don't_ go to the
|
||||
// RDF graph to set it.
|
||||
if (NS_FAILED(rv = element->SetAttribute(kNameSpaceID_None, kOpenAtom, aValue, PR_TRUE))) {
|
||||
NS_ERROR("unable to update attribute on content node");
|
||||
return rv;
|
||||
}
|
||||
|
||||
PersistAttribute(element, kNameSpaceID_None, kOpenAtom, aValue, eSet);
|
||||
|
||||
if (aValue.EqualsIgnoreCase("true")) {
|
||||
rv = OpenWidgetItem(element);
|
||||
}
|
||||
else {
|
||||
rv = CloseWidgetItem(element);
|
||||
}
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to open/close tree item");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else if ((elementNameSpaceID == kNameSpaceID_XUL) &&
|
||||
(IsResourceElement(element)) &&
|
||||
(attrNameSpaceID == kNameSpaceID_None) &&
|
||||
(attrNameAtom.get() == kIdAtom)) {
|
||||
|
||||
// We are (possibly) changing the actual identity of the
|
||||
// element; e.g., re-rooting an item in the tree.
|
||||
|
||||
nsCOMPtr<nsIRDFResource> newResource;
|
||||
if (NS_FAILED(rv = gRDFService->GetUnicodeResource(aValue.GetUnicode(), getter_AddRefs(newResource)))) {
|
||||
NS_ERROR("unable to get new resource");
|
||||
return rv;
|
||||
}
|
||||
|
||||
#if 0 // XXX we're fighting with the XUL builder, so just _always_ let this through.
|
||||
// Didn't change. So bail!
|
||||
if (resource == newResource)
|
||||
return NS_OK;
|
||||
#endif
|
||||
|
||||
// Allright, it really is changing. So blow away the old
|
||||
// content node and insert a new one with the new ID in
|
||||
// its place.
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
if (NS_FAILED(rv = element->GetParent(*getter_AddRefs(parent)))) {
|
||||
NS_ERROR("unable to get element's parent");
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRInt32 elementIndex;
|
||||
if (NS_FAILED(rv = parent->IndexOf(element, elementIndex))) {
|
||||
NS_ERROR("unable to get element's index within parent");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (! parent)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
if (NS_FAILED(rv = parent->RemoveChildAt(elementIndex, PR_TRUE))) {
|
||||
NS_ERROR("unable to remove element");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> newElement;
|
||||
if (NS_FAILED(rv = CreateElement(elementNameSpaceID,
|
||||
elementNameAtom,
|
||||
newResource,
|
||||
getter_AddRefs(newElement)))) {
|
||||
NS_ERROR("unable to create new element");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Attach transient properties to the new element.
|
||||
//
|
||||
// XXX all I really care about right this minute is the
|
||||
// "open" state. We could put this stuff in a table and
|
||||
// drive it that way.
|
||||
nsAutoString attrValue;
|
||||
if (NS_FAILED(rv = element->GetAttribute(kNameSpaceID_None, kOpenAtom, attrValue))) {
|
||||
NS_ERROR("unable to get open state of old element");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
|
||||
if (NS_FAILED(rv = newElement->SetAttribute(kNameSpaceID_None, kOpenAtom, attrValue, PR_FALSE))) {
|
||||
NS_ERROR("unable to set open state of new element");
|
||||
return rv;
|
||||
}
|
||||
|
||||
PersistAttribute(newElement, kNameSpaceID_None, kOpenAtom, attrValue, eSet);
|
||||
|
||||
}
|
||||
|
||||
// Mark as a container so the contents get regenerated
|
||||
if (NS_FAILED(rv = newElement->SetAttribute(kNameSpaceID_None,
|
||||
kLazyContentAtom,
|
||||
"true",
|
||||
PR_FALSE))) {
|
||||
NS_ERROR("unable to mark as a container");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Now insert the new element into the parent. This should
|
||||
// trigger a reflow and cause the contents to be regenerated.
|
||||
if (NS_FAILED(rv = parent->InsertChildAt(newElement, elementIndex, PR_TRUE))) {
|
||||
NS_ERROR("unable to add new element to the parent");
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
else if ((attrNameSpaceID == kNameSpaceID_None) &&
|
||||
(attrNameAtom.get() == kRefAtom)) {
|
||||
// Remove all of the template children and rebuild them
|
||||
rv = RemoveAndRebuildGeneratedChildren(element);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// If we get here, it's a "vanilla" property: push its value into the graph.
|
||||
if (kNameSpaceID_Unknown == attrNameSpaceID) {
|
||||
attrNameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
|
||||
}
|
||||
nsCOMPtr<nsIRDFResource> property;
|
||||
if (NS_FAILED(rv = GetResource(attrNameSpaceID, attrNameAtom, getter_AddRefs(property)))) {
|
||||
NS_ERROR("unable to construct resource");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Get the old value, if there was one.
|
||||
nsAutoString oldValueStr;
|
||||
rv = element->GetAttribute(attrNameSpaceID, attrNameAtom, oldValueStr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> oldvalue;
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == rv) {
|
||||
rv = gRDFService->GetLiteral(oldValueStr.GetUnicode(), getter_AddRefs(oldvalue));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to construct literal");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// Get the new value
|
||||
nsCOMPtr<nsIRDFLiteral> newvalue;
|
||||
rv = gRDFService->GetLiteral(aValue.GetUnicode(), getter_AddRefs(newvalue));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to construct literal");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (oldvalue) {
|
||||
rv = mDB->Change(resource, property, oldvalue, newvalue);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else {
|
||||
rv = mDB->Assert(resource, property, newvalue, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
if (rv == NS_RDF_ASSERTION_REJECTED) {
|
||||
// Okay, just force the attribute to be set.
|
||||
rv = element->SetAttribute(attrNameSpaceID, attrNameAtom, aValue, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnRemoveAttribute(nsIDOMElement* aElement, const nsString& aName)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
if (NS_FAILED(rv = GetDOMNodeResource(aElement, getter_AddRefs(resource)))) {
|
||||
// XXX it's not a resource element, so there's no assertions
|
||||
// we need to make on the back-end. Should we just do the
|
||||
// update?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get the nsIContent interface, it's a bit more utilitarian
|
||||
nsCOMPtr<nsIContent> element( do_QueryInterface(aElement) );
|
||||
if (! element) {
|
||||
NS_ERROR("element doesn't support nsIContent");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// Make sure that the element is in the widget. XXX Even this may be
|
||||
// a bit too promiscuous: an element may also be a XUL element...
|
||||
if (!IsElementInWidget(element))
|
||||
return NS_OK;
|
||||
|
||||
// Split the element into its namespace and tag components
|
||||
PRInt32 elementNameSpaceID;
|
||||
if (NS_FAILED(rv = element->GetNameSpaceID(elementNameSpaceID))) {
|
||||
NS_ERROR("unable to get element namespace ID");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> elementNameAtom;
|
||||
if (NS_FAILED(rv = element->GetTag( *getter_AddRefs(elementNameAtom) ))) {
|
||||
NS_ERROR("unable to get element tag");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Split the property name into its namespace and tag components
|
||||
PRInt32 attrNameSpaceID;
|
||||
nsCOMPtr<nsIAtom> attrNameAtom;
|
||||
if (NS_FAILED(rv = element->ParseAttributeString(aName, *getter_AddRefs(attrNameAtom), attrNameSpaceID))) {
|
||||
NS_ERROR("unable to parse attribute string");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if ((elementNameSpaceID == kNameSpaceID_XUL) &&
|
||||
IsResourceElement(element) && // XXX Is this what we really mean?
|
||||
(attrNameSpaceID == kNameSpaceID_None) &&
|
||||
(attrNameAtom.get() == kOpenAtom)) {
|
||||
// We are removing the value of the "open" attribute. This may
|
||||
// require us to destroy content from the tree.
|
||||
|
||||
|
||||
nsAutoString openVal;
|
||||
if (NS_FAILED(rv = element->GetAttribute(kNameSpaceID_None, kOpenAtom, openVal))) {
|
||||
NS_ERROR("unable to get open attribute on update content node");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// XXX should we check for existence of the attribute first?
|
||||
if (NS_FAILED(rv = element->UnsetAttribute(kNameSpaceID_None, kOpenAtom, PR_TRUE))) {
|
||||
NS_ERROR("unable to attribute on update content node");
|
||||
return rv;
|
||||
}
|
||||
|
||||
PersistAttribute(element, kNameSpaceID_None, kOpenAtom, openVal, eClear);
|
||||
|
||||
if (NS_FAILED(rv = CloseWidgetItem(element))) {
|
||||
NS_ERROR("unable to close widget item");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else if ((attrNameSpaceID == kNameSpaceID_None) &&
|
||||
(attrNameAtom.get() == kRefAtom)) {
|
||||
// Ignore changes to the 'ref=' attribute; the XUL builder
|
||||
// will take care of that for us.
|
||||
}
|
||||
else {
|
||||
// It's a "vanilla" property: push its value into the graph.
|
||||
|
||||
nsCOMPtr<nsIRDFResource> property;
|
||||
if (kNameSpaceID_Unknown == attrNameSpaceID) {
|
||||
attrNameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
|
||||
}
|
||||
if (NS_FAILED(rv = GetResource(attrNameSpaceID, attrNameAtom, getter_AddRefs(property)))) {
|
||||
NS_ERROR("unable to construct resource");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Unassert the old value, if there was one.
|
||||
nsAutoString oldValue;
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == element->GetAttribute(attrNameSpaceID, attrNameAtom, oldValue)) {
|
||||
nsCOMPtr<nsIRDFLiteral> value;
|
||||
if (NS_FAILED(rv = gRDFService->GetLiteral(oldValue.GetUnicode(), getter_AddRefs(value)))) {
|
||||
NS_ERROR("unable to construct literal");
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = mDB->Unassert(resource, property, value);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to unassert old property value");
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnSetAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aNewAttr)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnRemoveAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aOldAttr)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
#endif // 0
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@ -1977,23 +1576,6 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||
}
|
||||
}
|
||||
|
||||
// get any persistant attributes
|
||||
if ((!aIsUnique) && (isResourceElement)) {
|
||||
GetPersistentAttributes(realKid);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// If item says its "open", then recurse now and build up its children
|
||||
nsAutoString openState;
|
||||
rv = realKid->GetAttribute(kNameSpaceID_None, kOpenAtom, openState);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if ((rv == NS_CONTENT_ATTR_HAS_VALUE) && (openState.EqualsIgnoreCase("true"))) {
|
||||
rv = OpenWidgetItem(realKid);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (nameSpaceID == kNameSpaceID_HTML) {
|
||||
// If we just built HTML, then we have to recurse "by
|
||||
// hand" because HTML won't build itself up lazily.
|
||||
@ -2323,7 +1905,7 @@ RDFGenericBuilderImpl::CreateContainerContents(nsIContent* aElement, nsIRDFResou
|
||||
// This will insert all of the elements into the
|
||||
// container, but _won't_ bother layout about it.
|
||||
for (loop=0; loop<numElements; loop+=2) {
|
||||
rv = CreateWidgetItem(aElement, flatArray[loop+1], flatArray[loop], loop+1, (istree ? PR_FALSE : PR_TRUE));
|
||||
rv = CreateWidgetItem(aElement, flatArray[loop+1], flatArray[loop], loop+1, PR_FALSE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create widget item");
|
||||
if (NS_FAILED(rv)) break;
|
||||
}
|
||||
@ -2799,212 +2381,6 @@ RDFGenericBuilderImpl::GetResource(PRInt32 aNameSpaceID,
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
RDFGenericBuilderImpl::OpenWidgetItem(nsIContent* aElement)
|
||||
{
|
||||
#ifdef PR_LOGGING
|
||||
if (PR_LOG_TEST(gLog, PR_LOG_DEBUG)) {
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
rv = aElement->GetTag(*getter_AddRefs(tag));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString tagStr;
|
||||
tag->ToString(tagStr);
|
||||
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
("rdfgeneric open-widget-item %s",
|
||||
(const char*) nsCAutoString(tagStr)));
|
||||
}
|
||||
#endif
|
||||
return CreateContents(aElement);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
RDFGenericBuilderImpl::CloseWidgetItem(nsIContent* aElement)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (PR_LOG_TEST(gLog, PR_LOG_DEBUG)) {
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
rv = aElement->GetTag(*getter_AddRefs(tag));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString tagStr;
|
||||
tag->ToString(tagStr);
|
||||
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
("rdfgeneric close-widget-item %s",
|
||||
(const char*) nsCAutoString(tagStr)));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Find the tag that contains the children so that we can remove
|
||||
// all of the children.
|
||||
//
|
||||
// XXX We make a bit of a leap here and assume that the same
|
||||
// template that was used to generate _us_ was used to generate
|
||||
// our _kids_. I'm sure this'll break when we do toolbars or
|
||||
// something.
|
||||
nsAutoString tmplID;
|
||||
rv = aElement->GetAttribute(kNameSpaceID_None, kTemplateAtom, tmplID);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (rv != NS_CONTENT_ATTR_HAS_VALUE)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMXULDocument> xulDoc = do_QueryInterface(mDocument);
|
||||
if (! xulDoc)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> tmplDOMEle;
|
||||
rv = xulDoc->GetElementById(tmplID, getter_AddRefs(tmplDOMEle));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIContent> tmpl = do_QueryInterface(tmplDOMEle);
|
||||
if (! tmpl)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIContent> tmplParent;
|
||||
rv = tmpl->GetParent(*getter_AddRefs(tmplParent));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_ASSERTION(tmplParent != nsnull, "template node has no parent");
|
||||
if (! tmplParent)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIAtom> tmplParentTag;
|
||||
rv = tmplParent->GetTag(*getter_AddRefs(tmplParentTag));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIContent> childcontainer;
|
||||
if ((tmplParentTag.get() == kRuleAtom) || (tmplParentTag.get() == kTemplateAtom)) {
|
||||
childcontainer = dont_QueryInterface(aElement);
|
||||
}
|
||||
else {
|
||||
rv = nsRDFContentUtils::FindChildByTag(aElement,
|
||||
kNameSpaceID_XUL,
|
||||
tmplParentTag,
|
||||
getter_AddRefs(childcontainer));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (rv == NS_RDF_NO_VALUE) {
|
||||
// No tag; must've already been closed
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 count;
|
||||
rv = childcontainer->ChildCount(count);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get count of the parent's children");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
while (--count >= 0) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
rv = childcontainer->ChildAt(count, *getter_AddRefs(child));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = childcontainer->RemoveChildAt(count, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "error removing child");
|
||||
|
||||
do {
|
||||
// If it's _not_ a XUL element, then we want to blow it and
|
||||
// all of its kids out of the XUL document's
|
||||
// resource-to-element map.
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
rv = nsRDFContentUtils::GetElementResource(child, getter_AddRefs(resource));
|
||||
if (NS_FAILED(rv)) break;
|
||||
|
||||
PRBool isXULElement;
|
||||
rv = mDB->HasAssertion(resource, kRDF_instanceOf, kXUL_element, PR_TRUE, &isXULElement);
|
||||
if (NS_FAILED(rv)) break;
|
||||
|
||||
if (! isXULElement)
|
||||
break;
|
||||
|
||||
rv = child->SetDocument(nsnull, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
} while (0);
|
||||
}
|
||||
|
||||
// Clear the container-contents-generated attribute so that the next time we
|
||||
// come back, we'll regenerate the kids we just killed.
|
||||
rv = aElement->UnsetAttribute(kNameSpaceID_None,
|
||||
kContainerContentsGeneratedAtom,
|
||||
PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// This is a _total_ hack to make sure that any XUL we blow away
|
||||
// gets rebuilt.
|
||||
rv = childcontainer->UnsetAttribute(kNameSpaceID_None,
|
||||
kXULContentsGeneratedAtom,
|
||||
PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = childcontainer->SetAttribute(kNameSpaceID_None,
|
||||
kLazyContentAtom,
|
||||
"true",
|
||||
PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
RDFGenericBuilderImpl::RemoveAndRebuildGeneratedChildren(nsIContent* aElement)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
PRInt32 count;
|
||||
rv = aElement->ChildCount(count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
while (--count >= 0) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
rv = aElement->ChildAt(count, *getter_AddRefs(child));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString tmplID;
|
||||
rv = child->GetAttribute(kNameSpaceID_None, kTemplateAtom, tmplID);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (rv != NS_CONTENT_ATTR_HAS_VALUE)
|
||||
continue;
|
||||
|
||||
// It's a generated element. Remove it, and set its document
|
||||
// to null so that it'll get knocked out of the XUL doc's
|
||||
// resource-to-element map.
|
||||
rv = aElement->RemoveChildAt(count, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "error removing child");
|
||||
|
||||
rv = child->SetDocument(nsnull, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// Clear the contents-generated attribute so that the next time we
|
||||
// come back, we'll regenerate the kids we just killed.
|
||||
rv = aElement->UnsetAttribute(kNameSpaceID_None,
|
||||
kTemplateContentsGeneratedAtom,
|
||||
PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = aElement->UnsetAttribute(kNameSpaceID_None,
|
||||
kContainerContentsGeneratedAtom,
|
||||
PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = CreateContents(aElement);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
RDFGenericBuilderImpl::IsTreeWidgetItem(nsIContent* aElement)
|
||||
{
|
||||
@ -3053,7 +2429,7 @@ RDFGenericBuilderImpl::ScheduleReflow()
|
||||
rv = NS_NewTimer(getter_AddRefs(mTimer));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mTimer->Init(RDFGenericBuilderImpl::ForceTreeReflow, this, 1000);
|
||||
mTimer->Init(RDFGenericBuilderImpl::ForceTreeReflow, this, 100);
|
||||
NS_ADDREF(this); // the timer will hold a reference to the builder
|
||||
|
||||
return NS_OK;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIController.h"
|
||||
@ -70,14 +71,14 @@ GetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *v
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULCOMMANDDISPATCHER_FOCUSEDELEMENT:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.focusedelement", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -95,6 +96,7 @@ GetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *v
|
||||
}
|
||||
case XULCOMMANDDISPATCHER_FOCUSEDWINDOW:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.focusedwindow", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -113,7 +115,6 @@ GetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *v
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
@ -138,14 +139,14 @@ SetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *v
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULCOMMANDDISPATCHER_FOCUSEDELEMENT:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.focusedelement", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -164,6 +165,7 @@ SetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *v
|
||||
}
|
||||
case XULCOMMANDDISPATCHER_FOCUSEDWINDOW:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.focusedwindow", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -183,7 +185,6 @@ SetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *v
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
@ -235,8 +236,8 @@ XULCommandDispatcherAddCommand(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -246,7 +247,6 @@ XULCommandDispatcherAddCommand(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -291,8 +291,8 @@ XULCommandDispatcherRemoveCommand(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -302,7 +302,6 @@ XULCommandDispatcherRemoveCommand(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -346,8 +345,8 @@ XULCommandDispatcherUpdateCommands(JSContext *cx, JSObject *obj, uintN argc, jsv
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -357,7 +356,6 @@ XULCommandDispatcherUpdateCommands(JSContext *cx, JSObject *obj, uintN argc, jsv
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -390,8 +388,8 @@ XULCommandDispatcherGetController(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -401,7 +399,6 @@ XULCommandDispatcherGetController(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -435,8 +432,8 @@ XULCommandDispatcherSetController(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -446,7 +443,6 @@ XULCommandDispatcherSetController(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMElement.h"
|
||||
@ -71,14 +72,14 @@ GetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULDOCUMENT_POPUPELEMENT:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xuldocument.popupelement", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -96,6 +97,7 @@ GetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULDOCUMENT_TOOLTIPELEMENT:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xuldocument.tooltipelement", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -113,6 +115,7 @@ GetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULDOCUMENT_COMMANDDISPATCHER:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xuldocument.commanddispatcher", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -131,7 +134,6 @@ GetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
@ -156,14 +158,14 @@ SetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULDOCUMENT_POPUPELEMENT:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xuldocument.popupelement", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -182,6 +184,7 @@ SetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULDOCUMENT_TOOLTIPELEMENT:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xuldocument.tooltipelement", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -201,7 +204,6 @@ SetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
@ -254,8 +256,8 @@ XULDocumentGetElementById(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -265,7 +267,6 @@ XULDocumentGetElementById(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -306,8 +307,8 @@ XULDocumentGetElementsByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -317,7 +318,6 @@ XULDocumentGetElementsByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIController.h"
|
||||
@ -83,14 +84,14 @@ GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULELEMENT_ID:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.id", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -107,6 +108,7 @@ GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULELEMENT_CLASSNAME:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.classname", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -123,6 +125,7 @@ GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULELEMENT_STYLE:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.style", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -140,6 +143,7 @@ GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULELEMENT_DATABASE:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.database", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -157,6 +161,7 @@ GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULELEMENT_RESOURCE:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.resource", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -174,6 +179,7 @@ GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULELEMENT_CONTROLLER:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.controller", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -192,7 +198,6 @@ GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
@ -217,14 +222,14 @@ SetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULELEMENT_ID:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.id", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -239,6 +244,7 @@ SetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULELEMENT_CLASSNAME:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.classname", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -253,6 +259,7 @@ SetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULELEMENT_DATABASE:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.database", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -270,6 +277,7 @@ SetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULELEMENT_CONTROLLER:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.controller", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -288,7 +296,6 @@ SetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
@ -341,8 +348,8 @@ XULElementAddBroadcastListener(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -352,7 +359,6 @@ XULElementAddBroadcastListener(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -399,8 +405,8 @@ XULElementRemoveBroadcastListener(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -410,7 +416,6 @@ XULElementRemoveBroadcastListener(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -455,8 +460,8 @@ XULElementDoCommand(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -466,7 +471,6 @@ XULElementDoCommand(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -501,8 +505,8 @@ XULElementGetElementsByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -512,7 +516,6 @@ XULElementGetElementsByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMXULElement.h"
|
||||
@ -67,14 +68,14 @@ GetXULTreeElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULTREEELEMENT_SELECTEDITEMS:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xultreeelement.selecteditems", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -92,6 +93,7 @@ GetXULTreeElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULTREEELEMENT_SELECTEDCELLS:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xultreeelement.selectedcells", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -110,7 +112,6 @@ GetXULTreeElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
@ -135,9 +136,8 @@ SetXULTreeElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
@ -145,7 +145,6 @@ SetXULTreeElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
@ -197,8 +196,8 @@ XULTreeElementSelectItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -208,7 +207,6 @@ XULTreeElementSelectItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -253,8 +251,8 @@ XULTreeElementSelectCell(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -264,7 +262,6 @@ XULTreeElementSelectCell(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -308,8 +305,8 @@ XULTreeElementClearItemSelection(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -319,7 +316,6 @@ XULTreeElementClearItemSelection(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -351,8 +347,8 @@ XULTreeElementClearCellSelection(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -362,7 +358,6 @@ XULTreeElementClearCellSelection(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -395,8 +390,8 @@ XULTreeElementAddItemToSelection(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -406,7 +401,6 @@ XULTreeElementAddItemToSelection(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -451,8 +445,8 @@ XULTreeElementRemoveItemFromSelection(JSContext *cx, JSObject *obj, uintN argc,
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -462,7 +456,6 @@ XULTreeElementRemoveItemFromSelection(JSContext *cx, JSObject *obj, uintN argc,
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -507,8 +500,8 @@ XULTreeElementAddCellToSelection(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -518,7 +511,6 @@ XULTreeElementAddCellToSelection(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -563,8 +555,8 @@ XULTreeElementRemoveCellFromSelection(JSContext *cx, JSObject *obj, uintN argc,
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -574,7 +566,6 @@ XULTreeElementRemoveCellFromSelection(JSContext *cx, JSObject *obj, uintN argc,
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -619,8 +610,8 @@ XULTreeElementToggleItemSelection(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -630,7 +621,6 @@ XULTreeElementToggleItemSelection(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -675,8 +665,8 @@ XULTreeElementToggleCellSelection(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -686,7 +676,6 @@ XULTreeElementToggleCellSelection(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -732,8 +721,8 @@ XULTreeElementSelectItemRange(JSContext *cx, JSObject *obj, uintN argc, jsval *a
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -743,7 +732,6 @@ XULTreeElementSelectItemRange(JSContext *cx, JSObject *obj, uintN argc, jsval *a
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -796,8 +784,8 @@ XULTreeElementSelectCellRange(JSContext *cx, JSObject *obj, uintN argc, jsval *a
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -807,7 +795,6 @@ XULTreeElementSelectCellRange(JSContext *cx, JSObject *obj, uintN argc, jsval *a
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -858,8 +845,8 @@ XULTreeElementSelectAll(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -869,7 +856,6 @@ XULTreeElementSelectAll(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -901,8 +887,8 @@ XULTreeElementInvertSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *a
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -912,7 +898,6 @@ XULTreeElementInvertSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *a
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
|
@ -1,6 +1,4 @@
|
||||
nsIDOMXULCommandDispatcher.h
|
||||
nsIDOMElementObserver.h
|
||||
nsIDOMNodeObserver.h
|
||||
nsIDOMXULDocument.h
|
||||
nsIDOMXULElement.h
|
||||
nsIDOMXULTreeElement.h
|
||||
|
@ -25,8 +25,6 @@ include $(DEPTH)/config/autoconf.mk
|
||||
MODULE = rdf
|
||||
|
||||
EXPORTS = \
|
||||
nsIDOMElementObserver.h \
|
||||
nsIDOMNodeObserver.h \
|
||||
nsIDOMXULDocument.h \
|
||||
nsIDOMXULElement.h \
|
||||
nsIDOMXULTreeElement.h \
|
||||
|
@ -1,9 +0,0 @@
|
||||
interface ElementObserver {
|
||||
/* IID: { 0x17ddd8c2, 0xc5f8, 0x11d2, \
|
||||
{ 0xa6, 0xae, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } } */
|
||||
|
||||
void onSetAttribute(in Element element, in DOMString name, in DOMString value);
|
||||
void onRemoveAttribute(in Element element, in DOMString name);
|
||||
void onSetAttributeNode(in Element element, in Attr newAttr);
|
||||
void onRemoveAttributeNode(in Element element, in Attr oldAttr);
|
||||
};
|
@ -1,10 +0,0 @@
|
||||
interface NodeObserver {
|
||||
/* IID: { 0x3e969070, 0xc301, 0x11d2, \
|
||||
{ 0xa6, 0xae, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } } */
|
||||
|
||||
void onSetNodeValue(in Node node, in DOMString value);
|
||||
void onInsertBefore(in Node parent, in Node newChild, in Node refChild);
|
||||
void onReplaceChild(in Node parent, in Node newChild, in Node oldChild);
|
||||
void onRemoveChild(in Node parent, in Node oldChild);
|
||||
void onAppendChild(in Node parent, in Node newChild);
|
||||
};
|
@ -21,8 +21,6 @@ IGNORE_MANIFEST=1
|
||||
MODULE=rdf
|
||||
|
||||
IDLSRCS = \
|
||||
ElementObserver.idl \
|
||||
NodeObserver.idl \
|
||||
XULDocument.idl \
|
||||
XULElement.idl \
|
||||
XULCommandDispatcher.idl \
|
||||
|
@ -21,8 +21,6 @@ MODULE=rdf
|
||||
DEPTH=..\..\..
|
||||
|
||||
EXPORTS = \
|
||||
nsIDOMElementObserver.h \
|
||||
nsIDOMNodeObserver.h \
|
||||
nsIDOMXULDocument.h \
|
||||
nsIDOMXULElement.h \
|
||||
nsIDOMXULTreeElement.h \
|
||||
|
@ -1,67 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.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.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMElementObserver_h__
|
||||
#define nsIDOMElementObserver_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
class nsIDOMElement;
|
||||
class nsIDOMAttr;
|
||||
|
||||
#define NS_IDOMELEMENTOBSERVER_IID \
|
||||
{ 0x17ddd8c2, 0xc5f8, 0x11d2, \
|
||||
{ 0xa6, 0xae, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
|
||||
|
||||
class nsIDOMElementObserver : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMELEMENTOBSERVER_IID; return iid; }
|
||||
|
||||
NS_IMETHOD OnSetAttribute(nsIDOMElement* aElement, const nsString& aName, const nsString& aValue)=0;
|
||||
|
||||
NS_IMETHOD OnRemoveAttribute(nsIDOMElement* aElement, const nsString& aName)=0;
|
||||
|
||||
NS_IMETHOD OnSetAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aNewAttr)=0;
|
||||
|
||||
NS_IMETHOD OnRemoveAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aOldAttr)=0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DECL_IDOMELEMENTOBSERVER \
|
||||
NS_IMETHOD OnSetAttribute(nsIDOMElement* aElement, const nsString& aName, const nsString& aValue); \
|
||||
NS_IMETHOD OnRemoveAttribute(nsIDOMElement* aElement, const nsString& aName); \
|
||||
NS_IMETHOD OnSetAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aNewAttr); \
|
||||
NS_IMETHOD OnRemoveAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aOldAttr); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMELEMENTOBSERVER(_to) \
|
||||
NS_IMETHOD OnSetAttribute(nsIDOMElement* aElement, const nsString& aName, const nsString& aValue) { return _to OnSetAttribute(aElement, aName, aValue); } \
|
||||
NS_IMETHOD OnRemoveAttribute(nsIDOMElement* aElement, const nsString& aName) { return _to OnRemoveAttribute(aElement, aName); } \
|
||||
NS_IMETHOD OnSetAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aNewAttr) { return _to OnSetAttributeNode(aElement, aNewAttr); } \
|
||||
NS_IMETHOD OnRemoveAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aOldAttr) { return _to OnRemoveAttributeNode(aElement, aOldAttr); } \
|
||||
|
||||
|
||||
extern "C" NS_DOM nsresult NS_InitElementObserverClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptElementObserver(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMElementObserver_h__
|
@ -1,70 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.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.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMNodeObserver_h__
|
||||
#define nsIDOMNodeObserver_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
class nsIDOMNode;
|
||||
|
||||
#define NS_IDOMNODEOBSERVER_IID \
|
||||
{ 0x3e969070, 0xc301, 0x11d2, \
|
||||
{ 0xa6, 0xae, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
|
||||
|
||||
class nsIDOMNodeObserver : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMNODEOBSERVER_IID; return iid; }
|
||||
|
||||
NS_IMETHOD OnSetNodeValue(nsIDOMNode* aNode, const nsString& aValue)=0;
|
||||
|
||||
NS_IMETHOD OnInsertBefore(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aRefChild)=0;
|
||||
|
||||
NS_IMETHOD OnReplaceChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aOldChild)=0;
|
||||
|
||||
NS_IMETHOD OnRemoveChild(nsIDOMNode* aParent, nsIDOMNode* aOldChild)=0;
|
||||
|
||||
NS_IMETHOD OnAppendChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild)=0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DECL_IDOMNODEOBSERVER \
|
||||
NS_IMETHOD OnSetNodeValue(nsIDOMNode* aNode, const nsString& aValue); \
|
||||
NS_IMETHOD OnInsertBefore(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aRefChild); \
|
||||
NS_IMETHOD OnReplaceChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aOldChild); \
|
||||
NS_IMETHOD OnRemoveChild(nsIDOMNode* aParent, nsIDOMNode* aOldChild); \
|
||||
NS_IMETHOD OnAppendChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMNODEOBSERVER(_to) \
|
||||
NS_IMETHOD OnSetNodeValue(nsIDOMNode* aNode, const nsString& aValue) { return _to OnSetNodeValue(aNode, aValue); } \
|
||||
NS_IMETHOD OnInsertBefore(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aRefChild) { return _to OnInsertBefore(aParent, aNewChild, aRefChild); } \
|
||||
NS_IMETHOD OnReplaceChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aOldChild) { return _to OnReplaceChild(aParent, aNewChild, aOldChild); } \
|
||||
NS_IMETHOD OnRemoveChild(nsIDOMNode* aParent, nsIDOMNode* aOldChild) { return _to OnRemoveChild(aParent, aOldChild); } \
|
||||
NS_IMETHOD OnAppendChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild) { return _to OnAppendChild(aParent, aNewChild); } \
|
||||
|
||||
|
||||
extern "C" NS_DOM nsresult NS_InitNodeObserverClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptNodeObserver(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMNodeObserver_h__
|
@ -27,8 +27,6 @@ include $(topsrcdir)/config/config.mk
|
||||
LIBRARY_NAME = rdfcontent_s
|
||||
|
||||
CPPSRCS = \
|
||||
nsJSElementObserver.cpp \
|
||||
nsJSNodeObserver.cpp \
|
||||
nsJSXULDocument.cpp \
|
||||
nsJSXULElement.cpp \
|
||||
nsJSXULCommandDispatcher.cpp \
|
||||
|
@ -32,8 +32,6 @@ CPP_OBJS=\
|
||||
.\$(OBJDIR)\nsXULAttributes.obj \
|
||||
.\$(OBJDIR)\nsXULCommandDispatcher.obj \
|
||||
.\$(OBJDIR)\nsXULPopupListener.obj \
|
||||
.\$(OBJDIR)\nsJSElementObserver.obj \
|
||||
.\$(OBJDIR)\nsJSNodeObserver.obj \
|
||||
.\$(OBJDIR)\nsJSXULDocument.obj \
|
||||
.\$(OBJDIR)\nsJSXULElement.obj \
|
||||
.\$(OBJDIR)\nsJSXULTreeElement.obj \
|
||||
|
40
rdf/content/src/nsIRDFNodeList.h
Normal file
40
rdf/content/src/nsIRDFNodeList.h
Normal file
@ -0,0 +1,40 @@
|
||||
/* -*- 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 nsIRDFNodeList_h__
|
||||
#define nsIRDFNodeList_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
// {661D1971-5CD2-11d3-BE36-00104BDE6048}
|
||||
#define NS_IRDFNODELIST_IID \
|
||||
{ 0x661d1971, 0x5cd2, 0x11d3, { 0xbe, 0x36, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
|
||||
|
||||
class nsIRDFNodeList : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFNODELIST_IID; return iid; }
|
||||
|
||||
NS_IMETHOD AppendNode(nsIDOMNode* aNode) = 0;
|
||||
NS_IMETHOD RemoveNode(nsIDOMNode* aNode) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // nsIRDFNodeList_h__
|
||||
|
48
rdf/content/src/nsIXULContent.h
Normal file
48
rdf/content/src/nsIXULContent.h
Normal file
@ -0,0 +1,48 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Private interface to XUL content.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIXULContent_h__
|
||||
#define nsIXULContent_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
// {39C5ECC0-5C47-11d3-BE36-00104BDE6048}
|
||||
#define NS_IXULCONTENT_IID \
|
||||
{ 0x39c5ecc0, 0x5c47, 0x11d3, { 0xbe, 0x36, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
|
||||
|
||||
|
||||
class nsIXULContent : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IXULCONTENT_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Peek at a XUL element's child count without forcing children to be
|
||||
* instantiated.
|
||||
*/
|
||||
NS_IMETHOD PeekChildCount(PRInt32& aCount) const = 0;
|
||||
};
|
||||
|
||||
#endif // nsIXULContent_h__
|
44
rdf/content/src/nsIXULTreeContent.h
Normal file
44
rdf/content/src/nsIXULTreeContent.h
Normal file
@ -0,0 +1,44 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
A private interface to the tree element
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIXULTreeContent_h__
|
||||
#define nsIXULTreeContent_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
// {661D1970-5CD2-11d3-BE36-00104BDE6048}
|
||||
#define NS_IXULTREECONTENT_IID \
|
||||
{ 0x661d1970, 0x5cd2, 0x11d3, { 0xbe, 0x36, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
|
||||
|
||||
|
||||
class nsIXULTreeContent : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IXULTREECONTENT_IID; return iid; }
|
||||
|
||||
NS_IMETHOD FireOnSelectHandler() = 0;
|
||||
};
|
||||
|
||||
#endif // nsIXULTreeContent_h__
|
@ -1,539 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.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.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMElementObserver.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIAttrIID, NS_IDOMATTR_IID);
|
||||
static NS_DEFINE_IID(kIElementObserverIID, NS_IDOMELEMENTOBSERVER_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMElement);
|
||||
NS_DEF_PTR(nsIDOMAttr);
|
||||
NS_DEF_PTR(nsIDOMElementObserver);
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// ElementObserver Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetElementObserverProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMElementObserver *a = (nsIDOMElementObserver*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// ElementObserver Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetElementObserverProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMElementObserver *a = (nsIDOMElementObserver*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ElementObserver finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeElementObserver(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsJSUtils::nsGenericFinalize(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ElementObserver enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateElementObserver(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return nsJSUtils::nsGenericEnumerate(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ElementObserver resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveElementObserver(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
return nsJSUtils::nsGenericResolve(cx, obj, id);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method OnSetAttribute
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ElementObserverOnSetAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMElementObserver *nativeThis = (nsIDOMElementObserver*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMElementPtr b0;
|
||||
nsAutoString b1;
|
||||
nsAutoString b2;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "elementobserver.onsetattribute", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
if (argc < 3) {
|
||||
JS_ReportError(cx, "Function onSetAttribute requires 3 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kIElementIID,
|
||||
"Element",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
|
||||
nsJSUtils::nsConvertJSValToString(b2, cx, argv[2]);
|
||||
|
||||
if (NS_OK != nativeThis->OnSetAttribute(b0, b1, b2)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method OnRemoveAttribute
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ElementObserverOnRemoveAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMElementObserver *nativeThis = (nsIDOMElementObserver*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMElementPtr b0;
|
||||
nsAutoString b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "elementobserver.onremoveattribute", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
if (argc < 2) {
|
||||
JS_ReportError(cx, "Function onRemoveAttribute requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kIElementIID,
|
||||
"Element",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
|
||||
|
||||
if (NS_OK != nativeThis->OnRemoveAttribute(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method OnSetAttributeNode
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ElementObserverOnSetAttributeNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMElementObserver *nativeThis = (nsIDOMElementObserver*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMElementPtr b0;
|
||||
nsIDOMAttrPtr b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "elementobserver.onsetattributenode", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
if (argc < 2) {
|
||||
JS_ReportError(cx, "Function onSetAttributeNode requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kIElementIID,
|
||||
"Element",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kIAttrIID,
|
||||
"Attr",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->OnSetAttributeNode(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method OnRemoveAttributeNode
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ElementObserverOnRemoveAttributeNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMElementObserver *nativeThis = (nsIDOMElementObserver*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMElementPtr b0;
|
||||
nsIDOMAttrPtr b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "elementobserver.onremoveattributenode", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
if (argc < 2) {
|
||||
JS_ReportError(cx, "Function onRemoveAttributeNode requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kIElementIID,
|
||||
"Element",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kIAttrIID,
|
||||
"Attr",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->OnRemoveAttributeNode(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for ElementObserver
|
||||
//
|
||||
JSClass ElementObserverClass = {
|
||||
"ElementObserver",
|
||||
JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetElementObserverProperty,
|
||||
SetElementObserverProperty,
|
||||
EnumerateElementObserver,
|
||||
ResolveElementObserver,
|
||||
JS_ConvertStub,
|
||||
FinalizeElementObserver
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// ElementObserver class properties
|
||||
//
|
||||
static JSPropertySpec ElementObserverProperties[] =
|
||||
{
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// ElementObserver class methods
|
||||
//
|
||||
static JSFunctionSpec ElementObserverMethods[] =
|
||||
{
|
||||
{"onSetAttribute", ElementObserverOnSetAttribute, 3},
|
||||
{"onRemoveAttribute", ElementObserverOnRemoveAttribute, 2},
|
||||
{"onSetAttributeNode", ElementObserverOnSetAttributeNode, 2},
|
||||
{"onRemoveAttributeNode", ElementObserverOnRemoveAttributeNode, 2},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// ElementObserver constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ElementObserver(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ElementObserver class initialization
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_InitElementObserverClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = nsnull;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "ElementObserver", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp) ||
|
||||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
|
||||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp)) {
|
||||
|
||||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
parent_proto, // parent proto
|
||||
&ElementObserverClass, // JSClass
|
||||
ElementObserver, // JSNative ctor
|
||||
0, // ctor args
|
||||
ElementObserverProperties, // proto props
|
||||
ElementObserverMethods, // proto funcs
|
||||
nsnull, // ctor props (static)
|
||||
nsnull); // ctor funcs (static)
|
||||
if (nsnull == proto) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
|
||||
proto = JSVAL_TO_OBJECT(vp);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method for creating a new ElementObserver JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptElementObserver(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptElementObserver");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMElementObserver *aElementObserver;
|
||||
|
||||
if (nsnull == aParent) {
|
||||
parent = nsnull;
|
||||
}
|
||||
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
|
||||
NS_RELEASE(owner);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_OK != NS_InitElementObserverClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kIElementObserverIID, (void **)&aElementObserver);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &ElementObserverClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aElementObserver);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aElementObserver);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
@ -1,621 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.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.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeObserver.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kINodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kINodeObserverIID, NS_IDOMNODEOBSERVER_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMNode);
|
||||
NS_DEF_PTR(nsIDOMNodeObserver);
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// NodeObserver Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetNodeObserverProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMNodeObserver *a = (nsIDOMNodeObserver*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// NodeObserver Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetNodeObserverProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMNodeObserver *a = (nsIDOMNodeObserver*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// NodeObserver finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeNodeObserver(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsJSUtils::nsGenericFinalize(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// NodeObserver enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateNodeObserver(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return nsJSUtils::nsGenericEnumerate(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// NodeObserver resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveNodeObserver(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
return nsJSUtils::nsGenericResolve(cx, obj, id);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method OnSetNodeValue
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NodeObserverOnSetNodeValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeObserver *nativeThis = (nsIDOMNodeObserver*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMNodePtr b0;
|
||||
nsAutoString b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "nodeobserver.onsetnodevalue", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
if (argc < 2) {
|
||||
JS_ReportError(cx, "Function onSetNodeValue requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
|
||||
|
||||
if (NS_OK != nativeThis->OnSetNodeValue(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method OnInsertBefore
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NodeObserverOnInsertBefore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeObserver *nativeThis = (nsIDOMNodeObserver*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMNodePtr b0;
|
||||
nsIDOMNodePtr b1;
|
||||
nsIDOMNodePtr b2;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "nodeobserver.oninsertbefore", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
if (argc < 3) {
|
||||
JS_ReportError(cx, "Function onInsertBefore requires 3 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b2,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[2])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->OnInsertBefore(b0, b1, b2)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method OnReplaceChild
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NodeObserverOnReplaceChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeObserver *nativeThis = (nsIDOMNodeObserver*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMNodePtr b0;
|
||||
nsIDOMNodePtr b1;
|
||||
nsIDOMNodePtr b2;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "nodeobserver.onreplacechild", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
if (argc < 3) {
|
||||
JS_ReportError(cx, "Function onReplaceChild requires 3 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b2,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[2])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->OnReplaceChild(b0, b1, b2)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method OnRemoveChild
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NodeObserverOnRemoveChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeObserver *nativeThis = (nsIDOMNodeObserver*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMNodePtr b0;
|
||||
nsIDOMNodePtr b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "nodeobserver.onremovechild", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
if (argc < 2) {
|
||||
JS_ReportError(cx, "Function onRemoveChild requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->OnRemoveChild(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method OnAppendChild
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NodeObserverOnAppendChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeObserver *nativeThis = (nsIDOMNodeObserver*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMNodePtr b0;
|
||||
nsIDOMNodePtr b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "nodeobserver.onappendchild", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
if (argc < 2) {
|
||||
JS_ReportError(cx, "Function onAppendChild requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->OnAppendChild(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for NodeObserver
|
||||
//
|
||||
JSClass NodeObserverClass = {
|
||||
"NodeObserver",
|
||||
JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetNodeObserverProperty,
|
||||
SetNodeObserverProperty,
|
||||
EnumerateNodeObserver,
|
||||
ResolveNodeObserver,
|
||||
JS_ConvertStub,
|
||||
FinalizeNodeObserver
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// NodeObserver class properties
|
||||
//
|
||||
static JSPropertySpec NodeObserverProperties[] =
|
||||
{
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// NodeObserver class methods
|
||||
//
|
||||
static JSFunctionSpec NodeObserverMethods[] =
|
||||
{
|
||||
{"onSetNodeValue", NodeObserverOnSetNodeValue, 2},
|
||||
{"onInsertBefore", NodeObserverOnInsertBefore, 3},
|
||||
{"onReplaceChild", NodeObserverOnReplaceChild, 3},
|
||||
{"onRemoveChild", NodeObserverOnRemoveChild, 2},
|
||||
{"onAppendChild", NodeObserverOnAppendChild, 2},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// NodeObserver constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NodeObserver(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// NodeObserver class initialization
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_InitNodeObserverClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = nsnull;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "NodeObserver", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp) ||
|
||||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
|
||||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp)) {
|
||||
|
||||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
parent_proto, // parent proto
|
||||
&NodeObserverClass, // JSClass
|
||||
NodeObserver, // JSNative ctor
|
||||
0, // ctor args
|
||||
NodeObserverProperties, // proto props
|
||||
NodeObserverMethods, // proto funcs
|
||||
nsnull, // ctor props (static)
|
||||
nsnull); // ctor funcs (static)
|
||||
if (nsnull == proto) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
|
||||
proto = JSVAL_TO_OBJECT(vp);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method for creating a new NodeObserver JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptNodeObserver(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptNodeObserver");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMNodeObserver *aNodeObserver;
|
||||
|
||||
if (nsnull == aParent) {
|
||||
parent = nsnull;
|
||||
}
|
||||
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
|
||||
NS_RELEASE(owner);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_OK != NS_InitNodeObserverClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kINodeObserverIID, (void **)&aNodeObserver);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &NodeObserverClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aNodeObserver);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aNodeObserver);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
@ -25,6 +25,7 @@
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIController.h"
|
||||
@ -70,14 +71,14 @@ GetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *v
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULCOMMANDDISPATCHER_FOCUSEDELEMENT:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.focusedelement", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -95,6 +96,7 @@ GetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *v
|
||||
}
|
||||
case XULCOMMANDDISPATCHER_FOCUSEDWINDOW:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.focusedwindow", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -113,7 +115,6 @@ GetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *v
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
@ -138,14 +139,14 @@ SetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *v
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULCOMMANDDISPATCHER_FOCUSEDELEMENT:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.focusedelement", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -164,6 +165,7 @@ SetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *v
|
||||
}
|
||||
case XULCOMMANDDISPATCHER_FOCUSEDWINDOW:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.focusedwindow", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -183,7 +185,6 @@ SetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *v
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
@ -235,8 +236,8 @@ XULCommandDispatcherAddCommand(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -246,7 +247,6 @@ XULCommandDispatcherAddCommand(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -291,8 +291,8 @@ XULCommandDispatcherRemoveCommand(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -302,7 +302,6 @@ XULCommandDispatcherRemoveCommand(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -346,8 +345,8 @@ XULCommandDispatcherUpdateCommands(JSContext *cx, JSObject *obj, uintN argc, jsv
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -357,7 +356,6 @@ XULCommandDispatcherUpdateCommands(JSContext *cx, JSObject *obj, uintN argc, jsv
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -390,8 +388,8 @@ XULCommandDispatcherGetController(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -401,7 +399,6 @@ XULCommandDispatcherGetController(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -435,8 +432,8 @@ XULCommandDispatcherSetController(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -446,7 +443,6 @@ XULCommandDispatcherSetController(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMElement.h"
|
||||
@ -71,14 +72,14 @@ GetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULDOCUMENT_POPUPELEMENT:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xuldocument.popupelement", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -96,6 +97,7 @@ GetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULDOCUMENT_TOOLTIPELEMENT:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xuldocument.tooltipelement", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -113,6 +115,7 @@ GetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULDOCUMENT_COMMANDDISPATCHER:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xuldocument.commanddispatcher", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -131,7 +134,6 @@ GetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
@ -156,14 +158,14 @@ SetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULDOCUMENT_POPUPELEMENT:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xuldocument.popupelement", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -182,6 +184,7 @@ SetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULDOCUMENT_TOOLTIPELEMENT:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xuldocument.tooltipelement", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -201,7 +204,6 @@ SetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
@ -254,8 +256,8 @@ XULDocumentGetElementById(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -265,7 +267,6 @@ XULDocumentGetElementById(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -306,8 +307,8 @@ XULDocumentGetElementsByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -317,7 +318,6 @@ XULDocumentGetElementsByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIController.h"
|
||||
@ -83,14 +84,14 @@ GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULELEMENT_ID:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.id", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -107,6 +108,7 @@ GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULELEMENT_CLASSNAME:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.classname", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -123,6 +125,7 @@ GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULELEMENT_STYLE:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.style", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -140,6 +143,7 @@ GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULELEMENT_DATABASE:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.database", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -157,6 +161,7 @@ GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULELEMENT_RESOURCE:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.resource", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -174,6 +179,7 @@ GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULELEMENT_CONTROLLER:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.controller", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -192,7 +198,6 @@ GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
@ -217,14 +222,14 @@ SetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULELEMENT_ID:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.id", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -239,6 +244,7 @@ SetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULELEMENT_CLASSNAME:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.classname", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -253,6 +259,7 @@ SetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULELEMENT_DATABASE:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.database", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -270,6 +277,7 @@ SetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULELEMENT_CONTROLLER:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulelement.controller", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -288,7 +296,6 @@ SetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
@ -341,8 +348,8 @@ XULElementAddBroadcastListener(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -352,7 +359,6 @@ XULElementAddBroadcastListener(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -399,8 +405,8 @@ XULElementRemoveBroadcastListener(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -410,7 +416,6 @@ XULElementRemoveBroadcastListener(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -455,8 +460,8 @@ XULElementDoCommand(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -466,7 +471,6 @@ XULElementDoCommand(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -501,8 +505,8 @@ XULElementGetElementsByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -512,7 +516,6 @@ XULElementGetElementsByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMXULElement.h"
|
||||
@ -67,14 +68,14 @@ GetXULTreeElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULTREEELEMENT_SELECTEDITEMS:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xultreeelement.selecteditems", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -92,6 +93,7 @@ GetXULTreeElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
case XULTREEELEMENT_SELECTEDCELLS:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xultreeelement.selectedcells", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
@ -110,7 +112,6 @@ GetXULTreeElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
@ -135,9 +136,8 @@ SetXULTreeElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
@ -145,7 +145,6 @@ SetXULTreeElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
@ -197,8 +196,8 @@ XULTreeElementSelectItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -208,7 +207,6 @@ XULTreeElementSelectItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -253,8 +251,8 @@ XULTreeElementSelectCell(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -264,7 +262,6 @@ XULTreeElementSelectCell(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -308,8 +305,8 @@ XULTreeElementClearItemSelection(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -319,7 +316,6 @@ XULTreeElementClearItemSelection(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -351,8 +347,8 @@ XULTreeElementClearCellSelection(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -362,7 +358,6 @@ XULTreeElementClearCellSelection(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -395,8 +390,8 @@ XULTreeElementAddItemToSelection(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -406,7 +401,6 @@ XULTreeElementAddItemToSelection(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -451,8 +445,8 @@ XULTreeElementRemoveItemFromSelection(JSContext *cx, JSObject *obj, uintN argc,
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -462,7 +456,6 @@ XULTreeElementRemoveItemFromSelection(JSContext *cx, JSObject *obj, uintN argc,
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -507,8 +500,8 @@ XULTreeElementAddCellToSelection(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -518,7 +511,6 @@ XULTreeElementAddCellToSelection(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -563,8 +555,8 @@ XULTreeElementRemoveCellFromSelection(JSContext *cx, JSObject *obj, uintN argc,
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -574,7 +566,6 @@ XULTreeElementRemoveCellFromSelection(JSContext *cx, JSObject *obj, uintN argc,
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -619,8 +610,8 @@ XULTreeElementToggleItemSelection(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -630,7 +621,6 @@ XULTreeElementToggleItemSelection(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -675,8 +665,8 @@ XULTreeElementToggleCellSelection(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -686,7 +676,6 @@ XULTreeElementToggleCellSelection(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -732,8 +721,8 @@ XULTreeElementSelectItemRange(JSContext *cx, JSObject *obj, uintN argc, jsval *a
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -743,7 +732,6 @@ XULTreeElementSelectItemRange(JSContext *cx, JSObject *obj, uintN argc, jsval *a
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -796,8 +784,8 @@ XULTreeElementSelectCellRange(JSContext *cx, JSObject *obj, uintN argc, jsval *a
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -807,7 +795,6 @@ XULTreeElementSelectCellRange(JSContext *cx, JSObject *obj, uintN argc, jsval *a
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -858,8 +845,8 @@ XULTreeElementSelectAll(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -869,7 +856,6 @@ XULTreeElementSelectAll(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
@ -901,8 +887,8 @@ XULTreeElementInvertSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *a
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
@ -912,7 +898,6 @@ XULTreeElementInvertSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *a
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "nsIURL.h"
|
||||
#include "nsIXMLContent.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsNeckoUtil.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsRDFContentUtils.h"
|
||||
#include "nsString.h"
|
||||
@ -460,30 +461,59 @@ nsRDFContentUtils::MakeElementURI(nsIDocument* aDocument, const nsString& aEleme
|
||||
rv = aDocument->GetBaseURL(*getter_AddRefs(docURL));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
#ifdef NECKO
|
||||
char* spec;
|
||||
#else
|
||||
const char* spec;
|
||||
#endif
|
||||
docURL->GetSpec(&spec);
|
||||
// XXX Urgh. This is so broken; I'd really just like to use
|
||||
// NS_MakeAbsolueURI(). Unfortunatly, doing that breaks
|
||||
// MakeElementID in some cases that I haven't yet been able to
|
||||
// figure out.
|
||||
#define USE_BROKEN_RELATIVE_PARSING
|
||||
#ifdef USE_BROKEN_RELATIVE_PARSING
|
||||
nsXPIDLCString spec;
|
||||
docURL->GetSpec(getter_Copies(spec));
|
||||
if (! spec)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
aURI = spec;
|
||||
|
||||
#ifdef NECKO
|
||||
nsCRT::free(spec);
|
||||
#endif
|
||||
if (aElementID.First() != '#') {
|
||||
aURI += '#';
|
||||
}
|
||||
aURI += aElementID;
|
||||
#else
|
||||
nsXPIDLCString spec;
|
||||
rv = NS_MakeAbsoluteURI(nsCAutoString(aElementID), docURL, getter_Copies(spec));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aURI = spec;
|
||||
}
|
||||
else {
|
||||
NS_WARNING("MakeElementURI: NS_MakeAbsoluteURI failed");
|
||||
aURI = aElementID;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsRDFContentUtils::MakeElementResource(nsIDocument* aDocument, const nsString& aID, nsIRDFResource** aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCAutoString uri;
|
||||
rv = MakeElementURI(aDocument, aID, uri);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_WITH_SERVICE(nsIRDFService, rdf, kRDFServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = rdf->GetResource(uri, aResult);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsRDFContentUtils::MakeElementID(nsIDocument* aDocument, const nsString& aURI, nsString& aElementID)
|
||||
@ -496,25 +526,23 @@ nsRDFContentUtils::MakeElementID(nsIDocument* aDocument, const nsString& aURI, n
|
||||
rv = aDocument->GetBaseURL(*getter_AddRefs(docURL));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
#ifdef NECKO
|
||||
char* spec;
|
||||
#else
|
||||
const char* spec;
|
||||
#endif
|
||||
docURL->GetSpec(&spec);
|
||||
nsXPIDLCString spec;
|
||||
docURL->GetSpec(getter_Copies(spec));
|
||||
if (! spec)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (aURI.Find(spec) == 0) {
|
||||
#ifdef USE_BROKEN_RELATIVE_PARSING
|
||||
static const PRInt32 kFudge = 1; // XXX assume '#'
|
||||
#else
|
||||
static const PRInt32 kFudge = 0;
|
||||
#endif
|
||||
PRInt32 len = PL_strlen(spec);
|
||||
aURI.Right(aElementID, aURI.Length() - (len + 1)); // XXX assume '#'
|
||||
aURI.Right(aElementID, aURI.Length() - (len + kFudge));
|
||||
}
|
||||
else {
|
||||
aElementID = aURI;
|
||||
}
|
||||
#ifdef NECKO
|
||||
nsCRT::free(spec);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -73,6 +73,9 @@ public:
|
||||
static nsresult
|
||||
MakeElementURI(nsIDocument* aDocument, const nsString& aElementID, nsCString& aURI);
|
||||
|
||||
static nsresult
|
||||
MakeElementResource(nsIDocument* aDocument, const nsString& aElementID, nsIRDFResource** aResult);
|
||||
|
||||
static nsresult
|
||||
MakeElementID(nsIDocument* aDocument, const nsString& aURI, nsString& aElementID);
|
||||
|
||||
|
@ -101,18 +101,23 @@ static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(nsIDOMNodeList::GetIID()) ||
|
||||
if (aIID.Equals(nsCOMTypeInfo<nsIDOMNodeList>::GetIID()) ||
|
||||
aIID.Equals(kISupportsIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIDOMNodeList*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(nsCOMTypeInfo<nsIRDFNodeList>::GetIID())) {
|
||||
*aResult = NS_STATIC_CAST(nsIRDFNodeList*, this);
|
||||
}
|
||||
else if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIScriptObjectOwner*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
else {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@ -206,7 +211,7 @@ nsRDFDOMNodeList::Init(void)
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
NS_IMETHODIMP
|
||||
nsRDFDOMNodeList::AppendNode(nsIDOMNode* aNode)
|
||||
{
|
||||
NS_PRECONDITION(aNode != nsnull, "null ptr");
|
||||
@ -216,7 +221,7 @@ nsRDFDOMNodeList::AppendNode(nsIDOMNode* aNode)
|
||||
return mElements->AppendElement(aNode);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_IMETHODIMP
|
||||
nsRDFDOMNodeList::RemoveNode(nsIDOMNode* aNode)
|
||||
{
|
||||
NS_PRECONDITION(aNode != nsnull, "null ptr");
|
||||
|
@ -21,11 +21,13 @@
|
||||
#define nsRDFDOMNodeList_h__
|
||||
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIRDFNodeList.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
class nsIDOMNode;
|
||||
class nsISupportsArray;
|
||||
|
||||
class nsRDFDOMNodeList : public nsIDOMNodeList,
|
||||
public nsIRDFNodeList,
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
private:
|
||||
@ -51,8 +53,8 @@ public:
|
||||
NS_IMETHOD SetScriptObject(void* aScriptObject);
|
||||
|
||||
// Implementation methods
|
||||
nsresult AppendNode(nsIDOMNode* aNode);
|
||||
nsresult RemoveNode(nsIDOMNode* aNode);
|
||||
NS_IMETHOD AppendNode(nsIDOMNode* aNode);
|
||||
NS_IMETHOD RemoveNode(nsIDOMNode* aNode);
|
||||
};
|
||||
|
||||
#endif // nsRDFDOMNodeList_h__
|
||||
|
@ -41,10 +41,8 @@
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMElementObserver.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMNodeObserver.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsIDOMXULElement.h"
|
||||
#include "nsIDocument.h"
|
||||
@ -80,6 +78,7 @@
|
||||
#include "nsIFocusableContent.h"
|
||||
#include "nsIStyleRule.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIXULContent.h"
|
||||
#include "nsXULTreeElement.h"
|
||||
#include "rdfutil.h"
|
||||
#include "prlog.h"
|
||||
@ -227,6 +226,7 @@ class RDFElementImpl : public nsIDOMXULElement,
|
||||
public nsIJSScriptObject,
|
||||
public nsIStyledContent,
|
||||
public nsIXMLContent,
|
||||
public nsIXULContent,
|
||||
public nsIFocusableContent
|
||||
{
|
||||
public:
|
||||
@ -311,6 +311,9 @@ public:
|
||||
NS_IMETHOD GetNameSpacePrefix(nsIAtom*& aNameSpace) const;
|
||||
NS_IMETHOD SetNameSpaceID(PRInt32 aNameSpaceID);
|
||||
|
||||
// nsIXULContent
|
||||
NS_IMETHOD PeekChildCount(PRInt32& aCount) const;
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
|
||||
NS_IMETHOD RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
|
||||
@ -677,6 +680,9 @@ RDFElementImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
else if (iid.Equals(nsIXMLContent::GetIID())) {
|
||||
*result = NS_STATIC_CAST(nsIXMLContent*, this);
|
||||
}
|
||||
else if (iid.Equals(nsCOMTypeInfo<nsIXULContent>::GetIID())) {
|
||||
*result = NS_STATIC_CAST(nsIXULContent*, this);
|
||||
}
|
||||
else if (iid.Equals(nsIDOMXULElement::GetIID()) ||
|
||||
iid.Equals(kIDOMElementIID) ||
|
||||
iid.Equals(kIDOMNodeIID)) {
|
||||
@ -699,7 +705,8 @@ RDFElementImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
IsFocusableContent()) {
|
||||
*result = NS_STATIC_CAST(nsIFocusableContent*, this);
|
||||
}
|
||||
else if (iid.Equals(nsIDOMXULTreeElement::GetIID()) &&
|
||||
else if ((iid.Equals(nsIDOMXULTreeElement::GetIID()) ||
|
||||
iid.Equals(nsIXULTreeContent::GetIID())) &&
|
||||
(mNameSpaceID == kNameSpaceID_XUL) &&
|
||||
(mTag == kTreeAtom)) {
|
||||
// We delegate XULTreeElement APIs to an aggregate object
|
||||
@ -944,21 +951,68 @@ RDFElementImpl::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
NS_PRECONDITION(aNewChild != nsnull, "null ptr");
|
||||
if (! aNewChild)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// It's possible that mDocument will be null for an element that's
|
||||
// not in the content model (e.g., somebody is working on a
|
||||
// "scratch" element that has been removed from the content tree).
|
||||
if (mDocument) {
|
||||
nsIDOMNodeObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMNodeObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnInsertBefore(this, aNewChild, aRefChild);
|
||||
NS_RELEASE(obs);
|
||||
// aRefChild may be null; that means "append".
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIContent> newcontent = do_QueryInterface(aNewChild);
|
||||
NS_ASSERTION(newcontent != nsnull, "not an nsIContent");
|
||||
if (! newcontent)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
// First, check to see if the content was already parented
|
||||
// somewhere. If so, remove it.
|
||||
nsCOMPtr<nsIContent> oldparent;
|
||||
rv = newcontent->GetParent(*getter_AddRefs(oldparent));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (oldparent) {
|
||||
PRInt32 oldindex;
|
||||
rv = oldparent->IndexOf(newcontent, oldindex);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to determine index of aNewChild in old parent");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_ASSERTION(oldindex >= 0, "old parent didn't think aNewChild was a child");
|
||||
|
||||
if (oldindex >= 0) {
|
||||
rv = oldparent->RemoveChildAt(oldindex, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// Now, insert the element into the content model under 'this'
|
||||
if (aRefChild) {
|
||||
nsCOMPtr<nsIContent> refcontent = do_QueryInterface(aRefChild);
|
||||
NS_ASSERTION(refcontent != nsnull, "not an nsIContent");
|
||||
if (! refcontent)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
PRInt32 pos;
|
||||
rv = IndexOf(refcontent, pos);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to determine index of aRefChild");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (pos >= 0) {
|
||||
rv = InsertChildAt(newcontent, pos, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to insert aNewChild");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// XXX Hmm. There's a case here that we handle ambiguously, I
|
||||
// think. If aRefChild _isn't_ actually one of our kids, then
|
||||
// pos == -1, and we'll never insert the new kid. Should we
|
||||
// just append it?
|
||||
}
|
||||
else {
|
||||
rv = AppendChildTo(newcontent, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to append a aNewChild");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
NS_ADDREF(aNewChild);
|
||||
*aReturn = aNewChild;
|
||||
return NS_OK;
|
||||
@ -968,18 +1022,32 @@ RDFElementImpl::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDO
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
NS_PRECONDITION(aNewChild != nsnull, "null ptr");
|
||||
if (! aNewChild)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// It's possible that mDocument will be null for an element that's
|
||||
// not in the content model (e.g., somebody is working on a
|
||||
// "scratch" element that has been removed from the content tree).
|
||||
if (mDocument) {
|
||||
nsIDOMNodeObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMNodeObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnReplaceChild(this, aNewChild, aOldChild);
|
||||
NS_RELEASE(obs);
|
||||
NS_PRECONDITION(aOldChild != nsnull, "null ptr");
|
||||
if (! aOldChild)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIContent> oldelement = do_QueryInterface(aOldChild);
|
||||
NS_ASSERTION(oldelement != nsnull, "not an nsIContent");
|
||||
|
||||
if (oldelement) {
|
||||
PRInt32 pos;
|
||||
rv = IndexOf(oldelement, pos);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to determine index of aOldChild");
|
||||
|
||||
if (NS_SUCCEEDED(rv) && (pos >= 0)) {
|
||||
nsCOMPtr<nsIContent> newelement = do_QueryInterface(aNewChild);
|
||||
NS_ASSERTION(newelement != nsnull, "not an nsIContent");
|
||||
|
||||
if (newelement) {
|
||||
rv = ReplaceChildAt(newelement, pos, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to replace old child");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -992,18 +1060,23 @@ RDFElementImpl::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDO
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
NS_PRECONDITION(aOldChild != nsnull, "null ptr");
|
||||
if (! aOldChild)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// It's possible that mDocument will be null for an element that's
|
||||
// not in the content model (e.g., somebody is working on a
|
||||
// "scratch" element that has been removed from the content tree).
|
||||
if (mDocument) {
|
||||
nsIDOMNodeObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMNodeObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnRemoveChild(this, aOldChild);
|
||||
NS_RELEASE(obs);
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIContent> element = do_QueryInterface(aOldChild);
|
||||
NS_ASSERTION(element != nsnull, "not an nsIContent");
|
||||
|
||||
if (element) {
|
||||
PRInt32 pos;
|
||||
rv = IndexOf(element, pos);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to determine index of aOldChild");
|
||||
|
||||
if (NS_SUCCEEDED(rv) && (pos >= 0)) {
|
||||
rv = RemoveChildAt(pos, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to remove old child");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1016,24 +1089,7 @@ RDFElementImpl::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// It's possible that mDocument will be null for an element that's
|
||||
// not in the content model (e.g., somebody is working on a
|
||||
// "scratch" element that has been removed from the content tree).
|
||||
if (mDocument) {
|
||||
nsIDOMNodeObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMNodeObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnAppendChild(this, aNewChild);
|
||||
NS_RELEASE(obs);
|
||||
}
|
||||
}
|
||||
|
||||
NS_ADDREF(aNewChild);
|
||||
*aReturn = aNewChild;
|
||||
return NS_OK;
|
||||
return InsertBefore(aNewChild, nsnull, aReturn);
|
||||
}
|
||||
|
||||
|
||||
@ -1094,11 +1150,19 @@ RDFElementImpl::GetAttribute(const nsString& aName, nsString& aReturn)
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::SetAttribute(const nsString& aName, const nsString& aValue)
|
||||
{
|
||||
nsIDOMElementObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMElementObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnSetAttribute(this, aName, aValue);
|
||||
NS_RELEASE(obs);
|
||||
nsresult rv;
|
||||
|
||||
PRInt32 nameSpaceID;
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
|
||||
rv = ParseAttributeString(aName, *getter_AddRefs(tag), nameSpaceID);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to parse attribute name");
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = SetAttribute(nameSpaceID, tag, aValue, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set attribute");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1106,11 +1170,19 @@ RDFElementImpl::SetAttribute(const nsString& aName, const nsString& aValue)
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::RemoveAttribute(const nsString& aName)
|
||||
{
|
||||
nsIDOMElementObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMElementObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnRemoveAttribute(this, aName);
|
||||
NS_RELEASE(obs);
|
||||
nsresult rv;
|
||||
|
||||
PRInt32 nameSpaceID;
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
|
||||
rv = ParseAttributeString(aName, *getter_AddRefs(tag), nameSpaceID);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to parse attribute name");
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = UnsetAttribute(nameSpaceID, tag, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to remove attribute");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1142,15 +1214,12 @@ RDFElementImpl::GetAttributeNode(const nsString& aName, nsIDOMAttr** aReturn)
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::SetAttributeNode(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
NS_PRECONDITION(aNewAttr != nsnull, "null ptr");
|
||||
if (! aNewAttr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIDOMElementObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMElementObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnSetAttributeNode(this, aNewAttr);
|
||||
NS_RELEASE(obs);
|
||||
}
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
|
||||
NS_ADDREF(aNewAttr);
|
||||
*aReturn = aNewAttr;
|
||||
return NS_OK;
|
||||
@ -1160,15 +1229,12 @@ RDFElementImpl::SetAttributeNode(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn)
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::RemoveAttributeNode(nsIDOMAttr* aOldAttr, nsIDOMAttr** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
NS_PRECONDITION(aOldAttr != nsnull, "null ptr");
|
||||
if (! aOldAttr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIDOMElementObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMElementObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnRemoveAttributeNode(this, aOldAttr);
|
||||
NS_RELEASE(obs);
|
||||
}
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
|
||||
NS_ADDREF(aOldAttr);
|
||||
*aReturn = aOldAttr;
|
||||
return NS_OK;
|
||||
@ -1303,6 +1369,27 @@ RDFElementImpl::SetNameSpaceID(PRInt32 aNameSpaceID)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIXULContent interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::PeekChildCount(PRInt32& aCount) const
|
||||
{
|
||||
if (mChildren) {
|
||||
PRUint32 cnt;
|
||||
|
||||
nsresult rv;
|
||||
rv = mChildren->Count(&cnt);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
aCount = PRInt32(cnt);
|
||||
}
|
||||
else {
|
||||
aCount = 0;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIDOMEventReceiver interface
|
||||
@ -1718,15 +1805,7 @@ RDFElementImpl::ChildCount(PRInt32& aResult) const
|
||||
if (NS_FAILED(rv = EnsureContentsGenerated()))
|
||||
return rv;
|
||||
|
||||
if (mChildren) {
|
||||
PRUint32 cnt;
|
||||
rv = mChildren->Count(&cnt);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
aResult = cnt;
|
||||
}
|
||||
else
|
||||
aResult = 0;
|
||||
return NS_OK;
|
||||
return PeekChildCount(aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1824,14 +1903,6 @@ RDFElementImpl::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify)
|
||||
if (oldKid.get() == aKid)
|
||||
return NS_OK;
|
||||
|
||||
// Make sure that we're not trying to insert the same child
|
||||
// twice. If we do, the DOM APIs (e.g., GetNextSibling()), will
|
||||
// freak out.
|
||||
PRInt32 i = mChildren->IndexOf(aKid);
|
||||
NS_ASSERTION(i < 0, "element is already a child");
|
||||
if (i >= 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRBool replaceOk = mChildren->ReplaceElementAt(aKid, aIndex);
|
||||
if (replaceOk) {
|
||||
aKid->SetParent(NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
@ -1859,14 +1930,6 @@ RDFElementImpl::AppendChildTo(nsIContent* aKid, PRBool aNotify)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// Make sure that we're not trying to insert the same child
|
||||
// twice. If we do, the DOM APIs (e.g., GetNextSibling()), will
|
||||
// freak out.
|
||||
PRInt32 i = mChildren->IndexOf(aKid);
|
||||
NS_ASSERTION(i < 0, "element is already a child");
|
||||
if (i >= 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRBool appendOk = mChildren->AppendElement(aKid);
|
||||
if (appendOk) {
|
||||
aKid->SetParent(NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
@ -1913,16 +1976,12 @@ RDFElementImpl::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
// This is the nasty case. We have (potentially) a slew of selected items
|
||||
// and cells going away.
|
||||
// First, retrieve the tree.
|
||||
nsRDFDOMNodeList* itemList = nsnull;
|
||||
nsRDFDOMNodeList* cellList = nsnull;
|
||||
nsCOMPtr<nsIDOMXULTreeElement> treeElement;
|
||||
GetParentTree(getter_AddRefs(treeElement));
|
||||
rv = GetParentTree(getter_AddRefs(treeElement));
|
||||
if (treeElement) {
|
||||
nsCOMPtr<nsIDOMNodeList> nodes;
|
||||
treeElement->GetSelectedItems(getter_AddRefs(nodes));
|
||||
itemList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar.
|
||||
treeElement->GetSelectedCells(getter_AddRefs(nodes));
|
||||
cellList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar.
|
||||
nsCOMPtr<nsIDOMNodeList> itemList;
|
||||
treeElement->GetSelectedItems(getter_AddRefs(itemList));
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parentKid = do_QueryInterface(oldKid);
|
||||
PRBool fireSelectionHandler = PR_FALSE;
|
||||
if (itemList) {
|
||||
@ -1942,6 +2001,10 @@ RDFElementImpl::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNodeList> cellList;
|
||||
treeElement->GetSelectedCells(getter_AddRefs(cellList));
|
||||
|
||||
if (cellList) {
|
||||
// Iterate over all of the items and find out if they are contained inside
|
||||
// the removed subtree.
|
||||
@ -1961,8 +2024,10 @@ RDFElementImpl::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
}
|
||||
|
||||
if (fireSelectionHandler) {
|
||||
nsXULTreeElement* tree = (nsXULTreeElement*)(treeElement.get()); // XXX Yes, I am evil.
|
||||
tree->FireOnSelectHandler();
|
||||
nsCOMPtr<nsIXULTreeContent> tree = do_QueryInterface(treeElement);
|
||||
if (tree) {
|
||||
tree->FireOnSelectHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2131,14 +2196,14 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
|
||||
GetTag(*getter_AddRefs(tag));
|
||||
if (mDocument && (aNameSpaceID == kNameSpaceID_None)) {
|
||||
// See if we're a treeitem atom.
|
||||
nsRDFDOMNodeList* nodeList = nsnull;
|
||||
nsCOMPtr<nsIRDFNodeList> nodeList;
|
||||
if (tag && (tag.get() == kTreeItemAtom) && (aName == kSelectedAtom)) {
|
||||
nsCOMPtr<nsIDOMXULTreeElement> treeElement;
|
||||
GetParentTree(getter_AddRefs(treeElement));
|
||||
if (treeElement) {
|
||||
nsCOMPtr<nsIDOMNodeList> nodes;
|
||||
treeElement->GetSelectedItems(getter_AddRefs(nodes));
|
||||
nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar.
|
||||
nodeList = do_QueryInterface(nodes);
|
||||
}
|
||||
}
|
||||
else if (tag && (tag.get() == kTreeCellAtom) && (aName == kSelectedAtom)) {
|
||||
@ -2147,7 +2212,7 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
|
||||
if (treeElement) {
|
||||
nsCOMPtr<nsIDOMNodeList> nodes;
|
||||
treeElement->GetSelectedCells(getter_AddRefs(nodes));
|
||||
nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar.
|
||||
nodeList = do_QueryInterface(nodes);
|
||||
}
|
||||
}
|
||||
if (nodeList) {
|
||||
@ -2193,18 +2258,23 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
|
||||
// Check to see if the REF attribute is being set. If so, we need
|
||||
// to update the element map. First, remove the old mapping, if
|
||||
// necessary...
|
||||
if (mDocument && (aNameSpaceID == kNameSpaceID_None) && (aName == kRefAtom)) {
|
||||
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
|
||||
if (rdfdoc) {
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
|
||||
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
|
||||
if (rdfdoc && (aNameSpaceID == kNameSpaceID_None)) {
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
if (aName == kRefAtom) {
|
||||
GetRefResource(getter_AddRefs(resource));
|
||||
if (resource) {
|
||||
rdfdoc->RemoveElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
}
|
||||
}
|
||||
else if (aName == kIdAtom) {
|
||||
GetIdResource(getter_AddRefs(resource));
|
||||
}
|
||||
|
||||
if (resource) {
|
||||
rdfdoc->RemoveElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// XXX need to check if they're changing an event handler: if so, then we need
|
||||
// to unhook the old one.
|
||||
|
||||
@ -2231,15 +2301,17 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
|
||||
|
||||
// Check for REF attribute, part deux. Add the new REF to the map,
|
||||
// if appropriate.
|
||||
if (mDocument && (aNameSpaceID == kNameSpaceID_None) && (aName == kRefAtom)) {
|
||||
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
|
||||
if (rdfdoc) {
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
|
||||
if (rdfdoc && (aNameSpaceID == kNameSpaceID_None)) {
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
if (aName == kRefAtom) {
|
||||
GetRefResource(getter_AddRefs(resource));
|
||||
if (resource) {
|
||||
rdfdoc->AddElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
}
|
||||
}
|
||||
else if (aName == kIdAtom) {
|
||||
GetIdResource(getter_AddRefs(resource));
|
||||
}
|
||||
|
||||
if (resource) {
|
||||
rdfdoc->AddElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2374,6 +2446,7 @@ RDFElementImpl::GetAttribute(PRInt32 aNameSpaceID,
|
||||
else {
|
||||
rv = NS_CONTENT_ATTR_NO_VALUE;
|
||||
}
|
||||
#if 0
|
||||
if ((aNameSpaceID == kNameSpaceID_None) &&
|
||||
(attr->mName == kIdAtom))
|
||||
{
|
||||
@ -2384,6 +2457,7 @@ RDFElementImpl::GetAttribute(PRInt32 aNameSpaceID,
|
||||
nsRDFContentUtils::MakeElementID(mDocument, attr->mValue, aResult);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2427,14 +2501,14 @@ RDFElementImpl::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNot
|
||||
// doing it anyway. Need to make an nsIRDFNodeList interface that
|
||||
// I can QI to for additions and removals of nodes. For now
|
||||
// do an evil cast.
|
||||
nsRDFDOMNodeList* nodeList = nsnull;
|
||||
nsCOMPtr<nsIRDFNodeList> nodeList;
|
||||
if (tag && (tag.get() == kTreeItemAtom) && (aName == kSelectedAtom)) {
|
||||
nsCOMPtr<nsIDOMXULTreeElement> treeElement;
|
||||
GetParentTree(getter_AddRefs(treeElement));
|
||||
if (treeElement) {
|
||||
nsCOMPtr<nsIDOMNodeList> nodes;
|
||||
treeElement->GetSelectedItems(getter_AddRefs(nodes));
|
||||
nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar.
|
||||
nodeList = do_QueryInterface(nodes);
|
||||
}
|
||||
}
|
||||
else if (tag && (tag.get() == kTreeCellAtom) && (aName == kSelectedAtom)) {
|
||||
@ -2443,7 +2517,7 @@ RDFElementImpl::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNot
|
||||
if (treeElement) {
|
||||
nsCOMPtr<nsIDOMNodeList> nodes;
|
||||
treeElement->GetSelectedCells(getter_AddRefs(nodes));
|
||||
nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar.
|
||||
nodeList = do_QueryInterface(nodes);
|
||||
}
|
||||
}
|
||||
if (nodeList) {
|
||||
@ -2944,7 +3018,7 @@ RDFElementImpl::GetIdResource(nsIRDFResource** aResource)
|
||||
const nsXULAttribute* attr = (const nsXULAttribute*) mAttributes->ElementAt(i);
|
||||
if ((attr->mNameSpaceID == kNameSpaceID_None) &&
|
||||
(attr->mName == kIdAtom)) {
|
||||
return gRDFService->GetUnicodeResource(attr->mValue.GetUnicode(), aResource);
|
||||
return nsRDFContentUtils::MakeElementResource(mDocument, attr->mValue.GetUnicode(), aResource);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2970,7 +3044,7 @@ RDFElementImpl::GetRefResource(nsIRDFResource** aResource)
|
||||
|
||||
if (attr->mName != kRefAtom)
|
||||
continue;
|
||||
|
||||
#if 0
|
||||
// Found it!
|
||||
nsresult rv;
|
||||
|
||||
@ -2983,6 +3057,9 @@ RDFElementImpl::GetRefResource(nsIRDFResource** aResource)
|
||||
|
||||
// ...then, setup the new mapping.
|
||||
return gRDFService->GetUnicodeResource(uri.GetUnicode(), aResource);
|
||||
#else
|
||||
return nsRDFContentUtils::MakeElementResource(mDocument, attr->mValue.GetUnicode(), aResource);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,9 +39,7 @@
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMElementObserver.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeObserver.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
@ -390,12 +388,6 @@ RDFGenericBuilderImpl::QueryInterface(REFNSIID iid, void** aResult)
|
||||
else if (iid.Equals(kIRDFObserverIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIRDFObserver*, this);
|
||||
}
|
||||
else if (iid.Equals(nsIDOMNodeObserver::GetIID())) {
|
||||
*aResult = NS_STATIC_CAST(nsIDOMNodeObserver*, this);
|
||||
}
|
||||
else if (iid.Equals(nsIDOMElementObserver::GetIID())) {
|
||||
*aResult = NS_STATIC_CAST(nsIDOMElementObserver*, this);
|
||||
}
|
||||
else {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
@ -539,22 +531,38 @@ RDFGenericBuilderImpl::CreateElement(PRInt32 aNameSpaceID,
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> doc( do_QueryInterface(mDocument) );
|
||||
|
||||
if (aResource) {
|
||||
const char *uri;
|
||||
const char *uri;
|
||||
rv = aResource->GetValueConst(&uri);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource URI");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = result->SetAttribute(kNameSpaceID_None, kIdAtom, (const char*) uri, PR_FALSE);
|
||||
nsAutoString id;
|
||||
rv = nsRDFContentUtils::MakeElementID(doc, nsAutoString(uri), id);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = result->SetAttribute(kNameSpaceID_None, kIdAtom, id, PR_FALSE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set id attribute");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> doc( do_QueryInterface(mDocument) );
|
||||
rv = result->SetDocument(doc, PR_FALSE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set element's document");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (aResource && aNameSpaceID == kNameSpaceID_HTML) {
|
||||
// If this is an HTML element, then explicitly add it to the
|
||||
// map. (XUL elements don't have to do this because their
|
||||
// SetDocument() call does the magic.) Don't worry: the
|
||||
// document observer methods are on the lookout to update the
|
||||
// map for "attribute changed" calls that monkey with the 'id'
|
||||
// or 'ref' parameters.
|
||||
rv = mDocument->AddElementForResource(aResource, result);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
*aResult = result;
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
@ -628,15 +636,17 @@ RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource,
|
||||
// child to this node.
|
||||
|
||||
// XXX Bug 10818.
|
||||
PRBool notify;
|
||||
if (IsTreeWidgetItem(element) && !IsReflowScheduled()) {
|
||||
notify = PR_TRUE;
|
||||
|
||||
rv = ScheduleReflow();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else {
|
||||
notify = PR_FALSE;
|
||||
PRBool notify = PR_TRUE;
|
||||
if (IsTreeWidgetItem(element)) {
|
||||
if (!IsReflowScheduled()) {
|
||||
rv = ScheduleReflow();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else {
|
||||
// a reflow has been scheduled. we'll add the
|
||||
// element but won't notify right now.
|
||||
notify = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
rv = CreateWidgetItem(element, aProperty, resource, 0, notify);
|
||||
@ -676,9 +686,6 @@ RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource,
|
||||
// this node was created by a XUL template, so update it accordingly
|
||||
rv = SynchronizeUsingTemplate(templateNode, element, eSet, aProperty, aTarget);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PersistProperty(element, aProperty, aTarget, eSet);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -790,9 +797,6 @@ RDFGenericBuilderImpl::OnUnassert(nsIRDFResource* aSource,
|
||||
// this node was created by a XUL template, so update it accordingly
|
||||
rv = SynchronizeUsingTemplate(templateNode, element, eClear, aProperty, aTarget);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PersistProperty(element, aProperty, aTarget, eClear);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -907,9 +911,6 @@ RDFGenericBuilderImpl::OnChange(nsIRDFResource* aSource,
|
||||
// this node was created by a XUL template, so update it accordingly
|
||||
rv = SynchronizeUsingTemplate(templateNode, element, eSet, aProperty, aNewTarget);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PersistProperty(element, aProperty, aNewTarget, eSet);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -928,55 +929,7 @@ RDFGenericBuilderImpl::OnMove(nsIRDFResource* aOldSource,
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIDOMNodeObserver interface
|
||||
//
|
||||
// XXX Any of these methods that can't be implemented in a generic
|
||||
// way should become pure virtual on this class.
|
||||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnSetNodeValue(nsIDOMNode* aNode, const nsString& aValue)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnInsertBefore(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aRefChild)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnReplaceChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aOldChild)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnRemoveChild(nsIDOMNode* aParent, nsIDOMNode* aOldChild)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnAppendChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIDOMElementObserver interface
|
||||
|
||||
|
||||
#if 0
|
||||
PRBool
|
||||
RDFGenericBuilderImpl::IsAttributePersisent(nsIContent *element, PRInt32 aNameSpaceID, nsIAtom *aAtom)
|
||||
{
|
||||
@ -1151,361 +1104,7 @@ RDFGenericBuilderImpl::PersistProperty(nsIContent *element, nsIRDFResource *aPro
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnSetAttribute(nsIDOMElement* aElement, const nsString& aName, const nsString& aValue)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
if (NS_FAILED(rv = GetDOMNodeResource(aElement, getter_AddRefs(resource)))) {
|
||||
// XXX it's not a resource element, so there's no assertions
|
||||
// we need to make on the back-end. Should we just do the
|
||||
// update?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get the nsIContent interface, it's a bit more utilitarian
|
||||
nsCOMPtr<nsIContent> element( do_QueryInterface(aElement) );
|
||||
if (! element) {
|
||||
NS_ERROR("element doesn't support nsIContent");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// Make sure that the element is in the widget. XXX Even this may be
|
||||
// a bit too promiscuous: an element may also be a XUL element...
|
||||
if (!IsElementInWidget(element))
|
||||
return NS_OK;
|
||||
|
||||
// Split the element into its namespace and tag components
|
||||
PRInt32 elementNameSpaceID;
|
||||
if (NS_FAILED(rv = element->GetNameSpaceID(elementNameSpaceID))) {
|
||||
NS_ERROR("unable to get element namespace ID");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> elementNameAtom;
|
||||
if (NS_FAILED(rv = element->GetTag( *getter_AddRefs(elementNameAtom) ))) {
|
||||
NS_ERROR("unable to get element tag");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Split the property name into its namespace and tag components
|
||||
PRInt32 attrNameSpaceID;
|
||||
nsCOMPtr<nsIAtom> attrNameAtom;
|
||||
if (NS_FAILED(rv = element->ParseAttributeString(aName, *getter_AddRefs(attrNameAtom), attrNameSpaceID))) {
|
||||
NS_ERROR("unable to parse attribute string");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Now do the work to change the attribute. There are a couple of
|
||||
// special cases that we need to check for here...
|
||||
if ((elementNameSpaceID == kNameSpaceID_XUL) &&
|
||||
IsResourceElement(element) && // XXX IsResourceElement(): is this what we really mean?
|
||||
(attrNameSpaceID == kNameSpaceID_None) &&
|
||||
(attrNameAtom.get() == kOpenAtom)) {
|
||||
|
||||
// We are (possibly) changing the value of the "open"
|
||||
// attribute. This may require us to generate or destroy
|
||||
// content in the widget. See what the old value was...
|
||||
nsAutoString attrValue;
|
||||
if (NS_FAILED(rv = element->GetAttribute(kNameSpaceID_None, kOpenAtom, attrValue))) {
|
||||
NS_ERROR("unable to get current open state");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if ((rv == NS_CONTENT_ATTR_NO_VALUE) || (rv == NS_CONTENT_ATTR_NOT_THERE) ||
|
||||
((rv == NS_CONTENT_ATTR_HAS_VALUE) && (! attrValue.EqualsIgnoreCase(aValue))) ||
|
||||
PR_TRUE // XXX just always allow this to fire.
|
||||
) {
|
||||
// Okay, it's really changing.
|
||||
|
||||
// This is a "transient" property, so we _don't_ go to the
|
||||
// RDF graph to set it.
|
||||
if (NS_FAILED(rv = element->SetAttribute(kNameSpaceID_None, kOpenAtom, aValue, PR_TRUE))) {
|
||||
NS_ERROR("unable to update attribute on content node");
|
||||
return rv;
|
||||
}
|
||||
|
||||
PersistAttribute(element, kNameSpaceID_None, kOpenAtom, aValue, eSet);
|
||||
|
||||
if (aValue.EqualsIgnoreCase("true")) {
|
||||
rv = OpenWidgetItem(element);
|
||||
}
|
||||
else {
|
||||
rv = CloseWidgetItem(element);
|
||||
}
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to open/close tree item");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else if ((elementNameSpaceID == kNameSpaceID_XUL) &&
|
||||
(IsResourceElement(element)) &&
|
||||
(attrNameSpaceID == kNameSpaceID_None) &&
|
||||
(attrNameAtom.get() == kIdAtom)) {
|
||||
|
||||
// We are (possibly) changing the actual identity of the
|
||||
// element; e.g., re-rooting an item in the tree.
|
||||
|
||||
nsCOMPtr<nsIRDFResource> newResource;
|
||||
if (NS_FAILED(rv = gRDFService->GetUnicodeResource(aValue.GetUnicode(), getter_AddRefs(newResource)))) {
|
||||
NS_ERROR("unable to get new resource");
|
||||
return rv;
|
||||
}
|
||||
|
||||
#if 0 // XXX we're fighting with the XUL builder, so just _always_ let this through.
|
||||
// Didn't change. So bail!
|
||||
if (resource == newResource)
|
||||
return NS_OK;
|
||||
#endif
|
||||
|
||||
// Allright, it really is changing. So blow away the old
|
||||
// content node and insert a new one with the new ID in
|
||||
// its place.
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
if (NS_FAILED(rv = element->GetParent(*getter_AddRefs(parent)))) {
|
||||
NS_ERROR("unable to get element's parent");
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRInt32 elementIndex;
|
||||
if (NS_FAILED(rv = parent->IndexOf(element, elementIndex))) {
|
||||
NS_ERROR("unable to get element's index within parent");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (! parent)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
if (NS_FAILED(rv = parent->RemoveChildAt(elementIndex, PR_TRUE))) {
|
||||
NS_ERROR("unable to remove element");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> newElement;
|
||||
if (NS_FAILED(rv = CreateElement(elementNameSpaceID,
|
||||
elementNameAtom,
|
||||
newResource,
|
||||
getter_AddRefs(newElement)))) {
|
||||
NS_ERROR("unable to create new element");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Attach transient properties to the new element.
|
||||
//
|
||||
// XXX all I really care about right this minute is the
|
||||
// "open" state. We could put this stuff in a table and
|
||||
// drive it that way.
|
||||
nsAutoString attrValue;
|
||||
if (NS_FAILED(rv = element->GetAttribute(kNameSpaceID_None, kOpenAtom, attrValue))) {
|
||||
NS_ERROR("unable to get open state of old element");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
|
||||
if (NS_FAILED(rv = newElement->SetAttribute(kNameSpaceID_None, kOpenAtom, attrValue, PR_FALSE))) {
|
||||
NS_ERROR("unable to set open state of new element");
|
||||
return rv;
|
||||
}
|
||||
|
||||
PersistAttribute(newElement, kNameSpaceID_None, kOpenAtom, attrValue, eSet);
|
||||
|
||||
}
|
||||
|
||||
// Mark as a container so the contents get regenerated
|
||||
if (NS_FAILED(rv = newElement->SetAttribute(kNameSpaceID_None,
|
||||
kLazyContentAtom,
|
||||
"true",
|
||||
PR_FALSE))) {
|
||||
NS_ERROR("unable to mark as a container");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Now insert the new element into the parent. This should
|
||||
// trigger a reflow and cause the contents to be regenerated.
|
||||
if (NS_FAILED(rv = parent->InsertChildAt(newElement, elementIndex, PR_TRUE))) {
|
||||
NS_ERROR("unable to add new element to the parent");
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
else if ((attrNameSpaceID == kNameSpaceID_None) &&
|
||||
(attrNameAtom.get() == kRefAtom)) {
|
||||
// Remove all of the template children and rebuild them
|
||||
rv = RemoveAndRebuildGeneratedChildren(element);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// If we get here, it's a "vanilla" property: push its value into the graph.
|
||||
if (kNameSpaceID_Unknown == attrNameSpaceID) {
|
||||
attrNameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
|
||||
}
|
||||
nsCOMPtr<nsIRDFResource> property;
|
||||
if (NS_FAILED(rv = GetResource(attrNameSpaceID, attrNameAtom, getter_AddRefs(property)))) {
|
||||
NS_ERROR("unable to construct resource");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Get the old value, if there was one.
|
||||
nsAutoString oldValueStr;
|
||||
rv = element->GetAttribute(attrNameSpaceID, attrNameAtom, oldValueStr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> oldvalue;
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == rv) {
|
||||
rv = gRDFService->GetLiteral(oldValueStr.GetUnicode(), getter_AddRefs(oldvalue));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to construct literal");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// Get the new value
|
||||
nsCOMPtr<nsIRDFLiteral> newvalue;
|
||||
rv = gRDFService->GetLiteral(aValue.GetUnicode(), getter_AddRefs(newvalue));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to construct literal");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (oldvalue) {
|
||||
rv = mDB->Change(resource, property, oldvalue, newvalue);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else {
|
||||
rv = mDB->Assert(resource, property, newvalue, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
if (rv == NS_RDF_ASSERTION_REJECTED) {
|
||||
// Okay, just force the attribute to be set.
|
||||
rv = element->SetAttribute(attrNameSpaceID, attrNameAtom, aValue, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnRemoveAttribute(nsIDOMElement* aElement, const nsString& aName)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
if (NS_FAILED(rv = GetDOMNodeResource(aElement, getter_AddRefs(resource)))) {
|
||||
// XXX it's not a resource element, so there's no assertions
|
||||
// we need to make on the back-end. Should we just do the
|
||||
// update?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get the nsIContent interface, it's a bit more utilitarian
|
||||
nsCOMPtr<nsIContent> element( do_QueryInterface(aElement) );
|
||||
if (! element) {
|
||||
NS_ERROR("element doesn't support nsIContent");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// Make sure that the element is in the widget. XXX Even this may be
|
||||
// a bit too promiscuous: an element may also be a XUL element...
|
||||
if (!IsElementInWidget(element))
|
||||
return NS_OK;
|
||||
|
||||
// Split the element into its namespace and tag components
|
||||
PRInt32 elementNameSpaceID;
|
||||
if (NS_FAILED(rv = element->GetNameSpaceID(elementNameSpaceID))) {
|
||||
NS_ERROR("unable to get element namespace ID");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> elementNameAtom;
|
||||
if (NS_FAILED(rv = element->GetTag( *getter_AddRefs(elementNameAtom) ))) {
|
||||
NS_ERROR("unable to get element tag");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Split the property name into its namespace and tag components
|
||||
PRInt32 attrNameSpaceID;
|
||||
nsCOMPtr<nsIAtom> attrNameAtom;
|
||||
if (NS_FAILED(rv = element->ParseAttributeString(aName, *getter_AddRefs(attrNameAtom), attrNameSpaceID))) {
|
||||
NS_ERROR("unable to parse attribute string");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if ((elementNameSpaceID == kNameSpaceID_XUL) &&
|
||||
IsResourceElement(element) && // XXX Is this what we really mean?
|
||||
(attrNameSpaceID == kNameSpaceID_None) &&
|
||||
(attrNameAtom.get() == kOpenAtom)) {
|
||||
// We are removing the value of the "open" attribute. This may
|
||||
// require us to destroy content from the tree.
|
||||
|
||||
|
||||
nsAutoString openVal;
|
||||
if (NS_FAILED(rv = element->GetAttribute(kNameSpaceID_None, kOpenAtom, openVal))) {
|
||||
NS_ERROR("unable to get open attribute on update content node");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// XXX should we check for existence of the attribute first?
|
||||
if (NS_FAILED(rv = element->UnsetAttribute(kNameSpaceID_None, kOpenAtom, PR_TRUE))) {
|
||||
NS_ERROR("unable to attribute on update content node");
|
||||
return rv;
|
||||
}
|
||||
|
||||
PersistAttribute(element, kNameSpaceID_None, kOpenAtom, openVal, eClear);
|
||||
|
||||
if (NS_FAILED(rv = CloseWidgetItem(element))) {
|
||||
NS_ERROR("unable to close widget item");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else if ((attrNameSpaceID == kNameSpaceID_None) &&
|
||||
(attrNameAtom.get() == kRefAtom)) {
|
||||
// Ignore changes to the 'ref=' attribute; the XUL builder
|
||||
// will take care of that for us.
|
||||
}
|
||||
else {
|
||||
// It's a "vanilla" property: push its value into the graph.
|
||||
|
||||
nsCOMPtr<nsIRDFResource> property;
|
||||
if (kNameSpaceID_Unknown == attrNameSpaceID) {
|
||||
attrNameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
|
||||
}
|
||||
if (NS_FAILED(rv = GetResource(attrNameSpaceID, attrNameAtom, getter_AddRefs(property)))) {
|
||||
NS_ERROR("unable to construct resource");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Unassert the old value, if there was one.
|
||||
nsAutoString oldValue;
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == element->GetAttribute(attrNameSpaceID, attrNameAtom, oldValue)) {
|
||||
nsCOMPtr<nsIRDFLiteral> value;
|
||||
if (NS_FAILED(rv = gRDFService->GetLiteral(oldValue.GetUnicode(), getter_AddRefs(value)))) {
|
||||
NS_ERROR("unable to construct literal");
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = mDB->Unassert(resource, property, value);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to unassert old property value");
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnSetAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aNewAttr)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnRemoveAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aOldAttr)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
#endif // 0
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@ -1977,23 +1576,6 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||
}
|
||||
}
|
||||
|
||||
// get any persistant attributes
|
||||
if ((!aIsUnique) && (isResourceElement)) {
|
||||
GetPersistentAttributes(realKid);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// If item says its "open", then recurse now and build up its children
|
||||
nsAutoString openState;
|
||||
rv = realKid->GetAttribute(kNameSpaceID_None, kOpenAtom, openState);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if ((rv == NS_CONTENT_ATTR_HAS_VALUE) && (openState.EqualsIgnoreCase("true"))) {
|
||||
rv = OpenWidgetItem(realKid);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (nameSpaceID == kNameSpaceID_HTML) {
|
||||
// If we just built HTML, then we have to recurse "by
|
||||
// hand" because HTML won't build itself up lazily.
|
||||
@ -2323,7 +1905,7 @@ RDFGenericBuilderImpl::CreateContainerContents(nsIContent* aElement, nsIRDFResou
|
||||
// This will insert all of the elements into the
|
||||
// container, but _won't_ bother layout about it.
|
||||
for (loop=0; loop<numElements; loop+=2) {
|
||||
rv = CreateWidgetItem(aElement, flatArray[loop+1], flatArray[loop], loop+1, (istree ? PR_FALSE : PR_TRUE));
|
||||
rv = CreateWidgetItem(aElement, flatArray[loop+1], flatArray[loop], loop+1, PR_FALSE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create widget item");
|
||||
if (NS_FAILED(rv)) break;
|
||||
}
|
||||
@ -2799,212 +2381,6 @@ RDFGenericBuilderImpl::GetResource(PRInt32 aNameSpaceID,
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
RDFGenericBuilderImpl::OpenWidgetItem(nsIContent* aElement)
|
||||
{
|
||||
#ifdef PR_LOGGING
|
||||
if (PR_LOG_TEST(gLog, PR_LOG_DEBUG)) {
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
rv = aElement->GetTag(*getter_AddRefs(tag));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString tagStr;
|
||||
tag->ToString(tagStr);
|
||||
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
("rdfgeneric open-widget-item %s",
|
||||
(const char*) nsCAutoString(tagStr)));
|
||||
}
|
||||
#endif
|
||||
return CreateContents(aElement);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
RDFGenericBuilderImpl::CloseWidgetItem(nsIContent* aElement)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (PR_LOG_TEST(gLog, PR_LOG_DEBUG)) {
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
rv = aElement->GetTag(*getter_AddRefs(tag));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString tagStr;
|
||||
tag->ToString(tagStr);
|
||||
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
("rdfgeneric close-widget-item %s",
|
||||
(const char*) nsCAutoString(tagStr)));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Find the tag that contains the children so that we can remove
|
||||
// all of the children.
|
||||
//
|
||||
// XXX We make a bit of a leap here and assume that the same
|
||||
// template that was used to generate _us_ was used to generate
|
||||
// our _kids_. I'm sure this'll break when we do toolbars or
|
||||
// something.
|
||||
nsAutoString tmplID;
|
||||
rv = aElement->GetAttribute(kNameSpaceID_None, kTemplateAtom, tmplID);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (rv != NS_CONTENT_ATTR_HAS_VALUE)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMXULDocument> xulDoc = do_QueryInterface(mDocument);
|
||||
if (! xulDoc)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> tmplDOMEle;
|
||||
rv = xulDoc->GetElementById(tmplID, getter_AddRefs(tmplDOMEle));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIContent> tmpl = do_QueryInterface(tmplDOMEle);
|
||||
if (! tmpl)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIContent> tmplParent;
|
||||
rv = tmpl->GetParent(*getter_AddRefs(tmplParent));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_ASSERTION(tmplParent != nsnull, "template node has no parent");
|
||||
if (! tmplParent)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIAtom> tmplParentTag;
|
||||
rv = tmplParent->GetTag(*getter_AddRefs(tmplParentTag));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIContent> childcontainer;
|
||||
if ((tmplParentTag.get() == kRuleAtom) || (tmplParentTag.get() == kTemplateAtom)) {
|
||||
childcontainer = dont_QueryInterface(aElement);
|
||||
}
|
||||
else {
|
||||
rv = nsRDFContentUtils::FindChildByTag(aElement,
|
||||
kNameSpaceID_XUL,
|
||||
tmplParentTag,
|
||||
getter_AddRefs(childcontainer));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (rv == NS_RDF_NO_VALUE) {
|
||||
// No tag; must've already been closed
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 count;
|
||||
rv = childcontainer->ChildCount(count);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get count of the parent's children");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
while (--count >= 0) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
rv = childcontainer->ChildAt(count, *getter_AddRefs(child));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = childcontainer->RemoveChildAt(count, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "error removing child");
|
||||
|
||||
do {
|
||||
// If it's _not_ a XUL element, then we want to blow it and
|
||||
// all of its kids out of the XUL document's
|
||||
// resource-to-element map.
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
rv = nsRDFContentUtils::GetElementResource(child, getter_AddRefs(resource));
|
||||
if (NS_FAILED(rv)) break;
|
||||
|
||||
PRBool isXULElement;
|
||||
rv = mDB->HasAssertion(resource, kRDF_instanceOf, kXUL_element, PR_TRUE, &isXULElement);
|
||||
if (NS_FAILED(rv)) break;
|
||||
|
||||
if (! isXULElement)
|
||||
break;
|
||||
|
||||
rv = child->SetDocument(nsnull, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
} while (0);
|
||||
}
|
||||
|
||||
// Clear the container-contents-generated attribute so that the next time we
|
||||
// come back, we'll regenerate the kids we just killed.
|
||||
rv = aElement->UnsetAttribute(kNameSpaceID_None,
|
||||
kContainerContentsGeneratedAtom,
|
||||
PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// This is a _total_ hack to make sure that any XUL we blow away
|
||||
// gets rebuilt.
|
||||
rv = childcontainer->UnsetAttribute(kNameSpaceID_None,
|
||||
kXULContentsGeneratedAtom,
|
||||
PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = childcontainer->SetAttribute(kNameSpaceID_None,
|
||||
kLazyContentAtom,
|
||||
"true",
|
||||
PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
RDFGenericBuilderImpl::RemoveAndRebuildGeneratedChildren(nsIContent* aElement)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
PRInt32 count;
|
||||
rv = aElement->ChildCount(count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
while (--count >= 0) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
rv = aElement->ChildAt(count, *getter_AddRefs(child));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString tmplID;
|
||||
rv = child->GetAttribute(kNameSpaceID_None, kTemplateAtom, tmplID);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (rv != NS_CONTENT_ATTR_HAS_VALUE)
|
||||
continue;
|
||||
|
||||
// It's a generated element. Remove it, and set its document
|
||||
// to null so that it'll get knocked out of the XUL doc's
|
||||
// resource-to-element map.
|
||||
rv = aElement->RemoveChildAt(count, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "error removing child");
|
||||
|
||||
rv = child->SetDocument(nsnull, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// Clear the contents-generated attribute so that the next time we
|
||||
// come back, we'll regenerate the kids we just killed.
|
||||
rv = aElement->UnsetAttribute(kNameSpaceID_None,
|
||||
kTemplateContentsGeneratedAtom,
|
||||
PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = aElement->UnsetAttribute(kNameSpaceID_None,
|
||||
kContainerContentsGeneratedAtom,
|
||||
PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = CreateContents(aElement);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
RDFGenericBuilderImpl::IsTreeWidgetItem(nsIContent* aElement)
|
||||
{
|
||||
@ -3053,7 +2429,7 @@ RDFGenericBuilderImpl::ScheduleReflow()
|
||||
rv = NS_NewTimer(getter_AddRefs(mTimer));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mTimer->Init(RDFGenericBuilderImpl::ForceTreeReflow, this, 1000);
|
||||
mTimer->Init(RDFGenericBuilderImpl::ForceTreeReflow, this, 100);
|
||||
NS_ADDREF(this); // the timer will hold a reference to the builder
|
||||
|
||||
return NS_OK;
|
||||
|
@ -27,8 +27,6 @@
|
||||
#include "nsIRDFContainerUtils.h"
|
||||
#include "nsIRDFContentModelBuilder.h"
|
||||
#include "nsIRDFObserver.h"
|
||||
#include "nsIDOMNodeObserver.h"
|
||||
#include "nsIDOMElementObserver.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsIXULSortService.h"
|
||||
|
||||
@ -42,9 +40,7 @@ class nsIRDFService;
|
||||
class nsIHTMLElementFactory;
|
||||
|
||||
class RDFGenericBuilderImpl : public nsIRDFContentModelBuilder,
|
||||
public nsIRDFObserver,
|
||||
public nsIDOMNodeObserver,
|
||||
public nsIDOMElementObserver
|
||||
public nsIRDFObserver
|
||||
{
|
||||
public:
|
||||
RDFGenericBuilderImpl();
|
||||
@ -86,12 +82,6 @@ public:
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFNode* aTarget);
|
||||
|
||||
// nsIDOMNodeObserver interface
|
||||
NS_DECL_IDOMNODEOBSERVER
|
||||
|
||||
// nsIDOMElementObserver interface
|
||||
NS_DECL_IDOMELEMENTOBSERVER
|
||||
|
||||
// Implementation methods
|
||||
nsresult
|
||||
FindTemplate(nsIContent* aElement,
|
||||
@ -131,6 +121,7 @@ public:
|
||||
|
||||
enum eUpdateAction { eSet, eClear };
|
||||
|
||||
#if 0
|
||||
PRBool
|
||||
IsAttributePersisent(nsIContent *element, PRInt32 aNameSpaceID, nsIAtom* aAtom);
|
||||
|
||||
@ -149,6 +140,7 @@ public:
|
||||
nsIRDFResource *aProperty,
|
||||
nsIRDFNode *aTarget,
|
||||
eUpdateAction action);
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
SynchronizeUsingTemplate(nsIContent *aTemplateNode,
|
||||
@ -204,15 +196,6 @@ public:
|
||||
nsIAtom* aNameAtom,
|
||||
nsIRDFResource** aResource);
|
||||
|
||||
nsresult
|
||||
OpenWidgetItem(nsIContent* aElement);
|
||||
|
||||
nsresult
|
||||
CloseWidgetItem(nsIContent* aElement);
|
||||
|
||||
nsresult
|
||||
RemoveAndRebuildGeneratedChildren(nsIContent* aElement);
|
||||
|
||||
// XXX. Urg. Hack until layout can batch reflows. See bug 10818.
|
||||
PRBool
|
||||
IsTreeWidgetItem(nsIContent* aElement);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -190,6 +190,10 @@ XULCommandDispatcherImpl::SetFocusedWindow(nsIDOMWindow* aElement)
|
||||
NS_IMETHODIMP
|
||||
XULCommandDispatcherImpl::AddCommand(nsIDOMElement* aElement)
|
||||
{
|
||||
NS_PRECONDITION(aElement != nsnull, "null ptr");
|
||||
if (! aElement)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (!mFocusListeners) {
|
||||
mFocusListeners = new nsVoidArray();
|
||||
mFocusListeners->AppendElement((void*)aElement); // Weak ref to element.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -41,10 +41,8 @@
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMElementObserver.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMNodeObserver.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsIDOMXULElement.h"
|
||||
#include "nsIDocument.h"
|
||||
@ -80,6 +78,7 @@
|
||||
#include "nsIFocusableContent.h"
|
||||
#include "nsIStyleRule.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIXULContent.h"
|
||||
#include "nsXULTreeElement.h"
|
||||
#include "rdfutil.h"
|
||||
#include "prlog.h"
|
||||
@ -227,6 +226,7 @@ class RDFElementImpl : public nsIDOMXULElement,
|
||||
public nsIJSScriptObject,
|
||||
public nsIStyledContent,
|
||||
public nsIXMLContent,
|
||||
public nsIXULContent,
|
||||
public nsIFocusableContent
|
||||
{
|
||||
public:
|
||||
@ -311,6 +311,9 @@ public:
|
||||
NS_IMETHOD GetNameSpacePrefix(nsIAtom*& aNameSpace) const;
|
||||
NS_IMETHOD SetNameSpaceID(PRInt32 aNameSpaceID);
|
||||
|
||||
// nsIXULContent
|
||||
NS_IMETHOD PeekChildCount(PRInt32& aCount) const;
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
|
||||
NS_IMETHOD RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
|
||||
@ -677,6 +680,9 @@ RDFElementImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
else if (iid.Equals(nsIXMLContent::GetIID())) {
|
||||
*result = NS_STATIC_CAST(nsIXMLContent*, this);
|
||||
}
|
||||
else if (iid.Equals(nsCOMTypeInfo<nsIXULContent>::GetIID())) {
|
||||
*result = NS_STATIC_CAST(nsIXULContent*, this);
|
||||
}
|
||||
else if (iid.Equals(nsIDOMXULElement::GetIID()) ||
|
||||
iid.Equals(kIDOMElementIID) ||
|
||||
iid.Equals(kIDOMNodeIID)) {
|
||||
@ -699,7 +705,8 @@ RDFElementImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
IsFocusableContent()) {
|
||||
*result = NS_STATIC_CAST(nsIFocusableContent*, this);
|
||||
}
|
||||
else if (iid.Equals(nsIDOMXULTreeElement::GetIID()) &&
|
||||
else if ((iid.Equals(nsIDOMXULTreeElement::GetIID()) ||
|
||||
iid.Equals(nsIXULTreeContent::GetIID())) &&
|
||||
(mNameSpaceID == kNameSpaceID_XUL) &&
|
||||
(mTag == kTreeAtom)) {
|
||||
// We delegate XULTreeElement APIs to an aggregate object
|
||||
@ -944,21 +951,68 @@ RDFElementImpl::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
NS_PRECONDITION(aNewChild != nsnull, "null ptr");
|
||||
if (! aNewChild)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// It's possible that mDocument will be null for an element that's
|
||||
// not in the content model (e.g., somebody is working on a
|
||||
// "scratch" element that has been removed from the content tree).
|
||||
if (mDocument) {
|
||||
nsIDOMNodeObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMNodeObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnInsertBefore(this, aNewChild, aRefChild);
|
||||
NS_RELEASE(obs);
|
||||
// aRefChild may be null; that means "append".
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIContent> newcontent = do_QueryInterface(aNewChild);
|
||||
NS_ASSERTION(newcontent != nsnull, "not an nsIContent");
|
||||
if (! newcontent)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
// First, check to see if the content was already parented
|
||||
// somewhere. If so, remove it.
|
||||
nsCOMPtr<nsIContent> oldparent;
|
||||
rv = newcontent->GetParent(*getter_AddRefs(oldparent));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (oldparent) {
|
||||
PRInt32 oldindex;
|
||||
rv = oldparent->IndexOf(newcontent, oldindex);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to determine index of aNewChild in old parent");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_ASSERTION(oldindex >= 0, "old parent didn't think aNewChild was a child");
|
||||
|
||||
if (oldindex >= 0) {
|
||||
rv = oldparent->RemoveChildAt(oldindex, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// Now, insert the element into the content model under 'this'
|
||||
if (aRefChild) {
|
||||
nsCOMPtr<nsIContent> refcontent = do_QueryInterface(aRefChild);
|
||||
NS_ASSERTION(refcontent != nsnull, "not an nsIContent");
|
||||
if (! refcontent)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
PRInt32 pos;
|
||||
rv = IndexOf(refcontent, pos);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to determine index of aRefChild");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (pos >= 0) {
|
||||
rv = InsertChildAt(newcontent, pos, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to insert aNewChild");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// XXX Hmm. There's a case here that we handle ambiguously, I
|
||||
// think. If aRefChild _isn't_ actually one of our kids, then
|
||||
// pos == -1, and we'll never insert the new kid. Should we
|
||||
// just append it?
|
||||
}
|
||||
else {
|
||||
rv = AppendChildTo(newcontent, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to append a aNewChild");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
NS_ADDREF(aNewChild);
|
||||
*aReturn = aNewChild;
|
||||
return NS_OK;
|
||||
@ -968,18 +1022,32 @@ RDFElementImpl::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDO
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
NS_PRECONDITION(aNewChild != nsnull, "null ptr");
|
||||
if (! aNewChild)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// It's possible that mDocument will be null for an element that's
|
||||
// not in the content model (e.g., somebody is working on a
|
||||
// "scratch" element that has been removed from the content tree).
|
||||
if (mDocument) {
|
||||
nsIDOMNodeObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMNodeObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnReplaceChild(this, aNewChild, aOldChild);
|
||||
NS_RELEASE(obs);
|
||||
NS_PRECONDITION(aOldChild != nsnull, "null ptr");
|
||||
if (! aOldChild)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIContent> oldelement = do_QueryInterface(aOldChild);
|
||||
NS_ASSERTION(oldelement != nsnull, "not an nsIContent");
|
||||
|
||||
if (oldelement) {
|
||||
PRInt32 pos;
|
||||
rv = IndexOf(oldelement, pos);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to determine index of aOldChild");
|
||||
|
||||
if (NS_SUCCEEDED(rv) && (pos >= 0)) {
|
||||
nsCOMPtr<nsIContent> newelement = do_QueryInterface(aNewChild);
|
||||
NS_ASSERTION(newelement != nsnull, "not an nsIContent");
|
||||
|
||||
if (newelement) {
|
||||
rv = ReplaceChildAt(newelement, pos, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to replace old child");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -992,18 +1060,23 @@ RDFElementImpl::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDO
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
NS_PRECONDITION(aOldChild != nsnull, "null ptr");
|
||||
if (! aOldChild)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// It's possible that mDocument will be null for an element that's
|
||||
// not in the content model (e.g., somebody is working on a
|
||||
// "scratch" element that has been removed from the content tree).
|
||||
if (mDocument) {
|
||||
nsIDOMNodeObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMNodeObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnRemoveChild(this, aOldChild);
|
||||
NS_RELEASE(obs);
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIContent> element = do_QueryInterface(aOldChild);
|
||||
NS_ASSERTION(element != nsnull, "not an nsIContent");
|
||||
|
||||
if (element) {
|
||||
PRInt32 pos;
|
||||
rv = IndexOf(element, pos);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to determine index of aOldChild");
|
||||
|
||||
if (NS_SUCCEEDED(rv) && (pos >= 0)) {
|
||||
rv = RemoveChildAt(pos, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to remove old child");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1016,24 +1089,7 @@ RDFElementImpl::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// It's possible that mDocument will be null for an element that's
|
||||
// not in the content model (e.g., somebody is working on a
|
||||
// "scratch" element that has been removed from the content tree).
|
||||
if (mDocument) {
|
||||
nsIDOMNodeObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMNodeObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnAppendChild(this, aNewChild);
|
||||
NS_RELEASE(obs);
|
||||
}
|
||||
}
|
||||
|
||||
NS_ADDREF(aNewChild);
|
||||
*aReturn = aNewChild;
|
||||
return NS_OK;
|
||||
return InsertBefore(aNewChild, nsnull, aReturn);
|
||||
}
|
||||
|
||||
|
||||
@ -1094,11 +1150,19 @@ RDFElementImpl::GetAttribute(const nsString& aName, nsString& aReturn)
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::SetAttribute(const nsString& aName, const nsString& aValue)
|
||||
{
|
||||
nsIDOMElementObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMElementObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnSetAttribute(this, aName, aValue);
|
||||
NS_RELEASE(obs);
|
||||
nsresult rv;
|
||||
|
||||
PRInt32 nameSpaceID;
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
|
||||
rv = ParseAttributeString(aName, *getter_AddRefs(tag), nameSpaceID);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to parse attribute name");
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = SetAttribute(nameSpaceID, tag, aValue, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set attribute");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1106,11 +1170,19 @@ RDFElementImpl::SetAttribute(const nsString& aName, const nsString& aValue)
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::RemoveAttribute(const nsString& aName)
|
||||
{
|
||||
nsIDOMElementObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMElementObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnRemoveAttribute(this, aName);
|
||||
NS_RELEASE(obs);
|
||||
nsresult rv;
|
||||
|
||||
PRInt32 nameSpaceID;
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
|
||||
rv = ParseAttributeString(aName, *getter_AddRefs(tag), nameSpaceID);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to parse attribute name");
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = UnsetAttribute(nameSpaceID, tag, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to remove attribute");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1142,15 +1214,12 @@ RDFElementImpl::GetAttributeNode(const nsString& aName, nsIDOMAttr** aReturn)
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::SetAttributeNode(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
NS_PRECONDITION(aNewAttr != nsnull, "null ptr");
|
||||
if (! aNewAttr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIDOMElementObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMElementObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnSetAttributeNode(this, aNewAttr);
|
||||
NS_RELEASE(obs);
|
||||
}
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
|
||||
NS_ADDREF(aNewAttr);
|
||||
*aReturn = aNewAttr;
|
||||
return NS_OK;
|
||||
@ -1160,15 +1229,12 @@ RDFElementImpl::SetAttributeNode(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn)
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::RemoveAttributeNode(nsIDOMAttr* aOldAttr, nsIDOMAttr** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
NS_PRECONDITION(aOldAttr != nsnull, "null ptr");
|
||||
if (! aOldAttr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIDOMElementObserver* obs;
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(nsIDOMElementObserver::GetIID(), (void**) &obs))) {
|
||||
obs->OnRemoveAttributeNode(this, aOldAttr);
|
||||
NS_RELEASE(obs);
|
||||
}
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
|
||||
NS_ADDREF(aOldAttr);
|
||||
*aReturn = aOldAttr;
|
||||
return NS_OK;
|
||||
@ -1303,6 +1369,27 @@ RDFElementImpl::SetNameSpaceID(PRInt32 aNameSpaceID)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIXULContent interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::PeekChildCount(PRInt32& aCount) const
|
||||
{
|
||||
if (mChildren) {
|
||||
PRUint32 cnt;
|
||||
|
||||
nsresult rv;
|
||||
rv = mChildren->Count(&cnt);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
aCount = PRInt32(cnt);
|
||||
}
|
||||
else {
|
||||
aCount = 0;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIDOMEventReceiver interface
|
||||
@ -1718,15 +1805,7 @@ RDFElementImpl::ChildCount(PRInt32& aResult) const
|
||||
if (NS_FAILED(rv = EnsureContentsGenerated()))
|
||||
return rv;
|
||||
|
||||
if (mChildren) {
|
||||
PRUint32 cnt;
|
||||
rv = mChildren->Count(&cnt);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
aResult = cnt;
|
||||
}
|
||||
else
|
||||
aResult = 0;
|
||||
return NS_OK;
|
||||
return PeekChildCount(aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1824,14 +1903,6 @@ RDFElementImpl::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify)
|
||||
if (oldKid.get() == aKid)
|
||||
return NS_OK;
|
||||
|
||||
// Make sure that we're not trying to insert the same child
|
||||
// twice. If we do, the DOM APIs (e.g., GetNextSibling()), will
|
||||
// freak out.
|
||||
PRInt32 i = mChildren->IndexOf(aKid);
|
||||
NS_ASSERTION(i < 0, "element is already a child");
|
||||
if (i >= 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRBool replaceOk = mChildren->ReplaceElementAt(aKid, aIndex);
|
||||
if (replaceOk) {
|
||||
aKid->SetParent(NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
@ -1859,14 +1930,6 @@ RDFElementImpl::AppendChildTo(nsIContent* aKid, PRBool aNotify)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// Make sure that we're not trying to insert the same child
|
||||
// twice. If we do, the DOM APIs (e.g., GetNextSibling()), will
|
||||
// freak out.
|
||||
PRInt32 i = mChildren->IndexOf(aKid);
|
||||
NS_ASSERTION(i < 0, "element is already a child");
|
||||
if (i >= 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRBool appendOk = mChildren->AppendElement(aKid);
|
||||
if (appendOk) {
|
||||
aKid->SetParent(NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
@ -1913,16 +1976,12 @@ RDFElementImpl::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
// This is the nasty case. We have (potentially) a slew of selected items
|
||||
// and cells going away.
|
||||
// First, retrieve the tree.
|
||||
nsRDFDOMNodeList* itemList = nsnull;
|
||||
nsRDFDOMNodeList* cellList = nsnull;
|
||||
nsCOMPtr<nsIDOMXULTreeElement> treeElement;
|
||||
GetParentTree(getter_AddRefs(treeElement));
|
||||
rv = GetParentTree(getter_AddRefs(treeElement));
|
||||
if (treeElement) {
|
||||
nsCOMPtr<nsIDOMNodeList> nodes;
|
||||
treeElement->GetSelectedItems(getter_AddRefs(nodes));
|
||||
itemList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar.
|
||||
treeElement->GetSelectedCells(getter_AddRefs(nodes));
|
||||
cellList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar.
|
||||
nsCOMPtr<nsIDOMNodeList> itemList;
|
||||
treeElement->GetSelectedItems(getter_AddRefs(itemList));
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parentKid = do_QueryInterface(oldKid);
|
||||
PRBool fireSelectionHandler = PR_FALSE;
|
||||
if (itemList) {
|
||||
@ -1942,6 +2001,10 @@ RDFElementImpl::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNodeList> cellList;
|
||||
treeElement->GetSelectedCells(getter_AddRefs(cellList));
|
||||
|
||||
if (cellList) {
|
||||
// Iterate over all of the items and find out if they are contained inside
|
||||
// the removed subtree.
|
||||
@ -1961,8 +2024,10 @@ RDFElementImpl::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
}
|
||||
|
||||
if (fireSelectionHandler) {
|
||||
nsXULTreeElement* tree = (nsXULTreeElement*)(treeElement.get()); // XXX Yes, I am evil.
|
||||
tree->FireOnSelectHandler();
|
||||
nsCOMPtr<nsIXULTreeContent> tree = do_QueryInterface(treeElement);
|
||||
if (tree) {
|
||||
tree->FireOnSelectHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2131,14 +2196,14 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
|
||||
GetTag(*getter_AddRefs(tag));
|
||||
if (mDocument && (aNameSpaceID == kNameSpaceID_None)) {
|
||||
// See if we're a treeitem atom.
|
||||
nsRDFDOMNodeList* nodeList = nsnull;
|
||||
nsCOMPtr<nsIRDFNodeList> nodeList;
|
||||
if (tag && (tag.get() == kTreeItemAtom) && (aName == kSelectedAtom)) {
|
||||
nsCOMPtr<nsIDOMXULTreeElement> treeElement;
|
||||
GetParentTree(getter_AddRefs(treeElement));
|
||||
if (treeElement) {
|
||||
nsCOMPtr<nsIDOMNodeList> nodes;
|
||||
treeElement->GetSelectedItems(getter_AddRefs(nodes));
|
||||
nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar.
|
||||
nodeList = do_QueryInterface(nodes);
|
||||
}
|
||||
}
|
||||
else if (tag && (tag.get() == kTreeCellAtom) && (aName == kSelectedAtom)) {
|
||||
@ -2147,7 +2212,7 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
|
||||
if (treeElement) {
|
||||
nsCOMPtr<nsIDOMNodeList> nodes;
|
||||
treeElement->GetSelectedCells(getter_AddRefs(nodes));
|
||||
nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar.
|
||||
nodeList = do_QueryInterface(nodes);
|
||||
}
|
||||
}
|
||||
if (nodeList) {
|
||||
@ -2193,18 +2258,23 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
|
||||
// Check to see if the REF attribute is being set. If so, we need
|
||||
// to update the element map. First, remove the old mapping, if
|
||||
// necessary...
|
||||
if (mDocument && (aNameSpaceID == kNameSpaceID_None) && (aName == kRefAtom)) {
|
||||
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
|
||||
if (rdfdoc) {
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
|
||||
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
|
||||
if (rdfdoc && (aNameSpaceID == kNameSpaceID_None)) {
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
if (aName == kRefAtom) {
|
||||
GetRefResource(getter_AddRefs(resource));
|
||||
if (resource) {
|
||||
rdfdoc->RemoveElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
}
|
||||
}
|
||||
else if (aName == kIdAtom) {
|
||||
GetIdResource(getter_AddRefs(resource));
|
||||
}
|
||||
|
||||
if (resource) {
|
||||
rdfdoc->RemoveElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// XXX need to check if they're changing an event handler: if so, then we need
|
||||
// to unhook the old one.
|
||||
|
||||
@ -2231,15 +2301,17 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
|
||||
|
||||
// Check for REF attribute, part deux. Add the new REF to the map,
|
||||
// if appropriate.
|
||||
if (mDocument && (aNameSpaceID == kNameSpaceID_None) && (aName == kRefAtom)) {
|
||||
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
|
||||
if (rdfdoc) {
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
|
||||
if (rdfdoc && (aNameSpaceID == kNameSpaceID_None)) {
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
if (aName == kRefAtom) {
|
||||
GetRefResource(getter_AddRefs(resource));
|
||||
if (resource) {
|
||||
rdfdoc->AddElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
}
|
||||
}
|
||||
else if (aName == kIdAtom) {
|
||||
GetIdResource(getter_AddRefs(resource));
|
||||
}
|
||||
|
||||
if (resource) {
|
||||
rdfdoc->AddElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2374,6 +2446,7 @@ RDFElementImpl::GetAttribute(PRInt32 aNameSpaceID,
|
||||
else {
|
||||
rv = NS_CONTENT_ATTR_NO_VALUE;
|
||||
}
|
||||
#if 0
|
||||
if ((aNameSpaceID == kNameSpaceID_None) &&
|
||||
(attr->mName == kIdAtom))
|
||||
{
|
||||
@ -2384,6 +2457,7 @@ RDFElementImpl::GetAttribute(PRInt32 aNameSpaceID,
|
||||
nsRDFContentUtils::MakeElementID(mDocument, attr->mValue, aResult);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2427,14 +2501,14 @@ RDFElementImpl::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNot
|
||||
// doing it anyway. Need to make an nsIRDFNodeList interface that
|
||||
// I can QI to for additions and removals of nodes. For now
|
||||
// do an evil cast.
|
||||
nsRDFDOMNodeList* nodeList = nsnull;
|
||||
nsCOMPtr<nsIRDFNodeList> nodeList;
|
||||
if (tag && (tag.get() == kTreeItemAtom) && (aName == kSelectedAtom)) {
|
||||
nsCOMPtr<nsIDOMXULTreeElement> treeElement;
|
||||
GetParentTree(getter_AddRefs(treeElement));
|
||||
if (treeElement) {
|
||||
nsCOMPtr<nsIDOMNodeList> nodes;
|
||||
treeElement->GetSelectedItems(getter_AddRefs(nodes));
|
||||
nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar.
|
||||
nodeList = do_QueryInterface(nodes);
|
||||
}
|
||||
}
|
||||
else if (tag && (tag.get() == kTreeCellAtom) && (aName == kSelectedAtom)) {
|
||||
@ -2443,7 +2517,7 @@ RDFElementImpl::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNot
|
||||
if (treeElement) {
|
||||
nsCOMPtr<nsIDOMNodeList> nodes;
|
||||
treeElement->GetSelectedCells(getter_AddRefs(nodes));
|
||||
nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar.
|
||||
nodeList = do_QueryInterface(nodes);
|
||||
}
|
||||
}
|
||||
if (nodeList) {
|
||||
@ -2944,7 +3018,7 @@ RDFElementImpl::GetIdResource(nsIRDFResource** aResource)
|
||||
const nsXULAttribute* attr = (const nsXULAttribute*) mAttributes->ElementAt(i);
|
||||
if ((attr->mNameSpaceID == kNameSpaceID_None) &&
|
||||
(attr->mName == kIdAtom)) {
|
||||
return gRDFService->GetUnicodeResource(attr->mValue.GetUnicode(), aResource);
|
||||
return nsRDFContentUtils::MakeElementResource(mDocument, attr->mValue.GetUnicode(), aResource);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2970,7 +3044,7 @@ RDFElementImpl::GetRefResource(nsIRDFResource** aResource)
|
||||
|
||||
if (attr->mName != kRefAtom)
|
||||
continue;
|
||||
|
||||
#if 0
|
||||
// Found it!
|
||||
nsresult rv;
|
||||
|
||||
@ -2983,6 +3057,9 @@ RDFElementImpl::GetRefResource(nsIRDFResource** aResource)
|
||||
|
||||
// ...then, setup the new mapping.
|
||||
return gRDFService->GetUnicodeResource(uri.GetUnicode(), aResource);
|
||||
#else
|
||||
return nsRDFContentUtils::MakeElementResource(mDocument, attr->mValue.GetUnicode(), aResource);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,9 +25,7 @@
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMElementObserver.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeObserver.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIRDFContentModelBuilder.h"
|
||||
|
@ -39,9 +39,7 @@
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMElementObserver.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeObserver.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
@ -390,12 +388,6 @@ RDFGenericBuilderImpl::QueryInterface(REFNSIID iid, void** aResult)
|
||||
else if (iid.Equals(kIRDFObserverIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIRDFObserver*, this);
|
||||
}
|
||||
else if (iid.Equals(nsIDOMNodeObserver::GetIID())) {
|
||||
*aResult = NS_STATIC_CAST(nsIDOMNodeObserver*, this);
|
||||
}
|
||||
else if (iid.Equals(nsIDOMElementObserver::GetIID())) {
|
||||
*aResult = NS_STATIC_CAST(nsIDOMElementObserver*, this);
|
||||
}
|
||||
else {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
@ -539,22 +531,38 @@ RDFGenericBuilderImpl::CreateElement(PRInt32 aNameSpaceID,
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> doc( do_QueryInterface(mDocument) );
|
||||
|
||||
if (aResource) {
|
||||
const char *uri;
|
||||
const char *uri;
|
||||
rv = aResource->GetValueConst(&uri);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource URI");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = result->SetAttribute(kNameSpaceID_None, kIdAtom, (const char*) uri, PR_FALSE);
|
||||
nsAutoString id;
|
||||
rv = nsRDFContentUtils::MakeElementID(doc, nsAutoString(uri), id);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = result->SetAttribute(kNameSpaceID_None, kIdAtom, id, PR_FALSE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set id attribute");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> doc( do_QueryInterface(mDocument) );
|
||||
rv = result->SetDocument(doc, PR_FALSE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set element's document");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (aResource && aNameSpaceID == kNameSpaceID_HTML) {
|
||||
// If this is an HTML element, then explicitly add it to the
|
||||
// map. (XUL elements don't have to do this because their
|
||||
// SetDocument() call does the magic.) Don't worry: the
|
||||
// document observer methods are on the lookout to update the
|
||||
// map for "attribute changed" calls that monkey with the 'id'
|
||||
// or 'ref' parameters.
|
||||
rv = mDocument->AddElementForResource(aResource, result);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
*aResult = result;
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
@ -628,15 +636,17 @@ RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource,
|
||||
// child to this node.
|
||||
|
||||
// XXX Bug 10818.
|
||||
PRBool notify;
|
||||
if (IsTreeWidgetItem(element) && !IsReflowScheduled()) {
|
||||
notify = PR_TRUE;
|
||||
|
||||
rv = ScheduleReflow();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else {
|
||||
notify = PR_FALSE;
|
||||
PRBool notify = PR_TRUE;
|
||||
if (IsTreeWidgetItem(element)) {
|
||||
if (!IsReflowScheduled()) {
|
||||
rv = ScheduleReflow();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else {
|
||||
// a reflow has been scheduled. we'll add the
|
||||
// element but won't notify right now.
|
||||
notify = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
rv = CreateWidgetItem(element, aProperty, resource, 0, notify);
|
||||
@ -676,9 +686,6 @@ RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource,
|
||||
// this node was created by a XUL template, so update it accordingly
|
||||
rv = SynchronizeUsingTemplate(templateNode, element, eSet, aProperty, aTarget);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PersistProperty(element, aProperty, aTarget, eSet);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -790,9 +797,6 @@ RDFGenericBuilderImpl::OnUnassert(nsIRDFResource* aSource,
|
||||
// this node was created by a XUL template, so update it accordingly
|
||||
rv = SynchronizeUsingTemplate(templateNode, element, eClear, aProperty, aTarget);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PersistProperty(element, aProperty, aTarget, eClear);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -907,9 +911,6 @@ RDFGenericBuilderImpl::OnChange(nsIRDFResource* aSource,
|
||||
// this node was created by a XUL template, so update it accordingly
|
||||
rv = SynchronizeUsingTemplate(templateNode, element, eSet, aProperty, aNewTarget);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PersistProperty(element, aProperty, aNewTarget, eSet);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -928,55 +929,7 @@ RDFGenericBuilderImpl::OnMove(nsIRDFResource* aOldSource,
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIDOMNodeObserver interface
|
||||
//
|
||||
// XXX Any of these methods that can't be implemented in a generic
|
||||
// way should become pure virtual on this class.
|
||||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnSetNodeValue(nsIDOMNode* aNode, const nsString& aValue)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnInsertBefore(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aRefChild)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnReplaceChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aOldChild)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnRemoveChild(nsIDOMNode* aParent, nsIDOMNode* aOldChild)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnAppendChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIDOMElementObserver interface
|
||||
|
||||
|
||||
#if 0
|
||||
PRBool
|
||||
RDFGenericBuilderImpl::IsAttributePersisent(nsIContent *element, PRInt32 aNameSpaceID, nsIAtom *aAtom)
|
||||
{
|
||||
@ -1151,361 +1104,7 @@ RDFGenericBuilderImpl::PersistProperty(nsIContent *element, nsIRDFResource *aPro
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnSetAttribute(nsIDOMElement* aElement, const nsString& aName, const nsString& aValue)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
if (NS_FAILED(rv = GetDOMNodeResource(aElement, getter_AddRefs(resource)))) {
|
||||
// XXX it's not a resource element, so there's no assertions
|
||||
// we need to make on the back-end. Should we just do the
|
||||
// update?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get the nsIContent interface, it's a bit more utilitarian
|
||||
nsCOMPtr<nsIContent> element( do_QueryInterface(aElement) );
|
||||
if (! element) {
|
||||
NS_ERROR("element doesn't support nsIContent");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// Make sure that the element is in the widget. XXX Even this may be
|
||||
// a bit too promiscuous: an element may also be a XUL element...
|
||||
if (!IsElementInWidget(element))
|
||||
return NS_OK;
|
||||
|
||||
// Split the element into its namespace and tag components
|
||||
PRInt32 elementNameSpaceID;
|
||||
if (NS_FAILED(rv = element->GetNameSpaceID(elementNameSpaceID))) {
|
||||
NS_ERROR("unable to get element namespace ID");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> elementNameAtom;
|
||||
if (NS_FAILED(rv = element->GetTag( *getter_AddRefs(elementNameAtom) ))) {
|
||||
NS_ERROR("unable to get element tag");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Split the property name into its namespace and tag components
|
||||
PRInt32 attrNameSpaceID;
|
||||
nsCOMPtr<nsIAtom> attrNameAtom;
|
||||
if (NS_FAILED(rv = element->ParseAttributeString(aName, *getter_AddRefs(attrNameAtom), attrNameSpaceID))) {
|
||||
NS_ERROR("unable to parse attribute string");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Now do the work to change the attribute. There are a couple of
|
||||
// special cases that we need to check for here...
|
||||
if ((elementNameSpaceID == kNameSpaceID_XUL) &&
|
||||
IsResourceElement(element) && // XXX IsResourceElement(): is this what we really mean?
|
||||
(attrNameSpaceID == kNameSpaceID_None) &&
|
||||
(attrNameAtom.get() == kOpenAtom)) {
|
||||
|
||||
// We are (possibly) changing the value of the "open"
|
||||
// attribute. This may require us to generate or destroy
|
||||
// content in the widget. See what the old value was...
|
||||
nsAutoString attrValue;
|
||||
if (NS_FAILED(rv = element->GetAttribute(kNameSpaceID_None, kOpenAtom, attrValue))) {
|
||||
NS_ERROR("unable to get current open state");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if ((rv == NS_CONTENT_ATTR_NO_VALUE) || (rv == NS_CONTENT_ATTR_NOT_THERE) ||
|
||||
((rv == NS_CONTENT_ATTR_HAS_VALUE) && (! attrValue.EqualsIgnoreCase(aValue))) ||
|
||||
PR_TRUE // XXX just always allow this to fire.
|
||||
) {
|
||||
// Okay, it's really changing.
|
||||
|
||||
// This is a "transient" property, so we _don't_ go to the
|
||||
// RDF graph to set it.
|
||||
if (NS_FAILED(rv = element->SetAttribute(kNameSpaceID_None, kOpenAtom, aValue, PR_TRUE))) {
|
||||
NS_ERROR("unable to update attribute on content node");
|
||||
return rv;
|
||||
}
|
||||
|
||||
PersistAttribute(element, kNameSpaceID_None, kOpenAtom, aValue, eSet);
|
||||
|
||||
if (aValue.EqualsIgnoreCase("true")) {
|
||||
rv = OpenWidgetItem(element);
|
||||
}
|
||||
else {
|
||||
rv = CloseWidgetItem(element);
|
||||
}
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to open/close tree item");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else if ((elementNameSpaceID == kNameSpaceID_XUL) &&
|
||||
(IsResourceElement(element)) &&
|
||||
(attrNameSpaceID == kNameSpaceID_None) &&
|
||||
(attrNameAtom.get() == kIdAtom)) {
|
||||
|
||||
// We are (possibly) changing the actual identity of the
|
||||
// element; e.g., re-rooting an item in the tree.
|
||||
|
||||
nsCOMPtr<nsIRDFResource> newResource;
|
||||
if (NS_FAILED(rv = gRDFService->GetUnicodeResource(aValue.GetUnicode(), getter_AddRefs(newResource)))) {
|
||||
NS_ERROR("unable to get new resource");
|
||||
return rv;
|
||||
}
|
||||
|
||||
#if 0 // XXX we're fighting with the XUL builder, so just _always_ let this through.
|
||||
// Didn't change. So bail!
|
||||
if (resource == newResource)
|
||||
return NS_OK;
|
||||
#endif
|
||||
|
||||
// Allright, it really is changing. So blow away the old
|
||||
// content node and insert a new one with the new ID in
|
||||
// its place.
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
if (NS_FAILED(rv = element->GetParent(*getter_AddRefs(parent)))) {
|
||||
NS_ERROR("unable to get element's parent");
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRInt32 elementIndex;
|
||||
if (NS_FAILED(rv = parent->IndexOf(element, elementIndex))) {
|
||||
NS_ERROR("unable to get element's index within parent");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (! parent)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
if (NS_FAILED(rv = parent->RemoveChildAt(elementIndex, PR_TRUE))) {
|
||||
NS_ERROR("unable to remove element");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> newElement;
|
||||
if (NS_FAILED(rv = CreateElement(elementNameSpaceID,
|
||||
elementNameAtom,
|
||||
newResource,
|
||||
getter_AddRefs(newElement)))) {
|
||||
NS_ERROR("unable to create new element");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Attach transient properties to the new element.
|
||||
//
|
||||
// XXX all I really care about right this minute is the
|
||||
// "open" state. We could put this stuff in a table and
|
||||
// drive it that way.
|
||||
nsAutoString attrValue;
|
||||
if (NS_FAILED(rv = element->GetAttribute(kNameSpaceID_None, kOpenAtom, attrValue))) {
|
||||
NS_ERROR("unable to get open state of old element");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
|
||||
if (NS_FAILED(rv = newElement->SetAttribute(kNameSpaceID_None, kOpenAtom, attrValue, PR_FALSE))) {
|
||||
NS_ERROR("unable to set open state of new element");
|
||||
return rv;
|
||||
}
|
||||
|
||||
PersistAttribute(newElement, kNameSpaceID_None, kOpenAtom, attrValue, eSet);
|
||||
|
||||
}
|
||||
|
||||
// Mark as a container so the contents get regenerated
|
||||
if (NS_FAILED(rv = newElement->SetAttribute(kNameSpaceID_None,
|
||||
kLazyContentAtom,
|
||||
"true",
|
||||
PR_FALSE))) {
|
||||
NS_ERROR("unable to mark as a container");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Now insert the new element into the parent. This should
|
||||
// trigger a reflow and cause the contents to be regenerated.
|
||||
if (NS_FAILED(rv = parent->InsertChildAt(newElement, elementIndex, PR_TRUE))) {
|
||||
NS_ERROR("unable to add new element to the parent");
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
else if ((attrNameSpaceID == kNameSpaceID_None) &&
|
||||
(attrNameAtom.get() == kRefAtom)) {
|
||||
// Remove all of the template children and rebuild them
|
||||
rv = RemoveAndRebuildGeneratedChildren(element);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// If we get here, it's a "vanilla" property: push its value into the graph.
|
||||
if (kNameSpaceID_Unknown == attrNameSpaceID) {
|
||||
attrNameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
|
||||
}
|
||||
nsCOMPtr<nsIRDFResource> property;
|
||||
if (NS_FAILED(rv = GetResource(attrNameSpaceID, attrNameAtom, getter_AddRefs(property)))) {
|
||||
NS_ERROR("unable to construct resource");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Get the old value, if there was one.
|
||||
nsAutoString oldValueStr;
|
||||
rv = element->GetAttribute(attrNameSpaceID, attrNameAtom, oldValueStr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> oldvalue;
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == rv) {
|
||||
rv = gRDFService->GetLiteral(oldValueStr.GetUnicode(), getter_AddRefs(oldvalue));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to construct literal");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// Get the new value
|
||||
nsCOMPtr<nsIRDFLiteral> newvalue;
|
||||
rv = gRDFService->GetLiteral(aValue.GetUnicode(), getter_AddRefs(newvalue));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to construct literal");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (oldvalue) {
|
||||
rv = mDB->Change(resource, property, oldvalue, newvalue);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else {
|
||||
rv = mDB->Assert(resource, property, newvalue, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
if (rv == NS_RDF_ASSERTION_REJECTED) {
|
||||
// Okay, just force the attribute to be set.
|
||||
rv = element->SetAttribute(attrNameSpaceID, attrNameAtom, aValue, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnRemoveAttribute(nsIDOMElement* aElement, const nsString& aName)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
if (NS_FAILED(rv = GetDOMNodeResource(aElement, getter_AddRefs(resource)))) {
|
||||
// XXX it's not a resource element, so there's no assertions
|
||||
// we need to make on the back-end. Should we just do the
|
||||
// update?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get the nsIContent interface, it's a bit more utilitarian
|
||||
nsCOMPtr<nsIContent> element( do_QueryInterface(aElement) );
|
||||
if (! element) {
|
||||
NS_ERROR("element doesn't support nsIContent");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// Make sure that the element is in the widget. XXX Even this may be
|
||||
// a bit too promiscuous: an element may also be a XUL element...
|
||||
if (!IsElementInWidget(element))
|
||||
return NS_OK;
|
||||
|
||||
// Split the element into its namespace and tag components
|
||||
PRInt32 elementNameSpaceID;
|
||||
if (NS_FAILED(rv = element->GetNameSpaceID(elementNameSpaceID))) {
|
||||
NS_ERROR("unable to get element namespace ID");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> elementNameAtom;
|
||||
if (NS_FAILED(rv = element->GetTag( *getter_AddRefs(elementNameAtom) ))) {
|
||||
NS_ERROR("unable to get element tag");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Split the property name into its namespace and tag components
|
||||
PRInt32 attrNameSpaceID;
|
||||
nsCOMPtr<nsIAtom> attrNameAtom;
|
||||
if (NS_FAILED(rv = element->ParseAttributeString(aName, *getter_AddRefs(attrNameAtom), attrNameSpaceID))) {
|
||||
NS_ERROR("unable to parse attribute string");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if ((elementNameSpaceID == kNameSpaceID_XUL) &&
|
||||
IsResourceElement(element) && // XXX Is this what we really mean?
|
||||
(attrNameSpaceID == kNameSpaceID_None) &&
|
||||
(attrNameAtom.get() == kOpenAtom)) {
|
||||
// We are removing the value of the "open" attribute. This may
|
||||
// require us to destroy content from the tree.
|
||||
|
||||
|
||||
nsAutoString openVal;
|
||||
if (NS_FAILED(rv = element->GetAttribute(kNameSpaceID_None, kOpenAtom, openVal))) {
|
||||
NS_ERROR("unable to get open attribute on update content node");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// XXX should we check for existence of the attribute first?
|
||||
if (NS_FAILED(rv = element->UnsetAttribute(kNameSpaceID_None, kOpenAtom, PR_TRUE))) {
|
||||
NS_ERROR("unable to attribute on update content node");
|
||||
return rv;
|
||||
}
|
||||
|
||||
PersistAttribute(element, kNameSpaceID_None, kOpenAtom, openVal, eClear);
|
||||
|
||||
if (NS_FAILED(rv = CloseWidgetItem(element))) {
|
||||
NS_ERROR("unable to close widget item");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else if ((attrNameSpaceID == kNameSpaceID_None) &&
|
||||
(attrNameAtom.get() == kRefAtom)) {
|
||||
// Ignore changes to the 'ref=' attribute; the XUL builder
|
||||
// will take care of that for us.
|
||||
}
|
||||
else {
|
||||
// It's a "vanilla" property: push its value into the graph.
|
||||
|
||||
nsCOMPtr<nsIRDFResource> property;
|
||||
if (kNameSpaceID_Unknown == attrNameSpaceID) {
|
||||
attrNameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
|
||||
}
|
||||
if (NS_FAILED(rv = GetResource(attrNameSpaceID, attrNameAtom, getter_AddRefs(property)))) {
|
||||
NS_ERROR("unable to construct resource");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Unassert the old value, if there was one.
|
||||
nsAutoString oldValue;
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == element->GetAttribute(attrNameSpaceID, attrNameAtom, oldValue)) {
|
||||
nsCOMPtr<nsIRDFLiteral> value;
|
||||
if (NS_FAILED(rv = gRDFService->GetLiteral(oldValue.GetUnicode(), getter_AddRefs(value)))) {
|
||||
NS_ERROR("unable to construct literal");
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = mDB->Unassert(resource, property, value);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to unassert old property value");
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnSetAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aNewAttr)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnRemoveAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aOldAttr)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
#endif // 0
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@ -1977,23 +1576,6 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||
}
|
||||
}
|
||||
|
||||
// get any persistant attributes
|
||||
if ((!aIsUnique) && (isResourceElement)) {
|
||||
GetPersistentAttributes(realKid);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// If item says its "open", then recurse now and build up its children
|
||||
nsAutoString openState;
|
||||
rv = realKid->GetAttribute(kNameSpaceID_None, kOpenAtom, openState);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if ((rv == NS_CONTENT_ATTR_HAS_VALUE) && (openState.EqualsIgnoreCase("true"))) {
|
||||
rv = OpenWidgetItem(realKid);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (nameSpaceID == kNameSpaceID_HTML) {
|
||||
// If we just built HTML, then we have to recurse "by
|
||||
// hand" because HTML won't build itself up lazily.
|
||||
@ -2323,7 +1905,7 @@ RDFGenericBuilderImpl::CreateContainerContents(nsIContent* aElement, nsIRDFResou
|
||||
// This will insert all of the elements into the
|
||||
// container, but _won't_ bother layout about it.
|
||||
for (loop=0; loop<numElements; loop+=2) {
|
||||
rv = CreateWidgetItem(aElement, flatArray[loop+1], flatArray[loop], loop+1, (istree ? PR_FALSE : PR_TRUE));
|
||||
rv = CreateWidgetItem(aElement, flatArray[loop+1], flatArray[loop], loop+1, PR_FALSE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create widget item");
|
||||
if (NS_FAILED(rv)) break;
|
||||
}
|
||||
@ -2799,212 +2381,6 @@ RDFGenericBuilderImpl::GetResource(PRInt32 aNameSpaceID,
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
RDFGenericBuilderImpl::OpenWidgetItem(nsIContent* aElement)
|
||||
{
|
||||
#ifdef PR_LOGGING
|
||||
if (PR_LOG_TEST(gLog, PR_LOG_DEBUG)) {
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
rv = aElement->GetTag(*getter_AddRefs(tag));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString tagStr;
|
||||
tag->ToString(tagStr);
|
||||
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
("rdfgeneric open-widget-item %s",
|
||||
(const char*) nsCAutoString(tagStr)));
|
||||
}
|
||||
#endif
|
||||
return CreateContents(aElement);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
RDFGenericBuilderImpl::CloseWidgetItem(nsIContent* aElement)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (PR_LOG_TEST(gLog, PR_LOG_DEBUG)) {
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
rv = aElement->GetTag(*getter_AddRefs(tag));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString tagStr;
|
||||
tag->ToString(tagStr);
|
||||
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
("rdfgeneric close-widget-item %s",
|
||||
(const char*) nsCAutoString(tagStr)));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Find the tag that contains the children so that we can remove
|
||||
// all of the children.
|
||||
//
|
||||
// XXX We make a bit of a leap here and assume that the same
|
||||
// template that was used to generate _us_ was used to generate
|
||||
// our _kids_. I'm sure this'll break when we do toolbars or
|
||||
// something.
|
||||
nsAutoString tmplID;
|
||||
rv = aElement->GetAttribute(kNameSpaceID_None, kTemplateAtom, tmplID);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (rv != NS_CONTENT_ATTR_HAS_VALUE)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMXULDocument> xulDoc = do_QueryInterface(mDocument);
|
||||
if (! xulDoc)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> tmplDOMEle;
|
||||
rv = xulDoc->GetElementById(tmplID, getter_AddRefs(tmplDOMEle));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIContent> tmpl = do_QueryInterface(tmplDOMEle);
|
||||
if (! tmpl)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIContent> tmplParent;
|
||||
rv = tmpl->GetParent(*getter_AddRefs(tmplParent));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_ASSERTION(tmplParent != nsnull, "template node has no parent");
|
||||
if (! tmplParent)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIAtom> tmplParentTag;
|
||||
rv = tmplParent->GetTag(*getter_AddRefs(tmplParentTag));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIContent> childcontainer;
|
||||
if ((tmplParentTag.get() == kRuleAtom) || (tmplParentTag.get() == kTemplateAtom)) {
|
||||
childcontainer = dont_QueryInterface(aElement);
|
||||
}
|
||||
else {
|
||||
rv = nsRDFContentUtils::FindChildByTag(aElement,
|
||||
kNameSpaceID_XUL,
|
||||
tmplParentTag,
|
||||
getter_AddRefs(childcontainer));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (rv == NS_RDF_NO_VALUE) {
|
||||
// No tag; must've already been closed
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 count;
|
||||
rv = childcontainer->ChildCount(count);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get count of the parent's children");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
while (--count >= 0) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
rv = childcontainer->ChildAt(count, *getter_AddRefs(child));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = childcontainer->RemoveChildAt(count, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "error removing child");
|
||||
|
||||
do {
|
||||
// If it's _not_ a XUL element, then we want to blow it and
|
||||
// all of its kids out of the XUL document's
|
||||
// resource-to-element map.
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
rv = nsRDFContentUtils::GetElementResource(child, getter_AddRefs(resource));
|
||||
if (NS_FAILED(rv)) break;
|
||||
|
||||
PRBool isXULElement;
|
||||
rv = mDB->HasAssertion(resource, kRDF_instanceOf, kXUL_element, PR_TRUE, &isXULElement);
|
||||
if (NS_FAILED(rv)) break;
|
||||
|
||||
if (! isXULElement)
|
||||
break;
|
||||
|
||||
rv = child->SetDocument(nsnull, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
} while (0);
|
||||
}
|
||||
|
||||
// Clear the container-contents-generated attribute so that the next time we
|
||||
// come back, we'll regenerate the kids we just killed.
|
||||
rv = aElement->UnsetAttribute(kNameSpaceID_None,
|
||||
kContainerContentsGeneratedAtom,
|
||||
PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// This is a _total_ hack to make sure that any XUL we blow away
|
||||
// gets rebuilt.
|
||||
rv = childcontainer->UnsetAttribute(kNameSpaceID_None,
|
||||
kXULContentsGeneratedAtom,
|
||||
PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = childcontainer->SetAttribute(kNameSpaceID_None,
|
||||
kLazyContentAtom,
|
||||
"true",
|
||||
PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
RDFGenericBuilderImpl::RemoveAndRebuildGeneratedChildren(nsIContent* aElement)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
PRInt32 count;
|
||||
rv = aElement->ChildCount(count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
while (--count >= 0) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
rv = aElement->ChildAt(count, *getter_AddRefs(child));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString tmplID;
|
||||
rv = child->GetAttribute(kNameSpaceID_None, kTemplateAtom, tmplID);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (rv != NS_CONTENT_ATTR_HAS_VALUE)
|
||||
continue;
|
||||
|
||||
// It's a generated element. Remove it, and set its document
|
||||
// to null so that it'll get knocked out of the XUL doc's
|
||||
// resource-to-element map.
|
||||
rv = aElement->RemoveChildAt(count, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "error removing child");
|
||||
|
||||
rv = child->SetDocument(nsnull, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// Clear the contents-generated attribute so that the next time we
|
||||
// come back, we'll regenerate the kids we just killed.
|
||||
rv = aElement->UnsetAttribute(kNameSpaceID_None,
|
||||
kTemplateContentsGeneratedAtom,
|
||||
PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = aElement->UnsetAttribute(kNameSpaceID_None,
|
||||
kContainerContentsGeneratedAtom,
|
||||
PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = CreateContents(aElement);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
RDFGenericBuilderImpl::IsTreeWidgetItem(nsIContent* aElement)
|
||||
{
|
||||
@ -3053,7 +2429,7 @@ RDFGenericBuilderImpl::ScheduleReflow()
|
||||
rv = NS_NewTimer(getter_AddRefs(mTimer));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mTimer->Init(RDFGenericBuilderImpl::ForceTreeReflow, this, 1000);
|
||||
mTimer->Init(RDFGenericBuilderImpl::ForceTreeReflow, this, 100);
|
||||
NS_ADDREF(this); // the timer will hold a reference to the builder
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
@ -36,7 +36,30 @@
|
||||
nsIAtom* nsXULTreeElement::kSelectedAtom;
|
||||
int nsXULTreeElement::gRefCnt = 0;
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsXULTreeElement, nsXULElement, nsIDOMXULTreeElement);
|
||||
NS_IMPL_ADDREF_INHERITED(nsXULTreeElement, nsXULElement);
|
||||
NS_IMPL_RELEASE_INHERITED(nsXULTreeElement, nsXULElement);
|
||||
|
||||
nsresult
|
||||
nsXULTreeElement::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(nsCOMTypeInfo<nsIDOMXULTreeElement>::GetIID())) {
|
||||
*aResult = NS_STATIC_CAST(nsIDOMXULTreeElement*, this);
|
||||
}
|
||||
else if (aIID.Equals(nsCOMTypeInfo<nsIXULTreeContent>::GetIID())) {
|
||||
*aResult = NS_STATIC_CAST(nsIXULTreeContent*, this);
|
||||
}
|
||||
else {
|
||||
return nsXULElement::QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
NS_ADDREF(NS_REINTERPRET_CAST(nsISupports*, *aResult));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsXULTreeElement::nsXULTreeElement(nsIDOMXULElement* aOuter)
|
||||
:nsXULElement(aOuter)
|
||||
@ -306,7 +329,7 @@ nsXULTreeElement::InvertSelection()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsresult
|
||||
nsXULTreeElement::FireOnSelectHandler()
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mOuter);
|
||||
@ -319,7 +342,7 @@ nsXULTreeElement::FireOnSelectHandler()
|
||||
nsAutoString value;
|
||||
content->GetAttribute(kNameSpaceID_None, kSuppressSelectChange, value);
|
||||
if (value == "true")
|
||||
return;
|
||||
return NS_OK;
|
||||
|
||||
PRInt32 count = document->GetNumberOfShells();
|
||||
for (PRInt32 i = 0; i < count; i++) {
|
||||
@ -340,5 +363,7 @@ nsXULTreeElement::FireOnSelectHandler()
|
||||
|
||||
content->HandleDOMEvent(*aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -28,10 +28,12 @@
|
||||
|
||||
#include "nsXULElement.h"
|
||||
#include "nsIDOMXULTreeElement.h"
|
||||
#include "nsIXULTreeContent.h"
|
||||
#include "nsRDFDOMNodeList.h"
|
||||
|
||||
class nsXULTreeElement : public nsXULElement,
|
||||
public nsIDOMXULTreeElement
|
||||
public nsIDOMXULTreeElement,
|
||||
public nsIXULTreeContent
|
||||
{
|
||||
public:
|
||||
nsXULTreeElement(nsIDOMXULElement* aOuter);
|
||||
@ -51,11 +53,12 @@ public:
|
||||
// nsIDOMXULTreeElement interface
|
||||
NS_DECL_IDOMXULTREEELEMENT
|
||||
|
||||
// nsIXULTreeContent interface
|
||||
NS_IMETHOD FireOnSelectHandler();
|
||||
|
||||
static nsIAtom* kSelectedAtom;
|
||||
static int gRefCnt;
|
||||
|
||||
void FireOnSelectHandler();
|
||||
|
||||
protected:
|
||||
// Helpers
|
||||
void ClearItemSelectionInternal();
|
||||
|
Loading…
Reference in New Issue
Block a user