Bug 1401807 Part 3 - Use a local reflow status when reflowing nsVideoFrame's children. draft
authorTing-Yu Lin <tlin@mozilla.com>
Wed, 27 Sep 2017 23:27:25 +0800
changeset 671972 376ec6f7ccbabdca5b04e3aac0be08c1a1d1a933
parent 671971 9e32f13649b9b0c94a1294bf6ee98942bd05638c
child 733671 da44911b2a6cbc338f3b949c14788177c6e63fdc
push id82103
push userbmo:tlin@mozilla.com
push dateThu, 28 Sep 2017 15:03:24 +0000
bugs1401807
milestone58.0a1
Bug 1401807 Part 3 - Use a local reflow status when reflowing nsVideoFrame's children. This ensures the video frame's reflow status is not affect by its children's reflow result. MozReview-Commit-ID: 4WwLFyIyV4q
layout/generic/nsVideoFrame.cpp
--- a/layout/generic/nsVideoFrame.cpp
+++ b/layout/generic/nsVideoFrame.cpp
@@ -309,16 +309,17 @@ nsVideoFrame::Reflow(nsPresContext* aPre
 
   nsMargin borderPadding = aReflowInput.ComputedPhysicalBorderPadding();
 
   // Reflow the child frames. We may have up to three: an image
   // frame (for the poster image), a container frame for the controls,
   // and a container frame for the caption.
   for (nsIFrame* child : mFrames) {
     nsSize oldChildSize = child->GetSize();
+    nsReflowStatus childStatus;
 
     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;
@@ -336,18 +337,18 @@ nsVideoFrame::Reflow(nsPresContext* aPre
         posterRenderRect =
           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(),
+                  posterRenderRect.x, posterRenderRect.y, 0, childStatus);
+      MOZ_ASSERT(childStatus.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
@@ -372,18 +373,18 @@ nsVideoFrame::Reflow(nsPresContext* aPre
       availableSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
 
       ReflowInput kidReflowInput(aPresContext,
                                        aReflowInput,
                                        child,
                                        availableSize);
       ReflowOutput kidDesiredSize(kidReflowInput);
       ReflowChild(child, aPresContext, kidDesiredSize, kidReflowInput,
-                  borderPadding.left, borderPadding.top, 0, aStatus);
-      MOZ_ASSERT(aStatus.IsFullyComplete(),
+                  borderPadding.left, borderPadding.top, 0, childStatus);
+      MOZ_ASSERT(childStatus.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);
       }
@@ -417,16 +418,18 @@ nsVideoFrame::Reflow(nsPresContext* aPre
 
   aMetrics.SetOverflowAreasToDesiredBounds();
 
   FinishAndStoreOverflow(&aMetrics);
 
   NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
                  ("exit nsVideoFrame::Reflow: size=%d,%d",
                   aMetrics.Width(), aMetrics.Height()));
+
+  MOZ_ASSERT(aStatus.IsEmpty(), "This type of frame can't be split.");
   NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aMetrics);
 }
 
 class nsDisplayVideo : public nsDisplayItem {
 public:
   nsDisplayVideo(nsDisplayListBuilder* aBuilder, nsVideoFrame* aFrame)
     : nsDisplayItem(aBuilder, aFrame)
   {