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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 if (propertiesToInclude == EditingPropertiesInEffect) { | 480 if (propertiesToInclude == EditingPropertiesInEffect) { |
481 if (const CSSValue* value = backgroundColorValueInEffect(node)) | 481 if (const CSSValue* value = backgroundColorValueInEffect(node)) |
482 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssText()); | 482 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssText()); |
483 if (const CSSValue* value = computedStyleAtPosition->getPropertyCSSValue( | 483 if (const CSSValue* value = computedStyleAtPosition->getPropertyCSSValue( |
484 CSSPropertyWebkitTextDecorationsInEffect)) | 484 CSSPropertyWebkitTextDecorationsInEffect)) |
485 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssText()); | 485 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssText()); |
486 } | 486 } |
487 | 487 |
488 if (node && node->ensureComputedStyle()) { | 488 if (node && node->ensureComputedStyle()) { |
489 const ComputedStyle* computedStyle = node->ensureComputedStyle(); | 489 const ComputedStyle* computedStyle = node->ensureComputedStyle(); |
490 removeTextFillAndStrokeColorsIfNeeded(computedStyle); | 490 removeInheritedColorsIfNeeded(computedStyle); |
491 replaceFontSizeByKeywordIfPossible(computedStyle, computedStyleAtPosition); | 491 replaceFontSizeByKeywordIfPossible(computedStyle, computedStyleAtPosition); |
492 } | 492 } |
493 | 493 |
494 m_isMonospaceFont = computedStyleAtPosition->isMonospaceFont(); | 494 m_isMonospaceFont = computedStyleAtPosition->isMonospaceFont(); |
495 extractFontSizeDelta(); | 495 extractFontSizeDelta(); |
496 } | 496 } |
497 | 497 |
498 void EditingStyle::removeTextFillAndStrokeColorsIfNeeded( | 498 void EditingStyle::removeInheritedColorsIfNeeded( |
499 const ComputedStyle* computedStyle) { | 499 const ComputedStyle* computedStyle) { |
500 // If a node's text fill color is currentColor, then its children use | 500 // If a node's text fill color is currentColor, then its children use |
501 // their font-color as their text fill color (they don't | 501 // their font-color as their text fill color (they don't |
502 // inherit it). Likewise for stroke color. | 502 // inherit it). Likewise for stroke color. |
| 503 // Similar thing happens for caret-color if it's auto or currentColor. |
503 if (computedStyle->textFillColor().isCurrentColor()) | 504 if (computedStyle->textFillColor().isCurrentColor()) |
504 m_mutableStyle->removeProperty(CSSPropertyWebkitTextFillColor); | 505 m_mutableStyle->removeProperty(CSSPropertyWebkitTextFillColor); |
505 if (computedStyle->textStrokeColor().isCurrentColor()) | 506 if (computedStyle->textStrokeColor().isCurrentColor()) |
506 m_mutableStyle->removeProperty(CSSPropertyWebkitTextStrokeColor); | 507 m_mutableStyle->removeProperty(CSSPropertyWebkitTextStrokeColor); |
| 508 if (computedStyle->caretColor().isAutoColor() || |
| 509 computedStyle->caretColor().isCurrentColor()) |
| 510 m_mutableStyle->removeProperty(CSSPropertyCaretColor); |
507 } | 511 } |
508 | 512 |
509 void EditingStyle::setProperty(CSSPropertyID propertyID, | 513 void EditingStyle::setProperty(CSSPropertyID propertyID, |
510 const String& value, | 514 const String& value, |
511 bool important) { | 515 bool important) { |
512 if (!m_mutableStyle) | 516 if (!m_mutableStyle) |
513 m_mutableStyle = MutableStylePropertySet::create(HTMLQuirksMode); | 517 m_mutableStyle = MutableStylePropertySet::create(HTMLQuirksMode); |
514 | 518 |
515 m_mutableStyle->setProperty(propertyID, value, important); | 519 m_mutableStyle->setProperty(propertyID, value, important); |
516 } | 520 } |
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2036 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 2040 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
2037 CSSComputedStyleDeclaration* ancestorStyle = | 2041 CSSComputedStyleDeclaration* ancestorStyle = |
2038 CSSComputedStyleDeclaration::create(ancestor); | 2042 CSSComputedStyleDeclaration::create(ancestor); |
2039 if (!hasTransparentBackgroundColor(ancestorStyle)) | 2043 if (!hasTransparentBackgroundColor(ancestorStyle)) |
2040 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor); | 2044 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor); |
2041 } | 2045 } |
2042 return nullptr; | 2046 return nullptr; |
2043 } | 2047 } |
2044 | 2048 |
2045 } // namespace blink | 2049 } // namespace blink |
OLD | NEW |