зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1403500, part 3 - Document and do some renaming for SVGMPathElement's PathReference. r=longsonr
MozReview-Commit-ID: ILBHXwF4FkR
This commit is contained in:
Родитель
33a64073fd
Коммит
957895f090
|
@ -41,7 +41,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SVGMPathElement,
|
||||
SVGMPathElementBase)
|
||||
tmp->mHrefTarget.Traverse(&cb);
|
||||
tmp->mPathTracker.Traverse(&cb);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -56,8 +56,8 @@ NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(SVGMPathElement,
|
|||
|
||||
// Constructor
|
||||
SVGMPathElement::SVGMPathElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
||||
: SVGMPathElementBase(aNodeInfo),
|
||||
mHrefTarget(this)
|
||||
: SVGMPathElementBase(aNodeInfo)
|
||||
, mPathTracker(this)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ SVGMPathElement::BindToTree(nsIDocument* aDocument,
|
|||
nsIContent* aBindingParent,
|
||||
bool aCompileEventHandlers)
|
||||
{
|
||||
MOZ_ASSERT(!mHrefTarget.get(),
|
||||
MOZ_ASSERT(!mPathTracker.get(),
|
||||
"Shouldn't have href-target yet (or it should've been cleared)");
|
||||
nsresult rv = SVGMPathElementBase::BindToTree(aDocument, aParent,
|
||||
aBindingParent,
|
||||
|
@ -205,13 +205,13 @@ SVGMPathElement::GetReferencedPath()
|
|||
{
|
||||
if (!HasAttr(kNameSpaceID_XLink, nsGkAtoms::href) &&
|
||||
!HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
|
||||
MOZ_ASSERT(!mHrefTarget.get(),
|
||||
MOZ_ASSERT(!mPathTracker.get(),
|
||||
"We shouldn't have a href target "
|
||||
"if we don't have an xlink:href or href attribute");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsIContent* genericTarget = mHrefTarget.get();
|
||||
nsIContent* genericTarget = mPathTracker.get();
|
||||
if (genericTarget && genericTarget->IsSVGElement(nsGkAtoms::path)) {
|
||||
return static_cast<SVGPathElement*>(genericTarget);
|
||||
}
|
||||
|
@ -231,24 +231,24 @@ SVGMPathElement::UpdateHrefTarget(nsIContent* aParent,
|
|||
aHrefStr, OwnerDoc(), baseURI);
|
||||
|
||||
// Stop observing old target (if any)
|
||||
if (mHrefTarget.get()) {
|
||||
mHrefTarget.get()->RemoveMutationObserver(this);
|
||||
if (mPathTracker.get()) {
|
||||
mPathTracker.get()->RemoveMutationObserver(this);
|
||||
}
|
||||
|
||||
if (aParent) {
|
||||
// Pass in |aParent| instead of |this| -- first argument is only used
|
||||
// for a call to GetComposedDoc(), and |this| might not have a current
|
||||
// document yet (if our caller is BindToTree).
|
||||
mHrefTarget.Reset(aParent, targetURI);
|
||||
mPathTracker.Reset(aParent, targetURI);
|
||||
} else {
|
||||
// if we don't have a parent, then there's no animateMotion element
|
||||
// depending on our target, so there's no point tracking it right now.
|
||||
mHrefTarget.Unlink();
|
||||
mPathTracker.Unlink();
|
||||
}
|
||||
|
||||
// Start observing new target (if any)
|
||||
if (mHrefTarget.get()) {
|
||||
mHrefTarget.get()->AddMutationObserver(this);
|
||||
if (mPathTracker.get()) {
|
||||
mPathTracker.get()->AddMutationObserver(this);
|
||||
}
|
||||
|
||||
NotifyParentOfMpathChange(aParent);
|
||||
|
@ -258,10 +258,10 @@ void
|
|||
SVGMPathElement::UnlinkHrefTarget(bool aNotifyParent)
|
||||
{
|
||||
// Stop observing old target (if any)
|
||||
if (mHrefTarget.get()) {
|
||||
mHrefTarget.get()->RemoveMutationObserver(this);
|
||||
if (mPathTracker.get()) {
|
||||
mPathTracker.get()->RemoveMutationObserver(this);
|
||||
}
|
||||
mHrefTarget.Unlink();
|
||||
mPathTracker.Unlink();
|
||||
|
||||
if (aNotifyParent) {
|
||||
NotifyParentOfMpathChange(GetParent());
|
||||
|
|
|
@ -66,10 +66,18 @@ public:
|
|||
already_AddRefed<SVGAnimatedString> Href();
|
||||
|
||||
protected:
|
||||
class PathReference : public mozilla::dom::IDTracker {
|
||||
/**
|
||||
* Helper that provides a reference to the 'path' element with the ID that is
|
||||
* referenced by the 'mpath' element's 'href' attribute, and that will
|
||||
* invalidate the parent of the 'mpath' and update mutation observers to the
|
||||
* new path element if the element that that ID identifies changes to a
|
||||
* different element (or none).
|
||||
*/
|
||||
class PathElementTracker final : public IDTracker {
|
||||
public:
|
||||
explicit PathReference(SVGMPathElement* aMpathElement) :
|
||||
mMpathElement(aMpathElement) {}
|
||||
explicit PathElementTracker(SVGMPathElement* aMpathElement)
|
||||
: mMpathElement(aMpathElement)
|
||||
{}
|
||||
protected:
|
||||
// We need to be notified when target changes, in order to request a sample
|
||||
// (which will clear animation effects that used the old target-path
|
||||
|
@ -101,7 +109,7 @@ protected:
|
|||
enum { HREF, XLINK_HREF };
|
||||
nsSVGString mStringAttributes[2];
|
||||
static StringInfo sStringInfo[2];
|
||||
PathReference mHrefTarget;
|
||||
PathElementTracker mPathTracker;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
Загрузка…
Ссылка в новой задаче