tor-browser

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

HTMLLabelElement.h (2331B)


      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 /**
      8 * Declaration of HTML <label> elements.
      9 */
     10 #ifndef HTMLLabelElement_h
     11 #define HTMLLabelElement_h
     12 
     13 #include "mozilla/Attributes.h"
     14 #include "nsGenericHTMLElement.h"
     15 
     16 namespace mozilla {
     17 class EventChainPostVisitor;
     18 namespace dom {
     19 
     20 class HTMLLabelElement final : public nsGenericHTMLElement {
     21 public:
     22  explicit HTMLLabelElement(
     23      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
     24      : nsGenericHTMLElement(std::move(aNodeInfo)), mHandlingEvent(false) {}
     25 
     26  NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLLabelElement, label)
     27 
     28  // nsISupports
     29  NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLLabelElement, nsGenericHTMLElement)
     30 
     31  // Element
     32  virtual bool IsInteractiveHTMLContent() const override { return true; }
     33 
     34  HTMLFormElement* GetForm() const;
     35  void GetHtmlFor(nsString& aHtmlFor) {
     36    GetHTMLAttr(nsGkAtoms::_for, aHtmlFor);
     37  }
     38  void SetHtmlFor(const nsAString& aHtmlFor) {
     39    SetHTMLAttr(nsGkAtoms::_for, aHtmlFor);
     40  }
     41  nsGenericHTMLElement* GetControl() const { return GetLabeledElement(); }
     42 
     43  using nsGenericHTMLElement::Focus;
     44  virtual void Focus(const FocusOptions& aOptions,
     45                     const mozilla::dom::CallerType aCallerType,
     46                     ErrorResult& aError) override;
     47 
     48  // nsIContent
     49  MOZ_CAN_RUN_SCRIPT_BOUNDARY
     50  virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
     51  MOZ_CAN_RUN_SCRIPT
     52  virtual Result<bool, nsresult> PerformAccesskey(
     53      bool aKeyCausesActivation, bool aIsTrustedEvent) override;
     54  virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
     55 
     56  nsGenericHTMLElement* GetLabeledElement() const;
     57 
     58 protected:
     59  virtual ~HTMLLabelElement();
     60 
     61  virtual JSObject* WrapNode(JSContext* aCx,
     62                             JS::Handle<JSObject*> aGivenProto) override;
     63 
     64  nsGenericHTMLElement* GetFirstLabelableDescendant() const;
     65 
     66  // XXX It would be nice if we could use an event flag instead.
     67  bool mHandlingEvent;
     68 };
     69 
     70 }  // namespace dom
     71 }  // namespace mozilla
     72 
     73 #endif /* HTMLLabelElement_h */