Bug 1367293 - Early return from ValueFromStringHelper() if the target element is not associated with any documents. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Fri, 02 Jun 2017 09:38:00 +0900
changeset 588044 6b8cde612394ab13f8ee2ca6e3a180cb1515764e
parent 588043 c161f6f4aec6cd9d9eb81d4d03122c083b29ef6b
child 588045 9be37aca18cdf17c6fcb5e5177904c0a42d39dc2
push id61886
push userhikezoe@mozilla.com
push dateFri, 02 Jun 2017 02:26:43 +0000
reviewersbirtles
bugs1367293
milestone55.0a1
Bug 1367293 - Early return from ValueFromStringHelper() if the target element is not associated with any documents. r?birtles MozReview-Commit-ID: 1mcCb5txtB4
dom/smil/nsSMILCSSValueType.cpp
--- a/dom/smil/nsSMILCSSValueType.cpp
+++ b/dom/smil/nsSMILCSSValueType.cpp
@@ -461,49 +461,50 @@ ValueFromStringHelper(nsCSSPropertyID aP
                       nsStyleContext* aStyleContext,
                       const nsAString& aString)
 {
   // FIXME (bug 1358966): Support shorthand properties
   if (nsCSSProps::IsShorthand(aPropID)) {
     return nullptr;
   }
 
-  // Get a suitable style context for Servo
-  const ServoComputedValues* currentStyle =
-    aStyleContext->StyleSource().AsServoComputedValues();
-  // Bug 1349004: Remove GetParentAllowServo
-  const ServoComputedValues* parentStyle =
-    aStyleContext->GetParentAllowServo()
-    ? aStyleContext->GetParentAllowServo()->StyleSource()
-      .AsServoComputedValues()
-    : nullptr;
-  const ServoComputedValuesWithParent servoStyles =
-    { currentStyle, parentStyle };
-
-  // Parse property
   nsIDocument* doc = aTargetElement->GetUncomposedDoc();
   if (!doc) {
     return nullptr;
   }
+
+  // Parse property
   // FIXME this is using the wrong base uri (bug 1343919)
   RefPtr<URLExtraData> data = new URLExtraData(doc->GetDocumentURI(),
                                                doc->GetDocumentURI(),
                                                doc->NodePrincipal());
   NS_ConvertUTF16toUTF8 value(aString);
   RefPtr<RawServoDeclarationBlock> servoDeclarationBlock =
     Servo_ParseProperty(aPropID,
                         &value,
                         data,
                         ParsingMode::AllowUnitlessLength |
                         ParsingMode::AllowAllNumericValues,
                         doc->GetCompatibilityMode()).Consume();
   if (!servoDeclarationBlock) {
     return nullptr;
   }
 
+  // Get a suitable style context for Servo
+  const ServoComputedValues* currentStyle =
+    aStyleContext->StyleSource().AsServoComputedValues();
+  // Bug 1349004: Remove GetParentAllowServo
+  const ServoComputedValues* parentStyle =
+    aStyleContext->GetParentAllowServo()
+    ? aStyleContext->GetParentAllowServo()->StyleSource()
+      .AsServoComputedValues()
+    : nullptr;
+  const ServoComputedValuesWithParent servoStyles =
+    { currentStyle, parentStyle };
+
   // Compute value
   PropertyValuePair propValuePair;
   propValuePair.mProperty = aPropID;
   propValuePair.mServoDeclarationBlock = servoDeclarationBlock;
   AutoTArray<Keyframe, 1> keyframes;
   keyframes.AppendElement()->mPropertyValues.AppendElement(Move(propValuePair));
   nsTArray<ComputedKeyframeValues> computedValues =
     aPresContext->StyleSet()->AsServo()