tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

HTMLBRElement.h (2527B)


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