Bug 1542665 - Stop using const nsCOMPtr<nsIPresShell>& arguments r=bzbarsky

Some methods take `const nsCOMPtr<nsIPresShell>&` as their argument to make
their callers guarantee the lifetime.  However, currently all of them are
marked as `MOZ_CAN_RUN_SCRIPT`.  So, it's safe to change them to raw pointer.

Additionally, this patch makes them take `mozilla::PresShell*` directly
rather than via `nsIPresShell*`.

Differential Revision: https://phabricator.services.mozilla.com/D26456

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Masayuki Nakano 2019-04-13 02:23:07 +00:00
parent fdbbccd877
commit e2a9511e93
10 changed files with 42 additions and 44 deletions

View File

@ -7920,9 +7920,9 @@ nsView* nsContentUtils::GetViewToDispatchEvent(nsPresContext* presContext,
}
nsresult nsContentUtils::SendMouseEvent(
const nsCOMPtr<nsIPresShell>& aPresShell, const nsAString& aType, float aX,
float aY, int32_t aButton, int32_t aButtons, int32_t aClickCount,
int32_t aModifiers, bool aIgnoreRootScrollFrame, float aPressure,
mozilla::PresShell* aPresShell, const nsAString& aType, float aX, float aY,
int32_t aButton, int32_t aButtons, int32_t aClickCount, int32_t aModifiers,
bool aIgnoreRootScrollFrame, float aPressure,
unsigned short aInputSourceArg, uint32_t aIdentifier, bool aToWindow,
bool* aPreventDefault, bool aIsDOMEventSynthesized,
bool aIsWidgetEventSynthesized) {

View File

@ -2894,11 +2894,11 @@ class nsContentUtils {
*/
MOZ_CAN_RUN_SCRIPT
static nsresult SendMouseEvent(
const nsCOMPtr<nsIPresShell>& aPresShell, const nsAString& aType,
float aX, float aY, int32_t aButton, int32_t aButtons,
int32_t aClickCount, int32_t aModifiers, bool aIgnoreRootScrollFrame,
float aPressure, unsigned short aInputSourceArg, uint32_t aIdentifier,
bool aToWindow, bool* aPreventDefault, bool aIsDOMEventSynthesized,
mozilla::PresShell* aPresShell, const nsAString& aType, float aX,
float aY, int32_t aButton, int32_t aButtons, int32_t aClickCount,
int32_t aModifiers, bool aIgnoreRootScrollFrame, float aPressure,
unsigned short aInputSourceArg, uint32_t aIdentifier, bool aToWindow,
bool* aPreventDefault, bool aIsDOMEventSynthesized,
bool aIsWidgetEventSynthesized);
static void FirePageShowEvent(nsIDocShellTreeItem* aItem,

View File

@ -669,7 +669,7 @@ nsDOMWindowUtils::SendMouseEventCommon(
float aPressure, unsigned short aInputSourceArg, uint32_t aPointerId,
bool aToWindow, bool* aPreventDefault, bool aIsDOMEventSynthesized,
bool aIsWidgetEventSynthesized, int32_t aButtons) {
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
RefPtr<PresShell> presShell = GetPresShell();
return nsContentUtils::SendMouseEvent(
presShell, aType, aX, aY, aButton, aButtons, aClickCount, aModifiers,
aIgnoreRootScrollFrame, aPressure, aInputSourceArg, aPointerId, aToWindow,

View File

@ -1274,7 +1274,7 @@ mozilla::ipc::IPCResult TabChild::RecvHandleTap(
// to be refcounted. This function can run script, which may trigger a nested
// event loop, which may release this, so we hold a strong reference here.
RefPtr<TabChild> kungFuDeathGrip(this);
PresShell* presShell = GetTopLevelPresShell();
RefPtr<PresShell> presShell = GetTopLevelPresShell();
if (!presShell) {
return IPC_OK();
}
@ -1303,18 +1303,14 @@ mozilla::ipc::IPCResult TabChild::RecvHandleTap(
case GeckoContentController::TapType::eLongTap:
if (mTabChildMessageManager) {
RefPtr<APZEventState> eventState(mAPZEventState);
// XXX ProcessLongTap() requires nsCOMPtr<nsIPresShell&>.
nsCOMPtr<nsIPresShell> iPresShell = presShell;
eventState->ProcessLongTap(iPresShell, point, scale, aModifiers, aGuid,
eventState->ProcessLongTap(presShell, point, scale, aModifiers, aGuid,
aInputBlockId);
}
break;
case GeckoContentController::TapType::eLongTapUp:
if (mTabChildMessageManager) {
RefPtr<APZEventState> eventState(mAPZEventState);
// XXX ProcessLongTapUp() requires nsCOMPtr<nsIPresShell&>.
nsCOMPtr<nsIPresShell> iPresShell = presShell;
eventState->ProcessLongTapUp(iPresShell, point, scale, aModifiers);
eventState->ProcessLongTapUp(presShell, point, scale, aModifiers);
}
break;
}
@ -1423,8 +1419,7 @@ mozilla::ipc::IPCResult TabChild::RecvMouseEvent(
// to be refcounted. This function can run script, which may trigger a nested
// event loop, which may release this, so we hold a strong reference here.
RefPtr<TabChild> kungFuDeathGrip(this);
// XXX DispatchMouseEvent() requires nsCOMPtr<nsIPresShell>&.
nsCOMPtr<nsIPresShell> presShell = GetTopLevelPresShell();
RefPtr<PresShell> presShell = GetTopLevelPresShell();
APZCCallbackHelper::DispatchMouseEvent(
presShell, aType, CSSPoint(aX, aY), aButton, aClickCount, aModifiers,
aIgnoreRootScrollFrame, MouseEvent_Binding::MOZ_SOURCE_UNKNOWN,

View File

@ -576,10 +576,10 @@ nsEventStatus APZCCallbackHelper::DispatchSynthesizedMouseEvent(
}
bool APZCCallbackHelper::DispatchMouseEvent(
const nsCOMPtr<nsIPresShell>& aPresShell, const nsString& aType,
const CSSPoint& aPoint, int32_t aButton, int32_t aClickCount,
int32_t aModifiers, bool aIgnoreRootScrollFrame,
unsigned short aInputSourceArg, uint32_t aPointerId) {
PresShell* aPresShell, const nsString& aType, const CSSPoint& aPoint,
int32_t aButton, int32_t aClickCount, int32_t aModifiers,
bool aIgnoreRootScrollFrame, unsigned short aInputSourceArg,
uint32_t aPointerId) {
NS_ENSURE_TRUE(aPresShell, true);
bool defaultPrevented = false;

View File

@ -27,6 +27,9 @@ template <class T>
class nsCOMPtr;
namespace mozilla {
class PresShell;
namespace layers {
typedef std::function<void(uint64_t, const nsTArray<TouchBehaviorFlags>&)>
@ -134,10 +137,9 @@ class APZCCallbackHelper {
* Return whether or not any listeners have called preventDefault on the
* event. */
MOZ_CAN_RUN_SCRIPT
static bool DispatchMouseEvent(const nsCOMPtr<nsIPresShell>& aPresShell,
const nsString& aType, const CSSPoint& aPoint,
int32_t aButton, int32_t aClickCount,
int32_t aModifiers,
static bool DispatchMouseEvent(PresShell* aPresShell, const nsString& aType,
const CSSPoint& aPoint, int32_t aButton,
int32_t aClickCount, int32_t aModifiers,
bool aIgnoreRootScrollFrame,
unsigned short aInputSourceArg,
uint32_t aPointerId);

View File

@ -17,6 +17,7 @@
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/Move.h"
#include "mozilla/Preferences.h"
#include "mozilla/PresShell.h"
#include "mozilla/TouchEvents.h"
#include "mozilla/layers/APZCCallbackHelper.h"
#include "nsCOMPtr.h"
@ -212,10 +213,11 @@ void APZEventState::ProcessSingleTap(const CSSPoint& aPoint,
}
}
bool APZEventState::FireContextmenuEvents(
const nsCOMPtr<nsIPresShell>& aPresShell, const CSSPoint& aPoint,
const CSSToLayoutDeviceScale& aScale, Modifiers aModifiers,
const nsCOMPtr<nsIWidget>& aWidget) {
bool APZEventState::FireContextmenuEvents(PresShell* aPresShell,
const CSSPoint& aPoint,
const CSSToLayoutDeviceScale& aScale,
Modifiers aModifiers,
const nsCOMPtr<nsIWidget>& aWidget) {
// Synthesize mousemove event for allowing users to emulate to move mouse
// cursor over the element. As a result, users can open submenu UI which
// is opened when mouse cursor is moved over a link (i.e., it's a case that
@ -256,7 +258,7 @@ bool APZEventState::FireContextmenuEvents(
return eventHandled;
}
void APZEventState::ProcessLongTap(const nsCOMPtr<nsIPresShell>& aPresShell,
void APZEventState::ProcessLongTap(PresShell* aPresShell,
const CSSPoint& aPoint,
const CSSToLayoutDeviceScale& aScale,
Modifiers aModifiers,
@ -300,7 +302,7 @@ void APZEventState::ProcessLongTap(const nsCOMPtr<nsIPresShell>& aPresShell,
}
}
void APZEventState::ProcessLongTapUp(const nsCOMPtr<nsIPresShell>& aPresShell,
void APZEventState::ProcessLongTapUp(PresShell* aPresShell,
const CSSPoint& aPoint,
const CSSToLayoutDeviceScale& aScale,
Modifiers aModifiers) {

View File

@ -24,10 +24,12 @@
template <class>
class nsCOMPtr;
class nsIContent;
class nsIPresShell;
class nsIWidget;
namespace mozilla {
class PresShell;
namespace layers {
class ActiveElementManager;
@ -56,14 +58,12 @@ class APZEventState final {
Modifiers aModifiers, const ScrollableLayerGuid& aGuid,
int32_t aClickCount);
MOZ_CAN_RUN_SCRIPT
void ProcessLongTap(const nsCOMPtr<nsIPresShell>& aUtils,
const CSSPoint& aPoint,
void ProcessLongTap(PresShell* aPresShell, const CSSPoint& aPoint,
const CSSToLayoutDeviceScale& aScale,
Modifiers aModifiers, const ScrollableLayerGuid& aGuid,
uint64_t aInputBlockId);
MOZ_CAN_RUN_SCRIPT
void ProcessLongTapUp(const nsCOMPtr<nsIPresShell>& aPresShell,
const CSSPoint& aPoint,
void ProcessLongTapUp(PresShell* aPresShell, const CSSPoint& aPoint,
const CSSToLayoutDeviceScale& aScale,
Modifiers aModifiers);
void ProcessTouchEvent(const WidgetTouchEvent& aEvent,
@ -83,8 +83,7 @@ class APZEventState final {
~APZEventState();
bool SendPendingTouchPreventedResponse(bool aPreventDefault);
MOZ_CAN_RUN_SCRIPT
bool FireContextmenuEvents(const nsCOMPtr<nsIPresShell>& aPresShell,
const CSSPoint& aPoint,
bool FireContextmenuEvents(PresShell* aPresShell, const CSSPoint& aPoint,
const CSSToLayoutDeviceScale& aScale,
Modifiers aModifiers,
const nsCOMPtr<nsIWidget>& aWidget);

View File

@ -96,7 +96,7 @@ void ChromeProcessController::Destroy() {
mAPZEventState = nullptr;
}
nsIPresShell* ChromeProcessController::GetPresShell() const {
PresShell* ChromeProcessController::GetPresShell() const {
if (!mWidget) {
return nullptr;
}
@ -107,7 +107,7 @@ nsIPresShell* ChromeProcessController::GetPresShell() const {
}
dom::Document* ChromeProcessController::GetRootDocument() const {
if (nsIPresShell* presShell = GetPresShell()) {
if (PresShell* presShell = GetPresShell()) {
return presShell->GetDocument();
}
return nullptr;
@ -178,7 +178,7 @@ void ChromeProcessController::HandleTap(
return;
}
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
RefPtr<PresShell> presShell = GetPresShell();
if (!presShell) {
return;
}

View File

@ -14,11 +14,11 @@
class nsIDOMWindowUtils;
class nsIPresShell;
class nsIWidget;
class MessageLoop;
namespace mozilla {
class PresShell;
namespace dom {
class Document;
}
@ -85,7 +85,7 @@ class ChromeProcessController : public mozilla::layers::GeckoContentController {
MessageLoop* mUILoop;
void InitializeRoot();
nsIPresShell* GetPresShell() const;
PresShell* GetPresShell() const;
dom::Document* GetRootDocument() const;
dom::Document* GetRootContentDocument(
const ScrollableLayerGuid::ViewID& aScrollId) const;