Bug 1534370 part 2. Annotate doCommand as MOZ_CAN_RUN_SCRIPT. r=masayuki
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 12 Mar 2019 01:57:42 +0000
changeset 521632 1289a49488fa7cf67e0bfbb9ed81afc43196e3bf
parent 521631 dcaf8c29a1eef3bf5eb76a77a3ae1a188ba5b0b3
child 521633 879d393e6c581ce67bb748fce870f0325d502112
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 2. Annotate doCommand as MOZ_CAN_RUN_SCRIPT. r=masayuki Differential Revision: https://phabricator.services.mozilla.com/D23041
docshell/base/nsIDocShell.idl
dom/base/nsGlobalWindowCommands.cpp
dom/commandhandler/nsBaseCommandController.cpp
dom/commandhandler/nsIControllerCommand.idl
dom/commandhandler/nsIControllerCommandTable.idl
dom/html/nsTextEditorState.cpp
dom/xbl/nsXBLEventHandler.cpp
dom/xbl/nsXBLEventHandler.h
dom/xbl/nsXBLPrototypeHandler.h
dom/xbl/nsXBLWindowKeyHandler.h
dom/xul/nsIController.idl
editor/libeditor/EditorEventListener.cpp
editor/libeditor/EditorEventListener.h
--- a/docshell/base/nsIDocShell.idl
+++ b/docshell/base/nsIDocShell.idl
@@ -906,16 +906,17 @@ interface nsIDocShell : nsIDocShellTreeI
   boolean getCurrentSHEntry(out nsISHEntry aEntry);
 
   /**
     * Cherry picked parts of nsIController.
     * They are here, because we want to call these functions
     * from JS.
     */
   boolean isCommandEnabled(in string command);
+  [can_run_script]
   void doCommand(in string command);
   [can_run_script]
   void doCommandWithParams(in string command, in nsICommandParams aParams);
 
   /**
    * Invisible DocShell are dummy construct to simulate DOM windows
    * without any actual visual representation. They have to be marked
    * at construction time, to avoid any painting activity.
--- a/dom/base/nsGlobalWindowCommands.cpp
+++ b/dom/base/nsGlobalWindowCommands.cpp
@@ -115,16 +115,17 @@ class nsSelectionCommandsBase : public n
  public:
   NS_DECL_ISUPPORTS
   NS_IMETHOD IsCommandEnabled(const char *aCommandName,
                               nsISupports *aCommandContext,
                               bool *_retval) override;
   NS_IMETHOD GetCommandStateParams(const char *aCommandName,
                                    nsICommandParams *aParams,
                                    nsISupports *aCommandContext) override;
+  MOZ_CAN_RUN_SCRIPT
   NS_IMETHOD DoCommandParams(const char *aCommandName,
                              nsICommandParams *aParams,
                              nsISupports *aCommandContext) override;
 
  protected:
   virtual ~nsSelectionCommandsBase() {}
 
   static nsresult GetPresShellFromWindow(nsPIDOMWindowOuter *aWindow,
--- a/dom/commandhandler/nsBaseCommandController.cpp
+++ b/dom/commandhandler/nsBaseCommandController.cpp
@@ -109,23 +109,22 @@ nsBaseCommandController::SupportsCommand
   return mCommandTable->SupportsCommand(aCommand, context, aResult);
 }
 
 NS_IMETHODIMP
 nsBaseCommandController::DoCommand(const char* aCommand) {
   NS_ENSURE_ARG_POINTER(aCommand);
   NS_ENSURE_STATE(mCommandTable);
 
-  nsISupports* context = mCommandContextRawPtr;
-  nsCOMPtr<nsISupports> weak;
+  nsCOMPtr<nsISupports> context = mCommandContextRawPtr;
   if (!context) {
-    weak = do_QueryReferent(mCommandContextWeakPtr);
-    context = weak;
+    context = do_QueryReferent(mCommandContextWeakPtr);
   }
-  return mCommandTable->DoCommand(aCommand, context);
+  nsCOMPtr<nsIControllerCommandTable> commandTable(mCommandTable);
+  return commandTable->DoCommand(aCommand, context);
 }
 
 NS_IMETHODIMP
 nsBaseCommandController::DoCommandWithParams(const char* aCommand,
                                              nsICommandParams* aParams) {
   NS_ENSURE_ARG_POINTER(aCommand);
   NS_ENSURE_STATE(mCommandTable);
 
--- a/dom/commandhandler/nsIControllerCommand.idl
+++ b/dom/commandhandler/nsIControllerCommand.idl
@@ -38,15 +38,16 @@ interface nsIControllerCommand : nsISupp
    * Execute the name command.
    *
    * @param aCommandName  the name of the command to execute.
    * 
    * @param aCommandContext    a cookie held by the nsIControllerCommandTable,
    *                  allowing the command to get some context information.
    *                  The contents of this cookie are implementation-defined.
    */
+  [can_run_script]
   void    doCommand(in string aCommandName, in nsISupports aCommandContext);
 
   [can_run_script]
   void    doCommandParams(in string aCommandName, in nsICommandParams aParams, in nsISupports aCommandContext);
   
 };
 
--- a/dom/commandhandler/nsIControllerCommandTable.idl
+++ b/dom/commandhandler/nsIControllerCommandTable.idl
@@ -72,16 +72,17 @@ interface nsIControllerCommandTable : ns
 	boolean supportsCommand(in string aCommandName, in nsISupports aCommandRefCon);
 
   /**
    * Execute the named command.
    *
    * @param aCommandName    the name of the command to execute
    * @param aCommandRefCon  the command context data
    */
+  [can_run_script]
 	void    doCommand(in string aCommandName, in nsISupports aCommandRefCon);
 
   [can_run_script]
 	void    doCommandParams(in string aCommandName, in nsICommandParams aParam, in nsISupports aCommandRefCon);
 
 	void    getCommandState(in string aCommandName, in nsICommandParams aParam, in nsISupports aCommandRefCon);
 
   void getSupportedCommands(out unsigned long count,
--- a/dom/html/nsTextEditorState.cpp
+++ b/dom/html/nsTextEditorState.cpp
@@ -821,16 +821,17 @@ void TextInputListener::OnSelectionChang
   if (!weakFrame.IsAlive() || !mFrame ||
       !nsContentUtils::IsFocusedContent(mFrame->GetContent())) {
     return;
   }
 
   UpdateTextInputCommands(NS_LITERAL_STRING("select"), &aSelection, aReason);
 }
 
+MOZ_CAN_RUN_SCRIPT
 static void DoCommandCallback(Command aCommand, void* aData) {
   nsTextControlFrame* frame = static_cast<nsTextControlFrame*>(aData);
   nsIContent* content = frame->GetContent();
 
   nsCOMPtr<nsIControllers> controllers;
   HTMLInputElement* input = HTMLInputElement::FromNode(content);
   if (input) {
     input->GetControllers(getter_AddRefs(controllers));
--- a/dom/xbl/nsXBLEventHandler.cpp
+++ b/dom/xbl/nsXBLEventHandler.cpp
@@ -33,17 +33,18 @@ nsXBLEventHandler::HandleEvent(Event* aE
   if (phase == NS_PHASE_TARGET) {
     if (aEvent->EventPhase() != Event_Binding::AT_TARGET) {
       return NS_OK;
     }
   }
 
   if (!EventMatched(aEvent)) return NS_OK;
 
-  mProtoHandler->ExecuteHandler(aEvent->GetCurrentTarget(), aEvent);
+  RefPtr<EventTarget> currentTarget = aEvent->GetCurrentTarget();
+  mProtoHandler->ExecuteHandler(currentTarget, aEvent);
 
   return NS_OK;
 }
 
 nsXBLMouseEventHandler::nsXBLMouseEventHandler(nsXBLPrototypeHandler* aHandler)
     : nsXBLEventHandler(aHandler) {}
 
 nsXBLMouseEventHandler::~nsXBLMouseEventHandler() {}
--- a/dom/xbl/nsXBLEventHandler.h
+++ b/dom/xbl/nsXBLEventHandler.h
@@ -76,16 +76,17 @@ class nsXBLKeyEventHandler : public nsID
   void SetIsBoundToChrome(bool aIsBoundToChrome) {
     mIsBoundToChrome = aIsBoundToChrome;
   }
 
  private:
   nsXBLKeyEventHandler();
   virtual ~nsXBLKeyEventHandler();
 
+  MOZ_CAN_RUN_SCRIPT
   bool ExecuteMatchedHandlers(mozilla::dom::KeyboardEvent* aEvent,
                               uint32_t aCharCode,
                               const IgnoreModifierState& aIgnoreModifierState);
 
   nsTArray<nsXBLPrototypeHandler*> mProtoHandlers;
   RefPtr<nsAtom> mEventType;
   uint8_t mPhase;
   uint8_t mType;
--- a/dom/xbl/nsXBLPrototypeHandler.h
+++ b/dom/xbl/nsXBLPrototypeHandler.h
@@ -131,17 +131,17 @@ class nsXBLPrototypeHandler {
   uint8_t GetType() { return mType; }
   XBLReservedKey GetIsReserved() { return mReserved; }
 
   nsXBLPrototypeHandler* GetNextHandler() { return mNextHandler; }
   void SetNextHandler(nsXBLPrototypeHandler* aHandler) {
     mNextHandler = aHandler;
   }
 
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY
+  MOZ_CAN_RUN_SCRIPT
   nsresult ExecuteHandler(mozilla::dom::EventTarget* aTarget,
                           mozilla::dom::Event* aEvent);
 
   already_AddRefed<nsAtom> GetEventName();
   void SetEventName(nsAtom* aName) { mEventName = aName; }
 
   nsXBLEventHandler* GetEventHandler() {
     if (!mHandler) {
@@ -194,16 +194,17 @@ class nsXBLPrototypeHandler {
       const char16_t* aAllowUntrusted = nullptr);
 
   void ReportKeyConflict(const char16_t* aKey, const char16_t* aModifiers,
                          mozilla::dom::Element* aElement,
                          const char* aMessageName);
   void GetEventType(nsAString& type);
   bool ModifiersMatchMask(mozilla::dom::UIEvent* aEvent,
                           const IgnoreModifierState& aIgnoreModifierState);
+  MOZ_CAN_RUN_SCRIPT
   nsresult DispatchXBLCommand(mozilla::dom::EventTarget* aTarget,
                               mozilla::dom::Event* aEvent);
   nsresult DispatchXULKeyCommand(mozilla::dom::Event* aEvent);
   nsresult EnsureEventHandler(mozilla::dom::AutoJSAPI& jsapi, nsAtom* aName,
                               JS::MutableHandle<JSObject*> aHandler);
 
   Modifiers GetModifiers() const;
   Modifiers GetModifiersMask() const;
--- a/dom/xbl/nsXBLWindowKeyHandler.h
+++ b/dom/xbl/nsXBLWindowKeyHandler.h
@@ -44,37 +44,43 @@ class nsXBLWindowKeyHandler : public nsI
   static KeyboardMap CollectKeyboardShortcuts();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMEVENTLISTENER
 
  protected:
   virtual ~nsXBLWindowKeyHandler();
 
+  MOZ_CAN_RUN_SCRIPT
   nsresult WalkHandlers(KeyboardEvent* aKeyEvent);
 
   // walk the handlers, looking for one to handle the event
+  MOZ_CAN_RUN_SCRIPT
   bool WalkHandlersInternal(KeyboardEvent* aKeyEvent, bool aExecute,
                             bool* aOutReservedForChrome = nullptr);
 
   // walk the handlers for aEvent, aCharCode and aIgnoreModifierState. Execute
   // it if aExecute = true.
+  MOZ_CAN_RUN_SCRIPT
   bool WalkHandlersAndExecute(KeyboardEvent* aKeyEvent, uint32_t aCharCode,
                               const IgnoreModifierState& aIgnoreModifierState,
                               bool aExecute,
                               bool* aOutReservedForChrome = nullptr);
 
   // HandleEvent function for the capturing phase in the default event group.
+  MOZ_CAN_RUN_SCRIPT
   void HandleEventOnCaptureInDefaultEventGroup(KeyboardEvent* aEvent);
   // HandleEvent function for the capturing phase in the system event group.
+  MOZ_CAN_RUN_SCRIPT
   void HandleEventOnCaptureInSystemEventGroup(KeyboardEvent* aEvent);
 
   // Check if any handler would handle the given event. Optionally returns
   // whether the command handler for the event is marked with the "reserved"
   // attribute.
+  MOZ_CAN_RUN_SCRIPT
   bool HasHandlerForEvent(KeyboardEvent* aEvent,
                           bool* aOutReservedForChrome = nullptr);
 
   // Returns true if the key would be reserved for the given handler. A reserved
   // key is not sent to a content process or single-process equivalent.
   bool IsReservedKey(mozilla::WidgetKeyboardEvent* aKeyEvent,
                      nsXBLPrototypeHandler* aHandler);
 
--- a/dom/xul/nsIController.idl
+++ b/dom/xul/nsIController.idl
@@ -5,16 +5,17 @@
 
 #include "nsISupports.idl"
 
 [scriptable, uuid(D5B61B82-1DA4-11d3-BF87-00105A1B0627)]
 interface nsIController : nsISupports {
   boolean isCommandEnabled(in string command);
   boolean supportsCommand(in string command);
 
+  [can_run_script]
   void doCommand(in string command);
 
   void onEvent(in string eventName);
 };
 
 
 /*
 
--- a/editor/libeditor/EditorEventListener.cpp
+++ b/editor/libeditor/EditorEventListener.cpp
@@ -57,16 +57,17 @@
 #include "mozilla/dom/TabParent.h"
 
 class nsPresContext;
 
 namespace mozilla {
 
 using namespace dom;
 
+MOZ_CAN_RUN_SCRIPT
 static void DoCommandCallback(Command aCommand, void* aData) {
   Document* doc = static_cast<Document*>(aData);
   nsPIDOMWindowOuter* win = doc->GetWindow();
   if (!win) {
     return;
   }
   nsCOMPtr<nsPIWindowRoot> root = win->GetTopWindowRoot();
   if (!root) {
--- a/editor/libeditor/EditorEventListener.h
+++ b/editor/libeditor/EditorEventListener.h
@@ -60,16 +60,17 @@ class EditorEventListener : public nsIDO
   nsresult InstallToEditor();
   void UninstallFromEditor();
 
 #ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
   nsresult KeyDown(const WidgetKeyboardEvent* aKeyboardEvent);
   MOZ_CAN_RUN_SCRIPT
   nsresult KeyUp(const WidgetKeyboardEvent* aKeyboardEvent);
 #endif
+  MOZ_CAN_RUN_SCRIPT
   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);