PopupBoxObject.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* vim:set ts=2 sw=2 sts=2 et cindent: */
  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. #ifndef mozilla_dom_PopupBoxObject_h
  7. #define mozilla_dom_PopupBoxObject_h
  8. #include "mozilla/Attributes.h"
  9. #include "mozilla/ErrorResult.h"
  10. #include "nsCycleCollectionParticipant.h"
  11. #include "nsWrapperCache.h"
  12. #include "mozilla/dom/BoxObject.h"
  13. #include "nsString.h"
  14. struct JSContext;
  15. class nsPopupSetFrame;
  16. namespace mozilla {
  17. namespace dom {
  18. class DOMRect;
  19. class Element;
  20. class Event;
  21. class PopupBoxObject final : public BoxObject
  22. {
  23. public:
  24. NS_DECL_ISUPPORTS_INHERITED
  25. // also in PopupBoxObject.webidl
  26. static const uint32_t ROLLUP_DEFAULT = 0; /* widget/platform default */
  27. static const uint32_t ROLLUP_CONSUME = 1; /* consume the rollup event */
  28. static const uint32_t ROLLUP_NO_CONSUME = 2; /* don't consume the rollup event */
  29. PopupBoxObject();
  30. nsIContent* GetParentObject() const;
  31. virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
  32. void ShowPopup(Element* aAnchorElement,
  33. Element& aPopupElement,
  34. int32_t aXPos,
  35. int32_t aYPos,
  36. const nsAString& aPopupType,
  37. const nsAString& aAnchorAlignment,
  38. const nsAString& aPopupAlignment);
  39. void HidePopup(bool aCancel);
  40. bool AutoPosition();
  41. void SetAutoPosition(bool aShouldAutoPosition);
  42. void EnableKeyboardNavigator(bool aEnableKeyboardNavigator);
  43. void EnableRollup(bool aShouldRollup);
  44. void SetConsumeRollupEvent(uint32_t aConsume);
  45. void SizeTo(int32_t aWidth, int32_t aHeight);
  46. void MoveTo(int32_t aLeft, int32_t aTop);
  47. void OpenPopup(Element* aAnchorElement,
  48. const nsAString& aPosition,
  49. int32_t aXPos,
  50. int32_t aYPos,
  51. bool aIsContextMenu, bool aAttributesOverride,
  52. Event* aTriggerEvent);
  53. void OpenPopupAtScreen(int32_t aXPos,
  54. int32_t aYPos,
  55. bool aIsContextMenu,
  56. Event* aTriggerEvent);
  57. void OpenPopupAtScreenRect(const nsAString& aPosition,
  58. int32_t aXPos, int32_t aYPos,
  59. int32_t aWidth, int32_t aHeight,
  60. bool aIsContextMenu,
  61. bool aAttributesOverride,
  62. Event* aTriggerEvent);
  63. void GetPopupState(nsString& aState);
  64. nsINode* GetTriggerNode() const;
  65. Element* GetAnchorNode() const;
  66. already_AddRefed<DOMRect> GetOuterScreenRect();
  67. void MoveToAnchor(Element* aAnchorElement,
  68. const nsAString& aPosition,
  69. int32_t aXPos,
  70. int32_t aYPos,
  71. bool aAttributesOverride);
  72. void GetAlignmentPosition(nsString& positionStr);
  73. int32_t AlignmentOffset();
  74. void SetConstraintRect(dom::DOMRectReadOnly& aRect);
  75. private:
  76. ~PopupBoxObject();
  77. protected:
  78. nsPopupSetFrame* GetPopupSetFrame();
  79. };
  80. } // namespace dom
  81. } // namespace mozilla
  82. #endif // mozilla_dom_PopupBoxObject_h