--- /dev/null
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {DIV} at (0,0) size 784x212 [border: (2px solid #0000FF)]
+ RenderBlock {DIV} at (14,14) size 756x56
+ RenderText {TEXT} at (0,0) size 67x28
+ text run at (0,0) width 67: "Tests: "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {TEXT} at (0,28) size 498x28
+ text run at (0,28) width 498: "Smart delete when deleting the first word on a line."
+ RenderBlock {DIV} at (14,86) size 756x112
+ RenderText {TEXT} at (0,0) size 189x28
+ text run at (0,0) width 189: "Expected Results: "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {TEXT} at (0,28) size 714x56
+ text run at (0,28) width 714: "The first word and the space following the first word should be deleted. It"
+ text run at (0,56) width 202: "should like this this: "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {TEXT} at (0,84) size 71x28
+ text run at (0,84) width 71: "bar baz"
+ RenderBlock {DIV} at (0,236) size 784x32
+ RenderBlock {DIV} at (0,0) size 784x32 [border: (2px solid #FF0000)]
+ RenderText {TEXT} at (2,2) size 71x28
+ text run at (2,2) width 71: "bar baz"
+selection is CARET:
+start: position 0 of child 1 {TEXT} of child 1 {DIV} of root {DIV}
+upstream: position 0 of child 1 {DIV} of root {DIV}
+downstream: position 0 of child 1 {TEXT} of child 1 {DIV} of root {DIV}
--- /dev/null
+<html>
+<head>
+
+<style>
+.editing {
+ border: 2px solid red;
+ font-size: 24px;
+}
+.explanation {
+ border: 2px solid blue;
+ padding: 12px;
+ font-size: 24px;
+ margin-bottom: 24px;
+}
+.scenario { margin-bottom: 16px;}
+.scenario:first-line { font-weight: bold; margin-bottom: 16px;}
+.expected-results:first-line { font-weight: bold }
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+ extendSelectionForwardByWordCommand();
+ deleteCommand();
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body>
+
+<div class="explanation">
+<div class="scenario">
+Tests:
+<br>
+Smart delete when deleting the first word on a line.
+</div>
+<div class="expected-results">
+Expected Results:
+<br>
+The first word and the space following the first word should be deleted. It should like this this:
+<BR>
+bar baz
+</div>
+</div>
+
+<div contenteditable id="root" style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space;">
+<div id="test" class="editing">
+foo bar baz
+</div>
+</div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
--- /dev/null
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {DIV} at (0,0) size 784x212 [border: (2px solid #0000FF)]
+ RenderBlock {DIV} at (14,14) size 756x56
+ RenderText {TEXT} at (0,0) size 67x28
+ text run at (0,0) width 67: "Tests: "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {TEXT} at (0,28) size 522x28
+ text run at (0,28) width 522: "Smart delete when deleting the second word of a line."
+ RenderBlock {DIV} at (14,86) size 756x112
+ RenderText {TEXT} at (0,0) size 189x28
+ text run at (0,0) width 189: "Expected Results: "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {TEXT} at (0,28) size 738x56
+ text run at (0,28) width 738: "The second word and the space before the second word should be deleted. It"
+ text run at (0,56) width 202: "should like this this: "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {TEXT} at (0,84) size 72x28
+ text run at (0,84) width 72: "foo baz"
+ RenderBlock {DIV} at (0,236) size 784x32
+ RenderBlock {DIV} at (0,0) size 784x32 [border: (2px solid #FF0000)]
+ RenderText {TEXT} at (2,2) size 72x28
+ text run at (2,2) width 72: "foo baz"
+selection is CARET:
+start: position 4 of child 1 {TEXT} of child 1 {DIV} of root {DIV}
+upstream: position 4 of child 1 {TEXT} of child 1 {DIV} of root {DIV}
+downstream: position 4 of child 1 {TEXT} of child 1 {DIV} of root {DIV}
--- /dev/null
+<html>
+<head>
+
+<style>
+.editing {
+ border: 2px solid red;
+ font-size: 24px;
+}
+.explanation {
+ border: 2px solid blue;
+ padding: 12px;
+ font-size: 24px;
+ margin-bottom: 24px;
+}
+.scenario { margin-bottom: 16px;}
+.scenario:first-line { font-weight: bold; margin-bottom: 16px;}
+.expected-results:first-line { font-weight: bold }
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+ moveSelectionForwardByWordCommand();
+ moveSelectionForwardByCharacterCommand();
+ extendSelectionForwardByWordCommand();
+ deleteCommand();
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body>
+
+<div class="explanation">
+<div class="scenario">
+Tests:
+<br>
+Smart delete when deleting the second word of a line.
+</div>
+<div class="expected-results">
+Expected Results:
+<br>
+The second word and the space before the second word should be deleted. It should like this this:
+<BR>
+foo baz
+</div>
+</div>
+
+<div contenteditable id="root" style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space;">
+<div id="test" class="editing">
+foo bar baz
+</div>
+</div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
+2005-03-01 Chris Blumenberg <cblu@apple.com>
+
+ Fixed: <rdar://problem/4030669> smart delete does not delete spaces from pasted content
+
+ Reviewed by rjw.
+
+ * khtml/editing/htmlediting.cpp:
+ (khtml::DeleteSelectionCommand::initializePositionData): pass true for treatNBSPAsWhiteSpace to leadingWhitespacePosition and trailingWhitespacePosition when testing whether or not we have to delete those characters as well.
+ * khtml/editing/jsediting.cpp: pass true for smartDelete when the selection granularity is WORD. This allows us to write smart delete layout tests.
+ * layout-tests/editing/deleting/smart-delete-001-expected.txt: Added.
+ * layout-tests/editing/deleting/smart-delete-001.html: Added.
+ * layout-tests/editing/deleting/smart-delete-002-expected.txt: Added.
+ * layout-tests/editing/deleting/smart-delete-002.html: Added.
+
2005-03-01 Ken Kocienda <kocienda@apple.com>
Reviewed by Vicki
// Handle leading and trailing whitespace, as well as smart delete adjustments to the selection
//
m_leadingWhitespace = m_upstreamStart.leadingWhitespacePosition(m_selectionToDelete.startAffinity());
- bool hasLeadingWhitespaceBeforeAdjustment = m_leadingWhitespace.isNotNull();
- if (m_smartDelete && hasLeadingWhitespaceBeforeAdjustment) {
- VisiblePosition visiblePos = VisiblePosition(start, m_selectionToDelete.startAffinity()).previous();
- Position pos = visiblePos.deepEquivalent();
- // Expand out one character upstream for smart delete and recalculate
- // positions based on this change.
- m_upstreamStart = pos.upstream(StayInBlock);
- m_downstreamStart = pos.downstream(StayInBlock);
- m_leadingWhitespace = m_upstreamStart.leadingWhitespacePosition(visiblePos.affinity());
- }
m_trailingWhitespace = m_downstreamEnd.trailingWhitespacePosition(VP_DEFAULT_AFFINITY);
- // Note: trailing whitespace is only considered for smart delete if there is no leading
- // whitespace, as in the case where you double-click the first word of a paragraph.
- if (m_smartDelete && !hasLeadingWhitespaceBeforeAdjustment && m_trailingWhitespace.isNotNull()) {
- // Expand out one character downstream for smart delete and recalculate
- // positions based on this change.
- Position pos = VisiblePosition(end, m_selectionToDelete.endAffinity()).next().deepEquivalent();
- m_upstreamEnd = pos.upstream(StayInBlock);
- m_downstreamEnd = pos.downstream(StayInBlock);
- m_trailingWhitespace = m_downstreamEnd.trailingWhitespacePosition(VP_DEFAULT_AFFINITY);
+
+ if (m_smartDelete) {
+ bool hasLeadingWhitespaceBeforeAdjustment = m_upstreamStart.leadingWhitespacePosition(m_selectionToDelete.startAffinity(), true).isNotNull();
+ if (hasLeadingWhitespaceBeforeAdjustment) {
+ VisiblePosition visiblePos = VisiblePosition(start, m_selectionToDelete.startAffinity()).previous();
+ Position pos = visiblePos.deepEquivalent();
+ // Expand out one character upstream for smart delete and recalculate
+ // positions based on this change.
+ m_upstreamStart = pos.upstream(StayInBlock);
+ m_downstreamStart = pos.downstream(StayInBlock);
+ m_leadingWhitespace = m_upstreamStart.leadingWhitespacePosition(visiblePos.affinity());
+ }
+ // Note: trailing whitespace is only considered for smart delete if there is no leading
+ // whitespace, as in the case where you double-click the first word of a paragraph.
+ if (!hasLeadingWhitespaceBeforeAdjustment && m_downstreamEnd.trailingWhitespacePosition(VP_DEFAULT_AFFINITY, true).isNotNull()) {
+ // Expand out one character downstream for smart delete and recalculate
+ // positions based on this change.
+ Position pos = VisiblePosition(end, m_selectionToDelete.endAffinity()).next().deepEquivalent();
+ m_upstreamEnd = pos.upstream(StayInBlock);
+ m_downstreamEnd = pos.downstream(StayInBlock);
+ m_trailingWhitespace = m_downstreamEnd.trailingWhitespacePosition(VP_DEFAULT_AFFINITY);
+ }
}
+
m_trailingWhitespaceValid = true;
//
bool execDelete(KHTMLPart *part, bool userInterface, const DOMString &value)
{
- TypingCommand::deleteKeyPressed(part->xmlDocImpl());
+ TypingCommand::deleteKeyPressed(part->xmlDocImpl(), part->selectionGranularity() == khtml::WORD);
return true;
}