Bug 1497589 Part 3: Stub in physical direction enums for Flex API main and cross axes. r=dholbert
authorBrad Werth <bwerth@mozilla.com>
Wed, 17 Oct 2018 20:22:46 +0000
changeset 490305 082aaca611f9f0e13cd82d6cc708b687cfd35b7c
parent 490304 d0b82fc9252d1c017cfd7e3381873c9e2ee9ee8f
child 490306 d8e73cf6952fd03c118b8cdd3cc97a8f59045f95
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersdholbert
bugs1497589
milestone64.0a1
Bug 1497589 Part 3: Stub in physical direction enums for Flex API main and cross axes. r=dholbert Differential Revision: https://phabricator.services.mozilla.com/D8616
dom/chrome-webidl/Flex.webidl
dom/flex/Flex.cpp
dom/flex/Flex.h
--- a/dom/chrome-webidl/Flex.webidl
+++ b/dom/chrome-webidl/Flex.webidl
@@ -4,20 +4,43 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 /**
  * These objects support visualization of flex containers by the
  * dev tools.
  */
 
+/**
+ * A flex container's main and cross axes are either horizontal or
+ * vertical, each with two possible directions.
+ */
+enum FlexPhysicalDirection {
+  "horizontal-lr",
+  "horizontal-rl",
+  "vertical-tb",
+  "vertical-bt",
+};
+
 [ChromeOnly]
 interface Flex
 {
   sequence<FlexLineValues> getLines();
+
+  /**
+   * The physical direction in which successive flex items are placed,
+   * within a flex line in this flex container.
+   */
+  readonly attribute FlexPhysicalDirection mainAxisDirection;
+
+  /**
+   * The physical direction in which successive flex lines are placed
+   * in this flex container (if it is or were multi-line).
+   */
+  readonly attribute FlexPhysicalDirection crossAxisDirection;
 };
 
 /**
  * Lines with items that have been shrunk are shrinking; with items
  * that have grown are growing, and all others are unchanged.
  */
 enum FlexLineGrowthState { "unchanged", "shrinking", "growing" };
 
--- a/dom/flex/Flex.cpp
+++ b/dom/flex/Flex.cpp
@@ -50,10 +50,22 @@ Flex::WrapObject(JSContext* aCx, JS::Han
 }
 
 void
 Flex::GetLines(nsTArray<RefPtr<FlexLineValues>>& aResult)
 {
   aResult.AppendElements(mLines);
 }
 
+FlexPhysicalDirection
+Flex::MainAxisDirection() const
+{
+  return mMainAxisDirection;
+}
+
+FlexPhysicalDirection
+Flex::CrossAxisDirection() const
+{
+  return mCrossAxisDirection;
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/dom/flex/Flex.h
+++ b/dom/flex/Flex.h
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_Flex_h
 #define mozilla_dom_Flex_h
 
 #include "mozilla/dom/Element.h"
+#include "mozilla/dom/FlexBinding.h"
 #include "nsISupports.h"
 #include "nsWrapperCache.h"
 
 class nsFlexContainerFrame;
 
 namespace mozilla {
 namespace dom {
 
@@ -33,18 +34,22 @@ public:
 
   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
   Element* GetParentObject()
   {
     return mParent;
   }
 
   void GetLines(nsTArray<RefPtr<FlexLineValues>>& aResult);
+  FlexPhysicalDirection MainAxisDirection() const;
+  FlexPhysicalDirection CrossAxisDirection() const;
 
 protected:
   nsCOMPtr<Element> mParent;
   nsTArray<RefPtr<FlexLineValues>> mLines;
+  FlexPhysicalDirection mMainAxisDirection;
+  FlexPhysicalDirection mCrossAxisDirection;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif /* mozilla_dom_Flex_h */