tor-browser

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

HTMLLegendElement.h (3073B)


      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_HTMLLegendElement_h
      8 #define mozilla_dom_HTMLLegendElement_h
      9 
     10 #include "mozilla/dom/HTMLFormElement.h"
     11 #include "nsGenericHTMLElement.h"
     12 
     13 namespace mozilla::dom {
     14 
     15 class HTMLLegendElement final : public nsGenericHTMLElement {
     16 public:
     17  explicit HTMLLegendElement(
     18      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
     19      : nsGenericHTMLElement(std::move(aNodeInfo)) {}
     20 
     21  NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLLegendElement, legend)
     22 
     23  using nsGenericHTMLElement::Focus;
     24  virtual void Focus(const FocusOptions& aOptions,
     25                     const mozilla::dom::CallerType aCallerType,
     26                     ErrorResult& aError) override;
     27 
     28  virtual Result<bool, nsresult> PerformAccesskey(
     29      bool aKeyCausesActivation, bool aIsTrustedEvent) override;
     30 
     31  // nsIContent
     32  virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
     33  virtual void UnbindFromTree(UnbindContext&) override;
     34  virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
     35                              const nsAString& aValue,
     36                              nsIPrincipal* aMaybeScriptedPrincipal,
     37                              nsAttrValue& aResult) override;
     38  virtual nsChangeHint GetAttributeChangeHint(
     39      const nsAtom* aAttribute, AttrModType aModType) const override;
     40 
     41  virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
     42 
     43  enum class LegendAlignValue : uint8_t {
     44    Left,
     45    Right,
     46    Center,
     47    Bottom,
     48    Top,
     49    InlineStart,
     50    InlineEnd,
     51  };
     52 
     53  /**
     54   * Return the align value to use for the given fieldset writing-mode.
     55   * (This method resolves Left/Right to the appropriate InlineStart/InlineEnd).
     56   * @param aCBWM the fieldset writing-mode
     57   * @note we only parse left/right/center, so this method returns Center,
     58   * InlineStart or InlineEnd.
     59   */
     60  LegendAlignValue LogicalAlign(mozilla::WritingMode aCBWM) const;
     61 
     62  /**
     63   * WebIDL Interface
     64   */
     65 
     66  HTMLFormElement* GetForm() const;
     67 
     68  void GetAlign(DOMString& aAlign) { GetHTMLAttr(nsGkAtoms::align, aAlign); }
     69 
     70  void SetAlign(const nsAString& aAlign, ErrorResult& aError) {
     71    SetHTMLAttr(nsGkAtoms::align, aAlign, aError);
     72  }
     73 
     74  nsINode* GetScopeChainParent() const override {
     75    Element* form = GetForm();
     76    return form ? form : nsGenericHTMLElement::GetScopeChainParent();
     77  }
     78 
     79 protected:
     80  virtual ~HTMLLegendElement();
     81 
     82  virtual JSObject* WrapNode(JSContext* aCx,
     83                             JS::Handle<JSObject*> aGivenProto) override;
     84 
     85  /**
     86   * Get the fieldset content element that contains this legend.
     87   * Returns null if there is no fieldset containing this legend.
     88   */
     89  nsIContent* GetFieldSet() const;
     90 };
     91 
     92 }  // namespace mozilla::dom
     93 
     94 #endif /* mozilla_dom_HTMLLegendElement_h */