зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 07a20e5f68e3 (bug 1524314) for Build bustage in dom/svg/DOMSVGPointList.h. a=backout
This commit is contained in:
Родитель
42f90a41e1
Коммит
04fc1721e0
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "DOMSVGLengthList.h"
|
||||
#include "DOMSVGAnimatedLengthList.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsError.h"
|
||||
#include "nsMathUtils.h"
|
||||
#include "SVGAnimatedLength.h"
|
||||
|
@ -59,6 +60,37 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGLength)
|
|||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangeLengthNotifier
|
||||
// Stack-based helper class to pair calls to WillChangeLengthList and
|
||||
// DidChangeLengthList.
|
||||
class MOZ_RAII AutoChangeLengthNotifier : public mozAutoDocUpdate {
|
||||
public:
|
||||
explicit AutoChangeLengthNotifier(DOMSVGLength* aLength)
|
||||
: mozAutoDocUpdate(aLength->Element()->GetComposedDoc(), true),
|
||||
mLength(aLength) {
|
||||
MOZ_ASSERT(mLength, "Expecting non-null length");
|
||||
MOZ_ASSERT(mLength->HasOwner(),
|
||||
"Expecting list to have an owner for notification");
|
||||
mEmptyOrOldValue =
|
||||
mLength->Element()->WillChangeLengthList(mLength->mAttrEnum, *this);
|
||||
}
|
||||
|
||||
~AutoChangeLengthNotifier() {
|
||||
mLength->Element()->DidChangeLengthList(mLength->mAttrEnum,
|
||||
mEmptyOrOldValue, *this);
|
||||
// Null check mLength->mList, since DidChangeLengthList can run script,
|
||||
// potentially removing mLength from its list.
|
||||
if (mLength->mList && mLength->mList->IsAnimating()) {
|
||||
mLength->Element()->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
DOMSVGLength* const mLength;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
};
|
||||
|
||||
DOMSVGLength::DOMSVGLength(DOMSVGLengthList* aList, uint8_t aAttrEnum,
|
||||
uint32_t aListIndex, bool aIsAnimValItem)
|
||||
: mList(aList),
|
||||
|
@ -217,7 +249,7 @@ void DOMSVGLength::SetValue(float aUserUnitValue, ErrorResult& aRv) {
|
|||
if (uuPerUnit > 0) {
|
||||
float newValue = aUserUnitValue / uuPerUnit;
|
||||
if (IsFinite(newValue)) {
|
||||
AutoChangeLengthListNotifier notifier(this);
|
||||
AutoChangeLengthNotifier notifier(this);
|
||||
InternalItem().SetValueAndUnit(newValue, InternalItem().GetUnit());
|
||||
return;
|
||||
}
|
||||
|
@ -254,7 +286,9 @@ void DOMSVGLength::SetValueInSpecifiedUnits(float aValue, ErrorResult& aRv) {
|
|||
}
|
||||
|
||||
if (mVal) {
|
||||
mVal->SetBaseValueInSpecifiedUnits(aValue, mSVGElement, true);
|
||||
MOZ_ASSERT(mSVGElement);
|
||||
mozAutoDocUpdate updateBatch(mSVGElement->GetComposedDoc(), true);
|
||||
mVal->SetBaseValueInSpecifiedUnits(aValue, mSVGElement, true, updateBatch);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -262,7 +296,7 @@ void DOMSVGLength::SetValueInSpecifiedUnits(float aValue, ErrorResult& aRv) {
|
|||
if (InternalItem().GetValueInCurrentUnits() == aValue) {
|
||||
return;
|
||||
}
|
||||
AutoChangeLengthListNotifier notifier(this);
|
||||
AutoChangeLengthNotifier notifier(this);
|
||||
InternalItem().SetValueInCurrentUnits(aValue);
|
||||
return;
|
||||
}
|
||||
|
@ -289,7 +323,7 @@ void DOMSVGLength::SetValueAsString(const nsAString& aValue, ErrorResult& aRv) {
|
|||
if (InternalItem() == value) {
|
||||
return;
|
||||
}
|
||||
AutoChangeLengthListNotifier notifier(this);
|
||||
AutoChangeLengthNotifier notifier(this);
|
||||
InternalItem() = value;
|
||||
return;
|
||||
}
|
||||
|
@ -339,7 +373,7 @@ void DOMSVGLength::NewValueSpecifiedUnits(uint16_t aUnit, float aValue,
|
|||
InternalItem().GetValueInCurrentUnits() == aValue) {
|
||||
return;
|
||||
}
|
||||
AutoChangeLengthListNotifier notifier(this);
|
||||
AutoChangeLengthNotifier notifier(this);
|
||||
InternalItem().SetValueAndUnit(aValue, uint8_t(aUnit));
|
||||
return;
|
||||
}
|
||||
|
@ -369,7 +403,7 @@ void DOMSVGLength::ConvertToSpecifiedUnits(uint16_t aUnit, ErrorResult& aRv) {
|
|||
float val =
|
||||
InternalItem().GetValueInSpecifiedUnit(aUnit, Element(), Axis());
|
||||
if (IsFinite(val)) {
|
||||
AutoChangeLengthListNotifier notifier(this);
|
||||
AutoChangeLengthNotifier notifier(this);
|
||||
InternalItem().SetValueAndUnit(val, aUnit);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -79,10 +79,7 @@ class SVGElement;
|
|||
* https://bugzilla.mozilla.org/show_bug.cgi?id=571734
|
||||
*/
|
||||
class DOMSVGLength final : public nsISupports, public nsWrapperCache {
|
||||
template <class T>
|
||||
friend class AutoChangeLengthListNotifier;
|
||||
using AutoChangeLengthListNotifier =
|
||||
AutoChangeLengthListNotifier<DOMSVGLength>;
|
||||
friend class AutoChangeLengthNotifier;
|
||||
|
||||
/**
|
||||
* Ctor for creating the object returned by
|
||||
|
@ -122,11 +119,6 @@ class DOMSVGLength final : public nsISupports, public nsWrapperCache {
|
|||
|
||||
bool IsInList() const { return !!mList; }
|
||||
|
||||
/**
|
||||
* Returns true if our attribute is animating.
|
||||
*/
|
||||
bool IsAnimating() const { return mList && mList->IsAnimating(); }
|
||||
|
||||
/**
|
||||
* In future, if this class is used for non-list lengths, this will be
|
||||
* different to IsInList().
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "SVGElement.h"
|
||||
#include "DOMSVGLength.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsError.h"
|
||||
#include "SVGAnimatedLengthList.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -81,6 +82,33 @@ JSObject* DOMSVGLengthList::WrapObject(JSContext* cx,
|
|||
return mozilla::dom::SVGLengthList_Binding::Wrap(cx, this, aGivenProto);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangeLengthListNotifier
|
||||
// Stack-based helper class to pair calls to WillChangeLengthList and
|
||||
// DidChangeLengthList.
|
||||
class MOZ_RAII AutoChangeLengthListNotifier : public mozAutoDocUpdate {
|
||||
public:
|
||||
explicit AutoChangeLengthListNotifier(DOMSVGLengthList* aLengthList)
|
||||
: mozAutoDocUpdate(aLengthList->Element()->GetComposedDoc(), true),
|
||||
mLengthList(aLengthList) {
|
||||
MOZ_ASSERT(mLengthList, "Expecting non-null lengthList");
|
||||
mEmptyOrOldValue = mLengthList->Element()->WillChangeLengthList(
|
||||
mLengthList->AttrEnum(), *this);
|
||||
}
|
||||
|
||||
~AutoChangeLengthListNotifier() {
|
||||
mLengthList->Element()->DidChangeLengthList(mLengthList->AttrEnum(),
|
||||
mEmptyOrOldValue, *this);
|
||||
if (mLengthList->IsAnimating()) {
|
||||
mLengthList->Element()->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
DOMSVGLengthList* const mLengthList;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
};
|
||||
|
||||
void DOMSVGLengthList::InternalListLengthWillChange(uint32_t aNewLength) {
|
||||
uint32_t oldLength = mItems.Length();
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#define DOM_SVG_DOMSVGLENGTHLIST_H_
|
||||
|
||||
#include "DOMSVGAnimatedLengthList.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsTArray.h"
|
||||
|
@ -23,34 +22,6 @@ namespace dom {
|
|||
class DOMSVGLength;
|
||||
class SVGElement;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangeLengthListNotifier
|
||||
// Stack-based helper class to pair calls to WillChangeLengthList and
|
||||
// DidChangeLengthList. Used by DOMSVGLength and DOMSVGLengthList.
|
||||
template <class T>
|
||||
class MOZ_RAII AutoChangeLengthListNotifier : public mozAutoDocUpdate {
|
||||
public:
|
||||
explicit AutoChangeLengthListNotifier(T* aValue)
|
||||
: mozAutoDocUpdate(aValue->Element()->GetComposedDoc(), true),
|
||||
mValue(aValue) {
|
||||
MOZ_ASSERT(aValue, "Expecting non-null value");
|
||||
mEmptyOrOldValue =
|
||||
mValue->Element()->WillChangeLengthList(mValue->AttrEnum(), *this);
|
||||
}
|
||||
|
||||
~AutoChangeLengthListNotifier() {
|
||||
mValue->Element()->DidChangeLengthList(mValue->AttrEnum(), mEmptyOrOldValue,
|
||||
*this);
|
||||
if (mValue->IsAnimating()) {
|
||||
mValue->Element()->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
T* const mValue;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* Class DOMSVGLengthList
|
||||
*
|
||||
|
@ -69,11 +40,8 @@ class MOZ_RAII AutoChangeLengthListNotifier : public mozAutoDocUpdate {
|
|||
* Our DOM items are created lazily on demand as and when script requests them.
|
||||
*/
|
||||
class DOMSVGLengthList final : public nsISupports, public nsWrapperCache {
|
||||
template <class T>
|
||||
friend class AutoChangeLengthListNotifier;
|
||||
friend class DOMSVGLength;
|
||||
using AutoChangeLengthListNotifier =
|
||||
AutoChangeLengthListNotifier<DOMSVGLengthList>;
|
||||
|
||||
~DOMSVGLengthList() {
|
||||
// Our mAList's weak ref to us must be nulled out when we die. If GC has
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "DOMSVGAnimatedNumberList.h"
|
||||
#include "SVGAnimatedNumberList.h"
|
||||
#include "SVGElement.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsError.h"
|
||||
#include "nsContentUtils.h" // for NS_ENSURE_FINITE
|
||||
#include "mozilla/dom/SVGNumberBinding.h"
|
||||
|
@ -50,6 +51,37 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGNumber)
|
|||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangeNumberNotifier
|
||||
// Stack-based helper class to pair calls to WillChangeNumberList and
|
||||
// DidChangeNumberList.
|
||||
class MOZ_RAII AutoChangeNumberNotifier : public mozAutoDocUpdate {
|
||||
public:
|
||||
explicit AutoChangeNumberNotifier(DOMSVGNumber* aNumber)
|
||||
: mozAutoDocUpdate(aNumber->Element()->GetComposedDoc(), true),
|
||||
mNumber(aNumber) {
|
||||
MOZ_ASSERT(mNumber, "Expecting non-null number");
|
||||
MOZ_ASSERT(mNumber->HasOwner(),
|
||||
"Expecting list to have an owner for notification");
|
||||
mEmptyOrOldValue =
|
||||
mNumber->Element()->WillChangeNumberList(mNumber->mAttrEnum, *this);
|
||||
}
|
||||
|
||||
~AutoChangeNumberNotifier() {
|
||||
mNumber->Element()->DidChangeNumberList(mNumber->mAttrEnum,
|
||||
mEmptyOrOldValue, *this);
|
||||
// Null check mNumber->mList, since DidChangeNumberList can run script,
|
||||
// potentially removing mNumber from its list.
|
||||
if (mNumber->mList && mNumber->mList->IsAnimating()) {
|
||||
mNumber->Element()->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
DOMSVGNumber* const mNumber;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
};
|
||||
|
||||
DOMSVGNumber::DOMSVGNumber(DOMSVGNumberList* aList, uint8_t aAttrEnum,
|
||||
uint32_t aListIndex, bool aIsAnimValItem)
|
||||
: mList(aList),
|
||||
|
@ -98,7 +130,7 @@ void DOMSVGNumber::SetValue(float aValue, ErrorResult& aRv) {
|
|||
if (InternalItem() == aValue) {
|
||||
return;
|
||||
}
|
||||
AutoChangeNumberListNotifier notifier(this);
|
||||
AutoChangeNumberNotifier notifier(this);
|
||||
InternalItem() = aValue;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -38,10 +38,7 @@ class SVGSVGElement;
|
|||
* See the comment in DOMSVGLength.h (yes, LENGTH), which applies here too.
|
||||
*/
|
||||
class DOMSVGNumber final : public nsISupports, public nsWrapperCache {
|
||||
template <class T>
|
||||
friend class AutoChangeNumberListNotifier;
|
||||
using AutoChangeNumberListNotifier =
|
||||
AutoChangeNumberListNotifier<DOMSVGNumber>;
|
||||
friend class AutoChangeNumberNotifier;
|
||||
|
||||
~DOMSVGNumber() {
|
||||
// Our mList's weak ref to us must be nulled out when we die. If GC has
|
||||
|
@ -83,11 +80,6 @@ class DOMSVGNumber final : public nsISupports, public nsWrapperCache {
|
|||
|
||||
bool IsInList() const { return !!mList; }
|
||||
|
||||
/**
|
||||
* Returns true if our attribute is animating.
|
||||
*/
|
||||
bool IsAnimating() const { return mList && mList->IsAnimating(); }
|
||||
|
||||
/**
|
||||
* In future, if this class is used for non-list numbers, this will be
|
||||
* different to IsInList().
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "SVGElement.h"
|
||||
#include "DOMSVGNumber.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsError.h"
|
||||
#include "SVGAnimatedNumberList.h"
|
||||
#include "mozilla/dom/SVGNumberListBinding.h"
|
||||
|
@ -74,6 +75,33 @@ JSObject* DOMSVGNumberList::WrapObject(JSContext* cx,
|
|||
return mozilla::dom::SVGNumberList_Binding::Wrap(cx, this, aGivenProto);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangeNumberListNotifier
|
||||
// Stack-based helper class to pair calls to WillChangeNumberList and
|
||||
// DidChangeNumberList.
|
||||
class MOZ_RAII AutoChangeNumberListNotifier : public mozAutoDocUpdate {
|
||||
public:
|
||||
explicit AutoChangeNumberListNotifier(DOMSVGNumberList* aNumberList)
|
||||
: mozAutoDocUpdate(aNumberList->Element()->GetComposedDoc(), true),
|
||||
mNumberList(aNumberList) {
|
||||
MOZ_ASSERT(mNumberList, "Expecting non-null numberList");
|
||||
mEmptyOrOldValue = mNumberList->Element()->WillChangeNumberList(
|
||||
mNumberList->AttrEnum(), *this);
|
||||
}
|
||||
|
||||
~AutoChangeNumberListNotifier() {
|
||||
mNumberList->Element()->DidChangeNumberList(mNumberList->AttrEnum(),
|
||||
mEmptyOrOldValue, *this);
|
||||
if (mNumberList->IsAnimating()) {
|
||||
mNumberList->Element()->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
DOMSVGNumberList* const mNumberList;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
};
|
||||
|
||||
void DOMSVGNumberList::InternalListLengthWillChange(uint32_t aNewLength) {
|
||||
uint32_t oldLength = mItems.Length();
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#define DOM_SVG_DOMSVGNUMBERLIST_H_
|
||||
|
||||
#include "DOMSVGAnimatedNumberList.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsTArray.h"
|
||||
|
@ -23,34 +22,6 @@ namespace dom {
|
|||
class DOMSVGNumber;
|
||||
class SVGElement;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangeNumberListNotifier
|
||||
// Stack-based helper class to pair calls to WillChangeNumberList and
|
||||
// DidChangeNumberList. Used by DOMSVGNumber and DOMSVGNumberList.
|
||||
template <class T>
|
||||
class MOZ_RAII AutoChangeNumberListNotifier : public mozAutoDocUpdate {
|
||||
public:
|
||||
explicit AutoChangeNumberListNotifier(T* aValue)
|
||||
: mozAutoDocUpdate(aValue->Element()->GetComposedDoc(), true),
|
||||
mValue(aValue) {
|
||||
MOZ_ASSERT(mValue, "Expecting non-null value");
|
||||
mEmptyOrOldValue =
|
||||
mValue->Element()->WillChangeNumberList(mValue->AttrEnum(), *this);
|
||||
}
|
||||
|
||||
~AutoChangeNumberListNotifier() {
|
||||
mValue->Element()->DidChangeNumberList(mValue->AttrEnum(), mEmptyOrOldValue,
|
||||
*this);
|
||||
if (mValue->IsAnimating()) {
|
||||
mValue->Element()->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
T* const mValue;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* Class DOMSVGNumberList
|
||||
*
|
||||
|
@ -69,11 +40,8 @@ class MOZ_RAII AutoChangeNumberListNotifier : public mozAutoDocUpdate {
|
|||
* Our DOM items are created lazily on demand as and when script requests them.
|
||||
*/
|
||||
class DOMSVGNumberList final : public nsISupports, public nsWrapperCache {
|
||||
template <class T>
|
||||
friend class AutoChangeNumberListNotifier;
|
||||
friend class DOMSVGNumber;
|
||||
using AutoChangeNumberListNotifier =
|
||||
AutoChangeNumberListNotifier<DOMSVGNumberList>;
|
||||
|
||||
~DOMSVGNumberList() {
|
||||
// Our mAList's weak ref to us must be nulled out when we die. If GC has
|
||||
|
|
|
@ -44,6 +44,35 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMSVGPathSeg, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMSVGPathSeg, Release)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangePathSegNotifier
|
||||
// Stack-based helper class to pair calls to WillChangePathSegList
|
||||
// and DidChangePathSegList.
|
||||
class MOZ_RAII AutoChangePathSegNotifier : public mozAutoDocUpdate {
|
||||
public:
|
||||
explicit AutoChangePathSegNotifier(DOMSVGPathSeg* aPathSeg)
|
||||
: mozAutoDocUpdate(aPathSeg->Element()->GetComposedDoc(), true),
|
||||
mPathSeg(aPathSeg) {
|
||||
MOZ_ASSERT(mPathSeg, "Expecting non-null pathSeg");
|
||||
MOZ_ASSERT(mPathSeg->HasOwner(),
|
||||
"Expecting list to have an owner for notification");
|
||||
mEmptyOrOldValue = mPathSeg->Element()->WillChangePathSegList(*this);
|
||||
}
|
||||
|
||||
~AutoChangePathSegNotifier() {
|
||||
mPathSeg->Element()->DidChangePathSegList(mEmptyOrOldValue, *this);
|
||||
// Null check mPathSeg->mList, since DidChangePathSegList can run script,
|
||||
// potentially removing mPathSeg from its list.
|
||||
if (mPathSeg->mList && mPathSeg->mList->AttrIsAnimating()) {
|
||||
mPathSeg->Element()->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
DOMSVGPathSeg* const mPathSeg;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
};
|
||||
|
||||
DOMSVGPathSeg::DOMSVGPathSeg(DOMSVGPathSegList* aList, uint32_t aListIndex,
|
||||
bool aIsAnimValItem)
|
||||
: mList(aList), mListIndex(aListIndex), mIsAnimValItem(aIsAnimValItem) {
|
||||
|
@ -122,7 +151,7 @@ bool DOMSVGPathSeg::IndexIsValid() {
|
|||
if (InternalItem()[1 + index] == float(a##propName)) { \
|
||||
return; \
|
||||
} \
|
||||
AutoChangePathSegListNotifier notifier(this); \
|
||||
AutoChangePathSegNotifier notifier(this); \
|
||||
InternalItem()[1 + index] = float(a##propName); \
|
||||
} else { \
|
||||
mArgs[index] = float(a##propName); \
|
||||
|
|
|
@ -72,12 +72,7 @@ class SVGElement;
|
|||
* DOM wrapper for is a list of floats, not an instance of an internal class.
|
||||
*/
|
||||
class DOMSVGPathSeg : public nsWrapperCache {
|
||||
template <class T>
|
||||
friend class AutoChangePathSegListNotifier;
|
||||
|
||||
protected:
|
||||
using AutoChangePathSegListNotifier =
|
||||
AutoChangePathSegListNotifier<DOMSVGPathSeg>;
|
||||
friend class AutoChangePathSegNotifier;
|
||||
|
||||
public:
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMSVGPathSeg)
|
||||
|
@ -99,12 +94,6 @@ class DOMSVGPathSeg : public nsWrapperCache {
|
|||
|
||||
bool IsInList() const { return !!mList; }
|
||||
|
||||
/**
|
||||
* Returns true if our attribute is animating (in which case our animVal is
|
||||
* not simply a mirror of our baseVal).
|
||||
*/
|
||||
bool AttrIsAnimating() const { return mList && mList->AttrIsAnimating(); }
|
||||
|
||||
/**
|
||||
* In future, if this class is used for non-list segments, this will be
|
||||
* different to IsInList().
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "DOMSVGPathSegList.h"
|
||||
|
||||
#include "DOMSVGPathSeg.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsError.h"
|
||||
#include "SVGAnimatedPathSegList.h"
|
||||
#include "SVGAttrTearoffTable.h"
|
||||
|
@ -50,6 +51,31 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGPathSegList)
|
|||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangePathSegListNotifier
|
||||
// Stack-based helper class to pair calls to WillChangePathSegList and
|
||||
// DidChangePathSegList.
|
||||
class MOZ_RAII AutoChangePathSegListNotifier : public mozAutoDocUpdate {
|
||||
public:
|
||||
explicit AutoChangePathSegListNotifier(DOMSVGPathSegList* aPathSegList)
|
||||
: mozAutoDocUpdate(aPathSegList->Element()->GetComposedDoc(), true),
|
||||
mPathSegList(aPathSegList) {
|
||||
MOZ_ASSERT(mPathSegList, "Expecting non-null pathSegList");
|
||||
mEmptyOrOldValue = mPathSegList->Element()->WillChangePathSegList(*this);
|
||||
}
|
||||
|
||||
~AutoChangePathSegListNotifier() {
|
||||
mPathSegList->Element()->DidChangePathSegList(mEmptyOrOldValue, *this);
|
||||
if (mPathSegList->AttrIsAnimating()) {
|
||||
mPathSegList->Element()->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
DOMSVGPathSegList* const mPathSegList;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
};
|
||||
|
||||
/* static */
|
||||
already_AddRefed<DOMSVGPathSegList> DOMSVGPathSegList::GetDOMWrapper(
|
||||
void* aList, SVGElement* aElement, bool aIsAnimValList) {
|
||||
|
|
|
@ -7,15 +7,14 @@
|
|||
#ifndef DOM_SVG_DOMSVGPATHSEGLIST_H_
|
||||
#define DOM_SVG_DOMSVGPATHSEGLIST_H_
|
||||
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsDebug.h"
|
||||
#include "SVGElement.h"
|
||||
#include "nsTArray.h"
|
||||
#include "SVGPathData.h" // IWYU pragma: keep
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/dom/SVGElement.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -25,32 +24,6 @@ namespace dom {
|
|||
|
||||
class DOMSVGPathSeg;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangePathSegListNotifier
|
||||
// Stack-based helper class to pair calls to WillChangePathSegList and
|
||||
// DidChangePathSegList. Used by DOMSVGPathSeg and DOMSVGPathSegList.
|
||||
template <class T>
|
||||
class MOZ_RAII AutoChangePathSegListNotifier : public mozAutoDocUpdate {
|
||||
public:
|
||||
explicit AutoChangePathSegListNotifier(T* aValue)
|
||||
: mozAutoDocUpdate(aValue->Element()->GetComposedDoc(), true),
|
||||
mValue(aValue) {
|
||||
MOZ_ASSERT(mValue, "Expecting non-null value");
|
||||
mEmptyOrOldValue = mValue->Element()->WillChangePathSegList(*this);
|
||||
}
|
||||
|
||||
~AutoChangePathSegListNotifier() {
|
||||
mValue->Element()->DidChangePathSegList(mEmptyOrOldValue, *this);
|
||||
if (mValue->AttrIsAnimating()) {
|
||||
mValue->Element()->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
T* const mValue;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* Class DOMSVGPathSegList
|
||||
*
|
||||
|
@ -77,11 +50,8 @@ class MOZ_RAII AutoChangePathSegListNotifier : public mozAutoDocUpdate {
|
|||
* Our DOM items are created lazily on demand as and when script requests them.
|
||||
*/
|
||||
class DOMSVGPathSegList final : public nsISupports, public nsWrapperCache {
|
||||
template <class T>
|
||||
friend class AutoChangePathSegListNotifier;
|
||||
friend class DOMSVGPathSeg;
|
||||
using AutoChangePathSegListNotifier =
|
||||
AutoChangePathSegListNotifier<DOMSVGPathSegList>;
|
||||
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "DOMSVGPointList.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsError.h"
|
||||
#include "SVGPoint.h"
|
||||
|
@ -21,6 +22,35 @@ using namespace mozilla::gfx;
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangePointNotifier
|
||||
// Stack-based helper class to pair calls to WillChangePointList and
|
||||
// DidChangePointList.
|
||||
class MOZ_RAII AutoChangePointNotifier : public mozAutoDocUpdate {
|
||||
public:
|
||||
explicit AutoChangePointNotifier(DOMSVGPoint* aPoint)
|
||||
: mozAutoDocUpdate(aPoint->Element()->GetComposedDoc(), true),
|
||||
mPoint(aPoint) {
|
||||
MOZ_ASSERT(mPoint, "Expecting non-null point");
|
||||
MOZ_ASSERT(mPoint->HasOwner(),
|
||||
"Expecting list to have an owner for notification");
|
||||
mEmptyOrOldValue = mPoint->Element()->WillChangePointList(*this);
|
||||
}
|
||||
|
||||
~AutoChangePointNotifier() {
|
||||
mPoint->Element()->DidChangePointList(mEmptyOrOldValue, *this);
|
||||
// Null check mPoint->mList, since DidChangePointList can run script,
|
||||
// potentially removing mPoint from its list.
|
||||
if (mPoint->mList && mPoint->mList->AttrIsAnimating()) {
|
||||
mPoint->Element()->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
DOMSVGPoint* const mPoint;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
};
|
||||
|
||||
float DOMSVGPoint::X() {
|
||||
if (mIsAnimValItem && HasOwner()) {
|
||||
Element()->FlushAnimations(); // May make HasOwner() == false
|
||||
|
@ -38,7 +68,7 @@ void DOMSVGPoint::SetX(float aX, ErrorResult& rv) {
|
|||
if (InternalItem().mX == aX) {
|
||||
return;
|
||||
}
|
||||
AutoChangePointListNotifier notifier(this);
|
||||
AutoChangePointNotifier notifier(this);
|
||||
InternalItem().mX = aX;
|
||||
return;
|
||||
}
|
||||
|
@ -62,7 +92,7 @@ void DOMSVGPoint::SetY(float aY, ErrorResult& rv) {
|
|||
if (InternalItem().mY == aY) {
|
||||
return;
|
||||
}
|
||||
AutoChangePointListNotifier notifier(this);
|
||||
AutoChangePointNotifier notifier(this);
|
||||
InternalItem().mY = aY;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -36,10 +36,8 @@ class SVGElement;
|
|||
* of the important points regarding how this specific class works.
|
||||
*/
|
||||
class DOMSVGPoint final : public nsISVGPoint {
|
||||
template <class T>
|
||||
friend class AutoChangePointListNotifier;
|
||||
friend class AutoChangePointNotifier;
|
||||
|
||||
using AutoChangePointListNotifier = AutoChangePointListNotifier<DOMSVGPoint>;
|
||||
using Point = gfx::Point;
|
||||
|
||||
public:
|
||||
|
@ -80,12 +78,6 @@ class DOMSVGPoint final : public nsISVGPoint {
|
|||
const DOMMatrix2DInit& aMatrix, ErrorResult& aRv) override;
|
||||
nsISupports* GetParentObject() override { return mList; }
|
||||
|
||||
/**
|
||||
* Returns true if our attribute is animating (in which case our animVal is
|
||||
* not simply a mirror of our baseVal).
|
||||
*/
|
||||
bool AttrIsAnimating() const { return mList && mList->AttrIsAnimating(); }
|
||||
|
||||
virtual DOMSVGPoint* Copy() override { return new DOMSVGPoint(this); }
|
||||
|
||||
protected:
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "nsError.h"
|
||||
#include "SVGAnimatedPointList.h"
|
||||
#include "SVGAttrTearoffTable.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "mozilla/dom/SVGElement.h"
|
||||
#include "mozilla/dom/SVGPointListBinding.h"
|
||||
#include <algorithm>
|
||||
|
@ -67,6 +68,31 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGPointList)
|
|||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangePointListNotifier
|
||||
// Stack-based helper class to pair calls to WillChangePointList and
|
||||
// DidChangePointList.
|
||||
class MOZ_RAII AutoChangePointListNotifier : public mozAutoDocUpdate {
|
||||
public:
|
||||
explicit AutoChangePointListNotifier(DOMSVGPointList* aPointList)
|
||||
: mozAutoDocUpdate(aPointList->Element()->GetComposedDoc(), true),
|
||||
mPointList(aPointList) {
|
||||
MOZ_ASSERT(mPointList, "Expecting non-null pointList");
|
||||
mEmptyOrOldValue = mPointList->Element()->WillChangePointList(*this);
|
||||
}
|
||||
|
||||
~AutoChangePointListNotifier() {
|
||||
mPointList->Element()->DidChangePointList(mEmptyOrOldValue, *this);
|
||||
if (mPointList->AttrIsAnimating()) {
|
||||
mPointList->Element()->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
DOMSVGPointList* const mPointList;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
};
|
||||
|
||||
/* static */
|
||||
already_AddRefed<DOMSVGPointList> DOMSVGPointList::GetDOMWrapper(
|
||||
void* aList, SVGElement* aElement, bool aIsAnimValList) {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#ifndef DOM_SVG_DOMSVGPOINTLIST_H_
|
||||
#define DOM_SVG_DOMSVGPOINTLIST_H_
|
||||
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsDebug.h"
|
||||
#include "SVGElement.h"
|
||||
|
@ -26,32 +25,6 @@ namespace dom {
|
|||
class DOMSVGPoint;
|
||||
class nsISVGPoint;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangePointListNotifier
|
||||
// Stack-based helper class to pair calls to WillChangePointList and
|
||||
// DidChangePointList. Used by DOMSVGPoint and DOMSVGPointList.
|
||||
template <class T>
|
||||
class MOZ_RAII AutoChangePointListNotifier : public mozAutoDocUpdate {
|
||||
public:
|
||||
explicit AutoChangePointListNotifier(T* aValue)
|
||||
: mozAutoDocUpdate(aValue->Element()->GetComposedDoc(), true),
|
||||
mValue(aValue) {
|
||||
MOZ_ASSERT(mValue, "Expecting non-null value");
|
||||
mEmptyOrOldValue = mValue->Element()->WillChangePointList(*this);
|
||||
}
|
||||
|
||||
~AutoChangePointListNotifier() {
|
||||
mValue->Element()->DidChangePointList(mEmptyOrOldValue, *this);
|
||||
if (mValue->AttrIsAnimating()) {
|
||||
mValue->Element()->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
T* const mValue;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* Class DOMSVGPointList
|
||||
*
|
||||
|
@ -78,12 +51,9 @@ class MOZ_RAII AutoChangePointListNotifier : public mozAutoDocUpdate {
|
|||
* Our DOM items are created lazily on demand as and when script requests them.
|
||||
*/
|
||||
class DOMSVGPointList final : public nsISupports, public nsWrapperCache {
|
||||
template <class T>
|
||||
friend class AutoChangePointListNotifier;
|
||||
friend class nsISVGPoint;
|
||||
friend class DOMSVGPoint;
|
||||
using AutoChangePointListNotifier =
|
||||
AutoChangePointListNotifier<DOMSVGPointList>;
|
||||
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
|
|
|
@ -68,6 +68,40 @@ JSObject* DOMSVGTransform::WrapObject(JSContext* aCx,
|
|||
return SVGTransform_Binding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangeTransformNotifier
|
||||
// Stack-based helper class to pair calls to WillChangeTransformList
|
||||
// and DidChangeTransformList.
|
||||
class MOZ_RAII AutoChangeTransformNotifier {
|
||||
public:
|
||||
explicit AutoChangeTransformNotifier(DOMSVGTransform* aTransform)
|
||||
: mTransform(aTransform) {
|
||||
MOZ_ASSERT(mTransform, "Expecting non-null transform");
|
||||
if (mTransform->HasOwner()) {
|
||||
mUpdateBatch.emplace(mTransform->Element()->GetComposedDoc(), true);
|
||||
mEmptyOrOldValue =
|
||||
mTransform->Element()->WillChangeTransformList(mUpdateBatch.ref());
|
||||
}
|
||||
}
|
||||
|
||||
~AutoChangeTransformNotifier() {
|
||||
if (mTransform->HasOwner()) {
|
||||
mTransform->Element()->DidChangeTransformList(mEmptyOrOldValue,
|
||||
mUpdateBatch.ref());
|
||||
// Null check mTransform->mList, since DidChangeTransformList can run
|
||||
// script, potentially removing mTransform from its list.
|
||||
if (mTransform->mList && mTransform->mList->IsAnimating()) {
|
||||
mTransform->Element()->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Maybe<mozAutoDocUpdate> mUpdateBatch;
|
||||
DOMSVGTransform* const mTransform;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Ctors:
|
||||
|
||||
|
@ -170,7 +204,7 @@ void DOMSVGTransform::SetTranslate(float tx, float ty, ErrorResult& rv) {
|
|||
return;
|
||||
}
|
||||
|
||||
AutoChangeTransformListNotifier notifier(this);
|
||||
AutoChangeTransformNotifier notifier(this);
|
||||
Transform().SetTranslate(tx, ty);
|
||||
}
|
||||
|
||||
|
@ -184,7 +218,7 @@ void DOMSVGTransform::SetScale(float sx, float sy, ErrorResult& rv) {
|
|||
Matrixgfx()._22 == sy) {
|
||||
return;
|
||||
}
|
||||
AutoChangeTransformListNotifier notifier(this);
|
||||
AutoChangeTransformNotifier notifier(this);
|
||||
Transform().SetScale(sx, sy);
|
||||
}
|
||||
|
||||
|
@ -203,7 +237,7 @@ void DOMSVGTransform::SetRotate(float angle, float cx, float cy,
|
|||
}
|
||||
}
|
||||
|
||||
AutoChangeTransformListNotifier notifier(this);
|
||||
AutoChangeTransformNotifier notifier(this);
|
||||
Transform().SetRotate(angle, cx, cy);
|
||||
}
|
||||
|
||||
|
@ -223,7 +257,7 @@ void DOMSVGTransform::SetSkewX(float angle, ErrorResult& rv) {
|
|||
return;
|
||||
}
|
||||
|
||||
AutoChangeTransformListNotifier notifier(this);
|
||||
AutoChangeTransformNotifier notifier(this);
|
||||
DebugOnly<nsresult> result = Transform().SetSkewX(angle);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(result), "SetSkewX unexpectedly failed");
|
||||
}
|
||||
|
@ -244,7 +278,7 @@ void DOMSVGTransform::SetSkewY(float angle, ErrorResult& rv) {
|
|||
return;
|
||||
}
|
||||
|
||||
AutoChangeTransformListNotifier notifier(this);
|
||||
AutoChangeTransformNotifier notifier(this);
|
||||
DebugOnly<nsresult> result = Transform().SetSkewY(angle);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(result), "SetSkewY unexpectedly failed");
|
||||
}
|
||||
|
@ -303,7 +337,7 @@ void DOMSVGTransform::SetMatrix(const gfxMatrix& aMatrix) {
|
|||
return;
|
||||
}
|
||||
|
||||
AutoChangeTransformListNotifier notifier(this);
|
||||
AutoChangeTransformNotifier notifier(this);
|
||||
Transform().SetMatrix(aMatrix);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,10 +30,7 @@ class SVGMatrix;
|
|||
* DOM wrapper for an SVG transform. See DOMSVGLength.h.
|
||||
*/
|
||||
class DOMSVGTransform final : public nsWrapperCache {
|
||||
template <class T>
|
||||
friend class AutoChangeTransformListNotifier;
|
||||
using AutoChangeTransformListNotifier =
|
||||
AutoChangeTransformListNotifier<DOMSVGTransform>;
|
||||
friend class AutoChangeTransformNotifier;
|
||||
|
||||
public:
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMSVGTransform)
|
||||
|
@ -72,12 +69,6 @@ class DOMSVGTransform final : public nsWrapperCache {
|
|||
|
||||
bool IsInList() const { return !!mList; }
|
||||
|
||||
/**
|
||||
* Returns true if our attribute is animating (in which case our animVal is
|
||||
* not simply a mirror of our baseVal).
|
||||
*/
|
||||
bool IsAnimating() const { return mList && mList->IsAnimating(); }
|
||||
|
||||
/**
|
||||
* In future, if this class is used for non-list transforms, this will be
|
||||
* different to IsInList().
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "DOMSVGTransformList.h"
|
||||
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "mozilla/dom/SVGElement.h"
|
||||
#include "mozilla/dom/SVGMatrix.h"
|
||||
#include "mozilla/dom/SVGTransformListBinding.h"
|
||||
|
@ -74,6 +75,32 @@ JSObject* DOMSVGTransformList::WrapObject(JSContext* cx,
|
|||
return mozilla::dom::SVGTransformList_Binding::Wrap(cx, this, aGivenProto);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangeTransformListNotifier
|
||||
// Stack-based helper class to pair calls to WillChangeTransformList and
|
||||
// DidChangeTransformList.
|
||||
class MOZ_RAII AutoChangeTransformListNotifier : public mozAutoDocUpdate {
|
||||
public:
|
||||
explicit AutoChangeTransformListNotifier(DOMSVGTransformList* aTransformList)
|
||||
: mozAutoDocUpdate(aTransformList->Element()->GetComposedDoc(), true),
|
||||
mTransformList(aTransformList) {
|
||||
MOZ_ASSERT(mTransformList, "Expecting non-null transformList");
|
||||
mEmptyOrOldValue =
|
||||
mTransformList->Element()->WillChangeTransformList(*this);
|
||||
}
|
||||
|
||||
~AutoChangeTransformListNotifier() {
|
||||
mTransformList->Element()->DidChangeTransformList(mEmptyOrOldValue, *this);
|
||||
if (mTransformList->IsAnimating()) {
|
||||
mTransformList->Element()->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
DOMSVGTransformList* const mTransformList;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
};
|
||||
|
||||
void DOMSVGTransformList::InternalListLengthWillChange(uint32_t aNewLength) {
|
||||
uint32_t oldLength = mItems.Length();
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#define DOM_SVG_DOMSVGTRANSFORMLIST_H_
|
||||
|
||||
#include "DOMSVGAnimatedTransformList.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsDebug.h"
|
||||
#include "SVGTransformList.h"
|
||||
|
@ -24,39 +23,6 @@ class DOMSVGTransform;
|
|||
class SVGElement;
|
||||
class SVGMatrix;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangeTransformListNotifier
|
||||
// Stack-based helper class to pair calls to WillChangeTransformList and
|
||||
// DidChangeTransformList. Used by DOMSVGTransform and DOMSVGTransformList.
|
||||
template <class T>
|
||||
class MOZ_RAII AutoChangeTransformListNotifier {
|
||||
public:
|
||||
explicit AutoChangeTransformListNotifier(T* aValue) : mValue(aValue) {
|
||||
MOZ_ASSERT(mValue, "Expecting non-null value");
|
||||
// If we don't have an owner then changes don't affect anything else.
|
||||
if (mValue->HasOwner()) {
|
||||
mUpdateBatch.emplace(mValue->Element()->GetComposedDoc(), true);
|
||||
mEmptyOrOldValue =
|
||||
mValue->Element()->WillChangeTransformList(mUpdateBatch.ref());
|
||||
}
|
||||
}
|
||||
|
||||
~AutoChangeTransformListNotifier() {
|
||||
if (mValue->HasOwner()) {
|
||||
mValue->Element()->DidChangeTransformList(mEmptyOrOldValue,
|
||||
mUpdateBatch.ref());
|
||||
if (mValue->IsAnimating()) {
|
||||
mValue->Element()->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
T* const mValue;
|
||||
Maybe<mozAutoDocUpdate> mUpdateBatch;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* Class DOMSVGTransformList
|
||||
*
|
||||
|
@ -66,11 +32,8 @@ class MOZ_RAII AutoChangeTransformListNotifier {
|
|||
* See the architecture comment in DOMSVGAnimatedTransformList.h.
|
||||
*/
|
||||
class DOMSVGTransformList final : public nsISupports, public nsWrapperCache {
|
||||
template <class T>
|
||||
friend class AutoChangeTransformListNotifier;
|
||||
friend class dom::DOMSVGTransform;
|
||||
using AutoChangeTransformListNotifier =
|
||||
AutoChangeTransformListNotifier<DOMSVGTransformList>;
|
||||
|
||||
~DOMSVGTransformList() {
|
||||
// Our mAList's weak ref to us must be nulled out when we die. If GC has
|
||||
|
@ -114,12 +77,6 @@ class DOMSVGTransformList final : public nsISupports, public nsWrapperCache {
|
|||
/// Called to notify us to synchronize our length and detach excess items.
|
||||
void InternalListLengthWillChange(uint32_t aNewLength);
|
||||
|
||||
/*
|
||||
* List classes always have an owner. We need this so that templates that work
|
||||
* on lists and elements can check ownership where elements may be unowned.
|
||||
*/
|
||||
bool HasOwner() const { return true; }
|
||||
|
||||
/**
|
||||
* Returns true if our attribute is animating (in which case our animVal is
|
||||
* not simply a mirror of our baseVal).
|
||||
|
|
|
@ -18,33 +18,6 @@ namespace mozilla {
|
|||
|
||||
/* Implementation */
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangeBooleanNotifier
|
||||
// Stack-based helper class to ensure DidChangeBoolean is called.
|
||||
class MOZ_RAII AutoChangeBooleanNotifier {
|
||||
public:
|
||||
AutoChangeBooleanNotifier(SVGAnimatedBoolean* aBoolean,
|
||||
SVGElement* aSVGElement, bool aDoSetAttr = true)
|
||||
: mBoolean(aBoolean), mSVGElement(aSVGElement), mDoSetAttr(aDoSetAttr) {
|
||||
MOZ_ASSERT(mBoolean, "Expecting non-null boolean");
|
||||
MOZ_ASSERT(mSVGElement, "Expecting non-null element");
|
||||
}
|
||||
|
||||
~AutoChangeBooleanNotifier() {
|
||||
if (mDoSetAttr) {
|
||||
mSVGElement->DidChangeBoolean(mBoolean->mAttrEnum);
|
||||
}
|
||||
if (mBoolean->mIsAnimated) {
|
||||
mSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SVGAnimatedBoolean* const mBoolean;
|
||||
SVGElement* const mSVGElement;
|
||||
bool mDoSetAttr;
|
||||
};
|
||||
|
||||
static inline SVGAttrTearoffTable<SVGAnimatedBoolean, DOMSVGAnimatedBoolean>&
|
||||
SVGAnimatedBooleanTearoffTable() {
|
||||
static SVGAttrTearoffTable<SVGAnimatedBoolean, DOMSVGAnimatedBoolean>
|
||||
|
@ -85,16 +58,16 @@ nsresult SVGAnimatedBoolean::SetBaseValueAtom(const nsAtom* aValue,
|
|||
return rv;
|
||||
}
|
||||
|
||||
// We don't need to call DidChange* here - we're only called by
|
||||
// SVGElement::ParseAttribute under Element::SetAttr,
|
||||
// which takes care of notifying.
|
||||
AutoChangeBooleanNotifier notifier(this, aSVGElement, false);
|
||||
|
||||
mBaseVal = val;
|
||||
if (!mIsAnimated) {
|
||||
mAnimVal = mBaseVal;
|
||||
} else {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
|
||||
// We don't need to call DidChange* here - we're only called by
|
||||
// SVGElement::ParseAttribute under Element::SetAttr,
|
||||
// which takes care of notifying.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -107,12 +80,13 @@ void SVGAnimatedBoolean::SetBaseValue(bool aValue, SVGElement* aSVGElement) {
|
|||
return;
|
||||
}
|
||||
|
||||
AutoChangeBooleanNotifier notifier(this, aSVGElement);
|
||||
|
||||
mBaseVal = aValue;
|
||||
if (!mIsAnimated) {
|
||||
mAnimVal = mBaseVal;
|
||||
} else {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
aSVGElement->DidChangeBoolean(mAttrEnum);
|
||||
}
|
||||
|
||||
void SVGAnimatedBoolean::SetAnimValue(bool aValue, SVGElement* aSVGElement) {
|
||||
|
|
|
@ -27,7 +27,6 @@ class SVGElement;
|
|||
|
||||
class SVGAnimatedBoolean {
|
||||
public:
|
||||
friend class AutoChangeBooleanNotifier;
|
||||
using SVGElement = dom::SVGElement;
|
||||
|
||||
void Init(uint8_t aAttrEnum = 0xff, bool aValue = false) {
|
||||
|
|
|
@ -17,33 +17,6 @@ using namespace mozilla::dom;
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangeEnumNotifier
|
||||
// Stack-based helper class to ensure DidChangeEnum is called.
|
||||
class MOZ_RAII AutoChangeEnumNotifier {
|
||||
public:
|
||||
AutoChangeEnumNotifier(SVGAnimatedEnumeration* aEnum, SVGElement* aSVGElement,
|
||||
bool aDoSetAttr = true)
|
||||
: mEnum(aEnum), mSVGElement(aSVGElement), mDoSetAttr(aDoSetAttr) {
|
||||
MOZ_ASSERT(mEnum, "Expecting non-null enum");
|
||||
MOZ_ASSERT(mSVGElement, "Expecting non-null element");
|
||||
}
|
||||
|
||||
~AutoChangeEnumNotifier() {
|
||||
if (mDoSetAttr) {
|
||||
mSVGElement->DidChangeEnum(mEnum->mAttrEnum);
|
||||
}
|
||||
if (mEnum->mIsAnimated) {
|
||||
mSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SVGAnimatedEnumeration* const mEnum;
|
||||
SVGElement* const mSVGElement;
|
||||
bool mDoSetAttr;
|
||||
};
|
||||
|
||||
static SVGAttrTearoffTable<SVGAnimatedEnumeration,
|
||||
SVGAnimatedEnumeration::DOMAnimatedEnum>
|
||||
sSVGAnimatedEnumTearoffTable;
|
||||
|
@ -66,15 +39,15 @@ bool SVGAnimatedEnumeration::SetBaseValueAtom(const nsAtom* aValue,
|
|||
if (aValue == mapping->mKey) {
|
||||
mIsBaseSet = true;
|
||||
if (mBaseVal != mapping->mVal) {
|
||||
// We don't need to call DidChange* here - we're only called by
|
||||
// SVGElement::ParseAttribute under Element::SetAttr,
|
||||
// which takes care of notifying.
|
||||
AutoChangeEnumNotifier notifier(this, aSVGElement, false);
|
||||
|
||||
mBaseVal = mapping->mVal;
|
||||
if (!mIsAnimated) {
|
||||
mAnimVal = mBaseVal;
|
||||
} else {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
// We don't need to call DidChange* here - we're only called by
|
||||
// SVGElement::ParseAttribute under Element::SetAttr,
|
||||
// which takes care of notifying.
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -106,12 +79,13 @@ void SVGAnimatedEnumeration::SetBaseValue(uint16_t aValue,
|
|||
if (mapping->mVal == aValue) {
|
||||
mIsBaseSet = true;
|
||||
if (mBaseVal != uint8_t(aValue)) {
|
||||
AutoChangeEnumNotifier notifier(this, aSVGElement);
|
||||
|
||||
mBaseVal = uint8_t(aValue);
|
||||
if (!mIsAnimated) {
|
||||
mAnimVal = mBaseVal;
|
||||
} else {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
aSVGElement->DidChangeEnum(mAttrEnum);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ struct SVGEnumMapping {
|
|||
|
||||
class SVGAnimatedEnumeration {
|
||||
public:
|
||||
friend class AutoChangeEnumNotifier;
|
||||
using SVGElement = dom::SVGElement;
|
||||
|
||||
void Init(uint8_t aAttrEnum, uint16_t aValue) {
|
||||
|
|
|
@ -18,33 +18,6 @@ namespace mozilla {
|
|||
|
||||
/* Implementation */
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangeIntegerNotifier
|
||||
// Stack-based helper class ensure DidChangeInteger is called.
|
||||
class MOZ_RAII AutoChangeIntegerNotifier {
|
||||
public:
|
||||
AutoChangeIntegerNotifier(SVGAnimatedInteger* aInteger,
|
||||
SVGElement* aSVGElement, bool aDoSetAttr = true)
|
||||
: mInteger(aInteger), mSVGElement(aSVGElement), mDoSetAttr(aDoSetAttr) {
|
||||
MOZ_ASSERT(mInteger, "Expecting non-null integer");
|
||||
MOZ_ASSERT(mSVGElement, "Expecting non-null element");
|
||||
}
|
||||
|
||||
~AutoChangeIntegerNotifier() {
|
||||
if (mDoSetAttr) {
|
||||
mSVGElement->DidChangeInteger(mInteger->mAttrEnum);
|
||||
}
|
||||
if (mInteger->mIsAnimated) {
|
||||
mSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SVGAnimatedInteger* const mInteger;
|
||||
SVGElement* const mSVGElement;
|
||||
bool mDoSetAttr;
|
||||
};
|
||||
|
||||
static SVGAttrTearoffTable<SVGAnimatedInteger,
|
||||
SVGAnimatedInteger::DOMAnimatedInteger>
|
||||
sSVGAnimatedIntegerTearoffTable;
|
||||
|
@ -64,12 +37,12 @@ nsresult SVGAnimatedInteger::SetBaseValueString(const nsAString& aValueAsString,
|
|||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
}
|
||||
|
||||
AutoChangeIntegerNotifier notifier(this, aSVGElement, false);
|
||||
|
||||
mIsBaseSet = true;
|
||||
mBaseVal = value;
|
||||
if (!mIsAnimated) {
|
||||
mAnimVal = mBaseVal;
|
||||
} else {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -88,13 +61,14 @@ void SVGAnimatedInteger::SetBaseValue(int aValue, SVGElement* aSVGElement) {
|
|||
return;
|
||||
}
|
||||
|
||||
AutoChangeIntegerNotifier notifier(this, aSVGElement);
|
||||
|
||||
mBaseVal = aValue;
|
||||
mIsBaseSet = true;
|
||||
if (!mIsAnimated) {
|
||||
mAnimVal = mBaseVal;
|
||||
} else {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
aSVGElement->DidChangeInteger(mAttrEnum);
|
||||
}
|
||||
|
||||
void SVGAnimatedInteger::SetAnimValue(int aValue, SVGElement* aSVGElement) {
|
||||
|
|
|
@ -25,7 +25,6 @@ class SVGAnimationElement;
|
|||
|
||||
class SVGAnimatedInteger {
|
||||
public:
|
||||
friend class AutoChangeIntegerNotifier;
|
||||
using SVGElement = dom::SVGElement;
|
||||
|
||||
void Init(uint8_t aAttrEnum = 0xff, int32_t aValue = 0) {
|
||||
|
|
|
@ -18,45 +18,6 @@ using namespace mozilla::dom;
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangeIntegerPairNotifier
|
||||
// Stack-based helper class to pair calls to WillChangeIntegerPair and
|
||||
// DidChangeIntegerPair.
|
||||
class MOZ_RAII AutoChangeIntegerPairNotifier {
|
||||
public:
|
||||
AutoChangeIntegerPairNotifier(SVGAnimatedIntegerPair* aIntegerPair,
|
||||
SVGElement* aSVGElement, bool aDoSetAttr = true)
|
||||
: mIntegerPair(aIntegerPair),
|
||||
mSVGElement(aSVGElement),
|
||||
mDoSetAttr(aDoSetAttr) {
|
||||
MOZ_ASSERT(mIntegerPair, "Expecting non-null integerPair");
|
||||
MOZ_ASSERT(mSVGElement, "Expecting non-null element");
|
||||
|
||||
if (mDoSetAttr) {
|
||||
mUpdateBatch.emplace(aSVGElement->GetComposedDoc(), true);
|
||||
mEmptyOrOldValue = mSVGElement->WillChangeIntegerPair(
|
||||
mIntegerPair->mAttrEnum, mUpdateBatch.ref());
|
||||
}
|
||||
}
|
||||
|
||||
~AutoChangeIntegerPairNotifier() {
|
||||
if (mDoSetAttr) {
|
||||
mSVGElement->DidChangeIntegerPair(mIntegerPair->mAttrEnum,
|
||||
mEmptyOrOldValue, mUpdateBatch.ref());
|
||||
}
|
||||
if (mIntegerPair->mIsAnimated) {
|
||||
mSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SVGAnimatedIntegerPair* const mIntegerPair;
|
||||
SVGElement* const mSVGElement;
|
||||
Maybe<mozAutoDocUpdate> mUpdateBatch;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
bool mDoSetAttr;
|
||||
};
|
||||
|
||||
static SVGAttrTearoffTable<SVGAnimatedIntegerPair,
|
||||
SVGAnimatedIntegerPair::DOMAnimatedInteger>
|
||||
sSVGFirstAnimatedIntegerTearoffTable;
|
||||
|
@ -99,18 +60,19 @@ nsresult SVGAnimatedIntegerPair::SetBaseValueString(
|
|||
return rv;
|
||||
}
|
||||
|
||||
// We don't need to call DidChange* here - we're only called by
|
||||
// SVGElement::ParseAttribute under Element::SetAttr,
|
||||
// which takes care of notifying.
|
||||
AutoChangeIntegerPairNotifier notifier(this, aSVGElement, false);
|
||||
|
||||
mBaseVal[0] = val[0];
|
||||
mBaseVal[1] = val[1];
|
||||
mIsBaseSet = true;
|
||||
if (!mIsAnimated) {
|
||||
mAnimVal[0] = mBaseVal[0];
|
||||
mAnimVal[1] = mBaseVal[1];
|
||||
} else {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
|
||||
// We don't need to call DidChange* here - we're only called by
|
||||
// SVGElement::ParseAttribute under Element::SetAttr,
|
||||
// which takes care of notifying.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -131,13 +93,17 @@ void SVGAnimatedIntegerPair::SetBaseValue(int32_t aValue, PairIndex aPairIndex,
|
|||
return;
|
||||
}
|
||||
|
||||
AutoChangeIntegerPairNotifier notifier(this, aSVGElement);
|
||||
|
||||
mozAutoDocUpdate updateBatch(aSVGElement->GetComposedDoc(), true);
|
||||
nsAttrValue emptyOrOldValue =
|
||||
aSVGElement->WillChangeIntegerPair(mAttrEnum, updateBatch);
|
||||
mBaseVal[index] = aValue;
|
||||
mIsBaseSet = true;
|
||||
if (!mIsAnimated) {
|
||||
mAnimVal[index] = aValue;
|
||||
} else {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
aSVGElement->DidChangeIntegerPair(mAttrEnum, emptyOrOldValue, updateBatch);
|
||||
}
|
||||
|
||||
void SVGAnimatedIntegerPair::SetBaseValues(int32_t aValue1, int32_t aValue2,
|
||||
|
@ -146,15 +112,19 @@ void SVGAnimatedIntegerPair::SetBaseValues(int32_t aValue1, int32_t aValue2,
|
|||
return;
|
||||
}
|
||||
|
||||
AutoChangeIntegerPairNotifier notifier(this, aSVGElement);
|
||||
|
||||
mozAutoDocUpdate updateBatch(aSVGElement->GetComposedDoc(), true);
|
||||
nsAttrValue emptyOrOldValue =
|
||||
aSVGElement->WillChangeIntegerPair(mAttrEnum, updateBatch);
|
||||
mBaseVal[0] = aValue1;
|
||||
mBaseVal[1] = aValue2;
|
||||
mIsBaseSet = true;
|
||||
if (!mIsAnimated) {
|
||||
mAnimVal[0] = aValue1;
|
||||
mAnimVal[1] = aValue2;
|
||||
} else {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
aSVGElement->DidChangeIntegerPair(mAttrEnum, emptyOrOldValue, updateBatch);
|
||||
}
|
||||
|
||||
void SVGAnimatedIntegerPair::SetAnimValue(const int32_t aValue[2],
|
||||
|
|
|
@ -25,7 +25,6 @@ class SVGElement;
|
|||
|
||||
class SVGAnimatedIntegerPair {
|
||||
public:
|
||||
friend class AutoChangeIntegerPairNotifier;
|
||||
using SVGElement = dom::SVGElement;
|
||||
|
||||
enum PairIndex { eFirst, eSecond };
|
||||
|
|
|
@ -25,43 +25,6 @@ using namespace mozilla::dom;
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangeLengthNotifier
|
||||
// Stack-based helper class to pair calls to WillChangeLength and
|
||||
// DidChangeLength.
|
||||
class MOZ_RAII AutoChangeLengthNotifier {
|
||||
public:
|
||||
AutoChangeLengthNotifier(SVGAnimatedLength* aLength, SVGElement* aSVGElement,
|
||||
bool aDoSetAttr = true)
|
||||
: mLength(aLength), mSVGElement(aSVGElement), mDoSetAttr(aDoSetAttr) {
|
||||
MOZ_ASSERT(mLength, "Expecting non-null length");
|
||||
MOZ_ASSERT(mSVGElement, "Expecting non-null element");
|
||||
|
||||
if (mDoSetAttr) {
|
||||
mUpdateBatch.emplace(aSVGElement->GetComposedDoc(), true);
|
||||
mEmptyOrOldValue =
|
||||
mSVGElement->WillChangeLength(mLength->mAttrEnum, mUpdateBatch.ref());
|
||||
}
|
||||
}
|
||||
|
||||
~AutoChangeLengthNotifier() {
|
||||
if (mDoSetAttr) {
|
||||
mSVGElement->DidChangeLength(mLength->mAttrEnum, mEmptyOrOldValue,
|
||||
mUpdateBatch.ref());
|
||||
}
|
||||
if (mLength->mIsAnimated) {
|
||||
mSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SVGAnimatedLength* const mLength;
|
||||
SVGElement* const mSVGElement;
|
||||
Maybe<mozAutoDocUpdate> mUpdateBatch;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
bool mDoSetAttr;
|
||||
};
|
||||
|
||||
static const nsStaticAtom* const unitMap[] = {
|
||||
nullptr, /* SVG_LENGTHTYPE_UNKNOWN */
|
||||
nullptr, /* SVG_LENGTHTYPE_NUMBER */
|
||||
|
@ -289,19 +252,26 @@ float SVGAnimatedLength::GetPixelsPerUnit(const UserSpaceMetrics& aMetrics,
|
|||
}
|
||||
}
|
||||
|
||||
void SVGAnimatedLength::SetBaseValueInSpecifiedUnits(float aValue,
|
||||
SVGElement* aSVGElement,
|
||||
bool aDoSetAttr) {
|
||||
void SVGAnimatedLength::SetBaseValueInSpecifiedUnits(
|
||||
float aValue, SVGElement* aSVGElement, bool aDoSetAttr,
|
||||
const mozAutoDocUpdate& aProofOfUpdate) {
|
||||
if (mIsBaseSet && mBaseVal == aValue) {
|
||||
return;
|
||||
}
|
||||
|
||||
AutoChangeLengthNotifier notifier(this, aSVGElement, aDoSetAttr);
|
||||
|
||||
nsAttrValue emptyOrOldValue;
|
||||
if (aDoSetAttr) {
|
||||
emptyOrOldValue = aSVGElement->WillChangeLength(mAttrEnum, aProofOfUpdate);
|
||||
}
|
||||
mBaseVal = aValue;
|
||||
mIsBaseSet = true;
|
||||
if (!mIsAnimated) {
|
||||
mAnimVal = mBaseVal;
|
||||
} else {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
if (aDoSetAttr) {
|
||||
aSVGElement->DidChangeLength(mAttrEnum, emptyOrOldValue, aProofOfUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -328,12 +298,17 @@ nsresult SVGAnimatedLength::ConvertToSpecifiedUnits(uint16_t unitType,
|
|||
// on the document, we still need to send out notifications in case we have
|
||||
// mutation listeners, since the actual string value of the attribute will
|
||||
// change.
|
||||
AutoChangeLengthNotifier notifier(this, aSVGElement);
|
||||
mozAutoDocUpdate updateBatch(aSVGElement->GetComposedDoc(), true);
|
||||
nsAttrValue emptyOrOldValue =
|
||||
aSVGElement->WillChangeLength(mAttrEnum, updateBatch);
|
||||
|
||||
mSpecifiedUnitType = uint8_t(unitType);
|
||||
// Setting aDoSetAttr to false here will ensure we don't call
|
||||
// Will/DidChangeAngle a second time (and dispatch duplicate notifications).
|
||||
SetBaseValueInSpecifiedUnits(valueInSpecifiedUnits, aSVGElement, false);
|
||||
SetBaseValueInSpecifiedUnits(valueInSpecifiedUnits, aSVGElement, false,
|
||||
updateBatch);
|
||||
|
||||
aSVGElement->DidChangeLength(mAttrEnum, emptyOrOldValue, updateBatch);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -350,14 +325,18 @@ nsresult SVGAnimatedLength::NewValueSpecifiedUnits(uint16_t aUnitType,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
AutoChangeLengthNotifier notifier(this, aSVGElement);
|
||||
|
||||
mozAutoDocUpdate updateBatch(aSVGElement->GetComposedDoc(), true);
|
||||
nsAttrValue emptyOrOldValue =
|
||||
aSVGElement->WillChangeLength(mAttrEnum, updateBatch);
|
||||
mBaseVal = aValueInSpecifiedUnits;
|
||||
mIsBaseSet = true;
|
||||
mSpecifiedUnitType = uint8_t(aUnitType);
|
||||
if (!mIsAnimated) {
|
||||
mAnimVal = mBaseVal;
|
||||
} else {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
aSVGElement->DidChangeLength(mAttrEnum, emptyOrOldValue, updateBatch);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -388,15 +367,25 @@ nsresult SVGAnimatedLength::SetBaseValueString(const nsAString& aValueAsString,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
AutoChangeLengthNotifier notifier(this, aSVGElement, aDoSetAttr);
|
||||
|
||||
Maybe<mozAutoDocUpdate> updateBatch;
|
||||
nsAttrValue emptyOrOldValue;
|
||||
if (aDoSetAttr) {
|
||||
updateBatch.emplace(aSVGElement->GetComposedDoc(), true);
|
||||
emptyOrOldValue =
|
||||
aSVGElement->WillChangeLength(mAttrEnum, updateBatch.ref());
|
||||
}
|
||||
mBaseVal = value;
|
||||
mIsBaseSet = true;
|
||||
mSpecifiedUnitType = uint8_t(unitType);
|
||||
if (!mIsAnimated) {
|
||||
mAnimVal = mBaseVal;
|
||||
} else {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
|
||||
if (aDoSetAttr) {
|
||||
aSVGElement->DidChangeLength(mAttrEnum, emptyOrOldValue, updateBatch.ref());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -420,7 +409,9 @@ nsresult SVGAnimatedLength::SetBaseValue(float aValue, SVGElement* aSVGElement,
|
|||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
SetBaseValueInSpecifiedUnits(valueInSpecifiedUnits, aSVGElement, aDoSetAttr);
|
||||
mozAutoDocUpdate updateBatch(aSVGElement->GetComposedDoc(), true);
|
||||
SetBaseValueInSpecifiedUnits(valueInSpecifiedUnits, aSVGElement, aDoSetAttr,
|
||||
updateBatch);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ class nsIFrame;
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
class AutoChangeLengthNotifier;
|
||||
class SMILValue;
|
||||
|
||||
namespace dom {
|
||||
|
@ -80,7 +79,6 @@ class NonSVGFrameUserSpaceMetrics : public UserSpaceMetricsWithSize {
|
|||
} // namespace dom
|
||||
|
||||
class SVGAnimatedLength {
|
||||
friend class AutoChangeLengthNotifier;
|
||||
friend class dom::DOMSVGAnimatedLength;
|
||||
friend class dom::DOMSVGLength;
|
||||
using DOMSVGLength = dom::DOMSVGLength;
|
||||
|
@ -181,7 +179,8 @@ class SVGAnimatedLength {
|
|||
// perform unit conversion and are therefore infallible.
|
||||
nsresult SetBaseValue(float aValue, SVGElement* aSVGElement, bool aDoSetAttr);
|
||||
void SetBaseValueInSpecifiedUnits(float aValue, SVGElement* aSVGElement,
|
||||
bool aDoSetAttr);
|
||||
bool aDoSetAttr,
|
||||
const mozAutoDocUpdate& aProofOfUpdate);
|
||||
nsresult SetAnimValue(float aValue, SVGElement* aSVGElement);
|
||||
void SetAnimValueInSpecifiedUnits(float aValue, SVGElement* aSVGElement);
|
||||
nsresult NewValueSpecifiedUnits(uint16_t aUnitType,
|
||||
|
|
|
@ -19,29 +19,6 @@ namespace mozilla {
|
|||
|
||||
/* Implementation */
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangeNumberNotifier
|
||||
// Stack-based helper class to ensure DidChangeNumber is called.
|
||||
class MOZ_RAII AutoChangeNumberNotifier {
|
||||
public:
|
||||
AutoChangeNumberNotifier(SVGAnimatedNumber* aNumber, SVGElement* aSVGElement)
|
||||
: mNumber(aNumber), mSVGElement(aSVGElement) {
|
||||
MOZ_ASSERT(mNumber, "Expecting non-null number");
|
||||
MOZ_ASSERT(mSVGElement, "Expecting non-null element");
|
||||
}
|
||||
|
||||
~AutoChangeNumberNotifier() {
|
||||
mSVGElement->DidChangeNumber(mNumber->mAttrEnum);
|
||||
if (mNumber->mIsAnimated) {
|
||||
mSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SVGAnimatedNumber* const mNumber;
|
||||
SVGElement* const mSVGElement;
|
||||
};
|
||||
|
||||
static SVGAttrTearoffTable<SVGAnimatedNumber,
|
||||
SVGAnimatedNumber::DOMAnimatedNumber>
|
||||
sSVGAnimatedNumberTearoffTable;
|
||||
|
@ -107,13 +84,14 @@ void SVGAnimatedNumber::SetBaseValue(float aValue, SVGElement* aSVGElement) {
|
|||
return;
|
||||
}
|
||||
|
||||
AutoChangeNumberNotifier notifier(this, aSVGElement);
|
||||
|
||||
mBaseVal = aValue;
|
||||
mIsBaseSet = true;
|
||||
if (!mIsAnimated) {
|
||||
mAnimVal = mBaseVal;
|
||||
} else {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
aSVGElement->DidChangeNumber(mAttrEnum);
|
||||
}
|
||||
|
||||
void SVGAnimatedNumber::SetAnimValue(float aValue, SVGElement* aSVGElement) {
|
||||
|
|
|
@ -27,7 +27,6 @@ class SVGAnimationElement;
|
|||
|
||||
class SVGAnimatedNumber {
|
||||
public:
|
||||
friend class AutoChangeNumberNotifier;
|
||||
using SVGElement = dom::SVGElement;
|
||||
|
||||
void Init(uint8_t aAttrEnum = 0xff, float aValue = 0) {
|
||||
|
|
|
@ -16,43 +16,6 @@ using namespace mozilla::dom;
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangeNumberPairNotifier
|
||||
// Stack-based helper class to pair calls to WillChangeNumberPair and
|
||||
// DidChangeNumberPair.
|
||||
class MOZ_RAII AutoChangeNumberPairNotifier {
|
||||
public:
|
||||
AutoChangeNumberPairNotifier(SVGAnimatedNumberPair* aNumberPair,
|
||||
SVGElement* aSVGElement, bool aDoSetAttr = true)
|
||||
: mNumberPair(aNumberPair),
|
||||
mSVGElement(aSVGElement),
|
||||
mDoSetAttr(aDoSetAttr) {
|
||||
MOZ_ASSERT(mNumberPair, "Expecting non-null numberPair");
|
||||
MOZ_ASSERT(mSVGElement, "Expecting non-null element");
|
||||
|
||||
if (mDoSetAttr) {
|
||||
mEmptyOrOldValue =
|
||||
mSVGElement->WillChangeNumberPair(mNumberPair->mAttrEnum);
|
||||
}
|
||||
}
|
||||
|
||||
~AutoChangeNumberPairNotifier() {
|
||||
if (mDoSetAttr) {
|
||||
mSVGElement->DidChangeNumberPair(mNumberPair->mAttrEnum,
|
||||
mEmptyOrOldValue);
|
||||
}
|
||||
if (mNumberPair->mIsAnimated) {
|
||||
mSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SVGAnimatedNumberPair* const mNumberPair;
|
||||
SVGElement* const mSVGElement;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
bool mDoSetAttr;
|
||||
};
|
||||
|
||||
static SVGAttrTearoffTable<SVGAnimatedNumberPair,
|
||||
SVGAnimatedNumberPair::DOMAnimatedNumber>
|
||||
sSVGFirstAnimatedNumberTearoffTable;
|
||||
|
@ -92,19 +55,19 @@ nsresult SVGAnimatedNumberPair::SetBaseValueString(
|
|||
return rv;
|
||||
}
|
||||
|
||||
// We don't need to call Will/DidChange* here - we're only called by
|
||||
// SVGElement::ParseAttribute under Element::SetAttr,
|
||||
// which takes care of notifying.
|
||||
AutoChangeNumberPairNotifier notifier(this, aSVGElement, false);
|
||||
|
||||
mBaseVal[0] = val[0];
|
||||
mBaseVal[1] = val[1];
|
||||
mIsBaseSet = true;
|
||||
if (!mIsAnimated) {
|
||||
mAnimVal[0] = mBaseVal[0];
|
||||
mAnimVal[1] = mBaseVal[1];
|
||||
} else {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
|
||||
// We don't need to call Will/DidChange* here - we're only called by
|
||||
// SVGElement::ParseAttribute under Element::SetAttr,
|
||||
// which takes care of notifying.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -124,14 +87,15 @@ void SVGAnimatedNumberPair::SetBaseValue(float aValue, PairIndex aPairIndex,
|
|||
if (mIsBaseSet && mBaseVal[index] == aValue) {
|
||||
return;
|
||||
}
|
||||
|
||||
AutoChangeNumberPairNotifier notifier(this, aSVGElement);
|
||||
|
||||
nsAttrValue emptyOrOldValue = aSVGElement->WillChangeNumberPair(mAttrEnum);
|
||||
mBaseVal[index] = aValue;
|
||||
mIsBaseSet = true;
|
||||
if (!mIsAnimated) {
|
||||
mAnimVal[index] = aValue;
|
||||
} else {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
aSVGElement->DidChangeNumberPair(mAttrEnum, emptyOrOldValue);
|
||||
}
|
||||
|
||||
void SVGAnimatedNumberPair::SetBaseValues(float aValue1, float aValue2,
|
||||
|
@ -139,16 +103,17 @@ void SVGAnimatedNumberPair::SetBaseValues(float aValue1, float aValue2,
|
|||
if (mIsBaseSet && mBaseVal[0] == aValue1 && mBaseVal[1] == aValue2) {
|
||||
return;
|
||||
}
|
||||
|
||||
AutoChangeNumberPairNotifier notifier(this, aSVGElement);
|
||||
|
||||
nsAttrValue emptyOrOldValue = aSVGElement->WillChangeNumberPair(mAttrEnum);
|
||||
mBaseVal[0] = aValue1;
|
||||
mBaseVal[1] = aValue2;
|
||||
mIsBaseSet = true;
|
||||
if (!mIsAnimated) {
|
||||
mAnimVal[0] = aValue1;
|
||||
mAnimVal[1] = aValue2;
|
||||
} else {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
aSVGElement->DidChangeNumberPair(mAttrEnum, emptyOrOldValue);
|
||||
}
|
||||
|
||||
void SVGAnimatedNumberPair::SetAnimValue(const float aValue[2],
|
||||
|
|
|
@ -27,7 +27,6 @@ class SVGElement;
|
|||
|
||||
class SVGAnimatedNumberPair {
|
||||
public:
|
||||
friend class AutoChangeNumberPairNotifier;
|
||||
using SVGElement = dom::SVGElement;
|
||||
|
||||
enum PairIndex { eFirst, eSecond };
|
||||
|
|
|
@ -49,9 +49,9 @@ static SVGAttrTearoffTable<SVGAnimatedOrient, DOMSVGAngle>
|
|||
// DidChangeOrient with mozAutoDocUpdate.
|
||||
class MOZ_RAII AutoChangeOrientNotifier {
|
||||
public:
|
||||
AutoChangeOrientNotifier(
|
||||
SVGAnimatedOrient* aOrient, SVGElement* aSVGElement,
|
||||
bool aDoSetAttr = true)
|
||||
explicit AutoChangeOrientNotifier(SVGAnimatedOrient* aOrient,
|
||||
SVGElement* aSVGElement,
|
||||
bool aDoSetAttr = true)
|
||||
: mOrient(aOrient), mSVGElement(aSVGElement), mDoSetAttr(aDoSetAttr) {
|
||||
MOZ_ASSERT(mOrient, "Expecting non-null orient");
|
||||
if (mSVGElement && mDoSetAttr) {
|
||||
|
|
|
@ -39,45 +39,6 @@ JSObject* DOMSVGAnimatedPreserveAspectRatio::WrapObject(
|
|||
|
||||
/* Implementation */
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangePreserveAspectRatioNotifier
|
||||
// Stack-based helper class to pair calls to WillChangePreserveAspectRatio and
|
||||
// DidChangePreserveAspectRatio.
|
||||
class MOZ_RAII AutoChangePreserveAspectRatioNotifier {
|
||||
public:
|
||||
AutoChangePreserveAspectRatioNotifier(
|
||||
SVGAnimatedPreserveAspectRatio* aPreserveAspectRatio,
|
||||
SVGElement* aSVGElement, bool aDoSetAttr = true)
|
||||
: mPreserveAspectRatio(aPreserveAspectRatio),
|
||||
mSVGElement(aSVGElement),
|
||||
mDoSetAttr(aDoSetAttr) {
|
||||
MOZ_ASSERT(mPreserveAspectRatio, "Expecting non-null preserveAspectRatio");
|
||||
MOZ_ASSERT(mSVGElement, "Expecting non-null element");
|
||||
if (mDoSetAttr) {
|
||||
mUpdateBatch.emplace(aSVGElement->GetComposedDoc(), true);
|
||||
mEmptyOrOldValue =
|
||||
mSVGElement->WillChangePreserveAspectRatio(mUpdateBatch.ref());
|
||||
}
|
||||
}
|
||||
|
||||
~AutoChangePreserveAspectRatioNotifier() {
|
||||
if (mDoSetAttr) {
|
||||
mSVGElement->DidChangePreserveAspectRatio(mEmptyOrOldValue,
|
||||
mUpdateBatch.ref());
|
||||
}
|
||||
if (mPreserveAspectRatio->mIsAnimated) {
|
||||
mSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SVGAnimatedPreserveAspectRatio* const mPreserveAspectRatio;
|
||||
SVGElement* const mSVGElement;
|
||||
Maybe<mozAutoDocUpdate> mUpdateBatch;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
bool mDoSetAttr;
|
||||
};
|
||||
|
||||
static SVGAttrTearoffTable<SVGAnimatedPreserveAspectRatio,
|
||||
DOMSVGAnimatedPreserveAspectRatio>
|
||||
sSVGAnimatedPAspectRatioTearoffTable;
|
||||
|
@ -128,14 +89,27 @@ nsresult SVGAnimatedPreserveAspectRatio::SetBaseValueString(
|
|||
return res;
|
||||
}
|
||||
|
||||
AutoChangePreserveAspectRatioNotifier notifier(this, aSVGElement, aDoSetAttr);
|
||||
Maybe<mozAutoDocUpdate> updateBatch;
|
||||
nsAttrValue emptyOrOldValue;
|
||||
if (aDoSetAttr) {
|
||||
updateBatch.emplace(aSVGElement->GetComposedDoc(), true);
|
||||
emptyOrOldValue =
|
||||
aSVGElement->WillChangePreserveAspectRatio(updateBatch.ref());
|
||||
}
|
||||
|
||||
mBaseVal = val;
|
||||
mIsBaseSet = true;
|
||||
|
||||
if (!mIsAnimated) {
|
||||
mAnimVal = mBaseVal;
|
||||
}
|
||||
|
||||
if (aDoSetAttr) {
|
||||
aSVGElement->DidChangePreserveAspectRatio(emptyOrOldValue,
|
||||
updateBatch.ref());
|
||||
}
|
||||
if (mIsAnimated) {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -150,13 +124,19 @@ void SVGAnimatedPreserveAspectRatio::SetBaseValue(
|
|||
return;
|
||||
}
|
||||
|
||||
AutoChangePreserveAspectRatioNotifier notifier(this, aSVGElement);
|
||||
|
||||
mozAutoDocUpdate updateBatch(aSVGElement->GetComposedDoc(), true);
|
||||
nsAttrValue emptyOrOldValue =
|
||||
aSVGElement->WillChangePreserveAspectRatio(updateBatch);
|
||||
mBaseVal = aValue;
|
||||
mIsBaseSet = true;
|
||||
|
||||
if (!mIsAnimated) {
|
||||
mAnimVal = mBaseVal;
|
||||
}
|
||||
aSVGElement->DidChangePreserveAspectRatio(emptyOrOldValue, updateBatch);
|
||||
if (mIsAnimated) {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t PackPreserveAspectRatio(const SVGPreserveAspectRatio& par) {
|
||||
|
|
|
@ -25,8 +25,6 @@ class SVGAnimationElement;
|
|||
} // namespace dom
|
||||
|
||||
class SVGAnimatedPreserveAspectRatio final {
|
||||
friend class AutoChangePreserveAspectRatioNotifier;
|
||||
|
||||
public:
|
||||
void Init() {
|
||||
mBaseVal.mAlign =
|
||||
|
|
|
@ -72,41 +72,6 @@ static SVGAttrTearoffTable<SVGAnimatedViewBox, SVGRect>
|
|||
SVGAttrTearoffTable<SVGAnimatedViewBox, SVGAnimatedRect>
|
||||
SVGAnimatedViewBox::sSVGAnimatedRectTearoffTable;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper class: AutoChangeViewBoxNotifier
|
||||
// Stack-based helper class to pair calls to WillChangeViewBox and
|
||||
// DidChangeViewBox.
|
||||
class MOZ_RAII AutoChangeViewBoxNotifier {
|
||||
public:
|
||||
AutoChangeViewBoxNotifier(SVGAnimatedViewBox* aViewBox,
|
||||
SVGElement* aSVGElement, bool aDoSetAttr = true)
|
||||
: mViewBox(aViewBox), mSVGElement(aSVGElement), mDoSetAttr(aDoSetAttr) {
|
||||
MOZ_ASSERT(mViewBox, "Expecting non-null viewBox");
|
||||
MOZ_ASSERT(mSVGElement, "Expecting non-null element");
|
||||
|
||||
if (mDoSetAttr) {
|
||||
mUpdateBatch.emplace(aSVGElement->GetComposedDoc(), true);
|
||||
mEmptyOrOldValue = mSVGElement->WillChangeViewBox(mUpdateBatch.ref());
|
||||
}
|
||||
}
|
||||
|
||||
~AutoChangeViewBoxNotifier() {
|
||||
if (mDoSetAttr) {
|
||||
mSVGElement->DidChangeViewBox(mEmptyOrOldValue, mUpdateBatch.ref());
|
||||
}
|
||||
if (mViewBox->mAnimVal) {
|
||||
mSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SVGAnimatedViewBox* const mViewBox;
|
||||
SVGElement* const mSVGElement;
|
||||
Maybe<mozAutoDocUpdate> mUpdateBatch;
|
||||
nsAttrValue mEmptyOrOldValue;
|
||||
bool mDoSetAttr;
|
||||
};
|
||||
|
||||
/* Implementation of SVGAnimatedViewBox methods */
|
||||
|
||||
void SVGAnimatedViewBox::Init() {
|
||||
|
@ -159,10 +124,16 @@ void SVGAnimatedViewBox::SetBaseValue(const SVGViewBox& aRect,
|
|||
return;
|
||||
}
|
||||
|
||||
AutoChangeViewBoxNotifier notifier(this, aSVGElement);
|
||||
mozAutoDocUpdate updateBatch(aSVGElement->GetComposedDoc(), true);
|
||||
nsAttrValue emptyOrOldValue = aSVGElement->WillChangeViewBox(updateBatch);
|
||||
|
||||
mBaseVal = aRect;
|
||||
mHasBaseVal = true;
|
||||
|
||||
aSVGElement->DidChangeViewBox(emptyOrOldValue, updateBatch);
|
||||
if (mAnimVal) {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
}
|
||||
|
||||
nsresult SVGAnimatedViewBox::SetBaseValueString(const nsAString& aValue,
|
||||
|
@ -179,10 +150,21 @@ nsresult SVGAnimatedViewBox::SetBaseValueString(const nsAString& aValue,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
AutoChangeViewBoxNotifier notifier(this, aSVGElement, aDoSetAttr);
|
||||
Maybe<mozAutoDocUpdate> updateBatch;
|
||||
nsAttrValue emptyOrOldValue;
|
||||
if (aDoSetAttr) {
|
||||
updateBatch.emplace(aSVGElement->GetComposedDoc(), true);
|
||||
emptyOrOldValue = aSVGElement->WillChangeViewBox(updateBatch.ref());
|
||||
}
|
||||
mHasBaseVal = true;
|
||||
mBaseVal = viewBox;
|
||||
|
||||
if (aDoSetAttr) {
|
||||
aSVGElement->DidChangeViewBox(emptyOrOldValue, updateBatch.ref());
|
||||
}
|
||||
if (mAnimVal) {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ struct SVGViewBox {
|
|||
|
||||
class SVGAnimatedViewBox {
|
||||
public:
|
||||
friend class AutoChangeViewBoxNotifier;
|
||||
using SVGElement = dom::SVGElement;
|
||||
|
||||
void Init();
|
||||
|
|
Загрузка…
Ссылка в новой задаче