Bug 1302949 - Add a method to serialize a declaration block as a single value; r=heycam draft
authorBrian Birtles <birtles@gmail.com>
Thu, 15 Sep 2016 16:55:08 +0900
changeset 420997 4a44d4265603c982483e5d7ef9460a7ab35c1e1e
parent 420996 2403ee41f8a71261705eca0f6e5fd250dfc5c007
child 420998 b0532e144b3208d79e1e26ce3bff9a20c896abad
push id31345
push userbbirtles@mozilla.com
push dateWed, 05 Oct 2016 02:47:30 +0000
reviewersheycam
bugs1302949
milestone52.0a1
Bug 1302949 - Add a method to serialize a declaration block as a single value; r=heycam MozReview-Commit-ID: 59CCT0P4CBm
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -615,16 +615,29 @@ Gecko_AtomEqualsUTF8IgnoreCase(nsIAtom* 
   // XXXbholley: We should be able to do this without converting, I just can't
   // find the right thing to call.
   nsDependentAtomString atomStr(aAtom);
   NS_ConvertUTF8toUTF16 inStr(nsDependentCSubstring(aString, aLength));
   return nsContentUtils::EqualsIgnoreASCIICase(atomStr, inStr);
 }
 
 void
+Gecko_Utf8SliceToString(nsString* aString,
+                        const uint8_t* aBuffer,
+                        size_t aBufferLen)
+{
+  MOZ_ASSERT(aString);
+  MOZ_ASSERT(aBuffer);
+
+  aString->Truncate();
+  AppendUTF8toUTF16(Substring(reinterpret_cast<const char*>(aBuffer),
+                              aBufferLen), *aString);
+}
+
+void
 Gecko_FontFamilyList_Clear(FontFamilyList* aList) {
   aList->Clear();
 }
 
 void
 Gecko_FontFamilyList_AppendNamed(FontFamilyList* aList, nsIAtom* aName)
 {
   // Servo doesn't record whether the name was quoted or unquoted, so just
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -221,16 +221,21 @@ ServoDeclarationBlockBorrowedOrNull Geck
 // Atoms.
 nsIAtom* Gecko_Atomize(const char* aString, uint32_t aLength);
 void Gecko_AddRefAtom(nsIAtom* aAtom);
 void Gecko_ReleaseAtom(nsIAtom* aAtom);
 const uint16_t* Gecko_GetAtomAsUTF16(nsIAtom* aAtom, uint32_t* aLength);
 bool Gecko_AtomEqualsUTF8(nsIAtom* aAtom, const char* aString, uint32_t aLength);
 bool Gecko_AtomEqualsUTF8IgnoreCase(nsIAtom* aAtom, const char* aString, uint32_t aLength);
 
+// Strings (temporary until bug 1294742)
+void Gecko_Utf8SliceToString(nsString* aString,
+                             const uint8_t* aBuffer,
+                             size_t aBufferLen);
+
 // Font style
 void Gecko_FontFamilyList_Clear(FontFamilyList* aList);
 void Gecko_FontFamilyList_AppendNamed(FontFamilyList* aList, nsIAtom* aName);
 void Gecko_FontFamilyList_AppendGeneric(FontFamilyList* list, FontFamilyType familyType);
 void Gecko_CopyFontFamilyFrom(nsFont* dst, const nsFont* src);
 
 // Counter style.
 void Gecko_SetListStyleType(nsStyleList* style_struct, uint32_t type);