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