[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

adele at apple.com adele at apple.com
Thu Oct 29 20:50:43 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit b9149f88cde07360ea607f41d47162895b336e3c
Author: adele at apple.com <adele at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Oct 23 19:00:02 2009 +0000

    REGRESSION: Copy is copying incorrect background-color
    <rdar://problem/7248529>
    https://bugs.webkit.org/show_bug.cgi?id=29697
    
    Patch by Enrica Casucci <enrica at apple.com> on 2009-10-23
    Reviewed by Adele Peterson.
    
    WebCore:
    
    Test: editing/execCommand/indent-paragraphs.html
    
    This change removes the BackgroundColor from the list
    of inheritable CSS properties and changes significantly
    the way we perform indentation.
    The new implementation of IndentOutdentCommand uses a new method
    defined in CompositeEditCommand called moveParagraphWithClones.
    This is an improved version of the original moveParagraph that
    is aimed at preserving the original markup of the paragraph being
    moved.
    
    * editing/ApplyStyleCommand.cpp:
    (WebCore::): removed CSSPropertyBackgroundColor from editingStyleProperties.
    * editing/CompositeEditCommand.cpp:
    (WebCore::CompositeEditCommand::CompositeEditCommand): Removed trailing blanks.
    (WebCore::CompositeEditCommand::rebalanceWhitespaceAt): Removed trailing blanks.
    (WebCore::CompositeEditCommand::cloneParagraphUnderNewElement): Added.
    (WebCore::CompositeEditCommand::cleanupAfterDeletion): Added.
    (WebCore::CompositeEditCommand::moveParagraphWithClones): Added.
    (WebCore::CompositeEditCommand::moveParagraphs): Modified to use cleanupAfterDeletion.
    (WebCore::CompositeEditCommand::breakOutOfEmptyListItem): Removed trailing blanks.
    (WebCore::CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph): Removed trailing blanks.
    (WebCore::CompositeEditCommand::positionAvoidingSpecialElementBoundary): Removed trailing blanks.
    * editing/CompositeEditCommand.h: Added three new methods.
    * editing/IndentOutdentCommand.cpp:
    (WebCore::IndentOutdentCommand::tryIndentingAsListItem): Changed to use moveParagraphWithClones.
    (WebCore::IndentOutdentCommand::indentIntoBlockquote): Changed to use moveParagraphWithClones.
    (WebCore::IndentOutdentCommand::indentRegion): Removed comment.
    * editing/IndentOutdentCommand.h: Removed prepareBlockquoteLevelForInsertion method.
    
    LayoutTests:
    
    All the following tests have been re-baselined because
    the indent command now preserves the original markup.
    A new test (indent-paragraph.html) has been added to test
    several indent combinations not covered by the existing tests.
    
    * editing/execCommand/19087-expected.txt:
    * editing/execCommand/19653-1-expected.txt:
    * editing/execCommand/indent-div-inside-list-expected.txt:
    * editing/execCommand/indent-nested-blockquotes-expected.txt:
    * editing/execCommand/indent-nested-div-expected.txt:
    * editing/execCommand/indent-paragraphs.html: Added.
    * editing/execCommand/indent-second-paragraph-in-blockquote-expected.txt:
    * editing/execCommand/indent-with-style-expected.txt:
    * editing/inserting/5994480-2-expected.txt:
    * platform/mac/editing/execCommand/4641880-2-expected.txt:
    * platform/mac/editing/execCommand/4916541-expected.txt:
    * platform/mac/editing/execCommand/5138441-expected.txt:
    * platform/mac/editing/execCommand/5481523-expected.txt:
    * platform/mac/editing/execCommand/indent-paragraphs-expected.txt: Added.
    * platform/mac/editing/execCommand/indent-selection-expected.txt:
    * platform/mac/editing/pasteboard/select-element-1-expected.txt:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49985 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 48cb0ce..e540a77 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,33 @@
+2009-10-23  Enrica Casucci  <enrica at apple.com>
+
+        Reviewed by Adele Peterson.
+
+        REGRESSION: Copy is copying incorrect background-color
+        <rdar://problem/7248529>
+        https://bugs.webkit.org/show_bug.cgi?id=29697
+
+        All the following tests have been re-baselined because
+        the indent command now preserves the original markup.
+        A new test (indent-paragraph.html) has been added to test
+        several indent combinations not covered by the existing tests.
+        
+        * editing/execCommand/19087-expected.txt:
+        * editing/execCommand/19653-1-expected.txt:
+        * editing/execCommand/indent-div-inside-list-expected.txt:
+        * editing/execCommand/indent-nested-blockquotes-expected.txt:
+        * editing/execCommand/indent-nested-div-expected.txt:
+        * editing/execCommand/indent-paragraphs.html: Added.
+        * editing/execCommand/indent-second-paragraph-in-blockquote-expected.txt:
+        * editing/execCommand/indent-with-style-expected.txt:
+        * editing/inserting/5994480-2-expected.txt:
+        * platform/mac/editing/execCommand/4641880-2-expected.txt:
+        * platform/mac/editing/execCommand/4916541-expected.txt:
+        * platform/mac/editing/execCommand/5138441-expected.txt:
+        * platform/mac/editing/execCommand/5481523-expected.txt:
+        * platform/mac/editing/execCommand/indent-paragraphs-expected.txt: Added.
+        * platform/mac/editing/execCommand/indent-selection-expected.txt:
+        * platform/mac/editing/pasteboard/select-element-1-expected.txt:
+
 2009-10-23  Brian Weinstein  <bweinstein at apple.com>
 
         Rubber-stamped by Sam Weinig.
diff --git a/LayoutTests/editing/execCommand/19087-expected.txt b/LayoutTests/editing/execCommand/19087-expected.txt
index d382064..3211e80 100644
--- a/LayoutTests/editing/execCommand/19087-expected.txt
+++ b/LayoutTests/editing/execCommand/19087-expected.txt
@@ -3,3 +3,5 @@ This tests for a crash when indenting a particular selection that contains a blo
 
 
 
+
+
diff --git a/LayoutTests/editing/execCommand/19653-1-expected.txt b/LayoutTests/editing/execCommand/19653-1-expected.txt
index c983683..e9867fc 100644
--- a/LayoutTests/editing/execCommand/19653-1-expected.txt
+++ b/LayoutTests/editing/execCommand/19653-1-expected.txt
@@ -5,7 +5,7 @@ This tests creating a list from an empty paragraph when the typing style was Bol
 <ul><li><b>Bold</b></li></ul>
 
 This tests indenting an empty paragraph with bold already applied to it. The word below should be bold.
-<blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><b>Bold</b></blockquote>
+<blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><b>Bold</b></div></blockquote>
 
 This tests indenting an empty paragraph when the typing style was Bold. The word below should be bold.
 <blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><b>Bold</b></blockquote>
diff --git a/LayoutTests/editing/execCommand/indent-div-inside-list-expected.txt b/LayoutTests/editing/execCommand/indent-div-inside-list-expected.txt
index 368ecb2..39012bb 100644
--- a/LayoutTests/editing/execCommand/indent-div-inside-list-expected.txt
+++ b/LayoutTests/editing/execCommand/indent-div-inside-list-expected.txt
@@ -4,4 +4,4 @@ a
 hello
 world
 b
-a <ul> <li>hello</li></ul><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">world</blockquote> b
+a <ul> <li>hello<div id="test"><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"> world </blockquote></div></li></ul> b
diff --git a/LayoutTests/editing/execCommand/indent-nested-blockquotes-expected.txt b/LayoutTests/editing/execCommand/indent-nested-blockquotes-expected.txt
index 847d021..71b2bd4 100644
--- a/LayoutTests/editing/execCommand/indent-nested-blockquotes-expected.txt
+++ b/LayoutTests/editing/execCommand/indent-nested-blockquotes-expected.txt
@@ -4,4 +4,4 @@ hello
 world
 webkit
 is great
-<blockquote id="outer"> hello <blockquote id="inner"> world<br></blockquote></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">webkit</blockquote></blockquote></blockquote><blockquote id="outer"> is great </blockquote>
+<blockquote id="outer"> hello <blockquote id="inner"> world<br></blockquote></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><blockquote id="outer"><blockquote id="inner"> webkit </blockquote></blockquote></blockquote><blockquote id="outer"> is great </blockquote>
diff --git a/LayoutTests/editing/execCommand/indent-nested-div-expected.txt b/LayoutTests/editing/execCommand/indent-nested-div-expected.txt
index 89e572b..20f5e13 100644
--- a/LayoutTests/editing/execCommand/indent-nested-div-expected.txt
+++ b/LayoutTests/editing/execCommand/indent-nested-div-expected.txt
@@ -1,4 +1,4 @@
 This tests indenting nested divs. By indenting "hello", we should be able to enclose all three blocks 1 through 3 by a blockquote
 
 hello
-<blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">hello</blockquote>
+<blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div id="block1"><div id="block2"><div id="block3">hello</div></div></div></blockquote>
diff --git a/LayoutTests/editing/execCommand/indent-paragraphs.html b/LayoutTests/editing/execCommand/indent-paragraphs.html
new file mode 100644
index 0000000..7267fc9
--- /dev/null
+++ b/LayoutTests/editing/execCommand/indent-paragraphs.html
@@ -0,0 +1,35 @@
+<html>
+<head>
+    <script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+</head>
+<body>
+This tests indenting three paragraphs with different hierarchies.
+<div id="root" contenteditable="true">
+<div id="test">
+    <div><span class="Apple-style-span" style="background-color: rgb(255, 0, 0);">Hello <img src="http://"> world</span></div>
+    <div>Hello <img src="http://"> world</span></div>
+    Hello <img src="http://"> world
+</div>
+</div>
+<br>
+<ul>
+<li>Before indent:<span id="c1"></span></li>
+<li>After indent:<span id="c2"></span></li>
+</ul>
+
+<script type="text/javascript">
+function editingTest()
+{
+    var e = document.getElementById('root');
+
+    document.execCommand("SelectAll");
+    document.getElementById('c1').appendChild(document.createTextNode(e.innerHTML));
+
+    document.execCommand("Indent");
+    document.getElementById('c2').appendChild(document.createTextNode(e.innerHTML));
+}
+
+runEditingTest();
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/execCommand/indent-second-paragraph-in-blockquote-expected.txt b/LayoutTests/editing/execCommand/indent-second-paragraph-in-blockquote-expected.txt
index 2a4a5af..e5b3d53 100644
--- a/LayoutTests/editing/execCommand/indent-second-paragraph-in-blockquote-expected.txt
+++ b/LayoutTests/editing/execCommand/indent-second-paragraph-in-blockquote-expected.txt
@@ -2,4 +2,4 @@ This tests indenting the second paragraph in a blockquote. By indenting "world",
 
 hello
 world
-<blockquote id="test"> hello<br></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">world</blockquote></blockquote>
+<blockquote id="test"> hello<br></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><blockquote id="test"> world </blockquote></blockquote>
diff --git a/LayoutTests/editing/execCommand/indent-with-style-expected.txt b/LayoutTests/editing/execCommand/indent-with-style-expected.txt
index c774fae..f3c2f72 100644
--- a/LayoutTests/editing/execCommand/indent-with-style-expected.txt
+++ b/LayoutTests/editing/execCommand/indent-with-style-expected.txt
@@ -2,7 +2,7 @@ EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML
 EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > SPAN > BLOCKQUOTE > DIV > BODY > HTML > #document to 5 of #text > SPAN > BLOCKQUOTE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > SPAN > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document to 5 of #text > SPAN > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 This tests indenting two and three. You should see two and three indented and with the same background color as one and four.
@@ -14,4 +14,4 @@ three
 four
 
 Before ordered list: <div><span class="Apple-style-span" style="background-color: rgb(255, 0, 0);">one</span></div> <div id="test1"><span class="Apple-style-span" style="background-color: rgb(255, 0, 0);">two</span></div> <div id="test2"><span class="Apple-style-span" style="background-color: rgb(255, 0, 0);">three</span></div> <div><span class="Apple-style-span" style="background-color: rgb(255, 0, 0);">four</span></div>
-After ordered: <div><span class="Apple-style-span" style="background-color: rgb(255, 0, 0);">one</span></div> <blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><span class="Apple-style-span" style="background-color: rgb(255, 0, 0); ">two</span><br><span class="Apple-style-span" style="background-color: rgb(255, 0, 0); ">three</span></blockquote> <div><span class="Apple-style-span" style="background-color: rgb(255, 0, 0);">four</span></div>
+After ordered: <div><span class="Apple-style-span" style="background-color: rgb(255, 0, 0);">one</span></div> <blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div id="test1"><span class="Apple-style-span" style="background-color: rgb(255, 0, 0);">two</span></div><div id="test2"><span class="Apple-style-span" style="background-color: rgb(255, 0, 0);">three</span></div></blockquote> <div><span class="Apple-style-span" style="background-color: rgb(255, 0, 0);">four</span></div>
diff --git a/LayoutTests/editing/inserting/5994480-2-expected.txt b/LayoutTests/editing/inserting/5994480-2-expected.txt
index 5a360f2..224592b 100644
--- a/LayoutTests/editing/inserting/5994480-2-expected.txt
+++ b/LayoutTests/editing/inserting/5994480-2-expected.txt
@@ -1 +1 @@
-<font class="Apple-style-span" face="'Lucida Grande'" size="3"><span class="Apple-style-span" style="background-color: rgb(255, 255, 255); font-size: 11px;"><br></span></font>
+<font class="Apple-style-span" face="'Lucida Grande'" size="3"><span class="Apple-style-span" style="font-size: 11px;"><br></span></font>
diff --git a/LayoutTests/platform/mac/editing/execCommand/4641880-2-expected.txt b/LayoutTests/platform/mac/editing/execCommand/4641880-2-expected.txt
index 3f85c54..6d229ff 100644
--- a/LayoutTests/platform/mac/editing/execCommand/4641880-2-expected.txt
+++ b/LayoutTests/platform/mac/editing/execCommand/4641880-2-expected.txt
@@ -3,7 +3,7 @@ EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > BLOCKQUOTE > DIV > BODY > HTML > #document to 34 of #text > BLOCKQUOTE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > BLOCKQUOTE > DIV > BODY > HTML > #document to 35 of #text > BLOCKQUOTE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 layer at (0,0) size 800x600
@@ -24,5 +24,5 @@ layer at (0,0) size 800x600
           RenderText {#text} at (0,0) size 246x18
             text run at (0,0) width 246: "This paragraph should not be indented."
           RenderBR {BR} at (246,14) size 0x0
-selection start: position 0 of child 0 {#text} of child 0 {BLOCKQUOTE} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
-selection end:   position 34 of child 0 {#text} of child 0 {BLOCKQUOTE} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+selection start: position 1 of child 0 {#text} of child 0 {BLOCKQUOTE} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+selection end:   position 35 of child 0 {#text} of child 0 {BLOCKQUOTE} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/platform/mac/editing/execCommand/4916541-expected.txt b/LayoutTests/platform/mac/editing/execCommand/4916541-expected.txt
index 64a6293..ca5aeab 100644
--- a/LayoutTests/platform/mac/editing/execCommand/4916541-expected.txt
+++ b/LayoutTests/platform/mac/editing/execCommand/4916541-expected.txt
@@ -10,11 +10,13 @@ layer at (0,0) size 800x600
           text run at (0,18) width 320: "'foo' and 'bar' before and after the indent operation."
       RenderBlock {DIV} at (0,52) size 784x36
         RenderBlock {BLOCKQUOTE} at (40,0) size 744x36
-          RenderText {#text} at (0,0) size 21x18
-            text run at (0,0) width 21: "foo"
-          RenderBR {BR} at (21,14) size 0x0
-          RenderText {#text} at (0,18) size 20x18
-            text run at (0,18) width 20: "bar"
+          RenderInline {SPAN} at (0,0) size 21x18
+            RenderText {#text} at (0,0) size 21x18
+              text run at (0,0) width 21: "foo"
+            RenderBR {BR} at (21,14) size 0x0
+          RenderInline {SPAN} at (0,0) size 20x18
+            RenderText {#text} at (0,18) size 20x18
+              text run at (0,18) width 20: "bar"
         RenderBlock (anonymous) at (0,36) size 784x0
-selection start: position 1 of child 0 {#text} of child 0 {BLOCKQUOTE} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
-selection end:   position 2 of child 2 {#text} of child 0 {BLOCKQUOTE} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+selection start: position 1 of child 0 {#text} of child 0 {SPAN} of child 0 {BLOCKQUOTE} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+selection end:   position 2 of child 0 {#text} of child 1 {SPAN} of child 0 {BLOCKQUOTE} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/platform/mac/editing/execCommand/5138441-expected.txt b/LayoutTests/platform/mac/editing/execCommand/5138441-expected.txt
index 5cc3798..69948fb 100644
--- a/LayoutTests/platform/mac/editing/execCommand/5138441-expected.txt
+++ b/LayoutTests/platform/mac/editing/execCommand/5138441-expected.txt
@@ -11,9 +11,10 @@ layer at (0,0) size 800x600
           text run at (0,36) width 149: "to implement indenting."
       RenderBlock {DIV} at (0,70) size 784x62
         RenderBlock {BLOCKQUOTE} at (40,0) size 744x18
-          RenderText {#text} at (0,0) size 230x18
-            text run at (0,0) width 230: "This should be indented, not quoted."
+          RenderBlock {DIV} at (0,0) size 744x18
+            RenderText {#text} at (0,0) size 230x18
+              text run at (0,0) width 230: "This should be indented, not quoted."
         RenderBlock {BLOCKQUOTE} at (8,26) size 768x36 [border: (1px dashed #AAAAAA)]
           RenderText {#text} at (9,9) size 175x18
             text run at (9,9) width 175: "This text should be Quoted."
-caret: position 0 of child 0 {#text} of child 1 {BLOCKQUOTE} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+caret: position 0 of child 0 {#text} of child 0 {DIV} of child 1 {BLOCKQUOTE} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/platform/mac/editing/execCommand/5481523-expected.txt b/LayoutTests/platform/mac/editing/execCommand/5481523-expected.txt
index 0d6de44..3fc2305 100644
--- a/LayoutTests/platform/mac/editing/execCommand/5481523-expected.txt
+++ b/LayoutTests/platform/mac/editing/execCommand/5481523-expected.txt
@@ -27,7 +27,6 @@ layer at (0,0) size 800x600
                   RenderTableCell {TD} at (45,26) size 34x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
                     RenderText {#text} at (2,2) size 30x18
                       text run at (2,2) width 30: "Four"
-            RenderBlock (anonymous) at (0,52) size 704x0
         RenderBlock (anonymous) at (0,52) size 784x0
 selection start: position 0 of child 0 {TABLE} of child 0 {BLOCKQUOTE} of child 1 {BLOCKQUOTE} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
-selection end:   position 1 of child 0 {TABLE} of child 0 {BLOCKQUOTE} of child 1 {BLOCKQUOTE} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+selection end:   position 2 of child 0 {TABLE} of child 0 {BLOCKQUOTE} of child 1 {BLOCKQUOTE} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/platform/mac/editing/execCommand/indent-paragraphs-expected.txt b/LayoutTests/platform/mac/editing/execCommand/indent-paragraphs-expected.txt
new file mode 100644
index 0000000..e37376b
--- /dev/null
+++ b/LayoutTests/platform/mac/editing/execCommand/indent-paragraphs-expected.txt
@@ -0,0 +1,68 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > SPAN > DIV > DIV > DIV > BODY > HTML > #document to 6 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > SPAN > DIV > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document to 6 of #text > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+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 784x576
+      RenderBlock (anonymous) at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 395x18
+          text run at (0,0) width 395: "This tests indenting three paragraphs with different hierarchies."
+      RenderBlock {DIV} at (0,18) size 784x72
+        RenderBlock {BLOCKQUOTE} at (40,0) size 744x72
+          RenderBlock {DIV} at (0,0) size 744x24
+            RenderBlock {DIV} at (0,0) size 744x24
+              RenderInline {SPAN} at (0,0) size 100x18 [bgcolor=#FF0000]
+                RenderText {#text} at (0,6) size 39x18
+                  text run at (0,6) width 39: "Hello "
+                RenderImage {IMG} at (39,0) size 20x20
+                RenderText {#text} at (59,6) size 41x18
+                  text run at (59,6) width 41: " world"
+          RenderBlock {DIV} at (0,24) size 744x24
+            RenderBlock {DIV} at (0,0) size 744x24
+              RenderText {#text} at (0,6) size 39x18
+                text run at (0,6) width 39: "Hello "
+              RenderImage {IMG} at (39,0) size 20x20
+              RenderText {#text} at (59,6) size 41x18
+                text run at (59,6) width 41: " world"
+          RenderBlock {DIV} at (0,48) size 744x24
+            RenderText {#text} at (0,6) size 39x18
+              text run at (0,6) width 39: "Hello "
+            RenderImage {IMG} at (39,0) size 20x20
+            RenderText {#text} at (59,6) size 41x18
+              text run at (59,6) width 41: " world"
+      RenderBlock (anonymous) at (0,90) size 784x18
+        RenderBR {BR} at (0,0) size 0x18
+      RenderBlock {UL} at (0,124) size 784x126
+        RenderListItem {LI} at (40,0) size 744x54
+          RenderListMarker at (-17,0) size 7x18: bullet
+          RenderText {#text} at (0,0) size 90x18
+            text run at (0,0) width 90: "Before indent:"
+          RenderInline {SPAN} at (0,0) size 692x54
+            RenderText {#text} at (90,0) size 692x54
+              text run at (90,0) width 106: " <div id=\"test\"> "
+              text run at (196,0) width 479: "<div><span class=\"Apple-style-span\" style=\"background-color: rgb(255, 0,"
+              text run at (0,18) width 333: "0);\">Hello <img src=\"http://\"> world</span></div> "
+              text run at (333,18) width 287: "<div>Hello <img src=\"http://\"> world</div> "
+              text run at (620,18) width 72: "Hello <img"
+              text run at (0,36) width 173: "src=\"http://\"> world </div>"
+        RenderListItem {LI} at (40,54) size 744x72
+          RenderListMarker at (-17,0) size 7x18: bullet
+          RenderText {#text} at (0,0) size 80x18
+            text run at (0,0) width 80: "After indent:"
+          RenderInline {SPAN} at (0,0) size 730x72
+            RenderText {#text} at (80,0) size 730x72
+              text run at (80,0) width 622: " <blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding:"
+              text run at (0,18) width 730: "0px;\"><div id=\"test\"><div><span class=\"Apple-style-span\" style=\"background-color: rgb(255, 0, 0);\">Hello <img"
+              text run at (0,36) width 714: "src=\"http://\"> world</span></div></div><div id=\"test\"><div>Hello <img src=\"http://\"> world</div></div><div"
+              text run at (0,54) width 69: "id=\"test\"> "
+              text run at (69,54) width 341: "Hello <img src=\"http://\"> world </div></blockquote>"
+selection start: position 0 of child 0 {#text} of child 0 {SPAN} of child 0 {DIV} of child 0 {DIV} of child 1 {BLOCKQUOTE} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+selection end:   position 6 of child 2 {#text} of child 2 {DIV} of child 1 {BLOCKQUOTE} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/platform/mac/editing/execCommand/indent-selection-expected.txt b/LayoutTests/platform/mac/editing/execCommand/indent-selection-expected.txt
index 9c32795..a4548bc 100644
--- a/LayoutTests/platform/mac/editing/execCommand/indent-selection-expected.txt
+++ b/LayoutTests/platform/mac/editing/execCommand/indent-selection-expected.txt
@@ -3,7 +3,7 @@ EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > BLOCKQUOTE > DIV > BODY > HTML > #document to 5 of #text > BLOCKQUOTE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > SPAN > BLOCKQUOTE > DIV > BODY > HTML > #document to 5 of #text > SPAN > BLOCKQUOTE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 layer at (0,0) size 800x600
@@ -19,9 +19,10 @@ layer at (0,0) size 800x600
       RenderBlock {DIV} at (0,36) size 784x194
         RenderBlock {BLOCKQUOTE} at (40,0) size 744x54
           RenderBlock (anonymous) at (0,0) size 744x36
-            RenderText {#text} at (0,0) size 42x18
-              text run at (0,0) width 42: "Lorem"
-            RenderBR {BR} at (42,14) size 0x0
+            RenderInline {SPAN} at (0,0) size 42x18
+              RenderText {#text} at (0,0) size 42x18
+                text run at (0,0) width 42: "Lorem"
+              RenderBR {BR} at (42,14) size 0x0
             RenderText {#text} at (0,18) size 83x18
               text run at (0,18) width 83: "more Lorem!"
           RenderBlock {BLOCKQUOTE} at (40,36) size 704x18
@@ -51,8 +52,9 @@ layer at (0,0) size 800x600
             RenderText {#text} at (0,0) size 34x18
               text run at (0,0) width 34: "Sum!"
             RenderBR {BR} at (34,14) size 0x0
-            RenderText {#text} at (0,18) size 38x18
-              text run at (0,18) width 38: "Thing"
+            RenderInline {SPAN} at (0,0) size 38x18
+              RenderText {#text} at (0,18) size 38x18
+                text run at (0,18) width 38: "Thing"
         RenderBlock (anonymous) at (0,194) size 784x0
-selection start: position 0 of child 0 {#text} of child 1 {BLOCKQUOTE} of child 4 {DIV} of child 1 {BODY} of child 0 {HTML} of document
-selection end:   position 5 of child 3 {#text} of child 3 {BLOCKQUOTE} of child 4 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+selection start: position 0 of child 0 {#text} of child 0 {SPAN} of child 1 {BLOCKQUOTE} of child 4 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+selection end:   position 5 of child 0 {#text} of child 3 {SPAN} of child 3 {BLOCKQUOTE} of child 4 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/platform/mac/editing/pasteboard/select-element-1-expected.txt b/LayoutTests/platform/mac/editing/pasteboard/select-element-1-expected.txt
index 510acfb..30d1d13 100644
--- a/LayoutTests/platform/mac/editing/pasteboard/select-element-1-expected.txt
+++ b/LayoutTests/platform/mac/editing/pasteboard/select-element-1-expected.txt
@@ -30,7 +30,7 @@ layer at (0,0) size 800x600
           text run at (253,0) width 220: "All the options should be included."
       RenderBlock {DIV} at (0,34) size 784x13
         RenderInline {FONT} at (0,0) size 0x18
-          RenderInline {SPAN} at (0,0) size 0x13 [bgcolor=#FFFFFF]
+          RenderInline {SPAN} at (0,0) size 0x13
             RenderBR {BR} at (0,0) size 0x13
       RenderBlock {DIV} at (0,47) size 784x22
         RenderMenuList {SELECT} at (2,2) size 62x18 [bgcolor=#FFFFFF]
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 2e69124..996383f 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,41 @@
+2009-10-23  Enrica Casucci  <enrica at apple.com>
+
+        Reviewed by Adele Peterson.
+
+        REGRESSION: Copy is copying incorrect background-color
+        <rdar://problem/7248529>
+        https://bugs.webkit.org/show_bug.cgi?id=29697
+
+        Test: editing/execCommand/indent-paragraphs.html
+
+        This change removes the BackgroundColor from the list 
+        of inheritable CSS properties and changes significantly
+        the way we perform indentation.
+        The new implementation of IndentOutdentCommand uses a new method
+        defined in CompositeEditCommand called moveParagraphWithClones.
+        This is an improved version of the original moveParagraph that
+        is aimed at preserving the original markup of the paragraph being
+        moved.
+
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::): removed CSSPropertyBackgroundColor from editingStyleProperties.
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::CompositeEditCommand): Removed trailing blanks.
+        (WebCore::CompositeEditCommand::rebalanceWhitespaceAt): Removed trailing blanks.
+        (WebCore::CompositeEditCommand::cloneParagraphUnderNewElement): Added.
+        (WebCore::CompositeEditCommand::cleanupAfterDeletion): Added.
+        (WebCore::CompositeEditCommand::moveParagraphWithClones): Added.
+        (WebCore::CompositeEditCommand::moveParagraphs): Modified to use cleanupAfterDeletion.
+        (WebCore::CompositeEditCommand::breakOutOfEmptyListItem): Removed trailing blanks.
+        (WebCore::CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph): Removed trailing blanks.
+        (WebCore::CompositeEditCommand::positionAvoidingSpecialElementBoundary): Removed trailing blanks.
+        * editing/CompositeEditCommand.h: Added three new methods.
+        * editing/IndentOutdentCommand.cpp:
+        (WebCore::IndentOutdentCommand::tryIndentingAsListItem): Changed to use moveParagraphWithClones.
+        (WebCore::IndentOutdentCommand::indentIntoBlockquote): Changed to use moveParagraphWithClones.
+        (WebCore::IndentOutdentCommand::indentRegion): Removed comment.
+        * editing/IndentOutdentCommand.h: Removed prepareBlockquoteLevelForInsertion method.
+
 2009-10-23  Steve Block  <steveblock at google.com>
 
         Reviewed by Eric Seidel.
diff --git a/WebCore/editing/ApplyStyleCommand.cpp b/WebCore/editing/ApplyStyleCommand.cpp
index 89d862f..24d6f54 100644
--- a/WebCore/editing/ApplyStyleCommand.cpp
+++ b/WebCore/editing/ApplyStyleCommand.cpp
@@ -352,7 +352,6 @@ RefPtr<CSSMutableStyleDeclaration> getPropertiesNotInComputedStyle(CSSStyleDecla
 // e.g. when a user inserts a new paragraph, all properties listed here must be copied to the new paragraph.
 // FIXME: The current editingStyleProperties contains all inheritableProperties but we may not need to preserve all inheritable properties
 static const int editingStyleProperties[] = {
-    CSSPropertyBackgroundColor,
     // CSS inheritable properties
     CSSPropertyBorderCollapse,
     CSSPropertyColor,
diff --git a/WebCore/editing/CompositeEditCommand.cpp b/WebCore/editing/CompositeEditCommand.cpp
index 0496a8f..1617be8 100644
--- a/WebCore/editing/CompositeEditCommand.cpp
+++ b/WebCore/editing/CompositeEditCommand.cpp
@@ -20,7 +20,7 @@
  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include "config.h"
@@ -71,7 +71,7 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
-CompositeEditCommand::CompositeEditCommand(Document *document) 
+CompositeEditCommand::CompositeEditCommand(Document *document)
     : EditCommand(document)
 {
 }
@@ -396,7 +396,7 @@ void CompositeEditCommand::rebalanceWhitespaceAt(const Position& position)
     Node* node = position.node();
     if (!node || !node->isTextNode())
         return;
-    Text* textNode = static_cast<Text*>(node);    
+    Text* textNode = static_cast<Text*>(node);
     
     if (textNode->length() == 0)
         return;
@@ -739,6 +739,129 @@ void CompositeEditCommand::pushPartiallySelectedAnchorElementsDown()
     setEndingSelection(originalSelection);
 }
 
+// Clone the paragraph between start and end under blockElement,
+// preserving the hierarchy up to outerNode. 
+
+void CompositeEditCommand::cloneParagraphUnderNewElement(Position& start, Position& end, Node* outerNode, Element* blockElement)
+{
+    // First we clone the outerNode
+    
+    RefPtr<Node> lastNode = outerNode->cloneNode(isTableElement(outerNode));
+    appendNode(lastNode, blockElement);
+
+    if (start.node() != outerNode) {
+        Vector<RefPtr<Node> > ancestors;
+        
+        // Insert each node from innerNode to outerNode (excluded) in a list.
+        for (Node* n = start.node(); n && n != outerNode; n = n->parentNode())
+            ancestors.append(n);
+
+        // Clone every node between start.node() and outerBlock.
+
+        for (size_t i = ancestors.size(); i != 0; --i) {
+            Node* item = ancestors[i - 1].get();
+            RefPtr<Node> child = item->cloneNode(isTableElement(item));
+            appendNode(child, static_cast<Element *>(lastNode.get()));
+            lastNode = child.release();
+        }
+    }
+
+    // Handle the case of paragraphs with more than one node,
+    // cloning all the siblings until end.node() is reached.
+    
+    if (start.node() != end.node()) {
+        for (Node* n = start.node()->nextSibling(); n != NULL; n = n->nextSibling()) {
+            RefPtr<Node> clonedNode = n->cloneNode(true);
+            insertNodeAfter(clonedNode, lastNode);
+            lastNode = clonedNode.release();
+            if (n == end.node())
+                break;
+        }
+    }
+}
+
+    
+// There are bugs in deletion when it removes a fully selected table/list.
+// It expands and removes the entire table/list, but will let content
+// before and after the table/list collapse onto one line.   
+// Deleting a paragraph will leave a placeholder. Remove it (and prune
+// empty or unrendered parents).
+
+void CompositeEditCommand::cleanupAfterDeletion()
+{
+    VisiblePosition caretAfterDelete = endingSelection().visibleStart();
+    if (isStartOfParagraph(caretAfterDelete) && isEndOfParagraph(caretAfterDelete)) {
+        // Note: We want the rightmost candidate.
+        Position position = caretAfterDelete.deepEquivalent().downstream();
+        Node* node = position.node();
+        // Normally deletion will leave a br as a placeholder.
+        if (node->hasTagName(brTag))
+            removeNodeAndPruneAncestors(node);
+        // If the selection to move was empty and in an empty block that 
+        // doesn't require a placeholder to prop itself open (like a bordered
+        // div or an li), remove it during the move (the list removal code
+        // expects this behavior).
+        else if (isBlock(node))
+            removeNodeAndPruneAncestors(node);
+        else if (lineBreakExistsAtPosition(position)) {
+            // There is a preserved '\n' at caretAfterDelete.
+            // We can safely assume this is a text node.
+            Text* textNode = static_cast<Text*>(node);
+            if (textNode->length() == 1)
+                removeNodeAndPruneAncestors(node);
+            else
+                deleteTextFromNode(textNode, position.deprecatedEditingOffset(), 1);
+        }
+    }
+}
+    
+// This is a version of moveParagraph that preserves style by keeping the original markup
+// It is currently used only by IndentOutdentCommand but it is meant to be used in the
+// future by several other commands such as InsertList and the align commands.
+// The blockElement parameter is the element to move the paragraph to,
+// outerNode is the top element of the paragraph hierarchy. 
+
+void CompositeEditCommand::moveParagraphWithClones(const VisiblePosition& startOfParagraphToMove, const VisiblePosition& endOfParagraphToMove, Element* blockElement, Node* outerNode)
+{
+    ASSERT(outerNode);
+    ASSERT(blockElement);
+
+    VisiblePosition beforeParagraph = startOfParagraphToMove.previous();
+    VisiblePosition afterParagraph(endOfParagraphToMove.next());
+    
+    // We upstream() the end and downstream() the start so that we don't include collapsed whitespace in the move.
+    // When we paste a fragment, spaces after the end and before the start are treated as though they were rendered.
+    Position start = startOfParagraphToMove.deepEquivalent().downstream();
+    Position end = endOfParagraphToMove.deepEquivalent().upstream();
+
+    cloneParagraphUnderNewElement(start, end, outerNode, blockElement);
+      
+    setEndingSelection(VisibleSelection(start, end, DOWNSTREAM));
+    deleteSelection(false, false, false, false);
+    
+    // There are bugs in deletion when it removes a fully selected table/list.
+    // It expands and removes the entire table/list, but will let content
+    // before and after the table/list collapse onto one line.
+       
+    cleanupAfterDeletion();
+    
+    // Add a br if pruning an empty block level element caused a collapse.  For example:
+    // foo^
+    // <div>bar</div>
+    // baz
+    // Imagine moving 'bar' to ^.  'bar' will be deleted and its div pruned.  That would
+    // cause 'baz' to collapse onto the line with 'foobar' unless we insert a br.
+    // Must recononicalize these two VisiblePositions after the pruning above.
+    beforeParagraph = VisiblePosition(beforeParagraph.deepEquivalent());
+    afterParagraph = VisiblePosition(afterParagraph.deepEquivalent());
+
+    if (beforeParagraph.isNotNull() && !isTableElement(beforeParagraph.deepEquivalent().node()) && (!isEndOfParagraph(beforeParagraph) || beforeParagraph == afterParagraph)) {
+        // FIXME: Trim text between beforeParagraph and afterParagraph if they aren't equal.
+        insertNodeAt(createBreakElement(document()), beforeParagraph.deepEquivalent());
+    }
+}
+    
+    
 // This moves a paragraph preserving its style.
 void CompositeEditCommand::moveParagraph(const VisiblePosition& startOfParagraphToMove, const VisiblePosition& endOfParagraphToMove, const VisiblePosition& destination, bool preserveSelection, bool preserveStyle)
 {
@@ -784,7 +907,7 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
     VisiblePosition afterParagraph(endOfParagraphToMove.next());
 
     // We upstream() the end and downstream() the start so that we don't include collapsed whitespace in the move.
-    // When we paste a fragment, spaces after the end and before the start are treated as though they were rendered.    
+    // When we paste a fragment, spaces after the end and before the start are treated as though they were rendered.
     Position start = startOfParagraphToMove.deepEquivalent().downstream();
     Position end = endOfParagraphToMove.deepEquivalent().upstream();
     
@@ -793,7 +916,7 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
     Position endRangeCompliant = rangeCompliantEquivalent(end);
     RefPtr<Range> range = Range::create(document(), startRangeCompliant.node(), startRangeCompliant.deprecatedEditingOffset(), endRangeCompliant.node(), endRangeCompliant.deprecatedEditingOffset());
 
-    // FIXME: This is an inefficient way to preserve style on nodes in the paragraph to move.  It 
+    // FIXME: This is an inefficient way to preserve style on nodes in the paragraph to move. It
     // shouldn't matter though, since moved paragraphs will usually be quite small.
     RefPtr<DocumentFragment> fragment = startOfParagraphToMove != endOfParagraphToMove ? createFragmentFromMarkup(document(), createMarkup(range.get(), 0, DoNotAnnotateForInterchange, true), "") : 0;
     
@@ -813,42 +936,14 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
     deleteSelection(false, false, false, false);
 
     ASSERT(destination.deepEquivalent().node()->inDocument());
-    
-    // There are bugs in deletion when it removes a fully selected table/list.  
-    // It expands and removes the entire table/list, but will let content
-    // before and after the table/list collapse onto one line.
-    
-    // Deleting a paragraph will leave a placeholder.  Remove it (and prune
-    // empty or unrendered parents).
-    VisiblePosition caretAfterDelete = endingSelection().visibleStart();
-    if (isStartOfParagraph(caretAfterDelete) && isEndOfParagraph(caretAfterDelete)) {
-        // Note: We want the rightmost candidate.
-        Position position = caretAfterDelete.deepEquivalent().downstream();
-        Node* node = position.node();
-        // Normally deletion will leave a br as a placeholder.
-        if (node->hasTagName(brTag))
-            removeNodeAndPruneAncestors(node);
-        // If the selection to move was empty and in an empty block that 
-        // doesn't require a placeholder to prop itself open (like a bordered 
-        // div or an li), remove it during the move (the list removal code 
-        // expects this behavior).
-        else if (isBlock(node))
-            removeNodeAndPruneAncestors(node);
-        else if (lineBreakExistsAtVisiblePosition(caretAfterDelete)) {
-            // There is a preserved '\n' at caretAfterDelete.
-            Text* textNode = static_cast<Text*>(node);
-            if (textNode->length() == 1)
-                removeNodeAndPruneAncestors(node);
-            else 
-                deleteTextFromNode(textNode, position.deprecatedEditingOffset(), 1);
-        }
-    }
 
-    // Add a br if pruning an empty block level element caused a collapse.  For example:
+    cleanupAfterDeletion();
+
+    // Add a br if pruning an empty block level element caused a collapse. For example:
     // foo^
     // <div>bar</div>
     // baz
-    // Imagine moving 'bar' to ^.  'bar' will be deleted and its div pruned.  That would
+    // Imagine moving 'bar' to ^. 'bar' will be deleted and its div pruned. That would
     // cause 'baz' to collapse onto the line with 'foobar' unless we insert a br.
     // Must recononicalize these two VisiblePositions after the pruning above.
     beforeParagraph = VisiblePosition(beforeParagraph.deepEquivalent());
@@ -912,7 +1007,7 @@ bool CompositeEditCommand::breakOutOfEmptyListItem()
                 removeNodePreservingChildren(listNode->parentNode());
                 newBlock = createListItemElement(document());
             }
-            // If listNode does NOT appear at the end of the outer list item, then behave as if in a regular paragraph. 
+            // If listNode does NOT appear at the end of the outer list item, then behave as if in a regular paragraph.
         } else if (blockEnclosingList->hasTagName(olTag) || blockEnclosingList->hasTagName(ulTag))
             newBlock = createListItemElement(document());
     }
@@ -971,7 +1066,7 @@ bool CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph()
     // to hold the caret before the highest blockquote.
     insertNodeBefore(br, highestBlockquote);
     VisiblePosition atBR(Position(br.get(), 0));
-    // If the br we inserted collapsed, for example foo<br><blockquote>...</blockquote>, insert 
+    // If the br we inserted collapsed, for example foo<br><blockquote>...</blockquote>, insert
     // a second one.
     if (!isStartOfParagraph(atBR))
         insertNodeBefore(createBreakElement(document()), br);
@@ -1002,7 +1097,7 @@ bool CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph()
     return true;
 }
 
-// Operations use this function to avoid inserting content into an anchor when at the start or the end of 
+// Operations use this function to avoid inserting content into an anchor when at the start or the end of
 // that anchor, as in NSTextView.
 // FIXME: This is only an approximation of NSTextViews insertion behavior, which varies depending on how
 // the caret was made. 
@@ -1022,7 +1117,7 @@ Position CompositeEditCommand::positionAvoidingSpecialElementBoundary(const Posi
     if (enclosingAnchor && !isBlock(enclosingAnchor)) {
         VisiblePosition firstInAnchor(firstDeepEditingPositionForNode(enclosingAnchor));
         VisiblePosition lastInAnchor(lastDeepEditingPositionForNode(enclosingAnchor));
-        // If visually just after the anchor, insert *inside* the anchor unless it's the last 
+        // If visually just after the anchor, insert *inside* the anchor unless it's the last
         // VisiblePosition in the document, to match NSTextView.
         if (visiblePos == lastInAnchor) {
             // Make sure anchors are pushed down before avoiding them so that we don't
diff --git a/WebCore/editing/CompositeEditCommand.h b/WebCore/editing/CompositeEditCommand.h
index 2c6403e..0cceaaa 100644
--- a/WebCore/editing/CompositeEditCommand.h
+++ b/WebCore/editing/CompositeEditCommand.h
@@ -102,6 +102,9 @@ protected:
     
     void moveParagraph(const VisiblePosition&, const VisiblePosition&, const VisiblePosition&, bool preserveSelection = false, bool preserveStyle = true);
     void moveParagraphs(const VisiblePosition&, const VisiblePosition&, const VisiblePosition&, bool preserveSelection = false, bool preserveStyle = true);
+    void moveParagraphWithClones(const VisiblePosition& startOfParagraphToMove, const VisiblePosition& endOfParagraphToMove, Element* blockElement, Node* outerNode);
+    void cloneParagraphUnderNewElement(Position& start, Position& end, Node* outerNode, Element* blockElement);
+    void cleanupAfterDeletion();
     
     bool breakOutOfEmptyListItem();
     bool breakOutOfEmptyMailBlockquotedParagraph();
diff --git a/WebCore/editing/IndentOutdentCommand.cpp b/WebCore/editing/IndentOutdentCommand.cpp
index 84fa147..808a2f8 100644
--- a/WebCore/editing/IndentOutdentCommand.cpp
+++ b/WebCore/editing/IndentOutdentCommand.cpp
@@ -67,37 +67,6 @@ IndentOutdentCommand::IndentOutdentCommand(Document* document, EIndentType typeO
 {
 }
 
-// This function is a workaround for moveParagraph's tendency to strip blockquotes. It updates lastBlockquote to point to the
-// correct level for the current paragraph, and returns a pointer to a placeholder br where the insertion should be performed.
-PassRefPtr<Element> IndentOutdentCommand::prepareBlockquoteLevelForInsertion(const VisiblePosition& currentParagraph, RefPtr<Element>& lastBlockquote)
-{
-    int currentBlockquoteLevel = 0;
-    int lastBlockquoteLevel = 0;
-    Node* node = currentParagraph.deepEquivalent().node();
-    while ((node = enclosingNodeWithTag(Position(node->parentNode(), 0), blockquoteTag)))
-        currentBlockquoteLevel++;
-    node = lastBlockquote.get();
-    while ((node = enclosingNodeWithTag(Position(node->parentNode(), 0), blockquoteTag)))
-        lastBlockquoteLevel++;
-    while (currentBlockquoteLevel > lastBlockquoteLevel) {
-        RefPtr<Element> newBlockquote = createIndentBlockquoteElement(document());
-        appendNode(newBlockquote, lastBlockquote);
-        lastBlockquote = newBlockquote;
-        lastBlockquoteLevel++;
-    }
-    while (currentBlockquoteLevel < lastBlockquoteLevel) {
-        lastBlockquote = static_cast<Element*>(enclosingNodeWithTag(Position(lastBlockquote->parentNode(), 0), blockquoteTag));
-        lastBlockquoteLevel--;
-    }
-    RefPtr<Element> placeholder = createBreakElement(document());
-    appendNode(placeholder, lastBlockquote);
-    // Add another br before the placeholder if it collapsed.
-    VisiblePosition visiblePos(Position(placeholder.get(), 0));
-    if (!isStartOfParagraph(visiblePos))
-        insertNodeBefore(createBreakElement(document()), placeholder);
-    return placeholder.release();
-}
-
 bool IndentOutdentCommand::tryIndentingAsListItem(const VisiblePosition& endOfCurrentParagraph)
 {
     // If our selection is not inside a list, bail out.
@@ -117,13 +86,9 @@ bool IndentOutdentCommand::tryIndentingAsListItem(const VisiblePosition& endOfCu
     Element* nextList = selectedListItem->nextElementSibling();
 
     RefPtr<Element> newList = document()->createElement(listNode->tagQName(), false);
-    RefPtr<Element> newListItem = selectedListItem->cloneElementWithoutChildren();
-    RefPtr<Element> placeholder = createBreakElement(document());
     insertNodeBefore(newList, selectedListItem);
-    appendNode(newListItem, newList);
-    appendNode(placeholder, newListItem);
 
-    moveParagraph(startOfParagraph(endOfCurrentParagraph), endOfCurrentParagraph, VisiblePosition(Position(placeholder, 0)), true);
+    moveParagraphWithClones(startOfParagraph(endOfCurrentParagraph), endOfCurrentParagraph, newList.get(), selectedListItem);
 
     if (canMergeLists(previousList, newList.get()))
         mergeIdenticalElements(previousList, newList);
@@ -137,25 +102,31 @@ void IndentOutdentCommand::indentIntoBlockquote(const VisiblePosition& endOfCurr
 {
     Node* enclosingCell = 0;
 
+    Position start = startOfParagraph(endOfCurrentParagraph).deepEquivalent();
+    enclosingCell = enclosingNodeOfType(start, &isTableCell);
+    Node* nodeToSplitTo;
+    if (enclosingCell)
+        nodeToSplitTo = enclosingCell;
+    else if (enclosingList(start.node()))
+        nodeToSplitTo = enclosingBlock(start.node());
+    else
+        nodeToSplitTo = editableRootForPosition(start);
+
+    RefPtr<Node> outerBlock = splitTreeToNode(start.node(), nodeToSplitTo);
+
     if (!targetBlockquote) {
         // Create a new blockquote and insert it as a child of the root editable element. We accomplish
         // this by splitting all parents of the current paragraph up to that point.
         targetBlockquote = createIndentBlockquoteElement(document());
-        Position start = startOfParagraph(endOfCurrentParagraph).deepEquivalent();
-        enclosingCell = enclosingNodeOfType(start, &isTableCell);
-        Node* nodeToSplitTo = enclosingCell ? enclosingCell : editableRootForPosition(start);
-        RefPtr<Node> startOfNewBlock = splitTreeToNode(start.node(), nodeToSplitTo);
-        insertNodeBefore(targetBlockquote, startOfNewBlock);
+        insertNodeBefore(targetBlockquote, outerBlock);
     }
 
-    RefPtr<Element> insertionPoint = prepareBlockquoteLevelForInsertion(endOfCurrentParagraph, targetBlockquote);
-
+    moveParagraphWithClones(startOfParagraph(endOfCurrentParagraph), endOfCurrentParagraph, targetBlockquote.get(), outerBlock.get());
+    
     // Don't put the next paragraph in the blockquote we just created for this paragraph unless 
     // the next paragraph is in the same cell.
     if (enclosingCell && enclosingCell != enclosingNodeOfType(endOfNextParagraph.deepEquivalent(), &isTableCell))
         targetBlockquote = 0;
-
-    moveParagraph(startOfParagraph(endOfCurrentParagraph), endOfCurrentParagraph, VisiblePosition(Position(insertionPoint, 0)), true);
 }
 
 void IndentOutdentCommand::indentRegion()
@@ -191,8 +162,6 @@ void IndentOutdentCommand::indentRegion()
             blockquoteForNextIndent = 0;
         else
             indentIntoBlockquote(endOfCurrentParagraph, endOfNextParagraph, blockquoteForNextIndent);
-            // blockquoteForNextIndent maybe updated
-            // this is due to the way prepareBlockquoteLevelForInsertion was designed.
         // Sanity check: Make sure our moveParagraph calls didn't remove endOfNextParagraph.deepEquivalent().node()
         // If somehow we did, return to prevent crashes.
         if (endOfNextParagraph.isNotNull() && !endOfNextParagraph.deepEquivalent().node()->inDocument()) {
diff --git a/WebCore/editing/IndentOutdentCommand.h b/WebCore/editing/IndentOutdentCommand.h
index 419f832..817b4c8 100644
--- a/WebCore/editing/IndentOutdentCommand.h
+++ b/WebCore/editing/IndentOutdentCommand.h
@@ -49,7 +49,6 @@ private:
     void indentRegion();
     void outdentRegion();
     void outdentParagraph();
-    PassRefPtr<Element> prepareBlockquoteLevelForInsertion(const VisiblePosition&, RefPtr<Element>&);
     bool tryIndentingAsListItem(const VisiblePosition&);
     void indentIntoBlockquote(const VisiblePosition&, const VisiblePosition&, RefPtr<Element>&);
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list