Bug 1373018 - Part 8: stylo: Move nsStyleContext::SetStyle to GeckoStyleContext; r=bholley
authorManish Goregaokar <manishearth@gmail.com>
Sat, 10 Jun 2017 22:27:45 -0700
changeset 412986 02462591f243f41dc94a71e4e1b0c30e06016e46
parent 412985 305613bee6fb16a5f33077cc52807dcc5713f9d9
child 412987 b422d7f837f2be2ec1a21a6d1d69153f26df3505
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1373018
milestone56.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 1373018 - Part 8: stylo: Move nsStyleContext::SetStyle to GeckoStyleContext; r=bholley MozReview-Commit-ID: ycXu95whnG
dom/animation/AnimValuesStyleRule.cpp
dom/animation/EffectCompositor.cpp
dom/animation/KeyframeEffectReadOnly.cpp
layout/base/nsCSSFrameConstructor.cpp
layout/generic/nsFrame.cpp
layout/style/GeckoStyleContext.cpp
layout/style/GeckoStyleContext.h
layout/style/ServoBindings.cpp
layout/style/StyleAnimationValue.cpp
layout/style/nsRuleNode.cpp
layout/style/nsRuleNode.h
layout/style/nsStyleContext.cpp
layout/style/nsStyleContext.h
layout/style/nsStyleContextInlines.h
layout/tables/nsTableColGroupFrame.cpp
layout/xul/nsSplitterFrame.cpp
--- a/dom/animation/AnimValuesStyleRule.cpp
+++ b/dom/animation/AnimValuesStyleRule.cpp
@@ -1,26 +1,26 @@
 /* -*- 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/. */
 
 #include "AnimValuesStyleRule.h"
 #include "nsRuleData.h"
-#include "nsStyleContext.h"
+#include "mozilla/GeckoStyleContext.h"
 
 namespace mozilla {
 
 NS_IMPL_ISUPPORTS(AnimValuesStyleRule, nsIStyleRule)
 
 void
 AnimValuesStyleRule::MapRuleInfoInto(nsRuleData* aRuleData)
 {
-  nsStyleContext *contextParent = aRuleData->mStyleContext->GetParent();
+  GeckoStyleContext *contextParent = aRuleData->mStyleContext->GetParent();
   if (contextParent && contextParent->HasPseudoElementData()) {
     // Don't apply transitions or animations to things inside of
     // pseudo-elements.
     // FIXME (Bug 522599): Add tests for this.
 
     // Prevent structs from being cached on the rule node since we're inside
     // a pseudo-element, as we could determine cacheability differently
     // when walking the rule tree for a style context that is not inside
--- a/dom/animation/EffectCompositor.cpp
+++ b/dom/animation/EffectCompositor.cpp
@@ -10,16 +10,17 @@
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/KeyframeEffectReadOnly.h"
 #include "mozilla/AnimationComparator.h"
 #include "mozilla/AnimationPerformanceWarning.h"
 #include "mozilla/AnimationTarget.h"
 #include "mozilla/AnimationUtils.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/EffectSet.h"
+#include "mozilla/GeckoStyleContext.h"
 #include "mozilla/LayerAnimationInfo.h"
 #include "mozilla/RestyleManager.h"
 #include "mozilla/RestyleManagerInlines.h"
 #include "mozilla/ServoBindings.h" // Servo_GetProperties_Overriding_Animation
 #include "mozilla/ServoStyleSet.h"
 #include "mozilla/StyleAnimationValue.h"
 #include "mozilla/TypeTraits.h" // For Forward<>
 #include "nsComputedDOMStyle.h" // nsComputedDOMStyle::GetPresShellForContent
@@ -28,16 +29,17 @@
 #include "nsCSSPropertyIDSet.h"
 #include "nsCSSProps.h"
 #include "nsIAtom.h"
 #include "nsIPresShell.h"
 #include "nsIPresShellInlines.h"
 #include "nsLayoutUtils.h"
 #include "nsRuleNode.h" // For nsRuleNode::ComputePropertiesOverridingAnimation
 #include "nsRuleProcessorData.h" // For ElementRuleProcessorData etc.
+#include "nsStyleContextInlines.h"
 #include "nsTArray.h"
 #include <bitset>
 #include <initializer_list>
 
 using mozilla::dom::Animation;
 using mozilla::dom::Element;
 using mozilla::dom::KeyframeEffectReadOnly;
 
@@ -796,17 +798,17 @@ EffectCompositor::GetOverriddenPropertie
   switch (aBackendType) {
     case StyleBackendType::Servo:
       Servo_GetProperties_Overriding_Animation(elementToRestyle,
                                                &propertiesToTrack,
                                                &result);
       break;
     case StyleBackendType::Gecko:
       nsRuleNode::ComputePropertiesOverridingAnimation(propertiesToTrack,
-                                                       aStyleContext,
+                                                       aStyleContext->AsGecko(),
                                                        result);
       break;
 
     default:
       MOZ_ASSERT_UNREACHABLE("Unsupported style backend");
   }
 
   return result;
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -10,29 +10,31 @@
 #include "mozilla/dom/KeyframeAnimationOptionsBinding.h"
   // For UnrestrictedDoubleOrKeyframeAnimationOptions;
 #include "mozilla/dom/CSSPseudoElement.h"
 #include "mozilla/dom/KeyframeEffectBinding.h"
 #include "mozilla/AnimValuesStyleRule.h"
 #include "mozilla/AnimationUtils.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/EffectSet.h"
+#include "mozilla/GeckoStyleContext.h"
 #include "mozilla/FloatingPoint.h" // For IsFinite
 #include "mozilla/LookAndFeel.h" // For LookAndFeel::GetInt
 #include "mozilla/KeyframeUtils.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/TypeTraits.h"
 #include "Layers.h" // For Layer
 #include "nsComputedDOMStyle.h" // nsComputedDOMStyle::GetStyleContext
 #include "nsCSSPropertyIDSet.h"
 #include "nsCSSProps.h" // For nsCSSProps::PropHasFlags
 #include "nsCSSPseudoElements.h" // For CSSPseudoElementType
 #include "nsIPresShell.h"
 #include "nsIScriptError.h"
+#include "nsStyleContextInlines.h"
 
 namespace mozilla {
 
 bool
 PropertyValuePair::operator==(const PropertyValuePair& aOther) const
 {
   if (mProperty != aOther.mProperty || mValue != aOther.mValue) {
     return false;
@@ -1638,17 +1640,17 @@ CreateStyleContextForAnimationValue(nsCS
   nsStyleSet* styleSet =
     aBaseStyleContext->PresContext()->StyleSet()->AsGecko();
 
   RefPtr<nsStyleContext> styleContext =
     styleSet->ResolveStyleByAddingRules(aBaseStyleContext, rules);
 
   // We need to call StyleData to generate cached data for the style context.
   // Otherwise CalcStyleDifference returns no meaningful result.
-  styleContext->StyleData(nsCSSProps::kSIDTable[aProperty]);
+  styleContext->AsGecko()->StyleData(nsCSSProps::kSIDTable[aProperty]);
 
   return styleContext.forget();
 }
 
 void
 KeyframeEffectReadOnly::CalculateCumulativeChangeHint(
   nsStyleContext *aStyleContext)
 {
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -81,16 +81,17 @@
 #include "nsIObjectLoadingContent.h"
 #include "nsTArray.h"
 #include "nsGenericDOMDataNode.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/ElementInlines.h"
 #include "nsAutoLayoutPhase.h"
 #include "nsStyleStructInlines.h"
 #include "nsPageContentFrame.h"
+#include "mozilla/GeckoStyleContext.h"
 #include "mozilla/RestyleManager.h"
 #include "mozilla/RestyleManagerInlines.h"
 #include "StickyScrollContainer.h"
 #include "nsFieldSetFrame.h"
 #include "nsInlineFrame.h"
 #include "nsBlockFrame.h"
 #include "nsCanvasFrame.h"
 #include "nsFirstLetterFrame.h"
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -37,16 +37,17 @@
 #include "nsPresContext.h"
 #include "nsStyleConsts.h"
 #include "nsIPresShell.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Sprintf.h"
 #include "nsFrameManager.h"
 #include "nsLayoutUtils.h"
 #include "LayoutLogging.h"
+#include "mozilla/GeckoStyleContext.h"
 #include "mozilla/GeckoRestyleManager.h"
 #include "mozilla/RestyleManager.h"
 #include "mozilla/RestyleManagerInlines.h"
 
 #include "nsIDOMNode.h"
 #include "nsISelection.h"
 #include "nsISelectionPrivate.h"
 #include "nsFrameSelection.h"
--- a/layout/style/GeckoStyleContext.cpp
+++ b/layout/style/GeckoStyleContext.cpp
@@ -764,8 +764,53 @@ GeckoStyleContext::ApplyStyleFixups(bool
 #undef GET_UNIQUE_STYLE_DATA
 }
 
 bool
 GeckoStyleContext::HasNoChildren() const
 {
   return (nullptr == mChild) && (nullptr == mEmptyChild);
 }
+
+void
+GeckoStyleContext::SetStyle(nsStyleStructID aSID, void* aStruct)
+{
+  // This method should only be called from nsRuleNode!  It is not a public
+  // method!
+
+  NS_ASSERTION(aSID >= 0 && aSID < nsStyleStructID_Length, "out of bounds");
+
+  // NOTE:  nsCachedStyleData::GetStyleData works roughly the same way.
+  // See the comments there (in nsRuleNode.h) for more details about
+  // what this is doing and why.
+
+  void** dataSlot;
+  if (nsCachedStyleData::IsReset(aSID)) {
+    if (!mCachedResetData) {
+      mCachedResetData = new (PresContext()) nsResetStyleData;
+    }
+    dataSlot = &mCachedResetData->mStyleStructs[aSID];
+  } else {
+    dataSlot = &mCachedInheritedData.mStyleStructs[aSID];
+  }
+  NS_ASSERTION(!*dataSlot || (mBits & nsCachedStyleData::GetBitForSID(aSID)),
+               "Going to leak style data");
+  *dataSlot = aStruct;
+}
+
+
+const void*
+GeckoStyleContext::StyleData(nsStyleStructID aSID)
+{
+  const void* cachedData = GetCachedStyleData(aSID);
+  if (cachedData)
+    return cachedData; // We have computed data stored on this node in the context tree.
+  // Our style source will take care of it for us.
+  const void* newData = AsGecko()->RuleNode()->GetStyleData(aSID, this->AsGecko(), true);
+  if (!nsCachedStyleData::IsReset(aSID)) {
+    // always cache inherited data on the style context; the rule
+    // node set the bit in mBits for us if needed.
+    mCachedInheritedData.mStyleStructs[aSID] = const_cast<void*>(newData);
+  }
+
+  return newData;
+}
+
--- a/layout/style/GeckoStyleContext.h
+++ b/layout/style/GeckoStyleContext.h
@@ -51,16 +51,38 @@ public:
   //    non-null, GetStyleIfVisited()->mRuleNode == aSourceIfVisited
   //  * RelevantLinkVisited() == aRelevantLinkVisited
   already_AddRefed<GeckoStyleContext>
   FindChildWithRules(const nsIAtom* aPseudoTag,
                      nsRuleNode* aSource,
                      nsRuleNode* aSourceIfVisited,
                      bool aRelevantLinkVisited);
 
+  // Tell this style context to cache aStruct as the struct for aSID
+  void SetStyle(nsStyleStructID aSID, void* aStruct);
+
+
+  /*
+   * Get the style data for a style struct.  This is the most important
+   * member function of nsStyleContext.  It fills in a const pointer
+   * to a style data struct that is appropriate for the style context's
+   * frame.  This struct may be shared with other contexts (either in
+   * the rule tree or the style context tree), so it should not be
+   * modified.
+   *
+   * This function will NOT return null (even when out of memory) when
+   * given a valid style struct ID, so the result does not need to be
+   * null-checked.
+   *
+   * The typesafe functions below are preferred to the use of this
+   * function, both because they're easier to read and because they're
+   * faster.
+   */
+  const void* NS_FASTCALL StyleData(nsStyleStructID aSID) MOZ_NONNULL_RETURN;
+
 #ifdef DEBUG
   void AssertChildStructsNotUsedElsewhere(nsStyleContext* aDestroyingContext,
                                           int32_t aLevels) const;
   void ListDescendants(FILE* out, int32_t aIndent);
 
 #endif
 
 #ifdef RESTYLE_LOGGING
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -45,16 +45,17 @@
 #include "nsSVGElement.h"
 #include "nsTArray.h"
 #include "nsTransitionManager.h"
 
 #include "mozilla/DeclarationBlockInlines.h"
 #include "mozilla/EffectCompositor.h"
 #include "mozilla/EffectSet.h"
 #include "mozilla/EventStates.h"
+#include "mozilla/GeckoStyleContext.h"
 #include "mozilla/Keyframe.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/ServoElementSnapshot.h"
 #include "mozilla/ServoRestyleManager.h"
 #include "mozilla/StyleAnimationValue.h"
 #include "mozilla/SystemGroup.h"
 #include "mozilla/ServoMediaList.h"
 #include "mozilla/RWLock.h"
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -3515,17 +3515,17 @@ ComputeValuesFromStyleRule(nsCSSProperty
     tmpStyleContext =
       styleSet->ResolveStyleByAddingRules(aStyleContext, ruleArray);
     if (!tmpStyleContext) {
       return false;
     }
 
     // Force walk of rule tree
     nsStyleStructID sid = nsCSSProps::kSIDTable[aProperty];
-    tmpStyleContext->StyleData(sid);
+    tmpStyleContext->AsGecko()->StyleData(sid);
 
     // The rule node will have unconditional cached style data if the value is
     // not context-sensitive.  So if there's nothing cached, it's not context
     // sensitive.
     *aIsContextSensitive =
       !tmpStyleContext->RuleNode()->NodeHasCachedUnconditionalData(sid);
   }
 
@@ -3966,17 +3966,17 @@ SetPositionCoordValue(const Position::Co
  */
 static void
 SubstitutePixelValues(nsStyleContext* aStyleContext,
                       const nsCSSValue& aInput, nsCSSValue& aOutput)
 {
   if (aInput.IsCalcUnit()) {
     RuleNodeCacheConditions conditions;
     nsRuleNode::ComputedCalc c =
-      nsRuleNode::SpecifiedCalcToComputedCalc(aInput, aStyleContext,
+      nsRuleNode::SpecifiedCalcToComputedCalc(aInput, aStyleContext->AsGecko(),
                                               aStyleContext->PresContext(),
                                               conditions);
     nsStyleCoord::CalcValue c2;
     c2.mLength = c.mLength;
     c2.mPercent = c.mPercent;
     c2.mHasPercent = true; // doesn't matter for transform translate
     CalcValueToCSSValue(&c2, aOutput);
   } else if (aInput.UnitHasArrayValue()) {
@@ -3986,17 +3986,17 @@ SubstitutePixelValues(nsStyleContext* aS
     for (size_t i = 0, i_end = inputArray->Count(); i < i_end; ++i) {
       SubstitutePixelValues(aStyleContext,
                             inputArray->Item(i), outputArray->Item(i));
     }
     aOutput.SetArrayValue(outputArray, aInput.GetUnit());
   } else if (aInput.IsLengthUnit() &&
              aInput.GetUnit() != eCSSUnit_Pixel) {
     RuleNodeCacheConditions conditions;
-    nscoord len = nsRuleNode::CalcLength(aInput, aStyleContext,
+    nscoord len = nsRuleNode::CalcLength(aInput, aStyleContext->AsGecko(),
                                          aStyleContext->PresContext(),
                                          conditions);
     aOutput.SetFloatValue(nsPresContext::AppUnitsToFloatCSSPixels(len),
                           eCSSUnit_Pixel);
   } else {
     aOutput = aInput;
   }
 }
@@ -4216,17 +4216,17 @@ SetFallbackValue(nsCSSValuePair* aPair, 
 bool
 StyleAnimationValue::ExtractComputedValue(nsCSSPropertyID aProperty,
                                           nsStyleContext* aStyleContext,
                                           StyleAnimationValue& aComputedValue)
 {
   MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT_no_shorthands,
              "bad property");
   const void* styleStruct =
-    aStyleContext->StyleData(nsCSSProps::kSIDTable[aProperty]);
+    aStyleContext->AsGecko()->StyleData(nsCSSProps::kSIDTable[aProperty]);
   ptrdiff_t ssOffset = nsCSSProps::kStyleStructOffsetTable[aProperty];
   nsStyleAnimType animType = nsCSSProps::kAnimTypeTable[aProperty];
   MOZ_ASSERT(0 <= ssOffset ||
              animType == eStyleAnimType_Custom ||
              animType == eStyleAnimType_Discrete,
              "all animation types other than Custom and Discrete must " \
              "specify a style struct offset to extract values from");
   switch (animType) {
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -34,17 +34,17 @@
 #include "nsIWidget.h"
 #include "nsIPresShell.h"
 #include "nsFontMetrics.h"
 #include "gfxFont.h"
 #include "nsCSSAnonBoxes.h"
 #include "nsCSSPseudoElements.h"
 #include "nsThemeConstants.h"
 #include "PLDHashTable.h"
-#include "nsStyleContext.h"
+#include "GeckoStyleContext.h"
 #include "nsStyleSet.h"
 #include "nsStyleStruct.h"
 #include "nsSize.h"
 #include "nsRuleData.h"
 #include "nsIStyleRule.h"
 #include "nsBidiUtils.h"
 #include "nsStyleStructInlines.h"
 #include "nsCSSProps.h"
@@ -86,17 +86,17 @@ enum UnsetAction
   eUnsetInitial,
   eUnsetInherit
 };
 
 } // namespace mozilla
 
 void*
 nsConditionalResetStyleData::GetConditionalStyleData(nsStyleStructID aSID,
-                               nsStyleContext* aStyleContext) const
+                               GeckoStyleContext* aStyleContext) const
 {
   Entry* e = static_cast<Entry*>(mEntries[aSID]);
   MOZ_ASSERT(e, "if mConditionalBits bit is set, we must have at least one "
                 "conditional style struct");
   do {
     if (e->mConditions.Matches(aStyleContext)) {
       void* data = e->mStyleStruct;
 
@@ -140,24 +140,24 @@ CreateStyleImageRequest(nsPresContext* a
   RefPtr<nsStyleImageRequest> request =
     new nsStyleImageRequest(aModeFlags, proxy, imageValue, imageTracker);
   return request.forget();
 }
 
 static void
 SetStyleShapeSourceToCSSValue(StyleShapeSource* aShapeSource,
                               const nsCSSValue* aValue,
-                              nsStyleContext* aStyleContext,
+                              GeckoStyleContext* aStyleContext,
                               nsPresContext* aPresContext,
                               RuleNodeCacheConditions& aConditions);
 
 /* Helper function to convert a CSS <position> specified value into its
  * computed-style form. */
 static void
-ComputePositionValue(nsStyleContext* aStyleContext,
+ComputePositionValue(GeckoStyleContext* aStyleContext,
                      const nsCSSValue& aValue,
                      Position& aComputedValue,
                      RuleNodeCacheConditions& aConditions);
 
 /*
  * For storage of an |nsRuleNode|'s children in a PLDHashTable.
  */
 
@@ -920,17 +920,17 @@ GetFloatFromBoxPosition(int32_t aEnumVal
 #define SETCOORD_LE     (SETCOORD_LENGTH | SETCOORD_ENUMERATED)
 #define SETCOORD_LEH    (SETCOORD_LE | SETCOORD_INHERIT)
 #define SETCOORD_IA     (SETCOORD_INTEGER | SETCOORD_AUTO)
 #define SETCOORD_LAE    (SETCOORD_LENGTH | SETCOORD_AUTO | SETCOORD_ENUMERATED)
 
 // changes aCoord iff it returns true
 static bool SetCoord(const nsCSSValue& aValue, nsStyleCoord& aCoord,
                        const nsStyleCoord& aParentCoord,
-                       int32_t aMask, nsStyleContext* aStyleContext,
+                       int32_t aMask, GeckoStyleContext* aStyleContext,
                        nsPresContext* aPresContext,
                        RuleNodeCacheConditions& aConditions)
 {
   bool result = true;
   if (aValue.GetUnit() == eCSSUnit_Null) {
     result = false;
   }
   else if ((((aMask & SETCOORD_LENGTH) != 0) &&
@@ -1049,17 +1049,17 @@ static inline bool SetAbsCoord(const nsC
   MOZ_ASSERT((aMask & (SETCOORD_LH | SETCOORD_UNSET_INHERIT |
                        SETCOORD_UNSET_INITIAL)) == 0,
              "does not handle SETCOORD_LENGTH, SETCOORD_INHERIT and "
              "SETCOORD_UNSET_*");
 
   // The values of the following variables will never be used; so it does not
   // matter what to set.
   const nsStyleCoord dummyParentCoord;
-  nsStyleContext* dummyStyleContext = nullptr;
+  GeckoStyleContext* dummyStyleContext = nullptr;
   nsPresContext* dummyPresContext = nullptr;
   RuleNodeCacheConditions dummyCacheKey;
 
   bool rv = SetCoord(aValue, aCoord, dummyParentCoord, aMask,
                        dummyStyleContext, dummyPresContext,
                        dummyCacheKey);
   MOZ_ASSERT(dummyCacheKey.CacheableWithoutDependencies(),
              "SetCoord() should not modify dummyCacheKey.");
@@ -1069,17 +1069,17 @@ static inline bool SetAbsCoord(const nsC
 
 /* Given a specified value that might be a pair value, call SetCoord twice,
  * either using each member of the pair, or using the unpaired value twice.
  */
 static bool
 SetPairCoords(const nsCSSValue& aValue,
               nsStyleCoord& aCoordX, nsStyleCoord& aCoordY,
               const nsStyleCoord& aParentX, const nsStyleCoord& aParentY,
-              int32_t aMask, nsStyleContext* aStyleContext,
+              int32_t aMask, GeckoStyleContext* aStyleContext,
               nsPresContext* aPresContext, RuleNodeCacheConditions& aConditions)
 {
   const nsCSSValue& valX =
     aValue.GetUnit() == eCSSUnit_Pair ? aValue.GetPairValue().mXValue : aValue;
   const nsCSSValue& valY =
     aValue.GetUnit() == eCSSUnit_Pair ? aValue.GetPairValue().mYValue : aValue;
 
   bool cX = SetCoord(valX, aCoordX, aParentX, aMask, aStyleContext,
@@ -1228,17 +1228,17 @@ SetComplexColor(const nsCSSValue& aValue
   }
 }
 
 template<UnsetAction UnsetTo>
 static Maybe<nscoord>
 ComputeLineWidthValue(const nsCSSValue& aValue,
                       const nscoord aParentCoord,
                       const nscoord aInitialCoord,
-                      nsStyleContext* aStyleContext,
+                      GeckoStyleContext* aStyleContext,
                       nsPresContext* aPresContext,
                       RuleNodeCacheConditions& aConditions)
 {
   nsCSSUnit unit = aValue.GetUnit();
   if (unit == eCSSUnit_Initial ||
       (UnsetTo == eUnsetInitial && unit == eCSSUnit_Unset)) {
     return Some(aInitialCoord);
   } else if (unit == eCSSUnit_Inherit ||
@@ -1264,30 +1264,30 @@ ComputeLineWidthValue(const nsCSSValue& 
   } else {
     NS_ASSERTION(unit == eCSSUnit_Null,
                  "Missing case handling for line-width computing!");
     return Maybe<nscoord>(Nothing());
   }
 }
 
 static void SetGradientCoord(const nsCSSValue& aValue, nsPresContext* aPresContext,
-                             nsStyleContext* aContext, nsStyleCoord& aResult,
+                             GeckoStyleContext* aContext, nsStyleCoord& aResult,
                              RuleNodeCacheConditions& aConditions)
 {
   // OK to pass bad aParentCoord since we're not passing SETCOORD_INHERIT
   if (!SetCoord(aValue, aResult, nsStyleCoord(),
                 SETCOORD_LPO | SETCOORD_BOX_POSITION | SETCOORD_STORE_CALC,
                 aContext, aPresContext, aConditions)) {
     NS_NOTREACHED("unexpected unit for gradient anchor point");
     aResult.SetNoneValue();
   }
 }
 
 static void SetGradient(const nsCSSValue& aValue, nsPresContext* aPresContext,
-                        nsStyleContext* aContext, nsStyleGradient& aResult,
+                        GeckoStyleContext* aContext, nsStyleGradient& aResult,
                         RuleNodeCacheConditions& aConditions)
 {
   MOZ_ASSERT(aValue.GetUnit() == eCSSUnit_Gradient,
              "The given data is not a gradient");
 
   const nsCSSValueGradient* gradient = aValue.GetGradientValue();
 
   if (gradient->mIsExplicitSize) {
@@ -1375,17 +1375,17 @@ static void SetGradient(const nsCSSValue
       stop.mColor = NS_RGB(0, 0, 0);
     }
 
     aResult.mStops.AppendElement(stop);
   }
 }
 
 // -moz-image-rect(<uri>, <top>, <right>, <bottom>, <left>)
-static void SetStyleImageToImageRect(nsStyleContext* aStyleContext,
+static void SetStyleImageToImageRect(GeckoStyleContext* aStyleContext,
                                      const nsCSSValue& aValue,
                                      nsStyleImage& aResult)
 {
   MOZ_ASSERT(aValue.GetUnit() == eCSSUnit_Function &&
              aValue.EqualsFunction(eCSSKeyword__moz_image_rect),
              "the value is not valid -moz-image-rect()");
 
   nsCSSValue::Array* arr = aValue.GetArrayValue();
@@ -1410,17 +1410,17 @@ static void SetStyleImageToImageRect(nsS
 #endif
       SetAbsCoord(val, coord, SETCOORD_FACTOR | SETCOORD_PERCENT);
     MOZ_ASSERT(unitOk, "Incorrect data structure created by CSS parser");
     cropRect.Set(side, coord);
   }
   aResult.SetCropRect(MakeUnique<nsStyleSides>(cropRect));
 }
 
-static void SetStyleImage(nsStyleContext* aStyleContext,
+static void SetStyleImage(GeckoStyleContext* aStyleContext,
                           const nsCSSValue& aValue,
                           nsStyleImage& aResult,
                           RuleNodeCacheConditions& aConditions)
 {
   if (aValue.GetUnit() == eCSSUnit_Null) {
     return;
   }
 
@@ -1981,25 +1981,25 @@ nsRuleNode::PropagateDependentBit(nsStyl
 
     if (curr->IsUsedDirectly()) {
       curr->mStyleData.SetStyleData(aSID, mPresContext, aStruct);
     }
   }
 }
 
 /* static */ void
-nsRuleNode::PropagateGrandancestorBit(nsStyleContext* aContext,
-                                      nsStyleContext* aContextInheritedFrom)
+nsRuleNode::PropagateGrandancestorBit(GeckoStyleContext* aContext,
+                                      GeckoStyleContext* aContextInheritedFrom)
 {
   MOZ_ASSERT(aContext);
   MOZ_ASSERT(aContextInheritedFrom &&
              aContextInheritedFrom != aContext,
              "aContextInheritedFrom must be an ancestor of aContext");
 
-  for (nsStyleContext* context = aContext->GetParent();
+  for (GeckoStyleContext* context = aContext->GetParent();
        context != aContextInheritedFrom;
        context = context->GetParent()) {
     if (!context) {
       MOZ_ASSERT(false, "aContextInheritedFrom must be an ancestor of "
                         "aContext's parent");
       break;
     }
     context->AddStyleBit(NS_STYLE_CHILD_USES_GRANDANCESTOR_STYLE);
@@ -2391,17 +2391,17 @@ nsRuleNode::CheckSpecifiedProperties(con
 
   return result;
 }
 
 // If we need to restrict which properties apply to the style context,
 // return the bit to check in nsCSSProp's flags table.  Otherwise,
 // return 0.
 inline uint32_t
-GetPseudoRestriction(nsStyleContext *aContext)
+GetPseudoRestriction(GeckoStyleContext *aContext)
 {
   // This needs to match nsStyleSet::WalkRestrictionRule.
   uint32_t pseudoRestriction = 0;
   nsIAtom *pseudoType = aContext->GetPseudo();
   if (pseudoType) {
     if (pseudoType == nsCSSPseudoElements::firstLetter) {
       pseudoRestriction = CSS_PROPERTY_APPLIES_TO_FIRST_LETTER;
     } else if (pseudoType == nsCSSPseudoElements::firstLine) {
@@ -2452,17 +2452,17 @@ AutoCSSValueArray::~AutoCSSValueArray()
   for (size_t i = 0; i < mCount; ++i) {
     mArray[i].~nsCSSValue();
   }
 }
 
 /* static */ bool
 nsRuleNode::ResolveVariableReferences(const nsStyleStructID aSID,
                                       nsRuleData* aRuleData,
-                                      nsStyleContext* aContext)
+                                      GeckoStyleContext* aContext)
 {
   MOZ_ASSERT(aSID != eStyleStruct_Variables);
   MOZ_ASSERT(aRuleData->mSIDs & nsCachedStyleData::GetBitForSID(aSID));
   MOZ_ASSERT(aRuleData->mValueOffsets[aSID] == 0);
 
   nsCSSParser parser;
   bool anyTokenStreams = false;
 
@@ -2504,17 +2504,17 @@ nsRuleNode::ResolveVariableReferences(co
     anyTokenStreams = true;
   }
 
   return anyTokenStreams;
 }
 
 const void*
 nsRuleNode::WalkRuleTree(const nsStyleStructID aSID,
-                         nsStyleContext* aContext)
+                         GeckoStyleContext* aContext)
 {
   // use placement new[] on the result of alloca() to allocate a
   // variable-sized stack array, including execution of constructors,
   // and use an RAII class to run the destructors too.
   size_t nprops = nsCSSProps::PropertyCountInStruct(aSID);
   void* dataStorage = alloca(nprops * sizeof(nsCSSValue));
   AutoCSSValueArray dataArray(dataStorage, nprops);
 
@@ -2684,17 +2684,17 @@ nsRuleNode::WalkRuleTree(const nsStyleSt
     // We must check |!isReset| because the Compute*Data functions for
     // reset structs wouldn't handle none bits correctly.
     if (highestNode != this && !isReset)
       PropagateNoneBit(bit, highestNode);
 
     // All information must necessarily be inherited from our parent style context.
     // In the absence of any computed data in the rule tree and with
     // no rules specified that didn't have values of 'inherit', we should check our parent.
-    nsStyleContext* parentContext = aContext->GetParent();
+    GeckoStyleContext* parentContext = aContext->GetParent();
     if (isReset) {
       /* Reset structs don't inherit from first-line. */
       /* See similar code in COMPUTE_START_RESET */
       while (parentContext &&
              parentContext->GetPseudo() == nsCSSPseudoElements::firstLine) {
         parentContext = parentContext->GetParent();
       }
       if (parentContext && parentContext != aContext->GetParent()) {
@@ -2716,33 +2716,33 @@ nsRuleNode::WalkRuleTree(const nsStyleSt
     }
     else
       // We are the root.  In the case of fonts, the default values just
       // come from the pres context.
       return SetDefaultOnRoot(aSID, aContext);
   }
 
   typedef const void* (nsRuleNode::*ComputeFunc)(void*, const nsRuleData*,
-                                                 nsStyleContext*, nsRuleNode*,
+                                                 GeckoStyleContext*, nsRuleNode*,
                                                  RuleDetail,
                                                  const RuleNodeCacheConditions);
   static const ComputeFunc sComputeFuncs[] = {
 #define STYLE_STRUCT(name, checkdata_cb) &nsRuleNode::Compute##name##Data,
 #include "nsStyleStructList.h"
 #undef STYLE_STRUCT
   };
 
   // We need to compute the data from the information that the rules specified.
   return (this->*sComputeFuncs[aSID])(startStruct, &ruleData, aContext,
                                       highestNode, detail,
                                       ruleData.mConditions);
 }
 
 const void*
-nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsStyleContext* aContext)
+nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, GeckoStyleContext* aContext)
 {
   switch (aSID) {
     case eStyleStruct_Font:
     {
       nsStyleFont* fontData = new (mPresContext) nsStyleFont(mPresContext);
       nscoord minimumFontSize = mPresContext->MinFontSize(fontData->mLanguage);
 
       if (minimumFontSize > 0 && !mPresContext->IsChrome()) {
@@ -2911,17 +2911,17 @@ nsRuleNode::SetDefaultOnRoot(const nsSty
  *              function.
  * @param parentdata_ Variable (declared here) holding the parent style
  *                    context's data for this struct.
  */
 #define COMPUTE_START_INHERITED(type_, data_, parentdata_)                    \
   NS_ASSERTION(aRuleDetail != eRuleFullInherited,                             \
                "should not have bothered calling Compute*Data");              \
                                                                               \
-  nsStyleContext* parentContext = aContext->GetParent();                      \
+  GeckoStyleContext* parentContext = aContext->GetParent();                   \
                                                                               \
   nsStyle##type_* data_ = nullptr;                                            \
   mozilla::Maybe<nsStyle##type_> maybeFakeParentData;                         \
   const nsStyle##type_* parentdata_ = nullptr;                                \
   RuleNodeCacheConditions conditions = aConditions;                           \
                                                                               \
   /* If |conditions.Cacheable()| might be true by the time we're done, we */  \
   /* can't call parentContext->Style##type_() since it could recur into */    \
@@ -2971,17 +2971,17 @@ nsRuleNode::SetDefaultOnRoot(const nsSty
  *              function.
  * @param parentdata_ Variable (declared here) holding the parent style
  *                    context's data for this struct.
  */
 #define COMPUTE_START_RESET(type_, data_, parentdata_)                        \
   NS_ASSERTION(aRuleDetail != eRuleFullInherited,                             \
                "should not have bothered calling Compute*Data");              \
                                                                               \
-  nsStyleContext* parentContext = aContext->GetParent();                      \
+  GeckoStyleContext* parentContext = aContext->GetParent();                   \
   /* Reset structs don't inherit from first-line */                           \
   /* See similar code in WalkRuleTree */                                      \
   while (parentContext &&                                                     \
          parentContext->GetPseudo() == nsCSSPseudoElements::firstLine) {      \
     parentContext = parentContext->GetParent();                               \
   }                                                                           \
                                                                               \
   nsStyle##type_* data_;                                                      \
@@ -3299,23 +3299,23 @@ struct SetFontSizeCalcOps : public css::
   // resolve coeff_type (BasicCoordCalcOps and FloatCoeffsAlreadyNormalizedOps
   // both have |typedef float coeff_type|).
   typedef float coeff_type;
 
   // The parameters beyond aValue that we need for CalcLengthWith.
   const nscoord mParentSize;
   const nsStyleFont* const mParentFont;
   nsPresContext* const mPresContext;
-  nsStyleContext* const mStyleContext;
+  GeckoStyleContext* const mStyleContext;
   const bool mAtRoot;
   RuleNodeCacheConditions& mConditions;
 
   SetFontSizeCalcOps(nscoord aParentSize, const nsStyleFont* aParentFont,
                      nsPresContext* aPresContext,
-                     nsStyleContext* aStyleContext,
+                     GeckoStyleContext* aStyleContext,
                      bool aAtRoot,
                      RuleNodeCacheConditions& aConditions)
     : mParentSize(aParentSize),
       mParentFont(aParentFont),
       mPresContext(aPresContext),
       mStyleContext(aStyleContext),
       mAtRoot(aAtRoot),
       mConditions(aConditions)
@@ -3350,17 +3350,17 @@ struct SetFontSizeCalcOps : public css::
     }
 
     return size;
   }
 };
 
 /* static */ void
 nsRuleNode::SetFontSize(nsPresContext* aPresContext,
-                        nsStyleContext* aContext,
+                        GeckoStyleContext* aContext,
                         const nsRuleData* aRuleData,
                         const nsStyleFont* aFont,
                         const nsStyleFont* aParentFont,
                         nscoord* aSize,
                         const nsFont& aSystemFont,
                         nscoord aParentSize,
                         nscoord aScriptLevelAdjustedParentSize,
                         bool aUsedStartStruct,
@@ -3529,17 +3529,17 @@ nsRuleNode::ComputeSystemFont(nsFont* aS
         std::max(aDefaultVariableFont->size -
                  nsPresContext::CSSPointsToAppUnits(2), 0);
     }
 #endif
   }
 }
 
 /* static */ void
-nsRuleNode::SetFont(nsPresContext* aPresContext, nsStyleContext* aContext,
+nsRuleNode::SetFont(nsPresContext* aPresContext, GeckoStyleContext* aContext,
                     uint8_t aGenericFontID, const nsRuleData* aRuleData,
                     const nsStyleFont* aParentFont,
                     nsStyleFont* aFont, bool aUsedStartStruct,
                     RuleNodeCacheConditions& aConditions)
 {
   bool atRoot = !aContext->GetParent();
 
   // -x-text-zoom: none, inherit, initial
@@ -4156,24 +4156,24 @@ nsRuleNode::ComputeFontVariations(const 
 // This should die (bug 380915).
 //
 // SetGenericFont:
 //  - backtrack to an ancestor with the same generic font name (possibly
 //    up to the root where default values come from the presentation context)
 //  - re-apply cascading rules from there without caching intermediate values
 /* static */ void
 nsRuleNode::SetGenericFont(nsPresContext* aPresContext,
-                           nsStyleContext* aContext,
+                           GeckoStyleContext* aContext,
                            uint8_t aGenericFontID,
                            nsStyleFont* aFont)
 {
   // walk up the contexts until a context with the desired generic font
-  AutoTArray<nsStyleContext*, 8> contextPath;
+  AutoTArray<GeckoStyleContext*, 8> contextPath;
   contextPath.AppendElement(aContext);
-  nsStyleContext* higherContext = aContext->GetParent();
+  GeckoStyleContext* higherContext = aContext->GetParent();
   while (higherContext) {
     if (higherContext->StyleFont()->mGenericID == aGenericFontID) {
       // done walking up the higher contexts
       break;
     }
     contextPath.AppendElement(higherContext);
     higherContext = higherContext->GetParent();
   }
@@ -4196,17 +4196,17 @@ nsRuleNode::SetGenericFont(nsPresContext
 
   // use placement new[] on the result of alloca() to allocate a
   // variable-sized stack array, including execution of constructors,
   // and use an RAII class to run the destructors too.
   size_t nprops = nsCSSProps::PropertyCountInStruct(eStyleStruct_Font);
   void* dataStorage = alloca(nprops * sizeof(nsCSSValue));
 
   for (int32_t i = contextPath.Length() - 1; i >= 0; --i) {
-    nsStyleContext* context = contextPath[i];
+    GeckoStyleContext* context = contextPath[i];
     AutoCSSValueArray dataArray(dataStorage, nprops);
 
     nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Font), dataArray.get(),
                         aPresContext, context);
     ruleData.mValueOffsets[eStyleStruct_Font] = 0;
 
     // Trimmed down version of ::WalkRuleTree() to re-apply the style rules
     // Note that we *do* need to do this for our own data, since what is
@@ -4249,17 +4249,17 @@ nsRuleNode::SetGenericFont(nsPresContext
     // styles.
     PropagateGrandancestorBit(aContext, higherContext);
   }
 }
 
 const void*
 nsRuleNode::ComputeFontData(void* aStartStruct,
                             const nsRuleData* aRuleData,
-                            nsStyleContext* aContext,
+                            GeckoStyleContext* aContext,
                             nsRuleNode* aHighestNode,
                             const RuleDetail aRuleDetail,
                             const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_INHERITED(Font, font, parentFont)
 
   // NOTE:  The |aRuleDetail| passed in is a little bit conservative due
   // to the -moz-system-font property.  We really don't need to consider
@@ -4357,17 +4357,17 @@ inline uint32_t ListLength(const T* aLis
     len++;
     aList = aList->mNext;
   }
   return len;
 }
 
 static already_AddRefed<nsCSSShadowArray>
 GetShadowData(const nsCSSValueList* aList,
-              nsStyleContext* aContext,
+              GeckoStyleContext* aContext,
               bool aIsBoxShadow,
               nsPresContext* aPresContext,
               RuleNodeCacheConditions& aConditions)
 {
   uint32_t arrayLength = ListLength(aList);
 
   MOZ_ASSERT(arrayLength > 0,
              "Non-null text-shadow list, yet we counted 0 items.");
@@ -4498,21 +4498,21 @@ struct LengthNumberCalcObj
 {
   float mValue;
   bool mIsNumber;
 };
 
 struct LengthNumberCalcOps : public css::FloatCoeffsAlreadyNormalizedOps
 {
   typedef LengthNumberCalcObj result_type;
-  nsStyleContext* const mStyleContext;
+  GeckoStyleContext* const mStyleContext;
   nsPresContext* const mPresContext;
   RuleNodeCacheConditions& mConditions;
 
-  LengthNumberCalcOps(nsStyleContext* aStyleContext,
+  LengthNumberCalcOps(GeckoStyleContext* aStyleContext,
                       nsPresContext* aPresContext,
                       RuleNodeCacheConditions& aConditions)
     : mStyleContext(aStyleContext),
       mPresContext(aPresContext),
       mConditions(aConditions)
   {
   }
 
@@ -4580,17 +4580,17 @@ struct LengthNumberCalcOps : public css:
     }
 
     return result;
   }
 };
 
 struct SetLineHeightCalcOps : public LengthNumberCalcOps
 {
-  SetLineHeightCalcOps(nsStyleContext* aStyleContext,
+  SetLineHeightCalcOps(GeckoStyleContext* aStyleContext,
                        nsPresContext* aPresContext,
                        RuleNodeCacheConditions& aConditions)
     : LengthNumberCalcOps(aStyleContext, aPresContext, aConditions)
   {
   }
 
   result_type ComputeLeafValue(const nsCSSValue& aValue)
   {
@@ -4617,17 +4617,17 @@ struct SetLineHeightCalcOps : public Len
 
     return result;
   }
 };
 
 const void*
 nsRuleNode::ComputeTextData(void* aStartStruct,
                             const nsRuleData* aRuleData,
-                            nsStyleContext* aContext,
+                            GeckoStyleContext* aContext,
                             nsRuleNode* aHighestNode,
                             const RuleDetail aRuleDetail,
                             const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_INHERITED(Text, text, parentText)
 
   auto setComplexColor = [&](const nsCSSValue* aValue,
                              StyleComplexColor nsStyleText::* aField) {
@@ -4743,17 +4743,17 @@ nsRuleNode::ComputeTextData(void* aStart
     conditions.SetUncacheable();
     uint8_t parentAlign = parentText->mTextAlign;
     text->mTextAlign = (NS_STYLE_TEXT_ALIGN_START == parentAlign) ?
       NS_STYLE_TEXT_ALIGN_CENTER : parentAlign;
   } else if (eCSSUnit_Enumerated == textAlignValue->GetUnit() &&
              NS_STYLE_TEXT_ALIGN_MATCH_PARENT ==
                textAlignValue->GetIntValue()) {
     conditions.SetUncacheable();
-    nsStyleContext* parent = aContext->GetParent();
+    GeckoStyleContext* parent = aContext->GetParent();
     if (parent) {
       uint8_t parentAlign = parentText->mTextAlign;
       uint8_t parentDirection = parent->StyleVisibility()->mDirection;
       switch (parentAlign) {
         case NS_STYLE_TEXT_ALIGN_START:
           text->mTextAlign = parentDirection == NS_STYLE_DIRECTION_RTL ?
             NS_STYLE_TEXT_ALIGN_RIGHT : NS_STYLE_TEXT_ALIGN_LEFT;
           break;
@@ -4999,17 +4999,17 @@ nsRuleNode::ComputeTextData(void* aStart
            nsCSSParser::ControlCharVisibilityDefault());
 
   COMPUTE_END_INHERITED(Text, text)
 }
 
 const void*
 nsRuleNode::ComputeTextResetData(void* aStartStruct,
                                  const nsRuleData* aRuleData,
-                                 nsStyleContext* aContext,
+                                 GeckoStyleContext* aContext,
                                  nsRuleNode* aHighestNode,
                                  const RuleDetail aRuleDetail,
                                  const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_RESET(TextReset, text, parentText)
 
   // text-decoration-line: enum (bit field), inherit, initial
   const nsCSSValue* decorationLineValue =
@@ -5138,17 +5138,17 @@ nsRuleNode::ComputeTextResetData(void* a
   }
 
   COMPUTE_END_RESET(TextReset, text)
 }
 
 const void*
 nsRuleNode::ComputeUserInterfaceData(void* aStartStruct,
                                      const nsRuleData* aRuleData,
-                                     nsStyleContext* aContext,
+                                     GeckoStyleContext* aContext,
                                      nsRuleNode* aHighestNode,
                                      const RuleDetail aRuleDetail,
                                      const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_INHERITED(UserInterface, ui, parentUI)
 
   // cursor: enum, url, inherit
   const nsCSSValue* cursorValue = aRuleData->ValueForCursor();
@@ -5228,17 +5228,17 @@ nsRuleNode::ComputeUserInterfaceData(voi
                                  ui->mCaretColor, conditions);
 
   COMPUTE_END_INHERITED(UserInterface, ui)
 }
 
 const void*
 nsRuleNode::ComputeUIResetData(void* aStartStruct,
                                const nsRuleData* aRuleData,
-                               nsStyleContext* aContext,
+                               GeckoStyleContext* aContext,
                                nsRuleNode* aHighestNode,
                                const RuleDetail aRuleDetail,
                                const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_RESET(UIReset, ui, parentUI)
 
   // user-select: enum, inherit, initial
   SetValue(*aRuleData->ValueForUserSelect(),
@@ -5482,17 +5482,17 @@ GetWillChangeBitFieldFromPropFlags(const
   }
 
   return willChangeBitField;
 }
 
 const void*
 nsRuleNode::ComputeDisplayData(void* aStartStruct,
                                const nsRuleData* aRuleData,
-                               nsStyleContext* aContext,
+                               GeckoStyleContext* aContext,
                                nsRuleNode* aHighestNode,
                                const RuleDetail aRuleDetail,
                                const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_RESET(Display, display, parentDisplay)
 
   // We may have ended up with aStartStruct's values of mDisplay and
   // mFloat, but those may not be correct if our style data overrides
@@ -6579,17 +6579,17 @@ nsRuleNode::ComputeDisplayData(void* aSt
   }
 
   COMPUTE_END_RESET(Display, display)
 }
 
 const void*
 nsRuleNode::ComputeVisibilityData(void* aStartStruct,
                                   const nsRuleData* aRuleData,
-                                  nsStyleContext* aContext,
+                                  GeckoStyleContext* aContext,
                                   nsRuleNode* aHighestNode,
                                   const RuleDetail aRuleDetail,
                                   const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_INHERITED(Visibility, visibility, parentVisibility)
 
   // IMPORTANT: No properties in this struct have lengths in them.  We
   // depend on this since CalcLengthWith can call StyleVisibility()
@@ -6677,17 +6677,17 @@ nsRuleNode::ComputeVisibilityData(void* 
            NS_STYLE_COLOR_ADJUST_ECONOMY);
 
   COMPUTE_END_INHERITED(Visibility, visibility)
 }
 
 const void*
 nsRuleNode::ComputeColorData(void* aStartStruct,
                              const nsRuleData* aRuleData,
-                             nsStyleContext* aContext,
+                             GeckoStyleContext* aContext,
                              nsRuleNode* aHighestNode,
                              const RuleDetail aRuleDetail,
                              const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_INHERITED(Color, color, parentColor)
 
   // color: color, string, inherit
   // Special case for currentColor.  According to CSS3, setting color to 'currentColor'
@@ -6713,30 +6713,30 @@ nsRuleNode::ComputeColorData(void* aStar
 // information about how to compute values for background-* properties
 template <class SpecifiedValueItem, class ComputedValueItem>
 struct BackgroundItemComputer {
 };
 
 template <>
 struct BackgroundItemComputer<nsCSSValueList, uint8_t>
 {
-  static void ComputeValue(nsStyleContext* aStyleContext,
+  static void ComputeValue(GeckoStyleContext* aStyleContext,
                            const nsCSSValueList* aSpecifiedValue,
                            uint8_t& aComputedValue,
                            RuleNodeCacheConditions& aConditions)
   {
     SetValue(aSpecifiedValue->mValue, aComputedValue, aConditions,
              SETVAL_ENUMERATED, uint8_t(0), 0);
   }
 };
 
 template <>
 struct BackgroundItemComputer<nsCSSValuePairList, nsStyleImageLayers::Repeat>
 {
-  static void ComputeValue(nsStyleContext* aStyleContext,
+  static void ComputeValue(GeckoStyleContext* aStyleContext,
                            const nsCSSValuePairList* aSpecifiedValue,
                            nsStyleImageLayers::Repeat& aComputedValue,
                            RuleNodeCacheConditions& aConditions)
   {
     NS_ASSERTION(aSpecifiedValue->mXValue.GetUnit() == eCSSUnit_Enumerated &&
                  (aSpecifiedValue->mYValue.GetUnit() == eCSSUnit_Enumerated ||
                   aSpecifiedValue->mYValue.GetUnit() == eCSSUnit_Null),
                  "Invalid unit");
@@ -6787,47 +6787,47 @@ struct BackgroundItemComputer<nsCSSValue
       break;
     }
   }
 };
 
 template <>
 struct BackgroundItemComputer<nsCSSValueList, nsStyleImage>
 {
-  static void ComputeValue(nsStyleContext* aStyleContext,
+  static void ComputeValue(GeckoStyleContext* aStyleContext,
                            const nsCSSValueList* aSpecifiedValue,
                            nsStyleImage& aComputedValue,
                            RuleNodeCacheConditions& aConditions)
   {
     SetStyleImage(aStyleContext, aSpecifiedValue->mValue, aComputedValue,
                   aConditions);
   }
 };
 
 template <typename T>
 struct BackgroundItemComputer<nsCSSValueList, T>
 {
   typedef typename EnableIf<IsEnum<T>::value, T>::Type ComputedType;
 
-  static void ComputeValue(nsStyleContext* aStyleContext,
+  static void ComputeValue(GeckoStyleContext* aStyleContext,
                            const nsCSSValueList* aSpecifiedValue,
                            ComputedType& aComputedValue,
                            RuleNodeCacheConditions& aConditions)
   {
     aComputedValue =
       static_cast<T>(aSpecifiedValue->mValue.GetIntValue());
   }
 };
 
 /* Helper function for ComputePositionValue.
  * This function computes a single PositionCoord from two nsCSSValue objects,
  * which represent an edge and an offset from that edge.
  */
 static void
-ComputePositionCoord(nsStyleContext* aStyleContext,
+ComputePositionCoord(GeckoStyleContext* aStyleContext,
                      const nsCSSValue& aEdge,
                      const nsCSSValue& aOffset,
                      Position::Coord* aResult,
                      RuleNodeCacheConditions& aConditions)
 {
   if (eCSSUnit_Percent == aOffset.GetUnit()) {
     aResult->mLength = 0;
     aResult->mPercent = aOffset.GetPercentValue();
@@ -6868,17 +6868,17 @@ ComputePositionCoord(nsStyleContext* aSt
   } else {
     NS_ASSERTION(eCSSUnit_Null == aEdge.GetUnit(), "unexpected unit");
   }
 }
 
 /* Helper function to convert a CSS <position> specified value into its
  * computed-style form. */
 static void
-ComputePositionValue(nsStyleContext* aStyleContext,
+ComputePositionValue(GeckoStyleContext* aStyleContext,
                      const nsCSSValue& aValue,
                      Position& aComputedValue,
                      RuleNodeCacheConditions& aConditions)
 {
   NS_ASSERTION(aValue.GetUnit() == eCSSUnit_Array,
                "unexpected unit for CSS <position> value");
 
   RefPtr<nsCSSValue::Array> positionArray = aValue.GetArrayValue();
@@ -6905,17 +6905,17 @@ ComputePositionValue(nsStyleContext* aSt
   ComputePositionCoord(aStyleContext, yEdge, yOffset,
                        &aComputedValue.mYPosition,
                        aConditions);
 }
 
 /* Helper function to convert the -x or -y part of a CSS <position> specified
  * value into its computed-style form. */
 static void
-ComputePositionCoordValue(nsStyleContext* aStyleContext,
+ComputePositionCoordValue(GeckoStyleContext* aStyleContext,
                           const nsCSSValue& aValue,
                           Position::Coord& aComputedValue,
                           RuleNodeCacheConditions& aConditions)
 {
   NS_ASSERTION(aValue.GetUnit() == eCSSUnit_Array,
                "unexpected unit for position coord value");
 
   RefPtr<nsCSSValue::Array> positionArray = aValue.GetArrayValue();
@@ -6948,17 +6948,17 @@ static const BackgroundSizeAxis gBGSizeA
   { &nsCSSValuePairList::mYValue,
     &nsStyleImageLayers::Size::mHeight,
     &nsStyleImageLayers::Size::mHeightType }
 };
 
 template <>
 struct BackgroundItemComputer<nsCSSValuePairList, nsStyleImageLayers::Size>
 {
-  static void ComputeValue(nsStyleContext* aStyleContext,
+  static void ComputeValue(GeckoStyleContext* aStyleContext,
                            const nsCSSValuePairList* aSpecifiedValue,
                            nsStyleImageLayers::Size& aComputedValue,
                            RuleNodeCacheConditions& aConditions)
   {
     nsStyleImageLayers::Size &size = aComputedValue;
     for (const BackgroundSizeAxis *axis = gBGSizeAxes,
                         *axis_end = ArrayEnd(gBGSizeAxes);
          axis < axis_end; ++axis) {
@@ -7031,17 +7031,17 @@ struct BackgroundItemComputer<nsCSSValue
                 size.mWidthType != nsStyleImageLayers::Size::eCover) ||
                size.mWidthType == size.mHeightType,
                "contain/cover apply to both dimensions or to neither");
   }
 };
 
 template <class ComputedValueItem>
 static void
-SetImageLayerList(nsStyleContext* aStyleContext,
+SetImageLayerList(GeckoStyleContext* aStyleContext,
                   const nsCSSValue& aValue,
                   nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
                   const nsStyleAutoArray<nsStyleImageLayers::Layer>& aParentLayers,
                   ComputedValueItem nsStyleImageLayers::Layer::* aResultLocation,
                   ComputedValueItem aInitialValue,
                   uint32_t aParentItemCount,
                   uint32_t& aItemCount,
                   uint32_t& aMaxItemCount,
@@ -7100,17 +7100,17 @@ SetImageLayerList(nsStyleContext* aStyle
 }
 
 // The same as SetImageLayerList, but for values stored in
 // layer.mPosition.*aResultLocation instead of layer.*aResultLocation.
 // This code is duplicated because it would be annoying to make
 // SetImageLayerList generic enough to handle both cases.
 static void
 SetImageLayerPositionCoordList(
-                  nsStyleContext* aStyleContext,
+                  GeckoStyleContext* aStyleContext,
                   const nsCSSValue& aValue,
                   nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
                   const nsStyleAutoArray<nsStyleImageLayers::Layer>& aParentLayers,
                   Position::Coord
                       Position::* aResultLocation,
                   Position::Coord aInitialValue,
                   uint32_t aParentItemCount,
                   uint32_t& aItemCount,
@@ -7166,17 +7166,17 @@ SetImageLayerPositionCoordList(
   }
 
   if (aItemCount > aMaxItemCount)
     aMaxItemCount = aItemCount;
 }
 
 template <class ComputedValueItem>
 static void
-SetImageLayerPairList(nsStyleContext* aStyleContext,
+SetImageLayerPairList(GeckoStyleContext* aStyleContext,
                       const nsCSSValue& aValue,
                       nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
                       const nsStyleAutoArray<nsStyleImageLayers::Layer>& aParentLayers,
                       ComputedValueItem nsStyleImageLayers::Layer::*
                                                                 aResultLocation,
                       ComputedValueItem aInitialValue,
                       uint32_t aParentItemCount,
                       uint32_t& aItemCount,
@@ -7314,17 +7314,17 @@ nsRuleNode::FillAllBackgroundLists(nsSty
   FillImageLayerList(aImage.mLayers,
                      &nsStyleImageLayers::Layer::mComposite,
                      aImage.mCompositeCount, fillCount);
 }
 
 const void*
 nsRuleNode::ComputeBackgroundData(void* aStartStruct,
                                   const nsRuleData* aRuleData,
-                                  nsStyleContext* aContext,
+                                  GeckoStyleContext* aContext,
                                   nsRuleNode* aHighestNode,
                                   const RuleDetail aRuleDetail,
                                   const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_RESET(Background, bg, parentBG)
 
   // background-color: color, inherit
   SetComplexColor<eUnsetInitial>(*aRuleData->ValueForBackgroundColor(),
@@ -7435,17 +7435,17 @@ nsRuleNode::ComputeBackgroundData(void* 
   }
 
   COMPUTE_END_RESET(Background, bg)
 }
 
 const void*
 nsRuleNode::ComputeMarginData(void* aStartStruct,
                               const nsRuleData* aRuleData,
-                              nsStyleContext* aContext,
+                              GeckoStyleContext* aContext,
                               nsRuleNode* aHighestNode,
                               const RuleDetail aRuleDetail,
                               const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_RESET(Margin, margin, parentMargin)
 
   // margin: length, percent, calc, inherit
   const nsCSSPropertyID* subprops =
@@ -7540,17 +7540,17 @@ SetBorderImageSlice(const nsCSSValue& aV
   default:
     NS_ASSERTION(false, "Unexpected border image value for pair.");
   }
 }
 
 const void*
 nsRuleNode::ComputeBorderData(void* aStartStruct,
                               const nsRuleData* aRuleData,
-                              nsStyleContext* aContext,
+                              GeckoStyleContext* aContext,
                               nsRuleNode* aHighestNode,
                               const RuleDetail aRuleDetail,
                               const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_RESET(Border, border, parentBorder)
 
   // box-decoration-break: enum, inherit, initial
   SetValue(*aRuleData->ValueForBoxDecorationBreak(),
@@ -7799,17 +7799,17 @@ nsRuleNode::ComputeBorderData(void* aSta
            NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH);
 
   COMPUTE_END_RESET(Border, border)
 }
 
 const void*
 nsRuleNode::ComputePaddingData(void* aStartStruct,
                                const nsRuleData* aRuleData,
-                               nsStyleContext* aContext,
+                               GeckoStyleContext* aContext,
                                nsRuleNode* aHighestNode,
                                const RuleDetail aRuleDetail,
                                const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_RESET(Padding, padding, parentPadding)
 
   // padding: length, percent, calc, inherit
   const nsCSSPropertyID* subprops =
@@ -7827,17 +7827,17 @@ nsRuleNode::ComputePaddingData(void* aSt
   }
 
   COMPUTE_END_RESET(Padding, padding)
 }
 
 const void*
 nsRuleNode::ComputeOutlineData(void* aStartStruct,
                                const nsRuleData* aRuleData,
-                               nsStyleContext* aContext,
+                               GeckoStyleContext* aContext,
                                nsRuleNode* aHighestNode,
                                const RuleDetail aRuleDetail,
                                const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_RESET(Outline, outline, parentOutline)
 
   // outline-width: length, enum, inherit
   Maybe<nscoord> coord =
@@ -7911,17 +7911,17 @@ nsRuleNode::ComputeOutlineData(void* aSt
 
   outline->RecalcData();
   COMPUTE_END_RESET(Outline, outline)
 }
 
 const void*
 nsRuleNode::ComputeListData(void* aStartStruct,
                             const nsRuleData* aRuleData,
-                            nsStyleContext* aContext,
+                            GeckoStyleContext* aContext,
                             nsRuleNode* aHighestNode,
                             const RuleDetail aRuleDetail,
                             const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_INHERITED(List, list, parentList)
 
   // quotes: inherit, initial, none, [string string]+
   const nsCSSValue* quotesValue = aRuleData->ValueForQuotes();
@@ -8102,17 +8102,17 @@ nsRuleNode::ComputeListData(void* aStart
   }
 
   COMPUTE_END_INHERITED(List, list)
 }
 
 static void
 SetGridTrackBreadth(const nsCSSValue& aValue,
                     nsStyleCoord& aResult,
-                    nsStyleContext* aStyleContext,
+                    GeckoStyleContext* aStyleContext,
                     nsPresContext* aPresContext,
                     RuleNodeCacheConditions& aConditions)
 {
   nsCSSUnit unit = aValue.GetUnit();
   if (unit == eCSSUnit_FlexFraction) {
     aResult.SetFlexFractionValue(aValue.GetFloatValue());
   } else if (unit == eCSSUnit_Auto) {
     aResult.SetAutoValue();
@@ -8130,17 +8130,17 @@ SetGridTrackBreadth(const nsCSSValue& aV
     MOZ_ASSERT(stored, "invalid <track-size> value");
   }
 }
 
 static void
 SetGridTrackSize(const nsCSSValue& aValue,
                  nsStyleCoord& aResultMin,
                  nsStyleCoord& aResultMax,
-                 nsStyleContext* aStyleContext,
+                 GeckoStyleContext* aStyleContext,
                  nsPresContext* aPresContext,
                  RuleNodeCacheConditions& aConditions)
 {
   if (aValue.GetUnit() == eCSSUnit_Function) {
     nsCSSValue::Array* func = aValue.GetArrayValue();
     auto funcName = func->Item(0).GetKeywordValue();
     if (funcName == eCSSKeyword_minmax) {
       SetGridTrackBreadth(func->Item(1), aResultMin,
@@ -8166,17 +8166,17 @@ SetGridTrackSize(const nsCSSValue& aValu
 }
 
 static void
 SetGridAutoColumnsRows(const nsCSSValue& aValue,
                        nsStyleCoord& aResultMin,
                        nsStyleCoord& aResultMax,
                        const nsStyleCoord& aParentValueMin,
                        const nsStyleCoord& aParentValueMax,
-                       nsStyleContext* aStyleContext,
+                       GeckoStyleContext* aStyleContext,
                        nsPresContext* aPresContext,
                        RuleNodeCacheConditions& aConditions)
 
 {
   switch (aValue.GetUnit()) {
   case eCSSUnit_Null:
     break;
 
@@ -8216,17 +8216,17 @@ AppendGridLineNames(const nsCSSValue& aV
     } while (item);
   }
 }
 
 static void
 SetGridTrackList(const nsCSSValue& aValue,
                  nsStyleGridTemplate& aResult,
                  const nsStyleGridTemplate& aParentValue,
-                 nsStyleContext* aStyleContext,
+                 GeckoStyleContext* aStyleContext,
                  nsPresContext* aPresContext,
                  RuleNodeCacheConditions& aConditions)
 
 {
   switch (aValue.GetUnit()) {
   case eCSSUnit_Null:
     break;
 
@@ -8408,17 +8408,17 @@ SetGridLine(const nsCSSValue& aValue,
     MOZ_ASSERT(!aResult.IsAuto(),
                "should have set something away from default value");
   }
 }
 
 const void*
 nsRuleNode::ComputePositionData(void* aStartStruct,
                                 const nsRuleData* aRuleData,
-                                nsStyleContext* aContext,
+                                GeckoStyleContext* aContext,
                                 nsRuleNode* aHighestNode,
                                 const RuleDetail aRuleDetail,
                                 const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_RESET(Position, pos, parentPos)
 
   // box offsets: length, percent, calc, auto, inherit
   static const nsCSSPropertyID offsetProps[] = {
@@ -8751,17 +8751,17 @@ nsRuleNode::ComputePositionData(void* aS
   }
 
   COMPUTE_END_RESET(Position, pos)
 }
 
 const void*
 nsRuleNode::ComputeTableData(void* aStartStruct,
                              const nsRuleData* aRuleData,
-                             nsStyleContext* aContext,
+                             GeckoStyleContext* aContext,
                              nsRuleNode* aHighestNode,
                              const RuleDetail aRuleDetail,
                              const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_RESET(Table, table, parentTable)
 
   // table-layout: enum, inherit, initial
   SetValue(*aRuleData->ValueForTableLayout(),
@@ -8777,17 +8777,17 @@ nsRuleNode::ComputeTableData(void* aStar
     table->mSpan = spanValue->GetIntValue();
 
   COMPUTE_END_RESET(Table, table)
 }
 
 const void*
 nsRuleNode::ComputeTableBorderData(void* aStartStruct,
                                    const nsRuleData* aRuleData,
-                                   nsStyleContext* aContext,
+                                   GeckoStyleContext* aContext,
                                    nsRuleNode* aHighestNode,
                                    const RuleDetail aRuleDetail,
                                    const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_INHERITED(TableBorder, table, parentTable)
 
   // border-collapse: enum, inherit, initial
   SetValue(*aRuleData->ValueForBorderCollapse(), table->mBorderCollapse,
@@ -8834,17 +8834,17 @@ nsRuleNode::ComputeTableBorderData(void*
            NS_STYLE_TABLE_EMPTY_CELLS_SHOW);
 
   COMPUTE_END_INHERITED(TableBorder, table)
 }
 
 const void*
 nsRuleNode::ComputeContentData(void* aStartStruct,
                                const nsRuleData* aRuleData,
-                               nsStyleContext* aContext,
+                               GeckoStyleContext* aContext,
                                nsRuleNode* aHighestNode,
                                const RuleDetail aRuleDetail,
                                const RuleNodeCacheConditions aConditions)
 {
   uint32_t count;
   nsAutoString buffer;
 
   COMPUTE_START_RESET(Content, content, parentContent)
@@ -9057,17 +9057,17 @@ nsRuleNode::ComputeContentData(void* aSt
   }
 
   COMPUTE_END_RESET(Content, content)
 }
 
 const void*
 nsRuleNode::ComputeXULData(void* aStartStruct,
                            const nsRuleData* aRuleData,
-                           nsStyleContext* aContext,
+                           GeckoStyleContext* aContext,
                            nsRuleNode* aHighestNode,
                            const RuleDetail aRuleDetail,
                            const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_RESET(XUL, xul, parentXUL)
 
   // box-align: enum, inherit, initial
   SetValue(*aRuleData->ValueForBoxAlign(),
@@ -9116,17 +9116,17 @@ nsRuleNode::ComputeXULData(void* aStartS
            StyleStackSizing::StretchToFit);
 
   COMPUTE_END_RESET(XUL, xul)
 }
 
 const void*
 nsRuleNode::ComputeColumnData(void* aStartStruct,
                               const nsRuleData* aRuleData,
-                              nsStyleContext* aContext,
+                              GeckoStyleContext* aContext,
                               nsRuleNode* aHighestNode,
                               const RuleDetail aRuleDetail,
                               const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_RESET(Column, column, parent)
 
   // column-width: length, auto, inherit
   SetCoord(*aRuleData->ValueForColumnWidth(),
@@ -9212,17 +9212,17 @@ nsRuleNode::ComputeColumnData(void* aSta
            parent->mColumnSpan,
            NS_STYLE_COLUMN_SPAN_NONE);
 
   COMPUTE_END_RESET(Column, column)
 }
 
 static void
 SetSVGPaint(const nsCSSValue& aValue, const nsStyleSVGPaint& parentPaint,
-            nsPresContext* aPresContext, nsStyleContext *aContext,
+            nsPresContext* aPresContext, GeckoStyleContext *aContext,
             nsStyleSVGPaint& aResult, nsStyleSVGPaintType aInitialPaintType,
             RuleNodeCacheConditions& aConditions)
 {
   MOZ_ASSERT(aInitialPaintType == eStyleSVGPaintType_None ||
              aInitialPaintType == eStyleSVGPaintType_Color,
              "SetSVGPaint only supports initial values being either 'black' "
              "(represented by eStyleSVGPaintType_Color) or none (by "
              "eStyleSVGPaintType_None)");
@@ -9371,17 +9371,17 @@ nsRuleNode::FillAllMaskLists(nsStyleImag
   FillImageLayerList(aMask.mLayers,
                      &nsStyleImageLayers::Layer::mComposite,
                      aMask.mCompositeCount, fillCount);
 }
 
 const void*
 nsRuleNode::ComputeSVGData(void* aStartStruct,
                            const nsRuleData* aRuleData,
-                           nsStyleContext* aContext,
+                           GeckoStyleContext* aContext,
                            nsRuleNode* aHighestNode,
                            const RuleDetail aRuleDetail,
                            const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_INHERITED(SVG, svg, parentSVG)
 
   // clip-rule: enum, inherit, initial
   SetValue(*aRuleData->ValueForClipRule(),
@@ -9677,17 +9677,17 @@ nsRuleNode::ComputeSVGData(void* aStartS
     MOZ_ASSERT(false, "unrecognized -moz-context-properties value");
   }
 
   COMPUTE_END_INHERITED(SVG, svg)
 }
 
 static already_AddRefed<StyleBasicShape>
 GetStyleBasicShapeFromCSSValue(const nsCSSValue& aValue,
-                               nsStyleContext* aStyleContext,
+                               GeckoStyleContext* aStyleContext,
                                nsPresContext* aPresContext,
                                RuleNodeCacheConditions& aConditions)
 {
   RefPtr<StyleBasicShape> basicShape;
 
   nsCSSValue::Array* shapeFunction = aValue.GetArrayValue();
   nsCSSKeyword functionName =
     (nsCSSKeyword)shapeFunction->Item(0).GetIntValue();
@@ -9830,17 +9830,17 @@ GetStyleBasicShapeFromCSSValue(const nsC
 
   return basicShape.forget();
 }
 
 static void
 SetStyleShapeSourceToCSSValue(
   StyleShapeSource* aShapeSource,
   const nsCSSValue* aValue,
-  nsStyleContext* aStyleContext,
+  GeckoStyleContext* aStyleContext,
   nsPresContext* aPresContext,
   RuleNodeCacheConditions& aConditions)
 {
   MOZ_ASSERT(aValue->GetUnit() == eCSSUnit_Array,
              "expected a basic shape or reference box");
 
   const nsCSSValue::Array* array = aValue->GetArrayValue();
   MOZ_ASSERT(array->Count() == 1 || array->Count() == 2,
@@ -9868,17 +9868,17 @@ SetStyleShapeSourceToCSSValue(
     aShapeSource->SetReferenceBox(referenceBox);
   }
 }
 
 // Returns true if the nsStyleFilter was successfully set using the nsCSSValue.
 static bool
 SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter,
                          const nsCSSValue& aValue,
-                         nsStyleContext* aStyleContext,
+                         GeckoStyleContext* aStyleContext,
                          nsPresContext* aPresContext,
                          RuleNodeCacheConditions& aConditions)
 {
   nsCSSUnit unit = aValue.GetUnit();
   if (unit == eCSSUnit_URL) {
     return aStyleFilter->SetURL(aValue.GetURLStructValue());
   }
 
@@ -9926,17 +9926,17 @@ SetStyleFilterToCSSValue(nsStyleFilter* 
   aStyleFilter->SetFilterParameter(filterParameter, type);
   MOZ_ASSERT(didSetCoord, "unexpected unit");
   return true;
 }
 
 const void*
 nsRuleNode::ComputeSVGResetData(void* aStartStruct,
                                 const nsRuleData* aRuleData,
-                                nsStyleContext* aContext,
+                                GeckoStyleContext* aContext,
                                 nsRuleNode* aHighestNode,
                                 const RuleDetail aRuleDetail,
                                 const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_RESET(SVGReset, svgReset, parentSVGReset)
 
   // stop-color:
   const nsCSSValue* stopColorValue = aRuleData->ValueForStopColor();
@@ -10151,17 +10151,17 @@ nsRuleNode::ComputeSVGResetData(void* aS
 #endif
 
   COMPUTE_END_RESET(SVGReset, svgReset)
 }
 
 const void*
 nsRuleNode::ComputeVariablesData(void* aStartStruct,
                                  const nsRuleData* aRuleData,
-                                 nsStyleContext* aContext,
+                                 GeckoStyleContext* aContext,
                                  nsRuleNode* aHighestNode,
                                  const RuleDetail aRuleDetail,
                                  const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_INHERITED(Variables, variables, parentVariables)
 
   MOZ_ASSERT(aRuleData->mVariables,
              "shouldn't be in ComputeVariablesData if there were no variable "
@@ -10173,17 +10173,17 @@ nsRuleNode::ComputeVariablesData(void* a
   conditions.SetUncacheable();
 
   COMPUTE_END_INHERITED(Variables, variables)
 }
 
 const void*
 nsRuleNode::ComputeEffectsData(void* aStartStruct,
                                const nsRuleData* aRuleData,
-                               nsStyleContext* aContext,
+                               GeckoStyleContext* aContext,
                                nsRuleNode* aHighestNode,
                                const RuleDetail aRuleDetail,
                                const RuleNodeCacheConditions aConditions)
 {
   COMPUTE_START_RESET(Effects, effects, parentEffects)
 
   // filter: url, none, inherit
   const nsCSSValue* filterValue = aRuleData->ValueForFilter();
@@ -10333,17 +10333,17 @@ nsRuleNode::ComputeEffectsData(void* aSt
            SETVAL_ENUMERATED | SETVAL_UNSET_INITIAL,
            parentEffects->mMixBlendMode, NS_STYLE_BLEND_NORMAL);
 
   COMPUTE_END_RESET(Effects, effects)
 }
 
 const void*
 nsRuleNode::GetStyleData(nsStyleStructID aSID,
-                         nsStyleContext* aContext,
+                         GeckoStyleContext* aContext,
                          bool aComputeData)
 {
   NS_ASSERTION(IsUsedDirectly(),
                "if we ever call this on rule nodes that aren't used "
                "directly, we should adjust handling of mDependentBits "
                "in some way.");
   MOZ_ASSERT(!aContext->GetCachedStyleData(aSID),
              "style context should not have cached data for struct");
@@ -10402,16 +10402,18 @@ nsRuleNode::HasAuthorSpecifiedRules(nsSt
 {
 #ifdef MOZ_STYLO
   if (aStyleContext->StyleSource().IsServoComputedValues()) {
     NS_WARNING("stylo: nsRuleNode::HasAuthorSpecifiedRules not implemented");
     return true;
   }
 #endif
 
+  RefPtr<GeckoStyleContext> styleContext = aStyleContext->AsGecko();
+
   uint32_t inheritBits = 0;
   if (ruleTypeMask & NS_AUTHOR_SPECIFIED_BACKGROUND)
     inheritBits |= NS_STYLE_INHERIT_BIT(Background);
 
   if (ruleTypeMask & NS_AUTHOR_SPECIFIED_BORDER)
     inheritBits |= NS_STYLE_INHERIT_BIT(Border);
 
   if (ruleTypeMask & NS_AUTHOR_SPECIFIED_PADDING)
@@ -10447,19 +10449,19 @@ nsRuleNode::HasAuthorSpecifiedRules(nsSt
   if (ruleTypeMask & NS_AUTHOR_SPECIFIED_TEXT_SHADOW) {
     textShadowOffset = nprops;
     nprops += nsCSSProps::PropertyCountInStruct(eStyleStruct_Text);
   }
 
   void* dataStorage = alloca(nprops * sizeof(nsCSSValue));
   AutoCSSValueArray dataArray(dataStorage, nprops);
 
-  /* We're relying on the use of |aStyleContext| not mutating it! */
+  /* We're relying on the use of |styleContext| not mutating it! */
   nsRuleData ruleData(inheritBits, dataArray.get(),
-                      aStyleContext->PresContext(), aStyleContext);
+                      styleContext->PresContext(), styleContext);
 
   if (ruleTypeMask & NS_AUTHOR_SPECIFIED_BACKGROUND) {
     ruleData.mValueOffsets[eStyleStruct_Background] = backgroundOffset;
   }
 
   if (ruleTypeMask & NS_AUTHOR_SPECIFIED_BORDER) {
     ruleData.mValueOffsets[eStyleStruct_Border] = borderOffset;
   }
@@ -10547,28 +10549,28 @@ nsRuleNode::HasAuthorSpecifiedRules(nsSt
   if (ruleTypeMask & NS_AUTHOR_SPECIFIED_TEXT_SHADOW) {
     for (uint32_t i = 0, i_end = ArrayLength(textShadowValues);
          i < i_end; ++i) {
       properties[nValues] = textShadowValues[i];
       values[nValues++] = ruleData.ValueFor(textShadowValues[i]);
     }
   }
 
-  nsStyleContext* styleContext = aStyleContext;
+  GeckoStyleContext* styleContextRef = styleContext;
 
   // We need to be careful not to count styles covered up by user-important or
   // UA-important declarations.  But we do want to catch explicit inherit
   // styling in those and check our parent style context to see whether we have
   // user styling for those properties.  Note that we don't care here about
   // inheritance due to lack of a specified value, since all the properties we
   // care about are reset properties.
   bool haveExplicitUAInherit;
   do {
     haveExplicitUAInherit = false;
-    for (nsRuleNode* ruleNode = styleContext->RuleNode(); ruleNode;
+    for (nsRuleNode* ruleNode = styleContextRef->RuleNode(); ruleNode;
          ruleNode = ruleNode->GetParent()) {
       nsIStyleRule *rule = ruleNode->GetRule();
       if (rule) {
         ruleData.mLevel = ruleNode->GetLevel();
         ruleData.mIsImportantRule = ruleNode->IsImportantRule();
 
         rule->MapRuleInfoInto(&ruleData);
 
@@ -10625,27 +10627,27 @@ nsRuleNode::HasAuthorSpecifiedRules(nsSt
       // detect them being styled by the author) and move up to our parent
       // style context.
       for (uint32_t i = 0; i < nValues; ++i)
         if (values[i]->GetUnit() == eCSSUnit_Null)
           values[i]->SetDummyValue();
       for (uint32_t i = 0; i < nValues; ++i)
         if (values[i]->GetUnit() == eCSSUnit_DummyInherit)
           values[i]->Reset();
-      styleContext = styleContext->GetParent();
+      styleContextRef = styleContextRef->GetParent();
     }
   } while (haveExplicitUAInherit && styleContext);
 
   return false;
 }
 
 /* static */ void
 nsRuleNode::ComputePropertiesOverridingAnimation(
                               const nsTArray<nsCSSPropertyID>& aProperties,
-                              nsStyleContext* aStyleContext,
+                              GeckoStyleContext* aStyleContext,
                               nsCSSPropertyIDSet& aPropertiesOverridden)
 {
   /*
    * Set up an nsRuleData with all the structs needed for all of the
    * properties in aProperties.
    */
   uint32_t structBits = 0;
   size_t nprops = 0;
@@ -10735,31 +10737,31 @@ nsRuleNode::ComputeColor(const nsCSSValu
   RuleNodeCacheConditions conditions;
   bool ok = SetColor(aValue, NS_RGB(0, 0, 0), aPresContext, aStyleContext,
                      aResult, conditions);
   MOZ_ASSERT(ok || !(aPresContext && aStyleContext));
   return ok;
 }
 
 /* static */ bool
-nsRuleNode::ParentHasPseudoElementData(nsStyleContext* aContext)
-{
-  nsStyleContext* parent = aContext->GetParent();
+nsRuleNode::ParentHasPseudoElementData(GeckoStyleContext* aContext)
+{
+  GeckoStyleContext* parent = aContext->GetParent();
   return parent && parent->HasPseudoElementData();
 }
 
 /* static */ void
-nsRuleNode::StoreStyleOnContext(nsStyleContext* aContext,
+nsRuleNode::StoreStyleOnContext(GeckoStyleContext* aContext,
                                 nsStyleStructID aSID,
                                 void* aStruct)
 {
   aContext->AddStyleBit(nsCachedStyleData::GetBitForSID(aSID));
   aContext->SetStyle(aSID, aStruct);
 }
 
 #ifdef DEBUG
 bool
-nsRuleNode::ContextHasCachedData(nsStyleContext* aContext,
+nsRuleNode::ContextHasCachedData(GeckoStyleContext* aContext,
                                  nsStyleStructID aSID)
 {
   return !!aContext->GetCachedStyleData(aSID);
 }
 #endif
--- a/layout/style/nsRuleNode.h
+++ b/layout/style/nsRuleNode.h
@@ -20,23 +20,26 @@
 #include "mozilla/SheetType.h"
 #include "nsPresContext.h"
 #include "nsStyleStruct.h"
 
 class nsCSSPropertyIDSet;
 class nsCSSValue;
 class nsFontMetrics;
 class nsIStyleRule;
-class nsStyleContext;
 class nsStyleCoord;
 struct nsCSSRect;
 struct nsCSSValueList;
 struct nsCSSValuePairList;
 struct nsRuleData;
 
+namespace mozilla {
+  class GeckoStyleContext;
+}
+
 struct nsInheritedStyleData
 {
   mozilla::RangedArray<void*,
                        nsStyleStructID_Inherited_Start,
                        nsStyleStructID_Inherited_Count> mStyleStructs;
 
   void* operator new(size_t sz, nsPresContext* aContext) {
     return aContext->PresShell()->
@@ -158,17 +161,17 @@ struct nsConditionalResetStyleData
   void* GetStyleData(nsStyleStructID aSID) const {
     if (mConditionalBits & GetBitForSID(aSID)) {
       return nullptr;
     }
     return mEntries[aSID];
   }
 
   void* GetStyleData(nsStyleStructID aSID,
-                     nsStyleContext* aStyleContext,
+                     mozilla::GeckoStyleContext* aStyleContext,
                      bool aCanComputeData) const {
     if (!(mConditionalBits & GetBitForSID(aSID))) {
       return mEntries[aSID];
     }
     if (!aCanComputeData) {
       // If aCanComputeData is false, then any previously-computed data
       // would have been cached on the style context.  Therefore it's
       // unnecessary to check the conditional data.  It's also
@@ -178,17 +181,17 @@ struct nsConditionalResetStyleData
       return nullptr;
     }
     return GetConditionalStyleData(aSID, aStyleContext);
   }
 
 private:
   // non-inline helper for GetStyleData
   void* GetConditionalStyleData(nsStyleStructID aSID,
-                                nsStyleContext* aStyleContext) const;
+                                mozilla::GeckoStyleContext* aStyleContext) const;
 
 public:
   void SetStyleData(nsStyleStructID aSID, void* aStyleStruct) {
     MOZ_ASSERT(!(mConditionalBits & GetBitForSID(aSID)),
                "rule node should not have unconditional and conditional style "
                "data for a given struct");
     mEntries[aSID] = aStyleStruct;
   }
@@ -279,17 +282,17 @@ struct nsCachedStyleData
       if (mInheritedData) {
         return mInheritedData->mStyleStructs[aSID];
       }
     }
     return nullptr;
   }
 
   void* NS_FASTCALL GetStyleData(const nsStyleStructID aSID,
-                                 nsStyleContext* aStyleContext,
+                                 mozilla::GeckoStyleContext* aStyleContext,
                                  bool aCanComputeData) {
     if (IsReset(aSID)) {
       if (mResetData) {
         return mResetData->GetStyleData(aSID, aStyleContext, aCanComputeData);
       }
     } else {
       if (mInheritedData) {
         return mInheritedData->mStyleStructs[aSID];
@@ -315,17 +318,17 @@ struct nsCachedStyleData
 
   // Typesafe and faster versions of the above
   #define STYLE_STRUCT_INHERITED(name_, checkdata_cb_)                         \
     nsStyle##name_ * NS_FASTCALL GetStyle##name_ () {                          \
       return mInheritedData ? static_cast<nsStyle##name_*>(                    \
         mInheritedData->mStyleStructs[eStyleStruct_##name_]) : nullptr;        \
     }
   #define STYLE_STRUCT_RESET(name_, checkdata_cb_)                             \
-    nsStyle##name_ * NS_FASTCALL GetStyle##name_ (nsStyleContext* aContext,    \
+    nsStyle##name_ * NS_FASTCALL GetStyle##name_ (mozilla::GeckoStyleContext* aContext,    \
                                                   bool aCanComputeData) {      \
       return mResetData ? static_cast<nsStyle##name_*>(                        \
         mResetData->GetStyleData(eStyleStruct_##name_, aContext,               \
                                  aCanComputeData))                             \
                         : nullptr;                                             \
     }
   #include "nsStyleStructList.h"
   #undef STYLE_STRUCT_RESET
@@ -350,43 +353,43 @@ struct nsCachedStyleData
  *
  * The rule tree is owned by the nsStyleSet and is destroyed when the
  * presentation of the document goes away. Its entries are reference-
  * counted, with strong references held by child nodes, style structs
  * and (for the root), the style set. Rule nodes are not immediately
  * destroyed when their reference-count drops to zero, but are instead
  * destroyed during a GC sweep.
  *
- * An nsStyleContext, which represents the computed style data for an
+ * An mozilla::GeckoStyleContext, which represents the computed style data for an
  * element, points to an nsRuleNode.  The path from the root of the rule
- * tree to the nsStyleContext's mRuleNode gives the list of the rules
+ * tree to the mozilla::GeckoStyleContext's mRuleNode gives the list of the rules
  * matched, from least important in the cascading order to most
  * important in the cascading order.
  *
  * The reason for using a lexicographic tree is that it allows for
  * sharing of style data, which saves both memory (for storing the
  * computed style data) and time (for computing them).  This sharing
  * depends on the computed style data being stored in structs (nsStyle*)
  * that contain only properties that are inherited by default
  * ("inherited structs") or structs that contain only properties that
  * are not inherited by default ("reset structs").  The optimization
  * depends on the normal case being that style rules specify relatively
  * few properties and even that elements generally have relatively few
  * properties specified.  This allows sharing in the following ways:
  *   1. [mainly reset structs] When a style data struct will contain the
  *      same computed value for any elements that match the same set of
  *      rules (common for reset structs), it can be stored on the
- *      nsRuleNode instead of on the nsStyleContext.
+ *      nsRuleNode instead of on the mozilla::GeckoStyleContext.
  *   2. [only? reset structs] When (1) occurs, and an nsRuleNode doesn't
  *      have any rules that change the values in the struct, the
  *      nsRuleNode can share that struct with its parent nsRuleNode.
  *   3. [mainly inherited structs] When an element doesn't match any
  *      rules that change the value of a property (or, in the edge case,
- *      when all the values specified are 'inherit'), the nsStyleContext
- *      can use the same nsStyle* struct as its parent nsStyleContext.
+ *      when all the values specified are 'inherit'), the mozilla::GeckoStyleContext
+ *      can use the same nsStyle* struct as its parent mozilla::GeckoStyleContext.
  *
  * Since the data represented by an nsIStyleRule are immutable, the data
  * represented by an nsRuleNode are also immutable.
  */
 
 enum nsFontSizeType {
   eFontSize_HTML = 1,
   eFontSize_CSS = 2
@@ -560,231 +563,231 @@ public:
 
   // Implemented in nsStyleSet.h, since it needs to know about nsStyleSet.
   inline void Release();
 
 protected:
   void PropagateDependentBit(nsStyleStructID aSID, nsRuleNode* aHighestNode,
                              void* aStruct);
   void PropagateNoneBit(uint32_t aBit, nsRuleNode* aHighestNode);
-  static void PropagateGrandancestorBit(nsStyleContext* aContext,
-                                        nsStyleContext* aContextInheritedFrom);
+  static void PropagateGrandancestorBit(mozilla::GeckoStyleContext* aContext,
+                                        mozilla::GeckoStyleContext* aContextInheritedFrom);
 
   const void* SetDefaultOnRoot(const nsStyleStructID aSID,
-                               nsStyleContext* aContext);
+                               mozilla::GeckoStyleContext* aContext);
 
   /**
    * Resolves any property values in aRuleData for a given style struct that
    * have eCSSUnit_TokenStream values, by resolving them against the computed
    * variable values on the style context and re-parsing the property.
    *
    * @return Whether any properties with eCSSUnit_TokenStream values were
    *   encountered.
    */
   static bool ResolveVariableReferences(const nsStyleStructID aSID,
                                         nsRuleData* aRuleData,
-                                        nsStyleContext* aContext);
+                                        mozilla::GeckoStyleContext* aContext);
 
   const void*
-    WalkRuleTree(const nsStyleStructID aSID, nsStyleContext* aContext);
+    WalkRuleTree(const nsStyleStructID aSID, mozilla::GeckoStyleContext* aContext);
 
   const void*
     ComputeDisplayData(void* aStartStruct,
                        const nsRuleData* aRuleData,
-                       nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                       mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                        RuleDetail aRuleDetail,
                        const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeVisibilityData(void* aStartStruct,
                           const nsRuleData* aRuleData,
-                          nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                          mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                           RuleDetail aRuleDetail,
                           const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeFontData(void* aStartStruct,
                     const nsRuleData* aRuleData,
-                    nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                    mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                     RuleDetail aRuleDetail,
                     const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeColorData(void* aStartStruct,
                      const nsRuleData* aRuleData,
-                     nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                     mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                      RuleDetail aRuleDetail,
                      const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeBackgroundData(void* aStartStruct,
                           const nsRuleData* aRuleData,
-                          nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                          mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                           RuleDetail aRuleDetail,
                           const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeMarginData(void* aStartStruct,
                       const nsRuleData* aRuleData,
-                      nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                      mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                       RuleDetail aRuleDetail,
                       const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeBorderData(void* aStartStruct,
                       const nsRuleData* aRuleData,
-                      nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                      mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                       RuleDetail aRuleDetail,
                       const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputePaddingData(void* aStartStruct,
                        const nsRuleData* aRuleData,
-                       nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                       mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                        RuleDetail aRuleDetail,
                        const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeOutlineData(void* aStartStruct,
                        const nsRuleData* aRuleData,
-                       nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                       mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                        RuleDetail aRuleDetail,
                        const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeListData(void* aStartStruct,
                     const nsRuleData* aRuleData,
-                    nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                    mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                     RuleDetail aRuleDetail,
                     const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputePositionData(void* aStartStruct,
                         const nsRuleData* aRuleData,
-                        nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                        mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                         RuleDetail aRuleDetail,
                         const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeTableData(void* aStartStruct,
                      const nsRuleData* aRuleData,
-                     nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                     mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                      RuleDetail aRuleDetail,
                      const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeTableBorderData(void* aStartStruct,
                            const nsRuleData* aRuleData,
-                           nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                           mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                            RuleDetail aRuleDetail,
                            const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeContentData(void* aStartStruct,
                        const nsRuleData* aRuleData,
-                       nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                       mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                        RuleDetail aRuleDetail,
                        const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeTextData(void* aStartStruct,
                     const nsRuleData* aRuleData,
-                    nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                    mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                     RuleDetail aRuleDetail,
                     const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeTextResetData(void* aStartStruct,
                          const nsRuleData* aRuleData,
-                         nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                         mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                          RuleDetail aRuleDetail,
                          const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeUserInterfaceData(void* aStartStruct,
                              const nsRuleData* aRuleData,
-                             nsStyleContext* aContext,
+                             mozilla::GeckoStyleContext* aContext,
                              nsRuleNode* aHighestNode,
                              RuleDetail aRuleDetail,
                              const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeUIResetData(void* aStartStruct,
                        const nsRuleData* aRuleData,
-                       nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                       mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                        RuleDetail aRuleDetail,
                        const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeXULData(void* aStartStruct,
                    const nsRuleData* aRuleData,
-                   nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                   mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                    RuleDetail aRuleDetail,
                    const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeColumnData(void* aStartStruct,
                       const nsRuleData* aRuleData,
-                      nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                      mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                       RuleDetail aRuleDetail,
                       const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeSVGData(void* aStartStruct,
                    const nsRuleData* aRuleData,
-                   nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                   mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                    RuleDetail aRuleDetail,
                    const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeSVGResetData(void* aStartStruct,
                         const nsRuleData* aRuleData,
-                        nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                        mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                         RuleDetail aRuleDetail,
                         const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeVariablesData(void* aStartStruct,
                          const nsRuleData* aRuleData,
-                         nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                         mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                          RuleDetail aRuleDetail,
                          const mozilla::RuleNodeCacheConditions aConditions);
 
   const void*
     ComputeEffectsData(void* aStartStruct,
                        const nsRuleData* aRuleData,
-                       nsStyleContext* aContext, nsRuleNode* aHighestNode,
+                       mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
                        RuleDetail aRuleDetail,
                        const mozilla::RuleNodeCacheConditions aConditions);
 
   // helpers for |ComputeFontData| that need access to |mNoneBits|:
   static void SetFontSize(nsPresContext* aPresContext,
-                          nsStyleContext* aContext,
+                          mozilla::GeckoStyleContext* aContext,
                           const nsRuleData* aRuleData,
                           const nsStyleFont* aFont,
                           const nsStyleFont* aParentFont,
                           nscoord* aSize,
                           const nsFont& aSystemFont,
                           nscoord aParentSize,
                           nscoord aScriptLevelAdjustedParentSize,
                           bool aUsedStartStruct,
                           bool aAtRoot,
                           mozilla::RuleNodeCacheConditions& aConditions);
 
   static void SetFont(nsPresContext* aPresContext,
-                      nsStyleContext* aContext,
+                      mozilla::GeckoStyleContext* aContext,
                       uint8_t aGenericFontID,
                       const nsRuleData* aRuleData,
                       const nsStyleFont* aParentFont,
                       nsStyleFont* aFont,
                       bool aStartStruct,
                       mozilla::RuleNodeCacheConditions& aConditions);
 
   static void SetGenericFont(nsPresContext* aPresContext,
-                             nsStyleContext* aContext,
+                             mozilla::GeckoStyleContext* aContext,
                              uint8_t aGenericFontID,
                              nsStyleFont* aFont);
 
   inline RuleDetail CheckSpecifiedProperties(const nsStyleStructID aSID,
                                              const nsRuleData* aRuleData);
 
 private:
   nsRuleNode(nsPresContext* aPresContext, nsRuleNode* aParent,
@@ -885,28 +888,28 @@ public:
   }
 
   // NOTE:  Does not |AddRef|.  Null only for the root.
   nsIStyleRule* GetRule() const { return mRule; }
   // NOTE: Does not |AddRef|.  Never null.
   nsPresContext* PresContext() const { return mPresContext; }
 
   const void* GetStyleData(nsStyleStructID aSID,
-                           nsStyleContext* aContext,
+                           mozilla::GeckoStyleContext* aContext,
                            bool aComputeData);
 
   void GetDiscretelyAnimatedCSSValue(nsCSSPropertyID aProperty,
                                      nsCSSValue* aValue);
 
   // See comments in GetStyleData for an explanation of what the
   // code below does.
   #define STYLE_STRUCT_INHERITED(name_, checkdata_cb_)                        \
   template<bool aComputeData>                                                 \
   const nsStyle##name_*                                                       \
-  GetStyle##name_(nsStyleContext* aContext, uint64_t& aContextStyleBits)      \
+  GetStyle##name_(mozilla::GeckoStyleContext* aContext, uint64_t& aContextStyleBits)      \
   {                                                                           \
     NS_ASSERTION(IsUsedDirectly(),                                            \
                  "if we ever call this on rule nodes that aren't used "       \
                  "directly, we should adjust handling of mDependentBits "     \
                  "in some way.");                                             \
     MOZ_ASSERT(!ContextHasCachedData(aContext, eStyleStruct_##name_),         \
                "style context should not have cached data for struct");       \
                                                                               \
@@ -935,17 +938,17 @@ public:
                                                                               \
     MOZ_ASSERT(data, "should have aborted on out-of-memory");                 \
     return data;                                                              \
   }
 
   #define STYLE_STRUCT_RESET(name_, checkdata_cb_)                            \
   template<bool aComputeData>                                                 \
   const nsStyle##name_*                                                       \
-  GetStyle##name_(nsStyleContext* aContext)                                   \
+  GetStyle##name_(mozilla::GeckoStyleContext* aContext)                                   \
   {                                                                           \
     NS_ASSERTION(IsUsedDirectly(),                                            \
                  "if we ever call this on rule nodes that aren't used "       \
                  "directly, we should adjust handling of mDependentBits "     \
                  "in some way.");                                             \
     MOZ_ASSERT(!ContextHasCachedData(aContext, eStyleStruct_##name_),         \
                "style context should not have cached data for struct");       \
                                                                               \
@@ -991,17 +994,17 @@ public:
   /**
    * Fill in to aPropertiesOverridden all of the properties in aProperties
    * that, for this rule node, have a declaration that is higher than the
    * animation level in the CSS Cascade.
    */
   static void
   ComputePropertiesOverridingAnimation(
                               const nsTArray<nsCSSPropertyID>& aProperties,
-                              nsStyleContext* aStyleContext,
+                              mozilla::GeckoStyleContext* aStyleContext,
                               nsCSSPropertyIDSet& aPropertiesOverridden);
 
   // Expose this so media queries can use it
   static nscoord CalcLengthWithInitialFont(nsPresContext* aPresContext,
                                            const nsCSSValue& aValue);
   // Expose this so nsTransformFunctions can use it.
   static nscoord CalcLength(const nsCSSValue& aValue,
                             nsStyleContext* aStyleContext,
@@ -1086,17 +1089,17 @@ public:
    * @return false if we fail to extract a color; this will not happen if both
    *         aPresContext and aStyleContext are non-null
    */
   static bool ComputeColor(const nsCSSValue& aValue,
                            nsPresContext* aPresContext,
                            nsStyleContext* aStyleContext,
                            nscolor& aResult);
 
-  static bool ParentHasPseudoElementData(nsStyleContext* aContext);
+  static bool ParentHasPseudoElementData(mozilla::GeckoStyleContext* aContext);
 
   static void ComputeTimingFunction(const nsCSSValue& aValue,
                                     nsTimingFunction& aResult);
 
   // Fill unspecified layers by cycling through their values
   // till they all are of length aMaxItemCount
   static void FillAllBackgroundLists(nsStyleImageLayers& aLayers,
                                      uint32_t aMaxItemCount);
@@ -1108,22 +1111,22 @@ public:
                                 mozilla::LookAndFeel::FontID aFontID,
                                 const nsPresContext* aPresContext,
                                 const nsFont* aDefaultVariableFont);
 
 private:
 #ifdef DEBUG
   // non-inline helper function to allow assertions without incomplete
   // type errors
-  bool ContextHasCachedData(nsStyleContext* aContext, nsStyleStructID aSID);
+  bool ContextHasCachedData(mozilla::GeckoStyleContext* aContext, nsStyleStructID aSID);
 #endif
 
   // Store style struct on the style context and tell the style context
   // that it doesn't own the data
-  static void StoreStyleOnContext(nsStyleContext* aContext,
+  static void StoreStyleOnContext(mozilla::GeckoStyleContext* aContext,
                                   nsStyleStructID aSID,
                                   void* aStruct);
 };
 
 /**
  * We allocate arrays of CSS values with alloca.  (These arrays are a
  * fixed size per style struct, but we don't want to waste the
  * allocation and construction/destruction costs of the big structs when
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -313,92 +313,16 @@ nsStyleContext::MoveTo(nsStyleContext* a
 
   if (mStyleIfVisited) {
     mStyleIfVisited->mParent->RemoveChild(mStyleIfVisited);
     mStyleIfVisited->mParent = aNewParent;
     mStyleIfVisited->mParent->AddChild(mStyleIfVisited);
   }
 }
 
-const void* nsStyleContext::StyleData(nsStyleStructID aSID)
-{
-  const void* cachedData = GetCachedStyleData(aSID);
-  if (cachedData)
-    return cachedData; // We have computed data stored on this node in the context tree.
-  // Our style source will take care of it for us.
-  const void* newData;
-  if (IsGecko()) {
-    newData = AsGecko()->RuleNode()->GetStyleData(aSID, this, true);
-    if (!nsCachedStyleData::IsReset(aSID)) {
-      // always cache inherited data on the style context; the rule
-      // node set the bit in mBits for us if needed.
-      mCachedInheritedData.mStyleStructs[aSID] = const_cast<void*>(newData);
-    }
-  } else {
-    newData = StyleStructFromServoComputedValues(aSID);
-
-    // perform any remaining main thread work on the struct
-    switch (aSID) {
-#define STYLE_STRUCT(name_, checkdata_cb_)                                    \
-      case eStyleStruct_##name_: {                                            \
-        auto data = static_cast<const nsStyle##name_*>(newData);              \
-        const_cast<nsStyle##name_*>(data)->FinishStyle(PresContext());        \
-        break;                                                                \
-      }
-#include "nsStyleStructList.h"
-#undef STYLE_STRUCT
-      default:
-        MOZ_ASSERT_UNREACHABLE("unexpected nsStyleStructID value");
-        break;
-    }
-
-    // The Servo-backed StyleContextSource owns the struct.
-    AddStyleBit(nsCachedStyleData::GetBitForSID(aSID));
-
-    // XXXbholley: Unconditionally caching reset structs here defeats the memory
-    // optimization where we lazily allocate mCachedResetData, so that we can avoid
-    // performing an FFI call each time we want to get the style structs. We should
-    // measure the tradeoffs at some point. If the FFI overhead is low and the memory
-    // win significant, we should consider _always_ grabbing the struct over FFI, and
-    // potentially giving mCachedInheritedData the same treatment.
-    //
-    // Note that there is a similar comment in the struct getters in nsStyleContext.h.
-    SetStyle(aSID, const_cast<void*>(newData));
-  }
-  return newData;
-}
-
-void
-nsStyleContext::SetStyle(nsStyleStructID aSID, void* aStruct)
-{
-  MOZ_ASSERT(!IsServo(),
-             "Servo shouldn't cache style structs in the style context!");
-  // This method should only be called from nsRuleNode!  It is not a public
-  // method!
-
-  NS_ASSERTION(aSID >= 0 && aSID < nsStyleStructID_Length, "out of bounds");
-
-  // NOTE:  nsCachedStyleData::GetStyleData works roughly the same way.
-  // See the comments there (in nsRuleNode.h) for more details about
-  // what this is doing and why.
-
-  void** dataSlot;
-  if (nsCachedStyleData::IsReset(aSID)) {
-    if (!mCachedResetData) {
-      mCachedResetData = new (PresContext()) nsResetStyleData;
-    }
-    dataSlot = &mCachedResetData->mStyleStructs[aSID];
-  } else {
-    dataSlot = &mCachedInheritedData.mStyleStructs[aSID];
-  }
-  NS_ASSERTION(!*dataSlot || (mBits & nsCachedStyleData::GetBitForSID(aSID)),
-               "Going to leak style data");
-  *dataSlot = aStruct;
-}
-
 template<class StyleContextLike>
 nsChangeHint
 nsStyleContext::CalcStyleDifferenceInternal(StyleContextLike* aNewContext,
                                             uint32_t* aEqualStructs,
                                             uint32_t* aSamePointerStructs)
 {
   PROFILER_LABEL("nsStyleContext", "CalcStyleDifference",
     js::ProfileEntry::Category::CSS);
@@ -1093,8 +1017,19 @@ nsStyleContext::Initialize()
 #endif
 
 nsPresContext*
 nsStyleContext::PresContext() const
 {
     MOZ_STYLO_FORWARD(PresContext, ())
 }
 
+GeckoStyleContext*
+nsStyleContext::GetParent() const
+{
+  MOZ_ASSERT(IsGecko(),
+             "This should be used only in Gecko-backed style system!");
+  if (mParent) {
+    return mParent->AsGecko();
+  } else {
+    return nullptr;
+  }
+}
--- a/layout/style/nsStyleContext.h
+++ b/layout/style/nsStyleContext.h
@@ -125,21 +125,17 @@ public:
     NS_ASSERTION(mRefCnt != 0,
                  "do not call HasSingleReference on a newly created "
                  "nsStyleContext with no references yet");
     return mRefCnt == 1;
   }
 
   nsPresContext* PresContext() const;
 
-  nsStyleContext* GetParent() const {
-    MOZ_ASSERT(IsGecko(),
-               "This should be used only in Gecko-backed style system!");
-    return mParent;
-  }
+  mozilla::GeckoStyleContext* GetParent() const;
 
   nsStyleContext* GetParentAllowServo() const {
     return mParent;
   }
 
   nsIAtom* GetPseudo() const { return mPseudoTag; }
   mozilla::CSSPseudoElementType GetPseudoType() const {
     return static_cast<mozilla::CSSPseudoElementType>(
@@ -261,51 +257,30 @@ public:
   bool HasChildThatUsesGrandancestorStyle() const
     { return !!(mBits & NS_STYLE_CHILD_USES_GRANDANCESTOR_STYLE); }
 
   // Is this style context shared with a sibling or cousin?
   // (See nsStyleSet::GetContext.)
   bool IsShared() const
     { return !!(mBits & NS_STYLE_IS_SHARED); }
 
-  // Tell this style context to cache aStruct as the struct for aSID
-  void SetStyle(nsStyleStructID aSID, void* aStruct);
-
   /**
    * Returns whether this style context has cached style data for a
    * given style struct and it does NOT own that struct.  This can
    * happen because it was inherited from the parent style context, or
    * because it was stored conditionally on the rule node.
    */
   bool HasCachedDependentStyleData(nsStyleStructID aSID) {
     return mBits & nsCachedStyleData::GetBitForSID(aSID);
   }
 
   inline nsRuleNode* RuleNode();
 
   void AddStyleBit(const uint64_t& aBit) { mBits |= aBit; }
 
-  /*
-   * Get the style data for a style struct.  This is the most important
-   * member function of nsStyleContext.  It fills in a const pointer
-   * to a style data struct that is appropriate for the style context's
-   * frame.  This struct may be shared with other contexts (either in
-   * the rule tree or the style context tree), so it should not be
-   * modified.
-   *
-   * This function will NOT return null (even when out of memory) when
-   * given a valid style struct ID, so the result does not need to be
-   * null-checked.
-   *
-   * The typesafe functions below are preferred to the use of this
-   * function, both because they're easier to read and because they're
-   * faster.
-   */
-  const void* NS_FASTCALL StyleData(nsStyleStructID aSID) MOZ_NONNULL_RETURN;
-
   /**
    * Define typesafe getter functions for each style struct by
    * preprocessing the list of style structs.  These functions are the
    * preferred way to get style data.  The macro creates functions like:
    *   const nsStyleBorder* StyleBorder();
    *   const nsStyleColor* StyleColor();
    */
   #define STYLE_STRUCT(name_, checkdata_cb_) \
@@ -549,17 +524,17 @@ protected:
           /* We always cache inherited structs on the context when we */\
           /* compute them. */                                           \
           return nullptr;                                               \
         }                                                               \
         /* Have the rulenode deal */                                    \
         AUTO_CHECK_DEPENDENCY(eStyleStruct_##name_);                    \
         const nsStyle##name_ * newData =                                \
           StyleSource().AsGeckoRuleNode()->                             \
-            GetStyle##name_<aComputeData>(this, mBits);                 \
+            GetStyle##name_<aComputeData>(this->AsGecko(), mBits);      \
         /* always cache inherited data on the style context; the rule */\
         /* node set the bit in mBits for us if needed. */               \
         mCachedInheritedData.mStyleStructs[eStyleStruct_##name_] =      \
           const_cast<nsStyle##name_ *>(newData);                        \
         return newData;                                                 \
       }                                                                 \
       /**                                                               \
        * Also (conservatively) set the owning bit in the parent style   \
@@ -616,17 +591,17 @@ protected:
             static_cast<nsStyle##name_*>(                               \
               mCachedResetData->mStyleStructs[eStyleStruct_##name_]);   \
           if (cachedData) /* Have it cached already, yay */             \
             return cachedData;                                          \
         }                                                               \
         /* Have the rulenode deal */                                    \
         AUTO_CHECK_DEPENDENCY(eStyleStruct_##name_);                    \
         return StyleSource().AsGeckoRuleNode()->                        \
-          GetStyle##name_<aComputeData>(this);                          \
+          GetStyle##name_<aComputeData>(this->AsGecko());               \
       }                                                                 \
       const bool needToCompute = !(mBits & NS_STYLE_INHERIT_BIT(name_));\
       if (!aComputeData && needToCompute) {                             \
         return nullptr;                                                 \
       }                                                                 \
       const nsStyle##name_* data =                                      \
         Servo_GetStyle##name_(StyleSource().AsServoComputedValues());   \
       /* perform any remaining main thread work on the struct */        \
--- a/layout/style/nsStyleContextInlines.h
+++ b/layout/style/nsStyleContextInlines.h
@@ -25,10 +25,9 @@ MOZ_DEFINE_STYLO_METHODS(nsStyleContext,
 
 nsRuleNode*
 nsStyleContext::RuleNode()
 {
     MOZ_RELEASE_ASSERT(IsGecko());
     return AsGecko()->RuleNode();
 }
 
-
 #endif // nsStyleContextInlines_h
--- a/layout/tables/nsTableColGroupFrame.cpp
+++ b/layout/tables/nsTableColGroupFrame.cpp
@@ -8,16 +8,17 @@
 #include "nsStyleContext.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
 #include "nsHTMLParts.h"
 #include "nsGkAtoms.h"
 #include "nsCOMPtr.h"
 #include "nsCSSRendering.h"
 #include "nsIPresShell.h"
+#include "mozilla/GeckoStyleContext.h"
 
 using namespace mozilla;
 
 #define COL_GROUP_TYPE_BITS          (NS_FRAME_STATE_BIT(30) | \
                                       NS_FRAME_STATE_BIT(31))
 #define COL_GROUP_TYPE_OFFSET        30
 
 nsTableColGroupType 
@@ -293,17 +294,17 @@ nsTableColGroupFrame::RemoveFrame(ChildL
       nsTableColFrame* col = colFrame->GetNextCol();
       nsTableColFrame* nextCol;
       while (col && col->GetColType() == eColAnonymousCol) {
 #ifdef DEBUG
         nsIFrame* providerFrame;
         nsStyleContext* psc = colFrame->GetParentStyleContext(&providerFrame);
         if (psc->StyleSource().IsGeckoRuleNodeOrNull()) {
           // This check code is useful only in Gecko-backed style system.
-          if (colFrame->StyleContext()->GetParent() == psc) {
+          if (static_cast<nsStyleContext*>(colFrame->StyleContext()->GetParent()) == psc) {
             NS_ASSERTION(col->StyleContext() == colFrame->StyleContext() &&
                          col->GetContent() == colFrame->GetContent(),
                          "How did that happen??");
           }
           // else colFrame is being removed because of a frame
           // reconstruct on it, and its style context is still the old
           // one, so we can't assert anything about how it compares to
           // col's style context.
--- a/layout/xul/nsSplitterFrame.cpp
+++ b/layout/xul/nsSplitterFrame.cpp
@@ -24,16 +24,17 @@
 #include "nsIPresShell.h"
 #include "nsFrameList.h"
 #include "nsHTMLParts.h"
 #include "nsStyleContext.h"
 #include "nsBoxLayoutState.h"
 #include "nsIServiceManager.h"
 #include "nsContainerFrame.h"
 #include "nsContentCID.h"
+#include "mozilla/GeckoStyleContext.h"
 #include "mozilla/StyleSetHandle.h"
 #include "mozilla/StyleSetHandleInlines.h"
 #include "nsLayoutUtils.h"
 #include "nsDisplayList.h"
 #include "nsContentUtils.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/MouseEvents.h"
@@ -279,17 +280,17 @@ nsSplitterFrame::Init(nsIContent*       
   // XXXbz this is pretty messed up, since this can change whether we should
   // have a frame at all.  This really needs a better solution.
   if (aParent && aParent->IsXULBoxFrame()) {
     if (!aParent->IsXULHorizontal()) {
       if (!nsContentUtils::HasNonEmptyAttr(aContent, kNameSpaceID_None,
                                            nsGkAtoms::orient)) {
         aContent->SetAttr(kNameSpaceID_None, nsGkAtoms::orient,
                           NS_LITERAL_STRING("vertical"), false);
-        nsStyleContext* parentStyleContext = StyleContext()->GetParent();
+        GeckoStyleContext* parentStyleContext = StyleContext()->GetParent();
         RefPtr<nsStyleContext> newContext = PresContext()->StyleSet()->
           ResolveStyleFor(aContent->AsElement(), parentStyleContext,
                           LazyComputeBehavior::Allow);
         SetStyleContextWithoutNotification(newContext);
       }
     }
   }