Bug 303896 - Turn on displaying the selection when the 'disabled' attr is removed if the element has focus. r=ehsan

This commit is contained in:
Mats Palmgren 2013-07-24 23:03:38 +00:00
parent 3881778c25
commit 976dee9ded
4 changed files with 44 additions and 2 deletions

View File

@ -1165,9 +1165,11 @@ nsTextControlFrame::AttributeChanged(int32_t aNameSpaceID,
else
{ // unset disabled
flags &= ~(nsIPlaintextEditor::eEditorDisabledMask);
selCon->SetDisplaySelection(nsISelectionController::SELECTION_HIDDEN);
if (nsContentUtils::IsFocusedContent(mContent)) {
selCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
selCon->SetCaretEnabled(true);
} else {
selCon->SetDisplaySelection(nsISelectionController::SELECTION_HIDDEN);
}
}
editor->SetFlags(flags);

View File

@ -4,3 +4,4 @@ skip-if(B2G) fails-if(Android) == size-2.html size-2-ref.html
HTTP(..) == baseline-1.html baseline-1-ref.html
HTTP(..) == centering-1.xul centering-1-ref.xul
== dynamic-height-1.xul dynamic-height-1-ref.xul
needs-focus == select.html select-ref.html

View File

@ -0,0 +1,18 @@
<html class="reftest-wait">
<head>
<script type="text/javascript">
function finishTest() {
document.documentElement.removeAttribute("class");
}
function runTest() {
var field = document.getElementById('field');
field.focus();
field.select();
setTimeout(finishTest, 0);
}
</script>
</head>
<body onload="runTest()">
<input id="field" type="text" value="1234">
</body>
</html>

View File

@ -0,0 +1,21 @@
<html class="reftest-wait">
<head>
<script type="text/javascript">
function finishTest() {
document.documentElement.removeAttribute("class");
}
function runTest() {
var field = document.getElementById('field');
field.focus();
field.disabled = true;
field.setSelectionRange(0, 4);
field.disabled = false;
field.select();
setTimeout(finishTest, 0);
}
</script>
</head>
<body onload="runTest()">
<input id="field" type="text" value="1234">
</body>
</html>