Bug 1337718 part.4 Make EditorEventListener::KeyUp() take const WidgetKeyboardEvent* instead of nsIDOMKeyEvent* r?m_kato
MozReview-Commit-ID: K9zCJsYgfbL
--- a/editor/libeditor/EditorEventListener.cpp
+++ b/editor/libeditor/EditorEventListener.cpp
@@ -395,20 +395,18 @@ EditorEventListener::HandleEvent(nsIDOME
}
#ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
// keydown
case eKeyDown: {
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aEvent);
return KeyDown(keyEvent);
}
// keyup
- case eKeyUp: {
- nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aEvent);
- return KeyUp(keyEvent);
- }
+ case eKeyUp:
+ return KeyUp(internalEvent->AsKeyboardEvent());
#endif // #ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
// keypress
case eKeyPress:
return KeyPress(internalEvent->AsKeyboardEvent());
// mousedown
case eMouseDown: {
nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aEvent);
NS_ENSURE_TRUE(mouseEvent, NS_OK);
@@ -538,32 +536,30 @@ bool IsCtrlShiftPressed(nsIDOMKeyEvent*
}
}
// This logic is mostly borrowed from Chromium's
// RenderWidgetHostViewWin::OnKeyEvent.
nsresult
-EditorEventListener::KeyUp(nsIDOMKeyEvent* aKeyEvent)
+EditorEventListener::KeyUp(const WidgetKeyboardEvent* aKeyboardEvent)
{
- if (NS_WARN_IF(!aKeyEvent) || DetachedFromEditor()) {
+ if (NS_WARN_IF(!aKeyboardEvent) || DetachedFromEditor()) {
return NS_OK;
}
if (!mHaveBidiKeyboards) {
return NS_OK;
}
// XXX Why doesn't this method check if it's consumed?
RefPtr<EditorBase> editorBase(mEditorBase);
- uint32_t keyCode = 0;
- aKeyEvent->GetKeyCode(&keyCode);
- if ((keyCode == nsIDOMKeyEvent::DOM_VK_SHIFT ||
- keyCode == nsIDOMKeyEvent::DOM_VK_CONTROL) &&
+ if ((aKeyboardEvent->mKeyCode == NS_VK_SHIFT ||
+ aKeyboardEvent->mKeyCode == NS_VK_CONTROL) &&
mShouldSwitchTextDirection && editorBase->IsPlaintextEditor()) {
editorBase->SwitchTextDirectionTo(mSwitchToRTL ?
nsIPlaintextEditor::eEditorRightToLeft :
nsIPlaintextEditor::eEditorLeftToRight);
mShouldSwitchTextDirection = false;
}
return NS_OK;
}
--- a/editor/libeditor/EditorEventListener.h
+++ b/editor/libeditor/EditorEventListener.h
@@ -53,17 +53,17 @@ public:
protected:
virtual ~EditorEventListener();
nsresult InstallToEditor();
void UninstallFromEditor();
#ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
nsresult KeyDown(nsIDOMKeyEvent* aKeyEvent);
- nsresult KeyUp(nsIDOMKeyEvent* aKeyEvent);
+ nsresult KeyUp(const WidgetKeyboardEvent* aKeyboardEvent);
#endif
nsresult KeyPress(WidgetKeyboardEvent* aKeyboardEvent);
nsresult HandleChangeComposition(WidgetCompositionEvent* aCompositionEvent);
nsresult HandleStartComposition(WidgetCompositionEvent* aCompositionEvent);
void HandleEndComposition(WidgetCompositionEvent* aCompositionEvent);
virtual nsresult MouseDown(nsIDOMMouseEvent* aMouseEvent);
virtual nsresult MouseUp(nsIDOMMouseEvent* aMouseEvent) { return NS_OK; }
virtual nsresult MouseClick(nsIDOMMouseEvent* aMouseEvent);