Bug 1337718 part.2 Make EditorEventListener::ShouldHandleNativeKeyBindings() take WidgetKeyboardEvent* instead of nsIDOMKeyEvent* r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 08 Feb 2017 19:47:05 +0900
changeset 481122 0c6cb143f82a7fff489e8db48e1169ab81553b40
parent 481121 fa893701b2c6dffd7898858b3211decbda66095e
child 481123 9dd0a33b19cadd8e9e0f916de01f8be28e7b40d4
push id44730
push usermasayuki@d-toybox.com
push dateThu, 09 Feb 2017 09:50:16 +0000
reviewersm_kato
bugs1337718
milestone54.0a1
Bug 1337718 part.2 Make EditorEventListener::ShouldHandleNativeKeyBindings() take WidgetKeyboardEvent* instead of nsIDOMKeyEvent* r?m_kato MozReview-Commit-ID: 4JS2yJ6iXgY
editor/libeditor/EditorEventListener.cpp
editor/libeditor/EditorEventListener.h
--- 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;