Bug 631437: Add length to SVGXXXList interfaces and make them respond to array indexing (v4) r=jwatt,bzbarsky

This commit is contained in:
Cameron McCormack 2011-04-08 10:44:03 +12:00
Родитель f873853e5f
Коммит 9d78bc2a99
18 изменённых файлов: 303 добавлений и 94 удалений

Просмотреть файл

@ -92,6 +92,21 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGLengthList)
NS_INTERFACE_MAP_END
nsIDOMSVGLength*
DOMSVGLengthList::GetItemWithoutAddRef(PRUint32 aIndex)
{
#ifdef MOZ_SMIL
if (IsAnimValList()) {
Element()->FlushAnimations();
}
#endif
if (aIndex < Length()) {
EnsureItemAt(aIndex);
return mItems[aIndex];
}
return nsnull;
}
void
DOMSVGLengthList::InternalListLengthWillChange(PRUint32 aNewLength)
{
@ -210,18 +225,12 @@ NS_IMETHODIMP
DOMSVGLengthList::GetItem(PRUint32 index,
nsIDOMSVGLength **_retval)
{
#ifdef MOZ_SMIL
if (IsAnimValList()) {
Element()->FlushAnimations();
*_retval = GetItemWithoutAddRef(index);
if (!*_retval) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
#endif
if (index < Length()) {
EnsureItemAt(index);
NS_ADDREF(*_retval = mItems[index]);
return NS_OK;
}
*_retval = nsnull;
return NS_ERROR_DOM_INDEX_SIZE_ERR;
NS_ADDREF(*_retval);
return NS_OK;
}
NS_IMETHODIMP
@ -367,6 +376,12 @@ DOMSVGLengthList::AppendItem(nsIDOMSVGLength *newItem,
return InsertItemBefore(newItem, Length(), _retval);
}
NS_IMETHODIMP
DOMSVGLengthList::GetLength(PRUint32 *aNumberOfItems)
{
return GetNumberOfItems(aNumberOfItems);
}
void
DOMSVGLengthList::EnsureItemAt(PRUint32 aIndex)
{

Просмотреть файл

@ -109,6 +109,8 @@ public:
return mItems.Length();
}
nsIDOMSVGLength* GetItemWithoutAddRef(PRUint32 aIndex);
/// Called to notify us to syncronize our length and detach excess items.
void InternalListLengthWillChange(PRUint32 aNewLength);

Просмотреть файл

@ -92,6 +92,21 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGNumberList)
NS_INTERFACE_MAP_END
nsIDOMSVGNumber*
DOMSVGNumberList::GetItemWithoutAddRef(PRUint32 aIndex)
{
#ifdef MOZ_SMIL
if (IsAnimValList()) {
Element()->FlushAnimations();
}
#endif
if (aIndex < Length()) {
EnsureItemAt(aIndex);
return mItems[aIndex];
}
return nsnull;
}
void
DOMSVGNumberList::InternalListLengthWillChange(PRUint32 aNewLength)
{
@ -210,18 +225,12 @@ NS_IMETHODIMP
DOMSVGNumberList::GetItem(PRUint32 index,
nsIDOMSVGNumber **_retval)
{
#ifdef MOZ_SMIL
if (IsAnimValList()) {
Element()->FlushAnimations();
*_retval = GetItemWithoutAddRef(index);
if (!*_retval) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
#endif
if (index < Length()) {
EnsureItemAt(index);
NS_ADDREF(*_retval = mItems[index]);
return NS_OK;
}
*_retval = nsnull;
return NS_ERROR_DOM_INDEX_SIZE_ERR;
NS_ADDREF(*_retval);
return NS_OK;
}
NS_IMETHODIMP
@ -367,6 +376,12 @@ DOMSVGNumberList::AppendItem(nsIDOMSVGNumber *newItem,
return InsertItemBefore(newItem, Length(), _retval);
}
NS_IMETHODIMP
DOMSVGNumberList::GetLength(PRUint32 *aNumberOfItems)
{
return GetNumberOfItems(aNumberOfItems);
}
void
DOMSVGNumberList::EnsureItemAt(PRUint32 aIndex)
{

Просмотреть файл

@ -108,6 +108,8 @@ public:
return mItems.Length();
}
nsIDOMSVGNumber* GetItemWithoutAddRef(PRUint32 aIndex);
/// Called to notify us to syncronize our length and detach excess items.
void InternalListLengthWillChange(PRUint32 aNewLength);

Просмотреть файл

@ -96,6 +96,21 @@ DOMSVGPathSegList::~DOMSVGPathSegList()
sSVGPathSegListTearoffTable.RemoveTearoff(key);
}
nsIDOMSVGPathSeg*
DOMSVGPathSegList::GetItemWithoutAddRef(PRUint32 aIndex)
{
#ifdef MOZ_SMIL
if (IsAnimValList()) {
Element()->FlushAnimations();
}
#endif
if (aIndex < Length()) {
EnsureItemAt(aIndex);
return ItemAt(aIndex);
}
return nsnull;
}
void
DOMSVGPathSegList::InternalListWillChangeTo(const SVGPathData& aNewValue)
{
@ -305,18 +320,12 @@ NS_IMETHODIMP
DOMSVGPathSegList::GetItem(PRUint32 aIndex,
nsIDOMSVGPathSeg **_retval)
{
#ifdef MOZ_SMIL
if (IsAnimValList()) {
Element()->FlushAnimations();
*_retval = GetItemWithoutAddRef(aIndex);
if (!*_retval) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
#endif
if (aIndex < Length()) {
EnsureItemAt(aIndex);
NS_ADDREF(*_retval = ItemAt(aIndex));
return NS_OK;
}
*_retval = nsnull;
return NS_ERROR_DOM_INDEX_SIZE_ERR;
NS_ADDREF(*_retval);
return NS_OK;
}
NS_IMETHODIMP
@ -498,6 +507,12 @@ DOMSVGPathSegList::AppendItem(nsIDOMSVGPathSeg *aNewItem,
return InsertItemBefore(aNewItem, Length(), _retval);
}
NS_IMETHODIMP
DOMSVGPathSegList::GetLength(PRUint32 *aNumberOfItems)
{
return GetNumberOfItems(aNumberOfItems);
}
void
DOMSVGPathSegList::EnsureItemAt(PRUint32 aIndex)
{

Просмотреть файл

@ -126,6 +126,8 @@ public:
return mItems.Length();
}
nsIDOMSVGPathSeg* GetItemWithoutAddRef(PRUint32 aIndex);
/**
* WATCH OUT! If you add code to call this on a baseVal wrapper, then you
* must also call it on the animVal wrapper too if necessary!! See other

Просмотреть файл

@ -116,6 +116,21 @@ DOMSVGPointList::~DOMSVGPointList()
sSVGPointListTearoffTable.RemoveTearoff(key);
}
nsIDOMSVGPoint*
DOMSVGPointList::GetItemWithoutAddRef(PRUint32 aIndex)
{
#ifdef MOZ_SMIL
if (IsAnimValList()) {
Element()->FlushAnimations();
}
#endif
if (aIndex < Length()) {
EnsureItemAt(aIndex);
return mItems[aIndex];
}
return nsnull;
}
void
DOMSVGPointList::InternalListWillChangeTo(const SVGPointList& aNewValue)
{
@ -261,18 +276,12 @@ NS_IMETHODIMP
DOMSVGPointList::GetItem(PRUint32 aIndex,
nsIDOMSVGPoint **_retval)
{
#ifdef MOZ_SMIL
if (IsAnimValList()) {
Element()->FlushAnimations();
*_retval = GetItemWithoutAddRef(aIndex);
if (!*_retval) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
#endif
if (aIndex < Length()) {
EnsureItemAt(aIndex);
NS_ADDREF(*_retval = mItems[aIndex]);
return NS_OK;
}
*_retval = nsnull;
return NS_ERROR_DOM_INDEX_SIZE_ERR;
NS_ADDREF(*_retval);
return NS_OK;
}
NS_IMETHODIMP
@ -418,6 +427,12 @@ DOMSVGPointList::AppendItem(nsIDOMSVGPoint *aNewItem,
return InsertItemBefore(aNewItem, Length(), _retval);
}
NS_IMETHODIMP
DOMSVGPointList::GetLength(PRUint32 *aNumberOfItems)
{
return GetNumberOfItems(aNumberOfItems);
}
void
DOMSVGPointList::EnsureItemAt(PRUint32 aIndex)
{

Просмотреть файл

@ -126,6 +126,8 @@ public:
return mItems.Length();
}
nsIDOMSVGPoint* GetItemWithoutAddRef(PRUint32 aIndex);
/**
* WATCH OUT! If you add code to call this on a baseVal wrapper, then you
* must also call it on the animVal wrapper too if necessary!! See other

Просмотреть файл

@ -78,6 +78,7 @@ public:
// other methods:
nsIDOMSVGTransform* GetItemWithoutAddRef(PRInt32 index);
nsIDOMSVGTransform* ElementAt(PRInt32 index);
PRBool AppendElement(nsIDOMSVGTransform* aElement);
static already_AddRefed<nsIDOMSVGMatrix>

Просмотреть файл

@ -84,6 +84,7 @@ _TEST_FILES = \
test_SVGPathSegList.xhtml \
test_SVGStyleElement.xhtml \
test_SVGxxxList.xhtml \
test_SVGxxxListIndexing.xhtml \
test_switch.xhtml \
switch-helper.svg \
test_text.html \

Просмотреть файл

@ -0,0 +1,83 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=631437
-->
<head>
<title>Tests the array indexing and .length on SVGXXXList objects</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=631437">Mozilla Bug 631437</a>
<svg xmlns="http://www.w3.org/2000/svg" id="svg">
<text id="text" x="10 20 30" rotate="40 50 60">abcde</text>
<path id="path" d="M0,0 L100,100"/>
<polygon id="poly" points="50,50 70,70 90,50"/>
</svg>
<script type="text/javascript;version=1.8"><![CDATA[
var text = document.getElementById("text"),
path = document.getElementById("path"),
poly = document.getElementById("poly");
function CheckList(aListObject, aExpectedListLength, aListDescription)
{
is(aListObject.numberOfItems, aExpectedListLength, aListDescription + ".numberOfItems");
is(aListObject.numberOfItems, aExpectedListLength, aListDescription + ".length");
for (let i = 0; i < aListObject.length; i++) {
let item = aListObject.getItem(i);
ok(aListObject[i] === item, aListDescription + "[" + i + "]");
}
ok(aListObject[aListObject.length] === void 0, aListDescription + "[outOfBounds]");
}
var tests = [
{ element: text,
attribute: "x",
listProperty: "x.baseVal",
type: "SVGLengthList",
subtests: [ { values: null, length: 3 },
{ values: "40", length: 1 },
{ values: "1em 2em 3em 4em 5em", length: 5 } ] },
{ element: text,
attribute: "rotate",
listProperty: "rotate.baseVal",
type: "SVGNumberList",
subtests: [ { values: null, length: 3 },
{ values: "10", length: 1 },
{ values: "1 2 3 4 5", length: 5 } ] },
{ element: path,
attribute: "d",
listProperty: "pathSegList",
type: "SVGPathSegList",
subtests: [ { values: null, length: 2 },
{ values: "M50,50", length: 1 },
{ values: "M0,0 h10 v20 h30 v40", length: 5 } ] },
{ element: poly,
attribute: "points",
listProperty: "animatedPoints",
type: "SVGPointList",
subtests: [ { values: null, length: 3 },
{ values: "100,100", length: 1 },
{ values: "0,0 10,10 20,0 30,10 40,0", length: 5 } ] }
];
for each (let test in tests) {
let list = test.element;
for each (let property in test.listProperty.split(".")) {
list = list[property];
}
for each (let subtest in test.subtests) {
if (subtest.values) {
test.element.setAttribute(test.attribute, subtest.values);
}
CheckList(list, subtest.length,
test.type + ": " + test.element.localName + "." +
test.listProperty);
}
}
]]></script>
</body>
</html>

Просмотреть файл

@ -359,7 +359,6 @@
#include "nsIDOMXPathNSResolver.h"
#include "nsIDOMXPathResult.h"
#ifdef MOZ_SVG
#include "nsIDOMGetSVGDocument.h"
#include "nsIDOMSVGAElement.h"
#include "nsIDOMSVGAltGlyphElement.h"
@ -374,9 +373,9 @@
#include "nsIDOMSVGAnimatedNumberList.h"
#include "nsIDOMSVGAnimatedPathData.h"
#include "nsIDOMSVGAnimatedPoints.h"
#include "nsIDOMSVGAnimPresAspRatio.h"
#include "nsIDOMSVGAnimatedRect.h"
#include "nsIDOMSVGAnimatedString.h"
#include "nsIDOMSVGAnimPresAspRatio.h"
#ifdef MOZ_SMIL
#include "nsIDOMSVGAnimateElement.h"
#include "nsIDOMSVGAnimateTransformElement.h"
@ -439,12 +438,11 @@
#include "nsIDOMSVGTransformable.h"
#include "nsIDOMSVGTransformList.h"
#include "nsIDOMSVGTSpanElement.h"
#include "nsIDOMSVGUnitTypes.h"
#include "nsIDOMSVGURIReference.h"
#include "nsIDOMSVGUseElement.h"
#include "nsIDOMSVGUnitTypes.h"
#include "nsIDOMSVGZoomAndPan.h"
#include "nsIDOMSVGZoomEvent.h"
#endif // MOZ_SVG
#include "nsIDOMCanvasRenderingContext2D.h"
#include "nsIDOMWebGLRenderingContext.h"
@ -488,7 +486,10 @@
#include "nsHTMLSelectElement.h"
#include "nsHTMLLegendElement.h"
using namespace mozilla::dom;
#include "DOMSVGLengthList.h"
#include "DOMSVGNumberList.h"
#include "DOMSVGPathSegList.h"
#include "DOMSVGPointList.h"
#include "mozilla/dom/indexedDB/IDBFactory.h"
#include "mozilla/dom/indexedDB/IDBRequest.h"
@ -502,6 +503,8 @@ using namespace mozilla::dom;
#include "nsIIDBDatabaseException.h"
#include "nsIDOMEventException.h"
using namespace mozilla::dom;
static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
static const char kDOMStringBundleURL[] =
@ -991,7 +994,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(BeforeUnloadEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
#ifdef MOZ_SVG
// SVG document
NS_DEFINE_CLASSINFO_DATA(SVGDocument, nsDocumentSH,
DOCUMENT_SCRIPTABLE_FLAGS)
@ -1157,14 +1159,14 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGLength, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGLengthList, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGLengthList, nsSVGLengthListSH,
ARRAY_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGMatrix, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGNumber, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGNumberList, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGNumberList, nsSVGNumberListSH,
ARRAY_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGPathSegArcAbs, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGPathSegArcRel, nsDOMGenericSH,
@ -1199,16 +1201,16 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoVerticalRel, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGPathSegList, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGPathSegList, nsSVGPathSegListSH,
ARRAY_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGPathSegMovetoAbs, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGPathSegMovetoRel, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGPoint, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGPointList, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGPointList, nsSVGPointListSH,
ARRAY_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGPreserveAspectRatio, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGRect, nsDOMGenericSH,
@ -1219,7 +1221,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGZoomEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
#endif // MOZ_SVG
NS_DEFINE_CLASSINFO_DATA(HTMLCanvasElement, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS)
@ -1300,10 +1301,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(ClientRectList, nsClientRectListSH,
ARRAY_SCRIPTABLE_FLAGS)
#ifdef MOZ_SVG
NS_DEFINE_CLASSINFO_DATA(SVGForeignObjectElement, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS)
#endif
NS_DEFINE_CLASSINFO_DATA(XULCommandEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@ -2588,9 +2587,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_BEGIN(HTMLEmbedElement, nsIDOMHTMLEmbedElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLEmbedElement)
#ifdef MOZ_SVG
DOM_CLASSINFO_MAP_ENTRY(nsIDOMGetSVGDocument)
#endif
DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
@ -2645,9 +2642,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_BEGIN(HTMLIFrameElement, nsIDOMHTMLIFrameElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLIFrameElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHTMLFrameElement)
#ifdef MOZ_SVG
DOM_CLASSINFO_MAP_ENTRY(nsIDOMGetSVGDocument)
#endif
DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
@ -2714,9 +2709,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_BEGIN(HTMLObjectElement, nsIDOMHTMLObjectElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLObjectElement)
#ifdef MOZ_SVG
DOM_CLASSINFO_MAP_ENTRY(nsIDOMGetSVGDocument)
#endif
DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
@ -3045,7 +3038,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
#ifdef MOZ_SVG
#define DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES \
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget) \
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) \
@ -3702,7 +3694,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGZoomEvent)
DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
#endif // MOZ_SVG
DOM_CLASSINFO_MAP_BEGIN(HTMLCanvasElement, nsIDOMHTMLCanvasElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCanvasElement)
@ -3802,12 +3793,10 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
#ifdef MOZ_SVG
DOM_CLASSINFO_MAP_BEGIN(SVGForeignObjectElement, nsIDOMSVGForeignObjectElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGForeignObjectElement)
DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
#endif
DOM_CLASSINFO_MAP_BEGIN(XULCommandEvent, nsIDOMXULCommandEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULCommandEvent)
@ -7216,7 +7205,7 @@ nsNodeSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj,
// If this assertion fires the QI implementation for the object in
// question doesn't use the nsINode pointer as the nsISupports
// pointer. That must be fixed, or we'll crash...
NS_ASSERTION(node_qi == node, "Uh, fix QI!");
NS_ABORT_IF_FALSE(node_qi == node, "Uh, fix QI!");
}
#endif
@ -7753,7 +7742,7 @@ nsElementSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
// If this assertion fires the QI implementation for the object in
// question doesn't use the nsIContent pointer as the nsISupports
// pointer. That must be fixed, or we'll crash...
NS_ASSERTION(content_qi == element, "Uh, fix QI!");
NS_ABORT_IF_FALSE(content_qi == element, "Uh, fix QI!");
}
#endif
@ -7798,7 +7787,7 @@ nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
// If this assertion fires the QI implementation for the object in
// question doesn't use the nsIContent pointer as the nsISupports
// pointer. That must be fixed, or we'll crash...
NS_ASSERTION(content_qi == element, "Uh, fix QI!");
NS_ABORT_IF_FALSE(content_qi == element, "Uh, fix QI!");
}
#endif
@ -8070,7 +8059,7 @@ nsNodeListSH::GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
// If this assertion fires the QI implementation for the object in
// question doesn't use the nsINodeList pointer as the nsISupports
// pointer. That must be fixed, or we'll crash...
NS_ASSERTION(list_qi == list, "Uh, fix QI!");
NS_ABORT_IF_FALSE(list_qi == list, "Uh, fix QI!");
}
#endif
@ -8089,7 +8078,7 @@ nsNodeListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
// If this assertion fires the QI implementation for the object in
// question doesn't use the nsINodeList pointer as the nsISupports
// pointer. That must be fixed, or we'll crash...
NS_ASSERTION(list_qi == list, "Uh, fix QI!");
NS_ABORT_IF_FALSE(list_qi == list, "Uh, fix QI!");
}
#endif
@ -8252,7 +8241,7 @@ nsHTMLCollectionSH::GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
// If this assertion fires the QI implementation for the object in
// question doesn't use the nsIHTMLCollection pointer as the nsISupports
// pointer. That must be fixed, or we'll crash...
NS_ASSERTION(collection_qi == collection, "Uh, fix QI!");
NS_ABORT_IF_FALSE(collection_qi == collection, "Uh, fix QI!");
}
#endif
@ -8271,7 +8260,7 @@ nsHTMLCollectionSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
// If this assertion fires the QI implementation for the object in
// question doesn't use the nsIHTMLCollection pointer as the nsISupports
// pointer. That must be fixed, or we'll crash...
NS_ASSERTION(collection_qi == collection, "Uh, fix QI!");
NS_ABORT_IF_FALSE(collection_qi == collection, "Uh, fix QI!");
}
#endif
@ -8294,7 +8283,7 @@ nsHTMLCollectionSH::GetNamedItem(nsISupports *aNative,
// If this assertion fires the QI implementation for the object in
// question doesn't use the nsIHTMLCollection pointer as the nsISupports
// pointer. That must be fixed, or we'll crash...
NS_ASSERTION(collection_qi == collection, "Uh, fix QI!");
NS_ABORT_IF_FALSE(collection_qi == collection, "Uh, fix QI!");
}
#endif
@ -10177,7 +10166,7 @@ nsCSSRuleListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
// If this assertion fires the QI implementation for the object in
// question doesn't use the nsICSSRuleList pointer as the nsISupports
// pointer. That must be fixed, or we'll crash...
NS_ASSERTION(list_qi == list, "Uh, fix QI!");
NS_ABORT_IF_FALSE(list_qi == list, "Uh, fix QI!");
}
#endif
@ -10784,3 +10773,25 @@ nsFileListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
return list->GetItemAt(aIndex);
}
// Template for SVGXXXList helpers
template<class ListInterfaceType, class ListType> nsISupports*
nsSVGListSH<ListInterfaceType, ListType>::GetItemAt(nsISupports *aNative,
PRUint32 aIndex,
nsWrapperCache **aCache,
nsresult *aResult)
{
ListType* list = static_cast<ListType*>(static_cast<ListInterfaceType*>(aNative));
#ifdef DEBUG
{
nsCOMPtr<ListInterfaceType> list_qi = do_QueryInterface(aNative);
// If this assertion fires the QI implementation for the object in
// question doesn't use the nsIDOMSVGXXXList pointer as the nsISupports
// pointer. That must be fixed, or we'll crash...
NS_ABORT_IF_FALSE(list_qi == list, "Uh, fix QI!");
}
#endif
return list->GetItemWithoutAddRef(aIndex);
}

Просмотреть файл

@ -49,14 +49,31 @@
#include "nsIScriptGlobalObject.h"
#include "nsContentUtils.h"
class nsIDOMWindow;
class nsIDOMNSHTMLOptionCollection;
class nsIPluginInstance;
class nsIForm;
class nsIDOMNodeList;
class nsIDOMDocument;
class nsIHTMLDocument;
namespace mozilla {
class DOMSVGLengthList;
class DOMSVGNumberList;
class DOMSVGPathSegList;
class DOMSVGPointList;
}
class nsGlobalWindow;
class nsIDOMDocument;
class nsIDOMNSHTMLOptionCollection;
class nsIDOMNodeList;
class nsIDOMSVGLength;
class nsIDOMSVGLengthList;
class nsIDOMSVGNumber;
class nsIDOMSVGNumberList;
class nsIDOMSVGPathSeg;
class nsIDOMSVGPathSegList;
class nsIDOMSVGPoint;
class nsIDOMSVGPointList;
class nsIDOMSVGTransform;
class nsIDOMSVGTransformList;
class nsIDOMWindow;
class nsIForm;
class nsIHTMLDocument;
class nsIPluginInstance;
class nsSVGTransformList;
struct nsDOMClassInfoData;
@ -1839,4 +1856,30 @@ public:
}
};
// Template for SVGXXXList helpers
template<class ListInterfaceType, class ListType>
class nsSVGListSH : public nsArraySH
{
protected:
nsSVGListSH(nsDOMClassInfoData* aData) : nsArraySH(aData)
{
}
public:
virtual nsISupports* GetItemAt(nsISupports *aNative, PRUint32 aIndex,
nsWrapperCache **aCache, nsresult *aResult);
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
{
return new nsSVGListSH(aData);
}
};
typedef nsSVGListSH<nsIDOMSVGLengthList, mozilla::DOMSVGLengthList> nsSVGLengthListSH;
typedef nsSVGListSH<nsIDOMSVGNumberList, mozilla::DOMSVGNumberList> nsSVGNumberListSH;
typedef nsSVGListSH<nsIDOMSVGPathSegList, mozilla::DOMSVGPathSegList> nsSVGPathSegListSH;
typedef nsSVGListSH<nsIDOMSVGPointList, mozilla::DOMSVGPointList> nsSVGPointListSH;
#endif /* nsDOMClassInfo_h___ */

Просмотреть файл

@ -14,6 +14,7 @@ DOM_SRCDIRS = \
content/base/src \
content/html/content/src \
content/html/document/src \
content/svg/content/src \
layout/generic \
layout/style \
layout/xul/base/src \

Просмотреть файл

@ -40,10 +40,11 @@
interface nsIDOMSVGLength;
[scriptable, uuid(a8760fcd-3de5-446a-a009-5cf877e7a4df)]
[scriptable, uuid(f8c89734-d6b4-4a56-bdf5-1ce1104dc1ab)]
interface nsIDOMSVGLengthList : nsISupports
{
readonly attribute unsigned long numberOfItems;
readonly attribute unsigned long length; // synonym for numberOfItems
void clear();
// raises(nsIDOMDOMException);
@ -60,4 +61,3 @@ interface nsIDOMSVGLengthList : nsISupports
nsIDOMSVGLength appendItem(in nsIDOMSVGLength newItem);
// raises(nsIDOMDOMException, nsIDOMSVGException);
};

Просмотреть файл

@ -40,10 +40,11 @@
interface nsIDOMSVGNumber;
[scriptable, uuid(59364ec4-faf1-460f-bf58-e6a6a2769a3a)]
[scriptable, uuid(8e303812-38b4-4780-9f8c-9ddbfcb26c81)]
interface nsIDOMSVGNumberList : nsISupports
{
readonly attribute unsigned long numberOfItems;
readonly attribute unsigned long length; // synonym for numberOfItems
void clear();
// raises(nsIDOMDOMException);
@ -60,4 +61,3 @@ interface nsIDOMSVGNumberList : nsISupports
nsIDOMSVGNumber appendItem(in nsIDOMSVGNumber newItem);
// raises(nsIDOMDOMException, nsIDOMSVGException);
};

Просмотреть файл

@ -40,10 +40,11 @@
interface nsIDOMSVGPathSeg;
[scriptable, uuid(94a6db98-3f34-4529-a35f-89ef49713795)]
[scriptable, uuid(1e4efb5c-7b0f-4338-a92e-6ca5402b303c)]
interface nsIDOMSVGPathSegList : nsISupports
{
readonly attribute unsigned long numberOfItems;
readonly attribute unsigned long length; // synonym for numberOfItems
void clear();
// raises(nsIDOMDOMException);
@ -60,4 +61,3 @@ interface nsIDOMSVGPathSegList : nsISupports
nsIDOMSVGPathSeg appendItem(in nsIDOMSVGPathSeg newItem);
// raises(nsIDOMDOMException, nsIDOMSVGException);
};

Просмотреть файл

@ -40,10 +40,11 @@
interface nsIDOMSVGPoint;
[scriptable, uuid(4c12af24-0fc2-4fe7-b71d-5d6b41d463c1)]
[scriptable, uuid(7bb28750-7238-4083-b5f4-4def4646a637)]
interface nsIDOMSVGPointList : nsISupports
{
readonly attribute unsigned long numberOfItems;
readonly attribute unsigned long length; // synonym for numberOfItems
void clear();
// raises( DOMException );