[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
kocienda
kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:34:50 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit ee40dddeef3ef6f4a00f56d17429d44489e0b3bb
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Apr 16 23:18:54 2004 +0000
Reviewed by Hyatt
* khtml/editing/htmlediting_impl.cpp: New helper.
(DeleteSelectionCommandImpl::containsOnlyWhitespace): Fix deleting collapsed whitespace
at the end of a line where text has flowed to the next line and the caret is at the
beginning of the next line.
(DeleteSelectionCommandImpl::doApply): Updated for new helper.
* khtml/editing/htmlediting_impl.h:
* layout-tests/editing/deleting/delete-line-end-ws-001-expected.txt: Added.
* layout-tests/editing/deleting/delete-line-end-ws-001.html: Added.
* layout-tests/editing/deleting/delete-line-end-ws-002-expected.txt: Added.
* layout-tests/editing/deleting/delete-line-end-ws-002.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6414 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/editing/deleting/delete-line-end-ws-001-expected.txt b/LayoutTests/editing/deleting/delete-line-end-ws-001-expected.txt
new file mode 100644
index 0000000..1e5e595
--- /dev/null
+++ b/LayoutTests/editing/deleting/delete-line-end-ws-001-expected.txt
@@ -0,0 +1,15 @@
+layer at (0,0) size 820x585
+ RenderCanvas at (0,0) size 800x585
+layer at (0,0) size 820x372
+ RenderBlock {HTML} at (0,0) size 800x372
+ RenderBody {BODY} at (8,64) size 784x244
+ RenderBlock {DIV} at (64,0) size 748x244 [border: (50px solid #FF0000)]
+ RenderInline {SPAN} at (0,0) size 540x76
+ RenderText {TEXT} at (74,84) size 540x96
+ text run at (74,84) width 540: "Fourscore and seven years ago our fathers brought forth"
+ text run at (74,132) width 304: "onthis continent a new nation..."
+ RenderText {TEXT} at (0,0) size 0x0
+selection is CARET:
+start: position 58 of child 1 {TEXT} of child 2 {SPAN} of root {DIV}
+upstream: position 58 of child 1 {TEXT} of child 2 {SPAN} of root {DIV}
+downstream: position 58 of child 1 {TEXT} of child 2 {SPAN} of root {DIV}
diff --git a/LayoutTests/editing/deleting/delete-3608430-fix.html b/LayoutTests/editing/deleting/delete-line-end-ws-001.html
similarity index 60%
copy from LayoutTests/editing/deleting/delete-3608430-fix.html
copy to LayoutTests/editing/deleting/delete-line-end-ws-001.html
index 446cbcb..473985e 100644
--- a/LayoutTests/editing/deleting/delete-3608430-fix.html
+++ b/LayoutTests/editing/deleting/delete-line-end-ws-001.html
@@ -3,9 +3,12 @@
<style>
.editing {
- border: 2px solid red;
- padding: 12px;
+ border: solid red 50px;
font-size: 24px;
+ line-height: 48px;
+ padding: 24px;
+ margin: 64px;
+ width: 600px;
}
</style>
<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
@@ -13,12 +16,10 @@
<script>
function editingTest() {
- for (i = 0; i < 28; i++) {
+ for (i = 0; i < 59; i++) {
moveSelectionForwardByCharacterCommand();
}
- for (i = 0; i < 28; i++) {
- deleteCommand();
- }
+ deleteCommand();
}
</script>
@@ -27,8 +28,7 @@ function editingTest() {
</head>
<body>
<div contenteditable id="root" class="editing">
-<span id="test">foo
-<br>foo <i> </i> <img src="../abe.gif""> select-in-me-and-start-deleting</span>
+<span id="test">Fourscore and seven years ago our fathers brought forth on this continent a new nation...</span>
</div>
<script>
diff --git a/LayoutTests/editing/deleting/delete-line-end-ws-002-expected.txt b/LayoutTests/editing/deleting/delete-line-end-ws-002-expected.txt
new file mode 100644
index 0000000..1e5e595
--- /dev/null
+++ b/LayoutTests/editing/deleting/delete-line-end-ws-002-expected.txt
@@ -0,0 +1,15 @@
+layer at (0,0) size 820x585
+ RenderCanvas at (0,0) size 800x585
+layer at (0,0) size 820x372
+ RenderBlock {HTML} at (0,0) size 800x372
+ RenderBody {BODY} at (8,64) size 784x244
+ RenderBlock {DIV} at (64,0) size 748x244 [border: (50px solid #FF0000)]
+ RenderInline {SPAN} at (0,0) size 540x76
+ RenderText {TEXT} at (74,84) size 540x96
+ text run at (74,84) width 540: "Fourscore and seven years ago our fathers brought forth"
+ text run at (74,132) width 304: "onthis continent a new nation..."
+ RenderText {TEXT} at (0,0) size 0x0
+selection is CARET:
+start: position 58 of child 1 {TEXT} of child 2 {SPAN} of root {DIV}
+upstream: position 58 of child 1 {TEXT} of child 2 {SPAN} of root {DIV}
+downstream: position 58 of child 1 {TEXT} of child 2 {SPAN} of root {DIV}
diff --git a/LayoutTests/editing/deleting/delete-contiguous-ws-001.html b/LayoutTests/editing/deleting/delete-line-end-ws-002.html
similarity index 59%
copy from LayoutTests/editing/deleting/delete-contiguous-ws-001.html
copy to LayoutTests/editing/deleting/delete-line-end-ws-002.html
index 904a7cf..2e94548 100644
--- a/LayoutTests/editing/deleting/delete-contiguous-ws-001.html
+++ b/LayoutTests/editing/deleting/delete-line-end-ws-002.html
@@ -3,9 +3,12 @@
<style>
.editing {
- border: 2px solid red;
- padding: 12px;
+ border: solid red 50px;
font-size: 24px;
+ line-height: 48px;
+ padding: 24px;
+ margin: 64px;
+ width: 600px;
}
</style>
<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
@@ -13,13 +16,10 @@
<script>
function editingTest() {
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < 59; i++) {
moveSelectionForwardByCharacterCommand();
}
- for (i = 0; i < 3; i++) {
- extendSelectionForwardByCharacterCommand();
- }
- deleteCommand();
+ deleteCommand();
}
</script>
@@ -28,9 +28,10 @@ function editingTest() {
</head>
<body>
<div contenteditable id="root" class="editing">
-<span id="test">foo bar
+<span id="test">Fourscore and seven years ago our fathers brought forth on
+
-baz</span>
+this continent a new nation...</span>
</div>
<script>
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index a9f7868..8f03d12 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,18 @@
+2004-04-16 Ken Kocienda <kocienda at apple.com>
+
+ Reviewed by Hyatt
+
+ * khtml/editing/htmlediting_impl.cpp: New helper.
+ (DeleteSelectionCommandImpl::containsOnlyWhitespace): Fix deleting collapsed whitespace
+ at the end of a line where text has flowed to the next line and the caret is at the
+ beginning of the next line.
+ (DeleteSelectionCommandImpl::doApply): Updated for new helper.
+ * khtml/editing/htmlediting_impl.h:
+ * layout-tests/editing/deleting/delete-line-end-ws-001-expected.txt: Added.
+ * layout-tests/editing/deleting/delete-line-end-ws-001.html: Added.
+ * layout-tests/editing/deleting/delete-line-end-ws-002-expected.txt: Added.
+ * layout-tests/editing/deleting/delete-line-end-ws-002.html: Added.
+
=== Safari-137 ===
2004-04-16 Richard Williamson <rjw at apple.com>
diff --git a/WebCore/khtml/editing/htmlediting_impl.cpp b/WebCore/khtml/editing/htmlediting_impl.cpp
index 29940a7..1dfc336 100644
--- a/WebCore/khtml/editing/htmlediting_impl.cpp
+++ b/WebCore/khtml/editing/htmlediting_impl.cpp
@@ -811,6 +811,27 @@ void DeleteSelectionCommandImpl::joinTextNodesWithSameStyle()
}
}
+bool DeleteSelectionCommandImpl::containsOnlyWhitespace(const DOMPosition &start, const DOMPosition &end)
+{
+ // Returns whether the range contains only whitespace characters.
+ // This is inclusive of the start, but not of the end.
+ EditIterator it(start);
+ while (!it.atEnd()) {
+ if (!it.current().node()->isTextNode())
+ return false;
+ const DOMString &text = static_cast<TextImpl *>(it.current().node())->data();
+ // EDIT FIXME: signed/unsigned mismatch
+ if (text.length() > INT_MAX)
+ return false;
+ if (it.current().offset() < (int)text.length() && !isWS(text[it.current().offset()]))
+ return false;
+ it.next();
+ if (it.current() == end)
+ break;
+ }
+ return true;
+}
+
void DeleteSelectionCommandImpl::doApply()
{
if (m_selectionToDelete.state() != KHTMLSelection::RANGE)
@@ -827,15 +848,17 @@ void DeleteSelectionCommandImpl::doApply()
DOMPosition upstreamEnd = selection.endPosition().equivalentUpstreamPosition();
DOMPosition downstreamEnd = selection.endPosition().equivalentDownstreamPosition();
- bool startCompletelySelected =
- downstreamStart.offset() <= downstreamStart.node()->caretMinOffset() &&
+ bool onlyWhitespace = containsOnlyWhitespace(upstreamStart, downstreamEnd);
+
+ bool startCompletelySelected = !onlyWhitespace &&
+ (downstreamStart.offset() <= downstreamStart.node()->caretMinOffset() &&
((downstreamStart.node() != upstreamEnd.node()) ||
- (upstreamEnd.offset() >= upstreamEnd.node()->caretMaxOffset()));
+ (upstreamEnd.offset() >= upstreamEnd.node()->caretMaxOffset())));
- bool endCompletelySelected =
- upstreamEnd.offset() >= upstreamEnd.node()->caretMaxOffset() &&
+ bool endCompletelySelected = !onlyWhitespace &&
+ (upstreamEnd.offset() >= upstreamEnd.node()->caretMaxOffset() &&
((downstreamStart.node() != upstreamEnd.node()) ||
- (downstreamStart.offset() <= downstreamStart.node()->caretMinOffset()));
+ (downstreamStart.offset() <= downstreamStart.node()->caretMinOffset())));
unsigned long startRenderedOffset = downstreamStart.renderedOffset();
@@ -852,6 +875,7 @@ void DeleteSelectionCommandImpl::doApply()
LOG(Editing, "at start block: %s", startAtStartOfBlock ? "YES" : "NO");
LOG(Editing, "at start root block: %s", startAtStartOfRootEditableBlock ? "YES" : "NO");
LOG(Editing, "at end block: %s", endAtEndOfBlock ? "YES" : "NO");
+ LOG(Editing, "only whitespace: %s", onlyWhitespace ? "YES" : "NO");
// Start is not completely selected
if (startAtStartOfBlock) {
@@ -916,9 +940,23 @@ void DeleteSelectionCommandImpl::doApply()
// work on start node
if (startCompletelySelected) {
+ LOG(Editing, "start node delete case 1");
removeNodeAndPrune(downstreamStart.node());
}
+ else if (onlyWhitespace) {
+ // Selection only contains whitespace. This is really a special-case to
+ // handle significant whitespace that is collapsed at the end of a line,
+ // but also handles deleting a space in mid-line.
+ LOG(Editing, "start node delete case 2");
+ ASSERT(upstreamStart.node()->isTextNode());
+ TextImpl *text = static_cast<TextImpl *>(upstreamStart.node());
+ int length = downstreamStart.node() == upstreamStart.node() ?
+ kMax(downstreamStart.offset() - upstreamStart.offset(), 1L) :
+ text->length() - upstreamStart.offset();
+ deleteText(text, upstreamStart.offset(), length);
+ }
else if (downstreamStart.node()->isTextNode()) {
+ LOG(Editing, "start node delete case 3");
TextImpl *text = static_cast<TextImpl *>(downstreamStart.node());
int endOffset = text == upstreamEnd.node() ? upstreamEnd.offset() : text->length();
if (endOffset > downstreamStart.offset()) {
@@ -928,10 +966,11 @@ void DeleteSelectionCommandImpl::doApply()
else {
// we have clipped the end of a non-text element
// the offset must be 1 here. if it is, do nothing and move on.
+ LOG(Editing, "start node delete case 4");
ASSERT(downstreamStart.offset() == 1);
}
- if (downstreamStart.node() != upstreamEnd.node()) {
+ if (!onlyWhitespace && downstreamStart.node() != upstreamEnd.node()) {
// work on intermediate nodes
while (n != upstreamEnd.node()) {
NodeImpl *d = n;
diff --git a/WebCore/khtml/editing/htmlediting_impl.h b/WebCore/khtml/editing/htmlediting_impl.h
index 10bd78b..5d20e39 100644
--- a/WebCore/khtml/editing/htmlediting_impl.h
+++ b/WebCore/khtml/editing/htmlediting_impl.h
@@ -197,6 +197,7 @@ public:
private:
void deleteDownstreamWS(const DOM::DOMPosition &start);
+ bool containsOnlyWhitespace(const DOM::DOMPosition &start, const DOM::DOMPosition &end);
void joinTextNodesWithSameStyle();
KHTMLSelection m_selectionToDelete;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list