From 9a86a33fe8c313cdc05a66cccd8692c64d63862a Mon Sep 17 00:00:00 2001 From: "vidur%netscape.com" Date: Tue, 27 Apr 1999 22:15:32 +0000 Subject: [PATCH] Added nsIDOMNSRange method with InsertFragment method. --- dom/public/idl/range/Range.idl | 6 ++++ dom/public/range/MANIFEST | 1 + dom/public/range/Makefile.in | 1 + dom/public/range/makefile.win | 5 ++-- dom/public/range/nsIDOMNSRange.h | 49 ++++++++++++++++++++++++++++++++ dom/src/range/nsJSRange.cpp | 46 ++++++++++++++++++++++++++++++ 6 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 dom/public/range/nsIDOMNSRange.h diff --git a/dom/public/idl/range/Range.idl b/dom/public/idl/range/Range.idl index 982c577e2f95..02ab93242703 100644 --- a/dom/public/idl/range/Range.idl +++ b/dom/public/idl/range/Range.idl @@ -41,3 +41,9 @@ interface Range { DOMString toString(); }; + +interface NSRange { + /* IID: { 0xa6cf90f2, 0x15b3, 0x11d2, \ + { 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } */ + void insertFragment(in DOMString fragment); + }; diff --git a/dom/public/range/MANIFEST b/dom/public/range/MANIFEST index 15bc7a985564..423253f80f3d 100644 --- a/dom/public/range/MANIFEST +++ b/dom/public/range/MANIFEST @@ -17,5 +17,6 @@ # nsIDOMRange.h +nsIDOMNSRange.h nsIDOMSelection.h nsIDOMSelectionListener.h diff --git a/dom/public/range/Makefile.in b/dom/public/range/Makefile.in index fdc7a77d3289..835a0a000903 100644 --- a/dom/public/range/Makefile.in +++ b/dom/public/range/Makefile.in @@ -26,6 +26,7 @@ DEFINES += -D_IMPL_NS_DOM EXPORTS = \ nsIDOMRange.h \ + nsIDOMNSRange.h \ nsIDOMSelection.h \ nsIDOMSelectionListener.h \ $(NULL) diff --git a/dom/public/range/makefile.win b/dom/public/range/makefile.win index df031648b092..2bcebe96d87a 100644 --- a/dom/public/range/makefile.win +++ b/dom/public/range/makefile.win @@ -20,8 +20,9 @@ IGNORE_MANIFEST=1 DEFINES=-D_IMPL_NS_DOM EXPORTS = \ - nsIDOMRange.h \ - nsIDOMSelection.h \ + nsIDOMRange.h \ + nsIDOMNSRange.h \ + nsIDOMSelection.h \ nsIDOMSelectionListener.h \ $(NULL) diff --git a/dom/public/range/nsIDOMNSRange.h b/dom/public/range/nsIDOMNSRange.h new file mode 100644 index 000000000000..5fe0d2c5c843 --- /dev/null +++ b/dom/public/range/nsIDOMNSRange.h @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ +/* AUTO-GENERATED. DO NOT EDIT!!! */ + +#ifndef nsIDOMNSRange_h__ +#define nsIDOMNSRange_h__ + +#include "nsISupports.h" +#include "nsString.h" +#include "nsIScriptContext.h" + + +#define NS_IDOMNSRANGE_IID \ + { 0xa6cf90f2, 0x15b3, 0x11d2, \ + { 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } + +class nsIDOMNSRange : public nsISupports { +public: + static const nsIID& GetIID() { static nsIID iid = NS_IDOMNSRANGE_IID; return iid; } + + NS_IMETHOD InsertFragment(const nsString& aFragment)=0; +}; + + +#define NS_DECL_IDOMNSRANGE \ + NS_IMETHOD InsertFragment(const nsString& aFragment); \ + + + +#define NS_FORWARD_IDOMNSRANGE(_to) \ + NS_IMETHOD InsertFragment(const nsString& aFragment) { return _to InsertFragment(aFragment); } \ + + +#endif // nsIDOMNSRange_h__ diff --git a/dom/src/range/nsJSRange.cpp b/dom/src/range/nsJSRange.cpp index 8d3f424af4ce..ce009fa73a39 100644 --- a/dom/src/range/nsJSRange.cpp +++ b/dom/src/range/nsJSRange.cpp @@ -27,6 +27,7 @@ #include "nsIPtr.h" #include "nsString.h" #include "nsIDOMNode.h" +#include "nsIDOMNSRange.h" #include "nsIDOMDocumentFragment.h" #include "nsIDOMRange.h" @@ -35,10 +36,12 @@ static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID); static NS_DEFINE_IID(kINodeIID, NS_IDOMNODE_IID); +static NS_DEFINE_IID(kINSRangeIID, NS_IDOMNSRANGE_IID); static NS_DEFINE_IID(kIDocumentFragmentIID, NS_IDOMDOCUMENTFRAGMENT_IID); static NS_DEFINE_IID(kIRangeIID, NS_IDOMRANGE_IID); NS_DEF_PTR(nsIDOMNode); +NS_DEF_PTR(nsIDOMNSRange); NS_DEF_PTR(nsIDOMDocumentFragment); NS_DEF_PTR(nsIDOMRange); @@ -897,6 +900,48 @@ RangeToString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval } +// +// Native method InsertFragment +// +PR_STATIC_CALLBACK(JSBool) +NSRangeInsertFragment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMRange *privateThis = (nsIDOMRange*)JS_GetPrivate(cx, obj); + nsIDOMNSRange *nativeThis = nsnull; + if (NS_OK != privateThis->QueryInterface(kINSRangeIID, (void **)&nativeThis)) { + JS_ReportError(cx, "Object must be of type NSRange"); + return JS_FALSE; + } + + JSBool rBool = JS_FALSE; + nsAutoString b0; + + *rval = JSVAL_NULL; + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == nativeThis) { + return JS_TRUE; + } + + if (argc >= 1) { + + nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]); + + if (NS_OK != nativeThis->InsertFragment(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function insertFragment requires 1 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + /***********************************************************************/ // // class for Range @@ -952,6 +997,7 @@ static JSFunctionSpec RangeMethods[] = {"surroundContents", RangeSurroundContents, 1}, {"clone", RangeClone, 0}, {"toString", RangeToString, 0}, + {"insertFragment", NSRangeInsertFragment, 1}, {0} };