Bug 1539884 - Part 37: Add strong references for arguments in callers r=masayuki

Differential Revision: https://phabricator.services.mozilla.com/D134475
This commit is contained in:
Kagami Sascha Rosylight 2021-12-23 16:27:26 +00:00
Родитель 496a0d78cc
Коммит c5662e876e
9 изменённых файлов: 29 добавлений и 24 удалений

Просмотреть файл

@ -811,8 +811,10 @@ bool nsCopySupport::FireClipboardEvent(EventMessage aEventMessage,
nsEventStatus status = nsEventStatus_eIgnore;
InternalClipboardEvent evt(true, originalEventMessage);
evt.mClipboardData = clipboardData;
EventDispatcher::Dispatch(targetElement, presShell->GetPresContext(), &evt,
nullptr, &status);
RefPtr<nsPresContext> presContext = presShell->GetPresContext();
EventDispatcher::Dispatch(targetElement, presContext, &evt, nullptr,
&status);
// If the event was cancelled, don't do the clipboard operation
doDefault = (status != nsEventStatus_eConsumeNoDefault);
}

Просмотреть файл

@ -2721,8 +2721,8 @@ class FocusBlurEvent : public Runnable {
return EventDispatcher::Dispatch(mTarget, mContext, &event);
}
nsCOMPtr<nsISupports> mTarget;
RefPtr<nsPresContext> mContext;
const nsCOMPtr<nsISupports> mTarget;
const RefPtr<nsPresContext> mContext;
EventMessage mEventMessage;
bool mWindowRaised;
bool mIsRefocus;
@ -2762,8 +2762,8 @@ class FocusInOutEvent : public Runnable {
return NS_OK;
}
nsCOMPtr<nsISupports> mTarget;
RefPtr<nsPresContext> mContext;
const nsCOMPtr<nsISupports> mTarget;
const RefPtr<nsPresContext> mContext;
EventMessage mEventMessage;
nsCOMPtr<nsPIDOMWindowOuter> mOriginalFocusedWindow;
nsCOMPtr<nsIContent> mOriginalFocusedContent;

Просмотреть файл

@ -1809,7 +1809,9 @@ void EventStateManager::FireContextClick() {
AutoHandlingUserInputStatePusher userInpStatePusher(true, &event);
// dispatch to DOM
EventDispatcher::Dispatch(mGestureDownContent, mPresContext, &event,
RefPtr<nsIContent> gestureDownContent = mGestureDownContent;
RefPtr<nsPresContext> presContext = mPresContext;
EventDispatcher::Dispatch(gestureDownContent, presContext, &event,
nullptr, &status);
// We don't need to dispatch to frame handling because no frames

Просмотреть файл

@ -1167,7 +1167,7 @@ class EventStateManager : public nsSupportsWeakReference, public nsIObserver {
// member variables for the d&d gesture state machine
LayoutDeviceIntPoint mGestureDownPoint; // screen coordinates
// The content to use as target if we start a d&d (what we drag).
nsCOMPtr<nsIContent> mGestureDownContent;
RefPtr<nsIContent> mGestureDownContent;
// The content of the frame where the mouse-down event occurred. It's the same
// as the target in most cases but not always - for example when dragging
// an <area> of an image map this is the image. (bug 289667)

Просмотреть файл

@ -151,8 +151,10 @@ void TextComposition::DispatchEvent(
if (aDispatchEvent->mMessage == eCompositionChange) {
aDispatchEvent->mFlags.mOnlySystemGroupDispatchInContent = true;
}
EventDispatcher::Dispatch(mNode, mPresContext, aDispatchEvent, nullptr,
aStatus, aCallBack);
RefPtr<nsINode> node = mNode;
RefPtr<nsPresContext> presContext = mPresContext;
EventDispatcher::Dispatch(node, presContext, aDispatchEvent, nullptr, aStatus,
aCallBack);
OnCompositionEventDispatched(aDispatchEvent);
}

Просмотреть файл

@ -289,7 +289,7 @@ class TextComposition final {
// IMEStateManager::OnDestroyPresContext(), and then, it destroy
// this instance.
nsPresContext* mPresContext;
nsCOMPtr<nsINode> mNode;
RefPtr<nsINode> mNode;
RefPtr<BrowserParent> mBrowserParent;
// The text node which includes the composition string.

Просмотреть файл

@ -2156,7 +2156,7 @@ void PresShell::FireResizeEvent() {
WidgetEvent event(true, mozilla::eResize);
nsEventStatus status = nsEventStatus_eIgnore;
if (nsPIDOMWindowOuter* window = mDocument->GetWindow()) {
if (RefPtr<nsPIDOMWindowOuter> window = mDocument->GetWindow()) {
EventDispatcher::Dispatch(window, mPresContext, &event, nullptr, &status);
}
}
@ -5397,8 +5397,7 @@ PresShell::CanvasBackground PresShell::ComputeCanvasBackground() const {
}
if (mPresContext->IsRootContentDocumentCrossProcess() &&
!IsTransparentContainerElement(mPresContext)) {
color = NS_ComposeColors(
GetDefaultBackgroundColorToDraw(), color);
color = NS_ComposeColors(GetDefaultBackgroundColorToDraw(), color);
}
return {color, drawBackgroundColor};
}
@ -8772,8 +8771,8 @@ void PresShell::EventHandler::DispatchTouchEventToDOM(
}
}
nsPresContext* context = doc->GetPresContext();
if (!context) {
RefPtr<nsPresContext> presContext = doc->GetPresContext();
if (!presContext) {
if (contentPresShell) {
contentPresShell->PopCurrentEventInfo();
}
@ -8781,7 +8780,7 @@ void PresShell::EventHandler::DispatchTouchEventToDOM(
}
tmpStatus = nsEventStatus_eIgnore;
EventDispatcher::Dispatch(targetPtr, context, &newEvent, nullptr,
EventDispatcher::Dispatch(targetPtr, presContext, &newEvent, nullptr,
&tmpStatus, aEventCB);
if (nsEventStatus_eConsumeNoDefault == tmpStatus ||
newEvent.mFlags.mMultipleActionsPrevented) {

Просмотреть файл

@ -2823,8 +2823,8 @@ class PresShell final : public nsStubDocumentObserver,
// mDocument and mPresContext should've never been cleared nor swapped with
// another instance while PresShell instance is alive so that it's safe to
// call their can-run- script methods without local RefPtr variables.
RefPtr<Document> const mDocument;
RefPtr<nsPresContext> const mPresContext;
MOZ_KNOWN_LIVE RefPtr<Document> const mDocument;
MOZ_KNOWN_LIVE RefPtr<nsPresContext> const mPresContext;
// The document's style set owns it but we maintain a ref, may be null.
RefPtr<StyleSheet> mPrefStyleSheet;
UniquePtr<nsCSSFrameConstructor> mFrameConstructor;

Просмотреть файл

@ -977,7 +977,7 @@ nsDocumentViewer::LoadComplete(nsresult aStatus) {
// onload to the document content since that would likely confuse scripts
// on the page.
nsIDocShell* docShell = window->GetDocShell();
RefPtr<nsDocShell> docShell = nsDocShell::Cast(window->GetDocShell());
NS_ENSURE_TRUE(docShell, NS_ERROR_UNEXPECTED);
// Unfortunately, docShell->GetRestoringDocument() might no longer be set
@ -1082,12 +1082,12 @@ nsDocumentViewer::LoadComplete(nsresult aStatus) {
}
d->SetLoadEventFiring(true);
EventDispatcher::Dispatch(window, mPresContext, &event, nullptr, &status);
RefPtr<nsPresContext> presContext = mPresContext;
EventDispatcher::Dispatch(window, presContext, &event, nullptr, &status);
d->SetLoadEventFiring(false);
RefPtr<nsDocShell> dShell = nsDocShell::Cast(docShell);
if (docGroup && dShell->TreatAsBackgroundLoad()) {
docGroup->TryFlushIframePostMessages(dShell->GetOuterWindowID());
if (docGroup && docShell->TreatAsBackgroundLoad()) {
docGroup->TryFlushIframePostMessages(docShell->GetOuterWindowID());
}
if (timing) {