Commit 06a653c7 authored by justing's avatar justing

LayoutTests:

        Reviewed by darin
        
        <rdar://problem/5026848> Can cut/delete To Do subunits

        This tests to make sure that non-editable content
        that is in both the start and end editable roots
        is removed:
        * editing/deleting/5026848-1-expected.checksum: Added.
        * editing/deleting/5026848-1-expected.png: Added.
        * editing/deleting/5026848-1-expected.txt: Added.
        * editing/deleting/5026848-1.html: Added.
        This tests to make sure that non-editable content
        that is not in both the start and end editable roots
        is not removed:
        * editing/deleting/5026848-2-expected.checksum: Added.
        * editing/deleting/5026848-2-expected.png: Added.
        * editing/deleting/5026848-2-expected.txt: Added.
        * editing/deleting/5026848-2.html: Added.
        This tests to make sure that editable regions 
        that are not in both the start and end editable roots
        are cleared (not removed, unless they are in another
        editable region):
        * editing/deleting/5026848-3-expected.checksum: Added.
        * editing/deleting/5026848-3-expected.png: Added.
        * editing/deleting/5026848-3-expected.txt: Added.
        * editing/deleting/5026848-3.html: Added.

WebCore:

        Reviewed by darin
        
        <rdar://problem/5026848> Can cut/delete ToDo subunits
        
        We were removing non-editable content during a delete.

        * editing/DeleteSelectionCommand.cpp: 
        (WebCore::DeleteSelectionCommand::initializePositionData): 
        Set m_startRoot and m_endRoot.
        (WebCore::DeleteSelectionCommand::removeNode): If a node
        is not inside both the start and end roots, remove it only
        if it is in editable content.
        * editing/DeleteSelectionCommand.h: Added m_startRoot and 
        m_endRoot, the editable roots that contain the start and end
        of the selection, respectively.  We consult these every
        time we remove a node, and don't want to recompute them 
        on every call to removeNode().



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@20707 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 47ee8bc0
2007-04-03 Justin Garcia <justin.garcia@apple.com>
Reviewed by darin
<rdar://problem/5026848> Can cut/delete To Do subunits
This tests to make sure that non-editable content
that is in both the start and end editable roots
is removed:
* editing/deleting/5026848-1-expected.checksum: Added.
* editing/deleting/5026848-1-expected.png: Added.
* editing/deleting/5026848-1-expected.txt: Added.
* editing/deleting/5026848-1.html: Added.
This tests to make sure that non-editable content
that is not in both the start and end editable roots
is not removed:
* editing/deleting/5026848-2-expected.checksum: Added.
* editing/deleting/5026848-2-expected.png: Added.
* editing/deleting/5026848-2-expected.txt: Added.
* editing/deleting/5026848-2.html: Added.
This tests to make sure that editable regions
that are not in both the start and end editable roots
are cleared (not removed, unless they are in another
editable region):
* editing/deleting/5026848-3-expected.checksum: Added.
* editing/deleting/5026848-3-expected.png: Added.
* editing/deleting/5026848-3-expected.txt: Added.
* editing/deleting/5026848-3.html: Added.
2007-04-03 Anders Carlsson <andersca@apple.com>
Reviewed by Adam.
07421e18a1ed6f8d8061551cf40f4840
\ No newline at end of file
layer at (0,0) size 800x600
RenderView 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 {P} at (0,0) size 784x36
RenderText {#text} at (0,0) size 746x36
text run at (0,0) width 577: "This tests the deletion of non-editable content that is in both the start and end editable roots. "
text run at (577,0) width 141: "It should be removed. "
text run at (718,0) width 28: "You"
text run at (0,18) width 323: "shouldn't see anything in the editable region below."
RenderBlock {DIV} at (0,52) size 784x18
RenderBR {BR} at (0,0) size 0x18
caret: position 0 of child 0 {BR} of child 3 {DIV} of child 0 {BODY} of child 0 {HTML} of document
<html>
<body>
<p>This tests the deletion of non-editable content that is in both the start and end editable roots. It should be removed. You shouldn't see anything in the editable region below.</p>
<div id="div" contenteditable="true">foo <span style="color: red;" contenteditable="false">bar</span> baz</div>
<script>
var div = document.getElementById("div");
div.focus();
document.execCommand("SelectAll");
document.execCommand("Delete");
</script>
</body>
</html>
\ No newline at end of file
1925325ef015b138ba0c501485d9df65
\ No newline at end of file
layer at (0,0) size 800x600
RenderView 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 {P} at (0,0) size 784x36
RenderText {#text} at (0,0) size 758x36
text run at (0,0) width 758: "This tests to see that selected non-editable nodes that are not in both the start and end editable root are preserved during a"
text run at (0,18) width 58: "deletion. "
text run at (58,18) width 526: "You should see two 'Non-editable' pieces on either side of the editable piece below."
RenderBlock {DIV} at (0,52) size 784x24
RenderTable {TABLE} at (0,0) size 280x24
RenderTableSection {TBODY} at (0,0) size 280x24
RenderTableRow {TR} at (0,2) size 280x20
RenderTableCell {TD} at (2,2) size 84x20 [r=0 c=0 rs=1 cs=1]
RenderText {#text} at (1,1) size 82x18
text run at (1,1) width 82: "Non-editable"
RenderTableCell {TD} at (88,2) size 104x20 [r=0 c=1 rs=1 cs=1]
RenderText {#text} at (1,1) size 56x18
text run at (1,1) width 56: "Editable "
RenderInline {SPAN} at (0,0) size 46x18
RenderText {#text} at (57,1) size 46x18
text run at (57,1) width 46: "content"
RenderTableCell {TD} at (194,2) size 84x20 [r=0 c=2 rs=1 cs=1]
RenderText {#text} at (1,1) size 82x18
text run at (1,1) width 82: "Non-editable"
RenderBlock (anonymous) at (0,24) size 784x0
caret: position 9 of child 0 {#text} of child 1 {TD} of child 0 {TR} of child 1 {TBODY} of child 1 {TABLE} of child 3 {DIV} of child 0 {BODY} of child 0 {HTML} of document
<html>
<body>
<p>This tests to see that selected non-editable nodes that are not in both the start and end editable root are preserved during a deletion. You should see two 'Non-editable' pieces on either side of the editable piece below.</p>
<div id="div" contenteditable="true">
<table contenteditable="false">
<tr>
<td>Non-editable</td>
<td contenteditable="true">Editable <span id="start">content</span></td>
<td>Non-editable</td>
</tr>
</table>
Editable <span id="end">content</span>
</div>
<script>
var sel = window.getSelection();
var start = document.getElementById("start");
var end = document.getElementById("end");
sel.setBaseAndExtent(start, 0, end, 0);
document.execCommand("Delete");
</script>
</body>
</html>
e2168fe795fd036019af2bdafd84a4d6
\ No newline at end of file
layer at (0,0) size 800x600
RenderView 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 {P} at (0,0) size 784x72
RenderText {#text} at (0,0) size 777x72
text run at (0,0) width 671: "This tests to see that selected editable nodes that are not in both the start and end editable roots are cleared. "
text run at (671,0) width 98: "You should see"
text run at (0,18) width 471: "one non-editable piece and an editable one and then two empty table cells. "
text run at (471,18) width 306: "The table cells are editable but are preserved and"
text run at (0,36) width 348: "not removed because they are in a non-editable region. "
text run at (348,36) width 407: "They should be completely cleared out, even the second one that"
text run at (0,54) width 186: "contains a non-editable piece."
RenderBlock {DIV} at (0,88) size 784x28
RenderTable {TABLE} at (0,0) size 212x28 [border: (1px outset #808080)]
RenderTableSection {TBODY} at (1,1) size 210x26
RenderTableRow {TR} at (0,2) size 210x22
RenderTableCell {TD} at (2,2) size 86x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
RenderText {#text} at (2,2) size 82x18
text run at (2,2) width 82: "Non-editable"
RenderTableCell {TD} at (90,2) size 106x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
RenderText {#text} at (2,2) size 56x18
text run at (2,2) width 56: "Editable "
RenderInline {SPAN} at (0,0) size 46x18
RenderText {#text} at (58,2) size 46x18
text run at (58,2) width 46: "content"
RenderTableCell {TD} at (198,2) size 4x22 [border: (1px inset #808080)] [r=0 c=2 rs=1 cs=1]
RenderTableCell {TD} at (204,2) size 4x22 [border: (1px inset #808080)] [r=0 c=3 rs=1 cs=1]
RenderBlock (anonymous) at (0,28) size 784x0
caret: position 9 of child 0 {#text} of child 1 {TD} of child 0 {TR} of child 1 {TBODY} of child 1 {TABLE} of child 3 {DIV} of child 0 {BODY} of child 0 {HTML} of document
<html>
<body>
<p>This tests to see that selected editable nodes that are not in both the start and end editable roots are cleared. You should see one non-editable piece and an editable one and then two empty table cells. The table cells are editable but are preserved and not removed because they are in a non-editable region. They should be completely cleared out, even the second one that contains a non-editable piece.</p>
<div id="div" contenteditable="true">
<table border="1" contenteditable="false">
<tr>
<td>Non-editable</td>
<td contenteditable="true">Editable <span id="start">content</span></td>
<!-- The following cell should be removed, even though it contains non-editable pieces. -->
<td contenteditable="true">Editable</td>
<td contenteditable="true">Edit<span contenteditable="false">(non-editable content that should be removed because its in an editable region)</span>able</td>
</tr>
</table>
Editable <span id="end">content</span>
</div>
<script>
var sel = window.getSelection();
var start = document.getElementById("start");
var end = document.getElementById("end");
sel.setBaseAndExtent(start, 0, end, 0);
document.execCommand("Delete");
</script>
</body>
</html>
2007-04-03 Justin Garcia <justin.garcia@apple.com>
Reviewed by darin
<rdar://problem/5026848> Can cut/delete ToDo subunits
We were removing non-editable content during a delete.
* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::initializePositionData):
Set m_startRoot and m_endRoot.
(WebCore::DeleteSelectionCommand::removeNode): If a node
is not inside both the start and end roots, remove it only
if it is in editable content.
* editing/DeleteSelectionCommand.h: Added m_startRoot and
m_endRoot, the editable roots that contain the start and end
of the selection, respectively. We consult these every
time we remove a node, and don't want to recompute them
on every call to removeNode().
2007-04-03 David Hyatt <hyatt@apple.com>
Fix for <rdar://problem/5108896>, make sure the assert for setEncodedSize
......@@ -129,6 +129,9 @@ void DeleteSelectionCommand::initializePositionData()
m_upstreamEnd = end.upstream();
m_downstreamEnd = end.downstream();
m_startRoot = editableRootForPosition(start);
m_endRoot = editableRootForPosition(end);
Node* startCell = enclosingTableCell(m_upstreamStart.node());
Node* endCell = enclosingTableCell(m_downstreamEnd.node());
// Don't move content out of a table cell.
......@@ -238,6 +241,31 @@ static void updatePositionForNodeRemoval(Node* node, Position& position)
void DeleteSelectionCommand::removeNode(Node *node)
{
if (!node)
return;
if (m_startRoot != m_endRoot && !(node->isDescendantOf(m_startRoot.get()) && node->isDescendantOf(m_endRoot.get()))) {
// If a node is not in both the start and end editable roots, remove it only if its inside an editable region.
if (!node->parentNode()->isContentEditable()) {
// Don't remove non-editable atomic nodes.
if (!node->firstChild())
return;
// Search this non-editable region for editable regions to empty.
RefPtr<Node> child = node->firstChild();
while (child) {
RefPtr<Node> nextChild = child->nextSibling();
removeNode(child.get());
// Bail if nextChild is no longer node's child.
if (nextChild && nextChild->parentNode() != node)
return;
child = nextChild;
}
// Don't remove editable regions that are inside non-editable ones, just clear them.
return;
}
}
if (isTableStructureNode(node) || node == node->rootEditableElement()) {
// Do not remove an element of table structure; remove its contents.
// Likewise for the root editable element.
......
......@@ -76,6 +76,8 @@ private:
RefPtr<Node> m_endBlock;
RefPtr<CSSMutableStyleDeclaration> m_typingStyle;
RefPtr<CSSMutableStyleDeclaration> m_deleteIntoBlockquoteStyle;
RefPtr<Node> m_startRoot;
RefPtr<Node> m_endRoot;
};
} // namespace WebCore
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment