Merge mozilla-central to mozilla-inbound
authorDorel Luca <dluca@mozilla.com>
Mon, 15 Oct 2018 12:54:56 +0300
changeset 499728 1f2c8a6231564cbc7db6d7e9e21433007f508804
parent 499727 7f35ad97d197adc2af2ecda9d8749f8df7cb2b1f (current diff)
parent 499664 4a230b07f0cbf48e87dcb4265ea2d00893bb1b62 (diff)
child 499729 c4a64c83582060ffc3c30501a47cfa59ecc8fab3
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone64.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
Merge mozilla-central to mozilla-inbound
dom/base/OrderedTimeoutIterator.h
layout/style/ServoBindingList.h
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
toolkit/components/url-classifier/tests/mochitest/tracker.js
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -11,17 +11,17 @@
  */
 
 #ifndef mozilla_dom_Element_h__
 #define mozilla_dom_Element_h__
 
 #include "mozilla/dom/FragmentOrElement.h" // for base class
 #include "nsChangeHint.h"                  // for enum
 #include "mozilla/EventStates.h"           // for member
-#include "mozilla/ServoTypes.h"
+#include "mozilla/RustCell.h"
 #include "mozilla/dom/DirectionalityUtils.h"
 #include "nsILinkHandler.h"
 #include "nsINodeList.h"
 #include "nsNodeUtils.h"
 #include "AttrArray.h"
 #include "mozilla/FlushType.h"
 #include "nsDOMAttributeMap.h"
 #include "nsPresContext.h"
@@ -55,16 +55,17 @@ class nsDOMTokenList;
 struct nsRect;
 class nsFocusManager;
 class nsGlobalWindowInner;
 class nsGlobalWindowOuter;
 class nsDOMCSSAttributeDeclaration;
 class nsISMILAttr;
 class nsDocument;
 class nsDOMStringMap;
+struct ServoNodeData;
 
 namespace mozilla {
 class DeclarationBlock;
 struct MutationClosureData;
 class TextEditor;
 namespace css {
   struct URLValue;
 } // namespace css
@@ -1979,17 +1980,17 @@ private:
   void AsElement() = delete;
 
   // Data members
   EventStates mState;
   // Per-node data managed by Servo.
   //
   // There should not be data on nodes that are in the flattened tree, or
   // descendants of display: none elements.
-  mozilla::ServoCell<ServoNodeData*> mServoData;
+  mozilla::RustCell<ServoNodeData*> mServoData;
 };
 
 class RemoveFromBindingManagerRunnable : public mozilla::Runnable
 {
 public:
   RemoveFromBindingManagerRunnable(nsBindingManager* aManager,
                                    nsIContent* aContent,
                                    nsIDocument* aDoc);
deleted file mode 100644
--- a/dom/base/OrderedTimeoutIterator.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_OrderedTimeoutIterator_h__
-#define mozilla_dom_OrderedTimeoutIterator_h__
-
-#include "mozilla/RefPtr.h"
-#include "mozilla/dom/Timeout.h"
-#include "mozilla/dom/TimeoutManager.h"
-
-namespace mozilla {
-namespace dom {
-
-// This class implements and iterator which iterates the normal and tracking
-// timeouts lists simultaneously in the mWhen order.
-class MOZ_STACK_CLASS OrderedTimeoutIterator final {
-public:
-  typedef TimeoutManager::Timeouts Timeouts;
-  typedef Timeouts::TimeoutList    TimeoutList;
-
-  OrderedTimeoutIterator(Timeouts& aNormalTimeouts,
-                         Timeouts& aTrackingTimeouts)
-    : mNormalTimeouts(aNormalTimeouts.mTimeoutList),
-      mTrackingTimeouts(aTrackingTimeouts.mTimeoutList),
-      mNormalIter(mNormalTimeouts.getFirst()),
-      mTrackingIter(mTrackingTimeouts.getFirst()),
-      mKind(Kind::None),
-      mUpdateIteratorCalled(true)
-  {
-  }
-
-  // Return the current timeout and move to the next one.
-  // Unless this is the first time calling Next(), you must call
-  // UpdateIterator() before calling this method.
-  Timeout* Next()
-  {
-    MOZ_ASSERT(mUpdateIteratorCalled);
-    MOZ_ASSERT_IF(mNormalIter, mNormalIter->isInList());
-    MOZ_ASSERT_IF(mTrackingIter, mTrackingIter->isInList());
-
-    mUpdateIteratorCalled = false;
-    mKind = Kind::None;
-    Timeout* timeout = nullptr;
-    if (!mNormalIter) {
-      if (!mTrackingIter) {
-        // We have reached the end of both lists.  Bail out!
-        return nullptr;
-      } else {
-        // We have reached the end of the normal timeout list, select the next
-        // tracking timeout.
-        timeout = mTrackingIter;
-        mKind = Kind::Tracking;
-      }
-    } else if (!mTrackingIter) {
-      // We have reached the end of the tracking timeout list, select the next
-      // normal timeout.
-      timeout = mNormalIter;
-      mKind = Kind::Normal;
-    } else {
-      // If we have a normal and a tracking timer, return the one with the
-      // smaller mWhen (and prefer the timeout with a lower ID in case they are
-      // equal.) Otherwise, return whichever iterator has an item left,
-      // preferring a non-tracking timeout again.  Note that in practice, even
-      // if a web page calls setTimeout() twice in a row, it should get
-      // different mWhen values, so in practice we shouldn't fall back to
-      // comparing timeout IDs.
-      if (mNormalIter && mTrackingIter &&
-          (mTrackingIter->When() < mNormalIter->When() ||
-           (mTrackingIter->When() == mNormalIter->When() &&
-            mTrackingIter->mTimeoutId < mNormalIter->mTimeoutId))) {
-        timeout = mTrackingIter;
-        mKind = Kind::Tracking;
-      } else if (mNormalIter) {
-        timeout = mNormalIter;
-        mKind = Kind::Normal;
-      } else if (mTrackingIter) {
-        timeout = mTrackingIter;
-        mKind = Kind::Tracking;
-      }
-    }
-    if (!timeout) {
-      // We didn't find any suitable iterator.  This can happen for example
-      // when getNext() in UpdateIterator() returns nullptr and then Next()
-      // gets called.  Bail out!
-      return nullptr;
-    }
-
-    MOZ_ASSERT(mKind != Kind::None);
-
-    // Record the current timeout we just found.
-    mCurrent = timeout;
-    MOZ_ASSERT(mCurrent);
-
-    return mCurrent;
-  }
-
-  // Prepare the iterator for the next call to Next().
-  // This method can be called as many times as needed.  Calling this more than
-  // once is helpful in cases where we expect the timeouts list has been
-  // modified before we got a chance to call Next().
-  void UpdateIterator()
-  {
-    MOZ_ASSERT(mKind != Kind::None);
-    // Update the winning iterator to point to the next element.  Also check to
-    // see if the other iterator is still valid, otherwise reset it to the
-    // beginning of the list.  This is needed in case a timeout handler removes
-    // the timeout pointed to from one of our iterators.
-    if (mKind == Kind::Normal) {
-      mNormalIter = mCurrent->getNext();
-      if (mTrackingIter && !mTrackingIter->isInList()) {
-        mTrackingIter = mTrackingTimeouts.getFirst();
-      }
-    } else {
-      mTrackingIter = mCurrent->getNext();
-      if (mNormalIter && !mNormalIter->isInList()) {
-        mNormalIter = mNormalTimeouts.getFirst();
-      }
-    }
-
-    mUpdateIteratorCalled = true;
-  }
-
-  // This function resets the iterator to a defunct state.  It should only be
-  // used when we want to forcefully sever all of the strong references this
-  // class holds.
-  void Clear()
-  {
-    // Release all strong references.
-    mNormalIter = nullptr;
-    mTrackingIter = nullptr;
-    mCurrent = nullptr;
-    mKind = Kind::None;
-    mUpdateIteratorCalled = true;
-  }
-
-  // Returns true if the previous call to Next() picked a normal timeout.
-  // Cannot be called before Next() has been called.  Note that the result of
-  // this method is only affected by Next() and not UpdateIterator(), so calling
-  // UpdateIterator() before calling this is allowed.
-  bool PickedNormalIter() const
-  {
-    MOZ_ASSERT(mKind != Kind::None);
-    return mKind == Kind::Normal;
-  }
-
-  // Returns true if the previous call to Next() picked a tracking timeout.
-  // Cannot be called before Next() has been called.  Note that the result of
-  // this method is only affected by Next() and not UpdateIterator(), so calling
-  // UpdateIterator() before calling this is allowed.
-  bool PickedTrackingIter() const
-  {
-    MOZ_ASSERT(mKind != Kind::None);
-    return mKind == Kind::Tracking;
-  }
-
-private:
-  TimeoutList& mNormalTimeouts;          // The list of normal timeouts.
-  TimeoutList& mTrackingTimeouts;        // The list of tracking timeouts.
-  RefPtr<Timeout> mNormalIter;           // The iterator over the normal timeout list.
-  RefPtr<Timeout> mTrackingIter;         // The iterator over the tracking timeout list.
-  RefPtr<Timeout> mCurrent;              // The current timeout that Next() just found.
-  enum class Kind { Normal, Tracking, None };
-  Kind mKind;                            // The kind of iterator picked the last time.
-  DebugOnly<bool> mUpdateIteratorCalled; // Whether we have called UpdateIterator() before calling Next().
-};
-
-}
-}
-
-#endif
--- a/dom/base/Timeout.cpp
+++ b/dom/base/Timeout.cpp
@@ -14,18 +14,17 @@ namespace dom {
 Timeout::Timeout()
   : mTimeoutId(0),
     mFiringId(TimeoutManager::InvalidFiringId),
     mPopupState(openAllowed),
     mReason(Reason::eTimeoutOrInterval),
     mNestingLevel(0),
     mCleared(false),
     mRunning(false),
-    mIsInterval(false),
-    mIsTracking(false)
+    mIsInterval(false)
 {
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(Timeout)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Timeout)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindow)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mScriptHandler)
--- a/dom/base/Timeout.h
+++ b/dom/base/Timeout.h
@@ -99,17 +99,14 @@ public:
   // True if the timeout was cleared
   bool mCleared;
 
   // True if this is one of the timeouts that are currently running
   bool mRunning;
 
   // True if this is a repeating/interval timer
   bool mIsInterval;
-
-  // True if this is a timeout coming from a tracking script
-  bool mIsTracking;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_timeout_h
--- a/dom/base/TimeoutBudgetManager.cpp
+++ b/dom/base/TimeoutBudgetManager.cpp
@@ -6,19 +6,16 @@
 
 #include "TimeoutBudgetManager.h"
 
 #include "mozilla/dom/Timeout.h"
 
 namespace mozilla {
 namespace dom {
 
-// Time between sampling timeout execution time.
-const uint32_t kTelemetryPeriodMS = 1000;
-
 /* static */ TimeoutBudgetManager&
 TimeoutBudgetManager::Get()
 {
   static TimeoutBudgetManager gTimeoutBudgetManager;
   return gTimeoutBudgetManager;
 }
 
 void
@@ -30,68 +27,21 @@ TimeoutBudgetManager::StartRecording(con
 void
 TimeoutBudgetManager::StopRecording()
 {
   mStart = TimeStamp();
 }
 
 TimeDuration
 TimeoutBudgetManager::RecordExecution(const TimeStamp& aNow,
-                                      const Timeout* aTimeout,
-                                      bool aIsBackground)
+                                      const Timeout* aTimeout)
 {
   if (!mStart) {
     // If we've started a sync operation mStart might be null, in
     // which case we should not record this piece of execution.
     return TimeDuration();
   }
 
-  TimeDuration duration = aNow - mStart;
-
-  if (aIsBackground) {
-    if (aTimeout->mIsTracking) {
-      mTelemetryData.mBackgroundTracking += duration;
-    } else {
-      mTelemetryData.mBackgroundNonTracking += duration;
-    }
-  } else {
-    if (aTimeout->mIsTracking) {
-      mTelemetryData.mForegroundTracking += duration;
-    } else {
-      mTelemetryData.mForegroundNonTracking += duration;
-    }
-  }
-
-  return duration;
-}
-
-void
-TimeoutBudgetManager::Accumulate(Telemetry::HistogramID aId,
-                                 const TimeDuration& aSample)
-{
-  uint32_t sample = std::round(aSample.ToMilliseconds());
-  if (sample) {
-    Telemetry::Accumulate(aId, sample);
-  }
-}
-
-void
-TimeoutBudgetManager::MaybeCollectTelemetry(const TimeStamp& aNow)
-{
-  if ((aNow - mLastCollection).ToMilliseconds() < kTelemetryPeriodMS) {
-    return;
-  }
-
-  Accumulate(Telemetry::TIMEOUT_EXECUTION_FG_TRACKING_MS,
-             mTelemetryData.mForegroundTracking);
-  Accumulate(Telemetry::TIMEOUT_EXECUTION_FG_MS,
-             mTelemetryData.mForegroundNonTracking);
-  Accumulate(Telemetry::TIMEOUT_EXECUTION_BG_TRACKING_MS,
-             mTelemetryData.mBackgroundTracking);
-  Accumulate(Telemetry::TIMEOUT_EXECUTION_BG_MS,
-             mTelemetryData.mBackgroundNonTracking);
-
-  mTelemetryData = TelemetryData();
-  mLastCollection = aNow;
+  return aNow - mStart;
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/base/TimeoutBudgetManager.h
+++ b/dom/base/TimeoutBudgetManager.h
@@ -2,47 +2,33 @@
 /* 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/. */
 
 #ifndef mozilla_dom_timeoutbudgetmanager_h
 #define mozilla_dom_timeoutbudgetmanager_h
 
-#include "mozilla/Telemetry.h"
 #include "mozilla/TimeStamp.h"
 
 namespace mozilla {
 namespace dom {
 
 class Timeout;
 
 class TimeoutBudgetManager
 {
 public:
   static TimeoutBudgetManager& Get();
   void StartRecording(const TimeStamp& aNow);
   void StopRecording();
   TimeDuration RecordExecution(const TimeStamp& aNow,
-                               const Timeout* aTimeout,
-                               bool aIsBackground);
-  void MaybeCollectTelemetry(const TimeStamp& aNow);
+                               const Timeout* aTimeout);
 private:
-  TimeoutBudgetManager() : mLastCollection(TimeStamp::Now()) {}
-  struct TelemetryData
-  {
-    TimeDuration mForegroundTracking;
-    TimeDuration mForegroundNonTracking;
-    TimeDuration mBackgroundTracking;
-    TimeDuration mBackgroundNonTracking;
-  };
+  TimeoutBudgetManager() = default;
 
-  void Accumulate(Telemetry::HistogramID aId, const TimeDuration& aSample);
-
-  TelemetryData mTelemetryData;
   TimeStamp mStart;
-  TimeStamp mLastCollection;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_timeoutbudgetmanager_h
--- a/dom/base/TimeoutManager.cpp
+++ b/dom/base/TimeoutManager.cpp
@@ -13,17 +13,16 @@
 #include "mozilla/Telemetry.h"
 #include "mozilla/ThrottledEventQueue.h"
 #include "mozilla/TimeStamp.h"
 #include "nsIDocShell.h"
 #include "nsINamed.h"
 #include "nsITimeoutHandler.h"
 #include "mozilla/dom/DocGroup.h"
 #include "mozilla/dom/TabGroup.h"
-#include "OrderedTimeoutIterator.h"
 #include "TimeoutExecutor.h"
 #include "TimeoutBudgetManager.h"
 #include "mozilla/net/WebSocketEventService.h"
 #include "mozilla/MediaManager.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
@@ -288,21 +287,16 @@ TimeoutManager::CalculateDelay(Timeout* 
   MOZ_DIAGNOSTIC_ASSERT(aTimeout);
   TimeDuration result = aTimeout->mInterval;
 
   if (aTimeout->mNestingLevel >= DOM_CLAMP_TIMEOUT_NESTING_LEVEL) {
     result = TimeDuration::Max(
       result, TimeDuration::FromMilliseconds(gMinClampTimeoutValue));
   }
 
-  if (aTimeout->mIsTracking && mThrottleTrackingTimeouts) {
-    result = TimeDuration::Max(
-      result, TimeDuration::FromMilliseconds(gMinTrackingTimeoutValue));
-  }
-
   return result;
 }
 
 PerformanceCounter*
 TimeoutManager::GetPerformanceCounter()
 {
   if (!StaticPrefs::dom_performance_enable_scheduler_timing()) {
     return nullptr;
@@ -327,19 +321,17 @@ TimeoutManager::RecordExecution(Timeout*
   }
 
   TimeoutBudgetManager& budgetManager = TimeoutBudgetManager::Get();
   TimeStamp now = TimeStamp::Now();
 
   if (aRunningTimeout) {
     // If we're running a timeout callback, record any execution until
     // now.
-    TimeDuration duration = budgetManager.RecordExecution(
-      now, aRunningTimeout, mWindow.IsBackgroundInternal());
-    budgetManager.MaybeCollectTelemetry(now);
+    TimeDuration duration = budgetManager.RecordExecution(now, aRunningTimeout);
 
     UpdateBudget(now, duration);
 
     // This is an ad-hoc way to use the counters for the timers
     // that should be removed at somepoint. See Bug 1482834
     PerformanceCounter* counter = GetPerformanceCounter();
     if (counter) {
       counter->IncrementExecutionDuration(duration.ToMicroseconds());
@@ -391,23 +383,16 @@ TimeoutManager::UpdateBudget(const TimeS
     // timeouts being executed, even though budget throttling isn't
     // active at the moment.
     mExecutionBudget = GetMaxBudget(isBackground);
   }
 
   mLastBudgetUpdate = aNow;
 }
 
-#define TRACKING_SEPARATE_TIMEOUT_BUCKETING_STRATEGY 0 // Consider all timeouts coming from tracking scripts as tracking
-// These strategies are useful for testing.
-#define ALL_NORMAL_TIMEOUT_BUCKETING_STRATEGY        1 // Consider all timeouts as normal
-#define ALTERNATE_TIMEOUT_BUCKETING_STRATEGY         2 // Put every other timeout in the list of tracking timeouts
-#define RANDOM_TIMEOUT_BUCKETING_STRATEGY            3 // Put timeouts into either the normal or tracking timeouts list randomly
-static int32_t gTimeoutBucketingStrategy = 0;
-
 #define DEFAULT_TIMEOUT_THROTTLING_DELAY           -1  // Only positive integers cause us to introduce a delay for
                                                        // timeout throttling.
 
 // The longest interval (as PRIntervalTime) we permit, or that our
 // timer code can handle, really. See DELAY_INTERVAL_LIMIT in
 // nsTimerImpl.h for details.
 #define DOM_MAX_TIMEOUT_VALUE    DELAY_INTERVAL_LIMIT
 
@@ -425,18 +410,17 @@ uint32_t gMaxConsecutiveCallbacksMillise
 #define DEFAULT_DISABLE_OPEN_CLICK_DELAY 0
 int32_t gDisableOpenClickDelay;
 
 } // anonymous namespace
 
 TimeoutManager::TimeoutManager(nsGlobalWindowInner& aWindow)
   : mWindow(aWindow),
     mExecutor(new TimeoutExecutor(this)),
-    mNormalTimeouts(*this),
-    mTrackingTimeouts(*this),
+    mTimeouts(*this),
     mTimeoutIdCounter(1),
     mNextFiringId(InvalidFiringId + 1),
     mRunningTimeout(nullptr),
     mIdleCallbackTimeoutCounter(1),
     mLastBudgetUpdate(TimeStamp::Now()),
     mExecutionBudget(GetMaxBudget(mWindow.IsBackgroundInternal())),
     mThrottleTimeouts(false),
     mThrottleTrackingTimeouts(false),
@@ -469,19 +453,16 @@ TimeoutManager::Initialize()
                               "dom.min_background_timeout_value",
                               DEFAULT_MIN_BACKGROUND_TIMEOUT_VALUE);
   Preferences::AddIntVarCache(&gMinTrackingTimeoutValue,
                               "dom.min_tracking_timeout_value",
                               DEFAULT_MIN_TRACKING_TIMEOUT_VALUE);
   Preferences::AddIntVarCache(&gMinTrackingBackgroundTimeoutValue,
                               "dom.min_tracking_background_timeout_value",
                               DEFAULT_MIN_TRACKING_BACKGROUND_TIMEOUT_VALUE);
-  Preferences::AddIntVarCache(&gTimeoutBucketingStrategy,
-                              "dom.timeout_bucketing_strategy",
-                              TRACKING_SEPARATE_TIMEOUT_BUCKETING_STRATEGY);
   Preferences::AddIntVarCache(&gTimeoutThrottlingDelay,
                               "dom.timeout.throttling_delay",
                               DEFAULT_TIMEOUT_THROTTLING_DELAY);
 
   Preferences::AddBoolVarCache(&gAnnotateTrackingChannels,
                                "privacy.trackingprotection.annotate_channels",
                                false);
 
@@ -558,53 +539,16 @@ TimeoutManager::SetTimeout(nsITimeoutHan
   timeout->mIsInterval = aIsInterval;
   timeout->mInterval = TimeDuration::FromMilliseconds(interval);
   timeout->mScriptHandler = aHandler;
   timeout->mReason = aReason;
 
   // No popups from timeouts by default
   timeout->mPopupState = openAbused;
 
-  switch (gTimeoutBucketingStrategy) {
-  default:
-  case TRACKING_SEPARATE_TIMEOUT_BUCKETING_STRATEGY: {
-    const char* filename = nullptr;
-    uint32_t dummyLine = 0, dummyColumn = 0;
-    aHandler->GetLocation(&filename, &dummyLine, &dummyColumn);
-    timeout->mIsTracking = doc->IsScriptTracking(nsDependentCString(filename));
-
-    MOZ_LOG(gLog, LogLevel::Debug,
-            ("Classified timeout %p set from %s as %stracking\n",
-             timeout.get(), filename, timeout->mIsTracking ? "" : "non-"));
-    break;
-  }
-  case ALL_NORMAL_TIMEOUT_BUCKETING_STRATEGY:
-    // timeout->mIsTracking is already false!
-    MOZ_DIAGNOSTIC_ASSERT(!timeout->mIsTracking);
-
-    MOZ_LOG(gLog, LogLevel::Debug,
-            ("Classified timeout %p unconditionally as normal\n",
-             timeout.get()));
-    break;
-  case ALTERNATE_TIMEOUT_BUCKETING_STRATEGY:
-    timeout->mIsTracking = (mTimeoutIdCounter % 2) == 0;
-
-    MOZ_LOG(gLog, LogLevel::Debug,
-            ("Classified timeout %p as %stracking (alternating mode)\n",
-             timeout.get(), timeout->mIsTracking ? "" : "non-"));
-    break;
-  case RANDOM_TIMEOUT_BUCKETING_STRATEGY:
-    timeout->mIsTracking = (rand() % 2) == 0;
-
-    MOZ_LOG(gLog, LogLevel::Debug,
-            ("Classified timeout %p as %stracking (random mode)\n",
-             timeout.get(), timeout->mIsTracking ? "" : "non-"));
-    break;
-  }
-
   timeout->mNestingLevel = sNestingLevel < DOM_CLAMP_TIMEOUT_NESTING_LEVEL
                          ? sNestingLevel + 1 : sNestingLevel;
 
   // Now clamp the actual interval we will use for the timer based on
   TimeDuration realInterval = CalculateDelay(timeout);
   TimeStamp now = TimeStamp::Now();
   timeout->SetWhenOrTimeRemaining(now, realInterval);
 
@@ -628,59 +572,53 @@ TimeoutManager::SetTimeout(nsITimeoutHan
     // in some cases.
     if (interval <= gDisableOpenClickDelay) {
       timeout->mPopupState = nsContentUtils::GetPopupControlState();
     }
   }
 
   Timeouts::SortBy sort(mWindow.IsFrozen() ? Timeouts::SortBy::TimeRemaining
                                            : Timeouts::SortBy::TimeWhen);
-  if (timeout->mIsTracking) {
-    mTrackingTimeouts.Insert(timeout, sort);
-  } else {
-    mNormalTimeouts.Insert(timeout, sort);
-  }
+  mTimeouts.Insert(timeout, sort);
 
   timeout->mTimeoutId = GetTimeoutId(aReason);
   *aReturn = timeout->mTimeoutId;
 
   MOZ_LOG(gLog,
           LogLevel::Debug,
           ("Set%s(TimeoutManager=%p, timeout=%p, delay=%i, "
            "minimum=%f, throttling=%s, state=%s(%s), realInterval=%f) "
-           "returned %stracking timeout ID %u, budget=%d\n",
+           "returned timeout ID %u, budget=%d\n",
            aIsInterval ? "Interval" : "Timeout",
            this, timeout.get(), interval,
            (CalculateDelay(timeout) - timeout->mInterval).ToMilliseconds(),
            mThrottleTimeouts
              ? "yes"
              : (mThrottleTimeoutsTimer ? "pending" : "no"),
            IsActive() ? "active" : "inactive",
            mWindow.IsBackgroundInternal() ? "background" : "foreground",
            realInterval.ToMilliseconds(),
-           timeout->mIsTracking ? "" : "non-",
            timeout->mTimeoutId,
            int(mExecutionBudget.ToMilliseconds())));
 
   return NS_OK;
 }
 
 void
 TimeoutManager::ClearTimeout(int32_t aTimerId, Timeout::Reason aReason)
 {
   uint32_t timerId = (uint32_t)aTimerId;
 
   bool firstTimeout = true;
   bool deferredDeletion = false;
 
-  ForEachUnorderedTimeoutAbortable([&](Timeout* aTimeout) {
+  mTimeouts.ForEachAbortable([&](Timeout* aTimeout) {
     MOZ_LOG(gLog, LogLevel::Debug,
-            ("Clear%s(TimeoutManager=%p, timeout=%p, aTimerId=%u, ID=%u, tracking=%d)\n", aTimeout->mIsInterval ? "Interval" : "Timeout",
-             this, aTimeout, timerId, aTimeout->mTimeoutId,
-             int(aTimeout->mIsTracking)));
+            ("Clear%s(TimeoutManager=%p, timeout=%p, aTimerId=%u, ID=%u)\n", aTimeout->mIsInterval ? "Interval" : "Timeout",
+             this, aTimeout, timerId, aTimeout->mTimeoutId));
 
     if (aTimeout->mTimeoutId == timerId && aTimeout->mReason == aReason) {
       if (aTimeout->mRunning) {
         /* We're running from inside the aTimeout. Mark this
            aTimeout for deferred deletion by the code in
            RunTimeout() */
         aTimeout->mIsInterval = false;
         deferredDeletion = true;
@@ -707,18 +645,17 @@ TimeoutManager::ClearTimeout(int32_t aTi
   //    Timeouts.
   if (!firstTimeout || deferredDeletion || mWindow.IsSuspended()) {
     return;
   }
 
   // Stop the executor and restart it at the next soonest deadline.
   mExecutor->Cancel();
 
-  OrderedTimeoutIterator iter(mNormalTimeouts, mTrackingTimeouts);
-  Timeout* nextTimeout = iter.Next();
+  Timeout* nextTimeout = mTimeouts.GetFirst();
   if (nextTimeout) {
     MOZ_ALWAYS_SUCCEEDS(MaybeSchedule(nextTimeout->When()));
   }
 }
 
 void
 TimeoutManager::RunTimeout(const TimeStamp& aNow, const TimeStamp& aTargetDeadline)
 {
@@ -782,49 +719,40 @@ TimeoutManager::RunTimeout(const TimeSta
   uint32_t numTimersToRun = 0;
 
   // The timeout list is kept in deadline order. Discover the latest timeout
   // whose deadline has expired. On some platforms, native timeout events fire
   // "early", but we handled that above by setting deadline to aTargetDeadline
   // if the timer fired early.  So we can stop walking if we get to timeouts
   // whose When() is greater than deadline, since once that happens we know
   // nothing past that point is expired.
-  {
-    // Use a nested scope in order to make sure the strong references held by
-    // the iterator are freed after the loop.
-    OrderedTimeoutIterator expiredIter(mNormalTimeouts, mTrackingTimeouts);
-
-    while (true) {
-      Timeout* timeout = expiredIter.Next();
-      if (!timeout || totalTimeLimit.IsZero() || timeout->When() > deadline) {
-        if (timeout) {
-          nextDeadline = timeout->When();
-        }
-        break;
-      }
+  for (Timeout* timeout = mTimeouts.GetFirst();
+       timeout != nullptr;
+       timeout = timeout->getNext()) {
+    if (totalTimeLimit.IsZero() || timeout->When() > deadline) {
+      nextDeadline = timeout->When();
+      break;
+    }
 
-      if (IsInvalidFiringId(timeout->mFiringId)) {
-        // Mark any timeouts that are on the list to be fired with the
-        // firing depth so that we can reentrantly run timeouts
-        timeout->mFiringId = firingId;
+    if (IsInvalidFiringId(timeout->mFiringId)) {
+      // Mark any timeouts that are on the list to be fired with the
+      // firing depth so that we can reentrantly run timeouts
+      timeout->mFiringId = firingId;
 
-        numTimersToRun += 1;
+      numTimersToRun += 1;
 
-        // Run only a limited number of timers based on the configured maximum.
-        if (numTimersToRun % kNumTimersPerInitialElapsedCheck == 0) {
-          now = TimeStamp::Now();
-          TimeDuration elapsed(now - start);
-          if (elapsed >= initialTimeLimit) {
-            nextDeadline = timeout->When();
-            break;
-          }
+      // Run only a limited number of timers based on the configured maximum.
+      if (numTimersToRun % kNumTimersPerInitialElapsedCheck == 0) {
+        now = TimeStamp::Now();
+        TimeDuration elapsed(now - start);
+        if (elapsed >= initialTimeLimit) {
+          nextDeadline = timeout->When();
+          break;
         }
       }
-
-      expiredIter.UpdateIterator();
     }
   }
 
   now = TimeStamp::Now();
 
   // Wherever we stopped in the timer list, schedule the executor to
   // run for the next unexpired deadline.  Note, this *must* be done
   // before we start executing any content script handlers.  If one
@@ -848,27 +776,28 @@ TimeoutManager::RunTimeout(const TimeSta
   // Now we need to search the normal and tracking timer list at the same
   // time to run the timers in the scheduled order.
 
   // We stop iterating each list when we go past the last expired timeout from
   // that list that we have observed above.  That timeout will either be the
   // next item after the last timeout we looked at or nullptr if we have
   // exhausted the entire list while looking for the last expired timeout.
   {
-    // Use a nested scope in order to make sure the strong references held by
-    // the iterator are freed after the loop.
-    OrderedTimeoutIterator runIter(mNormalTimeouts, mTrackingTimeouts);
-    while (true) {
-      RefPtr<Timeout> timeout = runIter.Next();
-      if (!timeout) {
-        // We have run out of timeouts!
-        break;
-      }
-      runIter.UpdateIterator();
+    // Use a nested scope in order to make sure the strong references held while
+    // iterating are freed after the loop.
 
+    // The next timeout to run. This is used to advance the loop, but
+    // we cannot set it until we've run the current timeout, since
+    // running the current timeout might remove the immediate next
+    // timeout.
+    RefPtr<Timeout> next;
+
+    for (RefPtr<Timeout> timeout = mTimeouts.GetFirst();
+         timeout != nullptr;
+         timeout = next) {
       // We should only execute callbacks for the set of expired Timeout
       // objects we computed above.
       if (timeout->mFiringId != firingId) {
         // If the FiringId does not match, but is still valid, then this is
         // a TImeout for another RunTimeout() on the call stack.  Just
         // skip it.
         if (IsValidFiringId(timeout->mFiringId)) {
           continue;
@@ -902,25 +831,28 @@ TimeoutManager::RunTimeout(const TimeSta
         // so just remove it.
         timeout->remove();
         continue;
       }
 
       // This timeout is good to run
       bool timeout_was_cleared = mWindow.RunTimeoutHandler(timeout, scx);
 
-      MOZ_LOG(gLog, LogLevel::Debug,
-              ("Run%s(TimeoutManager=%p, timeout=%p, tracking=%d) returned %d\n", timeout->mIsInterval ? "Interval" : "Timeout",
-               this, timeout.get(),
-               int(timeout->mIsTracking),
-               !!timeout_was_cleared));
+      MOZ_LOG(
+        gLog,
+        LogLevel::Debug,
+        ("Run%s(TimeoutManager=%p, timeout=%p) returned %d\n",
+         timeout->mIsInterval ? "Interval" : "Timeout",
+         this,
+         timeout.get(),
+         !!timeout_was_cleared));
 
       if (timeout_was_cleared) {
-        // Make sure the iterator isn't holding any Timeout objects alive.
-        runIter.Clear();
+        // Make sure we're not holding any Timeout objects alive.
+        next = nullptr;
 
         // Since ClearAllTimeouts() was called the lists should be empty.
         MOZ_DIAGNOSTIC_ASSERT(!HasTimeouts());
 
         return;
       }
 
       // If we need to reschedule a setInterval() the delay should be
@@ -931,54 +863,47 @@ TimeoutManager::RunTimeout(const TimeSta
       now = TimeStamp::Now();
 
       // If we have a regular interval timer, we re-schedule the
       // timeout, accounting for clock drift.
       bool needsReinsertion = RescheduleTimeout(timeout, lastCallbackTime, now);
 
       // Running a timeout can cause another timeout to be deleted, so
       // we need to reset the pointer to the following timeout.
-      runIter.UpdateIterator();
+      next = timeout->getNext();
 
       timeout->remove();
 
       if (needsReinsertion) {
         // Insert interval timeout onto the corresponding list sorted in
         // deadline order. AddRefs timeout.
-        if (runIter.PickedTrackingIter()) {
-          mTrackingTimeouts.Insert(timeout,
-                                   mWindow.IsFrozen() ? Timeouts::SortBy::TimeRemaining
-                                                      : Timeouts::SortBy::TimeWhen);
-        } else {
-          mNormalTimeouts.Insert(timeout,
-                                 mWindow.IsFrozen() ? Timeouts::SortBy::TimeRemaining
-                                                    : Timeouts::SortBy::TimeWhen);
-        }
+        mTimeouts.Insert(timeout,
+                         mWindow.IsFrozen() ? Timeouts::SortBy::TimeRemaining
+                                            : Timeouts::SortBy::TimeWhen);
       }
 
       // Check to see if we have run out of time to execute timeout handlers.
       // If we've exceeded our time budget then terminate the loop immediately.
       TimeDuration elapsed = now - start;
       if (elapsed >= totalTimeLimit) {
         // We ran out of time.  Make sure to schedule the executor to
         // run immediately for the next timer, if it exists.  Its possible,
         // however, that the last timeout handler suspended the window.  If
         // that happened then we must skip this step.
         if (!mWindow.IsSuspended()) {
-          RefPtr<Timeout> timeout = runIter.Next();
-          if (timeout) {
+          if (next) {
             // If we ran out of execution budget we need to force a
             // reschedule. By cancelling the executor we will not run
             // immediately, but instead reschedule to the minimum
             // scheduling delay.
             if (mExecutionBudget < TimeDuration()) {
               mExecutor->Cancel();
             }
 
-            MOZ_ALWAYS_SUCCEEDS(MaybeSchedule(timeout->When(), now));
+            MOZ_ALWAYS_SUCCEEDS(MaybeSchedule(next->When(), now));
           }
         }
         break;
       }
     }
   }
 }
 
@@ -1051,18 +976,17 @@ TimeoutManager::ClearAllTimeouts()
     }
 
     // Set timeout->mCleared to true to indicate that the timeout was
     // cleared and taken out of the list of timeouts
     aTimeout->mCleared = true;
   });
 
   // Clear out our list
-  mNormalTimeouts.Clear();
-  mTrackingTimeouts.Clear();
+  mTimeouts.Clear();
 }
 
 void
 TimeoutManager::Timeouts::Insert(Timeout* aTimeout, SortBy aSortBy)
 {
 
   // Start at mLastTimeout and go backwards.  Stop if we see a Timeout with a
   // valid FiringId since those timers are currently being processed by
@@ -1144,18 +1068,17 @@ TimeoutManager::Resume()
 
   // When Suspend() has been called after IsDocumentLoaded(), but the
   // throttle tracking timer never managed to fire, start the timer
   // again.
   if (mWindow.AsInner()->IsDocumentLoaded() && !mThrottleTimeouts) {
     MaybeStartThrottleTimeout();
   }
 
-  OrderedTimeoutIterator iter(mNormalTimeouts, mTrackingTimeouts);
-  Timeout* nextTimeout = iter.Next();
+  Timeout* nextTimeout = mTimeouts.GetFirst();
   if (nextTimeout) {
     MOZ_ALWAYS_SUCCEEDS(MaybeSchedule(nextTimeout->When()));
   }
 }
 
 void
 TimeoutManager::Freeze()
 {
@@ -1197,33 +1120,24 @@ TimeoutManager::UpdateBackgroundState()
 {
   mExecutionBudget = GetMaxBudget(mWindow.IsBackgroundInternal());
 
   // When the window moves to the background or foreground we should
   // reschedule the TimeoutExecutor in case the MinSchedulingDelay()
   // changed.  Only do this if the window is not suspended and we
   // actually have a timeout.
   if (!mWindow.IsSuspended()) {
-    OrderedTimeoutIterator iter(mNormalTimeouts, mTrackingTimeouts);
-    Timeout* nextTimeout = iter.Next();
+    Timeout* nextTimeout = mTimeouts.GetFirst();
     if (nextTimeout) {
       mExecutor->Cancel();
       MOZ_ALWAYS_SUCCEEDS(MaybeSchedule(nextTimeout->When()));
     }
   }
 }
 
-bool
-TimeoutManager::IsTimeoutTracking(uint32_t aTimeoutId)
-{
-  return mTrackingTimeouts.ForEachAbortable([&](Timeout* aTimeout) {
-      return aTimeout->mTimeoutId == aTimeoutId;
-    });
-}
-
 namespace {
 
 class ThrottleTimeoutsCallback final : public nsITimerCallback
                                      , public nsINamed
 {
 public:
   explicit ThrottleTimeoutsCallback(nsGlobalWindowInner* aWindow)
     : mWindow(aWindow)
--- a/dom/base/TimeoutManager.h
+++ b/dom/base/TimeoutManager.h
@@ -16,17 +16,16 @@ class nsITimer;
 class nsGlobalWindowInner;
 
 namespace mozilla {
 
 class PerformanceCounter;
 
 namespace dom {
 
-class OrderedTimeoutIterator;
 class TimeoutExecutor;
 
 // This class manages the timeouts in a Window's setTimeout/setInterval pool.
 class TimeoutManager final
 {
 public:
   explicit TimeoutManager(nsGlobalWindowInner& aWindow);
   ~TimeoutManager();
@@ -35,18 +34,17 @@ public:
 
   bool IsRunningTimeout() const;
 
   static uint32_t GetNestingLevel() { return sNestingLevel; }
   static void SetNestingLevel(uint32_t aLevel) { sNestingLevel = aLevel; }
 
   bool HasTimeouts() const
   {
-    return !mNormalTimeouts.IsEmpty() ||
-           !mTrackingTimeouts.IsEmpty();
+    return !mTimeouts.IsEmpty();
   }
 
   nsresult SetTimeout(nsITimeoutHandler* aHandler,
                       int32_t interval, bool aIsInterval,
                       mozilla::dom::Timeout::Reason aReason,
                       int32_t* aReturn);
   void ClearTimeout(int32_t aTimerId,
                     mozilla::dom::Timeout::Reason aReason);
@@ -76,41 +74,26 @@ public:
 
   // This should be called by nsGlobalWindow when the window might have moved
   // to the background or foreground.
   void UpdateBackgroundState();
 
   // Initialize TimeoutManager before the first time it is accessed.
   static void Initialize();
 
-  // Exposed only for testing
-  bool IsTimeoutTracking(uint32_t aTimeoutId);
-
   // The document finished loading
   void OnDocumentLoaded();
   void StartThrottlingTimeouts();
 
   // Run some code for each Timeout in our list.  Note that this function
   // doesn't guarantee that Timeouts are iterated in any particular order.
   template <class Callable>
   void ForEachUnorderedTimeout(Callable c)
   {
-    mNormalTimeouts.ForEach(c);
-    mTrackingTimeouts.ForEach(c);
-  }
-
-  // Run some code for each Timeout in our list, but let the callback cancel the
-  // iteration by returning true.  Note that this function doesn't guarantee
-  // that Timeouts are iterated in any particular order.
-  template <class Callable>
-  void ForEachUnorderedTimeoutAbortable(Callable c)
-  {
-    if (!mNormalTimeouts.ForEachAbortable(c)) {
-      mTrackingTimeouts.ForEachAbortable(c);
-    }
+    mTimeouts.ForEach(c);
   }
 
   void BeginSyncOperation();
   void EndSyncOperation();
 
   nsIEventTarget*
   EventTarget();
 
@@ -199,43 +182,37 @@ private:
            timeout = timeout->getNext()) {
         if (c(timeout)) {
           return true;
         }
       }
       return false;
     }
 
-    friend class OrderedTimeoutIterator;
-
   private:
     // The TimeoutManager that owns this Timeouts structure.  This is
     // mainly used to call state inspecting methods like IsValidFiringId().
     const TimeoutManager&     mManager;
 
     typedef mozilla::LinkedList<RefPtr<Timeout>> TimeoutList;
 
     // mTimeoutList is generally sorted by mWhen, but new values are always
     // inserted after any Timeouts with a valid FiringId.
     TimeoutList               mTimeoutList;
   };
 
-  friend class OrderedTimeoutIterator;
-
   // Each nsGlobalWindowInner object has a TimeoutManager member.  This reference
   // points to that holder object.
   nsGlobalWindowInner&             mWindow;
   // The executor is specific to the nsGlobalWindow/TimeoutManager, but it
   // can live past the destruction of the window if its scheduled.  Therefore
   // it must be a separate ref-counted object.
   RefPtr<TimeoutExecutor>     mExecutor;
   // The list of timeouts coming from non-tracking scripts.
-  Timeouts                    mNormalTimeouts;
-  // The list of timeouts coming from scripts on the tracking protection list.
-  Timeouts                    mTrackingTimeouts;
+  Timeouts                    mTimeouts;
   uint32_t                    mTimeoutIdCounter;
   uint32_t                    mNextFiringId;
   AutoTArray<uint32_t, 2>     mFiringIdStack;
   mozilla::dom::Timeout*      mRunningTimeout;
 
    // The current idle request callback timeout handle
   uint32_t                    mIdleCallbackTimeoutCounter;
 
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -4245,31 +4245,16 @@ nsDOMWindowUtils::GetGpuProcessPid(int32
     *aPid = pm->GPUProcessPid();
   } else {
     *aPid = -1;
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsDOMWindowUtils::IsTimeoutTracking(uint32_t aTimeoutId, bool* aResult)
-{
-  NS_ENSURE_ARG_POINTER(aResult);
-  *aResult = false;
-
-  nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow);
-  NS_ENSURE_STATE(window);
-  nsCOMPtr<nsPIDOMWindowInner> innerWindow = window->GetCurrentInnerWindow();
-  NS_ENSURE_STATE(innerWindow);
-
-  *aResult = innerWindow->TimeoutManager().IsTimeoutTracking(aTimeoutId);
-  return NS_OK;
-}
-
 struct StateTableEntry
 {
   const char* mStateString;
   EventStates mState;
 };
 
 static constexpr StateTableEntry kManuallyManagedStates[] = {
   { "-moz-autofill", NS_EVENT_STATE_AUTOFILL },
@@ -4488,9 +4473,8 @@ nsDOMWindowUtils::IsCssPropertyRecordedI
 
   bool knownProp = false;
   *aRecorded =
     Servo_IsCssPropertyRecordedInUseCounter(doc->GetStyleUseCounters(),
                                             &aPropName,
                                             &knownProp);
   return knownProp ? NS_OK : NS_ERROR_FAILURE;
 }
-
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -107,16 +107,17 @@ class nsIRunnable;
 class nsISecurityConsoleMessage;
 class nsIStreamListener;
 class nsIStructuredCloneContainer;
 class nsIURI;
 class nsIVariant;
 class nsViewManager;
 class nsPresContext;
 class nsRange;
+class nsSimpleContentList;
 class nsSMILAnimationController;
 class nsSVGElement;
 class nsTextNode;
 class nsUnblockOnloadEvent;
 class nsWindowSizes;
 class nsDOMCaretPosition;
 class nsViewportInfo;
 class nsIGlobalObject;
--- a/dom/base/test/file_timer_flood.html
+++ b/dom/base/test/file_timer_flood.html
@@ -1,29 +1,19 @@
 <!DOCTYPE HTML>
 <html>
 <body>
 <script>
 let count = 0;
-let last_timer_set = 0;
-let last_timer_observed = 0;
-function cb(timer_observed) {
-  if (timer_observed > last_timer_observed) {
-    // In order to make the test more efficient, we don't use the SimpleTest
-    // ok() function to avoid generating one test assertion per one of these
-    // checks.  We only send a message to the parent which fails the test if
-    // we detect out of order firing of timeouts.
-    window.parent.postMessage('OUT_OF_ORDER', '*');
-  }
-  last_timer_observed = timer_observed;
+function cb() {
   count += 1;
   // Notify our parent that we are ready once the timer flood has
   // warmed up.
   if (count === 10000) {
     window.parent.postMessage('STARTED', '*');
   }
-  last_timer_set = setTimeout(cb.bind(last_timer_set), 0);
-  last_timer_set = setTimeout(cb.bind(last_timer_set), 0);
+  setTimeout(cb, 0);
+  setTimeout(cb, 0);
 }
 addEventListener('load', cb);
 </script>
 </body>
 </html>
--- a/dom/base/test/test_timer_flood.html
+++ b/dom/base/test/test_timer_flood.html
@@ -17,34 +17,25 @@ SimpleTest.waitForExplicitFinish();
 SimpleTest.requestLongerTimeout(5);
 
 function onLoad() {
   return new Promise(resolve => {
     addEventListener('load', resolve, { once: true });
   });
 }
 
-function setPrefs() {
-  // Put timeouts randomly in the tracking or normal buffer.  We do this in order to
-  // test to ensure that by default, this will not change the scheduling of timeouts.
-  return SpecialPowers.pushPrefEnv({"set": [["dom.timeout_bucketing_strategy", 3]]});
-}
-
 // Create a frame that executes a timer flood.  The frame signals
 // that is ready once the flood has had a chance to warm up.
 function withFloodFrame() {
-  return new Promise((resolve, reject) => {
+  return new Promise(resolve => {
     let frame = document.createElement('iframe');
     addEventListener('message', function onMsg(evt) {
       if (evt.data === 'STARTED') {
         removeEventListener('message', onMsg);
         resolve(frame);
-      } else if (evt.data == 'OUT_OF_ORDER') {
-        ok(false, "Out of order timeout observed");
-        reject();
       }
     });
     frame.src = 'file_timer_flood.html';
     document.body.appendChild(frame);
   });
 }
 
 // Test that we can load documents during a timer flood.
@@ -81,19 +72,17 @@ function testRequestAnimationFrame() {
       }
     };
     requestAnimationFrame(nextFrame);
   });
 }
 
 let floodFrame;
 
-onLoad()
-.then(setPrefs)
-.then(_ => {
+onLoad().then(_ => {
   // Start a timer flood in a frame.
   return withFloodFrame();
 }).then(frame => {
   floodFrame = frame;
 
   // Next we are going to start a bunch of asynchronous work that we
   // expect to complete in spite of the timer flood.  The type of work
   // is a bit arbitrary, but is chosen to reflect the kinds of things
@@ -117,15 +106,13 @@ onLoad()
 
   // Wait for all tests to finish.  If we do not handle the timer flood
   // well then this will likely time out.
   return Promise.all(tests);
 }).then(_ => {
   ok(true, 'completed tests without timing out');
   floodFrame.remove();
   SimpleTest.finish();
-}).catch(_ => {
-  SimpleTest.finish();
 });
 </script>
 </pre>
 </body>
 </html>
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -1872,22 +1872,16 @@ interface nsIDOMWindowUtils : nsISupport
   void terminateGPUProcess();
 
   /**
     * Returns the GPU process pid, or -1 if there is no GPU process.
     */
   readonly attribute int32_t gpuProcessPid;
 
   /**
-   * Returns true if the given timeout ID is in the list of tracking
-   * timeouts.
-   */
-  boolean isTimeoutTracking(in unsigned long timeoutId);
-
-  /**
    * Adds an EventStates bit to the element.
    *
    * The state string must be one of the following:
    *   * (none yet; but for example "higlighted" for NS_EVENT_STATE_HIGHLIGHTED)
    *
    * The supported state strings are defined in kManuallyManagedStates
    * in nsDOMWindowUtils.cpp.
    */
--- a/dom/smil/nsSMILCSSValueType.cpp
+++ b/dom/smil/nsSMILCSSValueType.cpp
@@ -24,17 +24,16 @@
 #include "mozilla/dom/BaseKeyframeTypesBinding.h" // For CompositeOperation
 #include "mozilla/dom/Element.h"
 #include "nsDebug.h"
 #include "nsStyleUtil.h"
 #include "nsIDocument.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
-using mozilla::StyleAnimationValue;
 
 typedef AutoTArray<RefPtr<RawServoAnimationValue>, 1> ServoAnimationValues;
 
 /*static*/ nsSMILCSSValueType nsSMILCSSValueType::sSingleton;
 
 struct ValueWrapper {
   ValueWrapper(nsCSSPropertyID aPropID, const AnimationValue& aValue)
     : mPropID(aPropID)
--- a/intl/locale/nsLanguageAtomService.cpp
+++ b/intl/locale/nsLanguageAtomService.cpp
@@ -91,17 +91,17 @@ nsLanguageAtomService::GetLanguageGroup(
   if (!retVal) {
     if (aNeedsToCache) {
       *aNeedsToCache = true;
       return nullptr;
     }
     RefPtr<nsAtom> uncached = GetUncachedLanguageGroup(aLanguage);
     retVal = uncached.get();
 
-    AssertIsMainThreadOrServoLangFontPrefsCacheLocked();
+    AssertIsMainThreadOrServoFontMetricsLocked();
     // The hashtable will keep an owning reference to the atom
     mLangToGroup.Put(aLanguage, uncached);
   }
 
   return retVal;
 }
 
 already_AddRefed<nsAtom>
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -6,16 +6,17 @@
 
 #include "mozilla/RestyleManager.h"
 
 #include "mozilla/AutoRestyleTimelineMarker.h"
 #include "mozilla/AutoTimelineMarker.h"
 #include "mozilla/ComputedStyle.h"
 #include "mozilla/ComputedStyleInlines.h"
 #include "mozilla/DocumentStyleRootIterator.h"
+#include "mozilla/GeckoBindings.h"
 #include "mozilla/LayerAnimationInfo.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/ServoStyleSetInlines.h"
 #include "mozilla/Unused.h"
 #include "mozilla/ViewportFrame.h"
 #include "mozilla/dom/ChildIterator.h"
 #include "mozilla/dom/ElementInlines.h"
 #include "mozilla/dom/HTMLBodyElement.h"
--- a/layout/base/StaticPresData.cpp
+++ b/layout/base/StaticPresData.cpp
@@ -260,27 +260,27 @@ StaticPresData::GetFontPrefsForLangHelpe
         break;
       }
       prefs = prefs->mNext;
     }
     if (aNeedsToCache) {
       *aNeedsToCache = true;
       return nullptr;
     }
-    AssertIsMainThreadOrServoLangFontPrefsCacheLocked();
+    AssertIsMainThreadOrServoFontMetricsLocked();
     // nothing cached, so go on and fetch the prefs for this lang group:
     prefs = prefs->mNext = new LangGroupFontPrefs;
   }
 
   if (aNeedsToCache) {
     *aNeedsToCache = true;
     return nullptr;
   }
 
-  AssertIsMainThreadOrServoLangFontPrefsCacheLocked();
+  AssertIsMainThreadOrServoFontMetricsLocked();
   prefs->Initialize(langGroupAtom);
 
   return prefs;
 }
 
 const nsFont*
 StaticPresData::GetDefaultFontHelper(uint8_t aFontID, nsAtom *aLanguage,
                                      const LangGroupFontPrefs* aPrefs) const
new file mode 100644
--- /dev/null
+++ b/layout/style/BorrowedTypeList.h
@@ -0,0 +1,52 @@
+/* -*- 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/. */
+
+/* a list of Gecko types used across bindings, for preprocessing */
+
+// There are two macros:
+//
+//   GECKO_BORROWED_TYPE(gecko_type, ffi_type_name)
+//   GECKO_BORROWED_MUT_TYPE(gecko_type, ffi_type_name)
+//
+// GECKO_BORROWED_TYPE will generated Borrowed and BorrowedOrNull types.
+//
+// GECKO_BORROWED_MUT_TYPE will generate those and the BorrowedMut &
+// BorrowedMutOrNull types.
+//
+// The first argument is the Gecko C++ type name.  This must be a type
+// that is in scope in ServoBindingTypes.h; forward declarations may need
+// to be added there.
+//
+// The second argument is the name of a typedef that will be generated,
+// equivalent to the actual C++ type.  This name will be used as the basis
+// for the generated borrowed type names to be used in FFI signatures in
+// C++ and Rust.  The convention for this name is "RawGecko{Type}", where
+// {Type} is the name of the C++ type or something close to it.
+//
+// See the comment at the top of ServoBindingTypes.h for how to use these.
+
+GECKO_BORROWED_TYPE(mozilla::dom::Element, RawGeckoElement)
+GECKO_BORROWED_TYPE(nsIDocument, RawGeckoDocument)
+GECKO_BORROWED_TYPE(nsINode, RawGeckoNode)
+GECKO_BORROWED_TYPE(nsPresContext, RawGeckoPresContext)
+GECKO_BORROWED_TYPE(nsXBLBinding, RawGeckoXBLBinding)
+GECKO_BORROWED_TYPE_MUT(mozilla::AnimationPropertySegment, RawGeckoAnimationPropertySegment)
+GECKO_BORROWED_TYPE_MUT(mozilla::ComputedTiming, RawGeckoComputedTiming)
+GECKO_BORROWED_TYPE_MUT(mozilla::dom::StyleChildrenIterator, RawGeckoStyleChildrenIterator)
+GECKO_BORROWED_TYPE_MUT(mozilla::GfxMatrix4x4, RawGeckoGfxMatrix4x4)
+GECKO_BORROWED_TYPE_MUT(mozilla::ServoElementSnapshot, ServoElementSnapshot)
+GECKO_BORROWED_TYPE_MUT(mozilla::URLExtraData, RawGeckoURLExtraData)
+GECKO_BORROWED_TYPE_MUT(nsCSSPropertyIDSet, nsCSSPropertyIDSet)
+GECKO_BORROWED_TYPE_MUT(nsCSSValue, nsCSSValue)
+GECKO_BORROWED_TYPE_MUT(nsStyleAutoArray<mozilla::StyleAnimation>, RawGeckoStyleAnimationList)
+GECKO_BORROWED_TYPE_MUT(nsTArray<const RawServoStyleRule*>, RawGeckoServoStyleRuleList)
+GECKO_BORROWED_TYPE_MUT(nsTArray<mozilla::ComputedKeyframeValues>, RawGeckoComputedKeyframeValuesList)
+GECKO_BORROWED_TYPE_MUT(nsTArray<mozilla::Keyframe>, RawGeckoKeyframeList)
+GECKO_BORROWED_TYPE_MUT(nsTArray<mozilla::PropertyValuePair>, RawGeckoPropertyValuePairList)
+GECKO_BORROWED_TYPE_MUT(nsTArray<nsCSSPropertyID>, RawGeckoCSSPropertyIDList)
+GECKO_BORROWED_TYPE_MUT(nsTArray<nsFontFaceRuleContainer>, RawGeckoFontFaceRuleList)
+GECKO_BORROWED_TYPE_MUT(nsTArray<RefPtr<RawServoAnimationValue>>, RawGeckoServoAnimationValueList)
+GECKO_BORROWED_TYPE_MUT(nsTimingFunction, nsTimingFunction)
rename from layout/style/ServoBindings.cpp
rename to layout/style/GeckoBindings.cpp
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/GeckoBindings.cpp
@@ -1,15 +1,17 @@
 /* -*- 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 "mozilla/ServoBindings.h"
+/* FFI functions for Servo to call into Gecko */
+
+#include "mozilla/GeckoBindings.h"
 
 #include "ChildIterator.h"
 #include "ErrorReporter.h"
 #include "GeckoProfiler.h"
 #include "gfxFontFamilyList.h"
 #include "gfxFontFeatures.h"
 #include "nsAnimationManager.h"
 #include "nsAttrValueInlines.h"
@@ -56,16 +58,17 @@
 #include "mozilla/Mutex.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ServoElementSnapshot.h"
 #include "mozilla/StaticPrefs.h"
 #include "mozilla/RestyleManager.h"
 #include "mozilla/SizeOfState.h"
 #include "mozilla/StyleAnimationValue.h"
 #include "mozilla/SystemGroup.h"
+#include "mozilla/ServoBindings.h"
 #include "mozilla/ServoTraversalStatistics.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/RWLock.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/ElementInlines.h"
 #include "mozilla/dom/HTMLTableCellElement.h"
 #include "mozilla/dom/HTMLBodyElement.h"
 #include "mozilla/dom/HTMLSlotElement.h"
@@ -116,23 +119,16 @@ ThreadSafeGetDefaultFontHelper(const nsP
   }
   {
     AutoWriteLock guard(*sServoFFILock);
     retval = aPresContext->GetDefaultFont(aGenericId, aLanguage, nullptr);
   }
   return retval;
 }
 
-void
-AssertIsMainThreadOrServoLangFontPrefsCacheLocked()
-{
-  MOZ_ASSERT(NS_IsMainThread() || sServoFFILock->LockedForWritingByCurrentThread());
-}
-
-
 /*
  * Does this child count as significant for selector matching?
  *
  * See nsStyleUtil::IsSignificantChild for details.
  */
 bool
 Gecko_IsSignificantChild(RawGeckoNodeBorrowed aNode,
                          bool aWhitespaceIsSignificant)
@@ -2432,16 +2428,18 @@ Gecko_XBLBinding_GetRawServoStyles(RawGe
 bool
 Gecko_XBLBinding_InheritsStyle(RawGeckoXBLBindingBorrowed aXBLBinding)
 {
   return aXBLBinding->InheritsStyle();
 }
 
 static StaticRefPtr<UACacheReporter> gUACacheReporter;
 
+namespace mozilla {
+
 void
 InitializeServo()
 {
   URLExtraData::InitDummy();
   Servo_Initialize(URLExtraData::Dummy());
 
   gUACacheReporter = new UACacheReporter();
   RegisterWeakMemoryReporter(gUACacheReporter);
@@ -2456,18 +2454,16 @@ ShutdownServo()
 
   UnregisterWeakMemoryReporter(gUACacheReporter);
   gUACacheReporter = nullptr;
 
   delete sServoFFILock;
   Servo_Shutdown();
 }
 
-namespace mozilla {
-
 void
 AssertIsMainThreadOrServoFontMetricsLocked()
 {
   if (!NS_IsMainThread()) {
     MOZ_ASSERT(sServoFFILock &&
                sServoFFILock->LockedForWritingByCurrentThread());
   }
 }
copy from layout/style/ServoBindings.h
copy to layout/style/GeckoBindings.h
--- a/layout/style/ServoBindings.h
+++ b/layout/style/GeckoBindings.h
@@ -1,81 +1,52 @@
 /* -*- 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/. */
 
-#ifndef mozilla_ServoBindings_h
-#define mozilla_ServoBindings_h
+/* FFI functions for Servo to call into Gecko */
+
+#ifndef mozilla_GeckoBindings_h
+#define mozilla_GeckoBindings_h
 
 #include <stdint.h>
 
-#include "mozilla/AtomArray.h"
 #include "mozilla/ServoTypes.h"
 #include "mozilla/ServoBindingTypes.h"
-#include "mozilla/ServoComputedDataInlines.h"
-#include "mozilla/ServoElementSnapshot.h"
 #include "mozilla/css/DocumentMatchingFunction.h"
 #include "mozilla/css/SheetLoadData.h"
-#include "mozilla/css/SheetParsingMode.h"
 #include "mozilla/EffectCompositor.h"
 #include "mozilla/ComputedTimingFunction.h"
-#include "nsChangeHint.h"
-#include "nsIDocument.h"
-
-/*
- * API for Servo to access Gecko data structures.
- *
- * Functions beginning with Gecko_ are implemented in Gecko and invoked from Servo.
- * Functions beginning with Servo_ are implemented in Servo and invoked from Gecko.
- */
+#include "nsCSSValue.h"
+#include "nsStyleStruct.h"
 
 class nsAtom;
-class nsIPrincipal;
 class nsIURI;
+class nsSimpleContentList;
 struct nsFont;
+
 namespace mozilla {
-  class FontFamilyList;
-  struct FontFamilyName;
-  enum FontFamilyType : uint8_t;
+  class ComputedStyle;
+  class SeenPtrs;
+  class ServoElementSnapshot;
+  class ServoElementSnapshotTable;
   class SharedFontList;
+  class StyleSheet;
   enum class CSSPseudoElementType : uint8_t;
-  struct Keyframe;
-  struct StyleTransition;
-  namespace css {
-    class ErrorReporter;
-    struct URLValue;
-    class LoaderReusableStyleSheets;
-  };
-  namespace dom {
-    enum class IterationCompositeOperation : uint8_t;
-  };
+  enum class PointerCapabilities : uint8_t;
   enum class UpdateAnimationsTasks : uint8_t;
-  struct LangGroupFontPrefs;
-  class SeenPtrs;
-  class ComputedStyle;
-  class StyleSheet;
-  class ServoElementSnapshotTable;
-  enum class PointerCapabilities : uint8_t;
+  struct FontFamilyName;
+  struct Keyframe;
+
+  namespace css {
+    class LoaderReusableStyleSheets;
+  }
 }
-using mozilla::FontFamilyList;
-using mozilla::FontFamilyName;
-using mozilla::FontFamilyType;
-using mozilla::ServoElementSnapshot;
-using mozilla::SharedFontList;
-struct nsMediaFeature;
-class nsSimpleContentList;
-struct nsStyleList;
-struct nsStyleImage;
-struct nsStyleGradientStop;
-class nsStyleGradient;
-class nsStyleCoord;
-struct nsStyleDisplay;
-class nsXBLBinding;
 
 #ifdef NIGHTLY_BUILD
 const bool GECKO_IS_NIGHTLY = true;
 #else
 const bool GECKO_IS_NIGHTLY = false;
 #endif
 
 #define NS_DECL_THREADSAFE_FFI_REFCOUNTING(class_, name_)                     \
@@ -85,121 +56,118 @@ const bool GECKO_IS_NIGHTLY = false;
   static_assert(class_::HasThreadSafeRefCnt::value,                           \
                 "NS_DECL_THREADSAFE_FFI_REFCOUNTING can only be used with "   \
                 "classes that have thread-safe refcounting");                 \
   void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr)                     \
   { NS_ADDREF(aPtr); }                                                        \
   void Gecko_Release##name_##ArbitraryThread(class_* aPtr)                    \
   { NS_RELEASE(aPtr); }
 
-#define NS_DECL_FFI_REFCOUNTING(class_, name_)  \
-  void Gecko_##name_##_AddRef(class_* aPtr);    \
-  void Gecko_##name_##_Release(class_* aPtr);
-#define NS_IMPL_FFI_REFCOUNTING(class_, name_)                    \
-  void Gecko_##name_##_AddRef(class_* aPtr)                       \
-    { MOZ_ASSERT(NS_IsMainThread()); NS_ADDREF(aPtr); }           \
-  void Gecko_##name_##_Release(class_* aPtr)                      \
-    { MOZ_ASSERT(NS_IsMainThread()); NS_RELEASE(aPtr); }
-
-#define DEFINE_ARRAY_TYPE_FOR(type_)                                \
-  struct nsTArrayBorrowed_##type_ {                                 \
-    nsTArray<type_>* mArray;                                        \
-    MOZ_IMPLICIT nsTArrayBorrowed_##type_(nsTArray<type_>* aArray)  \
-      : mArray(aArray) {}                                           \
-  }
-DEFINE_ARRAY_TYPE_FOR(uintptr_t);
-#undef DEFINE_ARRAY_TYPE_FOR
-
-extern "C" {
-
 class ServoBundledURI
 {
 public:
   // NOTE(emilio): Not calling IntoCssUrl will cause to leak the
   // string, so don't do that :)
   already_AddRefed<mozilla::css::URLValue> IntoCssUrl(mozilla::CORSMode);
   mozilla::ServoRawOffsetArc<RustString> mURLString;
   mozilla::URLExtraData* mExtraData;
 };
 
-struct FontSizePrefs
-{
-  void CopyFrom(const mozilla::LangGroupFontPrefs&);
-  nscoord mDefaultVariableSize;
-  nscoord mDefaultFixedSize;
-  nscoord mDefaultSerifSize;
-  nscoord mDefaultSansSerifSize;
-  nscoord mDefaultMonospaceSize;
-  nscoord mDefaultCursiveSize;
-  nscoord mDefaultFantasySize;
-};
-
-struct MediumFeaturesChangedResult {
-  bool mAffectsDocumentRules;
-  bool mAffectsNonDocumentRules;
-  bool mUsesViewportUnits;
-};
+extern "C" {
 
 // Debugging stuff.
 void Gecko_Element_DebugListAttributes(RawGeckoElementBorrowed, nsCString*);
-void Gecko_Snapshot_DebugListAttributes(const ServoElementSnapshot*, nsCString*);
+
+void Gecko_Snapshot_DebugListAttributes(
+  const mozilla::ServoElementSnapshot*,
+  nsCString*);
 
-bool Gecko_IsSignificantChild(RawGeckoNodeBorrowed node, bool whitespace_is_significant);
+bool Gecko_IsSignificantChild(
+  RawGeckoNodeBorrowed node,
+  bool whitespace_is_significant);
+
 RawGeckoNodeBorrowedOrNull Gecko_GetLastChild(RawGeckoNodeBorrowed node);
 RawGeckoNodeBorrowedOrNull Gecko_GetPreviousSibling(RawGeckoNodeBorrowed node);
-RawGeckoNodeBorrowedOrNull Gecko_GetFlattenedTreeParentNode(RawGeckoNodeBorrowed node);
-RawGeckoElementBorrowedOrNull Gecko_GetBeforeOrAfterPseudo(RawGeckoElementBorrowed element, bool is_before);
-nsTArray<nsIContent*>* Gecko_GetAnonymousContentForElement(RawGeckoElementBorrowed element);
-const nsTArray<RefPtr<nsINode>>* Gecko_GetAssignedNodes(RawGeckoElementBorrowed element);
+
+RawGeckoNodeBorrowedOrNull Gecko_GetFlattenedTreeParentNode(
+  RawGeckoNodeBorrowed node);
+
+RawGeckoElementBorrowedOrNull Gecko_GetBeforeOrAfterPseudo(
+  RawGeckoElementBorrowed element,
+  bool is_before);
+
+nsTArray<nsIContent*>* Gecko_GetAnonymousContentForElement(
+  RawGeckoElementBorrowed element);
+
+const nsTArray<RefPtr<nsINode>>* Gecko_GetAssignedNodes(
+  RawGeckoElementBorrowed element);
+
 void Gecko_DestroyAnonymousContentList(nsTArray<nsIContent*>* anon_content);
 
-void Gecko_ComputedStyle_Init(mozilla::ComputedStyle* context,
-                              RawGeckoPresContextBorrowed pres_context,
-                              ServoComputedDataBorrowed values,
-                              mozilla::CSSPseudoElementType pseudo_type,
-                              nsAtom* pseudo_tag);
-void Gecko_ComputedStyle_Destroy(mozilla::ComputedStyle* context);
+void Gecko_ComputedStyle_Init(
+  mozilla::ComputedStyle* context,
+  RawGeckoPresContextBorrowed pres_context,
+  ServoComputedDataBorrowed values,
+  mozilla::CSSPseudoElementType pseudo_type,
+  nsAtom* pseudo_tag);
+
+void Gecko_ComputedStyle_Destroy(
+  mozilla::ComputedStyle* context);
 
 // By default, Servo walks the DOM by traversing the siblings of the DOM-view
 // first child. This generally works, but misses anonymous children, which we
 // want to traverse during styling. To support these cases, we create an
 // optional stack-allocated iterator in aIterator for nodes that need it.
-void Gecko_ConstructStyleChildrenIterator(RawGeckoElementBorrowed aElement,
-                                          RawGeckoStyleChildrenIteratorBorrowedMut aIterator);
-void Gecko_DestroyStyleChildrenIterator(RawGeckoStyleChildrenIteratorBorrowedMut aIterator);
-RawGeckoNodeBorrowedOrNull Gecko_GetNextStyleChild(RawGeckoStyleChildrenIteratorBorrowedMut it);
+void Gecko_ConstructStyleChildrenIterator(
+  RawGeckoElementBorrowed aElement,
+  RawGeckoStyleChildrenIteratorBorrowedMut aIterator);
 
-NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::SheetLoadDataHolder, SheetLoadDataHolder);
+void Gecko_DestroyStyleChildrenIterator(
+  RawGeckoStyleChildrenIteratorBorrowedMut aIterator);
 
-void Gecko_StyleSheet_FinishAsyncParse(mozilla::css::SheetLoadDataHolder* data,
-                                       RawServoStyleSheetContentsStrong sheet_contents,
-                                       StyleUseCountersOwnedOrNull use_counters);
+RawGeckoNodeBorrowedOrNull Gecko_GetNextStyleChild(
+  RawGeckoStyleChildrenIteratorBorrowedMut it);
+
+NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::SheetLoadDataHolder,
+                                   SheetLoadDataHolder);
 
-mozilla::StyleSheet*
-Gecko_LoadStyleSheet(mozilla::css::Loader* loader,
-                     mozilla::StyleSheet* parent,
-                     mozilla::css::SheetLoadData* parent_load_data,
-                     mozilla::css::LoaderReusableStyleSheets* reusable_sheets,
-                     ServoBundledURI url,
-                     RawServoMediaListStrong media_list);
+void Gecko_StyleSheet_FinishAsyncParse(
+  mozilla::css::SheetLoadDataHolder* data,
+  RawServoStyleSheetContentsStrong sheet_contents,
+  StyleUseCountersOwnedOrNull use_counters);
 
-void
-Gecko_LoadStyleSheetAsync(mozilla::css::SheetLoadDataHolder* parent_data,
-                          ServoBundledURI url,
-                          RawServoMediaListStrong media_list,
-                          RawServoImportRuleStrong import_rule);
+mozilla::StyleSheet* Gecko_LoadStyleSheet(
+  mozilla::css::Loader* loader,
+  mozilla::StyleSheet* parent,
+  mozilla::css::SheetLoadData* parent_load_data,
+  mozilla::css::LoaderReusableStyleSheets* reusable_sheets,
+  ServoBundledURI url,
+  RawServoMediaListStrong media_list);
+
+void Gecko_LoadStyleSheetAsync(
+  mozilla::css::SheetLoadDataHolder* parent_data,
+  ServoBundledURI url,
+  RawServoMediaListStrong media_list,
+  RawServoImportRuleStrong import_rule);
 
 // Selector Matching.
 uint64_t Gecko_ElementState(RawGeckoElementBorrowed element);
 bool Gecko_IsRootElement(RawGeckoElementBorrowed element);
-bool Gecko_MatchLang(RawGeckoElementBorrowed element,
-                     nsAtom* override_lang, bool has_override_lang,
-                     const char16_t* value);
+
+bool Gecko_MatchLang(
+  RawGeckoElementBorrowed element,
+  nsAtom* override_lang,
+  bool has_override_lang,
+  const char16_t* value);
+
 nsAtom* Gecko_GetXMLLangValue(RawGeckoElementBorrowed element);
-nsIDocument::DocumentTheme Gecko_GetDocumentLWTheme(const nsIDocument* aDocument);
+
+nsIDocument::DocumentTheme Gecko_GetDocumentLWTheme(
+  const nsIDocument* aDocument);
+
 bool Gecko_IsTableBorderNonzero(RawGeckoElementBorrowed element);
 bool Gecko_IsBrowserFrame(RawGeckoElementBorrowed element);
 
 // Attributes.
 #define SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(prefix_, implementor_)  \
   nsAtom* prefix_##LangValue(implementor_ element);                           \
   bool prefix_##HasAttr(implementor_ element, nsAtom* ns, nsAtom* name);      \
   bool prefix_##AttrEquals(implementor_ element, nsAtom* ns, nsAtom* name,    \
@@ -214,257 +182,364 @@ bool Gecko_IsBrowserFrame(RawGeckoElemen
   bool prefix_##AttrHasPrefix(implementor_ element, nsAtom* ns,               \
                               nsAtom* name, nsAtom* str, bool ignore_case);   \
   bool prefix_##AttrHasSuffix(implementor_ element, nsAtom* ns,               \
                               nsAtom* name, nsAtom* str, bool ignore_case);
 
 bool Gecko_AssertClassAttrValueIsSane(const nsAttrValue*);
 const nsAttrValue* Gecko_GetSVGAnimatedClass(RawGeckoElementBorrowed);
 
+SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_, RawGeckoElementBorrowed)
 
-SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_, RawGeckoElementBorrowed)
-SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_Snapshot,
-                                              const ServoElementSnapshot*)
+SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(
+  Gecko_Snapshot,
+  const mozilla::ServoElementSnapshot*)
 
 #undef SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS
 
 // Style attributes.
-RawServoDeclarationBlockStrongBorrowedOrNull
-Gecko_GetStyleAttrDeclarationBlock(RawGeckoElementBorrowed element);
+RawServoDeclarationBlockStrongBorrowedOrNull Gecko_GetStyleAttrDeclarationBlock(
+  RawGeckoElementBorrowed element);
+
 void Gecko_UnsetDirtyStyleAttr(RawGeckoElementBorrowed element);
+
 RawServoDeclarationBlockStrongBorrowedOrNull
 Gecko_GetHTMLPresentationAttrDeclarationBlock(RawGeckoElementBorrowed element);
+
 RawServoDeclarationBlockStrongBorrowedOrNull
 Gecko_GetExtraContentStyleDeclarations(RawGeckoElementBorrowed element);
+
 RawServoDeclarationBlockStrongBorrowedOrNull
 Gecko_GetUnvisitedLinkAttrDeclarationBlock(RawGeckoElementBorrowed element);
+
 RawServoDeclarationBlockStrongBorrowedOrNull
 Gecko_GetVisitedLinkAttrDeclarationBlock(RawGeckoElementBorrowed element);
+
 RawServoDeclarationBlockStrongBorrowedOrNull
 Gecko_GetActiveLinkAttrDeclarationBlock(RawGeckoElementBorrowed element);
 
 // Visited handling.
 
 // Returns whether visited styles are enabled for a given document.
 bool Gecko_VisitedStylesEnabled(const nsIDocument*);
 
 // Animations
-bool
-Gecko_GetAnimationRule(RawGeckoElementBorrowed aElementOrPseudo,
-                       mozilla::EffectCompositor::CascadeLevel aCascadeLevel,
-                       RawServoAnimationValueMapBorrowedMut aAnimationValues);
-bool Gecko_StyleAnimationsEquals(RawGeckoStyleAnimationListBorrowed,
-                                 RawGeckoStyleAnimationListBorrowed);
-void Gecko_CopyAnimationNames(RawGeckoStyleAnimationListBorrowedMut aDest,
-                              RawGeckoStyleAnimationListBorrowed aSrc);
+bool Gecko_GetAnimationRule(
+  RawGeckoElementBorrowed aElementOrPseudo,
+  mozilla::EffectCompositor::CascadeLevel aCascadeLevel,
+  RawServoAnimationValueMapBorrowedMut aAnimationValues);
+
+bool Gecko_StyleAnimationsEquals(
+  RawGeckoStyleAnimationListBorrowed,
+  RawGeckoStyleAnimationListBorrowed);
+
+void Gecko_CopyAnimationNames(
+  RawGeckoStyleAnimationListBorrowedMut aDest,
+  RawGeckoStyleAnimationListBorrowed aSrc);
+
 // This function takes an already addrefed nsAtom
-void Gecko_SetAnimationName(mozilla::StyleAnimation* aStyleAnimation,
-                            nsAtom* aAtom);
-void Gecko_UpdateAnimations(RawGeckoElementBorrowed aElementOrPseudo,
-                            ComputedStyleBorrowedOrNull aOldComputedValues,
-                            ComputedStyleBorrowedOrNull aComputedValues,
-                            mozilla::UpdateAnimationsTasks aTasks);
+void Gecko_SetAnimationName(
+  mozilla::StyleAnimation* aStyleAnimation,
+  nsAtom* aAtom);
+
+void Gecko_UpdateAnimations(
+  RawGeckoElementBorrowed aElementOrPseudo,
+  ComputedStyleBorrowedOrNull aOldComputedValues,
+  ComputedStyleBorrowedOrNull aComputedValues,
+  mozilla::UpdateAnimationsTasks aTasks);
+
 size_t Gecko_GetAnimationEffectCount(RawGeckoElementBorrowed aElementOrPseudo);
 bool Gecko_ElementHasAnimations(RawGeckoElementBorrowed aElementOrPseudo);
 bool Gecko_ElementHasCSSAnimations(RawGeckoElementBorrowed aElementOrPseudo);
 bool Gecko_ElementHasCSSTransitions(RawGeckoElementBorrowed aElementOrPseudo);
 size_t Gecko_ElementTransitions_Length(RawGeckoElementBorrowed aElementOrPseudo);
+
 nsCSSPropertyID Gecko_ElementTransitions_PropertyAt(
   RawGeckoElementBorrowed aElementOrPseudo,
   size_t aIndex);
+
 RawServoAnimationValueBorrowedOrNull Gecko_ElementTransitions_EndValueAt(
   RawGeckoElementBorrowed aElementOrPseudo,
   size_t aIndex);
-double Gecko_GetProgressFromComputedTiming(RawGeckoComputedTimingBorrowed aComputedTiming);
+
+double Gecko_GetProgressFromComputedTiming(
+  RawGeckoComputedTimingBorrowed aComputedTiming);
+
 double Gecko_GetPositionInSegment(
   RawGeckoAnimationPropertySegmentBorrowed aSegment,
   double aProgress,
   mozilla::ComputedTimingFunction::BeforeFlag aBeforeFlag);
+
 // Get servo's AnimationValue for |aProperty| from the cached base style
 // |aBaseStyles|.
 // |aBaseStyles| is nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>.
-// We use RawServoAnimationValueTableBorrowed to avoid exposing nsRefPtrHashtable in FFI.
+// We use RawServoAnimationValueTableBorrowed to avoid exposing
+// nsRefPtrHashtable in FFI.
 RawServoAnimationValueBorrowedOrNull Gecko_AnimationGetBaseStyle(
   RawServoAnimationValueTableBorrowed aBaseStyles,
   nsCSSPropertyID aProperty);
+
 void Gecko_StyleTransition_SetUnsupportedProperty(
   mozilla::StyleTransition* aTransition,
   nsAtom* aAtom);
 
 // Atoms.
 nsAtom* Gecko_Atomize(const char* aString, uint32_t aLength);
 nsAtom* Gecko_Atomize16(const nsAString* aString);
 void Gecko_AddRefAtom(nsAtom* aAtom);
 void Gecko_ReleaseAtom(nsAtom* aAtom);
 
 // Font style
 void Gecko_CopyFontFamilyFrom(nsFont* dst, const nsFont* src);
-void Gecko_nsTArray_FontFamilyName_AppendNamed(nsTArray<FontFamilyName>* aNames, nsAtom* aName, bool aQuoted);
-void Gecko_nsTArray_FontFamilyName_AppendGeneric(nsTArray<FontFamilyName>* aNames, FontFamilyType aType);
+
+void Gecko_nsTArray_FontFamilyName_AppendNamed(
+  nsTArray<mozilla::FontFamilyName>* aNames,
+  nsAtom* aName,
+  bool aQuoted);
+
+void Gecko_nsTArray_FontFamilyName_AppendGeneric(
+  nsTArray<mozilla::FontFamilyName>* aNames,
+  mozilla::FontFamilyType aType);
+
 // Returns an already-AddRefed SharedFontList with an empty mNames array.
-SharedFontList* Gecko_SharedFontList_Create();
-size_t Gecko_SharedFontList_SizeOfIncludingThis(SharedFontList* fontlist);
-size_t Gecko_SharedFontList_SizeOfIncludingThisIfUnshared(SharedFontList* fontlist);
-NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::SharedFontList, SharedFontList);
+mozilla::SharedFontList* Gecko_SharedFontList_Create();
+
+size_t Gecko_SharedFontList_SizeOfIncludingThis(
+  mozilla::SharedFontList* fontlist);
+
+size_t Gecko_SharedFontList_SizeOfIncludingThisIfUnshared(
+  mozilla::SharedFontList* fontlist);
+
+NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::SharedFontList,
+                                   SharedFontList);
+
 // will not run destructors on dst, give it uninitialized memory
 // font_id is LookAndFeel::FontID
-void Gecko_nsFont_InitSystem(nsFont* dst, int32_t font_id,
-                             const nsStyleFont* font, RawGeckoPresContextBorrowed pres_context);
+void Gecko_nsFont_InitSystem(
+  nsFont* dst,
+  int32_t font_id,
+  const nsStyleFont* font,
+  RawGeckoPresContextBorrowed pres_context);
+
 void Gecko_nsFont_Destroy(nsFont* dst);
 
 // The gfxFontFeatureValueSet returned from this function has zero reference.
 gfxFontFeatureValueSet* Gecko_ConstructFontFeatureValueSet();
+
 nsTArray<unsigned int>* Gecko_AppendFeatureValueHashEntry(
-  gfxFontFeatureValueSet* value_set, nsAtom* family, uint32_t alternate, nsAtom* name);
-void Gecko_nsFont_SetFontFeatureValuesLookup(nsFont* font,
-                                             const RawGeckoPresContext* pres_context);
+  gfxFontFeatureValueSet* value_set,
+  nsAtom* family,
+  uint32_t alternate,
+  nsAtom* name);
+
+void Gecko_nsFont_SetFontFeatureValuesLookup(
+  nsFont* font,
+  const RawGeckoPresContext* pres_context);
+
 void Gecko_nsFont_ResetFontFeatureValuesLookup(nsFont* font);
 
 // Font variant alternates
 void Gecko_ClearAlternateValues(nsFont* font, size_t length);
-void Gecko_AppendAlternateValues(nsFont* font, uint32_t alternate_name, nsAtom* atom);
+
+void Gecko_AppendAlternateValues(
+  nsFont* font,
+  uint32_t alternate_name,
+  nsAtom* atom);
+
 void Gecko_CopyAlternateValuesFrom(nsFont* dest, const nsFont* src);
 
 // Visibility style
-void Gecko_SetImageOrientation(nsStyleVisibility* aVisibility,
-                               uint8_t aOrientation,
-                               bool aFlip);
-void Gecko_SetImageOrientationAsFromImage(nsStyleVisibility* aVisibility);
-void Gecko_CopyImageOrientationFrom(nsStyleVisibility* aDst,
-                                    const nsStyleVisibility* aSrc);
+void Gecko_SetImageOrientation(
+  nsStyleVisibility* aVisibility,
+  uint8_t aOrientation,
+  bool aFlip);
+
+void Gecko_SetImageOrientationAsFromImage(
+  nsStyleVisibility* aVisibility);
+
+void Gecko_CopyImageOrientationFrom(
+  nsStyleVisibility* aDst,
+  const nsStyleVisibility* aSrc);
 
 // Counter style.
 // This function takes an already addrefed nsAtom
-void Gecko_SetCounterStyleToName(mozilla::CounterStylePtr* ptr, nsAtom* name,
-                                 RawGeckoPresContextBorrowed pres_context);
-void Gecko_SetCounterStyleToSymbols(mozilla::CounterStylePtr* ptr,
-                                    uint8_t symbols_type,
-                                    nsACString const* const* symbols,
-                                    uint32_t symbols_count);
-void Gecko_SetCounterStyleToString(mozilla::CounterStylePtr* ptr,
-                                   const nsACString* symbol);
-void Gecko_CopyCounterStyle(mozilla::CounterStylePtr* dst,
-                            const mozilla::CounterStylePtr* src);
+void Gecko_SetCounterStyleToName(
+  mozilla::CounterStylePtr* ptr,
+  nsAtom* name,
+  RawGeckoPresContextBorrowed pres_context);
+
+void Gecko_SetCounterStyleToSymbols(
+  mozilla::CounterStylePtr* ptr,
+  uint8_t symbols_type,
+  nsACString const* const* symbols,
+  uint32_t symbols_count);
+
+void Gecko_SetCounterStyleToString(
+  mozilla::CounterStylePtr* ptr,
+  const nsACString* symbol);
+
+void Gecko_CopyCounterStyle(
+  mozilla::CounterStylePtr* dst,
+  const mozilla::CounterStylePtr* src);
+
 nsAtom* Gecko_CounterStyle_GetName(const mozilla::CounterStylePtr* ptr);
-const mozilla::AnonymousCounterStyle*
-Gecko_CounterStyle_GetAnonymous(const mozilla::CounterStylePtr* ptr);
+
+const mozilla::AnonymousCounterStyle* Gecko_CounterStyle_GetAnonymous(
+  const mozilla::CounterStylePtr* ptr);
 
 // background-image style.
 void Gecko_SetNullImageValue(nsStyleImage* image);
 void Gecko_SetGradientImageValue(nsStyleImage* image, nsStyleGradient* gradient);
-void Gecko_SetLayerImageImageValue(nsStyleImage* image,
-                                   mozilla::css::URLValue* image_value);
+
+void Gecko_SetLayerImageImageValue(
+  nsStyleImage* image,
+  mozilla::css::URLValue* image_value);
 
 void Gecko_SetImageElement(nsStyleImage* image, nsAtom* atom);
 void Gecko_CopyImageValueFrom(nsStyleImage* image, const nsStyleImage* other);
 void Gecko_InitializeImageCropRect(nsStyleImage* image);
 
-nsStyleGradient* Gecko_CreateGradient(uint8_t shape,
-                                      uint8_t size,
-                                      bool repeating,
-                                      bool legacy_syntax,
-                                      bool moz_legacy_syntax,
-                                      uint32_t stops);
+nsStyleGradient* Gecko_CreateGradient(
+  uint8_t shape,
+  uint8_t size,
+  bool repeating,
+  bool legacy_syntax,
+  bool moz_legacy_syntax,
+  uint32_t stops);
 
 const nsStyleImageRequest* Gecko_GetImageRequest(const nsStyleImage* image);
 nsAtom* Gecko_GetImageElement(const nsStyleImage* image);
 const nsStyleGradient* Gecko_GetGradientImageValue(const nsStyleImage* image);
 
 // list-style-image style.
 void Gecko_SetListStyleImageNone(nsStyleList* style_struct);
-void Gecko_SetListStyleImageImageValue(nsStyleList* style_struct,
-                                  mozilla::css::URLValue* aImageValue);
+
+void Gecko_SetListStyleImageImageValue(
+  nsStyleList* style_struct,
+  mozilla::css::URLValue* aImageValue);
+
 void Gecko_CopyListStyleImageFrom(nsStyleList* dest, const nsStyleList* src);
 
 // cursor style.
 void Gecko_SetCursorArrayLength(nsStyleUI* ui, size_t len);
-void Gecko_SetCursorImageValue(nsCursorImage* aCursor,
-                               mozilla::css::URLValue* aImageValue);
+
+void Gecko_SetCursorImageValue(
+  nsCursorImage* aCursor,
+  mozilla::css::URLValue* aImageValue);
+
 void Gecko_CopyCursorArrayFrom(nsStyleUI* dest, const nsStyleUI* src);
 
-void Gecko_SetContentDataImageValue(nsStyleContentData* aList,
-                                    mozilla::css::URLValue* aImageValue);
+void Gecko_SetContentDataImageValue(
+  nsStyleContentData* aList,
+  mozilla::css::URLValue* aImageValue);
+
 nsStyleContentData::CounterFunction* Gecko_SetCounterFunction(
-    nsStyleContentData* content_data, mozilla::StyleContentType);
+  nsStyleContentData* content_data,
+  mozilla::StyleContentType);
 
 // Dirtiness tracking.
 void Gecko_SetNodeFlags(RawGeckoNodeBorrowed node, uint32_t flags);
 void Gecko_UnsetNodeFlags(RawGeckoNodeBorrowed node, uint32_t flags);
 void Gecko_NoteDirtyElement(RawGeckoElementBorrowed element);
 void Gecko_NoteDirtySubtreeForInvalidation(RawGeckoElementBorrowed element);
 void Gecko_NoteAnimationOnlyDirtyElement(RawGeckoElementBorrowed element);
 
 bool Gecko_AnimationNameMayBeReferencedFromStyle(
   RawGeckoPresContextBorrowed pres_context,
   nsAtom* name);
 
 // Incremental restyle.
-mozilla::CSSPseudoElementType Gecko_GetImplementedPseudo(RawGeckoElementBorrowed element);
+mozilla::CSSPseudoElementType Gecko_GetImplementedPseudo(
+  RawGeckoElementBorrowed element);
+
 // We'd like to return `nsChangeHint` here, but bindgen bitfield enums don't
 // work as return values with the Linux 32-bit ABI at the moment because
 // they wrap the value in a struct.
-uint32_t Gecko_CalcStyleDifference(ComputedStyleBorrowed old_style,
-                                   ComputedStyleBorrowed new_style,
-                                   bool* any_style_struct_changed,
-                                   bool* reset_only_changed);
+uint32_t Gecko_CalcStyleDifference(
+  ComputedStyleBorrowed old_style,
+  ComputedStyleBorrowed new_style,
+  bool* any_style_struct_changed,
+  bool* reset_only_changed);
 
 // Get an element snapshot for a given element from the table.
-const ServoElementSnapshot*
-Gecko_GetElementSnapshot(const mozilla::ServoElementSnapshotTable* table,
-                         RawGeckoElementBorrowed element);
+const ServoElementSnapshot* Gecko_GetElementSnapshot(
+  const mozilla::ServoElementSnapshotTable* table,
+  RawGeckoElementBorrowed element);
 
 // Have we seen this pointer before?
-bool
-Gecko_HaveSeenPtr(mozilla::SeenPtrs* table, const void* ptr);
+bool Gecko_HaveSeenPtr(
+  mozilla::SeenPtrs* table,
+  const void* ptr);
 
 // `array` must be an nsTArray
 // If changing this signature, please update the
 // friend function declaration in nsTArray.h
 void Gecko_EnsureTArrayCapacity(void* array, size_t capacity, size_t elem_size);
 
 // Same here, `array` must be an nsTArray<T>, for some T.
 //
 // Important note: Only valid for POD types, since destructors won't be run
 // otherwise. This is ensured with rust traits for the relevant structs.
 void Gecko_ClearPODTArray(void* array, size_t elem_size, size_t elem_align);
 
 void Gecko_ResizeTArrayForStrings(nsTArray<nsString>* array, uint32_t length);
 
-void Gecko_SetStyleGridTemplate(mozilla::UniquePtr<nsStyleGridTemplate>* grid_template,
-                                nsStyleGridTemplate* value);
+void Gecko_SetStyleGridTemplate(
+  mozilla::UniquePtr<nsStyleGridTemplate>* grid_template,
+  nsStyleGridTemplate* value);
 
-nsStyleGridTemplate* Gecko_CreateStyleGridTemplate(uint32_t track_sizes,
-                                                   uint32_t name_size);
+nsStyleGridTemplate* Gecko_CreateStyleGridTemplate(
+  uint32_t track_sizes,
+  uint32_t name_size);
 
-void Gecko_CopyStyleGridTemplateValues(mozilla::UniquePtr<nsStyleGridTemplate>* grid_template,
-                                       const nsStyleGridTemplate* other);
+void Gecko_CopyStyleGridTemplateValues(
+  mozilla::UniquePtr<nsStyleGridTemplate>* grid_template,
+  const nsStyleGridTemplate* other);
 
-mozilla::css::GridTemplateAreasValue* Gecko_NewGridTemplateAreasValue(uint32_t areas,
-                                                                      uint32_t templates,
-                                                                      uint32_t columns);
-NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::GridTemplateAreasValue, GridTemplateAreasValue);
+mozilla::css::GridTemplateAreasValue* Gecko_NewGridTemplateAreasValue(
+  uint32_t areas,
+  uint32_t templates,
+  uint32_t columns);
+
+NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::GridTemplateAreasValue,
+                                   GridTemplateAreasValue);
 
-// Clear the mContents, mCounterIncrements, or mCounterResets field in nsStyleContent. This is
-// needed to run the destructors, otherwise we'd leak the images, strings, and whatnot.
-void Gecko_ClearAndResizeStyleContents(nsStyleContent* content,
-                                       uint32_t how_many);
-void Gecko_ClearAndResizeCounterIncrements(nsStyleContent* content,
-                                           uint32_t how_many);
-void Gecko_ClearAndResizeCounterResets(nsStyleContent* content,
-                                       uint32_t how_many);
-void Gecko_CopyStyleContentsFrom(nsStyleContent* content, const nsStyleContent* other);
-void Gecko_CopyCounterResetsFrom(nsStyleContent* content, const nsStyleContent* other);
-void Gecko_CopyCounterIncrementsFrom(nsStyleContent* content, const nsStyleContent* other);
+// Clear the mContents, mCounterIncrements, or mCounterResets field in
+// nsStyleContent. This is needed to run the destructors, otherwise we'd
+// leak the images, strings, and whatnot.
+void Gecko_ClearAndResizeStyleContents( nsStyleContent* content,
+  uint32_t how_many);
+
+void Gecko_ClearAndResizeCounterIncrements(
+  nsStyleContent* content,
+  uint32_t how_many);
+
+void Gecko_ClearAndResizeCounterResets(
+  nsStyleContent* content,
+  uint32_t how_many);
 
-void Gecko_EnsureImageLayersLength(nsStyleImageLayers* layers, size_t len,
-                                   nsStyleImageLayers::LayerType layer_type);
+void Gecko_CopyStyleContentsFrom(
+  nsStyleContent* content,
+  const nsStyleContent* other);
+
+void Gecko_CopyCounterResetsFrom(
+  nsStyleContent* content,
+  const nsStyleContent* other);
+
+void Gecko_CopyCounterIncrementsFrom(
+  nsStyleContent* content,
+  const nsStyleContent* other);
+
+void Gecko_EnsureImageLayersLength(
+  nsStyleImageLayers* layers,
+  size_t len,
+  nsStyleImageLayers::LayerType layer_type);
 
 void Gecko_EnsureStyleAnimationArrayLength(void* array, size_t len);
 void Gecko_EnsureStyleTransitionArrayLength(void* array, size_t len);
-
 void Gecko_ClearWillChange(nsStyleDisplay* display, size_t length);
 void Gecko_AppendWillChange(nsStyleDisplay* display, nsAtom* atom);
 void Gecko_CopyWillChangeFrom(nsStyleDisplay* dest, nsStyleDisplay* src);
 
 // Searches from the beginning of |keyframes| for a Keyframe object with the
 // specified offset and timing function. If none is found, a new Keyframe object
 // with the specified |offset| and |timingFunction| will be prepended to
 // |keyframes|.
@@ -504,253 +579,383 @@ mozilla::Keyframe* Gecko_GetOrCreateFina
 // Appends and returns a new PropertyValuePair to |aProperties| initialized with
 // its mProperty member set to |aProperty| and all other members initialized to
 // their default values.
 mozilla::PropertyValuePair* Gecko_AppendPropertyValuePair(
   RawGeckoPropertyValuePairListBorrowedMut aProperties,
   nsCSSPropertyID aProperty);
 
 // Clean up pointer-based coordinates
-void Gecko_ResetStyleCoord(nsStyleUnit* unit, nsStyleUnion* value);
+void Gecko_ResetStyleCoord(
+  nsStyleUnit* unit,
+  nsStyleUnion* value);
 
 // Set an nsStyleCoord to a computed `calc()` value
-void Gecko_SetStyleCoordCalcValue(nsStyleUnit* unit, nsStyleUnion* value, nsStyleCoord::CalcValue calc);
+void Gecko_SetStyleCoordCalcValue(
+  nsStyleUnit* unit,
+  nsStyleUnion* value,
+  nsStyleCoord::CalcValue calc);
 
-void Gecko_CopyShapeSourceFrom(mozilla::StyleShapeSource* dst, const mozilla::StyleShapeSource* src);
+void Gecko_CopyShapeSourceFrom(
+  mozilla::StyleShapeSource* dst,
+  const mozilla::StyleShapeSource* src);
 
 void Gecko_DestroyShapeSource(mozilla::StyleShapeSource* shape);
-void Gecko_NewBasicShape(mozilla::StyleShapeSource* shape,
-                         mozilla::StyleBasicShapeType type);
+
+void Gecko_NewBasicShape(
+  mozilla::StyleShapeSource* shape,
+  mozilla::StyleBasicShapeType type);
+
 void Gecko_NewShapeImage(mozilla::StyleShapeSource* shape);
-void Gecko_StyleShapeSource_SetURLValue(mozilla::StyleShapeSource* shape, mozilla::css::URLValue* uri);
+
+void Gecko_StyleShapeSource_SetURLValue(
+  mozilla::StyleShapeSource* shape,
+  mozilla::css::URLValue* uri);
+
 void Gecko_NewStyleSVGPath(mozilla::StyleShapeSource* shape);
-void Gecko_SetStyleMotion(mozilla::UniquePtr<mozilla::StyleMotion>* aMotion,
-                          mozilla::StyleMotion* aValue);
+
+void Gecko_SetStyleMotion(
+  mozilla::UniquePtr<mozilla::StyleMotion>* aMotion,
+  mozilla::StyleMotion* aValue);
+
 mozilla::StyleMotion* Gecko_NewStyleMotion();
-void Gecko_CopyStyleMotions(mozilla::UniquePtr<mozilla::StyleMotion>* motion,
-                            const mozilla::StyleMotion* other);
+
+void Gecko_CopyStyleMotions(
+  mozilla::UniquePtr<mozilla::StyleMotion>* motion,
+  const mozilla::StyleMotion* other);
 
 void Gecko_ResetFilters(nsStyleEffects* effects, size_t new_len);
+
 void Gecko_CopyFiltersFrom(nsStyleEffects* aSrc, nsStyleEffects* aDest);
-void Gecko_nsStyleFilter_SetURLValue(nsStyleFilter* effects, mozilla::css::URLValue* uri);
+
+void Gecko_nsStyleFilter_SetURLValue(
+  nsStyleFilter* effects,
+  mozilla::css::URLValue* uri);
 
-void Gecko_nsStyleSVGPaint_CopyFrom(nsStyleSVGPaint* dest, const nsStyleSVGPaint* src);
-void Gecko_nsStyleSVGPaint_SetURLValue(nsStyleSVGPaint* paint, mozilla::css::URLValue* uri);
+void Gecko_nsStyleSVGPaint_CopyFrom(
+  nsStyleSVGPaint* dest,
+  const nsStyleSVGPaint* src);
+
+void Gecko_nsStyleSVGPaint_SetURLValue(
+  nsStyleSVGPaint* paint,
+  mozilla::css::URLValue* uri);
+
 void Gecko_nsStyleSVGPaint_Reset(nsStyleSVGPaint* paint);
 
 void Gecko_nsStyleSVG_SetDashArrayLength(nsStyleSVG* svg, uint32_t len);
+
 void Gecko_nsStyleSVG_CopyDashArray(nsStyleSVG* dst, const nsStyleSVG* src);
+
 void Gecko_nsStyleSVG_SetContextPropertiesLength(nsStyleSVG* svg, uint32_t len);
-void Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG* dst, const nsStyleSVG* src);
+
+void Gecko_nsStyleSVG_CopyContextProperties(
+  nsStyleSVG* dst,
+  const nsStyleSVG* src);
 
-mozilla::css::URLValue* Gecko_URLValue_Create(ServoBundledURI uri, mozilla::CORSMode aCORSMode);
+mozilla::css::URLValue* Gecko_URLValue_Create(
+  ServoBundledURI uri,
+  mozilla::CORSMode aCORSMode);
+
 size_t Gecko_URLValue_SizeOfIncludingThis(mozilla::css::URLValue* url);
-void Gecko_GetComputedURLSpec(const mozilla::css::URLValue* url, nsCString* spec);
-void Gecko_GetComputedImageURLSpec(const mozilla::css::URLValue* url, nsCString* spec);
+
+void Gecko_GetComputedURLSpec(
+  const mozilla::css::URLValue* url,
+  nsCString* spec);
+
+void Gecko_GetComputedImageURLSpec(
+  const mozilla::css::URLValue* url,
+  nsCString* spec);
+
 void Gecko_nsIURI_Debug(nsIURI*, nsCString* spec);
 
 NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::URLValue, CSSURLValue);
 NS_DECL_THREADSAFE_FFI_REFCOUNTING(RawGeckoURLExtraData, URLExtraData);
 
 void Gecko_FillAllImageLayers(nsStyleImageLayers* layers, uint32_t max_len);
+
 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsStyleCoord::Calc, Calc);
 
 nsCSSShadowArray* Gecko_NewCSSShadowArray(uint32_t len);
+
 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsCSSShadowArray, CSSShadowArray);
 
 nsStyleQuoteValues* Gecko_NewStyleQuoteValues(uint32_t len);
+
 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsStyleQuoteValues, QuoteValues);
 
 nsCSSValueSharedList* Gecko_NewCSSValueSharedList(uint32_t len);
 nsCSSValueSharedList* Gecko_NewNoneTransform();
 
 // Getter for nsCSSValue
-nsCSSValueBorrowedMut Gecko_CSSValue_GetArrayItem(nsCSSValueBorrowedMut css_value, int32_t index);
+nsCSSValueBorrowedMut Gecko_CSSValue_GetArrayItem(
+  nsCSSValueBorrowedMut css_value,
+  int32_t index);
+
 // const version of the above function.
-nsCSSValueBorrowed Gecko_CSSValue_GetArrayItemConst(nsCSSValueBorrowed css_value, int32_t index);
+nsCSSValueBorrowed Gecko_CSSValue_GetArrayItemConst(
+  nsCSSValueBorrowed css_value,
+  int32_t index);
+
 nsCSSKeyword Gecko_CSSValue_GetKeyword(nsCSSValueBorrowed aCSSValue);
 float Gecko_CSSValue_GetNumber(nsCSSValueBorrowed css_value);
 float Gecko_CSSValue_GetPercentage(nsCSSValueBorrowed css_value);
 nsStyleCoord::CalcValue Gecko_CSSValue_GetCalc(nsCSSValueBorrowed aCSSValue);
+void Gecko_CSSValue_SetNumber(nsCSSValueBorrowedMut css_value, float number);
 
-void Gecko_CSSValue_SetNumber(nsCSSValueBorrowedMut css_value, float number);
-void Gecko_CSSValue_SetKeyword(nsCSSValueBorrowedMut css_value, nsCSSKeyword keyword);
-void Gecko_CSSValue_SetPercentage(nsCSSValueBorrowedMut css_value, float percent);
+void Gecko_CSSValue_SetKeyword(
+  nsCSSValueBorrowedMut css_value,
+  nsCSSKeyword keyword);
+
+void Gecko_CSSValue_SetPercentage(
+  nsCSSValueBorrowedMut css_value,
+  float percent);
+
 void Gecko_CSSValue_SetPixelLength(nsCSSValueBorrowedMut aCSSValue, float aLen);
-void Gecko_CSSValue_SetCalc(nsCSSValueBorrowedMut css_value, nsStyleCoord::CalcValue calc);
+
+void Gecko_CSSValue_SetCalc(
+  nsCSSValueBorrowedMut css_value,
+  nsStyleCoord::CalcValue calc);
+
 void Gecko_CSSValue_SetFunction(nsCSSValueBorrowedMut css_value, int32_t len);
-void Gecko_CSSValue_SetString(nsCSSValueBorrowedMut css_value,
-                              const uint8_t* string, uint32_t len, nsCSSUnit unit);
-void Gecko_CSSValue_SetStringFromAtom(nsCSSValueBorrowedMut css_value,
-                                      nsAtom* atom, nsCSSUnit unit);
+
+void Gecko_CSSValue_SetString(
+  nsCSSValueBorrowedMut css_value,
+  const uint8_t* string,
+  uint32_t len,
+  nsCSSUnit unit);
+
+void Gecko_CSSValue_SetStringFromAtom(
+  nsCSSValueBorrowedMut css_value,
+  nsAtom* atom,
+  nsCSSUnit unit);
+
 // Take an addrefed nsAtom and set it to the nsCSSValue
 void Gecko_CSSValue_SetAtomIdent(nsCSSValueBorrowedMut css_value, nsAtom* atom);
 void Gecko_CSSValue_SetArray(nsCSSValueBorrowedMut css_value, int32_t len);
-void Gecko_CSSValue_SetInt(nsCSSValueBorrowedMut css_value, int32_t integer, nsCSSUnit unit);
-void Gecko_CSSValue_SetFloat(nsCSSValueBorrowedMut css_value, float value, nsCSSUnit unit);
-void Gecko_CSSValue_SetPair(nsCSSValueBorrowedMut css_value,
-                            nsCSSValueBorrowed xvalue, nsCSSValueBorrowed yvalue);
+
+void Gecko_CSSValue_SetInt(
+  nsCSSValueBorrowedMut css_value,
+  int32_t integer,
+  nsCSSUnit unit);
+
+void Gecko_CSSValue_SetFloat(
+  nsCSSValueBorrowedMut css_value,
+  float value,
+  nsCSSUnit unit);
+
+void Gecko_CSSValue_SetPair(
+  nsCSSValueBorrowedMut css_value,
+  nsCSSValueBorrowed xvalue,
+  nsCSSValueBorrowed yvalue);
+
 void Gecko_CSSValue_SetList(nsCSSValueBorrowedMut css_value, uint32_t len);
 void Gecko_CSSValue_SetPairList(nsCSSValueBorrowedMut css_value, uint32_t len);
-void Gecko_CSSValue_InitSharedList(nsCSSValueBorrowedMut css_value, uint32_t len);
+
+void Gecko_CSSValue_InitSharedList(
+  nsCSSValueBorrowedMut css_value,
+  uint32_t len);
+
 void Gecko_CSSValue_Drop(nsCSSValueBorrowedMut css_value);
+
 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsCSSValueSharedList, CSSValueSharedList);
 
 float Gecko_FontStretch_ToFloat(mozilla::FontStretch aStretch);
-void Gecko_FontStretch_SetFloat(mozilla::FontStretch* aStretch,
-                                float aFloatValue);
+
+void Gecko_FontStretch_SetFloat(
+  mozilla::FontStretch* aStretch,
+  float aFloatValue);
+
 float Gecko_FontSlantStyle_ToFloat(mozilla::FontSlantStyle aStyle);
 void Gecko_FontSlantStyle_SetNormal(mozilla::FontSlantStyle*);
 void Gecko_FontSlantStyle_SetItalic(mozilla::FontSlantStyle*);
-void Gecko_FontSlantStyle_SetOblique(mozilla::FontSlantStyle*, float angle_degrees);
-void Gecko_FontSlantStyle_Get(mozilla::FontSlantStyle,
-                              bool* normal,
-                              bool* italic,
-                              float* oblique_angle);
+
+void Gecko_FontSlantStyle_SetOblique(
+  mozilla::FontSlantStyle*,
+  float angle_degrees);
+
+void Gecko_FontSlantStyle_Get(
+  mozilla::FontSlantStyle,
+  bool* normal,
+  bool* italic,
+  float* oblique_angle);
 
 float Gecko_FontWeight_ToFloat(mozilla::FontWeight aWeight);
-void Gecko_FontWeight_SetFloat(mozilla::FontWeight* aWeight,
-                               float aFloatValue);
+
+void Gecko_FontWeight_SetFloat(
+  mozilla::FontWeight* aWeight,
+  float aFloatValue);
 
 void Gecko_nsStyleFont_SetLang(nsStyleFont* font, nsAtom* atom);
-void Gecko_nsStyleFont_CopyLangFrom(nsStyleFont* aFont, const nsStyleFont* aSource);
-void Gecko_nsStyleFont_FixupNoneGeneric(nsStyleFont* font,
-                                        RawGeckoPresContextBorrowed pres_context);
-void Gecko_nsStyleFont_PrefillDefaultForGeneric(nsStyleFont* font,
-                                                RawGeckoPresContextBorrowed pres_context,
-                                                uint8_t generic_id);
-void Gecko_nsStyleFont_FixupMinFontSize(nsStyleFont* font,
-                                        RawGeckoPresContextBorrowed pres_context);
-FontSizePrefs Gecko_GetBaseSize(nsAtom* lang);
+
+void Gecko_nsStyleFont_CopyLangFrom(
+  nsStyleFont* aFont,
+  const nsStyleFont* aSource);
+
+void Gecko_nsStyleFont_FixupNoneGeneric(
+  nsStyleFont* font,
+  RawGeckoPresContextBorrowed pres_context);
+
+void Gecko_nsStyleFont_PrefillDefaultForGeneric(
+  nsStyleFont* font,
+  RawGeckoPresContextBorrowed pres_context,
+  uint8_t generic_id);
+
+void Gecko_nsStyleFont_FixupMinFontSize(
+  nsStyleFont* font,
+  RawGeckoPresContextBorrowed pres_context);
+
+mozilla::FontSizePrefs Gecko_GetBaseSize(nsAtom* lang);
 
 // XBL related functions.
-RawGeckoElementBorrowedOrNull Gecko_GetBindingParent(RawGeckoElementBorrowed aElement);
-RawServoAuthorStylesBorrowedOrNull Gecko_XBLBinding_GetRawServoStyles(RawGeckoXBLBindingBorrowed aXBLBinding);
+RawGeckoElementBorrowedOrNull Gecko_GetBindingParent(
+  RawGeckoElementBorrowed aElement);
+
+RawServoAuthorStylesBorrowedOrNull Gecko_XBLBinding_GetRawServoStyles(
+  RawGeckoXBLBindingBorrowed aXBLBinding);
+
 bool Gecko_XBLBinding_InheritsStyle(RawGeckoXBLBindingBorrowed aXBLBinding);
 
 struct GeckoFontMetrics
 {
   nscoord mChSize;
   nscoord mXSize;
 };
 
-GeckoFontMetrics Gecko_GetFontMetrics(RawGeckoPresContextBorrowed pres_context,
-                                      bool is_vertical,
-                                      const nsStyleFont* font,
-                                      nscoord font_size,
-                                      bool use_user_font_set);
-int32_t Gecko_GetAppUnitsPerPhysicalInch(RawGeckoPresContextBorrowed pres_context);
-void InitializeServo();
-void ShutdownServo();
-void AssertIsMainThreadOrServoLangFontPrefsCacheLocked();
+GeckoFontMetrics Gecko_GetFontMetrics(
+  RawGeckoPresContextBorrowed pres_context,
+  bool is_vertical,
+  const nsStyleFont* font,
+  nscoord font_size,
+  bool use_user_font_set);
+
+int32_t Gecko_GetAppUnitsPerPhysicalInch(
+  RawGeckoPresContextBorrowed pres_context);
 
 mozilla::StyleSheet* Gecko_StyleSheet_Clone(
-    const mozilla::StyleSheet* aSheet,
-    const mozilla::StyleSheet* aNewParentSheet);
+  const mozilla::StyleSheet* aSheet,
+  const mozilla::StyleSheet* aNewParentSheet);
+
 void Gecko_StyleSheet_AddRef(const mozilla::StyleSheet* aSheet);
 void Gecko_StyleSheet_Release(const mozilla::StyleSheet* aSheet);
-
 nsCSSKeyword Gecko_LookupCSSKeyword(const uint8_t* string, uint32_t len);
 const char* Gecko_CSSKeywordString(nsCSSKeyword keyword, uint32_t* len);
+bool Gecko_IsDocumentBody(RawGeckoElementBorrowed element);
 
-bool Gecko_IsDocumentBody(RawGeckoElementBorrowed element);
 // We use an int32_t here instead of a LookAndFeel::ColorID
 // because forward-declaring a nested enum/struct is impossible
-nscolor Gecko_GetLookAndFeelSystemColor(int32_t color_id,
-                                        RawGeckoPresContextBorrowed pres_context);
+nscolor Gecko_GetLookAndFeelSystemColor(
+  int32_t color_id,
+  RawGeckoPresContextBorrowed pres_context);
 
 void Gecko_AddPropertyToSet(nsCSSPropertyIDSetBorrowedMut, nsCSSPropertyID);
 
 // Style-struct management.
-#define STYLE_STRUCT(name)                                            \
-  void Gecko_Construct_Default_nsStyle##name(                         \
-    nsStyle##name* ptr,                                               \
-    RawGeckoPresContextBorrowed pres_context);                        \
-  void Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr,          \
-                                         const nsStyle##name* other); \
+#define STYLE_STRUCT(name)                                    \
+  void Gecko_Construct_Default_nsStyle##name(                 \
+    nsStyle##name* ptr,                                       \
+    RawGeckoPresContextBorrowed pres_context);                \
+  void Gecko_CopyConstruct_nsStyle##name(                     \
+    nsStyle##name* ptr,                                       \
+    const nsStyle##name* other);                              \
   void Gecko_Destroy_nsStyle##name(nsStyle##name* ptr);
 #include "nsStyleStructList.h"
 #undef STYLE_STRUCT
 
 void Gecko_RegisterProfilerThread(const char* name);
 void Gecko_UnregisterProfilerThread();
 
-bool Gecko_DocumentRule_UseForPresentation(RawGeckoPresContextBorrowed,
-                                           const nsACString* aPattern,
-                                           mozilla::css::DocumentMatchingFunction);
+bool Gecko_DocumentRule_UseForPresentation(
+  RawGeckoPresContextBorrowed,
+  const nsACString* aPattern,
+  mozilla::css::DocumentMatchingFunction);
 
 // Allocator hinting.
 void Gecko_SetJemallocThreadLocalArena(bool enabled);
-
 void Gecko_AddBufferToCrashReport(const void* addr, size_t len);
 void Gecko_AnnotateCrashReport(uint32_t key, const char* value_str);
 
 // Pseudo-element flags.
 #define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
   const uint32_t SERVO_CSS_PSEUDO_ELEMENT_FLAGS_##name_ = flags_;
 #include "nsCSSPseudoElementList.h"
 #undef CSS_PSEUDO_ELEMENT
 
-#define SERVO_BINDING_FUNC(name_, return_, ...) return_ name_(__VA_ARGS__);
-#include "mozilla/ServoBindingList.h"
-#undef SERVO_BINDING_FUNC
+bool Gecko_ErrorReportingEnabled(
+  const mozilla::StyleSheet* sheet,
+  const mozilla::css::Loader* loader);
 
-bool Gecko_ErrorReportingEnabled(const mozilla::StyleSheet* sheet,
-                                 const mozilla::css::Loader* loader);
-void Gecko_ReportUnexpectedCSSError(const mozilla::StyleSheet* sheet,
-                                    const mozilla::css::Loader* loader,
-                                    nsIURI* uri,
-                                    const char* message,
-                                    const char* param,
-                                    uint32_t paramLen,
-                                    const char* prefix,
-                                    const char* prefixParam,
-                                    uint32_t prefixParamLen,
-                                    const char* suffix,
-                                    const char* source,
-                                    uint32_t sourceLen,
-                                    uint32_t lineNumber,
-                                    uint32_t colNumber);
+void Gecko_ReportUnexpectedCSSError(
+  const mozilla::StyleSheet* sheet,
+  const mozilla::css::Loader* loader,
+  nsIURI* uri,
+  const char* message,
+  const char* param,
+  uint32_t paramLen,
+  const char* prefix,
+  const char* prefixParam,
+  uint32_t prefixParamLen,
+  const char* suffix,
+  const char* source,
+  uint32_t sourceLen,
+  uint32_t lineNumber,
+  uint32_t colNumber);
 
 // DOM APIs.
-void Gecko_ContentList_AppendAll(nsSimpleContentList* aContentList,
-                                 const RawGeckoElement** aElements,
-                                 size_t aLength);
+void Gecko_ContentList_AppendAll(
+  nsSimpleContentList* aContentList,
+  const RawGeckoElement** aElements,
+  size_t aLength);
 
 // FIXME(emilio): These two below should be a single function that takes a
 // `const DocumentOrShadowRoot*`, but that doesn't make MSVC builds happy for a
 // reason I haven't really dug into.
 const nsTArray<mozilla::dom::Element*>* Gecko_Document_GetElementsWithId(
-    const nsIDocument* aDocument,
-    nsAtom* aId);
+  const nsIDocument* aDocument,
+  nsAtom* aId);
 
 const nsTArray<mozilla::dom::Element*>* Gecko_ShadowRoot_GetElementsWithId(
-    const mozilla::dom::ShadowRoot* aDocument,
-    nsAtom* aId);
+  const mozilla::dom::ShadowRoot* aDocument,
+  nsAtom* aId);
 
 // Check the value of the given bool preference. The pref name needs to
 // be null-terminated.
 bool Gecko_GetBoolPrefValue(const char* pref_name);
 
 // Returns true if we're currently performing the servo traversal.
 bool Gecko_IsInServoTraversal();
 
 // Returns true if we're currently on the main thread.
 bool Gecko_IsMainThread();
 
 // Media feature helpers.
+//
+// Defined in nsMediaFeatures.cpp.
 mozilla::StyleDisplayMode Gecko_MediaFeatures_GetDisplayMode(nsIDocument*);
+
 uint32_t Gecko_MediaFeatures_GetColorDepth(nsIDocument*);
-void Gecko_MediaFeatures_GetDeviceSize(nsIDocument*, nscoord* width, nscoord* height);
+
+void Gecko_MediaFeatures_GetDeviceSize(
+  nsIDocument*,
+  nscoord* width,
+  nscoord* height);
+
 float Gecko_MediaFeatures_GetResolution(nsIDocument*);
 bool Gecko_MediaFeatures_PrefersReducedMotion(nsIDocument*);
-mozilla::PointerCapabilities Gecko_MediaFeatures_PrimaryPointerCapabilities(nsIDocument*);
-mozilla::PointerCapabilities Gecko_MediaFeatures_AllPointerCapabilities(nsIDocument*);
+
+mozilla::PointerCapabilities Gecko_MediaFeatures_PrimaryPointerCapabilities(
+  nsIDocument*);
+
+mozilla::PointerCapabilities Gecko_MediaFeatures_AllPointerCapabilities(
+  nsIDocument*);
+
 float Gecko_MediaFeatures_GetDevicePixelRatio(nsIDocument*);
-bool Gecko_MediaFeatures_HasSystemMetric(nsIDocument*,
-                                         nsAtom* metric,
-                                         bool is_accessible_from_content);
+
+bool Gecko_MediaFeatures_HasSystemMetric(
+  nsIDocument*,
+  nsAtom* metric,
+  bool is_accessible_from_content);
+
 bool Gecko_MediaFeatures_IsResourceDocument(nsIDocument*);
 nsAtom* Gecko_MediaFeatures_GetOperatingSystemVersion(nsIDocument*);
 
 } // extern "C"
 
-#endif // mozilla_ServoBindings_h
+#endif // mozilla_GeckoBindings_h
new file mode 100644
--- /dev/null
+++ b/layout/style/RustCell.h
@@ -0,0 +1,41 @@
+/* -*- 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/. */
+
+/* an object with the same layout as a Rust std::cell::Cell<T> */
+
+#ifndef mozilla_RustCell_h
+#define mozilla_RustCell_h
+
+namespace mozilla {
+
+/**
+ * Object with the same layout as std::cell::Cell<T>.
+ *
+ * ServoBindings.toml defines a mapping so that generated bindings use a
+ * real std::cell::Cell<T>.
+ *
+ * Note that while the layout matches, this doesn't have the same ABI as a
+ * std::cell::Cell<T>, so values of this type can't be passed over FFI
+ * functions.
+ */
+template<typename T>
+class RustCell
+{
+public:
+  RustCell()
+    : mValue()
+  {
+  }
+
+  T Get() const { return mValue; }
+
+private:
+  T mValue;
+};
+
+} // namespace mozilla
+
+#endif // mozilla_RustCell_h
--- a/layout/style/ServoArcTypeList.h
+++ b/layout/style/ServoArcTypeList.h
@@ -1,15 +1,29 @@
 /* -*- 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/. */
 
-/* a list of all Servo Arc types used in stylo bindings for preprocessing */
+/* a list of all Servo Arc<T> types used across bindings, for preprocessing */
+
+// The first argument is the name of the Servo type used inside the Arc.
+// This doesn't need to be accurate; it's only used to generate nice looking
+// FFI function names.
+//
+// The second argument is the name of an opaque Gecko type that will
+// correspond to the Servo type used inside the Arc.  The convention for the
+// the name of the opaque Gecko type is "RawServo{Type}", where {Type} is
+// the name of the Servo type or something close to it.
+//
+// See the comment at the top of ServoBindingTypes.h for how to use these.
+//
+// If you add an entry to this file, you should also add an impl_arc_ffi!()
+// call to servo/components/style/gecko/arc_types.rs.
 
 SERVO_ARC_TYPE(CssRules, ServoCssRules)
 SERVO_ARC_TYPE(StyleSheetContents, RawServoStyleSheetContents)
 SERVO_ARC_TYPE(DeclarationBlock, RawServoDeclarationBlock)
 SERVO_ARC_TYPE(StyleRule, RawServoStyleRule)
 SERVO_ARC_TYPE(ImportRule, RawServoImportRule)
 SERVO_ARC_TYPE(AnimationValue, RawServoAnimationValue)
 SERVO_ARC_TYPE(Keyframe, RawServoKeyframe)
deleted file mode 100644
--- a/layout/style/ServoBindingList.h
+++ /dev/null
@@ -1,952 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/* a list of all Servo binding functions */
-
-/* This file contains the list of all Servo binding functions. Each
- * entry is defined as a SERVO_BINDING_FUNC macro with the following
- * parameters:
- * - 'name_' the name of the binding function
- * - 'return_' the return type of the binding function
- * and the parameter list of the function.
- *
- * Users of this list should define a macro
- * SERVO_BINDING_FUNC(name_, return_, ...)
- * before including this file.
- */
-
-// Element data
-SERVO_BINDING_FUNC(Servo_Element_ClearData, void, RawGeckoElementBorrowed node)
-SERVO_BINDING_FUNC(Servo_Element_SizeOfExcludingThisAndCVs, size_t,
-                   mozilla::MallocSizeOf malloc_size_of,
-                   mozilla::MallocSizeOf malloc_enclosing_size_of,
-                   mozilla::SeenPtrs* seen_ptrs, RawGeckoElementBorrowed node)
-SERVO_BINDING_FUNC(Servo_Element_HasPrimaryComputedValues, bool,
-                   RawGeckoElementBorrowed node)
-SERVO_BINDING_FUNC(Servo_Element_GetPrimaryComputedValues,
-                   ComputedStyleStrong,
-                   RawGeckoElementBorrowed node)
-SERVO_BINDING_FUNC(Servo_Element_HasPseudoComputedValues, bool,
-                   RawGeckoElementBorrowed node, size_t index)
-SERVO_BINDING_FUNC(Servo_Element_GetPseudoComputedValues,
-                   ComputedStyleStrong,
-                   RawGeckoElementBorrowed node, size_t index)
-SERVO_BINDING_FUNC(Servo_Element_IsDisplayNone,
-                   bool,
-                   RawGeckoElementBorrowed element)
-SERVO_BINDING_FUNC(Servo_Element_IsDisplayContents,
-                   bool,
-                   RawGeckoElementBorrowed element)
-SERVO_BINDING_FUNC(Servo_Element_IsPrimaryStyleReusedViaRuleNode,
-                   bool,
-                   RawGeckoElementBorrowed element)
-SERVO_BINDING_FUNC(Servo_InvalidateStyleForDocStateChanges,
-                   void,
-                   RawGeckoElementBorrowed root,
-                   RawServoStyleSetBorrowed doc_styles,
-                   const nsTArray<RawServoAuthorStylesBorrowed>* non_document_styles,
-                   uint64_t aStatesChanged)
-
-// Styleset and Stylesheet management
-SERVO_BINDING_FUNC(Servo_StyleSheet_FromUTF8Bytes,
-                   RawServoStyleSheetContentsStrong,
-                   mozilla::css::Loader* loader,
-                   mozilla::StyleSheet* gecko_stylesheet,
-                   mozilla::css::SheetLoadData* load_data,
-                   const nsACString* bytes,
-                   mozilla::css::SheetParsingMode parsing_mode,
-                   RawGeckoURLExtraData* extra_data,
-                   uint32_t line_number_offset,
-                   nsCompatibility quirks_mode,
-                   mozilla::css::LoaderReusableStyleSheets* reusable_sheets,
-                   StyleUseCountersBorrowedOrNull use_counters)
-SERVO_BINDING_FUNC(Servo_StyleSheet_FromUTF8BytesAsync,
-                   void,
-                   mozilla::css::SheetLoadDataHolder* load_data,
-                   RawGeckoURLExtraData* extra_data,
-                   const nsACString* bytes,
-                   mozilla::css::SheetParsingMode parsing_mode,
-                   uint32_t line_number_offset,
-                   nsCompatibility quirks_mode,
-                   bool should_record_use_counters)
-SERVO_BINDING_FUNC(Servo_StyleSheet_Empty, RawServoStyleSheetContentsStrong,
-                   mozilla::css::SheetParsingMode parsing_mode)
-SERVO_BINDING_FUNC(Servo_StyleSheet_HasRules, bool,
-                   RawServoStyleSheetContentsBorrowed sheet)
-SERVO_BINDING_FUNC(Servo_StyleSheet_GetRules, ServoCssRulesStrong,
-                   RawServoStyleSheetContentsBorrowed sheet)
-SERVO_BINDING_FUNC(Servo_StyleSheet_Clone, RawServoStyleSheetContentsStrong,
-                   RawServoStyleSheetContentsBorrowed sheet,
-                   const mozilla::StyleSheet* reference_sheet);
-SERVO_BINDING_FUNC(Servo_StyleSheet_SizeOfIncludingThis, size_t,
-                   mozilla::MallocSizeOf malloc_size_of,
-                   mozilla::MallocSizeOf malloc_enclosing_size_of,
-                   RawServoStyleSheetContentsBorrowed sheet)
-SERVO_BINDING_FUNC(Servo_StyleSheet_GetSourceMapURL, void,
-                   RawServoStyleSheetContentsBorrowed sheet, nsAString* result)
-SERVO_BINDING_FUNC(Servo_StyleSheet_GetSourceURL, void,
-                   RawServoStyleSheetContentsBorrowed sheet, nsAString* result)
-// We'd like to return `OriginFlags` here, but bindgen bitfield enums don't
-// work as return values with the Linux 32-bit ABI at the moment because
-// they wrap the value in a struct.
-SERVO_BINDING_FUNC(Servo_StyleSheet_GetOrigin, uint8_t,
-                   RawServoStyleSheetContentsBorrowed sheet)
-SERVO_BINDING_FUNC(Servo_StyleSet_Init, RawServoStyleSet*, RawGeckoPresContextOwned pres_context)
-SERVO_BINDING_FUNC(Servo_StyleSet_RebuildCachedData, void,
-                   RawServoStyleSetBorrowed set)
-
-// We'd like to return `OriginFlags` here, but bindgen bitfield enums don't
-// work as return values with the Linux 32-bit ABI at the moment because
-// they wrap the value in a struct.
-SERVO_BINDING_FUNC(Servo_StyleSet_MediumFeaturesChanged,
-                   MediumFeaturesChangedResult,
-                   RawServoStyleSetBorrowed document_set,
-                   nsTArray<RawServoAuthorStylesBorrowedMut>* non_document_sets,
-                   bool may_affect_default_style)
-// We'd like to return `OriginFlags` here, but bindgen bitfield enums don't
-// work as return values with the Linux 32-bit ABI at the moment because
-// they wrap the value in a struct.
-SERVO_BINDING_FUNC(Servo_StyleSet_Drop, void, RawServoStyleSetOwned set)
-SERVO_BINDING_FUNC(Servo_StyleSet_CompatModeChanged, void,
-                   RawServoStyleSetBorrowed raw_data)
-SERVO_BINDING_FUNC(Servo_StyleSet_AppendStyleSheet, void,
-                   RawServoStyleSetBorrowed set,
-                   const mozilla::StyleSheet* gecko_sheet)
-SERVO_BINDING_FUNC(Servo_StyleSet_PrependStyleSheet, void,
-                   RawServoStyleSetBorrowed set,
-                   const mozilla::StyleSheet* gecko_sheet)
-SERVO_BINDING_FUNC(Servo_StyleSet_RemoveStyleSheet, void,
-                   RawServoStyleSetBorrowed set,
-                   const mozilla::StyleSheet* gecko_sheet)
-SERVO_BINDING_FUNC(Servo_StyleSet_InsertStyleSheetBefore, void,
-                   RawServoStyleSetBorrowed set,
-                   const mozilla::StyleSheet* gecko_sheet,
-                   const mozilla::StyleSheet* before)
-SERVO_BINDING_FUNC(Servo_StyleSet_FlushStyleSheets, void,
-                   RawServoStyleSetBorrowed set,
-                   RawGeckoElementBorrowedOrNull doc_elem,
-                   const mozilla::ServoElementSnapshotTable* snapshots)
-SERVO_BINDING_FUNC(Servo_StyleSet_SetAuthorStyleDisabled, void,
-                   RawServoStyleSetBorrowed set,
-                   bool author_style_disabled)
-SERVO_BINDING_FUNC(Servo_StyleSet_NoteStyleSheetsChanged, void,
-                   RawServoStyleSetBorrowed set,
-                   mozilla::OriginFlags changed_origins)
-SERVO_BINDING_FUNC(Servo_StyleSet_GetKeyframesForName, bool,
-                   RawServoStyleSetBorrowed set,
-                   RawGeckoElementBorrowed element,
-                   ComputedStyleBorrowed style,
-                   nsAtom* name,
-                   nsTimingFunctionBorrowed timing_function,
-                   RawGeckoKeyframeListBorrowedMut keyframe_list)
-SERVO_BINDING_FUNC(Servo_StyleSet_GetFontFaceRules, void,
-                   RawServoStyleSetBorrowed set,
-                   RawGeckoFontFaceRuleListBorrowedMut list)
-SERVO_BINDING_FUNC(Servo_StyleSet_GetCounterStyleRule,
-                   const RawServoCounterStyleRule*,
-                   RawServoStyleSetBorrowed set, nsAtom* name)
-// This function may return nullptr or gfxFontFeatureValueSet with zero reference.
-SERVO_BINDING_FUNC(Servo_StyleSet_BuildFontFeatureValueSet,
-                   gfxFontFeatureValueSet*,
-                   RawServoStyleSetBorrowed set)
-SERVO_BINDING_FUNC(Servo_StyleSet_ResolveForDeclarations,
-                   ComputedStyleStrong,
-                   RawServoStyleSetBorrowed set,
-                   ComputedStyleBorrowedOrNull parent_style,
-                   RawServoDeclarationBlockBorrowed declarations)
-SERVO_BINDING_FUNC(Servo_SelectorList_Drop, void,
-                   RawServoSelectorListOwned selector_list)
-SERVO_BINDING_FUNC(Servo_SelectorList_Parse,
-                   RawServoSelectorList*,
-                   const nsACString* selector_list)
-SERVO_BINDING_FUNC(Servo_SourceSizeList_Parse,
-                   RawServoSourceSizeList*,
-                   const nsACString* value)
-SERVO_BINDING_FUNC(Servo_SourceSizeList_Evaluate,
-                   int32_t,
-                   RawServoStyleSetBorrowed set,
-                   RawServoSourceSizeListBorrowedOrNull)
-SERVO_BINDING_FUNC(Servo_SourceSizeList_Drop, void,
-                   RawServoSourceSizeListOwned)
-SERVO_BINDING_FUNC(Servo_SelectorList_Matches, bool,
-                   RawGeckoElementBorrowed, RawServoSelectorListBorrowed)
-SERVO_BINDING_FUNC(Servo_SelectorList_Closest, const RawGeckoElement*,
-                   RawGeckoElementBorrowed, RawServoSelectorListBorrowed)
-SERVO_BINDING_FUNC(Servo_SelectorList_QueryFirst, const RawGeckoElement*,
-                   RawGeckoNodeBorrowed, RawServoSelectorListBorrowed,
-                   bool may_use_invalidation)
-SERVO_BINDING_FUNC(Servo_SelectorList_QueryAll, void,
-                   RawGeckoNodeBorrowed, RawServoSelectorListBorrowed,
-                   nsSimpleContentList* content_list,
-                   bool may_use_invalidation)
-SERVO_BINDING_FUNC(Servo_StyleSet_AddSizeOfExcludingThis, void,
-                   mozilla::MallocSizeOf malloc_size_of,
-                   mozilla::MallocSizeOf malloc_enclosing_size_of,
-                   mozilla::ServoStyleSetSizes* sizes,
-                   RawServoStyleSetBorrowed set)
-SERVO_BINDING_FUNC(Servo_UACache_AddSizeOf, void,
-                   mozilla::MallocSizeOf malloc_size_of,
-                   mozilla::MallocSizeOf malloc_enclosing_size_of,
-                   mozilla::ServoStyleSetSizes* sizes)
-
-// AuthorStyles
-SERVO_BINDING_FUNC(Servo_AuthorStyles_Create, RawServoAuthorStyles*)
-SERVO_BINDING_FUNC(Servo_AuthorStyles_Drop, void,
-                   RawServoAuthorStylesOwned self)
-// TODO(emilio): These will need to take a master style set to implement
-// invalidation for Shadow DOM.
-SERVO_BINDING_FUNC(Servo_AuthorStyles_AppendStyleSheet, void,
-                   RawServoAuthorStylesBorrowedMut self,
-                   const mozilla::StyleSheet* gecko_sheet)
-SERVO_BINDING_FUNC(Servo_AuthorStyles_RemoveStyleSheet, void,
-                   RawServoAuthorStylesBorrowedMut self,
-                   const mozilla::StyleSheet* gecko_sheet)
-SERVO_BINDING_FUNC(Servo_AuthorStyles_InsertStyleSheetBefore, void,
-                   RawServoAuthorStylesBorrowedMut self,
-                   const mozilla::StyleSheet* gecko_sheet,
-                   const mozilla::StyleSheet* before)
-SERVO_BINDING_FUNC(Servo_AuthorStyles_ForceDirty, void,
-                   RawServoAuthorStylesBorrowedMut self)
-// TODO(emilio): This will need to take an element and a master style set to
-// implement invalidation for Shadow DOM.
-SERVO_BINDING_FUNC(Servo_AuthorStyles_Flush, void,
-                   RawServoAuthorStylesBorrowedMut self,
-                   RawServoStyleSetBorrowed document_styles)
-SERVO_BINDING_FUNC(Servo_AuthorStyles_SizeOfIncludingThis, size_t,
-                   mozilla::MallocSizeOf malloc_size_of,
-                   mozilla::MallocSizeOf malloc_enclosing_size_of,
-                   RawServoAuthorStylesBorrowed self)
-
-SERVO_BINDING_FUNC(Servo_ComputedStyle_AddRef, void, ComputedStyleBorrowed ctx);
-SERVO_BINDING_FUNC(Servo_ComputedStyle_Release, void, ComputedStyleBorrowed ctx);
-
-SERVO_BINDING_FUNC(Servo_StyleSet_MightHaveAttributeDependency, bool,
-                   RawServoStyleSetBorrowed set,
-                   RawGeckoElementBorrowed element,
-                   nsAtom* local_name)
-SERVO_BINDING_FUNC(Servo_StyleSet_HasStateDependency, bool,
-                   RawServoStyleSetBorrowed set,
-                   RawGeckoElementBorrowed element,
-                   uint64_t state)
-SERVO_BINDING_FUNC(Servo_StyleSet_HasDocumentStateDependency, bool,
-                   RawServoStyleSetBorrowed set,
-                   uint64_t state)
-
-// CSSRuleList
-SERVO_BINDING_FUNC(Servo_CssRules_ListTypes, void,
-                   ServoCssRulesBorrowed rules,
-                   nsTArrayBorrowed_uintptr_t result)
-SERVO_BINDING_FUNC(Servo_CssRules_InsertRule, nsresult,
-                   ServoCssRulesBorrowed rules,
-                   RawServoStyleSheetContentsBorrowed sheet,
-                   const nsACString* rule,
-                   uint32_t index,
-                   bool nested,
-                   mozilla::css::Loader* loader,
-                   mozilla::StyleSheet* gecko_stylesheet,
-                   uint16_t* rule_type)
-SERVO_BINDING_FUNC(Servo_CssRules_DeleteRule, nsresult,
-                   ServoCssRulesBorrowed rules, uint32_t index)
-
-// CSS Rules
-#define BASIC_RULE_FUNCS_WITHOUT_GETTER(type_) \
-  SERVO_BINDING_FUNC(Servo_##type_##_Debug, void, \
-                     RawServo##type_##Borrowed rule, nsACString* result) \
-  SERVO_BINDING_FUNC(Servo_##type_##_GetCssText, void, \
-                     RawServo##type_##Borrowed rule, nsAString* result)
-#define BASIC_RULE_FUNCS(type_) \
-  SERVO_BINDING_FUNC(Servo_CssRules_Get##type_##RuleAt, \
-                     RawServo##type_##RuleStrong, \
-                     ServoCssRulesBorrowed rules, uint32_t index, \
-                     uint32_t* line, uint32_t* column) \
-  BASIC_RULE_FUNCS_WITHOUT_GETTER(type_##Rule)
-#define GROUP_RULE_FUNCS(type_) \
-  BASIC_RULE_FUNCS(type_) \
-  SERVO_BINDING_FUNC(Servo_##type_##Rule_GetRules, ServoCssRulesStrong, \
-                     RawServo##type_##RuleBorrowed rule)
-
-BASIC_RULE_FUNCS(Style)
-BASIC_RULE_FUNCS(Import)
-BASIC_RULE_FUNCS_WITHOUT_GETTER(Keyframe)
-BASIC_RULE_FUNCS(Keyframes)
-GROUP_RULE_FUNCS(Media)
-GROUP_RULE_FUNCS(MozDocument)
-BASIC_RULE_FUNCS(Namespace)
-BASIC_RULE_FUNCS(Page)
-GROUP_RULE_FUNCS(Supports)
-BASIC_RULE_FUNCS(FontFeatureValues)
-BASIC_RULE_FUNCS(FontFace)
-BASIC_RULE_FUNCS(CounterStyle)
-#undef GROUP_RULE_FUNCS
-#undef BASIC_RULE_FUNCS
-#undef BASIC_RULE_FUNCS_WITHOUT_GETTER
-SERVO_BINDING_FUNC(Servo_StyleRule_GetStyle, RawServoDeclarationBlockStrong,
-                   RawServoStyleRuleBorrowed rule)
-SERVO_BINDING_FUNC(Servo_StyleRule_SetStyle, void,
-                   RawServoStyleRuleBorrowed rule,
-                   RawServoDeclarationBlockBorrowed declarations)
-SERVO_BINDING_FUNC(Servo_StyleRule_GetSelectorText, void,
-                   RawServoStyleRuleBorrowed rule, nsAString* result)
-SERVO_BINDING_FUNC(Servo_StyleRule_GetSelectorTextAtIndex, void,
-                   RawServoStyleRuleBorrowed rule, uint32_t index,
-                   nsAString* result)
-SERVO_BINDING_FUNC(Servo_StyleRule_GetSpecificityAtIndex, void,
-                   RawServoStyleRuleBorrowed rule, uint32_t index,
-                   uint64_t* specificity)
-SERVO_BINDING_FUNC(Servo_StyleRule_GetSelectorCount, void,
-                   RawServoStyleRuleBorrowed rule, uint32_t* count)
-SERVO_BINDING_FUNC(Servo_StyleRule_SelectorMatchesElement, bool,
-                   RawServoStyleRuleBorrowed, RawGeckoElementBorrowed,
-                   uint32_t index, mozilla::CSSPseudoElementType pseudo_type)
-SERVO_BINDING_FUNC(Servo_StyleRule_SetSelectorText, bool,
-                   RawServoStyleSheetContentsBorrowed sheet,
-                   RawServoStyleRuleBorrowed rule, const nsAString* text)
-SERVO_BINDING_FUNC(Servo_ImportRule_GetHref, void,
-                   RawServoImportRuleBorrowed rule, nsAString* result)
-SERVO_BINDING_FUNC(Servo_ImportRule_GetSheet,
-                   const mozilla::StyleSheet*,
-                   RawServoImportRuleBorrowed rule)
-SERVO_BINDING_FUNC(Servo_ImportRule_SetSheet,
-                   void,
-                   RawServoImportRuleBorrowed rule,
-                   mozilla::StyleSheet* sheet);
-SERVO_BINDING_FUNC(Servo_Keyframe_GetKeyText, void,
-                   RawServoKeyframeBorrowed keyframe, nsAString* result)
-// Returns whether it successfully changes the key text.
-SERVO_BINDING_FUNC(Servo_Keyframe_SetKeyText, bool,
-                   RawServoKeyframeBorrowed keyframe, const nsACString* text)
-SERVO_BINDING_FUNC(Servo_Keyframe_GetStyle, RawServoDeclarationBlockStrong,
-                   RawServoKeyframeBorrowed keyframe)
-SERVO_BINDING_FUNC(Servo_Keyframe_SetStyle, void,
-                   RawServoKeyframeBorrowed keyframe,
-                   RawServoDeclarationBlockBorrowed declarations)
-SERVO_BINDING_FUNC(Servo_KeyframesRule_GetName, nsAtom*,
-                   RawServoKeyframesRuleBorrowed rule)
-// This method takes an addrefed nsAtom.
-SERVO_BINDING_FUNC(Servo_KeyframesRule_SetName, void,
-                   RawServoKeyframesRuleBorrowed rule, nsAtom* name)
-SERVO_BINDING_FUNC(Servo_KeyframesRule_GetCount, uint32_t,
-                   RawServoKeyframesRuleBorrowed rule)
-SERVO_BINDING_FUNC(Servo_KeyframesRule_GetKeyframeAt, RawServoKeyframeStrong,
-                   RawServoKeyframesRuleBorrowed rule, uint32_t index,
-                   uint32_t* line, uint32_t* column)
-// Returns the index of the rule, max value of uint32_t if nothing found.
-SERVO_BINDING_FUNC(Servo_KeyframesRule_FindRule, uint32_t,
-                   RawServoKeyframesRuleBorrowed rule, const nsACString* key)
-// Returns whether it successfully appends the rule.
-SERVO_BINDING_FUNC(Servo_KeyframesRule_AppendRule, bool,
-                   RawServoKeyframesRuleBorrowed rule,
-                   RawServoStyleSheetContentsBorrowed sheet,
-                   const nsACString* css)
-SERVO_BINDING_FUNC(Servo_KeyframesRule_DeleteRule, void,
-                   RawServoKeyframesRuleBorrowed rule, uint32_t index)
-SERVO_BINDING_FUNC(Servo_MediaRule_GetMedia, RawServoMediaListStrong,
-                   RawServoMediaRuleBorrowed rule)
-SERVO_BINDING_FUNC(Servo_NamespaceRule_GetPrefix, nsAtom*,
-                   RawServoNamespaceRuleBorrowed rule)
-SERVO_BINDING_FUNC(Servo_NamespaceRule_GetURI, nsAtom*,
-                   RawServoNamespaceRuleBorrowed rule)
-SERVO_BINDING_FUNC(Servo_PageRule_GetStyle, RawServoDeclarationBlockStrong,
-                   RawServoPageRuleBorrowed rule)
-SERVO_BINDING_FUNC(Servo_PageRule_SetStyle, void,
-                   RawServoPageRuleBorrowed rule,
-                   RawServoDeclarationBlockBorrowed declarations)
-SERVO_BINDING_FUNC(Servo_SupportsRule_GetConditionText, void,
-                   RawServoSupportsRuleBorrowed rule, nsAString* result)
-SERVO_BINDING_FUNC(Servo_MozDocumentRule_GetConditionText, void,
-                   RawServoMozDocumentRuleBorrowed rule, nsAString* result)
-SERVO_BINDING_FUNC(Servo_FontFeatureValuesRule_GetFontFamily, void,
-                   RawServoFontFeatureValuesRuleBorrowed rule,
-                   nsAString* result)
-SERVO_BINDING_FUNC(Servo_FontFeatureValuesRule_GetValueText, void,
-                   RawServoFontFeatureValuesRuleBorrowed rule,
-                   nsAString* result)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_CreateEmpty, RawServoFontFaceRuleStrong)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_Clone, RawServoFontFaceRuleStrong,
-                   RawServoFontFaceRuleBorrowed rule)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_GetSourceLocation, void,
-                   RawServoFontFaceRuleBorrowed rule,
-                   uint32_t* line, uint32_t* column)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_Length, uint32_t,
-                   RawServoFontFaceRuleBorrowed rule)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_IndexGetter, nsCSSFontDesc,
-                   RawServoFontFaceRuleBorrowed rule, uint32_t index)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_GetDeclCssText, void,
-                   RawServoFontFaceRuleBorrowed rule, nsAString* result)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_GetFontWeight, bool,
-                   RawServoFontFaceRuleBorrowed rule,
-                   mozilla::StyleComputedFontWeightRange* out)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_GetFontDisplay, bool,
-                   RawServoFontFaceRuleBorrowed rule,
-                   mozilla::StyleFontDisplay* out)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_GetFontStyle, bool,
-                   RawServoFontFaceRuleBorrowed rule,
-                   mozilla::StyleComputedFontStyleDescriptor* out)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_GetFontStretch, bool,
-                   RawServoFontFaceRuleBorrowed rule,
-                   mozilla::StyleComputedFontStretchRange* out)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_GetFontLanguageOverride, bool,
-                   RawServoFontFaceRuleBorrowed rule,
-                   mozilla::StyleFontLanguageOverride* out)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_GetFamilyName, nsAtom*,
-                   RawServoFontFaceRuleBorrowed rule)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_GetUnicodeRanges, const mozilla::StyleUnicodeRange*,
-                   RawServoFontFaceRuleBorrowed rule,
-                   size_t* out_len)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_GetSources, void,
-                   RawServoFontFaceRuleBorrowed rule,
-                   nsTArray<mozilla::StyleFontFaceSourceListComponent>* components)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_GetVariationSettings, void,
-                   RawServoFontFaceRuleBorrowed rule,
-                   nsTArray<mozilla::gfx::FontVariation>* out)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_GetFeatureSettings, void,
-                   RawServoFontFaceRuleBorrowed rule,
-                   nsTArray<gfxFontFeature>* out)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_GetDescriptorCssText, void,
-                   RawServoFontFaceRuleBorrowed rule,
-                   nsCSSFontDesc desc, nsAString* result)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_SetDescriptor, bool,
-                   RawServoFontFaceRuleBorrowed rule,
-                   nsCSSFontDesc desc, const nsACString* value,
-                   RawGeckoURLExtraData* data)
-SERVO_BINDING_FUNC(Servo_FontFaceRule_ResetDescriptor, void,
-                   RawServoFontFaceRuleBorrowed rule,
-                   nsCSSFontDesc desc)
-SERVO_BINDING_FUNC(Servo_CounterStyleRule_GetName, nsAtom*,
-                   RawServoCounterStyleRuleBorrowed rule)
-SERVO_BINDING_FUNC(Servo_CounterStyleRule_SetName, bool,
-                   RawServoCounterStyleRuleBorrowed rule,
-                   const nsACString* name)
-SERVO_BINDING_FUNC(Servo_CounterStyleRule_GetGeneration, uint32_t,
-                   RawServoCounterStyleRuleBorrowed rule)
-SERVO_BINDING_FUNC(Servo_CounterStyleRule_GetSystem, uint8_t,
-                   RawServoCounterStyleRuleBorrowed rule)
-SERVO_BINDING_FUNC(Servo_CounterStyleRule_GetExtended, nsAtom*,
-                   RawServoCounterStyleRuleBorrowed rule)
-SERVO_BINDING_FUNC(Servo_CounterStyleRule_GetFixedFirstValue, int32_t,
-                   RawServoCounterStyleRuleBorrowed rule)
-SERVO_BINDING_FUNC(Servo_CounterStyleRule_GetFallback, nsAtom*,
-                   RawServoCounterStyleRuleBorrowed rule)
-SERVO_BINDING_FUNC(Servo_CounterStyleRule_GetDescriptor, void,
-                   RawServoCounterStyleRuleBorrowed rule,
-                   nsCSSCounterDesc desc, nsCSSValueBorrowedMut result)
-SERVO_BINDING_FUNC(Servo_CounterStyleRule_GetDescriptorCssText, void,
-                   RawServoCounterStyleRuleBorrowed rule,
-                   nsCSSCounterDesc desc, nsAString* result)
-SERVO_BINDING_FUNC(Servo_CounterStyleRule_SetDescriptor, bool,
-                   RawServoCounterStyleRuleBorrowed rule,
-                   nsCSSCounterDesc desc, const nsACString* value)
-
-// Animations API
-SERVO_BINDING_FUNC(Servo_ParseProperty,
-                   RawServoDeclarationBlockStrong,
-                   nsCSSPropertyID property, const nsACString* value,
-                   RawGeckoURLExtraData* data,
-                   mozilla::ParsingMode parsing_mode,
-                   nsCompatibility quirks_mode,
-                   mozilla::css::Loader* loader)
-SERVO_BINDING_FUNC(Servo_ParseEasing, bool,
-                   const nsAString* easing,
-                   RawGeckoURLExtraData* data,
-                   nsTimingFunctionBorrowedMut output)
-SERVO_BINDING_FUNC(Servo_GetComputedKeyframeValues, void,
-                   RawGeckoKeyframeListBorrowed keyframes,
-                   RawGeckoElementBorrowed element,
-                   ComputedStyleBorrowed style,
-                   RawServoStyleSetBorrowed set,
-                   RawGeckoComputedKeyframeValuesListBorrowedMut result)
-SERVO_BINDING_FUNC(Servo_ComputedValues_ExtractAnimationValue,
-                   RawServoAnimationValueStrong,
-                   ComputedStyleBorrowed computed_values,
-                   nsCSSPropertyID property)
-SERVO_BINDING_FUNC(Servo_ComputedValues_SpecifiesAnimationsOrTransitions, bool,
-                   ComputedStyleBorrowed computed_values)
-SERVO_BINDING_FUNC(Servo_Property_IsAnimatable, bool,
-                   nsCSSPropertyID property)
-SERVO_BINDING_FUNC(Servo_Property_IsTransitionable, bool,
-                   nsCSSPropertyID property)
-SERVO_BINDING_FUNC(Servo_Property_IsDiscreteAnimatable, bool,
-                   nsCSSPropertyID property)
-SERVO_BINDING_FUNC(Servo_GetProperties_Overriding_Animation, void,
-                   RawGeckoElementBorrowed,
-                   RawGeckoCSSPropertyIDListBorrowed,
-                   nsCSSPropertyIDSetBorrowedMut)
-SERVO_BINDING_FUNC(Servo_MatrixTransform_Operate, void,
-                   nsStyleTransformMatrix::MatrixTransformOperator
-                     matrix_operator,
-                   const RawGeckoGfxMatrix4x4* from,
-                   const RawGeckoGfxMatrix4x4* to,
-                   double progress,
-                   RawGeckoGfxMatrix4x4* result)
-SERVO_BINDING_FUNC(Servo_GetAnimationValues, void,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   RawGeckoElementBorrowed element,
-                   ComputedStyleBorrowed style,
-                   RawServoStyleSetBorrowed style_set,
-                   RawGeckoServoAnimationValueListBorrowedMut animation_values)
-
-// AnimationValues handling
-SERVO_BINDING_FUNC(Servo_AnimationValues_Interpolate,
-                   RawServoAnimationValueStrong,
-                   RawServoAnimationValueBorrowed from,
-                   RawServoAnimationValueBorrowed to,
-                   double progress)
-SERVO_BINDING_FUNC(Servo_AnimationValues_IsInterpolable, bool,
-                   RawServoAnimationValueBorrowed from,
-                   RawServoAnimationValueBorrowed to)
-SERVO_BINDING_FUNC(Servo_AnimationValues_Add,
-                   RawServoAnimationValueStrong,
-                   RawServoAnimationValueBorrowed a,
-                   RawServoAnimationValueBorrowed b)
-SERVO_BINDING_FUNC(Servo_AnimationValues_Accumulate,
-                   RawServoAnimationValueStrong,
-                   RawServoAnimationValueBorrowed a,
-                   RawServoAnimationValueBorrowed b,
-                   uint64_t count)
-SERVO_BINDING_FUNC(Servo_AnimationValues_GetZeroValue,
-                   RawServoAnimationValueStrong,
-                   RawServoAnimationValueBorrowed value_to_match)
-SERVO_BINDING_FUNC(Servo_AnimationValues_ComputeDistance, double,
-                   RawServoAnimationValueBorrowed from,
-                   RawServoAnimationValueBorrowed to)
-SERVO_BINDING_FUNC(Servo_AnimationValue_Serialize, void,
-                   RawServoAnimationValueBorrowed value,
-                   nsCSSPropertyID property,
-                   nsAString* buffer)
-SERVO_BINDING_FUNC(Servo_AnimationValue_GetOpacity, float,
-                   RawServoAnimationValueBorrowed value)
-SERVO_BINDING_FUNC(Servo_AnimationValue_Opacity,
-                   RawServoAnimationValueStrong,
-                   float)
-SERVO_BINDING_FUNC(Servo_AnimationValue_GetTransform, void,
-                   RawServoAnimationValueBorrowed value,
-                   RefPtr<nsCSSValueSharedList>* list)
-SERVO_BINDING_FUNC(Servo_AnimationValue_Transform,
-                   RawServoAnimationValueStrong,
-                   const nsCSSValueSharedList& list)
-SERVO_BINDING_FUNC(Servo_AnimationValue_DeepEqual, bool,
-                   RawServoAnimationValueBorrowed,
-                   RawServoAnimationValueBorrowed)
-SERVO_BINDING_FUNC(Servo_AnimationValue_Uncompute,
-                   RawServoDeclarationBlockStrong,
-                   RawServoAnimationValueBorrowed value)
-SERVO_BINDING_FUNC(Servo_AnimationValue_Compute,
-                   RawServoAnimationValueStrong,
-                   RawGeckoElementBorrowed element,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   ComputedStyleBorrowed style,
-                   RawServoStyleSetBorrowed raw_data)
-
-// Style attribute
-SERVO_BINDING_FUNC(Servo_ParseStyleAttribute, RawServoDeclarationBlockStrong,
-                   const nsACString* data,
-                   RawGeckoURLExtraData* extra_data,
-                   nsCompatibility quirks_mode,
-                   mozilla::css::Loader* loader)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_CreateEmpty,
-                   RawServoDeclarationBlockStrong)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_Clone, RawServoDeclarationBlockStrong,
-                   RawServoDeclarationBlockBorrowed declarations)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_Equals, bool,
-                   RawServoDeclarationBlockBorrowed a,
-                   RawServoDeclarationBlockBorrowed b)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_GetCssText, void,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   nsAString* result)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_SerializeOneValue, void,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   nsCSSPropertyID property, nsAString* buffer,
-                   ComputedStyleBorrowedOrNull computed_values,
-                   RawServoDeclarationBlockBorrowedOrNull custom_properties)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_Count, uint32_t,
-                   RawServoDeclarationBlockBorrowed declarations)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_GetNthProperty, bool,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   uint32_t index, nsAString* result)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_GetPropertyValue, void,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   const nsACString* property, nsAString* value)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_GetPropertyValueById, void,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   nsCSSPropertyID property, nsAString* value)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_GetPropertyIsImportant, bool,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   const nsACString* property)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetProperty, bool,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   const nsACString* property,
-                   const nsACString* value, bool is_important,
-                   RawGeckoURLExtraData* data,
-                   mozilla::ParsingMode parsing_mode,
-                   nsCompatibility quirks_mode,
-                   mozilla::css::Loader* loader,
-                   DeclarationBlockMutationClosure)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetPropertyToAnimationValue, bool,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   RawServoAnimationValueBorrowed animation_value)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetPropertyById, bool,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   nsCSSPropertyID property,
-                   const nsACString* value, bool is_important,
-                   RawGeckoURLExtraData* data,
-                   mozilla::ParsingMode parsing_mode,
-                   nsCompatibility quirks_mode,
-                   mozilla::css::Loader* loader,
-                   DeclarationBlockMutationClosure)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_RemoveProperty, bool,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   const nsACString* property,
-                   DeclarationBlockMutationClosure)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_RemovePropertyById, bool,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   nsCSSPropertyID property,
-                   DeclarationBlockMutationClosure)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_HasCSSWideKeyword, bool,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   nsCSSPropertyID property)
-// Compose animation value for a given property.
-// |base_values| is nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>.
-// We use RawServoAnimationValueTableBorrowed to avoid exposing
-// nsRefPtrHashtable in FFI.
-SERVO_BINDING_FUNC(Servo_AnimationCompose, void,
-                   RawServoAnimationValueMapBorrowedMut animation_values,
-                   RawServoAnimationValueTableBorrowed base_values,
-                   nsCSSPropertyID property,
-                   RawGeckoAnimationPropertySegmentBorrowed animation_segment,
-                   RawGeckoAnimationPropertySegmentBorrowed last_segment,
-                   RawGeckoComputedTimingBorrowed computed_timing,
-                   mozilla::dom::IterationCompositeOperation iter_composite)
-// Calculate the result of interpolating given animation segment at the given
-// progress and current iteration.
-// This includes combining the segment endpoints with the underlying value
-// and/or last value depending the composite modes specified on the
-// segment endpoints and the supplied iteration composite mode.
-// The caller is responsible for providing an underlying value and
-// last value in all situations where there are needed.
-SERVO_BINDING_FUNC(Servo_ComposeAnimationSegment,
-                   RawServoAnimationValueStrong,
-                   RawGeckoAnimationPropertySegmentBorrowed animation_segment,
-                   RawServoAnimationValueBorrowedOrNull underlying_value,
-                   RawServoAnimationValueBorrowedOrNull last_value,
-                   mozilla::dom::IterationCompositeOperation iter_composite,
-                   double progress,
-                   uint64_t current_iteration)
-
-// presentation attributes
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_PropertyIsSet, bool,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   nsCSSPropertyID property)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetIdentStringValue, void,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   nsCSSPropertyID property,
-                   nsAtom* value)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetKeywordValue, void,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   nsCSSPropertyID property,
-                   int32_t value)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetIntValue, void,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   nsCSSPropertyID property,
-                   int32_t value)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetPixelValue, void,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   nsCSSPropertyID property,
-                   float value)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetLengthValue, void,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   nsCSSPropertyID property,
-                   float value,
-                   nsCSSUnit unit)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetNumberValue, void,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   nsCSSPropertyID property,
-                   float value)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetPercentValue, void,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   nsCSSPropertyID property,
-                   float value)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetAutoValue, void,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   nsCSSPropertyID property)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetCurrentColor, void,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   nsCSSPropertyID property)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetColorValue, void,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   nsCSSPropertyID property,
-                   nscolor value)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetFontFamily, void,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   const nsAString& value)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetTextDecorationColorOverride, void,
-                   RawServoDeclarationBlockBorrowed declarations)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetBackgroundImage, void,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   const nsAString& value,
-                   RawGeckoURLExtraData* extra_data)
-
-// MediaList
-SERVO_BINDING_FUNC(Servo_MediaList_Create, RawServoMediaListStrong)
-SERVO_BINDING_FUNC(Servo_MediaList_DeepClone, RawServoMediaListStrong,
-                   RawServoMediaListBorrowed list)
-SERVO_BINDING_FUNC(Servo_MediaList_Matches, bool,
-                   RawServoMediaListBorrowed list,
-                   RawServoStyleSetBorrowed set)
-SERVO_BINDING_FUNC(Servo_MediaList_GetText, void,
-                   RawServoMediaListBorrowed list, nsAString* result)
-SERVO_BINDING_FUNC(Servo_MediaList_SetText, void,
-                   RawServoMediaListBorrowed list, const nsACString* text,
-                   mozilla::dom::CallerType aCallerType)
-SERVO_BINDING_FUNC(Servo_MediaList_GetLength, uint32_t,
-                   RawServoMediaListBorrowed list)
-SERVO_BINDING_FUNC(Servo_MediaList_GetMediumAt, bool,
-                   RawServoMediaListBorrowed list, uint32_t index,
-                   nsAString* result)
-SERVO_BINDING_FUNC(Servo_MediaList_AppendMedium, void,
-                   RawServoMediaListBorrowed list, const nsACString* new_medium)
-SERVO_BINDING_FUNC(Servo_MediaList_DeleteMedium, bool,
-                   RawServoMediaListBorrowed list, const nsACString* old_medium)
-SERVO_BINDING_FUNC(Servo_MediaList_SizeOfIncludingThis, size_t,
-                   mozilla::MallocSizeOf malloc_size_of,
-                   mozilla::MallocSizeOf malloc_enclosing_size_of,
-                   RawServoMediaListBorrowed list)
-
-// CSS supports()
-SERVO_BINDING_FUNC(Servo_CSSSupports2, bool,
-                   const nsACString* name, const nsACString* value)
-SERVO_BINDING_FUNC(Servo_CSSSupports, bool,
-                   const nsACString* cond)
-
-// Computed style data
-SERVO_BINDING_FUNC(Servo_ComputedValues_GetForAnonymousBox,
-                   ComputedStyleStrong,
-                   ComputedStyleBorrowedOrNull parent_style_or_null,
-                   nsAtom* pseudo_tag,
-                   RawServoStyleSetBorrowed set)
-SERVO_BINDING_FUNC(Servo_ComputedValues_Inherit, ComputedStyleStrong,
-                   RawServoStyleSetBorrowed set,
-                   nsAtom* pseudo_tag,
-                   ComputedStyleBorrowedOrNull parent_style,
-                   mozilla::InheritTarget target)
-SERVO_BINDING_FUNC(Servo_ComputedValues_GetStyleBits, uint8_t,
-                   ComputedStyleBorrowed values)
-SERVO_BINDING_FUNC(Servo_ComputedValues_EqualCustomProperties, bool,
-                   ServoComputedDataBorrowed first,
-                   ServoComputedDataBorrowed second)
-// Gets the source style rules for the computed values. This returns
-// the result via rules, which would include a list of unowned pointers
-// to RawServoStyleRule.
-SERVO_BINDING_FUNC(Servo_ComputedValues_GetStyleRuleList, void,
-                   ComputedStyleBorrowed values,
-                   RawGeckoServoStyleRuleListBorrowedMut rules)
-
-// Initialize Servo components. Should be called exactly once at startup.
-SERVO_BINDING_FUNC(Servo_Initialize, void,
-                   RawGeckoURLExtraData* dummy_url_data)
-// Initialize Servo on a cooperative Quantum DOM thread.
-SERVO_BINDING_FUNC(Servo_InitializeCooperativeThread, void);
-// Shut down Servo components. Should be called exactly once at shutdown.
-SERVO_BINDING_FUNC(Servo_Shutdown, void)
-
-// Restyle and change hints.
-SERVO_BINDING_FUNC(Servo_NoteExplicitHints, void, RawGeckoElementBorrowed element,
-                   nsRestyleHint restyle_hint, nsChangeHint change_hint)
-// We'd like to return `nsChangeHint` here, but bindgen bitfield enums don't
-// work as return values with the Linux 32-bit ABI at the moment because
-// they wrap the value in a struct.
-SERVO_BINDING_FUNC(Servo_TakeChangeHint,
-                   uint32_t,
-                   RawGeckoElementBorrowed element,
-                   bool* was_restyled)
-SERVO_BINDING_FUNC(Servo_ResolveStyle, ComputedStyleStrong,
-                   RawGeckoElementBorrowed element,
-                   RawServoStyleSetBorrowed set)
-SERVO_BINDING_FUNC(Servo_ResolvePseudoStyle, ComputedStyleStrong,
-                   RawGeckoElementBorrowed element,
-                   mozilla::CSSPseudoElementType pseudo_type,
-                   bool is_probe,
-                   ComputedStyleBorrowedOrNull inherited_style,
-                   RawServoStyleSetBorrowed set)
-SERVO_BINDING_FUNC(Servo_ComputedValues_ResolveXULTreePseudoStyle,
-                   ComputedStyleStrong,
-                   RawGeckoElementBorrowed element,
-                   nsAtom* pseudo_tag,
-                   ComputedStyleBorrowed inherited_style,
-                   const mozilla::AtomArray* input_word,
-                   RawServoStyleSetBorrowed set)
-SERVO_BINDING_FUNC(Servo_SetExplicitStyle, void,
-                   RawGeckoElementBorrowed element,
-                   ComputedStyleBorrowed primary_style)
-SERVO_BINDING_FUNC(Servo_HasAuthorSpecifiedRules, bool,
-                   ComputedStyleBorrowed style,
-                   RawGeckoElementBorrowed element,
-                   mozilla::CSSPseudoElementType pseudo_type,
-                   uint32_t rule_type_mask,
-                   bool author_colors_allowed)
-
-// Resolves style for an element or pseudo-element without processing pending
-// restyles first. The Element and its ancestors may be unstyled, have pending
-// restyles, or be in a display:none subtree. Styles are cached when possible,
-// though caching is not possible within display:none subtrees, and the styles
-// may be invalidated by already-scheduled restyles.
-//
-// The tree must be in a consistent state such that a normal traversal could be
-// performed, and this function maintains that invariant.
-SERVO_BINDING_FUNC(Servo_ResolveStyleLazily, ComputedStyleStrong,
-                   RawGeckoElementBorrowed element,
-                   mozilla::CSSPseudoElementType pseudo_type,
-                   mozilla::StyleRuleInclusion rule_inclusion,
-                   const mozilla::ServoElementSnapshotTable* snapshots,
-                   RawServoStyleSetBorrowed set)
-
-// Reparents style to the new parents.
-SERVO_BINDING_FUNC(Servo_ReparentStyle, ComputedStyleStrong,
-                   ComputedStyleBorrowed style_to_reparent,
-                   ComputedStyleBorrowed parent_style,
-                   ComputedStyleBorrowed parent_style_ignoring_first_line,
-                   ComputedStyleBorrowed layout_parent_style,
-                   // element is null if there is no content node involved, or
-                   // if it's not an element.
-                   RawGeckoElementBorrowedOrNull element,
-                   RawServoStyleSetBorrowed set);
-
-// Use ServoStyleSet::PrepareAndTraverseSubtree instead of calling this
-// directly
-SERVO_BINDING_FUNC(Servo_TraverseSubtree,
-                   bool,
-                   RawGeckoElementBorrowed root,
-                   RawServoStyleSetBorrowed set,
-                   const mozilla::ServoElementSnapshotTable* snapshots,
-                   mozilla::ServoTraversalFlags flags)
-
-// Assert that the tree has no pending or unconsumed restyles.
-SERVO_BINDING_FUNC(Servo_AssertTreeIsClean, void, RawGeckoElementBorrowed root)
-
-// Returns true if the current thread is a Servo parallel worker thread.
-SERVO_BINDING_FUNC(Servo_IsWorkerThread, bool, )
-
-// Checks whether the rule tree has crossed its threshold for unused rule nodes,
-// and if so, frees them.
-SERVO_BINDING_FUNC(Servo_MaybeGCRuleTree, void, RawServoStyleSetBorrowed set)
-
-// Returns computed values for the given element without any animations rules.
-SERVO_BINDING_FUNC(Servo_StyleSet_GetBaseComputedValuesForElement,
-                   ComputedStyleStrong,
-                   RawServoStyleSetBorrowed set,
-                   RawGeckoElementBorrowed element,
-                   ComputedStyleBorrowed existing_style,
-                   const mozilla::ServoElementSnapshotTable* snapshots)
-// Returns computed values for the given element by adding an animation value.
-SERVO_BINDING_FUNC(Servo_StyleSet_GetComputedValuesByAddingAnimation,
-                   ComputedStyleStrong,
-                   RawServoStyleSetBorrowed set,
-                   RawGeckoElementBorrowed element,
-                   ComputedStyleBorrowed existing_style,
-                   const mozilla::ServoElementSnapshotTable* snapshots,
-                   RawServoAnimationValueBorrowed animation)
-
-// For canvas font.
-SERVO_BINDING_FUNC(Servo_SerializeFontValueForCanvas, void,
-                   RawServoDeclarationBlockBorrowed declarations,
-                   nsAString* buffer)
-
-// GetComputedStyle APIs.
-SERVO_BINDING_FUNC(Servo_GetCustomPropertyValue, bool,
-                   ComputedStyleBorrowed computed_values,
-                   const nsAString* name, nsAString* value)
-
-SERVO_BINDING_FUNC(Servo_GetCustomPropertiesCount, uint32_t,
-                   ComputedStyleBorrowed computed_values)
-
-SERVO_BINDING_FUNC(Servo_GetCustomPropertyNameAt, bool,
-                   ComputedStyleBorrowed, uint32_t index,
-                   nsAString* name)
-
-SERVO_BINDING_FUNC(Servo_GetPropertyValue, void,
-                   ComputedStyleBorrowed computed_values,
-                   nsCSSPropertyID property, nsAString* value)
-
-SERVO_BINDING_FUNC(Servo_ProcessInvalidations, void,
-                   RawServoStyleSetBorrowed set,
-                   RawGeckoElementBorrowed element,
-                   const mozilla::ServoElementSnapshotTable* snapshots)
-
-
-SERVO_BINDING_FUNC(Servo_HasPendingRestyleAncestor, bool,
-                   RawGeckoElementBorrowed element)
-
-SERVO_BINDING_FUNC(Servo_GetArcStringData, void,
-                   const RustString*, uint8_t const** chars, uint32_t* len);
-SERVO_BINDING_FUNC(Servo_ReleaseArcStringData, void,
-                   const mozilla::ServoRawOffsetArc<RustString>* string);
-
-// CSS parsing utility functions.
-SERVO_BINDING_FUNC(Servo_IsValidCSSColor, bool, const nsAString* value);
-SERVO_BINDING_FUNC(Servo_ComputeColor, bool,
-                   RawServoStyleSetBorrowedOrNull set,
-                   nscolor current_color,
-                   const nsAString* value,
-                   nscolor* result_color,
-                   bool* was_current_color,
-                   mozilla::css::Loader* loader)
-SERVO_BINDING_FUNC(Servo_IntersectionObserverRootMargin_Parse, bool,
-                   const nsAString* value, nsStyleSides* result)
-SERVO_BINDING_FUNC(Servo_IntersectionObserverRootMargin_ToString, void,
-                   const nsStyleSides* rect, nsAString* result)
-// Returning false means the parsed transform contains relative lengths or
-// percentage value, so we cannot compute the matrix. In this case, we keep
-// |result| and |contains_3d_transform| as-is.
-SERVO_BINDING_FUNC(Servo_ParseTransformIntoMatrix, bool,
-                   const nsAString* value,
-                   bool* contains_3d_transform,
-                   RawGeckoGfxMatrix4x4* result);
-SERVO_BINDING_FUNC(Servo_ParseFontShorthandForMatching, bool,
-                   const nsAString* value,
-                   RawGeckoURLExtraData* data,
-                   RefPtr<SharedFontList>* family,
-                   // We use ComputedFontStyleDescriptor just for convenience,
-                   // but the two values of Oblique are the same.
-                   mozilla::StyleComputedFontStyleDescriptor* style,
-                   float* stretch,
-                   float* weight);
-
-SERVO_BINDING_FUNC(Servo_ResolveLogicalProperty,
-                   nsCSSPropertyID,
-                   nsCSSPropertyID,
-                   ComputedStyleBorrowed);
-SERVO_BINDING_FUNC(Servo_Property_LookupEnabledForAllContent,
-                   nsCSSPropertyID,
-                   const nsACString* name);
-SERVO_BINDING_FUNC(Servo_Property_GetName,
-                   const uint8_t*,
-                   nsCSSPropertyID,
-                   uint32_t* out_length);
-SERVO_BINDING_FUNC(Servo_Property_IsShorthand, bool,
-                   const nsACString* name, bool* found);
-SERVO_BINDING_FUNC(Servo_Property_IsInherited, bool,
-                   const nsACString* name);
-SERVO_BINDING_FUNC(Servo_Property_SupportsType, bool,
-                   const nsACString* name, uint32_t ty, bool* found);
-SERVO_BINDING_FUNC(Servo_Property_GetCSSValuesForProperty, void,
-                   const nsACString* name, bool* found, nsTArray<nsString>* result)
-SERVO_BINDING_FUNC(Servo_PseudoClass_GetStates, uint64_t,
-                   const nsACString* name)
-SERVO_BINDING_FUNC(Servo_UseCounters_Create, StyleUseCounters*)
-SERVO_BINDING_FUNC(Servo_UseCounters_Drop, void, StyleUseCountersOwned)
-SERVO_BINDING_FUNC(Servo_UseCounters_Merge, void,
-                   StyleUseCountersBorrowed doc_counters,
-                   StyleUseCountersBorrowed sheet_counters)
-SERVO_BINDING_FUNC(Servo_IsCssPropertyRecordedInUseCounter, bool,
-                   StyleUseCountersBorrowed,
-                   const nsACString* property,
-                   bool* out_known_prop)
-
-// AddRef / Release functions
-#define SERVO_ARC_TYPE(name_, type_)                                \
-  SERVO_BINDING_FUNC(Servo_##name_##_AddRef, void, type_##Borrowed) \
-  SERVO_BINDING_FUNC(Servo_##name_##_Release, void, type_##Borrowed)
-#include "mozilla/ServoArcTypeList.h"
-#undef SERVO_ARC_TYPE
--- a/layout/style/ServoBindingTypes.h
+++ b/layout/style/ServoBindingTypes.h
@@ -1,224 +1,240 @@
 /* -*- 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/. */
 
+/* C++ types corresponding to Servo and Gecko types used across bindings,
+   with some annotations to indicate ownership expectations */
+
+// This file defines a number of C++ types used to represent borrowed,
+// strong, and owning references to Servo and Gecko objects that might
+// be used across bindings and FFI.
+//
+// By convention, the types defined here are named "RawServo{Type}" and
+// "RawGecko{Type}".  The {Type} should be something close to the real Rust or
+// C++ name of the type, but need not be.  The "Raw" is really just used to
+// avoid clashing with other names.
+//
+// For Servo types, each "RawServo{ServoTypeName}" is generated as an opaque,
+// declared but not defined struct.
+//
+// For Gecko types, each "RawGecko{GeckoTypeName}" is a typedef that aliases
+// the actual C++ type.
+//
+// Each of these types can have a number of different typedefs generated for
+// them, representing different notions of ownership when passing or receiving
+// these values across bindings and FFI:
+//
+//   Raw{Gecko,Servo}{Type}Borrowed
+//   Raw{Gecko,Servo}{Type}BorrowedOrNull
+//     immutable, borrowed reference (or null)
+//
+//   Raw{Gecko,Servo}{Type}BorrowedMut
+//   Raw{Gecko,Servo}{Type}BorrowedMutOrNull
+//     mutable, borrowed reference (or null)
+//
+//   RawServo{Type}Strong
+//     strong reference to an Arc-managed value
+//
+//   RawServo{Type}Owned
+//   RawServo{Type}OwnedOrNull
+//     owned reference to a Box-managed value (or null)
+//
+// All of these borrowed, strong, and owned types are generated by adding
+// entries to one of these files:
+//
+//   BorrowedTypeList.h
+//     generates some or all of the Borrowed types
+//
+//   ServoArcTypeList.h
+//     generates all of the Borrowed types and the Strong type
+//
+//   ServoBoxedTypeList.h
+//     generates all of the Borrowed types and the Owned & OwnedNull types
+//
+// The borrowed, strong, and owned reference types should be used in FFI
+// function signatures where possible, to help indicate the ownership properties
+// that both sides of the function call must adhere to.
+//
+// There are some special cases defined at the bottom of this file that don't
+// fit neatly into these three categories.
+//
+//
+// Using these types in C++
+// ========================
+//
+// All of the Borrowed types are C++ typedefs for raw pointers, and can be used
+// directly.  Since the types they point to are opaque, there isn't much that
+// can be done with these apart from passing them around, holding on to them,
+// checking them for equality, etc.  If they are Arc-managed or Box-managed
+// Servo types, they can be assigned to a RefPtr<> or UniquePtr<>.
+//
+// The Strong types are a C++ struct that wraps a raw pointer.  When receiving
+// a Strong value from a Servo_* FFI function, you must call Consume() on it
+// to convert it into an already_AddRefed<RawServo{Type}>, otherwise it will
+// leak.
+//
+// We don't currently have any cases where we pass a Strong value to Servo; this
+// could be done by creating a RawServo{Type}Strong struct value whose mPtr is
+// initialized to the result of calling `.forget().take()` on a
+// RefPtr<RawServo{Type}>, but it's probably easier just to pass a Borrowed
+// value and let the Rust code turn it into an Arc.
+//
+// The Owned types are C++ typedefs for raw pointers.  When receiving an Owned
+// value from a Servo_* FFI function, it should be assigned to a UniquePtr<>,
+// otherwise it will leak.
+//
+// To pass an Owned value to Servo, call `release()` on the UniquePtr<> it's
+// living in (to take ownership of it), and pass that pointer in directly.
+//
+// TODO(heycam): We should perhaps have a similar struct for Owned types with
+// a Consume() method to convert them into a UniquePtr.  The struct for Strong
+// types at least have MOZ_MUST_USE_TYPE on them.
+//
+//
+// Using these types in Rust
+// =========================
+//
+// The FFI type names are available in Rust in the gecko_bindings::bindings mod,
+// which is generated by servo/components/style/build_gecko.rs.
+//
+// The Borrowed types are defined as Rust reference types.
+//
+// Borrowed types for Gecko values are references to the bindgened versions of
+// the C++ types, so when receiving references over FFI into a Servo_* function,
+// they can be used directly, and when returning them back to Gecko, the
+// reference can be returned directly.
+//
+// Borrowed types for Servo values are references to an opaque type, which must
+// be converted to or from the appropriate Rust type:
+//
+//   For an Arc-owned value, a RawServoFooBorrowed received from FFI can be
+//   converted into a `&Arc<Foo>` by calling `Foo::as_arc(&raw_servo_foo)`.
+//   Returning a RawServoFooBorrowed over FFI back to Gecko can be done by
+//   calling `as_borrowed()` on the `Arc<Foo>`.
+//
+//   For a Box-owned value, a RawServoFooBorrowed received from FFI can be
+//   converted into a `&Foo` by calling `Foo::from_ffi(&raw_servo_foo)`.
+//   Returning a RawServoFooBorrowed over FFI back to Gecko can be done by
+//   calling `as_ffi()` on the `Foo`.
+//
+// The Strong types are defined as gecko_bindings::sugar::ownership::Strong<T>.
+//
+// This is an FFI safe type that represents the value with a strong reference
+// already added to it.  Dropping a Strong<T> will leak the strong reference.
+//
+// A RawServoFooStrong received from FFI can be converted into a
+// `RawOffsetArc<Foo>` by calling `into_arc()` or `into_arc_opt()` on it.
+// To pass a RawServoFooStrong back to Gecko, call `into_strong()` on the
+// `Arc<Foo>`.
+//
+// The Owned types are defined as gecko_bindings::sugar::ownership::Owned<T>
+// (or OwnedOrNull<T>).
+//
+// This is another FFI safe type that represents the owning reference to the
+// value.  Dropping an Owned<T> will leak the value.
+//
+// A RawServoFooOwned received from FFI can be converted into a `Box<Foo>`
+// by calling `into_box()` or `into_box_opt()` on it.  To pass a
+// RawServoFooOwned back to Gecko, call `HasBoxFFI::into_ffi()` passing in
+// the `Box<Foo>` value.
+//
+//
+// Reading through servo/components/style/gecko_bindings/sugar/ownership.rs
+// is also instructive in understanding all this.
+
 #ifndef mozilla_ServoBindingTypes_h
 #define mozilla_ServoBindingTypes_h
 
 #include "mozilla/RefPtr.h"
 #include "mozilla/ServoComputedData.h"
 #include "mozilla/ServoTypes.h"
-#include "mozilla/SheetType.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/gfx/Types.h"
 #include "nsCSSPropertyID.h"
 #include "nsStyleAutoArray.h"
 #include "nsTArray.h"
 
-struct RawServoAuthorStyles;
-struct RawServoStyleSet;
-struct RawServoSelectorList;
-struct RawServoSourceSizeList;
-struct RawServoAnimationValueMap;
-struct RustString;
-struct StyleUseCounters;
+// Forward declarations.
+
+#define SERVO_BOXED_TYPE(name_, type_) struct type_;
+#include "mozilla/ServoBoxedTypeList.h"
+#undef SERVO_BOXED_TYPE
 
 #define SERVO_ARC_TYPE(name_, type_) struct type_;
 #include "mozilla/ServoArcTypeList.h"
 #undef SERVO_ARC_TYPE
 
-namespace mozilla {
-class ServoElementSnapshot;
-class ComputedStyle;
-struct StyleAnimation;
-struct URLExtraData;
-namespace dom {
-class Element;
-class StyleChildrenIterator;
-} // namespace dom
-struct AnimationPropertySegment;
-struct ComputedTiming;
-struct Keyframe;
-struct PropertyValuePair;
-struct PropertyStyleAnimationValuePair;
-enum class OriginFlags : uint8_t;
-using ComputedKeyframeValues = nsTArray<PropertyStyleAnimationValuePair>;
-} // namespace mozilla
-namespace nsStyleTransformMatrix {
-enum class MatrixTransformOperator: uint8_t;
-}
-
 class nsCSSPropertyIDSet;
 class nsCSSValue;
-struct nsFontFaceRuleContainer;
 class nsIDocument;
 class nsINode;
 class nsPresContext;
-class nsSimpleContentList;
+class nsXBLBinding;
+struct nsFontFaceRuleContainer;
 struct nsTimingFunction;
-class nsXBLBinding;
-
-using mozilla::dom::StyleChildrenIterator;
-using mozilla::ServoElementSnapshot;
-
-typedef void* RawServoAnimationValueTableBorrowed;
 
-typedef nsINode RawGeckoNode;
-typedef mozilla::dom::Element RawGeckoElement;
-typedef nsIDocument RawGeckoDocument;
-typedef nsPresContext RawGeckoPresContext;
-typedef nsXBLBinding RawGeckoXBLBinding;
-typedef mozilla::URLExtraData RawGeckoURLExtraData;
-typedef nsTArray<RefPtr<RawServoAnimationValue>> RawGeckoServoAnimationValueList;
-typedef nsTArray<mozilla::Keyframe> RawGeckoKeyframeList;
-typedef nsTArray<mozilla::PropertyValuePair> RawGeckoPropertyValuePairList;
-typedef nsTArray<mozilla::ComputedKeyframeValues> RawGeckoComputedKeyframeValuesList;
-typedef nsStyleAutoArray<mozilla::StyleAnimation> RawGeckoStyleAnimationList;
-typedef nsTArray<nsFontFaceRuleContainer> RawGeckoFontFaceRuleList;
-typedef mozilla::AnimationPropertySegment RawGeckoAnimationPropertySegment;
-typedef mozilla::ComputedTiming RawGeckoComputedTiming;
-typedef nsTArray<const RawServoStyleRule*> RawGeckoServoStyleRuleList;
-typedef nsTArray<nsCSSPropertyID> RawGeckoCSSPropertyIDList;
-typedef mozilla::gfx::Float RawGeckoGfxMatrix4x4[16];
-typedef mozilla::dom::StyleChildrenIterator RawGeckoStyleChildrenIterator;
+namespace mozilla {
+class ComputedStyle;
+class ServoElementSnapshot;
+struct AnimationPropertySegment;
+struct ComputedTiming;
+struct Keyframe;
+struct PropertyStyleAnimationValuePair;
+struct PropertyValuePair;
+struct StyleAnimation;
+struct URLExtraData;
+using ComputedKeyframeValues = nsTArray<PropertyStyleAnimationValuePair>;
+using GfxMatrix4x4 = mozilla::gfx::Float[16];
 
-// A callback that can be sent via FFI which will be invoked _right before_
-// being mutated, and at most once.
-struct DeclarationBlockMutationClosure
-{
-  // The callback function. The argument is `data`.
-  void (*function)(void*) = nullptr;
-  void* data = nullptr;
-};
+namespace dom {
+class StyleChildrenIterator;
+class Element;
+} // namespace dom
+} // namespace mozilla
 
-// We have these helper types so that we can directly generate
-// things like &T or Borrowed<T> on the Rust side in the function, providing
-// additional safety benefits.
-//
-// FFI has a problem with templated types, so we just use raw pointers here.
-//
-// The "Borrowed" types generate &T or Borrowed<T> in the nullable case.
-//
-// The "Owned" types generate Owned<T> or OwnedOrNull<T>. Some of these
-// are Servo-managed and can be converted to Box<ServoType> on the
-// Servo side.
-//
-// The "Arc" types are Servo-managed Arc<ServoType>s, which are passed
-// over FFI as Strong<T> (which is nullable).
-// Note that T != ServoType, rather T is ArcInner<ServoType>
 #define DECL_BORROWED_REF_TYPE_FOR(type_) typedef type_ const* type_##Borrowed;
 #define DECL_NULLABLE_BORROWED_REF_TYPE_FOR(type_) typedef type_ const* type_##BorrowedOrNull;
 #define DECL_BORROWED_MUT_REF_TYPE_FOR(type_) typedef type_* type_##BorrowedMut;
 #define DECL_NULLABLE_BORROWED_MUT_REF_TYPE_FOR(type_) typedef type_* type_##BorrowedMutOrNull;
 
-#define SERVO_ARC_TYPE(name_, type_)         \
-  DECL_NULLABLE_BORROWED_REF_TYPE_FOR(type_) \
-  DECL_BORROWED_REF_TYPE_FOR(type_)          \
-  DECL_BORROWED_MUT_REF_TYPE_FOR(type_)      \
-  struct MOZ_MUST_USE_TYPE type_##Strong     \
-  {                                          \
-    type_* mPtr;                             \
-    already_AddRefed<type_> Consume();       \
-  };
-#include "mozilla/ServoArcTypeList.h"
-#undef SERVO_ARC_TYPE
-
-typedef mozilla::ComputedStyle const* ComputedStyleBorrowed;
-typedef mozilla::ComputedStyle const* ComputedStyleBorrowedOrNull;
-typedef ServoComputedData const* ServoComputedDataBorrowed;
-
-struct MOZ_MUST_USE_TYPE ComputedStyleStrong
-{
-  mozilla::ComputedStyle* mPtr;
-  already_AddRefed<mozilla::ComputedStyle> Consume();
-};
-
 #define DECL_OWNED_REF_TYPE_FOR(type_)    \
   typedef type_* type_##Owned;            \
   DECL_BORROWED_REF_TYPE_FOR(type_)       \
   DECL_BORROWED_MUT_REF_TYPE_FOR(type_)
 
 #define DECL_NULLABLE_OWNED_REF_TYPE_FOR(type_)    \
   typedef type_* type_##OwnedOrNull;               \
   DECL_NULLABLE_BORROWED_REF_TYPE_FOR(type_)       \
   DECL_NULLABLE_BORROWED_MUT_REF_TYPE_FOR(type_)
 
-// This is a reference to a reference of RawServoDeclarationBlock, which
-// corresponds to Option<&Arc<Locked<RawServoDeclarationBlock>>> in Servo side.
-DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawServoDeclarationBlockStrong)
-DECL_OWNED_REF_TYPE_FOR(RawServoAuthorStyles)
-DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawServoAuthorStyles)
-DECL_OWNED_REF_TYPE_FOR(RawServoStyleSet)
-DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawServoStyleSet)
-DECL_NULLABLE_OWNED_REF_TYPE_FOR(StyleChildrenIterator)
-DECL_OWNED_REF_TYPE_FOR(StyleChildrenIterator)
-DECL_OWNED_REF_TYPE_FOR(ServoElementSnapshot)
-DECL_OWNED_REF_TYPE_FOR(RawServoAnimationValueMap)
-
-// We don't use BorrowedMut because the nodes may alias
-// Servo itself doesn't directly read or mutate these;
-// it only asks Gecko to do so. In case we wish to in
-// the future, we should ensure that things being mutated
-// are protected from noalias violations by a cell type
-DECL_BORROWED_REF_TYPE_FOR(RawGeckoNode)
-DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawGeckoNode)
-DECL_BORROWED_REF_TYPE_FOR(RawGeckoElement)
-DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawGeckoElement)
-DECL_BORROWED_REF_TYPE_FOR(RawGeckoDocument)
-DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawGeckoDocument)
-DECL_BORROWED_REF_TYPE_FOR(RawGeckoXBLBinding)
-DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawGeckoXBLBinding)
-DECL_BORROWED_MUT_REF_TYPE_FOR(StyleChildrenIterator)
-DECL_BORROWED_MUT_REF_TYPE_FOR(ServoElementSnapshot)
-DECL_BORROWED_REF_TYPE_FOR(nsCSSValue)
-DECL_BORROWED_MUT_REF_TYPE_FOR(nsCSSValue)
-DECL_OWNED_REF_TYPE_FOR(RawGeckoPresContext)
-DECL_BORROWED_REF_TYPE_FOR(RawGeckoPresContext)
-DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoServoAnimationValueList)
-DECL_BORROWED_REF_TYPE_FOR(RawGeckoServoAnimationValueList)
-DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoKeyframeList)
-DECL_BORROWED_REF_TYPE_FOR(RawGeckoKeyframeList)
-DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoPropertyValuePairList)
-DECL_BORROWED_REF_TYPE_FOR(RawGeckoPropertyValuePairList)
-DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoComputedKeyframeValuesList)
-DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoStyleAnimationList)
-DECL_BORROWED_REF_TYPE_FOR(RawGeckoStyleAnimationList)
-DECL_BORROWED_MUT_REF_TYPE_FOR(nsTimingFunction)
-DECL_BORROWED_REF_TYPE_FOR(nsTimingFunction)
-DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoFontFaceRuleList)
-DECL_BORROWED_REF_TYPE_FOR(RawGeckoAnimationPropertySegment)
-DECL_BORROWED_REF_TYPE_FOR(RawGeckoComputedTiming)
-DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoServoStyleRuleList)
-DECL_BORROWED_MUT_REF_TYPE_FOR(nsCSSPropertyIDSet)
-DECL_BORROWED_REF_TYPE_FOR(RawGeckoCSSPropertyIDList)
-DECL_BORROWED_REF_TYPE_FOR(nsXBLBinding)
-DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoStyleChildrenIterator)
-DECL_OWNED_REF_TYPE_FOR(RawServoSelectorList)
-DECL_BORROWED_REF_TYPE_FOR(RawServoSelectorList)
-DECL_OWNED_REF_TYPE_FOR(RawServoSourceSizeList)
-DECL_BORROWED_REF_TYPE_FOR(RawServoSourceSizeList)
-DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawServoSourceSizeList)
-DECL_OWNED_REF_TYPE_FOR(StyleUseCounters)
-DECL_NULLABLE_OWNED_REF_TYPE_FOR(StyleUseCounters)
-DECL_BORROWED_REF_TYPE_FOR(StyleUseCounters)
-DECL_NULLABLE_BORROWED_REF_TYPE_FOR(StyleUseCounters)
-
-#undef DECL_ARC_REF_TYPE_FOR
-#undef DECL_OWNED_REF_TYPE_FOR
-#undef DECL_NULLABLE_OWNED_REF_TYPE_FOR
-#undef DECL_BORROWED_REF_TYPE_FOR
-#undef DECL_NULLABLE_BORROWED_REF_TYPE_FOR
-#undef DECL_BORROWED_MUT_REF_TYPE_FOR
-#undef DECL_NULLABLE_BORROWED_MUT_REF_TYPE_FOR
+#define GECKO_BORROWED_TYPE(geckotype_, ffitype_)      \
+  using ffitype_ = geckotype_;                         \
+  using ffitype_##Borrowed = const ffitype_*;          \
+  using ffitype_##BorrowedOrNull = const ffitype_*;
+#define GECKO_BORROWED_TYPE_MUT(geckotype_, ffitype_)  \
+  GECKO_BORROWED_TYPE(geckotype_, ffitype_)            \
+  using ffitype_##BorrowedMut = ffitype_*;             \
+  using ffitype_##BorrowedMutOrNull = ffitype_*;
+#include "mozilla/BorrowedTypeList.h"
+#undef GECKO_BORROWED_TYPE_MUT
+#undef GECKO_BORROWED_TYPE
 
 #define SERVO_ARC_TYPE(name_, type_)                 \
+  DECL_NULLABLE_BORROWED_REF_TYPE_FOR(type_)         \
+  DECL_BORROWED_REF_TYPE_FOR(type_)                  \
+  DECL_BORROWED_MUT_REF_TYPE_FOR(type_)              \
+  struct MOZ_MUST_USE_TYPE type_##Strong             \
+  {                                                  \
+    type_* mPtr;                                     \
+    already_AddRefed<type_> Consume();               \
+  };                                                 \
   extern "C" {                                       \
   void Servo_##name_##_AddRef(type_##Borrowed ptr);  \
   void Servo_##name_##_Release(type_##Borrowed ptr); \
   }                                                  \
   namespace mozilla {                                \
   template<> struct RefPtrTraits<type_> {            \
     static void AddRef(type_* aPtr) {                \
       Servo_##name_##_AddRef(aPtr);                  \
@@ -226,38 +242,69 @@ DECL_NULLABLE_BORROWED_REF_TYPE_FOR(Styl
     static void Release(type_* aPtr) {               \
       Servo_##name_##_Release(aPtr);                 \
     }                                                \
   };                                                 \
   }
 #include "mozilla/ServoArcTypeList.h"
 #undef SERVO_ARC_TYPE
 
-#define DEFINE_BOXED_TYPE(name_, type_)                     \
+#define SERVO_BOXED_TYPE(name_, type_)                      \
+  DECL_OWNED_REF_TYPE_FOR(type_)                            \
+  DECL_NULLABLE_OWNED_REF_TYPE_FOR(type_)                   \
   extern "C" void Servo_##name_##_Drop(type_##Owned ptr);   \
   namespace mozilla {                                       \
   template<>                                                \
   class DefaultDelete<type_>                                \
   {                                                         \
   public:                                                   \
     void operator()(type_* aPtr) const                      \
     {                                                       \
       Servo_##name_##_Drop(aPtr);                           \
     }                                                       \
   };                                                        \
   }
+#include "mozilla/ServoBoxedTypeList.h"
+#undef SERVO_BOXED_TYPE
 
-DEFINE_BOXED_TYPE(StyleSet, RawServoStyleSet);
-DEFINE_BOXED_TYPE(AuthorStyles, RawServoAuthorStyles);
-DEFINE_BOXED_TYPE(SelectorList, RawServoSelectorList);
-DEFINE_BOXED_TYPE(SourceSizeList, RawServoSourceSizeList);
-DEFINE_BOXED_TYPE(UseCounters, StyleUseCounters);
+#define DEFINE_ARRAY_TYPE_FOR(type_)                                \
+  struct nsTArrayBorrowed_##type_ {                                 \
+    nsTArray<type_>* mArray;                                        \
+    MOZ_IMPLICIT nsTArrayBorrowed_##type_(nsTArray<type_>* aArray)  \
+      : mArray(aArray) {}                                           \
+  }
+DEFINE_ARRAY_TYPE_FOR(uintptr_t);
+#undef DEFINE_ARRAY_TYPE_FOR
+
+
+// Other special cases.
 
-#undef DEFINE_BOXED_TYPE
+typedef void* RawServoAnimationValueTableBorrowed;
+
+// TODO(heycam): Handle these elsewhere.
+struct RawServoAnimationValueMap;
+DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawServoAnimationValueMap)
+DECL_BORROWED_REF_TYPE_FOR(RawServoAnimationValueMap)
+DECL_BORROWED_MUT_REF_TYPE_FOR(RawServoAnimationValueMap)
 
-// used for associating sheet type with specific @font-face rules
-struct nsFontFaceRuleContainer
+typedef mozilla::ComputedStyle const* ComputedStyleBorrowed;
+typedef mozilla::ComputedStyle const* ComputedStyleBorrowedOrNull;
+typedef ServoComputedData const* ServoComputedDataBorrowed;
+
+struct MOZ_MUST_USE_TYPE ComputedStyleStrong
 {
-  RefPtr<RawServoFontFaceRule> mRule;
-  mozilla::SheetType mSheetType;
+  mozilla::ComputedStyle* mPtr;
+  already_AddRefed<mozilla::ComputedStyle> Consume();
 };
 
+// This is a reference to a reference of RawServoDeclarationBlock, which
+// corresponds to Option<&Arc<Locked<RawServoDeclarationBlock>>> in Servo side.
+DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawServoDeclarationBlockStrong)
+
+#undef DECL_ARC_REF_TYPE_FOR
+#undef DECL_OWNED_REF_TYPE_FOR
+#undef DECL_NULLABLE_OWNED_REF_TYPE_FOR
+#undef DECL_BORROWED_REF_TYPE_FOR
+#undef DECL_NULLABLE_BORROWED_REF_TYPE_FOR
+#undef DECL_BORROWED_MUT_REF_TYPE_FOR
+#undef DECL_NULLABLE_BORROWED_MUT_REF_TYPE_FOR
+
 #endif // mozilla_ServoBindingTypes_h
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -1,756 +1,1183 @@
 /* -*- 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/. */
 
+/* FFI functions for Gecko to call into Servo */
+
 #ifndef mozilla_ServoBindings_h
 #define mozilla_ServoBindings_h
 
 #include <stdint.h>
 
 #include "mozilla/AtomArray.h"
-#include "mozilla/ServoTypes.h"
-#include "mozilla/ServoBindingTypes.h"
-#include "mozilla/ServoComputedDataInlines.h"
-#include "mozilla/ServoElementSnapshot.h"
-#include "mozilla/css/DocumentMatchingFunction.h"
 #include "mozilla/css/SheetLoadData.h"
 #include "mozilla/css/SheetParsingMode.h"
-#include "mozilla/EffectCompositor.h"
-#include "mozilla/ComputedTimingFunction.h"
+#include "mozilla/ServoBindingTypes.h"
 #include "nsChangeHint.h"
-#include "nsIDocument.h"
+#include "nsColor.h"
+#include "nsCSSValue.h"
 
-/*
- * API for Servo to access Gecko data structures.
- *
- * Functions beginning with Gecko_ are implemented in Gecko and invoked from Servo.
- * Functions beginning with Servo_ are implemented in Servo and invoked from Gecko.
- */
-
+class gfxFontFeatureValueSet;
 class nsAtom;
-class nsIPrincipal;
-class nsIURI;
-struct nsFont;
+class nsSimpleContentList;
+struct gfxFontFeature;
+
 namespace mozilla {
-  class FontFamilyList;
-  struct FontFamilyName;
-  enum FontFamilyType : uint8_t;
+  class SeenPtrs;
+  class ServoElementSnapshotTable;
   class SharedFontList;
+  class StyleSheet;
   enum class CSSPseudoElementType : uint8_t;
+  enum class OriginFlags : uint8_t;
   struct Keyframe;
-  struct StyleTransition;
+
   namespace css {
-    class ErrorReporter;
-    struct URLValue;
     class LoaderReusableStyleSheets;
-  };
+  }
+
+  namespace gfx {
+    struct FontVariation;
+  }
+
   namespace dom {
     enum class IterationCompositeOperation : uint8_t;
-  };
-  enum class UpdateAnimationsTasks : uint8_t;
-  struct LangGroupFontPrefs;
-  class SeenPtrs;
-  class ComputedStyle;
-  class StyleSheet;
-  class ServoElementSnapshotTable;
-  enum class PointerCapabilities : uint8_t;
+  }
 }
-using mozilla::FontFamilyList;
-using mozilla::FontFamilyName;
-using mozilla::FontFamilyType;
-using mozilla::ServoElementSnapshot;
-using mozilla::SharedFontList;
-struct nsMediaFeature;
-class nsSimpleContentList;
-struct nsStyleList;
-struct nsStyleImage;
-struct nsStyleGradientStop;
-class nsStyleGradient;
-class nsStyleCoord;
-struct nsStyleDisplay;
-class nsXBLBinding;
-
-#ifdef NIGHTLY_BUILD
-const bool GECKO_IS_NIGHTLY = true;
-#else
-const bool GECKO_IS_NIGHTLY = false;
-#endif
 
-#define NS_DECL_THREADSAFE_FFI_REFCOUNTING(class_, name_)                     \
-  void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr);                    \
-  void Gecko_Release##name_##ArbitraryThread(class_* aPtr);
-#define NS_IMPL_THREADSAFE_FFI_REFCOUNTING(class_, name_)                     \
-  static_assert(class_::HasThreadSafeRefCnt::value,                           \
-                "NS_DECL_THREADSAFE_FFI_REFCOUNTING can only be used with "   \
-                "classes that have thread-safe refcounting");                 \
-  void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr)                     \
-  { NS_ADDREF(aPtr); }                                                        \
-  void Gecko_Release##name_##ArbitraryThread(class_* aPtr)                    \
-  { NS_RELEASE(aPtr); }
-
-#define NS_DECL_FFI_REFCOUNTING(class_, name_)  \
-  void Gecko_##name_##_AddRef(class_* aPtr);    \
-  void Gecko_##name_##_Release(class_* aPtr);
-#define NS_IMPL_FFI_REFCOUNTING(class_, name_)                    \
-  void Gecko_##name_##_AddRef(class_* aPtr)                       \
-    { MOZ_ASSERT(NS_IsMainThread()); NS_ADDREF(aPtr); }           \
-  void Gecko_##name_##_Release(class_* aPtr)                      \
-    { MOZ_ASSERT(NS_IsMainThread()); NS_RELEASE(aPtr); }
-
-#define DEFINE_ARRAY_TYPE_FOR(type_)                                \
-  struct nsTArrayBorrowed_##type_ {                                 \
-    nsTArray<type_>* mArray;                                        \
-    MOZ_IMPLICIT nsTArrayBorrowed_##type_(nsTArray<type_>* aArray)  \
-      : mArray(aArray) {}                                           \
-  }
-DEFINE_ARRAY_TYPE_FOR(uintptr_t);
-#undef DEFINE_ARRAY_TYPE_FOR
+namespace nsStyleTransformMatrix {
+  enum class MatrixTransformOperator: uint8_t;
+}
 
 extern "C" {
 
-class ServoBundledURI
-{
-public:
-  // NOTE(emilio): Not calling IntoCssUrl will cause to leak the
-  // string, so don't do that :)
-  already_AddRefed<mozilla::css::URLValue> IntoCssUrl(mozilla::CORSMode);
-  mozilla::ServoRawOffsetArc<RustString> mURLString;
-  mozilla::URLExtraData* mExtraData;
-};
+// Element data
+void Servo_Element_ClearData(RawGeckoElementBorrowed node);
+
+size_t Servo_Element_SizeOfExcludingThisAndCVs(
+  mozilla::MallocSizeOf malloc_size_of,
+  mozilla::MallocSizeOf malloc_enclosing_size_of,
+  mozilla::SeenPtrs* seen_ptrs,
+  RawGeckoElementBorrowed node);
+
+bool Servo_Element_HasPrimaryComputedValues(RawGeckoElementBorrowed node);
+
+ComputedStyleStrong Servo_Element_GetPrimaryComputedValues(
+  RawGeckoElementBorrowed node);
+
+bool Servo_Element_HasPseudoComputedValues(
+  RawGeckoElementBorrowed node,
+  size_t index);
 
-struct FontSizePrefs
-{
-  void CopyFrom(const mozilla::LangGroupFontPrefs&);
-  nscoord mDefaultVariableSize;
-  nscoord mDefaultFixedSize;
-  nscoord mDefaultSerifSize;
-  nscoord mDefaultSansSerifSize;
-  nscoord mDefaultMonospaceSize;
-  nscoord mDefaultCursiveSize;
-  nscoord mDefaultFantasySize;
-};
+ComputedStyleStrong Servo_Element_GetPseudoComputedValues(
+  RawGeckoElementBorrowed node,
+  size_t index);
+
+bool Servo_Element_IsDisplayNone(RawGeckoElementBorrowed element);
+bool Servo_Element_IsDisplayContents(RawGeckoElementBorrowed element);
 
-struct MediumFeaturesChangedResult {
-  bool mAffectsDocumentRules;
-  bool mAffectsNonDocumentRules;
-  bool mUsesViewportUnits;
-};
+bool Servo_Element_IsPrimaryStyleReusedViaRuleNode(
+  RawGeckoElementBorrowed element);
+
+void Servo_InvalidateStyleForDocStateChanges(
+  RawGeckoElementBorrowed root,
+  RawServoStyleSetBorrowed doc_styles,
+  const nsTArray<RawServoAuthorStylesBorrowed>* non_document_styles,
+  uint64_t aStatesChanged);
+
+// Styleset and Stylesheet management
 
-// Debugging stuff.
-void Gecko_Element_DebugListAttributes(RawGeckoElementBorrowed, nsCString*);
-void Gecko_Snapshot_DebugListAttributes(const ServoElementSnapshot*, nsCString*);
+RawServoStyleSheetContentsStrong Servo_StyleSheet_FromUTF8Bytes(
+  mozilla::css::Loader* loader,
+  mozilla::StyleSheet* gecko_stylesheet,
+  mozilla::css::SheetLoadData* load_data,
+  const nsACString* bytes,
+  mozilla::css::SheetParsingMode parsing_mode,
+  RawGeckoURLExtraData* extra_data,
+  uint32_t line_number_offset,
+  nsCompatibility quirks_mode,
+  mozilla::css::LoaderReusableStyleSheets* reusable_sheets,
+  StyleUseCountersBorrowedOrNull use_counters);
 
-bool Gecko_IsSignificantChild(RawGeckoNodeBorrowed node, bool whitespace_is_significant);
-RawGeckoNodeBorrowedOrNull Gecko_GetLastChild(RawGeckoNodeBorrowed node);
-RawGeckoNodeBorrowedOrNull Gecko_GetPreviousSibling(RawGeckoNodeBorrowed node);
-RawGeckoNodeBorrowedOrNull Gecko_GetFlattenedTreeParentNode(RawGeckoNodeBorrowed node);
-RawGeckoElementBorrowedOrNull Gecko_GetBeforeOrAfterPseudo(RawGeckoElementBorrowed element, bool is_before);
-nsTArray<nsIContent*>* Gecko_GetAnonymousContentForElement(RawGeckoElementBorrowed element);
-const nsTArray<RefPtr<nsINode>>* Gecko_GetAssignedNodes(RawGeckoElementBorrowed element);
-void Gecko_DestroyAnonymousContentList(nsTArray<nsIContent*>* anon_content);
+void Servo_StyleSheet_FromUTF8BytesAsync(
+  mozilla::css::SheetLoadDataHolder* load_data,
+  RawGeckoURLExtraData* extra_data,
+  const nsACString* bytes,
+  mozilla::css::SheetParsingMode parsing_mode,
+  uint32_t line_number_offset,
+  nsCompatibility quirks_mode,
+  bool should_record_use_counters);
+
+RawServoStyleSheetContentsStrong Servo_StyleSheet_Empty(
+  mozilla::css::SheetParsingMode parsing_mode);
+
+bool Servo_StyleSheet_HasRules(RawServoStyleSheetContentsBorrowed sheet);
 
-void Gecko_ComputedStyle_Init(mozilla::ComputedStyle* context,
-                              RawGeckoPresContextBorrowed pres_context,
-                              ServoComputedDataBorrowed values,
-                              mozilla::CSSPseudoElementType pseudo_type,
-                              nsAtom* pseudo_tag);
-void Gecko_ComputedStyle_Destroy(mozilla::ComputedStyle* context);
+ServoCssRulesStrong Servo_StyleSheet_GetRules(
+  RawServoStyleSheetContentsBorrowed sheet);
+
+RawServoStyleSheetContentsStrong Servo_StyleSheet_Clone(
+  RawServoStyleSheetContentsBorrowed sheet,
+  const mozilla::StyleSheet* reference_sheet);
+
+size_t Servo_StyleSheet_SizeOfIncludingThis(
+  mozilla::MallocSizeOf malloc_size_of,
+  mozilla::MallocSizeOf malloc_enclosing_size_of,
+  RawServoStyleSheetContentsBorrowed sheet);
 
-// By default, Servo walks the DOM by traversing the siblings of the DOM-view
-// first child. This generally works, but misses anonymous children, which we
-// want to traverse during styling. To support these cases, we create an
-// optional stack-allocated iterator in aIterator for nodes that need it.
-void Gecko_ConstructStyleChildrenIterator(RawGeckoElementBorrowed aElement,
-                                          RawGeckoStyleChildrenIteratorBorrowedMut aIterator);
-void Gecko_DestroyStyleChildrenIterator(RawGeckoStyleChildrenIteratorBorrowedMut aIterator);
-RawGeckoNodeBorrowedOrNull Gecko_GetNextStyleChild(RawGeckoStyleChildrenIteratorBorrowedMut it);
+void Servo_StyleSheet_GetSourceMapURL(
+  RawServoStyleSheetContentsBorrowed sheet,
+  nsAString* result);
+
+void Servo_StyleSheet_GetSourceURL(
+  RawServoStyleSheetContentsBorrowed sheet,
+  nsAString* result);
 
-NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::SheetLoadDataHolder, SheetLoadDataHolder);
+// We'd like to return `OriginFlags` here, but bindgen bitfield enums don't
+// work as return values with the Linux 32-bit ABI at the moment because
+// they wrap the value in a struct.
+uint8_t Servo_StyleSheet_GetOrigin(RawServoStyleSheetContentsBorrowed sheet);
 
-void Gecko_StyleSheet_FinishAsyncParse(mozilla::css::SheetLoadDataHolder* data,
-                                       RawServoStyleSheetContentsStrong sheet_contents,
-                                       StyleUseCountersOwnedOrNull use_counters);
+RawServoStyleSet* Servo_StyleSet_Init(RawGeckoPresContextBorrowed pres_context);
+void Servo_StyleSet_RebuildCachedData(RawServoStyleSetBorrowed set);
 
-mozilla::StyleSheet*
-Gecko_LoadStyleSheet(mozilla::css::Loader* loader,
-                     mozilla::StyleSheet* parent,
-                     mozilla::css::SheetLoadData* parent_load_data,
-                     mozilla::css::LoaderReusableStyleSheets* reusable_sheets,
-                     ServoBundledURI url,
-                     RawServoMediaListStrong media_list);
+// We'd like to return `OriginFlags` here, but bindgen bitfield enums don't
+// work as return values with the Linux 32-bit ABI at the moment because
+// they wrap the value in a struct.
+mozilla::MediumFeaturesChangedResult Servo_StyleSet_MediumFeaturesChanged(
+  RawServoStyleSetBorrowed document_set,
+  nsTArray<RawServoAuthorStylesBorrowedMut>* non_document_sets,
+  bool may_affect_default_style);
+
+void Servo_StyleSet_Drop(RawServoStyleSetOwned set);
+void Servo_StyleSet_CompatModeChanged(RawServoStyleSetBorrowed raw_data);
+
+void Servo_StyleSet_AppendStyleSheet(
+  RawServoStyleSetBorrowed set,
+  const mozilla::StyleSheet* gecko_sheet);
+
+void Servo_StyleSet_PrependStyleSheet(
+  RawServoStyleSetBorrowed set,
+  const mozilla::StyleSheet* gecko_sheet);
 
-void
-Gecko_LoadStyleSheetAsync(mozilla::css::SheetLoadDataHolder* parent_data,
-                          ServoBundledURI url,
-                          RawServoMediaListStrong media_list,
-                          RawServoImportRuleStrong import_rule);
+void Servo_StyleSet_RemoveStyleSheet(
+  RawServoStyleSetBorrowed set,
+  const mozilla::StyleSheet* gecko_sheet);
+
+void Servo_StyleSet_InsertStyleSheetBefore(
+  RawServoStyleSetBorrowed set,
+  const mozilla::StyleSheet* gecko_sheet,
+  const mozilla::StyleSheet* before);
 
-// Selector Matching.
-uint64_t Gecko_ElementState(RawGeckoElementBorrowed element);
-bool Gecko_IsRootElement(RawGeckoElementBorrowed element);
-bool Gecko_MatchLang(RawGeckoElementBorrowed element,
-                     nsAtom* override_lang, bool has_override_lang,
-                     const char16_t* value);
-nsAtom* Gecko_GetXMLLangValue(RawGeckoElementBorrowed element);
-nsIDocument::DocumentTheme Gecko_GetDocumentLWTheme(const nsIDocument* aDocument);
-bool Gecko_IsTableBorderNonzero(RawGeckoElementBorrowed element);
-bool Gecko_IsBrowserFrame(RawGeckoElementBorrowed element);
+void Servo_StyleSet_FlushStyleSheets(
+  RawServoStyleSetBorrowed set,
+  RawGeckoElementBorrowedOrNull doc_elem,
+  const mozilla::ServoElementSnapshotTable* snapshots);
+
+void Servo_StyleSet_SetAuthorStyleDisabled(
+  RawServoStyleSetBorrowed set,
+  bool author_style_disabled);
+
+void Servo_StyleSet_NoteStyleSheetsChanged(
+  RawServoStyleSetBorrowed set,
+  mozilla::OriginFlags changed_origins);
 
-// Attributes.
-#define SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(prefix_, implementor_)  \
-  nsAtom* prefix_##LangValue(implementor_ element);                           \
-  bool prefix_##HasAttr(implementor_ element, nsAtom* ns, nsAtom* name);      \
-  bool prefix_##AttrEquals(implementor_ element, nsAtom* ns, nsAtom* name,    \
-                           nsAtom* str, bool ignoreCase);                     \
-  bool prefix_##AttrDashEquals(implementor_ element, nsAtom* ns,              \
-                               nsAtom* name, nsAtom* str, bool ignore_case);  \
-  bool prefix_##AttrIncludes(implementor_ element, nsAtom* ns,                \
-                             nsAtom* name, nsAtom* str, bool ignore_case);    \
-  bool prefix_##AttrHasSubstring(implementor_ element, nsAtom* ns,            \
-                                 nsAtom* name, nsAtom* str,                   \
-                                 bool ignore_case);                           \
-  bool prefix_##AttrHasPrefix(implementor_ element, nsAtom* ns,               \
-                              nsAtom* name, nsAtom* str, bool ignore_case);   \
-  bool prefix_##AttrHasSuffix(implementor_ element, nsAtom* ns,               \
-                              nsAtom* name, nsAtom* str, bool ignore_case);
+bool Servo_StyleSet_GetKeyframesForName(
+  RawServoStyleSetBorrowed set,
+  RawGeckoElementBorrowed element,
+  ComputedStyleBorrowed style,
+  nsAtom* name,
+  nsTimingFunctionBorrowed timing_function,
+  RawGeckoKeyframeListBorrowedMut keyframe_list);
+
+void Servo_StyleSet_GetFontFaceRules(
+  RawServoStyleSetBorrowed set,
+  RawGeckoFontFaceRuleListBorrowedMut list);
 
-bool Gecko_AssertClassAttrValueIsSane(const nsAttrValue*);
-const nsAttrValue* Gecko_GetSVGAnimatedClass(RawGeckoElementBorrowed);
+const RawServoCounterStyleRule* Servo_StyleSet_GetCounterStyleRule(
+  RawServoStyleSetBorrowed set,
+  nsAtom* name);
 
+// This function may return nullptr or gfxFontFeatureValueSet with zero
+// references.
+gfxFontFeatureValueSet* Servo_StyleSet_BuildFontFeatureValueSet(
+  RawServoStyleSetBorrowed set);
+
+ComputedStyleStrong Servo_StyleSet_ResolveForDeclarations(
+  RawServoStyleSetBorrowed set,
+  ComputedStyleBorrowedOrNull parent_style,
+  RawServoDeclarationBlockBorrowed declarations);
 
-SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_, RawGeckoElementBorrowed)
-SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_Snapshot,
-                                              const ServoElementSnapshot*)
+void Servo_SelectorList_Drop(RawServoSelectorListOwned selector_list);
+RawServoSelectorList* Servo_SelectorList_Parse(const nsACString* selector_list);
+RawServoSourceSizeList* Servo_SourceSizeList_Parse(const nsACString* value);
 
-#undef SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS
+int32_t Servo_SourceSizeList_Evaluate(
+  RawServoStyleSetBorrowed set,
+  RawServoSourceSizeListBorrowedOrNull);
+
+void Servo_SourceSizeList_Drop(RawServoSourceSizeListOwned);
+
+bool Servo_SelectorList_Matches(
+  RawGeckoElementBorrowed,
+  RawServoSelectorListBorrowed);
 
-// Style attributes.
-RawServoDeclarationBlockStrongBorrowedOrNull
-Gecko_GetStyleAttrDeclarationBlock(RawGeckoElementBorrowed element);
-void Gecko_UnsetDirtyStyleAttr(RawGeckoElementBorrowed element);
-RawServoDeclarationBlockStrongBorrowedOrNull
-Gecko_GetHTMLPresentationAttrDeclarationBlock(RawGeckoElementBorrowed element);
-RawServoDeclarationBlockStrongBorrowedOrNull
-Gecko_GetExtraContentStyleDeclarations(RawGeckoElementBorrowed element);
-RawServoDeclarationBlockStrongBorrowedOrNull
-Gecko_GetUnvisitedLinkAttrDeclarationBlock(RawGeckoElementBorrowed element);
-RawServoDeclarationBlockStrongBorrowedOrNull
-Gecko_GetVisitedLinkAttrDeclarationBlock(RawGeckoElementBorrowed element);
-RawServoDeclarationBlockStrongBorrowedOrNull
-Gecko_GetActiveLinkAttrDeclarationBlock(RawGeckoElementBorrowed element);
+const RawGeckoElement* Servo_SelectorList_Closest(
+  RawGeckoElementBorrowed,
+  RawServoSelectorListBorrowed);
 
-// Visited handling.
+const RawGeckoElement* Servo_SelectorList_QueryFirst(
+  RawGeckoNodeBorrowed,
+  RawServoSelectorListBorrowed,
+  bool may_use_invalidation);
 
-// Returns whether visited styles are enabled for a given document.
-bool Gecko_VisitedStylesEnabled(const nsIDocument*);
+void Servo_SelectorList_QueryAll(
+  RawGeckoNodeBorrowed,
+  RawServoSelectorListBorrowed,
+  nsSimpleContentList* content_list,
+  bool may_use_invalidation);
 
-// Animations
-bool
-Gecko_GetAnimationRule(RawGeckoElementBorrowed aElementOrPseudo,
-                       mozilla::EffectCompositor::CascadeLevel aCascadeLevel,
-                       RawServoAnimationValueMapBorrowedMut aAnimationValues);
-bool Gecko_StyleAnimationsEquals(RawGeckoStyleAnimationListBorrowed,
-                                 RawGeckoStyleAnimationListBorrowed);
-void Gecko_CopyAnimationNames(RawGeckoStyleAnimationListBorrowedMut aDest,
-                              RawGeckoStyleAnimationListBorrowed aSrc);
-// This function takes an already addrefed nsAtom
-void Gecko_SetAnimationName(mozilla::StyleAnimation* aStyleAnimation,
-                            nsAtom* aAtom);
-void Gecko_UpdateAnimations(RawGeckoElementBorrowed aElementOrPseudo,
-                            ComputedStyleBorrowedOrNull aOldComputedValues,
-                            ComputedStyleBorrowedOrNull aComputedValues,
-                            mozilla::UpdateAnimationsTasks aTasks);
-size_t Gecko_GetAnimationEffectCount(RawGeckoElementBorrowed aElementOrPseudo);
-bool Gecko_ElementHasAnimations(RawGeckoElementBorrowed aElementOrPseudo);
-bool Gecko_ElementHasCSSAnimations(RawGeckoElementBorrowed aElementOrPseudo);
-bool Gecko_ElementHasCSSTransitions(RawGeckoElementBorrowed aElementOrPseudo);
-size_t Gecko_ElementTransitions_Length(RawGeckoElementBorrowed aElementOrPseudo);
-nsCSSPropertyID Gecko_ElementTransitions_PropertyAt(
-  RawGeckoElementBorrowed aElementOrPseudo,
-  size_t aIndex);
-RawServoAnimationValueBorrowedOrNull Gecko_ElementTransitions_EndValueAt(
-  RawGeckoElementBorrowed aElementOrPseudo,
-  size_t aIndex);
-double Gecko_GetProgressFromComputedTiming(RawGeckoComputedTimingBorrowed aComputedTiming);
-double Gecko_GetPositionInSegment(
-  RawGeckoAnimationPropertySegmentBorrowed aSegment,
-  double aProgress,
-  mozilla::ComputedTimingFunction::BeforeFlag aBeforeFlag);
-// Get servo's AnimationValue for |aProperty| from the cached base style
-// |aBaseStyles|.
-// |aBaseStyles| is nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>.
-// We use RawServoAnimationValueTableBorrowed to avoid exposing nsRefPtrHashtable in FFI.
-RawServoAnimationValueBorrowedOrNull Gecko_AnimationGetBaseStyle(
-  RawServoAnimationValueTableBorrowed aBaseStyles,
-  nsCSSPropertyID aProperty);
-void Gecko_StyleTransition_SetUnsupportedProperty(
-  mozilla::StyleTransition* aTransition,
-  nsAtom* aAtom);
+void Servo_StyleSet_AddSizeOfExcludingThis(
+  mozilla::MallocSizeOf malloc_size_of,
+  mozilla::MallocSizeOf malloc_enclosing_size_of,
+  mozilla::ServoStyleSetSizes* sizes,
+  RawServoStyleSetBorrowed set);
+
+void Servo_UACache_AddSizeOf(
+  mozilla::MallocSizeOf malloc_size_of,
+  mozilla::MallocSizeOf malloc_enclosing_size_of,
+  mozilla::ServoStyleSetSizes* sizes);
+
+// AuthorStyles
+
+RawServoAuthorStyles* Servo_AuthorStyles_Create();
+void Servo_AuthorStyles_Drop(RawServoAuthorStylesOwned self);
+
+// TODO(emilio): These will need to take a master style set to implement
+// invalidation for Shadow DOM.
+void Servo_AuthorStyles_AppendStyleSheet(
+  RawServoAuthorStylesBorrowedMut self,
+  const mozilla::StyleSheet* gecko_sheet);
+
+void Servo_AuthorStyles_RemoveStyleSheet(
+  RawServoAuthorStylesBorrowedMut self,
+  const mozilla::StyleSheet* gecko_sheet);
+
+void Servo_AuthorStyles_InsertStyleSheetBefore(
+  RawServoAuthorStylesBorrowedMut self,
+  const mozilla::StyleSheet* gecko_sheet,
+  const mozilla::StyleSheet* before);
+
+void Servo_AuthorStyles_ForceDirty(RawServoAuthorStylesBorrowedMut self);
+
+// TODO(emilio): This will need to take an element and a master style set to
+// implement invalidation for Shadow DOM.
+void Servo_AuthorStyles_Flush(
+  RawServoAuthorStylesBorrowedMut self,
+  RawServoStyleSetBorrowed document_styles);
+
+size_t Servo_AuthorStyles_SizeOfIncludingThis(
+  mozilla::MallocSizeOf malloc_size_of,
+  mozilla::MallocSizeOf malloc_enclosing_size_of,
+  RawServoAuthorStylesBorrowed self);
 
-// Atoms.
-nsAtom* Gecko_Atomize(const char* aString, uint32_t aLength);
-nsAtom* Gecko_Atomize16(const nsAString* aString);
-void Gecko_AddRefAtom(nsAtom* aAtom);
-void Gecko_ReleaseAtom(nsAtom* aAtom);
+void Servo_ComputedStyle_AddRef(ComputedStyleBorrowed ctx);
+
+void Servo_ComputedStyle_Release(ComputedStyleBorrowed ctx);
+
+bool Servo_StyleSet_MightHaveAttributeDependency(
+  RawServoStyleSetBorrowed set,
+  RawGeckoElementBorrowed element,
+  nsAtom* local_name);
+
+bool Servo_StyleSet_HasStateDependency(
+  RawServoStyleSetBorrowed set,
+  RawGeckoElementBorrowed element,
+  uint64_t state);
+
+bool Servo_StyleSet_HasDocumentStateDependency(
+  RawServoStyleSetBorrowed set,
+  uint64_t state);
+
+// CSSRuleList
 
-// Font style
-void Gecko_CopyFontFamilyFrom(nsFont* dst, const nsFont* src);
-void Gecko_nsTArray_FontFamilyName_AppendNamed(nsTArray<FontFamilyName>* aNames, nsAtom* aName, bool aQuoted);
-void Gecko_nsTArray_FontFamilyName_AppendGeneric(nsTArray<FontFamilyName>* aNames, FontFamilyType aType);
-// Returns an already-AddRefed SharedFontList with an empty mNames array.
-SharedFontList* Gecko_SharedFontList_Create();
-size_t Gecko_SharedFontList_SizeOfIncludingThis(SharedFontList* fontlist);
-size_t Gecko_SharedFontList_SizeOfIncludingThisIfUnshared(SharedFontList* fontlist);
-NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::SharedFontList, SharedFontList);
-// will not run destructors on dst, give it uninitialized memory
-// font_id is LookAndFeel::FontID
-void Gecko_nsFont_InitSystem(nsFont* dst, int32_t font_id,
-                             const nsStyleFont* font, RawGeckoPresContextBorrowed pres_context);
-void Gecko_nsFont_Destroy(nsFont* dst);
+void Servo_CssRules_ListTypes(
+  ServoCssRulesBorrowed rules,
+  nsTArrayBorrowed_uintptr_t result);
 
-// The gfxFontFeatureValueSet returned from this function has zero reference.
-gfxFontFeatureValueSet* Gecko_ConstructFontFeatureValueSet();
-nsTArray<unsigned int>* Gecko_AppendFeatureValueHashEntry(
-  gfxFontFeatureValueSet* value_set, nsAtom* family, uint32_t alternate, nsAtom* name);
-void Gecko_nsFont_SetFontFeatureValuesLookup(nsFont* font,
-                                             const RawGeckoPresContext* pres_context);
-void Gecko_nsFont_ResetFontFeatureValuesLookup(nsFont* font);
+nsresult Servo_CssRules_InsertRule(
+  ServoCssRulesBorrowed rules,
+  RawServoStyleSheetContentsBorrowed sheet,
+  const nsACString* rule,
+  uint32_t index,
+  bool nested,
+  mozilla::css::Loader* loader,
+  mozilla::StyleSheet* gecko_stylesheet,
+  uint16_t* rule_type);
+
+nsresult Servo_CssRules_DeleteRule(ServoCssRulesBorrowed rules, uint32_t index);
+
+// CSS Rules
+
+#define BASIC_RULE_FUNCS_WITHOUT_GETTER(type_)                             \
+  void Servo_##type_##_Debug(                                              \
+    RawServo##type_##Borrowed rule,                                        \
+    nsACString* result);                                                   \
+  void Servo_##type_##_GetCssText(                                         \
+    RawServo##type_##Borrowed rule,                                        \
+    nsAString* result);
 
-// Font variant alternates
-void Gecko_ClearAlternateValues(nsFont* font, size_t length);
-void Gecko_AppendAlternateValues(nsFont* font, uint32_t alternate_name, nsAtom* atom);
-void Gecko_CopyAlternateValuesFrom(nsFont* dest, const nsFont* src);
+#define BASIC_RULE_FUNCS(type_)                                           \
+  RawServo##type_##RuleStrong Servo_CssRules_Get##type_##RuleAt(          \
+    ServoCssRulesBorrowed rules,                                          \
+    uint32_t index,                                                       \
+    uint32_t* line,                                                       \
+    uint32_t* column);                                                    \
+  BASIC_RULE_FUNCS_WITHOUT_GETTER(type_##Rule)
 
-// Visibility style
-void Gecko_SetImageOrientation(nsStyleVisibility* aVisibility,
-                               uint8_t aOrientation,
-                               bool aFlip);
-void Gecko_SetImageOrientationAsFromImage(nsStyleVisibility* aVisibility);
-void Gecko_CopyImageOrientationFrom(nsStyleVisibility* aDst,
-                                    const nsStyleVisibility* aSrc);
+#define GROUP_RULE_FUNCS(type_)                                           \
+  BASIC_RULE_FUNCS(type_)                                                 \
+  ServoCssRulesStrong Servo_##type_##Rule_GetRules(                       \
+    RawServo##type_##RuleBorrowed rule);
 
-// Counter style.
-// This function takes an already addrefed nsAtom
-void Gecko_SetCounterStyleToName(mozilla::CounterStylePtr* ptr, nsAtom* name,
-                                 RawGeckoPresContextBorrowed pres_context);
-void Gecko_SetCounterStyleToSymbols(mozilla::CounterStylePtr* ptr,
-                                    uint8_t symbols_type,
-                                    nsACString const* const* symbols,
-                                    uint32_t symbols_count);
-void Gecko_SetCounterStyleToString(mozilla::CounterStylePtr* ptr,
-                                   const nsACString* symbol);
-void Gecko_CopyCounterStyle(mozilla::CounterStylePtr* dst,
-                            const mozilla::CounterStylePtr* src);
-nsAtom* Gecko_CounterStyle_GetName(const mozilla::CounterStylePtr* ptr);
-const mozilla::AnonymousCounterStyle*
-Gecko_CounterStyle_GetAnonymous(const mozilla::CounterStylePtr* ptr);
+BASIC_RULE_FUNCS(Style)
+BASIC_RULE_FUNCS(Import)
+BASIC_RULE_FUNCS_WITHOUT_GETTER(Keyframe)
+BASIC_RULE_FUNCS(Keyframes)
+GROUP_RULE_FUNCS(Media)
+GROUP_RULE_FUNCS(MozDocument)
+BASIC_RULE_FUNCS(Namespace)
+BASIC_RULE_FUNCS(Page)
+GROUP_RULE_FUNCS(Supports)
+BASIC_RULE_FUNCS(FontFeatureValues)
+BASIC_RULE_FUNCS(FontFace)
+BASIC_RULE_FUNCS(CounterStyle)
 
-// background-image style.
-void Gecko_SetNullImageValue(nsStyleImage* image);
-void Gecko_SetGradientImageValue(nsStyleImage* image, nsStyleGradient* gradient);
-void Gecko_SetLayerImageImageValue(nsStyleImage* image,
-                                   mozilla::css::URLValue* image_value);
+#undef GROUP_RULE_FUNCS
+#undef BASIC_RULE_FUNCS
+#undef BASIC_RULE_FUNCS_WITHOUT_GETTER
+
+RawServoDeclarationBlockStrong Servo_StyleRule_GetStyle(
+  RawServoStyleRuleBorrowed rule);
+
+void Servo_StyleRule_SetStyle(
+  RawServoStyleRuleBorrowed rule,
+  RawServoDeclarationBlockBorrowed declarations);
+
+void Servo_StyleRule_GetSelectorText(
+  RawServoStyleRuleBorrowed rule,
+  nsAString* result);
+
+void Servo_StyleRule_GetSelectorTextAtIndex(
+  RawServoStyleRuleBorrowed rule,
+  uint32_t index,
+  nsAString* result);
 
-void Gecko_SetImageElement(nsStyleImage* image, nsAtom* atom);
-void Gecko_CopyImageValueFrom(nsStyleImage* image, const nsStyleImage* other);
-void Gecko_InitializeImageCropRect(nsStyleImage* image);
+void Servo_StyleRule_GetSpecificityAtIndex(
+  RawServoStyleRuleBorrowed rule,
+  uint32_t index,
+  uint64_t* specificity);
+
+void Servo_StyleRule_GetSelectorCount(
+  RawServoStyleRuleBorrowed rule,
+  uint32_t* count);
 
-nsStyleGradient* Gecko_CreateGradient(uint8_t shape,
-                                      uint8_t size,
-                                      bool repeating,
-                                      bool legacy_syntax,
-                                      bool moz_legacy_syntax,
-                                      uint32_t stops);
+bool Servo_StyleRule_SelectorMatchesElement(
+  RawServoStyleRuleBorrowed,
+  RawGeckoElementBorrowed,
+  uint32_t index,
+  mozilla::CSSPseudoElementType pseudo_type);
 
-const nsStyleImageRequest* Gecko_GetImageRequest(const nsStyleImage* image);
-nsAtom* Gecko_GetImageElement(const nsStyleImage* image);
-const nsStyleGradient* Gecko_GetGradientImageValue(const nsStyleImage* image);
+bool Servo_StyleRule_SetSelectorText(
+  RawServoStyleSheetContentsBorrowed sheet,
+  RawServoStyleRuleBorrowed rule,
+  const nsAString* text);
 
-// list-style-image style.
-void Gecko_SetListStyleImageNone(nsStyleList* style_struct);
-void Gecko_SetListStyleImageImageValue(nsStyleList* style_struct,
-                                  mozilla::css::URLValue* aImageValue);
-void Gecko_CopyListStyleImageFrom(nsStyleList* dest, const nsStyleList* src);
+void Servo_ImportRule_GetHref(
+  RawServoImportRuleBorrowed rule,
+  nsAString* result);
 
-// cursor style.
-void Gecko_SetCursorArrayLength(nsStyleUI* ui, size_t len);
-void Gecko_SetCursorImageValue(nsCursorImage* aCursor,
-                               mozilla::css::URLValue* aImageValue);
-void Gecko_CopyCursorArrayFrom(nsStyleUI* dest, const nsStyleUI* src);
+const mozilla::StyleSheet* Servo_ImportRule_GetSheet(
+  RawServoImportRuleBorrowed rule);
+
+void Servo_ImportRule_SetSheet(
+  RawServoImportRuleBorrowed rule,
+  mozilla::StyleSheet* sheet);
+
+void Servo_Keyframe_GetKeyText(
+  RawServoKeyframeBorrowed keyframe,
+  nsAString* result);
 
-void Gecko_SetContentDataImageValue(nsStyleContentData* aList,
-                                    mozilla::css::URLValue* aImageValue);
-nsStyleContentData::CounterFunction* Gecko_SetCounterFunction(
-    nsStyleContentData* content_data, mozilla::StyleContentType);
+// Returns whether it successfully changes the key text.
+bool Servo_Keyframe_SetKeyText(
+  RawServoKeyframeBorrowed keyframe,
+  const nsACString* text);
+
+RawServoDeclarationBlockStrong Servo_Keyframe_GetStyle(
+  RawServoKeyframeBorrowed keyframe);
 
-// Dirtiness tracking.
-void Gecko_SetNodeFlags(RawGeckoNodeBorrowed node, uint32_t flags);
-void Gecko_UnsetNodeFlags(RawGeckoNodeBorrowed node, uint32_t flags);
-void Gecko_NoteDirtyElement(RawGeckoElementBorrowed element);
-void Gecko_NoteDirtySubtreeForInvalidation(RawGeckoElementBorrowed element);
-void Gecko_NoteAnimationOnlyDirtyElement(RawGeckoElementBorrowed element);
+void Servo_Keyframe_SetStyle(
+  RawServoKeyframeBorrowed keyframe,
+  RawServoDeclarationBlockBorrowed declarations);
 
-bool Gecko_AnimationNameMayBeReferencedFromStyle(
-  RawGeckoPresContextBorrowed pres_context,
+nsAtom* Servo_KeyframesRule_GetName(RawServoKeyframesRuleBorrowed rule);
+
+// This method takes an addrefed nsAtom.
+void Servo_KeyframesRule_SetName(
+  RawServoKeyframesRuleBorrowed rule,
   nsAtom* name);
 
-// Incremental restyle.
-mozilla::CSSPseudoElementType Gecko_GetImplementedPseudo(RawGeckoElementBorrowed element);
+uint32_t Servo_KeyframesRule_GetCount(RawServoKeyframesRuleBorrowed rule);
+
+RawServoKeyframeStrong Servo_KeyframesRule_GetKeyframeAt(
+  RawServoKeyframesRuleBorrowed rule,
+  uint32_t index,
+  uint32_t* line,
+  uint32_t* column);
+
+// Returns the index of the rule, max value of uint32_t if nothing found.
+uint32_t Servo_KeyframesRule_FindRule(
+  RawServoKeyframesRuleBorrowed rule,
+  const nsACString* key);
+
+// Returns whether it successfully appends the rule.
+bool Servo_KeyframesRule_AppendRule(
+  RawServoKeyframesRuleBorrowed rule,
+  RawServoStyleSheetContentsBorrowed sheet,
+  const nsACString* css);
+
+void Servo_KeyframesRule_DeleteRule(
+  RawServoKeyframesRuleBorrowed rule,
+  uint32_t index);
+
+RawServoMediaListStrong Servo_MediaRule_GetMedia(
+  RawServoMediaRuleBorrowed rule);
+
+nsAtom* Servo_NamespaceRule_GetPrefix(RawServoNamespaceRuleBorrowed rule);
+nsAtom* Servo_NamespaceRule_GetURI(RawServoNamespaceRuleBorrowed rule);
+
+RawServoDeclarationBlockStrong Servo_PageRule_GetStyle(
+  RawServoPageRuleBorrowed rule);
+
+void Servo_PageRule_SetStyle(
+  RawServoPageRuleBorrowed rule,
+  RawServoDeclarationBlockBorrowed declarations);
+
+void Servo_SupportsRule_GetConditionText(
+  RawServoSupportsRuleBorrowed rule,
+  nsAString* result);
+
+void Servo_MozDocumentRule_GetConditionText(
+  RawServoMozDocumentRuleBorrowed rule,
+  nsAString* result);
+
+void Servo_FontFeatureValuesRule_GetFontFamily(
+  RawServoFontFeatureValuesRuleBorrowed rule,
+  nsAString* result);
+
+void Servo_FontFeatureValuesRule_GetValueText(
+  RawServoFontFeatureValuesRuleBorrowed rule,
+  nsAString* result);
+
+RawServoFontFaceRuleStrong Servo_FontFaceRule_CreateEmpty();
+
+RawServoFontFaceRuleStrong Servo_FontFaceRule_Clone(
+  RawServoFontFaceRuleBorrowed rule);
+
+void Servo_FontFaceRule_GetSourceLocation(
+  RawServoFontFaceRuleBorrowed rule,
+  uint32_t* line,
+  uint32_t* column);
+
+uint32_t Servo_FontFaceRule_Length(RawServoFontFaceRuleBorrowed rule);
+
+nsCSSFontDesc Servo_FontFaceRule_IndexGetter(
+  RawServoFontFaceRuleBorrowed rule,
+  uint32_t index);
+
+void Servo_FontFaceRule_GetDeclCssText(
+  RawServoFontFaceRuleBorrowed rule,
+  nsAString* result);
+
+bool Servo_FontFaceRule_GetFontWeight(
+  RawServoFontFaceRuleBorrowed rule,
+  mozilla::StyleComputedFontWeightRange* out);
+
+bool Servo_FontFaceRule_GetFontDisplay(
+  RawServoFontFaceRuleBorrowed rule,
+  mozilla::StyleFontDisplay* out);
+
+bool Servo_FontFaceRule_GetFontStyle(
+  RawServoFontFaceRuleBorrowed rule,
+  mozilla::StyleComputedFontStyleDescriptor* out);
+
+bool Servo_FontFaceRule_GetFontStretch(
+  RawServoFontFaceRuleBorrowed rule,
+  mozilla::StyleComputedFontStretchRange* out);
+
+bool Servo_FontFaceRule_GetFontLanguageOverride(
+  RawServoFontFaceRuleBorrowed rule,
+  mozilla::StyleFontLanguageOverride* out);
+
+nsAtom* Servo_FontFaceRule_GetFamilyName(RawServoFontFaceRuleBorrowed rule);
+
+const mozilla::StyleUnicodeRange* Servo_FontFaceRule_GetUnicodeRanges(
+  RawServoFontFaceRuleBorrowed rule,
+  size_t* out_len);
+
+void Servo_FontFaceRule_GetSources(
+  RawServoFontFaceRuleBorrowed rule,
+  nsTArray<mozilla::StyleFontFaceSourceListComponent>* components);
+
+void Servo_FontFaceRule_GetVariationSettings(
+  RawServoFontFaceRuleBorrowed rule,
+  nsTArray<mozilla::gfx::FontVariation>* out);
+
+void Servo_FontFaceRule_GetFeatureSettings(
+  RawServoFontFaceRuleBorrowed rule,
+  nsTArray<gfxFontFeature>* out);
+
+void Servo_FontFaceRule_GetDescriptorCssText(
+  RawServoFontFaceRuleBorrowed rule,
+  nsCSSFontDesc desc,
+  nsAString* result);
+
+bool Servo_FontFaceRule_SetDescriptor(
+  RawServoFontFaceRuleBorrowed rule,
+  nsCSSFontDesc desc,
+  const nsACString* value,
+  RawGeckoURLExtraData* data);
+
+void Servo_FontFaceRule_ResetDescriptor(
+  RawServoFontFaceRuleBorrowed rule,
+  nsCSSFontDesc desc);
+
+nsAtom* Servo_CounterStyleRule_GetName(RawServoCounterStyleRuleBorrowed rule);
+
+bool Servo_CounterStyleRule_SetName(
+  RawServoCounterStyleRuleBorrowed rule,
+  const nsACString* name);
+
+uint32_t Servo_CounterStyleRule_GetGeneration(
+  RawServoCounterStyleRuleBorrowed rule);
+
+uint8_t Servo_CounterStyleRule_GetSystem(RawServoCounterStyleRuleBorrowed rule);
+
+nsAtom* Servo_CounterStyleRule_GetExtended(
+  RawServoCounterStyleRuleBorrowed rule);
+
+int32_t Servo_CounterStyleRule_GetFixedFirstValue(
+  RawServoCounterStyleRuleBorrowed rule);
+
+nsAtom* Servo_CounterStyleRule_GetFallback(
+  RawServoCounterStyleRuleBorrowed rule);
+
+void Servo_CounterStyleRule_GetDescriptor(
+  RawServoCounterStyleRuleBorrowed rule,
+  nsCSSCounterDesc desc,
+  nsCSSValueBorrowedMut result);
+
+void Servo_CounterStyleRule_GetDescriptorCssText(
+  RawServoCounterStyleRuleBorrowed rule,
+  nsCSSCounterDesc desc,
+  nsAString* result);
+
+bool Servo_CounterStyleRule_SetDescriptor(
+  RawServoCounterStyleRuleBorrowed rule,
+  nsCSSCounterDesc desc,
+  const nsACString* value);
+
+// Animations API
+
+RawServoDeclarationBlockStrong Servo_ParseProperty(
+  nsCSSPropertyID property,
+  const nsACString* value,
+  RawGeckoURLExtraData* data,
+  mozilla::ParsingMode parsing_mode,
+  nsCompatibility quirks_mode,
+  mozilla::css::Loader* loader);
+
+bool Servo_ParseEasing(
+  const nsAString* easing,
+  RawGeckoURLExtraData* data,
+  nsTimingFunctionBorrowedMut output);
+
+void Servo_GetComputedKeyframeValues(
+  RawGeckoKeyframeListBorrowed keyframes,
+  RawGeckoElementBorrowed element,
+  ComputedStyleBorrowed style,
+  RawServoStyleSetBorrowed set,
+  RawGeckoComputedKeyframeValuesListBorrowedMut result);
+
+RawServoAnimationValueStrong Servo_ComputedValues_ExtractAnimationValue(
+  ComputedStyleBorrowed computed_values,
+  nsCSSPropertyID property);
+
+bool Servo_ComputedValues_SpecifiesAnimationsOrTransitions(
+  ComputedStyleBorrowed computed_values);
+
+bool Servo_Property_IsAnimatable(nsCSSPropertyID property);
+bool Servo_Property_IsTransitionable(nsCSSPropertyID property);
+bool Servo_Property_IsDiscreteAnimatable(nsCSSPropertyID property);
+
+void Servo_GetProperties_Overriding_Animation(
+  RawGeckoElementBorrowed,
+  RawGeckoCSSPropertyIDListBorrowed,
+  nsCSSPropertyIDSetBorrowedMut);
+
+void Servo_MatrixTransform_Operate(
+  nsStyleTransformMatrix::MatrixTransformOperator matrix_operator,
+  const RawGeckoGfxMatrix4x4* from,
+  const RawGeckoGfxMatrix4x4* to,
+  double progress,
+  RawGeckoGfxMatrix4x4* result);
+
+void Servo_GetAnimationValues(
+  RawServoDeclarationBlockBorrowed declarations,
+  RawGeckoElementBorrowed element,
+  ComputedStyleBorrowed style,
+  RawServoStyleSetBorrowed style_set,
+  RawGeckoServoAnimationValueListBorrowedMut animation_values);
+
+// AnimationValues handling
+
+RawServoAnimationValueStrong Servo_AnimationValues_Interpolate(
+  RawServoAnimationValueBorrowed from,
+  RawServoAnimationValueBorrowed to,
+  double progress);
+
+bool Servo_AnimationValues_IsInterpolable(
+  RawServoAnimationValueBorrowed from,
+  RawServoAnimationValueBorrowed to);
+
+RawServoAnimationValueStrong Servo_AnimationValues_Add(
+  RawServoAnimationValueBorrowed a,
+  RawServoAnimationValueBorrowed b);
+
+RawServoAnimationValueStrong Servo_AnimationValues_Accumulate(
+  RawServoAnimationValueBorrowed a,
+  RawServoAnimationValueBorrowed b,
+  uint64_t count);
+
+RawServoAnimationValueStrong Servo_AnimationValues_GetZeroValue(
+  RawServoAnimationValueBorrowed value_to_match);
+
+double Servo_AnimationValues_ComputeDistance(
+  RawServoAnimationValueBorrowed from,
+  RawServoAnimationValueBorrowed to);
+
+void Servo_AnimationValue_Serialize(
+  RawServoAnimationValueBorrowed value,
+  nsCSSPropertyID property,
+  nsAString* buffer);
+
+float Servo_AnimationValue_GetOpacity(RawServoAnimationValueBorrowed value);
+RawServoAnimationValueStrong Servo_AnimationValue_Opacity(float);
+
+void Servo_AnimationValue_GetTransform(
+  RawServoAnimationValueBorrowed value,
+  RefPtr<nsCSSValueSharedList>* list);
+
+RawServoAnimationValueStrong Servo_AnimationValue_Transform(
+  const nsCSSValueSharedList& list);
+
+bool Servo_AnimationValue_DeepEqual(
+  RawServoAnimationValueBorrowed,
+  RawServoAnimationValueBorrowed);
+
+RawServoDeclarationBlockStrong Servo_AnimationValue_Uncompute(
+  RawServoAnimationValueBorrowed value);
+
+RawServoAnimationValueStrong Servo_AnimationValue_Compute(
+  RawGeckoElementBorrowed element,
+  RawServoDeclarationBlockBorrowed declarations,
+  ComputedStyleBorrowed style,
+  RawServoStyleSetBorrowed raw_data);
+
+// Style attribute
+
+RawServoDeclarationBlockStrong Servo_ParseStyleAttribute(
+  const nsACString* data,
+  RawGeckoURLExtraData* extra_data,
+  nsCompatibility quirks_mode,
+  mozilla::css::Loader* loader);
+
+RawServoDeclarationBlockStrong Servo_DeclarationBlock_CreateEmpty();
+
+RawServoDeclarationBlockStrong Servo_DeclarationBlock_Clone(
+  RawServoDeclarationBlockBorrowed declarations);
+
+bool Servo_DeclarationBlock_Equals(
+  RawServoDeclarationBlockBorrowed a,
+  RawServoDeclarationBlockBorrowed b);
+
+void Servo_DeclarationBlock_GetCssText(
+  RawServoDeclarationBlockBorrowed declarations,
+  nsAString* result);
+
+void Servo_DeclarationBlock_SerializeOneValue(
+  RawServoDeclarationBlockBorrowed declarations,
+  nsCSSPropertyID property,
+  nsAString* buffer,
+  ComputedStyleBorrowedOrNull computed_values,
+  RawServoDeclarationBlockBorrowedOrNull custom_properties);
+
+uint32_t Servo_DeclarationBlock_Count(
+  RawServoDeclarationBlockBorrowed declarations);
+
+bool Servo_DeclarationBlock_GetNthProperty(
+  RawServoDeclarationBlockBorrowed declarations,
+  uint32_t index,
+  nsAString* result);
+
+void Servo_DeclarationBlock_GetPropertyValue(
+  RawServoDeclarationBlockBorrowed declarations,
+  const nsACString* property,
+  nsAString* value);
+
+void Servo_DeclarationBlock_GetPropertyValueById(
+  RawServoDeclarationBlockBorrowed declarations,
+  nsCSSPropertyID property,
+  nsAString* value);
+
+bool Servo_DeclarationBlock_GetPropertyIsImportant(
+  RawServoDeclarationBlockBorrowed declarations,
+  const nsACString* property);
+
+bool Servo_DeclarationBlock_SetProperty(
+  RawServoDeclarationBlockBorrowed declarations,
+  const nsACString* property,
+  const nsACString* value,
+  bool is_important,
+  RawGeckoURLExtraData* data,
+  mozilla::ParsingMode parsing_mode,
+  nsCompatibility quirks_mode,
+  mozilla::css::Loader* loader,
+  mozilla::DeclarationBlockMutationClosure);
+
+bool Servo_DeclarationBlock_SetPropertyToAnimationValue(
+  RawServoDeclarationBlockBorrowed declarations,
+  RawServoAnimationValueBorrowed animation_value);
+
+bool Servo_DeclarationBlock_SetPropertyById(
+  RawServoDeclarationBlockBorrowed declarations,
+  nsCSSPropertyID property,
+  const nsACString* value,
+  bool is_important,
+  RawGeckoURLExtraData* data,
+  mozilla::ParsingMode parsing_mode,
+  nsCompatibility quirks_mode,
+  mozilla::css::Loader* loader,
+  mozilla::DeclarationBlockMutationClosure);
+
+bool Servo_DeclarationBlock_RemoveProperty(
+  RawServoDeclarationBlockBorrowed declarations,
+  const nsACString* property,
+  mozilla::DeclarationBlockMutationClosure);
+
+bool Servo_DeclarationBlock_RemovePropertyById(
+  RawServoDeclarationBlockBorrowed declarations,
+  nsCSSPropertyID property,
+  mozilla::DeclarationBlockMutationClosure);
+
+bool Servo_DeclarationBlock_HasCSSWideKeyword(
+  RawServoDeclarationBlockBorrowed declarations,
+  nsCSSPropertyID property);
+
+// Compose animation value for a given property.
+// |base_values| is nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>.
+// We use RawServoAnimationValueTableBorrowed to avoid exposing
+// nsRefPtrHashtable in FFI.
+void Servo_AnimationCompose(
+  RawServoAnimationValueMapBorrowedMut animation_values,
+  RawServoAnimationValueTableBorrowed base_values,
+  nsCSSPropertyID property,
+  RawGeckoAnimationPropertySegmentBorrowed animation_segment,
+  RawGeckoAnimationPropertySegmentBorrowed last_segment,
+  RawGeckoComputedTimingBorrowed computed_timing,
+  mozilla::dom::IterationCompositeOperation iter_composite);
+
+// Calculate the result of interpolating given animation segment at the given
+// progress and current iteration.
+// This includes combining the segment endpoints with the underlying value
+// and/or last value depending the composite modes specified on the
+// segment endpoints and the supplied iteration composite mode.
+// The caller is responsible for providing an underlying value and
+// last value in all situations where there are needed.
+RawServoAnimationValueStrong Servo_ComposeAnimationSegment(
+  RawGeckoAnimationPropertySegmentBorrowed animation_segment,
+  RawServoAnimationValueBorrowedOrNull underlying_value,
+  RawServoAnimationValueBorrowedOrNull last_value,
+  mozilla::dom::IterationCompositeOperation iter_composite,
+  double progress,
+  uint64_t current_iteration);
+
+// presentation attributes
+
+bool Servo_DeclarationBlock_PropertyIsSet(
+  RawServoDeclarationBlockBorrowed declarations,
+  nsCSSPropertyID property);
+
+void Servo_DeclarationBlock_SetIdentStringValue(
+  RawServoDeclarationBlockBorrowed declarations,
+  nsCSSPropertyID property,
+  nsAtom* value);
+
+void Servo_DeclarationBlock_SetKeywordValue(
+  RawServoDeclarationBlockBorrowed declarations,
+  nsCSSPropertyID property,
+  int32_t value);
+
+void Servo_DeclarationBlock_SetIntValue(
+  RawServoDeclarationBlockBorrowed declarations,
+  nsCSSPropertyID property,
+  int32_t value);
+
+void Servo_DeclarationBlock_SetPixelValue(
+  RawServoDeclarationBlockBorrowed declarations,
+  nsCSSPropertyID property,
+  float value);
+
+void Servo_DeclarationBlock_SetLengthValue(
+  RawServoDeclarationBlockBorrowed declarations,
+  nsCSSPropertyID property,
+  float value,
+  nsCSSUnit unit);
+
+void Servo_DeclarationBlock_SetNumberValue(
+  RawServoDeclarationBlockBorrowed declarations,
+  nsCSSPropertyID property,
+  float value);
+
+void Servo_DeclarationBlock_SetPercentValue(
+  RawServoDeclarationBlockBorrowed declarations,
+  nsCSSPropertyID property,
+  float value);
+
+void Servo_DeclarationBlock_SetAutoValue(
+  RawServoDeclarationBlockBorrowed declarations,
+  nsCSSPropertyID property);
+
+void Servo_DeclarationBlock_SetCurrentColor(
+  RawServoDeclarationBlockBorrowed declarations,
+  nsCSSPropertyID property);
+
+void Servo_DeclarationBlock_SetColorValue(
+  RawServoDeclarationBlockBorrowed declarations,
+  nsCSSPropertyID property,
+  nscolor value);
+
+void Servo_DeclarationBlock_SetFontFamily(
+  RawServoDeclarationBlockBorrowed declarations,
+  const nsAString& value);
+
+void Servo_DeclarationBlock_SetTextDecorationColorOverride(
+  RawServoDeclarationBlockBorrowed declarations);
+
+void Servo_DeclarationBlock_SetBackgroundImage(
+  RawServoDeclarationBlockBorrowed declarations,
+  const nsAString& value,
+  RawGeckoURLExtraData* extra_data);
+
+// MediaList
+
+RawServoMediaListStrong Servo_MediaList_Create();
+
+RawServoMediaListStrong Servo_MediaList_DeepClone(
+  RawServoMediaListBorrowed list);
+
+bool Servo_MediaList_Matches(
+  RawServoMediaListBorrowed list,
+  RawServoStyleSetBorrowed set);
+
+void Servo_MediaList_GetText(RawServoMediaListBorrowed list, nsAString* result);
+
+void Servo_MediaList_SetText(
+  RawServoMediaListBorrowed list,
+  const nsACString* text,
+  mozilla::dom::CallerType aCallerType);
+
+uint32_t Servo_MediaList_GetLength(RawServoMediaListBorrowed list);
+
+bool Servo_MediaList_GetMediumAt(
+  RawServoMediaListBorrowed list,
+  uint32_t index,
+  nsAString* result);
+
+void Servo_MediaList_AppendMedium(
+  RawServoMediaListBorrowed list,
+  const nsACString* new_medium);
+
+bool Servo_MediaList_DeleteMedium(
+  RawServoMediaListBorrowed list,
+  const nsACString* old_medium);
+
+size_t Servo_MediaList_SizeOfIncludingThis(
+  mozilla::MallocSizeOf malloc_size_of,
+  mozilla::MallocSizeOf malloc_enclosing_size_of,
+  RawServoMediaListBorrowed list);
+
+// CSS supports();
+
+bool Servo_CSSSupports2(const nsACString* name, const nsACString* value);
+bool Servo_CSSSupports(const nsACString* cond);
+
+// Computed style data
+
+ComputedStyleStrong Servo_ComputedValues_GetForAnonymousBox(
+  ComputedStyleBorrowedOrNull parent_style_or_null,
+  nsAtom* pseudo_tag,
+  RawServoStyleSetBorrowed set);
+
+ComputedStyleStrong Servo_ComputedValues_Inherit(
+  RawServoStyleSetBorrowed set,
+  nsAtom* pseudo_tag,
+  ComputedStyleBorrowedOrNull parent_style,
+  mozilla::InheritTarget target);
+
+uint8_t Servo_ComputedValues_GetStyleBits(ComputedStyleBorrowed values);
+
+bool Servo_ComputedValues_EqualCustomProperties(
+  ServoComputedDataBorrowed first,
+  ServoComputedDataBorrowed second);
+
+// Gets the source style rules for the computed values. This returns
+// the result via rules, which would include a list of unowned pointers
+// to RawServoStyleRule.
+void Servo_ComputedValues_GetStyleRuleList(
+  ComputedStyleBorrowed values,
+  RawGeckoServoStyleRuleListBorrowedMut rules);
+
+// Initialize Servo components. Should be called exactly once at startup.
+void Servo_Initialize(RawGeckoURLExtraData* dummy_url_data);
+
+// Initialize Servo on a cooperative Quantum DOM thread.
+void Servo_InitializeCooperativeThread();
+
+// Shut down Servo components. Should be called exactly once at shutdown.
+void Servo_Shutdown();
+
+// Restyle and change hints.
+void Servo_NoteExplicitHints(
+  RawGeckoElementBorrowed element,
+  nsRestyleHint restyle_hint,
+  nsChangeHint change_hint);
+
 // We'd like to return `nsChangeHint` here, but bindgen bitfield enums don't
 // work as return values with the Linux 32-bit ABI at the moment because
 // they wrap the value in a struct.
-uint32_t Gecko_CalcStyleDifference(ComputedStyleBorrowed old_style,
-                                   ComputedStyleBorrowed new_style,
-                                   bool* any_style_struct_changed,
-                                   bool* reset_only_changed);
+uint32_t Servo_TakeChangeHint(
+  RawGeckoElementBorrowed element,
+  bool* was_restyled);
 
-// Get an element snapshot for a given element from the table.
-const ServoElementSnapshot*
-Gecko_GetElementSnapshot(const mozilla::ServoElementSnapshotTable* table,
-                         RawGeckoElementBorrowed element);
-
-// Have we seen this pointer before?
-bool
-Gecko_HaveSeenPtr(mozilla::SeenPtrs* table, const void* ptr);
-
-// `array` must be an nsTArray
-// If changing this signature, please update the
-// friend function declaration in nsTArray.h
-void Gecko_EnsureTArrayCapacity(void* array, size_t capacity, size_t elem_size);
+ComputedStyleStrong Servo_ResolveStyle(
+  RawGeckoElementBorrowed element,
+  RawServoStyleSetBorrowed set);
 
-// Same here, `array` must be an nsTArray<T>, for some T.
-//
-// Important note: Only valid for POD types, since destructors won't be run
-// otherwise. This is ensured with rust traits for the relevant structs.
-void Gecko_ClearPODTArray(void* array, size_t elem_size, size_t elem_align);
-
-void Gecko_ResizeTArrayForStrings(nsTArray<nsString>* array, uint32_t length);
-
-void Gecko_SetStyleGridTemplate(mozilla::UniquePtr<nsStyleGridTemplate>* grid_template,
-                                nsStyleGridTemplate* value);
+ComputedStyleStrong Servo_ResolvePseudoStyle(
+  RawGeckoElementBorrowed element,
+  mozilla::CSSPseudoElementType pseudo_type,
+  bool is_probe,
+  ComputedStyleBorrowedOrNull inherited_style,
+  RawServoStyleSetBorrowed set);
 
-nsStyleGridTemplate* Gecko_CreateStyleGridTemplate(uint32_t track_sizes,
-                                                   uint32_t name_size);
-
-void Gecko_CopyStyleGridTemplateValues(mozilla::UniquePtr<nsStyleGridTemplate>* grid_template,
-                                       const nsStyleGridTemplate* other);
-
-mozilla::css::GridTemplateAreasValue* Gecko_NewGridTemplateAreasValue(uint32_t areas,
-                                                                      uint32_t templates,
-                                                                      uint32_t columns);
-NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::GridTemplateAreasValue, GridTemplateAreasValue);
+ComputedStyleStrong Servo_ComputedValues_ResolveXULTreePseudoStyle(
+  RawGeckoElementBorrowed element,
+  nsAtom* pseudo_tag,
+  ComputedStyleBorrowed inherited_style,
+  const mozilla::AtomArray* input_word,
+  RawServoStyleSetBorrowed set);
 
-// Clear the mContents, mCounterIncrements, or mCounterResets field in nsStyleContent. This is
-// needed to run the destructors, otherwise we'd leak the images, strings, and whatnot.
-void Gecko_ClearAndResizeStyleContents(nsStyleContent* content,
-                                       uint32_t how_many);
-void Gecko_ClearAndResizeCounterIncrements(nsStyleContent* content,
-                                           uint32_t how_many);
-void Gecko_ClearAndResizeCounterResets(nsStyleContent* content,
-                                       uint32_t how_many);
-void Gecko_CopyStyleContentsFrom(nsStyleContent* content, const nsStyleContent* other);
-void Gecko_CopyCounterResetsFrom(nsStyleContent* content, const nsStyleContent* other);
-void Gecko_CopyCounterIncrementsFrom(nsStyleContent* content, const nsStyleContent* other);
+void Servo_SetExplicitStyle(
+  RawGeckoElementBorrowed element,
+  ComputedStyleBorrowed primary_style);
 
-void Gecko_EnsureImageLayersLength(nsStyleImageLayers* layers, size_t len,
-                                   nsStyleImageLayers::LayerType layer_type);
-
-void Gecko_EnsureStyleAnimationArrayLength(void* array, size_t len);
-void Gecko_EnsureStyleTransitionArrayLength(void* array, size_t len);
+bool Servo_HasAuthorSpecifiedRules(
+  ComputedStyleBorrowed style,
+  RawGeckoElementBorrowed element,
+  mozilla::CSSPseudoElementType pseudo_type,
+  uint32_t rule_type_mask,
+  bool author_colors_allowed);
 
-void Gecko_ClearWillChange(nsStyleDisplay* display, size_t length);
-void Gecko_AppendWillChange(nsStyleDisplay* display, nsAtom* atom);
-void Gecko_CopyWillChangeFrom(nsStyleDisplay* dest, nsStyleDisplay* src);
-
-// Searches from the beginning of |keyframes| for a Keyframe object with the
-// specified offset and timing function. If none is found, a new Keyframe object
-// with the specified |offset| and |timingFunction| will be prepended to
-// |keyframes|.
+// Resolves style for an element or pseudo-element without processing pending
+// restyles first. The Element and its ancestors may be unstyled, have pending
+// restyles, or be in a display:none subtree. Styles are cached when possible,
+// though caching is not possible within display:none subtrees, and the styles
+// may be invalidated by already-scheduled restyles.
 //
-// @param keyframes  An array of Keyframe objects, sorted by offset.
-//                   The first Keyframe in the array, if any, MUST have an
-//                   offset greater than or equal to |offset|.
-// @param offset  The offset to search for, or, if no suitable Keyframe is
-//                found, the offset to use for the created Keyframe.
-//                Must be a floating point number in the range [0.0, 1.0].
-// @param timingFunction  The timing function to match, or, if no suitable
-//                        Keyframe is found, to set on the created Keyframe.
-//
-// @returns  The matching or created Keyframe.
-mozilla::Keyframe* Gecko_GetOrCreateKeyframeAtStart(
-  RawGeckoKeyframeListBorrowedMut keyframes,
-  float offset,
-  const nsTimingFunction* timingFunction);
+// The tree must be in a consistent state such that a normal traversal could be
+// performed, and this function maintains that invariant.
+
+ComputedStyleStrong Servo_ResolveStyleLazily(
+  RawGeckoElementBorrowed element,
+  mozilla::CSSPseudoElementType pseudo_type,
+  mozilla::StyleRuleInclusion rule_inclusion,
+  const mozilla::ServoElementSnapshotTable* snapshots,
+  RawServoStyleSetBorrowed set);
 
-// As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
-// from the beginning of |keyframes| for a Keyframe with matching timing
-// function and an offset of 0.0.
-// Furthermore, if a matching Keyframe is not found, a new Keyframe will be
-// inserted after the *last* Keyframe in |keyframes| with offset 0.0.
-mozilla::Keyframe* Gecko_GetOrCreateInitialKeyframe(
-  RawGeckoKeyframeListBorrowedMut keyframes,
-  const nsTimingFunction* timingFunction);
+// Reparents style to the new parents.
+ComputedStyleStrong Servo_ReparentStyle(
+  ComputedStyleBorrowed style_to_reparent,
+  ComputedStyleBorrowed parent_style,
+  ComputedStyleBorrowed parent_style_ignoring_first_line,
+  ComputedStyleBorrowed layout_parent_style,
+  // element is null if there is no content node involved, or if it's not an
+  // element.
+  RawGeckoElementBorrowedOrNull element,
+  RawServoStyleSetBorrowed set);
 
-// As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
-// from the *end* of |keyframes| for a Keyframe with matching timing function
-// and an offset of 1.0. If a matching Keyframe is not found, a new Keyframe
-// will be appended to the end of |keyframes|.
-mozilla::Keyframe* Gecko_GetOrCreateFinalKeyframe(
-  RawGeckoKeyframeListBorrowedMut keyframes,
-  const nsTimingFunction* timingFunction);
+// Use ServoStyleSet::PrepareAndTraverseSubtree instead of calling this
+// directly
+bool Servo_TraverseSubtree(
+  RawGeckoElementBorrowed root,
+  RawServoStyleSetBorrowed set,
+  const mozilla::ServoElementSnapshotTable* snapshots,
+  mozilla::ServoTraversalFlags flags);
 
-// Appends and returns a new PropertyValuePair to |aProperties| initialized with
-// its mProperty member set to |aProperty| and all other members initialized to
-// their default values.
-mozilla::PropertyValuePair* Gecko_AppendPropertyValuePair(
-  RawGeckoPropertyValuePairListBorrowedMut aProperties,
-  nsCSSPropertyID aProperty);
+// Assert that the tree has no pending or unconsumed restyles.
+void Servo_AssertTreeIsClean(RawGeckoElementBorrowed root);
 
-// Clean up pointer-based coordinates
-void Gecko_ResetStyleCoord(nsStyleUnit* unit, nsStyleUnion* value);
-
-// Set an nsStyleCoord to a computed `calc()` value
-void Gecko_SetStyleCoordCalcValue(nsStyleUnit* unit, nsStyleUnion* value, nsStyleCoord::CalcValue calc);
-
-void Gecko_CopyShapeSourceFrom(mozilla::StyleShapeSource* dst, const mozilla::StyleShapeSource* src);
+// Returns true if the current thread is a Servo parallel worker thread.
+bool Servo_IsWorkerThread();
 
-void Gecko_DestroyShapeSource(mozilla::StyleShapeSource* shape);
-void Gecko_NewBasicShape(mozilla::StyleShapeSource* shape,
-                         mozilla::StyleBasicShapeType type);
-void Gecko_NewShapeImage(mozilla::StyleShapeSource* shape);
-void Gecko_StyleShapeSource_SetURLValue(mozilla::StyleShapeSource* shape, mozilla::css::URLValue* uri);
-void Gecko_NewStyleSVGPath(mozilla::StyleShapeSource* shape);
-void Gecko_SetStyleMotion(mozilla::UniquePtr<mozilla::StyleMotion>* aMotion,
-                          mozilla::StyleMotion* aValue);
-mozilla::StyleMotion* Gecko_NewStyleMotion();
-void Gecko_CopyStyleMotions(mozilla::UniquePtr<mozilla::StyleMotion>* motion,
-                            const mozilla::StyleMotion* other);
+// Checks whether the rule tree has crossed its threshold for unused rule nodes,
+// and if so, frees them.
+void Servo_MaybeGCRuleTree(RawServoStyleSetBorrowed set);
 
-void Gecko_ResetFilters(nsStyleEffects* effects, size_t new_len);
-void Gecko_CopyFiltersFrom(nsStyleEffects* aSrc, nsStyleEffects* aDest);
-void Gecko_nsStyleFilter_SetURLValue(nsStyleFilter* effects, mozilla::css::URLValue* uri);
-
-void Gecko_nsStyleSVGPaint_CopyFrom(nsStyleSVGPaint* dest, const nsStyleSVGPaint* src);
-void Gecko_nsStyleSVGPaint_SetURLValue(nsStyleSVGPaint* paint, mozilla::css::URLValue* uri);
-void Gecko_nsStyleSVGPaint_Reset(nsStyleSVGPaint* paint);
-
-void Gecko_nsStyleSVG_SetDashArrayLength(nsStyleSVG* svg, uint32_t len);
-void Gecko_nsStyleSVG_CopyDashArray(nsStyleSVG* dst, const nsStyleSVG* src);
-void Gecko_nsStyleSVG_SetContextPropertiesLength(nsStyleSVG* svg, uint32_t len);
-void Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG* dst, const nsStyleSVG* src);
+// Returns computed values for the given element without any animations rules.
+ComputedStyleStrong Servo_StyleSet_GetBaseComputedValuesForElement(
+  RawServoStyleSetBorrowed set,
+  RawGeckoElementBorrowed element,
+  ComputedStyleBorrowed existing_style,
+  const mozilla::ServoElementSnapshotTable* snapshots);
 
-mozilla::css::URLValue* Gecko_URLValue_Create(ServoBundledURI uri, mozilla::CORSMode aCORSMode);
-size_t Gecko_URLValue_SizeOfIncludingThis(mozilla::css::URLValue* url);
-void Gecko_GetComputedURLSpec(const mozilla::css::URLValue* url, nsCString* spec);
-void Gecko_GetComputedImageURLSpec(const mozilla::css::URLValue* url, nsCString* spec);
-void Gecko_nsIURI_Debug(nsIURI*, nsCString* spec);
-
-NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::URLValue, CSSURLValue);
-NS_DECL_THREADSAFE_FFI_REFCOUNTING(RawGeckoURLExtraData, URLExtraData);
-
-void Gecko_FillAllImageLayers(nsStyleImageLayers* layers, uint32_t max_len);
-NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsStyleCoord::Calc, Calc);
-
-nsCSSShadowArray* Gecko_NewCSSShadowArray(uint32_t len);
-NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsCSSShadowArray, CSSShadowArray);
+// Returns computed values for the given element by adding an animation value.
+ComputedStyleStrong Servo_StyleSet_GetComputedValuesByAddingAnimation(
+  RawServoStyleSetBorrowed set,
+  RawGeckoElementBorrowed element,
+  ComputedStyleBorrowed existing_style,
+  const mozilla::ServoElementSnapshotTable* snapshots,
+  RawServoAnimationValueBorrowed animation);
 
-nsStyleQuoteValues* Gecko_NewStyleQuoteValues(uint32_t len);
-NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsStyleQuoteValues, QuoteValues);
-
-nsCSSValueSharedList* Gecko_NewCSSValueSharedList(uint32_t len);
-nsCSSValueSharedList* Gecko_NewNoneTransform();
+// For canvas font.
+void Servo_SerializeFontValueForCanvas(
+  RawServoDeclarationBlockBorrowed declarations,
+  nsAString* buffer);
 
-// Getter for nsCSSValue
-nsCSSValueBorrowedMut Gecko_CSSValue_GetArrayItem(nsCSSValueBorrowedMut css_value, int32_t index);
-// const version of the above function.
-nsCSSValueBorrowed Gecko_CSSValue_GetArrayItemConst(nsCSSValueBorrowed css_value, int32_t index);
-nsCSSKeyword Gecko_CSSValue_GetKeyword(nsCSSValueBorrowed aCSSValue);
-float Gecko_CSSValue_GetNumber(nsCSSValueBorrowed css_value);
-float Gecko_CSSValue_GetPercentage(nsCSSValueBorrowed css_value);
-nsStyleCoord::CalcValue Gecko_CSSValue_GetCalc(nsCSSValueBorrowed aCSSValue);
+// GetComputedStyle APIs.
+bool Servo_GetCustomPropertyValue(
+  ComputedStyleBorrowed computed_values,
+  const nsAString* name,
+  nsAString* value);
 
-void Gecko_CSSValue_SetNumber(nsCSSValueBorrowedMut css_value, float number);
-void Gecko_CSSValue_SetKeyword(nsCSSValueBorrowedMut css_value, nsCSSKeyword keyword);
-void Gecko_CSSValue_SetPercentage(nsCSSValueBorrowedMut css_value, float percent);
-void Gecko_CSSValue_SetPixelLength(nsCSSValueBorrowedMut aCSSValue, float aLen);
-void Gecko_CSSValue_SetCalc(nsCSSValueBorrowedMut css_value, nsStyleCoord::CalcValue calc);
-void Gecko_CSSValue_SetFunction(nsCSSValueBorrowedMut css_value, int32_t len);
-void Gecko_CSSValue_SetString(nsCSSValueBorrowedMut css_value,
-                              const uint8_t* string, uint32_t len, nsCSSUnit unit);
-void Gecko_CSSValue_SetStringFromAtom(nsCSSValueBorrowedMut css_value,
-                                      nsAtom* atom, nsCSSUnit unit);
-// Take an addrefed nsAtom and set it to the nsCSSValue
-void Gecko_CSSValue_SetAtomIdent(nsCSSValueBorrowedMut css_value, nsAtom* atom);
-void Gecko_CSSValue_SetArray(nsCSSValueBorrowedMut css_value, int32_t len);
-void Gecko_CSSValue_SetInt(nsCSSValueBorrowedMut css_value, int32_t integer, nsCSSUnit unit);
-void Gecko_CSSValue_SetFloat(nsCSSValueBorrowedMut css_value, float value, nsCSSUnit unit);
-void Gecko_CSSValue_SetPair(nsCSSValueBorrowedMut css_value,
-                            nsCSSValueBorrowed xvalue, nsCSSValueBorrowed yvalue);
-void Gecko_CSSValue_SetList(nsCSSValueBorrowedMut css_value, uint32_t len);
-void Gecko_CSSValue_SetPairList(nsCSSValueBorrowedMut css_value, uint32_t len);
-void Gecko_CSSValue_InitSharedList(nsCSSValueBorrowedMut css_value, uint32_t len);
-void Gecko_CSSValue_Drop(nsCSSValueBorrowedMut css_value);
-NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsCSSValueSharedList, CSSValueSharedList);
+uint32_t Servo_GetCustomPropertiesCount(ComputedStyleBorrowed computed_values);
+
+bool Servo_GetCustomPropertyNameAt(
+  ComputedStyleBorrowed,
+  uint32_t index,
+  nsAString* name);
 
-float Gecko_FontStretch_ToFloat(mozilla::FontStretch aStretch);
-void Gecko_FontStretch_SetFloat(mozilla::FontStretch* aStretch,
-                                float aFloatValue);
-float Gecko_FontSlantStyle_ToFloat(mozilla::FontSlantStyle aStyle);
-void Gecko_FontSlantStyle_SetNormal(mozilla::FontSlantStyle*);
-void Gecko_FontSlantStyle_SetItalic(mozilla::FontSlantStyle*);
-void Gecko_FontSlantStyle_SetOblique(mozilla::FontSlantStyle*, float angle_degrees);
-void Gecko_FontSlantStyle_Get(mozilla::FontSlantStyle,
-                              bool* normal,
-                              bool* italic,
-                              float* oblique_angle);
+void Servo_GetPropertyValue(
+  ComputedStyleBorrowed computed_values,
+  nsCSSPropertyID property,
+  nsAString* value);
 
-float Gecko_FontWeight_ToFloat(mozilla::FontWeight aWeight);
-void Gecko_FontWeight_SetFloat(mozilla::FontWeight* aWeight,
-                               float aFloatValue);
+void Servo_ProcessInvalidations(
+  RawServoStyleSetBorrowed set,
+  RawGeckoElementBorrowed element,
+  const mozilla::ServoElementSnapshotTable* snapshots);
+
+bool Servo_HasPendingRestyleAncestor(RawGeckoElementBorrowed element);
 
-void Gecko_nsStyleFont_SetLang(nsStyleFont* font, nsAtom* atom);
-void Gecko_nsStyleFont_CopyLangFrom(nsStyleFont* aFont, const nsStyleFont* aSource);
-void Gecko_nsStyleFont_FixupNoneGeneric(nsStyleFont* font,
-                                        RawGeckoPresContextBorrowed pres_context);
-void Gecko_nsStyleFont_PrefillDefaultForGeneric(nsStyleFont* font,
-                                                RawGeckoPresContextBorrowed pres_context,
-                                                uint8_t generic_id);
-void Gecko_nsStyleFont_FixupMinFontSize(nsStyleFont* font,
-                                        RawGeckoPresContextBorrowed pres_context);
-FontSizePrefs Gecko_GetBaseSize(nsAtom* lang);
+void Servo_GetArcStringData(
+  const RustString*,
+  uint8_t const** chars,
+  uint32_t* len);
 
-// XBL related functions.
-RawGeckoElementBorrowedOrNull Gecko_GetBindingParent(RawGeckoElementBorrowed aElement);
-RawServoAuthorStylesBorrowedOrNull Gecko_XBLBinding_GetRawServoStyles(RawGeckoXBLBindingBorrowed aXBLBinding);
-bool Gecko_XBLBinding_InheritsStyle(RawGeckoXBLBindingBorrowed aXBLBinding);
+void Servo_ReleaseArcStringData(
+  const mozilla::ServoRawOffsetArc<RustString>* string);
 
-struct GeckoFontMetrics
-{
-  nscoord mChSize;
-  nscoord mXSize;
-};
+// CSS parsing utility functions.
+
+bool Servo_IsValidCSSColor(const nsAString* value);
 
-GeckoFontMetrics Gecko_GetFontMetrics(RawGeckoPresContextBorrowed pres_context,
-                                      bool is_vertical,
-                                      const nsStyleFont* font,
-                                      nscoord font_size,
-                                      bool use_user_font_set);
-int32_t Gecko_GetAppUnitsPerPhysicalInch(RawGeckoPresContextBorrowed pres_context);
-void InitializeServo();
-void ShutdownServo();
-void AssertIsMainThreadOrServoLangFontPrefsCacheLocked();
+bool Servo_ComputeColor(
+  RawServoStyleSetBorrowedOrNull set,
+  nscolor current_color,
+  const nsAString* value,
+  nscolor* result_color,
+  bool* was_current_color,
+  mozilla::css::Loader* loader);
 
-mozilla::StyleSheet* Gecko_StyleSheet_Clone(
-    const mozilla::StyleSheet* aSheet,
-    const mozilla::StyleSheet* aNewParentSheet);
-void Gecko_StyleSheet_AddRef(const mozilla::StyleSheet* aSheet);
-void Gecko_StyleSheet_Release(const mozilla::StyleSheet* aSheet);
+bool Servo_IntersectionObserverRootMargin_Parse(
+  const nsAString* value,
+  nsStyleSides* result);
 
-nsCSSKeyword Gecko_LookupCSSKeyword(const uint8_t* string, uint32_t len);
-const char* Gecko_CSSKeywordString(nsCSSKeyword keyword, uint32_t* len);
-
-bool Gecko_IsDocumentBody(RawGeckoElementBorrowed element);
-// We use an int32_t here instead of a LookAndFeel::ColorID
-// because forward-declaring a nested enum/struct is impossible
-nscolor Gecko_GetLookAndFeelSystemColor(int32_t color_id,
-                                        RawGeckoPresContextBorrowed pres_context);
-
-void Gecko_AddPropertyToSet(nsCSSPropertyIDSetBorrowedMut, nsCSSPropertyID);
+void Servo_IntersectionObserverRootMargin_ToString(
+  const nsStyleSides* rect,
+  nsAString* result);
 
-// Style-struct management.
-#define STYLE_STRUCT(name)                                            \
-  void Gecko_Construct_Default_nsStyle##name(                         \
-    nsStyle##name* ptr,                                               \
-    RawGeckoPresContextBorrowed pres_context);                        \
-  void Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr,          \
-                                         const nsStyle##name* other); \
-  void Gecko_Destroy_nsStyle##name(nsStyle##name* ptr);
-#include "nsStyleStructList.h"
-#undef STYLE_STRUCT
-
-void Gecko_RegisterProfilerThread(const char* name);
-void Gecko_UnregisterProfilerThread();
+// Returning false means the parsed transform contains relative lengths or
+// percentage value, so we cannot compute the matrix. In this case, we keep
+// |result| and |contains_3d_transform| as-is.
+bool Servo_ParseTransformIntoMatrix(
+  const nsAString* value,
+  bool* contains_3d_transform,
+  RawGeckoGfxMatrix4x4* result);
 
-bool Gecko_DocumentRule_UseForPresentation(RawGeckoPresContextBorrowed,
-                                           const nsACString* aPattern,
-                                           mozilla::css::DocumentMatchingFunction);
-
-// Allocator hinting.
-void Gecko_SetJemallocThreadLocalArena(bool enabled);
-
-void Gecko_AddBufferToCrashReport(const void* addr, size_t len);
-void Gecko_AnnotateCrashReport(uint32_t key, const char* value_str);
+bool Servo_ParseFontShorthandForMatching(
+  const nsAString* value,
+  RawGeckoURLExtraData* data,
+  RefPtr<mozilla::SharedFontList>* family,
+  // We use ComputedFontStyleDescriptor just for convenience,
+  // but the two values of Oblique are the same.
+  mozilla::StyleComputedFontStyleDescriptor* style,
+  float* stretch,
+  float* weight);
 
-// Pseudo-element flags.
-#define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
-  const uint32_t SERVO_CSS_PSEUDO_ELEMENT_FLAGS_##name_ = flags_;
-#include "nsCSSPseudoElementList.h"
-#undef CSS_PSEUDO_ELEMENT
+nsCSSPropertyID Servo_ResolveLogicalProperty(
+  nsCSSPropertyID,
+  ComputedStyleBorrowed);
 
-#define SERVO_BINDING_FUNC(name_, return_, ...) return_ name_(__VA_ARGS__);
-#include "mozilla/ServoBindingList.h"
-#undef SERVO_BINDING_FUNC
+nsCSSPropertyID Servo_Property_LookupEnabledForAllContent(
+  const nsACString* name);
+
+const uint8_t* Servo_Property_GetName(nsCSSPropertyID, uint32_t* out_length);
+bool Servo_Property_IsShorthand(const nsACString* name, bool* found);
+bool Servo_Property_IsInherited(const nsACString* name);
 
-bool Gecko_ErrorReportingEnabled(const mozilla::StyleSheet* sheet,
-                                 const mozilla::css::Loader* loader);
-void Gecko_ReportUnexpectedCSSError(const mozilla::StyleSheet* sheet,
-                                    const mozilla::css::Loader* loader,
-                                    nsIURI* uri,
-                                    const char* message,
-                                    const char* param,
-                                    uint32_t paramLen,
-                                    const char* prefix,
-                                    const char* prefixParam,
-                                    uint32_t prefixParamLen,
-                                    const char* suffix,
-                                    const char* source,
-                                    uint32_t sourceLen,
-                                    uint32_t lineNumber,
-                                    uint32_t colNumber);
+bool Servo_Property_SupportsType(
+  const nsACString* name,
+  uint32_t ty,
+  bool* found);
 
-// DOM APIs.
-void Gecko_ContentList_AppendAll(nsSimpleContentList* aContentList,
-                                 const RawGeckoElement** aElements,
-                                 size_t aLength);
+void Servo_Property_GetCSSValuesForProperty(
+  const nsACString* name,
+  bool* found,
+  nsTArray<nsString>* result);
 
-// FIXME(emilio): These two below should be a single function that takes a
-// `const DocumentOrShadowRoot*`, but that doesn't make MSVC builds happy for a
-// reason I haven't really dug into.
-const nsTArray<mozilla::dom::Element*>* Gecko_Document_GetElementsWithId(
-    const nsIDocument* aDocument,
-    nsAtom* aId);
+uint64_t Servo_PseudoClass_GetStates(const nsACString* name);
+
+StyleUseCounters* Servo_UseCounters_Create();
+void Servo_UseCounters_Drop(StyleUseCountersOwned);
 
-const nsTArray<mozilla::dom::Element*>* Gecko_ShadowRoot_GetElementsWithId(
-    const mozilla::dom::ShadowRoot* aDocument,
-    nsAtom* aId);
-
-// Check the value of the given bool preference. The pref name needs to
-// be null-terminated.
-bool Gecko_GetBoolPrefValue(const char* pref_name);
-
-// Returns true if we're currently performing the servo traversal.
-bool Gecko_IsInServoTraversal();
-
-// Returns true if we're currently on the main thread.
-bool Gecko_IsMainThread();
+void Servo_UseCounters_Merge(
+  StyleUseCountersBorrowed doc_counters,
+  StyleUseCountersBorrowed sheet_counters);
 
-// Media feature helpers.
-mozilla::StyleDisplayMode Gecko_MediaFeatures_GetDisplayMode(nsIDocument*);
-uint32_t Gecko_MediaFeatures_GetColorDepth(nsIDocument*);
-void Gecko_MediaFeatures_GetDeviceSize(nsIDocument*, nscoord* width, nscoord* height);
-float Gecko_MediaFeatures_GetResolution(nsIDocument*);
-bool Gecko_MediaFeatures_PrefersReducedMotion(nsIDocument*);
-mozilla::PointerCapabilities Gecko_MediaFeatures_PrimaryPointerCapabilities(nsIDocument*);
-mozilla::PointerCapabilities Gecko_MediaFeatures_AllPointerCapabilities(nsIDocument*);
-float Gecko_MediaFeatures_GetDevicePixelRatio(nsIDocument*);
-bool Gecko_MediaFeatures_HasSystemMetric(nsIDocument*,
-                                         nsAtom* metric,
-                                         bool is_accessible_from_content);
-bool Gecko_MediaFeatures_IsResourceDocument(nsIDocument*);
-nsAtom* Gecko_MediaFeatures_GetOperatingSystemVersion(nsIDocument*);
+bool Servo_IsCssPropertyRecordedInUseCounter(
+  StyleUseCountersBorrowed,
+  const nsACString* property,
+  bool* out_known_prop);
+
+// AddRef / Release functions
+#define SERVO_ARC_TYPE(name_, type_)              \
+  void Servo_##name_##_AddRef(type_##Borrowed);   \
+  void Servo_##name_##_Release(type_##Borrowed);
+#include "mozilla/ServoArcTypeList.h"
+#undef SERVO_ARC_TYPE
 
 } // extern "C"
 
 #endif // mozilla_ServoBindings_h
--- a/layout/style/ServoBindings.toml
+++ b/layout/style/ServoBindings.toml
@@ -78,17 +78,17 @@ headers = [
     "mozilla/Keyframe.h",
     "mozilla/ServoElementSnapshot.h",
     "mozilla/ServoElementSnapshotTable.h",
     "mozilla/dom/Element.h",
     "mozilla/dom/ChildIterator.h",
     "mozilla/dom/NameSpaceConstants.h",
     "mozilla/LookAndFeel.h",
     "mozilla/StaticPrefs.h",
-    "mozilla/ServoBindings.h",
+    "mozilla/GeckoBindings.h",
     "mozilla/ComputedStyle.h",
     "mozilla/ServoTraversalStatistics.h",
     "mozilla/SizeOfState.h",
     "nsCSSProps.h",
     "nsContentUtils.h",
     "nsNameSpaceManager.h",
     "nsMediaFeatures.h",
     "nsXBLBinding.h",
@@ -222,17 +222,18 @@ whitelist-vars = [
     "kNameSpaceID_.*",
     "kGenericFont_.*",
     "kPresContext_.*",
     "nsContentUtils_.*",
     "GECKO_IS_NIGHTLY",
 ]
 whitelist-types = [
     "RawGecko.*",
-    "DeclarationBlockMutationClosure",
+    "RawServoAnimationValueMap",  # TODO(heycam): Handle this elsewhere.
+    "mozilla::DeclarationBlockMutationClosure",
     "mozilla::AnimationPropertySegment",
     "mozilla::AnonymousCounterStyle",
     "mozilla::AtomArray",
     "mozilla::ComputedTiming",
     "mozilla::ComputedTimingFunction",
     "mozilla::ComputedTimingFunction::BeforeFlag",
     "mozilla::SeenPtrs",
     "mozilla::ServoElementSnapshot.*",
@@ -276,29 +277,29 @@ whitelist-types = [
     "AnonymousContent",
     "AudioContext",
     "CapturingContentInfo",
     "DefaultDelete",
     "DOMIntersectionObserverEntry",
     "Element",
     "FontFamilyList",
     "FontFamilyName",
-    "FontSizePrefs",
+    "mozilla::FontSizePrefs",
     "FragmentOrURL",
     "FrameRequestCallback",
     "GeckoParserExtraData",
     "GeckoFontMetrics",
     "gfxAlternateValue",
     "gfxFontFeatureValueSet",
     "GridNamedArea",
     "mozilla::HalfCorner",
     "Image",
     "ImageURL",
     "Keyframe",
-    "MediumFeaturesChangedResult",
+    "mozilla::MediumFeaturesChangedResult",
     "nsAttrName",
     "nsAttrValue",
     "nscolor",
     "nsChangeHint",
     "nsCSSCounterDesc",
     "nsCSSFontDesc",
     "nsCSSKTableEntry",
     "nsCSSKeyword",
@@ -437,34 +438,38 @@ opaque-types = [
     "gfxSize_Super",  # Ditto.
     "mozilla::StyleAnimationValue",
     "StyleAnimationValue", # pulls in a whole bunch of stuff we don't need in the bindings
     "mozilla::dom::.*Callback", # Pulls in ErrorResult and other things that
                                 # don't align properly on Linux 32-bit
     "mozilla::SchedulerGroup", # Non-standard-layout packing of field into superclass
 ]
 mapped-generic-types = [
-    { generic = true, gecko = "mozilla::ServoUnsafeCell", servo = "::std::cell::UnsafeCell" },
-    { generic = true, gecko = "mozilla::ServoCell", servo = "::std::cell::Cell" },
+    { generic = true, gecko = "mozilla::RustCell", servo = "::std::cell::Cell" },
     { generic = false, gecko = "ServoNodeData", servo = "AtomicRefCell<ElementData>" },
     { generic = false, gecko = "mozilla::ServoWritingMode", servo = "::logical_geometry::WritingMode" },
     { generic = false, gecko = "mozilla::ServoCustomPropertiesMap", servo = "Option<::servo_arc::Arc<::custom_properties::CustomPropertiesMap>>" },
     { generic = false, gecko = "mozilla::ServoRuleNode", servo = "Option<::rule_tree::StrongRuleNode>" },
     { generic = false, gecko = "mozilla::ServoVisitedStyle", servo = "Option<::servo_arc::RawOffsetArc<::properties::ComputedValues>>" },
     { generic = false, gecko = "mozilla::ServoComputedValueFlags", servo = "::properties::computed_value_flags::ComputedValueFlags" },
     { generic = true, gecko = "mozilla::ServoRawOffsetArc", servo = "::servo_arc::RawOffsetArc" },
     { generic = false, gecko = "ComputedStyleStrong", servo = "::gecko_bindings::sugar::ownership::Strong<::properties::ComputedValues>" },
 ]
 fixups = [
     { pat = "\\broot\\s*::\\s*nsString\\b", rep = "::nsstring::nsStringRepr" },
     { pat = "\\broot\\s*::\\s*nsTString\\s*<\\s*u16\\s*>", rep = "::nsstring::nsStringRepr" },
 ]
 
 [bindings]
-headers = ["mozilla/ServoBindings.h"]
+headers = [
+    "mozilla/GeckoBindings.h",
+    # We include ServoBindings.h so we can type check the C function declarations
+    # in there against the function definitions in servo/ports/gecko/glue.rs.
+    "mozilla/ServoBindings.h",
+]
 hide-types = [
     "nsACString_internal",
     "nsAString_internal",
     "ComputedStyleBorrowed",
     "ComputedStyleBorrowedOrNull",
 ]
 raw-lines = [
     "pub use nsstring::{nsACString, nsAString, nsCString, nsString, nsStringRepr};",
@@ -499,24 +504,24 @@ structs-types = [
     "mozilla::StyleComputedFontWeightRange",
     "mozilla::StyleFontDisplay",
     "mozilla::StyleUnicodeRange",
     "mozilla::StyleFontLanguageOverride",
     "mozilla::StyleFontFaceSourceListComponent",
     "gfxFontFeature",
     "mozilla::gfx::FontVariation",
     "ServoRawOffsetArc",
-    "DeclarationBlockMutationClosure",
+    "mozilla::DeclarationBlockMutationClosure",
     "nsAttrValue",
     "nsIContent",
     "nsINode",
     "nsIDocument",
     "nsIDocument_DocumentTheme",
     "nsSimpleContentList",
-    "MediumFeaturesChangedResult",
+    "mozilla::MediumFeaturesChangedResult",
     "RawGeckoAnimationPropertySegment",
     "RawGeckoComputedTiming",
     "RawGeckoCSSPropertyIDList",
     "RawGeckoDocument",
     "RawGeckoElement",
     "Element",
     "RawGeckoKeyframeList",
     "RawGeckoPropertyValuePairList",
@@ -526,33 +531,32 @@ structs-types = [
     "RawServoAnimationValue",
     "RawServoFontFaceRule",
     "RawGeckoServoAnimationValueList",
     "RawServoMediaList",
     "RawServoStyleSheetContents",
     "RawServoDeclarationBlock",
     "RawServoStyleRule",
     "RawGeckoPresContext",
-    "RawGeckoPresContextOwned",
     "RawGeckoStyleAnimationList",
     "RawGeckoStyleChildrenIterator",
     "RawGeckoServoStyleRuleList",
     "RawGeckoURLExtraData",
     "RawGeckoXBLBinding",
     "RawServoSelectorList",
     "RawServoSourceSizeList",
     "RefPtr",
     "RustString",
     "StyleUseCounters",
     "CSSPseudoElementType",
     "ServoTraversalFlags",
     "ComputedTimingFunction_BeforeFlag",
     "CounterStylePtr",
     "FontFamilyType",
-    "FontSizePrefs",
+    "mozilla::FontSizePrefs",
     "GeckoFontMetrics",
     "IterationCompositeOperation",
     "Keyframe",
     "PropertyValuePair",
     "SeenPtrs",
     "ServoBundledURI",
     "ServoElementSnapshot",
     "ServoElementSnapshotTable",
@@ -641,51 +645,25 @@ structs-types = [
     "InheritTarget",
     "DocumentMatchingFunction",
     "StyleAnimation",
     "StyleRuleInclusion",
     "nsStyleTransformMatrix::MatrixTransformOperator",
     "RawGeckoGfxMatrix4x4",
     "FontFamilyName",
     "mozilla::SharedFontList",
+    "RawServoAnimationValueMap",
 ]
 array-types = [
     { cpp-type = "uintptr_t", rust-type = "usize" },
 ]
-servo-owned-types = [
-    { name = "RawServoStyleSet", opaque = true },
-    { name = "RawServoAuthorStyles", opaque = true },
-    { name = "RawServoSelectorList", opaque = false },
-    { name = "RawServoSourceSizeList", opaque = false },
-    { name = "StyleUseCounters", opaque = false },
-    { name = "ServoElementSnapshot", opaque = false },
-    { name = "RawServoAnimationValueMap", opaque = true },
-]
 servo-immutable-borrow-types = [
-    "RawGeckoNode",
-    "RawGeckoElement",
-    "RawGeckoDocument",
     "RawServoDeclarationBlockStrong",
-    "RawGeckoPresContext",
-    "RawGeckoXBLBinding",
 ]
 servo-borrow-types = [
-    "nsCSSPropertyIDSet",
-    "nsCSSValue",
-    "nsTimingFunction",
-    "RawGeckoAnimationPropertySegment",
-    "RawGeckoComputedTiming",
-    "RawGeckoCSSPropertyIDList",
-    "RawGeckoKeyframeList",
-    "RawGeckoPropertyValuePairList",
-    "RawGeckoComputedKeyframeValuesList",
-    "RawGeckoFontFaceRuleList",
-    "RawGeckoServoStyleRuleList",
-    "RawGeckoServoAnimationValueList",
-    "RawGeckoStyleAnimationList",
-    "RawGeckoStyleChildrenIterator",
+    "RawServoAnimationValueMap",  # FIXME(heycam): Try to get rid of this.
 ]
 fixups = [
     # Remap the templated string type to the helper type
     { pat = "\\bnsTString\\s*<\\s*u16\\s*>", rep = "nsString" },
     # hack for gecko-owned string
     { pat = "<\\s*nsString\\s*", rep = "<nsStringRepr" },
 ]
new file mode 100644
--- /dev/null
+++ b/layout/style/ServoBoxedTypeList.h
@@ -0,0 +1,31 @@
+/* -*- 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/. */
+
+/* a list of all Servo Box<T> types used across bindings, for preprocessing */
+
+// The first argument is the name of the Servo type used inside the Box.
+// This doesn't need to be accurate; it's only used to generate nice looking
+// FFI function names.
+//
+// The second argument is the name of an opaque Gecko type that will
+// correspond to the Servo type used inside the Box.  The convention for the
+// the name of the opaque Gecko type is "RawServo{Type}", where {Type} is
+// the name of the Servo type or something close to it.
+//
+// See the comment at the top of ServoBindingTypes.h for how to use these.
+//
+// If you add an entry to this file, you should also add impls of HasFFI
+// (with FFIType equal to ::gecko_bindings::structs::RawServo{Type}),
+// HasSimpleFFI, and HasBoxFFI to the Servo type. You will also need to
+// add a Servo_{FriendlyServoName}_Drop function to servo/ports/gecko/glue.rs.
+//
+// TODO(heycam): Do some of this automatically.
+
+SERVO_BOXED_TYPE(StyleSet, RawServoStyleSet)
+SERVO_BOXED_TYPE(AuthorStyles, RawServoAuthorStyles)
+SERVO_BOXED_TYPE(SelectorList, RawServoSelectorList)
+SERVO_BOXED_TYPE(SourceSizeList, RawServoSourceSizeList)
+SERVO_BOXED_TYPE(UseCounters, StyleUseCounters)
--- a/layout/style/ServoComputedData.h
+++ b/layout/style/ServoComputedData.h
@@ -2,51 +2,63 @@
 /* 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/. */
 
 #ifndef mozilla_ServoComputedData_h
 #define mozilla_ServoComputedData_h
 
-#include "mozilla/ServoTypes.h"
+class nsWindowSizes;
 
 /*
  * ServoComputedData and its related types.
  */
 
 #define STYLE_STRUCT(name_) struct nsStyle##name_;
 #include "nsStyleStructList.h"
 #undef STYLE_STRUCT
 
 namespace mozilla {
 
-struct ServoWritingMode {
+template<typename T>
+struct ServoRawOffsetArc
+{
+  // This is a pointer to a T that lives inside a servo_arc::Arc<T>, and
+  // which already has had its reference count incremented.
+  T* mPtr;
+};
+
+struct ServoWritingMode
+{
   uint8_t mBits;
 };
 
-struct ServoCustomPropertiesMap {
+struct ServoCustomPropertiesMap
+{
   uintptr_t mPtr;
 };
 
-struct ServoRuleNode {
+struct ServoRuleNode
+{
   uintptr_t mPtr;
 };
 
 class ComputedStyle;
 
-struct ServoVisitedStyle {
-  // This is actually a strong reference
-  // but ServoComputedData's destructor is
-  // managed by the Rust code so we just use a
-  // regular pointer
+struct ServoVisitedStyle
+{
+  // This is actually a strong reference but ServoComputedData's
+  // destructor is managed by the Rust code so we just use a regular
+  // pointer
   ComputedStyle* mPtr;
 };
 
-struct ServoComputedValueFlags {
+struct ServoComputedValueFlags
+{
   uint16_t mFlags;
 };
 
 #define STYLE_STRUCT(name_) struct Gecko##name_;
 #include "nsStyleStructList.h"
 #undef STYLE_STRUCT
 
 } // namespace mozilla
--- a/layout/style/ServoElementSnapshot.cpp
+++ b/layout/style/ServoElementSnapshot.cpp
@@ -1,16 +1,16 @@
 /* -*- 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 "mozilla/ServoElementSnapshot.h"
-#include "mozilla/ServoBindings.h"
+#include "mozilla/GeckoBindings.h"
 #include "mozilla/dom/Element.h"
 #include "nsIContentInlines.h"
 #include "nsContentUtils.h"
 
 namespace mozilla {
 
 ServoElementSnapshot::ServoElementSnapshot(const Element& aElement)
   : mState(0)
--- a/layout/style/ServoTypes.h
+++ b/layout/style/ServoTypes.h
@@ -1,49 +1,38 @@
 /* -*- 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/. */
 
+/* types defined to pass values through Gecko_* and Servo_* FFI functions */
+
 #ifndef mozilla_ServoTypes_h
 #define mozilla_ServoTypes_h
 
+#include "mozilla/RefPtr.h"
+#include "mozilla/SheetType.h"
 #include "mozilla/TypedEnumBits.h"
+#include "nsCoord.h"
 
-/*
- * Type definitions used to interact with Servo. This gets included by nsINode,
- * so don't add significant include dependencies to this file.
- */
-
-class nsWindowSizes;
-struct ServoNodeData;
-namespace mozilla {
+struct RawServoFontFaceRule;
 
-class SizeOfState;
-
-/*
- * Replaced types. These get mapped to associated Servo types in bindgen.
- */
+namespace mozilla {
+  struct LangGroupFontPrefs;
+}
 
-template<typename T>
-struct ServoUnsafeCell {
-  T value;
-
-  // Ensure that primitive types (i.e. pointers) get zero-initialized.
-  ServoUnsafeCell() : value() {};
+// used for associating sheet type with specific @font-face rules
+struct nsFontFaceRuleContainer
+{
+  RefPtr<RawServoFontFaceRule> mRule;
+  mozilla::SheetType mSheetType;
 };
 
-template<typename T>
-struct ServoCell {
-  ServoUnsafeCell<T> value;
-  T Get() const { return value.value; }
-  void Set(T arg) { value.value = arg; }
-  ServoCell() : value() {};
-};
+namespace mozilla {
 
 // Indicates whether the Servo style system should expect the style on an element
 // to have already been resolved (i.e. via a parallel traversal), or whether it
 // may be lazily computed.
 enum class LazyComputeBehavior {
   Allow,
   Assert,
 };
@@ -153,18 +142,39 @@ public:
     , mPrecomputedPseudos(0)
     , mElementAndPseudosMaps(0)
     , mInvalidationMap(0)
     , mRevalidationSelectors(0)
     , mOther(0)
   {}
 };
 
-template <typename T>
-struct ServoRawOffsetArc {
-  // Again, a strong reference, but
-  // managed by the Rust code
-  T* mPtr;
+// A callback that can be sent via FFI which will be invoked _right before_
+// being mutated, and at most once.
+struct DeclarationBlockMutationClosure
+{
+  // The callback function. The argument is `data`.
+  void (*function)(void*) = nullptr;
+  void* data = nullptr;
+};
+
+struct MediumFeaturesChangedResult
+{
+  bool mAffectsDocumentRules;
+  bool mAffectsNonDocumentRules;
+  bool mUsesViewportUnits;
+};
+
+struct FontSizePrefs
+{
+  void CopyFrom(const mozilla::LangGroupFontPrefs&);
+  nscoord mDefaultVariableSize;
+  nscoord mDefaultFixedSize;
+  nscoord mDefaultSerifSize;
+  nscoord mDefaultSansSerifSize;
+  nscoord mDefaultMonospaceSize;
+  nscoord mDefaultCursiveSize;
+  nscoord mDefaultFantasySize;
 };
 
 } // namespace mozilla
 
 #endif // mozilla_ServoTypes_h
--- a/layout/style/ServoUtils.h
+++ b/layout/style/ServoUtils.h
@@ -1,26 +1,28 @@
 /* -*- 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/. */
 
-/* some utilities for stylo */
+/* some utilities for Gecko to use for Servo initialization and assertions */
 
 #ifndef mozilla_ServoUtils_h
 #define mozilla_ServoUtils_h
 
 #include "mozilla/Assertions.h"
 #include "mozilla/TypeTraits.h"
 #include "MainThreadUtils.h"
 
 namespace mozilla {
 
-// Defined in ServoBindings.cpp.
+// Defined in GeckoBindings.cpp.
+void InitializeServo();
+void ShutdownServo();
 void AssertIsMainThreadOrServoFontMetricsLocked();
 
 class ServoStyleSet;
 extern ServoStyleSet* sInServoTraversal;
 inline bool IsInServoTraversal()
 {
   // The callers of this function are generally main-thread-only _except_
   // for potentially running during the Servo traversal, in which case they may
--- a/layout/style/StyleSheet.h
+++ b/layout/style/StyleSheet.h
@@ -26,16 +26,17 @@
 class nsIDocument;
 class nsINode;
 class nsIPrincipal;
 
 namespace mozilla {
 
 class ServoCSSRuleList;
 class ServoStyleSet;
+enum class OriginFlags : uint8_t;
 
 typedef MozPromise</* Dummy */ bool,
                    /* Dummy */ bool,
                    /* IsExclusive = */ true> StyleSheetParsePromise;
 
 namespace css {
 class GroupRule;
 class Loader;
@@ -141,17 +142,17 @@ public:
   NS_IMETHOD StyleSheetLoaded(StyleSheet* aSheet, bool aWasAlternate,
                               nsresult aStatus) final;
 
   // Internal GetCssRules methods which do not have security check and
   // completeness check.
   ServoCSSRuleList* GetCssRulesInternal();
 
   // Returns the stylesheet's Servo origin as an OriginFlags value.
-  OriginFlags GetOrigin();
+  mozilla::OriginFlags GetOrigin();
 
   /**
    * The different changes that a stylesheet may go through.
    *
    * Used by the StyleSets in order to handle more efficiently some kinds of
    * changes.
    */
   enum class ChangeType {
--- a/layout/style/StyleSheetInfo.h
+++ b/layout/style/StyleSheetInfo.h
@@ -13,16 +13,17 @@
 #include "mozilla/CORSMode.h"
 
 #include "nsIURI.h"
 
 class nsIPrincipal;
 
 namespace mozilla {
 class StyleSheet;
+struct URLExtraData;
 
 /**
  * Struct for data common to CSSStyleSheetInner and ServoStyleSheet.
  */
 struct StyleSheetInfo final
 {
   typedef net::ReferrerPolicy ReferrerPolicy;
 
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -70,32 +70,35 @@ EXPORTS += [
     'nsStyleUtil.h',
     'nsTimingFunction.h',
 ]
 
 EXPORTS.mozilla += [
     '!ServoCSSPropList.h',
     'AnimationCollection.h',
     'BindingStyleRule.h',
+    'BorrowedTypeList.h',
     'CachedInheritingStyles.h',
     'ComputedStyle.h',
     'ComputedStyleInlines.h',
     'CSSEnabledState.h',
     'CSSPropFlags.h',
     'DeclarationBlock.h',
     'DocumentStyleRootIterator.h',
+    'GeckoBindings.h',
     'LayerAnimationInfo.h',
     'MappedDeclarations.h',
     'MediaFeatureChange.h',
     'PostTraversalTask.h',
     'PreloadedStyleSheet.h',
+    'RustCell.h',
     'ServoArcTypeList.h',
-    'ServoBindingList.h',
     'ServoBindings.h',
     'ServoBindingTypes.h',
+    'ServoBoxedTypeList.h',
     'ServoComputedData.h',
     'ServoComputedDataInlines.h',
     'ServoCSSParser.h',
     'ServoCSSRuleList.h',
     'ServoElementSnapshot.h',
     'ServoElementSnapshotTable.h',
     'ServoStyleSet.h',
     'ServoStyleSetInlines.h',
@@ -167,16 +170,17 @@ UNIFIED_SOURCES += [
     'CSSStyleRule.cpp',
     'CSSSupportsRule.cpp',
     'DeclarationBlock.cpp',
     'DocumentStyleRootIterator.cpp',
     'ErrorReporter.cpp',
     'FontFace.cpp',
     'FontFaceSet.cpp',
     'FontFaceSetIterator.cpp',
+    'GeckoBindings.cpp',
     'GroupRule.cpp',
     'ImageLoader.cpp',
     'LayerAnimationInfo.cpp',
     'Loader.cpp',
     'MappedDeclarations.cpp',
     'MediaList.cpp',
     'MediaQueryList.cpp',
     'nsAnimationManager.cpp',
@@ -198,17 +202,16 @@ UNIFIED_SOURCES += [
     'nsStyleStruct.cpp',
     'nsStyleTransformMatrix.cpp',
     'nsStyleUtil.cpp',
     'nsTransitionManager.cpp',
     'PaintWorkletImpl.cpp',
     'PostTraversalTask.cpp',
     'PreloadedStyleSheet.cpp',
     'Rule.cpp',
-    'ServoBindings.cpp',
     'ServoCSSParser.cpp',
     'ServoCSSRuleList.cpp',
     'ServoElementSnapshot.cpp',
     'ServoStyleSet.cpp',
     'StreamLoader.cpp',
     'StyleAnimationValue.cpp',
     'StyleComplexColor.cpp',
     'StyleSheet.cpp',
--- a/layout/style/nsCSSValue.h
+++ b/layout/style/nsCSSValue.h
@@ -8,17 +8,17 @@
 
 #ifndef nsCSSValue_h___
 #define nsCSSValue_h___
 
 #include "mozilla/Attributes.h"
 #include "mozilla/CORSMode.h"
 #include "mozilla/FontPropertyTypes.h"
 #include "mozilla/MemoryReporting.h"
-#include "mozilla/ServoTypes.h"
+#include "mozilla/ServoBindingTypes.h"
 #include "mozilla/SheetType.h"
 #include "mozilla/URLExtraData.h"
 #include "mozilla/UniquePtr.h"
 
 #include "nsCSSKeywords.h"
 #include "nsCSSPropertyID.h"
 #include "nsCoord.h"
 #include "nsProxyRelease.h"
--- a/layout/style/nsDOMCSSAttrDeclaration.h
+++ b/layout/style/nsDOMCSSAttrDeclaration.h
@@ -53,17 +53,17 @@ public:
 
   nsresult SetPropertyValue(const nsCSSPropertyID aPropID,
                             const nsAString& aValue,
                             nsIPrincipal* aSubjectPrincipal) override;
 
   static void MutationClosureFunction(void* aData);
 
   void
-  GetPropertyChangeClosure(DeclarationBlockMutationClosure* aClosure,
+  GetPropertyChangeClosure(mozilla::DeclarationBlockMutationClosure* aClosure,
                            mozilla::MutationClosureData* aClosureData) final
   {
     if (!mIsSMILOverride) {
       aClosure->function = MutationClosureFunction;
       aClosure->data = aClosureData;
       aClosureData->mClosure = MutationClosureFunction;
       aClosureData->mElement = mElement;
     }
--- a/layout/style/nsDOMCSSDeclaration.h
+++ b/layout/style/nsDOMCSSDeclaration.h
@@ -18,20 +18,20 @@
 #include "nsIURI.h"
 #include "nsCOMPtr.h"
 #include "nsCompatibility.h"
 
 class nsIPrincipal;
 class nsIDocument;
 struct JSContext;
 class JSObject;
-struct DeclarationBlockMutationClosure;
 
 namespace mozilla {
 class DeclarationBlock;
+struct DeclarationBlockMutationClosure;
 namespace css {
 class Loader;
 class Rule;
 } // namespace css
 namespace dom {
 class Element;
 }
 
@@ -214,17 +214,17 @@ protected:
                                     const nsAString& aPropValue,
                                     bool aIsImportant,
                                     nsIPrincipal* aSubjectPrincipal);
 
   nsresult RemovePropertyInternal(nsCSSPropertyID aPropID);
   nsresult RemovePropertyInternal(const nsAString& aProperty);
 
   virtual void
-  GetPropertyChangeClosure(DeclarationBlockMutationClosure* aClosure,
+  GetPropertyChangeClosure(mozilla::DeclarationBlockMutationClosure* aClosure,
                            mozilla::MutationClosureData* aClosureData)
   {
   }
 
 protected:
   virtual ~nsDOMCSSDeclaration();
 
 private:
--- a/layout/style/nsMediaFeatures.cpp
+++ b/layout/style/nsMediaFeatures.cpp
@@ -17,16 +17,17 @@
 #include "nsDeviceContext.h"
 #include "nsIBaseWindow.h"
 #include "nsIDocShell.h"
 #include "nsIDocument.h"
 #include "nsIWidget.h"
 #include "nsContentUtils.h"
 #include "mozilla/StyleSheet.h"
 #include "mozilla/StyleSheetInlines.h"
+#include "mozilla/GeckoBindings.h"
 
 using namespace mozilla;
 
 static nsTArray<const nsStaticAtom*>* sSystemMetrics = nullptr;
 
 #ifdef XP_WIN
 struct OperatingSystemVersionInfo {
   LookAndFeel::OperatingSystemVersion mId;
--- a/servo/components/style/build_gecko.rs
+++ b/servo/components/style/build_gecko.rs
@@ -295,45 +295,73 @@ mod bindings {
         }
         let bytes = result.into_bytes();
         File::create(&out_file)
             .unwrap()
             .write_all(&bytes)
             .expect("Unable to write output");
     }
 
-    fn get_arc_types() -> Vec<String> {
+    fn get_types(filename: &str, macro_pat: &str) -> Vec<(String, String)> {
         // Read the file
-        let mut list_file = File::open(DISTDIR_PATH.join("include/mozilla/ServoArcTypeList.h"))
-            .expect("Unable to open ServoArcTypeList.h");
+        let path = DISTDIR_PATH.join("include/mozilla/").join(filename);
+        let mut list_file = File::open(path)
+            .expect(&format!("Unable to open {}", filename));
         let mut content = String::new();
         list_file
             .read_to_string(&mut content)
-            .expect("Fail to read ServoArcTypeList.h");
+            .expect(&format!("Failed to read {}", filename));
         // Remove comments
         let block_comment_re = Regex::new(r#"(?s)/\*.*?\*/"#).unwrap();
+        let line_comment_re = Regex::new(r#"//.*"#).unwrap();
         let content = block_comment_re.replace_all(&content, "");
+        let content = line_comment_re.replace_all(&content, "");
         // Extract the list
-        let re = Regex::new(r#"^SERVO_ARC_TYPE\(\w+,\s*(\w+)\)$"#).unwrap();
+        let re_string = format!(r#"^({})\(.+,\s*(\w+)\)$"#, macro_pat);
+        let re = Regex::new(&re_string).unwrap();
         content
             .lines()
             .map(|line| line.trim())
             .filter(|line| !line.is_empty())
             .map(|line| {
-                re.captures(&line)
+                let captures = re.captures(&line)
                     .expect(&format!(
-                        "Unrecognized line in ServoArcTypeList.h: '{}'",
+                        "Unrecognized line in {}: '{}'",
+                        filename,
                         line
-                    )).get(1)
-                    .unwrap()
-                    .as_str()
-                    .to_string()
+                    ));
+                let macro_name = captures.get(1).unwrap().as_str().to_string();
+                let type_name = captures.get(2).unwrap().as_str().to_string();
+                (macro_name, type_name)
             }).collect()
     }
 
+    fn get_borrowed_types() -> Vec<(bool, String)> {
+        get_types("BorrowedTypeList.h", "GECKO_BORROWED_TYPE(?:_MUT)?")
+            .into_iter()
+            .map(|(macro_name, type_name)| {
+                (macro_name.ends_with("MUT"), type_name)
+            })
+            .collect()
+    }
+
+    fn get_arc_types() -> Vec<String> {
+        get_types("ServoArcTypeList.h", "SERVO_ARC_TYPE")
+            .into_iter()
+            .map(|(_, type_name)| type_name)
+            .collect()
+    }
+
+    fn get_boxed_types() -> Vec<String> {
+        get_types("ServoBoxedTypeList.h", "SERVO_BOXED_TYPE")
+            .into_iter()
+            .map(|(_, type_name)| type_name)
+            .collect()
+    }
+
     struct BuilderWithConfig<'a> {
         builder: Builder,
         config: &'a Table,
         used_keys: HashSet<&'static str>,
     }
     impl<'a> BuilderWithConfig<'a> {
         fn new(builder: Builder, config: &'a Table) -> Self {
             BuilderWithConfig {
@@ -519,45 +547,49 @@ mod bindings {
             .handle_table_items("array-types", |builder, item| {
                 let cpp_type = item["cpp-type"].as_str().unwrap();
                 let rust_type = item["rust-type"].as_str().unwrap();
                 builder
                     .raw_line(format!(concat!("pub type nsTArrayBorrowed_{}<'a> = ",
                                               "&'a mut ::gecko_bindings::structs::nsTArray<{}>;"),
                                       cpp_type, rust_type))
             })
-            .handle_table_items("servo-owned-types", |mut builder, item| {
-                let name = item["name"].as_str().unwrap();
-                builder = builder.blacklist_type(format!("{}Owned", name))
-                    .raw_line(format!("pub type {0}Owned = ::gecko_bindings::sugar::ownership::Owned<{0}>;", name))
-                    .blacklist_type(format!("{}OwnedOrNull", name))
-                    .raw_line(format!(concat!("pub type {0}OwnedOrNull = ",
-                                              "::gecko_bindings::sugar::ownership::OwnedOrNull<{0}>;"), name))
-                    .mutable_borrowed_type(name);
-                if item["opaque"].as_bool().unwrap() {
-                    builder = builder.zero_size_type(name, &structs_types);
-                }
-                builder
-            })
             .handle_str_items("servo-immutable-borrow-types", |b, ty| b.borrowed_type(ty))
             // Right now the only immutable borrow types are ones which we import
             // from the |structs| module. As such, we don't need to create an opaque
             // type with zero_size_type. If we ever introduce immutable borrow types
             // which _do_ need to be opaque, we'll need a separate mode.
             .handle_str_items("servo-borrow-types", |b, ty| b.mutable_borrowed_type(ty))
             .get_builder();
+        for (is_mut, ty) in get_borrowed_types().iter() {
+            if *is_mut {
+                builder = builder.mutable_borrowed_type(ty);
+            } else {
+                builder = builder.borrowed_type(ty);
+            }
+        }
         for ty in get_arc_types().iter() {
             builder = builder
                 .blacklist_type(format!("{}Strong", ty))
                 .raw_line(format!(
                     "pub type {0}Strong = ::gecko_bindings::sugar::ownership::Strong<{0}>;",
                     ty
                 )).borrowed_type(ty)
                 .zero_size_type(ty, &structs_types);
         }
+        for ty in get_boxed_types().iter() {
+            builder = builder
+                .blacklist_type(format!("{}Owned", ty))
+                .raw_line(format!("pub type {0}Owned = ::gecko_bindings::sugar::ownership::Owned<{0}>;", ty))
+                .blacklist_type(format!("{}OwnedOrNull", ty))
+                .raw_line(format!(concat!("pub type {0}OwnedOrNull = ",
+                                          "::gecko_bindings::sugar::ownership::OwnedOrNull<{0}>;"), ty))
+                .mutable_borrowed_type(ty)
+                .zero_size_type(ty, &structs_types);
+        }
         write_binding_file(builder, BINDINGS_FILE, &fixups);
     }
 
     fn generate_atoms() {
         let script = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap())
             .join("gecko")
             .join("regen_atoms.py");
         println!("cargo:rerun-if-changed={}", script.display());
--- a/servo/components/style/gecko/data.rs
+++ b/servo/components/style/gecko/data.rs
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 //! Data needed to style a Gecko document.
 
 use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
 use context::QuirksMode;
 use dom::TElement;
 use gecko_bindings::bindings::{self, RawServoStyleSet};
-use gecko_bindings::structs::{RawGeckoPresContextOwned, ServoStyleSetSizes, StyleSheet as DomStyleSheet};
+use gecko_bindings::structs::{RawGeckoPresContextBorrowed, ServoStyleSetSizes, StyleSheet as DomStyleSheet};
 use gecko_bindings::structs::{StyleSheetInfo, nsIDocument};
 use gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI};
 use invalidation::media_queries::{MediaListKey, ToMediaListKey};
 use malloc_size_of::MallocSizeOfOps;
 use media_queries::{Device, MediaList};
 use properties::ComputedValues;
 use selector_parser::SnapshotMap;
 use servo_arc::Arc;
@@ -138,17 +138,17 @@ pub struct PerDocumentStyleDataImpl {
 }
 
 /// The data itself is an `AtomicRefCell`, which guarantees the proper semantics
 /// and unexpected races while trying to mutate it.
 pub struct PerDocumentStyleData(AtomicRefCell<PerDocumentStyleDataImpl>);
 
 impl PerDocumentStyleData {
     /// Create a dummy `PerDocumentStyleData`.
-    pub fn new(pres_context: RawGeckoPresContextOwned) -> Self {
+    pub fn new(pres_context: RawGeckoPresContextBorrowed) -> Self {
         let device = Device::new(pres_context);
 
         // FIXME(emilio, tlin): How is this supposed to work with XBL? This is
         // right now not always honored, see bug 1405543...
         //
         // Should we just force XBL Stylists to be NoQuirks?
         let quirks_mode =
             unsafe { (*device.pres_context().mDocument.raw::<nsIDocument>()).mCompatMode };
--- a/servo/components/style/gecko/media_queries.rs
+++ b/servo/components/style/gecko/media_queries.rs
@@ -7,17 +7,17 @@
 use app_units::AU_PER_PX;
 use app_units::Au;
 use cssparser::RGBA;
 use euclid::Size2D;
 use euclid::TypedScale;
 use gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor};
 use gecko_bindings::bindings;
 use gecko_bindings::structs;
-use gecko_bindings::structs::{nsPresContext, RawGeckoPresContextOwned};
+use gecko_bindings::structs::{nsPresContext, RawGeckoPresContextBorrowed};
 use media_queries::MediaType;
 use properties::ComputedValues;
 use servo_arc::Arc;
 use std::fmt;
 use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicUsize, Ordering};
 use string_cache::Atom;
 use style_traits::{CSSPixel, DevicePixel};
 use style_traits::viewport::ViewportConstraints;
@@ -25,17 +25,17 @@ use values::{CustomIdent, KeyframesName}
 use values::computed::font::FontSize;
 
 /// The `Device` in Gecko wraps a pres context, has a default values computed,
 /// and contains all the viewport rule state.
 pub struct Device {
     /// NB: The pres context lifetime is tied to the styleset, who owns the
     /// stylist, and thus the `Device`, so having a raw pres context pointer
     /// here is fine.
-    pres_context: RawGeckoPresContextOwned,
+    pres_context: RawGeckoPresContextBorrowed,
     default_values: Arc<ComputedValues>,
     /// The font size of the root element
     /// This is set when computing the style of the root
     /// element, and used for rem units in other elements.
     ///
     /// When computing the style of the root element, there can't be any
     /// other style being computed at the same time, given we need the style of
     /// the parent to compute everything else. So it is correct to just use
@@ -72,17 +72,17 @@ impl fmt::Debug for Device {
     }
 }
 
 unsafe impl Sync for Device {}
 unsafe impl Send for Device {}
 
 impl Device {
     /// Trivially constructs a new `Device`.
-    pub fn new(pres_context: RawGeckoPresContextOwned) -> Self {
+    pub fn new(pres_context: RawGeckoPresContextBorrowed) -> Self {
         assert!(!pres_context.is_null());
         Device {
             pres_context,
             default_values: ComputedValues::default_values(unsafe { &*pres_context }),
             // FIXME(bz): Seems dubious?
             root_font_size: AtomicIsize::new(FontSize::medium().size().0 as isize),
             body_text_color: AtomicUsize::new(unsafe { &*pres_context }.mDefaultColor as usize),
             used_root_font_size: AtomicBool::new(false),
--- a/servo/components/style/gecko_bindings/sugar/ns_t_array.rs
+++ b/servo/components/style/gecko_bindings/sugar/ns_t_array.rs
@@ -77,32 +77,47 @@ impl<T> nsTArray<T> {
     where
         T: Copy,
     {
         unsafe { self.clear() }
     }
 
     /// Resize and set the length of the array to `len`.
     ///
-    /// unsafe because the array may contain uninitialized members.
+    /// unsafe because this may leave the array with uninitialized elements.
     ///
-    /// This will not call constructors, if you need that, either manually add
+    /// This will not call constructors.  If you need that, either manually add
     /// bindings or run the typed `EnsureCapacity` call on the gecko side.
     pub unsafe fn set_len(&mut self, len: u32) {
         // this can leak
         debug_assert!(len >= self.len() as u32);
         self.ensure_capacity(len as usize);
         let header = self.header_mut();
         header.mLength = len;
     }
 
     /// Resizes an array containing only POD elements
     ///
+    /// unsafe because this may leave the array with uninitialized elements.
+    ///
     /// This will not leak since it only works on POD types (and thus doesn't assert)
     pub unsafe fn set_len_pod(&mut self, len: u32)
     where
         T: Copy,
     {
         self.ensure_capacity(len as usize);
         let header = self.header_mut();
         header.mLength = len;
     }
+
+    /// Collects the given iterator into this array.
+    ///
+    /// Not unsafe because we won't leave uninitialized elements in the array.
+    pub fn assign_from_iter_pod<I>(&mut self, iter: I)
+    where
+        T: Copy,
+        I: ExactSizeIterator + Iterator<Item = T>,
+    {
+        debug_assert!(iter.len() <= 0xFFFFFFFF);
+        unsafe { self.set_len_pod(iter.len() as u32); }
+        self.iter_mut().zip(iter).for_each(|(r, v)| *r = v);
+    }
 }
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -1368,45 +1368,32 @@ impl Clone for ${style_struct.gecko_stru
     <% impl_simple_copy(ident, gecko_ffi_name) %>
 
     #[allow(non_snake_case)]
     pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
         From::from(self.gecko.${gecko_ffi_name})
     }
 </%def>
 
-<%def name="impl_font_settings(ident, tag_type, value_type, gecko_value_type)">
+<%def name="impl_font_settings(ident, gecko_type, tag_type, value_type, gecko_value_type)">
     <%
     gecko_ffi_name = to_camel_case_lower(ident)
     %>
 
     pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
-        let current_settings = &mut self.gecko.mFont.${gecko_ffi_name};
-        current_settings.clear_pod();
-
-        unsafe { current_settings.set_len_pod(v.0.len() as u32) };
-
-        for (current, other) in current_settings.iter_mut().zip(v.0.iter()) {
-            current.mTag = other.tag.0;
-            current.mValue = other.value as ${gecko_value_type};
-        }
+        let iter = v.0.iter().map(|other| structs::${gecko_type} {
+            mTag: other.tag.0,
+            mValue: other.value as ${gecko_value_type},
+        });
+        self.gecko.mFont.${gecko_ffi_name}.assign_from_iter_pod(iter);
     }
 
     pub fn copy_${ident}_from(&mut self, other: &Self) {
-        let current_settings = &mut self.gecko.mFont.${gecko_ffi_name};
-        let other_settings = &other.gecko.mFont.${gecko_ffi_name};
-        let settings_length = other_settings.len() as u32;
-
-        current_settings.clear_pod();
-        unsafe { current_settings.set_len_pod(settings_length) };
-
-        for (current, other) in current_settings.iter_mut().zip(other_settings.iter()) {
-            current.mTag = other.mTag;
-            current.mValue = other.mValue;
-        }
+        let iter = other.gecko.mFont.${gecko_ffi_name}.iter().map(|s| *s);
+        self.gecko.mFont.${gecko_ffi_name}.assign_from_iter_pod(iter);
     }
 
     pub fn reset_${ident}(&mut self, other: &Self) {
         self.copy_${ident}_from(other)
     }
 
     pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
         use values::generics::font::{FontSettings, FontTag, ${tag_type}};
@@ -2269,18 +2256,18 @@ fn static_assert() {
                              font-feature-settings font-variation-settings
                              -moz-min-font-size-ratio -x-text-zoom"""
 %>
 <%self:impl_trait style_struct_name="Font"
     skip_longhands="${skip_font_longhands}">
 
     // Negative numbers are invalid at parse time, but <integer> is still an
     // i32.
-    <% impl_font_settings("font_feature_settings", "FeatureTagValue", "i32", "u32") %>
-    <% impl_font_settings("font_variation_settings", "VariationValue", "f32", "f32") %>
+    <% impl_font_settings("font_feature_settings", "gfxFontFeature", "FeatureTagValue", "i32", "u32") %>
+    <% impl_font_settings("font_variation_settings", "gfxFontVariation", "VariationValue", "f32", "f32") %>
 
     pub fn fixup_none_generic(&mut self, device: &Device) {
         self.gecko.mFont.systemFont = false;
         unsafe {
             bindings::Gecko_nsStyleFont_FixupNoneGeneric(&mut self.gecko, device.pres_context())
         }
     }
 
@@ -3208,38 +3195,26 @@ fn static_assert() {
 
     ${impl_style_coord("scroll_snap_points_x", "mScrollSnapPointsX")}
     ${impl_style_coord("scroll_snap_points_y", "mScrollSnapPointsY")}
 
     pub fn set_scroll_snap_coordinate<I>(&mut self, v: I)
         where I: IntoIterator<Item = longhands::scroll_snap_coordinate::computed_value::single_value::T>,
               I::IntoIter: ExactSizeIterator
     {
-        let v = v.into_iter();
-
-        unsafe { self.gecko.mScrollSnapCoordinate.set_len_pod(v.len() as u32); }
-        for (gecko, servo) in self.gecko.mScrollSnapCoordinate
-                               .iter_mut()
-                               .zip(v) {
-            gecko.mXPosition = servo.horizontal.into();
-            gecko.mYPosition = servo.vertical.into();
-        }
+        let iter = v.into_iter().map(|c| structs::mozilla::Position {
+            mXPosition: c.horizontal.into(),
+            mYPosition: c.vertical.into(),
+        });
+        self.gecko.mScrollSnapCoordinate.assign_from_iter_pod(iter);
     }
 
     pub fn copy_scroll_snap_coordinate_from(&mut self, other: &Self) {
-        unsafe {
-            self.gecko.mScrollSnapCoordinate
-                .set_len_pod(other.gecko.mScrollSnapCoordinate.len() as u32);
-        }
-
-        for (this, that) in self.gecko.mScrollSnapCoordinate
-                               .iter_mut()
-                               .zip(other.gecko.mScrollSnapCoordinate.iter()) {
-            *this = *that;
-        }
+        let iter = other.gecko.mScrollSnapCoordinate.iter().map(|c| *c);
+        self.gecko.mScrollSnapCoordinate.assign_from_iter_pod(iter);
     }
 
     pub fn reset_scroll_snap_coordinate(&mut self, other: &Self) {
         self.copy_scroll_snap_coordinate_from(other)
     }
 
     pub fn clone_scroll_snap_coordinate(&self) -> longhands::scroll_snap_coordinate::computed_value::T {
         let vec = self.gecko.mScrollSnapCoordinate.iter().map(|f| f.into()).collect();
@@ -4990,22 +4965,22 @@ fn set_style_svg_path(
     // Setup type.
     shape_source.mType = StyleShapeSourceType::Path;
 
     // Setup path.
     let gecko_path = unsafe {
         Gecko_NewStyleSVGPath(shape_source);
         &mut shape_source.__bindgen_anon_1.mSVGPath.as_mut().mPtr.as_mut().unwrap()
     };
-    unsafe { gecko_path.mPath.set_len(servo_path.commands().len() as u32) };
-    debug_assert_eq!(gecko_path.mPath.len(), servo_path.commands().len());
-    for (servo, gecko) in servo_path.commands().iter().zip(gecko_path.mPath.iter_mut()) {
+
+    let iter = servo_path.commands().iter().map(|command| {
         // unsafe: cbindgen ensures the representation is the same.
-        *gecko = unsafe { transmute(*servo) };
-    }
+        unsafe { transmute(*command) }
+    });
+    gecko_path.mPath.assign_from_iter_pod(iter);
 
     // Setup fill-rule.
     // unsafe: cbindgen ensures the representation is the same.
     gecko_path.mFillRule = unsafe { transmute(fill) };
 }
 
 <%def name="impl_shape_source(ident, gecko_ffi_name)">
     pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -4,17 +4,17 @@
 
 <%namespace name="helpers" file="/helpers.mako.rs" />
 
 <%
     from data import to_idl_name, SYSTEM_FONT_LONGHANDS, to_camel_case
     from itertools import groupby
 %>
 
-#[cfg(feature = "gecko")] use gecko_bindings::bindings::RawServoAnimationValueMap;
+#[cfg(feature = "gecko")] use gecko_bindings::structs::RawServoAnimationValueMap;
 #[cfg(feature = "gecko")] use gecko_bindings::structs::RawGeckoGfxMatrix4x4;
 #[cfg(feature = "gecko")] use gecko_bindings::structs::nsCSSPropertyID;
 #[cfg(feature = "gecko")] use gecko_bindings::sugar::ownership::{HasFFI, HasSimpleFFI};
 use itertools::{EitherOrBoth, Itertools};
 use num_traits::Zero;
 use properties::{CSSWideKeyword, PropertyDeclaration};
 use properties::longhands;
 use properties::longhands::font_weight::computed_value::T as FontWeight;
--- a/servo/components/style/stylesheets/font_feature_values_rule.rs
+++ b/servo/components/style/stylesheets/font_feature_values_rule.rs
@@ -174,22 +174,17 @@ impl Parse for VectorValues {
 
         Ok(VectorValues(vec))
     }
 }
 
 #[cfg(feature = "gecko")]
 impl ToGeckoFontFeatureValues for VectorValues {
     fn to_gecko_font_feature_values(&self, array: &mut nsTArray<u32>) {
-        unsafe {
-            array.set_len_pod(self.0.len() as u32);
-        }
-        for (dest, value) in array.iter_mut().zip(self.0.iter()) {
-            *dest = *value;
-        }
+        array.assign_from_iter_pod(self.0.iter().map(|v| *v));
     }
 }
 
 /// Parses a list of `FamilyName`s.
 pub fn parse_family_name_list<'i, 't>(
     context: &ParserContext,
     input: &mut Parser<'i, 't>,
 ) -> Result<Vec<FamilyName>, ParseError<'i>> {
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -31,16 +31,17 @@ use style::gecko::data::{GeckoStyleSheet
 use style::gecko::global_style_data::{GLOBAL_STYLE_DATA, GlobalStyleData, STYLE_THREAD_POOL};
 use style::gecko::restyle_damage::GeckoRestyleDamage;
 use style::gecko::selector_parser::{NonTSPseudoClass, PseudoElement};
 use style::gecko::traversal::RecalcStyleOnly;
 use style::gecko::wrapper::{GeckoElement, GeckoNode};
 use style::gecko_bindings::bindings;
 use style::gecko_bindings::bindings::{RawGeckoElementBorrowed, RawGeckoElementBorrowedOrNull, RawGeckoNodeBorrowed};
 use style::gecko_bindings::bindings::{RawGeckoKeyframeListBorrowed, RawGeckoKeyframeListBorrowedMut};
+use style::gecko_bindings::bindings::RawGeckoPresContextBorrowed;
 use style::gecko_bindings::bindings::{RawServoAuthorStyles, RawServoAuthorStylesBorrowed};
 use style::gecko_bindings::bindings::{RawServoAuthorStylesBorrowedMut, RawServoAuthorStylesOwned};
 use style::gecko_bindings::bindings::{RawServoCounterStyleRule, RawServoCounterStyleRuleBorrowed};
 use style::gecko_bindings::bindings::{RawServoDeclarationBlockBorrowed, RawServoDeclarationBlockStrong};
 use style::gecko_bindings::bindings::{RawServoFontFaceRuleBorrowed, RawServoFontFaceRuleStrong};
 use style::gecko_bindings::bindings::{RawServoFontFeatureValuesRule, RawServoFontFeatureValuesRuleBorrowed};
 use style::gecko_bindings::bindings::{RawServoImportRule, RawServoImportRuleBorrowed};
 use style::gecko_bindings::bindings::{RawServoKeyframe, RawServoKeyframeBorrowed, RawServoKeyframeStrong};
@@ -97,17 +98,16 @@ use style::gecko_bindings::structs::{nsR
 use style::gecko_bindings::structs::AtomArray;
 use style::gecko_bindings::structs::IterationCompositeOperation;
 use style::gecko_bindings::structs::MallocSizeOf as GeckoMallocSizeOf;
 use style::gecko_bindings::structs::OriginFlags;
 use style::gecko_bindings::structs::OriginFlags_Author;
 use style::gecko_bindings::structs::OriginFlags_User;
 use style::gecko_bindings::structs::OriginFlags_UserAgent;
 use style::gecko_bindings::structs::RawGeckoGfxMatrix4x4;
-use style::gecko_bindings::structs::RawGeckoPresContextOwned;
 use style::gecko_bindings::structs::RawServoFontFaceRule;
 use style::gecko_bindings::structs::RawServoSelectorList;
 use style::gecko_bindings::structs::RawServoSourceSizeList;
 use style::gecko_bindings::structs::SeenPtrs;
 use style::gecko_bindings::structs::ServoElementSnapshotTable;
 use style::gecko_bindings::structs::ServoStyleSetSizes;
 use style::gecko_bindings::structs::ServoTraversalFlags;
 use style::gecko_bindings::structs::StyleRuleInclusion;
@@ -1684,21 +1684,19 @@ fn write_locked_arc<T, R, F>(raw: &<Lock
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_CssRules_ListTypes(
     rules: ServoCssRulesBorrowed,
     result: nsTArrayBorrowed_uintptr_t,
 ) {
     read_locked_arc(rules, |rules: &CssRules| {
-        let iter = rules.0.iter().map(|rule| rule.rule_type() as usize);
-        let (size, upper) = iter.size_hint();
-        debug_assert_eq!(size, upper.unwrap());
-        unsafe { result.set_len(size as u32) };
-        result.iter_mut().zip(iter).fold((), |_, (r, v)| *r = v);
+        result.assign_from_iter_pod(
+            rules.0.iter().map(|rule| rule.rule_type() as usize)
+        );
     })
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_CssRules_InsertRule(
     rules: ServoCssRulesBorrowed,
     contents: RawServoStyleSheetContentsBorrowed,
     rule: *const nsACString,
@@ -3335,32 +3333,31 @@ pub extern "C" fn Servo_ComputedValues_G
         // rules.
         if node.importance().important() {
             continue;
         }
 
         result.push(style_rule);
     }
 
-    unsafe { rules.set_len(result.len() as u32) };
-    for (ref src, ref mut dest) in result.into_iter().zip(rules.iter_mut()) {
+    rules.assign_from_iter_pod(result.into_iter().map(|src| {
         src.with_arc(|a| {
             a.with_raw_offset_arc(|arc| {
-                **dest = *Locked::<StyleRule>::arc_as_borrowed(arc);
+                *Locked::<StyleRule>::arc_as_borrowed(arc) as *const _
             })
-        });
-    }
+        })
+    }))
 }
 
 /// See the comment in `Device` to see why it's ok to pass an owned reference to
 /// the pres context (hint: the context outlives the StyleSet, that holds the
 /// device alive).
 #[no_mangle]
 pub extern "C" fn Servo_StyleSet_Init(
-    pres_context: RawGeckoPresContextOwned,
+    pres_context: RawGeckoPresContextBorrowed,
 ) -> *mut RawServoStyleSet {
     let data = Box::new(PerDocumentStyleData::new(pres_context));
     Box::into_raw(data) as *mut RawServoStyleSet
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_StyleSet_RebuildCachedData(raw_data: RawServoStyleSetBorrowed) {
     let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -13174,61 +13174,16 @@
     "expires_in_version": "70",
     "kind": "exponential",
     "low": 32,
     "high": 750,
     "n_buckets": 40,
     "keyed": true,
     "description": "Measures the number of milliseconds we spend waiting for sync message manager IPC messages to finish sending, keyed by message name. Note: only messages that wait for more than 500 microseconds are included in this probe."
   },
-  "TIMEOUT_EXECUTION_FG_MS":
-  {
-    "record_in_processes": ["main", "content"],
-    "alert_emails": ["farre@mozilla.com"],
-    "bug_numbers": [1355480],
-    "expires_in_version": "61",
-    "kind": "exponential",
-    "high": 1000,
-    "n_buckets": 20,
-    "description": "Time in ms used to execute callbacks from setTimeout/setInterval, when the script belongs to a tab in the foreground and the script is not on the tracking list. Multiple events are aggregated over a 1s interval."
-  },
-  "TIMEOUT_EXECUTION_FG_TRACKING_MS":
-  {
-    "record_in_processes": ["main", "content"],
-    "alert_emails": ["farre@mozilla.com"],
-    "bug_numbers": [1355480],
-    "expires_in_version": "61",
-    "kind": "exponential",
-    "high": 1000,
-    "n_buckets": 20,
-    "description": "Time in ms used to execute callbacks from setTimeout/setInterval, when the script belongs to a tab in the foreground and the script is on the tracking list. Multiple events are aggregated over a 1s interval."
-  },
-  "TIMEOUT_EXECUTION_BG_MS":
-  {
-    "record_in_processes": ["main", "content"],
-    "alert_emails": ["farre@mozilla.com"],
-    "bug_numbers": [1355480],
-    "expires_in_version": "61",
-    "kind": "exponential",
-    "high": 1000,
-    "n_buckets": 20,
-    "description": "Time in ms used to execute callbacks from setTimeout/setInterval, when the script belongs to a tab in the background and the script is not on the tracking list. Multiple events are aggregated over a 1s interval."
-  },
-  "TIMEOUT_EXECUTION_BG_TRACKING_MS":
-  {
-    "record_in_processes": ["main", "content"],
-    "alert_emails": ["farre@mozilla.com"],
-    "bug_numbers": [1355480],
-    "expires_in_version": "61",
-    "kind": "exponential",
-    "low": 1,
-    "high": 1000,
-    "n_buckets": 10,
-    "description": "Time in ms used to execute callbacks from setTimeout/setInterval, when the script belongs to a tab in the background and the script is on the tracking list. Multiple events are aggregated over a 1s interval."
-  },
   "TIME_TO_DOM_LOADING_MS": {
     "record_in_processes": ["content"],
     "alert_emails": ["hbambas@mozilla.com", "vgosu@mozilla.com", "jduell@mozilla.com"],
     "expires_in_version": "never",
     "releaseChannelCollection": "opt-out",
     "kind": "exponential",
     "high": 50000,
     "n_buckets": 100,
--- a/toolkit/components/url-classifier/tests/mochitest/chrome.ini
+++ b/toolkit/components/url-classifier/tests/mochitest/chrome.ini
@@ -37,17 +37,16 @@ support-files =
   !/toolkit/components/url-classifier/tests/mochitest/basic.vtt
   !/toolkit/components/url-classifier/tests/mochitest/basic.vtt^headers^
   !/toolkit/components/url-classifier/tests/mochitest/dnt.html
   !/toolkit/components/url-classifier/tests/mochitest/dnt.sjs
   !/toolkit/components/url-classifier/tests/mochitest/update.sjs
   !/toolkit/components/url-classifier/tests/mochitest/bad.css
   !/toolkit/components/url-classifier/tests/mochitest/bad.css^headers^
   !/toolkit/components/url-classifier/tests/mochitest/gethashFrame.html
-  !/toolkit/components/url-classifier/tests/mochitest/tracker.js
   !/toolkit/components/url-classifier/tests/mochitest/seek.webm
   !/toolkit/components/url-classifier/tests/mochitest/cache.sjs
 
 [test_lookup_system_principal.html]
 [test_classified_annotations.html]
 tags = trackingprotection
 skip-if = os == 'linux' && asan # Bug 1202548
 [test_allowlisted_annotations.html]
--- a/toolkit/components/url-classifier/tests/mochitest/classifierFrame.html
+++ b/toolkit/components/url-classifier/tests/mochitest/classifierFrame.html
@@ -27,39 +27,25 @@ function checkLoads() {
   // cache entries.
   if (window.parent.firstLoad) {
     window.parent.info("Reloading from cache...");
     window.parent.firstLoad = false;
     window.parent.loadTestFrame();
     return;
   }
 
-  let dwu = window.parent.SpecialPowers.getDOMWindowUtils(window);
-  let timer1 = window.setTimeout(function() {}, 0);
-  window.parent.ok(!dwu.isTimeoutTracking(timer1),
-                   "Timeout set from main script should not be considered as tracking");
-  /* global getTrackerTimeout */
-  let timer2 = getTrackerTimeout();
-  window.parent.ok(dwu.isTimeoutTracking(timer2),
-                   "Timeout set from included script should be considered as tracking");
-  window.clearTimeout(timer1);
-  window.clearTimeout(timer2);
-
   // End (parent) test.
   window.parent.SimpleTest.finish();
 }
 
 </script>
 
 <!-- Try loading from a malware javascript URI -->
 <script type="text/javascript" src="http://malware.example.com/tests/toolkit/components/url-classifier/tests/mochitest/evil.js"></script>
 
-<!-- Try loading from a tracker javascript URI -->
-<script type="text/javascript" src="http://tracking.example.com/tests/toolkit/components/url-classifier/tests/mochitest/tracker.js"></script>
-
 <!-- Try loading from an uwanted software css URI -->
 <link rel="stylesheet" type="text/css" href="http://unwanted.example.com/tests/toolkit/components/url-classifier/tests/mochitest/evil.css"></link>
 
 <!-- Try loading a marked-as-malware css through an @import from a clean URI -->
 <link rel="stylesheet" type="text/css" href="import.css"></link>
 </head>
 
 <body onload="checkLoads()">
--- a/toolkit/components/url-classifier/tests/mochitest/mochitest.ini
+++ b/toolkit/components/url-classifier/tests/mochitest/mochitest.ini
@@ -25,17 +25,16 @@ support-files =
   basic.vtt^headers^
   dnt.html
   dnt.sjs
   update.sjs
   bad.css
   bad.css^headers^
   gethash.sjs
   gethashFrame.html
-  tracker.js
   seek.webm
   cache.sjs
 
 [test_classifier.html]
 skip-if = (os == 'linux' && debug) #Bug 1199778
 [test_classifier_match.html]
 [test_classifier_worker.html]
 [test_classify_ping.html]
deleted file mode 100644
--- a/toolkit/components/url-classifier/tests/mochitest/tracker.js
+++ /dev/null
@@ -1,3 +0,0 @@
-function getTrackerTimeout() {
-  return window.setTimeout(function() {}, 0);
-}