mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 249048 - Implement SVG exceptions.
p=jonathan.watt@strath.ac.uk, r=afri, sr=peterv
This commit is contained in:
parent
2deceb4923
commit
f463a3d401
@ -37,6 +37,7 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsSVGMatrix.h"
|
||||
#include "nsDOMError.h"
|
||||
#include <math.h>
|
||||
|
||||
const double radPerDegree = 2.0*3.1415926535 / 360.0;
|
||||
@ -192,10 +193,8 @@ NS_IMETHODIMP nsSVGMatrix::Multiply(nsIDOMSVGMatrix *secondMatrix, nsIDOMSVGMatr
|
||||
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
|
||||
}
|
||||
if (det == 0.0)
|
||||
return NS_ERROR_DOM_SVG_MATRIX_NOT_INVERTABLE;
|
||||
|
||||
Create(_retval);
|
||||
if (!*_retval) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -64,6 +64,7 @@ XPIDLSRCS = \
|
||||
nsIDOMSVGDocument.idl \
|
||||
nsIDOMSVGElement.idl \
|
||||
nsIDOMSVGEllipseElement.idl \
|
||||
nsIDOMSVGException.idl \
|
||||
nsIDOMSVGFitToViewBox.idl \
|
||||
nsIDOMSVGForeignObjectElem.idl \
|
||||
nsIDOMSVGGElement.idl \
|
||||
|
54
dom/public/idl/svg/nsIDOMSVGException.idl
Normal file
54
dom/public/idl/svg/nsIDOMSVGException.idl
Normal file
@ -0,0 +1,54 @@
|
||||
/* -*- 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 SVG Project code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Jonathan Watt.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jonathan Watt <jonathan.watt@strath.ac.uk> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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 MPL, 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 ***** */
|
||||
|
||||
/**
|
||||
* Corresponds to http://www.w3.org/TR/SVG11/svgdom.html#InterfaceSVGException
|
||||
*/
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(64e6f0e1-af99-4bb9-ab25-7e56012f0021)]
|
||||
interface nsIDOMSVGException : nsISupports
|
||||
{
|
||||
// SVGExceptionCode
|
||||
const unsigned short SVG_WRONG_TYPE_ERR = 0;
|
||||
const unsigned short SVG_INVALID_VALUE_ERR = 1;
|
||||
const unsigned short SVG_MATRIX_NOT_INVERTABLE = 2;
|
||||
|
||||
readonly attribute unsigned short code;
|
||||
};
|
@ -74,6 +74,13 @@
|
||||
#define NS_ERROR_DOM_VALIDATION_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,16)
|
||||
#define NS_ERROR_DOM_TYPE_MISMATCH_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,17)
|
||||
|
||||
/* SVG DOM error codes from http://www.w3.org/TR/SVG11/svgdom.html */
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
#define NS_ERROR_DOM_SVG_WRONG_TYPE_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_SVG,0)
|
||||
#define NS_ERROR_DOM_SVG_INVALID_VALUE_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_SVG,1)
|
||||
#define NS_ERROR_DOM_SVG_MATRIX_NOT_INVERTABLE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_SVG,2)
|
||||
#endif
|
||||
|
||||
/* DOM error codes defined by us */
|
||||
|
||||
|
@ -294,6 +294,7 @@ enum nsDOMClassInfoID {
|
||||
eDOMClassInfo_SVGAnimatedPreserveAspectRatio_id,
|
||||
eDOMClassInfo_SVGPreserveAspectRatio_id,
|
||||
eDOMClassInfo_SVGScriptElement_id,
|
||||
eDOMClassInfo_SVGException_id,
|
||||
#endif //MOZ_SVG
|
||||
|
||||
// This one better be the last one in this list
|
||||
|
@ -69,6 +69,14 @@ DOM_MSG_DEF(NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR, "The container of an bound
|
||||
DOM_MSG_DEF(NS_ERROR_DOM_VALIDATION_ERR, "A call to a method would make the Node invalid with respect to \"partial validity\", so the operation was not done")
|
||||
DOM_MSG_DEF(NS_ERROR_DOM_TYPE_MISMATCH_ERR, "The type of an object is incompatible with the expected type of the parameter associated to the object")
|
||||
|
||||
/* SVG DOM error codes from http://www.w3.org/TR/SVG11/svgdom.html */
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
DOM_MSG_DEF(NS_ERROR_DOM_SVG_WRONG_TYPE_ERR, "Unknown or invalid type")
|
||||
DOM_MSG_DEF(NS_ERROR_DOM_SVG_INVALID_VALUE_ERR, "One of the parameters has an invalid value")
|
||||
DOM_MSG_DEF(NS_ERROR_DOM_SVG_MATRIX_NOT_INVERTABLE, "The matrix could not be computed")
|
||||
#endif
|
||||
|
||||
/* DOM error codes defined by us */
|
||||
|
||||
/* XXX string should be specified by norris */
|
||||
|
@ -304,6 +304,7 @@
|
||||
#include "nsIDOMSVGAnimTransformList.h"
|
||||
#include "nsIDOMSVGCircleElement.h"
|
||||
#include "nsIDOMSVGEllipseElement.h"
|
||||
#include "nsIDOMSVGException.h"
|
||||
#include "nsIDOMSVGLineElement.h"
|
||||
#include "nsIDOMSVGRectElement.h"
|
||||
#include "nsIDOMSVGDocument.h"
|
||||
@ -893,7 +894,9 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(SVGScriptElement, nsElementSH,
|
||||
ELEMENT_SCRIPTABLE_FLAGS)
|
||||
#endif
|
||||
NS_DEFINE_CLASSINFO_DATA(SVGException, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
#endif //MOZ_SVG
|
||||
};
|
||||
|
||||
nsIXPConnect *nsDOMClassInfo::sXPConnect = nsnull;
|
||||
@ -2386,6 +2389,11 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(SVGException, nsIDOMSVGException)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGException)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIException)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
#endif //MOZ_SVG
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
|
@ -43,6 +43,9 @@
|
||||
#include "nsDOMException.h"
|
||||
#include "nsIDOMDOMException.h"
|
||||
#include "nsIDOMRangeException.h"
|
||||
#ifdef MOZ_SVG
|
||||
#include "nsIDOMSVGException.h"
|
||||
#endif
|
||||
#include "nsString.h"
|
||||
#include "prprf.h"
|
||||
|
||||
@ -108,11 +111,6 @@ static struct ResultStruct
|
||||
#undef DOM_MSG_DEF
|
||||
|
||||
static void
|
||||
NSResultToNameAndMessage(nsresult aNSResult,
|
||||
const char** aName,
|
||||
const char** aMessage);
|
||||
|
||||
void
|
||||
NSResultToNameAndMessage(nsresult aNSResult,
|
||||
const char** aName,
|
||||
const char** aMessage)
|
||||
@ -168,6 +166,25 @@ nsRangeException::GetCode(PRUint16* aCode)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
IMPL_INTERNAL_DOM_EXCEPTION_HEAD(nsSVGException, nsIDOMSVGException)
|
||||
NS_DECL_NSIDOMSVGEXCEPTION
|
||||
IMPL_INTERNAL_DOM_EXCEPTION_TAIL(nsSVGException, nsIDOMSVGException,
|
||||
SVGException, NS_ERROR_MODULE_SVG,
|
||||
NSResultToNameAndMessage)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGException::GetCode(PRUint16* aCode)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCode);
|
||||
nsresult result;
|
||||
GetResult(&result);
|
||||
*aCode = NS_ERROR_GET_CODE(result);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif // MOZ_SVG
|
||||
|
||||
|
||||
nsBaseDOMException::nsBaseDOMException()
|
||||
{
|
||||
|
@ -64,8 +64,11 @@ protected:
|
||||
#define DECL_INTERNAL_DOM_EXCEPTION(domname) \
|
||||
nsresult \
|
||||
NS_New##domname(nsresult aNSResult, nsIException* aDefaultException, \
|
||||
nsIException** aException)
|
||||
nsIException** aException);
|
||||
|
||||
|
||||
DECL_INTERNAL_DOM_EXCEPTION(DOMException);
|
||||
DECL_INTERNAL_DOM_EXCEPTION(RangeException);
|
||||
DECL_INTERNAL_DOM_EXCEPTION(DOMException)
|
||||
DECL_INTERNAL_DOM_EXCEPTION(RangeException)
|
||||
#ifdef MOZ_SVG
|
||||
DECL_INTERNAL_DOM_EXCEPTION(SVGException)
|
||||
#endif
|
||||
|
@ -78,6 +78,9 @@ nsDOMScriptObjectFactory::nsDOMScriptObjectFactory()
|
||||
if (xs) {
|
||||
xs->RegisterExceptionProvider(this, NS_ERROR_MODULE_DOM);
|
||||
xs->RegisterExceptionProvider(this, NS_ERROR_MODULE_DOM_RANGE);
|
||||
#ifdef MOZ_SVG
|
||||
xs->RegisterExceptionProvider(this, NS_ERROR_MODULE_SVG);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,6 +195,10 @@ nsDOMScriptObjectFactory::Observe(nsISupports *aSubject,
|
||||
|
||||
if (xs) {
|
||||
xs->UnregisterExceptionProvider(this, NS_ERROR_MODULE_DOM);
|
||||
xs->UnregisterExceptionProvider(this, NS_ERROR_MODULE_DOM_RANGE);
|
||||
#ifdef MOZ_SVG
|
||||
xs->UnregisterExceptionProvider(this, NS_ERROR_MODULE_SVG);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,10 +210,17 @@ nsDOMScriptObjectFactory::GetException(nsresult result,
|
||||
nsIException *aDefaultException,
|
||||
nsIException **_retval)
|
||||
{
|
||||
if (NS_ERROR_GET_MODULE(result) == NS_ERROR_MODULE_DOM_RANGE) {
|
||||
return NS_NewRangeException(result, aDefaultException, _retval);
|
||||
switch (NS_ERROR_GET_MODULE(result))
|
||||
{
|
||||
case NS_ERROR_MODULE_DOM_RANGE:
|
||||
return NS_NewRangeException(result, aDefaultException, _retval);
|
||||
#ifdef MOZ_SVG
|
||||
case NS_ERROR_MODULE_SVG:
|
||||
return NS_NewSVGException(result, aDefaultException, _retval);
|
||||
#endif
|
||||
default:
|
||||
return NS_NewDOMException(result, aDefaultException, _retval);
|
||||
}
|
||||
return NS_NewDOMException(result, aDefaultException, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -93,6 +93,7 @@
|
||||
#define NS_ERROR_MODULE_PYXPCOM 26
|
||||
#define NS_ERROR_MODULE_XSLT 27
|
||||
#define NS_ERROR_MODULE_IPC 28
|
||||
#define NS_ERROR_MODULE_SVG 29
|
||||
|
||||
/* NS_ERROR_MODULE_GENERAL should be used by modules that do not
|
||||
* care if return code values overlap. Callers of methods that
|
||||
|
Loading…
Reference in New Issue
Block a user