diff --git a/accessible/src/base/AccIterator.cpp b/accessible/src/base/AccIterator.cpp index bdf4b7ca3a56..a317820eec33 100644 --- a/accessible/src/base/AccIterator.cpp +++ b/accessible/src/base/AccIterator.cpp @@ -82,7 +82,7 @@ RelatedAccIterator:: { mBindingParent = aDependentContent->GetBindingParent(); nsIAtom* IDAttr = mBindingParent ? - nsGkAtoms::anonid : aDependentContent->GetIDAttributeName(); + nsGkAtoms::anonid : nsGkAtoms::id; nsAutoString id; if (aDependentContent->GetAttr(kNameSpaceID_None, IDAttr, id)) diff --git a/accessible/src/base/nsCoreUtils.cpp b/accessible/src/base/nsCoreUtils.cpp index c0771687faf6..621492037a07 100644 --- a/accessible/src/base/nsCoreUtils.cpp +++ b/accessible/src/base/nsCoreUtils.cpp @@ -456,8 +456,7 @@ nsCoreUtils::IsErrorPage(nsIDocument *aDocument) bool nsCoreUtils::GetID(nsIContent *aContent, nsAString& aID) { - nsIAtom *idAttribute = aContent->GetIDAttributeName(); - return idAttribute ? aContent->GetAttr(kNameSpaceID_None, idAttribute, aID) : false; + return aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::id, aID); } bool diff --git a/accessible/src/generic/Accessible.cpp b/accessible/src/generic/Accessible.cpp index 3d4a11232ba8..f2b64bbe878a 100644 --- a/accessible/src/generic/Accessible.cpp +++ b/accessible/src/generic/Accessible.cpp @@ -1555,7 +1555,7 @@ Accessible::ApplyARIAState(uint64_t* aState) const if (mRoleMapEntry->role != roles::NOTHING) *aState &= ~states::READONLY; - if (mContent->HasAttr(kNameSpaceID_None, mContent->GetIDAttributeName())) { + if (mContent->HasID()) { // If has a role & ID and aria-activedescendant on the container, assume focusable nsIContent *ancestorContent = mContent; while ((ancestorContent = ancestorContent->GetParent()) != nullptr) { diff --git a/content/base/public/Element.h b/content/base/public/Element.h index 5eb59bde5d59..3e58f0e6c989 100644 --- a/content/base/public/Element.h +++ b/content/base/public/Element.h @@ -279,13 +279,6 @@ class Element : public FragmentOrElement virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute, int32_t aModType) const; - /** - * Returns an atom holding the name of the "class" attribute on this - * content node (if applicable). Returns null if there is no - * "class" attribute for this type of content node. - */ - virtual nsIAtom *GetClassAttributeName() const; - inline Directionality GetDirectionality() const { if (HasFlag(NODE_HAS_DIRECTION_RTL)) { return eDir_RTL; @@ -587,8 +580,20 @@ class Element : public FragmentOrElement { SetAttr(kNameSpaceID_None, nsGkAtoms::id, aId, true); } + void GetClassName(nsAString& aClassName) + { + GetAttr(kNameSpaceID_None, nsGkAtoms::_class, aClassName); + } + void GetClassName(DOMString& aClassName) + { + GetAttr(kNameSpaceID_None, nsGkAtoms::_class, aClassName); + } + void SetClassName(const nsAString& aClassName) + { + SetAttr(kNameSpaceID_None, nsGkAtoms::_class, aClassName, true); + } - nsDOMTokenList* GetClassList(); + nsDOMTokenList* ClassList(); nsDOMAttributeMap* Attributes() { nsDOMSlots* slots = DOMSlots(); @@ -862,8 +867,6 @@ class Element : public FragmentOrElement const nsAttrValue* mValue; }; - // Be careful when using this method. This does *NOT* handle - // XUL prototypes. You may want to use GetAttrInfo. const nsAttrValue* GetParsedAttr(nsIAtom* aAttr) const { return mAttrsAndChildren.GetAttr(aAttr); @@ -1128,8 +1131,7 @@ class Element : public FragmentOrElement * Add/remove this element to the documents id cache */ void AddToIdTable(nsIAtom* aId); - void RemoveFromIdTable(); // checks HasID() and uses DoGetID() - void RemoveFromIdTable(nsIAtom* aId); + void RemoveFromIdTable(); /** * Functions to carry out event default actions for links of all types @@ -1364,6 +1366,26 @@ NS_IMETHOD GetTagName(nsAString& aTagName) MOZ_FINAL \ Element::GetTagName(aTagName); \ return NS_OK; \ } \ +NS_IMETHOD GetId(nsAString& aId) MOZ_FINAL \ +{ \ + Element::GetId(aId); \ + return NS_OK; \ +} \ +NS_IMETHOD SetId(const nsAString& aId) MOZ_FINAL \ +{ \ + Element::SetId(aId); \ + return NS_OK; \ +} \ +NS_IMETHOD GetClassName(nsAString& aClassName) MOZ_FINAL \ +{ \ + Element::GetClassName(aClassName); \ + return NS_OK; \ +} \ +NS_IMETHOD SetClassName(const nsAString& aClassName) MOZ_FINAL \ +{ \ + Element::SetClassName(aClassName); \ + return NS_OK; \ +} \ NS_IMETHOD GetClassList(nsISupports** aClassList) MOZ_FINAL \ { \ Element::GetClassList(aClassList); \ diff --git a/content/base/public/FragmentOrElement.h b/content/base/public/FragmentOrElement.h index e73f9b9342f3..0576e992b400 100644 --- a/content/base/public/FragmentOrElement.h +++ b/content/base/public/FragmentOrElement.h @@ -222,7 +222,6 @@ class FragmentOrElement : public nsIContent virtual void DestroyContent() MOZ_OVERRIDE; virtual void SaveSubtreeState() MOZ_OVERRIDE; - virtual const nsAttrValue* DoGetClasses() const MOZ_OVERRIDE; NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker) MOZ_OVERRIDE; nsIHTMLCollection* Children(); diff --git a/content/base/public/nsIContent.h b/content/base/public/nsIContent.h index bed0209ade26..4922f729ca0e 100644 --- a/content/base/public/nsIContent.h +++ b/content/base/public/nsIContent.h @@ -320,13 +320,6 @@ class nsIContent : public nsINode { GetBindingParent(); } - /** - * Returns an atom holding the name of the attribute of type ID on - * this content node (if applicable). Returns null for non-element - * content nodes. - */ - virtual nsIAtom *GetIDAttributeName() const = 0; - /** * Set attribute values. All attribute values are assumed to have a * canonical string representation that can be used for these @@ -831,8 +824,7 @@ class nsIContent : public nsINode { /** * Get the ID of this content node (the atom corresponding to the - * value of the null-namespace attribute whose name is given by - * GetIDAttributeName(). This may be null if there is no ID. + * value of the id attribute). This may be null if there is no ID. */ nsIAtom* GetID() const { if (HasID()) { @@ -843,8 +835,7 @@ class nsIContent : public nsINode { /** * Get the class list of this content node (this corresponds to the - * value of the null-namespace attribute whose name is given by - * GetClassAttributeName()). This may be null if there are no + * value of the class attribute). This may be null if there are no * classes, but that's not guaranteed. */ const nsAttrValue* GetClasses() const { @@ -957,14 +948,14 @@ class nsIContent : public nsINode { * Hook for implementing GetID. This is guaranteed to only be * called if HasID() is true. */ - virtual nsIAtom* DoGetID() const = 0; + nsIAtom* DoGetID() const; private: /** * Hook for implementing GetClasses. This is guaranteed to only be * called if the NODE_MAY_HAVE_CLASS flag is set. */ - virtual const nsAttrValue* DoGetClasses() const = 0; + const nsAttrValue* DoGetClasses() const; public: #ifdef DEBUG diff --git a/content/base/public/nsINodeInfo.h b/content/base/public/nsINodeInfo.h index 53e695b56609..e73bbe1e7a11 100644 --- a/content/base/public/nsINodeInfo.h +++ b/content/base/public/nsINodeInfo.h @@ -160,22 +160,6 @@ class nsINodeInfo : public nsISupports return mInner.mExtraName; } - /* - * Get and set the ID attribute atom for this node. - * See http://www.w3.org/TR/1998/REC-xml-19980210#sec-attribute-types - * for the definition of an ID attribute. - * - */ - nsIAtom* GetIDAttributeAtom() const - { - return mIDAttributeAtom; - } - - void SetIDAttributeAtom(nsIAtom* aID) - { - mIDAttributeAtom = aID; - } - /** * Get the owning node info manager. Only to be used inside Gecko, you can't * really do anything with the pointer outside Gecko anyway. @@ -330,7 +314,6 @@ class nsINodeInfo : public nsISupports nsNodeInfoInner mInner; - nsCOMPtr mIDAttributeAtom; nsRefPtr mOwnerManager; /* diff --git a/content/base/src/Attr.cpp b/content/base/src/Attr.cpp index 76f7f7a79e4d..ecc43cf9cdb1 100644 --- a/content/base/src/Attr.cpp +++ b/content/base/src/Attr.cpp @@ -321,19 +321,7 @@ Attr::SetTextContentInternal(const nsAString& aTextContent, NS_IMETHODIMP Attr::GetIsId(bool* aReturn) { - Element* element = GetElement(); - if (!element) { - *aReturn = false; - return NS_OK; - } - - nsIAtom* idAtom = element->GetIDAttributeName(); - if (!idAtom) { - *aReturn = false; - return NS_OK; - } - - *aReturn = mNodeInfo->Equals(idAtom, kNameSpaceID_None); + *aReturn = mNodeInfo->Equals(nsGkAtoms::id, kNameSpaceID_None); return NS_OK; } diff --git a/content/base/src/DocumentFragment.cpp b/content/base/src/DocumentFragment.cpp index ac185d0aced5..ace0e4c968ad 100644 --- a/content/base/src/DocumentFragment.cpp +++ b/content/base/src/DocumentFragment.cpp @@ -35,18 +35,6 @@ DocumentFragment::IsNodeOfType(uint32_t aFlags) const return !(aFlags & ~(eCONTENT | eDOCUMENT_FRAGMENT)); } -nsIAtom* -DocumentFragment::DoGetID() const -{ - return nullptr; -} - -nsIAtom* -DocumentFragment::GetIDAttributeName() const -{ - return nullptr; -} - NS_IMETHODIMP DocumentFragment::QuerySelector(const nsAString& aSelector, nsIDOMElement **aReturn) diff --git a/content/base/src/DocumentFragment.h b/content/base/src/DocumentFragment.h index 1e4fc9e5ce34..5c932dda3f42 100644 --- a/content/base/src/DocumentFragment.h +++ b/content/base/src/DocumentFragment.h @@ -103,9 +103,6 @@ class DocumentFragment : public FragmentOrElement, virtual nsIDOMNode* AsDOMNode() MOZ_OVERRIDE { return this; } - virtual nsIAtom* DoGetID() const MOZ_OVERRIDE; - virtual nsIAtom *GetIDAttributeName() const MOZ_OVERRIDE; - virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsIContent* aBindingParent, bool aCompileEventHandlers) MOZ_OVERRIDE diff --git a/content/base/src/Element.cpp b/content/base/src/Element.cpp index 707419957de6..a527f0dceb20 100644 --- a/content/base/src/Element.cpp +++ b/content/base/src/Element.cpp @@ -66,6 +66,7 @@ #ifdef MOZ_XUL #include "nsXULElement.h" #endif /* MOZ_XUL */ +#include "nsSVGElement.h" #include "nsFrameManager.h" #include "nsFrameSelection.h" #ifdef DEBUG @@ -138,6 +139,32 @@ using namespace mozilla; using namespace mozilla::dom; +nsIAtom* +nsIContent::DoGetID() const +{ + MOZ_ASSERT(HasID(), "Unexpected call"); + MOZ_ASSERT(IsElement(), "Only elements can have IDs"); + + return AsElement()->GetParsedAttr(nsGkAtoms::id)->GetAtomValue(); +} + +const nsAttrValue* +nsIContent::DoGetClasses() const +{ + MOZ_ASSERT(HasFlag(NODE_MAY_HAVE_CLASS), "Unexpected call"); + MOZ_ASSERT(IsElement(), "Only elements can have classes"); + + if (IsSVG()) { + const nsAttrValue* animClass = + static_cast(this)->GetAnimatedClassName(); + if (animClass) { + return animClass; + } + } + + return AsElement()->GetParsedAttr(nsGkAtoms::_class); +} + NS_IMETHODIMP Element::QueryInterface(REFNSIID aIID, void** aInstancePtr) { @@ -469,15 +496,12 @@ Element::WrapObject(JSContext *aCx) } nsDOMTokenList* -Element::GetClassList() +Element::ClassList() { - Element::nsDOMSlots *slots = DOMSlots(); + Element::nsDOMSlots* slots = DOMSlots(); if (!slots->mClassList) { - nsIAtom* classAttr = GetClassAttributeName(); - if (classAttr) { - slots->mClassList = new nsDOMTokenList(this, classAttr); - } + slots->mClassList = new nsDOMTokenList(this, nsGkAtoms::_class); } return slots->mClassList; @@ -486,7 +510,7 @@ Element::GetClassList() void Element::GetClassList(nsISupports** aClassList) { - NS_IF_ADDREF(*aClassList = GetClassList()); + NS_ADDREF(*aClassList = ClassList()); } already_AddRefed @@ -739,31 +763,22 @@ Element::AddToIdTable(nsIAtom* aId) void Element::RemoveFromIdTable() { - if (HasID()) { - RemoveFromIdTable(DoGetID()); + if (!HasID()) { + return; } -} -void -Element::RemoveFromIdTable(nsIAtom* aId) -{ - NS_ASSERTION(HasID(), "Node doesn't have an ID?"); + nsIAtom* id = DoGetID(); if (HasFlag(NODE_IS_IN_SHADOW_TREE)) { ShadowRoot* containingShadow = GetContainingShadow(); // Check for containingShadow because it may have // been deleted during unlinking. if (containingShadow) { - containingShadow->RemoveFromIdTable(this, aId); + containingShadow->RemoveFromIdTable(this, id); } } else { nsIDocument* doc = GetCurrentDoc(); if (doc && (!IsInAnonymousSubtree() || doc->IsXUL())) { - // id can be null during mutation events evilness. Also, XUL elements - // loose their proto attributes during cc-unlink, so this can happen - // during cc-unlink too. - if (aId) { - doc->RemoveFromIdTable(this, aId); - } + doc->RemoveFromIdTable(this, id); } } } @@ -1573,12 +1588,6 @@ Element::GetAttributeChangeHint(const nsIAtom* aAttribute, return nsChangeHint(0); } -nsIAtom * -Element::GetClassAttributeName() const -{ - return nullptr; -} - bool Element::FindAttributeDependence(const nsIAtom* aAttribute, const MappedAttributeEntry* const aMaps[], @@ -2056,6 +2065,27 @@ Element::ParseAttribute(int32_t aNamespaceID, const nsAString& aValue, nsAttrValue& aResult) { + if (aNamespaceID == kNameSpaceID_None) { + if (aAttribute == nsGkAtoms::_class) { + SetFlags(NODE_MAY_HAVE_CLASS); + aResult.ParseAtomArray(aValue); + return true; + } + if (aAttribute == nsGkAtoms::id) { + // Store id as an atom. id="" means that the element has no id, + // not that it has an emptystring as the id. + RemoveFromIdTable(); + if (aValue.IsEmpty()) { + ClearHasID(); + return false; + } + aResult.ParseAtom(aValue); + SetHasID(); + AddToIdTable(aResult.GetAtomValue()); + return true; + } + } + return false; } @@ -2171,6 +2201,12 @@ Element::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName, // react to unexpected attribute changes. nsMutationGuard::DidMutate(); + if (aName == nsGkAtoms::id && aNameSpaceID == kNameSpaceID_None) { + // Have to do this before clearing flag. See RemoveFromIdTable + RemoveFromIdTable(); + ClearHasID(); + } + bool hadValidDir = false; bool hadDirAuto = false; diff --git a/content/base/src/FragmentOrElement.cpp b/content/base/src/FragmentOrElement.cpp index 0a15e4c3435d..9046ebb80bb3 100644 --- a/content/base/src/FragmentOrElement.cpp +++ b/content/base/src/FragmentOrElement.cpp @@ -886,13 +886,6 @@ nsIContent::IsFocusableInternal(int32_t* aTabIndex, bool aWithMouse) return false; } -const nsAttrValue* -FragmentOrElement::DoGetClasses() const -{ - NS_NOTREACHED("Shouldn't ever be called"); - return nullptr; -} - NS_IMETHODIMP FragmentOrElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker) { diff --git a/content/base/src/nsGenericDOMDataNode.cpp b/content/base/src/nsGenericDOMDataNode.cpp index 58271510d528..db837d9b3a09 100644 --- a/content/base/src/nsGenericDOMDataNode.cpp +++ b/content/base/src/nsGenericDOMDataNode.cpp @@ -590,12 +590,6 @@ nsGenericDOMDataNode::GetChildren(uint32_t aFilter) return nullptr; } -nsIAtom * -nsGenericDOMDataNode::GetIDAttributeName() const -{ - return nullptr; -} - nsresult nsGenericDOMDataNode::SetAttr(int32_t aNameSpaceID, nsIAtom* aAttr, nsIAtom* aPrefix, const nsAString& aValue, @@ -1070,19 +1064,6 @@ nsGenericDOMDataNode::GetCurrentValueAtom() return NS_NewAtom(val); } -nsIAtom* -nsGenericDOMDataNode::DoGetID() const -{ - return nullptr; -} - -const nsAttrValue* -nsGenericDOMDataNode::DoGetClasses() const -{ - NS_NOTREACHED("Shouldn't ever be called"); - return nullptr; -} - NS_IMETHODIMP nsGenericDOMDataNode::WalkContentStyleRules(nsRuleWalker* aRuleWalker) { @@ -1103,12 +1084,6 @@ nsGenericDOMDataNode::GetAttributeChangeHint(const nsIAtom* aAttribute, return nsChangeHint(0); } -nsIAtom* -nsGenericDOMDataNode::GetClassAttributeName() const -{ - return nullptr; -} - size_t nsGenericDOMDataNode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { diff --git a/content/base/src/nsGenericDOMDataNode.h b/content/base/src/nsGenericDOMDataNode.h index 3df7e0eda656..81ecd2abdb05 100644 --- a/content/base/src/nsGenericDOMDataNode.h +++ b/content/base/src/nsGenericDOMDataNode.h @@ -115,7 +115,6 @@ class nsGenericDOMDataNode : public nsIContent virtual already_AddRefed GetChildren(uint32_t aFilter) MOZ_OVERRIDE; - virtual nsIAtom *GetIDAttributeName() const MOZ_OVERRIDE; nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAString& aValue, bool aNotify) @@ -170,13 +169,10 @@ class nsGenericDOMDataNode : public nsIContent virtual mozilla::dom::CustomElementData* GetCustomElementData() const MOZ_OVERRIDE; virtual void SetCustomElementData(mozilla::dom::CustomElementData* aData) MOZ_OVERRIDE; - virtual nsIAtom* DoGetID() const MOZ_OVERRIDE; - virtual const nsAttrValue* DoGetClasses() const MOZ_OVERRIDE; NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker) MOZ_OVERRIDE; NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute, int32_t aModType) const; - virtual nsIAtom *GetClassAttributeName() const; virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE { diff --git a/content/base/src/nsStyledElement.cpp b/content/base/src/nsStyledElement.cpp index 6698157a7a6a..9cb112f9b152 100644 --- a/content/base/src/nsStyledElement.cpp +++ b/content/base/src/nsStyledElement.cpp @@ -28,106 +28,22 @@ using namespace mozilla::dom; //---------------------------------------------------------------------- // nsIContent methods -nsIAtom* -nsStyledElementNotElementCSSInlineStyle::GetClassAttributeName() const -{ - return nsGkAtoms::_class; -} - -nsIAtom* -nsStyledElementNotElementCSSInlineStyle::GetIDAttributeName() const -{ - return nsGkAtoms::id; -} - -nsIAtom* -nsStyledElementNotElementCSSInlineStyle::DoGetID() const -{ - NS_ASSERTION(HasID(), "Unexpected call"); - - // The nullcheck here is needed because Element::UnsetAttr calls - // out to various code between removing the attribute and we get a chance to - // ClearHasID(). - - const nsAttrValue* attr = mAttrsAndChildren.GetAttr(nsGkAtoms::id); - - return attr ? attr->GetAtomValue() : nullptr; -} - -const nsAttrValue* -nsStyledElementNotElementCSSInlineStyle::DoGetClasses() const -{ - NS_ASSERTION(HasFlag(NODE_MAY_HAVE_CLASS), "Unexpected call"); - return mAttrsAndChildren.GetAttr(nsGkAtoms::_class); -} - bool nsStyledElementNotElementCSSInlineStyle::ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult) { - if (aNamespaceID == kNameSpaceID_None) { - if (aAttribute == nsGkAtoms::style) { - SetMayHaveStyle(); - ParseStyleAttribute(aValue, aResult, false); - return true; - } - if (aAttribute == nsGkAtoms::_class) { - SetFlags(NODE_MAY_HAVE_CLASS); - aResult.ParseAtomArray(aValue); - return true; - } - if (aAttribute == nsGkAtoms::id) { - // Store id as an atom. id="" means that the element has no id, - // not that it has an emptystring as the id. - RemoveFromIdTable(); - if (aValue.IsEmpty()) { - ClearHasID(); - return false; - } - aResult.ParseAtom(aValue); - SetHasID(); - AddToIdTable(aResult.GetAtomValue()); - return true; - } + if (aAttribute == nsGkAtoms::style && aNamespaceID == kNameSpaceID_None) { + SetMayHaveStyle(); + ParseStyleAttribute(aValue, aResult, false); + return true; } return nsStyledElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue, aResult); } -nsresult -nsStyledElementNotElementCSSInlineStyle::UnsetAttr(int32_t aNameSpaceID, - nsIAtom* aAttribute, - bool aNotify) -{ - nsAutoScriptBlocker scriptBlocker; - if (aAttribute == nsGkAtoms::id && aNameSpaceID == kNameSpaceID_None) { - // Have to do this before clearing flag. See RemoveFromIdTable - RemoveFromIdTable(); - } - - return Element::UnsetAttr(aNameSpaceID, aAttribute, aNotify); -} - -nsresult -nsStyledElementNotElementCSSInlineStyle::AfterSetAttr(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAttrValue* aValue, - bool aNotify) -{ - if (aNamespaceID == kNameSpaceID_None && !aValue && - aAttribute == nsGkAtoms::id) { - // The id has been removed when calling UnsetAttr but we kept it because - // the id is used for some layout stuff between UnsetAttr and AfterSetAttr. - // Now. the id is really removed so it would not be safe to keep this flag. - ClearHasID(); - } - - return Element::AfterSetAttr(aNamespaceID, aAttribute, aValue, aNotify); -} - nsresult nsStyledElementNotElementCSSInlineStyle::SetInlineStyleRule(css::StyleRule* aStyleRule, const nsAString* aSerialized, diff --git a/content/base/src/nsStyledElement.h b/content/base/src/nsStyledElement.h index 832b986772af..3f381c1da031 100644 --- a/content/base/src/nsStyledElement.h +++ b/content/base/src/nsStyledElement.h @@ -36,21 +36,11 @@ class nsStyledElementNotElementCSSInlineStyle : public nsStyledElementBase public: // nsIContent interface methods - virtual nsIAtom* GetClassAttributeName() const MOZ_OVERRIDE; - virtual nsIAtom* GetIDAttributeName() const MOZ_OVERRIDE; - virtual nsIAtom* DoGetID() const MOZ_OVERRIDE; - virtual const nsAttrValue* DoGetClasses() const MOZ_OVERRIDE; - virtual mozilla::css::StyleRule* GetInlineStyleRule(); virtual nsresult SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule, const nsAString* aSerialized, bool aNotify) MOZ_OVERRIDE; - virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, - bool aNotify) MOZ_OVERRIDE; - virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, - const nsAttrValue* aValue, bool aNotify) MOZ_OVERRIDE; - nsICSSDeclaration* Style(); protected: diff --git a/content/base/test/test_classList.html b/content/base/test/test_classList.html index 981c5dec78dd..3b659586be2a 100644 --- a/content/base/test/test_classList.html +++ b/content/base/test/test_classList.html @@ -412,16 +412,13 @@ content.appendChild(mathMLNode); testClassList(mathMLNode); -// Nodes not meant to be styled have a null classList property. - var xmlNode = document.createElementNS(null, "foo"); content.appendChild(xmlNode); -is(xmlNode.classList, null, "classList is not null for plain XML nodes"); +testClassList(xmlNode); var fooNode = document.createElementNS("http://example.org/foo", "foo"); content.appendChild(fooNode); -is(fooNode.classList, null, "classList is not null for nodes in " + - " http://example.org/foo namespace"); +testClassList(fooNode); diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index 92a7d9d944da..273863ad5670 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -255,14 +255,6 @@ class nsGenericHTMLElement : public nsGenericHTMLElementBase, #undef ERROR_EVENT #undef FORWARDED_EVENT #undef EVENT - void GetClassName(mozilla::dom::DOMString& aClassName) - { - GetAttr(kNameSpaceID_None, nsGkAtoms::_class, aClassName); - } - void SetClassName(const nsAString& aClassName) - { - SetAttr(kNameSpaceID_None, nsGkAtoms::_class, aClassName, true); - } mozilla::dom::Element* GetOffsetParent() { mozilla::CSSIntRect rcFrame; @@ -321,14 +313,6 @@ class nsGenericHTMLElement : public nsGenericHTMLElementBase, NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_IMETHOD GetId(nsAString& aId) MOZ_FINAL { - mozilla::dom::Element::GetId(aId); - return NS_OK; - } - NS_IMETHOD SetId(const nsAString& aId) MOZ_FINAL { - mozilla::dom::Element::SetId(aId); - return NS_OK; - } NS_IMETHOD GetTitle(nsAString& aTitle) MOZ_FINAL { nsString title; GetTitle(title); diff --git a/content/html/document/src/ImageDocument.cpp b/content/html/document/src/ImageDocument.cpp index f8f57f5ddc98..0a60f8d72b55 100644 --- a/content/html/document/src/ImageDocument.cpp +++ b/content/html/document/src/ImageDocument.cpp @@ -459,7 +459,7 @@ ImageDocument::Notify(imgIRequest* aRequest, int32_t aType, const nsIntRect* aDa return OnStartContainer(aRequest, image); } - nsDOMTokenList* classList = mImageContent->AsElement()->GetClassList(); + nsDOMTokenList* classList = mImageContent->AsElement()->ClassList(); mozilla::ErrorResult rv; if (aType == imgINotificationObserver::DECODE_COMPLETE) { if (mImageContent && !nsContentUtils::IsChildOfSameType(this)) { @@ -494,7 +494,7 @@ ImageDocument::Notify(imgIRequest* aRequest, int32_t aType, const nsIntRect* aDa void ImageDocument::SetModeClass(eModeClasses mode) { - nsDOMTokenList* classList = mImageContent->AsElement()->GetClassList(); + nsDOMTokenList* classList = mImageContent->AsElement()->ClassList(); mozilla::ErrorResult rv; if (mode == eShrinkToFit) { diff --git a/content/mathml/content/src/nsMathMLElementFactory.cpp b/content/mathml/content/src/nsMathMLElementFactory.cpp index e4fec647263b..4b4c978b6d4c 100644 --- a/content/mathml/content/src/nsMathMLElementFactory.cpp +++ b/content/mathml/content/src/nsMathMLElementFactory.cpp @@ -13,11 +13,6 @@ using namespace mozilla::dom; nsresult NS_NewMathMLElement(Element** aResult, already_AddRefed&& aNodeInfo) { - nsCOMPtr ni = aNodeInfo; - ni->SetIDAttributeAtom(nsGkAtoms::id); - - nsMathMLElement* it = new nsMathMLElement(ni.forget()); - - NS_ADDREF(*aResult = it); + NS_ADDREF(*aResult = new nsMathMLElement(aNodeInfo)); return NS_OK; } diff --git a/content/svg/content/src/nsSVGElement.cpp b/content/svg/content/src/nsSVGElement.cpp index 23e923230c59..eaeddd37c48d 100644 --- a/content/svg/content/src/nsSVGElement.cpp +++ b/content/svg/content/src/nsSVGElement.cpp @@ -99,7 +99,7 @@ nsSVGElement::WrapNode(JSContext *aCx) /* readonly attribute SVGAnimatedString className; */ NS_IMETHODIMP -nsSVGElement::GetClassName(nsISupports** aClassName) +nsSVGElement::GetSVGClassName(nsISupports** aClassName) { *aClassName = ClassName().take(); return NS_OK; @@ -240,15 +240,6 @@ NS_IMPL_ISUPPORTS_INHERITED(nsSVGElement, nsSVGElementBase, //---------------------------------------------------------------------- // nsIContent methods -const nsAttrValue* -nsSVGElement::DoGetClasses() const -{ - if (mClassAttribute.IsAnimated()) { - return mClassAnimAttr; - } - return nsSVGElementBase::DoGetClasses(); -} - nsresult nsSVGElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsIContent* aBindingParent, @@ -1095,19 +1086,6 @@ nsSVGElement::sMaskMap[] = { //---------------------------------------------------------------------- // nsIDOMSVGElement methods -/* attribute DOMString id; */ -NS_IMETHODIMP nsSVGElement::GetId(nsAString & aId) -{ - GetAttr(kNameSpaceID_None, nsGkAtoms::id, aId); - - return NS_OK; -} - -NS_IMETHODIMP nsSVGElement::SetId(const nsAString & aId) -{ - return SetAttr(kNameSpaceID_None, nsGkAtoms::id, aId, true); -} - /* readonly attribute nsIDOMSVGSVGElement ownerSVGElement; */ NS_IMETHODIMP nsSVGElement::GetOwnerSVGElement(nsIDOMSVGElement * *aOwnerSVGElement) diff --git a/content/svg/content/src/nsSVGElement.h b/content/svg/content/src/nsSVGElement.h index bc72a134db8a..88c4430640aa 100644 --- a/content/svg/content/src/nsSVGElement.h +++ b/content/svg/content/src/nsSVGElement.h @@ -96,7 +96,6 @@ class nsSVGElement : public nsSVGElementBase // nsIContent // nsISupports NS_DECL_ISUPPORTS_INHERITED - virtual const nsAttrValue* DoGetClasses() const MOZ_OVERRIDE; void DidAnimateClass(); // nsIContent interface methods @@ -305,6 +304,13 @@ class nsSVGElement : public nsSVGElementBase // nsIContent virtual nsIAtom* GetTransformListAttrName() const { return nullptr; } + const nsAttrValue* GetAnimatedClassName() const + { + if (!mClassAttribute.IsAnimated()) { + return nullptr; + } + return mClassAnimAttr; + } virtual nsIDOMNode* AsDOMNode() MOZ_FINAL MOZ_OVERRIDE { return this; } virtual bool IsTransformable() { return false; } diff --git a/content/xml/content/src/nsXMLElement.cpp b/content/xml/content/src/nsXMLElement.cpp index 1fa15a97e3f8..1ef2fe9366ed 100644 --- a/content/xml/content/src/nsXMLElement.cpp +++ b/content/xml/content/src/nsXMLElement.cpp @@ -29,107 +29,3 @@ nsXMLElement::WrapNode(JSContext *aCx) } NS_IMPL_ELEMENT_CLONE(nsXMLElement) - -nsresult -nsXMLElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, - bool aNotify) -{ - nsAutoScriptBlocker scriptBlocker; - bool isId = false; - if (aAttribute == GetIDAttributeName() && - aNameSpaceID == kNameSpaceID_None) { - // Have to do this before clearing flag. See RemoveFromIdTable - RemoveFromIdTable(); - isId = true; - } - - nsMutationGuard guard; - - nsresult rv = Element::UnsetAttr(aNameSpaceID, aAttribute, aNotify); - - if (isId && - (!guard.Mutated(0) || - !mNodeInfo->GetIDAttributeAtom() || - !HasAttr(kNameSpaceID_None, GetIDAttributeName()))) { - ClearHasID(); - } - - return rv; -} - -nsIAtom * -nsXMLElement::GetIDAttributeName() const -{ - return mNodeInfo->GetIDAttributeAtom(); -} - -nsIAtom* -nsXMLElement::DoGetID() const -{ - NS_ASSERTION(HasID(), "Unexpected call"); - - const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(GetIDAttributeName()); - return attrVal ? attrVal->GetAtomValue() : nullptr; -} - -void -nsXMLElement::NodeInfoChanged(nsINodeInfo* aOldNodeInfo) -{ - NS_ASSERTION(!IsInDoc() || - aOldNodeInfo->GetDocument() == mNodeInfo->GetDocument(), - "Can only change document if we're not inside one"); - nsIDocument* doc = GetCurrentDoc(); - - if (HasID() && doc) { - const nsAttrValue* attrVal = - mAttrsAndChildren.GetAttr(aOldNodeInfo->GetIDAttributeAtom()); - if (attrVal) { - RemoveFromIdTable(attrVal->GetAtomValue()); - } - } - - ClearHasID(); - - nsIAtom* IDName = GetIDAttributeName(); - if (IDName) { - const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(IDName); - if (attrVal) { - SetHasID(); - if (attrVal->Type() == nsAttrValue::eString) { - nsString idVal(attrVal->GetStringValue()); - - // Create an atom from the value and set it into the attribute list. - const_cast(attrVal)->ParseAtom(idVal); - } - NS_ASSERTION(attrVal->Type() == nsAttrValue::eAtom, - "Should be atom by now"); - if (doc) { - AddToIdTable(attrVal->GetAtomValue()); - } - } - } -} - -bool -nsXMLElement::ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) -{ - if (aAttribute == GetIDAttributeName() && - aNamespaceID == kNameSpaceID_None) { - // Store id as an atom. id="" means that the element has no id, - // not that it has an emptystring as the id. - RemoveFromIdTable(); - if (aValue.IsEmpty()) { - ClearHasID(); - return false; - } - aResult.ParseAtom(aValue); - SetHasID(); - AddToIdTable(aResult.GetAtomValue()); - return true; - } - - return false; -} diff --git a/content/xml/content/src/nsXMLElement.h b/content/xml/content/src/nsXMLElement.h index da7d789d9dac..ebfb4a8780b6 100644 --- a/content/xml/content/src/nsXMLElement.h +++ b/content/xml/content/src/nsXMLElement.h @@ -34,19 +34,6 @@ class nsXMLElement : public mozilla::dom::Element, virtual nsIDOMNode* AsDOMNode() MOZ_OVERRIDE { return this; } - // nsIContent interface methods - virtual nsIAtom *GetIDAttributeName() const MOZ_OVERRIDE; - virtual nsIAtom* DoGetID() const MOZ_OVERRIDE; - virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, - bool aNotify) MOZ_OVERRIDE; - virtual bool ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) MOZ_OVERRIDE; - - // Element overrides - virtual void NodeInfoChanged(nsINodeInfo* aOldNodeInfo) MOZ_OVERRIDE; - protected: virtual JSObject* WrapNode(JSContext *aCx) MOZ_OVERRIDE; }; diff --git a/content/xml/document/src/nsXMLContentSink.cpp b/content/xml/document/src/nsXMLContentSink.cpp index d21971d8c0f7..db85b3fb1da0 100644 --- a/content/xml/document/src/nsXMLContentSink.cpp +++ b/content/xml/document/src/nsXMLContentSink.cpp @@ -937,10 +937,9 @@ NS_IMETHODIMP nsXMLContentSink::HandleStartElement(const char16_t *aName, const char16_t **aAtts, uint32_t aAttsCount, - int32_t aIndex, uint32_t aLineNumber) { - return HandleStartElement(aName, aAtts, aAttsCount, aIndex, aLineNumber, + return HandleStartElement(aName, aAtts, aAttsCount, aLineNumber, true); } @@ -948,11 +947,9 @@ nsresult nsXMLContentSink::HandleStartElement(const char16_t *aName, const char16_t **aAtts, uint32_t aAttsCount, - int32_t aIndex, uint32_t aLineNumber, bool aInterruptable) { - NS_PRECONDITION(aIndex >= -1, "Bogus aIndex"); NS_PRECONDITION(aAttsCount % 2 == 0, "incorrect aAttsCount"); // Adjust aAttsCount so it's the actual number of attributes aAttsCount /= 2; @@ -998,17 +995,6 @@ nsXMLContentSink::HandleStartElement(const char16_t *aName, result = PushContent(content); NS_ENSURE_SUCCESS(result, result); - // Set the ID attribute atom on the node info object for this node - // This must occur before the attributes are added so the name - // of the id attribute is known. - if (aIndex != -1 && NS_SUCCEEDED(result)) { - nsCOMPtr IDAttr = do_GetAtom(aAtts[aIndex]); - - if (IDAttr) { - nodeInfo->SetIDAttributeAtom(IDAttr); - } - } - // Set the attributes on the new content element result = AddAttributes(aAtts, content); @@ -1384,7 +1370,7 @@ nsXMLContentSink::ReportError(const char16_t* aErrorText, parsererror.Append((char16_t)0xFFFF); parsererror.AppendLiteral("parsererror"); - rv = HandleStartElement(parsererror.get(), noAtts, 0, -1, (uint32_t)-1, + rv = HandleStartElement(parsererror.get(), noAtts, 0, (uint32_t)-1, false); NS_ENSURE_SUCCESS(rv, rv); @@ -1395,7 +1381,7 @@ nsXMLContentSink::ReportError(const char16_t* aErrorText, sourcetext.Append((char16_t)0xFFFF); sourcetext.AppendLiteral("sourcetext"); - rv = HandleStartElement(sourcetext.get(), noAtts, 0, -1, (uint32_t)-1, + rv = HandleStartElement(sourcetext.get(), noAtts, 0, (uint32_t)-1, false); NS_ENSURE_SUCCESS(rv, rv); diff --git a/content/xml/document/src/nsXMLContentSink.h b/content/xml/document/src/nsXMLContentSink.h index 126ad168199c..a5c5e45f00e0 100644 --- a/content/xml/document/src/nsXMLContentSink.h +++ b/content/xml/document/src/nsXMLContentSink.h @@ -157,8 +157,7 @@ class nsXMLContentSink : public nsContentSink, bool IsMonolithicContainer(nsINodeInfo* aNodeInfo); nsresult HandleStartElement(const char16_t *aName, const char16_t **aAtts, - uint32_t aAttsCount, int32_t aIndex, - uint32_t aLineNumber, + uint32_t aAttsCount, uint32_t aLineNumber, bool aInterruptable); nsresult HandleEndElement(const char16_t *aName, bool aInterruptable); nsresult HandleCharacterData(const char16_t *aData, uint32_t aLength, diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index c1eac141beeb..79b0aa14d301 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -336,6 +336,12 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXULElement, } NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXULElement, + nsStyledElement) + // Why aren't we unlinking the prototype? + tmp->ClearHasID(); +NS_IMPL_CYCLE_COLLECTION_UNLINK_END + NS_IMPL_ADDREF_INHERITED(nsXULElement, nsStyledElement) NS_IMPL_RELEASE_INHERITED(nsXULElement, nsStyledElement) @@ -1503,7 +1509,6 @@ nsXULElement::GetBoxObject(ErrorResult& rv) } -NS_IMPL_XUL_STRING_ATTR(ClassName, _class) NS_IMPL_XUL_STRING_ATTR(Align, align) NS_IMPL_XUL_STRING_ATTR(Dir, dir) NS_IMPL_XUL_STRING_ATTR(Flex, flex) diff --git a/content/xul/content/src/nsXULElement.h b/content/xul/content/src/nsXULElement.h index 62307e1cda68..e506899e7898 100644 --- a/content/xul/content/src/nsXULElement.h +++ b/content/xul/content/src/nsXULElement.h @@ -379,8 +379,7 @@ class nsXULElement MOZ_FINAL : public nsStyledElement, // nsISupports NS_DECL_ISUPPORTS_INHERITED - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsXULElement, - mozilla::dom::Element) + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsXULElement, nsStyledElement) // nsINode virtual nsresult PreHandleEvent( diff --git a/content/xul/document/src/XULDocument.cpp b/content/xul/document/src/XULDocument.cpp index b6b882bd03e0..0b1aec6cfd3c 100644 --- a/content/xul/document/src/XULDocument.cpp +++ b/content/xul/document/src/XULDocument.cpp @@ -966,8 +966,7 @@ XULDocument::AttributeWillChange(nsIDocument* aDocument, // XXXbz check aNameSpaceID, dammit! // See if we need to update our ref map. - if (aAttribute == nsGkAtoms::ref || - (aAttribute == nsGkAtoms::id && !aElement->GetIDAttributeName())) { + if (aAttribute == nsGkAtoms::ref) { // Might not need this, but be safe for now. nsCOMPtr kungFuDeathGrip(this); RemoveElementFromRefMap(aElement); @@ -986,8 +985,7 @@ XULDocument::AttributeChanged(nsIDocument* aDocument, // XXXbz check aNameSpaceID, dammit! // See if we need to update our ref map. - if (aAttribute == nsGkAtoms::ref || - (aAttribute == nsGkAtoms::id && !aElement->GetIDAttributeName())) { + if (aAttribute == nsGkAtoms::ref) { AddElementToRefMap(aElement); } @@ -1927,9 +1925,6 @@ static void GetRefMapAttribute(Element* aElement, nsAutoString* aValue) { aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::ref, *aValue); - if (aValue->IsEmpty() && !aElement->GetIDAttributeName()) { - aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::id, *aValue); - } } nsresult diff --git a/content/xul/document/src/nsXULContentSink.cpp b/content/xul/document/src/nsXULContentSink.cpp index 804a38a5c4cd..fc68b984c0c1 100644 --- a/content/xul/document/src/nsXULContentSink.cpp +++ b/content/xul/document/src/nsXULContentSink.cpp @@ -456,13 +456,11 @@ NS_IMETHODIMP XULContentSinkImpl::HandleStartElement(const char16_t *aName, const char16_t **aAtts, uint32_t aAttsCount, - int32_t aIndex, uint32_t aLineNumber) { // XXX Hopefully the parser will flag this before we get here. If // we're in the epilog, there should be no new elements NS_PRECONDITION(mState != eInEpilog, "tag in XUL doc epilog"); - NS_PRECONDITION(aIndex >= -1, "Bogus aIndex"); NS_PRECONDITION(aAttsCount % 2 == 0, "incorrect aAttsCount"); // Adjust aAttsCount so it's the actual number of attributes aAttsCount /= 2; @@ -503,15 +501,6 @@ XULContentSinkImpl::HandleStartElement(const char16_t *aName, break; } - // Set the ID attribute atom on the node info object for this node - if (aIndex != -1 && NS_SUCCEEDED(rv)) { - nsCOMPtr IDAttr = do_GetAtom(aAtts[aIndex]); - - if (IDAttr) { - nodeInfo->SetIDAttributeAtom(IDAttr); - } - } - return rv; } @@ -721,7 +710,7 @@ XULContentSinkImpl::ReportError(const char16_t* aErrorText, parsererror.Append((char16_t)0xFFFF); parsererror.AppendLiteral("parsererror"); - rv = HandleStartElement(parsererror.get(), noAtts, 0, -1, 0); + rv = HandleStartElement(parsererror.get(), noAtts, 0, 0); NS_ENSURE_SUCCESS(rv,rv); rv = HandleCharacterData(aErrorText, NS_strlen(aErrorText)); @@ -731,7 +720,7 @@ XULContentSinkImpl::ReportError(const char16_t* aErrorText, sourcetext.Append((char16_t)0xFFFF); sourcetext.AppendLiteral("sourcetext"); - rv = HandleStartElement(sourcetext.get(), noAtts, 0, -1, 0); + rv = HandleStartElement(sourcetext.get(), noAtts, 0, 0); NS_ENSURE_SUCCESS(rv,rv); rv = HandleCharacterData(aSourceText, NS_strlen(aSourceText)); diff --git a/dom/imptests/failures/html/dom/nodes/test_Node-properties.html.json b/dom/imptests/failures/html/dom/nodes/test_Node-properties.html.json index 2f99d6512b8c..8c7b35264d9f 100644 --- a/dom/imptests/failures/html/dom/nodes/test_Node-properties.html.json +++ b/dom/imptests/failures/html/dom/nodes/test_Node-properties.html.json @@ -3,7 +3,5 @@ "foreignDoc.characterSet": true, "xmlDoc.characterSet": true, "xmlElement.namespaceURI": true, - "xmlElement.className": true, - "detachedXmlElement.namespaceURI": true, - "detachedXmlElement.className": true + "detachedXmlElement.namespaceURI": true } diff --git a/dom/imptests/failures/html/dom/test_interfaces.html.json b/dom/imptests/failures/html/dom/test_interfaces.html.json index cf7880ee4086..830faf148b3b 100644 --- a/dom/imptests/failures/html/dom/test_interfaces.html.json +++ b/dom/imptests/failures/html/dom/test_interfaces.html.json @@ -35,13 +35,11 @@ "Element interface: attribute namespaceURI": true, "Element interface: attribute prefix": true, "Element interface: attribute localName": true, - "Element interface: attribute className": true, "Element interface: operation prepend([object Object],[object Object])": true, "Element interface: operation append([object Object],[object Object])": true, "Element interface: operation before([object Object],[object Object])": true, "Element interface: operation after([object Object],[object Object])": true, "Element interface: operation replace([object Object],[object Object])": true, - "Element interface: element must inherit property \"className\" with the proper type (5)": true, "Element interface: element must inherit property \"prepend\" with the proper type (23)": true, "Element interface: calling prepend([object Object],[object Object]) on element with too few arguments must throw TypeError": true, "Element interface: element must inherit property \"append\" with the proper type (24)": true, diff --git a/dom/interfaces/core/nsIDOMElement.idl b/dom/interfaces/core/nsIDOMElement.idl index 08f8c966654b..7bbc73c1e4b7 100644 --- a/dom/interfaces/core/nsIDOMElement.idl +++ b/dom/interfaces/core/nsIDOMElement.idl @@ -20,6 +20,8 @@ interface nsIDOMElement : nsIDOMNode { readonly attribute DOMString tagName; + attribute DOMString id; + attribute DOMString className; /** * Returns a DOMTokenList object reflecting the class attribute. */ diff --git a/dom/interfaces/html/nsIDOMHTMLElement.idl b/dom/interfaces/html/nsIDOMHTMLElement.idl index 8badbe446c16..f2caf94ef9e0 100644 --- a/dom/interfaces/html/nsIDOMHTMLElement.idl +++ b/dom/interfaces/html/nsIDOMHTMLElement.idl @@ -23,12 +23,9 @@ interface nsIDOMHTMLMenuElement; interface nsIDOMHTMLElement : nsIDOMElement { // metadata attributes - attribute DOMString id; attribute DOMString title; attribute DOMString lang; attribute DOMString dir; - [binaryname(DOMClassName)] - attribute DOMString className; readonly attribute nsISupports dataset; attribute boolean itemScope; diff --git a/dom/interfaces/svg/nsIDOMSVGElement.idl b/dom/interfaces/svg/nsIDOMSVGElement.idl index 0c740ddccc41..5cb7fa6608d1 100644 --- a/dom/interfaces/svg/nsIDOMSVGElement.idl +++ b/dom/interfaces/svg/nsIDOMSVGElement.idl @@ -12,11 +12,11 @@ interface nsIDOMCSSValue; [uuid(abdf347a-0063-42cc-b6fc-c9a19a65248e)] interface nsIDOMSVGElement : nsIDOMElement { - attribute DOMString id; // raises DOMException on setting readonly attribute nsIDOMSVGElement ownerSVGElement; readonly attribute nsIDOMSVGElement viewportElement; + [binaryname(SVGClassName)] readonly attribute nsISupports className; readonly attribute nsIDOMCSSStyleDeclaration style; }; diff --git a/dom/interfaces/xul/nsIDOMXULElement.idl b/dom/interfaces/xul/nsIDOMXULElement.idl index 86a8acc25726..16d516fd4da0 100644 --- a/dom/interfaces/xul/nsIDOMXULElement.idl +++ b/dom/interfaces/xul/nsIDOMXULElement.idl @@ -15,8 +15,6 @@ interface nsIBoxObject; [uuid(e89578c8-64ec-4047-984a-cce1b1735543)] interface nsIDOMXULElement : nsIDOMElement { - attribute DOMString className; - // Layout properties attribute DOMString align; attribute DOMString dir; diff --git a/dom/smil/test/test_smilValues.xhtml b/dom/smil/test/test_smilValues.xhtml index a656e08dc9cb..37a4a05cb509 100644 --- a/dom/smil/test/test_smilValues.xhtml +++ b/dom/smil/test/test_smilValues.xhtml @@ -159,6 +159,7 @@ function checkSample(anim, expectedValue, sampleTime, caseNum) " (values: '" + anim.getAttribute('values') + "')," + "t=" + sampleTime + ": Unexpected sample value:"; + is(typeof anim.targetElement.className, "object"); is(anim.targetElement.className.animVal, expectedValue, msg); } diff --git a/dom/webidl/Element.webidl b/dom/webidl/Element.webidl index 005207aa3114..d48af43acfca 100644 --- a/dom/webidl/Element.webidl +++ b/dom/webidl/Element.webidl @@ -28,12 +28,10 @@ interface Element : Node { [Pure] attribute DOMString id; -/* - FIXME Bug 810677 Move className from HTMLElement to Element + [Pure] attribute DOMString className; -*/ [Constant] - readonly attribute DOMTokenList? classList; + readonly attribute DOMTokenList classList; [SameObject] readonly attribute MozNamedAttrMap attributes; diff --git a/dom/xbl/nsXBLContentSink.cpp b/dom/xbl/nsXBLContentSink.cpp index b285332f197c..61eac4fbce31 100644 --- a/dom/xbl/nsXBLContentSink.cpp +++ b/dom/xbl/nsXBLContentSink.cpp @@ -251,10 +251,10 @@ NS_IMETHODIMP nsXBLContentSink::HandleStartElement(const char16_t *aName, const char16_t **aAtts, uint32_t aAttsCount, - int32_t aIndex, uint32_t aLineNumber) { - nsresult rv = nsXMLContentSink::HandleStartElement(aName,aAtts,aAttsCount,aIndex,aLineNumber); + nsresult rv = nsXMLContentSink::HandleStartElement(aName, aAtts, aAttsCount, + aLineNumber); if (NS_FAILED(rv)) return rv; diff --git a/dom/xbl/nsXBLContentSink.h b/dom/xbl/nsXBLContentSink.h index 37d46fadadc5..30419ff17c8c 100644 --- a/dom/xbl/nsXBLContentSink.h +++ b/dom/xbl/nsXBLContentSink.h @@ -69,7 +69,6 @@ class nsXBLContentSink : public nsXMLContentSink { NS_IMETHOD HandleStartElement(const char16_t *aName, const char16_t **aAtts, uint32_t aAttsCount, - int32_t aIndex, uint32_t aLineNumber) MOZ_OVERRIDE; NS_IMETHOD HandleEndElement(const char16_t *aName) MOZ_OVERRIDE; diff --git a/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp b/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp index 18a3eb522da9..9ce956d8d3b5 100644 --- a/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp +++ b/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp @@ -118,13 +118,12 @@ NS_IMETHODIMP txStylesheetSink::HandleStartElement(const char16_t *aName, const char16_t **aAtts, uint32_t aAttsCount, - int32_t aIndex, uint32_t aLineNumber) { NS_PRECONDITION(aAttsCount % 2 == 0, "incorrect aAttsCount"); nsresult rv = - mCompiler->startElement(aName, aAtts, aAttsCount / 2, aIndex); + mCompiler->startElement(aName, aAtts, aAttsCount / 2); if (NS_FAILED(rv)) { mCompiler->cancel(rv); diff --git a/dom/xslt/xslt/txStylesheetCompiler.cpp b/dom/xslt/xslt/txStylesheetCompiler.cpp index b53e9ee0d533..6535ea38b6d2 100644 --- a/dom/xslt/xslt/txStylesheetCompiler.cpp +++ b/dom/xslt/xslt/txStylesheetCompiler.cpp @@ -103,7 +103,7 @@ txStylesheetCompiler::startElement(int32_t aNamespaceID, nsIAtom* aLocalName, nsresult txStylesheetCompiler::startElement(const char16_t *aName, const char16_t **aAttrs, - int32_t aAttrCount, int32_t aIDOffset) + int32_t aAttrCount) { if (NS_FAILED(mStatus)) { // ignore content after failure @@ -162,12 +162,8 @@ txStylesheetCompiler::startElement(const char16_t *aName, getter_AddRefs(localname), &namespaceID); NS_ENSURE_SUCCESS(rv, rv); - int32_t idOffset = aIDOffset; - if (idOffset > 0) { - idOffset /= 2; - } return startElementInternal(namespaceID, localname, prefix, atts, - aAttrCount, idOffset); + aAttrCount); } nsresult @@ -175,8 +171,7 @@ txStylesheetCompiler::startElementInternal(int32_t aNamespaceID, nsIAtom* aLocalName, nsIAtom* aPrefix, txStylesheetAttr* aAttributes, - int32_t aAttrCount, - int32_t aIDOffset) + int32_t aAttrCount) { nsresult rv = NS_OK; int32_t i; @@ -188,6 +183,16 @@ txStylesheetCompiler::startElementInternal(int32_t aNamespaceID, for (i = 0; i < aAttrCount; ++i) { txStylesheetAttr* attr = aAttributes + i; + // id + if (mEmbedStatus == eNeedEmbed && + attr->mLocalName == nsGkAtoms::id && + attr->mNamespaceID == kNameSpaceID_None && + attr->mValue.Equals(mTarget)) { + // We found the right ID, signal to compile the + // embedded stylesheet. + mEmbedStatus = eInEmbed; + } + // xml:space if (attr->mNamespaceID == kNameSpaceID_XML && attr->mLocalName == nsGkAtoms::space) { @@ -277,14 +282,6 @@ txStylesheetCompiler::startElementInternal(int32_t aNamespaceID, } } - if (mEmbedStatus == eNeedEmbed) { - // handle embedded stylesheets - if (aIDOffset >= 0 && aAttributes[aIDOffset].mValue.Equals(mTarget)) { - // We found the right ID, signal to compile the - // embedded stylesheet. - mEmbedStatus = eInEmbed; - } - } const txElementHandler* handler; do { handler = isInstruction ? diff --git a/dom/xslt/xslt/txStylesheetCompiler.h b/dom/xslt/xslt/txStylesheetCompiler.h index ac385e6b24aa..aa7d6cce6b7b 100644 --- a/dom/xslt/xslt/txStylesheetCompiler.h +++ b/dom/xslt/xslt/txStylesheetCompiler.h @@ -202,7 +202,7 @@ class txStylesheetCompiler MOZ_FINAL : private txStylesheetCompilerState, int32_t aAttrCount); nsresult startElement(const char16_t *aName, const char16_t **aAtts, - int32_t aAttrCount, int32_t aIDOffset); + int32_t aAttrCount); nsresult endElement(); nsresult characters(const nsAString& aStr); nsresult doneLoading(); @@ -224,8 +224,7 @@ class txStylesheetCompiler MOZ_FINAL : private txStylesheetCompilerState, nsresult startElementInternal(int32_t aNamespaceID, nsIAtom* aLocalName, nsIAtom* aPrefix, txStylesheetAttr* aAttributes, - int32_t aAttrCount, - int32_t aIDOffset = -1); + int32_t aAttrCount); nsresult flushCharacters(); nsresult ensureNewElementContext(); diff --git a/layout/reftests/bugs/495354-1a.xhtml b/layout/reftests/bugs/495354-1a.xhtml index 085754d06f1e..cc5bb9423e5b 100644 --- a/layout/reftests/bugs/495354-1a.xhtml +++ b/layout/reftests/bugs/495354-1a.xhtml @@ -2,7 +2,7 @@ - -
123
+ +
123
diff --git a/layout/reftests/bugs/495354-1b.xhtml b/layout/reftests/bugs/495354-1b.xhtml index f0ff0c929e80..0d7a14bd40c1 100644 --- a/layout/reftests/bugs/495354-1b.xhtml +++ b/layout/reftests/bugs/495354-1b.xhtml @@ -2,7 +2,7 @@ - -
123
+ +
123
diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index c65852352447..f0ab036add57 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -2754,7 +2754,7 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData // rules we might stop matching; if the after change notification, the // ones we might have started matching. if (cascade) { - if (aData->mAttribute == aData->mElement->GetIDAttributeName()) { + if (aData->mAttribute == nsGkAtoms::id) { nsIAtom* id = aData->mElement->GetID(); if (id) { AtomSelectorEntry *entry = @@ -2769,7 +2769,7 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData EnumerateSelectors(cascade->mPossiblyNegatedIDSelectors, &data); } - if (aData->mAttribute == aData->mElement->GetClassAttributeName()) { + if (aData->mAttribute == nsGkAtoms::_class) { const nsAttrValue* elementClasses = aData->mElement->GetClasses(); if (elementClasses) { int32_t atomCount = elementClasses->GetAtomCount(); diff --git a/parser/htmlparser/public/nsIExpatSink.idl b/parser/htmlparser/public/nsIExpatSink.idl index 74bc9c33d08a..43500b0e0118 100644 --- a/parser/htmlparser/public/nsIExpatSink.idl +++ b/parser/htmlparser/public/nsIExpatSink.idl @@ -27,15 +27,11 @@ interface nsIExpatSink : nsISupports * and attributes that are defined to have default values in a DTD are * present in aAtts. * @param aAttsCount the number of elements in aAtts. - * @param aIndex If the element has an attribute of type ID, then - * aAtts[aIndex] is the name of that attribute. Otherwise, aIndex - * is -1 * @param aLineNumber the line number of the start tag in the data stream. */ void HandleStartElement(in wstring aName, [array, size_is(aAttsCount)] in wstring aAtts, in unsigned long aAttsCount, - in long aIndex, in unsigned long aLineNumber); /** diff --git a/parser/htmlparser/src/nsExpatDriver.cpp b/parser/htmlparser/src/nsExpatDriver.cpp index f9a013bad1e0..eb839a62fc71 100644 --- a/parser/htmlparser/src/nsExpatDriver.cpp +++ b/parser/htmlparser/src/nsExpatDriver.cpp @@ -381,7 +381,6 @@ nsExpatDriver::HandleStartElement(const char16_t *aValue, if (mSink) { nsresult rv = mSink-> HandleStartElement(aValue, aAtts, attrArrayLength, - XML_GetIdAttributeIndex(mExpatParser), XML_GetCurrentLineNumber(mExpatParser)); MaybeStopParser(rv); } diff --git a/parser/xml/src/nsSAXXMLReader.cpp b/parser/xml/src/nsSAXXMLReader.cpp index 727ab707e453..049cb6c12601 100644 --- a/parser/xml/src/nsSAXXMLReader.cpp +++ b/parser/xml/src/nsSAXXMLReader.cpp @@ -81,7 +81,6 @@ NS_IMETHODIMP nsSAXXMLReader::HandleStartElement(const char16_t *aName, const char16_t **aAtts, uint32_t aAttsCount, - int32_t aIndex, uint32_t aLineNumber) { if (!mContentHandler) diff --git a/rdf/base/src/nsRDFContentSink.cpp b/rdf/base/src/nsRDFContentSink.cpp index c45c8e41b459..f58b596b751a 100644 --- a/rdf/base/src/nsRDFContentSink.cpp +++ b/rdf/base/src/nsRDFContentSink.cpp @@ -397,7 +397,6 @@ NS_IMETHODIMP RDFContentSinkImpl::HandleStartElement(const char16_t *aName, const char16_t **aAtts, uint32_t aAttsCount, - int32_t aIndex, uint32_t aLineNumber) { FlushText();