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 : a13c6c277ddb545614eb8c93131112bc793c1348
This commit is contained in:
Ehsan Akhgari 2010-09-01 18:06:52 -04:00
Родитель 08f3d2d20a
Коммит 551fb2e6c7
7 изменённых файлов: 56 добавлений и 0 удалений

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

@ -267,6 +267,9 @@ nsTextEditRules::AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection)
// insure trailing br node
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
@ -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

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

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

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

@ -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 \

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

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

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

@ -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>

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

@ -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>

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

@ -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' ] ,