зеркало из https://github.com/mozilla/pjs.git
Adding public routine ComparePoints for mjudge
This commit is contained in:
Родитель
bda828779a
Коммит
afa58600ae
|
@ -192,6 +192,31 @@ nsresult nsRange::QueryInterface(const nsIID& aIID,
|
|||
}
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Public helper routines
|
||||
******************************************************/
|
||||
|
||||
//
|
||||
// Returns -1 if point1 < point2, 1, if point1 > point2,
|
||||
// 0 if error or if point1 == point2.
|
||||
//
|
||||
PRInt32 ComparePoints(nsIDOMNode* aParent1, PRInt32 aOffset1,
|
||||
nsIDOMNode* aParent2, PRInt32 aOffset2)
|
||||
{
|
||||
if (aParent1 == aParent2 && aOffset1 == aOffset2)
|
||||
return 0;
|
||||
nsRange* range = new nsRange;
|
||||
nsresult res = range->SetStart(aParent1, aOffset1);
|
||||
if (!NS_SUCCEEDED(res))
|
||||
return 0;
|
||||
res = range->SetEnd(aParent2, aOffset2);
|
||||
delete range;
|
||||
if (NS_SUCCEEDED(res))
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
/******************************************************
|
||||
* Private helper routines
|
||||
******************************************************/
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/* -*- 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* nsRange.h : Useful routines for users of nsRange objects.
|
||||
* This doesn't include the definition of the nsRange class itself,
|
||||
* since range users should always get their ranges via nsIDOMRange.
|
||||
*/
|
||||
|
||||
PRInt32 ComparePoints(nsIDOMNode* aParent1, PRInt32 aOffset1,
|
||||
nsIDOMNode* aParent2, PRInt32 aOffset2);
|
|
@ -192,6 +192,31 @@ nsresult nsRange::QueryInterface(const nsIID& aIID,
|
|||
}
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Public helper routines
|
||||
******************************************************/
|
||||
|
||||
//
|
||||
// Returns -1 if point1 < point2, 1, if point1 > point2,
|
||||
// 0 if error or if point1 == point2.
|
||||
//
|
||||
PRInt32 ComparePoints(nsIDOMNode* aParent1, PRInt32 aOffset1,
|
||||
nsIDOMNode* aParent2, PRInt32 aOffset2)
|
||||
{
|
||||
if (aParent1 == aParent2 && aOffset1 == aOffset2)
|
||||
return 0;
|
||||
nsRange* range = new nsRange;
|
||||
nsresult res = range->SetStart(aParent1, aOffset1);
|
||||
if (!NS_SUCCEEDED(res))
|
||||
return 0;
|
||||
res = range->SetEnd(aParent2, aOffset2);
|
||||
delete range;
|
||||
if (NS_SUCCEEDED(res))
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
/******************************************************
|
||||
* Private helper routines
|
||||
******************************************************/
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/* -*- 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* nsRange.h : Useful routines for users of nsRange objects.
|
||||
* This doesn't include the definition of the nsRange class itself,
|
||||
* since range users should always get their ranges via nsIDOMRange.
|
||||
*/
|
||||
|
||||
PRInt32 ComparePoints(nsIDOMNode* aParent1, PRInt32 aOffset1,
|
||||
nsIDOMNode* aParent2, PRInt32 aOffset2);
|
Загрузка…
Ссылка в новой задаче