Bug 1506687 Part 2: Make FlexItemValues also provide the item's position and size. r=dholbert
☠☠ backed out by 9bff4fddd787 ☠ ☠
authorBrad Werth <bwerth@mozilla.com>
Thu, 15 Nov 2018 16:20:40 +0000
changeset 503068 1c3baa04d4ce66c9a8b3428b3d475c73bc07f76b
parent 503067 c50af93cfc84373d529aefc2a3ccd423e48b0d1f
child 503069 2788a93e179aff117492e29f911c4449cd101a40
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1506687
milestone65.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 1506687 Part 2: Make FlexItemValues also provide the item's position and size. r=dholbert Depends on D11782 Differential Revision: https://phabricator.services.mozilla.com/D11783
dom/chrome-webidl/Flex.webidl
dom/flex/FlexItemValues.cpp
dom/flex/FlexItemValues.h
layout/generic/nsFlexContainerFrame.cpp
layout/generic/nsFlexContainerFrame.h
--- a/dom/chrome-webidl/Flex.webidl
+++ b/dom/chrome-webidl/Flex.webidl
@@ -78,16 +78,20 @@ interface FlexLineValues
 enum FlexItemClampState {
   "unclamped", "clamped_to_min", "clamped_to_max"
 };
 
 [ChromeOnly]
 interface FlexItemValues
 {
   readonly attribute Node? node;
+  readonly attribute double mainPosition;
+  readonly attribute double mainSize;
   readonly attribute double mainBaseSize;
   readonly attribute double mainDeltaSize;
   readonly attribute double mainMinSize;
   readonly attribute double mainMaxSize;
+  readonly attribute double crossPosition;
+  readonly attribute double crossSize;
   readonly attribute double crossMinSize;
   readonly attribute double crossMaxSize;
   readonly attribute FlexItemClampState clampState;
 };
--- a/dom/flex/FlexItemValues.cpp
+++ b/dom/flex/FlexItemValues.cpp
@@ -45,23 +45,31 @@ FlexItemValues::FlexItemValues(FlexLineV
   MOZ_ASSERT(aItem,
     "Should never be instantiated with a null ComputedFlexLineInfo.");
 
   // Eagerly copy values from aItem, because we're not
   // going to keep it around.
   mNode = aItem->mNode;
 
   // Convert app unit sizes to css pixel sizes.
+  mMainPosition = nsPresContext::AppUnitsToDoubleCSSPixels(
+    aItem->mMainPosition);
+  mMainSize = nsPresContext::AppUnitsToDoubleCSSPixels(
+    aItem->mMainSize);
   mMainBaseSize = nsPresContext::AppUnitsToDoubleCSSPixels(
     aItem->mMainBaseSize);
   mMainDeltaSize = nsPresContext::AppUnitsToDoubleCSSPixels(
     aItem->mMainDeltaSize);
   mMainMinSize = nsPresContext::AppUnitsToDoubleCSSPixels(
     aItem->mMainMinSize);
   mMainMaxSize = ToPossiblyUnconstrainedPixels(aItem->mMainMaxSize);
+  mCrossPosition = nsPresContext::AppUnitsToDoubleCSSPixels(
+    aItem->mCrossPosition);
+  mCrossSize = nsPresContext::AppUnitsToDoubleCSSPixels(
+    aItem->mCrossSize);
   mCrossMinSize = nsPresContext::AppUnitsToDoubleCSSPixels(
     aItem->mCrossMinSize);
   mCrossMaxSize = ToPossiblyUnconstrainedPixels(aItem->mCrossMaxSize);
 
   mClampState = aItem->mClampState;
 }
 
 JSObject*
@@ -72,16 +80,28 @@ FlexItemValues::WrapObject(JSContext* aC
 
 nsINode*
 FlexItemValues::GetNode() const
 {
   return mNode;
 }
 
 double
+FlexItemValues::MainPosition() const
+{
+  return mMainPosition;
+}
+
+double
+FlexItemValues::MainSize() const
+{
+  return mMainSize;
+}
+
+double
 FlexItemValues::MainBaseSize() const
 {
   return mMainBaseSize;
 }
 
 double
 FlexItemValues::MainDeltaSize() const
 {
@@ -96,16 +116,28 @@ FlexItemValues::MainMinSize() const
 
 double
 FlexItemValues::MainMaxSize() const
 {
   return mMainMaxSize;
 }
 
 double
+FlexItemValues::CrossPosition() const
+{
+  return mCrossPosition;
+}
+
+double
+FlexItemValues::CrossSize() const
+{
+  return mCrossSize;
+}
+
+double
 FlexItemValues::CrossMinSize() const
 {
   return mCrossMinSize;
 }
 
 double
 FlexItemValues::CrossMaxSize() const
 {
--- a/dom/flex/FlexItemValues.h
+++ b/dom/flex/FlexItemValues.h
@@ -34,33 +34,41 @@ public:
 
   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
   FlexLineValues* GetParentObject()
   {
     return mParent;
   }
 
   nsINode* GetNode() const;
+  double MainPosition() const;
+  double MainSize() const;
   double MainBaseSize() const;
   double MainDeltaSize() const;
   double MainMinSize() const;
   double MainMaxSize() const;
+  double CrossPosition() const;
+  double CrossSize() const;
   double CrossMinSize() const;
   double CrossMaxSize() const;
   FlexItemClampState ClampState() const;
 
 protected:
   RefPtr<FlexLineValues> mParent;
   RefPtr<nsINode> mNode;
 
-  // These sizes are all CSS pixel units.
+  // These measurements are all CSS pixel units.
+  double mMainPosition;
+  double mMainSize;
   double mMainBaseSize;
   double mMainDeltaSize;
   double mMainMinSize;
   double mMainMaxSize;
+  double mCrossPosition;
+  double mCrossSize;
   double mCrossMinSize;
   double mCrossMaxSize;
   FlexItemClampState mClampState;
 };
 
 } // namespace dom
 } // namespace mozilla
 
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -4793,24 +4793,19 @@ nsFlexContainerFrame::DoFlexLayout(nsPre
         nsAtom* pseudoTag = frame->Style()->GetPseudo();
         if (pseudoTag != nsCSSAnonBoxes::anonymousFlexItem()) {
           node = frame->GetContent();
         }
 
         ComputedFlexItemInfo* itemInfo = lineInfo->mItems.AppendElement();
         itemInfo->mNode = node;
 
-        // mMainBaseSize and itemInfo->mMainDeltaSize will
-        // be filled out in ResolveFlexibleLengths().
-
-        // Other FlexItem properties can be captured now.
-        itemInfo->mMainMinSize = item->GetMainMinSize();
-        itemInfo->mMainMaxSize = item->GetMainMaxSize();
-        itemInfo->mCrossMinSize = item->GetCrossMinSize();
-        itemInfo->mCrossMaxSize = item->GetCrossMaxSize();
+        // itemInfo->mMainBaseSize and mMainDeltaSize will be filled out
+        // in ResolveFlexibleLengths(). Other measurements will be captured
+        // at the end of this function.
       }
     }
   }
 
   aContentBoxMainSize =
     ResolveFlexContainerMainSize(aReflowInput, aAxisTracker,
                                  aContentBoxMainSize, aAvailableBSizeForContent,
                                  lines.getFirst(), aStatus);
@@ -5205,26 +5200,40 @@ nsFlexContainerFrame::DoFlexLayout(nsPre
     ConsiderChildOverflow(aDesiredSize.mOverflowAreas, childFrame);
   }
 
   FinishReflowWithAbsoluteFrames(aPresContext, aDesiredSize,
                                  aReflowInput, aStatus);
 
   NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize)
 
-  // Finally update our line sizing values in our containerInfo.
+  // Finally update our line and item measurements in our containerInfo.
   if (MOZ_UNLIKELY(containerInfo)) {
     lineIndex = 0;
     for (const FlexLine* line = lines.getFirst(); line;
          line = line->getNext(), ++lineIndex) {
       ComputedFlexLineInfo& lineInfo = containerInfo->mLines[lineIndex];
 
       lineInfo.mCrossSize = line->GetLineCrossSize();
       lineInfo.mFirstBaselineOffset = line->GetFirstBaselineOffset();
       lineInfo.mLastBaselineOffset = line->GetLastBaselineOffset();
+
+      uint32_t itemIndex = 0;
+      for (const FlexItem* item = line->GetFirstItem(); item;
+           item = item->getNext(), ++itemIndex) {
+        ComputedFlexItemInfo& itemInfo = lineInfo.mItems[itemIndex];
+        itemInfo.mMainPosition = item->GetMainPosition();
+        itemInfo.mMainSize = item->GetMainSize();
+        itemInfo.mMainMinSize = item->GetMainMinSize();
+        itemInfo.mMainMaxSize = item->GetMainMaxSize();
+        itemInfo.mCrossPosition = item->GetCrossPosition();
+        itemInfo.mCrossSize = item->GetCrossSize();
+        itemInfo.mCrossMinSize = item->GetCrossMinSize();
+        itemInfo.mCrossMaxSize = item->GetCrossMaxSize();
+      }
     }
   }
 }
 
 void
 nsFlexContainerFrame::MoveFlexItemToFinalPosition(
   const ReflowInput& aReflowInput,
   const FlexItem& aItem,
--- a/layout/generic/nsFlexContainerFrame.h
+++ b/layout/generic/nsFlexContainerFrame.h
@@ -28,16 +28,18 @@ nsContainerFrame* NS_NewFlexContainerFra
  * extracted by devtools via Chrome APIs. The structures are only
  * created when requested in GetFlexFrameWithComputedInfo(), and
  * the structures are attached to the nsFlexContainerFrame via the
  * FlexContainerInfo property.
  */
 struct ComputedFlexItemInfo
 {
   nsCOMPtr<nsINode> mNode;
+  nscoord mMainPosition;
+  nscoord mMainSize;
   /**
    * mMainBaseSize is a measure of the size of the item in the main
    * axis before the flex sizing algorithm is applied. In the spec,
    * this is called "flex base size", but we use this name to connect
    * the value to the other main axis sizes.
    */
   nscoord mMainBaseSize;
   /**
@@ -47,16 +49,18 @@ struct ComputedFlexItemInfo
    * flex layout algorithm "wants" to shrink or grow the item, and
    * would do, if it was unconstrained. Since the flex sizing
    * algorithm proceeds linearly, the mMainDeltaSize for an item only
    * respects the resolved size of items already frozen.
    */
   nscoord mMainDeltaSize;
   nscoord mMainMinSize;
   nscoord mMainMaxSize;
+  nscoord mCrossPosition;
+  nscoord mCrossSize;
   nscoord mCrossMinSize;
   nscoord mCrossMaxSize;
   mozilla::dom::FlexItemClampState mClampState;
 };
 
 struct ComputedFlexLineInfo
 {
   nsTArray<ComputedFlexItemInfo> mItems;