зеркало из https://github.com/mozilla/gecko-dev.git
Bug 602331 - selection addRange cannot select nodes that are being dynamically appended to the DOM. r=roc a=blocking2.0:final
This commit is contained in:
Родитель
227698aa53
Коммит
418ee669d2
|
@ -4356,11 +4356,6 @@ nsTypedSelection::selectFrames(nsPresContext* aPresContext, nsIRange *aRange, PR
|
|||
if (!presShell)
|
||||
return NS_OK;
|
||||
|
||||
// Re-get shell because the flush might have destroyed it
|
||||
presShell = aPresContext->GetPresShell();
|
||||
if (!presShell)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMRange> domRange = do_QueryInterface(aRange);
|
||||
if (!domRange || !aPresContext)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
@ -4821,9 +4816,14 @@ nsTypedSelection::AddRange(nsIRange* aRange)
|
|||
|
||||
nsRefPtr<nsPresContext> presContext;
|
||||
GetPresContext(getter_AddRefs(presContext));
|
||||
|
||||
// Ensure all frames are properly constructed for selectFrames, bug 602331.
|
||||
nsIPresShell* presShell = presContext ? presContext->GetPresShell() : nsnull;
|
||||
if (presShell) {
|
||||
presShell->FlushPendingNotifications(Flush_Frames);
|
||||
}
|
||||
selectFrames(presContext, aRange, PR_TRUE);
|
||||
|
||||
//ScrollIntoView(); this should not happen automatically
|
||||
if (!mFrameSelection)
|
||||
return NS_OK;//nothing to do
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Testcase #2 for bug 602331</title>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
function selectNewlyAdded() {
|
||||
window.getSelection().removeAllRanges();
|
||||
|
||||
var newNode = document.createElement('span');
|
||||
newNode.innerHTML = "Hello Kitty";
|
||||
document.getElementById('new_nodes').appendChild(newNode);
|
||||
var range = document.createRange();
|
||||
range.selectNode(newNode);
|
||||
window.getSelection().addRange(range);
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body onload="selectNewlyAdded()">
|
||||
* <span id="new_nodes"></span> *
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Testcase #3 for bug 602331</title>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
function selectAllOfNewNodes() {
|
||||
window.getSelection().removeAllRanges();
|
||||
|
||||
var newNode = document.createElement('span');
|
||||
newNode.innerHTML = "Kitty";
|
||||
document.getElementById('new_nodes').appendChild(newNode);
|
||||
var range = document.createRange();
|
||||
range.selectNode(document.getElementById('new_nodes'));
|
||||
window.getSelection().addRange(range);
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body onload="selectAllOfNewNodes()">
|
||||
* <span id="new_nodes"><span>Hello</span> </span> *
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Testcase #1 for bug 602331</title>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
function selectExisting() {
|
||||
window.getSelection().removeAllRanges();
|
||||
|
||||
var range = document.createRange();
|
||||
range.selectNode(document.getElementById('existing_node'));
|
||||
window.getSelection().addRange(range);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="selectExisting()">
|
||||
* <span id="existing_node">Hello Kitty</span> *
|
||||
</body>
|
||||
</html>
|
|
@ -28,3 +28,5 @@
|
|||
# These tests uses Highlight and HighlightText color keywords, they are not same as text selection color on Mac.
|
||||
fails-if(cocoaWidget) == non-themed-widget.html non-themed-widget-ref.html
|
||||
fails-if(cocoaWidget) == themed-widget.html themed-widget-ref.html
|
||||
== addrange-1.html addrange-ref.html
|
||||
== addrange-2.html addrange-ref.html
|
||||
|
|
Загрузка…
Ссылка в новой задаче