| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc. | 2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc. |
| 3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/editing/EditingStyle.h" | 28 #include "core/editing/EditingStyle.h" |
| 29 | 29 |
| 30 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 30 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 31 #include "core/HTMLNames.h" | 31 #include "core/HTMLNames.h" |
| 32 #include "core/css/CSSColorValue.h" |
| 32 #include "core/css/CSSComputedStyleDeclaration.h" | 33 #include "core/css/CSSComputedStyleDeclaration.h" |
| 33 #include "core/css/CSSPropertyMetadata.h" | 34 #include "core/css/CSSPropertyMetadata.h" |
| 34 #include "core/css/CSSRuleList.h" | 35 #include "core/css/CSSRuleList.h" |
| 35 #include "core/css/CSSStyleRule.h" | 36 #include "core/css/CSSStyleRule.h" |
| 36 #include "core/css/CSSValueList.h" | 37 #include "core/css/CSSValueList.h" |
| 37 #include "core/css/CSSValuePool.h" | 38 #include "core/css/CSSValuePool.h" |
| 38 #include "core/css/FontSize.h" | 39 #include "core/css/FontSize.h" |
| 39 #include "core/css/StylePropertySet.h" | 40 #include "core/css/StylePropertySet.h" |
| 40 #include "core/css/StyleRule.h" | 41 #include "core/css/StyleRule.h" |
| 41 #include "core/css/parser/CSSParser.h" | 42 #include "core/css/parser/CSSParser.h" |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 { | 390 { |
| 390 setProperty(propertyID, value); | 391 setProperty(propertyID, value); |
| 391 } | 392 } |
| 392 | 393 |
| 393 EditingStyle::~EditingStyle() | 394 EditingStyle::~EditingStyle() |
| 394 { | 395 { |
| 395 } | 396 } |
| 396 | 397 |
| 397 static RGBA32 cssValueToRGBA(CSSValue* colorValue) | 398 static RGBA32 cssValueToRGBA(CSSValue* colorValue) |
| 398 { | 399 { |
| 399 if (!colorValue || !colorValue->isPrimitiveValue()) | 400 if (!colorValue || (!colorValue->isColorValue() && !colorValue->isPrimitiveV
alue())) |
| 400 return Color::transparent; | 401 return Color::transparent; |
| 401 | 402 |
| 402 CSSPrimitiveValue* primitiveColor = toCSSPrimitiveValue(colorValue); | 403 if (colorValue->isColorValue()) |
| 403 if (primitiveColor->isRGBColor()) | 404 return toCSSColorValue(colorValue)->value(); |
| 404 return primitiveColor->getRGBA32Value(); | |
| 405 | 405 |
| 406 RGBA32 rgba = 0; | 406 RGBA32 rgba = 0; |
| 407 // FIXME: Why ignore the return value? | 407 // FIXME: Why ignore the return value? |
| 408 CSSParser::parseColor(rgba, colorValue->cssText()); | 408 CSSParser::parseColor(rgba, colorValue->cssText()); |
| 409 return rgba; | 409 return rgba; |
| 410 } | 410 } |
| 411 | 411 |
| 412 static inline RGBA32 getRGBAFontColor(CSSStyleDeclaration* style) | 412 static inline RGBA32 getRGBAFontColor(CSSStyleDeclaration* style) |
| 413 { | 413 { |
| 414 return cssValueToRGBA(style->getPropertyCSSValueInternal(CSSPropertyColor).g
et()); | 414 return cssValueToRGBA(style->getPropertyCSSValueInternal(CSSPropertyColor).g
et()); |
| (...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 if (CSSValueXSmall <= value->getValueID() && value->getValueID() <= CSSValue
WebkitXxxLarge) | 1687 if (CSSValueXSmall <= value->getValueID() && value->getValueID() <= CSSValue
WebkitXxxLarge) |
| 1688 return value->getValueID() - CSSValueXSmall + 1; | 1688 return value->getValueID() - CSSValueXSmall + 1; |
| 1689 | 1689 |
| 1690 return 0; | 1690 return 0; |
| 1691 } | 1691 } |
| 1692 | 1692 |
| 1693 bool isTransparentColorValue(CSSValue* cssValue) | 1693 bool isTransparentColorValue(CSSValue* cssValue) |
| 1694 { | 1694 { |
| 1695 if (!cssValue) | 1695 if (!cssValue) |
| 1696 return true; | 1696 return true; |
| 1697 if (cssValue->isColorValue()) |
| 1698 return !alphaChannel(toCSSColorValue(cssValue)->value()); |
| 1697 if (!cssValue->isPrimitiveValue()) | 1699 if (!cssValue->isPrimitiveValue()) |
| 1698 return false; | 1700 return false; |
| 1699 CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue); | 1701 CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue); |
| 1700 if (value->isRGBColor()) | |
| 1701 return !alphaChannel(value->getRGBA32Value()); | |
| 1702 return value->getValueID() == CSSValueTransparent; | 1702 return value->getValueID() == CSSValueTransparent; |
| 1703 } | 1703 } |
| 1704 | 1704 |
| 1705 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style) | 1705 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style) |
| 1706 { | 1706 { |
| 1707 RefPtrWillBeRawPtr<CSSValue> cssValue = style->getPropertyCSSValueInternal(C
SSPropertyBackgroundColor); | 1707 RefPtrWillBeRawPtr<CSSValue> cssValue = style->getPropertyCSSValueInternal(C
SSPropertyBackgroundColor); |
| 1708 return isTransparentColorValue(cssValue.get()); | 1708 return isTransparentColorValue(cssValue.get()); |
| 1709 } | 1709 } |
| 1710 | 1710 |
| 1711 bool hasTransparentBackgroundColor(StylePropertySet* style) | 1711 bool hasTransparentBackgroundColor(StylePropertySet* style) |
| 1712 { | 1712 { |
| 1713 RefPtrWillBeRawPtr<CSSValue> cssValue = style->getPropertyCSSValue(CSSProper
tyBackgroundColor); | 1713 RefPtrWillBeRawPtr<CSSValue> cssValue = style->getPropertyCSSValue(CSSProper
tyBackgroundColor); |
| 1714 return isTransparentColorValue(cssValue.get()); | 1714 return isTransparentColorValue(cssValue.get()); |
| 1715 } | 1715 } |
| 1716 | 1716 |
| 1717 PassRefPtrWillBeRawPtr<CSSValue> backgroundColorInEffect(Node* node) | 1717 PassRefPtrWillBeRawPtr<CSSValue> backgroundColorInEffect(Node* node) |
| 1718 { | 1718 { |
| 1719 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1719 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
| 1720 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); | 1720 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); |
| 1721 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1721 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
| 1722 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); | 1722 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); |
| 1723 } | 1723 } |
| 1724 return nullptr; | 1724 return nullptr; |
| 1725 } | 1725 } |
| 1726 | 1726 |
| 1727 } | 1727 } |
| OLD | NEW |