Changeset 65019 in webkit
- Timestamp:
- Aug 9, 2010 5:24:18 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r65016 r65019 1 2010-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 1 14 2010-08-09 Chris Fleizach <cfleizach@apple.com> 2 15 -
trunk/WebCore/ChangeLog
r65018 r65019 1 2010-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 1 23 2010-08-09 Kenneth Russell <kbr@google.com> 2 24 -
trunk/WebCore/editing/ApplyStyleCommand.cpp
r65014 r65019 52 52 using namespace HTMLNames; 53 53 54 static 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 54 74 class StyleChange { 55 75 public: … … 210 230 } 211 231 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(); 223 234 style->removeProperty(CSSPropertyColor); 224 235 } … … 382 393 if (fontWeightIsBold(result.get()) == fontWeightIsBold(computedStyle)) 383 394 result->removeProperty(CSSPropertyFontWeight); 395 396 if (getRGBAFontColor(result.get()) == getRGBAFontColor(computedStyle)) 397 result->removeProperty(CSSPropertyColor); 384 398 385 399 return result; … … 1730 1744 } 1731 1745 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 1759 1746 void ApplyStyleCommand::addInlineStyleIfNeeded(CSSMutableStyleDeclaration *style, Node *startNode, Node *endNode) 1760 1747 { … … 1764 1751 StyleChange styleChange(style, Position(startNode, 0)); 1765 1752 1766 //1767 1753 // Font tags need to go outside of CSS so that CSS font sizes override leagcy font sizes. 1768 //1769 1754 if (styleChange.applyFontColor() || styleChange.applyFontFace() || styleChange.applyFontSize()) { 1770 1755 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()); 1787 1765 } 1788 1766
Note: See TracChangeset
for help on using the changeset viewer.