mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 761020 - Add nsIDocument::GetDocumentType(); r=mounir
This commit is contained in:
parent
f696a656cc
commit
33a16fe510
@ -92,8 +92,8 @@ class Element;
|
||||
} // namespace mozilla
|
||||
|
||||
#define NS_IDOCUMENT_IID \
|
||||
{ 0x7bac702d, 0xca67, 0x4ce1, \
|
||||
{ 0x80, 0x3c, 0x35, 0xde, 0x81, 0x26, 0x04, 0x97 } }
|
||||
{ 0x077dcff0, 0x400d, 0x4d3c, \
|
||||
{ 0xbd, 0x4d, 0x5f, 0xd5, 0xe1, 0xa6, 0x63, 0x07 } }
|
||||
|
||||
// Flag for AddStyleSheet().
|
||||
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
|
||||
@ -501,10 +501,15 @@ public:
|
||||
*/
|
||||
virtual Element* FindContentForSubDocument(nsIDocument* aDocument) const = 0;
|
||||
|
||||
/**
|
||||
* Return the doctype for this document.
|
||||
*/
|
||||
nsIContent* GetDocumentType() const;
|
||||
|
||||
/**
|
||||
* Return the root element for this document.
|
||||
*/
|
||||
Element *GetRootElement() const;
|
||||
Element* GetRootElement() const;
|
||||
|
||||
protected:
|
||||
virtual Element *GetRootElementInternal() const = 0;
|
||||
|
@ -4295,22 +4295,25 @@ nsDocument::StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
|
||||
//
|
||||
// nsIDOMDocument interface
|
||||
//
|
||||
nsIContent*
|
||||
nsIDocument::GetDocumentType() const
|
||||
{
|
||||
for (nsIContent* child = GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->NodeType() == nsIDOMNode::DOCUMENT_TYPE_NODE) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetDoctype(nsIDOMDocumentType** aDoctype)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDoctype);
|
||||
|
||||
*aDoctype = nsnull;
|
||||
PRInt32 i, count;
|
||||
count = mChildren.ChildCount();
|
||||
for (i = 0; i < count; i++) {
|
||||
CallQueryInterface(mChildren.ChildAt(i), aDoctype);
|
||||
|
||||
if (*aDoctype) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
MOZ_ASSERT(aDoctype);
|
||||
nsCOMPtr<nsIDOMDocumentType> doctype = do_QueryInterface(GetDocumentType());
|
||||
doctype.forget(aDoctype);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -4000,8 +4000,8 @@ bool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent,
|
||||
return true;
|
||||
}
|
||||
|
||||
Element* rootElement =
|
||||
static_cast<nsIDocument*>(aParent)->GetRootElement();
|
||||
nsIDocument* parentDocument = static_cast<nsIDocument*>(aParent);
|
||||
Element* rootElement = parentDocument->GetRootElement();
|
||||
if (rootElement) {
|
||||
// Already have a documentElement, so this is only OK if we're
|
||||
// replacing it.
|
||||
@ -4015,13 +4015,7 @@ bool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent,
|
||||
return true;
|
||||
}
|
||||
|
||||
// Now grovel for a doctype
|
||||
nsCOMPtr<nsIDOMDocument> doc = do_QueryInterface(aParent);
|
||||
NS_ASSERTION(doc, "Shouldn't happen");
|
||||
nsCOMPtr<nsIDOMDocumentType> docType;
|
||||
doc->GetDoctype(getter_AddRefs(docType));
|
||||
nsCOMPtr<nsIContent> docTypeContent = do_QueryInterface(docType);
|
||||
|
||||
nsIContent* docTypeContent = parentDocument->GetDocumentType();
|
||||
if (!docTypeContent) {
|
||||
// It's all good.
|
||||
return true;
|
||||
@ -4043,11 +4037,8 @@ bool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent,
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> doc = do_QueryInterface(aParent);
|
||||
NS_ASSERTION(doc, "Shouldn't happen");
|
||||
nsCOMPtr<nsIDOMDocumentType> docType;
|
||||
doc->GetDoctype(getter_AddRefs(docType));
|
||||
nsCOMPtr<nsIContent> docTypeContent = do_QueryInterface(docType);
|
||||
nsIDocument* parentDocument = static_cast<nsIDocument*>(aParent);
|
||||
nsIContent* docTypeContent = parentDocument->GetDocumentType();
|
||||
if (docTypeContent) {
|
||||
// Already have a doctype, so this is only OK if we're replacing it
|
||||
return aIsReplace && docTypeContent == aRefChild;
|
||||
@ -4055,8 +4046,7 @@ bool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent,
|
||||
|
||||
// We don't have a doctype yet. Our one remaining constraint is
|
||||
// that the doctype must come before the documentElement.
|
||||
Element* rootElement =
|
||||
static_cast<nsIDocument*>(aParent)->GetRootElement();
|
||||
Element* rootElement = parentDocument->GetRootElement();
|
||||
if (!rootElement) {
|
||||
// It's all good
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user