tor-browser

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

HTMLTemplateElement.h (3636B)


      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_HTMLTemplateElement_h
      8 #define mozilla_dom_HTMLTemplateElement_h
      9 
     10 #include "mozilla/Attributes.h"
     11 #include "mozilla/ErrorResult.h"
     12 #include "mozilla/dom/DocumentFragment.h"
     13 #include "mozilla/dom/ShadowRootBinding.h"
     14 #include "nsGenericHTMLElement.h"
     15 #include "nsGkAtoms.h"
     16 
     17 namespace mozilla::dom {
     18 
     19 class HTMLTemplateElement final : public nsGenericHTMLElement {
     20 public:
     21  explicit HTMLTemplateElement(
     22      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
     23 
     24  // nsISupports
     25  NS_DECL_ISUPPORTS_INHERITED
     26 
     27  NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLTemplateElement, _template);
     28 
     29  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLTemplateElement,
     30                                           nsGenericHTMLElement)
     31 
     32  void AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
     33                    const nsAttrValue* aValue, const nsAttrValue* aOldValue,
     34                    nsIPrincipal* aMaybeScriptedPrincipal,
     35                    bool aNotify) override;
     36 
     37  bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
     38                      const nsAString& aValue,
     39                      nsIPrincipal* aMaybeScriptedPrincipal,
     40                      nsAttrValue& aResult) override;
     41 
     42  virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
     43 
     44  DocumentFragment* Content() { return mContent; }
     45  void SetContent(DocumentFragment* aContent) { mContent = aContent; }
     46 
     47  void GetShadowRootMode(nsAString& aResult) const {
     48    GetEnumAttr(nsGkAtoms::shadowrootmode, nullptr, aResult);
     49  }
     50  void SetShadowRootMode(const nsAString& aValue) {
     51    SetHTMLAttr(nsGkAtoms::shadowrootmode, aValue);
     52  }
     53 
     54  bool ShadowRootDelegatesFocus() const {
     55    return GetBoolAttr(nsGkAtoms::shadowrootdelegatesfocus);
     56  }
     57  void SetShadowRootDelegatesFocus(bool aValue, ErrorResult& aRv) {
     58    SetHTMLBoolAttr(nsGkAtoms::shadowrootdelegatesfocus, aValue, aRv);
     59  }
     60 
     61  bool ShadowRootClonable() const {
     62    return GetBoolAttr(nsGkAtoms::shadowrootclonable);
     63  }
     64  void SetShadowRootClonable(bool aValue, ErrorResult& aRv) {
     65    SetHTMLBoolAttr(nsGkAtoms::shadowrootclonable, aValue, aRv);
     66  }
     67 
     68  bool ShadowRootSerializable() const {
     69    return GetBoolAttr(nsGkAtoms::shadowrootserializable);
     70  }
     71  void SetShadowRootSerializable(bool aValue, ErrorResult& aRv) {
     72    SetHTMLBoolAttr(nsGkAtoms::shadowrootserializable, aValue, aRv);
     73  }
     74 
     75  void GetShadowRootReferenceTarget(nsAString& aResult) const {
     76    GetHTMLAttr(nsGkAtoms::shadowrootreferencetarget, aResult);
     77  }
     78  void SetShadowRootReferenceTarget(const nsAString& aValue, ErrorResult& aRv) {
     79    SetHTMLAttr(nsGkAtoms::shadowrootreferencetarget, aValue);
     80  }
     81 
     82  void SetHTML(const nsAString& aInnerHTML, const SetHTMLOptions& aOptions,
     83               ErrorResult& aError) final;
     84 
     85  MOZ_CAN_RUN_SCRIPT
     86  void SetHTMLUnsafe(const TrustedHTMLOrString& aHTML,
     87                     const SetHTMLUnsafeOptions& aOptions,
     88                     nsIPrincipal* aSubjectPrincipal,
     89                     ErrorResult& aError) final;
     90 
     91 protected:
     92  virtual ~HTMLTemplateElement();
     93 
     94  virtual JSObject* WrapNode(JSContext* aCx,
     95                             JS::Handle<JSObject*> aGivenProto) override;
     96 
     97  RefPtr<DocumentFragment> mContent;
     98  Maybe<ShadowRootMode> mShadowRootMode;
     99 };
    100 
    101 }  // namespace mozilla::dom
    102 
    103 #endif  // mozilla_dom_HTMLTemplateElement_h