зеркало из https://github.com/mozilla/gecko-dev.git
Bug 531259 - The SVG script element should respect the aFromParser flag on NS_NewElement. r=hsivonen, r+sr=jst
This commit is contained in:
Родитель
42233b71c8
Коммит
2d6a644d32
|
@ -47,8 +47,8 @@
|
|||
#include "nsIParser.h"
|
||||
|
||||
#define NS_ISCRIPTELEMENT_IID \
|
||||
{ 0xa9d5732a, 0x8c1f, 0x439d, \
|
||||
{ 0x83, 0x75, 0x3d, 0xf6, 0xa9, 0xba, 0xa3, 0x7d } }
|
||||
{ 0x6d625b30, 0xfac4, 0x11de, \
|
||||
{ 0x8a, 0x39, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66 } }
|
||||
|
||||
/**
|
||||
* Internal interface implemented by script elements
|
||||
|
@ -140,12 +140,6 @@ public:
|
|||
mIsEvaluated = PR_TRUE;
|
||||
}
|
||||
|
||||
void WillCallDoneAddingChildren()
|
||||
{
|
||||
NS_ASSERTION(mDoneAddingChildren, "unexpected, but not fatal");
|
||||
mDoneAddingChildren = PR_FALSE;
|
||||
}
|
||||
|
||||
void SetCreatorParser(nsIParser* aParser)
|
||||
{
|
||||
mCreatorParser = getter_AddRefs(NS_GetWeakReference(aParser));
|
||||
|
|
|
@ -371,26 +371,45 @@ nsresult \
|
|||
NS_NewSVG##_elementName##Element(nsIContent **aResult, \
|
||||
nsINodeInfo *aNodeInfo) \
|
||||
{ \
|
||||
nsSVG##_elementName##Element *it = \
|
||||
nsRefPtr<nsSVG##_elementName##Element> it = \
|
||||
new nsSVG##_elementName##Element(aNodeInfo); \
|
||||
if (!it) \
|
||||
return NS_ERROR_OUT_OF_MEMORY; \
|
||||
\
|
||||
NS_ADDREF(it); \
|
||||
\
|
||||
nsresult rv = it->Init(); \
|
||||
\
|
||||
if (NS_FAILED(rv)) { \
|
||||
NS_RELEASE(it); \
|
||||
return rv; \
|
||||
} \
|
||||
\
|
||||
*aResult = it; \
|
||||
*aResult = it.forget().get(); \
|
||||
\
|
||||
return rv; \
|
||||
}
|
||||
|
||||
// No unlinking, we'd need to null out the value pointer (the object it
|
||||
#define NS_IMPL_NS_NEW_SVG_ELEMENT_CHECK_PARSER(_elementName) \
|
||||
nsresult \
|
||||
NS_NewSVG##_elementName##Element(nsIContent **aResult, \
|
||||
nsINodeInfo *aNodeInfo, \
|
||||
PRBool aFromParser) \
|
||||
{ \
|
||||
nsRefPtr<nsSVG##_elementName##Element> it = \
|
||||
new nsSVG##_elementName##Element(aNodeInfo, aFromParser); \
|
||||
if (!it) \
|
||||
return NS_ERROR_OUT_OF_MEMORY; \
|
||||
\
|
||||
nsresult rv = it->Init(); \
|
||||
\
|
||||
if (NS_FAILED(rv)) { \
|
||||
return rv; \
|
||||
} \
|
||||
\
|
||||
*aResult = it.forget().get(); \
|
||||
\
|
||||
return rv; \
|
||||
}
|
||||
|
||||
// No unlinking, we'd need to null out the value pointer (the object it
|
||||
// points to is held by the element) and null-check it everywhere.
|
||||
#define NS_SVG_VAL_IMPL_CYCLE_COLLECTION(_val, _element) \
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(_val) \
|
||||
|
|
|
@ -91,7 +91,8 @@ NS_NewSVGDefsElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
|
|||
nsresult
|
||||
NS_NewSVGDescElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
|
||||
nsresult
|
||||
NS_NewSVGScriptElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
|
||||
NS_NewSVGScriptElement(nsIContent **aResult, nsINodeInfo *aNodeInfo,
|
||||
PRBool aFromParser);
|
||||
nsresult
|
||||
NS_NewSVGUseElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
|
||||
nsresult
|
||||
|
@ -229,7 +230,7 @@ NS_NewSVGElement(nsIContent** aResult, nsINodeInfo *aNodeInfo,
|
|||
if (name == nsGkAtoms::desc)
|
||||
return NS_NewSVGDescElement(aResult, aNodeInfo);
|
||||
if (name == nsGkAtoms::script)
|
||||
return NS_NewSVGScriptElement(aResult, aNodeInfo);
|
||||
return NS_NewSVGScriptElement(aResult, aNodeInfo, aFromParser);
|
||||
if (name == nsGkAtoms::use)
|
||||
return NS_NewSVGUseElement(aResult, aNodeInfo);
|
||||
if (name == nsGkAtoms::symbol)
|
||||
|
|
|
@ -152,28 +152,7 @@ nsSVGElement::EnumInfo nsSVGSVGElement::sEnumInfo[1] =
|
|||
}
|
||||
};
|
||||
|
||||
// From NS_IMPL_NS_NEW_SVG_ELEMENT but with aFromParser
|
||||
nsresult
|
||||
NS_NewSVGSVGElement(nsIContent **aResult, nsINodeInfo *aNodeInfo,
|
||||
PRBool aFromParser)
|
||||
{
|
||||
nsSVGSVGElement *it = new nsSVGSVGElement(aNodeInfo, aFromParser);
|
||||
if (!it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(it);
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aResult = it;
|
||||
|
||||
return rv;
|
||||
}
|
||||
NS_IMPL_NS_NEW_SVG_ELEMENT_CHECK_PARSER(SVG)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
|
|
@ -58,8 +58,9 @@ class nsSVGScriptElement : public nsSVGScriptElementBase,
|
|||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGScriptElement(nsIContent **aResult,
|
||||
nsINodeInfo *aNodeInfo);
|
||||
nsSVGScriptElement(nsINodeInfo *aNodeInfo);
|
||||
nsINodeInfo *aNodeInfo,
|
||||
PRBool aFromParser);
|
||||
nsSVGScriptElement(nsINodeInfo *aNodeInfo, PRBool aFromParser);
|
||||
|
||||
public:
|
||||
// interfaces:
|
||||
|
@ -88,6 +89,7 @@ public:
|
|||
|
||||
// nsIContent specializations:
|
||||
virtual nsresult DoneAddingChildren(PRBool aHaveNotified);
|
||||
virtual PRBool IsDoneAddingChildren();
|
||||
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
nsIContent* aBindingParent,
|
||||
PRBool aCompileEventHandlers);
|
||||
|
@ -107,7 +109,7 @@ nsSVGElement::StringInfo nsSVGScriptElement::sStringInfo[1] =
|
|||
{ &nsGkAtoms::href, kNameSpaceID_XLink }
|
||||
};
|
||||
|
||||
NS_IMPL_NS_NEW_SVG_ELEMENT(Script)
|
||||
NS_IMPL_NS_NEW_SVG_ELEMENT_CHECK_PARSER(Script)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
@ -126,9 +128,11 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGScriptElementBase)
|
|||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGScriptElement::nsSVGScriptElement(nsINodeInfo *aNodeInfo)
|
||||
nsSVGScriptElement::nsSVGScriptElement(nsINodeInfo *aNodeInfo,
|
||||
PRBool aFromParser)
|
||||
: nsSVGScriptElementBase(aNodeInfo)
|
||||
{
|
||||
mDoneAddingChildren = !aFromParser;
|
||||
AddMutationObserver(this);
|
||||
}
|
||||
|
||||
|
@ -140,7 +144,7 @@ nsSVGScriptElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
|
|||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
nsSVGScriptElement* it = new nsSVGScriptElement(aNodeInfo);
|
||||
nsSVGScriptElement* it = new nsSVGScriptElement(aNodeInfo, PR_FALSE);
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -278,6 +282,12 @@ nsSVGScriptElement::DoneAddingChildren(PRBool aHaveNotified)
|
|||
return rv;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsSVGScriptElement::IsDoneAddingChildren()
|
||||
{
|
||||
return mDoneAddingChildren;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGScriptElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
nsIContent* aBindingParent,
|
||||
|
|
|
@ -524,9 +524,6 @@ nsXMLContentSink::CreateElement(const PRUnichar** aAtts, PRUint32 aAttsCount,
|
|||
) {
|
||||
nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(content);
|
||||
sele->SetScriptLineNumber(aLineNumber);
|
||||
if (aNodeInfo->Equals(nsGkAtoms::script, kNameSpaceID_SVG)) {
|
||||
sele->WillCallDoneAddingChildren();
|
||||
}
|
||||
mConstrainSize = PR_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -549,11 +549,6 @@ txMozillaXMLOutput::startElementInternal(nsIAtom* aPrefix,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
}
|
||||
else if (aNsID == kNameSpaceID_SVG &&
|
||||
aLocalName == txHTMLAtoms::script) {
|
||||
nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(mOpenedElement);
|
||||
sele->WillCallDoneAddingChildren();
|
||||
}
|
||||
}
|
||||
|
||||
if (mCreatingNewDocument) {
|
||||
|
@ -746,10 +741,6 @@ txMozillaXMLOutput::startHTMLElement(nsIContent* aElement, PRBool aIsHTML)
|
|||
rv = aElement->AppendChildTo(meta, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else if (atom == nsGkAtoms::script) {
|
||||
nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(aElement);
|
||||
sele->WillCallDoneAddingChildren();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -373,9 +373,6 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
|||
ssle->InitStyleLinkElement(PR_FALSE);
|
||||
ssle->SetEnableUpdates(PR_FALSE);
|
||||
}
|
||||
} else if (NS_UNLIKELY(name == nsHtml5Atoms::script && ns == kNameSpaceID_SVG)) {
|
||||
nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(newContent);
|
||||
sele->WillCallDoneAddingChildren();
|
||||
}
|
||||
|
||||
if (!attributes) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче