--- /dev/null
+<html>
+<head>
+
+<style>
+.editing {
+ border: 2px solid red;
+ padding: 12px;
+ font-size: 24px;
+}
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+ moveSelectionForwardByCharacterCommand();
+ insertNewlineCommand();
+ typeCharacterCommand();
+ selectAllCommand();
+ deleteCommand();
+ typeCharacterCommand();
+ insertNewlineCommand();
+ typeCharacterCommand();
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body>
+<div contenteditable id="root" class="editing">
+<span id="test">x</span>
+</div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
+2004-08-26 Ken Kocienda <kocienda@apple.com>
+
+ Reviewed by Hyatt
+
+ Fix for this bug:
+
+ <rdar://problem/3775316> document sprouts an extra newline character at the end
+
+ * khtml/editing/htmlediting_impl.cpp:
+ (khtml::InputNewlineCommandImpl::doApply): There was in insufficient check
+ in the code which adds extra BR elements at the ends of blocks, which we do
+ to work around the fact that BR elements, when they are the last element in a
+ block, do not render. Now the code sees whether there already is one of these
+ extra BR's in the document and won't add and "extra" extra.
+ * layout-tests/editing/inserting/insert-3775316-fix.html: Added.
+
2004-08-26 David Hyatt <hyatt@apple.com>
Fix for 3710721 and 3504114, crashes because of bad ownership model for list markers.
if (atEndOfBlock) {
LOG(Editing, "input newline case 1");
- // Insert an "extra" BR at the end of the block. This makes the "real" BR we want
- // to insert appear in the rendering without any significant side effects (and no
- // real worries either since you can't arrow past this extra one.
+ // Check for a trailing BR. If there isn't one, we'll need to insert an "extra" one.
+ // This makes the "real" BR we want to insert appear in the rendering without any
+ // significant side effects (and no real worries either since you can't arrow past
+ // this extra one.
+ NodeImpl *next = pos.node()->traverseNextNode();
+ bool hasTrailingBR = next && next->id() == ID_BR;
insertNodeAfterPosition(nodeToInsert, pos);
- exceptionCode = 0;
- ElementImpl *extraBreakNode = document()->createHTMLElement("BR", exceptionCode);
- ASSERT(exceptionCode == 0);
- insertNodeAfter(extraBreakNode, nodeToInsert);
- setEndingSelection(Position(extraBreakNode, 0));
+ if (hasTrailingBR) {
+ setEndingSelection(Position(nodeToInsert, 0));
+ }
+ else {
+ // Insert an "extra" BR at the end of the block.
+ ElementImpl *extraBreakNode = document()->createHTMLElement("BR", exceptionCode);
+ ASSERT(exceptionCode == 0);
+ insertNodeAfter(extraBreakNode, nodeToInsert);
+ setEndingSelection(Position(extraBreakNode, 0));
+ }
}
else if (atStart) {
LOG(Editing, "input newline case 2");