Bug 579638 - Reinstate Range.intersectsNode; r=smaug

This commit is contained in:
Ms2ger 2012-07-18 12:36:08 +02:00
Родитель 42a55f1a28
Коммит cbdc7a3775
4 изменённых файлов: 48 добавлений и 2248 удалений

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

@ -649,7 +649,47 @@ nsRange::ComparePoint(nsIDOMNode* aParent, PRInt32 aOffset, PRInt16* aResult)
return NS_OK;
}
NS_IMETHODIMP
nsRange::IntersectsNode(nsIDOMNode* aNode, bool* aResult)
{
*aResult = false;
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
// TODO: This should throw a TypeError.
NS_ENSURE_ARG(node);
NS_ENSURE_TRUE(mIsPositioned, NS_ERROR_NOT_INITIALIZED);
// Step 3.
nsINode* parent = node->GetNodeParent();
if (!parent) {
// Steps 2 and 4.
// |parent| is null, so |node|'s root is |node| itself.
*aResult = (GetRoot() == node);
return NS_OK;
}
// Step 5.
PRInt32 nodeIndex = parent->IndexOf(node);
// Steps 6-7.
// Note: if disconnected is true, ComparePoints returns 1.
bool disconnected = false;
*aResult = nsContentUtils::ComparePoints(mStartParent, mStartOffset,
parent, nodeIndex + 1,
&disconnected) < 0 &&
nsContentUtils::ComparePoints(parent, nodeIndex,
mEndParent, mEndOffset,
&disconnected) < 0;
// Step 2.
if (disconnected) {
*aResult = false;
}
return NS_OK;
}
/******************************************************
* Private helper routines
******************************************************/

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -378,7 +378,6 @@
"Range interface: attribute endOffset": true,
"Range interface: attribute collapsed": true,
"Range interface: attribute commonAncestorContainer": true,
"Range interface: operation intersectsNode(Node)": true,
"Range interface: calling setStart(Node,unsigned long) on document.createRange() with too few arguments must throw TypeError": true,
"Range interface: calling setEnd(Node,unsigned long) on document.createRange() with too few arguments must throw TypeError": true,
"Range interface: calling setStartBefore(Node) on document.createRange() with too few arguments must throw TypeError": true,
@ -393,7 +392,6 @@
"Range interface: calling surroundContents(Node) on document.createRange() with too few arguments must throw TypeError": true,
"Range interface: calling isPointInRange(Node,unsigned long) on document.createRange() with too few arguments must throw TypeError": true,
"Range interface: calling comparePoint(Node,unsigned long) on document.createRange() with too few arguments must throw TypeError": true,
"Range interface: document.createRange() must inherit property \"intersectsNode\" with the proper type (29)": true,
"Range interface: calling intersectsNode(Node) on document.createRange() with too few arguments must throw TypeError": true,
"Range interface: calling setStart(Node,unsigned long) on detachedRange with too few arguments must throw TypeError": true,
"Range interface: calling setEnd(Node,unsigned long) on detachedRange with too few arguments must throw TypeError": true,
@ -409,7 +407,6 @@
"Range interface: calling surroundContents(Node) on detachedRange with too few arguments must throw TypeError": true,
"Range interface: calling isPointInRange(Node,unsigned long) on detachedRange with too few arguments must throw TypeError": true,
"Range interface: calling comparePoint(Node,unsigned long) on detachedRange with too few arguments must throw TypeError": true,
"Range interface: detachedRange must inherit property \"intersectsNode\" with the proper type (29)": true,
"Range interface: calling intersectsNode(Node) on detachedRange with too few arguments must throw TypeError": true,
"NodeIterator interface: existence and properties of interface object": true,
"NodeIterator interface: existence and properties of interface prototype object": true,

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

@ -12,7 +12,7 @@
* http://www.w3.org/TR/DOM-Level-2-Traversal-Range/
*/
[scriptable, builtinclass, uuid(a059eea8-fece-4c14-93d3-7f50a944ae43)]
[scriptable, builtinclass, uuid(1f94055c-42e7-4a30-96a1-6a804f1c2d1e)]
interface nsIDOMRange : nsISupports
{
readonly attribute nsIDOMNode startContainer;
@ -65,6 +65,11 @@ interface nsIDOMRange : nsISupports
// Sort of a strcmp for ranges.
short comparePoint(in nsIDOMNode parent, in long offset);
/**
* Returns whether the range intersects node.
*/
boolean intersectsNode(in nsIDOMNode node);
// These methods come from
// http://dev.w3.org/csswg/cssom-view/#extensions-to-the-range-interface
nsIDOMClientRectList getClientRects();