[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 11:51:18 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit d63cefb34f35174ba3cd4050931b40d59d1f2c2d
Author: rniwa at webkit.org <rniwa at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 10 00:24:18 2010 +0000

    2010-08-09  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Justin Garcia.
    
            fontColorChangesComputedStyle, fontSizeChangesComputedStyle, and fontFaceChangesComputedStyle should be removed
            https://bugs.webkit.org/show_bug.cgi?id=43465
    
            Removed fontColorChangesComputedStyle, fontSizeChangesComputedStyle, and fontFaceChangesComputedStyle
            because StyleChange's applyFontColor, applyFontFace, and applyFontSize all return false
            if there was no difference between the new font color, font size, font face and that of the computed style.
    
            Also added a work-around for the bug 28282 in getPropertiesNotInComputedStyle with a test so that
            the above change will not add a redundant font or span element.
    
            Test: editing/style/fore-color-by-name.html
    
            * editing/ApplyStyleCommand.cpp:
            (WebCore::getRGBAFontColor): Added.
            (WebCore::StyleChange::extractTextStyles): Calls getRGBAFontColor.
            (WebCore::getPropertiesNotInComputedStyle): Removes color property manually by checking the RGBA values.
            (WebCore::ApplyStyleCommand::addInlineStyleIfNeeded): See above.
    2010-08-09  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Justin Garcia.
    
            fontColorChangesComputedStyle, fontSizeChangesComputedStyle, and fontFaceChangesComputedStyle should be removed
            https://bugs.webkit.org/show_bug.cgi?id=43465
    
            Added a test for applying execCommand('foreColor') by color name. Because of the bug 28282, we have to manually
            process color property in getPropertiesNotInComputedStyle to avoid adding a redundant font or span element.
    
            * editing/style/fore-color-by-name-expected.txt: Added.
            * editing/style/fore-color-by-name.html: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65019 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 7af3927..b42853f 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2010-08-09  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Justin Garcia.
+
+        fontColorChangesComputedStyle, fontSizeChangesComputedStyle, and fontFaceChangesComputedStyle should be removed
+        https://bugs.webkit.org/show_bug.cgi?id=43465
+
+        Added a test for applying execCommand('foreColor') by color name. Because of the bug 28282, we have to manually
+        process color property in getPropertiesNotInComputedStyle to avoid adding a redundant font or span element.
+
+        * editing/style/fore-color-by-name-expected.txt: Added.
+        * editing/style/fore-color-by-name.html: Added.
+
 2010-08-09  Chris Fleizach  <cfleizach at apple.com>
 
         Reviewed by David Kilzer.
diff --git a/LayoutTests/editing/style/fore-color-by-name-expected.txt b/LayoutTests/editing/style/fore-color-by-name-expected.txt
new file mode 100644
index 0000000..25b9a5f
--- /dev/null
+++ b/LayoutTests/editing/style/fore-color-by-name-expected.txt
@@ -0,0 +1,11 @@
+
+"world" should be red:
+| "hello "
+| <font>
+|   class="Apple-style-span"
+|   color="#FF0000"
+|   "<#selection-anchor>world<#selection-focus>"
+
+there should be no span or font elements:
+| "<#selection-anchor>hello "
+| "world<#selection-focus>"
diff --git a/LayoutTests/editing/style/fore-color-by-name.html b/LayoutTests/editing/style/fore-color-by-name.html
new file mode 100644
index 0000000..4c47278
--- /dev/null
+++ b/LayoutTests/editing/style/fore-color-by-name.html
@@ -0,0 +1,23 @@
+<html>
+<head>
+<script src="../../resources/dump-as-markup.js"></script>
+</head>
+<body>
+<div id="test" contenteditable>hello world</div>
+<script>
+
+window.getSelection().setPosition(test, 0);
+window.getSelection().modify('move', 'forward', 'word');
+window.getSelection().modify('move', 'forward', 'character');
+window.getSelection().modify('extend', 'forward', 'word');
+document.execCommand('foreColor', false, 'red');
+Markup.dump('test', '"world" should be red');
+
+window.getSelection().selectAllChildren(test);
+document.execCommand('foreColor', false, 'black');
+
+Markup.dump('test', 'there should be no span or font elements');
+
+</script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 9cbbba3..3efcff9 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-08-09  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Justin Garcia.
+
+        fontColorChangesComputedStyle, fontSizeChangesComputedStyle, and fontFaceChangesComputedStyle should be removed
+        https://bugs.webkit.org/show_bug.cgi?id=43465
+
+        Removed fontColorChangesComputedStyle, fontSizeChangesComputedStyle, and fontFaceChangesComputedStyle
+        because StyleChange's applyFontColor, applyFontFace, and applyFontSize all return false
+        if there was no difference between the new font color, font size, font face and that of the computed style.
+
+        Also added a work-around for the bug 28282 in getPropertiesNotInComputedStyle with a test so that
+        the above change will not add a redundant font or span element.
+
+        Test: editing/style/fore-color-by-name.html
+
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::getRGBAFontColor): Added.
+        (WebCore::StyleChange::extractTextStyles): Calls getRGBAFontColor.
+        (WebCore::getPropertiesNotInComputedStyle): Removes color property manually by checking the RGBA values.
+        (WebCore::ApplyStyleCommand::addInlineStyleIfNeeded): See above.
+
 2010-08-09  Kenneth Russell  <kbr at google.com>
 
         Reviewed by David Levin.
diff --git a/WebCore/editing/ApplyStyleCommand.cpp b/WebCore/editing/ApplyStyleCommand.cpp
index 50654c6..a9d1509 100644
--- a/WebCore/editing/ApplyStyleCommand.cpp
+++ b/WebCore/editing/ApplyStyleCommand.cpp
@@ -51,6 +51,26 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
+static RGBA32 getRGBAFontColor(CSSStyleDeclaration* style)
+{
+    RefPtr<CSSValue> colorValue = style->getPropertyCSSValue(CSSPropertyColor);
+    if (!colorValue)
+        return Color::transparent;
+
+    ASSERT(colorValue->isPrimitiveValue());
+
+    CSSPrimitiveValue* primitiveColor = static_cast<CSSPrimitiveValue*>(colorValue.get());
+    RGBA32 rgba = 0;
+    if (primitiveColor->primitiveType() != CSSPrimitiveValue::CSS_RGBCOLOR) {
+        CSSParser::parseColor(rgba, colorValue->cssText());
+        // Need to take care of named color such as green and black
+        // This code should be removed after https://bugs.webkit.org/show_bug.cgi?id=28282 is fixed.
+    } else
+        rgba = primitiveColor->getRGBA32Value();
+
+    return rgba;
+}
+
 class StyleChange {
 public:
     explicit StyleChange(CSSStyleDeclaration*, const Position&);
@@ -209,17 +229,8 @@ void StyleChange::extractTextStyles(CSSMutableStyleDeclaration* style)
         break;
     }
 
-    if (RefPtr<CSSValue> colorValue = style->getPropertyCSSValue(CSSPropertyColor)) {
-        ASSERT(colorValue->isPrimitiveValue());
-        CSSPrimitiveValue* primitiveColor = static_cast<CSSPrimitiveValue*>(colorValue.get());
-        RGBA32 rgba = 0;
-        if (primitiveColor->primitiveType() != CSSPrimitiveValue::CSS_RGBCOLOR) {
-            CSSParser::parseColor(rgba, colorValue->cssText());
-            // Need to take care of named color such as green and black
-            // This code should be removed after https://bugs.webkit.org/show_bug.cgi?id=28282 is fixed.
-        } else
-            rgba = primitiveColor->getRGBA32Value();
-        m_applyFontColor = Color(rgba).name();
+    if (style->getPropertyCSSValue(CSSPropertyColor)) {
+        m_applyFontColor = Color(getRGBAFontColor(style)).name();
         style->removeProperty(CSSPropertyColor);
     }
 
@@ -382,6 +393,9 @@ RefPtr<CSSMutableStyleDeclaration> getPropertiesNotInComputedStyle(CSSStyleDecla
     if (fontWeightIsBold(result.get()) == fontWeightIsBold(computedStyle))
         result->removeProperty(CSSPropertyFontWeight);
 
+    if (getRGBAFontColor(result.get()) == getRGBAFontColor(computedStyle))
+        result->removeProperty(CSSPropertyColor);
+
     return result;
 }
 
@@ -1729,33 +1743,6 @@ void ApplyStyleCommand::addBlockStyle(const StyleChange& styleChange, HTMLElemen
     setNodeAttribute(block, styleAttr, cssText);
 }
 
-static bool fontColorChangesComputedStyle(const Color& computedStyleColor, StyleChange styleChange)
-{
-    if (styleChange.applyFontColor()) {
-        if (Color(styleChange.fontColor()) != computedStyleColor)
-            return true;
-    }
-    return false;
-}
-
-static bool fontSizeChangesComputedStyle(RenderStyle* computedStyle, StyleChange styleChange)
-{
-    if (styleChange.applyFontSize()) {
-        if (styleChange.fontSize().toInt() != computedStyle->fontSize())
-            return true;
-    }
-    return false;
-}
-
-static bool fontFaceChangesComputedStyle(RenderStyle* computedStyle, StyleChange styleChange)
-{
-    if (styleChange.applyFontFace()) {
-        if (computedStyle->fontDescription().family().family().string() != styleChange.fontFace())
-            return true;
-    }
-    return false;
-}
-
 void ApplyStyleCommand::addInlineStyleIfNeeded(CSSMutableStyleDeclaration *style, Node *startNode, Node *endNode)
 {
     if (m_removeOnly)
@@ -1763,27 +1750,18 @@ void ApplyStyleCommand::addInlineStyleIfNeeded(CSSMutableStyleDeclaration *style
 
     StyleChange styleChange(style, Position(startNode, 0));
 
-    //
     // Font tags need to go outside of CSS so that CSS font sizes override leagcy font sizes.
-    //
     if (styleChange.applyFontColor() || styleChange.applyFontFace() || styleChange.applyFontSize()) {
         RefPtr<Element> fontElement = createFontElement(document());
-        RenderStyle* computedStyle = startNode->computedStyle();
-
-        // We only want to insert a font element if it will end up changing the style of the
-        // text somehow. Otherwise it will be a garbage node that will create problems for us
-        // most notably when we apply a blockquote style for a message reply.
-        if (fontColorChangesComputedStyle(computedStyle->color(), styleChange)
-                || fontFaceChangesComputedStyle(computedStyle, styleChange)
-                || fontSizeChangesComputedStyle(computedStyle, styleChange)) {
-            if (styleChange.applyFontColor())
-                fontElement->setAttribute(colorAttr, styleChange.fontColor());
-            if (styleChange.applyFontFace())
-                fontElement->setAttribute(faceAttr, styleChange.fontFace());
-            if (styleChange.applyFontSize())
-                fontElement->setAttribute(sizeAttr, styleChange.fontSize());
-            surroundNodeRangeWithElement(startNode, endNode, fontElement.get());
-        }
+
+        if (styleChange.applyFontColor())
+            fontElement->setAttribute(colorAttr, styleChange.fontColor());
+        if (styleChange.applyFontFace())
+            fontElement->setAttribute(faceAttr, styleChange.fontFace());
+        if (styleChange.applyFontSize())
+            fontElement->setAttribute(sizeAttr, styleChange.fontSize());
+
+        surroundNodeRangeWithElement(startNode, endNode, fontElement.get());
     }
 
     if (styleChange.cssStyle().length()) {

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list