HTMLHeadingElement.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #include "mozilla/dom/HTMLHeadingElement.h"
  6. #include "mozilla/dom/HTMLHeadingElementBinding.h"
  7. #include "nsGkAtoms.h"
  8. #include "nsStyleConsts.h"
  9. #include "nsMappedAttributes.h"
  10. #include "nsRuleData.h"
  11. #include "mozAutoDocUpdate.h"
  12. NS_IMPL_NS_NEW_HTML_ELEMENT(Heading)
  13. namespace mozilla {
  14. namespace dom {
  15. HTMLHeadingElement::~HTMLHeadingElement()
  16. {
  17. }
  18. NS_IMPL_ELEMENT_CLONE(HTMLHeadingElement)
  19. JSObject*
  20. HTMLHeadingElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
  21. {
  22. return HTMLHeadingElementBinding::Wrap(aCx, this, aGivenProto);
  23. }
  24. bool
  25. HTMLHeadingElement::ParseAttribute(int32_t aNamespaceID,
  26. nsIAtom* aAttribute,
  27. const nsAString& aValue,
  28. nsAttrValue& aResult)
  29. {
  30. if (aAttribute == nsGkAtoms::align && aNamespaceID == kNameSpaceID_None) {
  31. return ParseDivAlignValue(aValue, aResult);
  32. }
  33. return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
  34. aResult);
  35. }
  36. void
  37. HTMLHeadingElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
  38. nsRuleData* aData)
  39. {
  40. nsGenericHTMLElement::MapDivAlignAttributeInto(aAttributes, aData);
  41. nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
  42. }
  43. NS_IMETHODIMP_(bool)
  44. HTMLHeadingElement::IsAttributeMapped(const nsIAtom* aAttribute) const
  45. {
  46. static const MappedAttributeEntry* const map[] = {
  47. sDivAlignAttributeMap,
  48. sCommonAttributeMap
  49. };
  50. return FindAttributeDependence(aAttribute, map);
  51. }
  52. nsMapRuleToAttributesFunc
  53. HTMLHeadingElement::GetAttributeMappingFunction() const
  54. {
  55. return &MapAttributesIntoRule;
  56. }
  57. } // namespace dom
  58. } // namespace mozilla