Bug 1401807 Part 1 - Give unconstrained block size when reflowing mPosterImage. draft
authorTing-Yu Lin <tlin@mozilla.com>
Wed, 27 Sep 2017 23:04:42 +0800
changeset 671970 0444e5182f44c6c3af6f79e080f1b3dac413829f
parent 671801 76a26ef7c493311c170ae83eb0c1d6592a21396d
child 671971 9e32f13649b9b0c94a1294bf6ee98942bd05638c
push id82103
push userbmo:tlin@mozilla.com
push dateThu, 28 Sep 2017 15:03:24 +0000
bugs1401807
milestone58.0a1
Bug 1401807 Part 1 - Give unconstrained block size when reflowing mPosterImage. Also, added MOZ_ASSERT to ensure all the video frame's children are fully complete after reflowing (except for the mVideoControls special case on Android). This fixed aStatus.IsEmpty() assertion for the test case added in Part 2. MozReview-Commit-ID: HKze4EZoaJY
layout/generic/nsVideoFrame.cpp
--- a/layout/generic/nsVideoFrame.cpp
+++ b/layout/generic/nsVideoFrame.cpp
@@ -316,16 +316,18 @@ nsVideoFrame::Reflow(nsPresContext* aPre
     nsSize oldChildSize = child->GetSize();
 
     if (child->GetContent() == mPosterImage) {
       // Reflow the poster frame.
       nsImageFrame* imageFrame = static_cast<nsImageFrame*>(child);
       ReflowOutput kidDesiredSize(aReflowInput);
       WritingMode wm = imageFrame->GetWritingMode();
       LogicalSize availableSize = aReflowInput.AvailableSize(wm);
+      availableSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
+
       LogicalSize cbSize = aMetrics.Size(aMetrics.GetWritingMode()).
                              ConvertTo(wm, aMetrics.GetWritingMode());
       ReflowInput kidReflowInput(aPresContext,
                                        aReflowInput,
                                        imageFrame,
                                        availableSize,
                                        &cbSize);
 
@@ -335,16 +337,20 @@ nsVideoFrame::Reflow(nsPresContext* aPre
           nsRect(nsPoint(borderPadding.left, borderPadding.top),
                  nsSize(aReflowInput.ComputedWidth(),
                         aReflowInput.ComputedHeight()));
       }
       kidReflowInput.SetComputedWidth(posterRenderRect.width);
       kidReflowInput.SetComputedHeight(posterRenderRect.height);
       ReflowChild(imageFrame, aPresContext, kidDesiredSize, kidReflowInput,
                   posterRenderRect.x, posterRenderRect.y, 0, aStatus);
+      MOZ_ASSERT(aStatus.IsFullyComplete(),
+                 "We gave our child unconstrained available block-size, "
+                 "so it should be complete!");
+
       FinishReflowChild(imageFrame, aPresContext,
                         kidDesiredSize, &kidReflowInput,
                         posterRenderRect.x, posterRenderRect.y, 0);
 
 // Android still uses XUL media controls & hence needs this XUL-friendly
 // custom reflow code. This will go away in bug 1310907.
 #ifdef ANDROID
     } else if (child->GetContent() == mVideoControls) {
@@ -367,16 +373,19 @@ nsVideoFrame::Reflow(nsPresContext* aPre
 
       ReflowInput kidReflowInput(aPresContext,
                                        aReflowInput,
                                        child,
                                        availableSize);
       ReflowOutput kidDesiredSize(kidReflowInput);
       ReflowChild(child, aPresContext, kidDesiredSize, kidReflowInput,
                   borderPadding.left, borderPadding.top, 0, aStatus);
+      MOZ_ASSERT(aStatus.IsFullyComplete(),
+                 "We gave our child unconstrained available block-size, "
+                 "so it should be complete!");
 
       if (child->GetContent() == mVideoControls && isBSizeShrinkWrapping) {
         // Resolve our own BSize based on the controls' size in the same axis.
         contentBoxBSize = myWM.IsOrthogonalTo(wm) ?
           kidDesiredSize.ISize(wm) : kidDesiredSize.BSize(wm);
       }
 
       FinishReflowChild(child, aPresContext,