Bug 240933 - Part 7: Collapse the selection in textarea's to the trailing BR if needed after every edit operation; r,a=roc

--HG--
extra : rebase_source : def2e0da4f32e9e50231b250075c45766bb00819
This commit is contained in:
Ehsan Akhgari 2010-09-01 18:06:52 -04:00
parent b5f720a55c
commit 88f276e98a
7 changed files with 56 additions and 0 deletions

View File

@ -268,6 +268,9 @@ nsTextEditRules::AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection)
res = CreateTrailingBRIfNeeded();
NS_ENSURE_SUCCESS(res, res);
// collapse the selection to the trailing BR if it's at the end of our text node
CollapseSelectionToTrailingBRIfNeeded(selection);
/* After inserting text the cursor Bidi level must be set to the level of the inserted text.
* This is difficult, because we cannot know what the level is until after the Bidi algorithm
* is applied to the whole paragraph.
@ -455,6 +458,12 @@ nsTextEditRules::WillInsertBreak(nsISelection *aSelection, PRBool *aCancel, PRBo
nsresult
nsTextEditRules::DidInsertBreak(nsISelection *aSelection, nsresult aResult)
{
return NS_OK;
}
nsresult
nsTextEditRules::CollapseSelectionToTrailingBRIfNeeded(nsISelection* aSelection)
{
// we only need to execute the stuff below if we are a plaintext editor.
// html editors have a different mechanism for putting in mozBR's

View File

@ -233,6 +233,8 @@ protected:
nsresult HideLastPWInput();
nsresult CollapseSelectionToTrailingBRIfNeeded(nsISelection *aSelection);
PRBool IsPasswordEditor() const
{
return mEditor ? mEditor->IsPasswordEditor() : PR_FALSE;

View File

@ -92,6 +92,9 @@ _TEST_FILES = \
bug106855-1.html \
bug106855-2.html \
bug106855-1-ref.html \
bug240933-1.html \
bug240933-2.html \
bug240933-1-ref.html \
bug482484.html \
bug482484-ref.html \
bug512295-1.html \

View File

@ -0,0 +1,10 @@
<!DOCTYPE HTML><html>
<body>
<textarea id="t" rows="4">
</textarea>
<script>
document.getElementById("t").focus();
</script>
</body>
</html>

View File

@ -0,0 +1,14 @@
<!DOCTYPE HTML><html><head>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
</head>
<body>
<textarea id="t" rows="4"></textarea>
<script>
var area = document.getElementById('t');
area.focus();
sendKey('VK_ENTER'); // press Enter once
</script>
</body>
</html>

View File

@ -0,0 +1,16 @@
<!DOCTYPE HTML><html><head>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
</head>
<body>
<textarea id="t" rows="4"></textarea>
<script>
var area = document.getElementById('t');
area.focus();
sendKey('VK_ENTER'); // press Enter twice
sendKey('VK_ENTER');
sendKey('VK_BACK_SPACE'); // press Backspace once
</script>
</body>
</html>

View File

@ -88,6 +88,8 @@ function endTest() {
var tests = [
[ 'bug106855-1.html' , 'bug106855-1-ref.html' ] ,
[ 'bug106855-2.html' , 'bug106855-1-ref.html' ] ,
[ 'bug240933-1.html' , 'bug240933-1-ref.html' ] ,
[ 'bug240933-2.html' , 'bug240933-1-ref.html' ] ,
[ 'bug482484.html' , 'bug482484-ref.html' ] ,
[ 'bug512295-1.html' , 'bug512295-1-ref.html' ] ,
[ 'bug512295-2.html' , 'bug512295-2-ref.html' ] ,