Back out 13acd3b74386:68ded29fc68e (bug 824327) for browser_bug329212.js failures

This commit is contained in:
Phil Ringnalda 2013-01-04 16:30:31 -08:00
parent 6f2696298b
commit f5e89a88e8
31 changed files with 890 additions and 1275 deletions

View File

@ -45,6 +45,7 @@ CPPSRCS = \
nsSVGClipPathElement.cpp \
nsSVGDataParser.cpp \
nsSVGDefsElement.cpp \
nsSVGDescElement.cpp \
nsSVGElement.cpp \
nsSVGElementFactory.cpp \
nsSVGEllipseElement.cpp \
@ -63,6 +64,7 @@ CPPSRCS = \
nsSVGLineElement.cpp \
nsSVGMarkerElement.cpp \
nsSVGMaskElement.cpp \
nsSVGMetadataElement.cpp \
nsSVGNumber2.cpp \
nsSVGNumberPair.cpp \
nsSVGPathDataParser.cpp \
@ -77,6 +79,8 @@ CPPSRCS = \
nsSVGRect.cpp \
nsSVGRectElement.cpp \
nsSVGSVGElement.cpp \
nsSVGStopElement.cpp \
nsSVGStyleElement.cpp \
nsSVGSwitchElement.cpp \
nsSVGSymbolElement.cpp \
nsSVGTSpanElement.cpp \
@ -84,6 +88,7 @@ CPPSRCS = \
nsSVGTextElement.cpp \
nsSVGTextPathElement.cpp \
nsSVGTextPositioningElement.cpp \
nsSVGTitleElement.cpp \
nsSVGUnknownElement.cpp \
nsSVGUseElement.cpp \
nsSVGViewBox.cpp \
@ -106,7 +111,6 @@ CPPSRCS = \
SVGPointList.cpp \
SVGPreserveAspectRatio.cpp \
SVGStringList.cpp \
SVGTitleElement.cpp \
SVGTransform.cpp \
SVGTransformList.cpp \
SVGTransformListParser.cpp \
@ -114,25 +118,21 @@ CPPSRCS = \
nsSVGAnimateTransformElement.cpp \
nsSVGAnimateMotionElement.cpp \
nsSVGAnimationElement.cpp \
nsSVGMpathElement.cpp \
nsSVGSetElement.cpp \
SVGAttrValueWrapper.cpp \
SVGContentUtils.cpp \
SVGDescElement.cpp \
SVGIntegerPairSMILType.cpp \
SVGLengthListSMILType.cpp \
SVGMetadataElement.cpp \
SVGMotionSMILType.cpp \
SVGMotionSMILAttr.cpp \
SVGMotionSMILAnimationFunction.cpp \
SVGMotionSMILPathUtils.cpp \
SVGMPathElement.cpp \
SVGNumberListSMILType.cpp \
SVGNumberPairSMILType.cpp \
SVGOrientSMILType.cpp \
SVGPathSegListSMILType.cpp \
SVGPointListSMILType.cpp \
SVGStopElement.cpp \
SVGStyleElement.cpp \
SVGTransformListSMILType.cpp \
SVGViewBoxSMILType.cpp \
$(NULL)
@ -154,12 +154,6 @@ EXPORTS_mozilla/dom = \
SVGAngle.h \
SVGAnimatedAngle.h \
SVGAnimatedBoolean.h \
SVGDescElement.h \
SVGMetadataElement.h \
SVGMPathElement.h \
SVGStopElement.h \
SVGStyleElement.h \
SVGTitleElement.h \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -1,50 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "mozilla/dom/SVGDescElement.h"
#include "mozilla/dom/SVGDescElementBinding.h"
DOMCI_NODE_DATA(SVGDescElement, mozilla::dom::SVGDescElement)
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Desc)
namespace mozilla {
namespace dom {
JSObject*
SVGDescElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return SVGDescElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF_INHERITED(SVGDescElement, SVGDescElementBase)
NS_IMPL_RELEASE_INHERITED(SVGDescElement, SVGDescElementBase)
NS_INTERFACE_TABLE_HEAD(SVGDescElement)
NS_NODE_INTERFACE_TABLE4(SVGDescElement, nsIDOMNode, nsIDOMElement,
nsIDOMSVGElement, nsIDOMSVGDescElement)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGDescElement)
NS_INTERFACE_MAP_END_INHERITING(SVGDescElementBase)
//----------------------------------------------------------------------
// Implementation
SVGDescElement::SVGDescElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: SVGDescElementBase(aNodeInfo)
{
SetIsDOMBinding();
}
//----------------------------------------------------------------------
// nsIDOMNode methods
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGDescElement)
} // namespace dom
} // namespace mozilla

View File

@ -1,52 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#ifndef mozilla_dom_SVGDescElement_h
#define mozilla_dom_SVGDescElement_h
#include "nsSVGElement.h"
#include "nsIDOMSVGDescElement.h"
nsresult NS_NewSVGDescElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
typedef nsSVGElement SVGDescElementBase;
namespace mozilla {
namespace dom {
class SVGDescElement MOZ_FINAL : public SVGDescElementBase,
public nsIDOMSVGDescElement
{
protected:
friend nsresult (::NS_NewSVGDescElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo));
SVGDescElement(already_AddRefed<nsINodeInfo> aNodeInfo);
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
public:
// interfaces:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGDESCELEMENT
// xxx I wish we could use virtual inheritance
NS_FORWARD_NSIDOMNODE_TO_NSINODE
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
NS_FORWARD_NSIDOMSVGELEMENT(SVGDescElementBase::)
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_SVGDescElement_h

View File

@ -1,59 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "mozilla/dom/SVGMetadataElement.h"
#include "mozilla/dom/SVGMetadataElementBinding.h"
DOMCI_NODE_DATA(SVGMetadataElement, mozilla::dom::SVGMetadataElement)
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Metadata)
namespace mozilla {
namespace dom {
JSObject*
SVGMetadataElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return SVGMetadataElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF_INHERITED(SVGMetadataElement, SVGMetadataElementBase)
NS_IMPL_RELEASE_INHERITED(SVGMetadataElement, SVGMetadataElementBase)
NS_INTERFACE_TABLE_HEAD(SVGMetadataElement)
NS_NODE_INTERFACE_TABLE4(SVGMetadataElement, nsIDOMNode, nsIDOMElement,
nsIDOMSVGElement, nsIDOMSVGMetadataElement)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGMetadataElement)
NS_INTERFACE_MAP_END_INHERITING(SVGMetadataElementBase)
//----------------------------------------------------------------------
// Implementation
SVGMetadataElement::SVGMetadataElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: SVGMetadataElementBase(aNodeInfo)
{
SetIsDOMBinding();
}
nsresult
SVGMetadataElement::Init()
{
return NS_OK;
}
//----------------------------------------------------------------------
// nsIDOMNode methods
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGMetadataElement)
} // namespace dom
} // namespace mozilla

View File

@ -1,52 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#ifndef mozilla_dom_SVGMetadataElement_h
#define mozilla_dom_SVGMetadataElement_h
#include "nsSVGElement.h"
#include "nsIDOMSVGMetadataElement.h"
nsresult NS_NewSVGMetadataElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
typedef nsSVGElement SVGMetadataElementBase;
namespace mozilla {
namespace dom {
class SVGMetadataElement MOZ_FINAL : public SVGMetadataElementBase,
public nsIDOMSVGMetadataElement
{
protected:
friend nsresult (::NS_NewSVGMetadataElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo));
SVGMetadataElement(already_AddRefed<nsINodeInfo> aNodeInfo);
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
nsresult Init();
public:
// interfaces:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGMETADATAELEMENT
// xxx I wish we could use virtual inheritance
NS_FORWARD_NSIDOMNODE_TO_NSINODE
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGElement::)
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_SVGMetadataElement_h

View File

@ -11,13 +11,11 @@
#include "SVGMotionSMILPathUtils.h"
#include "nsSVGPathDataParser.h"
#include "nsSVGPathElement.h" // for nsSVGPathList
#include "SVGMPathElement.h"
#include "nsSVGMpathElement.h"
#include "nsAttrValueInlines.h"
namespace mozilla {
using namespace dom;
SVGMotionSMILAnimationFunction::SVGMotionSMILAnimationFunction()
: mRotateType(eRotateType_Explicit),
mRotateAngle(0.0f),
@ -126,14 +124,14 @@ SVGMotionSMILAnimationFunction::GetCalcMode() const
* Returns the first <mpath> child of the given element
*/
static SVGMPathElement*
static nsSVGMpathElement*
GetFirstMpathChild(nsIContent* aElem)
{
for (nsIContent* child = aElem->GetFirstChild();
child;
child = child->GetNextSibling()) {
if (child->IsSVG(nsGkAtoms::mpath)) {
return static_cast<SVGMPathElement*>(child);
return static_cast<nsSVGMpathElement*>(child);
}
}
@ -212,7 +210,7 @@ SVGMotionSMILAnimationFunction::
void
SVGMotionSMILAnimationFunction::
RebuildPathAndVerticesFromMpathElem(SVGMPathElement* aMpathElem)
RebuildPathAndVerticesFromMpathElem(nsSVGMpathElement* aMpathElem)
{
mPathSourceType = ePathSourceType_Mpath;
@ -272,7 +270,7 @@ SVGMotionSMILAnimationFunction::
// Do we have a mpath child? if so, it trumps everything. Otherwise, we look
// through our list of path-defining attributes, in order of priority.
SVGMPathElement* firstMpathChild =
nsSVGMpathElement* firstMpathChild =
GetFirstMpathChild(&mAnimationElement->AsElement());
if (firstMpathChild) {

View File

@ -17,13 +17,10 @@ class nsIAtom;
class nsIContent;
class nsISMILAttr;
class nsSMILValue;
class nsSVGMpathElement;
namespace mozilla {
namespace dom {
class SVGMPathElement;
}
//----------------------------------------------------------------------
// SVGMotionSMILAnimationFunction
//
@ -75,7 +72,7 @@ protected:
// Helpers for GetValues
void MarkStaleIfAttributeAffectsPath(nsIAtom* aAttribute);
void RebuildPathAndVertices(const nsIContent* aContextElem);
void RebuildPathAndVerticesFromMpathElem(dom::SVGMPathElement* aMpathElem);
void RebuildPathAndVerticesFromMpathElem(nsSVGMpathElement* aMpathElem);
void RebuildPathAndVerticesFromPathAttr();
void RebuildPathAndVerticesFromBasicAttrs(const nsIContent* aContextElem);
bool GenerateValuesForPathAndPoints(gfxFlattenedPath* aPath,

View File

@ -1,93 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "mozilla/dom/SVGStopElement.h"
#include "mozilla/dom/SVGStopElementBinding.h"
DOMCI_NODE_DATA(SVGStopElement, mozilla::dom::SVGStopElement)
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Stop)
namespace mozilla {
namespace dom {
JSObject*
SVGStopElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return SVGStopElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
nsSVGElement::NumberInfo SVGStopElement::sNumberInfo =
{ &nsGkAtoms::offset, 0, true };
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF_INHERITED(SVGStopElement, SVGStopElementBase)
NS_IMPL_RELEASE_INHERITED(SVGStopElement, SVGStopElementBase)
NS_INTERFACE_TABLE_HEAD(SVGStopElement)
NS_NODE_INTERFACE_TABLE4(SVGStopElement, nsIDOMNode, nsIDOMElement,
nsIDOMSVGElement, nsIDOMSVGStopElement)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStopElement)
NS_INTERFACE_MAP_END_INHERITING(SVGStopElementBase)
//----------------------------------------------------------------------
// Implementation
SVGStopElement::SVGStopElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: SVGStopElementBase(aNodeInfo)
{
SetIsDOMBinding();
}
//----------------------------------------------------------------------
// nsIDOMNode methods
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGStopElement)
//----------------------------------------------------------------------
// nsIDOMSVGStopElement methods
/* readonly attribute nsIDOMSVGAnimatedNumber offset; */
NS_IMETHODIMP SVGStopElement::GetOffset(nsIDOMSVGAnimatedNumber * *aOffset)
{
return mOffset.ToDOMAnimatedNumber(aOffset,this);
}
already_AddRefed<nsIDOMSVGAnimatedNumber>
SVGStopElement::Offset()
{
nsCOMPtr<nsIDOMSVGAnimatedNumber> offset;
mOffset.ToDOMAnimatedNumber(getter_AddRefs(offset), this);
return offset.forget();
}
//----------------------------------------------------------------------
// sSVGElement methods
nsSVGElement::NumberAttributesInfo
SVGStopElement::GetNumberInfo()
{
return NumberAttributesInfo(&mOffset, &sNumberInfo, 1);
}
//----------------------------------------------------------------------
// nsIContent methods
NS_IMETHODIMP_(bool)
SVGStopElement::IsAttributeMapped(const nsIAtom* name) const
{
static const MappedAttributeEntry* const map[] = {
sGradientStopMap
};
return FindAttributeDependence(name, map) ||
SVGStopElementBase::IsAttributeMapped(name);
}
} // namespace dom
} // namespace mozilla

View File

@ -1,65 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#ifndef mozilla_dom_SVGStopElement_h
#define mozilla_dom_SVGStopElement_h
#include "nsSVGElement.h"
#include "nsSVGNumber2.h"
#include "nsIDOMSVGStopElement.h"
nsresult NS_NewSVGStopElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
typedef nsSVGElement SVGStopElementBase;
namespace mozilla {
namespace dom {
class SVGStopElement MOZ_FINAL : public SVGStopElementBase,
public nsIDOMSVGStopElement
{
protected:
friend nsresult (::NS_NewSVGStopElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo));
SVGStopElement(already_AddRefed<nsINodeInfo> aNodeInfo);
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
public:
// interfaces:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGSTOPELEMENT
// xxx If xpcom allowed virtual inheritance we wouldn't need to
// forward here :-(
NS_FORWARD_NSIDOMNODE_TO_NSINODE
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
NS_FORWARD_NSIDOMSVGELEMENT(SVGStopElementBase::)
// nsIContent interface
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
// WebIDL
already_AddRefed<nsIDOMSVGAnimatedNumber> Offset();
protected:
virtual NumberAttributesInfo GetNumberInfo();
// nsIDOMSVGStopElement properties:
nsSVGNumber2 mOffset;
static NumberInfo sNumberInfo;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_SVGStopElement_h

View File

@ -1,307 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "mozilla/dom/SVGStyleElement.h"
#include "nsContentUtils.h"
#include "nsStubMutationObserver.h"
#include "mozilla/dom/SVGStyleElementBinding.h"
DOMCI_NODE_DATA(SVGStyleElement, mozilla::dom::SVGStyleElement)
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Style)
namespace mozilla {
namespace dom {
JSObject*
SVGStyleElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return SVGStyleElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF_INHERITED(SVGStyleElement, SVGStyleElementBase)
NS_IMPL_RELEASE_INHERITED(SVGStyleElement, SVGStyleElementBase)
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(SVGStyleElement)
NS_NODE_INTERFACE_TABLE7(SVGStyleElement, nsIDOMNode, nsIDOMElement,
nsIDOMSVGElement, nsIDOMSVGStyleElement,
nsIDOMLinkStyle, nsIStyleSheetLinkingElement,
nsIMutationObserver)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStyleElement)
NS_INTERFACE_MAP_END_INHERITING(SVGStyleElementBase)
NS_IMPL_CYCLE_COLLECTION_CLASS(SVGStyleElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SVGStyleElement,
SVGStyleElementBase)
tmp->nsStyleLinkElement::Traverse(cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SVGStyleElement,
SVGStyleElementBase)
tmp->nsStyleLinkElement::Unlink();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
//----------------------------------------------------------------------
// Implementation
SVGStyleElement::SVGStyleElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: SVGStyleElementBase(aNodeInfo)
{
SetIsDOMBinding();
AddMutationObserver(this);
}
//----------------------------------------------------------------------
// nsIDOMNode methods
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGStyleElement)
//----------------------------------------------------------------------
// nsIContent methods
nsresult
SVGStyleElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers)
{
nsresult rv = SVGStyleElementBase::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
void (SVGStyleElement::*update)() = &SVGStyleElement::UpdateStyleSheetInternal;
nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update));
return rv;
}
void
SVGStyleElement::UnbindFromTree(bool aDeep, bool aNullParent)
{
nsCOMPtr<nsIDocument> oldDoc = GetCurrentDoc();
SVGStyleElementBase::UnbindFromTree(aDeep, aNullParent);
UpdateStyleSheetInternal(oldDoc);
}
nsresult
SVGStyleElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
bool aNotify)
{
nsresult rv = SVGStyleElementBase::SetAttr(aNameSpaceID, aName, aPrefix,
aValue, aNotify);
if (NS_SUCCEEDED(rv)) {
UpdateStyleSheetInternal(nullptr,
aNameSpaceID == kNameSpaceID_None &&
(aName == nsGkAtoms::title ||
aName == nsGkAtoms::media ||
aName == nsGkAtoms::type));
}
return rv;
}
nsresult
SVGStyleElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
bool aNotify)
{
nsresult rv = SVGStyleElementBase::UnsetAttr(aNameSpaceID, aAttribute,
aNotify);
if (NS_SUCCEEDED(rv)) {
UpdateStyleSheetInternal(nullptr,
aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::title ||
aAttribute == nsGkAtoms::media ||
aAttribute == nsGkAtoms::type));
}
return rv;
}
bool
SVGStyleElement::ParseAttribute(int32_t aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aNamespaceID == kNameSpaceID_None &&
aAttribute == nsGkAtoms::crossorigin) {
ParseCORSValue(aValue, aResult);
return true;
}
return SVGStyleElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
//----------------------------------------------------------------------
// nsIMutationObserver methods
void
SVGStyleElement::CharacterDataChanged(nsIDocument* aDocument,
nsIContent* aContent,
CharacterDataChangeInfo* aInfo)
{
ContentChanged(aContent);
}
void
SVGStyleElement::ContentAppended(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aFirstNewContent,
int32_t aNewIndexInContainer)
{
ContentChanged(aContainer);
}
void
SVGStyleElement::ContentInserted(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aChild,
int32_t aIndexInContainer)
{
ContentChanged(aChild);
}
void
SVGStyleElement::ContentRemoved(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aChild,
int32_t aIndexInContainer,
nsIContent* aPreviousSibling)
{
ContentChanged(aChild);
}
void
SVGStyleElement::ContentChanged(nsIContent* aContent)
{
if (nsContentUtils::IsInSameAnonymousTree(this, aContent)) {
UpdateStyleSheetInternal(nullptr);
}
}
//----------------------------------------------------------------------
// nsIDOMSVGStyleElement methods
/* attribute DOMString xmlspace; */
NS_IMETHODIMP SVGStyleElement::GetXmlspace(nsAString & aXmlspace)
{
GetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace);
return NS_OK;
}
NS_IMETHODIMP SVGStyleElement::SetXmlspace(const nsAString & aXmlspace)
{
return SetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace, true);
}
void
SVGStyleElement::SetXmlspace(const nsAString & aXmlspace, ErrorResult& rv)
{
rv = SetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace, true);
}
/* attribute DOMString type; */
NS_IMETHODIMP SVGStyleElement::GetType(nsAString & aType)
{
GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);
return NS_OK;
}
NS_IMETHODIMP SVGStyleElement::SetType(const nsAString & aType)
{
return SetAttr(kNameSpaceID_None, nsGkAtoms::type, aType, true);
}
void
SVGStyleElement::SetType(const nsAString & aType, ErrorResult& rv)
{
rv = SetAttr(kNameSpaceID_None, nsGkAtoms::type, aType, true);
}
/* attribute DOMString media; */
NS_IMETHODIMP SVGStyleElement::GetMedia(nsAString & aMedia)
{
GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia);
return NS_OK;
}
NS_IMETHODIMP SVGStyleElement::SetMedia(const nsAString & aMedia)
{
return SetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia, true);
}
void
SVGStyleElement::SetMedia(const nsAString & aMedia, ErrorResult& rv)
{
rv = SetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia, true);
}
/* attribute DOMString title; */
NS_IMETHODIMP SVGStyleElement::GetTitle(nsAString & aTitle)
{
GetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle);
return NS_OK;
}
NS_IMETHODIMP SVGStyleElement::SetTitle(const nsAString & aTitle)
{
return SetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle, true);
}
void
SVGStyleElement::SetTitle(const nsAString & aTitle, ErrorResult& rv)
{
rv = SetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle, true);
}
//----------------------------------------------------------------------
// nsStyleLinkElement methods
already_AddRefed<nsIURI>
SVGStyleElement::GetStyleSheetURL(bool* aIsInline)
{
*aIsInline = true;
return nullptr;
}
void
SVGStyleElement::GetStyleSheetInfo(nsAString& aTitle,
nsAString& aType,
nsAString& aMedia,
bool* aIsAlternate)
{
*aIsAlternate = false;
nsAutoString title;
GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
title.CompressWhitespace();
aTitle.Assign(title);
GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia);
// The SVG spec is formulated in terms of the CSS2 spec,
// which specifies that media queries are case insensitive.
nsContentUtils::ASCIIToLower(aMedia);
GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);
if (aType.IsEmpty()) {
aType.AssignLiteral("text/css");
}
return;
}
CORSMode
SVGStyleElement::GetCORSMode() const
{
return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin));
}
} // namespace dom
} // namespace mozilla

View File

@ -1,114 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#ifndef mozilla_dom_SVGStyleElement_h
#define mozilla_dom_SVGStyleElement_h
#include "nsSVGElement.h"
#include "nsIDOMSVGStyleElement.h"
#include "nsStyleLinkElement.h"
#include "nsStubMutationObserver.h"
nsresult NS_NewSVGStyleElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
typedef nsSVGElement SVGStyleElementBase;
namespace mozilla {
namespace dom {
class SVGStyleElement MOZ_FINAL : public SVGStyleElementBase,
public nsIDOMSVGStyleElement,
public nsStyleLinkElement,
public nsStubMutationObserver
{
protected:
friend nsresult (::NS_NewSVGStyleElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo));
SVGStyleElement(already_AddRefed<nsINodeInfo> aNodeInfo);
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGSTYLEELEMENT
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGStyleElement,
SVGStyleElementBase)
// xxx I wish we could use virtual inheritance
NS_FORWARD_NSIDOMNODE_TO_NSINODE
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
NS_FORWARD_NSIDOMSVGELEMENT(SVGStyleElementBase::)
// nsIContent
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers);
virtual void UnbindFromTree(bool aDeep = true,
bool aNullParent = true);
nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
const nsAString& aValue, bool aNotify)
{
return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify);
}
virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
bool aNotify);
virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
bool aNotify);
virtual bool ParseAttribute(int32_t aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
// nsIMutationObserver
NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
// WebIDL
void SetXmlspace(const nsAString & aXmlspace, ErrorResult& rv);
void SetType(const nsAString & aType, ErrorResult& rv);
void SetMedia(const nsAString & aMedia, ErrorResult& rv);
void SetTitle(const nsAString & aTitle, ErrorResult& rv);
protected:
// Dummy init method to make the NS_IMPL_NS_NEW_SVG_ELEMENT and
// NS_IMPL_ELEMENT_CLONE_WITH_INIT usable with this class. This should be
// completely optimized away.
inline nsresult Init()
{
return NS_OK;
}
// nsStyleLinkElement overrides
already_AddRefed<nsIURI> GetStyleSheetURL(bool* aIsInline);
void GetStyleSheetInfo(nsAString& aTitle,
nsAString& aType,
nsAString& aMedia,
bool* aIsAlternate);
virtual CORSMode GetCORSMode() const;
/**
* Common method to call from the various mutation observer methods.
* aContent is a content node that's either the one that changed or its
* parent; we should only respond to the change if aContent is non-anonymous.
*/
void ContentChanged(nsIContent* aContent);
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_SVGStyleElement_h

View File

@ -1,131 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "mozilla/dom/SVGTitleElement.h"
#include "mozilla/dom/SVGTitleElementBinding.h"
DOMCI_NODE_DATA(SVGTitleElement, mozilla::dom::SVGTitleElement)
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Title)
namespace mozilla {
namespace dom {
JSObject*
SVGTitleElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return SVGTitleElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF_INHERITED(SVGTitleElement, SVGTitleElementBase)
NS_IMPL_RELEASE_INHERITED(SVGTitleElement, SVGTitleElementBase)
NS_INTERFACE_TABLE_HEAD(SVGTitleElement)
NS_NODE_INTERFACE_TABLE4(SVGTitleElement, nsIDOMNode, nsIDOMElement,
nsIDOMSVGElement,
nsIMutationObserver)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTitleElement)
NS_INTERFACE_MAP_END_INHERITING(SVGTitleElementBase)
//----------------------------------------------------------------------
// Implementation
SVGTitleElement::SVGTitleElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: SVGTitleElementBase(aNodeInfo)
{
SetIsDOMBinding();
AddMutationObserver(this);
}
void
SVGTitleElement::CharacterDataChanged(nsIDocument *aDocument,
nsIContent *aContent,
CharacterDataChangeInfo *aInfo)
{
SendTitleChangeEvent(false);
}
void
SVGTitleElement::ContentAppended(nsIDocument *aDocument,
nsIContent *aContainer,
nsIContent *aFirstNewContent,
int32_t aNewIndexInContainer)
{
SendTitleChangeEvent(false);
}
void
SVGTitleElement::ContentInserted(nsIDocument *aDocument,
nsIContent *aContainer,
nsIContent *aChild,
int32_t aIndexInContainer)
{
SendTitleChangeEvent(false);
}
void
SVGTitleElement::ContentRemoved(nsIDocument *aDocument,
nsIContent *aContainer,
nsIContent *aChild,
int32_t aIndexInContainer,
nsIContent *aPreviousSibling)
{
SendTitleChangeEvent(false);
}
nsresult
SVGTitleElement::BindToTree(nsIDocument *aDocument,
nsIContent *aParent,
nsIContent *aBindingParent,
bool aCompileEventHandlers)
{
// Let this fall through.
nsresult rv = SVGTitleElementBase::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
SendTitleChangeEvent(true);
return NS_OK;
}
void
SVGTitleElement::UnbindFromTree(bool aDeep, bool aNullParent)
{
SendTitleChangeEvent(false);
// Let this fall through.
SVGTitleElementBase::UnbindFromTree(aDeep, aNullParent);
}
void
SVGTitleElement::DoneAddingChildren(bool aHaveNotified)
{
if (!aHaveNotified) {
SendTitleChangeEvent(false);
}
}
void
SVGTitleElement::SendTitleChangeEvent(bool aBound)
{
nsIDocument* doc = GetCurrentDoc();
if (doc) {
doc->NotifyPossibleTitleChange(aBound);
}
}
//----------------------------------------------------------------------
// nsIDOMNode methods
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGTitleElement)
} // namespace dom
} // namespace mozilla

View File

@ -1,69 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#ifndef mozilla_dom_SVGTitleElement_h
#define mozilla_dom_SVGTitleElement_h
#include "nsSVGElement.h"
#include "nsIDOMSVGTitleElement.h"
#include "nsStubMutationObserver.h"
typedef nsSVGElement SVGTitleElementBase;
nsresult NS_NewSVGTitleElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
namespace mozilla {
namespace dom {
class SVGTitleElement MOZ_FINAL : public SVGTitleElementBase,
public nsStubMutationObserver,
public nsIDOMSVGTitleElement
{
protected:
friend nsresult (::NS_NewSVGTitleElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo));
SVGTitleElement(already_AddRefed<nsINodeInfo> aNodeInfo);
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
public:
// interfaces:
NS_DECL_ISUPPORTS_INHERITED
// xxx I wish we could use virtual inheritance
NS_FORWARD_NSIDOMNODE_TO_NSINODE
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
NS_FORWARD_NSIDOMSVGELEMENT(SVGTitleElementBase::)
// nsIMutationObserver
NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent,
nsIContent *aBindingParent,
bool aCompileEventHandlers);
virtual void UnbindFromTree(bool aDeep = true,
bool aNullParent = true);
virtual void DoneAddingChildren(bool aHaveNotified);
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
private:
void SendTitleChangeEvent(bool aBound);
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_SVGTitleElement_h

View File

@ -0,0 +1,76 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "nsSVGElement.h"
#include "nsIDOMSVGDescElement.h"
typedef nsSVGElement nsSVGDescElementBase;
class nsSVGDescElement : public nsSVGDescElementBase,
public nsIDOMSVGDescElement
{
protected:
friend nsresult NS_NewSVGDescElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
nsSVGDescElement(already_AddRefed<nsINodeInfo> aNodeInfo);
nsresult Init();
public:
// interfaces:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGDESCELEMENT
// xxx I wish we could use virtual inheritance
NS_FORWARD_NSIDOMNODE_TO_NSINODE
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGDescElementBase::)
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
};
NS_IMPL_NS_NEW_SVG_ELEMENT(Desc)
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF_INHERITED(nsSVGDescElement, nsSVGDescElementBase)
NS_IMPL_RELEASE_INHERITED(nsSVGDescElement, nsSVGDescElementBase)
DOMCI_NODE_DATA(SVGDescElement, nsSVGDescElement)
NS_INTERFACE_TABLE_HEAD(nsSVGDescElement)
NS_NODE_INTERFACE_TABLE4(nsSVGDescElement, nsIDOMNode, nsIDOMElement,
nsIDOMSVGElement, nsIDOMSVGDescElement)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGDescElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGDescElementBase)
//----------------------------------------------------------------------
// Implementation
nsSVGDescElement::nsSVGDescElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsSVGDescElementBase(aNodeInfo)
{
}
nsresult
nsSVGDescElement::Init()
{
return nsSVGDescElementBase::Init();
}
//----------------------------------------------------------------------
// nsIDOMNode methods
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGDescElement)

View File

@ -640,25 +640,6 @@ NS_NewSVG##_elementName##Element(nsIContent **aResult, \
return rv; \
}
#define NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(_elementName) \
nsresult \
NS_NewSVG##_elementName##Element(nsIContent **aResult, \
already_AddRefed<nsINodeInfo> aNodeInfo) \
{ \
nsRefPtr<mozilla::dom::SVG##_elementName##Element> it = \
new mozilla::dom::SVG##_elementName##Element(aNodeInfo); \
\
nsresult rv = it->Init(); \
\
if (NS_FAILED(rv)) { \
return rv; \
} \
\
it.forget(aResult); \
\
return rv; \
}
#define NS_IMPL_NS_NEW_SVG_ELEMENT_CHECK_PARSER(_elementName) \
nsresult \
NS_NewSVG##_elementName##Element(nsIContent **aResult, \

View File

@ -201,7 +201,7 @@ nsresult
NS_NewSVGAnimateMotionElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
nsresult
NS_NewSVGMPathElement(nsIContent **aResult,
NS_NewSVGMpathElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
nsresult
NS_NewSVGSetElement(nsIContent **aResult,
@ -348,7 +348,7 @@ NS_NewSVGElement(nsIContent** aResult, already_AddRefed<nsINodeInfo> aNodeInfo,
if (name == nsGkAtoms::animateMotion)
return NS_NewSVGAnimateMotionElement(aResult, aNodeInfo);
if (name == nsGkAtoms::mpath)
return NS_NewSVGMPathElement(aResult, aNodeInfo);
return NS_NewSVGMpathElement(aResult, aNodeInfo);
if (name == nsGkAtoms::set)
return NS_NewSVGSetElement(aResult, aNodeInfo);
}

View File

@ -0,0 +1,75 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "nsSVGElement.h"
#include "nsIDOMSVGMetadataElement.h"
typedef nsSVGElement nsSVGMetadataElementBase;
class nsSVGMetadataElement : public nsSVGMetadataElementBase,
public nsIDOMSVGMetadataElement
{
protected:
friend nsresult NS_NewSVGMetadataElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
nsSVGMetadataElement(already_AddRefed<nsINodeInfo> aNodeInfo);
nsresult Init();
public:
// interfaces:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGMETADATAELEMENT
// xxx I wish we could use virtual inheritance
NS_FORWARD_NSIDOMNODE_TO_NSINODE
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGElement::)
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
};
NS_IMPL_NS_NEW_SVG_ELEMENT(Metadata)
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF_INHERITED(nsSVGMetadataElement, nsSVGMetadataElementBase)
NS_IMPL_RELEASE_INHERITED(nsSVGMetadataElement, nsSVGMetadataElementBase)
DOMCI_NODE_DATA(SVGMetadataElement, nsSVGMetadataElement)
NS_INTERFACE_TABLE_HEAD(nsSVGMetadataElement)
NS_NODE_INTERFACE_TABLE4(nsSVGMetadataElement, nsIDOMNode, nsIDOMElement,
nsIDOMSVGElement, nsIDOMSVGMetadataElement)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGMetadataElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGMetadataElementBase)
//----------------------------------------------------------------------
// Implementation
nsSVGMetadataElement::nsSVGMetadataElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsSVGMetadataElementBase(aNodeInfo)
{
}
nsresult
nsSVGMetadataElement::Init()
{
return NS_OK;
}
//----------------------------------------------------------------------
// nsIDOMNode methods
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGMetadataElement)

View File

@ -5,56 +5,49 @@
#include "mozilla/Util.h"
#include "mozilla/dom/SVGMPathElement.h"
#include "nsSVGMpathElement.h"
#include "nsAutoPtr.h"
#include "nsDebug.h"
#include "nsSVGPathElement.h"
#include "nsSVGAnimateMotionElement.h"
#include "nsContentUtils.h"
#include "mozilla/dom/SVGMPathElementBinding.h"
DOMCI_NODE_DATA(SVGMpathElement, mozilla::dom::SVGMPathElement)
using namespace mozilla;
using namespace mozilla::dom;
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(MPath)
namespace mozilla {
namespace dom {
JSObject*
SVGMPathElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return SVGMPathElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
nsSVGElement::StringInfo SVGMPathElement::sStringInfo[1] =
nsSVGElement::StringInfo nsSVGMpathElement::sStringInfo[1] =
{
{ &nsGkAtoms::href, kNameSpaceID_XLink, false }
};
NS_IMPL_NS_NEW_SVG_ELEMENT(Mpath)
// Cycle collection magic -- based on nsSVGUseElement
NS_IMPL_CYCLE_COLLECTION_CLASS(SVGMPathElement)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SVGMPathElement,
SVGMPathElementBase)
NS_IMPL_CYCLE_COLLECTION_CLASS(nsSVGMpathElement)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsSVGMpathElement,
nsSVGMpathElementBase)
tmp->UnlinkHrefTarget(false);
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SVGMPathElement,
SVGMPathElementBase)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsSVGMpathElement,
nsSVGMpathElementBase)
tmp->mHrefTarget.Traverse(&cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF_INHERITED(SVGMPathElement,SVGMPathElementBase)
NS_IMPL_RELEASE_INHERITED(SVGMPathElement,SVGMPathElementBase)
NS_IMPL_ADDREF_INHERITED(nsSVGMpathElement,nsSVGMpathElementBase)
NS_IMPL_RELEASE_INHERITED(nsSVGMpathElement,nsSVGMpathElementBase)
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(SVGMPathElement)
NS_NODE_INTERFACE_TABLE6(SVGMPathElement, nsIDOMNode, nsIDOMElement,
DOMCI_NODE_DATA(SVGMpathElement, nsSVGMpathElement)
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsSVGMpathElement)
NS_NODE_INTERFACE_TABLE6(nsSVGMpathElement, nsIDOMNode, nsIDOMElement,
nsIDOMSVGElement, nsIDOMSVGURIReference,
nsIDOMSVGMpathElement, nsIMutationObserver)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGMpathElement)
NS_INTERFACE_MAP_END_INHERITING(SVGMPathElementBase)
NS_INTERFACE_MAP_END_INHERITING(nsSVGMpathElementBase)
// Constructor
#ifdef _MSC_VER
@ -64,17 +57,16 @@ NS_INTERFACE_MAP_END_INHERITING(SVGMPathElementBase)
#pragma warning(push)
#pragma warning(disable:4355)
#endif
SVGMPathElement::SVGMPathElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: SVGMPathElementBase(aNodeInfo),
nsSVGMpathElement::nsSVGMpathElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsSVGMpathElementBase(aNodeInfo),
mHrefTarget(this)
#ifdef _MSC_VER
#pragma warning(pop)
#endif
{
SetIsDOMBinding();
}
SVGMPathElement::~SVGMPathElement()
nsSVGMpathElement::~nsSVGMpathElement()
{
UnlinkHrefTarget(false);
}
@ -82,42 +74,33 @@ SVGMPathElement::~SVGMPathElement()
//----------------------------------------------------------------------
// nsIDOMNode methods
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGMPathElement)
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGMpathElement)
//----------------------------------------------------------------------
// nsIDOMSVGURIReference methods
/* readonly attribute nsIDOMSVGAnimatedString href; */
already_AddRefed<nsIDOMSVGAnimatedString>
SVGMPathElement::Href()
{
nsCOMPtr<nsIDOMSVGAnimatedString> href;
mStringAttributes[HREF].ToDOMAnimatedString(getter_AddRefs(href), this);
return href.forget();
}
NS_IMETHODIMP
SVGMPathElement::GetHref(nsIDOMSVGAnimatedString** aHref)
nsSVGMpathElement::GetHref(nsIDOMSVGAnimatedString** aHref)
{
*aHref = Href().get();
return NS_OK;
return mStringAttributes[HREF].ToDOMAnimatedString(aHref, this);
}
//----------------------------------------------------------------------
// nsIContent methods
nsresult
SVGMPathElement::BindToTree(nsIDocument* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers)
nsSVGMpathElement::BindToTree(nsIDocument* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers)
{
NS_ABORT_IF_FALSE(!mHrefTarget.get(),
"Shouldn't have href-target yet "
"(or it should've been cleared)");
nsresult rv = SVGMPathElementBase::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
nsresult rv = nsSVGMpathElementBase::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv,rv);
if (aDocument) {
@ -132,20 +115,20 @@ SVGMPathElement::BindToTree(nsIDocument* aDocument,
}
void
SVGMPathElement::UnbindFromTree(bool aDeep, bool aNullParent)
nsSVGMpathElement::UnbindFromTree(bool aDeep, bool aNullParent)
{
UnlinkHrefTarget(true);
SVGMPathElementBase::UnbindFromTree(aDeep, aNullParent);
nsSVGMpathElementBase::UnbindFromTree(aDeep, aNullParent);
}
bool
SVGMPathElement::ParseAttribute(int32_t aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
nsSVGMpathElement::ParseAttribute(int32_t aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
bool returnVal =
SVGMPathElementBase::ParseAttribute(aNamespaceID, aAttribute,
nsSVGMpathElementBase::ParseAttribute(aNamespaceID, aAttribute,
aValue, aResult);
if (aNamespaceID == kNameSpaceID_XLink &&
aAttribute == nsGkAtoms::href &&
@ -158,11 +141,11 @@ SVGMPathElement::ParseAttribute(int32_t aNamespaceID,
}
nsresult
SVGMPathElement::UnsetAttr(int32_t aNamespaceID,
nsIAtom* aAttribute, bool aNotify)
nsSVGMpathElement::UnsetAttr(int32_t aNamespaceID,
nsIAtom* aAttribute, bool aNotify)
{
nsresult rv = SVGMPathElementBase::UnsetAttr(aNamespaceID, aAttribute,
aNotify);
nsresult rv = nsSVGMpathElementBase::UnsetAttr(aNamespaceID, aAttribute,
aNotify);
NS_ENSURE_SUCCESS(rv, rv);
if (aNamespaceID == kNameSpaceID_XLink &&
@ -177,7 +160,7 @@ SVGMPathElement::UnsetAttr(int32_t aNamespaceID,
// nsSVGElement methods
nsSVGElement::StringAttributesInfo
SVGMPathElement::GetStringInfo()
nsSVGMpathElement::GetStringInfo()
{
return StringAttributesInfo(mStringAttributes, sStringInfo,
ArrayLength(sStringInfo));
@ -187,11 +170,11 @@ SVGMPathElement::GetStringInfo()
// nsIMutationObserver methods
void
SVGMPathElement::AttributeChanged(nsIDocument* aDocument,
Element* aElement,
int32_t aNameSpaceID,
nsIAtom* aAttribute,
int32_t aModType)
nsSVGMpathElement::AttributeChanged(nsIDocument* aDocument,
Element* aElement,
int32_t aNameSpaceID,
nsIAtom* aAttribute,
int32_t aModType)
{
if (aNameSpaceID == kNameSpaceID_None) {
if (aAttribute == nsGkAtoms::d) {
@ -204,7 +187,7 @@ SVGMPathElement::AttributeChanged(nsIDocument* aDocument,
// Public helper methods
nsSVGPathElement*
SVGMPathElement::GetReferencedPath()
nsSVGMpathElement::GetReferencedPath()
{
if (!HasAttr(kNameSpaceID_XLink, nsGkAtoms::href)) {
NS_ABORT_IF_FALSE(!mHrefTarget.get(),
@ -224,8 +207,8 @@ SVGMPathElement::GetReferencedPath()
// Protected helper methods
void
SVGMPathElement::UpdateHrefTarget(nsIContent* aParent,
const nsAString& aHrefStr)
nsSVGMpathElement::UpdateHrefTarget(nsIContent* aParent,
const nsAString& aHrefStr)
{
nsCOMPtr<nsIURI> targetURI;
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
@ -257,7 +240,7 @@ SVGMPathElement::UpdateHrefTarget(nsIContent* aParent,
}
void
SVGMPathElement::UnlinkHrefTarget(bool aNotifyParent)
nsSVGMpathElement::UnlinkHrefTarget(bool aNotifyParent)
{
// Stop observing old target (if any)
if (mHrefTarget.get()) {
@ -271,7 +254,7 @@ SVGMPathElement::UnlinkHrefTarget(bool aNotifyParent)
}
void
SVGMPathElement::NotifyParentOfMpathChange(nsIContent* aParent)
nsSVGMpathElement::NotifyParentOfMpathChange(nsIContent* aParent)
{
if (aParent && aParent->IsSVG(nsGkAtoms::animateMotion)) {
@ -282,7 +265,3 @@ SVGMPathElement::NotifyParentOfMpathChange(nsIContent* aParent)
AnimationNeedsResample();
}
}
} // namespace dom
} // namespace mozilla

View File

@ -3,8 +3,8 @@
* 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/. */
#ifndef mozilla_dom_SVGMPathElement_h
#define mozilla_dom_SVGMPathElement_h
#ifndef NS_SVGMPATHELEMENT_H_
#define NS_SVGMPATHELEMENT_H_
#include "nsIDOMSVGMpathElement.h"
#include "nsIDOMSVGURIReference.h"
@ -14,26 +14,20 @@
#include "nsSVGString.h"
#include "nsReferencedElement.h"
nsresult NS_NewSVGMPathElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
typedef nsSVGElement SVGMPathElementBase;
typedef nsSVGElement nsSVGMpathElementBase;
namespace mozilla {
namespace dom {
class SVGMPathElement MOZ_FINAL : public SVGMPathElementBase,
public nsIDOMSVGMpathElement,
public nsIDOMSVGURIReference,
public nsStubMutationObserver
class nsSVGMpathElement : public nsSVGMpathElementBase,
public nsIDOMSVGMpathElement,
public nsIDOMSVGURIReference,
public nsStubMutationObserver
{
protected:
friend nsresult (::NS_NewSVGMPathElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo));
SVGMPathElement(already_AddRefed<nsINodeInfo> aNodeInfo);
~SVGMPathElement();
friend nsresult NS_NewSVGMpathElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
nsSVGMpathElement(already_AddRefed<nsINodeInfo> aNodeInfo);
~nsSVGMpathElement();
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
public:
// interfaces:
@ -41,15 +35,15 @@ public:
NS_DECL_NSIDOMSVGMPATHELEMENT
NS_DECL_NSIDOMSVGURIREFERENCE
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGMPathElement,
SVGMPathElementBase)
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsSVGMpathElement,
nsSVGMpathElementBase)
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
// Forward interface implementations to base class
NS_FORWARD_NSIDOMNODE_TO_NSINODE
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
NS_FORWARD_NSIDOMSVGELEMENT(SVGMPathElementBase::)
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGMpathElementBase::)
// nsIContent interface
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
@ -74,14 +68,10 @@ public:
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
// WebIDL
already_AddRefed<nsIDOMSVGAnimatedString> Href();
protected:
class PathReference : public nsReferencedElement {
public:
PathReference(SVGMPathElement* aMpathElement) :
PathReference(nsSVGMpathElement* aMpathElement) :
mMpathElement(aMpathElement) {}
protected:
// We need to be notified when target changes, in order to request a sample
@ -102,7 +92,7 @@ protected:
// first time the target changes)
virtual bool IsPersistent() { return true; }
private:
SVGMPathElement* const mMpathElement;
nsSVGMpathElement* const mMpathElement;
};
virtual StringAttributesInfo GetStringInfo();
@ -117,7 +107,4 @@ protected:
PathReference mHrefTarget;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_SVGMPathElement_h
#endif // NS_SVGMPATHELEMENT_H_

View File

@ -0,0 +1,118 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "mozilla/Util.h"
#include "nsSVGElement.h"
#include "nsIDOMSVGStopElement.h"
#include "nsSVGNumber2.h"
#include "nsGenericHTMLElement.h"
using namespace mozilla;
typedef nsSVGElement nsSVGStopElementBase;
class nsSVGStopElement : public nsSVGStopElementBase,
public nsIDOMSVGStopElement
{
protected:
friend nsresult NS_NewSVGStopElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
nsSVGStopElement(already_AddRefed<nsINodeInfo> aNodeInfo);
public:
// interfaces:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGSTOPELEMENT
// xxx If xpcom allowed virtual inheritance we wouldn't need to
// forward here :-(
NS_FORWARD_NSIDOMNODE_TO_NSINODE
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGStopElementBase::)
// nsIContent interface
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
protected:
virtual NumberAttributesInfo GetNumberInfo();
// nsIDOMSVGStopElement properties:
nsSVGNumber2 mOffset;
static NumberInfo sNumberInfo;
};
nsSVGElement::NumberInfo nsSVGStopElement::sNumberInfo =
{ &nsGkAtoms::offset, 0, true };
NS_IMPL_NS_NEW_SVG_ELEMENT(Stop)
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF_INHERITED(nsSVGStopElement,nsSVGStopElementBase)
NS_IMPL_RELEASE_INHERITED(nsSVGStopElement,nsSVGStopElementBase)
DOMCI_NODE_DATA(SVGStopElement, nsSVGStopElement)
NS_INTERFACE_TABLE_HEAD(nsSVGStopElement)
NS_NODE_INTERFACE_TABLE4(nsSVGStopElement, nsIDOMNode, nsIDOMElement,
nsIDOMSVGElement, nsIDOMSVGStopElement)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStopElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGStopElementBase)
//----------------------------------------------------------------------
// Implementation
nsSVGStopElement::nsSVGStopElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsSVGStopElementBase(aNodeInfo)
{
}
//----------------------------------------------------------------------
// nsIDOMNode methods
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGStopElement)
//----------------------------------------------------------------------
// nsIDOMSVGStopElement methods
/* readonly attribute nsIDOMSVGAnimatedNumber offset; */
NS_IMETHODIMP nsSVGStopElement::GetOffset(nsIDOMSVGAnimatedNumber * *aOffset)
{
return mOffset.ToDOMAnimatedNumber(aOffset,this);
}
//----------------------------------------------------------------------
// nsSVGElement methods
nsSVGElement::NumberAttributesInfo
nsSVGStopElement::GetNumberInfo()
{
return NumberAttributesInfo(&mOffset, &sNumberInfo, 1);
}
//----------------------------------------------------------------------
// nsIContent methods
NS_IMETHODIMP_(bool)
nsSVGStopElement::IsAttributeMapped(const nsIAtom* name) const
{
static const MappedAttributeEntry* const map[] = {
sGradientStopMap
};
return FindAttributeDependence(name, map) ||
nsSVGStopElementBase::IsAttributeMapped(name);
}

View File

@ -0,0 +1,363 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "nsSVGElement.h"
#include "nsGkAtoms.h"
#include "nsIDOMSVGStyleElement.h"
#include "nsUnicharUtils.h"
#include "nsIDocument.h"
#include "nsStyleLinkElement.h"
#include "nsContentUtils.h"
#include "nsStubMutationObserver.h"
using namespace mozilla;
typedef nsSVGElement nsSVGStyleElementBase;
class nsSVGStyleElement : public nsSVGStyleElementBase,
public nsIDOMSVGStyleElement,
public nsStyleLinkElement,
public nsStubMutationObserver
{
protected:
friend nsresult NS_NewSVGStyleElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
nsSVGStyleElement(already_AddRefed<nsINodeInfo> aNodeInfo);
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGSTYLEELEMENT
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsSVGStyleElement,
nsSVGStyleElementBase)
// xxx I wish we could use virtual inheritance
NS_FORWARD_NSIDOMNODE_TO_NSINODE
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGStyleElementBase::)
// nsIContent
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers);
virtual void UnbindFromTree(bool aDeep = true,
bool aNullParent = true);
nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
const nsAString& aValue, bool aNotify)
{
return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify);
}
virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
bool aNotify);
virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
bool aNotify);
virtual bool ParseAttribute(int32_t aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
// nsIMutationObserver
NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
protected:
// Dummy init method to make the NS_IMPL_NS_NEW_SVG_ELEMENT and
// NS_IMPL_ELEMENT_CLONE_WITH_INIT usable with this class. This should be
// completely optimized away.
inline nsresult Init()
{
return NS_OK;
}
// nsStyleLinkElement overrides
already_AddRefed<nsIURI> GetStyleSheetURL(bool* aIsInline);
void GetStyleSheetInfo(nsAString& aTitle,
nsAString& aType,
nsAString& aMedia,
bool* aIsAlternate);
virtual CORSMode GetCORSMode() const;
/**
* Common method to call from the various mutation observer methods.
* aContent is a content node that's either the one that changed or its
* parent; we should only respond to the change if aContent is non-anonymous.
*/
void ContentChanged(nsIContent* aContent);
};
NS_IMPL_NS_NEW_SVG_ELEMENT(Style)
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF_INHERITED(nsSVGStyleElement,nsSVGStyleElementBase)
NS_IMPL_RELEASE_INHERITED(nsSVGStyleElement,nsSVGStyleElementBase)
DOMCI_NODE_DATA(SVGStyleElement, nsSVGStyleElement)
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsSVGStyleElement)
NS_NODE_INTERFACE_TABLE7(nsSVGStyleElement, nsIDOMNode, nsIDOMElement,
nsIDOMSVGElement, nsIDOMSVGStyleElement,
nsIDOMLinkStyle, nsIStyleSheetLinkingElement,
nsIMutationObserver)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStyleElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGStyleElementBase)
NS_IMPL_CYCLE_COLLECTION_CLASS(nsSVGStyleElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsSVGStyleElement,
nsSVGStyleElementBase)
tmp->nsStyleLinkElement::Traverse(cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsSVGStyleElement,
nsSVGStyleElementBase)
tmp->nsStyleLinkElement::Unlink();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
//----------------------------------------------------------------------
// Implementation
nsSVGStyleElement::nsSVGStyleElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsSVGStyleElementBase(aNodeInfo)
{
AddMutationObserver(this);
}
//----------------------------------------------------------------------
// nsIDOMNode methods
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGStyleElement)
//----------------------------------------------------------------------
// nsIContent methods
nsresult
nsSVGStyleElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers)
{
nsresult rv = nsSVGStyleElementBase::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
void (nsSVGStyleElement::*update)() = &nsSVGStyleElement::UpdateStyleSheetInternal;
nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update));
return rv;
}
void
nsSVGStyleElement::UnbindFromTree(bool aDeep, bool aNullParent)
{
nsCOMPtr<nsIDocument> oldDoc = GetCurrentDoc();
nsSVGStyleElementBase::UnbindFromTree(aDeep, aNullParent);
UpdateStyleSheetInternal(oldDoc);
}
nsresult
nsSVGStyleElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
bool aNotify)
{
nsresult rv = nsSVGStyleElementBase::SetAttr(aNameSpaceID, aName, aPrefix,
aValue, aNotify);
if (NS_SUCCEEDED(rv)) {
UpdateStyleSheetInternal(nullptr,
aNameSpaceID == kNameSpaceID_None &&
(aName == nsGkAtoms::title ||
aName == nsGkAtoms::media ||
aName == nsGkAtoms::type));
}
return rv;
}
nsresult
nsSVGStyleElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
bool aNotify)
{
nsresult rv = nsSVGStyleElementBase::UnsetAttr(aNameSpaceID, aAttribute,
aNotify);
if (NS_SUCCEEDED(rv)) {
UpdateStyleSheetInternal(nullptr,
aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::title ||
aAttribute == nsGkAtoms::media ||
aAttribute == nsGkAtoms::type));
}
return rv;
}
bool
nsSVGStyleElement::ParseAttribute(int32_t aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aNamespaceID == kNameSpaceID_None &&
aAttribute == nsGkAtoms::crossorigin) {
ParseCORSValue(aValue, aResult);
return true;
}
return nsSVGStyleElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
//----------------------------------------------------------------------
// nsIMutationObserver methods
void
nsSVGStyleElement::CharacterDataChanged(nsIDocument* aDocument,
nsIContent* aContent,
CharacterDataChangeInfo* aInfo)
{
ContentChanged(aContent);
}
void
nsSVGStyleElement::ContentAppended(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aFirstNewContent,
int32_t aNewIndexInContainer)
{
ContentChanged(aContainer);
}
void
nsSVGStyleElement::ContentInserted(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aChild,
int32_t aIndexInContainer)
{
ContentChanged(aChild);
}
void
nsSVGStyleElement::ContentRemoved(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aChild,
int32_t aIndexInContainer,
nsIContent* aPreviousSibling)
{
ContentChanged(aChild);
}
void
nsSVGStyleElement::ContentChanged(nsIContent* aContent)
{
if (nsContentUtils::IsInSameAnonymousTree(this, aContent)) {
UpdateStyleSheetInternal(nullptr);
}
}
//----------------------------------------------------------------------
// nsIDOMSVGStyleElement methods
/* attribute DOMString xmlspace; */
NS_IMETHODIMP nsSVGStyleElement::GetXmlspace(nsAString & aXmlspace)
{
GetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace);
return NS_OK;
}
NS_IMETHODIMP nsSVGStyleElement::SetXmlspace(const nsAString & aXmlspace)
{
return SetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace, true);
}
/* attribute DOMString type; */
NS_IMETHODIMP nsSVGStyleElement::GetType(nsAString & aType)
{
GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);
return NS_OK;
}
NS_IMETHODIMP nsSVGStyleElement::SetType(const nsAString & aType)
{
return SetAttr(kNameSpaceID_None, nsGkAtoms::type, aType, true);
}
/* attribute DOMString media; */
NS_IMETHODIMP nsSVGStyleElement::GetMedia(nsAString & aMedia)
{
GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia);
return NS_OK;
}
NS_IMETHODIMP nsSVGStyleElement::SetMedia(const nsAString & aMedia)
{
return SetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia, true);
}
/* attribute DOMString title; */
NS_IMETHODIMP nsSVGStyleElement::GetTitle(nsAString & aTitle)
{
GetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle);
return NS_OK;
}
NS_IMETHODIMP nsSVGStyleElement::SetTitle(const nsAString & aTitle)
{
return SetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle, true);
}
//----------------------------------------------------------------------
// nsStyleLinkElement methods
already_AddRefed<nsIURI>
nsSVGStyleElement::GetStyleSheetURL(bool* aIsInline)
{
*aIsInline = true;
return nullptr;
}
void
nsSVGStyleElement::GetStyleSheetInfo(nsAString& aTitle,
nsAString& aType,
nsAString& aMedia,
bool* aIsAlternate)
{
*aIsAlternate = false;
nsAutoString title;
GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
title.CompressWhitespace();
aTitle.Assign(title);
GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia);
// The SVG spec is formulated in terms of the CSS2 spec,
// which specifies that media queries are case insensitive.
nsContentUtils::ASCIIToLower(aMedia);
GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);
if (aType.IsEmpty()) {
aType.AssignLiteral("text/css");
}
return;
}
CORSMode
nsSVGStyleElement::GetCORSMode() const
{
return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin));
}

View File

@ -0,0 +1,173 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "nsSVGElement.h"
#include "nsIDOMSVGTitleElement.h"
#include "nsStubMutationObserver.h"
typedef nsSVGElement nsSVGTitleElementBase;
class nsSVGTitleElement : public nsSVGTitleElementBase,
public nsIDOMSVGTitleElement,
public nsStubMutationObserver
{
protected:
friend nsresult NS_NewSVGTitleElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
nsSVGTitleElement(already_AddRefed<nsINodeInfo> aNodeInfo);
nsresult Init();
public:
// interfaces:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGTITLEELEMENT
// xxx I wish we could use virtual inheritance
NS_FORWARD_NSIDOMNODE_TO_NSINODE
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGTitleElementBase::)
// nsIMutationObserver
NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent,
nsIContent *aBindingParent,
bool aCompileEventHandlers);
virtual void UnbindFromTree(bool aDeep = true,
bool aNullParent = true);
virtual void DoneAddingChildren(bool aHaveNotified);
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
private:
void SendTitleChangeEvent(bool aBound);
};
NS_IMPL_NS_NEW_SVG_ELEMENT(Title)
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF_INHERITED(nsSVGTitleElement, nsSVGTitleElementBase)
NS_IMPL_RELEASE_INHERITED(nsSVGTitleElement, nsSVGTitleElementBase)
DOMCI_NODE_DATA(SVGTitleElement, nsSVGTitleElement)
NS_INTERFACE_TABLE_HEAD(nsSVGTitleElement)
NS_NODE_INTERFACE_TABLE5(nsSVGTitleElement, nsIDOMNode, nsIDOMElement,
nsIDOMSVGElement, nsIDOMSVGTitleElement,
nsIMutationObserver)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTitleElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGTitleElementBase)
//----------------------------------------------------------------------
// Implementation
nsSVGTitleElement::nsSVGTitleElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsSVGTitleElementBase(aNodeInfo)
{
AddMutationObserver(this);
}
nsresult
nsSVGTitleElement::Init()
{
return nsSVGTitleElementBase::Init();
}
void
nsSVGTitleElement::CharacterDataChanged(nsIDocument *aDocument,
nsIContent *aContent,
CharacterDataChangeInfo *aInfo)
{
SendTitleChangeEvent(false);
}
void
nsSVGTitleElement::ContentAppended(nsIDocument *aDocument,
nsIContent *aContainer,
nsIContent *aFirstNewContent,
int32_t aNewIndexInContainer)
{
SendTitleChangeEvent(false);
}
void
nsSVGTitleElement::ContentInserted(nsIDocument *aDocument,
nsIContent *aContainer,
nsIContent *aChild,
int32_t aIndexInContainer)
{
SendTitleChangeEvent(false);
}
void
nsSVGTitleElement::ContentRemoved(nsIDocument *aDocument,
nsIContent *aContainer,
nsIContent *aChild,
int32_t aIndexInContainer,
nsIContent *aPreviousSibling)
{
SendTitleChangeEvent(false);
}
nsresult
nsSVGTitleElement::BindToTree(nsIDocument *aDocument,
nsIContent *aParent,
nsIContent *aBindingParent,
bool aCompileEventHandlers)
{
// Let this fall through.
nsresult rv = nsSVGTitleElementBase::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
SendTitleChangeEvent(true);
return NS_OK;
}
void
nsSVGTitleElement::UnbindFromTree(bool aDeep, bool aNullParent)
{
SendTitleChangeEvent(false);
// Let this fall through.
nsSVGTitleElementBase::UnbindFromTree(aDeep, aNullParent);
}
void
nsSVGTitleElement::DoneAddingChildren(bool aHaveNotified)
{
if (!aHaveNotified) {
SendTitleChangeEvent(false);
}
}
void
nsSVGTitleElement::SendTitleChangeEvent(bool aBound)
{
nsIDocument* doc = GetCurrentDoc();
if (doc) {
doc->NotifyPossibleTitleChange(aBound);
}
}
//----------------------------------------------------------------------
// nsIDOMNode methods
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGTitleElement)

View File

@ -716,10 +716,6 @@ DOMInterfaces = {
'headerFile': 'SVGPreserveAspectRatio.h'
},
'SVGTitleElement': {
'hasInstanceInterface': 'nsIDOMSVGTitleElement',
},
'SVGTransform': {
'nativeType': 'mozilla::DOMSVGTransform',
'headerFile': 'DOMSVGTransform.h'
@ -1122,7 +1118,6 @@ addExternalIface('ProcessingInstruction', nativeType='nsXMLProcessingInstruction
addExternalIface('Range', nativeType='nsRange')
addExternalIface('Selection', nativeType='nsISelection')
addExternalIface('StyleSheetList')
addExternalIface('SVGAnimatedNumber')
addExternalIface('SVGAnimatedString')
addExternalIface('SVGLength')
addExternalIface('SVGNumber')

View File

@ -1,15 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* http://www.w3.org/TR/SVG2/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
interface SVGDescElement : SVGElement {
};

View File

@ -1,17 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* http://www.w3.org/TR/SVG2/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
interface SVGMPathElement : SVGElement {
};
SVGMPathElement implements SVGURIReference;

View File

@ -1,15 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* http://www.w3.org/TR/SVG2/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
interface SVGMetadataElement : SVGElement {
};

View File

@ -1,18 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* http://www.w3.org/TR/SVG2/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
interface SVGAnimatedNumber;
interface SVGStopElement : SVGElement {
readonly attribute SVGAnimatedNumber offset;
};

View File

@ -1,23 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* http://www.w3.org/TR/SVG2/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
interface SVGStyleElement : SVGElement {
[SetterThrows]
attribute DOMString xmlspace; // Spec claims this should be on SVGElement
[SetterThrows]
attribute DOMString type;
[SetterThrows]
attribute DOMString media;
[SetterThrows]
attribute DOMString title;
};

View File

@ -1,15 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* http://www.w3.org/TR/SVG2/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
interface SVGTitleElement : SVGElement {
};

View File

@ -1,19 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* http://www.w3.org/TR/SVG2/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
interface SVGAnimatedString;
[NoInterfaceObject]
interface SVGURIReference {
readonly attribute SVGAnimatedString href;
};

View File

@ -96,24 +96,17 @@ webidl_files = \
SVGAnimatedNumberList.webidl \
SVGAnimatedPreserveAspectRatio.webidl \
SVGAnimatedTransformList.webidl \
SVGDescElement.webidl \
SVGElement.webidl \
SVGLengthList.webidl \
SVGMatrix.webidl \
SVGMetadataElement.webidl \
SVGMPathElement.webidl \
SVGNumberList.webidl \
SVGPathSeg.webidl \
SVGPathSegList.webidl \
SVGPoint.webidl \
SVGPointList.webidl \
SVGPreserveAspectRatio.webidl \
SVGStopElement.webidl \
SVGStyleElement.webidl \
SVGTitleElement.webidl \
SVGTransform.webidl \
SVGTransformList.webidl \
SVGURIReference.webidl \
Text.webidl \
TextDecoder.webidl \
TextEncoder.webidl \