2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2013-01-05 05:50:22 +04:00
|
|
|
#include "mozilla/dom/SVGMPathElement.h"
|
2018-12-28 05:47:10 +03:00
|
|
|
|
2010-04-29 03:00:54 +04:00
|
|
|
#include "nsDebug.h"
|
2018-12-28 05:47:10 +03:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2020-12-21 06:49:33 +03:00
|
|
|
#include "mozilla/SVGObserverUtils.h"
|
2020-11-23 19:21:38 +03:00
|
|
|
#include "mozilla/dom/ReferrerInfo.h"
|
2013-01-06 13:32:02 +04:00
|
|
|
#include "mozilla/dom/SVGAnimateMotionElement.h"
|
2020-10-01 19:19:37 +03:00
|
|
|
#include "mozilla/dom/SVGGeometryElement.h"
|
2012-01-26 13:57:21 +04:00
|
|
|
#include "nsContentUtils.h"
|
2019-07-16 14:43:56 +03:00
|
|
|
#include "nsIReferrerInfo.h"
|
2013-01-05 05:50:22 +04:00
|
|
|
#include "mozilla/dom/SVGMPathElementBinding.h"
|
2013-08-24 06:42:40 +04:00
|
|
|
#include "nsIURI.h"
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2018-12-21 14:43:29 +03:00
|
|
|
NS_IMPL_NS_NEW_SVG_ELEMENT(MPath)
|
2013-01-05 05:50:22 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
JSObject* SVGMPathElement::WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return SVGMPathElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-01-05 05:50:22 +04:00
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::StringInfo SVGMPathElement::sStringInfo[2] = {
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::href, kNameSpaceID_None, false},
|
|
|
|
{nsGkAtoms::href, kNameSpaceID_XLink, false}};
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2016-09-22 17:33:42 +03:00
|
|
|
// Cycle collection magic -- based on SVGUseElement
|
2013-08-02 05:29:05 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(SVGMPathElement)
|
|
|
|
|
2013-01-05 05:50:22 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SVGMPathElement,
|
|
|
|
SVGMPathElementBase)
|
2011-10-17 18:59:28 +04:00
|
|
|
tmp->UnlinkHrefTarget(false);
|
2010-04-29 03:00:54 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
2013-01-05 05:50:22 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SVGMPathElement,
|
|
|
|
SVGMPathElementBase)
|
2017-09-12 16:37:10 +03:00
|
|
|
tmp->mPathTracker.Traverse(&cb);
|
2010-04-29 03:00:54 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
2017-09-01 02:29:22 +03:00
|
|
|
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(SVGMPathElement,
|
|
|
|
SVGMPathElementBase,
|
|
|
|
nsIMutationObserver)
|
2010-04-29 03:00:54 +04:00
|
|
|
|
|
|
|
// Constructor
|
2018-09-21 23:45:49 +03:00
|
|
|
SVGMPathElement::SVGMPathElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
|
|
|
: SVGMPathElementBase(std::move(aNodeInfo)), mPathTracker(this) {}
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2013-01-05 05:50:22 +04:00
|
|
|
SVGMPathElement::~SVGMPathElement() { UnlinkHrefTarget(false); }
|
2010-04-29 03:00:54 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-05-30 05:58:49 +03:00
|
|
|
// nsINode methods
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2013-01-05 05:50:22 +04:00
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGMPathElement)
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedString> SVGMPathElement::Href() {
|
2016-07-06 11:40:30 +03:00
|
|
|
return mStringAttributes[HREF].IsExplicitlySet()
|
|
|
|
? mStringAttributes[HREF].ToDOMAnimatedString(this)
|
|
|
|
: mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
|
2013-01-05 05:50:22 +04:00
|
|
|
}
|
|
|
|
|
2010-04-29 03:00:54 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods
|
|
|
|
|
Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.
Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.
I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.
Steps are:
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format
Then manual fixups.
Depends on D32948
Differential Revision: https://phabricator.services.mozilla.com/D32949
2019-05-29 07:27:04 +03:00
|
|
|
nsresult SVGMPathElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
2017-09-12 16:37:10 +03:00
|
|
|
MOZ_ASSERT(!mPathTracker.get(),
|
2015-02-10 01:34:50 +03:00
|
|
|
"Shouldn't have href-target yet (or it should've been cleared)");
|
Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.
Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.
I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.
Steps are:
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format
Then manual fixups.
Depends on D32948
Differential Revision: https://phabricator.services.mozilla.com/D32949
2019-05-29 07:27:04 +03:00
|
|
|
nsresult rv = SVGMPathElementBase::BindToTree(aContext, aParent);
|
2010-04-29 03:00:54 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2019-05-13 20:28:59 +03:00
|
|
|
if (IsInComposedDoc()) {
|
2010-04-29 03:00:54 +04:00
|
|
|
const nsAttrValue* hrefAttrValue =
|
2016-07-06 11:40:30 +03:00
|
|
|
HasAttr(kNameSpaceID_None, nsGkAtoms::href)
|
2018-08-07 22:07:26 +03:00
|
|
|
? mAttrs.GetAttr(nsGkAtoms::href, kNameSpaceID_None)
|
|
|
|
: mAttrs.GetAttr(nsGkAtoms::href, kNameSpaceID_XLink);
|
2010-04-29 03:00:54 +04:00
|
|
|
if (hrefAttrValue) {
|
Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.
Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.
I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.
Steps are:
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format
Then manual fixups.
Depends on D32948
Differential Revision: https://phabricator.services.mozilla.com/D32949
2019-05-29 07:27:04 +03:00
|
|
|
UpdateHrefTarget(nsIContent::FromNode(aParent),
|
|
|
|
hrefAttrValue->GetStringValue());
|
2010-04-29 03:00:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-29 01:47:08 +03:00
|
|
|
void SVGMPathElement::UnbindFromTree(bool aNullParent) {
|
2011-10-17 18:59:28 +04:00
|
|
|
UnlinkHrefTarget(true);
|
2019-05-29 01:47:08 +03:00
|
|
|
SVGMPathElementBase::UnbindFromTree(aNullParent);
|
2010-04-29 03:00:54 +04:00
|
|
|
}
|
|
|
|
|
2013-01-05 05:50:22 +04:00
|
|
|
bool SVGMPathElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
2017-11-02 06:35:52 +03:00
|
|
|
const nsAString& aValue,
|
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2013-01-05 05:50:22 +04:00
|
|
|
nsAttrValue& aResult) {
|
2018-01-04 05:03:29 +03:00
|
|
|
bool returnVal = SVGMPathElementBase::ParseAttribute(
|
2017-11-02 06:35:52 +03:00
|
|
|
aNamespaceID, aAttribute, aValue, aMaybeScriptedPrincipal, aResult);
|
2016-07-06 11:40:30 +03:00
|
|
|
if ((aNamespaceID == kNameSpaceID_XLink ||
|
|
|
|
aNamespaceID == kNameSpaceID_None) &&
|
2019-05-13 20:28:59 +03:00
|
|
|
aAttribute == nsGkAtoms::href && IsInComposedDoc()) {
|
2016-07-06 11:40:30 +03:00
|
|
|
// Note: If we fail the IsInDoc call, it's ok -- we'll update the target
|
2010-04-29 03:00:54 +04:00
|
|
|
// on next BindToTree call.
|
2016-07-06 11:40:30 +03:00
|
|
|
|
|
|
|
// Note: "href" takes priority over xlink:href. So if "xlink:href" is being
|
|
|
|
// set here, we only let that update our target if "href" is *unset*.
|
|
|
|
if (aNamespaceID != kNameSpaceID_XLink ||
|
|
|
|
!mStringAttributes[HREF].IsExplicitlySet()) {
|
|
|
|
UpdateHrefTarget(GetParent(), aValue);
|
|
|
|
}
|
2010-04-29 03:00:54 +04:00
|
|
|
}
|
|
|
|
return returnVal;
|
|
|
|
}
|
|
|
|
|
2018-01-04 05:03:29 +03:00
|
|
|
nsresult SVGMPathElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
|
|
|
|
const nsAttrValue* aValue,
|
|
|
|
const nsAttrValue* aOldValue,
|
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
|
|
|
bool aNotify) {
|
|
|
|
if (!aValue && aName == nsGkAtoms::href) {
|
|
|
|
// href attr being removed.
|
2016-07-06 11:40:30 +03:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
|
|
|
UnlinkHrefTarget(true);
|
|
|
|
|
|
|
|
// After unsetting href, we may still have xlink:href, so we should
|
|
|
|
// try to add it back.
|
|
|
|
const nsAttrValue* xlinkHref =
|
2018-08-07 22:07:26 +03:00
|
|
|
mAttrs.GetAttr(nsGkAtoms::href, kNameSpaceID_XLink);
|
2016-07-06 11:40:30 +03:00
|
|
|
if (xlinkHref) {
|
|
|
|
UpdateHrefTarget(GetParent(), xlinkHref->GetStringValue());
|
|
|
|
}
|
2018-01-04 05:03:29 +03:00
|
|
|
} else if (aNamespaceID == kNameSpaceID_XLink &&
|
|
|
|
!HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
|
2016-07-06 11:40:30 +03:00
|
|
|
UnlinkHrefTarget(true);
|
2018-01-04 05:03:29 +03:00
|
|
|
} // else: we unset some random-namespace href attribute, or unset
|
|
|
|
// xlink:href but still have href attribute, so keep the target linking
|
|
|
|
// to href.
|
2010-04-29 03:00:54 +04:00
|
|
|
}
|
|
|
|
|
2018-01-04 05:03:29 +03:00
|
|
|
return SVGMPathElementBase::AfterSetAttr(
|
|
|
|
aNamespaceID, aName, aValue, aOldValue, aMaybeScriptedPrincipal, aNotify);
|
2010-04-29 03:00:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-12-21 11:58:14 +03:00
|
|
|
// SVGElement methods
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::StringAttributesInfo SVGMPathElement::GetStringInfo() {
|
2010-04-29 03:00:54 +04:00
|
|
|
return StringAttributesInfo(mStringAttributes, sStringInfo,
|
2011-10-11 09:50:08 +04:00
|
|
|
ArrayLength(sStringInfo));
|
2010-04-29 03:00:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIMutationObserver methods
|
|
|
|
|
2018-03-01 14:36:58 +03:00
|
|
|
void SVGMPathElement::AttributeChanged(Element* aElement, int32_t aNameSpaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute, int32_t aModType,
|
2015-07-25 09:01:19 +03:00
|
|
|
const nsAttrValue* aOldValue) {
|
2010-04-29 03:00:54 +04:00
|
|
|
if (aNameSpaceID == kNameSpaceID_None) {
|
|
|
|
if (aAttribute == nsGkAtoms::d) {
|
|
|
|
NotifyParentOfMpathChange(GetParent());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Public helper methods
|
|
|
|
|
2020-10-01 19:19:37 +03:00
|
|
|
SVGGeometryElement* SVGMPathElement::GetReferencedPath() {
|
2016-07-06 11:40:30 +03:00
|
|
|
if (!HasAttr(kNameSpaceID_XLink, nsGkAtoms::href) &&
|
|
|
|
!HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
|
2017-09-12 16:37:10 +03:00
|
|
|
MOZ_ASSERT(!mPathTracker.get(),
|
2016-07-06 11:40:30 +03:00
|
|
|
"We shouldn't have a href target "
|
|
|
|
"if we don't have an xlink:href or href attribute");
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-04-29 03:00:54 +04:00
|
|
|
}
|
|
|
|
|
2017-09-12 16:37:10 +03:00
|
|
|
nsIContent* genericTarget = mPathTracker.get();
|
2020-10-01 19:19:37 +03:00
|
|
|
if (genericTarget && genericTarget->IsNodeOfType(nsINode::eSHAPE)) {
|
|
|
|
return static_cast<SVGGeometryElement*>(genericTarget);
|
2010-04-29 03:00:54 +04:00
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-04-29 03:00:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Protected helper methods
|
|
|
|
|
2013-01-05 05:50:22 +04:00
|
|
|
void SVGMPathElement::UpdateHrefTarget(nsIContent* aParent,
|
|
|
|
const nsAString& aHrefStr) {
|
2020-12-21 06:49:33 +03:00
|
|
|
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
|
|
|
if (nsContentUtils::IsLocalRefURL(aHrefStr)) {
|
|
|
|
baseURI = SVGObserverUtils::GetBaseURLForLocalRef(this, baseURI);
|
|
|
|
}
|
2010-04-29 03:00:54 +04:00
|
|
|
nsCOMPtr<nsIURI> targetURI;
|
|
|
|
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(targetURI), aHrefStr,
|
2020-12-21 06:49:33 +03:00
|
|
|
OwnerDoc(), baseURI);
|
2010-04-29 03:00:54 +04:00
|
|
|
|
|
|
|
// Stop observing old target (if any)
|
2017-09-12 16:37:10 +03:00
|
|
|
if (mPathTracker.get()) {
|
|
|
|
mPathTracker.get()->RemoveMutationObserver(this);
|
2010-04-29 03:00:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aParent) {
|
|
|
|
// Pass in |aParent| instead of |this| -- first argument is only used
|
2014-10-03 16:32:26 +04:00
|
|
|
// for a call to GetComposedDoc(), and |this| might not have a current
|
2010-04-29 03:00:54 +04:00
|
|
|
// document yet (if our caller is BindToTree).
|
2019-07-16 14:43:56 +03:00
|
|
|
nsCOMPtr<nsIReferrerInfo> referrerInfo =
|
|
|
|
ReferrerInfo::CreateForSVGResources(OwnerDoc());
|
|
|
|
|
|
|
|
mPathTracker.ResetToURIFragmentID(aParent, targetURI, referrerInfo);
|
2010-04-29 03:00:54 +04:00
|
|
|
} 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.
|
2017-09-12 16:37:10 +03:00
|
|
|
mPathTracker.Unlink();
|
2010-04-29 03:00:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Start observing new target (if any)
|
2017-09-12 16:37:10 +03:00
|
|
|
if (mPathTracker.get()) {
|
|
|
|
mPathTracker.get()->AddMutationObserver(this);
|
2010-04-29 03:00:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NotifyParentOfMpathChange(aParent);
|
|
|
|
}
|
|
|
|
|
2013-01-05 05:50:22 +04:00
|
|
|
void SVGMPathElement::UnlinkHrefTarget(bool aNotifyParent) {
|
2010-04-29 03:00:54 +04:00
|
|
|
// Stop observing old target (if any)
|
2017-09-12 16:37:10 +03:00
|
|
|
if (mPathTracker.get()) {
|
|
|
|
mPathTracker.get()->RemoveMutationObserver(this);
|
2010-04-29 03:00:54 +04:00
|
|
|
}
|
2017-09-12 16:37:10 +03:00
|
|
|
mPathTracker.Unlink();
|
2010-04-29 03:00:54 +04:00
|
|
|
|
|
|
|
if (aNotifyParent) {
|
|
|
|
NotifyParentOfMpathChange(GetParent());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-05 05:50:22 +04:00
|
|
|
void SVGMPathElement::NotifyParentOfMpathChange(nsIContent* aParent) {
|
2015-03-03 14:08:59 +03:00
|
|
|
if (aParent && aParent->IsSVGElement(nsGkAtoms::animateMotion)) {
|
2013-01-06 13:32:02 +04:00
|
|
|
SVGAnimateMotionElement* animateMotionParent =
|
|
|
|
static_cast<SVGAnimateMotionElement*>(aParent);
|
2010-04-29 03:00:54 +04:00
|
|
|
|
|
|
|
animateMotionParent->MpathChanged();
|
|
|
|
AnimationNeedsResample();
|
|
|
|
}
|
|
|
|
}
|
2013-01-05 05:50:22 +04:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|