Bug 1467670 - Devirtualize InsertFromDrop. r=masayuki
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Fri, 08 Jun 2018 05:19:51 +0000
changeset 478609 f86b968525a8a9b21abb87fc75ac28f454417fb5
parent 478608 7eb872d2f548c167e82454fef02354619cfcb754
child 478610 1f16a2ff45ab492025e42afb8122f4d52cb24c0b
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1467670
milestone62.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 1467670 - Devirtualize InsertFromDrop. r=masayuki InsertFromDrop is implemented on TextEditor only, so it can do devirtualize this method. Also, this method is only called by drop event handler of EditorEventListener, so it should rename to better name (OnDrop). Differential Revision: https://phabricator.services.mozilla.com/D1592
editor/libeditor/EditorBase.h
editor/libeditor/EditorEventListener.cpp
editor/libeditor/TextEditor.h
editor/libeditor/TextEditorDataTransfer.cpp
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -655,18 +655,16 @@ public:
 
   /**
    * This method has to be called by EditorEventListener::Focus.
    * All actions that have to be done when the editor is focused needs to be
    * added here.
    */
   void OnFocus(dom::EventTarget* aFocusEventTarget);
 
-  virtual nsresult InsertFromDrop(dom::DragEvent* aDropEvent) = 0;
-
   /** Resyncs spellchecking state (enabled/disabled).  This should be called
     * when anything that affects spellchecking state changes, such as the
     * spellcheck attribute value.
     */
   void SyncRealTimeSpell();
 
 protected: // May be called by friends.
   /****************************************************************************
--- a/editor/libeditor/EditorEventListener.cpp
+++ b/editor/libeditor/EditorEventListener.cpp
@@ -893,18 +893,18 @@ EditorEventListener::Drop(DragEvent* aDr
       // editfields if that is what is desired.
       aDragEvent->StopPropagation();
     }
     return NS_OK;
   }
 
   aDragEvent->StopPropagation();
   aDragEvent->PreventDefault();
-  RefPtr<EditorBase> editorBase(mEditorBase);
-  return editorBase->InsertFromDrop(aDragEvent);
+  RefPtr<TextEditor> textEditor = mEditorBase->AsTextEditor();
+  return textEditor->OnDrop(aDragEvent);
 }
 
 bool
 EditorEventListener::CanDrop(DragEvent* aEvent)
 {
   MOZ_ASSERT(!DetachedFromEditorOrDefaultPrevented(
                 aEvent->WidgetEventPtr()));
 
--- a/editor/libeditor/TextEditor.h
+++ b/editor/libeditor/TextEditor.h
@@ -167,16 +167,22 @@ public:
 
   /**
    * OnCompositionEnd() is called when editor receives an eCompositionChange
    * event and it's followed by eCompositionEnd event and after
    * OnCompositionChange() is called.
    */
   void OnCompositionEnd(WidgetCompositionEvent& aCompositionEndEvent);
 
+  /**
+   * OnDrop() is called from EditorEventListener::Drop that is handler of drop
+   * event.
+   */
+  nsresult OnDrop(dom::DragEvent* aDropEvent);
+
 protected: // May be called by friends.
   /****************************************************************************
    * Some classes like TextEditRules, HTMLEditRules, WSRunObject which are
    * part of handling edit actions are allowed to call the following protected
    * methods.  However, those methods won't prepare caches of some objects
    * which are necessary for them.  So, if you want some following methods
    * to do that for you, you need to create a wrapper method in public scope
    * and call it.
@@ -189,18 +195,16 @@ protected: // May be called by friends.
                      bool aSuppressTransaction) override;
   virtual nsresult SetAttributeOrEquivalent(Element* aElement,
                                             nsAtom* aAttribute,
                                             const nsAString& aValue,
                                             bool aSuppressTransaction) override;
   using EditorBase::RemoveAttributeOrEquivalent;
   using EditorBase::SetAttributeOrEquivalent;
 
-  virtual nsresult InsertFromDrop(dom::DragEvent* aDropEvent) override;
-
   /**
    * DeleteSelectionWithTransaction() removes selected content or content
    * around caret with transactions.
    *
    * @param aDirection          How much range should be removed.
    * @param aStripWrappers      Whether the parent blocks should be removed
    *                            when they become empty.
    */
--- a/editor/libeditor/TextEditorDataTransfer.cpp
+++ b/editor/libeditor/TextEditorDataTransfer.cpp
@@ -158,17 +158,17 @@ TextEditor::InsertFromDataTransfer(DataT
     AutoPlaceholderBatch beginBatching(this);
     return InsertTextAt(insertText, aDestinationNode, aDestOffset, aDoDeleteSelection);
   }
 
   return NS_OK;
 }
 
 nsresult
-TextEditor::InsertFromDrop(DragEvent* aDropEvent)
+TextEditor::OnDrop(DragEvent* aDropEvent)
 {
   CommitComposition();
 
   NS_ENSURE_TRUE(aDropEvent, NS_ERROR_FAILURE);
 
   RefPtr<DataTransfer> dataTransfer = aDropEvent->GetDataTransfer();
   NS_ENSURE_TRUE(dataTransfer, NS_ERROR_FAILURE);