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/. */
|
2007-01-27 02:45:15 +03:00
|
|
|
|
2013-01-10 09:30:13 +04:00
|
|
|
#include "mozilla/dom/SVGAElement.h"
|
2013-07-10 13:56:47 +04:00
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
2014-03-18 08:48:21 +04:00
|
|
|
#include "mozilla/EventDispatcher.h"
|
2014-04-03 08:18:36 +04:00
|
|
|
#include "mozilla/EventStates.h"
|
2013-01-10 09:30:13 +04:00
|
|
|
#include "mozilla/dom/SVGAElementBinding.h"
|
2007-01-27 02:45:15 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2011-08-11 17:29:50 +04:00
|
|
|
#include "nsContentUtils.h"
|
2013-07-10 13:56:47 +04:00
|
|
|
#include "nsGkAtoms.h"
|
2018-06-08 22:57:13 +03:00
|
|
|
#include "nsIContentInlines.h"
|
2013-08-24 06:42:40 +04:00
|
|
|
#include "nsIURI.h"
|
2007-01-27 02:45:15 +03:00
|
|
|
|
2018-12-21 14:43:29 +03:00
|
|
|
NS_IMPL_NS_NEW_SVG_ELEMENT(A)
|
2013-01-10 09:30:13 +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* SVGAElement::WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return SVGAElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-01-10 09:30:13 +04:00
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::StringInfo SVGAElement::sStringInfo[3] = {
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::href, kNameSpaceID_None, true},
|
|
|
|
{nsGkAtoms::href, kNameSpaceID_XLink, true},
|
|
|
|
{nsGkAtoms::target, kNameSpaceID_None, true}};
|
2008-06-14 13:01:02 +04:00
|
|
|
|
2018-04-14 16:53:37 +03:00
|
|
|
// static
|
|
|
|
const DOMTokenListSupportedToken SVGAElement::sSupportedRelValues[] = {
|
|
|
|
"noreferrer", "noopener", nullptr};
|
2007-01-27 02:45:15 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
2018-04-14 16:53:37 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SVGAElement)
|
2017-09-06 00:12:31 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(Link)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(SVGAElementBase)
|
2013-12-12 23:30:27 +04:00
|
|
|
|
2018-04-14 16:53:37 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED(SVGAElement, SVGAElementBase, mRelList)
|
|
|
|
|
2017-09-06 20:18:06 +03:00
|
|
|
NS_IMPL_ADDREF_INHERITED(SVGAElement, SVGAElementBase)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(SVGAElement, SVGAElementBase)
|
2007-01-27 02:45:15 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2018-09-21 23:45:49 +03:00
|
|
|
SVGAElement::SVGAElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
|
|
|
: SVGAElementBase(std::move(aNodeInfo)), Link(this) {}
|
2007-01-27 02:45:15 +03:00
|
|
|
|
2014-07-09 01:23:16 +04:00
|
|
|
SVGAElement::~SVGAElement() {}
|
|
|
|
|
2013-06-15 02:37:27 +04:00
|
|
|
already_AddRefed<SVGAnimatedString> SVGAElement::Href() {
|
2016-06-28 12:22:30 +03:00
|
|
|
return mStringAttributes[HREF].IsExplicitlySet()
|
|
|
|
? mStringAttributes[HREF].ToDOMAnimatedString(this)
|
|
|
|
: mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
|
2007-01-27 02:45:15 +03:00
|
|
|
}
|
|
|
|
|
2017-05-06 22:32:14 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Link methods
|
|
|
|
|
|
|
|
bool SVGAElement::ElementHasHref() const {
|
|
|
|
return mStringAttributes[HREF].IsExplicitlySet() ||
|
|
|
|
mStringAttributes[XLINK_HREF].IsExplicitlySet();
|
|
|
|
}
|
|
|
|
|
2007-01-27 02:45:15 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsINode methods
|
|
|
|
|
2016-10-21 05:11:07 +03:00
|
|
|
void SVGAElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
|
2018-04-05 20:42:41 +03:00
|
|
|
Element::GetEventTargetParent(aVisitor);
|
2007-04-23 11:31:21 +04:00
|
|
|
|
2018-04-05 20:42:41 +03:00
|
|
|
GetEventTargetParentForLinks(aVisitor);
|
2007-04-23 11:31:21 +04:00
|
|
|
}
|
|
|
|
|
2014-03-18 08:48:20 +04:00
|
|
|
nsresult SVGAElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
|
2007-01-27 02:45:15 +03:00
|
|
|
return PostHandleEventForLinks(aVisitor);
|
|
|
|
}
|
|
|
|
|
2013-01-10 09:30:13 +04:00
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGAElement)
|
2007-01-27 02:45:15 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2013-06-15 02:37:27 +04:00
|
|
|
already_AddRefed<SVGAnimatedString> SVGAElement::Target() {
|
2013-03-10 11:58:53 +04:00
|
|
|
return mStringAttributes[TARGET].ToDOMAnimatedString(this);
|
2013-01-10 09:30:13 +04:00
|
|
|
}
|
|
|
|
|
2018-04-04 06:58:49 +03:00
|
|
|
void SVGAElement::GetDownload(nsAString& aDownload) {
|
|
|
|
GetAttr(nsGkAtoms::download, aDownload);
|
2013-02-19 02:48:53 +04:00
|
|
|
}
|
2013-01-10 09:30:13 +04:00
|
|
|
|
2018-04-04 06:58:49 +03:00
|
|
|
void SVGAElement::SetDownload(const nsAString& aDownload, ErrorResult& rv) {
|
|
|
|
SetAttr(nsGkAtoms::download, aDownload, rv);
|
2013-02-19 02:48:53 +04:00
|
|
|
}
|
2007-01-27 02:45:15 +03:00
|
|
|
|
2018-04-14 16:53:37 +03:00
|
|
|
void SVGAElement::GetPing(nsAString& aPing) { GetAttr(nsGkAtoms::ping, aPing); }
|
|
|
|
|
|
|
|
void SVGAElement::SetPing(const nsAString& aPing, ErrorResult& rv) {
|
|
|
|
SetAttr(nsGkAtoms::ping, aPing, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SVGAElement::GetRel(nsAString& aRel) { GetAttr(nsGkAtoms::rel, aRel); }
|
|
|
|
|
|
|
|
void SVGAElement::SetRel(const nsAString& aRel, ErrorResult& rv) {
|
|
|
|
SetAttr(nsGkAtoms::rel, aRel, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SVGAElement::GetReferrerPolicy(nsAString& aPolicy) {
|
|
|
|
GetEnumAttr(nsGkAtoms::referrerpolicy, EmptyCString().get(), aPolicy);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SVGAElement::SetReferrerPolicy(const nsAString& aPolicy,
|
|
|
|
mozilla::ErrorResult& rv) {
|
|
|
|
SetAttr(nsGkAtoms::referrerpolicy, aPolicy, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDOMTokenList* SVGAElement::RelList() {
|
|
|
|
if (!mRelList) {
|
|
|
|
mRelList = new nsDOMTokenList(this, nsGkAtoms::rel, sSupportedRelValues);
|
|
|
|
}
|
|
|
|
return mRelList;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SVGAElement::GetHreflang(nsAString& aHreflang) {
|
|
|
|
GetAttr(nsGkAtoms::hreflang, aHreflang);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SVGAElement::SetHreflang(const nsAString& aHreflang,
|
|
|
|
mozilla::ErrorResult& rv) {
|
|
|
|
SetAttr(nsGkAtoms::hreflang, aHreflang, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SVGAElement::GetType(nsAString& aType) { GetAttr(nsGkAtoms::type, aType); }
|
|
|
|
|
|
|
|
void SVGAElement::SetType(const nsAString& aType, mozilla::ErrorResult& rv) {
|
|
|
|
SetAttr(nsGkAtoms::type, aType, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SVGAElement::GetText(nsAString& aText, mozilla::ErrorResult& rv) {
|
|
|
|
if (NS_WARN_IF(
|
|
|
|
!nsContentUtils::GetNodeTextContent(this, true, aText, fallible))) {
|
|
|
|
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SVGAElement::SetText(const nsAString& aText, mozilla::ErrorResult& rv) {
|
|
|
|
rv = nsContentUtils::SetNodeTextContent(this, aText, false);
|
|
|
|
}
|
|
|
|
|
2007-01-27 02:45:15 +03:00
|
|
|
//----------------------------------------------------------------------
|
2009-07-13 15:48:06 +04:00
|
|
|
// nsIContent methods
|
2007-01-27 02:45:15 +03:00
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
nsresult SVGAElement::BindToTree(Document* aDocument, nsIContent* aParent,
|
2018-07-31 21:18:38 +03:00
|
|
|
nsIContent* aBindingParent) {
|
2012-12-07 18:35:14 +04:00
|
|
|
Link::ResetLinkState(false, Link::ElementHasHref());
|
2009-11-23 21:48:52 +03:00
|
|
|
|
2013-01-10 09:30:13 +04:00
|
|
|
nsresult rv = SVGAElementBase::BindToTree(aDocument, aParent, aBindingParent);
|
2009-11-23 21:48:52 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2013-01-10 09:30:13 +04:00
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* doc = GetComposedDoc();
|
2014-10-03 16:32:26 +04:00
|
|
|
if (doc) {
|
|
|
|
doc->RegisterPendingLinkUpdate(this);
|
2011-11-14 07:24:41 +04:00
|
|
|
}
|
2009-11-23 21:48:52 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-01-10 09:30:13 +04:00
|
|
|
void SVGAElement::UnbindFromTree(bool aDeep, bool aNullParent) {
|
2018-12-13 18:16:52 +03:00
|
|
|
// Without removing the link state we risk a dangling pointer
|
|
|
|
// in the mStyledLinks hashtable
|
2012-12-07 18:35:14 +04:00
|
|
|
Link::ResetLinkState(false, Link::ElementHasHref());
|
2013-01-10 09:30:13 +04:00
|
|
|
|
|
|
|
SVGAElementBase::UnbindFromTree(aDeep, aNullParent);
|
2009-11-23 21:48:52 +03:00
|
|
|
}
|
|
|
|
|
2013-01-10 09:30:13 +04:00
|
|
|
already_AddRefed<nsIURI> SVGAElement::GetHrefURI() const {
|
2009-11-09 21:00:54 +03:00
|
|
|
nsCOMPtr<nsIURI> hrefURI;
|
2012-07-30 18:20:58 +04:00
|
|
|
return IsLink(getter_AddRefs(hrefURI)) ? hrefURI.forget() : nullptr;
|
2007-01-27 02:45:15 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2017-10-03 01:05:19 +03:00
|
|
|
SVGAElement::IsAttributeMapped(const nsAtom* name) const {
|
2010-06-09 22:53:40 +04:00
|
|
|
static const MappedAttributeEntry* const map[] = {sFEFloodMap,
|
|
|
|
sFiltersMap,
|
|
|
|
sFontSpecificationMap,
|
|
|
|
sGradientStopMap,
|
|
|
|
sLightingEffectsMap,
|
|
|
|
sMarkersMap,
|
|
|
|
sTextContentElementsMap,
|
|
|
|
sViewportsMap};
|
|
|
|
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(name, map) ||
|
2013-01-10 09:30:13 +04:00
|
|
|
SVGAElementBase::IsAttributeMapped(name);
|
2010-06-09 22:53:40 +04:00
|
|
|
}
|
|
|
|
|
2016-09-28 05:21:50 +03:00
|
|
|
int32_t SVGAElement::TabIndexDefault() { return 0; }
|
|
|
|
|
|
|
|
static bool IsNodeInEditableRegion(nsINode* aNode) {
|
|
|
|
while (aNode) {
|
|
|
|
if (aNode->IsEditable()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
aNode = aNode->GetParent();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-12-19 12:41:11 +03:00
|
|
|
bool SVGAElement::IsFocusableInternal(int32_t* aTabIndex, bool aWithMouse) {
|
|
|
|
bool isFocusable = false;
|
|
|
|
if (IsSVGFocusable(&isFocusable, aTabIndex)) {
|
|
|
|
return isFocusable;
|
2016-09-28 05:21:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// cannot focus links if there is no link handler
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* doc = GetComposedDoc();
|
2016-09-28 05:21:50 +03:00
|
|
|
if (doc) {
|
2018-02-21 01:00:10 +03:00
|
|
|
nsPresContext* presContext = doc->GetPresContext();
|
|
|
|
if (presContext && !presContext->GetLinkHandler()) {
|
|
|
|
return false;
|
2016-09-28 05:21:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Links that are in an editable region should never be focusable, even if
|
|
|
|
// they are in a contenteditable="false" region.
|
|
|
|
if (IsNodeInEditableRegion(this)) {
|
2007-01-27 02:45:15 +03:00
|
|
|
if (aTabIndex) {
|
2016-09-28 05:21:50 +03:00
|
|
|
*aTabIndex = -1;
|
2007-01-27 02:45:15 +03:00
|
|
|
}
|
2018-12-19 12:41:11 +03:00
|
|
|
return false;
|
2007-01-27 02:45:15 +03:00
|
|
|
}
|
2016-09-28 05:21:50 +03:00
|
|
|
|
|
|
|
if (!HasAttr(kNameSpaceID_None, nsGkAtoms::tabindex)) {
|
|
|
|
// check whether we're actually a link
|
|
|
|
if (!Link::HasURI()) {
|
|
|
|
// Not tabbable or focusable without href (bug 17605), unless
|
|
|
|
// forced to be via presence of nonnegative tabindex attribute
|
|
|
|
if (aTabIndex) {
|
|
|
|
*aTabIndex = -1;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-24 07:22:17 +03:00
|
|
|
}
|
2007-01-27 02:45:15 +03:00
|
|
|
|
2016-09-28 05:21:50 +03:00
|
|
|
if (aTabIndex && (sTabFocusModel & eTabFocus_linksMask) == 0) {
|
2007-01-27 02:45:15 +03:00
|
|
|
*aTabIndex = -1;
|
|
|
|
}
|
|
|
|
|
2018-12-19 12:41:11 +03:00
|
|
|
return true;
|
2007-01-27 02:45:15 +03:00
|
|
|
}
|
|
|
|
|
2013-01-10 09:30:13 +04:00
|
|
|
bool SVGAElement::IsLink(nsIURI** aURI) const {
|
2007-01-27 02:45:15 +03:00
|
|
|
// To be a clickable XLink for styling and interaction purposes, we require:
|
|
|
|
//
|
|
|
|
// xlink:href - must be set
|
|
|
|
// xlink:type - must be unset or set to "" or set to "simple"
|
|
|
|
// xlink:show - must be unset or set to "", "new" or "replace"
|
|
|
|
// xlink:actuate - must be unset or set to "" or "onRequest"
|
|
|
|
//
|
|
|
|
// For any other values, we're either not a *clickable* XLink, or the end
|
2011-10-17 18:59:28 +04:00
|
|
|
// result is poorly specified. Either way, we return false.
|
2007-01-27 02:45:15 +03:00
|
|
|
|
2017-12-07 21:13:50 +03:00
|
|
|
static Element::AttrValuesArray sTypeVals[] = {nsGkAtoms::_empty,
|
2018-04-03 06:21:06 +03:00
|
|
|
nsGkAtoms::simple, nullptr};
|
2007-01-27 02:45:15 +03:00
|
|
|
|
2017-12-07 21:13:50 +03:00
|
|
|
static Element::AttrValuesArray sShowVals[] = {
|
2018-04-03 06:21:06 +03:00
|
|
|
nsGkAtoms::_empty, nsGkAtoms::_new, nsGkAtoms::replace, nullptr};
|
2007-01-27 02:45:15 +03:00
|
|
|
|
2017-12-07 21:13:50 +03:00
|
|
|
static Element::AttrValuesArray sActuateVals[] = {
|
2018-04-03 06:21:06 +03:00
|
|
|
nsGkAtoms::_empty, nsGkAtoms::onRequest, nullptr};
|
2007-01-27 02:45:15 +03:00
|
|
|
|
|
|
|
// Optimization: check for href first for early return
|
2017-05-06 22:32:14 +03:00
|
|
|
bool useBareHref = mStringAttributes[HREF].IsExplicitlySet();
|
2016-06-28 12:22:30 +03:00
|
|
|
|
2017-05-06 22:32:14 +03:00
|
|
|
if ((useBareHref || mStringAttributes[XLINK_HREF].IsExplicitlySet()) &&
|
2007-01-27 02:45:15 +03:00
|
|
|
FindAttrValueIn(kNameSpaceID_XLink, nsGkAtoms::type, sTypeVals,
|
2017-12-07 21:13:50 +03:00
|
|
|
eCaseMatters) != Element::ATTR_VALUE_NO_MATCH &&
|
2007-01-27 02:45:15 +03:00
|
|
|
FindAttrValueIn(kNameSpaceID_XLink, nsGkAtoms::show, sShowVals,
|
2017-12-07 21:13:50 +03:00
|
|
|
eCaseMatters) != Element::ATTR_VALUE_NO_MATCH &&
|
2007-01-27 02:45:15 +03:00
|
|
|
FindAttrValueIn(kNameSpaceID_XLink, nsGkAtoms::actuate, sActuateVals,
|
2017-12-07 21:13:50 +03:00
|
|
|
eCaseMatters) != Element::ATTR_VALUE_NO_MATCH) {
|
2007-01-27 02:45:15 +03:00
|
|
|
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
|
|
|
// Get absolute URI
|
2009-01-22 03:56:51 +03:00
|
|
|
nsAutoString str;
|
2017-05-06 22:32:14 +03:00
|
|
|
const uint8_t idx = useBareHref ? HREF : XLINK_HREF;
|
2016-06-28 12:22:30 +03:00
|
|
|
mStringAttributes[idx].GetAnimValue(str, this);
|
|
|
|
nsContentUtils::NewURIWithDocumentCharset(aURI, str, OwnerDoc(), baseURI);
|
2007-01-27 02:45:15 +03:00
|
|
|
// must promise out param is non-null if we return true
|
|
|
|
return !!*aURI;
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
*aURI = nullptr;
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2007-01-27 02:45:15 +03:00
|
|
|
}
|
|
|
|
|
2013-01-10 09:30:13 +04:00
|
|
|
void SVGAElement::GetLinkTarget(nsAString& aTarget) {
|
2009-01-22 03:56:51 +03:00
|
|
|
mStringAttributes[TARGET].GetAnimValue(aTarget, this);
|
2007-04-03 12:59:11 +04:00
|
|
|
if (aTarget.IsEmpty()) {
|
2017-12-07 21:13:50 +03:00
|
|
|
static Element::AttrValuesArray sShowVals[] = {nsGkAtoms::_new,
|
2018-04-03 06:21:06 +03:00
|
|
|
nsGkAtoms::replace, nullptr};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2008-08-01 13:52:23 +04:00
|
|
|
switch (FindAttrValueIn(kNameSpaceID_XLink, nsGkAtoms::show, sShowVals,
|
|
|
|
eCaseMatters)) {
|
|
|
|
case 0:
|
|
|
|
aTarget.AssignLiteral("_blank");
|
|
|
|
return;
|
|
|
|
case 1:
|
|
|
|
return;
|
|
|
|
}
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* ownerDoc = OwnerDoc();
|
2007-04-03 12:59:11 +04:00
|
|
|
if (ownerDoc) {
|
|
|
|
ownerDoc->GetBaseTarget(aTarget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-06-14 13:01:02 +04:00
|
|
|
|
2013-01-10 09:30:13 +04:00
|
|
|
EventStates SVGAElement::IntrinsicState() const {
|
|
|
|
return Link::LinkState() | SVGAElementBase::IntrinsicState();
|
2009-12-16 03:04:09 +03:00
|
|
|
}
|
|
|
|
|
2018-01-03 22:21:22 +03:00
|
|
|
nsresult SVGAElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
|
|
|
const nsAttrValue* aValue,
|
|
|
|
const nsAttrValue* aOldValue,
|
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
|
|
|
bool aNotify) {
|
2016-06-28 12:22:30 +03:00
|
|
|
if (aName == nsGkAtoms::href && (aNameSpaceID == kNameSpaceID_XLink ||
|
|
|
|
aNameSpaceID == kNameSpaceID_None)) {
|
2018-01-03 22:21:22 +03:00
|
|
|
// We can't assume that null aValue means we no longer have an href, because
|
|
|
|
// we could be unsetting xlink:href but still have a null-namespace href, or
|
|
|
|
// vice versa. But we can fast-path the case when we _do_ have a new value.
|
|
|
|
Link::ResetLinkState(aNotify, aValue || Link::ElementHasHref());
|
2010-02-24 19:37:02 +03:00
|
|
|
}
|
|
|
|
|
2018-01-03 22:21:22 +03:00
|
|
|
return SVGAElementBase::AfterSetAttr(aNameSpaceID, aName, aValue, aOldValue,
|
|
|
|
aMaybeScriptedPrincipal, aNotify);
|
2010-02-24 19:37:02 +03:00
|
|
|
}
|
|
|
|
|
2008-06-14 13:01:02 +04:00
|
|
|
//----------------------------------------------------------------------
|
2018-12-21 11:58:14 +03:00
|
|
|
// SVGElement methods
|
2008-06-14 13:01:02 +04:00
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::StringAttributesInfo SVGAElement::GetStringInfo() {
|
2008-06-14 13:01:02 +04:00
|
|
|
return StringAttributesInfo(mStringAttributes, sStringInfo,
|
2011-10-11 09:50:08 +04:00
|
|
|
ArrayLength(sStringInfo));
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
2013-01-10 09:30:13 +04:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|