Bug 1709491 Part 2 - Simplify Subgrid::mMarginBorderPadding computation. r=dholbert
authorTing-Yu Lin <tlin@mozilla.com>
Wed, 12 May 2021 06:32:40 +0000
changeset 579463 d90d530ebb5d4fd2a494f0a7a79ecbfdbf1cedce
parent 579462 4c5d0ee7fbe47b41d3dcbd667b2b69262da505e7
child 579464 02aeefba2bce0e142979ec9f8aa8c37b55778306
push id143005
push useraethanyc@gmail.com
push dateWed, 12 May 2021 06:35:13 +0000
treeherderautoland@02aeefba2bce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1709491
milestone90.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 1709491 Part 2 - Simplify Subgrid::mMarginBorderPadding computation. r=dholbert SizeComputationInput's logical margin and border&padding getters accept arbitrary writing mode, so we can operate on `cbWM` directly without using physical coordinates. This patch is a preparation of the next part, and it shouldn't change the behavior. Differential Revision: https://phabricator.services.mozilla.com/D114545
layout/generic/nsGridContainerFrame.cpp
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -3415,28 +3415,24 @@ struct MOZ_STACK_CLASS nsGridContainerFr
  * Compute margin+border+padding for aGridItem.mFrame (a subgrid) and store it
  * on its Subgrid property (and return that property).
  * aPercentageBasis is in the grid item's writing-mode.
  */
 static Subgrid* SubgridComputeMarginBorderPadding(
     const GridItemInfo& aGridItem, const LogicalSize& aPercentageBasis) {
   auto* subgridFrame = aGridItem.SubgridFrame();
   auto cbWM = aGridItem.mFrame->GetParent()->GetWritingMode();
-  nsMargin physicalMBP;
-  {
-    auto wm = subgridFrame->GetWritingMode();
-    auto pmPercentageBasis = cbWM.IsOrthogonalTo(wm)
-                                 ? aPercentageBasis.BSize(wm)
-                                 : aPercentageBasis.ISize(wm);
-    SizeComputationInput sz(subgridFrame, nullptr, cbWM, pmPercentageBasis);
-    physicalMBP =
-        sz.ComputedPhysicalMargin() + sz.ComputedPhysicalBorderPadding();
-  }
   auto* subgrid = subgridFrame->GetProperty(Subgrid::Prop());
-  subgrid->mMarginBorderPadding = LogicalMargin(cbWM, physicalMBP);
+  auto wm = subgridFrame->GetWritingMode();
+  auto pmPercentageBasis = cbWM.IsOrthogonalTo(wm) ? aPercentageBasis.BSize(wm)
+                                                   : aPercentageBasis.ISize(wm);
+  SizeComputationInput sz(subgridFrame, nullptr, cbWM, pmPercentageBasis);
+  subgrid->mMarginBorderPadding =
+      sz.ComputedLogicalMargin(cbWM) + sz.ComputedLogicalBorderPadding(cbWM);
+
   if (aGridItem.mFrame != subgridFrame) {
     nsIScrollableFrame* scrollFrame = aGridItem.mFrame->GetScrollTargetFrame();
     if (scrollFrame) {
       nsMargin ssz = scrollFrame->GetActualScrollbarSizes();
       subgrid->mMarginBorderPadding += LogicalMargin(cbWM, ssz);
     }
 
     if (aGridItem.mFrame->IsFieldSetFrame()) {