Merge mozilla-central to autoland. a=merge on a CLOSED TREE
authorRazvan Maries <rmaries@mozilla.com>
Tue, 27 Nov 2018 19:35:52 +0200
changeset 448337 33930dc85090600ba8c1ab269b9854ac4f1c0ebb
parent 448336 7ac08d9d34640922c7b9593eb9ca3d12f56432b7 (current diff)
parent 448293 f83dcdf697697c8708e8015cd5c7b0b49d170b7f (diff)
child 448338 ab61114ae332c44234176d2181a897ff5e89d6d6
push id35109
push usercsabou@mozilla.com
push dateTue, 27 Nov 2018 21:53:40 +0000
treeherdermozilla-central@67c8cedbfd4e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge mozilla-central to autoland. a=merge on a CLOSED TREE
docshell/base/nsDocShell.cpp
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
modules/libpref/init/StaticPrefList.h
testing/web-platform/meta/eventsource/format-data-before-final-empty-line.htm.ini
testing/web-platform/meta/eventsource/format-field-retry-bogus.htm.ini
testing/web-platform/meta/eventsource/format-field-retry.htm.ini
testing/web-platform/meta/workers/constructors/SharedWorker/connect-event.html.ini
--- a/accessible/generic/DocAccessible.h
+++ b/accessible/generic/DocAccessible.h
@@ -638,17 +638,17 @@ protected:
   nsCOMPtr<nsIContent> mAnchorJumpElm;
 
   /**
    * A generic state (see items below) before the attribute value was changed.
    * @see AttributeWillChange and AttributeChanged notifications.
    */
   union {
     // ARIA attribute value
-    nsAtom* mARIAAttrOldValue;
+    const nsAtom* mARIAAttrOldValue;
 
     // True if the accessible state bit was on
     bool mStateBitWasOn;
   };
 
   nsTArray<RefPtr<DocAccessible> > mChildDocuments;
 
   /**
--- a/browser/themes/shared/controlcenter/panel.inc.css
+++ b/browser/themes/shared/controlcenter/panel.inc.css
@@ -431,17 +431,17 @@ description#identity-popup-content-verif
  * and allow it to scroll vertically.*/
 #identity-popup-trackersView {
   max-height: 600px;
 }
 
 #identity-popup-trackersView-list {
   padding: 5px 20px;
   -moz-box-flex: 1;
-  overflow: scroll;
+  overflow: auto;
 }
 
 .identity-popup-trackersView-list-item {
   margin: 5px 0;
   overflow: hidden;
 }
 
 .identity-popup-trackersView-list-item > label {
--- a/devtools/client/themes/webconsole.css
+++ b/devtools/client/themes/webconsole.css
@@ -249,16 +249,17 @@ a {
   display: none;
 }
 
 .message-location {
   max-width: 40vw;
   flex-shrink: 0;
   color: var(--frame-link-source);
   margin-inline-start: 5px;
+  margin-inline-end: 10px;
 }
 
 .stack-trace {
   /* The markup contains extra whitespace to improve formatting of clipboard text.
      Make sure this whitespace doesn't affect the HTML rendering */
   white-space: normal;
 }
 
--- a/dom/base/AttrArray.cpp
+++ b/dom/base/AttrArray.cpp
@@ -29,17 +29,17 @@ AttrArray::Impl::~Impl()
   for (InternalAttr& attr : NonMappedAttrs()) {
     attr.~InternalAttr();
   }
 
   NS_IF_RELEASE(mMappedAttrs);
 }
 
 const nsAttrValue*
-AttrArray::GetAttr(nsAtom* aLocalName, int32_t aNamespaceID) const
+AttrArray::GetAttr(const nsAtom* aLocalName, int32_t aNamespaceID) const
 {
   if (aNamespaceID == kNameSpaceID_None) {
     // This should be the common case so lets make an optimized loop
     for (const InternalAttr& attr : NonMappedAttrs()) {
       if (attr.mName.Equals(aLocalName)) {
         return &attr.mValue;
       }
     }
@@ -268,17 +268,17 @@ AttrArray::GetExistingAttrNameFromQName(
   if (mImpl && mImpl->mMappedAttrs) {
     return mImpl->mMappedAttrs->GetExistingAttrNameFromQName(aName);
   }
 
   return nullptr;
 }
 
 int32_t
-AttrArray::IndexOfAttr(nsAtom* aLocalName, int32_t aNamespaceID) const
+AttrArray::IndexOfAttr(const nsAtom* aLocalName, int32_t aNamespaceID) const
 {
   if (!mImpl) {
     return -1;
   }
 
   int32_t idx;
   if (mImpl->mMappedAttrs && aNamespaceID == kNameSpaceID_None) {
     idx = mImpl->mMappedAttrs->IndexOfAttr(aLocalName);
--- a/dom/base/AttrArray.h
+++ b/dom/base/AttrArray.h
@@ -41,17 +41,17 @@ public:
     return NonMappedAttrCount() || MappedAttrCount();
   }
 
   uint32_t AttrCount() const
   {
     return NonMappedAttrCount() + MappedAttrCount();
   }
 
-  const nsAttrValue* GetAttr(nsAtom* aLocalName,
+  const nsAttrValue* GetAttr(const nsAtom* aLocalName,
                              int32_t aNamespaceID = kNameSpaceID_None) const;
   // As above but using a string attr name and always using
   // kNameSpaceID_None.  This is always case-sensitive.
   const nsAttrValue* GetAttr(const nsAString& aName) const;
   // Get an nsAttrValue by qualified name.  Can optionally do
   // ASCII-case-insensitive name matching.
   const nsAttrValue* GetAttr(const nsAString& aName,
                              nsCaseTreatment aCaseSensitive) const;
@@ -74,17 +74,17 @@ public:
 
   // Returns the attribute info at a given position, *not* out-of-bounds safe
   BorrowedAttrInfo AttrInfoAt(uint32_t aPos) const;
 
   // Returns attribute name at given position or null if aPos is out-of-bounds
   const nsAttrName* GetSafeAttrNameAt(uint32_t aPos) const;
 
   const nsAttrName* GetExistingAttrNameFromQName(const nsAString& aName) const;
-  int32_t IndexOfAttr(nsAtom* aLocalName, int32_t aNamespaceID = kNameSpaceID_None) const;
+  int32_t IndexOfAttr(const nsAtom* aLocalName, int32_t aNamespaceID = kNameSpaceID_None) const;
 
   // SetAndSwapMappedAttr swaps the current attribute value with aValue.
   // If the attribute was unset, an empty value will be swapped into aValue
   // and aHadValue will be set to false. Otherwise, aHadValue will be set to
   // true.
   nsresult SetAndSwapMappedAttr(nsAtom* aLocalName, nsAttrValue& aValue,
                                 nsMappedAttributeElement* aContent,
                                 nsHTMLStyleSheet* aSheet,
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -2415,18 +2415,18 @@ Element::InternalGetAttrNameFromQName(co
     }
   }
 
   return val;
 }
 
 bool
 Element::MaybeCheckSameAttrVal(int32_t aNamespaceID,
-                               nsAtom* aName,
-                               nsAtom* aPrefix,
+                               const nsAtom* aName,
+                               const nsAtom* aPrefix,
                                const nsAttrValueOrString& aValue,
                                bool aNotify,
                                nsAttrValue& aOldValue,
                                uint8_t* aModType,
                                bool* aHasListeners,
                                bool* aOldValueSet)
 {
   bool modification = false;
@@ -2900,28 +2900,28 @@ EventListenerManager*
 Element::GetEventListenerManagerForAttr(nsAtom* aAttrName,
                                         bool* aDefer)
 {
   *aDefer = true;
   return GetOrCreateListenerManager();
 }
 
 bool
-Element::GetAttr(int32_t aNameSpaceID, nsAtom* aName,
+Element::GetAttr(int32_t aNameSpaceID, const nsAtom* aName,
                  nsAString& aResult) const
 {
   DOMString str;
   bool haveAttr = GetAttr(aNameSpaceID, aName, str);
   str.ToString(aResult);
   return haveAttr;
 }
 
 int32_t
 Element::FindAttrValueIn(int32_t aNameSpaceID,
-                         nsAtom* aName,
+                         const nsAtom* aName,
                          AttrValuesArray* aValues,
                          nsCaseTreatment aCaseSensitive) const
 {
   NS_ASSERTION(aName, "Must have attr name");
   NS_ASSERTION(aNameSpaceID != kNameSpaceID_Unknown, "Must have namespace");
   NS_ASSERTION(aValues, "Null value array");
 
   const nsAttrValue* val = mAttrs.GetAttr(aName, aNameSpaceID);
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -702,18 +702,19 @@ public:
    *   nsAttrValue::eString or nsAttrValue::eAtom.
    * @param aModType [out] Set to MutationEvent_Binding::MODIFICATION or to
    *   MutationEvent_Binding::ADDITION, but only if this helper returns true
    * @param aHasListeners [out] Set to true if there are mutation event
    *   listeners listening for NS_EVENT_BITS_MUTATION_ATTRMODIFIED
    * @param aOldValueSet [out] Indicates whether an old attribute value has been
    *   stored in aOldValue. The bool will be set to true if a value was stored.
    */
-  bool MaybeCheckSameAttrVal(int32_t aNamespaceID, nsAtom* aName,
-                             nsAtom* aPrefix,
+  bool MaybeCheckSameAttrVal(int32_t aNamespaceID,
+                             const nsAtom* aName,
+                             const nsAtom* aPrefix,
                              const nsAttrValueOrString& aValue,
                              bool aNotify, nsAttrValue& aOldValue,
                              uint8_t* aModType, bool* aHasListeners,
                              bool* aOldValueSet);
 
   /**
    * Notifies mutation listeners if aNotify is true, there are mutation
    * listeners, and the attribute value is changing.
@@ -760,65 +761,65 @@ public:
                          kNameSpaceID_None in the overload that omits this arg)
    * @param aName the name of the attr
    * @param aResult the value (may legitimately be the empty string) [OUT]
    * @returns true if the attribute was set (even when set to empty string)
    *          false when not set.
    * GetAttr is not inlined on purpose, to keep down codesize from all the
    * inlined nsAttrValue bits for C++ callers.
    */
-  bool GetAttr(int32_t aNameSpaceID, nsAtom* aName, nsAString& aResult) const;
+  bool GetAttr(int32_t aNameSpaceID, const nsAtom* aName, nsAString& aResult) const;
 
-  bool GetAttr(nsAtom* aName, nsAString& aResult) const
+  bool GetAttr(const nsAtom* aName, nsAString& aResult) const
   {
     return GetAttr(kNameSpaceID_None, aName, aResult);
   }
 
   /**
    * Determine if an attribute has been set (empty string or otherwise).
    *
    * @param aNameSpaceId the namespace id of the attribute (defaults to
                          kNameSpaceID_None in the overload that omits this arg)
    * @param aAttr the attribute name
    * @return whether an attribute exists
    */
-  inline bool HasAttr(int32_t aNameSpaceID, nsAtom* aName) const;
+  inline bool HasAttr(int32_t aNameSpaceID, const nsAtom* aName) const;
 
-  bool HasAttr(nsAtom* aAttr) const
+  bool HasAttr(const nsAtom* aAttr) const
   {
     return HasAttr(kNameSpaceID_None, aAttr);
   }
 
   /**
    * Test whether this Element's given attribute has the given value.  If the
    * attribute is not set at all, this will return false.
    *
    * @param aNameSpaceID The namespace ID of the attribute.  Must not
    *                     be kNameSpaceID_Unknown.
    * @param aName The name atom of the attribute.  Must not be null.
    * @param aValue The value to compare to.
    * @param aCaseSensitive Whether to do a case-sensitive compare on the value.
    */
-  inline bool AttrValueIs(int32_t aNameSpaceID, nsAtom* aName,
+  inline bool AttrValueIs(int32_t aNameSpaceID, const nsAtom* aName,
                           const nsAString& aValue,
                           nsCaseTreatment aCaseSensitive) const;
 
   /**
    * Test whether this Element's given attribute has the given value.  If the
    * attribute is not set at all, this will return false.
    *
    * @param aNameSpaceID The namespace ID of the attribute.  Must not
    *                     be kNameSpaceID_Unknown.
    * @param aName The name atom of the attribute.  Must not be null.
    * @param aValue The value to compare to.  Must not be null.
    * @param aCaseSensitive Whether to do a case-sensitive compare on the value.
    */
   bool AttrValueIs(int32_t aNameSpaceID,
-                   nsAtom* aName,
-                   nsAtom* aValue,
+                   const nsAtom* aName,
+                   const nsAtom* aValue,
                    nsCaseTreatment aCaseSensitive) const;
 
   enum {
     ATTR_MISSING = -1,
     ATTR_VALUE_NO_MATCH = -2
   };
   /**
    * Check whether this Element's given attribute has one of a given list of
@@ -833,17 +834,17 @@ public:
    * @param aValues a nullptr-terminated array of pointers to atom values to test
    *                against.
    * @param aCaseSensitive Whether to do a case-sensitive compare on the values.
    * @return ATTR_MISSING, ATTR_VALUE_NO_MATCH or the non-negative index
    * indicating the first value of aValues that matched
    */
   typedef nsStaticAtom* const AttrValuesArray;
   int32_t FindAttrValueIn(int32_t aNameSpaceID,
-                                  nsAtom* aName,
+                                  const nsAtom* aName,
                                   AttrValuesArray* aValues,
                                   nsCaseTreatment aCaseSensitive) const;
 
   /**
    * Set attribute values. All attribute values are assumed to have a
    * canonical string representation that can be used for these
    * methods. The SetAttr method is assumed to perform a translation
    * of the canonical form into the underlying content specific
@@ -1009,17 +1010,17 @@ private:
   void DescribeAttribute(uint32_t index, nsAString& aOutDescription) const;
 
   static bool
   FindAttributeDependence(const nsAtom* aAttribute,
                           const MappedAttributeEntry* const aMaps[],
                           uint32_t aMapCount);
 
 protected:
-  inline bool GetAttr(int32_t aNameSpaceID, nsAtom* aName,
+  inline bool GetAttr(int32_t aNameSpaceID, const nsAtom* aName,
                       DOMString& aResult) const
   {
     NS_ASSERTION(nullptr != aName, "must have attribute name");
     NS_ASSERTION(aNameSpaceID != kNameSpaceID_Unknown,
                  "must have a real namespace ID!");
     MOZ_ASSERT(aResult.IsEmpty(), "Should have empty string coming in");
     const nsAttrValue* val = mAttrs.GetAttr(aName, aNameSpaceID);
     if (val) {
@@ -1458,22 +1459,22 @@ public:
   // Work around silly C++ name hiding stuff
   nsIFrame* GetPrimaryFrame() const { return nsIContent::GetPrimaryFrame(); }
 
   bool IsDisplayContents() const
   {
     return HasServoData() && Servo_Element_IsDisplayContents(this);
   }
 
-  const nsAttrValue* GetParsedAttr(nsAtom* aAttr) const
+  const nsAttrValue* GetParsedAttr(const nsAtom* aAttr) const
   {
     return mAttrs.GetAttr(aAttr);
   }
 
-  const nsAttrValue* GetParsedAttr(nsAtom* aAttr, int32_t aNameSpaceID) const
+  const nsAttrValue* GetParsedAttr(const nsAtom* aAttr, int32_t aNameSpaceID) const
   {
     return mAttrs.GetAttr(aAttr, aNameSpaceID);
   }
 
   /**
    * Returns the attribute map, if there is one.
    *
    * @return existing attribute map or nullptr.
@@ -1492,17 +1493,17 @@ public:
   /**
    * Get the attr info for the given namespace ID and attribute name.  The
    * namespace ID must not be kNameSpaceID_Unknown and the name must not be
    * null.  Note that this can only return info on attributes that actually
    * live on this element (and is only virtual to handle XUL prototypes).  That
    * is, this should only be called from methods that only care about attrs
    * that effectively live in mAttrs.
    */
-  BorrowedAttrInfo GetAttrInfo(int32_t aNamespaceID, nsAtom* aName) const
+  BorrowedAttrInfo GetAttrInfo(int32_t aNamespaceID, const nsAtom* aName) const
   {
     NS_ASSERTION(aName, "must have attribute name");
     NS_ASSERTION(aNamespaceID != kNameSpaceID_Unknown,
                  "must have a real namespace ID!");
 
     int32_t index = mAttrs.IndexOfAttr(aName, aNamespaceID);
     if (index < 0) {
       return BorrowedAttrInfo(nullptr, nullptr);
@@ -2013,42 +2014,42 @@ private:
   RefPtr<nsBindingManager> mManager;
   RefPtr<nsIContent> mContent;
   nsCOMPtr<nsIDocument> mDoc;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(Element, NS_ELEMENT_IID)
 
 inline bool
-Element::HasAttr(int32_t aNameSpaceID, nsAtom* aName) const
+Element::HasAttr(int32_t aNameSpaceID, const nsAtom* aName) const
 {
   NS_ASSERTION(nullptr != aName, "must have attribute name");
   NS_ASSERTION(aNameSpaceID != kNameSpaceID_Unknown,
                "must have a real namespace ID!");
 
   return mAttrs.IndexOfAttr(aName, aNameSpaceID) >= 0;
 }
 
 inline bool
 Element::AttrValueIs(int32_t aNameSpaceID,
-                     nsAtom* aName,
+                     const nsAtom* aName,
                      const nsAString& aValue,
                      nsCaseTreatment aCaseSensitive) const
 {
   NS_ASSERTION(aName, "Must have attr name");
   NS_ASSERTION(aNameSpaceID != kNameSpaceID_Unknown, "Must have namespace");
 
   const nsAttrValue* val = mAttrs.GetAttr(aName, aNameSpaceID);
   return val && val->Equals(aValue, aCaseSensitive);
 }
 
 inline bool
 Element::AttrValueIs(int32_t aNameSpaceID,
-                     nsAtom* aName,
-                     nsAtom* aValue,
+                     const nsAtom* aName,
+                     const nsAtom* aValue,
                      nsCaseTreatment aCaseSensitive) const
 {
   NS_ASSERTION(aName, "Must have attr name");
   NS_ASSERTION(aNameSpaceID != kNameSpaceID_Unknown, "Must have namespace");
   NS_ASSERTION(aValue, "Null value atom");
 
   const nsAttrValue* val = mAttrs.GetAttr(aName, aNameSpaceID);
   return val && val->Equals(aValue, aCaseSensitive);
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -878,42 +878,39 @@ FragmentOrElement::GetChildren(uint32_t 
   AllChildrenIterator iter(this, aFilter);
   while (nsIContent* kid = iter.GetNextChild()) {
     list->AppendElement(kid);
   }
 
   return list.forget();
 }
 
-static nsIContent*
-FindChromeAccessOnlySubtreeOwner(nsIContent* aContent)
+static nsINode*
+FindChromeAccessOnlySubtreeOwner(nsINode* aNode)
 {
-  if (aContent->ChromeOnlyAccess()) {
-    bool chromeAccessOnly = false;
-    while (aContent && !chromeAccessOnly) {
-      chromeAccessOnly = aContent->IsRootOfChromeAccessOnlySubtree();
-      aContent = aContent->GetParent();
-    }
+  if (!aNode->ChromeOnlyAccess()) {
+    return aNode;
   }
-  return aContent;
+
+  while (aNode && !aNode->IsRootOfChromeAccessOnlySubtree()) {
+    aNode = aNode->GetParentNode();
+  }
+
+  return aNode ? aNode->GetParentOrHostNode() : nullptr;
 }
 
 already_AddRefed<nsINode>
 FindChromeAccessOnlySubtreeOwner(EventTarget* aTarget)
 {
   nsCOMPtr<nsINode> node = do_QueryInterface(aTarget);
   if (!node || !node->ChromeOnlyAccess()) {
     return node.forget();
   }
 
-  if (!node->IsContent()) {
-    return nullptr;
-  }
-
-  node = FindChromeAccessOnlySubtreeOwner(node->AsContent());
+  node = FindChromeAccessOnlySubtreeOwner(node);
   return node.forget();
 }
 
 void
 nsIContent::GetEventTargetParent(EventChainPreVisitor& aVisitor)
 {
   //FIXME! Document how this event retargeting works, Bug 329124.
   aVisitor.mCanHandle = true;
@@ -946,19 +943,19 @@ nsIContent::GetEventTargetParent(EventCh
       // target is descendant of an element which is anonymous for events,
       // we may want to stop event propagation.
       // If this is the original target, aVisitor.mRelatedTargetIsInAnon
       // must be updated.
       if (isAnonForEvents || aVisitor.mRelatedTargetIsInAnon ||
           (aVisitor.mEvent->mOriginalTarget == this &&
            (aVisitor.mRelatedTargetIsInAnon =
             relatedTarget->ChromeOnlyAccess()))) {
-        nsIContent* anonOwner = FindChromeAccessOnlySubtreeOwner(this);
+        nsINode* anonOwner = FindChromeAccessOnlySubtreeOwner(this);
         if (anonOwner) {
-          nsIContent* anonOwnerRelated =
+          nsINode* anonOwnerRelated =
             FindChromeAccessOnlySubtreeOwner(relatedTarget);
           if (anonOwnerRelated) {
             // Note, anonOwnerRelated may still be inside some other
             // native anonymous subtree. The case where anonOwner is still
             // inside native anonymous subtree will be handled when event
             // propagates up in the DOM tree.
             while (anonOwner != anonOwnerRelated &&
                    anonOwnerRelated->ChromeOnlyAccess()) {
--- a/dom/base/NodeInfo.h
+++ b/dom/base/NodeInfo.h
@@ -149,33 +149,33 @@ public:
    * Utility functions that can be used to check if a nodeinfo holds a specific
    * name, name and prefix, name and prefix and namespace ID, or just
    * namespace ID.
    */
   inline bool Equals(NodeInfo* aNodeInfo) const;
 
   bool NameAndNamespaceEquals(NodeInfo* aNodeInfo) const;
 
-  bool Equals(nsAtom* aNameAtom) const
+  bool Equals(const nsAtom* aNameAtom) const
   {
     return mInner.mName == aNameAtom;
   }
 
-  bool Equals(nsAtom* aNameAtom, nsAtom* aPrefixAtom) const
+  bool Equals(const nsAtom* aNameAtom, const nsAtom* aPrefixAtom) const
   {
     return (mInner.mName == aNameAtom) && (mInner.mPrefix == aPrefixAtom);
   }
 
-  bool Equals(nsAtom* aNameAtom, int32_t aNamespaceID) const
+  bool Equals(const nsAtom* aNameAtom, int32_t aNamespaceID) const
   {
     return ((mInner.mName == aNameAtom) &&
             (mInner.mNamespaceID == aNamespaceID));
   }
 
-  bool Equals(nsAtom* aNameAtom, nsAtom* aPrefixAtom, int32_t aNamespaceID) const
+  bool Equals(const nsAtom* aNameAtom, const nsAtom* aPrefixAtom, int32_t aNamespaceID) const
   {
     return ((mInner.mName == aNameAtom) &&
             (mInner.mPrefix == aPrefixAtom) &&
             (mInner.mNamespaceID == aNamespaceID));
   }
 
   bool NamespaceEquals(int32_t aNamespaceID) const
   {
@@ -187,17 +187,17 @@ public:
   inline bool Equals(const nsAString& aName, const nsAString& aPrefix) const;
 
   inline bool Equals(const nsAString& aName, int32_t aNamespaceID) const;
 
   inline bool Equals(const nsAString& aName, const nsAString& aPrefix, int32_t aNamespaceID) const;
 
   bool NamespaceEquals(const nsAString& aNamespaceURI) const;
 
-  inline bool QualifiedNameEquals(nsAtom* aNameAtom) const;
+  inline bool QualifiedNameEquals(const nsAtom* aNameAtom) const;
 
   bool QualifiedNameEquals(const nsAString& aQualifiedName) const
   {
     return mQualifiedName == aQualifiedName;
   }
 
   /*
    * Retrieve a pointer to the document that owns this node info.
--- a/dom/base/NodeInfoInlines.h
+++ b/dom/base/NodeInfoInlines.h
@@ -53,32 +53,32 @@ inline bool
 NodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix,
                  int32_t aNamespaceID) const
 {
   return mInner.mName->Equals(aName) && mInner.mNamespaceID == aNamespaceID &&
     (mInner.mPrefix ? mInner.mPrefix->Equals(aPrefix) : aPrefix.IsEmpty());
 }
 
 inline bool
-NodeInfo::QualifiedNameEquals(nsAtom* aNameAtom) const
+NodeInfo::QualifiedNameEquals(const nsAtom* aNameAtom) const
 {
   MOZ_ASSERT(aNameAtom, "Must have name atom");
   if (!GetPrefixAtom()) {
     return Equals(aNameAtom);
   }
 
   return aNameAtom->Equals(mQualifiedName);
 }
 
 } // namespace dom
 } // namespace mozilla
 
 inline void
-CheckValidNodeInfo(uint16_t aNodeType, nsAtom *aName, int32_t aNamespaceID,
-                   nsAtom* aExtraName)
+CheckValidNodeInfo(uint16_t aNodeType, const nsAtom *aName,
+                   int32_t aNamespaceID, const nsAtom* aExtraName)
 {
   MOZ_ASSERT(aNodeType == nsINode::ELEMENT_NODE ||
              aNodeType == nsINode::ATTRIBUTE_NODE ||
              aNodeType == nsINode::TEXT_NODE ||
              aNodeType == nsINode::CDATA_SECTION_NODE ||
              aNodeType == nsINode::PROCESSING_INSTRUCTION_NODE ||
              aNodeType == nsINode::COMMENT_NODE ||
              aNodeType == nsINode::DOCUMENT_NODE ||
--- a/dom/base/ShadowRoot.h
+++ b/dom/base/ShadowRoot.h
@@ -206,16 +206,18 @@ public:
 
   bool IsUAWidget() const
   {
     return mIsUAWidget;
   }
 
   void SetIsUAWidget()
   {
+    MOZ_ASSERT(!HasChildren());
+    SetFlags(NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS | NODE_CHROME_ONLY_ACCESS);
     mIsUAWidget = true;
   }
 
   void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
 
   // nsIRadioGroupContainer
   NS_IMETHOD WalkRadioGroup(const nsAString& aName,
                             nsIRadioVisitor* aVisitor,
--- a/dom/base/nsAttrName.h
+++ b/dom/base/nsAttrName.h
@@ -100,28 +100,28 @@ public:
     return mBits == aOther.mBits;
   }
 
   // Faster comparison in the case we know the namespace is null
   // Note that some callers such as AttrArray::IndexOfAttr() will
   // call this function on nsAttrName structs with 0 mBits, so no attempt
   // must be made to do anything with mBits besides comparing it with the
   // incoming aAtom argument.
-  bool Equals(nsAtom* aAtom) const
+  bool Equals(const nsAtom* aAtom) const
   {
     return reinterpret_cast<uintptr_t>(aAtom) == mBits;
   }
 
   // And the same but without forcing callers to atomize
   bool Equals(const nsAString& aLocalName) const
   {
     return IsAtom() && Atom()->Equals(aLocalName);
   }
 
-  bool Equals(nsAtom* aLocalName, int32_t aNamespaceID) const
+  bool Equals(const nsAtom* aLocalName, int32_t aNamespaceID) const
   {
     if (aNamespaceID == kNameSpaceID_None) {
       return Equals(aLocalName);
     }
     return !IsAtom() && NodeInfo()->Equals(aLocalName, aNamespaceID);
   }
 
   bool Equals(mozilla::dom::NodeInfo* aNodeInfo) const
@@ -182,17 +182,17 @@ public:
   uint32_t HashValue() const
   {
     // mBits and uint32_t might have different size. This should silence
     // any warnings or compile-errors. This is what the implementation of
     // NS_PTR_TO_INT32 does to take care of the same problem.
     return mBits - 0;
   }
 
-  bool IsSmaller(nsAtom* aOther) const
+  bool IsSmaller(const nsAtom* aOther) const
   {
     return mBits < reinterpret_cast<uintptr_t>(aOther);
   }
 
 private:
 
   void AddRefInternalName()
   {
--- a/dom/base/nsAttrValue.cpp
+++ b/dom/base/nsAttrValue.cpp
@@ -1094,17 +1094,17 @@ nsAttrValue::Equals(const nsAString& aVa
 
   nsAutoString val;
   ToString(val);
   return aCaseSensitive == eCaseMatters ? val.Equals(aValue) :
     nsContentUtils::EqualsIgnoreASCIICase(val, aValue);
 }
 
 bool
-nsAttrValue::Equals(nsAtom* aValue, nsCaseTreatment aCaseSensitive) const
+nsAttrValue::Equals(const nsAtom* aValue, nsCaseTreatment aCaseSensitive) const
 {
   if (aCaseSensitive != eCaseMatters) {
     // Need a better way to handle this!
     nsAutoString value;
     aValue->ToString(value);
     return Equals(value, aCaseSensitive);
   }
 
--- a/dom/base/nsAttrValue.h
+++ b/dom/base/nsAttrValue.h
@@ -214,17 +214,17 @@ public:
   // Returns the atom at aIndex (0-based).  Do not call this with
   // aIndex >= GetAtomCount().
   nsAtom* AtomAt(int32_t aIndex) const;
 
   uint32_t HashValue() const;
   bool Equals(const nsAttrValue& aOther) const;
   // aCaseSensitive == eIgnoreCase means ASCII case-insenstive matching
   bool Equals(const nsAString& aValue, nsCaseTreatment aCaseSensitive) const;
-  bool Equals(nsAtom* aValue, nsCaseTreatment aCaseSensitive) const;
+  bool Equals(const nsAtom* aValue, nsCaseTreatment aCaseSensitive) const;
 
   /**
    * Compares this object with aOther according to their string representation.
    *
    * For example, when called on an object with type eInteger and value 4, and
    * given aOther of type eString and value "4", EqualsAsStrings will return
    * true (while Equals will return false).
    */
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -2088,19 +2088,28 @@ nsContentUtils::CanCallerAccess(nsIPrinc
 
   // The subject doesn't subsume aPrincipal. Allow access only if the subject
   // is chrome.
   return IsCallerChrome();
 }
 
 // static
 bool
-nsContentUtils::CanCallerAccess(nsINode* aNode)
-{
-  return CanCallerAccess(SubjectPrincipal(), aNode->NodePrincipal());
+nsContentUtils::CanCallerAccess(const nsINode* aNode)
+{
+  nsIPrincipal* subject = SubjectPrincipal();
+  if (IsSystemPrincipal(subject)) {
+    return true;
+  }
+
+  if (aNode->ChromeOnlyAccess()) {
+    return false;
+  }
+
+  return CanCallerAccess(subject, aNode->NodePrincipal());
 }
 
 // static
 bool
 nsContentUtils::CanCallerAccess(nsPIDOMWindowInner* aWindow)
 {
   nsCOMPtr<nsIScriptObjectPrincipal> scriptObject = do_QueryInterface(aWindow);
   NS_ENSURE_TRUE(scriptObject, false);
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -629,17 +629,17 @@ public:
 
   /**
    * Checks whether two nodes come from the same origin.
    */
   static nsresult CheckSameOrigin(const nsINode* aTrustedNode,
                                   const nsINode* unTrustedNode);
 
   // Check if the (JS) caller can access aNode.
-  static bool CanCallerAccess(nsINode* aNode);
+  static bool CanCallerAccess(const nsINode* aNode);
 
   // Check if the (JS) caller can access aWindow.
   // aWindow can be either outer or inner window.
   static bool CanCallerAccess(nsPIDOMWindowInner* aWindow);
 
   // Check if the principal is chrome or an addon with the permission.
   static bool PrincipalHasPermission(nsIPrincipal* aPrincipal, const nsAtom* aPerm);
 
--- a/dom/base/nsIContent.h
+++ b/dom/base/nsIContent.h
@@ -174,36 +174,16 @@ public:
    * @note calling this method with eAllButXBL will return children that are
    *  also in the eAllButXBL and eAllChildren child lists of other descendants
    *  of this node in the tree, but those other nodes cannot be reached from the
    *  eAllButXBL child list.
    */
   virtual already_AddRefed<nsINodeList> GetChildren(uint32_t aFilter) = 0;
 
   /**
-   * Get whether this content is C++-generated anonymous content
-   * @see nsIAnonymousContentCreator
-   * @return whether this content is anonymous
-   */
-  bool IsRootOfNativeAnonymousSubtree() const
-  {
-    NS_ASSERTION(!HasFlag(NODE_IS_NATIVE_ANONYMOUS_ROOT) ||
-                 (HasFlag(NODE_IS_ANONYMOUS_ROOT) &&
-                  HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE)),
-                 "Some flags seem to be missing!");
-    return HasFlag(NODE_IS_NATIVE_ANONYMOUS_ROOT);
-  }
-
-  bool IsRootOfChromeAccessOnlySubtree() const
-  {
-    return HasFlag(NODE_IS_NATIVE_ANONYMOUS_ROOT |
-                   NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS);
-  }
-
-  /**
    * Makes this content anonymous
    * @see nsIAnonymousContentCreator
    */
   void SetIsNativeAnonymousRoot()
   {
     SetFlags(NODE_IS_ANONYMOUS_ROOT | NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE |
              NODE_IS_NATIVE_ANONYMOUS_ROOT);
   }
@@ -268,65 +248,65 @@ public:
     return mNodeInfo->NamespaceID();
   }
 
   inline bool IsHTMLElement() const
   {
     return IsInNamespace(kNameSpaceID_XHTML);
   }
 
-  inline bool IsHTMLElement(nsAtom* aTag) const
+  inline bool IsHTMLElement(const nsAtom* aTag) const
   {
     return mNodeInfo->Equals(aTag, kNameSpaceID_XHTML);
   }
 
   template<typename First, typename... Args>
   inline bool IsAnyOfHTMLElements(First aFirst, Args... aArgs) const
   {
     return IsHTMLElement() && IsNodeInternal(aFirst, aArgs...);
   }
 
   inline bool IsSVGElement() const
   {
     return IsInNamespace(kNameSpaceID_SVG);
   }
 
-  inline bool IsSVGElement(nsAtom* aTag) const
+  inline bool IsSVGElement(const nsAtom* aTag) const
   {
     return mNodeInfo->Equals(aTag, kNameSpaceID_SVG);
   }
 
   template<typename First, typename... Args>
   inline bool IsAnyOfSVGElements(First aFirst, Args... aArgs) const
   {
     return IsSVGElement() && IsNodeInternal(aFirst, aArgs...);
   }
 
   inline bool IsXULElement() const
   {
     return IsInNamespace(kNameSpaceID_XUL);
   }
 
-  inline bool IsXULElement(nsAtom* aTag) const
+  inline bool IsXULElement(const nsAtom* aTag) const
   {
     return mNodeInfo->Equals(aTag, kNameSpaceID_XUL);
   }
 
   template<typename First, typename... Args>
   inline bool IsAnyOfXULElements(First aFirst, Args... aArgs) const
   {
     return IsXULElement() && IsNodeInternal(aFirst, aArgs...);
   }
 
   inline bool IsMathMLElement() const
   {
     return IsInNamespace(kNameSpaceID_MathML);
   }
 
-  inline bool IsMathMLElement(nsAtom* aTag) const
+  inline bool IsMathMLElement(const nsAtom* aTag) const
   {
     return mNodeInfo->Equals(aTag, kNameSpaceID_MathML);
   }
 
   template<typename First, typename... Args>
   inline bool IsAnyOfMathMLElements(First aFirst, Args... aArgs) const
   {
     return IsMathMLElement() && IsNodeInternal(aFirst, aArgs...);
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -168,17 +168,17 @@ nsINode::nsINode(already_AddRefed<mozill
 
 nsINode::~nsINode()
 {
   MOZ_ASSERT(!HasSlots(), "nsNodeUtils::LastRelease was not called?");
   MOZ_ASSERT(mSubtreeRoot == this, "Didn't restore state properly?");
 }
 
 void*
-nsINode::GetProperty(nsAtom* aPropertyName, nsresult* aStatus) const
+nsINode::GetProperty(const nsAtom* aPropertyName, nsresult* aStatus) const
 {
   if (!HasProperties()) { // a fast HasFlag() test
     if (aStatus) {
       *aStatus = NS_PROPTABLE_PROP_NOT_THERE;
     }
     return nullptr;
   }
   return OwnerDoc()->PropertyTable().GetProperty(this, aPropertyName, aStatus);
@@ -199,23 +199,23 @@ nsINode::SetProperty(nsAtom* aPropertyNa
   if (NS_SUCCEEDED(rv)) {
     SetFlags(NODE_HAS_PROPERTIES);
   }
 
   return rv;
 }
 
 void
-nsINode::DeleteProperty(nsAtom* aPropertyName)
+nsINode::DeleteProperty(const nsAtom* aPropertyName)
 {
   OwnerDoc()->PropertyTable().DeleteProperty(this, aPropertyName);
 }
 
 void*
-nsINode::UnsetProperty(nsAtom* aPropertyName, nsresult* aStatus)
+nsINode::UnsetProperty(const nsAtom* aPropertyName, nsresult* aStatus)
 {
   return OwnerDoc()->PropertyTable().UnsetProperty(this, aPropertyName, aStatus);
 }
 
 nsINode::nsSlots*
 nsINode::CreateSlots()
 {
   return new nsSlots();
--- a/dom/base/nsINode.h
+++ b/dom/base/nsINode.h
@@ -726,65 +726,65 @@ protected:
   }
 
 public:
   inline bool IsHTMLElement() const
   {
     return IsElement() && IsInNamespace(kNameSpaceID_XHTML);
   }
 
-  inline bool IsHTMLElement(nsAtom* aTag) const
+  inline bool IsHTMLElement(const nsAtom* aTag) const
   {
     return IsElement() && mNodeInfo->Equals(aTag, kNameSpaceID_XHTML);
   }
 
   template<typename First, typename... Args>
   inline bool IsAnyOfHTMLElements(First aFirst, Args... aArgs) const
   {
     return IsHTMLElement() && IsNodeInternal(aFirst, aArgs...);
   }
 
   inline bool IsSVGElement() const
   {
     return IsElement() && IsInNamespace(kNameSpaceID_SVG);
   }
 
-  inline bool IsSVGElement(nsAtom* aTag) const
+  inline bool IsSVGElement(const nsAtom* aTag) const
   {
     return IsElement() && mNodeInfo->Equals(aTag, kNameSpaceID_SVG);
   }
 
   template<typename First, typename... Args>
   inline bool IsAnyOfSVGElements(First aFirst, Args... aArgs) const
   {
     return IsSVGElement() && IsNodeInternal(aFirst, aArgs...);
   }
 
   inline bool IsXULElement() const
   {
     return IsElement() && IsInNamespace(kNameSpaceID_XUL);
   }
 
-  inline bool IsXULElement(nsAtom* aTag) const
+  inline bool IsXULElement(const nsAtom* aTag) const
   {
     return IsElement() && mNodeInfo->Equals(aTag, kNameSpaceID_XUL);
   }
 
   template<typename First, typename... Args>
   inline bool IsAnyOfXULElements(First aFirst, Args... aArgs) const
   {
     return IsXULElement() && IsNodeInternal(aFirst, aArgs...);
   }
 
   inline bool IsMathMLElement() const
   {
     return IsElement() && IsInNamespace(kNameSpaceID_MathML);
   }
 
-  inline bool IsMathMLElement(nsAtom* aTag) const
+  inline bool IsMathMLElement(const nsAtom* aTag) const
   {
     return IsElement() && mNodeInfo->Equals(aTag, kNameSpaceID_MathML);
   }
 
   template<typename First, typename... Args>
   inline bool IsAnyOfMathMLElements(First aFirst, Args... aArgs) const
   {
     return IsMathMLElement() && IsNodeInternal(aFirst, aArgs...);
@@ -860,17 +860,17 @@ public:
    * @param aPropertyName  name of property to get.
    * @param aStatus        out parameter for storing resulting status.
    *                       Set to NS_PROPTABLE_PROP_NOT_THERE if the property
    *                       is not set.
    * @return               the property. Null if the property is not set
    *                       (though a null return value does not imply the
    *                       property was not set, i.e. it can be set to null).
    */
-  void* GetProperty(nsAtom* aPropertyName, nsresult* aStatus = nullptr) const;
+  void* GetProperty(const nsAtom* aPropertyName, nsresult* aStatus = nullptr) const;
 
   /**
    * Set a property to be associated with this node. This will overwrite an
    * existing value if one exists. The existing value is destroyed using the
    * destructor function given when that value was set.
    *
    * @param aPropertyName  name of property to set.
    * @param aValue         new value of property.
@@ -899,32 +899,32 @@ public:
   }
 
   /**
    * Destroys a property associated with this node. The value is destroyed
    * using the destruction function given when that value was set.
    *
    * @param aPropertyName  name of property to destroy.
    */
-  void DeleteProperty(nsAtom* aPropertyName);
+  void DeleteProperty(const nsAtom* aPropertyName);
 
   /**
    * Unset a property associated with this node. The value will not be
    * destroyed but rather returned. It is the caller's responsibility to
    * destroy the value after that point.
    *
    * @param aPropertyName  name of property to unset.
    * @param aStatus        out parameter for storing resulting status.
    *                       Set to NS_PROPTABLE_PROP_NOT_THERE if the property
    *                       is not set.
    * @return               the property. Null if the property is not set
    *                       (though a null return value does not imply the
    *                       property was not set, i.e. it can be set to null).
    */
-  void* UnsetProperty(nsAtom* aPropertyName, nsresult* aStatus = nullptr);
+  void* UnsetProperty(const nsAtom* aPropertyName, nsresult* aStatus = nullptr);
 
   bool HasProperties() const
   {
     return HasFlag(NODE_HAS_PROPERTIES);
   }
 
   /**
    * Return the principal of this node.  This is guaranteed to never be a null
@@ -1228,16 +1228,36 @@ public:
   }
 
   bool IsInShadowTree() const
   {
     return HasFlag(NODE_IS_IN_SHADOW_TREE);
   }
 
   /**
+   * Get whether this node is C++-generated anonymous content
+   * @see nsIAnonymousContentCreator
+   * @return whether this content is anonymous
+   */
+  bool IsRootOfNativeAnonymousSubtree() const
+  {
+    NS_ASSERTION(!HasFlag(NODE_IS_NATIVE_ANONYMOUS_ROOT) ||
+                 (HasFlag(NODE_IS_ANONYMOUS_ROOT) &&
+                  HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE)),
+                 "Some flags seem to be missing!");
+    return HasFlag(NODE_IS_NATIVE_ANONYMOUS_ROOT);
+  }
+
+  bool IsRootOfChromeAccessOnlySubtree() const
+  {
+    return HasFlag(NODE_IS_NATIVE_ANONYMOUS_ROOT |
+                   NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS);
+  }
+
+  /**
    * Returns true if |this| node is the common ancestor of the start/end
    * nodes of a Range in a Selection or a descendant of such a common ancestor.
    * This node is definitely not selected when |false| is returned, but it may
    * or may not be selected when |true| is returned.
    */
   bool IsSelectionDescendant() const
   {
     return IsDescendantOfCommonAncestorForRangeInSelection() ||
--- a/dom/base/nsMappedAttributes.cpp
+++ b/dom/base/nsMappedAttributes.cpp
@@ -170,17 +170,17 @@ nsMappedAttributes::SetAndSwapAttr(nsAto
 
   new (&Attrs()[i].mName) nsAttrName(aAttrName);
   new (&Attrs()[i].mValue) nsAttrValue();
   Attrs()[i].mValue.SwapValueWith(aValue);
   ++mAttrCount;
 }
 
 const nsAttrValue*
-nsMappedAttributes::GetAttr(nsAtom* aAttrName) const
+nsMappedAttributes::GetAttr(const nsAtom* aAttrName) const
 {
   MOZ_ASSERT(aAttrName, "null name");
 
   for (uint32_t i = 0; i < mAttrCount; ++i) {
     if (Attrs()[i].mName.Equals(aAttrName)) {
       return &Attrs()[i].mValue;
     }
   }
@@ -273,17 +273,17 @@ nsMappedAttributes::GetExistingAttrNameF
       }
     }
   }
 
   return nullptr;
 }
 
 int32_t
-nsMappedAttributes::IndexOfAttr(nsAtom* aLocalName) const
+nsMappedAttributes::IndexOfAttr(const nsAtom* aLocalName) const
 {
   uint32_t i;
   for (i = 0; i < mAttrCount; ++i) {
     if (Attrs()[i].mName.Equals(aLocalName)) {
       return i;
     }
   }
 
--- a/dom/base/nsMappedAttributes.h
+++ b/dom/base/nsMappedAttributes.h
@@ -30,17 +30,17 @@ public:
   // Do not return null.
   void* operator new(size_t size, uint32_t aAttrCount = 1) CPP_THROW_NEW;
   nsMappedAttributes* Clone(bool aWillAddAttr);
 
   NS_INLINE_DECL_REFCOUNTING_WITH_DESTROY(nsMappedAttributes, LastRelease())
 
   void SetAndSwapAttr(nsAtom* aAttrName, nsAttrValue& aValue,
                       bool* aValueWasSet);
-  const nsAttrValue* GetAttr(nsAtom* aAttrName) const;
+  const nsAttrValue* GetAttr(const nsAtom* aAttrName) const;
   const nsAttrValue* GetAttr(const nsAString& aAttrName) const;
 
   uint32_t Count() const
   {
     return mAttrCount;
   }
 
   bool Equals(const nsMappedAttributes* aAttributes) const;
@@ -70,17 +70,17 @@ public:
   {
     NS_ASSERTION(aPos < mAttrCount, "out-of-bounds");
     return &Attrs()[aPos].mValue;
   }
   // Remove the attr at position aPos.  The value of the attr is placed in
   // aValue; any value that was already in aValue is destroyed.
   void RemoveAttrAt(uint32_t aPos, nsAttrValue& aValue);
   const nsAttrName* GetExistingAttrNameFromQName(const nsAString& aName) const;
-  int32_t IndexOfAttr(nsAtom* aLocalName) const;
+  int32_t IndexOfAttr(const nsAtom* aLocalName) const;
 
   // Apply the contained mapper to the contained set of servo rules,
   // unless the servo rules have already been initialized.
   void LazilyResolveServoDeclaration(nsIDocument* aDocument);
 
   // Obtain the contained servo declaration block
   // May return null if called before the inner block
   // has been (lazily) resolved
--- a/dom/base/nsPropertyTable.cpp
+++ b/dom/base/nsPropertyTable.cpp
@@ -36,17 +36,17 @@ public:
 
   // Removes the property associated with the given object, and destroys
   // the property value
   bool DeletePropertyFor(nsPropertyOwner aObject);
 
   // Destroy all remaining properties (without removing them)
   void Destroy();
 
-  bool Equals(nsAtom *aPropertyName)
+  bool Equals(const nsAtom *aPropertyName)
   {
     return mName == aPropertyName;
   }
 
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);
 
   RefPtr<nsAtom>  mName;           // property name
   PLDHashTable       mObjectValueMap; // map of object/value pairs
@@ -131,17 +131,17 @@ nsPropertyTable::EnumerateAll(NSProperty
       aCallBack(const_cast<void*>(entry->key), prop->mName, entry->value,
                 aData);
     }
   }
 }
 
 void*
 nsPropertyTable::GetPropertyInternal(nsPropertyOwner aObject,
-                                     nsAtom* aPropertyName,
+                                     const nsAtom* aPropertyName,
                                      bool aRemove,
                                      nsresult* aResult)
 {
   MOZ_ASSERT(aPropertyName && aObject, "unexpected null param");
   nsresult rv = NS_PROPTABLE_PROP_NOT_THERE;
   void *propValue = nullptr;
 
   PropertyList* propertyList = GetPropertyListFor(aPropertyName);
@@ -211,31 +211,31 @@ nsPropertyTable::SetPropertyInternal(nsP
   entry->key = aObject;
   entry->value = aPropertyValue;
 
   return result;
 }
 
 nsresult
 nsPropertyTable::DeleteProperty(nsPropertyOwner aObject,
-                                nsAtom* aPropertyName)
+                                const nsAtom* aPropertyName)
 {
   MOZ_ASSERT(aPropertyName && aObject, "unexpected null param");
 
   PropertyList* propertyList = GetPropertyListFor(aPropertyName);
   if (propertyList) {
     if (propertyList->DeletePropertyFor(aObject))
       return NS_OK;
   }
 
   return NS_PROPTABLE_PROP_NOT_THERE;
 }
 
 nsPropertyTable::PropertyList*
-nsPropertyTable::GetPropertyListFor(nsAtom* aPropertyName) const
+nsPropertyTable::GetPropertyListFor(const nsAtom* aPropertyName) const
 {
   PropertyList* result;
 
   for (result = mPropertyList; result; result = result->mNext) {
     if (result->Equals(aPropertyName)) {
       break;
     }
   }
--- a/dom/base/nsPropertyTable.h
+++ b/dom/base/nsPropertyTable.h
@@ -56,17 +56,17 @@ private:
 class nsPropertyTable
 {
  public:
   /**
    * Get the value of the property |aPropertyName| for node |aObject|.
    * |aResult|, if supplied, is filled in with a return status code.
    **/
   void* GetProperty(const nsPropertyOwner& aObject,
-                    nsAtom    *aPropertyName,
+                    const nsAtom *aPropertyName,
                     nsresult   *aResult = nullptr)
   {
     return GetPropertyInternal(aObject, aPropertyName, false, aResult);
   }
 
   /**
    * Set the value of the property |aPropertyName| to
    * |aPropertyValue| for node |aObject|.  |aDtor| is a destructor for the
@@ -92,25 +92,25 @@ class nsPropertyTable
     return SetPropertyInternal(aObject, aPropertyName, aPropertyValue,
                                aDtor, aDtorData, aTransfer);
   }
 
   /**
    * Delete the property |aPropertyName| in the global category for object
    * |aObject|. The property's destructor function will be called.
    */
-  nsresult DeleteProperty(nsPropertyOwner aObject, nsAtom* aPropertyName);
+  nsresult DeleteProperty(nsPropertyOwner aObject, const nsAtom* aPropertyName);
 
   /**
    * Unset the property |aPropertyName| in the global category for object
    * |aObject|, but do not call the property's destructor function.  The
    * property value is returned.
    */
   void* UnsetProperty(const nsPropertyOwner& aObject,
-                      nsAtom* aPropertyName,
+                      const nsAtom* aPropertyName,
                       nsresult* aStatus = nullptr)
   {
     return GetPropertyInternal(aObject, aPropertyName, true, aStatus);
   }
 
   /**
    * Deletes all of the properties for object |aObject|, calling the
    * destructor function for each property.
@@ -162,19 +162,19 @@ class nsPropertyTable
 
   class PropertyList;
 
   size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
 
  private:
   void DestroyPropertyList();
-  PropertyList* GetPropertyListFor(nsAtom* aPropertyName) const;
+  PropertyList* GetPropertyListFor(const nsAtom* aPropertyName) const;
   void* GetPropertyInternal(nsPropertyOwner aObject,
-                            nsAtom* aPropertyName,
+                            const nsAtom* aPropertyName,
                             bool aRemove,
                             nsresult* aStatus);
   nsresult SetPropertyInternal(nsPropertyOwner aObject,
                                nsAtom* aPropertyName,
                                void* aPropertyValue,
                                NSPropertyDtorFunc  aDtor,
                                void* aDtorData,
                                bool aTransfer);
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -4952,16 +4952,17 @@ WorkerPrivate::ConnectMessagePort(JSCont
   }
 
   GlobalObject globalObject(aCx, jsGlobal);
   if (globalObject.Failed()) {
     return false;
   }
 
   RootedDictionary<MessageEventInit> init(aCx);
+  init.mData = JS_GetEmptyStringValue(aCx);
   init.mBubbles = false;
   init.mCancelable = false;
   init.mSource.SetValue().SetAsMessagePort() = port;
   if (!init.mPorts.AppendElement(port.forget(), fallible)) {
     return false;
   }
 
   RefPtr<MessageEvent> event =
--- a/gfx/layers/LayersLogging.h
+++ b/gfx/layers/LayersLogging.h
@@ -9,16 +9,17 @@
 
 #include "FrameMetrics.h"               // for FrameMetrics
 #include "mozilla/gfx/Matrix.h"         // for Matrix4x4
 #include "mozilla/gfx/Point.h"          // for IntSize, etc
 #include "mozilla/gfx/TiledRegion.h"    // for TiledRegion
 #include "mozilla/gfx/Types.h"          // for SamplingFilter, SurfaceFormat
 #include "mozilla/layers/CompositorTypes.h"  // for TextureFlags
 #include "mozilla/layers/WebRenderLayersLogging.h"
+#include "mozilla/layers/ZoomConstraints.h"
 #include "nsAString.h"
 #include "nsPrintfCString.h"            // for nsPrintfCString
 #include "nsRegion.h"                   // for nsRegion, nsIntRegion
 #include "nscore.h"                     // for nsACString, etc
 
 struct nsRectAbsolute;
 
 namespace mozilla {
--- a/gfx/layers/wr/IpcResourceUpdateQueue.h
+++ b/gfx/layers/wr/IpcResourceUpdateQueue.h
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFX_WR_IPCRESOURCEUPDATEQUEUE_H
 #define GFX_WR_IPCRESOURCEUPDATEQUEUE_H
 
 #include "mozilla/layers/WebRenderMessages.h"
 #include "mozilla/layers/RefCountedShmem.h"
+#include "mozilla/layers/TextureClient.h"
 #include "mozilla/webrender/WebRenderTypes.h"
 
 namespace mozilla {
 namespace ipc {
 class IShmemAllocator;
 }
 namespace wr {
 
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -8,16 +8,17 @@
 #define MOZILLA_LAYERS_WEBRENDERAPI_H
 
 #include <vector>
 #include <unordered_map>
 #include <unordered_set>
 
 #include "mozilla/AlreadyAddRefed.h"
 #include "mozilla/gfx/CompositorHitTestInfo.h"
+#include "mozilla/layers/IpcResourceUpdateQueue.h"
 #include "mozilla/layers/ScrollableLayerGuid.h"
 #include "mozilla/layers/SyncObject.h"
 #include "mozilla/Range.h"
 #include "mozilla/webrender/webrender_ffi.h"
 #include "mozilla/webrender/WebRenderTypes.h"
 #include "GLTypes.h"
 #include "Units.h"
 
--- a/js/src/builtin/String.cpp
+++ b/js/src/builtin/String.cpp
@@ -2739,16 +2739,28 @@ BuildFlatRopeReplacement(JSContext* cx, 
      * through it, building a new rope.
      */
     StringSegmentRange r(cx);
     if (!r.init(textstr)) {
         return nullptr;
     }
 
     RopeBuilder builder(cx);
+
+    /*
+     * Special case when the pattern string is '', which matches to the
+     * head of the string and doesn't overlap with any component of the rope.
+     */
+    if (patternLength == 0) {
+        MOZ_ASSERT(match == 0);
+        if (!builder.append(repstr)) {
+            return nullptr;
+        }
+    }
+
     size_t pos = 0;
     while (!r.empty()) {
         RootedString str(cx, r.front());
         size_t len = str->length();
         size_t strEnd = pos + len;
         if (pos < matchEnd && strEnd > match) {
             /*
              * We need to special-case any part of the rope that overlaps
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -1718,16 +1718,31 @@ NewRope(JSContext* cx, unsigned argc, Va
         return false;
     }
 
     args.rval().setString(str);
     return true;
 }
 
 static bool
+IsRope(JSContext* cx, unsigned argc, Value* vp)
+{
+    CallArgs args = CallArgsFromVp(argc, vp);
+
+    if (!args.get(0).isString()) {
+        JS_ReportErrorASCII(cx, "isRope requires a string argument.");
+        return false;
+    }
+
+    JSString* str = args[0].toString();
+    args.rval().setBoolean(str->isRope());
+    return true;
+}
+
+static bool
 EnsureFlatString(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 
     if (args.length() != 1 || !args[0].isString()) {
         JS_ReportErrorASCII(cx, "ensureFlatString takes exactly one string argument.");
         return false;
     }
@@ -5945,16 +5960,20 @@ static const JSFunctionSpecWithHelp Test
 #endif // defined(DEBUG) || defined(JS_OOM_BREAKPOINT)
 
     JS_FN_HELP("newRope", NewRope, 3, 0,
 "newRope(left, right[, options])",
 "  Creates a rope with the given left/right strings.\n"
 "  Available options:\n"
 "    nursery: bool - force the string to be created in/out of the nursery, if possible.\n"),
 
+    JS_FN_HELP("isRope", IsRope, 1, 0,
+"isRope(str)",
+"  Returns true if the parameter is a rope"),
+
     JS_FN_HELP("settlePromiseNow", SettlePromiseNow, 1, 0,
 "settlePromiseNow(promise)",
 "  'Settle' a 'promise' immediately. This just marks the promise as resolved\n"
 "  with a value of `undefined` and causes the firing of any onPromiseSettled\n"
 "  hooks set on Debugger instances that are observing the given promise's\n"
 "  global as a debuggee."),
     JS_FN_HELP("getWaitForAllPromise", GetWaitForAllPromise, 1, 0,
 "getWaitForAllPromise(densePromisesArray)",
--- a/js/src/jit/MacroAssembler.h
+++ b/js/src/jit/MacroAssembler.h
@@ -1608,17 +1608,18 @@ class MacroAssembler : public MacroAssem
                                       wasm::BytecodeOffset off, Label* rejoin)
         DEFINED_ON(arm, arm64, x86_shared, mips_shared);
 
     // This function takes care of loading the callee's TLS and pinned regs but
     // it is the caller's responsibility to save/restore TLS or pinned regs.
     void wasmCallImport(const wasm::CallSiteDesc& desc, const wasm::CalleeDesc& callee);
 
     // WasmTableCallIndexReg must contain the index of the indirect call.
-    void wasmCallIndirect(const wasm::CallSiteDesc& desc, const wasm::CalleeDesc& callee, bool needsBoundsCheck);
+    void wasmCallIndirect(const wasm::CallSiteDesc& desc, const wasm::CalleeDesc& callee,
+                          bool needsBoundsCheck);
 
     // This function takes care of loading the pointer to the current instance
     // as the implicit first argument. It preserves TLS and pinned registers.
     // (TLS & pinned regs are non-volatile registers in the system ABI).
     void wasmCallBuiltinInstanceMethod(const wasm::CallSiteDesc& desc, const ABIArg& instanceArg,
                                        wasm::SymbolicAddress builtin);
 
     // As enterFakeExitFrame(), but using register conventions appropriate for
new file mode 100644
--- /dev/null
+++ b/js/src/tests/non262/String/replace-rope-empty.js
@@ -0,0 +1,28 @@
+var BUGNUMBER = 1509768;
+var summary = "String#replace with an empty string pattern on a rope should prepend the replacement string.";
+
+print(BUGNUMBER + ": " + summary);
+
+// Rope is created when the string length >= 24.
+//
+// This testcase depends on that condition to reliably test the code for
+// String#replace on a rope.
+//
+// Please rewrite this testcase when the following assertion fails.
+assertEq(isRope("a".repeat(23)), false);
+assertEq(isRope("a".repeat(24)), true);
+
+// Not a rope.
+assertEq("a".repeat(23).replace("", "foo"),
+         "foo" + "a".repeat(23));
+assertEq("a".repeat(23).replace("", ""),
+         "a".repeat(23));
+
+// A rope.
+assertEq("a".repeat(24).replace("", "foo"),
+         "foo" + "a".repeat(24));
+assertEq("a".repeat(24).replace("", ""),
+         "a".repeat(24));
+
+if (typeof reportCompare === "function")
+    reportCompare(true, true);
--- a/js/src/wasm/WasmCompile.cpp
+++ b/js/src/wasm/WasmCompile.cpp
@@ -537,28 +537,16 @@ wasm::CompileBuffer(const CompileArgs& a
     CompilerEnvironment compilerEnv(args);
     ModuleEnvironment env(args.gcTypesConfigured,
                           &compilerEnv,
                           args.sharedMemoryEnabled ? Shareable::True : Shareable::False);
     if (!DecodeModuleEnvironment(d, &env)) {
         return nullptr;
     }
 
-#ifdef ENABLE_WASM_CRANELIFT
-    if (compilerEnv.tier() == Tier::Optimized &&
-        compilerEnv.optimizedBackend() == OptimizedBackend::Cranelift)
-    {
-        // At the moment, Cranelift performs no validation, so validate
-        // explicitly.
-        if (!ValidateForCranelift(bytecode, error)) {
-           return nullptr;
-        }
-    }
-#endif
-
     ModuleGenerator mg(args, &env, nullptr, error);
     if (!mg.init()) {
         return nullptr;
     }
 
     if (!DecodeCodeSection(env, d, mg)) {
         return nullptr;
     }
--- a/js/src/wasm/WasmCraneliftCompile.cpp
+++ b/js/src/wasm/WasmCraneliftCompile.cpp
@@ -274,20 +274,22 @@ env_global(const CraneliftModuleEnvironm
     return &env->env.globals[globalIndex];
 }
 
 bool
 wasm::CraneliftCompileFunctions(const ModuleEnvironment& env,
                                 LifoAlloc& lifo,
                                 const FuncCompileInputVector& inputs,
                                 CompiledCode* code,
+                                ExclusiveDeferredValidationState& dvs,
                                 UniqueChars* error)
 {
     MOZ_ASSERT(env.tier() == Tier::Optimized);
     MOZ_ASSERT(env.optimizedBackend() == OptimizedBackend::Cranelift);
+    MOZ_ASSERT(!env.isAsmJS());
 
     AutoCranelift compiler(env);
     if (!compiler.init()) {
         return false;
     }
 
     TempAllocator alloc(&lifo);
     JitContext jitContext(&alloc);
@@ -296,16 +298,21 @@ wasm::CraneliftCompileFunctions(const Mo
 
     // Swap in already-allocated empty vectors to avoid malloc/free.
     MOZ_ASSERT(code->empty());
     if (!code->swap(masm)) {
         return false;
     }
 
     for (const FuncCompileInput& func : inputs) {
+        Decoder d(func.begin, func.end, func.lineOrBytecode, error);
+        if (!ValidateFunctionBody(env, func.index, func.end - func.begin, d, dvs)) {
+            return false;
+        }
+
         CraneliftFuncCompileInput clifInput(func);
 
         CraneliftCompiledFunc clifFunc;
         if (!cranelift_compile_function(compiler, &clifInput, &clifFunc)) {
             *error = JS_smprintf("Cranelift error in clifFunc #%u", clifInput.index);
             return false;
         }
 
--- a/js/src/wasm/WasmCraneliftCompile.h
+++ b/js/src/wasm/WasmCraneliftCompile.h
@@ -27,14 +27,15 @@ namespace js {
 namespace wasm {
 
 // Generates code with Cranelift.
 MOZ_MUST_USE bool
 CraneliftCompileFunctions(const ModuleEnvironment& env,
                          LifoAlloc& lifo,
                          const FuncCompileInputVector& inputs,
                          CompiledCode* code,
+                         ExclusiveDeferredValidationState& dvs,
                          UniqueChars* error);
 
 } // namespace wasm
 } // namespace js
 
 #endif // wasm_cranelift_compile_h
--- a/js/src/wasm/WasmGenerator.cpp
+++ b/js/src/wasm/WasmGenerator.cpp
@@ -667,17 +667,17 @@ ExecuteCompileTask(CompileTask* task, Un
     MOZ_ASSERT(task->lifo.isEmpty());
     MOZ_ASSERT(task->output.empty());
 
     switch (task->env.tier()) {
       case Tier::Optimized:
 #ifdef ENABLE_WASM_CRANELIFT
         if (task->env.optimizedBackend() == OptimizedBackend::Cranelift) {
             if (!CraneliftCompileFunctions(task->env, task->lifo, task->inputs, &task->output,
-                                           error))
+                                           task->dvs, error))
             {
                 return false;
             }
             break;
         }
 #endif
         MOZ_ASSERT(task->env.optimizedBackend() == OptimizedBackend::Ion);
         if (!IonCompileFunctions(task->env, task->lifo, task->inputs,
--- a/js/src/wasm/WasmValidate.cpp
+++ b/js/src/wasm/WasmValidate.cpp
@@ -2528,18 +2528,17 @@ DecodeFunctionBody(Decoder& d, const Mod
     if (!ValidateFunctionBody(env, funcIndex, bodySize, d, dvs)) {
         return false;
     }
 
     return true;
 }
 
 static bool
-DecodeCodeSection(Decoder& d, ModuleEnvironment* env,
-                  ExclusiveDeferredValidationState& dvs)
+DecodeCodeSection(Decoder& d, ModuleEnvironment* env, ExclusiveDeferredValidationState& dvs)
 {
     if (!env->codeSection) {
         if (env->numFuncDefs() != 0) {
             return d.fail("expected code section");
         }
         return true;
     }
 
@@ -2858,40 +2857,8 @@ wasm::Validate(JSContext* cx, const Shar
 
     if (!DecodeModuleTail(d, &env, dvs)) {
         return false;
     }
 
     MOZ_ASSERT(!*error, "unreported error in decoding");
     return true;
 }
-
-bool
-wasm::ValidateForCranelift(const ShareableBytes& bytecode, UniqueChars* error)
-{
-    Decoder d(bytecode.bytes, 0, error);
-
-    // Cranelift doesn't support GC yet.
-    HasGcTypes hasGcTypes = HasGcTypes::False;
-
-    // Cranelift doesn't support threads yet.
-    Shareable threadSupport = Shareable::False;
-
-    CompilerEnvironment compilerEnv(CompileMode::Once, Tier::Optimized,
-                                    OptimizedBackend::Cranelift, DebugEnabled::False, hasGcTypes);
-    ModuleEnvironment env(hasGcTypes, &compilerEnv, threadSupport);
-
-    if (!DecodeModuleEnvironment(d, &env)) {
-        return false;
-    }
-
-    ExclusiveDeferredValidationState dvs(mutexid::WasmDeferredValidation);
-
-    if (!DecodeCodeSection(d, &env, dvs)) {
-        return false;
-    }
-    if (!DecodeModuleTail(d, &env, dvs)) {
-        return false;
-    }
-
-    MOZ_ASSERT(!*error, "unreported error in decoding");
-    return true;
-}
--- a/js/src/wasm/WasmValidate.h
+++ b/js/src/wasm/WasmValidate.h
@@ -927,17 +927,12 @@ ConvertMemoryPagesToBytes(Limits* memory
 // Validate an entire module, returning true if the module was validated
 // successfully. If Validate returns false:
 //  - if *error is null, the caller should report out-of-memory
 //  - otherwise, there was a legitimate error described by *error
 
 MOZ_MUST_USE bool
 Validate(JSContext* cx, const ShareableBytes& bytecode, UniqueChars* error);
 
-// Same, but don't require a JSContext.
-MOZ_MUST_USE bool
-ValidateForCranelift(const ShareableBytes& bytecode, UniqueChars* error);
-
-
 }  // namespace wasm
 }  // namespace js
 
 #endif // namespace wasm_validate_h
--- a/js/src/wasm/cranelift/build.rs
+++ b/js/src/wasm/cranelift/build.rs
@@ -45,34 +45,40 @@ fn main() {
         .clang_args(&[
             "-x",
             "c++",
             "-std=gnu++14",
             "-fno-sized-deallocation",
             "-DRUST_BINDGEN",
         ]).clang_arg("-I../..");
 
-    let path = PathBuf::from(env::var_os("MOZ_TOPOBJDIR").unwrap())
-        .join("js/src/rust/extra-bindgen-flags");
+    match env::var_os("MOZ_TOPOBJDIR") {
+        Some(path) => {
+            let path = PathBuf::from(path).join("js/src/rust/extra-bindgen-flags");
 
-    let mut extra_flags = String::new();
-    File::open(&path)
-        .expect("Failed to open extra-bindgen-flags file")
-        .read_to_string(&mut extra_flags)
-        .expect("Failed to read extra-bindgen-flags file");
+            let mut extra_flags = String::new();
+            File::open(&path)
+                .expect("Failed to open extra-bindgen-flags file")
+                .read_to_string(&mut extra_flags)
+                .expect("Failed to read extra-bindgen-flags file");
 
-    let display_path = path.to_str().expect("path is utf8 encoded");
-    println!("cargo:rerun-if-changed={}", display_path);
+            let display_path = path.to_str().expect("path is utf8 encoded");
+            println!("cargo:rerun-if-changed={}", display_path);
 
-    let extra_flags: Vec<String> = extra_flags
-        .split_whitespace()
-        .map(|s| s.to_owned())
-        .collect();
-    for flag in extra_flags {
-        bindings = bindings.clang_arg(flag);
+            let extra_flags: Vec<String> = extra_flags
+                .split_whitespace()
+                .map(|s| s.to_owned())
+                .collect();
+            for flag in extra_flags {
+                bindings = bindings.clang_arg(flag);
+            }
+        }
+        None => {
+            println!("cargo:warning={}", "MOZ_TOPOBJDIR should be set by default, otherwise the build is not guaranted to finish.");
+        }
     }
 
     let bindings = bindings
         .generate()
         .expect("Unable to generate baldrapi.h bindings");
 
     // Write the bindings to the $OUT_DIR/bindings.rs file.
     let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
--- a/js/src/wasm/cranelift/src/baldrapi.rs
+++ b/js/src/wasm/cranelift/src/baldrapi.rs
@@ -18,17 +18,17 @@
 //! The Baldr API consists of a set of C functions and some associated types.
 
 #![allow(non_upper_case_globals)]
 #![allow(non_camel_case_types)]
 #![allow(non_snake_case)]
 
 use cranelift_codegen::binemit::CodeOffset;
 use cranelift_codegen::entity::EntityRef;
-use cranelift_codegen::ir;
+use cranelift_codegen::ir::SourceLoc;
 use cranelift_wasm::FuncIndex;
 
 use compile::CompiledFunc;
 
 include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
 
 impl CraneliftFuncCompileInput {
     pub fn bytecode(&self) -> &[u8] {
@@ -46,44 +46,44 @@ impl CraneliftCompiledFunc {
         self.containsCalls = compiled_func.contains_calls;
 
         self.code = compiled_func.code_buffer.as_ptr();
         self.codeSize = compiled_func.code_buffer.len();
     }
 }
 
 impl CraneliftMetadataEntry {
-    pub fn direct_call(offset: CodeOffset, func_index: FuncIndex, srcloc: ir::SourceLoc) -> Self {
+    pub fn direct_call(offset: CodeOffset, func_index: FuncIndex, srcloc: SourceLoc) -> Self {
         Self {
             which: CraneliftMetadataEntry_Which_DirectCall,
             offset,
             srcLoc: srcloc.bits(),
             extra: func_index.index(),
         }
     }
 
-    pub fn indirect_call(offset: CodeOffset, srcloc: ir::SourceLoc) -> Self {
+    pub fn indirect_call(offset: CodeOffset, srcloc: SourceLoc) -> Self {
         Self {
             which: CraneliftMetadataEntry_Which_IndirectCall,
             offset,
             srcLoc: srcloc.bits(),
             extra: 0,
         }
     }
 
-    pub fn trap(offset: CodeOffset, srcloc: ir::SourceLoc, which: Trap) -> Self {
+    pub fn trap(offset: CodeOffset, srcloc: SourceLoc, which: Trap) -> Self {
         Self {
             which: CraneliftMetadataEntry_Which_Trap,
             offset,
             srcLoc: srcloc.bits(),
             extra: which as usize,
         }
     }
 
-    pub fn memory_access(offset: CodeOffset, srcloc: ir::SourceLoc) -> Self {
+    pub fn memory_access(offset: CodeOffset, srcloc: SourceLoc) -> Self {
         Self {
             which: CraneliftMetadataEntry_Which_MemoryAccess,
             offset,
             srcLoc: srcloc.bits(),
             extra: 0,
         }
     }
 
--- a/js/src/wasm/cranelift/src/baldrdash.rs
+++ b/js/src/wasm/cranelift/src/baldrdash.rs
@@ -12,46 +12,36 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 // Safe wrappers to the low-level ABI.  This re-exports all types in
 // baldrapi but none of the functions.
 
 use baldrapi::CraneliftModuleEnvironment;
-use cranelift_codegen::binemit::CodeOffset;
-use cranelift_codegen::cursor::{Cursor, FuncCursor};
+use cranelift_codegen::cursor::FuncCursor;
 use cranelift_codegen::entity::EntityRef;
 use cranelift_codegen::ir::immediates::{Ieee32, Ieee64};
-use cranelift_codegen::ir::stackslot::StackSize;
 use cranelift_codegen::ir::{self, InstBuilder};
-use cranelift_codegen::{CodegenError, CodegenResult};
 use cranelift_wasm::{FuncIndex, GlobalIndex, SignatureIndex, TableIndex};
 use std::mem;
 use std::slice;
 
 use baldrapi;
 
 pub use baldrapi::BD_SymbolicAddress as SymbolicAddress;
 pub use baldrapi::BD_ValType as ValType;
 pub use baldrapi::CraneliftCompiledFunc as CompiledFunc;
 pub use baldrapi::CraneliftFuncCompileInput as FuncCompileInput;
 pub use baldrapi::CraneliftMetadataEntry as MetadataEntry;
 pub use baldrapi::CraneliftStaticEnvironment as StaticEnvironment;
 pub use baldrapi::FuncTypeIdDescKind;
 pub use baldrapi::Trap;
 pub use baldrapi::TypeCode;
 
-pub enum ConstantValue {
-    I32(i32),
-    I64(i64),
-    F32(f32),
-    F64(f64),
-}
-
 /// Convert a `TypeCode` into the equivalent Cranelift type.
 ///
 /// We expect Cranelift's `VOID` type to go away in the future, so use `None` to represent a
 /// function without a return value.
 impl Into<Option<ir::Type>> for TypeCode {
     fn into(self) -> Option<ir::Type> {
         match self {
             TypeCode::I32 => Some(ir::types::I32),
@@ -106,17 +96,17 @@ impl GlobalDesc {
     }
 
     /// Insert an instruction at `pos` that materialized the constant value.
     pub fn emit_constant(self, pos: &mut FuncCursor) -> ir::Value {
         unsafe {
             let v = baldrapi::global_constantValue(self.0);
             // Note that the floating point constants below
             match v.t {
-                TypeCode::I32 => pos.ins().iconst(ir::types::I32, v.u.i32 as i64),
+                TypeCode::I32 => pos.ins().iconst(ir::types::I32, i64::from(v.u.i32)),
                 TypeCode::I64 => pos.ins().iconst(ir::types::I64, v.u.i64),
                 TypeCode::F32 => pos.ins().f32const(Ieee32::with_bits(v.u.i32 as u32)),
                 TypeCode::F64 => pos.ins().f64const(Ieee64::with_bits(v.u.i64 as u64)),
                 _ => panic!("unexpected type"),
             }
         }
     }
 
@@ -196,11 +186,11 @@ impl<'a> ModuleEnvironment<'a> {
     }
     pub fn table(&self, table_index: TableIndex) -> TableDesc {
         TableDesc(unsafe { baldrapi::env_table(self.env, table_index.index()) })
     }
     pub fn global(&self, global_index: GlobalIndex) -> GlobalDesc {
         GlobalDesc(unsafe { baldrapi::env_global(self.env, global_index.index()) })
     }
     pub fn min_memory_length(&self) -> i64 {
-        self.env.min_memory_length as i64
+        i64::from(self.env.min_memory_length)
     }
 }
--- a/js/src/wasm/cranelift/src/compile.rs
+++ b/js/src/wasm/cranelift/src/compile.rs
@@ -15,28 +15,24 @@
 
 //! Cranelift WebAssembly function compiler.
 //!
 //! This module defines the `compile()` function which uses Cranelift to compile a single
 //! WebAssembly function.
 
 use baldrdash as bd;
 use cpu::make_isa;
-use cranelift_codegen::binemit::{Addend, CodeOffset, NullTrapSink, Reloc, RelocSink, TrapSink};
-use cranelift_codegen::cursor::{Cursor, FuncCursor};
+use cranelift_codegen::binemit::{Addend, CodeOffset, NullTrapSink, Reloc, RelocSink};
 use cranelift_codegen::entity::EntityRef;
+use cranelift_codegen::ir;
 use cranelift_codegen::ir::stackslot::StackSize;
-use cranelift_codegen::ir::{InstBuilder, SourceLoc, TrapCode};
 use cranelift_codegen::isa::TargetIsa;
-use cranelift_codegen::settings::Flags;
-use cranelift_codegen::{self, ir};
-use cranelift_codegen::{CodegenError, CodegenResult};
-use cranelift_wasm::{
-    self, FuncIndex, GlobalIndex, MemoryIndex, SignatureIndex, TableIndex, WasmResult,
-};
+use cranelift_codegen::CodegenResult;
+use cranelift_codegen::Context;
+use cranelift_wasm::{FuncIndex, FuncTranslator, WasmResult};
 use std::fmt;
 use std::mem;
 use utils::DashResult;
 use wasm2clif::{init_sig, native_pointer_size, TransEnv};
 
 /// The result of a function's compilation: code + metadata.
 pub struct CompiledFunc {
     pub frame_pushed: StackSize,
@@ -65,33 +61,33 @@ impl CompiledFunc {
 }
 
 /// A batch compiler holds on to data structures that can be recycled for multiple function
 /// compilations.
 pub struct BatchCompiler<'a, 'b> {
     static_environ: &'a bd::StaticEnvironment,
     environ: bd::ModuleEnvironment<'b>,
     isa: Box<TargetIsa>,
-    context: cranelift_codegen::Context,
-    trans: cranelift_wasm::FuncTranslator,
+    context: Context,
+    trans: FuncTranslator,
     pub current_func: CompiledFunc,
 }
 
 impl<'a, 'b> BatchCompiler<'a, 'b> {
     pub fn new(
         static_environ: &'a bd::StaticEnvironment,
         environ: bd::ModuleEnvironment<'b>,
     ) -> DashResult<Self> {
         // TODO: The target ISA could be shared by multiple batch compilers across threads.
         Ok(BatchCompiler {
             static_environ,
             environ,
             isa: make_isa(static_environ)?,
-            context: cranelift_codegen::Context::new(),
-            trans: cranelift_wasm::FuncTranslator::new(),
+            context: Context::new(),
+            trans: FuncTranslator::new(),
             current_func: CompiledFunc::new(),
         })
     }
 
     pub fn compile(&mut self) -> CodegenResult<()> {
         let size = self.context.compile(&*self.isa)?;
         self.binemit(size as usize)
     }
@@ -141,21 +137,17 @@ impl<'a, 'b> BatchCompiler<'a, 'b> {
             let current_size = self.current_func.code_buffer.len();
             // There's no way to do a proper uninitialized reserve, so first reserve and then
             // unsafely set the final size.
             self.current_func.code_buffer.reserve(size - current_size);
             unsafe { self.current_func.code_buffer.set_len(size) };
         }
 
         {
-            let eenv = &mut EmitEnv::new(
-                &self.context.func,
-                &self.environ,
-                &mut self.current_func.metadata,
-            );
+            let eenv = &mut EmitEnv::new(&mut self.current_func.metadata);
             let mut trap_sink = NullTrapSink {};
             unsafe {
                 let code_buffer = &mut self.current_func.code_buffer;
                 self.context.emit_to_memory(
                     &*self.isa,
                     code_buffer.as_mut_ptr(),
                     eenv,
                     &mut trap_sink,
@@ -168,17 +160,17 @@ impl<'a, 'b> BatchCompiler<'a, 'b> {
 
     /// Compute the `framePushed` argument to pass to `GenerateFunctionPrologue`. This is the
     /// number of frame bytes used by Cranelift, not counting the values pushed by the standard
     /// prologue generated by `GenerateFunctionPrologue`.
     fn frame_pushed(&self) -> StackSize {
         // Cranelift computes the total stack frame size including the pushed return address,
         // standard SM prologue pushes, and its own stack slots.
         let total = self.context.func.stack_slots.frame_size.expect("No frame");
-        let sm_pushed = self.isa.flags().baldrdash_prologue_words() as StackSize
+        let sm_pushed = StackSize::from(self.isa.flags().baldrdash_prologue_words())
             * mem::size_of::<usize>() as StackSize;
         total
             .checked_sub(sm_pushed)
             .expect("SpiderMonkey prologue pushes not counted")
     }
 
     /// Determine whether the current function may contain calls.
     fn contains_calls(&self) -> bool {
@@ -272,18 +264,18 @@ impl<'a, 'b> BatchCompiler<'a, 'b> {
 
         // This is a direct call, so the callee should be a non-imported wasm
         // function. We register both the call site *and* the target for relocation.
         let callee = match func.dfg[inst] {
             ir::InstructionData::Call { func_ref, .. } => &func.dfg.ext_funcs[func_ref].name,
             _ => panic!("Bad format for call"),
         };
 
-        let func_index = match callee {
-            &ir::ExternalName::User {
+        let func_index = match *callee {
+            ir::ExternalName::User {
                 namespace: 0,
                 index,
             } => FuncIndex::new(index as usize),
             _ => panic!("Direct call to {} unsupported", callee),
         };
 
         let srcloc = func.srclocs[inst];
         assert!(
@@ -422,68 +414,55 @@ pub fn wasm_function_name(func: FuncInde
 pub fn symbolic_function_name(sym: bd::SymbolicAddress) -> ir::ExternalName {
     ir::ExternalName::User {
         namespace: 1,
         index: sym as u32,
     }
 }
 
 /// References joined so we can implement `RelocSink`.
-struct EmitEnv<'a, 'b, 'c> {
-    func: &'a ir::Function,
-    env: &'b bd::ModuleEnvironment<'b>,
-    metadata: &'c mut Vec<bd::MetadataEntry>,
+struct EmitEnv<'a> {
+    metadata: &'a mut Vec<bd::MetadataEntry>,
 }
 
-impl<'a, 'b, 'c> EmitEnv<'a, 'b, 'c> {
-    pub fn new(
-        func: &'a ir::Function,
-        env: &'b bd::ModuleEnvironment,
-        metadata: &'c mut Vec<bd::MetadataEntry>,
-    ) -> EmitEnv<'a, 'b, 'c> {
-        EmitEnv {
-            func,
-            env,
-            metadata,
-        }
+impl<'a> EmitEnv<'a> {
+    pub fn new(metadata: &'a mut Vec<bd::MetadataEntry>) -> EmitEnv<'a> {
+        EmitEnv { metadata }
     }
 }
 
-impl<'a, 'b, 'c> RelocSink for EmitEnv<'a, 'b, 'c> {
+impl<'a> RelocSink for EmitEnv<'a> {
     fn reloc_ebb(&mut self, _offset: CodeOffset, _reloc: Reloc, _ebb_offset: CodeOffset) {
         unimplemented!();
     }
 
     fn reloc_external(
         &mut self,
         offset: CodeOffset,
         _reloc: Reloc,
         name: &ir::ExternalName,
         _addend: Addend,
     ) {
         // Decode the function name.
-        match name {
-            &ir::ExternalName::User {
-                namespace: 0,
-                index,
-            } => {
+        match *name {
+            ir::ExternalName::User { namespace: 0, .. } => {
                 // This is a direct function call handled by `emit_metadata` above.
             }
-            &ir::ExternalName::User {
+            ir::ExternalName::User {
                 namespace: 1,
                 index,
             } => {
                 // This is a symbolic function reference encoded by `symbolic_function_name()`.
                 let sym = index.into();
                 // The symbolic access patch address points *after* the stored pointer.
                 let offset = offset + native_pointer_size() as u32;
                 self.metadata
                     .push(bd::MetadataEntry::symbolic_access(offset, sym));
             }
-            &ir::ExternalName::LibCall(call) => {
+            ir::ExternalName::LibCall(call) => {
                 let sym = match call {
                     ir::LibCall::CeilF32 => bd::SymbolicAddress::CeilF32,
                     ir::LibCall::CeilF64 => bd::SymbolicAddress::CeilF64,
                     ir::LibCall::FloorF32 => bd::SymbolicAddress::FloorF32,
                     ir::LibCall::FloorF64 => bd::SymbolicAddress::FloorF64,
                     ir::LibCall::NearestF32 => bd::SymbolicAddress::NearestF32,
                     ir::LibCall::NearestF64 => bd::SymbolicAddress::NearestF64,
                     ir::LibCall::TruncF32 => bd::SymbolicAddress::TruncF32,
--- a/js/src/wasm/cranelift/src/cpu.rs
+++ b/js/src/wasm/cranelift/src/cpu.rs
@@ -18,20 +18,17 @@
 //! This module deals with the configuration of Cranelift to generate code for the current CPU that
 //! is compatible with the SpiderMonkey JIT.
 //!
 //! The main entry point is the `make_isa()` function which allocates a configured `TargetISA`
 //! object.
 
 use cranelift_codegen::isa;
 use cranelift_codegen::settings::{self, Configurable};
-use std::error;
-use std::mem;
 use std::str::FromStr;
-use target_lexicon;
 use utils::{BasicError, DashResult};
 
 use baldrdash::StaticEnvironment;
 
 impl From<isa::LookupError> for BasicError {
     fn from(err: isa::LookupError) -> BasicError {
         BasicError::new(err.to_string())
     }
--- a/js/src/wasm/cranelift/src/lib.rs
+++ b/js/src/wasm/cranelift/src/lib.rs
@@ -8,19 +8,16 @@
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
-#![allow(unused)]
-#![warn(unused_must_use)]
-
 extern crate cranelift_codegen;
 extern crate cranelift_wasm;
 #[macro_use]
 extern crate target_lexicon;
 #[macro_use]
 extern crate log;
 extern crate env_logger;
 
@@ -48,65 +45,65 @@ pub extern "C" fn cranelift_initialize()
         }
     }
 }
 
 /// Allocate a compiler for a module environment and return an opaque handle.
 ///
 /// This is declared in `clifapi.h`.
 #[no_mangle]
-pub extern "C" fn cranelift_compiler_create<'a, 'b>(
+pub unsafe extern "C" fn cranelift_compiler_create<'a, 'b>(
     static_env: *const StaticEnvironment,
     env: *const baldrapi::CraneliftModuleEnvironment,
 ) -> *mut BatchCompiler<'a, 'b> {
-    let env = unsafe { env.as_ref().unwrap() };
-    let static_env = unsafe { static_env.as_ref().unwrap() };
+    let env = env.as_ref().unwrap();
+    let static_env = static_env.as_ref().unwrap();
     match BatchCompiler::new(static_env, ModuleEnvironment::new(env)) {
         Ok(compiler) => Box::into_raw(Box::new(compiler)),
         Err(err) => {
             error!("When constructing the batch compiler: {}", err);
             ptr::null_mut()
         }
     }
 }
 
 /// Deallocate compiler.
 ///
 /// This is declared in `clifapi.h`.
 #[no_mangle]
-pub extern "C" fn cranelift_compiler_destroy(compiler: *mut BatchCompiler) {
+pub unsafe extern "C" fn cranelift_compiler_destroy(compiler: *mut BatchCompiler) {
     assert!(
         !compiler.is_null(),
         "NULL pointer passed to cranelift_compiler_destroy"
     );
     // Convert the pointer back into the box it came from. Then drop it.
-    let _box = unsafe { Box::from_raw(compiler) };
+    let _box = Box::from_raw(compiler);
 }
 
 /// Compile a single function.
 ///
 /// This is declared in `clifapi.h`.
 #[no_mangle]
-pub extern "C" fn cranelift_compile_function(
+pub unsafe extern "C" fn cranelift_compile_function(
     compiler: *mut BatchCompiler,
     data: *const FuncCompileInput,
     result: *mut CompiledFunc,
 ) -> bool {
-    let compiler = unsafe { compiler.as_mut().unwrap() };
-    let data = unsafe { data.as_ref().unwrap() };
+    let compiler = compiler.as_mut().unwrap();
+    let data = data.as_ref().unwrap();
 
     if let Err(e) = compiler.translate_wasm(data) {
         error!("Wasm translation error: {}\n{}", e, compiler);
         return false;
     };
 
     if let Err(e) = compiler.compile() {
         error!("Cranelift compilation error: {}\n{}", e, compiler);
         return false;
     };
 
     // TODO(bbouvier) if destroy is called while one of these objects is alive, you're going to
     // have a bad time. Would be nice to be able to enforce lifetimes accross languages, somehow.
-    let result = unsafe { result.as_mut().unwrap() };
+    let result = result.as_mut().unwrap();
     result.reset(&compiler.current_func);
 
     true
 }
--- a/js/src/wasm/cranelift/src/utils.rs
+++ b/js/src/wasm/cranelift/src/utils.rs
@@ -9,17 +9,16 @@
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 /// Helpers common to other source files here.
-use std;
 use std::error;
 use std::fmt;
 
 type DashError = Box<error::Error>;
 pub type DashResult<T> = Result<T, DashError>;
 
 /// A simple error type that contains a string message, used to wrap raw Cranelift error types
 /// which don't implement std::error::Error.
--- a/js/src/wasm/cranelift/src/wasm2clif.rs
+++ b/js/src/wasm/cranelift/src/wasm2clif.rs
@@ -22,22 +22,21 @@ use baldrdash as bd;
 use compile::{symbolic_function_name, wasm_function_name};
 use cranelift_codegen::cursor::{Cursor, FuncCursor};
 use cranelift_codegen::entity::{EntityRef, PrimaryMap, SecondaryMap};
 use cranelift_codegen::ir;
 use cranelift_codegen::ir::condcodes::IntCC;
 use cranelift_codegen::ir::InstBuilder;
 use cranelift_codegen::isa::{CallConv, TargetFrontendConfig, TargetIsa};
 use cranelift_codegen::packed_option::PackedOption;
-use cranelift_codegen::settings::Flags;
 use cranelift_wasm::{
-    self, FuncIndex, GlobalIndex, MemoryIndex, ReturnMode, SignatureIndex, TableIndex, WasmResult,
+    FuncEnvironment, FuncIndex, GlobalIndex, GlobalVariable, MemoryIndex, ReturnMode,
+    SignatureIndex, TableIndex, WasmResult,
 };
 use std::collections::HashMap;
-use target_lexicon::Triple;
 
 /// Get the integer type used for representing pointers on this platform.
 fn native_pointer_type() -> ir::Type {
     if cfg!(target_pointer_width = "64") {
         ir::types::I64
     } else {
         ir::types::I32
     }
@@ -368,38 +367,34 @@ impl<'a, 'b, 'c> TransEnv<'a, 'b, 'c> {
             gv_addr,
             offset32(self.static_env.realmFuncImportTlsOffset),
         );
         pos.ins()
             .store(flags, realm, cx, offset32(self.static_env.realmCxOffset));
     }
 }
 
-impl<'a, 'b, 'c> cranelift_wasm::FuncEnvironment for TransEnv<'a, 'b, 'c> {
+impl<'a, 'b, 'c> FuncEnvironment for TransEnv<'a, 'b, 'c> {
     fn target_config(&self) -> TargetFrontendConfig {
         self.isa.frontend_config()
     }
 
     fn pointer_type(&self) -> ir::Type {
         native_pointer_type()
     }
 
-    fn make_global(
-        &mut self,
-        func: &mut ir::Function,
-        index: GlobalIndex,
-    ) -> cranelift_wasm::GlobalVariable {
+    fn make_global(&mut self, func: &mut ir::Function, index: GlobalIndex) -> GlobalVariable {
         let global = self.env.global(index);
         if global.is_constant() {
             // Constant globals have a known value at compile time. We insert an instruction to
             // materialize the constant at the front of the entry block.
             let mut pos = FuncCursor::new(func);
             pos.next_ebb().expect("empty function");
             pos.next_inst();
-            cranelift_wasm::GlobalVariable::Const(global.emit_constant(&mut pos))
+            GlobalVariable::Const(global.emit_constant(&mut pos))
         } else {
             // This is a global variable. Here we don't care if it is mutable or not.
             let offset = global.tls_offset();
             let mut gv = self.get_vmctx_gv(func);
 
             // Some globals are represented as a pointer to the actual data, in which case we
             // must do an extra dereference to get to them.
             if global.is_indirect() {
@@ -414,17 +409,17 @@ impl<'a, 'b, 'c> cranelift_wasm::FuncEnv
                     base: gv,
                     offset: imm64(offset),
                     global_type: native_pointer_type(),
                 });
             }
 
             // Create a Cranelift global variable. We don't need to remember the reference, the
             // function translator does that for us.
-            cranelift_wasm::GlobalVariable::Memory {
+            GlobalVariable::Memory {
                 gv,
                 ty: global.value_type().into(),
             }
         }
     }
 
     fn make_heap(&mut self, func: &mut ir::Function, index: MemoryIndex) -> ir::Heap {
         assert_eq!(index.index(), 0, "Only one WebAssembly memory supported");
@@ -530,17 +525,16 @@ impl<'a, 'b, 'c> cranelift_wasm::FuncEnv
         table: ir::Table,
         sig_index: SignatureIndex,
         sig_ref: ir::SigRef,
         callee: ir::Value,
         call_args: &[ir::Value],
     ) -> WasmResult<ir::Inst> {
         let wsig = self.env.signature(sig_index);
 
-        // TODO: When compiling asm.js, the table index in inferred from the signature index.
         // Currently, WebAssembly doesn't support multiple tables. That may change.
         assert_eq!(table_index.index(), 0);
         let wtable = self.get_table(pos.func, table_index);
 
         // Follows `MacroAssembler::wasmCallIndirect`:
 
         // 1. Materialize the signature ID.
         let sigid_value = match wsig.id_kind() {
@@ -684,33 +678,32 @@ impl<'a, 'b, 'c> cranelift_wasm::FuncEnv
                 .Call(ir::Opcode::Call, ir::types::INVALID, callee, args)
                 .0)
         }
     }
 
     fn translate_memory_grow(
         &mut self,
         mut pos: FuncCursor,
-        index: MemoryIndex,
-        heap: ir::Heap,
+        _index: MemoryIndex,
+        _heap: ir::Heap,
         val: ir::Value,
     ) -> WasmResult<ir::Value> {
-        use cranelift_codegen::ir::types::I32;
         // We emit a call to `uint32_t growMemory_i32(Instance* instance, uint32_t delta)` via a
         // stub.
         let (fnref, sigref) =
             self.symbolic_funcref(pos.func, bd::SymbolicAddress::GrowMemory, || {
                 let mut sig = ir::Signature::new(CallConv::Baldrdash);
                 sig.params.push(ir::AbiParam::new(native_pointer_type()));
-                sig.params.push(ir::AbiParam::new(I32).uext());
+                sig.params.push(ir::AbiParam::new(ir::types::I32).uext());
                 sig.params.push(ir::AbiParam::special(
                     native_pointer_type(),
                     ir::ArgumentPurpose::VMContext,
                 ));
-                sig.returns.push(ir::AbiParam::new(I32).uext());
+                sig.returns.push(ir::AbiParam::new(ir::types::I32).uext());
                 sig
             });
 
         // Get the instance pointer needed by `growMemory_i32`.
         let instance = self.load_instance(&mut pos);
         let vmctx = pos
             .func
             .special_param(ir::ArgumentPurpose::VMContext)
@@ -723,30 +716,29 @@ impl<'a, 'b, 'c> cranelift_wasm::FuncEnv
             .call_indirect(sigref, addr, &[instance, val, vmctx]);
         self.switch_to_wasm_tls_realm(&mut pos);
         Ok(pos.func.dfg.first_result(call))
     }
 
     fn translate_memory_size(
         &mut self,
         mut pos: FuncCursor,
-        index: MemoryIndex,
-        heap: ir::Heap,
+        _index: MemoryIndex,
+        _heap: ir::Heap,
     ) -> WasmResult<ir::Value> {
-        use cranelift_codegen::ir::types::I32;
         // We emit a call to `uint32_t currentMemory_i32(Instance* instance)` via a stub.
         let (fnref, sigref) =
             self.symbolic_funcref(pos.func, bd::SymbolicAddress::CurrentMemory, || {
                 let mut sig = ir::Signature::new(CallConv::Baldrdash);
                 sig.params.push(ir::AbiParam::new(native_pointer_type()));
                 sig.params.push(ir::AbiParam::special(
                     native_pointer_type(),
                     ir::ArgumentPurpose::VMContext,
                 ));
-                sig.returns.push(ir::AbiParam::new(I32).uext());
+                sig.returns.push(ir::AbiParam::new(ir::types::I32).uext());
                 sig
             });
 
         // Get the instance pointer needed by `currentMemory_i32`.
         let instance = self.load_instance(&mut pos);
         let vmctx = pos
             .func
             .special_param(ir::ArgumentPurpose::VMContext)
@@ -790,30 +782,15 @@ impl TableInfo {
             base: vmctx,
             offset,
             global_type: native_pointer_type(),
         });
 
         TableInfo { global }
     }
 
-    /// Load the table length.
-    pub fn load_length(&self, pos: &mut FuncCursor, addr: ir::Value) -> ir::Value {
-        pos.ins().load(ir::types::I32, ir::MemFlags::new(), addr, 0)
-    }
-
-    /// Load the table base.
-    pub fn load_base(&self, pos: &mut FuncCursor, addr: ir::Value) -> ir::Value {
-        pos.ins().load(
-            native_pointer_type(),
-            ir::MemFlags::new(),
-            addr,
-            native_pointer_size(),
-        )
-    }
-
     /// Get the size in bytes of each table entry.
     pub fn entry_size(&self) -> i64 {
         // Each entry is an `wasm::FunctionTableElem` which consists of the code pointer and a new
         // VM context pointer.
-        native_pointer_size() as i64 * 2
+        i64::from(native_pointer_size()) * 2
     }
 }
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -8,16 +8,17 @@
 
 #include "mozilla/AutoRestyleTimelineMarker.h"
 #include "mozilla/AutoTimelineMarker.h"
 #include "mozilla/ComputedStyle.h"
 #include "mozilla/ComputedStyleInlines.h"
 #include "mozilla/DocumentStyleRootIterator.h"
 #include "mozilla/GeckoBindings.h"
 #include "mozilla/LayerAnimationInfo.h"
+#include "mozilla/layers/AnimationInfo.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/ServoStyleSetInlines.h"
 #include "mozilla/Unused.h"
 #include "mozilla/ViewportFrame.h"
 #include "mozilla/dom/ChildIterator.h"
 #include "mozilla/dom/ElementInlines.h"
 #include "mozilla/dom/HTMLBodyElement.h"
 
@@ -48,16 +49,18 @@
 #include "SVGTextFrame.h"
 #include "ActiveLayerTracker.h"
 #include "nsSVGIntegrationUtils.h"
 
 #ifdef ACCESSIBILITY
 #include "nsAccessibilityService.h"
 #endif
 
+using mozilla::layers::AnimationInfo;
+
 using namespace mozilla::dom;
 using namespace mozilla::layers;
 
 namespace mozilla {
 
 RestyleManager::RestyleManager(nsPresContext* aPresContext)
   : mPresContext(aPresContext)
   , mRestyleGeneration(1)
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -5,16 +5,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "base/basictypes.h"
 
 #include "nsLayoutStatics.h"
 #include "nscore.h"
 
 #include "DateTimeFormat.h"
+#include "MediaManager.h"
+#include "mozilla/dom/ServiceWorkerRegistrar.h"
 #include "nsAttrValue.h"
 #include "nsColorNames.h"
 #include "nsComputedDOMStyle.h"
 #include "nsContentDLF.h"
 #include "nsContentUtils.h"
 #include "nsCSSAnonBoxes.h"
 #include "mozilla/css/ErrorReporter.h"
 #include "nsCSSKeywords.h"
--- a/layout/forms/nsColorControlFrame.cpp
+++ b/layout/forms/nsColorControlFrame.cpp
@@ -10,16 +10,17 @@
 #include "nsContentUtils.h"
 #include "nsCSSPseudoElements.h"
 #include "nsCheckboxRadioFrame.h"
 #include "nsGkAtoms.h"
 #include "nsIFormControl.h"
 #include "mozilla/dom/HTMLInputElement.h"
 #include "nsIDocument.h"
 
+using namespace mozilla;
 using mozilla::dom::Element;
 using mozilla::dom::HTMLInputElement;
 using mozilla::dom::CallerType;
 
 nsColorControlFrame::nsColorControlFrame(ComputedStyle* aStyle)
   : nsHTMLButtonControlFrame(aStyle, kClassID)
 {
 }
--- a/layout/forms/nsHTMLButtonControlFrame.cpp
+++ b/layout/forms/nsHTMLButtonControlFrame.cpp
@@ -3,16 +3,17 @@
 /* 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 "nsHTMLButtonControlFrame.h"
 
 #include "nsContainerFrame.h"
 #include "nsIFormControlFrame.h"
+#include "nsIFrameInlines.h"
 #include "nsPresContext.h"
 #include "nsGkAtoms.h"
 #include "nsButtonFrameRenderer.h"
 #include "nsCSSAnonBoxes.h"
 #include "nsCheckboxRadioFrame.h"
 #include "nsNameSpaceManager.h"
 #include "nsDisplayList.h"
 #include <algorithm>
--- a/layout/forms/nsLegendFrame.cpp
+++ b/layout/forms/nsLegendFrame.cpp
@@ -1,22 +1,27 @@
 /* -*- 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 "nsLegendFrame.h"
+
+#include "ComputedStyle.h"
 #include "nsIContent.h"
 #include "nsGenericHTMLElement.h"
 #include "nsAttrValueInlines.h"
 #include "nsHTMLParts.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsCheckboxRadioFrame.h"
+#include "WritingModes.h"
+
+using namespace mozilla;
 
 nsIFrame*
 NS_NewLegendFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle)
 {
 #ifdef DEBUG
   const nsStyleDisplay* disp = aStyle->StyleDisplay();
   NS_ASSERTION(!disp->IsAbsolutelyPositionedStyle() && !disp->IsFloatingStyle(),
                "Legends should not be positioned and should not float");
--- a/layout/generic/ScrollAnimationPhysics.h
+++ b/layout/generic/ScrollAnimationPhysics.h
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_layout_ScrollAnimationPhysics_h_
 #define mozilla_layout_ScrollAnimationPhysics_h_
 
 #include "mozilla/TimeStamp.h"
 #include "nsPoint.h"
+#include "Units.h"
 
 namespace mozilla {
 
 class ScrollAnimationPhysics
 {
 public:
   virtual void Update(const TimeStamp& aTime,
                       const nsPoint& aDestination,
--- a/layout/inspector/InspectorUtils.cpp
+++ b/layout/inspector/InspectorUtils.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/EventStates.h"
 
 #include "inLayoutUtils.h"
 
+#include "gfxTextRun.h"
 #include "nsArray.h"
 #include "nsAutoPtr.h"
 #include "nsIServiceManager.h"
 #include "nsString.h"
 #include "nsIStyleSheetLinkingElement.h"
 #include "nsIContentInlines.h"
 #include "nsIDocument.h"
 #include "nsIPresShell.h"
--- a/layout/inspector/ServoStyleRuleMap.cpp
+++ b/layout/inspector/ServoStyleRuleMap.cpp
@@ -5,21 +5,25 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ServoStyleRuleMap.h"
 
 #include "mozilla/css/GroupRule.h"
 #include "mozilla/dom/CSSImportRule.h"
 #include "mozilla/dom/CSSRuleBinding.h"
 #include "mozilla/dom/CSSStyleRule.h"
+#include "mozilla/dom/ShadowRoot.h"
 #include "mozilla/IntegerRange.h"
 #include "mozilla/ServoStyleSet.h"
 #include "mozilla/StyleSheetInlines.h"
 #include "nsDocument.h"
 #include "nsStyleSheetService.h"
+#include "nsXBLPrototypeResources.h"
+
+using namespace mozilla::dom;
 
 namespace mozilla {
 
 void
 ServoStyleRuleMap::EnsureTable(ServoStyleSet& aStyleSet)
 {
   if (!IsEmpty()) {
     return;
--- a/layout/inspector/inDeepTreeWalker.cpp
+++ b/layout/inspector/inDeepTreeWalker.cpp
@@ -2,25 +2,29 @@
 /* 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 "inDeepTreeWalker.h"
 #include "inLayoutUtils.h"
 
+#include "BindingStyleRule.h"
+#include "InspectorUtils.h"
 #include "nsString.h"
 #include "nsIDocument.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIContent.h"
 #include "ChildIterator.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/InspectorUtils.h"
 #include "mozilla/dom/NodeFilterBinding.h"
 
+using mozilla::dom::InspectorUtils;
+
 /*****************************************************************************
  * This implementation does not currently operaate according to the W3C spec.
  * In particular it does NOT handle DOM mutations during the walk.  It also
  * ignores whatToShow and the filter.
  *****************************************************************************/
 
 ////////////////////////////////////////////////////
 
--- a/layout/mathml/nsMathMLOperators.cpp
+++ b/layout/mathml/nsMathMLOperators.cpp
@@ -3,16 +3,17 @@
 /* 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 "nsMathMLOperators.h"
 #include "nsCOMPtr.h"
 #include "nsDataHashtable.h"
 #include "nsHashKeys.h"
+#include "nsNetUtil.h"
 #include "nsTArray.h"
 
 #include "nsIPersistentProperties2.h"
 #include "nsISimpleEnumerator.h"
 #include "nsCRT.h"
 
 // operator dictionary entry
 struct OperatorData {
--- a/layout/mathml/nsMathMLmactionFrame.cpp
+++ b/layout/mathml/nsMathMLmactionFrame.cpp
@@ -11,16 +11,17 @@
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIWebBrowserChrome.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsTextFragment.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/dom/Event.h"
 
+using namespace mozilla;
 using mozilla::dom::Event;
 
 //
 // <maction> -- bind actions to a subexpression - implementation
 //
 
 enum nsMactionActionTypes {
   NS_MATHML_ACTION_TYPE_CLASS_ERROR            = 0x10,
--- a/layout/mathml/nsMathMLmfencedFrame.cpp
+++ b/layout/mathml/nsMathMLmfencedFrame.cpp
@@ -6,16 +6,18 @@
 
 #include "gfxContext.h"
 #include "nsMathMLmfencedFrame.h"
 #include "nsMathMLChar.h"
 #include <algorithm>
 
 using namespace mozilla;
 
+using mozilla::gfx::DrawTarget;
+
 //
 // <mfenced> -- surround content with a pair of fences
 //
 
 nsIFrame*
 NS_NewMathMLmfencedFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle)
 {
   return new (aPresShell) nsMathMLmfencedFrame(aStyle);
--- a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp
+++ b/layout/mathml/nsMathMLmmultiscriptsFrame.cpp
@@ -6,17 +6,17 @@
 
 
 #include "nsMathMLmmultiscriptsFrame.h"
 #include "nsPresContext.h"
 #include <algorithm>
 #include "gfxContext.h"
 #include "gfxMathTable.h"
 
-using mozilla::WritingMode;
+using namespace mozilla;
 
 //
 // <mmultiscripts> -- attach prescripts and tensor indices to a base - implementation
 // <msub> -- attach a subscript to a base - implementation
 // <msubsup> -- attach a subscript-superscript pair to a base - implementation
 // <msup> -- attach a superscript to a base - implementation
 //
 
--- a/layout/mathml/nsMathMLmoFrame.cpp
+++ b/layout/mathml/nsMathMLmoFrame.cpp
@@ -7,16 +7,18 @@
 #include "gfxContext.h"
 #include "nsMathMLmoFrame.h"
 #include "nsPresContext.h"
 #include "nsContentUtils.h"
 #include "nsFrameSelection.h"
 #include "nsMathMLElement.h"
 #include <algorithm>
 
+using namespace mozilla;
+
 //
 // <mo> -- operator, fence, or separator - implementation
 //
 
 // additional ComputedStyle to be used by our MathMLChar.
 #define NS_MATHML_CHAR_STYLE_CONTEXT_INDEX   0
 
 nsIFrame*
--- a/layout/mathml/nsMathMLmpaddedFrame.cpp
+++ b/layout/mathml/nsMathMLmpaddedFrame.cpp
@@ -6,16 +6,18 @@
 
 
 #include "nsMathMLmpaddedFrame.h"
 #include "nsMathMLElement.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/TextUtils.h"
 #include <algorithm>
 
+using namespace mozilla;
+
 //
 // <mpadded> -- adjust space around content - implementation
 //
 
 #define NS_MATHML_SIGN_INVALID           -1 // if the attribute is not there
 #define NS_MATHML_SIGN_UNSPECIFIED        0
 #define NS_MATHML_SIGN_MINUS              1
 #define NS_MATHML_SIGN_PLUS               2
--- a/layout/mathml/nsMathMLmrowFrame.cpp
+++ b/layout/mathml/nsMathMLmrowFrame.cpp
@@ -2,16 +2,18 @@
 /* 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 "nsMathMLmrowFrame.h"
 #include "mozilla/gfx/2D.h"
 
+using namespace mozilla;
+
 //
 // <mrow> -- horizontally group any number of subexpressions - implementation
 //
 
 nsIFrame*
 NS_NewMathMLmrowFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle)
 {
   return new (aPresShell) nsMathMLmrowFrame(aStyle);
--- a/layout/mathml/nsMathMLmspaceFrame.cpp
+++ b/layout/mathml/nsMathMLmspaceFrame.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsMathMLmspaceFrame.h"
 #include "nsMathMLElement.h"
 #include "mozilla/gfx/2D.h"
 #include <algorithm>
 
+using namespace mozilla;
 
 //
 // <mspace> -- space - implementation
 //
 
 nsIFrame*
 NS_NewMathMLmspaceFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle)
 {
--- a/layout/mathml/nsMathMLmunderoverFrame.cpp
+++ b/layout/mathml/nsMathMLmunderoverFrame.cpp
@@ -7,16 +7,18 @@
 #include "nsMathMLmunderoverFrame.h"
 #include "nsPresContext.h"
 #include "nsMathMLmmultiscriptsFrame.h"
 #include "nsMathMLElement.h"
 #include <algorithm>
 #include "gfxContext.h"
 #include "gfxMathTable.h"
 
+using namespace mozilla;
+
 //
 // <munderover> -- attach an underscript-overscript pair to a base - implementation
 // <mover> -- attach an overscript to a base - implementation
 // <munder> -- attach an underscript to a base - implementation
 //
 
 nsIFrame*
 NS_NewMathMLmunderoverFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle)
--- a/layout/mathml/nsMathMLsemanticsFrame.cpp
+++ b/layout/mathml/nsMathMLsemanticsFrame.cpp
@@ -4,16 +4,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
 #include "nsMathMLsemanticsFrame.h"
 #include "nsMimeTypes.h"
 #include "mozilla/gfx/2D.h"
 
+using namespace mozilla;
+
 //
 // <semantics> -- associate annotations with a MathML expression
 //
 
 nsIFrame*
 NS_NewMathMLsemanticsFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle)
 {
   return new (aPresShell) nsMathMLsemanticsFrame(aStyle);
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -17,26 +17,29 @@
 #include <limits>
 
 #include "gfxContext.h"
 #include "gfxUtils.h"
 #include "mozilla/dom/TabChild.h"
 #include "mozilla/dom/HTMLCanvasElement.h"
 #include "mozilla/dom/KeyframeEffect.h"
 #include "mozilla/dom/Selection.h"
+#include "mozilla/dom/ServiceWorkerRegistrar.h"
+#include "mozilla/dom/ServiceWorkerRegistration.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/layers/PLayerTransaction.h"
 #include "mozilla/ShapeUtils.h"
 #include "nsCSSRendering.h"
 #include "nsCSSRenderingGradients.h"
 #include "nsISelectionController.h"
 #include "nsIPresShell.h"
 #include "nsRegion.h"
 #include "nsStyleStructInlines.h"
 #include "nsStyleTransformMatrix.h"
+#include "nsTransitionManager.h"
 #include "gfxMatrix.h"
 #include "gfxPrefs.h"
 #include "nsSVGIntegrationUtils.h"
 #include "nsSVGUtils.h"
 #include "nsLayoutUtils.h"
 #include "nsIScrollableFrame.h"
 #include "nsIFrameInlines.h"
 #include "nsStyleConsts.h"
--- a/layout/printing/PrintTranslator.h
+++ b/layout/printing/PrintTranslator.h
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_layout_PrintTranslator_h
 #define mozilla_layout_PrintTranslator_h
 
 #include <istream>
 
+#include "DrawEventRecorder.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/Filters.h"
 #include "mozilla/gfx/RecordedEvent.h"
 #include "nsRefPtrHashtable.h"
 
 class nsDeviceContext;
 
 namespace mozilla {
--- a/layout/printing/ipc/RemotePrintJobParent.h
+++ b/layout/printing/ipc/RemotePrintJobParent.h
@@ -14,21 +14,22 @@
 #include "nsCOMPtr.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/gfx/RecordedEvent.h"
 
 class nsDeviceContext;
 class nsIPrintSettings;
 class nsIWebProgressListener;
-class PrintTranslator;
 
 namespace mozilla {
 namespace layout {
 
+class PrintTranslator;
+
 class RemotePrintJobParent final : public PRemotePrintJobParent
 {
 public:
   explicit RemotePrintJobParent(nsIPrintSettings* aPrintSettings);
 
   void ActorDestroy(ActorDestroyReason aWhy) final;
 
   mozilla::ipc::IPCResult RecvInitializePrint(const nsString& aDocumentTitle,
--- a/layout/printing/nsPrintData.cpp
+++ b/layout/printing/nsPrintData.cpp
@@ -3,16 +3,17 @@
 /* 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 "nsPrintData.h"
 
 #include "nsIStringBundle.h"
 #include "nsIServiceManager.h"
+#include "nsIWidget.h"
 #include "nsPrintObject.h"
 #include "nsPrintPreviewListener.h"
 #include "nsIWebProgressListener.h"
 #include "mozilla/Services.h"
 
 //-----------------------------------------------------
 // PR LOGGING
 #include "mozilla/Logging.h"
--- a/layout/printing/nsPrintJob.cpp
+++ b/layout/printing/nsPrintJob.cpp
@@ -132,17 +132,17 @@ using namespace mozilla::dom;
 // but we only want some of it on,
 //#define EXTENDED_DEBUG_PRINTING
 #endif
 
 // this log level turns on the dumping of each document's layout info
 #define DUMP_LAYOUT_LEVEL (static_cast<mozilla::LogLevel>(9))
 
 #ifndef PR_PL
-static mozilla::LazyLogModule gPrintingLog("printing")
+static mozilla::LazyLogModule gPrintingLog("printing");
 
 #define PR_PL(_p1)  MOZ_LOG(gPrintingLog, mozilla::LogLevel::Debug, _p1);
 #endif
 
 #ifdef EXTENDED_DEBUG_PRINTING
 static uint32_t gDumpFileNameCnt   = 0;
 static uint32_t gDumpLOFileNameCnt = 0;
 #endif
--- a/layout/printing/nsPrintObject.cpp
+++ b/layout/printing/nsPrintObject.cpp
@@ -1,27 +1,33 @@
 /* -*- 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 "nsPrintObject.h"
+
 #include "nsIContentViewer.h"
 #include "nsContentUtils.h" // for nsAutoScriptBlocker
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsPIDOMWindow.h"
+#include "nsPresContext.h"
 #include "nsGkAtoms.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIBaseWindow.h"
 #include "nsIDocument.h"
 #include "nsDocShell.h"
 
 #include "mozilla/dom/BrowsingContext.h"
+#include "mozilla/dom/Element.h"
+
+using mozilla::dom::BrowsingContext;
+using mozilla::dom::Element;
 
 //---------------------------------------------------
 //-- nsPrintObject Class Impl
 //---------------------------------------------------
 nsPrintObject::nsPrintObject() :
   mContent(nullptr), mFrameType(eFrame), mParent(nullptr),
   mHasBeenPrinted(false), mDontPrint(true), mPrintAsIs(false),
   mInvisible(false), mPrintPreview(false), mDidCreateDocShell(false),
--- a/layout/style/CSSKeyframesRule.cpp
+++ b/layout/style/CSSKeyframesRule.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/CSSKeyframesRule.h"
 
 #include "mozilla/dom/CSSKeyframesRuleBinding.h"
 #include "mozilla/dom/CSSRuleList.h"
 #include "mozilla/ServoBindings.h"
+#include "nsCOMArray.h"
 
 #include <limits>
 
 namespace mozilla {
 namespace dom {
 
 // -------------------------------------------
 // CSSKeyframeList
--- a/layout/style/CounterStyleManager.cpp
+++ b/layout/style/CounterStyleManager.cpp
@@ -7,16 +7,17 @@
 #include "CounterStyleManager.h"
 
 #include "mozilla/ArenaObjectID.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/Types.h"
 #include "mozilla/WritingModes.h"
+#include "nsPresContext.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsTHashtable.h"
 #include "nsUnicodeProperties.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/ServoStyleSet.h"
 
 namespace mozilla {
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -15,16 +15,17 @@
 #include "mozilla/LoadInfo.h"
 #include "mozilla/Logging.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/StyleSheetInlines.h"
 #include "mozilla/SystemGroup.h"
 #include "mozilla/ResultExtensions.h"
 #include "mozilla/URLPreloader.h"
 #include "nsIRunnable.h"
+#include "nsITimedChannel.h"
 #include "nsSyncLoadService.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIURI.h"
 #include "nsNetUtil.h"
 #include "nsIProtocolHandler.h"
--- a/layout/style/MappedDeclarations.cpp
+++ b/layout/style/MappedDeclarations.cpp
@@ -1,15 +1,19 @@
 /* -*- 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/MappedDeclarations.h"
+#include "MappedDeclarations.h"
+
+#include "nsAttrValue.h"
+#include "nsIDocument.h"
+#include "nsPresContext.h"
 
 namespace mozilla {
 
 void
 MappedDeclarations::SetIdentAtomValue(nsCSSPropertyID aId, nsAtom* aValue)
 {
   Servo_DeclarationBlock_SetIdentStringValue(mDecl, aId, aValue);
   if (aId == eCSSProperty__x_lang) {
--- a/layout/style/MediaList.cpp
+++ b/layout/style/MediaList.cpp
@@ -8,16 +8,17 @@
 
 #include "mozilla/dom/MediaList.h"
 
 #include "mozAutoDocUpdate.h"
 #include "mozilla/dom/MediaListBinding.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/ServoStyleSet.h"
 #include "mozilla/StyleSheetInlines.h"
+#include "nsPresContext.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MediaList)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
--- a/layout/style/ServoCSSParser.h
+++ b/layout/style/ServoCSSParser.h
@@ -6,16 +6,17 @@
 
 /* CSS parsing utility functions */
 
 #ifndef mozilla_ServoCSSParser_h
 #define mozilla_ServoCSSParser_h
 
 #include "mozilla/gfx/Types.h"
 #include "mozilla/RefPtr.h"
+#include "mozilla/ServoStyleConsts.h"
 #include "mozilla/ServoTypes.h"
 #include "nsColor.h"
 #include "nsCSSPropertyID.h"
 #include "nsDOMCSSDeclaration.h"
 #include "nsStringFwd.h"
 
 class nsCSSValue;
 class nsIDocument;
--- a/layout/style/ServoCSSRuleList.cpp
+++ b/layout/style/ServoCSSRuleList.cpp
@@ -17,16 +17,17 @@
 #include "mozilla/dom/CSSMozDocumentRule.h"
 #include "mozilla/dom/CSSNamespaceRule.h"
 #include "mozilla/dom/CSSPageRule.h"
 #include "mozilla/dom/CSSStyleRule.h"
 #include "mozilla/dom/CSSSupportsRule.h"
 #include "mozilla/IntegerRange.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/StyleSheet.h"
+#include "nsIDocument.h"
 
 using namespace mozilla::dom;
 
 namespace mozilla {
 
 ServoCSSRuleList::ServoCSSRuleList(already_AddRefed<ServoCssRules> aRawRules,
                                    StyleSheet* aSheet,
                                    css::GroupRule* aParentRule)
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ServoStyleSet.h"
 #include "mozilla/ServoStyleSetInlines.h"
 
 #include "gfxPlatformFontList.h"
 #include "mozilla/AutoRestyleTimelineMarker.h"
 #include "mozilla/DocumentStyleRootIterator.h"
+#include "mozilla/EffectCompositor.h"
 #include "mozilla/IntegerRange.h"
 #include "mozilla/LookAndFeel.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/RestyleManager.h"
 #include "mozilla/ServoStyleRuleMap.h"
 #include "mozilla/ServoTypes.h"
 #include "mozilla/StyleAnimationValue.h"
 #include "mozilla/css/Loader.h"
--- a/layout/style/nsDOMCSSValueList.cpp
+++ b/layout/style/nsDOMCSSValueList.cpp
@@ -3,16 +3,17 @@
 /* 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/. */
 
 /* DOM object representing lists of values in DOM computed style */
 
 #include "nsDOMCSSValueList.h"
 #include "nsString.h"
+#include "mozilla/ErrorResult.h"
 #include "mozilla/Move.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 nsDOMCSSValueList::nsDOMCSSValueList(bool aCommaDelimited)
   : CSSValue()
   , mCommaDelimited(aCommaDelimited)
--- a/layout/svg/SVGFELeafFrame.cpp
+++ b/layout/svg/SVGFELeafFrame.cpp
@@ -1,21 +1,24 @@
 /* -*- 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/. */
 
 // Keep in (case-insensitive) order:
+#include "ComputedStyle.h"
 #include "nsContainerFrame.h"
 #include "nsFrame.h"
 #include "nsGkAtoms.h"
 #include "SVGObserverUtils.h"
 #include "nsSVGFilters.h"
 
+using namespace mozilla;
+
 /*
  * This frame is used by filter primitive elements that don't
  * have special child elements that provide parameters.
  */
 class SVGFELeafFrame final : public nsFrame
 {
   friend nsIFrame*
   NS_NewSVGFELeafFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle);
--- a/layout/svg/SVGFEUnstyledLeafFrame.cpp
+++ b/layout/svg/SVGFEUnstyledLeafFrame.cpp
@@ -6,16 +6,18 @@
 
 // Keep in (case-insensitive) order:
 #include "nsContainerFrame.h"
 #include "nsFrame.h"
 #include "nsGkAtoms.h"
 #include "SVGObserverUtils.h"
 #include "nsSVGFilters.h"
 
+using namespace mozilla;
+
 class SVGFEUnstyledLeafFrame final : public nsFrame
 {
   friend nsIFrame*
   NS_NewSVGFEUnstyledLeafFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle);
 protected:
   explicit SVGFEUnstyledLeafFrame(ComputedStyle* aStyle)
     : nsFrame(aStyle, kClassID)
   {
--- a/layout/svg/SVGObserverUtils.cpp
+++ b/layout/svg/SVGObserverUtils.cpp
@@ -8,27 +8,29 @@
 #include "SVGObserverUtils.h"
 
 // Keep others in (case-insensitive) order:
 #include "mozilla/dom/CanvasRenderingContext2D.h"
 #include "mozilla/RestyleManager.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsISupportsImpl.h"
 #include "nsSVGClipPathFrame.h"
+#include "nsSVGMarkerFrame.h"
 #include "nsSVGPaintServerFrame.h"
 #include "nsSVGFilterFrame.h"
 #include "nsSVGMaskFrame.h"
 #include "nsIReflowCallback.h"
 #include "nsCycleCollectionParticipant.h"
 #include "SVGGeometryElement.h"
 #include "SVGTextPathElement.h"
 #include "SVGUseElement.h"
 #include "ImageLoader.h"
 #include "mozilla/net/ReferrerPolicy.h"
 
+using namespace mozilla;
 using namespace mozilla::dom;
 
 static already_AddRefed<URLAndReferrerInfo>
 ResolveURLUsingLocalRef(nsIFrame* aFrame, const css::URLValue* aURL)
 {
   MOZ_ASSERT(aFrame);
 
   if (!aURL) {
--- a/layout/svg/SVGViewFrame.cpp
+++ b/layout/svg/SVGViewFrame.cpp
@@ -6,16 +6,17 @@
 
 // Keep in (case-insensitive) order:
 #include "nsFrame.h"
 #include "nsGkAtoms.h"
 #include "nsSVGOuterSVGFrame.h"
 #include "mozilla/dom/SVGSVGElement.h"
 #include "mozilla/dom/SVGViewElement.h"
 
+using namespace mozilla;
 using namespace mozilla::dom;
 
 /**
  * While views are not directly rendered in SVG they can be linked to
  * and thereby override attributes of an <svg> element via a fragment
  * identifier. The SVGViewFrame class passes on any attribute changes
  * the view receives to the overridden <svg> element (if there is one).
  **/
--- a/layout/svg/nsCSSClipPathInstance.h
+++ b/layout/svg/nsCSSClipPathInstance.h
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef __NS_CSSCLIPPATHINSTANCE_H__
 #define __NS_CSSCLIPPATHINSTANCE_H__
 
+#include "gfxPoint.h"
 #include "nsStyleStruct.h"
 #include "nsRect.h"
 #include "mozilla/gfx/2D.h"
 
 class nsIFrame;
 class gfxContext;
 
 namespace mozilla {
--- a/layout/svg/nsSVGGFrame.cpp
+++ b/layout/svg/nsSVGGFrame.cpp
@@ -10,16 +10,17 @@
 // Keep others in (case-insensitive) order:
 #include "nsGkAtoms.h"
 #include "SVGTransformableElement.h"
 #include "nsIFrame.h"
 #include "SVGGraphicsElement.h"
 #include "nsSVGIntegrationUtils.h"
 #include "nsSVGUtils.h"
 
+using namespace mozilla;
 using namespace mozilla::dom;
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsIFrame*
 NS_NewSVGGFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle)
 {
--- a/layout/svg/nsSVGGenericContainerFrame.cpp
+++ b/layout/svg/nsSVGGenericContainerFrame.cpp
@@ -3,16 +3,18 @@
 /* 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/. */
 
 // Main header first:
 #include "nsSVGGenericContainerFrame.h"
 #include "nsSVGIntegrationUtils.h"
 
+using namespace mozilla;
+
 //----------------------------------------------------------------------
 // nsSVGGenericContainerFrame Implementation
 
 nsIFrame*
 NS_NewSVGGenericContainerFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle)
 {
   return new (aPresShell) nsSVGGenericContainerFrame(aStyle);
 }
--- a/layout/svg/nsSVGInnerSVGFrame.cpp
+++ b/layout/svg/nsSVGInnerSVGFrame.cpp
@@ -2,16 +2,18 @@
 /* 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/. */
 
 // Main header first:
 #include "nsSVGInnerSVGFrame.h"
 
+using namespace mozilla;
+
 nsIFrame*
 NS_NewSVGInnerSVGFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle)
 {
   return new (aPresShell) nsSVGInnerSVGFrame(aStyle);
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGInnerSVGFrame)
 
--- a/layout/svg/nsSVGMarkerFrame.cpp
+++ b/layout/svg/nsSVGMarkerFrame.cpp
@@ -9,16 +9,17 @@
 
 // Keep others in (case-insensitive) order:
 #include "gfxContext.h"
 #include "SVGObserverUtils.h"
 #include "mozilla/dom/SVGMarkerElement.h"
 #include "SVGGeometryElement.h"
 #include "SVGGeometryFrame.h"
 
+using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 using namespace mozilla::image;
 
 nsContainerFrame*
 NS_NewSVGMarkerFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle)
 {
   return new (aPresShell) nsSVGMarkerFrame(aStyle);
--- a/layout/svg/nsSVGOuterSVGFrame.cpp
+++ b/layout/svg/nsSVGOuterSVGFrame.cpp
@@ -17,16 +17,17 @@
 #include "nsSVGForeignObjectFrame.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/SVGSVGElement.h"
 #include "mozilla/dom/SVGViewElement.h"
 #include "nsSubDocumentFrame.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
+using namespace mozilla::gfx;
 using namespace mozilla::image;
 
 //----------------------------------------------------------------------
 // Implementation helpers
 
 void
 nsSVGOuterSVGFrame::RegisterForeignObject(nsSVGForeignObjectFrame* aFrame)
 {
--- a/layout/svg/nsSVGStopFrame.cpp
+++ b/layout/svg/nsSVGStopFrame.cpp
@@ -6,16 +6,18 @@
 
 // Keep in (case-insensitive) order:
 #include "nsContainerFrame.h"
 #include "nsFrame.h"
 #include "nsGkAtoms.h"
 #include "mozilla/ComputedStyle.h"
 #include "SVGObserverUtils.h"
 
+using namespace mozilla;
+
 // This is a very simple frame whose only purpose is to capture style change
 // events and propagate them to the parent.  Most of the heavy lifting is done
 // within the nsSVGGradientFrame, which is the parent for this frame
 
 class nsSVGStopFrame : public nsFrame
 {
   friend nsIFrame*
   NS_NewSVGStopFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle);
--- a/layout/svg/nsSVGSwitchFrame.cpp
+++ b/layout/svg/nsSVGSwitchFrame.cpp
@@ -6,16 +6,17 @@
 
 // Keep in (case-insensitive) order:
 #include "gfxRect.h"
 #include "SVGObserverUtils.h"
 #include "nsSVGGFrame.h"
 #include "mozilla/dom/SVGSwitchElement.h"
 #include "nsSVGUtils.h"
 
+using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::image;
 
 class nsSVGSwitchFrame final : public nsSVGGFrame
 {
   friend nsIFrame*
   NS_NewSVGSwitchFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle);
 protected:
--- a/layout/svg/nsSVGSymbolFrame.cpp
+++ b/layout/svg/nsSVGSymbolFrame.cpp
@@ -2,16 +2,18 @@
 /* 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/. */
 
 // Main header first:
 #include "nsSVGSymbolFrame.h"
 
+using namespace mozilla;
+
 nsIFrame*
 NS_NewSVGSymbolFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle)
 {
   return new (aPresShell) nsSVGSymbolFrame(aStyle);
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGSymbolFrame)
 
--- a/layout/tables/FixedTableLayoutStrategy.cpp
+++ b/layout/tables/FixedTableLayoutStrategy.cpp
@@ -5,21 +5,25 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * Algorithms that determine column and table inline sizes used for
  * CSS2's 'table-layout: fixed'.
  */
 
 #include "FixedTableLayoutStrategy.h"
+#include "nsStyleConsts.h"
 #include "nsTableFrame.h"
 #include "nsTableColFrame.h"
 #include "nsTableCellFrame.h"
+#include "WritingModes.h"
 #include <algorithm>
 
+using namespace mozilla;
+
 FixedTableLayoutStrategy::FixedTableLayoutStrategy(nsTableFrame *aTableFrame)
   : nsITableLayoutStrategy(nsITableLayoutStrategy::Fixed)
   , mTableFrame(aTableFrame)
 {
   MarkIntrinsicISizesDirty();
 }
 
 /* virtual */
--- a/layout/tables/SpanningCellSorter.cpp
+++ b/layout/tables/SpanningCellSorter.cpp
@@ -8,16 +8,18 @@
  * Code to sort cells by their colspan, used by BasicTableLayoutStrategy.
  */
 
 #include "SpanningCellSorter.h"
 #include "nsQuickSort.h"
 #include "nsIPresShell.h"
 #include "mozilla/HashFunctions.h"
 
+using namespace mozilla;
+
 //#define DEBUG_SPANNING_CELL_SORTER
 
 SpanningCellSorter::SpanningCellSorter()
   : mState(ADDING)
   , mHashTable(&HashTableOps, sizeof(HashTableEntry))
   , mSortedHashTable(nullptr)
 {
     memset(mArray, 0, sizeof(mArray));
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -1,22 +1,25 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 sw=2 et 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 "nsTableFrame.h"
+
+#include "mozilla/gfx/2D.h"
+#include "mozilla/gfx/Helpers.h"
 #include "mozilla/Likely.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/IntegerRange.h"
 #include "mozilla/WritingModes.h"
 
 #include "gfxContext.h"
 #include "nsCOMPtr.h"
-#include "nsTableFrame.h"
 #include "mozilla/ComputedStyle.h"
 #include "nsStyleConsts.h"
 #include "nsIContent.h"
 #include "nsCellMap.h"
 #include "nsTableCellFrame.h"
 #include "nsHTMLParts.h"
 #include "nsTableColFrame.h"
 #include "nsTableColGroupFrame.h"
@@ -49,16 +52,21 @@
 #include "gfxPrefs.h"
 #include "mozilla/layers/StackingContextHelper.h"
 #include "mozilla/layers/WebRenderLayerManager.h"
 
 using namespace mozilla;
 using namespace mozilla::image;
 using namespace mozilla::layout;
 
+using mozilla::gfx::AutoRestoreTransform;
+using mozilla::gfx::DrawTarget;
+using mozilla::gfx::Float;
+using mozilla::gfx::ToDeviceColor;
+
 /********************************************************************************
  ** TableReflowInput                                                         **
  ********************************************************************************/
 
 namespace mozilla {
 
 struct TableReflowInput {
 
--- a/layout/xul/grid/nsGridRowGroupFrame.cpp
+++ b/layout/xul/grid/nsGridRowGroupFrame.cpp
@@ -12,16 +12,18 @@
 //
 
 #include "nsGridRowGroupFrame.h"
 #include "nsGridRowLeafLayout.h"
 #include "nsGridRow.h"
 #include "nsBoxLayoutState.h"
 #include "nsGridLayout2.h"
 
+using namespace mozilla;
+
 already_AddRefed<nsBoxLayout> NS_NewGridRowGroupLayout();
 
 nsIFrame*
 NS_NewGridRowGroupFrame(nsIPresShell* aPresShell,
                         ComputedStyle* aStyle)
 {
   nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowGroupLayout();
   return new (aPresShell) nsGridRowGroupFrame(aStyle, layout);
--- a/layout/xul/grid/nsGridRowLeafFrame.cpp
+++ b/layout/xul/grid/nsGridRowLeafFrame.cpp
@@ -12,16 +12,18 @@
 //
 
 #include "nsGridRowLeafFrame.h"
 #include "nsGridRowLeafLayout.h"
 #include "nsGridRow.h"
 #include "nsBoxLayoutState.h"
 #include "nsGridLayout2.h"
 
+using namespace mozilla;
+
 already_AddRefed<nsBoxLayout> NS_NewGridRowLeafLayout();
 
 nsIFrame*
 NS_NewGridRowLeafFrame(nsIPresShell* aPresShell,
                        ComputedStyle* aStyle)
 {
   nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowLeafLayout();
   return new (aPresShell) nsGridRowLeafFrame(aStyle, false, layout);
--- a/layout/xul/nsButtonBoxFrame.cpp
+++ b/layout/xul/nsButtonBoxFrame.cpp
@@ -17,17 +17,17 @@
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/EventStateManager.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TextEvents.h"
 
 using namespace mozilla;
-
+using namespace mozilla::dom;
 
 NS_IMPL_ISUPPORTS(nsButtonBoxFrame::nsButtonBoxListener, nsIDOMEventListener)
 
 nsresult
 nsButtonBoxFrame::nsButtonBoxListener::HandleEvent(dom::Event* aEvent)
 {
   if (!mButtonBoxFrame) {
     return NS_OK;
--- a/layout/xul/nsDeckFrame.cpp
+++ b/layout/xul/nsDeckFrame.cpp
@@ -28,16 +28,18 @@
 #include "nsContainerFrame.h"
 #include "nsContentUtils.h"
 #include "nsXULPopupManager.h"
 
 #ifdef ACCESSIBILITY
 #include "nsAccessibilityService.h"
 #endif
 
+using namespace mozilla;
+
 nsIFrame*
 NS_NewDeckFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle)
 {
   return new (aPresShell) nsDeckFrame(aStyle);
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsDeckFrame)
 
--- a/layout/xul/nsDocElementBoxFrame.cpp
+++ b/layout/xul/nsDocElementBoxFrame.cpp
@@ -18,16 +18,17 @@
 #include "nsIServiceManager.h"
 #include "nsNodeInfoManager.h"
 #include "nsContentCreatorFunctions.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/FromParser.h"
 
 //#define DEBUG_REFLOW
 
+using namespace mozilla;
 using namespace mozilla::dom;
 
 class nsDocElementBoxFrame final : public nsBoxFrame
                                  , public nsIAnonymousContentCreator
 {
 public:
   virtual void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override;
 
--- a/layout/xul/nsMenuBarListener.h
+++ b/layout/xul/nsMenuBarListener.h
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef nsMenuBarListener_h
 #define nsMenuBarListener_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/EventForwards.h"
+#include "nsIContent.h"
 #include "nsIDOMEventListener.h"
 
 // X.h defines KeyPress
 #ifdef KeyPress
 #undef KeyPress
 #endif
 
 class nsMenuFrame;
--- a/layout/xul/nsMenuPopupFrame.h
+++ b/layout/xul/nsMenuPopupFrame.h
@@ -9,16 +9,17 @@
 //
 
 #ifndef nsMenuPopupFrame_h__
 #define nsMenuPopupFrame_h__
 
 #include "mozilla/Attributes.h"
 #include "mozilla/gfx/Types.h"
 #include "nsAtom.h"
+#include "nsIDOMXULSelectCntrlEl.h"
 #include "nsGkAtoms.h"
 #include "nsCOMPtr.h"
 #include "nsMenuFrame.h"
 
 #include "nsBoxFrame.h"
 #include "nsMenuParent.h"
 
 #include "nsITimer.h"
--- a/layout/xul/nsResizerFrame.h
+++ b/layout/xul/nsResizerFrame.h
@@ -10,16 +10,19 @@
 #include "mozilla/EventForwards.h"
 #include "nsTitleBarFrame.h"
 
 class nsIBaseWindow;
 
 class nsResizerFrame final : public nsTitleBarFrame
 {
 protected:
+  typedef mozilla::LayoutDeviceIntPoint LayoutDeviceIntPoint;
+  typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
+
   struct Direction {
     int8_t mHorizontal;
     int8_t mVertical;
   };
 
 public:
   NS_DECL_FRAMEARENA_HELPERS(nsResizerFrame)
 
--- a/layout/xul/nsSplitterFrame.cpp
+++ b/layout/xul/nsSplitterFrame.cpp
@@ -35,16 +35,18 @@
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/MouseEvent.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/UniquePtr.h"
 #include "nsBindingManager.h"
 
 using namespace mozilla;
 
+using mozilla::dom::Event;
+
 class nsSplitterInfo {
 public:
   nscoord min;
   nscoord max;
   nscoord current;
   nscoord changed;
   nsCOMPtr<nsIContent> childElem;
   int32_t flex;
--- a/layout/xul/tree/nsTreeColFrame.cpp
+++ b/layout/xul/tree/nsTreeColFrame.cpp
@@ -13,16 +13,18 @@
 #include "nsIBoxObject.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/TreeBoxObject.h"
 #include "nsTreeColumns.h"
 #include "nsDisplayList.h"
 #include "nsTreeBodyFrame.h"
 #include "nsXULElement.h"
 
+using namespace mozilla;
+
 //
 // NS_NewTreeColFrame
 //
 // Creates a new col frame
 //
 nsIFrame*
 NS_NewTreeColFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle)
 {
--- a/layout/xul/tree/nsTreeColFrame.h
+++ b/layout/xul/tree/nsTreeColFrame.h
@@ -1,21 +1,22 @@
 /* -*- 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/Attributes.h"
+#include "mozilla/ComputedStyle.h"
 #include "nsBoxFrame.h"
 
 class nsITreeBoxObject;
 
 nsIFrame* NS_NewTreeColFrame(nsIPresShell* aPresShell,
-                             ComputedStyle* aStyle);
+                             mozilla::ComputedStyle* aStyle);
 
 class nsTreeColFrame final : public nsBoxFrame
 {
 public:
   NS_DECL_FRAMEARENA_HELPERS(nsTreeColFrame)
 
   explicit nsTreeColFrame(ComputedStyle* aStyle):
     nsBoxFrame(aStyle, kClassID) {}
--- a/layout/xul/tree/nsTreeColumns.cpp
+++ b/layout/xul/tree/nsTreeColumns.cpp
@@ -13,16 +13,17 @@
 #include "nsContentUtils.h"
 #include "nsTreeBodyFrame.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/TreeBoxObject.h"
 #include "mozilla/dom/TreeColumnBinding.h"
 #include "mozilla/dom/TreeColumnsBinding.h"
 
 using namespace mozilla;
+using namespace mozilla::dom;
 
 // Column class that caches all the info about our column.
 nsTreeColumn::nsTreeColumn(nsTreeColumns* aColumns, dom::Element* aElement)
   : mContent(aElement),
     mColumns(aColumns),
     mIndex(0),
     mPrevious(nullptr)
 {
--- a/layout/xul/tree/nsTreeContentView.cpp
+++ b/layout/xul/tree/nsTreeContentView.cpp
@@ -11,21 +11,23 @@
 #include "nsTreeContentView.h"
 #include "ChildIterator.h"
 #include "nsError.h"
 #include "nsXULSortService.h"
 #include "nsTreeBodyFrame.h"
 #include "nsTreeColumns.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/Element.h"
+#include "mozilla/dom/TreeBoxObject.h"
 #include "mozilla/dom/TreeContentViewBinding.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIDocument.h"
 
 using namespace mozilla;
+using namespace mozilla::dom;
 
 // A content model view implementation for the tree.
 
 #define ROW_FLAG_CONTAINER      0x01
 #define ROW_FLAG_OPEN           0x02
 #define ROW_FLAG_EMPTY          0x04
 #define ROW_FLAG_SEPARATOR      0x08
 
--- a/layout/xul/tree/nsTreeStyleCache.h
+++ b/layout/xul/tree/nsTreeStyleCache.h
@@ -6,19 +6,22 @@
 
 #ifndef nsTreeStyleCache_h__
 #define nsTreeStyleCache_h__
 
 #include "mozilla/AtomArray.h"
 #include "mozilla/Attributes.h"
 #include "nsAutoPtr.h"
 #include "nsCOMArray.h"
+#include "nsDataHashtable.h"
 #include "nsRefPtrHashtable.h"
 #include "mozilla/ComputedStyle.h"
 
+class nsIContent;
+
 class nsTreeStyleCache
 {
 public:
   nsTreeStyleCache()
     : mNextState(0)
   {
   }
 
deleted file mode 100644
--- a/testing/web-platform/meta/eventsource/format-data-before-final-empty-line.htm.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[format-data-before-final-empty-line.htm]
-  disabled: 1086275
deleted file mode 100644
--- a/testing/web-platform/meta/eventsource/format-field-retry-bogus.htm.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[format-field-retry-bogus.htm]
-  disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1006396
deleted file mode 100644
--- a/testing/web-platform/meta/eventsource/format-field-retry.htm.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[format-field-retry.htm]
-  disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1006396
deleted file mode 100644
--- a/testing/web-platform/meta/workers/constructors/SharedWorker/connect-event.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[connect-event.html]
-  [connect event]
-    expected: FAIL
-