nsButtonBoxFrame.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef nsButtonBoxFrame_h___
  6. #define nsButtonBoxFrame_h___
  7. #include "mozilla/Attributes.h"
  8. #include "nsIDOMEventListener.h"
  9. #include "nsBoxFrame.h"
  10. class nsButtonBoxFrame : public nsBoxFrame
  11. {
  12. public:
  13. NS_DECL_FRAMEARENA_HELPERS
  14. friend nsIFrame* NS_NewButtonBoxFrame(nsIPresShell* aPresShell);
  15. explicit nsButtonBoxFrame(nsStyleContext* aContext);
  16. virtual void Init(nsIContent* aContent,
  17. nsContainerFrame* aParent,
  18. nsIFrame* aPrevInFlow) override;
  19. virtual void BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
  20. const nsDisplayListSet& aLists) override;
  21. virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
  22. virtual nsresult HandleEvent(nsPresContext* aPresContext,
  23. mozilla::WidgetGUIEvent* aEvent,
  24. nsEventStatus* aEventStatus) override;
  25. virtual void MouseClicked(mozilla::WidgetGUIEvent* aEvent)
  26. { DoMouseClick(aEvent, false); }
  27. void Blurred();
  28. #ifdef DEBUG_FRAME_DUMP
  29. virtual nsresult GetFrameName(nsAString& aResult) const override {
  30. return MakeFrameName(NS_LITERAL_STRING("ButtonBoxFrame"), aResult);
  31. }
  32. #endif
  33. /**
  34. * Our implementation of MouseClicked.
  35. * @param aTrustEvent if true and aEvent as null, then assume the event was trusted
  36. */
  37. void DoMouseClick(mozilla::WidgetGUIEvent* aEvent, bool aTrustEvent);
  38. void UpdateMouseThrough() override { AddStateBits(NS_FRAME_MOUSE_THROUGH_NEVER); }
  39. private:
  40. class nsButtonBoxListener final : public nsIDOMEventListener
  41. {
  42. public:
  43. explicit nsButtonBoxListener(nsButtonBoxFrame* aButtonBoxFrame) :
  44. mButtonBoxFrame(aButtonBoxFrame)
  45. { }
  46. NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override;
  47. NS_DECL_ISUPPORTS
  48. private:
  49. friend class nsButtonBoxFrame;
  50. virtual ~nsButtonBoxListener() { }
  51. nsButtonBoxFrame* mButtonBoxFrame;
  52. };
  53. RefPtr<nsButtonBoxListener> mButtonBoxListener;
  54. bool mIsHandlingKeyEvent;
  55. }; // class nsButtonBoxFrame
  56. #endif /* nsButtonBoxFrame_h___ */