Backed out changeset 447c87c2d139 (bug 1539356) on request of Jorg K. a=backout
authorOana Pop Rus <opoprus@mozilla.com>
Sat, 30 Mar 2019 00:42:32 +0200
changeset 466833 1e7c6202d94f27e9b14450dc8710f32e7df31572
parent 466832 bd1e28b0143bdcff0798b0e6a4f54791c41192e8
child 466910 d42c60ccf0d05a8b1e6098c1ab62d26e6edd2267
push id35783
push useropoprus@mozilla.com
push dateFri, 29 Mar 2019 22:44:21 +0000
treeherdermozilla-central@1e7c6202d94f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1539356
milestone68.0a1
backs out447c87c2d1396aa1d0980d023067f1629d972c25
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
Backed out changeset 447c87c2d139 (bug 1539356) on request of Jorg K. a=backout
docshell/base/nsDocShellEditorData.cpp
docshell/base/nsDocShellEditorData.h
dom/html/nsTextEditorState.cpp
editor/composer/nsEditingSession.h
editor/composer/nsIEditingSession.idl
editor/libeditor/CSSEditUtils.cpp
editor/libeditor/CSSEditUtils.h
editor/libeditor/EditorBase.cpp
editor/libeditor/EditorBase.h
editor/libeditor/EditorEventListener.h
editor/libeditor/HTMLEditRules.cpp
editor/libeditor/HTMLEditRules.h
editor/libeditor/HTMLEditor.cpp
editor/libeditor/HTMLEditor.h
editor/libeditor/HTMLEditorCommands.cpp
editor/libeditor/HTMLEditorCommands.h
editor/libeditor/HTMLEditorDataTransfer.cpp
editor/libeditor/HTMLEditorEventListener.cpp
editor/libeditor/HTMLEditorEventListener.h
editor/libeditor/HTMLEditorObjectResizer.cpp
editor/libeditor/HTMLStyleEditor.cpp
editor/libeditor/HTMLTableEditor.cpp
editor/libeditor/TextEditRules.cpp
editor/libeditor/TextEditRules.h
editor/libeditor/TextEditUtils.cpp
editor/libeditor/TextEditUtils.h
editor/libeditor/TextEditor.cpp
editor/libeditor/TextEditor.h
editor/libeditor/WSRunObject.cpp
editor/libeditor/WSRunObject.h
editor/nsIEditor.idl
editor/nsIEditorMailSupport.idl
editor/nsIHTMLEditor.idl
--- a/docshell/base/nsDocShellEditorData.cpp
+++ b/docshell/base/nsDocShellEditorData.cpp
@@ -53,16 +53,33 @@ nsresult nsDocShellEditorData::MakeEdita
   }
   return NS_OK;
 }
 
 bool nsDocShellEditorData::GetEditable() {
   return mMakeEditable || (mHTMLEditor != nullptr);
 }
 
+nsresult nsDocShellEditorData::CreateEditor() {
+  nsCOMPtr<nsIEditingSession> editingSession;
+  nsresult rv = GetEditingSession(getter_AddRefs(editingSession));
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+
+  nsCOMPtr<nsPIDOMWindowOuter> domWindow =
+      mDocShell ? mDocShell->GetWindow() : nullptr;
+  rv = editingSession->SetupEditorOnWindow(domWindow);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+
+  return NS_OK;
+}
+
 nsresult nsDocShellEditorData::GetEditingSession(nsIEditingSession** aResult) {
   EnsureEditingSession();
 
   NS_ADDREF(*aResult = mEditingSession);
 
   return NS_OK;
 }
 
--- a/docshell/base/nsDocShellEditorData.h
+++ b/docshell/base/nsDocShellEditorData.h
@@ -19,16 +19,17 @@ class nsIEditingSession;
 
 class nsDocShellEditorData {
  public:
   explicit nsDocShellEditorData(nsIDocShell* aOwningDocShell);
   ~nsDocShellEditorData();
 
   nsresult MakeEditable(bool aWaitForUriLoad);
   bool GetEditable();
+  nsresult CreateEditor();
   nsresult GetEditingSession(nsIEditingSession** aResult);
   mozilla::HTMLEditor* GetHTMLEditor() const { return mHTMLEditor; }
   nsresult SetHTMLEditor(mozilla::HTMLEditor* aHTMLEditor);
   void TearDownEditor();
   nsresult DetachFromWindow();
   nsresult ReattachToWindow(nsIDocShell* aDocShell);
   bool WaitingForLoad() const { return mMakeEditable; }
 
--- a/dom/html/nsTextEditorState.cpp
+++ b/dom/html/nsTextEditorState.cpp
@@ -1340,20 +1340,18 @@ nsresult nsTextEditorState::PrepareEdito
     // for its content manipulations, and it causes it to fail some security
     // checks deep inside when initializing. So we explictly make it clear that
     // we're native code.
     // Note that any script that's directly trying to access our value
     // has to be going through some scriptable object to do that and that
     // already does the relevant security checks.
     AutoNoJSAPI nojsapi;
 
-    RefPtr<Element> rootElement = GetRootNode();
-    RefPtr<nsTextInputSelectionImpl> selectionController = mSelCon;
-    rv = newTextEditor->Init(*doc, rootElement, selectionController,
-                             editorFlags, defaultValue);
+    rv = newTextEditor->Init(*doc, GetRootNode(), mSelCon, editorFlags,
+                             defaultValue);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   // Initialize the controller for the editor
 
   if (!SuppressEventHandlers(presContext)) {
     nsCOMPtr<nsIControllers> controllers;
     nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
--- a/editor/composer/nsEditingSession.h
+++ b/editor/composer/nsEditingSession.h
@@ -67,17 +67,16 @@ class nsEditingSession final : public ns
   nsresult PrepareForEditing(nsPIDOMWindowOuter* aWindow);
 
   static void TimerCallback(nsITimer* aTimer, void* aClosure);
   nsCOMPtr<nsITimer> mLoadBlankDocTimer;
 
   // progress load stuff
   nsresult StartDocumentLoad(nsIWebProgress* aWebProgress,
                              bool isToBeMadeEditable);
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY
   nsresult EndDocumentLoad(nsIWebProgress* aWebProgress, nsIChannel* aChannel,
                            nsresult aStatus, bool isToBeMadeEditable);
   nsresult StartPageLoad(nsIChannel* aChannel);
   nsresult EndPageLoad(nsIWebProgress* aWebProgress, nsIChannel* aChannel,
                        nsresult aStatus);
 
   bool IsProgressForTargetDocument(nsIWebProgress* aWebProgress);
 
--- a/editor/composer/nsIEditingSession.idl
+++ b/editor/composer/nsIEditingSession.idl
@@ -42,17 +42,16 @@ interface nsIEditingSession : nsISupport
    *  @param aWindow nsIDOMWindow, the window the embedder needs to make editable
    *  @param aEditorType string, "html" "htmlsimple" "text" "textsimple"
    *  @param aMakeWholeDocumentEditable if PR_TRUE make the whole document in
    *                                    aWindow editable, otherwise it's the
    *                                    embedder who should make the document
    *                                    (or part of it) editable.
    *  @param aInteractive if PR_FALSE turn off scripting and plugins
    */
-  [can_run_script]
   void makeWindowEditable(in mozIDOMWindowProxy window,
                           in string aEditorType,
                           in boolean doAfterUriLoad,
                           in boolean aMakeWholeDocumentEditable,
                           in boolean aInteractive);
 
   /**
    *  Test whether a specific window has had its editable flag set; it may have an editor
@@ -66,17 +65,16 @@ interface nsIEditingSession : nsISupport
   /**
    *  Get the editor for this window. May return null
    */
 	nsIEditor getEditorForWindow(in mozIDOMWindowProxy window);
 
   /**
    *  Setup editor and related support objects
    */
-  [can_run_script]
   void setupEditorOnWindow(in mozIDOMWindowProxy window);
 
   /**
    *   Destroy editor and related support objects
    */
   void tearDownEditorOnWindow(in mozIDOMWindowProxy window);
 
   void setEditorOnControllers(in mozIDOMWindowProxy aWindow,
--- a/editor/libeditor/CSSEditUtils.cpp
+++ b/editor/libeditor/CSSEditUtils.cpp
@@ -490,29 +490,29 @@ already_AddRefed<nsComputedDOMStyle> CSS
 
   return style.forget();
 }
 
 // remove the CSS style "aProperty : aPropertyValue" and possibly remove the
 // whole node if it is a span and if its only attribute is _moz_dirty
 nsresult CSSEditUtils::RemoveCSSInlineStyle(nsINode& aNode, nsAtom* aProperty,
                                             const nsAString& aPropertyValue) {
-  OwningNonNull<Element> element(*aNode.AsElement());
+  RefPtr<Element> element = aNode.AsElement();
+  NS_ENSURE_STATE(element);
 
   // remove the property from the style attribute
-  nsresult rv = RemoveCSSProperty(element, *aProperty, aPropertyValue);
+  nsresult rv = RemoveCSSProperty(*element, *aProperty, aPropertyValue);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!element->IsHTMLElement(nsGkAtoms::span) ||
       HTMLEditor::HasAttributes(element)) {
     return NS_OK;
   }
 
-  OwningNonNull<HTMLEditor> htmlEditor(*mHTMLEditor);
-  return htmlEditor->RemoveContainerWithTransaction(element);
+  return mHTMLEditor->RemoveContainerWithTransaction(*element);
 }
 
 // Answers true if the property can be removed by setting a "none" CSS value
 // on a node
 
 // static
 bool CSSEditUtils::IsCSSInvertible(nsAtom& aProperty, nsAtom* aAttribute) {
   return nsGkAtoms::b == &aProperty;
@@ -842,19 +842,18 @@ nsresult CSSEditUtils::RemoveCSSEquivale
   nsTArray<nsString> cssValueArray;
   GenerateCSSDeclarationsFromHTMLStyle(aElement, aHTMLProperty, aAttribute,
                                        aValue, cssPropertyArray, cssValueArray,
                                        true);
 
   // remove the individual CSS inline styles
   int32_t count = cssPropertyArray.Length();
   for (int32_t index = 0; index < count; index++) {
-    nsresult rv =
-        RemoveCSSProperty(*aElement, MOZ_KnownLive(*cssPropertyArray[index]),
-                          cssValueArray[index], aSuppressTransaction);
+    nsresult rv = RemoveCSSProperty(*aElement, *cssPropertyArray[index],
+                                    cssValueArray[index], aSuppressTransaction);
     NS_ENSURE_SUCCESS(rv, rv);
   }
   return NS_OK;
 }
 
 // returns in aValueString the list of values for the CSS equivalences to
 // the HTML style aHTMLProperty/aAttribute/aValueString for the node aNode;
 // the value of aStyleType controls the styles we retrieve : specified or
--- a/editor/libeditor/CSSEditUtils.h
+++ b/editor/libeditor/CSSEditUtils.h
@@ -95,17 +95,16 @@ class CSSEditUtils final {
    *                            property.
    * @param aSuppressTransaction [IN] A boolean indicating, when true,
    *                                  that no transaction should be recorded.
    */
   nsresult SetCSSProperty(dom::Element& aElement, nsAtom& aProperty,
                           const nsAString& aValue, bool aSuppressTxn = false);
   nsresult SetCSSPropertyPixels(dom::Element& aElement, nsAtom& aProperty,
                                 int32_t aIntValue);
-  MOZ_CAN_RUN_SCRIPT
   nsresult RemoveCSSProperty(dom::Element& aElement, nsAtom& aProperty,
                              const nsAString& aPropertyValue,
                              bool aSuppressTxn = false);
 
   /**
    * Gets the specified/computed style value of a CSS property for a given
    * node (or its element ancestor if it is not an element).
    *
@@ -123,17 +122,16 @@ class CSSEditUtils final {
    * and removes the node if it is an useless span.
    *
    * @param aNode           [IN] The specific node we want to remove a style
    *                             from.
    * @param aProperty       [IN] The CSS property atom to remove.
    * @param aPropertyValue  [IN] The value of the property we have to remove
    *                             if the property accepts more than one value.
    */
-  MOZ_CAN_RUN_SCRIPT
   nsresult RemoveCSSInlineStyle(nsINode& aNode, nsAtom* aProperty,
                                 const nsAString& aPropertyValue);
 
   /**
    * Answers true is the property can be removed by setting a "none" CSS value
    * on a node.
    *
    * @param aProperty     [IN] An atom containing a CSS property.
@@ -255,17 +253,16 @@ class CSSEditUtils final {
    * @param aElement       [IN] A DOM Element (must not be null).
    * @param aHTMLProperty  [IN] An atom containing an HTML property.
    * @param aAttribute     [IN] An atom to an attribute name or nullptr if
    *                            irrelevant.
    * @param aValue         [IN] The attribute value.
    * @param aSuppressTransaction [IN] A boolean indicating, when true,
    *                                  that no transaction should be recorded.
    */
-  MOZ_CAN_RUN_SCRIPT
   nsresult RemoveCSSEquivalentToHTMLStyle(dom::Element* aElement,
                                           nsAtom* aHTMLProperty,
                                           nsAtom* aAttribute,
                                           const nsAString* aValue,
                                           bool aSuppressTransaction);
 
   /**
    * Parses a "xxxx.xxxxxuuu" string where x is a digit and u an alpha char.
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -2367,25 +2367,23 @@ void EditorBase::CloneAttributesWithTran
   // Set just the attributes that the source element has
   RefPtr<nsDOMAttributeMap> sourceAttributes = sourceElement->Attributes();
   uint32_t sourceCount = sourceAttributes->Length();
   for (uint32_t i = 0; i < sourceCount; i++) {
     RefPtr<Attr> attr = sourceAttributes->Item(i);
     nsAutoString value;
     attr->GetValue(value);
     if (isDestElementInBody) {
-      SetAttributeOrEquivalent(destElement,
-                               MOZ_KnownLive(attr->NodeInfo()->NameAtom()),
-                               value, false);
+      SetAttributeOrEquivalent(destElement, attr->NodeInfo()->NameAtom(), value,
+                               false);
     } else {
       // The element is not inserted in the document yet, we don't want to put
       // a transaction on the UndoStack
-      SetAttributeOrEquivalent(destElement,
-                               MOZ_KnownLive(attr->NodeInfo()->NameAtom()),
-                               value, true);
+      SetAttributeOrEquivalent(destElement, attr->NodeInfo()->NameAtom(), value,
+                               true);
     }
   }
 }
 
 nsresult EditorBase::ScrollSelectionIntoView(bool aScrollToAnchor) {
   nsISelectionController* selectionController = GetSelectionController();
   if (!selectionController) {
     return NS_OK;
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -166,17 +166,16 @@ class EditorBase : public nsIEditor,
    * @param aRoot         This is the root of the editable section of this
    *                      document. If it is null then we get root
    *                      from document body.
    * @param aSelCon       this should be used to get the selection location
    *                      (will be null for HTML editors)
    * @param aFlags        A bitmask of flags for specifying the behavior
    *                      of the editor.
    */
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult Init(Document& doc, Element* aRoot,
                         nsISelectionController* aSelCon, uint32_t aFlags,
                         const nsAString& aInitialValue);
 
   /**
    * PostCreate should be called after Init, and is the time that the editor
    * tells its documentStateObservers that the document has been created.
    */
@@ -881,17 +880,16 @@ class EditorBase : public nsIEditor,
    *                        The point after inserted aStringToInsert.
    *                        So, when this method actually inserts string,
    *                        this is set to a point in the text node.
    *                        Otherwise, this may be set to aPointToInsert.
    * @return                When this succeeds to insert the string or
    *                        does nothing during composition, returns NS_OK.
    *                        Otherwise, an error code.
    */
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult InsertTextWithTransaction(
       Document& aDocument, const nsAString& aStringToInsert,
       const EditorRawDOMPoint& aPointToInsert,
       EditorRawDOMPoint* aPointAfterInsertedString = nullptr);
 
   /**
    * InsertTextIntoTextNodeWithTransaction() inserts aStringToInsert into
    * aOffset of aTextNode with transaction.
@@ -923,47 +921,45 @@ class EditorBase : public nsIEditor,
    * @param aContentToInsert    The node to be inserted.
    * @param aPointToInsert      The insertion point of aContentToInsert.
    *                            If this refers end of the container, the
    *                            transaction will append the node to the
    *                            container.  Otherwise, will insert the node
    *                            before child node referred by this.
    */
   template <typename PT, typename CT>
-  MOZ_CAN_RUN_SCRIPT nsresult
-  InsertNodeWithTransaction(nsIContent& aContentToInsert,
-                            const EditorDOMPointBase<PT, CT>& aPointToInsert);
+  nsresult InsertNodeWithTransaction(
+      nsIContent& aContentToInsert,
+      const EditorDOMPointBase<PT, CT>& aPointToInsert);
 
   /**
    * ReplaceContainerWithTransaction() creates new element whose name is
    * aTagName, moves all children in aOldContainer to the new element, then,
    * removes aOldContainer from the DOM tree.
    *
    * @param aOldContainer       The element node which should be replaced
    *                            with new element.
    * @param aTagName            The name of new element node.
    */
-  MOZ_CAN_RUN_SCRIPT
   already_AddRefed<Element> ReplaceContainerWithTransaction(
       Element& aOldContainer, nsAtom& aTagName) {
     return ReplaceContainerWithTransactionInternal(
         aOldContainer, aTagName, *nsGkAtoms::_empty, EmptyString(), false);
   }
 
   /**
    * ReplaceContainerAndCloneAttributesWithTransaction() creates new element
    * whose name is aTagName, copies all attributes from aOldContainer to the
    * new element, moves all children in aOldContainer to the new element, then,
    * removes aOldContainer from the DOM tree.
    *
    * @param aOldContainer       The element node which should be replaced
    *                            with new element.
    * @param aTagName            The name of new element node.
    */
-  MOZ_CAN_RUN_SCRIPT
   already_AddRefed<Element> ReplaceContainerAndCloneAttributesWithTransaction(
       Element& aOldContainer, nsAtom& aTagName) {
     return ReplaceContainerWithTransactionInternal(
         aOldContainer, aTagName, *nsGkAtoms::_empty, EmptyString(), true);
   }
 
   /**
    * ReplaceContainerWithTransaction() creates new element whose name is
@@ -972,57 +968,53 @@ class EditorBase : public nsIEditor,
    * aOldContainer from the DOM tree.
    *
    * @param aOldContainer       The element node which should be replaced
    *                            with new element.
    * @param aTagName            The name of new element node.
    * @param aAttribute          Attribute name to be set to the new element.
    * @param aAttributeValue     Attribute value to be set to aAttribute.
    */
-  MOZ_CAN_RUN_SCRIPT
   already_AddRefed<Element> ReplaceContainerWithTransaction(
       Element& aOldContainer, nsAtom& aTagName, nsAtom& aAttribute,
       const nsAString& aAttributeValue) {
     return ReplaceContainerWithTransactionInternal(
         aOldContainer, aTagName, aAttribute, aAttributeValue, false);
   }
 
   /**
    * CloneAttributesWithTransaction() clones all attributes from
    * aSourceElement to aDestElement after removing all attributes in
    * aDestElement.
    */
-  MOZ_CAN_RUN_SCRIPT
   void CloneAttributesWithTransaction(Element& aDestElement,
                                       Element& aSourceElement);
 
   /**
    * RemoveContainerWithTransaction() removes aElement from the DOM tree and
    * moves all its children to the parent of aElement.
    *
    * @param aElement            The element to be removed.
    */
-  MOZ_CAN_RUN_SCRIPT
   nsresult RemoveContainerWithTransaction(Element& aElement);
 
   /**
    * InsertContainerWithTransaction() creates new element whose name is
    * aTagName, moves aContent into the new element, then, inserts the new
    * element into where aContent was.
    * Note that this method does not check if aContent is valid child of
    * the new element.  So, callers need to guarantee it.
    *
    * @param aContent            The content which will be wrapped with new
    *                            element.
    * @param aTagName            Element name of new element which will wrap
    *                            aContent and be inserted into where aContent
    *                            was.
    * @return                    The new element.
    */
-  MOZ_CAN_RUN_SCRIPT
   already_AddRefed<Element> InsertContainerWithTransaction(nsIContent& aContent,
                                                            nsAtom& aTagName) {
     return InsertContainerWithTransactionInternal(
         aContent, aTagName, *nsGkAtoms::_empty, EmptyString());
   }
 
   /**
    * InsertContainerWithTransaction() creates new element whose name is
@@ -1036,17 +1028,16 @@ class EditorBase : public nsIEditor,
    * @param aTagName            Element name of new element which will wrap
    *                            aContent and be inserted into where aContent
    *                            was.
    * @param aAttribute          Attribute which should be set to the new
    *                            element.
    * @param aAttributeValue     Value to be set to aAttribute.
    * @return                    The new element.
    */
-  MOZ_CAN_RUN_SCRIPT
   already_AddRefed<Element> InsertContainerWithTransaction(
       nsIContent& aContent, nsAtom& aTagName, nsAtom& aAttribute,
       const nsAString& aAttributeValue) {
     return InsertContainerWithTransactionInternal(aContent, aTagName,
                                                   aAttribute, aAttributeValue);
   }
 
   /**
@@ -1079,27 +1070,26 @@ class EditorBase : public nsIEditor,
   nsresult JoinNodesWithTransaction(nsINode& aLeftNode, nsINode& aRightNode);
 
   /**
    * MoveNodeWithTransaction() moves aContent to aPointToInsert.
    *
    * @param aContent        The node to be moved.
    */
   template <typename PT, typename CT>
-  MOZ_CAN_RUN_SCRIPT nsresult MoveNodeWithTransaction(
+  nsresult MoveNodeWithTransaction(
       nsIContent& aContent, const EditorDOMPointBase<PT, CT>& aPointToInsert);
 
   /**
    * MoveNodeToEndWithTransaction() moves aContent to end of aNewContainer.
    *
    * @param aContent        The node to be moved.
    * @param aNewContainer   The new container which will contain aContent as
    *                        its last child.
    */
-  MOZ_CAN_RUN_SCRIPT
   nsresult MoveNodeToEndWithTransaction(nsIContent& aContent,
                                         nsINode& aNewContainer) {
     EditorRawDOMPoint pointToInsert;
     pointToInsert.SetToEndOf(&aNewContainer);
     return MoveNodeWithTransaction(aContent, pointToInsert);
   }
 
   /**
@@ -1176,32 +1166,30 @@ class EditorBase : public nsIEditor,
    * RemoveAttributeWithTransaction() removes aAttribute from aElement.
    *
    * @param aElement        Element node which will lose aAttribute.
    * @param aAttribute      Attribute name to be removed from aElement.
    */
   nsresult RemoveAttributeWithTransaction(Element& aElement,
                                           nsAtom& aAttribute);
 
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult RemoveAttributeOrEquivalent(Element* aElement,
                                                nsAtom* aAttribute,
                                                bool aSuppressTransaction) = 0;
 
   /**
    * SetAttributeWithTransaction() sets aAttribute of aElement to aValue.
    *
    * @param aElement        Element node which will have aAttribute.
    * @param aAttribute      Attribute name to be set.
    * @param aValue          Attribute value be set to aAttribute.
    */
   nsresult SetAttributeWithTransaction(Element& aElement, nsAtom& aAttribute,
                                        const nsAString& aValue);
 
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult SetAttributeOrEquivalent(Element* aElement,
                                             nsAtom* aAttribute,
                                             const nsAString& aValue,
                                             bool aSuppressTransaction) = 0;
 
   /**
    * Method to replace certain CreateElementNS() calls.
    *
@@ -1288,17 +1276,16 @@ class EditorBase : public nsIEditor,
    * @param aAttribute          Attribute name which will be set to the new
    *                            element.  This will be ignored if
    *                            aCloneAllAttributes is set to true.
    * @param aAttributeValue     Attribute value which will be set to
    *                            aAttribute.
    * @param aCloneAllAttributes If true, all attributes of aOldContainer will
    *                            be copied to the new element.
    */
-  MOZ_CAN_RUN_SCRIPT
   already_AddRefed<Element> ReplaceContainerWithTransactionInternal(
       Element& aElement, nsAtom& aTagName, nsAtom& aAttribute,
       const nsAString& aAttributeValue, bool aCloneAllAttributes);
 
   /**
    * InsertContainerWithTransactionInternal() creates new element whose name is
    * aTagName, moves aContent into the new element, then, inserts the new
    * element into where aContent was.  If aAttribute is not nsGkAtoms::_empty,
@@ -1311,17 +1298,16 @@ class EditorBase : public nsIEditor,
    *                            was.
    * @param aAttribute          Attribute which should be set to the new
    *                            element.  If this is nsGkAtoms::_empty,
    *                            this does not set any attributes to the new
    *                            element.
    * @param aAttributeValue     Value to be set to aAttribute.
    * @return                    The new element.
    */
-  MOZ_CAN_RUN_SCRIPT
   already_AddRefed<Element> InsertContainerWithTransactionInternal(
       nsIContent& aContent, nsAtom& aTagName, nsAtom& aAttribute,
       const nsAString& aAttributeValue);
 
   /**
    * DoSplitNode() creates a new node (left node) identical to an existing
    * node (right node), and split the contents between the same point in both
    * nodes.
@@ -1748,17 +1734,16 @@ class EditorBase : public nsIEditor,
    */
   virtual void OnStartToHandleTopLevelEditSubAction(
       EditSubAction aEditSubAction, nsIEditor::EDirection aDirection);
 
   /**
    * OnEndHandlingTopLevelEditSubAction() is called after
    * SetTopLevelEditSubAction() is handled.
    */
-  MOZ_CAN_RUN_SCRIPT
   virtual void OnEndHandlingTopLevelEditSubAction();
 
   /**
    * Routines for managing the preservation of selection across
    * various editor actions.
    */
   bool ArePreservingSelection();
   void PreserveSelectionAcrossActions();
@@ -2126,20 +2111,19 @@ class EditorBase : public nsIEditor,
       if (!mEditorBase.GetTopLevelEditSubAction()) {
         mEditorBase.OnStartToHandleTopLevelEditSubAction(aEditSubAction,
                                                          aDirection);
       } else {
         mDoNothing = true;  // nested calls will end up here
       }
     }
 
-    MOZ_CAN_RUN_SCRIPT_BOUNDARY
     ~AutoTopLevelEditSubActionNotifier() {
       if (!mDoNothing) {
-        MOZ_KnownLive(mEditorBase).OnEndHandlingTopLevelEditSubAction();
+        mEditorBase.OnEndHandlingTopLevelEditSubAction();
       }
     }
 
    protected:
     EditorBase& mEditorBase;
     bool mDoNothing;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
   };
--- a/editor/libeditor/EditorEventListener.h
+++ b/editor/libeditor/EditorEventListener.h
@@ -69,17 +69,16 @@ class EditorEventListener : public nsIDO
   nsresult KeyPress(WidgetKeyboardEvent* aKeyboardEvent);
   MOZ_CAN_RUN_SCRIPT
   nsresult HandleChangeComposition(WidgetCompositionEvent* aCompositionEvent);
   nsresult HandleStartComposition(WidgetCompositionEvent* aCompositionEvent);
   MOZ_CAN_RUN_SCRIPT
   void HandleEndComposition(WidgetCompositionEvent* aCompositionEvent);
   MOZ_CAN_RUN_SCRIPT
   virtual nsresult MouseDown(dom::MouseEvent* aMouseEvent);
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult MouseUp(dom::MouseEvent* aMouseEvent) { return NS_OK; }
   MOZ_CAN_RUN_SCRIPT
   virtual nsresult MouseClick(WidgetMouseEvent* aMouseClickEvent);
   nsresult Focus(InternalFocusEvent* aFocusEvent);
   nsresult Blur(InternalFocusEvent* aBlurEvent);
   MOZ_CAN_RUN_SCRIPT nsresult DragEnter(dom::DragEvent* aDragEvent);
   MOZ_CAN_RUN_SCRIPT nsresult DragOver(dom::DragEvent* aDragEvent);
   nsresult DragExit(dom::DragEvent* aDragEvent);
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -1338,19 +1338,18 @@ nsresult HTMLEditRules::WillInsertText(E
     // the insertion point.
     int32_t IMESelectionOffset = HTMLEditorRef().GetIMESelectionStartOffsetIn(
         pointToInsert.GetContainer());
     if (IMESelectionOffset >= 0) {
       pointToInsert.Set(pointToInsert.GetContainer(), IMESelectionOffset);
     }
 
     if (inString->IsEmpty()) {
-      rv = MOZ_KnownLive(HTMLEditorRef())
-               .InsertTextWithTransaction(*doc, *inString,
-                                          EditorRawDOMPoint(pointToInsert));
+      rv = HTMLEditorRef().InsertTextWithTransaction(
+          *doc, *inString, EditorRawDOMPoint(pointToInsert));
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       return NS_OK;
     }
@@ -1440,20 +1439,19 @@ nsresult HTMLEditRules::WillInsertText(E
           NS_WARNING_ASSERTION(
               advanced, "Failed to advance offset after the new <br> element");
           NS_WARNING_ASSERTION(currentPoint == pointToInsert,
                                "Perhaps, <br> element position has been moved "
                                "to different point "
                                "by mutation observer");
         } else {
           EditorRawDOMPoint pointAfterInsertedString;
-          rv = MOZ_KnownLive(HTMLEditorRef())
-                   .InsertTextWithTransaction(*doc, subStr,
-                                              EditorRawDOMPoint(currentPoint),
-                                              &pointAfterInsertedString);
+          rv = HTMLEditorRef().InsertTextWithTransaction(
+              *doc, subStr, EditorRawDOMPoint(currentPoint),
+              &pointAfterInsertedString);
           if (NS_WARN_IF(!CanHandleEditAction())) {
             return NS_ERROR_EDITOR_DESTROYED;
           }
           if (NS_WARN_IF(NS_FAILED(rv))) {
             return rv;
           }
           currentPoint = pointAfterInsertedString;
           pointToInsert = pointAfterInsertedString;
@@ -1728,18 +1726,18 @@ EditActionResult HTMLEditRules::WillInse
 
   if (host == blockParent && separator != ParagraphSeparator::br) {
     // Insert a new block first
     MOZ_ASSERT(separator == ParagraphSeparator::div ||
                separator == ParagraphSeparator::p);
     // MakeBasicBlock() creates AutoSelectionRestorer.
     // Therefore, even if it returns NS_OK, editor might have been destroyed
     // at restoring Selection.
-    nsresult rv =
-        MakeBasicBlock(MOZ_KnownLive(ParagraphSeparatorElement(separator)));
+    OwningNonNull<nsAtom> separatorTag = ParagraphSeparatorElement(separator);
+    nsresult rv = MakeBasicBlock(separatorTag);
     if (NS_WARN_IF(rv == NS_ERROR_EDITOR_DESTROYED) ||
         NS_WARN_IF(!CanHandleEditAction())) {
       return EditActionIgnored(NS_ERROR_EDITOR_DESTROYED);
     }
     // We warn on failure, but don't handle it, because it might be harmless.
     // Instead we just check that a new block was actually created.
     NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
                          "HTMLEditRules::MakeBasicBlock() failed");
@@ -1793,19 +1791,19 @@ EditActionResult HTMLEditRules::WillInse
     }
     if (NS_WARN_IF(!brElement)) {
       return EditActionIgnored(NS_ERROR_FAILURE);
     }
   }
 
   nsCOMPtr<Element> listItem = IsInListItem(blockParent);
   if (listItem && listItem != host) {
-    nsresult rv = ReturnInListItem(
-        *listItem, MOZ_KnownLive(*atStartOfSelection.GetContainer()),
-        atStartOfSelection.Offset());
+    nsresult rv =
+        ReturnInListItem(*listItem, *atStartOfSelection.GetContainer(),
+                         atStartOfSelection.Offset());
     if (NS_WARN_IF(rv == NS_ERROR_EDITOR_DESTROYED)) {
       return EditActionIgnored(NS_ERROR_EDITOR_DESTROYED);
     }
     NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
                          "Failed to insert break into list item");
     return EditActionHandled();
   }
 
@@ -1962,20 +1960,18 @@ nsresult HTMLEditRules::InsertBRElement(
     // The next thing after the break we inserted is another break.  Move the
     // second break to be the first break's sibling.  This will prevent them
     // from being in different inline nodes, which would break
     // SetInterlinePosition().  It will also assure that if the user clicks
     // away and then clicks back on their new blank line, they will still get
     // the style from the line above.
     EditorDOMPoint atSecondBRElement(maybeSecondBRNode);
     if (brElement->GetNextSibling() != maybeSecondBRNode) {
-      nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                        .MoveNodeWithTransaction(
-                            MOZ_KnownLive(*maybeSecondBRNode->AsContent()),
-                            afterBRElement);
+      nsresult rv = HTMLEditorRef().MoveNodeWithTransaction(
+          *maybeSecondBRNode->AsContent(), afterBRElement);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
   }
@@ -2587,17 +2583,17 @@ nsresult HTMLEditRules::WillDeleteSelect
       if (sibling) {
         stepbrother = HTMLEditorRef().GetNextHTMLSibling(sibling);
       }
       // Are they both text nodes?  If so, join them!
       if (startPoint.GetContainer() == stepbrother &&
           startPoint.GetContainerAsText() && sibling->GetAsText()) {
         EditorDOMPoint pt;
         nsresult rv = JoinNearestEditableNodesWithTransaction(
-            *sibling, MOZ_KnownLive(*startPoint.GetContainerAsContent()), &pt);
+            *sibling, *startPoint.GetContainerAsContent(), &pt);
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
         if (NS_WARN_IF(!pt.IsSet())) {
           return NS_ERROR_FAILURE;
         }
         // Fix up selection
         ErrorResult error;
@@ -2699,18 +2695,17 @@ nsresult HTMLEditRules::WillDeleteSelect
       EditorDOMPoint selPoint(startPoint);
       {
         AutoTrackDOMPoint tracker(HTMLEditorRef().RangeUpdaterRef(), &selPoint);
         if (NS_WARN_IF(!leftNode) || NS_WARN_IF(!leftNode->IsContent()) ||
             NS_WARN_IF(!rightNode) || NS_WARN_IF(!rightNode->IsContent())) {
           return NS_ERROR_FAILURE;
         }
         EditActionResult ret = TryToJoinBlocksWithTransaction(
-            MOZ_KnownLive(*leftNode->AsContent()),
-            MOZ_KnownLive(*rightNode->AsContent()));
+            *leftNode->AsContent(), *rightNode->AsContent());
         *aHandled |= ret.Handled();
         *aCancel |= ret.Canceled();
         if (NS_WARN_IF(ret.Failed())) {
           return ret.Rv();
         }
       }
 
       // If TryToJoinBlocksWithTransaction() didn't handle it  and it's not
@@ -2780,18 +2775,17 @@ nsresult HTMLEditRules::WillDeleteSelect
       EditorDOMPoint selPoint(startPoint);
       {
         AutoTrackDOMPoint tracker(HTMLEditorRef().RangeUpdaterRef(), &selPoint);
         if (NS_WARN_IF(!leftNode->IsContent()) ||
             NS_WARN_IF(!rightNode->IsContent())) {
           return NS_ERROR_FAILURE;
         }
         EditActionResult ret = TryToJoinBlocksWithTransaction(
-            MOZ_KnownLive(*leftNode->AsContent()),
-            MOZ_KnownLive(*rightNode->AsContent()));
+            *leftNode->AsContent(), *rightNode->AsContent());
         // This should claim that trying to join the block means that
         // this handles the action because the caller shouldn't do anything
         // anymore in this case.
         *aHandled = true;
         *aCancel |= ret.Canceled();
         if (NS_WARN_IF(ret.Failed())) {
           return ret.Rv();
         }
@@ -3459,18 +3453,18 @@ EditActionResult HTMLEditRules::TryToJoi
           previousContent.Set(previousContentParent, previousContentOffset);
         }
       }
 
       if (NS_WARN_IF(!previousContent.IsSet())) {
         return EditActionIgnored(NS_ERROR_NULL_POINTER);
       }
 
-      ret |= MoveBlock(MOZ_KnownLive(*previousContent.GetContainerAsElement()),
-                       *rightBlock, previousContent.Offset(), 0);
+      ret |= MoveBlock(*previousContent.GetContainerAsElement(), *rightBlock,
+                       previousContent.Offset(), 0);
       if (NS_WARN_IF(ret.Failed())) {
         return ret;
       }
     }
     if (brNode) {
       nsresult rv = HTMLEditorRef().DeleteNodeWithTransaction(*brNode);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return ret.SetResult(NS_ERROR_EDITOR_DESTROYED);
@@ -3510,18 +3504,18 @@ EditActionResult HTMLEditRules::TryToJoi
     // Nodes are same type.  merge them.
     EditorDOMPoint pt;
     nsresult rv =
         JoinNearestEditableNodesWithTransaction(*leftBlock, *rightBlock, &pt);
     if (NS_WARN_IF(rv == NS_ERROR_EDITOR_DESTROYED)) {
       return EditActionIgnored(NS_ERROR_EDITOR_DESTROYED);
     }
     if (pt.IsSet() && mergeLists) {
-      CreateElementResult convertListTypeResult = ConvertListType(
-          *rightBlock, MOZ_KnownLive(*existingList), *nsGkAtoms::li);
+      CreateElementResult convertListTypeResult =
+          ConvertListType(*rightBlock, *existingList, *nsGkAtoms::li);
       if (NS_WARN_IF(convertListTypeResult.Rv() == NS_ERROR_EDITOR_DESTROYED)) {
         return EditActionIgnored(NS_ERROR_EDITOR_DESTROYED);
       }
     }
     ret.MarkAsHandled();
   } else {
     // Nodes are dissimilar types.
     ret |= MoveBlock(*leftBlock, *rightBlock, -1, 0);
@@ -3560,31 +3554,31 @@ EditActionResult HTMLEditRules::MoveBloc
     return EditActionIgnored(rv);
   }
 
   EditActionResult ret(NS_OK);
   for (uint32_t i = 0; i < arrayOfNodes.Length(); i++) {
     // get the node to act on
     if (IsBlockNode(arrayOfNodes[i])) {
       // For block nodes, move their contents only, then delete block.
-      ret |= MoveContents(MOZ_KnownLive(*arrayOfNodes[i]->AsElement()),
-                          aLeftBlock, &aLeftOffset);
+      ret |=
+          MoveContents(*arrayOfNodes[i]->AsElement(), aLeftBlock, &aLeftOffset);
       if (NS_WARN_IF(ret.Failed())) {
         return ret;
       }
       rv = HTMLEditorRef().DeleteNodeWithTransaction(*arrayOfNodes[i]);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return ret.SetResult(NS_ERROR_EDITOR_DESTROYED);
       }
       NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to remove a block node");
       ret.MarkAsHandled();
     } else {
       // Otherwise move the content as is, checking against the DTD.
-      ret |= MoveNodeSmart(MOZ_KnownLive(*arrayOfNodes[i]->AsContent()),
-                           aLeftBlock, &aLeftOffset);
+      ret |= MoveNodeSmart(*arrayOfNodes[i]->AsContent(), aLeftBlock,
+                           &aLeftOffset);
       if (NS_WARN_IF(ret.Rv() == NS_ERROR_EDITOR_DESTROYED)) {
         return ret;
       }
       NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
                            "Failed to move current node to the left block");
     }
   }
 
@@ -3601,28 +3595,28 @@ EditActionResult HTMLEditRules::MoveNode
                                               int32_t* aInOutDestOffset) {
   MOZ_ASSERT(IsEditorDataAvailable());
   MOZ_ASSERT(aInOutDestOffset);
 
   // Check if this node can go into the destination node
   if (HTMLEditorRef().CanContain(aDestElement, aNode)) {
     // If it can, move it there.
     if (*aInOutDestOffset == -1) {
-      nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                        .MoveNodeToEndWithTransaction(aNode, aDestElement);
+      nsresult rv =
+          HTMLEditorRef().MoveNodeToEndWithTransaction(aNode, aDestElement);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return EditActionIgnored(NS_ERROR_EDITOR_DESTROYED);
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return EditActionIgnored(rv);
       }
     } else {
       EditorRawDOMPoint pointToInsert(&aDestElement, *aInOutDestOffset);
-      nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                        .MoveNodeWithTransaction(aNode, pointToInsert);
+      nsresult rv =
+          HTMLEditorRef().MoveNodeWithTransaction(aNode, pointToInsert);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return EditActionIgnored(NS_ERROR_EDITOR_DESTROYED);
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return EditActionIgnored(rv);
       }
     }
     if (*aInOutDestOffset != -1) {
@@ -3630,18 +3624,17 @@ EditActionResult HTMLEditRules::MoveNode
     }
     // XXX Should we check if the node is actually moved in this case?
     return EditActionHandled();
   }
 
   // If it can't, move its children (if any), and then delete it.
   EditActionResult ret(NS_OK);
   if (aNode.IsElement()) {
-    ret = MoveContents(MOZ_KnownLive(*aNode.AsElement()), aDestElement,
-                       aInOutDestOffset);
+    ret = MoveContents(*aNode.AsElement(), aDestElement, aInOutDestOffset);
     if (NS_WARN_IF(ret.Failed())) {
       return ret;
     }
   }
 
   nsresult rv = HTMLEditorRef().DeleteNodeWithTransaction(aNode);
   if (NS_WARN_IF(!CanHandleEditAction())) {
     return ret.SetResult(NS_ERROR_EDITOR_DESTROYED);
@@ -3658,17 +3651,17 @@ EditActionResult HTMLEditRules::MoveCont
   MOZ_ASSERT(aInOutDestOffset);
 
   if (NS_WARN_IF(&aElement == &aDestElement)) {
     return EditActionIgnored(NS_ERROR_ILLEGAL_VALUE);
   }
 
   EditActionResult ret(NS_OK);
   while (aElement.GetFirstChild()) {
-    ret |= MoveNodeSmart(MOZ_KnownLive(*aElement.GetFirstChild()), aDestElement,
+    ret |= MoveNodeSmart(*aElement.GetFirstChild(), aDestElement,
                          aInOutDestOffset);
     if (NS_WARN_IF(ret.Failed())) {
       return ret;
     }
   }
   return ret;
 }
 
@@ -3966,43 +3959,41 @@ nsresult HTMLEditRules::MakeList(nsAtom&
 
     if (HTMLEditUtils::IsList(curNode)) {
       // do we have a curList already?
       if (curList && !EditorUtils::IsDescendantOf(*curNode, *curList)) {
         // move all of our children into curList.  cheezy way to do it: move
         // whole list and then RemoveContainerWithTransaction() on the list.
         // ConvertListType first: that routine handles converting the list
         // item types, if needed.
-        rv = MOZ_KnownLive(HTMLEditorRef())
-                 .MoveNodeToEndWithTransaction(*curNode, *curList);
+        rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode, *curList);
         if (NS_WARN_IF(!CanHandleEditAction())) {
           return NS_ERROR_EDITOR_DESTROYED;
         }
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
-        CreateElementResult convertListTypeResult = ConvertListType(
-            MOZ_KnownLive(*curNode->AsElement()), aListType, aItemType);
+        CreateElementResult convertListTypeResult =
+            ConvertListType(*curNode->AsElement(), aListType, aItemType);
         if (NS_WARN_IF(convertListTypeResult.Failed())) {
           return convertListTypeResult.Rv();
         }
-        rv = MOZ_KnownLive(HTMLEditorRef())
-                 .RemoveBlockContainerWithTransaction(
-                     MOZ_KnownLive(*convertListTypeResult.GetNewNode()));
+        rv = HTMLEditorRef().RemoveBlockContainerWithTransaction(
+            *convertListTypeResult.GetNewNode());
         if (NS_WARN_IF(!CanHandleEditAction())) {
           return NS_ERROR_EDITOR_DESTROYED;
         }
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
         newBlock = convertListTypeResult.forget();
       } else {
         // replace list with new list type
-        CreateElementResult convertListTypeResult = ConvertListType(
-            MOZ_KnownLive(*curNode->AsElement()), aListType, aItemType);
+        CreateElementResult convertListTypeResult =
+            ConvertListType(*curNode->AsElement(), aListType, aItemType);
         if (NS_WARN_IF(convertListTypeResult.Failed())) {
           return convertListTypeResult.Rv();
         }
         curList = convertListTypeResult.forget();
       }
       prevListItem = nullptr;
       continue;
     }
@@ -4037,56 +4028,52 @@ nsresult HTMLEditRules::MakeList(nsAtom&
           if (NS_WARN_IF(!CanHandleEditAction())) {
             return NS_ERROR_EDITOR_DESTROYED;
           }
           if (NS_WARN_IF(!curList)) {
             return NS_ERROR_FAILURE;
           }
         }
         // move list item to new list
-        rv = MOZ_KnownLive(HTMLEditorRef())
-                 .MoveNodeToEndWithTransaction(*curNode, *curList);
+        rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode, *curList);
         if (NS_WARN_IF(!CanHandleEditAction())) {
           return NS_ERROR_EDITOR_DESTROYED;
         }
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
         // convert list item type if needed
         if (!curNode->IsHTMLElement(&aItemType)) {
-          newBlock = MOZ_KnownLive(HTMLEditorRef())
-                         .ReplaceContainerWithTransaction(
-                             MOZ_KnownLive(*curNode->AsElement()), aItemType);
+          newBlock = HTMLEditorRef().ReplaceContainerWithTransaction(
+              *curNode->AsElement(), aItemType);
           if (NS_WARN_IF(!CanHandleEditAction())) {
             return NS_ERROR_EDITOR_DESTROYED;
           }
           if (NS_WARN_IF(!newBlock)) {
             return NS_ERROR_FAILURE;
           }
         }
       } else {
         // item is in right type of list.  But we might still have to move it.
         // and we might need to convert list item types.
         if (!curList) {
           curList = atCurNode.GetContainerAsElement();
         } else if (atCurNode.GetContainer() != curList) {
           // move list item to new list
-          rv = MOZ_KnownLive(HTMLEditorRef())
-                   .MoveNodeToEndWithTransaction(*curNode, *curList);
+          rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode, *curList);
           if (NS_WARN_IF(!CanHandleEditAction())) {
             return NS_ERROR_EDITOR_DESTROYED;
           }
           if (NS_WARN_IF(NS_FAILED(rv))) {
             return rv;
           }
         }
         if (!curNode->IsHTMLElement(&aItemType)) {
-          newBlock = MOZ_KnownLive(HTMLEditorRef())
-                         .ReplaceContainerWithTransaction(
-                             MOZ_KnownLive(*curNode->AsElement()), aItemType);
+          newBlock = HTMLEditorRef().ReplaceContainerWithTransaction(
+              *curNode->AsElement(), aItemType);
           if (NS_WARN_IF(!CanHandleEditAction())) {
             return NS_ERROR_EDITOR_DESTROYED;
           }
           if (NS_WARN_IF(!newBlock)) {
             return NS_ERROR_FAILURE;
           }
         }
       }
@@ -4117,19 +4104,18 @@ nsresult HTMLEditRules::MakeList(nsAtom&
     }
 
     // if we hit a div clear our prevListItem, insert divs contents
     // into our node array, and remove the div
     if (curNode->IsHTMLElement(nsGkAtoms::div)) {
       prevListItem = nullptr;
       int32_t j = i + 1;
       GetInnerContent(*curNode, arrayOfNodes, &j);
-      rv = MOZ_KnownLive(HTMLEditorRef())
-               .RemoveContainerWithTransaction(
-                   MOZ_KnownLive(*curNode->AsElement()));
+      rv =
+          HTMLEditorRef().RemoveContainerWithTransaction(*curNode->AsElement());
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       listCount = arrayOfNodes.Length();
       continue;
@@ -4161,39 +4147,38 @@ nsresult HTMLEditRules::MakeList(nsAtom&
     }
 
     // if curNode isn't a list item, we must wrap it in one
     nsCOMPtr<Element> listItem;
     if (!HTMLEditUtils::IsListItem(curNode)) {
       if (IsInlineNode(curNode) && prevListItem) {
         // this is a continuation of some inline nodes that belong together in
         // the same list item.  use prevListItem
-        rv = MOZ_KnownLive(HTMLEditorRef())
-                 .MoveNodeToEndWithTransaction(*curNode, *prevListItem);
+        rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode,
+                                                          *prevListItem);
         if (NS_WARN_IF(!CanHandleEditAction())) {
           return NS_ERROR_EDITOR_DESTROYED;
         }
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
       } else {
         // don't wrap li around a paragraph.  instead replace paragraph with li
         if (curNode->IsHTMLElement(nsGkAtoms::p)) {
-          listItem = MOZ_KnownLive(HTMLEditorRef())
-                         .ReplaceContainerWithTransaction(
-                             MOZ_KnownLive(*curNode->AsElement()), aItemType);
+          listItem = HTMLEditorRef().ReplaceContainerWithTransaction(
+              *curNode->AsElement(), aItemType);
           if (NS_WARN_IF(!CanHandleEditAction())) {
             return NS_ERROR_EDITOR_DESTROYED;
           }
           if (NS_WARN_IF(!listItem)) {
             return NS_ERROR_FAILURE;
           }
         } else {
-          listItem = MOZ_KnownLive(HTMLEditorRef())
-                         .InsertContainerWithTransaction(*curNode, aItemType);
+          listItem = HTMLEditorRef().InsertContainerWithTransaction(*curNode,
+                                                                    aItemType);
           if (NS_WARN_IF(!CanHandleEditAction())) {
             return NS_ERROR_EDITOR_DESTROYED;
           }
           if (NS_WARN_IF(!listItem)) {
             return NS_ERROR_FAILURE;
           }
         }
         if (IsInlineNode(curNode)) {
@@ -4204,18 +4189,17 @@ nsresult HTMLEditRules::MakeList(nsAtom&
       }
     } else {
       listItem = curNode->AsElement();
     }
 
     if (listItem) {
       // if we made a new list item, deal with it: tuck the listItem into the
       // end of the active list
-      rv = MOZ_KnownLive(HTMLEditorRef())
-               .MoveNodeToEndWithTransaction(*listItem, *curList);
+      rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*listItem, *curList);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
   }
@@ -4260,25 +4244,25 @@ nsresult HTMLEditRules::WillRemoveList(b
 
   // Only act on lists or list items in the array
   for (auto& curNode : arrayOfNodes) {
     // here's where we actually figure out what to do
     if (HTMLEditUtils::IsListItem(curNode)) {
       // unlist this listitem
       bool bOutOfList;
       do {
-        rv = PopListItem(MOZ_KnownLive(*curNode->AsContent()), &bOutOfList);
+        rv = PopListItem(*curNode->AsContent(), &bOutOfList);
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
       } while (
           !bOutOfList);  // keep popping it out until it's not in a list anymore
     } else if (HTMLEditUtils::IsList(curNode)) {
       // node is a list, move list items out
-      rv = RemoveListStructure(MOZ_KnownLive(*curNode->AsElement()));
+      rv = RemoveListStructure(*curNode->AsElement());
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
   }
   return NS_OK;
 }
 
@@ -4694,20 +4678,18 @@ nsresult HTMLEditRules::IndentAroundSele
       // We do this if the next element is a list, and the list is of the
       // same type (li/ol) as curNode was a part it.
       sibling = HTMLEditorRef().GetNextHTMLSibling(curNode);
       if (sibling && HTMLEditUtils::IsList(sibling) &&
           atCurNode.GetContainer()->NodeInfo()->NameAtom() ==
               sibling->NodeInfo()->NameAtom() &&
           atCurNode.GetContainer()->NodeInfo()->NamespaceID() ==
               sibling->NodeInfo()->NamespaceID()) {
-        nsresult rv =
-            MOZ_KnownLive(HTMLEditorRef())
-                .MoveNodeWithTransaction(MOZ_KnownLive(*curNode->AsContent()),
-                                         EditorRawDOMPoint(sibling, 0));
+        nsresult rv = HTMLEditorRef().MoveNodeWithTransaction(
+            *curNode->AsContent(), EditorRawDOMPoint(sibling, 0));
         if (NS_WARN_IF(!CanHandleEditAction())) {
           return NS_ERROR_EDITOR_DESTROYED;
         }
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
         continue;
       }
@@ -4716,19 +4698,18 @@ nsresult HTMLEditRules::IndentAroundSele
       // We do this if the previous element is a list, and the list is of
       // the same type (li/ol) as curNode was a part of.
       sibling = HTMLEditorRef().GetPriorHTMLSibling(curNode);
       if (sibling && HTMLEditUtils::IsList(sibling) &&
           atCurNode.GetContainer()->NodeInfo()->NameAtom() ==
               sibling->NodeInfo()->NameAtom() &&
           atCurNode.GetContainer()->NodeInfo()->NamespaceID() ==
               sibling->NodeInfo()->NamespaceID()) {
-        nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                          .MoveNodeToEndWithTransaction(
-                              MOZ_KnownLive(*curNode->AsContent()), *sibling);
+        nsresult rv = HTMLEditorRef().MoveNodeToEndWithTransaction(
+            *curNode->AsContent(), *sibling);
         if (NS_WARN_IF(!CanHandleEditAction())) {
           return NS_ERROR_EDITOR_DESTROYED;
         }
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
         continue;
       }
@@ -4758,33 +4739,31 @@ nsresult HTMLEditRules::IndentAroundSele
         if (NS_WARN_IF(!curList)) {
           return NS_ERROR_FAILURE;
         }
         // curList is now the correct thing to put curNode in
         // remember our new block for postprocessing
         mNewBlock = curList;
       }
       // tuck the node into the end of the active list
-      nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                        .MoveNodeToEndWithTransaction(
-                            MOZ_KnownLive(*curNode->AsContent()), *curList);
+      nsresult rv = HTMLEditorRef().MoveNodeToEndWithTransaction(
+          *curNode->AsContent(), *curList);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       continue;
     }
 
     // Not a list item.
 
     if (IsBlockNode(*curNode)) {
-      nsresult rv =
-          IncreaseMarginToIndent(MOZ_KnownLive(*curNode->AsElement()));
+      nsresult rv = IncreaseMarginToIndent(*curNode->AsElement());
       if (NS_WARN_IF(rv == NS_ERROR_EDITOR_DESTROYED)) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to inrease indentation");
       curQuote = nullptr;
       continue;
     }
 
@@ -4815,19 +4794,18 @@ nsresult HTMLEditRules::IndentAroundSele
       }
       NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to increase indentation");
       // remember our new block for postprocessing
       mNewBlock = curQuote;
       // curQuote is now the correct thing to put curNode in
     }
 
     // tuck the node into the end of the active blockquote
-    nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                      .MoveNodeToEndWithTransaction(
-                          MOZ_KnownLive(*curNode->AsContent()), *curQuote);
+    nsresult rv = HTMLEditorRef().MoveNodeToEndWithTransaction(
+        *curNode->AsContent(), *curQuote);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
   return NS_OK;
@@ -4967,19 +4945,18 @@ nsresult HTMLEditRules::IndentAroundSele
       // We do this if the next element is a list, and the list is of the
       // same type (li/ol) as curNode was a part it.
       sibling = HTMLEditorRef().GetNextHTMLSibling(curNode);
       if (sibling && HTMLEditUtils::IsList(sibling) &&
           atCurNode.GetContainer()->NodeInfo()->NameAtom() ==
               sibling->NodeInfo()->NameAtom() &&
           atCurNode.GetContainer()->NodeInfo()->NamespaceID() ==
               sibling->NodeInfo()->NamespaceID()) {
-        rv = MOZ_KnownLive(HTMLEditorRef())
-                 .MoveNodeWithTransaction(MOZ_KnownLive(*curNode->AsContent()),
-                                          EditorRawDOMPoint(sibling, 0));
+        rv = HTMLEditorRef().MoveNodeWithTransaction(
+            *curNode->AsContent(), EditorRawDOMPoint(sibling, 0));
         if (NS_WARN_IF(!CanHandleEditAction())) {
           return NS_ERROR_EDITOR_DESTROYED;
         }
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
         continue;
       }
@@ -4988,19 +4965,18 @@ nsresult HTMLEditRules::IndentAroundSele
       // We do this if the previous element is a list, and the list is of
       // the same type (li/ol) as curNode was a part of.
       sibling = HTMLEditorRef().GetPriorHTMLSibling(curNode);
       if (sibling && HTMLEditUtils::IsList(sibling) &&
           atCurNode.GetContainer()->NodeInfo()->NameAtom() ==
               sibling->NodeInfo()->NameAtom() &&
           atCurNode.GetContainer()->NodeInfo()->NamespaceID() ==
               sibling->NodeInfo()->NamespaceID()) {
-        rv = MOZ_KnownLive(HTMLEditorRef())
-                 .MoveNodeToEndWithTransaction(
-                     MOZ_KnownLive(*curNode->AsContent()), *sibling);
+        rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode->AsContent(),
+                                                          *sibling);
         if (NS_WARN_IF(!CanHandleEditAction())) {
           return NS_ERROR_EDITOR_DESTROYED;
         }
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
         continue;
       }
@@ -5030,19 +5006,18 @@ nsresult HTMLEditRules::IndentAroundSele
         if (NS_WARN_IF(!curList)) {
           return NS_ERROR_FAILURE;
         }
         // curList is now the correct thing to put curNode in
         // remember our new block for postprocessing
         mNewBlock = curList;
       }
       // tuck the node into the end of the active list
-      rv = MOZ_KnownLive(HTMLEditorRef())
-               .MoveNodeToEndWithTransaction(
-                   MOZ_KnownLive(*curNode->AsContent()), *curList);
+      rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode->AsContent(),
+                                                        *curList);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       // forget curQuote, if any
       curQuote = nullptr;
@@ -5089,18 +5064,17 @@ nsresult HTMLEditRules::IndentAroundSele
         if (NS_WARN_IF(!CanHandleEditAction())) {
           return NS_ERROR_EDITOR_DESTROYED;
         }
         if (NS_WARN_IF(!curList)) {
           return NS_ERROR_FAILURE;
         }
       }
 
-      rv = MOZ_KnownLive(HTMLEditorRef())
-               .MoveNodeToEndWithTransaction(*listItem, *curList);
+      rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*listItem, *curList);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
 
       // remember we indented this li
@@ -5139,19 +5113,18 @@ nsresult HTMLEditRules::IndentAroundSele
         return NS_ERROR_FAILURE;
       }
       // remember our new block for postprocessing
       mNewBlock = curQuote;
       // curQuote is now the correct thing to put curNode in
     }
 
     // tuck the node into the end of the active blockquote
-    rv = MOZ_KnownLive(HTMLEditorRef())
-             .MoveNodeToEndWithTransaction(MOZ_KnownLive(*curNode->AsContent()),
-                                           *curQuote);
+    rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode->AsContent(),
+                                                      *curQuote);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
     // forget curList, if any
     curList = nullptr;
@@ -5297,19 +5270,18 @@ SplitRangeOffFromNodeResult HTMLEditRule
         leftContentOfLastOutdented = outdentResult.GetLeftContent();
         middleContentOfLastOutdented = outdentResult.GetMiddleContent();
         rightContentOfLastOutdented = outdentResult.GetRightContent();
         curBlockQuote = nullptr;
         firstBQChild = nullptr;
         lastBQChild = nullptr;
         curBlockQuoteIsIndentedWithCSS = false;
       }
-      rv = MOZ_KnownLive(HTMLEditorRef())
-               .RemoveBlockContainerWithTransaction(
-                   MOZ_KnownLive(*curNode->AsElement()));
+      rv = HTMLEditorRef().RemoveBlockContainerWithTransaction(
+          *curNode->AsElement());
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return SplitRangeOffFromNodeResult(rv);
       }
       continue;
     }
@@ -5321,18 +5293,17 @@ SplitRangeOffFromNodeResult HTMLEditRule
       CSSEditUtils::GetSpecifiedProperty(curNode, marginProperty, value);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
       }
       float f;
       RefPtr<nsAtom> unit;
       CSSEditUtils::ParseLength(value, &f, getter_AddRefs(unit));
       if (f > 0) {
-        nsresult rv =
-            DecreaseMarginToOutdent(MOZ_KnownLive(*curNode->AsElement()));
+        nsresult rv = DecreaseMarginToOutdent(*curNode->AsElement());
         if (NS_WARN_IF(rv == NS_ERROR_EDITOR_DESTROYED)) {
           return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
         }
         NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
                              "Failed to decrease indentation");
         continue;
       }
     }
@@ -5352,17 +5323,17 @@ SplitRangeOffFromNodeResult HTMLEditRule
         leftContentOfLastOutdented = outdentResult.GetLeftContent();
         middleContentOfLastOutdented = outdentResult.GetMiddleContent();
         rightContentOfLastOutdented = outdentResult.GetRightContent();
         curBlockQuote = nullptr;
         firstBQChild = nullptr;
         lastBQChild = nullptr;
         curBlockQuoteIsIndentedWithCSS = false;
       }
-      rv = PopListItem(MOZ_KnownLive(*curNode->AsContent()));
+      rv = PopListItem(*curNode->AsContent());
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return SplitRangeOffFromNodeResult(rv);
       }
       continue;
     }
 
     // Do we have a blockquote that we are already committed to removing?
     if (curBlockQuote) {
@@ -5439,19 +5410,18 @@ SplitRangeOffFromNodeResult HTMLEditRule
       continue;
     }
 
     // Couldn't find enclosing blockquote.
     if (HTMLEditUtils::IsList(curParent)) {
       // Move node out of list
       if (HTMLEditUtils::IsList(curNode)) {
         // Just unwrap this sublist
-        rv = MOZ_KnownLive(HTMLEditorRef())
-                 .RemoveBlockContainerWithTransaction(
-                     MOZ_KnownLive(*curNode->AsElement()));
+        rv = HTMLEditorRef().RemoveBlockContainerWithTransaction(
+            *curNode->AsElement());
         if (NS_WARN_IF(!CanHandleEditAction())) {
           return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
         }
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return SplitRangeOffFromNodeResult(rv);
         }
       }
       continue;
@@ -5466,18 +5436,18 @@ SplitRangeOffFromNodeResult HTMLEditRule
           if (NS_WARN_IF(NS_FAILED(rv))) {
             return SplitRangeOffFromNodeResult(rv);
           }
         } else if (HTMLEditUtils::IsList(child)) {
           // We have an embedded list, so move it out from under the parent
           // list. Be sure to put it after the parent list because this
           // loop iterates backwards through the parent's list of children.
           EditorRawDOMPoint afterCurrentList(curParent, offset + 1);
-          rv = MOZ_KnownLive(HTMLEditorRef())
-                   .MoveNodeWithTransaction(*child, afterCurrentList);
+          rv =
+              HTMLEditorRef().MoveNodeWithTransaction(*child, afterCurrentList);
           if (NS_WARN_IF(!CanHandleEditAction())) {
             return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
           }
           if (NS_WARN_IF(NS_FAILED(rv))) {
             return SplitRangeOffFromNodeResult(rv);
           }
         } else {
           // Delete any non-list items for now
@@ -5487,19 +5457,18 @@ SplitRangeOffFromNodeResult HTMLEditRule
           }
           if (NS_WARN_IF(NS_FAILED(rv))) {
             return SplitRangeOffFromNodeResult(rv);
           }
         }
         child = curNode->GetLastChild();
       }
       // Delete the now-empty list
-      rv = MOZ_KnownLive(HTMLEditorRef())
-               .RemoveBlockContainerWithTransaction(
-                   MOZ_KnownLive(*curNode->AsElement()));
+      rv = HTMLEditorRef().RemoveBlockContainerWithTransaction(
+          *curNode->AsElement());
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return SplitRangeOffFromNodeResult(rv);
       }
       continue;
     }
@@ -5548,18 +5517,18 @@ HTMLEditRules::SplitRangeOffFromBlockAnd
 
   SplitRangeOffFromNodeResult splitResult =
       SplitRangeOffFromBlock(aBlockElement, aStartOfRange, aEndOfRange);
   if (NS_WARN_IF(splitResult.Rv() == NS_ERROR_EDITOR_DESTROYED)) {
     return splitResult;
   }
   NS_WARNING_ASSERTION(splitResult.Succeeded(),
                        "Failed to split the range off from the block element");
-  nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                    .RemoveBlockContainerWithTransaction(aBlockElement);
+  nsresult rv =
+      HTMLEditorRef().RemoveBlockContainerWithTransaction(aBlockElement);
   if (NS_WARN_IF(!CanHandleEditAction())) {
     return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
   }
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return SplitRangeOffFromNodeResult(rv);
   }
   return SplitRangeOffFromNodeResult(splitResult.GetLeftContent(), nullptr,
                                      splitResult.GetRightContent());
@@ -5613,32 +5582,31 @@ SplitRangeOffFromNodeResult HTMLEditRule
     return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
   }
 
   if (NS_WARN_IF(!splitResult.GetMiddleContentAsElement())) {
     return SplitRangeOffFromNodeResult(NS_ERROR_FAILURE);
   }
 
   if (!aIsBlockIndentedWithCSS) {
-    nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                      .RemoveBlockContainerWithTransaction(MOZ_KnownLive(
-                          *splitResult.GetMiddleContentAsElement()));
+    nsresult rv = HTMLEditorRef().RemoveBlockContainerWithTransaction(
+        *splitResult.GetMiddleContentAsElement());
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return SplitRangeOffFromNodeResult(rv);
     }
     return SplitRangeOffFromNodeResult(splitResult.GetLeftContent(), nullptr,
                                        splitResult.GetRightContent());
   }
 
   if (splitResult.GetMiddleContentAsElement()) {
-    nsresult rv = DecreaseMarginToOutdent(
-        MOZ_KnownLive(*splitResult.GetMiddleContentAsElement()));
+    nsresult rv =
+        DecreaseMarginToOutdent(*splitResult.GetMiddleContentAsElement());
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return SplitRangeOffFromNodeResult(rv);
     }
     return splitResult;
   }
 
   return splitResult;
 }
@@ -5649,47 +5617,45 @@ CreateElementResult HTMLEditRules::Conve
   MOZ_ASSERT(IsEditorDataAvailable());
 
   nsCOMPtr<nsINode> child = aListElement.GetFirstChild();
   while (child) {
     if (child->IsElement()) {
       Element* element = child->AsElement();
       if (HTMLEditUtils::IsListItem(element) &&
           !element->IsHTMLElement(&aNewListItemTag)) {
-        child = MOZ_KnownLive(HTMLEditorRef())
-                    .ReplaceContainerWithTransaction(MOZ_KnownLive(*element),
-                                                     aNewListItemTag);
+        child = HTMLEditorRef().ReplaceContainerWithTransaction(
+            *element, aNewListItemTag);
         if (NS_WARN_IF(!CanHandleEditAction())) {
           return CreateElementResult(NS_ERROR_EDITOR_DESTROYED);
         }
         if (NS_WARN_IF(!child)) {
           return CreateElementResult(NS_ERROR_FAILURE);
         }
       } else if (HTMLEditUtils::IsList(element) &&
                  !element->IsHTMLElement(&aNewListTag)) {
         // XXX List elements shouldn't have other list elements as their
         //     child.  Why do we handle such invalid tree?
-        CreateElementResult convertListTypeResult = ConvertListType(
-            MOZ_KnownLive(*child->AsElement()), aNewListTag, aNewListItemTag);
+        CreateElementResult convertListTypeResult =
+            ConvertListType(*child->AsElement(), aNewListTag, aNewListItemTag);
         if (NS_WARN_IF(convertListTypeResult.Failed())) {
           return convertListTypeResult;
         }
         child = convertListTypeResult.forget();
       }
     }
     child = child->GetNextSibling();
   }
 
   if (aListElement.IsHTMLElement(&aNewListTag)) {
     return CreateElementResult(&aListElement);
   }
 
-  RefPtr<Element> listElement =
-      MOZ_KnownLive(HTMLEditorRef())
-          .ReplaceContainerWithTransaction(aListElement, aNewListTag);
+  RefPtr<Element> listElement = HTMLEditorRef().ReplaceContainerWithTransaction(
+      aListElement, aNewListTag);
   if (NS_WARN_IF(!CanHandleEditAction())) {
     return CreateElementResult(NS_ERROR_EDITOR_DESTROYED);
   }
   NS_WARNING_ASSERTION(listElement != nullptr, "Failed to create list element");
   return CreateElementResult(listElement.forget());
 }
 
 nsresult HTMLEditRules::CreateStyleForInsertText(Document& aDocument) {
@@ -5714,20 +5680,18 @@ nsresult HTMLEditRules::CreateStyleForIn
 
   {
     // Transactions may set selection, but we will set selection if necessary.
     AutoTransactionsConserveSelection dontChangeMySelection(HTMLEditorRef());
 
     while (item && node != rootElement) {
       // XXX If we redesign ClearStyle(), we can use EditorDOMPoint in this
       //     method.
-      nsresult rv =
-          MOZ_KnownLive(HTMLEditorRef())
-              .ClearStyle(address_of(node), &offset, MOZ_KnownLive(item->tag),
-                          MOZ_KnownLive(item->attr));
+      nsresult rv = HTMLEditorRef().ClearStyle(address_of(node), &offset,
+                                               item->tag, item->attr);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       item = HTMLEditorRef().mTypeInState->TakeClearProperty();
       weDidSomething = true;
@@ -5757,50 +5721,46 @@ nsresult HTMLEditRules::CreateStyleForIn
       node = splitPoint.GetContainer();
       offset = splitPoint.Offset();
     }
     if (!HTMLEditorRef().IsContainer(node)) {
       return NS_OK;
     }
     OwningNonNull<Text> newNode =
         EditorBase::CreateTextNode(aDocument, EmptyString());
-    nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                      .InsertNodeWithTransaction(
-                          *newNode, EditorRawDOMPoint(node, offset));
+    nsresult rv = HTMLEditorRef().InsertNodeWithTransaction(
+        *newNode, EditorRawDOMPoint(node, offset));
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
     node = newNode;
     offset = 0;
     weDidSomething = true;
 
     if (relFontSize) {
       // dir indicated bigger versus smaller.  1 = bigger, -1 = smaller
       HTMLEditor::FontSize dir = relFontSize > 0 ? HTMLEditor::FontSize::incr
                                                  : HTMLEditor::FontSize::decr;
       for (int32_t j = 0; j < DeprecatedAbs(relFontSize); j++) {
-        rv = MOZ_KnownLive(HTMLEditorRef())
-                 .RelativeFontChangeOnTextNode(dir, newNode, 0, -1);
+        rv = HTMLEditorRef().RelativeFontChangeOnTextNode(dir, newNode, 0, -1);
         if (NS_WARN_IF(!CanHandleEditAction())) {
           return NS_ERROR_EDITOR_DESTROYED;
         }
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
       }
     }
 
     while (item) {
-      rv = MOZ_KnownLive(HTMLEditorRef())
-               .SetInlinePropertyOnNode(MOZ_KnownLive(*node->AsContent()),
-                                        MOZ_KnownLive(*item->tag),
-                                        MOZ_KnownLive(item->attr), item->value);
+      rv = HTMLEditorRef().SetInlinePropertyOnNode(
+          *node->AsContent(), *item->tag, item->attr, item->value);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       item = HTMLEditorRef().mTypeInState->TakeSetProperty();
     }
@@ -5889,17 +5849,17 @@ nsresult HTMLEditRules::AlignContentsAtS
   if (nodeArray.Length() == 1) {
     OwningNonNull<nsINode> node = nodeArray[0];
 
     if (HTMLEditUtils::SupportsAlignAttr(*node)) {
       // The node is a table element, an hr, a paragraph, a div or a section
       // header; in HTML 4, it can directly carry the ALIGN attribute and we
       // don't need to make a div! If we are in CSS mode, all the work is done
       // in AlignBlock
-      rv = AlignBlock(MOZ_KnownLive(*node->AsElement()), aAlignType,
+      rv = AlignBlock(*node->AsElement(), aAlignType,
                       ResetAlignOf::OnlyDescendants);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       return NS_OK;
     }
 
     if (TextEditUtils::IsBreak(node)) {
@@ -6028,17 +5988,17 @@ nsresult HTMLEditRules::AlignContentsAtS
       continue;
     }
 
     // The node is a table element, an hr, a paragraph, a div or a section
     // header; in HTML 4, it can directly carry the ALIGN attribute and we
     // don't need to nest it, just set the alignment.  In CSS, assign the
     // corresponding CSS styles in AlignBlock
     if (HTMLEditUtils::SupportsAlignAttr(*curNode)) {
-      rv = AlignBlock(MOZ_KnownLive(*curNode->AsElement()), aAlignType,
+      rv = AlignBlock(*curNode->AsElement(), aAlignType,
                       ResetAlignOf::ElementAndDescendants);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       // Clear out curDiv so that we don't put nodes after this one into it
       curDiv = nullptr;
       continue;
     }
@@ -6125,19 +6085,18 @@ nsresult HTMLEditRules::AlignContentsAtS
       rv = AlignBlock(*curDiv, aAlignType, ResetAlignOf::OnlyDescendants);
       if (NS_WARN_IF(rv == NS_ERROR_EDITOR_DESTROYED)) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to align the <div>");
     }
 
     // Tuck the node into the end of the active div
-    rv = MOZ_KnownLive(HTMLEditorRef())
-             .MoveNodeToEndWithTransaction(MOZ_KnownLive(*curNode->AsContent()),
-                                           *curDiv);
+    rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode->AsContent(),
+                                                      *curDiv);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
@@ -6175,20 +6134,18 @@ nsresult HTMLEditRules::AlignBlockConten
     // this cell has no content, nothing to align
     return NS_OK;
   }
 
   nsCOMPtr<nsIContent> lastChild = HTMLEditorRef().GetLastEditableChild(aNode);
   if (firstChild == lastChild && firstChild->IsHTMLElement(nsGkAtoms::div)) {
     // the cell already has a div containing all of its content: just
     // act on this div.
-    nsresult rv =
-        MOZ_KnownLive(HTMLEditorRef())
-            .SetAttributeOrEquivalent(MOZ_KnownLive(firstChild->AsElement()),
-                                      nsGkAtoms::align, aAlignType, false);
+    nsresult rv = HTMLEditorRef().SetAttributeOrEquivalent(
+        firstChild->AsElement(), nsGkAtoms::align, aAlignType, false);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
     return NS_OK;
   }
@@ -6200,30 +6157,28 @@ nsresult HTMLEditRules::AlignBlockConten
       HTMLEditorRef().CreateNodeWithTransaction(*nsGkAtoms::div, atStartOfNode);
   if (NS_WARN_IF(!CanHandleEditAction())) {
     return NS_ERROR_EDITOR_DESTROYED;
   }
   if (NS_WARN_IF(!divElem)) {
     return NS_ERROR_FAILURE;
   }
   // set up the alignment on the div
-  nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                    .SetAttributeOrEquivalent(divElem, nsGkAtoms::align,
-                                              aAlignType, false);
+  nsresult rv = HTMLEditorRef().SetAttributeOrEquivalent(
+      divElem, nsGkAtoms::align, aAlignType, false);
   if (NS_WARN_IF(!CanHandleEditAction())) {
     return NS_ERROR_EDITOR_DESTROYED;
   }
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   // tuck the children into the end of the active div
   while (lastChild && (lastChild != divElem)) {
-    nsresult rv =
-        MOZ_KnownLive(HTMLEditorRef())
-            .MoveNodeWithTransaction(*lastChild, EditorRawDOMPoint(divElem, 0));
+    nsresult rv = HTMLEditorRef().MoveNodeWithTransaction(
+        *lastChild, EditorRawDOMPoint(divElem, 0));
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
     lastChild = HTMLEditorRef().GetLastEditableChild(aNode);
   }
@@ -7212,18 +7167,17 @@ nsresult HTMLEditRules::GetNodesForOpera
       aEditSubAction == EditSubAction::eIndent ||
       aEditSubAction == EditSubAction::eOutdent) {
     for (int32_t i = aOutArrayOfNodes.Length() - 1; i >= 0; i--) {
       OwningNonNull<nsINode> node = aOutArrayOfNodes[i];
       // XXX Why do we run this loop even when aTouchContent is "no"?
       if (aTouchContent == TouchContent::yes && IsInlineNode(node) &&
           HTMLEditorRef().IsContainer(node) && !EditorBase::IsTextNode(node)) {
         nsTArray<OwningNonNull<nsINode>> arrayOfInlines;
-        nsresult rv = BustUpInlinesAtBRs(MOZ_KnownLive(*node->AsContent()),
-                                         arrayOfInlines);
+        nsresult rv = BustUpInlinesAtBRs(*node->AsContent(), arrayOfInlines);
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
 
         // Put these nodes in aOutArrayOfNodes, replacing the current node
         aOutArrayOfNodes.RemoveElementAt(i);
         aOutArrayOfNodes.InsertElementsAt(i, arrayOfInlines);
       }
@@ -7501,19 +7455,18 @@ nsresult HTMLEditRules::BustUpInlinesAtB
       // Might not be a left node.  A break might have been at the very
       // beginning of inline container, in which case
       // SplitNodeDeepWithTransaction() would not actually split anything.
       aOutArrayOfNodes.AppendElement(*splitNodeResult.GetPreviousNode());
     }
 
     // Move break outside of container and also put in node list
     EditorRawDOMPoint atNextNode(splitNodeResult.GetNextNode());
-    nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                      .MoveNodeWithTransaction(
-                          MOZ_KnownLive(*brNode->AsContent()), atNextNode);
+    nsresult rv = HTMLEditorRef().MoveNodeWithTransaction(*brNode->AsContent(),
+                                                          atNextNode);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
     aOutArrayOfNodes.AppendElement(*brNode);
 
@@ -8111,19 +8064,18 @@ nsresult HTMLEditRules::ReturnInListItem
 
     // Are we in a sublist?
     EditorRawDOMPoint atNextSiblingOfLeftList(leftListNode);
     DebugOnly<bool> advanced = atNextSiblingOfLeftList.AdvanceOffset();
     NS_WARNING_ASSERTION(advanced,
                          "Failed to advance offset after the right list node");
     if (HTMLEditUtils::IsList(atNextSiblingOfLeftList.GetContainer())) {
       // If so, move item out of this list and into the grandparent list
-      nsresult rv =
-          MOZ_KnownLive(HTMLEditorRef())
-              .MoveNodeWithTransaction(aListItem, atNextSiblingOfLeftList);
+      nsresult rv = HTMLEditorRef().MoveNodeWithTransaction(
+          aListItem, atNextSiblingOfLeftList);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       ErrorResult error;
       SelectionRefPtr()->Collapse(RawRangeBoundary(&aListItem, 0), error);
@@ -8265,20 +8217,19 @@ nsresult HTMLEditRules::ReturnInListItem
           }
           if (NS_WARN_IF(error.Failed())) {
             return error.StealNSResult();
           }
           return NS_OK;
         }
 
         RefPtr<Element> brElement;
-        nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                          .CopyLastEditableChildStylesWithTransaction(
-                              MOZ_KnownLive(*prevItem->AsElement()), aListItem,
-                              address_of(brElement));
+        nsresult rv =
+            HTMLEditorRef().CopyLastEditableChildStylesWithTransaction(
+                *prevItem->AsElement(), aListItem, address_of(brElement));
         if (NS_WARN_IF(!CanHandleEditAction())) {
           return NS_ERROR_EDITOR_DESTROYED;
         }
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return NS_ERROR_FAILURE;
         }
         if (brElement) {
           EditorRawDOMPoint atBrNode(brElement);
@@ -8405,19 +8356,18 @@ nsresult HTMLEditRules::MakeBlockquote(
       if (NS_WARN_IF(!curBlock)) {
         return NS_ERROR_FAILURE;
       }
       // remember our new block for postprocessing
       mNewBlock = curBlock;
       // note: doesn't matter if we set mNewBlock multiple times.
     }
 
-    nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                      .MoveNodeToEndWithTransaction(
-                          MOZ_KnownLive(*curNode->AsContent()), *curBlock);
+    nsresult rv = HTMLEditorRef().MoveNodeToEndWithTransaction(
+        *curNode->AsContent(), *curBlock);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
   return NS_OK;
@@ -8444,19 +8394,18 @@ nsresult HTMLEditRules::RemoveBlockStyle
           return removeMiddleContainerResult.Rv();
         }
         firstNode = lastNode = curBlock = nullptr;
       }
       if (!HTMLEditorRef().IsEditable(curNode)) {
         continue;
       }
       // Remove current block
-      nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                        .RemoveBlockContainerWithTransaction(
-                            MOZ_KnownLive(*curNode->AsElement()));
+      nsresult rv = HTMLEditorRef().RemoveBlockContainerWithTransaction(
+          *curNode->AsElement());
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       continue;
     }
@@ -8570,19 +8519,19 @@ nsresult HTMLEditRules::ApplyBlockStyle(
 
     // If curNode is a address, p, header, address, or pre, replace it with a
     // new block of correct type.
     // XXX: pre can't hold everything the others can
     if (HTMLEditUtils::IsMozDiv(curNode) ||
         HTMLEditUtils::IsFormatNode(curNode)) {
       // Forget any previous block used for previous inline nodes
       curBlock = nullptr;
-      newBlock = MOZ_KnownLive(HTMLEditorRef())
-                     .ReplaceContainerAndCloneAttributesWithTransaction(
-                         MOZ_KnownLive(*curNode->AsElement()), aBlockTag);
+      newBlock =
+          HTMLEditorRef().ReplaceContainerAndCloneAttributesWithTransaction(
+              *curNode->AsElement(), aBlockTag);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(!newBlock)) {
         return NS_ERROR_FAILURE;
       }
       continue;
     }
@@ -8652,19 +8601,18 @@ nsresult HTMLEditRules::ApplyBlockStyle(
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(!curBlock)) {
         return NS_ERROR_FAILURE;
       }
       // Remember our new block for postprocessing
       mNewBlock = curBlock;
       // Note: doesn't matter if we set mNewBlock multiple times.
-      nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                        .MoveNodeToEndWithTransaction(
-                            MOZ_KnownLive(*curNode->AsContent()), *curBlock);
+      nsresult rv = HTMLEditorRef().MoveNodeToEndWithTransaction(
+          *curNode->AsContent(), *curBlock);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       continue;
     }
@@ -8709,19 +8657,18 @@ nsresult HTMLEditRules::ApplyBlockStyle(
         // This is possible due to mutation events, let's not assert
         return NS_ERROR_UNEXPECTED;
       }
 
       // XXX If curNode is a br, replace it with a return if going to <pre>
 
       // This is a continuation of some inline nodes that belong together in
       // the same block item.  Use curBlock.
-      nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                        .MoveNodeToEndWithTransaction(
-                            MOZ_KnownLive(*curNode->AsContent()), *curBlock);
+      nsresult rv = HTMLEditorRef().MoveNodeToEndWithTransaction(
+          *curNode->AsContent(), *curBlock);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
   }
@@ -8799,19 +8746,18 @@ nsresult HTMLEditRules::JoinNearestEdita
     return NS_ERROR_FAILURE;
   }
   nsCOMPtr<nsINode> rightParent = aNodeRight.GetParentNode();
 
   // If they don't have the same parent, first move the right node to after the
   // left one
   if (parent != rightParent) {
     int32_t parOffset = parent->ComputeIndexOf(&aNodeLeft);
-    nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                      .MoveNodeWithTransaction(
-                          aNodeRight, EditorRawDOMPoint(parent, parOffset));
+    nsresult rv = HTMLEditorRef().MoveNodeWithTransaction(
+        aNodeRight, EditorRawDOMPoint(parent, parOffset));
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
@@ -9733,18 +9679,18 @@ nsresult HTMLEditRules::PopListItem(nsIC
   // be inserted between the both list elements.  This allows user to hit
   // Enter twice at a list item breaks the parent list node.
   if (!isFirstListItem) {
     DebugOnly<bool> advanced = pointToInsertListItem.AdvanceOffset();
     NS_WARNING_ASSERTION(advanced,
                          "Failed to advance offset to right list node");
   }
 
-  nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                    .MoveNodeWithTransaction(*listItem, pointToInsertListItem);
+  nsresult rv =
+      HTMLEditorRef().MoveNodeWithTransaction(*listItem, pointToInsertListItem);
   if (NS_WARN_IF(!CanHandleEditAction())) {
     return NS_ERROR_EDITOR_DESTROYED;
   }
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   // unwrap list item contents if they are no longer in a list
@@ -9752,19 +9698,18 @@ nsresult HTMLEditRules::PopListItem(nsIC
   //     (although invalid tree), the list item element won't be unwrapped.
   //     That makes the parent ancestor element tree valid, but might be
   //     unexpected result.
   // XXX If aListItem is <dl> or <dd> and current parent is <ul> or <ol>,
   //     the list items won't be unwrapped.  If aListItem is <li> and its
   //     current parent is <dl>, there is same issue.
   if (!HTMLEditUtils::IsList(pointToInsertListItem.GetContainer()) &&
       HTMLEditUtils::IsListItem(listItem)) {
-    rv = MOZ_KnownLive(HTMLEditorRef())
-             .RemoveBlockContainerWithTransaction(
-                 MOZ_KnownLive(*listItem->AsElement()));
+    rv = HTMLEditorRef().RemoveBlockContainerWithTransaction(
+        *listItem->AsElement());
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
     if (aOutOfList) {
       *aOutOfList = true;
@@ -9797,17 +9742,17 @@ nsresult HTMLEditRules::RemoveListStruct
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
       } while (!isOutOfList);
       continue;
     }
 
     if (HTMLEditUtils::IsList(child)) {
-      nsresult rv = RemoveListStructure(MOZ_KnownLive(*child->AsElement()));
+      nsresult rv = RemoveListStructure(*child->AsElement());
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       continue;
     }
 
     // Delete any non-list items for now
     // XXX This is not HTML5 aware.  HTML5 allows all list elements to have
@@ -9818,18 +9763,18 @@ nsresult HTMLEditRules::RemoveListStruct
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
   // Delete the now-empty list
-  nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                    .RemoveBlockContainerWithTransaction(aListElement);
+  nsresult rv =
+      HTMLEditorRef().RemoveBlockContainerWithTransaction(aListElement);
   if (NS_WARN_IF(!CanHandleEditAction())) {
     return NS_ERROR_EDITOR_DESTROYED;
   }
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
@@ -10205,19 +10150,17 @@ nsresult HTMLEditRules::RemoveAlignment(
       // we may have to insert BRs in first and last position of element's
       // children if the nodes before/after are not blocks and not BRs
       rv = MakeSureElemStartsAndEndsOnCR(*child);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
 
       // now remove the CENTER container
-      rv = MOZ_KnownLive(HTMLEditorRef())
-               .RemoveContainerWithTransaction(
-                   MOZ_KnownLive(*child->AsElement()));
+      rv = HTMLEditorRef().RemoveContainerWithTransaction(*child->AsElement());
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     } else if (IsBlockNode(*child) || child->IsHTMLElement(nsGkAtoms::hr)) {
       // the current node is a block element
@@ -10229,20 +10172,18 @@ nsresult HTMLEditRules::RemoveAlignment(
           return NS_ERROR_EDITOR_DESTROYED;
         }
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
       }
       if (useCSS) {
         if (child->IsAnyOfHTMLElements(nsGkAtoms::table, nsGkAtoms::hr)) {
-          nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                            .SetAttributeOrEquivalent(
-                                MOZ_KnownLive(child->AsElement()),
-                                nsGkAtoms::align, aAlignType, false);
+          nsresult rv = HTMLEditorRef().SetAttributeOrEquivalent(
+              child->AsElement(), nsGkAtoms::align, aAlignType, false);
           if (NS_WARN_IF(!CanHandleEditAction())) {
             return NS_ERROR_EDITOR_DESTROYED;
           }
           if (NS_WARN_IF(NS_FAILED(rv))) {
             return rv;
           }
         } else {
           nsAutoString dummyCssValue;
@@ -10345,38 +10286,36 @@ nsresult HTMLEditRules::AlignBlock(Eleme
   nsresult rv = RemoveAlignment(aElement, aAlignType,
                                 aResetAlignOf == ResetAlignOf::OnlyDescendants);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   if (HTMLEditorRef().IsCSSEnabled()) {
     // Let's use CSS alignment; we use margin-left and margin-right for tables
     // and text-align for other block-level elements
-    nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                      .SetAttributeOrEquivalent(&aElement, nsGkAtoms::align,
-                                                aAlignType, false);
+    nsresult rv = HTMLEditorRef().SetAttributeOrEquivalent(
+        &aElement, nsGkAtoms::align, aAlignType, false);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
     return NS_OK;
   }
 
   // HTML case; this code is supposed to be called ONLY if the element
   // supports the align attribute but we'll never know...
   if (NS_WARN_IF(!HTMLEditUtils::SupportsAlignAttr(aElement))) {
     // XXX error?
     return NS_OK;
   }
 
-  rv = MOZ_KnownLive(HTMLEditorRef())
-           .SetAttributeOrEquivalent(&aElement, nsGkAtoms::align, aAlignType,
-                                     false);
+  rv = HTMLEditorRef().SetAttributeOrEquivalent(&aElement, nsGkAtoms::align,
+                                                aAlignType, false);
   if (NS_WARN_IF(!CanHandleEditAction())) {
     return NS_ERROR_EDITOR_DESTROYED;
   }
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
@@ -10426,32 +10365,31 @@ nsresult HTMLEditRules::ChangeMarginStar
     HTMLEditorRef().mCSSEditUtils->SetCSSProperty(aElement, marginProperty,
                                                   newValue);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     return NS_OK;
   }
 
-  HTMLEditorRef().mCSSEditUtils->RemoveCSSProperty(
-      aElement, MOZ_KnownLive(marginProperty), value);
+  HTMLEditorRef().mCSSEditUtils->RemoveCSSProperty(aElement, marginProperty,
+                                                   value);
   if (NS_WARN_IF(!CanHandleEditAction())) {
     return NS_ERROR_EDITOR_DESTROYED;
   }
 
   // Remove unnecessary divs
   if (!aElement.IsHTMLElement(nsGkAtoms::div) ||
       &aElement == HTMLEditorRef().GetActiveEditingHost() ||
       !HTMLEditorRef().IsDescendantOfEditorRoot(&aElement) ||
       HTMLEditor::HasAttributes(&aElement)) {
     return NS_OK;
   }
 
-  nsresult rv =
-      MOZ_KnownLive(HTMLEditorRef()).RemoveContainerWithTransaction(aElement);
+  nsresult rv = HTMLEditorRef().RemoveContainerWithTransaction(aElement);
   if (NS_WARN_IF(!CanHandleEditAction())) {
     return NS_ERROR_EDITOR_DESTROYED;
   }
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
@@ -10632,19 +10570,18 @@ nsresult HTMLEditRules::PrepareToMakeEle
         }
         if (NS_WARN_IF(!curList)) {
           return NS_ERROR_FAILURE;
         }
         // curList is now the correct thing to put curNode in.  Remember our
         // new block for postprocessing.
       }
       // Tuck the node into the end of the active list
-      rv = MOZ_KnownLive(HTMLEditorRef())
-               .MoveNodeToEndWithTransaction(
-                   MOZ_KnownLive(*curNode->AsContent()), *curList);
+      rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode->AsContent(),
+                                                        *curList);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       continue;
     }
@@ -10699,18 +10636,17 @@ nsresult HTMLEditRules::PrepareToMakeEle
             *containerName, atEndOfCurPositionedDiv);
         if (NS_WARN_IF(!CanHandleEditAction())) {
           return NS_ERROR_EDITOR_DESTROYED;
         }
         if (NS_WARN_IF(!curList)) {
           return NS_ERROR_FAILURE;
         }
       }
-      rv = MOZ_KnownLive(HTMLEditorRef())
-               .MoveNodeToEndWithTransaction(*listItem, *curList);
+      rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*listItem, *curList);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       // Remember we indented this li
       indentedLI = listItem;
@@ -10740,19 +10676,18 @@ nsresult HTMLEditRules::PrepareToMakeEle
         return NS_ERROR_FAILURE;
       }
       // Remember our new block for postprocessing
       *aTargetElement = curPositionedDiv;
       // curPositionedDiv is now the correct thing to put curNode in
     }
 
     // Tuck the node into the end of the active blockquote
-    rv = MOZ_KnownLive(HTMLEditorRef())
-             .MoveNodeToEndWithTransaction(MOZ_KnownLive(*curNode->AsContent()),
-                                           *curPositionedDiv);
+    rv = HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode->AsContent(),
+                                                      *curPositionedDiv);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
     // Forget curList, if any
     curList = nullptr;
@@ -10761,19 +10696,17 @@ nsresult HTMLEditRules::PrepareToMakeEle
 }
 
 nsresult HTMLEditRules::DidAbsolutePosition() {
   MOZ_ASSERT(IsEditorDataAvailable());
 
   if (!mNewBlock) {
     return NS_OK;
   }
-  OwningNonNull<Element> newBlock(*mNewBlock);
-  nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                    .SetPositionToAbsoluteOrStatic(*newBlock, true);
+  nsresult rv = HTMLEditorRef().SetPositionToAbsoluteOrStatic(*mNewBlock, true);
   if (NS_WARN_IF(!CanHandleEditAction())) {
     return NS_ERROR_EDITOR_DESTROYED;
   }
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
@@ -10800,18 +10733,18 @@ nsresult HTMLEditRules::WillRemoveAbsolu
       HTMLEditorRef().GetAbsolutelyPositionedSelectionContainer();
   if (NS_WARN_IF(!element)) {
     return NS_ERROR_FAILURE;
   }
 
   {
     AutoSelectionRestorer restoreSelectionLater(HTMLEditorRef());
 
-    nsresult rv = MOZ_KnownLive(HTMLEditorRef())
-                      .SetPositionToAbsoluteOrStatic(*element, false);
+    nsresult rv =
+        HTMLEditorRef().SetPositionToAbsoluteOrStatic(*element, false);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
--- a/editor/libeditor/HTMLEditRules.h
+++ b/editor/libeditor/HTMLEditRules.h
@@ -73,49 +73,37 @@ struct StyleCache final : public PropIte
 class HTMLEditRules : public TextEditRules {
  public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLEditRules, TextEditRules)
 
   HTMLEditRules();
 
   // TextEditRules methods
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult Init(TextEditor* aTextEditor) override;
   virtual nsresult DetachEditor() override;
   virtual nsresult BeforeEdit(EditSubAction aEditSubAction,
                               nsIEditor::EDirection aDirection) override;
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult AfterEdit(EditSubAction aEditSubAction,
                              nsIEditor::EDirection aDirection) override;
-  // NOTE: Don't mark WillDoAction() nor DidDoAction() as MOZ_CAN_RUN_SCRIPT
-  //       because they are too generic and doing it makes a lot of public
-  //       editor methods marked as MOZ_CAN_RUN_SCRIPT too, but some of them
-  //       may not causes running script.  So, ideal fix must be that we make
-  //       each method callsed by this method public.
   MOZ_CAN_RUN_SCRIPT_BOUNDARY
   virtual nsresult WillDoAction(EditSubActionInfo& aInfo, bool* aCancel,
                                 bool* aHandled) override;
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY
   virtual nsresult DidDoAction(EditSubActionInfo& aInfo,
                                nsresult aResult) override;
   virtual bool DocumentIsEmpty() override;
 
   /**
    * DocumentModified() is called when editor content is changed.
    */
   MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult DocumentModified();
 
-  MOZ_CAN_RUN_SCRIPT
   nsresult GetListState(bool* aMixed, bool* aOL, bool* aUL, bool* aDL);
-  MOZ_CAN_RUN_SCRIPT
   nsresult GetListItemState(bool* aMixed, bool* aLI, bool* aDT, bool* aDD);
-  MOZ_CAN_RUN_SCRIPT
   nsresult GetAlignment(bool* aMixed, nsIHTMLEditor::EAlignment* aAlign);
-  MOZ_CAN_RUN_SCRIPT
   nsresult GetParagraphState(bool* aMixed, nsAString& outFormat);
 
   /**
    * MakeSureElemStartsAndEndsOnCR() inserts <br> element at start (and/or end)
    * of aNode if neither:
    * - first (last) editable child of aNode is a block or a <br>,
    * - previous (next) sibling of aNode is block or a <br>
    * - nor no previous (next) sibling of aNode.
@@ -181,17 +169,16 @@ class HTMLEditRules : public TextEditRul
    *                            or EditSubAction::eInsertText.
    * @param aCancel             Returns true if the operation is canceled.
    * @param aHandled            Returns true if the edit action is handled.
    * @param inString            String to be inserted.
    * @param outString           String actually inserted.
    * @param aMaxLength          The maximum string length which the editor
    *                            allows to set.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult WillInsertText(EditSubAction aEditSubAction,
                                        bool* aCancel, bool* aHandled,
                                        const nsAString* inString,
                                        nsAString* outString,
                                        int32_t aMaxLength);
 
   /**
    * WillLoadHTML() is called before loading enter document from source.
@@ -218,17 +205,16 @@ class HTMLEditRules : public TextEditRul
   MOZ_MUST_USE nsresult DeleteNodeIfCollapsedText(nsINode& aNode);
 
   /**
    * InsertBRElement() inserts a <br> element into aInsertToBreak.
    *
    * @param aInsertToBreak      The point where new <br> element will be
    *                            inserted before.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult InsertBRElement(const EditorDOMPoint& aInsertToBreak);
 
   /**
    * SplitMailCites() splits mail-cite elements at start of Selection if
    * Selection starts from inside a mail-cite element.  Of course, if it's
    * necessary, this inserts <br> node to new left nodes or existing right
    * nodes.
    */
@@ -324,59 +310,55 @@ class HTMLEditRules : public TextEditRul
    * @return            Sets canceled to true if the operation should do
    *                    nothing anymore even if this doesn't join the blocks.
    *                    Sets handled to true if this actually handles the
    *                    request.  Note that this may set it to true even if this
    *                    does not join the block.  E.g., if the blocks shouldn't
    *                    be joined or it's impossible to join them but it's not
    *                    unexpected case, this returns true with this.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE EditActionResult
   TryToJoinBlocksWithTransaction(nsIContent& aLeftNode, nsIContent& aRightNode);
 
   /**
    * MoveBlock() moves the content from aRightBlock starting from aRightOffset
    * into aLeftBlock at aLeftOffset. Note that the "block" can be inline nodes
    * between <br>s, or between blocks, etc.  DTD containment rules are followed
    * throughout.
    *
    * @return            Sets handled to true if this actually joins the nodes.
    *                    canceled is always false.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE EditActionResult MoveBlock(Element& aLeftBlock,
                                           Element& aRightBlock,
                                           int32_t aLeftOffset,
                                           int32_t aRightOffset);
 
   /**
    * MoveNodeSmart() moves aNode to (aDestElement, aInOutDestOffset).
    * DTD containment rules are followed throughout.
    *
    * @param aOffset                 returns the point after inserted content.
    * @return                        Sets true to handled if this actually moves
    *                                the nodes.
    *                                canceled is always false.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE EditActionResult MoveNodeSmart(nsIContent& aNode,
                                               Element& aDestElement,
                                               int32_t* aInOutDestOffset);
 
   /**
    * MoveContents() moves the contents of aElement to (aDestElement,
    * aInOutDestOffset).  DTD containment rules are followed throughout.
    *
    * @param aInOutDestOffset        updated to point after inserted content.
    * @return                        Sets true to handled if this actually moves
    *                                the nodes.
    *                                canceled is always false.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE EditActionResult MoveContents(Element& aElement,
                                              Element& aDestElement,
                                              int32_t* aInOutDestOffset);
 
   /**
    * DeleteElementsExceptTableRelatedElements() removes elements except
    * table related elements (except <table> itself) and their contents
    * from the DOM tree.
@@ -468,17 +450,16 @@ class HTMLEditRules : public TextEditRul
    * Called before changing absolute positioned element to static positioned.
    * This method actually changes the position property of nearest absolute
    * positioned element.  Therefore, this might cause destroying the HTML
    * editor.
    *
    * @param aCancel             Returns true if the operation is canceled.
    * @param aHandled            Returns true if the edit action is handled.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult WillRemoveAbsolutePosition(bool* aCancel,
                                                    bool* aHandled);
 
   /**
    * Called before changing z-index.
    * This method actually changes z-index of nearest absolute positioned
    * element relatively.  Therefore, this might cause destroying the HTML
    * editor.
@@ -558,69 +539,64 @@ class HTMLEditRules : public TextEditRul
    * with AutoSelectionRestorer.  So, all callers have to check if
    * CanHandleEditAction() still returns true after a call of this method.
    * XXX Should be documented outline of this method.
    *
    * @param aHandled            Returns true if the edit action is handled.
    * @param aTargetElement      Returns target element which should be
    *                            changed to absolute positioned.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult PrepareToMakeElementAbsolutePosition(
       bool* aHandled, RefPtr<Element>* aTargetElement);
 
   /**
    * Called if nobody handles the edit action to make an element absolute
    * positioned.
    * This method actually changes the element which is computed by
    * WillAbsolutePosition() to absolute positioned.
    * Therefore, this might cause destroying the HTML editor.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult DidAbsolutePosition();
 
   /**
    * AlignInnerBlocks() calls AlignBlockContents() for every list item element
    * and table cell element in aNode.
    *
    * @param aNode               The node whose descendants should be aligned
    *                            to aAlignType.
    * @param aAlignType          New value of align attribute of <div>.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult AlignInnerBlocks(nsINode& aNode,
                                          const nsAString& aAlignType);
 
   /**
    * AlignBlockContents() sets align attribute of <div> element which is
    * only child of aNode to aAlignType.  If aNode has 2 or more children or
    * does not have a <div> element has only child, inserts a <div> element
    * into aNode and move all children of aNode into the new <div> element.
    *
    * @param aNode               The node whose contents should be aligned
    *                            to aAlignType.
    * @param aAlignType          New value of align attribute of <div> which
    *                            is only child of aNode.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult AlignBlockContents(nsINode& aNode,
                                            const nsAString& aAlignType);
 
   /**
    * AlignContentsAtSelection() aligns contents around Selection to aAlignType.
    * This creates AutoSelectionRestorer.  Therefore, even if this returns
    * NS_OK, CanHandleEditAction() may return false if the editor is destroyed
    * during restoring the Selection.  So, every caller needs to check if
    * CanHandleEditAction() returns true before modifying the DOM tree or
    * changing Selection.
    *
    * @param aAlignType          New align attribute value where the contents
    *                            should be aligned to.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult AlignContentsAtSelection(const nsAString& aAlignType);
 
   nsresult AppendInnerFormatNodes(nsTArray<OwningNonNull<nsINode>>& aArray,
                                   nsINode* aNode);
   nsresult GetFormatString(nsINode* aNode, nsAString& outFormat);
 
   /**
    * aLists and aTables allow the caller to specify what kind of content to
@@ -696,60 +672,55 @@ class HTMLEditRules : public TextEditRul
    * Enter key press) in a list item element.
    *
    * @param aListItem           The list item which has the following point.
    * @param aNode               Typically, Selection start container, where to
    *                            insert a break.
    * @param aOffset             Typically, Selection start offset in the
    *                            start container, where to insert a break.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult ReturnInListItem(Element& aListItem, nsINode& aNode,
                                          int32_t aOffset);
 
   /**
    * Called after handling edit action.  This may adjust Selection, remove
    * unnecessary empty nodes, create <br> elements if needed, etc.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult AfterEditInner(EditSubAction aEditSubAction,
                                        nsIEditor::EDirection aDirection);
 
   /**
    * IndentAroundSelectionWithCSS() indents around Selection with CSS.
    * This method creates AutoSelectionRestorer.  Therefore, each caller
    * need to check if the editor is still available even if this returns
    * NS_OK.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult IndentAroundSelectionWithCSS();
 
   /**
    * IndentAroundSelectionWithHTML() indents around Selection with HTML.
    * This method creates AutoSelectionRestorer.  Therefore, each caller
    * need to check if the editor is still available even if this returns
    * NS_OK.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult IndentAroundSelectionWithHTML();
 
   /**
    * OutdentAroundSelection() outdents contents around Selection.
    * This method creates AutoSelectionRestorer.  Therefore, each caller
    * need to check if the editor is still available even if this returns
    * NS_OK.
    *
    * @return                    The left content is left content of last
    *                            outdented element.
    *                            The right content is right content of last
    *                            outdented element.
    *                            The middle content is middle content of last
    *                            outdented element.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE SplitRangeOffFromNodeResult OutdentAroundSelection();
 
   /**
    * SplitRangeOffFromBlockAndRemoveMiddleContainer() splits the nodes
    * between aStartOfRange and aEndOfRange, then, removes the middle element
    * and moves its content to where the middle element was.
    *
    * @param aBlockElement           The node which will be split.
@@ -759,17 +730,16 @@ class HTMLEditRules : public TextEditRul
    *                                aBlockElement.
    * @return                        The left content is new created left
    *                                element of aBlockElement.
    *                                The right content is split element,
    *                                i.e., must be aBlockElement.
    *                                The middle content is nullptr since
    *                                removing it is the job of this method.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE SplitRangeOffFromNodeResult
   SplitRangeOffFromBlockAndRemoveMiddleContainer(Element& aBlockElement,
                                                  nsIContent& aStartOfRange,
                                                  nsIContent& aEndOfRange);
 
   /**
    * SplitRangeOffFromBlock() splits aBlock at two points, before aStartChild
    * and after aEndChild.  If they are very start or very end of aBlcok, this
@@ -801,28 +771,26 @@ class HTMLEditRules : public TextEditRul
    *                                or something.
    * @return                        The left content is new created element
    *                                splitting before aStartOfOutdent.
    *                                The right content is existing element.
    *                                The middle content is outdented element
    *                                if aIsBlockIndentedWithCSS is true.
    *                                Otherwise, nullptr.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE SplitRangeOffFromNodeResult
   OutdentPartOfBlock(Element& aBlockElement, nsIContent& aStartOfOutdent,
                      nsIContent& aEndOutdent, bool aIsBlockIndentedWithCSS);
 
   /**
    * XXX Should document what this does.
    * This method creates AutoSelectionRestorer.  Therefore, each caller
    * need to check if the editor is still available even if this returns
    * NS_OK.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult MakeList(nsAtom& aListType, bool aEntireList,
                                  const nsAString* aBulletType, bool* aCancel,
                                  nsAtom& aItemType);
 
   /**
    * ConvertListType() replaces child list items of aListElement with
    * new list item element whose tag name is aNewListItemTag.
    * Note that if there are other list elements as children of aListElement,
@@ -831,28 +799,26 @@ class HTMLEditRules : public TextEditRul
    * @param aListElement        The list element whose list items will be
    *                            replaced.
    * @param aNewListTag         New list tag name.
    * @param aNewListItemTag     New list item tag name.
    * @return                    New list element or an error code if it fails.
    *                            New list element may be aListElement if its
    *                            tag name is same as aNewListTag.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE CreateElementResult ConvertListType(Element& aListElement,
                                                    nsAtom& aListType,
                                                    nsAtom& aItemType);
 
   /**
    * CreateStyleForInsertText() sets CSS properties which are stored in
    * TypeInState to proper element node.
    *
    * @param aDocument           The document of the editor.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult CreateStyleForInsertText(dom::Document& aDocument);
 
   /**
    * IsEmptyBlockElement() returns true if aElement is a block level element
    * and it doesn't have any visible content.
    */
   enum class IgnoreSingleBR { eYes, eNo };
   bool IsEmptyBlockElement(Element& aElement, IgnoreSingleBR aIgnoreSingleBR);
@@ -930,52 +896,47 @@ class HTMLEditRules : public TextEditRul
   /**
    * GetNodesForOperation() runs through the ranges in the array and construct a
    * new array of nodes to be acted on.
    *
    * XXX This name stats with "Get" but actually this modifies the DOM tree with
    *     transaction.  We should rename this to making clearer what this does.
    */
   enum class TouchContent { no, yes };
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult GetNodesForOperation(
       nsTArray<RefPtr<nsRange>>& aArrayOfRanges,
       nsTArray<OwningNonNull<nsINode>>& aOutArrayOfNodes,
       EditSubAction aEditSubAction, TouchContent aTouchContent);
 
   void GetChildNodesForOperation(
       nsINode& aNode, nsTArray<OwningNonNull<nsINode>>& outArrayOfNodes);
 
   /**
    * GetNodesFromPoint() constructs a list of nodes from a point that will be
    * operated on.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult
   GetNodesFromPoint(const EditorDOMPoint& aPoint, EditSubAction aEditSubAction,
                     nsTArray<OwningNonNull<nsINode>>& outArrayOfNodes,
                     TouchContent aTouchContent);
 
   /**
    * GetNodesFromSelection() constructs a list of nodes from the selection that
    * will be operated on.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult
   GetNodesFromSelection(EditSubAction aEditSubAction,
                         nsTArray<OwningNonNull<nsINode>>& outArrayOfNodes,
                         TouchContent aTouchContent);
 
   enum class EntireList { no, yes };
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult
   GetListActionNodes(nsTArray<OwningNonNull<nsINode>>& aOutArrayOfNodes,
                      EntireList aEntireList, TouchContent aTouchContent);
   void GetDefinitionListItemTypes(Element* aElement, bool* aDT, bool* aDD);
-  MOZ_CAN_RUN_SCRIPT
   nsresult GetParagraphFormatNodes(
       nsTArray<OwningNonNull<nsINode>>& outArrayOfNodes);
   void LookInsideDivBQandList(nsTArray<OwningNonNull<nsINode>>& aNodeArray);
 
   /**
    * BustUpInlinesAtRangeEndpoints() splits nodes at both start and end of
    * aRangeItem.  If this splits at every point, this modifies aRangeItem
    * to point each split point (typically, right node).  Note that this splits
@@ -993,17 +954,16 @@ class HTMLEditRules : public TextEditRul
    * this returns all <br> elements, every left node and aNode with
    * aOutArrayNodes.
    *
    * @param aNode               An inline container element.
    * @param aOutArrayOfNodes    All found <br> elements, left nodes (may not
    *                            be set if <br> is at start edge of aNode) and
    *                            aNode itself.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult BustUpInlinesAtBRs(
       nsIContent& aNode, nsTArray<OwningNonNull<nsINode>>& aOutArrayOfNodes);
 
   /**
    * GetHiestInlineParent() returns the highest inline node parent between
    * aNode and the editing host.  Even if the editing host is an inline
    * element, this method never returns the editing host as the result.
    */
@@ -1020,17 +980,16 @@ class HTMLEditRules : public TextEditRul
   /**
    * RemoveBlockStyle() removes all format blocks, table related element,
    * etc in aNodeArray.
    * If aNodeArray has a format node, it will be removed and its contents
    * will be moved to where it was.
    * If aNodeArray has a table related element, <li>, <blockquote> or <div>,
    * it will removed and its contents will be moved to where it was.
    */
-  MOZ_CAN_RUN_SCRIPT
   nsresult RemoveBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray);
 
   /**
    * ApplyBlockStyle() formats all nodes in aNodeArray with block elements
    * whose name is aBlockTag.
    * If aNodeArray has an inline element, a block element is created and the
    * inline element and following inline elements are moved into the new block
    * element.
@@ -1039,30 +998,28 @@ class HTMLEditRules : public TextEditRul
    * elements.
    * If aNodeArray has a block element, this calls itself with children of
    * the block element.  Then, new block element will be created when there
    * are some remaining inline elements.
    *
    * @param aNodeArray      Must be descendants of a node.
    * @param aBlockTag       The element name of new block elements.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult ApplyBlockStyle(
       nsTArray<OwningNonNull<nsINode>>& aNodeArray, nsAtom& aBlockTag);
 
   /**
    * MakeBlockquote() inserts at least one <blockquote> element and moves
    * nodes in aNodeArray into new <blockquote> elements.  If aNodeArray
    * includes a table related element except <table>, this calls itself
    * recursively to insert <blockquote> into the cell.
    *
    * @param aNodeArray          Nodes which will be moved into created
    *                            <blockquote> elements.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult
   MakeBlockquote(nsTArray<OwningNonNull<nsINode>>& aNodeArray);
 
   /**
    * MaybeSplitAncestorsForInsertWithTransaction() does nothing if container of
    * aStartOfDeepestRightNode can have an element whose tag name is aTag.
    * Otherwise, looks for an ancestor node which is or is in active editing
    * host and can have an element whose name is aTag.  If there is such
@@ -1098,17 +1055,16 @@ class HTMLEditRules : public TextEditRul
    *     any users...
    *
    * @param aLeftNode   The node which will be removed.
    * @param aRightNode  The node which will be inserted the content of
    *                    aLeftNode.
    * @param aNewFirstChildOfRightNode
    *                    The point at the first child of aRightNode.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult JoinNearestEditableNodesWithTransaction(
       nsIContent& aLeftNode, nsIContent& aRightNode,
       EditorDOMPoint* aNewFirstChildOfRightNode);
 
   Element* GetTopEnclosingMailCite(nsINode& aNode);
 
   /**
    * PopListItem() tries to move aListItem outside its parent.  If it's
@@ -1120,33 +1076,31 @@ class HTMLEditRules : public TextEditRul
    * element was.
    *
    * @param aListItem           Should be a <li>, <dt> or <dd> element.
    *                            If it's not so, returns NS_ERROR_FAILURE.
    * @param aOutOfList          Returns true if the list item element is
    *                            removed (i.e., unwrapped contents of
    *                            aListItem).  Otherwise, false.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult PopListItem(nsIContent& aListItem,
                                     bool* aOutOfList = nullptr);
 
   /**
    * RemoveListStructure() destroys the list structure of aListElement.
    * If aListElement has <li>, <dl> or <dt> as a child, the element is removed
    * but its descendants are moved to where the list item element was.
    * If aListElement has another <ul>, <ol> or <dl> as a child, this method
    * is called recursively.
    * If aListElement has other nodes as its child, they are just removed.
    * Finally, aListElement is removed. and its all children are moved to
    * where the aListElement was.
    *
    * @param aListElement        A <ul>, <ol> or <dl> element.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult RemoveListStructure(Element& aListElement);
 
   /**
    * CacheInlineStyles() caches style of aNode into mCachedStyles.
    * This may cause flushing layout at retrieving computed value of CSS
    * properties.
    */
   MOZ_MUST_USE nsresult CacheInlineStyles(nsINode* aNode);
@@ -1257,17 +1211,16 @@ class HTMLEditRules : public TextEditRul
    * @param aAlignType          New align value to be set only when it's in
    *                            CSS mode and this method meets <table> or <hr>.
    *                            XXX This is odd and not clear when you see
    *                                caller of this method.  Do you have better
    *                                idea?
    * @param aDescendantsOnly    true if align information of aNode itself
    *                            shouldn't be removed.  Otherwise, false.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult RemoveAlignment(nsINode& aNode,
                                         const nsAString& aAlignType,
                                         bool aDescendantsOnly);
 
   /**
    * MakeSureElemStartsOrEndsOnCR() inserts <br> element at start (end) of
    * aNode if neither:
    * - first (last) editable child of aNode is a block or a <br>,
@@ -1287,56 +1240,52 @@ class HTMLEditRules : public TextEditRul
    *
    * @param aElement            The element whose contents will be aligned.
    * @param aAlignType          Boundary or "center" which contents should be
    *                            aligned on.
    * @param aResetAlignOf       Resets align of whether element and its
    *                            descendants or only descendants.
    */
   enum class ResetAlignOf { ElementAndDescendants, OnlyDescendants };
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult AlignBlock(Element& aElement,
                                    const nsAString& aAlignType,
                                    ResetAlignOf aResetAlignOf);
 
   /**
    * IncreaseMarginToIndent() increases the margin of aElement.  See the
    * document of ChangeMarginStart() for the detail.
    * XXX This is not aware of vertical writing-mode.
    *
    * @param aElement            The element to be indented.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult IncreaseMarginToIndent(Element& aElement) {
     return ChangeMarginStart(aElement, true);
   }
 
   /**
    * DecreaseMarginToOutdent() decreases the margin of aElement.  See the
    * document of ChangeMarginStart() for the detail.
    * XXX This is not aware of vertical writing-mode.
    *
    * @param aElement            The element to be outdented.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult DecreaseMarginToOutdent(Element& aElement) {
     return ChangeMarginStart(aElement, false);
   }
 
   /**
    * ChangeMarginStart() changes margin of aElement to indent or outdent.
    * However, use IncreaseMarginToIndent() and DecreaseMarginToOutdent()
    * instead.  If it's rtl text, margin-right will be changed.  Otherwise,
    * margin-left.
    * XXX This is not aware of vertical writing-mode.
    *
    * @param aElement            The element to be indented or outdented.
    * @param aIncrease           true for indent, false for outdent.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult ChangeMarginStart(Element& aElement, bool aIncrease);
 
   /**
    * DocumentModifiedWorker() is called by DocumentModified() either
    * synchronously or asynchronously.
    */
   MOZ_CAN_RUN_SCRIPT void DocumentModifiedWorker();
 
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -495,18 +495,17 @@ HTMLEditor::SetFlags(uint32_t aFlags) {
 
 nsresult HTMLEditor::InitRules() {
   MOZ_ASSERT(IsEditActionDataAvailable());
 
   if (!mRules) {
     // instantiate the rules for the html editor
     mRules = new HTMLEditRules();
   }
-  RefPtr<TextEditRules> rules(mRules);
-  return rules->Init(this);
+  return mRules->Init(this);
 }
 
 NS_IMETHODIMP
 HTMLEditor::BeginningOfDocument() {
   AutoEditActionDataSetter editActionData(*this, EditAction::eNotEditing);
   if (NS_WARN_IF(!editActionData.CanHandle())) {
     return NS_ERROR_NOT_INITIALIZED;
   }
@@ -1480,18 +1479,17 @@ HTMLEditor::RebuildDocumentFromSource(co
       range->CreateContextualFragment(bodyTag, erv);
   NS_ENSURE_TRUE(!erv.Failed(), erv.StealNSResult());
   NS_ENSURE_TRUE(docfrag, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<nsIContent> child = docfrag->GetFirstChild();
   NS_ENSURE_TRUE(child && child->IsElement(), NS_ERROR_NULL_POINTER);
 
   // Copy all attributes from the div child to current body element
-  CloneAttributesWithTransaction(*rootElement,
-                                 MOZ_KnownLive(*child->AsElement()));
+  CloneAttributesWithTransaction(*rootElement, *child->AsElement());
 
   // place selection at first editable content
   return MaybeCollapseSelectionAtFirstEditableNode(false);
 }
 
 EditorRawDOMPoint HTMLEditor::GetBetterInsertionPointFor(
     nsINode& aNodeToInsert, const EditorRawDOMPoint& aPointToInsert) {
   if (NS_WARN_IF(!aPointToInsert.IsSet())) {
@@ -2942,17 +2940,17 @@ HTMLEditor::InsertLinkAroundSelection(El
       // We must clear the string buffers
       //   because GetValue appends to previous string!
       value.Truncate();
 
       nsAtom* name = attribute->NodeInfo()->NameAtom();
 
       attribute->GetValue(value);
 
-      rv = SetInlinePropertyInternal(*nsGkAtoms::a, MOZ_KnownLive(name), value);
+      rv = SetInlinePropertyInternal(*nsGkAtoms::a, name, value);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
   }
   return NS_OK;
 }
 
@@ -4569,18 +4567,18 @@ nsresult HTMLEditor::CopyLastEditableChi
       // Clone all attributes.
       // XXX Looks like that this clones id attribute too.
       CloneAttributesWithTransaction(*lastClonedElement,
                                      *elementInPreviousBlock);
       continue;
     }
     // Otherwise, inserts new parent inline container to the previous inserted
     // inline container.
-    lastClonedElement = InsertContainerWithTransaction(*lastClonedElement,
-                                                       MOZ_KnownLive(*tagName));
+    lastClonedElement =
+        InsertContainerWithTransaction(*lastClonedElement, *tagName);
     if (NS_WARN_IF(!lastClonedElement)) {
       return NS_ERROR_FAILURE;
     }
     CloneAttributesWithTransaction(*lastClonedElement, *elementInPreviousBlock);
   }
 
   if (!firstClonsedElement) {
     // XXX Even if no inline elements are cloned, shouldn't we create new
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -121,17 +121,16 @@ class HTMLEditor final : public TextEdit
 
   nsHTMLDocument* GetHTMLDocument() const;
 
   virtual void PreDestroy(bool aDestroyingFrames) override;
 
   bool GetReturnInParagraphCreatesNewParagraph();
 
   // TextEditor overrides
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult Init(Document& aDoc, Element* aRoot,
                         nsISelectionController* aSelCon, uint32_t aFlags,
                         const nsAString& aValue) override;
   NS_IMETHOD BeginningOfDocument() override;
   NS_IMETHOD SetFlags(uint32_t aFlags) override;
 
   NS_IMETHOD CanPaste(int32_t aSelectionType, bool* aCanPaste) override;
 
@@ -196,17 +195,16 @@ class HTMLEditor final : public TextEdit
    *       the DOM tree nor undo transactions, and does not refer Selection,
    *       HTMLEditRules, etc.
    *
    * @param aTagName            The new element's tag name.  If the name is
    *                            one of "href", "anchor" or "namedanchor",
    *                            this creates an <a> element.
    * @return                    Newly created element.
    */
-  MOZ_CAN_RUN_SCRIPT
   already_AddRefed<Element> CreateElementWithDefaults(const nsAtom& aTagName);
 
   /**
    * Indent or outdent content around Selection.
    */
   nsresult IndentAsAction();
   nsresult OutdentAsAction();
 
@@ -221,17 +219,16 @@ class HTMLEditor final : public TextEdit
                        dom::Event* aMouseEvent);
 
   /**
    * event callback when a mouse button is released
    * @param aX      [IN] horizontal position of the pointer
    * @param aY      [IN] vertical position of the pointer
    * @param aTarget [IN] the element triggering the event
    */
-  MOZ_CAN_RUN_SCRIPT
   nsresult OnMouseUp(int32_t aX, int32_t aY, Element* aTarget);
 
   /**
    * event callback when the mouse pointer is moved
    * @param aMouseEvent [IN] the event
    */
   MOZ_CAN_RUN_SCRIPT nsresult OnMouseMove(dom::MouseEvent* aMouseEvent);
 
@@ -343,17 +340,16 @@ class HTMLEditor final : public TextEdit
   nsresult AddZIndex(int32_t aChange);
 
   /**
    * SetInlinePropertyAsAction() sets a property which changes inline style of
    * text.  E.g., bold, italic, super and sub.
    * This automatically removes exclusive style, however, treats all changes
    * as a transaction.
    */
-  MOZ_CAN_RUN_SCRIPT
   nsresult SetInlinePropertyAsAction(nsAtom& aProperty, nsAtom* aAttribute,
                                      const nsAString& aValue);
 
   nsresult GetInlineProperty(nsAtom* aProperty, nsAtom* aAttribute,
                              const nsAString& aValue, bool* aFirst, bool* aAny,
                              bool* aAll);
   nsresult GetInlinePropertyWithAttrValue(nsAtom* aProperty, nsAtom* aAttr,
                                           const nsAString& aValue, bool* aFirst,
@@ -370,17 +366,16 @@ class HTMLEditor final : public TextEdit
    *                    attribute will be removed.
    *                    If nsGkAtoms::name, <a> element which has non-empty
    *                    name attribute will be removed.
    * @param aAttribute  If aProperty is nsGkAtoms::font, aAttribute should be
    *                    nsGkAtoms::fase, nsGkAtoms::size, nsGkAtoms::color or
    *                    nsGkAtoms::bgcolor.  Otherwise, set nullptr.
    *                    Must not use nsGkAtoms::_empty here.
    */
-  MOZ_CAN_RUN_SCRIPT
   nsresult RemoveInlinePropertyAsAction(nsAtom& aProperty, nsAtom* aAttribute);
 
   /**
    * GetFontColorState() returns foreground color information in first
    * range of Selection.
    * If first range of Selection is collapsed and there is a cache of style for
    * new text, aIsMixed is set to false and aColor is set to the cached color.
    * If first range of Selection is collapsed and there is no cached color,
@@ -455,16 +450,26 @@ class HTMLEditor final : public TextEdit
                                        nsINode* aNode) const;
 
   /**
    * Get an active editor's editing host in DOM window.  If this editor isn't
    * active in the DOM window, this returns NULL.
    */
   Element* GetActiveEditingHost() const;
 
+  /** Insert a string as quoted text
+   * (whose representation is dependant on the editor type),
+   * replacing the selected text (if any).
+   *
+   * @param aQuotedText    The actual text to be quoted
+   * @parem aNodeInserted  Return the node which was inserted.
+   */
+  nsresult InsertAsQuotation(const nsAString& aQuotedText,
+                             nsINode** aNodeInserted);
+
   /**
    * Inserts a plaintext string at the current location,
    * with special processing for lines beginning with ">",
    * which will be treated as mail quotes and inserted
    * as plaintext quoted blocks.
    * If the selection is not collapsed, the selection is deleted
    * and the insertion takes place at the resulting collapsed selection.
    *
@@ -512,17 +517,16 @@ class HTMLEditor final : public TextEdit
    * @param aLength             Length of removing text.
    */
   nsresult DeleteTextWithTransaction(dom::CharacterData& aTextNode,
                                      uint32_t aOffset, uint32_t aLength);
 
   /**
    * InsertTextWithTransaction() inserts aStringToInsert at aPointToInsert.
    */
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult InsertTextWithTransaction(
       Document& aDocument, const nsAString& aStringToInsert,
       const EditorRawDOMPoint& aPointToInsert,
       EditorRawDOMPoint* aPointAfterInsertedString = nullptr) override;
 
   /**
    * CopyLastEditableChildStyles() clones inline container elements into
    * aPreviousBlock to aNewBlock to keep using same style in it.
@@ -530,39 +534,35 @@ class HTMLEditor final : public TextEdit
    * @param aPreviousBlock      The previous block element.  All inline
    *                            elements which are last sibling of each level
    *                            are cloned to aNewBlock.
    * @param aNewBlock           New block container element.
    * @param aNewBrElement       If this method creates a new <br> element for
    *                            placeholder, this is set to the new <br>
    *                            element.
    */
-  MOZ_CAN_RUN_SCRIPT
   nsresult CopyLastEditableChildStylesWithTransaction(
       Element& aPreviousBlock, Element& aNewBlock,
       RefPtr<Element>* aNewBrElement);
 
   /**
    * RemoveBlockContainerWithTransaction() removes aElement from the DOM tree
    * but moves its all children to its parent node and if its parent needs <br>
    * element to have at least one line-height, this inserts <br> element
    * automatically.
    *
    * @param aElement            Block element to be removed.
    */
-  MOZ_CAN_RUN_SCRIPT
   nsresult RemoveBlockContainerWithTransaction(Element& aElement);
 
   virtual Element* GetEditorRoot() const override;
   using EditorBase::IsEditable;
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult RemoveAttributeOrEquivalent(
       Element* aElement, nsAtom* aAttribute,
       bool aSuppressTransaction) override;
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult SetAttributeOrEquivalent(Element* aElement,
                                             nsAtom* aAttribute,
                                             const nsAString& aValue,
                                             bool aSuppressTransaction) override;
   using EditorBase::RemoveAttributeOrEquivalent;
   using EditorBase::SetAttributeOrEquivalent;
 
   /**
@@ -662,17 +662,16 @@ class HTMLEditor final : public TextEdit
 
   /**
    * extracts an element from the normal flow of the document and
    * positions it, and puts it back in the normal flow.
    * @param aElement [IN] the element
    * @param aEnabled [IN] true to absolutely position the element,
    *                      false to put it back in the normal flow
    */
-  MOZ_CAN_RUN_SCRIPT
   nsresult SetPositionToAbsoluteOrStatic(Element& aElement, bool aEnabled);
 
   /**
    * adds aChange to the z-index of an arbitrary element.
    * @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
@@ -760,22 +759,20 @@ class HTMLEditor final : public TextEdit
    * Small utility routine to test if a break node is visible to user.
    */
   bool IsVisibleBRElement(nsINode* aNode);
 
   /**
    * Helper routines for font size changing.
    */
   enum class FontSize { incr, decr };
-  MOZ_CAN_RUN_SCRIPT
   nsresult RelativeFontChangeOnTextNode(FontSize aDir, Text& aTextNode,
                                         int32_t aStartOffset,
                                         int32_t aEndOffset);
 
-  MOZ_CAN_RUN_SCRIPT
   nsresult SetInlinePropertyOnNode(nsIContent& aNode, nsAtom& aProperty,
                                    nsAtom* aAttribute, const nsAString& aValue);
 
   nsresult SplitStyleAbovePoint(nsCOMPtr<nsINode>* aNode, int32_t* aOffset,
                                 nsAtom* aProperty, nsAtom* aAttribute,
                                 nsIContent** aOutLeftNode = nullptr,
                                 nsIContent** aOutRightNode = nullptr);
 
@@ -928,36 +925,33 @@ class HTMLEditor final : public TextEdit
 
   nsIContent* GetFirstEditableLeaf(nsINode& aNode);
   nsIContent* GetLastEditableLeaf(nsINode& aNode);
 
   nsresult GetInlinePropertyBase(nsAtom& aProperty, nsAtom* aAttribute,
                                  const nsAString* aValue, bool* aFirst,
                                  bool* aAny, bool* aAll, nsAString* outValue);
 
-  MOZ_CAN_RUN_SCRIPT
   nsresult ClearStyle(nsCOMPtr<nsINode>* aNode, int32_t* aOffset,
                       nsAtom* aProperty, nsAtom* aAttribute);
 
   nsresult SetPositionToAbsolute(Element& aElement);
-  MOZ_CAN_RUN_SCRIPT
   nsresult SetPositionToStatic(Element& aElement);
 
   /**
    * OnModifyDocument() is called when the editor is changed.  This should
    * be called only by HTMLEditRules::DocumentModifiedWorker() to call
    * HTMLEditRules::OnModifyDocument() with AutoEditActionDataSetter
    * instance.
    */
   MOZ_CAN_RUN_SCRIPT void OnModifyDocument();
 
  protected:  // Called by helper classes.
   virtual void OnStartToHandleTopLevelEditSubAction(
       EditSubAction aEditSubAction, nsIEditor::EDirection aDirection) override;
-  MOZ_CAN_RUN_SCRIPT
   virtual void OnEndHandlingTopLevelEditSubAction() override;
 
  protected:  // Shouldn't be used by friend classes
   virtual ~HTMLEditor();
 
   /**
    * InsertParagraphSeparatorAsSubAction() inserts a line break if it's
    * HTMLEditor and it's possible.
@@ -1436,17 +1430,16 @@ class HTMLEditor final : public TextEdit
    *                        element.
    * @param aCitation       cite attribute value of new <blockquote> element.
    * @param aInsertHTML     true if aQuotedText should be treated as HTML
    *                        source.
    *                        false if aQuotedText should be treated as plain
    *                        text.
    * @param aNodeInserted   [OUT] The new <blockquote> element.
    */
-  MOZ_CAN_RUN_SCRIPT
   nsresult InsertAsCitedQuotationInternal(const nsAString& aQuotedText,
                                           const nsAString& aCitation,
                                           bool aInsertHTML,
                                           nsINode** aNodeInserted);
 
   /**
    * InsertNodeIntoProperAncestorWithTransaction() attempts to insert aNode
    * into the document, at aPointToInsert.  Checks with strict dtd to see if
@@ -1460,17 +1453,17 @@ class HTMLEditor final : public TextEdit
    *
    * @param aNode             Node to insert.
    * @param aPointToInsert    Insertion point.
    * @param aSplitAtEdges     Splitting can result in empty nodes?
    * @return                  Returns inserted point if succeeded.
    *                          Otherwise, the result is not set.
    */
   template <typename PT, typename CT>
-  MOZ_CAN_RUN_SCRIPT EditorDOMPoint InsertNodeIntoProperAncestorWithTransaction(
+  EditorDOMPoint InsertNodeIntoProperAncestorWithTransaction(
       nsIContent& aNode, const EditorDOMPointBase<PT, CT>& aPointToInsert,
       SplitAtEdges aSplitAtEdges);
 
   /**
    * InsertBrElementAtSelectionWithTransaction() inserts a new <br> element at
    * selection.  If there is non-collapsed selection ranges, the selected
    * ranges is deleted first.
    */
@@ -1491,33 +1484,29 @@ class HTMLEditor final : public TextEdit
    * Selection.  Callers have to guarantee that there is a placeholder
    * transaction.
    *
    * @param aEditSubAction      Must be EditSubAction::eIndent or
    *                            EditSubAction::eOutdent.
    */
   nsresult IndentOrOutdentAsSubAction(EditSubAction aEditSubAction);
 
-  MOZ_CAN_RUN_SCRIPT
   nsresult LoadHTML(const nsAString& aInputString);
 
-  MOZ_CAN_RUN_SCRIPT
   nsresult SetInlinePropertyInternal(nsAtom& aProperty, nsAtom* aAttribute,
                                      const nsAString& aValue);
-  MOZ_CAN_RUN_SCRIPT
   nsresult RemoveInlinePropertyInternal(nsAtom* aProperty, nsAtom* aAttribute);
 
   /**
    * ReplaceHeadContentsWithSourceWithTransaction() replaces all children of
    * <head> element with given source code.  This is undoable.
    *
    * @param aSourceToInsert     HTML source fragment to replace the children
    *                            of <head> element.
    */
-  MOZ_CAN_RUN_SCRIPT
   nsresult ReplaceHeadContentsWithSourceWithTransaction(
       const nsAString& aSourceToInsert);
 
   nsresult GetCSSBackgroundColorState(bool* aMixed, nsAString& aOutColor,
                                       bool aBlockLevel);
   nsresult GetHTMLBackgroundColorState(bool* aMixed, nsAString& outColor);
 
   nsresult GetLastCellInRow(nsINode* aRowNode, nsINode** aCellNode);
@@ -1636,33 +1625,31 @@ class HTMLEditor final : public TextEdit
    public:
     BlobReader(dom::BlobImpl* aBlob, HTMLEditor* aHTMLEditor, bool aIsSafe,
                Document* aSourceDoc, const EditorDOMPoint& aPointToInsert,
                bool aDoDeleteSelection);
 
     NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(BlobReader)
     NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(BlobReader)
 
-    MOZ_CAN_RUN_SCRIPT
     nsresult OnResult(const nsACString& aResult);
     nsresult OnError(const nsAString& aErrorName);
 
    private:
     ~BlobReader() {}
 
     RefPtr<dom::BlobImpl> mBlob;
     RefPtr<HTMLEditor> mHTMLEditor;
     nsCOMPtr<Document> mSourceDoc;
     EditorDOMPoint mPointToInsert;
     EditAction mEditAction;
     bool mIsSafe;
     bool mDoDeleteSelection;
   };
 
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult InitRules() override;
 
   virtual void CreateEventListeners() override;
   virtual nsresult InstallEventListeners() override;
   virtual void RemoveEventListeners() override;
 
   bool ShouldReplaceRootElement();
   void NotifyRootChanged();
@@ -1751,17 +1738,16 @@ class HTMLEditor final : public TextEdit
                                           InsertPosition aInsertPosition);
 
   /**
    * Insert a new cell after or before supplied aCell.
    * Optional: If aNewCell supplied, returns the newly-created cell (addref'd,
    * of course)
    * This doesn't change or use the current selection.
    */
-  MOZ_CAN_RUN_SCRIPT
   nsresult InsertCell(Element* aCell, int32_t aRowSpan, int32_t aColSpan,
                       bool aAfter, bool aIsHeader, Element** aNewCell);
 
   /**
    * DeleteSelectedTableColumnsWithTransaction() removes cell elements which
    * belong to same columns of selected cell elements.
    * If only one cell element is selected or first selection range is
    * in a cell, removes cell elements which belong to same column.
@@ -1854,17 +1840,16 @@ class HTMLEditor final : public TextEdit
    *
    * @param aElement        The element whose children you want to remove.
    */
   nsresult DeleteAllChildrenWithTransaction(Element& aElement);
 
   /**
    * Move all contents from aCellToMerge into aTargetCell (append at end).
    */
-  MOZ_CAN_RUN_SCRIPT
   nsresult MergeCells(RefPtr<Element> aTargetCell, RefPtr<Element> aCellToMerge,
                       bool aDeleteCellToMerge);
 
   /**
    * DeleteTableElementAndChildren() removes aTableElement (and its children)
    * from the DOM tree with transaction.
    *
    * @param aTableElement   The <table> element which you want to remove.
@@ -1912,22 +1897,20 @@ class HTMLEditor final : public TextEdit
    */
   nsresult GetCellContext(Element** aTable, Element** aCell,
                           nsINode** aCellParent, int32_t* aCellOffset,
                           int32_t* aRowIndex, int32_t* aColIndex);
 
   nsresult GetCellSpansAt(Element* aTable, int32_t aRowIndex, int32_t aColIndex,
                           int32_t& aActualRowSpan, int32_t& aActualColSpan);
 
-  MOZ_CAN_RUN_SCRIPT
   nsresult SplitCellIntoColumns(Element* aTable, int32_t aRowIndex,
                                 int32_t aColIndex, int32_t aColSpanLeft,
                                 int32_t aColSpanRight, Element** aNewCell);
 
-  MOZ_CAN_RUN_SCRIPT
   nsresult SplitCellIntoRows(Element* aTable, int32_t aRowIndex,
                              int32_t aColIndex, int32_t aRowSpanAbove,
                              int32_t aRowSpanBelow, Element** aNewCell);
 
   nsresult CopyCellBackgroundColor(Element* aDestCell, Element* aSourceCell);
 
   /**
    * Reduce rowspan/colspan when cells span into nonexistent rows/columns.
@@ -1942,17 +1925,16 @@ class HTMLEditor final : public TextEdit
    *     bigger or smaller rowspan or colspan than actual number of cells,
    *     this always failed to scan the table.  Therefore, this does nothing
    *     when the table should be normalized.
    *
    * @param aTableOrElementInTable  An element which is in a <table> element
    *                                or <table> element itself.  Otherwise,
    *                                this returns NS_OK but does nothing.
    */
-  MOZ_CAN_RUN_SCRIPT
   nsresult NormalizeTableInternal(Element& aTableOrElementInTable);
 
   /**
    * Fallback method: Call this after using ClearSelection() and you
    * failed to set selection to some other content in the document.
    */
   nsresult SetSelectionAtDocumentStart();
 
@@ -2066,49 +2048,43 @@ class HTMLEditor final : public TextEdit
    * @param aTagName            A block level element name.  Must NOT be
    *                            nsGkAtoms::dt nor nsGkAtoms::dd.
    */
   nsresult InsertBasicBlockWithTransaction(nsAtom& aTagName);
 
   /**
    * Increase/decrease the font size of selection.
    */
-  MOZ_CAN_RUN_SCRIPT
   nsresult RelativeFontChange(FontSize aDir);
 
-  MOZ_CAN_RUN_SCRIPT
   nsresult RelativeFontChangeOnNode(int32_t aSizeChange, nsIContent* aNode);
-  MOZ_CAN_RUN_SCRIPT
   nsresult RelativeFontChangeHelper(int32_t aSizeChange, nsINode* aNode);
 
   /**
    * Helper routines for inline style.
    */
-  MOZ_CAN_RUN_SCRIPT
   nsresult SetInlinePropertyOnTextNode(Text& aData, int32_t aStartOffset,
                                        int32_t aEndOffset, nsAtom& aProperty,
                                        nsAtom* aAttribute,
                                        const nsAString& aValue);
 
   nsresult PromoteInlineRange(nsRange& aRange);
   nsresult PromoteRangeIfStartsOrEndsInNamedAnchor(nsRange& aRange);
   nsresult SplitStyleAboveRange(nsRange* aRange, nsAtom* aProperty,
                                 nsAtom* aAttribute);
-  MOZ_CAN_RUN_SCRIPT
   nsresult RemoveStyleInside(nsIContent& aNode, nsAtom* aProperty,
                              nsAtom* aAttribute,
                              const bool aChildrenOnly = false);
 
   bool NodeIsProperty(nsINode& aNode);
   bool IsAtFrontOfNode(nsINode& aNode, int32_t aOffset);
   bool IsAtEndOfNode(nsINode& aNode, int32_t aOffset);
   bool IsOnlyAttribute(const Element* aElement, nsAtom* aAttribute);
 
   bool HasStyleOrIdOrClass(Element* aElement);
-  MOZ_CAN_RUN_SCRIPT
   nsresult RemoveElementIfNoStyleOrIdOrClass(Element& aElement);
 
   /**
    * Whether the outer window of the DOM event target has focus or not.
    */
   bool OurWindowHasFocus();
 
   /**
@@ -2118,17 +2094,17 @@ class HTMLEditor final : public TextEdit
    * from the InsertHTML method.  We may want the HTML input to be sanitized
    * (for example, if it's coming from a transferable object), in which case
    * aTrustedInput should be set to false, otherwise, the caller should set it
    * to true, which means that the HTML will be inserted in the DOM verbatim.
    *
    * aClearStyle should be set to false if you want the paste to be affected by
    * local style (e.g., for the insertHTML command).
    */
-  MOZ_CAN_RUN_SCRIPT
+  MOZ_CAN_RUN_SCRIPT_BOUNDARY
   nsresult DoInsertHTMLWithContext(
       const nsAString& aInputString, const nsAString& aContextStr,
       const nsAString& aInfoStr, const nsAString& aFlavor, Document* aSourceDoc,
       const EditorDOMPoint& aPointToInsert, bool aDeleteSelection,
       bool aTrustedInput, bool aClearStyle = true);
 
   /**
    * sets the position of an element; warning it does NOT check if the
@@ -2245,17 +2221,16 @@ class HTMLEditor final : public TextEdit
   int32_t GetNewResizingIncrement(int32_t aX, int32_t aY, ResizeAt aResizeAt);
 
   nsresult StartResizing(Element* aHandle);
   int32_t GetNewResizingX(int32_t aX, int32_t aY);
   int32_t GetNewResizingY(int32_t aX, int32_t aY);
   int32_t GetNewResizingWidth(int32_t aX, int32_t aY);
   int32_t GetNewResizingHeight(int32_t aX, int32_t aY);
   void HideShadowAndInfo();
-  MOZ_CAN_RUN_SCRIPT
   void SetFinalSize(int32_t aX, int32_t aY);
   void SetResizeIncrements(int32_t aX, int32_t aY, int32_t aW, int32_t aH,
                            bool aPreserveRatio);
 
   /**
    * HideAnonymousEditingUIs() forcibly hides all editing UIs (resizers,
    * inline-table-editing UI, absolute positioning UI).
    */
@@ -2338,17 +2313,16 @@ class HTMLEditor final : public TextEdit
   /**
    * IsEmptyTextNode() returns true if aNode is a text node and does not have
    * any visible characters.
    */
   bool IsEmptyTextNode(nsINode& aNode);
 
   bool IsSimpleModifiableNode(nsIContent* aContent, nsAtom* aProperty,
                               nsAtom* aAttribute, const nsAString* aValue);
-  MOZ_CAN_RUN_SCRIPT
   nsresult SetInlinePropertyOnNodeImpl(nsIContent& aNode, nsAtom& aProperty,
                                        nsAtom* aAttribute,
                                        const nsAString& aValue);
   typedef enum { eInserted, eAppended } InsertedOrAppended;
   void DoContentInserted(nsIContent* aChild, InsertedOrAppended);
 
   /**
    * Returns an anonymous Element of type aTag,
--- a/editor/libeditor/HTMLEditorCommands.cpp
+++ b/editor/libeditor/HTMLEditorCommands.cpp
@@ -29,19 +29,18 @@
 #include "nsStringFwd.h"      // for nsString
 
 class nsISupports;
 
 namespace mozilla {
 using dom::Element;
 
 // prototype
-MOZ_CAN_RUN_SCRIPT_BOUNDARY  // XXX Needs to change nsIControllerCommand.idl
-    static nsresult
-    GetListState(HTMLEditor* aHTMLEditor, bool* aMixed, nsAString& aLocalName);
+static nsresult GetListState(HTMLEditor* aHTMLEditor, bool* aMixed,
+                             nsAString& aLocalName);
 
 // defines
 #define STATE_ENABLED "state_enabled"
 #define STATE_ALL "state_all"
 #define STATE_ANY "state_any"
 #define STATE_MIXED "state_mixed"
 #define STATE_BEGIN "state_begin"
 #define STATE_END "state_end"
@@ -80,17 +79,17 @@ StateUpdatingCommandBase::DoCommand(cons
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
   }
   mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
   if (NS_WARN_IF(!htmlEditor)) {
     return NS_ERROR_FAILURE;
   }
-  return ToggleState(MOZ_KnownLive(htmlEditor));
+  return ToggleState(htmlEditor);
 }
 
 NS_IMETHODIMP
 StateUpdatingCommandBase::DoCommandParams(const char* aCommandName,
                                           nsICommandParams* aParams,
                                           nsISupports* refCon) {
   return DoCommand(aCommandName, refCon);
 }
@@ -241,26 +240,25 @@ nsresult StyleUpdatingCommand::ToggleSta
     } else if (mTagName == nsGkAtoms::strike) {
       nsresult rv =
           aHTMLEditor->RemoveInlinePropertyAsAction(*nsGkAtoms::s, nullptr);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
 
-    nsresult rv = aHTMLEditor->RemoveInlinePropertyAsAction(
-        MOZ_KnownLive(*mTagName), nullptr);
+    nsresult rv = aHTMLEditor->RemoveInlinePropertyAsAction(*mTagName, nullptr);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
     return NS_OK;
   }
 
-  nsresult rv = aHTMLEditor->SetInlinePropertyAsAction(MOZ_KnownLive(*mTagName),
-                                                       nullptr, EmptyString());
+  nsresult rv =
+      aHTMLEditor->SetInlinePropertyAsAction(*mTagName, nullptr, EmptyString());
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 ListCommand::ListCommand(nsAtom* aTagName)
     : StateUpdatingCommandBase(aTagName) {}
@@ -397,17 +395,17 @@ RemoveListCommand::IsCommandEnabled(cons
   // It is enabled if we are in any list type
   mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
   if (NS_WARN_IF(!htmlEditor)) {
     return NS_ERROR_FAILURE;
   }
 
   bool bMixed;
   nsAutoString localName;
-  nsresult rv = GetListState(MOZ_KnownLive(htmlEditor), &bMixed, localName);
+  nsresult rv = GetListState(htmlEditor, &bMixed, localName);
   NS_ENSURE_SUCCESS(rv, rv);
 
   *outCmdEnabled = bMixed || !localName.IsEmpty();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 RemoveListCommand::DoCommand(const char* aCommandName, nsISupports* refCon) {
@@ -586,32 +584,32 @@ MultiStateCommandBase::DoCommandParams(c
     nsAutoCString asciiAttribute;
     nsresult rv = params->GetCString(STATE_ATTRIBUTE, asciiAttribute);
     if (NS_SUCCEEDED(rv)) {
       CopyASCIItoUTF16(asciiAttribute, attribute);
     } else {
       params->GetString(STATE_ATTRIBUTE, attribute);
     }
   }
-  return SetState(MOZ_KnownLive(htmlEditor), attribute);
+  return SetState(htmlEditor, attribute);
 }
 
 NS_IMETHODIMP
 MultiStateCommandBase::GetCommandStateParams(const char* aCommandName,
                                              nsICommandParams* aParams,
                                              nsISupports* refCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (!editor) {
     return NS_OK;
   }
   mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
   if (NS_WARN_IF(!htmlEditor)) {
     return NS_ERROR_FAILURE;
   }
-  return GetCurrentState(MOZ_KnownLive(htmlEditor), aParams);
+  return GetCurrentState(htmlEditor, aParams);
 }
 
 ParagraphStateCommand::ParagraphStateCommand() : MultiStateCommandBase() {}
 
 nsresult ParagraphStateCommand::GetCurrentState(HTMLEditor* aHTMLEditor,
                                                 nsICommandParams* aParams) {
   if (NS_WARN_IF(!aHTMLEditor)) {
     return NS_ERROR_INVALID_ARG;
@@ -1152,17 +1150,17 @@ RemoveStylesCommand::DoCommand(const cha
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (!editor) {
     return NS_OK;
   }
   mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
   if (!htmlEditor) {
     return NS_OK;
   }
-  return MOZ_KnownLive(htmlEditor)->RemoveAllInlineProperties();
+  return htmlEditor->RemoveAllInlineProperties();
 }
 
 NS_IMETHODIMP
 RemoveStylesCommand::DoCommandParams(const char* aCommandName,
                                      nsICommandParams* aParams,
                                      nsISupports* refCon) {
   return DoCommand(aCommandName, refCon);
 }
@@ -1198,17 +1196,17 @@ IncreaseFontSizeCommand::DoCommand(const
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (!editor) {
     return NS_OK;
   }
   mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
   if (!htmlEditor) {
     return NS_OK;
   }
-  return MOZ_KnownLive(htmlEditor)->IncreaseFontSize();
+  return htmlEditor->IncreaseFontSize();
 }
 
 NS_IMETHODIMP
 IncreaseFontSizeCommand::DoCommandParams(const char* aCommandName,
                                          nsICommandParams* aParams,
                                          nsISupports* refCon) {
   return DoCommand(aCommandName, refCon);
 }
@@ -1244,17 +1242,17 @@ DecreaseFontSizeCommand::DoCommand(const
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (!editor) {
     return NS_OK;
   }
   mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
   if (!htmlEditor) {
     return NS_OK;
   }
-  return MOZ_KnownLive(htmlEditor)->DecreaseFontSize();
+  return htmlEditor->DecreaseFontSize();
 }
 
 NS_IMETHODIMP
 DecreaseFontSizeCommand::DoCommandParams(const char* aCommandName,
                                          nsICommandParams* aParams,
                                          nsISupports* refCon) {
   return DoCommand(aCommandName, refCon);
 }
@@ -1294,17 +1292,17 @@ InsertHTMLCommand::DoCommand(const char*
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
   }
   mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
   if (NS_WARN_IF(!htmlEditor)) {
     return NS_ERROR_FAILURE;
   }
   nsAutoString html;
-  return MOZ_KnownLive(htmlEditor)->InsertHTML(html);
+  return htmlEditor->InsertHTML(html);
 }
 
 NS_IMETHODIMP
 InsertHTMLCommand::DoCommandParams(const char* aCommandName,
                                    nsICommandParams* aParams,
                                    nsISupports* refCon) {
   NS_ENSURE_ARG_POINTER(aParams);
   NS_ENSURE_ARG_POINTER(refCon);
@@ -1319,17 +1317,17 @@ InsertHTMLCommand::DoCommandParams(const
   }
 
   // Get HTML source string to insert from command params
   nsAutoString html;
   nsresult rv = aParams->AsCommandParams()->GetString(STATE_DATA, html);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
-  return MOZ_KnownLive(htmlEditor)->InsertHTML(html);
+  return htmlEditor->InsertHTML(html);
 }
 
 NS_IMETHODIMP
 InsertHTMLCommand::GetCommandStateParams(const char* aCommandName,
                                          nsICommandParams* aParams,
                                          nsISupports* refCon) {
   NS_ENSURE_ARG_POINTER(aParams);
   NS_ENSURE_ARG_POINTER(refCon);
@@ -1370,24 +1368,21 @@ InsertTagCommand::DoCommand(const char* 
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
   }
   mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
   if (NS_WARN_IF(!htmlEditor)) {
     return NS_ERROR_FAILURE;
   }
 
-  RefPtr<Element> newElement =
-      MOZ_KnownLive(htmlEditor)
-          ->CreateElementWithDefaults(MOZ_KnownLive(*mTagName));
+  RefPtr<Element> newElement = htmlEditor->CreateElementWithDefaults(*mTagName);
   if (NS_WARN_IF(!newElement)) {
     return NS_ERROR_FAILURE;
   }
-  nsresult rv =
-      MOZ_KnownLive(htmlEditor)->InsertElementAtSelection(newElement, true);
+  nsresult rv = htmlEditor->InsertElementAtSelection(newElement, true);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 InsertTagCommand::DoCommandParams(const char* aCommandName,
@@ -1428,39 +1423,37 @@ InsertTagCommand::DoCommandParams(const 
   if (mTagName == nsGkAtoms::a) {
     attribute = nsGkAtoms::href;
   } else if (mTagName == nsGkAtoms::img) {
     attribute = nsGkAtoms::src;
   } else {
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
-  RefPtr<Element> newElement =
-      MOZ_KnownLive(htmlEditor)
-          ->CreateElementWithDefaults(MOZ_KnownLive(*mTagName));
+  RefPtr<Element> newElement = htmlEditor->CreateElementWithDefaults(*mTagName);
   if (NS_WARN_IF(!newElement)) {
     return NS_ERROR_FAILURE;
   }
 
   ErrorResult err;
   newElement->SetAttr(attribute, value, err);
   if (NS_WARN_IF(err.Failed())) {
     return err.StealNSResult();
   }
 
   // do actual insertion
   if (mTagName == nsGkAtoms::a) {
-    rv = MOZ_KnownLive(htmlEditor)->InsertLinkAroundSelection(newElement);
+    rv = htmlEditor->InsertLinkAroundSelection(newElement);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
     return NS_OK;
   }
 
-  rv = MOZ_KnownLive(htmlEditor)->InsertElementAtSelection(newElement, true);
+  rv = htmlEditor->InsertElementAtSelection(newElement, true);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 InsertTagCommand::GetCommandStateParams(const char* aCommandName,
@@ -1474,18 +1467,17 @@ InsertTagCommand::GetCommandStateParams(
   return aParams->AsCommandParams()->SetBool(STATE_ENABLED, outCmdEnabled);
 }
 
 /****************************/
 // HELPER METHODS
 /****************************/
 
 static nsresult GetListState(HTMLEditor* aHTMLEditor, bool* aMixed,
-                             nsAString& aLocalName)
-    MOZ_CAN_RUN_SCRIPT_FOR_DEFINITION {
+                             nsAString& aLocalName) {
   MOZ_ASSERT(aHTMLEditor);
   MOZ_ASSERT(aMixed);
 
   *aMixed = false;
   aLocalName.Truncate();
 
   bool bOL, bUL, bDL;
   nsresult rv = aHTMLEditor->GetListState(aMixed, &bOL, &bUL, &bDL);
--- a/editor/libeditor/HTMLEditorCommands.h
+++ b/editor/libeditor/HTMLEditorCommands.h
@@ -53,42 +53,38 @@ class StateUpdatingCommandBase : public 
                                        HTMLEditorCommandBase)
 
   NS_DECL_NSICONTROLLERCOMMAND
 
  protected:
   virtual ~StateUpdatingCommandBase();
 
   // get the current state (on or off) for this style or block format
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY  // XXX Needs to change nsIControllerCommand.idl
-      virtual nsresult
-      GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) = 0;
+  virtual nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
+                                   nsICommandParams* aParams) = 0;
 
   // add/remove the style
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult ToggleState(HTMLEditor* aHTMLEditor) = 0;
 
  protected:
   nsAtom* mTagName;
 };
 
 // Shared class for the various style updating commands like bold, italics etc.
 // Suitable for commands whose state is either 'on' or 'off'.
 class StyleUpdatingCommand final : public StateUpdatingCommandBase {
  public:
   explicit StyleUpdatingCommand(nsAtom* aTagName);
 
  protected:
   // get the current state (on or off) for this style or block format
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY  // XXX Needs to change nsIControllerCommand.idl
-      nsresult
-      GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
+  nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
+                           nsICommandParams* aParams) final;
 
   // add/remove the style
-  MOZ_CAN_RUN_SCRIPT
   nsresult ToggleState(HTMLEditor* aHTMLEditor) final;
 };
 
 class InsertTagCommand final : public HTMLEditorCommandBase {
  public:
   explicit InsertTagCommand(nsAtom* aTagName);
 
   NS_INLINE_DECL_REFCOUNTING_INHERITED(InsertTagCommand, HTMLEditorCommandBase)
@@ -102,157 +98,135 @@ class InsertTagCommand final : public HT
 };
 
 class ListCommand final : public StateUpdatingCommandBase {
  public:
   explicit ListCommand(nsAtom* aTagName);
 
  protected:
   // get the current state (on or off) for this style or block format
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY  // XXX Needs to change nsIControllerCommand.idl
-      nsresult
-      GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
+  nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
+                           nsICommandParams* aParams) final;
 
   // add/remove the style
-  MOZ_CAN_RUN_SCRIPT
   nsresult ToggleState(HTMLEditor* aHTMLEditor) final;
 };
 
 class ListItemCommand final : public StateUpdatingCommandBase {
  public:
   explicit ListItemCommand(nsAtom* aTagName);
 
  protected:
   // get the current state (on or off) for this style or block format
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY  // XXX Needs to change nsIControllerCommand.idl
-      nsresult
-      GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
+  nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
+                           nsICommandParams* aParams) final;
 
   // add/remove the style
-  MOZ_CAN_RUN_SCRIPT
   nsresult ToggleState(HTMLEditor* aHTMLEditor) final;
 };
 
 // Base class for commands whose state consists of a string (e.g. para format)
 class MultiStateCommandBase : public HTMLEditorCommandBase {
  public:
   MultiStateCommandBase();
 
   NS_INLINE_DECL_REFCOUNTING_INHERITED(MultiStateCommandBase,
                                        HTMLEditorCommandBase)
   NS_DECL_NSICONTROLLERCOMMAND
 
  protected:
   virtual ~MultiStateCommandBase();
 
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY  // XXX Needs to change nsIControllerCommand.idl
-      virtual nsresult
-      GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) = 0;
-  MOZ_CAN_RUN_SCRIPT
+  virtual nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
+                                   nsICommandParams* aParams) = 0;
   virtual nsresult SetState(HTMLEditor* aHTMLEditor,
                             const nsString& newState) = 0;
 };
 
 class ParagraphStateCommand final : public MultiStateCommandBase {
  public:
   ParagraphStateCommand();
 
  protected:
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY  // XXX Needs to change nsIControllerCommand.idl
-      nsresult
-      GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
-  MOZ_CAN_RUN_SCRIPT
+  nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
+                           nsICommandParams* aParams) final;
   nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
 };
 
 class FontFaceStateCommand final : public MultiStateCommandBase {
  public:
   FontFaceStateCommand();
 
  protected:
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY  // XXX Needs to change nsIControllerCommand.idl
-      nsresult
-      GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
-  MOZ_CAN_RUN_SCRIPT
+  nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
+                           nsICommandParams* aParams) final;
   nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
 };
 
 class FontSizeStateCommand final : public MultiStateCommandBase {
  public:
   FontSizeStateCommand();
 
  protected:
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY  // XXX Needs to change nsIControllerCommand.idl
-      nsresult
-      GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
-  MOZ_CAN_RUN_SCRIPT
+  nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
+                           nsICommandParams* aParams) final;
   nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
 };
 
 class HighlightColorStateCommand final : public MultiStateCommandBase {
  public:
   HighlightColorStateCommand();
 
  protected:
   NS_IMETHOD IsCommandEnabled(const char* aCommandName,
                               nsISupports* aCommandRefCon, bool* _retval) final;
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY  // XXX Needs to change nsIControllerCommand.idl
-      nsresult
-      GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
-  MOZ_CAN_RUN_SCRIPT
+  nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
+                           nsICommandParams* aParams) final;
   nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
 };
 
 class FontColorStateCommand final : public MultiStateCommandBase {
  public:
   FontColorStateCommand();
 
  protected:
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY  // XXX Needs to change nsIControllerCommand.idl
-      nsresult
-      GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
-  MOZ_CAN_RUN_SCRIPT
+  nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
+                           nsICommandParams* aParams) final;
   nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
 };
 
 class AlignCommand final : public MultiStateCommandBase {
  public:
   AlignCommand();
 
  protected:
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY  // XXX Needs to change nsIControllerCommand.idl
-      nsresult
-      GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
-  MOZ_CAN_RUN_SCRIPT
+  nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
+                           nsICommandParams* aParams) final;
   nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
 };
 
 class BackgroundColorStateCommand final : public MultiStateCommandBase {
  public:
   BackgroundColorStateCommand();
 
  protected:
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY  // XXX Needs to change nsIControllerCommand.idl
-      nsresult
-      GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
-  MOZ_CAN_RUN_SCRIPT
+  nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
+                           nsICommandParams* aParams) final;
   nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
 };
 
 class AbsolutePositioningCommand final : public StateUpdatingCommandBase {
  public:
   AbsolutePositioningCommand();
 
  protected:
   NS_IMETHOD IsCommandEnabled(const char* aCommandName,
                               nsISupports* aCommandRefCon, bool* _retval) final;
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY  // XXX Needs to change nsIControllerCommand.idl
-      nsresult
-      GetCurrentState(HTMLEditor* aHTMLEditor, nsICommandParams* aParams) final;
-  MOZ_CAN_RUN_SCRIPT
+  nsresult GetCurrentState(HTMLEditor* aHTMLEditor,
+                           nsICommandParams* aParams) final;
   nsresult ToggleState(HTMLEditor* aHTMLEditor) final;
 };
 
 // composer commands
 
 NS_DECL_COMPOSER_COMMAND(DocumentStateCommand)
 NS_DECL_COMPOSER_COMMAND(SetDocumentStateCommand)
 
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -518,17 +518,17 @@ nsresult HTMLEditor::DoInsertHTMLWithCon
                                "Failed to advance offset from inserted point");
         }
       }
 
       if (!bDidInsert || NS_FAILED(rv)) {
         // Try to insert.
         EditorDOMPoint insertedPoint =
             InsertNodeIntoProperAncestorWithTransaction(
-                MOZ_KnownLive(*curNode->AsContent()), pointToInsert,
+                *curNode->AsContent(), pointToInsert,
                 SplitAtEdges::eDoNotCreateEmptyContainer);
         if (insertedPoint.IsSet()) {
           lastInsertNode = curNode->AsContent();
           pointToInsert = insertedPoint;
         }
 
         // Assume failure means no legal parent in the document hierarchy,
         // try again with the parent of curNode in the paste hierarchy.
@@ -537,17 +537,17 @@ nsresult HTMLEditor::DoInsertHTMLWithCon
              content && !insertedPoint.IsSet();
              content = content->GetParent()) {
           if (NS_WARN_IF(!content->GetParent()) ||
               NS_WARN_IF(TextEditUtils::IsBody(content->GetParent()))) {
             continue;
           }
           nsCOMPtr<nsINode> oldParent = content->GetParentNode();
           insertedPoint = InsertNodeIntoProperAncestorWithTransaction(
-              MOZ_KnownLive(*content->GetParent()), pointToInsert,
+              *content->GetParent(), pointToInsert,
               SplitAtEdges::eDoNotCreateEmptyContainer);
           if (insertedPoint.IsSet()) {
             insertedContextParent = oldParent;
             pointToInsert = insertedPoint;
           }
         }
       }
       if (lastInsertNode) {
@@ -977,23 +977,19 @@ nsresult HTMLEditor::BlobReader::OnResul
   NS_ConvertUTF16toUTF8 type(blobType);
   nsAutoString stuffToPaste;
   nsresult rv = ImgFromData(type, aResult, stuffToPaste);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return EditorBase::ToGenericNSResult(rv);
   }
 
   AutoPlaceholderBatch treatAsOneTransaction(*mHTMLEditor);
-  RefPtr<Document> sourceDocument(mSourceDoc);
-  EditorDOMPoint pointToInsert(mPointToInsert);
-  rv = MOZ_KnownLive(mHTMLEditor)
-           ->DoInsertHTMLWithContext(stuffToPaste, EmptyString(), EmptyString(),
-                                     NS_LITERAL_STRING(kFileMime),
-                                     sourceDocument, pointToInsert,
-                                     mDoDeleteSelection, mIsSafe, false);
+  rv = mHTMLEditor->DoInsertHTMLWithContext(
+      stuffToPaste, EmptyString(), EmptyString(), NS_LITERAL_STRING(kFileMime),
+      mSourceDoc, mPointToInsert, mDoDeleteSelection, mIsSafe, false);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return EditorBase::ToGenericNSResult(rv);
   }
   return NS_OK;
 }
 
 nsresult HTMLEditor::BlobReader::OnError(const nsAString& aError) {
   const nsPromiseFlatString& flat = PromiseFlatString(aError);
@@ -1008,17 +1004,16 @@ nsresult HTMLEditor::BlobReader::OnError
 class SlurpBlobEventListener final : public nsIDOMEventListener {
  public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS(SlurpBlobEventListener)
 
   explicit SlurpBlobEventListener(HTMLEditor::BlobReader* aListener)
       : mListener(aListener) {}
 
-  MOZ_CAN_RUN_SCRIPT
   NS_IMETHOD HandleEvent(Event* aEvent) override;
 
  private:
   ~SlurpBlobEventListener() = default;
 
   RefPtr<HTMLEditor::BlobReader> mListener;
 };
 
@@ -1041,27 +1036,26 @@ SlurpBlobEventListener::HandleEvent(Even
 
   RefPtr<FileReader> reader = do_QueryObject(target);
   if (!reader) {
     return NS_OK;
   }
 
   EventMessage message = aEvent->WidgetEventPtr()->mMessage;
 
-  RefPtr<HTMLEditor::BlobReader> listener(mListener);
   if (message == eLoad) {
     MOZ_ASSERT(reader->DataFormat() == FileReader::FILE_AS_BINARY);
 
     // The original data has been converted from Latin1 to UTF-16, this just
     // undoes that conversion.
-    listener->OnResult(NS_LossyConvertUTF16toASCII(reader->Result()));
+    mListener->OnResult(NS_LossyConvertUTF16toASCII(reader->Result()));
   } else if (message == eLoadError) {
     nsAutoString errorMessage;
     reader->GetError()->GetErrorMessage(errorMessage);
-    listener->OnError(errorMessage);
+    mListener->OnError(errorMessage);
   }
 
   return NS_OK;
 }
 
 // static
 nsresult HTMLEditor::SlurpBlob(Blob* aBlob, nsPIDOMWindowOuter* aWindow,
                                BlobReader* aBlobReader) {
@@ -1917,16 +1911,49 @@ nsresult HTMLEditor::InsertTextWithQuota
     }
     curHunkIsQuoted = quoted;
     hunkStart = lineStart;
   }
 
   return rv;
 }
 
+nsresult HTMLEditor::InsertAsQuotation(const nsAString& aQuotedText,
+                                       nsINode** aNodeInserted) {
+  if (IsPlaintextEditor()) {
+    AutoEditActionDataSetter editActionData(*this, EditAction::eInsertText);
+    if (NS_WARN_IF(!editActionData.CanHandle())) {
+      return NS_ERROR_NOT_INITIALIZED;
+    }
+    MOZ_ASSERT(!aQuotedText.IsVoid());
+    editActionData.SetData(aQuotedText);
+    AutoPlaceholderBatch treatAsOneTransaction(*this);
+    nsresult rv = InsertAsPlaintextQuotation(aQuotedText, true, aNodeInserted);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return EditorBase::ToGenericNSResult(rv);
+    }
+    return NS_OK;
+  }
+
+  AutoEditActionDataSetter editActionData(*this,
+                                          EditAction::eInsertBlockquoteElement);
+  if (NS_WARN_IF(!editActionData.CanHandle())) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
+  nsAutoString citation;
+  nsresult rv = InsertAsCitedQuotationInternal(aQuotedText, citation, false,
+                                               aNodeInserted);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return EditorBase::ToGenericNSResult(rv);
+  }
+  return NS_OK;
+}
+
 // Insert plaintext as a quotation, with cite marks (e.g. "> ").
 // This differs from its corresponding method in TextEditor
 // in that here, quoted material is enclosed in a <pre> tag
 // in order to preserve the original line wrapping.
 nsresult HTMLEditor::InsertAsPlaintextQuotation(const nsAString& aQuotedText,
                                                 bool aAddCites,
                                                 nsINode** aNodeInserted) {
   MOZ_ASSERT(IsEditActionDataAvailable());
--- a/editor/libeditor/HTMLEditorEventListener.cpp
+++ b/editor/libeditor/HTMLEditorEventListener.cpp
@@ -223,17 +223,17 @@ nsresult HTMLEditorEventListener::Listen
 
 nsresult HTMLEditorEventListener::MouseUp(MouseEvent* aMouseEvent) {
   if (DetachedFromEditor()) {
     return NS_OK;
   }
 
   // FYI: We need to notify HTML editor of mouseup even if it's consumed
   //      because HTML editor always needs to release grabbing resizer.
-  RefPtr<HTMLEditor> htmlEditor = mEditorBase->AsHTMLEditor();
+  HTMLEditor* htmlEditor = mEditorBase->AsHTMLEditor();
   MOZ_ASSERT(htmlEditor);
 
   RefPtr<EventTarget> target = aMouseEvent->GetTarget();
   NS_ENSURE_TRUE(target, NS_ERROR_NULL_POINTER);
   nsCOMPtr<Element> element = do_QueryInterface(target);
 
   int32_t clientX = aMouseEvent->ClientX();
   int32_t clientY = aMouseEvent->ClientY();
--- a/editor/libeditor/HTMLEditorEventListener.h
+++ b/editor/libeditor/HTMLEditorEventListener.h
@@ -69,17 +69,16 @@ class HTMLEditorEventListener final : pu
    * ListenToWindowResizeEvent() starts to listen to or stop listening to
    * "resize" events of the document.
    */
   nsresult ListenToWindowResizeEvent(bool aListen);
 
  protected:
   MOZ_CAN_RUN_SCRIPT
   virtual nsresult MouseDown(dom::MouseEvent* aMouseEvent) override;
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult MouseUp(dom::MouseEvent* aMouseEvent) override;
   MOZ_CAN_RUN_SCRIPT
   virtual nsresult MouseClick(WidgetMouseEvent* aMouseClickEvent) override;
 
   nsresult ListenToMouseMoveEventForResizersOrGrabber(bool aListen,
                                                       bool aForGrabber);
 
   bool mListeningToMouseMoveEventForResizers;
--- a/editor/libeditor/HTMLEditorObjectResizer.cpp
+++ b/editor/libeditor/HTMLEditorObjectResizer.cpp
@@ -965,35 +965,34 @@ void HTMLEditor::SetFinalSize(int32_t aX
                   ? mResizedObjectBorderLeft + mResizedObjectMarginLeft
                   : 0);
   y = top - ((mResizedObjectIsAbsolutelyPositioned)
                  ? mResizedObjectBorderTop + mResizedObjectMarginTop
                  : 0);
 
   // we want one transaction only from a user's point of view
   AutoPlaceholderBatch treatAsOneTransaction(*this);
-  RefPtr<Element> resizedObject(mResizedObject);
 
   if (mResizedObjectIsAbsolutelyPositioned) {
     if (setHeight) {
-      mCSSEditUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::top, y);
+      mCSSEditUtils->SetCSSPropertyPixels(*mResizedObject, *nsGkAtoms::top, y);
     }
     if (setWidth) {
-      mCSSEditUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::left, x);
+      mCSSEditUtils->SetCSSPropertyPixels(*mResizedObject, *nsGkAtoms::left, x);
     }
   }
   if (IsCSSEnabled() || mResizedObjectIsAbsolutelyPositioned) {
     if (setWidth &&
-        resizedObject->HasAttr(kNameSpaceID_None, nsGkAtoms::width)) {
-      RemoveAttributeWithTransaction(*resizedObject, *nsGkAtoms::width);
+        mResizedObject->HasAttr(kNameSpaceID_None, nsGkAtoms::width)) {
+      RemoveAttributeWithTransaction(*mResizedObject, *nsGkAtoms::width);
     }
 
     if (setHeight &&
-        resizedObject->HasAttr(kNameSpaceID_None, nsGkAtoms::height)) {
-      RemoveAttributeWithTransaction(*resizedObject, *nsGkAtoms::height);
+        mResizedObject->HasAttr(kNameSpaceID_None, nsGkAtoms::height)) {
+      RemoveAttributeWithTransaction(*mResizedObject, *nsGkAtoms::height);
     }
 
     if (setWidth) {
       mCSSEditUtils->SetCSSPropertyPixels(*mResizedObject, *nsGkAtoms::width,
                                           width);
     }
     if (setHeight) {
       mCSSEditUtils->SetCSSPropertyPixels(*mResizedObject, *nsGkAtoms::height,
@@ -1001,40 +1000,40 @@ void HTMLEditor::SetFinalSize(int32_t aX
     }
   } else {
     // we use HTML size and remove all equivalent CSS properties
 
     // we set the CSS width and height to remove it later,
     // triggering an immediate reflow; otherwise, we have problems
     // with asynchronous reflow
     if (setWidth) {
-      mCSSEditUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::width,
+      mCSSEditUtils->SetCSSPropertyPixels(*mResizedObject, *nsGkAtoms::width,
                                           width);
     }
     if (setHeight) {
-      mCSSEditUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::height,
+      mCSSEditUtils->SetCSSPropertyPixels(*mResizedObject, *nsGkAtoms::height,
                                           height);
     }
     if (setWidth) {
       nsAutoString w;
       w.AppendInt(width);
-      SetAttributeWithTransaction(*resizedObject, *nsGkAtoms::width, w);
+      SetAttributeWithTransaction(*mResizedObject, *nsGkAtoms::width, w);
     }
     if (setHeight) {
       nsAutoString h;
       h.AppendInt(height);
-      SetAttributeWithTransaction(*resizedObject, *nsGkAtoms::height, h);
+      SetAttributeWithTransaction(*mResizedObject, *nsGkAtoms::height, h);
     }
 
     if (setWidth) {
-      mCSSEditUtils->RemoveCSSProperty(*resizedObject, *nsGkAtoms::width,
+      mCSSEditUtils->RemoveCSSProperty(*mResizedObject, *nsGkAtoms::width,
                                        EmptyString());
     }
     if (setHeight) {
-      mCSSEditUtils->RemoveCSSProperty(*resizedObject, *nsGkAtoms::height,
+      mCSSEditUtils->RemoveCSSProperty(*mResizedObject, *nsGkAtoms::height,
                                        EmptyString());
     }
   }
 
   // keep track of that size
   mResizedObjectWidth = width;
   mResizedObjectHeight = height;
 
--- a/editor/libeditor/HTMLStyleEditor.cpp
+++ b/editor/libeditor/HTMLStyleEditor.cpp
@@ -181,18 +181,18 @@ nsresult HTMLEditor::SetInlinePropertyIn
         return rv;
       }
 
       // Check for easy case: both range endpoints in same text node
       nsCOMPtr<nsINode> startNode = range->GetStartContainer();
       nsCOMPtr<nsINode> endNode = range->GetEndContainer();
       if (startNode && startNode == endNode && startNode->GetAsText()) {
         rv = SetInlinePropertyOnTextNode(
-            MOZ_KnownLive(*startNode->GetAsText()), range->StartOffset(),
-            range->EndOffset(), aProperty, aAttribute, aValue);
+            *startNode->GetAsText(), range->StartOffset(), range->EndOffset(),
+            aProperty, aAttribute, aValue);
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
         continue;
       }
 
       // Not the easy case.  Range not contained in single text node.  There
       // are up to three phases here.  There are all the nodes reported by the
@@ -222,18 +222,18 @@ nsresult HTMLEditor::SetInlinePropertyIn
           }
         }
       }
       // First check the start parent of the range to see if it needs to be
       // separately handled (it does if it's a text node, due to how the
       // subtree iterator works - it will not have reported it).
       if (startNode && startNode->GetAsText() && IsEditable(startNode)) {
         rv = SetInlinePropertyOnTextNode(
-            MOZ_KnownLive(*startNode->GetAsText()), range->StartOffset(),
-            startNode->Length(), aProperty, aAttribute, aValue);
+            *startNode->GetAsText(), range->StartOffset(), startNode->Length(),
+            aProperty, aAttribute, aValue);
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
       }
 
       // Then loop through the list, set the property on each node
       for (auto& node : arrayOfNodes) {
         rv = SetInlinePropertyOnNode(*node, aProperty, aAttribute, aValue);
@@ -241,18 +241,18 @@ nsresult HTMLEditor::SetInlinePropertyIn
           return rv;
         }
       }
 
       // Last check the end parent of the range to see if it needs to be
       // separately handled (it does if it's a text node, due to how the
       // subtree iterator works - it will not have reported it).
       if (endNode && endNode->GetAsText() && IsEditable(endNode)) {
-        rv = SetInlinePropertyOnTextNode(MOZ_KnownLive(*endNode->GetAsText()),
-                                         0, range->EndOffset(), aProperty,
+        rv = SetInlinePropertyOnTextNode(*endNode->GetAsText(), 0,
+                                         range->EndOffset(), aProperty,
                                          aAttribute, aValue);
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
       }
     }
   }
   if (cancel) {
@@ -383,17 +383,17 @@ nsresult HTMLEditor::SetInlinePropertyOn
     if (NS_WARN_IF(error.Failed())) {
       return error.StealNSResult();
     }
     Unused << newLeftNode;
   }
 
   if (aAttribute) {
     // Look for siblings that are correct type of node
-    nsCOMPtr<nsIContent> sibling = GetPriorHTMLSibling(textNodeForTheRange);
+    nsIContent* sibling = GetPriorHTMLSibling(textNodeForTheRange);
     if (IsSimpleModifiableNode(sibling, &aProperty, aAttribute, &aValue)) {
       // Previous sib is already right kind of inline node; slide this over
       return MoveNodeToEndWithTransaction(*textNodeForTheRange, *sibling);
     }
     sibling = GetNextHTMLSibling(textNodeForTheRange);
     if (IsSimpleModifiableNode(sibling, &aProperty, aAttribute, &aValue)) {
       // Following sib is already right kind of inline node; slide this over
       return MoveNodeWithTransaction(*textNodeForTheRange,
@@ -812,27 +812,25 @@ nsresult HTMLEditor::RemoveStyleInside(n
           return rv;
         }
         rv = CloneAttributeWithTransaction(*nsGkAtoms::_class, *spanNode,
                                            *aNode.AsElement());
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
       }
-      nsresult rv =
-          RemoveContainerWithTransaction(MOZ_KnownLive(*aNode.AsElement()));
+      nsresult rv = RemoveContainerWithTransaction(*aNode.AsElement());
       NS_ENSURE_SUCCESS(rv, rv);
     } else if (aNode.IsElement()) {
       // otherwise we just want to eliminate the attribute
       if (aNode.AsElement()->HasAttr(kNameSpaceID_None, aAttribute)) {
         // if this matching attribute is the ONLY one on the node,
         // then remove the whole node.  Otherwise just nix the attribute.
         if (IsOnlyAttribute(aNode.AsElement(), aAttribute)) {
-          nsresult rv =
-              RemoveContainerWithTransaction(MOZ_KnownLive(*aNode.AsElement()));
+          nsresult rv = RemoveContainerWithTransaction(*aNode.AsElement());
           if (NS_WARN_IF(NS_FAILED(rv))) {
             return rv;
           }
         } else {
           nsresult rv =
               RemoveAttributeWithTransaction(*aNode.AsElement(), *aAttribute);
           if (NS_WARN_IF(NS_FAILED(rv))) {
             return rv;
@@ -850,35 +848,34 @@ nsresult HTMLEditor::RemoveStyleInside(n
     if (aNode.IsElement()) {
       bool hasAttribute = CSSEditUtils::HaveCSSEquivalentStyles(
           aNode, aProperty, aAttribute, CSSEditUtils::eSpecified);
       if (hasAttribute) {
         // yes, tmp has the corresponding css declarations in its style
         // attribute
         // let's remove them
         mCSSEditUtils->RemoveCSSEquivalentToHTMLStyle(
-            MOZ_KnownLive(aNode.AsElement()), aProperty, aAttribute, nullptr,
-            false);
+            aNode.AsElement(), aProperty, aAttribute, nullptr, false);
         // remove the node if it is a span or font, if its style attribute is
         // empty or absent, and if it does not have a class nor an id
-        RemoveElementIfNoStyleOrIdOrClass(MOZ_KnownLive(*aNode.AsElement()));
+        RemoveElementIfNoStyleOrIdOrClass(*aNode.AsElement());
       }
     }
   }
 
   // Or node is big or small and we are setting font size
   if (aChildrenOnly) {
     return NS_OK;
   }
   if (aProperty == nsGkAtoms::font &&
       (aNode.IsHTMLElement(nsGkAtoms::big) ||
        aNode.IsHTMLElement(nsGkAtoms::small)) &&
       aAttribute == nsGkAtoms::size) {
     // if we are setting font size, remove any nested bigs and smalls
-    return RemoveContainerWithTransaction(MOZ_KnownLive(*aNode.AsElement()));
+    return RemoveContainerWithTransaction(*aNode.AsElement());
   }
   return NS_OK;
 }
 
 bool HTMLEditor::IsOnlyAttribute(const Element* aElement, nsAtom* aAttribute) {
   MOZ_ASSERT(aElement);
 
   uint32_t attrCount = aElement->GetAttrCount();
@@ -1401,17 +1398,17 @@ nsresult HTMLEditor::RemoveInlinePropert
                   CSSEditUtils::eComputed)) {
             // startNode's computed style indicates the CSS equivalence to the
             // HTML style to remove is applied; but we found no element in the
             // ancestors of startNode carrying specified styles; assume it
             // comes from a rule and try to insert a span "inverting" the style
             if (CSSEditUtils::IsCSSInvertible(*aProperty, aAttribute)) {
               NS_NAMED_LITERAL_STRING(value, "-moz-editor-invert-value");
               SetInlinePropertyOnTextNode(
-                  MOZ_KnownLive(*startNode->GetAsText()), range->StartOffset(),
+                  *startNode->GetAsText(), range->StartOffset(),
                   range->EndOffset(), *aProperty, aAttribute, value);
             }
           }
         }
       } else {
         // Not the easy case.  Range not contained in single text node.
 
         nsTArray<OwningNonNull<nsIContent>> arrayOfNodes;
@@ -1548,19 +1545,19 @@ nsresult HTMLEditor::RelativeFontChange(
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     // Check for easy case: both range endpoints in same text node
     nsCOMPtr<nsINode> startNode = range->GetStartContainer();
     nsCOMPtr<nsINode> endNode = range->GetEndContainer();
     if (startNode == endNode && IsTextNode(startNode)) {
-      rv = RelativeFontChangeOnTextNode(
-          aDir, MOZ_KnownLive(*startNode->GetAsText()), range->StartOffset(),
-          range->EndOffset());
+      rv = RelativeFontChangeOnTextNode(aDir, *startNode->GetAsText(),
+                                        range->StartOffset(),
+                                        range->EndOffset());
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     } else {
       // Not the easy case.  Range not contained in single text node.  There
       // are up to three phases here.  There are all the nodes reported by the
       // subtree iterator to be processed.  And there are potentially a
       // starting textnode and an ending textnode which are only partially
@@ -1595,26 +1592,26 @@ nsresult HTMLEditor::RelativeFontChange(
             return rv;
           }
         }
       }
       // Now check the start and end parents of the range to see if they need
       // to be separately handled (they do if they are text nodes, due to how
       // the subtree iterator works - it will not have reported them).
       if (IsTextNode(startNode) && IsEditable(startNode)) {
-        rv = RelativeFontChangeOnTextNode(
-            aDir, MOZ_KnownLive(*startNode->GetAsText()), range->StartOffset(),
-            startNode->Length());
+        rv = RelativeFontChangeOnTextNode(aDir, *startNode->GetAsText(),
+                                          range->StartOffset(),
+                                          startNode->Length());
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
       }
       if (IsTextNode(endNode) && IsEditable(endNode)) {
-        rv = RelativeFontChangeOnTextNode(
-            aDir, MOZ_KnownLive(*endNode->GetAsText()), 0, range->EndOffset());
+        rv = RelativeFontChangeOnTextNode(aDir, *endNode->GetAsText(), 0,
+                                          range->EndOffset());
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
       }
     }
   }
 
   return NS_OK;
@@ -1683,18 +1680,18 @@ nsresult HTMLEditor::RelativeFontChangeO
                                           EditorRawDOMPoint(sibling, 0));
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
     return NS_OK;
   }
 
   // Else reparent the node inside font node with appropriate relative size
-  RefPtr<Element> newElement = InsertContainerWithTransaction(
-      *textNodeForTheRange, MOZ_KnownLive(*nodeType));
+  RefPtr<Element> newElement =
+      InsertContainerWithTransaction(*textNodeForTheRange, *nodeType);
   if (NS_WARN_IF(!newElement)) {
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
 nsresult HTMLEditor::RelativeFontChangeHelper(int32_t aSizeChange,
                                               nsINode* aNode) {
@@ -1763,45 +1760,44 @@ nsresult HTMLEditor::RelativeFontChangeO
 
   // Is it the opposite of what we want?
   if ((aSizeChange == 1 && aNode->IsHTMLElement(nsGkAtoms::small)) ||
       (aSizeChange == -1 && aNode->IsHTMLElement(nsGkAtoms::big))) {
     // first populate any nested font tags that have the size attr set
     nsresult rv = RelativeFontChangeHelper(aSizeChange, aNode);
     NS_ENSURE_SUCCESS(rv, rv);
     // in that case, just remove this node and pull up the children
-    return RemoveContainerWithTransaction(MOZ_KnownLive(*aNode->AsElement()));
+    return RemoveContainerWithTransaction(*aNode->AsElement());
   }
 
   // can it be put inside a "big" or "small"?
   if (TagCanContain(*atom, *aNode)) {
     // first populate any nested font tags that have the size attr set
     nsresult rv = RelativeFontChangeHelper(aSizeChange, aNode);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // ok, chuck it in.
     // first look at siblings of aNode for matching bigs or smalls.
     // if we find one, move aNode into it.
-    nsCOMPtr<nsIContent> sibling = GetPriorHTMLSibling(aNode);
+    nsIContent* sibling = GetPriorHTMLSibling(aNode);
     if (sibling && sibling->IsHTMLElement(atom)) {
       // previous sib is already right kind of inline node; slide this over into
       // it
       return MoveNodeToEndWithTransaction(*aNode, *sibling);
     }
 
     sibling = GetNextHTMLSibling(aNode);
     if (sibling && sibling->IsHTMLElement(atom)) {
       // following sib is already right kind of inline node; slide this over
       // into it
       return MoveNodeWithTransaction(*aNode, EditorRawDOMPoint(sibling, 0));
     }
 
     // else insert it above aNode
-    RefPtr<Element> newElement =
-        InsertContainerWithTransaction(*aNode, MOZ_KnownLive(*atom));
+    RefPtr<Element> newElement = InsertContainerWithTransaction(*aNode, *atom);
     if (NS_WARN_IF(!newElement)) {
       return NS_ERROR_FAILURE;
     }
     return NS_OK;
   }
 
   // none of the above?  then cycle through the children.
   // MOOSE: we should group the children together if possible
--- a/editor/libeditor/HTMLTableEditor.cpp
+++ b/editor/libeditor/HTMLTableEditor.cpp
@@ -2198,18 +2198,18 @@ nsresult HTMLEditor::SplitCellIntoColumn
   nsresult rv = SetColSpan(cellData.mElement, aColSpanLeft);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   // Insert new cell after using the remaining span
   // and always get the new cell so we can copy the background color;
   RefPtr<Element> newCellElement;
-  rv = InsertCell(MOZ_KnownLive(cellData.mElement), cellData.mEffectiveRowSpan,
-                  aColSpanRight, true, false, getter_AddRefs(newCellElement));
+  rv = InsertCell(cellData.mElement, cellData.mEffectiveRowSpan, aColSpanRight,
+                  true, false, getter_AddRefs(newCellElement));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   if (!newCellElement) {
     return NS_OK;
   }
   if (aNewCell) {
     NS_ADDREF(*aNewCell = newCellElement.get());
@@ -2369,17 +2369,17 @@ HTMLEditor::SwitchTableCellHeaderType(El
 
   // Set to the opposite of current type
   nsAtom* newCellName =
       aSourceCell->IsHTMLElement(nsGkAtoms::td) ? nsGkAtoms::th : nsGkAtoms::td;
 
   // This creates new node, moves children, copies attributes (true)
   //   and manages the selection!
   RefPtr<Element> newCell = ReplaceContainerAndCloneAttributesWithTransaction(
-      *aSourceCell, MOZ_KnownLive(*newCellName));
+      *aSourceCell, *newCellName);
   if (NS_WARN_IF(!newCell)) {
     return NS_ERROR_FAILURE;
   }
 
   // Return the new cell
   if (aNewCell) {
     newCell.forget(aNewCell);
   }
--- a/editor/libeditor/TextEditRules.cpp
+++ b/editor/libeditor/TextEditRules.cpp
@@ -464,20 +464,19 @@ EditActionResult TextEditRules::WillInse
     return EditActionIgnored(NS_ERROR_NOT_INITIALIZED);
   }
 
   // Don't change my selection in sub-transactions.
   AutoTransactionsConserveSelection dontChangeMySelection(TextEditorRef());
 
   // Insert a linefeed character.
   EditorRawDOMPoint pointAfterInsertedLineBreak;
-  rv = MOZ_KnownLive(TextEditorRef())
-           .InsertTextWithTransaction(*doc, NS_LITERAL_STRING("\n"),
-                                      pointToInsert,
-                                      &pointAfterInsertedLineBreak);
+  rv = TextEditorRef().InsertTextWithTransaction(*doc, NS_LITERAL_STRING("\n"),
+                                                 pointToInsert,
+                                                 &pointAfterInsertedLineBreak);
   if (NS_WARN_IF(!pointAfterInsertedLineBreak.IsSet())) {
     return EditActionIgnored(NS_ERROR_FAILURE);
   }
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return EditActionIgnored(rv);
   }
 
   // set the selection to the correct location
@@ -835,34 +834,33 @@ nsresult TextEditRules::WillInsertText(E
     // If there is one or more IME selections, its minimum offset should be
     // the insertion point.
     int32_t IMESelectionOffset = TextEditorRef().GetIMESelectionStartOffsetIn(
         betterInsertionPoint.GetContainer());
     if (IMESelectionOffset >= 0) {
       betterInsertionPoint.Set(betterInsertionPoint.GetContainer(),
                                IMESelectionOffset);
     }
-    rv = MOZ_KnownLive(TextEditorRef())
-             .InsertTextWithTransaction(*doc, *outString, betterInsertionPoint);
+    rv = TextEditorRef().InsertTextWithTransaction(*doc, *outString,
+                                                   betterInsertionPoint);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   } else {
     // aEditSubAction == EditSubAction::eInsertText
 
     // don't change my selection in subtransactions
     AutoTransactionsConserveSelection dontChangeMySelection(TextEditorRef());
 
     EditorRawDOMPoint pointAfterStringInserted;
-    rv = MOZ_KnownLive(TextEditorRef())
-             .InsertTextWithTransaction(*doc, *outString, atStartOfSelection,
-                                        &pointAfterStringInserted);
+    rv = TextEditorRef().InsertTextWithTransaction(
+        *doc, *outString, atStartOfSelection, &pointAfterStringInserted);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     if (pointAfterStringInserted.IsSet()) {
@@ -951,19 +949,18 @@ nsresult TextEditRules::WillSetText(bool
     RefPtr<Document> doc = TextEditorRef().GetDocument();
     if (NS_WARN_IF(!doc)) {
       return NS_OK;
     }
     RefPtr<nsTextNode> newNode = EditorBase::CreateTextNode(*doc, tString);
     if (NS_WARN_IF(!newNode)) {
       return NS_OK;
     }
-    nsresult rv = MOZ_KnownLive(TextEditorRef())
-                      .InsertNodeWithTransaction(
-                          *newNode, EditorRawDOMPoint(rootElement, 0));
+    nsresult rv = TextEditorRef().InsertNodeWithTransaction(
+        *newNode, EditorRawDOMPoint(rootElement, 0));
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
     *aHandled = true;
 
@@ -1513,24 +1510,20 @@ nsresult TextEditRules::CreateBogusNodeI
   }
 
   // set mBogusNode to be the newly created <br>
   mBogusNode = newBrElement;
 
   // Give it a special attribute.
   newBrElement->SetAttr(kNameSpaceID_None, kMOZEditorBogusNodeAttrAtom,
                         kMOZEditorBogusNodeValue, false);
-  if (NS_WARN_IF(mBogusNode != newBrElement)) {
-    return NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE;
-  }
 
   // Put the node in the document.
-  nsresult rv = MOZ_KnownLive(TextEditorRef())
-                    .InsertNodeWithTransaction(
-                        *newBrElement, EditorRawDOMPoint(rootElement, 0));
+  nsresult rv = TextEditorRef().InsertNodeWithTransaction(
+      *mBogusNode, EditorRawDOMPoint(rootElement, 0));
   if (NS_WARN_IF(!CanHandleEditAction())) {
     return NS_ERROR_EDITOR_DESTROYED;
   }
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   // Set selection.
--- a/editor/libeditor/TextEditRules.h
+++ b/editor/libeditor/TextEditRules.h
@@ -75,34 +75,26 @@ class TextEditRules : public nsITimerCal
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(TextEditRules, nsITimerCallback)
 
   TextEditRules();
 
   HTMLEditRules* AsHTMLEditRules();
   const HTMLEditRules* AsHTMLEditRules() const;
 
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult Init(TextEditor* aTextEditor);
   virtual nsresult SetInitialValue(const nsAString& aValue);
   virtual nsresult DetachEditor();
   virtual nsresult BeforeEdit(EditSubAction aEditSubAction,
                               nsIEditor::EDirection aDirection);
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult AfterEdit(EditSubAction aEditSubAction,
                              nsIEditor::EDirection aDirection);
-  // NOTE: Don't mark WillDoAction() nor DidDoAction() as MOZ_CAN_RUN_SCRIPT
-  //       because they are too generic and doing it makes a lot of public
-  //       editor methods marked as MOZ_CAN_RUN_SCRIPT too, but some of them
-  //       may not causes running script.  So, ideal fix must be that we make
-  //       each method callsed by this method public.
   MOZ_CAN_RUN_SCRIPT_BOUNDARY
   virtual nsresult WillDoAction(EditSubActionInfo& aInfo, bool* aCancel,
                                 bool* aHandled);
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY
   virtual nsresult DidDoAction(EditSubActionInfo& aInfo, nsresult aResult);
 
   /**
    * Return false if the editor has non-empty text nodes or non-text
    * nodes.  Otherwise, i.e., there is no meaningful content,
    * return true.
    */
   virtual bool DocumentIsEmpty();
@@ -199,17 +191,16 @@ class TextEditRules : public nsITimerCal
    * destroying the text editor.
    *
    * @param aCancel             Returns true if the operation is canceled.
    * @param aHandled            Returns true if the edit action is handled.
    * @param inString            String to be set.
    * @param aMaxLength          The maximum string length which the text editor
    *                            allows to set.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult WillSetText(bool* aCancel, bool* aHandled,
                                     const nsAString* inString,
                                     int32_t aMaxLength);
 
   /**
    * Called before inserting something into the editor.
    * This method may removes mBougsNode if there is.  Therefore, this method
    * might cause destroying the editor.
@@ -284,17 +275,16 @@ class TextEditRules : public nsITimerCal
   /**
    * Creates a trailing break in the text doc if there is not one already.
    */
   MOZ_MUST_USE nsresult CreateTrailingBRIfNeeded();
 
   /**
    * Creates a bogus <br> node if the root element has no editable content.
    */
-  MOZ_CAN_RUN_SCRIPT
   MOZ_MUST_USE nsresult CreateBogusNodeIfNeeded();
 
   /**
    * Returns a truncated insertion string if insertion would place us over
    * aMaxLength
    */
   nsresult TruncateInsertionIfNeeded(const nsAString* aInString,
                                      nsAString* aOutString, int32_t aMaxLength,
--- a/editor/libeditor/TextEditUtils.cpp
+++ b/editor/libeditor/TextEditUtils.cpp
@@ -71,13 +71,13 @@ AutoEditInitRulesTrigger::AutoEditInitRu
     : mTextEditor(aTextEditor), mResult(aResult) {
   if (mTextEditor) {
     mTextEditor->BeginEditorInit();
   }
 }
 
 AutoEditInitRulesTrigger::~AutoEditInitRulesTrigger() {
   if (mTextEditor) {
-    mResult = MOZ_KnownLive(mTextEditor)->EndEditorInit();
+    mResult = mTextEditor->EndEditorInit();
   }
 }
 
 }  // namespace mozilla
--- a/editor/libeditor/TextEditUtils.h
+++ b/editor/libeditor/TextEditUtils.h
@@ -24,20 +24,19 @@ class TextEditUtils final {
 };
 
 /***************************************************************************
  * stack based helper class for detecting end of editor initialization, in
  * order to trigger "end of init" initialization of the edit rules.
  */
 class AutoEditInitRulesTrigger final {
  private:
-  RefPtr<TextEditor> mTextEditor;
+  TextEditor* mTextEditor;
   nsresult& mResult;
 
  public:
   AutoEditInitRulesTrigger(TextEditor* aTextEditor, nsresult& aResult);
-  MOZ_CAN_RUN_SCRIPT
   ~AutoEditInitRulesTrigger();
 };
 
 }  // namespace mozilla
 
 #endif  // #ifndef TextEditUtils_h
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -316,18 +316,17 @@ bool TextEditor::UpdateMetaCharset(Docum
 
 nsresult TextEditor::InitRules() {
   MOZ_ASSERT(IsEditActionDataAvailable());
 
   if (!mRules) {
     // instantiate the rules for this text editor
     mRules = new TextEditRules();
   }
-  RefPtr<TextEditRules> textEditRules(mRules);
-  return textEditRules->Init(this);
+  return mRules->Init(this);
 }
 
 nsresult TextEditor::HandleKeyPressEvent(WidgetKeyboardEvent* aKeyboardEvent) {
   // NOTE: When you change this method, you should also change:
   //   * editor/libeditor/tests/test_texteditor_keyevent_handling.html
   //   * editor/libeditor/tests/test_htmleditor_keyevent_handling.html
   //
   // And also when you add new key handling, you need to change the subclass's
--- a/editor/libeditor/TextEditor.h
+++ b/editor/libeditor/TextEditor.h
@@ -82,17 +82,16 @@ class TextEditor : public EditorBase, pu
   /** 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|.
    */
   virtual bool CanPasteTransferable(nsITransferable* aTransferable);
 
   // Overrides of EditorBase
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult Init(Document& aDoc, Element* aRoot,
                         nsISelectionController* aSelCon, uint32_t aFlags,
                         const nsAString& aValue) override;
 
   /**
    * IsEmpty() checks whether the editor is empty.  If editor has only bogus
    * node, returns true.  If editor's root element has non-empty text nodes or
    * other nodes like <br>, returns false.
@@ -262,21 +261,19 @@ class TextEditor : public EditorBase, pu
    * 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.
    ****************************************************************************/
 
   // Overrides of EditorBase
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult RemoveAttributeOrEquivalent(
       Element* aElement, nsAtom* aAttribute,
       bool aSuppressTransaction) override;
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult SetAttributeOrEquivalent(Element* aElement,
                                             nsAtom* aAttribute,
                                             const nsAString& aValue,
                                             bool aSuppressTransaction) override;
   using EditorBase::RemoveAttributeOrEquivalent;
   using EditorBase::SetAttributeOrEquivalent;
 
   /**
@@ -361,21 +358,19 @@ class TextEditor : public EditorBase, pu
   MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult HideLastPasswordInput();
 
   static void GetDefaultEditorPrefs(int32_t& aNewLineHandling,
                                     int32_t& aCaretStyle);
 
  protected:  // Called by helper classes.
   virtual void OnStartToHandleTopLevelEditSubAction(
       EditSubAction aEditSubAction, nsIEditor::EDirection aDirection) override;
-  MOZ_CAN_RUN_SCRIPT
   virtual void OnEndHandlingTopLevelEditSubAction() override;
 
   void BeginEditorInit();
-  MOZ_CAN_RUN_SCRIPT
   nsresult EndEditorInit();
 
  protected:  // Shouldn't be used by friend classes
   virtual ~TextEditor();
 
   int32_t WrapWidth() const { return mWrapColumn; }
 
   /**
@@ -437,17 +432,16 @@ class TextEditor : public EditorBase, pu
 
   /**
    * Return true if the data is safe to insert as the source and destination
    * principals match, or we are in a editor context where this doesn't matter.
    * Otherwise, the data must be sanitized first.
    */
   bool IsSafeToInsertData(Document* aSourceDoc);
 
-  MOZ_CAN_RUN_SCRIPT
   virtual nsresult InitRules();
 
   /**
    * GetAndInitDocEncoder() returns a document encoder instance for aFormatType
    * after initializing it.  The result may be cached for saving recreation
    * cost.
    *
    * @param aFormatType             MIME type like "text/plain".
--- a/editor/libeditor/WSRunObject.cpp
+++ b/editor/libeditor/WSRunObject.cpp
@@ -247,18 +247,17 @@ already_AddRefed<Element> WSRunObject::I
   }
   return newBrElement.forget();
 }
 
 template <typename PT, typename CT>
 nsresult WSRunObject::InsertText(
     Document& aDocument, const nsAString& aStringToInsert,
     const EditorDOMPointBase<PT, CT>& aPointToInsert,
-    EditorRawDOMPoint* aPointAfterInsertedString)
-    MOZ_CAN_RUN_SCRIPT_FOR_DEFINITION {
+    EditorRawDOMPoint* aPointAfterInsertedString) {
   // MOOSE: for now, we always assume non-PRE formatting.  Fix this later.
   // meanwhile, the pre case is handled in WillInsertText in
   // HTMLEditRules.cpp
 
   // MOOSE: for now, just getting the ws logic straight.  This implementation
   // is very slow.  Will need to replace edit rules impl with a more efficient
   // text sink here that does the minimal amount of searching/replacing/copying
 
@@ -377,20 +376,18 @@ nsresult WSRunObject::InsertText(
         prevWS = true;
       }
     } else {
       prevWS = false;
     }
   }
 
   // Ready, aim, fire!
-  nsresult rv =
-      MOZ_KnownLive(mHTMLEditor)
-          ->InsertTextWithTransaction(aDocument, theString, pointToInsert,
-                                      aPointAfterInsertedString);
+  nsresult rv = mHTMLEditor->InsertTextWithTransaction(
+      aDocument, theString, pointToInsert, aPointAfterInsertedString);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return NS_OK;
   }
   return NS_OK;
 }
 
 nsresult WSRunObject::DeleteWSBackward() {
   WSPoint point = GetPreviousCharPoint(Point());
--- a/editor/libeditor/WSRunObject.h
+++ b/editor/libeditor/WSRunObject.h
@@ -231,20 +231,20 @@ class MOZ_STACK_CLASS WSRunObject final 
    *                        So, when this method actually inserts string,
    *                        this is set to a point in the text node.
    *                        Otherwise, this may be set to aPointToInsert.
    * @return                When this succeeds to insert the string or
    *                        does nothing during composition, returns NS_OK.
    *                        Otherwise, an error code.
    */
   template <typename PT, typename CT>
-  MOZ_CAN_RUN_SCRIPT nsresult
-  InsertText(dom::Document& aDocument, const nsAString& aStringToInsert,
-             const EditorDOMPointBase<PT, CT>& aPointToInsert,
-             EditorRawDOMPoint* aPointAfterInsertedString = nullptr);
+  nsresult InsertText(dom::Document& aDocument,
+                      const nsAString& aStringToInsert,
+                      const EditorDOMPointBase<PT, CT>& aPointToInsert,
+                      EditorRawDOMPoint* aPointAfterInsertedString = nullptr);
 
   // DeleteWSBackward deletes a single visible piece of ws before the ws
   // point (the point to create the wsRunObject, passed to its constructor).
   // It makes any needed conversion to adjacent ws to retain its
   // significance.
   nsresult DeleteWSBackward();
 
   // DeleteWSForward deletes a single visible piece of ws after the ws point
--- a/editor/nsIEditor.idl
+++ b/editor/nsIEditor.idl
@@ -47,22 +47,20 @@ interface nsIEditor  : nsISupports
   const short eToBeginningOfLine = 5;
   const short eToEndOfLine = 6;
 
   const short eStrip = 0;
   const short eNoStrip = 1;
 
   readonly attribute Selection selection;
 
-  [can_run_script]
   void setAttributeOrEquivalent(in Element element,
                                 in AString sourceAttrName,
                                 in AString sourceAttrValue,
                                 in boolean aSuppressTransaction);
-  [can_run_script]
   void removeAttributeOrEquivalent(in Element element,
                                    in AString sourceAttrName,
                                    in boolean aSuppressTransaction);
 
   /** edit flags for this editor.  May be set at any time. */
   attribute unsigned long flags;
 
   /**
@@ -383,30 +381,28 @@ interface nsIEditor  : nsISupports
    *   it assures the attribute nodes of the destination are identical
    *   with the source node by copying all existing attributes from the
    *   source and deleting those not in the source.
    *   This is used when the destination element already exists
    *
    * @param aDestNode     the destination element to operate on
    * @param aSourceNode   the source element to copy attributes from
    */
-  [can_run_script]
   void cloneAttributes(in Element aDestElement, in Element aSourceElement);
 
   /**
    * insertNode inserts aNode into aParent at aPosition.
    * No checking is done to verify the legality of the insertion.
    * That is the responsibility of the caller.
    * @param aNode     The DOM Node to insert.
    * @param aParent   The node to insert the new object into
    * @param aPosition The place in aParent to insert the new node
    *                  0=first child, 1=second child, etc.
    *                  any number > number of current children = last child
    */
-  [can_run_script]
   void insertNode(in Node node,
                   in Node parent,
                   in long aPosition);
 
 
   /**
    * splitNode() creates a new node identical to an existing node,
    * and split the contents between the two nodes
--- a/editor/nsIEditorMailSupport.idl
+++ b/editor/nsIEditorMailSupport.idl
@@ -17,17 +17,16 @@ interface nsIEditorMailSupport : nsISupp
     * (whose representation is dependant on the editor type),
     * replacing the selected text (if any),
     * including, if possible, a "cite" attribute.
     * @param aQuotedText  The actual text to be quoted
     * @param aCitation    The "mid" URL of the source message
     * @param aInsertHTML  Insert as html?  (vs plaintext)
     * @return             The node which was inserted
     */
-  [can_run_script]
   Node insertAsCitedQuotation(in AString aQuotedText,
                               in AString aCitation,
                               in boolean aInsertHTML);
 
   /**
    * Rewrap the selected part of the document, re-quoting if necessary.
    * @param aRespectNewlines  Try to maintain newlines in the original?
    */
--- a/editor/nsIHTMLEditor.idl
+++ b/editor/nsIHTMLEditor.idl
@@ -37,17 +37,16 @@ interface nsIHTMLEditor : nsISupports
    * @param aAttribute  the attribute of the property, if applicable.
    *                    May be null.
    *                    Example: aProperty="font", aAttribute="color"
    * @param aValue      if aAttribute is not null, the value of the attribute.
    *                    May be null.
    *                    Example: aProperty="font", aAttribute="color",
    *                             aValue="0x00FFFF"
    */
-  [can_run_script]
   void setInlineProperty(in AString aProperty,
                          in AString aAttribute,
                          in AString aValue);
 
   /**
    * getInlineProperty() gets aggregate properties of the current selection.
    * All object in the current selection are scanned and their attributes are
    * represented in a list of Property object.
@@ -80,50 +79,46 @@ interface nsIHTMLEditor : nsISupports
                                          out boolean aFirst,
                                          out boolean aAny,
                                          out boolean aAll);
 
   /**
    * removeAllInlineProperties() deletes all the inline properties from all
    * text in the current selection.
    */
-  [can_run_script]
   void removeAllInlineProperties();
 
 
   /**
    * removeInlineProperty() removes a property which changes inline style of
    * text.  E.g., bold, italic, super and sub.
    *
    * @param aProperty   Tag name whcih represents the inline style you want to
    *                    remove.  E.g., "strong", "b", etc.
    *                    If "href", <a> element which has href attribute will be
    *                    removed.
    *                    If "name", <a> element which has non-empty name
    *                    attribute will be removed.
    * @param aAttribute  If aProperty is "font", aAttribute should be "face",
    *                    "size", "color" or "bgcolor".
    */
-  [can_run_script]
   void removeInlineProperty(in AString aProperty, in AString aAttribute);
 
   /**
    *  Increase font size for text in selection by 1 HTML unit
    *  All existing text is scanned for existing <FONT SIZE> attributes
    *  so they will be incremented instead of inserting new <FONT> tag
    */
-  [can_run_script]
   void increaseFontSize();
 
   /**
    *  Decrease font size for text in selection by 1 HTML unit
    *  All existing text is scanned for existing <FONT SIZE> attributes
    *  so they will be decreased instead of inserting new <FONT> tag
    */
-  [can_run_script]
   void decreaseFontSize();
 
   /* ------------ HTML content methods -------------- */
 
   /**
    * Tests if a node is a BLOCK element according the the HTML 4.0 DTD.
    *   This does NOT consider CSS effect on display type
    *
@@ -131,17 +126,16 @@ interface nsIHTMLEditor : nsISupports
    */
   boolean nodeIsBlock(in Node node);
 
   /**
    * Insert some HTML source at the current location
    *
    * @param aInputString   the string to be inserted
    */
-  [can_run_script]
   void insertHTML(in AString aInputString);
 
 
   /**
     * Paste the text in the OS clipboard at the cursor position, replacing
     * the selected text (if any), but strip out any HTML styles and formatting
     */
   [can_run_script]
@@ -163,17 +157,16 @@ interface nsIHTMLEditor : nsISupports
     *   be useful for other elements.
     *
     * @param aElement           The element to insert
     * @param aDeleteSelection   Delete the selection before inserting
     *     If aDeleteSelection is PR_FALSE, then the element is inserted
     *     after the end of the selection for all element except
     *     Named Anchors, which insert before the selection
     */
-  [can_run_script]
   void insertElementAtSelection(in Element aElement,
                                 in boolean aDeleteSelection);
 
   /**
    *   Set the BaseURL for the document to the current URL
    *     but only if the page doesn't have a <base> tag
    *   This should be done after the document URL has changed,
    *     such as after saving a file
@@ -214,17 +207,16 @@ interface nsIHTMLEditor : nsISupports
   void setParagraphFormat(in AString aParagraphFormat);
 
   /**
    * getParagraphState returns what block tag paragraph format is in
    * the selection.
    * @param aMixed     True if there is more than one format
    * @return           Name of block tag. "" is returned for none.
    */
-  [can_run_script]
   AString getParagraphState(out boolean aMixed);
 
   /**
    * getFontFaceState returns what font face is in the selection.
    * @param aMixed    True if there is more than one font face
    * @return          Name of face.  Note: "tt" is returned for
    *                  tt tag.  "" is returned for none.
    */
@@ -248,40 +240,37 @@ interface nsIHTMLEditor : nsISupports
    * getListState returns what list type is in the selection.
    * @param aMixed    True if there is more than one type of list, or
    *                  if there is some list and non-list
    * @param aOL       The company that employs me.  No, really, it's
    *                  true if an "ol" list is selected.
    * @param aUL       true if an "ul" list is selected.
    * @param aDL       true if a "dl" list is selected.
    */
-  [can_run_script]
   void getListState(out boolean aMixed, out boolean aOL, out boolean aUL,
                     out boolean aDL);
 
   /**
    * getListItemState returns what list item type is in the selection.
    * @param aMixed    True if there is more than one type of list item, or
    *                  if there is some list and non-list
    * @param aLI       true if "li" list items are selected.
    * @param aDT       true if "dt" list items are selected.
    * @param aDD       true if "dd" list items are selected.
    */
-  [can_run_script]
   void getListItemState(out boolean aMixed, out boolean aLI,
                         out boolean aDT, out boolean aDD);
 
   /**
    * getAlignment     returns what alignment is in the selection.
    * @param aMixed    True if there is more than one type of list item, or
    *                  if there is some list and non-list
    * @param aAlign    enum value for first encountered alignment
    *                  (left/center/right)
    */
-  [can_run_script]
   void getAlignment(out boolean aMixed, out short aAlign);
 
   /**
    * Document me!
    *
    */
   void makeOrChangeList(in AString aListType, in boolean entireList,
                         in AString aBulletType);
@@ -362,25 +351,23 @@ interface nsIHTMLEditor : nsISupports
    * @param aTagName  The HTML tagname
    *    Special input values for Links and Named anchors:
    *    Use "href" to get a link node
    *      (an "A" tag with the "href" attribute set)
    *    Use "anchor" or "namedanchor" to get a named anchor node
    *      (an "A" tag with the "name" attribute set)
    * @return          The new element created.
    */
-  [can_run_script]
   Element createElementWithDefaults(in AString aTagName);
 
   /**
    * Insert an link element as the parent of the current selection
    *
    * @param aElement   An "A" element with a non-empty "href" attribute
    */
-  [can_run_script]
   void insertLinkAroundSelection(in Element aAnchorElement);
 
   /**
    * Set the value of the "bgcolor" attribute on the document's <body> element
    *
    * @param aColor  The HTML color string, such as "#ffccff" or "yellow"
    */
   void setBackgroundColor(in AString aColor);