From daa208b89676765684cc50d800268e539a4254a8 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Thu, 1 Mar 2012 13:35:48 -0500 Subject: [PATCH] Bug 711047 Part 2 - Remove RangeException in favor of DOMException. r=sicking --- content/base/src/nsRange.cpp | 24 ++++----- content/base/test/Makefile.in | 1 + content/base/test/test_bug454326.html | 9 ++-- content/base/test/test_bug711047.html | 16 ++++++ dom/base/domerr.msg | 5 -- dom/base/nsDOMClassInfo.cpp | 9 ---- dom/base/nsDOMClassInfoClasses.h | 2 - dom/base/nsDOMError.h | 5 -- dom/base/nsDOMException.cpp | 18 ------- dom/base/nsDOMException.h | 1 - dom/base/nsDOMScriptObjectFactory.cpp | 5 -- dom/interfaces/base/domstubs.idl | 1 - dom/interfaces/range/Makefile.in | 4 -- dom/interfaces/range/nsIDOMRangeException.idl | 54 ------------------- xpcom/base/nsError.h | 2 +- 15 files changed, 36 insertions(+), 120 deletions(-) create mode 100644 content/base/test/test_bug711047.html delete mode 100644 dom/interfaces/range/nsIDOMRangeException.idl diff --git a/content/base/src/nsRange.cpp b/content/base/src/nsRange.cpp index b299053e5e6..5836ee1a6d8 100644 --- a/content/base/src/nsRange.cpp +++ b/content/base/src/nsRange.cpp @@ -928,7 +928,7 @@ nsRange::SetStart(nsIDOMNode* aParent, PRInt32 aOffset) nsRange::SetStart(nsINode* aParent, PRInt32 aOffset) { nsINode* newRoot = IsValidBoundary(aParent); - NS_ENSURE_TRUE(newRoot, NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR); + NS_ENSURE_TRUE(newRoot, NS_ERROR_DOM_INVALID_NODE_TYPE_ERR); PRInt32 len = GetNodeLength(aParent); if (aOffset < 0 || aOffset > len) @@ -957,7 +957,7 @@ nsRange::SetStartBefore(nsIDOMNode* aSibling) nsCOMPtr parent; nsresult rv = aSibling->GetParentNode(getter_AddRefs(parent)); if (NS_FAILED(rv) || !parent) { - return NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR; + return NS_ERROR_DOM_INVALID_NODE_TYPE_ERR; } return SetStart(parent, IndexOf(aSibling)); @@ -971,7 +971,7 @@ nsRange::SetStartAfter(nsIDOMNode* aSibling) nsCOMPtr nParent; nsresult res = aSibling->GetParentNode(getter_AddRefs(nParent)); if (NS_FAILED(res) || !nParent) { - return NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR; + return NS_ERROR_DOM_INVALID_NODE_TYPE_ERR; } return SetStart(nParent, IndexOf(aSibling) + 1); @@ -992,7 +992,7 @@ nsRange::SetEnd(nsIDOMNode* aParent, PRInt32 aOffset) nsRange::SetEnd(nsINode* aParent, PRInt32 aOffset) { nsINode* newRoot = IsValidBoundary(aParent); - NS_ENSURE_TRUE(newRoot, NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR); + NS_ENSURE_TRUE(newRoot, NS_ERROR_DOM_INVALID_NODE_TYPE_ERR); PRInt32 len = GetNodeLength(aParent); if (aOffset < 0 || aOffset > len) { @@ -1022,7 +1022,7 @@ nsRange::SetEndBefore(nsIDOMNode* aSibling) nsCOMPtr nParent; nsresult rv = aSibling->GetParentNode(getter_AddRefs(nParent)); if (NS_FAILED(rv) || !nParent) { - return NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR; + return NS_ERROR_DOM_INVALID_NODE_TYPE_ERR; } return SetEnd(nParent, IndexOf(aSibling)); @@ -1036,7 +1036,7 @@ nsRange::SetEndAfter(nsIDOMNode* aSibling) nsCOMPtr nParent; nsresult res = aSibling->GetParentNode(getter_AddRefs(nParent)); if (NS_FAILED(res) || !nParent) { - return NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR; + return NS_ERROR_DOM_INVALID_NODE_TYPE_ERR; } return SetEnd(nParent, IndexOf(aSibling) + 1); @@ -1065,15 +1065,15 @@ nsRange::SelectNode(nsIDOMNode* aN) VALIDATE_ACCESS(aN); nsCOMPtr node = do_QueryInterface(aN); - NS_ENSURE_TRUE(node, NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR); + NS_ENSURE_TRUE(node, NS_ERROR_DOM_INVALID_NODE_TYPE_ERR); nsINode* parent = node->GetNodeParent(); nsINode* newRoot = IsValidBoundary(parent); - NS_ENSURE_TRUE(newRoot, NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR); + NS_ENSURE_TRUE(newRoot, NS_ERROR_DOM_INVALID_NODE_TYPE_ERR); PRInt32 index = parent->IndexOf(node); if (index < 0) { - return NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR; + return NS_ERROR_DOM_INVALID_NODE_TYPE_ERR; } AutoInvalidateSelection atEndOfBlock(this); @@ -1089,7 +1089,7 @@ nsRange::SelectNodeContents(nsIDOMNode* aN) nsCOMPtr node = do_QueryInterface(aN); nsINode* newRoot = IsValidBoundary(node); - NS_ENSURE_TRUE(newRoot, NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR); + NS_ENSURE_TRUE(newRoot, NS_ERROR_DOM_INVALID_NODE_TYPE_ERR); AutoInvalidateSelection atEndOfBlock(this); DoSetRange(node, 0, node, GetNodeLength(node), newRoot); @@ -2144,7 +2144,7 @@ nsRange::SurroundContents(nsIDOMNode* aNewParent) VALIDATE_ACCESS(aNewParent); NS_ENSURE_TRUE(mRoot, NS_ERROR_DOM_INVALID_STATE_ERR); - // BAD_BOUNDARYPOINTS_ERR: Raised if the Range partially selects a non-text + // INVALID_STATE_ERROR: Raised if the Range partially selects a non-text // node. if (mStartParent != mEndParent) { bool startIsText = mStartParent->IsNodeOfType(nsINode::eTEXT); @@ -2160,7 +2160,7 @@ nsRange::SurroundContents(nsIDOMNode* aNewParent) (endIsText && endGrandParent && endGrandParent == mStartParent), - NS_ERROR_DOM_RANGE_BAD_BOUNDARYPOINTS_ERR); + NS_ERROR_DOM_INVALID_STATE_ERR); } // Extract the contents within the range. diff --git a/content/base/test/Makefile.in b/content/base/test/Makefile.in index 7070f64e1f0..a97f7a6e49d 100644 --- a/content/base/test/Makefile.in +++ b/content/base/test/Makefile.in @@ -561,6 +561,7 @@ _TEST_FILES2 = \ file_bug717511_2.html^headers^ \ test_bug726364.html \ test_bug698381.html \ + test_bug711047.html \ $(NULL) _CHROME_FILES = \ diff --git a/content/base/test/test_bug454326.html b/content/base/test/test_bug454326.html index af80b2a4bce..070e9d54216 100644 --- a/content/base/test/test_bug454326.html +++ b/content/base/test/test_bug454326.html @@ -84,7 +84,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=454326 is(r3.toString(), "Hello ", "Wrong range!"); } catch(e) { ex = e; - is(e.code, 1, "Didn't get BAD_BOUNDARYPOINTS_ERR exception!"); + is(Object.getPrototypeOf(e), DOMException.prototype, "Didn't get DOMException!"); + is(e.code, 11, "Didn't get INVALID_STATE_ERR exception!"); } ok(ex, "There should have been an exception!"); @@ -99,7 +100,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=454326 is(r3.toString(), "World!", "Wrong range!"); } catch(e) { ex = e; - is(e.code, 1, "Didn't get BAD_BOUNDARYPOINTS_ERR exception!"); + is(Object.getPrototypeOf(e), DOMException.prototype, "Didn't get DOMException!"); + is(e.code, 11, "Didn't get INVALID_STATE_ERR exception!"); } ok(ex, "There should have been an exception!"); @@ -114,7 +116,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=454326 is(r4.toString(), "Hello World!", "Wrong range!"); } catch(e) { ex = e; - is(e.code, 1, "Didn't get BAD_BOUNDARYPOINTS_ERR exception!"); + is(Object.getPrototypeOf(e), DOMException.prototype, "Didn't get DOMException!"); + is(e.code, 11, "Didn't get INVALID_STATE_ERR exception!"); } ok(ex, "There should have been an exception!"); } diff --git a/content/base/test/test_bug711047.html b/content/base/test/test_bug711047.html new file mode 100644 index 00000000000..65bc20c35ff --- /dev/null +++ b/content/base/test/test_bug711047.html @@ -0,0 +1,16 @@ + + +Test for Bug 711047 + + +Mozilla Bug 711047 +
+
+
+
+
diff --git a/dom/base/domerr.msg b/dom/base/domerr.msg index 15773986b24..10727e91320 100644 --- a/dom/base/domerr.msg +++ b/dom/base/domerr.msg @@ -66,11 +66,6 @@ DOM_MSG_DEF_(TIMEOUT_ERR, "TimeoutError", "The operation timed out.") DOM_MSG_DEF_(INVALID_NODE_TYPE_ERR, "InvalidNodeTypeError", "The supplied node is incorrect or has an incorrect ancestor for this operation.") DOM_MSG_DEF_(DATA_CLONE_ERR, "DataCloneError", "The object could not be cloned.") -/* DOM error codes from http://www.w3.org/TR/DOM-Level-2/range.html */ - -DOM_MSG_DEF(NS_ERROR_DOM_RANGE_BAD_BOUNDARYPOINTS_ERR, "The boundary-points of a range does not meet specific requirements.") -DOM_MSG_DEF(NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR, "The container of an boundary-point of a range is being set to either a node of an invalid type or a node with an ancestor of an invalid type.") - /* SVG DOM error codes from http://www.w3.org/TR/SVG11/svgdom.html */ DOM_MSG_DEF(NS_ERROR_DOM_SVG_WRONG_TYPE_ERR, "Unknown or invalid type") diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index e61de3c3508..ecbde6f25f5 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -321,7 +321,6 @@ #include "nsIDOMDeviceOrientationEvent.h" #include "nsIDOMDeviceMotionEvent.h" #include "nsIDOMRange.h" -#include "nsIDOMRangeException.h" #include "nsIDOMNodeIterator.h" #include "nsIDOMTreeWalker.h" #include "nsIDOMXULDocument.h" @@ -1024,9 +1023,6 @@ static nsDOMClassInfoData sClassInfoData[] = { NS_DEFINE_CLASSINFO_DATA(CSSRGBColor, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA(RangeException, nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA(CSSValueList, nsCSSValueListSH, ARRAY_SCRIPTABLE_FLAGS) @@ -3099,11 +3095,6 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsIDOMChromeWindow) DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(RangeException, nsIDOMRangeException) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMRangeException) - DOM_CLASSINFO_MAP_ENTRY(nsIException) - DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ContentList, nsIDOMHTMLCollection) DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeList) DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCollection) diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index dcf073032aa..37d56358bec 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -197,8 +197,6 @@ DOMCI_CLASS(ChromeWindow) // RGBColor object used by getComputedStyle DOMCI_CLASS(CSSRGBColor) -DOMCI_CLASS(RangeException) - // CSSValueList object that represents an nsIDOMCSSValueList, used // by DOM CSS DOMCI_CLASS(CSSValueList) diff --git a/dom/base/nsDOMError.h b/dom/base/nsDOMError.h index 24e99017002..c2018359a30 100644 --- a/dom/base/nsDOMError.h +++ b/dom/base/nsDOMError.h @@ -71,11 +71,6 @@ #define NS_ERROR_DOM_INVALID_NODE_TYPE_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,24) #define NS_ERROR_DOM_DATA_CLONE_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,25) -/* DOM error codes from http://www.w3.org/TR/DOM-Level-2/range.html */ - -#define NS_ERROR_DOM_RANGE_BAD_BOUNDARYPOINTS_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_RANGE, 1) -#define NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_RANGE, 2) - /* SVG DOM error codes from http://www.w3.org/TR/SVG11/svgdom.html */ #define NS_ERROR_DOM_SVG_WRONG_TYPE_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_SVG,0) diff --git a/dom/base/nsDOMException.cpp b/dom/base/nsDOMException.cpp index da2a975b3e8..742f5200c39 100644 --- a/dom/base/nsDOMException.cpp +++ b/dom/base/nsDOMException.cpp @@ -42,7 +42,6 @@ #include "nsDOMError.h" #include "nsDOMException.h" #include "nsIDOMDOMException.h" -#include "nsIDOMRangeException.h" #include "nsIDOMFileException.h" #include "nsIDOMSVGException.h" #include "nsIDOMXPathException.h" @@ -169,23 +168,6 @@ nsDOMException::GetCode(PRUint16* aCode) return NS_OK; } -IMPL_INTERNAL_DOM_EXCEPTION_HEAD(nsRangeException, nsIDOMRangeException) - NS_DECL_NSIDOMRANGEEXCEPTION -IMPL_INTERNAL_DOM_EXCEPTION_TAIL(nsRangeException, nsIDOMRangeException, - RangeException, NS_ERROR_MODULE_DOM_RANGE, - NSResultToNameAndMessage) - -NS_IMETHODIMP -nsRangeException::GetCode(PRUint16* aCode) -{ - NS_ENSURE_ARG_POINTER(aCode); - nsresult result; - GetResult(&result); - *aCode = NS_ERROR_GET_CODE(result); - - return NS_OK; -} - IMPL_INTERNAL_DOM_EXCEPTION_HEAD(nsSVGException, nsIDOMSVGException) NS_DECL_NSIDOMSVGEXCEPTION IMPL_INTERNAL_DOM_EXCEPTION_TAIL(nsSVGException, nsIDOMSVGException, diff --git a/dom/base/nsDOMException.h b/dom/base/nsDOMException.h index d92388f7a6b..a1d376b3c41 100644 --- a/dom/base/nsDOMException.h +++ b/dom/base/nsDOMException.h @@ -72,7 +72,6 @@ NS_New##domname(nsresult aNSResult, nsIException* aDefaultException, \ DECL_INTERNAL_DOM_EXCEPTION(DOMException) -DECL_INTERNAL_DOM_EXCEPTION(RangeException) DECL_INTERNAL_DOM_EXCEPTION(SVGException) DECL_INTERNAL_DOM_EXCEPTION(XPathException) DECL_INTERNAL_DOM_EXCEPTION(FileException) diff --git a/dom/base/nsDOMScriptObjectFactory.cpp b/dom/base/nsDOMScriptObjectFactory.cpp index 20e6459d881..d89912092f5 100644 --- a/dom/base/nsDOMScriptObjectFactory.cpp +++ b/dom/base/nsDOMScriptObjectFactory.cpp @@ -87,7 +87,6 @@ nsDOMScriptObjectFactory::nsDOMScriptObjectFactory() : if (xs) { xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM); - xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM_RANGE); xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_SVG); xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM_XPATH); xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM_INDEXEDDB); @@ -287,8 +286,6 @@ nsDOMScriptObjectFactory::Observe(nsISupports *aSubject, if (xs) { xs->UnregisterExceptionProvider(gExceptionProvider, NS_ERROR_MODULE_DOM); - xs->UnregisterExceptionProvider(gExceptionProvider, - NS_ERROR_MODULE_DOM_RANGE); xs->UnregisterExceptionProvider(gExceptionProvider, NS_ERROR_MODULE_SVG); xs->UnregisterExceptionProvider(gExceptionProvider, @@ -386,8 +383,6 @@ nsDOMExceptionProvider::GetException(nsresult result, switch (NS_ERROR_GET_MODULE(result)) { - case NS_ERROR_MODULE_DOM_RANGE: - return NS_NewRangeException(result, aDefaultException, _retval); case NS_ERROR_MODULE_SVG: return NS_NewSVGException(result, aDefaultException, _retval); case NS_ERROR_MODULE_DOM_XPATH: diff --git a/dom/interfaces/base/domstubs.idl b/dom/interfaces/base/domstubs.idl index f24d2bb3daa..0505386a715 100644 --- a/dom/interfaces/base/domstubs.idl +++ b/dom/interfaces/base/domstubs.idl @@ -70,7 +70,6 @@ interface nsIDOMClientRectList; // Needed for raises() in our IDL interface DOMException; -interface RangeException; // Style Sheets interface nsIDOMStyleSheetList; diff --git a/dom/interfaces/range/Makefile.in b/dom/interfaces/range/Makefile.in index 5929384ac21..39c4839ed02 100644 --- a/dom/interfaces/range/Makefile.in +++ b/dom/interfaces/range/Makefile.in @@ -50,8 +50,4 @@ SDK_XPIDLSRCS = \ nsIDOMRange.idl \ $(NULL) -XPIDLSRCS = \ - nsIDOMRangeException.idl \ - $(NULL) - include $(topsrcdir)/config/rules.mk diff --git a/dom/interfaces/range/nsIDOMRangeException.idl b/dom/interfaces/range/nsIDOMRangeException.idl deleted file mode 100644 index 9840f8207d4..00000000000 --- a/dom/interfaces/range/nsIDOMRangeException.idl +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: IDL; 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.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Peter Van der Beken (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 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 ***** */ - -/* - * The complete Range spec is located at: - * http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html - */ - -#include "nsISupports.idl" - -[scriptable, uuid(0f807301-39d2-11d6-a7f2-8f504ff870dc)] -interface nsIDOMRangeException : nsISupports -{ - const unsigned short BAD_BOUNDARYPOINTS_ERR = 1; - const unsigned short INVALID_NODE_TYPE_ERR = 2; - - readonly attribute unsigned short code; -}; diff --git a/xpcom/base/nsError.h b/xpcom/base/nsError.h index a51d5b44b34..c6d866bdecc 100644 --- a/xpcom/base/nsError.h +++ b/xpcom/base/nsError.h @@ -87,7 +87,7 @@ #define NS_ERROR_MODULE_LDAP 20 #define NS_ERROR_MODULE_SECURITY 21 #define NS_ERROR_MODULE_DOM_XPATH 22 -#define NS_ERROR_MODULE_DOM_RANGE 23 +// 23 used to be NS_ERROR_MODULE_DOM_RANGE (see bug 711047) #define NS_ERROR_MODULE_URILOADER 24 #define NS_ERROR_MODULE_CONTENT 25 #define NS_ERROR_MODULE_PYXPCOM 26