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"
|
|
|
|
#include "nsSVGString.h"
|
2013-08-24 06:42:40 +04:00
|
|
|
#include "nsIURI.h"
|
2007-01-27 02:45:15 +03:00
|
|
|
|
2013-01-10 09:30:13 +04:00
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(A)
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
JSObject*
|
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
|
|
|
SVGAElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-01-10 09:30:13 +04:00
|
|
|
{
|
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
|
|
|
return SVGAElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-01-10 09:30:13 +04:00
|
|
|
}
|
|
|
|
|
2016-06-28 12:22:30 +03:00
|
|
|
nsSVGElement::StringInfo SVGAElement::sStringInfo[3] =
|
2008-06-14 13:01:02 +04:00
|
|
|
{
|
2016-06-28 12:22:30 +03:00
|
|
|
{ &nsGkAtoms::href, kNameSpaceID_None, true },
|
2011-10-17 18:59:28 +04:00
|
|
|
{ &nsGkAtoms::href, kNameSpaceID_XLink, true },
|
|
|
|
{ &nsGkAtoms::target, kNameSpaceID_None, true }
|
2008-06-14 13:01:02 +04:00
|
|
|
};
|
|
|
|
|
2007-01-27 02:45:15 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
2017-09-06 00:12:31 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN(SVGAElement)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(Link)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(SVGAElementBase)
|
2013-12-12 23:30:27 +04:00
|
|
|
|
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
|
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
SVGAElement::SVGAElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2013-07-10 13:56:47 +04:00
|
|
|
: SVGAElementBase(aNodeInfo)
|
2015-01-07 08:39:46 +03:00
|
|
|
, 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>
|
2013-01-10 09:30:13 +04:00
|
|
|
SVGAElement::Href()
|
2007-01-27 02:45:15 +03:00
|
|
|
{
|
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
|
|
|
|
|
2007-04-23 11:31:21 +04:00
|
|
|
nsresult
|
2016-10-21 05:11:07 +03:00
|
|
|
SVGAElement::GetEventTargetParent(EventChainPreVisitor& aVisitor)
|
2007-04-23 11:31:21 +04:00
|
|
|
{
|
2016-10-21 05:11:07 +03:00
|
|
|
nsresult rv = Element::GetEventTargetParent(aVisitor);
|
2007-04-23 11:31:21 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2016-10-21 05:11:07 +03:00
|
|
|
return GetEventTargetParentForLinks(aVisitor);
|
2007-04-23 11:31:21 +04:00
|
|
|
}
|
|
|
|
|
2007-01-27 02:45:15 +03:00
|
|
|
nsresult
|
2014-03-18 08:48:20 +04:00
|
|
|
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>
|
2013-01-10 09:30:13 +04:00
|
|
|
SVGAElement::Target()
|
|
|
|
{
|
2013-03-10 11:58:53 +04:00
|
|
|
return mStringAttributes[TARGET].ToDOMAnimatedString(this);
|
2013-01-10 09:30:13 +04:00
|
|
|
}
|
|
|
|
|
2013-02-19 02:48:53 +04:00
|
|
|
void
|
|
|
|
SVGAElement::GetDownload(nsAString & aDownload)
|
|
|
|
{
|
|
|
|
GetAttr(kNameSpaceID_None, nsGkAtoms::download, aDownload);
|
|
|
|
}
|
2013-01-10 09:30:13 +04:00
|
|
|
|
2013-02-19 02:48:53 +04:00
|
|
|
void
|
|
|
|
SVGAElement::SetDownload(const nsAString & aDownload, ErrorResult& rv)
|
|
|
|
{
|
|
|
|
rv = SetAttr(kNameSpaceID_None, nsGkAtoms::download, aDownload, true);
|
|
|
|
}
|
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
|
|
|
|
2009-11-23 21:48:52 +03:00
|
|
|
nsresult
|
2013-01-10 09:30:13 +04:00
|
|
|
SVGAElement::BindToTree(nsIDocument *aDocument, nsIContent *aParent,
|
|
|
|
nsIContent *aBindingParent,
|
|
|
|
bool aCompileEventHandlers)
|
2009-11-23 21:48:52 +03:00
|
|
|
{
|
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,
|
|
|
|
aCompileEventHandlers);
|
2009-11-23 21:48:52 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2013-01-10 09:30:13 +04:00
|
|
|
|
2014-10-03 16:32:26 +04:00
|
|
|
nsIDocument* doc = GetComposedDoc();
|
|
|
|
if (doc) {
|
|
|
|
doc->RegisterPendingLinkUpdate(this);
|
2011-11-14 07:24:41 +04:00
|
|
|
}
|
2009-11-23 21:48:52 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-10 09:30:13 +04:00
|
|
|
SVGAElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
2009-11-23 21:48:52 +03:00
|
|
|
{
|
|
|
|
// If this link is ever reinserted into a document, it might
|
|
|
|
// be under a different xml:base, so forget the cached state now.
|
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
|
|
|
}
|
|
|
|
|
2009-07-13 15:48:06 +04:00
|
|
|
already_AddRefed<nsIURI>
|
2013-01-10 09:30:13 +04:00
|
|
|
SVGAElement::GetHrefURI() const
|
2007-01-27 02:45:15 +03:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2016-09-28 05:21:50 +03:00
|
|
|
SVGAElement::IsSVGFocusable(bool* aIsFocusable, int32_t* aTabIndex)
|
2007-01-27 02:45:15 +03:00
|
|
|
{
|
2016-09-28 05:21:50 +03:00
|
|
|
if (nsSVGElement::IsSVGFocusable(aIsFocusable, aTabIndex)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// cannot focus links if there is no link handler
|
|
|
|
nsIDocument* doc = GetComposedDoc();
|
|
|
|
if (doc) {
|
|
|
|
nsIPresShell* presShell = doc->GetShell();
|
|
|
|
if (presShell) {
|
|
|
|
nsPresContext* presContext = presShell->GetPresContext();
|
|
|
|
if (presContext && !presContext->GetLinkHandler()) {
|
|
|
|
*aIsFocusable = false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
}
|
2016-09-28 05:21:50 +03:00
|
|
|
|
|
|
|
*aIsFocusable = false;
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aIsFocusable = false;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-09-28 05:21:50 +03:00
|
|
|
*aIsFocusable = true;
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2007-01-27 02:45:15 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2013-01-10 09:30:13 +04:00
|
|
|
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
|
|
|
|
|
|
|
static nsIContent::AttrValuesArray sTypeVals[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{ &nsGkAtoms::_empty, &nsGkAtoms::simple, nullptr };
|
2007-01-27 02:45:15 +03:00
|
|
|
|
|
|
|
static nsIContent::AttrValuesArray sShowVals[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{ &nsGkAtoms::_empty, &nsGkAtoms::_new, &nsGkAtoms::replace, nullptr };
|
2007-01-27 02:45:15 +03:00
|
|
|
|
|
|
|
static nsIContent::AttrValuesArray sActuateVals[] =
|
2012-07-30 18:20:58 +04: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, eCaseMatters) !=
|
|
|
|
nsIContent::ATTR_VALUE_NO_MATCH &&
|
|
|
|
FindAttrValueIn(kNameSpaceID_XLink, nsGkAtoms::show,
|
|
|
|
sShowVals, eCaseMatters) !=
|
|
|
|
nsIContent::ATTR_VALUE_NO_MATCH &&
|
|
|
|
FindAttrValueIn(kNameSpaceID_XLink, nsGkAtoms::actuate,
|
|
|
|
sActuateVals, eCaseMatters) !=
|
|
|
|
nsIContent::ATTR_VALUE_NO_MATCH) {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2007-04-03 12:59:11 +04:00
|
|
|
void
|
2013-01-10 09:30:13 +04:00
|
|
|
SVGAElement::GetLinkTarget(nsAString& aTarget)
|
2007-04-03 12:59:11 +04:00
|
|
|
{
|
2009-01-22 03:56:51 +03:00
|
|
|
mStringAttributes[TARGET].GetAnimValue(aTarget, this);
|
2007-04-03 12:59:11 +04:00
|
|
|
if (aTarget.IsEmpty()) {
|
2008-08-01 13:52:23 +04:00
|
|
|
|
|
|
|
static nsIContent::AttrValuesArray sShowVals[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{ &nsGkAtoms::_new, &nsGkAtoms::replace, nullptr };
|
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;
|
|
|
|
}
|
2011-10-18 14:53:36 +04:00
|
|
|
nsIDocument* ownerDoc = OwnerDoc();
|
2007-04-03 12:59:11 +04:00
|
|
|
if (ownerDoc) {
|
|
|
|
ownerDoc->GetBaseTarget(aTarget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-06-14 13:01:02 +04:00
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates
|
2013-01-10 09:30:13 +04:00
|
|
|
SVGAElement::IntrinsicState() const
|
2009-12-16 03:04:09 +03:00
|
|
|
{
|
2013-01-10 09:30:13 +04:00
|
|
|
return Link::LinkState() | SVGAElementBase::IntrinsicState();
|
2009-12-16 03:04:09 +03:00
|
|
|
}
|
|
|
|
|
2010-02-24 19:37:02 +03:00
|
|
|
nsresult
|
2017-10-03 01:05:19 +03:00
|
|
|
SVGAElement::SetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
|
|
|
nsAtom* aPrefix, const nsAString& aValue,
|
2017-10-10 00:33:38 +03:00
|
|
|
nsIPrincipal* aSubjectPrincipal,
|
2013-01-10 09:30:13 +04:00
|
|
|
bool aNotify)
|
2010-02-24 19:37:02 +03:00
|
|
|
{
|
2013-01-10 09:30:13 +04:00
|
|
|
nsresult rv = SVGAElementBase::SetAttr(aNameSpaceID, aName, aPrefix,
|
2017-10-10 00:33:38 +03:00
|
|
|
aValue, aSubjectPrincipal, aNotify);
|
2010-02-24 19:37:38 +03:00
|
|
|
|
|
|
|
// The ordering of the parent class's SetAttr call and Link::ResetLinkState
|
|
|
|
// is important here! The attribute is not set until SetAttr returns, and
|
|
|
|
// we will need the updated attribute value because notifying the document
|
|
|
|
// that content states have changed will call IntrinsicState, which will try
|
|
|
|
// to get updated information about the visitedness from Link.
|
2016-06-28 12:22:30 +03:00
|
|
|
if (aName == nsGkAtoms::href &&
|
|
|
|
(aNameSpaceID == kNameSpaceID_XLink ||
|
|
|
|
aNameSpaceID == kNameSpaceID_None)) {
|
2012-12-07 18:35:14 +04:00
|
|
|
Link::ResetLinkState(!!aNotify, true);
|
2010-02-24 19:37:02 +03:00
|
|
|
}
|
|
|
|
|
2010-02-24 19:37:38 +03:00
|
|
|
return rv;
|
2010-02-24 19:37:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2017-10-03 01:05:19 +03:00
|
|
|
SVGAElement::UnsetAttr(int32_t aNameSpaceID, nsAtom* aAttr,
|
2013-01-10 09:30:13 +04:00
|
|
|
bool aNotify)
|
2010-02-24 19:37:02 +03:00
|
|
|
{
|
2013-01-06 10:25:52 +04:00
|
|
|
nsresult rv = nsSVGElement::UnsetAttr(aNameSpaceID, aAttr, aNotify);
|
2010-03-03 23:55:35 +03:00
|
|
|
|
|
|
|
// The ordering of the parent class's UnsetAttr call and Link::ResetLinkState
|
|
|
|
// is important here! The attribute is not unset until UnsetAttr returns, and
|
|
|
|
// we will need the updated attribute value because notifying the document
|
|
|
|
// that content states have changed will call IntrinsicState, which will try
|
|
|
|
// to get updated information about the visitedness from Link.
|
2016-06-28 12:22:30 +03:00
|
|
|
if (aAttr == nsGkAtoms::href &&
|
|
|
|
(aNameSpaceID == kNameSpaceID_XLink ||
|
|
|
|
aNameSpaceID == kNameSpaceID_None)) {
|
2017-05-06 22:32:14 +03:00
|
|
|
Link::ResetLinkState(!!aNotify, Link::ElementHasHref());
|
2010-02-24 19:37:02 +03:00
|
|
|
}
|
|
|
|
|
2010-03-03 23:55:35 +03:00
|
|
|
return rv;
|
2010-02-24 19:37:02 +03:00
|
|
|
}
|
|
|
|
|
2008-06-14 13:01:02 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
|
|
|
nsSVGElement::StringAttributesInfo
|
2013-01-10 09:30:13 +04:00
|
|
|
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
|