Bug 1337718 part.2 Make EditorEventListener::ShouldHandleNativeKeyBindings() take WidgetKeyboardEvent* instead of nsIDOMKeyEvent* r?m_kato
MozReview-Commit-ID: 4JS2yJ6iXgY
--- a/editor/libeditor/EditorEventListener.cpp
+++ b/editor/libeditor/EditorEventListener.cpp
@@ -616,17 +616,17 @@ EditorEventListener::KeyPress(nsIDOMKeyE
}
nsresult rv = editorBase->HandleKeyPressEvent(keypressEvent);
NS_ENSURE_SUCCESS(rv, rv);
if (DetachedFromEditorOrDefaultPrevented(keypressEvent)) {
return NS_OK;
}
- if (!ShouldHandleNativeKeyBindings(aKeyEvent)) {
+ if (!ShouldHandleNativeKeyBindings(keypressEvent)) {
return NS_OK;
}
// Now, ask the native key bindings to handle the event.
nsIWidget* widget = keypressEvent->mWidget;
// If the event is created by chrome script, the widget is always nullptr.
if (!widget) {
nsCOMPtr<nsIPresShell> ps = GetPresShell();
@@ -1233,30 +1233,30 @@ EditorEventListener::IsFileControlTextBo
if (!parent || !parent->IsHTMLElement(nsGkAtoms::input)) {
return false;
}
nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(parent);
return formControl->GetType() == NS_FORM_INPUT_FILE;
}
bool
-EditorEventListener::ShouldHandleNativeKeyBindings(nsIDOMKeyEvent* aKeyEvent)
+EditorEventListener::ShouldHandleNativeKeyBindings(
+ WidgetKeyboardEvent* aKeyboardEvent)
{
MOZ_ASSERT(!DetachedFromEditor());
// Only return true if the target of the event is a desendant of the active
// editing host in order to match the similar decision made in
// nsXBLWindowKeyHandler.
// Note that IsAcceptableInputEvent doesn't check for the active editing
// host for keyboard events, otherwise this check would have been
// unnecessary. IsAcceptableInputEvent currently makes a similar check for
// mouse events.
- nsCOMPtr<nsIDOMEventTarget> target;
- aKeyEvent->AsEvent()->GetTarget(getter_AddRefs(target));
+ nsCOMPtr<nsIDOMEventTarget> target = aKeyboardEvent->GetDOMEventTarget();
nsCOMPtr<nsIContent> targetContent = do_QueryInterface(target);
if (!targetContent) {
return false;
}
RefPtr<EditorBase> editorBase(mEditorBase);
nsCOMPtr<nsIHTMLEditor> htmlEditor =
do_QueryInterface(static_cast<nsIEditor*>(editorBase));
--- a/editor/libeditor/EditorEventListener.h
+++ b/editor/libeditor/EditorEventListener.h
@@ -78,17 +78,17 @@ protected:
void CleanupDragDropCaret();
already_AddRefed<nsIPresShell> GetPresShell();
nsPresContext* GetPresContext();
nsIContent* GetFocusedRootContent();
// Returns true if IME consumes the mouse event.
bool NotifyIMEOfMouseButtonEvent(nsIDOMMouseEvent* aMouseEvent);
bool EditorHasFocus();
bool IsFileControlTextBox();
- bool ShouldHandleNativeKeyBindings(nsIDOMKeyEvent* aKeyEvent);
+ bool ShouldHandleNativeKeyBindings(WidgetKeyboardEvent* aKeyboardEvent);
nsresult HandleMiddleClickPaste(nsIDOMMouseEvent* aMouseEvent);
/**
* DetachedFromEditor() returns true if editor was detached.
* Otherwise, false.
*/
bool DetachedFromEditor() const;