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/. */
|
2005-08-26 06:49:52 +04:00
|
|
|
|
2013-01-06 18:14:43 +04:00
|
|
|
#include "mozilla/dom/SVGTextPathElement.h"
|
2018-02-02 16:21:33 +03:00
|
|
|
#include "mozilla/dom/SVGLengthBinding.h"
|
2018-02-18 18:53:13 +03:00
|
|
|
#include "mozilla/dom/SVGTextContentElementBinding.h"
|
2013-01-06 18:14:43 +04:00
|
|
|
#include "mozilla/dom/SVGTextPathElementBinding.h"
|
2018-12-21 11:58:14 +03:00
|
|
|
#include "SVGElement.h"
|
2006-12-26 20:47:52 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2012-07-27 18:03:27 +04:00
|
|
|
#include "nsError.h"
|
2005-08-26 06:49:52 +04:00
|
|
|
|
2018-12-21 14:43:29 +03:00
|
|
|
NS_IMPL_NS_NEW_SVG_ELEMENT(TextPath)
|
2013-01-06 18:14:43 +04:00
|
|
|
|
2022-05-09 23:41:17 +03:00
|
|
|
namespace mozilla::dom {
|
2013-01-06 18:14:43 +04:00
|
|
|
|
2018-06-26 00:20:54 +03:00
|
|
|
using namespace SVGTextContentElement_Binding;
|
|
|
|
using namespace SVGTextPathElement_Binding;
|
2018-02-18 18:53:13 +03:00
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
class DOMSVGAnimatedLength;
|
2013-03-12 02:05:58 +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
|
|
|
JSObject* SVGTextPathElement::WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return SVGTextPathElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-01-06 18:14:43 +04:00
|
|
|
}
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::LengthInfo SVGTextPathElement::sLengthInfo[2] = {
|
2013-07-24 04:01:35 +04:00
|
|
|
// from SVGTextContentElement:
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::textLength, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER,
|
|
|
|
SVGContentUtils::XY},
|
2013-07-24 04:01:35 +04:00
|
|
|
// from SVGTextPathElement:
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::startOffset, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER,
|
|
|
|
SVGContentUtils::X}};
|
2005-08-26 06:49:52 +04:00
|
|
|
|
2019-01-02 21:24:11 +03:00
|
|
|
SVGEnumMapping SVGTextPathElement::sMethodMap[] = {
|
2018-03-29 12:45:28 +03:00
|
|
|
{nsGkAtoms::align, TEXTPATH_METHODTYPE_ALIGN},
|
|
|
|
{nsGkAtoms::stretch, TEXTPATH_METHODTYPE_STRETCH},
|
2012-07-30 18:20:58 +04:00
|
|
|
{nullptr, 0}};
|
2007-08-28 03:11:14 +04:00
|
|
|
|
2019-01-02 21:24:11 +03:00
|
|
|
SVGEnumMapping SVGTextPathElement::sSpacingMap[] = {
|
2018-03-29 12:45:28 +03:00
|
|
|
{nsGkAtoms::_auto, TEXTPATH_SPACINGTYPE_AUTO},
|
|
|
|
{nsGkAtoms::exact, TEXTPATH_SPACINGTYPE_EXACT},
|
2012-07-30 18:20:58 +04:00
|
|
|
{nullptr, 0}};
|
2007-08-28 03:11:14 +04:00
|
|
|
|
2019-01-02 21:24:11 +03:00
|
|
|
SVGEnumMapping SVGTextPathElement::sSideMap[] = {
|
2018-03-29 12:45:28 +03:00
|
|
|
{nsGkAtoms::left, TEXTPATH_SIDETYPE_LEFT},
|
|
|
|
{nsGkAtoms::right, TEXTPATH_SIDETYPE_RIGHT},
|
2018-03-22 21:43:50 +03:00
|
|
|
{nullptr, 0}};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::EnumInfo SVGTextPathElement::sEnumInfo[4] = {
|
2013-07-24 04:01:35 +04:00
|
|
|
// from SVGTextContentElement:
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::lengthAdjust, sLengthAdjustMap, LENGTHADJUST_SPACING},
|
2013-07-24 04:01:35 +04:00
|
|
|
// from SVGTextPathElement:
|
2013-02-08 23:55:49 +04:00
|
|
|
{nsGkAtoms::method, sMethodMap, TEXTPATH_METHODTYPE_ALIGN},
|
|
|
|
{nsGkAtoms::spacing, sSpacingMap, TEXTPATH_SPACINGTYPE_EXACT},
|
2018-03-22 21:43:50 +03:00
|
|
|
{nsGkAtoms::side_, sSideMap, TEXTPATH_SIDETYPE_LEFT}};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::StringInfo SVGTextPathElement::sStringInfo[2] = {
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::href, kNameSpaceID_None, true},
|
|
|
|
{nsGkAtoms::href, kNameSpaceID_XLink, true}};
|
2008-06-14 13:01:02 +04:00
|
|
|
|
2005-08-26 06:49:52 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2018-09-21 23:45:49 +03:00
|
|
|
SVGTextPathElement::SVGTextPathElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
|
|
|
: SVGTextPathElementBase(std::move(aNodeInfo)) {}
|
2005-08-26 06:49:52 +04:00
|
|
|
|
2018-08-15 23:32:04 +03:00
|
|
|
void SVGTextPathElement::HrefAsString(nsAString& aHref) {
|
|
|
|
if (mStringAttributes[SVGTextPathElement::HREF].IsExplicitlySet()) {
|
|
|
|
mStringAttributes[SVGTextPathElement::HREF].GetAnimValue(aHref, this);
|
|
|
|
} else {
|
|
|
|
mStringAttributes[SVGTextPathElement::XLINK_HREF].GetAnimValue(aHref, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-26 06:49:52 +04:00
|
|
|
//----------------------------------------------------------------------
|
2018-05-30 05:58:49 +03:00
|
|
|
// nsINode methods
|
2005-08-26 06:49:52 +04:00
|
|
|
|
2013-01-06 18:14:43 +04:00
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGTextPathElement)
|
2005-08-26 06:49:52 +04:00
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedString> SVGTextPathElement::Href() {
|
2016-07-07 06:44:25 +03:00
|
|
|
return mStringAttributes[HREF].IsExplicitlySet()
|
|
|
|
? mStringAttributes[HREF].ToDOMAnimatedString(this)
|
|
|
|
: mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
|
2005-08-26 06:49:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-06 18:14:43 +04:00
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedLength> SVGTextPathElement::StartOffset() {
|
2013-01-06 18:14:43 +04:00
|
|
|
return mLengthAttributes[STARTOFFSET].ToDOMAnimatedLength(this);
|
2005-08-26 06:49:52 +04:00
|
|
|
}
|
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedEnumeration> SVGTextPathElement::Method() {
|
2013-01-06 18:14:43 +04:00
|
|
|
return mEnumAttributes[METHOD].ToDOMAnimatedEnum(this);
|
2005-08-26 06:49:52 +04:00
|
|
|
}
|
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedEnumeration> SVGTextPathElement::Spacing() {
|
2013-01-06 18:14:43 +04:00
|
|
|
return mEnumAttributes[SPACING].ToDOMAnimatedEnum(this);
|
2005-08-26 06:49:52 +04:00
|
|
|
}
|
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedEnumeration> SVGTextPathElement::Side() {
|
2018-03-22 21:43:50 +03:00
|
|
|
return mEnumAttributes[SIDE].ToDOMAnimatedEnum(this);
|
|
|
|
}
|
|
|
|
|
2005-08-26 06:49:52 +04:00
|
|
|
//----------------------------------------------------------------------
|
2005-11-02 03:41:51 +03:00
|
|
|
// nsIContent methods
|
2005-08-26 06:49:52 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2017-10-03 01:05:19 +03:00
|
|
|
SVGTextPathElement::IsAttributeMapped(const nsAtom* name) const {
|
2005-08-26 06:49:52 +04:00
|
|
|
static const MappedAttributeEntry* const map[] = {
|
2006-10-20 03:48:12 +04:00
|
|
|
sColorMap, sFillStrokeMap, sFontSpecificationMap, sGraphicsMap,
|
2007-03-20 13:43:33 +03:00
|
|
|
sTextContentElementsMap};
|
2013-01-06 18:14:43 +04:00
|
|
|
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(name, map) ||
|
2013-01-06 18:14:43 +04:00
|
|
|
SVGTextPathElementBase::IsAttributeMapped(name);
|
2005-08-26 06:49:52 +04:00
|
|
|
}
|
|
|
|
|
2013-01-03 00:24:07 +04:00
|
|
|
//----------------------------------------------------------------------
|
2018-12-21 11:58:14 +03:00
|
|
|
// SVGElement overrides
|
2013-01-03 00:24:07 +04:00
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::LengthAttributesInfo SVGTextPathElement::GetLengthInfo() {
|
2006-04-14 19:09:39 +04:00
|
|
|
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
2011-10-11 09:50:08 +04:00
|
|
|
ArrayLength(sLengthInfo));
|
2006-04-14 19:09:39 +04:00
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::EnumAttributesInfo SVGTextPathElement::GetEnumInfo() {
|
2007-08-28 03:11:14 +04:00
|
|
|
return EnumAttributesInfo(mEnumAttributes, sEnumInfo, ArrayLength(sEnumInfo));
|
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::StringAttributesInfo SVGTextPathElement::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-06 18:14:43 +04:00
|
|
|
|
2022-05-09 23:41:17 +03:00
|
|
|
} // namespace mozilla::dom
|