Bug 1337718 part.2 Make EditorEventListener::ShouldHandleNativeKeyBindings() take WidgetKeyboardEvent* instead of nsIDOMKeyEvent* r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 08 Feb 2017 19:47:05 +0900
changeset 388396 a07723fd11f17a9446cfb1626c17b9acc5657b7f
parent 388395 2888f135c73709ed5e1582c55cdab2eee9c8d3be
child 388397 331fad29a7c4f735861f5130be935cba0307c730
push id7198
push userjlorenzo@mozilla.com
push dateTue, 18 Apr 2017 12:07:49 +0000
treeherdermozilla-beta@d57aa49c3948 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1337718
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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;