Bug 1561738 - Remove nsStyleCoord. r=boris
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 28 Jun 2019 09:46:26 +0000
changeset 480542 e0af0c6328746dd6eefa01c51c502ef583c99953
parent 480541 ad438d2a0a154498e428740aece0db242955e8cd
child 480543 a88d7aced3040da7e6f7a803708b92f4bec6410b
push id113555
push usercsabou@mozilla.com
push dateFri, 28 Jun 2019 16:23:03 +0000
treeherdermozilla-inbound@7e8d43bbeb96 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersboris
bugs1561738
milestone69.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 1561738 - Remove nsStyleCoord. r=boris And move the useful bits of it somewhere else (ServoStyleConstInlines.h for the inline function definitions, and nsFrame.cpp for the static assertions). Differential Revision: https://phabricator.services.mozilla.com/D36120
docshell/base/nsDocShellTreeOwner.cpp
dom/base/DOMIntersectionObserver.h
dom/base/nsFocusManager.cpp
dom/svg/SVGContentUtils.h
gfx/2d/Types.h
gfx/layers/FrameMetrics.h
layout/base/ScrollStyles.h
layout/base/ShapeUtils.cpp
layout/base/ShapeUtils.h
layout/base/nsLayoutUtils.h
layout/generic/ColumnUtils.h
layout/generic/ReflowInput.h
layout/generic/WritingModes.h
layout/generic/nsFlexContainerFrame.h
layout/generic/nsFrame.cpp
layout/generic/nsImageFrame.cpp
layout/style/GeckoBindings.cpp
layout/style/GeckoBindings.h
layout/style/ServoBindings.toml
layout/style/ServoStyleConstsInlines.h
layout/style/StyleAnimationValue.h
layout/style/moz.build
layout/style/nsCSSValue.h
layout/style/nsComputedDOMStyle.cpp
layout/style/nsComputedDOMStyle.h
layout/style/nsStyleCoord.cpp
layout/style/nsStyleCoord.h
layout/style/nsStyleStruct.h
layout/style/nsStyleUtil.cpp
layout/style/nsStyleUtil.h
layout/svg/nsSVGUtils.cpp
layout/tables/nsTableFrame.h
servo/components/style/gecko/conversions.rs
servo/components/style/gecko/values.rs
servo/components/style/gecko_bindings/sugar/mod.rs
servo/components/style/gecko_bindings/sugar/ns_style_coord.rs
servo/ports/geckolib/cbindgen.toml
--- a/docshell/base/nsDocShellTreeOwner.cpp
+++ b/docshell/base/nsDocShellTreeOwner.cpp
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Local Includes
 #include "nsDocShellTreeOwner.h"
 #include "nsWebBrowser.h"
 
 // Helper Classes
 #include "nsContentUtils.h"
-#include "nsStyleCoord.h"
 #include "nsSize.h"
 #include "mozilla/ReflowInput.h"
 #include "nsIServiceManager.h"
 #include "nsComponentManagerUtils.h"
 #include "nsString.h"
 #include "nsAtom.h"
 #include "nsReadableUtils.h"
 #include "nsUnicharUtils.h"
--- a/dom/base/DOMIntersectionObserver.h
+++ b/dom/base/DOMIntersectionObserver.h
@@ -4,17 +4,17 @@
  * 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 DOMIntersectionObserver_h
 #define DOMIntersectionObserver_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/IntersectionObserverBinding.h"
-#include "nsStyleCoord.h"
+#include "mozilla/ServoStyleConsts.h"
 #include "nsTArray.h"
 
 using mozilla::dom::DOMRect;
 using mozilla::dom::Element;
 
 namespace mozilla {
 namespace dom {
 
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -31,17 +31,16 @@
 #include "mozilla/dom/Selection.h"
 #include "nsXULPopupManager.h"
 #include "nsMenuPopupFrame.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIPrincipal.h"
 #include "nsIObserverService.h"
 #include "nsIObjectFrame.h"
 #include "nsBindingManager.h"
-#include "nsStyleCoord.h"
 #include "BrowserChild.h"
 #include "nsFrameLoader.h"
 #include "nsHTMLDocument.h"
 #include "nsNumberControlFrame.h"
 #include "nsNetUtil.h"
 #include "nsRange.h"
 
 #include "mozilla/AccessibleCaretEventHub.h"
--- a/dom/svg/SVGContentUtils.h
+++ b/dom/svg/SVGContentUtils.h
@@ -8,17 +8,17 @@
 #define MOZILLA_SVGCONTENTUTILS_H
 
 // include math.h to pick up definition of M_ maths defines e.g. M_PI
 #include <math.h>
 
 #include "mozilla/gfx/2D.h"  // for StrokeOptions
 #include "mozilla/gfx/Matrix.h"
 #include "mozilla/RangedPtr.h"
-#include "nsStyleCoord.h"
+#include "mozilla/ServoStyleConsts.h"
 #include "nsError.h"
 #include "nsStringFwd.h"
 #include "gfx2DGlue.h"
 #include "nsDependentSubstring.h"
 
 class nsIContent;
 
 class nsIFrame;
@@ -313,17 +313,17 @@ class SVGContentUtils {
    * Parse an integer of the form:
    * integer ::= [+-]? [0-9]+
    * The returned number is clamped to an int32_t if outside that range.
    * Parsing fails if there is anything left over after the number.
    */
   static bool ParseInteger(const nsAString& aString, int32_t& aValue);
 
   /**
-   * Converts an nsStyleCoord into a userspace value, resolving percentage
+   * Converts a LengthPercentage into a userspace value, resolving percentage
    * values relative to aContent's SVG viewport.
    */
   static float CoordToFloat(dom::SVGElement* aContent, const LengthPercentage&);
   /**
    * Parse the SVG path string
    * Returns a path
    * string formatted as an SVG path
    */
--- a/gfx/2d/Types.h
+++ b/gfx/2d/Types.h
@@ -555,17 +555,17 @@ static inline HalfCorner operator++(Half
   MOZ_ASSERT(
       aHalfCorner >= eCornerTopLeftX && aHalfCorner <= eCornerBottomLeftY,
       "Out of range half corner!");
   aHalfCorner = HalfCorner(aHalfCorner + 1);
   return aHalfCorner;
 }
 
 // The result of these conversion functions are exhaustively checked in
-// nsStyleCoord.cpp, which also serves as usage examples.
+// nsFrame.cpp, which also serves as usage examples.
 
 constexpr bool HalfCornerIsX(HalfCorner aHalfCorner) {
   return !(aHalfCorner % 2);
 }
 
 constexpr Corner HalfToFullCorner(HalfCorner aHalfCorner) {
   return Corner(aHalfCorner / 2);
 }
--- a/gfx/layers/FrameMetrics.h
+++ b/gfx/layers/FrameMetrics.h
@@ -17,17 +17,17 @@
 #include "mozilla/gfx/Rect.h"                    // for RoundedIn
 #include "mozilla/gfx/ScaleFactor.h"             // for ScaleFactor
 #include "mozilla/gfx/Logging.h"                 // for Log
 #include "mozilla/layers/LayersTypes.h"          // for ScrollDirection
 #include "mozilla/layers/ScrollableLayerGuid.h"  // for ScrollableLayerGuid
 #include "mozilla/StaticPtr.h"                   // for StaticAutoPtr
 #include "mozilla/TimeStamp.h"                   // for TimeStamp
 #include "nsString.h"
-#include "nsStyleCoord.h"  // for nsStyleCoord
+#include "mozilla/ServoStyleConsts.h"
 #include "PLDHashTable.h"  // for PLDHashNumber
 
 struct nsStyleDisplay;
 namespace mozilla {
 class WritingMode;
 }  // namespace mozilla
 
 namespace IPC {
@@ -754,17 +754,17 @@ struct ScrollSnapInfo {
   mozilla::StyleScrollSnapStrictness mScrollSnapStrictnessY =
       mozilla::StyleScrollSnapStrictness::None;
 
   // The intervals derived from the scroll frame's scroll-snap-points.
   Maybe<nscoord> mScrollSnapIntervalX;
   Maybe<nscoord> mScrollSnapIntervalY;
 
   // The scroll frame's scroll-snap-destination, in cooked form (to avoid
-  // shipping the raw nsStyleCoord::CalcValue over IPC).
+  // shipping the raw style value over IPC).
   nsPoint mScrollSnapDestination;
 
   // The scroll-snap-coordinates of any descendant frames of the scroll frame,
   // relative to the origin of the scrolled frame.
   nsTArray<nsPoint> mScrollSnapCoordinates;
 
   // The scroll positions corresponding to scroll-snap-align values.
   nsTArray<nscoord> mSnapPositionX;
--- a/layout/base/ScrollStyles.h
+++ b/layout/base/ScrollStyles.h
@@ -4,17 +4,16 @@
  * 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_ScrollStyles_h
 #define mozilla_ScrollStyles_h
 
 #include <stdint.h>
 #include "nsStyleConsts.h"
-#include "nsStyleCoord.h"  // for nsStyleCoord
 #include "mozilla/dom/WindowBinding.h"
 
 // Forward declarations
 struct nsStyleDisplay;
 
 namespace mozilla {
 
 struct ScrollStyles {
--- a/layout/base/ShapeUtils.cpp
+++ b/layout/base/ShapeUtils.cpp
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ShapeUtils.h"
 
 #include <cstdlib>
 
 #include "nsCSSRendering.h"
 #include "nsMargin.h"
-#include "nsStyleCoord.h"
 #include "nsStyleStruct.h"
 #include "SVGContentUtils.h"
 
 namespace mozilla {
 
 nscoord ShapeUtils::ComputeShapeRadius(const StyleShapeRadius& aType,
                                        const nscoord aCenter,
                                        const nscoord aPosMin,
--- a/layout/base/ShapeUtils.h
+++ b/layout/base/ShapeUtils.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_ShapeUtils_h
 #define mozilla_ShapeUtils_h
 
 #include "nsCoord.h"
 #include "nsSize.h"
 #include "nsStyleConsts.h"
-#include "nsStyleCoord.h"
 #include "nsTArray.h"
 
 struct nsPoint;
 struct nsRect;
 
 namespace mozilla {
 // ShapeUtils is a namespace class containing utility functions related to
 // processing basic shapes in the CSS Shapes Module.
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -14,17 +14,16 @@
 #include "mozilla/Maybe.h"
 #include "mozilla/TypedEnumBits.h"
 #include "nsBoundingMetrics.h"
 #include "nsChangeHint.h"
 #include "mozilla/layout/FrameChildList.h"
 #include "mozilla/layers/ScrollableLayerGuid.h"
 #include "nsThreadUtils.h"
 #include "nsCSSPropertyIDSet.h"
-#include "nsStyleCoord.h"
 #include "nsStyleConsts.h"
 #include "nsGkAtoms.h"
 #include "mozilla/gfx/2D.h"
 #include "Units.h"
 #include "mozilla/ToString.h"
 #include "mozilla/ReflowOutput.h"
 #include "ImageContainer.h"  // for layers::Image
 #include "gfx2DGlue.h"
@@ -50,17 +49,16 @@ enum class nsDisplayListBuilderMode : ui
 class nsDisplayItem;
 class nsFontMetrics;
 class nsFontFaceList;
 class nsIImageLoadingContent;
 class nsBlockFrame;
 class nsContainerFrame;
 class nsView;
 class nsIFrame;
-class nsStyleCoord;
 class nsPIDOMWindowOuter;
 class imgIRequest;
 struct nsStyleFont;
 struct nsOverflowAreas;
 
 namespace mozilla {
 struct AspectRatio;
 class ComputedStyle;
--- a/layout/generic/ColumnUtils.h
+++ b/layout/generic/ColumnUtils.h
@@ -4,17 +4,18 @@
  * 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/. */
 
 /* A namespace class for static muti-column utilities. */
 
 #ifndef mozilla_ColumnUtils_h
 #define mozilla_ColumnUtils_h
 
-#include "nsStyleCoord.h"
+#include "nsCoord.h"
+#include "nsStyleConsts.h"
 
 class nsContainerFrame;
 
 namespace mozilla {
 
 // ColumnUtils is a namespace class containing utility functions used by
 // multi-column containers like ColumnSetWrapperFrame and nsColumnSetFrame.
 //
--- a/layout/generic/ReflowInput.h
+++ b/layout/generic/ReflowInput.h
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* struct containing the input to nsIFrame::Reflow */
 
 #ifndef mozilla_ReflowInput_h
 #define mozilla_ReflowInput_h
 
 #include "nsMargin.h"
-#include "nsStyleCoord.h"
+#include "nsStyleConsts.h"
 #include "nsIFrame.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Maybe.h"
 #include <algorithm>
 
 class gfxContext;
 class nsFloatManager;
 struct nsHypotheticalPosition;
@@ -329,20 +329,20 @@ struct SizeComputationInput {
  protected:
   void InitOffsets(mozilla::WritingMode aWM, nscoord aPercentBasis,
                    mozilla::LayoutFrameType aFrameType, ReflowInputFlags aFlags,
                    const nsMargin* aBorder = nullptr,
                    const nsMargin* aPadding = nullptr,
                    const nsStyleDisplay* aDisplay = nullptr);
 
   /*
-   * Convert nsStyleCoord to nscoord when percentages depend on the
-   * inline size of the containing block, and enumerated values are for
-   * inline size, min-inline-size, or max-inline-size.  Does not handle
-   * auto inline sizes.
+   * Convert StyleSize or StyleMaxSize to nscoord when percentages depend on the
+   * inline size of the containing block, and enumerated values are for inline
+   * size, min-inline-size, or max-inline-size.  Does not handle auto inline
+   * sizes.
    */
   template <typename SizeOrMaxSize>
   inline nscoord ComputeISizeValue(nscoord aContainingBlockISize,
                                    nscoord aContentEdgeToBoxSizing,
                                    nscoord aBoxSizingToMarginEdge,
                                    const SizeOrMaxSize&) const;
   // same as previous, but using mComputedBorderPadding, mComputedPadding,
   // and mComputedMargin
--- a/layout/generic/WritingModes.h
+++ b/layout/generic/WritingModes.h
@@ -1914,69 +1914,16 @@ const T& StyleRect<T>::GetIEnd(mozilla::
 
 template <typename T>
 const T& StyleRect<T>::GetBEnd(mozilla::WritingMode aWM) const {
   return Get(aWM, mozilla::eLogicalSideBEnd);
 }
 
 }  // namespace mozilla
 
-// Definitions of inline methods for nsStyleSides, declared in nsStyleCoord.h
-// but not defined there because they need WritingMode.
-inline nsStyleUnit nsStyleSides::GetUnit(mozilla::WritingMode aWM,
-                                         mozilla::LogicalSide aSide) const {
-  return GetUnit(aWM.PhysicalSide(aSide));
-}
-
-inline nsStyleUnit nsStyleSides::GetIStartUnit(mozilla::WritingMode aWM) const {
-  return GetUnit(aWM, mozilla::eLogicalSideIStart);
-}
-
-inline nsStyleUnit nsStyleSides::GetBStartUnit(mozilla::WritingMode aWM) const {
-  return GetUnit(aWM, mozilla::eLogicalSideBStart);
-}
-
-inline nsStyleUnit nsStyleSides::GetIEndUnit(mozilla::WritingMode aWM) const {
-  return GetUnit(aWM, mozilla::eLogicalSideIEnd);
-}
-
-inline nsStyleUnit nsStyleSides::GetBEndUnit(mozilla::WritingMode aWM) const {
-  return GetUnit(aWM, mozilla::eLogicalSideBEnd);
-}
-
-inline bool nsStyleSides::HasBlockAxisAuto(mozilla::WritingMode aWM) const {
-  return GetBStartUnit(aWM) == eStyleUnit_Auto ||
-         GetBEndUnit(aWM) == eStyleUnit_Auto;
-}
-
-inline bool nsStyleSides::HasInlineAxisAuto(mozilla::WritingMode aWM) const {
-  return GetIStartUnit(aWM) == eStyleUnit_Auto ||
-         GetIEndUnit(aWM) == eStyleUnit_Auto;
-}
-
-inline nsStyleCoord nsStyleSides::Get(mozilla::WritingMode aWM,
-                                      mozilla::LogicalSide aSide) const {
-  return Get(aWM.PhysicalSide(aSide));
-}
-
-inline nsStyleCoord nsStyleSides::GetIStart(mozilla::WritingMode aWM) const {
-  return Get(aWM, mozilla::eLogicalSideIStart);
-}
-
-inline nsStyleCoord nsStyleSides::GetBStart(mozilla::WritingMode aWM) const {
-  return Get(aWM, mozilla::eLogicalSideBStart);
-}
-
-inline nsStyleCoord nsStyleSides::GetIEnd(mozilla::WritingMode aWM) const {
-  return Get(aWM, mozilla::eLogicalSideIEnd);
-}
-
-inline nsStyleCoord nsStyleSides::GetBEnd(mozilla::WritingMode aWM) const {
-  return Get(aWM, mozilla::eLogicalSideBEnd);
-}
 
 // Definitions of inline methods for nsStylePosition, declared in
 // nsStyleStruct.h but not defined there because they need WritingMode.
 inline const mozilla::StyleSize& nsStylePosition::ISize(WritingMode aWM) const {
   return aWM.IsVertical() ? mHeight : mWidth;
 }
 inline const mozilla::StyleSize& nsStylePosition::MinISize(
     WritingMode aWM) const {
--- a/layout/generic/nsFlexContainerFrame.h
+++ b/layout/generic/nsFlexContainerFrame.h
@@ -8,18 +8,16 @@
 
 #ifndef nsFlexContainerFrame_h___
 #define nsFlexContainerFrame_h___
 
 #include "nsContainerFrame.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/dom/FlexBinding.h"
 
-class nsStyleCoord;
-
 namespace mozilla {
 template <class T>
 class LinkedList;
 class LogicalPoint;
 class PresShell;
 }  // namespace mozilla
 
 nsContainerFrame* NS_NewFlexContainerFrame(mozilla::PresShell* aPresShell,
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -12316,9 +12316,102 @@ void ReflowInput::DisplayInitFrameTypeEx
     printf("%s%s\n", repNoBlock ? " +rep" : "", repBlock ? " +repBlk" : "");
   }
   DR_state->DeleteTreeNode(*treeNode);
 }
 
 #  endif
 // End Display Reflow
 
+// Validation of SideIsVertical.
+#define CASE(side, result) \
+  static_assert(SideIsVertical(side) == result, "SideIsVertical is wrong")
+CASE(eSideTop, false);
+CASE(eSideRight, true);
+CASE(eSideBottom, false);
+CASE(eSideLeft, true);
+#undef CASE
+
+// Validation of HalfCornerIsX.
+#define CASE(corner, result) \
+  static_assert(HalfCornerIsX(corner) == result, "HalfCornerIsX is wrong")
+CASE(eCornerTopLeftX, true);
+CASE(eCornerTopLeftY, false);
+CASE(eCornerTopRightX, true);
+CASE(eCornerTopRightY, false);
+CASE(eCornerBottomRightX, true);
+CASE(eCornerBottomRightY, false);
+CASE(eCornerBottomLeftX, true);
+CASE(eCornerBottomLeftY, false);
+#undef CASE
+
+// Validation of HalfToFullCorner.
+#define CASE(corner, result)                        \
+  static_assert(HalfToFullCorner(corner) == result, \
+                "HalfToFullCorner is "              \
+                "wrong")
+CASE(eCornerTopLeftX, eCornerTopLeft);
+CASE(eCornerTopLeftY, eCornerTopLeft);
+CASE(eCornerTopRightX, eCornerTopRight);
+CASE(eCornerTopRightY, eCornerTopRight);
+CASE(eCornerBottomRightX, eCornerBottomRight);
+CASE(eCornerBottomRightY, eCornerBottomRight);
+CASE(eCornerBottomLeftX, eCornerBottomLeft);
+CASE(eCornerBottomLeftY, eCornerBottomLeft);
+#undef CASE
+
+// Validation of FullToHalfCorner.
+#define CASE(corner, vert, result)                        \
+  static_assert(FullToHalfCorner(corner, vert) == result, \
+                "FullToHalfCorner is wrong")
+CASE(eCornerTopLeft, false, eCornerTopLeftX);
+CASE(eCornerTopLeft, true, eCornerTopLeftY);
+CASE(eCornerTopRight, false, eCornerTopRightX);
+CASE(eCornerTopRight, true, eCornerTopRightY);
+CASE(eCornerBottomRight, false, eCornerBottomRightX);
+CASE(eCornerBottomRight, true, eCornerBottomRightY);
+CASE(eCornerBottomLeft, false, eCornerBottomLeftX);
+CASE(eCornerBottomLeft, true, eCornerBottomLeftY);
+#undef CASE
+
+// Validation of SideToFullCorner.
+#define CASE(side, second, result)                        \
+  static_assert(SideToFullCorner(side, second) == result, \
+                "SideToFullCorner is wrong")
+CASE(eSideTop, false, eCornerTopLeft);
+CASE(eSideTop, true, eCornerTopRight);
+
+CASE(eSideRight, false, eCornerTopRight);
+CASE(eSideRight, true, eCornerBottomRight);
+
+CASE(eSideBottom, false, eCornerBottomRight);
+CASE(eSideBottom, true, eCornerBottomLeft);
+
+CASE(eSideLeft, false, eCornerBottomLeft);
+CASE(eSideLeft, true, eCornerTopLeft);
+#undef CASE
+
+// Validation of SideToHalfCorner.
+#define CASE(side, second, parallel, result)                        \
+  static_assert(SideToHalfCorner(side, second, parallel) == result, \
+                "SideToHalfCorner is wrong")
+CASE(eSideTop, false, true, eCornerTopLeftX);
+CASE(eSideTop, false, false, eCornerTopLeftY);
+CASE(eSideTop, true, true, eCornerTopRightX);
+CASE(eSideTop, true, false, eCornerTopRightY);
+
+CASE(eSideRight, false, false, eCornerTopRightX);
+CASE(eSideRight, false, true, eCornerTopRightY);
+CASE(eSideRight, true, false, eCornerBottomRightX);
+CASE(eSideRight, true, true, eCornerBottomRightY);
+
+CASE(eSideBottom, false, true, eCornerBottomRightX);
+CASE(eSideBottom, false, false, eCornerBottomRightY);
+CASE(eSideBottom, true, true, eCornerBottomLeftX);
+CASE(eSideBottom, true, false, eCornerBottomLeftY);
+
+CASE(eSideLeft, false, false, eCornerBottomLeftX);
+CASE(eSideLeft, false, true, eCornerBottomLeftY);
+CASE(eSideLeft, true, false, eCornerTopLeftX);
+CASE(eSideLeft, true, true, eCornerTopLeftY);
+#undef CASE
+
 #endif
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -38,17 +38,16 @@
 #include "nsString.h"
 #include "nsPrintfCString.h"
 #include "nsPresContext.h"
 #include "nsGkAtoms.h"
 #include "mozilla/dom/Document.h"
 #include "nsContentUtils.h"
 #include "nsCSSAnonBoxes.h"
 #include "nsStyleConsts.h"
-#include "nsStyleCoord.h"
 #include "nsStyleUtil.h"
 #include "nsTransform2D.h"
 #include "nsImageMap.h"
 #include "nsIIOService.h"
 #include "nsILoadGroup.h"
 #include "nsISupportsPriority.h"
 #include "nsNetUtil.h"
 #include "nsNetCID.h"
--- a/layout/style/GeckoBindings.cpp
+++ b/layout/style/GeckoBindings.cpp
@@ -1468,33 +1468,16 @@ Keyframe* Gecko_GetOrCreateFinalKeyframe
 PropertyValuePair* Gecko_AppendPropertyValuePair(
     nsTArray<PropertyValuePair>* aProperties, nsCSSPropertyID aProperty) {
   MOZ_ASSERT(aProperties);
   MOZ_ASSERT(aProperty == eCSSPropertyExtra_variable ||
              !nsCSSProps::PropHasFlags(aProperty, CSSPropFlags::IsLogical));
   return aProperties->AppendElement(PropertyValuePair{aProperty});
 }
 
-void Gecko_ResetStyleCoord(nsStyleUnit* aUnit, nsStyleUnion* aValue) {
-  nsStyleCoord::Reset(*aUnit, *aValue);
-}
-
-void Gecko_SetStyleCoordCalcValue(nsStyleUnit* aUnit, nsStyleUnion* aValue,
-                                  nsStyleCoord::CalcValue aCalc) {
-  // Calc units should be cleaned up first
-  MOZ_ASSERT(*aUnit != nsStyleUnit::eStyleUnit_Calc);
-  nsStyleCoord::Calc* calcRef = new nsStyleCoord::Calc();
-  calcRef->mLength = aCalc.mLength;
-  calcRef->mPercent = aCalc.mPercent;
-  calcRef->mHasPercent = aCalc.mHasPercent;
-  *aUnit = nsStyleUnit::eStyleUnit_Calc;
-  aValue->mPointer = calcRef;
-  calcRef->AddRef();
-}
-
 void Gecko_CopyShapeSourceFrom(StyleShapeSource* aDst,
                                const StyleShapeSource* aSrc) {
   MOZ_ASSERT(aDst);
   MOZ_ASSERT(aSrc);
 
   *aDst = *aSrc;
 }
 
@@ -1604,18 +1587,16 @@ void Gecko_Element_DebugListAttributes(c
 
 void Gecko_Snapshot_DebugListAttributes(const ServoElementSnapshot* aSnapshot,
                                         nsCString* aOut) {
   DebugListAttributes(*aSnapshot, *aOut);
 }
 
 NS_IMPL_THREADSAFE_FFI_REFCOUNTING(URLExtraData, URLExtraData);
 
-NS_IMPL_THREADSAFE_FFI_REFCOUNTING(nsStyleCoord::Calc, Calc);
-
 void Gecko_nsStyleFont_SetLang(nsStyleFont* aFont, nsAtom* aAtom) {
   aFont->mLanguage = dont_AddRef(aAtom);
   aFont->mExplicitLanguage = true;
 }
 
 void Gecko_nsStyleFont_CopyLangFrom(nsStyleFont* aFont,
                                     const nsStyleFont* aSource) {
   aFont->mLanguage = aSource->mLanguage;
--- a/layout/style/GeckoBindings.h
+++ b/layout/style/GeckoBindings.h
@@ -499,23 +499,16 @@ mozilla::Keyframe* Gecko_GetOrCreateFina
     const nsTimingFunction* timingFunction);
 
 // Appends and returns a new PropertyValuePair to |aProperties| initialized with
 // its mProperty member set to |aProperty| and all other members initialized to
 // their default values.
 mozilla::PropertyValuePair* Gecko_AppendPropertyValuePair(
     nsTArray<mozilla::PropertyValuePair>*, nsCSSPropertyID aProperty);
 
-// Clean up pointer-based coordinates
-void Gecko_ResetStyleCoord(nsStyleUnit* unit, nsStyleUnion* value);
-
-// Set an nsStyleCoord to a computed `calc()` value
-void Gecko_SetStyleCoordCalcValue(nsStyleUnit* unit, nsStyleUnion* value,
-                                  nsStyleCoord::CalcValue calc);
-
 void Gecko_CopyShapeSourceFrom(mozilla::StyleShapeSource* dst,
                                const mozilla::StyleShapeSource* src);
 
 void Gecko_DestroyShapeSource(mozilla::StyleShapeSource* shape);
 
 void Gecko_NewShapeImage(mozilla::StyleShapeSource* shape);
 
 void Gecko_SetToSVGPath(
@@ -551,18 +544,16 @@ void Gecko_GetComputedImageURLSpec(const
                                    nsCString* spec);
 
 void Gecko_nsIURI_Debug(nsIURI*, nsCString* spec);
 
 NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::URLExtraData, URLExtraData);
 
 void Gecko_FillAllImageLayers(nsStyleImageLayers* layers, uint32_t max_len);
 
-NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsStyleCoord::Calc, Calc);
-
 float Gecko_FontStretch_ToFloat(mozilla::FontStretch aStretch);
 
 void Gecko_FontStretch_SetFloat(mozilla::FontStretch* aStretch,
                                 float aFloatValue);
 
 void Gecko_LoadData_DeregisterLoad(const mozilla::StyleLoadData*);
 
 float Gecko_FontSlantStyle_ToFloat(mozilla::FontSlantStyle aStyle);
--- a/layout/style/ServoBindings.toml
+++ b/layout/style/ServoBindings.toml
@@ -66,17 +66,16 @@ rusty-enums = [
     "mozilla::dom::CallerType",
     "mozilla::dom::IterationCompositeOperation",
     "mozilla::dom::CompositeOperation",
     "mozilla::InheritTarget",
     "mozilla::css::DocumentMatchingFunction",
     "mozilla::css::SheetParsingMode",
     "mozilla::StyleContentType",
     "nsStyleSVGOpacitySource",
-    "nsStyleUnit",
     "nsCSSKeyword",
     "mozilla::dom::Document_DocumentTheme",
     "mozilla::dom::Document_Type",
     "nsCSSUnit",
     "nsCSSFontDesc",
     "nsCSSPropertyID",
     "nsCSSCounterDesc",
     "nsMediaFeature_RangeType",
@@ -270,17 +269,16 @@ whitelist-types = [
     "nsSize",
     "nsStyleBackground",
     "nsStyleBorder",
     "nsStyleColor",
     "nsStyleColumn",
     "nsStyleContent",
     "nsStyleContentData",
     "ComputedStyle",
-    "nsStyleCoord",
     "nsStyleCounterData",
     "nsStyleDisplay",
     "nsStyleEffects",
     "nsStyleFilter",
     "nsStyleFont",
     "nsStyleGradient",
     "nsStyleGridTemplate",
     "nsStyleImage",
@@ -296,17 +294,16 @@ whitelist-types = [
     "nsStyleSVGPaint",
     "nsStyleSVGReset",
     "nsStyleTable",
     "nsStyleTableBorder",
     "nsStyleText",
     "nsStyleTextReset",
     "nsStyleUIReset",
     "nsStyleUnion",
-    "nsStyleUnit",
     "nsStyleUI",
     "nsStyleVisibility",
     "nsStyleXUL",
     "nsTArrayHeader",
     "Position",
     "PropertyValuePair",
     "Runnable",
     "ServoAttrSnapshot",
--- a/layout/style/ServoStyleConstsInlines.h
+++ b/layout/style/ServoStyleConstsInlines.h
@@ -395,11 +395,253 @@ inline nsAtom* StyleGridLine::LineName()
   return ident.AsAtom();
 }
 
 template <>
 inline bool StyleGridLine::IsAuto() const {
   return LineName()->IsEmpty() && line_num == 0 && !is_span;
 }
 
+class WritingMode;
+
+// Logical axis, edge, side and corner constants for use in various places.
+enum LogicalAxis { eLogicalAxisBlock = 0x0, eLogicalAxisInline = 0x1 };
+enum LogicalEdge { eLogicalEdgeStart = 0x0, eLogicalEdgeEnd = 0x1 };
+enum LogicalSide : uint8_t {
+  eLogicalSideBStart = (eLogicalAxisBlock << 1) | eLogicalEdgeStart,   // 0x0
+  eLogicalSideBEnd = (eLogicalAxisBlock << 1) | eLogicalEdgeEnd,       // 0x1
+  eLogicalSideIStart = (eLogicalAxisInline << 1) | eLogicalEdgeStart,  // 0x2
+  eLogicalSideIEnd = (eLogicalAxisInline << 1) | eLogicalEdgeEnd       // 0x3
+};
+
+enum LogicalCorner {
+  eLogicalCornerBStartIStart = 0,
+  eLogicalCornerBStartIEnd = 1,
+  eLogicalCornerBEndIEnd = 2,
+  eLogicalCornerBEndIStart = 3
+};
+
+using LengthPercentage = StyleLengthPercentage;
+using LengthPercentageOrAuto = StyleLengthPercentageOrAuto;
+using NonNegativeLengthPercentage = StyleNonNegativeLengthPercentage;
+using NonNegativeLengthPercentageOrAuto =
+    StyleNonNegativeLengthPercentageOrAuto;
+using NonNegativeLengthPercentageOrNormal =
+    StyleNonNegativeLengthPercentageOrNormal;
+using Length = StyleLength;
+using LengthOrAuto = StyleLengthOrAuto;
+using NonNegativeLength = StyleNonNegativeLength;
+using NonNegativeLengthOrAuto = StyleNonNegativeLengthOrAuto;
+using BorderRadius = StyleBorderRadius;
+
+bool StyleCSSPixelLength::IsZero() const { return _0 == 0.0f; }
+
+nscoord StyleCSSPixelLength::ToAppUnits() const {
+  // We want to resolve the length part of the calc() expression rounding 0.5
+  // away from zero, instead of the default behavior of
+  // NSToCoordRound{,WithClamp} which do floor(x + 0.5).
+  //
+  // This is what the rust code in the app_units crate does, and not doing this
+  // would regress bug 1323735, for example.
+  //
+  // FIXME(emilio, bug 1528114): Probably we should do something smarter.
+  float length = _0 * float(mozilla::AppUnitsPerCSSPixel());
+  if (length >= nscoord_MAX) {
+    return nscoord_MAX;
+  }
+  if (length <= nscoord_MIN) {
+    return nscoord_MIN;
+  }
+  return NSToIntRound(length);
+}
+
+constexpr LengthPercentage LengthPercentage::Zero() {
+  return {{0.}, {0.}, StyleAllowedNumericType::All, false, false};
+}
+
+LengthPercentage LengthPercentage::FromPixels(CSSCoord aCoord) {
+  return {{aCoord}, {0.}, StyleAllowedNumericType::All, false, false};
+}
+
+LengthPercentage LengthPercentage::FromAppUnits(nscoord aCoord) {
+  return LengthPercentage::FromPixels(CSSPixel::FromAppUnits(aCoord));
+}
+
+LengthPercentage LengthPercentage::FromPercentage(float aPercentage) {
+  return {{0.}, {aPercentage}, StyleAllowedNumericType::All, true, false};
+}
+
+CSSCoord LengthPercentage::LengthInCSSPixels() const { return length._0; }
+
+float LengthPercentage::Percentage() const { return percentage._0; }
+
+bool LengthPercentage::HasPercent() const { return has_percentage; }
+
+bool LengthPercentage::ConvertsToLength() const { return !HasPercent(); }
+
+nscoord LengthPercentage::ToLength() const {
+  MOZ_ASSERT(ConvertsToLength());
+  return length.ToAppUnits();
+}
+
+bool LengthPercentage::ConvertsToPercentage() const {
+  return has_percentage && length.IsZero();
+}
+
+float LengthPercentage::ToPercentage() const {
+  MOZ_ASSERT(ConvertsToPercentage());
+  return Percentage();
+}
+
+bool LengthPercentage::HasLengthAndPercentage() const {
+  return !ConvertsToLength() && !ConvertsToPercentage();
+}
+
+bool LengthPercentage::IsDefinitelyZero() const {
+  return length.IsZero() && Percentage() == 0.0f;
+}
+
+CSSCoord LengthPercentage::ResolveToCSSPixels(CSSCoord aPercentageBasis) const {
+  return LengthInCSSPixels() + Percentage() * aPercentageBasis;
+}
+
+template <typename T>
+CSSCoord LengthPercentage::ResolveToCSSPixelsWith(T aPercentageGetter) const {
+  static_assert(std::is_same<decltype(aPercentageGetter()), CSSCoord>::value,
+                "Should return CSS pixels");
+  if (ConvertsToLength()) {
+    return LengthInCSSPixels();
+  }
+  return ResolveToCSSPixels(aPercentageGetter());
+}
+
+template <typename T, typename U>
+nscoord LengthPercentage::Resolve(T aPercentageGetter,
+                                  U aPercentageRounder) const {
+  static_assert(std::is_same<decltype(aPercentageGetter()), nscoord>::value,
+                "Should return app units");
+  static_assert(
+      std::is_same<decltype(aPercentageRounder(1.0f)), nscoord>::value,
+      "Should return app units");
+  if (ConvertsToLength()) {
+    return ToLength();
+  }
+  nscoord basis = aPercentageGetter();
+  return length.ToAppUnits() + aPercentageRounder(basis * Percentage());
+}
+
+nscoord LengthPercentage::Resolve(nscoord aPercentageBasis) const {
+  return Resolve([=] { return aPercentageBasis; }, NSToCoordFloorClamped);
+}
+
+template <typename T>
+nscoord LengthPercentage::Resolve(T aPercentageGetter) const {
+  static_assert(std::is_same<decltype(aPercentageGetter()), nscoord>::value,
+                "Should return app units");
+  return Resolve(aPercentageGetter, NSToCoordFloorClamped);
+}
+
+template <typename T>
+nscoord LengthPercentage::Resolve(nscoord aPercentageBasis,
+                                  T aPercentageRounder) const {
+  return Resolve([=] { return aPercentageBasis; }, aPercentageRounder);
+}
+
+#define IMPL_LENGTHPERCENTAGE_FORWARDS(ty_)                                 \
+  template <>                                                               \
+  inline bool ty_::HasPercent() const {                                     \
+    return IsLengthPercentage() && AsLengthPercentage().HasPercent();       \
+  }                                                                         \
+  template <>                                                               \
+  inline bool ty_::ConvertsToLength() const {                               \
+    return IsLengthPercentage() && AsLengthPercentage().ConvertsToLength(); \
+  }                                                                         \
+  template <>                                                               \
+  inline bool ty_::HasLengthAndPercentage() const {                         \
+    return IsLengthPercentage() &&                                          \
+           AsLengthPercentage().HasLengthAndPercentage();                   \
+  }                                                                         \
+  template <>                                                               \
+  inline nscoord ty_::ToLength() const {                                    \
+    MOZ_ASSERT(ConvertsToLength());                                         \
+    return AsLengthPercentage().ToLength();                                 \
+  }                                                                         \
+  template <>                                                               \
+  inline bool ty_::ConvertsToPercentage() const {                           \
+    return IsLengthPercentage() &&                                          \
+           AsLengthPercentage().ConvertsToPercentage();                     \
+  }                                                                         \
+  template <>                                                               \
+  inline float ty_::ToPercentage() const {                                  \
+    MOZ_ASSERT(ConvertsToPercentage());                                     \
+    return AsLengthPercentage().ToPercentage();                             \
+  }
+
+IMPL_LENGTHPERCENTAGE_FORWARDS(LengthPercentageOrAuto)
+IMPL_LENGTHPERCENTAGE_FORWARDS(StyleSize)
+IMPL_LENGTHPERCENTAGE_FORWARDS(StyleMaxSize)
+
+template <>
+inline bool LengthOrAuto::IsLength() const {
+  return IsLengthPercentage();
+}
+
+template <>
+inline const Length& LengthOrAuto::AsLength() const {
+  return AsLengthPercentage();
+}
+
+template <>
+inline bool StyleFlexBasis::IsAuto() const {
+  return IsSize() && AsSize().IsAuto();
+}
+
+template <>
+inline bool StyleSize::BehavesLikeInitialValueOnBlockAxis() const {
+  return IsAuto() || IsExtremumLength();
+}
+
+template <>
+inline bool StyleMaxSize::BehavesLikeInitialValueOnBlockAxis() const {
+  return IsNone() || IsExtremumLength();
+}
+
+template <>
+inline bool StyleBackgroundSize::IsInitialValue() const {
+  return IsExplicitSize() && explicit_size.width.IsAuto() &&
+         explicit_size.height.IsAuto();
+}
+
+template <typename T>
+const T& StyleRect<T>::Get(mozilla::Side aSide) const {
+  static_assert(sizeof(StyleRect<T>) == sizeof(T) * 4, "");
+  static_assert(alignof(StyleRect<T>) == alignof(T), "");
+  return reinterpret_cast<const T*>(this)[aSide];
+}
+
+template <typename T>
+template <typename Predicate>
+bool StyleRect<T>::All(Predicate aPredicate) const {
+  return aPredicate(_0) && aPredicate(_1) && aPredicate(_2) && aPredicate(_3);
+}
+
+template <typename T>
+template <typename Predicate>
+bool StyleRect<T>::Any(Predicate aPredicate) const {
+  return aPredicate(_0) || aPredicate(_1) || aPredicate(_2) || aPredicate(_3);
+}
+
+template <>
+inline const LengthPercentage& BorderRadius::Get(HalfCorner aCorner) const {
+  static_assert(sizeof(BorderRadius) == sizeof(LengthPercentage) * 8, "");
+  static_assert(alignof(BorderRadius) == alignof(LengthPercentage), "");
+  auto* self = reinterpret_cast<const LengthPercentage*>(this);
+  return self[aCorner];
+}
+
+template <>
+inline bool StyleTrackBreadth::HasPercent() const {
+  return IsBreadth() && AsBreadth().HasPercent();
+}
+
 }  // namespace mozilla
 
 #endif
--- a/layout/style/StyleAnimationValue.h
+++ b/layout/style/StyleAnimationValue.h
@@ -16,17 +16,17 @@
 #include "mozilla/ServoStyleConsts.h"  // Servo_AnimationValue_Dump
 #include "mozilla/DbgMacro.h"
 #include "nsStringFwd.h"
 #include "nsStringBuffer.h"
 #include "nsCoord.h"
 #include "nsColor.h"
 #include "nsCSSPropertyID.h"
 #include "nsCSSValue.h"
-#include "nsStyleCoord.h"
+#include "nsStyleConsts.h"
 #include "nsStyleTransformMatrix.h"
 
 class nsIFrame;
 class gfx3DMatrix;
 
 namespace mozilla {
 
 class ComputedStyle;
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -55,17 +55,16 @@ EXPORTS += [
     'nsDOMCSSAttrDeclaration.h',
     'nsDOMCSSDeclaration.h',
     'nsICSSDeclaration.h',
     'nsICSSLoaderObserver.h',
     'nsLayoutStylesheetCache.h',
     'nsMediaFeatures.h',
     'nsStyleAutoArray.h',
     'nsStyleConsts.h',
-    'nsStyleCoord.h',
     'nsStyleStruct.h',
     'nsStyleStructFwd.h',
     'nsStyleStructInlines.h',
     'nsStyleStructList.h',
     'nsStyleTransformMatrix.h',
     'nsStyleUtil.h',
     'nsTimingFunction.h',
 ]
@@ -200,17 +199,16 @@ UNIFIED_SOURCES += [
     'nsFontFaceLoader.cpp',
     'nsFontFaceUtils.cpp',
     'nsHTMLCSSStyleSheet.cpp',
     'nsHTMLStyleSheet.cpp',
     'nsICSSDeclaration.cpp',
     'nsLayoutStylesheetCache.cpp',
     'nsMediaFeatures.cpp',
     'nsROCSSPrimitiveValue.cpp',
-    'nsStyleCoord.cpp',
     'nsStyleStruct.cpp',
     'nsStyleTransformMatrix.cpp',
     'nsStyleUtil.cpp',
     'nsTransitionManager.cpp',
     'PaintWorkletGlobalScope.cpp',
     'PaintWorkletImpl.cpp',
     'PostTraversalTask.cpp',
     'PreferenceSheet.cpp',
--- a/layout/style/nsCSSValue.h
+++ b/layout/style/nsCSSValue.h
@@ -6,32 +6,32 @@
 
 /* representation of simple property values within CSS declarations */
 
 #ifndef nsCSSValue_h___
 #define nsCSSValue_h___
 
 #include "mozilla/Attributes.h"
 #include "mozilla/CORSMode.h"
+#include "mozilla/EnumTypeTraits.h"
 #include "mozilla/FontPropertyTypes.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/ServoBindingTypes.h"
 #include "mozilla/URLExtraData.h"
 #include "mozilla/UniquePtr.h"
 
 #include "nsCSSKeywords.h"
 #include "nsCSSPropertyID.h"
 #include "nsCoord.h"
 #include "nsProxyRelease.h"
 #include "nsRefPtrHashtable.h"
 #include "nsString.h"
 #include "nsStringBuffer.h"
 #include "nsTArray.h"
 #include "nsStyleConsts.h"
-#include "nsStyleCoord.h"
 #include "gfxFontFamilyList.h"
 
 #include <type_traits>
 
 class imgRequestProxy;
 class nsAtom;
 class nsIContent;
 
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -41,17 +41,16 @@
 #include "nsCSSPseudoElements.h"
 #include "mozilla/EffectSet.h"
 #include "mozilla/IntegerRange.h"
 #include "mozilla/ServoStyleSet.h"
 #include "mozilla/RestyleManager.h"
 #include "imgIRequest.h"
 #include "nsLayoutUtils.h"
 #include "nsCSSKeywords.h"
-#include "nsStyleCoord.h"
 #include "nsDisplayList.h"
 #include "nsDOMCSSDeclaration.h"
 #include "nsStyleTransformMatrix.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/ElementInlines.h"
 #include "prtime.h"
 #include "nsWrapperCacheInlines.h"
 #include "mozilla/AppUnits.h"
@@ -1160,40 +1159,16 @@ already_AddRefed<CSSValue> nsComputedDOM
     return nullptr;
 
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
   val->SetIdent(nsCSSProps::ValueToKeywordEnum(
       StyleFont()->mFont.smoothing, nsCSSProps::kFontSmoothingKTable));
   return val.forget();
 }
 
-static void SetValueToCalc(const nsStyleCoord::CalcValue* aCalc,
-                           nsROCSSPrimitiveValue* aValue) {
-  RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
-  nsAutoString tmp, result;
-
-  result.AppendLiteral("calc(");
-
-  val->SetAppUnits(aCalc->mLength);
-  val->GetCssText(tmp);
-  result.Append(tmp);
-
-  if (aCalc->mHasPercent) {
-    result.AppendLiteral(" + ");
-
-    val->SetPercent(aCalc->mPercent);
-    val->GetCssText(tmp);
-    result.Append(tmp);
-  }
-
-  result.Append(')');
-
-  aValue->SetString(result);  // not really SetString
-}
-
 already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetImageLayerPosition(
     const nsStyleImageLayers& aLayers) {
   if (aLayers.mPositionXCount != aLayers.mPositionYCount) {
     // No value to return.  We can't express this combination of
     // values as a shorthand.
     return nullptr;
   }
 
@@ -1781,42 +1756,16 @@ already_AddRefed<CSSValue> nsComputedDOM
 
   val->SetIdent(
       nsCSSProps::ValueToKeywordEnum(StyleTextReset()->mTextDecorationStyle,
                                      nsCSSProps::kTextDecorationStyleKTable));
 
   return val.forget();
 }
 
-/* Border image properties */
-
-void nsComputedDOMStyle::AppendFourSideCoordValues(
-    nsDOMCSSValueList* aList, const nsStyleSides& aValues) {
-  const nsStyleCoord& top = aValues.Get(eSideTop);
-  const nsStyleCoord& right = aValues.Get(eSideRight);
-  const nsStyleCoord& bottom = aValues.Get(eSideBottom);
-  const nsStyleCoord& left = aValues.Get(eSideLeft);
-
-  auto appendValue = [this, aList](const nsStyleCoord& value) {
-    RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
-    SetValueToCoord(val, value, true);
-    aList->AppendCSSValue(val.forget());
-  };
-  appendValue(top);
-  if (top != right || top != bottom || top != left) {
-    appendValue(right);
-    if (top != bottom || right != left) {
-      appendValue(bottom);
-      if (right != left) {
-        appendValue(left);
-      }
-    }
-  }
-}
-
 already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetHeight() {
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
 
   bool calcHeight = false;
 
   if (mInnerFrame) {
     calcHeight = true;
 
@@ -2263,99 +2212,16 @@ void nsComputedDOMStyle::SetValueToLengt
     val->SetPercent(aLength.Percentage());
     val->GetCssText(tmp);
     result.Append(tmp);
   }
   result.Append(')');
   aValue->SetString(result);
 }
 
-void nsComputedDOMStyle::SetValueToCoord(
-    nsROCSSPrimitiveValue* aValue, const nsStyleCoord& aCoord,
-    bool aClampNegativeCalc, PercentageBaseGetter aPercentageBaseGetter,
-    const KTableEntry aTable[]) {
-  MOZ_ASSERT(aValue, "Must have a value to work with");
-
-  switch (aCoord.GetUnit()) {
-    case eStyleUnit_Normal:
-      aValue->SetIdent(eCSSKeyword_normal);
-      break;
-
-    case eStyleUnit_Auto:
-      aValue->SetIdent(eCSSKeyword_auto);
-      break;
-
-    case eStyleUnit_Percent: {
-      nscoord percentageBase;
-      if (aPercentageBaseGetter &&
-          (this->*aPercentageBaseGetter)(percentageBase)) {
-        nscoord val =
-            NSCoordSaturatingMultiply(percentageBase, aCoord.GetPercentValue());
-        aValue->SetAppUnits(val);
-      } else {
-        aValue->SetPercent(aCoord.GetPercentValue());
-      }
-    } break;
-
-    case eStyleUnit_Factor:
-      aValue->SetNumber(aCoord.GetFactorValue());
-      break;
-
-    case eStyleUnit_Coord: {
-      nscoord val = aCoord.GetCoordValue();
-      aValue->SetAppUnits(val);
-    } break;
-
-    case eStyleUnit_Integer:
-      aValue->SetNumber(aCoord.GetIntValue());
-      break;
-
-    case eStyleUnit_Enumerated:
-      NS_ASSERTION(aTable, "Must have table to handle this case");
-      aValue->SetIdent(
-          nsCSSProps::ValueToKeywordEnum(aCoord.GetIntValue(), aTable));
-      break;
-
-    case eStyleUnit_None:
-      aValue->SetIdent(eCSSKeyword_none);
-      break;
-
-    case eStyleUnit_Calc:
-      nscoord percentageBase;
-      if (!aCoord.CalcHasPercent()) {
-        nscoord val = aCoord.ComputeCoordPercentCalc(0);
-        if (aClampNegativeCalc && val < 0) {
-          MOZ_ASSERT(aCoord.IsCalcUnit(), "parser should have rejected value");
-          val = 0;
-        }
-        aValue->SetAppUnits(val);
-      } else if (aPercentageBaseGetter &&
-                 (this->*aPercentageBaseGetter)(percentageBase)) {
-        nscoord val = aCoord.ComputeCoordPercentCalc(percentageBase);
-        if (aClampNegativeCalc && val < 0) {
-          MOZ_ASSERT(aCoord.IsCalcUnit(), "parser should have rejected value");
-          val = 0;
-        }
-        aValue->SetAppUnits(val);
-      } else {
-        nsStyleCoord::Calc* calc = aCoord.GetCalcValue();
-        SetValueToCalc(calc, aValue);
-      }
-      break;
-
-    case eStyleUnit_Degree:
-      aValue->SetDegree(aCoord.GetAngleValue());
-      break;
-
-    default:
-      NS_ERROR("Can't handle this unit");
-      break;
-  }
-}
-
 nscoord nsComputedDOMStyle::StyleCoordToNSCoord(
     const LengthPercentage& aCoord, PercentageBaseGetter aPercentageBaseGetter,
     nscoord aDefaultValue, bool aClampNegativeCalc) {
   MOZ_ASSERT(aPercentageBaseGetter, "Must have a percentage base getter");
   if (aCoord.ConvertsToLength()) {
     return aCoord.ToLength();
   }
   nscoord percentageBase;
@@ -2523,24 +2389,16 @@ already_AddRefed<CSSValue> nsComputedDOM
                                                        nsSize(0, 0));
 
   gfx::Matrix4x4 matrix = nsStyleTransformMatrix::ReadTransforms(
       aTransform, refBox, float(mozilla::AppUnitsPerCSSPixel()));
 
   return MatrixToCSSValue(matrix);
 }
 
-void nsComputedDOMStyle::SetCssTextToCoord(nsAString& aCssText,
-                                           const nsStyleCoord& aCoord,
-                                           bool aClampNegativeCalc) {
-  RefPtr<nsROCSSPrimitiveValue> value = new nsROCSSPrimitiveValue;
-  SetValueToCoord(value, aCoord, aClampNegativeCalc);
-  value->GetCssText(aCssText);
-}
-
 already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetMask() {
   const nsStyleSVGReset* svg = StyleSVGReset();
   const nsStyleImageLayers::Layer& firstLayer = svg->mMask.mLayers[0];
 
   // Mask is now a shorthand, but it used to be a longhand, so that we
   // need to support computed style for the cases where it used to be
   // a longhand.
   if (svg->mMask.mImageCount > 1 ||
--- a/layout/style/nsComputedDOMStyle.h
+++ b/layout/style/nsComputedDOMStyle.h
@@ -35,20 +35,18 @@ struct ComputedGridTrackInfo;
 }  // namespace mozilla
 
 struct ComputedStyleMap;
 struct nsCSSKTableEntry;
 class nsIFrame;
 class nsDOMCSSValueList;
 struct nsMargin;
 class nsROCSSPrimitiveValue;
-class nsStyleCoord;
 class nsStyleGradient;
 struct nsStyleImage;
-class nsStyleSides;
 
 class nsComputedDOMStyle final : public nsDOMCSSDeclaration,
                                  public nsStubMutationObserver {
  private:
   // Convenience typedefs:
   using KTableEntry = nsCSSKTableEntry;
   using CSSValue = mozilla::dom::CSSValue;
   using StyleGeometryBox = mozilla::StyleGeometryBox;
@@ -304,35 +302,16 @@ class nsComputedDOMStyle final : public 
                                   bool aClampNegativeCalc);
 
   void SetValueToMaxSize(nsROCSSPrimitiveValue* aValue, const StyleMaxSize&);
 
   void SetValueToExtremumLength(nsROCSSPrimitiveValue* aValue,
                                 StyleExtremumLength);
 
   /**
-   * Method to set aValue to aCoord.  If aCoord is a percentage value and
-   * aPercentageBaseGetter is not null, aPercentageBaseGetter is called.  If it
-   * returns true, the percentage base it outputs in its out param is used
-   * to compute an nscoord value.  If the getter is null or returns false,
-   * the percent value of aCoord is set as a percent value on aValue.  aTable,
-   * if not null, is the keyword table to handle eStyleUnit_Enumerated.  When
-   * calling SetAppUnits on aValue (for coord or percent values), the value
-   * passed in will be clamped to be no less than aMinAppUnits and no more than
-   * aMaxAppUnits.
-   *
-   * XXXbz should caller pass in some sort of bitfield indicating which units
-   * can be expected or something?
-   */
-  void SetValueToCoord(nsROCSSPrimitiveValue* aValue,
-                       const nsStyleCoord& aCoord, bool aClampNegativeCalc,
-                       PercentageBaseGetter aPercentageBaseGetter = nullptr,
-                       const KTableEntry aTable[] = nullptr);
-
-  /**
    * If aCoord is a eStyleUnit_Coord returns the nscoord.  If it's
    * eStyleUnit_Percent, attempts to resolve the percentage base and returns
    * the resulting nscoord.  If it's some other unit or a percentage base can't
    * be determined, returns aDefaultValue.
    */
   nscoord StyleCoordToNSCoord(const LengthPercentage& aCoord,
                               PercentageBaseGetter aPercentageBaseGetter,
                               nscoord aDefaultValue, bool aClampNegativeCalc);
@@ -343,35 +322,25 @@ class nsComputedDOMStyle final : public 
     if (aCoord.IsLengthPercentage()) {
       return StyleCoordToNSCoord(aCoord.AsLengthPercentage(),
                                  aPercentageBaseGetter, aDefaultValue,
                                  aClampNegativeCalc);
     }
     return aDefaultValue;
   }
 
-  /**
-   * Append coord values from four sides. It omits values when possible.
-   */
-  void AppendFourSideCoordValues(nsDOMCSSValueList* aList,
-                                 const nsStyleSides& aValues);
-
   bool GetCBContentWidth(nscoord& aWidth);
   bool GetCBContentHeight(nscoord& aHeight);
   bool GetCBPaddingRectWidth(nscoord& aWidth);
   bool GetCBPaddingRectHeight(nscoord& aHeight);
   bool GetScrollFrameContentWidth(nscoord& aWidth);
   bool GetScrollFrameContentHeight(nscoord& aHeight);
   bool GetFrameBorderRectWidth(nscoord& aWidth);
   bool GetFrameBorderRectHeight(nscoord& aHeight);
 
-  /* Helper functions for computing and serializing a nsStyleCoord. */
-  void SetCssTextToCoord(nsAString& aCssText, const nsStyleCoord& aCoord,
-                         bool aClampNegativeCalc);
-
   // Find out if we can safely skip flushing (i.e. pending restyles do not
   // affect mElement).
   bool NeedsToFlush() const;
 
   static ComputedStyleMap* GetComputedStyleMap();
 
   // We don't really have a good immutable representation of "presentation".
   // Given the way GetComputedStyle is currently used, we should just grab the
deleted file mode 100644
--- a/layout/style/nsStyleCoord.cpp
+++ /dev/null
@@ -1,297 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/. */
-
-/* representation of length values in computed style data */
-
-#include "mozilla/HashFunctions.h"
-#include "mozilla/PodOperations.h"
-
-// nsStyleCoord.h must not be the first header in a unified source file,
-// otherwise it may not build with MSVC due to a bug in our STL wrapper.
-// See bug 1331102.
-#include "nsStyleCoord.h"
-
-using namespace mozilla;
-
-nsStyleCoord::nsStyleCoord(nsStyleUnit aUnit) : mUnit(aUnit) {
-  NS_ASSERTION(aUnit < eStyleUnit_Percent, "not a valueless unit");
-  if (aUnit >= eStyleUnit_Percent) {
-    mUnit = eStyleUnit_Null;
-  }
-  mValue.mInt = 0;
-}
-
-nsStyleCoord::nsStyleCoord(int32_t aValue, nsStyleUnit aUnit) : mUnit(aUnit) {
-  // if you want to pass in eStyleUnit_Coord, don't. instead, use the
-  // constructor just above this one... MMP
-  NS_ASSERTION(
-      (aUnit == eStyleUnit_Enumerated) || (aUnit == eStyleUnit_Integer),
-      "not an int value");
-  if ((aUnit == eStyleUnit_Enumerated) || (aUnit == eStyleUnit_Integer)) {
-    mValue.mInt = aValue;
-  } else {
-    mUnit = eStyleUnit_Null;
-    mValue.mInt = 0;
-  }
-}
-
-nsStyleCoord::nsStyleCoord(float aValue, nsStyleUnit aUnit) : mUnit(aUnit) {
-  if (aUnit < eStyleUnit_Percent || aUnit >= eStyleUnit_Coord) {
-    MOZ_ASSERT_UNREACHABLE("not a float value");
-    mUnit = eStyleUnit_Null;
-    mValue.mInt = 0;
-  } else {
-    mValue.mFloat = aValue;
-  }
-}
-
-bool nsStyleCoord::operator==(const nsStyleCoord& aOther) const {
-  if (mUnit != aOther.mUnit) {
-    return false;
-  }
-  switch (mUnit) {
-    case eStyleUnit_Null:
-    case eStyleUnit_Normal:
-    case eStyleUnit_Auto:
-    case eStyleUnit_None:
-      return true;
-    case eStyleUnit_Percent:
-    case eStyleUnit_Factor:
-    case eStyleUnit_Degree:
-    case eStyleUnit_FlexFraction:
-      return mValue.mFloat == aOther.mValue.mFloat;
-    case eStyleUnit_Coord:
-    case eStyleUnit_Integer:
-    case eStyleUnit_Enumerated:
-      return mValue.mInt == aOther.mValue.mInt;
-    case eStyleUnit_Calc:
-      return *this->GetCalcValue() == *aOther.GetCalcValue();
-  }
-  MOZ_ASSERT(false, "unexpected unit");
-  return false;
-}
-
-void nsStyleCoord::Reset() { Reset(mUnit, mValue); }
-
-void nsStyleCoord::SetCoordValue(nscoord aValue) {
-  Reset();
-  mUnit = eStyleUnit_Coord;
-  mValue.mInt = aValue;
-}
-
-void nsStyleCoord::SetIntValue(int32_t aValue, nsStyleUnit aUnit) {
-  NS_ASSERTION(
-      (aUnit == eStyleUnit_Enumerated) || (aUnit == eStyleUnit_Integer),
-      "not an int value");
-  Reset();
-  if ((aUnit == eStyleUnit_Enumerated) || (aUnit == eStyleUnit_Integer)) {
-    mUnit = aUnit;
-    mValue.mInt = aValue;
-  }
-}
-
-void nsStyleCoord::SetPercentValue(float aValue) {
-  Reset();
-  mUnit = eStyleUnit_Percent;
-  mValue.mFloat = aValue;
-}
-
-void nsStyleCoord::SetFactorValue(float aValue) {
-  Reset();
-  mUnit = eStyleUnit_Factor;
-  mValue.mFloat = aValue;
-}
-
-void nsStyleCoord::SetFlexFractionValue(float aValue) {
-  Reset();
-  mUnit = eStyleUnit_FlexFraction;
-  mValue.mFloat = aValue;
-}
-
-void nsStyleCoord::SetCalcValue(Calc* aValue) {
-  Reset();
-  mUnit = eStyleUnit_Calc;
-  mValue.mPointer = aValue;
-  aValue->AddRef();
-}
-
-void nsStyleCoord::SetNormalValue() {
-  Reset();
-  mUnit = eStyleUnit_Normal;
-  mValue.mInt = 0;
-}
-
-void nsStyleCoord::SetAutoValue() {
-  Reset();
-  mUnit = eStyleUnit_Auto;
-  mValue.mInt = 0;
-}
-
-void nsStyleCoord::SetNoneValue() {
-  Reset();
-  mUnit = eStyleUnit_None;
-  mValue.mInt = 0;
-}
-
-// accessors that are not inlined
-
-double nsStyleCoord::GetAngleValueInDegrees() const {
-  // Note that this extends the value from float to double.
-  return GetAngleValue();
-}
-
-double nsStyleCoord::GetAngleValueInRadians() const {
-  return GetAngleValueInDegrees() * M_PI / 180.0;
-}
-
-nscoord nsStyleCoord::ComputeComputedCalc(nscoord aPercentageBasis) const {
-  Calc* calc = GetCalcValue();
-  return calc->mLength +
-         NSToCoordFloorClamped(aPercentageBasis * calc->mPercent);
-}
-
-nscoord nsStyleCoord::ComputeCoordPercentCalc(nscoord aPercentageBasis) const {
-  switch (GetUnit()) {
-    case eStyleUnit_Coord:
-      return GetCoordValue();
-    case eStyleUnit_Percent:
-      return NSToCoordFloorClamped(aPercentageBasis * GetPercentValue());
-    case eStyleUnit_Calc:
-      return ComputeComputedCalc(aPercentageBasis);
-    default:
-      MOZ_ASSERT_UNREACHABLE("Unexpected unit!");
-      return 0;
-  }
-}
-
-nsStyleSides::nsStyleSides() {
-  NS_FOR_CSS_SIDES(i) { mUnits[i] = eStyleUnit_Null; }
-  mozilla::PodArrayZero(mValues);
-}
-
-nsStyleSides::nsStyleSides(const nsStyleSides& aOther) {
-  NS_FOR_CSS_SIDES(i) { mUnits[i] = eStyleUnit_Null; }
-  *this = aOther;
-}
-
-nsStyleSides::~nsStyleSides() { Reset(); }
-
-nsStyleSides& nsStyleSides::operator=(const nsStyleSides& aCopy) {
-  if (this != &aCopy) {
-    NS_FOR_CSS_SIDES(i) {
-      nsStyleCoord::SetValue(mUnits[i], mValues[i], aCopy.mUnits[i],
-                             aCopy.mValues[i]);
-    }
-  }
-  return *this;
-}
-
-bool nsStyleSides::operator==(const nsStyleSides& aOther) const {
-  NS_FOR_CSS_SIDES(i) {
-    if (nsStyleCoord(mValues[i], (nsStyleUnit)mUnits[i]) !=
-        nsStyleCoord(aOther.mValues[i], (nsStyleUnit)aOther.mUnits[i])) {
-      return false;
-    }
-  }
-  return true;
-}
-
-void nsStyleSides::Reset() {
-  NS_FOR_CSS_SIDES(i) { nsStyleCoord::Reset(mUnits[i], mValues[i]); }
-}
-
-// Validation of SideIsVertical.
-#define CASE(side, result) \
-  static_assert(SideIsVertical(side) == result, "SideIsVertical is wrong")
-CASE(eSideTop, false);
-CASE(eSideRight, true);
-CASE(eSideBottom, false);
-CASE(eSideLeft, true);
-#undef CASE
-
-// Validation of HalfCornerIsX.
-#define CASE(corner, result) \
-  static_assert(HalfCornerIsX(corner) == result, "HalfCornerIsX is wrong")
-CASE(eCornerTopLeftX, true);
-CASE(eCornerTopLeftY, false);
-CASE(eCornerTopRightX, true);
-CASE(eCornerTopRightY, false);
-CASE(eCornerBottomRightX, true);
-CASE(eCornerBottomRightY, false);
-CASE(eCornerBottomLeftX, true);
-CASE(eCornerBottomLeftY, false);
-#undef CASE
-
-// Validation of HalfToFullCorner.
-#define CASE(corner, result)                        \
-  static_assert(HalfToFullCorner(corner) == result, \
-                "HalfToFullCorner is "              \
-                "wrong")
-CASE(eCornerTopLeftX, eCornerTopLeft);
-CASE(eCornerTopLeftY, eCornerTopLeft);
-CASE(eCornerTopRightX, eCornerTopRight);
-CASE(eCornerTopRightY, eCornerTopRight);
-CASE(eCornerBottomRightX, eCornerBottomRight);
-CASE(eCornerBottomRightY, eCornerBottomRight);
-CASE(eCornerBottomLeftX, eCornerBottomLeft);
-CASE(eCornerBottomLeftY, eCornerBottomLeft);
-#undef CASE
-
-// Validation of FullToHalfCorner.
-#define CASE(corner, vert, result)                        \
-  static_assert(FullToHalfCorner(corner, vert) == result, \
-                "FullToHalfCorner is wrong")
-CASE(eCornerTopLeft, false, eCornerTopLeftX);
-CASE(eCornerTopLeft, true, eCornerTopLeftY);
-CASE(eCornerTopRight, false, eCornerTopRightX);
-CASE(eCornerTopRight, true, eCornerTopRightY);
-CASE(eCornerBottomRight, false, eCornerBottomRightX);
-CASE(eCornerBottomRight, true, eCornerBottomRightY);
-CASE(eCornerBottomLeft, false, eCornerBottomLeftX);
-CASE(eCornerBottomLeft, true, eCornerBottomLeftY);
-#undef CASE
-
-// Validation of SideToFullCorner.
-#define CASE(side, second, result)                        \
-  static_assert(SideToFullCorner(side, second) == result, \
-                "SideToFullCorner is wrong")
-CASE(eSideTop, false, eCornerTopLeft);
-CASE(eSideTop, true, eCornerTopRight);
-
-CASE(eSideRight, false, eCornerTopRight);
-CASE(eSideRight, true, eCornerBottomRight);
-
-CASE(eSideBottom, false, eCornerBottomRight);
-CASE(eSideBottom, true, eCornerBottomLeft);
-
-CASE(eSideLeft, false, eCornerBottomLeft);
-CASE(eSideLeft, true, eCornerTopLeft);
-#undef CASE
-
-// Validation of SideToHalfCorner.
-#define CASE(side, second, parallel, result)                        \
-  static_assert(SideToHalfCorner(side, second, parallel) == result, \
-                "SideToHalfCorner is wrong")
-CASE(eSideTop, false, true, eCornerTopLeftX);
-CASE(eSideTop, false, false, eCornerTopLeftY);
-CASE(eSideTop, true, true, eCornerTopRightX);
-CASE(eSideTop, true, false, eCornerTopRightY);
-
-CASE(eSideRight, false, false, eCornerTopRightX);
-CASE(eSideRight, false, true, eCornerTopRightY);
-CASE(eSideRight, true, false, eCornerBottomRightX);
-CASE(eSideRight, true, true, eCornerBottomRightY);
-
-CASE(eSideBottom, false, true, eCornerBottomRightX);
-CASE(eSideBottom, false, false, eCornerBottomRightY);
-CASE(eSideBottom, true, true, eCornerBottomLeftX);
-CASE(eSideBottom, true, false, eCornerBottomLeftY);
-
-CASE(eSideLeft, false, false, eCornerBottomLeftX);
-CASE(eSideLeft, false, true, eCornerBottomLeftY);
-CASE(eSideLeft, true, false, eCornerTopLeftX);
-CASE(eSideLeft, true, true, eCornerTopLeftY);
-#undef CASE
deleted file mode 100644
--- a/layout/style/nsStyleCoord.h
+++ /dev/null
@@ -1,805 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/. */
-
-/* representation of length values in computed style data */
-
-#ifndef nsStyleCoord_h___
-#define nsStyleCoord_h___
-
-#include <type_traits>
-
-#include "mozilla/EnumTypeTraits.h"
-#include "mozilla/gfx/Types.h"
-#include "Units.h"
-#include "nsCoord.h"
-#include "nsISupportsImpl.h"
-#include "nsStyleConsts.h"
-
-namespace mozilla {
-
-class WritingMode;
-
-// Logical axis, edge, side and corner constants for use in various places.
-enum LogicalAxis { eLogicalAxisBlock = 0x0, eLogicalAxisInline = 0x1 };
-enum LogicalEdge { eLogicalEdgeStart = 0x0, eLogicalEdgeEnd = 0x1 };
-enum LogicalSide : uint8_t {
-  eLogicalSideBStart = (eLogicalAxisBlock << 1) | eLogicalEdgeStart,   // 0x0
-  eLogicalSideBEnd = (eLogicalAxisBlock << 1) | eLogicalEdgeEnd,       // 0x1
-  eLogicalSideIStart = (eLogicalAxisInline << 1) | eLogicalEdgeStart,  // 0x2
-  eLogicalSideIEnd = (eLogicalAxisInline << 1) | eLogicalEdgeEnd       // 0x3
-};
-
-enum LogicalCorner {
-  eLogicalCornerBStartIStart = 0,
-  eLogicalCornerBStartIEnd = 1,
-  eLogicalCornerBEndIEnd = 2,
-  eLogicalCornerBEndIStart = 3
-};
-
-using LengthPercentage = StyleLengthPercentage;
-using LengthPercentageOrAuto = StyleLengthPercentageOrAuto;
-using NonNegativeLengthPercentage = StyleNonNegativeLengthPercentage;
-using NonNegativeLengthPercentageOrAuto =
-    StyleNonNegativeLengthPercentageOrAuto;
-using NonNegativeLengthPercentageOrNormal =
-    StyleNonNegativeLengthPercentageOrNormal;
-using Length = StyleLength;
-using LengthOrAuto = StyleLengthOrAuto;
-using NonNegativeLength = StyleNonNegativeLength;
-using NonNegativeLengthOrAuto = StyleNonNegativeLengthOrAuto;
-using BorderRadius = StyleBorderRadius;
-
-bool StyleCSSPixelLength::IsZero() const { return _0 == 0.0f; }
-
-nscoord StyleCSSPixelLength::ToAppUnits() const {
-  // We want to resolve the length part of the calc() expression rounding 0.5
-  // away from zero, instead of the default behavior of
-  // NSToCoordRound{,WithClamp} which do floor(x + 0.5).
-  //
-  // This is what the rust code in the app_units crate does, and not doing this
-  // would regress bug 1323735, for example.
-  //
-  // FIXME(emilio, bug 1528114): Probably we should do something smarter.
-  float length = _0 * float(mozilla::AppUnitsPerCSSPixel());
-  if (length >= nscoord_MAX) {
-    return nscoord_MAX;
-  }
-  if (length <= nscoord_MIN) {
-    return nscoord_MIN;
-  }
-  return NSToIntRound(length);
-}
-
-constexpr LengthPercentage LengthPercentage::Zero() {
-  return {{0.}, {0.}, StyleAllowedNumericType::All, false, false};
-}
-
-LengthPercentage LengthPercentage::FromPixels(CSSCoord aCoord) {
-  return {{aCoord}, {0.}, StyleAllowedNumericType::All, false, false};
-}
-
-LengthPercentage LengthPercentage::FromAppUnits(nscoord aCoord) {
-  return LengthPercentage::FromPixels(CSSPixel::FromAppUnits(aCoord));
-}
-
-LengthPercentage LengthPercentage::FromPercentage(float aPercentage) {
-  return {{0.}, {aPercentage}, StyleAllowedNumericType::All, true, false};
-}
-
-CSSCoord LengthPercentage::LengthInCSSPixels() const { return length._0; }
-
-float LengthPercentage::Percentage() const { return percentage._0; }
-
-bool LengthPercentage::HasPercent() const { return has_percentage; }
-
-bool LengthPercentage::ConvertsToLength() const { return !HasPercent(); }
-
-nscoord LengthPercentage::ToLength() const {
-  MOZ_ASSERT(ConvertsToLength());
-  return length.ToAppUnits();
-}
-
-bool LengthPercentage::ConvertsToPercentage() const {
-  return has_percentage && length.IsZero();
-}
-
-float LengthPercentage::ToPercentage() const {
-  MOZ_ASSERT(ConvertsToPercentage());
-  return Percentage();
-}
-
-bool LengthPercentage::HasLengthAndPercentage() const {
-  return !ConvertsToLength() && !ConvertsToPercentage();
-}
-
-bool LengthPercentage::IsDefinitelyZero() const {
-  return length.IsZero() && Percentage() == 0.0f;
-}
-
-CSSCoord LengthPercentage::ResolveToCSSPixels(CSSCoord aPercentageBasis) const {
-  return LengthInCSSPixels() + Percentage() * aPercentageBasis;
-}
-
-template <typename T>
-CSSCoord LengthPercentage::ResolveToCSSPixelsWith(T aPercentageGetter) const {
-  static_assert(std::is_same<decltype(aPercentageGetter()), CSSCoord>::value,
-                "Should return CSS pixels");
-  if (ConvertsToLength()) {
-    return LengthInCSSPixels();
-  }
-  return ResolveToCSSPixels(aPercentageGetter());
-}
-
-template <typename T, typename U>
-nscoord LengthPercentage::Resolve(T aPercentageGetter,
-                                  U aPercentageRounder) const {
-  static_assert(std::is_same<decltype(aPercentageGetter()), nscoord>::value,
-                "Should return app units");
-  static_assert(
-      std::is_same<decltype(aPercentageRounder(1.0f)), nscoord>::value,
-      "Should return app units");
-  if (ConvertsToLength()) {
-    return ToLength();
-  }
-  nscoord basis = aPercentageGetter();
-  return length.ToAppUnits() + aPercentageRounder(basis * Percentage());
-}
-
-nscoord LengthPercentage::Resolve(nscoord aPercentageBasis) const {
-  return Resolve([=] { return aPercentageBasis; }, NSToCoordFloorClamped);
-}
-
-template <typename T>
-nscoord LengthPercentage::Resolve(T aPercentageGetter) const {
-  static_assert(std::is_same<decltype(aPercentageGetter()), nscoord>::value,
-                "Should return app units");
-  return Resolve(aPercentageGetter, NSToCoordFloorClamped);
-}
-
-template <typename T>
-nscoord LengthPercentage::Resolve(nscoord aPercentageBasis,
-                                  T aPercentageRounder) const {
-  return Resolve([=] { return aPercentageBasis; }, aPercentageRounder);
-}
-
-#define IMPL_LENGTHPERCENTAGE_FORWARDS(ty_)                                 \
-  template <>                                                               \
-  inline bool ty_::HasPercent() const {                                     \
-    return IsLengthPercentage() && AsLengthPercentage().HasPercent();       \
-  }                                                                         \
-  template <>                                                               \
-  inline bool ty_::ConvertsToLength() const {                               \
-    return IsLengthPercentage() && AsLengthPercentage().ConvertsToLength(); \
-  }                                                                         \
-  template <>                                                               \
-  inline bool ty_::HasLengthAndPercentage() const {                         \
-    return IsLengthPercentage() &&                                          \
-           AsLengthPercentage().HasLengthAndPercentage();                   \
-  }                                                                         \
-  template <>                                                               \
-  inline nscoord ty_::ToLength() const {                                    \
-    MOZ_ASSERT(ConvertsToLength());                                         \
-    return AsLengthPercentage().ToLength();                                 \
-  }                                                                         \
-  template <>                                                               \
-  inline bool ty_::ConvertsToPercentage() const {                           \
-    return IsLengthPercentage() &&                                          \
-           AsLengthPercentage().ConvertsToPercentage();                     \
-  }                                                                         \
-  template <>                                                               \
-  inline float ty_::ToPercentage() const {                                  \
-    MOZ_ASSERT(ConvertsToPercentage());                                     \
-    return AsLengthPercentage().ToPercentage();                             \
-  }
-
-IMPL_LENGTHPERCENTAGE_FORWARDS(LengthPercentageOrAuto)
-IMPL_LENGTHPERCENTAGE_FORWARDS(StyleSize)
-IMPL_LENGTHPERCENTAGE_FORWARDS(StyleMaxSize)
-
-template <>
-inline bool LengthOrAuto::IsLength() const {
-  return IsLengthPercentage();
-}
-
-template <>
-inline const Length& LengthOrAuto::AsLength() const {
-  return AsLengthPercentage();
-}
-
-template <>
-inline bool StyleFlexBasis::IsAuto() const {
-  return IsSize() && AsSize().IsAuto();
-}
-
-template <>
-inline bool StyleSize::BehavesLikeInitialValueOnBlockAxis() const {
-  return IsAuto() || IsExtremumLength();
-}
-
-template <>
-inline bool StyleMaxSize::BehavesLikeInitialValueOnBlockAxis() const {
-  return IsNone() || IsExtremumLength();
-}
-
-template <>
-inline bool StyleBackgroundSize::IsInitialValue() const {
-  return IsExplicitSize() && explicit_size.width.IsAuto() &&
-         explicit_size.height.IsAuto();
-}
-
-template <typename T>
-const T& StyleRect<T>::Get(mozilla::Side aSide) const {
-  static_assert(sizeof(StyleRect<T>) == sizeof(T) * 4, "");
-  static_assert(alignof(StyleRect<T>) == alignof(T), "");
-  return reinterpret_cast<const T*>(this)[aSide];
-}
-
-template <typename T>
-template <typename Predicate>
-bool StyleRect<T>::All(Predicate aPredicate) const {
-  return aPredicate(_0) && aPredicate(_1) && aPredicate(_2) && aPredicate(_3);
-}
-
-template <typename T>
-template <typename Predicate>
-bool StyleRect<T>::Any(Predicate aPredicate) const {
-  return aPredicate(_0) || aPredicate(_1) || aPredicate(_2) || aPredicate(_3);
-}
-
-template <>
-inline const LengthPercentage& BorderRadius::Get(HalfCorner aCorner) const {
-  static_assert(sizeof(BorderRadius) == sizeof(LengthPercentage) * 8, "");
-  static_assert(alignof(BorderRadius) == alignof(LengthPercentage), "");
-  auto* self = reinterpret_cast<const LengthPercentage*>(this);
-  return self[aCorner];
-}
-
-template <>
-inline bool StyleTrackBreadth::HasPercent() const {
-  return IsBreadth() && AsBreadth().HasPercent();
-}
-
-}  // namespace mozilla
-
-enum nsStyleUnit : uint8_t {
-  eStyleUnit_Null = 0,           // (no value) value is not specified
-  eStyleUnit_Normal = 1,         // (no value)
-  eStyleUnit_Auto = 2,           // (no value)
-  eStyleUnit_None = 3,           // (no value)
-  eStyleUnit_Percent = 10,       // (float) 1.0 == 100%
-  eStyleUnit_Factor = 11,        // (float) a multiplier
-  eStyleUnit_Degree = 12,        // (float) angle in degrees
-  eStyleUnit_FlexFraction = 16,  // (float) <flex> in fr units
-  eStyleUnit_Coord = 20,         // (nscoord) value is twips
-  eStyleUnit_Integer = 30,       // (int) value is simple integer
-  eStyleUnit_Enumerated = 32,    // (int) value has enumerated meaning
-
-  // The following are reference counted allocated types.
-  eStyleUnit_Calc = 40,  // (Calc*) calc() toplevel; always present
-                         // to distinguish 50% from calc(50%), etc.
-
-  eStyleUnit_MAX = 40  // highest valid nsStyleUnit value
-};
-
-typedef union {
-  int32_t mInt;  // nscoord is a int32_t for now
-  float mFloat;
-  // An mPointer is a reference counted pointer.  Currently this can only
-  // ever be an nsStyleCoord::Calc*.
-  void* mPointer;
-} nsStyleUnion;
-
-/**
- * Class that hold a single size specification used by the style
- * system.  The size specification consists of two parts -- a number
- * and a unit.  The number is an integer, a floating point value, an
- * nscoord, or undefined, and the unit is an nsStyleUnit.  Checking
- * the unit is a must before asking for the value in any particular
- * form.
- */
-/** <div rustbindgen private accessor="unsafe"></div> */
-class nsStyleCoord {
- public:
-  // Non-reference counted calc() value.  See nsStyleStruct.h for some uses
-  // of this.
-  struct CalcValue {
-    // Every calc() expression evaluates to a length plus a percentage.
-    nscoord mLength;
-    float mPercent;
-    bool mHasPercent;  // whether there was any % syntax, even if 0
-
-    bool operator==(const CalcValue& aOther) const {
-      return mLength == aOther.mLength && mPercent == aOther.mPercent &&
-             mHasPercent == aOther.mHasPercent;
-    }
-    bool operator!=(const CalcValue& aOther) const {
-      return !(*this == aOther);
-    }
-
-    nscoord ToLength() const {
-      MOZ_ASSERT(!mHasPercent);
-      return mLength;
-    }
-
-    // If this returns true the value is definitely zero. It it returns false
-    // it might be zero. So it's best used for conservative optimization.
-    bool IsDefinitelyZero() const { return mLength == 0 && mPercent == 0; }
-  };
-
-  // Reference counted calc() value.  This is the type that is used to store
-  // the calc() value in nsStyleCoord.
-  struct Calc final : public CalcValue {
-    NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Calc)
-    Calc() {}
-
-   private:
-    Calc(const Calc&) = delete;
-    ~Calc() {}
-    Calc& operator=(const Calc&) = delete;
-  };
-
-  explicit nsStyleCoord(nsStyleUnit aUnit = eStyleUnit_Null);
-  enum CoordConstructorType { CoordConstructor };
-  inline nsStyleCoord(nscoord aValue, CoordConstructorType);
-  nsStyleCoord(int32_t aValue, nsStyleUnit aUnit);
-  nsStyleCoord(float aValue, nsStyleUnit aUnit);
-  inline nsStyleCoord(const nsStyleCoord& aCopy);
-  inline nsStyleCoord(const nsStyleUnion& aValue, nsStyleUnit aUnit);
-  ~nsStyleCoord() { Reset(); }
-
-  nsStyleCoord& operator=(const nsStyleCoord& aOther) {
-    if (this != &aOther) {
-      SetValue(mUnit, mValue, aOther);
-    }
-    return *this;
-  }
-  bool operator==(const nsStyleCoord& aOther) const;
-  bool operator!=(const nsStyleCoord& aOther) const;
-
-  nsStyleUnit GetUnit() const {
-    NS_ASSERTION(mUnit != eStyleUnit_Null, "reading uninitialized value");
-    return mUnit;
-  }
-
-  // This is especially useful to check if it is the property's initial value
-  // or keyword for sizing properties.
-  bool IsAutoOrEnum() const {
-    // The initial value of width/height and min-width/min-height is `auto`.
-    // The initial value of max-width/max-height is `none`.
-    return mUnit == eStyleUnit_Auto || mUnit == eStyleUnit_None ||
-           mUnit == eStyleUnit_Enumerated;
-  }
-
-  bool IsAngleValue() const { return eStyleUnit_Degree == mUnit; }
-
-  static bool IsCalcUnit(nsStyleUnit aUnit) { return aUnit == eStyleUnit_Calc; }
-
-  static bool IsPointerUnit(nsStyleUnit aUnit) { return IsCalcUnit(aUnit); }
-
-  bool IsCalcUnit() const { return IsCalcUnit(mUnit); }
-
-  bool IsPointerValue() const { return IsPointerUnit(mUnit); }
-
-  bool IsCoordPercentCalcUnit() const {
-    return mUnit == eStyleUnit_Coord || mUnit == eStyleUnit_Percent ||
-           IsCalcUnit();
-  }
-
-  // Does this calc() expression have any percentages inside it?  Can be
-  // called only when IsCalcUnit() is true.
-  bool CalcHasPercent() const { return GetCalcValue()->mHasPercent; }
-
-  bool HasPercent() const {
-    return mUnit == eStyleUnit_Percent || (IsCalcUnit() && CalcHasPercent());
-  }
-
-  static bool ConvertsToPercent(const nsStyleUnit aUnit,
-                                const nsStyleUnion aValue) {
-    if (aUnit == eStyleUnit_Percent) {
-      return true;
-    }
-    if (!IsCalcUnit(aUnit)) {
-      return false;
-    }
-    auto* calc = AsCalcValue(aValue);
-    return calc->mLength == 0 && calc->mHasPercent;
-  }
-
-  bool ConvertsToPercent() const { return ConvertsToPercent(mUnit, mValue); }
-
-  float ToPercent() const {
-    MOZ_ASSERT(ConvertsToPercent());
-    if (IsCalcUnit()) {
-      MOZ_ASSERT(CalcHasPercent() && GetCalcValue()->mLength == 0);
-      return GetCalcValue()->mPercent;
-    }
-    return mValue.mFloat;
-  }
-
-  static bool ConvertsToLength(const nsStyleUnit aUnit,
-                               const nsStyleUnion aValue) {
-    return aUnit == eStyleUnit_Coord ||
-           (IsCalcUnit(aUnit) && !AsCalcValue(aValue)->mHasPercent);
-  }
-
-  bool ConvertsToLength() const { return ConvertsToLength(mUnit, mValue); }
-
-  static nscoord ToLength(nsStyleUnit aUnit, nsStyleUnion aValue) {
-    MOZ_ASSERT(ConvertsToLength(aUnit, aValue));
-    if (IsCalcUnit(aUnit)) {
-      // Note: ToLength asserts !mHasPercent
-      return AsCalcValue(aValue)->ToLength();
-    }
-    MOZ_ASSERT(aUnit == eStyleUnit_Coord);
-    return aValue.mInt;
-  }
-
-  nscoord ToLength() const { return ToLength(GetUnit(), mValue); }
-
-  // Callers must verify IsCalcUnit before calling this function.
-  static Calc* AsCalcValue(nsStyleUnion aValue) {
-    return static_cast<Calc*>(aValue.mPointer);
-  }
-
-  // Compute the value that IsCalcUnit().
-  // @note the caller is expected to handle percentage of an indefinite size
-  // and NOT call this method with aPercentageBasis == NS_UNCONSTRAINEDSIZE.
-  // @note the return value may be negative, e.g. for "calc(a - b%)"
-  nscoord ComputeComputedCalc(nscoord aPercentageBasis) const;
-
-  // Compute the value that is either a coord, a percent, or a calc expression.
-  // @note the caller is expected to handle percentage of an indefinite size
-  // and NOT call this method with aPercentageBasis == NS_UNCONSTRAINEDSIZE.
-  // @note the return value may be negative, e.g. for "calc(a - b%)"
-  nscoord ComputeCoordPercentCalc(nscoord aPercentageBasis) const;
-
-  nscoord GetCoordValue() const;
-  int32_t GetIntValue() const;
-  float GetPercentValue() const;
-  float GetFactorValue() const;
-  float GetFactorOrPercentValue() const;
-  float GetAngleValue() const;
-  double GetAngleValueInDegrees() const;
-  double GetAngleValueInRadians() const;
-  float GetFlexFractionValue() const;
-  Calc* GetCalcValue() const;
-  template <typename T,
-            typename = typename std::enable_if<std::is_enum<T>::value>::type>
-  T GetEnumValue() const {
-    MOZ_ASSERT(GetUnit() == eStyleUnit_Enumerated,
-               "The unit must be eStyleUnit_Enumerated!");
-    return static_cast<T>(GetIntValue());
-  }
-
-  // Sets to null and releases any refcounted objects.  Only use this if the
-  // object is initialized (i.e. don't use it in nsStyleCoord constructors).
-  void Reset();
-
-  void SetCoordValue(nscoord aValue);
-  void SetIntValue(int32_t aValue, nsStyleUnit aUnit);
-  void SetPercentValue(float aValue);
-  void SetFactorValue(float aValue);
-  void SetFlexFractionValue(float aValue);
-  void SetNormalValue();
-  void SetAutoValue();
-  void SetNoneValue();
-  void SetCalcValue(Calc* aValue);
-  template <typename T,
-            typename = typename std::enable_if<std::is_enum<T>::value>::type>
-  void SetEnumValue(T aValue) {
-    static_assert(mozilla::EnumTypeFitsWithin<T, int32_t>::value,
-                  "aValue must be an enum that fits within mValue.mInt!");
-    SetIntValue(static_cast<int32_t>(aValue), eStyleUnit_Enumerated);
-  }
-
-  // Resets a coord represented by a unit/value pair.
-  static inline void Reset(nsStyleUnit& aUnit, nsStyleUnion& aValue);
-
-  // Sets a coord represented by a unit/value pair from a second
-  // unit/value pair.
-  static inline void SetValue(nsStyleUnit& aUnit, nsStyleUnion& aValue,
-                              nsStyleUnit aOtherUnit,
-                              const nsStyleUnion& aOtherValue);
-
-  // Sets a coord represented by a unit/value pair from an nsStyleCoord.
-  static inline void SetValue(nsStyleUnit& aUnit, nsStyleUnion& aValue,
-                              const nsStyleCoord& aOther);
-
-  // Like the above, but do not reset before setting.
-  static inline void InitWithValue(nsStyleUnit& aUnit, nsStyleUnion& aValue,
-                                   nsStyleUnit aOtherUnit,
-                                   const nsStyleUnion& aOtherValue);
-
-  static inline void InitWithValue(nsStyleUnit& aUnit, nsStyleUnion& aValue,
-                                   const nsStyleCoord& aOther);
-
- private:
-  nsStyleUnit mUnit;
-  nsStyleUnion mValue;
-};
-
-/**
- * Class that represents a set of top/right/bottom/left nsStyleCoords.
- * This is commonly used to hold the widths of the borders, margins,
- * or paddings of a box.
- */
-/** <div rustbindgen private accessor="unsafe"></div> */
-class nsStyleSides {
- public:
-  nsStyleSides();
-  nsStyleSides(const nsStyleSides&);
-  ~nsStyleSides();
-
-  nsStyleSides& operator=(const nsStyleSides& aCopy);
-  bool operator==(const nsStyleSides& aOther) const;
-  bool operator!=(const nsStyleSides& aOther) const;
-
-  inline nsStyleUnit GetUnit(mozilla::Side aSide) const;
-  inline nsStyleUnit GetLeftUnit() const;
-  inline nsStyleUnit GetTopUnit() const;
-  inline nsStyleUnit GetRightUnit() const;
-  inline nsStyleUnit GetBottomUnit() const;
-
-  inline nsStyleCoord Get(mozilla::Side aSide) const;
-  inline nsStyleCoord GetLeft() const;
-  inline nsStyleCoord GetTop() const;
-  inline nsStyleCoord GetRight() const;
-  inline nsStyleCoord GetBottom() const;
-
-  // Methods to access the units and values in terms of logical sides
-  // for a given writing mode.
-  // NOTE: The definitions are in WritingModes.h (after we have the full
-  // declaration of WritingMode available).
-  inline nsStyleUnit GetUnit(mozilla::WritingMode aWritingMode,
-                             mozilla::LogicalSide aSide) const;
-  inline nsStyleUnit GetIStartUnit(mozilla::WritingMode aWritingMode) const;
-  inline nsStyleUnit GetBStartUnit(mozilla::WritingMode aWritingMode) const;
-  inline nsStyleUnit GetIEndUnit(mozilla::WritingMode aWritingMode) const;
-  inline nsStyleUnit GetBEndUnit(mozilla::WritingMode aWritingMode) const;
-
-  // Return true if either the start or end side in the axis is 'auto'.
-  inline bool HasBlockAxisAuto(mozilla::WritingMode aWritingMode) const;
-  inline bool HasInlineAxisAuto(mozilla::WritingMode aWritingMode) const;
-
-  inline nsStyleCoord Get(mozilla::WritingMode aWritingMode,
-                          mozilla::LogicalSide aSide) const;
-  inline nsStyleCoord GetIStart(mozilla::WritingMode aWritingMode) const;
-  inline nsStyleCoord GetBStart(mozilla::WritingMode aWritingMode) const;
-  inline nsStyleCoord GetIEnd(mozilla::WritingMode aWritingMode) const;
-  inline nsStyleCoord GetBEnd(mozilla::WritingMode aWritingMode) const;
-
-  // Sets each side to null and releases any refcounted objects.  Only use this
-  // if the object is initialized (i.e. don't use it in nsStyleSides
-  // constructors).
-  void Reset();
-
-  inline void Set(mozilla::Side aSide, const nsStyleCoord& aCoord);
-  inline void SetLeft(const nsStyleCoord& aCoord);
-  inline void SetTop(const nsStyleCoord& aCoord);
-  inline void SetRight(const nsStyleCoord& aCoord);
-  inline void SetBottom(const nsStyleCoord& aCoord);
-
-  nscoord ToLength(mozilla::Side aSide) const {
-    return nsStyleCoord::ToLength(mUnits[aSide], mValues[aSide]);
-  }
-
-  bool ConvertsToLength() const {
-    NS_FOR_CSS_SIDES(side) {
-      if (!nsStyleCoord::ConvertsToLength(mUnits[side], mValues[side])) {
-        return false;
-      }
-    }
-    return true;
-  }
-
- protected:
-  nsStyleUnit mUnits[4];
-  nsStyleUnion mValues[4];
-};
-
-// -------------------------
-// nsStyleCoord inlines
-//
-inline nsStyleCoord::nsStyleCoord(nscoord aValue, CoordConstructorType)
-    : mUnit(eStyleUnit_Coord) {
-  mValue.mInt = aValue;
-}
-
-inline nsStyleCoord::nsStyleCoord(const nsStyleCoord& aCopy)
-    : mUnit(eStyleUnit_Null) {
-  InitWithValue(mUnit, mValue, aCopy);
-}
-
-inline nsStyleCoord::nsStyleCoord(const nsStyleUnion& aValue, nsStyleUnit aUnit)
-    : mUnit(eStyleUnit_Null) {
-  InitWithValue(mUnit, mValue, aUnit, aValue);
-}
-
-inline bool nsStyleCoord::operator!=(const nsStyleCoord& aOther) const {
-  return !((*this) == aOther);
-}
-
-inline nscoord nsStyleCoord::GetCoordValue() const {
-  NS_ASSERTION((mUnit == eStyleUnit_Coord), "not a coord value");
-  if (mUnit == eStyleUnit_Coord) {
-    return mValue.mInt;
-  }
-  return 0;
-}
-
-inline int32_t nsStyleCoord::GetIntValue() const {
-  NS_ASSERTION(
-      (mUnit == eStyleUnit_Enumerated) || (mUnit == eStyleUnit_Integer),
-      "not an int value");
-  if ((mUnit == eStyleUnit_Enumerated) || (mUnit == eStyleUnit_Integer)) {
-    return mValue.mInt;
-  }
-  return 0;
-}
-
-inline float nsStyleCoord::GetPercentValue() const {
-  NS_ASSERTION(mUnit == eStyleUnit_Percent, "not a percent value");
-  if (mUnit == eStyleUnit_Percent) {
-    return mValue.mFloat;
-  }
-  return 0.0f;
-}
-
-inline float nsStyleCoord::GetFactorValue() const {
-  NS_ASSERTION(mUnit == eStyleUnit_Factor, "not a factor value");
-  if (mUnit == eStyleUnit_Factor) {
-    return mValue.mFloat;
-  }
-  return 0.0f;
-}
-
-inline float nsStyleCoord::GetFactorOrPercentValue() const {
-  NS_ASSERTION(mUnit == eStyleUnit_Factor || mUnit == eStyleUnit_Percent,
-               "not a percent or factor value");
-  if (mUnit == eStyleUnit_Factor || mUnit == eStyleUnit_Percent) {
-    return mValue.mFloat;
-  }
-  return 0.0f;
-}
-
-inline float nsStyleCoord::GetAngleValue() const {
-  MOZ_ASSERT(mUnit == eStyleUnit_Degree);
-  return mValue.mFloat;
-}
-
-inline float nsStyleCoord::GetFlexFractionValue() const {
-  NS_ASSERTION(mUnit == eStyleUnit_FlexFraction, "not a fr value");
-  if (mUnit == eStyleUnit_FlexFraction) {
-    return mValue.mFloat;
-  }
-  return 0.0f;
-}
-
-inline nsStyleCoord::Calc* nsStyleCoord::GetCalcValue() const {
-  NS_ASSERTION(IsCalcUnit(), "not a pointer value");
-  if (IsCalcUnit()) {
-    return AsCalcValue(mValue);
-  }
-  return nullptr;
-}
-
-/* static */ inline void nsStyleCoord::Reset(nsStyleUnit& aUnit,
-                                             nsStyleUnion& aValue) {
-  MOZ_ASSERT(aUnit <= eStyleUnit_MAX,
-             "calling Reset on uninitialized nsStyleCoord?");
-
-  switch (aUnit) {
-    case eStyleUnit_Calc:
-      static_cast<Calc*>(aValue.mPointer)->Release();
-      break;
-    default:
-      MOZ_ASSERT(!IsPointerUnit(aUnit), "check pointer refcounting logic");
-  }
-
-  aUnit = eStyleUnit_Null;
-  aValue.mInt = 0;
-}
-
-/* static */ inline void nsStyleCoord::SetValue(
-    nsStyleUnit& aUnit, nsStyleUnion& aValue, nsStyleUnit aOtherUnit,
-    const nsStyleUnion& aOtherValue) {
-  Reset(aUnit, aValue);
-  InitWithValue(aUnit, aValue, aOtherUnit, aOtherValue);
-}
-
-/* static */ inline void nsStyleCoord::InitWithValue(
-    nsStyleUnit& aUnit, nsStyleUnion& aValue, nsStyleUnit aOtherUnit,
-    const nsStyleUnion& aOtherValue) {
-  aUnit = aOtherUnit;
-  aValue = aOtherValue;
-
-  switch (aUnit) {
-    case eStyleUnit_Calc:
-      static_cast<Calc*>(aValue.mPointer)->AddRef();
-      break;
-    default:
-      MOZ_ASSERT(!IsPointerUnit(aUnit), "check pointer refcounting logic");
-  }
-}
-
-/* static */ inline void nsStyleCoord::SetValue(nsStyleUnit& aUnit,
-                                                nsStyleUnion& aValue,
-                                                const nsStyleCoord& aOther) {
-  SetValue(aUnit, aValue, aOther.mUnit, aOther.mValue);
-}
-
-/* static */ inline void nsStyleCoord::InitWithValue(
-    nsStyleUnit& aUnit, nsStyleUnion& aValue, const nsStyleCoord& aOther) {
-  InitWithValue(aUnit, aValue, aOther.mUnit, aOther.mValue);
-}
-
-// -------------------------
-// nsStyleSides inlines
-//
-inline bool nsStyleSides::operator!=(const nsStyleSides& aOther) const {
-  return !((*this) == aOther);
-}
-
-inline nsStyleUnit nsStyleSides::GetUnit(mozilla::Side aSide) const {
-  return (nsStyleUnit)mUnits[aSide];
-}
-
-inline nsStyleUnit nsStyleSides::GetLeftUnit() const {
-  return GetUnit(mozilla::eSideLeft);
-}
-
-inline nsStyleUnit nsStyleSides::GetTopUnit() const {
-  return GetUnit(mozilla::eSideTop);
-}
-
-inline nsStyleUnit nsStyleSides::GetRightUnit() const {
-  return GetUnit(mozilla::eSideRight);
-}
-
-inline nsStyleUnit nsStyleSides::GetBottomUnit() const {
-  return GetUnit(mozilla::eSideBottom);
-}
-
-inline nsStyleCoord nsStyleSides::Get(mozilla::Side aSide) const {
-  return nsStyleCoord(mValues[aSide], nsStyleUnit(mUnits[aSide]));
-}
-
-inline nsStyleCoord nsStyleSides::GetLeft() const {
-  return Get(mozilla::eSideLeft);
-}
-
-inline nsStyleCoord nsStyleSides::GetTop() const {
-  return Get(mozilla::eSideTop);
-}
-
-inline nsStyleCoord nsStyleSides::GetRight() const {
-  return Get(mozilla::eSideRight);
-}
-
-inline nsStyleCoord nsStyleSides::GetBottom() const {
-  return Get(mozilla::eSideBottom);
-}
-
-inline void nsStyleSides::Set(mozilla::Side aSide, const nsStyleCoord& aCoord) {
-  nsStyleCoord::SetValue(mUnits[aSide], mValues[aSide], aCoord);
-}
-
-inline void nsStyleSides::SetLeft(const nsStyleCoord& aCoord) {
-  Set(mozilla::eSideLeft, aCoord);
-}
-
-inline void nsStyleSides::SetTop(const nsStyleCoord& aCoord) {
-  Set(mozilla::eSideTop, aCoord);
-}
-
-inline void nsStyleSides::SetRight(const nsStyleCoord& aCoord) {
-  Set(mozilla::eSideRight, aCoord);
-}
-
-inline void nsStyleSides::SetBottom(const nsStyleCoord& aCoord) {
-  Set(mozilla::eSideBottom, aCoord);
-}
-#endif /* nsStyleCoord_h___ */
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -17,17 +17,16 @@
 #include "mozilla/StaticPtr.h"
 #include "mozilla/StyleColorInlines.h"
 #include "mozilla/UniquePtr.h"
 #include "nsColor.h"
 #include "nsCoord.h"
 #include "nsMargin.h"
 #include "nsFont.h"
 #include "nsStyleAutoArray.h"
-#include "nsStyleCoord.h"
 #include "nsStyleConsts.h"
 #include "nsChangeHint.h"
 #include "nsTimingFunction.h"
 #include "nsCOMPtr.h"
 #include "nsCOMArray.h"
 #include "nsTArray.h"
 #include "nsCSSValue.h"
 #include "imgRequestProxy.h"
@@ -964,21 +963,16 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
 //   An omitted <line-names> is still represented in mLineNameLists,
 //   as an empty sub-array.
 //
 //   A <track-size> specified as a single <track-breadth> is represented
 //   as identical min and max sizing functions.
 //   A 'fit-content(size)' <track-size> is represented as eStyleUnit_None
 //   in the min sizing function and 'size' in the max sizing function.
 //
-//   The units for nsStyleCoord are:
-//   * eStyleUnit_Percent represents a <percentage>
-//   * eStyleUnit_FlexFraction represents a <flex> flexible fraction
-//   * eStyleUnit_Coord represents a <length>
-//   * eStyleUnit_Enumerated represents min-content or max-content
 // * subgrid <line-name-list>?:
 //   mIsSubgrid is true,
 //   mLineNameLists may or may not be empty,
 //   mTrackSizingFunctions is empty.
 //
 // If mRepeatAutoIndex != -1 then that index is an <auto-repeat> and
 // mIsAutoFill == true means it's an 'auto-fill', otherwise 'auto-fit'.
 // mRepeatAutoLineNameListBefore is the list of line names before the track
--- a/layout/style/nsStyleUtil.cpp
+++ b/layout/style/nsStyleUtil.cpp
@@ -181,34 +181,16 @@ void nsStyleUtil::AppendBitmaskCSSValue(
         aResult.Append(char16_t(' '));
       }
     }
   }
   MOZ_ASSERT(aMaskedValue == 0, "unexpected bit remaining in bitfield");
 }
 
 /* static */
-void nsStyleUtil::AppendAngleValue(const nsStyleCoord& aAngle,
-                                   nsAString& aResult) {
-  MOZ_ASSERT(aAngle.IsAngleValue(), "Should have angle value");
-
-  // Append number.
-  AppendCSSNumber(aAngle.GetAngleValue(), aResult);
-
-  // Append unit.
-  switch (aAngle.GetUnit()) {
-    case eStyleUnit_Degree:
-      aResult.AppendLiteral("deg");
-      break;
-    default:
-      MOZ_ASSERT_UNREACHABLE("unrecognized angle unit");
-  }
-}
-
-/* static */
 void nsStyleUtil::AppendPaintOrderValue(uint8_t aValue, nsAString& aResult) {
   static_assert(
       NS_STYLE_PAINT_ORDER_BITWIDTH * NS_STYLE_PAINT_ORDER_LAST_VALUE <= 8,
       "SVGStyleStruct::mPaintOrder and local variables not big enough");
 
   if (aValue == NS_STYLE_PAINT_ORDER_NORMAL) {
     aResult.AppendLiteral("normal");
     return;
@@ -423,12 +405,13 @@ void nsStyleUtil::AppendFontSlantStyle(c
     aOut.AppendLiteral("normal");
   } else if (aStyle.IsItalic()) {
     aOut.AppendLiteral("italic");
   } else {
     aOut.AppendLiteral("oblique");
     auto angle = aStyle.ObliqueAngle();
     if (angle != FontSlantStyle::kDefaultAngle) {
       aOut.AppendLiteral(" ");
-      AppendAngleValue(nsStyleCoord(angle, eStyleUnit_Degree), aOut);
+      AppendCSSNumber(angle, aOut);
+      aOut.AppendLiteral("deg");
     }
   }
 }
--- a/layout/style/nsStyleUtil.h
+++ b/layout/style/nsStyleUtil.h
@@ -10,17 +10,16 @@
 #include "nsCSSPropertyID.h"
 #include "nsTArrayForwardDeclare.h"
 #include "gfxFontFamilyList.h"
 #include "nsStringFwd.h"
 #include "nsStyleStruct.h"
 #include "nsCRT.h"
 
 class nsCSSValue;
-class nsStyleCoord;
 class nsIContent;
 class nsIPrincipal;
 class nsIURI;
 struct gfxFontFeature;
 struct gfxAlternateValue;
 struct nsCSSKTableEntry;
 struct nsCSSValueList;
 
@@ -60,18 +59,16 @@ class nsStyleUtil {
                                    nsAString& aResult);
 
  public:
   // Append a bitmask-valued property's value(s) (space-separated) to aResult.
   static void AppendBitmaskCSSValue(const nsCSSKTableEntry aTable[],
                                     int32_t aMaskedValue, int32_t aFirstMask,
                                     int32_t aLastMask, nsAString& aResult);
 
-  static void AppendAngleValue(const nsStyleCoord& aValue, nsAString& aResult);
-
   static void AppendPaintOrderValue(uint8_t aValue, nsAString& aResult);
 
   static void AppendCSSNumber(float aNumber, nsAString& aResult) {
     aResult.AppendFloat(aNumber);
   }
 
   /*
    * Convert an author-provided floating point number to an integer (0
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -21,17 +21,16 @@
 #include "nsDisplayList.h"
 #include "nsFilterInstance.h"
 #include "nsFrameList.h"
 #include "nsGkAtoms.h"
 #include "nsIContent.h"
 #include "nsIFrame.h"
 #include "nsLayoutUtils.h"
 #include "nsPresContext.h"
-#include "nsStyleCoord.h"
 #include "nsStyleStruct.h"
 #include "nsStyleTransformMatrix.h"
 #include "SVGAnimatedLength.h"
 #include "nsSVGClipPathFrame.h"
 #include "nsSVGContainerFrame.h"
 #include "SVGContentUtils.h"
 #include "nsSVGDisplayableFrame.h"
 #include "nsSVGFilterPaintCallback.h"
--- a/layout/tables/nsTableFrame.h
+++ b/layout/tables/nsTableFrame.h
@@ -5,17 +5,16 @@
 #ifndef nsTableFrame_h__
 #define nsTableFrame_h__
 
 #include "mozilla/Attributes.h"
 #include "celldata.h"
 #include "imgIContainer.h"
 #include "nscore.h"
 #include "nsContainerFrame.h"
-#include "nsStyleCoord.h"
 #include "nsStyleConsts.h"
 #include "nsCellMap.h"
 #include "nsGkAtoms.h"
 #include "nsDisplayList.h"
 #include "TableArea.h"
 
 struct BCPaintBorderAction;
 class nsTableCellFrame;
--- a/servo/components/style/gecko/conversions.rs
+++ b/servo/components/style/gecko/conversions.rs
@@ -5,59 +5,25 @@
 //! This module contains conversion helpers between Servo and Gecko types
 //! Ideally, it would be in geckolib itself, but coherence
 //! forces us to keep the traits and implementations here
 //!
 //! FIXME(emilio): This file should generally just die.
 
 #![allow(unsafe_code)]
 
-use crate::gecko::values::GeckoStyleCoordConvertible;
 use crate::gecko_bindings::bindings;
-use crate::gecko_bindings::structs::{self, nsStyleCoord_CalcValue, Matrix4x4Components};
+use crate::gecko_bindings::structs::{self, Matrix4x4Components};
 use crate::gecko_bindings::structs::{nsStyleImage, nsresult};
 use crate::stylesheets::RulesMutateError;
 use crate::values::computed::transform::Matrix3D;
 use crate::values::computed::url::ComputedImageUrl;
-use crate::values::computed::{Gradient, Image, LengthPercentage};
-use crate::values::computed::{Length, Percentage, TextAlign};
+use crate::values::computed::{Gradient, Image, TextAlign};
 use crate::values::generics::image::GenericImage;
 use crate::values::generics::rect::Rect;
-use crate::Zero;
-use app_units::Au;
-use style_traits::values::specified::AllowedNumericType;
-
-impl From<LengthPercentage> for nsStyleCoord_CalcValue {
-    fn from(other: LengthPercentage) -> nsStyleCoord_CalcValue {
-        debug_assert!(
-            other.was_calc || !other.has_percentage || other.unclamped_length() == Length::zero()
-        );
-        nsStyleCoord_CalcValue {
-            mLength: other.unclamped_length().to_i32_au(),
-            mPercent: other.percentage(),
-            mHasPercent: other.has_percentage,
-        }
-    }
-}
-
-impl From<nsStyleCoord_CalcValue> for LengthPercentage {
-    fn from(other: nsStyleCoord_CalcValue) -> LengthPercentage {
-        let percentage = if other.mHasPercent {
-            Some(Percentage(other.mPercent))
-        } else {
-            None
-        };
-        Self::with_clamping_mode(
-            Au(other.mLength).into(),
-            percentage,
-            AllowedNumericType::All,
-            /* was_calc = */ true,
-        )
-    }
-}
 
 impl nsStyleImage {
     /// Set a given Servo `Image` value into this `nsStyleImage`.
     pub fn set(&mut self, image: Image) {
         match image {
             GenericImage::Gradient(boxed_gradient) => self.set_gradient(boxed_gradient),
             GenericImage::Url(ref url) => unsafe {
                 bindings::Gecko_SetLayerImageImageValue(self, url);
@@ -291,41 +257,16 @@ impl From<RulesMutateError> for nsresult
             RulesMutateError::Syntax => nsresult::NS_ERROR_DOM_SYNTAX_ERR,
             RulesMutateError::IndexSize => nsresult::NS_ERROR_DOM_INDEX_SIZE_ERR,
             RulesMutateError::HierarchyRequest => nsresult::NS_ERROR_DOM_HIERARCHY_REQUEST_ERR,
             RulesMutateError::InvalidState => nsresult::NS_ERROR_DOM_INVALID_STATE_ERR,
         }
     }
 }
 
-impl<T> Rect<T>
-where
-    T: GeckoStyleCoordConvertible,
-{
-    /// Convert this generic Rect to given Gecko fields.
-    pub fn to_gecko_rect(&self, sides: &mut crate::gecko_bindings::structs::nsStyleSides) {
-        self.0.to_gecko_style_coord(&mut sides.data_at_mut(0));
-        self.1.to_gecko_style_coord(&mut sides.data_at_mut(1));
-        self.2.to_gecko_style_coord(&mut sides.data_at_mut(2));
-        self.3.to_gecko_style_coord(&mut sides.data_at_mut(3));
-    }
-
-    /// Convert from given Gecko data to generic Rect.
-    pub fn from_gecko_rect(
-        sides: &crate::gecko_bindings::structs::nsStyleSides,
-    ) -> Option<crate::values::generics::rect::Rect<T>> {
-        Some(Rect::new(
-            T::from_gecko_style_coord(&sides.data_at(0)).expect("coord[0] cound not convert"),
-            T::from_gecko_style_coord(&sides.data_at(1)).expect("coord[1] cound not convert"),
-            T::from_gecko_style_coord(&sides.data_at(2)).expect("coord[2] cound not convert"),
-            T::from_gecko_style_coord(&sides.data_at(3)).expect("coord[3] cound not convert"),
-        ))
-    }
-}
-
 impl TextAlign {
     /// Obtain a specified value from a Gecko keyword value
     ///
     /// Intended for use with presentation attributes, not style structs
     pub fn from_gecko_keyword(kw: u32) -> Self {
         match kw {
             structs::NS_STYLE_TEXT_ALIGN_LEFT => TextAlign::Left,
             structs::NS_STYLE_TEXT_ALIGN_RIGHT => TextAlign::Right,
--- a/servo/components/style/gecko/values.rs
+++ b/servo/components/style/gecko/values.rs
@@ -2,175 +2,25 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
 
 #![allow(unsafe_code)]
 
 //! Different kind of helpers to interact with Gecko values.
 
 use crate::counter_style::{Symbol, Symbols};
-use crate::gecko_bindings::structs::{nsStyleCoord, CounterStylePtr};
-use crate::gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
-use crate::values::computed::{Length, LengthPercentage};
-use crate::values::computed::{Number, NumberOrPercentage, Percentage};
-use crate::values::generics::length::LengthPercentageOrAuto;
-use crate::values::generics::{CounterStyleOrNone, NonNegative};
+use crate::gecko_bindings::structs::CounterStylePtr;
+use crate::values::generics::CounterStyleOrNone;
 use crate::values::Either;
-use crate::{Atom, Zero};
+use crate::Atom;
 use app_units::Au;
 use cssparser::RGBA;
 use nsstring::{nsACString, nsCStr};
 use std::cmp::max;
 
-/// A trait that defines an interface to convert from and to `nsStyleCoord`s.
-///
-/// TODO(emilio): Almost everything that is in this file should be somehow
-/// switched to cbindgen.
-pub trait GeckoStyleCoordConvertible: Sized {
-    /// Convert this to a `nsStyleCoord`.
-    fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T);
-    /// Given a `nsStyleCoord`, try to get a value of this type..
-    fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self>;
-}
-
-impl nsStyleCoord {
-    #[inline]
-    /// Set this `nsStyleCoord` value to `val`.
-    pub fn set<T: GeckoStyleCoordConvertible>(&mut self, val: T) {
-        val.to_gecko_style_coord(self);
-    }
-}
-
-impl<Inner> GeckoStyleCoordConvertible for NonNegative<Inner>
-where
-    Inner: GeckoStyleCoordConvertible,
-{
-    fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
-        self.0.to_gecko_style_coord(coord)
-    }
-
-    fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
-        Some(NonNegative(Inner::from_gecko_style_coord(coord)?))
-    }
-}
-
-impl GeckoStyleCoordConvertible for Number {
-    fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
-        coord.set_value(CoordDataValue::Factor(*self));
-    }
-
-    fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
-        match coord.as_value() {
-            CoordDataValue::Factor(f) => Some(f),
-            _ => None,
-        }
-    }
-}
-
-impl GeckoStyleCoordConvertible for Percentage {
-    fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
-        coord.set_value(CoordDataValue::Percent(self.0));
-    }
-
-    fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
-        match coord.as_value() {
-            CoordDataValue::Percent(p) => Some(Percentage(p)),
-            _ => None,
-        }
-    }
-}
-
-impl GeckoStyleCoordConvertible for NumberOrPercentage {
-    fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
-        match *self {
-            NumberOrPercentage::Number(ref n) => n.to_gecko_style_coord(coord),
-            NumberOrPercentage::Percentage(ref p) => p.to_gecko_style_coord(coord),
-        }
-    }
-
-    fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
-        match coord.as_value() {
-            CoordDataValue::Factor(f) => Some(NumberOrPercentage::Number(f)),
-            CoordDataValue::Percent(p) => Some(NumberOrPercentage::Percentage(Percentage(p))),
-            _ => None,
-        }
-    }
-}
-
-impl GeckoStyleCoordConvertible for LengthPercentage {
-    fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
-        if self.was_calc {
-            return coord.set_value(CoordDataValue::Calc((*self).into()));
-        }
-        debug_assert!(!self.has_percentage || self.unclamped_length() == Length::zero());
-        if self.has_percentage {
-            return coord.set_value(CoordDataValue::Percent(self.percentage()));
-        }
-        coord.set_value(CoordDataValue::Coord(self.unclamped_length().to_i32_au()))
-    }
-
-    fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
-        match coord.as_value() {
-            CoordDataValue::Coord(coord) => Some(LengthPercentage::new(Au(coord).into(), None)),
-            CoordDataValue::Percent(p) => {
-                Some(LengthPercentage::new(Au(0).into(), Some(Percentage(p))))
-            },
-            CoordDataValue::Calc(calc) => Some(calc.into()),
-            _ => None,
-        }
-    }
-}
-
-impl GeckoStyleCoordConvertible for Length {
-    fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
-        coord.set_value(CoordDataValue::Coord(self.to_i32_au()));
-    }
-
-    fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
-        match coord.as_value() {
-            CoordDataValue::Coord(coord) => Some(Au(coord).into()),
-            _ => None,
-        }
-    }
-}
-
-impl<LengthPercentage> GeckoStyleCoordConvertible for LengthPercentageOrAuto<LengthPercentage>
-where
-    LengthPercentage: GeckoStyleCoordConvertible,
-{
-    fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
-        match *self {
-            LengthPercentageOrAuto::Auto => coord.set_value(CoordDataValue::Auto),
-            LengthPercentageOrAuto::LengthPercentage(ref lp) => lp.to_gecko_style_coord(coord),
-        }
-    }
-
-    fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
-        match coord.as_value() {
-            CoordDataValue::Auto => Some(LengthPercentageOrAuto::Auto),
-            _ => LengthPercentage::from_gecko_style_coord(coord)
-                .map(LengthPercentageOrAuto::LengthPercentage),
-        }
-    }
-}
-
-impl<T: GeckoStyleCoordConvertible> GeckoStyleCoordConvertible for Option<T> {
-    fn to_gecko_style_coord<U: CoordDataMut>(&self, coord: &mut U) {
-        if let Some(ref me) = *self {
-            me.to_gecko_style_coord(coord);
-        } else {
-            coord.set_value(CoordDataValue::None);
-        }
-    }
-
-    fn from_gecko_style_coord<U: CoordData>(coord: &U) -> Option<Self> {
-        Some(T::from_gecko_style_coord(coord))
-    }
-}
-
 /// Convert a given RGBA value to `nscolor`.
 pub fn convert_rgba_to_nscolor(rgba: &RGBA) -> u32 {
     ((rgba.alpha as u32) << 24) |
         ((rgba.blue as u32) << 16) |
         ((rgba.green as u32) << 8) |
         (rgba.red as u32)
 }
 
--- a/servo/components/style/gecko_bindings/sugar/mod.rs
+++ b/servo/components/style/gecko_bindings/sugar/mod.rs
@@ -2,13 +2,12 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
 
 //! Rust sugar and convenience methods for Gecko types.
 
 mod ns_com_ptr;
 mod ns_compatibility;
 mod ns_style_auto_array;
-pub mod ns_style_coord;
 mod ns_t_array;
 pub mod origin_flags;
 pub mod ownership;
 pub mod refptr;
deleted file mode 100644
--- a/servo/components/style/gecko_bindings/sugar/ns_style_coord.rs
+++ /dev/null
@@ -1,369 +0,0 @@
-/* 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 https://mozilla.org/MPL/2.0/. */
-
-//! Rust helpers for Gecko's `nsStyleCoord`.
-
-use crate::gecko_bindings::bindings;
-use crate::gecko_bindings::structs::nsStyleSides;
-use crate::gecko_bindings::structs::{nsStyleCoord, nsStyleCoord_Calc, nsStyleCoord_CalcValue};
-use crate::gecko_bindings::structs::{nsStyleUnion, nsStyleUnit, nscoord};
-use std::mem;
-
-impl nsStyleCoord {
-    #[inline]
-    /// Get a `null` nsStyleCoord.
-    pub fn null() -> Self {
-        // Can't construct directly because it has private fields
-        let mut coord: Self = unsafe { mem::zeroed() };
-        coord.leaky_set_null();
-        coord
-    }
-}
-
-unsafe impl CoordData for nsStyleCoord {
-    #[inline]
-    fn unit(&self) -> nsStyleUnit {
-        unsafe { *self.get_mUnit() }
-    }
-    #[inline]
-    fn union(&self) -> nsStyleUnion {
-        unsafe { *self.get_mValue() }
-    }
-}
-
-unsafe impl CoordDataMut for nsStyleCoord {
-    unsafe fn values_mut(&mut self) -> (&mut nsStyleUnit, &mut nsStyleUnion) {
-        let unit = self.get_mUnit_mut() as *mut _;
-        let value = self.get_mValue_mut() as *mut _;
-        (&mut *unit, &mut *value)
-    }
-}
-
-impl nsStyleCoord_CalcValue {
-    /// Create an "empty" CalcValue (whose value is `0`).
-    pub fn new() -> Self {
-        nsStyleCoord_CalcValue {
-            mLength: 0,
-            mPercent: 0.0,
-            mHasPercent: false,
-        }
-    }
-}
-
-impl PartialEq for nsStyleCoord_CalcValue {
-    fn eq(&self, other: &Self) -> bool {
-        self.mLength == other.mLength &&
-            self.mPercent == other.mPercent &&
-            self.mHasPercent == other.mHasPercent
-    }
-}
-
-impl nsStyleSides {
-    /// Immutably get the `nsStyleCoord`-like object representing the side at
-    /// index `index`.
-    #[inline]
-    pub fn data_at(&self, index: usize) -> SidesData {
-        SidesData {
-            sides: self,
-            index: index,
-        }
-    }
-
-    /// Mutably get the `nsStyleCoord`-like object representing the side at
-    /// index `index`.
-    #[inline]
-    pub fn data_at_mut(&mut self, index: usize) -> SidesDataMut {
-        SidesDataMut {
-            sides: self,
-            index: index,
-        }
-    }
-}
-
-/// A `nsStyleCoord`-like object on top of an immutable reference to
-/// `nsStyleSides`.
-pub struct SidesData<'a> {
-    sides: &'a nsStyleSides,
-    index: usize,
-}
-
-/// A `nsStyleCoord`-like object on top of an mutable reference to
-/// `nsStyleSides`.
-pub struct SidesDataMut<'a> {
-    sides: &'a mut nsStyleSides,
-    index: usize,
-}
-
-unsafe impl<'a> CoordData for SidesData<'a> {
-    #[inline]
-    fn unit(&self) -> nsStyleUnit {
-        unsafe { self.sides.get_mUnits()[self.index] }
-    }
-    #[inline]
-    fn union(&self) -> nsStyleUnion {
-        unsafe { self.sides.get_mValues()[self.index] }
-    }
-}
-unsafe impl<'a> CoordData for SidesDataMut<'a> {
-    #[inline]
-    fn unit(&self) -> nsStyleUnit {
-        unsafe { self.sides.get_mUnits()[self.index] }
-    }
-    #[inline]
-    fn union(&self) -> nsStyleUnion {
-        unsafe { self.sides.get_mValues()[self.index] }
-    }
-}
-unsafe impl<'a> CoordDataMut for SidesDataMut<'a> {
-    unsafe fn values_mut(&mut self) -> (&mut nsStyleUnit, &mut nsStyleUnion) {
-        let unit = &mut self.sides.get_mUnits_mut()[self.index] as *mut _;
-        let value = &mut self.sides.get_mValues_mut()[self.index] as *mut _;
-        (&mut *unit, &mut *value)
-    }
-}
-
-/// Enum representing the tagged union that is CoordData.
-///
-/// In release mode this should never actually exist in the code, and will be
-/// optimized out by threading matches and inlining.
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub enum CoordDataValue {
-    /// eStyleUnit_Null
-    Null,
-    /// eStyleUnit_Normal
-    Normal,
-    /// eStyleUnit_Auto
-    Auto,
-    /// eStyleUnit_None
-    None,
-    /// eStyleUnit_Percent
-    Percent(f32),
-    /// eStyleUnit_Factor
-    Factor(f32),
-    /// eStyleUnit_Degree
-    Degree(f32),
-    /// eStyleUnit_FlexFraction
-    FlexFraction(f32),
-    /// eStyleUnit_Coord
-    Coord(nscoord),
-    /// eStyleUnit_Integer
-    Integer(i32),
-    /// eStyleUnit_Enumerated
-    Enumerated(u32),
-    /// eStyleUnit_Calc
-    Calc(nsStyleCoord_CalcValue),
-}
-
-/// A trait to abstract on top of a mutable `nsStyleCoord`-like object.
-pub unsafe trait CoordDataMut: CoordData {
-    /// Get mutably the unit and the union.
-    ///
-    /// This is unsafe since it's possible to modify the unit without changing
-    /// the union.
-    ///
-    /// NB: This can't be two methods since we can't mutably borrow twice
-    unsafe fn values_mut(&mut self) -> (&mut nsStyleUnit, &mut nsStyleUnion);
-
-    /// Clean up any resources used by the union.
-    ///
-    /// Currently, this only happens if the nsStyleUnit is a Calc.
-    #[inline]
-    fn reset(&mut self) {
-        unsafe {
-            if self.unit() == nsStyleUnit::eStyleUnit_Calc {
-                let (unit, union) = self.values_mut();
-                bindings::Gecko_ResetStyleCoord(unit, union);
-            }
-        }
-    }
-
-    #[inline]
-    /// Copies the unit and value from another `CoordData` type.
-    fn copy_from<T: CoordData>(&mut self, other: &T) {
-        unsafe {
-            self.reset();
-            self.copy_from_unchecked(other);
-            self.addref_if_calc();
-        }
-    }
-
-    #[inline]
-    /// Moves the unit and value from another `CoordData` type.
-    fn move_from<T: CoordData>(&mut self, other: T) {
-        unsafe {
-            self.reset();
-            self.copy_from_unchecked(&other);
-        }
-    }
-
-    #[inline]
-    /// Copies the unit and value from another `CoordData` type without checking
-    /// the type of the value (so refcounted values like calc may leak).
-    unsafe fn copy_from_unchecked<T: CoordData>(&mut self, other: &T) {
-        let (unit, union) = self.values_mut();
-        *unit = other.unit();
-        *union = other.union();
-    }
-
-    /// Useful for initializing uninits, given that `set_value` may segfault on
-    /// uninits.
-    fn leaky_set_null(&mut self) {
-        use crate::gecko_bindings::structs::nsStyleUnit::*;
-        unsafe {
-            let (unit, union) = self.values_mut();
-            *unit = eStyleUnit_Null;
-            *union.mInt.as_mut() = 0;
-        }
-    }
-
-    #[inline(always)]
-    /// Sets the inner value.
-    fn set_value(&mut self, value: CoordDataValue) {
-        use self::CoordDataValue::*;
-        use crate::gecko_bindings::structs::nsStyleUnit::*;
-        self.reset();
-        unsafe {
-            let (unit, union) = self.values_mut();
-            match value {
-                Null => {
-                    *unit = eStyleUnit_Null;
-                    *union.mInt.as_mut() = 0;
-                },
-                Normal => {
-                    *unit = eStyleUnit_Normal;
-                    *union.mInt.as_mut() = 0;
-                },
-                Auto => {
-                    *unit = eStyleUnit_Auto;
-                    *union.mInt.as_mut() = 0;
-                },
-                None => {
-                    *unit = eStyleUnit_None;
-                    *union.mInt.as_mut() = 0;
-                },
-                Percent(f) => {
-                    *unit = eStyleUnit_Percent;
-                    *union.mFloat.as_mut() = f;
-                },
-                Factor(f) => {
-                    *unit = eStyleUnit_Factor;
-                    *union.mFloat.as_mut() = f;
-                },
-                Degree(f) => {
-                    *unit = eStyleUnit_Degree;
-                    *union.mFloat.as_mut() = f;
-                },
-                FlexFraction(f) => {
-                    *unit = eStyleUnit_FlexFraction;
-                    *union.mFloat.as_mut() = f;
-                },
-                Coord(coord) => {
-                    *unit = eStyleUnit_Coord;
-                    *union.mInt.as_mut() = coord;
-                },
-                Integer(i) => {
-                    *unit = eStyleUnit_Integer;
-                    *union.mInt.as_mut() = i;
-                },
-                Enumerated(i) => {
-                    *unit = eStyleUnit_Enumerated;
-                    *union.mInt.as_mut() = i as i32;
-                },
-                Calc(calc) => {
-                    // Gecko_SetStyleCoordCalcValue changes the unit internally
-                    bindings::Gecko_SetStyleCoordCalcValue(unit, union, calc);
-                },
-            }
-        }
-    }
-
-    #[inline]
-    /// Gets the `Calc` value mutably, asserts in debug builds if the unit is
-    /// not `Calc`.
-    unsafe fn as_calc_mut(&mut self) -> &mut nsStyleCoord_Calc {
-        debug_assert_eq!(self.unit(), nsStyleUnit::eStyleUnit_Calc);
-        &mut *(*self.union().mPointer.as_mut() as *mut nsStyleCoord_Calc)
-    }
-
-    #[inline]
-    /// Does what it promises, if the unit is `calc`, it bumps the reference
-    /// count _of the calc expression_.
-    fn addref_if_calc(&mut self) {
-        unsafe {
-            if self.unit() == nsStyleUnit::eStyleUnit_Calc {
-                bindings::Gecko_AddRefCalcArbitraryThread(self.as_calc_mut());
-            }
-        }
-    }
-}
-/// A trait to abstract on top of a `nsStyleCoord`-like object.
-pub unsafe trait CoordData {
-    /// Get the unit of this object.
-    fn unit(&self) -> nsStyleUnit;
-    /// Get the `nsStyleUnion` for this object.
-    fn union(&self) -> nsStyleUnion;
-
-    #[inline(always)]
-    /// Get the appropriate value for this object.
-    fn as_value(&self) -> CoordDataValue {
-        use self::CoordDataValue::*;
-        use crate::gecko_bindings::structs::nsStyleUnit::*;
-        unsafe {
-            match self.unit() {
-                eStyleUnit_Null => Null,
-                eStyleUnit_Normal => Normal,
-                eStyleUnit_Auto => Auto,
-                eStyleUnit_None => None,
-                eStyleUnit_Percent => Percent(self.get_float()),
-                eStyleUnit_Factor => Factor(self.get_float()),
-                eStyleUnit_Degree => Degree(self.get_float()),
-                eStyleUnit_FlexFraction => FlexFraction(self.get_float()),
-                eStyleUnit_Coord => Coord(self.get_integer()),
-                eStyleUnit_Integer => Integer(self.get_integer()),
-                eStyleUnit_Enumerated => Enumerated(self.get_integer() as u32),
-                eStyleUnit_Calc => Calc(self.get_calc_value()),
-            }
-        }
-    }
-
-    #[inline]
-    /// Pretend inner value is a float; obtain it.
-    unsafe fn get_float(&self) -> f32 {
-        use crate::gecko_bindings::structs::nsStyleUnit::*;
-        debug_assert!(
-            self.unit() == eStyleUnit_Percent ||
-                self.unit() == eStyleUnit_Factor ||
-                self.unit() == eStyleUnit_Degree ||
-                self.unit() == eStyleUnit_FlexFraction
-        );
-        *self.union().mFloat.as_ref()
-    }
-
-    #[inline]
-    /// Pretend inner value is an int; obtain it.
-    unsafe fn get_integer(&self) -> i32 {
-        use crate::gecko_bindings::structs::nsStyleUnit::*;
-        debug_assert!(
-            self.unit() == eStyleUnit_Coord ||
-                self.unit() == eStyleUnit_Integer ||
-                self.unit() == eStyleUnit_Enumerated
-        );
-        *self.union().mInt.as_ref()
-    }
-
-    #[inline]
-    /// Pretend inner value is a calc; obtain it.
-    /// Ensure that the unit is Calc before calling this.
-    unsafe fn get_calc_value(&self) -> nsStyleCoord_CalcValue {
-        debug_assert_eq!(self.unit(), nsStyleUnit::eStyleUnit_Calc);
-        (*self.as_calc())._base
-    }
-
-    #[inline]
-    /// Pretend the inner value is a calc expression, and obtain it.
-    unsafe fn as_calc(&self) -> &nsStyleCoord_Calc {
-        debug_assert_eq!(self.unit(), nsStyleUnit::eStyleUnit_Calc);
-        &*(*self.union().mPointer.as_ref() as *const nsStyleCoord_Calc)
-    }
-}
--- a/servo/ports/geckolib/cbindgen.toml
+++ b/servo/ports/geckolib/cbindgen.toml
@@ -216,17 +216,16 @@ renaming_overrides_prefixing = true
 [export.body]
 "CSSPixelLength" = """
   inline nscoord ToAppUnits() const;
   inline bool IsZero() const;
   float ToCSSPixels() const { return _0; }
 """
 
 "LengthPercentage" = """
-  // Defined in nsStyleCoord.h
   static constexpr inline StyleLengthPercentage Zero();
   static inline StyleLengthPercentage FromAppUnits(nscoord);
   static inline StyleLengthPercentage FromPixels(CSSCoord);
   static inline StyleLengthPercentage FromPercentage(float);
   inline CSSCoord LengthInCSSPixels() const;
   inline float Percentage() const;
   inline bool HasPercent() const;
   inline bool ConvertsToLength() const;
@@ -287,17 +286,16 @@ renaming_overrides_prefixing = true
   static inline StyleGenericPosition FromPercentage(float);
 """
 
 "GenericBackgroundSize" = """
   bool IsInitialValue() const;
 """
 
 "Rect" = """
-  // Defined in nsStyleCoord.h
   template<typename Predicate> inline bool All(Predicate) const;
   template<typename Predicate> inline bool Any(Predicate) const;
 
   // Defined in WritingModes.h
   inline const T& Get(mozilla::Side) const;
   inline const T& Get(mozilla::WritingMode, mozilla::LogicalSide) const;
   inline const T& GetIStart(mozilla::WritingMode) const;
   inline const T& GetBStart(mozilla::WritingMode) const;