Bug 1131000. Implement nsMathMLSelectedFrame::ComputeSize to delegate size computation to the selected frame. r=mats
authorRobert O'Callahan <robert@ocallahan.org>
Thu, 05 Mar 2015 17:06:32 +1300
changeset 232385 16f240fd86de0d4a8ed8d8e146e109541ad4bc4b
parent 232384 3c86caa855ee1c526a8ed0ee0fd0f2340baee0f1
child 232386 3ec78ec97624dff4b1ed5d68e57baae9c0a9697f
child 232425 eeaf226575f2e08c01d8df1ef345dcfa3bc9540f
push id56533
push userrocallahan@mozilla.com
push dateSat, 07 Mar 2015 09:41:30 +0000
treeherdermozilla-inbound@16f240fd86de [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1131000
milestone39.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 1131000. Implement nsMathMLSelectedFrame::ComputeSize to delegate size computation to the selected frame. r=mats
layout/mathml/nsMathMLSelectedFrame.cpp
layout/mathml/nsMathMLSelectedFrame.h
layout/reftests/mathml/reftest.list
layout/reftests/mathml/semantics-4-ref.html
layout/reftests/mathml/semantics-4.html
--- a/layout/mathml/nsMathMLSelectedFrame.cpp
+++ b/layout/mathml/nsMathMLSelectedFrame.cpp
@@ -93,16 +93,48 @@ nsMathMLSelectedFrame::BuildDisplayList(
   }
 
 #if defined(DEBUG) && defined(SHOW_BOUNDING_BOX)
   // visual debug
   DisplayBoundingMetrics(aBuilder, this, mReference, mBoundingMetrics, aLists);
 #endif
 }
 
+/* virtual */
+LogicalSize
+nsMathMLSelectedFrame::ComputeSize(nsRenderingContext *aRenderingContext,
+                                   WritingMode aWM,
+                                   const LogicalSize& aCBSize,
+                                   nscoord aAvailableISize,
+                                   const LogicalSize& aMargin,
+                                   const LogicalSize& aBorder,
+                                   const LogicalSize& aPadding,
+                                   ComputeSizeFlags aFlags)
+{
+  nsIFrame* childFrame = GetSelectedFrame();
+  if (childFrame) {
+    // Delegate size computation to the child frame.
+    // Try to account for border/padding/margin on this frame and the child,
+    // though we don't really support them during reflow anyway...
+    nscoord availableISize = aAvailableISize - aBorder.ISize(aWM) -
+        aPadding.ISize(aWM) - aMargin.ISize(aWM);
+    LogicalSize cbSize = aCBSize - aBorder - aPadding - aMargin;
+    nsCSSOffsetState offsetState(childFrame, aRenderingContext, availableISize);
+    LogicalSize size =
+        childFrame->ComputeSize(aRenderingContext, aWM, cbSize,
+            availableISize, offsetState.ComputedLogicalMargin().Size(aWM),
+            offsetState.ComputedLogicalBorderPadding().Size(aWM) -
+            offsetState.ComputedLogicalPadding().Size(aWM),
+            offsetState.ComputedLogicalPadding().Size(aWM),
+            aFlags);
+    return size + offsetState.ComputedLogicalBorderPadding().Size(aWM);
+  }
+  return LogicalSize(aWM);
+}
+
 // Only reflow the selected child ...
 void
 nsMathMLSelectedFrame::Reflow(nsPresContext*          aPresContext,
                               nsHTMLReflowMetrics&     aDesiredSize,
                               const nsHTMLReflowState& aReflowState,
                               nsReflowStatus&          aStatus)
 {
   aStatus = NS_FRAME_COMPLETE;
--- a/layout/mathml/nsMathMLSelectedFrame.h
+++ b/layout/mathml/nsMathMLSelectedFrame.h
@@ -29,16 +29,26 @@ public:
                                 const nsRect&           aDirtyRect,
                                 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
 
   virtual nsresult
   Place(nsRenderingContext& aRenderingContext,
         bool                 aPlaceOrigin,
         nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE;
 
+  virtual mozilla::LogicalSize
+  ComputeSize(nsRenderingContext *aRenderingContext,
+              mozilla::WritingMode aWritingMode,
+              const mozilla::LogicalSize& aCBSize,
+              nscoord aAvailableISize,
+              const mozilla::LogicalSize& aMargin,
+              const mozilla::LogicalSize& aBorder,
+              const mozilla::LogicalSize& aPadding,
+              ComputeSizeFlags aFlags) MOZ_OVERRIDE;
+
   virtual void
   Reflow(nsPresContext*          aPresContext,
          nsHTMLReflowMetrics&     aDesiredSize,
          const nsHTMLReflowState& aReflowState,
          nsReflowStatus&          aStatus) MOZ_OVERRIDE;
 
   virtual nsQueryFrame::FrameIID GetFrameId() MOZ_OVERRIDE = 0;
 
--- a/layout/reftests/mathml/reftest.list
+++ b/layout/reftests/mathml/reftest.list
@@ -106,16 +106,17 @@ fails == stretchy-mover-2a.html stretchy
 == embellished-op-4-1.html embellished-op-4-1-ref.html
 == embellished-op-4-2.html embellished-op-4-2-ref.html
 == embellished-op-4-3.html embellished-op-4-3-ref.html
 == embellished-op-5-1.html embellished-op-5-ref.html
 == embellished-op-5-2.html embellished-op-5-ref.html
 random-if(winWidget&&!/^Windows\x20NT\x205\.1/.test(http.oscpu)) == semantics-1.xhtml semantics-1-ref.xhtml # Windows versions with Cambria Math
 == semantics-2.html semantics-2-ref.html
 == semantics-3.html semantics-3-ref.html
+== semantics-4.html semantics-4-ref.html
 != mathcolor-1.xml mathcolor-1-ref.xml
 != mathcolor-2.xml mathcolor-2-ref.xml
 != mathcolor-3.xml mathcolor-3-ref.xml
 == mathcolor-4.xml mathcolor-4-ref.xml
 != mathbackground-1.xml mathbackground-1-ref.xml
 != mathbackground-2.xml mathbackground-2-ref.xml
 != mathbackground-3.xml mathbackground-3-ref.xml
 == mathbackground-4.xml mathbackground-4-ref.xml
new file mode 100644
--- /dev/null
+++ b/layout/reftests/mathml/semantics-4-ref.html
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML>
+<math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
+  <mtable width="100%" mathbackground="red">
+   <mtr> <mtd><mi>x</mi></mtd> </mtr>
+  </mtable>
+</math>
+
+<math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
+  <mtable mathbackground="red">
+   <mtr> <mtd><mi>x</mi></mtd> </mtr>
+  </mtable>
+</math>
+
+<math display="inline" xmlns="http://www.w3.org/1998/Math/MathML">
+  <mtable width="100%" mathbackground="red">
+   <mtr> <mtd><mi>x</mi></mtd> </mtr>
+  </mtable>
+</math>
+
+<math display="inline" xmlns="http://www.w3.org/1998/Math/MathML">
+  <mtable mathbackground="red">
+   <mtr> <mtd><mi>x</mi></mtd> </mtr>
+  </mtable>
+</math>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/mathml/semantics-4.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML>
+<math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
+  <semantics>
+    <mtable width="100%" mathbackground="red">
+      <mtr> <mtd><mi>x</mi></mtd> </mtr>
+    </mtable>
+    <annotation encoding="application/x-tex">y</annotation>
+  </semantics>
+</math>
+
+<math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
+  <semantics>
+    <mtable mathbackground="red">
+      <mtr> <mtd><mi>x</mi></mtd> </mtr>
+    </mtable>
+    <annotation encoding="application/x-tex">y</annotation>
+  </semantics>
+</math>
+
+<math display="inline" xmlns="http://www.w3.org/1998/Math/MathML">
+  <semantics>
+    <mtable width="100%" mathbackground="red">
+      <mtr> <mtd><mi>x</mi></mtd> </mtr>
+    </mtable>
+    <annotation encoding="application/x-tex">y</annotation>
+  </semantics>
+</math>
+
+<math display="inline" xmlns="http://www.w3.org/1998/Math/MathML">
+  <semantics>
+    <mtable mathbackground="red">
+      <mtr> <mtd><mi>x</mi></mtd> </mtr>
+    </mtable>
+    <annotation encoding="application/x-tex">y</annotation>
+  </semantics>
+</math>