Bug 1334036 - Part 9: Handle None transform properly. draft
authorBoris Chiou <boris.chiou@gmail.com>
Sat, 18 Feb 2017 18:49:26 +0800
changeset 579534 c47ef4e0d5e676b08345cdc60aab8e47881b9e8b
parent 579533 82650a1a0eb51d55b078a9eec5f86602799bac9a
child 579535 72c5e41b51162c1855805f9fabcd0fe8f9578840
push id59275
push userbmo:boris.chiou@gmail.com
push dateWed, 17 May 2017 11:38:11 +0000
bugs1334036
milestone55.0a1
Bug 1334036 - Part 9: Handle None transform properly. If the transform is None, we should return a valid None transform from FFI. MozReview-Commit-ID: 49cFXE2BIbm
js/src/devtools/rootAnalysis/analyzeHeapWrites.js
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
servo/components/style/gecko/generated/bindings.rs
servo/ports/geckolib/glue.rs
--- a/js/src/devtools/rootAnalysis/analyzeHeapWrites.js
+++ b/js/src/devtools/rootAnalysis/analyzeHeapWrites.js
@@ -380,16 +380,17 @@ function ignoreContents(entry)
 
         // The analysis can't cope with the indirection used for the objects
         // being initialized here.
         "Gecko_GetOrCreateKeyframeAtStart",
         "Gecko_GetOrCreateInitialKeyframe",
         "Gecko_GetOrCreateFinalKeyframe",
         "Gecko_NewStyleQuoteValues",
         "Gecko_NewCSSValueSharedList",
+        "Gecko_NewNoneTransform",
         "Gecko_NewGridTemplateAreasValue",
         /nsCSSValue::SetCalcValue/,
         /CSSValueSerializeCalcOps::Append/,
         "Gecko_CSSValue_SetFunction",
         "Gecko_CSSValue_SetArray",
         "Gecko_EnsureMozBorderColors",
         "Gecko_ClearMozBorderColors",
         "Gecko_AppendMozBorderColors",
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -1767,16 +1767,25 @@ Gecko_NewCSSValueSharedList(uint32_t aLe
   for (uint32_t i = 0; i < aLen - 1; i++) {
     cur->mNext = new nsCSSValueList;
     cur = cur->mNext;
   }
 
   return list.forget().take();
 }
 
+nsCSSValueSharedList*
+Gecko_NewNoneTransform()
+{
+  RefPtr<nsCSSValueSharedList> list = new nsCSSValueSharedList;
+  list->mHead = new nsCSSValueList;
+  list->mHead->mValue.SetNoneValue();
+  return list.forget().take();
+}
+
 void
 Gecko_CSSValue_SetAbsoluteLength(nsCSSValueBorrowedMut aCSSValue, nscoord aLen)
 {
   MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null || aCSSValue->IsLengthUnit());
   // The call below could trigger refcounting if aCSSValue were a
   // FontFamilyList, but we just asserted that it's not. So we can
   // whitelist this for static analysis.
   aCSSValue->SetIntegerCoordValue(aLen);
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -452,16 +452,17 @@ NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsSty
 
 nsCSSShadowArray* Gecko_NewCSSShadowArray(uint32_t len);
 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsCSSShadowArray, CSSShadowArray);
 
 nsStyleQuoteValues* Gecko_NewStyleQuoteValues(uint32_t len);
 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsStyleQuoteValues, QuoteValues);
 
 nsCSSValueSharedList* Gecko_NewCSSValueSharedList(uint32_t len);
+nsCSSValueSharedList* Gecko_NewNoneTransform();
 
 // Getter for nsCSSValue
 nsCSSValueBorrowedMut Gecko_CSSValue_GetArrayItem(nsCSSValueBorrowedMut css_value, int32_t index);
 // const version of the above function.
 nsCSSValueBorrowed Gecko_CSSValue_GetArrayItemConst(nsCSSValueBorrowed css_value, int32_t index);
 nscoord Gecko_CSSValue_GetAbsoluteLength(nsCSSValueBorrowed css_value);
 nsCSSKeyword Gecko_CSSValue_GetKeyword(nsCSSValueBorrowed aCSSValue);
 float Gecko_CSSValue_GetNumber(nsCSSValueBorrowed css_value);
--- a/servo/components/style/gecko/generated/bindings.rs
+++ b/servo/components/style/gecko/generated/bindings.rs
@@ -1129,16 +1129,19 @@ extern "C" {
 extern "C" {
     pub fn Gecko_ReleaseQuoteValuesArbitraryThread(aPtr:
                                                        *mut nsStyleQuoteValues);
 }
 extern "C" {
     pub fn Gecko_NewCSSValueSharedList(len: u32) -> *mut nsCSSValueSharedList;
 }
 extern "C" {
+    pub fn Gecko_NewNoneTransform() -> *mut nsCSSValueSharedList;
+}
+extern "C" {
     pub fn Gecko_CSSValue_GetArrayItem(css_value: nsCSSValueBorrowedMut,
                                        index: i32) -> nsCSSValueBorrowedMut;
 }
 extern "C" {
     pub fn Gecko_CSSValue_GetArrayItemConst(css_value: nsCSSValueBorrowed,
                                             index: i32) -> nsCSSValueBorrowed;
 }
 extern "C" {
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -39,16 +39,17 @@ use style::gecko_bindings::bindings::{Ra
 use style::gecko_bindings::bindings::{RawServoStyleSheetStrong, ServoComputedValuesStrong};
 use style::gecko_bindings::bindings::{RawServoSupportsRule, RawServoSupportsRuleBorrowed};
 use style::gecko_bindings::bindings::{ServoCssRulesBorrowed, ServoCssRulesStrong};
 use style::gecko_bindings::bindings::{nsACString, nsAString, nsCSSPropertyIDSetBorrowedMut};
 use style::gecko_bindings::bindings::Gecko_AddPropertyToSet;
 use style::gecko_bindings::bindings::Gecko_GetOrCreateFinalKeyframe;
 use style::gecko_bindings::bindings::Gecko_GetOrCreateInitialKeyframe;
 use style::gecko_bindings::bindings::Gecko_GetOrCreateKeyframeAtStart;
+use style::gecko_bindings::bindings::Gecko_NewNoneTransform;
 use style::gecko_bindings::bindings::RawGeckoAnimationPropertySegmentBorrowed;
 use style::gecko_bindings::bindings::RawGeckoComputedKeyframeValuesListBorrowedMut;
 use style::gecko_bindings::bindings::RawGeckoComputedTimingBorrowed;
 use style::gecko_bindings::bindings::RawGeckoCSSPropertyIDListBorrowed;
 use style::gecko_bindings::bindings::RawGeckoElementBorrowed;
 use style::gecko_bindings::bindings::RawGeckoFontFaceRuleListBorrowedMut;
 use style::gecko_bindings::bindings::RawGeckoServoStyleRuleListBorrowedMut;
 use style::gecko_bindings::bindings::RawServoAnimationValueBorrowed;
@@ -424,17 +425,25 @@ pub extern "C" fn Servo_AnimationValue_G
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_AnimationValue_GetTransform(value: RawServoAnimationValueBorrowed,
                                                     list: *mut structs::RefPtr<nsCSSValueSharedList>)
 {
     let value = AnimationValue::as_arc(&value);
     if let AnimationValue::Transform(ref servo_list) = **value {
-        style_structs::Box::convert_transform(servo_list.0.clone().unwrap(), unsafe { &mut *list });
+        let list = unsafe { &mut *list };
+        match servo_list.0 {
+            Some(ref servo_list) => {
+                style_structs::Box::convert_transform(servo_list.clone(), list);
+            },
+            None => unsafe {
+                list.set_move(RefPtr::from_addrefed(Gecko_NewNoneTransform()));
+            }
+        }
     } else {
         panic!("The AnimationValue should be transform");
     }
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_AnimationValue_DeepEqual(this: RawServoAnimationValueBorrowed,
                                                  other: RawServoAnimationValueBorrowed)