[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

rniwa at webkit.org rniwa at webkit.org
Wed Dec 22 18:44:17 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 50fa7d151925473310c3a494705458bdc634965d
Author: rniwa at webkit.org <rniwa at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 16 22:08:01 2010 +0000

    2010-12-16  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Darin Adler.
    
            execCommand('JustifyCenter') adds extra BR
            https://bugs.webkit.org/show_bug.cgi?id=51082
    
            The bug was caused by moveParagraphContentsToNewBlockIfNecessary's adding a placeholder br
            to new block and not removing it later. Fixed the bug by removing it when the paragraph
            moved into the block didn't have a br at the end.
    
            Test: editing/execCommand/justify.html
    
            * editing/CompositeEditCommand.cpp:
            (WebCore::CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary):
    2010-12-16  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Darin Adler.
    
            execCommand('JustifyCenter') adds extra BR
            https://bugs.webkit.org/show_bug.cgi?id=51082
    
            Added a test to ensure WebKit executes Justify* properly. In particular,
            this test ensures WebKit does not erroneously add a BR at the end of each block.
    
            * editing/execCommand/justify-expected.txt: Added.
            * editing/execCommand/justify.html: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74214 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index cbad9a1..179287f 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2010-12-16  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        execCommand('JustifyCenter') adds extra BR
+        https://bugs.webkit.org/show_bug.cgi?id=51082
+
+        Added a test to ensure WebKit executes Justify* properly. In particular,
+        this test ensures WebKit does not erroneously add a BR at the end of each block.
+
+        * editing/execCommand/justify-expected.txt: Added.
+        * editing/execCommand/justify.html: Added.
+
 2010-12-16  Jian Li  <jianli at chromium.org>
 
         Unreviewed. Updated chromium test expectations.
diff --git a/LayoutTests/editing/execCommand/justify-expected.txt b/LayoutTests/editing/execCommand/justify-expected.txt
new file mode 100644
index 0000000..d5c118e
--- /dev/null
+++ b/LayoutTests/editing/execCommand/justify-expected.txt
@@ -0,0 +1,53 @@
+Tests justifying paragraphs to left, right, and center.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+Center
+PASS execCommand('JustifyCenter') returned "<div style="text-align: center;"><br></div>" selecting first position of ""
+PASS execCommand('JustifyCenter') returned "<div style="text-align: center;"><br></div>" selecting first position of "<br>"
+PASS execCommand('JustifyCenter') returned "<div style="text-align: center;"><br></div><br>" selecting first position of "<br><br>"
+PASS execCommand('JustifyCenter') returned "<div style="text-align: center;">hello</div>" selecting first position of "hello"
+PASS execCommand('JustifyCenter') returned "<div style="text-align: center;">hello</div><p>world</p>" selecting first position of "hello<p>world</p>"
+PASS execCommand('JustifyCenter') returned "<p style="text-align: center;">hello</p>world" selecting first position of "<p>hello</p>world"
+PASS execCommand('JustifyCenter') returned "<div style="text-align: center;">hello</div><blockquote style="text-align: center;">world</blockquote>" selecting all of "hello<blockquote>world</blockquote>"
+PASS execCommand('JustifyCenter') returned "<h3 style="text-align: center;">hello</h3><div style="text-align: center;">world</div>" selecting all of "<h3>hello</h3>world"
+PASS execCommand('JustifyCenter') returned "<div style="text-align: center;">hello<br>world</div>" selecting first position of "<div style="text-align: center;">hello<br>world</div>"
+
+Full
+PASS execCommand('JustifyFull') returned "<div style="text-align: justify;"><br></div>" selecting first position of ""
+PASS execCommand('JustifyFull') returned "<div style="text-align: justify;"><br></div>" selecting first position of "<br>"
+PASS execCommand('JustifyFull') returned "<div style="text-align: justify;"><br></div><br>" selecting first position of "<br><br>"
+PASS execCommand('JustifyFull') returned "<div style="text-align: justify;">hello</div>" selecting first position of "hello"
+PASS execCommand('JustifyFull') returned "<div style="text-align: justify;">hello</div><p>world</p>" selecting first position of "hello<p>world</p>"
+PASS execCommand('JustifyFull') returned "<p style="text-align: justify;">hello</p>world" selecting first position of "<p>hello</p>world"
+PASS execCommand('JustifyFull') returned "<div style="text-align: justify;">hello</div><blockquote style="text-align: justify;">world</blockquote>" selecting all of "hello<blockquote>world</blockquote>"
+PASS execCommand('JustifyFull') returned "<h3 style="text-align: justify;">hello</h3><div style="text-align: justify;">world</div>" selecting all of "<h3>hello</h3>world"
+PASS execCommand('JustifyFull') returned "<div style="text-align: justify;">hello<br>world</div>" selecting first position of "<div style="text-align: justify;">hello<br>world</div>"
+
+Left
+PASS execCommand('JustifyLeft') returned "<div style="text-align: left;"><br></div>" selecting first position of ""
+PASS execCommand('JustifyLeft') returned "<div style="text-align: left;"><br></div>" selecting first position of "<br>"
+PASS execCommand('JustifyLeft') returned "<div style="text-align: left;"><br></div><br>" selecting first position of "<br><br>"
+PASS execCommand('JustifyLeft') returned "<div style="text-align: left;">hello</div>" selecting first position of "hello"
+PASS execCommand('JustifyLeft') returned "<div style="text-align: left;">hello</div><p>world</p>" selecting first position of "hello<p>world</p>"
+PASS execCommand('JustifyLeft') returned "<p style="text-align: left;">hello</p>world" selecting first position of "<p>hello</p>world"
+PASS execCommand('JustifyLeft') returned "<div style="text-align: left;">hello</div><blockquote style="text-align: left;">world</blockquote>" selecting all of "hello<blockquote>world</blockquote>"
+PASS execCommand('JustifyLeft') returned "<h3 style="text-align: left;">hello</h3><div style="text-align: left;">world</div>" selecting all of "<h3>hello</h3>world"
+PASS execCommand('JustifyLeft') returned "<div style="text-align: left;">hello<br>world</div>" selecting first position of "<div style="text-align: left;">hello<br>world</div>"
+
+Right
+PASS execCommand('JustifyRight') returned "<div style="text-align: right;"><br></div>" selecting first position of ""
+PASS execCommand('JustifyRight') returned "<div style="text-align: right;"><br></div>" selecting first position of "<br>"
+PASS execCommand('JustifyRight') returned "<div style="text-align: right;"><br></div><br>" selecting first position of "<br><br>"
+PASS execCommand('JustifyRight') returned "<div style="text-align: right;">hello</div>" selecting first position of "hello"
+PASS execCommand('JustifyRight') returned "<div style="text-align: right;">hello</div><p>world</p>" selecting first position of "hello<p>world</p>"
+PASS execCommand('JustifyRight') returned "<p style="text-align: right;">hello</p>world" selecting first position of "<p>hello</p>world"
+PASS execCommand('JustifyRight') returned "<div style="text-align: right;">hello</div><blockquote style="text-align: right;">world</blockquote>" selecting all of "hello<blockquote>world</blockquote>"
+PASS execCommand('JustifyRight') returned "<h3 style="text-align: right;">hello</h3><div style="text-align: right;">world</div>" selecting all of "<h3>hello</h3>world"
+PASS execCommand('JustifyRight') returned "<div style="text-align: right;">hello<br>world</div>" selecting first position of "<div style="text-align: right;">hello<br>world</div>"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/editing/execCommand/justify.html b/LayoutTests/editing/execCommand/justify.html
new file mode 100644
index 0000000..595beb0
--- /dev/null
+++ b/LayoutTests/editing/execCommand/justify.html
@@ -0,0 +1,109 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("Tests justifying paragraphs to left, right, and center.")
+
+var testContainer = document.createElement("div");
+testContainer.contentEditable = true;
+document.body.appendChild(testContainer);
+
+function testJustifying(selector, command, content, expected)
+{
+    testContainer.innerHTML = content;
+    var selected = selector(testContainer);
+    document.execCommand(command, false, null);
+    var actual = testContainer.innerHTML;
+    var action = "execCommand('" + command + "') returned \"" + actual + '" selecting ' + selected + ' of "' + content + '"';
+    if (!expected)
+        expected = content;
+    if (actual == expected)
+        testPassed(action);
+    else
+        testFailed(action + ' but expected "' + expected + '"');
+}
+
+function selectFirstPosition(container) {
+    while (container.firstChild)
+        container = container.firstChild;
+    window.getSelection().setPosition(container, 0);
+    return 'first position'
+}
+
+function selectAll(container) {
+    window.getSelection().selectAllChildren(container);
+    return 'all'
+}
+
+function selectMiddleOfHelloWorld(container) {
+    window.getSelection().setPosition(container, 0);
+    window.getSelection().modify('move', 'forward', 'character');
+    window.getSelection().modify('move', 'forward', 'character');
+    window.getSelection().modify('extend', 'forward', 'word');
+    window.getSelection().modify('extend', 'forward', 'character');
+    window.getSelection().modify('extend', 'forward', 'character');
+    window.getSelection().modify('extend', 'forward', 'character');
+    return '"llo wo"'
+}
+
+debug('\nCenter');
+testJustifying(selectFirstPosition, 'JustifyCenter', '', '<div style="text-align: center;"><br></div>');
+testJustifying(selectFirstPosition, 'JustifyCenter', '<br>', '<div style="text-align: center;"><br></div>');
+testJustifying(selectFirstPosition, 'JustifyCenter', '<br><br>', '<div style="text-align: center;"><br></div><br>');
+testJustifying(selectFirstPosition, 'JustifyCenter', 'hello', '<div style="text-align: center;">hello</div>');
+testJustifying(selectFirstPosition, 'JustifyCenter', 'hello<p>world</p>', '<div style="text-align: center;">hello</div><p>world</p>');
+testJustifying(selectFirstPosition, 'JustifyCenter', '<p>hello</p>world', '<p style="text-align: center;">hello</p>world');
+testJustifying(selectAll, 'JustifyCenter', 'hello<blockquote>world</blockquote>', '<div style="text-align: center;">hello</div><blockquote style="text-align: center;">world</blockquote>');
+testJustifying(selectAll, 'JustifyCenter', '<h3>hello</h3>world', '<h3 style="text-align: center;">hello</h3><div style="text-align: center;">world</div>');
+testJustifying(selectFirstPosition, 'JustifyCenter', '<div style="text-align: center;">hello<br>world</div>');
+
+debug('\nFull');
+testJustifying(selectFirstPosition, 'JustifyFull', '', '<div style="text-align: justify;"><br></div>');
+testJustifying(selectFirstPosition, 'JustifyFull', '<br>', '<div style="text-align: justify;"><br></div>');
+testJustifying(selectFirstPosition, 'JustifyFull', '<br><br>', '<div style="text-align: justify;"><br></div><br>');
+testJustifying(selectFirstPosition, 'JustifyFull', 'hello', '<div style="text-align: justify;">hello</div>');
+testJustifying(selectFirstPosition, 'JustifyFull', 'hello<p>world</p>', '<div style="text-align: justify;">hello</div><p>world</p>');
+testJustifying(selectFirstPosition, 'JustifyFull', '<p>hello</p>world', '<p style="text-align: justify;">hello</p>world');
+testJustifying(selectAll, 'JustifyFull', 'hello<blockquote>world</blockquote>', '<div style="text-align: justify;">hello</div><blockquote style="text-align: justify;">world</blockquote>');
+testJustifying(selectAll, 'JustifyFull', '<h3>hello</h3>world', '<h3 style="text-align: justify;">hello</h3><div style="text-align: justify;">world</div>');
+testJustifying(selectFirstPosition, 'JustifyFull', '<div style="text-align: justify;">hello<br>world</div>');
+
+// Because the default alignment is left, we need to force a different alignment to test "left"
+testContainer.style.textAlign = 'center';
+
+debug('\nLeft');
+testJustifying(selectFirstPosition, 'JustifyLeft', '', '<div style="text-align: left;"><br></div>');
+testJustifying(selectFirstPosition, 'JustifyLeft', '<br>', '<div style="text-align: left;"><br></div>');
+testJustifying(selectFirstPosition, 'JustifyLeft', '<br><br>', '<div style="text-align: left;"><br></div><br>');
+testJustifying(selectFirstPosition, 'JustifyLeft', 'hello', '<div style="text-align: left;">hello</div>');
+testJustifying(selectFirstPosition, 'JustifyLeft', 'hello<p>world</p>', '<div style="text-align: left;">hello</div><p>world</p>');
+testJustifying(selectFirstPosition, 'JustifyLeft', '<p>hello</p>world', '<p style="text-align: left;">hello</p>world');
+testJustifying(selectAll, 'JustifyLeft', 'hello<blockquote>world</blockquote>', '<div style="text-align: left;">hello</div><blockquote style="text-align: left;">world</blockquote>');
+testJustifying(selectAll, 'JustifyLeft', '<h3>hello</h3>world', '<h3 style="text-align: left;">hello</h3><div style="text-align: left;">world</div>');
+testJustifying(selectFirstPosition, 'JustifyLeft', '<div style="text-align: left;">hello<br>world</div>');
+
+debug('\nRight');
+testJustifying(selectFirstPosition, 'JustifyRight', '', '<div style="text-align: right;"><br></div>');
+testJustifying(selectFirstPosition, 'JustifyRight', '<br>', '<div style="text-align: right;"><br></div>');
+testJustifying(selectFirstPosition, 'JustifyRight', '<br><br>', '<div style="text-align: right;"><br></div><br>');
+testJustifying(selectFirstPosition, 'JustifyRight', 'hello', '<div style="text-align: right;">hello</div>');
+testJustifying(selectFirstPosition, 'JustifyRight', 'hello<p>world</p>', '<div style="text-align: right;">hello</div><p>world</p>');
+testJustifying(selectFirstPosition, 'JustifyRight', '<p>hello</p>world', '<p style="text-align: right;">hello</p>world');
+testJustifying(selectAll, 'JustifyRight', 'hello<blockquote>world</blockquote>', '<div style="text-align: right;">hello</div><blockquote style="text-align: right;">world</blockquote>');
+testJustifying(selectAll, 'JustifyRight', '<h3>hello</h3>world', '<h3 style="text-align: right;">hello</h3><div style="text-align: right;">world</div>');
+testJustifying(selectFirstPosition, 'JustifyRight', '<div style="text-align: right;">hello<br>world</div>');
+
+document.body.removeChild(testContainer);
+var successfullyParsed = true;
+
+</script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index b2f2296..3a1a8a7 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,19 @@
+2010-12-16  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        execCommand('JustifyCenter') adds extra BR
+        https://bugs.webkit.org/show_bug.cgi?id=51082
+
+        The bug was caused by moveParagraphContentsToNewBlockIfNecessary's adding a placeholder br
+        to new block and not removing it later. Fixed the bug by removing it when the paragraph
+        moved into the block didn't have a br at the end.
+
+        Test: editing/execCommand/justify.html
+
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary):
+
 2010-12-16  Jian Li  <jianli at chromium.org>
 
         Unreviewed. Fixed chromium build break caused by r74207.
diff --git a/WebCore/editing/CompositeEditCommand.cpp b/WebCore/editing/CompositeEditCommand.cpp
index 92e3de5..748777d 100644
--- a/WebCore/editing/CompositeEditCommand.cpp
+++ b/WebCore/editing/CompositeEditCommand.cpp
@@ -716,8 +716,13 @@ PassRefPtr<Node> CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessar
 
     RefPtr<Node> newBlock = insertNewDefaultParagraphElementAt(upstreamStart);
     
+    bool endWasBr = visibleParagraphEnd.deepEquivalent().node()->hasTagName(brTag);
+
     moveParagraphs(visibleParagraphStart, visibleParagraphEnd, VisiblePosition(Position(newBlock.get(), 0)));
-    
+
+    if (newBlock->lastChild() && newBlock->lastChild()->hasTagName(brTag) && !endWasBr)
+        removeNode(newBlock->lastChild());
+
     return newBlock.release();
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list