| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 static CSSComputedStyleDeclaration* ensureComputedStyle(const Position& position
) | 153 static CSSComputedStyleDeclaration* ensureComputedStyle(const Position& position
) |
| 154 { | 154 { |
| 155 Element* elem = associatedElementOf(position); | 155 Element* elem = associatedElementOf(position); |
| 156 if (!elem) | 156 if (!elem) |
| 157 return nullptr; | 157 return nullptr; |
| 158 return CSSComputedStyleDeclaration::create(elem); | 158 return CSSComputedStyleDeclaration::create(elem); |
| 159 } | 159 } |
| 160 | 160 |
| 161 static MutableStylePropertySet* getPropertiesNotIn(StylePropertySet* styleWithRe
dundantProperties, CSSStyleDeclaration* baseStyle); | 161 static MutableStylePropertySet* getPropertiesNotIn(StylePropertySet* styleWithRe
dundantProperties, CSSStyleDeclaration* baseStyle); |
| 162 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV
aluesMatch }; | 162 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV
aluesMatch }; |
| 163 static int legacyFontSizeFromCSSValue(Document*, const CSSPrimitiveValue*, bool,
LegacyFontSizeMode); | 163 static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool, Legac
yFontSizeMode); |
| 164 static bool isTransparentColorValue(const CSSValue*); | 164 static bool isTransparentColorValue(CSSValue*); |
| 165 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); | 165 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); |
| 166 static bool hasTransparentBackgroundColor(StylePropertySet*); | 166 static bool hasTransparentBackgroundColor(StylePropertySet*); |
| 167 static const CSSValue* backgroundColorValueInEffect(Node*); | 167 static CSSValue* backgroundColorValueInEffect(Node*); |
| 168 static bool hasAncestorVerticalAlignStyle(Node&, CSSValueID); | 168 static bool hasAncestorVerticalAlignStyle(Node&, CSSValueID); |
| 169 | 169 |
| 170 class HTMLElementEquivalent : public GarbageCollected<HTMLElementEquivalent> { | 170 class HTMLElementEquivalent : public GarbageCollected<HTMLElementEquivalent> { |
| 171 public: | 171 public: |
| 172 static HTMLElementEquivalent* create(CSSPropertyID propertyID, CSSValueID pr
imitiveValue, const HTMLQualifiedName& tagName) | 172 static HTMLElementEquivalent* create(CSSPropertyID propertyID, CSSValueID pr
imitiveValue, const HTMLQualifiedName& tagName) |
| 173 { | 173 { |
| 174 return new HTMLElementEquivalent(propertyID, primitiveValue, tagName); | 174 return new HTMLElementEquivalent(propertyID, primitiveValue, tagName); |
| 175 } | 175 } |
| 176 | 176 |
| 177 virtual bool matches(const Element* element) const { return !m_tagName || el
ement->hasTagName(*m_tagName); } | 177 virtual bool matches(const Element* element) const { return !m_tagName || el
ement->hasTagName(*m_tagName); } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 206 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, CSSValueID primit
iveValue, const HTMLQualifiedName& tagName) | 206 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, CSSValueID primit
iveValue, const HTMLQualifiedName& tagName) |
| 207 : m_propertyID(id) | 207 : m_propertyID(id) |
| 208 , m_primitiveValue(CSSPrimitiveValue::createIdentifier(primitiveValue)) | 208 , m_primitiveValue(CSSPrimitiveValue::createIdentifier(primitiveValue)) |
| 209 , m_tagName(&tagName) | 209 , m_tagName(&tagName) |
| 210 { | 210 { |
| 211 DCHECK_NE(primitiveValue, CSSValueInvalid); | 211 DCHECK_NE(primitiveValue, CSSValueInvalid); |
| 212 } | 212 } |
| 213 | 213 |
| 214 bool HTMLElementEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePro
pertySet* style) const | 214 bool HTMLElementEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePro
pertySet* style) const |
| 215 { | 215 { |
| 216 const CSSValue* value = style->getPropertyCSSValue(m_propertyID); | 216 CSSValue* value = style->getPropertyCSSValue(m_propertyID); |
| 217 return matches(element) && value && value->isPrimitiveValue() && toCSSPrimit
iveValue(value)->getValueID() == m_primitiveValue->getValueID(); | 217 return matches(element) && value && value->isPrimitiveValue() && toCSSPrimit
iveValue(value)->getValueID() == m_primitiveValue->getValueID(); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void HTMLElementEquivalent::addToStyle(Element*, EditingStyle* style) const | 220 void HTMLElementEquivalent::addToStyle(Element*, EditingStyle* style) const |
| 221 { | 221 { |
| 222 style->setProperty(m_propertyID, m_primitiveValue->cssText()); | 222 style->setProperty(m_propertyID, m_primitiveValue->cssText()); |
| 223 } | 223 } |
| 224 | 224 |
| 225 class HTMLTextDecorationEquivalent final : public HTMLElementEquivalent { | 225 class HTMLTextDecorationEquivalent final : public HTMLElementEquivalent { |
| 226 public: | 226 public: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 244 } | 244 } |
| 245 | 245 |
| 246 bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet*
style) const | 246 bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet*
style) const |
| 247 { | 247 { |
| 248 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect) | 248 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect) |
| 249 || style->getPropertyCSSValue(textDecorationPropertyForEditing()); | 249 || style->getPropertyCSSValue(textDecorationPropertyForEditing()); |
| 250 } | 250 } |
| 251 | 251 |
| 252 bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(HTMLElement* element, S
tylePropertySet* style) const | 252 bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(HTMLElement* element, S
tylePropertySet* style) const |
| 253 { | 253 { |
| 254 const CSSValue* styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTex
tDecorationsInEffect); | 254 CSSValue* styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTextDecor
ationsInEffect); |
| 255 if (!styleValue) | 255 if (!styleValue) |
| 256 styleValue = style->getPropertyCSSValue(textDecorationPropertyForEditing
()); | 256 styleValue = style->getPropertyCSSValue(textDecorationPropertyForEditing
()); |
| 257 return matches(element) && styleValue && styleValue->isValueList() && toCSSV
alueList(styleValue)->hasValue(*m_primitiveValue); | 257 return matches(element) && styleValue && styleValue->isValueList() && toCSSV
alueList(styleValue)->hasValue(*m_primitiveValue); |
| 258 } | 258 } |
| 259 | 259 |
| 260 class HTMLAttributeEquivalent : public HTMLElementEquivalent { | 260 class HTMLAttributeEquivalent : public HTMLElementEquivalent { |
| 261 public: | 261 public: |
| 262 static HTMLAttributeEquivalent* create(CSSPropertyID propertyID, const HTMLQ
ualifiedName& tagName, const QualifiedName& attrName) | 262 static HTMLAttributeEquivalent* create(CSSPropertyID propertyID, const HTMLQ
ualifiedName& tagName, const QualifiedName& attrName) |
| 263 { | 263 { |
| 264 return new HTMLAttributeEquivalent(propertyID, tagName, attrName); | 264 return new HTMLAttributeEquivalent(propertyID, tagName, attrName); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 291 | 291 |
| 292 HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const Qualifi
edName& attrName) | 292 HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const Qualifi
edName& attrName) |
| 293 : HTMLElementEquivalent(id) | 293 : HTMLElementEquivalent(id) |
| 294 , m_attrName(attrName) | 294 , m_attrName(attrName) |
| 295 { | 295 { |
| 296 } | 296 } |
| 297 | 297 |
| 298 bool HTMLAttributeEquivalent::valueIsPresentInStyle(HTMLElement* element, StyleP
ropertySet* style) const | 298 bool HTMLAttributeEquivalent::valueIsPresentInStyle(HTMLElement* element, StyleP
ropertySet* style) const |
| 299 { | 299 { |
| 300 CSSValue* value = attributeValueAsCSSValue(element); | 300 CSSValue* value = attributeValueAsCSSValue(element); |
| 301 const CSSValue* styleValue = style->getPropertyCSSValue(m_propertyID); | 301 CSSValue* styleValue = style->getPropertyCSSValue(m_propertyID); |
| 302 | 302 |
| 303 return compareCSSValuePtr(value, styleValue); | 303 return compareCSSValuePtr(value, styleValue); |
| 304 } | 304 } |
| 305 | 305 |
| 306 void HTMLAttributeEquivalent::addToStyle(Element* element, EditingStyle* style)
const | 306 void HTMLAttributeEquivalent::addToStyle(Element* element, EditingStyle* style)
const |
| 307 { | 307 { |
| 308 if (CSSValue* value = attributeValueAsCSSValue(element)) | 308 if (CSSValue* value = attributeValueAsCSSValue(element)) |
| 309 style->setProperty(m_propertyID, value->cssText()); | 309 style->setProperty(m_propertyID, value->cssText()); |
| 310 } | 310 } |
| 311 | 311 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 | 385 |
| 386 EditingStyle::EditingStyle(CSSPropertyID propertyID, const String& value) | 386 EditingStyle::EditingStyle(CSSPropertyID propertyID, const String& value) |
| 387 : m_mutableStyle(nullptr) | 387 : m_mutableStyle(nullptr) |
| 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 m_isVerticalAlign = propertyID == CSSPropertyVerticalAlign && (value == "sub
" || value == "super"); | 392 m_isVerticalAlign = propertyID == CSSPropertyVerticalAlign && (value == "sub
" || value == "super"); |
| 393 } | 393 } |
| 394 | 394 |
| 395 static Color cssValueToColor(const CSSValue* colorValue) | 395 static Color cssValueToColor(CSSValue* colorValue) |
| 396 { | 396 { |
| 397 if (!colorValue || (!colorValue->isColorValue() && !colorValue->isPrimitiveV
alue())) | 397 if (!colorValue || (!colorValue->isColorValue() && !colorValue->isPrimitiveV
alue())) |
| 398 return Color::transparent; | 398 return Color::transparent; |
| 399 | 399 |
| 400 if (colorValue->isColorValue()) | 400 if (colorValue->isColorValue()) |
| 401 return toCSSColorValue(colorValue)->value(); | 401 return toCSSColorValue(colorValue)->value(); |
| 402 | 402 |
| 403 Color color = 0; | 403 Color color = 0; |
| 404 // FIXME: Why ignore the return value? | 404 // FIXME: Why ignore the return value? |
| 405 CSSParser::parseColor(color, colorValue->cssText()); | 405 CSSParser::parseColor(color, colorValue->cssText()); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 { | 463 { |
| 464 if (isTabHTMLSpanElementTextNode(node)) | 464 if (isTabHTMLSpanElementTextNode(node)) |
| 465 node = tabSpanElement(node)->parentNode(); | 465 node = tabSpanElement(node)->parentNode(); |
| 466 else if (isTabHTMLSpanElement(node)) | 466 else if (isTabHTMLSpanElement(node)) |
| 467 node = node->parentNode(); | 467 node = node->parentNode(); |
| 468 | 468 |
| 469 CSSComputedStyleDeclaration* computedStyleAtPosition = CSSComputedStyleDecla
ration::create(node); | 469 CSSComputedStyleDeclaration* computedStyleAtPosition = CSSComputedStyleDecla
ration::create(node); |
| 470 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi
tion ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle
(computedStyleAtPosition); | 470 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi
tion ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle
(computedStyleAtPosition); |
| 471 | 471 |
| 472 if (propertiesToInclude == EditingPropertiesInEffect) { | 472 if (propertiesToInclude == EditingPropertiesInEffect) { |
| 473 if (const CSSValue* value = backgroundColorValueInEffect(node)) | 473 if (CSSValue* value = backgroundColorValueInEffect(node)) |
| 474 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe
xt()); | 474 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe
xt()); |
| 475 if (const CSSValue* value = computedStyleAtPosition->getPropertyCSSValue
(CSSPropertyWebkitTextDecorationsInEffect)) | 475 if (CSSValue* value = computedStyleAtPosition->getPropertyCSSValue(CSSPr
opertyWebkitTextDecorationsInEffect)) |
| 476 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex
t()); | 476 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex
t()); |
| 477 } | 477 } |
| 478 | 478 |
| 479 if (node && node->ensureComputedStyle()) { | 479 if (node && node->ensureComputedStyle()) { |
| 480 const ComputedStyle* computedStyle = node->ensureComputedStyle(); | 480 const ComputedStyle* computedStyle = node->ensureComputedStyle(); |
| 481 removeTextFillAndStrokeColorsIfNeeded(computedStyle); | 481 removeTextFillAndStrokeColorsIfNeeded(computedStyle); |
| 482 replaceFontSizeByKeywordIfPossible(computedStyle, computedStyleAtPositio
n); | 482 replaceFontSizeByKeywordIfPossible(computedStyle, computedStyleAtPositio
n); |
| 483 } | 483 } |
| 484 | 484 |
| 485 m_isMonospaceFont = computedStyleAtPosition->isMonospaceFont(); | 485 m_isMonospaceFont = computedStyleAtPosition->isMonospaceFont(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 if (!m_mutableStyle) | 517 if (!m_mutableStyle) |
| 518 return; | 518 return; |
| 519 | 519 |
| 520 if (m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize)) { | 520 if (m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize)) { |
| 521 // Explicit font size overrides any delta. | 521 // Explicit font size overrides any delta. |
| 522 m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta); | 522 m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta); |
| 523 return; | 523 return; |
| 524 } | 524 } |
| 525 | 525 |
| 526 // Get the adjustment amount out of the style. | 526 // Get the adjustment amount out of the style. |
| 527 const CSSValue* value = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebki
tFontSizeDelta); | 527 CSSValue* value = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebkitFontS
izeDelta); |
| 528 if (!value || !value->isPrimitiveValue()) | 528 if (!value || !value->isPrimitiveValue()) |
| 529 return; | 529 return; |
| 530 | 530 |
| 531 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 531 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 532 | 532 |
| 533 // Only PX handled now. If we handle more types in the future, perhaps | 533 // Only PX handled now. If we handle more types in the future, perhaps |
| 534 // a switch statement here would be more appropriate. | 534 // a switch statement here would be more appropriate. |
| 535 if (!primitiveValue->isPx()) | 535 if (!primitiveValue->isPx()) |
| 536 return; | 536 return; |
| 537 | 537 |
| 538 m_fontSizeDelta = primitiveValue->getFloatValue(); | 538 m_fontSizeDelta = primitiveValue->getFloatValue(); |
| 539 m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta); | 539 m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta); |
| 540 } | 540 } |
| 541 | 541 |
| 542 bool EditingStyle::isEmpty() const | 542 bool EditingStyle::isEmpty() const |
| 543 { | 543 { |
| 544 return (!m_mutableStyle || m_mutableStyle->isEmpty()) && m_fontSizeDelta ==
NoFontDelta; | 544 return (!m_mutableStyle || m_mutableStyle->isEmpty()) && m_fontSizeDelta ==
NoFontDelta; |
| 545 } | 545 } |
| 546 | 546 |
| 547 bool EditingStyle::textDirection(WritingDirection& writingDirection) const | 547 bool EditingStyle::textDirection(WritingDirection& writingDirection) const |
| 548 { | 548 { |
| 549 if (!m_mutableStyle) | 549 if (!m_mutableStyle) |
| 550 return false; | 550 return false; |
| 551 | 551 |
| 552 const CSSValue* unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropert
yUnicodeBidi); | 552 CSSValue* unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnico
deBidi); |
| 553 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) | 553 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) |
| 554 return false; | 554 return false; |
| 555 | 555 |
| 556 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValueID()
; | 556 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValueID()
; |
| 557 if (isEmbedOrIsolate(unicodeBidiValue)) { | 557 if (isEmbedOrIsolate(unicodeBidiValue)) { |
| 558 const CSSValue* direction = m_mutableStyle->getPropertyCSSValue(CSSPrope
rtyDirection); | 558 CSSValue* direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDir
ection); |
| 559 if (!direction || !direction->isPrimitiveValue()) | 559 if (!direction || !direction->isPrimitiveValue()) |
| 560 return false; | 560 return false; |
| 561 | 561 |
| 562 writingDirection = toCSSPrimitiveValue(direction)->getValueID() == CSSVa
lueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection; | 562 writingDirection = toCSSPrimitiveValue(direction)->getValueID() == CSSVa
lueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection; |
| 563 | 563 |
| 564 return true; | 564 return true; |
| 565 } | 565 } |
| 566 | 566 |
| 567 if (unicodeBidiValue == CSSValueNormal) { | 567 if (unicodeBidiValue == CSSValueNormal) { |
| 568 writingDirection = NaturalWritingDirection; | 568 writingDirection = NaturalWritingDirection; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 unsigned propertyCount = nodeStyle->propertyCount(); | 689 unsigned propertyCount = nodeStyle->propertyCount(); |
| 690 for (unsigned i = 0; i < propertyCount; ++i) | 690 for (unsigned i = 0; i < propertyCount; ++i) |
| 691 m_mutableStyle->removeProperty(nodeStyle->propertyAt(i).id()); | 691 m_mutableStyle->removeProperty(nodeStyle->propertyAt(i).id()); |
| 692 } | 692 } |
| 693 | 693 |
| 694 void EditingStyle::collapseTextDecorationProperties() | 694 void EditingStyle::collapseTextDecorationProperties() |
| 695 { | 695 { |
| 696 if (!m_mutableStyle) | 696 if (!m_mutableStyle) |
| 697 return; | 697 return; |
| 698 | 698 |
| 699 const CSSValue* textDecorationsInEffect = m_mutableStyle->getPropertyCSSValu
e(CSSPropertyWebkitTextDecorationsInEffect); | 699 CSSValue* textDecorationsInEffect = m_mutableStyle->getPropertyCSSValue(CSSP
ropertyWebkitTextDecorationsInEffect); |
| 700 if (!textDecorationsInEffect) | 700 if (!textDecorationsInEffect) |
| 701 return; | 701 return; |
| 702 | 702 |
| 703 if (textDecorationsInEffect->isValueList()) | 703 if (textDecorationsInEffect->isValueList()) |
| 704 m_mutableStyle->setProperty(textDecorationPropertyForEditing(), textDeco
rationsInEffect->cssText(), m_mutableStyle->propertyIsImportant(textDecorationPr
opertyForEditing())); | 704 m_mutableStyle->setProperty(textDecorationPropertyForEditing(), textDeco
rationsInEffect->cssText(), m_mutableStyle->propertyIsImportant(textDecorationPr
opertyForEditing())); |
| 705 else | 705 else |
| 706 m_mutableStyle->removeProperty(textDecorationPropertyForEditing()); | 706 m_mutableStyle->removeProperty(textDecorationPropertyForEditing()); |
| 707 m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); | 707 m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); |
| 708 } | 708 } |
| 709 | 709 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 TriState state = FalseTriState; | 762 TriState state = FalseTriState; |
| 763 bool nodeIsStart = true; | 763 bool nodeIsStart = true; |
| 764 for (Node& node : NodeTraversal::startsAt(*selection.start().anchorNode()))
{ | 764 for (Node& node : NodeTraversal::startsAt(*selection.start().anchorNode()))
{ |
| 765 if (node.layoutObject() && node.hasEditableStyle()) { | 765 if (node.layoutObject() && node.hasEditableStyle()) { |
| 766 CSSComputedStyleDeclaration* nodeStyle = CSSComputedStyleDeclaration
::create(&node); | 766 CSSComputedStyleDeclaration* nodeStyle = CSSComputedStyleDeclaration
::create(&node); |
| 767 if (nodeStyle) { | 767 if (nodeStyle) { |
| 768 // If the selected element has <sub> or <sup> ancestor element,
apply the corresponding | 768 // If the selected element has <sub> or <sup> ancestor element,
apply the corresponding |
| 769 // style(vertical-align) to it so that document.queryCommandStat
e() works with the style. | 769 // style(vertical-align) to it so that document.queryCommandStat
e() works with the style. |
| 770 // See bug http://crbug.com/582225. | 770 // See bug http://crbug.com/582225. |
| 771 if (m_isVerticalAlign && getIdentifierValue(nodeStyle, CSSProper
tyVerticalAlign) == CSSValueBaseline) { | 771 if (m_isVerticalAlign && getIdentifierValue(nodeStyle, CSSProper
tyVerticalAlign) == CSSValueBaseline) { |
| 772 const CSSPrimitiveValue* verticalAlign = toCSSPrimitiveValue
(m_mutableStyle->getPropertyCSSValue(CSSPropertyVerticalAlign)); | 772 CSSPrimitiveValue* verticalAlign = toCSSPrimitiveValue(m_mut
ableStyle->getPropertyCSSValue(CSSPropertyVerticalAlign)); |
| 773 if (hasAncestorVerticalAlignStyle(node, verticalAlign->getVa
lueID())) | 773 if (hasAncestorVerticalAlignStyle(node, verticalAlign->getVa
lueID())) |
| 774 node.mutableComputedStyle()->setVerticalAlign(verticalAl
ign->convertTo<EVerticalAlign>()); | 774 node.mutableComputedStyle()->setVerticalAlign(verticalAl
ign->convertTo<EVerticalAlign>()); |
| 775 } | 775 } |
| 776 | 776 |
| 777 // Pass EditingStyle::DoNotIgnoreTextOnlyProperties without chec
king if node.isTextNode() | 777 // Pass EditingStyle::DoNotIgnoreTextOnlyProperties without chec
king if node.isTextNode() |
| 778 // because the node can be an element node. See bug http://crbug
.com/584939. | 778 // because the node can be an element node. See bug http://crbug
.com/584939. |
| 779 TriState nodeState = triStateOfStyle(nodeStyle, EditingStyle::Do
NotIgnoreTextOnlyProperties); | 779 TriState nodeState = triStateOfStyle(nodeStyle, EditingStyle::Do
NotIgnoreTextOnlyProperties); |
| 780 if (nodeIsStart) { | 780 if (nodeIsStart) { |
| 781 state = nodeState; | 781 state = nodeState; |
| 782 nodeIsStart = false; | 782 nodeIsStart = false; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 { | 1008 { |
| 1009 if (!m_mutableStyle) | 1009 if (!m_mutableStyle) |
| 1010 return; | 1010 return; |
| 1011 | 1011 |
| 1012 // ReplaceSelectionCommand::handleStyleSpans() requires that this function o
nly removes the editing style. | 1012 // ReplaceSelectionCommand::handleStyleSpans() requires that this function o
nly removes the editing style. |
| 1013 // If this function was modified in the future to delete all redundant prope
rties, then add a boolean value to indicate | 1013 // If this function was modified in the future to delete all redundant prope
rties, then add a boolean value to indicate |
| 1014 // which one of editingStyleAtPosition or computedStyle is called. | 1014 // which one of editingStyleAtPosition or computedStyle is called. |
| 1015 EditingStyle* editingStyleAtPosition = EditingStyle::create(position, Editin
gPropertiesInEffect); | 1015 EditingStyle* editingStyleAtPosition = EditingStyle::create(position, Editin
gPropertiesInEffect); |
| 1016 StylePropertySet* styleAtPosition = editingStyleAtPosition->m_mutableStyle.g
et(); | 1016 StylePropertySet* styleAtPosition = editingStyleAtPosition->m_mutableStyle.g
et(); |
| 1017 | 1017 |
| 1018 const CSSValue* unicodeBidi = nullptr; | 1018 CSSValue* unicodeBidi = nullptr; |
| 1019 const CSSValue* direction = nullptr; | 1019 CSSValue* direction = nullptr; |
| 1020 if (shouldPreserveWritingDirection == PreserveWritingDirection) { | 1020 if (shouldPreserveWritingDirection == PreserveWritingDirection) { |
| 1021 unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi
); | 1021 unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi
); |
| 1022 direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection); | 1022 direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection); |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 m_mutableStyle->removeEquivalentProperties(styleAtPosition); | 1025 m_mutableStyle->removeEquivalentProperties(styleAtPosition); |
| 1026 | 1026 |
| 1027 if (textAlignResolvingStartAndEnd(m_mutableStyle.get()) == textAlignResolvin
gStartAndEnd(styleAtPosition)) | 1027 if (textAlignResolvingStartAndEnd(m_mutableStyle.get()) == textAlignResolvin
gStartAndEnd(styleAtPosition)) |
| 1028 m_mutableStyle->removeProperty(CSSPropertyTextAlign); | 1028 m_mutableStyle->removeProperty(CSSPropertyTextAlign); |
| 1029 | 1029 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 break; | 1148 break; |
| 1149 if (node.isStyledElement() && !isMailHTMLBlockquoteElement(&node)) { | 1149 if (node.isStyledElement() && !isMailHTMLBlockquoteElement(&node)) { |
| 1150 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(&node)
, EditingStyle::DoNotOverrideValues, | 1150 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(&node)
, EditingStyle::DoNotOverrideValues, |
| 1151 EditingStyle::EditingPropertiesInEffect); | 1151 EditingStyle::EditingPropertiesInEffect); |
| 1152 } | 1152 } |
| 1153 } | 1153 } |
| 1154 | 1154 |
| 1155 return wrappingStyle; | 1155 return wrappingStyle; |
| 1156 } | 1156 } |
| 1157 | 1157 |
| 1158 static CSSValueList* mergeTextDecorationValues(const CSSValueList* mergedValue,
const CSSValueList* valueToMerge) | 1158 static void mergeTextDecorationValues(CSSValueList* mergedValue, const CSSValueL
ist* valueToMerge) |
| 1159 { | 1159 { |
| 1160 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::create
Identifier(CSSValueUnderline))); | 1160 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::create
Identifier(CSSValueUnderline))); |
| 1161 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::crea
teIdentifier(CSSValueLineThrough))); | 1161 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::crea
teIdentifier(CSSValueLineThrough))); |
| 1162 CSSValueList* result = mergedValue->copy(); | |
| 1163 if (valueToMerge->hasValue(underline) && !mergedValue->hasValue(underline)) | 1162 if (valueToMerge->hasValue(underline) && !mergedValue->hasValue(underline)) |
| 1164 result->append(&underline); | 1163 mergedValue->append(&underline); |
| 1165 | 1164 |
| 1166 if (valueToMerge->hasValue(lineThrough) && !mergedValue->hasValue(lineThroug
h)) | 1165 if (valueToMerge->hasValue(lineThrough) && !mergedValue->hasValue(lineThroug
h)) |
| 1167 result->append(&lineThrough); | 1166 mergedValue->append(&lineThrough); |
| 1168 | |
| 1169 return result; | |
| 1170 } | 1167 } |
| 1171 | 1168 |
| 1172 void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride
Mode mode) | 1169 void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride
Mode mode) |
| 1173 { | 1170 { |
| 1174 if (!style) | 1171 if (!style) |
| 1175 return; | 1172 return; |
| 1176 | 1173 |
| 1177 if (!m_mutableStyle) { | 1174 if (!m_mutableStyle) { |
| 1178 m_mutableStyle = style->mutableCopy(); | 1175 m_mutableStyle = style->mutableCopy(); |
| 1179 return; | 1176 return; |
| 1180 } | 1177 } |
| 1181 | 1178 |
| 1182 unsigned propertyCount = style->propertyCount(); | 1179 unsigned propertyCount = style->propertyCount(); |
| 1183 for (unsigned i = 0; i < propertyCount; ++i) { | 1180 for (unsigned i = 0; i < propertyCount; ++i) { |
| 1184 StylePropertySet::PropertyReference property = style->propertyAt(i); | 1181 StylePropertySet::PropertyReference property = style->propertyAt(i); |
| 1185 const CSSValue* value = m_mutableStyle->getPropertyCSSValue(property.id(
)); | 1182 CSSValue* value = m_mutableStyle->getPropertyCSSValue(property.id()); |
| 1186 | 1183 |
| 1187 // text decorations never override values | 1184 // text decorations never override values |
| 1188 if ((property.id() == textDecorationPropertyForEditing() || property.id(
) == CSSPropertyWebkitTextDecorationsInEffect) && property.value()->isValueList(
) && value) { | 1185 if ((property.id() == textDecorationPropertyForEditing() || property.id(
) == CSSPropertyWebkitTextDecorationsInEffect) && property.value()->isValueList(
) && value) { |
| 1189 if (value->isValueList()) { | 1186 if (value->isValueList()) { |
| 1190 CSSValueList* result = mergeTextDecorationValues(toCSSValueList(
value), toCSSValueList(property.value())); | 1187 mergeTextDecorationValues(toCSSValueList(value), toCSSValueList(
property.value())); |
| 1191 m_mutableStyle->setProperty(property.id(), result, property.isIm
portant()); | |
| 1192 continue; | 1188 continue; |
| 1193 } | 1189 } |
| 1194 value = nullptr; // text-decoration: none is equivalent to not havin
g the property | 1190 value = nullptr; // text-decoration: none is equivalent to not havin
g the property |
| 1195 } | 1191 } |
| 1196 | 1192 |
| 1197 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value)) | 1193 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value)) |
| 1198 m_mutableStyle->setProperty(property.id(), property.value()->cssText
(), property.isImportant()); | 1194 m_mutableStyle->setProperty(property.id(), property.value()->cssText
(), property.isImportant()); |
| 1199 } | 1195 } |
| 1200 } | 1196 } |
| 1201 | 1197 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 CSSComputedStyleDeclaration* computedStyleForElement = CSSComputedStyleDecla
ration::create(element); | 1229 CSSComputedStyleDeclaration* computedStyleForElement = CSSComputedStyleDecla
ration::create(element); |
| 1234 MutableStylePropertySet* fromComputedStyle = MutableStylePropertySet::create
(HTMLQuirksMode); | 1230 MutableStylePropertySet* fromComputedStyle = MutableStylePropertySet::create
(HTMLQuirksMode); |
| 1235 { | 1231 { |
| 1236 unsigned propertyCount = m_mutableStyle->propertyCount(); | 1232 unsigned propertyCount = m_mutableStyle->propertyCount(); |
| 1237 for (unsigned i = 0; i < propertyCount; ++i) { | 1233 for (unsigned i = 0; i < propertyCount; ++i) { |
| 1238 StylePropertySet::PropertyReference property = m_mutableStyle->prope
rtyAt(i); | 1234 StylePropertySet::PropertyReference property = m_mutableStyle->prope
rtyAt(i); |
| 1239 CSSValue* value = property.value(); | 1235 CSSValue* value = property.value(); |
| 1240 if (!value->isPrimitiveValue()) | 1236 if (!value->isPrimitiveValue()) |
| 1241 continue; | 1237 continue; |
| 1242 if (toCSSPrimitiveValue(value)->isPercentage()) { | 1238 if (toCSSPrimitiveValue(value)->isPercentage()) { |
| 1243 if (const CSSValue* computedPropertyValue = computedStyleForElem
ent->getPropertyCSSValue(property.id())) | 1239 if (CSSValue* computedPropertyValue = computedStyleForElement->g
etPropertyCSSValue(property.id())) |
| 1244 fromComputedStyle->addRespectingCascade(CSSProperty(property
.id(), computedPropertyValue)); | 1240 fromComputedStyle->addRespectingCascade(CSSProperty(property
.id(), computedPropertyValue)); |
| 1245 } | 1241 } |
| 1246 } | 1242 } |
| 1247 } | 1243 } |
| 1248 m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle); | 1244 m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle); |
| 1249 } | 1245 } |
| 1250 | 1246 |
| 1251 static void removePropertiesInStyle(MutableStylePropertySet* styleToRemoveProper
tiesFrom, StylePropertySet* style) | 1247 static void removePropertiesInStyle(MutableStylePropertySet* styleToRemoveProper
tiesFrom, StylePropertySet* style) |
| 1252 { | 1248 { |
| 1253 unsigned propertyCount = style->propertyCount(); | 1249 unsigned propertyCount = style->propertyCount(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1327 void EditingStyle::forceInline() | 1323 void EditingStyle::forceInline() |
| 1328 { | 1324 { |
| 1329 if (!m_mutableStyle) | 1325 if (!m_mutableStyle) |
| 1330 m_mutableStyle = MutableStylePropertySet::create(HTMLQuirksMode); | 1326 m_mutableStyle = MutableStylePropertySet::create(HTMLQuirksMode); |
| 1331 const bool propertyIsImportant = true; | 1327 const bool propertyIsImportant = true; |
| 1332 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm
portant); | 1328 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm
portant); |
| 1333 } | 1329 } |
| 1334 | 1330 |
| 1335 int EditingStyle::legacyFontSize(Document* document) const | 1331 int EditingStyle::legacyFontSize(Document* document) const |
| 1336 { | 1332 { |
| 1337 const CSSValue* cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyFo
ntSize); | 1333 CSSValue* cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize
); |
| 1338 if (!cssValue || !cssValue->isPrimitiveValue()) | 1334 if (!cssValue || !cssValue->isPrimitiveValue()) |
| 1339 return 0; | 1335 return 0; |
| 1340 return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue), | 1336 return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue), |
| 1341 m_isMonospaceFont, AlwaysUseLegacyFontSize); | 1337 m_isMonospaceFont, AlwaysUseLegacyFontSize); |
| 1342 } | 1338 } |
| 1343 | 1339 |
| 1344 EditingStyle* EditingStyle::styleAtSelectionStart(const VisibleSelection& select
ion, bool shouldUseBackgroundColorInEffect, MutableStylePropertySet* styleToChec
k) | 1340 EditingStyle* EditingStyle::styleAtSelectionStart(const VisibleSelection& select
ion, bool shouldUseBackgroundColorInEffect, MutableStylePropertySet* styleToChec
k) |
| 1345 { | 1341 { |
| 1346 if (selection.isNone()) | 1342 if (selection.isNone()) |
| 1347 return nullptr; | 1343 return nullptr; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1372 // Find the ancestor that has CSSValueSub or CSSValueSuper as the value
of CSS vertical-align property. | 1368 // Find the ancestor that has CSSValueSub or CSSValueSuper as the value
of CSS vertical-align property. |
| 1373 if (getIdentifierValue(elementStyle, CSSPropertyVerticalAlign) == CSSVal
ueBaseline && hasAncestorVerticalAlignStyle(*element, valueID)) | 1369 if (getIdentifierValue(elementStyle, CSSPropertyVerticalAlign) == CSSVal
ueBaseline && hasAncestorVerticalAlignStyle(*element, valueID)) |
| 1374 style->m_mutableStyle->setProperty(CSSPropertyVerticalAlign, valueID
); | 1370 style->m_mutableStyle->setProperty(CSSPropertyVerticalAlign, valueID
); |
| 1375 } | 1371 } |
| 1376 | 1372 |
| 1377 // If background color is transparent, traverse parent nodes until we hit a
different value or document root | 1373 // If background color is transparent, traverse parent nodes until we hit a
different value or document root |
| 1378 // Also, if the selection is a range, ignore the background color at the sta
rt of selection, | 1374 // Also, if the selection is a range, ignore the background color at the sta
rt of selection, |
| 1379 // and find the background color of the common ancestor. | 1375 // and find the background color of the common ancestor. |
| 1380 if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTranspare
ntBackgroundColor(style->m_mutableStyle.get()))) { | 1376 if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTranspare
ntBackgroundColor(style->m_mutableStyle.get()))) { |
| 1381 const EphemeralRange range(selection.toNormalizedEphemeralRange()); | 1377 const EphemeralRange range(selection.toNormalizedEphemeralRange()); |
| 1382 if (const CSSValue* value = backgroundColorValueInEffect(Range::commonAn
cestorContainer(range.startPosition().computeContainerNode(), range.endPosition(
).computeContainerNode()))) | 1378 if (CSSValue* value = backgroundColorValueInEffect(Range::commonAncestor
Container(range.startPosition().computeContainerNode(), range.endPosition().comp
uteContainerNode()))) |
| 1383 style->setProperty(CSSPropertyBackgroundColor, value->cssText()); | 1379 style->setProperty(CSSPropertyBackgroundColor, value->cssText()); |
| 1384 } | 1380 } |
| 1385 | 1381 |
| 1386 return style; | 1382 return style; |
| 1387 } | 1383 } |
| 1388 | 1384 |
| 1389 static bool isUnicodeBidiNestedOrMultipleEmbeddings(CSSValueID valueID) | 1385 static bool isUnicodeBidiNestedOrMultipleEmbeddings(CSSValueID valueID) |
| 1390 { | 1386 { |
| 1391 return valueID == CSSValueEmbed || valueID == CSSValueBidiOverride | 1387 return valueID == CSSValueEmbed || valueID == CSSValueBidiOverride |
| 1392 || valueID == CSSValueWebkitIsolate || valueID == CSSValueWebkitIsolateO
verride || valueID == CSSValueWebkitPlaintext | 1388 || valueID == CSSValueWebkitIsolate || valueID == CSSValueWebkitIsolateO
verride || valueID == CSSValueWebkitPlaintext |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1410 if (selection.isRange()) { | 1406 if (selection.isRange()) { |
| 1411 end = mostBackwardCaretPosition(selection.end()); | 1407 end = mostBackwardCaretPosition(selection.end()); |
| 1412 | 1408 |
| 1413 DCHECK(end.document()); | 1409 DCHECK(end.document()); |
| 1414 Node* pastLast = Range::create(*end.document(), position.parentAnchoredE
quivalent(), end.parentAnchoredEquivalent())->pastLastNode(); | 1410 Node* pastLast = Range::create(*end.document(), position.parentAnchoredE
quivalent(), end.parentAnchoredEquivalent())->pastLastNode(); |
| 1415 for (Node* n = node; n && n != pastLast; n = NodeTraversal::next(*n)) { | 1411 for (Node* n = node; n && n != pastLast; n = NodeTraversal::next(*n)) { |
| 1416 if (!n->isStyledElement()) | 1412 if (!n->isStyledElement()) |
| 1417 continue; | 1413 continue; |
| 1418 | 1414 |
| 1419 CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::cr
eate(n); | 1415 CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::cr
eate(n); |
| 1420 const CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSProperty
UnicodeBidi); | 1416 CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicod
eBidi); |
| 1421 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) | 1417 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) |
| 1422 continue; | 1418 continue; |
| 1423 | 1419 |
| 1424 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getV
alueID(); | 1420 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getV
alueID(); |
| 1425 if (isUnicodeBidiNestedOrMultipleEmbeddings(unicodeBidiValue)) | 1421 if (isUnicodeBidiNestedOrMultipleEmbeddings(unicodeBidiValue)) |
| 1426 return NaturalWritingDirection; | 1422 return NaturalWritingDirection; |
| 1427 } | 1423 } |
| 1428 } | 1424 } |
| 1429 | 1425 |
| 1430 if (selection.isCaret()) { | 1426 if (selection.isCaret()) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1443 WritingDirection foundDirection = NaturalWritingDirection; | 1439 WritingDirection foundDirection = NaturalWritingDirection; |
| 1444 | 1440 |
| 1445 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*node)) { | 1441 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*node)) { |
| 1446 if (runner == block) | 1442 if (runner == block) |
| 1447 break; | 1443 break; |
| 1448 if (!runner.isStyledElement()) | 1444 if (!runner.isStyledElement()) |
| 1449 continue; | 1445 continue; |
| 1450 | 1446 |
| 1451 Element* element = &toElement(runner); | 1447 Element* element = &toElement(runner); |
| 1452 CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::create
(element); | 1448 CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::create
(element); |
| 1453 const CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnic
odeBidi); | 1449 CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBid
i); |
| 1454 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) | 1450 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) |
| 1455 continue; | 1451 continue; |
| 1456 | 1452 |
| 1457 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValue
ID(); | 1453 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValue
ID(); |
| 1458 if (unicodeBidiValue == CSSValueNormal) | 1454 if (unicodeBidiValue == CSSValueNormal) |
| 1459 continue; | 1455 continue; |
| 1460 | 1456 |
| 1461 if (unicodeBidiValue == CSSValueBidiOverride) | 1457 if (unicodeBidiValue == CSSValueBidiOverride) |
| 1462 return NaturalWritingDirection; | 1458 return NaturalWritingDirection; |
| 1463 | 1459 |
| 1464 DCHECK(isEmbedOrIsolate(unicodeBidiValue)) << unicodeBidiValue; | 1460 DCHECK(isEmbedOrIsolate(unicodeBidiValue)) << unicodeBidiValue; |
| 1465 const CSSValue* direction = style->getPropertyCSSValue(CSSPropertyDirect
ion); | 1461 CSSValue* direction = style->getPropertyCSSValue(CSSPropertyDirection); |
| 1466 if (!direction || !direction->isPrimitiveValue()) | 1462 if (!direction || !direction->isPrimitiveValue()) |
| 1467 continue; | 1463 continue; |
| 1468 | 1464 |
| 1469 int directionValue = toCSSPrimitiveValue(direction)->getValueID(); | 1465 int directionValue = toCSSPrimitiveValue(direction)->getValueID(); |
| 1470 if (directionValue != CSSValueLtr && directionValue != CSSValueRtl) | 1466 if (directionValue != CSSValueLtr && directionValue != CSSValueRtl) |
| 1471 continue; | 1467 continue; |
| 1472 | 1468 |
| 1473 if (foundDirection != NaturalWritingDirection) | 1469 if (foundDirection != NaturalWritingDirection) |
| 1474 return NaturalWritingDirection; | 1470 return NaturalWritingDirection; |
| 1475 | 1471 |
| 1476 // In the range case, make sure that the embedding element persists unti
l the end of the range. | 1472 // In the range case, make sure that the embedding element persists unti
l the end of the range. |
| 1477 if (selection.isRange() && !end.anchorNode()->isDescendantOf(element)) | 1473 if (selection.isRange() && !end.anchorNode()->isDescendantOf(element)) |
| 1478 return NaturalWritingDirection; | 1474 return NaturalWritingDirection; |
| 1479 | 1475 |
| 1480 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec
tion : RightToLeftWritingDirection; | 1476 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec
tion : RightToLeftWritingDirection; |
| 1481 } | 1477 } |
| 1482 hasNestedOrMultipleEmbeddings = false; | 1478 hasNestedOrMultipleEmbeddings = false; |
| 1483 return foundDirection; | 1479 return foundDirection; |
| 1484 } | 1480 } |
| 1485 | 1481 |
| 1486 DEFINE_TRACE(EditingStyle) | 1482 DEFINE_TRACE(EditingStyle) |
| 1487 { | 1483 { |
| 1488 visitor->trace(m_mutableStyle); | 1484 visitor->trace(m_mutableStyle); |
| 1489 } | 1485 } |
| 1490 | 1486 |
| 1491 static void reconcileTextDecorationProperties(MutableStylePropertySet* style) | 1487 static void reconcileTextDecorationProperties(MutableStylePropertySet* style) |
| 1492 { | 1488 { |
| 1493 const CSSValue* textDecorationsInEffect = style->getPropertyCSSValue(CSSProp
ertyWebkitTextDecorationsInEffect); | 1489 CSSValue* textDecorationsInEffect = style->getPropertyCSSValue(CSSPropertyWe
bkitTextDecorationsInEffect); |
| 1494 const CSSValue* textDecoration = style->getPropertyCSSValue(textDecorationPr
opertyForEditing()); | 1490 CSSValue* textDecoration = style->getPropertyCSSValue(textDecorationProperty
ForEditing()); |
| 1495 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef
fect because that wouldn't make sense. | 1491 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef
fect because that wouldn't make sense. |
| 1496 DCHECK(!textDecorationsInEffect || !textDecoration); | 1492 DCHECK(!textDecorationsInEffect || !textDecoration); |
| 1497 if (textDecorationsInEffect) { | 1493 if (textDecorationsInEffect) { |
| 1498 style->setProperty(textDecorationPropertyForEditing(), textDecorationsIn
Effect->cssText()); | 1494 style->setProperty(textDecorationPropertyForEditing(), textDecorationsIn
Effect->cssText()); |
| 1499 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); | 1495 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); |
| 1500 textDecoration = textDecorationsInEffect; | 1496 textDecoration = textDecorationsInEffect; |
| 1501 } | 1497 } |
| 1502 | 1498 |
| 1503 // If text-decoration is set to "none", remove the property because we don't
want to add redundant "text-decoration: none". | 1499 // If text-decoration is set to "none", remove the property because we don't
want to add redundant "text-decoration: none". |
| 1504 if (textDecoration && !textDecoration->isValueList()) | 1500 if (textDecoration && !textDecoration->isValueList()) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1560 } | 1556 } |
| 1561 | 1557 |
| 1562 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); | 1558 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); |
| 1563 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { | 1559 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { |
| 1564 style->removeProperty(CSSPropertyFontStyle); | 1560 style->removeProperty(CSSPropertyFontStyle); |
| 1565 m_applyItalic = true; | 1561 m_applyItalic = true; |
| 1566 } | 1562 } |
| 1567 | 1563 |
| 1568 // Assuming reconcileTextDecorationProperties has been called, there should
not be -webkit-text-decorations-in-effect | 1564 // Assuming reconcileTextDecorationProperties has been called, there should
not be -webkit-text-decorations-in-effect |
| 1569 // Furthermore, text-decoration: none has been trimmed so that text-decorati
on property is always a CSSValueList. | 1565 // Furthermore, text-decoration: none has been trimmed so that text-decorati
on property is always a CSSValueList. |
| 1570 const CSSValue* textDecoration = style->getPropertyCSSValue(textDecorationPr
opertyForEditing()); | 1566 CSSValue* textDecoration = style->getPropertyCSSValue(textDecorationProperty
ForEditing()); |
| 1571 if (textDecoration && textDecoration->isValueList()) { | 1567 if (textDecoration && textDecoration->isValueList()) { |
| 1572 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::cr
eateIdentifier(CSSValueUnderline))); | 1568 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::cr
eateIdentifier(CSSValueUnderline))); |
| 1573 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::
createIdentifier(CSSValueLineThrough))); | 1569 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::
createIdentifier(CSSValueLineThrough))); |
| 1574 CSSValueList* newTextDecoration = toCSSValueList(textDecoration)->copy()
; | 1570 CSSValueList* newTextDecoration = toCSSValueList(textDecoration)->copy()
; |
| 1575 if (newTextDecoration->removeAll(underline)) | 1571 if (newTextDecoration->removeAll(underline)) |
| 1576 m_applyUnderline = true; | 1572 m_applyUnderline = true; |
| 1577 if (newTextDecoration->removeAll(lineThrough)) | 1573 if (newTextDecoration->removeAll(lineThrough)) |
| 1578 m_applyLineThrough = true; | 1574 m_applyLineThrough = true; |
| 1579 | 1575 |
| 1580 // If trimTextDecorations, delete underline and line-through | 1576 // If trimTextDecorations, delete underline and line-through |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1596 if (style->getPropertyCSSValue(CSSPropertyColor)) { | 1592 if (style->getPropertyCSSValue(CSSPropertyColor)) { |
| 1597 m_applyFontColor = getFontColor(style).serialized(); | 1593 m_applyFontColor = getFontColor(style).serialized(); |
| 1598 style->removeProperty(CSSPropertyColor); | 1594 style->removeProperty(CSSPropertyColor); |
| 1599 } | 1595 } |
| 1600 | 1596 |
| 1601 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily); | 1597 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily); |
| 1602 // Remove double quotes for Outlook 2007 compatibility. See https://bugs.web
kit.org/show_bug.cgi?id=79448 | 1598 // Remove double quotes for Outlook 2007 compatibility. See https://bugs.web
kit.org/show_bug.cgi?id=79448 |
| 1603 m_applyFontFace.replace('"', ""); | 1599 m_applyFontFace.replace('"', ""); |
| 1604 style->removeProperty(CSSPropertyFontFamily); | 1600 style->removeProperty(CSSPropertyFontFamily); |
| 1605 | 1601 |
| 1606 if (const CSSValue* fontSize = style->getPropertyCSSValue(CSSPropertyFontSiz
e)) { | 1602 if (CSSValue* fontSize = style->getPropertyCSSValue(CSSPropertyFontSize)) { |
| 1607 if (!fontSize->isPrimitiveValue()) { | 1603 if (!fontSize->isPrimitiveValue()) { |
| 1608 style->removeProperty(CSSPropertyFontSize); // Can't make sense of t
he number. Put no font size. | 1604 style->removeProperty(CSSPropertyFontSize); // Can't make sense of t
he number. Put no font size. |
| 1609 } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toC
SSPrimitiveValue(fontSize), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelValuesM
atch)) { | 1605 } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toC
SSPrimitiveValue(fontSize), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelValuesM
atch)) { |
| 1610 m_applyFontSize = String::number(legacyFontSize); | 1606 m_applyFontSize = String::number(legacyFontSize); |
| 1611 style->removeProperty(CSSPropertyFontSize); | 1607 style->removeProperty(CSSPropertyFontSize); |
| 1612 } | 1608 } |
| 1613 } | 1609 } |
| 1614 } | 1610 } |
| 1615 | 1611 |
| 1616 static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr
opertyID, const CSSValue* refTextDecoration) | 1612 static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr
opertID, CSSValue* refTextDecoration) |
| 1617 { | 1613 { |
| 1618 const CSSValue* textDecoration = style->getPropertyCSSValue(propertyID); | 1614 CSSValue* textDecoration = style->getPropertyCSSValue(propertID); |
| 1619 if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration
|| !refTextDecoration->isValueList()) | 1615 if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration
|| !refTextDecoration->isValueList()) |
| 1620 return; | 1616 return; |
| 1621 | 1617 |
| 1622 CSSValueList* newTextDecoration = toCSSValueList(textDecoration)->copy(); | 1618 CSSValueList* newTextDecoration = toCSSValueList(textDecoration)->copy(); |
| 1623 const CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecora
tion); | 1619 CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration); |
| 1624 | 1620 |
| 1625 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++) | 1621 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++) |
| 1626 newTextDecoration->removeAll(*valuesInRefTextDecoration->item(i)); | 1622 newTextDecoration->removeAll(*valuesInRefTextDecoration->item(i)); |
| 1627 | 1623 |
| 1628 setTextDecorationProperty(style, newTextDecoration, propertyID); | 1624 setTextDecorationProperty(style, newTextDecoration, propertID); |
| 1629 } | 1625 } |
| 1630 | 1626 |
| 1631 static bool fontWeightIsBold(const CSSValue* fontWeight) | 1627 static bool fontWeightIsBold(CSSValue* fontWeight) |
| 1632 { | 1628 { |
| 1633 if (!fontWeight->isPrimitiveValue()) | 1629 if (!fontWeight->isPrimitiveValue()) |
| 1634 return false; | 1630 return false; |
| 1635 | 1631 |
| 1636 // Because b tag can only bold text, there are only two states in plain html
: bold and not bold. | 1632 // Because b tag can only bold text, there are only two states in plain html
: bold and not bold. |
| 1637 // Collapse all other values to either one of these two states for editing p
urposes. | 1633 // Collapse all other values to either one of these two states for editing p
urposes. |
| 1638 switch (toCSSPrimitiveValue(fontWeight)->getValueID()) { | 1634 switch (toCSSPrimitiveValue(fontWeight)->getValueID()) { |
| 1639 case CSSValue100: | 1635 case CSSValue100: |
| 1640 case CSSValue200: | 1636 case CSSValue200: |
| 1641 case CSSValue300: | 1637 case CSSValue300: |
| 1642 case CSSValue400: | 1638 case CSSValue400: |
| 1643 case CSSValue500: | 1639 case CSSValue500: |
| 1644 case CSSValueNormal: | 1640 case CSSValueNormal: |
| 1645 return false; | 1641 return false; |
| 1646 case CSSValueBold: | 1642 case CSSValueBold: |
| 1647 case CSSValue600: | 1643 case CSSValue600: |
| 1648 case CSSValue700: | 1644 case CSSValue700: |
| 1649 case CSSValue800: | 1645 case CSSValue800: |
| 1650 case CSSValue900: | 1646 case CSSValue900: |
| 1651 return true; | 1647 return true; |
| 1652 default: | 1648 default: |
| 1653 break; | 1649 break; |
| 1654 } | 1650 } |
| 1655 | 1651 |
| 1656 ASSERT_NOT_REACHED(); // For CSSValueBolder and CSSValueLighter | 1652 ASSERT_NOT_REACHED(); // For CSSValueBolder and CSSValueLighter |
| 1657 return false; | 1653 return false; |
| 1658 } | 1654 } |
| 1659 | 1655 |
| 1660 static bool fontWeightNeedsResolving(const CSSValue* fontWeight) | 1656 static bool fontWeightNeedsResolving(CSSValue* fontWeight) |
| 1661 { | 1657 { |
| 1662 if (!fontWeight->isPrimitiveValue()) | 1658 if (!fontWeight->isPrimitiveValue()) |
| 1663 return true; | 1659 return true; |
| 1664 | 1660 |
| 1665 const CSSValueID value = toCSSPrimitiveValue(fontWeight)->getValueID(); | 1661 CSSValueID value = toCSSPrimitiveValue(fontWeight)->getValueID(); |
| 1666 return value == CSSValueLighter || value == CSSValueBolder; | 1662 return value == CSSValueLighter || value == CSSValueBolder; |
| 1667 } | 1663 } |
| 1668 | 1664 |
| 1669 MutableStylePropertySet* getPropertiesNotIn(StylePropertySet* styleWithRedundant
Properties, CSSStyleDeclaration* baseStyle) | 1665 MutableStylePropertySet* getPropertiesNotIn(StylePropertySet* styleWithRedundant
Properties, CSSStyleDeclaration* baseStyle) |
| 1670 { | 1666 { |
| 1671 DCHECK(styleWithRedundantProperties); | 1667 DCHECK(styleWithRedundantProperties); |
| 1672 DCHECK(baseStyle); | 1668 DCHECK(baseStyle); |
| 1673 MutableStylePropertySet* result = styleWithRedundantProperties->mutableCopy(
); | 1669 MutableStylePropertySet* result = styleWithRedundantProperties->mutableCopy(
); |
| 1674 | 1670 |
| 1675 result->removeEquivalentProperties(baseStyle); | 1671 result->removeEquivalentProperties(baseStyle); |
| 1676 | 1672 |
| 1677 const CSSValue* baseTextDecorationsInEffect = baseStyle->getPropertyCSSValue
Internal(CSSPropertyWebkitTextDecorationsInEffect); | 1673 CSSValue* baseTextDecorationsInEffect = baseStyle->getPropertyCSSValueIntern
al(CSSPropertyWebkitTextDecorationsInEffect); |
| 1678 diffTextDecorations(result, textDecorationPropertyForEditing(), baseTextDeco
rationsInEffect); | 1674 diffTextDecorations(result, textDecorationPropertyForEditing(), baseTextDeco
rationsInEffect); |
| 1679 diffTextDecorations(result, CSSPropertyWebkitTextDecorationsInEffect, baseTe
xtDecorationsInEffect); | 1675 diffTextDecorations(result, CSSPropertyWebkitTextDecorationsInEffect, baseTe
xtDecorationsInEffect); |
| 1680 | 1676 |
| 1681 if (const CSSValue* baseFontWeight = baseStyle->getPropertyCSSValueInternal(
CSSPropertyFontWeight)) { | 1677 if (CSSValue* baseFontWeight = baseStyle->getPropertyCSSValueInternal(CSSPro
pertyFontWeight)) { |
| 1682 if (CSSValue* fontWeight = result->getPropertyCSSValue(CSSPropertyFontWe
ight)) { | 1678 if (CSSValue* fontWeight = result->getPropertyCSSValue(CSSPropertyFontWe
ight)) { |
| 1683 if (!fontWeightNeedsResolving(fontWeight) && !fontWeightNeedsResolvi
ng(baseFontWeight) | 1679 if (!fontWeightNeedsResolving(fontWeight) && !fontWeightNeedsResolvi
ng(baseFontWeight) |
| 1684 && (fontWeightIsBold(fontWeight) == fontWeightIsBold(baseFontWei
ght))) | 1680 && (fontWeightIsBold(fontWeight) == fontWeightIsBold(baseFontWei
ght))) |
| 1685 result->removeProperty(CSSPropertyFontWeight); | 1681 result->removeProperty(CSSPropertyFontWeight); |
| 1686 } | 1682 } |
| 1687 } | 1683 } |
| 1688 | 1684 |
| 1689 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getFontColor
(result) == getFontColor(baseStyle)) | 1685 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getFontColor
(result) == getFontColor(baseStyle)) |
| 1690 result->removeProperty(CSSPropertyColor); | 1686 result->removeProperty(CSSPropertyColor); |
| 1691 | 1687 |
| 1692 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) | 1688 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) |
| 1693 && textAlignResolvingStartAndEnd(result) == textAlignResolvingStartAndEn
d(baseStyle)) | 1689 && textAlignResolvingStartAndEnd(result) == textAlignResolvingStartAndEn
d(baseStyle)) |
| 1694 result->removeProperty(CSSPropertyTextAlign); | 1690 result->removeProperty(CSSPropertyTextAlign); |
| 1695 | 1691 |
| 1696 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge
tBackgroundColor(result) == getBackgroundColor(baseStyle)) | 1692 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge
tBackgroundColor(result) == getBackgroundColor(baseStyle)) |
| 1697 result->removeProperty(CSSPropertyBackgroundColor); | 1693 result->removeProperty(CSSPropertyBackgroundColor); |
| 1698 | 1694 |
| 1699 return result; | 1695 return result; |
| 1700 } | 1696 } |
| 1701 | 1697 |
| 1702 CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) | 1698 CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) |
| 1703 { | 1699 { |
| 1704 if (!style) | 1700 if (!style) |
| 1705 return CSSValueInvalid; | 1701 return CSSValueInvalid; |
| 1706 const CSSValue* value = style->getPropertyCSSValue(propertyID); | 1702 CSSValue* value = style->getPropertyCSSValue(propertyID); |
| 1707 if (!value || !value->isPrimitiveValue()) | 1703 if (!value || !value->isPrimitiveValue()) |
| 1708 return CSSValueInvalid; | 1704 return CSSValueInvalid; |
| 1709 return toCSSPrimitiveValue(value)->getValueID(); | 1705 return toCSSPrimitiveValue(value)->getValueID(); |
| 1710 } | 1706 } |
| 1711 | 1707 |
| 1712 CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID property
ID) | 1708 CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID property
ID) |
| 1713 { | 1709 { |
| 1714 if (!style) | 1710 if (!style) |
| 1715 return CSSValueInvalid; | 1711 return CSSValueInvalid; |
| 1716 const CSSValue* value = style->getPropertyCSSValueInternal(propertyID); | 1712 CSSValue* value = style->getPropertyCSSValueInternal(propertyID); |
| 1717 if (!value || !value->isPrimitiveValue()) | 1713 if (!value || !value->isPrimitiveValue()) |
| 1718 return CSSValueInvalid; | 1714 return CSSValueInvalid; |
| 1719 return toCSSPrimitiveValue(value)->getValueID(); | 1715 return toCSSPrimitiveValue(value)->getValueID(); |
| 1720 } | 1716 } |
| 1721 | 1717 |
| 1722 int legacyFontSizeFromCSSValue(Document* document, const CSSPrimitiveValue* valu
e, bool isMonospaceFont, LegacyFontSizeMode mode) | 1718 int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo
l isMonospaceFont, LegacyFontSizeMode mode) |
| 1723 { | 1719 { |
| 1724 CSSPrimitiveValue::LengthUnitType lengthType; | 1720 CSSPrimitiveValue::LengthUnitType lengthType; |
| 1725 if (CSSPrimitiveValue::unitTypeToLengthUnitType(value->typeWithCalcResolved(
), lengthType) | 1721 if (CSSPrimitiveValue::unitTypeToLengthUnitType(value->typeWithCalcResolved(
), lengthType) |
| 1726 && lengthType == CSSPrimitiveValue::UnitTypePixels) { | 1722 && lengthType == CSSPrimitiveValue::UnitTypePixels) { |
| 1727 double conversion = CSSPrimitiveValue::conversionToCanonicalUnitsScaleFa
ctor(value->typeWithCalcResolved()); | 1723 double conversion = CSSPrimitiveValue::conversionToCanonicalUnitsScaleFa
ctor(value->typeWithCalcResolved()); |
| 1728 int pixelFontSize = clampTo<int>(value->getDoubleValue() * conversion); | 1724 int pixelFontSize = clampTo<int>(value->getDoubleValue() * conversion); |
| 1729 int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSize, i
sMonospaceFont); | 1725 int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSize, i
sMonospaceFont); |
| 1730 // Use legacy font size only if pixel value matches exactly to that of l
egacy font size. | 1726 // Use legacy font size only if pixel value matches exactly to that of l
egacy font size. |
| 1731 if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(docu
ment, legacyFontSize, isMonospaceFont) == pixelFontSize) | 1727 if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(docu
ment, legacyFontSize, isMonospaceFont) == pixelFontSize) |
| 1732 return legacyFontSize; | 1728 return legacyFontSize; |
| 1733 | 1729 |
| 1734 return 0; | 1730 return 0; |
| 1735 } | 1731 } |
| 1736 | 1732 |
| 1737 if (CSSValueXSmall <= value->getValueID() && value->getValueID() <= CSSValue
WebkitXxxLarge) | 1733 if (CSSValueXSmall <= value->getValueID() && value->getValueID() <= CSSValue
WebkitXxxLarge) |
| 1738 return value->getValueID() - CSSValueXSmall + 1; | 1734 return value->getValueID() - CSSValueXSmall + 1; |
| 1739 | 1735 |
| 1740 return 0; | 1736 return 0; |
| 1741 } | 1737 } |
| 1742 | 1738 |
| 1743 bool isTransparentColorValue(const CSSValue* cssValue) | 1739 bool isTransparentColorValue(CSSValue* cssValue) |
| 1744 { | 1740 { |
| 1745 if (!cssValue) | 1741 if (!cssValue) |
| 1746 return true; | 1742 return true; |
| 1747 if (cssValue->isColorValue()) | 1743 if (cssValue->isColorValue()) |
| 1748 return !toCSSColorValue(cssValue)->value().alpha(); | 1744 return !toCSSColorValue(cssValue)->value().alpha(); |
| 1749 if (!cssValue->isPrimitiveValue()) | 1745 if (!cssValue->isPrimitiveValue()) |
| 1750 return false; | 1746 return false; |
| 1751 const CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue); | 1747 CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue); |
| 1752 return value->getValueID() == CSSValueTransparent; | 1748 return value->getValueID() == CSSValueTransparent; |
| 1753 } | 1749 } |
| 1754 | 1750 |
| 1755 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style) | 1751 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style) |
| 1756 { | 1752 { |
| 1757 const CSSValue* cssValue = style->getPropertyCSSValueInternal(CSSPropertyBac
kgroundColor); | 1753 CSSValue* cssValue = style->getPropertyCSSValueInternal(CSSPropertyBackgroun
dColor); |
| 1758 return isTransparentColorValue(cssValue); | 1754 return isTransparentColorValue(cssValue); |
| 1759 } | 1755 } |
| 1760 | 1756 |
| 1761 bool hasTransparentBackgroundColor(StylePropertySet* style) | 1757 bool hasTransparentBackgroundColor(StylePropertySet* style) |
| 1762 { | 1758 { |
| 1763 const CSSValue* cssValue = style->getPropertyCSSValue(CSSPropertyBackgroundC
olor); | 1759 CSSValue* cssValue = style->getPropertyCSSValue(CSSPropertyBackgroundColor); |
| 1764 return isTransparentColorValue(cssValue); | 1760 return isTransparentColorValue(cssValue); |
| 1765 } | 1761 } |
| 1766 | 1762 |
| 1767 const CSSValue* backgroundColorValueInEffect(Node* node) | 1763 CSSValue* backgroundColorValueInEffect(Node* node) |
| 1768 { | 1764 { |
| 1769 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1765 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
| 1770 CSSComputedStyleDeclaration* ancestorStyle = CSSComputedStyleDeclaration
::create(ancestor); | 1766 CSSComputedStyleDeclaration* ancestorStyle = CSSComputedStyleDeclaration
::create(ancestor); |
| 1771 if (!hasTransparentBackgroundColor(ancestorStyle)) | 1767 if (!hasTransparentBackgroundColor(ancestorStyle)) |
| 1772 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); | 1768 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); |
| 1773 } | 1769 } |
| 1774 return nullptr; | 1770 return nullptr; |
| 1775 } | 1771 } |
| 1776 | 1772 |
| 1777 } // namespace blink | 1773 } // namespace blink |
| OLD | NEW |