Bug 1334036 - Part 6: Handle None transform properly. draft
authorBoris Chiou <boris.chiou@gmail.com>
Sat, 18 Feb 2017 18:49:26 +0800
changeset 486979 a2401754d3f2715a489e9ac11c3581044d8b0b2b
parent 486978 7e844f4849eb5ed5e759a6b4b86375d0d1c97137
child 486980 60db9b299c06923183b4f4ec8e3b1d1dc66af4f3
push id46109
push userbmo:boris.chiou@gmail.com
push dateMon, 20 Feb 2017 11:01:51 +0000
bugs1334036
milestone54.0a1
Bug 1334036 - Part 6: Handle None transform properly. If the transform is None, we should return a valid None transform from FFI. MozReview-Commit-ID: 49cFXE2BIbm
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
servo/ports/geckolib/glue.rs
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -1095,16 +1095,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
@@ -296,16 +296,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);
 float Gecko_CSSValue_GetAngle(nsCSSValueBorrowed css_value);
 nsCSSKeyword Gecko_CSSValue_GetKeyword(nsCSSValueBorrowed aCSSValue);
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -35,16 +35,17 @@ use style::gecko_bindings::bindings::{Ra
 use style::gecko_bindings::bindings::{RawServoStyleSetBorrowed, RawServoStyleSetOwned};
 use style::gecko_bindings::bindings::{RawServoStyleSheetBorrowed, ServoComputedValuesBorrowed};
 use style::gecko_bindings::bindings::{RawServoStyleSheetStrong, ServoComputedValuesStrong};
 use style::gecko_bindings::bindings::{ServoCssRulesBorrowed, ServoCssRulesStrong};
 use style::gecko_bindings::bindings::{nsACString, nsCSSValueBorrowedMut, nsAString};
 use style::gecko_bindings::bindings::nsCSSPropertyIDSetBorrowedMut;
 use style::gecko_bindings::bindings::Gecko_AnimationAppendKeyframe;
 use style::gecko_bindings::bindings::Gecko_AddPropertyToSet;
+use style::gecko_bindings::bindings::Gecko_NewNoneTransform;
 use style::gecko_bindings::bindings::RawGeckoAnimationValueListBorrowedMut;
 use style::gecko_bindings::bindings::RawGeckoElementBorrowed;
 use style::gecko_bindings::bindings::RawGeckoKeyframeListBorrowedMut;
 use style::gecko_bindings::bindings::RawGeckoPresContextBorrowed;
 use style::gecko_bindings::bindings::RawServoAnimationValueBorrowed;
 use style::gecko_bindings::bindings::RawServoAnimationValueStrong;
 use style::gecko_bindings::bindings::RawServoImportRuleBorrowed;
 use style::gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
@@ -58,16 +59,17 @@ use style::gecko_bindings::structs::Load
 use style::gecko_bindings::structs::RawGeckoPresContextOwned;
 use style::gecko_bindings::structs::RawServoAnimationValueBorrowedListBorrowed;
 use style::gecko_bindings::structs::ServoStyleSheet;
 use style::gecko_bindings::structs::nsCSSValueSharedList;
 use style::gecko_bindings::structs::nsTimingFunction;
 use style::gecko_bindings::structs::nsresult;
 use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI, HasBoxFFI};
 use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, Strong};
+use style::gecko_bindings::sugar::refptr;
 use style::gecko_bindings::sugar::refptr::{GeckoArcPrincipal, GeckoArcURI};
 use style::gecko_properties::style_structs;
 use style::keyframes::KeyframesStepValue;
 use style::parallel;
 use style::parser::{ParserContext, ParserContextExtraData};
 use style::properties::{ComputedValues, Importance, PropertyDeclaration};
 use style::properties::{PropertyDeclarationParseResult, PropertyDeclarationBlock, PropertyId};
 use style::properties::animated_properties::{AnimationValue, Interpolate, TransitionProperty};
@@ -260,17 +262,22 @@ 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 };
+        if servo_list.0.is_none() {
+            unsafe{ list.set_move(refptr::RefPtr::from_addrefed(Gecko_NewNoneTransform())) };
+        } else {
+            style_structs::Box::convert_transform(servo_list.0.clone().unwrap(), list);
+        }
     } else {
         panic!("The AnimationValue should be transform");
     }
 }
 
 /// Takes a ServoAnimationValues and populates it with the animation values corresponding
 /// to a given property declaration block
 #[no_mangle]