зеркало из https://github.com/mozilla/pjs.git
Fix for bug 27382 (ownerDocument of orphan text and attr nodes is null). r/sr=jst.
This commit is contained in:
Родитель
fc956e069b
Коммит
0836738940
|
@ -130,10 +130,6 @@
|
|||
#define NS_CSS_LOADER_CID \
|
||||
{ 0xeaca2576, 0x0d4a, 0x11d3, { 0x9d, 0x7e, 0x00, 0x60, 0x08, 0x8f, 0x9f, 0xf7 } }
|
||||
|
||||
// {96882B71-8A27-11d2-8EAF-00805F29F370}
|
||||
#define NS_TEXTNODE_CID \
|
||||
{ 0x96882b71, 0x8a27, 0x11d2, { 0x8e, 0xaf, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {96882B72-8A27-11d2-8EAF-00805F29F370}
|
||||
#define NS_SELECTION_CID \
|
||||
{ 0x96882b72, 0x8a27, 0x11d2, { 0x8e, 0xaf, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
|
||||
class nsAString;
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsINodeInfo;
|
||||
class imgIRequest;
|
||||
|
||||
|
@ -59,17 +60,32 @@ NS_NewElement(nsIContent** aResult, PRInt32 aElementType,
|
|||
nsresult
|
||||
NS_NewXMLElement(nsIContent** aResult, nsINodeInfo* aNodeInfo);
|
||||
|
||||
/**
|
||||
* There's no need to pass in aOwnerDocument if the node is going to be
|
||||
* inserted *immediately* after creation.
|
||||
*/
|
||||
nsresult
|
||||
NS_NewXMLProcessingInstruction(nsIContent** aInstancePtrResult,
|
||||
const nsAString& aTarget,
|
||||
const nsAString& aData);
|
||||
const nsAString& aData,
|
||||
nsIDocument *aOwnerDocument = nsnull);
|
||||
|
||||
/**
|
||||
* There's no need to pass in aOwnerDocument if the node is going to be
|
||||
* inserted *immediately* after creation.
|
||||
*/
|
||||
nsresult
|
||||
NS_NewXMLStylesheetProcessingInstruction(nsIContent** aInstancePtrResult,
|
||||
const nsAString& aData);
|
||||
const nsAString& aData,
|
||||
nsIDocument *aOwnerDocument = nsnull);
|
||||
|
||||
/**
|
||||
* There's no need to pass in aOwnerDocument if the node is going to be
|
||||
* inserted *immediately* after creation.
|
||||
*/
|
||||
nsresult
|
||||
NS_NewXMLCDATASection(nsIContent** aInstancePtrResult);
|
||||
NS_NewXMLCDATASection(nsIContent** aInstancePtrResult,
|
||||
nsIDocument *aOwnerDocument = nsnull);
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLElement(nsIContent** aResult, nsINodeInfo *aNodeInfo);
|
||||
|
|
|
@ -59,8 +59,8 @@ class nsIURI;
|
|||
|
||||
// IID for the nsIContent interface
|
||||
#define NS_ICONTENT_IID \
|
||||
{ 0x78030220, 0x9447, 0x11d1, \
|
||||
{0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
{ 0x658d21a4, 0xc446, 0x11d8, \
|
||||
{ 0x84, 0xe1, 0x00, 0x0a, 0x95, 0xdc, 0x23, 0x4c } }
|
||||
|
||||
/**
|
||||
* A node of content in a document's content model. This interface
|
||||
|
@ -71,13 +71,14 @@ public:
|
|||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICONTENT_IID)
|
||||
|
||||
nsIContent()
|
||||
: mDocument(nsnull), mParentPtrBits(0) { }
|
||||
: mParentPtrBits(0) { }
|
||||
|
||||
/**
|
||||
* DEPRECATED - Use GetCurrentDoc or GetOwnerDoc.
|
||||
* Get the document for this content.
|
||||
* @return the document
|
||||
*/
|
||||
nsIDocument* GetDocument() const { return mDocument; }
|
||||
virtual nsIDocument* GetDocument() const = 0;
|
||||
|
||||
/**
|
||||
* Set the document for this content.
|
||||
|
@ -88,16 +89,40 @@ public:
|
|||
* the document (used by nsXULElement)
|
||||
*/
|
||||
virtual void SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
PRBool aCompileEventHandlers) = 0;
|
||||
|
||||
/**
|
||||
* Returns true if the content has an ancestor that is a document.
|
||||
*
|
||||
* @return whether this content is in a document tree
|
||||
*/
|
||||
virtual PRBool IsInDoc() const = 0;
|
||||
|
||||
/**
|
||||
* Get the document that this content is currently in, if any. This will be
|
||||
* null if the content has no ancestor that is a document.
|
||||
*
|
||||
* @return the current document
|
||||
*/
|
||||
nsIDocument *GetCurrentDoc() const
|
||||
{
|
||||
mDocument = aDocument;
|
||||
// XXX This should become:
|
||||
// return IsInDoc() ? GetOwnerDoc() : nsnull;
|
||||
return GetDocument();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ownerDocument for this content.
|
||||
*
|
||||
* @return the ownerDocument
|
||||
*/
|
||||
virtual nsIDocument *GetOwnerDoc() const = 0;
|
||||
|
||||
/**
|
||||
* Get the parent content for this content.
|
||||
* @return the parent, or null if no parent
|
||||
*/
|
||||
nsIContent* GetParent() const
|
||||
virtual nsIContent* GetParent() const
|
||||
{
|
||||
return NS_REINTERPRET_CAST(nsIContent *, mParentPtrBits & ~kParentBitMask);
|
||||
}
|
||||
|
@ -108,10 +133,7 @@ public:
|
|||
* pointer, so subclasses which use those bits should override this.
|
||||
* @param aParent the new parent content to set (could be null)
|
||||
*/
|
||||
virtual void SetParent(nsIContent* aParent)
|
||||
{
|
||||
mParentPtrBits = NS_REINTERPRET_CAST(PtrBits, aParent);
|
||||
}
|
||||
virtual void SetParent(nsIContent* aParent) = 0;
|
||||
|
||||
/**
|
||||
* Get whether this content is C++-generated anonymous content
|
||||
|
@ -623,7 +645,6 @@ protected:
|
|||
// Subclasses may use the low two bits of mParentPtrBits to store other data
|
||||
enum { kParentBitMask = 0x3 };
|
||||
|
||||
nsIDocument *mDocument;
|
||||
PtrBits mParentPtrBits;
|
||||
};
|
||||
|
||||
|
|
|
@ -89,8 +89,8 @@ class nsIHTMLCSSStyleSheet;
|
|||
// IID for the nsIDocument interface
|
||||
// c59c70e5-28d1-494b-9f8e-c18368d09ebc
|
||||
#define NS_IDOCUMENT_IID \
|
||||
{ 0xc59c70e5, 0x28d1, 0x494b, \
|
||||
{ 0x9f, 0x8e, 0xc1, 0x83, 0x68, 0xd0, 0x9e, 0xbc } }
|
||||
{ 0x9f670164, 0xc446, 0x11d8, \
|
||||
{ 0x84, 0xe1, 0x00, 0x0a, 0x95, 0xdc, 0x23, 0x4c } }
|
||||
|
||||
// The base value for the content ID counter.
|
||||
// This counter is used by the document to
|
||||
|
@ -608,11 +608,13 @@ public:
|
|||
PRBool aDocumentDefaultType,
|
||||
nsIContent** aResult) = 0;
|
||||
|
||||
// Get the security info (i.e. SSL state etc) that the document got
|
||||
// from the channel/document that created the content of the
|
||||
// document.
|
||||
//
|
||||
// @see nsIChannel
|
||||
/**
|
||||
* Get the security info (i.e. SSL state etc) that the document got
|
||||
* from the channel/document that created the content of the
|
||||
* document.
|
||||
*
|
||||
* @see nsIChannel
|
||||
*/
|
||||
nsISupports *GetSecurityInfo()
|
||||
{
|
||||
return mSecurityInfo;
|
||||
|
@ -624,6 +626,27 @@ public:
|
|||
*/
|
||||
virtual PRInt32 GetDefaultNamespaceID() const = 0;
|
||||
|
||||
/**
|
||||
* Returns false if aContent is an orphan (an orphan is a node that is not a
|
||||
* descendant of this document but whose ownerDocument pointer points to this
|
||||
* document).
|
||||
*/
|
||||
virtual PRBool IsOrphan(nsIContent* aContent) = 0;
|
||||
|
||||
/**
|
||||
* Add aContent as an orphan of this document (an orphan is a node that is
|
||||
* not a descendant of this document but whose ownerDocument pointer points
|
||||
* to this document).
|
||||
*/
|
||||
virtual PRBool AddOrphan(nsIContent* aContent) = 0;
|
||||
|
||||
/**
|
||||
* Remove aContent as an orphan of this document (an orphan is a node that is
|
||||
* not a descendant of this document but whose ownerDocument pointer points
|
||||
* to this document).
|
||||
*/
|
||||
virtual void RemoveOrphan(nsIContent* aContent) = 0;
|
||||
|
||||
protected:
|
||||
nsString mDocumentTitle;
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
|
|
|
@ -88,12 +88,6 @@ public:
|
|||
*/
|
||||
virtual PRBool IsOnlyWhitespace() = 0;
|
||||
|
||||
/**
|
||||
* Clone this content node. Unlike the nsIDOMNode equivalent, this
|
||||
* method allows you to specify whether to copy the text as well.
|
||||
*/
|
||||
virtual already_AddRefed<nsITextContent> CloneContent(PRBool aCloneText) = 0;
|
||||
|
||||
/**
|
||||
* Append the text content to aResult.
|
||||
*/
|
||||
|
@ -101,11 +95,19 @@ public:
|
|||
};
|
||||
|
||||
// XXX These belong elsewhere
|
||||
/**
|
||||
* There's no need to pass in aOwnerDocument if the node is going to be
|
||||
* inserted *immediately* after creation.
|
||||
*/
|
||||
nsresult
|
||||
NS_NewTextNode(nsITextContent** aResult);
|
||||
NS_NewTextNode(nsITextContent **aResult, nsIDocument *aOwnerDocument = nsnull);
|
||||
|
||||
/**
|
||||
* There's no need to pass in aOwnerDocument if the node is going to be
|
||||
* inserted *immediately* after creation.
|
||||
*/
|
||||
nsresult
|
||||
NS_NewCommentNode(nsIContent** aResult);
|
||||
NS_NewCommentNode(nsIContent **aResult, nsIDocument *aOwnerDocument = nsnull);
|
||||
|
||||
|
||||
#endif /* nsITextContent_h___ */
|
||||
|
|
|
@ -72,7 +72,9 @@ nsAttrAndChildArray::~nsAttrAndChildArray()
|
|||
return;
|
||||
}
|
||||
|
||||
Clear();
|
||||
NS_ASSERTION(!mImpl->mMappedAttrs &&
|
||||
mImpl->mAttrAndChildCount == 0,
|
||||
"Call nsAttrAndChildArray::Clear() before destruction.");
|
||||
|
||||
PR_Free(mImpl);
|
||||
}
|
||||
|
|
|
@ -108,13 +108,12 @@ public:
|
|||
void WalkMappedAttributeStyleRules(nsRuleWalker* aRuleWalker);
|
||||
|
||||
void Compact();
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
nsAttrAndChildArray(const nsAttrAndChildArray& aOther); // Not to be implemented
|
||||
nsAttrAndChildArray& operator=(const nsAttrAndChildArray& aOther); // Not to be implemented
|
||||
|
||||
void Clear();
|
||||
|
||||
PRUint32 NonMappedAttrCount() const;
|
||||
PRUint32 MappedAttrCount() const;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "nsGenericDOMDataNode.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIDocument.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ class nsCommentNode : public nsGenericDOMDataNode,
|
|||
public nsIDOMComment
|
||||
{
|
||||
public:
|
||||
nsCommentNode();
|
||||
nsCommentNode(nsIDocument *aDocument);
|
||||
virtual ~nsCommentNode();
|
||||
|
||||
// nsISupports
|
||||
|
@ -73,22 +73,29 @@ public:
|
|||
}
|
||||
#endif
|
||||
|
||||
// nsITextContent
|
||||
virtual already_AddRefed<nsITextContent> CloneContent(PRBool aCloneText);
|
||||
virtual already_AddRefed<nsITextContent> CloneContent(PRBool aCloneText,
|
||||
nsIDocument *aOwnerDocument);
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewCommentNode(nsIContent** aInstancePtrResult)
|
||||
NS_NewCommentNode(nsIContent** aInstancePtrResult, nsIDocument *aOwnerDocument)
|
||||
{
|
||||
*aInstancePtrResult = new nsCommentNode();
|
||||
NS_ENSURE_TRUE(*aInstancePtrResult, NS_ERROR_OUT_OF_MEMORY);
|
||||
*aInstancePtrResult = nsnull;
|
||||
|
||||
NS_ADDREF(*aInstancePtrResult);
|
||||
nsCOMPtr<nsIContent> instance = new nsCommentNode(aOwnerDocument);
|
||||
NS_ENSURE_TRUE(instance, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (aOwnerDocument && !aOwnerDocument->AddOrphan(instance)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
instance.swap(*aInstancePtrResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCommentNode::nsCommentNode()
|
||||
nsCommentNode::nsCommentNode(nsIDocument *aDocument)
|
||||
: nsGenericDOMDataNode(aDocument)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -146,16 +153,16 @@ nsCommentNode::GetNodeType(PRUint16* aNodeType)
|
|||
NS_IMETHODIMP
|
||||
nsCommentNode::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsCOMPtr<nsITextContent> textContent = CloneContent(PR_TRUE);
|
||||
nsCOMPtr<nsITextContent> textContent = CloneContent(PR_TRUE, GetOwnerDoc());
|
||||
NS_ENSURE_TRUE(textContent, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return CallQueryInterface(textContent, aReturn);
|
||||
}
|
||||
|
||||
already_AddRefed<nsITextContent>
|
||||
nsCommentNode::CloneContent(PRBool aCloneText)
|
||||
nsCommentNode::CloneContent(PRBool aCloneText, nsIDocument *aOwnerDocument)
|
||||
{
|
||||
nsCommentNode* it = new nsCommentNode();
|
||||
nsCommentNode* it = new nsCommentNode(aOwnerDocument);
|
||||
if (!it)
|
||||
return nsnull;
|
||||
|
||||
|
@ -165,6 +172,10 @@ nsCommentNode::CloneContent(PRBool aCloneText)
|
|||
|
||||
NS_ADDREF(it);
|
||||
|
||||
if (aOwnerDocument && !aOwnerDocument->AddOrphan(it)) {
|
||||
NS_RELEASE(it);
|
||||
}
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
|
@ -172,7 +183,7 @@ nsCommentNode::CloneContent(PRBool aCloneText)
|
|||
void
|
||||
nsCommentNode::List(FILE* out, PRInt32 aIndent) const
|
||||
{
|
||||
NS_PRECONDITION(mDocument, "bad content");
|
||||
NS_PRECONDITION(IsInDoc(), "bad content");
|
||||
|
||||
PRInt32 indx;
|
||||
for (indx = aIndent; --indx >= 0; ) fputs(" ", out);
|
||||
|
|
|
@ -245,6 +245,7 @@ nsDOMAttribute::GetFirstChild(nsIDOMNode** aFirstChild)
|
|||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
// XXX We should be setting |this| as the parent of the textnode!
|
||||
result = CallQueryInterface(content, &mChild);
|
||||
}
|
||||
mChild->SetData(value);
|
||||
|
|
|
@ -73,6 +73,7 @@ nsDOMDocumentType::nsDOMDocumentType(nsIAtom *aName,
|
|||
const nsAString& aPublicId,
|
||||
const nsAString& aSystemId,
|
||||
const nsAString& aInternalSubset) :
|
||||
nsGenericDOMDataNode(nsnull),
|
||||
mName(aName),
|
||||
mEntities(aEntities),
|
||||
mNotations(aNotations),
|
||||
|
@ -206,11 +207,3 @@ nsDOMDocumentType::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
|||
|
||||
return CallQueryInterface(it, aReturn);
|
||||
}
|
||||
|
||||
already_AddRefed<nsITextContent>
|
||||
nsDOMDocumentType::CloneContent(PRBool aCloneText)
|
||||
{
|
||||
NS_ERROR("Huh, this should never be called!");
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
|
|
@ -74,9 +74,6 @@ public:
|
|||
// nsIContent
|
||||
virtual nsIAtom *Tag() const;
|
||||
|
||||
// nsITextContent
|
||||
virtual already_AddRefed<nsITextContent> CloneContent(PRBool aCloneText);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIAtom> mName;
|
||||
nsCOMPtr<nsIDOMNamedNodeMap> mEntities;
|
||||
|
|
|
@ -499,6 +499,14 @@ NS_IMPL_ADDREF_USING_AGGREGATOR(nsXPathDocumentTearoff, mDocument)
|
|||
NS_IMPL_RELEASE_USING_AGGREGATOR(nsXPathDocumentTearoff, mDocument)
|
||||
|
||||
|
||||
class OrphansEntry : public PLDHashEntryHdr
|
||||
{
|
||||
public:
|
||||
nsIContent *mKey; // must be first, to look like PLDHashEntryStub
|
||||
};
|
||||
|
||||
PLDHashTable nsDocument::sOrphans;
|
||||
|
||||
// ==================================================================
|
||||
// =
|
||||
// ==================================================================
|
||||
|
@ -554,6 +562,8 @@ nsDocument::~nsDocument()
|
|||
mSubDocuments = nsnull;
|
||||
}
|
||||
|
||||
RemoveOrphans();
|
||||
|
||||
if (mRootContent) {
|
||||
if (mRootContent->GetDocument()) {
|
||||
// The root content still has a pointer back to the document,
|
||||
|
@ -673,6 +683,15 @@ NS_INTERFACE_MAP_END
|
|||
NS_IMPL_ADDREF(nsDocument)
|
||||
NS_IMPL_RELEASE(nsDocument)
|
||||
|
||||
// static
|
||||
void
|
||||
nsDocument::Shutdown()
|
||||
{
|
||||
if (sOrphans.entrySize) {
|
||||
PL_DHashTableFinish(&sOrphans);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocument::Init()
|
||||
{
|
||||
|
@ -748,6 +767,8 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup)
|
|||
mSubDocuments = nsnull;
|
||||
}
|
||||
|
||||
RemoveOrphans();
|
||||
|
||||
mRootContent = nsnull;
|
||||
PRInt32 count, i;
|
||||
count = mChildren.Count();
|
||||
|
@ -1787,6 +1808,8 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject)
|
|||
|
||||
mIsGoingAway = PR_TRUE;
|
||||
|
||||
RemoveOrphans();
|
||||
|
||||
for (indx = 0; indx < count; ++indx) {
|
||||
mChildren[indx]->SetDocument(nsnull, PR_TRUE, PR_TRUE);
|
||||
}
|
||||
|
@ -2309,7 +2332,7 @@ nsDocument::CreateTextNode(const nsAString& aData, nsIDOMText** aReturn)
|
|||
*aReturn = nsnull;
|
||||
|
||||
nsCOMPtr<nsITextContent> text;
|
||||
nsresult rv = NS_NewTextNode(getter_AddRefs(text));
|
||||
nsresult rv = NS_NewTextNode(getter_AddRefs(text), this);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = CallQueryInterface(text, aReturn);
|
||||
|
@ -2331,7 +2354,7 @@ nsDocument::CreateComment(const nsAString& aData, nsIDOMComment** aReturn)
|
|||
*aReturn = nsnull;
|
||||
|
||||
nsCOMPtr<nsIContent> comment;
|
||||
nsresult rv = NS_NewCommentNode(getter_AddRefs(comment));
|
||||
nsresult rv = NS_NewCommentNode(getter_AddRefs(comment), this);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = CallQueryInterface(comment, aReturn);
|
||||
|
@ -2356,7 +2379,7 @@ nsDocument::CreateCDATASection(const nsAString& aData,
|
|||
return NS_ERROR_DOM_INVALID_CHARACTER_ERR;
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsresult rv = NS_NewXMLCDATASection(getter_AddRefs(content));
|
||||
nsresult rv = NS_NewXMLCDATASection(getter_AddRefs(content), this);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = CallQueryInterface(content, aReturn);
|
||||
|
@ -2377,7 +2400,8 @@ nsDocument::CreateProcessingInstruction(const nsAString& aTarget,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
rv = NS_NewXMLProcessingInstruction(getter_AddRefs(content), aTarget, aData);
|
||||
rv = NS_NewXMLProcessingInstruction(getter_AddRefs(content), aTarget, aData,
|
||||
this);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -4437,3 +4461,93 @@ nsDocument::CreateElement(nsINodeInfo *aNodeInfo, PRInt32 aElementType,
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsDocument::IsOrphan(nsIContent* aContent)
|
||||
{
|
||||
if (mOrphanCache == aContent) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
if (!sOrphans.ops) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PLDHashEntryHdr *entry = PL_DHashTableOperate(&sOrphans, aContent,
|
||||
PL_DHASH_LOOKUP);
|
||||
|
||||
return PL_DHASH_ENTRY_IS_BUSY(entry);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsDocument::AddOrphan(nsIContent* aContent)
|
||||
{
|
||||
if (mIsGoingAway || mInDestructor) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
if (mOrphanCache) {
|
||||
if (!sOrphans.ops &&
|
||||
!PL_DHashTableInit(&sOrphans, PL_DHashGetStubOps(), nsnull,
|
||||
sizeof(OrphansEntry), 5)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PLDHashEntryHdr *entry = PL_DHashTableOperate(&sOrphans, mOrphanCache,
|
||||
PL_DHASH_ADD);
|
||||
if (!entry) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_REINTERPRET_CAST(OrphansEntry*, entry)->mKey = mOrphanCache;
|
||||
}
|
||||
|
||||
mOrphanCache = aContent;
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::RemoveOrphan(nsIContent* aContent)
|
||||
{
|
||||
if (mOrphanCache == aContent) {
|
||||
mOrphanCache = nsnull;
|
||||
}
|
||||
else if (sOrphans.ops) {
|
||||
PL_DHashTableOperate(&sOrphans, aContent, PL_DHASH_REMOVE);
|
||||
}
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(PLDHashOperator)
|
||||
RemoveOrphanFromDocument(PLDHashTable *aTable, PLDHashEntryHdr *aHeader,
|
||||
PRUint32 aNumber, void *aArg)
|
||||
{
|
||||
nsIContent *content = NS_REINTERPRET_CAST(OrphansEntry*,
|
||||
aHeader)->mKey;
|
||||
nsIDocument *document = content->GetOwnerDoc();
|
||||
|
||||
if (document == NS_STATIC_CAST(nsIDocument*, aArg)) {
|
||||
content->SetDocument(nsnull, PR_TRUE, PR_TRUE);
|
||||
|
||||
return PL_DHASH_REMOVE;
|
||||
}
|
||||
|
||||
// XXX Not an orphan anymore if the document pointer has already been
|
||||
// cleared. This shouldn't happen, but until we clean up
|
||||
// SetDocument and SetParent it will.
|
||||
return document ? PL_DHASH_NEXT : PL_DHASH_REMOVE;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::RemoveOrphans()
|
||||
{
|
||||
if (mOrphanCache) {
|
||||
mOrphanCache->SetDocument(nsnull, PR_TRUE, PR_TRUE);
|
||||
mOrphanCache = nsnull;
|
||||
}
|
||||
|
||||
if (sOrphans.ops) {
|
||||
PL_DHashTableEnumerate(&sOrphans, RemoveOrphanFromDocument,
|
||||
NS_STATIC_CAST(nsIDocument*, this));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -502,6 +502,8 @@ public:
|
|||
// virtual nsIPrincipal* GetPrincipal();
|
||||
// Already declared in nsIDocument
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
virtual nsresult Init();
|
||||
|
||||
virtual nsresult AddXMLEventsContent(nsIContent * aXMLEventsElement);
|
||||
|
@ -511,6 +513,10 @@ public:
|
|||
PRBool aDocumentDefaultType,
|
||||
nsIContent **aResult);
|
||||
|
||||
PRBool IsOrphan(nsIContent* aContent);
|
||||
PRBool AddOrphan(nsIContent* aContent);
|
||||
void RemoveOrphan(nsIContent* aContent);
|
||||
|
||||
protected:
|
||||
|
||||
void RetrieveRelevantHeaders(nsIChannel *aChannel);
|
||||
|
@ -600,6 +606,11 @@ private:
|
|||
nsDocument& operator=(const nsDocument& aOther);
|
||||
|
||||
nsXPathDocumentTearoff* mXPathDocument;
|
||||
|
||||
void RemoveOrphans();
|
||||
nsIContent *mOrphanCache;
|
||||
|
||||
static PLDHashTable sOrphans;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -57,9 +57,9 @@
|
|||
#include "pldhash.h"
|
||||
#include "prprf.h"
|
||||
|
||||
nsGenericDOMDataNode::nsGenericDOMDataNode()
|
||||
: mText()
|
||||
nsGenericDOMDataNode::nsGenericDOMDataNode(nsIDocument *aDocument)
|
||||
{
|
||||
mParentPtrBits = NS_REINTERPRET_CAST(PtrBits, aDocument);
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode::~nsGenericDOMDataNode()
|
||||
|
@ -73,6 +73,13 @@ nsGenericDOMDataNode::~nsGenericDOMDataNode()
|
|||
PL_DHashTableOperate(&nsGenericElement::sRangeListsHash,
|
||||
this, PL_DHASH_REMOVE);
|
||||
}
|
||||
|
||||
if (ParentIsDocument()) {
|
||||
nsIDocument *document = ParentPtrBitsAsDocument();
|
||||
if (document) {
|
||||
document->RemoveOrphan(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -108,24 +115,22 @@ nsGenericDOMDataNode::SetNodeValue(const nsAString& aNodeValue)
|
|||
nsresult
|
||||
nsGenericDOMDataNode::GetParentNode(nsIDOMNode** aParentNode)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsIContent *parent_weak = GetParent();
|
||||
|
||||
if (parent_weak) {
|
||||
res = CallQueryInterface(parent_weak, aParentNode);
|
||||
} else if (mDocument) {
|
||||
// If we don't have a parent, but we're in the document, we must
|
||||
// be the root node of the document. The DOM says that the root
|
||||
// is the document.
|
||||
res = CallQueryInterface(mDocument, aParentNode);
|
||||
} else {
|
||||
*aParentNode = nsnull;
|
||||
nsIContent *parent = GetParent();
|
||||
if (parent) {
|
||||
rv = CallQueryInterface(parent, aParentNode);
|
||||
}
|
||||
else {
|
||||
nsIDocument *doc = ParentPtrBitsAsDocument();
|
||||
if (doc && !doc->IsOrphan(this)) {
|
||||
rv = CallQueryInterface(doc, aParentNode);
|
||||
}
|
||||
}
|
||||
|
||||
NS_ASSERTION(NS_OK == res, "Must be a DOM Node");
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Must be a DOM Node");
|
||||
|
||||
return res;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -133,26 +138,27 @@ nsGenericDOMDataNode::GetPreviousSibling(nsIDOMNode** aPrevSibling)
|
|||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsIContent *parent_weak = GetParent();
|
||||
nsIContent *sibling = nsnull;
|
||||
|
||||
if (parent_weak) {
|
||||
PRInt32 pos = parent_weak->IndexOf(this);
|
||||
nsIContent *parent = GetParent();
|
||||
if (parent) {
|
||||
PRInt32 pos = parent->IndexOf(this);
|
||||
if (pos > 0) {
|
||||
sibling = parent_weak->GetChildAt(pos - 1);
|
||||
sibling = parent->GetChildAt(pos - 1);
|
||||
}
|
||||
} else if (mDocument) {
|
||||
// Nodes that are just below the document (their parent is the
|
||||
// document) need to go to the document to find their next sibling.
|
||||
PRInt32 pos = mDocument->IndexOf(this);
|
||||
if (pos > 0) {
|
||||
sibling = mDocument->GetChildAt(pos - 1);
|
||||
}
|
||||
else {
|
||||
nsIDocument *doc = ParentPtrBitsAsDocument();
|
||||
if (doc) {
|
||||
PRInt32 pos = doc->IndexOf(this);
|
||||
if (pos > 0) {
|
||||
sibling = doc->GetChildAt(pos - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sibling) {
|
||||
rv = CallQueryInterface(sibling, aPrevSibling);
|
||||
NS_ASSERTION(rv == NS_OK, "Must be a DOM Node");
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Must be a DOM Node");
|
||||
} else {
|
||||
*aPrevSibling = nsnull;
|
||||
}
|
||||
|
@ -165,27 +171,27 @@ nsGenericDOMDataNode::GetNextSibling(nsIDOMNode** aNextSibling)
|
|||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsIContent *parent_weak = GetParent();
|
||||
nsIContent *sibling = nsnull;
|
||||
|
||||
if (parent_weak) {
|
||||
PRInt32 pos = parent_weak->IndexOf(this);
|
||||
if (pos > -1 ) {
|
||||
sibling = parent_weak->GetChildAt(pos + 1);
|
||||
nsIContent *parent = GetParent();
|
||||
if (parent) {
|
||||
PRInt32 pos = parent->IndexOf(this);
|
||||
if (pos > 0) {
|
||||
sibling = parent->GetChildAt(pos + 1);
|
||||
}
|
||||
}
|
||||
else if (mDocument) {
|
||||
// Nodes that are just below the document (their parent is the
|
||||
// document) need to go to the document to find their next sibling.
|
||||
PRInt32 pos = mDocument->IndexOf(this);
|
||||
if (pos > -1 ) {
|
||||
sibling = mDocument->GetChildAt(pos + 1);
|
||||
else {
|
||||
nsIDocument *doc = ParentPtrBitsAsDocument();
|
||||
if (doc) {
|
||||
PRInt32 pos = doc->IndexOf(this);
|
||||
if (pos > 0) {
|
||||
sibling = doc->GetChildAt(pos + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sibling) {
|
||||
rv = CallQueryInterface(sibling, aNextSibling);
|
||||
NS_ASSERTION(rv == NS_OK, "Must be a DOM Node");
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Must be a DOM Node");
|
||||
} else {
|
||||
*aNextSibling = nsnull;
|
||||
}
|
||||
|
@ -210,14 +216,13 @@ nsGenericDOMDataNode::GetChildNodes(nsIDOMNodeList** aChildNodes)
|
|||
nsresult
|
||||
nsGenericDOMDataNode::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
{
|
||||
// XXX Actually the owner document is the document in whose context
|
||||
// the node has been created. We should be able to get at it
|
||||
// whether or not we are attached to the document.
|
||||
if (mDocument) {
|
||||
return CallQueryInterface(mDocument, aOwnerDocument);
|
||||
nsIDocument *document = GetOwnerDoc();
|
||||
if (document) {
|
||||
return CallQueryInterface(document, aOwnerDocument);
|
||||
}
|
||||
|
||||
*aOwnerDocument = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -424,8 +429,9 @@ nsGenericDOMDataNode::AppendData(const nsAString& aData)
|
|||
}
|
||||
|
||||
// Trigger a reflow
|
||||
if (mDocument) {
|
||||
mDocument->CharacterDataChanged(this, PR_TRUE);
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
if (document) {
|
||||
document->CharacterDataChanged(this, PR_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -589,15 +595,70 @@ nsGenericDOMDataNode::ToCString(nsAString& aBuf, PRInt32 aOffset,
|
|||
}
|
||||
#endif
|
||||
|
||||
nsIDocument*
|
||||
nsGenericDOMDataNode::GetDocument() const
|
||||
{
|
||||
nsIContent *parent = GetParent();
|
||||
if (parent) {
|
||||
return parent->GetDocument();
|
||||
}
|
||||
|
||||
nsIDocument *document = ParentPtrBitsAsDocument();
|
||||
if (document &&
|
||||
document->IsOrphan(NS_CONST_CAST(nsGenericDOMDataNode*, this))) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
void
|
||||
nsGenericDOMDataNode::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
nsIContent::SetDocument(aDocument, aDeep, aCompileEventHandlers);
|
||||
if (aDocument) {
|
||||
if (ParentIsDocument()) {
|
||||
nsIDocument *document = ParentPtrBitsAsDocument();
|
||||
if (document) {
|
||||
document->RemoveOrphan(this);
|
||||
}
|
||||
|
||||
if (mDocument && mText.IsBidi()) {
|
||||
mDocument->SetBidiEnabled(PR_TRUE);
|
||||
mParentPtrBits =
|
||||
NS_REINTERPRET_CAST(PtrBits, aDocument) |
|
||||
(mParentPtrBits & PARENT_BIT_RANGELISTS_OR_LISTENERMANAGER);
|
||||
}
|
||||
|
||||
if (mText.IsBidi()) {
|
||||
aDocument->SetBidiEnabled(PR_TRUE);
|
||||
}
|
||||
}
|
||||
else if (ParentIsDocument()) {
|
||||
// XXX We should call AddOrphan here, but we first need ClearDocumentPointer
|
||||
// so that RemoveOrphan/RemoveOrphans don't end up here.
|
||||
mParentPtrBits &= nsIContent::kParentBitMask;
|
||||
}
|
||||
}
|
||||
|
||||
nsIDocument*
|
||||
nsGenericDOMDataNode::GetOwnerDoc() const
|
||||
{
|
||||
nsIContent *parent = GetParent();
|
||||
|
||||
return parent ? parent->GetOwnerDoc() : ParentPtrBitsAsDocument();
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGenericDOMDataNode::IsInDoc() const
|
||||
{
|
||||
nsIContent *parent = GetParent();
|
||||
if (parent) {
|
||||
return parent->IsInDoc();
|
||||
}
|
||||
|
||||
nsIDocument *document = ParentPtrBitsAsDocument();
|
||||
|
||||
return document && !document->IsOrphan(NS_CONST_CAST(nsGenericDOMDataNode*,
|
||||
this));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -605,9 +666,28 @@ nsGenericDOMDataNode::SetParent(nsIContent* aParent)
|
|||
{
|
||||
PtrBits new_bits = NS_REINTERPRET_CAST(PtrBits, aParent);
|
||||
|
||||
new_bits |= mParentPtrBits & nsIContent::kParentBitMask;
|
||||
if (aParent) {
|
||||
if (ParentIsDocument()) {
|
||||
nsIDocument *document = ParentPtrBitsAsDocument();
|
||||
if (document) {
|
||||
document->RemoveOrphan(this);
|
||||
}
|
||||
}
|
||||
|
||||
mParentPtrBits = new_bits;
|
||||
new_bits |= PARENT_BIT_BITPTR_IS_CONTENT;
|
||||
}
|
||||
else {
|
||||
nsIContent *parent = GetParent();
|
||||
if (parent) {
|
||||
nsIDocument *document = parent->GetOwnerDoc();
|
||||
if (document && document->AddOrphan(this)) {
|
||||
new_bits = NS_REINTERPRET_CAST(PtrBits, document);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mParentPtrBits = new_bits |
|
||||
(mParentPtrBits & PARENT_BIT_RANGELISTS_OR_LISTENERMANAGER);
|
||||
}
|
||||
|
||||
PRBool
|
||||
|
@ -717,17 +797,22 @@ nsGenericDOMDataNode::HandleDOMEvent(nsPresContext* aPresContext,
|
|||
aFlags |= NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_CAPTURE;
|
||||
}
|
||||
|
||||
nsIContent *parent_weak = GetParent();
|
||||
nsIContent *parent = GetParent();
|
||||
|
||||
//Capturing stage evaluation
|
||||
if (NS_EVENT_FLAG_CAPTURE & aFlags) {
|
||||
//Initiate capturing phase. Special case first call to document
|
||||
if (parent_weak) {
|
||||
parent_weak->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags & NS_EVENT_CAPTURE_MASK, aEventStatus);
|
||||
} else if (mDocument) {
|
||||
ret = mDocument->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags & NS_EVENT_CAPTURE_MASK, aEventStatus);
|
||||
if (parent) {
|
||||
parent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags & NS_EVENT_CAPTURE_MASK, aEventStatus);
|
||||
}
|
||||
else {
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
if (document) {
|
||||
document->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags & NS_EVENT_CAPTURE_MASK,
|
||||
aEventStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -748,9 +833,9 @@ nsGenericDOMDataNode::HandleDOMEvent(nsPresContext* aPresContext,
|
|||
}
|
||||
|
||||
//Bubbling stage
|
||||
if (NS_EVENT_FLAG_BUBBLE & aFlags && parent_weak) {
|
||||
ret = parent_weak->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags & NS_EVENT_BUBBLE_MASK, aEventStatus);
|
||||
if (NS_EVENT_FLAG_BUBBLE & aFlags && parent) {
|
||||
ret = parent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags & NS_EVENT_BUBBLE_MASK, aEventStatus);
|
||||
}
|
||||
|
||||
if (NS_EVENT_FLAG_INIT & aFlags) {
|
||||
|
@ -950,15 +1035,17 @@ already_AddRefed<nsIURI>
|
|||
nsGenericDOMDataNode::GetBaseURI() const
|
||||
{
|
||||
// DOM Data Node inherits the base from its parent element/document
|
||||
nsIContent* parent_weak = GetParent();
|
||||
if (parent_weak) {
|
||||
return parent_weak->GetBaseURI();
|
||||
nsIContent *parent = GetParent();
|
||||
if (parent) {
|
||||
return parent->GetBaseURI();
|
||||
}
|
||||
|
||||
nsIURI *uri;
|
||||
if (mDocument) {
|
||||
NS_IF_ADDREF(uri = mDocument->GetBaseURI());
|
||||
} else {
|
||||
nsIDocument *document = ParentPtrBitsAsDocument();
|
||||
if (document) {
|
||||
NS_IF_ADDREF(uri = document->GetBaseURI());
|
||||
}
|
||||
else {
|
||||
uri = nsnull;
|
||||
}
|
||||
|
||||
|
@ -995,7 +1082,7 @@ nsGenericDOMDataNode::SplitText(PRUint32 aOffset, nsIDOMText** aReturn)
|
|||
* same class as this node!
|
||||
*/
|
||||
|
||||
nsCOMPtr<nsITextContent> newContent = CloneContent(PR_FALSE);
|
||||
nsCOMPtr<nsITextContent> newContent = CloneContent(PR_FALSE, nsnull);
|
||||
if (!newContent) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -1012,6 +1099,8 @@ nsGenericDOMDataNode::SplitText(PRUint32 aOffset, nsIDOMText** aReturn)
|
|||
parent->InsertChildAt(content, index+1, PR_TRUE, PR_FALSE);
|
||||
}
|
||||
|
||||
// XXX Shouldn't we handle the case where this is a child of the document?
|
||||
|
||||
return CallQueryInterface(newContent, aReturn);
|
||||
}
|
||||
|
||||
|
@ -1042,10 +1131,11 @@ nsGenericDOMDataNode::SetText(const PRUnichar* aBuffer,
|
|||
return;
|
||||
}
|
||||
|
||||
mozAutoDocUpdate updateBatch(mDocument, UPDATE_CONTENT_MODEL, aNotify);
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
|
||||
|
||||
PRBool haveMutationListeners =
|
||||
mDocument && nsGenericElement::HasMutationListeners(this, NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED);
|
||||
document && nsGenericElement::HasMutationListeners(this, NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED);
|
||||
|
||||
nsCOMPtr<nsIAtom> oldValue;
|
||||
if (haveMutationListeners) {
|
||||
|
@ -1074,8 +1164,8 @@ nsGenericDOMDataNode::SetText(const PRUnichar* aBuffer,
|
|||
}
|
||||
|
||||
// Trigger a reflow
|
||||
if (aNotify && mDocument) {
|
||||
mDocument->CharacterDataChanged(this, PR_FALSE);
|
||||
if (aNotify && document) {
|
||||
document->CharacterDataChanged(this, PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1089,10 +1179,11 @@ nsGenericDOMDataNode::SetText(const char* aBuffer, PRUint32 aLength,
|
|||
return;
|
||||
}
|
||||
|
||||
mozAutoDocUpdate updateBatch(mDocument, UPDATE_CONTENT_MODEL, aNotify);
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
|
||||
|
||||
PRBool haveMutationListeners =
|
||||
mDocument && nsGenericElement::HasMutationListeners(this, NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED);
|
||||
document && nsGenericElement::HasMutationListeners(this, NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED);
|
||||
|
||||
nsCOMPtr<nsIAtom> oldValue;
|
||||
if (haveMutationListeners) {
|
||||
|
@ -1119,8 +1210,8 @@ nsGenericDOMDataNode::SetText(const char* aBuffer, PRUint32 aLength,
|
|||
}
|
||||
|
||||
// Trigger a reflow
|
||||
if (aNotify && mDocument) {
|
||||
mDocument->CharacterDataChanged(this, PR_FALSE);
|
||||
if (aNotify && document) {
|
||||
document->CharacterDataChanged(this, PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1128,10 +1219,11 @@ void
|
|||
nsGenericDOMDataNode::SetText(const nsAString& aStr,
|
||||
PRBool aNotify)
|
||||
{
|
||||
mozAutoDocUpdate updateBatch(mDocument, UPDATE_CONTENT_MODEL, aNotify);
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
|
||||
|
||||
PRBool haveMutationListeners =
|
||||
mDocument && nsGenericElement::HasMutationListeners(this, NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED);
|
||||
document && nsGenericElement::HasMutationListeners(this, NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED);
|
||||
|
||||
nsCOMPtr<nsIAtom> oldValue;
|
||||
if (haveMutationListeners) {
|
||||
|
@ -1155,8 +1247,8 @@ nsGenericDOMDataNode::SetText(const nsAString& aStr,
|
|||
}
|
||||
|
||||
// Trigger a reflow
|
||||
if (aNotify && mDocument) {
|
||||
mDocument->CharacterDataChanged(this, PR_FALSE);
|
||||
if (aNotify && document) {
|
||||
document->CharacterDataChanged(this, PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1240,15 +1332,16 @@ nsGenericDOMDataNode::LookupRangeList() const
|
|||
|
||||
void nsGenericDOMDataNode::SetBidiStatus()
|
||||
{
|
||||
if (mDocument && mDocument->GetBidiEnabled()) {
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
if (document && document->GetBidiEnabled()) {
|
||||
// OK, we already know it's Bidi, so we won't test again
|
||||
return;
|
||||
}
|
||||
|
||||
mText.SetBidiFlag();
|
||||
|
||||
if (mDocument && mText.IsBidi()) {
|
||||
mDocument->SetBidiEnabled(PR_TRUE);
|
||||
if (document && mText.IsBidi()) {
|
||||
document->SetBidiEnabled(PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1259,4 +1352,12 @@ nsGenericDOMDataNode::GetCurrentValueAtom()
|
|||
GetData(val);
|
||||
return NS_NewAtom(val);
|
||||
}
|
||||
|
||||
|
||||
already_AddRefed<nsITextContent>
|
||||
nsGenericDOMDataNode::CloneContent(PRBool aCloneText,
|
||||
nsIDocument *aOwnerDocument)
|
||||
{
|
||||
NS_ERROR("Huh, this shouldn't be called!");
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
|
|
@ -55,15 +55,15 @@ class nsIDOMText;
|
|||
class nsINodeInfo;
|
||||
class nsURI;
|
||||
|
||||
#define PARENT_BIT_RANGELISTS ((PtrBits)0x1 << 0)
|
||||
#define PARENT_BIT_LISTENERMANAGER ((PtrBits)0x1 << 1)
|
||||
#define PARENT_BIT_RANGELISTS_OR_LISTENERMANAGER ((PtrBits)0x1 << 0)
|
||||
#define PARENT_BIT_BITPTR_IS_CONTENT ((PtrBits)0x1 << 1)
|
||||
|
||||
class nsGenericDOMDataNode : public nsITextContent
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsGenericDOMDataNode();
|
||||
nsGenericDOMDataNode(nsIDocument *aDocument);
|
||||
virtual ~nsGenericDOMDataNode();
|
||||
|
||||
// Implementation for nsIDOMNode
|
||||
|
@ -166,8 +166,15 @@ public:
|
|||
const nsAString& aArg);
|
||||
|
||||
// Implementation for nsIContent
|
||||
nsIDocument* GetDocument() const;
|
||||
virtual void SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers);
|
||||
PRBool IsInDoc() const;
|
||||
nsIDocument *GetOwnerDoc() const;
|
||||
nsIContent *GetParent() const
|
||||
{
|
||||
return ParentIsContent() ? ParentPtrBitsAsContent() : nsnull;
|
||||
}
|
||||
virtual void SetParent(nsIContent* aParent);
|
||||
virtual PRBool IsNativeAnonymous() const;
|
||||
virtual void SetNativeAnonymous(PRBool aAnonymous);
|
||||
|
@ -234,6 +241,9 @@ public:
|
|||
|
||||
//----------------------------------------
|
||||
|
||||
already_AddRefed<nsITextContent> CloneContent(PRBool aCloneText,
|
||||
nsIDocument *aOwnerDocument);
|
||||
|
||||
#ifdef DEBUG
|
||||
void ToCString(nsAString& aBuf, PRInt32 aOffset, PRInt32 aLen) const;
|
||||
#endif
|
||||
|
@ -250,36 +260,55 @@ private:
|
|||
void SetBidiStatus();
|
||||
|
||||
already_AddRefed<nsIAtom> GetCurrentValueAtom();
|
||||
|
||||
|
||||
void SetHasRangeList(PRBool aHasRangeList)
|
||||
{
|
||||
if (aHasRangeList) {
|
||||
mParentPtrBits |= PARENT_BIT_RANGELISTS;
|
||||
mParentPtrBits |= PARENT_BIT_RANGELISTS_OR_LISTENERMANAGER;
|
||||
} else {
|
||||
mParentPtrBits &= ~PARENT_BIT_RANGELISTS;
|
||||
mParentPtrBits &= ~PARENT_BIT_RANGELISTS_OR_LISTENERMANAGER;
|
||||
}
|
||||
}
|
||||
|
||||
void SetHasEventListenerManager(PRBool aHasRangeList)
|
||||
{
|
||||
if (aHasRangeList) {
|
||||
mParentPtrBits |= PARENT_BIT_LISTENERMANAGER;
|
||||
mParentPtrBits |= PARENT_BIT_RANGELISTS_OR_LISTENERMANAGER;
|
||||
} else {
|
||||
mParentPtrBits &= ~PARENT_BIT_LISTENERMANAGER;
|
||||
mParentPtrBits &= ~PARENT_BIT_RANGELISTS_OR_LISTENERMANAGER;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool HasRangeList() const
|
||||
{
|
||||
return (mParentPtrBits & PARENT_BIT_RANGELISTS &&
|
||||
return (mParentPtrBits & PARENT_BIT_RANGELISTS_OR_LISTENERMANAGER &&
|
||||
nsGenericElement::sRangeListsHash.ops);
|
||||
}
|
||||
|
||||
PRBool HasEventListenerManager() const
|
||||
{
|
||||
return (mParentPtrBits & PARENT_BIT_LISTENERMANAGER &&
|
||||
return (mParentPtrBits & PARENT_BIT_RANGELISTS_OR_LISTENERMANAGER &&
|
||||
nsGenericElement::sEventListenerManagersHash.ops);
|
||||
}
|
||||
|
||||
PRBool ParentIsDocument() const
|
||||
{
|
||||
return !(mParentPtrBits & PARENT_BIT_BITPTR_IS_CONTENT);
|
||||
}
|
||||
nsIDocument *ParentPtrBitsAsDocument() const
|
||||
{
|
||||
return NS_REINTERPRET_CAST(nsIDocument *,
|
||||
mParentPtrBits & ~kParentBitMask);
|
||||
}
|
||||
PRBool ParentIsContent() const
|
||||
{
|
||||
return mParentPtrBits & PARENT_BIT_BITPTR_IS_CONTENT;
|
||||
}
|
||||
nsIContent *ParentPtrBitsAsContent() const
|
||||
{
|
||||
return NS_REINTERPRET_CAST(nsIContent *,
|
||||
mParentPtrBits & ~kParentBitMask);
|
||||
}
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -810,7 +810,8 @@ nsGenericElement::nsGenericElement(nsINodeInfo *aNodeInfo)
|
|||
|
||||
nsGenericElement::~nsGenericElement()
|
||||
{
|
||||
NS_PRECONDITION(!mDocument, "Please remove this from the document properly");
|
||||
NS_PRECONDITION(!IsInDoc(),
|
||||
"Please remove this from the document properly");
|
||||
|
||||
// pop any enclosed ranges out
|
||||
// nsRange::OwnerGone(mContent); not used for now
|
||||
|
@ -857,6 +858,8 @@ nsGenericElement::~nsGenericElement()
|
|||
delete slots;
|
||||
}
|
||||
|
||||
mAttrsAndChildren.Clear();
|
||||
|
||||
// No calling GetFlags() beyond this point...
|
||||
}
|
||||
|
||||
|
@ -996,16 +999,17 @@ nsGenericElement::GetNodeType(PRUint16* aNodeType)
|
|||
NS_IMETHODIMP
|
||||
nsGenericElement::GetParentNode(nsIDOMNode** aParentNode)
|
||||
{
|
||||
if (GetParent()) {
|
||||
return CallQueryInterface(GetParent(), aParentNode);
|
||||
nsIContent *parent = GetParent();
|
||||
if (parent) {
|
||||
return CallQueryInterface(parent, aParentNode);
|
||||
}
|
||||
|
||||
if (mDocument) {
|
||||
if (IsInDoc()) {
|
||||
// If we don't have a parent, but we're in the document, we must
|
||||
// be the root node of the document. The DOM says that the root
|
||||
// is the document.
|
||||
|
||||
return CallQueryInterface(mDocument, aParentNode);
|
||||
return CallQueryInterface(GetOwnerDoc(), aParentNode);
|
||||
}
|
||||
|
||||
*aParentNode = nsnull;
|
||||
|
@ -1021,17 +1025,19 @@ nsGenericElement::GetPreviousSibling(nsIDOMNode** aPrevSibling)
|
|||
nsIContent *sibling = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (GetParent()) {
|
||||
PRInt32 pos = GetParent()->IndexOf(this);
|
||||
nsIContent *parent = GetParent();
|
||||
if (parent) {
|
||||
PRInt32 pos = parent->IndexOf(this);
|
||||
if (pos > 0 ) {
|
||||
sibling = GetParent()->GetChildAt(pos - 1);
|
||||
sibling = parent->GetChildAt(pos - 1);
|
||||
}
|
||||
} else if (mDocument) {
|
||||
} else if (IsInDoc()) {
|
||||
// Nodes that are just below the document (their parent is the
|
||||
// document) need to go to the document to find their next sibling.
|
||||
PRInt32 pos = mDocument->IndexOf(this);
|
||||
nsIDocument *document = GetOwnerDoc();
|
||||
PRInt32 pos = document->IndexOf(this);
|
||||
if (pos > 0 ) {
|
||||
sibling = mDocument->GetChildAt(pos - 1);
|
||||
sibling = document->GetChildAt(pos - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1051,17 +1057,19 @@ nsGenericElement::GetNextSibling(nsIDOMNode** aNextSibling)
|
|||
nsIContent *sibling = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (GetParent()) {
|
||||
PRInt32 pos = GetParent()->IndexOf(this);
|
||||
nsIContent *parent = GetParent();
|
||||
if (parent) {
|
||||
PRInt32 pos = parent->IndexOf(this);
|
||||
if (pos > -1 ) {
|
||||
sibling = GetParent()->GetChildAt(pos + 1);
|
||||
sibling = parent->GetChildAt(pos + 1);
|
||||
}
|
||||
} else if (mDocument) {
|
||||
} else if (IsInDoc()) {
|
||||
// Nodes that are just below the document (their parent is the
|
||||
// document) need to go to the document to find their next sibling.
|
||||
PRInt32 pos = mDocument->IndexOf(this);
|
||||
nsIDocument *document = GetOwnerDoc();
|
||||
PRInt32 pos = document->IndexOf(this);
|
||||
if (pos > -1 ) {
|
||||
sibling = mDocument->GetChildAt(pos + 1);
|
||||
sibling = document->GetChildAt(pos + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1076,16 +1084,13 @@ nsGenericElement::GetNextSibling(nsIDOMNode** aNextSibling)
|
|||
NS_IMETHODIMP
|
||||
nsGenericElement::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOwnerDocument);
|
||||
|
||||
nsIDocument* doc = GetOwnerDocument();
|
||||
|
||||
nsIDocument *doc = GetOwnerDoc();
|
||||
if (doc) {
|
||||
return CallQueryInterface(doc, aOwnerDocument);
|
||||
}
|
||||
|
||||
// No document, return nsnull
|
||||
*aOwnerDocument = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1412,7 +1417,7 @@ nsGenericElement::GetElementsByTagName(const nsAString& aTagname,
|
|||
NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsCOMPtr<nsIContentList> list;
|
||||
NS_GetContentList(mDocument, nameAtom, kNameSpaceID_Unknown, this,
|
||||
NS_GetContentList(GetCurrentDoc(), nameAtom, kNameSpaceID_Unknown, this,
|
||||
getter_AddRefs(list));
|
||||
NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
|
@ -1534,13 +1539,14 @@ nsGenericElement::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
|||
|
||||
nsCOMPtr<nsIContentList> list;
|
||||
|
||||
nsIDocument* document = GetCurrentDoc();
|
||||
if (!aNamespaceURI.EqualsLiteral("*")) {
|
||||
nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI,
|
||||
&nameSpaceId);
|
||||
|
||||
if (nameSpaceId == kNameSpaceID_Unknown) {
|
||||
// Unknown namespace means no matches, we create an empty list...
|
||||
NS_GetContentList(mDocument, nsnull, kNameSpaceID_None, nsnull,
|
||||
NS_GetContentList(document, nsnull, kNameSpaceID_None, nsnull,
|
||||
getter_AddRefs(list));
|
||||
NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -1550,7 +1556,7 @@ nsGenericElement::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
|||
nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aLocalName);
|
||||
NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_GetContentList(mDocument, nameAtom, nameSpaceId, this,
|
||||
NS_GetContentList(document, nameAtom, nameSpaceId, this,
|
||||
getter_AddRefs(list));
|
||||
NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -1697,45 +1703,53 @@ void
|
|||
nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
if (aDocument != mDocument) {
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
if (aDocument != document) {
|
||||
// If we were part of a document, make sure we get rid of the
|
||||
// script context reference to our script object so that our
|
||||
// script object can be freed (or collected).
|
||||
|
||||
if (mDocument && aDeep) {
|
||||
if (document && aDeep) {
|
||||
// Notify XBL- & nsIAnonymousContentCreator-generated
|
||||
// anonymous content that the document is changing.
|
||||
nsIBindingManager* bindingManager = mDocument->GetBindingManager();
|
||||
nsIBindingManager* bindingManager = document->GetBindingManager();
|
||||
NS_ASSERTION(bindingManager, "No binding manager.");
|
||||
if (bindingManager) {
|
||||
bindingManager->ChangeDocumentFor(this, mDocument, aDocument);
|
||||
bindingManager->ChangeDocumentFor(this, document, aDocument);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMElement> domElement;
|
||||
QueryInterface(NS_GET_IID(nsIDOMElement), getter_AddRefs(domElement));
|
||||
|
||||
if (domElement) {
|
||||
nsCOMPtr<nsIDOMNSDocument> nsDoc(do_QueryInterface(mDocument));
|
||||
nsCOMPtr<nsIDOMNSDocument> nsDoc(do_QueryInterface(document));
|
||||
nsDoc->SetBoxObjectFor(domElement, nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
// check the document on the nodeinfo to see whether we need a
|
||||
// new nodeinfo
|
||||
if (aDocument && aDocument != nsContentUtils::GetDocument(mNodeInfo)) {
|
||||
// get a new nodeinfo
|
||||
nsNodeInfoManager* nodeInfoManager = aDocument->NodeInfoManager();
|
||||
nsCOMPtr<nsINodeInfo> newNodeInfo;
|
||||
nodeInfoManager->GetNodeInfo(mNodeInfo->NameAtom(),
|
||||
mNodeInfo->GetPrefixAtom(),
|
||||
mNodeInfo->NamespaceID(),
|
||||
getter_AddRefs(newNodeInfo));
|
||||
if (newNodeInfo) {
|
||||
mNodeInfo.swap(newNodeInfo);
|
||||
if (aDocument) {
|
||||
mParentPtrBits |= PARENT_BIT_INDOCUMENT;
|
||||
|
||||
// check the document on the nodeinfo to see whether we need a
|
||||
// new nodeinfo
|
||||
if (aDocument != GetOwnerDoc()) {
|
||||
// get a new nodeinfo
|
||||
nsNodeInfoManager* nodeInfoManager = aDocument->NodeInfoManager();
|
||||
if (nodeInfoManager) {
|
||||
nsCOMPtr<nsINodeInfo> newNodeInfo;
|
||||
nodeInfoManager->GetNodeInfo(mNodeInfo->NameAtom(),
|
||||
mNodeInfo->GetPrefixAtom(),
|
||||
mNodeInfo->NamespaceID(),
|
||||
getter_AddRefs(newNodeInfo));
|
||||
if (newNodeInfo) {
|
||||
mNodeInfo.swap(newNodeInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsIContent::SetDocument(aDocument, aDeep, aCompileEventHandlers);
|
||||
else {
|
||||
mParentPtrBits &= ~PARENT_BIT_INDOCUMENT;
|
||||
}
|
||||
}
|
||||
|
||||
if (aDeep) {
|
||||
|
@ -1747,7 +1761,12 @@ nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
|||
void
|
||||
nsGenericElement::SetParent(nsIContent* aParent)
|
||||
{
|
||||
nsIContent::SetParent(aParent);
|
||||
PtrBits new_bits = NS_REINTERPRET_CAST(PtrBits, aParent);
|
||||
|
||||
new_bits |= mParentPtrBits & nsIContent::kParentBitMask;
|
||||
|
||||
mParentPtrBits = new_bits;
|
||||
|
||||
if (aParent) {
|
||||
nsIContent* bindingPar = aParent->GetBindingParent();
|
||||
if (bindingPar)
|
||||
|
@ -1834,8 +1853,8 @@ nsGenericElement::HandleDOMEvent(nsPresContext* aPresContext,
|
|||
|
||||
// determine the parent:
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
if (mDocument) {
|
||||
nsIBindingManager* bindingManager = mDocument->GetBindingManager();
|
||||
if (IsInDoc()) {
|
||||
nsIBindingManager* bindingManager = GetOwnerDoc()->GetBindingManager();
|
||||
if (bindingManager) {
|
||||
// we have a binding manager -- do we have an anonymous parent?
|
||||
bindingManager->GetInsertionParent(this, getter_AddRefs(parent));
|
||||
|
@ -1894,10 +1913,11 @@ nsGenericElement::HandleDOMEvent(nsPresContext* aPresContext,
|
|||
parent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags & NS_EVENT_CAPTURE_MASK,
|
||||
aEventStatus);
|
||||
} else if (mDocument != nsnull) {
|
||||
ret = mDocument->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags & NS_EVENT_CAPTURE_MASK,
|
||||
aEventStatus);
|
||||
} else if (IsInDoc()) {
|
||||
ret = GetOwnerDoc()->HandleDOMEvent(aPresContext, aEvent,
|
||||
aDOMEvent,
|
||||
aFlags & NS_EVENT_CAPTURE_MASK,
|
||||
aEventStatus);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1961,7 +1981,7 @@ nsGenericElement::HandleDOMEvent(nsPresContext* aPresContext,
|
|||
}
|
||||
|
||||
//Bubbling stage
|
||||
if (NS_EVENT_FLAG_BUBBLE & aFlags && mDocument &&
|
||||
if (NS_EVENT_FLAG_BUBBLE & aFlags && IsInDoc() &&
|
||||
aEvent->message != NS_PAGE_LOAD && aEvent->message != NS_SCRIPT_LOAD &&
|
||||
aEvent->message != NS_IMAGE_ERROR && aEvent->message != NS_IMAGE_LOAD &&
|
||||
!(aEvent->message == NS_SCROLL_EVENT &&
|
||||
|
@ -1976,9 +1996,9 @@ nsGenericElement::HandleDOMEvent(nsPresContext* aPresContext,
|
|||
// If there's no parent but there is a document (i.e. this is
|
||||
// the root node) we pass the event to the document...
|
||||
|
||||
ret = mDocument->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags & NS_EVENT_BUBBLE_MASK,
|
||||
aEventStatus);
|
||||
ret = GetOwnerDoc()->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags & NS_EVENT_BUBBLE_MASK,
|
||||
aEventStatus);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2187,7 +2207,7 @@ nsGenericElement::GetAttributeMappingFunction(nsMapRuleToAttributesFunc& aMapRul
|
|||
already_AddRefed<nsIURI>
|
||||
nsGenericElement::GetBaseURI() const
|
||||
{
|
||||
nsIDocument* doc = GetOwnerDocument();
|
||||
nsIDocument* doc = GetOwnerDoc();
|
||||
if (!doc) {
|
||||
// We won't be able to do security checks, etc. So don't go any
|
||||
// further. That said, this really shouldn't happen...
|
||||
|
@ -2459,7 +2479,9 @@ nsGenericElement::InsertChildAt(nsIContent* aKid,
|
|||
PRBool aDeepSetDocument)
|
||||
{
|
||||
NS_PRECONDITION(aKid, "null ptr");
|
||||
mozAutoDocUpdate updateBatch(mDocument, UPDATE_CONTENT_MODEL, aNotify);
|
||||
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
|
||||
|
||||
PRBool isAppend;
|
||||
|
||||
|
@ -2472,14 +2494,13 @@ nsGenericElement::InsertChildAt(nsIContent* aKid,
|
|||
|
||||
aKid->SetParent(this);
|
||||
nsRange::OwnerChildInserted(this, aIndex);
|
||||
|
||||
if (mDocument) {
|
||||
aKid->SetDocument(mDocument, aDeepSetDocument, PR_TRUE);
|
||||
if (document) {
|
||||
aKid->SetDocument(document, aDeepSetDocument, PR_TRUE);
|
||||
if (aNotify) {
|
||||
if (isAppend) {
|
||||
mDocument->ContentAppended(this, aIndex);
|
||||
document->ContentAppended(this, aIndex);
|
||||
} else {
|
||||
mDocument->ContentInserted(this, aKid, aIndex);
|
||||
document->ContentInserted(this, aKid, aIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2500,7 +2521,8 @@ nsGenericElement::AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
|||
PRBool aDeepSetDocument)
|
||||
{
|
||||
NS_PRECONDITION(aKid && this != aKid, "null ptr");
|
||||
mozAutoDocUpdate updateBatch(mDocument, UPDATE_CONTENT_MODEL, aNotify);
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
|
||||
|
||||
nsresult rv = mAttrsAndChildren.AppendChild(aKid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -2508,10 +2530,10 @@ nsGenericElement::AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
|||
aKid->SetParent(this);
|
||||
// ranges don't need adjustment since new child is at end of list
|
||||
|
||||
if (mDocument) {
|
||||
aKid->SetDocument(mDocument, aDeepSetDocument, PR_TRUE);
|
||||
if (document) {
|
||||
aKid->SetDocument(document, aDeepSetDocument, PR_TRUE);
|
||||
if (aNotify) {
|
||||
mDocument->ContentAppended(this, GetChildCount() - 1);
|
||||
document->ContentAppended(this, GetChildCount() - 1);
|
||||
}
|
||||
|
||||
if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEINSERTED)) {
|
||||
|
@ -2531,7 +2553,8 @@ nsGenericElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
|||
{
|
||||
nsCOMPtr<nsIContent> oldKid = GetChildAt(aIndex);
|
||||
if (oldKid) {
|
||||
mozAutoDocUpdate updateBatch(mDocument, UPDATE_CONTENT_MODEL, aNotify);
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
|
||||
|
||||
if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEREMOVED)) {
|
||||
nsMutationEvent mutation(NS_MUTATION_NODEREMOVED, oldKid);
|
||||
|
@ -2546,8 +2569,8 @@ nsGenericElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
|||
|
||||
mAttrsAndChildren.RemoveChildAt(aIndex);
|
||||
|
||||
if (aNotify && mDocument) {
|
||||
mDocument->ContentRemoved(this, oldKid, aIndex);
|
||||
if (aNotify && document) {
|
||||
document->ContentRemoved(this, oldKid, aIndex);
|
||||
}
|
||||
|
||||
oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE);
|
||||
|
@ -3050,8 +3073,9 @@ NS_IMPL_RELEASE(nsGenericElement)
|
|||
nsresult
|
||||
nsGenericElement::PostQueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (mDocument) {
|
||||
nsIBindingManager* manager = mDocument->GetBindingManager();
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
if (document) {
|
||||
nsIBindingManager* manager = document->GetBindingManager();
|
||||
if (manager)
|
||||
return manager->GetBindingImplementation(this, aIID, aInstancePtr);
|
||||
}
|
||||
|
@ -3125,7 +3149,8 @@ nsGenericElement::AddScriptEventListener(nsIAtom* aAttribute,
|
|||
|
||||
// If we have a document, and it has a script global, add the
|
||||
// event listener on the global. If not, proceed as normal.
|
||||
if (mDocument && (sgo = mDocument->GetScriptGlobalObject())) {
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
if (document && (sgo = document->GetScriptGlobalObject())) {
|
||||
nsCOMPtr<nsIDOMEventReceiver> receiver(do_QueryInterface(sgo));
|
||||
NS_ENSURE_TRUE(receiver, NS_ERROR_FAILURE);
|
||||
|
||||
|
@ -3269,10 +3294,11 @@ nsGenericElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
|
|||
}
|
||||
|
||||
// Begin the update _before_ changing the attr value
|
||||
mozAutoDocUpdate updateBatch(mDocument, UPDATE_CONTENT_MODEL, aNotify);
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
|
||||
|
||||
if (aNotify && mDocument) {
|
||||
mDocument->AttributeWillChange(this, aNamespaceID, aName);
|
||||
if (aNotify && document) {
|
||||
document->AttributeWillChange(this, aNamespaceID, aName);
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
|
@ -3292,9 +3318,9 @@ nsGenericElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (mDocument) {
|
||||
if (document) {
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
mDocument->GetBindingManager()->GetBinding(this, getter_AddRefs(binding));
|
||||
document->GetBindingManager()->GetBinding(this, getter_AddRefs(binding));
|
||||
if (binding)
|
||||
binding->AttributeChanged(aName, aNamespaceID, PR_FALSE, aNotify);
|
||||
|
||||
|
@ -3331,7 +3357,7 @@ nsGenericElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
|
|||
if (aNotify) {
|
||||
PRInt32 modHint = modification ? PRInt32(nsIDOMMutationEvent::MODIFICATION)
|
||||
: PRInt32(nsIDOMMutationEvent::ADDITION);
|
||||
mDocument->AttributeChanged(this, aNamespaceID, aName, modHint);
|
||||
document->AttributeChanged(this, aNamespaceID, aName, modHint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3388,10 +3414,11 @@ nsGenericElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
mozAutoDocUpdate updateBatch(mDocument, UPDATE_CONTENT_MODEL, aNotify);
|
||||
if (mDocument) {
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
|
||||
if (document) {
|
||||
if (aNotify) {
|
||||
mDocument->AttributeWillChange(this, aNameSpaceID, aName);
|
||||
document->AttributeWillChange(this, aNameSpaceID, aName);
|
||||
}
|
||||
|
||||
if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_ATTRMODIFIED)) {
|
||||
|
@ -3423,15 +3450,15 @@ nsGenericElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
|||
nsresult rv = mAttrsAndChildren.RemoveAttrAt(index);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (mDocument) {
|
||||
if (document) {
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
mDocument->GetBindingManager()->GetBinding(this, getter_AddRefs(binding));
|
||||
document->GetBindingManager()->GetBinding(this, getter_AddRefs(binding));
|
||||
if (binding)
|
||||
binding->AttributeChanged(aName, aNameSpaceID, PR_TRUE, aNotify);
|
||||
|
||||
if (aNotify) {
|
||||
mDocument->AttributeChanged(this, aNameSpaceID, aName,
|
||||
nsIDOMMutationEvent::REMOVAL);
|
||||
document->AttributeChanged(this, aNameSpaceID, aName,
|
||||
nsIDOMMutationEvent::REMOVAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3468,7 +3495,7 @@ nsGenericElement::GetAttrCount() const
|
|||
void
|
||||
nsGenericElement::List(FILE* out, PRInt32 aIndent) const
|
||||
{
|
||||
NS_PRECONDITION(nsnull != mDocument, "bad content");
|
||||
NS_PRECONDITION(IsInDoc(), "bad content");
|
||||
|
||||
PRInt32 index;
|
||||
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
|
@ -3509,8 +3536,9 @@ nsGenericElement::List(FILE* out, PRInt32 aIndent) const
|
|||
|
||||
fputs(">\n", out);
|
||||
|
||||
if (mDocument) {
|
||||
nsIBindingManager* bindingManager = mDocument->GetBindingManager();
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
if (document) {
|
||||
nsIBindingManager* bindingManager = document->GetBindingManager();
|
||||
if (bindingManager) {
|
||||
nsCOMPtr<nsIDOMNodeList> anonymousChildren;
|
||||
bindingManager->GetAnonymousNodesFor(NS_CONST_CAST(nsGenericElement*, this),
|
||||
|
|
|
@ -100,6 +100,8 @@ typedef unsigned long PtrBits;
|
|||
((PRUint32)((~PtrBits(0)) >> GENERIC_ELEMENT_CONTENT_ID_BITS_OFFSET))
|
||||
|
||||
|
||||
#define PARENT_BIT_INDOCUMENT ((PtrBits)0x1 << 0)
|
||||
|
||||
/**
|
||||
* Class that implements the nsIDOMNodeList interface (a list of children of
|
||||
* the content), by holding a reference to the content and delegating GetLength
|
||||
|
@ -348,8 +350,20 @@ public:
|
|||
static void Shutdown();
|
||||
|
||||
// nsIContent interface methods
|
||||
nsIDocument* GetDocument() const
|
||||
{
|
||||
return IsInDoc() ? GetOwnerDoc() : nsnull;
|
||||
}
|
||||
virtual void SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers);
|
||||
PRBool IsInDoc() const
|
||||
{
|
||||
return mParentPtrBits & PARENT_BIT_INDOCUMENT;
|
||||
}
|
||||
nsIDocument *GetOwnerDoc() const
|
||||
{
|
||||
return mNodeInfo->GetDocument();
|
||||
}
|
||||
virtual void SetParent(nsIContent* aParent);
|
||||
virtual PRBool IsNativeAnonymous() const;
|
||||
virtual void SetNativeAnonymous(PRBool aAnonymous);
|
||||
|
@ -722,19 +736,6 @@ protected:
|
|||
sEventListenerManagersHash.ops);
|
||||
}
|
||||
|
||||
nsIDocument* GetOwnerDocument() const
|
||||
{
|
||||
return mDocument ? mDocument : nsContentUtils::GetDocument(mNodeInfo);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* GetContentsAsText will take all the textnodes that are children
|
||||
* of |this| and concatenate the text in them into aText. It
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMMutationEvent.h"
|
||||
#include "nsIAttribute.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
/**
|
||||
* Class used to implement DOM text nodes
|
||||
|
@ -51,7 +52,7 @@ class nsTextNode : public nsGenericDOMDataNode,
|
|||
public nsIDOMText
|
||||
{
|
||||
public:
|
||||
nsTextNode();
|
||||
nsTextNode(nsIDocument *aDocument);
|
||||
virtual ~nsTextNode();
|
||||
|
||||
// nsISupports
|
||||
|
@ -74,8 +75,8 @@ public:
|
|||
virtual void DumpContent(FILE* out, PRInt32 aIndent, PRBool aDumpAll) const;
|
||||
#endif
|
||||
|
||||
// nsITextContent
|
||||
virtual already_AddRefed<nsITextContent> CloneContent(PRBool aCloneText);
|
||||
virtual already_AddRefed<nsITextContent> CloneContent(PRBool aCloneText,
|
||||
nsIDocument *aOwnerDocument);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -111,6 +112,8 @@ public:
|
|||
nsITextContent* mContent; // Weak ref; it owns us
|
||||
};
|
||||
|
||||
nsAttributeTextNode() : nsTextNode(nsnull) {
|
||||
}
|
||||
virtual ~nsAttributeTextNode() {
|
||||
DetachListener();
|
||||
}
|
||||
|
@ -128,17 +131,25 @@ private:
|
|||
};
|
||||
|
||||
nsresult
|
||||
NS_NewTextNode(nsITextContent** aInstancePtrResult)
|
||||
NS_NewTextNode(nsITextContent** aInstancePtrResult,
|
||||
nsIDocument *aOwnerDocument)
|
||||
{
|
||||
*aInstancePtrResult = new nsTextNode();
|
||||
NS_ENSURE_TRUE(*aInstancePtrResult, NS_ERROR_OUT_OF_MEMORY);
|
||||
*aInstancePtrResult = nsnull;
|
||||
|
||||
NS_ADDREF(*aInstancePtrResult);
|
||||
nsCOMPtr<nsITextContent> instance = new nsTextNode(aOwnerDocument);
|
||||
NS_ENSURE_TRUE(instance, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (aOwnerDocument && !aOwnerDocument->AddOrphan(instance)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
instance.swap(*aInstancePtrResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsTextNode::nsTextNode()
|
||||
nsTextNode::nsTextNode(nsIDocument *aDocument)
|
||||
: nsGenericDOMDataNode(aDocument)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -194,16 +205,16 @@ nsTextNode::GetNodeType(PRUint16* aNodeType)
|
|||
NS_IMETHODIMP
|
||||
nsTextNode::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsCOMPtr<nsITextContent> textContent = CloneContent(PR_TRUE);
|
||||
nsCOMPtr<nsITextContent> textContent = CloneContent(PR_TRUE, GetOwnerDoc());
|
||||
NS_ENSURE_TRUE(textContent, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return CallQueryInterface(textContent, aReturn);
|
||||
}
|
||||
|
||||
already_AddRefed<nsITextContent>
|
||||
nsTextNode::CloneContent(PRBool aCloneText)
|
||||
nsTextNode::CloneContent(PRBool aCloneText, nsIDocument *aOwnerDocument)
|
||||
{
|
||||
nsTextNode* it = new nsTextNode();
|
||||
nsTextNode* it = new nsTextNode(aOwnerDocument);
|
||||
if (!it)
|
||||
return nsnull;
|
||||
|
||||
|
@ -213,6 +224,10 @@ nsTextNode::CloneContent(PRBool aCloneText)
|
|||
|
||||
NS_ADDREF(it);
|
||||
|
||||
if (aOwnerDocument && !aOwnerDocument->AddOrphan(it)) {
|
||||
NS_RELEASE(it);
|
||||
}
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
|
@ -226,7 +241,7 @@ nsTextNode::IsContentOfType(PRUint32 aFlags) const
|
|||
void
|
||||
nsTextNode::List(FILE* out, PRInt32 aIndent) const
|
||||
{
|
||||
NS_PRECONDITION(mDocument, "bad content");
|
||||
NS_PRECONDITION(IsInDoc(), "bad content");
|
||||
|
||||
PRInt32 index;
|
||||
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
|
@ -243,7 +258,7 @@ nsTextNode::List(FILE* out, PRInt32 aIndent) const
|
|||
void
|
||||
nsTextNode::DumpContent(FILE* out, PRInt32 aIndent, PRBool aDumpAll) const
|
||||
{
|
||||
NS_PRECONDITION(mDocument, "bad content");
|
||||
NS_PRECONDITION(IsInDoc(), "bad content");
|
||||
|
||||
if(aDumpAll) {
|
||||
PRInt32 index;
|
||||
|
|
|
@ -539,13 +539,14 @@ nsGenericHTMLElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
|
|||
void
|
||||
nsGenericHTMLElement::RecreateFrames()
|
||||
{
|
||||
if (!mDocument) {
|
||||
if (!IsInDoc()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PRInt32 numShells = mDocument->GetNumberOfShells();
|
||||
nsIDocument *document = GetOwnerDoc();
|
||||
PRInt32 numShells = document->GetNumberOfShells();
|
||||
for (PRInt32 i = 0; i < numShells; ++i) {
|
||||
nsIPresShell *shell = mDocument->GetShellAt(i);
|
||||
nsIPresShell *shell = document->GetShellAt(i);
|
||||
if (shell) {
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetPrimaryFrameFor(this, &frame);
|
||||
|
@ -584,12 +585,13 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent)
|
|||
aRect.x = aRect.y = 0;
|
||||
aRect.Empty();
|
||||
|
||||
if (!mDocument) {
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
if (!document) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get Presentation shell 0
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
nsIPresShell *presShell = document->GetShellAt(0);
|
||||
|
||||
if (!presShell) {
|
||||
return;
|
||||
|
@ -604,7 +606,7 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent)
|
|||
}
|
||||
|
||||
// Flush all pending notifications so that our frames are uptodate
|
||||
mDocument->FlushPendingNotifications(Flush_Layout);
|
||||
document->FlushPendingNotifications(Flush_Layout);
|
||||
|
||||
// Get the Frame for our content
|
||||
nsIFrame* frame = nsnull;
|
||||
|
@ -629,7 +631,7 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent)
|
|||
rcFrame = frame->GetRect();
|
||||
}
|
||||
|
||||
nsIContent *docElement = mDocument->GetRootContent();
|
||||
nsIContent *docElement = document->GetRootContent();
|
||||
|
||||
// Find the frame parent whose content's tagName either matches
|
||||
// the tagName passed in or is the document element.
|
||||
|
@ -722,7 +724,7 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent)
|
|||
// parent chain. We want the offset parent in this case to be
|
||||
// the body, so we just get the body element from the document.
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLDocument> html_doc(do_QueryInterface(mDocument));
|
||||
nsCOMPtr<nsIDOMHTMLDocument> html_doc(do_QueryInterface(document));
|
||||
|
||||
if (html_doc) {
|
||||
nsCOMPtr<nsIDOMHTMLElement> html_element;
|
||||
|
@ -856,7 +858,7 @@ nsGenericHTMLElement::GetInnerHTML(nsAString& aInnerHTML)
|
|||
{
|
||||
aInnerHTML.Truncate();
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = GetOwnerDocument();
|
||||
nsCOMPtr<nsIDocument> doc = GetOwnerDoc();
|
||||
if (!doc) {
|
||||
return NS_OK; // We rely on the document for doing HTML conversion
|
||||
}
|
||||
|
@ -908,7 +910,7 @@ nsGenericHTMLElement::SetInnerHTML(const nsAString& aInnerHTML)
|
|||
|
||||
nsCOMPtr<nsIDOMDocumentFragment> df;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = GetOwnerDocument();
|
||||
nsCOMPtr<nsIDocument> doc = GetOwnerDoc();
|
||||
|
||||
nsIScriptContext *scx = nsnull;
|
||||
PRBool scripts_enabled = PR_FALSE;
|
||||
|
@ -957,14 +959,15 @@ nsGenericHTMLElement::GetScrollInfo(nsIScrollableView **aScrollableView,
|
|||
*aP2T = 0.0f;
|
||||
*aT2P = 0.0f;
|
||||
|
||||
if (!mDocument) {
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
if (!document) {
|
||||
return;
|
||||
}
|
||||
|
||||
mDocument->FlushPendingNotifications(Flush_Layout);
|
||||
document->FlushPendingNotifications(Flush_Layout);
|
||||
|
||||
// Get the presentation shell
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
nsIPresShell *presShell = document->GetShellAt(0);
|
||||
if (!presShell) {
|
||||
return;
|
||||
}
|
||||
|
@ -1004,7 +1007,7 @@ nsGenericHTMLElement::GetScrollInfo(nsIScrollableView **aScrollableView,
|
|||
}
|
||||
}
|
||||
|
||||
PRBool quirksMode = InNavQuirksMode(mDocument);
|
||||
PRBool quirksMode = InNavQuirksMode(document);
|
||||
if ((quirksMode && mNodeInfo->Equals(nsHTMLAtoms::body)) ||
|
||||
(!quirksMode && mNodeInfo->Equals(nsHTMLAtoms::html))) {
|
||||
// In quirks mode, the scroll info for the body element should map to the
|
||||
|
@ -1256,18 +1259,19 @@ nsGenericHTMLElement::GetClientWidth(PRInt32* aClientWidth)
|
|||
nsresult
|
||||
nsGenericHTMLElement::ScrollIntoView(PRBool aTop)
|
||||
{
|
||||
if (!mDocument) {
|
||||
if (!IsInDoc()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get the presentation shell
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
nsIDocument *document = GetOwnerDoc();
|
||||
nsIPresShell *presShell = document->GetShellAt(0);
|
||||
if (!presShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Now flush to make sure things are up to date
|
||||
mDocument->FlushPendingNotifications(Flush_Layout);
|
||||
document->FlushPendingNotifications(Flush_Layout);
|
||||
|
||||
// Get the primary frame for this element
|
||||
nsIFrame *frame = nsnull;
|
||||
|
@ -1301,13 +1305,14 @@ void
|
|||
nsGenericHTMLElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
PRBool doNothing = aDocument == mDocument; // short circuit useless work
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
PRBool doNothing = aDocument == document; // short circuit useless work
|
||||
|
||||
nsGenericElement::SetDocument(aDocument, aDeep, aCompileEventHandlers);
|
||||
|
||||
ReparseStyleAttribute();
|
||||
if (!doNothing && mDocument) {
|
||||
nsHTMLStyleSheet* sheet = mDocument->GetAttributeStyleSheet();
|
||||
if (!doNothing && aDocument) {
|
||||
nsHTMLStyleSheet* sheet = aDocument->GetAttributeStyleSheet();
|
||||
if (sheet) {
|
||||
mAttrsAndChildren.SetMappedAttrStyleSheet(sheet);
|
||||
}
|
||||
|
@ -1418,11 +1423,12 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsPresContext* aPresContext,
|
|||
{
|
||||
// don't make the link grab the focus if there is no link handler
|
||||
nsILinkHandler *handler = aPresContext->GetLinkHandler();
|
||||
if (handler && mDocument) {
|
||||
if (handler && IsInDoc()) {
|
||||
// If the window is not active, do not allow the focus to bring the
|
||||
// window to the front. We update the focus controller, but do
|
||||
// nothing else.
|
||||
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(mDocument->GetScriptGlobalObject()));
|
||||
nsCOMPtr<nsPIDOMWindow> win =
|
||||
do_QueryInterface(GetOwnerDoc()->GetScriptGlobalObject());
|
||||
nsIFocusController *focusController =
|
||||
win->GetRootFocusController();
|
||||
PRBool isActive = PR_FALSE;
|
||||
|
@ -1555,7 +1561,7 @@ nsGenericHTMLElement::GetHrefURIForAnchors(nsIURI** aURI)
|
|||
// Get absolute URI.
|
||||
nsresult rv = nsContentUtils::NewURIWithDocumentCharset(aURI,
|
||||
relURISpec,
|
||||
mDocument,
|
||||
GetCurrentDoc(),
|
||||
baseURI);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aURI = nsnull;
|
||||
|
@ -1592,7 +1598,7 @@ nsGenericHTMLElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aAttribute,
|
|||
PRBool hasListeners = PR_FALSE;
|
||||
PRBool modification = PR_FALSE;
|
||||
|
||||
if (mDocument) {
|
||||
if (IsInDoc()) {
|
||||
hasListeners = nsGenericElement::HasMutationListeners(this,
|
||||
NS_EVENT_BITS_MUTATION_ATTRMODIFIED);
|
||||
|
||||
|
@ -1650,15 +1656,16 @@ nsGenericHTMLElement::SetAttrAndNotify(PRInt32 aNamespaceID,
|
|||
NS_STATIC_CAST(PRUint8, nsIDOMMutationEvent::MODIFICATION) :
|
||||
NS_STATIC_CAST(PRUint8, nsIDOMMutationEvent::ADDITION);
|
||||
|
||||
mozAutoDocUpdate updateBatch(mDocument, UPDATE_CONTENT_MODEL, aNotify);
|
||||
if (aNotify && mDocument) {
|
||||
mDocument->AttributeWillChange(this, aNamespaceID, aAttribute);
|
||||
nsIDocument* document = GetCurrentDoc();
|
||||
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
|
||||
if (aNotify && document) {
|
||||
document->AttributeWillChange(this, aNamespaceID, aAttribute);
|
||||
}
|
||||
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
if (IsAttributeMapped(aAttribute)) {
|
||||
nsHTMLStyleSheet* sheet = mDocument ?
|
||||
mDocument->GetAttributeStyleSheet() : nsnull;
|
||||
nsHTMLStyleSheet* sheet = document ?
|
||||
document->GetAttributeStyleSheet() : nsnull;
|
||||
rv = mAttrsAndChildren.SetAndTakeMappedAttr(aAttribute, aParsedValue,
|
||||
this, sheet);
|
||||
}
|
||||
|
@ -1678,9 +1685,9 @@ nsGenericHTMLElement::SetAttrAndNotify(PRInt32 aNamespaceID,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (mDocument) {
|
||||
if (document) {
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
mDocument->GetBindingManager()->GetBinding(this, getter_AddRefs(binding));
|
||||
document->GetBindingManager()->GetBinding(this, getter_AddRefs(binding));
|
||||
if (binding) {
|
||||
binding->AttributeChanged(aAttribute, aNamespaceID, PR_FALSE, aNotify);
|
||||
}
|
||||
|
@ -1717,7 +1724,7 @@ nsGenericHTMLElement::SetAttrAndNotify(PRInt32 aNamespaceID,
|
|||
}
|
||||
|
||||
if (aNotify) {
|
||||
mDocument->AttributeChanged(this, aNamespaceID, aAttribute, modType);
|
||||
document->AttributeChanged(this, aNamespaceID, aAttribute, modType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1954,7 +1961,7 @@ nsGenericHTMLElement::SetInlineStyleRule(nsICSSStyleRule* aStyleRule,
|
|||
PRBool modification = PR_FALSE;
|
||||
nsAutoString oldValueStr;
|
||||
|
||||
if (mDocument) {
|
||||
if (IsInDoc()) {
|
||||
hasListeners = nsGenericElement::HasMutationListeners(this,
|
||||
NS_EVENT_BITS_MUTATION_ATTRMODIFIED);
|
||||
|
||||
|
@ -1981,7 +1988,7 @@ nsGenericHTMLElement::SetInlineStyleRule(nsICSSStyleRule* aStyleRule,
|
|||
already_AddRefed<nsIURI>
|
||||
nsGenericHTMLElement::GetBaseURI() const
|
||||
{
|
||||
nsIDocument* doc = GetOwnerDocument();
|
||||
nsIDocument* doc = GetOwnerDoc();
|
||||
|
||||
const nsAttrValue* val = mAttrsAndChildren.GetAttr(nsHTMLAtoms::_baseHref);
|
||||
if (val) {
|
||||
|
@ -2025,8 +2032,8 @@ nsGenericHTMLElement::GetBaseTarget(nsAString& aBaseTarget) const
|
|||
return;
|
||||
}
|
||||
|
||||
if (mDocument) {
|
||||
mDocument->GetBaseTarget(aBaseTarget);
|
||||
if (IsInDoc()) {
|
||||
GetOwnerDoc()->GetBaseTarget(aBaseTarget);
|
||||
}
|
||||
else {
|
||||
aBaseTarget.Truncate();
|
||||
|
@ -2069,7 +2076,7 @@ nsGenericHTMLElement::ListAttributes(FILE* out) const
|
|||
void
|
||||
nsGenericHTMLElement::List(FILE* out, PRInt32 aIndent) const
|
||||
{
|
||||
NS_PRECONDITION(nsnull != mDocument, "bad content");
|
||||
NS_PRECONDITION(IsInDoc(), "bad content");
|
||||
|
||||
PRInt32 index;
|
||||
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
|
@ -2099,7 +2106,7 @@ void
|
|||
nsGenericHTMLElement::DumpContent(FILE* out, PRInt32 aIndent,
|
||||
PRBool aDumpAll) const
|
||||
{
|
||||
NS_PRECONDITION(nsnull != mDocument, "bad content");
|
||||
NS_PRECONDITION(IsInDoc(), "bad content");
|
||||
|
||||
PRInt32 index;
|
||||
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
|
@ -2480,7 +2487,7 @@ PRBool
|
|||
nsGenericHTMLElement::ParseTableHAlignValue(const nsAString& aString,
|
||||
nsAttrValue& aResult) const
|
||||
{
|
||||
if (InNavQuirksMode(mDocument)) {
|
||||
if (InNavQuirksMode(GetCurrentDoc())) {
|
||||
return aResult.ParseEnumValue(aString, kCompatTableHAlignTable);
|
||||
}
|
||||
return aResult.ParseEnumValue(aString, kTableHAlignTable);
|
||||
|
@ -2490,7 +2497,7 @@ PRBool
|
|||
nsGenericHTMLElement::TableHAlignValueToString(const nsHTMLValue& aValue,
|
||||
nsAString& aResult) const
|
||||
{
|
||||
if (InNavQuirksMode(mDocument)) {
|
||||
if (InNavQuirksMode(GetCurrentDoc())) {
|
||||
return aValue.EnumValueToString(kCompatTableHAlignTable, aResult);
|
||||
}
|
||||
return aValue.EnumValueToString(kTableHAlignTable, aResult);
|
||||
|
@ -2529,7 +2536,7 @@ PRBool
|
|||
nsGenericHTMLElement::ParseTableCellHAlignValue(const nsAString& aString,
|
||||
nsAttrValue& aResult) const
|
||||
{
|
||||
if (InNavQuirksMode(mDocument)) {
|
||||
if (InNavQuirksMode(GetCurrentDoc())) {
|
||||
return aResult.ParseEnumValue(aString, kCompatTableCellHAlignTable);
|
||||
}
|
||||
return aResult.ParseEnumValue(aString, kTableCellHAlignTable);
|
||||
|
@ -2539,7 +2546,7 @@ PRBool
|
|||
nsGenericHTMLElement::TableCellHAlignValueToString(const nsHTMLValue& aValue,
|
||||
nsAString& aResult) const
|
||||
{
|
||||
if (InNavQuirksMode(mDocument)) {
|
||||
if (InNavQuirksMode(GetCurrentDoc())) {
|
||||
return aValue.EnumValueToString(kCompatTableCellHAlignTable, aResult);
|
||||
}
|
||||
return aValue.EnumValueToString(kTableCellHAlignTable, aResult);
|
||||
|
@ -3168,7 +3175,7 @@ nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsAString& aResult)
|
|||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
nsCOMPtr<nsIURI> attrURI;
|
||||
rv = nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(attrURI),
|
||||
attrValue, GetOwnerDocument(),
|
||||
attrValue, GetOwnerDoc(),
|
||||
baseURI);
|
||||
if (NS_FAILED(rv)) {
|
||||
// Just use the attr value as the result...
|
||||
|
@ -3279,8 +3286,8 @@ nsGenericHTMLFrameElement::IsFocusable(PRInt32 *aTabIndex)
|
|||
|
||||
// If there is no subdocument, docshell or content viewer, it's not tabbable
|
||||
PRBool isFocusable = PR_FALSE;
|
||||
if (mDocument) {
|
||||
nsIDocument *subDoc = mDocument->GetSubDocumentFor(this);
|
||||
if (IsInDoc()) {
|
||||
nsIDocument *subDoc = GetOwnerDoc()->GetSubDocumentFor(this);
|
||||
if (subDoc) {
|
||||
nsCOMPtr<nsISupports> container = subDoc->GetContainer();
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
|
||||
|
@ -3314,7 +3321,7 @@ nsGenericHTMLFormElement::SetParent(nsIContent* aParent)
|
|||
{
|
||||
if (!aParent && mForm) {
|
||||
SetForm(nsnull);
|
||||
} else if (mDocument && aParent && (GetParent() || !mForm)) {
|
||||
} else if (IsInDoc() && 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
|
||||
|
@ -3488,7 +3495,7 @@ nsGenericHTMLFrameElement::GetContentWindow(nsIDOMWindow** aContentWindow)
|
|||
nsresult
|
||||
nsGenericHTMLFrameElement::EnsureFrameLoader()
|
||||
{
|
||||
if (!GetParent() || !mDocument || mFrameLoader) {
|
||||
if (!GetParent() || !IsInDoc() || mFrameLoader) {
|
||||
// If frame loader is there, we just keep it around, cached
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3539,7 +3546,7 @@ nsGenericHTMLFrameElement::SetParent(nsIContent *aParent)
|
|||
|
||||
// When parent is being set to null on the element's destruction, do not
|
||||
// call LoadSrc().
|
||||
if (!GetParent() || !mDocument) {
|
||||
if (!GetParent() || !IsInDoc()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3550,7 +3557,7 @@ void
|
|||
nsGenericHTMLFrameElement::SetDocument(nsIDocument *aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
const nsIDocument *old_doc = mDocument;
|
||||
const nsIDocument *old_doc = GetCurrentDoc();
|
||||
|
||||
nsGenericHTMLElement::SetDocument(aDocument, aDeep,
|
||||
aCompileEventHandlers);
|
||||
|
@ -3651,7 +3658,7 @@ nsGenericHTMLElement::RemoveFocus(nsPresContext *aPresContext)
|
|||
}
|
||||
}
|
||||
|
||||
if (mDocument) {
|
||||
if (IsInDoc()) {
|
||||
aPresContext->EventStateManager()->SetContentState(nsnull,
|
||||
NS_EVENT_STATE_FOCUS);
|
||||
}
|
||||
|
|
|
@ -275,11 +275,11 @@ public:
|
|||
*/
|
||||
nsIFormControlFrame* GetFormControlFrame(PRBool aFlushContent)
|
||||
{
|
||||
if (!mDocument) {
|
||||
if (!IsInDoc()) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return GetFormControlFrameFor(this, mDocument, aFlushContent);
|
||||
return GetFormControlFrameFor(this, GetOwnerDoc(), aFlushContent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -290,11 +290,11 @@ public:
|
|||
*/
|
||||
nsIFrame* GetPrimaryFrame(PRBool aFlushContent)
|
||||
{
|
||||
if (!mDocument) {
|
||||
if (!IsInDoc()) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return GetPrimaryFrameFor(this, mDocument, aFlushContent);
|
||||
return GetPrimaryFrameFor(this, GetOwnerDoc(), aFlushContent);
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
|
|
|
@ -173,17 +173,18 @@ void
|
|||
nsHTMLAnchorElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
PRBool documentChanging = (aDocument != mDocument);
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
PRBool documentChanging = (aDocument != document);
|
||||
|
||||
// Unregister the access key for the old document.
|
||||
if (documentChanging && mDocument) {
|
||||
if (documentChanging && document) {
|
||||
RegUnRegAccessKey(PR_FALSE);
|
||||
}
|
||||
|
||||
nsGenericHTMLElement::SetDocument(aDocument, aDeep, aCompileEventHandlers);
|
||||
|
||||
// Register the access key for the new document.
|
||||
if (documentChanging && mDocument) {
|
||||
if (documentChanging && aDocument) {
|
||||
RegUnRegAccessKey(PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
@ -218,8 +219,8 @@ nsHTMLAnchorElement::SetFocus(nsPresContext* aPresContext)
|
|||
NS_EVENT_STATE_FOCUS);
|
||||
|
||||
// Make sure the presentation is up-to-date
|
||||
if (mDocument) {
|
||||
mDocument->FlushPendingNotifications(Flush_Layout);
|
||||
if (IsInDoc()) {
|
||||
GetOwnerDoc()->FlushPendingNotifications(Flush_Layout);
|
||||
}
|
||||
|
||||
nsIPresShell *presShell = aPresContext->GetPresShell();
|
||||
|
@ -277,8 +278,7 @@ nsHTMLAnchorElement::GetTarget(nsAString& aValue)
|
|||
{
|
||||
aValue.Truncate();
|
||||
|
||||
nsresult rv;
|
||||
rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, aValue);
|
||||
nsresult rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, aValue);
|
||||
if (rv == NS_CONTENT_ATTR_NOT_THERE) {
|
||||
GetBaseTarget(aValue);
|
||||
}
|
||||
|
@ -301,8 +301,7 @@ nsHTMLAnchorElement::GetProtocol(nsAString& aProtocol)
|
|||
return rv;
|
||||
|
||||
// XXX this should really use GetHrefURI and not do so much string stuff
|
||||
return GetProtocolFromHrefString(href, aProtocol,
|
||||
nsGenericHTMLElement::GetOwnerDocument());
|
||||
return GetProtocolFromHrefString(href, aProtocol, GetOwnerDoc());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -185,8 +185,8 @@ nsHTMLAreaElement::SetFocus(nsPresContext* aPresContext)
|
|||
NS_EVENT_STATE_FOCUS);
|
||||
|
||||
// Make sure the presentation is up-to-date
|
||||
if (mDocument) {
|
||||
mDocument->FlushPendingNotifications(Flush_Layout);
|
||||
if (IsInDoc()) {
|
||||
GetOwnerDoc()->FlushPendingNotifications(Flush_Layout);
|
||||
}
|
||||
|
||||
nsIPresShell *presShell = aPresContext->GetPresShell();
|
||||
|
@ -205,17 +205,18 @@ void
|
|||
nsHTMLAreaElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
PRBool documentChanging = (aDocument != mDocument);
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
PRBool documentChanging = (aDocument != document);
|
||||
|
||||
// Unregister the access key for the old document.
|
||||
if (documentChanging && mDocument) {
|
||||
if (documentChanging && document) {
|
||||
RegUnRegAccessKey(PR_FALSE);
|
||||
}
|
||||
|
||||
nsGenericHTMLElement::SetDocument(aDocument, aDeep, aCompileEventHandlers);
|
||||
|
||||
// Register the access key for the new document.
|
||||
if (documentChanging && mDocument) {
|
||||
if (documentChanging && aDocument) {
|
||||
RegUnRegAccessKey(PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
@ -266,8 +267,7 @@ nsHTMLAreaElement::GetProtocol(nsAString& aProtocol)
|
|||
return rv;
|
||||
|
||||
// XXX this should really use GetHrefURI and not do so much string stuff
|
||||
return GetProtocolFromHrefString(href, aProtocol,
|
||||
nsGenericHTMLElement::GetOwnerDocument());
|
||||
return GetProtocolFromHrefString(href, aProtocol, GetOwnerDoc());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -374,11 +374,12 @@ nsHTMLBodyElement::GetBgColor(nsAString& aBgColor)
|
|||
// If we don't have an attribute, find the actual color used for
|
||||
// (generally from the user agent style sheet) for compatibility
|
||||
if (rv == NS_CONTENT_ATTR_NOT_THERE) {
|
||||
if (mDocument) {
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
if (document) {
|
||||
// Make sure the style is up-to-date, since we need it
|
||||
mDocument->FlushPendingNotifications(Flush_Style);
|
||||
document->FlushPendingNotifications(Flush_Style);
|
||||
|
||||
nsIFrame* frame = GetPrimaryFrameFor(this, mDocument, PR_FALSE);
|
||||
nsIFrame* frame = GetPrimaryFrameFor(this, document, PR_FALSE);
|
||||
|
||||
if (frame) {
|
||||
bgcolor = frame->GetStyleBackground()->mBackgroundColor;
|
||||
|
@ -415,7 +416,7 @@ nsHTMLBodyElement::ParseAttribute(nsIAtom* aAttribute,
|
|||
aAttribute == nsHTMLAtoms::link ||
|
||||
aAttribute == nsHTMLAtoms::alink ||
|
||||
aAttribute == nsHTMLAtoms::vlink) {
|
||||
return aResult.ParseColor(aValue, nsGenericHTMLElement::GetOwnerDocument());
|
||||
return aResult.ParseColor(aValue, GetOwnerDoc());
|
||||
}
|
||||
if (aAttribute == nsHTMLAtoms::marginwidth ||
|
||||
aAttribute == nsHTMLAtoms::marginheight ||
|
||||
|
@ -433,7 +434,8 @@ void
|
|||
nsHTMLBodyElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
if (aDocument != mDocument && mContentStyleRule) {
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
if (aDocument != document && mContentStyleRule) {
|
||||
mContentStyleRule->mPart = nsnull;
|
||||
mContentStyleRule->mSheet = nsnull;
|
||||
|
||||
|
@ -501,8 +503,9 @@ nsHTMLBodyElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
|
|||
{
|
||||
nsGenericHTMLElement::WalkContentStyleRules(aRuleWalker);
|
||||
|
||||
if (!mContentStyleRule && mDocument) {
|
||||
mContentStyleRule = new BodyRule(this, mDocument->GetAttributeStyleSheet());
|
||||
if (!mContentStyleRule && IsInDoc()) {
|
||||
mContentStyleRule = new BodyRule(this,
|
||||
GetOwnerDoc()->GetAttributeStyleSheet());
|
||||
NS_IF_ADDREF(mContentStyleRule);
|
||||
}
|
||||
if (aRuleWalker && mContentStyleRule) {
|
||||
|
|
|
@ -198,9 +198,9 @@ nsHTMLButtonElement::Click()
|
|||
mHandlingClick = PR_TRUE;
|
||||
// Hold on to the document in case one of the events makes it die or
|
||||
// something...
|
||||
nsCOMPtr<nsIDocument> doc = mDocument;
|
||||
nsCOMPtr<nsIDocument> doc = GetCurrentDoc();
|
||||
|
||||
if (mDocument) {
|
||||
if (doc) {
|
||||
nsIPresShell *shell = doc->GetShellAt(0);
|
||||
if (shell) {
|
||||
nsCOMPtr<nsPresContext> context;
|
||||
|
|
|
@ -134,7 +134,7 @@ nsHTMLFontElement::ParseAttribute(nsIAtom* aAttribute,
|
|||
return aResult.ParseIntValue(aValue);
|
||||
}
|
||||
if (aAttribute == nsHTMLAtoms::color) {
|
||||
return aResult.ParseColor(aValue, nsGenericHTMLElement::GetOwnerDocument());
|
||||
return aResult.ParseColor(aValue, GetOwnerDoc());
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
|
||||
|
|
|
@ -652,10 +652,10 @@ void
|
|||
nsHTMLFormElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLDocument> oldDocument = do_QueryInterface(mDocument);
|
||||
nsCOMPtr<nsIHTMLDocument> oldDocument = do_QueryInterface(GetCurrentDoc());
|
||||
nsGenericHTMLElement::SetDocument(aDocument, aDeep, aCompileEventHandlers);
|
||||
|
||||
nsCOMPtr<nsIHTMLDocument> newDocument = do_QueryInterface(mDocument);
|
||||
nsCOMPtr<nsIHTMLDocument> newDocument = do_QueryInterface(GetCurrentDoc());
|
||||
if (oldDocument != newDocument) {
|
||||
if (oldDocument) {
|
||||
oldDocument->RemovedForm();
|
||||
|
@ -763,8 +763,8 @@ nsHTMLFormElement::DoSubmitOrReset(nsPresContext* aPresContext,
|
|||
NS_ENSURE_ARG_POINTER(aPresContext);
|
||||
|
||||
// Make sure the presentation is up-to-date
|
||||
if (mDocument) {
|
||||
mDocument->FlushPendingNotifications(Flush_ContentAndNotify);
|
||||
if (IsInDoc()) {
|
||||
GetOwnerDoc()->FlushPendingNotifications(Flush_ContentAndNotify);
|
||||
}
|
||||
|
||||
// JBK Don't get form frames anymore - bug 34297
|
||||
|
@ -975,7 +975,8 @@ nsHTMLFormElement::NotifySubmitObservers(nsIURI* aActionURL,
|
|||
nsCOMPtr<nsISupports> inst;
|
||||
*aCancelSubmit = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> window = do_QueryInterface(mDocument->GetScriptGlobalObject());
|
||||
nsCOMPtr<nsIDOMWindowInternal> window =
|
||||
do_QueryInterface(GetOwnerDoc()->GetScriptGlobalObject());
|
||||
|
||||
PRBool loop = PR_TRUE;
|
||||
while (NS_SUCCEEDED(theEnum->HasMoreElements(&loop)) && loop) {
|
||||
|
@ -1244,12 +1245,13 @@ nsHTMLFormElement::GetActionURL(nsIURI** aActionURL)
|
|||
// Get the document to form the URL.
|
||||
// We'll also need it later to get the DOM window when notifying form submit
|
||||
// observers (bug 33203)
|
||||
if (!mDocument) {
|
||||
if (!IsInDoc()) {
|
||||
return NS_OK; // No doc means don't submit, see Bug 28988
|
||||
}
|
||||
|
||||
// Get base URL
|
||||
nsIURI *docURI = mDocument->GetDocumentURI();
|
||||
nsIDocument *document = GetOwnerDoc();
|
||||
nsIURI *docURI = document->GetDocumentURI();
|
||||
NS_ENSURE_TRUE(docURI, NS_ERROR_UNEXPECTED);
|
||||
|
||||
// If an action is not specified and we are inside
|
||||
|
@ -1261,7 +1263,7 @@ nsHTMLFormElement::GetActionURL(nsIURI** aActionURL)
|
|||
|
||||
nsCOMPtr<nsIURI> actionURL;
|
||||
if (action.IsEmpty()) {
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(mDocument));
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(document));
|
||||
if (!htmlDoc) {
|
||||
// Must be a XML, XUL or other non-HTML document type
|
||||
// so do nothing.
|
||||
|
@ -1288,7 +1290,7 @@ nsHTMLFormElement::GetActionURL(nsIURI** aActionURL)
|
|||
nsIScriptSecurityManager *securityManager =
|
||||
nsContentUtils::GetSecurityManager();
|
||||
rv = securityManager->
|
||||
CheckLoadURIWithPrincipal(mDocument->GetPrincipal(), actionURL,
|
||||
CheckLoadURIWithPrincipal(document->GetPrincipal(), actionURL,
|
||||
nsIScriptSecurityManager::STANDARD);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ nsHTMLFrameElement::ParseAttribute(nsIAtom* aAttribute,
|
|||
nsAttrValue& aResult)
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::bordercolor) {
|
||||
return aResult.ParseColor(aValue, nsGenericHTMLFrameElement::GetOwnerDocument());
|
||||
return aResult.ParseColor(aValue, nsGenericHTMLFrameElement::GetOwnerDoc());
|
||||
}
|
||||
if (aAttribute == nsHTMLAtoms::frameborder) {
|
||||
return ParseFrameborderValue(aValue, aResult);
|
||||
|
|
|
@ -292,7 +292,7 @@ nsHTMLFrameSetElement::ParseAttribute(nsIAtom* aAttribute,
|
|||
nsAttrValue& aResult)
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::bordercolor) {
|
||||
return aResult.ParseColor(aValue, nsGenericHTMLElement::GetOwnerDocument());
|
||||
return aResult.ParseColor(aValue, GetOwnerDoc());
|
||||
}
|
||||
if (aAttribute == nsHTMLAtoms::frameborder) {
|
||||
return nsGenericHTMLElement::ParseFrameborderValue(aValue, aResult);
|
||||
|
@ -444,7 +444,7 @@ nsHTMLFrameSetElement::ParseRowColSpec(nsString& aSpec,
|
|||
// Treat 0* as 1* in quirks mode (bug 40383)
|
||||
nsCompatibility mode = eCompatibility_FullStandards;
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDocument =
|
||||
do_QueryInterface(nsGenericHTMLElement::GetOwnerDocument());
|
||||
do_QueryInterface(GetOwnerDoc());
|
||||
if (htmlDocument) {
|
||||
mode = htmlDocument->GetCompatibilityMode();
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ nsHTMLHRElement::ParseAttribute(nsIAtom* aAttribute,
|
|||
return aResult.ParseEnumValue(aValue, kAlignTable);
|
||||
}
|
||||
if (aAttribute == nsHTMLAtoms::color) {
|
||||
return aResult.ParseColor(aValue, nsGenericHTMLElement::GetOwnerDocument());
|
||||
return aResult.ParseColor(aValue, GetOwnerDoc());
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
|
||||
|
|
|
@ -259,12 +259,14 @@ nsHTMLImageElement::GetXY()
|
|||
{
|
||||
nsPoint point(0, 0);
|
||||
|
||||
if (!mDocument) {
|
||||
if (!IsInDoc()) {
|
||||
return point;
|
||||
}
|
||||
|
||||
nsIDocument *document = GetOwnerDoc();
|
||||
|
||||
// Get Presentation shell 0
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
nsIPresShell *presShell = document->GetShellAt(0);
|
||||
if (!presShell) {
|
||||
return point;
|
||||
}
|
||||
|
@ -278,7 +280,7 @@ nsHTMLImageElement::GetXY()
|
|||
}
|
||||
|
||||
// Flush all pending notifications so that our frames are laid out correctly
|
||||
mDocument->FlushPendingNotifications(Flush_Layout);
|
||||
document->FlushPendingNotifications(Flush_Layout);
|
||||
|
||||
// Get the Frame for this image
|
||||
nsIFrame* frame = nsnull;
|
||||
|
@ -327,11 +329,11 @@ nsHTMLImageElement::GetWidthHeight()
|
|||
{
|
||||
nsSize size(0,0);
|
||||
|
||||
if (mDocument) {
|
||||
if (IsInDoc()) {
|
||||
// Flush all pending notifications so that our frames are up to date.
|
||||
// If we're not in a document, we don't have a frame anyway, so we
|
||||
// don't care.
|
||||
mDocument->FlushPendingNotifications(Flush_Layout);
|
||||
GetOwnerDoc()->FlushPendingNotifications(Flush_Layout);
|
||||
}
|
||||
|
||||
nsIImageFrame* imageFrame;
|
||||
|
@ -536,11 +538,11 @@ nsHTMLImageElement::IsFocusable(PRInt32 *aTabIndex)
|
|||
PRInt32 tabIndex;
|
||||
GetTabIndex(&tabIndex);
|
||||
|
||||
if (mDocument) {
|
||||
if (IsInDoc()) {
|
||||
nsAutoString usemap;
|
||||
GetUseMap(usemap);
|
||||
nsCOMPtr<nsIDOMHTMLMapElement> imageMap =
|
||||
nsImageMapUtils::FindImageMap(mDocument, usemap);
|
||||
nsImageMapUtils::FindImageMap(GetOwnerDoc(), usemap);
|
||||
if (imageMap) {
|
||||
if (aTabIndex) {
|
||||
// Use tab index on individual map areas
|
||||
|
@ -605,7 +607,7 @@ void
|
|||
nsHTMLImageElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
PRBool documentChanging = aDocument && (aDocument != mDocument);
|
||||
PRBool documentChanging = aDocument && aDocument != GetCurrentDoc();
|
||||
|
||||
nsGenericHTMLElement::SetDocument(aDocument, aDeep, aCompileEventHandlers);
|
||||
if (documentChanging && GetParent()) {
|
||||
|
@ -623,7 +625,7 @@ void
|
|||
nsHTMLImageElement::SetParent(nsIContent* aParent)
|
||||
{
|
||||
nsGenericHTMLElement::SetParent(aParent);
|
||||
if (aParent && mDocument) {
|
||||
if (aParent && IsInDoc()) {
|
||||
// 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;
|
||||
|
|
|
@ -895,8 +895,8 @@ nsHTMLInputElement::GetRadioGroupContainer()
|
|||
nsIRadioGroupContainer* retval = nsnull;
|
||||
if (mForm) {
|
||||
CallQueryInterface(mForm, &retval);
|
||||
} else if (mDocument && GetParent()) {
|
||||
CallQueryInterface(mDocument, &retval);
|
||||
} else if (IsInDoc() && GetParent()) {
|
||||
CallQueryInterface(GetOwnerDoc(), &retval);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
@ -999,9 +999,10 @@ nsHTMLInputElement::SetCheckedInternal(PRBool aChecked, PRBool aNotify)
|
|||
|
||||
// Notify the document that the CSS :checked pseudoclass for this element
|
||||
// has changed state.
|
||||
if (mDocument && aNotify) {
|
||||
mozAutoDocUpdate(mDocument, UPDATE_CONTENT_STATE, aNotify);
|
||||
mDocument->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_CHECKED);
|
||||
if (IsInDoc() && aNotify) {
|
||||
nsIDocument* document = GetOwnerDoc();
|
||||
mozAutoDocUpdate(document, UPDATE_CONTENT_STATE, aNotify);
|
||||
document->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_CHECKED);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1044,7 +1045,7 @@ nsHTMLInputElement::SetFocus(nsPresContext* aPresContext)
|
|||
return;
|
||||
|
||||
// We can't be focus'd if we don't have a document
|
||||
if (!mDocument)
|
||||
if (!IsInDoc())
|
||||
return;
|
||||
|
||||
// first see if we are disabled or not. If disabled then do nothing.
|
||||
|
@ -1057,7 +1058,8 @@ nsHTMLInputElement::SetFocus(nsPresContext* aPresContext)
|
|||
// If the window is not active, do not allow the focus to bring the
|
||||
// window to the front. We update the focus controller, but do
|
||||
// nothing else.
|
||||
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(mDocument->GetScriptGlobalObject()));
|
||||
nsCOMPtr<nsPIDOMWindow> win =
|
||||
do_QueryInterface(GetOwnerDoc()->GetScriptGlobalObject());
|
||||
nsIFocusController *focusController = win->GetRootFocusController();
|
||||
PRBool isActive = PR_FALSE;
|
||||
focusController->GetActive(&isActive);
|
||||
|
@ -1085,7 +1087,7 @@ NS_IMETHODIMP
|
|||
nsHTMLInputElement::Select()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (!mDocument)
|
||||
if (!IsInDoc())
|
||||
return NS_OK;
|
||||
|
||||
// first see if we are disabled or not. If disabled then do nothing.
|
||||
|
@ -1105,7 +1107,8 @@ nsHTMLInputElement::Select()
|
|||
// If the window is not active, do not allow the select to bring the
|
||||
// window to the front. We update the focus controller, but do
|
||||
// nothing else.
|
||||
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(mDocument->GetScriptGlobalObject()));
|
||||
nsCOMPtr<nsPIDOMWindow> win =
|
||||
do_QueryInterface(GetOwnerDoc()->GetScriptGlobalObject());
|
||||
nsIFocusController *focusController = win->GetRootFocusController();
|
||||
PRBool isActive = PR_FALSE;
|
||||
focusController->GetActive(&isActive);
|
||||
|
@ -1187,7 +1190,7 @@ nsHTMLInputElement::Click()
|
|||
|
||||
// see what type of input we are. Only click button, checkbox, radio,
|
||||
// reset, submit, & image
|
||||
if (mDocument &&
|
||||
if (IsInDoc() &&
|
||||
(mType == NS_FORM_INPUT_BUTTON ||
|
||||
mType == NS_FORM_INPUT_CHECKBOX ||
|
||||
mType == NS_FORM_INPUT_RADIO ||
|
||||
|
@ -1195,7 +1198,8 @@ nsHTMLInputElement::Click()
|
|||
mType == NS_FORM_INPUT_SUBMIT ||
|
||||
mType == NS_FORM_INPUT_IMAGE)) {
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = mDocument; // Strong in case the event kills it
|
||||
// Strong in case the event kills it
|
||||
nsCOMPtr<nsIDocument> doc = GetOwnerDoc();
|
||||
nsCOMPtr<nsPresContext> context;
|
||||
|
||||
nsIPresShell *shell = doc->GetShellAt(0);
|
||||
|
@ -1657,7 +1661,7 @@ void
|
|||
nsHTMLInputElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
PRBool documentChanging = (aDocument != mDocument);
|
||||
PRBool documentChanging = (aDocument != GetCurrentDoc());
|
||||
|
||||
// SetDocument() sets the form and that takes care of form's WillRemove
|
||||
// so we just have to take care of the case where we're removing from the
|
||||
|
@ -1698,7 +1702,7 @@ void
|
|||
nsHTMLInputElement::SetParent(nsIContent* aParent)
|
||||
{
|
||||
nsGenericHTMLFormElement::SetParent(aParent);
|
||||
if (mType == NS_FORM_INPUT_IMAGE && aParent && mDocument) {
|
||||
if (mType == NS_FORM_INPUT_IMAGE && aParent && IsInDoc()) {
|
||||
// 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;
|
||||
|
@ -2533,7 +2537,7 @@ nsHTMLInputElement::AddedToRadioGroup(PRBool aNotify)
|
|||
// If the input element is not in a form and
|
||||
// not in a document, we just need to return.
|
||||
//
|
||||
if (!mForm && !(mDocument && GetParent())) {
|
||||
if (!mForm && !(IsInDoc() && GetParent())) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2588,7 +2592,7 @@ nsHTMLInputElement::WillRemoveFromRadioGroup()
|
|||
// If the input element is not in a form and
|
||||
// not in a document, we just need to return.
|
||||
//
|
||||
if (!mForm && !(mDocument && GetParent())) {
|
||||
if (!mForm && !(IsInDoc() && GetParent())) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -160,10 +160,11 @@ void
|
|||
nsHTMLLabelElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
PRBool documentChanging = (aDocument != mDocument);
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
PRBool documentChanging = (aDocument != document);
|
||||
|
||||
// Unregister the access key for the old document.
|
||||
if (documentChanging && mDocument) {
|
||||
if (documentChanging && document) {
|
||||
RegUnRegAccessKey(PR_FALSE);
|
||||
}
|
||||
|
||||
|
@ -171,7 +172,7 @@ nsHTMLLabelElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
|||
aCompileEventHandlers);
|
||||
|
||||
// Register the access key for the new document.
|
||||
if (documentChanging && mDocument) {
|
||||
if (documentChanging && aDocument) {
|
||||
RegUnRegAccessKey(PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ void
|
|||
nsHTMLLinkElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> oldDoc = mDocument;
|
||||
nsCOMPtr<nsIDocument> oldDoc = GetCurrentDoc();
|
||||
|
||||
nsAutoString rel;
|
||||
nsAutoString rev;
|
||||
|
@ -207,7 +207,7 @@ nsHTMLLinkElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
|||
nsGenericHTMLElement::SetDocument(aDocument, aDeep, aCompileEventHandlers);
|
||||
UpdateStyleSheet(oldDoc);
|
||||
|
||||
CreateAndDispatchEvent(mDocument, rel, rev,
|
||||
CreateAndDispatchEvent(aDocument, rel, rev,
|
||||
NS_LITERAL_STRING("DOMLinkAdded"));
|
||||
}
|
||||
|
||||
|
|
|
@ -108,10 +108,11 @@ void
|
|||
nsHTMLMapElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
PRBool documentChanging = (aDocument != mDocument);
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
PRBool documentChanging = (aDocument != document);
|
||||
|
||||
if (documentChanging) {
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(mDocument));
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(document);
|
||||
|
||||
if (htmlDoc) {
|
||||
htmlDoc->RemoveImageMap(this);
|
||||
|
@ -122,7 +123,7 @@ nsHTMLMapElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
|||
|
||||
if (documentChanging) {
|
||||
// Since we changed the document, gotta re-QI
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(mDocument));
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(aDocument);
|
||||
|
||||
if (htmlDoc) {
|
||||
htmlDoc->AddImageMap(this);
|
||||
|
|
|
@ -213,11 +213,11 @@ nsHTMLObjectElement::GetContentDocument(nsIDOMDocument** aContentDocument)
|
|||
|
||||
*aContentDocument = nsnull;
|
||||
|
||||
if (!mDocument) {
|
||||
if (!IsInDoc()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDocument *sub_doc = mDocument->GetSubDocumentFor(this);
|
||||
nsIDocument *sub_doc = GetOwnerDoc()->GetSubDocumentFor(this);
|
||||
|
||||
if (!sub_doc) {
|
||||
return NS_OK;
|
||||
|
|
|
@ -230,9 +230,10 @@ nsHTMLOptionElement::SetSelectedInternal(PRBool aValue, PRBool aNotify)
|
|||
mIsInitialized = PR_TRUE;
|
||||
mIsSelected = aValue;
|
||||
|
||||
if (aNotify && mDocument) {
|
||||
mozAutoDocUpdate(mDocument, UPDATE_CONTENT_STATE, aNotify);
|
||||
mDocument->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_CHECKED);
|
||||
if (aNotify && IsInDoc()) {
|
||||
nsIDocument* document = GetOwnerDoc();
|
||||
mozAutoDocUpdate(document, UPDATE_CONTENT_STATE, aNotify);
|
||||
document->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_CHECKED);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -504,7 +505,7 @@ nsHTMLOptionElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
|||
nsIFormControlFrame *
|
||||
nsHTMLOptionElement::GetSelectFrame() const
|
||||
{
|
||||
if (!GetParent() || !mDocument) {
|
||||
if (!GetParent() || !IsInDoc()) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
@ -518,7 +519,7 @@ nsHTMLOptionElement::GetSelectFrame() const
|
|||
return nsnull;
|
||||
}
|
||||
|
||||
return GetFormControlFrameFor(selectContent, mDocument, PR_FALSE);
|
||||
return GetFormControlFrameFor(selectContent, GetOwnerDoc(), PR_FALSE);
|
||||
}
|
||||
|
||||
// Get the select content element that contains this option
|
||||
|
|
|
@ -649,14 +649,14 @@ nsHTMLScriptElement::GetScriptLineNumber()
|
|||
void
|
||||
nsHTMLScriptElement::MaybeProcessScript()
|
||||
{
|
||||
if (mIsEvaluated || mEvaluating || !mDocument || !GetParent()) {
|
||||
if (mIsEvaluated || mEvaluating || !IsInDoc() || !GetParent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We'll always call this to make sure that
|
||||
// ScriptAvailable/ScriptEvaluated gets called. See bug 153600
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIScriptLoader> loader = mDocument->GetScriptLoader();
|
||||
nsCOMPtr<nsIScriptLoader> loader = GetOwnerDoc()->GetScriptLoader();
|
||||
if (loader) {
|
||||
mEvaluating = PR_TRUE;
|
||||
rv = loader->ProcessScriptElement(this, this);
|
||||
|
|
|
@ -1862,10 +1862,11 @@ nsHTMLSelectElement::GetBoxObject(nsIBoxObject** aResult)
|
|||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
if (!mDocument)
|
||||
if (!IsInDoc())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMNSDocument> nsDoc(do_QueryInterface(mDocument));
|
||||
nsCOMPtr<nsIDOMNSDocument> nsDoc = do_QueryInterface(GetOwnerDoc());
|
||||
|
||||
return nsDoc->GetBoxObjectFor(NS_STATIC_CAST(nsIDOMElement*, this), aResult);
|
||||
}
|
||||
|
||||
|
@ -2031,7 +2032,7 @@ nsHTMLSelectElement::GetHasOptGroups(PRBool* aHasGroups)
|
|||
void
|
||||
nsHTMLSelectElement::DispatchDOMEvent(const nsAString& aName)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocumentEvent> domDoc = do_QueryInterface(mDocument);
|
||||
nsCOMPtr<nsIDOMDocumentEvent> domDoc = do_QueryInterface(GetCurrentDoc());
|
||||
if (domDoc) {
|
||||
nsCOMPtr<nsIDOMEvent> selectEvent;
|
||||
domDoc->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(selectEvent));
|
||||
|
|
|
@ -215,7 +215,7 @@ void
|
|||
nsHTMLStyleElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> oldDoc = mDocument;
|
||||
nsCOMPtr<nsIDocument> oldDoc = GetCurrentDoc();
|
||||
|
||||
nsGenericHTMLElement::SetDocument(aDocument, aDeep, aCompileEventHandlers);
|
||||
|
||||
|
|
|
@ -134,8 +134,9 @@ nsHTMLTableCellElement::GetTable()
|
|||
{
|
||||
nsIContent *result = nsnull;
|
||||
|
||||
if (GetParent()) { // GetParent() should be a row
|
||||
nsIContent* section = GetParent()->GetParent();
|
||||
nsIContent *parent = GetParent();
|
||||
if (parent) { // GetParent() should be a row
|
||||
nsIContent* section = parent->GetParent();
|
||||
if (section) {
|
||||
if (section->IsContentOfType(eHTML) &&
|
||||
section->GetNodeInfo()->Equals(nsHTMLAtoms::table)) {
|
||||
|
@ -282,7 +283,7 @@ nsHTMLTableCellElement::ParseAttribute(nsIAtom* aAttribute,
|
|||
if (res) {
|
||||
PRInt32 val = aResult.GetIntegerValue();
|
||||
// quirks mode does not honor the special html 4 value of 0
|
||||
if (val < 0 || (0 == val && InNavQuirksMode(mDocument))) {
|
||||
if (val < 0 || (0 == val && InNavQuirksMode(GetCurrentDoc()))) {
|
||||
aResult.SetTo(1, nsAttrValue::eInteger);
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +299,7 @@ nsHTMLTableCellElement::ParseAttribute(nsIAtom* aAttribute,
|
|||
return ParseTableCellHAlignValue(aValue, aResult);
|
||||
}
|
||||
if (aAttribute == nsHTMLAtoms::bgcolor) {
|
||||
return aResult.ParseColor(aValue, nsGenericHTMLElement::GetOwnerDocument());
|
||||
return aResult.ParseColor(aValue, GetOwnerDoc());
|
||||
}
|
||||
if (aAttribute == nsHTMLAtoms::scope) {
|
||||
return aResult.ParseEnumValue(aValue, kCellScopeTable);
|
||||
|
|
|
@ -904,7 +904,7 @@ nsHTMLTableElement::ParseAttribute(nsIAtom* aAttribute,
|
|||
}
|
||||
if (aAttribute == nsHTMLAtoms::bgcolor ||
|
||||
aAttribute == nsHTMLAtoms::bordercolor) {
|
||||
return aResult.ParseColor(aValue, nsGenericHTMLElement::GetOwnerDocument());
|
||||
return aResult.ParseColor(aValue, GetOwnerDoc());
|
||||
}
|
||||
if (aAttribute == nsHTMLAtoms::frame) {
|
||||
return aResult.ParseEnumValue(aValue, kFrameTable);
|
||||
|
|
|
@ -403,7 +403,7 @@ nsHTMLTableRowElement::ParseAttribute(nsIAtom* aAttribute,
|
|||
return ParseTableCellHAlignValue(aValue, aResult);
|
||||
}
|
||||
if (aAttribute == nsHTMLAtoms::bgcolor) {
|
||||
return aResult.ParseColor(aValue, nsGenericHTMLElement::GetOwnerDocument());
|
||||
return aResult.ParseColor(aValue, GetOwnerDoc());
|
||||
}
|
||||
if (aAttribute == nsHTMLAtoms::valign) {
|
||||
return ParseTableVAlignValue(aValue, aResult);
|
||||
|
|
|
@ -252,7 +252,7 @@ nsHTMLTableSectionElement::ParseAttribute(nsIAtom* aAttribute,
|
|||
return ParseTableCellHAlignValue(aValue, aResult);
|
||||
}
|
||||
if (aAttribute == nsHTMLAtoms::bgcolor) {
|
||||
return aResult.ParseColor(aValue, nsGenericHTMLElement::GetOwnerDocument());
|
||||
return aResult.ParseColor(aValue, GetOwnerDoc());
|
||||
}
|
||||
if (aAttribute == nsHTMLAtoms::valign) {
|
||||
return ParseTableVAlignValue(aValue, aResult);
|
||||
|
|
|
@ -122,7 +122,7 @@ nsHTMLTitleElement::SetText(const nsAString& aTitle)
|
|||
nsresult result = NS_OK;
|
||||
nsCOMPtr<nsIDOMNode> child;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(mDocument));
|
||||
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(GetCurrentDoc()));
|
||||
|
||||
if (htmlDoc) {
|
||||
htmlDoc->SetTitle(aTitle);
|
||||
|
|
|
@ -1594,8 +1594,6 @@ SinkContext::AddComment(const nsIParserNode& aNode)
|
|||
|
||||
domComment->AppendData(aNode.GetText());
|
||||
|
||||
comment->SetDocument(mSink->mDocument, PR_FALSE, PR_TRUE);
|
||||
|
||||
NS_ASSERTION(mStackPos > 0, "stack out of bounds");
|
||||
if (mStackPos <= 0) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -1862,9 +1860,6 @@ SinkContext::FlushText(PRBool* aDidFlush, PRBool aReleaseLast)
|
|||
|
||||
mLastTextNode = textContent;
|
||||
|
||||
// Set the content's document
|
||||
mLastTextNode->SetDocument(mSink->mDocument, PR_FALSE, PR_TRUE);
|
||||
|
||||
// Set the text in the text node
|
||||
mLastTextNode->SetText(mText, mTextLength, PR_FALSE);
|
||||
|
||||
|
@ -3174,7 +3169,6 @@ HTMLContentSink::SetDocumentTitle(const nsAString& aTitle)
|
|||
text->SetText(mTitle, PR_TRUE);
|
||||
|
||||
it->AppendChildTo(text, PR_FALSE, PR_FALSE);
|
||||
text->SetDocument(mDocument, PR_FALSE, PR_TRUE);
|
||||
|
||||
mHead->AppendChildTo(it, PR_FALSE, PR_FALSE);
|
||||
|
||||
|
@ -4225,7 +4219,6 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
|
|||
text->SetText(script, PR_TRUE);
|
||||
|
||||
element->AppendChildTo(text, PR_FALSE, PR_FALSE);
|
||||
text->SetDocument(mDocument, PR_FALSE, PR_TRUE);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptLoader> loader;
|
||||
|
|
|
@ -75,6 +75,7 @@ nsSVGElement::~nsSVGElement()
|
|||
for (i = 0; i < count; ++i) {
|
||||
mMappedAttributes.AttrAt(i)->GetSVGValue()->RemoveObserver(this);
|
||||
}
|
||||
mMappedAttributes.Clear();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -130,7 +131,7 @@ nsSVGElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aName, nsIAtom* aPrefix,
|
|||
|
||||
PRInt32 index = mAttrsAndChildren.IndexOfAttr(aName, aNamespaceID);
|
||||
|
||||
if (mDocument) {
|
||||
if (IsInDoc()) {
|
||||
hasListeners = nsGenericElement::HasMutationListeners(this,
|
||||
NS_EVENT_BITS_MUTATION_ATTRMODIFIED);
|
||||
|
||||
|
@ -214,9 +215,10 @@ nsSVGElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aName, nsIAtom* aPrefix,
|
|||
// creation as well as for the root element of a document
|
||||
// we're parsing. But in famous last words, this code will
|
||||
// be changing soon to allow multiple onloads per document.
|
||||
if (mDocument && !mDocument->GetRootContent()) {
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
if (document && !document->GetRootContent()) {
|
||||
nsCOMPtr<nsIDOMEventReceiver> receiver =
|
||||
do_QueryInterface(mDocument->GetScriptGlobalObject());
|
||||
do_QueryInterface(document->GetScriptGlobalObject());
|
||||
if (receiver) {
|
||||
receiver->GetListenerManager(getter_AddRefs(manager));
|
||||
}
|
||||
|
@ -308,7 +310,7 @@ nsSVGElement::SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify)
|
|||
PRBool modification = PR_FALSE;
|
||||
nsAutoString oldValueStr;
|
||||
|
||||
if (mDocument) {
|
||||
if (IsInDoc()) {
|
||||
hasListeners = nsGenericElement::HasMutationListeners(this,
|
||||
NS_EVENT_BITS_MUTATION_ATTRMODIFIED);
|
||||
|
||||
|
@ -452,8 +454,8 @@ nsSVGElement::GetOwnerSVGElement(nsIDOMSVGSVGElement * *aOwnerSVGElement)
|
|||
*aOwnerSVGElement = nsnull;
|
||||
|
||||
nsIBindingManager *bindingManager = nsnull;
|
||||
if (mDocument) {
|
||||
bindingManager = mDocument->GetBindingManager();
|
||||
if (IsInDoc()) {
|
||||
bindingManager = GetOwnerDoc()->GetBindingManager();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
|
@ -548,7 +550,7 @@ nsSVGElement::DidModifySVGObservable(nsISVGValue* aObservable)
|
|||
const nsAttrName* attrName = mMappedAttributes.GetSafeAttrNameAt(i);
|
||||
PRBool modification = PR_FALSE;
|
||||
PRBool hasListeners = PR_FALSE;
|
||||
if (mDocument) {
|
||||
if (IsInDoc()) {
|
||||
modification = !!mAttrsAndChildren.GetAttr(attrName->LocalName(),
|
||||
attrName->NamespaceID());
|
||||
hasListeners = nsGenericElement::HasMutationListeners(this,
|
||||
|
@ -612,9 +614,10 @@ nsSVGElement::SetAttrAndNotify(PRInt32 aNamespaceID, nsIAtom* aAttribute,
|
|||
NS_STATIC_CAST(PRUint8, nsIDOMMutationEvent::MODIFICATION) :
|
||||
NS_STATIC_CAST(PRUint8, nsIDOMMutationEvent::ADDITION);
|
||||
|
||||
mozAutoDocUpdate updateBatch(mDocument, UPDATE_CONTENT_MODEL, aNotify);
|
||||
if (aNotify && mDocument) {
|
||||
mDocument->AttributeWillChange(this, aNamespaceID, aAttribute);
|
||||
nsIDocument* document = GetCurrentDoc();
|
||||
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
|
||||
if (aNotify && document) {
|
||||
document->AttributeWillChange(this, aNamespaceID, aAttribute);
|
||||
}
|
||||
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
|
@ -633,9 +636,9 @@ nsSVGElement::SetAttrAndNotify(PRInt32 aNamespaceID, nsIAtom* aAttribute,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (mDocument) {
|
||||
if (document) {
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
mDocument->GetBindingManager()->GetBinding(this, getter_AddRefs(binding));
|
||||
document->GetBindingManager()->GetBinding(this, getter_AddRefs(binding));
|
||||
if (binding) {
|
||||
binding->AttributeChanged(aAttribute, aNamespaceID, PR_FALSE, aNotify);
|
||||
}
|
||||
|
@ -669,7 +672,7 @@ nsSVGElement::SetAttrAndNotify(PRInt32 aNamespaceID, nsIAtom* aAttribute,
|
|||
}
|
||||
|
||||
if (aNotify) {
|
||||
mDocument->AttributeChanged(this, aNamespaceID, aAttribute, modType);
|
||||
document->AttributeChanged(this, aNamespaceID, aAttribute, modType);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,8 +114,8 @@ NS_IMETHODIMP nsSVGGraphicElement::GetBBox(nsIDOMSVGRect **_retval)
|
|||
{
|
||||
*_retval = nsnull;
|
||||
|
||||
if (!mDocument) return NS_ERROR_FAILURE;
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
if (!IsInDoc()) return NS_ERROR_FAILURE;
|
||||
nsIPresShell *presShell = GetOwnerDoc()->GetShellAt(0);
|
||||
NS_ASSERTION(presShell, "no presShell");
|
||||
if (!presShell) return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -141,8 +141,8 @@ NS_IMETHODIMP nsSVGGraphicElement::GetCTM(nsIDOMSVGMatrix **_retval)
|
|||
nsCOMPtr<nsIDOMSVGMatrix> CTM;
|
||||
|
||||
nsIBindingManager *bindingManager = nsnull;
|
||||
if (mDocument) {
|
||||
bindingManager = mDocument->GetBindingManager();
|
||||
if (IsInDoc()) {
|
||||
bindingManager = GetOwnerDoc()->GetBindingManager();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
|
@ -216,8 +216,8 @@ NS_IMETHODIMP nsSVGGraphicElement::GetScreenCTM(nsIDOMSVGMatrix **_retval)
|
|||
nsCOMPtr<nsIDOMSVGMatrix> screenCTM;
|
||||
|
||||
nsIBindingManager *bindingManager = nsnull;
|
||||
if (mDocument) {
|
||||
bindingManager = mDocument->GetBindingManager();
|
||||
if (IsInDoc()) {
|
||||
bindingManager = GetOwnerDoc()->GetBindingManager();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
|
|
|
@ -352,9 +352,9 @@ nsSVGSVGElement::GetPixelUnitToMillimeterX(float *aPixelUnitToMillimeterX)
|
|||
|
||||
*aPixelUnitToMillimeterX = 0.28f; // 90dpi
|
||||
|
||||
if (!mDocument) return NS_OK;
|
||||
if (!IsInDoc()) return NS_OK;
|
||||
// Get Presentation shell 0
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
nsIPresShell *presShell = GetOwnerDoc()->GetShellAt(0);
|
||||
if (!presShell) return NS_OK;
|
||||
|
||||
// Get the Presentation Context from the Shell
|
||||
|
@ -382,9 +382,9 @@ nsSVGSVGElement::GetScreenPixelToMillimeterX(float *aScreenPixelToMillimeterX)
|
|||
|
||||
*aScreenPixelToMillimeterX = 0.28f; // 90dpi
|
||||
|
||||
if (!mDocument) return NS_OK;
|
||||
if (!IsInDoc()) return NS_OK;
|
||||
// Get Presentation shell 0
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
nsIPresShell *presShell = GetOwnerDoc()->GetShellAt(0);
|
||||
if (!presShell) return NS_OK;
|
||||
|
||||
// Get the Presentation Context from the Shell
|
||||
|
@ -457,8 +457,8 @@ nsSVGSVGElement::SuspendRedraw(PRUint32 max_wait_milliseconds, PRUint32 *_retval
|
|||
if (++mRedrawSuspendCount > 1)
|
||||
return NS_OK;
|
||||
|
||||
if (!mDocument) return NS_ERROR_FAILURE;
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
if (!IsInDoc()) return NS_ERROR_FAILURE;
|
||||
nsIPresShell *presShell = GetOwnerDoc()->GetShellAt(0);
|
||||
NS_ASSERTION(presShell, "need presShell to suspend redraw");
|
||||
if (!presShell) return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -508,8 +508,8 @@ nsSVGSVGElement::UnsuspendRedrawAll()
|
|||
{
|
||||
mRedrawSuspendCount = 0;
|
||||
|
||||
if (!mDocument) return NS_ERROR_FAILURE;
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
if (!IsInDoc()) return NS_ERROR_FAILURE;
|
||||
nsIPresShell *presShell = GetOwnerDoc()->GetShellAt(0);
|
||||
NS_ASSERTION(presShell, "need presShell to unsuspend redraw");
|
||||
if (!presShell) return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -533,9 +533,9 @@ nsSVGSVGElement::UnsuspendRedrawAll()
|
|||
NS_IMETHODIMP
|
||||
nsSVGSVGElement::ForceRedraw()
|
||||
{
|
||||
if (!mDocument) return NS_ERROR_FAILURE;
|
||||
if (!IsInDoc()) return NS_ERROR_FAILURE;
|
||||
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
nsIPresShell *presShell = GetOwnerDoc()->GetShellAt(0);
|
||||
NS_ASSERTION(presShell, "need presShell to unsuspend redraw");
|
||||
if (!presShell) return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -890,8 +890,8 @@ nsSVGSVGElement::GetCTM(nsIDOMSVGMatrix **_retval)
|
|||
nsCOMPtr<nsIDOMSVGMatrix> CTM;
|
||||
|
||||
nsIBindingManager *bindingManager = nsnull;
|
||||
if (mDocument) {
|
||||
bindingManager = mDocument->GetBindingManager();
|
||||
if (IsInDoc()) {
|
||||
bindingManager = GetOwnerDoc()->GetBindingManager();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
|
@ -963,8 +963,8 @@ nsSVGSVGElement::GetScreenCTM(nsIDOMSVGMatrix **_retval)
|
|||
nsCOMPtr<nsIDOMSVGMatrix> screenCTM;
|
||||
|
||||
nsIBindingManager *bindingManager = nsnull;
|
||||
if (mDocument) {
|
||||
bindingManager = mDocument->GetBindingManager();
|
||||
if (IsInDoc()) {
|
||||
bindingManager = GetOwnerDoc()->GetBindingManager();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
|
@ -1136,8 +1136,8 @@ nsSVGSVGElement::DidModifySVGObservable (nsISVGValue* observable)
|
|||
|
||||
mViewBoxToViewportTransform = nsnull;
|
||||
|
||||
if (!mDocument) return NS_ERROR_FAILURE;
|
||||
nsIPresShell* presShell = mDocument->GetShellAt(0);
|
||||
if (!IsInDoc()) return NS_ERROR_FAILURE;
|
||||
nsIPresShell* presShell = GetOwnerDoc()->GetShellAt(0);
|
||||
NS_ASSERTION(presShell, "no presShell");
|
||||
if (!presShell) return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -1183,9 +1183,10 @@ void nsSVGSVGElement::GetScreenPosition(PRInt32 &x, PRInt32 &y)
|
|||
x = 0;
|
||||
y = 0;
|
||||
|
||||
if (!mDocument) return;
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
if (!document) return;
|
||||
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
nsIPresShell *presShell = document->GetShellAt(0);
|
||||
if (!presShell) {
|
||||
NS_ERROR("couldn't get presshell");
|
||||
return;
|
||||
|
@ -1199,7 +1200,7 @@ void nsSVGSVGElement::GetScreenPosition(PRInt32 &x, PRInt32 &y)
|
|||
}
|
||||
|
||||
// Flush all pending notifications so that our frames are uptodate
|
||||
mDocument->FlushPendingNotifications(Flush_Layout);
|
||||
document->FlushPendingNotifications(Flush_Layout);
|
||||
|
||||
nsIFrame* frame;
|
||||
presShell->GetPrimaryFrameFor(this, &frame);
|
||||
|
|
|
@ -229,8 +229,8 @@ nsSVGScriptElement::ScriptAvailable(nsresult aResult,
|
|||
{
|
||||
if (!aIsInline && NS_FAILED(aResult)) {
|
||||
nsCOMPtr<nsPresContext> presContext;
|
||||
if (mDocument) {
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
if (IsInDoc()) {
|
||||
nsIPresShell *presShell = GetOwnerDoc()->GetShellAt(0);
|
||||
if (presShell)
|
||||
presShell->GetPresContext(getter_AddRefs(presContext));
|
||||
}
|
||||
|
@ -269,8 +269,8 @@ nsSVGScriptElement::ScriptEvaluated(nsresult aResult,
|
|||
nsresult rv = NS_OK;
|
||||
if (!aIsInline) {
|
||||
nsCOMPtr<nsPresContext> presContext;
|
||||
if (mDocument) {
|
||||
nsIPresShell *presShell = mDocument->GetShellAt(0);
|
||||
if (IsInDoc()) {
|
||||
nsIPresShell *presShell = GetOwnerDoc()->GetShellAt(0);
|
||||
if (presShell)
|
||||
presShell->GetPresContext(getter_AddRefs(presContext));
|
||||
}
|
||||
|
@ -393,14 +393,14 @@ nsSVGScriptElement::AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
|||
void
|
||||
nsSVGScriptElement::MaybeProcessScript()
|
||||
{
|
||||
if (mIsEvaluated || mEvaluating || !mDocument || !GetParent()) {
|
||||
if (mIsEvaluated || mEvaluating || !IsInDoc() || !GetParent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We'll always call this to make sure that
|
||||
// ScriptAvailable/ScriptEvaluated gets called. See bug 153600
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIScriptLoader> loader = mDocument->GetScriptLoader();
|
||||
nsCOMPtr<nsIScriptLoader> loader = GetOwnerDoc()->GetScriptLoader();
|
||||
if (loader) {
|
||||
mEvaluating = PR_TRUE;
|
||||
rv = loader->ProcessScriptElement(this, this);
|
||||
|
|
|
@ -185,7 +185,7 @@ void
|
|||
nsSVGStyleElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> oldDoc = mDocument;
|
||||
nsCOMPtr<nsIDocument> oldDoc = GetCurrentDoc();
|
||||
|
||||
nsSVGStyleElementBase::SetDocument(aDocument, aDeep, aCompileEventHandlers);
|
||||
|
||||
|
|
|
@ -358,12 +358,12 @@ void nsSVGTextElement::ParentChainChanged()
|
|||
already_AddRefed<nsISVGTextContentMetrics>
|
||||
nsSVGTextElement::GetTextContentMetrics()
|
||||
{
|
||||
if (!mDocument) {
|
||||
if (!IsInDoc()) {
|
||||
NS_ERROR("no document");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsIPresShell* presShell = mDocument->GetShellAt(0);
|
||||
nsIPresShell* presShell = GetOwnerDoc()->GetShellAt(0);
|
||||
if (!presShell) {
|
||||
NS_ERROR("no presshell");
|
||||
return nsnull;
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
#include "nsParserCIID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "plstr.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIXMLContentSink.h"
|
||||
#include "nsContentCID.h"
|
||||
|
@ -499,13 +499,14 @@ nsXBLPrototypeBinding::AttributeChanged(nsIAtom* aAttribute,
|
|||
nsAutoString value;
|
||||
aChangedElement->GetAttr(aNameSpaceID, aAttribute, value);
|
||||
if (!value.IsEmpty()) {
|
||||
nsCOMPtr<nsIDOMText> textNode;
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(
|
||||
do_QueryInterface(aChangedElement->GetDocument()));
|
||||
domDoc->CreateTextNode(value, getter_AddRefs(textNode));
|
||||
nsCOMPtr<nsIDOMNode> dummy;
|
||||
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(realElement));
|
||||
domElement->AppendChild(textNode, getter_AddRefs(dummy));
|
||||
nsCOMPtr<nsITextContent> textContent;
|
||||
NS_NewTextNode(getter_AddRefs(textContent));
|
||||
if (!textContent) {
|
||||
continue;
|
||||
}
|
||||
|
||||
textContent->SetText(value, PR_TRUE);
|
||||
realElement->AppendChildTo(textContent, PR_TRUE, PR_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -886,13 +887,14 @@ PRBool PR_CALLBACK SetAttrs(nsHashKey* aKey, void* aData, void* aClosure)
|
|||
(realElement->GetNodeInfo()->Equals(nsHTMLAtoms::html,
|
||||
kNameSpaceID_XUL) &&
|
||||
dst == nsHTMLAtoms::value && !value.IsEmpty())) {
|
||||
nsCOMPtr<nsIDOMText> textNode;
|
||||
nsCOMPtr<nsIDOMDocument> domDoc =
|
||||
do_QueryInterface(changeData->mBoundElement->GetDocument());
|
||||
domDoc->CreateTextNode(value, getter_AddRefs(textNode));
|
||||
nsCOMPtr<nsIDOMNode> dummy;
|
||||
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(realElement));
|
||||
domElement->AppendChild(textNode, getter_AddRefs(dummy));
|
||||
nsCOMPtr<nsITextContent> textContent;
|
||||
NS_NewTextNode(getter_AddRefs(textContent));
|
||||
if (!textContent) {
|
||||
continue;
|
||||
}
|
||||
|
||||
textContent->SetText(value, PR_TRUE);
|
||||
realElement->AppendChildTo(textContent, PR_TRUE, PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "nsIDOMCDATASection.h"
|
||||
#include "nsGenericDOMDataNode.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
|
||||
#include "nsIDocument.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ class nsXMLCDATASection : public nsGenericDOMDataNode,
|
|||
public nsIDOMCDATASection
|
||||
{
|
||||
public:
|
||||
nsXMLCDATASection();
|
||||
nsXMLCDATASection(nsIDocument *aDocument);
|
||||
virtual ~nsXMLCDATASection();
|
||||
|
||||
// nsISupports
|
||||
|
@ -72,24 +72,32 @@ public:
|
|||
virtual void DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) const;
|
||||
#endif
|
||||
|
||||
// nsITextContent
|
||||
virtual already_AddRefed<nsITextContent> CloneContent(PRBool aCloneText);
|
||||
virtual already_AddRefed<nsITextContent> CloneContent(PRBool aCloneText,
|
||||
nsIDocument *aOwnerDocument);
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewXMLCDATASection(nsIContent** aInstancePtrResult)
|
||||
NS_NewXMLCDATASection(nsIContent** aInstancePtrResult,
|
||||
nsIDocument *aOwnerDocument)
|
||||
{
|
||||
*aInstancePtrResult = new nsXMLCDATASection();
|
||||
NS_ENSURE_TRUE(*aInstancePtrResult, NS_ERROR_OUT_OF_MEMORY);
|
||||
*aInstancePtrResult = nsnull;
|
||||
|
||||
NS_ADDREF(*aInstancePtrResult);
|
||||
nsCOMPtr<nsIContent> instance = new nsXMLCDATASection(aOwnerDocument);
|
||||
NS_ENSURE_TRUE(instance, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (aOwnerDocument && !aOwnerDocument->AddOrphan(instance)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
instance.swap(*aInstancePtrResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsXMLCDATASection::nsXMLCDATASection()
|
||||
nsXMLCDATASection::nsXMLCDATASection(nsIDocument *aDocument)
|
||||
: nsGenericDOMDataNode(aDocument)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -153,16 +161,16 @@ nsXMLCDATASection::GetNodeType(PRUint16* aNodeType)
|
|||
NS_IMETHODIMP
|
||||
nsXMLCDATASection::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsCOMPtr<nsITextContent> textContent = CloneContent(PR_TRUE);
|
||||
nsCOMPtr<nsITextContent> textContent = CloneContent(PR_TRUE, GetOwnerDoc());
|
||||
NS_ENSURE_TRUE(textContent, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return CallQueryInterface(textContent, aReturn);
|
||||
}
|
||||
|
||||
already_AddRefed<nsITextContent>
|
||||
nsXMLCDATASection::CloneContent(PRBool aCloneText)
|
||||
nsXMLCDATASection::CloneContent(PRBool aCloneText, nsIDocument *aOwnerDocument)
|
||||
{
|
||||
nsXMLCDATASection* it = new nsXMLCDATASection();
|
||||
nsXMLCDATASection* it = new nsXMLCDATASection(aOwnerDocument);
|
||||
if (!it)
|
||||
return nsnull;
|
||||
|
||||
|
@ -172,6 +180,10 @@ nsXMLCDATASection::CloneContent(PRBool aCloneText)
|
|||
|
||||
NS_ADDREF(it);
|
||||
|
||||
if (aOwnerDocument && !aOwnerDocument->AddOrphan(it)) {
|
||||
NS_RELEASE(it);
|
||||
}
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
|
@ -179,7 +191,7 @@ nsXMLCDATASection::CloneContent(PRBool aCloneText)
|
|||
void
|
||||
nsXMLCDATASection::List(FILE* out, PRInt32 aIndent) const
|
||||
{
|
||||
NS_PRECONDITION(mDocument, "bad content");
|
||||
NS_PRECONDITION(IsInDoc(), "bad content");
|
||||
|
||||
PRInt32 index;
|
||||
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
|
|
|
@ -258,7 +258,7 @@ nsXMLElement::MaybeTriggerAutoLink(nsIDocShell *aShell)
|
|||
nsCOMPtr<nsIURI> uri;
|
||||
rv = nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri),
|
||||
value,
|
||||
mDocument,
|
||||
GetCurrentDoc(),
|
||||
base);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsPresContext> pc;
|
||||
|
@ -293,6 +293,7 @@ nsXMLElement::HandleDOMEvent(nsPresContext* aPresContext,
|
|||
|
||||
if (mIsLink && (NS_OK == ret) && (nsEventStatus_eIgnore == *aEventStatus) &&
|
||||
!(aFlags & NS_EVENT_FLAG_CAPTURE) && !(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT)) {
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
switch (aEvent->message) {
|
||||
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
||||
{
|
||||
|
@ -388,7 +389,7 @@ nsXMLElement::HandleDOMEvent(nsPresContext* aPresContext,
|
|||
nsCOMPtr<nsIURI> uri;
|
||||
ret = nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri),
|
||||
href,
|
||||
mDocument,
|
||||
document,
|
||||
baseURI);
|
||||
if (NS_SUCCEEDED(ret)) {
|
||||
ret = TriggerLink(aPresContext, eLinkVerb_Replace, baseURI, uri,
|
||||
|
|
|
@ -45,22 +45,35 @@
|
|||
nsresult
|
||||
NS_NewXMLProcessingInstruction(nsIContent** aInstancePtrResult,
|
||||
const nsAString& aTarget,
|
||||
const nsAString& aData)
|
||||
const nsAString& aData,
|
||||
nsIDocument *aOwnerDocument)
|
||||
{
|
||||
if (aTarget.EqualsLiteral("xml-stylesheet")) {
|
||||
return NS_NewXMLStylesheetProcessingInstruction(aInstancePtrResult, aData);
|
||||
return NS_NewXMLStylesheetProcessingInstruction(aInstancePtrResult, aData,
|
||||
aOwnerDocument);
|
||||
}
|
||||
*aInstancePtrResult = new nsXMLProcessingInstruction(aTarget, aData);
|
||||
NS_ENSURE_TRUE(*aInstancePtrResult, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(*aInstancePtrResult);
|
||||
*aInstancePtrResult = nsnull;
|
||||
|
||||
nsCOMPtr<nsIContent> instance;
|
||||
instance = new nsXMLProcessingInstruction(aTarget, aData,
|
||||
aOwnerDocument);
|
||||
NS_ENSURE_TRUE(instance, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (aOwnerDocument && !aOwnerDocument->AddOrphan(instance)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
instance.swap(*aInstancePtrResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsXMLProcessingInstruction::nsXMLProcessingInstruction(const nsAString& aTarget,
|
||||
const nsAString& aData) :
|
||||
mTarget(aTarget)
|
||||
const nsAString& aData,
|
||||
nsIDocument *aDocument)
|
||||
: nsGenericDOMDataNode(aDocument),
|
||||
mTarget(aTarget)
|
||||
{
|
||||
nsGenericDOMDataNode::SetData(aData);
|
||||
}
|
||||
|
@ -156,29 +169,27 @@ nsXMLProcessingInstruction::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
|||
nsAutoString data;
|
||||
GetData(data);
|
||||
|
||||
*aReturn = new nsXMLProcessingInstruction(mTarget, data);
|
||||
if (!*aReturn) {
|
||||
nsIDocument *document = GetOwnerDoc();
|
||||
nsXMLProcessingInstruction *pi =
|
||||
new nsXMLProcessingInstruction(mTarget, data, document);
|
||||
if (!pi) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_ADDREF(*aReturn);
|
||||
if (document) {
|
||||
document->AddOrphan(pi);
|
||||
}
|
||||
|
||||
NS_ADDREF(*aReturn = pi);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsITextContent>
|
||||
nsXMLProcessingInstruction::CloneContent(PRBool aCloneText)
|
||||
{
|
||||
NS_ERROR("Huh, this shouldn't be called!");
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
nsXMLProcessingInstruction::List(FILE* out, PRInt32 aIndent) const
|
||||
{
|
||||
NS_PRECONDITION(mDocument, "bad content");
|
||||
NS_PRECONDITION(IsInDoc(), "bad content");
|
||||
|
||||
PRInt32 index;
|
||||
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
|
|
|
@ -50,7 +50,8 @@ class nsXMLProcessingInstruction : public nsGenericDOMDataNode,
|
|||
{
|
||||
public:
|
||||
nsXMLProcessingInstruction(const nsAString& aTarget,
|
||||
const nsAString& aData);
|
||||
const nsAString& aData,
|
||||
nsIDocument *aDocument);
|
||||
virtual ~nsXMLProcessingInstruction();
|
||||
|
||||
// nsISupports
|
||||
|
@ -71,9 +72,6 @@ public:
|
|||
virtual void DumpContent(FILE* out, PRInt32 aIndent, PRBool aDumpAll) const;
|
||||
#endif
|
||||
|
||||
// nsITextContent
|
||||
virtual already_AddRefed<nsITextContent> CloneContent(PRBool aCloneText);
|
||||
|
||||
protected:
|
||||
PRBool GetAttrValue(const nsAString& aAttr, nsAString& aValue);
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class nsXMLStylesheetPI : public nsXMLProcessingInstruction,
|
|||
public nsStyleLinkElement
|
||||
{
|
||||
public:
|
||||
nsXMLStylesheetPI(const nsAString& aData);
|
||||
nsXMLStylesheetPI(const nsAString& aData, nsIDocument *aDocument);
|
||||
virtual ~nsXMLStylesheetPI();
|
||||
|
||||
// nsISupports
|
||||
|
@ -89,8 +89,10 @@ NS_IMPL_ADDREF_INHERITED(nsXMLStylesheetPI, nsXMLProcessingInstruction)
|
|||
NS_IMPL_RELEASE_INHERITED(nsXMLStylesheetPI, nsXMLProcessingInstruction)
|
||||
|
||||
|
||||
nsXMLStylesheetPI::nsXMLStylesheetPI(const nsAString& aData) :
|
||||
nsXMLProcessingInstruction(NS_LITERAL_STRING("xml-stylesheet"), aData)
|
||||
nsXMLStylesheetPI::nsXMLStylesheetPI(const nsAString& aData,
|
||||
nsIDocument *aDocument) :
|
||||
nsXMLProcessingInstruction(NS_LITERAL_STRING("xml-stylesheet"), aData,
|
||||
aDocument)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -104,7 +106,7 @@ void
|
|||
nsXMLStylesheetPI::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> oldDoc = mDocument;
|
||||
nsCOMPtr<nsIDocument> oldDoc = GetCurrentDoc();
|
||||
nsXMLProcessingInstruction::SetDocument(aDocument, aDeep,
|
||||
aCompileEventHandlers);
|
||||
|
||||
|
@ -130,12 +132,17 @@ nsXMLStylesheetPI::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
|||
nsAutoString data;
|
||||
GetData(data);
|
||||
|
||||
*aReturn = new nsXMLStylesheetPI(data);
|
||||
if (!*aReturn) {
|
||||
nsIDocument *document = GetOwnerDoc();
|
||||
nsXMLStylesheetPI *pi = new nsXMLStylesheetPI(data, document);
|
||||
if (!pi) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_ADDREF(*aReturn);
|
||||
if (document) {
|
||||
document->AddOrphan(pi);
|
||||
}
|
||||
|
||||
NS_ADDREF(*aReturn = pi);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -167,9 +174,10 @@ nsXMLStylesheetPI::GetStyleSheetURL(PRBool* aIsInline,
|
|||
|
||||
nsIURI *baseURL;
|
||||
nsCAutoString charset;
|
||||
if (mDocument) {
|
||||
baseURL = mDocument->GetBaseURI();
|
||||
charset = mDocument->GetDocumentCharacterSet();
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
if (document) {
|
||||
baseURL = document->GetBaseURI();
|
||||
charset = document->GetDocumentCharacterSet();
|
||||
} else {
|
||||
baseURL = nsnull;
|
||||
}
|
||||
|
@ -233,14 +241,21 @@ nsXMLStylesheetPI::GetStyleSheetInfo(nsAString& aTitle,
|
|||
|
||||
nsresult
|
||||
NS_NewXMLStylesheetProcessingInstruction(nsIContent** aInstancePtrResult,
|
||||
const nsAString& aData)
|
||||
const nsAString& aData,
|
||||
nsIDocument *aOwnerDocument)
|
||||
{
|
||||
*aInstancePtrResult = new nsXMLStylesheetPI(aData);
|
||||
if (!*aInstancePtrResult)
|
||||
*aInstancePtrResult = nsnull;
|
||||
|
||||
nsCOMPtr<nsIContent> instance = new nsXMLStylesheetPI(aData, aOwnerDocument);
|
||||
if (!instance) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_ADDREF(*aInstancePtrResult);
|
||||
if (aOwnerDocument && !aOwnerDocument->AddOrphan(instance)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
instance.swap(*aInstancePtrResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -738,9 +738,6 @@ nsXMLContentSink::FlushText(PRBool aCreateTextNode, PRBool* aDidFlush)
|
|||
rv = NS_NewTextNode(getter_AddRefs(textContent));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Set the content's document
|
||||
textContent->SetDocument(mDocument, PR_FALSE, PR_TRUE);
|
||||
|
||||
// Set the text in the text node
|
||||
textContent->SetText(mText, mTextLength, PR_FALSE);
|
||||
|
||||
|
@ -1084,7 +1081,6 @@ nsXMLContentSink::HandleComment(const PRUnichar *aName)
|
|||
nsCOMPtr<nsIDOMComment> domComment = do_QueryInterface(comment, &result);
|
||||
if (domComment) {
|
||||
domComment->AppendData(nsDependentString(aName));
|
||||
comment->SetDocument(mDocument, PR_FALSE, PR_TRUE);
|
||||
result = AddContentAsLeaf(comment);
|
||||
}
|
||||
}
|
||||
|
@ -1108,7 +1104,6 @@ nsXMLContentSink::HandleCDataSection(const PRUnichar *aData,
|
|||
nsCOMPtr<nsIDOMCDATASection> domCDATA = do_QueryInterface(cdata);
|
||||
if (domCDATA) {
|
||||
domCDATA->SetData(nsDependentString(aData, aLength));
|
||||
cdata->SetDocument(mDocument, PR_FALSE, PR_TRUE);
|
||||
result = AddContentAsLeaf(cdata);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -438,6 +438,7 @@ PRUint32 nsXULPrototypeAttribute::gNumCacheFills;
|
|||
|
||||
nsXULElement::nsXULElement()
|
||||
: mPrototype(nsnull),
|
||||
mDocument(nsnull),
|
||||
mBindingParent(nsnull),
|
||||
mSlots(nsnull)
|
||||
{
|
||||
|
@ -463,6 +464,8 @@ nsXULElement::Init()
|
|||
|
||||
nsXULElement::~nsXULElement()
|
||||
{
|
||||
mAttrsAndChildren.Clear();
|
||||
|
||||
if (mPrototype)
|
||||
mPrototype->Release();
|
||||
|
||||
|
@ -632,8 +635,9 @@ nsXULElement::GetNodeType(PRUint16* aNodeType)
|
|||
NS_IMETHODIMP
|
||||
nsXULElement::GetParentNode(nsIDOMNode** aParentNode)
|
||||
{
|
||||
if (GetParent()) {
|
||||
return CallQueryInterface(GetParent(), aParentNode);
|
||||
nsIContent *parent = GetParent();
|
||||
if (parent) {
|
||||
return CallQueryInterface(parent, aParentNode);
|
||||
}
|
||||
|
||||
if (mDocument) {
|
||||
|
@ -704,10 +708,11 @@ nsXULElement::GetLastChild(nsIDOMNode** aLastChild)
|
|||
NS_IMETHODIMP
|
||||
nsXULElement::GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
||||
{
|
||||
if (GetParent()) {
|
||||
PRInt32 pos = GetParent()->IndexOf(this);
|
||||
nsIContent *parent = GetParent();
|
||||
if (parent) {
|
||||
PRInt32 pos = parent->IndexOf(this);
|
||||
if (pos > 0) {
|
||||
nsIContent *prev = GetParent()->GetChildAt(--pos);
|
||||
nsIContent *prev = parent->GetChildAt(--pos);
|
||||
if (prev) {
|
||||
nsresult rv = CallQueryInterface(prev, aPreviousSibling);
|
||||
NS_ASSERTION(*aPreviousSibling, "not a DOM node");
|
||||
|
@ -726,10 +731,11 @@ nsXULElement::GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
|||
NS_IMETHODIMP
|
||||
nsXULElement::GetNextSibling(nsIDOMNode** aNextSibling)
|
||||
{
|
||||
if (GetParent()) {
|
||||
PRInt32 pos = GetParent()->IndexOf(this);
|
||||
nsIContent *parent = GetParent();
|
||||
if (parent) {
|
||||
PRInt32 pos = parent->IndexOf(this);
|
||||
if (pos > -1) {
|
||||
nsIContent *next = GetParent()->GetChildAt(++pos);
|
||||
nsIContent *next = parent->GetChildAt(++pos);
|
||||
if (next) {
|
||||
nsresult rv = CallQueryInterface(next, aNextSibling);
|
||||
NS_ASSERTION(*aNextSibling, "not a DOM Node");
|
||||
|
@ -767,14 +773,13 @@ nsXULElement::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
|||
NS_IMETHODIMP
|
||||
nsXULElement::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
{
|
||||
if (mDocument) {
|
||||
return CallQueryInterface(mDocument, aOwnerDocument);
|
||||
}
|
||||
nsIDocument* doc = nsContentUtils::GetDocument(NodeInfo());
|
||||
if (doc) {
|
||||
return CallQueryInterface(doc, aOwnerDocument);
|
||||
nsIDocument *document = GetOwnerDoc();
|
||||
if (document) {
|
||||
return CallQueryInterface(document, aOwnerDocument);
|
||||
}
|
||||
|
||||
*aOwnerDocument = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1634,7 +1639,7 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
|||
mListenerManager->SetListenerTarget(nsnull);
|
||||
mListenerManager = nsnull;
|
||||
|
||||
nsIContent::SetDocument(aDocument, aDeep, aCompileEventHandlers);
|
||||
mDocument = aDocument;
|
||||
|
||||
if (mDocument) {
|
||||
// When we SetDocument(), we're either adding an element
|
||||
|
@ -1682,7 +1687,8 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
|||
void
|
||||
nsXULElement::SetParent(nsIContent* aParent)
|
||||
{
|
||||
nsIContent::SetParent(aParent);
|
||||
mParentPtrBits = NS_REINTERPRET_CAST(PtrBits, aParent);
|
||||
|
||||
if (aParent) {
|
||||
nsIContent* bindingPar = aParent->GetBindingParent();
|
||||
if (bindingPar)
|
||||
|
|
|
@ -433,8 +433,20 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIContent (from nsIStyledContent)
|
||||
nsIDocument *GetDocument() const
|
||||
{
|
||||
return mDocument;
|
||||
}
|
||||
virtual void SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers);
|
||||
PRBool IsInDoc() const
|
||||
{
|
||||
return !!mDocument;
|
||||
}
|
||||
nsIDocument *GetOwnerDoc() const
|
||||
{
|
||||
return mDocument ? mDocument : NodeInfo()->GetDocument();
|
||||
}
|
||||
virtual void SetParent(nsIContent* aParent);
|
||||
virtual PRBool IsNativeAnonymous() const;
|
||||
virtual void SetNativeAnonymous(PRBool aAnonymous);
|
||||
|
@ -572,6 +584,7 @@ protected:
|
|||
protected:
|
||||
// Required fields
|
||||
nsXULPrototypeElement* mPrototype;
|
||||
nsIDocument* mDocument;
|
||||
nsAttrAndChildArray mAttrsAndChildren; // [OWNER]
|
||||
nsCOMPtr<nsIEventListenerManager> mListenerManager; // [OWNER]
|
||||
|
||||
|
|
|
@ -2808,9 +2808,7 @@ nsXULDocument::ResumeWalk()
|
|||
|
||||
nsXULPrototypeText* textproto =
|
||||
NS_REINTERPRET_CAST(nsXULPrototypeText*, childproto);
|
||||
text->SetText(textproto->mValue.get(),
|
||||
textproto->mValue.Length(),
|
||||
PR_FALSE);
|
||||
text->SetText(textproto->mValue, PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIContent> child = do_QueryInterface(text);
|
||||
if (! child)
|
||||
|
|
|
@ -79,7 +79,6 @@
|
|||
|
||||
//----------------------------------------------------------------------0
|
||||
|
||||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
static NS_DEFINE_CID(kXULSortServiceCID, NS_XULSORTSERVICE_CID);
|
||||
|
||||
PRBool
|
||||
|
@ -656,11 +655,11 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
|||
rv = SubstituteText(*aMatch, attrValue, value);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsITextContent> content =
|
||||
do_CreateInstance(kTextNodeCID, &rv);
|
||||
nsCOMPtr<nsITextContent> content;
|
||||
rv = NS_NewTextNode(getter_AddRefs(content));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
content->SetText(value.get(), value.Length(), PR_FALSE);
|
||||
content->SetText(value, PR_FALSE);
|
||||
|
||||
rv = aRealNode->AppendChildTo(content, aNotify, PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -670,12 +669,14 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
|||
}
|
||||
}
|
||||
else if (tag == nsLayoutAtoms::textTagName) {
|
||||
nsCOMPtr<nsITextContent> tmplTextContent = do_QueryInterface(tmplKid);
|
||||
if (!tmplTextContent) {
|
||||
NS_ERROR("textnode not implementing nsITextContent??");
|
||||
nsCOMPtr<nsIDOMNode> tmplTextNode = do_QueryInterface(tmplKid);
|
||||
if (!tmplTextNode) {
|
||||
NS_ERROR("textnode not implementing nsIDOMNode??");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsCOMPtr<nsITextContent> clonedContent = tmplTextContent->CloneContent(PR_TRUE);
|
||||
nsCOMPtr<nsIDOMNode> clonedNode;
|
||||
tmplTextNode->CloneNode(PR_FALSE, getter_AddRefs(clonedNode));
|
||||
nsCOMPtr<nsIContent> clonedContent = do_QueryInterface(clonedNode);
|
||||
if (!clonedContent) {
|
||||
NS_ERROR("failed to clone textnode");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
|
@ -114,7 +114,6 @@
|
|||
#include "nsXULAtoms.h"
|
||||
#include "nsBoxFrame.h"
|
||||
|
||||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
|
@ -1488,10 +1487,8 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsPresContext* aPresContext
|
|||
rv = NS_NewAttributeContent(aContent, attrNameSpace, attrName,
|
||||
getter_AddRefs(content));
|
||||
|
||||
// Set aContent as the parent content and set the document
|
||||
// object. This way event handling works
|
||||
// Set aContent as the parent content so that event handling works.
|
||||
content->SetParent(aContent);
|
||||
content->SetDocument(aDocument, PR_TRUE, PR_TRUE);
|
||||
content->SetNativeAnonymous(PR_TRUE);
|
||||
content->SetBindingParent(content);
|
||||
|
||||
|
@ -1544,19 +1541,17 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsPresContext* aPresContext
|
|||
|
||||
// Create a text content node
|
||||
nsIFrame* textFrame = nsnull;
|
||||
nsCOMPtr<nsIContent> textContent = do_CreateInstance(kTextNodeCID);
|
||||
nsCOMPtr<nsITextContent> textContent;
|
||||
NS_NewTextNode(getter_AddRefs(textContent));
|
||||
if (textContent) {
|
||||
// Set the text
|
||||
nsCOMPtr<nsIDOMCharacterData> domData = do_QueryInterface(textContent);
|
||||
domData->SetData(contentString);
|
||||
textContent->SetText(contentString, PR_TRUE);
|
||||
|
||||
if (textPtr)
|
||||
*textPtr = domData;
|
||||
*textPtr = do_QueryInterface(textContent);
|
||||
|
||||
// Set aContent as the parent content and set the document object. This
|
||||
// way event handling works
|
||||
// Set aContent as the parent content so that event handling works.
|
||||
textContent->SetParent(aContent);
|
||||
textContent->SetDocument(aDocument, PR_TRUE, PR_TRUE);
|
||||
textContent->SetNativeAnonymous(PR_TRUE);
|
||||
textContent->SetBindingParent(textContent);
|
||||
|
||||
|
@ -10167,18 +10162,16 @@ nsCSSFrameConstructor::ConstructAlternateFrame(nsIPresShell* aPresShell,
|
|||
GetAlternateTextFor(aContent, aContent->Tag(), altText);
|
||||
|
||||
// Create a text content element for the alternate text
|
||||
nsCOMPtr<nsIContent> altTextContent(do_CreateInstance(kTextNodeCID,&rv));
|
||||
nsCOMPtr<nsITextContent> altTextContent;
|
||||
rv = NS_NewTextNode(getter_AddRefs(altTextContent));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Set the content's text
|
||||
nsCOMPtr<nsIDOMCharacterData> domData = do_QueryInterface(altTextContent);
|
||||
if (domData)
|
||||
domData->SetData(altText);
|
||||
altTextContent->SetText(altText, PR_TRUE);
|
||||
|
||||
// Set aContent as the parent content and set the document object
|
||||
// Set aContent as the parent content.
|
||||
altTextContent->SetParent(aContent);
|
||||
altTextContent->SetDocument(mDocument, PR_TRUE, PR_TRUE);
|
||||
|
||||
// Create either an inline frame, block frame, or area frame
|
||||
nsIFrame* containerFrame;
|
||||
|
|
|
@ -113,10 +113,6 @@
|
|||
#define NS_CSS_LOADER_CID \
|
||||
{ 0xeaca2576, 0x0d4a, 0x11d3, { 0x9d, 0x7e, 0x00, 0x60, 0x08, 0x8f, 0x9f, 0xf7 } }
|
||||
|
||||
// {96882B71-8A27-11d2-8EAF-00805F29F370}
|
||||
#define NS_TEXTNODE_CID \
|
||||
{ 0x96882b71, 0x8a27, 0x11d2, { 0x8e, 0xaf, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {96882B72-8A27-11d2-8EAF-00805F29F370}
|
||||
#define NS_SELECTION_CID \
|
||||
{ 0x96882b72, 0x8a27, 0x11d2, { 0x8e, 0xaf, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
|
|
@ -96,7 +96,6 @@
|
|||
#include "nsIRangeUtils.h"
|
||||
#include "nsIScriptNameSpaceManager.h"
|
||||
#include "nsISelection.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsIFrameLoader.h"
|
||||
#include "nsICaret.h"
|
||||
|
@ -148,6 +147,7 @@
|
|||
#include "nsScriptNameSpaceManager.h"
|
||||
#include "nsIControllerContext.h"
|
||||
#include "nsDOMScriptObjectFactory.h"
|
||||
#include "nsDocument.h"
|
||||
|
||||
class nsIDocumentLoaderFactory;
|
||||
|
||||
|
@ -356,6 +356,7 @@ Shutdown()
|
|||
|
||||
gInitialized = PR_FALSE;
|
||||
|
||||
nsDocument::Shutdown();
|
||||
nsRange::Shutdown();
|
||||
nsGenericElement::Shutdown();
|
||||
nsEventListenerManager::Shutdown();
|
||||
|
@ -539,7 +540,6 @@ MAKE_CTOR(CreateSVGDocument, nsIDocument, NS_NewSVG
|
|||
MAKE_CTOR(CreateImageDocument, nsIDocument, NS_NewImageDocument)
|
||||
MAKE_CTOR(CreateCSSParser, nsICSSParser, NS_NewCSSParser)
|
||||
MAKE_CTOR(CreateCSSLoader, nsICSSLoader, NS_NewCSSLoader)
|
||||
MAKE_CTOR(CreateTextNode, nsITextContent, NS_NewTextNode)
|
||||
MAKE_CTOR(CreateDOMSelection, nsISelection, NS_NewDomSelection)
|
||||
MAKE_CTOR(CreateSelection, nsIFrameSelection, NS_NewSelection)
|
||||
MAKE_CTOR(CreateRange, nsIDOMRange, NS_NewRange)
|
||||
|
@ -948,11 +948,6 @@ static const nsModuleComponentInfo gComponents[] = {
|
|||
nsnull,
|
||||
CreateCSSLoader },
|
||||
|
||||
{ "Text element",
|
||||
NS_TEXTNODE_CID,
|
||||
nsnull,
|
||||
CreateTextNode },
|
||||
|
||||
{ "Dom selection",
|
||||
NS_DOMSELECTION_CID,
|
||||
"@mozilla.org/content/dom-selection;1",
|
||||
|
|
|
@ -87,8 +87,6 @@
|
|||
#include "nsNodeInfoManager.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
|
||||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
#include "nsIXULDocument.h" // Temporary fix for Bug 36558
|
||||
#endif
|
||||
|
@ -2015,11 +2013,13 @@ nsComboboxControlFrame::CreateAnonymousContent(nsPresContext* aPresContext,
|
|||
//nsIAtom* tag = NS_NewAtom("mozcombodisplay");
|
||||
|
||||
// Add a child text content node for the label
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIContent> labelContent(do_CreateInstance(kTextNodeCID, &rv));
|
||||
if (NS_SUCCEEDED(rv) && labelContent) {
|
||||
|
||||
nsCOMPtr<nsITextContent> labelContent;
|
||||
NS_NewTextNode(getter_AddRefs(labelContent));
|
||||
|
||||
if (labelContent) {
|
||||
// set the value of the text node
|
||||
mDisplayContent = do_QueryInterface(labelContent);
|
||||
mDisplayContent.swap(labelContent);
|
||||
mDisplayContent->SetText(NS_LITERAL_STRING("X"), PR_TRUE);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
|
||||
|
@ -2030,11 +2030,11 @@ nsComboboxControlFrame::CreateAnonymousContent(nsPresContext* aPresContext,
|
|||
kNameSpaceID_None,
|
||||
getter_AddRefs(nodeInfo));
|
||||
|
||||
aChildList.AppendElement(labelContent);
|
||||
aChildList.AppendElement(mDisplayContent);
|
||||
|
||||
// create button which drops the list down
|
||||
nsCOMPtr<nsIContent> btnContent;
|
||||
rv = NS_NewHTMLElement(getter_AddRefs(btnContent), nodeInfo);
|
||||
nsresult rv = NS_NewHTMLElement(getter_AddRefs(btnContent), nodeInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// make someone to listen to the button. If its pressed by someone like Accessibility
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#include "nsFormControlFrame.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsContentCID.h"
|
||||
#ifdef ACCESSIBILITY
|
||||
#include "nsIAccessibilityService.h"
|
||||
#endif
|
||||
|
@ -55,8 +54,6 @@
|
|||
// MouseEvent suppression in PP
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
|
||||
// Saving PresState
|
||||
#include "nsIPresState.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
|
@ -197,14 +194,13 @@ nsGfxButtonControlFrame::CreateAnonymousContent(nsPresContext* aPresContext,
|
|||
}
|
||||
|
||||
// Add a child text content node for the label
|
||||
nsCOMPtr<nsIContent> labelContent(do_CreateInstance(kTextNodeCID,&result));
|
||||
if (NS_SUCCEEDED(result) && labelContent) {
|
||||
nsCOMPtr<nsITextContent> labelContent;
|
||||
NS_NewTextNode(getter_AddRefs(labelContent));
|
||||
if (labelContent) {
|
||||
// set the value of the text node and add it to the child list
|
||||
mTextContent = do_QueryInterface(labelContent, &result);
|
||||
if (NS_SUCCEEDED(result) && mTextContent) {
|
||||
mTextContent->SetText(value, PR_TRUE);
|
||||
aChildList.AppendElement(mTextContent);
|
||||
}
|
||||
mTextContent.swap(labelContent);
|
||||
mTextContent->SetText(value, PR_TRUE);
|
||||
aChildList.AppendElement(mTextContent);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -80,8 +80,6 @@
|
|||
#include "nsNodeInfoManager.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
|
||||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
|
||||
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
|
||||
nsresult
|
||||
|
@ -99,9 +97,7 @@ NS_NewIsIndexFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIsIndexFrame::nsIsIndexFrame():
|
||||
mTextContent(nsnull),
|
||||
mInputContent(nsnull)
|
||||
nsIsIndexFrame::nsIsIndexFrame()
|
||||
{
|
||||
//Shrink the area around it's contents
|
||||
SetFlags(NS_BLOCK_SHRINK_WRAP);
|
||||
|
@ -109,14 +105,10 @@ nsIsIndexFrame::nsIsIndexFrame():
|
|||
|
||||
nsIsIndexFrame::~nsIsIndexFrame()
|
||||
{
|
||||
if (mTextContent) {
|
||||
NS_RELEASE(mTextContent);
|
||||
}
|
||||
// remove ourself as a listener of the text control (bug 40533)
|
||||
if (mInputContent) {
|
||||
nsCOMPtr<nsIDOMEventReceiver> reciever(do_QueryInterface(mInputContent));
|
||||
reciever->RemoveEventListenerByIID(this, NS_GET_IID(nsIDOMKeyListener));
|
||||
NS_RELEASE(mInputContent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,9 +156,10 @@ nsIsIndexFrame::UpdatePromptLabel()
|
|||
result = nsFormControlHelper::GetLocalizedString(nsFormControlHelper::GetHTMLPropertiesFileName(),
|
||||
NS_LITERAL_STRING("IsIndexPrompt").get(), prompt);
|
||||
}
|
||||
nsCOMPtr<nsITextContent> text = do_QueryInterface(mTextContent);
|
||||
text->SetText(prompt, PR_TRUE);
|
||||
return result;
|
||||
|
||||
mTextContent->SetText(prompt, PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -242,14 +235,13 @@ nsIsIndexFrame::CreateAnonymousContent(nsPresContext* aPresContext,
|
|||
|
||||
// Add a child text content node for the label
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
nsCOMPtr<nsIContent> labelContent(do_CreateInstance(kTextNodeCID,&result));
|
||||
if (NS_SUCCEEDED(result) && labelContent) {
|
||||
nsCOMPtr<nsITextContent> labelContent;
|
||||
NS_NewTextNode(getter_AddRefs(labelContent));
|
||||
if (labelContent) {
|
||||
// set the value of the text node and add it to the child list
|
||||
result = labelContent->QueryInterface(NS_GET_IID(nsITextContent),(void**)&mTextContent);
|
||||
if (NS_SUCCEEDED(result) && mTextContent) {
|
||||
UpdatePromptLabel();
|
||||
result = aChildList.AppendElement(mTextContent);
|
||||
}
|
||||
mTextContent.swap(labelContent);
|
||||
UpdatePromptLabel();
|
||||
aChildList.AppendElement(mTextContent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -258,7 +250,7 @@ nsIsIndexFrame::CreateAnonymousContent(nsPresContext* aPresContext,
|
|||
nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None,
|
||||
getter_AddRefs(inputInfo));
|
||||
|
||||
result = NS_NewHTMLElement(&mInputContent, inputInfo);
|
||||
result = NS_NewHTMLElement(getter_AddRefs(mInputContent), inputInfo);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
mInputContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("text"), PR_FALSE);
|
||||
|
|
|
@ -136,8 +136,8 @@ public:
|
|||
NS_IMETHOD RestoreState(nsPresContext* aPresContext, nsIPresState* aState);
|
||||
|
||||
protected:
|
||||
nsIHTMLContent* mTextContent;
|
||||
nsIContent* mInputContent;
|
||||
nsCOMPtr<nsITextContent> mTextContent;
|
||||
nsCOMPtr<nsIContent> mInputContent;
|
||||
|
||||
// XXX Hack: pres context needed by function KeyPress() and SetFocus()
|
||||
nsPresContext* mPresContext; // weak reference
|
||||
|
|
|
@ -87,8 +87,6 @@
|
|||
#include "nsNodeInfoManager.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
|
||||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
#include "nsIXULDocument.h" // Temporary fix for Bug 36558
|
||||
#endif
|
||||
|
@ -2015,11 +2013,13 @@ nsComboboxControlFrame::CreateAnonymousContent(nsPresContext* aPresContext,
|
|||
//nsIAtom* tag = NS_NewAtom("mozcombodisplay");
|
||||
|
||||
// Add a child text content node for the label
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIContent> labelContent(do_CreateInstance(kTextNodeCID, &rv));
|
||||
if (NS_SUCCEEDED(rv) && labelContent) {
|
||||
|
||||
nsCOMPtr<nsITextContent> labelContent;
|
||||
NS_NewTextNode(getter_AddRefs(labelContent));
|
||||
|
||||
if (labelContent) {
|
||||
// set the value of the text node
|
||||
mDisplayContent = do_QueryInterface(labelContent);
|
||||
mDisplayContent.swap(labelContent);
|
||||
mDisplayContent->SetText(NS_LITERAL_STRING("X"), PR_TRUE);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
|
||||
|
@ -2030,11 +2030,11 @@ nsComboboxControlFrame::CreateAnonymousContent(nsPresContext* aPresContext,
|
|||
kNameSpaceID_None,
|
||||
getter_AddRefs(nodeInfo));
|
||||
|
||||
aChildList.AppendElement(labelContent);
|
||||
aChildList.AppendElement(mDisplayContent);
|
||||
|
||||
// create button which drops the list down
|
||||
nsCOMPtr<nsIContent> btnContent;
|
||||
rv = NS_NewHTMLElement(getter_AddRefs(btnContent), nodeInfo);
|
||||
nsresult rv = NS_NewHTMLElement(getter_AddRefs(btnContent), nodeInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// make someone to listen to the button. If its pressed by someone like Accessibility
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#include "nsFormControlFrame.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsContentCID.h"
|
||||
#ifdef ACCESSIBILITY
|
||||
#include "nsIAccessibilityService.h"
|
||||
#endif
|
||||
|
@ -55,8 +54,6 @@
|
|||
// MouseEvent suppression in PP
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
|
||||
// Saving PresState
|
||||
#include "nsIPresState.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
|
@ -197,14 +194,13 @@ nsGfxButtonControlFrame::CreateAnonymousContent(nsPresContext* aPresContext,
|
|||
}
|
||||
|
||||
// Add a child text content node for the label
|
||||
nsCOMPtr<nsIContent> labelContent(do_CreateInstance(kTextNodeCID,&result));
|
||||
if (NS_SUCCEEDED(result) && labelContent) {
|
||||
nsCOMPtr<nsITextContent> labelContent;
|
||||
NS_NewTextNode(getter_AddRefs(labelContent));
|
||||
if (labelContent) {
|
||||
// set the value of the text node and add it to the child list
|
||||
mTextContent = do_QueryInterface(labelContent, &result);
|
||||
if (NS_SUCCEEDED(result) && mTextContent) {
|
||||
mTextContent->SetText(value, PR_TRUE);
|
||||
aChildList.AppendElement(mTextContent);
|
||||
}
|
||||
mTextContent.swap(labelContent);
|
||||
mTextContent->SetText(value, PR_TRUE);
|
||||
aChildList.AppendElement(mTextContent);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -80,8 +80,6 @@
|
|||
#include "nsNodeInfoManager.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
|
||||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
|
||||
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
|
||||
nsresult
|
||||
|
@ -99,9 +97,7 @@ NS_NewIsIndexFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIsIndexFrame::nsIsIndexFrame():
|
||||
mTextContent(nsnull),
|
||||
mInputContent(nsnull)
|
||||
nsIsIndexFrame::nsIsIndexFrame()
|
||||
{
|
||||
//Shrink the area around it's contents
|
||||
SetFlags(NS_BLOCK_SHRINK_WRAP);
|
||||
|
@ -109,14 +105,10 @@ nsIsIndexFrame::nsIsIndexFrame():
|
|||
|
||||
nsIsIndexFrame::~nsIsIndexFrame()
|
||||
{
|
||||
if (mTextContent) {
|
||||
NS_RELEASE(mTextContent);
|
||||
}
|
||||
// remove ourself as a listener of the text control (bug 40533)
|
||||
if (mInputContent) {
|
||||
nsCOMPtr<nsIDOMEventReceiver> reciever(do_QueryInterface(mInputContent));
|
||||
reciever->RemoveEventListenerByIID(this, NS_GET_IID(nsIDOMKeyListener));
|
||||
NS_RELEASE(mInputContent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,9 +156,10 @@ nsIsIndexFrame::UpdatePromptLabel()
|
|||
result = nsFormControlHelper::GetLocalizedString(nsFormControlHelper::GetHTMLPropertiesFileName(),
|
||||
NS_LITERAL_STRING("IsIndexPrompt").get(), prompt);
|
||||
}
|
||||
nsCOMPtr<nsITextContent> text = do_QueryInterface(mTextContent);
|
||||
text->SetText(prompt, PR_TRUE);
|
||||
return result;
|
||||
|
||||
mTextContent->SetText(prompt, PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -242,14 +235,13 @@ nsIsIndexFrame::CreateAnonymousContent(nsPresContext* aPresContext,
|
|||
|
||||
// Add a child text content node for the label
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
nsCOMPtr<nsIContent> labelContent(do_CreateInstance(kTextNodeCID,&result));
|
||||
if (NS_SUCCEEDED(result) && labelContent) {
|
||||
nsCOMPtr<nsITextContent> labelContent;
|
||||
NS_NewTextNode(getter_AddRefs(labelContent));
|
||||
if (labelContent) {
|
||||
// set the value of the text node and add it to the child list
|
||||
result = labelContent->QueryInterface(NS_GET_IID(nsITextContent),(void**)&mTextContent);
|
||||
if (NS_SUCCEEDED(result) && mTextContent) {
|
||||
UpdatePromptLabel();
|
||||
result = aChildList.AppendElement(mTextContent);
|
||||
}
|
||||
mTextContent.swap(labelContent);
|
||||
UpdatePromptLabel();
|
||||
aChildList.AppendElement(mTextContent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -258,7 +250,7 @@ nsIsIndexFrame::CreateAnonymousContent(nsPresContext* aPresContext,
|
|||
nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None,
|
||||
getter_AddRefs(inputInfo));
|
||||
|
||||
result = NS_NewHTMLElement(&mInputContent, inputInfo);
|
||||
result = NS_NewHTMLElement(getter_AddRefs(mInputContent), inputInfo);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
mInputContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("text"), PR_FALSE);
|
||||
|
|
|
@ -1,162 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* 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.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIsIndexFrame_h___
|
||||
#define nsIsIndexFrame_h___
|
||||
|
||||
#include "nsAreaFrame.h"
|
||||
#include "nsIFormControlFrame.h"
|
||||
#include "nsIAnonymousContentCreator.h"
|
||||
#include "nsIStatefulFrame.h"
|
||||
#include "nsIUnicodeEncoder.h"
|
||||
#include "nsIDOMKeyListener.h"
|
||||
|
||||
#include "nsTextControlFrame.h"
|
||||
#include "nsFormControlHelper.h"
|
||||
typedef nsTextControlFrame nsNewFrame;
|
||||
|
||||
class nsIPresState;
|
||||
class nsISupportsArray;
|
||||
class nsIHTMLContent;
|
||||
|
||||
class nsIsIndexFrame : public nsAreaFrame,
|
||||
public nsIAnonymousContentCreator,
|
||||
public nsIDOMKeyListener,
|
||||
public nsIStatefulFrame
|
||||
{
|
||||
public:
|
||||
nsIsIndexFrame();
|
||||
virtual ~nsIsIndexFrame();
|
||||
|
||||
NS_IMETHOD Paint(nsPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer,
|
||||
PRUint32 aFlags = 0);
|
||||
|
||||
// XXX Hack so we can squirrel away the pres context pointer for the KeyPress method
|
||||
NS_IMETHOD Init(nsPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIFrame* aParent,
|
||||
nsStyleContext* aContext,
|
||||
nsIFrame* aPrevInFlow) {
|
||||
mPresContext = aPresContext;
|
||||
return nsAreaFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a key pressed event
|
||||
* @param aKeyEvent @see nsIDOMEvent.h
|
||||
* @returns whether the event was consumed or ignored. @see nsresult
|
||||
*/
|
||||
NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent) { return NS_OK; }
|
||||
|
||||
/**
|
||||
* Processes a key release event
|
||||
* @param aKeyEvent @see nsIDOMEvent.h
|
||||
* @returns whether the event was consumed or ignored. @see nsresult
|
||||
*/
|
||||
NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent) { return NS_OK; }
|
||||
|
||||
/**
|
||||
* Processes a key typed event
|
||||
* @param aKeyEvent @see nsIDOMEvent.h
|
||||
* @returns whether the event was consumed or ignored. @see nsresult
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent); // we only care when a key is pressed
|
||||
|
||||
// nsIFormControlFrame
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
NS_IMETHOD Reflow(nsPresContext* aCX,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
NS_IMETHOD GetFrameName(nsAString& aResult) const;
|
||||
#endif
|
||||
NS_IMETHOD AttributeChanged(nsPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aModType);
|
||||
|
||||
void SetFocus(PRBool aOn, PRBool aRepaint);
|
||||
void ScrollIntoView(nsPresContext* aPresContext);
|
||||
|
||||
// from nsIAnonymousContentCreator
|
||||
NS_IMETHOD CreateAnonymousContent(nsPresContext* aPresContext,
|
||||
nsISupportsArray& aChildList);
|
||||
NS_IMETHOD CreateFrameFor(nsPresContext* aPresContext,
|
||||
nsIContent * aContent,
|
||||
nsIFrame** aFrame) { if (aFrame) *aFrame = nsnull; return NS_ERROR_FAILURE; }
|
||||
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
||||
NS_IMETHOD OnSubmit(nsPresContext* aPresContext);
|
||||
|
||||
//nsIStatefulFrame
|
||||
NS_IMETHOD SaveState(nsPresContext* aPresContext, nsIPresState** aState);
|
||||
NS_IMETHOD RestoreState(nsPresContext* aPresContext, nsIPresState* aState);
|
||||
|
||||
protected:
|
||||
nsIHTMLContent* mTextContent;
|
||||
nsIContent* mInputContent;
|
||||
|
||||
// XXX Hack: pres context needed by function KeyPress() and SetFocus()
|
||||
nsPresContext* mPresContext; // weak reference
|
||||
|
||||
private:
|
||||
NS_IMETHOD UpdatePromptLabel();
|
||||
NS_IMETHOD GetInputFrame(nsPresContext* aPresContext, nsIFormControlFrame** oFrame);
|
||||
NS_IMETHOD GetInputValue(nsPresContext* aPresContext, nsString& oString);
|
||||
NS_IMETHOD SetInputValue(nsPresContext* aPresContext, const nsString aString);
|
||||
|
||||
void GetSubmitCharset(nsCString& oCharset);
|
||||
NS_IMETHOD GetEncoder(nsIUnicodeEncoder** encoder);
|
||||
char* UnicodeToNewBytes(const PRUnichar* aSrc, PRUint32 aLen, nsIUnicodeEncoder* encoder);
|
||||
void URLEncode(const nsString& aString, nsIUnicodeEncoder* encoder, nsString& oString);
|
||||
|
||||
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
|
||||
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -114,7 +114,6 @@
|
|||
#include "nsXULAtoms.h"
|
||||
#include "nsBoxFrame.h"
|
||||
|
||||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
|
@ -1488,10 +1487,8 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsPresContext* aPresContext
|
|||
rv = NS_NewAttributeContent(aContent, attrNameSpace, attrName,
|
||||
getter_AddRefs(content));
|
||||
|
||||
// Set aContent as the parent content and set the document
|
||||
// object. This way event handling works
|
||||
// Set aContent as the parent content so that event handling works.
|
||||
content->SetParent(aContent);
|
||||
content->SetDocument(aDocument, PR_TRUE, PR_TRUE);
|
||||
content->SetNativeAnonymous(PR_TRUE);
|
||||
content->SetBindingParent(content);
|
||||
|
||||
|
@ -1544,19 +1541,17 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsPresContext* aPresContext
|
|||
|
||||
// Create a text content node
|
||||
nsIFrame* textFrame = nsnull;
|
||||
nsCOMPtr<nsIContent> textContent = do_CreateInstance(kTextNodeCID);
|
||||
nsCOMPtr<nsITextContent> textContent;
|
||||
NS_NewTextNode(getter_AddRefs(textContent));
|
||||
if (textContent) {
|
||||
// Set the text
|
||||
nsCOMPtr<nsIDOMCharacterData> domData = do_QueryInterface(textContent);
|
||||
domData->SetData(contentString);
|
||||
textContent->SetText(contentString, PR_TRUE);
|
||||
|
||||
if (textPtr)
|
||||
*textPtr = domData;
|
||||
*textPtr = do_QueryInterface(textContent);
|
||||
|
||||
// Set aContent as the parent content and set the document object. This
|
||||
// way event handling works
|
||||
// Set aContent as the parent content so that event handling works.
|
||||
textContent->SetParent(aContent);
|
||||
textContent->SetDocument(aDocument, PR_TRUE, PR_TRUE);
|
||||
textContent->SetNativeAnonymous(PR_TRUE);
|
||||
textContent->SetBindingParent(textContent);
|
||||
|
||||
|
@ -10167,18 +10162,16 @@ nsCSSFrameConstructor::ConstructAlternateFrame(nsIPresShell* aPresShell,
|
|||
GetAlternateTextFor(aContent, aContent->Tag(), altText);
|
||||
|
||||
// Create a text content element for the alternate text
|
||||
nsCOMPtr<nsIContent> altTextContent(do_CreateInstance(kTextNodeCID,&rv));
|
||||
nsCOMPtr<nsITextContent> altTextContent;
|
||||
rv = NS_NewTextNode(getter_AddRefs(altTextContent));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Set the content's text
|
||||
nsCOMPtr<nsIDOMCharacterData> domData = do_QueryInterface(altTextContent);
|
||||
if (domData)
|
||||
domData->SetData(altText);
|
||||
altTextContent->SetText(altText, PR_TRUE);
|
||||
|
||||
// Set aContent as the parent content and set the document object
|
||||
// Set aContent as the parent content.
|
||||
altTextContent->SetParent(aContent);
|
||||
altTextContent->SetDocument(mDocument, PR_TRUE, PR_TRUE);
|
||||
|
||||
// Create either an inline frame, block frame, or area frame
|
||||
nsIFrame* containerFrame;
|
||||
|
|
|
@ -264,8 +264,6 @@ int main(int argc, char** argv)
|
|||
txt->AppendData(tmp);
|
||||
NS_RELEASE(txt);
|
||||
|
||||
text->SetDocument(myDoc, PR_FALSE, PR_TRUE);
|
||||
|
||||
#if 0
|
||||
// Query ITextContent interface
|
||||
nsITextContent* textContent;
|
||||
|
|
Загрузка…
Ссылка в новой задаче