Bug 1252015 - Changed mImageContent reference to be Element type instead of nsIContent; r?baku
MozReview-Commit-ID: 9Mwhgg5ADmY
--- a/dom/html/ImageDocument.cpp
+++ b/dom/html/ImageDocument.cpp
@@ -353,17 +353,17 @@ ImageDocument::ShrinkToFit()
} else {
classList->Remove(NS_LITERAL_STRING("overflowingVertical"), ignored);
}
ignored.SuppressException();
return;
}
// Keep image content alive while changing the attributes.
- nsCOMPtr<nsIContent> imageContent = mImageContent;
+ nsCOMPtr<Element> imageContent = mImageContent;
nsCOMPtr<nsIDOMHTMLImageElement> image = do_QueryInterface(mImageContent);
image->SetWidth(std::max(1, NSToCoordFloor(GetRatio() * mImageWidth)));
image->SetHeight(std::max(1, NSToCoordFloor(GetRatio() * mImageHeight)));
// The view might have been scrolled when zooming in, scroll back to the
// origin now that we're showing a shrunk-to-window version.
ScrollImageTo(0, 0, false);
@@ -421,17 +421,17 @@ ImageDocument::ScrollImageTo(int32_t aX,
void
ImageDocument::RestoreImage()
{
if (!mImageContent) {
return;
}
// Keep image content alive while changing the attributes.
- nsCOMPtr<nsIContent> imageContent = mImageContent;
+ nsCOMPtr<Element> imageContent = mImageContent;
imageContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::width, true);
imageContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::height, true);
if (ImageIsOverflowing()) {
if (!mImageIsOverflowingVertically) {
SetModeClass(eOverflowingHorizontalOnly);
} else {
SetModeClass(eOverflowingVertical);
@@ -505,25 +505,25 @@ ImageDocument::Notify(imgIRequest* aRequ
void
ImageDocument::OnHasTransparency()
{
if (!mImageContent || nsContentUtils::IsChildOfSameType(this)) {
return;
}
- nsDOMTokenList* classList = mImageContent->AsElement()->ClassList();
+ nsDOMTokenList* classList = mImageContent->ClassList();
mozilla::ErrorResult rv;
classList->Add(NS_LITERAL_STRING("transparent"), rv);
}
void
ImageDocument::SetModeClass(eModeClasses mode)
{
- nsDOMTokenList* classList = mImageContent->AsElement()->ClassList();
+ nsDOMTokenList* classList = mImageContent->ClassList();
ErrorResult rv;
if (mode == eShrinkToFit) {
classList->Add(NS_LITERAL_STRING("shrinkToFit"), rv);
} else {
classList->Remove(NS_LITERAL_STRING("shrinkToFit"), rv);
}
@@ -618,22 +618,21 @@ ImageDocument::HandleEvent(nsIDOMEvent*
return NS_OK;
}
void
ImageDocument::UpdateSizeFromLayout()
{
// Pull an updated size from the content frame to account for any size
// change due to CSS properties like |image-orientation|.
- Element* contentElement = mImageContent->AsElement();
- if (!contentElement) {
+ if (!mImageContent) {
return;
}
- nsIFrame* contentFrame = contentElement->GetPrimaryFrame(Flush_Frames);
+ nsIFrame* contentFrame = mImageContent->GetPrimaryFrame(Flush_Frames);
if (!contentFrame) {
return;
}
nsIntSize oldSize(mImageWidth, mImageHeight);
IntrinsicSize newSize = contentFrame->GetIntrinsicSize();
if (newSize.width.GetUnit() == eStyleUnit_Coord) {
--- a/dom/html/ImageDocument.h
+++ b/dom/html/ImageDocument.h
@@ -105,17 +105,17 @@ protected:
eOverflowingHorizontalOnly
};
void SetModeClass(eModeClasses mode);
nsresult OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage);
nsresult OnLoadComplete(imgIRequest* aRequest, nsresult aStatus);
void OnHasTransparency();
- nsCOMPtr<nsIContent> mImageContent;
+ nsCOMPtr<Element> mImageContent;
float mVisibleWidth;
float mVisibleHeight;
int32_t mImageWidth;
int32_t mImageHeight;
bool mResizeImageByDefault;
bool mClickResizingEnabled;