Bug 1397178 - Make EditorBase::GetRoot() not call nsIEditor::GetRootElement() r?smaug draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 05 Sep 2017 23:32:17 +0900
changeset 659725 77a0de0e55d42f82b26d80c3171d1f1d7f3c4c28
parent 659724 550a96ab3ad7d815882c5b8062630c5058a1be74
child 730045 48df5e2da2c9c72dff03f7ee86b060d0f44b9a3b
push id78191
push usermasayuki@d-toybox.com
push dateWed, 06 Sep 2017 08:31:48 +0000
reviewerssmaug
bugs1397178
milestone57.0a1
Bug 1397178 - Make EditorBase::GetRoot() not call nsIEditor::GetRootElement() r?smaug In the old design, EditorBase::mRootElement is initialized when nsIEditor::GetRootElement() is called. Therefore, EditorBase::GetRoot() calls if mRootElement is nullptr. However, mRootElement is now initialized when EditorBase::UpdateRootElement() is called and it's always initialized when EditorBase::Init() is called. So, EditorBase::GetRoot() doesn't need to call nsIEditor::GetRootElement() anymore. MozReview-Commit-ID: 6dNEJaGNMZe
editor/libeditor/EditorBase.h
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -967,26 +967,17 @@ public:
                                   nsIDOMNode* aEndContainer,
                                   int32_t aEndOffset);
 
   virtual already_AddRefed<dom::EventTarget> GetDOMEventTarget() = 0;
 
   /**
    * Fast non-refcounting editor root element accessor
    */
-  Element* GetRoot()
-  {
-    if (!mRootElement) {
-      // Let GetRootElement() do the work
-      nsCOMPtr<nsIDOMElement> root;
-      GetRootElement(getter_AddRefs(root));
-    }
-
-    return mRootElement;
-  }
+  Element* GetRoot() const { return mRootElement; }
 
   /**
    * Likewise, but gets the editor's root instead, which is different for HTML
    * editors.
    */
   virtual Element* GetEditorRoot();
 
   /**