Diff
Modified: trunk/LayoutTests/ChangeLog (95334 => 95335)
--- trunk/LayoutTests/ChangeLog 2011-09-16 23:33:23 UTC (rev 95334)
+++ trunk/LayoutTests/ChangeLog 2011-09-17 00:00:07 UTC (rev 95335)
@@ -1,3 +1,32 @@
+2011-09-14 Ryosuke Niwa <rn...@webkit.org>
+
+ Deleting line break before h1 converts h1 to span
+ https://bugs.webkit.org/show_bug.cgi?id=45784
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Added a bunch of tests to ensure WebKit does not keep block elements' style when merging paragraphs.
+ When removing line breaks between <h1>hello</h1>world and hello<pre>world</pre> for example,
+ we should not be overriding and preserving styles from h1 in the merge paragraph respectively.
+
+ * editing/deleting/merge-paragraph-from-address-expected.txt: Added.
+ * editing/deleting/merge-paragraph-from-address.html: Added.
+ * editing/deleting/merge-paragraph-from-h6-expected.txt: Added.
+ * editing/deleting/merge-paragraph-from-h6-with-style-expected.txt: Added.
+ * editing/deleting/merge-paragraph-from-h6-with-style.html: Added.
+ * editing/deleting/merge-paragraph-from-h6.html: Added.
+ * editing/deleting/merge-paragraph-from-listing-expected.txt: Added.
+ * editing/deleting/merge-paragraph-from-listing.html: Added.
+ * editing/deleting/merge-paragraph-into-h1-expected.txt: Added.
+ * editing/deleting/merge-paragraph-into-h1-style-expected.txt: Added.
+ * editing/deleting/merge-paragraph-into-h1-with-style-expected.txt: Added.
+ * editing/deleting/merge-paragraph-into-h1-with-style.html: Added.
+ * editing/deleting/merge-paragraph-into-h1.html: Added.
+ * editing/deleting/merge-paragraph-into-pre-expected.txt: Added.
+ * editing/deleting/merge-paragraph-into-pre.html: Added.
+ * platform/mac/editing/deleting/merge-whitespace-pre-expected.png:
+ * platform/mac/editing/deleting/merge-whitespace-pre-expected.txt:
+
2011-09-16 David Levin <le...@chromium.org>
[chromium] Rebaseline fix up due to r95239.
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-from-address-expected.txt (0 => 95335)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-from-address-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-from-address-expected.txt 2011-09-17 00:00:07 UTC (rev 95335)
@@ -0,0 +1,18 @@
+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: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 7 of #text > DIV > BODY > HTML > #document to 0 of ADDRESS > DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 6 of #text > DIV > BODY > HTML > #document to 6 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+This tests deleting line break before address.
+WebKit should not cancel styles added by address by those of document's default style.
+| "
+hello<#selection-caret>"
+| "world"
+| "
+"
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-from-address.html (0 => 95335)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-from-address.html (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-from-address.html 2011-09-17 00:00:07 UTC (rev 95335)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p id="description">This tests deleting line break before address.
+WebKit should not cancel styles added by address by those of document's default style.</p>
+<div id="test" contenteditable>
+hello
+<address>world</address>
+</div>
+</div>
+<script src=""
+<script src=""
+<script>
+
+function editingTest() {
+ moveSelectionForwardByLineCommand();
+ deleteCommand();
+
+ Markup.description(document.getElementById('description').textContent);
+ Markup.dump('test');
+}
+
+runEditingTest();
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-from-h6-expected.txt (0 => 95335)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-from-h6-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-from-h6-expected.txt 2011-09-17 00:00:07 UTC (rev 95335)
@@ -0,0 +1,18 @@
+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: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 7 of #text > DIV > BODY > HTML > #document to 0 of H1 > DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 6 of #text > DIV > BODY > HTML > #document to 6 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+This tests deleting line break before h6.
+WebKit should not cancel styles added by h6 by those of document's default style.
+| "
+hello<#selection-caret>"
+| "world"
+| "
+"
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-from-h6-with-style-expected.txt (0 => 95335)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-from-h6-with-style-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-from-h6-with-style-expected.txt 2011-09-17 00:00:07 UTC (rev 95335)
@@ -0,0 +1,22 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 5 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 0 of H1 > DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 5 of #text > EM > DIV > BODY > HTML > #document to 5 of #text > EM > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+This tests deleting line break before h6.
+WebKit should not cancel styles added by h6 by those of document's default style but still keep "hello" italicized and "world" in red.
+| "
+"
+| <em>
+| "hello<#selection-caret>"
+| <span>
+| style="color: rgb(255, 0, 0); "
+| "world"
+| "
+"
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-from-h6-with-style.html (0 => 95335)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-from-h6-with-style.html (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-from-h6-with-style.html 2011-09-17 00:00:07 UTC (rev 95335)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p id="description">This tests deleting line break before h6.
+WebKit should not cancel styles added by h6 by those of document's default style but still keep "hello" italicized and "world" in red.</p>
+<div id="test" contenteditable>
+<em>hello</em>
+<h1><font color="red">world</font></h1>
+</div>
+</div>
+<script src=""
+<script src=""
+<script>
+
+function editingTest() {
+ moveSelectionForwardByLineCommand();
+ deleteCommand();
+
+ Markup.description(document.getElementById('description').textContent);
+ Markup.dump('test');
+}
+
+runEditingTest();
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-from-h6.html (0 => 95335)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-from-h6.html (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-from-h6.html 2011-09-17 00:00:07 UTC (rev 95335)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p id="description">This tests deleting line break before h6.
+WebKit should not cancel styles added by h6 by those of document's default style.</p>
+<div id="test" contenteditable>
+hello
+<h1>world</h1>
+</div>
+</div>
+<script src=""
+<script src=""
+<script>
+
+function editingTest() {
+ moveSelectionForwardByLineCommand();
+ deleteCommand();
+
+ Markup.description(document.getElementById('description').textContent);
+ Markup.dump('test');
+}
+
+runEditingTest();
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-from-listing-expected.txt (0 => 95335)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-from-listing-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-from-listing-expected.txt 2011-09-17 00:00:07 UTC (rev 95335)
@@ -0,0 +1,18 @@
+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: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 7 of #text > DIV > BODY > HTML > #document to 0 of LISTING > DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 6 of #text > DIV > BODY > HTML > #document to 6 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+This tests deleting line break before listing.
+WebKit should not cancel styles added by listing by those of document's default style.
+| "
+hello<#selection-caret>"
+| "world"
+| "
+"
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-from-listing.html (0 => 95335)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-from-listing.html (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-from-listing.html 2011-09-17 00:00:07 UTC (rev 95335)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p id="description">This tests deleting line break before listing.
+WebKit should not cancel styles added by listing by those of document's default style.</p>
+<div id="test" contenteditable>
+hello
+<listing>world</listing>
+</div>
+</div>
+<script src=""
+<script src=""
+<script>
+
+function editingTest() {
+ moveSelectionForwardByLineCommand();
+ deleteCommand();
+
+ Markup.description(document.getElementById('description').textContent);
+ Markup.dump('test');
+}
+
+runEditingTest();
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-expected.txt (0 => 95335)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-expected.txt 2011-09-17 00:00:07 UTC (rev 95335)
@@ -0,0 +1,19 @@
+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: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 5 of #text > H1 > DIV > BODY > HTML > #document to 0 of #text > DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 5 of #text > H1 > DIV > BODY > HTML > #document to 5 of #text > H1 > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+This tests deleting line break after h1.
+WebKit should not cancel styles added by h1 by those of document's default style
+| "
+"
+| <h1>
+| "hello<#selection-caret>"
+| "world"
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-style-expected.txt (0 => 95335)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-style-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-style-expected.txt 2011-09-17 00:00:07 UTC (rev 95335)
@@ -0,0 +1,19 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 5 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 5 of #text > H1 > DIV > BODY > HTML > #document to 0 of EM > DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 5 of #text > H1 > DIV > BODY > HTML > #document to 5 of #text > H1 > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+This tests deleting line break after h1.
+WebKit should not cancel styles added by 1 by those of document's default style but keep "world" italicized.
+| "
+"
+| <h1>
+| "hello<#selection-caret>"
+| <em>
+| "world"
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-with-style-expected.txt (0 => 95335)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-with-style-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-with-style-expected.txt 2011-09-17 00:00:07 UTC (rev 95335)
@@ -0,0 +1,19 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 5 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 5 of #text > H1 > DIV > BODY > HTML > #document to 0 of EM > DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 5 of #text > H1 > DIV > BODY > HTML > #document to 5 of #text > H1 > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+This tests deleting line break after h1.
+WebKit should not cancel styles added by h1 by those of document's default style but keep "world" italicized.
+| "
+"
+| <h1>
+| "hello<#selection-caret>"
+| <em>
+| "world"
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-with-style.html (0 => 95335)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-with-style.html (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1-with-style.html 2011-09-17 00:00:07 UTC (rev 95335)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p id="description">This tests deleting line break after h1.
+WebKit should not cancel styles added by h1 by those of document's default style but keep "world" italicized.</p>
+<div id="test" contenteditable>
+<h1>hello</h1>
+<em>world</em>
+</div>
+</div>
+<script src=""
+<script src=""
+<script>
+
+function editingTest() {
+ moveSelectionForwardByLineCommand();
+ deleteCommand();
+
+ Markup.description(document.getElementById('description').textContent);
+ Markup.dump('test');
+}
+
+runEditingTest();
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1.html (0 => 95335)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1.html (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-into-h1.html 2011-09-17 00:00:07 UTC (rev 95335)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p id="description">This tests deleting line break after h1.
+WebKit should not cancel styles added by h1 by those of document's default style</p>
+<div id="test" contenteditable>
+<h1>hello</h1>
+world
+</div>
+</div>
+<script src=""
+<script src=""
+<script>
+
+function editingTest() {
+ moveSelectionForwardByLineCommand();
+ deleteCommand();
+
+ Markup.description(document.getElementById('description').textContent);
+ Markup.dump('test');
+}
+
+runEditingTest();
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-into-pre-expected.txt (0 => 95335)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-into-pre-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-into-pre-expected.txt 2011-09-17 00:00:07 UTC (rev 95335)
@@ -0,0 +1,19 @@
+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: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 5 of #text > PRE > DIV > BODY > HTML > #document to 0 of #text > DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 5 of #text > PRE > DIV > BODY > HTML > #document to 5 of #text > PRE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+This tests deleting line break after pre.
+WebKit should not cancel styles added by pre by those of document's default style.
+| "
+"
+| <pre>
+| "hello<#selection-caret>"
+| "world"
Added: trunk/LayoutTests/editing/deleting/merge-paragraph-into-pre.html (0 => 95335)
--- trunk/LayoutTests/editing/deleting/merge-paragraph-into-pre.html (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraph-into-pre.html 2011-09-17 00:00:07 UTC (rev 95335)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p id="description">This tests deleting line break after pre.
+WebKit should not cancel styles added by pre by those of document's default style.</p>
+<div id="test" contenteditable>
+<pre>hello</pre>
+world
+</div>
+</div>
+<script src=""
+<script src=""
+<script>
+
+function editingTest() {
+ moveSelectionForwardByLineCommand();
+ deleteCommand();
+
+ Markup.description(document.getElementById('description').textContent);
+ Markup.dump('test');
+}
+
+runEditingTest();
+</script>
+</body>
+</html>
Modified: trunk/LayoutTests/platform/mac/editing/deleting/merge-whitespace-pre-expected.png
(Binary files differ)
Modified: trunk/LayoutTests/platform/mac/editing/deleting/merge-whitespace-pre-expected.txt (95334 => 95335)
--- trunk/LayoutTests/platform/mac/editing/deleting/merge-whitespace-pre-expected.txt 2011-09-16 23:33:23 UTC (rev 95334)
+++ trunk/LayoutTests/platform/mac/editing/deleting/merge-whitespace-pre-expected.txt 2011-09-17 00:00:07 UTC (rev 95335)
@@ -12,9 +12,8 @@
RenderBlock {DIV} at (0,0) size 784x18
RenderText {#text} at (0,0) size 21x18
text run at (0,0) width 21: "foo"
- RenderInline {SPAN} at (0,0) size 24x15
- RenderText {#text} at (21,2) size 24x15
- text run at (21,2) width 24: "bar"
+ RenderText {#text} at (21,0) size 20x18
+ text run at (21,0) width 20: "bar"
RenderBlock {PRE} at (0,31) size 784x15
RenderText {#text} at (0,0) size 24x15
text run at (0,0) width 24: "baz"
Modified: trunk/Source/WebCore/ChangeLog (95334 => 95335)
--- trunk/Source/WebCore/ChangeLog 2011-09-16 23:33:23 UTC (rev 95334)
+++ trunk/Source/WebCore/ChangeLog 2011-09-17 00:00:07 UTC (rev 95335)
@@ -1,3 +1,31 @@
+2011-09-14 Ryosuke Niwa <rn...@webkit.org>
+
+ Deleting line break before h1 converts h1 to span
+ https://bugs.webkit.org/show_bug.cgi?id=45784
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Fixed the bug by treating h1 and other elements that retain structure like Mail blockquote.
+
+ We already had a logic to overriding styles of merged paragraphs by Mail blockquote so
+ just extend this logic for h1-h6, pre, etc...
+
+ Tests: editing/deleting/merge-paragraph-from-address.html
+ editing/deleting/merge-paragraph-from-h6-with-style.html
+ editing/deleting/merge-paragraph-from-h6.html
+ editing/deleting/merge-paragraph-from-listing.html
+ editing/deleting/merge-paragraph-into-h1-with-style.html
+ editing/deleting/merge-paragraph-into-h1.html
+ editing/deleting/merge-paragraph-into-pre.html
+
+ * editing/ReplaceSelectionCommand.cpp:
+ (WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
+ * editing/markup.cpp:
+ (WebCore::isBlockNodeToRetainAppearance): Extracted from ancestorToRetainStructureAndAppearance.
+ (WebCore::StyledMarkupAccumulator::serializeNodes):
+ (WebCore::ancestorToRetainStructureAndAppearance):
+ * editing/markup.h:
+
2011-09-16 Max Perepelitsyn <pph...@gmail.com>
Set but not used variables cleanup (gcc 4.6)
Modified: trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp (95334 => 95335)
--- trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2011-09-16 23:33:23 UTC (rev 95334)
+++ trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2011-09-17 00:00:07 UTC (rev 95335)
@@ -496,7 +496,7 @@
// If Mail wraps the fragment with a Paste as Quotation blockquote, or if you're pasting into a quoted region,
// styles from blockquoteNode are allowed to override those from the source document, see <rdar://problem/4930986> and <rdar://problem/5089327>.
- Node* blockquoteNode = isMailPasteAsQuotationNode(context) ? context : enclosingNodeOfType(firstPositionInNode(context), isMailBlockquote, CanCrossEditingBoundary);
+ Node* blockquoteNode = isMailPasteAsQuotationNode(context) ? context : enclosingNodeOfType(firstPositionInNode(context), isBlockNodeToRetainAppearance, CanCrossEditingBoundary);
if (blockquoteNode)
newInlineStyle->removeStyleFromRulesAndContext(element, document()->documentElement());
Modified: trunk/Source/WebCore/editing/markup.cpp (95334 => 95335)
--- trunk/Source/WebCore/editing/markup.cpp 2011-09-16 23:33:23 UTC (rev 95334)
+++ trunk/Source/WebCore/editing/markup.cpp 2011-09-17 00:00:07 UTC (rev 95335)
@@ -336,6 +336,24 @@
appendCloseTag(out, element);
}
+bool isBlockNodeToRetainAppearance(const Node* node)
+{
+ DEFINE_STATIC_LOCAL(HashSet<QualifiedName::QualifiedNameImpl*>, names, ());
+ if (!names.size()) {
+ names.add(addressTag.impl());
+ names.add(blockquoteTag.impl());
+ names.add(h1Tag.impl());
+ names.add(h2Tag.impl());
+ names.add(h3Tag.impl());
+ names.add(h4Tag.impl());
+ names.add(h5Tag.impl());
+ names.add(h6Tag.impl());
+ names.add(listingTag.impl());
+ names.add(preTag.impl());
+ }
+ return node->isElementNode() && names.contains(toElement(node)->tagQName().impl());
+}
+
Node* StyledMarkupAccumulator::serializeNodes(Node* startNode, Node* pastEnd)
{
if (!m_highestNodeToBeSerialized) {
@@ -350,7 +368,7 @@
// Styles that Mail blockquotes contribute should only be placed on the Mail blockquote,
// to help us differentiate those styles from ones that the user has applied.
// This helps us get the color of content pasted into blockquotes right.
- m_wrappingStyle->removeStyleAddedByNode(enclosingNodeOfType(firstPositionInOrBeforeNode(parentOfHighestNode), isMailBlockquote, CanCrossEditingBoundary));
+ m_wrappingStyle->removeStyleAddedByNode(enclosingNodeOfType(firstPositionInOrBeforeNode(parentOfHighestNode), isBlockNodeToRetainAppearance, CanCrossEditingBoundary));
// Call collapseTextDecorationProperties first or otherwise it'll copy the value over from in-effect to text-decorations.
m_wrappingStyle->collapseTextDecorationProperties();
@@ -453,17 +471,11 @@
return table;
}
- if (commonAncestorBlock->hasTagName(listingTag)
+ if (isBlockNodeToRetainAppearance(commonAncestorBlock)
|| commonAncestorBlock->hasTagName(olTag)
- || commonAncestorBlock->hasTagName(preTag)
|| commonAncestorBlock->hasTagName(tableTag)
|| commonAncestorBlock->hasTagName(ulTag)
- || commonAncestorBlock->hasTagName(xmpTag)
- || commonAncestorBlock->hasTagName(h1Tag)
- || commonAncestorBlock->hasTagName(h2Tag)
- || commonAncestorBlock->hasTagName(h3Tag)
- || commonAncestorBlock->hasTagName(h4Tag)
- || commonAncestorBlock->hasTagName(h5Tag))
+ || commonAncestorBlock->hasTagName(xmpTag))
return commonAncestorBlock;
return 0;
Modified: trunk/Source/WebCore/editing/markup.h (95334 => 95335)
--- trunk/Source/WebCore/editing/markup.h 2011-09-16 23:33:23 UTC (rev 95334)
+++ trunk/Source/WebCore/editing/markup.h 2011-09-17 00:00:07 UTC (rev 95335)
@@ -49,10 +49,11 @@
bool isPlainTextMarkup(Node *node);
+ bool isBlockNodeToRetainAppearance(const Node*);
String createMarkup(const Range*,
Vector<Node*>* = 0, EAnnotateForInterchange = DoNotAnnotateForInterchange, bool convertBlocksToInlines = false, EAbsoluteURLs = DoNotResolveURLs);
String createMarkup(const Node*, EChildrenOnly = IncludeNode, Vector<Node*>* = 0, EAbsoluteURLs = DoNotResolveURLs);
-
+
String createFullMarkup(const Node*);
String createFullMarkup(const Range*);