Bug 1365362. Make Gecko_AtomAttrValue work correctly when the attr's value is not an atom. r=emilio
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 17 May 2017 00:53:52 -0400
changeset 358629 159f82e6813c4dca0a72c1fa2a49ec99b087db32
parent 358628 30f6ea5ad9e6d3891b12ab8a72e1e10dc0bd82c4
child 358630 9957d3e640736942b95c21dad5cfea3192cc1e96
push id90361
push userbzbarsky@mozilla.com
push dateWed, 17 May 2017 04:54:18 +0000
treeherdermozilla-inbound@159f82e6813c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1365362
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1365362. Make Gecko_AtomAttrValue work correctly when the attr's value is not an atom. r=emilio MozReview-Commit-ID: Btf7ZI4ZdMX
layout/style/ServoBindings.cpp
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -255,17 +255,23 @@ Gecko_Namespace(RawGeckoElementBorrowed 
   int32_t id = aElement->NodeInfo()->NamespaceID();
   return nsContentUtils::NameSpaceManager()->NameSpaceURIAtomForServo(id);
 }
 
 nsIAtom*
 Gecko_GetElementId(RawGeckoElementBorrowed aElement)
 {
   const nsAttrValue* attr = aElement->GetParsedAttr(nsGkAtoms::id);
-  return attr ? attr->GetAtomValue() : nullptr;
+  if (attr && attr->Type() == nsAttrValue::eAtom) {
+    return attr->GetAtomValue();
+  }
+  // The only case in which we should have a non-atom value here is if it's the
+  // empty string value.
+  MOZ_ASSERT_IF(attr, attr->IsEmptyString());
+  return nullptr;
 }
 
 // Dirtiness tracking.
 uint32_t
 Gecko_GetNodeFlags(RawGeckoNodeBorrowed aNode)
 {
   return aNode->GetFlags();
 }