Fix for this bug:
<rdar://problem/
3768378> crash typing newline in Blot
* khtml/editing/htmlediting_impl.cpp:
(khtml::InputNewlineCommandImpl::doApply): Adding an assert in a recent change
showed up that inserting newlines that was not being handled correctly for the
case described in the bug. I added a new case to handle inserting BR's when
at the caret max offset for a node, and this new code runs instead of the
fall-through case that should not have been running and triggered the assert.
* layout-tests/editing/inserting/insert-br-case2-expected.txt: Regenerated results.
* layout-tests/editing/inserting/insert-br-case6-expected.txt: Added.
* layout-tests/editing/inserting/insert-br-case6.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7309
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {DIV} at (0,0) size 784x112 [border: (2px solid #FF0000)]
- RenderInline {SPAN} at (0,0) size 46x84
+ RenderInline {SPAN} at (0,0) size 34x84
RenderText {TEXT} at (14,14) size 34x28
text run at (14,14) width 34: "test"
RenderBR {BR} at (0,0) size 0x0
- RenderText {TEXT} at (0,0) size 0x0
- RenderBR {BR} at (0,0) size 0x0
- RenderText {TEXT} at (14,70) size 46x28
- text run at (14,70) width 46: "xtest"
+ RenderText {TEXT} at (14,42) size 12x28
+ text run at (14,42) width 12: "x"
+ RenderBR {BR} at (14,42) size 0x28
+ RenderText {TEXT} at (14,70) size 34x28
+ text run at (14,70) width 34: "test"
RenderText {TEXT} at (0,0) size 0x0
selection is CARET:
-start: position 1 of child 5 {TEXT} of child 2 {SPAN} of root {DIV}
-upstream: position 1 of child 5 {TEXT} of child 2 {SPAN} of root {DIV}
-downstream: position 1 of child 5 {TEXT} of child 2 {SPAN} of root {DIV}
+start: position 1 of child 3 {TEXT} of child 2 {SPAN} of root {DIV}
+upstream: position 1 of child 3 {TEXT} of child 2 {SPAN} of root {DIV}
+downstream: position 0 of child 4 {BR} of child 2 {SPAN} of root {DIV}
+2004-08-20 Ken Kocienda <kocienda@apple.com>
+
+ Reviewed by Trey
+
+ Fix for this bug:
+
+ <rdar://problem/3768378> crash typing newline in Blot
+
+ * khtml/editing/htmlediting_impl.cpp:
+ (khtml::InputNewlineCommandImpl::doApply): Adding an assert in a recent change
+ showed up that inserting newlines that was not being handled correctly for the
+ case described in the bug. I added a new case to handle inserting BR's when
+ at the caret max offset for a node, and this new code runs instead of the
+ fall-through case that should not have been running and triggered the assert.
+ * layout-tests/editing/inserting/insert-br-case2-expected.txt: Regenerated results.
+ * layout-tests/editing/inserting/insert-br-case6-expected.txt: Added.
+ * layout-tests/editing/inserting/insert-br-case6.html: Added.
+
2004-08-20 Trey Matteson <trey@apple.com>
Fixing: Spellchecker called once or twice for every char typed.
Position pos(selection.start().upstream(StayInBlock));
bool atStart = pos.offset() <= pos.node()->caretMinOffset();
+ bool atEnd = pos.offset() >= pos.node()->caretMaxOffset();
bool atEndOfBlock = pos.isLastRenderedPositionInEditableBlock();
if (atEndOfBlock) {
// position. This will make the caret appear after the break, and as we know
// there is content at that location, this is OK.
insertNodeBeforePosition(nodeToInsert, pos);
- setEndingSelection(Position(pos.node(), 0));
+ setEndingSelection(Position(pos.node(), pos.node()->caretMinOffset()));
+ }
+ else if (atEnd) {
+ LOG(Editing, "input newline case 3");
+ // Insert BR after this node. Place caret in the position that is downstream
+ // of the current position, reckoned before inserting the BR in between.
+ Position endingPosition = pos.downstream(StayInBlock);
+ insertNodeAfterPosition(nodeToInsert, pos);
+ setEndingSelection(endingPosition);
}
else {
// Split a text node
- LOG(Editing, "input newline case 3");
+ LOG(Editing, "input newline case 4");
ASSERT(pos.node()->isTextNode());
// See if there is trailing whitespace we need to consider