Bug 1591417: part 2) Rename `HasMutationEventListeners` to `MaybeHasMutationEventListeners`. r=masayuki
authorMirko Brodesser <mbrodesser@mozilla.com>
Tue, 12 Nov 2019 15:20:20 +0000
changeset 501717 34804d1ae0c049bef2003f93e9ffb966a228db3c
parent 501716 6ece388605bb8696347d1d4202387ae8b043132f
child 501718 0dd20dae7caac58c51562d1ab9fd0b51792a8d2d
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1591417
milestone72.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 1591417: part 2) Rename `HasMutationEventListeners` to `MaybeHasMutationEventListeners`. r=masayuki After removing all mutation event listeners, the corresponding method still returns `true`, so the new name is more accurate. Differential Revision: https://phabricator.services.mozilla.com/D52342
editor/libeditor/EditorBase.h
editor/libeditor/HTMLEditSubActionHandler.cpp
editor/libeditor/HTMLEditor.cpp
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -206,17 +206,19 @@ class EditorBase : public nsIEditor,
 
   Document* GetDocument() const { return mDocument; }
   nsPIDOMWindowOuter* GetWindow() const {
     return mDocument ? mDocument->GetWindow() : nullptr;
   }
   nsPIDOMWindowInner* GetInnerWindow() const {
     return mDocument ? mDocument->GetInnerWindow() : nullptr;
   }
-  bool HasMutationEventListeners(
+  // @param aMutationEventType One or multiple of NS_EVENT_BITS_MUTATION_*.
+  // @return true, iff at least one of NS_EVENT_BITS_MUTATION_* is set.
+  bool MaybeHasMutationEventListeners(
       uint32_t aMutationEventType = 0xFFFFFFFF) const {
     if (!mIsHTMLEditorClass) {
       // DOM mutation event listeners cannot catch the changes of
       // <input type="text"> nor <textarea>.
       return false;
     }
     nsPIDOMWindowInner* window = GetInnerWindow();
     return window ? window->HasMutationListeners(aMutationEventType) : false;
--- a/editor/libeditor/HTMLEditSubActionHandler.cpp
+++ b/editor/libeditor/HTMLEditSubActionHandler.cpp
@@ -3925,17 +3925,17 @@ MoveNodeResult HTMLEditor::MoveOneHardLi
       offset = result.NextInsertionPointRef().Offset();
       DebugOnly<nsresult> rvIgnored = DeleteNodeWithTransaction(*node);
       if (NS_WARN_IF(Destroyed())) {
         return MoveNodeResult(NS_ERROR_EDITOR_DESTROYED);
       }
       NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
                            "DeleteNodeWithTransaction() failed, but ignored");
       result.MarkAsHandled();
-      if (HasMutationEventListeners()) {
+      if (MaybeHasMutationEventListeners()) {
         // Mutation event listener may make `offset` value invalid with
         // removing some previous children while we call
         // `DeleteNodeWithTransaction()` so that we should adjust it here.
         offset = std::min(offset, aPointToInsert.GetContainer()->Length());
       }
       continue;
     }
     // XXX Different from the above block, we ignore error of moving nodes.
@@ -3992,17 +3992,17 @@ MoveNodeResult HTMLEditor::MoveNodeOrChi
 
   nsresult rv = DeleteNodeWithTransaction(aContent);
   if (NS_WARN_IF(Destroyed())) {
     return MoveNodeResult(NS_ERROR_EDITOR_DESTROYED);
   }
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return MoveNodeResult(rv);
   }
-  if (HasMutationEventListeners()) {
+  if (MaybeHasMutationEventListeners()) {
     // Mutation event listener may make `offset` value invalid with
     // removing some previous children while we call
     // `DeleteNodeWithTransaction()` so that we should adjust it here.
     if (!result.NextInsertionPointRef().IsSetAndValid()) {
       result = MoveNodeHandled(
           EditorDOMPoint::AtEndOf(*aPointToInsert.GetContainer()));
     }
   }
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -3230,19 +3230,20 @@ nsresult HTMLEditor::DeleteParentBlocksW
   if (nextPoint.GetContainer() == wsObj.GetEditingHost()) {
     return NS_OK;
   }
 
   // Otherwise, we need to check whether we're still in empty block or not.
 
   // If we have mutation event listeners, the next point is now outside of
   // editing host or editing hos has been changed.
-  if (HasMutationEventListeners(NS_EVENT_BITS_MUTATION_NODEREMOVED |
-                                NS_EVENT_BITS_MUTATION_NODEREMOVEDFROMDOCUMENT |
-                                NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED)) {
+  if (MaybeHasMutationEventListeners(
+          NS_EVENT_BITS_MUTATION_NODEREMOVED |
+          NS_EVENT_BITS_MUTATION_NODEREMOVEDFROMDOCUMENT |
+          NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED)) {
     Element* editingHost = GetActiveEditingHost();
     if (NS_WARN_IF(!editingHost) ||
         NS_WARN_IF(editingHost != wsObj.GetEditingHost())) {
       return NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE;
     }
     if (NS_WARN_IF(!EditorUtils::IsDescendantOf(*nextPoint.GetContainer(),
                                                 *editingHost))) {
       return NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE;