Bug 215083: Fix CreateContinuingFrame to account for non-nsImageLoadingContent image frames. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 30 Jun 2018 03:18:49 +0200
changeset 424516 cd4d140d2826391e40660efce32438d01b181a1e
parent 424515 72416dd3422aca3e119b4ce0f80047f523aee5f7
child 424517 19766d4c54e3c0ef09caf3c9a7fd3f162e4d5ac6
child 424532 c3983769db6d28b2af6f4f7d1dee2f4ed4aa887a
push id34211
push userapavel@mozilla.com
push dateSat, 30 Jun 2018 09:49:56 +0000
treeherdermozilla-central@19766d4c54e3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs215083
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 215083: Fix CreateContinuingFrame to account for non-nsImageLoadingContent image frames. r=heycam MozReview-Commit-ID: CLx3siPe4Cx
layout/base/nsCSSFrameConstructor.cpp
layout/generic/nsImageFrame.cpp
layout/generic/nsImageFrame.h
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -8615,17 +8615,18 @@ nsCSSFrameConstructor::CreateContinuingF
     newFrame = cellFrame;
   } else if (LayoutFrameType::Line == frameType) {
     newFrame = NS_NewFirstLineFrame(shell, computedStyle);
     newFrame->Init(content, aParentFrame, aFrame);
   } else if (LayoutFrameType::Letter == frameType) {
     newFrame = NS_NewFirstLetterFrame(shell, computedStyle);
     newFrame->Init(content, aParentFrame, aFrame);
   } else if (LayoutFrameType::Image == frameType) {
-    newFrame = NS_NewImageFrame(shell, computedStyle);
+    auto* imageFrame = static_cast<nsImageFrame*>(aFrame);
+    newFrame = imageFrame->CreateContinuingFrame(shell, computedStyle);
     newFrame->Init(content, aParentFrame, aFrame);
   } else if (LayoutFrameType::ImageControl == frameType) {
     newFrame = NS_NewImageControlFrame(shell, computedStyle);
     newFrame->Init(content, aParentFrame, aFrame);
   } else if (LayoutFrameType::FieldSet == frameType) {
     nsContainerFrame* fieldset = NS_NewFieldSetFrame(shell, computedStyle);
 
     fieldset->Init(content, aParentFrame, aFrame);
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -136,16 +136,23 @@ NS_NewImageFrame(nsIPresShell* aPresShel
 nsIFrame*
 NS_NewImageFrameForContentProperty(nsIPresShell* aPresShell,
                                    ComputedStyle* aStyle)
 {
   return new (aPresShell) nsImageFrame(
     aStyle, nsImageFrame::Kind::NonGeneratedContentProperty);
 }
 
+nsImageFrame*
+nsImageFrame::CreateContinuingFrame(nsIPresShell* aPresShell,
+                                    ComputedStyle* aStyle) const
+{
+  return new (aPresShell) nsImageFrame(aStyle, mKind);
+}
+
 NS_IMPL_FRAMEARENA_HELPERS(nsImageFrame)
 
 nsImageFrame::nsImageFrame(ComputedStyle* aStyle, ClassID aID, Kind aKind)
   : nsAtomicContainerFrame(aStyle, aID)
   , mComputedSize(0, 0)
   , mIntrinsicRatio(0, 0)
   , mKind(aKind)
   , mDisplayingIcon(false)
@@ -276,20 +283,24 @@ SizeIsAvailable(imgIRequest* aRequest)
   }
 
   uint32_t imageStatus = 0;
   nsresult rv = aRequest->GetImageStatus(&imageStatus);
   return NS_SUCCEEDED(rv) && (imageStatus & imgIRequest::STATUS_SIZE_AVAILABLE);
 }
 
 void
-nsImageFrame::Init(nsIContent*       aContent,
+nsImageFrame::Init(nsIContent* aContent,
                    nsContainerFrame* aParent,
-                   nsIFrame*         aPrevInFlow)
+                   nsIFrame* aPrevInFlow)
 {
+  MOZ_ASSERT_IF(aPrevInFlow,
+                aPrevInFlow->Type() == LayoutFrameType::Image &&
+                static_cast<nsImageFrame*>(aPrevInFlow)->mKind == mKind);
+
   nsAtomicContainerFrame::Init(aContent, aParent, aPrevInFlow);
 
   mListener = new nsImageListener(this);
 
   if (!gIconLoad)
     LoadIcons(PresContext());
 
   if (mKind == Kind::ImageElement) {
--- a/layout/generic/nsImageFrame.h
+++ b/layout/generic/nsImageFrame.h
@@ -193,16 +193,19 @@ public:
   // Whether this frame is for a non-generated image element, that is, one that
   // isn't a ::before / ::after.
   bool IsForNonGeneratedImageElement() const
   {
     return mKind == Kind::ImageElement &&
       !HasAnyStateBits(NS_FRAME_GENERATED_CONTENT);
   }
 
+  // Creates a suitable continuing frame for this frame.
+  nsImageFrame* CreateContinuingFrame(nsIPresShell*, ComputedStyle*) const;
+
 private:
   friend nsIFrame* NS_NewImageFrame(nsIPresShell*, ComputedStyle*);
   friend nsIFrame* NS_NewImageFrameForContentProperty(nsIPresShell*, ComputedStyle*);
 
   nsImageFrame(ComputedStyle* aStyle, Kind aKind)
     : nsImageFrame(aStyle, kClassID, aKind)
   { }