Bug 1345696 part 4 - Add function for sugar of nsCSSValue. r=Manishearth draft
authorXidorn Quan <me@upsuper.org>
Tue, 28 Mar 2017 11:52:14 +1100
changeset 553418 9ae6e65de6a28027730881f08a589167ef09a313
parent 553417 bc4542e87a72d896fcfcf6c0cfc2093f9af718c1
child 553419 fa5d3343dfa81593b4d26691a9593435cdcc69cc
push id51629
push userxquan@mozilla.com
push dateThu, 30 Mar 2017 01:13:04 +0000
reviewersManishearth
bugs1345696
milestone55.0a1
Bug 1345696 part 4 - Add function for sugar of nsCSSValue. r=Manishearth MozReview-Commit-ID: 9go3QDIXLgH
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -1356,16 +1356,22 @@ Gecko_CSSValue_GetAbsoluteLength(nsCSSVa
   // values in eCSSUnit_Pixel unit. We need to convert the values back to app
   // units by GetPixelLength().
   MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Pixel,
              "The unit should be eCSSUnit_Pixel");
   return aCSSValue->GetPixelLength();
 }
 
 void
+Gecko_CSSValue_SetNormal(nsCSSValueBorrowedMut aCSSValue)
+{
+  aCSSValue->SetNormalValue();
+}
+
+void
 Gecko_CSSValue_SetNumber(nsCSSValueBorrowedMut aCSSValue, float aNumber)
 {
   aCSSValue->SetFloatValue(aNumber, eCSSUnit_Number);
 }
 
 float
 Gecko_CSSValue_GetNumber(nsCSSValueBorrowed aCSSValue)
 {
@@ -1427,35 +1433,33 @@ Gecko_CSSValue_GetCalc(nsCSSValueBorrowe
 void
 Gecko_CSSValue_SetFunction(nsCSSValueBorrowedMut aCSSValue, int32_t aLen)
 {
   nsCSSValue::Array* arr = nsCSSValue::Array::Create(aLen);
   aCSSValue->SetArrayValue(arr, eCSSUnit_Function);
 }
 
 void
-Gecko_CSSValue_SetString(nsCSSValueBorrowedMut aCSSValue, const uint8_t* aString, uint32_t aLength)
+Gecko_CSSValue_SetString(nsCSSValueBorrowedMut aCSSValue,
+                         const uint8_t* aString, uint32_t aLength,
+                         nsCSSUnit aUnit)
 {
   MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null);
   nsString string;
   nsDependentCSubstring slice(reinterpret_cast<const char*>(aString),
                                   aLength);
   AppendUTF8toUTF16(slice, string);
-  aCSSValue->SetStringValue(string, eCSSUnit_String);
+  aCSSValue->SetStringValue(string, aUnit);
 }
 
 void
-Gecko_CSSValue_SetIdent(nsCSSValueBorrowedMut aCSSValue, const uint8_t* aString, uint32_t aLength)
+Gecko_CSSValue_SetStringFromAtom(nsCSSValueBorrowedMut aCSSValue,
+                                 nsIAtom* aAtom, nsCSSUnit aUnit)
 {
-  MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null);
-  nsString string;
-  nsDependentCSubstring slice(reinterpret_cast<const char*>(aString),
-                                  aLength);
-  AppendUTF8toUTF16(slice, string);
-  aCSSValue->SetStringValue(string, eCSSUnit_Ident);
+  aCSSValue->SetStringValue(nsDependentAtomString(aAtom), aUnit);
 }
 
 void
 Gecko_CSSValue_SetArray(nsCSSValueBorrowedMut aCSSValue, int32_t aLength)
 {
   MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null);
   RefPtr<nsCSSValue::Array> array
     = nsCSSValue::Array::Create(aLength);
@@ -1467,28 +1471,20 @@ Gecko_CSSValue_SetURL(nsCSSValueBorrowed
                       ServoBundledURI aURI)
 {
   MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null);
   RefPtr<css::URLValue> url = aURI.IntoCssUrl();
   aCSSValue->SetURLValue(url.get());
 }
 
 void
-Gecko_CSSValue_SetLocal(nsCSSValueBorrowedMut aCSSValue, const nsString aFamily)
+Gecko_CSSValue_SetInt(nsCSSValueBorrowedMut aCSSValue,
+                      int32_t aInteger, nsCSSUnit aUnit)
 {
-  MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null);
-  aCSSValue->SetStringValue(aFamily, eCSSUnit_Local_Font);
-}
-
-void
-Gecko_CSSValue_SetInteger(nsCSSValueBorrowedMut aCSSValue, int32_t aInteger)
-{
-  MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null ||
-    aCSSValue->GetUnit() == eCSSUnit_Integer);
-  aCSSValue->SetIntValue(aInteger, eCSSUnit_Integer);
+  aCSSValue->SetIntValue(aInteger, aUnit);
 }
 
 nsCSSValueBorrowedMut
 Gecko_CSSValue_GetArrayItem(nsCSSValueBorrowedMut aCSSValue, int32_t aIndex)
 {
   return &aCSSValue->GetArrayValue()->Item(aIndex);
 }
 
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -364,28 +364,30 @@ nsCSSValueBorrowed Gecko_CSSValue_GetArr
 nscoord Gecko_CSSValue_GetAbsoluteLength(nsCSSValueBorrowed css_value);
 float Gecko_CSSValue_GetAngle(nsCSSValueBorrowed css_value);
 nsCSSKeyword Gecko_CSSValue_GetKeyword(nsCSSValueBorrowed aCSSValue);
 float Gecko_CSSValue_GetNumber(nsCSSValueBorrowed css_value);
 float Gecko_CSSValue_GetPercentage(nsCSSValueBorrowed css_value);
 nsStyleCoord::CalcValue Gecko_CSSValue_GetCalc(nsCSSValueBorrowed aCSSValue);
 
 void Gecko_CSSValue_SetAbsoluteLength(nsCSSValueBorrowedMut css_value, nscoord len);
+void Gecko_CSSValue_SetNormal(nsCSSValueBorrowedMut css_value);
 void Gecko_CSSValue_SetNumber(nsCSSValueBorrowedMut css_value, float number);
 void Gecko_CSSValue_SetKeyword(nsCSSValueBorrowedMut css_value, nsCSSKeyword keyword);
 void Gecko_CSSValue_SetPercentage(nsCSSValueBorrowedMut css_value, float percent);
 void Gecko_CSSValue_SetAngle(nsCSSValueBorrowedMut css_value, float radians);
 void Gecko_CSSValue_SetCalc(nsCSSValueBorrowedMut css_value, nsStyleCoord::CalcValue calc);
 void Gecko_CSSValue_SetFunction(nsCSSValueBorrowedMut css_value, int32_t len);
-void Gecko_CSSValue_SetString(nsCSSValueBorrowedMut css_value, const uint8_t* string, uint32_t len);
-void Gecko_CSSValue_SetIdent(nsCSSValueBorrowedMut css_value, const uint8_t* string, uint32_t len);
+void Gecko_CSSValue_SetString(nsCSSValueBorrowedMut css_value,
+                              const uint8_t* string, uint32_t len, nsCSSUnit unit);
+void Gecko_CSSValue_SetStringFromAtom(nsCSSValueBorrowedMut css_value,
+                                      nsIAtom* atom, nsCSSUnit unit);
 void Gecko_CSSValue_SetArray(nsCSSValueBorrowedMut css_value, int32_t len);
 void Gecko_CSSValue_SetURL(nsCSSValueBorrowedMut css_value, ServoBundledURI uri);
-void Gecko_CSSValue_SetLocal(nsCSSValueBorrowedMut css_value, const nsString family);
-void Gecko_CSSValue_SetInteger(nsCSSValueBorrowedMut css_value, int32_t integer);
+void Gecko_CSSValue_SetInt(nsCSSValueBorrowedMut css_value, int32_t integer, nsCSSUnit unit);
 void Gecko_CSSValue_Drop(nsCSSValueBorrowedMut css_value);
 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsCSSValueSharedList, CSSValueSharedList);
 bool Gecko_PropertyId_IsPrefEnabled(nsCSSPropertyID id);
 
 void Gecko_nsStyleFont_SetLang(nsStyleFont* font, nsIAtom* atom);
 void Gecko_nsStyleFont_CopyLangFrom(nsStyleFont* aFont, const nsStyleFont* aSource);
 nscoord Gecko_nsStyleFont_GetBaseSize(const nsStyleFont* font, RawGeckoPresContextBorrowed pres_context);