зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1458814: Make SMIL values not roundtrip through strings. r=hiro
MozReview-Commit-ID: DpbFSutIv3t
This commit is contained in:
Родитель
9af9052231
Коммит
d7f92df0f2
|
@ -16,7 +16,9 @@
|
||||||
#include "nsCSSValue.h"
|
#include "nsCSSValue.h"
|
||||||
#include "nsColor.h"
|
#include "nsColor.h"
|
||||||
#include "nsPresContext.h"
|
#include "nsPresContext.h"
|
||||||
|
#include "mozilla/DeclarationBlockInlines.h"
|
||||||
#include "mozilla/ServoBindings.h"
|
#include "mozilla/ServoBindings.h"
|
||||||
|
#include "mozilla/ServoDeclarationBlock.h"
|
||||||
#include "mozilla/StyleAnimationValue.h" // For AnimationValue
|
#include "mozilla/StyleAnimationValue.h" // For AnimationValue
|
||||||
#include "mozilla/ServoCSSParser.h"
|
#include "mozilla/ServoCSSParser.h"
|
||||||
#include "mozilla/ServoStyleSet.h"
|
#include "mozilla/ServoStyleSet.h"
|
||||||
|
@ -630,6 +632,28 @@ nsSMILCSSValueType::ValueToString(const nsSMILValue& aValue,
|
||||||
&aString);
|
&aString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
bool
|
||||||
|
nsSMILCSSValueType::SetPropertyValues(const nsSMILValue& aValue,
|
||||||
|
DeclarationBlock& aDecl)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(aValue.mType == &nsSMILCSSValueType::sSingleton,
|
||||||
|
"Unexpected SMIL value type");
|
||||||
|
const ValueWrapper* wrapper = ExtractValueWrapper(aValue);
|
||||||
|
if (!wrapper) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool changed = false;
|
||||||
|
for (const auto& value : wrapper->mServoValues) {
|
||||||
|
changed |=
|
||||||
|
Servo_DeclarationBlock_SetPropertyToAnimationValue(
|
||||||
|
aDecl.AsServo()->Raw(), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
nsCSSPropertyID
|
nsCSSPropertyID
|
||||||
nsSMILCSSValueType::PropertyFromValue(const nsSMILValue& aValue)
|
nsSMILCSSValueType::PropertyFromValue(const nsSMILValue& aValue)
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
struct AnimationValue;
|
struct AnimationValue;
|
||||||
|
class DeclarationBlock;
|
||||||
namespace dom {
|
namespace dom {
|
||||||
class Element;
|
class Element;
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
@ -114,6 +115,13 @@ public:
|
||||||
*/
|
*/
|
||||||
static void ValueToString(const nsSMILValue& aValue, nsAString& aString);
|
static void ValueToString(const nsSMILValue& aValue, nsAString& aString);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the relevant property values in the declaration block.
|
||||||
|
*
|
||||||
|
* Returns whether the declaration changed.
|
||||||
|
*/
|
||||||
|
static bool SetPropertyValues(const nsSMILValue&, mozilla::DeclarationBlock&);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the CSS property animated by the specified value.
|
* Return the CSS property animated by the specified value.
|
||||||
*
|
*
|
||||||
|
|
|
@ -557,6 +557,9 @@ SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetProperty, bool,
|
||||||
mozilla::ParsingMode parsing_mode,
|
mozilla::ParsingMode parsing_mode,
|
||||||
nsCompatibility quirks_mode,
|
nsCompatibility quirks_mode,
|
||||||
mozilla::css::Loader* loader)
|
mozilla::css::Loader* loader)
|
||||||
|
SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetPropertyToAnimationValue, bool,
|
||||||
|
RawServoDeclarationBlockBorrowed declarations,
|
||||||
|
RawServoAnimationValueBorrowed animation_value)
|
||||||
SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetPropertyById, bool,
|
SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetPropertyById, bool,
|
||||||
RawServoDeclarationBlockBorrowed declarations,
|
RawServoDeclarationBlockBorrowed declarations,
|
||||||
nsCSSPropertyID property,
|
nsCSSPropertyID property,
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "mozilla/dom/MutationEventBinding.h"
|
#include "mozilla/dom/MutationEventBinding.h"
|
||||||
#include "mozilla/InternalMutationEvent.h"
|
#include "mozilla/InternalMutationEvent.h"
|
||||||
#include "mozilla/ServoDeclarationBlock.h"
|
#include "mozilla/ServoDeclarationBlock.h"
|
||||||
|
#include "mozAutoDocUpdate.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
#include "nsIURI.h"
|
#include "nsIURI.h"
|
||||||
|
@ -172,19 +173,20 @@ nsDOMCSSAttributeDeclaration::SetSMILValue(const nsCSSPropertyID aPropID,
|
||||||
const nsSMILValue& aValue)
|
const nsSMILValue& aValue)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mIsSMILOverride);
|
MOZ_ASSERT(mIsSMILOverride);
|
||||||
|
// No need to do the ActiveLayerTracker / ScrollLinkedEffectDetector bits,
|
||||||
// Convert nsSMILValue to string.
|
// since we're in a SMIL animation anyway, no need to try to detect we're a
|
||||||
//
|
// scripted animation.
|
||||||
// FIXME(emilio): This roundtrip should go away.
|
DeclarationBlock* olddecl = GetCSSDeclaration(eOperation_Modify);
|
||||||
nsAutoString valStr;
|
if (!olddecl) {
|
||||||
nsSMILCSSValueType::ValueToString(aValue, valStr);
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
|
|
||||||
nsAutoString oldValStr;
|
|
||||||
GetPropertyValue(aPropID, oldValStr);
|
|
||||||
if (valStr.Equals(oldValStr)) {
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
return SetPropertyValue(aPropID, valStr, nullptr);
|
mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true);
|
||||||
|
RefPtr<DeclarationBlock> decl = olddecl->EnsureMutable();
|
||||||
|
bool changed = nsSMILCSSValueType::SetPropertyValues(aValue, *decl);
|
||||||
|
if (changed) {
|
||||||
|
SetCSSDeclaration(decl);
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
|
|
@ -3609,6 +3609,20 @@ pub unsafe extern "C" fn Servo_DeclarationBlock_SetProperty(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn Servo_DeclarationBlock_SetPropertyToAnimationValue(
|
||||||
|
declarations: RawServoDeclarationBlockBorrowed,
|
||||||
|
animation_value: RawServoAnimationValueBorrowed,
|
||||||
|
) -> bool {
|
||||||
|
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||||
|
decls.push(
|
||||||
|
AnimationValue::as_arc(&animation_value).uncompute(),
|
||||||
|
Importance::Normal,
|
||||||
|
DeclarationSource::CssOm,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn Servo_DeclarationBlock_SetPropertyById(
|
pub unsafe extern "C" fn Servo_DeclarationBlock_SetPropertyById(
|
||||||
declarations: RawServoDeclarationBlockBorrowed,
|
declarations: RawServoDeclarationBlockBorrowed,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче