| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "core/editing/FrameSelection.h" | 49 #include "core/editing/FrameSelection.h" |
| 50 #include "core/editing/HTMLInterchange.h" | 50 #include "core/editing/HTMLInterchange.h" |
| 51 #include "core/editing/htmlediting.h" | 51 #include "core/editing/htmlediting.h" |
| 52 #include "core/html/HTMLFontElement.h" | 52 #include "core/html/HTMLFontElement.h" |
| 53 #include "core/page/Frame.h" | 53 #include "core/page/Frame.h" |
| 54 #include "core/page/RuntimeCSSEnabled.h" | 54 #include "core/page/RuntimeCSSEnabled.h" |
| 55 #include "core/rendering/style/RenderStyle.h" | 55 #include "core/rendering/style/RenderStyle.h" |
| 56 | 56 |
| 57 namespace WebCore { | 57 namespace WebCore { |
| 58 | 58 |
| 59 static const CSSPropertyID& textDecorationPropertyForEditing() |
| 60 { |
| 61 static const CSSPropertyID property = RuntimeEnabledFeatures::css3TextDecora
tionsEnabled() ? CSSPropertyTextDecorationLine : CSSPropertyTextDecoration; |
| 62 return property; |
| 63 } |
| 64 |
| 59 // Editing style properties must be preserved during editing operation. | 65 // Editing style properties must be preserved during editing operation. |
| 60 // e.g. when a user inserts a new paragraph, all properties listed here must be
copied to the new paragraph. | 66 // e.g. when a user inserts a new paragraph, all properties listed here must be
copied to the new paragraph. |
| 61 // NOTE: Use either allEditingProperties() or inheritableEditingProperties() to | 67 // NOTE: Use either allEditingProperties() or inheritableEditingProperties() to |
| 62 // respect runtime enabling of properties. | 68 // respect runtime enabling of properties. |
| 63 static const CSSPropertyID staticEditingProperties[] = { | 69 static const CSSPropertyID staticEditingProperties[] = { |
| 64 CSSPropertyBackgroundColor, | 70 CSSPropertyBackgroundColor, |
| 65 CSSPropertyColor, | 71 CSSPropertyColor, |
| 66 CSSPropertyFontFamily, | 72 CSSPropertyFontFamily, |
| 67 CSSPropertyFontSize, | 73 CSSPropertyFontSize, |
| 68 CSSPropertyFontStyle, | 74 CSSPropertyFontStyle, |
| 69 CSSPropertyFontVariant, | 75 CSSPropertyFontVariant, |
| 70 CSSPropertyFontWeight, | 76 CSSPropertyFontWeight, |
| 71 CSSPropertyLetterSpacing, | 77 CSSPropertyLetterSpacing, |
| 72 CSSPropertyLineHeight, | 78 CSSPropertyLineHeight, |
| 73 CSSPropertyOrphans, | 79 CSSPropertyOrphans, |
| 74 CSSPropertyTextAlign, | 80 CSSPropertyTextAlign, |
| 81 // FIXME: CSSPropertyTextDecoration needs to be removed when CSS3 Text |
| 82 // Decoration feature is no longer experimental. |
| 75 CSSPropertyTextDecoration, | 83 CSSPropertyTextDecoration, |
| 84 CSSPropertyTextDecorationLine, |
| 76 CSSPropertyTextIndent, | 85 CSSPropertyTextIndent, |
| 77 CSSPropertyTextTransform, | 86 CSSPropertyTextTransform, |
| 78 CSSPropertyWhiteSpace, | 87 CSSPropertyWhiteSpace, |
| 79 CSSPropertyWidows, | 88 CSSPropertyWidows, |
| 80 CSSPropertyWordSpacing, | 89 CSSPropertyWordSpacing, |
| 81 CSSPropertyWebkitTextDecorationsInEffect, | 90 CSSPropertyWebkitTextDecorationsInEffect, |
| 82 CSSPropertyWebkitTextFillColor, | 91 CSSPropertyWebkitTextFillColor, |
| 83 CSSPropertyWebkitTextStrokeColor, | 92 CSSPropertyWebkitTextStrokeColor, |
| 84 CSSPropertyWebkitTextStrokeWidth, | 93 CSSPropertyWebkitTextStrokeWidth, |
| 85 }; | 94 }; |
| 86 | 95 |
| 87 enum EditingPropertiesType { OnlyInheritableEditingProperties, AllEditingPropert
ies }; | 96 enum EditingPropertiesType { OnlyInheritableEditingProperties, AllEditingPropert
ies }; |
| 88 | 97 |
| 89 static const Vector<CSSPropertyID>& allEditingProperties() | 98 static const Vector<CSSPropertyID>& allEditingProperties() |
| 90 { | 99 { |
| 91 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); | 100 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); |
| 92 if (properties.isEmpty()) | 101 if (properties.isEmpty()) { |
| 93 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro
perties, WTF_ARRAY_LENGTH(staticEditingProperties), properties); | 102 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro
perties, WTF_ARRAY_LENGTH(staticEditingProperties), properties); |
| 103 // This ensures we have only one of these properties on the vector. |
| 104 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) |
| 105 properties.remove(properties.find(CSSPropertyTextDecoration)); |
| 106 else |
| 107 properties.remove(properties.find(CSSPropertyTextDecorationLine)); |
| 108 } |
| 94 return properties; | 109 return properties; |
| 95 } | 110 } |
| 96 | 111 |
| 97 static const Vector<CSSPropertyID>& inheritableEditingProperties() | 112 static const Vector<CSSPropertyID>& inheritableEditingProperties() |
| 98 { | 113 { |
| 99 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); | 114 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); |
| 100 if (properties.isEmpty()) { | 115 if (properties.isEmpty()) { |
| 101 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro
perties, WTF_ARRAY_LENGTH(staticEditingProperties), properties); | 116 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro
perties, WTF_ARRAY_LENGTH(staticEditingProperties), properties); |
| 102 for (size_t index = 0; index < properties.size();) { | 117 for (size_t index = 0; index < properties.size();) { |
| 103 if (!CSSProperty::isInheritedProperty(properties[index])) { | 118 if (!CSSProperty::isInheritedProperty(properties[index])) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 return adoptPtr(new HTMLTextDecorationEquivalent(primitiveValue, tagName
)); | 215 return adoptPtr(new HTMLTextDecorationEquivalent(primitiveValue, tagName
)); |
| 201 } | 216 } |
| 202 virtual bool propertyExistsInStyle(const StylePropertySet*) const; | 217 virtual bool propertyExistsInStyle(const StylePropertySet*) const; |
| 203 virtual bool valueIsPresentInStyle(Element*, StylePropertySet*) const; | 218 virtual bool valueIsPresentInStyle(Element*, StylePropertySet*) const; |
| 204 | 219 |
| 205 private: | 220 private: |
| 206 HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const QualifiedName&
tagName); | 221 HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const QualifiedName&
tagName); |
| 207 }; | 222 }; |
| 208 | 223 |
| 209 HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent(CSSValueID primitiveV
alue, const QualifiedName& tagName) | 224 HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent(CSSValueID primitiveV
alue, const QualifiedName& tagName) |
| 210 : HTMLElementEquivalent(CSSPropertyTextDecoration, primitiveValue, tagName) | 225 : HTMLElementEquivalent(textDecorationPropertyForEditing(), primitiveValue,
tagName) |
| 211 // m_propertyID is used in HTMLElementEquivalent::addToStyle | 226 // m_propertyID is used in HTMLElementEquivalent::addToStyle |
| 212 { | 227 { |
| 213 } | 228 } |
| 214 | 229 |
| 215 bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet*
style) const | 230 bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet*
style) const |
| 216 { | 231 { |
| 217 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect)
|| style->getPropertyCSSValue(CSSPropertyTextDecoration); | 232 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect) |
| 233 || style->getPropertyCSSValue(textDecorationPropertyForEditing()); |
| 218 } | 234 } |
| 219 | 235 |
| 220 bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(Element* element, Style
PropertySet* style) const | 236 bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(Element* element, Style
PropertySet* style) const |
| 221 { | 237 { |
| 222 RefPtr<CSSValue> styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTe
xtDecorationsInEffect); | 238 RefPtr<CSSValue> styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTe
xtDecorationsInEffect); |
| 223 if (!styleValue) | 239 if (!styleValue) |
| 224 styleValue = style->getPropertyCSSValue(CSSPropertyTextDecoration); | 240 styleValue = style->getPropertyCSSValue(textDecorationPropertyForEditing
()); |
| 225 return matches(element) && styleValue && styleValue->isValueList() && toCSSV
alueList(styleValue.get())->hasValue(m_primitiveValue.get()); | 241 return matches(element) && styleValue && styleValue->isValueList() && toCSSV
alueList(styleValue.get())->hasValue(m_primitiveValue.get()); |
| 226 } | 242 } |
| 227 | 243 |
| 228 class HTMLAttributeEquivalent : public HTMLElementEquivalent { | 244 class HTMLAttributeEquivalent : public HTMLElementEquivalent { |
| 229 public: | 245 public: |
| 230 static PassOwnPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID,
const QualifiedName& tagName, const QualifiedName& attrName) | 246 static PassOwnPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID,
const QualifiedName& tagName, const QualifiedName& attrName) |
| 231 { | 247 { |
| 232 return adoptPtr(new HTMLAttributeEquivalent(propertyID, tagName, attrNam
e)); | 248 return adoptPtr(new HTMLAttributeEquivalent(propertyID, tagName, attrNam
e)); |
| 233 } | 249 } |
| 234 static PassOwnPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID,
const QualifiedName& attrName) | 250 static PassOwnPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID,
const QualifiedName& attrName) |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 void EditingStyle::collapseTextDecorationProperties() | 658 void EditingStyle::collapseTextDecorationProperties() |
| 643 { | 659 { |
| 644 if (!m_mutableStyle) | 660 if (!m_mutableStyle) |
| 645 return; | 661 return; |
| 646 | 662 |
| 647 RefPtr<CSSValue> textDecorationsInEffect = m_mutableStyle->getPropertyCSSVal
ue(CSSPropertyWebkitTextDecorationsInEffect); | 663 RefPtr<CSSValue> textDecorationsInEffect = m_mutableStyle->getPropertyCSSVal
ue(CSSPropertyWebkitTextDecorationsInEffect); |
| 648 if (!textDecorationsInEffect) | 664 if (!textDecorationsInEffect) |
| 649 return; | 665 return; |
| 650 | 666 |
| 651 if (textDecorationsInEffect->isValueList()) | 667 if (textDecorationsInEffect->isValueList()) |
| 652 m_mutableStyle->setProperty(CSSPropertyTextDecoration, textDecorationsIn
Effect->cssText(), m_mutableStyle->propertyIsImportant(CSSPropertyTextDecoration
)); | 668 m_mutableStyle->setProperty(textDecorationPropertyForEditing(), textDeco
rationsInEffect->cssText(), m_mutableStyle->propertyIsImportant(textDecorationPr
opertyForEditing())); |
| 653 else | 669 else |
| 654 m_mutableStyle->removeProperty(CSSPropertyTextDecoration); | 670 m_mutableStyle->removeProperty(textDecorationPropertyForEditing()); |
| 655 m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); | 671 m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); |
| 656 } | 672 } |
| 657 | 673 |
| 658 // CSS properties that create a visual difference only when applied to text. | 674 // CSS properties that create a visual difference only when applied to text. |
| 659 static const CSSPropertyID textOnlyProperties[] = { | 675 static const CSSPropertyID textOnlyProperties[] = { |
| 676 // FIXME: CSSPropertyTextDecoration needs to be removed when CSS3 Text |
| 677 // Decoration feature is no longer experimental. |
| 660 CSSPropertyTextDecoration, | 678 CSSPropertyTextDecoration, |
| 679 CSSPropertyTextDecorationLine, |
| 661 CSSPropertyWebkitTextDecorationsInEffect, | 680 CSSPropertyWebkitTextDecorationsInEffect, |
| 662 CSSPropertyFontStyle, | 681 CSSPropertyFontStyle, |
| 663 CSSPropertyFontWeight, | 682 CSSPropertyFontWeight, |
| 664 CSSPropertyColor, | 683 CSSPropertyColor, |
| 665 }; | 684 }; |
| 666 | 685 |
| 667 TriState EditingStyle::triStateOfStyle(EditingStyle* style) const | 686 TriState EditingStyle::triStateOfStyle(EditingStyle* style) const |
| 668 { | 687 { |
| 669 if (!style || !style->m_mutableStyle) | 688 if (!style || !style->m_mutableStyle) |
| 670 return FalseTriState; | 689 return FalseTriState; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 return false; | 746 return false; |
| 728 | 747 |
| 729 unsigned propertyCount = m_mutableStyle->propertyCount(); | 748 unsigned propertyCount = m_mutableStyle->propertyCount(); |
| 730 for (unsigned i = 0; i < propertyCount; ++i) { | 749 for (unsigned i = 0; i < propertyCount; ++i) { |
| 731 CSSPropertyID propertyID = m_mutableStyle->propertyAt(i).id(); | 750 CSSPropertyID propertyID = m_mutableStyle->propertyAt(i).id(); |
| 732 | 751 |
| 733 // We don't override whitespace property of a tab span because that woul
d collapse the tab into a space. | 752 // We don't override whitespace property of a tab span because that woul
d collapse the tab into a space. |
| 734 if (propertyID == CSSPropertyWhiteSpace && isTabSpanNode(element)) | 753 if (propertyID == CSSPropertyWhiteSpace && isTabSpanNode(element)) |
| 735 continue; | 754 continue; |
| 736 | 755 |
| 737 if (propertyID == CSSPropertyWebkitTextDecorationsInEffect && inlineStyl
e->getPropertyCSSValue(CSSPropertyTextDecoration)) { | 756 if (propertyID == CSSPropertyWebkitTextDecorationsInEffect && inlineStyl
e->getPropertyCSSValue(textDecorationPropertyForEditing())) { |
| 738 if (!conflictingProperties) | 757 if (!conflictingProperties) |
| 739 return true; | 758 return true; |
| 740 conflictingProperties->append(CSSPropertyTextDecoration); | 759 conflictingProperties->append(CSSPropertyTextDecoration); |
| 760 // Because text-decoration expands to text-decoration-line when CSS3 |
| 761 // Text Decoration is enabled, we also state it as conflicting. |
| 762 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) |
| 763 conflictingProperties->append(CSSPropertyTextDecorationLine); |
| 741 if (extractedStyle) | 764 if (extractedStyle) |
| 742 extractedStyle->setProperty(CSSPropertyTextDecoration, inlineSty
le->getPropertyValue(CSSPropertyTextDecoration), inlineStyle->propertyIsImportan
t(CSSPropertyTextDecoration)); | 765 extractedStyle->setProperty(textDecorationPropertyForEditing(),
inlineStyle->getPropertyValue(textDecorationPropertyForEditing()), inlineStyle->
propertyIsImportant(textDecorationPropertyForEditing())); |
| 743 continue; | 766 continue; |
| 744 } | 767 } |
| 745 | 768 |
| 746 if (!inlineStyle->getPropertyCSSValue(propertyID)) | 769 if (!inlineStyle->getPropertyCSSValue(propertyID)) |
| 747 continue; | 770 continue; |
| 748 | 771 |
| 749 if (propertyID == CSSPropertyUnicodeBidi && inlineStyle->getPropertyCSSV
alue(CSSPropertyDirection)) { | 772 if (propertyID == CSSPropertyUnicodeBidi && inlineStyle->getPropertyCSSV
alue(CSSPropertyDirection)) { |
| 750 if (!conflictingProperties) | 773 if (!conflictingProperties) |
| 751 return true; | 774 return true; |
| 752 conflictingProperties->append(CSSPropertyDirection); | 775 conflictingProperties->append(CSSPropertyDirection); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 m_mutableStyle = style->mutableCopy(); | 1113 m_mutableStyle = style->mutableCopy(); |
| 1091 return; | 1114 return; |
| 1092 } | 1115 } |
| 1093 | 1116 |
| 1094 unsigned propertyCount = style->propertyCount(); | 1117 unsigned propertyCount = style->propertyCount(); |
| 1095 for (unsigned i = 0; i < propertyCount; ++i) { | 1118 for (unsigned i = 0; i < propertyCount; ++i) { |
| 1096 StylePropertySet::PropertyReference property = style->propertyAt(i); | 1119 StylePropertySet::PropertyReference property = style->propertyAt(i); |
| 1097 RefPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(property.id
()); | 1120 RefPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(property.id
()); |
| 1098 | 1121 |
| 1099 // text decorations never override values | 1122 // text decorations never override values |
| 1100 if ((property.id() == CSSPropertyTextDecoration || property.id() == CSSP
ropertyWebkitTextDecorationsInEffect) && property.value()->isValueList() && valu
e) { | 1123 if ((property.id() == textDecorationPropertyForEditing() || property.id(
) == CSSPropertyWebkitTextDecorationsInEffect) && property.value()->isValueList(
) && value) { |
| 1101 if (value->isValueList()) { | 1124 if (value->isValueList()) { |
| 1102 mergeTextDecorationValues(toCSSValueList(value.get()), toCSSValu
eList(property.value())); | 1125 mergeTextDecorationValues(toCSSValueList(value.get()), toCSSValu
eList(property.value())); |
| 1103 continue; | 1126 continue; |
| 1104 } | 1127 } |
| 1105 value = 0; // text-decoration: none is equivalent to not having the
property | 1128 value = 0; // text-decoration: none is equivalent to not having the
property |
| 1106 } | 1129 } |
| 1107 | 1130 |
| 1108 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value)) | 1131 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value)) |
| 1109 m_mutableStyle->setProperty(property.id(), property.value()->cssText
(), property.isImportant()); | 1132 m_mutableStyle->setProperty(property.id(), property.value()->cssText
(), property.isImportant()); |
| 1110 } | 1133 } |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1345 | 1368 |
| 1346 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec
tion : RightToLeftWritingDirection; | 1369 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec
tion : RightToLeftWritingDirection; |
| 1347 } | 1370 } |
| 1348 hasNestedOrMultipleEmbeddings = false; | 1371 hasNestedOrMultipleEmbeddings = false; |
| 1349 return foundDirection; | 1372 return foundDirection; |
| 1350 } | 1373 } |
| 1351 | 1374 |
| 1352 static void reconcileTextDecorationProperties(MutableStylePropertySet* style) | 1375 static void reconcileTextDecorationProperties(MutableStylePropertySet* style) |
| 1353 { | 1376 { |
| 1354 RefPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSSValue(CSSPro
pertyWebkitTextDecorationsInEffect); | 1377 RefPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSSValue(CSSPro
pertyWebkitTextDecorationsInEffect); |
| 1355 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(CSSPropertyText
Decoration); | 1378 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(textDecorationP
ropertyForEditing()); |
| 1356 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef
fect because that wouldn't make sense. | 1379 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef
fect because that wouldn't make sense. |
| 1357 ASSERT(!textDecorationsInEffect || !textDecoration); | 1380 ASSERT(!textDecorationsInEffect || !textDecoration); |
| 1358 if (textDecorationsInEffect) { | 1381 if (textDecorationsInEffect) { |
| 1359 style->setProperty(CSSPropertyTextDecoration, textDecorationsInEffect->c
ssText()); | 1382 style->setProperty(textDecorationPropertyForEditing(), textDecorationsIn
Effect->cssText()); |
| 1360 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); | 1383 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); |
| 1361 textDecoration = textDecorationsInEffect; | 1384 textDecoration = textDecorationsInEffect; |
| 1362 } | 1385 } |
| 1363 | 1386 |
| 1364 // If text-decoration is set to "none", remove the property because we don't
want to add redundant "text-decoration: none". | 1387 // If text-decoration is set to "none", remove the property because we don't
want to add redundant "text-decoration: none". |
| 1365 if (textDecoration && !textDecoration->isValueList()) | 1388 if (textDecoration && !textDecoration->isValueList()) |
| 1366 style->removeProperty(CSSPropertyTextDecoration); | 1389 style->removeProperty(textDecorationPropertyForEditing()); |
| 1367 } | 1390 } |
| 1368 | 1391 |
| 1369 StyleChange::StyleChange(EditingStyle* style, const Position& position) | 1392 StyleChange::StyleChange(EditingStyle* style, const Position& position) |
| 1370 : m_applyBold(false) | 1393 : m_applyBold(false) |
| 1371 , m_applyItalic(false) | 1394 , m_applyItalic(false) |
| 1372 , m_applyUnderline(false) | 1395 , m_applyUnderline(false) |
| 1373 , m_applyLineThrough(false) | 1396 , m_applyLineThrough(false) |
| 1374 , m_applySubscript(false) | 1397 , m_applySubscript(false) |
| 1375 , m_applySuperscript(false) | 1398 , m_applySuperscript(false) |
| 1376 { | 1399 { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1420 } | 1443 } |
| 1421 | 1444 |
| 1422 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); | 1445 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); |
| 1423 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { | 1446 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { |
| 1424 style->removeProperty(CSSPropertyFontStyle); | 1447 style->removeProperty(CSSPropertyFontStyle); |
| 1425 m_applyItalic = true; | 1448 m_applyItalic = true; |
| 1426 } | 1449 } |
| 1427 | 1450 |
| 1428 // Assuming reconcileTextDecorationProperties has been called, there should
not be -webkit-text-decorations-in-effect | 1451 // Assuming reconcileTextDecorationProperties has been called, there should
not be -webkit-text-decorations-in-effect |
| 1429 // Furthermore, text-decoration: none has been trimmed so that text-decorati
on property is always a CSSValueList. | 1452 // Furthermore, text-decoration: none has been trimmed so that text-decorati
on property is always a CSSValueList. |
| 1430 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(CSSPropertyText
Decoration); | 1453 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(textDecorationP
ropertyForEditing()); |
| 1431 if (textDecoration && textDecoration->isValueList()) { | 1454 if (textDecoration && textDecoration->isValueList()) { |
| 1432 DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, underline, (CSSPrimitiveV
alue::createIdentifier(CSSValueUnderline))); | 1455 DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, underline, (CSSPrimitiveV
alue::createIdentifier(CSSValueUnderline))); |
| 1433 DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, lineThrough, (CSSPrimitiv
eValue::createIdentifier(CSSValueLineThrough))); | 1456 DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, lineThrough, (CSSPrimitiv
eValue::createIdentifier(CSSValueLineThrough))); |
| 1434 | 1457 |
| 1435 RefPtr<CSSValueList> newTextDecoration = toCSSValueList(textDecoration.g
et())->copy(); | 1458 RefPtr<CSSValueList> newTextDecoration = toCSSValueList(textDecoration.g
et())->copy(); |
| 1436 if (newTextDecoration->removeAll(underline.get())) | 1459 if (newTextDecoration->removeAll(underline.get())) |
| 1437 m_applyUnderline = true; | 1460 m_applyUnderline = true; |
| 1438 if (newTextDecoration->removeAll(lineThrough.get())) | 1461 if (newTextDecoration->removeAll(lineThrough.get())) |
| 1439 m_applyLineThrough = true; | 1462 m_applyLineThrough = true; |
| 1440 | 1463 |
| 1441 // If trimTextDecorations, delete underline and line-through | 1464 // If trimTextDecorations, delete underline and line-through |
| 1442 setTextDecorationProperty(style, newTextDecoration.get(), CSSPropertyTex
tDecoration); | 1465 setTextDecorationProperty(style, newTextDecoration.get(), textDecoration
PropertyForEditing()); |
| 1443 } | 1466 } |
| 1444 | 1467 |
| 1445 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign); | 1468 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign); |
| 1446 switch (verticalAlign) { | 1469 switch (verticalAlign) { |
| 1447 case CSSValueSub: | 1470 case CSSValueSub: |
| 1448 style->removeProperty(CSSPropertyVerticalAlign); | 1471 style->removeProperty(CSSPropertyVerticalAlign); |
| 1449 m_applySubscript = true; | 1472 m_applySubscript = true; |
| 1450 break; | 1473 break; |
| 1451 case CSSValueSuper: | 1474 case CSSValueSuper: |
| 1452 style->removeProperty(CSSPropertyVerticalAlign); | 1475 style->removeProperty(CSSPropertyVerticalAlign); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1537 | 1560 |
| 1538 PassRefPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWi
thRedundantProperties, CSSStyleDeclaration* baseStyle) | 1561 PassRefPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWi
thRedundantProperties, CSSStyleDeclaration* baseStyle) |
| 1539 { | 1562 { |
| 1540 ASSERT(styleWithRedundantProperties); | 1563 ASSERT(styleWithRedundantProperties); |
| 1541 ASSERT(baseStyle); | 1564 ASSERT(baseStyle); |
| 1542 RefPtr<MutableStylePropertySet> result = styleWithRedundantProperties->mutab
leCopy(); | 1565 RefPtr<MutableStylePropertySet> result = styleWithRedundantProperties->mutab
leCopy(); |
| 1543 | 1566 |
| 1544 result->removeEquivalentProperties(baseStyle); | 1567 result->removeEquivalentProperties(baseStyle); |
| 1545 | 1568 |
| 1546 RefPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPropertyCSSValu
eInternal(CSSPropertyWebkitTextDecorationsInEffect); | 1569 RefPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPropertyCSSValu
eInternal(CSSPropertyWebkitTextDecorationsInEffect); |
| 1547 diffTextDecorations(result.get(), CSSPropertyTextDecoration, baseTextDecorat
ionsInEffect.get()); | 1570 diffTextDecorations(result.get(), textDecorationPropertyForEditing(), baseTe
xtDecorationsInEffect.get()); |
| 1548 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect,
baseTextDecorationsInEffect.get()); | 1571 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect,
baseTextDecorationsInEffect.get()); |
| 1549 | 1572 |
| 1550 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight) && fontWei
ghtIsBold(result.get()) == fontWeightIsBold(baseStyle)) | 1573 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight) && fontWei
ghtIsBold(result.get()) == fontWeightIsBold(baseStyle)) |
| 1551 result->removeProperty(CSSPropertyFontWeight); | 1574 result->removeProperty(CSSPropertyFontWeight); |
| 1552 | 1575 |
| 1553 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC
olor(result.get()) == getRGBAFontColor(baseStyle)) | 1576 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC
olor(result.get()) == getRGBAFontColor(baseStyle)) |
| 1554 result->removeProperty(CSSPropertyColor); | 1577 result->removeProperty(CSSPropertyColor); |
| 1555 | 1578 |
| 1556 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) | 1579 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) |
| 1557 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar
tAndEnd(baseStyle)) | 1580 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar
tAndEnd(baseStyle)) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1635 { | 1658 { |
| 1636 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1659 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
| 1637 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl
aration::create(ancestor); | 1660 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl
aration::create(ancestor); |
| 1638 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1661 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
| 1639 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); | 1662 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); |
| 1640 } | 1663 } |
| 1641 return 0; | 1664 return 0; |
| 1642 } | 1665 } |
| 1643 | 1666 |
| 1644 } | 1667 } |
| OLD | NEW |