Bug 1494333 - index crons just like artifacts r=Callek
[gecko.git] / dom / html / HTMLPreElement.cpp
blob18209a567a86eaa7bc49ae4430f9465c2dd909fb
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/HTMLPreElement.h"
8 #include "mozilla/dom/HTMLPreElementBinding.h"
10 #include "mozilla/MappedDeclarations.h"
11 #include "nsAttrValueInlines.h"
12 #include "nsGkAtoms.h"
13 #include "nsStyleConsts.h"
14 #include "nsMappedAttributes.h"
16 NS_IMPL_NS_NEW_HTML_ELEMENT(Pre)
18 namespace mozilla {
19 namespace dom {
21 HTMLPreElement::~HTMLPreElement()
25 NS_IMPL_ELEMENT_CLONE(HTMLPreElement)
27 bool
28 HTMLPreElement::ParseAttribute(int32_t aNamespaceID,
29 nsAtom* aAttribute,
30 const nsAString& aValue,
31 nsIPrincipal* aMaybeScriptedPrincipal,
32 nsAttrValue& aResult)
34 if (aNamespaceID == kNameSpaceID_None) {
35 if (aAttribute == nsGkAtoms::width) {
36 return aResult.ParseIntValue(aValue);
40 return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
41 aMaybeScriptedPrincipal, aResult);
44 void
45 HTMLPreElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
46 MappedDeclarations& aDecls)
48 if (!aDecls.PropertyIsSet(eCSSProperty_white_space)) {
49 // wrap: empty
50 if (aAttributes->GetAttr(nsGkAtoms::wrap))
51 aDecls.SetKeywordValue(eCSSProperty_white_space, StyleWhiteSpace::PreWrap);
54 nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aDecls);
57 NS_IMETHODIMP_(bool)
58 HTMLPreElement::IsAttributeMapped(const nsAtom* aAttribute) const
60 if (!mNodeInfo->Equals(nsGkAtoms::pre)) {
61 return nsGenericHTMLElement::IsAttributeMapped(aAttribute);
64 static const MappedAttributeEntry attributes[] = {
65 { nsGkAtoms::wrap },
66 { nullptr },
69 static const MappedAttributeEntry* const map[] = {
70 attributes,
71 sCommonAttributeMap,
74 return FindAttributeDependence(aAttribute, map);
77 nsMapRuleToAttributesFunc
78 HTMLPreElement::GetAttributeMappingFunction() const
80 if (!mNodeInfo->Equals(nsGkAtoms::pre)) {
81 return nsGenericHTMLElement::GetAttributeMappingFunction();
84 return &MapAttributesIntoRule;
87 JSObject*
88 HTMLPreElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
90 return HTMLPreElement_Binding::Wrap(aCx, this, aGivenProto);
93 } // namespace dom
94 } // namespace mozilla