Bug 1449806: Introduce MappedDeclarations. r?xidorn draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 22 Jun 2018 18:48:42 +0200
changeset 809656 30777d1ae2d442407eb291fc7d4e54cf9c7980dd
parent 809655 54b5db87eb7e86b8f05c9e94c8e2353b87e78403
child 809657 75353a8cc6fc85b006fb76f9f99d7f4d72c2b1b6
push id113755
push userbmo:emilio@crisal.io
push dateFri, 22 Jun 2018 17:38:23 +0000
reviewersxidorn
bugs1449806
milestone62.0a1
Bug 1449806: Introduce MappedDeclarations. r?xidorn The idea would be that this header is only included in cpp files, thus it's ok to include ServoBindings, etc. MozReview-Commit-ID: EgQEsR0cZd4
dom/base/nsMappedAttributes.cpp
layout/style/GenericSpecifiedValues.h
layout/style/GenericSpecifiedValuesInlines.h
layout/style/MappedDeclarations.cpp
layout/style/MappedDeclarations.h
layout/style/ServoSpecifiedValues.cpp
layout/style/ServoSpecifiedValues.h
layout/style/moz.build
--- a/dom/base/nsMappedAttributes.cpp
+++ b/dom/base/nsMappedAttributes.cpp
@@ -306,13 +306,14 @@ nsMappedAttributes::SizeOfIncludingThis(
 
 void
 nsMappedAttributes::LazilyResolveServoDeclaration(nsIDocument* aDoc)
 {
 
   MOZ_ASSERT(!mServoStyle,
              "LazilyResolveServoDeclaration should not be called if mServoStyle is already set");
   if (mRuleMapper) {
-    mServoStyle = Servo_DeclarationBlock_CreateEmpty().Consume();
-    ServoSpecifiedValues servo = ServoSpecifiedValues(aDoc, mServoStyle.get());
-    (*mRuleMapper)(this, &servo);
+    MappedDeclarations declarations(
+      aDoc, Servo_DeclarationBlock_CreateEmpty().Consume());
+    (*mRuleMapper)(this, declarations);
+    mServoStyle = declarations.TakeDeclarationBlock();
   }
 }
deleted file mode 100644
--- a/layout/style/GenericSpecifiedValues.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Generic representation of a container of specified CSS values, which
- * could potentially be Servo- or Gecko- format. Used to make attribute mapping
- * code generic over style backends.
- */
-
-#ifndef mozilla_GenericSpecifiedValues_h
-#define mozilla_GenericSpecifiedValues_h
-
-#include "mozilla/ServoUtils.h"
-#include "mozilla/FontPropertyTypes.h"
-#include "nsCSSPropertyID.h"
-#include "nsCSSValue.h"
-#include "nsColor.h"
-
-class nsAttrValue;
-
-namespace mozilla {
-
-class ServoSpecifiedValues;
-
-// This provides a common interface for attribute mappers
-// (MapAttributesIntoRule) to use regardless of the style backend. If the style
-// backend is Gecko, this will contain an nsRuleData. If it is Servo, it will be
-// a PropertyDeclarationBlock.
-class GenericSpecifiedValues
-{
-protected:
-  explicit GenericSpecifiedValues(nsIDocument* aDoc)
-    : mDocument(aDoc)
-  {}
-
-public:
-  MOZ_DECL_STYLO_METHODS(nsRuleData, ServoSpecifiedValues)
-
-  nsIDocument* Document()
-  {
-    return mDocument;
-  }
-
-  // Check if we already contain a certain longhand
-  inline bool PropertyIsSet(nsCSSPropertyID aId);
-
-  // Set a property to an identifier (string)
-  inline void SetIdentStringValue(nsCSSPropertyID aId, const nsString& aValue);
-  inline void SetIdentStringValueIfUnset(nsCSSPropertyID aId,
-                                         const nsString& aValue);
-
-  inline void SetIdentAtomValue(nsCSSPropertyID aId, nsAtom* aValue);
-  inline void SetIdentAtomValueIfUnset(nsCSSPropertyID aId, nsAtom* aValue);
-
-  // Set a property to a keyword (usually NS_STYLE_* or StyleFoo::*)
-  inline void SetKeywordValue(nsCSSPropertyID aId, int32_t aValue);
-  inline void SetKeywordValueIfUnset(nsCSSPropertyID aId, int32_t aValue);
-
-  template<typename T,
-           typename = typename std::enable_if<std::is_enum<T>::value>::type>
-  void SetKeywordValue(nsCSSPropertyID aId, T aValue)
-  {
-    static_assert(mozilla::EnumTypeFitsWithin<T, int32_t>::value,
-                  "aValue must be an enum that fits within 32 bits");
-    SetKeywordValue(aId, static_cast<int32_t>(aValue));
-  }
-  template<typename T,
-           typename = typename std::enable_if<std::is_enum<T>::value>::type>
-  void SetKeywordValueIfUnset(nsCSSPropertyID aId, T aValue)
-  {
-    static_assert(mozilla::EnumTypeFitsWithin<T, int32_t>::value,
-                  "aValue must be an enum that fits within 32 bits");
-    SetKeywordValueIfUnset(aId, static_cast<int32_t>(aValue));
-  }
-
-  // Set a property to an integer value
-  inline void SetIntValue(nsCSSPropertyID aId, int32_t aValue);
-  // Set a property to a pixel value
-  inline void SetPixelValue(nsCSSPropertyID aId, float aValue);
-  inline void SetPixelValueIfUnset(nsCSSPropertyID aId, float aValue);
-
-  inline void SetLengthValue(nsCSSPropertyID aId, nsCSSValue aValue);
-
-  // Set a property to a number value
-  inline void SetNumberValue(nsCSSPropertyID aId, float aValue);
-
-  // Set a property to a percent value
-  inline void SetPercentValue(nsCSSPropertyID aId, float aValue);
-  inline void SetPercentValueIfUnset(nsCSSPropertyID aId, float aValue);
-
-  // Set a property to `auto`
-  inline void SetAutoValue(nsCSSPropertyID aId);
-  inline void SetAutoValueIfUnset(nsCSSPropertyID aId);
-
-  // Set a property to `currentcolor`
-  inline void SetCurrentColor(nsCSSPropertyID aId);
-  inline void SetCurrentColorIfUnset(nsCSSPropertyID aId);
-
-  // Set a property to an RGBA nscolor value
-  inline void SetColorValue(nsCSSPropertyID aId, nscolor aValue);
-  inline void SetColorValueIfUnset(nsCSSPropertyID aId, nscolor aValue);
-
-  // Set font-family to a string
-  inline void SetFontFamily(const nsString& aValue);
-  // Add a quirks-mode override to the decoration color of elements nested in <a>
-  inline void SetTextDecorationColorOverride();
-  inline void SetBackgroundImage(nsAttrValue& value);
-
-  nsIDocument* const mDocument;
-};
-
-} // namespace mozilla
-
-#endif // mozilla_GenericSpecifiedValues_h
deleted file mode 100644
--- a/layout/style/GenericSpecifiedValuesInlines.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Inlined methods for GenericSpecifiedValues. Will just redirect to
- * nsRuleData methods when compiled without stylo, but will do
- * virtual dispatch (by checking which kind of container it is)
- * in stylo mode.
- */
-
-#ifndef mozilla_GenericSpecifiedValuesInlines_h
-#define mozilla_GenericSpecifiedValuesInlines_h
-
-#include "mozilla/GenericSpecifiedValues.h"
-#include "mozilla/ServoSpecifiedValues.h"
-
-namespace mozilla {
-
-MOZ_DEFINE_STYLO_METHODS(GenericSpecifiedValues,
-                         nsRuleData,
-                         ServoSpecifiedValues)
-
-bool
-GenericSpecifiedValues::PropertyIsSet(nsCSSPropertyID aId)
-{
-  MOZ_STYLO_FORWARD(PropertyIsSet, (aId))
-}
-
-void
-GenericSpecifiedValues::SetIdentStringValue(nsCSSPropertyID aId,
-                                            const nsString& aValue)
-{
-  MOZ_STYLO_FORWARD(SetIdentStringValue, (aId, aValue))
-}
-
-void
-GenericSpecifiedValues::SetIdentStringValueIfUnset(nsCSSPropertyID aId,
-                                                   const nsString& aValue)
-{
-  if (!PropertyIsSet(aId)) {
-    SetIdentStringValue(aId, aValue);
-  }
-}
-
-void
-GenericSpecifiedValues::SetIdentAtomValue(nsCSSPropertyID aId, nsAtom* aValue)
-{
-  MOZ_STYLO_FORWARD(SetIdentAtomValue, (aId, aValue))
-}
-
-void
-GenericSpecifiedValues::SetIdentAtomValueIfUnset(nsCSSPropertyID aId,
-                                                 nsAtom* aValue)
-{
-  if (!PropertyIsSet(aId)) {
-    SetIdentAtomValue(aId, aValue);
-  }
-}
-
-void
-GenericSpecifiedValues::SetKeywordValue(nsCSSPropertyID aId, int32_t aValue)
-{
-
-  return AsServo()->SetKeywordValue(aId, aValue);
-}
-
-void
-GenericSpecifiedValues::SetKeywordValueIfUnset(nsCSSPropertyID aId,
-                                               int32_t aValue)
-{
-  if (!PropertyIsSet(aId)) {
-    SetKeywordValue(aId, aValue);
-  }
-}
-
-void
-GenericSpecifiedValues::SetIntValue(nsCSSPropertyID aId, int32_t aValue)
-{
-  MOZ_STYLO_FORWARD(SetIntValue, (aId, aValue))
-}
-
-void
-GenericSpecifiedValues::SetPixelValue(nsCSSPropertyID aId, float aValue)
-{
-  MOZ_STYLO_FORWARD(SetPixelValue, (aId, aValue))
-}
-
-void
-GenericSpecifiedValues::SetPixelValueIfUnset(nsCSSPropertyID aId, float aValue)
-{
-  if (!PropertyIsSet(aId)) {
-    SetPixelValue(aId, aValue);
-  }
-}
-
-void
-GenericSpecifiedValues::SetLengthValue(nsCSSPropertyID aId, nsCSSValue aValue)
-{
-  MOZ_STYLO_FORWARD(SetLengthValue, (aId, aValue))
-}
-
-void
-GenericSpecifiedValues::SetNumberValue(nsCSSPropertyID aId, float aValue)
-{
-  MOZ_STYLO_FORWARD(SetNumberValue, (aId, aValue))
-}
-
-void
-GenericSpecifiedValues::SetPercentValue(nsCSSPropertyID aId, float aValue)
-{
-  MOZ_STYLO_FORWARD(SetPercentValue, (aId, aValue))
-}
-
-void
-GenericSpecifiedValues::SetPercentValueIfUnset(nsCSSPropertyID aId,
-                                               float aValue)
-{
-  if (!PropertyIsSet(aId)) {
-    SetPercentValue(aId, aValue);
-  }
-}
-
-void
-GenericSpecifiedValues::SetAutoValue(nsCSSPropertyID aId)
-{
-  MOZ_STYLO_FORWARD(SetAutoValue, (aId))
-}
-
-void
-GenericSpecifiedValues::SetAutoValueIfUnset(nsCSSPropertyID aId)
-{
-  if (!PropertyIsSet(aId)) {
-    SetAutoValue(aId);
-  }
-}
-
-void
-GenericSpecifiedValues::SetCurrentColor(nsCSSPropertyID aId)
-{
-  MOZ_STYLO_FORWARD(SetCurrentColor, (aId))
-}
-
-void
-GenericSpecifiedValues::SetCurrentColorIfUnset(nsCSSPropertyID aId)
-{
-  if (!PropertyIsSet(aId)) {
-    SetCurrentColor(aId);
-  }
-}
-
-void
-GenericSpecifiedValues::SetColorValue(nsCSSPropertyID aId, nscolor aValue)
-{
-  MOZ_STYLO_FORWARD(SetColorValue, (aId, aValue))
-}
-
-void
-GenericSpecifiedValues::SetColorValueIfUnset(nsCSSPropertyID aId,
-                                             nscolor aValue)
-{
-  if (!PropertyIsSet(aId)) {
-    SetColorValue(aId, aValue);
-  }
-}
-
-void
-GenericSpecifiedValues::SetFontFamily(const nsString& aValue)
-{
-  MOZ_STYLO_FORWARD(SetFontFamily, (aValue))
-}
-
-void
-GenericSpecifiedValues::SetTextDecorationColorOverride()
-{
-  MOZ_STYLO_FORWARD(SetTextDecorationColorOverride, ())
-}
-
-void
-GenericSpecifiedValues::SetBackgroundImage(nsAttrValue& aValue)
-{
-  MOZ_STYLO_FORWARD(SetBackgroundImage, (aValue))
-}
-
-} // namespace mozilla
-
-#endif // mozilla_GenericSpecifiedValuesInlines_h
new file mode 100644
--- /dev/null
+++ b/layout/style/MappedDeclarations.cpp
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "MappedDeclarations.h"
+
+namespace mozilla {
+
+void
+MappedDeclarations::SetIdentAtomValue(nsCSSPropertyID aId, nsAtom* aValue)
+{
+  Servo_DeclarationBlock_SetIdentStringValue(mDecl, aId, aValue);
+  if (aId == eCSSProperty__x_lang) {
+    // This forces the lang prefs result to be cached so that we can access them
+    // off main thread during traversal.
+    //
+    // FIXME(emilio): Can we move mapped attribute declarations across
+    // documents? Isn't this wrong in that case? This is pretty out of place
+    // anyway.
+    if (nsPresContext* pc = mDocument->GetPresContext()) {
+      pc->ForceCacheLang(aValue);
+    }
+  }
+}
+
+void
+MappedDeclarations::SetBackgroundImage(const nsAttrValue& aValue)
+{
+  if (aValue.Type() != nsAttrValue::eURL) {
+    return;
+  }
+  // FIXME(emilio): Going through URL parsing again seems slightly wasteful.
+  nsAutoString str;
+  aValue.ToString(str);
+  Servo_DeclarationBlock_SetBackgroundImage(
+    mDecl, str, mDocument->DefaultStyleAttrURLData());
+}
+
+
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/layout/style/MappedDeclarations.h
@@ -0,0 +1,210 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Representation of a declaration block used for attribute mapping */
+
+#ifndef mozilla_MappedDeclarations_h
+#define mozilla_MappedDeclarations_h
+
+#include "mozilla/FontPropertyTypes.h"
+#include "mozilla/ServoBindingTypes.h"
+#include "mozilla/ServoBindings.h"
+#include "nsCSSPropertyID.h"
+#include "nsCSSValue.h"
+#include "nsColor.h"
+
+class nsAttrValue;
+
+namespace mozilla {
+
+// This provides a common interface for attribute mappers
+// (MapAttributesIntoRule) to use regardless of the style backend. If the style
+// backend is Gecko, this will contain an nsRuleData. If it is Servo, it will be
+// a PropertyDeclarationBlock.
+class MappedDeclarations final
+{
+public:
+  explicit MappedDeclarations(nsIDocument* aDoc,
+                              already_AddRefed<RawServoDeclarationBlock> aDecls)
+    : mDocument(aDoc)
+    , mDecl(aDecls)
+  {}
+
+  nsIDocument* Document()
+  {
+    return mDocument;
+  }
+
+  already_AddRefed<RawServoDeclarationBlock> TakeDeclarationBlock()
+  {
+    return mDecl.forget();
+  }
+
+  // Check if we already contain a certain longhand
+  bool PropertyIsSet(nsCSSPropertyID aId) const
+  {
+    return Servo_DeclarationBlock_PropertyIsSet(mDecl, aId);
+  }
+
+  // Set a property to an identifier (string)
+  void SetIdentStringValue(nsCSSPropertyID aId, const nsString& aValue)
+  {
+    RefPtr<nsAtom> atom = NS_AtomizeMainThread(aValue);
+    SetIdentAtomValue(aId, atom);
+  }
+
+  void SetIdentStringValueIfUnset(nsCSSPropertyID aId, const nsString& aValue)
+  {
+    if (!PropertyIsSet(aId)) {
+      SetIdentStringValue(aId, aValue);
+    }
+  }
+
+  void SetIdentAtomValue(nsCSSPropertyID aId, nsAtom* aValue);
+
+  void SetIdentAtomValueIfUnset(nsCSSPropertyID aId, nsAtom* aValue)
+  {
+    if (!PropertyIsSet(aId)) {
+      SetIdentAtomValue(aId, aValue);
+    }
+  }
+
+  // Set a property to a keyword (usually NS_STYLE_* or StyleFoo::*)
+  void SetKeywordValue(nsCSSPropertyID aId, int32_t aValue)
+  {
+    Servo_DeclarationBlock_SetKeywordValue(mDecl, aId, aValue);
+  }
+
+  void SetKeywordValueIfUnset(nsCSSPropertyID aId, int32_t aValue)
+  {
+    if (!PropertyIsSet(aId)) {
+      SetKeywordValue(aId, aValue);
+    }
+  }
+
+  template<typename T,
+           typename = typename std::enable_if<std::is_enum<T>::value>::type>
+  void SetKeywordValue(nsCSSPropertyID aId, T aValue)
+  {
+    static_assert(mozilla::EnumTypeFitsWithin<T, int32_t>::value,
+                  "aValue must be an enum that fits within 32 bits");
+    SetKeywordValue(aId, static_cast<int32_t>(aValue));
+  }
+  template<typename T,
+           typename = typename std::enable_if<std::is_enum<T>::value>::type>
+  void SetKeywordValueIfUnset(nsCSSPropertyID aId, T aValue)
+  {
+    static_assert(mozilla::EnumTypeFitsWithin<T, int32_t>::value,
+                  "aValue must be an enum that fits within 32 bits");
+    SetKeywordValueIfUnset(aId, static_cast<int32_t>(aValue));
+  }
+
+  // Set a property to an integer value
+  void SetIntValue(nsCSSPropertyID aId, int32_t aValue)
+  {
+    Servo_DeclarationBlock_SetIntValue(mDecl, aId, aValue);
+  }
+
+  // Set a property to a pixel value
+  void SetPixelValue(nsCSSPropertyID aId, float aValue)
+  {
+    Servo_DeclarationBlock_SetPixelValue(mDecl, aId, aValue);
+  }
+
+  void SetPixelValueIfUnset(nsCSSPropertyID aId, float aValue)
+  {
+    if (!PropertyIsSet(aId)) {
+      SetPixelValue(aId, aValue);
+    }
+  }
+
+  void SetLengthValue(nsCSSPropertyID aId, const nsCSSValue& aValue)
+  {
+    MOZ_ASSERT(aValue.IsLengthUnit());
+    Servo_DeclarationBlock_SetLengthValue(
+      mDecl, aId, aValue.GetFloatValue(), aValue.GetUnit());
+  }
+
+  // Set a property to a number value
+  void SetNumberValue(nsCSSPropertyID aId, float aValue)
+  {
+    Servo_DeclarationBlock_SetNumberValue(mDecl, aId, aValue);
+  }
+
+  // Set a property to a percent value
+  void SetPercentValue(nsCSSPropertyID aId, float aValue)
+  {
+    Servo_DeclarationBlock_SetPercentValue(mDecl, aId, aValue);
+  }
+
+  void SetPercentValueIfUnset(nsCSSPropertyID aId, float aValue)
+  {
+    if (!PropertyIsSet(aId)) {
+      SetPercentValue(aId, aValue);
+    }
+  }
+
+  // Set a property to `auto`
+  void SetAutoValue(nsCSSPropertyID aId)
+  {
+    Servo_DeclarationBlock_SetAutoValue(mDecl, aId);
+  }
+
+  void SetAutoValueIfUnset(nsCSSPropertyID aId)
+  {
+    if (!PropertyIsSet(aId)) {
+      SetAutoValue(aId);
+    }
+  }
+
+  // Set a property to `currentcolor`
+  void SetCurrentColor(nsCSSPropertyID aId)
+  {
+    Servo_DeclarationBlock_SetCurrentColor(mDecl, aId);
+  }
+
+  void SetCurrentColorIfUnset(nsCSSPropertyID aId)
+  {
+    if (!PropertyIsSet(aId)) {
+      SetCurrentColor(aId);
+    }
+  }
+
+  // Set a property to an RGBA nscolor value
+  void SetColorValue(nsCSSPropertyID aId, nscolor aValue)
+  {
+    Servo_DeclarationBlock_SetColorValue(mDecl, aId, aValue);
+  }
+
+  void SetColorValueIfUnset(nsCSSPropertyID aId, nscolor aValue)
+  {
+    if (!PropertyIsSet(aId)) {
+      SetColorValue(aId, aValue);
+    }
+  }
+
+  // Set font-family to a string
+  void SetFontFamily(const nsString& aValue)
+  {
+    Servo_DeclarationBlock_SetFontFamily(mDecl, aValue);
+  }
+
+  // Add a quirks-mode override to the decoration color of elements nested in <a>
+  void SetTextDecorationColorOverride()
+  {
+    Servo_DeclarationBlock_SetTextDecorationColorOverride(mDecl);
+  }
+
+  void SetBackgroundImage(const nsAttrValue& value);
+
+private:
+  nsIDocument* const mDocument;
+  RefPtr<RawServoDeclarationBlock> mDecl;
+};
+
+} // namespace mozilla
+
+#endif
deleted file mode 100644
--- a/layout/style/ServoSpecifiedValues.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "mozilla/ServoBindings.h"
-#include "mozilla/ServoSpecifiedValues.h"
-
-using namespace mozilla;
-
-bool
-ServoSpecifiedValues::PropertyIsSet(nsCSSPropertyID aId)
-{
-  return Servo_DeclarationBlock_PropertyIsSet(mDecl, aId);
-}
-
-void
-ServoSpecifiedValues::SetIdentStringValue(nsCSSPropertyID aId,
-                                          const nsString& aValue)
-{
-  RefPtr<nsAtom> atom = NS_Atomize(aValue);
-  SetIdentAtomValue(aId, atom);
-}
-
-void
-ServoSpecifiedValues::SetIdentAtomValue(nsCSSPropertyID aId, nsAtom* aValue)
-{
-  Servo_DeclarationBlock_SetIdentStringValue(mDecl, aId, aValue);
-  if (aId == eCSSProperty__x_lang) {
-    // This forces the lang prefs result to be cached so that we can access them
-    // off main thread during traversal.
-    //
-    // FIXME(emilio): Can we move mapped attribute declarations across
-    // documents? Isn't this wrong in that case? This is pretty out of place
-    // anyway.
-    if (nsPresContext* pc = mDocument->GetPresContext()) {
-      pc->ForceCacheLang(aValue);
-    }
-  }
-}
-
-void
-ServoSpecifiedValues::SetKeywordValue(nsCSSPropertyID aId, int32_t aValue)
-{
-  Servo_DeclarationBlock_SetKeywordValue(mDecl, aId, aValue);
-}
-
-void
-ServoSpecifiedValues::SetIntValue(nsCSSPropertyID aId, int32_t aValue)
-{
-  Servo_DeclarationBlock_SetIntValue(mDecl, aId, aValue);
-}
-
-void
-ServoSpecifiedValues::SetPixelValue(nsCSSPropertyID aId, float aValue)
-{
-  Servo_DeclarationBlock_SetPixelValue(mDecl, aId, aValue);
-}
-
-void
-ServoSpecifiedValues::SetLengthValue(nsCSSPropertyID aId, nsCSSValue aValue)
-{
-  MOZ_ASSERT(aValue.IsLengthUnit());
-  Servo_DeclarationBlock_SetLengthValue(
-    mDecl, aId, aValue.GetFloatValue(), aValue.GetUnit());
-}
-
-void
-ServoSpecifiedValues::SetNumberValue(nsCSSPropertyID aId, float aValue)
-{
-  Servo_DeclarationBlock_SetNumberValue(mDecl, aId, aValue);
-}
-
-void
-ServoSpecifiedValues::SetPercentValue(nsCSSPropertyID aId, float aValue)
-{
-  Servo_DeclarationBlock_SetPercentValue(mDecl, aId, aValue);
-}
-
-void
-ServoSpecifiedValues::SetAutoValue(nsCSSPropertyID aId)
-{
-  Servo_DeclarationBlock_SetAutoValue(mDecl, aId);
-}
-
-void
-ServoSpecifiedValues::SetCurrentColor(nsCSSPropertyID aId)
-{
-  Servo_DeclarationBlock_SetCurrentColor(mDecl, aId);
-}
-
-void
-ServoSpecifiedValues::SetColorValue(nsCSSPropertyID aId, nscolor aColor)
-{
-  Servo_DeclarationBlock_SetColorValue(mDecl, aId, aColor);
-}
-
-void
-ServoSpecifiedValues::SetFontFamily(const nsString& aValue)
-{
-  Servo_DeclarationBlock_SetFontFamily(mDecl, aValue);
-}
-
-void
-ServoSpecifiedValues::SetTextDecorationColorOverride()
-{
-  Servo_DeclarationBlock_SetTextDecorationColorOverride(mDecl);
-}
-
-void
-ServoSpecifiedValues::SetBackgroundImage(nsAttrValue& aValue)
-{
-  if (aValue.Type() != nsAttrValue::eURL) {
-    return;
-  }
-  nsAutoString str;
-  aValue.ToString(str);
-  Servo_DeclarationBlock_SetBackgroundImage(
-    mDecl, str, mDocument->DefaultStyleAttrURLData());
-}
deleted file mode 100644
--- a/layout/style/ServoSpecifiedValues.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Servo-backed specified value store, to be used when mapping presentation
- * attributes
- */
-
-#ifndef mozilla_ServoSpecifiedValues_h
-#define mozilla_ServoSpecifiedValues_h
-
-#include "mozilla/GenericSpecifiedValues.h"
-#include "mozilla/ServoBindingTypes.h"
-
-namespace mozilla {
-
-class ServoSpecifiedValues final : public GenericSpecifiedValues
-{
-public:
-  ServoSpecifiedValues(nsIDocument* aDocument, RawServoDeclarationBlock* aDecl)
-    : GenericSpecifiedValues(aDocument)
-    , mDecl(aDecl)
-  {}
-
-  // GenericSpecifiedValues overrides
-  bool PropertyIsSet(nsCSSPropertyID aId);
-
-  void SetIdentStringValue(nsCSSPropertyID aId, const nsString& aValue);
-
-  void SetIdentAtomValue(nsCSSPropertyID aId, nsAtom* aValue);
-
-  void SetKeywordValue(nsCSSPropertyID aId, int32_t aValue);
-
-  void SetIntValue(nsCSSPropertyID aId, int32_t aValue);
-
-  void SetPixelValue(nsCSSPropertyID aId, float aValue);
-
-  void SetLengthValue(nsCSSPropertyID aId, nsCSSValue aValue);
-
-  void SetNumberValue(nsCSSPropertyID aId, float aValue);
-
-  void SetPercentValue(nsCSSPropertyID aId, float aValue);
-
-  void SetAutoValue(nsCSSPropertyID aId);
-
-  void SetCurrentColor(nsCSSPropertyID aId);
-
-  void SetColorValue(nsCSSPropertyID aId, nscolor aValue);
-
-  void SetFontFamily(const nsString& aValue);
-  void SetTextDecorationColorOverride();
-  void SetBackgroundImage(nsAttrValue& aValue);
-
-private:
-  RefPtr<RawServoDeclarationBlock> mDecl;
-};
-
-} // namespace mozilla
-
-#endif // mozilla_ServoSpecifiedValues_h
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -64,33 +64,31 @@ EXPORTS.mozilla += [
     'BindingStyleRule.h',
     'CachedInheritingStyles.h',
     'ComputedStyle.h',
     'ComputedStyleInlines.h',
     'CSSEnabledState.h',
     'CSSPropFlags.h',
     'DeclarationBlock.h',
     'DocumentStyleRootIterator.h',
-    'GenericSpecifiedValues.h',
-    'GenericSpecifiedValuesInlines.h',
     'LayerAnimationInfo.h',
+    'MappedDeclarations.h',
     'MediaFeatureChange.h',
     'PostTraversalTask.h',
     'PreloadedStyleSheet.h',
     'ServoArcTypeList.h',
     'ServoBindingList.h',
     'ServoBindings.h',
     'ServoBindingTypes.h',
     'ServoComputedData.h',
     'ServoComputedDataInlines.h',
     'ServoCSSParser.h',
     'ServoCSSRuleList.h',
     'ServoElementSnapshot.h',
     'ServoElementSnapshotTable.h',
-    'ServoSpecifiedValues.h',
     'ServoStyleSet.h',
     'ServoStyleSetInlines.h',
     'ServoTraversalStatistics.h',
     'ServoTypes.h',
     'ServoUtils.h',
     'SheetType.h',
     'StyleAnimationValue.h',
     'StyleComplexColor.h',
@@ -160,16 +158,17 @@ UNIFIED_SOURCES += [
     'ErrorReporter.cpp',
     'FontFace.cpp',
     'FontFaceSet.cpp',
     'FontFaceSetIterator.cpp',
     'GroupRule.cpp',
     'ImageLoader.cpp',
     'LayerAnimationInfo.cpp',
     'Loader.cpp',
+    'MappedDeclarations.cpp',
     'MediaList.cpp',
     'MediaQueryList.cpp',
     'nsAnimationManager.cpp',
     'nsComputedDOMStyle.cpp',
     'nsCSSKeywords.cpp',
     'nsCSSProps.cpp',
     'nsCSSValue.cpp',
     'nsDOMCSSAttrDeclaration.cpp',
@@ -191,17 +190,16 @@ UNIFIED_SOURCES += [
     'nsTransitionManager.cpp',
     'PostTraversalTask.cpp',
     'PreloadedStyleSheet.cpp',
     'Rule.cpp',
     'ServoBindings.cpp',
     'ServoCSSParser.cpp',
     'ServoCSSRuleList.cpp',
     'ServoElementSnapshot.cpp',
-    'ServoSpecifiedValues.cpp',
     'ServoStyleSet.cpp',
     'StreamLoader.cpp',
     'StyleAnimationValue.cpp',
     'StyleComplexColor.cpp',
     'StyleSheet.cpp',
     'URLExtraData.cpp',
 ]