Title: [130532] trunk
Revision
130532
Author
rn...@webkit.org
Date
2012-10-05 11:26:37 -0700 (Fri, 05 Oct 2012)

Log Message

Deleting across multiple paragraphs can change the style of surrounding text
https://bugs.webkit.org/show_bug.cgi?id=97266

Reviewed by Levi Weintraub.

Source/WebCore: 

Preserve editing styles from CSS rules in wrappingStyleForSerialization as well as inline styles
even when we're not annotating. We don't want to preserve all styles because it's against
the user expectation to keep borders, etc... when merging paragraphs. We also don't want to copy
styles from a mail blockquote because that's not a style the user has applied. See the comment
in EditingStyle::wrappingStyleForSerialization.

Test: editing/deleting/merge-paragraph-with-style-from-rule.html

* editing/EditingStyle.cpp:
(WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement):
(WebCore::EditingStyle::wrappingStyleForSerialization):

LayoutTests: 

Added a regression test and rebaselined tests.

* editing/deleting/delete-before-block-image-2-expected.txt:
* editing/deleting/merge-paragraph-from-p-with-style-expected.txt:
* editing/deleting/merge-paragraph-from-p-with-style.html: We changed the behavior. The editing style of p
is now preserved when merging paragraphs.
* editing/deleting/merge-paragraph-with-style-from-rule-expected.txt: Added.
* editing/deleting/merge-paragraph-with-style-from-rule.html: Added.
* platform/mac/editing/deleting/delete-block-merge-contents-001-expected.txt:
* platform/mac/editing/pasteboard/merge-end-blockquote-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (130531 => 130532)


--- trunk/LayoutTests/ChangeLog	2012-10-05 18:18:50 UTC (rev 130531)
+++ trunk/LayoutTests/ChangeLog	2012-10-05 18:26:37 UTC (rev 130532)
@@ -1,3 +1,21 @@
+2012-10-05  Ryosuke Niwa  <rn...@webkit.org>
+
+        Deleting across multiple paragraphs can change the style of surrounding text
+        https://bugs.webkit.org/show_bug.cgi?id=97266
+
+        Reviewed by Levi Weintraub.
+
+        Added a regression test and rebaselined tests.
+
+        * editing/deleting/delete-before-block-image-2-expected.txt:
+        * editing/deleting/merge-paragraph-from-p-with-style-expected.txt:
+        * editing/deleting/merge-paragraph-from-p-with-style.html: We changed the behavior. The editing style of p
+        is now preserved when merging paragraphs.
+        * editing/deleting/merge-paragraph-with-style-from-rule-expected.txt: Added.
+        * editing/deleting/merge-paragraph-with-style-from-rule.html: Added.
+        * platform/mac/editing/deleting/delete-block-merge-contents-001-expected.txt:
+        * platform/mac/editing/pasteboard/merge-end-blockquote-expected.txt:
+
 2012-10-05  Julien Chaffraix  <jchaffr...@webkit.org>
 
         Unreviewed rebaseline after r130355.

Modified: trunk/LayoutTests/editing/deleting/delete-before-block-image-2-expected.txt (130531 => 130532)


--- trunk/LayoutTests/editing/deleting/delete-before-block-image-2-expected.txt	2012-10-05 18:18:50 UTC (rev 130531)
+++ trunk/LayoutTests/editing/deleting/delete-before-block-image-2-expected.txt	2012-10-05 18:26:37 UTC (rev 130532)
@@ -1,3 +1,3 @@
-<img id="img" style="display:block;" src=""
+<img id="img" src="" style="display: block;">
 
 Selection: [[object HTMLDivElement], 0]

Modified: trunk/LayoutTests/editing/deleting/merge-paragraph-from-p-with-style-expected.txt (130531 => 130532)


--- trunk/LayoutTests/editing/deleting/merge-paragraph-from-p-with-style-expected.txt	2012-10-05 18:18:50 UTC (rev 130531)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-from-p-with-style-expected.txt	2012-10-05 18:26:37 UTC (rev 130532)
@@ -8,11 +8,11 @@
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
 This tests deleting line break before p.
-"helloworld" should both be in black text (no p element) and "world" should be italicized.
+"world" in "helloworld" should be italicized in red.
 | "
 hello<#selection-caret>"
 | <span>
-|   style="font-style: italic;"
+|   style="color: red; font-style: italic;"
 |   "world"
 | "
 "

Modified: trunk/LayoutTests/editing/deleting/merge-paragraph-from-p-with-style.html (130531 => 130532)


--- trunk/LayoutTests/editing/deleting/merge-paragraph-from-p-with-style.html	2012-10-05 18:18:50 UTC (rev 130531)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-from-p-with-style.html	2012-10-05 18:26:37 UTC (rev 130532)
@@ -7,7 +7,7 @@
 </head>
 <body>
 <p id="description">This tests deleting line break before p.
-"helloworld" should both be in black text (no p element) and "world" should be italicized.</p>
+"world" in "helloworld" should be italicized in red.</p>
 <div id="test" contenteditable>
 hello
 <p style="font-style: italic;">world</p>

Added: trunk/LayoutTests/editing/deleting/merge-paragraph-with-style-from-rule-expected.txt (0 => 130532)


--- trunk/LayoutTests/editing/deleting/merge-paragraph-with-style-from-rule-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-with-style-from-rule-expected.txt	2012-10-05 18:26:37 UTC (rev 130532)
@@ -0,0 +1,18 @@
+You should see "hello webKit" all in blue:
+| "
+"
+| <p>
+|   <span>
+|     class="someClass"
+|     style="font-size: 12pt;"
+|     "hello"
+|   " "
+|   <span>
+|     class="someClass"
+|     style="font-size: 12pt;"
+|     "w<#selection-caret>"
+|   <span>
+|     style="color: blue; font-size: 12pt;"
+|     "ebKit"
+| "
+"

Added: trunk/LayoutTests/editing/deleting/merge-paragraph-with-style-from-rule.html (0 => 130532)


--- trunk/LayoutTests/editing/deleting/merge-paragraph-with-style-from-rule.html	                        (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-with-style-from-rule.html	2012-10-05 18:26:37 UTC (rev 130532)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<body>
+<style type="text/css">
+.someClass {
+    color: blue;
+}
+</style>
+<p id="description">You should see "hello webKit" all in blue:</p>
+<div id="editor" contenteditable>
+<p><span style="font-size: 12pt;" class="someClass">hello</span> <span style="font-size: 12pt;" class="someClass">world</span></p>
+<p><span style="font-size: 12pt;" class="someClass">WebKit</span></p>
+</div>
+<div id="log"></div>
+<script src=""
+<script>
+
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+document.getElementById('editor').focus();
+for (var i = 0; i < 7; i++)
+    getSelection().modify('move', 'forward', 'character');
+for (var i = 0; i < 6; i++)
+    getSelection().modify('extend', 'forward', 'character');
+document.execCommand('delete');
+
+Markup.description(document.getElementById('description').textContent);
+Markup.dump('editor');
+
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/mac/editing/deleting/delete-block-merge-contents-001-expected.txt (130531 => 130532)


--- trunk/LayoutTests/platform/mac/editing/deleting/delete-block-merge-contents-001-expected.txt	2012-10-05 18:18:50 UTC (rev 130531)
+++ trunk/LayoutTests/platform/mac/editing/deleting/delete-block-merge-contents-001-expected.txt	2012-10-05 18:26:37 UTC (rev 130532)
@@ -18,4 +18,5 @@
         RenderBlock {DIV} at (14,14) size 756x28
           RenderText {#text} at (0,0) size 84x28
             text run at (0,0) width 84: "OneTwo"
+          RenderText {#text} at (0,0) size 0x0
 caret: position 4 of child 0 {#text} of child 1 {DIV} of child 1 {DIV} of body

Modified: trunk/LayoutTests/platform/mac/editing/pasteboard/merge-end-blockquote-expected.txt (130531 => 130532)


--- trunk/LayoutTests/platform/mac/editing/pasteboard/merge-end-blockquote-expected.txt	2012-10-05 18:18:50 UTC (rev 130531)
+++ trunk/LayoutTests/platform/mac/editing/pasteboard/merge-end-blockquote-expected.txt	2012-10-05 18:26:37 UTC (rev 130532)
@@ -1,7 +1,7 @@
 EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
 EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 16 of #text > DIV > BODY > HTML > #document to 16 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 17 of #text > DIV > BODY > HTML > #document to 17 of #text > DIV > BODY > HTML > #document toDOMRange:range from 16 of #text > DIV > BODY > HTML > #document to 16 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 EDITING DELEGATE: shouldEndEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
@@ -11,7 +11,7 @@
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 14 of #text > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document to 14 of #text > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document toDOMRange:range from 4 of #text > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document to 4 of #text > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 14 of #text > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document to 14 of #text > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document toDOMRange:range from 3 of #text > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document to 3 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
@@ -41,4 +41,4 @@
           RenderBlock {DIV} at (0,0) size 704x18
             RenderText {#text} at (0,0) size 49x18
               text run at (0,0) width 49: "barText"
-caret: position 4 of child 0 {#text} of child 0 {DIV} of child 1 {BLOCKQUOTE} of child 10 {DIV} of body
+caret: position 3 of child 0 {#text} of child 0 {DIV} of child 1 {BLOCKQUOTE} of child 10 {DIV} of body

Modified: trunk/Source/WebCore/ChangeLog (130531 => 130532)


--- trunk/Source/WebCore/ChangeLog	2012-10-05 18:18:50 UTC (rev 130531)
+++ trunk/Source/WebCore/ChangeLog	2012-10-05 18:26:37 UTC (rev 130532)
@@ -1,3 +1,22 @@
+2012-10-05  Ryosuke Niwa  <rn...@webkit.org>
+
+        Deleting across multiple paragraphs can change the style of surrounding text
+        https://bugs.webkit.org/show_bug.cgi?id=97266
+
+        Reviewed by Levi Weintraub.
+
+        Preserve editing styles from CSS rules in wrappingStyleForSerialization as well as inline styles
+        even when we're not annotating. We don't want to preserve all styles because it's against
+        the user expectation to keep borders, etc... when merging paragraphs. We also don't want to copy
+        styles from a mail blockquote because that's not a style the user has applied. See the comment
+        in EditingStyle::wrappingStyleForSerialization.
+
+        Test: editing/deleting/merge-paragraph-with-style-from-rule.html
+
+        * editing/EditingStyle.cpp:
+        (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement):
+        (WebCore::EditingStyle::wrappingStyleForSerialization):
+
 2012-10-05  Dan Bernstein  <m...@apple.com>
 
         Reversing a GlyphBuffer needlessly queries its size multiple times

Modified: trunk/Source/WebCore/editing/EditingStyle.cpp (130531 => 130532)


--- trunk/Source/WebCore/editing/EditingStyle.cpp	2012-10-05 18:18:50 UTC (rev 130531)
+++ trunk/Source/WebCore/editing/EditingStyle.cpp	2012-10-05 18:26:37 UTC (rev 130532)
@@ -981,6 +981,11 @@
 
 void EditingStyle::mergeInlineAndImplicitStyleOfElement(StyledElement* element, CSSPropertyOverrideMode mode, PropertiesToInclude propertiesToInclude)
 {
+    RefPtr<EditingStyle> styleFromRules = EditingStyle::create();
+    styleFromRules->mergeStyleFromRulesForSerialization(element);
+    styleFromRules->removeNonEditingProperties();
+    mergeStyle(styleFromRules->m_mutableStyle.get(), mode);
+
     mergeInlineStyleOfElement(element, mode, propertiesToInclude);
 
     const Vector<OwnPtr<HTMLElementEquivalent> >& elementEquivalents = htmlElementEquivalents();
@@ -1019,7 +1024,7 @@
 
     // When not annotating for interchange, we only preserve inline style declarations.
     for (Node* node = context; node && !node->isDocumentNode(); node = node->parentNode()) {
-        if (node->isStyledElement()) {
+        if (node->isStyledElement() && !isMailBlockquote(node)) {
             wrappingStyle->mergeInlineAndImplicitStyleOfElement(static_cast<StyledElement*>(node), EditingStyle::DoNotOverrideValues,
                 EditingStyle::EditingPropertiesInEffect);
         }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to