Bug 1534370 part 4. Remove some simple MOZ_CAN_RUN_SCRIPT_BOUNDARY annotations from editor. r=masayuki
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 12 Mar 2019 01:50:41 +0000
changeset 521634 ce5d6bf5dcca9cf3d61955a97b34023f0a870b23
parent 521633 879d393e6c581ce67bb748fce870f0325d502112
child 521635 dff00691b1576fe6d78b38c4b6934c9a9a6aac60
child 521674 9067457d7dcf72804288f61fc18326f31b2fc140
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1534370
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1534370 part 4. Remove some simple MOZ_CAN_RUN_SCRIPT_BOUNDARY annotations from editor. r=masayuki Differential Revision: https://phabricator.services.mozilla.com/D23044
editor/libeditor/EditorBase.h
editor/libeditor/EditorCommands.cpp
editor/libeditor/EditorEventListener.h
editor/libeditor/HTMLEditorEventListener.h
editor/libeditor/TextEditor.h
editor/nsIEditor.idl
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -275,17 +275,17 @@ class EditorBase : public nsIEditor,
    * For example, the editor instance, the widget or the process itself may
    * be destroyed.
    */
   nsresult CommitComposition();
 
   /**
    * ToggleTextDirection() toggles text-direction of the root element.
    */
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY
+  MOZ_CAN_RUN_SCRIPT
   nsresult ToggleTextDirection();
 
   /**
    * SwitchTextDirectionTo() sets the text-direction of the root element to
    * LTR or RTL.
    */
   enum class TextDirection {
     eLTR,
--- a/editor/libeditor/EditorCommands.cpp
+++ b/editor/libeditor/EditorCommands.cpp
@@ -68,17 +68,18 @@ UndoCommand::IsCommandEnabled(const char
 NS_IMETHODIMP
 UndoCommand::DoCommand(const char* aCommandName, nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (!editor) {
     return NS_ERROR_FAILURE;
   }
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
-  return textEditor->Undo(1);
+  // MOZ_KnownLive because we are holding a stack ref in "editor".
+  return MOZ_KnownLive(textEditor)->Undo(1);
 }
 
 NS_IMETHODIMP
 UndoCommand::DoCommandParams(const char* aCommandName,
                              nsICommandParams* aParams,
                              nsISupports* aCommandRefCon) {
   return DoCommand(aCommandName, aCommandRefCon);
 }
@@ -121,17 +122,18 @@ RedoCommand::IsCommandEnabled(const char
 NS_IMETHODIMP
 RedoCommand::DoCommand(const char* aCommandName, nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (!editor) {
     return NS_ERROR_FAILURE;
   }
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
-  return textEditor->Redo(1);
+  // MOZ_KnownLive because we are holding a stack ref in "editor".
+  return MOZ_KnownLive(textEditor)->Redo(1);
 }
 
 NS_IMETHODIMP
 RedoCommand::DoCommandParams(const char* aCommandName,
                              nsICommandParams* aParams,
                              nsISupports* aCommandRefCon) {
   return DoCommand(aCommandName, aCommandRefCon);
 }
@@ -534,17 +536,18 @@ NS_IMETHODIMP
 SwitchTextDirectionCommand::DoCommand(const char* aCommandName,
                                       nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
   }
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
-  return textEditor->ToggleTextDirection();
+  // MOZ_KnownLive because we are holding a stack ref in "editor".
+  return MOZ_KnownLive(textEditor)->ToggleTextDirection();
 }
 
 NS_IMETHODIMP
 SwitchTextDirectionCommand::DoCommandParams(const char* aCommandName,
                                             nsICommandParams* aParams,
                                             nsISupports* aCommandRefCon) {
   return DoCommand(aCommandName, aCommandRefCon);
 }
--- a/editor/libeditor/EditorEventListener.h
+++ b/editor/libeditor/EditorEventListener.h
@@ -44,17 +44,17 @@ class EditorEventListener : public nsIDO
 
   virtual nsresult Connect(EditorBase* aEditorBase);
 
   virtual void Disconnect();
 
   NS_DECL_ISUPPORTS
 
   // nsIDOMEventListener
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY
+  MOZ_CAN_RUN_SCRIPT
   NS_IMETHOD HandleEvent(dom::Event* aEvent) override;
 
   void SpellCheckIfNeeded();
 
  protected:
   virtual ~EditorEventListener();
 
   nsresult InstallToEditor();
--- a/editor/libeditor/HTMLEditorEventListener.h
+++ b/editor/libeditor/HTMLEditorEventListener.h
@@ -19,17 +19,17 @@ class HTMLEditorEventListener final : pu
       : EditorEventListener(),
         mListeningToMouseMoveEventForResizers(false),
         mListeningToMouseMoveEventForGrabber(false),
         mListeningToResizeEvent(false) {}
 
   virtual ~HTMLEditorEventListener() {}
 
   // nsIDOMEventListener
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY
+  MOZ_CAN_RUN_SCRIPT
   NS_IMETHOD HandleEvent(dom::Event* aEvent) override;
 
   /**
    * Connect() fails if aEditorBase isn't an HTMLEditor instance.
    */
   virtual nsresult Connect(EditorBase* aEditorBase) override;
 
   virtual void Disconnect() override;
--- a/editor/libeditor/TextEditor.h
+++ b/editor/libeditor/TextEditor.h
@@ -57,19 +57,19 @@ class TextEditor : public EditorBase, pu
 
   NS_IMETHOD DeleteSelection(EDirection aAction,
                              EStripWrappers aStripWrappers) override;
 
   NS_IMETHOD SetDocumentCharacterSet(const nsACString& characterSet) override;
 
   // If there are some good name to create non-virtual Undo()/Redo() methods,
   // we should create them and those methods should just run them.
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY
+  MOZ_CAN_RUN_SCRIPT
   NS_IMETHOD Undo(uint32_t aCount) final;
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY
+  MOZ_CAN_RUN_SCRIPT
   NS_IMETHOD Redo(uint32_t aCount) final;
 
   NS_IMETHOD Cut() override;
   NS_IMETHOD CanCut(bool* aCanCut) override;
   NS_IMETHOD Copy() override;
   NS_IMETHOD CanCopy(bool* aCanCopy) override;
   NS_IMETHOD CanDelete(bool* aCanDelete) override;
   NS_IMETHOD CanPaste(int32_t aSelectionType, bool* aCanPaste) override;
--- a/editor/nsIEditor.idl
+++ b/editor/nsIEditor.idl
@@ -163,16 +163,17 @@ interface nsIEditor  : nsISupports
     * It is provided here so clients need no knowledge of whether
     * the editor has a transaction manager or not.
     * If a transaction manager is present, it is told to undo,
     * and the result of that undo is returned.
     * Otherwise, the Undo request is ignored and an
     * error NS_ERROR_NOT_AVAILABLE is returned.
     *
     */
+  [can_run_script]
   void undo(in unsigned long count);
 
   /** returns state information about the undo system.
     * @param aIsEnabled [OUT] PR_TRUE if undo is enabled
     * @param aCanUndo   [OUT] PR_TRUE if at least one transaction is
     *                         currently ready to be undone.
     */
   void canUndo(out boolean isEnabled, out boolean canUndo);
@@ -182,16 +183,17 @@ interface nsIEditor  : nsISupports
     * the editor has a transaction manager or not.
     * If a transaction manager is present, it is told to redo and the
     * result of the previously undone transaction is reapplied to the document.
     * If no transaction is available for Redo, or if the document
     * has no transaction manager, the Redo request is ignored and an
     * error NS_ERROR_NOT_AVAILABLE is returned.
     *
     */
+  [can_run_script]
   void redo(in unsigned long count);
 
   /** returns state information about the redo system.
     * @param aIsEnabled [OUT] PR_TRUE if redo is enabled
     * @param aCanRedo   [OUT] PR_TRUE if at least one transaction is
                               currently ready to be redone.
     */
   void canRedo(out boolean isEnabled, out boolean canRedo);