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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 return allEditingProperties().contains(static_cast<CSSPropertyID>(id)); | 120 return allEditingProperties().contains(static_cast<CSSPropertyID>(id)); |
121 } | 121 } |
122 | 122 |
123 static PassRefPtr<MutableStylePropertySet> editingStyleFromComputedStyle(PassRef
Ptr<CSSComputedStyleDeclaration> style, EditingPropertiesType type = OnlyInherit
ableEditingProperties) | 123 static PassRefPtr<MutableStylePropertySet> editingStyleFromComputedStyle(PassRef
Ptr<CSSComputedStyleDeclaration> style, EditingPropertiesType type = OnlyInherit
ableEditingProperties) |
124 { | 124 { |
125 if (!style) | 125 if (!style) |
126 return MutableStylePropertySet::create(); | 126 return MutableStylePropertySet::create(); |
127 return copyEditingProperties(style.get(), type); | 127 return copyEditingProperties(style.get(), type); |
128 } | 128 } |
129 | 129 |
130 static PassRefPtr<StylePropertySet> getPropertiesNotIn(StylePropertySet* styleWi
thRedundantProperties, CSSStyleDeclaration* baseStyle); | 130 static PassRefPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet*
styleWithRedundantProperties, CSSStyleDeclaration* baseStyle); |
131 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV
aluesMatch }; | 131 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV
aluesMatch }; |
132 static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool should
UseFixedFontDefaultSize, LegacyFontSizeMode); | 132 static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool should
UseFixedFontDefaultSize, LegacyFontSizeMode); |
133 static bool isTransparentColorValue(CSSValue*); | 133 static bool isTransparentColorValue(CSSValue*); |
134 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); | 134 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); |
135 static bool hasTransparentBackgroundColor(StylePropertySet*); | 135 static bool hasTransparentBackgroundColor(StylePropertySet*); |
136 static PassRefPtr<CSSValue> backgroundColorInEffect(Node*); | 136 static PassRefPtr<CSSValue> backgroundColorInEffect(Node*); |
137 | 137 |
138 class HTMLElementEquivalent { | 138 class HTMLElementEquivalent { |
139 WTF_MAKE_FAST_ALLOCATED; | 139 WTF_MAKE_FAST_ALLOCATED; |
140 public: | 140 public: |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 } | 535 } |
536 | 536 |
537 if (unicodeBidiValue == CSSValueNormal) { | 537 if (unicodeBidiValue == CSSValueNormal) { |
538 writingDirection = NaturalWritingDirection; | 538 writingDirection = NaturalWritingDirection; |
539 return true; | 539 return true; |
540 } | 540 } |
541 | 541 |
542 return false; | 542 return false; |
543 } | 543 } |
544 | 544 |
545 void EditingStyle::setStyle(PassRefPtr<StylePropertySet> style) | 545 void EditingStyle::setStyle(PassRefPtr<MutableStylePropertySet> style) |
546 { | 546 { |
547 m_mutableStyle = style; | 547 m_mutableStyle = style; |
548 // FIXME: We should be able to figure out whether or not font is fixed width
for mutable style. | 548 // FIXME: We should be able to figure out whether or not font is fixed width
for mutable style. |
549 // We need to check font-family is monospace as in FontDescription but we do
n't want to duplicate code here. | 549 // We need to check font-family is monospace as in FontDescription but we do
n't want to duplicate code here. |
550 m_shouldUseFixedDefaultFontSize = false; | 550 m_shouldUseFixedDefaultFontSize = false; |
551 extractFontSizeDelta(); | 551 extractFontSizeDelta(); |
552 } | 552 } |
553 | 553 |
554 void EditingStyle::overrideWithStyle(const StylePropertySet* style) | 554 void EditingStyle::overrideWithStyle(const StylePropertySet* style) |
555 { | 555 { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 CSSPropertyWebkitTextDecorationsInEffect, | 664 CSSPropertyWebkitTextDecorationsInEffect, |
665 CSSPropertyFontStyle, | 665 CSSPropertyFontStyle, |
666 CSSPropertyFontWeight, | 666 CSSPropertyFontWeight, |
667 CSSPropertyColor, | 667 CSSPropertyColor, |
668 }; | 668 }; |
669 | 669 |
670 TriState EditingStyle::triStateOfStyle(EditingStyle* style) const | 670 TriState EditingStyle::triStateOfStyle(EditingStyle* style) const |
671 { | 671 { |
672 if (!style || !style->m_mutableStyle) | 672 if (!style || !style->m_mutableStyle) |
673 return FalseTriState; | 673 return FalseTriState; |
674 return triStateOfStyle(static_pointer_cast<MutableStylePropertySet>(style->m
_mutableStyle)->ensureCSSStyleDeclaration(), DoNotIgnoreTextOnlyProperties); | 674 return triStateOfStyle(style->m_mutableStyle->ensureCSSStyleDeclaration(), D
oNotIgnoreTextOnlyProperties); |
675 } | 675 } |
676 | 676 |
677 TriState EditingStyle::triStateOfStyle(CSSStyleDeclaration* styleToCompare, Shou
ldIgnoreTextOnlyProperties shouldIgnoreTextOnlyProperties) const | 677 TriState EditingStyle::triStateOfStyle(CSSStyleDeclaration* styleToCompare, Shou
ldIgnoreTextOnlyProperties shouldIgnoreTextOnlyProperties) const |
678 { | 678 { |
679 RefPtr<StylePropertySet> difference = getPropertiesNotIn(m_mutableStyle.get(
), styleToCompare); | 679 RefPtr<MutableStylePropertySet> difference = getPropertiesNotIn(m_mutableSty
le.get(), styleToCompare); |
680 | 680 |
681 if (shouldIgnoreTextOnlyProperties == IgnoreTextOnlyProperties) | 681 if (shouldIgnoreTextOnlyProperties == IgnoreTextOnlyProperties) |
682 difference->removePropertiesInSet(textOnlyProperties, WTF_ARRAY_LENGTH(t
extOnlyProperties)); | 682 difference->removePropertiesInSet(textOnlyProperties, WTF_ARRAY_LENGTH(t
extOnlyProperties)); |
683 | 683 |
684 if (difference->isEmpty()) | 684 if (difference->isEmpty()) |
685 return TrueTriState; | 685 return TrueTriState; |
686 if (difference->propertyCount() == m_mutableStyle->propertyCount()) | 686 if (difference->propertyCount() == m_mutableStyle->propertyCount()) |
687 return FalseTriState; | 687 return FalseTriState; |
688 | 688 |
689 return MixedTriState; | 689 return MixedTriState; |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 if (matchedRules->item(i)->type() == CSSRule::STYLE_RULE) | 1101 if (matchedRules->item(i)->type() == CSSRule::STYLE_RULE) |
1102 style->mergeAndOverrideOnConflict(static_cast<CSSStyleRule*>(mat
chedRules->item(i))->styleRule()->properties()); | 1102 style->mergeAndOverrideOnConflict(static_cast<CSSStyleRule*>(mat
chedRules->item(i))->styleRule()->properties()); |
1103 } | 1103 } |
1104 } | 1104 } |
1105 | 1105 |
1106 return style.release(); | 1106 return style.release(); |
1107 } | 1107 } |
1108 | 1108 |
1109 void EditingStyle::mergeStyleFromRules(StyledElement* element) | 1109 void EditingStyle::mergeStyleFromRules(StyledElement* element) |
1110 { | 1110 { |
1111 RefPtr<StylePropertySet> styleFromMatchedRules = styleFromMatchedRulesForEle
ment(element, | 1111 RefPtr<MutableStylePropertySet> styleFromMatchedRules = styleFromMatchedRule
sForElement(element, |
1112 StyleResolver::AuthorCSSRules | StyleResolver::CrossOriginCSSRules); | 1112 StyleResolver::AuthorCSSRules | StyleResolver::CrossOriginCSSRules); |
1113 // Styles from the inline style declaration, held in the variable "style", t
ake precedence | 1113 // Styles from the inline style declaration, held in the variable "style", t
ake precedence |
1114 // over those from matched rules. | 1114 // over those from matched rules. |
1115 if (m_mutableStyle) | 1115 if (m_mutableStyle) |
1116 styleFromMatchedRules->mergeAndOverrideOnConflict(m_mutableStyle.get()); | 1116 styleFromMatchedRules->mergeAndOverrideOnConflict(m_mutableStyle.get()); |
1117 | 1117 |
1118 clear(); | 1118 clear(); |
1119 m_mutableStyle = styleFromMatchedRules; | 1119 m_mutableStyle = styleFromMatchedRules; |
1120 } | 1120 } |
1121 | 1121 |
(...skipping 15 matching lines...) Expand all Loading... |
1137 continue; | 1137 continue; |
1138 if (static_cast<CSSPrimitiveValue*>(value)->isPercentage()) { | 1138 if (static_cast<CSSPrimitiveValue*>(value)->isPercentage()) { |
1139 if (RefPtr<CSSValue> computedPropertyValue = computedStyleForEle
ment->getPropertyCSSValue(property.id())) | 1139 if (RefPtr<CSSValue> computedPropertyValue = computedStyleForEle
ment->getPropertyCSSValue(property.id())) |
1140 fromComputedStyle->addParsedProperty(CSSProperty(property.id
(), computedPropertyValue)); | 1140 fromComputedStyle->addParsedProperty(CSSProperty(property.id
(), computedPropertyValue)); |
1141 } | 1141 } |
1142 } | 1142 } |
1143 } | 1143 } |
1144 m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle.get()); | 1144 m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle.get()); |
1145 } | 1145 } |
1146 | 1146 |
1147 static void removePropertiesInStyle(StylePropertySet* styleToRemovePropertiesFro
m, StylePropertySet* style) | 1147 static void removePropertiesInStyle(MutableStylePropertySet* styleToRemoveProper
tiesFrom, StylePropertySet* style) |
1148 { | 1148 { |
1149 unsigned propertyCount = style->propertyCount(); | 1149 unsigned propertyCount = style->propertyCount(); |
1150 Vector<CSSPropertyID> propertiesToRemove(propertyCount); | 1150 Vector<CSSPropertyID> propertiesToRemove(propertyCount); |
1151 for (unsigned i = 0; i < propertyCount; ++i) | 1151 for (unsigned i = 0; i < propertyCount; ++i) |
1152 propertiesToRemove[i] = style->propertyAt(i).id(); | 1152 propertiesToRemove[i] = style->propertyAt(i).id(); |
1153 | 1153 |
1154 styleToRemovePropertiesFrom->removePropertiesInSet(propertiesToRemove.data()
, propertiesToRemove.size()); | 1154 styleToRemovePropertiesFrom->removePropertiesInSet(propertiesToRemove.data()
, propertiesToRemove.size()); |
1155 } | 1155 } |
1156 | 1156 |
1157 void EditingStyle::removeStyleFromRulesAndContext(StyledElement* element, Node*
context) | 1157 void EditingStyle::removeStyleFromRulesAndContext(StyledElement* element, Node*
context) |
1158 { | 1158 { |
1159 ASSERT(element); | 1159 ASSERT(element); |
1160 if (!m_mutableStyle) | 1160 if (!m_mutableStyle) |
1161 return; | 1161 return; |
1162 | 1162 |
1163 // 1. Remove style from matched rules because style remain without repeating
it in inline style declaration | 1163 // 1. Remove style from matched rules because style remain without repeating
it in inline style declaration |
1164 RefPtr<MutableStylePropertySet> styleFromMatchedRules = styleFromMatchedRule
sForElement(element, StyleResolver::AllButEmptyCSSRules); | 1164 RefPtr<MutableStylePropertySet> styleFromMatchedRules = styleFromMatchedRule
sForElement(element, StyleResolver::AllButEmptyCSSRules); |
1165 if (styleFromMatchedRules && !styleFromMatchedRules->isEmpty()) | 1165 if (styleFromMatchedRules && !styleFromMatchedRules->isEmpty()) |
1166 m_mutableStyle = getPropertiesNotIn(m_mutableStyle.get(), styleFromMatch
edRules->ensureCSSStyleDeclaration()); | 1166 m_mutableStyle = getPropertiesNotIn(m_mutableStyle.get(), styleFromMatch
edRules->ensureCSSStyleDeclaration()); |
1167 | 1167 |
1168 // 2. Remove style present in context and not overriden by matched rules. | 1168 // 2. Remove style present in context and not overriden by matched rules. |
1169 RefPtr<EditingStyle> computedStyle = EditingStyle::create(context, EditingPr
opertiesInEffect); | 1169 RefPtr<EditingStyle> computedStyle = EditingStyle::create(context, EditingPr
opertiesInEffect); |
1170 if (computedStyle->m_mutableStyle) { | 1170 if (computedStyle->m_mutableStyle) { |
1171 if (!computedStyle->m_mutableStyle->getPropertyCSSValue(CSSPropertyBackg
roundColor)) | 1171 if (!computedStyle->m_mutableStyle->getPropertyCSSValue(CSSPropertyBackg
roundColor)) |
1172 computedStyle->m_mutableStyle->setProperty(CSSPropertyBackgroundColo
r, CSSValueTransparent); | 1172 computedStyle->m_mutableStyle->setProperty(CSSPropertyBackgroundColo
r, CSSValueTransparent); |
1173 | 1173 |
1174 removePropertiesInStyle(computedStyle->m_mutableStyle.get(), styleFromMa
tchedRules.get()); | 1174 removePropertiesInStyle(computedStyle->m_mutableStyle.get(), styleFromMa
tchedRules.get()); |
1175 m_mutableStyle = getPropertiesNotIn(m_mutableStyle.get(), static_pointer
_cast<MutableStylePropertySet>(computedStyle->m_mutableStyle)->ensureCSSStyleDec
laration()); | 1175 m_mutableStyle = getPropertiesNotIn(m_mutableStyle.get(), computedStyle-
>m_mutableStyle->ensureCSSStyleDeclaration()); |
1176 } | 1176 } |
1177 | 1177 |
1178 // 3. If this element is a span and has display: inline or float: none, remo
ve them unless they are overriden by rules. | 1178 // 3. If this element is a span and has display: inline or float: none, remo
ve them unless they are overriden by rules. |
1179 // These rules are added by serialization code to wrap text nodes. | 1179 // These rules are added by serialization code to wrap text nodes. |
1180 if (isStyleSpanOrSpanWithOnlyStyleAttribute(element)) { | 1180 if (isStyleSpanOrSpanWithOnlyStyleAttribute(element)) { |
1181 if (!styleFromMatchedRules->getPropertyCSSValue(CSSPropertyDisplay) && g
etIdentifierValue(m_mutableStyle.get(), CSSPropertyDisplay) == CSSValueInline) | 1181 if (!styleFromMatchedRules->getPropertyCSSValue(CSSPropertyDisplay) && g
etIdentifierValue(m_mutableStyle.get(), CSSPropertyDisplay) == CSSValueInline) |
1182 m_mutableStyle->removeProperty(CSSPropertyDisplay); | 1182 m_mutableStyle->removeProperty(CSSPropertyDisplay); |
1183 if (!styleFromMatchedRules->getPropertyCSSValue(CSSPropertyFloat) && get
IdentifierValue(m_mutableStyle.get(), CSSPropertyFloat) == CSSValueNone) | 1183 if (!styleFromMatchedRules->getPropertyCSSValue(CSSPropertyFloat) && get
IdentifierValue(m_mutableStyle.get(), CSSPropertyFloat) == CSSValueNone) |
1184 m_mutableStyle->removeProperty(CSSPropertyFloat); | 1184 m_mutableStyle->removeProperty(CSSPropertyFloat); |
1185 } | 1185 } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 // In the range case, make sure that the embedding element persists unti
l the end of the range. | 1324 // In the range case, make sure that the embedding element persists unti
l the end of the range. |
1325 if (selection.isRange() && !end.deprecatedNode()->isDescendantOf(node)) | 1325 if (selection.isRange() && !end.deprecatedNode()->isDescendantOf(node)) |
1326 return NaturalWritingDirection; | 1326 return NaturalWritingDirection; |
1327 | 1327 |
1328 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec
tion : RightToLeftWritingDirection; | 1328 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec
tion : RightToLeftWritingDirection; |
1329 } | 1329 } |
1330 hasNestedOrMultipleEmbeddings = false; | 1330 hasNestedOrMultipleEmbeddings = false; |
1331 return foundDirection; | 1331 return foundDirection; |
1332 } | 1332 } |
1333 | 1333 |
1334 static void reconcileTextDecorationProperties(StylePropertySet* style) | 1334 static void reconcileTextDecorationProperties(MutableStylePropertySet* style) |
1335 { | 1335 { |
1336 RefPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSSValue(CSSPro
pertyWebkitTextDecorationsInEffect); | 1336 RefPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSSValue(CSSPro
pertyWebkitTextDecorationsInEffect); |
1337 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(CSSPropertyText
Decoration); | 1337 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(CSSPropertyText
Decoration); |
1338 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef
fect because that wouldn't make sense. | 1338 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef
fect because that wouldn't make sense. |
1339 ASSERT(!textDecorationsInEffect || !textDecoration); | 1339 ASSERT(!textDecorationsInEffect || !textDecoration); |
1340 if (textDecorationsInEffect) { | 1340 if (textDecorationsInEffect) { |
1341 style->setProperty(CSSPropertyTextDecoration, textDecorationsInEffect->c
ssText()); | 1341 style->setProperty(CSSPropertyTextDecoration, textDecorationsInEffect->c
ssText()); |
1342 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); | 1342 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); |
1343 textDecoration = textDecorationsInEffect; | 1343 textDecoration = textDecorationsInEffect; |
1344 } | 1344 } |
(...skipping 10 matching lines...) Expand all Loading... |
1355 , m_applyLineThrough(false) | 1355 , m_applyLineThrough(false) |
1356 , m_applySubscript(false) | 1356 , m_applySubscript(false) |
1357 , m_applySuperscript(false) | 1357 , m_applySuperscript(false) |
1358 { | 1358 { |
1359 Document* document = position.anchorNode() ? position.anchorNode()->document
() : 0; | 1359 Document* document = position.anchorNode() ? position.anchorNode()->document
() : 0; |
1360 if (!style || !style->style() || !document || !document->frame()) | 1360 if (!style || !style->style() || !document || !document->frame()) |
1361 return; | 1361 return; |
1362 | 1362 |
1363 RefPtr<CSSComputedStyleDeclaration> computedStyle = position.computedStyle()
; | 1363 RefPtr<CSSComputedStyleDeclaration> computedStyle = position.computedStyle()
; |
1364 // FIXME: take care of background-color in effect | 1364 // FIXME: take care of background-color in effect |
1365 RefPtr<StylePropertySet> mutableStyle = getPropertiesNotIn(style->style(), c
omputedStyle.get()); | 1365 RefPtr<MutableStylePropertySet> mutableStyle = getPropertiesNotIn(style->sty
le(), computedStyle.get()); |
1366 | 1366 |
1367 reconcileTextDecorationProperties(mutableStyle.get()); | 1367 reconcileTextDecorationProperties(mutableStyle.get()); |
1368 if (!document->frame()->editor()->shouldStyleWithCSS()) | 1368 if (!document->frame()->editor()->shouldStyleWithCSS()) |
1369 extractTextStyles(document, mutableStyle.get(), computedStyle->useFixedF
ontDefaultSize()); | 1369 extractTextStyles(document, mutableStyle.get(), computedStyle->useFixedF
ontDefaultSize()); |
1370 | 1370 |
1371 // Changing the whitespace style in a tab span would collapse the tab into a
space. | 1371 // Changing the whitespace style in a tab span would collapse the tab into a
space. |
1372 if (isTabSpanTextNode(position.deprecatedNode()) || isTabSpanNode((position.
deprecatedNode()))) | 1372 if (isTabSpanTextNode(position.deprecatedNode()) || isTabSpanNode((position.
deprecatedNode()))) |
1373 mutableStyle->removeProperty(CSSPropertyWhiteSpace); | 1373 mutableStyle->removeProperty(CSSPropertyWhiteSpace); |
1374 | 1374 |
1375 // If unicode-bidi is present in mutableStyle and direction is not, then add
direction to mutableStyle. | 1375 // If unicode-bidi is present in mutableStyle and direction is not, then add
direction to mutableStyle. |
1376 // FIXME: Shouldn't this be done in getPropertiesNotIn? | 1376 // FIXME: Shouldn't this be done in getPropertiesNotIn? |
1377 if (mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi) && !style->sty
le()->getPropertyCSSValue(CSSPropertyDirection)) | 1377 if (mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi) && !style->sty
le()->getPropertyCSSValue(CSSPropertyDirection)) |
1378 mutableStyle->setProperty(CSSPropertyDirection, style->style()->getPrope
rtyValue(CSSPropertyDirection)); | 1378 mutableStyle->setProperty(CSSPropertyDirection, style->style()->getPrope
rtyValue(CSSPropertyDirection)); |
1379 | 1379 |
1380 // Save the result for later | 1380 // Save the result for later |
1381 m_cssStyle = mutableStyle->asText().stripWhiteSpace(); | 1381 m_cssStyle = mutableStyle->asText().stripWhiteSpace(); |
1382 } | 1382 } |
1383 | 1383 |
1384 static void setTextDecorationProperty(StylePropertySet* style, const CSSValueLis
t* newTextDecoration, CSSPropertyID propertyID) | 1384 static void setTextDecorationProperty(MutableStylePropertySet* style, const CSSV
alueList* newTextDecoration, CSSPropertyID propertyID) |
1385 { | 1385 { |
1386 if (newTextDecoration->length()) | 1386 if (newTextDecoration->length()) |
1387 style->setProperty(propertyID, newTextDecoration->cssText(), style->prop
ertyIsImportant(propertyID)); | 1387 style->setProperty(propertyID, newTextDecoration->cssText(), style->prop
ertyIsImportant(propertyID)); |
1388 else { | 1388 else { |
1389 // text-decoration: none is redundant since it does not remove any text
decorations. | 1389 // text-decoration: none is redundant since it does not remove any text
decorations. |
1390 ASSERT(!style->propertyIsImportant(propertyID)); | 1390 ASSERT(!style->propertyIsImportant(propertyID)); |
1391 style->removeProperty(propertyID); | 1391 style->removeProperty(propertyID); |
1392 } | 1392 } |
1393 } | 1393 } |
1394 | 1394 |
1395 void StyleChange::extractTextStyles(Document* document, StylePropertySet* style,
bool shouldUseFixedFontDefaultSize) | 1395 void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet*
style, bool shouldUseFixedFontDefaultSize) |
1396 { | 1396 { |
1397 ASSERT(style); | 1397 ASSERT(style); |
1398 | 1398 |
1399 if (getIdentifierValue(style, CSSPropertyFontWeight) == CSSValueBold) { | 1399 if (getIdentifierValue(style, CSSPropertyFontWeight) == CSSValueBold) { |
1400 style->removeProperty(CSSPropertyFontWeight); | 1400 style->removeProperty(CSSPropertyFontWeight); |
1401 m_applyBold = true; | 1401 m_applyBold = true; |
1402 } | 1402 } |
1403 | 1403 |
1404 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); | 1404 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); |
1405 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { | 1405 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 if (!fontSize->isPrimitiveValue()) | 1450 if (!fontSize->isPrimitiveValue()) |
1451 style->removeProperty(CSSPropertyFontSize); // Can't make sense of t
he number. Put no font size. | 1451 style->removeProperty(CSSPropertyFontSize); // Can't make sense of t
he number. Put no font size. |
1452 else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, stati
c_cast<CSSPrimitiveValue*>(fontSize.get()), | 1452 else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, stati
c_cast<CSSPrimitiveValue*>(fontSize.get()), |
1453 shouldUseFixedFontDefaultSize, UseLegacyFontSizeOnlyIfPixelValue
sMatch)) { | 1453 shouldUseFixedFontDefaultSize, UseLegacyFontSizeOnlyIfPixelValue
sMatch)) { |
1454 m_applyFontSize = String::number(legacyFontSize); | 1454 m_applyFontSize = String::number(legacyFontSize); |
1455 style->removeProperty(CSSPropertyFontSize); | 1455 style->removeProperty(CSSPropertyFontSize); |
1456 } | 1456 } |
1457 } | 1457 } |
1458 } | 1458 } |
1459 | 1459 |
1460 static void diffTextDecorations(StylePropertySet* style, CSSPropertyID propertID
, CSSValue* refTextDecoration) | 1460 static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr
opertID, CSSValue* refTextDecoration) |
1461 { | 1461 { |
1462 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(propertID); | 1462 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(propertID); |
1463 if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration
|| !refTextDecoration->isValueList()) | 1463 if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration
|| !refTextDecoration->isValueList()) |
1464 return; | 1464 return; |
1465 | 1465 |
1466 RefPtr<CSSValueList> newTextDecoration = static_cast<CSSValueList*>(textDeco
ration.get())->copy(); | 1466 RefPtr<CSSValueList> newTextDecoration = static_cast<CSSValueList*>(textDeco
ration.get())->copy(); |
1467 CSSValueList* valuesInRefTextDecoration = static_cast<CSSValueList*>(refText
Decoration); | 1467 CSSValueList* valuesInRefTextDecoration = static_cast<CSSValueList*>(refText
Decoration); |
1468 | 1468 |
1469 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++) | 1469 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++) |
1470 newTextDecoration->removeAll(valuesInRefTextDecoration->item(i)); | 1470 newTextDecoration->removeAll(valuesInRefTextDecoration->item(i)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1508 return fontWeightIsBold(fontWeight.get()); | 1508 return fontWeightIsBold(fontWeight.get()); |
1509 } | 1509 } |
1510 | 1510 |
1511 static bool fontWeightIsBold(StylePropertySet* style) | 1511 static bool fontWeightIsBold(StylePropertySet* style) |
1512 { | 1512 { |
1513 ASSERT(style); | 1513 ASSERT(style); |
1514 RefPtr<CSSValue> fontWeight = style->getPropertyCSSValue(CSSPropertyFontWeig
ht); | 1514 RefPtr<CSSValue> fontWeight = style->getPropertyCSSValue(CSSPropertyFontWeig
ht); |
1515 return fontWeightIsBold(fontWeight.get()); | 1515 return fontWeightIsBold(fontWeight.get()); |
1516 } | 1516 } |
1517 | 1517 |
1518 PassRefPtr<StylePropertySet> getPropertiesNotIn(StylePropertySet* styleWithRedun
dantProperties, CSSStyleDeclaration* baseStyle) | 1518 PassRefPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWi
thRedundantProperties, CSSStyleDeclaration* baseStyle) |
1519 { | 1519 { |
1520 ASSERT(styleWithRedundantProperties); | 1520 ASSERT(styleWithRedundantProperties); |
1521 ASSERT(baseStyle); | 1521 ASSERT(baseStyle); |
1522 RefPtr<MutableStylePropertySet> result = styleWithRedundantProperties->mutab
leCopy(); | 1522 RefPtr<MutableStylePropertySet> result = styleWithRedundantProperties->mutab
leCopy(); |
1523 | 1523 |
1524 result->removeEquivalentProperties(baseStyle); | 1524 result->removeEquivalentProperties(baseStyle); |
1525 | 1525 |
1526 RefPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPropertyCSSValu
eInternal(CSSPropertyWebkitTextDecorationsInEffect); | 1526 RefPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPropertyCSSValu
eInternal(CSSPropertyWebkitTextDecorationsInEffect); |
1527 diffTextDecorations(result.get(), CSSPropertyTextDecoration, baseTextDecorat
ionsInEffect.get()); | 1527 diffTextDecorations(result.get(), CSSPropertyTextDecoration, baseTextDecorat
ionsInEffect.get()); |
1528 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect,
baseTextDecorationsInEffect.get()); | 1528 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect,
baseTextDecorationsInEffect.get()); |
1529 | 1529 |
1530 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight) && fontWei
ghtIsBold(result.get()) == fontWeightIsBold(baseStyle)) | 1530 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight) && fontWei
ghtIsBold(result.get()) == fontWeightIsBold(baseStyle)) |
1531 result->removeProperty(CSSPropertyFontWeight); | 1531 result->removeProperty(CSSPropertyFontWeight); |
1532 | 1532 |
1533 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC
olor(result.get()) == getRGBAFontColor(baseStyle)) | 1533 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC
olor(result.get()) == getRGBAFontColor(baseStyle)) |
1534 result->removeProperty(CSSPropertyColor); | 1534 result->removeProperty(CSSPropertyColor); |
1535 | 1535 |
1536 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) | 1536 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) |
1537 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar
tAndEnd(baseStyle)) | 1537 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar
tAndEnd(baseStyle)) |
1538 result->removeProperty(CSSPropertyTextAlign); | 1538 result->removeProperty(CSSPropertyTextAlign); |
1539 | 1539 |
1540 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge
tRGBABackgroundColor(result.get()) == getRGBABackgroundColor(baseStyle)) | 1540 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge
tRGBABackgroundColor(result.get()) == getRGBABackgroundColor(baseStyle)) |
1541 result->removeProperty(CSSPropertyBackgroundColor); | 1541 result->removeProperty(CSSPropertyBackgroundColor); |
1542 | 1542 |
1543 return result; | 1543 return result.release(); |
1544 } | 1544 } |
1545 | 1545 |
1546 int getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) | 1546 int getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) |
1547 { | 1547 { |
1548 if (!style) | 1548 if (!style) |
1549 return 0; | 1549 return 0; |
1550 RefPtr<CSSValue> value = style->getPropertyCSSValue(propertyID); | 1550 RefPtr<CSSValue> value = style->getPropertyCSSValue(propertyID); |
1551 if (!value || !value->isPrimitiveValue()) | 1551 if (!value || !value->isPrimitiveValue()) |
1552 return 0; | 1552 return 0; |
1553 return static_cast<CSSPrimitiveValue*>(value.get())->getIdent(); | 1553 return static_cast<CSSPrimitiveValue*>(value.get())->getIdent(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1615 { | 1615 { |
1616 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1616 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
1617 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl
aration::create(ancestor); | 1617 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl
aration::create(ancestor); |
1618 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1618 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
1619 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); | 1619 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); |
1620 } | 1620 } |
1621 return 0; | 1621 return 0; |
1622 } | 1622 } |
1623 | 1623 |
1624 } | 1624 } |
OLD | NEW |