Bug 1441009: Don't null-check OwnerDoc. r=smaug

Can't return null.

MozReview-Commit-ID: JzcNwmsCxIu
This commit is contained in:
Emilio Cobos Álvarez 2018-02-25 16:44:51 +01:00
parent d6a3786a64
commit 0ad7abf15e
5 changed files with 12 additions and 12 deletions

View file

@ -1024,8 +1024,7 @@ nsIContent::GetEventTargetParent(EventChainPreVisitor& aVisitor)
}
if (!aVisitor.mEvent->mFlags.mComposedInNativeAnonymousContent &&
IsRootOfNativeAnonymousSubtree() && OwnerDoc() &&
OwnerDoc()->GetWindow()) {
IsRootOfNativeAnonymousSubtree() && OwnerDoc()->GetWindow()) {
aVisitor.SetParentTarget(OwnerDoc()->GetWindow()->GetParentTarget(), true);
} else if (parent) {
aVisitor.SetParentTarget(parent, false);

View file

@ -1861,7 +1861,7 @@ CanvasRenderingContext2D::RegisterAllocation()
static already_AddRefed<LayerManager>
LayerManagerFromCanvasElement(nsINode* aCanvasElement)
{
if (!aCanvasElement || !aCanvasElement->OwnerDoc()) {
if (!aCanvasElement) {
return nullptr;
}
@ -1926,7 +1926,7 @@ CanvasRenderingContext2D::TrySharedTarget(RefPtr<gfx::DrawTarget>& aOutDT,
aOutDT = nullptr;
aOutProvider = nullptr;
if (!mCanvasElement || !mCanvasElement->OwnerDoc()) {
if (!mCanvasElement) {
return false;
}
@ -4967,9 +4967,10 @@ CanvasRenderingContext2D::IsPointInPath(JSContext* aCx, double aX, double aY, co
// Check for site-specific permission and return false if no permission.
if (mCanvasElement) {
nsCOMPtr<nsIDocument> ownerDoc = mCanvasElement->OwnerDoc();
if (!ownerDoc || !CanvasUtils::IsImageExtractionAllowed(ownerDoc, aCx))
if (!CanvasUtils::IsImageExtractionAllowed(ownerDoc, aCx)) {
return false;
}
}
EnsureUserSpacePath(aWinding);
if (!mPath) {
@ -5009,9 +5010,10 @@ CanvasRenderingContext2D::IsPointInStroke(JSContext* aCx, double aX, double aY)
// Check for site-specific permission and return false if no permission.
if (mCanvasElement) {
nsCOMPtr<nsIDocument> ownerDoc = mCanvasElement->OwnerDoc();
if (!ownerDoc || !CanvasUtils::IsImageExtractionAllowed(ownerDoc, aCx))
if (!CanvasUtils::IsImageExtractionAllowed(ownerDoc, aCx)) {
return false;
}
}
EnsureUserSpacePath();
if (!mPath) {
@ -5878,8 +5880,7 @@ CanvasRenderingContext2D::GetImageDataArray(JSContext* aCx,
bool usePlaceholder = false;
if (mCanvasElement) {
nsCOMPtr<nsIDocument> ownerDoc = mCanvasElement->OwnerDoc();
usePlaceholder = !ownerDoc ||
!CanvasUtils::IsImageExtractionAllowed(ownerDoc, aCx);
usePlaceholder = !CanvasUtils::IsImageExtractionAllowed(ownerDoc, aCx);
}
do {

View file

@ -316,7 +316,7 @@ TabParent::SetOwnerElement(Element* aElement)
void
TabParent::AddWindowListeners()
{
if (mFrameElement && mFrameElement->OwnerDoc()) {
if (mFrameElement) {
if (nsCOMPtr<nsPIDOMWindowOuter> window = mFrameElement->OwnerDoc()->GetWindow()) {
nsCOMPtr<EventTarget> eventTarget = window->GetTopWindowRoot();
if (eventTarget) {

View file

@ -497,7 +497,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocument(nsIDocument* *aDocument)
// XXX sXBL/XBL2 issue: current doc or owner doc?
// But keep in mind bug 322414 comment 33
NS_IF_ADDREF(*aDocument = content->OwnerDoc());
NS_ADDREF(*aDocument = content->OwnerDoc());
return NS_OK;
}
@ -3292,7 +3292,7 @@ void nsPluginInstanceOwner::SetFrame(nsPluginFrame *aFrame)
}
// Register for widget-focus events on the window root.
if (content && content->OwnerDoc() && content->OwnerDoc()->GetWindow()) {
if (content && content->OwnerDoc()->GetWindow()) {
nsCOMPtr<EventTarget> windowRoot = content->OwnerDoc()->GetWindow()->GetTopWindowRoot();
if (windowRoot) {
windowRoot->AddEventListener(NS_LITERAL_STRING("activate"),

View file

@ -147,7 +147,7 @@ protected:
bool IsRoot() const {
NS_ASSERTION((IsInUncomposedDoc() && !GetParent()) ==
(OwnerDoc() && (OwnerDoc()->GetRootElement() == this)),
(OwnerDoc()->GetRootElement() == this),
"Can't determine if we're root");
return IsInUncomposedDoc() && !GetParent();
}