HTMLPreElement.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_HTMLPreElement_h
  6. #define mozilla_dom_HTMLPreElement_h
  7. #include "mozilla/Attributes.h"
  8. #include "nsIDOMHTMLPreElement.h"
  9. #include "nsGenericHTMLElement.h"
  10. namespace mozilla {
  11. namespace dom {
  12. class HTMLPreElement final : public nsGenericHTMLElement,
  13. public nsIDOMHTMLPreElement
  14. {
  15. public:
  16. explicit HTMLPreElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
  17. : nsGenericHTMLElement(aNodeInfo)
  18. {
  19. }
  20. // nsISupports
  21. NS_DECL_ISUPPORTS_INHERITED
  22. // nsIDOMHTMLPreElement
  23. NS_IMETHOD GetWidth(int32_t* aWidth) override;
  24. NS_IMETHOD SetWidth(int32_t aWidth) override;
  25. virtual bool ParseAttribute(int32_t aNamespaceID,
  26. nsIAtom* aAttribute,
  27. const nsAString& aValue,
  28. nsAttrValue& aResult) override;
  29. NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const override;
  30. virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
  31. virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
  32. // WebIDL API
  33. int32_t Width() const
  34. {
  35. return GetIntAttr(nsGkAtoms::width, 0);
  36. }
  37. void SetWidth(int32_t aWidth, mozilla::ErrorResult& rv)
  38. {
  39. rv = SetIntAttr(nsGkAtoms::width, aWidth);
  40. }
  41. protected:
  42. virtual ~HTMLPreElement();
  43. virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
  44. private:
  45. static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
  46. nsRuleData* aData);
  47. };
  48. } // namespace dom
  49. } // namespace mozilla
  50. #endif // mozilla_dom_HTMLPreElement_h