Skip to content

Commit

Permalink
#442: M1347639
Browse files Browse the repository at this point in the history
  • Loading branch information
classilla committed Dec 4, 2017
1 parent 71e9386 commit dfaeb3f
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 22 deletions.
3 changes: 3 additions & 0 deletions dom/base/nsGenConImageContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class nsGenConImageContent final : public nsXMLElement,
}
return nsXMLElement::PreHandleEvent(aVisitor);
}

protected:
nsIContent* AsContent() override { return this; }

private:
virtual ~nsGenConImageContent();
Expand Down
29 changes: 7 additions & 22 deletions dom/base/nsImageLoadingContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ nsImageLoadingContent::LoadImage(nsIURI* aNewURI,
// We use the principal of aDocument to avoid having to QI |this| an extra
// time. It should always be the same as the principal of this node.
#ifdef DEBUG
nsCOMPtr<nsIContent> thisContent = do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
nsIContent* thisContent = AsContent();
MOZ_ASSERT(thisContent &&
thisContent->NodePrincipal() == aDocument->NodePrincipal(),
"Principal mismatch?");
Expand Down Expand Up @@ -909,8 +909,7 @@ nsImageLoadingContent::LoadImage(nsIURI* aNewURI,

// Not blocked. Do the load.
RefPtr<imgRequestProxy>& req = PrepareNextRequest(aImageLoadType);
nsCOMPtr<nsIContent> content =
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
nsIContent* content = AsContent();
nsresult rv = nsContentUtils::LoadImage(aNewURI, aDocument,
aDocument->NodePrincipal(),
aDocument->GetDocumentURI(),
Expand Down Expand Up @@ -1048,10 +1047,7 @@ nsImageLoadingContent::UpdateImageState(bool aNotify)
return;
}

nsCOMPtr<nsIContent> thisContent = do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
if (!thisContent) {
return;
}
nsIContent* thisContent = AsContent();

mLoading = mBroken = mUserDisabled = mSuppressed = false;

Expand Down Expand Up @@ -1115,29 +1111,19 @@ nsImageLoadingContent::UseAsPrimaryRequest(imgRequestProxy* aRequest,
nsIDocument*
nsImageLoadingContent::GetOurOwnerDoc()
{
nsCOMPtr<nsIContent> thisContent =
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
NS_ENSURE_TRUE(thisContent, nullptr);

return thisContent->OwnerDoc();
return AsContent()->OwnerDoc();
}

nsIDocument*
nsImageLoadingContent::GetOurCurrentDoc()
{
nsCOMPtr<nsIContent> thisContent =
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
NS_ENSURE_TRUE(thisContent, nullptr);

return thisContent->GetComposedDoc();
return AsContent()->GetComposedDoc();
}

nsIFrame*
nsImageLoadingContent::GetOurPrimaryFrame()
{
nsCOMPtr<nsIContent> thisContent =
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
return thisContent->GetPrimaryFrame();
return AsContent()->GetPrimaryFrame();
}

nsPresContext* nsImageLoadingContent::GetFramePresContext()
Expand All @@ -1159,8 +1145,7 @@ nsImageLoadingContent::StringToURI(const nsAString& aSpec,
NS_PRECONDITION(aURI, "Null out param");

// (1) Get the base URI
nsCOMPtr<nsIContent> thisContent = do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
NS_ASSERTION(thisContent, "An image loading content must be an nsIContent");
nsIContent* thisContent = AsContent();
nsCOMPtr<nsIURI> baseURL = thisContent->GetBaseURI();

// (2) Get the charset
Expand Down
4 changes: 4 additions & 0 deletions dom/base/nsImageLoadingContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ class nsImageLoadingContent : public nsIImageLoadingContent,
// The nsContentPolicyType we would use for this ImageLoadType
static nsContentPolicyType PolicyTypeForLoad(ImageLoadType aImageLoadType);

// Get ourselves as an nsIContent*. Not const because some of the callers
// want a non-const nsIContent.
virtual nsIContent* AsContent() = 0;

private:
/**
* Struct used to manage the image observers.
Expand Down
3 changes: 3 additions & 0 deletions dom/html/HTMLImageElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ class HTMLImageElement final : public nsGenericHTMLElement,
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify) override;

// Override for nsImageLoadingContent.
nsIContent* AsContent() override { return this; }

// This is a weak reference that this element and the HTMLFormElement
// cooperate in maintaining.
HTMLFormElement* mForm;
Expand Down
5 changes: 5 additions & 0 deletions dom/html/HTMLInputElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,11 @@ class HTMLInputElement final : public nsGenericHTMLFormElementWithState,
*/
bool IsPopupBlocked() const;

/**
* Override for nsImageLoadingContent.
*/
nsIContent* AsContent() override { return this; }

nsCOMPtr<nsIControllers> mControllers;

/*
Expand Down
4 changes: 4 additions & 0 deletions dom/html/HTMLObjectElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ class HTMLObjectElement final : public nsGenericHTMLFormElement
return GetContentDocument();
}

protected:
// Override for nsImageLoadingContent.
nsIContent* AsContent() override { return this; }

private:
/**
* Calls LoadObject with the correct arguments to start the plugin load.
Expand Down
4 changes: 4 additions & 0 deletions dom/html/HTMLSharedObjectElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ class HTMLSharedObjectElement final : public nsGenericHTMLElement
return GetContentDocument();
}

protected:
// Override for nsImageLoadingContent.
nsIContent* AsContent() override { return this; }

private:
virtual ~HTMLSharedObjectElement();

Expand Down
3 changes: 3 additions & 0 deletions dom/svg/SVGFEImageElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class SVGFEImageElement final : public SVGFEImageElementBase,
virtual SVGAnimatedPreserveAspectRatio *GetPreserveAspectRatio() override;
virtual StringAttributesInfo GetStringInfo() override;

// Override for nsImageLoadingContent.
nsIContent* AsContent() override { return this; }

enum { RESULT, HREF };
nsSVGString mStringAttributes[2];
static StringInfo sStringInfo[2];
Expand Down
3 changes: 3 additions & 0 deletions dom/svg/SVGImageElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ class SVGImageElement : public SVGImageElementBase,
virtual SVGAnimatedPreserveAspectRatio *GetPreserveAspectRatio() override;
virtual StringAttributesInfo GetStringInfo() override;

// Override for nsImageLoadingContent.
nsIContent* AsContent() override { return this; }

enum { ATTR_X, ATTR_Y, ATTR_WIDTH, ATTR_HEIGHT };
nsSVGLength2 mLengthAttributes[4];
static LengthInfo sLengthInfo[4];
Expand Down

0 comments on commit dfaeb3f

Please sign in to comment.