Bug 1243614 - Implement UpdateOverflow for nsMathMLContainerFrame. r=roc
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 04 May 2016 12:26:42 +1200
changeset 363176 1b39ee989734c20b48beeb119b29dfd39cf98551
parent 363175 84ce9439f0c6f8982d180b052dba25edb31a5f38
child 363177 35b6bedcbb2ec68e387a87d14e8f5c7b98d2743e
push id17124
push usercykesiopka.bmo@gmail.com
push dateWed, 04 May 2016 04:32:33 +0000
reviewersroc
bugs1243614
milestone49.0a1
Bug 1243614 - Implement UpdateOverflow for nsMathMLContainerFrame. r=roc
layout/mathml/nsMathMLContainerFrame.cpp
layout/mathml/nsMathMLContainerFrame.h
--- a/layout/mathml/nsMathMLContainerFrame.cpp
+++ b/layout/mathml/nsMathMLContainerFrame.cpp
@@ -777,55 +777,63 @@ nsMathMLContainerFrame::AttributeChanged
   // XXXldb This should only do work for attributes that cause changes!
   PresContext()->PresShell()->
     FrameNeedsReflow(this, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
 
   return NS_OK;
 }
 
 void
-nsMathMLContainerFrame::GatherAndStoreOverflow(nsHTMLReflowMetrics* aMetrics)
+nsMathMLContainerFrame::ComputeOverflow(nsOverflowAreas& aOverflowAreas)
 {
-  // nsIFrame::FinishAndStoreOverflow likes the overflow area to include the
-  // frame rectangle.
-  aMetrics->SetOverflowAreasToDesiredBounds();
-
   // All non-child-frame content such as nsMathMLChars (and most child-frame
   // content) is included in mBoundingMetrics.
   nsRect boundingBox(mBoundingMetrics.leftBearing,
-                     aMetrics->BlockStartAscent() - mBoundingMetrics.ascent,
+                     mBlockStartAscent - mBoundingMetrics.ascent,
                      mBoundingMetrics.rightBearing - mBoundingMetrics.leftBearing,
                      mBoundingMetrics.ascent + mBoundingMetrics.descent);
 
   // REVIEW: Maybe this should contribute only to visual overflow
   // and not scrollable?
-  aMetrics->mOverflowAreas.UnionAllWith(boundingBox);
+  aOverflowAreas.UnionAllWith(boundingBox);
 
   // mBoundingMetrics does not necessarily include content of <mpadded>
   // elements whose mBoundingMetrics may not be representative of the true
   // bounds, and doesn't include the CSS2 outline rectangles of children, so
   // make such to include child overflow areas.
   nsIFrame* childFrame = mFrames.FirstChild();
   while (childFrame) {
-    ConsiderChildOverflow(aMetrics->mOverflowAreas, childFrame);
+    ConsiderChildOverflow(aOverflowAreas, childFrame);
     childFrame = childFrame->GetNextSibling();
   }
+}
+
+void
+nsMathMLContainerFrame::GatherAndStoreOverflow(nsHTMLReflowMetrics* aMetrics)
+{
+  mBlockStartAscent = aMetrics->BlockStartAscent();
+
+  // nsIFrame::FinishAndStoreOverflow likes the overflow area to include the
+  // frame rectangle.
+  aMetrics->SetOverflowAreasToDesiredBounds();
+
+  ComputeOverflow(aMetrics->mOverflowAreas);
 
   FinishAndStoreOverflow(aMetrics);
 }
 
 bool
 nsMathMLContainerFrame::UpdateOverflow()
 {
-  // Our overflow areas may have changed, so reflow the frame.
-  PresContext()->PresShell()->FrameNeedsReflow(
-    this, nsIPresShell::eResize, NS_FRAME_IS_DIRTY);
+  nsRect bounds(nsPoint(0, 0), GetSize());
+  nsOverflowAreas overflowAreas(bounds, bounds);
 
-  // As we're reflowing, there's no need to propagate this change.
-  return false;
+  ComputeOverflow(overflowAreas);
+
+  return FinishAndStoreOverflow(overflowAreas, GetSize());
 }
 
 void
 nsMathMLContainerFrame::ReflowChild(nsIFrame*                aChildFrame,
                                     nsPresContext*           aPresContext,
                                     nsHTMLReflowMetrics&     aDesiredSize,
                                     const nsHTMLReflowState& aReflowState,
                                     nsReflowStatus&          aStatus)
--- a/layout/mathml/nsMathMLContainerFrame.h
+++ b/layout/mathml/nsMathMLContainerFrame.h
@@ -29,16 +29,17 @@
 
 class nsMathMLContainerFrame : public nsContainerFrame,
                                public nsMathMLFrame {
   friend class nsMathMLmfencedFrame;
 public:
   explicit nsMathMLContainerFrame(nsStyleContext* aContext)
     : nsContainerFrame(aContext)
     , mIntrinsicWidth(NS_INTRINSIC_WIDTH_UNKNOWN)
+    , mBlockStartAscent(0)
   {}
 
   NS_DECL_QUERYFRAME_TARGET(nsMathMLContainerFrame)
   NS_DECL_QUERYFRAME
   NS_DECL_ABSTRACT_FRAME(nsMathMLContainerFrame)
 
   // --------------------------------------------------------------------------
   // Overloaded nsMathMLFrame methods -- see documentation in nsIMathMLFrame.h
@@ -374,31 +375,35 @@ protected:
   void
   PositionRowChildFrames(nscoord aOffsetX, nscoord aBaseline);
 
   // A variant on FinishAndStoreOverflow() that uses the union of child
   // overflows, the frame bounds, and mBoundingMetrics to set and store the
   // overflow.
   void GatherAndStoreOverflow(nsHTMLReflowMetrics* aMetrics);
 
+  void ComputeOverflow(nsOverflowAreas& aOverflowAreas);
+
   /**
    * Call DidReflow() if the NS_FRAME_IN_REFLOW frame bit is set on aFirst and
    * all its next siblings up to, but not including, aStop.
    * aStop == nullptr meaning all next siblings with the bit set.
    * The method does nothing if aFirst == nullptr.
    */
   static void DidReflowChildren(nsIFrame* aFirst, nsIFrame* aStop = nullptr);
 
   /**
    * Recompute mIntrinsicWidth if it's not already up to date.
    */
   void UpdateIntrinsicWidth(nsRenderingContext* aRenderingContext);
 
   nscoord mIntrinsicWidth;
 
+  nscoord mBlockStartAscent;
+
 private:
   class RowChildFrameIterator;
   friend class RowChildFrameIterator;
 };
 
 
 // --------------------------------------------------------------------------
 // Currently, to benefit from line-breaking inside the <math> element, <math> is