Changeset 65019 in webkit


Ignore:
Timestamp:
Aug 9, 2010 5:24:18 PM (14 years ago)
Author:
rniwa@webkit.org
Message:

2010-08-09 Ryosuke Niwa <rniwa@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@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.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r65016 r65019  
     12010-08-09  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Justin Garcia.
     4
     5        fontColorChangesComputedStyle, fontSizeChangesComputedStyle, and fontFaceChangesComputedStyle should be removed
     6        https://bugs.webkit.org/show_bug.cgi?id=43465
     7
     8        Added a test for applying execCommand('foreColor') by color name. Because of the bug 28282, we have to manually
     9        process color property in getPropertiesNotInComputedStyle to avoid adding a redundant font or span element.
     10
     11        * editing/style/fore-color-by-name-expected.txt: Added.
     12        * editing/style/fore-color-by-name.html: Added.
     13
    1142010-08-09  Chris Fleizach  <cfleizach@apple.com>
    215
  • trunk/WebCore/ChangeLog

    r65018 r65019  
     12010-08-09  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Justin Garcia.
     4
     5        fontColorChangesComputedStyle, fontSizeChangesComputedStyle, and fontFaceChangesComputedStyle should be removed
     6        https://bugs.webkit.org/show_bug.cgi?id=43465
     7
     8        Removed fontColorChangesComputedStyle, fontSizeChangesComputedStyle, and fontFaceChangesComputedStyle
     9        because StyleChange's applyFontColor, applyFontFace, and applyFontSize all return false
     10        if there was no difference between the new font color, font size, font face and that of the computed style.
     11
     12        Also added a work-around for the bug 28282 in getPropertiesNotInComputedStyle with a test so that
     13        the above change will not add a redundant font or span element.
     14
     15        Test: editing/style/fore-color-by-name.html
     16
     17        * editing/ApplyStyleCommand.cpp:
     18        (WebCore::getRGBAFontColor): Added.
     19        (WebCore::StyleChange::extractTextStyles): Calls getRGBAFontColor.
     20        (WebCore::getPropertiesNotInComputedStyle): Removes color property manually by checking the RGBA values.
     21        (WebCore::ApplyStyleCommand::addInlineStyleIfNeeded): See above.
     22
    1232010-08-09  Kenneth Russell  <kbr@google.com>
    224
  • trunk/WebCore/editing/ApplyStyleCommand.cpp

    r65014 r65019  
    5252using namespace HTMLNames;
    5353
     54static RGBA32 getRGBAFontColor(CSSStyleDeclaration* style)
     55{
     56    RefPtr<CSSValue> colorValue = style->getPropertyCSSValue(CSSPropertyColor);
     57    if (!colorValue)
     58        return Color::transparent;
     59
     60    ASSERT(colorValue->isPrimitiveValue());
     61
     62    CSSPrimitiveValue* primitiveColor = static_cast<CSSPrimitiveValue*>(colorValue.get());
     63    RGBA32 rgba = 0;
     64    if (primitiveColor->primitiveType() != CSSPrimitiveValue::CSS_RGBCOLOR) {
     65        CSSParser::parseColor(rgba, colorValue->cssText());
     66        // Need to take care of named color such as green and black
     67        // This code should be removed after https://bugs.webkit.org/show_bug.cgi?id=28282 is fixed.
     68    } else
     69        rgba = primitiveColor->getRGBA32Value();
     70
     71    return rgba;
     72}
     73
    5474class StyleChange {
    5575public:
     
    210230    }
    211231
    212     if (RefPtr<CSSValue> colorValue = style->getPropertyCSSValue(CSSPropertyColor)) {
    213         ASSERT(colorValue->isPrimitiveValue());
    214         CSSPrimitiveValue* primitiveColor = static_cast<CSSPrimitiveValue*>(colorValue.get());
    215         RGBA32 rgba = 0;
    216         if (primitiveColor->primitiveType() != CSSPrimitiveValue::CSS_RGBCOLOR) {
    217             CSSParser::parseColor(rgba, colorValue->cssText());
    218             // Need to take care of named color such as green and black
    219             // This code should be removed after https://bugs.webkit.org/show_bug.cgi?id=28282 is fixed.
    220         } else
    221             rgba = primitiveColor->getRGBA32Value();
    222         m_applyFontColor = Color(rgba).name();
     232    if (style->getPropertyCSSValue(CSSPropertyColor)) {
     233        m_applyFontColor = Color(getRGBAFontColor(style)).name();
    223234        style->removeProperty(CSSPropertyColor);
    224235    }
     
    382393    if (fontWeightIsBold(result.get()) == fontWeightIsBold(computedStyle))
    383394        result->removeProperty(CSSPropertyFontWeight);
     395
     396    if (getRGBAFontColor(result.get()) == getRGBAFontColor(computedStyle))
     397        result->removeProperty(CSSPropertyColor);
    384398
    385399    return result;
     
    17301744}
    17311745
    1732 static bool fontColorChangesComputedStyle(const Color& computedStyleColor, StyleChange styleChange)
    1733 {
    1734     if (styleChange.applyFontColor()) {
    1735         if (Color(styleChange.fontColor()) != computedStyleColor)
    1736             return true;
    1737     }
    1738     return false;
    1739 }
    1740 
    1741 static bool fontSizeChangesComputedStyle(RenderStyle* computedStyle, StyleChange styleChange)
    1742 {
    1743     if (styleChange.applyFontSize()) {
    1744         if (styleChange.fontSize().toInt() != computedStyle->fontSize())
    1745             return true;
    1746     }
    1747     return false;
    1748 }
    1749 
    1750 static bool fontFaceChangesComputedStyle(RenderStyle* computedStyle, StyleChange styleChange)
    1751 {
    1752     if (styleChange.applyFontFace()) {
    1753         if (computedStyle->fontDescription().family().family().string() != styleChange.fontFace())
    1754             return true;
    1755     }
    1756     return false;
    1757 }
    1758 
    17591746void ApplyStyleCommand::addInlineStyleIfNeeded(CSSMutableStyleDeclaration *style, Node *startNode, Node *endNode)
    17601747{
     
    17641751    StyleChange styleChange(style, Position(startNode, 0));
    17651752
    1766     //
    17671753    // Font tags need to go outside of CSS so that CSS font sizes override leagcy font sizes.
    1768     //
    17691754    if (styleChange.applyFontColor() || styleChange.applyFontFace() || styleChange.applyFontSize()) {
    17701755        RefPtr<Element> fontElement = createFontElement(document());
    1771         RenderStyle* computedStyle = startNode->computedStyle();
    1772 
    1773         // We only want to insert a font element if it will end up changing the style of the
    1774         // text somehow. Otherwise it will be a garbage node that will create problems for us
    1775         // most notably when we apply a blockquote style for a message reply.
    1776         if (fontColorChangesComputedStyle(computedStyle->color(), styleChange)
    1777                 || fontFaceChangesComputedStyle(computedStyle, styleChange)
    1778                 || fontSizeChangesComputedStyle(computedStyle, styleChange)) {
    1779             if (styleChange.applyFontColor())
    1780                 fontElement->setAttribute(colorAttr, styleChange.fontColor());
    1781             if (styleChange.applyFontFace())
    1782                 fontElement->setAttribute(faceAttr, styleChange.fontFace());
    1783             if (styleChange.applyFontSize())
    1784                 fontElement->setAttribute(sizeAttr, styleChange.fontSize());
    1785             surroundNodeRangeWithElement(startNode, endNode, fontElement.get());
    1786         }
     1756
     1757        if (styleChange.applyFontColor())
     1758            fontElement->setAttribute(colorAttr, styleChange.fontColor());
     1759        if (styleChange.applyFontFace())
     1760            fontElement->setAttribute(faceAttr, styleChange.fontFace());
     1761        if (styleChange.applyFontSize())
     1762            fontElement->setAttribute(sizeAttr, styleChange.fontSize());
     1763
     1764        surroundNodeRangeWithElement(startNode, endNode, fontElement.get());
    17871765    }
    17881766
Note: See TracChangeset for help on using the changeset viewer.