mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 719523 - Selection.selectAllChildren() on a Document always produces end offset of 1; r=ehsan
This commit is contained in:
parent
610d48849d
commit
57af16cb02
@ -5283,47 +5283,25 @@ nsTypedSelection::Extend(nsINode* aParentNode, PRInt32 aOffset)
|
||||
return mFrameSelection->NotifySelectionListeners(GetType());
|
||||
}
|
||||
|
||||
static nsresult
|
||||
GetChildOffset(nsIDOMNode *aChild, nsIDOMNode *aParent, PRInt32 &aOffset)
|
||||
{
|
||||
NS_ASSERTION((aChild && aParent), "bad args");
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aParent);
|
||||
nsCOMPtr<nsIContent> cChild = do_QueryInterface(aChild);
|
||||
|
||||
if (!cChild || !content)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
aOffset = content->IndexOf(cChild);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTypedSelection::SelectAllChildren(nsIDOMNode* aParentNode)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aParentNode);
|
||||
|
||||
if (mFrameSelection)
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aParentNode);
|
||||
|
||||
if (mFrameSelection)
|
||||
{
|
||||
mFrameSelection->PostReason(nsISelectionListener::SELECTALL_REASON);
|
||||
}
|
||||
nsresult result = Collapse(aParentNode, 0);
|
||||
if (NS_SUCCEEDED(result))
|
||||
nsresult result = Collapse(node, 0);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
if (mFrameSelection)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode>lastChild;
|
||||
result = aParentNode->GetLastChild(getter_AddRefs(lastChild));
|
||||
if ((NS_SUCCEEDED(result)) && lastChild)
|
||||
{
|
||||
PRInt32 numBodyChildren=0;
|
||||
GetChildOffset(lastChild, aParentNode, numBodyChildren);
|
||||
if (mFrameSelection)
|
||||
{
|
||||
mFrameSelection->PostReason(nsISelectionListener::SELECTALL_REASON);
|
||||
}
|
||||
result = Extend(aParentNode, numBodyChildren+1);
|
||||
}
|
||||
mFrameSelection->PostReason(nsISelectionListener::SELECTALL_REASON);
|
||||
}
|
||||
return result;
|
||||
return Extend(node, node->GetChildCount());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -130,6 +130,7 @@ _TEST_FILES = \
|
||||
test_bug719503.html \
|
||||
test_bug719515.html \
|
||||
test_bug719518.html \
|
||||
test_bug719523.html \
|
||||
$(NULL)
|
||||
|
||||
_CHROME_FILES = \
|
||||
|
20
layout/generic/test/test_bug719523.html
Normal file
20
layout/generic/test/test_bug719523.html
Normal file
@ -0,0 +1,20 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=719523
|
||||
-->
|
||||
<title>Test for Bug 719523</title>
|
||||
<script 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=719523">Mozilla Bug 719523</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
<script>
|
||||
getSelection().selectAllChildren(document);
|
||||
is(document.childNodes.length, 2, "Sanity check: number of document children");
|
||||
is(getSelection().focusNode, document,
|
||||
"Sanity check: document must be selected");
|
||||
is(getSelection().focusOffset, 2,
|
||||
"selectAllChildren() must select all the document's children");
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user