зеркало из https://github.com/mozilla/gecko-dev.git
Bug 80142 (among others) - landing of SVG_20010721_BRANCH. Work by
alex.fritze@crocodile-clips.com, james.turner@crocodile-clips.com, and everyone else how helped on the branch. Thanks to peterv for last minute build changes r=cls for build changes r=jst, rs=brendan for #ifdef'd parts touching existing files. NOT ON BY DEFAULT
This commit is contained in:
Родитель
95f32b532c
Коммит
5c8cc975a2
|
@ -157,6 +157,10 @@ ifdef MOZ_ENABLE_GTK
|
|||
tier_9_dirs += widget/src/gtksuperwin widget/src/gtkxtbin
|
||||
endif
|
||||
|
||||
ifdef MOZ_INTERNAL_LIBART_LGPL
|
||||
tier_9_dirs += other-licenses/libart_lgpl
|
||||
endif
|
||||
|
||||
tier_9_dirs += \
|
||||
widget/timer \
|
||||
modules/libutil \
|
||||
|
|
|
@ -7,6 +7,7 @@ builtin(include, build/autoconf/glib.m4)dnl
|
|||
builtin(include, build/autoconf/gtk.m4)dnl
|
||||
builtin(include, build/autoconf/libIDL.m4)dnl
|
||||
builtin(include, build/autoconf/nspr.m4)dnl
|
||||
builtin(include, build/autoconf/libart.m4)dnl
|
||||
builtin(include, build/autoconf/pkg.m4)dnl
|
||||
dnl
|
||||
define(MOZ_TOPSRCDIR,.)dnl MOZ_TOPSRCDIR is used in altoptions.m4
|
||||
|
|
|
@ -928,15 +928,27 @@ if [ "$MOZ_MATHML" ]; then
|
|||
"
|
||||
fi
|
||||
|
||||
# layout/svg
|
||||
#libart
|
||||
if [ "$MOZ_INTERNAL_LIBART_LGPL" ]; then
|
||||
MAKEFILES_libart="other-licenses/libart_lgpl/Makefile"
|
||||
fi
|
||||
|
||||
# svg
|
||||
if [ "$MOZ_SVG" ]; then
|
||||
MAKEFILES_content="$MAKEFILES_content
|
||||
content/svg/Makefile
|
||||
content/svg/document/Makefile
|
||||
content/svg/document/src/Makefile
|
||||
content/svg/content/Makefile
|
||||
content/svg/content/src/Makefile
|
||||
"
|
||||
MAKEFILES_dom="$MAKEFILES_dom
|
||||
dom/public/idl/svg/Makefile
|
||||
"
|
||||
MAKEFILES_layout="$MAKEFILES_layout
|
||||
layout/svg/Makefile
|
||||
layout/svg/base/Makefile
|
||||
layout/svg/base/public/Makefile
|
||||
layout/svg/base/src/Makefile
|
||||
layout/svg/content/Makefile
|
||||
layout/svg/content/src/Makefile
|
||||
"
|
||||
fi
|
||||
|
||||
|
@ -1107,6 +1119,7 @@ $MAKEFILES_l10n_lang
|
|||
$MAKEFILES_langpacks
|
||||
$MAKEFILES_content
|
||||
$MAKEFILES_layout
|
||||
$MAKEFILES_libart
|
||||
$MAKEFILES_libreg
|
||||
$MAKEFILES_libimg
|
||||
$MAKEFILES_libpr0n
|
||||
|
|
|
@ -711,10 +711,6 @@ sub BuildClientDist()
|
|||
InstallFromManifest(":mozilla:layout:html:base:src:MANIFEST", "$distdirectory:layout:");
|
||||
InstallFromManifest(":mozilla:layout:html:forms:public:MANIFEST", "$distdirectory:layout:");
|
||||
InstallFromManifest(":mozilla:layout:html:table:public:MANIFEST", "$distdirectory:layout:");
|
||||
if ($main::options{svg})
|
||||
{
|
||||
InstallFromManifest(":mozilla:layout:svg:base:public:MANIFEST", "$distdirectory:layout:");
|
||||
}
|
||||
InstallFromManifest(":mozilla:layout:xul:base:public:Manifest", "$distdirectory:layout:");
|
||||
|
||||
#GFX
|
||||
|
@ -737,6 +733,16 @@ sub BuildClientDist()
|
|||
InstallFromManifest(":mozilla:dom:public:idl:views:MANIFEST_IDL", "$distdirectory:idl:");
|
||||
InstallFromManifest(":mozilla:dom:public:idl:xbl:MANIFEST_IDL", "$distdirectory:idl:");
|
||||
InstallFromManifest(":mozilla:dom:public:idl:xul:MANIFEST_IDL", "$distdirectory:idl:");
|
||||
|
||||
# SVG
|
||||
if ($main::options{libart_lgpl}) {
|
||||
InstallFromManifest(":mozilla:other-licenses:libart_lgpl:MANIFEST", "$distdirectory:include:");
|
||||
}
|
||||
if ($main::options{svg}) {
|
||||
InstallFromManifest(":mozilla:content:svg:content:src:MANIFEST", "$distdirectory:content:");
|
||||
InstallFromManifest(":mozilla:layout:svg:base:src:MANIFEST", "$distdirectory:layout:");
|
||||
}
|
||||
|
||||
InstallFromManifest(":mozilla:dom:public:MANIFEST", "$distdirectory:dom:");
|
||||
InstallFromManifest(":mozilla:dom:public:base:MANIFEST", "$distdirectory:dom:");
|
||||
InstallFromManifest(":mozilla:dom:public:coreEvents:MANIFEST", "$distdirectory:dom:");
|
||||
|
@ -903,6 +909,11 @@ sub BuildClientDist()
|
|||
InstallFromManifest(":mozilla:js:jsd:MANIFEST", "$distdirectory:jsdebug:");
|
||||
}
|
||||
|
||||
# libart
|
||||
if ($main::options{libart_lgpl}) {
|
||||
InstallFromManifest(":mozilla:modules:libart_lgpl:MANIFEST", "$distdirectory:include:");
|
||||
}
|
||||
|
||||
print("--- Client Dist export complete ----\n");
|
||||
}
|
||||
|
||||
|
@ -1097,6 +1108,10 @@ sub BuildIDLProjects()
|
|||
BuildIDLProject(":mozilla:dom:macbuild:dom_xblIDL.xml", "dom_xbl");
|
||||
BuildIDLProject(":mozilla:dom:macbuild:dom_xulIDL.xml", "dom_xul");
|
||||
|
||||
if ($main::options{svg}) {
|
||||
BuildIDLProject(":mozilla:dom:macbuild:dom_svgIDL.xml", "dom_svg");
|
||||
}
|
||||
|
||||
BuildIDLProject(":mozilla:dom:src:jsurl:macbuild:JSUrlDL.xml", "jsurl");
|
||||
|
||||
BuildIDLProject(":mozilla:gfx:macbuild:gfxIDL.xml", "gfx");
|
||||
|
@ -1592,6 +1607,15 @@ sub BuildLayoutProjects()
|
|||
BuildProject(":mozilla:content:macbuild:contentshared.xml", "contentshared$D.o");
|
||||
MakeAlias(":mozilla:content:macbuild:contentshared$D.o", ":mozilla:dist:content:");
|
||||
|
||||
if ($main::options{svg})
|
||||
{
|
||||
BuildOneProject(":mozilla:content:macbuild:contentSVG.xml", "contentSVG$D.o", 0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildOneProject(":mozilla:content:macbuild:contentSVG.xml", "contentSVG$D.o stub", 0, 0, 0);
|
||||
}
|
||||
|
||||
BuildOneProject(":mozilla:content:macbuild:content.xml", "content$D.$S", 1, $main::ALIAS_SYM_FILES, 1);
|
||||
if ($main::options{mathml})
|
||||
{
|
||||
|
@ -1601,6 +1625,10 @@ sub BuildLayoutProjects()
|
|||
{
|
||||
BuildProject(":mozilla:layout:macbuild:layoutmathml.xml", "layoutmathml$D.o stub");
|
||||
}
|
||||
if ($main::options{libart_lgpl})
|
||||
{
|
||||
BuildOneProject(":mozilla:other-licenses:libart_lgpl:macbuild:libart.xml", "libart$D.shlb", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
}
|
||||
if ($main::options{svg})
|
||||
{
|
||||
BuildProject(":mozilla:layout:macbuild:layoutsvg.xml", "layoutsvg$D.o");
|
||||
|
|
44
client.mak
44
client.mak
|
@ -216,6 +216,40 @@ GFX2_CO_FLAGS=$(GFX2_CO_FLAGS) $(CVS_BRANCH)
|
|||
|
||||
CVSCO_GFX2 = cvs $(CVS_FLAGS) co $(GFX2_CO_FLAGS)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Figure out how to pull the internal libart
|
||||
#// (only pulled and built if MOZ_INTERNAL_LIBART_LGPL is set)
|
||||
#// If no MOZ_INTERNAL_LIBART_CO_TAG is specified, use the default tag
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
!if defined(MOZ_SVG) && !defined(MOZ_INTERNAL_LIBART_LGPL)
|
||||
ERR_MESSAGE = ^
|
||||
You are trying to build Mozilla with SVG support (MOZ_SVG=1), but you ^
|
||||
haven not specified that mozilla/other-licenses/libart_lgpl should be ^
|
||||
pulled and built. At the moment Mozilla SVG builds need this patched ^
|
||||
version of libart. You either need to disable SVG support (unset MOZ_SVG) ^
|
||||
or enable pulling and building by setting MOZ_INTERNAL_LIBART_LGPL=1.^
|
||||
^
|
||||
If you choose to pull and build libart, note that it is only licensed^
|
||||
under the terms of the LGPL, not the MPL. (Which is why you have to opt^
|
||||
in explicitly.)
|
||||
!endif
|
||||
|
||||
!if defined(MOZ_INTERNAL_LIBART_LGPL)
|
||||
|
||||
!ifndef MOZ_INTERNAL_LIBART_CO_FLAGS
|
||||
MOZ_INTERNAL_LIBART_CO_FLAGS=$(MOZ_CO_FLAGS)
|
||||
!endif
|
||||
|
||||
!if "$(MOZ_INTERNAL_LIBART_CO_TAG)" != ""
|
||||
MOZ_INTERNAL_LIBART_CO_FLAGS=$(MOZ_INTERNAL_LIBART_CO_FLAGS) -r $(MOZ_INTERNAL_LIBART_CO_TAG)
|
||||
!else
|
||||
MOZ_INTERNAL_LIBART_CO_FLAGS=$(MOZ_INTERNAL_LIBART_CO_FLAGS) $(CVS_BRANCH)
|
||||
!endif
|
||||
|
||||
CVSCO_MOZ_INTERNAL_LIBART = cvs $(CVS_FLAGS) co $(MOZ_INTERNAL_LIBART_CO_FLAGS)
|
||||
|
||||
!endif
|
||||
|
||||
## The master target
|
||||
############################################################
|
||||
|
@ -228,7 +262,11 @@ pull_and_build_all: pull_all build_all_dep
|
|||
|
||||
pull_clobber_and_build_all: pull_all clobber_all build_all
|
||||
|
||||
!if !defined(MOZ_INTERNAL_LIBART_LGPL)
|
||||
pull_all: pull_nspr pull_psm pull_ldapcsdk pull_accessible pull_gfx2 pull_imglib2 pull_seamonkey
|
||||
!else
|
||||
pull_all: pull_nspr pull_psm pull_ldapcsdk pull_accessible pull_gfx2 pull_imglib2 pull_moz_internal_libart pull_seamonkey
|
||||
!endif
|
||||
|
||||
pull_nspr: pull_clientmak
|
||||
cd $(MOZ_SRC)\.
|
||||
|
@ -260,6 +298,12 @@ pull_imglib2:
|
|||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_IMGLIB2) mozilla/modules/libpr0n
|
||||
|
||||
!if defined(MOZ_INTERNAL_LIBART_LGPL)
|
||||
pull_moz_internal_libart:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_MOZ_INTERNAL_LIBART) mozilla/other-licenses/libart_lgpl
|
||||
!endif
|
||||
|
||||
pull_xpconnect: pull_nspr
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO) mozilla/include
|
||||
|
|
15
client.mk
15
client.mk
|
@ -332,6 +332,19 @@ ifeq ($(MOZ_CO_MODULE),)
|
|||
endif
|
||||
CVSCO_SEAMONKEY := $(CVSCO) $(CVS_CO_DATE_FLAGS) $(MOZ_CO_MODULE)
|
||||
|
||||
####################################
|
||||
# CVS defined for libart (pulled and built if MOZ_INTERNAL_LIBART_LGPL is set)
|
||||
#
|
||||
CVSCO_LIBART := $(CVSCO) $(CVS_CO_DATE_FLAGS) mozilla/other-licenses/libart_lgpl
|
||||
|
||||
ifdef MOZ_INTERNAL_LIBART_LGPL
|
||||
FASTUPDATE_LIBART := fast_update $(CVSCO_LIBART)
|
||||
CHECKOUT_LIBART := cvs_co $(CVSCO_LIBART)
|
||||
else
|
||||
CHECKOUT_LIBART := true
|
||||
FASTUPDATE_LIBART := true
|
||||
endif
|
||||
|
||||
####################################
|
||||
# CVS defines for Calendar (pulled and built if MOZ_CALENDAR is set)
|
||||
#
|
||||
|
@ -409,6 +422,7 @@ real_checkout:
|
|||
cvs_co $(CVSCO_IMGLIB2) && \
|
||||
cvs_co $(CVSCO_SEAMONKEY) && \
|
||||
$(CHECKOUT_CALENDAR) && \
|
||||
$(CHECKOUT_LIBART) && \
|
||||
cvs_co $(CVSCO_NOSUBDIRS)
|
||||
@echo "checkout finish: "`date` | tee -a $(CVSCO_LOGFILE)
|
||||
# @: Check the log for conflicts. ;
|
||||
|
@ -466,6 +480,7 @@ real_fast-update:
|
|||
fast_update $(CVSCO_IMGLIB2) && \
|
||||
fast_update $(CVSCO_SEAMONKEY) && \
|
||||
$(FASTUPDATE_CALENDAR) && \
|
||||
$(FASTUPDATE_LIBART) && \
|
||||
fast_update $(CVSCO_NOSUBDIRS)
|
||||
@echo "fast_update finish: "`date` | tee -a $(CVSCO_LOGFILE)
|
||||
# @: Check the log for conflicts. ;
|
||||
|
|
|
@ -111,11 +111,23 @@ MOZ_NATIVE_JPEG = @SYSTEM_JPEG@
|
|||
MOZ_NATIVE_PNG = @SYSTEM_PNG@
|
||||
MOZ_NATIVE_MNG = @SYSTEM_MNG@
|
||||
|
||||
MOZ_INTERNAL_LIBART_LGPL = @MOZ_INTERNAL_LIBART_LGPL@
|
||||
|
||||
MOZ_UPDATE_XTERM = @MOZ_UPDATE_XTERM@
|
||||
MOZ_MATHML = @MOZ_MATHML@
|
||||
MOZ_SVG = @MOZ_SVG@
|
||||
MOZ_LIBART_CFLAGS = @MOZ_LIBART_CFLAGS@
|
||||
TX_EXE = @TX_EXE@
|
||||
|
||||
# Mac's don't like / in a #include, so we include the libart
|
||||
# headers locally if we're using the external library
|
||||
ifdef MOZ_LIBART_CFLAGS
|
||||
ifndef MOZ_INTERNAL_LIBART_LGPL
|
||||
MOZ_LIBART_CFLAGS := $(MOZ_LIBART_CFLAGS)/libart_lgpl
|
||||
endif
|
||||
endif
|
||||
MOZ_LIBART_LIBS = @MOZ_LIBART_LIBS@
|
||||
|
||||
MOZ_INSURE = @MOZ_INSURE@
|
||||
MOZ_INSURIFYING = @MOZ_INSURIFYING@
|
||||
MOZ_INSURE_DIRS = @MOZ_INSURE_DIRS@
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
30
configure.in
30
configure.in
|
@ -90,6 +90,7 @@ LIBIDL_VERSION=0.6.3
|
|||
PERL_VERSION=5.004
|
||||
QT_VERSION=2.2.0
|
||||
QT_VERSION_NUM=220
|
||||
LIBART_VERSION=2.3.4
|
||||
GTK2_VERSION=1.3.7
|
||||
|
||||
dnl Set various checks
|
||||
|
@ -4051,6 +4052,35 @@ AC_SUBST(HOST_LIBIDL_CONFIG)
|
|||
AC_SUBST(HOST_LIBIDL_CFLAGS)
|
||||
AC_SUBST(HOST_LIBIDL_LIBS)
|
||||
|
||||
dnl ========================================================
|
||||
dnl Check for libart
|
||||
dnl ========================================================
|
||||
MOZ_LIBART_CFLAGS=
|
||||
MOZ_LIBART_LIBS=
|
||||
|
||||
if test "$MOZ_SVG"; then
|
||||
if test "$MOZ_INTERNAL_LIBART_LGPL"; then
|
||||
dnl libart's configure hasn't been run yet, but we know what the
|
||||
dnl answer should be anyway
|
||||
MOZ_LIBART_CFLAGS='-I${DIST}/include/libart_lgpl'
|
||||
MOZ_LIBART_LIBS='-lmoz_art_lgpl -lm'
|
||||
else
|
||||
dnl Disable system libart until the pixel format changes are merged upstream
|
||||
AC_MSG_ERROR([SVG requires a modified version of libart. To pull and build
|
||||
this LGPL library, set MOZ_INTERNAL_LIBART_LGPL, and then rerun the
|
||||
checkout stage])
|
||||
dnl AM_PATH_LIBART($LIBART_VERSION,
|
||||
dnl AC_MSG_ERROR(SVG requires at least version $LIBART_VERSION of libart))
|
||||
dnl
|
||||
dnl MOZ_LIBART_CFLAGS=$LIBART_CFLAGS
|
||||
dnl MOZ_LIBART_LIBS=$LIBART_LIBS
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_SUBST(MOZ_LIBART_CFLAGS)
|
||||
AC_SUBST(MOZ_LIBART_LIBS)
|
||||
AC_SUBST(MOZ_INTERNAL_LIBART_LGPL)
|
||||
|
||||
dnl ========================================================
|
||||
dnl disable xul
|
||||
dnl ========================================================
|
||||
|
|
|
@ -28,6 +28,10 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
DIRS = base html xml xul xbl xsl
|
||||
|
||||
ifdef MOZ_SVG
|
||||
DIRS += svg
|
||||
endif
|
||||
|
||||
DIRS += events shared build
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -269,4 +269,22 @@
|
|||
#define NS_RANGEUTILS_CID \
|
||||
{ 0xa6cf9126, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
|
||||
// {4E48C00A-E20F-4061-B869-2BAC285D68E8}
|
||||
#define NS_SVGELEMENTFACTORY_DEPRECATED_CID \
|
||||
{ 0x4e48c00a, 0xe20f, 0x4061, { 0xb8, 0x69, 0x2b, 0xac, 0x28, 0x5d, 0x68, 0xe8 } }
|
||||
|
||||
|
||||
// {34D9B28A-FBFF-4bbd-8546-1822FE3FB8B5}
|
||||
#define NS_SVGELEMENTFACTORY_CID \
|
||||
{ 0x34d9b28a, 0xfbff, 0x4bbd, { 0x85, 0x46, 0x18, 0x22, 0xfe, 0x3f, 0xb8, 0xb5 } }
|
||||
|
||||
#define NS_SVGDOCUMENT_CID \
|
||||
{ /* b7f44954-1dd1-11b2-8c2e-c2feab4186bc */ \
|
||||
0xb7f44954, 0x11d1, 0x11b2, \
|
||||
{0x8c, 0x2e, 0xc2, 0xfe, 0xab, 0x41, 0x86, 0xbc}}
|
||||
|
||||
#endif // MOZ_SVG
|
||||
|
||||
#endif /* nsContentCID_h__ */
|
||||
|
|
|
@ -380,6 +380,11 @@ extern NS_EXPORT nsresult
|
|||
extern NS_EXPORT nsresult
|
||||
NS_NewXMLDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
extern NS_EXPORT nsresult
|
||||
NS_NewSVGDocument(nsIDocument** aInstancePtrResult);
|
||||
#endif
|
||||
|
||||
extern NS_EXPORT nsresult
|
||||
NS_NewImageDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
|
|
|
@ -68,4 +68,13 @@ public:
|
|||
#define NS_HTML_ELEMENT_FACTORY_CONTRACTID NS_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_HTML_NAMESPACE
|
||||
#define NS_XML_ELEMENT_FACTORY_CONTRACTID NS_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_XML_NAMESPACE
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
#define NS_SVG_DEPRECATED_NAMESPACE "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.svg"
|
||||
#define NS_SVG_DEPRECATED_ELEMENT_FACTORY_CONTRACTID \
|
||||
NS_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_SVG_DEPRECATED_NAMESPACE
|
||||
|
||||
#define NS_SVG_NAMESPACE "http://www.w3.org/2000/svg"
|
||||
#define NS_SVG_ELEMENT_FACTORY_CONTRACTID NS_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_SVG_NAMESPACE
|
||||
#endif
|
||||
|
||||
#endif /* nsIElementFactory_h___ */
|
||||
|
|
|
@ -913,6 +913,22 @@ static const PropertyCheckData XULCheckProperties[] = {
|
|||
};
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
static const PropertyCheckData SVGCheckProperties[] = {
|
||||
CHECKDATA_PROP(nsCSSSVG, mFill, CHECKDATA_VALUE, PR_FALSE),
|
||||
CHECKDATA_PROP(nsCSSSVG, mFillOpacity, CHECKDATA_VALUE, PR_FALSE),
|
||||
CHECKDATA_PROP(nsCSSSVG, mFillRule, CHECKDATA_VALUE, PR_FALSE),
|
||||
CHECKDATA_PROP(nsCSSSVG, mStroke, CHECKDATA_VALUE, PR_FALSE),
|
||||
CHECKDATA_PROP(nsCSSSVG, mStrokeDasharray, CHECKDATA_VALUE, PR_FALSE),
|
||||
CHECKDATA_PROP(nsCSSSVG, mStrokeDashoffset, CHECKDATA_VALUE, PR_FALSE),
|
||||
CHECKDATA_PROP(nsCSSSVG, mStrokeLinecap, CHECKDATA_VALUE, PR_FALSE),
|
||||
CHECKDATA_PROP(nsCSSSVG, mStrokeLinejoin, CHECKDATA_VALUE, PR_FALSE),
|
||||
CHECKDATA_PROP(nsCSSSVG, mStrokeMiterlimit, CHECKDATA_VALUE, PR_FALSE),
|
||||
CHECKDATA_PROP(nsCSSSVG, mStrokeOpacity, CHECKDATA_VALUE, PR_FALSE),
|
||||
CHECKDATA_PROP(nsCSSSVG, mStrokeWidth, CHECKDATA_VALUE, PR_FALSE)
|
||||
};
|
||||
#endif
|
||||
|
||||
// These are indexed by style struct ID and must stay in order!
|
||||
static const StructCheckData gCheckProperties[] = {
|
||||
{ nsnull, 0, nsnull}, /* empty, since no 0th SID */
|
||||
|
@ -937,6 +953,9 @@ static const StructCheckData gCheckProperties[] = {
|
|||
CHECKDATA_STRUCT(OutlineCheckProperties),
|
||||
#ifdef INCLUDE_XUL
|
||||
CHECKDATA_STRUCT(XULCheckProperties),
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
CHECKDATA_STRUCT(SVGCheckProperties),
|
||||
#endif
|
||||
{ nsnull, 0, nsnull} /* empty, so at least we crash reliably if someone
|
||||
passes in the BorderPaddingShortcut ID */
|
||||
|
@ -1400,6 +1419,18 @@ nsRuleNode::GetXULData(nsIStyleContext* aContext, PRBool aComputeData)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
const nsStyleStruct*
|
||||
nsRuleNode::GetSVGData(nsIStyleContext* aContext, PRBool aComputeData)
|
||||
{
|
||||
nsCSSSVG svgData; // Declare a struct with null CSS values.
|
||||
nsRuleData ruleData(eStyleStruct_SVG, mPresContext, aContext);
|
||||
ruleData.mSVGData = &svgData;
|
||||
|
||||
return WalkRuleTree(eStyleStruct_SVG, aContext, &ruleData, &svgData, aComputeData);
|
||||
}
|
||||
#endif
|
||||
|
||||
const nsStyleStruct*
|
||||
nsRuleNode::WalkRuleTree(const nsStyleStructID aSID,
|
||||
nsIStyleContext* aContext,
|
||||
|
@ -1676,6 +1707,15 @@ nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsIStyleContext* aConte
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
case eStyleStruct_SVG:
|
||||
{
|
||||
nsStyleSVG* svg = new (mPresContext) nsStyleSVG();
|
||||
aContext->SetStyle(eStyleStruct_SVG, *svg);
|
||||
return svg;
|
||||
}
|
||||
#endif
|
||||
|
||||
case eStyleStruct_BorderPaddingShortcut:
|
||||
NS_ERROR("unexpected SID");
|
||||
}
|
||||
|
@ -1708,6 +1748,9 @@ nsRuleNode::gComputeStyleDataFn[] = {
|
|||
&nsRuleNode::ComputeOutlineData,
|
||||
#ifdef INCLUDE_XUL
|
||||
&nsRuleNode::ComputeXULData,
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
&nsRuleNode::ComputeSVGData,
|
||||
#endif
|
||||
nsnull
|
||||
};
|
||||
|
@ -4425,6 +4468,180 @@ nsRuleNode::ComputeXULData(nsStyleStruct* aStartStruct, const nsCSSStruct& aData
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
static void
|
||||
SetSVGPaint(const nsCSSValue& aValue, const nsStyleSVGPaint& parentPaint,
|
||||
nsIPresContext* aPresContext, nsStyleSVGPaint& aResult, PRBool& aInherited)
|
||||
{
|
||||
if (aValue.GetUnit() == eCSSUnit_Inherit) {
|
||||
aResult = parentPaint;
|
||||
aInherited = PR_TRUE;
|
||||
} else if (aValue.GetUnit() == eCSSUnit_None) {
|
||||
aResult.mType = eStyleSVGPaintType_None;
|
||||
} else if (SetColor(aValue, parentPaint.mColor, aPresContext, aResult.mColor, aInherited)) {
|
||||
aResult.mType = eStyleSVGPaintType_Color;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SetSVGOpacity(const nsCSSValue& aValue, float parentOpacity, float& opacity, PRBool& aInherited)
|
||||
{
|
||||
if (aValue.GetUnit() == eCSSUnit_Inherit) {
|
||||
opacity = parentOpacity;
|
||||
aInherited = PR_TRUE;
|
||||
}
|
||||
else if (aValue.GetUnit() == eCSSUnit_Number) {
|
||||
opacity = aValue.GetFloatValue();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SetSVGLength(const nsCSSValue& aValue, float parentLength, float& length,
|
||||
nsIStyleContext* aContext, nsIPresContext* aPresContext, PRBool& aInherited)
|
||||
{
|
||||
nsStyleCoord coord;
|
||||
PRBool dummy;
|
||||
if (SetCoord(aValue, coord, coord,
|
||||
SETCOORD_LP | SETCOORD_FACTOR,
|
||||
aContext, aPresContext, dummy)) {
|
||||
if (coord.GetUnit() == eStyleUnit_Factor) { // user units
|
||||
length = (float) coord.GetFactorValue();
|
||||
}
|
||||
else {
|
||||
length = (float) coord.GetCoordValue();
|
||||
float twipsPerPix;
|
||||
aPresContext->GetScaledPixelsToTwips(&twipsPerPix);
|
||||
if (twipsPerPix == 0.0f)
|
||||
twipsPerPix = 1e-20f;
|
||||
length /= twipsPerPix;
|
||||
}
|
||||
}
|
||||
else if (aValue.GetUnit() == eCSSUnit_Inherit) {
|
||||
length = parentLength;
|
||||
aInherited = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
const nsStyleStruct*
|
||||
nsRuleNode::ComputeSVGData(nsStyleStruct* aStartStruct, const nsCSSStruct& aData,
|
||||
nsIStyleContext* aContext,
|
||||
nsRuleNode* aHighestNode,
|
||||
const RuleDetail& aRuleDetail, PRBool aInherited)
|
||||
{
|
||||
nsCOMPtr<nsIStyleContext> parentContext = getter_AddRefs(aContext->GetParent());
|
||||
|
||||
nsStyleSVG* svg = nsnull;
|
||||
nsStyleSVG* parentSVG = svg;
|
||||
PRBool inherited = aInherited;
|
||||
const nsCSSSVG& SVGData = NS_STATIC_CAST(const nsCSSSVG&, aData);
|
||||
|
||||
if (aStartStruct)
|
||||
// We only need to compute the delta between this computed data and our
|
||||
// computed data.
|
||||
svg = new (mPresContext) nsStyleSVG(*NS_STATIC_CAST(nsStyleSVG*,aStartStruct));
|
||||
else {
|
||||
if (aRuleDetail != eRuleFullMixed) {
|
||||
// No question. We will have to inherit. Go ahead and init
|
||||
// with inherited vals from parent.
|
||||
inherited = PR_TRUE;
|
||||
if (parentContext)
|
||||
parentSVG = (nsStyleSVG*)parentContext->GetStyleData(eStyleStruct_SVG);
|
||||
if (parentSVG)
|
||||
svg = new (mPresContext) nsStyleSVG(*parentSVG);
|
||||
}
|
||||
}
|
||||
|
||||
if (!svg)
|
||||
svg = parentSVG = new (mPresContext) nsStyleSVG();
|
||||
|
||||
// fill:
|
||||
SetSVGPaint(SVGData.mFill, parentSVG->mFill, mPresContext, svg->mFill, inherited);
|
||||
|
||||
// fill-opacity:
|
||||
SetSVGOpacity(SVGData.mFillOpacity, parentSVG->mFillOpacity, svg->mFillOpacity, inherited);
|
||||
|
||||
// fill-rule: enum, inherit
|
||||
if (eCSSUnit_Enumerated == SVGData.mFillRule.GetUnit()) {
|
||||
svg->mFillRule = SVGData.mFillRule.GetIntValue();
|
||||
}
|
||||
else if (eCSSUnit_Inherit == SVGData.mFillRule.GetUnit()) {
|
||||
inherited = PR_TRUE;
|
||||
svg->mFillRule = parentSVG->mFillRule;
|
||||
}
|
||||
|
||||
// stroke:
|
||||
SetSVGPaint(SVGData.mStroke, parentSVG->mStroke, mPresContext, svg->mStroke, inherited);
|
||||
|
||||
// stroke-dasharray: <dasharray>, none, inherit
|
||||
if (eCSSUnit_String == SVGData.mStrokeDasharray.GetUnit()) {
|
||||
SVGData.mStrokeDasharray.GetStringValue(svg->mStrokeDasharray);
|
||||
}
|
||||
else if (eCSSUnit_None == SVGData.mStrokeDasharray.GetUnit()) {
|
||||
svg->mStrokeDasharray.Truncate();
|
||||
}
|
||||
else if (eCSSUnit_Inherit == SVGData.mStrokeDasharray.GetUnit()) {
|
||||
inherited = PR_TRUE;
|
||||
svg->mStrokeDasharray = parentSVG->mStrokeDasharray;
|
||||
}
|
||||
|
||||
// stroke-dashoffset: <dashoffset>, inherit
|
||||
SetSVGLength(SVGData.mStrokeDashoffset, parentSVG->mStrokeDashoffset,
|
||||
svg->mStrokeDashoffset, aContext, mPresContext, inherited);
|
||||
|
||||
// stroke-linecap: enum, inherit
|
||||
if (eCSSUnit_Enumerated == SVGData.mStrokeLinecap.GetUnit()) {
|
||||
svg->mStrokeLinecap = SVGData.mStrokeLinecap.GetIntValue();
|
||||
}
|
||||
else if (eCSSUnit_Inherit == SVGData.mStrokeLinecap.GetUnit()) {
|
||||
inherited = PR_TRUE;
|
||||
svg->mStrokeLinecap = parentSVG->mStrokeLinecap;
|
||||
}
|
||||
|
||||
// stroke-linejoin: enum, inherit
|
||||
if (eCSSUnit_Enumerated == SVGData.mStrokeLinejoin.GetUnit()) {
|
||||
svg->mStrokeLinejoin = SVGData.mStrokeLinejoin.GetIntValue();
|
||||
}
|
||||
else if (eCSSUnit_Inherit == SVGData.mStrokeLinejoin.GetUnit()) {
|
||||
inherited = PR_TRUE;
|
||||
svg->mStrokeLinejoin = parentSVG->mStrokeLinejoin;
|
||||
}
|
||||
|
||||
// stroke-miterlimit: <miterlimit>, inherit
|
||||
if (eCSSUnit_Number == SVGData.mStrokeMiterlimit.GetUnit()) {
|
||||
float value = SVGData.mStrokeMiterlimit.GetFloatValue();
|
||||
if (value > 1) { // XXX this check should probably be in nsCSSParser
|
||||
svg->mStrokeMiterlimit = value;
|
||||
}
|
||||
}
|
||||
else if (eCSSUnit_Inherit == SVGData.mStrokeMiterlimit.GetUnit()) {
|
||||
svg->mStrokeMiterlimit = parentSVG->mStrokeMiterlimit;
|
||||
inherited = PR_TRUE;
|
||||
}
|
||||
|
||||
// stroke-opacity:
|
||||
SetSVGOpacity(SVGData.mStrokeOpacity, parentSVG->mStrokeOpacity, svg->mStrokeOpacity, inherited);
|
||||
|
||||
// stroke-width:
|
||||
SetSVGLength(SVGData.mStrokeWidth, parentSVG->mStrokeWidth,
|
||||
svg->mStrokeWidth, aContext, mPresContext, inherited);
|
||||
|
||||
if (inherited)
|
||||
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
|
||||
// style context.
|
||||
aContext->SetStyle(eStyleStruct_SVG, *svg);
|
||||
else {
|
||||
// We were fully specified and can therefore be cached right on the rule node.
|
||||
if (!aHighestNode->mStyleData.mInheritedData)
|
||||
aHighestNode->mStyleData.mInheritedData = new (mPresContext) nsInheritedStyleData;
|
||||
aHighestNode->mStyleData.mInheritedData->mSVGData = svg;
|
||||
// Propagate the bit down.
|
||||
PropagateInheritBit(NS_STYLE_INHERIT_SVG, aHighestNode);
|
||||
}
|
||||
|
||||
return svg;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline const nsStyleStruct*
|
||||
nsRuleNode::GetParentData(const nsStyleStructID aSID)
|
||||
{
|
||||
|
@ -4468,6 +4685,9 @@ nsRuleNode::gGetStyleDataFn[] = {
|
|||
&nsRuleNode::GetOutlineData,
|
||||
#ifdef INCLUDE_XUL
|
||||
&nsRuleNode::GetXULData,
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
&nsRuleNode::GetSVGData,
|
||||
#endif
|
||||
nsnull
|
||||
};
|
||||
|
|
|
@ -519,6 +519,11 @@ nsStyleContext::SetStyle(nsStyleStructID aSID, const nsStyleStruct& aStruct)
|
|||
case eStyleStruct_XUL:
|
||||
mCachedStyleData.mResetData->mXULData = (nsStyleXUL*)(const nsStyleXUL*)(&aStruct);
|
||||
break;
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
case eStyleStruct_SVG:
|
||||
mCachedStyleData.mInheritedData->mSVGData = (nsStyleSVG*)(const nsStyleSVG*)(&aStruct);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
NS_ERROR("Invalid style struct id");
|
||||
|
@ -683,6 +688,20 @@ nsStyleContext::CalcStyleDifference(nsIStyleContext* aOther, PRInt32& aHint)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
if (aHint < maxHint) {
|
||||
const nsStyleSVG* svg = (const nsStyleSVG*)PeekStyleData(eStyleStruct_SVG);
|
||||
if (svg) {
|
||||
const nsStyleSVG* otherSVG = (const nsStyleSVG*)aOther->GetStyleData(eStyleStruct_SVG);
|
||||
if (svg != otherSVG) {
|
||||
hint = svg->CalcDifference(*otherSVG);
|
||||
if (aHint < hint)
|
||||
aHint = hint;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// At this point, we know that the worst kind of damage we could do is a reflow.
|
||||
maxHint = NS_STYLE_HINT_REFLOW;
|
||||
|
||||
|
@ -1223,6 +1242,18 @@ void nsStyleContext::DumpRegressionData(nsIPresContext* aPresContext, FILE* out,
|
|||
(int)xul->mBoxOrient,
|
||||
(int)xul->mBoxPack,
|
||||
(int)xul->mBoxOrdinal);
|
||||
#endif
|
||||
|
||||
// SVG
|
||||
#ifdef MOZ_SVG
|
||||
IndentBy(out,aIndent);
|
||||
const nsStyleSVG* svg = (const nsStyleSVG*)GetStyleData(eStyleStruct_SVG);
|
||||
fprintf(out, "<svg data=\"%d %f %f %d %f",
|
||||
(int)svg->mStroke.mType,
|
||||
svg->mStrokeWidth,
|
||||
svg->mStrokeOpacity,
|
||||
(int)svg->mFill.mType,
|
||||
svg->mFillOpacity);
|
||||
fprintf(out, "\" />\n");
|
||||
#endif
|
||||
//#insert new style structs here#
|
||||
|
|
|
@ -82,6 +82,13 @@ SHARED_LIBRARY_LIBS = \
|
|||
$(DIST)/lib/libgkconshared_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_SVG
|
||||
SHARED_LIBRARY_LIBS += \
|
||||
$(DIST)/lib/libgkconsvgdoc_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/libgkcontentsvg_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ifdef MOZ_PERF_METRICS
|
||||
SHARED_LIBRARY_LIBS += \
|
||||
$(DIST)/lib/libmozutil_s.$(LIB_SUFFIX) \
|
||||
|
|
|
@ -82,6 +82,10 @@ SUB_LIBRARIES=\
|
|||
$(DIST)\lib\contentxuldocument_s.lib \
|
||||
$(DIST)\lib\contentxultemplates_s.lib \
|
||||
$(DIST)\lib\contentxbl_s.lib \
|
||||
!ifdef MOZ_SVG
|
||||
$(DIST)\lib\contentsvgdoc_s.lib \
|
||||
$(DIST)\lib\contentsvg_s.lib \
|
||||
!endif
|
||||
$(DIST)\lib\contentevents_s.lib \
|
||||
$(DIST)\lib\contentshared_s.lib \
|
||||
$(NULL)
|
||||
|
|
|
@ -269,4 +269,22 @@
|
|||
#define NS_RANGEUTILS_CID \
|
||||
{ 0xa6cf9126, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
|
||||
// {4E48C00A-E20F-4061-B869-2BAC285D68E8}
|
||||
#define NS_SVGELEMENTFACTORY_DEPRECATED_CID \
|
||||
{ 0x4e48c00a, 0xe20f, 0x4061, { 0xb8, 0x69, 0x2b, 0xac, 0x28, 0x5d, 0x68, 0xe8 } }
|
||||
|
||||
|
||||
// {34D9B28A-FBFF-4bbd-8546-1822FE3FB8B5}
|
||||
#define NS_SVGELEMENTFACTORY_CID \
|
||||
{ 0x34d9b28a, 0xfbff, 0x4bbd, { 0x85, 0x46, 0x18, 0x22, 0xfe, 0x3f, 0xb8, 0xb5 } }
|
||||
|
||||
#define NS_SVGDOCUMENT_CID \
|
||||
{ /* b7f44954-1dd1-11b2-8c2e-c2feab4186bc */ \
|
||||
0xb7f44954, 0x11d1, 0x11b2, \
|
||||
{0x8c, 0x2e, 0xc2, 0xfe, 0xab, 0x41, 0x86, 0xbc}}
|
||||
|
||||
#endif // MOZ_SVG
|
||||
|
||||
#endif /* nsContentCID_h__ */
|
||||
|
|
|
@ -70,6 +70,9 @@
|
|||
|
||||
static NS_DEFINE_IID(kHTMLDocumentCID, NS_HTMLDOCUMENT_CID);
|
||||
static NS_DEFINE_IID(kXMLDocumentCID, NS_XMLDOCUMENT_CID);
|
||||
#ifdef MOZ_SVG
|
||||
static NS_DEFINE_IID(kSVGDocumentCID, NS_SVGDOCUMENT_CID);
|
||||
#endif
|
||||
static NS_DEFINE_IID(kImageDocumentCID, NS_IMAGEDOCUMENT_CID);
|
||||
static NS_DEFINE_IID(kXULDocumentCID, NS_XULDOCUMENT_CID);
|
||||
|
||||
|
@ -99,6 +102,13 @@ static const char* const gXMLTypes[] = {
|
|||
0
|
||||
};
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
static char* gSVGTypes[] = {
|
||||
"image/svg+xml",
|
||||
"image/svg+xml; x-view-type=view-source",
|
||||
0
|
||||
};
|
||||
#endif
|
||||
|
||||
static const char* const gRDFTypes[] = {
|
||||
"text/rdf",
|
||||
|
@ -241,6 +251,19 @@ nsContentDLF::CreateInstance(const char* aCommand,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// Try SVG
|
||||
typeIndex = 0;
|
||||
while(gSVGTypes[typeIndex]) {
|
||||
if (!PL_strcmp(gSVGTypes[typeIndex++], aContentType)) {
|
||||
return CreateDocument(aCommand,
|
||||
aChannel, aLoadGroup,
|
||||
aContainer, kSVGDocumentCID,
|
||||
aDocListener, aDocViewer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Try RDF
|
||||
typeIndex = 0;
|
||||
while (gRDFTypes[typeIndex]) {
|
||||
|
@ -610,6 +633,14 @@ nsContentDLF::RegisterDocumentFactories(nsIComponentManager* aCompMgr,
|
|||
rv = RegisterTypes(aCompMgr, catmgr, "view-source", aPath, aLocation, aType, gXMLTypes);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
#ifdef MOZ_SVG
|
||||
rv = RegisterTypes(aCompMgr, catmgr, "view", aPath, aLocation, aType, gSVGTypes);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
rv = RegisterTypes(aCompMgr, catmgr, "view-source", aPath, aLocation, aType, gSVGTypes);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
#endif
|
||||
rv = RegisterTypes(aCompMgr, catmgr, "view", aPath, aLocation, aType, gImageTypes);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
|
|
@ -126,6 +126,10 @@ class nsIDocumentLoaderFactory;
|
|||
#include "nsXULElement.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
#include "nsSVGAtoms.h"
|
||||
#endif
|
||||
|
||||
// jst says, ``we need this to avoid holding on to XPConnect past its
|
||||
// destruction. By being an XPCOM shutdown observer we can make sure
|
||||
// we release the content global reference to XPConnect before
|
||||
|
@ -181,6 +185,10 @@ Initialize(nsIModule* aSelf)
|
|||
nsXULContentUtils::Init();
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
nsSVGAtoms::AddRefAtoms();
|
||||
#endif
|
||||
|
||||
nsContentUtils::Init();
|
||||
|
||||
// Add our shutdown observer.
|
||||
|
@ -226,6 +234,10 @@ Shutdown(nsIModule* aSelf)
|
|||
nsXULElement::ReleaseGlobals();
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
nsSVGAtoms::ReleaseAtoms();
|
||||
#endif
|
||||
|
||||
NS_IF_RELEASE(nsContentDLF::gUAStyleSheet);
|
||||
NS_IF_RELEASE(nsRuleNode::gLangService);
|
||||
nsContentUtils::Shutdown();
|
||||
|
@ -257,6 +269,10 @@ extern nsresult NS_NewXULElementFactory(nsIElementFactory** aResult);
|
|||
extern NS_IMETHODIMP NS_NewXULControllers(nsISupports* aOuter, REFNSIID aIID, void** aResult);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
extern nsresult NS_NewSVGElementFactory(nsIElementFactory** aResult);
|
||||
#endif
|
||||
|
||||
#define MAKE_CTOR(ctor_, iface_, func_) \
|
||||
static NS_IMETHODIMP \
|
||||
ctor_(nsISupports* aOuter, REFNSIID aIID, void** aResult) \
|
||||
|
@ -284,6 +300,9 @@ MAKE_CTOR(CreateHTMLDocument, nsIDocument, NS_NewHTM
|
|||
MAKE_CTOR(CreateHTMLCSSStyleSheet, nsIHTMLCSSStyleSheet, NS_NewHTMLCSSStyleSheet)
|
||||
MAKE_CTOR(CreateDOMImplementation, nsIDOMDOMImplementation, NS_NewDOMImplementation)
|
||||
MAKE_CTOR(CreateXMLDocument, nsIDocument, NS_NewXMLDocument)
|
||||
#ifdef MOZ_SVG
|
||||
MAKE_CTOR(CreateSVGDocument, nsIDocument, NS_NewSVGDocument)
|
||||
#endif
|
||||
MAKE_CTOR(CreateImageDocument, nsIDocument, NS_NewImageDocument)
|
||||
MAKE_CTOR(CreateCSSParser, nsICSSParser, NS_NewCSSParser)
|
||||
MAKE_CTOR(CreateCSSLoader, nsICSSLoader, NS_NewCSSLoader)
|
||||
|
@ -324,6 +343,9 @@ MAKE_CTOR(CreateXULPopupListener, nsIXULPopupListener, NS_NewXUL
|
|||
// NS_NewXULPrototypeCache
|
||||
MAKE_CTOR(CreateXULElementFactory, nsIElementFactory, NS_NewXULElementFactory)
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
MAKE_CTOR(CreateSVGElementFactory, nsIElementFactory, NS_NewSVGElementFactory)
|
||||
#endif
|
||||
MAKE_CTOR(CreateControllerCommandManager, nsIControllerCommandManager, NS_NewControllerCommandManager)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsContentHTTPStartup)
|
||||
MAKE_CTOR(CreateContentDLF, nsIDocumentLoaderFactory, NS_NewContentDocumentLoaderFactory)
|
||||
|
@ -477,6 +499,13 @@ static nsModuleComponentInfo gComponents[] = {
|
|||
nsnull,
|
||||
CreateXMLDocument },
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
{ "SVG document",
|
||||
NS_SVGDOCUMENT_CID,
|
||||
nsnull,
|
||||
CreateSVGDocument },
|
||||
#endif
|
||||
|
||||
{ "Image document",
|
||||
NS_IMAGEDOCUMENT_CID,
|
||||
nsnull,
|
||||
|
@ -601,6 +630,13 @@ static nsModuleComponentInfo gComponents[] = {
|
|||
NS_DOC_ENCODER_CONTRACTID_BASE "application/xhtml+xml",
|
||||
CreateTextEncoder },
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
{ "SVG document encoder",
|
||||
NS_TEXT_ENCODER_CID,
|
||||
NS_DOC_ENCODER_CONTRACTID_BASE "image/svg+xml",
|
||||
CreateTextEncoder },
|
||||
#endif
|
||||
|
||||
{ "HTML document encoder",
|
||||
NS_TEXT_ENCODER_CID,
|
||||
NS_DOC_ENCODER_CONTRACTID_BASE "text/html",
|
||||
|
@ -631,6 +667,13 @@ static nsModuleComponentInfo gComponents[] = {
|
|||
NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "application/xhtml+xml",
|
||||
CreateXMLContentSerializer },
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
{ "SVG content serializer",
|
||||
NS_XMLCONTENTSERIALIZER_CID,
|
||||
NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "image/svg+xml",
|
||||
CreateXMLContentSerializer },
|
||||
#endif
|
||||
|
||||
{ "HTML content serializer",
|
||||
NS_HTMLCONTENTSERIALIZER_CID,
|
||||
NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "text/html",
|
||||
|
@ -728,6 +771,18 @@ static nsModuleComponentInfo gComponents[] = {
|
|||
CreateXULElementFactory },
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
{ "SVG element factory (deprecated namespace)",
|
||||
NS_SVGELEMENTFACTORY_CID,
|
||||
NS_SVG_DEPRECATED_ELEMENT_FACTORY_CONTRACTID,
|
||||
CreateSVGElementFactory },
|
||||
|
||||
{ "SVG element factory",
|
||||
NS_SVGELEMENTFACTORY_CID,
|
||||
NS_SVG_ELEMENT_FACTORY_CONTRACTID,
|
||||
CreateSVGElementFactory },
|
||||
#endif
|
||||
|
||||
{ "Controller Command Manager",
|
||||
NS_CONTROLLERCOMMANDMANAGER_CID,
|
||||
"@mozilla.org/content/controller-command-manager;1",
|
||||
|
|
|
@ -70,6 +70,10 @@ static NS_DEFINE_IID(kCSSAuralSID, NS_CSS_AURAL_SID);
|
|||
static NS_DEFINE_IID(kCSSXULSID, NS_CSS_XUL_SID);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
static NS_DEFINE_IID(kCSSSVGSID, NS_CSS_SVG_SID);
|
||||
#endif
|
||||
|
||||
#define CSS_IF_DELETE(ptr) if (nsnull != ptr) { delete ptr; ptr = nsnull; }
|
||||
|
||||
nsCSSStruct::~nsCSSStruct()
|
||||
|
@ -1075,6 +1079,62 @@ void nsCSSXUL::List(FILE* out, PRInt32 aIndent) const
|
|||
|
||||
#endif // INCLUDE_XUL
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// --- nsCSSSVG -----------------
|
||||
|
||||
nsCSSSVG::nsCSSSVG(void)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsCSSSVG);
|
||||
}
|
||||
|
||||
nsCSSSVG::nsCSSSVG(const nsCSSSVG& aCopy)
|
||||
: mFill(aCopy.mFill),
|
||||
mFillOpacity(aCopy.mFillOpacity),
|
||||
mFillRule(aCopy.mFillRule),
|
||||
mStroke(aCopy.mStroke),
|
||||
mStrokeDasharray(aCopy.mStrokeDasharray),
|
||||
mStrokeDashoffset(aCopy.mStrokeDashoffset),
|
||||
mStrokeLinecap(aCopy.mStrokeLinecap),
|
||||
mStrokeLinejoin(aCopy.mStrokeLinejoin),
|
||||
mStrokeMiterlimit(aCopy.mStrokeMiterlimit),
|
||||
mStrokeOpacity(aCopy.mStrokeOpacity),
|
||||
mStrokeWidth(aCopy.mStrokeWidth)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsCSSSVG);
|
||||
}
|
||||
|
||||
nsCSSSVG::~nsCSSSVG(void)
|
||||
{
|
||||
MOZ_COUNT_DTOR(nsCSSSVG);
|
||||
}
|
||||
|
||||
const nsID& nsCSSSVG::GetID(void)
|
||||
{
|
||||
return kCSSSVGSID;
|
||||
}
|
||||
|
||||
void nsCSSSVG::List(FILE* out, PRInt32 aIndent) const
|
||||
{
|
||||
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
|
||||
nsAutoString buffer;
|
||||
|
||||
mFill.AppendToString(buffer, eCSSProperty_fill);
|
||||
mFillOpacity.AppendToString(buffer, eCSSProperty_fill_opacity);
|
||||
mFillRule.AppendToString(buffer, eCSSProperty_fill_rule);
|
||||
mStroke.AppendToString(buffer, eCSSProperty_stroke);
|
||||
mStrokeDasharray.AppendToString(buffer, eCSSProperty_stroke_dasharray);
|
||||
mStrokeDashoffset.AppendToString(buffer, eCSSProperty_stroke_dashoffset);
|
||||
mStrokeLinecap.AppendToString(buffer, eCSSProperty_stroke_linecap);
|
||||
mStrokeLinejoin.AppendToString(buffer, eCSSProperty_stroke_linejoin);
|
||||
mStrokeMiterlimit.AppendToString(buffer, eCSSProperty_stroke_miterlimit);
|
||||
mStrokeOpacity.AppendToString(buffer, eCSSProperty_stroke_opacity);
|
||||
mStrokeWidth.AppendToString(buffer, eCSSProperty_stroke_width);
|
||||
fputs(NS_LossyConvertUCS2toASCII(buffer).get(), out);
|
||||
}
|
||||
|
||||
#endif // MOZ_SVG
|
||||
|
||||
|
||||
// --- nsCSSDeclaration -----------------
|
||||
|
||||
|
@ -1185,6 +1245,10 @@ protected:
|
|||
nsCSSXUL* mXUL;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
nsCSSSVG* mSVG;
|
||||
#endif
|
||||
|
||||
CSSDeclarationImpl* mImportant;
|
||||
|
||||
nsVoidArray* mOrder;
|
||||
|
@ -1230,6 +1294,10 @@ CSSDeclarationImpl::CSSDeclarationImpl(const CSSDeclarationImpl& aCopy)
|
|||
DECL_IF_COPY(XUL);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
DECL_IF_COPY(SVG);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_REFS
|
||||
++gInstanceCount;
|
||||
fprintf(stdout, "CSSDeclaration Instances (cp-ctor): %ld\n", (long)gInstanceCount);
|
||||
|
@ -1275,6 +1343,10 @@ CSSDeclarationImpl::~CSSDeclarationImpl(void)
|
|||
CSS_IF_DELETE(mXUL);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
CSS_IF_DELETE(mSVG);
|
||||
#endif
|
||||
|
||||
NS_IF_RELEASE(mImportant);
|
||||
CSS_IF_DELETE(mOrder);
|
||||
CSS_IF_DELETE(mComments);
|
||||
|
@ -1312,6 +1384,9 @@ CSSDeclarationImpl::GetData(const nsID& aSID, nsCSSStruct** aDataPtr)
|
|||
CSS_IF_GET_ELSE(aSID, Aural, aDataPtr)
|
||||
#ifdef INCLUDE_XUL
|
||||
CSS_IF_GET_ELSE(aSID, XUL, aDataPtr)
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
CSS_IF_GET_ELSE(aSID, SVG, aDataPtr)
|
||||
#endif
|
||||
{
|
||||
return NS_NOINTERFACE;
|
||||
|
@ -1884,6 +1959,39 @@ CSSDeclarationImpl::AppendValue(nsCSSProperty aProperty, const nsCSSValue& aValu
|
|||
break;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// nsCSSSVG
|
||||
case eCSSProperty_fill:
|
||||
case eCSSProperty_fill_opacity:
|
||||
case eCSSProperty_fill_rule:
|
||||
case eCSSProperty_stroke:
|
||||
case eCSSProperty_stroke_dasharray:
|
||||
case eCSSProperty_stroke_dashoffset:
|
||||
case eCSSProperty_stroke_linecap:
|
||||
case eCSSProperty_stroke_linejoin:
|
||||
case eCSSProperty_stroke_miterlimit:
|
||||
case eCSSProperty_stroke_opacity:
|
||||
case eCSSProperty_stroke_width:
|
||||
CSS_ENSURE(SVG) {
|
||||
switch (aProperty) {
|
||||
case eCSSProperty_fill: mSVG->mFill = aValue; break;
|
||||
case eCSSProperty_fill_opacity: mSVG->mFillOpacity = aValue; break;
|
||||
case eCSSProperty_fill_rule: mSVG->mFillRule = aValue; break;
|
||||
case eCSSProperty_stroke: mSVG->mStroke = aValue; break;
|
||||
case eCSSProperty_stroke_dasharray: mSVG->mStrokeDasharray = aValue; break;
|
||||
case eCSSProperty_stroke_dashoffset: mSVG->mStrokeDashoffset = aValue; break;
|
||||
case eCSSProperty_stroke_linecap: mSVG->mStrokeLinecap = aValue; break;
|
||||
case eCSSProperty_stroke_linejoin: mSVG->mStrokeLinejoin = aValue; break;
|
||||
case eCSSProperty_stroke_miterlimit: mSVG->mStrokeMiterlimit = aValue; break;
|
||||
case eCSSProperty_stroke_opacity: mSVG->mStrokeOpacity = aValue; break;
|
||||
case eCSSProperty_stroke_width: mSVG->mStrokeWidth = aValue; break;
|
||||
CSS_BOGUS_DEFAULT; // make compiler happy
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
// nsCSSAural
|
||||
case eCSSProperty_azimuth:
|
||||
case eCSSProperty_elevation:
|
||||
|
@ -2747,6 +2855,40 @@ CSSDeclarationImpl::SetValueImportant(nsCSSProperty aProperty)
|
|||
break;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// nsCSSSVG
|
||||
case eCSSProperty_fill:
|
||||
case eCSSProperty_fill_opacity:
|
||||
case eCSSProperty_fill_rule:
|
||||
case eCSSProperty_stroke:
|
||||
case eCSSProperty_stroke_dasharray:
|
||||
case eCSSProperty_stroke_dashoffset:
|
||||
case eCSSProperty_stroke_linecap:
|
||||
case eCSSProperty_stroke_linejoin:
|
||||
case eCSSProperty_stroke_miterlimit:
|
||||
case eCSSProperty_stroke_opacity:
|
||||
case eCSSProperty_stroke_width:
|
||||
if (nsnull != mSVG) {
|
||||
CSS_ENSURE_IMPORTANT(SVG) {
|
||||
switch (aProperty) {
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_fill, mSVG->mFill);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_fill_opacity, mSVG->mFillOpacity);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_fill_rule, mSVG->mFillRule);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_stroke, mSVG->mStroke);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_stroke_dasharray, mSVG->mStrokeDasharray);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_stroke_dashoffset, mSVG->mStrokeDashoffset);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_stroke_linecap, mSVG->mStrokeLinecap);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_stroke_linejoin, mSVG->mStrokeLinejoin);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_stroke_miterlimit, mSVG->mStrokeMiterlimit);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_stroke_opacity, mSVG->mStrokeOpacity);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_stroke_width, mSVG->mStrokeWidth);
|
||||
CSS_BOGUS_DEFAULT; // make compiler happy
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
// nsCSSAural
|
||||
case eCSSProperty_azimuth:
|
||||
case eCSSProperty_elevation:
|
||||
|
@ -3483,6 +3625,39 @@ CSSDeclarationImpl::RemoveProperty(nsCSSProperty aProperty)
|
|||
break;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// nsCSSSVG
|
||||
case eCSSProperty_fill:
|
||||
case eCSSProperty_fill_opacity:
|
||||
case eCSSProperty_fill_rule:
|
||||
case eCSSProperty_stroke:
|
||||
case eCSSProperty_stroke_dasharray:
|
||||
case eCSSProperty_stroke_dashoffset:
|
||||
case eCSSProperty_stroke_linecap:
|
||||
case eCSSProperty_stroke_linejoin:
|
||||
case eCSSProperty_stroke_miterlimit:
|
||||
case eCSSProperty_stroke_opacity:
|
||||
case eCSSProperty_stroke_width:
|
||||
CSS_CHECK(SVG) {
|
||||
switch(aProperty) {
|
||||
case eCSSProperty_fill: mSVG->mFill.Reset(); break;
|
||||
case eCSSProperty_fill_opacity: mSVG->mFillOpacity.Reset(); break;
|
||||
case eCSSProperty_fill_rule: mSVG->mFillRule.Reset(); break;
|
||||
case eCSSProperty_stroke: mSVG->mStroke.Reset(); break;
|
||||
case eCSSProperty_stroke_dasharray: mSVG->mStrokeDasharray.Reset(); break;
|
||||
case eCSSProperty_stroke_dashoffset: mSVG->mStrokeDashoffset.Reset(); break;
|
||||
case eCSSProperty_stroke_linecap: mSVG->mStrokeLinecap.Reset(); break;
|
||||
case eCSSProperty_stroke_linejoin: mSVG->mStrokeLinejoin.Reset(); break;
|
||||
case eCSSProperty_stroke_miterlimit: mSVG->mStrokeMiterlimit.Reset(); break;
|
||||
case eCSSProperty_stroke_opacity: mSVG->mStrokeOpacity.Reset(); break;
|
||||
case eCSSProperty_stroke_width: mSVG->mStrokeWidth.Reset(); break;
|
||||
CSS_BOGUS_DEFAULT; // Make compiler happy
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
// nsCSSAural
|
||||
case eCSSProperty_azimuth:
|
||||
case eCSSProperty_elevation:
|
||||
|
@ -4258,6 +4433,41 @@ CSSDeclarationImpl::GetValue(nsCSSProperty aProperty, nsCSSValue& aValue)
|
|||
break;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// nsCSSSVG
|
||||
case eCSSProperty_fill:
|
||||
case eCSSProperty_fill_opacity:
|
||||
case eCSSProperty_fill_rule:
|
||||
case eCSSProperty_stroke:
|
||||
case eCSSProperty_stroke_dasharray:
|
||||
case eCSSProperty_stroke_dashoffset:
|
||||
case eCSSProperty_stroke_linecap:
|
||||
case eCSSProperty_stroke_linejoin:
|
||||
case eCSSProperty_stroke_miterlimit:
|
||||
case eCSSProperty_stroke_opacity:
|
||||
case eCSSProperty_stroke_width:
|
||||
if (nsnull != mSVG) {
|
||||
switch (aProperty) {
|
||||
case eCSSProperty_fill: aValue = mSVG->mFill; break;
|
||||
case eCSSProperty_fill_opacity: aValue = mSVG->mFillOpacity; break;
|
||||
case eCSSProperty_fill_rule: aValue = mSVG->mFillRule; break;
|
||||
case eCSSProperty_stroke: aValue = mSVG->mStroke; break;
|
||||
case eCSSProperty_stroke_dasharray: aValue = mSVG->mStrokeDasharray; break;
|
||||
case eCSSProperty_stroke_dashoffset: aValue = mSVG->mStrokeDashoffset; break;
|
||||
case eCSSProperty_stroke_linecap: aValue = mSVG->mStrokeLinecap; break;
|
||||
case eCSSProperty_stroke_linejoin: aValue = mSVG->mStrokeLinejoin; break;
|
||||
case eCSSProperty_stroke_miterlimit: aValue = mSVG->mStrokeMiterlimit; break;
|
||||
case eCSSProperty_stroke_opacity: aValue = mSVG->mStrokeOpacity; break;
|
||||
case eCSSProperty_stroke_width: aValue = mSVG->mStrokeWidth; break;
|
||||
CSS_BOGUS_DEFAULT; // make compiler happy
|
||||
}
|
||||
}
|
||||
else {
|
||||
aValue.Reset();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
// nsCSSAural
|
||||
case eCSSProperty_azimuth:
|
||||
case eCSSProperty_elevation:
|
||||
|
@ -5438,6 +5648,11 @@ void CSSDeclarationImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSiz
|
|||
if(mXUL && uniqueItems->AddItem(mXUL)){
|
||||
aSize += sizeof(*mXUL);
|
||||
}
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
if(mSVG && uniqueItems->AddItem(mSVG)){
|
||||
aSize += sizeof(*mSVG);
|
||||
}
|
||||
#endif
|
||||
if(mAural && uniqueItems->AddItem(mAural)){
|
||||
aSize += sizeof(*mAural);
|
||||
|
|
|
@ -3672,6 +3672,41 @@ PRBool CSSParserImpl::ParseSingleValueProperty(PRInt32& aErrorCode,
|
|||
nsCSSProps::kBoxPackKTable);
|
||||
case eCSSProperty_box_ordinal_group:
|
||||
return ParseVariant(aErrorCode, aValue, VARIANT_INTEGER, nsnull);
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
case eCSSProperty_fill:
|
||||
return ParseVariant(aErrorCode, aValue, VARIANT_HC | VARIANT_NONE,
|
||||
nsnull);
|
||||
case eCSSProperty_fill_opacity:
|
||||
return ParseVariant(aErrorCode, aValue, VARIANT_HN,
|
||||
nsnull);
|
||||
case eCSSProperty_fill_rule:
|
||||
return ParseVariant(aErrorCode, aValue, VARIANT_HK,
|
||||
nsCSSProps::kFillRuleKTable);
|
||||
case eCSSProperty_stroke:
|
||||
return ParseVariant(aErrorCode, aValue, VARIANT_HC | VARIANT_NONE,
|
||||
nsnull);
|
||||
case eCSSProperty_stroke_dasharray:
|
||||
return ParseVariant(aErrorCode, aValue, VARIANT_HOS,
|
||||
nsnull); // XXX parse into new CSS value type, not string
|
||||
case eCSSProperty_stroke_dashoffset:
|
||||
return ParseVariant(aErrorCode, aValue, VARIANT_HLPN,
|
||||
nsnull);
|
||||
case eCSSProperty_stroke_linecap:
|
||||
return ParseVariant(aErrorCode, aValue, VARIANT_HK,
|
||||
nsCSSProps::kStrokeLinecapKTable);
|
||||
case eCSSProperty_stroke_linejoin:
|
||||
return ParseVariant(aErrorCode, aValue, VARIANT_HK,
|
||||
nsCSSProps::kStrokeLinejoinKTable);
|
||||
case eCSSProperty_stroke_miterlimit:
|
||||
return ParsePositiveVariant(aErrorCode, aValue, VARIANT_HN,
|
||||
nsnull); // XXX value > 1
|
||||
case eCSSProperty_stroke_opacity:
|
||||
return ParseVariant(aErrorCode, aValue, VARIANT_HN,
|
||||
nsnull);
|
||||
case eCSSProperty_stroke_width:
|
||||
return ParsePositiveVariant(aErrorCode, aValue, VARIANT_HLPN,
|
||||
nsnull);
|
||||
#endif
|
||||
case eCSSProperty_box_sizing:
|
||||
return ParseVariant(aErrorCode, aValue, VARIANT_HK,
|
||||
|
|
|
@ -70,6 +70,10 @@ static NS_DEFINE_IID(kCSSAuralSID, NS_CSS_AURAL_SID);
|
|||
static NS_DEFINE_IID(kCSSXULSID, NS_CSS_XUL_SID);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
static NS_DEFINE_IID(kCSSSVGSID, NS_CSS_SVG_SID);
|
||||
#endif
|
||||
|
||||
#define CSS_IF_DELETE(ptr) if (nsnull != ptr) { delete ptr; ptr = nsnull; }
|
||||
|
||||
nsCSSStruct::~nsCSSStruct()
|
||||
|
@ -1075,6 +1079,62 @@ void nsCSSXUL::List(FILE* out, PRInt32 aIndent) const
|
|||
|
||||
#endif // INCLUDE_XUL
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// --- nsCSSSVG -----------------
|
||||
|
||||
nsCSSSVG::nsCSSSVG(void)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsCSSSVG);
|
||||
}
|
||||
|
||||
nsCSSSVG::nsCSSSVG(const nsCSSSVG& aCopy)
|
||||
: mFill(aCopy.mFill),
|
||||
mFillOpacity(aCopy.mFillOpacity),
|
||||
mFillRule(aCopy.mFillRule),
|
||||
mStroke(aCopy.mStroke),
|
||||
mStrokeDasharray(aCopy.mStrokeDasharray),
|
||||
mStrokeDashoffset(aCopy.mStrokeDashoffset),
|
||||
mStrokeLinecap(aCopy.mStrokeLinecap),
|
||||
mStrokeLinejoin(aCopy.mStrokeLinejoin),
|
||||
mStrokeMiterlimit(aCopy.mStrokeMiterlimit),
|
||||
mStrokeOpacity(aCopy.mStrokeOpacity),
|
||||
mStrokeWidth(aCopy.mStrokeWidth)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsCSSSVG);
|
||||
}
|
||||
|
||||
nsCSSSVG::~nsCSSSVG(void)
|
||||
{
|
||||
MOZ_COUNT_DTOR(nsCSSSVG);
|
||||
}
|
||||
|
||||
const nsID& nsCSSSVG::GetID(void)
|
||||
{
|
||||
return kCSSSVGSID;
|
||||
}
|
||||
|
||||
void nsCSSSVG::List(FILE* out, PRInt32 aIndent) const
|
||||
{
|
||||
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
|
||||
nsAutoString buffer;
|
||||
|
||||
mFill.AppendToString(buffer, eCSSProperty_fill);
|
||||
mFillOpacity.AppendToString(buffer, eCSSProperty_fill_opacity);
|
||||
mFillRule.AppendToString(buffer, eCSSProperty_fill_rule);
|
||||
mStroke.AppendToString(buffer, eCSSProperty_stroke);
|
||||
mStrokeDasharray.AppendToString(buffer, eCSSProperty_stroke_dasharray);
|
||||
mStrokeDashoffset.AppendToString(buffer, eCSSProperty_stroke_dashoffset);
|
||||
mStrokeLinecap.AppendToString(buffer, eCSSProperty_stroke_linecap);
|
||||
mStrokeLinejoin.AppendToString(buffer, eCSSProperty_stroke_linejoin);
|
||||
mStrokeMiterlimit.AppendToString(buffer, eCSSProperty_stroke_miterlimit);
|
||||
mStrokeOpacity.AppendToString(buffer, eCSSProperty_stroke_opacity);
|
||||
mStrokeWidth.AppendToString(buffer, eCSSProperty_stroke_width);
|
||||
fputs(NS_LossyConvertUCS2toASCII(buffer).get(), out);
|
||||
}
|
||||
|
||||
#endif // MOZ_SVG
|
||||
|
||||
|
||||
// --- nsCSSDeclaration -----------------
|
||||
|
||||
|
@ -1185,6 +1245,10 @@ protected:
|
|||
nsCSSXUL* mXUL;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
nsCSSSVG* mSVG;
|
||||
#endif
|
||||
|
||||
CSSDeclarationImpl* mImportant;
|
||||
|
||||
nsVoidArray* mOrder;
|
||||
|
@ -1230,6 +1294,10 @@ CSSDeclarationImpl::CSSDeclarationImpl(const CSSDeclarationImpl& aCopy)
|
|||
DECL_IF_COPY(XUL);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
DECL_IF_COPY(SVG);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_REFS
|
||||
++gInstanceCount;
|
||||
fprintf(stdout, "CSSDeclaration Instances (cp-ctor): %ld\n", (long)gInstanceCount);
|
||||
|
@ -1275,6 +1343,10 @@ CSSDeclarationImpl::~CSSDeclarationImpl(void)
|
|||
CSS_IF_DELETE(mXUL);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
CSS_IF_DELETE(mSVG);
|
||||
#endif
|
||||
|
||||
NS_IF_RELEASE(mImportant);
|
||||
CSS_IF_DELETE(mOrder);
|
||||
CSS_IF_DELETE(mComments);
|
||||
|
@ -1312,6 +1384,9 @@ CSSDeclarationImpl::GetData(const nsID& aSID, nsCSSStruct** aDataPtr)
|
|||
CSS_IF_GET_ELSE(aSID, Aural, aDataPtr)
|
||||
#ifdef INCLUDE_XUL
|
||||
CSS_IF_GET_ELSE(aSID, XUL, aDataPtr)
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
CSS_IF_GET_ELSE(aSID, SVG, aDataPtr)
|
||||
#endif
|
||||
{
|
||||
return NS_NOINTERFACE;
|
||||
|
@ -1884,6 +1959,39 @@ CSSDeclarationImpl::AppendValue(nsCSSProperty aProperty, const nsCSSValue& aValu
|
|||
break;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// nsCSSSVG
|
||||
case eCSSProperty_fill:
|
||||
case eCSSProperty_fill_opacity:
|
||||
case eCSSProperty_fill_rule:
|
||||
case eCSSProperty_stroke:
|
||||
case eCSSProperty_stroke_dasharray:
|
||||
case eCSSProperty_stroke_dashoffset:
|
||||
case eCSSProperty_stroke_linecap:
|
||||
case eCSSProperty_stroke_linejoin:
|
||||
case eCSSProperty_stroke_miterlimit:
|
||||
case eCSSProperty_stroke_opacity:
|
||||
case eCSSProperty_stroke_width:
|
||||
CSS_ENSURE(SVG) {
|
||||
switch (aProperty) {
|
||||
case eCSSProperty_fill: mSVG->mFill = aValue; break;
|
||||
case eCSSProperty_fill_opacity: mSVG->mFillOpacity = aValue; break;
|
||||
case eCSSProperty_fill_rule: mSVG->mFillRule = aValue; break;
|
||||
case eCSSProperty_stroke: mSVG->mStroke = aValue; break;
|
||||
case eCSSProperty_stroke_dasharray: mSVG->mStrokeDasharray = aValue; break;
|
||||
case eCSSProperty_stroke_dashoffset: mSVG->mStrokeDashoffset = aValue; break;
|
||||
case eCSSProperty_stroke_linecap: mSVG->mStrokeLinecap = aValue; break;
|
||||
case eCSSProperty_stroke_linejoin: mSVG->mStrokeLinejoin = aValue; break;
|
||||
case eCSSProperty_stroke_miterlimit: mSVG->mStrokeMiterlimit = aValue; break;
|
||||
case eCSSProperty_stroke_opacity: mSVG->mStrokeOpacity = aValue; break;
|
||||
case eCSSProperty_stroke_width: mSVG->mStrokeWidth = aValue; break;
|
||||
CSS_BOGUS_DEFAULT; // make compiler happy
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
// nsCSSAural
|
||||
case eCSSProperty_azimuth:
|
||||
case eCSSProperty_elevation:
|
||||
|
@ -2747,6 +2855,40 @@ CSSDeclarationImpl::SetValueImportant(nsCSSProperty aProperty)
|
|||
break;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// nsCSSSVG
|
||||
case eCSSProperty_fill:
|
||||
case eCSSProperty_fill_opacity:
|
||||
case eCSSProperty_fill_rule:
|
||||
case eCSSProperty_stroke:
|
||||
case eCSSProperty_stroke_dasharray:
|
||||
case eCSSProperty_stroke_dashoffset:
|
||||
case eCSSProperty_stroke_linecap:
|
||||
case eCSSProperty_stroke_linejoin:
|
||||
case eCSSProperty_stroke_miterlimit:
|
||||
case eCSSProperty_stroke_opacity:
|
||||
case eCSSProperty_stroke_width:
|
||||
if (nsnull != mSVG) {
|
||||
CSS_ENSURE_IMPORTANT(SVG) {
|
||||
switch (aProperty) {
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_fill, mSVG->mFill);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_fill_opacity, mSVG->mFillOpacity);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_fill_rule, mSVG->mFillRule);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_stroke, mSVG->mStroke);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_stroke_dasharray, mSVG->mStrokeDasharray);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_stroke_dashoffset, mSVG->mStrokeDashoffset);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_stroke_linecap, mSVG->mStrokeLinecap);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_stroke_linejoin, mSVG->mStrokeLinejoin);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_stroke_miterlimit, mSVG->mStrokeMiterlimit);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_stroke_opacity, mSVG->mStrokeOpacity);
|
||||
CSS_CASE_IMPORTANT(eCSSProperty_stroke_width, mSVG->mStrokeWidth);
|
||||
CSS_BOGUS_DEFAULT; // make compiler happy
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
// nsCSSAural
|
||||
case eCSSProperty_azimuth:
|
||||
case eCSSProperty_elevation:
|
||||
|
@ -3483,6 +3625,39 @@ CSSDeclarationImpl::RemoveProperty(nsCSSProperty aProperty)
|
|||
break;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// nsCSSSVG
|
||||
case eCSSProperty_fill:
|
||||
case eCSSProperty_fill_opacity:
|
||||
case eCSSProperty_fill_rule:
|
||||
case eCSSProperty_stroke:
|
||||
case eCSSProperty_stroke_dasharray:
|
||||
case eCSSProperty_stroke_dashoffset:
|
||||
case eCSSProperty_stroke_linecap:
|
||||
case eCSSProperty_stroke_linejoin:
|
||||
case eCSSProperty_stroke_miterlimit:
|
||||
case eCSSProperty_stroke_opacity:
|
||||
case eCSSProperty_stroke_width:
|
||||
CSS_CHECK(SVG) {
|
||||
switch(aProperty) {
|
||||
case eCSSProperty_fill: mSVG->mFill.Reset(); break;
|
||||
case eCSSProperty_fill_opacity: mSVG->mFillOpacity.Reset(); break;
|
||||
case eCSSProperty_fill_rule: mSVG->mFillRule.Reset(); break;
|
||||
case eCSSProperty_stroke: mSVG->mStroke.Reset(); break;
|
||||
case eCSSProperty_stroke_dasharray: mSVG->mStrokeDasharray.Reset(); break;
|
||||
case eCSSProperty_stroke_dashoffset: mSVG->mStrokeDashoffset.Reset(); break;
|
||||
case eCSSProperty_stroke_linecap: mSVG->mStrokeLinecap.Reset(); break;
|
||||
case eCSSProperty_stroke_linejoin: mSVG->mStrokeLinejoin.Reset(); break;
|
||||
case eCSSProperty_stroke_miterlimit: mSVG->mStrokeMiterlimit.Reset(); break;
|
||||
case eCSSProperty_stroke_opacity: mSVG->mStrokeOpacity.Reset(); break;
|
||||
case eCSSProperty_stroke_width: mSVG->mStrokeWidth.Reset(); break;
|
||||
CSS_BOGUS_DEFAULT; // Make compiler happy
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
// nsCSSAural
|
||||
case eCSSProperty_azimuth:
|
||||
case eCSSProperty_elevation:
|
||||
|
@ -4258,6 +4433,41 @@ CSSDeclarationImpl::GetValue(nsCSSProperty aProperty, nsCSSValue& aValue)
|
|||
break;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// nsCSSSVG
|
||||
case eCSSProperty_fill:
|
||||
case eCSSProperty_fill_opacity:
|
||||
case eCSSProperty_fill_rule:
|
||||
case eCSSProperty_stroke:
|
||||
case eCSSProperty_stroke_dasharray:
|
||||
case eCSSProperty_stroke_dashoffset:
|
||||
case eCSSProperty_stroke_linecap:
|
||||
case eCSSProperty_stroke_linejoin:
|
||||
case eCSSProperty_stroke_miterlimit:
|
||||
case eCSSProperty_stroke_opacity:
|
||||
case eCSSProperty_stroke_width:
|
||||
if (nsnull != mSVG) {
|
||||
switch (aProperty) {
|
||||
case eCSSProperty_fill: aValue = mSVG->mFill; break;
|
||||
case eCSSProperty_fill_opacity: aValue = mSVG->mFillOpacity; break;
|
||||
case eCSSProperty_fill_rule: aValue = mSVG->mFillRule; break;
|
||||
case eCSSProperty_stroke: aValue = mSVG->mStroke; break;
|
||||
case eCSSProperty_stroke_dasharray: aValue = mSVG->mStrokeDasharray; break;
|
||||
case eCSSProperty_stroke_dashoffset: aValue = mSVG->mStrokeDashoffset; break;
|
||||
case eCSSProperty_stroke_linecap: aValue = mSVG->mStrokeLinecap; break;
|
||||
case eCSSProperty_stroke_linejoin: aValue = mSVG->mStrokeLinejoin; break;
|
||||
case eCSSProperty_stroke_miterlimit: aValue = mSVG->mStrokeMiterlimit; break;
|
||||
case eCSSProperty_stroke_opacity: aValue = mSVG->mStrokeOpacity; break;
|
||||
case eCSSProperty_stroke_width: aValue = mSVG->mStrokeWidth; break;
|
||||
CSS_BOGUS_DEFAULT; // make compiler happy
|
||||
}
|
||||
}
|
||||
else {
|
||||
aValue.Reset();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
// nsCSSAural
|
||||
case eCSSProperty_azimuth:
|
||||
case eCSSProperty_elevation:
|
||||
|
@ -5438,6 +5648,11 @@ void CSSDeclarationImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSiz
|
|||
if(mXUL && uniqueItems->AddItem(mXUL)){
|
||||
aSize += sizeof(*mXUL);
|
||||
}
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
if(mSVG && uniqueItems->AddItem(mSVG)){
|
||||
aSize += sizeof(*mSVG);
|
||||
}
|
||||
#endif
|
||||
if(mAural && uniqueItems->AddItem(mAural)){
|
||||
aSize += sizeof(*mAural);
|
||||
|
|
|
@ -95,6 +95,9 @@ static NS_DEFINE_IID(kCSSPageSID, NS_CSS_PAGE_SID);
|
|||
#ifdef INCLUDE_XUL
|
||||
static NS_DEFINE_IID(kCSSXULSID, NS_CSS_XUL_SID);
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
static NS_DEFINE_IID(kCSSSVGSID, NS_CSS_SVG_SID);
|
||||
#endif
|
||||
|
||||
// -- nsCSSSelector -------------------------------
|
||||
|
||||
|
@ -875,6 +878,10 @@ static nsresult MapUIForDeclaration(nsICSSDeclaration* aDecl, const nsStyleStruc
|
|||
static nsresult MapXULForDeclaration(nsICSSDeclaration* aDecl, nsCSSXUL& aXUL);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
static nsresult MapSVGForDeclaration(nsICSSDeclaration* aDecl, nsCSSSVG& aSVG);
|
||||
#endif
|
||||
|
||||
class CSSStyleRuleImpl;
|
||||
|
||||
class CSSImportantRule : public nsIStyleRule {
|
||||
|
@ -986,6 +993,10 @@ CSSImportantRule::MapRuleInfoInto(nsRuleData* aRuleData)
|
|||
else if (aRuleData->mXULData)
|
||||
return MapXULForDeclaration(mDeclaration, *aRuleData->mXULData);
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
else if (aRuleData->mSVGData)
|
||||
return MapSVGForDeclaration(mDeclaration, *aRuleData->mSVGData);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1722,6 +1733,10 @@ CSSStyleRuleImpl::MapRuleInfoInto(nsRuleData* aRuleData)
|
|||
else if (aRuleData->mXULData)
|
||||
return MapXULForDeclaration(mDeclaration, *aRuleData->mXULData);
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
else if (aRuleData->mSVGData)
|
||||
return MapSVGForDeclaration(mDeclaration, *aRuleData->mSVGData);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1798,6 +1813,57 @@ MapXULForDeclaration(nsICSSDeclaration* aDecl, nsCSSXUL& aXUL)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
static nsresult
|
||||
MapSVGForDeclaration(nsICSSDeclaration* aDecl, nsCSSSVG& aSVG)
|
||||
{
|
||||
if (!aDecl)
|
||||
return NS_OK; // The rule must have a declaration.
|
||||
|
||||
nsCSSSVG* ourSVG;
|
||||
aDecl->GetData(kCSSSVGSID, (nsCSSStruct**)&ourSVG);
|
||||
if (!ourSVG)
|
||||
return NS_OK; // We don't have any rules for SVG.
|
||||
|
||||
// fill:
|
||||
if (aSVG.mFill.GetUnit() == eCSSUnit_Null && ourSVG->mFill.GetUnit() != eCSSUnit_Null)
|
||||
aSVG.mFill = ourSVG->mFill;
|
||||
// fill-opacity:
|
||||
if (aSVG.mFillOpacity.GetUnit() == eCSSUnit_Null && ourSVG->mFillOpacity.GetUnit() != eCSSUnit_Null)
|
||||
aSVG.mFillOpacity = ourSVG->mFillOpacity;
|
||||
// fill-rule:
|
||||
if (aSVG.mFillRule.GetUnit() == eCSSUnit_Null && ourSVG->mFillRule.GetUnit() != eCSSUnit_Null)
|
||||
aSVG.mFillRule = ourSVG->mFillRule;
|
||||
// stroke:
|
||||
if (aSVG.mStroke.GetUnit() == eCSSUnit_Null && ourSVG->mStroke.GetUnit() != eCSSUnit_Null)
|
||||
aSVG.mStroke = ourSVG->mStroke;
|
||||
// stroke-dasharray:
|
||||
if (aSVG.mStrokeDasharray.GetUnit() == eCSSUnit_Null && ourSVG->mStrokeDasharray.GetUnit() != eCSSUnit_Null)
|
||||
aSVG.mStrokeDasharray = ourSVG->mStrokeDasharray;
|
||||
// stroke-dashoffset:
|
||||
if (aSVG.mStrokeDashoffset.GetUnit() == eCSSUnit_Null && ourSVG->mStrokeDashoffset.GetUnit() != eCSSUnit_Null)
|
||||
aSVG.mStrokeDashoffset = ourSVG->mStrokeDashoffset;
|
||||
// stroke-linecap: enum, inherit
|
||||
if (aSVG.mStrokeLinecap.GetUnit() == eCSSUnit_Null && ourSVG->mStrokeLinecap.GetUnit() != eCSSUnit_Null)
|
||||
aSVG.mStrokeLinecap = ourSVG->mStrokeLinecap;
|
||||
// stroke-linejoin
|
||||
if (aSVG.mStrokeLinejoin.GetUnit() == eCSSUnit_Null && ourSVG->mStrokeLinejoin.GetUnit() != eCSSUnit_Null)
|
||||
aSVG.mStrokeLinejoin = ourSVG->mStrokeLinejoin;
|
||||
// stroke-miterlimit:
|
||||
if (aSVG.mStrokeMiterlimit.GetUnit() == eCSSUnit_Null && ourSVG->mStrokeMiterlimit.GetUnit() != eCSSUnit_Null)
|
||||
aSVG.mStrokeMiterlimit = ourSVG->mStrokeMiterlimit;
|
||||
// stroke-opacity:
|
||||
if (aSVG.mStrokeOpacity.GetUnit() == eCSSUnit_Null && ourSVG->mStrokeOpacity.GetUnit() != eCSSUnit_Null)
|
||||
aSVG.mStrokeOpacity = ourSVG->mStrokeOpacity;
|
||||
// stroke-width:
|
||||
if (aSVG.mStrokeWidth.GetUnit() == eCSSUnit_Null && ourSVG->mStrokeWidth.GetUnit() != eCSSUnit_Null)
|
||||
aSVG.mStrokeWidth = ourSVG->mStrokeWidth;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static nsresult
|
||||
MapPositionForDeclaration(nsICSSDeclaration* aDecl, nsCSSPosition& aPosition)
|
||||
{
|
||||
|
|
|
@ -112,6 +112,12 @@ struct nsCSSStruct {
|
|||
{ 0xfc075d62, 0xb1cf, 0x47a1, { 0xaf, 0x4e, 0xcb, 0x40, 0xe1, 0x1a, 0x43, 0x14 } }
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// {9A41A036-027B-45ef-89C9-6E32797839E7}
|
||||
#define NS_CSS_SVG_SID \
|
||||
{ 0x9a41a036, 0x27b, 0x45ef, { 0x89, 0xc9, 0x6e, 0x32, 0x79, 0x78, 0x39, 0xe7 } }
|
||||
#endif
|
||||
|
||||
// IID for the nsICSSDeclaration interface {7b36b9ac-b48d-11d1-9ca5-0060088f9ff7}
|
||||
#define NS_ICSS_DECLARATION_IID \
|
||||
{0x7b36b9ac, 0xb48d, 0x11d1, {0x9c, 0xa5, 0x00, 0x60, 0x08, 0x8f, 0x9f, 0xf7}}
|
||||
|
@ -436,6 +442,29 @@ struct nsCSSXUL : public nsCSSStruct {
|
|||
};
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
struct nsCSSSVG : public nsCSSStruct {
|
||||
nsCSSSVG(void);
|
||||
nsCSSSVG(const nsCSSSVG& aCopy);
|
||||
virtual ~nsCSSSVG(void);
|
||||
|
||||
const nsID& GetID(void);
|
||||
void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
|
||||
|
||||
nsCSSValue mFill;
|
||||
nsCSSValue mFillOpacity;
|
||||
nsCSSValue mFillRule;
|
||||
nsCSSValue mStroke;
|
||||
nsCSSValue mStrokeDasharray;
|
||||
nsCSSValue mStrokeDashoffset;
|
||||
nsCSSValue mStrokeLinecap;
|
||||
nsCSSValue mStrokeLinejoin;
|
||||
nsCSSValue mStrokeMiterlimit;
|
||||
nsCSSValue mStrokeOpacity;
|
||||
nsCSSValue mStrokeWidth;
|
||||
};
|
||||
#endif
|
||||
|
||||
class nsICSSDeclaration : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICSS_DECLARATION_IID);
|
||||
|
|
|
@ -169,6 +169,14 @@ nsCachedStyleData::gInfo[] = {
|
|||
},
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
/* eStyleStruct_SVG */
|
||||
{ offsetof(nsCachedStyleData, mInheritedData),
|
||||
offsetof(nsInheritedStyleData, mSVGData),
|
||||
PR_FALSE
|
||||
},
|
||||
#endif
|
||||
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
|
|
@ -2366,6 +2366,13 @@
|
|||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS>Debug</FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>contentSVG.o</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Library</FILEKIND>
|
||||
<FILEFLAGS>Debug</FILEFLAGS>
|
||||
</FILE>
|
||||
</FILELIST>
|
||||
<LINKORDER>
|
||||
<FILEREF>
|
||||
|
@ -3408,6 +3415,11 @@
|
|||
<PATH>nsXBLProtoImplProperty.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>contentSVG.o</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</LINKORDER>
|
||||
</TARGET>
|
||||
<TARGET>
|
||||
|
@ -5723,6 +5735,13 @@
|
|||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS>Debug</FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>contentSVGDebug.o</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Library</FILEKIND>
|
||||
<FILEFLAGS>Debug</FILEFLAGS>
|
||||
</FILE>
|
||||
</FILELIST>
|
||||
<LINKORDER>
|
||||
<FILEREF>
|
||||
|
@ -6765,6 +6784,11 @@
|
|||
<PATH>nsXBLProtoImplProperty.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>contentSVGDebug.o</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</LINKORDER>
|
||||
</TARGET>
|
||||
</TARGETLIST>
|
||||
|
@ -7985,8 +8009,20 @@
|
|||
</GROUP>
|
||||
<GROUP><NAME>Options</NAME>
|
||||
<GROUP><NAME>Debug</NAME>
|
||||
<FILEREF>
|
||||
<TARGETNAME>contentDebug.shlb</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>contentSVGDebug.o</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</GROUP>
|
||||
<GROUP><NAME>Optimized</NAME>
|
||||
<FILEREF>
|
||||
<TARGETNAME>content.shlb</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>contentSVG.o</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</GROUP>
|
||||
</GROUP>
|
||||
<GROUP><NAME>Static Libs</NAME>
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -27,6 +27,9 @@ DIRS= \
|
|||
xml \
|
||||
xsl \
|
||||
xbl \
|
||||
!ifdef MOZ_SVG
|
||||
svg \
|
||||
!endif
|
||||
events \
|
||||
xul \
|
||||
shared \
|
||||
|
|
|
@ -22,6 +22,8 @@ nsStyleStruct.h
|
|||
nsTextFragment.h
|
||||
nsXULAtomList.h
|
||||
nsXULAtoms.h
|
||||
nsSVGAtoms.h
|
||||
nsSVGAtomList.h
|
||||
nsXBLAtomList.h
|
||||
nsXBLAtoms.h
|
||||
|
||||
|
|
|
@ -54,6 +54,10 @@ nsXBLAtomList.h \
|
|||
nsXBLAtoms.h \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_SVG
|
||||
EXPORTS += nsSVGAtomList.h nsSVGAtoms.h
|
||||
endif
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -43,6 +43,10 @@ EXPORTS = \
|
|||
nsTextFragment.h \
|
||||
nsXULAtomList.h \
|
||||
nsXULAtoms.h \
|
||||
!ifdef MOZ_SVG
|
||||
nsSVGAtomList.h \
|
||||
nsSVGAtoms.h \
|
||||
!endif
|
||||
nsXBLAtomList.h \
|
||||
nsXBLAtoms.h \
|
||||
$(NULL)
|
||||
|
|
|
@ -408,3 +408,12 @@ CSS_KEY(x-small, x_small)
|
|||
CSS_KEY(x-soft, x_soft)
|
||||
CSS_KEY(xx-large, xx_large)
|
||||
CSS_KEY(xx-small, xx_small)
|
||||
#ifdef MOZ_SVG
|
||||
CSS_KEY(bevel, bevel)
|
||||
CSS_KEY(butt, butt)
|
||||
CSS_KEY(evenodd, evenodd)
|
||||
CSS_KEY(miter, miter)
|
||||
CSS_KEY(nonzero, nonzero)
|
||||
CSS_KEY(round, round)
|
||||
//CSS_KEY(square, square)
|
||||
#endif
|
||||
|
|
|
@ -251,3 +251,17 @@ CSS_PROP(widows, widows, REFLOW)
|
|||
CSS_PROP(width, width, REFLOW)
|
||||
CSS_PROP(word-spacing, word_spacing, REFLOW)
|
||||
CSS_PROP(z-index, z_index, REFLOW)
|
||||
#ifdef MOZ_SVG
|
||||
CSS_PROP(fill, fill, VISUAL)
|
||||
CSS_PROP(fill-opacity, fill_opacity, VISUAL)
|
||||
CSS_PROP(fill-rule, fill_rule, VISUAL)
|
||||
CSS_PROP(stroke, stroke, VISUAL)
|
||||
CSS_PROP(stroke-dasharray, stroke_dasharray, VISUAL)
|
||||
CSS_PROP(stroke-dashoffset, stroke_dashoffset, VISUAL)
|
||||
CSS_PROP(stroke-linecap, stroke_linecap, VISUAL)
|
||||
CSS_PROP(stroke-linejoin, stroke_linejoin, VISUAL)
|
||||
CSS_PROP(stroke-miterlimit, stroke_miterlimit, VISUAL)
|
||||
CSS_PROP(stroke-opacity, stroke_opacity, VISUAL)
|
||||
CSS_PROP(stroke-width, stroke_width, VISUAL)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -96,6 +96,11 @@ public:
|
|||
static const PRInt32 kBoxDirectionKTable[];
|
||||
static const PRInt32 kBoxOrientKTable[];
|
||||
static const PRInt32 kBoxPackKTable[];
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
static const PRInt32 kFillRuleKTable[];
|
||||
static const PRInt32 kStrokeLinecapKTable[];
|
||||
static const PRInt32 kStrokeLinejoinKTable[];
|
||||
#endif
|
||||
static const PRInt32 kBoxSizingKTable[];
|
||||
static const PRInt32 kCaptionSideKTable[];
|
||||
|
|
|
@ -64,6 +64,9 @@ struct nsInheritedStyleData
|
|||
nsStyleQuotes* mQuotesData;
|
||||
nsStyleText* mTextData;
|
||||
nsStyleUserInterface* mUIData;
|
||||
#ifdef MOZ_SVG
|
||||
nsStyleSVG* mSVGData;
|
||||
#endif
|
||||
|
||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||
void* result = nsnull;
|
||||
|
@ -88,6 +91,10 @@ struct nsInheritedStyleData
|
|||
mTextData = nsnull;
|
||||
if (mUIData && (aBits & NS_STYLE_INHERIT_UI))
|
||||
mUIData = nsnull;
|
||||
#ifdef MOZ_SVG
|
||||
if (mSVGData && (aBits & NS_STYLE_INHERIT_SVG))
|
||||
mSVGData = nsnull;
|
||||
#endif
|
||||
};
|
||||
|
||||
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
|
||||
|
@ -107,12 +114,19 @@ struct nsInheritedStyleData
|
|||
mTextData->Destroy(aContext);
|
||||
if (mUIData && !(aBits & NS_STYLE_INHERIT_UI))
|
||||
mUIData->Destroy(aContext);
|
||||
#ifdef MOZ_SVG
|
||||
if (mSVGData && !(aBits & NS_STYLE_INHERIT_SVG))
|
||||
mSVGData->Destroy(aContext);
|
||||
#endif
|
||||
aContext->FreeToShell(sizeof(nsInheritedStyleData), this);
|
||||
};
|
||||
|
||||
nsInheritedStyleData()
|
||||
:mVisibilityData(nsnull), mFontData(nsnull), mListData(nsnull),
|
||||
mTableData(nsnull), mColorData(nsnull), mQuotesData(nsnull), mTextData(nsnull), mUIData(nsnull)
|
||||
#ifdef MOZ_SVG
|
||||
, mSVGData(nsnull)
|
||||
#endif
|
||||
{};
|
||||
};
|
||||
|
||||
|
@ -284,6 +298,10 @@ struct nsRuleData
|
|||
nsCSSXUL* mXULData;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
nsCSSSVG* mSVGData;
|
||||
#endif
|
||||
|
||||
nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsIStyleContext* aStyleContext)
|
||||
:mSID(aSID), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull),
|
||||
mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull),
|
||||
|
@ -294,6 +312,9 @@ struct nsRuleData
|
|||
|
||||
#ifdef INCLUDE_XUL
|
||||
mXULData = nsnull;
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
mSVGData = nsnull;
|
||||
#endif
|
||||
};
|
||||
~nsRuleData() {};
|
||||
|
@ -455,6 +476,13 @@ protected:
|
|||
const RuleDetail& aRuleDetail, PRBool aInherited);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
const nsStyleStruct* ComputeSVGData(nsStyleStruct* aStartSVG, const nsCSSStruct& aSVGData,
|
||||
nsIStyleContext* aContext,
|
||||
nsRuleNode* aHighestNode,
|
||||
const RuleDetail& aRuleDetail, PRBool aInherited);
|
||||
#endif
|
||||
|
||||
typedef const nsStyleStruct*
|
||||
(nsRuleNode::*ComputeStyleDataFn)(nsStyleStruct* aStartStruct,
|
||||
const nsCSSStruct& aStartData,
|
||||
|
@ -490,6 +518,9 @@ protected:
|
|||
#ifdef INCLUDE_XUL
|
||||
const nsStyleStruct* GetXULData(nsIStyleContext* aContext, PRBool aComputeData);
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
const nsStyleStruct* GetSVGData(nsIStyleContext* aContext, PRBool aComputeData);
|
||||
#endif
|
||||
|
||||
typedef const nsStyleStruct* (nsRuleNode::*GetStyleDataFn)(nsIStyleContext*, PRBool);
|
||||
static GetStyleDataFn gGetStyleDataFn[];
|
||||
|
|
|
@ -76,9 +76,15 @@ enum nsStyleStructID {
|
|||
eStyleStruct_Border = 18,
|
||||
eStyleStruct_Outline = 19,
|
||||
eStyleStruct_XUL = 20,
|
||||
eStyleStruct_Min = eStyleStruct_Font,
|
||||
#ifdef MOZ_SVG
|
||||
eStyleStruct_SVG = 21,
|
||||
eStyleStruct_Max = eStyleStruct_SVG,
|
||||
eStyleStruct_BorderPaddingShortcut = 22, // only for use in GetStyle()
|
||||
#else
|
||||
eStyleStruct_Max = eStyleStruct_XUL,
|
||||
eStyleStruct_BorderPaddingShortcut = 21 // only for use in GetStyle()
|
||||
eStyleStruct_BorderPaddingShortcut = 21, // only for use in GetStyle()
|
||||
#endif
|
||||
eStyleStruct_Min = eStyleStruct_Font
|
||||
};
|
||||
|
||||
// Bits for each struct.
|
||||
|
@ -103,15 +109,18 @@ enum nsStyleStructID {
|
|||
#define NS_STYLE_INHERIT_BORDER NS_STYLE_INHERIT_BIT(eStyleStruct_Border)
|
||||
#define NS_STYLE_INHERIT_OUTLINE NS_STYLE_INHERIT_BIT(eStyleStruct_Outline)
|
||||
#define NS_STYLE_INHERIT_XUL NS_STYLE_INHERIT_BIT(eStyleStruct_XUL)
|
||||
#ifdef MOZ_SVG
|
||||
#define NS_STYLE_INHERIT_SVG NS_STYLE_INHERIT_BIT(eStyleStruct_SVG)
|
||||
#endif
|
||||
|
||||
#define NS_STYLE_INHERIT_MASK 0x0fffff
|
||||
#define NS_STYLE_INHERIT_MASK 0x00ffffff
|
||||
|
||||
// A bit to test whether or not a style context can be shared
|
||||
// by siblings.
|
||||
#define NS_STYLE_UNIQUE_CONTEXT 0x100000
|
||||
#define NS_STYLE_UNIQUE_CONTEXT 0x01000000
|
||||
|
||||
// A bit to test whether or not we have any text decorations.
|
||||
#define NS_STYLE_HAS_TEXT_DECORATIONS 0x200000
|
||||
#define NS_STYLE_HAS_TEXT_DECORATIONS 0x02000000
|
||||
|
||||
#define NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(the_sid) \
|
||||
static const nsStyleStructID GetStyleStructID() {return the_sid;}
|
||||
|
@ -1121,6 +1130,52 @@ struct nsStyleXUL : public nsStyleStruct {
|
|||
};
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
enum nsStyleSVGPaintType {
|
||||
eStyleSVGPaintType_None = 0,
|
||||
eStyleSVGPaintType_Color,
|
||||
eStyleSVGPaintType_Server
|
||||
};
|
||||
|
||||
struct nsStyleSVGPaint
|
||||
{
|
||||
nsStyleSVGPaintType mType;
|
||||
nscolor mColor;
|
||||
};
|
||||
|
||||
struct nsStyleSVG : public nsStyleStruct {
|
||||
nsStyleSVG();
|
||||
nsStyleSVG(const nsStyleSVG& aSource);
|
||||
~nsStyleSVG();
|
||||
|
||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||
void* result = nsnull;
|
||||
aContext->AllocateFromShell(sz, &result);
|
||||
return result;
|
||||
}
|
||||
void Destroy(nsIPresContext* aContext) {
|
||||
this->~nsStyleSVG();
|
||||
aContext->FreeToShell(sizeof(nsStyleSVG), this);
|
||||
};
|
||||
|
||||
PRInt32 CalcDifference(const nsStyleSVG& aOther) const;
|
||||
|
||||
// all [inherit]ed
|
||||
nsStyleSVGPaint mFill;
|
||||
float mFillOpacity;
|
||||
PRUint8 mFillRule; // see nsStyleConsts.h
|
||||
nsStyleSVGPaint mStroke;
|
||||
nsString mStrokeDasharray; // XXX we want a parsed value here
|
||||
float mStrokeDashoffset;
|
||||
PRUint8 mStrokeLinecap; // see nsStyleConsts.h
|
||||
PRUint8 mStrokeLinejoin; // see nsStyleConsts.h
|
||||
float mStrokeMiterlimit;
|
||||
float mStrokeOpacity;
|
||||
float mStrokeWidth; // in pixels
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#define BORDER_PRECEDENT_EQUAL 0
|
||||
#define BORDER_PRECEDENT_LOWER 1
|
||||
#define BORDER_PRECEDENT_HIGHER 2
|
||||
|
|
|
@ -60,6 +60,10 @@ CPPSRCS = \
|
|||
nsStyleStruct.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_SVG
|
||||
CPPSRCS += nsSVGAtoms.cpp
|
||||
endif
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
|
|
|
@ -58,6 +58,9 @@ CPP_OBJS= \
|
|||
.\$(OBJDIR)\nsXULAtoms.obj \
|
||||
.\$(OBJDIR)\nsXBLAtoms.obj \
|
||||
.\$(OBJDIR)\nsStyleCoord.obj \
|
||||
!ifdef MOZ_SVG
|
||||
.\$(OBJDIR)\nsSVGAtoms.obj \
|
||||
!endif
|
||||
$(NULL)
|
||||
|
||||
LCFLAGS = \
|
||||
|
|
|
@ -738,6 +738,29 @@ const PRInt32 nsCSSProps::kBoxPackKTable[] = {
|
|||
};
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// keyword tables for SVG properties
|
||||
const PRInt32 nsCSSProps::kFillRuleKTable[] = {
|
||||
eCSSKeyword_nonzero, NS_STYLE_FILL_RULE_NONZERO,
|
||||
eCSSKeyword_evenodd, NS_STYLE_FILL_RULE_EVENODD,
|
||||
-1, -1
|
||||
};
|
||||
|
||||
const PRInt32 nsCSSProps::kStrokeLinecapKTable[] = {
|
||||
eCSSKeyword_butt, NS_STYLE_STROKE_LINECAP_BUTT,
|
||||
eCSSKeyword_round, NS_STYLE_STROKE_LINECAP_ROUND,
|
||||
eCSSKeyword_square, NS_STYLE_STROKE_LINECAP_SQUARE,
|
||||
-1, -1
|
||||
};
|
||||
|
||||
const PRInt32 nsCSSProps::kStrokeLinejoinKTable[] = {
|
||||
eCSSKeyword_butt, NS_STYLE_STROKE_LINEJOIN_MITER,
|
||||
eCSSKeyword_round, NS_STYLE_STROKE_LINEJOIN_ROUND,
|
||||
eCSSKeyword_bevel, NS_STYLE_STROKE_LINEJOIN_BEVEL,
|
||||
-1, -1
|
||||
};
|
||||
#endif
|
||||
|
||||
PRInt32
|
||||
nsCSSProps::SearchKeywordTableInt(PRInt32 aValue, const PRInt32 aTable[])
|
||||
{
|
||||
|
@ -835,6 +858,25 @@ static const PRInt32 kBackgroundYPositionKTable[] = {
|
|||
return SearchKeywordTable(aValue, kBoxPackKTable);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
case eCSSProperty_fill:
|
||||
case eCSSProperty_fill_opacity:
|
||||
case eCSSProperty_stroke:
|
||||
case eCSSProperty_stroke_dasharray:
|
||||
case eCSSProperty_stroke_dashoffset:
|
||||
case eCSSProperty_stroke_miterlimit:
|
||||
case eCSSProperty_stroke_opacity:
|
||||
case eCSSProperty_stroke_width:
|
||||
break;
|
||||
|
||||
case eCSSProperty_fill_rule:
|
||||
return SearchKeywordTable(aValue, kFillRuleKTable);
|
||||
case eCSSProperty_stroke_linecap:
|
||||
return SearchKeywordTable(aValue, kStrokeLinecapKTable);
|
||||
case eCSSProperty_stroke_linejoin:
|
||||
return SearchKeywordTable(aValue, kStrokeLinejoinKTable);
|
||||
#endif
|
||||
|
||||
case eCSSProperty_box_sizing:
|
||||
return SearchKeywordTable(aValue, kBoxSizingKTable);
|
||||
|
||||
|
|
|
@ -717,6 +717,78 @@ nsStyleXUL::CalcDifference(const nsStyleXUL& aOther) const
|
|||
|
||||
#endif // INCLUDE_XUL
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// --------------------
|
||||
// nsStyleSVG
|
||||
//
|
||||
nsStyleSVG::nsStyleSVG()
|
||||
{
|
||||
mFill.mType = eStyleSVGPaintType_None;
|
||||
mFill.mColor = NS_RGB(0,0,0);
|
||||
mFillOpacity = 1.0f;
|
||||
mFillRule = NS_STYLE_FILL_RULE_NONZERO;
|
||||
mStroke.mType = eStyleSVGPaintType_None;
|
||||
mStroke.mColor = NS_RGB(0,0,0);
|
||||
mStrokeDasharray.Truncate();
|
||||
mStrokeDashoffset = 0.0f;
|
||||
mStrokeLinecap = NS_STYLE_STROKE_LINECAP_BUTT;
|
||||
mStrokeLinejoin = NS_STYLE_STROKE_LINEJOIN_MITER;
|
||||
mStrokeMiterlimit = 4.0f;
|
||||
mStrokeOpacity = 1.0f;
|
||||
mStrokeWidth = 1.0f;
|
||||
}
|
||||
|
||||
nsStyleSVG::~nsStyleSVG()
|
||||
{
|
||||
}
|
||||
|
||||
nsStyleSVG::nsStyleSVG(const nsStyleSVG& aSource)
|
||||
{
|
||||
//nsCRT::memcpy((nsStyleSVG*)this, &aSource, sizeof(nsStyleSVG));
|
||||
|
||||
mFill.mType = aSource.mFill.mType;
|
||||
if (mFill.mType == eStyleSVGPaintType_Color)
|
||||
mFill.mColor = aSource.mFill.mColor;
|
||||
mFillOpacity = aSource.mFillOpacity;
|
||||
mFillRule = aSource.mFillRule;
|
||||
mStroke.mType = aSource.mStroke.mType;
|
||||
if (mStroke.mType == eStyleSVGPaintType_Color)
|
||||
mStroke.mColor = aSource.mStroke.mColor;
|
||||
mStrokeDasharray = aSource.mStrokeDasharray;
|
||||
mStrokeDashoffset = aSource.mStrokeDashoffset;
|
||||
mStrokeLinecap = aSource.mStrokeLinecap;
|
||||
mStrokeLinejoin = aSource.mStrokeLinejoin;
|
||||
mStrokeMiterlimit = aSource.mStrokeMiterlimit;
|
||||
mStrokeOpacity = aSource.mStrokeOpacity;
|
||||
mStrokeWidth = aSource.mStrokeWidth;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsStyleSVG::CalcDifference(const nsStyleSVG& aOther) const
|
||||
{
|
||||
if ( mFill.mType != aOther.mFill.mType ||
|
||||
mFillOpacity != aOther.mFillOpacity ||
|
||||
mFillRule != aOther.mFillRule ||
|
||||
mStroke.mType != aOther.mStroke.mType ||
|
||||
mStrokeDasharray != aOther.mStrokeDasharray ||
|
||||
mStrokeDashoffset != aOther.mStrokeDashoffset ||
|
||||
mStrokeLinecap != aOther.mStrokeLinecap ||
|
||||
mStrokeLinejoin != aOther.mStrokeLinejoin ||
|
||||
mStrokeMiterlimit != aOther.mStrokeMiterlimit ||
|
||||
mStrokeOpacity != aOther.mStrokeOpacity ||
|
||||
mStrokeWidth != aOther.mStrokeWidth )
|
||||
return NS_STYLE_HINT_VISUAL;
|
||||
|
||||
if ( (mStroke.mType == eStyleSVGPaintType_Color && mStroke.mColor != aOther.mStroke.mColor) ||
|
||||
(mFill.mType == eStyleSVGPaintType_Color && mFill.mColor != aOther.mFill.mColor) )
|
||||
return NS_STYLE_HINT_VISUAL;
|
||||
|
||||
return NS_STYLE_HINT_NONE;
|
||||
}
|
||||
|
||||
#endif // MOZ_SVG
|
||||
|
||||
|
||||
// --------------------
|
||||
// nsStylePosition
|
||||
//
|
||||
|
|
|
@ -169,6 +169,14 @@ nsCachedStyleData::gInfo[] = {
|
|||
},
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
/* eStyleStruct_SVG */
|
||||
{ offsetof(nsCachedStyleData, mInheritedData),
|
||||
offsetof(nsInheritedStyleData, mSVGData),
|
||||
PR_FALSE
|
||||
},
|
||||
#endif
|
||||
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is Crocodile Clips Ltd code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Crocodile Clips Ltd. Portions created by Crocodile Clips are
|
||||
# Copyright (C) 2001 Crocodile Clips Ltd. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = document content
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -1,38 +1,35 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
# The Original Code is Crocodile Clips Ltd code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# The Initial Developer of the Original Code is
|
||||
# Crocodile Clips Ltd. Portions created by Crocodile Clips are
|
||||
# Copyright (C) 2001 Crocodile Clips Ltd. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alex Fritze <alex.fritze@crocodile-clips.com>
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = layout
|
||||
|
||||
EXPORTS = \
|
||||
nsISVGFrame.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
DIRS = src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -1,23 +1,26 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
# The Original Code is Crocodile Clips Ltd code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# The Initial Developer of the Original Code is
|
||||
# Crocodile Clips Ltd. Portions created by Crocodile Clips are
|
||||
# Copyright (C) 2001 Crocodile Clips Ltd. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alex Fritze <alex.fritze@crocodile-clips.com>
|
||||
#
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
nsISVGValue.h
|
||||
nsISVGValueObserver.h
|
||||
nsISVGAttribute.h
|
||||
nsISVGStyleValue.h
|
|
@ -0,0 +1,102 @@
|
|||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is Crocodile Clips Ltd code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Crocodile Clips Ltd. Portions created by Crocodile Clips are
|
||||
# Copyright (C) 2001 Crocodile Clips Ltd. All
|
||||
# Rights Reserved.
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = content
|
||||
LIBRARY_NAME = gkcontentsvg_s
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
layout \
|
||||
content \
|
||||
widget \
|
||||
gfx \
|
||||
dom \
|
||||
js \
|
||||
locale \
|
||||
htmlparser \
|
||||
view \
|
||||
pref \
|
||||
necko \
|
||||
webshell
|
||||
|
||||
CPPSRCS = \
|
||||
nsSVGAnimatedLength.cpp \
|
||||
nsSVGAnimatedRect.cpp \
|
||||
nsSVGAnimatedTransformList.cpp \
|
||||
nsSVGAttributes.cpp \
|
||||
nsSVGCircleElement.cpp \
|
||||
nsSVGElement.cpp \
|
||||
nsSVGElementFactory.cpp \
|
||||
nsSVGEllipseElement.cpp \
|
||||
nsSVGForeignObjectElement.cpp \
|
||||
nsSVGGElement.cpp \
|
||||
nsSVGGenericStringValue.cpp \
|
||||
nsSVGGraphicElement.cpp \
|
||||
nsSVGLength.cpp \
|
||||
nsSVGLineElement.cpp \
|
||||
nsSVGMatrix.cpp \
|
||||
nsSVGPathDataParser.cpp \
|
||||
nsSVGPathElement.cpp \
|
||||
nsSVGPathSeg.cpp \
|
||||
nsSVGPathSegList.cpp \
|
||||
nsSVGPoint.cpp \
|
||||
nsSVGPointList.cpp \
|
||||
nsSVGPolygonElement.cpp \
|
||||
nsSVGPolylineElement.cpp \
|
||||
nsSVGRect.cpp \
|
||||
nsSVGRectElement.cpp \
|
||||
nsSVGSVGElement.cpp \
|
||||
nsSVGStyleValue.cpp \
|
||||
nsSVGTransform.cpp \
|
||||
nsSVGTransformList.cpp \
|
||||
nsSVGValue.cpp \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
EXPORTS = \
|
||||
nsISVGAttribute.h \
|
||||
nsISVGValue.h \
|
||||
nsISVGStyleValue.h \
|
||||
$(NULL)
|
||||
|
||||
CFLAGS += $(MOZ_LIBART_CFLAGS)
|
||||
CXXFLAGS += $(MOZ_LIBART_CFLAGS)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_HTML
|
||||
|
||||
|
||||
INCLUDES += \
|
||||
-I$(srcdir)/../../../shared/public \
|
||||
-I$(srcdir)/../../../html/base/src \
|
||||
-I$(srcdir)/../../../xml/content/src \
|
||||
-I$(srcdir)/../../../../dom \
|
||||
-I$(srcdir)/../../../base/src \
|
||||
-I$(srcdir)/../../../../layout/svg/base/src \
|
||||
$(NULL)
|
|
@ -0,0 +1,110 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is Crocodile Clips Ltd code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Crocodile Clips Ltd. Portions created by Crocodile Clips are
|
||||
# Copyright (C) 2001 Crocodile Clips Ltd. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alex Fritze <alex.fritze@crocodile-clips.com>
|
||||
#
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
LIBRARY_NAME=contentsvg_s
|
||||
MODULE=raptor
|
||||
REQUIRES = \
|
||||
xpcom \
|
||||
string \
|
||||
layout \
|
||||
content \
|
||||
widget \
|
||||
gfx \
|
||||
dom \
|
||||
js \
|
||||
locale \
|
||||
htmlparser \
|
||||
webshell \
|
||||
necko \
|
||||
view \
|
||||
libart_lgpl \
|
||||
$(NULL)
|
||||
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsSVGAnimatedLength.obj \
|
||||
.\$(OBJDIR)\nsSVGAnimatedRect.obj \
|
||||
.\$(OBJDIR)\nsSVGAnimatedTransformList.obj \
|
||||
.\$(OBJDIR)\nsSVGAttributes.obj \
|
||||
.\$(OBJDIR)\nsSVGCircleElement.obj \
|
||||
.\$(OBJDIR)\nsSVGElement.obj \
|
||||
.\$(OBJDIR)\nsSVGElementFactory.obj \
|
||||
.\$(OBJDIR)\nsSVGEllipseElement.obj \
|
||||
.\$(OBJDIR)\nsSVGForeignObjectElement.obj \
|
||||
.\$(OBJDIR)\nsSVGGElement.obj \
|
||||
.\$(OBJDIR)\nsSVGGenericStringValue.obj \
|
||||
.\$(OBJDIR)\nsSVGGraphicElement.obj \
|
||||
.\$(OBJDIR)\nsSVGLength.obj \
|
||||
.\$(OBJDIR)\nsSVGLineElement.obj \
|
||||
.\$(OBJDIR)\nsSVGMatrix.obj \
|
||||
.\$(OBJDIR)\nsSVGPathDataParser.obj \
|
||||
.\$(OBJDIR)\nsSVGPathElement.obj \
|
||||
.\$(OBJDIR)\nsSVGPathSeg.obj \
|
||||
.\$(OBJDIR)\nsSVGPathSegList.obj \
|
||||
.\$(OBJDIR)\nsSVGPoint.obj \
|
||||
.\$(OBJDIR)\nsSVGPointList.obj \
|
||||
.\$(OBJDIR)\nsSVGPolygonElement.obj \
|
||||
.\$(OBJDIR)\nsSVGPolylineElement.obj \
|
||||
.\$(OBJDIR)\nsSVGRect.obj \
|
||||
.\$(OBJDIR)\nsSVGRectElement.obj \
|
||||
.\$(OBJDIR)\nsSVGSVGElement.obj \
|
||||
.\$(OBJDIR)\nsSVGStyleValue.obj \
|
||||
.\$(OBJDIR)\nsSVGTransform.obj \
|
||||
.\$(OBJDIR)\nsSVGTransformList.obj \
|
||||
.\$(OBJDIR)\nsSVGValue.obj \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsISVGAttribute.h \
|
||||
nsISVGValue.h \
|
||||
nsISVGStyleValue.h \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
|
||||
-I..\..\..\shared\public -I..\..\..\html\base\src -I$(PUBLIC)\dom \
|
||||
-I..\..\..\html\document\src \
|
||||
-I$(PUBLIC)\netlib \
|
||||
-I$(PUBLIC)\pref \
|
||||
-I..\..\..\xml\document\src \
|
||||
-I..\..\..\base\src \
|
||||
-I..\..\..\xml\content\src \
|
||||
-I..\..\..\..\layout\svg\base\src\ \
|
||||
$(NULL)
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
|
@ -1,25 +1,26 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
@ -31,36 +32,32 @@
|
|||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
//
|
||||
// nsPolylineFrame
|
||||
//
|
||||
|
||||
#ifndef nsPolylineFrame_h__
|
||||
#define nsPolylineFrame_h__
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
|
||||
#include "nsPolygonFrame.h"
|
||||
#ifndef __NS_ISVGATTRIBUTE_H__
|
||||
#define __NS_ISVGATTRIBUTE_H__
|
||||
|
||||
class nsString;
|
||||
#include "nsIDOMAttr.h"
|
||||
|
||||
class nsISVGValue;
|
||||
|
||||
nsresult NS_NewPolylineFrame(nsIPresShell* aPresShell, nsIFrame** aResult) ;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsISVGAttribute: private interface for svg attributes
|
||||
|
||||
// {6557CCDF-7252-481d-8AB0-7E083E7E7AB0}
|
||||
#define NS_ISVGATTRIBUTE_IID \
|
||||
{ 0x6557ccdf, 0x7252, 0x481d, { 0x8a, 0xb0, 0x7e, 0x8, 0x3e, 0x7e, 0x7a, 0xb0 } }
|
||||
|
||||
// XXX - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
// This should NOT be derived from nsLeafFrame
|
||||
// we really want to create our own container class from the nsIFrame
|
||||
// interface and not derive from any HTML Frames
|
||||
// XXX - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
class nsPolylineFrame : public nsPolygonFrame
|
||||
class nsISVGAttribute : public nsIDOMAttr
|
||||
{
|
||||
NS_IMETHOD RenderPoints(nsIRenderingContext& aRenderingContext,
|
||||
const nsPoint aPoints[], PRInt32 aNumPoints);
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_ISVGATTRIBUTE_IID; return iid; }
|
||||
|
||||
}; // class nsPolylineFrame
|
||||
NS_IMETHOD GetSVGValue(nsISVGValue** value) = 0;
|
||||
};
|
||||
|
||||
#endif // __NS_ISVGATTRIBUTE_H__
|
||||
|
||||
#endif
|
|
@ -1,26 +1,26 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Original Author: Rod Spears (rods@netscape.com)
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
@ -32,42 +32,30 @@
|
|||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
/******
|
||||
|
||||
This file contains the list of all SVG nsIAtoms and their values
|
||||
#ifndef __NS_ISVGSTYLEVALUE_H__
|
||||
#define __NS_ISVGSTYLEVALUE_H__
|
||||
|
||||
It is designed to be used as inline input to nsSVGAtoms.cpp *only*
|
||||
through the magic of C preprocessing.
|
||||
#include "nsISupports.h"
|
||||
|
||||
All entires must be enclosed in the macro SVG_ATOM which will have cruel
|
||||
and unusual things done to it
|
||||
class nsIStyleRule;
|
||||
class nsIDocument;
|
||||
|
||||
It is recommended (but not strictly necessary) to keep all entries
|
||||
in alphabetical order
|
||||
// {BD099C4C-8FA5-47c4-A44E-189B5AA5DBAF}
|
||||
#define NS_ISVGSTYLEVALUE_IID \
|
||||
{ 0xbd099c4c, 0x8fa5, 0x47c4, { 0xa4, 0x4e, 0x18, 0x9b, 0x5a, 0xa5, 0xdb, 0xaf } }
|
||||
|
||||
The first argument to SVG_ATOM is the C++ identifier of the atom
|
||||
The second argument is the string value of the atom
|
||||
class nsISVGStyleValue : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_ISVGSTYLEVALUE_IID; return iid; }
|
||||
|
||||
******/
|
||||
NS_IMETHOD GetStyleRule(nsIDocument* baseDocument, nsIStyleRule** rule)=0;
|
||||
};
|
||||
|
||||
// tags
|
||||
SVG_ATOM(path, "path")
|
||||
SVG_ATOM(polygon, "polygon")
|
||||
SVG_ATOM(polyline, "polyline")
|
||||
SVG_ATOM(rect, "rect")
|
||||
SVG_ATOM(circle, "circle")
|
||||
SVG_ATOM(ellipse, "ellipse")
|
||||
SVG_ATOM(line, "line")
|
||||
SVG_ATOM(svg, "svg")
|
||||
SVG_ATOM(g, "g")
|
||||
#endif // __NS_ISVGSTYLEVALUE_H__
|
||||
|
||||
// properties
|
||||
SVG_ATOM(points, "points")
|
||||
SVG_ATOM(x, "x")
|
||||
SVG_ATOM(y, "y")
|
||||
SVG_ATOM(fill, "fill")
|
||||
SVG_ATOM(d, "d")
|
|
@ -0,0 +1,81 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
|
||||
#ifndef __NS_ISVGVALUE_H__
|
||||
#define __NS_ISVGVALUE_H__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsISVGValueObserver;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsISVGValue: private interface for svg values
|
||||
|
||||
/* This interface is implemented by all value-types (e.g. coords,
|
||||
pointlists, matrices) that can be parsed from/to strings. This is
|
||||
used for element-properties that are also XML attributes. E.g. the
|
||||
'polyline'-element has a 'points'-attribute and a property
|
||||
'animatedPoints' in the DOM.
|
||||
|
||||
XXX Observers
|
||||
*/
|
||||
|
||||
// {79293232-F695-4bda-9FC7-C2679647B790}
|
||||
#define NS_ISVGVALUE_IID \
|
||||
{ 0x79293232, 0xf695, 0x4bda, { 0x9f, 0xc7, 0xc2, 0x67, 0x96, 0x47, 0xb7, 0x90 } }
|
||||
|
||||
|
||||
class nsISVGValue : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_ISVGVALUE_IID; return iid; }
|
||||
|
||||
NS_IMETHOD SetValueString(const nsAReadableString& aValue)=0;
|
||||
NS_IMETHOD GetValueString(nsAWritableString& aValue)=0;
|
||||
|
||||
NS_IMETHOD AddObserver(nsISVGValueObserver* observer)=0;
|
||||
NS_IMETHOD RemoveObserver(nsISVGValueObserver* observer)=0;
|
||||
};
|
||||
|
||||
extern nsresult
|
||||
NS_CreateSVGGenericStringValue(const nsAReadableString& aValue, nsISVGValue** aResult);
|
||||
|
||||
#endif // __NS_ISVGVALUE_H__
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
|
||||
#ifndef __NS_ISVGVALUEOBSERVER_H__
|
||||
#define __NS_ISVGVALUEOBSERVER_H__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsISVGValue;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsISVGValueObserver
|
||||
|
||||
/*
|
||||
Implementors of this interface also need to implement
|
||||
nsISupportsWeakReference so that svg-values can store safe owning
|
||||
refs.
|
||||
*/
|
||||
|
||||
// {33e46adb-9aa4-4903-9ede-699fae1107d8}
|
||||
#define NS_ISVGVALUEOBSERVER_IID \
|
||||
{ 0x33e46adb, 0x9aa4, 0x4903, { 0x9e, 0xde, 0x69, 0x9f, 0xae, 0x11, 0x7, 0xd8 } }
|
||||
|
||||
|
||||
class nsISVGValueObserver : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_ISVGVALUEOBSERVER_IID; return iid; }
|
||||
|
||||
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable)=0;
|
||||
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable)=0;
|
||||
};
|
||||
|
||||
#endif // __NS_ISVGVALUEOBSERVER_H__
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGValue.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsSVGAnimatedLength.h"
|
||||
#include "nsSVGLength.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsSVGAnimatedLength
|
||||
|
||||
class nsSVGAnimatedLength : public nsIDOMSVGAnimatedLength,
|
||||
public nsSVGValue,
|
||||
public nsISVGValueObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGAnimatedLength(nsIDOMSVGAnimatedLength** result,
|
||||
nsIDOMSVGLength* baseVal);
|
||||
nsSVGAnimatedLength();
|
||||
~nsSVGAnimatedLength();
|
||||
void Init(nsIDOMSVGLength* baseVal);
|
||||
|
||||
public:
|
||||
// nsISupports interface:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMSVGAnimatedLength interface:
|
||||
NS_DECL_NSIDOMSVGANIMATEDLENGTH
|
||||
|
||||
// remainder of nsISVGValue interface:
|
||||
NS_IMETHOD SetValueString(const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetValueString(nsAWritableString& aValue);
|
||||
|
||||
// nsISVGValueObserver
|
||||
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable);
|
||||
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable);
|
||||
|
||||
// nsISupportsWeakReference
|
||||
// implementation inherited from nsSupportsWeakReference
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDOMSVGLength> mBaseVal;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGAnimatedLength::nsSVGAnimatedLength()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsSVGAnimatedLength::~nsSVGAnimatedLength()
|
||||
{
|
||||
if (!mBaseVal) return;
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(mBaseVal);
|
||||
if (!val) return;
|
||||
val->RemoveObserver(this);
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGAnimatedLength::Init(nsIDOMSVGLength* baseVal)
|
||||
{
|
||||
mBaseVal = baseVal;
|
||||
if (!mBaseVal) return;
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(mBaseVal);
|
||||
NS_ASSERTION(val, "baseval needs to implement nsISVGValue interface");
|
||||
if (!val) return;
|
||||
val->AddObserver(this);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ADDREF(nsSVGAnimatedLength)
|
||||
NS_IMPL_RELEASE(nsSVGAnimatedLength)
|
||||
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGAnimatedLength)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGValue)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedLength)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGAnimatedLength)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISVGValue)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValue methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAnimatedLength::SetValueString(const nsAReadableString& aValue)
|
||||
{
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mBaseVal);
|
||||
return value->SetValueString(aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAnimatedLength::GetValueString(nsAWritableString& aValue)
|
||||
{
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mBaseVal);
|
||||
return value->GetValueString(aValue);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGAnimatedLength methods:
|
||||
|
||||
/* readonly attribute nsIDOMSVGLength baseVal; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGAnimatedLength::GetBaseVal(nsIDOMSVGLength * *aBaseVal)
|
||||
{
|
||||
*aBaseVal = mBaseVal;
|
||||
NS_ADDREF(*aBaseVal);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGLength animVal; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGAnimatedLength::GetAnimVal(nsIDOMSVGLength * *aAnimVal)
|
||||
{
|
||||
*aAnimVal = mBaseVal;
|
||||
NS_ADDREF(*aAnimVal);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValueObserver methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAnimatedLength::WillModifySVGObservable(nsISVGValue* observable)
|
||||
{
|
||||
WillModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAnimatedLength::DidModifySVGObservable (nsISVGValue* observable)
|
||||
{
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Exported creation functions
|
||||
|
||||
nsresult
|
||||
NS_NewSVGAnimatedLength(nsIDOMSVGAnimatedLength** aResult,
|
||||
nsIDOMSVGLength* baseVal)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
nsSVGAnimatedLength* animatedLength = new nsSVGAnimatedLength();
|
||||
if(!animatedLength) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(animatedLength);
|
||||
|
||||
// nsCOMPtr<nsIDOMSVGLength> baseVal;
|
||||
// NS_NewSVGLength(getter_AddRefs(baseVal), owner);
|
||||
|
||||
animatedLength->Init(baseVal);
|
||||
|
||||
*aResult = (nsIDOMSVGAnimatedLength*) animatedLength;
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#ifndef __NS_SVGANIMATEDLENGTH_H__
|
||||
#define __NS_SVGANIMATEDLENGTH_H__
|
||||
|
||||
#include "nsIDOMSVGAnimatedLength.h"
|
||||
#include "nsIDOMSVGLength.h"
|
||||
|
||||
nsresult NS_NewSVGAnimatedLength(nsIDOMSVGAnimatedLength** result,
|
||||
nsIDOMSVGLength* baseVal);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //__NS_SVGANIMATEDLENGTH_H__
|
|
@ -0,0 +1,193 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGAnimatedRect.h"
|
||||
#include "nsSVGRect.h"
|
||||
#include "nsSVGValue.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsSVGAnimatedRect
|
||||
|
||||
class nsSVGAnimatedRect : public nsIDOMSVGAnimatedRect,
|
||||
public nsSVGValue,
|
||||
public nsISVGValueObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGAnimatedRect(nsIDOMSVGAnimatedRect** result,
|
||||
nsIDOMSVGRect* baseVal);
|
||||
|
||||
nsSVGAnimatedRect();
|
||||
~nsSVGAnimatedRect();
|
||||
void Init(nsIDOMSVGRect* baseVal);
|
||||
|
||||
public:
|
||||
// nsISupports interface:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMSVGAnimatedRect interface:
|
||||
NS_DECL_NSIDOMSVGANIMATEDRECT
|
||||
|
||||
// remainder of nsISVGValue interface:
|
||||
NS_IMETHOD SetValueString(const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetValueString(nsAWritableString& aValue);
|
||||
|
||||
// nsISVGValueObserver
|
||||
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable);
|
||||
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable);
|
||||
|
||||
// nsISupportsWeakReference
|
||||
// implementation inherited from nsSupportsWeakReference
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDOMSVGRect> mBaseVal;
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGAnimatedRect::nsSVGAnimatedRect()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsSVGAnimatedRect::~nsSVGAnimatedRect()
|
||||
{
|
||||
if (!mBaseVal) return;
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(mBaseVal);
|
||||
if (!val) return;
|
||||
val->RemoveObserver(this);
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGAnimatedRect::Init(nsIDOMSVGRect* baseVal)
|
||||
{
|
||||
mBaseVal = baseVal;
|
||||
if (!mBaseVal) return;
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(mBaseVal);
|
||||
if (!val) return;
|
||||
val->AddObserver(this);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ISUPPORTS4(nsSVGAnimatedRect,
|
||||
nsISVGValue,
|
||||
nsIDOMSVGAnimatedRect,
|
||||
nsISupportsWeakReference,
|
||||
nsISVGValueObserver);
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValue methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAnimatedRect::SetValueString(const nsAReadableString& aValue)
|
||||
{
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mBaseVal);
|
||||
return value->SetValueString(aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAnimatedRect::GetValueString(nsAWritableString& aValue)
|
||||
{
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mBaseVal);
|
||||
return value->GetValueString(aValue);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGAnimatedRect methods:
|
||||
|
||||
/* readonly attribute nsIDOMSVGRect baseVal; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGAnimatedRect::GetBaseVal(nsIDOMSVGRect * *aBaseVal)
|
||||
{
|
||||
*aBaseVal = mBaseVal;
|
||||
NS_ADDREF(*aBaseVal);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGRect animVal; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGAnimatedRect::GetAnimVal(nsIDOMSVGRect * *aAnimVal)
|
||||
{
|
||||
*aAnimVal = mBaseVal;
|
||||
NS_ADDREF(*aAnimVal);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValueObserver methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAnimatedRect::WillModifySVGObservable(nsISVGValue* observable)
|
||||
{
|
||||
WillModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAnimatedRect::DidModifySVGObservable (nsISVGValue* observable)
|
||||
{
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Exported creation functions:
|
||||
|
||||
nsresult
|
||||
NS_NewSVGAnimatedRect(nsIDOMSVGAnimatedRect** result,
|
||||
nsIDOMSVGRect* baseVal)
|
||||
{
|
||||
*result = nsnull;
|
||||
|
||||
nsSVGAnimatedRect* animatedRect = new nsSVGAnimatedRect();
|
||||
if(!animatedRect) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(animatedRect);
|
||||
|
||||
animatedRect->Init(baseVal);
|
||||
|
||||
*result = (nsIDOMSVGAnimatedRect*) animatedRect;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#ifndef __NS_SVGANIMATEDRECT_H__
|
||||
#define __NS_SVGANIMATEDRECT_H__
|
||||
|
||||
#include "nsIDOMSVGAnimatedRect.h"
|
||||
#include "nsIDOMSVGRect.h"
|
||||
|
||||
nsresult
|
||||
NS_NewSVGAnimatedRect(nsIDOMSVGAnimatedRect** result,
|
||||
nsIDOMSVGRect* baseVal);
|
||||
|
||||
#endif //__NS_SVGANIMATEDRECT_H__
|
|
@ -0,0 +1,201 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGAnimatedTransformList.h"
|
||||
#include "nsSVGTransformList.h"
|
||||
#include "nsSVGValue.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsSVGAnimatedTransformList
|
||||
|
||||
class nsSVGAnimatedTransformList : public nsIDOMSVGAnimatedTransformList,
|
||||
public nsSVGValue,
|
||||
public nsISVGValueObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
protected:
|
||||
friend nsresult
|
||||
NS_NewSVGAnimatedTransformList(nsIDOMSVGAnimatedTransformList** result,
|
||||
nsIDOMSVGTransformList* baseVal);
|
||||
|
||||
nsSVGAnimatedTransformList();
|
||||
~nsSVGAnimatedTransformList();
|
||||
void Init(nsIDOMSVGTransformList* baseVal);
|
||||
|
||||
public:
|
||||
// nsISupports interface:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMSVGAnimatedTransformList interface:
|
||||
NS_DECL_NSIDOMSVGANIMATEDTRANSFORMLIST
|
||||
|
||||
// remainder of nsISVGValue interface:
|
||||
NS_IMETHOD SetValueString(const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetValueString(nsAWritableString& aValue);
|
||||
|
||||
// nsISVGValueObserver
|
||||
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable);
|
||||
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable);
|
||||
|
||||
// nsISupportsWeakReference
|
||||
// implementation inherited from nsSupportsWeakReference
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDOMSVGTransformList> mBaseVal;
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGAnimatedTransformList::nsSVGAnimatedTransformList()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsSVGAnimatedTransformList::~nsSVGAnimatedTransformList()
|
||||
{
|
||||
if (!mBaseVal) return;
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(mBaseVal);
|
||||
if (!val) return;
|
||||
val->RemoveObserver(this);
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGAnimatedTransformList::Init(nsIDOMSVGTransformList* baseVal)
|
||||
{
|
||||
mBaseVal = baseVal;
|
||||
if (!mBaseVal) return;
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(mBaseVal);
|
||||
if (!val) return;
|
||||
val->AddObserver(this);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ADDREF(nsSVGAnimatedTransformList)
|
||||
NS_IMPL_RELEASE(nsSVGAnimatedTransformList)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGAnimatedTransformList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGValue)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedTransformList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGAnimatedTransformList)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISVGValue)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValue methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAnimatedTransformList::SetValueString(const nsAReadableString& aValue)
|
||||
{
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mBaseVal);
|
||||
return value->SetValueString(aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAnimatedTransformList::GetValueString(nsAWritableString& aValue)
|
||||
{
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mBaseVal);
|
||||
return value->GetValueString(aValue);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGAnimatedTransformList methods:
|
||||
|
||||
/* readonly attribute nsIDOMSVGTransformList baseVal; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGAnimatedTransformList::GetBaseVal(nsIDOMSVGTransformList * *aBaseVal)
|
||||
{
|
||||
*aBaseVal = mBaseVal;
|
||||
NS_ADDREF(*aBaseVal);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGTransformList animVal; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGAnimatedTransformList::GetAnimVal(nsIDOMSVGTransformList * *aAnimVal)
|
||||
{
|
||||
*aAnimVal = mBaseVal;
|
||||
NS_ADDREF(*aAnimVal);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValueObserver methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAnimatedTransformList::WillModifySVGObservable(nsISVGValue* observable)
|
||||
{
|
||||
WillModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAnimatedTransformList::DidModifySVGObservable (nsISVGValue* observable)
|
||||
{
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Exported creation functions:
|
||||
|
||||
nsresult
|
||||
NS_NewSVGAnimatedTransformList(nsIDOMSVGAnimatedTransformList** result,
|
||||
nsIDOMSVGTransformList* baseVal)
|
||||
{
|
||||
*result = nsnull;
|
||||
|
||||
nsSVGAnimatedTransformList* animatedTransformList = new nsSVGAnimatedTransformList();
|
||||
if(!animatedTransformList) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(animatedTransformList);
|
||||
|
||||
animatedTransformList->Init(baseVal);
|
||||
|
||||
*result = (nsIDOMSVGAnimatedTransformList*) animatedTransformList;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#ifndef __NS_SVGANIMATEDTRANSFORMLIST_H__
|
||||
#define __NS_SVGANIMATEDTRANSFORMLIST_H__
|
||||
|
||||
#include "nsIDOMSVGAnimTransformList.h"
|
||||
#include "nsIDOMSVGTransformList.h"
|
||||
|
||||
nsresult
|
||||
NS_NewSVGAnimatedTransformList(nsIDOMSVGAnimatedTransformList** result,
|
||||
nsIDOMSVGTransformList* baseVal);
|
||||
|
||||
#endif //__NS_SVGANIMATEDTRANSFORMLIST_H__
|
|
@ -0,0 +1,974 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGAttributes.h"
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIBindingManager.h"
|
||||
#include "nsIXBLBinding.h"
|
||||
#include "nsMutationEvent.h"
|
||||
#include "nsGenericElement.h"
|
||||
#include "nsIDOMMutationEvent.h"
|
||||
#include "nsStyleConsts.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsSVGAttribute implementation
|
||||
|
||||
nsresult
|
||||
nsSVGAttribute::Create(nsINodeInfo* aNodeInfo,
|
||||
nsISVGValue* value,
|
||||
nsSVGAttributeFlags flags,
|
||||
nsSVGAttribute** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNodeInfo);
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aResult = (nsSVGAttribute*) new nsSVGAttribute(aNodeInfo, value, flags);
|
||||
if(!*aResult) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
if ((*aResult)->mValue)
|
||||
(*aResult)->mValue->AddObserver(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGAttribute::Create(nsINodeInfo* aNodeInfo,
|
||||
const nsAReadableString& value,
|
||||
nsSVGAttribute** aResult)
|
||||
{
|
||||
nsCOMPtr<nsISVGValue> svg_value;
|
||||
NS_CreateSVGGenericStringValue(value, getter_AddRefs(svg_value));
|
||||
if(!svg_value) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return nsSVGAttribute::Create(aNodeInfo, svg_value, 0, aResult);
|
||||
}
|
||||
|
||||
|
||||
nsSVGAttribute::nsSVGAttribute(nsINodeInfo* aNodeInfo,
|
||||
nsISVGValue* value,
|
||||
nsSVGAttributeFlags flags)
|
||||
: mFlags(flags),
|
||||
mOwner(0),
|
||||
mNodeInfo(aNodeInfo),
|
||||
mValue(value)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsSVGAttribute::~nsSVGAttribute()
|
||||
{
|
||||
if (mValue)
|
||||
mValue->RemoveObserver(this);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports interface
|
||||
|
||||
NS_IMPL_ADDREF(nsSVGAttribute)
|
||||
NS_IMPL_RELEASE(nsSVGAttribute)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGAttribute)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMAttr)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGAttribute)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMNode)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNode interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetNodeName(nsAWritableString& aNodeName)
|
||||
{
|
||||
GetQualifiedName(aNodeName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetNodeValue(nsAWritableString& aNodeValue)
|
||||
{
|
||||
return GetValue()->GetValueString(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::SetNodeValue(const nsAReadableString& aNodeValue)
|
||||
{
|
||||
return SetValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = (PRUint16)nsIDOMNode::ATTRIBUTE_NODE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetParentNode(nsIDOMNode** aParentNode)
|
||||
{
|
||||
*aParentNode = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetChildNodes(nsIDOMNodeList** aChildNodes)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetFirstChild(nsIDOMNode** aFirstChild)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetLastChild(nsIDOMNode** aLastChild)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
||||
{
|
||||
*aPreviousSibling = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetNextSibling(nsIDOMNode** aNextSibling)
|
||||
{
|
||||
*aNextSibling = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
||||
{
|
||||
*aAttributes = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetNamespaceURI(nsAWritableString& aNamespaceURI)
|
||||
{
|
||||
return mNodeInfo->GetNamespaceURI(aNamespaceURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetPrefix(nsAWritableString& aPrefix)
|
||||
{
|
||||
return mNodeInfo->GetPrefix(aPrefix);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::SetPrefix(const nsAReadableString& aPrefix)
|
||||
{
|
||||
// XXX: Validate the prefix string!
|
||||
|
||||
nsINodeInfo *newNodeInfo = nsnull;
|
||||
nsCOMPtr<nsIAtom> prefix;
|
||||
|
||||
if (aPrefix.Length()) {
|
||||
prefix = dont_AddRef(NS_NewAtom(aPrefix));
|
||||
NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
nsresult rv = mNodeInfo->PrefixChanged(prefix, newNodeInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mNodeInfo = newNodeInfo;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetLocalName(nsAWritableString& aLocalName)
|
||||
{
|
||||
return mNodeInfo->GetLocalName(aLocalName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::HasChildNodes(PRBool* aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::HasAttributes(PRBool* aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::Normalize()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::IsSupported(const nsAReadableString& aFeature,
|
||||
const nsAReadableString& aVersion,
|
||||
PRBool* aReturn)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMAttr interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetName(nsAWritableString& aName)
|
||||
{
|
||||
GetQualifiedName(aName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetSpecified(PRBool* aSpecified)
|
||||
{
|
||||
// XXX this'll break when we make Clone() work
|
||||
*aSpecified = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetValue(nsAWritableString& aValue)
|
||||
{
|
||||
return GetValue()->GetValueString(aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::SetValue(const nsAReadableString& aValue)
|
||||
{
|
||||
if (mOwner) {
|
||||
return mOwner->SetAttr(mNodeInfo, aValue, PR_TRUE);
|
||||
}
|
||||
|
||||
return GetValue()->SetValueString(aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetOwnerElement(nsIDOMElement** aOwnerElement)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOwnerElement);
|
||||
|
||||
nsIContent *content;
|
||||
if (mOwner && (content = mOwner->GetContent())) {
|
||||
return content->QueryInterface(NS_GET_IID(nsIDOMElement),
|
||||
(void **)aOwnerElement);
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGAttribute methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::GetSVGValue(nsISVGValue** value)
|
||||
{
|
||||
*value = mValue;
|
||||
NS_IF_ADDREF(*value);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValueObserver methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::WillModifySVGObservable(nsISVGValue* observable)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttribute::DidModifySVGObservable (nsISVGValue* observable)
|
||||
{
|
||||
if (!mOwner) return NS_OK;
|
||||
|
||||
mOwner->AttributeWasModified(this);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation functions
|
||||
|
||||
void
|
||||
nsSVGAttribute::GetQualifiedName(nsAWritableString& aQualifiedName)const
|
||||
{
|
||||
mNodeInfo->GetQualifiedName(aQualifiedName);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsSVGAttributes
|
||||
//
|
||||
|
||||
nsSVGAttributes::nsSVGAttributes(nsIContent* aContent)
|
||||
: mContent(aContent)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
|
||||
nsSVGAttributes::~nsSVGAttributes()
|
||||
{
|
||||
ReleaseAttributes();
|
||||
ReleaseMappedAttributes();
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsSVGAttributes::Create(nsIContent* aContent, nsSVGAttributes** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aResult = new nsSVGAttributes(aContent);
|
||||
if (! *aResult) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports interface
|
||||
NS_IMPL_ISUPPORTS1(nsSVGAttributes,nsIDOMNamedNodeMap);
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation Helpers
|
||||
|
||||
void
|
||||
nsSVGAttributes::ReleaseAttributes()
|
||||
{
|
||||
PRInt32 count = mAttributes.Count();
|
||||
for (PRInt32 index = 0; index < count; ++index) {
|
||||
nsSVGAttribute* attr = NS_REINTERPRET_CAST(nsSVGAttribute*, mAttributes.ElementAt(index));
|
||||
attr->mOwner = nsnull;
|
||||
NS_RELEASE(attr);
|
||||
}
|
||||
mAttributes.Clear();
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGAttributes::ReleaseMappedAttributes()
|
||||
{
|
||||
PRInt32 count = mMappedAttributes.Count();
|
||||
for (PRInt32 index = 0; index < count; ++index) {
|
||||
nsSVGAttribute* attr = NS_REINTERPRET_CAST(nsSVGAttribute*, mMappedAttributes.ElementAt(index));
|
||||
attr->mOwner = nsnull;
|
||||
NS_RELEASE(attr);
|
||||
}
|
||||
mMappedAttributes.Clear();
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsSVGAttributes::GetMappedAttribute(nsINodeInfo* aNodeInfo, nsSVGAttribute** attrib)
|
||||
{
|
||||
PRInt32 count = mMappedAttributes.Count();
|
||||
PRInt32 index;
|
||||
for (index = 0; index < count; index++) {
|
||||
*attrib = (nsSVGAttribute*)mMappedAttributes.ElementAt(index);
|
||||
if ((*attrib)->GetNodeInfo()->Equals(aNodeInfo)) { // XXX is this the right test? (don't want to compare prefixes!)
|
||||
NS_ADDREF(*attrib);
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
*attrib = nsnull;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsSVGAttributes::IsExplicitAttribute(nsSVGAttribute* attrib)
|
||||
{
|
||||
PRInt32 count = mAttributes.Count();
|
||||
for (PRInt32 i=0; i<count; ++i) {
|
||||
if (mAttributes.ElementAt(i) == attrib)
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsSVGAttributes::IsMappedAttribute(nsSVGAttribute* attrib)
|
||||
{
|
||||
PRInt32 count = mMappedAttributes.Count();
|
||||
for (PRInt32 i=0; i<count; ++i) {
|
||||
if (mMappedAttributes.ElementAt(i) == attrib)
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
nsSVGAttribute*
|
||||
nsSVGAttributes::ElementAt(PRInt32 i) const
|
||||
{
|
||||
return (nsSVGAttribute*)mAttributes.ElementAt(i);
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGAttributes::AppendElement(nsSVGAttribute* aElement)
|
||||
{
|
||||
aElement->mOwner = this;
|
||||
NS_ADDREF(aElement);
|
||||
mAttributes.AppendElement((void*)aElement);
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGAttributes::RemoveElementAt(PRInt32 aIndex)
|
||||
{
|
||||
nsSVGAttribute* attrib = ElementAt(aIndex);
|
||||
NS_ASSERTION(attrib,"null attrib");
|
||||
if (!IsMappedAttribute(attrib))
|
||||
attrib->mOwner = 0;
|
||||
mAttributes.RemoveElementAt(aIndex);
|
||||
NS_RELEASE(attrib);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// interface used by the content element:
|
||||
|
||||
PRInt32
|
||||
nsSVGAttributes::Count() const
|
||||
{
|
||||
return mAttributes.Count();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttributes::GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsIAtom*& aPrefix,
|
||||
nsAWritableString& aResult)
|
||||
{
|
||||
NS_ASSERTION(nsnull != aName, "must have attribute name");
|
||||
if (nsnull == aName) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsresult rv = NS_CONTENT_ATTR_NOT_THERE;
|
||||
|
||||
PRInt32 count = Count();
|
||||
PRInt32 index;
|
||||
for (index = 0; index < count; index++) {
|
||||
nsSVGAttribute *attr = ElementAt(index);
|
||||
if ((aNameSpaceID == kNameSpaceID_Unknown ||
|
||||
attr->GetNodeInfo()->NamespaceEquals(aNameSpaceID)) &&
|
||||
(attr->GetNodeInfo()->Equals(aName))) {
|
||||
attr->GetNodeInfo()->GetPrefixAtom(aPrefix);
|
||||
attr->GetValue()->GetValueString(aResult);
|
||||
if (0 < aResult.Length()) {
|
||||
rv = NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
else {
|
||||
rv = NS_CONTENT_ATTR_NO_VALUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rv == NS_CONTENT_ATTR_NOT_THERE) {
|
||||
// In other cases we already set the out param.
|
||||
// Since we are returning a success code we'd better do
|
||||
// something about the out parameters (someone may have
|
||||
// given us a non-empty string).
|
||||
aResult.Truncate();
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttributes::SetAttr(nsINodeInfo* aNodeInfo,
|
||||
const nsAReadableString& aValue,
|
||||
PRBool aNotify)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNodeInfo);
|
||||
PRBool modification = PR_FALSE;
|
||||
nsAutoString oldValue;
|
||||
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
if (mContent)
|
||||
mContent->GetDocument(*getter_AddRefs(document));
|
||||
|
||||
if (aNotify && document) {
|
||||
document->BeginUpdate();
|
||||
}
|
||||
|
||||
nsSVGAttribute* attr;
|
||||
PRInt32 index;
|
||||
PRInt32 count;
|
||||
|
||||
count = Count();
|
||||
for (index = 0; index < count; index++) {
|
||||
attr = ElementAt(index);
|
||||
if (attr->GetNodeInfo() == aNodeInfo) {
|
||||
attr->GetValue()->GetValueString(oldValue);
|
||||
modification = PR_TRUE;
|
||||
attr->GetValue()->SetValueString(aValue);
|
||||
rv = NS_OK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index >= count) { // didn't find it
|
||||
|
||||
if (GetMappedAttribute(aNodeInfo, &attr)) {
|
||||
AppendElement(attr);
|
||||
attr->GetValue()->SetValueString(aValue);
|
||||
}
|
||||
else {
|
||||
rv = nsSVGAttribute::Create(aNodeInfo, aValue, &attr);
|
||||
NS_ENSURE_TRUE(attr, rv);
|
||||
AppendElement(attr);
|
||||
}
|
||||
attr->Release();
|
||||
rv = NS_OK;
|
||||
}
|
||||
|
||||
if (document && NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIAtom> name;
|
||||
PRInt32 nameSpaceID;
|
||||
|
||||
aNodeInfo->GetNameAtom(*getter_AddRefs(name));
|
||||
aNodeInfo->GetNamespaceID(nameSpaceID);
|
||||
|
||||
nsCOMPtr<nsIBindingManager> bindingManager;
|
||||
document->GetBindingManager(getter_AddRefs(bindingManager));
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
bindingManager->GetBinding(mContent, getter_AddRefs(binding));
|
||||
if (binding)
|
||||
binding->AttributeChanged(name, nameSpaceID, PR_FALSE);
|
||||
|
||||
if (nsGenericElement::HasMutationListeners(mContent, NS_EVENT_BITS_MUTATION_ATTRMODIFIED)) {
|
||||
nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(mContent));
|
||||
nsMutationEvent mutation;
|
||||
mutation.eventStructType = NS_MUTATION_EVENT;
|
||||
mutation.message = NS_MUTATION_ATTRMODIFIED;
|
||||
mutation.mTarget = node;
|
||||
|
||||
//XXX mutation.mRelatedNode = do_QueryInterface(attr);
|
||||
attr->QueryInterface(NS_GET_IID(nsIDOMNode), getter_AddRefs(mutation.mRelatedNode));
|
||||
mutation.mAttrName = name;
|
||||
if (!oldValue.IsEmpty())
|
||||
mutation.mPrevAttrValue = getter_AddRefs(NS_NewAtom(oldValue));
|
||||
if (!aValue.IsEmpty())
|
||||
mutation.mNewAttrValue = getter_AddRefs(NS_NewAtom(aValue));
|
||||
mutation.mAttrChange = modification ? nsIDOMMutationEvent::MODIFICATION :
|
||||
nsIDOMMutationEvent::ADDITION;
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsCOMPtr<nsIDOMEvent> domEvent;
|
||||
mContent->HandleDOMEvent(nsnull, &mutation, getter_AddRefs(domEvent),
|
||||
NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
|
||||
if (aNotify) {
|
||||
PRInt32 modHint = modification ? PRInt32(nsIDOMMutationEvent::MODIFICATION)
|
||||
: PRInt32(nsIDOMMutationEvent::ADDITION);
|
||||
document->AttributeChanged(mContent, nameSpaceID, name,
|
||||
modHint, NS_STYLE_HINT_UNKNOWN);
|
||||
document->EndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttributes::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
PRBool aNotify)
|
||||
{
|
||||
NS_ASSERTION(nsnull != aName, "must have attribute name");
|
||||
if (nsnull == aName) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
if (mContent)
|
||||
mContent->GetDocument(*getter_AddRefs(document));
|
||||
|
||||
PRInt32 count = Count();
|
||||
PRInt32 index;
|
||||
PRBool found = PR_FALSE;
|
||||
for (index = 0; index < count; index++) {
|
||||
nsSVGAttribute* attr = ElementAt(index);
|
||||
if ((aNameSpaceID == kNameSpaceID_Unknown ||
|
||||
attr->GetNodeInfo()->NamespaceEquals(aNameSpaceID)) &&
|
||||
attr->GetNodeInfo()->Equals(aName) &&
|
||||
!attr->IsRequired() &&
|
||||
!attr->IsFixed()) {
|
||||
if (aNotify && document) {
|
||||
document->BeginUpdate();
|
||||
}
|
||||
|
||||
if (mContent && nsGenericElement::HasMutationListeners(mContent, NS_EVENT_BITS_MUTATION_ATTRMODIFIED)) {
|
||||
nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(mContent));
|
||||
nsMutationEvent mutation;
|
||||
mutation.eventStructType = NS_MUTATION_EVENT;
|
||||
mutation.message = NS_MUTATION_ATTRMODIFIED;
|
||||
mutation.mTarget = node;
|
||||
|
||||
//XXX mutation.mRelatedNode = do_QueryInterface(attr);
|
||||
attr->QueryInterface(NS_GET_IID(nsIDOMNode), getter_AddRefs(mutation.mRelatedNode));
|
||||
mutation.mAttrName = aName;
|
||||
nsAutoString str;
|
||||
attr->GetValue()->GetValueString(str);
|
||||
if (!str.IsEmpty())
|
||||
mutation.mPrevAttrValue = getter_AddRefs(NS_NewAtom(str));
|
||||
mutation.mAttrChange = nsIDOMMutationEvent::REMOVAL;
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsCOMPtr<nsIDOMEvent> domEvent;
|
||||
mContent->HandleDOMEvent(nsnull, &mutation, getter_AddRefs(domEvent),
|
||||
NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
|
||||
RemoveElementAt(index);
|
||||
found = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) && found && document) {
|
||||
nsCOMPtr<nsIBindingManager> bindingManager;
|
||||
document->GetBindingManager(getter_AddRefs(bindingManager));
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
bindingManager->GetBinding(mContent, getter_AddRefs(binding));
|
||||
if (binding)
|
||||
binding->AttributeChanged(aName, aNameSpaceID, PR_TRUE);
|
||||
|
||||
if (aNotify) {
|
||||
document->AttributeChanged(mContent, aNameSpaceID, aName,
|
||||
nsIDOMMutationEvent::REMOVAL,
|
||||
NS_STYLE_HINT_UNKNOWN);
|
||||
document->EndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSVGAttributes::HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const
|
||||
{
|
||||
// XXX - this should be hashed, or something
|
||||
PRInt32 count = Count();
|
||||
PRInt32 index;
|
||||
for (index = 0; index < count; index++) {
|
||||
nsSVGAttribute *attr = ElementAt(index);
|
||||
if ((aNameSpaceID == kNameSpaceID_Unknown ||
|
||||
attr->GetNodeInfo()->NamespaceEquals(aNameSpaceID)) &&
|
||||
(attr->GetNodeInfo()->Equals(aName))) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttributes::NormalizeAttrString(const nsAReadableString& aStr,
|
||||
nsINodeInfo*& aNodeInfo)
|
||||
{
|
||||
PRInt32 indx, count = Count();
|
||||
for (indx = 0; indx < count; indx++) {
|
||||
nsSVGAttribute* attr = ElementAt(indx);
|
||||
if (attr->GetNodeInfo()->QualifiedNameEquals(aStr)) {
|
||||
aNodeInfo = attr->GetNodeInfo();
|
||||
NS_ADDREF(aNodeInfo);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_ASSERTION(mContent,"no owner content");
|
||||
if (!mContent) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> contentNodeInfo;
|
||||
mContent->GetNodeInfo(*getter_AddRefs(contentNodeInfo));
|
||||
|
||||
nsCOMPtr<nsINodeInfoManager> nimgr;
|
||||
contentNodeInfo->GetNodeInfoManager(*getter_AddRefs(nimgr));
|
||||
NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE);
|
||||
|
||||
return nimgr->GetNodeInfo(aStr, nsnull, kNameSpaceID_None, aNodeInfo);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttributes::GetAttrNameAt(PRInt32 aIndex,
|
||||
PRInt32& aNameSpaceID,
|
||||
nsIAtom*& aName,
|
||||
nsIAtom*& aPrefix)
|
||||
{
|
||||
nsSVGAttribute* attr = ElementAt(aIndex);
|
||||
if (attr) {
|
||||
attr->GetNodeInfo()->GetNamespaceID(aNameSpaceID);
|
||||
attr->GetNodeInfo()->GetNameAtom(aName);
|
||||
attr->GetNodeInfo()->GetPrefixAtom(aPrefix);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
aNameSpaceID = kNameSpaceID_None;
|
||||
aName = nsnull;
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttributes::AddMappedSVGValue(nsIAtom* name, nsISupports* value)
|
||||
{
|
||||
nsCOMPtr<nsISVGValue> svg_value = do_QueryInterface(value);
|
||||
NS_ENSURE_TRUE(svg_value, NS_ERROR_FAILURE);
|
||||
|
||||
NS_ASSERTION(mContent,"no owner content");
|
||||
if (!mContent) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> contentNodeInfo;
|
||||
mContent->GetNodeInfo(*getter_AddRefs(contentNodeInfo));
|
||||
|
||||
nsCOMPtr<nsINodeInfoManager> nimgr;
|
||||
contentNodeInfo->GetNodeInfoManager(*getter_AddRefs(nimgr));
|
||||
NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
nimgr->GetNodeInfo(name, nsnull, kNameSpaceID_None, *getter_AddRefs(ni));
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
||||
|
||||
nsSVGAttribute* attrib = nsnull;
|
||||
nsSVGAttribute::Create(ni, svg_value, NS_SVGATTRIBUTE_FLAGS_MAPPED, &attrib);
|
||||
NS_ENSURE_TRUE(attrib, NS_ERROR_FAILURE);
|
||||
attrib->mOwner = this;
|
||||
mMappedAttributes.AppendElement((void*)attrib);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttributes::CopyAttributes(nsSVGAttributes* dest)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ENSURE_TRUE(dest, NS_ERROR_FAILURE);
|
||||
PRInt32 count = Count();
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsSVGAttribute* attr = ElementAt(i);
|
||||
nsAutoString value;
|
||||
rv = attr->GetValue()->GetValueString(value);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = dest->SetAttr(attr->GetNodeInfo(), value, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// interface used by our attributes:
|
||||
|
||||
void
|
||||
nsSVGAttributes::AttributeWasModified(nsSVGAttribute* caller)
|
||||
{
|
||||
if (!IsExplicitAttribute(caller)) {
|
||||
NS_ASSERTION(IsMappedAttribute(caller), "unknown attribute");
|
||||
AppendElement(caller);
|
||||
}
|
||||
// XXX Mutation events
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNamedNodeMap interface:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttributes::GetLength(PRUint32* aLength)
|
||||
{
|
||||
NS_PRECONDITION(aLength != nsnull, "null ptr");
|
||||
if (! aLength)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aLength = mAttributes.Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttributes::GetNamedItem(const nsAReadableString& aName,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
*aReturn = nsnull;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> inpNodeInfo;
|
||||
|
||||
if (NS_FAILED(rv = mContent->NormalizeAttrString(aName, *getter_AddRefs(inpNodeInfo))))
|
||||
return rv;
|
||||
|
||||
for (PRInt32 i = mAttributes.Count() - 1; i >= 0; --i) {
|
||||
nsSVGAttribute* attr = (nsSVGAttribute*) mAttributes[i];
|
||||
nsINodeInfo *ni = attr->GetNodeInfo();
|
||||
|
||||
if (inpNodeInfo->Equals(ni)) {
|
||||
NS_ADDREF(attr);
|
||||
*aReturn = attr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttributes::SetNamedItem(nsIDOMNode* aArg, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttributes::RemoveNamedItem(const nsAReadableString& aName,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> element( do_QueryInterface(mContent) );
|
||||
if (element) {
|
||||
return element->RemoveAttribute(aName);
|
||||
*aReturn = nsnull; // XXX should be the element we just removed
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAttributes::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = (nsSVGAttribute*) mAttributes[aIndex];
|
||||
NS_IF_ADDREF(*aReturn);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGAttributes::GetNamedItemNS(const nsAReadableString& aNamespaceURI,
|
||||
const nsAReadableString& aLocalName,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGAttributes::SetNamedItemNS(nsIDOMNode* aArg, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGAttributes::RemoveNamedItemNS(const nsAReadableString& aNamespaceURI,
|
||||
const nsAReadableString& aLocalName,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,213 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
|
||||
#ifndef __NS_SVGATTRIBUTES_H__
|
||||
#define __NS_SVGATTRIBUTES_H__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISVGAttribute.h"
|
||||
#include "nsIDOMNamedNodeMap.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsISVGValue.h"
|
||||
#include "nsISVGValueObserver.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsSVGAttributes;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// SVG Attribute Flags
|
||||
|
||||
// XXX these flags are not used yet
|
||||
|
||||
typedef PRUint32 nsSVGAttributeFlags;
|
||||
|
||||
// This is a #REQUIRED-attribute. Should not be allowed to unset
|
||||
#define NS_SVGATTRIBUTE_FLAGS_REQUIRED 0x0001
|
||||
|
||||
// This is a #FIXED-attribute. Should not be allowed to set/unset
|
||||
#define NS_SVGATTRIBUTE_FLAGS_FIXED 0x0002
|
||||
|
||||
// this attribute is a mapped value. if it is being unset we keep it
|
||||
// around to be reused:
|
||||
#define NS_SVGATTRIBUTE_FLAGS_MAPPED 0x0004
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsSVGAttribute
|
||||
|
||||
class nsSVGAttribute : public nsISVGAttribute, // :nsIDOMAttr
|
||||
public nsISVGValueObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
static nsresult
|
||||
Create(nsINodeInfo* aNodeInfo,
|
||||
nsISVGValue* value,
|
||||
nsSVGAttributeFlags flags,
|
||||
nsSVGAttribute** aResult);
|
||||
|
||||
// create a generic string attribute:
|
||||
static nsresult
|
||||
Create(nsINodeInfo* aNodeInfo,
|
||||
const nsAReadableString& value,
|
||||
nsSVGAttribute** aResult);
|
||||
|
||||
protected:
|
||||
|
||||
nsSVGAttribute(nsINodeInfo* aNodeInfo,
|
||||
nsISVGValue* value,
|
||||
nsSVGAttributeFlags flags);
|
||||
|
||||
virtual ~nsSVGAttribute();
|
||||
|
||||
public:
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNode interface
|
||||
NS_DECL_NSIDOMNODE
|
||||
|
||||
// nsIDOMAttr interface
|
||||
NS_DECL_NSIDOMATTR
|
||||
|
||||
// nsISVGAttribute interface
|
||||
NS_IMETHOD GetSVGValue(nsISVGValue** value);
|
||||
|
||||
// nsISVGValueObserver
|
||||
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable);
|
||||
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable);
|
||||
|
||||
// nsISupportsWeakReference
|
||||
// implementation inherited from nsSupportsWeakReference
|
||||
|
||||
|
||||
// other implementation functions
|
||||
nsINodeInfo* GetNodeInfo()const { return mNodeInfo; }
|
||||
void GetQualifiedName(nsAWritableString& aQualifiedName)const;
|
||||
|
||||
nsISVGValue* GetValue() { return mValue; }
|
||||
|
||||
nsSVGAttributeFlags GetFlags()const { return mFlags; }
|
||||
PRBool IsRequired()const { return mFlags & NS_SVGATTRIBUTE_FLAGS_REQUIRED; }
|
||||
PRBool IsFixed()const { return mFlags & NS_SVGATTRIBUTE_FLAGS_FIXED; }
|
||||
|
||||
protected:
|
||||
friend class nsSVGAttributes;
|
||||
|
||||
nsSVGAttributeFlags mFlags;
|
||||
nsSVGAttributes* mOwner;
|
||||
nsCOMPtr<nsINodeInfo> mNodeInfo;
|
||||
nsCOMPtr<nsISVGValue> mValue;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsSVGAttributes: the collection of attribs for one content element
|
||||
|
||||
class nsSVGAttributes : public nsIDOMNamedNodeMap
|
||||
{
|
||||
public:
|
||||
static nsresult
|
||||
Create(nsIContent* aElement, nsSVGAttributes** aResult);
|
||||
|
||||
protected:
|
||||
nsSVGAttributes(nsIContent* aContent);
|
||||
virtual ~nsSVGAttributes();
|
||||
|
||||
public:
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNamedNodeMap interface
|
||||
NS_DECL_NSIDOMNAMEDNODEMAP
|
||||
|
||||
// interface for the content element:
|
||||
|
||||
PRInt32 Count() const;
|
||||
NS_IMETHOD GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsIAtom*& aPrefix,
|
||||
nsAWritableString& aResult);
|
||||
NS_IMETHOD SetAttr(nsINodeInfo* aNodeInfo,
|
||||
const nsAReadableString& aValue,
|
||||
PRBool aNotify);
|
||||
NS_IMETHOD UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
PRBool aNotify);
|
||||
NS_IMETHOD_(PRBool) HasAttr(PRInt32 aNameSpaceID,
|
||||
nsIAtom* aName) const;
|
||||
NS_IMETHOD NormalizeAttrString(const nsAReadableString& aStr,
|
||||
nsINodeInfo*& aNodeInfo);
|
||||
NS_IMETHOD GetAttrNameAt(PRInt32 aIndex,
|
||||
PRInt32& aNameSpaceID,
|
||||
nsIAtom*& aName,
|
||||
nsIAtom*& aPrefix);
|
||||
|
||||
NS_IMETHOD AddMappedSVGValue(nsIAtom* name, nsISupports* value);
|
||||
|
||||
NS_IMETHOD CopyAttributes(nsSVGAttributes* dest);
|
||||
|
||||
// interface for our attributes:
|
||||
nsIContent* GetContent(){ return mContent; }
|
||||
void AttributeWasModified(nsSVGAttribute* caller);
|
||||
|
||||
protected:
|
||||
// implementation helpers:
|
||||
void ReleaseAttributes();
|
||||
void ReleaseMappedAttributes();
|
||||
PRBool GetMappedAttribute(nsINodeInfo* aNodeInfo, nsSVGAttribute**
|
||||
attrib);
|
||||
|
||||
PRBool IsExplicitAttribute(nsSVGAttribute* attrib);
|
||||
PRBool IsMappedAttribute(nsSVGAttribute* attrib);
|
||||
|
||||
nsSVGAttribute* ElementAt(PRInt32 index) const;
|
||||
void AppendElement(nsSVGAttribute* aElement);
|
||||
void RemoveElementAt(PRInt32 aIndex);
|
||||
|
||||
|
||||
nsIContent* mContent; // our owner
|
||||
|
||||
nsAutoVoidArray mAttributes;
|
||||
nsAutoVoidArray mMappedAttributes;
|
||||
};
|
||||
|
||||
|
||||
#endif // __NS_SVGATTRIBUTES_H__
|
||||
|
|
@ -0,0 +1,258 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGGraphicElement.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsSVGAnimatedLength.h"
|
||||
#include "nsSVGLength.h"
|
||||
#include "nsIDOMSVGCircleElement.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
typedef nsSVGGraphicElement nsSVGCircleElementBase;
|
||||
|
||||
class nsSVGCircleElement : public nsSVGCircleElementBase,
|
||||
public nsIDOMSVGCircleElement
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGCircleElement(nsIContent **aResult,
|
||||
nsINodeInfo *aNodeInfo);
|
||||
nsSVGCircleElement();
|
||||
virtual ~nsSVGCircleElement();
|
||||
virtual nsresult Init();
|
||||
|
||||
public:
|
||||
// interfaces:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMSVGCIRCLEELEMENT
|
||||
|
||||
// xxx I wish we could use virtual inheritance
|
||||
NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGCircleElementBase::)
|
||||
NS_FORWARD_NSIDOMELEMENT(nsSVGCircleElementBase::)
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGCircleElementBase::)
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mCx;
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mCy;
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mR;
|
||||
|
||||
};
|
||||
|
||||
|
||||
nsresult NS_NewSVGCircleElement(nsIContent **aResult, nsINodeInfo *aNodeInfo)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
nsSVGCircleElement* it = new nsSVGCircleElement();
|
||||
|
||||
if (!it) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = NS_STATIC_CAST(nsGenericElement*,it)->Init(aNodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aResult = NS_STATIC_CAST(nsIContent *, it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsSVGCircleElement,nsSVGCircleElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(nsSVGCircleElement,nsSVGCircleElementBase)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGCircleElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGCircleElement)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGCircleElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGCircleElementBase)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGCircleElement::nsSVGCircleElement()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
nsSVGCircleElement::~nsSVGCircleElement()
|
||||
{
|
||||
if (mCx) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mCx);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
if (mCy) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mCy);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
if (mR) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mR);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsSVGCircleElement::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsSVGCircleElementBase::Init();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// Create mapped properties:
|
||||
|
||||
// DOM property: cx , #IMPLIED attrib: cx
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eXDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mCx), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::cx, mCx);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
// DOM property: cy , #IMPLIED attrib: cy
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eYDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mCy), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::cy, mCy);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
// DOM property: r , #REQUIRED attrib: r
|
||||
// XXX: enforce requiredness
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eNoDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mR), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::r, mR);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNode methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGCircleElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
nsSVGCircleElement* it = new nsSVGCircleElement();
|
||||
|
||||
if (!it) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = NS_STATIC_CAST(nsGenericElement*,it)->Init(mNodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = CopyNode(it, aDeep);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aReturn = NS_STATIC_CAST(nsSVGCircleElementBase*, it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGCircleElement methods
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength cx; */
|
||||
NS_IMETHODIMP nsSVGCircleElement::GetCx(nsIDOMSVGAnimatedLength * *aCx)
|
||||
{
|
||||
*aCx = mCx;
|
||||
NS_IF_ADDREF(*aCx);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength cy; */
|
||||
NS_IMETHODIMP nsSVGCircleElement::GetCy(nsIDOMSVGAnimatedLength * *aCy)
|
||||
{
|
||||
*aCy = mCy;
|
||||
NS_IF_ADDREF(*aCy);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength r; */
|
||||
NS_IMETHODIMP nsSVGCircleElement::GetR(nsIDOMSVGAnimatedLength * *aR)
|
||||
{
|
||||
*aR = mR;
|
||||
NS_IF_ADDREF(*aR);
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,862 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGElement.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsRange.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOMMutationEvent.h"
|
||||
#include "nsMutationEvent.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIBindingManager.h"
|
||||
#include "nsIXBLBinding.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIDOMViewCSS.h"
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsIStyleRule.h"
|
||||
#include "nsIDOMSVGSVGElement.h"
|
||||
#include "nsRuleWalker.h"
|
||||
#include "nsSVGStyleValue.h"
|
||||
|
||||
nsSVGElement::nsSVGElement()
|
||||
: mAttributes(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
nsSVGElement::~nsSVGElement()
|
||||
{
|
||||
|
||||
PRInt32 count = mChildren.Count();
|
||||
PRInt32 index;
|
||||
for (index = 0; index < count; index++) {
|
||||
nsIContent* kid = (nsIContent *)mChildren.ElementAt(index);
|
||||
kid->SetParent(nsnull);
|
||||
NS_RELEASE(kid);
|
||||
}
|
||||
|
||||
if (mAttributes)
|
||||
NS_RELEASE(mAttributes);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsSVGElement,nsGenericElement)
|
||||
NS_IMPL_RELEASE_INHERITED(nsSVGElement,nsGenericElement)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIXMLContent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Node, nsNode3Tearoff(this))
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
|
||||
// provided by nsGenericElement:
|
||||
// NS_INTERFACE_MAP_ENTRY(nsIStyledContent)
|
||||
// NS_INTERFACE_MAP_ENTRY(nsIContent)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsGenericElement)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsresult
|
||||
nsSVGElement::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
rv = nsSVGAttributes::Create(this,&mAttributes);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsINodeInfoManager> nimgr;
|
||||
rv = mNodeInfo->GetNodeInfoManager(*getter_AddRefs(nimgr));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
|
||||
// Create mapped properties:
|
||||
|
||||
// style #IMPLIED
|
||||
rv = NS_NewSVGStyleValue(getter_AddRefs(mStyle));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::style, mStyle);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIContent methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::CanContainChildren(PRBool& aResult) const
|
||||
{
|
||||
aResult = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::ChildCount(PRInt32& aResult) const
|
||||
{
|
||||
aResult = mChildren.Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::ChildAt(PRInt32 aIndex, nsIContent*& aResult) const
|
||||
{
|
||||
nsIContent *child = (nsIContent *)mChildren.ElementAt(aIndex);
|
||||
if (nsnull != child) {
|
||||
NS_ADDREF(child);
|
||||
}
|
||||
aResult = child;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aPossibleChild, "null ptr");
|
||||
aResult = mChildren.IndexOf(aPossibleChild);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
PRBool aNotify,
|
||||
PRBool aDeepSetDocument)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aKid, "null ptr");
|
||||
nsIDocument* doc = mDocument;
|
||||
if (aNotify && (nsnull != doc)) {
|
||||
doc->BeginUpdate();
|
||||
}
|
||||
PRBool rv = mChildren.InsertElementAt(aKid, aIndex);/* XXX fix up void array api to use nsresult's*/
|
||||
if (rv) {
|
||||
NS_ADDREF(aKid);
|
||||
aKid->SetParent(this);
|
||||
nsRange::OwnerChildInserted(this, aIndex);
|
||||
if (nsnull != doc) {
|
||||
aKid->SetDocument(doc, aDeepSetDocument, PR_TRUE);
|
||||
if (aNotify) {
|
||||
doc->ContentInserted(this, aKid, aIndex);
|
||||
}
|
||||
|
||||
if (nsGenericElement::HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEINSERTED)) {
|
||||
nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(aKid));
|
||||
nsMutationEvent mutation;
|
||||
mutation.eventStructType = NS_MUTATION_EVENT;
|
||||
mutation.message = NS_MUTATION_NODEINSERTED;
|
||||
mutation.mTarget = node;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> relNode(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this)));
|
||||
mutation.mRelatedNode = relNode;
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsCOMPtr<nsIDOMEvent> domEvent;
|
||||
aKid->HandleDOMEvent(nsnull, &mutation, getter_AddRefs(domEvent), NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aNotify && (nsnull != doc)) {
|
||||
doc->EndUpdate();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
PRBool aNotify,
|
||||
PRBool aDeepSetDocument)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aKid, "null ptr");
|
||||
nsIDocument* doc = mDocument;
|
||||
if (aNotify && (nsnull != mDocument)) {
|
||||
doc->BeginUpdate();
|
||||
}
|
||||
nsIContent* oldKid = (nsIContent *)mChildren.ElementAt(aIndex);
|
||||
nsRange::OwnerChildReplaced(this, aIndex, oldKid);
|
||||
PRBool rv = mChildren.ReplaceElementAt(aKid, aIndex);
|
||||
if (rv) {
|
||||
NS_ADDREF(aKid);
|
||||
aKid->SetParent(this);
|
||||
if (nsnull != doc) {
|
||||
aKid->SetDocument(doc, aDeepSetDocument, PR_TRUE);
|
||||
if (aNotify) {
|
||||
doc->ContentReplaced(this, oldKid, aKid, aIndex);
|
||||
}
|
||||
}
|
||||
oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE);
|
||||
oldKid->SetParent(nsnull);
|
||||
NS_RELEASE(oldKid);
|
||||
}
|
||||
if (aNotify && (nsnull != mDocument)) {
|
||||
doc->EndUpdate();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aKid && this != aKid, "null ptr");
|
||||
nsIDocument* doc = mDocument;
|
||||
if (aNotify && (nsnull != doc)) {
|
||||
doc->BeginUpdate();
|
||||
}
|
||||
PRBool rv = mChildren.AppendElement(aKid);
|
||||
if (rv) {
|
||||
NS_ADDREF(aKid);
|
||||
aKid->SetParent(this);
|
||||
// ranges don't need adjustment since new child is at end of list
|
||||
if (nsnull != doc) {
|
||||
aKid->SetDocument(doc, aDeepSetDocument, PR_TRUE);
|
||||
if (aNotify) {
|
||||
doc->ContentAppended(this, mChildren.Count() - 1);
|
||||
}
|
||||
|
||||
if (nsGenericElement::HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEINSERTED)) {
|
||||
nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(aKid));
|
||||
nsMutationEvent mutation;
|
||||
mutation.eventStructType = NS_MUTATION_EVENT;
|
||||
mutation.message = NS_MUTATION_NODEINSERTED;
|
||||
mutation.mTarget = node;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> relNode(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this)));
|
||||
mutation.mRelatedNode = relNode;
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsCOMPtr<nsIDOMEvent> domEvent;
|
||||
aKid->HandleDOMEvent(nsnull, &mutation, getter_AddRefs(domEvent), NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aNotify && (nsnull != doc)) {
|
||||
doc->EndUpdate();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
{
|
||||
nsIDocument* doc = mDocument;
|
||||
if (aNotify && (nsnull != doc)) {
|
||||
doc->BeginUpdate();
|
||||
}
|
||||
nsIContent* oldKid = (nsIContent *)mChildren.ElementAt(aIndex);
|
||||
if (nsnull != oldKid ) {
|
||||
|
||||
if (nsGenericElement::HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEREMOVED)) {
|
||||
nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(oldKid));
|
||||
nsMutationEvent mutation;
|
||||
mutation.eventStructType = NS_MUTATION_EVENT;
|
||||
mutation.message = NS_MUTATION_NODEREMOVED;
|
||||
mutation.mTarget = node;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> relNode(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this)));
|
||||
mutation.mRelatedNode = relNode;
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsCOMPtr<nsIDOMEvent> domEvent;
|
||||
oldKid->HandleDOMEvent(nsnull, &mutation, getter_AddRefs(domEvent),
|
||||
NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
|
||||
nsRange::OwnerChildRemoved(this, aIndex, oldKid);
|
||||
|
||||
mChildren.RemoveElementAt(aIndex);
|
||||
if (aNotify) {
|
||||
if (nsnull != doc) {
|
||||
doc->ContentRemoved(this, oldKid, aIndex);
|
||||
}
|
||||
}
|
||||
oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE);
|
||||
oldKid->SetParent(nsnull);
|
||||
NS_RELEASE(oldKid);
|
||||
}
|
||||
if (aNotify && (nsnull != doc)) {
|
||||
doc->EndUpdate();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::NormalizeAttrString(const nsAReadableString& aStr,
|
||||
nsINodeInfo*& aNodeInfo)
|
||||
{
|
||||
return mAttributes->NormalizeAttrString(aStr, aNodeInfo);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsAReadableString& aValue,
|
||||
PRBool aNotify)
|
||||
{
|
||||
nsCOMPtr<nsINodeInfoManager> nimgr;
|
||||
|
||||
mNodeInfo->GetNodeInfoManager(*getter_AddRefs(nimgr));
|
||||
NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
nimgr->GetNodeInfo(aName, nsnull, aNameSpaceID, *getter_AddRefs(ni));
|
||||
|
||||
return SetAttr(ni, aValue, aNotify);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::SetAttr(nsINodeInfo* aNodeInfo,
|
||||
const nsAReadableString& aValue,
|
||||
PRBool aNotify)
|
||||
{
|
||||
return mAttributes->SetAttr(aNodeInfo, aValue, aNotify);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsAWritableString& aResult) const
|
||||
{
|
||||
nsCOMPtr<nsIAtom> prefix;
|
||||
return GetAttr(aNameSpaceID, aName, *getter_AddRefs(prefix), aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsIAtom*& aPrefix,
|
||||
nsAWritableString& aResult) const
|
||||
{
|
||||
return mAttributes->GetAttr(aNameSpaceID, aName, aPrefix, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
PRBool aNotify)
|
||||
{
|
||||
return mAttributes->UnsetAttr(aNameSpaceID, aName, aNotify);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSVGElement::HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const
|
||||
{
|
||||
return mAttributes->HasAttr(aNameSpaceID, aName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetAttrNameAt(PRInt32 aIndex,
|
||||
PRInt32& aNameSpaceID,
|
||||
nsIAtom*& aName,
|
||||
nsIAtom*& aPrefix) const
|
||||
{
|
||||
return mAttributes->GetAttrNameAt(aIndex, aNameSpaceID, aName, aPrefix);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetAttrCount(PRInt32& aResult) const
|
||||
{
|
||||
aResult = mAttributes->Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::List(FILE* out, PRInt32 aIndent) const
|
||||
{
|
||||
// XXX
|
||||
fprintf(out, "some SVG element\n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) const
|
||||
{
|
||||
// XXX
|
||||
fprintf(out, "some SVG element\n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
||||
{
|
||||
// NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIXMLContent methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::SetContainingNameSpace(nsINameSpace* aNameSpace)
|
||||
{
|
||||
mNameSpace = aNameSpace;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetContainingNameSpace(nsINameSpace*& aNameSpace) const
|
||||
{
|
||||
aNameSpace = mNameSpace;
|
||||
NS_IF_ADDREF(aNameSpace);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIStyledContent methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetID(nsIAtom*& aId)const
|
||||
{
|
||||
nsresult rv;
|
||||
nsAutoString value;
|
||||
|
||||
rv = NS_CONST_CAST(nsSVGElement*,this)->GetAttribute(NS_LITERAL_STRING("id"), value);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
aId = NS_NewAtom(value);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::WalkInlineStyleRules(nsRuleWalker* aRuleWalker)
|
||||
{
|
||||
nsCOMPtr<nsIStyleRule> rule;
|
||||
mStyle->GetStyleRule(mDocument, getter_AddRefs(rule));
|
||||
if (aRuleWalker && rule) {
|
||||
aRuleWalker->Forward(rule);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType,
|
||||
PRInt32& aHint) const
|
||||
{
|
||||
// we don't rely on the cssframeconstructor to map attribute changes
|
||||
// to changes in our frames. an exception is css.
|
||||
// style_hint_content will trigger a re-resolve of the style context
|
||||
// if the attribute is used in a css selector:
|
||||
aHint = NS_STYLE_HINT_CONTENT;
|
||||
|
||||
// ... and we special case the style attribute
|
||||
if (aAttribute == nsSVGAtoms::style) {
|
||||
aHint = NS_STYLE_HINT_VISUAL;
|
||||
// aHint = NS_STYLE_HINT_FRAMECHANGE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNode methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetNodeName(nsAWritableString& aNodeName)
|
||||
{
|
||||
return mNodeInfo->GetQualifiedName(aNodeName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetNodeValue(nsAWritableString& aNodeValue)
|
||||
{
|
||||
aNodeValue.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::SetNodeValue(const nsAReadableString& aNodeValue)
|
||||
{
|
||||
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = (PRUint16)nsIDOMNode::ELEMENT_NODE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetParentNode(nsIDOMNode** aParentNode)
|
||||
{
|
||||
if (mParent) {
|
||||
return mParent->QueryInterface(NS_GET_IID(nsIDOMNode), (void**) aParentNode);
|
||||
}
|
||||
else if (mDocument) {
|
||||
// we're the root content
|
||||
return mDocument->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)aParentNode);
|
||||
}
|
||||
|
||||
// A standalone element (i.e. one without a parent or a document)
|
||||
*aParentNode = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetChildNodes(nsIDOMNodeList** aChildNodes)
|
||||
{
|
||||
nsDOMSlots *slots = GetDOMSlots();
|
||||
|
||||
if (nsnull == slots->mChildNodes) {
|
||||
slots->mChildNodes = new nsChildContentList(this);
|
||||
if (nsnull == slots->mChildNodes) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ADDREF(slots->mChildNodes);
|
||||
}
|
||||
|
||||
return slots->mChildNodes->QueryInterface(NS_GET_IID(nsIDOMNodeList),
|
||||
(void **)aChildNodes);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetFirstChild(nsIDOMNode** aNode)
|
||||
{
|
||||
nsIContent *child = (nsIContent *)mChildren.ElementAt(0);
|
||||
if (nsnull != child) {
|
||||
nsresult res = child->QueryInterface(NS_GET_IID(nsIDOMNode),
|
||||
(void**)aNode);
|
||||
NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); // must be a DOM Node
|
||||
return res;
|
||||
}
|
||||
*aNode = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetLastChild(nsIDOMNode** aNode)
|
||||
{
|
||||
nsIContent *child = (nsIContent *)mChildren.ElementAt(mChildren.Count()-1);
|
||||
if (nsnull != child) {
|
||||
nsresult res = child->QueryInterface(NS_GET_IID(nsIDOMNode),
|
||||
(void**)aNode);
|
||||
NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); // must be a DOM Node
|
||||
return res;
|
||||
}
|
||||
*aNode = nsnull;
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
||||
{
|
||||
return nsGenericElement::GetPreviousSibling(aPreviousSibling);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetNextSibling(nsIDOMNode** aNextSibling)
|
||||
{
|
||||
return nsGenericElement::GetNextSibling(aNextSibling);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
||||
{
|
||||
*aAttributes = mAttributes;
|
||||
NS_ADDREF(*aAttributes);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
{
|
||||
return nsGenericElement::GetOwnerDocument(aOwnerDocument);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetNamespaceURI(nsAWritableString& aNamespaceURI)
|
||||
{
|
||||
return mNodeInfo->GetNamespaceURI(aNamespaceURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetPrefix(nsAWritableString& aPrefix)
|
||||
{
|
||||
return nsGenericElement::GetPrefix(aPrefix);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::SetPrefix(const nsAReadableString& aPrefix)
|
||||
{
|
||||
return nsGenericElement::SetPrefix(aPrefix);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetLocalName(nsAWritableString& aLocalName)
|
||||
{
|
||||
return nsGenericElement::GetLocalName(aLocalName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return nsGenericElement::doInsertBefore(aNewChild, aRefChild, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return nsGenericElement::doReplaceChild(aNewChild, aOldChild, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return nsGenericElement::doRemoveChild(aOldChild, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return nsGenericElement::doInsertBefore(aNewChild, nsnull, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::HasChildNodes(PRBool* aReturn)
|
||||
{
|
||||
if (0 != mChildren.Count()) {
|
||||
*aReturn = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
*aReturn = PR_FALSE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_ASSERTION(1==0,"CloneNode must be implemented by subclass!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::Normalize()
|
||||
{
|
||||
return nsGenericElement::Normalize();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::IsSupported(const nsAReadableString& aFeature, const nsAReadableString& aVersion, PRBool* aReturn)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::HasAttributes(PRBool* aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
|
||||
PRInt32 attrCount = 0;
|
||||
|
||||
GetAttrCount(attrCount);
|
||||
|
||||
*aReturn = (attrCount > 0);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMElement methods
|
||||
|
||||
// forwarded to nsGenericElement implementations
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGElement methods
|
||||
|
||||
/* attribute DOMString id; */
|
||||
NS_IMETHODIMP nsSVGElement::GetId(nsAWritableString & aId)
|
||||
{
|
||||
return GetAttribute(NS_LITERAL_STRING("id"), aId);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSVGElement::SetId(const nsAReadableString & aId)
|
||||
{
|
||||
return SetAttribute(NS_LITERAL_STRING("id"), aId);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGSVGElement ownerSVGElement; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetOwnerSVGElement(nsIDOMSVGSVGElement * *aOwnerSVGElement)
|
||||
{
|
||||
*aOwnerSVGElement = nsnull;
|
||||
|
||||
nsCOMPtr<nsIBindingManager> bindingManager;
|
||||
if (mDocument) {
|
||||
mDocument->GetBindingManager(getter_AddRefs(bindingManager));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
|
||||
if (bindingManager) {
|
||||
// we have a binding manager -- do we have an anonymous parent?
|
||||
bindingManager->GetInsertionParent(this, getter_AddRefs(parent));
|
||||
}
|
||||
|
||||
if (!parent) {
|
||||
// if we didn't find an anonymous parent, use the explicit one,
|
||||
// whether it's null or not...
|
||||
parent = mParent;
|
||||
}
|
||||
|
||||
while (parent) {
|
||||
nsCOMPtr<nsIDOMSVGSVGElement> SVGSVGElement = do_QueryInterface(parent);
|
||||
if (SVGSVGElement) {
|
||||
*aOwnerSVGElement = SVGSVGElement;
|
||||
NS_ADDREF(*aOwnerSVGElement);
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIContent> next;
|
||||
|
||||
if (bindingManager) {
|
||||
bindingManager->GetInsertionParent(parent, getter_AddRefs(next));
|
||||
}
|
||||
|
||||
if (!next) {
|
||||
// no anonymous parent, so use explicit one
|
||||
parent->GetParent(*getter_AddRefs(next));
|
||||
}
|
||||
|
||||
parent = next;
|
||||
}
|
||||
|
||||
// we don't have a parent SVG element...
|
||||
|
||||
// are _we_ the outermost SVG element? If yes, return nsnull, but don't fail
|
||||
nsCOMPtr<nsIDOMSVGSVGElement> SVGSVGElement = do_QueryInterface((nsIDOMSVGElement*)this);
|
||||
NS_ENSURE_TRUE(SVGSVGElement, NS_ERROR_FAILURE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGElement viewportElement; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetViewportElement(nsIDOMSVGElement * *aViewportElement)
|
||||
{
|
||||
*aViewportElement = nsnull;
|
||||
nsCOMPtr<nsIDOMSVGSVGElement> SVGSVGElement;
|
||||
nsresult rv = GetOwnerSVGElement(getter_AddRefs(SVGSVGElement));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if (SVGSVGElement) {
|
||||
nsCOMPtr<nsIDOMSVGElement> SVGElement = do_QueryInterface(SVGSVGElement);
|
||||
*aViewportElement = SVGElement;
|
||||
NS_IF_ADDREF(*aViewportElement);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValueObserver methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::WillModifySVGObservable(nsISVGValue* observable)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::DidModifySVGObservable (nsISVGValue* observable)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation Helpers:
|
||||
|
||||
nsresult
|
||||
nsSVGElement::CopyNode(nsSVGElement* dest, PRBool deep)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// copy attributes:
|
||||
NS_ASSERTION(mAttributes, "null pointer");
|
||||
NS_ASSERTION(dest->mAttributes, "null pointer");
|
||||
rv = mAttributes->CopyAttributes(dest->mAttributes);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (deep) {
|
||||
// copy children:
|
||||
PRInt32 count = mChildren.Count();
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsIContent* child = NS_STATIC_CAST(nsIContent*, mChildren[i]);
|
||||
|
||||
NS_ASSERTION(child != nsnull, "null ptr");
|
||||
if (!child)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> domchild = do_QueryInterface(child);
|
||||
NS_ASSERTION(domchild != nsnull, "child is not a DOM node");
|
||||
if (! domchild)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> newdomchild;
|
||||
rv = domchild->CloneNode(PR_TRUE, getter_AddRefs(newdomchild));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIContent> newchild = do_QueryInterface(newdomchild);
|
||||
NS_ASSERTION(newchild != nsnull, "newdomchild is not an nsIContent");
|
||||
if (!newchild)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
rv = dest->AppendChildTo(newchild, PR_FALSE, PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
@ -0,0 +1,181 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#ifndef __NS_SVGELEMENT_H__
|
||||
#define __NS_SVGELEMENT_H__
|
||||
|
||||
/*
|
||||
nsSVGElement is the base class for all SVG content elements.
|
||||
It implements all the common DOM interfaces and handles attributes.
|
||||
*/
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMSVGElement.h"
|
||||
#include "nsGenericElement.h"
|
||||
#include "nsSVGAttributes.h"
|
||||
#include "nsISVGValue.h"
|
||||
#include "nsISVGValueObserver.h"
|
||||
#include "nsINameSpace.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsISVGStyleValue.h"
|
||||
|
||||
class nsSVGElement : public nsGenericElement, // :nsIHTMLContent:nsIStyledContent:nsIContent
|
||||
public nsIDOMSVGElement, // :nsIDOMElement:nsIDOMNode
|
||||
public nsISVGValueObserver,
|
||||
public nsSupportsWeakReference // :nsISupportsWeakReference
|
||||
{
|
||||
protected:
|
||||
nsSVGElement();
|
||||
virtual ~nsSVGElement();
|
||||
|
||||
virtual nsresult Init();
|
||||
|
||||
public:
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIContent interface methods
|
||||
|
||||
// NS_IMETHOD GetDocument(nsIDocument*& aResult) const;
|
||||
// NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
// PRBool aCompileEventHandlers);
|
||||
// NS_IMETHOD GetParent(nsIContent*& aResult) const;
|
||||
// NS_IMETHOD SetParent(nsIContent* aParent);
|
||||
// NS_IMETHOD GetNameSpaceID(PRInt32& aNameSpaceID) const;
|
||||
// NS_IMETHOD GetTag(nsIAtom*& aResult) const;
|
||||
// NS_IMETHOD GetNodeInfo(nsINodeInfo*& aResult) const;
|
||||
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const;
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const;
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const;
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const;
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
|
||||
NS_IMETHOD NormalizeAttrString(const nsAReadableString& aStr,
|
||||
nsINodeInfo*& aNodeInfo);
|
||||
NS_IMETHOD SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsAReadableString& aValue,
|
||||
PRBool aNotify);
|
||||
NS_IMETHOD SetAttr(nsINodeInfo* aNodeInfo,
|
||||
const nsAReadableString& aValue,
|
||||
PRBool aNotify);
|
||||
NS_IMETHOD GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsAWritableString& aResult) const;
|
||||
NS_IMETHOD GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsIAtom*& aPrefix,
|
||||
nsAWritableString& aResult) const;
|
||||
NS_IMETHOD_(PRBool) HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const;
|
||||
NS_IMETHOD UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
PRBool aNotify);
|
||||
NS_IMETHOD GetAttrNameAt(PRInt32 aIndex,
|
||||
PRInt32& aNameSpaceID,
|
||||
nsIAtom*& aName,
|
||||
nsIAtom*& aPrefix) const;
|
||||
NS_IMETHOD GetAttrCount(PRInt32& aResult) const;
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
|
||||
NS_IMETHOD DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) const;
|
||||
|
||||
// NS_IMETHOD RangeAdd(nsIDOMRange& aRange);
|
||||
// NS_IMETHOD RangeRemove(nsIDOMRange& aRange);
|
||||
// NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const;
|
||||
// NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
// nsEvent* aEvent,
|
||||
// nsIDOMEvent** aDOMEvent,
|
||||
// PRUint32 aFlags,
|
||||
// nsEventStatus* aEventStatus);
|
||||
// NS_IMETHOD GetContentID(PRUint32* aID);
|
||||
// NS_IMETHOD SetContentID(PRUint32 aID);
|
||||
// NS_IMETHOD SetFocus(nsIPresContext* aContext);
|
||||
// NS_IMETHOD RemoveFocus(nsIPresContext* aContext);
|
||||
// NS_IMETHOD GetBindingParent(nsIContent** aContent);
|
||||
// NS_IMETHOD SetBindingParent(nsIContent* aParent);
|
||||
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||
|
||||
// nsIXMLContent
|
||||
NS_IMETHOD SetContainingNameSpace(nsINameSpace* aNameSpace);
|
||||
NS_IMETHOD GetContainingNameSpace(nsINameSpace*& aNameSpace) const;
|
||||
// NS_IMETHOD MaybeTriggerAutoLink(nsIWebShell *aShell);
|
||||
|
||||
// nsIStyledContent
|
||||
NS_IMETHOD GetID(nsIAtom*& aResult) const;
|
||||
// NS_IMETHOD GetClasses(nsVoidArray& aArray) const;
|
||||
// NS_IMETHOD HasClass(nsIAtom* aClass) const;
|
||||
|
||||
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
|
||||
NS_IMETHOD WalkInlineStyleRules(nsRuleWalker* aRuleWalker);
|
||||
|
||||
NS_IMETHOD GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType,
|
||||
PRInt32& aHint) const;
|
||||
|
||||
// nsIDOMNode
|
||||
NS_DECL_NSIDOMNODE
|
||||
|
||||
// nsIDOMElement
|
||||
// NS_DECL_IDOMELEMENT
|
||||
NS_FORWARD_NSIDOMELEMENT(nsGenericElement::)
|
||||
|
||||
// nsIDOMSVGElement
|
||||
NS_DECL_NSIDOMSVGELEMENT
|
||||
|
||||
// nsISVGValueObserver
|
||||
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable);
|
||||
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable);
|
||||
|
||||
// nsISupportsWeakReference
|
||||
// implementation inherited from nsSupportsWeakReference
|
||||
|
||||
protected:
|
||||
|
||||
nsresult CopyNode(nsSVGElement* dest, PRBool deep);
|
||||
|
||||
nsVoidArray mChildren;
|
||||
nsSVGAttributes* mAttributes;
|
||||
nsCOMPtr<nsINameSpace> mNameSpace;
|
||||
nsCOMPtr<nsISVGStyleValue> mStyle;
|
||||
};
|
||||
|
||||
#endif // __NS_SVGELEMENT_H__
|
|
@ -0,0 +1,146 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIElementFactory.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsIXMLContent.h"
|
||||
|
||||
extern nsresult NS_NewSVGPolylineElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
|
||||
extern nsresult NS_NewSVGPolygonElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
|
||||
extern nsresult NS_NewSVGCircleElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
|
||||
extern nsresult NS_NewSVGEllipseElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
|
||||
extern nsresult NS_NewSVGLineElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
|
||||
extern nsresult NS_NewSVGRectElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
|
||||
extern nsresult NS_NewSVGGElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
|
||||
extern nsresult NS_NewSVGSVGElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
|
||||
extern nsresult NS_NewSVGForeignObjectElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
|
||||
extern nsresult NS_NewSVGPathElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
|
||||
|
||||
|
||||
class nsSVGElementFactory : public nsIElementFactory
|
||||
{
|
||||
protected:
|
||||
nsSVGElementFactory();
|
||||
virtual ~nsSVGElementFactory();
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIElementFactory interface
|
||||
NS_IMETHOD CreateInstanceByTag(nsINodeInfo *aNodeInfo, nsIContent** aResult);
|
||||
|
||||
public:
|
||||
friend nsresult NS_NewSVGElementFactory(nsIElementFactory** aResult);
|
||||
};
|
||||
|
||||
|
||||
|
||||
nsSVGElementFactory::nsSVGElementFactory()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsSVGElementFactory::~nsSVGElementFactory()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsSVGElementFactory, nsIElementFactory);
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewSVGElementFactory(nsIElementFactory** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsSVGElementFactory* result = new nsSVGElementFactory();
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(result);
|
||||
*aResult = result;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGElementFactory::CreateInstanceByTag(nsINodeInfo *aNodeInfo,
|
||||
nsIContent** aResult)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> name;
|
||||
aNodeInfo->GetNameAtom(*getter_AddRefs(name));
|
||||
|
||||
if (name == nsSVGAtoms::polyline)
|
||||
return NS_NewSVGPolylineElement(aResult, aNodeInfo);
|
||||
else if (name == nsSVGAtoms::polygon)
|
||||
return NS_NewSVGPolygonElement(aResult, aNodeInfo);
|
||||
else if (name == nsSVGAtoms::circle)
|
||||
return NS_NewSVGCircleElement(aResult, aNodeInfo);
|
||||
else if (name == nsSVGAtoms::ellipse)
|
||||
return NS_NewSVGEllipseElement(aResult, aNodeInfo);
|
||||
else if (name == nsSVGAtoms::line)
|
||||
return NS_NewSVGLineElement(aResult, aNodeInfo);
|
||||
else if (name == nsSVGAtoms::rect)
|
||||
return NS_NewSVGRectElement(aResult, aNodeInfo);
|
||||
else if (name == nsSVGAtoms::svg)
|
||||
return NS_NewSVGSVGElement(aResult, aNodeInfo);
|
||||
else if (name == nsSVGAtoms::g)
|
||||
return NS_NewSVGGElement(aResult, aNodeInfo);
|
||||
else if (name == nsSVGAtoms::foreignObject)
|
||||
return NS_NewSVGForeignObjectElement(aResult, aNodeInfo);
|
||||
else if (name == nsSVGAtoms::path)
|
||||
return NS_NewSVGPathElement(aResult, aNodeInfo);
|
||||
|
||||
// if we don't know what to create, just create a standard xml element:
|
||||
nsCOMPtr<nsIContent> xmlContent;
|
||||
nsresult rv;
|
||||
rv = NS_NewXMLElement(getter_AddRefs(xmlContent), aNodeInfo);
|
||||
|
||||
*aResult = xmlContent;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
@ -0,0 +1,284 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* William Cook <william.cook@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGGraphicElement.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsSVGAnimatedLength.h"
|
||||
#include "nsSVGLength.h"
|
||||
#include "nsIDOMSVGEllipseElement.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
typedef nsSVGGraphicElement nsSVGEllipseElementBase;
|
||||
|
||||
class nsSVGEllipseElement : public nsSVGEllipseElementBase,
|
||||
public nsIDOMSVGEllipseElement
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGEllipseElement(nsIContent **aResult,
|
||||
nsINodeInfo *aNodeInfo);
|
||||
nsSVGEllipseElement();
|
||||
virtual ~nsSVGEllipseElement();
|
||||
virtual nsresult Init();
|
||||
|
||||
public:
|
||||
// interfaces:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMSVGELLIPSEELEMENT
|
||||
|
||||
// xxx I wish we could use virtual inheritance
|
||||
NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGEllipseElementBase::)
|
||||
NS_FORWARD_NSIDOMELEMENT(nsSVGEllipseElementBase::)
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGEllipseElementBase::)
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mCx;
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mCy;
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mRx;
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mRy;
|
||||
|
||||
};
|
||||
|
||||
|
||||
nsresult NS_NewSVGEllipseElement(nsIContent **aResult, nsINodeInfo *aNodeInfo)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
nsSVGEllipseElement* it = new nsSVGEllipseElement();
|
||||
|
||||
if (!it) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = NS_STATIC_CAST(nsGenericElement*,it)->Init(aNodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aResult = NS_STATIC_CAST(nsIContent *, it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsSVGEllipseElement,nsSVGEllipseElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(nsSVGEllipseElement,nsSVGEllipseElementBase)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGEllipseElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGEllipseElement)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGEllipseElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGEllipseElementBase)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGEllipseElement::nsSVGEllipseElement()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
nsSVGEllipseElement::~nsSVGEllipseElement()
|
||||
{
|
||||
if (mCx) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mCx);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
if (mCy) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mCy);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
if (mRx) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mRx);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
if (mRy) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mRy);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsSVGEllipseElement::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsSVGEllipseElementBase::Init();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// Create mapped properties:
|
||||
|
||||
// DOM property: cx , #IMPLIED attrib: cx
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eXDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mCx), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::cx, mCx);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
// DOM property: cy , #IMPLIED attrib: cy
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eYDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mCy), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::cy, mCy);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
// DOM property: rx , #REQUIRED attrib: rx
|
||||
// XXX: enforce requiredness
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eXDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mRx), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::rx, mRx);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
// DOM property: ry , #REQUIRED attrib: ry
|
||||
// XXX: enforce requiredness
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eYDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mRy), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::ry, mRy);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNode methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGEllipseElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
nsSVGEllipseElement* it = new nsSVGEllipseElement();
|
||||
|
||||
if (!it) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = NS_STATIC_CAST(nsGenericElement*,it)->Init(mNodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = CopyNode(it, aDeep);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aReturn = NS_STATIC_CAST(nsSVGEllipseElementBase*, it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGEllipseElement methods
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength cx; */
|
||||
NS_IMETHODIMP nsSVGEllipseElement::GetCx(nsIDOMSVGAnimatedLength * *aCx)
|
||||
{
|
||||
*aCx = mCx;
|
||||
NS_IF_ADDREF(*aCx);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength cy; */
|
||||
NS_IMETHODIMP nsSVGEllipseElement::GetCy(nsIDOMSVGAnimatedLength * *aCy)
|
||||
{
|
||||
*aCy = mCy;
|
||||
NS_IF_ADDREF(*aCy);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength rx; */
|
||||
NS_IMETHODIMP nsSVGEllipseElement::GetRx(nsIDOMSVGAnimatedLength * *aRx)
|
||||
{
|
||||
*aRx = mRx;
|
||||
NS_IF_ADDREF(*aRx);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength ry; */
|
||||
NS_IMETHODIMP nsSVGEllipseElement::GetRy(nsIDOMSVGAnimatedLength * *aRy)
|
||||
{
|
||||
*aRy = mRy;
|
||||
NS_IF_ADDREF(*aRy);
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,285 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGGraphicElement.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsIDOMSVGForeignObjectElem.h"
|
||||
#include "nsSVGLength.h"
|
||||
#include "nsSVGAnimatedLength.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
typedef nsSVGGraphicElement nsSVGForeignObjectElementBase;
|
||||
|
||||
class nsSVGForeignObjectElement : public nsSVGForeignObjectElementBase,
|
||||
public nsIDOMSVGForeignObjectElement
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGForeignObjectElement(nsIContent **aResult,
|
||||
nsINodeInfo *aNodeInfo);
|
||||
nsSVGForeignObjectElement();
|
||||
virtual ~nsSVGForeignObjectElement();
|
||||
virtual nsresult Init();
|
||||
|
||||
public:
|
||||
// interfaces:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMSVGFOREIGNOBJECTELEMENT
|
||||
|
||||
// xxx I wish we could use virtual inheritance
|
||||
NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGForeignObjectElementBase::)
|
||||
NS_FORWARD_NSIDOMELEMENT(nsSVGForeignObjectElementBase::)
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGForeignObjectElementBase::)
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mX;
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mY;
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mWidth;
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mHeight;
|
||||
};
|
||||
|
||||
|
||||
nsresult NS_NewSVGForeignObjectElement(nsIContent **aResult, nsINodeInfo *aNodeInfo)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
nsSVGForeignObjectElement* it = new nsSVGForeignObjectElement();
|
||||
|
||||
if (!it) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = NS_STATIC_CAST(nsGenericElement*,it)->Init(aNodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aResult = NS_STATIC_CAST(nsIContent *, it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsSVGForeignObjectElement,nsSVGForeignObjectElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(nsSVGForeignObjectElement,nsSVGForeignObjectElementBase)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGForeignObjectElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGForeignObjectElement)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGForeignObjectElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGForeignObjectElementBase)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGForeignObjectElement::nsSVGForeignObjectElement()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
nsSVGForeignObjectElement::~nsSVGForeignObjectElement()
|
||||
{
|
||||
if (mX) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mX);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
if (mY) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mY);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
if (mWidth) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mWidth);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
if (mHeight) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mHeight);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsSVGForeignObjectElement::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsSVGForeignObjectElementBase::Init();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// Create mapped properties:
|
||||
|
||||
|
||||
// DOM property: x , #IMPLIED attrib: x
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eXDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mX), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::x, mX);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
// DOM property: y , #IMPLIED attrib: y
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eYDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mY), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::y, mY);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
// DOM property: width , #REQUIRED attrib: width
|
||||
// XXX: enforce requiredness
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eXDirection,
|
||||
100.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mWidth), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::width, mWidth);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
// DOM property: height , #REQUIRED attrib: height
|
||||
// XXX: enforce requiredness
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eYDirection,
|
||||
100.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mHeight), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::height, mHeight);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNode methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGForeignObjectElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
nsSVGForeignObjectElement* it = new nsSVGForeignObjectElement();
|
||||
|
||||
if (!it) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = NS_STATIC_CAST(nsGenericElement*,it)->Init(mNodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = CopyNode(it, aDeep);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aReturn = NS_STATIC_CAST(nsSVGForeignObjectElementBase*, it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGForeignObjectElement methods:
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength x; */
|
||||
NS_IMETHODIMP nsSVGForeignObjectElement::GetX(nsIDOMSVGAnimatedLength * *aX)
|
||||
{
|
||||
*aX = mX;
|
||||
NS_IF_ADDREF(*aX);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength y; */
|
||||
NS_IMETHODIMP nsSVGForeignObjectElement::GetY(nsIDOMSVGAnimatedLength * *aY)
|
||||
{
|
||||
*aY = mY;
|
||||
NS_IF_ADDREF(*aY);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength width; */
|
||||
NS_IMETHODIMP nsSVGForeignObjectElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
|
||||
{
|
||||
*aWidth = mWidth;
|
||||
NS_IF_ADDREF(*aWidth);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength height; */
|
||||
NS_IMETHODIMP nsSVGForeignObjectElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
|
||||
{
|
||||
*aHeight = mHeight;
|
||||
NS_IF_ADDREF(*aHeight);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGGraphicElement.h"
|
||||
#include "nsIDOMSVGGElement.h"
|
||||
|
||||
typedef nsSVGGraphicElement nsSVGGElementBase;
|
||||
|
||||
class nsSVGGElement : public nsSVGGElementBase,
|
||||
public nsIDOMSVGGElement
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGGElement(nsIContent **aResult,
|
||||
nsINodeInfo *aNodeInfo);
|
||||
nsSVGGElement();
|
||||
virtual ~nsSVGGElement();
|
||||
virtual nsresult Init();
|
||||
|
||||
public:
|
||||
// interfaces:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMSVGGELEMENT
|
||||
|
||||
// xxx I wish we could use virtual inheritance
|
||||
NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGGElementBase::)
|
||||
NS_FORWARD_NSIDOMELEMENT(nsSVGGElementBase::)
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGGElementBase::)
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// implementation
|
||||
|
||||
nsresult NS_NewSVGGElement(nsIContent **aResult, nsINodeInfo *aNodeInfo)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
nsSVGGElement* it = new nsSVGGElement();
|
||||
|
||||
if (!it) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = NS_STATIC_CAST(nsGenericElement*,it)->Init(aNodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aResult = NS_STATIC_CAST(nsIContent *, it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsSVGGElement,nsSVGGElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(nsSVGGElement,nsSVGGElementBase)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGGElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGGElement)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGGElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGGElementBase)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGGElement::nsSVGGElement()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
nsSVGGElement::~nsSVGGElement()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsSVGGElement::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsSVGGElementBase::Init();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNode methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGGElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
nsSVGGElement* it = new nsSVGGElement();
|
||||
|
||||
if (!it) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = NS_STATIC_CAST(nsGenericElement*,it)->Init(mNodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = CopyNode(it, aDeep);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aReturn = NS_STATIC_CAST(nsSVGGElementBase*, it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGValue.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsSVGGenericStringValue implementation
|
||||
|
||||
class nsSVGGenericStringValue : public nsSVGValue
|
||||
{
|
||||
protected:
|
||||
friend nsresult
|
||||
NS_CreateSVGGenericStringValue(const nsAReadableString& aValue, nsISVGValue** aResult);
|
||||
|
||||
nsSVGGenericStringValue(const nsAReadableString& aValue);
|
||||
virtual ~nsSVGGenericStringValue();
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsISVGValue interface:
|
||||
NS_IMETHOD SetValueString(const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetValueString(nsAWritableString& aValue);
|
||||
|
||||
protected:
|
||||
nsString mValue;
|
||||
};
|
||||
|
||||
|
||||
nsresult
|
||||
NS_CreateSVGGenericStringValue(const nsAReadableString& aValue,
|
||||
nsISVGValue** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aResult = (nsISVGValue*) new nsSVGGenericStringValue(aValue);
|
||||
if(!*aResult) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsSVGGenericStringValue::nsSVGGenericStringValue(const nsAReadableString& aValue)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
mValue = aValue;
|
||||
}
|
||||
|
||||
nsSVGGenericStringValue::~nsSVGGenericStringValue()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsSVGGenericStringValue, nsISVGValue);
|
||||
|
||||
|
||||
// nsISVGValue methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGGenericStringValue::SetValueString(const nsAReadableString& aValue)
|
||||
{
|
||||
WillModify();
|
||||
mValue = aValue;
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGGenericStringValue::GetValueString(nsAWritableString& aValue)
|
||||
{
|
||||
aValue = mValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,282 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGGraphicElement.h"
|
||||
#include "nsSVGTransformList.h"
|
||||
#include "nsSVGAnimatedTransformList.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
#include "nsIDOMSVGSVGElement.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIBindingManager.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsSVGGraphicElement, nsSVGGraphicElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(nsSVGGraphicElement, nsSVGGraphicElementBase)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGGraphicElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGLocatable)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTransformable)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGGraphicElementBase)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsresult
|
||||
nsSVGGraphicElement::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsSVGGraphicElementBase::Init();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// Create mapped properties:
|
||||
|
||||
// DOM property: transform, #IMPLIED attrib: transform
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGTransformList> transformList;
|
||||
rv = nsSVGTransformList::Create(getter_AddRefs(transformList));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedTransformList(getter_AddRefs(mTransforms),
|
||||
transformList);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::transform, mTransforms);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGLocatable methods
|
||||
|
||||
/* readonly attribute nsIDOMSVGElement nearestViewportElement; */
|
||||
NS_IMETHODIMP nsSVGGraphicElement::GetNearestViewportElement(nsIDOMSVGElement * *aNearestViewportElement)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGElement farthestViewportElement; */
|
||||
NS_IMETHODIMP nsSVGGraphicElement::GetFarthestViewportElement(nsIDOMSVGElement * *aFarthestViewportElement)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGRect getBBox (); */
|
||||
NS_IMETHODIMP nsSVGGraphicElement::GetBBox(nsIDOMSVGRect **_retval)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix getCTM (); */
|
||||
NS_IMETHODIMP nsSVGGraphicElement::GetCTM(nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGMatrix> CTM;
|
||||
|
||||
nsCOMPtr<nsIBindingManager> bindingManager;
|
||||
if (mDocument) {
|
||||
mDocument->GetBindingManager(getter_AddRefs(bindingManager));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
|
||||
if (bindingManager) {
|
||||
// we have a binding manager -- do we have an anonymous parent?
|
||||
bindingManager->GetInsertionParent(this, getter_AddRefs(parent));
|
||||
}
|
||||
|
||||
if (!parent) {
|
||||
// if we didn't find an anonymous parent, use the explicit one,
|
||||
// whether it's null or not...
|
||||
parent = mParent;
|
||||
}
|
||||
|
||||
while (parent) {
|
||||
nsCOMPtr<nsIDOMSVGSVGElement> viewportElement = do_QueryInterface(parent);
|
||||
if (viewportElement) {
|
||||
// Our nearest SVG parent is a viewport element.
|
||||
viewportElement->GetViewboxToViewportTransform(getter_AddRefs(CTM));
|
||||
break;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMSVGLocatable> locatableElement = do_QueryInterface(parent);
|
||||
if (locatableElement) {
|
||||
// Our nearest SVG parent is a locatable object that is not a
|
||||
// viewport. Its GetCTM function will give us a ctm from the
|
||||
// viewport to itself:
|
||||
locatableElement->GetCTM(getter_AddRefs(CTM));
|
||||
break;
|
||||
}
|
||||
|
||||
// Our parent was not svg content. We allow interdispersed non-SVG
|
||||
// content to coexist with XBL. Loop until we find the first SVG
|
||||
// parent.
|
||||
|
||||
nsCOMPtr<nsIContent> next;
|
||||
|
||||
if (bindingManager) {
|
||||
bindingManager->GetInsertionParent(parent, getter_AddRefs(next));
|
||||
}
|
||||
|
||||
if (!next) {
|
||||
// no anonymous parent, so use explicit one
|
||||
parent->GetParent(*getter_AddRefs(next));
|
||||
}
|
||||
|
||||
parent = next;
|
||||
}
|
||||
|
||||
if (!CTM) {
|
||||
// We either didn't find an SVG parent, or our parent failed in
|
||||
// giving us a CTM. In either case:
|
||||
NS_WARNING("Couldn't get CTM");
|
||||
nsSVGMatrix::Create(getter_AddRefs(CTM));
|
||||
}
|
||||
|
||||
// append our local transformations:
|
||||
nsCOMPtr<nsIDOMSVGTransformList> transforms;
|
||||
mTransforms->GetAnimVal(getter_AddRefs(transforms));
|
||||
NS_ENSURE_TRUE(transforms, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsIDOMSVGMatrix> matrix;
|
||||
transforms->GetConsolidation(getter_AddRefs(matrix));
|
||||
|
||||
return CTM->Multiply(matrix, _retval);
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix getScreenCTM (); */
|
||||
NS_IMETHODIMP nsSVGGraphicElement::GetScreenCTM(nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGMatrix> screenCTM;
|
||||
|
||||
nsCOMPtr<nsIBindingManager> bindingManager;
|
||||
if (mDocument) {
|
||||
mDocument->GetBindingManager(getter_AddRefs(bindingManager));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
|
||||
if (bindingManager) {
|
||||
// we have a binding manager -- do we have an anonymous parent?
|
||||
bindingManager->GetInsertionParent(this, getter_AddRefs(parent));
|
||||
}
|
||||
|
||||
if (!parent) {
|
||||
// if we didn't find an anonymous parent, use the explicit one,
|
||||
// whether it's null or not...
|
||||
parent = mParent;
|
||||
}
|
||||
|
||||
while (parent) {
|
||||
|
||||
nsCOMPtr<nsIDOMSVGLocatable> locatableElement = do_QueryInterface(parent);
|
||||
if (locatableElement) {
|
||||
nsCOMPtr<nsIDOMSVGMatrix> ctm;
|
||||
locatableElement->GetScreenCTM(getter_AddRefs(ctm));
|
||||
if (!ctm) break;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGSVGElement> viewportElement = do_QueryInterface(parent);
|
||||
if (viewportElement) {
|
||||
// It is a viewport element. we need to append the viewbox xform:
|
||||
nsCOMPtr<nsIDOMSVGMatrix> matrix;
|
||||
viewportElement->GetViewboxToViewportTransform(getter_AddRefs(matrix));
|
||||
ctm->Multiply(matrix, getter_AddRefs(screenCTM));
|
||||
}
|
||||
else
|
||||
screenCTM = ctm;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Our parent was not svg content. We allow interdispersed non-SVG
|
||||
// content to coexist with XBL. Loop until we find the first SVG
|
||||
// parent.
|
||||
|
||||
nsCOMPtr<nsIContent> next;
|
||||
|
||||
if (bindingManager) {
|
||||
bindingManager->GetInsertionParent(parent, getter_AddRefs(next));
|
||||
}
|
||||
|
||||
if (!next) {
|
||||
// no anonymous parent, so use explicit one
|
||||
parent->GetParent(*getter_AddRefs(next));
|
||||
}
|
||||
|
||||
parent = next;
|
||||
}
|
||||
|
||||
if (!screenCTM) {
|
||||
// We either didn't find an SVG parent, or our parent failed in
|
||||
// giving us a CTM. In either case:
|
||||
NS_ERROR("couldn't get ctm");
|
||||
nsSVGMatrix::Create(getter_AddRefs(screenCTM));
|
||||
}
|
||||
|
||||
// append our local transformations:
|
||||
nsCOMPtr<nsIDOMSVGTransformList> transforms;
|
||||
mTransforms->GetAnimVal(getter_AddRefs(transforms));
|
||||
NS_ENSURE_TRUE(transforms, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsIDOMSVGMatrix> matrix;
|
||||
transforms->GetConsolidation(getter_AddRefs(matrix));
|
||||
|
||||
return screenCTM->Multiply(matrix, _retval);
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix getTransformToElement (in nsIDOMSVGElement element); */
|
||||
NS_IMETHODIMP nsSVGGraphicElement::GetTransformToElement(nsIDOMSVGElement *element, nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGTransformable methods
|
||||
/* readonly attribute nsIDOMSVGAnimatedTransformList transform; */
|
||||
|
||||
NS_IMETHODIMP nsSVGGraphicElement::GetTransform(nsIDOMSVGAnimatedTransformList * *aTransform)
|
||||
{
|
||||
*aTransform = mTransforms;
|
||||
NS_IF_ADDREF(*aTransform);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#ifndef __NS_SVGGRAPHICELEMENT_H__
|
||||
#define __NS_SVGGRAPHICELEMENT_H__
|
||||
|
||||
#include "nsSVGElement.h"
|
||||
#include "nsIDOMSVGLocatable.h"
|
||||
#include "nsIDOMSVGTransformable.h"
|
||||
#include "nsIDOMSVGAnimTransformList.h"
|
||||
|
||||
typedef nsSVGElement nsSVGGraphicElementBase;
|
||||
|
||||
class nsSVGGraphicElement : public nsSVGGraphicElementBase,
|
||||
public nsIDOMSVGTransformable // : nsIDOMSVGLocatable
|
||||
{
|
||||
protected:
|
||||
virtual nsresult Init();
|
||||
|
||||
public:
|
||||
// interfaces:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMSVGLOCATABLE
|
||||
NS_DECL_NSIDOMSVGTRANSFORMABLE
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDOMSVGAnimatedTransformList> mTransforms;
|
||||
};
|
||||
|
||||
#endif // __NS_SVGGRAPHICELEMENT_H__
|
|
@ -0,0 +1,621 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGLength.h"
|
||||
#include "prdtoa.h"
|
||||
#include "nsIDOMSVGLocatable.h"
|
||||
#include "nsIDOMSVGMatrix.h"
|
||||
#include "nsSVGPoint.h"
|
||||
#include "nsIDOMSVGSVGElement.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsIDOMSVGRect.h"
|
||||
#include "nsSVGValue.h"
|
||||
#include "nsIWeakReference.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include <math.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsSVGLength class
|
||||
|
||||
class nsSVGLength : public nsIDOMSVGLength,
|
||||
public nsSVGValue
|
||||
{
|
||||
public:
|
||||
static nsresult Create(nsIDOMSVGLength** aResult,
|
||||
nsIDOMSVGElement* owner,
|
||||
float value, PRUint16 unit,
|
||||
nsSVGLengthDirection dir);
|
||||
|
||||
protected:
|
||||
nsSVGLength(float value, PRUint16 unit,
|
||||
nsSVGLengthDirection dir);
|
||||
nsresult Init(nsIDOMSVGElement* owner);
|
||||
public:
|
||||
// nsISupports interface:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMSVGLength interface:
|
||||
NS_DECL_NSIDOMSVGLENGTH
|
||||
|
||||
// nsISVGValue interface:
|
||||
NS_IMETHOD SetValueString(const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetValueString(nsAWritableString& aValue);
|
||||
|
||||
|
||||
protected:
|
||||
// implementation helpers:
|
||||
float UserUnitsPerPixel();
|
||||
float mmPerPixel();
|
||||
float ViewportDimension();
|
||||
void GetUnitString(nsAWritableString& unit);
|
||||
PRUint16 GetUnitTypeForString(const char* unitStr);
|
||||
PRBool IsValidUnitType(PRUint16 unit);
|
||||
|
||||
float mValueInSpecifiedUnits;
|
||||
PRUint16 mSpecifiedUnitType;
|
||||
nsCOMPtr<nsIWeakReference> mOwnerElementRef;
|
||||
nsSVGLengthDirection mDirection;
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsresult
|
||||
nsSVGLength::Create(nsIDOMSVGLength** aResult,
|
||||
nsIDOMSVGElement* owner,
|
||||
float value, PRUint16 unit,
|
||||
nsSVGLengthDirection dir)
|
||||
{
|
||||
nsSVGLength *pl = new nsSVGLength(value, unit, dir);
|
||||
NS_ENSURE_TRUE(pl, NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ADDREF(pl);
|
||||
if (NS_FAILED(pl->Init(owner))) {
|
||||
NS_RELEASE(pl);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
*aResult = pl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsSVGLength::nsSVGLength(float value,
|
||||
PRUint16 unit,
|
||||
nsSVGLengthDirection dir)
|
||||
: mValueInSpecifiedUnits(value),
|
||||
mSpecifiedUnitType(unit),
|
||||
mDirection(dir)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsresult nsSVGLength::Init(nsIDOMSVGElement* owner)
|
||||
{
|
||||
NS_ASSERTION(owner, "need owner");
|
||||
mOwnerElementRef = NS_GetWeakReference(owner);
|
||||
NS_ENSURE_TRUE(mOwnerElementRef, NS_ERROR_FAILURE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ADDREF(nsSVGLength)
|
||||
NS_IMPL_RELEASE(nsSVGLength)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGLength)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGValue)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGLength)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGLength)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISVGValue)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValue methods:
|
||||
NS_IMETHODIMP
|
||||
nsSVGLength::SetValueString(const nsAReadableString& aValue)
|
||||
{
|
||||
return SetValueAsString(aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGLength::GetValueString(nsAWritableString& aValue)
|
||||
{
|
||||
return GetValueAsString(aValue);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGLength methods:
|
||||
|
||||
/* readonly attribute unsigned short unitType; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGLength::GetUnitType(PRUint16 *aUnitType)
|
||||
{
|
||||
*aUnitType = mSpecifiedUnitType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute float value; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGLength::GetValue(float *aValue)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
switch (mSpecifiedUnitType) {
|
||||
case SVG_LENGTHTYPE_NUMBER:
|
||||
*aValue = mValueInSpecifiedUnits;
|
||||
break;
|
||||
case SVG_LENGTHTYPE_PX:
|
||||
*aValue = mValueInSpecifiedUnits * UserUnitsPerPixel();
|
||||
break;
|
||||
case SVG_LENGTHTYPE_MM:
|
||||
*aValue = mValueInSpecifiedUnits / mmPerPixel() * UserUnitsPerPixel();
|
||||
break;
|
||||
case SVG_LENGTHTYPE_CM:
|
||||
*aValue = mValueInSpecifiedUnits * 10.0f / mmPerPixel() * UserUnitsPerPixel();
|
||||
break;
|
||||
case SVG_LENGTHTYPE_IN:
|
||||
*aValue = mValueInSpecifiedUnits * 25.4f / mmPerPixel() * UserUnitsPerPixel();
|
||||
break;
|
||||
case SVG_LENGTHTYPE_PT:
|
||||
*aValue = mValueInSpecifiedUnits * 25.4f/72.0f / mmPerPixel() * UserUnitsPerPixel();
|
||||
break;
|
||||
case SVG_LENGTHTYPE_PC:
|
||||
*aValue = mValueInSpecifiedUnits * 25.4f*12.0f/72.0f / mmPerPixel() * UserUnitsPerPixel();
|
||||
break;
|
||||
case SVG_LENGTHTYPE_PERCENTAGE:
|
||||
*aValue = mValueInSpecifiedUnits * ViewportDimension() / 100.0f;
|
||||
break;
|
||||
case SVG_LENGTHTYPE_EMS:
|
||||
case SVG_LENGTHTYPE_EXS:
|
||||
//XXX
|
||||
NS_ASSERTION(PR_FALSE, "unit not implemented yet");
|
||||
default:
|
||||
rv = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGLength::SetValue(float aValue)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
WillModify();
|
||||
|
||||
switch (mSpecifiedUnitType) {
|
||||
case SVG_LENGTHTYPE_NUMBER:
|
||||
mValueInSpecifiedUnits = aValue;
|
||||
break;
|
||||
case SVG_LENGTHTYPE_PX:
|
||||
mValueInSpecifiedUnits = aValue / UserUnitsPerPixel();
|
||||
break;
|
||||
case SVG_LENGTHTYPE_MM:
|
||||
mValueInSpecifiedUnits = aValue / UserUnitsPerPixel() * mmPerPixel();
|
||||
break;
|
||||
case SVG_LENGTHTYPE_CM:
|
||||
mValueInSpecifiedUnits = aValue / UserUnitsPerPixel() * mmPerPixel() / 10.0f;
|
||||
break;
|
||||
case SVG_LENGTHTYPE_IN:
|
||||
mValueInSpecifiedUnits = aValue / UserUnitsPerPixel() * mmPerPixel() / 25.4f;
|
||||
break;
|
||||
case SVG_LENGTHTYPE_PT:
|
||||
mValueInSpecifiedUnits = aValue / UserUnitsPerPixel() * mmPerPixel() * 72.0f/25.4f;
|
||||
break;
|
||||
case SVG_LENGTHTYPE_PC:
|
||||
mValueInSpecifiedUnits = aValue / UserUnitsPerPixel() * mmPerPixel() * 72.0f/24.4f/12.0f;
|
||||
break;
|
||||
case SVG_LENGTHTYPE_PERCENTAGE:
|
||||
mValueInSpecifiedUnits = aValue * 100.0f / ViewportDimension();
|
||||
break;
|
||||
case SVG_LENGTHTYPE_EMS:
|
||||
case SVG_LENGTHTYPE_EXS:
|
||||
//XXX
|
||||
NS_ASSERTION(PR_FALSE, "unit not implemented yet");
|
||||
default:
|
||||
rv = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
|
||||
DidModify();
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* attribute float valueInSpecifiedUnits; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGLength::GetValueInSpecifiedUnits(float *aValueInSpecifiedUnits)
|
||||
{
|
||||
*aValueInSpecifiedUnits = mValueInSpecifiedUnits;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsSVGLength::SetValueInSpecifiedUnits(float aValueInSpecifiedUnits)
|
||||
{
|
||||
WillModify();
|
||||
mValueInSpecifiedUnits = aValueInSpecifiedUnits;
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute DOMString valueAsString; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGLength::GetValueAsString(nsAWritableString & aValueAsString)
|
||||
{
|
||||
aValueAsString.Truncate();
|
||||
|
||||
char buf[80];
|
||||
sprintf(buf, "%g", (double)mValueInSpecifiedUnits);
|
||||
aValueAsString.Append(NS_ConvertASCIItoUCS2(buf));
|
||||
|
||||
nsAutoString unitString;
|
||||
GetUnitString(unitString);
|
||||
aValueAsString.Append(unitString);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGLength::SetValueAsString(const nsAReadableString & aValueAsString)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// XXX how am I supposed to do this ???
|
||||
// char* str = aValue.ToNewCString();
|
||||
char* str;
|
||||
{
|
||||
nsAutoString temp(aValueAsString);
|
||||
str = ToNewCString(temp);
|
||||
}
|
||||
|
||||
char* number = str;
|
||||
while (*number && isspace(*number))
|
||||
++number;
|
||||
|
||||
if (*number) {
|
||||
char *rest;
|
||||
double value = PR_strtod(number, &rest);
|
||||
if (rest!=number) {
|
||||
PRUint16 unitType = GetUnitTypeForString(nsCRT::strtok(rest, "\x20\x9\xD\xA", &rest));
|
||||
if (IsValidUnitType(unitType)){
|
||||
WillModify();
|
||||
mValueInSpecifiedUnits = (float)value;
|
||||
mSpecifiedUnitType = unitType;
|
||||
DidModify();
|
||||
}
|
||||
else { // parse error
|
||||
// not a valid unit type
|
||||
// rv = ???
|
||||
}
|
||||
}
|
||||
else { // parse error
|
||||
// no number
|
||||
// rv = NS_ERROR_???;
|
||||
}
|
||||
}
|
||||
|
||||
nsMemory::Free(str);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void newValueSpecifiedUnits (in unsigned short unitType, in float valueInSpecifiedUnits); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGLength::NewValueSpecifiedUnits(PRUint16 unitType, float valueInSpecifiedUnits)
|
||||
{
|
||||
if (!IsValidUnitType(unitType)) return NS_ERROR_FAILURE;
|
||||
|
||||
WillModify();
|
||||
mValueInSpecifiedUnits = valueInSpecifiedUnits;
|
||||
mSpecifiedUnitType = unitType;
|
||||
DidModify();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void convertToSpecifiedUnits (in unsigned short unitType); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGLength::ConvertToSpecifiedUnits(PRUint16 unitType)
|
||||
{
|
||||
if (!IsValidUnitType(unitType)) return NS_ERROR_FAILURE;
|
||||
|
||||
WillModify();
|
||||
|
||||
float valueInUserUnits;
|
||||
GetValue(&valueInUserUnits);
|
||||
mSpecifiedUnitType = unitType;
|
||||
SetValue(valueInUserUnits);
|
||||
|
||||
DidModify();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* float getTransformedValue (in nsIDOMSVGMatrix matrix); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGLength::GetTransformedValue(nsIDOMSVGMatrix *matrix,
|
||||
float *_retval)
|
||||
{
|
||||
|
||||
// XXX we don't have enough information here. is the length part of a
|
||||
// coordinate pair (in which case it should transform like a point) or
|
||||
// is it used like a vector-component (in which case it doesn't
|
||||
// translate)
|
||||
|
||||
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation helpers:
|
||||
|
||||
float nsSVGLength::UserUnitsPerPixel()
|
||||
{
|
||||
float UUPerPx = 1.0f;
|
||||
|
||||
// SVG CR 20001102: New: A px unit and a user unit are defined to be
|
||||
// equivalent in SVG. Thus, a length of "5px" is the same as a
|
||||
// length of "5".
|
||||
//
|
||||
|
||||
// old way of mapping pixels:
|
||||
// if (!mOwnerElement) return UUPerPx;
|
||||
|
||||
// nsCOMPtr<nsIDOMSVGLocatable> locatable;
|
||||
// locatable = do_QueryInterface(mOwnerElement);
|
||||
// if (!locatable) return UUPerPx;
|
||||
|
||||
// nsCOMPtr<nsIDOMSVGMatrix> matrix;
|
||||
// locatable->GetCTM( getter_AddRefs(matrix) );
|
||||
// if (!matrix) return UUPerPx;
|
||||
|
||||
// nsCOMPtr<nsIDOMSVGPoint> point, XFormedPoint;
|
||||
// nsSVGPoint::Create(1.0, 1.0, getter_AddRefs(point));
|
||||
// point->MatrixTransform(matrix, getter_AddRefs(XFormedPoint));
|
||||
|
||||
// switch (mDirection) {
|
||||
// case eXDirection:
|
||||
// XFormedPoint->GetX(&UUPerPx);
|
||||
// break;
|
||||
// case eYDirection:
|
||||
// XFormedPoint->GetY(&UUPerPx);
|
||||
// break;
|
||||
// case eNoDirection:
|
||||
// {
|
||||
// float x,y;
|
||||
// XFormedPoint->GetX(&x);
|
||||
// XFormedPoint->GetY(&y);
|
||||
// UUPerPx = (x==y ? x : (x+y)/2);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (UUPerPx == 0.0f) {
|
||||
// NS_ASSERTION(PR_FALSE, "invalid uu/pixels");
|
||||
// UUPerPx = 1e-20f; // some small value
|
||||
// }
|
||||
|
||||
return UUPerPx;
|
||||
}
|
||||
|
||||
float nsSVGLength::mmPerPixel()
|
||||
{
|
||||
float mmPerPx = 0.28f; // 90dpi by default
|
||||
|
||||
if (!mOwnerElementRef) return mmPerPx;
|
||||
nsCOMPtr<nsIDOMSVGElement> ownerElement = do_QueryReferent(mOwnerElementRef);
|
||||
if (!ownerElement) return mmPerPx;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGSVGElement> SVGElement;
|
||||
ownerElement->GetOwnerSVGElement(getter_AddRefs(SVGElement));
|
||||
if (!SVGElement) { // maybe our owner is the svg element...
|
||||
SVGElement = do_QueryInterface(ownerElement);
|
||||
}
|
||||
|
||||
if (!SVGElement) return mmPerPx;
|
||||
|
||||
switch (mDirection) {
|
||||
case eXDirection:
|
||||
SVGElement->GetPixelUnitToMillimeterX(&mmPerPx);
|
||||
break;
|
||||
case eYDirection:
|
||||
SVGElement->GetPixelUnitToMillimeterY(&mmPerPx);
|
||||
break;
|
||||
case eNoDirection:
|
||||
{
|
||||
float x,y;
|
||||
SVGElement->GetPixelUnitToMillimeterX(&x);
|
||||
SVGElement->GetPixelUnitToMillimeterY(&y);
|
||||
mmPerPx = (x==y ? x : (x+y)/2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mmPerPx == 0.0f) {
|
||||
NS_ASSERTION(PR_FALSE, "invalid mm/pixels");
|
||||
mmPerPx = 1e-20f; // some small value
|
||||
}
|
||||
|
||||
return mmPerPx;
|
||||
}
|
||||
|
||||
float nsSVGLength::ViewportDimension()
|
||||
{
|
||||
float d = 1e-20f;
|
||||
|
||||
NS_ASSERTION(mOwnerElementRef, "need owner");
|
||||
if (!mOwnerElementRef) return d;
|
||||
nsCOMPtr<nsIDOMSVGElement> ownerElement = do_QueryReferent(mOwnerElementRef);
|
||||
NS_ASSERTION(ownerElement, "need owner");
|
||||
if (!ownerElement) return d;
|
||||
|
||||
// find element that establishes the current viewport:
|
||||
nsCOMPtr<nsIDOMSVGElement> vpElement;
|
||||
ownerElement->GetViewportElement(getter_AddRefs(vpElement));
|
||||
if (!vpElement) { // maybe our owner is the outermost svg element...
|
||||
vpElement = ownerElement;
|
||||
}
|
||||
|
||||
// only 'svg' elements establish explicit viewports ? XXX
|
||||
nsCOMPtr<nsIDOMSVGSVGElement> SVGElement = do_QueryInterface(vpElement);
|
||||
NS_ASSERTION(SVGElement, "need svg element to obtain vieport");
|
||||
if (!SVGElement) return d;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGRect> vp;
|
||||
SVGElement->GetViewport(getter_AddRefs(vp));
|
||||
if (!vp) return d;
|
||||
|
||||
switch (mDirection) {
|
||||
case eXDirection:
|
||||
vp->GetWidth(&d);
|
||||
break;
|
||||
case eYDirection:
|
||||
vp->GetHeight(&d);
|
||||
break;
|
||||
case eNoDirection:
|
||||
{
|
||||
float x,y;
|
||||
vp->GetWidth(&x);
|
||||
vp->GetHeight(&y);
|
||||
d = (float) sqrt(x*x+y*y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NS_ASSERTION(d!=0.0f, "zero viewport w/h?");
|
||||
|
||||
if (d == 0.0f)
|
||||
d = 1e-20f;
|
||||
return d;
|
||||
}
|
||||
|
||||
void nsSVGLength::GetUnitString(nsAWritableString& unit)
|
||||
{
|
||||
nsIAtom* UnitAtom = nsnull;
|
||||
|
||||
switch (mSpecifiedUnitType) {
|
||||
case SVG_LENGTHTYPE_NUMBER:
|
||||
UnitAtom = nsnull;
|
||||
break;
|
||||
case SVG_LENGTHTYPE_PX:
|
||||
UnitAtom = nsSVGAtoms::px;
|
||||
break;
|
||||
case SVG_LENGTHTYPE_MM:
|
||||
UnitAtom = nsSVGAtoms::mm;
|
||||
break;
|
||||
case SVG_LENGTHTYPE_CM:
|
||||
UnitAtom = nsSVGAtoms::cm;
|
||||
break;
|
||||
case SVG_LENGTHTYPE_IN:
|
||||
UnitAtom = nsSVGAtoms::in;
|
||||
break;
|
||||
case SVG_LENGTHTYPE_PT:
|
||||
UnitAtom = nsSVGAtoms::pt;
|
||||
break;
|
||||
case SVG_LENGTHTYPE_PC:
|
||||
UnitAtom = nsSVGAtoms::pc;
|
||||
break;
|
||||
case SVG_LENGTHTYPE_EMS:
|
||||
UnitAtom = nsSVGAtoms::ems;
|
||||
break;
|
||||
case SVG_LENGTHTYPE_EXS:
|
||||
UnitAtom = nsSVGAtoms::exs;
|
||||
break;
|
||||
case SVG_LENGTHTYPE_PERCENTAGE:
|
||||
UnitAtom = nsSVGAtoms::percentage;
|
||||
break;
|
||||
default:
|
||||
NS_ASSERTION(PR_FALSE, "unknown unit");
|
||||
break;
|
||||
}
|
||||
if (!UnitAtom) return;
|
||||
|
||||
UnitAtom->ToString(unit);
|
||||
}
|
||||
|
||||
PRUint16 nsSVGLength::GetUnitTypeForString(const char* unitStr)
|
||||
{
|
||||
if (!unitStr || *unitStr=='\0') return SVG_LENGTHTYPE_NUMBER;
|
||||
|
||||
nsCOMPtr<nsIAtom> unitAtom = NS_NewAtom(unitStr);
|
||||
|
||||
if (unitAtom == nsSVGAtoms::px)
|
||||
return SVG_LENGTHTYPE_PX;
|
||||
else if (unitAtom == nsSVGAtoms::mm)
|
||||
return SVG_LENGTHTYPE_MM;
|
||||
else if (unitAtom == nsSVGAtoms::cm)
|
||||
return SVG_LENGTHTYPE_CM;
|
||||
else if (unitAtom == nsSVGAtoms::in)
|
||||
return SVG_LENGTHTYPE_IN;
|
||||
else if (unitAtom == nsSVGAtoms::pt)
|
||||
return SVG_LENGTHTYPE_PT;
|
||||
else if (unitAtom == nsSVGAtoms::pc)
|
||||
return SVG_LENGTHTYPE_PC;
|
||||
else if (unitAtom == nsSVGAtoms::ems)
|
||||
return SVG_LENGTHTYPE_EMS;
|
||||
else if (unitAtom == nsSVGAtoms::exs)
|
||||
return SVG_LENGTHTYPE_EXS;
|
||||
else if (unitAtom == nsSVGAtoms::percentage)
|
||||
return SVG_LENGTHTYPE_PERCENTAGE;
|
||||
|
||||
return SVG_LENGTHTYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
PRBool nsSVGLength::IsValidUnitType(PRUint16 unit)
|
||||
{
|
||||
if (unit>0 && unit<10)
|
||||
return PR_TRUE;
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Exported creation functions:
|
||||
|
||||
nsresult
|
||||
NS_NewSVGLength(nsIDOMSVGLength** result,
|
||||
nsIDOMSVGElement* owner,
|
||||
nsSVGLengthDirection dir,
|
||||
float value,
|
||||
PRUint16 unit)
|
||||
{
|
||||
return nsSVGLength::Create(result, owner, value, unit, dir);
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#ifndef __NS_SVGLENGTH_H__
|
||||
#define __NS_SVGLENGTH_H__
|
||||
|
||||
#include "nsIDOMSVGLength.h"
|
||||
#include "nsIDOMSVGElement.h"
|
||||
|
||||
enum nsSVGLengthDirection { eXDirection, eYDirection, eNoDirection };
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewSVGLength(nsIDOMSVGLength** result,
|
||||
nsIDOMSVGElement* owner,
|
||||
nsSVGLengthDirection dir = eNoDirection,
|
||||
float value=0.0f,
|
||||
PRUint16 unit=nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER);
|
||||
|
||||
// XXX we'll need this prototype-based stuff to support unsetting:
|
||||
//nsresult NS_NewSVGLength(nsIDOMSVGLength** result,
|
||||
// nsIDOMSVGLength* prototype);
|
||||
|
||||
|
||||
#endif //__NS_SVGLENGTH_H__
|
|
@ -0,0 +1,282 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* William Cook <william.cook@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGGraphicElement.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsSVGAnimatedLength.h"
|
||||
#include "nsSVGLength.h"
|
||||
#include "nsIDOMSVGLineElement.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
typedef nsSVGGraphicElement nsSVGLineElementBase;
|
||||
|
||||
class nsSVGLineElement : public nsSVGLineElementBase,
|
||||
public nsIDOMSVGLineElement
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGLineElement(nsIContent **aResult,
|
||||
nsINodeInfo *aNodeInfo);
|
||||
nsSVGLineElement();
|
||||
virtual ~nsSVGLineElement();
|
||||
virtual nsresult Init();
|
||||
|
||||
public:
|
||||
// interfaces:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMSVGLINEELEMENT
|
||||
|
||||
// xxx I wish we could use virtual inheritance
|
||||
NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGLineElementBase::)
|
||||
NS_FORWARD_NSIDOMELEMENT(nsSVGLineElementBase::)
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGLineElementBase::)
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mX1;
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mY1;
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mX2;
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mY2;
|
||||
|
||||
};
|
||||
|
||||
|
||||
nsresult NS_NewSVGLineElement(nsIContent **aResult, nsINodeInfo *aNodeInfo)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
nsSVGLineElement* it = new nsSVGLineElement();
|
||||
|
||||
if (!it) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = NS_STATIC_CAST(nsGenericElement*,it)->Init(aNodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aResult = NS_STATIC_CAST(nsIContent *, it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsSVGLineElement,nsSVGLineElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(nsSVGLineElement,nsSVGLineElementBase)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGLineElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGLineElement)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGLineElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGLineElementBase)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGLineElement::nsSVGLineElement()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
nsSVGLineElement::~nsSVGLineElement()
|
||||
{
|
||||
if (mX1) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mX1);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
if (mY1) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mY1);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
if (mX2) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mX2);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
if (mY2) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mY2);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsSVGLineElement::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsSVGLineElementBase::Init();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// Create mapped properties:
|
||||
|
||||
// DOM property: x1 , #IMPLIED attrib: x1
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eXDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mX1), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::x1, mX1);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
// DOM property: y1 , #IMPLIED attrib: y1
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eYDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mY1), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::y1, mY1);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
// DOM property: x2 , #IMPLIED attrib: x2
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eXDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mX2), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::x2, mX2);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
// DOM property: y2 , #IMPLIED attrib: y2
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eYDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mY2), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::y2, mY2);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNode methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGLineElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
nsSVGLineElement* it = new nsSVGLineElement();
|
||||
|
||||
if (!it) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = NS_STATIC_CAST(nsGenericElement*,it)->Init(mNodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = CopyNode(it, aDeep);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aReturn = NS_STATIC_CAST(nsSVGLineElementBase*, it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGLineElement methods
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength cx; */
|
||||
NS_IMETHODIMP nsSVGLineElement::GetX1(nsIDOMSVGAnimatedLength * *aX1)
|
||||
{
|
||||
*aX1 = mX1;
|
||||
NS_IF_ADDREF(*aX1);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength cy; */
|
||||
NS_IMETHODIMP nsSVGLineElement::GetY1(nsIDOMSVGAnimatedLength * *aY1)
|
||||
{
|
||||
*aY1 = mY1;
|
||||
NS_IF_ADDREF(*aY1);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength rx; */
|
||||
NS_IMETHODIMP nsSVGLineElement::GetX2(nsIDOMSVGAnimatedLength * *aX2)
|
||||
{
|
||||
*aX2 = mX2;
|
||||
NS_IF_ADDREF(*aX2);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength ry; */
|
||||
NS_IMETHODIMP nsSVGLineElement::GetY2(nsIDOMSVGAnimatedLength * *aY2)
|
||||
{
|
||||
*aY2 = mY2;
|
||||
NS_IF_ADDREF(*aY2);
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,351 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGMatrix.h"
|
||||
#include <math.h>
|
||||
|
||||
const double radPerDegree = 2.0*3.1415926535 / 360.0;
|
||||
|
||||
nsresult
|
||||
nsSVGMatrix::Create(nsIDOMSVGMatrix** aResult)
|
||||
{
|
||||
*aResult = (nsIDOMSVGMatrix*) new nsSVGMatrix();
|
||||
if(!*aResult) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsSVGMatrix::nsSVGMatrix(float a, float b, float c,
|
||||
float d, float e, float f)
|
||||
: mA(a), mB(b), mC(c), mD(d), mE(e), mF(f)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ADDREF(nsSVGMatrix)
|
||||
NS_IMPL_RELEASE(nsSVGMatrix)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGMatrix)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGValue)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGMatrix)
|
||||
// NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
// NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGMatrix)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISVGValue)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGMatrix methods:
|
||||
|
||||
/* attribute float a; */
|
||||
NS_IMETHODIMP nsSVGMatrix::GetA(float *aA)
|
||||
{
|
||||
*aA = mA;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsSVGMatrix::SetA(float aA)
|
||||
{
|
||||
WillModify();
|
||||
mA = aA;
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute float b; */
|
||||
NS_IMETHODIMP nsSVGMatrix::GetB(float *aB)
|
||||
{
|
||||
*aB = mB;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsSVGMatrix::SetB(float aB)
|
||||
{
|
||||
WillModify();
|
||||
mB = aB;
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute float c; */
|
||||
NS_IMETHODIMP nsSVGMatrix::GetC(float *aC)
|
||||
{
|
||||
*aC = mC;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsSVGMatrix::SetC(float aC)
|
||||
{
|
||||
WillModify();
|
||||
mC = aC;
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute float d; */
|
||||
NS_IMETHODIMP nsSVGMatrix::GetD(float *aD)
|
||||
{
|
||||
*aD = mD;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsSVGMatrix::SetD(float aD)
|
||||
{
|
||||
WillModify();
|
||||
mD = aD;
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute float e; */
|
||||
NS_IMETHODIMP nsSVGMatrix::GetE(float *aE)
|
||||
{
|
||||
*aE = mE;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsSVGMatrix::SetE(float aE)
|
||||
{
|
||||
WillModify();
|
||||
mE = aE;
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute float f; */
|
||||
NS_IMETHODIMP nsSVGMatrix::GetF(float *aF)
|
||||
{
|
||||
*aF = mF;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsSVGMatrix::SetF(float aF)
|
||||
{
|
||||
WillModify();
|
||||
mF = aF;
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix multiply (in nsIDOMSVGMatrix secondMatrix); */
|
||||
NS_IMETHODIMP nsSVGMatrix::Multiply(nsIDOMSVGMatrix *secondMatrix, nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
if (!secondMatrix) return NS_ERROR_FAILURE;
|
||||
|
||||
float sa,sb,sc,sd,se,sf;
|
||||
secondMatrix->GetA(&sa);
|
||||
secondMatrix->GetB(&sb);
|
||||
secondMatrix->GetC(&sc);
|
||||
secondMatrix->GetD(&sd);
|
||||
secondMatrix->GetE(&se);
|
||||
secondMatrix->GetF(&sf);
|
||||
|
||||
Create(_retval);
|
||||
if (!*_retval) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
(*_retval)->SetA( mA*sa + mC*sb );
|
||||
(*_retval)->SetB( mB*sa + mD*sb );
|
||||
(*_retval)->SetC( mA*sc + mC*sd );
|
||||
(*_retval)->SetD( mB*sc + mD*sd );
|
||||
(*_retval)->SetE( mA*se + mC*sf + mE );
|
||||
(*_retval)->SetF( mB*se + mD*sf + mF );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix inverse (); */
|
||||
NS_IMETHODIMP nsSVGMatrix::Inverse(nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
double det = mA*mD - mC*mB;
|
||||
if (det == 0.0) {
|
||||
return NS_ERROR_FAILURE;
|
||||
// XXX should return SVG_MATRIX_NOT_INVERTABLE
|
||||
}
|
||||
|
||||
Create(_retval);
|
||||
if (!*_retval) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
(*_retval)->SetA( (float)( mD/det) );
|
||||
(*_retval)->SetB( (float)(-mB/det) );
|
||||
(*_retval)->SetC( (float)(-mC/det) );
|
||||
(*_retval)->SetD( (float)( mA/det) );
|
||||
(*_retval)->SetE( (float)((mC*mF - mE*mD)/det) );
|
||||
(*_retval)->SetF( (float)((mE*mB - mA*mF)/det) );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix translate (in float x, in float y); */
|
||||
NS_IMETHODIMP nsSVGMatrix::Translate(float x, float y, nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
Create(_retval);
|
||||
if (!*_retval) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
(*_retval)->SetA( mA );
|
||||
(*_retval)->SetB( mB );
|
||||
(*_retval)->SetC( mC );
|
||||
(*_retval)->SetD( mD );
|
||||
(*_retval)->SetE( mA*x + mC*y + mE );
|
||||
(*_retval)->SetF( mB*x + mD*y + mF );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix scale (in float scaleFactor); */
|
||||
NS_IMETHODIMP nsSVGMatrix::Scale(float scaleFactor, nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
Create(_retval);
|
||||
if (!*_retval) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
(*_retval)->SetA( mA*scaleFactor );
|
||||
(*_retval)->SetB( mB*scaleFactor );
|
||||
(*_retval)->SetC( mC*scaleFactor );
|
||||
(*_retval)->SetD( mD*scaleFactor );
|
||||
(*_retval)->SetE( mE );
|
||||
(*_retval)->SetF( mF );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix scaleNonUniform (in float scaleFactorX, in float scaleFactorY); */
|
||||
NS_IMETHODIMP nsSVGMatrix::ScaleNonUniform(float scaleFactorX, float scaleFactorY, nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
Create(_retval);
|
||||
if (!*_retval) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
(*_retval)->SetA( mA*scaleFactorX );
|
||||
(*_retval)->SetB( mB*scaleFactorX );
|
||||
(*_retval)->SetC( mC*scaleFactorY );
|
||||
(*_retval)->SetD( mD*scaleFactorY );
|
||||
(*_retval)->SetE( mE );
|
||||
(*_retval)->SetF( mF );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix rotate (in float angle); */
|
||||
NS_IMETHODIMP nsSVGMatrix::Rotate(float angle, nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
Create(_retval);
|
||||
if (!*_retval) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
double ca = cos( angle*radPerDegree );
|
||||
double sa = sin( angle*radPerDegree );
|
||||
|
||||
(*_retval)->SetA( (float) (mA*ca + mC*sa) );
|
||||
(*_retval)->SetB( (float) (mB*ca + mD*sa) );
|
||||
(*_retval)->SetC( (float) (mC*ca - mA*sa) );
|
||||
(*_retval)->SetD( (float) (mD*ca - mB*sa) );
|
||||
(*_retval)->SetE( mE );
|
||||
(*_retval)->SetF( mF );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix rotateFromVector (in float x, in float y); */
|
||||
NS_IMETHODIMP nsSVGMatrix::RotateFromVector(float x, float y, nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix flipX (); */
|
||||
NS_IMETHODIMP nsSVGMatrix::FlipX(nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix flipY (); */
|
||||
NS_IMETHODIMP nsSVGMatrix::FlipY(nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix skewX (in float angle); */
|
||||
NS_IMETHODIMP nsSVGMatrix::SkewX(float angle, nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
Create(_retval);
|
||||
if (!*_retval) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
double ta = tan( angle*radPerDegree );
|
||||
|
||||
(*_retval)->SetA( mA );
|
||||
(*_retval)->SetB( mB );
|
||||
(*_retval)->SetC( (float) ( mC + mA*ta) );
|
||||
(*_retval)->SetD( (float) ( mD + mB*ta) );
|
||||
(*_retval)->SetE( mE );
|
||||
(*_retval)->SetF( mF );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix skewY (in float angle); */
|
||||
NS_IMETHODIMP nsSVGMatrix::SkewY(float angle, nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
Create(_retval);
|
||||
if (!*_retval) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
double ta = tan( angle*radPerDegree );
|
||||
|
||||
(*_retval)->SetA( (float) (mA + mC*ta) );
|
||||
(*_retval)->SetB( (float) (mB + mD*ta) );
|
||||
(*_retval)->SetC( mC );
|
||||
(*_retval)->SetD( mD );
|
||||
(*_retval)->SetE( mE );
|
||||
(*_retval)->SetF( mF );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValue methods:
|
||||
NS_IMETHODIMP
|
||||
nsSVGMatrix::SetValueString(const nsAReadableString& aValue)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGMatrix::GetValueString(nsAWritableString& aValue)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#ifndef __NS_SVGMATRIX_H__
|
||||
#define __NS_SVGMATRIX_H__
|
||||
|
||||
#include "nsIDOMSVGMatrix.h"
|
||||
#include "nsSVGValue.h"
|
||||
|
||||
class nsSVGMatrix : public nsIDOMSVGMatrix,
|
||||
public nsSVGValue
|
||||
{
|
||||
public:
|
||||
static nsresult Create(nsIDOMSVGMatrix** aResult);
|
||||
|
||||
protected:
|
||||
nsSVGMatrix(float a=1.0f,
|
||||
float b=0.0f,
|
||||
float c=0.0f,
|
||||
float d=1.0f,
|
||||
float e=0.0f,
|
||||
float f=0.0f);
|
||||
|
||||
public:
|
||||
// nsISupports interface:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMSVGMatrix interface:
|
||||
NS_DECL_NSIDOMSVGMATRIX
|
||||
|
||||
// nsISVGValue interface:
|
||||
NS_IMETHOD SetValueString(const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetValueString(nsAWritableString& aValue);
|
||||
|
||||
|
||||
protected:
|
||||
float mA, mB, mC, mD, mE, mF;
|
||||
};
|
||||
|
||||
|
||||
#endif //__NS_SVGMATRIX_H__
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,163 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#ifndef __NS_SVGPATHDATAPARSER_H__
|
||||
#define __NS_SVGPATHDATAPARSER_H__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMSVGPathSegList.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsSVGPathDataParser: a simple recurvice descent parser that builds
|
||||
// nsIDOMPathSegs from path data strings. The grammar for path data
|
||||
// can be found in SVG CR 20001102, chapter 8.
|
||||
|
||||
class nsSVGPathDataParser
|
||||
{
|
||||
public:
|
||||
nsSVGPathDataParser(nsIDOMSVGPathSegList* segList);
|
||||
nsresult Parse(const char* str);
|
||||
|
||||
protected:
|
||||
const char* inputpos;
|
||||
|
||||
char tokenval;
|
||||
const char* tokenpos;
|
||||
enum { DIGIT, WSP, COMMA, POINT, SIGN, OTHER, END } tokentype;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGPathSegList> mSegList;
|
||||
|
||||
|
||||
// helpers
|
||||
nsresult AppendSegment(nsIDOMSVGPathSeg* seg);
|
||||
void getNextToken();
|
||||
void windBack(const char* pos);
|
||||
nsresult match(char tok);
|
||||
|
||||
|
||||
nsresult matchSvgPath();
|
||||
|
||||
nsresult matchSubPaths();
|
||||
PRBool isTokenSubPathsStarter();
|
||||
|
||||
nsresult matchSubPath();
|
||||
PRBool isTokenSubPathStarter();
|
||||
|
||||
nsresult matchSubPathElements();
|
||||
PRBool isTokenSubPathElementsStarter();
|
||||
|
||||
nsresult matchSubPathElement();
|
||||
PRBool isTokenSubPathElementStarter();
|
||||
|
||||
nsresult matchMoveto();
|
||||
nsresult matchMovetoArgSeq(PRBool absCoords);
|
||||
|
||||
nsresult matchClosePath();
|
||||
|
||||
nsresult matchLineto();
|
||||
|
||||
nsresult matchLinetoArgSeq(PRBool absCoords);
|
||||
PRBool isTokenLinetoArgSeqStarter();
|
||||
|
||||
nsresult matchHorizontalLineto();
|
||||
nsresult matchHorizontalLinetoArgSeq(PRBool absCoords);
|
||||
|
||||
nsresult matchVerticalLineto();
|
||||
nsresult matchVerticalLinetoArgSeq(PRBool absCoords);
|
||||
|
||||
nsresult matchCurveto();
|
||||
nsresult matchCurvetoArgSeq(PRBool absCoords);
|
||||
nsresult matchCurvetoArg(float* x, float* y, float* x1,
|
||||
float* y1, float* x2, float* y2);
|
||||
PRBool isTokenCurvetoArgStarter();
|
||||
|
||||
nsresult matchSmoothCurveto();
|
||||
nsresult matchSmoothCurvetoArgSeq(PRBool absCoords);
|
||||
nsresult matchSmoothCurvetoArg(float* x, float* y, float* x2, float* y2);
|
||||
PRBool isTokenSmoothCurvetoArgStarter();
|
||||
|
||||
nsresult matchQuadBezierCurveto();
|
||||
nsresult matchQuadBezierCurvetoArgSeq(PRBool absCoords);
|
||||
nsresult matchQuadBezierCurvetoArg(float* x, float* y, float* x1, float* y1);
|
||||
PRBool isTokenQuadBezierCurvetoArgStarter();
|
||||
|
||||
nsresult matchSmoothQuadBezierCurveto();
|
||||
nsresult matchSmoothQuadBezierCurvetoArgSeq(PRBool absCoords);
|
||||
|
||||
nsresult matchEllipticalArc();
|
||||
nsresult matchEllipticalArcArgSeq(PRBool absCoords);
|
||||
nsresult matchEllipticalArcArg(float* x, float* y,
|
||||
float* r1, float* r2, float* angle,
|
||||
PRBool* largeArcFlag, PRBool* sweepFlag);
|
||||
PRBool isTokenEllipticalArcArgStarter();
|
||||
|
||||
nsresult matchCoordPair(float* x, float* y);
|
||||
PRBool isTokenCoordPairStarter();
|
||||
|
||||
nsresult matchCoord(float* x);
|
||||
PRBool isTokenCoordStarter();
|
||||
|
||||
nsresult matchNonNegativeNumber(float* x);
|
||||
PRBool isTokenNonNegativeNumberStarter();
|
||||
|
||||
nsresult matchNumber(float* x);
|
||||
PRBool isTokenNumberStarter();
|
||||
|
||||
nsresult matchFlag(PRBool* f);
|
||||
|
||||
nsresult matchCommaWsp();
|
||||
PRBool isTokenCommaWspStarter();
|
||||
|
||||
nsresult matchIntegerConst();
|
||||
|
||||
nsresult matchFloatingPointConst();
|
||||
|
||||
nsresult matchFractConst();
|
||||
|
||||
nsresult matchExponent();
|
||||
PRBool isTokenExponentStarter();
|
||||
|
||||
nsresult matchDigitSeq();
|
||||
PRBool isTokenDigitSeqStarter();
|
||||
|
||||
nsresult matchWsp();
|
||||
PRBool isTokenWspStarter();
|
||||
|
||||
};
|
||||
|
||||
#endif // __NS_SVGPATHDATAPARSER_H__
|
|
@ -0,0 +1,384 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGGraphicElement.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsSVGPathSegList.h"
|
||||
#include "nsIDOMSVGPathElement.h"
|
||||
#include "nsIDOMSVGAnimatedPathData.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
typedef nsSVGGraphicElement nsSVGPathElementBase;
|
||||
|
||||
class nsSVGPathElement : public nsSVGPathElementBase,
|
||||
public nsIDOMSVGPathElement,
|
||||
public nsIDOMSVGAnimatedPathData
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGPathElement(nsIContent **aResult,
|
||||
nsINodeInfo *aNodeInfo);
|
||||
nsSVGPathElement();
|
||||
virtual ~nsSVGPathElement();
|
||||
virtual nsresult Init();
|
||||
|
||||
public:
|
||||
// interfaces:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMSVGPATHELEMENT
|
||||
NS_DECL_NSIDOMSVGANIMATEDPATHDATA
|
||||
|
||||
// xxx I wish we could use virtual inheritance
|
||||
NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGPathElementBase::)
|
||||
NS_FORWARD_NSIDOMELEMENT(nsSVGPathElementBase::)
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGPathElementBase::)
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDOMSVGPathSegList> mSegments;
|
||||
};
|
||||
|
||||
|
||||
nsresult NS_NewSVGPathElement(nsIContent **aResult, nsINodeInfo *aNodeInfo)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
nsSVGPathElement* it = new nsSVGPathElement();
|
||||
|
||||
if (!it) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = NS_STATIC_CAST(nsGenericElement*,it)->Init(aNodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aResult = NS_STATIC_CAST(nsIContent *, it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsSVGPathElement,nsSVGPathElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(nsSVGPathElement,nsSVGPathElementBase)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGPathElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGPathElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedPathData)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGPathElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGPathElementBase)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGPathElement::nsSVGPathElement()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
nsSVGPathElement::~nsSVGPathElement()
|
||||
{
|
||||
if (mSegments) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mSegments);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsSVGPathElement::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsSVGPathElementBase::Init();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// Create mapped properties:
|
||||
|
||||
// d #REQUIRED
|
||||
rv = NS_NewSVGPathSegList(getter_AddRefs(mSegments));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::d, mSegments);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNode methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
nsSVGPathElement* it = new nsSVGPathElement();
|
||||
|
||||
if (!it) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = NS_STATIC_CAST(nsGenericElement*,it)->Init(mNodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = CopyNode(it, aDeep);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aReturn = NS_STATIC_CAST(nsSVGPathElementBase*, it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGPathElement methods:
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedNumber pathLength; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::GetPathLength(nsIDOMSVGAnimatedNumber * *aPathLength)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* float getTotalLength (); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::GetTotalLength(float *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPoint getPointAtLength (in float distance); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::GetPointAtLength(float distance, nsIDOMSVGPoint **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* unsigned long getPathSegAtLength (in float distance); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::GetPathSegAtLength(float distance, PRUint32 *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegClosePath createSVGPathSegClosePath (); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegClosePath(nsIDOMSVGPathSegClosePath **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegMovetoAbs createSVGPathSegMovetoAbs (in float x, in float y); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegMovetoAbs(float x, float y, nsIDOMSVGPathSegMovetoAbs **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegMovetoRel createSVGPathSegMovetoRel (in float x, in float y); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegMovetoRel(float x, float y, nsIDOMSVGPathSegMovetoRel **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegLinetoAbs createSVGPathSegLinetoAbs (in float x, in float y); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegLinetoAbs(float x, float y, nsIDOMSVGPathSegLinetoAbs **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegLinetoRel createSVGPathSegLinetoRel (in float x, in float y); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegLinetoRel(float x, float y, nsIDOMSVGPathSegLinetoRel **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegCurvetoCubicAbs createSVGPathSegCurvetoCubicAbs (in float x, in float y, in float x1, in float y1, in float x2, in float y2); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2, nsIDOMSVGPathSegCurvetoCubicAbs **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegCurvetoCubicRel createSVGPathSegCurvetoCubicRel (in float x, in float y, in float x1, in float y1, in float x2, in float y2); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2, nsIDOMSVGPathSegCurvetoCubicRel **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegCurvetoQuadraticAbs createSVGPathSegCurvetoQuadraticAbs (in float x, in float y, in float x1, in float y1); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1, nsIDOMSVGPathSegCurvetoQuadraticAbs **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegCurvetoQuadraticRel createSVGPathSegCurvetoQuadraticRel (in float x, in float y, in float x1, in float y1); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1, nsIDOMSVGPathSegCurvetoQuadraticRel **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegArcAbs createSVGPathSegArcAbs (in float x, in float y, in float r1, in float r2, in float angle, in boolean largeArcFlag, in boolean sweepFlag); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, PRBool largeArcFlag, PRBool sweepFlag, nsIDOMSVGPathSegArcAbs **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegArcRel createSVGPathSegArcRel (in float x, in float y, in float r1, in float r2, in float angle, in boolean largeArcFlag, in boolean sweepFlag); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, PRBool largeArcFlag, PRBool sweepFlag, nsIDOMSVGPathSegArcRel **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegLinetoHorizontalAbs createSVGPathSegLinetoHorizontalAbs (in float x); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegLinetoHorizontalAbs(float x, nsIDOMSVGPathSegLinetoHorizontalAbs **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegLinetoHorizontalRel createSVGPathSegLinetoHorizontalRel (in float x); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegLinetoHorizontalRel(float x, nsIDOMSVGPathSegLinetoHorizontalRel **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegLinetoVerticalAbs createSVGPathSegLinetoVerticalAbs (in float y); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegLinetoVerticalAbs(float y, nsIDOMSVGPathSegLinetoVerticalAbs **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegLinetoVerticalRel createSVGPathSegLinetoVerticalRel (in float y); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegLinetoVerticalRel(float y, nsIDOMSVGPathSegLinetoVerticalRel **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegCurvetoCubicSmoothAbs createSVGPathSegCurvetoCubicSmoothAbs (in float x, in float y, in float x2, in float y2); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2, nsIDOMSVGPathSegCurvetoCubicSmoothAbs **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegCurvetoCubicSmoothRel createSVGPathSegCurvetoCubicSmoothRel (in float x, in float y, in float x2, in float y2); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2, nsIDOMSVGPathSegCurvetoCubicSmoothRel **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegCurvetoQuadraticSmoothAbs createSVGPathSegCurvetoQuadraticSmoothAbs (in float x, in float y); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y, nsIDOMSVGPathSegCurvetoQuadraticSmoothAbs **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSegCurvetoQuadraticSmoothRel createSVGPathSegCurvetoQuadraticSmoothRel (in float x, in float y); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathElement::CreateSVGPathSegCurvetoQuadraticSmoothRel(float x, float y, nsIDOMSVGPathSegCurvetoQuadraticSmoothRel **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGAnimatedPathData methods:
|
||||
|
||||
/* readonly attribute nsIDOMSVGPathSegList pathSegList; */
|
||||
NS_IMETHODIMP nsSVGPathElement::GetPathSegList(nsIDOMSVGPathSegList * *aPathSegList)
|
||||
{
|
||||
*aPathSegList = mSegments;
|
||||
NS_ADDREF(*aPathSegList);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGPathSegList normalizedPathSegList; */
|
||||
NS_IMETHODIMP nsSVGPathElement::GetNormalizedPathSegList(nsIDOMSVGPathSegList * *aNormalizedPathSegList)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGPathSegList animatedPathSegList; */
|
||||
NS_IMETHODIMP nsSVGPathElement::GetAnimatedPathSegList(nsIDOMSVGPathSegList * *aAnimatedPathSegList)
|
||||
{
|
||||
*aAnimatedPathSegList = mSegments;
|
||||
NS_ADDREF(*aAnimatedPathSegList);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGPathSegList animatedNormalizedPathSegList; */
|
||||
NS_IMETHODIMP nsSVGPathElement::GetAnimatedNormalizedPathSegList(nsIDOMSVGPathSegList * *aAnimatedNormalizedPathSegList)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,132 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#ifndef __NS_SVGPATHSEG_H__
|
||||
#define __NS_SVGPATHSEG_H__
|
||||
|
||||
#include "nsIDOMSVGPathSeg.h"
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegClosePath(nsIDOMSVGPathSeg** result);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegMovetoAbs(nsIDOMSVGPathSeg** result,
|
||||
float x, float y);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegMovetoRel(nsIDOMSVGPathSeg** result,
|
||||
float x, float y);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegLinetoAbs(nsIDOMSVGPathSeg** result,
|
||||
float x, float y);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegLinetoRel(nsIDOMSVGPathSeg** result,
|
||||
float x, float y);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegCurvetoCubicAbs(nsIDOMSVGPathSeg** result,
|
||||
float x, float y,
|
||||
float x1, float y1,
|
||||
float x2, float y2);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegCurvetoCubicRel(nsIDOMSVGPathSeg** result,
|
||||
float x, float y,
|
||||
float x1, float y1,
|
||||
float x2, float y2);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegCurvetoQuadraticAbs(nsIDOMSVGPathSeg** result,
|
||||
float x, float y,
|
||||
float x1, float y1);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegCurvetoQuadraticRel(nsIDOMSVGPathSeg** result,
|
||||
float x, float y,
|
||||
float x1, float y1);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegArcAbs(nsIDOMSVGPathSeg** result,
|
||||
float x, float y,
|
||||
float r1, float r2, float angle,
|
||||
PRBool largeArcFlag, PRBool sweepFlag);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegArcRel(nsIDOMSVGPathSeg** result,
|
||||
float x, float y,
|
||||
float r1, float r2, float angle,
|
||||
PRBool largeArcFlag, PRBool sweepFlag);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegLinetoHorizontalAbs(nsIDOMSVGPathSeg** result,
|
||||
float x);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegLinetoHorizontalRel(nsIDOMSVGPathSeg** result,
|
||||
float x);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegLinetoVerticalAbs(nsIDOMSVGPathSeg** result,
|
||||
float y);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegLinetoVerticalRel(nsIDOMSVGPathSeg** result,
|
||||
float y);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegCurvetoCubicSmoothAbs(nsIDOMSVGPathSeg** result,
|
||||
float x, float y,
|
||||
float x2, float y2);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegCurvetoCubicSmoothRel(nsIDOMSVGPathSeg** result,
|
||||
float x, float y,
|
||||
float x2, float y2);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegCurvetoQuadraticSmoothAbs(nsIDOMSVGPathSeg** result,
|
||||
float x, float y);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegCurvetoQuadraticSmoothRel(nsIDOMSVGPathSeg** result,
|
||||
float x, float y);
|
||||
|
||||
|
||||
#endif //__NS_SVGPATHSEG_H__
|
|
@ -0,0 +1,362 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGPathSegList.h"
|
||||
#include "nsSVGPathSeg.h"
|
||||
#include "nsSVGValue.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsSVGPathDataParser.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsSVGPathSegList
|
||||
|
||||
class nsSVGPathSegList : public nsIDOMSVGPathSegList,
|
||||
public nsSVGValue,
|
||||
public nsISVGValueObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGPathSegList(nsIDOMSVGPathSegList** result);
|
||||
|
||||
nsSVGPathSegList();
|
||||
~nsSVGPathSegList();
|
||||
// void Init();
|
||||
|
||||
public:
|
||||
// nsISupports interface:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMSVGPathSegList interface:
|
||||
NS_DECL_NSIDOMSVGPATHSEGLIST
|
||||
|
||||
// remainder of nsISVGValue interface:
|
||||
NS_IMETHOD SetValueString(const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetValueString(nsAWritableString& aValue);
|
||||
|
||||
// nsISVGValueObserver
|
||||
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable);
|
||||
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable);
|
||||
|
||||
// nsISupportsWeakReference
|
||||
// implementation inherited from nsSupportsWeakReference
|
||||
|
||||
protected:
|
||||
// implementation helpers:
|
||||
nsIDOMSVGPathSeg* ElementAt(PRInt32 index);
|
||||
void AppendElement(nsIDOMSVGPathSeg* aElement);
|
||||
void RemoveElementAt(PRInt32 index);
|
||||
void InsertElementAt(nsIDOMSVGPathSeg* aElement, PRInt32 index);
|
||||
|
||||
void ReleaseSegments();
|
||||
|
||||
nsAutoVoidArray mSegments;
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGPathSegList::nsSVGPathSegList()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsSVGPathSegList::~nsSVGPathSegList()
|
||||
{
|
||||
ReleaseSegments();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ADDREF(nsSVGPathSegList)
|
||||
NS_IMPL_RELEASE(nsSVGPathSegList)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGPathSegList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGValue)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGPathSegList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGPathSegList)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISVGValue)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValue methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathSegList::SetValueString(const nsAReadableString& aValue)
|
||||
{
|
||||
WillModify();
|
||||
|
||||
ReleaseSegments();
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// XXX how am I supposed to do this ???
|
||||
// char* str = aValue.ToNewCString();
|
||||
char* str;
|
||||
{
|
||||
nsAutoString temp(aValue);
|
||||
str = ToNewCString(temp);
|
||||
}
|
||||
|
||||
nsSVGPathDataParser parser(this);
|
||||
rv = parser.Parse(str);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "path data parse error!");
|
||||
nsMemory::Free(str);
|
||||
|
||||
DidModify();
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathSegList::GetValueString(nsAWritableString& aValue)
|
||||
{
|
||||
aValue.Truncate();
|
||||
|
||||
PRInt32 count = mSegments.Count();
|
||||
|
||||
if (count<=0) return NS_OK;
|
||||
|
||||
PRInt32 i = 0;
|
||||
|
||||
while (1) {
|
||||
nsIDOMSVGPathSeg* seg = ElementAt(i);
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(seg);
|
||||
NS_ASSERTION(val, "path segment doesn't implement required interface");
|
||||
if (!val) continue;
|
||||
nsAutoString str;
|
||||
val->GetValueString(str);
|
||||
aValue.Append(str);
|
||||
|
||||
if (++i >= count) break;
|
||||
|
||||
aValue.Append(NS_LITERAL_STRING(" "));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGPathSegList methods:
|
||||
|
||||
/* readonly attribute unsigned long numberOfItems; */
|
||||
NS_IMETHODIMP nsSVGPathSegList::GetNumberOfItems(PRUint32 *aNumberOfItems)
|
||||
{
|
||||
*aNumberOfItems = mSegments.Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void clear (); */
|
||||
NS_IMETHODIMP nsSVGPathSegList::Clear()
|
||||
{
|
||||
WillModify();
|
||||
ReleaseSegments();
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSeg initialize (in nsIDOMSVGPathSeg newItem); */
|
||||
NS_IMETHODIMP nsSVGPathSegList::Initialize(nsIDOMSVGPathSeg *newItem, nsIDOMSVGPathSeg **_retval)
|
||||
{
|
||||
Clear();
|
||||
return AppendItem(newItem, _retval);
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSeg getItem (in unsigned long index); */
|
||||
NS_IMETHODIMP nsSVGPathSegList::GetItem(PRUint32 index, nsIDOMSVGPathSeg **_retval)
|
||||
{
|
||||
if ((PRInt32)index >= mSegments.Count()) {
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
}
|
||||
|
||||
*_retval = ElementAt(index);
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSeg insertItemBefore (in nsIDOMSVGPathSeg newItem, in unsigned long index); */
|
||||
NS_IMETHODIMP nsSVGPathSegList::InsertItemBefore(nsIDOMSVGPathSeg *newItem, PRUint32 index, nsIDOMSVGPathSeg **_retval)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSeg replaceItem (in nsIDOMSVGPathSeg newItem, in unsigned long index); */
|
||||
NS_IMETHODIMP nsSVGPathSegList::ReplaceItem(nsIDOMSVGPathSeg *newItem, PRUint32 index, nsIDOMSVGPathSeg **_retval)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSeg removeItem (in unsigned long index); */
|
||||
NS_IMETHODIMP nsSVGPathSegList::RemoveItem(PRUint32 index, nsIDOMSVGPathSeg **_retval)
|
||||
{
|
||||
if ((PRInt32)index >= mSegments.Count()) {
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
}
|
||||
|
||||
*_retval = ElementAt(index);
|
||||
NS_ADDREF(*_retval);
|
||||
WillModify();
|
||||
RemoveElementAt(index);
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPathSeg appendItem (in nsIDOMSVGPathSeg newItem); */
|
||||
NS_IMETHODIMP nsSVGPathSegList::AppendItem(nsIDOMSVGPathSeg *newItem, nsIDOMSVGPathSeg **_retval)
|
||||
{
|
||||
// XXX The SVG specs state that 'if newItem is already in a list, it
|
||||
// is removed from its previous list before it is inserted into this
|
||||
// list'. We don't do that. Should we?
|
||||
|
||||
*_retval = newItem;
|
||||
NS_ADDREF(*_retval);
|
||||
AppendElement(newItem);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValueObserver methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathSegList::WillModifySVGObservable(nsISVGValue* observable)
|
||||
{
|
||||
WillModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGPathSegList::DidModifySVGObservable (nsISVGValue* observable)
|
||||
{
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation helpers
|
||||
|
||||
void
|
||||
nsSVGPathSegList::ReleaseSegments()
|
||||
{
|
||||
WillModify();
|
||||
PRInt32 count = mSegments.Count();
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsIDOMSVGPathSeg* seg = ElementAt(i);
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(seg);
|
||||
if (val)
|
||||
val->RemoveObserver(this);
|
||||
NS_RELEASE(seg);
|
||||
}
|
||||
mSegments.Clear();
|
||||
DidModify();
|
||||
}
|
||||
|
||||
nsIDOMSVGPathSeg*
|
||||
nsSVGPathSegList::ElementAt(PRInt32 index)
|
||||
{
|
||||
return (nsIDOMSVGPathSeg*)mSegments.ElementAt(index);
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGPathSegList::AppendElement(nsIDOMSVGPathSeg* aElement)
|
||||
{
|
||||
WillModify();
|
||||
NS_ADDREF(aElement);
|
||||
mSegments.AppendElement((void*)aElement);
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(aElement);
|
||||
if (val)
|
||||
val->AddObserver(this);
|
||||
DidModify();
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGPathSegList::RemoveElementAt(PRInt32 index)
|
||||
{
|
||||
WillModify();
|
||||
nsIDOMSVGPathSeg* seg = ElementAt(index);
|
||||
NS_ASSERTION(seg, "null pathsegment");
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(seg);
|
||||
if (val)
|
||||
val->RemoveObserver(this);
|
||||
mSegments.RemoveElementAt(index);
|
||||
NS_RELEASE(seg);
|
||||
DidModify();
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGPathSegList::InsertElementAt(nsIDOMSVGPathSeg* aElement, PRInt32 index)
|
||||
{
|
||||
WillModify();
|
||||
NS_ADDREF(aElement);
|
||||
mSegments.InsertElementAt((void*)aElement, index);
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(aElement);
|
||||
if (val)
|
||||
val->AddObserver(this);
|
||||
DidModify();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Exported creation functions:
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegList(nsIDOMSVGPathSegList** result)
|
||||
{
|
||||
*result = nsnull;
|
||||
|
||||
nsSVGPathSegList* pathSegList = new nsSVGPathSegList();
|
||||
if (!pathSegList) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(pathSegList);
|
||||
|
||||
// pathSegList->Init();
|
||||
|
||||
*result = (nsIDOMSVGPathSegList*) pathSegList;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#ifndef __NS_SVGPATHSEGLIST_H__
|
||||
#define __NS_SVGPATHSEGLIST_H__
|
||||
|
||||
#include "nsIDOMSVGPathSegList.h"
|
||||
|
||||
nsresult
|
||||
NS_NewSVGPathSegList(nsIDOMSVGPathSegList** result);
|
||||
|
||||
#endif //__NS_SVGPATHSEGLIST_H__
|
|
@ -0,0 +1,134 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGPoint.h"
|
||||
#include "nsIDOMSVGMatrix.h"
|
||||
|
||||
nsresult
|
||||
nsSVGPoint::Create(float x, float y, nsIDOMSVGPoint** aResult)
|
||||
{
|
||||
*aResult = (nsIDOMSVGPoint*) new nsSVGPoint(x, y);
|
||||
if(!*aResult) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsSVGPoint::nsSVGPoint(float x, float y)
|
||||
: mX(x), mY(y)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ADDREF(nsSVGPoint)
|
||||
NS_IMPL_RELEASE(nsSVGPoint)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGPoint)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGValue)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGPoint)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGPoint)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISVGValue)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGPoint methods:
|
||||
|
||||
/* attribute float x; */
|
||||
NS_IMETHODIMP nsSVGPoint::GetX(float *aX)
|
||||
{
|
||||
*aX = mX;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsSVGPoint::SetX(float aX)
|
||||
{
|
||||
WillModify();
|
||||
mX = aX;
|
||||
DidModify();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute float y; */
|
||||
NS_IMETHODIMP nsSVGPoint::GetY(float *aY)
|
||||
{
|
||||
*aY = mY;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsSVGPoint::SetY(float aY)
|
||||
{
|
||||
WillModify();
|
||||
mY = aY;
|
||||
DidModify();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPoint matrixTransform (in nsIDOMSVGMatrix matrix); */
|
||||
NS_IMETHODIMP nsSVGPoint::MatrixTransform(nsIDOMSVGMatrix *matrix, nsIDOMSVGPoint **_retval)
|
||||
{
|
||||
if (!matrix) return NS_ERROR_FAILURE;
|
||||
|
||||
float a, b, c, d, e, f;
|
||||
matrix->GetA(&a);
|
||||
matrix->GetB(&b);
|
||||
matrix->GetC(&c);
|
||||
matrix->GetD(&d);
|
||||
matrix->GetE(&e);
|
||||
matrix->GetF(&f);
|
||||
|
||||
return Create( a*mX + c*mY + e, b*mX + d*mY + f, _retval);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValue methods:
|
||||
NS_IMETHODIMP
|
||||
nsSVGPoint::SetValueString(const nsAReadableString& aValue)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGPoint::GetValueString(nsAWritableString& aValue)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#ifndef __NS_SVGPOINT_H__
|
||||
#define __NS_SVGPOINT_H__
|
||||
|
||||
#include "nsIDOMSVGPoint.h"
|
||||
#include "nsSVGValue.h"
|
||||
|
||||
class nsSVGPoint : public nsIDOMSVGPoint,
|
||||
public nsSVGValue
|
||||
{
|
||||
public:
|
||||
static nsresult Create(float x, float y, nsIDOMSVGPoint** aResult);
|
||||
|
||||
protected:
|
||||
nsSVGPoint(float x, float y);
|
||||
|
||||
public:
|
||||
// nsISupports interface:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMSVGPoint interface:
|
||||
NS_DECL_NSIDOMSVGPOINT
|
||||
|
||||
// nsISVGValue interface:
|
||||
NS_IMETHOD SetValueString(const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetValueString(nsAWritableString& aValue);
|
||||
|
||||
|
||||
protected:
|
||||
float mX;
|
||||
float mY;
|
||||
};
|
||||
|
||||
|
||||
#endif //__NS_SVGPOINT_H__
|
|
@ -0,0 +1,336 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGPointList.h"
|
||||
#include "nsSVGPoint.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "prdtoa.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
nsresult
|
||||
nsSVGPointList::Create(const nsAReadableString& aValue,
|
||||
nsISVGValue** aResult)
|
||||
{
|
||||
*aResult = (nsISVGValue*) new nsSVGPointList();
|
||||
if(!*aResult) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
(*aResult)->SetValueString(aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGPointList::Create(nsIDOMSVGPointList** aResult)
|
||||
{
|
||||
*aResult = (nsIDOMSVGPointList*) new nsSVGPointList();
|
||||
if(!*aResult) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsSVGPointList::nsSVGPointList()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsSVGPointList::~nsSVGPointList()
|
||||
{
|
||||
ReleasePoints();
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGPointList::ReleasePoints()
|
||||
{
|
||||
WillModify();
|
||||
PRInt32 count = mPoints.Count();
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsIDOMSVGPoint* point = ElementAt(i);
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(point);
|
||||
if (val)
|
||||
val->RemoveObserver(this);
|
||||
NS_RELEASE(point);
|
||||
}
|
||||
mPoints.Clear();
|
||||
DidModify();
|
||||
}
|
||||
|
||||
nsIDOMSVGPoint*
|
||||
nsSVGPointList::ElementAt(PRInt32 index)
|
||||
{
|
||||
return (nsIDOMSVGPoint*)mPoints.ElementAt(index);
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGPointList::AppendElement(nsIDOMSVGPoint* aElement)
|
||||
{
|
||||
WillModify();
|
||||
NS_ADDREF(aElement);
|
||||
mPoints.AppendElement((void*)aElement);
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(aElement);
|
||||
if (val)
|
||||
val->AddObserver(this);
|
||||
DidModify();
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGPointList::RemoveElementAt(PRInt32 index)
|
||||
{
|
||||
WillModify();
|
||||
nsIDOMSVGPoint* point = ElementAt(index);
|
||||
NS_ASSERTION(point, "null point");
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(point);
|
||||
if (val)
|
||||
val->RemoveObserver(this);
|
||||
mPoints.RemoveElementAt(index);
|
||||
NS_RELEASE(point);
|
||||
DidModify();
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGPointList::InsertElementAt(nsIDOMSVGPoint* aElement, PRInt32 index)
|
||||
{
|
||||
WillModify();
|
||||
NS_ADDREF(aElement);
|
||||
mPoints.InsertElementAt((void*)aElement, index);
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(aElement);
|
||||
if (val)
|
||||
val->AddObserver(this);
|
||||
DidModify();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ADDREF(nsSVGPointList)
|
||||
NS_IMPL_RELEASE(nsSVGPointList)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGPointList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGValue)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGPointList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGPointList)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISVGValue)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValue methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGPointList::SetValueString(const nsAReadableString& aValue)
|
||||
{
|
||||
WillModify();
|
||||
|
||||
ReleasePoints();
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// XXX how am I supposed to do this ???
|
||||
// char* str = aValue.ToNewCString();
|
||||
char* str;
|
||||
{
|
||||
nsAutoString temp(aValue);
|
||||
str = ToNewCString(temp);
|
||||
}
|
||||
|
||||
char* rest = str;
|
||||
char* token1;
|
||||
char* token2;
|
||||
const char* delimiters = ",\x20\x9\xD\xA";
|
||||
|
||||
while ( (token1 = nsCRT::strtok(rest, delimiters, &rest)) &&
|
||||
(token2 = nsCRT::strtok(rest, delimiters, &rest)) ) {
|
||||
|
||||
char *end;
|
||||
|
||||
double x = PR_strtod(token1, &end);
|
||||
if (*end != '\0') break; // parse error
|
||||
|
||||
double y = PR_strtod(token2, &end);
|
||||
if (*end != '\0') break; // parse error
|
||||
|
||||
nsCOMPtr<nsIDOMSVGPoint> point;
|
||||
nsSVGPoint::Create((float)x, (float)y, getter_AddRefs(point));
|
||||
if (!point) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
AppendElement(point);
|
||||
}
|
||||
|
||||
if (token1) {
|
||||
// there was a parse error. should we return an error?
|
||||
// rv = NS_ERROR_???;
|
||||
}
|
||||
|
||||
nsMemory::Free(str);
|
||||
|
||||
DidModify();
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGPointList::GetValueString(nsAWritableString& aValue)
|
||||
{
|
||||
aValue.Truncate();
|
||||
|
||||
PRInt32 count = mPoints.Count();
|
||||
|
||||
if (count<=0) return NS_OK;
|
||||
|
||||
PRInt32 i = 0;
|
||||
char buf[80];
|
||||
|
||||
while (1) {
|
||||
nsIDOMSVGPoint* point = ElementAt(i);
|
||||
float x, y;
|
||||
point->GetX(&x);
|
||||
point->GetY(&y);
|
||||
|
||||
sprintf(buf, "%g,%g", (double)x, (double)y);
|
||||
aValue.Append(NS_ConvertASCIItoUCS2(buf));
|
||||
|
||||
if (++i >= count) break;
|
||||
|
||||
aValue.Append(NS_LITERAL_STRING(" "));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGPointList methods:
|
||||
|
||||
/* readonly attribute unsigned long numberOfItems; */
|
||||
NS_IMETHODIMP nsSVGPointList::GetNumberOfItems(PRUint32 *aNumberOfItems)
|
||||
{
|
||||
*aNumberOfItems = mPoints.Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void clear (); */
|
||||
NS_IMETHODIMP nsSVGPointList::Clear()
|
||||
{
|
||||
WillModify();
|
||||
ReleasePoints();
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPoint initialize (in nsIDOMSVGPoint newItem); */
|
||||
NS_IMETHODIMP nsSVGPointList::Initialize(nsIDOMSVGPoint *newItem, nsIDOMSVGPoint **_retval)
|
||||
{
|
||||
Clear();
|
||||
return AppendItem(newItem, _retval);
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPoint getItem (in unsigned long index); */
|
||||
NS_IMETHODIMP nsSVGPointList::GetItem(PRUint32 index, nsIDOMSVGPoint **_retval)
|
||||
{
|
||||
if ((PRInt32)index >= mPoints.Count()) {
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
}
|
||||
|
||||
*_retval = ElementAt(index);
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPoint insertItemBefore (in nsIDOMSVGPoint newItem, in unsigned long index); */
|
||||
NS_IMETHODIMP nsSVGPointList::InsertItemBefore(nsIDOMSVGPoint *newItem, PRUint32 index, nsIDOMSVGPoint **_retval)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPoint replaceItem (in nsIDOMSVGPoint newItem, in unsigned long index); */
|
||||
NS_IMETHODIMP nsSVGPointList::ReplaceItem(nsIDOMSVGPoint *newItem, PRUint32 index, nsIDOMSVGPoint **_retval)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPoint removeItem (in unsigned long index); */
|
||||
NS_IMETHODIMP nsSVGPointList::RemoveItem(PRUint32 index, nsIDOMSVGPoint **_retval)
|
||||
{
|
||||
if ((PRInt32)index >= mPoints.Count()) {
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
}
|
||||
|
||||
*_retval = ElementAt(index);
|
||||
NS_ADDREF(*_retval);
|
||||
WillModify();
|
||||
RemoveElementAt(index);
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGPoint appendItem (in nsIDOMSVGPoint newItem); */
|
||||
NS_IMETHODIMP nsSVGPointList::AppendItem(nsIDOMSVGPoint *newItem, nsIDOMSVGPoint **_retval)
|
||||
{
|
||||
// XXX The SVG specs state that 'if newItem is already in a list, it
|
||||
// is removed from its previous list before it is inserted into this
|
||||
// list'. We don't do that. Should we?
|
||||
|
||||
*_retval = newItem;
|
||||
NS_ADDREF(*_retval);
|
||||
AppendElement(newItem);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValueObserver methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGPointList::WillModifySVGObservable(nsISVGValue* observable)
|
||||
{
|
||||
WillModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGPointList::DidModifySVGObservable (nsISVGValue* observable)
|
||||
{
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#ifndef __NS_SVGPOINTLIST_H__
|
||||
#define __NS_SVGPOINTLIST_H__
|
||||
|
||||
#include "nsSVGValue.h"
|
||||
#include "nsISVGValueObserver.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIDOMSVGPointList.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
|
||||
class nsSVGPointList : public nsSVGValue,
|
||||
public nsIDOMSVGPointList,
|
||||
public nsISVGValueObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
static nsresult Create(const nsAReadableString& aValue, nsISVGValue** aResult);
|
||||
static nsresult Create(nsIDOMSVGPointList** aResult);
|
||||
|
||||
protected:
|
||||
nsSVGPointList();
|
||||
virtual ~nsSVGPointList();
|
||||
|
||||
public:
|
||||
// nsISupports interface:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMSVGPointList interface:
|
||||
NS_DECL_NSIDOMSVGPOINTLIST
|
||||
|
||||
// remainder of nsISVGValue interface:
|
||||
NS_IMETHOD SetValueString(const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetValueString(nsAWritableString& aValue);
|
||||
|
||||
// nsISVGValueObserver
|
||||
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable);
|
||||
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable);
|
||||
|
||||
// nsISupportsWeakReference
|
||||
// implementation inherited from nsSupportsWeakReference
|
||||
|
||||
|
||||
// other methods:
|
||||
nsIDOMSVGPoint* ElementAt(PRInt32 index);
|
||||
void AppendElement(nsIDOMSVGPoint* aElement);
|
||||
void RemoveElementAt(PRInt32 index);
|
||||
void InsertElementAt(nsIDOMSVGPoint* aElement, PRInt32 index);
|
||||
|
||||
protected:
|
||||
void ReleasePoints();
|
||||
|
||||
nsAutoVoidArray mPoints;
|
||||
};
|
||||
|
||||
|
||||
#endif //__NS_SVGPOINTLIST_H__
|
|
@ -0,0 +1,207 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGGraphicElement.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsSVGPointList.h"
|
||||
#include "nsIDOMSVGPolygonElement.h"
|
||||
#include "nsIDOMSVGAnimatedPoints.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
typedef nsSVGGraphicElement nsSVGPolygonElementBase;
|
||||
|
||||
class nsSVGPolygonElement : public nsSVGPolygonElementBase,
|
||||
public nsIDOMSVGPolygonElement,
|
||||
public nsIDOMSVGAnimatedPoints
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGPolygonElement(nsIContent **aResult,
|
||||
nsINodeInfo *aNodeInfo);
|
||||
nsSVGPolygonElement();
|
||||
virtual ~nsSVGPolygonElement();
|
||||
virtual nsresult Init();
|
||||
|
||||
public:
|
||||
// interfaces:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMSVGPOLYGONELEMENT
|
||||
NS_DECL_NSIDOMSVGANIMATEDPOINTS
|
||||
|
||||
// xxx I wish we could use virtual inheritance
|
||||
NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGPolygonElementBase::)
|
||||
NS_FORWARD_NSIDOMELEMENT(nsSVGPolygonElementBase::)
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGPolygonElementBase::)
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDOMSVGPointList> mPoints;
|
||||
};
|
||||
|
||||
|
||||
nsresult NS_NewSVGPolygonElement(nsIContent **aResult, nsINodeInfo *aNodeInfo)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
nsSVGPolygonElement* it = new nsSVGPolygonElement();
|
||||
|
||||
if (!it) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = NS_STATIC_CAST(nsGenericElement*,it)->Init(aNodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aResult = NS_STATIC_CAST(nsIContent *, it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsSVGPolygonElement,nsSVGPolygonElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(nsSVGPolygonElement,nsSVGPolygonElementBase)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGPolygonElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGPolygonElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedPoints)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGPolygonElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGPolygonElementBase)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGPolygonElement::nsSVGPolygonElement()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
nsSVGPolygonElement::~nsSVGPolygonElement()
|
||||
{
|
||||
if (mPoints) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mPoints);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsSVGPolygonElement::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsSVGPolygonElementBase::Init();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// Create mapped properties:
|
||||
|
||||
// points #IMPLIED
|
||||
rv = nsSVGPointList::Create(getter_AddRefs(mPoints));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::points, mPoints);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNode methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGPolygonElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
nsSVGPolygonElement* it = new nsSVGPolygonElement();
|
||||
|
||||
if (!it) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = NS_STATIC_CAST(nsGenericElement*,it)->Init(mNodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = CopyNode(it, aDeep);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aReturn = NS_STATIC_CAST(nsSVGPolygonElementBase*, it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSGAnimatedPoints methods:
|
||||
|
||||
/* readonly attribute nsIDOMSVGPointList points; */
|
||||
NS_IMETHODIMP nsSVGPolygonElement::GetPoints(nsIDOMSVGPointList * *aPoints)
|
||||
{
|
||||
*aPoints = mPoints;
|
||||
NS_ADDREF(*aPoints);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGPointList animatedPoints; */
|
||||
NS_IMETHODIMP nsSVGPolygonElement::GetAnimatedPoints(nsIDOMSVGPointList * *aAnimatedPoints)
|
||||
{
|
||||
*aAnimatedPoints = mPoints;
|
||||
NS_ADDREF(*aAnimatedPoints);
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,206 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGGraphicElement.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsSVGPointList.h"
|
||||
#include "nsIDOMSVGPolylineElement.h"
|
||||
#include "nsIDOMSVGAnimatedPoints.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
typedef nsSVGGraphicElement nsSVGPolylineElementBase;
|
||||
|
||||
class nsSVGPolylineElement : public nsSVGPolylineElementBase,
|
||||
public nsIDOMSVGPolylineElement,
|
||||
public nsIDOMSVGAnimatedPoints
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGPolylineElement(nsIContent **aResult,
|
||||
nsINodeInfo *aNodeInfo);
|
||||
nsSVGPolylineElement();
|
||||
virtual ~nsSVGPolylineElement();
|
||||
virtual nsresult Init();
|
||||
|
||||
public:
|
||||
// interfaces:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMSVGPOLYLINEELEMENT
|
||||
NS_DECL_NSIDOMSVGANIMATEDPOINTS
|
||||
|
||||
// xxx I wish we could use virtual inheritance
|
||||
NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGPolylineElementBase::)
|
||||
NS_FORWARD_NSIDOMELEMENT(nsSVGPolylineElementBase::)
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGPolylineElementBase::)
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDOMSVGPointList> mPoints;
|
||||
};
|
||||
|
||||
|
||||
nsresult NS_NewSVGPolylineElement(nsIContent **aResult, nsINodeInfo *aNodeInfo)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
nsSVGPolylineElement* it = new nsSVGPolylineElement();
|
||||
|
||||
if (!it) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = NS_STATIC_CAST(nsGenericElement*,it)->Init(aNodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aResult = NS_STATIC_CAST(nsIContent *, it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsSVGPolylineElement,nsSVGPolylineElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(nsSVGPolylineElement,nsSVGPolylineElementBase)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGPolylineElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGPolylineElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedPoints)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGPolylineElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGPolylineElementBase)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGPolylineElement::nsSVGPolylineElement()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
nsSVGPolylineElement::~nsSVGPolylineElement()
|
||||
{
|
||||
if (mPoints) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mPoints);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsSVGPolylineElement::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsSVGPolylineElementBase::Init();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// Create mapped properties:
|
||||
|
||||
// points #IMPLIED
|
||||
rv = nsSVGPointList::Create(getter_AddRefs(mPoints));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::points, mPoints);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNode methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGPolylineElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
nsSVGPolylineElement* it = new nsSVGPolylineElement();
|
||||
|
||||
if (!it) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = NS_STATIC_CAST(nsGenericElement*,it)->Init(mNodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = CopyNode(it, aDeep);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aReturn = NS_STATIC_CAST(nsSVGPolylineElementBase*, it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSGAnimatedPoints methods:
|
||||
|
||||
/* readonly attribute nsIDOMSVGPointList points; */
|
||||
NS_IMETHODIMP nsSVGPolylineElement::GetPoints(nsIDOMSVGPointList * *aPoints)
|
||||
{
|
||||
*aPoints = mPoints;
|
||||
NS_ADDREF(*aPoints);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGPointList animatedPoints; */
|
||||
NS_IMETHODIMP nsSVGPolylineElement::GetAnimatedPoints(nsIDOMSVGPointList * *aAnimatedPoints)
|
||||
{
|
||||
*aAnimatedPoints = mPoints;
|
||||
NS_ADDREF(*aAnimatedPoints);
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,371 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGRect.h"
|
||||
#include "prdtoa.h"
|
||||
#include "nsSVGValue.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsSVGRect class
|
||||
|
||||
class nsSVGRect : public nsIDOMSVGRect,
|
||||
public nsSVGValue
|
||||
{
|
||||
public:
|
||||
static nsresult Create(nsIDOMSVGRect** result,
|
||||
float x=0.0f, float y=0.0f,
|
||||
float w=0.0f, float h=0.0f);
|
||||
protected:
|
||||
nsSVGRect(float x, float y, float w, float h);
|
||||
|
||||
public:
|
||||
// nsISupports interface:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMSVGRect interface:
|
||||
NS_DECL_NSIDOMSVGRECT
|
||||
|
||||
// nsISVGValue interface:
|
||||
NS_IMETHOD SetValueString(const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetValueString(nsAWritableString& aValue);
|
||||
|
||||
|
||||
protected:
|
||||
float mX, mY, mWidth, mHeight;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// implementation:
|
||||
|
||||
nsresult
|
||||
nsSVGRect::Create(nsIDOMSVGRect** result,
|
||||
float x, float y, float w, float h)
|
||||
{
|
||||
*result = (nsIDOMSVGRect*) new nsSVGRect(x,y,w,h);
|
||||
if(!*result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsSVGRect::nsSVGRect(float x, float y, float w, float h)
|
||||
: mX(x), mY(y), mWidth(w), mHeight(h)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ADDREF(nsSVGRect)
|
||||
NS_IMPL_RELEASE(nsSVGRect)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGRect)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGValue)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGRect)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGRect)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISVGValue)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValue methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGRect::SetValueString(const nsAReadableString& aValue)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGRect::GetValueString(nsAWritableString& aValue)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGRect methods:
|
||||
|
||||
/* attribute float x; */
|
||||
NS_IMETHODIMP nsSVGRect::GetX(float *aX)
|
||||
{
|
||||
*aX = mX;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsSVGRect::SetX(float aX)
|
||||
{
|
||||
WillModify();
|
||||
mX = aX;
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute float y; */
|
||||
NS_IMETHODIMP nsSVGRect::GetY(float *aY)
|
||||
{
|
||||
*aY = mY;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsSVGRect::SetY(float aY)
|
||||
{
|
||||
WillModify();
|
||||
mY = aY;
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute float width; */
|
||||
NS_IMETHODIMP nsSVGRect::GetWidth(float *aWidth)
|
||||
{
|
||||
*aWidth = mWidth;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsSVGRect::SetWidth(float aWidth)
|
||||
{
|
||||
WillModify();
|
||||
mWidth = aWidth;
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute float height; */
|
||||
NS_IMETHODIMP nsSVGRect::GetHeight(float *aHeight)
|
||||
{
|
||||
*aHeight = mHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsSVGRect::SetHeight(float aHeight)
|
||||
{
|
||||
WillModify();
|
||||
mHeight = aHeight;
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsSVGRect prototype wrapper class
|
||||
// delegates all 'getter' calls to the given prototype if the property
|
||||
// hasn't been set on the object directly
|
||||
|
||||
class nsSVGRectPrototypeWrapper : public nsIDOMSVGRect,
|
||||
public nsSVGValue
|
||||
{
|
||||
public:
|
||||
static nsresult Create(nsIDOMSVGRect** result,
|
||||
nsIDOMSVGRect* prototype,
|
||||
nsIDOMSVGRect* body=nsnull);
|
||||
protected:
|
||||
nsSVGRectPrototypeWrapper(nsIDOMSVGRect* prototype,
|
||||
nsIDOMSVGRect* body);
|
||||
virtual ~nsSVGRectPrototypeWrapper();
|
||||
|
||||
public:
|
||||
// nsISupports interface:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMSVGRect interface:
|
||||
NS_DECL_NSIDOMSVGRECT
|
||||
|
||||
// nsISVGValue interface:
|
||||
NS_IMETHOD SetValueString(const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetValueString(nsAWritableString& aValue);
|
||||
|
||||
|
||||
protected:
|
||||
void EnsureBody();
|
||||
nsIDOMSVGRect* Delegate() { return mBody ? mBody.get() : mPrototype.get(); }
|
||||
|
||||
nsCOMPtr<nsIDOMSVGRect> mPrototype;
|
||||
nsCOMPtr<nsIDOMSVGRect> mBody;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// implementation:
|
||||
|
||||
nsresult
|
||||
nsSVGRectPrototypeWrapper::Create(nsIDOMSVGRect** result,
|
||||
nsIDOMSVGRect* prototype,
|
||||
nsIDOMSVGRect* body)
|
||||
{
|
||||
*result = (nsIDOMSVGRect*) new nsSVGRectPrototypeWrapper(prototype, body);
|
||||
if(!*result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsSVGRectPrototypeWrapper::nsSVGRectPrototypeWrapper(nsIDOMSVGRect* prototype,
|
||||
nsIDOMSVGRect* body)
|
||||
: mPrototype(prototype), mBody(body)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
NS_ASSERTION(mPrototype, "need prototype");
|
||||
}
|
||||
|
||||
nsSVGRectPrototypeWrapper::~nsSVGRectPrototypeWrapper()
|
||||
{
|
||||
// if (mBody) {
|
||||
// nsCOMPtr<nsISVGValue> val = do_QueryInterface(mBody);
|
||||
// if (val)
|
||||
// val->RemoveObserver(this);
|
||||
// }
|
||||
}
|
||||
|
||||
void nsSVGRectPrototypeWrapper::EnsureBody()
|
||||
{
|
||||
if (mBody) return;
|
||||
|
||||
nsSVGRect::Create(getter_AddRefs(mBody));
|
||||
NS_ASSERTION(mBody, "couldn't create body");
|
||||
// nsCOMPtr<nsISVGValue> val = do_QueryInterface(mBody);
|
||||
// if (val)
|
||||
// val->AddObserver(this);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ADDREF(nsSVGRectPrototypeWrapper)
|
||||
NS_IMPL_RELEASE(nsSVGRectPrototypeWrapper)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGRectPrototypeWrapper)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGValue)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGRect)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGRect)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISVGValue)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValue methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGRectPrototypeWrapper::SetValueString(const nsAReadableString& aValue)
|
||||
{
|
||||
EnsureBody();
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(mBody);
|
||||
NS_ASSERTION(val, "missing interface on body");
|
||||
|
||||
return val->SetValueString(aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGRectPrototypeWrapper::GetValueString(nsAWritableString& aValue)
|
||||
{
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface( Delegate() );
|
||||
NS_ASSERTION(val, "missing interface on body");
|
||||
|
||||
return val->GetValueString(aValue);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGRect methods:
|
||||
|
||||
/* attribute float x; */
|
||||
NS_IMETHODIMP nsSVGRectPrototypeWrapper::GetX(float *aX)
|
||||
{
|
||||
return Delegate()->GetX(aX);
|
||||
}
|
||||
NS_IMETHODIMP nsSVGRectPrototypeWrapper::SetX(float aX)
|
||||
{
|
||||
WillModify();
|
||||
EnsureBody();
|
||||
nsresult rv = mBody->SetX(aX);
|
||||
DidModify();
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* attribute float y; */
|
||||
NS_IMETHODIMP nsSVGRectPrototypeWrapper::GetY(float *aY)
|
||||
{
|
||||
return Delegate()->GetY(aY);
|
||||
}
|
||||
NS_IMETHODIMP nsSVGRectPrototypeWrapper::SetY(float aY)
|
||||
{
|
||||
WillModify();
|
||||
EnsureBody();
|
||||
nsresult rv = mBody->SetY(aY);
|
||||
DidModify();
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* attribute float width; */
|
||||
NS_IMETHODIMP nsSVGRectPrototypeWrapper::GetWidth(float *aWidth)
|
||||
{
|
||||
return Delegate()->GetWidth(aWidth);
|
||||
}
|
||||
NS_IMETHODIMP nsSVGRectPrototypeWrapper::SetWidth(float aWidth)
|
||||
{
|
||||
WillModify();
|
||||
EnsureBody();
|
||||
nsresult rv = mBody->SetWidth(aWidth);
|
||||
DidModify();
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* attribute float height; */
|
||||
NS_IMETHODIMP nsSVGRectPrototypeWrapper::GetHeight(float *aHeight)
|
||||
{
|
||||
return Delegate()->GetHeight(aHeight);
|
||||
}
|
||||
NS_IMETHODIMP nsSVGRectPrototypeWrapper::SetHeight(float aHeight)
|
||||
{
|
||||
WillModify();
|
||||
EnsureBody();
|
||||
nsresult rv = mBody->SetHeight(aHeight);
|
||||
DidModify();
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Exported creation functions:
|
||||
|
||||
nsresult
|
||||
NS_NewSVGRect(nsIDOMSVGRect** result, float x, float y,
|
||||
float width, float height)
|
||||
{
|
||||
return nsSVGRect::Create(result, x, y, width, height);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewSVGRectPrototypeWrapper(nsIDOMSVGRect** result,
|
||||
nsIDOMSVGRect* prototype)
|
||||
{
|
||||
return nsSVGRectPrototypeWrapper::Create(result, prototype);
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#ifndef __NS_SVGRECT_H__
|
||||
#define __NS_SVGRECT_H__
|
||||
|
||||
#include "nsIDOMSVGRect.h"
|
||||
|
||||
nsresult
|
||||
NS_NewSVGRect(nsIDOMSVGRect** result,
|
||||
float x=0.0f, float y=0.0f,
|
||||
float width=0.0f, float height=0.0f);
|
||||
|
||||
|
||||
// create an SVGRect wrapper object that delegates all 'getter' calls
|
||||
// to the given prototype if the property hasn't been set on the
|
||||
// object directly
|
||||
nsresult
|
||||
NS_NewSVGRectPrototypeWrapper(nsIDOMSVGRect** result,
|
||||
nsIDOMSVGRect* prototype);
|
||||
|
||||
|
||||
#endif //__NS_SVGRECT_H__
|
|
@ -0,0 +1,337 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* William Cook <william.cook@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGGraphicElement.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsSVGAnimatedLength.h"
|
||||
#include "nsSVGLength.h"
|
||||
#include "nsIDOMSVGRectElement.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
typedef nsSVGGraphicElement nsSVGRectElementBase;
|
||||
|
||||
class nsSVGRectElement : public nsSVGRectElementBase,
|
||||
public nsIDOMSVGRectElement
|
||||
{
|
||||
protected:
|
||||
friend nsresult NS_NewSVGRectElement(nsIContent **aResult,
|
||||
nsINodeInfo *aNodeInfo);
|
||||
nsSVGRectElement();
|
||||
virtual ~nsSVGRectElement();
|
||||
virtual nsresult Init();
|
||||
|
||||
public:
|
||||
// interfaces:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMSVGRECTELEMENT
|
||||
|
||||
// xxx I wish we could use virtual inheritance
|
||||
NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGRectElementBase::)
|
||||
NS_FORWARD_NSIDOMELEMENT(nsSVGRectElementBase::)
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGRectElementBase::)
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mX;
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mY;
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mWidth;
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mHeight;
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mRx;
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> mRy;
|
||||
|
||||
};
|
||||
|
||||
|
||||
nsresult NS_NewSVGRectElement(nsIContent **aResult, nsINodeInfo *aNodeInfo)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
nsSVGRectElement* it = new nsSVGRectElement();
|
||||
|
||||
if (!it) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = NS_STATIC_CAST(nsGenericElement*,it)->Init(aNodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aResult = NS_STATIC_CAST(nsIContent *, it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsSVGRectElement,nsSVGRectElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(nsSVGRectElement,nsSVGRectElementBase)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGRectElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGRectElement)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGRectElement)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGRectElementBase)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsSVGRectElement::nsSVGRectElement()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
nsSVGRectElement::~nsSVGRectElement()
|
||||
{
|
||||
if (mX) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mX);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
if (mY) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mY);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
if (mWidth) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mWidth);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
if (mHeight) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mHeight);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
if (mRx) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mRx);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
if (mRy) {
|
||||
nsCOMPtr<nsISVGValue> value = do_QueryInterface(mRy);
|
||||
value->RemoveObserver(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsSVGRectElement::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsSVGRectElementBase::Init();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// Create mapped properties:
|
||||
|
||||
// DOM property: x , #IMPLIED attrib: x
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eXDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mX), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::x, mX);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
// DOM property: y , #IMPLIED attrib: y
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eYDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mY), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::y, mY);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
// DOM property: width , #REQUIRED attrib: width
|
||||
// XXX: enforce requiredness
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eXDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mWidth), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::width, mWidth);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
// DOM property: height , #REQUIRED attrib: height
|
||||
// XXX: enforce requiredness
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eYDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mHeight), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::height, mHeight);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
// DOM property: rx , #IMPLIED attrib: rx
|
||||
// XXX: enforce requiredness
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eXDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mRx), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::rx, mRx);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
// DOM property: ry , #IMPLIED attrib: ry
|
||||
// XXX: enforce requiredness
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGLength> length;
|
||||
rv = NS_NewSVGLength(getter_AddRefs(length),
|
||||
(nsSVGElement*)this, eYDirection,
|
||||
0.0f);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = NS_NewSVGAnimatedLength(getter_AddRefs(mRy), length);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = mAttributes->AddMappedSVGValue(nsSVGAtoms::ry, mRy);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNode methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGRectElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
nsSVGRectElement* it = new nsSVGRectElement();
|
||||
|
||||
if (!it) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
|
||||
nsresult rv = NS_STATIC_CAST(nsGenericElement*,it)->Init(mNodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = it->Init();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = CopyNode(it, aDeep);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
it->Release();
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aReturn = NS_STATIC_CAST(nsSVGRectElementBase*, it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGRectElement methods
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength x; */
|
||||
NS_IMETHODIMP nsSVGRectElement::GetX(nsIDOMSVGAnimatedLength * *aX)
|
||||
{
|
||||
*aX = mX;
|
||||
NS_IF_ADDREF(*aX);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength y; */
|
||||
NS_IMETHODIMP nsSVGRectElement::GetY(nsIDOMSVGAnimatedLength * *aY)
|
||||
{
|
||||
*aY = mY;
|
||||
NS_IF_ADDREF(*aY);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength width; */
|
||||
NS_IMETHODIMP nsSVGRectElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
|
||||
{
|
||||
*aWidth = mWidth;
|
||||
NS_IF_ADDREF(*aWidth);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength height; */
|
||||
NS_IMETHODIMP nsSVGRectElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
|
||||
{
|
||||
*aHeight = mHeight;
|
||||
NS_IF_ADDREF(*aHeight);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength rx; */
|
||||
NS_IMETHODIMP nsSVGRectElement::GetRx(nsIDOMSVGAnimatedLength * *aRx)
|
||||
{
|
||||
*aRx = mRx;
|
||||
NS_IF_ADDREF(*aRx);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength ry; */
|
||||
NS_IMETHODIMP nsSVGRectElement::GetRy(nsIDOMSVGAnimatedLength * *aRy)
|
||||
{
|
||||
*aRy = mRy;
|
||||
NS_IF_ADDREF(*aRy);
|
||||
return NS_OK;
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,169 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGValue.h"
|
||||
#include "nsISVGStyleValue.h"
|
||||
#include "nsSVGStyleValue.h"
|
||||
#include "nsIStyleRule.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsICSSParser.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsLayoutCID.h"
|
||||
|
||||
static NS_DEFINE_CID(kCSSParserCID, NS_CSSPARSER_CID);
|
||||
|
||||
class nsSVGStyleValue : public nsSVGValue,
|
||||
public nsISVGStyleValue
|
||||
{
|
||||
protected:
|
||||
friend nsresult
|
||||
NS_NewSVGStyleValue(nsISVGStyleValue** aResult);
|
||||
|
||||
nsSVGStyleValue();
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsISVGValue interface:
|
||||
NS_IMETHOD SetValueString(const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetValueString(nsAWritableString& aValue);
|
||||
|
||||
// nsISVGStyleValue interface:
|
||||
NS_IMETHOD GetStyleRule(nsIDocument* baseDoc, nsIStyleRule** rule);
|
||||
|
||||
protected:
|
||||
// Implementation helpers:
|
||||
void UpdateStyleRule(nsIDocument* baseDoc);
|
||||
|
||||
nsString mValue;
|
||||
nsCOMPtr<nsIStyleRule> mRule; // lazily cached
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation:
|
||||
|
||||
nsresult
|
||||
NS_NewSVGStyleValue(nsISVGStyleValue** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aResult = (nsISVGStyleValue*) new nsSVGStyleValue();
|
||||
if(!*aResult) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsSVGStyleValue::nsSVGStyleValue()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsSVGStyleValue,
|
||||
nsISVGValue,
|
||||
nsISVGStyleValue);
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValue methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGStyleValue::SetValueString(const nsAReadableString& aValue)
|
||||
{
|
||||
WillModify();
|
||||
mValue = aValue;
|
||||
mRule = nsnull;
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGStyleValue::GetValueString(nsAWritableString& aValue)
|
||||
{
|
||||
aValue = mValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGStyleValue interface:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGStyleValue::GetStyleRule(nsIDocument* baseDoc, nsIStyleRule** rule)
|
||||
{
|
||||
if (!mRule) {
|
||||
UpdateStyleRule(baseDoc);
|
||||
}
|
||||
|
||||
*rule = mRule;
|
||||
NS_IF_ADDREF(*rule);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation helpers:
|
||||
|
||||
void
|
||||
nsSVGStyleValue::UpdateStyleRule(nsIDocument* baseDoc)
|
||||
{
|
||||
|
||||
if (mValue.IsEmpty()) {
|
||||
// XXX: Removing the rule. Is this sufficient?
|
||||
mRule = nsnull;
|
||||
return;
|
||||
}
|
||||
|
||||
NS_ASSERTION(baseDoc,"need base document");
|
||||
nsCOMPtr <nsIURI> docURL;
|
||||
baseDoc->GetBaseURL(*getter_AddRefs(docURL));
|
||||
|
||||
nsCOMPtr<nsICSSParser> css;
|
||||
nsComponentManager::CreateInstance(kCSSParserCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsICSSParser),
|
||||
getter_AddRefs(css));
|
||||
NS_ASSERTION(css, "can't get a css parser");
|
||||
if (!css) return;
|
||||
|
||||
css->ParseStyleAttribute(mValue, docURL, getter_AddRefs(mRule));
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
|
||||
#ifndef __NS_SVGSTYLEVALUE_H__
|
||||
#define __NS_SVGSTYLEVALUE_H__
|
||||
|
||||
class nsISVGStyleValue;
|
||||
|
||||
nsresult
|
||||
NS_NewSVGStyleValue(nsISVGStyleValue** aResult);
|
||||
|
||||
#endif // __NS_SVGSTYLEVALUE_H__
|
||||
|
|
@ -0,0 +1,349 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGTransform.h"
|
||||
#include "prdtoa.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsSVGValue.h"
|
||||
#include "nsIWeakReference.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsSVGTransform 'letter' class
|
||||
|
||||
class nsSVGTransform : public nsIDOMSVGTransform,
|
||||
public nsSVGValue
|
||||
{
|
||||
public:
|
||||
static nsresult Create(nsIDOMSVGTransform** aResult);
|
||||
|
||||
protected:
|
||||
nsSVGTransform();
|
||||
nsresult Init();
|
||||
public:
|
||||
// nsISupports interface:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMSVGTransform interface:
|
||||
NS_DECL_NSIDOMSVGTRANSFORM
|
||||
|
||||
// nsISVGValue interface:
|
||||
NS_IMETHOD SetValueString(const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetValueString(nsAWritableString& aValue);
|
||||
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDOMSVGMatrix> mMatrix;
|
||||
float mAngle, mOriginX, mOriginY;
|
||||
PRUint16 mType;
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
nsresult
|
||||
nsSVGTransform::Create(nsIDOMSVGTransform** aResult)
|
||||
{
|
||||
nsSVGTransform *pl = new nsSVGTransform();
|
||||
NS_ENSURE_TRUE(pl, NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ADDREF(pl);
|
||||
if (NS_FAILED(pl->Init())) {
|
||||
NS_RELEASE(pl);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
*aResult = pl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsSVGTransform::nsSVGTransform()
|
||||
: mAngle(0.0f),
|
||||
mOriginX(0.0f),
|
||||
mOriginY(0.0f),
|
||||
mType( SVG_TRANSFORM_MATRIX )
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsresult nsSVGTransform::Init()
|
||||
{
|
||||
return nsSVGMatrix::Create(getter_AddRefs(mMatrix));
|
||||
// XXX register as matrix observer
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ADDREF(nsSVGTransform)
|
||||
NS_IMPL_RELEASE(nsSVGTransform)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGTransform)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGValue)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTransform)
|
||||
// NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
// NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGTransform)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISVGValue)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValue methods:
|
||||
NS_IMETHODIMP
|
||||
nsSVGTransform::SetValueString(const nsAReadableString& aValue)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGTransform::GetValueString(nsAWritableString& aValue)
|
||||
{
|
||||
aValue.Truncate();
|
||||
char buf[256];
|
||||
|
||||
switch (mType) {
|
||||
case nsIDOMSVGTransform::SVG_TRANSFORM_TRANSLATE:
|
||||
{
|
||||
float dx, dy;
|
||||
mMatrix->GetE(&dx);
|
||||
mMatrix->GetF(&dy);
|
||||
if (dy != 0.0f)
|
||||
sprintf(buf, "translate(%g, %g)", dx, dy);
|
||||
else
|
||||
sprintf(buf, "translate(%g)", dx);
|
||||
}
|
||||
break;
|
||||
case nsIDOMSVGTransform::SVG_TRANSFORM_ROTATE:
|
||||
{
|
||||
if (mOriginX != 0.0f || mOriginY != 0.0f)
|
||||
sprintf(buf, "rotate(%g, %g, %g)", mAngle, mOriginX, mOriginY);
|
||||
else
|
||||
sprintf(buf, "rotate(%g)", mAngle);
|
||||
}
|
||||
break;
|
||||
case nsIDOMSVGTransform::SVG_TRANSFORM_SCALE:
|
||||
{
|
||||
float sx, sy;
|
||||
mMatrix->GetA(&sx);
|
||||
mMatrix->GetD(&sy);
|
||||
if (sy != 0.0f)
|
||||
sprintf(buf, "scale(%g, %g)", sx, sy);
|
||||
else
|
||||
sprintf(buf, "scale(%g)", sx);
|
||||
}
|
||||
break;
|
||||
case nsIDOMSVGTransform::SVG_TRANSFORM_SKEWX:
|
||||
{
|
||||
float sx;
|
||||
mMatrix->GetC(&sx);
|
||||
sprintf(buf, "skewX(%g)", sx);
|
||||
}
|
||||
break;
|
||||
case nsIDOMSVGTransform::SVG_TRANSFORM_SKEWY:
|
||||
{
|
||||
float sy;
|
||||
mMatrix->GetB(&sy);
|
||||
sprintf(buf, "skewY(%g)", sy);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
buf[0] = '\0';
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
break;
|
||||
}
|
||||
|
||||
aValue.Append(NS_ConvertASCIItoUCS2(buf));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGTransform methods:
|
||||
|
||||
/* readonly attribute unsigned short type; */
|
||||
NS_IMETHODIMP nsSVGTransform::GetType(PRUint16 *aType)
|
||||
{
|
||||
*aType = mType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGMatrix matrix; */
|
||||
NS_IMETHODIMP nsSVGTransform::GetMatrix(nsIDOMSVGMatrix * *aMatrix)
|
||||
{
|
||||
// XXX should we make a copy here? is the matrix supposed to be live
|
||||
// or not?
|
||||
*aMatrix = mMatrix;
|
||||
NS_IF_ADDREF(*aMatrix);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute float angle; */
|
||||
NS_IMETHODIMP nsSVGTransform::GetAngle(float *aAngle)
|
||||
{
|
||||
*aAngle = mAngle;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void setMatrix (in nsIDOMSVGMatrix matrix); */
|
||||
NS_IMETHODIMP nsSVGTransform::SetMatrix(nsIDOMSVGMatrix *matrix)
|
||||
{
|
||||
WillModify();
|
||||
|
||||
mType = SVG_TRANSFORM_MATRIX;
|
||||
mAngle = 0.0f;
|
||||
mOriginX = 0.0f;
|
||||
mOriginY = 0.0f;
|
||||
|
||||
// XXX should we copy the matrix instead of replacing?
|
||||
mMatrix = matrix;
|
||||
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void setTranslate (in float tx, in float ty); */
|
||||
NS_IMETHODIMP nsSVGTransform::SetTranslate(float tx, float ty)
|
||||
{
|
||||
WillModify();
|
||||
|
||||
mType = SVG_TRANSFORM_TRANSLATE;
|
||||
mAngle = 0.0f;
|
||||
mOriginX = 0.0f;
|
||||
mOriginY = 0.0f;
|
||||
mMatrix->SetA(1.0f);
|
||||
mMatrix->SetB(0.0f);
|
||||
mMatrix->SetC(0.0f);
|
||||
mMatrix->SetD(1.0f);
|
||||
mMatrix->SetE(tx);
|
||||
mMatrix->SetF(ty);
|
||||
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void setScale (in float sx, in float sy); */
|
||||
NS_IMETHODIMP nsSVGTransform::SetScale(float sx, float sy)
|
||||
{
|
||||
WillModify();
|
||||
|
||||
mType = SVG_TRANSFORM_SCALE;
|
||||
mAngle = 0.0f;
|
||||
mOriginX = 0.0f;
|
||||
mOriginY = 0.0f;
|
||||
mMatrix->SetA(sx);
|
||||
mMatrix->SetB(0.0f);
|
||||
mMatrix->SetC(0.0f);
|
||||
mMatrix->SetD(sy);
|
||||
mMatrix->SetE(0.0f);
|
||||
mMatrix->SetF(0.0f);
|
||||
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void setRotate (in float angle, in float cx, in float cy); */
|
||||
NS_IMETHODIMP nsSVGTransform::SetRotate(float angle, float cx, float cy)
|
||||
{
|
||||
WillModify();
|
||||
|
||||
mType = SVG_TRANSFORM_ROTATE;
|
||||
mAngle = angle;
|
||||
mOriginX = cx;
|
||||
mOriginY = cy;
|
||||
|
||||
nsSVGMatrix::Create(getter_AddRefs(mMatrix));
|
||||
nsCOMPtr<nsIDOMSVGMatrix> temp;
|
||||
mMatrix->Translate(cx, cy, getter_AddRefs(temp));
|
||||
mMatrix = temp;
|
||||
mMatrix->Rotate(angle, getter_AddRefs(temp));
|
||||
mMatrix = temp;
|
||||
mMatrix->Translate(-cx,-cy, getter_AddRefs(temp));
|
||||
mMatrix = temp;
|
||||
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void setSkewX (in float angle); */
|
||||
NS_IMETHODIMP nsSVGTransform::SetSkewX(float angle)
|
||||
{
|
||||
WillModify();
|
||||
|
||||
mType = SVG_TRANSFORM_SKEWX;
|
||||
mAngle = angle;
|
||||
|
||||
nsSVGMatrix::Create(getter_AddRefs(mMatrix));
|
||||
nsCOMPtr<nsIDOMSVGMatrix> temp;
|
||||
mMatrix->SkewX(angle, getter_AddRefs(temp));
|
||||
mMatrix = temp;
|
||||
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void setSkewY (in float angle); */
|
||||
NS_IMETHODIMP nsSVGTransform::SetSkewY(float angle)
|
||||
{
|
||||
WillModify();
|
||||
|
||||
mType = SVG_TRANSFORM_SKEWY;
|
||||
mAngle = angle;
|
||||
|
||||
nsSVGMatrix::Create(getter_AddRefs(mMatrix));
|
||||
nsCOMPtr<nsIDOMSVGMatrix> temp;
|
||||
mMatrix->SkewY(angle, getter_AddRefs(temp));
|
||||
mMatrix = temp;
|
||||
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Exported creation functions:
|
||||
|
||||
nsresult
|
||||
NS_NewSVGTransform(nsIDOMSVGTransform** result)
|
||||
{
|
||||
return nsSVGTransform::Create(result);
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#ifndef __NS_SVGTRANSFORM_H__
|
||||
#define __NS_SVGTRANSFORM_H__
|
||||
|
||||
#include "nsIDOMSVGTransform.h"
|
||||
|
||||
nsresult
|
||||
NS_NewSVGTransform(nsIDOMSVGTransform** result);
|
||||
|
||||
// XXX we'll need this prototype-based stuff to support unsetting:
|
||||
//nsresult NS_NewSVGTransform(nsIDOMSVGTransform** result,
|
||||
// nsIDOMSVGTransform* prototype);
|
||||
|
||||
|
||||
#endif //__NS_SVGTRANSFORM_H__
|
|
@ -0,0 +1,440 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ----- BEGIN LICENSE BLOCK -----
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Crocodile Clips Ltd..
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ----- END LICENSE BLOCK ----- */
|
||||
|
||||
#include "nsSVGTransformList.h"
|
||||
#include "nsSVGTransform.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "prdtoa.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
nsresult
|
||||
nsSVGTransformList::Create(const nsAReadableString& aValue,
|
||||
nsISVGValue** aResult)
|
||||
{
|
||||
*aResult = (nsISVGValue*) new nsSVGTransformList();
|
||||
if(!*aResult) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
(*aResult)->SetValueString(aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGTransformList::Create(nsIDOMSVGTransformList** aResult)
|
||||
{
|
||||
*aResult = (nsIDOMSVGTransformList*) new nsSVGTransformList();
|
||||
if(!*aResult) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsSVGTransformList::nsSVGTransformList()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsSVGTransformList::~nsSVGTransformList()
|
||||
{
|
||||
ReleaseTransforms();
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGTransformList::ReleaseTransforms()
|
||||
{
|
||||
WillModify();
|
||||
PRInt32 count = mTransforms.Count();
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsIDOMSVGTransform* transform = ElementAt(i);
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(transform);
|
||||
if (val)
|
||||
val->RemoveObserver(this);
|
||||
NS_RELEASE(transform);
|
||||
}
|
||||
mTransforms.Clear();
|
||||
DidModify();
|
||||
}
|
||||
|
||||
nsIDOMSVGTransform*
|
||||
nsSVGTransformList::ElementAt(PRInt32 index)
|
||||
{
|
||||
return (nsIDOMSVGTransform*)mTransforms.ElementAt(index);
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGTransformList::AppendElement(nsIDOMSVGTransform* aElement)
|
||||
{
|
||||
WillModify();
|
||||
NS_ADDREF(aElement);
|
||||
mTransforms.AppendElement((void*)aElement);
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(aElement);
|
||||
if (val)
|
||||
val->AddObserver(this);
|
||||
DidModify();
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGTransformList::RemoveElementAt(PRInt32 index)
|
||||
{
|
||||
WillModify();
|
||||
nsIDOMSVGTransform* transform = ElementAt(index);
|
||||
NS_ASSERTION(transform, "null transform");
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(transform);
|
||||
if (val)
|
||||
val->RemoveObserver(this);
|
||||
mTransforms.RemoveElementAt(index);
|
||||
NS_RELEASE(transform);
|
||||
DidModify();
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGTransformList::InsertElementAt(nsIDOMSVGTransform* aElement, PRInt32 index)
|
||||
{
|
||||
WillModify();
|
||||
NS_ADDREF(aElement);
|
||||
mTransforms.InsertElementAt((void*)aElement, index);
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(aElement);
|
||||
if (val)
|
||||
val->AddObserver(this);
|
||||
DidModify();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// XPConnect interface list
|
||||
NS_CLASSINFO_MAP_BEGIN(SVGTransformList)
|
||||
NS_CLASSINFO_MAP_ENTRY(nsIDOMSVGTransformList)
|
||||
NS_CLASSINFO_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
NS_IMPL_ADDREF(nsSVGTransformList)
|
||||
NS_IMPL_RELEASE(nsSVGTransformList)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSVGTransformList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGValue)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTransformList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGTransformList)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISVGValue)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValue methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGTransformList::SetValueString(const nsAReadableString& aValue)
|
||||
{
|
||||
// XXX: we don't implement the _exact_ BNF given in the
|
||||
// specs.
|
||||
|
||||
WillModify();
|
||||
|
||||
ReleaseTransforms();
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// XXX how am I supposed to do this ???
|
||||
// char* str = aValue.ToNewCString();
|
||||
char* str;
|
||||
{
|
||||
nsAutoString temp(aValue);
|
||||
str = ToNewCString(temp);
|
||||
}
|
||||
|
||||
char* rest = str;
|
||||
char* keyword;
|
||||
char* args;
|
||||
const char* delimiters1 = "\x20\x9\xD\xA,(";
|
||||
const char* delimiters2 = "()";
|
||||
const char* delimiters3 = "\x20\x9\xD\xA,";
|
||||
|
||||
while ((keyword = nsCRT::strtok(rest, delimiters1, &rest))) {
|
||||
|
||||
while (rest && isspace(*rest))
|
||||
++rest;
|
||||
|
||||
if (!(args = nsCRT::strtok(rest, delimiters2, &rest)))
|
||||
break; // parse error
|
||||
|
||||
nsCOMPtr<nsIDOMSVGTransform> transform;
|
||||
NS_NewSVGTransform(getter_AddRefs(transform));
|
||||
if (!transform) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> keyatom = dont_AddRef(NS_NewAtom(keyword));
|
||||
|
||||
if (keyatom == nsSVGAtoms::translate) {
|
||||
char* arg1 = nsCRT::strtok(args, delimiters3, &args);
|
||||
if (!arg1) break; // parse error
|
||||
char* arg2 = nsCRT::strtok(args, delimiters3, &args);
|
||||
char* end;
|
||||
float tx = (float) PR_strtod(arg1, &end);
|
||||
float ty = arg2 ? (float) PR_strtod(arg2, &end) : 0.0f;
|
||||
transform->SetTranslate(tx, ty);
|
||||
}
|
||||
else if (keyatom == nsSVGAtoms::scale) {
|
||||
char* arg1 = nsCRT::strtok(args, delimiters3, &args);
|
||||
if (!arg1) break; // parse error
|
||||
char* arg2 = nsCRT::strtok(args, delimiters3, &args);
|
||||
char* end;
|
||||
float sx = (float) PR_strtod(arg1, &end);
|
||||
float sy = arg2 ? (float) PR_strtod(arg2, &end) : sx;
|
||||
transform->SetScale(sx, sy);
|
||||
}
|
||||
else if (keyatom == nsSVGAtoms::rotate) {
|
||||
char* arg1 = nsCRT::strtok(args, delimiters3, &args);
|
||||
if (!arg1) break; // parse error
|
||||
char* arg2 = nsCRT::strtok(args, delimiters3, &args);
|
||||
char* arg3 = arg2 ? nsCRT::strtok(args, delimiters3, &args) : nsnull;
|
||||
if (arg2 && !arg3) break; // parse error
|
||||
|
||||
char* end;
|
||||
float angle = (float) PR_strtod(arg1, &end);
|
||||
float cx = arg2 ? (float) PR_strtod(arg2, &end) : 0.0f;
|
||||
float cy = arg3 ? (float) PR_strtod(arg3, &end) : 0.0f;
|
||||
transform->SetRotate(angle, cx, cy);
|
||||
}
|
||||
else if (keyatom == nsSVGAtoms::skewX) {
|
||||
char* arg1 = nsCRT::strtok(args, delimiters3, &args);
|
||||
if (!arg1) break; // parse error
|
||||
|
||||
char* end;
|
||||
float angle = (float) PR_strtod(arg1, &end);
|
||||
transform->SetSkewX(angle);
|
||||
}
|
||||
else if (keyatom == nsSVGAtoms::skewY) {
|
||||
char* arg1 = nsCRT::strtok(args, delimiters3, &args);
|
||||
if (!arg1) break; // parse error
|
||||
|
||||
char* end;
|
||||
float angle = (float) PR_strtod(arg1, &end);
|
||||
transform->SetSkewY(angle);
|
||||
}
|
||||
else { // parse error
|
||||
break;
|
||||
}
|
||||
AppendElement(transform);
|
||||
}
|
||||
|
||||
if (keyword) {
|
||||
// there was a parse error. should we return an error?
|
||||
// rv = NS_ERROR_???;
|
||||
#ifdef DEBUG
|
||||
printf("transform-attribute parse error\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
nsMemory::Free(str);
|
||||
|
||||
DidModify();
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGTransformList::GetValueString(nsAWritableString& aValue)
|
||||
{
|
||||
aValue.Truncate();
|
||||
|
||||
PRInt32 count = mTransforms.Count();
|
||||
|
||||
if (count<=0) return NS_OK;
|
||||
|
||||
PRInt32 i = 0;
|
||||
|
||||
while (1) {
|
||||
nsIDOMSVGTransform* transform = ElementAt(i);
|
||||
|
||||
nsCOMPtr<nsISVGValue> val = do_QueryInterface(transform);
|
||||
nsAutoString str;
|
||||
val->GetValueString(str);
|
||||
aValue.Append(str);
|
||||
|
||||
if (++i >= count) break;
|
||||
|
||||
aValue.Append(NS_LITERAL_STRING(" "));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGTransformList methods:
|
||||
|
||||
/* readonly attribute unsigned long numberOfItems; */
|
||||
NS_IMETHODIMP nsSVGTransformList::GetNumberOfItems(PRUint32 *aNumberOfItems)
|
||||
{
|
||||
*aNumberOfItems = mTransforms.Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void clear (); */
|
||||
NS_IMETHODIMP nsSVGTransformList::Clear()
|
||||
{
|
||||
WillModify();
|
||||
ReleaseTransforms();
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGTransform initialize (in nsIDOMSVGTransform newItem); */
|
||||
NS_IMETHODIMP nsSVGTransformList::Initialize(nsIDOMSVGTransform *newItem, nsIDOMSVGTransform **_retval)
|
||||
{
|
||||
Clear();
|
||||
return AppendItem(newItem, _retval);
|
||||
}
|
||||
|
||||
/* nsIDOMSVGTransform getItem (in unsigned long index); */
|
||||
NS_IMETHODIMP nsSVGTransformList::GetItem(PRUint32 index, nsIDOMSVGTransform **_retval)
|
||||
{
|
||||
if ((PRInt32)index >= mTransforms.Count()) {
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
}
|
||||
|
||||
*_retval = ElementAt(index);
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGTransform insertItemBefore (in nsIDOMSVGTransform newItem, in unsigned long index); */
|
||||
NS_IMETHODIMP nsSVGTransformList::InsertItemBefore(nsIDOMSVGTransform *newItem, PRUint32 index, nsIDOMSVGTransform **_retval)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGTransform replaceItem (in nsIDOMSVGTransform newItem, in unsigned long index); */
|
||||
NS_IMETHODIMP nsSVGTransformList::ReplaceItem(nsIDOMSVGTransform *newItem, PRUint32 index, nsIDOMSVGTransform **_retval)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGTransform removeItem (in unsigned long index); */
|
||||
NS_IMETHODIMP nsSVGTransformList::RemoveItem(PRUint32 index, nsIDOMSVGTransform **_retval)
|
||||
{
|
||||
if ((PRInt32)index >= mTransforms.Count()) {
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
}
|
||||
|
||||
*_retval = ElementAt(index);
|
||||
NS_ADDREF(*_retval);
|
||||
WillModify();
|
||||
RemoveElementAt(index);
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGTransform appendItem (in nsIDOMSVGTransform newItem); */
|
||||
NS_IMETHODIMP nsSVGTransformList::AppendItem(nsIDOMSVGTransform *newItem, nsIDOMSVGTransform **_retval)
|
||||
{
|
||||
// XXX The SVG specs state that 'if newItem is already in a list, it
|
||||
// is removed from its previous list before it is inserted into this
|
||||
// list'. We don't do that. Should we?
|
||||
|
||||
*_retval = newItem;
|
||||
NS_ADDREF(*_retval);
|
||||
AppendElement(newItem);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGTransform createSVGTransformFromMatrix (in nsIDOMSVGMatrix matrix); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGTransformList::CreateSVGTransformFromMatrix(nsIDOMSVGMatrix *matrix,
|
||||
nsIDOMSVGTransform **_retval)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGTransform consolidate (); */
|
||||
NS_IMETHODIMP nsSVGTransformList::Consolidate(nsIDOMSVGTransform **_retval)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix getConsolidation (); */
|
||||
NS_IMETHODIMP nsSVGTransformList::GetConsolidation(nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
PRInt32 count = mTransforms.Count();
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> consolidation;
|
||||
nsSVGMatrix::Create(getter_AddRefs(consolidation));
|
||||
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsIDOMSVGTransform* transform = ElementAt(i);
|
||||
nsCOMPtr<nsIDOMSVGMatrix> matrix;
|
||||
transform->GetMatrix(getter_AddRefs(matrix));
|
||||
nsCOMPtr<nsIDOMSVGMatrix> temp;
|
||||
consolidation->Multiply(matrix, getter_AddRefs(temp));
|
||||
consolidation = temp;
|
||||
}
|
||||
|
||||
*_retval = consolidation;
|
||||
NS_ADDREF(*_retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISVGValueObserver methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGTransformList::WillModifySVGObservable(nsISVGValue* observable)
|
||||
{
|
||||
WillModify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGTransformList::DidModifySVGObservable (nsISVGValue* observable)
|
||||
{
|
||||
DidModify();
|
||||
return NS_OK;
|
||||
}
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче