Bug 1583203 - Annotate nsINode::OwnerDoc() as MOZ_NONNULL_RETURN. r=smaug

People keep adding useless null-checks and it was not clear what the consensus
was from bug 1441165, but this should be unobjectionable I guess.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-09-23 18:12:19 +00:00
parent 58e3682952
commit 678c18063d
6 changed files with 10 additions and 11 deletions

View File

@ -1305,10 +1305,8 @@ void ChromeTooltipListener::sTooltipCallback(nsITimer* aTimer,
self->mMouseScreenY - screenDot.y / scaleFactor,
tooltipText, directionText);
self->mLastShownTooltipText = std::move(tooltipText);
if (self->mPossibleTooltipNode->OwnerDoc()) {
self->mLastDocshell = do_GetWeakReference(
self->mPossibleTooltipNode->OwnerDoc()->GetDocShell());
}
self->mLastDocshell = do_GetWeakReference(
self->mPossibleTooltipNode->OwnerDoc()->GetDocShell());
}
}

View File

@ -597,13 +597,15 @@ class nsINode : public mozilla::dom::EventTarget {
*
* For all other cases OwnerDoc and GetOwnerDocument behave identically.
*/
Document* OwnerDoc() const { return mNodeInfo->GetDocument(); }
Document* OwnerDoc() const MOZ_NONNULL_RETURN {
return mNodeInfo->GetDocument();
}
/**
* Return the "owner document" of this node as an nsINode*. Implemented
* in Document.h.
*/
inline nsINode* OwnerDocAsNode() const;
inline nsINode* OwnerDocAsNode() const MOZ_NONNULL_RETURN;
/**
* Returns true if the content has an ancestor that is a document.

View File

@ -2175,7 +2175,7 @@ void HTMLMediaElement::Load() {
HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay),
AutoplayPolicy::IsAllowedToPlay(*this), OwnerDoc(),
DocumentOrigin(OwnerDoc()).get(),
OwnerDoc() ? OwnerDoc()->HasBeenUserGestureActivated() : 0, mMuted,
OwnerDoc()->HasBeenUserGestureActivated(), mMuted,
mVolume));
if (mIsRunningLoadMethod) {

View File

@ -3163,7 +3163,7 @@ void nsPluginInstanceOwner::SetFrame(nsPluginFrame* aFrame) {
// If we already have a frame that is changing or going away...
if (mPluginFrame) {
if (content && content->OwnerDoc() && content->OwnerDoc()->GetWindow()) {
if (content && content->OwnerDoc()->GetWindow()) {
nsCOMPtr<EventTarget> windowRoot =
content->OwnerDoc()->GetWindow()->GetTopWindowRoot();
if (windowRoot) {

View File

@ -455,7 +455,7 @@ nsresult nsXBLService::LoadBindings(Element* aElement, nsIURI* aURL,
// in AllowXULXBL() documents in content process in production without
// knowing.
if (XRE_IsContentProcess() &&
IsSystemOrChromeURLPrincipal(aOriginPrincipal) && aElement->OwnerDoc() &&
IsSystemOrChromeURLPrincipal(aOriginPrincipal) &&
!aElement->OwnerDoc()->AllowXULXBL()) {
MOZ_ASSERT(false, "Unexpected XBL binding used in the content process");
}

View File

@ -77,8 +77,7 @@ void ElementPropertyTransition::UpdateStartValueFromReplacedTransition() {
CSSPropFlags::CanAnimateOnCompositor),
"The transition property should be able to be run on the "
"compositor");
MOZ_ASSERT(mTarget && mTarget->mElement->OwnerDoc(),
"We should have a valid document at this moment");
MOZ_ASSERT(mTarget, "We should have a valid target at this moment");
dom::DocumentTimeline* timeline = mTarget->mElement->OwnerDoc()->Timeline();
ComputedTiming computedTiming = GetComputedTimingAt(