Commit 7548ac64 authored by adele@apple.com's avatar adele@apple.com

2009-04-13 Adele Peterson <adele@apple.com>

        Reviewed by Darin Adler.

        Fix for <rdar://problem/6703873> Triple-click quoted line and type Return creates an extra quoted blank line

        Test: editing/inserting/6703873.html

        * editing/BreakBlockquoteCommand.cpp: (WebCore::BreakBlockquoteCommand::doApply):
        If the startNode's original parent is now empty, we can remove it.  Its already been cloned and copied with the startNode,
        so we only need to keep it around if it actually holds some original content, otherwise it will look like an extra empty 
        container in the document.



git-svn-id: svn://svn.chromium.org/blink/trunk@42501 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 5f89b581
<html>
<head>
<style>
blockquote {
color: blue;
border-left: 2px solid blue;
margin: 0px;
padding-left: 10px;
}
</style>
<script>
function log(msg)
{
document.getElementById('console').appendChild(document.createTextNode(msg + '\n'));
}
function test()
{
var s = window.getSelection();
s.setPosition(document.getElementById('qt'), 0);
s.modify("extend", "forward", "line");
document.execCommand("InsertNewlineInQuotedContent");
document.execCommand("InsertText", "true", "unquoted");
}
</script>
</head>
<body onload="test()">
<p>This tests that inserting a newline in place of a full line of quoted content doesn't add an extra quoted line. The test has passed if there are no empty lines (quoted or unquoted) in the box below.</p>
<div contenteditable="true">
<blockquote type="cite"><div>quoted</div><div id="qt">quoted</div><div>quoted</div></blockquote>
</div>
<pre id="console"></pre>
</body>
</html>
dc7a17a8c6bb8f316c95ef426b30c5af
\ 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 784x579
RenderBlock {P} at (0,0) size 784x36
RenderText {#text} at (0,0) size 742x36
text run at (0,0) width 667: "This tests that inserting a newline in place of a full line of quoted content doesn't add an extra quoted line. "
text run at (667,0) width 75: "The test has"
text run at (0,18) width 460: "passed if there are no empty lines (quoted or unquoted) in the box below."
RenderBlock {DIV} at (0,52) size 784x54
RenderBlock {BLOCKQUOTE} at (0,0) size 784x18 [color=#0000FF] [border: (2px solid #0000FF)]
RenderBlock {DIV} at (12,0) size 772x18
RenderText {#text} at (0,0) size 43x18
text run at (0,0) width 43: "quoted"
RenderBlock {DIV} at (12,18) size 772x0
RenderBlock (anonymous) at (0,18) size 784x18
RenderText {#text} at (0,0) size 59x18
text run at (0,0) width 59: "unquoted"
RenderBR {BR} at (59,14) size 0x0
RenderBlock {BLOCKQUOTE} at (0,36) size 784x18 [color=#0000FF] [border: (2px solid #0000FF)]
RenderBlock {DIV} at (12,0) size 772x18
RenderText {#text} at (0,0) size 43x18
text run at (0,0) width 43: "quoted"
RenderBlock {PRE} at (0,119) size 784x0
caret: position 8 of child 2 {#text} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
2009-04-13 Adele Peterson <adele@apple.com>
Reviewed by Darin Adler.
Fix for <rdar://problem/6703873> Triple-click quoted line and type Return creates an extra quoted blank line
Test: editing/inserting/6703873.html
* editing/BreakBlockquoteCommand.cpp: (WebCore::BreakBlockquoteCommand::doApply):
If the startNode's original parent is now empty, we can remove it. Its already been cloned and copied with the startNode,
so we only need to keep it around if it actually holds some original content, otherwise it will look like an extra empty
container in the document.
2009-04-14 Xan Lopez <xlopez@igalia.com>
Reviewed by Holger Freyther.
......@@ -82,7 +82,7 @@ void BreakBlockquoteCommand::doApply()
// If we're inserting the break at the end of the quoted content, we don't need to break the quote.
if (isLastVisiblePositionInNode(visiblePos, topBlockquote)) {
setEndingSelection(VisibleSelection(Position(breakNode.get(), 0), DOWNSTREAM));
rebalanceWhitespace();
rebalanceWhitespace();
return;
}
......@@ -157,10 +157,7 @@ void BreakBlockquoteCommand::doApply()
moveNode = next;
}
// Hold open startNode's original parent if we emptied it
if (!ancestors.isEmpty()) {
addBlockPlaceholderIfNeeded(ancestors.first());
// Split the tree up the ancestor chain until the topBlockquote
// Throughout this loop, clonedParent is the clone of ancestor's parent.
// This is so we can clone ancestor's siblings and place the clones
......@@ -178,6 +175,11 @@ void BreakBlockquoteCommand::doApply()
moveNode = next;
}
}
// If the startNode's original parent is now empty, remove it
Node* originalParent = ancestors.first();
if (!originalParent->hasChildNodes())
removeNode(originalParent);
}
// Make sure the cloned block quote renders.
......
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