Bug 1498273 Part 1: Updated Flex.webidl to add a per-item clamp state attribute. r=dholbert
authorBrad Werth <bwerth@mozilla.com>
Wed, 24 Oct 2018 23:46:16 +0000
changeset 491244 24b46ea119a07030f321c71007d158277d919e1a
parent 491243 19fb1af8f782fdc2397c59aa0afb686172324879
child 491245 28d81e5c33d8e04494ad4455a8d7cf5a0813083f
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersdholbert
bugs1498273
milestone65.0a1
Bug 1498273 Part 1: Updated Flex.webidl to add a per-item clamp state attribute. r=dholbert Differential Revision: https://phabricator.services.mozilla.com/D8769
dom/chrome-webidl/Flex.webidl
dom/flex/FlexItemValues.cpp
dom/flex/FlexItemValues.h
--- a/dom/chrome-webidl/Flex.webidl
+++ b/dom/chrome-webidl/Flex.webidl
@@ -66,19 +66,28 @@ interface FlexLineValues
 
   /**
    * getItems() returns FlexItemValues only for the Elements in
    * this Flex container -- ignoring struts and abs-pos Elements.
    */
   sequence<FlexItemValues> getItems();
 };
 
+/**
+ * Item main sizes have either been unclamped, clamped to the minimum,
+ * or clamped to the maximum.
+ */
+enum FlexItemClampState {
+  "unclamped", "clamped_to_min", "clamped_to_max"
+};
+
 [ChromeOnly]
 interface FlexItemValues
 {
   readonly attribute Node? node;
   readonly attribute double mainBaseSize;
   readonly attribute double mainDeltaSize;
   readonly attribute double mainMinSize;
   readonly attribute double mainMaxSize;
   readonly attribute double crossMinSize;
   readonly attribute double crossMaxSize;
+  readonly attribute FlexItemClampState clampState;
 };
--- a/dom/flex/FlexItemValues.cpp
+++ b/dom/flex/FlexItemValues.cpp
@@ -55,16 +55,18 @@ FlexItemValues::FlexItemValues(FlexLineV
   mMainDeltaSize = nsPresContext::AppUnitsToDoubleCSSPixels(
     aItem->mMainDeltaSize);
   mMainMinSize = nsPresContext::AppUnitsToDoubleCSSPixels(
     aItem->mMainMinSize);
   mMainMaxSize = ToPossiblyUnconstrainedPixels(aItem->mMainMaxSize);
   mCrossMinSize = nsPresContext::AppUnitsToDoubleCSSPixels(
     aItem->mCrossMinSize);
   mCrossMaxSize = ToPossiblyUnconstrainedPixels(aItem->mCrossMaxSize);
+
+  mClampState = FlexItemClampState::Unclamped;
 }
 
 JSObject*
 FlexItemValues::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return FlexItemValues_Binding::Wrap(aCx, this, aGivenProto);
 }
 
@@ -105,10 +107,16 @@ FlexItemValues::CrossMinSize() const
 }
 
 double
 FlexItemValues::CrossMaxSize() const
 {
   return mCrossMaxSize;
 }
 
+FlexItemClampState
+FlexItemValues::ClampState() const
+{
+  return mClampState;
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/dom/flex/FlexItemValues.h
+++ b/dom/flex/FlexItemValues.h
@@ -40,26 +40,28 @@ public:
 
   nsINode* GetNode() const;
   double MainBaseSize() const;
   double MainDeltaSize() const;
   double MainMinSize() const;
   double MainMaxSize() const;
   double CrossMinSize() const;
   double CrossMaxSize() const;
+  FlexItemClampState ClampState() const;
 
 protected:
   RefPtr<FlexLineValues> mParent;
   RefPtr<nsINode> mNode;
 
   // These sizes are all CSS pixel units.
   double mMainBaseSize;
   double mMainDeltaSize;
   double mMainMinSize;
   double mMainMaxSize;
   double mCrossMinSize;
   double mCrossMaxSize;
+  FlexItemClampState mClampState;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif /* mozilla_dom_FlexItemValues_h */