Source code

Revision control

Other Tools

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 XULPopupElement_h__
8
#define XULPopupElement_h__
9
10
#include "mozilla/Attributes.h"
11
#include "mozilla/ErrorResult.h"
12
#include "nsCycleCollectionParticipant.h"
13
#include "nsWrapperCache.h"
14
#include "nsString.h"
15
#include "nsXULElement.h"
16
17
struct JSContext;
18
19
namespace mozilla {
20
namespace dom {
21
22
class DOMRect;
23
class Element;
24
class Event;
25
class StringOrOpenPopupOptions;
26
27
nsXULElement* NS_NewXULPopupElement(
28
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
29
30
class XULPopupElement : public nsXULElement {
31
private:
32
nsIFrame* GetFrame(bool aFlushLayout);
33
34
public:
35
explicit XULPopupElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
36
: nsXULElement(std::move(aNodeInfo)) {}
37
38
void GetLabel(DOMString& aValue) const {
39
GetXULAttr(nsGkAtoms::label, aValue);
40
}
41
void SetLabel(const nsAString& aValue, ErrorResult& rv) {
42
SetXULAttr(nsGkAtoms::label, aValue, rv);
43
}
44
45
void GetPosition(DOMString& aValue) const {
46
GetXULAttr(nsGkAtoms::position, aValue);
47
}
48
void SetPosition(const nsAString& aValue, ErrorResult& rv) {
49
SetXULAttr(nsGkAtoms::position, aValue, rv);
50
}
51
52
bool AutoPosition();
53
54
void SetAutoPosition(bool aShouldAutoPosition);
55
56
void OpenPopup(Element* aAnchorElement,
57
const StringOrOpenPopupOptions& aOptions, int32_t aXPos,
58
int32_t aYPos, bool aIsContextMenu, bool aAttributesOverride,
59
Event* aTriggerEvent);
60
61
void OpenPopupAtScreen(int32_t aXPos, int32_t aYPos, bool aIsContextMenu,
62
Event* aTriggerEvent);
63
64
void OpenPopupAtScreenRect(const nsAString& aPosition, int32_t aXPos,
65
int32_t aYPos, int32_t aWidth, int32_t aHeight,
66
bool aIsContextMenu, bool aAttributesOverride,
67
Event* aTriggerEvent);
68
69
void HidePopup(bool aCancel);
70
71
void GetState(nsString& aState);
72
73
nsINode* GetTriggerNode() const;
74
75
Element* GetAnchorNode() const;
76
77
already_AddRefed<DOMRect> GetOuterScreenRect();
78
79
void MoveTo(int32_t aLeft, int32_t aTop);
80
81
void MoveToAnchor(Element* aAnchorElement, const nsAString& aPosition,
82
int32_t aXPos, int32_t aYPos, bool aAttributesOverride);
83
84
void SizeTo(int32_t aWidth, int32_t aHeight);
85
86
void GetAlignmentPosition(nsString& positionStr);
87
88
int32_t AlignmentOffset();
89
90
void SetConstraintRect(DOMRectReadOnly& aRect);
91
92
protected:
93
virtual ~XULPopupElement() {}
94
95
JSObject* WrapNode(JSContext* aCx,
96
JS::Handle<JSObject*> aGivenProto) override;
97
};
98
99
} // namespace dom
100
} // namespace mozilla
101
102
#endif // XULPopupElement_h