Bug 968923 - part 2 - change MappedAttrParser to store a nsSVGElement directly, instead of its nsIPrincipal; r=smaug

We'll need access to the element, and to its OwnerDoc, once we hook up
use counters.
This commit is contained in:
Cameron McCormack 2015-02-05 12:32:14 -05:00
parent 1f278968fd
commit e432a02402

View File

@ -1129,7 +1129,7 @@ public:
MappedAttrParser(css::Loader* aLoader, MappedAttrParser(css::Loader* aLoader,
nsIURI* aDocURI, nsIURI* aDocURI,
already_AddRefed<nsIURI> aBaseURI, already_AddRefed<nsIURI> aBaseURI,
nsIPrincipal* aNodePrincipal); nsSVGElement* aElement);
~MappedAttrParser(); ~MappedAttrParser();
// Parses a mapped attribute value. // Parses a mapped attribute value.
@ -1149,18 +1149,20 @@ private:
// Arguments for nsCSSParser::ParseProperty // Arguments for nsCSSParser::ParseProperty
nsIURI* mDocURI; nsIURI* mDocURI;
nsCOMPtr<nsIURI> mBaseURI; nsCOMPtr<nsIURI> mBaseURI;
nsIPrincipal* mNodePrincipal;
// Declaration for storing parsed values (lazily initialized) // Declaration for storing parsed values (lazily initialized)
css::Declaration* mDecl; css::Declaration* mDecl;
// For reporting use counters
nsSVGElement* mElement;
}; };
MappedAttrParser::MappedAttrParser(css::Loader* aLoader, MappedAttrParser::MappedAttrParser(css::Loader* aLoader,
nsIURI* aDocURI, nsIURI* aDocURI,
already_AddRefed<nsIURI> aBaseURI, already_AddRefed<nsIURI> aBaseURI,
nsIPrincipal* aNodePrincipal) nsSVGElement* aElement)
: mParser(aLoader), mDocURI(aDocURI), mBaseURI(aBaseURI), : mParser(aLoader), mDocURI(aDocURI), mBaseURI(aBaseURI),
mNodePrincipal(aNodePrincipal), mDecl(nullptr) mDecl(nullptr), mElement(aElement)
{ {
} }
@ -1187,7 +1189,7 @@ MappedAttrParser::ParseMappedAttrValue(nsIAtom* aMappedAttrName,
if (propertyID != eCSSProperty_UNKNOWN) { if (propertyID != eCSSProperty_UNKNOWN) {
bool changed; // outparam for ParseProperty. (ignored) bool changed; // outparam for ParseProperty. (ignored)
mParser.ParseProperty(propertyID, aMappedAttrValue, mDocURI, mBaseURI, mParser.ParseProperty(propertyID, aMappedAttrValue, mDocURI, mBaseURI,
mNodePrincipal, mDecl, &changed, false, true); mElement->NodePrincipal(), mDecl, &changed, false, true);
return; return;
} }
MOZ_ASSERT(aMappedAttrName == nsGkAtoms::lang, MOZ_ASSERT(aMappedAttrName == nsGkAtoms::lang,
@ -1234,7 +1236,7 @@ nsSVGElement::UpdateContentStyleRule()
nsIDocument* doc = OwnerDoc(); nsIDocument* doc = OwnerDoc();
MappedAttrParser mappedAttrParser(doc->CSSLoader(), doc->GetDocumentURI(), MappedAttrParser mappedAttrParser(doc->CSSLoader(), doc->GetDocumentURI(),
GetBaseURI(), NodePrincipal()); GetBaseURI(), this);
for (uint32_t i = 0; i < attrCount; ++i) { for (uint32_t i = 0; i < attrCount; ++i) {
const nsAttrName* attrName = mAttrsAndChildren.AttrNameAt(i); const nsAttrName* attrName = mAttrsAndChildren.AttrNameAt(i);
@ -1325,7 +1327,7 @@ nsSVGElement::UpdateAnimatedContentStyleRule()
} }
MappedAttrParser mappedAttrParser(doc->CSSLoader(), doc->GetDocumentURI(), MappedAttrParser mappedAttrParser(doc->CSSLoader(), doc->GetDocumentURI(),
GetBaseURI(), NodePrincipal()); GetBaseURI(), this);
doc->PropertyTable(SMIL_MAPPED_ATTR_ANIMVAL)-> doc->PropertyTable(SMIL_MAPPED_ATTR_ANIMVAL)->
Enumerate(this, ParseMappedAttrAnimValueCallback, &mappedAttrParser); Enumerate(this, ParseMappedAttrAnimValueCallback, &mappedAttrParser);