Bug 1346052 - Part 1: Factor out ParseProperty. r=birtles

We can reuse ParseProperty in nsDOMWindowUtils::ComputeAnimationDistance(),
so factor out this function.

MozReview-Commit-ID: FdXGPxOZf84

--HG--
extra : rebase_source : 525bb436fdc1ce4d1241a08b198f9cd572506a86
This commit is contained in:
Boris Chiou 2017-03-24 17:35:27 +08:00
Родитель a9d71f94f4
Коммит c78d90ed63
2 изменённых файлов: 33 добавлений и 8 удалений

Просмотреть файл

@ -730,6 +730,21 @@ KeyframeUtils::IsAnimatableProperty(nsCSSPropertyID aProperty)
return false;
}
/* static */ already_AddRefed<RawServoDeclarationBlock>
KeyframeUtils::ParseProperty(nsCSSPropertyID aProperty,
const nsAString& aValue,
nsIDocument* aDocument)
{
MOZ_ASSERT(aDocument);
NS_ConvertUTF16toUTF8 value(aValue);
// FIXME this is using the wrong base uri (bug 1343919)
RefPtr<URLExtraData> data = new URLExtraData(aDocument->GetDocumentURI(),
aDocument->GetDocumentURI(),
aDocument->NodePrincipal());
return Servo_ParseProperty(aProperty, &value, data).Consume();
}
// ------------------------------------------------------------------
//
// Internal helpers
@ -1015,15 +1030,8 @@ MakePropertyValuePair(nsCSSPropertyID aProperty, const nsAString& aStringValue,
result.mProperty = aProperty;
if (aDocument->GetStyleBackendType() == StyleBackendType::Servo) {
NS_ConvertUTF16toUTF8 value(aStringValue);
// FIXME this is using the wrong base uri (bug 1343919)
RefPtr<URLExtraData> data = new URLExtraData(aDocument->GetDocumentURI(),
aDocument->GetDocumentURI(),
aDocument->NodePrincipal());
RefPtr<RawServoDeclarationBlock> servoDeclarationBlock =
Servo_ParseProperty(aProperty, &value, data).Consume();
KeyframeUtils::ParseProperty(aProperty, aStringValue, aDocument);
if (servoDeclarationBlock) {
result.mServoDeclarationBlock = servoDeclarationBlock.forget();

Просмотреть файл

@ -16,6 +16,7 @@ class JSObject;
class nsIDocument;
class nsStyleContext;
struct ServoComputedValues;
struct RawServoDeclarationBlock;
namespace mozilla {
struct AnimationProperty;
@ -161,6 +162,22 @@ public:
* @return true if |aProperty| is animatable.
*/
static bool IsAnimatableProperty(nsCSSPropertyID aProperty);
/**
* Parse a string representing a CSS property value into a
* RawServoDeclarationBlock.
*
* @param aProperty The property to be parsed.
* @param aValue The specified value.
* @param aDocument The current document.
* @return The parsed value as a RawServoDeclarationBlock. We put the value
* in a declaration block since that is how we represent specified values
* in Servo.
*/
static already_AddRefed<RawServoDeclarationBlock> ParseProperty(
nsCSSPropertyID aProperty,
const nsAString& aValue,
nsIDocument* aDocument);
};
} // namespace mozilla