| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 136 |
| 137 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> editingStyleFromComputedS
tyle(PassRefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style, EditingPropertie
sType type = OnlyInheritableEditingProperties) | 137 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> editingStyleFromComputedS
tyle(PassRefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style, EditingPropertie
sType type = OnlyInheritableEditingProperties) |
| 138 { | 138 { |
| 139 if (!style) | 139 if (!style) |
| 140 return MutableStylePropertySet::create(); | 140 return MutableStylePropertySet::create(); |
| 141 return copyEditingProperties(style.get(), type); | 141 return copyEditingProperties(style.get(), type); |
| 142 } | 142 } |
| 143 | 143 |
| 144 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleP
ropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle); | 144 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleP
ropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle); |
| 145 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV
aluesMatch }; | 145 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV
aluesMatch }; |
| 146 static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool should
UseFixedFontDefaultSize, LegacyFontSizeMode); | 146 static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, FixedPitchF
ontType, LegacyFontSizeMode); |
| 147 static bool isTransparentColorValue(CSSValue*); | 147 static bool isTransparentColorValue(CSSValue*); |
| 148 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); | 148 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); |
| 149 static bool hasTransparentBackgroundColor(StylePropertySet*); | 149 static bool hasTransparentBackgroundColor(StylePropertySet*); |
| 150 static PassRefPtrWillBeRawPtr<CSSValue> backgroundColorInEffect(Node*); | 150 static PassRefPtrWillBeRawPtr<CSSValue> backgroundColorInEffect(Node*); |
| 151 | 151 |
| 152 class HTMLElementEquivalent : public NoBaseWillBeGarbageCollected<HTMLElementEqu
ivalent> { | 152 class HTMLElementEquivalent : public NoBaseWillBeGarbageCollected<HTMLElementEqu
ivalent> { |
| 153 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | 153 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
| 154 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent); | 154 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent); |
| 155 public: | 155 public: |
| 156 static PassOwnPtrWillBeRawPtr<HTMLElementEquivalent> create(CSSPropertyID pr
opertyID, CSSValueID primitiveValue, const QualifiedName& tagName) | 156 static PassOwnPtrWillBeRawPtr<HTMLElementEquivalent> create(CSSPropertyID pr
opertyID, CSSValueID primitiveValue, const QualifiedName& tagName) |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 return nullptr; | 335 return nullptr; |
| 336 CSSValueID size; | 336 CSSValueID size; |
| 337 if (!HTMLFontElement::cssValueFromFontSizeNumber(value, size)) | 337 if (!HTMLFontElement::cssValueFromFontSizeNumber(value, size)) |
| 338 return nullptr; | 338 return nullptr; |
| 339 return CSSPrimitiveValue::createIdentifier(size); | 339 return CSSPrimitiveValue::createIdentifier(size); |
| 340 } | 340 } |
| 341 | 341 |
| 342 float EditingStyle::NoFontDelta = 0.0f; | 342 float EditingStyle::NoFontDelta = 0.0f; |
| 343 | 343 |
| 344 EditingStyle::EditingStyle() | 344 EditingStyle::EditingStyle() |
| 345 : m_shouldUseFixedDefaultFontSize(false) | 345 : m_fixedPitchFont(NonFixedPitchFont) |
| 346 , m_fontSizeDelta(NoFontDelta) | 346 , m_fontSizeDelta(NoFontDelta) |
| 347 { | 347 { |
| 348 } | 348 } |
| 349 | 349 |
| 350 EditingStyle::EditingStyle(Node* node, PropertiesToInclude propertiesToInclude) | 350 EditingStyle::EditingStyle(Node* node, PropertiesToInclude propertiesToInclude) |
| 351 : m_shouldUseFixedDefaultFontSize(false) | 351 : m_fixedPitchFont(NonFixedPitchFont) |
| 352 , m_fontSizeDelta(NoFontDelta) | 352 , m_fontSizeDelta(NoFontDelta) |
| 353 { | 353 { |
| 354 init(node, propertiesToInclude); | 354 init(node, propertiesToInclude); |
| 355 } | 355 } |
| 356 | 356 |
| 357 EditingStyle::EditingStyle(const Position& position, PropertiesToInclude propert
iesToInclude) | 357 EditingStyle::EditingStyle(const Position& position, PropertiesToInclude propert
iesToInclude) |
| 358 : m_shouldUseFixedDefaultFontSize(false) | 358 : m_fixedPitchFont(NonFixedPitchFont) |
| 359 , m_fontSizeDelta(NoFontDelta) | 359 , m_fontSizeDelta(NoFontDelta) |
| 360 { | 360 { |
| 361 init(position.deprecatedNode(), propertiesToInclude); | 361 init(position.deprecatedNode(), propertiesToInclude); |
| 362 } | 362 } |
| 363 | 363 |
| 364 EditingStyle::EditingStyle(const StylePropertySet* style) | 364 EditingStyle::EditingStyle(const StylePropertySet* style) |
| 365 : m_mutableStyle(style ? style->mutableCopy() : nullptr) | 365 : m_mutableStyle(style ? style->mutableCopy() : nullptr) |
| 366 , m_shouldUseFixedDefaultFontSize(false) | 366 , m_fixedPitchFont(NonFixedPitchFont) |
| 367 , m_fontSizeDelta(NoFontDelta) | 367 , m_fontSizeDelta(NoFontDelta) |
| 368 { | 368 { |
| 369 extractFontSizeDelta(); | 369 extractFontSizeDelta(); |
| 370 } | 370 } |
| 371 | 371 |
| 372 EditingStyle::EditingStyle(CSSPropertyID propertyID, const String& value) | 372 EditingStyle::EditingStyle(CSSPropertyID propertyID, const String& value) |
| 373 : m_mutableStyle(nullptr) | 373 : m_mutableStyle(nullptr) |
| 374 , m_shouldUseFixedDefaultFontSize(false) | 374 , m_fixedPitchFont(NonFixedPitchFont) |
| 375 , m_fontSizeDelta(NoFontDelta) | 375 , m_fontSizeDelta(NoFontDelta) |
| 376 { | 376 { |
| 377 setProperty(propertyID, value); | 377 setProperty(propertyID, value); |
| 378 } | 378 } |
| 379 | 379 |
| 380 EditingStyle::~EditingStyle() | 380 EditingStyle::~EditingStyle() |
| 381 { | 381 { |
| 382 } | 382 } |
| 383 | 383 |
| 384 static RGBA32 cssValueToRGBA(CSSValue* colorValue) | 384 static RGBA32 cssValueToRGBA(CSSValue* colorValue) |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 if (RefPtrWillBeRawPtr<CSSValue> value = computedStyleAtPosition->getPro
pertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect)) | 464 if (RefPtrWillBeRawPtr<CSSValue> value = computedStyleAtPosition->getPro
pertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect)) |
| 465 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex
t()); | 465 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex
t()); |
| 466 } | 466 } |
| 467 | 467 |
| 468 if (node && node->computedStyle()) { | 468 if (node && node->computedStyle()) { |
| 469 RenderStyle* renderStyle = node->computedStyle(); | 469 RenderStyle* renderStyle = node->computedStyle(); |
| 470 removeTextFillAndStrokeColorsIfNeeded(renderStyle); | 470 removeTextFillAndStrokeColorsIfNeeded(renderStyle); |
| 471 replaceFontSizeByKeywordIfPossible(renderStyle, computedStyleAtPosition.
get()); | 471 replaceFontSizeByKeywordIfPossible(renderStyle, computedStyleAtPosition.
get()); |
| 472 } | 472 } |
| 473 | 473 |
| 474 m_shouldUseFixedDefaultFontSize = computedStyleAtPosition->useFixedFontDefau
ltSize(); | 474 m_fixedPitchFont = computedStyleAtPosition->fixedPitchFont(); |
| 475 extractFontSizeDelta(); | 475 extractFontSizeDelta(); |
| 476 } | 476 } |
| 477 | 477 |
| 478 void EditingStyle::removeTextFillAndStrokeColorsIfNeeded(RenderStyle* renderStyl
e) | 478 void EditingStyle::removeTextFillAndStrokeColorsIfNeeded(RenderStyle* renderStyl
e) |
| 479 { | 479 { |
| 480 // If a node's text fill color is currentColor, then its children use | 480 // If a node's text fill color is currentColor, then its children use |
| 481 // their font-color as their text fill color (they don't | 481 // their font-color as their text fill color (they don't |
| 482 // inherit it). Likewise for stroke color. | 482 // inherit it). Likewise for stroke color. |
| 483 if (renderStyle->textFillColor().isCurrentColor()) | 483 if (renderStyle->textFillColor().isCurrentColor()) |
| 484 m_mutableStyle->removeProperty(CSSPropertyWebkitTextFillColor); | 484 m_mutableStyle->removeProperty(CSSPropertyWebkitTextFillColor); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 return; | 567 return; |
| 568 if (!m_mutableStyle) | 568 if (!m_mutableStyle) |
| 569 m_mutableStyle = MutableStylePropertySet::create(); | 569 m_mutableStyle = MutableStylePropertySet::create(); |
| 570 m_mutableStyle->mergeAndOverrideOnConflict(style); | 570 m_mutableStyle->mergeAndOverrideOnConflict(style); |
| 571 extractFontSizeDelta(); | 571 extractFontSizeDelta(); |
| 572 } | 572 } |
| 573 | 573 |
| 574 void EditingStyle::clear() | 574 void EditingStyle::clear() |
| 575 { | 575 { |
| 576 m_mutableStyle.clear(); | 576 m_mutableStyle.clear(); |
| 577 m_shouldUseFixedDefaultFontSize = false; | 577 m_fixedPitchFont = NonFixedPitchFont; |
| 578 m_fontSizeDelta = NoFontDelta; | 578 m_fontSizeDelta = NoFontDelta; |
| 579 } | 579 } |
| 580 | 580 |
| 581 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::copy() const | 581 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::copy() const |
| 582 { | 582 { |
| 583 RefPtrWillBeRawPtr<EditingStyle> copy = EditingStyle::create(); | 583 RefPtrWillBeRawPtr<EditingStyle> copy = EditingStyle::create(); |
| 584 if (m_mutableStyle) | 584 if (m_mutableStyle) |
| 585 copy->m_mutableStyle = m_mutableStyle->mutableCopy(); | 585 copy->m_mutableStyle = m_mutableStyle->mutableCopy(); |
| 586 copy->m_shouldUseFixedDefaultFontSize = m_shouldUseFixedDefaultFontSize; | 586 copy->m_fixedPitchFont = m_fixedPitchFont; |
| 587 copy->m_fontSizeDelta = m_fontSizeDelta; | 587 copy->m_fontSizeDelta = m_fontSizeDelta; |
| 588 return copy; | 588 return copy; |
| 589 } | 589 } |
| 590 | 590 |
| 591 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::extractAndRemoveBlockProperti
es() | 591 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::extractAndRemoveBlockProperti
es() |
| 592 { | 592 { |
| 593 RefPtrWillBeRawPtr<EditingStyle> blockProperties = EditingStyle::create(); | 593 RefPtrWillBeRawPtr<EditingStyle> blockProperties = EditingStyle::create(); |
| 594 if (!m_mutableStyle) | 594 if (!m_mutableStyle) |
| 595 return blockProperties; | 595 return blockProperties; |
| 596 | 596 |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 const bool propertyIsImportant = true; | 1239 const bool propertyIsImportant = true; |
| 1240 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm
portant); | 1240 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm
portant); |
| 1241 } | 1241 } |
| 1242 | 1242 |
| 1243 int EditingStyle::legacyFontSize(Document* document) const | 1243 int EditingStyle::legacyFontSize(Document* document) const |
| 1244 { | 1244 { |
| 1245 RefPtrWillBeRawPtr<CSSValue> cssValue = m_mutableStyle->getPropertyCSSValue(
CSSPropertyFontSize); | 1245 RefPtrWillBeRawPtr<CSSValue> cssValue = m_mutableStyle->getPropertyCSSValue(
CSSPropertyFontSize); |
| 1246 if (!cssValue || !cssValue->isPrimitiveValue()) | 1246 if (!cssValue || !cssValue->isPrimitiveValue()) |
| 1247 return 0; | 1247 return 0; |
| 1248 return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue.get
()), | 1248 return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue.get
()), |
| 1249 m_shouldUseFixedDefaultFontSize, AlwaysUseLegacyFontSize); | 1249 m_fixedPitchFont, AlwaysUseLegacyFontSize); |
| 1250 } | 1250 } |
| 1251 | 1251 |
| 1252 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::styleAtSelectionStart(const V
isibleSelection& selection, bool shouldUseBackgroundColorInEffect) | 1252 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::styleAtSelectionStart(const V
isibleSelection& selection, bool shouldUseBackgroundColorInEffect) |
| 1253 { | 1253 { |
| 1254 if (selection.isNone()) | 1254 if (selection.isNone()) |
| 1255 return nullptr; | 1255 return nullptr; |
| 1256 | 1256 |
| 1257 Position position = adjustedSelectionStartForStyleComputation(selection); | 1257 Position position = adjustedSelectionStartForStyleComputation(selection); |
| 1258 | 1258 |
| 1259 // If the pos is at the end of a text node, then this node is not fully sele
cted. | 1259 // If the pos is at the end of a text node, then this node is not fully sele
cted. |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1402 Document* document = position.document(); | 1402 Document* document = position.document(); |
| 1403 if (!style || !style->style() || !document || !document->frame()) | 1403 if (!style || !style->style() || !document || !document->frame()) |
| 1404 return; | 1404 return; |
| 1405 | 1405 |
| 1406 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyle = position.com
putedStyle(); | 1406 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyle = position.com
putedStyle(); |
| 1407 // FIXME: take care of background-color in effect | 1407 // FIXME: take care of background-color in effect |
| 1408 RefPtrWillBeRawPtr<MutableStylePropertySet> mutableStyle = getPropertiesNotI
n(style->style(), computedStyle.get()); | 1408 RefPtrWillBeRawPtr<MutableStylePropertySet> mutableStyle = getPropertiesNotI
n(style->style(), computedStyle.get()); |
| 1409 | 1409 |
| 1410 reconcileTextDecorationProperties(mutableStyle.get()); | 1410 reconcileTextDecorationProperties(mutableStyle.get()); |
| 1411 if (!document->frame()->editor().shouldStyleWithCSS()) | 1411 if (!document->frame()->editor().shouldStyleWithCSS()) |
| 1412 extractTextStyles(document, mutableStyle.get(), computedStyle->useFixedF
ontDefaultSize()); | 1412 extractTextStyles(document, mutableStyle.get(), computedStyle->fixedPitc
hFont()); |
| 1413 | 1413 |
| 1414 // Changing the whitespace style in a tab span would collapse the tab into a
space. | 1414 // Changing the whitespace style in a tab span would collapse the tab into a
space. |
| 1415 if (isTabSpanTextNode(position.deprecatedNode()) || isTabSpanNode((position.
deprecatedNode()))) | 1415 if (isTabSpanTextNode(position.deprecatedNode()) || isTabSpanNode((position.
deprecatedNode()))) |
| 1416 mutableStyle->removeProperty(CSSPropertyWhiteSpace); | 1416 mutableStyle->removeProperty(CSSPropertyWhiteSpace); |
| 1417 | 1417 |
| 1418 // If unicode-bidi is present in mutableStyle and direction is not, then add
direction to mutableStyle. | 1418 // If unicode-bidi is present in mutableStyle and direction is not, then add
direction to mutableStyle. |
| 1419 // FIXME: Shouldn't this be done in getPropertiesNotIn? | 1419 // FIXME: Shouldn't this be done in getPropertiesNotIn? |
| 1420 if (mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi) && !style->sty
le()->getPropertyCSSValue(CSSPropertyDirection)) | 1420 if (mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi) && !style->sty
le()->getPropertyCSSValue(CSSPropertyDirection)) |
| 1421 mutableStyle->setProperty(CSSPropertyDirection, style->style()->getPrope
rtyValue(CSSPropertyDirection)); | 1421 mutableStyle->setProperty(CSSPropertyDirection, style->style()->getPrope
rtyValue(CSSPropertyDirection)); |
| 1422 | 1422 |
| 1423 // Save the result for later | 1423 // Save the result for later |
| 1424 m_cssStyle = mutableStyle->asText().stripWhiteSpace(); | 1424 m_cssStyle = mutableStyle->asText().stripWhiteSpace(); |
| 1425 } | 1425 } |
| 1426 | 1426 |
| 1427 static void setTextDecorationProperty(MutableStylePropertySet* style, const CSSV
alueList* newTextDecoration, CSSPropertyID propertyID) | 1427 static void setTextDecorationProperty(MutableStylePropertySet* style, const CSSV
alueList* newTextDecoration, CSSPropertyID propertyID) |
| 1428 { | 1428 { |
| 1429 if (newTextDecoration->length()) | 1429 if (newTextDecoration->length()) |
| 1430 style->setProperty(propertyID, newTextDecoration->cssText(), style->prop
ertyIsImportant(propertyID)); | 1430 style->setProperty(propertyID, newTextDecoration->cssText(), style->prop
ertyIsImportant(propertyID)); |
| 1431 else { | 1431 else { |
| 1432 // text-decoration: none is redundant since it does not remove any text
decorations. | 1432 // text-decoration: none is redundant since it does not remove any text
decorations. |
| 1433 style->removeProperty(propertyID); | 1433 style->removeProperty(propertyID); |
| 1434 } | 1434 } |
| 1435 } | 1435 } |
| 1436 | 1436 |
| 1437 void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet*
style, bool shouldUseFixedFontDefaultSize) | 1437 void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet*
style, FixedPitchFontType fixedPitchFontType) |
| 1438 { | 1438 { |
| 1439 ASSERT(style); | 1439 ASSERT(style); |
| 1440 | 1440 |
| 1441 if (getIdentifierValue(style, CSSPropertyFontWeight) == CSSValueBold) { | 1441 if (getIdentifierValue(style, CSSPropertyFontWeight) == CSSValueBold) { |
| 1442 style->removeProperty(CSSPropertyFontWeight); | 1442 style->removeProperty(CSSPropertyFontWeight); |
| 1443 m_applyBold = true; | 1443 m_applyBold = true; |
| 1444 } | 1444 } |
| 1445 | 1445 |
| 1446 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); | 1446 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); |
| 1447 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { | 1447 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1486 m_applyFontColor = Color(getRGBAFontColor(style)).serialized(); | 1486 m_applyFontColor = Color(getRGBAFontColor(style)).serialized(); |
| 1487 style->removeProperty(CSSPropertyColor); | 1487 style->removeProperty(CSSPropertyColor); |
| 1488 } | 1488 } |
| 1489 | 1489 |
| 1490 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily); | 1490 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily); |
| 1491 // Remove single quotes for Outlook 2007 compatibility. See https://bugs.web
kit.org/show_bug.cgi?id=79448 | 1491 // Remove single quotes for Outlook 2007 compatibility. See https://bugs.web
kit.org/show_bug.cgi?id=79448 |
| 1492 m_applyFontFace.replaceWithLiteral('\'', ""); | 1492 m_applyFontFace.replaceWithLiteral('\'', ""); |
| 1493 style->removeProperty(CSSPropertyFontFamily); | 1493 style->removeProperty(CSSPropertyFontFamily); |
| 1494 | 1494 |
| 1495 if (RefPtrWillBeRawPtr<CSSValue> fontSize = style->getPropertyCSSValue(CSSPr
opertyFontSize)) { | 1495 if (RefPtrWillBeRawPtr<CSSValue> fontSize = style->getPropertyCSSValue(CSSPr
opertyFontSize)) { |
| 1496 if (!fontSize->isPrimitiveValue()) | 1496 if (!fontSize->isPrimitiveValue()) { |
| 1497 style->removeProperty(CSSPropertyFontSize); // Can't make sense of t
he number. Put no font size. | 1497 style->removeProperty(CSSPropertyFontSize); // Can't make sense of t
he number. Put no font size. |
| 1498 else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toCSS
PrimitiveValue(fontSize.get()), | 1498 } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toC
SSPrimitiveValue(fontSize.get()), fixedPitchFontType, UseLegacyFontSizeOnlyIfPix
elValuesMatch)) { |
| 1499 shouldUseFixedFontDefaultSize, UseLegacyFontSizeOnlyIfPixelValue
sMatch)) { | |
| 1500 m_applyFontSize = String::number(legacyFontSize); | 1499 m_applyFontSize = String::number(legacyFontSize); |
| 1501 style->removeProperty(CSSPropertyFontSize); | 1500 style->removeProperty(CSSPropertyFontSize); |
| 1502 } | 1501 } |
| 1503 } | 1502 } |
| 1504 } | 1503 } |
| 1505 | 1504 |
| 1506 static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr
opertID, CSSValue* refTextDecoration) | 1505 static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr
opertID, CSSValue* refTextDecoration) |
| 1507 { | 1506 { |
| 1508 RefPtrWillBeRawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(pro
pertID); | 1507 RefPtrWillBeRawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(pro
pertID); |
| 1509 if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration
|| !refTextDecoration->isValueList()) | 1508 if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration
|| !refTextDecoration->isValueList()) |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1606 if (!value || !value->isPrimitiveValue()) | 1605 if (!value || !value->isPrimitiveValue()) |
| 1607 return CSSValueInvalid; | 1606 return CSSValueInvalid; |
| 1608 return toCSSPrimitiveValue(value.get())->getValueID(); | 1607 return toCSSPrimitiveValue(value.get())->getValueID(); |
| 1609 } | 1608 } |
| 1610 | 1609 |
| 1611 static bool isCSSValueLength(CSSPrimitiveValue* value) | 1610 static bool isCSSValueLength(CSSPrimitiveValue* value) |
| 1612 { | 1611 { |
| 1613 return value->isFontIndependentLength(); | 1612 return value->isFontIndependentLength(); |
| 1614 } | 1613 } |
| 1615 | 1614 |
| 1616 int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo
l shouldUseFixedFontDefaultSize, LegacyFontSizeMode mode) | 1615 int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, Fix
edPitchFontType fixedPitchFontType, LegacyFontSizeMode mode) |
| 1617 { | 1616 { |
| 1618 if (isCSSValueLength(value)) { | 1617 if (isCSSValueLength(value)) { |
| 1619 int pixelFontSize = value->getIntValue(CSSPrimitiveValue::CSS_PX); | 1618 int pixelFontSize = value->getIntValue(CSSPrimitiveValue::CSS_PX); |
| 1620 int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSize, s
houldUseFixedFontDefaultSize); | 1619 int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSize, f
ixedPitchFontType); |
| 1621 // Use legacy font size only if pixel value matches exactly to that of l
egacy font size. | 1620 // Use legacy font size only if pixel value matches exactly to that of l
egacy font size. |
| 1622 int cssPrimitiveEquivalent = legacyFontSize - 1 + CSSValueXSmall; | 1621 CSSValueID cssPrimitiveEquivalent = static_cast<CSSValueID>(legacyFontSi
ze - 1 + CSSValueXSmall); |
| 1623 if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(docu
ment, cssPrimitiveEquivalent, shouldUseFixedFontDefaultSize) == pixelFontSize) | 1622 if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(docu
ment, cssPrimitiveEquivalent, fixedPitchFontType) == pixelFontSize) |
| 1624 return legacyFontSize; | 1623 return legacyFontSize; |
| 1625 | 1624 |
| 1626 return 0; | 1625 return 0; |
| 1627 } | 1626 } |
| 1628 | 1627 |
| 1629 if (CSSValueXSmall <= value->getValueID() && value->getValueID() <= CSSValue
WebkitXxxLarge) | 1628 if (CSSValueXSmall <= value->getValueID() && value->getValueID() <= CSSValue
WebkitXxxLarge) |
| 1630 return value->getValueID() - CSSValueXSmall + 1; | 1629 return value->getValueID() - CSSValueXSmall + 1; |
| 1631 | 1630 |
| 1632 return 0; | 1631 return 0; |
| 1633 } | 1632 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1660 { | 1659 { |
| 1661 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1660 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
| 1662 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); | 1661 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); |
| 1663 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1662 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
| 1664 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); | 1663 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); |
| 1665 } | 1664 } |
| 1666 return nullptr; | 1665 return nullptr; |
| 1667 } | 1666 } |
| 1668 | 1667 |
| 1669 } | 1668 } |
| OLD | NEW |