Bug 776517 - Move GetExistingAttrNameFromQName from nsIContent to dom::Element; r=smaug

This commit is contained in:
Ms2ger 2013-07-24 09:39:46 +02:00
parent cf27a89df0
commit a185a3e840
7 changed files with 32 additions and 43 deletions

View File

@ -406,7 +406,20 @@ public:
bool aCompileEventHandlers) MOZ_OVERRIDE;
virtual void UnbindFromTree(bool aDeep = true,
bool aNullParent = true) MOZ_OVERRIDE;
virtual already_AddRefed<nsINodeInfo> GetExistingAttrNameFromQName(const nsAString& aStr) const MOZ_OVERRIDE;
/**
* Normalizes an attribute name and returns it as a nodeinfo if an attribute
* with that name exists. This method is intended for character case
* conversion if the content object is case insensitive (e.g. HTML). Returns
* the nodeinfo of the attribute with the specified name if one exists or
* null otherwise.
*
* @param aStr the unparsed attribute string
* @return the node info. May be nullptr.
*/
already_AddRefed<nsINodeInfo>
GetExistingAttrNameFromQName(const nsAString& aStr) const;
nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
const nsAString& aValue, bool aNotify)
{

View File

@ -34,8 +34,8 @@ enum nsLinkState {
// IID for the nsIContent interface
#define NS_ICONTENT_IID \
{ 0Xf22c131c, 0Xc554, 0X4d06, \
{ 0X81, 0Xac, 0X86, 0X64, 0X2f, 0X05, 0Xcc, 0X81 } }
{ 0x976f4cd1, 0xbdfc, 0x4a1e, \
{ 0x82, 0x46, 0x1c, 0x13, 0x9c, 0xd3, 0x73, 0x7f } }
/**
* A node of content in a document's content model. This interface
@ -319,18 +319,6 @@ public:
*/
virtual nsIAtom *GetIDAttributeName() const = 0;
/**
* Normalizes an attribute name and returns it as a nodeinfo if an attribute
* with that name exists. This method is intended for character case
* conversion if the content object is case insensitive (e.g. HTML). Returns
* the nodeinfo of the attribute with the specified name if one exists or
* null otherwise.
*
* @param aStr the unparsed attribute string
* @return the node info. May be nullptr.
*/
virtual already_AddRefed<nsINodeInfo> GetExistingAttrNameFromQName(const nsAString& aStr) const = 0;
/**
* Set attribute values. All attribute values are assumed to have a
* canonical string representation that can be used for these

View File

@ -74,12 +74,6 @@ public:
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
// nsIContent
virtual already_AddRefed<nsINodeInfo>
GetExistingAttrNameFromQName(const nsAString& aStr) const MOZ_OVERRIDE
{
return nullptr;
}
nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
const nsAString& aValue, bool aNotify)
{

View File

@ -572,12 +572,6 @@ nsGenericDOMDataNode::GetIDAttributeName() const
return nullptr;
}
already_AddRefed<nsINodeInfo>
nsGenericDOMDataNode::GetExistingAttrNameFromQName(const nsAString& aStr) const
{
return nullptr;
}
nsresult
nsGenericDOMDataNode::SetAttr(int32_t aNameSpaceID, nsIAtom* aAttr,
nsIAtom* aPrefix, const nsAString& aValue,

View File

@ -115,7 +115,7 @@ public:
virtual already_AddRefed<nsINodeList> GetChildren(uint32_t aFilter) MOZ_OVERRIDE;
virtual nsIAtom *GetIDAttributeName() const MOZ_OVERRIDE;
virtual already_AddRefed<nsINodeInfo> GetExistingAttrNameFromQName(const nsAString& aStr) const MOZ_OVERRIDE;
nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
const nsAString& aValue, bool aNotify)
{

View File

@ -1293,16 +1293,15 @@ XULDocument::Persist(const nsAString& aID,
if (mApplyingPersistedAttrs)
return NS_OK;
nsresult rv;
nsIContent *element = nsDocument::GetElementById(aID);
if (! element)
Element* element = nsDocument::GetElementById(aID);
if (!element)
return NS_OK;
nsCOMPtr<nsIAtom> tag;
int32_t nameSpaceID;
nsCOMPtr<nsINodeInfo> ni = element->GetExistingAttrNameFromQName(aAttr);
nsresult rv;
if (ni) {
tag = ni->NameAtom();
nameSpaceID = ni->NamespaceID();

View File

@ -146,7 +146,7 @@ protected:
* @param aResult result to look up variable->value bindings in
*/
nsresult
AddPersistentAttributes(nsIContent* aTemplateNode,
AddPersistentAttributes(Element* aTemplateNode,
nsIXULTemplateResult* aResult,
nsIContent* aRealNode);
@ -513,16 +513,16 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
bool isGenerationElement = false;
bool isUnique = aIsUnique;
{
// We identify the resource element by presence of a
// "uri='rdf:*'" attribute. (We also support the older
// "uri='...'" syntax.)
if (tmplKid->HasAttr(kNameSpaceID_None, nsGkAtoms::uri) && aMatch->IsActive()) {
isGenerationElement = true;
isUnique = false;
}
// We identify the resource element by presence of a
// "uri='rdf:*'" attribute. (We also support the older
// "uri='...'" syntax.)
if (tmplKid->HasAttr(kNameSpaceID_None, nsGkAtoms::uri) && aMatch->IsActive()) {
isGenerationElement = true;
isUnique = false;
}
MOZ_ASSERT_IF(isGenerationElement, tmplKid->IsElement());
nsIAtom *tag = tmplKid->Tag();
#ifdef PR_LOGGING
@ -679,7 +679,8 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
// Add any persistent attributes
if (isGenerationElement) {
rv = AddPersistentAttributes(tmplKid, aChild, realKid);
rv = AddPersistentAttributes(tmplKid->AsElement(), aChild,
realKid);
if (NS_FAILED(rv)) return rv;
}
@ -783,7 +784,7 @@ nsXULContentBuilder::CopyAttributesToElement(nsIContent* aTemplateNode,
}
nsresult
nsXULContentBuilder::AddPersistentAttributes(nsIContent* aTemplateNode,
nsXULContentBuilder::AddPersistentAttributes(Element* aTemplateNode,
nsIXULTemplateResult* aResult,
nsIContent* aRealNode)
{