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

rniwa at webkit.org rniwa at webkit.org
Wed Dec 22 13:50:12 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 06f1791f9ffbf965999684b142645ca655cf283a
Author: rniwa at webkit.org <rniwa at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Sep 28 01:22:57 2010 +0000

    2010-09-27  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Darin Adler.
    
            queryCommandState with justifyCenter, justifyLeft, and justifyRight always return false
            https://bugs.webkit.org/show_bug.cgi?id=45910
    
            Implemented queryCommandState for justifyCenter, justifyLeft, and justifyRight commands.
            Added getTextAlignment to convert -webkit-center, -webkit-left, and -webkit-right to
            center, left, and right respectively because they can be treated equally for editing purposes.
    
            Test: editing/execCommand/query-text-alignment.html
    
            * editing/ApplyStyleCommand.cpp:
            (WebCore::getTextAlignment): Added.
            (WebCore::getPropertiesNotIn): Uses getTextAlignment.
            * editing/EditorCommand.cpp:
            (WebCore::stateJustifyCenter): Added.
            (WebCore::stateJustifyLeft): Added.
            (WebCore::stateJustifyRight): Added.
            (WebCore::createCommandMap): Refers to stateJustifyCenter, stateJustifyLeft, and stateJustifyRight.
    2010-09-27  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Darin Adler.
    
            queryCommandState with justifyCenter, justifyLeft, and justifyRight always return false
            https://bugs.webkit.org/show_bug.cgi?id=45910
    
            Added tests for queryCommandState with justifyCenter, justifyLeft, and justifyRight commands.
    
            * editing/execCommand/query-text-alignment-expected.txt: Added.
            * editing/execCommand/query-text-alignment.html: Added.
            * editing/execCommand/script-tests/query-text-alignment.js: Added.
            (queryTextAlignment):
            (selectFirstPosition):
            (selectMiddleOfHelloWorld):
            (runRangeTests):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68465 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 07be41c..f6287ab 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,20 @@
+2010-09-27  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        queryCommandState with justifyCenter, justifyLeft, and justifyRight always return false
+        https://bugs.webkit.org/show_bug.cgi?id=45910
+
+        Added tests for queryCommandState with justifyCenter, justifyLeft, and justifyRight commands.
+
+        * editing/execCommand/query-text-alignment-expected.txt: Added.
+        * editing/execCommand/query-text-alignment.html: Added.
+        * editing/execCommand/script-tests/query-text-alignment.js: Added.
+        (queryTextAlignment):
+        (selectFirstPosition):
+        (selectMiddleOfHelloWorld):
+        (runRangeTests):
+
 2010-09-27  James Robinson  <jamesr at chromium.org>
 
         Update baselines for fast/repaint/repaint-svg-after-style-change.html
diff --git a/LayoutTests/editing/execCommand/query-text-alignment-expected.txt b/LayoutTests/editing/execCommand/query-text-alignment-expected.txt
new file mode 100644
index 0000000..ca47482
--- /dev/null
+++ b/LayoutTests/editing/execCommand/query-text-alignment-expected.txt
@@ -0,0 +1,59 @@
+Tests queryCommandState('justifyCenter'), queryCommandState('justifyLeft'), queryCommandState('justifyRight')
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Caret
+PASS queryCommand('format') returns "" when selecting no selection on of "hello"
+PASS queryCommand('format') returns "" when selecting first position of "hello"
+PASS queryCommand('format') returns "" when selecting first position of "<p>hello</p>"
+PASS queryCommand('format') returns "center" when selecting first position of "<p align="center">hello</p>"
+PASS queryCommand('format') returns "left" when selecting first position of "<p align="left">hello</p>"
+PASS queryCommand('format') returns "right" when selecting first position of "<p align="right">hello</p>"
+PASS queryCommand('format') returns "center" when selecting first position of "<p style="text-align: center;">hello</p>"
+PASS queryCommand('format') returns "left" when selecting first position of "<p style="text-align: left;">hello</p>"
+PASS queryCommand('format') returns "right" when selecting first position of "<p style="text-align: right;">hello</p>"
+PASS queryCommand('format') returns "left" when selecting first position of "<p align="right" style="text-align: left;">hello</p>"
+PASS queryCommand('format') returns "right" when selecting first position of "<p align="center" style="text-align: right;">hello</p>"
+PASS queryCommand('format') returns "center" when selecting first position of "<p align="left" style="text-align: center;">hello</p>"
+PASS queryCommand('format') returns "left" when selecting first position of "<p align="right" style="text-align: left;">hello</p>"
+PASS queryCommand('format') returns "right" when selecting first position of "<p align="center" style="text-align: right;">hello</p>"
+PASS queryCommand('format') returns "center" when selecting first position of "<p align="left" style="text-align: center;">hello</p>"
+PASS queryCommand('format') returns "" when selecting first position of "<h1>hello</h1>"
+PASS queryCommand('format') returns "center" when selecting first position of "<h1 align="center">hello</h1>"
+PASS queryCommand('format') returns "left" when selecting first position of "<h2 align="left">hello</h2>"
+PASS queryCommand('format') returns "right" when selecting first position of "<h3 align="right">hello</h3>"
+PASS queryCommand('format') returns "center" when selecting first position of "<h4 align="center">hello</h4>"
+PASS queryCommand('format') returns "left" when selecting first position of "<h5 align="left">hello</h5>"
+PASS queryCommand('format') returns "right" when selecting first position of "<h6 align="right">hello</h6>"
+PASS queryCommand('format') returns "center" when selecting first position of "<div align="center">hello</div>"
+PASS queryCommand('format') returns "left" when selecting first position of "<div align="left">hello</div>"
+PASS queryCommand('format') returns "right" when selecting first position of "<div align="right">hello</div>"
+
+Tests for win
+PASS queryCommand('format') returns "" when selecting middle of "<p>hello</p><p>world</p>"
+PASS queryCommand('format') returns "" when selecting middle of "<p align="left">hello</p><p>world</p>"
+PASS queryCommand('format') returns "" when selecting middle of "<p>hello</p><p align="left">world</p>"
+PASS queryCommand('format') returns "" when selecting middle of "<p align="left">hello</p><p align="right">world</p>"
+PASS queryCommand('format') returns "center" when selecting middle of "<p align="center">hello</p><p align="center">world</p>"
+PASS queryCommand('format') returns "left" when selecting middle of "<p align="left">hello</p><p align="left">world</p>"
+PASS queryCommand('format') returns "right" when selecting middle of "<p align="right">hello</p><p align="right">world</p>"
+PASS queryCommand('format') returns "" when selecting middle of "<div align="right">hello<p align="left">world</p></div>"
+PASS queryCommand('format') returns "" when selecting middle of "<div align="left"><p align="center">world</p>hello</div>"
+FAIL queryCommand('format') returns "" when selecting middle of "<p align="left">hello</p><p>w</p><p align="left">orld</p>" but expected "[object Object]"
+
+Tests for mac
+PASS queryCommand('format') returns "" when selecting middle of "<p>hello</p><p>world</p>"
+PASS queryCommand('format') returns "left" when selecting middle of "<p align="left">hello</p><p>world</p>"
+PASS queryCommand('format') returns "" when selecting middle of "<p>hello</p><p align="left">world</p>"
+PASS queryCommand('format') returns "left" when selecting middle of "<p align="left">hello</p><p align="right">world</p>"
+PASS queryCommand('format') returns "center" when selecting middle of "<p align="center">hello</p><p align="center">world</p>"
+PASS queryCommand('format') returns "left" when selecting middle of "<p align="left">hello</p><p align="left">world</p>"
+PASS queryCommand('format') returns "right" when selecting middle of "<p align="right">hello</p><p align="right">world</p>"
+PASS queryCommand('format') returns "right" when selecting middle of "<div align="right">hello<p align="left">world</p></div>"
+PASS queryCommand('format') returns "center" when selecting middle of "<div align="left"><p align="center">world</p>hello</div>"
+FAIL queryCommand('format') returns "left" when selecting middle of "<p align="left">hello</p><p>w</p><p align="left">orld</p>" but expected "[object Object]"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/editing/execCommand/query-text-alignment.html b/LayoutTests/editing/execCommand/query-text-alignment.html
new file mode 100644
index 0000000..8a29452
--- /dev/null
+++ b/LayoutTests/editing/execCommand/query-text-alignment.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<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 src="script-tests/query-text-alignment.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/editing/execCommand/script-tests/query-text-alignment.js b/LayoutTests/editing/execCommand/script-tests/query-text-alignment.js
new file mode 100644
index 0000000..2e7d936
--- /dev/null
+++ b/LayoutTests/editing/execCommand/script-tests/query-text-alignment.js
@@ -0,0 +1,94 @@
+description("Tests queryCommandState('justifyCenter'), queryCommandState('justifyLeft'), queryCommandState('justifyRight')")
+
+var testContainer = document.createElement("div");
+testContainer.contentEditable = true;
+document.body.appendChild(testContainer);
+
+function queryTextAlignment(selector, content, expected)
+{
+    testContainer.innerHTML = content;
+    var selected = selector(testContainer);
+    var center = document.queryCommandState('justifyCenter');
+    var left = document.queryCommandState('justifyLeft');
+    var right = document.queryCommandState('justifyRight');
+    if ((center && left) || (left && right) || (right && center))
+        testFailed('Inconsistent state when selecting ' + selected + ' of "' + content + '".  More than one of justifyCenter, justifyRight, and justifyLeft returned true.')
+
+    var actual = center ? 'center' : left ? 'left' : right ? 'right' : '';
+    var action = "queryCommand('format') returns \"" + actual + '" when selecting ' + selected + ' of "' + 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 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 'middle';
+}
+
+debug('Caret');
+queryTextAlignment(function () {return 'no selection on'}, 'hello', '');
+queryTextAlignment(selectFirstPosition, 'hello', '');
+queryTextAlignment(selectFirstPosition, '<p>hello</p>', '');
+queryTextAlignment(selectFirstPosition, '<p align="center">hello</p>', 'center');
+queryTextAlignment(selectFirstPosition, '<p align="left">hello</p>', 'left');
+queryTextAlignment(selectFirstPosition, '<p align="right">hello</p>', 'right');
+queryTextAlignment(selectFirstPosition, '<p style="text-align: center;">hello</p>', 'center');
+queryTextAlignment(selectFirstPosition, '<p style="text-align: left;">hello</p>', 'left');
+queryTextAlignment(selectFirstPosition, '<p style="text-align: right;">hello</p>', 'right');
+queryTextAlignment(selectFirstPosition, '<p align="right" style="text-align: left;">hello</p>', 'left');
+queryTextAlignment(selectFirstPosition, '<p align="center" style="text-align: right;">hello</p>', 'right');
+queryTextAlignment(selectFirstPosition, '<p align="left" style="text-align: center;">hello</p>', 'center');
+queryTextAlignment(selectFirstPosition, '<p align="right" style="text-align: left;">hello</p>', 'left');
+queryTextAlignment(selectFirstPosition, '<p align="center" style="text-align: right;">hello</p>', 'right');
+queryTextAlignment(selectFirstPosition, '<p align="left" style="text-align: center;">hello</p>', 'center');
+queryTextAlignment(selectFirstPosition, '<h1>hello</h1>', '');
+queryTextAlignment(selectFirstPosition, '<h1 align="center">hello</h1>', 'center');
+queryTextAlignment(selectFirstPosition, '<h2 align="left">hello</h2>', 'left');
+queryTextAlignment(selectFirstPosition, '<h3 align="right">hello</h3>', 'right');
+queryTextAlignment(selectFirstPosition, '<h4 align="center">hello</h4>', 'center');
+queryTextAlignment(selectFirstPosition, '<h5 align="left">hello</h5>', 'left');
+queryTextAlignment(selectFirstPosition, '<h6 align="right">hello</h6>', 'right');
+queryTextAlignment(selectFirstPosition, '<div align="center">hello</div>', 'center');
+queryTextAlignment(selectFirstPosition, '<div align="left">hello</div>', 'left');
+queryTextAlignment(selectFirstPosition, '<div align="right">hello</div>', 'right');
+
+function runRangeTests(editingBehavior)
+{
+    if (window.layoutTestController)
+        layoutTestController.setEditingBehavior(editingBehavior);
+    debug('Tests for ' + editingBehavior);
+
+    queryTextAlignment(selectMiddleOfHelloWorld, '<p>hello</p><p>world</p>', '');
+    queryTextAlignment(selectMiddleOfHelloWorld, '<p align="left">hello</p><p>world</p>', {'mac': 'left', 'win': ''}[editingBehavior]);
+    queryTextAlignment(selectMiddleOfHelloWorld, '<p>hello</p><p align="left">world</p>', '');
+    queryTextAlignment(selectMiddleOfHelloWorld, '<p align="left">hello</p><p align="right">world</p>', {'mac': 'left', 'win': ''}[editingBehavior]);
+    queryTextAlignment(selectMiddleOfHelloWorld, '<p align="center">hello</p><p align="center">world</p>', 'center');
+    queryTextAlignment(selectMiddleOfHelloWorld, '<p align="left">hello</p><p align="left">world</p>', 'left');
+    queryTextAlignment(selectMiddleOfHelloWorld, '<p align="right">hello</p><p align="right">world</p>', 'right');
+    queryTextAlignment(selectMiddleOfHelloWorld, '<div align="right">hello<p align="left">world</p></div>', {'mac': 'right', 'win': ''}[editingBehavior]);
+    queryTextAlignment(selectMiddleOfHelloWorld, '<div align="left"><p align="center">world</p>hello</div>', {'mac': 'center', 'win': ''}[editingBehavior]);
+    queryTextAlignment(selectMiddleOfHelloWorld, '<p align="left">hello</p><p>w</p><p align="left">orld</p>', {'mac': 'left', 'win': ''});
+}
+
+debug('');
+runRangeTests('win');
+debug('');
+runRangeTests('mac');
+
+document.body.removeChild(testContainer);
+var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 8a01298..b641102 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-09-27  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        queryCommandState with justifyCenter, justifyLeft, and justifyRight always return false
+        https://bugs.webkit.org/show_bug.cgi?id=45910
+
+        Implemented queryCommandState for justifyCenter, justifyLeft, and justifyRight commands.
+        Added getTextAlignment to convert -webkit-center, -webkit-left, and -webkit-right to
+        center, left, and right respectively because they can be treated equally for editing purposes.
+
+        Test: editing/execCommand/query-text-alignment.html
+
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::getTextAlignment): Added.
+        (WebCore::getPropertiesNotIn): Uses getTextAlignment.
+        * editing/EditorCommand.cpp:
+        (WebCore::stateJustifyCenter): Added.
+        (WebCore::stateJustifyLeft): Added.
+        (WebCore::stateJustifyRight): Added.
+        (WebCore::createCommandMap): Refers to stateJustifyCenter, stateJustifyLeft, and stateJustifyRight.
+
 2010-09-27  Alpha Lam  <hclam at chromium.org>
 
         Unreviewed. Build fix.
diff --git a/WebCore/editing/ApplyStyleCommand.cpp b/WebCore/editing/ApplyStyleCommand.cpp
index a904033..3ff7169 100644
--- a/WebCore/editing/ApplyStyleCommand.cpp
+++ b/WebCore/editing/ApplyStyleCommand.cpp
@@ -388,6 +388,23 @@ static bool fontWeightIsBold(CSSStyleDeclaration* style)
     return false; // Make compiler happy
 }
 
+static int getTextAlignment(CSSStyleDeclaration* style)
+{
+    int textAlign = getIdentifierValue(style, CSSPropertyTextAlign);
+    switch (textAlign) {
+    case CSSValueCenter:
+    case CSSValueWebkitCenter:
+        return CSSValueCenter;
+    case CSSValueLeft:
+    case CSSValueWebkitLeft:
+        return CSSValueLeft;
+    case CSSValueRight:
+    case CSSValueWebkitRight:
+        return CSSValueRight;
+    }
+    return CSSValueInvalid;
+}
+
 RefPtr<CSSMutableStyleDeclaration> getPropertiesNotIn(CSSStyleDeclaration* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle)
 {
     ASSERT(styleWithRedundantProperties);
@@ -405,6 +422,9 @@ RefPtr<CSSMutableStyleDeclaration> getPropertiesNotIn(CSSStyleDeclaration* style
     if (getRGBAFontColor(result.get()) == getRGBAFontColor(baseStyle))
         result->removeProperty(CSSPropertyColor);
 
+    if (getTextAlignment(result.get()) == getTextAlignment(baseStyle))
+        result->removeProperty(CSSPropertyTextAlign);        
+
     return result;
 }
 
diff --git a/WebCore/editing/EditorCommand.cpp b/WebCore/editing/EditorCommand.cpp
index 61c4d0f..616c07b 100644
--- a/WebCore/editing/EditorCommand.cpp
+++ b/WebCore/editing/EditorCommand.cpp
@@ -1299,6 +1299,21 @@ static TriState stateUnorderedList(Frame* frame, Event*)
     return frame->editor()->selectionUnorderedListState();
 }
 
+static TriState stateJustifyCenter(Frame* frame, Event*)
+{
+    return stateStyle(frame, CSSPropertyTextAlign, "center");
+}
+
+static TriState stateJustifyLeft(Frame* frame, Event*)
+{
+    return stateStyle(frame, CSSPropertyTextAlign, "left");
+}
+
+static TriState stateJustifyRight(Frame* frame, Event*)
+{
+    return stateStyle(frame, CSSPropertyTextAlign, "right");
+}
+
 // Value functions
 
 static String valueNull(Frame*, Event*)
@@ -1385,11 +1400,11 @@ static const CommandMap& createCommandMap()
         { "InsertText", { executeInsertText, supported, enabledInEditableText, stateNone, valueNull, isTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "InsertUnorderedList", { executeInsertUnorderedList, supported, enabledInRichlyEditableText, stateUnorderedList, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "Italic", { executeToggleItalic, supported, enabledInRichlyEditableText, stateItalic, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
-        { "JustifyCenter", { executeJustifyCenter, supported, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
+        { "JustifyCenter", { executeJustifyCenter, supported, enabledInRichlyEditableText, stateJustifyCenter, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "JustifyFull", { executeJustifyFull, supported, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
-        { "JustifyLeft", { executeJustifyLeft, supported, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
+        { "JustifyLeft", { executeJustifyLeft, supported, enabledInRichlyEditableText, stateJustifyLeft, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "JustifyNone", { executeJustifyLeft, supported, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
-        { "JustifyRight", { executeJustifyRight, supported, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
+        { "JustifyRight", { executeJustifyRight, supported, enabledInRichlyEditableText, stateJustifyRight, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "MakeTextWritingDirectionLeftToRight", { executeMakeTextWritingDirectionLeftToRight, supportedFromMenuOrKeyBinding, enabledInRichlyEditableText, stateTextWritingDirectionLeftToRight, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "MakeTextWritingDirectionNatural", { executeMakeTextWritingDirectionNatural, supportedFromMenuOrKeyBinding, enabledInRichlyEditableText, stateTextWritingDirectionNatural, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "MakeTextWritingDirectionRightToLeft", { executeMakeTextWritingDirectionRightToLeft, supportedFromMenuOrKeyBinding, enabledInRichlyEditableText, stateTextWritingDirectionRightToLeft, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list