Bug 1269046 part 10: Skip the normal margin-adding codepath for abspos frames that undergo CSS Box Alignment (which takes care of margins). r=mats
authorDaniel Holbert <dholbert@cs.stanford.edu>
Mon, 31 Oct 2016 08:59:40 -0700
changeset 347025 5c85b7c93c5e86011e180451c86bae49dcc49f4e
parent 347024 c8965356a17237420621f7089af5146275e5efff
child 347026 995211b23a553e1518e8c79570d27f5c4fd0bb86
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1269046
milestone52.0a1
Bug 1269046 part 10: Skip the normal margin-adding codepath for abspos frames that undergo CSS Box Alignment (which takes care of margins). r=mats MozReview-Commit-ID: Ha0o1rwFzE9
layout/generic/nsAbsoluteContainingBlock.cpp
--- a/layout/generic/nsAbsoluteContainingBlock.cpp
+++ b/layout/generic/nsAbsoluteContainingBlock.cpp
@@ -622,18 +622,29 @@ nsAbsoluteContainingBlock::ReflowAbsolut
                                    LogicalSize(wm, availISize,
                                                NS_UNCONSTRAINEDSIZE),
                                    &logicalCBSize, rsFlags);
 
   // Get the border values
   WritingMode outerWM = aReflowInput.GetWritingMode();
   const LogicalMargin border(outerWM,
                              aReflowInput.mStyleBorder->GetComputedBorder());
-  const LogicalMargin margin =
+  LogicalMargin margin =
     kidReflowInput.ComputedLogicalMargin().ConvertTo(outerWM, wm);
+
+  // If we're doing CSS Box Alignment in either axis, that will apply the
+  // margin for us in that axis (since the thing that's aligned is the margin
+  // box).  So, we clear out the margin here to avoid applying it twice.
+  if (kidReflowInput.mFlags.mIOffsetsNeedCSSAlign) {
+    margin.IStart(outerWM) = margin.IEnd(outerWM) = 0;
+  }
+  if (kidReflowInput.mFlags.mBOffsetsNeedCSSAlign) {
+    margin.BStart(outerWM) = margin.BEnd(outerWM) = 0;
+  }
+
   bool constrainBSize = (aReflowInput.AvailableBSize() != NS_UNCONSTRAINEDSIZE)
     && (aFlags & AbsPosReflowFlags::eConstrainHeight)
        // Don't split if told not to (e.g. for fixed frames)
     && (aDelegatingFrame->GetType() != nsGkAtoms::inlineFrame)
        //XXX we don't handle splitting frames for inline absolute containing blocks yet
     && (aKidFrame->GetLogicalRect(aContainingBlock.Size()).BStart(wm) <=
         aReflowInput.AvailableBSize());
        // Don't split things below the fold. (Ideally we shouldn't *have*