Bug 1467691 - Make some methods of EditorBase non-public r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 06 Jun 2018 13:30:44 +0900
changeset 805643 96ba8e87cee72a7d01d901ef030ffe7724b6217c
parent 805642 d387662706750000bcd658dee27d470266182ec5
push id112724
push usermasayuki@d-toybox.com
push dateFri, 08 Jun 2018 07:25:52 +0000
reviewersm_kato
bugs1467691
milestone62.0a1
Bug 1467691 - Make some methods of EditorBase non-public r?m_kato This moves NotifyEditorObservers() and GetInputEventTargetContent() into protected member which should not be used by friends. And also this moves IsModifiableNode() into protected member which can be used by friends. MozReview-Commit-ID: AxDBgTVED3V
editor/libeditor/EditorBase.h
editor/libeditor/HTMLEditor.h
editor/libeditor/TextEditor.h
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -307,38 +307,28 @@ public:
 
   /**
    * Fast non-refcounting editor root element accessor
    */
   Element* GetRoot() const { return mRootElement; }
 
   RangeUpdater& RangeUpdaterRef() { return mRangeUpdater; }
 
-  enum NotificationForEditorObservers
-  {
-    eNotifyEditorObserversOfEnd,
-    eNotifyEditorObserversOfBefore,
-    eNotifyEditorObserversOfCancel
-  };
-  void NotifyEditorObservers(NotificationForEditorObservers aNotification);
-
   /**
    * Set or unset TextInputListener.  If setting non-nullptr when the editor
    * already has a TextInputListener, this will crash in debug build.
    */
   void SetTextInputListener(TextInputListener* aTextInputListener);
 
   /**
    * Set or unset IMEContentObserver.  If setting non-nullptr when the editor
    * already has an IMEContentObserver, this will crash in debug build.
    */
   void SetIMEContentObserver(IMEContentObserver* aIMEContentObserver);
 
-  virtual bool IsModifiableNode(nsINode* aNode);
-
   /**
    * Returns current composition.
    */
   TextComposition* GetComposition() const;
 
   /**
    * Get preferred IME status of current widget.
    */
@@ -616,21 +606,16 @@ public:
   bool OutputsMozDirty() const
   {
     // Return true for Composer (!IsInteractionAllowed()) or mail
     // (IsMailEditor()), but false for webpages.
     return !IsInteractionAllowed() || IsMailEditor();
   }
 
   /**
-   * Get the input event target. This might return null.
-   */
-  virtual already_AddRefed<nsIContent> GetInputEventTargetContent() = 0;
-
-  /**
    * Get the focused content, if we're focused.  Returns null otherwise.
    */
   virtual nsIContent* GetFocusedContent();
 
   /**
    * Get the focused content for the argument of some IMEStateManager's
    * methods.
    */
@@ -1493,16 +1478,18 @@ protected: // May be called by friends.
    */
   virtual bool AreNodesSameType(nsIContent* aNode1, nsIContent* aNode2);
 
   static bool IsTextNode(nsINode* aNode)
   {
     return aNode->NodeType() == nsINode::TEXT_NODE;
   }
 
+  virtual bool IsModifiableNode(nsINode* aNode);
+
   /**
    * GetNodeAtRangeOffsetPoint() returns the node at this position in a range,
    * assuming that the container is the node itself if it's a text node, or
    * the node's parent otherwise.
    */
   static nsIContent* GetNodeAtRangeOffsetPoint(nsINode* aContainer,
                                                int32_t aOffset)
   {
@@ -1750,16 +1737,21 @@ protected: // Shouldn't be used by frien
                                   bool aNoBlockCrossing);
 
 
   virtual nsresult InstallEventListeners();
   virtual void CreateEventListeners();
   virtual void RemoveEventListeners();
 
   /**
+   * Get the input event target. This might return null.
+   */
+  virtual already_AddRefed<nsIContent> GetInputEventTargetContent() = 0;
+
+  /**
    * Return true if spellchecking should be enabled for this editor.
    */
   bool GetDesiredSpellCheckState();
 
   bool CanEnableSpellCheck()
   {
     // Check for password/readonly/disabled, which are not spellchecked
     // regardless of DOM. Also, check to see if spell check should be skipped
@@ -1817,16 +1809,24 @@ protected: // Shouldn't be used by frien
    */
   virtual nsresult InsertFromDataTransfer(dom::DataTransfer* aDataTransfer,
                                           int32_t aIndex,
                                           nsIDocument* aSourceDoc,
                                           nsINode* aDestinationNode,
                                           int32_t aDestOffset,
                                           bool aDoDeleteSelection) = 0;
 
+  enum NotificationForEditorObservers
+  {
+    eNotifyEditorObserversOfEnd,
+    eNotifyEditorObserversOfBefore,
+    eNotifyEditorObserversOfCancel
+  };
+  void NotifyEditorObservers(NotificationForEditorObservers aNotification);
+
 private:
   nsCOMPtr<nsISelectionController> mSelectionController;
   nsCOMPtr<nsIDocument> mDocument;
 
 protected:
   enum Tristate
   {
     eTriUnset,
@@ -1919,16 +1919,17 @@ protected:
   friend class AutoPlaceholderBatch;
   friend class AutoSelectionRestorer;
   friend class AutoTopLevelEditSubActionNotifier;
   friend class AutoTransactionsConserveSelection;
   friend class AutoUpdateViewBatch;
   friend class CompositionTransaction;
   friend class CreateElementTransaction;
   friend class CSSEditUtils;
+  friend class DeleteNodeTransaction;
   friend class DeleteTextTransaction;
   friend class HTMLEditRules;
   friend class HTMLEditUtils;
   friend class InsertNodeTransaction;
   friend class InsertTextTransaction;
   friend class JoinNodeTransaction;
   friend class SplitNodeTransaction;
   friend class TextEditRules;
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -152,17 +152,16 @@ public:
                      WidgetKeyboardEvent* aKeyboardEvent) override;
   virtual nsIContent* GetFocusedContent() override;
   virtual already_AddRefed<nsIContent> GetFocusedContentForIME() override;
   virtual bool IsActiveInDOMWindow() override;
   virtual dom::EventTarget* GetDOMEventTarget() override;
   virtual already_AddRefed<nsIContent> FindSelectionRoot(
                                          nsINode *aNode) override;
   virtual bool IsAcceptableInputEvent(WidgetGUIEvent* aGUIEvent) override;
-  virtual already_AddRefed<nsIContent> GetInputEventTargetContent() override;
   virtual nsresult GetPreferredIMEState(widget::IMEState* aState) override;
 
   /**
    * Can we paste |aTransferable| or, if |aTransferable| is null, will a call
    * to pasteTransferable later possibly succeed if given an instance of
    * nsITransferable then? True if the doc is modifiable, and, if
    * |aTransfeable| is non-null, we have pasteable data in |aTransfeable|.
    */
@@ -435,21 +434,21 @@ protected: // May be called by friends.
    * @param aElement [IN] the element
    * @param aChange  [IN] relative change to apply to current z-index of
    *                      the element
    * @param aReturn  [OUT] the new z-index of the element
    */
   nsresult RelativeChangeElementZIndex(Element& aElement, int32_t aChange,
                                        int32_t* aReturn);
 
+  virtual bool IsModifiableNode(nsINode* aNode) override;
+
   virtual bool IsBlockNode(nsINode *aNode) override;
   using EditorBase::IsBlockNode;
 
-  virtual bool IsModifiableNode(nsINode* aNode) override;
-
   /**
    * returns true if aParentTag can contain a child of type aChildTag.
    */
   virtual bool TagCanContainTag(nsAtom& aParentTag,
                                 nsAtom& aChildTag) const override;
 
   /**
    * Returns true if aNode is a container.
@@ -909,16 +908,18 @@ protected: // Shouldn't be used by frien
 
   /**
    * Get the focused node of this editor.
    * @return    If the editor has focus, this returns the focused node.
    *            Otherwise, returns null.
    */
   already_AddRefed<nsINode> GetFocusedNode();
 
+  virtual already_AddRefed<nsIContent> GetInputEventTargetContent() override;
+
   /**
    * Return TRUE if aElement is a table-related elemet and caret was set.
    */
   bool SetCaretInTableCell(dom::Element* aElement);
 
   nsresult TabInTable(bool inIsShift, bool* outHandled);
 
   /**
--- a/editor/libeditor/TextEditor.h
+++ b/editor/libeditor/TextEditor.h
@@ -100,18 +100,16 @@ public:
 
   nsresult DocumentIsEmpty(bool* aIsEmpty);
 
   virtual nsresult HandleKeyPressEvent(
                      WidgetKeyboardEvent* aKeyboardEvent) override;
 
   virtual dom::EventTarget* GetDOMEventTarget() override;
 
-  virtual already_AddRefed<nsIContent> GetInputEventTargetContent() override;
-
   /**
    * InsertTextAsAction() inserts aStringToInsert at selection.
    * Although this method is implementation of nsIPlaintextEditor.insertText(),
    * this treats the input is an edit action.
    *
    * @param aStringToInsert     The string to insert.
    */
   nsresult InsertTextAsAction(const nsAString& aStringToInsert);
@@ -355,16 +353,18 @@ protected: // Shouldn't be used by frien
    * the event comes to the editor.
    *
    * @return            true if there is a composition.  Otherwise, for example,
    *                    a composition event handler in web contents moved focus
    *                    for committing the composition, returns false.
    */
   bool EnsureComposition(WidgetCompositionEvent& aCompositionEvent);
 
+  virtual already_AddRefed<nsIContent> GetInputEventTargetContent() override;
+
 protected:
   nsCOMPtr<nsIDocumentEncoder> mCachedDocumentEncoder;
   nsString mCachedDocumentEncoderType;
   int32_t mWrapColumn;
   int32_t mMaxTextLength;
   int32_t mInitTriggerCounter;
   int32_t mNewlineHandling;
   int32_t mCaretStyle;