tor-browser

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

HTMLBodyElement.h (4352B)


      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 #ifndef HTMLBodyElement_h___
      7 #define HTMLBodyElement_h___
      8 
      9 #include "nsGenericHTMLElement.h"
     10 
     11 namespace mozilla {
     12 
     13 class EditorBase;
     14 
     15 namespace dom {
     16 
     17 class OnBeforeUnloadEventHandlerNonNull;
     18 
     19 class HTMLBodyElement final : public nsGenericHTMLElement {
     20 public:
     21  using Element::GetCharacterDataBuffer;
     22 
     23  explicit HTMLBodyElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
     24      : nsGenericHTMLElement(std::move(aNodeInfo)) {}
     25 
     26  // nsISupports
     27  NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLBodyElement, nsGenericHTMLElement)
     28 
     29  NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLBodyElement, body);
     30 
     31  // Event listener stuff; we need to declare only the ones we need to
     32  // forward to window that don't come from nsIDOMHTMLBodyElement.
     33 #define EVENT(name_, id_, type_, struct_) /* nothing; handled by the shim */
     34 #define WINDOW_EVENT_HELPER(name_, type_) \
     35  type_* GetOn##name_();                  \
     36  void SetOn##name_(type_* handler);
     37 #define WINDOW_EVENT(name_, id_, type_, struct_) \
     38  WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
     39 #define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
     40  WINDOW_EVENT_HELPER(name_, OnBeforeUnloadEventHandlerNonNull)
     41 #include "mozilla/EventNameList.h"  // IWYU pragma: keep
     42 #undef BEFOREUNLOAD_EVENT
     43 #undef WINDOW_EVENT
     44 #undef WINDOW_EVENT_HELPER
     45 #undef EVENT
     46 
     47  void GetText(nsAString& aText) { GetHTMLAttr(nsGkAtoms::text, aText); }
     48  void SetText(const nsAString& aText) { SetHTMLAttr(nsGkAtoms::text, aText); }
     49  void SetText(const nsAString& aText, ErrorResult& aError) {
     50    SetHTMLAttr(nsGkAtoms::text, aText, aError);
     51  }
     52  void GetLink(nsAString& aLink) { GetHTMLAttr(nsGkAtoms::link, aLink); }
     53  void SetLink(const nsAString& aLink) { SetHTMLAttr(nsGkAtoms::link, aLink); }
     54  void SetLink(const nsAString& aLink, ErrorResult& aError) {
     55    SetHTMLAttr(nsGkAtoms::link, aLink, aError);
     56  }
     57  void GetVLink(nsAString& aVLink) { GetHTMLAttr(nsGkAtoms::vlink, aVLink); }
     58  void SetVLink(const nsAString& aVLink) {
     59    SetHTMLAttr(nsGkAtoms::vlink, aVLink);
     60  }
     61  void SetVLink(const nsAString& aVLink, ErrorResult& aError) {
     62    SetHTMLAttr(nsGkAtoms::vlink, aVLink, aError);
     63  }
     64  void GetALink(nsAString& aALink) { GetHTMLAttr(nsGkAtoms::alink, aALink); }
     65  void SetALink(const nsAString& aALink) {
     66    SetHTMLAttr(nsGkAtoms::alink, aALink);
     67  }
     68  void SetALink(const nsAString& aALink, ErrorResult& aError) {
     69    SetHTMLAttr(nsGkAtoms::alink, aALink, aError);
     70  }
     71  void GetBgColor(nsAString& aBgColor) {
     72    GetHTMLAttr(nsGkAtoms::bgcolor, aBgColor);
     73  }
     74  void SetBgColor(const nsAString& aBgColor) {
     75    SetHTMLAttr(nsGkAtoms::bgcolor, aBgColor);
     76  }
     77  void SetBgColor(const nsAString& aBgColor, ErrorResult& aError) {
     78    SetHTMLAttr(nsGkAtoms::bgcolor, aBgColor, aError);
     79  }
     80  void GetBackground(DOMString& aBackground) {
     81    GetHTMLAttr(nsGkAtoms::background, aBackground);
     82  }
     83  void GetBackground(nsAString& aBackground) {
     84    GetHTMLAttr(nsGkAtoms::background, aBackground);
     85  }
     86  void SetBackground(const nsAString& aBackground, ErrorResult& aError) {
     87    SetHTMLAttr(nsGkAtoms::background, aBackground, aError);
     88  }
     89 
     90  bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
     91                      const nsAString& aValue,
     92                      nsIPrincipal* aMaybeScriptedPrincipal,
     93                      nsAttrValue& aResult) override;
     94  nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
     95  NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
     96  already_AddRefed<EditorBase> GetAssociatedEditor() override;
     97  nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
     98 
     99  bool IsEventAttributeNameInternal(nsAtom* aName) override;
    100  nsresult BindToTree(BindContext&, nsINode& aParent) override;
    101 
    102  void FrameMarginsChanged();
    103 
    104 protected:
    105  virtual ~HTMLBodyElement();
    106 
    107  JSObject* WrapNode(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
    108 
    109 private:
    110  static void MapAttributesIntoRule(MappedDeclarationsBuilder&);
    111 };
    112 
    113 }  // namespace dom
    114 }  // namespace mozilla
    115 
    116 #endif /* HTMLBodyElement_h___ */