| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 return nullptr; | 154 return nullptr; |
| 155 return CSSComputedStyleDeclaration::create(elem); | 155 return CSSComputedStyleDeclaration::create(elem); |
| 156 } | 156 } |
| 157 | 157 |
| 158 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleP
ropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle); | 158 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleP
ropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle); |
| 159 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV
aluesMatch }; | 159 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV
aluesMatch }; |
| 160 static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool, Legac
yFontSizeMode); | 160 static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool, Legac
yFontSizeMode); |
| 161 static bool isTransparentColorValue(CSSValue*); | 161 static bool isTransparentColorValue(CSSValue*); |
| 162 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); | 162 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); |
| 163 static bool hasTransparentBackgroundColor(StylePropertySet*); | 163 static bool hasTransparentBackgroundColor(StylePropertySet*); |
| 164 static PassRefPtrWillBeRawPtr<CSSValue> backgroundColorInEffect(Node*); | 164 static PassRefPtrWillBeRawPtr<CSSValue> backgroundColorValueInEffect(Node*); |
| 165 | 165 |
| 166 class HTMLElementEquivalent : public NoBaseWillBeGarbageCollected<HTMLElementEqu
ivalent> { | 166 class HTMLElementEquivalent : public NoBaseWillBeGarbageCollected<HTMLElementEqu
ivalent> { |
| 167 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(HTMLElementEquivalent); | 167 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(HTMLElementEquivalent); |
| 168 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent); | 168 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent); |
| 169 public: | 169 public: |
| 170 static PassOwnPtrWillBeRawPtr<HTMLElementEquivalent> create(CSSPropertyID pr
opertyID, CSSValueID primitiveValue, const HTMLQualifiedName& tagName) | 170 static PassOwnPtrWillBeRawPtr<HTMLElementEquivalent> create(CSSPropertyID pr
opertyID, CSSValueID primitiveValue, const HTMLQualifiedName& tagName) |
| 171 { | 171 { |
| 172 return adoptPtrWillBeNoop(new HTMLElementEquivalent(propertyID, primitiv
eValue, tagName)); | 172 return adoptPtrWillBeNoop(new HTMLElementEquivalent(propertyID, primitiv
eValue, tagName)); |
| 173 } | 173 } |
| 174 | 174 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 , m_isMonospaceFont(false) | 388 , m_isMonospaceFont(false) |
| 389 , m_fontSizeDelta(NoFontDelta) | 389 , m_fontSizeDelta(NoFontDelta) |
| 390 { | 390 { |
| 391 setProperty(propertyID, value); | 391 setProperty(propertyID, value); |
| 392 } | 392 } |
| 393 | 393 |
| 394 EditingStyle::~EditingStyle() | 394 EditingStyle::~EditingStyle() |
| 395 { | 395 { |
| 396 } | 396 } |
| 397 | 397 |
| 398 static RGBA32 cssValueToRGBA(CSSValue* colorValue) | 398 static Color cssValueToColor(CSSValue* colorValue) |
| 399 { | 399 { |
| 400 if (!colorValue || (!colorValue->isColorValue() && !colorValue->isPrimitiveV
alue())) | 400 if (!colorValue || (!colorValue->isColorValue() && !colorValue->isPrimitiveV
alue())) |
| 401 return Color::transparent; | 401 return Color::transparent; |
| 402 | 402 |
| 403 if (colorValue->isColorValue()) | 403 if (colorValue->isColorValue()) |
| 404 return toCSSColorValue(colorValue)->value(); | 404 return toCSSColorValue(colorValue)->value(); |
| 405 | 405 |
| 406 RGBA32 rgba = 0; | 406 Color color = 0; |
| 407 // FIXME: Why ignore the return value? | 407 // FIXME: Why ignore the return value? |
| 408 CSSParser::parseColor(rgba, colorValue->cssText()); | 408 CSSParser::parseColor(color, colorValue->cssText()); |
| 409 return rgba; | 409 return color; |
| 410 } | 410 } |
| 411 | 411 |
| 412 static inline RGBA32 getRGBAFontColor(CSSStyleDeclaration* style) | 412 static inline Color getFontColor(CSSStyleDeclaration* style) |
| 413 { | 413 { |
| 414 return cssValueToRGBA(style->getPropertyCSSValueInternal(CSSPropertyColor).g
et()); | 414 return cssValueToColor(style->getPropertyCSSValueInternal(CSSPropertyColor).
get()); |
| 415 } | 415 } |
| 416 | 416 |
| 417 static inline RGBA32 getRGBAFontColor(StylePropertySet* style) | 417 static inline Color getFontColor(StylePropertySet* style) |
| 418 { | 418 { |
| 419 return cssValueToRGBA(style->getPropertyCSSValue(CSSPropertyColor).get()); | 419 return cssValueToColor(style->getPropertyCSSValue(CSSPropertyColor).get()); |
| 420 } | 420 } |
| 421 | 421 |
| 422 static inline RGBA32 getRGBABackgroundColor(CSSStyleDeclaration* style) | 422 static inline Color getBackgroundColor(CSSStyleDeclaration* style) |
| 423 { | 423 { |
| 424 return cssValueToRGBA(style->getPropertyCSSValueInternal(CSSPropertyBackgrou
ndColor).get()); | 424 return cssValueToColor(style->getPropertyCSSValueInternal(CSSPropertyBackgro
undColor).get()); |
| 425 } | 425 } |
| 426 | 426 |
| 427 static inline RGBA32 getRGBABackgroundColor(StylePropertySet* style) | 427 static inline Color getBackgroundColor(StylePropertySet* style) |
| 428 { | 428 { |
| 429 return cssValueToRGBA(style->getPropertyCSSValue(CSSPropertyBackgroundColor)
.get()); | 429 return cssValueToColor(style->getPropertyCSSValue(CSSPropertyBackgroundColor
).get()); |
| 430 } | 430 } |
| 431 | 431 |
| 432 static inline RGBA32 rgbaBackgroundColorInEffect(Node* node) | 432 static inline Color backgroundColorInEffect(Node* node) |
| 433 { | 433 { |
| 434 return cssValueToRGBA(backgroundColorInEffect(node).get()); | 434 return cssValueToColor(backgroundColorValueInEffect(node).get()); |
| 435 } | 435 } |
| 436 | 436 |
| 437 static int textAlignResolvingStartAndEnd(int textAlign, int direction) | 437 static int textAlignResolvingStartAndEnd(int textAlign, int direction) |
| 438 { | 438 { |
| 439 switch (textAlign) { | 439 switch (textAlign) { |
| 440 case CSSValueCenter: | 440 case CSSValueCenter: |
| 441 case CSSValueWebkitCenter: | 441 case CSSValueWebkitCenter: |
| 442 return CSSValueCenter; | 442 return CSSValueCenter; |
| 443 case CSSValueJustify: | 443 case CSSValueJustify: |
| 444 return CSSValueJustify; | 444 return CSSValueJustify; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 466 { | 466 { |
| 467 if (isTabHTMLSpanElementTextNode(node)) | 467 if (isTabHTMLSpanElementTextNode(node)) |
| 468 node = tabSpanElement(node)->parentNode(); | 468 node = tabSpanElement(node)->parentNode(); |
| 469 else if (isTabHTMLSpanElement(node)) | 469 else if (isTabHTMLSpanElement(node)) |
| 470 node = node->parentNode(); | 470 node = node->parentNode(); |
| 471 | 471 |
| 472 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = CS
SComputedStyleDeclaration::create(node); | 472 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = CS
SComputedStyleDeclaration::create(node); |
| 473 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi
tion ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle
(computedStyleAtPosition); | 473 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi
tion ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle
(computedStyleAtPosition); |
| 474 | 474 |
| 475 if (propertiesToInclude == EditingPropertiesInEffect) { | 475 if (propertiesToInclude == EditingPropertiesInEffect) { |
| 476 if (RefPtrWillBeRawPtr<CSSValue> value = backgroundColorInEffect(node)) | 476 if (RefPtrWillBeRawPtr<CSSValue> value = backgroundColorValueInEffect(no
de)) |
| 477 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe
xt()); | 477 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe
xt()); |
| 478 if (RefPtrWillBeRawPtr<CSSValue> value = computedStyleAtPosition->getPro
pertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect)) | 478 if (RefPtrWillBeRawPtr<CSSValue> value = computedStyleAtPosition->getPro
pertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect)) |
| 479 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex
t()); | 479 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex
t()); |
| 480 } | 480 } |
| 481 | 481 |
| 482 if (node && node->ensureComputedStyle()) { | 482 if (node && node->ensureComputedStyle()) { |
| 483 const ComputedStyle* computedStyle = node->ensureComputedStyle(); | 483 const ComputedStyle* computedStyle = node->ensureComputedStyle(); |
| 484 removeTextFillAndStrokeColorsIfNeeded(computedStyle); | 484 removeTextFillAndStrokeColorsIfNeeded(computedStyle); |
| 485 replaceFontSizeByKeywordIfPossible(computedStyle, computedStyleAtPositio
n.get()); | 485 replaceFontSizeByKeywordIfPossible(computedStyle, computedStyleAtPositio
n.get()); |
| 486 } | 486 } |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 if (shouldPreserveWritingDirection == PreserveWritingDirection) { | 998 if (shouldPreserveWritingDirection == PreserveWritingDirection) { |
| 999 unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi
); | 999 unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi
); |
| 1000 direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection); | 1000 direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection); |
| 1001 } | 1001 } |
| 1002 | 1002 |
| 1003 m_mutableStyle->removeEquivalentProperties(styleAtPosition); | 1003 m_mutableStyle->removeEquivalentProperties(styleAtPosition); |
| 1004 | 1004 |
| 1005 if (textAlignResolvingStartAndEnd(m_mutableStyle.get()) == textAlignResolvin
gStartAndEnd(styleAtPosition)) | 1005 if (textAlignResolvingStartAndEnd(m_mutableStyle.get()) == textAlignResolvin
gStartAndEnd(styleAtPosition)) |
| 1006 m_mutableStyle->removeProperty(CSSPropertyTextAlign); | 1006 m_mutableStyle->removeProperty(CSSPropertyTextAlign); |
| 1007 | 1007 |
| 1008 if (getRGBAFontColor(m_mutableStyle.get()) == getRGBAFontColor(styleAtPositi
on)) | 1008 if (getFontColor(m_mutableStyle.get()) == getFontColor(styleAtPosition)) |
| 1009 m_mutableStyle->removeProperty(CSSPropertyColor); | 1009 m_mutableStyle->removeProperty(CSSPropertyColor); |
| 1010 | 1010 |
| 1011 if (hasTransparentBackgroundColor(m_mutableStyle.get()) | 1011 if (hasTransparentBackgroundColor(m_mutableStyle.get()) |
| 1012 || cssValueToRGBA(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgro
undColor).get()) == rgbaBackgroundColorInEffect(position.computeContainerNode())
) | 1012 || cssValueToColor(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgr
oundColor).get()) == backgroundColorInEffect(position.computeContainerNode())) |
| 1013 m_mutableStyle->removeProperty(CSSPropertyBackgroundColor); | 1013 m_mutableStyle->removeProperty(CSSPropertyBackgroundColor); |
| 1014 | 1014 |
| 1015 if (unicodeBidi && unicodeBidi->isPrimitiveValue()) { | 1015 if (unicodeBidi && unicodeBidi->isPrimitiveValue()) { |
| 1016 m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, toCSSPrimitiveValue(
unicodeBidi.get())->getValueID()); | 1016 m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, toCSSPrimitiveValue(
unicodeBidi.get())->getValueID()); |
| 1017 if (direction && direction->isPrimitiveValue()) | 1017 if (direction && direction->isPrimitiveValue()) |
| 1018 m_mutableStyle->setProperty(CSSPropertyDirection, toCSSPrimitiveValu
e(direction.get())->getValueID()); | 1018 m_mutableStyle->setProperty(CSSPropertyDirection, toCSSPrimitiveValu
e(direction.get())->getValueID()); |
| 1019 } | 1019 } |
| 1020 } | 1020 } |
| 1021 | 1021 |
| 1022 void EditingStyle::mergeTypingStyle(Document* document) | 1022 void EditingStyle::mergeTypingStyle(Document* document) |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1332 return nullptr; | 1332 return nullptr; |
| 1333 | 1333 |
| 1334 RefPtrWillBeRawPtr<EditingStyle> style = EditingStyle::create(element, Editi
ngStyle::AllProperties); | 1334 RefPtrWillBeRawPtr<EditingStyle> style = EditingStyle::create(element, Editi
ngStyle::AllProperties); |
| 1335 style->mergeTypingStyle(&element->document()); | 1335 style->mergeTypingStyle(&element->document()); |
| 1336 | 1336 |
| 1337 // If background color is transparent, traverse parent nodes until we hit a
different value or document root | 1337 // If background color is transparent, traverse parent nodes until we hit a
different value or document root |
| 1338 // Also, if the selection is a range, ignore the background color at the sta
rt of selection, | 1338 // Also, if the selection is a range, ignore the background color at the sta
rt of selection, |
| 1339 // and find the background color of the common ancestor. | 1339 // and find the background color of the common ancestor. |
| 1340 if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTranspare
ntBackgroundColor(style->m_mutableStyle.get()))) { | 1340 if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTranspare
ntBackgroundColor(style->m_mutableStyle.get()))) { |
| 1341 const EphemeralRange range(selection.toNormalizedEphemeralRange()); | 1341 const EphemeralRange range(selection.toNormalizedEphemeralRange()); |
| 1342 if (PassRefPtrWillBeRawPtr<CSSValue> value = backgroundColorInEffect(Ran
ge::commonAncestorContainer(range.startPosition().computeContainerNode(), range.
endPosition().computeContainerNode()))) | 1342 if (PassRefPtrWillBeRawPtr<CSSValue> value = backgroundColorValueInEffec
t(Range::commonAncestorContainer(range.startPosition().computeContainerNode(), r
ange.endPosition().computeContainerNode()))) |
| 1343 style->setProperty(CSSPropertyBackgroundColor, value->cssText()); | 1343 style->setProperty(CSSPropertyBackgroundColor, value->cssText()); |
| 1344 } | 1344 } |
| 1345 | 1345 |
| 1346 return style; | 1346 return style; |
| 1347 } | 1347 } |
| 1348 | 1348 |
| 1349 WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
selection, EditingStyle* typingStyle, bool& hasNestedOrMultipleEmbeddings) | 1349 WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
selection, EditingStyle* typingStyle, bool& hasNestedOrMultipleEmbeddings) |
| 1350 { | 1350 { |
| 1351 hasNestedOrMultipleEmbeddings = true; | 1351 hasNestedOrMultipleEmbeddings = true; |
| 1352 | 1352 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1537 style->removeProperty(CSSPropertyVerticalAlign); | 1537 style->removeProperty(CSSPropertyVerticalAlign); |
| 1538 m_applySubscript = true; | 1538 m_applySubscript = true; |
| 1539 break; | 1539 break; |
| 1540 case CSSValueSuper: | 1540 case CSSValueSuper: |
| 1541 style->removeProperty(CSSPropertyVerticalAlign); | 1541 style->removeProperty(CSSPropertyVerticalAlign); |
| 1542 m_applySuperscript = true; | 1542 m_applySuperscript = true; |
| 1543 break; | 1543 break; |
| 1544 } | 1544 } |
| 1545 | 1545 |
| 1546 if (style->getPropertyCSSValue(CSSPropertyColor)) { | 1546 if (style->getPropertyCSSValue(CSSPropertyColor)) { |
| 1547 m_applyFontColor = Color(getRGBAFontColor(style)).serialized(); | 1547 m_applyFontColor = getFontColor(style).serialized(); |
| 1548 style->removeProperty(CSSPropertyColor); | 1548 style->removeProperty(CSSPropertyColor); |
| 1549 } | 1549 } |
| 1550 | 1550 |
| 1551 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily); | 1551 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily); |
| 1552 // Remove single quotes for Outlook 2007 compatibility. See https://bugs.web
kit.org/show_bug.cgi?id=79448 | 1552 // Remove single quotes for Outlook 2007 compatibility. See https://bugs.web
kit.org/show_bug.cgi?id=79448 |
| 1553 m_applyFontFace.replaceWithLiteral('\'', ""); | 1553 m_applyFontFace.replaceWithLiteral('\'', ""); |
| 1554 style->removeProperty(CSSPropertyFontFamily); | 1554 style->removeProperty(CSSPropertyFontFamily); |
| 1555 | 1555 |
| 1556 if (RefPtrWillBeRawPtr<CSSValue> fontSize = style->getPropertyCSSValue(CSSPr
opertyFontSize)) { | 1556 if (RefPtrWillBeRawPtr<CSSValue> fontSize = style->getPropertyCSSValue(CSSPr
opertyFontSize)) { |
| 1557 if (!fontSize->isPrimitiveValue()) { | 1557 if (!fontSize->isPrimitiveValue()) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1629 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect,
baseTextDecorationsInEffect.get()); | 1629 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect,
baseTextDecorationsInEffect.get()); |
| 1630 | 1630 |
| 1631 if (RefPtrWillBeRawPtr<CSSValue> baseFontWeight = baseStyle->getPropertyCSSV
alueInternal(CSSPropertyFontWeight)) { | 1631 if (RefPtrWillBeRawPtr<CSSValue> baseFontWeight = baseStyle->getPropertyCSSV
alueInternal(CSSPropertyFontWeight)) { |
| 1632 if (RefPtrWillBeRawPtr<CSSValue> fontWeight = result->getPropertyCSSValu
e(CSSPropertyFontWeight)) { | 1632 if (RefPtrWillBeRawPtr<CSSValue> fontWeight = result->getPropertyCSSValu
e(CSSPropertyFontWeight)) { |
| 1633 if (!fontWeightNeedsResolving(fontWeight.get()) && !fontWeightNeedsR
esolving(baseFontWeight.get()) | 1633 if (!fontWeightNeedsResolving(fontWeight.get()) && !fontWeightNeedsR
esolving(baseFontWeight.get()) |
| 1634 && (fontWeightIsBold(fontWeight.get()) == fontWeightIsBold(baseF
ontWeight.get()))) | 1634 && (fontWeightIsBold(fontWeight.get()) == fontWeightIsBold(baseF
ontWeight.get()))) |
| 1635 result->removeProperty(CSSPropertyFontWeight); | 1635 result->removeProperty(CSSPropertyFontWeight); |
| 1636 } | 1636 } |
| 1637 } | 1637 } |
| 1638 | 1638 |
| 1639 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC
olor(result.get()) == getRGBAFontColor(baseStyle)) | 1639 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getFontColor
(result.get()) == getFontColor(baseStyle)) |
| 1640 result->removeProperty(CSSPropertyColor); | 1640 result->removeProperty(CSSPropertyColor); |
| 1641 | 1641 |
| 1642 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) | 1642 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) |
| 1643 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar
tAndEnd(baseStyle)) | 1643 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar
tAndEnd(baseStyle)) |
| 1644 result->removeProperty(CSSPropertyTextAlign); | 1644 result->removeProperty(CSSPropertyTextAlign); |
| 1645 | 1645 |
| 1646 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge
tRGBABackgroundColor(result.get()) == getRGBABackgroundColor(baseStyle)) | 1646 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge
tBackgroundColor(result.get()) == getBackgroundColor(baseStyle)) |
| 1647 result->removeProperty(CSSPropertyBackgroundColor); | 1647 result->removeProperty(CSSPropertyBackgroundColor); |
| 1648 | 1648 |
| 1649 return result.release(); | 1649 return result.release(); |
| 1650 } | 1650 } |
| 1651 | 1651 |
| 1652 CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) | 1652 CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) |
| 1653 { | 1653 { |
| 1654 if (!style) | 1654 if (!style) |
| 1655 return CSSValueInvalid; | 1655 return CSSValueInvalid; |
| 1656 RefPtrWillBeRawPtr<CSSValue> value = style->getPropertyCSSValue(propertyID); | 1656 RefPtrWillBeRawPtr<CSSValue> value = style->getPropertyCSSValue(propertyID); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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()) | 1697 if (cssValue->isColorValue()) |
| 1698 return !alphaChannel(toCSSColorValue(cssValue)->value()); | 1698 return !toCSSColorValue(cssValue)->value().alpha(); |
| 1699 if (!cssValue->isPrimitiveValue()) | 1699 if (!cssValue->isPrimitiveValue()) |
| 1700 return false; | 1700 return false; |
| 1701 CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue); | 1701 CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue); |
| 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> backgroundColorValueInEffect(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 |