Bug 1331213: Add an API to drop a nsCSSValue in the stack. r?heycam
The getter function may create an nsCSSValue with allocated stuff, and we don't
want to leak it.
MozReview-Commit-ID: DYkUD8CW88E
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -1049,16 +1049,22 @@ Gecko_CSSValue_SetFunction(nsCSSValueBor
nsCSSValueBorrowedMut
Gecko_CSSValue_GetArrayItem(nsCSSValueBorrowedMut aCSSValue, int32_t aIndex)
{
return &aCSSValue->GetArrayValue()->Item(aIndex);
}
void
+Gecko_CSSValue_Drop(nsCSSValueBorrowedMut aCSSValue)
+{
+ aCSSValue->~nsCSSValue();
+}
+
+void
Gecko_LoadStyleSheet(css::Loader* aLoader,
ServoStyleSheet* aParent,
RawServoImportRuleBorrowed aImportRule,
const uint8_t* aURLString,
uint32_t aURLStringLength,
const uint8_t* aMediaString,
uint32_t aMediaStringLength)
{
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -288,16 +288,17 @@ nsCSSValueSharedList* Gecko_NewCSSValueS
void Gecko_CSSValue_SetAbsoluteLength(nsCSSValueBorrowedMut css_value, nscoord len);
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);
nsCSSValueBorrowedMut Gecko_CSSValue_GetArrayItem(nsCSSValueBorrowedMut css_value, int32_t index);
+void Gecko_CSSValue_Drop(nsCSSValueBorrowedMut css_value);
NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsCSSValueSharedList, CSSValueSharedList);
const nsMediaFeature* Gecko_GetMediaFeatures();
// Style-struct management.
#define STYLE_STRUCT(name, checkdata_cb) \
void Gecko_Construct_Default_nsStyle##name( \
nsStyle##name* ptr, \
--- a/servo/components/style/gecko_bindings/bindings.rs
+++ b/servo/components/style/gecko_bindings/bindings.rs
@@ -731,16 +731,19 @@ extern "C" {
pub fn Gecko_CSSValue_SetFunction(css_value: nsCSSValueBorrowedMut,
len: i32);
}
extern "C" {
pub fn Gecko_CSSValue_GetArrayItem(css_value: nsCSSValueBorrowedMut,
index: i32) -> nsCSSValueBorrowedMut;
}
extern "C" {
+ pub fn Gecko_CSSValue_Drop(css_value: nsCSSValueBorrowedMut);
+}
+extern "C" {
pub fn Gecko_AddRefCSSValueSharedListArbitraryThread(aPtr:
*mut nsCSSValueSharedList);
}
extern "C" {
pub fn Gecko_ReleaseCSSValueSharedListArbitraryThread(aPtr:
*mut nsCSSValueSharedList);
}
extern "C" {