Bug 998590 - Cleanup HTMLHeadingElement, and add HTMLHeadingElement::FromNode. r=bzbarsky

Differential Revision: https://phabricator.services.mozilla.com/D49406

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-10-16 14:25:05 +00:00
Родитель dccb496ee8
Коммит 2ec3bb2b4f
2 изменённых файлов: 16 добавлений и 8 удалений

Просмотреть файл

@ -746,6 +746,11 @@ class nsINode : public mozilla::dom::EventTarget {
return isShadowRoot;
}
bool IsHTMLHeadingElement() const {
return IsAnyOfHTMLElements(nsGkAtoms::h1, nsGkAtoms::h2, nsGkAtoms::h3,
nsGkAtoms::h4, nsGkAtoms::h5, nsGkAtoms::h6);
}
/**
* Insert a content node before another or at the end.
* This method handles calling BindToTree on the child appropriately.

Просмотреть файл

@ -17,15 +17,17 @@ class HTMLHeadingElement final : public nsGenericHTMLElement {
public:
explicit HTMLHeadingElement(
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
: nsGenericHTMLElement(std::move(aNodeInfo)) {}
: nsGenericHTMLElement(std::move(aNodeInfo)) {
MOZ_ASSERT(IsHTMLHeadingElement());
}
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,
nsIPrincipal* aMaybeScriptedPrincipal,
nsAttrValue& aResult) override;
bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,
nsIPrincipal* aMaybeScriptedPrincipal,
nsAttrValue& aResult) override;
NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
void SetAlign(const nsAString& aAlign, ErrorResult& aError) {
return SetHTMLAttr(nsGkAtoms::align, aAlign, aError);
@ -34,11 +36,12 @@ class HTMLHeadingElement final : public nsGenericHTMLElement {
return GetHTMLAttr(nsGkAtoms::align, aAlign);
}
NS_IMPL_FROMNODE_HELPER(HTMLHeadingElement, IsHTMLHeadingElement())
protected:
virtual ~HTMLHeadingElement();
virtual JSObject* WrapNode(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
JSObject* WrapNode(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
private:
static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,