Bug 1769952 - Fix running raptor on a Win10-64 VM r=sparky
[gecko.git] / dom / xul / XULPopupElement.h
blobdb7fd278c323fdf6997383e7a6de580d95fe6b70
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/. */
7 #ifndef XULPopupElement_h__
8 #define XULPopupElement_h__
10 #include "mozilla/Attributes.h"
11 #include "nsCycleCollectionParticipant.h"
12 #include "nsWrapperCache.h"
13 #include "nsString.h"
14 #include "nsXULElement.h"
16 struct JSContext;
18 namespace mozilla {
19 class ErrorResult;
21 namespace dom {
23 class DOMRect;
24 class Element;
25 class Event;
26 class StringOrOpenPopupOptions;
27 struct ActivateMenuItemOptions;
29 nsXULElement* NS_NewXULPopupElement(
30 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
32 class XULPopupElement : public nsXULElement {
33 private:
34 nsIFrame* GetFrame(bool aFlushLayout);
36 public:
37 explicit XULPopupElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
38 : nsXULElement(std::move(aNodeInfo)) {}
40 void GetLabel(DOMString& aValue) const {
41 GetXULAttr(nsGkAtoms::label, aValue);
43 void SetLabel(const nsAString& aValue, ErrorResult& rv) {
44 SetXULAttr(nsGkAtoms::label, aValue, rv);
47 void GetPosition(DOMString& aValue) const {
48 GetXULAttr(nsGkAtoms::position, aValue);
50 void SetPosition(const nsAString& aValue, ErrorResult& rv) {
51 SetXULAttr(nsGkAtoms::position, aValue, rv);
54 bool AutoPosition();
56 void SetAutoPosition(bool aShouldAutoPosition);
58 void OpenPopup(Element* aAnchorElement,
59 const StringOrOpenPopupOptions& aOptions, int32_t aXPos,
60 int32_t aYPos, bool aIsContextMenu, bool aAttributesOverride,
61 Event* aTriggerEvent);
63 void OpenPopupAtScreen(int32_t aXPos, int32_t aYPos, bool aIsContextMenu,
64 Event* aTriggerEvent);
66 void OpenPopupAtScreenRect(const nsAString& aPosition, int32_t aXPos,
67 int32_t aYPos, int32_t aWidth, int32_t aHeight,
68 bool aIsContextMenu, bool aAttributesOverride,
69 Event* aTriggerEvent);
71 void HidePopup(bool aCancel);
73 void ActivateItem(Element& aItemElement,
74 const ActivateMenuItemOptions& aOptions, ErrorResult& aRv);
76 void GetState(nsString& aState);
78 nsINode* GetTriggerNode() const;
80 Element* GetAnchorNode() const;
82 already_AddRefed<DOMRect> GetOuterScreenRect();
84 void MoveTo(int32_t aLeft, int32_t aTop);
86 void MoveToAnchor(Element* aAnchorElement, const nsAString& aPosition,
87 int32_t aXPos, int32_t aYPos, bool aAttributesOverride);
89 void SizeTo(int32_t aWidth, int32_t aHeight);
91 void SetConstraintRect(DOMRectReadOnly& aRect);
93 protected:
94 virtual ~XULPopupElement() = default;
96 JSObject* WrapNode(JSContext* aCx,
97 JS::Handle<JSObject*> aGivenProto) override;
100 } // namespace dom
101 } // namespace mozilla
103 #endif // XULPopupElement_h