1 /* -*- Mode: C++; tab-width: 4; 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/. */
6 #ifndef HTMLEditorEventListener_h
7 #define HTMLEditorEventListener_h
9 #include "EditorEventListener.h"
11 #include "EditorForwards.h"
12 #include "HTMLEditor.h"
22 class HTMLEditorEventListener final
: public EditorEventListener
{
24 HTMLEditorEventListener()
25 : mListeningToMouseMoveEventForResizers(false),
26 mListeningToMouseMoveEventForGrabber(false),
27 mListeningToResizeEvent(false) {}
29 // nsIDOMEventListener
30 MOZ_CAN_RUN_SCRIPT NS_IMETHOD
HandleEvent(dom::Event
* aEvent
) override
;
33 * Connect() fails if aEditorBase isn't an HTMLEditor instance.
35 virtual nsresult
Connect(EditorBase
* aEditorBase
) override
;
37 virtual void Disconnect() override
;
40 * ListenToMouseMoveEventForResizers() starts to listen to or stop
41 * listening to "mousemove" events for resizers.
43 nsresult
ListenToMouseMoveEventForResizers(bool aListen
) {
44 if (aListen
== mListeningToMouseMoveEventForResizers
) {
47 nsresult rv
= ListenToMouseMoveEventForResizersOrGrabber(aListen
, false);
48 NS_WARNING_ASSERTION(NS_SUCCEEDED(rv
),
49 "HTMLEditorEventListener::"
50 "ListenToMouseMoveEventForResizersOrGrabber() failed");
55 * ListenToMouseMoveEventForResizers() starts to listen to or stop
56 * listening to "mousemove" events for grabber to move absolutely
59 nsresult
ListenToMouseMoveEventForGrabber(bool aListen
) {
60 if (aListen
== mListeningToMouseMoveEventForGrabber
) {
63 nsresult rv
= ListenToMouseMoveEventForResizersOrGrabber(aListen
, true);
64 NS_WARNING_ASSERTION(NS_SUCCEEDED(rv
),
65 "HTMLEditorEventListener::"
66 "ListenToMouseMoveEventForResizersOrGrabber() failed");
71 * ListenToWindowResizeEvent() starts to listen to or stop listening to
72 * "resize" events of the document.
74 nsresult
ListenToWindowResizeEvent(bool aListen
);
77 MOZ_CAN_RUN_SCRIPT
virtual nsresult
MouseDown(
78 dom::MouseEvent
* aMouseEvent
) override
;
79 MOZ_CAN_RUN_SCRIPT
virtual nsresult
MouseUp(
80 dom::MouseEvent
* aMouseEvent
) override
;
81 MOZ_CAN_RUN_SCRIPT
virtual nsresult
MouseClick(
82 WidgetMouseEvent
* aMouseClickEvent
) override
;
84 nsresult
ListenToMouseMoveEventForResizersOrGrabber(bool aListen
,
87 MOZ_CAN_RUN_SCRIPT nsresult
HandlePrimaryMouseButtonDown(
88 HTMLEditor
& aHTMLEditor
, dom::MouseEvent
& aMouseEvent
);
89 MOZ_CAN_RUN_SCRIPT nsresult
HandleSecondaryMouseButtonDown(
90 HTMLEditor
& aHTMLEditor
, dom::MouseEvent
& aMouseEvent
);
92 bool mListeningToMouseMoveEventForResizers
;
93 bool mListeningToMouseMoveEventForGrabber
;
94 bool mListeningToResizeEvent
;
97 } // namespace mozilla
99 #endif // #ifndef HTMLEditorEventListener_h