Bug 1444905: Remove scoped style support from the old style system. r=xidorn,smaug
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 12 Mar 2018 15:07:42 +0100
changeset 407816 543c4f3183a2812d33b75226cecafa04bb35c541
parent 407815 b3d94aa6bbd8e0e784adb05966df183fd4e7837e
child 407884 43f6b05c381757502bab10f08dac8ae7fcaf34db
push id100791
push userecoal95@gmail.com
push dateTue, 13 Mar 2018 09:26:37 +0000
treeherdermozilla-inbound@543c4f3183a2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn, smaug
bugs1444905
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1444905: Remove scoped style support from the old style system. r=xidorn,smaug Summary: It uses two node bits that can be better suited for something else. Reviewers: xidorn, smaug Bug #: 1444905 Differential Revision: https://phabricator.services.mozilla.com/D709 MozReview-Commit-ID: HIPDtHm6xpM
dom/base/Element.cpp
dom/base/FragmentOrElement.cpp
dom/base/FragmentOrElement.h
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
dom/base/nsDocument.cpp
dom/base/nsIDocument.h
dom/base/nsINode.h
dom/base/nsStyleLinkElement.cpp
dom/base/nsStyleLinkElement.h
dom/html/HTMLLinkElement.cpp
dom/html/HTMLLinkElement.h
dom/html/HTMLStyleElement.cpp
dom/html/HTMLStyleElement.h
dom/html/test/test_style_attributes_reflection.html
dom/ipc/ContentPrefs.cpp
dom/svg/SVGStyleElement.cpp
dom/svg/SVGStyleElement.h
dom/webidl/HTMLStyleElement.webidl
dom/webidl/SVGStyleElement.webidl
dom/xml/XMLStylesheetProcessingInstruction.cpp
dom/xml/XMLStylesheetProcessingInstruction.h
layout/base/GeckoRestyleManager.cpp
layout/base/nsCSSFrameConstructor.cpp
layout/reftests/css-mediaqueries/reftest.list
layout/reftests/css-mediaqueries/scoped-mq-update-helper.html
layout/reftests/css-mediaqueries/scoped-mq-update-ref.html
layout/reftests/css-mediaqueries/scoped-mq-update.html
layout/reftests/moz.build
layout/reftests/reftest.list
layout/reftests/scoped-style/reftest.list
layout/reftests/scoped-style/scoped-style-001-ref.html
layout/reftests/scoped-style/scoped-style-001.html
layout/reftests/scoped-style/scoped-style-002-ref.html
layout/reftests/scoped-style/scoped-style-002.html
layout/reftests/scoped-style/scoped-style-003-ref.html
layout/reftests/scoped-style/scoped-style-003.html
layout/reftests/scoped-style/scoped-style-004-ref.html
layout/reftests/scoped-style/scoped-style-004.html
layout/reftests/scoped-style/scoped-style-005-ref.html
layout/reftests/scoped-style/scoped-style-005.html
layout/reftests/scoped-style/scoped-style-006-ref.html
layout/reftests/scoped-style/scoped-style-006.html
layout/reftests/scoped-style/scoped-style-007-ref.html
layout/reftests/scoped-style/scoped-style-007.html
layout/reftests/scoped-style/scoped-style-008-ref.html
layout/reftests/scoped-style/scoped-style-008.html
layout/reftests/scoped-style/scoped-style-009-ref.html
layout/reftests/scoped-style/scoped-style-009.html
layout/reftests/scoped-style/scoped-style-010-ref.html
layout/reftests/scoped-style/scoped-style-010.html
layout/reftests/scoped-style/scoped-style-011-ref.html
layout/reftests/scoped-style/scoped-style-011.html
layout/reftests/scoped-style/scoped-style-012-ref.html
layout/reftests/scoped-style/scoped-style-012.html
layout/reftests/scoped-style/scoped-style-013-ref.html
layout/reftests/scoped-style/scoped-style-013.html
layout/reftests/scoped-style/scoped-style-014-ref.html
layout/reftests/scoped-style/scoped-style-014.html
layout/reftests/scoped-style/scoped-style-015-ref.html
layout/reftests/scoped-style/scoped-style-015.html
layout/reftests/scoped-style/scoped-style-016-ref.html
layout/reftests/scoped-style/scoped-style-016.html
layout/reftests/scoped-style/scoped-style-017-ref.html
layout/reftests/scoped-style/scoped-style-017.html
layout/reftests/scoped-style/scoped-style-018-ref.html
layout/reftests/scoped-style/scoped-style-018.html
layout/reftests/scoped-style/scoped-style-019-ref.svg
layout/reftests/scoped-style/scoped-style-019.svg
layout/reftests/scoped-style/scoped-style-020-ref.html
layout/reftests/scoped-style/scoped-style-020.html
layout/reftests/scoped-style/scoped-style-021-ref.html
layout/reftests/scoped-style/scoped-style-021.html
layout/reftests/scoped-style/scoped-style-022-ref.html
layout/reftests/scoped-style/scoped-style-022.html
layout/reftests/scoped-style/scoped-style-023-ref.html
layout/reftests/scoped-style/scoped-style-023.html
layout/reftests/scoped-style/scoped-style-024-ref.html
layout/reftests/scoped-style/scoped-style-024.html
layout/reftests/scoped-style/scoped-style-charset-ref.html
layout/reftests/scoped-style/scoped-style-charset.html
layout/reftests/scoped-style/scoped-style-document-ref.html
layout/reftests/scoped-style/scoped-style-document.html
layout/reftests/scoped-style/scoped-style-dynamic-001-ref.html
layout/reftests/scoped-style/scoped-style-dynamic-001.html
layout/reftests/scoped-style/scoped-style-dynamic-002-ref.html
layout/reftests/scoped-style/scoped-style-dynamic-002.html
layout/reftests/scoped-style/scoped-style-dynamic-003-ref.html
layout/reftests/scoped-style/scoped-style-dynamic-003.html
layout/reftests/scoped-style/scoped-style-dynamic-004-ref.html
layout/reftests/scoped-style/scoped-style-dynamic-004.html
layout/reftests/scoped-style/scoped-style-dynamic-005-ref.html
layout/reftests/scoped-style/scoped-style-dynamic-005.html
layout/reftests/scoped-style/scoped-style-dynamic-006-ref.html
layout/reftests/scoped-style/scoped-style-dynamic-006.html
layout/reftests/scoped-style/scoped-style-dynamic-007-ref.html
layout/reftests/scoped-style/scoped-style-dynamic-007.html
layout/reftests/scoped-style/scoped-style-dynamic-008-ref.html
layout/reftests/scoped-style/scoped-style-dynamic-008.html
layout/reftests/scoped-style/scoped-style-dynamic-009-ref.html
layout/reftests/scoped-style/scoped-style-dynamic-009.html
layout/reftests/scoped-style/scoped-style-dynamic-010-ref.html
layout/reftests/scoped-style/scoped-style-dynamic-010.html
layout/reftests/scoped-style/scoped-style-dynamic-011-ref.html
layout/reftests/scoped-style/scoped-style-dynamic-011.html
layout/reftests/scoped-style/scoped-style-dynamic-012-ref.svg
layout/reftests/scoped-style/scoped-style-dynamic-012.svg
layout/reftests/scoped-style/scoped-style-dynamic-013-ref.svg
layout/reftests/scoped-style/scoped-style-dynamic-013.svg
layout/reftests/scoped-style/scoped-style-dynamic-014-ref.svg
layout/reftests/scoped-style/scoped-style-dynamic-014.svg
layout/reftests/scoped-style/scoped-style-dynamic-015-ref.svg
layout/reftests/scoped-style/scoped-style-dynamic-015.svg
layout/reftests/scoped-style/scoped-style-font-face-ref.html
layout/reftests/scoped-style/scoped-style-font-face.html
layout/reftests/scoped-style/scoped-style-import-ref.html
layout/reftests/scoped-style/scoped-style-import.html
layout/reftests/scoped-style/scoped-style-important-001-ref.html
layout/reftests/scoped-style/scoped-style-important-001.html
layout/reftests/scoped-style/scoped-style-important-002-ref.html
layout/reftests/scoped-style/scoped-style-important-002.html
layout/reftests/scoped-style/scoped-style-important-003-ref.html
layout/reftests/scoped-style/scoped-style-important-003.html
layout/reftests/scoped-style/scoped-style-important-004-ref.html
layout/reftests/scoped-style/scoped-style-important-004.html
layout/reftests/scoped-style/scoped-style-important-005-ref.html
layout/reftests/scoped-style/scoped-style-important-005.html
layout/reftests/scoped-style/scoped-style-important-006-ref.html
layout/reftests/scoped-style/scoped-style-important-006.html
layout/reftests/scoped-style/scoped-style-important-007-ref.html
layout/reftests/scoped-style/scoped-style-important-007.html
layout/reftests/scoped-style/scoped-style-imported.css
layout/reftests/scoped-style/scoped-style-keyframes-ref.html
layout/reftests/scoped-style/scoped-style-keyframes.html
layout/reftests/scoped-style/scoped-style-media-ref.html
layout/reftests/scoped-style/scoped-style-media.html
layout/reftests/scoped-style/scoped-style-namespace-ref.html
layout/reftests/scoped-style/scoped-style-namespace.html
layout/reftests/scoped-style/scoped-style-pseudo-001-ref.html
layout/reftests/scoped-style/scoped-style-pseudo-001.html
layout/reftests/scoped-style/scoped-style-pseudo-002-ref.html
layout/reftests/scoped-style/scoped-style-pseudo-002.html
layout/reftests/scoped-style/scoped-style-pseudo-003-ref.html
layout/reftests/scoped-style/scoped-style-pseudo-003.html
layout/reftests/scoped-style/scoped-style-supports-ref.html
layout/reftests/scoped-style/scoped-style-supports.html
layout/style/CSSStyleSheet.cpp
layout/style/CSSStyleSheet.h
layout/style/Loader.cpp
layout/style/Loader.h
layout/style/SheetType.h
layout/style/nsCSSRuleProcessor.cpp
layout/style/nsCSSRuleProcessor.h
layout/style/nsRuleProcessorData.h
layout/style/nsStyleSet.cpp
layout/style/nsStyleSet.h
modules/libpref/init/all.js
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -1707,21 +1707,16 @@ Element::BindToTree(nsIDocument* aDocume
   }
 
   // Propagate scoped style sheet tracking bit.
   if (mParent->IsContent()) {
     nsIContent* parent = mParent->AsContent();
     if (ShadowRoot* shadowRootParent = ShadowRoot::FromNode(parent)) {
       parent = shadowRootParent->GetHost();
     }
-
-    bool inStyleScope = parent->IsElementInStyleScope();
-
-    SetIsElementInStyleScope(inStyleScope);
-    SetIsElementInStyleScopeFlagOnShadowTree(inStyleScope);
   }
 
   // This has to be here, rather than in nsGenericHTMLElement::BindToTree,
   //  because it has to happen after updating the parent pointer, but before
   //  recursively binding the kids.
   if (IsHTMLElement()) {
     SetDirOnBind(this, aParent);
   }
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -2463,45 +2463,8 @@ FragmentOrElement::AddSizeOfExcludingThi
   *aNodeSize +=
     mAttrsAndChildren.SizeOfExcludingThis(aSizes.mState.mMallocSizeOf);
 
   nsDOMSlots* slots = GetExistingDOMSlots();
   if (slots) {
     *aNodeSize += slots->SizeOfIncludingThis(aSizes.mState.mMallocSizeOf);
   }
 }
-
-void
-FragmentOrElement::SetIsElementInStyleScopeFlagOnSubtree(bool aInStyleScope)
-{
-  if (aInStyleScope && IsElementInStyleScope()) {
-    return;
-  }
-
-  if (IsElement()) {
-    SetIsElementInStyleScope(aInStyleScope);
-    SetIsElementInStyleScopeFlagOnShadowTree(aInStyleScope);
-  }
-
-  nsIContent* n = GetNextNode(this);
-  while (n) {
-    if (n->IsElementInStyleScope()) {
-      n = n->GetNextNonChildNode(this);
-    } else {
-      if (n->IsElement()) {
-        n->SetIsElementInStyleScope(aInStyleScope);
-        n->AsElement()->SetIsElementInStyleScopeFlagOnShadowTree(aInStyleScope);
-      }
-      n = n->GetNextNode(this);
-    }
-  }
-}
-
-void
-FragmentOrElement::SetIsElementInStyleScopeFlagOnShadowTree(bool aInStyleScope)
-{
-  NS_ASSERTION(IsElement(), "calling SetIsElementInStyleScopeFlagOnShadowTree "
-                            "on a non-Element is useless");
-  ShadowRoot* shadowRoot = GetShadowRoot();
-  if (shadowRoot) {
-    shadowRoot->SetIsElementInStyleScopeFlagOnSubtree(aInStyleScope);
-  }
-}
--- a/dom/base/FragmentOrElement.h
+++ b/dom/base/FragmentOrElement.h
@@ -159,24 +159,16 @@ public:
   virtual void SaveSubtreeState() override;
 
   nsIHTMLCollection* Children();
   uint32_t ChildElementCount()
   {
     return Children()->Length();
   }
 
-  /**
-   * Sets the IsElementInStyleScope flag on each element in the subtree rooted
-   * at this node, including any elements reachable through shadow trees.
-   *
-   * @param aInStyleScope The flag value to set.
-   */
-  void SetIsElementInStyleScopeFlagOnSubtree(bool aInStyleScope);
-
 public:
   /**
    * If there are listeners for DOMNodeInserted event, fires the event on all
    * aNodes
    */
   static void FireNodeInserted(nsIDocument* aDoc,
                                nsINode* aParent,
                                nsTArray<nsCOMPtr<nsIContent> >& aNodes);
@@ -370,24 +362,16 @@ protected:
       GetExistingExtendedContentSlots());
   }
 
   nsExtendedDOMSlots* GetExistingExtendedDOMSlots()
   {
     return static_cast<nsExtendedDOMSlots*>(GetExistingExtendedContentSlots());
   }
 
-  /**
-   * Calls SetIsElementInStyleScopeFlagOnSubtree for each shadow tree attached
-   * to this node, which is assumed to be an Element.
-   *
-   * @param aInStyleScope The IsElementInStyleScope flag value to set.
-   */
-  void SetIsElementInStyleScopeFlagOnShadowTree(bool aInStyleScope);
-
   friend class ::ContentUnbinder;
   /**
    * Array containing all attributes and children for this element
    */
   nsAttrAndChildArray mAttrsAndChildren;
 };
 
 } // namespace dom
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -306,17 +306,16 @@ bool nsContentUtils::sSkipCursorMoveForS
 bool nsContentUtils::sRequestIdleCallbackEnabled = false;
 bool nsContentUtils::sLowerNetworkPriority = false;
 bool nsContentUtils::sTailingEnabled = false;
 bool nsContentUtils::sShowInputPlaceholderOnFocus = true;
 bool nsContentUtils::sAutoFocusEnabled = true;
 #ifndef RELEASE_OR_BETA
 bool nsContentUtils::sBypassCSSOMOriginCheck = false;
 #endif
-bool nsContentUtils::sIsScopedStyleEnabled = false;
 
 bool nsContentUtils::sIsBytecodeCacheEnabled = false;
 int32_t nsContentUtils::sBytecodeCacheStrategy = 0;
 nsCString* nsContentUtils::sJSBytecodeMimeType = nullptr;
 
 int32_t nsContentUtils::sPrivacyMaxInnerWidth = 1000;
 int32_t nsContentUtils::sPrivacyMaxInnerHeight = 1000;
 
@@ -711,19 +710,16 @@ nsContentUtils::Init()
 
   Preferences::AddBoolVarCache(&sRequestIdleCallbackEnabled,
                                "dom.requestIdleCallback.enabled", false);
 
 #ifndef RELEASE_OR_BETA
   sBypassCSSOMOriginCheck = getenv("MOZ_BYPASS_CSSOM_ORIGIN_CHECK");
 #endif
 
-  Preferences::AddBoolVarCache(&sIsScopedStyleEnabled,
-                               "layout.css.scoped-style.enabled", false);
-
   Preferences::AddBoolVarCache(&sLowerNetworkPriority,
                                "privacy.trackingprotection.lower_network_priority", false);
 
   Preferences::AddBoolVarCache(&sTailingEnabled,
                                "network.http.tailing.enabled", true);
 
   Preferences::AddBoolVarCache(&sShowInputPlaceholderOnFocus,
                                "dom.placeholder.show_on_focus", true);
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -2442,24 +2442,16 @@ public:
 #ifdef RELEASE_OR_BETA
     return false;
 #else
     return sBypassCSSOMOriginCheck;
 #endif
   }
 
   /**
-   * Returns true if the <style scoped> enabling pref is true.
-   */
-  static bool IsScopedStylePrefEnabled()
-  {
-    return sIsScopedStyleEnabled;
-  }
-
-  /**
    * Fire mutation events for changes caused by parsing directly into a
    * context node.
    *
    * @param aDoc the document of the node
    * @param aDest the destination node that got stuff appended to it
    * @param aOldChildCount the number of children the node had before parsing
    */
   static void FireMutationEventsForDirectParsing(nsIDocument* aDoc,
@@ -3464,17 +3456,16 @@ private:
   static bool sRequestIdleCallbackEnabled;
   static bool sLowerNetworkPriority;
   static bool sTailingEnabled;
   static bool sShowInputPlaceholderOnFocus;
   static bool sAutoFocusEnabled;
 #ifndef RELEASE_OR_BETA
   static bool sBypassCSSOMOriginCheck;
 #endif
-  static bool sIsScopedStyleEnabled;
   static bool sIsBytecodeCacheEnabled;
   static int32_t sBytecodeCacheStrategy;
   static uint32_t sCookiesLifetimePolicy;
   static uint32_t sCookiesBehavior;
   static bool sShortcutsCustomized;
 
   static int32_t sPrivacyMaxInnerWidth;
   static int32_t sPrivacyMaxInnerHeight;
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -1496,17 +1496,16 @@ nsIDocument::nsIDocument()
     mDOMCompleteSet(false),
     mAutoFocusFired(false),
     mScrolledToRefAlready(false),
     mChangeScrollPosWhenScrollingToRef(false),
     mHasWarnedAboutBoxObjects(false),
     mDelayFrameLoaderInitialization(false),
     mSynchronousDOMContentLoaded(false),
     mMaybeServiceWorkerControlled(false),
-    mIsScopedStyleEnabled(eScopedStyle_Unknown),
     mPendingFullscreenRequests(0),
     mXMLDeclarationBits(0),
     mCompatMode(eCompatibility_FullStandards),
     mReadyState(ReadyState::READYSTATE_UNINITIALIZED),
     mStyleBackendType(StyleBackendType::None),
 #ifdef MOZILLA_INTERNAL_API
     mVisibilityState(dom::VisibilityState::Hidden),
 #else
@@ -13336,28 +13335,16 @@ nsIDocument::IsThirdParty()
     return mIsThirdParty.value();
   }
 
   // Fall-through. Document is not a Third-Party Document.
   mIsThirdParty.emplace(false);
   return mIsThirdParty.value();
 }
 
-bool
-nsIDocument::IsScopedStyleEnabled()
-{
-  if (mIsScopedStyleEnabled == eScopedStyle_Unknown) {
-    mIsScopedStyleEnabled = nsContentUtils::IsChromeDoc(this) ||
-                            nsContentUtils::IsScopedStylePrefEnabled()
-                              ? eScopedStyle_Enabled
-                              : eScopedStyle_Disabled;
-  }
-  return mIsScopedStyleEnabled == eScopedStyle_Enabled;
-}
-
 void
 nsIDocument::ClearStaleServoData()
 {
   DocumentStyleRootIterator iter(this);
   while (Element* root = iter.GetNextStyleRoot()) {
     ServoRestyleManager::ClearServoDataFromSubtree(root);
   }
 }
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -4123,20 +4123,16 @@ protected:
   bool mDelayFrameLoaderInitialization: 1;
 
   bool mSynchronousDOMContentLoaded: 1;
 
   // Set to true when the document is possibly controlled by the ServiceWorker.
   // Used to prevent multiple requests to ServiceWorkerManager.
   bool mMaybeServiceWorkerControlled: 1;
 
-  // Whether <style scoped> support is enabled in this document.
-  enum { eScopedStyle_Unknown, eScopedStyle_Disabled, eScopedStyle_Enabled };
-  unsigned int mIsScopedStyleEnabled : 2;
-
   uint8_t mPendingFullscreenRequests;
 
   uint8_t mXMLDeclarationBits;
 
   // Compatibility mode
   nsCompatibility mCompatMode;
 
   // Our readyState
--- a/dom/base/nsINode.h
+++ b/dom/base/nsINode.h
@@ -1657,21 +1657,16 @@ private:
     // node that determines its direction
     NodeHasDirAutoSet,
     // Set if the node is a text node descendant of a node with dir=auto
     // and has a TextNodeDirectionalityMap property listing the elements whose
     // direction it determines.
     NodeHasTextNodeDirectionalityMap,
     // Set if a node in the node's parent chain has dir=auto.
     NodeAncestorHasDirAuto,
-    // Set if the element is in the scope of a scoped style sheet; this flag is
-    // only accurate for elements bound to a document
-    ElementIsInStyleScope,
-    // Set if the element is a scoped style sheet root
-    ElementIsScopedStyleRoot,
     // Set if the node is handling a click.
     NodeHandlingClick,
     // Set if the node has had :hover selectors matched against it
     NodeHasRelevantHoverRules,
     // Set if the element has a parser insertion mode other than "in body",
     // per the HTML5 "Parse state" section.
     ElementHasWeirdParserInsertionMode,
     // Parser sets this flag if it has notified about the node.
@@ -1790,33 +1785,16 @@ public:
 
   void SetAncestorHasDirAuto() { SetBoolFlag(NodeAncestorHasDirAuto); }
   void ClearAncestorHasDirAuto() { ClearBoolFlag(NodeAncestorHasDirAuto); }
   bool AncestorHasDirAuto() const { return GetBoolFlag(NodeAncestorHasDirAuto); }
 
   // Implemented in nsIContentInlines.h.
   inline bool NodeOrAncestorHasDirAuto() const;
 
-  void SetIsElementInStyleScope(bool aValue) {
-    MOZ_ASSERT(IsElement(), "SetIsInStyleScope on a non-Element node");
-    SetBoolFlag(ElementIsInStyleScope, aValue);
-  }
-  void SetIsElementInStyleScope() {
-    MOZ_ASSERT(IsElement(), "SetIsInStyleScope on a non-Element node");
-    SetBoolFlag(ElementIsInStyleScope);
-  }
-  void ClearIsElementInStyleScope() {
-    MOZ_ASSERT(IsElement(), "ClearIsInStyleScope on a non-Element node");
-    ClearBoolFlag(ElementIsInStyleScope);
-  }
-  bool IsElementInStyleScope() const { return GetBoolFlag(ElementIsInStyleScope); }
-
-  void SetIsScopedStyleRoot() { SetBoolFlag(ElementIsScopedStyleRoot); }
-  void ClearIsScopedStyleRoot() { ClearBoolFlag(ElementIsScopedStyleRoot); }
-  bool IsScopedStyleRoot() { return GetBoolFlag(ElementIsScopedStyleRoot); }
   bool HasRelevantHoverRules() const { return GetBoolFlag(NodeHasRelevantHoverRules); }
   void SetHasRelevantHoverRules() { SetBoolFlag(NodeHasRelevantHoverRules); }
   void SetParserHasNotified() { SetBoolFlag(ParserHasNotified); };
   bool HasParserNotified() { return GetBoolFlag(ParserHasNotified); }
 
   void SetMayBeApzAware() { SetBoolFlag(MayBeApzAware); }
   bool NodeMayBeApzAware() const
   {
--- a/dom/base/nsStyleLinkElement.cpp
+++ b/dom/base/nsStyleLinkElement.cpp
@@ -325,66 +325,16 @@ nsStyleLinkElement::UpdateStyleSheetInte
                                              ShadowRoot *aOldShadowRoot,
                                              bool aForceUpdate)
 {
   bool notify, alternate;
   return DoUpdateStyleSheet(aOldDocument, aOldShadowRoot, nullptr, &notify,
                             &alternate, aForceUpdate);
 }
 
-static bool
-IsScopedStyleElement(nsIContent* aContent)
-{
-  // This is quicker than, say, QIing aContent to nsStyleLinkElement
-  // and then calling its virtual GetStyleSheetInfo method to find out
-  // if it is scoped.
-  return (aContent->IsHTMLElement(nsGkAtoms::style) ||
-          aContent->IsSVGElement(nsGkAtoms::style)) &&
-         aContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::scoped) &&
-         aContent->OwnerDoc()->IsScopedStyleEnabled();
-}
-
-static bool
-HasScopedStyleSheetChild(nsIContent* aContent)
-{
-  for (nsIContent* n = aContent->GetFirstChild(); n; n = n->GetNextSibling()) {
-    if (IsScopedStyleElement(n)) {
-      return true;
-    }
-  }
-  return false;
-}
-
-// Called when aElement has had a <style scoped> child removed.
-static void
-UpdateIsElementInStyleScopeFlagOnSubtree(Element* aElement)
-{
-  NS_ASSERTION(aElement->IsElementInStyleScope(),
-               "only call UpdateIsElementInStyleScopeFlagOnSubtree on a "
-               "subtree that has IsElementInStyleScope boolean flag set");
-
-  if (HasScopedStyleSheetChild(aElement)) {
-    return;
-  }
-
-  aElement->ClearIsElementInStyleScope();
-
-  nsIContent* n = aElement->GetNextNode(aElement);
-  while (n) {
-    if (HasScopedStyleSheetChild(n)) {
-      n = n->GetNextNonChildNode(aElement);
-    } else {
-      if (n->IsElement()) {
-        n->ClearIsElementInStyleScope();
-      }
-      n = n->GetNextNode(aElement);
-    }
-  }
-}
-
 nsresult
 nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument* aOldDocument,
                                        ShadowRoot* aOldShadowRoot,
                                        nsICSSLoaderObserver* aObserver,
                                        bool* aWillNotify,
                                        bool* aIsAlternate,
                                        bool aForceUpdate)
 {
@@ -404,30 +354,16 @@ nsStyleLinkElement::DoUpdateStyleSheet(n
   // Check for a ShadowRoot because link elements are inert in a
   // ShadowRoot.
   ShadowRoot* containingShadow = thisContent->GetContainingShadow();
   if (thisContent->IsHTMLElement(nsGkAtoms::link) &&
       (aOldShadowRoot || containingShadow)) {
     return NS_OK;
   }
 
-  // XXXheycam ServoStyleSheets do not support <style scoped>.
-  Element* oldScopeElement = nullptr;
-  if (mStyleSheet) {
-    if (mStyleSheet->IsServo()) {
-      // XXXheycam ServoStyleSheets don't support <style scoped>.
-    } else {
-#ifdef MOZ_OLD_STYLE
-      oldScopeElement = mStyleSheet->AsGecko()->GetScopeElement();
-#else
-      MOZ_CRASH("old style system disabled");
-#endif
-    }
-  }
-
   if (mStyleSheet && (aOldDocument || aOldShadowRoot)) {
     MOZ_ASSERT(!(aOldDocument && aOldShadowRoot),
                "ShadowRoot content is never in document, thus "
                "there should not be a old document and old "
                "ShadowRoot simultaneously.");
 
     // We're removing the link element from the document or shadow tree,
     // unload the stylesheet.  We want to do this even if updates are
@@ -437,19 +373,16 @@ nsStyleLinkElement::DoUpdateStyleSheet(n
       aOldShadowRoot->RemoveSheet(mStyleSheet);
     } else {
       aOldDocument->BeginUpdate(UPDATE_STYLE);
       aOldDocument->RemoveStyleSheet(mStyleSheet);
       aOldDocument->EndUpdate(UPDATE_STYLE);
     }
 
     nsStyleLinkElement::SetStyleSheet(nullptr);
-    if (oldScopeElement) {
-      UpdateIsElementInStyleScopeFlagOnSubtree(oldScopeElement);
-    }
   }
 
   // When static documents are created, stylesheets are cloned manually.
   if (mDontLoadStyle || !mUpdatesEnabled ||
       thisContent->OwnerDoc()->IsStaticDocument()) {
     return NS_OK;
   }
 
@@ -487,31 +420,24 @@ nsStyleLinkElement::DoUpdateStyleSheet(n
     nsStyleLinkElement::SetStyleSheet(nullptr);
   }
 
   if (!uri && !isInline) {
     return NS_OK; // If href is empty and this is not inline style then just bail
   }
 
   nsAutoString title, type, media;
-  bool isScoped;
   bool isAlternate;
 
-  GetStyleSheetInfo(title, type, media, &isScoped, &isAlternate);
+  GetStyleSheetInfo(title, type, media, &isAlternate);
 
   if (!type.LowerCaseEqualsLiteral("text/css")) {
     return NS_OK;
   }
 
-  Element* scopeElement = isScoped ? thisContent->GetParentElement() : nullptr;
-  if (scopeElement) {
-    NS_ASSERTION(isInline, "non-inline style must not have scope element");
-    scopeElement->SetIsElementInStyleScopeFlagOnSubtree(true);
-  }
-
   bool doneLoading = false;
   nsresult rv = NS_OK;
 
   // Load the link's referrerpolicy attribute. If the link does not provide a
   // referrerpolicy attribute, ignore this and use the document's referrer
   // policy
 
   net::ReferrerPolicy referrerPolicy = GetLinkReferrerPolicy();
@@ -533,17 +459,17 @@ nsStyleLinkElement::DoUpdateStyleSheet(n
                                            triggeringPrincipal,
                                            doc->GetDocumentURI(),
                                            mLineNumber, text, &rv))
       return rv;
 
     // Parse the style sheet.
     rv = doc->CSSLoader()->
       LoadInlineStyle(thisContent, text, triggeringPrincipal, mLineNumber,
-                      title, media, referrerPolicy, scopeElement,
+                      title, media, referrerPolicy,
                       aObserver, &doneLoading, &isAlternate);
   } else {
     nsAutoString integrity;
     if (thisContent->IsElement()) {
       thisContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::integrity,
                                         integrity);
     }
     if (!integrity.IsEmpty()) {
@@ -572,65 +498,8 @@ nsStyleLinkElement::DoUpdateStyleSheet(n
 
   NS_ENSURE_SUCCESS(rv, rv);
 
   *aWillNotify = !doneLoading;
   *aIsAlternate = isAlternate;
 
   return NS_OK;
 }
-
-void
-nsStyleLinkElement::UpdateStyleSheetScopedness(bool aIsNowScoped)
-{
-  if (!mStyleSheet) {
-    return;
-  }
-
-  if (mStyleSheet->IsServo()) {
-    // XXXheycam ServoStyleSheets don't support <style scoped>.
-    NS_ERROR("stylo: ServoStyleSheets don't support <style scoped>");
-    return;
-  }
-
-#ifdef MOZ_OLD_STYLE
-  CSSStyleSheet* sheet = mStyleSheet->AsGecko();
-
-  nsCOMPtr<nsIContent> thisContent = do_QueryInterface(this);
-
-  Element* oldScopeElement = sheet->GetScopeElement();
-  Element* newScopeElement = aIsNowScoped ?
-                               thisContent->GetParentElement() :
-                               nullptr;
-
-  if (oldScopeElement == newScopeElement) {
-    return;
-  }
-
-  nsIDocument* document = thisContent->GetOwnerDocument();
-
-  if (thisContent->IsInShadowTree()) {
-    ShadowRoot* containingShadow = thisContent->GetContainingShadow();
-    containingShadow->RemoveSheet(mStyleSheet);
-
-    sheet->SetScopeElement(newScopeElement);
-
-    containingShadow->InsertSheet(mStyleSheet, thisContent);
-  } else {
-    document->BeginUpdate(UPDATE_STYLE);
-    document->RemoveStyleSheet(mStyleSheet);
-
-    sheet->SetScopeElement(newScopeElement);
-
-    document->AddStyleSheet(mStyleSheet);
-    document->EndUpdate(UPDATE_STYLE);
-  }
-
-  if (oldScopeElement) {
-    UpdateIsElementInStyleScopeFlagOnSubtree(oldScopeElement);
-  }
-  if (newScopeElement) {
-    newScopeElement->SetIsElementInStyleScopeFlagOnSubtree(true);
-  }
-#else
-  MOZ_CRASH("old style system disabled");
-#endif
-}
--- a/dom/base/nsStyleLinkElement.h
+++ b/dom/base/nsStyleLinkElement.h
@@ -86,23 +86,20 @@ protected:
    *                     changed.  This should be used in cases when something
    *                     about the content that affects the resulting sheet
    *                     changed but the URI may not have changed.
    */
   nsresult UpdateStyleSheetInternal(nsIDocument *aOldDocument,
                                     mozilla::dom::ShadowRoot *aOldShadowRoot,
                                     bool aForceUpdate = false);
 
-  void UpdateStyleSheetScopedness(bool aIsNowScoped);
-
   virtual already_AddRefed<nsIURI> GetStyleSheetURL(bool* aIsInline, nsIPrincipal** aTriggeringPrincipal) = 0;
   virtual void GetStyleSheetInfo(nsAString& aTitle,
                                  nsAString& aType,
                                  nsAString& aMedia,
-                                 bool* aIsScoped,
                                  bool* aIsAlternate) = 0;
 
   virtual mozilla::CORSMode GetCORSMode() const
   {
     // Default to no CORS
     return mozilla::CORS_NONE;
   }
 
--- a/dom/html/HTMLLinkElement.cpp
+++ b/dom/html/HTMLLinkElement.cpp
@@ -428,23 +428,21 @@ HTMLLinkElement::GetStyleSheetURL(bool* 
   nsCOMPtr<nsIURI> uri = Link::GetURI();
   return uri.forget();
 }
 
 void
 HTMLLinkElement::GetStyleSheetInfo(nsAString& aTitle,
                                    nsAString& aType,
                                    nsAString& aMedia,
-                                   bool* aIsScoped,
                                    bool* aIsAlternate)
 {
   aTitle.Truncate();
   aType.Truncate();
   aMedia.Truncate();
-  *aIsScoped = false;
   *aIsAlternate = false;
 
   nsAutoString rel;
   GetAttr(kNameSpaceID_None, nsGkAtoms::rel, rel);
   uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(rel);
   // Is it a stylesheet link?
   if (!(linkTypes & nsStyleLinkElement::eSTYLESHEET)) {
     return;
--- a/dom/html/HTMLLinkElement.h
+++ b/dom/html/HTMLLinkElement.h
@@ -202,22 +202,23 @@ public:
     ClearHasPendingLinkUpdate();
     nsGenericHTMLElement::NodeInfoChanged(aOldDoc);
   }
 
 protected:
   virtual ~HTMLLinkElement();
 
   // nsStyleLinkElement
-  virtual already_AddRefed<nsIURI> GetStyleSheetURL(bool* aIsInline, nsIPrincipal** aTriggeringPrincipal) override;
-  virtual void GetStyleSheetInfo(nsAString& aTitle,
-                                 nsAString& aType,
-                                 nsAString& aMedia,
-                                 bool* aIsScoped,
-                                 bool* aIsAlternate) override;
+  already_AddRefed<nsIURI>
+    GetStyleSheetURL(bool* aIsInline, nsIPrincipal** aTriggeringPrincipal) final;
+
+  void GetStyleSheetInfo(nsAString& aTitle,
+                         nsAString& aType,
+                         nsAString& aMedia,
+                         bool* aIsAlternate) final;
 protected:
   RefPtr<nsDOMTokenList> mRelList;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_HTMLLinkElement_h
--- a/dom/html/HTMLStyleElement.cpp
+++ b/dom/html/HTMLStyleElement.cpp
@@ -140,20 +140,16 @@ HTMLStyleElement::AfterSetAttr(int32_t a
                                nsIPrincipal* aSubjectPrincipal,
                                bool aNotify)
 {
   if (aNameSpaceID == kNameSpaceID_None) {
     if (aName == nsGkAtoms::title ||
         aName == nsGkAtoms::media ||
         aName == nsGkAtoms::type) {
       UpdateStyleSheetInternal(nullptr, nullptr, true);
-    } else if (aName == nsGkAtoms::scoped &&
-               OwnerDoc()->IsScopedStyleEnabled()) {
-      bool isScoped = aValue;
-      UpdateStyleSheetScopedness(isScoped);
     }
   }
 
   return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue,
                                             aOldValue, aSubjectPrincipal, aNotify);
 }
 
 NS_IMETHODIMP
@@ -196,17 +192,16 @@ HTMLStyleElement::GetStyleSheetURL(bool*
   *aTriggeringPrincipal = do_AddRef(mTriggeringPrincipal).take();
   return nullptr;
 }
 
 void
 HTMLStyleElement::GetStyleSheetInfo(nsAString& aTitle,
                                     nsAString& aType,
                                     nsAString& aMedia,
-                                    bool* aIsScoped,
                                     bool* aIsAlternate)
 {
   aTitle.Truncate();
   aType.Truncate();
   aMedia.Truncate();
   *aIsAlternate = false;
 
   nsAutoString title;
@@ -216,19 +211,16 @@ HTMLStyleElement::GetStyleSheetInfo(nsAS
 
   GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia);
   // The HTML5 spec is formulated in terms of the CSSOM spec, which specifies
   // that media queries should be ASCII lowercased during serialization.
   nsContentUtils::ASCIIToLower(aMedia);
 
   GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);
 
-  *aIsScoped = HasAttr(kNameSpaceID_None, nsGkAtoms::scoped) &&
-               OwnerDoc()->IsScopedStyleEnabled();
-
   nsAutoString mimeType;
   nsAutoString notUsed;
   nsContentUtils::SplitMimeType(aType, mimeType, notUsed);
   if (!mimeType.IsEmpty() && !mimeType.LowerCaseEqualsLiteral("text/css")) {
     return;
   }
 
   // If we get here we assume that we're loading a css file, so set the
--- a/dom/html/HTMLStyleElement.h
+++ b/dom/html/HTMLStyleElement.h
@@ -73,36 +73,28 @@ public:
   void GetType(nsAString& aValue)
   {
     GetHTMLAttr(nsGkAtoms::type, aValue);
   }
   void SetType(const nsAString& aType, ErrorResult& aError)
   {
     SetHTMLAttr(nsGkAtoms::type, aType, aError);
   }
-  bool Scoped()
-  {
-    return GetBoolAttr(nsGkAtoms::scoped);
-  }
-  void SetScoped(bool aScoped, ErrorResult& aError)
-  {
-    SetHTMLBoolAttr(nsGkAtoms::scoped, aScoped, aError);
-  }
 
   virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 protected:
   virtual ~HTMLStyleElement();
 
-  already_AddRefed<nsIURI> GetStyleSheetURL(bool* aIsInline, nsIPrincipal** aTriggeringPrincipal) override;
+  already_AddRefed<nsIURI>
+    GetStyleSheetURL(bool* aIsInline, nsIPrincipal** aTriggeringPrincipal) final;
   void GetStyleSheetInfo(nsAString& aTitle,
                          nsAString& aType,
                          nsAString& aMedia,
-                         bool* aIsScoped,
-                         bool* aIsAlternate) override;
+                         bool* aIsAlternate) final;
   /**
    * Common method to call from the various mutation observer methods.
    * aContent is a content node that's either the one that changed or its
    * parent; we should only respond to the change if aContent is non-anonymous.
    */
   void ContentChanged(nsIContent* aContent);
 };
 
--- a/dom/html/test/test_style_attributes_reflection.html
+++ b/dom/html/test/test_style_attributes_reflection.html
@@ -24,20 +24,12 @@ reflectString({
 });
 
 // .type
 reflectString({
   element: e,
   attribute: "type"
 });
 
-if (SpecialPowers.getBoolPref("layout.css.scoped-style.enabled")) {
-  // .scoped
-  reflectBoolean({
-    element: e,
-    attribute: "scoped"
-  });
-}
-
 </script>
 </pre>
 </body>
 </html>
--- a/dom/ipc/ContentPrefs.cpp
+++ b/dom/ipc/ContentPrefs.cpp
@@ -175,17 +175,16 @@ const char* mozilla::dom::ContentPrefs::
   "layout.css.prefixes.box-sizing",
   "layout.css.prefixes.device-pixel-ratio-webkit",
   "layout.css.prefixes.font-features",
   "layout.css.prefixes.gradients",
   "layout.css.prefixes.transforms",
   "layout.css.prefixes.transitions",
   "layout.css.prefixes.webkit",
   "layout.css.scope-pseudo.enabled",
-  "layout.css.scoped-style.enabled",
   "layout.css.scroll-behavior.property-enabled",
   "layout.css.scroll-snap.enabled",
 #ifdef MOZ_STYLO
   "layout.css.servo.chrome.enabled",
   "layout.css.servo.enabled",
 #endif
   "layout.css.shape-outside.enabled",
   "layout.css.text-align-unsafe-value.enabled",
--- a/dom/svg/SVGStyleElement.cpp
+++ b/dom/svg/SVGStyleElement.cpp
@@ -96,19 +96,16 @@ SVGStyleElement::AfterSetAttr(int32_t aN
                               nsIPrincipal* aMaybeScriptedPrincipal,
                               bool aNotify)
 {
   if (aNameSpaceID == kNameSpaceID_None) {
     if (aName == nsGkAtoms::title ||
         aName == nsGkAtoms::media ||
         aName == nsGkAtoms::type) {
       UpdateStyleSheetInternal(nullptr, nullptr, true);
-    } else if (aName == nsGkAtoms::scoped &&
-               OwnerDoc()->IsScopedStyleEnabled()) {
-      UpdateStyleSheetScopedness(!!aValue);
     }
   }
 
   return SVGStyleElementBase::AfterSetAttr(aNameSpaceID, aName, aValue,
                                            aOldValue, aMaybeScriptedPrincipal,
                                            aNotify);
 }
 
@@ -187,28 +184,16 @@ SVGStyleElement::GetMedia(nsAString & aM
 }
 
 void
 SVGStyleElement::SetMedia(const nsAString& aMedia, ErrorResult& rv)
 {
   rv = SetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia, true);
 }
 
-bool
-SVGStyleElement::Scoped() const
-{
-  return GetBoolAttr(nsGkAtoms::scoped);
-}
-
-void
-SVGStyleElement::SetScoped(bool aScoped, ErrorResult& rv)
-{
-  rv = SetBoolAttr(nsGkAtoms::scoped, aScoped);
-}
-
 void
 SVGStyleElement::GetType(nsAString & aType)
 {
   GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);
 }
 
 void
 SVGStyleElement::SetType(const nsAString& aType, ErrorResult& rv)
@@ -238,17 +223,16 @@ SVGStyleElement::GetStyleSheetURL(bool* 
   *aTriggeringPrincipal = nullptr;
   return nullptr;
 }
 
 void
 SVGStyleElement::GetStyleSheetInfo(nsAString& aTitle,
                                    nsAString& aType,
                                    nsAString& aMedia,
-                                   bool* aIsScoped,
                                    bool* aIsAlternate)
 {
   *aIsAlternate = false;
 
   nsAutoString title;
   GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
   title.CompressWhitespace();
   aTitle.Assign(title);
@@ -257,19 +241,16 @@ SVGStyleElement::GetStyleSheetInfo(nsASt
   // The SVG spec is formulated in terms of the CSS2 spec,
   // which specifies that media queries are case insensitive.
   nsContentUtils::ASCIIToLower(aMedia);
 
   GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);
   if (aType.IsEmpty()) {
     aType.AssignLiteral("text/css");
   }
-
-  *aIsScoped = HasAttr(kNameSpaceID_None, nsGkAtoms::scoped) &&
-               OwnerDoc()->IsScopedStyleEnabled();
 }
 
 CORSMode
 SVGStyleElement::GetCORSMode() const
 {
   return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin));
 }
 
--- a/dom/svg/SVGStyleElement.h
+++ b/dom/svg/SVGStyleElement.h
@@ -64,41 +64,40 @@ public:
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
 
   // WebIDL
   void GetXmlspace(nsAString & aXmlspace);
   void SetXmlspace(const nsAString & aXmlspace, ErrorResult& rv);
   void GetMedia(nsAString & aMedia);
   void SetMedia(const nsAString& aMedia, ErrorResult& rv);
-  bool Scoped() const;
-  void SetScoped(bool aScoped, ErrorResult& rv);
   void GetType(nsAString & aType);
   void SetType(const nsAString& aType, ErrorResult& rv);
   void GetTitle(nsAString & aTitle);
   void SetTitle(const nsAString& aTitle, ErrorResult& rv);
 
 protected:
   // Dummy init method to make the NS_IMPL_NS_NEW_SVG_ELEMENT and
   // NS_IMPL_ELEMENT_CLONE_WITH_INIT usable with this class. This should be
   // completely optimized away.
   inline nsresult Init()
   {
     return NS_OK;
   }
 
   // nsStyleLinkElement overrides
-  already_AddRefed<nsIURI> GetStyleSheetURL(bool* aIsInline, nsIPrincipal** aTriggeringPrincipal) override;
+  already_AddRefed<nsIURI>
+    GetStyleSheetURL(bool* aIsInline, nsIPrincipal** aTriggeringPrincipal) final;
 
   void GetStyleSheetInfo(nsAString& aTitle,
                          nsAString& aType,
                          nsAString& aMedia,
-                         bool* aIsScoped,
-                         bool* aIsAlternate) override;
-  virtual CORSMode GetCORSMode() const override;
+                         bool* aIsAlternate) final;
+
+  CORSMode GetCORSMode() const final;
 
   /**
    * Common method to call from the various mutation observer methods.
    * aContent is a content node that's either the one that changed or its
    * parent; we should only respond to the change if aContent is non-anonymous.
    */
   void ContentChanged(nsIContent* aContent);
 };
--- a/dom/webidl/HTMLStyleElement.webidl
+++ b/dom/webidl/HTMLStyleElement.webidl
@@ -11,13 +11,11 @@
 [HTMLConstructor]
 interface HTMLStyleElement : HTMLElement {
            [Pure]
            attribute boolean disabled;
            [CEReactions, SetterThrows, Pure]
            attribute DOMString media;
            [CEReactions, SetterThrows, Pure]
            attribute DOMString type;
-           [SetterThrows, Pure, Pref="layout.css.scoped-style.enabled"]
-           attribute boolean scoped;
 };
 HTMLStyleElement implements LinkStyle;
 
--- a/dom/webidl/SVGStyleElement.webidl
+++ b/dom/webidl/SVGStyleElement.webidl
@@ -14,13 +14,11 @@ interface SVGStyleElement : SVGElement {
   [SetterThrows]
   attribute DOMString xmlspace; // Spec claims this should be on SVGElement
   [SetterThrows]
   attribute DOMString type;
   [SetterThrows]
   attribute DOMString media;
   [SetterThrows]
   attribute DOMString title;
-  [SetterThrows, Pref="layout.css.scoped-style.enabled"]
-  attribute boolean scoped;
 };
 SVGStyleElement implements LinkStyle;
 
--- a/dom/xml/XMLStylesheetProcessingInstruction.cpp
+++ b/dom/xml/XMLStylesheetProcessingInstruction.cpp
@@ -123,23 +123,21 @@ XMLStylesheetProcessingInstruction::GetS
   NS_NewURI(getter_AddRefs(aURI), href, encoding, baseURL);
   return aURI.forget();
 }
 
 void
 XMLStylesheetProcessingInstruction::GetStyleSheetInfo(nsAString& aTitle,
                                                       nsAString& aType,
                                                       nsAString& aMedia,
-                                                      bool* aIsScoped,
                                                       bool* aIsAlternate)
 {
   aTitle.Truncate();
   aType.Truncate();
   aMedia.Truncate();
-  *aIsScoped = false;
   *aIsAlternate = false;
 
   // xml-stylesheet PI is special only in prolog
   if (!nsContentUtils::InProlog(this)) {
     return;
   }
 
   nsAutoString data;
--- a/dom/xml/XMLStylesheetProcessingInstruction.h
+++ b/dom/xml/XMLStylesheetProcessingInstruction.h
@@ -72,22 +72,22 @@ public:
   }
   using ProcessingInstruction::SetData; // Prevent hiding overloaded virtual function.
 
 protected:
   virtual ~XMLStylesheetProcessingInstruction();
 
   nsCOMPtr<nsIURI> mOverriddenBaseURI;
 
-  already_AddRefed<nsIURI> GetStyleSheetURL(bool* aIsInline, nsIPrincipal** aTriggeringPrincipal) override;
+  already_AddRefed<nsIURI>
+    GetStyleSheetURL(bool* aIsInline, nsIPrincipal** aTriggeringPrincipal) final;
   void GetStyleSheetInfo(nsAString& aTitle,
                          nsAString& aType,
                          nsAString& aMedia,
-                         bool* aIsScoped,
-                         bool* aIsAlternate) override;
-  virtual nsGenericDOMDataNode* CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
-                                              bool aCloneText) const override;
+                         bool* aIsAlternate) final;
+  nsGenericDOMDataNode* CloneDataNode(mozilla::dom::NodeInfo* aNodeInfo,
+                                      bool aCloneText) const final;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_XMLStylesheetProcessingInstruction_h
--- a/layout/base/GeckoRestyleManager.cpp
+++ b/layout/base/GeckoRestyleManager.cpp
@@ -3232,17 +3232,17 @@ ElementRestyler::RestyleUndisplayedNodes
                                          nsIContent*        aUndisplayedParent,
                                          GeckoStyleContext*    aParentContext,
                                          const StyleDisplay aDisplay)
 {
   nsIContent* undisplayedParent = aUndisplayedParent;
   UndisplayedNode* undisplayed = aUndisplayed;
   TreeMatchContext::AutoAncestorPusher pusher(&mTreeMatchContext);
   if (undisplayed) {
-    pusher.PushAncestorAndStyleScope(undisplayedParent);
+    pusher.PushAncestor(undisplayedParent);
   }
   for (; undisplayed; undisplayed = undisplayed->getNext()) {
     NS_ASSERTION(undisplayedParent ||
                  undisplayed->mContent ==
                    mPresContext->Document()->GetRootElement(),
                  "undisplayed node child of null must be root");
     NS_ASSERTION(!undisplayed->mStyle->GetPseudo(),
                  "Shouldn't have random pseudo style contexts in the "
@@ -3252,17 +3252,17 @@ ElementRestyler::RestyleUndisplayedNodes
                 undisplayed->mContent.get());
 
     // Get the parent of the undisplayed content and check if it is a XBL
     // children element. Push the children element as an ancestor here because it does
     // not have a frame and would not otherwise be pushed as an ancestor.
     nsIContent* parent = undisplayed->mContent->GetParent();
     TreeMatchContext::AutoAncestorPusher insertionPointPusher(&mTreeMatchContext);
     if (parent && parent->IsActiveChildrenElement()) {
-      insertionPointPusher.PushAncestorAndStyleScope(parent);
+      insertionPointPusher.PushAncestor(parent);
     }
 
     nsRestyleHint thisChildHint = aChildRestyleHint;
     nsAutoPtr<RestyleTracker::RestyleData> undisplayedRestyleData;
     Element* element = undisplayed->mContent->AsElement();
     if (mRestyleTracker.GetRestyleData(element,
                                        undisplayedRestyleData)) {
       thisChildHint =
@@ -3460,17 +3460,17 @@ void
 ElementRestyler::RestyleContentChildren(nsIFrame* aParent,
                                         nsRestyleHint aChildRestyleHint)
 {
   LOG_RESTYLE("RestyleContentChildren");
 
   nsIFrame::ChildListIterator lists(aParent);
   TreeMatchContext::AutoAncestorPusher ancestorPusher(&mTreeMatchContext);
   if (!lists.IsDone()) {
-    ancestorPusher.PushAncestorAndStyleScope(mContent);
+    ancestorPusher.PushAncestor(mContent);
   }
   for (; !lists.IsDone(); lists.Next()) {
     for (nsIFrame* child : lists.CurrentList()) {
       // Out-of-flows are reached through their placeholders.  Continuations
       // and block-in-inline splits are reached through those chains.
       if (!(child->GetStateBits() & NS_FRAME_OUT_OF_FLOW) &&
           !GetPrevContinuationWithSameStyle(child)) {
         // Get the parent of the child frame's content and check if it
@@ -3478,17 +3478,17 @@ ElementRestyler::RestyleContentChildren(
         // ancestor here because it does not have a frame and would not
         // otherwise be pushed as an ancestor.
 
         // Check if the frame has a content because |child| may be a
         // nsPageFrame that does not have a content.
         nsIContent* parent = child->GetContent() ? child->GetContent()->GetParent() : nullptr;
         TreeMatchContext::AutoAncestorPusher insertionPointPusher(&mTreeMatchContext);
         if (parent && parent->IsActiveChildrenElement()) {
-          insertionPointPusher.PushAncestorAndStyleScope(parent);
+          insertionPointPusher.PushAncestor(parent);
         }
 
         // only do frames that are in flow
         if (child->IsPlaceholderFrame()) { // placeholder
           // get out of flow frame and recur there
           nsIFrame* outOfFlowFrame =
             nsPlaceholderFrame::GetRealFrameForPlaceholder(child);
           NS_ASSERTION(outOfFlowFrame, "no out-of-flow frame");
@@ -3672,32 +3672,30 @@ AutoDisplayContentsAncestorPusher::AutoD
       mAncestors.AppendElement(p->AsElement());
     }
     bool hasFilter = mTreeMatchContext.mAncestorFilter.HasFilter();
     nsTArray<mozilla::dom::Element*>::size_type i = mAncestors.Length();
     while (i--) {
       if (hasFilter) {
         mTreeMatchContext.mAncestorFilter.PushAncestor(mAncestors[i]);
       }
-      mTreeMatchContext.PushStyleScope(mAncestors[i]);
     }
   }
 }
 
 AutoDisplayContentsAncestorPusher::~AutoDisplayContentsAncestorPusher()
 {
   // Pop the ancestors we pushed in the CTOR, if any.
   typedef nsTArray<mozilla::dom::Element*>::size_type sz;
   sz len = mAncestors.Length();
   bool hasFilter = mTreeMatchContext.mAncestorFilter.HasFilter();
   for (sz i = 0; i < len; ++i) {
     if (hasFilter) {
       mTreeMatchContext.mAncestorFilter.PopAncestor();
     }
-    mTreeMatchContext.PopStyleScope(mAncestors[i]);
   }
 }
 
 #ifdef RESTYLE_LOGGING
 uint32_t
 GeckoRestyleManager::StructsToLog()
 {
   static bool initialized = false;
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -2628,17 +2628,17 @@ nsCSSFrameConstructor::ConstructDocEleme
                "Scrollbars should have been propagated to the viewport");
 
   if (MOZ_UNLIKELY(display->mDisplay == StyleDisplay::None)) {
     RegisterDisplayNoneStyleFor(aDocElement, styleContext);
     return nullptr;
   }
 
   TreeMatchContext::AutoAncestorPusher ancestorPusher(state.mTreeMatchContext);
-  ancestorPusher.PushAncestorAndStyleScope(aDocElement);
+  ancestorPusher.PushAncestor(aDocElement);
 
   // Make sure to start any background image loads for the root element now.
   styleContext->StartBackgroundImageLoads();
 
   nsFrameConstructorSaveState docElementContainingBlockAbsoluteSaveState;
   if (mHasRootAbsPosContainingBlock) {
     // Push the absolute containing block now so we can absolutely position
     // the root element
@@ -4015,36 +4015,32 @@ nsCSSFrameConstructor::ConstructFrameFro
   // necessary to do so in order to correctly handle style resolution on
   // descendants.  (If !adcp.IsEmpty() then it was already pushed by
   // AutoDisplayContentsAncestorPusher above.)
   TreeMatchContext::AutoAncestorPusher
     insertionPointPusher(aState.mTreeMatchContext);
   if (adcp.isSome() && adcp->IsEmpty() && parent &&
       parent->IsActiveChildrenElement()) {
     if (aState.HasAncestorFilter()) {
-      insertionPointPusher.PushAncestorAndStyleScope(parent);
-    } else {
-      insertionPointPusher.PushStyleScope(parent);
+      insertionPointPusher.PushAncestor(parent);
     }
   }
 
   // Push the content as a style ancestor now, so we don't have to do
   // it in our various full-constructor functions.  In particular,
   // since a number of full-constructor functions don't actually call
   // ProcessChildren in some cases (e.g. for CSS anonymous table boxes
   // or for situations where only anonymouse children are having
   // frames constructed), this is the best place to bottleneck the
   // pushing of the content instead of having to do it in multiple
   // places.
   TreeMatchContext::AutoAncestorPusher
     ancestorPusher(aState.mTreeMatchContext);
   if (aState.HasAncestorFilter()) {
-    ancestorPusher.PushAncestorAndStyleScope(content);
-  } else {
-    ancestorPusher.PushStyleScope(content);
+    ancestorPusher.PushAncestor(content);
   }
 
   nsIFrame* newFrame;
   nsIFrame* primaryFrame;
   nsStyleContext* const styleContext = aItem.mStyleContext;
   const nsStyleDisplay* display = styleContext->StyleDisplay();
   if (bits & FCDATA_FUNC_IS_FULL_CTOR) {
     newFrame =
@@ -4768,19 +4764,17 @@ nsCSSFrameConstructor::BeginBuildingScro
   // be parented to the scrollframe, and everything else needs to be parented
   // to the scrolledframe.
   AutoTArray<nsIAnonymousContentCreator::ContentInfo, 4> scrollNAC;
   DebugOnly<nsresult> rv = GetAnonymousContent(aContent, gfxScrollFrame, scrollNAC);
   MOZ_ASSERT(NS_SUCCEEDED(rv));
   if (scrollNAC.Length() > 0) {
     TreeMatchContext::AutoAncestorPusher ancestorPusher(aState.mTreeMatchContext);
     if (aState.HasAncestorFilter()) {
-      ancestorPusher.PushAncestorAndStyleScope(aContent->AsElement());
-    } else {
-      ancestorPusher.PushStyleScope(aContent->AsElement());
+      ancestorPusher.PushAncestor(aContent->AsElement());
     }
 
     AutoFrameConstructionItemList items(this);
     AddFCItemsForAnonymousContent(aState, gfxScrollFrame, scrollNAC, items);
     ConstructFramesFromItemList(aState, items, gfxScrollFrame,
                                 /* aParentIsWrapperAnonBox = */ false,
                                 anonymousItems);
   }
@@ -6174,19 +6168,17 @@ nsCSSFrameConstructor::AddFrameConstruct
                                                             styleContext);
     } else {
       aState.mFrameManager->ChangeRegisteredDisplayContentsStyleFor(aContent,
                                                                     styleContext);
     }
 
     TreeMatchContext::AutoAncestorPusher ancestorPusher(aState.mTreeMatchContext);
     if (aState.HasAncestorFilter()) {
-      ancestorPusher.PushAncestorAndStyleScope(aContent->AsElement());
-    } else {
-      ancestorPusher.PushStyleScope(aContent->AsElement());
+      ancestorPusher.PushAncestor(aContent->AsElement());
     }
 
     if (aParentFrame) {
       aParentFrame->AddStateBits(NS_FRAME_MAY_HAVE_GENERATED_CONTENT);
     }
     CreateGeneratedContentItem(aState, aParentFrame, aContent->AsElement(),
                                styleContext, CSSPseudoElementType::before,
                                aItems);
@@ -6202,19 +6194,17 @@ nsCSSFrameConstructor::AddFrameConstruct
       // FlattenedChildIterator will transitively iterate through <xbl:children>
       // for default content). Push the children element as an ancestor here because
       // it does not have a frame and would not otherwise be pushed as an ancestor.
       nsIContent* parent = child->GetParent();
       MOZ_ASSERT(parent, "Parent must be non-null because we are iterating children.");
       TreeMatchContext::AutoAncestorPusher ancestorPusher(aState.mTreeMatchContext);
       if (parent != aContent && parent->IsElement()) {
         if (aState.HasAncestorFilter()) {
-          ancestorPusher.PushAncestorAndStyleScope(parent->AsElement());
-        } else {
-          ancestorPusher.PushStyleScope(parent->AsElement());
+          ancestorPusher.PushAncestor(parent->AsElement());
         }
       }
 
       RefPtr<nsStyleContext> childContext =
         ResolveStyleContext(styleContext, child, &aState);
       DoAddFrameConstructionItems(aState, child, childContext,
                                   aSuppressWhiteSpaceOptimizations,
                                   aParentFrame, aAnonChildren, aItems);
@@ -7379,22 +7369,21 @@ nsCSSFrameConstructor::CreateNeededFrame
   FlattenedChildIterator iter(aContent);
   for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
     if (child->HasFlag(NODE_DESCENDANTS_NEED_FRAMES)) {
       TreeMatchContext::AutoAncestorPusher insertionPointPusher(
           &aTreeMatchContext);
 
       // Handle stuff like xbl:children.
       if (child->GetParent() != aContent && child->GetParent()->IsElement()) {
-        insertionPointPusher.PushAncestorAndStyleScope(
-            child->GetParent()->AsElement());
+        insertionPointPusher.PushAncestor(child->GetParent()->AsElement());
       }
 
       TreeMatchContext::AutoAncestorPusher pusher(&aTreeMatchContext);
-      pusher.PushAncestorAndStyleScope(child);
+      pusher.PushAncestor(child);
 
       CreateNeededFrames(child, aTreeMatchContext);
     }
   }
 }
 
 void
 nsCSSFrameConstructor::CreateNeededFrames()
@@ -11093,19 +11082,17 @@ nsCSSFrameConstructor::ProcessChildren(n
       insertion.mContainer = aContent;
       nsIContent* parent = child->GetParent();
       MOZ_ASSERT(parent, "Parent must be non-null because we are iterating children.");
       TreeMatchContext::AutoAncestorPusher ancestorPusher(aState.mTreeMatchContext);
       if (parent != aContent && parent->IsElement()) {
         insertion.mContainer = child->GetFlattenedTreeParent();
         MOZ_ASSERT(insertion.mContainer == GetInsertionPoint(child).mContainer);
         if (aState.HasAncestorFilter()) {
-          ancestorPusher.PushAncestorAndStyleScope(parent->AsElement());
-        } else {
-          ancestorPusher.PushStyleScope(parent->AsElement());
+          ancestorPusher.PushAncestor(parent->AsElement());
         }
       }
 
       // Frame construction item construction should not post
       // restyles, so removing restyle flags here is safe.
       child->UnsetRestyleFlagsIfGecko();
       if (addChildItems) {
         AddFrameConstructionItems(aState, child, iter.XBLInvolved(), insertion,
@@ -12283,19 +12270,17 @@ nsCSSFrameConstructor::BuildInlineChildI
   nsFrameConstructorState::PendingBindingAutoPusher
     pusher(aState, aParentItem.mPendingBinding);
 
   nsStyleContext* const parentStyleContext = aParentItem.mStyleContext;
   nsIContent* const parentContent = aParentItem.mContent;
 
   TreeMatchContext::AutoAncestorPusher ancestorPusher(aState.mTreeMatchContext);
   if (aState.HasAncestorFilter()) {
-    ancestorPusher.PushAncestorAndStyleScope(parentContent->AsElement());
-  } else {
-    ancestorPusher.PushStyleScope(parentContent->AsElement());
+    ancestorPusher.PushAncestor(parentContent->AsElement());
   }
 
   if (!aItemIsWithinSVGText) {
     // Probe for generated content before
     CreateGeneratedContentItem(aState, nullptr, parentContent->AsElement(),
                                parentStyleContext, CSSPseudoElementType::before,
                                aParentItem.mChildItems);
   }
@@ -12324,19 +12309,17 @@ nsCSSFrameConstructor::BuildInlineChildI
       // FlattenedChildIterator will transitively iterate through <xbl:children>
       // for default content). Push the children element as an ancestor here because
       // it does not have a frame and would not otherwise be pushed as an ancestor.
       nsIContent* contentParent = content->GetParent();
       MOZ_ASSERT(contentParent, "Parent must be non-null because we are iterating children.");
       TreeMatchContext::AutoAncestorPusher insertionPointPusher(aState.mTreeMatchContext);
       if (contentParent != parentContent && contentParent->IsElement()) {
         if (aState.HasAncestorFilter()) {
-          insertionPointPusher.PushAncestorAndStyleScope(contentParent->AsElement());
-        } else {
-          insertionPointPusher.PushStyleScope(contentParent->AsElement());
+          insertionPointPusher.PushAncestor(contentParent->AsElement());
         }
       }
 
       // Manually check for comments/PIs, since we don't have a frame to pass to
       // AddFrameConstructionItems.  We know our parent is a non-replaced inline,
       // so there is no need to do the NeedFrameFor check.
       content->UnsetFlags(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME);
       if (content->IsNodeOfType(nsINode::eCOMMENT) ||
--- a/layout/reftests/css-mediaqueries/reftest.list
+++ b/layout/reftests/css-mediaqueries/reftest.list
@@ -9,10 +9,8 @@ fuzzy-if(Android,8,454) == mq_print_heig
 fuzzy-if(Android,8,454) == mq_print_orientation.xhtml mq_print_orientation-ref.xhtml
 fuzzy-if(Android,8,454) == mq_print_maxheight.xhtml mq_print-ref.xhtml
 == mq_print_maxwidth.xhtml mq_print-ref.xhtml
 
 == mq_print_maxwidth_updown.xhtml mq_print-ref.xhtml
 == mq_print_maxheight_updown.xhtml mq_print-ref.xhtml
 == mq_print_minheight_updown.xhtml mq_print-ref.xhtml
 == mq_print_minwidth_updown.xhtml mq_print-ref.xhtml
-
-pref(layout.css.scoped-style.enabled,true) == scoped-mq-update.html scoped-mq-update-ref.html
deleted file mode 100644
--- a/layout/reftests/css-mediaqueries/scoped-mq-update-helper.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<body>
-<style>
-body { width: 100%; height: 100%; background-color: red; }
-</style>
-<style scoped>
-@media (max-width: 200px) {
-  body { background-color: green; }
-}
-</style>
deleted file mode 100644
--- a/layout/reftests/css-mediaqueries/scoped-mq-update-ref.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<!DOCTYPE html>
-<iframe src="scoped-mq-update-helper.html" width="100" height="100" style="border: none"></iframe>
deleted file mode 100644
--- a/layout/reftests/css-mediaqueries/scoped-mq-update.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<html class="reftest-wait">
-<iframe src="scoped-mq-update-helper.html" width="300" height="100" style="border: none"></iframe>
-<script>
-function test() {
-  document.querySelector("iframe").width = "100";
-  document.documentElement.removeAttribute("class");
-}
-
-window.addEventListener("MozReftestInvalidate", test);
-</script>
--- a/layout/reftests/moz.build
+++ b/layout/reftests/moz.build
@@ -224,18 +224,16 @@ with Files('position-dynamic-changes/**'
 with Files('position-relative/**'):
     BUG_COMPONENT = ('Core', 'Layout: R & A Pos')
 with Files('position-sticky/**'):
     BUG_COMPONENT = ('Core', 'Layout: R & A Pos')
 with Files('printing/**'):
     BUG_COMPONENT = ('Core', 'Printing: Output')
 with Files('reftest-sanity/**'):
     BUG_COMPONENT = ('Testing', 'Reftest')
-with Files('scoped-style/**'):
-    BUG_COMPONENT = ('Core', 'CSS Parsing and Computation')
 with Files('scrolling/**'):
     BUG_COMPONENT = ('Core', 'Layout')
 with Files('selection/**'):
     BUG_COMPONENT = ('Core', 'Selection')
 with Files('svg/**'):
     BUG_COMPONENT = ('Core', 'SVG')
 with Files('tab-size/**'):
     BUG_COMPONENT = ('Core', 'Layout: Text')
--- a/layout/reftests/reftest.list
+++ b/layout/reftests/reftest.list
@@ -300,19 +300,16 @@ include position-dynamic-changes/reftest
 
 # printing
 # SkiaPDF is required for printing tests to control printing to PDF files.
 skip-if(!skiaPdf||styloVsGecko) include printing/reftest.list
 
 # pagination
 include pagination/reftest.list
 
-# <style scoped>
-include scoped-style/reftest.list
-
 # scrolling
 include scrolling/reftest.list
 
 # selection
 include selection/reftest.list
 
 # sticky positioning
 include position-sticky/reftest.list
deleted file mode 100644
--- a/layout/reftests/scoped-style/reftest.list
+++ /dev/null
@@ -1,59 +0,0 @@
-default-preferences pref(layout.css.scoped-style.enabled,true)
-
-fails-if(styloVsGecko||stylo) == scoped-style-001.html scoped-style-001-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-002.html scoped-style-002-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-003.html scoped-style-003-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-004.html scoped-style-004-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-005.html scoped-style-005-ref.html
-== scoped-style-006.html scoped-style-006-ref.html
-== scoped-style-007.html scoped-style-007-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-008.html scoped-style-008-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-009.html scoped-style-009-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-010.html scoped-style-010-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-011.html scoped-style-011-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-012.html scoped-style-012-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-013.html scoped-style-013-ref.html
-== scoped-style-014.html scoped-style-014-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-015.html scoped-style-015-ref.html
-== scoped-style-016.html scoped-style-016-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-017.html scoped-style-017-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-018.html scoped-style-018-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-019.svg scoped-style-019-ref.svg
-== scoped-style-020.html scoped-style-020-ref.html
-== scoped-style-021.html scoped-style-021-ref.html
-== scoped-style-022.html scoped-style-022-ref.html
-== scoped-style-023.html scoped-style-023-ref.html
-== scoped-style-024.html scoped-style-024-ref.html
-== scoped-style-important-001.html scoped-style-important-001-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-important-002.html scoped-style-important-002-ref.html
-== scoped-style-important-003.html scoped-style-important-003-ref.html
-== scoped-style-important-004.html scoped-style-important-004-ref.html
-== scoped-style-important-005.html scoped-style-important-005-ref.html
-== scoped-style-important-006.html scoped-style-important-006-ref.html
-== scoped-style-important-007.html scoped-style-important-007-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-dynamic-001.html scoped-style-dynamic-001-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-dynamic-002.html scoped-style-dynamic-002-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-dynamic-003.html scoped-style-dynamic-003-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-dynamic-004.html scoped-style-dynamic-004-ref.html
-asserts-if(styloVsGecko,0-1) asserts-if(stylo,1) == scoped-style-dynamic-005.html scoped-style-dynamic-005-ref.html # bug 1394603: 0-1 styloVsGecko asserts because there are 0 Gecko asserts and 1 Stylo assert.
-skip-if(styloVsGecko) asserts-if(stylo,1) fails-if(stylo) == scoped-style-dynamic-006.html scoped-style-dynamic-006-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-dynamic-007.html scoped-style-dynamic-007-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-dynamic-008.html scoped-style-dynamic-008-ref.html
-skip-if(styloVsGecko) asserts-if(stylo,1) fails-if(stylo) == scoped-style-dynamic-009.html scoped-style-dynamic-009-ref.html
-asserts-if(styloVsGecko,0-1) asserts-if(stylo,1) == scoped-style-dynamic-010.html scoped-style-dynamic-010-ref.html # bug 1394603: 0-1 styloVsGecko asserts because there are 0 Gecko asserts and 1 Stylo assert.
-fails-if(styloVsGecko||stylo) == scoped-style-dynamic-011.html scoped-style-dynamic-011-ref.html
-asserts-if(styloVsGecko,0-1) asserts-if(stylo,1) == scoped-style-dynamic-012.svg scoped-style-dynamic-012-ref.svg # bug 1394603: 0-1 styloVsGecko asserts because there are 0 Gecko asserts and 1 Stylo assert.
-fails-if(styloVsGecko) asserts-if(styloVsGecko,1) asserts-if(stylo,1) fails-if(stylo) == scoped-style-dynamic-013.svg scoped-style-dynamic-013-ref.svg # bug 1394603: 0-1 styloVsGecko asserts because there are 0 Gecko asserts and 1 Stylo assert.
-asserts-if(styloVsGecko,0-1) asserts-if(stylo,1) == scoped-style-dynamic-014.svg scoped-style-dynamic-014-ref.svg # bug 1394603: 0-1 styloVsGecko asserts because there are 0 Gecko asserts and 1 Stylo assert.
-fails-if(styloVsGecko) asserts-if(styloVsGecko,0-1) asserts-if(stylo,1) fails-if(stylo) == scoped-style-dynamic-015.svg scoped-style-dynamic-015-ref.svg # bug 1394603: 0-1 styloVsGecko asserts because there are 0 Gecko asserts and 1 Stylo assert.
-fails-if(styloVsGecko||stylo) == scoped-style-import.html scoped-style-import-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-media.html scoped-style-media-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-namespace.html scoped-style-namespace-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-charset.html scoped-style-charset-ref.html
-pref(layout.css.moz-document.content.enabled,true) fails-if(styloVsGecko||stylo) == scoped-style-document.html scoped-style-document-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-font-face.html scoped-style-font-face-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-keyframes.html scoped-style-keyframes-ref.html
-fails-if(styloVsGecko||stylo) == scoped-style-supports.html scoped-style-supports-ref.html
-pref(layout.css.scope-pseudo.enabled,true) fails-if(styloVsGecko||stylo) == scoped-style-pseudo-001.html scoped-style-pseudo-001-ref.html
-pref(layout.css.scope-pseudo.enabled,true) fails-if(styloVsGecko||stylo) == scoped-style-pseudo-002.html scoped-style-pseudo-002-ref.html
-pref(layout.css.scope-pseudo.enabled,true) == scoped-style-pseudo-003.html scoped-style-pseudo-003-ref.html
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-001-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: green">Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-001.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>
-    <style scoped>
-      p { color: green }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-002-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: blue">First</p>
-  <p style="color: green">Second</p>
-  <p style="color: blue">Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-002.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <style>
-    p { color: blue }
-  </style>
-  <p>First</p>
-  <p>
-    <style scoped>
-      p { color: green }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-003-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: blue">First</p>
-  <p style="color: green">Second</p>
-  <p style="color: blue">Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-003.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>
-    <style scoped>
-      p { color: green }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-  <style>
-    p { color: blue }
-  </style>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-004-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: blue">First</p>
-  <p style="color: green">Second</p>
-  <p style="color: blue">Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-004.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <style>
-    body p { color: blue }
-  </style>
-  <p>First</p>
-  <p>
-    <style scoped>
-      p { color: green }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-005-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: blue">First</p>
-  <p style="color: green">Second</p>
-  <p style="color: blue">Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-005.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>
-    <style scoped>
-      p { color: green }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-  <style>
-    body p { color: blue }
-  </style>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-006-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: blue">First</p>
-  <p style="color: green">Second</p>
-  <p style="color: blue">Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-006.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <style>
-    p { color: blue }
-  </style>
-  <p>First</p>
-  <p id=a>
-    <style scoped>
-      #a { color: green }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-007-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: blue">First</p>
-  <p style="color: green">Second</p>
-  <p style="color: blue">Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-007.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p id=a>
-    <style scoped>
-      #a { color: green }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-  <style>
-    p { color: blue }
-  </style>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-008-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-008.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>
-    <style scoped>
-      body p { color: green }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-009-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-009.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>
-    <style scoped>
-      p + p { color: red }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-010-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: green; text-decoration: underline">Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-010.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>
-    <style scoped>
-      p { color: red }
-    </style>
-    <style scoped>
-      p { text-decoration: underline }
-    </style>
-    Second
-    <style scoped>
-      p { color: green }
-    </style>
-  </p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-011-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p><div style="color: green">Second</div></p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-011.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <div>
-    <style scoped>
-      p { color: green }
-    </style>
-    <p>
-      Second
-    </p>
-  </div>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-012-ref.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <div>First</div>
-  <div style="color: green">
-    Second
-    <div style="text-decoration: underline">Third</div>
-  </div>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-012.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <div>First</div>
-  <div>
-    <style scoped>
-      div { color: green }
-    </style>
-    Second
-    <div>
-      <style scoped>
-        div { text-decoration: underline }
-      </style>
-      Third
-    </div>
-  </div>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-013-ref.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <div>
-    <p>First</p>
-  </div>
-  <div>
-    <p style="color: green">Second</p>
-  </div>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-013.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <div>
-    <p>First</p>
-  </div>
-  <div>
-    <style scoped>
-      div p { color: green }
-    </style>
-    <p>Second</p>
-  </div>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-014-ref.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <div>
-    <p>First</p>
-  </div>
-  <blockquote>
-    <div>
-      <div>
-        <div>
-          <p style="color: green">Second</p>
-        </div>
-      </div>
-    </div>
-  </blockquote>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-014.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <div>
-    <p>First</p>
-  </div>
-  <blockquote>
-    <style scoped>
-      blockquote p { color: green }
-    </style>
-    <div>
-      <div>
-        <div>
-          <p>Second</p>
-        </div>
-      </div>
-    </div>
-  </blockquote>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-015-ref.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <div>
-    <p style="color: green">Second</p>
-  </div>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-015.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <div>
-    <style scoped>
-      p { color: red }
-    </style>
-    <p style="color: green">Second</p>
-  </div>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-016-ref.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <div>
-    <p>Second</p>
-    <p style="color: green">Third</p>
-  </div>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-016.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <div>
-    <style scoped>
-      p + p { color: green }
-    </style>
-    <p>Second</p>
-    <p>Third</p>
-  </div>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-017-ref.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <div style="text-decoration: underline">
-    <p>Second</p>
-    <p>Third</p>
-  </div>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-017.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <div>
-    <style scoped>
-      div { text-decoration: underline }
-    </style>
-    <p>
-      <style scoped>
-        div { color: red }
-      </style>
-      Second
-    </p>
-    <p>Third</p>
-  </div>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-018-ref.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <div>
-    <div>
-      <p style="color: green">This should be green.</p>
-    </div>
-  </div>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-018.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <div>
-    <div>
-      <p>This should be green.</p>
-      <style scoped>
-        p { color: green }
-      </style>
-    </div>
-    <style scoped>
-      p { color: red }
-    </style>
-  </div>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-019-ref.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg">
-  <rect width="50" height="50"/>
-  <g>
-    <rect x="60" width="50" height="50" fill="blue"/>
-  </g>
-  <rect x="120" width="50" height="50"/>
-</svg>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-019.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg">
-  <rect width="50" height="50"/>
-  <g>
-    <style scoped="">
-      rect { fill: blue }
-    </style>
-    <rect x="60" width="50" height="50"/>
-  </g>
-  <rect x="120" width="50" height="50"/>
-</svg>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-020-ref.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: green">Hello</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-020.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: green">
-    <style scoped>
-      p { color: red }
-    </style>
-    Hello
-  </p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-021-ref.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: green">Hello</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-021.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <style scoped>
-    p { color: red }
-  </style>
-  <p style="color: green">Hello</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-022-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <div>
-    <p style="color: green">Hello</p>
-  </div>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-022.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <style scoped>
-    body > div p { color: green; }
-  </style>
-  <div>
-    <p>Hello</p>
-  </div>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-023-ref.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p><span style="color: green">First line</span><br><span style="color: blue">Second line</span></p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-023.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <style scoped>
-    p::first-line { color: green; }
-    span { color: blue; }
-  </style>
-  <p>First line<br><span>Second line</span></p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-024-ref.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: green">Hello.</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-024.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <style scoped>
-    p[data-test] { color: green; }
-  </style>
-  <p>Hello.</p>
-  <script>
-    document.body.offsetHeight;
-    document.querySelector("p").setAttribute("data-test", "");
-  </script>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-charset-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: blue">Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-charset.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>
-    <style scoped>
-      @charset "UTF-16";
-      p { color: blue }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-document-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: blue">Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-document.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>
-    <style scoped>
-      @-moz-document regexp("^.*scoped-style-document\\.html$") {
-        p { color: blue }
-      }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-001-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: green">Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-001.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<body onload="f()">
-  <p>First</p>
-  <p>Second</p>
-  <p>Third</p>
-  <script>
-    function f() {
-      var p = document.getElementsByTagName("p")[1];
-      var style = document.createElement("style");
-      style.setAttribute("scoped", "");
-      style.textContent = "p { color: green }";
-      p.appendChild(style);
-    }
-  </script>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-002-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: green; text-decoration: underline">Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-002.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE html>
-<body onload="f()">
-  <p>First</p>
-  <p>
-    <style scoped>
-      p { text-decoration: underline }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-  <script>
-    function f() {
-      var p = document.getElementsByTagName("p")[1];
-      var style = document.createElement("style");
-      style.setAttribute("scoped", "");
-      style.textContent = "p { color: green }";
-      p.appendChild(style);
-    }
-  </script>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-003-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: green">Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-003.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE html>
-<body onload="f()">
-  <p>First</p>
-  <p>
-    <style scoped>
-      p { color: green }
-    </style>
-    <style scoped>
-      p { text-decoration: underline }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-  <script>
-    function f() {
-      var style = document.getElementsByTagName("style")[1];
-      style.remove();
-    }
-  </script>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-004-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: green; background-color: yellow">Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-004.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE html>
-<body onload="f()">
-  <p>First</p>
-  <p>
-    <style scoped>
-      p { color: green }
-    </style>
-    <style scoped>
-      p { text-decoration: underline }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-  <script>
-    function f() {
-      var style = document.getElementsByTagName("style")[1];
-      style.textContent = "p { background-color: yellow }";
-    }
-  </script>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-005-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: green">First</p>
-  <p style="color: green">Second</p>
-  <p style="color: green">Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-005.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE html>
-<body onload="f()">
-  <p>First</p>
-  <p>
-    <style scoped>
-      p { color: green }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-  <script>
-    function f() {
-      var style = document.getElementsByTagName("style")[0];
-      style.removeAttribute("scoped");
-    }
-  </script>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-006-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: green">Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-006.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE html>
-<body onload="f()">
-  <p>First</p>
-  <p>
-    <style>
-      p { color: green }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-  <script>
-    function f() {
-      var style = document.getElementsByTagName("style")[0];
-      style.setAttribute("scoped", "");
-    }
-  </script>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-007-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <div></div>
-  <p>Second</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-007.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE html>
-<body onload="f()">
-  <p>First</p>
-  <div>
-    <style scoped>
-      p { color: green }
-    </style>
-    <p>Second</p>
-  </div>
-  <script>
-    function f() {
-      var p = document.getElementsByTagName("p")[1];
-      document.body.appendChild(p);
-    }
-  </script>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-008-ref.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <div>
-    <p style="color: green">First</p>
-  </div>
-  <p>Second</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-008.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE html>
-<body onload="f()">
-  <p>First</p>
-  <div>
-    <style scoped>
-      p { color: green }
-    </style>
-  </div>
-  <p>Second</p>
-  <script>
-    function f() {
-      var p = document.getElementsByTagName("p")[0];
-      var div = document.getElementsByTagName("div")[0];
-      div.appendChild(p);
-    }
-  </script>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-009-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: green">Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-009.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE html>
-<body onload="f()">
-  <p>First</p>
-  <p>
-    <style>
-      p { color: green }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-  <script>
-    function f() {
-      var style = document.getElementsByTagName("style")[0];
-      style.scoped = true;
-    }
-  </script>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-010-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: green">First</p>
-  <p style="color: green">Second</p>
-  <p style="color: green">Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-010.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE html>
-<body onload="f()">
-  <p>First</p>
-  <p>
-    <style scoped>
-      p { color: green }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-  <script>
-    function f() {
-      var style = document.getElementsByTagName("style")[0];
-      style.scoped = false;
-    }
-  </script>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-011-ref.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: green">Second</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-011.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE html>
-<body onload="f()">
-  <p>
-    <style scoped>
-      p { color: green }
-    </style>
-    First
-  </p>
-  <p>Second</p>
-  <script>
-    function f() {
-      var style = document.getElementsByTagName("style")[0];
-      var p = document.getElementsByTagName("p")[1];
-      p.appendChild(style);
-    }
-  </script>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-012-ref.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg">
-  <rect width="50" height="50" fill="blue"/>
-  <g>
-    <rect x="60" width="50" height="50" fill="blue"/>
-  </g>
-  <rect x="120" width="50" height="50" fill="blue"/>
-</svg>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-012.svg
+++ /dev/null
@@ -1,15 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" onload="f()">
-  <rect width="50" height="50"/>
-  <g>
-    <style scoped="">
-      rect { fill: blue }
-    </style>
-    <rect x="60" width="50" height="50"/>
-  </g>
-  <rect x="120" width="50" height="50"/>
-  <script>
-    function f() {
-      document.getElementsByTagName("style")[0].removeAttribute("scoped");
-    }
-  </script>
-</svg>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-013-ref.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg">
-  <rect width="50" height="50"/>
-  <g>
-    <rect x="60" width="50" height="50" fill="blue"/>
-  </g>
-  <rect x="120" width="50" height="50"/>
-</svg>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-013.svg
+++ /dev/null
@@ -1,15 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" onload="f()">
-  <rect width="50" height="50"/>
-  <g>
-    <style>
-      rect { fill: blue }
-    </style>
-    <rect x="60" width="50" height="50"/>
-  </g>
-  <rect x="120" width="50" height="50"/>
-  <script>
-    function f() {
-      document.getElementsByTagName("style")[0].setAttribute("scoped", "");
-    }
-  </script>
-</svg>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-014-ref.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg">
-  <rect width="50" height="50" fill="blue"/>
-  <g>
-    <rect x="60" width="50" height="50" fill="blue"/>
-  </g>
-  <rect x="120" width="50" height="50" fill="blue"/>
-</svg>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-014.svg
+++ /dev/null
@@ -1,15 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" onload="f()">
-  <rect width="50" height="50"/>
-  <g>
-    <style scoped="">
-      rect { fill: blue }
-    </style>
-    <rect x="60" width="50" height="50"/>
-  </g>
-  <rect x="120" width="50" height="50"/>
-  <script>
-    function f() {
-      document.getElementsByTagName("style")[0].scoped = false;
-    }
-  </script>
-</svg>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-015-ref.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg">
-  <rect width="50" height="50"/>
-  <g>
-    <rect x="60" width="50" height="50" fill="blue"/>
-  </g>
-  <rect x="120" width="50" height="50"/>
-</svg>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-dynamic-015.svg
+++ /dev/null
@@ -1,15 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" onload="f()">
-  <rect width="50" height="50"/>
-  <g>
-    <style>
-      rect { fill: blue }
-    </style>
-    <rect x="60" width="50" height="50"/>
-  </g>
-  <rect x="120" width="50" height="50"/>
-  <script>
-    function f() {
-      document.getElementsByTagName("style")[0].scoped = true;
-    }
-  </script>
-</svg>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-font-face-ref.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <style>
-    @font-face {
-      font-family: Ahem;
-      src: url(../fonts/Ahem.ttf);
-    }
-    #a { font-family: Ahem }
-  </style>
-  <p id=a>First</p>
-  <p style="color: blue">Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-font-face.html
+++ /dev/null
@@ -1,23 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <style>
-    @font-face {
-      font-family: Ahem;
-      src: url(../fonts/Ahem.ttf);
-    }
-    #a { font-family: Ahem }
-    #c { font-family: Ahem2 }
-  </style>
-  <p id=a>First</p>
-  <p>
-    <style scoped>
-      @font-face {
-        font-family: Ahem2;
-        src: url(../fonts/Ahem.ttf);
-      }
-      p { font-family: Ahem2; color: blue }
-    </style>
-    Second
-  </p>
-  <p id=c>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-import-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: blue">Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-import.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>
-    <style scoped>
-      @import url(scoped-style-imported.css);
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-important-001-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: blue">First</p>
-  <p style="color: blue">Second</p>
-  <p style="color: blue">Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-important-001.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>
-    <style scoped>
-      p { color: red }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-  <style>
-    p { color: blue !important }
-  </style>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-important-002-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: blue">Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-important-002.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: red">
-    <style scoped>
-      p { color: blue !important }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-important-003-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: green">First</p>
-  <p style="color: green">Second</p>
-  <p style="color: green">Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-important-003.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>
-    <style scoped>
-      p { color: red !important }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-  <style>
-    p { color: green !important }
-  </style>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-important-004-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: green">First</p>
-  <p style="color: green">Second</p>
-  <p style="color: green">Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-important-004.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>
-    <style scoped>
-      p { color: red !important }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-  <style scoped>
-    p { color: green !important }
-  </style>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-important-005-ref.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: green">Hello</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-important-005.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <style scoped>
-    p { color: green !important }
-  </style>
-  <p style="color: red">Hello</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-important-006-ref.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: green">Hello</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-important-006.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: red">
-    <style scoped>
-      p { color: green !important }
-    </style>
-    Hello
-  </p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-important-007-ref.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: green">Hello</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-important-007.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <style scoped>
-    p { color: red !important }
-  </style>
-  <p style="color: green !important">Hello</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-imported.css
+++ /dev/null
@@ -1,1 +0,0 @@
-p { color: blue }
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-keyframes-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p style="color: green">First</p>
-  <p>Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-keyframes.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <style>
-    @keyframes a {
-      from { color: green }
-      to { color: green }
-    }
-    p { animation-duration: 1s; animation-fill-mode: both }
-    #a { animation-name: a }
-    #c { animation-name: b }
-  </style>
-  <p id=a>First</p>
-  <p>
-    <style scoped>
-      @keyframes a {
-        from { color: blue }
-        to { color: blue }
-      }
-      @keyframes b {
-        from { color: red }
-        to { color: red }
-      }
-      p { animation-name: b }
-    </style>
-    Second
-  </p>
-  <p id=c>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-media-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: blue">Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-media.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>
-    <style scoped>
-      @media not all {
-        p { text-decoration: underline }
-      }
-      @media all {
-        p { color: blue }
-      }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-namespace-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: blue">Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-namespace.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>
-    <style scoped>
-      @namespace html url(http://www.w3.org/1999/xhtml);
-      html|p { color: blue }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-pseudo-001-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: green">Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-pseudo-001.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>
-    <style scoped>
-      :scope { color: green }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-pseudo-002-ref.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: green">
-    <div style="border: 2px solid black">Second</div>
-  </p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-pseudo-002.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>
-    <style scoped>
-      :scope { color: green }
-    </style>
-    <div>
-      <style scoped>
-        :scope { border: 2px solid black }
-      </style>
-      Second
-    </div>
-  </p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-pseudo-003-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p><span>Second</span></p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-pseudo-003.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>
-    <style scoped>
-      p :scope { color: red }
-    </style>
-    <span>Second</span>
-  </p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-supports-ref.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p style="color: blue">Second</p>
-  <p>Third</p>
-</body>
deleted file mode 100644
--- a/layout/reftests/scoped-style/scoped-style-supports.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE html>
-<body>
-  <p>First</p>
-  <p>
-    <style scoped>
-      @supports (color: rainbow) {
-        p { text-decoration: underline }
-      }
-      @supports (color: blue) {
-        p { color: blue }
-      }
-    </style>
-    Second
-  </p>
-  <p>Third</p>
-</body>
--- a/layout/style/CSSStyleSheet.cpp
+++ b/layout/style/CSSStyleSheet.cpp
@@ -181,17 +181,16 @@ CSSStyleSheet::SizeOfIncludingThis(Mallo
 
     // Measurement of the following members may be added later if DMD finds it
     // is worthwhile:
     // - s->mRuleCollection
     // - s->mRuleProcessors
     //
     // The following members are not measured:
     // - s->mOwnerRule, because it's non-owning
-    // - s->mScopeElement, because it's non-owning
 
     s = s->mNext ? s->mNext->AsGecko() : nullptr;
   }
   return n;
 }
 
 CSSStyleSheetInner::CSSStyleSheetInner(CSSStyleSheetInner& aCopy,
                                        CSSStyleSheet* aPrimarySheet)
@@ -314,31 +313,29 @@ CSSStyleSheetInner::SizeOfIncludingThis(
 // -------------------------------
 // CSS Style Sheet
 //
 
 CSSStyleSheet::CSSStyleSheet(css::SheetParsingMode aParsingMode,
                              CORSMode aCORSMode, ReferrerPolicy aReferrerPolicy)
   : StyleSheet(StyleBackendType::Gecko, aParsingMode),
     mInRuleProcessorCache(false),
-    mScopeElement(nullptr),
     mRuleProcessors(nullptr)
 {
   mInner = new CSSStyleSheetInner(aCORSMode, aReferrerPolicy,
                                   SRIMetadata());
   mInner->AddSheet(this);
 }
 
 CSSStyleSheet::CSSStyleSheet(css::SheetParsingMode aParsingMode,
                              CORSMode aCORSMode,
                              ReferrerPolicy aReferrerPolicy,
                              const SRIMetadata& aIntegrity)
   : StyleSheet(StyleBackendType::Gecko, aParsingMode),
     mInRuleProcessorCache(false),
-    mScopeElement(nullptr),
     mRuleProcessors(nullptr)
 {
   mInner = new CSSStyleSheetInner(aCORSMode, aReferrerPolicy,
                                   aIntegrity);
   mInner->AddSheet(this);
 }
 
 CSSStyleSheet::CSSStyleSheet(const CSSStyleSheet& aCopy,
@@ -347,17 +344,16 @@ CSSStyleSheet::CSSStyleSheet(const CSSSt
                              nsIDocument* aDocumentToUse,
                              nsINode* aOwningNodeToUse)
   : StyleSheet(aCopy,
                aParentToUse,
                aOwnerRuleToUse,
                aDocumentToUse,
                aOwningNodeToUse)
   , mInRuleProcessorCache(false)
-  , mScopeElement(nullptr)
   , mRuleProcessors(nullptr)
 {
   if (HasForcedUniqueInner()) { // CSSOM's been there, force full copy now
     NS_ASSERTION(mInner->mComplete,
                  "Why have rules been accessed on an incomplete sheet?");
     // FIXME: handle failure?
     //
     // NOTE: It's important to call this from the subclass, since it could
@@ -446,23 +442,21 @@ NS_IMPL_RELEASE_INHERITED(CSSStyleSheet,
 NS_IMPL_CYCLE_COLLECTION_CLASS(CSSStyleSheet)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CSSStyleSheet)
   // We do not unlink mNext; our parent will handle that.  If we
   // unlinked it here, our parent would not be able to walk its list
   // of child sheets and null out the back-references to it, if we got
   // unlinked before it does.
   tmp->DropRuleCollection();
-  tmp->mScopeElement = nullptr;
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(StyleSheet)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(CSSStyleSheet, StyleSheet)
   // We do not traverse mNext; our parent will handle that.  See
   // comments in Unlink for why.
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRuleCollection)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mScopeElement)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 nsresult
 CSSStyleSheet::AddRuleProcessor(nsCSSRuleProcessor* aProcessor)
 {
   if (! mRuleProcessors) {
     mRuleProcessors = new AutoTArray<nsCSSRuleProcessor*, 8>();
     if (!mRuleProcessors)
@@ -624,22 +618,16 @@ CSSStyleSheet::RegisterNamespaceRule(css
     nsresult rv = Inner()->CreateNamespaceMap();
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   AddNamespaceRuleToMap(aRule, Inner()->mNameSpaceMap);
   return NS_OK;
 }
 
-void
-CSSStyleSheet::SetScopeElement(dom::Element* aScopeElement)
-{
-  mScopeElement = aScopeElement;
-}
-
 CSSRuleList*
 CSSStyleSheet::GetCssRulesInternal()
 {
   if (!mRuleCollection) {
     mRuleCollection = new CSSRuleListImpl(this);
   }
   return mRuleCollection;
 }
--- a/layout/style/CSSStyleSheet.h
+++ b/layout/style/CSSStyleSheet.h
@@ -136,19 +136,16 @@ public:
 
   // Function used as a callback to rebuild our inner's child sheet
   // list after we clone a unique inner for ourselves.
   static bool RebuildChildList(css::Rule* aRule,
                                ChildSheetListBuilder* aBuilder);
 
   size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;
 
-  dom::Element* GetScopeElement() const { return mScopeElement; }
-  void SetScopeElement(dom::Element* aScopeElement);
-
   void DidDirty() override;
 
 private:
   CSSStyleSheet(const CSSStyleSheet& aCopy,
                 CSSStyleSheet* aParentToUse,
                 dom::CSSImportRule* aOwnerRuleToUse,
                 nsIDocument* aDocumentToUse,
                 nsINode* aOwningNodeToUse);
@@ -188,17 +185,16 @@ protected:
   nsresult InsertRuleIntoGroupInternal(const nsAString& aRule,
                                        css::GroupRule* aGroup,
                                        uint32_t aIndex);
 
   void EnabledStateChangedInternal();
 
   RefPtr<CSSRuleListImpl> mRuleCollection;
   bool                  mInRuleProcessorCache;
-  RefPtr<dom::Element> mScopeElement;
 
   AutoTArray<nsCSSRuleProcessor*, 8>* mRuleProcessors;
 
   friend class mozilla::StyleSheet;
   friend class ::nsCSSRuleProcessor;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(CSSStyleSheet, NS_CSS_STYLE_SHEET_IMPL_CID)
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -1141,45 +1141,32 @@ Loader::CreateSheet(nsIURI* aURI,
  * well as setting the enabled state based on the title and whether
  * the sheet had "alternate" in its rel.
  */
 void
 Loader::PrepareSheet(StyleSheet* aSheet,
                      const nsAString& aTitle,
                      const nsAString& aMediaString,
                      MediaList* aMediaList,
-                     Element* aScopeElement,
                      bool aIsAlternate)
 {
   NS_PRECONDITION(aSheet, "Must have a sheet!");
 
   RefPtr<MediaList> mediaList(aMediaList);
 
   if (!aMediaString.IsEmpty()) {
     NS_ASSERTION(!aMediaList,
                  "must not provide both aMediaString and aMediaList");
     mediaList = MediaList::Create(GetStyleBackendType(), aMediaString);
   }
 
   aSheet->SetMedia(mediaList);
 
   aSheet->SetTitle(aTitle);
   aSheet->SetEnabled(!aIsAlternate);
-
-  if (aSheet->IsGecko()) {
-#ifdef MOZ_OLD_STYLE
-    aSheet->AsGecko()->SetScopeElement(aScopeElement);
-#else
-    MOZ_CRASH("old style system disabled");
-#endif
-  } else {
-    if (aScopeElement) {
-      NS_WARNING("stylo: scoped style sheets not supported");
-    }
-  }
 }
 
 /**
  * InsertSheetInDoc handles ordering of sheets in the document.  Here
  * we have two types of sheets -- those with linking elements and
  * those without.  The latter are loaded by Link: headers.
  * The following constraints are observed:
  * 1) Any sheet with a linking element comes after all sheets without
@@ -2000,17 +1987,16 @@ Loader::MarkLoadTreeFailed(SheetLoadData
 nsresult
 Loader::LoadInlineStyle(nsIContent* aElement,
                         const nsAString& aBuffer,
                         nsIPrincipal* aTriggeringPrincipal,
                         uint32_t aLineNumber,
                         const nsAString& aTitle,
                         const nsAString& aMedia,
                         ReferrerPolicy aReferrerPolicy,
-                        Element* aScopeElement,
                         nsICSSLoaderObserver* aObserver,
                         bool* aCompleted,
                         bool* aIsAlternate)
 {
   LOG(("css::Loader::LoadInlineStyle"));
 
   *aCompleted = true;
 
@@ -2036,17 +2022,17 @@ Loader::LoadInlineStyle(nsIContent* aEle
                             false, false, aTitle, state, aIsAlternate,
                             &sheet);
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ASSERTION(state == eSheetNeedsParser,
                "Inline sheets should not be cached");
 
   LOG(("  Sheet is alternate: %d", *aIsAlternate));
 
-  PrepareSheet(sheet, aTitle, aMedia, nullptr, aScopeElement, *aIsAlternate);
+  PrepareSheet(sheet, aTitle, aMedia, nullptr, *aIsAlternate);
 
   if (aElement->HasFlag(NODE_IS_IN_SHADOW_TREE)) {
     ShadowRoot* containingShadow = aElement->GetContainingShadow();
     MOZ_ASSERT(containingShadow);
     containingShadow->InsertSheet(sheet, aElement);
   } else {
     rv = InsertSheetInDoc(sheet, aElement, mDocument);
     NS_ENSURE_SUCCESS(rv, rv);
@@ -2147,17 +2133,17 @@ Loader::LoadStyleLink(nsIContent* aEleme
   rv = CreateSheet(aURL, aElement, principal, eAuthorSheetFeatures,
                    aCORSMode, aReferrerPolicy, aIntegrity, false,
                    aHasAlternateRel, aTitle, state, aIsAlternate,
                    &sheet);
   NS_ENSURE_SUCCESS(rv, rv);
 
   LOG(("  Sheet is alternate: %d", *aIsAlternate));
 
-  PrepareSheet(sheet, aTitle, aMedia, nullptr, nullptr, *aIsAlternate);
+  PrepareSheet(sheet, aTitle, aMedia, nullptr, *aIsAlternate);
 
   rv = InsertSheetInDoc(sheet, aElement, mDocument);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIStyleSheetLinkingElement> owningElement(do_QueryInterface(aElement));
 
   if (state == eSheetComplete) {
     LOG(("  Sheet already complete: 0x%p", sheet.get()));
@@ -2321,17 +2307,17 @@ Loader::LoadChildSheet(StyleSheet* aPare
     rv = CreateSheet(aURL, nullptr, principal,
                      aParentSheet->ParsingMode(),
                      CORS_NONE, aParentSheet->GetReferrerPolicy(),
                      EmptyString(), // integrity is only checked on main sheet
                      aParentData ? aParentData->mSyncLoad : false,
                      false, empty, state, &isAlternate, &sheet);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    PrepareSheet(sheet, empty, empty, aMedia, nullptr, isAlternate);
+    PrepareSheet(sheet, empty, empty, aMedia, isAlternate);
   }
 
   rv = InsertChildSheet(sheet, aParentSheet, aGeckoParentRule);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (state == eSheetComplete) {
     LOG(("  Sheet already complete"));
     // We're completely done.  No need to notify, even, since the
@@ -2477,17 +2463,17 @@ Loader::InternalLoadNonDocumentSheet(nsI
   bool syncLoad = (aObserver == nullptr);
   const nsAString& empty = EmptyString();
 
   rv = CreateSheet(aURL, nullptr, aOriginPrincipal, aParsingMode,
                    aCORSMode, aReferrerPolicy, aIntegrity, syncLoad,
                    false, empty, state, &isAlternate, &sheet);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  PrepareSheet(sheet, empty, empty, nullptr, nullptr, isAlternate);
+  PrepareSheet(sheet, empty, empty, nullptr, isAlternate);
 
   if (state == eSheetComplete) {
     LOG(("  Sheet already complete"));
     if (aObserver || !mObservers.IsEmpty()) {
       rv = PostLoadEvent(aURL, sheet, aObserver, false, nullptr);
     }
     if (aSheet) {
       sheet.swap(*aSheet);
--- a/layout/style/Loader.h
+++ b/layout/style/Loader.h
@@ -242,17 +242,16 @@ public:
    */
   nsresult LoadInlineStyle(nsIContent* aElement,
                            const nsAString& aBuffer,
                            nsIPrincipal* aTriggeringPrincipal,
                            uint32_t aLineNumber,
                            const nsAString& aTitle,
                            const nsAString& aMedia,
                            ReferrerPolicy aReferrerPolicy,
-                           mozilla::dom::Element* aScopeElement,
                            nsICSSLoaderObserver* aObserver,
                            bool* aCompleted,
                            bool* aIsAlternate);
 
   /**
    * Load a linked (document) stylesheet.  If a successful result is returned,
    * aObserver is guaranteed to be notified asynchronously once the sheet is
    * loaded and marked complete.  If an error is returned, aObserver will not
@@ -520,17 +519,16 @@ private:
   // Pass in either a media string or the MediaList from the CSSParser.  Don't
   // pass both.
   //
   // This method will set the sheet's enabled state based on aIsAlternate
   void PrepareSheet(StyleSheet* aSheet,
                     const nsAString& aTitle,
                     const nsAString& aMediaString,
                     dom::MediaList* aMediaList,
-                    dom::Element* aScopeElement,
                     bool aIsAlternate);
 
   nsresult InsertSheetInDoc(StyleSheet* aSheet,
                             nsIContent* aLinkingContent,
                             nsIDocument* aDocument);
 
   nsresult InsertChildSheet(StyleSheet* aSheet,
                             StyleSheet* aParentSheet,
--- a/layout/style/SheetType.h
+++ b/layout/style/SheetType.h
@@ -18,17 +18,16 @@ namespace mozilla {
 //
 // Be sure to update NS_RULE_NODE_LEVEL_MASK when changing the number
 // of sheet types; static assertions enforce this.
 enum class SheetType : uint8_t {
   Agent, // CSS
   User, // CSS
   PresHint,
   Doc, // CSS
-  ScopedDoc, // CSS
   StyleAttr,
   Override, // CSS
   Animation,
   Transition,
 
   Count,
   Unknown = 0xff
 };
@@ -37,17 +36,16 @@ enum class SheetType : uint8_t {
 // a StyleSheet object.
 inline bool
 IsCSSSheetType(SheetType aSheetType)
 {
   switch (aSheetType) {
     case SheetType::Agent:
     case SheetType::User:
     case SheetType::Doc:
-    case SheetType::ScopedDoc:
     case SheetType::Override:
       return true;
     default:
       return false;
   }
 }
 
 } // namespace mozilla
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -980,29 +980,25 @@ nsCSSRuleProcessor::nsCSSRuleProcessor(s
                                          aPreviousCSSRuleProcessor,
                                        bool aIsShared)
   : mSheets(aSheets)
   , mRuleCascades(nullptr)
   , mPreviousCacheKey(aPreviousCSSRuleProcessor
                        ? aPreviousCSSRuleProcessor->CloneMQCacheKey()
                        : UniquePtr<nsMediaQueryResultCacheKey>())
   , mLastPresContext(nullptr)
-  , mScopeElement(aScopeElement)
   , mStyleSetRefCnt(0)
   , mSheetType(aSheetType)
   , mIsShared(aIsShared)
   , mMustGatherDocumentRules(aIsShared)
   , mInRuleProcessorCache(false)
 #ifdef DEBUG
   , mDocumentRulesAndCacheKeyValid(false)
 #endif
 {
-  NS_ASSERTION(!!mScopeElement == (aSheetType == SheetType::ScopedDoc),
-               "aScopeElement must be specified iff aSheetType is "
-               "eScopedDocSheet");
   for (sheet_array_type::size_type i = mSheets.Length(); i-- != 0; ) {
     mSheets[i]->AddRuleProcessor(this);
   }
 }
 
 nsCSSRuleProcessor::~nsCSSRuleProcessor()
 {
   if (mInRuleProcessorCache) {
@@ -1020,22 +1016,20 @@ NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsCSSRuleProcessor)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsCSSRuleProcessor)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsCSSRuleProcessor)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsCSSRuleProcessor)
   tmp->ClearSheets();
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mScopeElement)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsCSSRuleProcessor)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSheets)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mScopeElement)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 void
 nsCSSRuleProcessor::ClearSheets()
 {
   for (sheet_array_type::size_type i = mSheets.Length(); i-- != 0; ) {
     mSheets[i]->DropRuleProcessor(this);
   }
@@ -1752,28 +1746,17 @@ static bool SelectorMatches(Element* aEl
     case CSSPseudoClassType::mozWindowInactive:
       if (!aTreeMatchContext.mDocument->GetDocumentState().
               HasState(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) {
         return false;
       }
       break;
 
     case CSSPseudoClassType::scope:
-      if (aTreeMatchContext.mForScopedStyle) {
-        if (aTreeMatchContext.mCurrentStyleScope) {
-          // If mCurrentStyleScope is null, aElement must be the style
-          // scope root.  This is because the PopStyleScopeForSelectorMatching
-          // call in SelectorMatchesTree sets mCurrentStyleScope to null
-          // as soon as we visit the style scope element, and we won't
-          // progress further up the tree after this call to
-          // SelectorMatches.  Thus if mCurrentStyleScope is still set,
-          // we know the selector does not match.
-          return false;
-        }
-      } else if (aTreeMatchContext.HasSpecifiedScope()) {
+      if (aTreeMatchContext.HasSpecifiedScope()) {
         if (!aTreeMatchContext.IsScopeElement(aElement)) {
           return false;
         }
       } else {
         if (aElement != aElement->OwnerDoc()->GetRootElement()) {
           return false;
         }
       }
@@ -1996,24 +1979,16 @@ SelectorMatchesTree(Element* aPrevElemen
   Element* prevElement = aPrevElement;
   bool xblChildrenMatched = false;
 
   while (selector) { // check compound selectors
     NS_ASSERTION(!selector->mNext ||
                  selector->mNext->mOperator != char16_t(0),
                  "compound selector without combinator");
 
-    // If after the previous selector match we are now outside the
-    // current style scope, we don't need to match any further.
-    if (aTreeMatchContext.mForScopedStyle &&
-        !aTreeMatchContext.IsWithinStyleScopeForSelectorMatching()) {
-      ASSERT_XBL_CHILDREN_HACK();
-      return false;
-    }
-
     // for adjacent sibling combinators, the content to test against the
     // selector is the previous sibling *element*
     Element* element = nullptr;
     if (char16_t('+') == selector->mOperator ||
         char16_t('~') == selector->mOperator) {
       // The relevant link must be an ancestor of the node being matched.
       aFlags = SelectorMatchesTreeFlags(aFlags & ~eLookForRelevantLink);
       nsIContent* parent = prevElement->GetParent();
@@ -2033,46 +2008,32 @@ SelectorMatchesTree(Element* aPrevElemen
         // According to the spec, we should not match rules cross the shadow
         // DOM boundary.
         content = nullptr;
       }
       // GetParent could return a document fragment; we only want
       // element parents.
       if (content && content->IsElement()) {
         element = content->AsElement();
-        if (aTreeMatchContext.mForScopedStyle) {
-          // We are moving up to the parent element; tell the
-          // TreeMatchContext, so that in case this element is the
-          // style scope element, selector matching stops before we
-          // traverse further up the tree.
-          aTreeMatchContext.PopStyleScopeForSelectorMatching(element);
-        }
 
         // Compatibility hack: First try matching this selector as though the
         // <xbl:children> element wasn't in the tree to allow old selectors
         // were written before <xbl:children> participated in CSS selector
         // matching to work.
         if (selector->mOperator == '>' && element->IsActiveChildrenElement()) {
-          Element* styleScope = aTreeMatchContext.mCurrentStyleScope;
           xblChildrenMatched |=
             SelectorMatchesTree(element, selector, aTreeMatchContext, aFlags);
 
 #ifndef EARLY_BETA_OR_EARLIER
           if (xblChildrenMatched) {
             // It matched, don't try matching on the <xbl:children> element at
             // all.
             return true;
           }
 #endif
-
-          // We want to reset mCurrentStyleScope on aTreeMatchContext
-          // back to its state before the SelectorMatchesTree call, in
-          // case that call happens to traverse past the style scope element
-          // and sets it to null.
-          aTreeMatchContext.mCurrentStyleScope = styleScope;
         }
       }
     }
     if (!element) {
       ASSERT_XBL_CHILDREN_HACK();
       return false;
     }
     if ((aFlags & eMatchOnConditionalRestyleAncestor) &&
@@ -2118,25 +2079,19 @@ SelectorMatchesTree(Element* aPrevElemen
 
         // pretend the selector didn't match, and step through content
         // while testing the same selector
 
         // This approach is slightly strange in that when it recurs
         // it tests from the top of the content tree, down.  This
         // doesn't matter much for performance since most selectors
         // don't match.  (If most did, it might be faster...)
-        Element* styleScope = aTreeMatchContext.mCurrentStyleScope;
         if (SelectorMatchesTree(element, selector, aTreeMatchContext, aFlags)) {
           return true;
         }
-        // We want to reset mCurrentStyleScope on aTreeMatchContext
-        // back to its state before the SelectorMatchesTree call, in
-        // case that call happens to traverse past the style scope element
-        // and sets it to null.
-        aTreeMatchContext.mCurrentStyleScope = styleScope;
       }
       selector = selector->mNext;
     }
     else {
       // for adjacent sibling and child combinators, if we didn't find
       // a match, we're done
       if (!NS_IS_GREEDY_OPERATOR(selector->mOperator)) {
         ASSERT_XBL_CHILDREN_HACK();
@@ -2159,22 +2114,16 @@ void ContentEnumFunc(const RuleValue& va
     data->mTreeMatchContext.SetHaveRelevantLink();
   }
   if (ancestorFilter &&
       !ancestorFilter->MightHaveMatchingAncestor<RuleValue::eMaxAncestorHashes>(
           value.mAncestorSelectorHashes)) {
     // We won't match; nothing else to do here
     return;
   }
-  if (!data->mTreeMatchContext.SetStyleScopeForSelectorMatching(data->mElement,
-                                                                data->mScope)) {
-    // The selector is for a rule in a scoped style sheet, and the subject
-    // of the selector matching is not in its scope.
-    return;
-  }
   nsCSSSelector* selector = aSelector;
   if (selector->IsPseudoElement()) {
     PseudoElementRuleProcessorData* pdata =
       static_cast<PseudoElementRuleProcessorData*>(data);
     if (!pdata->mPseudoElement && selector->mPseudoClassList) {
       // We can get here when calling getComputedStyle(aElt, aPseudo) if:
       //
       //   * aPseudo is a pseudo-element that supports a user action
@@ -2319,20 +2268,16 @@ static inline nsRestyleHint RestyleHintF
 }
 
 nsRestyleHint
 nsCSSRuleProcessor::HasStateDependentStyle(ElementDependentRuleProcessorData* aData,
                                            Element* aStatefulElement,
                                            CSSPseudoElementType aPseudoType,
                                            EventStates aStateMask)
 {
-  MOZ_ASSERT(!aData->mTreeMatchContext.mForScopedStyle,
-             "mCurrentStyleScope will need to be saved and restored after the "
-             "SelectorMatchesTree call");
-
   bool isPseudoElement =
     aPseudoType != CSSPseudoElementType::NotPseudo;
 
   RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
 
   // Look up the content node in the state rule list, which points to
   // any (CSS2 definition) simple selector (whether or not it is the
   // subject) that has a state pseudo-class on it.  This means that this
@@ -2508,23 +2453,16 @@ RestyleHintForSelectorWithAttributeChang
 
 static void
 AttributeEnumFunc(nsCSSSelector* aSelector,
                   nsCSSSelector* aRightmostSelector,
                   AttributeEnumData* aData)
 {
   AttributeRuleProcessorData *data = aData->data;
 
-  if (!data->mTreeMatchContext.SetStyleScopeForSelectorMatching(data->mElement,
-                                                                data->mScope)) {
-    // The selector is for a rule in a scoped style sheet, and the subject
-    // of the selector matching is not in its scope.
-    return;
-  }
-
   nsRestyleHint possibleChange =
     RestyleHintForSelectorWithAttributeChange(aData->change,
                                               aSelector, aRightmostSelector);
 
   // If, ignoring eRestyle_SomeDescendants, enumData->change already includes
   // all the bits of possibleChange, don't bother calling SelectorMatches, since
   // even if it returns false enumData->change won't change.  If possibleChange
   // has eRestyle_SomeDescendants, we need to call SelectorMatches(Tree)
@@ -3574,20 +3512,16 @@ nsCSSRuleProcessor::RefreshRuleCascade(n
   }
 }
 
 /* static */ bool
 nsCSSRuleProcessor::SelectorListMatches(Element* aElement,
                                         TreeMatchContext& aTreeMatchContext,
                                         nsCSSSelectorList* aSelectorList)
 {
-  MOZ_ASSERT(!aTreeMatchContext.mForScopedStyle,
-             "mCurrentStyleScope will need to be saved and restored after the "
-             "SelectorMatchesTree call");
-
   while (aSelectorList) {
     nsCSSSelector* sel = aSelectorList->mSelectors;
     NS_ASSERTION(sel, "Should have *some* selectors");
     NS_ASSERTION(!sel->IsPseudoElement(), "Shouldn't have been called");
     NodeMatchContext nodeContext(EventStates(), false);
     if (SelectorMatches(aElement, sel, nodeContext, aTreeMatchContext,
                         SelectorMatchesFlags::NONE)) {
       nsCSSSelector* next = sel->mNext;
@@ -3644,17 +3578,16 @@ nsCSSRuleProcessor::ReleaseStyleSetRef()
 }
 
 // TreeMatchContext and AncestorFilter out of line methods
 void
 TreeMatchContext::InitAncestors(Element *aElement)
 {
   MOZ_ASSERT(!mAncestorFilter.mFilter);
   MOZ_ASSERT(mAncestorFilter.mHashes.IsEmpty());
-  MOZ_ASSERT(mStyleScopes.IsEmpty());
 
   mAncestorFilter.mFilter = new AncestorFilter::Filter();
 
   if (MOZ_LIKELY(aElement)) {
     MOZ_ASSERT(aElement->GetUncomposedDoc() ||
                aElement->HasFlag(NODE_IS_IN_SHADOW_TREE),
                "aElement must be in the document or in shadow tree "
                "for the assumption that GetParentNode() is non-null "
@@ -3665,38 +3598,16 @@ TreeMatchContext::InitAncestors(Element 
     do {
       ancestors.AppendElement(cur);
       cur = cur->GetParentElementCrossingShadowRoot();
     } while (cur);
 
     // Now push them in reverse order.
     for (uint32_t i = ancestors.Length(); i-- != 0; ) {
       mAncestorFilter.PushAncestor(ancestors[i]);
-      PushStyleScope(ancestors[i]);
-    }
-  }
-}
-
-void
-TreeMatchContext::InitStyleScopes(Element* aElement)
-{
-  MOZ_ASSERT(mStyleScopes.IsEmpty());
-
-  if (MOZ_LIKELY(aElement)) {
-    // Collect up the ancestors
-    AutoTArray<Element*, 50> ancestors;
-    Element* cur = aElement;
-    do {
-      ancestors.AppendElement(cur);
-      cur = cur->GetParentElementCrossingShadowRoot();
-    } while (cur);
-
-    // Now push them in reverse order.
-    for (uint32_t i = ancestors.Length(); i-- != 0; ) {
-      PushStyleScope(ancestors[i]);
     }
   }
 }
 
 void
 AncestorFilter::PushAncestor(Element *aElement)
 {
   MOZ_ASSERT(mFilter);
@@ -3752,26 +3663,9 @@ void
 AncestorFilter::AssertHasAllAncestors(Element *aElement) const
 {
   Element* cur = aElement->GetParentElementCrossingShadowRoot();
   while (cur) {
     MOZ_ASSERT(mElements.Contains(cur));
     cur = cur->GetParentElementCrossingShadowRoot();
   }
 }
-
-void
-TreeMatchContext::AssertHasAllStyleScopes(Element* aElement) const
-{
-  if (aElement->IsInNativeAnonymousSubtree()) {
-    // Document style sheets are never applied to native anonymous content,
-    // so it's not possible for them to be in a <style scoped> scope.
-    return;
-  }
-  Element* cur = aElement->GetParentElementCrossingShadowRoot();
-  while (cur) {
-    if (cur->IsScopedStyleRoot()) {
-      MOZ_ASSERT(mStyleScopes.Contains(cur));
-    }
-    cur = cur->GetParentElementCrossingShadowRoot();
-  }
-}
 #endif
--- a/layout/style/nsCSSRuleProcessor.h
+++ b/layout/style/nsCSSRuleProcessor.h
@@ -178,23 +178,16 @@ public:
                                                  nsAtom* aName);
 
   bool AppendPageRules(nsPresContext* aPresContext,
                        nsTArray<nsCSSPageRule*>& aArray);
 
   bool AppendFontFeatureValuesRules(nsPresContext* aPresContext,
                               nsTArray<nsCSSFontFeatureValuesRule*>& aArray);
 
-  /**
-   * Returns the scope element for the scoped style sheets this rule
-   * processor is for.  If this is not a rule processor for scoped style
-   * sheets, it returns null.
-   */
-  mozilla::dom::Element* GetScopeElement() const { return mScopeElement; }
-
   void TakeDocumentRulesAndCacheKey(
       nsPresContext* aPresContext,
       nsTArray<mozilla::css::DocumentRule*>& aDocumentRules,
       nsDocumentRuleResultCacheKey& aDocumentRuleResultCacheKey);
 
   bool IsShared() const { return mIsShared; }
 
   nsExpirationState* GetExpirationState() { return &mExpirationState; }
@@ -243,20 +236,16 @@ private:
   // If we cleared our mRuleCascades or replaced a previous rule
   // processor, this is the media query result cache key that was used
   // before we lost the old rule cascades.
   mozilla::UniquePtr<nsMediaQueryResultCacheKey> mPreviousCacheKey;
 
   // The last pres context for which GetRuleCascades was called.
   nsPresContext *mLastPresContext;
 
-  // The scope element for this rule processor's scoped style sheets.
-  // Only used if mSheetType == nsStyleSet::eScopedDocSheet.
-  RefPtr<mozilla::dom::Element> mScopeElement;
-
   nsTArray<mozilla::css::DocumentRule*> mDocumentRules;
   nsDocumentRuleResultCacheKey mDocumentCacheKey;
 
   nsExpirationState mExpirationState;
   MozRefCountType mStyleSetRefCnt;
 
   // type of stylesheet using this processor
   mozilla::SheetType mSheetType;
--- a/layout/style/nsRuleProcessorData.h
+++ b/layout/style/nsRuleProcessorData.h
@@ -146,186 +146,71 @@ struct MOZ_STACK_CLASS TreeMatchContext 
   }
   bool HasSpecifiedScope() const {
     return mHaveSpecifiedScope;
   }
 
   /**
    * Initialize the ancestor filter and list of style scopes.  If aElement is
    * not null, it and all its ancestors will be passed to
-   * mAncestorFilter.PushAncestor and PushStyleScope, starting from the root and
+   * mAncestorFilter.PushAncestor, starting from the root and
    * going down the tree.  Must only be called for elements in a document.
    */
   void InitAncestors(mozilla::dom::Element *aElement);
 
-  /**
-   * Like InitAncestors, but only initializes the style scope list, not the
-   * ancestor filter.  May be called for elements outside a document.
-   */
-  void InitStyleScopes(mozilla::dom::Element* aElement);
-
-  void PushStyleScope(mozilla::dom::Element* aElement)
-  {
-    NS_PRECONDITION(aElement, "aElement must not be null");
-    if (aElement->IsScopedStyleRoot()) {
-      mStyleScopes.AppendElement(aElement);
-    }
-  }
-
-  void PopStyleScope(mozilla::dom::Element* aElement)
-  {
-    NS_PRECONDITION(aElement, "aElement must not be null");
-    if (mStyleScopes.SafeLastElement(nullptr) == aElement) {
-      mStyleScopes.TruncateLength(mStyleScopes.Length() - 1);
-    }
-  }
-
-  bool PopStyleScopeForSelectorMatching(mozilla::dom::Element* aElement)
-  {
-    NS_ASSERTION(mForScopedStyle, "only call PopStyleScopeForSelectorMatching "
-                                  "when mForScopedStyle is true");
-
-    if (!mCurrentStyleScope) {
-      return false;
-    }
-    if (mCurrentStyleScope == aElement) {
-      mCurrentStyleScope = nullptr;
-    }
-    return true;
-  }
-
-#ifdef DEBUG
-  void AssertHasAllStyleScopes(mozilla::dom::Element* aElement) const;
-#endif
-
-  bool SetStyleScopeForSelectorMatching(mozilla::dom::Element* aSubject,
-                                        mozilla::dom::Element* aScope)
-  {
-#ifdef DEBUG
-    AssertHasAllStyleScopes(aSubject);
-#endif
-
-    mForScopedStyle = !!aScope;
-    if (!aScope) {
-      // This is not for a scoped style sheet; return true, as we want
-      // selector matching to proceed.
-      mCurrentStyleScope = nullptr;
-      return true;
-    }
-    if (aScope == aSubject) {
-      // Although the subject is the same element as the scope, as soon
-      // as we continue with selector matching up the tree we don't want
-      // to match any more elements.  So we return true to indicate that
-      // we want to do the initial selector matching, but set
-      // mCurrentStyleScope to null so that no ancestor elements will match.
-      mCurrentStyleScope = nullptr;
-      return true;
-    }
-    if (mStyleScopes.Contains(aScope)) {
-      // mStyleScopes contains all of the scope elements that are ancestors of
-      // aSubject, so if aScope is in mStyleScopes, then we do want selector
-      // matching to proceed.
-      mCurrentStyleScope = aScope;
-      return true;
-    }
-    // Otherwise, we're not in the scope, and we don't want to proceed
-    // with selector matching.
-    mCurrentStyleScope = nullptr;
-    return false;
-  }
-
-  bool IsWithinStyleScopeForSelectorMatching() const
-  {
-    NS_ASSERTION(mForScopedStyle, "only call IsWithinScopeForSelectorMatching "
-                                  "when mForScopedStyle is true");
-    return mCurrentStyleScope;
-  }
-
   /*
    * Helper class for maintaining the ancestor state.
    *
    * This class does nothing if aTreeMatchContext is null, which is the case for
    * the Servo style system.
    */
   class MOZ_RAII AutoAncestorPusher {
   public:
     explicit AutoAncestorPusher(TreeMatchContext* aTreeMatchContext
                                 MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : mPushedAncestor(false)
-      , mPushedStyleScope(false)
       , mTreeMatchContext(aTreeMatchContext)
       , mElement(nullptr)
     {
       MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     }
 
-    void PushAncestorAndStyleScope(mozilla::dom::Element* aElement) {
+    void PushAncestor(mozilla::dom::Element* aElement) {
       if (!mTreeMatchContext) {
         MOZ_ASSERT(!aElement || aElement->IsStyledByServo());
         return;
       }
 
       MOZ_ASSERT(!mElement);
       if (aElement) {
         mElement = aElement;
         mPushedAncestor = true;
-        mPushedStyleScope = true;
         mTreeMatchContext->mAncestorFilter.PushAncestor(aElement);
-        mTreeMatchContext->PushStyleScope(aElement);
       }
     }
 
-    void PushAncestorAndStyleScope(nsIContent* aContent) {
+    void PushAncestor(nsIContent* aContent) {
       if (!mTreeMatchContext) {
         MOZ_ASSERT(!aContent || aContent->IsStyledByServo());
         return;
       }
 
       if (aContent && aContent->IsElement()) {
-        PushAncestorAndStyleScope(aContent->AsElement());
-      }
-    }
-
-    void PushStyleScope(mozilla::dom::Element* aElement) {
-      if (!mTreeMatchContext) {
-        MOZ_ASSERT(!aElement || aElement->IsStyledByServo());
-        return;
-      }
-
-      MOZ_ASSERT(!mElement);
-      if (aElement) {
-        mElement = aElement;
-        mPushedStyleScope = true;
-        mTreeMatchContext->PushStyleScope(aElement);
-      }
-    }
-
-    void PushStyleScope(nsIContent* aContent) {
-      if (!mTreeMatchContext) {
-        MOZ_ASSERT(!aContent || aContent->IsStyledByServo());
-        return;
-      }
-
-      if (aContent && aContent->IsElement()) {
-        PushStyleScope(aContent->AsElement());
+        PushAncestor(aContent->AsElement());
       }
     }
 
     ~AutoAncestorPusher() {
       if (mPushedAncestor) {
         mTreeMatchContext->mAncestorFilter.PopAncestor();
       }
-      if (mPushedStyleScope) {
-        mTreeMatchContext->PopStyleScope(mElement);
-      }
     }
 
   private:
     bool mPushedAncestor;
-    bool mPushedStyleScope;
     TreeMatchContext* mTreeMatchContext;
     mozilla::dom::Element* mElement;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
   };
 
   /* Helper class for tracking whether we're skipping the ApplyStyleFixups
    * code for special cases where child element style is modified based on
    * parent display value.
@@ -399,55 +284,46 @@ struct MOZ_STACK_CLASS TreeMatchContext 
   bool mUsingPrivateBrowsing;
 
   // Whether we're currently skipping the part of ApplyStyleFixups that changes
   // style of child elements based on their parent's display value
   // (e.g. for children of elements that have a mandatory frame-type for which
   // we ignore "display:flex/grid").
   bool mSkippingParentDisplayBasedStyleFixup;
 
-  // Whether this TreeMatchContext is being used with an nsCSSRuleProcessor
-  // for an HTML5 scoped style sheet.
-  bool mForScopedStyle;
-
   // An enum that communicates the consumer's intensions for this
   // TreeMatchContext in terms of :visited handling.  eNeverMatchVisited means
   // that this TreeMatchContext's VisitedHandlingType will always be
   // eRelevantLinkUnvisited (in other words, this value will be passed to the
   // constructor and ResetForVisitedMatching() will never be called).
   // eMatchVisitedDefault doesn't communicate any information about the current
   // or future VisitedHandlingType of this TreeMatchContext.
   enum MatchVisited {
     eNeverMatchVisited,
     eMatchVisitedDefault
   };
 
   // List of ancestor elements that define a style scope (due to having a
   // <style scoped> child).
   AutoTArray<mozilla::dom::Element*, 1> mStyleScopes;
 
-  // The current style scope element for selector matching.
-  mozilla::dom::Element* mCurrentStyleScope;
-
   // Constructor to use when creating a tree match context for styling
   TreeMatchContext(bool aForStyling,
                    nsRuleWalker::VisitedHandlingType aVisitedHandling,
                    nsIDocument* aDocument,
                    MatchVisited aMatchVisited = eMatchVisitedDefault)
     : mForStyling(aForStyling)
     , mHaveRelevantLink(false)
     , mHaveSpecifiedScope(false)
     , mVisitedHandling(aVisitedHandling)
     , mDocument(aDocument)
     , mIsHTMLDocument(aDocument->IsHTMLDocument())
     , mCompatMode(aDocument->GetCompatibilityMode())
     , mUsingPrivateBrowsing(false)
     , mSkippingParentDisplayBasedStyleFixup(false)
-    , mForScopedStyle(false)
-    , mCurrentStyleScope(nullptr)
   {
     if (aMatchVisited != eNeverMatchVisited) {
       nsILoadContext* loadContext = mDocument->GetLoadContext();
       if (loadContext) {
         mUsingPrivateBrowsing = loadContext->UsePrivateBrowsing();
       }
     } else {
       MOZ_ASSERT(aVisitedHandling == nsRuleWalker::eRelevantLinkUnvisited,
@@ -646,18 +522,17 @@ struct MOZ_STACK_CLASS AttributeRuleProc
 // style system code is compiled out.
 struct TreeMatchContext
 {
 public:
   class AutoAncestorPusher
   {
   public:
     explicit AutoAncestorPusher(TreeMatchContext* aTreeMatchContext) {}
-    void PushAncestorAndStyleScope(nsIContent* aContent) {}
-    void PushStyleScope(nsIContent* aContent) {}
+    void PushAncestor(nsIContent* aContent) {}
   };
 
   class AutoParentDisplayBasedStyleFixupSkipper
   {
   public:
     explicit AutoParentDisplayBasedStyleFixupSkipper(
         TreeMatchContext& aTreeMatchContext,
         bool aSkipParentDisplayBasedStyleFixup = true) {}
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -190,17 +190,16 @@ nsDisableTextZoomStyleRule::List(FILE* o
 }
 #endif
 
 static const SheetType gCSSSheetTypes[] = {
   // From lowest to highest in cascading order.
   SheetType::Agent,
   SheetType::User,
   SheetType::Doc,
-  SheetType::ScopedDoc,
   SheetType::Override
 };
 
 nsStyleSet::nsStyleSet()
   : mRuleTree(nullptr),
     mBatching(0),
     mStylesHaveChanged(0),
     mInShutdown(false),
@@ -260,21 +259,16 @@ nsStyleSet::AddSizeOfIncludingThis(nsWin
         n += mRuleProcessors[type]->SizeOfIncludingThis(mallocSizeOf);
       }
     }
     // We don't own the sheets (either the nsLayoutStyleSheetCache singleton
     // or our document owns them).
     n += mSheets[type].ShallowSizeOfExcludingThis(mallocSizeOf);
   }
 
-  for (uint32_t i = 0; i < mScopedDocSheetRuleProcessors.Length(); i++) {
-    n += mScopedDocSheetRuleProcessors[i]->SizeOfIncludingThis(mallocSizeOf);
-  }
-  n += mScopedDocSheetRuleProcessors.ShallowSizeOfExcludingThis(mallocSizeOf);
-
   aSizes.mLayoutGeckoStyleSets += n;
 }
 
 void
 nsStyleSet::Init(nsPresContext* aPresContext)
 {
   mFirstLineRule = new nsEmptyStyleRule;
   mFirstLetterRule = new nsEmptyStyleRule;
@@ -325,133 +319,43 @@ nsStyleSet::EndReconstruct()
 {
   NS_ASSERTION(mInReconstruct, "Unmatched begin/end?");
   mInReconstruct = false;
   GCRuleTrees();
 }
 
 typedef nsDataHashtable<nsPtrHashKey<nsINode>, uint32_t> ScopeDepthCache;
 
-// Returns the depth of a style scope element, with 1 being the depth of
-// a style scope element that has no ancestor style scope elements.  The
-// depth does not count intervening non-scope elements.
-static uint32_t
-GetScopeDepth(nsINode* aScopeElement, ScopeDepthCache& aCache)
-{
-  nsINode* parent = aScopeElement->GetParent();
-  if (!parent || !parent->IsElementInStyleScope()) {
-    return 1;
-  }
-
-  uint32_t depth = aCache.Get(aScopeElement);
-  if (!depth) {
-    for (nsINode* n = parent; n; n = n->GetParent()) {
-      if (n->IsScopedStyleRoot()) {
-        depth = GetScopeDepth(n, aCache) + 1;
-        aCache.Put(aScopeElement, depth);
-        break;
-      }
-    }
-  }
-  return depth;
-}
-
-struct ScopedSheetOrder
-{
-  CSSStyleSheet* mSheet;
-  uint32_t mDepth;
-  uint32_t mOrder;
-
-  bool operator==(const ScopedSheetOrder& aRHS) const
-  {
-    return mDepth == aRHS.mDepth &&
-           mOrder == aRHS.mOrder;
-  }
-
-  bool operator<(const ScopedSheetOrder& aRHS) const
-  {
-    if (mDepth != aRHS.mDepth) {
-      return mDepth < aRHS.mDepth;
-    }
-    return mOrder < aRHS.mOrder;
-  }
-};
-
-// Sorts aSheets such that style sheets for ancestor scopes come
-// before those for descendant scopes, and with sheets for a single
-// scope in document order.
-static void
-SortStyleSheetsByScope(nsTArray<CSSStyleSheet*>& aSheets)
-{
-  uint32_t n = aSheets.Length();
-  if (n == 1) {
-    return;
-  }
-
-  ScopeDepthCache cache;
-
-  nsTArray<ScopedSheetOrder> sheets;
-  sheets.SetLength(n);
-
-  // For each sheet, record the depth of its scope element and its original
-  // document order.
-  for (uint32_t i = 0; i < n; i++) {
-    sheets[i].mSheet = aSheets[i];
-    sheets[i].mDepth = GetScopeDepth(aSheets[i]->GetScopeElement(), cache);
-    sheets[i].mOrder = i;
-  }
-
-  // Sort by depth first, then document order.
-  sheets.Sort();
-
-  for (uint32_t i = 0; i < n; i++) {
-    aSheets[i] = sheets[i].mSheet;
-  }
-}
-
 void
 nsStyleSet::GatherRuleProcessors(SheetType aType)
 {
   if (mInShutdown) {
     return;
   }
 
   // We might be in GatherRuleProcessors because we are dropping a sheet,
   // resulting in an nsCSSSelector being destroyed.  Tell the
   // RestyleManager for each document we're used in so that they can
   // drop any nsCSSSelector pointers (used for eRestyle_SomeDescendants)
   // in their mPendingRestyles.
   if (IsCSSSheetType(aType)) {
     ClearSelectors();
   }
   nsCOMPtr<nsIStyleRuleProcessor> oldRuleProcessor(mRuleProcessors[aType]);
-  nsTArray<nsCOMPtr<nsIStyleRuleProcessor>> oldScopedDocRuleProcessors;
   if (aType == SheetType::Agent || aType == SheetType::User) {
     // drop reference to cached rule processor
     nsCSSRuleProcessor* rp =
       static_cast<nsCSSRuleProcessor*>(mRuleProcessors[aType].get());
     if (rp) {
       MOZ_ASSERT(rp->IsShared());
       rp->ReleaseStyleSetRef();
     }
   }
   mRuleProcessors[aType] = nullptr;
-  if (aType == SheetType::ScopedDoc) {
-    for (uint32_t i = 0; i < mScopedDocSheetRuleProcessors.Length(); i++) {
-      nsIStyleRuleProcessor* processor = mScopedDocSheetRuleProcessors[i].get();
-      Element* scope =
-        static_cast<nsCSSRuleProcessor*>(processor)->GetScopeElement();
-      scope->ClearIsScopedStyleRoot();
-    }
-
-    // Clear mScopedDocSheetRuleProcessors, but save it.
-    oldScopedDocRuleProcessors.SwapElements(mScopedDocSheetRuleProcessors);
-  }
   if (mAuthorStyleDisabled && (aType == SheetType::Doc ||
-                               aType == SheetType::ScopedDoc ||
                                aType == SheetType::StyleAttr)) {
     // Don't regather if this level is disabled.  Note that we gather
     // preshint sheets no matter what, but then skip them for some
     // elements later if mAuthorStyleDisabled.
     return;
   }
   switch (aType) {
     // levels that do not contain CSS style sheets
@@ -474,73 +378,16 @@ nsStyleSet::GatherRuleProcessors(SheetTy
       mRuleProcessors[aType] =
         PresContext()->Document()->GetAttributeStyleSheet();
       return;
     default:
       // keep going
       break;
   }
   MOZ_ASSERT(IsCSSSheetType(aType));
-  if (aType == SheetType::ScopedDoc) {
-    // Create a rule processor for each scope.
-    uint32_t count = mSheets[SheetType::ScopedDoc].Length();
-    if (count) {
-      // Gather the scoped style sheets into an array as
-      // CSSStyleSheets, and mark all of their scope elements
-      // as scoped style roots.
-      nsTArray<CSSStyleSheet*> sheets(count);
-      for (CSSStyleSheet* sheet : mSheets[SheetType::ScopedDoc]) {
-        sheets.AppendElement(sheet);
-
-        Element* scope = sheet->GetScopeElement();
-        scope->SetIsScopedStyleRoot();
-      }
-
-      // Sort the scoped style sheets so that those for the same scope are
-      // adjacent and that ancestor scopes come before descendent scopes.
-      SortStyleSheetsByScope(sheets);
-
-      // Put the old scoped rule processors in a hashtable so that we
-      // can retrieve them efficiently, even in edge cases like the
-      // simultaneous removal and addition of a large number of elements
-      // with scoped sheets.
-      nsDataHashtable<nsPtrHashKey<Element>,
-                      nsCSSRuleProcessor*> oldScopedRuleProcessorHash;
-      for (size_t i = oldScopedDocRuleProcessors.Length(); i-- != 0; ) {
-        nsCSSRuleProcessor* oldRP =
-          static_cast<nsCSSRuleProcessor*>(oldScopedDocRuleProcessors[i].get());
-        Element* scope = oldRP->GetScopeElement();
-        MOZ_ASSERT(!oldScopedRuleProcessorHash.Get(scope),
-                   "duplicate rule processors for same scope element?");
-        oldScopedRuleProcessorHash.Put(scope, oldRP);
-      }
-
-      uint32_t start = 0, end;
-      do {
-        // Find the range of style sheets with the same scope.
-        Element* scope = sheets[start]->GetScopeElement();
-        end = start + 1;
-        while (end < count && sheets[end]->GetScopeElement() == scope) {
-          end++;
-        }
-
-        scope->SetIsScopedStyleRoot();
-
-        // Create a rule processor for the scope.
-        nsTArray<RefPtr<CSSStyleSheet>> sheetsForScope;
-        sheetsForScope.AppendElements(sheets.Elements() + start, end - start);
-        nsCSSRuleProcessor* oldRP = oldScopedRuleProcessorHash.Get(scope);
-        mScopedDocSheetRuleProcessors.AppendElement
-          (new nsCSSRuleProcessor(Move(sheetsForScope), aType, scope, oldRP));
-
-        start = end;
-      } while (start < count);
-    }
-    return;
-  }
   if (!mSheets[aType].IsEmpty()) {
     switch (aType) {
       case SheetType::Agent:
       case SheetType::User: {
         // levels containing non-scoped CSS style sheets whose rule processors
         // we want to re-use
         nsTArray<CSSStyleSheet*> sheets(mSheets[aType].Length());
         for (CSSStyleSheet* sheet : mSheets[aType]) {
@@ -693,34 +540,31 @@ nsStyleSet::DirtyRuleProcessors(SheetTyp
 
 void
 nsStyleSet::SetAuthorStyleDisabled(bool aStyleDisabled)
 {
   if (aStyleDisabled == !mAuthorStyleDisabled) {
     mAuthorStyleDisabled = aStyleDisabled;
     BeginUpdate();
     mDirty |= DirtyBit(SheetType::Doc) |
-              DirtyBit(SheetType::ScopedDoc) |
               DirtyBit(SheetType::StyleAttr);
     EndUpdate();
   }
 }
 
 // -------- Doc Sheets
 
 nsresult
 nsStyleSet::AddDocStyleSheet(CSSStyleSheet* aSheet, nsIDocument* aDocument)
 {
   NS_PRECONDITION(aSheet && aDocument, "null arg");
   NS_ASSERTION(aSheet->IsApplicable(),
                "Inapplicable sheet being placed in style set");
 
-  SheetType type = aSheet->GetScopeElement() ?
-                     SheetType::ScopedDoc :
-                     SheetType::Doc;
+  SheetType type = SheetType::Doc;
   nsTArray<RefPtr<CSSStyleSheet>>& sheets = mSheets[type];
 
   bool present = sheets.RemoveElement(aSheet);
 
   size_t index = aDocument->FindDocStyleSheetInsertionPoint(sheets, *aSheet);
   sheets.InsertElementAt(index, aSheet);
 
   if (!present) {
@@ -736,19 +580,17 @@ nsStyleSet::AppendAllXBLStyleSheets(nsTA
   if (mBindingManager) {
     mBindingManager->AppendAllSheets(aArray);
   }
 }
 
 nsresult
 nsStyleSet::RemoveDocStyleSheet(CSSStyleSheet* aSheet)
 {
-  bool isScoped = aSheet->GetScopeElement();
-  return RemoveStyleSheet(isScoped ? SheetType::ScopedDoc : SheetType::Doc,
-                          aSheet);
+  return RemoveStyleSheet(SheetType::Doc, aSheet);
 }
 
 // Batching
 void
 nsStyleSet::BeginUpdate()
 {
   ++mBatching;
 }
@@ -1128,35 +970,16 @@ nsStyleSet::FileRules(nsIStyleRuleProces
                                static_cast<ElementDependentRuleProcessorData*>(aData),
                                &cutOffInheritance);
   }
   if (!skipUserStyles && !cutOffInheritance && // NOTE: different
       mRuleProcessors[SheetType::Doc])
     (*aCollectorFunc)(mRuleProcessors[SheetType::Doc], aData);
   nsRuleNode* lastDocRN = aRuleWalker->CurrentNode();
   bool haveImportantDocRules = !aRuleWalker->GetCheckForImportantRules();
-  nsTArray<nsRuleNode*> lastScopedRNs;
-  nsTArray<bool> haveImportantScopedRules;
-  bool haveAnyImportantScopedRules = false;
-  if (!skipUserStyles && !cutOffInheritance &&
-      aElement && aElement->IsElementInStyleScope()) {
-    lastScopedRNs.SetLength(mScopedDocSheetRuleProcessors.Length());
-    haveImportantScopedRules.SetLength(mScopedDocSheetRuleProcessors.Length());
-    for (uint32_t i = 0; i < mScopedDocSheetRuleProcessors.Length(); i++) {
-      aRuleWalker->SetLevel(SheetType::ScopedDoc, false, true);
-      nsCSSRuleProcessor* processor =
-        static_cast<nsCSSRuleProcessor*>(mScopedDocSheetRuleProcessors[i].get());
-      aData->mScope = processor->GetScopeElement();
-      (*aCollectorFunc)(mScopedDocSheetRuleProcessors[i], aData);
-      lastScopedRNs[i] = aRuleWalker->CurrentNode();
-      haveImportantScopedRules[i] = !aRuleWalker->GetCheckForImportantRules();
-      haveAnyImportantScopedRules = haveAnyImportantScopedRules || haveImportantScopedRules[i];
-    }
-    aData->mScope = nullptr;
-  }
   nsRuleNode* lastScopedRN = aRuleWalker->CurrentNode();
   aRuleWalker->SetLevel(SheetType::StyleAttr, false, true);
   if (mRuleProcessors[SheetType::StyleAttr])
     (*aCollectorFunc)(mRuleProcessors[SheetType::StyleAttr], aData);
   nsRuleNode* lastStyleAttrRN = aRuleWalker->CurrentNode();
   bool haveImportantStyleAttrRules = !aRuleWalker->GetCheckForImportantRules();
 
   aRuleWalker->SetLevel(SheetType::Override, false, true);
@@ -1164,37 +987,16 @@ nsStyleSet::FileRules(nsIStyleRuleProces
     (*aCollectorFunc)(mRuleProcessors[SheetType::Override], aData);
   nsRuleNode* lastOvrRN = aRuleWalker->CurrentNode();
   bool haveImportantOverrideRules = !aRuleWalker->GetCheckForImportantRules();
 
   // This needs to match IsMoreSpecificThanAnimation() above.
   aRuleWalker->SetLevel(SheetType::Animation, false, false);
   (*aCollectorFunc)(mRuleProcessors[SheetType::Animation], aData);
 
-  if (haveAnyImportantScopedRules) {
-    for (uint32_t i = lastScopedRNs.Length(); i-- != 0; ) {
-      aRuleWalker->SetLevel(SheetType::ScopedDoc, true, false);
-      nsRuleNode* startRN = lastScopedRNs[i];
-      nsRuleNode* endRN = i == 0 ? lastDocRN : lastScopedRNs[i - 1];
-      if (haveImportantScopedRules[i]) {
-        AddImportantRules(startRN, endRN, aRuleWalker);  // scoped
-      }
-#ifdef DEBUG
-      else {
-        AssertNoImportantRules(startRN, endRN);
-      }
-#endif
-    }
-  }
-#ifdef DEBUG
-  else {
-    AssertNoImportantRules(lastScopedRN, lastDocRN);
-  }
-#endif
-
   if (haveImportantDocRules) {
     aRuleWalker->SetLevel(SheetType::Doc, true, false);
     AddImportantRules(lastDocRN, lastPresHintRN, aRuleWalker);  // doc
   }
 #ifdef DEBUG
   else {
     AssertNoImportantRules(lastDocRN, lastPresHintRN);
   }
@@ -1285,44 +1087,31 @@ nsStyleSet::WalkRuleProcessors(nsIStyleR
       mBindingManager->WalkAllRules(aFunc, aData);
     } else {
       mBindingManager->WalkRules(aFunc, aData, &cutOffInheritance);
     }
   }
   if (!skipUserStyles && !cutOffInheritance) {
     if (mRuleProcessors[SheetType::Doc]) // NOTE: different
       (*aFunc)(mRuleProcessors[SheetType::Doc], aData);
-    if (aData->mElement->IsElementInStyleScope()) {
-      for (uint32_t i = 0; i < mScopedDocSheetRuleProcessors.Length(); i++)
-        (*aFunc)(mScopedDocSheetRuleProcessors[i], aData);
-    }
   }
   if (mRuleProcessors[SheetType::StyleAttr])
     (*aFunc)(mRuleProcessors[SheetType::StyleAttr], aData);
   if (mRuleProcessors[SheetType::Override])
     (*aFunc)(mRuleProcessors[SheetType::Override], aData);
   (*aFunc)(mRuleProcessors[SheetType::Animation], aData);
   (*aFunc)(mRuleProcessors[SheetType::Transition], aData);
 }
 
-static void
-InitStyleScopes(TreeMatchContext& aTreeContext, Element* aElement)
-{
-  if (aElement->IsElementInStyleScope()) {
-    aTreeContext.InitStyleScopes(aElement->GetParentElementCrossingShadowRoot());
-  }
-}
-
 already_AddRefed<GeckoStyleContext>
 nsStyleSet::ResolveStyleFor(Element* aElement,
                             GeckoStyleContext* aParentContext)
 {
   TreeMatchContext treeContext(true, nsRuleWalker::eRelevantLinkUnvisited,
                                aElement->OwnerDoc());
-  InitStyleScopes(treeContext, aElement);
   return ResolveStyleFor(aElement, aParentContext, treeContext);
 }
 
 already_AddRefed<GeckoStyleContext>
 nsStyleSet::ResolveStyleForInternal(Element* aElement,
                                     GeckoStyleContext* aParentContext,
                                     TreeMatchContext& aTreeMatchContext,
                                     AnimationFlag aAnimationFlag)
@@ -1457,22 +1246,20 @@ struct CascadeLevel {
   nsRestyleHint mLevelReplacementHint;
 };
 
 static const CascadeLevel gCascadeLevels[] = {
   { SheetType::Agent,            false, false, nsRestyleHint(0) },
   { SheetType::User,             false, false, nsRestyleHint(0) },
   { SheetType::PresHint,         false, false, nsRestyleHint(0) },
   { SheetType::Doc,              false, false, nsRestyleHint(0) },
-  { SheetType::ScopedDoc,        false, false, nsRestyleHint(0) },
   { SheetType::StyleAttr,        false, true,  eRestyle_StyleAttribute |
                                                eRestyle_StyleAttribute_Animations },
   { SheetType::Override,         false, false, nsRestyleHint(0) },
   { SheetType::Animation,        false, false, eRestyle_CSSAnimations },
-  { SheetType::ScopedDoc,        true,  false, nsRestyleHint(0) },
   { SheetType::Doc,              true,  false, nsRestyleHint(0) },
   { SheetType::StyleAttr,        true,  false, eRestyle_StyleAttribute |
                                                eRestyle_StyleAttribute_Animations },
   { SheetType::Override,         true,  false, nsRestyleHint(0) },
   { SheetType::User,             true,  false, nsRestyleHint(0) },
   { SheetType::Agent,            true,  false, nsRestyleHint(0) },
   { SheetType::Transition,       false, false, eRestyle_CSSTransitions },
 };
@@ -1819,17 +1606,16 @@ already_AddRefed<GeckoStyleContext>
 nsStyleSet::ResolveStyleWithoutAnimation(Element* aTarget,
                                          GeckoStyleContext* aParentContext)
 {
   GeckoRestyleManager* restyleManager =
     PresContext()->RestyleManager()->AsGecko();
 
   TreeMatchContext treeContext(true, nsRuleWalker::eRelevantLinkUnvisited,
                                aTarget->OwnerDoc());
-  InitStyleScopes(treeContext, aTarget);
 
   bool oldSkipAnimationRules = restyleManager->SkipAnimationRules();
   restyleManager->SetSkipAnimationRules(true);
 
   // Here we can call ResolveStyleForInternal() instead of
   // ResolveStyleWithReplacement() since we don't need any animation rules
   // (CSS Animations, Transitions and script animations). That's because
   // EffectCompositor::GetAnimationRule() skips all of animations rules if
@@ -1915,17 +1701,16 @@ nsStyleSet::ResolvePseudoElementStyleInt
 
   NS_ASSERTION(aType < CSSPseudoElementType::Count,
                "must have pseudo element type");
   NS_ASSERTION(aParentElement, "Must have parent element");
 
   nsRuleWalker ruleWalker(mRuleTree, mAuthorStyleDisabled);
   TreeMatchContext treeContext(true, nsRuleWalker::eRelevantLinkUnvisited,
                                aParentElement->OwnerDoc());
-  InitStyleScopes(treeContext, aParentElement);
   PseudoElementRuleProcessorData data(PresContext(), aParentElement,
                                       &ruleWalker, aType, treeContext,
                                       aPseudoElement);
   WalkRestrictionRule(aType, &ruleWalker);
   FileRules(EnumRulesMatching<PseudoElementRuleProcessorData>, &data,
             aParentElement, &ruleWalker);
 
   nsRuleNode *ruleNode = ruleWalker.CurrentNode();
@@ -1990,17 +1775,16 @@ nsStyleSet::ResolvePseudoElementStyleWit
 
 already_AddRefed<GeckoStyleContext>
 nsStyleSet::ProbePseudoElementStyle(Element* aParentElement,
                                     CSSPseudoElementType aType,
                                     GeckoStyleContext* aParentContext)
 {
   TreeMatchContext treeContext(true, nsRuleWalker::eRelevantLinkUnvisited,
                                aParentElement->OwnerDoc());
-  InitStyleScopes(treeContext, aParentElement);
   return ProbePseudoElementStyle(aParentElement, aType, aParentContext,
                                  treeContext);
 }
 
 already_AddRefed<GeckoStyleContext>
 nsStyleSet::ProbePseudoElementStyle(Element* aParentElement,
                                     CSSPseudoElementType aType,
                                     GeckoStyleContext* aParentContext,
@@ -2175,17 +1959,16 @@ nsStyleSet::ResolveXULTreePseudoStyle(El
 
   NS_ASSERTION(aPseudoTag, "must have pseudo tag");
   NS_ASSERTION(nsCSSAnonBoxes::IsTreePseudoElement(aPseudoTag),
                "Unexpected pseudo");
 
   nsRuleWalker ruleWalker(mRuleTree, mAuthorStyleDisabled);
   TreeMatchContext treeContext(true, nsRuleWalker::eRelevantLinkUnvisited,
                                aParentElement->OwnerDoc());
-  InitStyleScopes(treeContext, aParentElement);
   XULTreeRuleProcessorData data(PresContext(), aParentElement, &ruleWalker,
                                 aPseudoTag, aInputWord, treeContext);
   FileRules(EnumRulesMatching<XULTreeRuleProcessorData>, &data, aParentElement,
             &ruleWalker);
 
   nsRuleNode *ruleNode = ruleWalker.CurrentNode();
   nsRuleNode *visitedRuleNode = nullptr;
 
@@ -2208,36 +1991,32 @@ nsStyleSet::ResolveXULTreePseudoStyle(El
 bool
 nsStyleSet::AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray)
 {
   NS_ENSURE_FALSE(mInShutdown, false);
   NS_ASSERTION(mBatching == 0, "rule processors out of date");
 
   nsPresContext* presContext = PresContext();
   for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) {
-    if (gCSSSheetTypes[i] == SheetType::ScopedDoc)
-      continue;
     nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*>
                                     (mRuleProcessors[gCSSSheetTypes[i]].get());
     if (ruleProc && !ruleProc->AppendFontFaceRules(presContext, aArray))
       return false;
   }
   return true;
 }
 
 nsCSSKeyframesRule*
 nsStyleSet::KeyframesRuleForName(nsAtom* aName)
 {
   NS_ENSURE_FALSE(mInShutdown, nullptr);
   NS_ASSERTION(mBatching == 0, "rule processors out of date");
 
   nsPresContext* presContext = PresContext();
   for (uint32_t i = ArrayLength(gCSSSheetTypes); i-- != 0; ) {
-    if (gCSSSheetTypes[i] == SheetType::ScopedDoc)
-      continue;
     nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*>
                                     (mRuleProcessors[gCSSSheetTypes[i]].get());
     if (!ruleProc)
       continue;
     nsCSSKeyframesRule* result =
       ruleProc->KeyframesRuleForName(presContext, aName);
     if (result)
       return result;
@@ -2248,18 +2027,16 @@ nsStyleSet::KeyframesRuleForName(nsAtom*
 nsCSSCounterStyleRule*
 nsStyleSet::CounterStyleRuleForName(nsAtom* aName)
 {
   NS_ENSURE_FALSE(mInShutdown, nullptr);
   NS_ASSERTION(mBatching == 0, "rule processors out of date");
 
   nsPresContext* presContext = PresContext();
   for (uint32_t i = ArrayLength(gCSSSheetTypes); i-- != 0; ) {
-    if (gCSSSheetTypes[i] == SheetType::ScopedDoc)
-      continue;
     nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*>
                                     (mRuleProcessors[gCSSSheetTypes[i]].get());
     if (!ruleProc)
       continue;
     nsCSSCounterStyleRule *result =
       ruleProc->CounterStyleRuleForName(presContext, aName);
     if (result)
       return result;
@@ -2313,18 +2090,16 @@ nsStyleSet::AppendFontFeatureValuesRules
 bool
 nsStyleSet::AppendPageRules(nsTArray<nsCSSPageRule*>& aArray)
 {
   NS_ENSURE_FALSE(mInShutdown, false);
   NS_ASSERTION(mBatching == 0, "rule processors out of date");
 
   nsPresContext* presContext = PresContext();
   for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) {
-    if (gCSSSheetTypes[i] == SheetType::ScopedDoc)
-      continue;
     nsCSSRuleProcessor* ruleProc = static_cast<nsCSSRuleProcessor*>
                                     (mRuleProcessors[gCSSSheetTypes[i]].get());
     if (ruleProc && !ruleProc->AppendPageRules(presContext, aArray))
       return false;
   }
   return true;
 }
 
@@ -2350,21 +2125,16 @@ void
 nsStyleSet::SheetChanged(CSSStyleSheet& aStyleSheet)
 {
   MOZ_ASSERT(mBatching != 0, "Should be in an update");
 
   if (mStylesHaveChanged) {
     return;
   }
 
-  if (Element* scopeElement = aStyleSheet.GetScopeElement()) {
-    mChangedScopeStyleRoots.AppendElement(scopeElement);
-    return;
-  }
-
   mStylesHaveChanged = true;
   // If we need to restyle everything, no need to restyle individual
   // scoped style roots.
   mChangedScopeStyleRoots.Clear();
 }
 
 void
 nsStyleSet::RecordShadowStyleChange(ShadowRoot& aShadowRoot)
@@ -2540,17 +2310,16 @@ bool
 nsStyleSet::HasDocumentStateDependentStyle(nsIContent*    aContent,
                                            EventStates    aStateMask)
 {
   if (!aContent || !aContent->IsElement())
     return false;
 
   TreeMatchContext treeContext(false, nsRuleWalker::eLinksVisitedOrUnvisited,
                                aContent->OwnerDoc());
-  InitStyleScopes(treeContext, aContent->AsElement());
   StatefulData data(PresContext(), aContent->AsElement(), aStateMask,
                     treeContext);
   WalkRuleProcessors(SheetHasDocumentStateStyle, &data, true);
   return data.mHint != 0;
 }
 
 static bool SheetHasStatefulStyle(nsIStyleRuleProcessor* aProcessor,
                                     void *aData)
@@ -2572,31 +2341,29 @@ static bool SheetHasStatefulPseudoElemen
 
 // Test if style is dependent on content state
 nsRestyleHint
 nsStyleSet::HasStateDependentStyle(Element*             aElement,
                                    EventStates          aStateMask)
 {
   TreeMatchContext treeContext(false, nsRuleWalker::eLinksVisitedOrUnvisited,
                                aElement->OwnerDoc());
-  InitStyleScopes(treeContext, aElement);
   StatefulData data(PresContext(), aElement, aStateMask, treeContext);
   WalkRuleProcessors(SheetHasStatefulStyle, &data, false);
   return data.mHint;
 }
 
 nsRestyleHint
 nsStyleSet::HasStateDependentStyle(Element* aElement,
                                    CSSPseudoElementType aPseudoType,
                                    Element* aPseudoElement,
                                    EventStates aStateMask)
 {
   TreeMatchContext treeContext(false, nsRuleWalker::eLinksVisitedOrUnvisited,
                                aElement->OwnerDoc());
-  InitStyleScopes(treeContext, aElement);
   StatefulPseudoElementData data(PresContext(), aElement, aStateMask,
                                  aPseudoType, treeContext, aPseudoElement);
   WalkRuleProcessors(SheetHasStatefulPseudoElementStyle, &data, false);
   return data.mHint;
 }
 
 struct MOZ_STACK_CLASS AttributeData : public AttributeRuleProcessorData {
   AttributeData(nsPresContext* aPresContext, Element* aElement,
@@ -2630,17 +2397,16 @@ nsStyleSet::HasAttributeDependentStyle(E
                                        int32_t        aModType,
                                        bool           aAttrHasChanged,
                                        const nsAttrValue* aOtherValue,
                                        mozilla::RestyleHintData&
                                          aRestyleHintDataResult)
 {
   TreeMatchContext treeContext(false, nsRuleWalker::eLinksVisitedOrUnvisited,
                                aElement->OwnerDoc());
-  InitStyleScopes(treeContext, aElement);
   AttributeData data(PresContext(), aElement, aNameSpaceID, aAttribute,
                      aModType, aAttrHasChanged, aOtherValue, treeContext);
   WalkRuleProcessors(SheetHasAttributeStyle, &data, false);
   if (!(data.mHint & eRestyle_Subtree)) {
     // No point keeping the list of selectors around if we are going to
     // restyle the whole subtree unconditionally.
     aRestyleHintDataResult = Move(data.mHintData);
   }
@@ -2657,20 +2423,16 @@ nsStyleSet::MediumFeaturesChanged(mozill
   bool stylesChanged = false;
   for (nsIStyleRuleProcessor* processor : mRuleProcessors) {
     if (!processor) {
       continue;
     }
     bool thisChanged = processor->MediumFeaturesChanged(presContext);
     stylesChanged = stylesChanged || thisChanged;
   }
-  for (nsIStyleRuleProcessor* processor : mScopedDocSheetRuleProcessors) {
-    bool thisChanged = processor->MediumFeaturesChanged(presContext);
-    stylesChanged = stylesChanged || thisChanged;
-  }
 
   if (mBindingManager) {
     bool thisChanged =
       mBindingManager->MediumFeaturesChanged(presContext, aReason);
     stylesChanged = stylesChanged || thisChanged;
   }
 
   if (stylesChanged) {
--- a/layout/style/nsStyleSet.h
+++ b/layout/style/nsStyleSet.h
@@ -425,17 +425,17 @@ class nsStyleSet final
   nsresult RemoveStyleSheet(mozilla::SheetType aType,
                             mozilla::CSSStyleSheet* aSheet);
   nsresult ReplaceSheets(mozilla::SheetType aType,
                          const nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aNewSheets);
   nsresult InsertStyleSheetBefore(mozilla::SheetType aType,
                                   mozilla::CSSStyleSheet* aNewSheet,
                                   mozilla::CSSStyleSheet* aReferenceSheet);
 
-  // Enable/Disable entire author style level (Doc, ScopedDoc & PresHint levels)
+  // Enable/Disable entire author style level (Doc & PresHint levels)
   bool GetAuthorStyleDisabled() const
   {
     return mAuthorStyleDisabled;
   }
 
   void SetAuthorStyleDisabled(bool aStyleDisabled);
 
   int32_t SheetCount(mozilla::SheetType aType) const {
@@ -617,24 +617,19 @@ private:
   // The sheets in each array in mSheets are stored with the most significant
   // sheet last.
   // The arrays for ePresHintSheet, eStyleAttrSheet, eTransitionSheet,
   // eAnimationSheet are always empty.
   // (FIXME:  We should reduce the storage needed for them.)
   mozilla::EnumeratedArray<mozilla::SheetType, mozilla::SheetType::Count,
                            nsTArray<RefPtr<mozilla::CSSStyleSheet>>> mSheets;
 
-  // mRuleProcessors[eScopedDocSheet] is always null; rule processors
-  // for scoped style sheets are stored in mScopedDocSheetRuleProcessors.
   mozilla::EnumeratedArray<mozilla::SheetType, mozilla::SheetType::Count,
                            nsCOMPtr<nsIStyleRuleProcessor>> mRuleProcessors;
 
-  // Rule processors for HTML5 scoped style sheets, one per scope.
-  nsTArray<nsCOMPtr<nsIStyleRuleProcessor> > mScopedDocSheetRuleProcessors;
-
   RefPtr<nsBindingManager> mBindingManager;
 
   RefPtr<nsRuleNode> mRuleTree; // This is the root of our rule tree.  It is a
                                 // lexicographic tree of matched rules that style
                                 // contexts use to look up properties.
 
   // List of subtrees rooted at style scope roots that need to be restyled.
   // When a change to a scoped style sheet is made, we add the style scope
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -3069,22 +3069,16 @@ pref("layout.css.prefixes.gradients", tr
 // Are webkit-prefixed properties & property-values supported?
 pref("layout.css.prefixes.webkit", true);
 
 // Are "-webkit-{min|max}-device-pixel-ratio" media queries supported?
 // (Note: this pref has no effect if the master 'layout.css.prefixes.webkit'
 // pref is set to false.)
 pref("layout.css.prefixes.device-pixel-ratio-webkit", false);
 
-// Is support for <style scoped> enabled in content documents?
-//
-// If disabled, this will also disable the DOM API (HTMLStyleElement.scoped)
-// in chrome documents.
-pref("layout.css.scoped-style.enabled", false);
-
 // Is support for the :scope selector enabled?
 pref("layout.css.scope-pseudo.enabled", true);
 
 // Is support for background-blend-mode enabled?
 pref("layout.css.background-blend-mode.enabled", true);
 
 // Is support for CSS text-combine-upright (tate-chu-yoko) enabled?
 pref("layout.css.text-combine-upright.enabled", true);