Commit 503ccf17 authored by justing's avatar justing

Reviewed by geoff

        Fixed problem with patch that I just backed out

        Test cases added:
        * layout-tests/editing/deleting/delete-4038408-fix-expected.txt: Added.
        * layout-tests/editing/deleting/delete-4038408-fix.html: Added.

        * khtml/editing/delete_selection_command.cpp:
        (khtml::DeleteSelectionCommand::DeleteSelectionCommand):
        (khtml::DeleteSelectionCommand::saveTypingStyleState):
        (khtml::DeleteSelectionCommand::calculateTypingStyleAfterDelete):
        (khtml::DeleteSelectionCommand::clearTransientState):
        * khtml/editing/delete_selection_command.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@9955 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0bf3c211
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 784x204 [border: (2px solid #FF0000)]
RenderBlock {DIV} at (14,14) size 756x18
RenderText {TEXT} at (0,0) size 46x18
text run at (0,0) width 46: "Radar: "
RenderInline {A} at (0,0) size 359x18 [color=#0000EE]
RenderText {TEXT} at (46,0) size 359x18
text run at (46,0) width 359: "rdar://problems/4038408&4154187&4125087&4125381"
RenderBlock {DIV} at (14,32) size 756x18
RenderText {TEXT} at (0,0) size 674x18
text run at (0,0) width 674: "Deletion of reply text should not produce reply text style unless the caret is inside the reply text blockquote."
RenderBlock {DIV} at (14,50) size 756x18
RenderBR {BR} at (0,0) size 0x18
RenderBlock {DIV} at (14,68) size 756x18
RenderText {TEXT} at (0,0) size 299x18
text run at (0,0) width 299: "This tests deletion from underneath quoted text:"
RenderBlock {DIV} at (14,86) size 756x18
RenderBR {BR} at (0,0) size 0x18
RenderBlock {DIV} at (14,104) size 756x86
RenderBlock {BLOCKQUOTE} at (0,0) size 756x68 [color=#0000FF] [border: (2px solid #0000FF)]
RenderBlock {DIV} at (18,16) size 722x18
RenderText {TEXT} at (0,0) size 145x18
text run at (0,0) width 145: "Here is some reply text"
RenderBlock {DIV} at (18,34) size 722x18
RenderText {TEXT} at (0,0) size 208x18
text run at (0,0) width 208: "It should have the reply text style"
RenderBlock {DIV} at (0,68) size 756x18
RenderText {TEXT} at (0,0) size 354x18
text run at (0,0) width 354: "This text should not have the same style as the reply text"
RenderBR {BR} at (0,0) size 0x0
caret: position 58 of child 0 {TEXT} of child 2 {DIV} of child 11 {DIV} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
<html>
<head>
<style>
.editing {
border: 2px solid red;
padding: 12px;
}
blockquote {
border-left: 2px solid blue;
padding: 1em;
margin: 0;
}
</style>
<script src="../editing.js" language="JavaScript" type="text/JavaScript" ></script>
<script>
function editingTest() {
selectAllCommand();
moveSelectionForwardByCharacterCommand();
deleteCommand();
deleteCommand();
var string;
string = "This is some text";
for(i = 0; i < string.length; i++)
typeCharacterCommand(string[i]);
for(i = 0; i < string.length; i++)
extendSelectionBackwardByCharacterCommand();
deleteCommand();
deleteCommand();
string = "This text should not have the same style as the reply text";
for(i = 0; i < string.length; i++)
typeCharacterCommand(string[i]);
}
</script>
<title>Editing Test</title>
</head>
<body>
<div contenteditable id="root" class="editing">
<div>Radar: <a href="rdar://problems/4038408&4154187&4125087&4125381">rdar://problems/4038408&4154187&4125087&4125381</a></div>
<div>Deletion of reply text should not produce reply text style unless the caret is inside the reply text blockquote.</div>
<div><BR class=3D"khtml-block-placeholder"></div>
<div>This tests deletion from underneath quoted text:</div>
<div><BR class=3D"khtml-block-placeholder"></div>
<div>
<blockquote style="color:blue;" type="cite">
<div>Here is some reply text</div>
<div>It should have the reply text style</div>
<div><BR class=3D"khtml-block-placeholder"></div>
<div><BR class=3D"khtml-block-placeholder"></div>
<div><BR class=3D"khtml-block-placeholder"></div>
</blockquote>
<div><BR class=3D"khtml-block-placeholder"></div>
</div>
</div>
</div>
</div>
<script>
runEditingTest();
</script>
</body>
</html>
2005-07-29 Justin Garcia <justin.garcia@apple.com>
Reviewed by geoff
Fixed problem with patch that I just backed out
Test cases added:
* layout-tests/editing/deleting/delete-4038408-fix-expected.txt: Added.
* layout-tests/editing/deleting/delete-4038408-fix.html: Added.
* khtml/editing/delete_selection_command.cpp:
(khtml::DeleteSelectionCommand::DeleteSelectionCommand):
(khtml::DeleteSelectionCommand::saveTypingStyleState):
(khtml::DeleteSelectionCommand::calculateTypingStyleAfterDelete):
(khtml::DeleteSelectionCommand::clearTransientState):
* khtml/editing/delete_selection_command.h:
2005-07-29 Geoffrey Garen <ggaren@apple.com>
- Oops. Last checkin omitted the actual test for:
......@@ -129,7 +129,8 @@ DeleteSelectionCommand::DeleteSelectionCommand(DocumentImpl *document, bool smar
m_startBlock(0),
m_endBlock(0),
m_startNode(0),
m_typingStyle(0)
m_typingStyle(0),
m_deleteIntoBlockquoteStyle(0)
{
}
......@@ -142,7 +143,8 @@ DeleteSelectionCommand::DeleteSelectionCommand(DocumentImpl *document, const Sel
m_startBlock(0),
m_endBlock(0),
m_startNode(0),
m_typingStyle(0)
m_typingStyle(0),
m_deleteIntoBlockquoteStyle(0)
{
}
......@@ -278,6 +280,17 @@ void DeleteSelectionCommand::saveTypingStyleState()
m_typingStyle = computedStyle->copyInheritableProperties();
m_typingStyle->ref();
computedStyle->deref();
// If we're deleting into a Mail blockquote, save the style at end() instead of start()
// We'll use this later in computeTypingStyleAfterDelete if we end up outside of a Mail blockquote
if (nearestMailBlockquote(m_selectionToDelete.start().node())) {
computedStyle = m_selectionToDelete.end().computedStyle();
computedStyle->ref();
m_deleteIntoBlockquoteStyle = computedStyle->copyInheritableProperties();
m_deleteIntoBlockquoteStyle->ref();
computedStyle->deref();
} else
m_deleteIntoBlockquoteStyle = 0;
}
bool DeleteSelectionCommand::handleSpecialCaseBRDelete()
......@@ -629,6 +642,20 @@ void DeleteSelectionCommand::calculateTypingStyleAfterDelete(NodeImpl *insertedP
// has completed.
// FIXME: Improve typing style.
// See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
if (m_deleteIntoBlockquoteStyle) {
// If we deleted into a blockquote, but are now no longer in a blockquote, use the alternate typing style
if (!nearestMailBlockquote(m_endingPosition.node())) {
CSSMutableStyleDeclarationImpl *oldStyle = m_typingStyle;
m_typingStyle = m_deleteIntoBlockquoteStyle;
m_deleteIntoBlockquoteStyle = 0;
oldStyle->deref();
} else {
m_deleteIntoBlockquoteStyle->deref();
m_deleteIntoBlockquoteStyle = 0;
}
}
CSSComputedStyleDeclarationImpl endingStyle(m_endingPosition.node());
endingStyle.diff(m_typingStyle);
if (!m_typingStyle->length()) {
......@@ -687,6 +714,10 @@ void DeleteSelectionCommand::clearTransientState()
m_typingStyle->deref();
m_typingStyle = 0;
}
if (m_deleteIntoBlockquoteStyle) {
m_deleteIntoBlockquoteStyle->deref();
m_deleteIntoBlockquoteStyle = 0;
}
}
void DeleteSelectionCommand::doApply()
......
......@@ -73,6 +73,7 @@ private:
DOM::NodeImpl *m_endBlock;
DOM::NodeImpl *m_startNode;
DOM::CSSMutableStyleDeclarationImpl *m_typingStyle;
DOM::CSSMutableStyleDeclarationImpl *m_deleteIntoBlockquoteStyle;
};
} // namespace khtml
......
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