Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / html / HTMLBRElement.h
blobe98210dcd20479a144a04b641f59ac9b7bee9bee
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 #ifndef mozilla_dom_HTMLBRElement_h
8 #define mozilla_dom_HTMLBRElement_h
10 #include "mozilla/Attributes.h"
11 #include "nsGenericHTMLElement.h"
12 #include "nsGkAtoms.h"
14 namespace mozilla::dom {
16 #define BR_ELEMENT_FLAG_BIT(n_) \
17 NODE_FLAG_BIT(HTML_ELEMENT_TYPE_SPECIFIC_BITS_OFFSET + (n_))
19 // BR element specific bits
20 enum {
21 // NS_PADDING_FOR_EMPTY_EDITOR is set if the <br> element is created by
22 // editor for placing caret at proper position in empty editor.
23 NS_PADDING_FOR_EMPTY_EDITOR = BR_ELEMENT_FLAG_BIT(0),
25 // NS_PADDING_FOR_EMPTY_LAST_LINE is set if the <br> element is created by
26 // editor for placing caret at proper position for making empty last line
27 // in a block or <textarea> element visible.
28 NS_PADDING_FOR_EMPTY_LAST_LINE = BR_ELEMENT_FLAG_BIT(1),
31 ASSERT_NODE_FLAGS_SPACE(HTML_ELEMENT_TYPE_SPECIFIC_BITS_OFFSET + 2);
33 class HTMLBRElement final : public nsGenericHTMLElement {
34 public:
35 explicit HTMLBRElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
37 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLBRElement, br)
39 bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
40 const nsAString& aValue,
41 nsIPrincipal* aMaybeScriptedPrincipal,
42 nsAttrValue& aResult) override;
43 NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
44 nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
45 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
47 bool Clear() const { return GetBoolAttr(nsGkAtoms::clear); }
48 void SetClear(const nsAString& aClear, ErrorResult& aError) {
49 return SetHTMLAttr(nsGkAtoms::clear, aClear, aError);
51 void GetClear(DOMString& aClear) const {
52 return GetHTMLAttr(nsGkAtoms::clear, aClear);
55 JSObject* WrapNode(JSContext* aCx,
56 JS::Handle<JSObject*> aGivenProto) override;
58 bool IsPaddingForEmptyEditor() const {
59 return HasFlag(NS_PADDING_FOR_EMPTY_EDITOR);
61 bool IsPaddingForEmptyLastLine() const {
62 return HasFlag(NS_PADDING_FOR_EMPTY_LAST_LINE);
65 private:
66 virtual ~HTMLBRElement();
68 static void MapAttributesIntoRule(MappedDeclarationsBuilder&);
71 } // namespace mozilla::dom
73 #endif