Bug 1252015 - Changed mImageContent reference to be Element type instead of nsIContent; r?baku draft
authorStephan Leroux <sleroux@mozilla.com>
Thu, 03 Mar 2016 12:55:54 -0500
changeset 337418 53eba828764eba474801d905d491dde087e447d5
parent 337411 be593a64d7c6a826260514fe758ef32a6ee580f7
child 515657 9c3a1dc86e497fe03a74086165a5768a8dbc0995
push id12352
push userbmo:sleroux@mozilla.com
push dateMon, 07 Mar 2016 17:08:51 +0000
reviewersbaku
bugs1252015
milestone48.0a1
Bug 1252015 - Changed mImageContent reference to be Element type instead of nsIContent; r?baku MozReview-Commit-ID: 9Mwhgg5ADmY
dom/html/ImageDocument.cpp
dom/html/ImageDocument.h
--- 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;