Bug 711047 Part 2 - Remove RangeException in favor of DOMException. r=sicking

This commit is contained in:
Aryeh Gregor 2012-03-01 13:35:48 -05:00
parent 9bb9053585
commit 88c8133b31
15 changed files with 36 additions and 120 deletions

View File

@ -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<nsIDOMNode> 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<nsIDOMNode> 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<nsIDOMNode> 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<nsIDOMNode> 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<nsINode> 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<nsINode> 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.

View File

@ -561,6 +561,7 @@ _TEST_FILES2 = \
file_bug717511_2.html^headers^ \
test_bug726364.html \
test_bug698381.html \
test_bug711047.html \
$(NULL)
_CHROME_FILES = \

View File

@ -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!");
}

View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=711047
-->
<title>Test for Bug 711047</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=711047">Mozilla Bug 711047</a>
<div id="content">
</div>
<pre id="test">
<script>
/** Test for Bug 711047 **/
ok(!("RangeException" in window), "RangeException shouldn't exist");
</script>
</pre>

View File

@ -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")

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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,

View File

@ -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)

View File

@ -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:

View File

@ -70,7 +70,6 @@ interface nsIDOMClientRectList;
// Needed for raises() in our IDL
interface DOMException;
interface RangeException;
// Style Sheets
interface nsIDOMStyleSheetList;

View File

@ -50,8 +50,4 @@ SDK_XPIDLSRCS = \
nsIDOMRange.idl \
$(NULL)
XPIDLSRCS = \
nsIDOMRangeException.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -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 <peterv@netscape.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 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;
};

View File

@ -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