tor-browser

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

HTMLSharedElement.h (4371B)


      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_HTMLSharedElement_h
      8 #define mozilla_dom_HTMLSharedElement_h
      9 
     10 #include "mozilla/Assertions.h"
     11 #include "nsGenericHTMLElement.h"
     12 #include "nsGkAtoms.h"
     13 
     14 namespace mozilla::dom {
     15 
     16 class HTMLSharedElement final : public nsGenericHTMLElement {
     17 public:
     18  explicit HTMLSharedElement(
     19      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
     20      : nsGenericHTMLElement(std::move(aNodeInfo)) {
     21    if (mNodeInfo->Equals(nsGkAtoms::head) ||
     22        mNodeInfo->Equals(nsGkAtoms::html)) {
     23      SetHasWeirdParserInsertionMode();
     24    }
     25  }
     26 
     27  // nsIContent
     28  void DoneAddingChildren(bool aHaveNotified) override;
     29 
     30  nsresult BindToTree(BindContext&, nsINode& aParent) override;
     31 
     32  void UnbindFromTree(UnbindContext&) override;
     33 
     34  nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
     35 
     36  // WebIDL API
     37  // HTMLParamElement
     38  void GetName(DOMString& aValue) {
     39    MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param));
     40    GetHTMLAttr(nsGkAtoms::name, aValue);
     41  }
     42  void SetName(const nsAString& aValue, ErrorResult& aResult) {
     43    MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param));
     44    SetHTMLAttr(nsGkAtoms::name, aValue, aResult);
     45  }
     46  void GetValue(DOMString& aValue) {
     47    MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param));
     48    GetHTMLAttr(nsGkAtoms::value, aValue);
     49  }
     50  void SetValue(const nsAString& aValue, ErrorResult& aResult) {
     51    MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param));
     52    SetHTMLAttr(nsGkAtoms::value, aValue, aResult);
     53  }
     54  void GetType(DOMString& aValue) {
     55    MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param));
     56    GetHTMLAttr(nsGkAtoms::type, aValue);
     57  }
     58  void SetType(const nsAString& aValue, ErrorResult& aResult) {
     59    MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param));
     60    SetHTMLAttr(nsGkAtoms::type, aValue, aResult);
     61  }
     62  void GetValueType(DOMString& aValue) {
     63    MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param));
     64    GetHTMLAttr(nsGkAtoms::valuetype, aValue);
     65  }
     66  void SetValueType(const nsAString& aValue, ErrorResult& aResult) {
     67    MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param));
     68    SetHTMLAttr(nsGkAtoms::valuetype, aValue, aResult);
     69  }
     70 
     71  // HTMLBaseElement
     72  void GetTarget(DOMString& aValue) {
     73    MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::base));
     74    GetHTMLAttr(nsGkAtoms::target, aValue);
     75  }
     76  void SetTarget(const nsAString& aValue, ErrorResult& aResult) {
     77    MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::base));
     78    SetHTMLAttr(nsGkAtoms::target, aValue, aResult);
     79  }
     80 
     81  void GetHref(nsAString& aValue);
     82  void SetHref(const nsAString& aValue, ErrorResult& aResult) {
     83    MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::base));
     84    SetHTMLAttr(nsGkAtoms::href, aValue, aResult);
     85  }
     86 
     87  // HTMLDirectoryElement
     88  bool Compact() const {
     89    MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::dir));
     90    return GetBoolAttr(nsGkAtoms::compact);
     91  }
     92  void SetCompact(bool aCompact, ErrorResult& aResult) {
     93    MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::dir));
     94    SetHTMLBoolAttr(nsGkAtoms::compact, aCompact, aResult);
     95  }
     96 
     97  // HTMLQuoteElement
     98  void GetCite(nsString& aCite) { GetHTMLURIAttr(nsGkAtoms::cite, aCite); }
     99 
    100  void SetCite(const nsAString& aValue, ErrorResult& aResult) {
    101    MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::q) ||
    102               mNodeInfo->Equals(nsGkAtoms::blockquote));
    103    SetHTMLAttr(nsGkAtoms::cite, aValue, aResult);
    104  }
    105 
    106  // HTMLHtmlElement
    107  void GetVersion(DOMString& aValue) {
    108    MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::html));
    109    GetHTMLAttr(nsGkAtoms::version, aValue);
    110  }
    111  void SetVersion(const nsAString& aValue, ErrorResult& aResult) {
    112    MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::html));
    113    SetHTMLAttr(nsGkAtoms::version, aValue, aResult);
    114  }
    115 
    116 protected:
    117  virtual ~HTMLSharedElement();
    118 
    119  JSObject* WrapNode(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
    120 
    121  void AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
    122                    const nsAttrValue* aValue, const nsAttrValue* aOldValue,
    123                    nsIPrincipal* aSubjectPrincipal, bool aNotify) override;
    124 };
    125 
    126 }  // namespace mozilla::dom
    127 
    128 #endif  // mozilla_dom_HTMLSharedElement_h