4
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
6
7
- #include " nsEditorEventListener .h"
7
+ #include " EditorEventListener .h"
8
8
9
9
#include " mozilla/Assertions.h" // for MOZ_ASSERT, etc
10
10
#include " mozilla/EventListenerManager.h" // for EventListenerManager
64
64
65
65
class nsPresContext ;
66
66
67
- using namespace mozilla ;
68
- using namespace mozilla ::dom;
67
+ namespace mozilla {
68
+
69
+ using namespace dom ;
69
70
70
71
static void
71
72
DoCommandCallback (Command aCommand, void * aData)
@@ -96,7 +97,7 @@ DoCommandCallback(Command aCommand, void* aData)
96
97
}
97
98
}
98
99
99
- nsEditorEventListener::nsEditorEventListener ()
100
+ EditorEventListener::EditorEventListener ()
100
101
: mEditor (nullptr )
101
102
, mCommitText (false )
102
103
, mInTransaction (false )
@@ -109,7 +110,7 @@ nsEditorEventListener::nsEditorEventListener()
109
110
{
110
111
}
111
112
112
- nsEditorEventListener ::~nsEditorEventListener ()
113
+ EditorEventListener ::~EditorEventListener ()
113
114
{
114
115
if (mEditor ) {
115
116
NS_WARNING (" We're not uninstalled" );
@@ -118,7 +119,7 @@ nsEditorEventListener::~nsEditorEventListener()
118
119
}
119
120
120
121
nsresult
121
- nsEditorEventListener ::Connect (nsEditor* aEditor)
122
+ EditorEventListener ::Connect (nsEditor* aEditor)
122
123
{
123
124
NS_ENSURE_ARG (aEditor);
124
125
@@ -141,7 +142,7 @@ nsEditorEventListener::Connect(nsEditor* aEditor)
141
142
}
142
143
143
144
nsresult
144
- nsEditorEventListener ::InstallToEditor ()
145
+ EditorEventListener ::InstallToEditor ()
145
146
{
146
147
NS_PRECONDITION (mEditor , " The caller must set mEditor" );
147
148
@@ -211,7 +212,7 @@ nsEditorEventListener::InstallToEditor()
211
212
}
212
213
213
214
void
214
- nsEditorEventListener ::Disconnect ()
215
+ EditorEventListener ::Disconnect ()
215
216
{
216
217
if (!mEditor ) {
217
218
return ;
@@ -236,7 +237,7 @@ nsEditorEventListener::Disconnect()
236
237
}
237
238
238
239
void
239
- nsEditorEventListener ::UninstallFromEditor ()
240
+ EditorEventListener ::UninstallFromEditor ()
240
241
{
241
242
nsCOMPtr<EventTarget> piTarget = mEditor ->GetDOMEventTarget ();
242
243
if (!piTarget) {
@@ -298,22 +299,22 @@ nsEditorEventListener::UninstallFromEditor()
298
299
}
299
300
300
301
already_AddRefed<nsIPresShell>
301
- nsEditorEventListener ::GetPresShell ()
302
+ EditorEventListener ::GetPresShell ()
302
303
{
303
304
NS_PRECONDITION (mEditor ,
304
305
" The caller must check whether this is connected to an editor" );
305
306
return mEditor ->GetPresShell ();
306
307
}
307
308
308
309
nsPresContext*
309
- nsEditorEventListener ::GetPresContext ()
310
+ EditorEventListener ::GetPresContext ()
310
311
{
311
312
nsCOMPtr<nsIPresShell> presShell = GetPresShell ();
312
313
return presShell ? presShell->GetPresContext () : nullptr ;
313
314
}
314
315
315
316
nsIContent*
316
- nsEditorEventListener ::GetFocusedRootContent ()
317
+ EditorEventListener ::GetFocusedRootContent ()
317
318
{
318
319
NS_ENSURE_TRUE (mEditor , nullptr );
319
320
@@ -333,7 +334,7 @@ nsEditorEventListener::GetFocusedRootContent()
333
334
}
334
335
335
336
bool
336
- nsEditorEventListener ::EditorHasFocus ()
337
+ EditorEventListener ::EditorHasFocus ()
337
338
{
338
339
NS_PRECONDITION (mEditor ,
339
340
" The caller must check whether this is connected to an editor" );
@@ -345,18 +346,10 @@ nsEditorEventListener::EditorHasFocus()
345
346
return !!composedDoc;
346
347
}
347
348
348
- /* *
349
- * nsISupports implementation
350
- */
351
-
352
- NS_IMPL_ISUPPORTS (nsEditorEventListener, nsIDOMEventListener)
353
-
354
- /* *
355
- * nsIDOMEventListener implementation
356
- */
349
+ NS_IMPL_ISUPPORTS (EditorEventListener, nsIDOMEventListener)
357
350
358
351
NS_IMETHODIMP
359
- nsEditorEventListener ::HandleEvent(nsIDOMEvent* aEvent)
352
+ EditorEventListener ::HandleEvent (nsIDOMEvent* aEvent)
360
353
{
361
354
NS_ENSURE_TRUE (mEditor , NS_ERROR_FAILURE);
362
355
@@ -416,7 +409,7 @@ nsEditorEventListener::HandleEvent(nsIDOMEvent* aEvent)
416
409
case eMouseDown: {
417
410
nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface (aEvent);
418
411
NS_ENSURE_TRUE (mouseEvent, NS_OK);
419
- // nsEditorEventListener may receive (1) all mousedown, mouseup and click
412
+ // EditorEventListener may receive (1) all mousedown, mouseup and click
420
413
// events, (2) only mousedown event or (3) only mouseup event.
421
414
// mMouseDownOrUpConsumedByIME is used only for ignoring click event if
422
415
// preceding mousedown and/or mouseup event is consumed by IME.
@@ -433,7 +426,7 @@ nsEditorEventListener::HandleEvent(nsIDOMEvent* aEvent)
433
426
// See above comment in the eMouseDown case, first.
434
427
// This code assumes that case #1 is occuring. However, if case #3 may
435
428
// occurs after case #2 and the mousedown is consumed,
436
- // mMouseDownOrUpConsumedByIME is true even though nsEditorEventListener
429
+ // mMouseDownOrUpConsumedByIME is true even though EditorEventListener
437
430
// has not received the preceding mousedown event of this mouseup event.
438
431
// So, mMouseDownOrUpConsumedByIME may be invalid here. However,
439
432
// this is not a matter because mMouseDownOrUpConsumedByIME is referred
@@ -545,7 +538,7 @@ bool IsCtrlShiftPressed(nsIDOMKeyEvent* aEvent, bool& isRTL)
545
538
// RenderWidgetHostViewWin::OnKeyEvent.
546
539
547
540
nsresult
548
- nsEditorEventListener ::KeyUp (nsIDOMKeyEvent* aKeyEvent)
541
+ EditorEventListener ::KeyUp (nsIDOMKeyEvent* aKeyEvent)
549
542
{
550
543
NS_ENSURE_TRUE (aKeyEvent, NS_OK);
551
544
@@ -567,7 +560,7 @@ nsEditorEventListener::KeyUp(nsIDOMKeyEvent* aKeyEvent)
567
560
}
568
561
569
562
nsresult
570
- nsEditorEventListener ::KeyDown (nsIDOMKeyEvent* aKeyEvent)
563
+ EditorEventListener ::KeyDown (nsIDOMKeyEvent* aKeyEvent)
571
564
{
572
565
NS_ENSURE_TRUE (aKeyEvent, NS_OK);
573
566
@@ -592,7 +585,7 @@ nsEditorEventListener::KeyDown(nsIDOMKeyEvent* aKeyEvent)
592
585
#endif
593
586
594
587
nsresult
595
- nsEditorEventListener ::KeyPress (nsIDOMKeyEvent* aKeyEvent)
588
+ EditorEventListener ::KeyPress (nsIDOMKeyEvent* aKeyEvent)
596
589
{
597
590
NS_ENSURE_TRUE (aKeyEvent, NS_OK);
598
591
@@ -649,7 +642,7 @@ nsEditorEventListener::KeyPress(nsIDOMKeyEvent* aKeyEvent)
649
642
}
650
643
651
644
nsresult
652
- nsEditorEventListener ::MouseClick (nsIDOMMouseEvent* aMouseEvent)
645
+ EditorEventListener ::MouseClick (nsIDOMMouseEvent* aMouseEvent)
653
646
{
654
647
// nothing to do if editor isn't editable or clicked on out of the editor.
655
648
if (mEditor ->IsReadonly () || mEditor ->IsDisabled () ||
@@ -687,7 +680,7 @@ nsEditorEventListener::MouseClick(nsIDOMMouseEvent* aMouseEvent)
687
680
}
688
681
689
682
nsresult
690
- nsEditorEventListener ::HandleMiddleClickPaste (nsIDOMMouseEvent* aMouseEvent)
683
+ EditorEventListener ::HandleMiddleClickPaste (nsIDOMMouseEvent* aMouseEvent)
691
684
{
692
685
if (!Preferences::GetBool (" middlemouse.paste" , false )) {
693
686
// Middle click paste isn't enabled.
@@ -747,8 +740,8 @@ nsEditorEventListener::HandleMiddleClickPaste(nsIDOMMouseEvent* aMouseEvent)
747
740
}
748
741
749
742
bool
750
- nsEditorEventListener ::NotifyIMEOfMouseButtonEvent (
751
- nsIDOMMouseEvent* aMouseEvent)
743
+ EditorEventListener ::NotifyIMEOfMouseButtonEvent (
744
+ nsIDOMMouseEvent* aMouseEvent)
752
745
{
753
746
if (!EditorHasFocus ()) {
754
747
return false ;
@@ -768,7 +761,7 @@ nsEditorEventListener::NotifyIMEOfMouseButtonEvent(
768
761
}
769
762
770
763
nsresult
771
- nsEditorEventListener ::MouseDown (nsIDOMMouseEvent* aMouseEvent)
764
+ EditorEventListener ::MouseDown (nsIDOMMouseEvent* aMouseEvent)
772
765
{
773
766
// FYI: This may be called by HTMLEditorEventListener::MouseDown() even
774
767
// when the event is not acceptable for committing composition.
@@ -777,7 +770,7 @@ nsEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
777
770
}
778
771
779
772
nsresult
780
- nsEditorEventListener ::HandleText (nsIDOMEvent* aTextEvent)
773
+ EditorEventListener ::HandleText (nsIDOMEvent* aTextEvent)
781
774
{
782
775
if (!mEditor ->IsAcceptableInputEvent (aTextEvent)) {
783
776
return NS_OK;
@@ -796,7 +789,7 @@ nsEditorEventListener::HandleText(nsIDOMEvent* aTextEvent)
796
789
*/
797
790
798
791
nsresult
799
- nsEditorEventListener ::DragEnter (nsIDOMDragEvent* aDragEvent)
792
+ EditorEventListener ::DragEnter (nsIDOMDragEvent* aDragEvent)
800
793
{
801
794
NS_ENSURE_TRUE (aDragEvent, NS_OK);
802
795
@@ -819,7 +812,7 @@ nsEditorEventListener::DragEnter(nsIDOMDragEvent* aDragEvent)
819
812
}
820
813
821
814
nsresult
822
- nsEditorEventListener ::DragOver (nsIDOMDragEvent* aDragEvent)
815
+ EditorEventListener ::DragOver (nsIDOMDragEvent* aDragEvent)
823
816
{
824
817
NS_ENSURE_TRUE (aDragEvent, NS_OK);
825
818
@@ -864,7 +857,7 @@ nsEditorEventListener::DragOver(nsIDOMDragEvent* aDragEvent)
864
857
}
865
858
866
859
void
867
- nsEditorEventListener ::CleanupDragDropCaret ()
860
+ EditorEventListener ::CleanupDragDropCaret ()
868
861
{
869
862
if (!mCaret ) {
870
863
return ;
@@ -882,7 +875,7 @@ nsEditorEventListener::CleanupDragDropCaret()
882
875
}
883
876
884
877
nsresult
885
- nsEditorEventListener ::DragExit (nsIDOMDragEvent* aDragEvent)
878
+ EditorEventListener ::DragExit (nsIDOMDragEvent* aDragEvent)
886
879
{
887
880
NS_ENSURE_TRUE (aDragEvent, NS_OK);
888
881
@@ -892,7 +885,7 @@ nsEditorEventListener::DragExit(nsIDOMDragEvent* aDragEvent)
892
885
}
893
886
894
887
nsresult
895
- nsEditorEventListener ::Drop (nsIDOMDragEvent* aDragEvent)
888
+ EditorEventListener ::Drop (nsIDOMDragEvent* aDragEvent)
896
889
{
897
890
NS_ENSURE_TRUE (aDragEvent, NS_OK);
898
891
@@ -928,7 +921,7 @@ nsEditorEventListener::Drop(nsIDOMDragEvent* aDragEvent)
928
921
}
929
922
930
923
bool
931
- nsEditorEventListener ::CanDrop (nsIDOMDragEvent* aEvent)
924
+ EditorEventListener ::CanDrop (nsIDOMDragEvent* aEvent)
932
925
{
933
926
// if the target doc is read-only, we can't drop
934
927
if (mEditor ->IsReadonly () || mEditor ->IsDisabled ()) {
@@ -1030,7 +1023,7 @@ nsEditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
1030
1023
}
1031
1024
1032
1025
nsresult
1033
- nsEditorEventListener ::HandleStartComposition (nsIDOMEvent* aCompositionEvent)
1026
+ EditorEventListener ::HandleStartComposition (nsIDOMEvent* aCompositionEvent)
1034
1027
{
1035
1028
if (!mEditor ->IsAcceptableInputEvent (aCompositionEvent)) {
1036
1029
return NS_OK;
@@ -1041,7 +1034,7 @@ nsEditorEventListener::HandleStartComposition(nsIDOMEvent* aCompositionEvent)
1041
1034
}
1042
1035
1043
1036
void
1044
- nsEditorEventListener ::HandleEndComposition (nsIDOMEvent* aCompositionEvent)
1037
+ EditorEventListener ::HandleEndComposition (nsIDOMEvent* aCompositionEvent)
1045
1038
{
1046
1039
if (!mEditor ->IsAcceptableInputEvent (aCompositionEvent)) {
1047
1040
return ;
@@ -1051,7 +1044,7 @@ nsEditorEventListener::HandleEndComposition(nsIDOMEvent* aCompositionEvent)
1051
1044
}
1052
1045
1053
1046
nsresult
1054
- nsEditorEventListener ::Focus (nsIDOMEvent* aEvent)
1047
+ EditorEventListener ::Focus (nsIDOMEvent* aEvent)
1055
1048
{
1056
1049
NS_ENSURE_TRUE (aEvent, NS_OK);
1057
1050
@@ -1115,7 +1108,7 @@ nsEditorEventListener::Focus(nsIDOMEvent* aEvent)
1115
1108
}
1116
1109
1117
1110
nsresult
1118
- nsEditorEventListener ::Blur (nsIDOMEvent* aEvent)
1111
+ EditorEventListener ::Blur (nsIDOMEvent* aEvent)
1119
1112
{
1120
1113
NS_ENSURE_TRUE (aEvent, NS_OK);
1121
1114
@@ -1133,7 +1126,7 @@ nsEditorEventListener::Blur(nsIDOMEvent* aEvent)
1133
1126
}
1134
1127
1135
1128
void
1136
- nsEditorEventListener ::SpellCheckIfNeeded ()
1129
+ EditorEventListener ::SpellCheckIfNeeded ()
1137
1130
{
1138
1131
// If the spell check skip flag is still enabled from creation time,
1139
1132
// disable it because focused editors are allowed to spell check.
@@ -1146,7 +1139,7 @@ nsEditorEventListener::SpellCheckIfNeeded()
1146
1139
}
1147
1140
1148
1141
bool
1149
- nsEditorEventListener ::IsFileControlTextBox ()
1142
+ EditorEventListener ::IsFileControlTextBox ()
1150
1143
{
1151
1144
dom::Element* root = mEditor ->GetRoot ();
1152
1145
if (!root || !root->ChromeOnlyAccess ()) {
@@ -1161,7 +1154,7 @@ nsEditorEventListener::IsFileControlTextBox()
1161
1154
}
1162
1155
1163
1156
bool
1164
- nsEditorEventListener ::ShouldHandleNativeKeyBindings (nsIDOMKeyEvent* aKeyEvent)
1157
+ EditorEventListener ::ShouldHandleNativeKeyBindings (nsIDOMKeyEvent* aKeyEvent)
1165
1158
{
1166
1159
// Only return true if the target of the event is a desendant of the active
1167
1160
// editing host in order to match the similar decision made in
@@ -1197,3 +1190,5 @@ nsEditorEventListener::ShouldHandleNativeKeyBindings(nsIDOMKeyEvent* aKeyEvent)
1197
1190
1198
1191
return nsContentUtils::ContentIsDescendantOf (targetContent, editingHost);
1199
1192
}
1193
+
1194
+ } // namespace mozilla
0 commit comments