Inline nsIContent::GetParent() and GetDocument(). Also, remove unused return value on SetParent(). Bug 224331, r=sicking, sr=jst.

This commit is contained in:
bryner%brianryner.com 2003-11-07 09:47:23 +00:00
Родитель 932c74eca5
Коммит 78bc7f6016
21 изменённых файлов: 156 добавлений и 260 удалений

Просмотреть файл

@ -71,11 +71,14 @@ class nsIContent : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICONTENT_IID)
nsIContent()
: mDocument(nsnull), mParentPtrBits(0) { }
/**
* Get the document for this content.
* @return the document
*/
NS_IMETHOD_(nsIDocument*) GetDocument() const = 0;
nsIDocument* GetDocument() const { return mDocument; }
/**
* Set the document for this content.
@ -85,20 +88,31 @@ public:
* @param aCompileEventHandlers whether to initialize the event handlers in
* the document (used by nsXULElement)
*/
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) = 0;
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers)
{
mDocument = aDocument;
return NS_OK;
}
/**
* Get the parent content for this content.
* @return the parent, or null if no parent
*/
NS_IMETHOD_(nsIContent*) GetParent() const = 0;
nsIContent* GetParent() const
{
return NS_REINTERPRET_CAST(nsIContent *, mParentPtrBits & ~kParentBitMask);
}
/**
* Set the parent content for this content. (This does not add the child to
* its parent's child list.)
* its parent's child list.) This clobbers the low 2 bits of the parent
* pointer, so subclasses which use those bits should override this.
* @param aParent the new parent content to set (could be null)
*/
NS_IMETHOD SetParent(nsIContent* aParent) = 0;
NS_IMETHOD_(void) SetParent(nsIContent* aParent)
{
mParentPtrBits = NS_REINTERPRET_CAST(PtrBits, aParent);
}
/**
* Get whether this content is C++-generated anonymous content
@ -553,6 +567,15 @@ public:
*/
NS_IMETHOD DumpContent(FILE* out = stdout, PRInt32 aIndent = 0,PRBool aDumpAll=PR_TRUE) const = 0;
#endif
protected:
typedef long PtrBits;
// Subclasses may use the low two bits of mParentPtrBits to store other data
static const int kParentBitMask = ((PtrBits) 0x3);
nsIDocument *mDocument;
PtrBits mParentPtrBits;
};
#endif /* nsIContent_h___ */

Просмотреть файл

@ -127,8 +127,7 @@ public:
NS_DECL_NSIDOM3NODE
// nsIContent
NS_IMETHOD SetParent(nsIContent* aParent)
{ return NS_OK; }
NS_IMETHOD_(void) SetParent(nsIContent* aParent) { }
NS_IMETHOD SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString& aValue,
PRBool aNotify)

Просмотреть файл

@ -68,7 +68,7 @@ nsGenericDOMDataNode::Shutdown()
//----------------------------------------------------------------------
nsGenericDOMDataNode::nsGenericDOMDataNode()
: mText(), mDocument(nsnull), mParentPtrBits(0)
: mText()
{
}
@ -125,7 +125,7 @@ nsGenericDOMDataNode::GetParentNode(nsIDOMNode** aParentNode)
{
nsresult res = NS_OK;
nsIContent *parent_weak = GetParentWeak();
nsIContent *parent_weak = GetParent();
if (parent_weak) {
res = CallQueryInterface(parent_weak, aParentNode);
@ -148,7 +148,7 @@ nsGenericDOMDataNode::GetPreviousSibling(nsIDOMNode** aPrevSibling)
{
nsresult rv = NS_OK;
nsIContent *parent_weak = GetParentWeak();
nsIContent *parent_weak = GetParent();
nsIContent *sibling = nsnull;
if (parent_weak) {
@ -180,7 +180,7 @@ nsGenericDOMDataNode::GetNextSibling(nsIDOMNode** aNextSibling)
{
nsresult rv = NS_OK;
nsIContent *parent_weak = GetParentWeak();
nsIContent *parent_weak = GetParent();
nsIContent *sibling = nsnull;
if (parent_weak) {
@ -301,7 +301,7 @@ nsGenericDOMDataNode::LookupPrefix(const nsAString& aNamespaceURI,
{
aPrefix.Truncate();
nsIContent *parent_weak = GetParentWeak();
nsIContent *parent_weak = GetParent();
// DOM Data Node passes the query on to its parent
nsCOMPtr<nsIDOM3Node> node(do_QueryInterface(parent_weak));
@ -318,7 +318,7 @@ nsGenericDOMDataNode::LookupNamespaceURI(const nsAString& aNamespacePrefix,
{
aNamespaceURI.Truncate();
nsIContent *parent_weak = GetParentWeak();
nsIContent *parent_weak = GetParent();
// DOM Data Node passes the query on to its parent
nsCOMPtr<nsIDOM3Node> node(do_QueryInterface(parent_weak));
@ -624,18 +624,11 @@ nsGenericDOMDataNode::ToCString(nsAString& aBuf, PRInt32 aOffset,
}
#endif
NS_IMETHODIMP_(nsIDocument*)
nsGenericDOMDataNode::GetDocument() const
{
return mDocument;
}
NS_IMETHODIMP
nsGenericDOMDataNode::SetDocument(nsIDocument* aDocument, PRBool aDeep,
PRBool aCompileEventHandlers)
{
mDocument = aDocument;
nsIContent::SetDocument(aDocument, aDeep, aCompileEventHandlers);
if (mDocument && mText.IsBidi()) {
mDocument->SetBidiEnabled(PR_TRUE);
@ -644,28 +637,20 @@ nsGenericDOMDataNode::SetDocument(nsIDocument* aDocument, PRBool aDeep,
return NS_OK;
}
NS_IMETHODIMP_(nsIContent*)
nsGenericDOMDataNode::GetParent() const
{
return GetParentWeak();
}
NS_IMETHODIMP
NS_IMETHODIMP_(void)
nsGenericDOMDataNode::SetParent(nsIContent* aParent)
{
PtrBits new_bits = NS_REINTERPRET_CAST(PtrBits, aParent);
new_bits |= mParentPtrBits & PARENT_BIT_MASK;
new_bits |= mParentPtrBits & nsIContent::kParentBitMask;
mParentPtrBits = new_bits;
return NS_OK;
}
NS_IMETHODIMP_(PRBool)
nsGenericDOMDataNode::IsNativeAnonymous() const
{
nsIContent* parent = GetParentWeak();
nsIContent* parent = GetParent();
return parent && parent->IsNativeAnonymous();
}
@ -787,7 +772,7 @@ nsGenericDOMDataNode::HandleDOMEvent(nsIPresContext* aPresContext,
aFlags |= NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_CAPTURE;
}
nsIContent *parent_weak = GetParentWeak();
nsIContent *parent_weak = GetParent();
//Capturing stage evaluation
if (NS_EVENT_FLAG_CAPTURE & aFlags) {
@ -1059,7 +1044,7 @@ NS_IMETHODIMP
nsGenericDOMDataNode::GetBaseURL(nsIURI** aURI) const
{
// DOM Data Node inherits the base from its parent element/document
nsIContent* parent_weak = GetParentWeak();
nsIContent* parent_weak = GetParent();
if (parent_weak) {
return parent_weak->GetBaseURL(aURI);
}
@ -1121,7 +1106,7 @@ nsGenericDOMDataNode::SplitText(PRUint32 aOffset, nsIDOMText** aReturn)
return rv;
}
nsIContent* parentNode = GetParentWeak();
nsIContent* parentNode = GetParent();
if (parentNode) {
PRInt32 index = parentNode->IndexOf(this);

Просмотреть файл

@ -58,8 +58,6 @@ class nsURI;
#define PARENT_BIT_RANGELISTS ((PtrBits)0x1 << 0)
#define PARENT_BIT_LISTENERMANAGER ((PtrBits)0x1 << 1)
#define PARENT_BIT_MASK (PARENT_BIT_RANGELISTS | \
PARENT_BIT_LISTENERMANAGER)
class nsGenericDOMDataNode : public nsITextContent
{
@ -169,11 +167,9 @@ public:
const nsAString& aArg);
// Implementation for nsIContent
NS_IMETHOD_(nsIDocument*) GetDocument() const;
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep,
PRBool aCompileEventHandlers);
NS_IMETHOD_(nsIContent*) GetParent() const;
NS_IMETHOD SetParent(nsIContent* aParent);
NS_IMETHOD_(void) SetParent(nsIContent* aParent);
NS_IMETHOD_(PRBool) IsNativeAnonymous() const;
NS_IMETHOD_(void) SetNativeAnonymous(PRBool aAnonymous);
NS_IMETHOD GetNameSpaceID(PRInt32* aID) const;
@ -253,15 +249,7 @@ public:
static void Shutdown();
protected:
nsIContent *GetParentWeak() const
{
PtrBits bits = mParentPtrBits & ~PARENT_BIT_MASK;
return NS_REINTERPRET_CAST(nsIContent *, bits);
}
nsTextFragment mText;
nsIDocument* mDocument; // WEAK
private:
void LookupListenerManager(nsIEventListenerManager **aListenerManager) const;
@ -270,8 +258,6 @@ private:
void SetBidiStatus();
typedef long PtrBits;
void SetHasRangeList(PRBool aHasRangeList)
{
if (aHasRangeList) {
@ -301,10 +287,6 @@ private:
return (mParentPtrBits & PARENT_BIT_LISTENERMANAGER &&
nsGenericElement::sEventListenerManagersHash.ops);
}
// Weak parent pointer (nsIContent *) and bits for knowing if
// there's a rangelist or listener manager for this node
PtrBits mParentPtrBits;
};
//----------------------------------------------------------------------

Просмотреть файл

@ -837,8 +837,7 @@ nsGenericElement::Shutdown()
}
nsGenericElement::nsGenericElement()
: mDocument(nsnull), mParent(nsnull),
mFlagsOrSlots(GENERIC_ELEMENT_DOESNT_HAVE_DOMSLOTS)
: mFlagsOrSlots(GENERIC_ELEMENT_DOESNT_HAVE_DOMSLOTS)
{
}
@ -1044,8 +1043,8 @@ nsGenericElement::GetNodeType(PRUint16* aNodeType)
NS_IMETHODIMP
nsGenericElement::GetParentNode(nsIDOMNode** aParentNode)
{
if (mParent) {
return CallQueryInterface(mParent, aParentNode);
if (GetParent()) {
return CallQueryInterface(GetParent(), aParentNode);
}
if (mDocument) {
@ -1069,10 +1068,10 @@ nsGenericElement::GetPreviousSibling(nsIDOMNode** aPrevSibling)
nsIContent *sibling = nsnull;
nsresult rv = NS_OK;
if (mParent) {
PRInt32 pos = mParent->IndexOf(this);
if (GetParent()) {
PRInt32 pos = GetParent()->IndexOf(this);
if (pos > 0 ) {
sibling = mParent->GetChildAt(pos - 1);
sibling = GetParent()->GetChildAt(pos - 1);
}
} else if (mDocument) {
// Nodes that are just below the document (their parent is the
@ -1099,10 +1098,10 @@ nsGenericElement::GetNextSibling(nsIDOMNode** aNextSibling)
nsIContent *sibling = nsnull;
nsresult rv = NS_OK;
if (mParent) {
PRInt32 pos = mParent->IndexOf(this);
if (GetParent()) {
PRInt32 pos = GetParent()->IndexOf(this);
if (pos > -1 ) {
sibling = mParent->GetChildAt(pos + 1);
sibling = GetParent()->GetChildAt(pos + 1);
}
} else if (mDocument) {
// Nodes that are just below the document (their parent is the
@ -1669,13 +1668,6 @@ nsGenericElement::Normalize()
}
nsIDocument*
nsGenericElement::GetDocument() const
{
return mDocument;
}
void
nsGenericElement::SetDocumentInChildrenOf(nsIContent* aContent,
nsIDocument* aDocument,
@ -1740,7 +1732,7 @@ nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
}
}
mDocument = aDocument;
nsIContent::SetDocument(aDocument, aDeep, aCompileEventHandlers);
}
if (aDeep) {
@ -1751,22 +1743,15 @@ nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
}
nsIContent*
nsGenericElement::GetParent() const
{
return mParent;
}
nsresult
NS_IMETHODIMP_(void)
nsGenericElement::SetParent(nsIContent* aParent)
{
mParent = aParent;
nsIContent::SetParent(aParent);
if (aParent) {
nsIContent* bindingPar = aParent->GetBindingParent();
if (bindingPar)
SetBindingParent(bindingPar);
}
return NS_OK;
}
NS_IMETHODIMP_(PRBool)
@ -1848,8 +1833,8 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext,
if (bindingParent) {
// We're anonymous. We may potentially need to retarget
// our event if our parent is in a different scope.
if (mParent) {
if (mParent->GetBindingParent() != bindingParent)
if (GetParent()) {
if (GetParent()->GetBindingParent() != bindingParent)
retarget = PR_TRUE;
}
}
@ -1868,10 +1853,10 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext,
} else {
// if we didn't find an anonymous parent, use the explicit one,
// whether it's null or not...
parent = mParent;
parent = GetParent();
}
if (retarget || (parent.get() != mParent)) {
if (retarget || (parent.get() != GetParent())) {
if (!*aDOMEvent) {
// We haven't made a DOMEvent yet. Force making one now.
nsCOMPtr<nsIEventListenerManager> listenerManager;
@ -1901,7 +1886,7 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext,
privateEvent->SetOriginalTarget(oldTarget);
if (retarget) {
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(mParent);
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(GetParent());
privateEvent->SetTarget(target);
}
}
@ -1979,7 +1964,7 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext,
// retargeting.
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(*aDOMEvent);
if (privateEvent) {
nsCOMPtr<nsIDOMEventTarget> parentTarget(do_QueryInterface(mParent));
nsCOMPtr<nsIDOMEventTarget> parentTarget(do_QueryInterface(GetParent()));
privateEvent->SetTarget(parentTarget);
}
}
@ -2206,8 +2191,8 @@ nsGenericElement::GetBaseURL(nsIURI** aBaseURL) const
// Our base URL depends on whether we have an xml:base attribute, as
// well as on whether any of our ancestors do.
nsCOMPtr<nsIURI> parentBase;
if (mParent) {
mParent->GetBaseURL(getter_AddRefs(parentBase));
if (GetParent()) {
GetParent()->GetBaseURL(getter_AddRefs(parentBase));
} else if (doc) {
// No parent, so just use the document (we must be the root or not in the
// tree).

Просмотреть файл

@ -362,11 +362,9 @@ public:
static void Shutdown();
// nsIContent interface methods
NS_IMETHOD_(nsIDocument*) GetDocument() const;
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep,
PRBool aCompileEventHandlers);
NS_IMETHOD_(nsIContent*) GetParent() const;
NS_IMETHOD SetParent(nsIContent* aParent);
NS_IMETHOD_(void) SetParent(nsIContent* aParent);
NS_IMETHOD_(PRBool) IsNativeAnonymous() const;
NS_IMETHOD_(void) SetNativeAnonymous(PRBool aAnonymous);
NS_IMETHOD GetNameSpaceID(PRInt32* aNameSpaceID) const;
@ -705,16 +703,14 @@ protected:
return mDocument ? mDocument : mNodeInfo->GetDocument();
}
/**
* The document for this content
*/
nsIDocument* mDocument; // WEAK
nsIContent* GetParent() const {
// Override nsIContent::GetParent to be more efficient internally,
// since no subclasses of nsGenericElement use the low 2 bits of
// mParentPtrBits for anything.
return NS_REINTERPRET_CAST(nsIContent *, mParentPtrBits);
}
/**
* The parent content
*/
nsIContent* mParent; // WEAK
/**
* Information about this type of node
*/

Просмотреть файл

@ -83,10 +83,6 @@ public:
NS_DECL_ISUPPORTS
// Implementation for nsIContent
NS_IMETHOD_(nsIDocument*) GetDocument() const;
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers);
NS_IMETHOD_(nsIContent*) GetParent() const;
NS_IMETHOD SetParent(nsIContent* aParent);
NS_IMETHOD_(PRBool) IsNativeAnonymous() const { return PR_TRUE; }
NS_IMETHOD_(void) SetNativeAnonymous(PRBool aAnonymous) { }
@ -226,13 +222,18 @@ public:
void ToCString(nsAString& aBuf, PRInt32 aOffset, PRInt32 aLen) const;
nsIContent* GetParent() const {
// Override nsIContent::GetParent to be more efficient internally,
// since we don't use the low 2 bits of mParentPtrBits for anything.
return NS_REINTERPRET_CAST(nsIContent *, mParentPtrBits);
}
// Up pointer to the real content object that we are
// supporting. Sometimes there is work that we just can't do
// ourselves, so this is needed to ask the real object to do the
// work.
nsIContent* mContent;
nsIDocument* mDocument;
nsIContent* mParent;
nsTextFragment mText;
PRInt32 mNameSpaceID;
@ -259,8 +260,6 @@ NS_NewAttributeContent(nsIContent** aContent)
nsAttributeContent::nsAttributeContent()
: mText()
{
mDocument = nsnull;
mParent = nsnull;
mContent = nsnull;
mAttrName = nsnull;
}
@ -318,34 +317,6 @@ nsAttributeContent::ToCString(nsAString& aBuf, PRInt32 aOffset,
{
}
NS_IMETHODIMP_(nsIDocument*)
nsAttributeContent::GetDocument() const
{
return mDocument;
}
nsresult
nsAttributeContent::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers)
{
mDocument = aDocument;
//NS_IF_ADDREF(mDocument);
return NS_OK;
}
NS_IMETHODIMP_(nsIContent*)
nsAttributeContent::GetParent() const
{
return mParent;
}
nsresult
nsAttributeContent::SetParent(nsIContent* aParent)
{
mParent = aParent;
return NS_OK;
}
nsresult
nsAttributeContent::HandleDOMEvent(nsIPresContext* aPresContext,
nsEvent* aEvent,
@ -381,8 +352,8 @@ nsAttributeContent::GetRangeList(nsVoidArray** aResult) const
NS_IMETHODIMP
nsAttributeContent::GetBaseURL(nsIURI** aURI) const
{
if (mParent) {
return mParent->GetBaseURL(aURI);
if (GetParent()) {
return GetParent()->GetBaseURL(aURI);
}
if (mDocument) {

Просмотреть файл

@ -1387,7 +1387,7 @@ nsGenericHTMLElement::FindForm(nsIDOMHTMLFormElement **aForm)
return NS_OK;
}
nsresult
void
nsGenericHTMLElement::FindAndSetForm(nsIFormControl *aFormControl)
{
nsCOMPtr<nsIDOMHTMLFormElement> form;
@ -1395,10 +1395,8 @@ nsGenericHTMLElement::FindAndSetForm(nsIFormControl *aFormControl)
FindForm(getter_AddRefs(form));
if (form) {
return aFormControl->SetForm(form);
aFormControl->SetForm(form); // always succeeds
}
return NS_OK;
}
static PRBool
@ -3955,28 +3953,22 @@ nsGenericHTMLContainerFormElement::GetForm(nsIDOMHTMLFormElement** aForm)
return NS_OK;
}
NS_IMETHODIMP
NS_IMETHODIMP_(void)
nsGenericHTMLContainerFormElement::SetParent(nsIContent* aParent)
{
nsresult rv = NS_OK;
if (!aParent && mForm) {
SetForm(nsnull);
} else if (mDocument && aParent && (mParent || !mForm)) {
} else if (mDocument && aParent && (GetParent() || !mForm)) {
// If we have a new parent and either we had an old parent or we
// don't have a form, search for a containing form. If we didn't
// have an old parent, but we do have a form, we shouldn't do the
// search. In this case, someone (possibly the content sink) has
// already set the form for us.
rv = FindAndSetForm(this);
FindAndSetForm(this);
}
if (NS_SUCCEEDED(rv)) {
rv = nsGenericElement::SetParent(aParent);
}
return rv;
nsGenericElement::SetParent(aParent);
}
NS_IMETHODIMP
@ -3984,32 +3976,26 @@ nsGenericHTMLContainerFormElement::SetDocument(nsIDocument* aDocument,
PRBool aDeep,
PRBool aCompileEventHandlers)
{
nsresult rv = NS_OK;
// Save state before doing anything if the document is being removed
if (!aDocument) {
SaveState();
}
if (aDocument && mParent && !mForm) {
rv = FindAndSetForm(this);
if (aDocument && GetParent() && !mForm) {
FindAndSetForm(this);
} else if (!aDocument && mForm) {
// We got removed from document. We have a parent form. Check
// that the form is still in the document, and if so remove
// ourselves from the form. This keeps ghosts from appearing in
// the form's |elements| array
nsCOMPtr<nsIContent> formContent(do_QueryInterface(mForm, &rv));
nsCOMPtr<nsIContent> formContent(do_QueryInterface(mForm));
if (formContent && formContent->GetDocument()) {
SetForm(nsnull);
}
}
if (NS_SUCCEEDED(rv)) {
rv = nsGenericHTMLElement::SetDocument(aDocument, aDeep,
return nsGenericHTMLElement::SetDocument(aDocument, aDeep,
aCompileEventHandlers);
}
return rv;
}
@ -4198,16 +4184,12 @@ nsGenericHTMLLeafFormElement::GetForm(nsIDOMHTMLFormElement** aForm)
return NS_OK;
}
NS_IMETHODIMP
NS_IMETHODIMP_(void)
nsGenericHTMLLeafFormElement::SetParent(nsIContent* aParent)
{
nsresult rv = NS_OK;
PRBool old_parent = NS_PTR_TO_INT32(GetParent());
PRBool old_parent = NS_PTR_TO_INT32(mParent);
if (NS_SUCCEEDED(rv)) {
rv = nsGenericElement::SetParent(aParent);
}
nsGenericElement::SetParent(aParent);
if (!aParent && mForm) {
SetForm(nsnull);
@ -4218,10 +4200,8 @@ nsGenericHTMLLeafFormElement::SetParent(nsIContent* aParent)
// search. In this case, someone (possibly the content sink) has
// already set the form for us.
else if (mDocument && aParent && (old_parent || !mForm)) {
rv = FindAndSetForm(this);
FindAndSetForm(this);
}
return rv;
}
NS_IMETHODIMP
@ -4229,32 +4209,26 @@ nsGenericHTMLLeafFormElement::SetDocument(nsIDocument* aDocument,
PRBool aDeep,
PRBool aCompileEventHandlers)
{
nsresult rv = NS_OK;
// Save state before doing anything if the document is being removed
if (!aDocument) {
SaveState();
}
if (aDocument && mParent && !mForm) {
rv = FindAndSetForm(this);
if (aDocument && GetParent() && !mForm) {
FindAndSetForm(this);
} else if (!aDocument && mForm) {
// We got removed from document. We have a parent form. Check
// that the form is still in the document, and if so remove
// ourselves from the form. This keeps ghosts from appearing in
// the form's |elements| array
nsCOMPtr<nsIContent> formContent(do_QueryInterface(mForm, &rv));
nsCOMPtr<nsIContent> formContent(do_QueryInterface(mForm));
if (formContent && formContent->GetDocument()) {
SetForm(nsnull);
}
}
if (NS_SUCCEEDED(rv)) {
rv = nsGenericHTMLElement::SetDocument(aDocument, aDeep,
return nsGenericHTMLElement::SetDocument(aDocument, aDeep,
aCompileEventHandlers);
}
return rv;
}
NS_IMETHODIMP

Просмотреть файл

@ -672,7 +672,7 @@ public:
*
* @param aFormControl the form control to set the form for
*/
nsresult FindAndSetForm(nsIFormControl *aFormControl);
void FindAndSetForm(nsIFormControl *aFormControl);
/**
* See if the document being tested has nav-quirks mode enabled.
@ -957,7 +957,7 @@ public:
NS_IMETHOD RestoreState(nsIPresState* aState) { return NS_OK; }
// nsIContent
NS_IMETHOD SetParent(nsIContent *aParent);
NS_IMETHOD_(void) SetParent(nsIContent *aParent);
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep,
PRBool aCompileEventHandlers);
@ -1004,7 +1004,7 @@ public:
NS_IMETHOD RestoreState(nsIPresState* aState) { return NS_OK; }
// nsIContent
NS_IMETHOD SetParent(nsIContent *aParent);
NS_IMETHOD_(void) SetParent(nsIContent *aParent);
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep,
PRBool aCompileEventHandlers);

Просмотреть файл

@ -91,7 +91,7 @@ public:
NS_IMETHOD SetFrameLoader(nsIFrameLoader *aFrameLoader);
// nsIContent
NS_IMETHOD SetParent(nsIContent *aParent);
NS_IMETHOD_(void) SetParent(nsIContent *aParent);
NS_IMETHOD SetDocument(nsIDocument *aDocument, PRBool aDeep,
PRBool aCompileEventHandlers);
@ -274,7 +274,7 @@ nsHTMLIFrameElement::GetContentWindow(nsIDOMWindow** aContentWindow)
nsresult
nsHTMLIFrameElement::EnsureFrameLoader()
{
if (!mParent || !mDocument || mFrameLoader) {
if (!GetParent() || !mDocument || mFrameLoader) {
// If frame loader is there, we just keep it around, cached
return NS_OK;
}
@ -320,19 +320,18 @@ nsHTMLIFrameElement::LoadSrc()
}
NS_IMETHODIMP
NS_IMETHODIMP_(void)
nsHTMLIFrameElement::SetParent(nsIContent *aParent)
{
nsresult rv = nsGenericHTMLContainerElement::SetParent(aParent);
NS_ENSURE_SUCCESS(rv, rv);
nsGenericHTMLContainerElement::SetParent(aParent);
// When parent is being set to null on the element's destruction, do not
// call LoadSrc().
if (!mParent || !mDocument) {
return NS_OK;
if (!GetParent() || !mDocument) {
return;
}
return LoadSrc();
LoadSrc();
}
NS_IMETHODIMP
@ -359,7 +358,7 @@ nsHTMLIFrameElement::SetDocument(nsIDocument *aDocument, PRBool aDeep,
// When document is being set to null on the element's destruction,
// or when the document is being set to what the document already
// is, do not call LoadSrc().
if (!mParent || !aDocument || aDocument == old_doc) {
if (!GetParent() || !aDocument || aDocument == old_doc) {
return NS_OK;
}

Просмотреть файл

@ -143,7 +143,7 @@ public:
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep,
PRBool aCompileEventHandlers);
NS_IMETHOD SetParent(nsIContent* aParent);
NS_IMETHOD_(void) SetParent(nsIContent* aParent);
protected:
void GetImageFrame(nsIImageFrame** aImageFrame);
@ -272,7 +272,7 @@ nsHTMLImageElement::GetImageFrame(nsIImageFrame** aImageFrame)
{
*aImageFrame = nsnull;
// If we have no parent, then we won't have a frame yet
if (!mParent)
if (!GetParent())
return;
nsIFrame* frame = GetPrimaryFrame(PR_TRUE);
@ -645,7 +645,7 @@ nsHTMLImageElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
nsresult rv = nsGenericHTMLLeafElement::SetDocument(aDocument, aDeep,
aCompileEventHandlers);
if (documentChanging && mParent) {
if (documentChanging && GetParent()) {
// Our base URI may have changed; claim that our URI changed, and the
// nsImageLoadingContent will decide whether a new image load is warranted.
nsAutoString uri;
@ -657,10 +657,10 @@ nsHTMLImageElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
return rv;
}
NS_IMETHODIMP
NS_IMETHODIMP_(void)
nsHTMLImageElement::SetParent(nsIContent* aParent)
{
nsresult rv = nsGenericHTMLLeafElement::SetParent(aParent);
nsGenericHTMLLeafElement::SetParent(aParent);
if (aParent && mDocument) {
// Our base URI may have changed; claim that our URI changed, and the
// nsImageLoadingContent will decide whether a new image load is warranted.
@ -670,7 +670,6 @@ nsHTMLImageElement::SetParent(nsIContent* aParent)
ImageURIChanged(uri);
}
}
return rv;
}
NS_IMETHODIMP

Просмотреть файл

@ -192,7 +192,7 @@ public:
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep,
PRBool aCompileEventHandlers);
NS_IMETHOD SetParent(nsIContent* aParent);
NS_IMETHOD_(void) SetParent(nsIContent* aParent);
NS_IMETHOD SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString& aValue, PRBool aNotify) {
@ -1779,7 +1779,7 @@ nsHTMLInputElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
NS_ENSURE_SUCCESS(rv, rv);
if (mType == NS_FORM_INPUT_IMAGE &&
documentChanging && aDocument && mParent) {
documentChanging && aDocument && GetParent()) {
// Our base URI may have changed; claim that our URI changed, and the
// nsImageLoadingContent will decide whether a new image load is warranted.
nsAutoString uri;
@ -1805,10 +1805,10 @@ nsHTMLInputElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
return NS_OK;
}
NS_IMETHODIMP
NS_IMETHODIMP_(void)
nsHTMLInputElement::SetParent(nsIContent* aParent)
{
nsresult rv = nsGenericHTMLLeafFormElement::SetParent(aParent);
nsGenericHTMLLeafFormElement::SetParent(aParent);
if (mType == NS_FORM_INPUT_IMAGE && aParent && mDocument) {
// Our base URI may have changed; claim that our URI changed, and the
// nsImageLoadingContent will decide whether a new image load is warranted.
@ -1818,7 +1818,6 @@ nsHTMLInputElement::SetParent(nsIContent* aParent)
ImageURIChanged(uri);
}
}
return rv;
}

Просмотреть файл

@ -215,7 +215,7 @@ void
nsHTMLOptGroupElement::GetSelect(nsISelectElement **aSelectElement)
{
*aSelectElement = nsnull;
for (nsIContent* parent = mParent; parent; parent = parent->GetParent()) {
for (nsIContent* parent = GetParent(); parent; parent = parent->GetParent()) {
CallQueryInterface(parent, aSelectElement);
if (*aSelectElement) {
break;

Просмотреть файл

@ -643,7 +643,7 @@ nsHTMLOptionElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
nsIFormControlFrame *
nsHTMLOptionElement::GetSelectFrame() const
{
if (!mParent || !mDocument) {
if (!GetParent() || !mDocument) {
return nsnull;
}
@ -666,7 +666,7 @@ nsHTMLOptionElement::GetSelect(nsIDOMHTMLSelectElement **aSelectElement) const
{
*aSelectElement = nsnull;
for (nsIContent* parent = mParent; parent; parent = parent->GetParent()) {
for (nsIContent* parent = GetParent(); parent; parent = parent->GetParent()) {
CallQueryInterface(parent, aSelectElement);
if (*aSelectElement) {
break;

Просмотреть файл

@ -645,7 +645,7 @@ nsHTMLScriptElement::GetLineNumber(PRUint32* aLineNumber)
void
nsHTMLScriptElement::MaybeProcessScript()
{
if (mIsEvaluated || mEvaluating || !mDocument || !mParent) {
if (mIsEvaluated || mEvaluating || !mDocument || !GetParent()) {
return;
}

Просмотреть файл

@ -207,8 +207,8 @@ nsHTMLTableCellElement::GetTable()
{
nsIContent *result = nsnull;
if (mParent) { // mParent should be a row
nsIContent* section = mParent->GetParent();
if (GetParent()) { // GetParent() should be a row
nsIContent* section = GetParent()->GetParent();
if (section) {
if (section->IsContentOfType(eHTML) &&
section->GetNodeInfo()->Equals(nsHTMLAtoms::table)) {

Просмотреть файл

@ -319,8 +319,8 @@ nsSVGElement::GetNodeType(PRUint16* aNodeType)
NS_IMETHODIMP
nsSVGElement::GetParentNode(nsIDOMNode** aParentNode)
{
if (mParent) {
return CallQueryInterface(mParent, aParentNode);
if (GetParent()) {
return CallQueryInterface(GetParent(), aParentNode);
}
if (mDocument) {
// we're the root content
@ -533,7 +533,7 @@ nsSVGElement::GetOwnerSVGElement(nsIDOMSVGSVGElement * *aOwnerSVGElement)
if (!parent) {
// if we didn't find an anonymous parent, use the explicit one,
// whether it's null or not...
parent = mParent;
parent = GetParent();
}
while (parent) {

Просмотреть файл

@ -128,7 +128,7 @@ NS_IMETHODIMP nsSVGGraphicElement::GetCTM(nsIDOMSVGMatrix **_retval)
if (!parent) {
// if we didn't find an anonymous parent, use the explicit one,
// whether it's null or not...
parent = mParent;
parent = GetParent();
}
while (parent) {
@ -203,7 +203,7 @@ NS_IMETHODIMP nsSVGGraphicElement::GetScreenCTM(nsIDOMSVGMatrix **_retval)
if (!parent) {
// if we didn't find an anonymous parent, use the explicit one,
// whether it's null or not...
parent = mParent;
parent = GetParent();
}
while (parent) {

Просмотреть файл

@ -801,7 +801,7 @@ nsSVGSVGElement::GetCTM(nsIDOMSVGMatrix **_retval)
if (!parent) {
// if we didn't find an anonymous parent, use the explicit one,
// whether it's null or not...
parent = mParent;
parent = GetParent();
}
while (parent) {
@ -874,7 +874,7 @@ nsSVGSVGElement::GetScreenCTM(nsIDOMSVGMatrix **_retval)
if (!parent) {
// if we didn't find an anonymous parent, use the explicit one,
// whether it's null or not...
parent = mParent;
parent = GetParent();
}
while (parent) {

Просмотреть файл

@ -420,8 +420,6 @@ PRUint32 nsXULPrototypeAttribute::gNumCacheFills;
nsXULElement::nsXULElement()
: mPrototype(nsnull),
mDocument(nsnull),
mParent(nsnull),
mBindingParent(nsnull),
mSlots(nsnull)
{
@ -452,9 +450,6 @@ nsXULElement::~nsXULElement()
delete mSlots;
//NS_IF_RELEASE(mDocument); // not refcounted
//NS_IF_RELEASE(mParent) // not refcounted
// Force child's parent to be null. This ensures that we don't
// have dangling pointers if a child gets leaked.
for (PRInt32 i = mChildren.Count() - 1; i >= 0; --i) {
@ -683,8 +678,8 @@ nsXULElement::GetNodeType(PRUint16* aNodeType)
NS_IMETHODIMP
nsXULElement::GetParentNode(nsIDOMNode** aParentNode)
{
if (mParent) {
return CallQueryInterface(mParent, aParentNode);
if (GetParent()) {
return CallQueryInterface(GetParent(), aParentNode);
}
if (mDocument) {
@ -771,10 +766,10 @@ nsXULElement::GetLastChild(nsIDOMNode** aLastChild)
NS_IMETHODIMP
nsXULElement::GetPreviousSibling(nsIDOMNode** aPreviousSibling)
{
if (nsnull != mParent) {
PRInt32 pos = mParent->IndexOf(this);
if (GetParent()) {
PRInt32 pos = GetParent()->IndexOf(this);
if (pos > 0) {
nsIContent *prev = mParent->GetChildAt(--pos);
nsIContent *prev = GetParent()->GetChildAt(--pos);
if (prev) {
nsresult rv = CallQueryInterface(prev, aPreviousSibling);
NS_ASSERTION(*aPreviousSibling, "not a DOM node");
@ -793,10 +788,10 @@ nsXULElement::GetPreviousSibling(nsIDOMNode** aPreviousSibling)
NS_IMETHODIMP
nsXULElement::GetNextSibling(nsIDOMNode** aNextSibling)
{
if (nsnull != mParent) {
PRInt32 pos = mParent->IndexOf(this);
if (GetParent()) {
PRInt32 pos = GetParent()->IndexOf(this);
if (pos > -1) {
nsIContent *next = mParent->GetChildAt(++pos);
nsIContent *next = GetParent()->GetChildAt(++pos);
if (next) {
nsresult rv = CallQueryInterface(next, aNextSibling);
NS_ASSERTION(*aNextSibling, "not a DOM Node");
@ -1720,12 +1715,6 @@ nsXULElement::CompileEventHandler(nsIScriptContext* aContext,
// nsIContent interface
//
NS_IMETHODIMP_(nsIDocument*)
nsXULElement::GetDocument() const
{
return mDocument;
}
nsresult
nsXULElement::AddListenerFor(nsINodeInfo *aNodeInfo,
PRBool aCompileEventHandlers)
@ -1795,7 +1784,7 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileE
mListenerManager->SetListenerTarget(nsnull);
mListenerManager = nsnull;
mDocument = aDocument; // not refcounted
nsIContent::SetDocument(aDocument, aDeep, aCompileEventHandlers);
if (mDocument) {
// When we SetDocument(), we're either adding an element
@ -1848,23 +1837,15 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileE
return NS_OK;
}
NS_IMETHODIMP_(nsIContent*)
nsXULElement::GetParent() const
{
return mParent;
}
NS_IMETHODIMP
NS_IMETHODIMP_(void)
nsXULElement::SetParent(nsIContent* aParent)
{
mParent = aParent; // no refcount
nsIContent::SetParent(aParent);
if (aParent) {
nsIContent* bindingPar = aParent->GetBindingParent();
if (bindingPar)
SetBindingParent(bindingPar);
}
return NS_OK;
}
NS_IMETHODIMP_(PRBool)
@ -3082,7 +3063,7 @@ nsXULElement::HandleDOMEvent(nsIPresContext* aPresContext,
if (bindingParent) {
// We're anonymous. We may potentially need to retarget
// our event if our parent is in a different scope.
if (mParent && mParent->GetBindingParent() != bindingParent) {
if (GetParent() && GetParent()->GetBindingParent() != bindingParent) {
retarget = PR_TRUE;
}
}
@ -3102,10 +3083,10 @@ nsXULElement::HandleDOMEvent(nsIPresContext* aPresContext,
else {
// if we didn't find an anonymous parent, use the explicit one,
// whether it's null or not...
parent = mParent;
parent = GetParent();
}
if (retarget || (parent != mParent)) {
if (retarget || (parent != GetParent())) {
if (!*aDOMEvent) {
// We haven't made a DOMEvent yet. Force making one now.
nsCOMPtr<nsIEventListenerManager> listenerManager;
@ -3134,7 +3115,7 @@ nsXULElement::HandleDOMEvent(nsIPresContext* aPresContext,
privateEvent->SetOriginalTarget(oldTarget);
if (retarget) {
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(mParent);
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(GetParent());
privateEvent->SetTarget(target);
}
}
@ -3172,7 +3153,7 @@ nsXULElement::HandleDOMEvent(nsIPresContext* aPresContext,
// The event originated beneath us, and we need to perform a retargeting.
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(*aDOMEvent);
if (privateEvent) {
nsCOMPtr<nsIDOMEventTarget> parentTarget(do_QueryInterface(mParent));
nsCOMPtr<nsIDOMEventTarget> parentTarget(do_QueryInterface(GetParent()));
privateEvent->SetTarget(parentTarget);
}
}
@ -4155,7 +4136,7 @@ nsXULElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
NS_IMETHODIMP
nsXULElement::GetParentTree(nsIDOMXULMultiSelectControlElement** aTreeElement)
{
for (nsIContent* current = mParent; current; current = current->GetParent()) {
for (nsIContent* current = GetParent(); current; current = current->GetParent()) {
nsCOMPtr<nsIAtom> tag;
current->GetTag(getter_AddRefs(tag));
if (tag == nsXULAtoms::listbox) {

Просмотреть файл

@ -416,10 +416,8 @@ public:
NS_DECL_ISUPPORTS
// nsIContent (from nsIStyledContent)
NS_IMETHOD_(nsIDocument*) GetDocument() const;
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers);
NS_IMETHOD_(nsIContent*) GetParent() const;
NS_IMETHOD SetParent(nsIContent* aParent);
NS_IMETHOD_(void) SetParent(nsIContent* aParent);
NS_IMETHOD_(PRBool) IsNativeAnonymous() const;
NS_IMETHOD_(void) SetNativeAnonymous(PRBool aAnonymous);
NS_IMETHOD_(PRBool) CanContainChildren() const;
@ -548,11 +546,16 @@ protected:
nsresult AddPopupListener(nsIAtom* aName);
nsIContent* GetParent() const {
// Override nsIContent::GetParent to be more efficient internally,
// we don't use the low 2 bits of mParentPtrBits for anything.
return NS_REINTERPRET_CAST(nsIContent *, mParentPtrBits);
}
protected:
// Required fields
nsXULPrototypeElement* mPrototype;
nsIDocument* mDocument; // [WEAK]
nsIContent* mParent; // [WEAK]
nsSmallVoidArray mChildren; // [OWNER]
nsCOMPtr<nsIEventListenerManager> mListenerManager; // [OWNER]