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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "core/editing/FrameSelection.h" | 50 #include "core/editing/FrameSelection.h" |
51 #include "core/editing/Position.h" | 51 #include "core/editing/Position.h" |
52 #include "core/editing/commands/ApplyStyleCommand.h" | 52 #include "core/editing/commands/ApplyStyleCommand.h" |
53 #include "core/editing/serializers/HTMLInterchange.h" | 53 #include "core/editing/serializers/HTMLInterchange.h" |
54 #include "core/frame/LocalFrame.h" | 54 #include "core/frame/LocalFrame.h" |
55 #include "core/html/HTMLFontElement.h" | 55 #include "core/html/HTMLFontElement.h" |
56 #include "core/html/HTMLSpanElement.h" | 56 #include "core/html/HTMLSpanElement.h" |
57 #include "core/layout/LayoutBox.h" | 57 #include "core/layout/LayoutBox.h" |
58 #include "core/layout/LayoutObject.h" | 58 #include "core/layout/LayoutObject.h" |
59 #include "core/style/ComputedStyle.h" | 59 #include "core/style/ComputedStyle.h" |
60 #include "wtf/StdLibExtras.h" | |
61 | 60 |
62 namespace blink { | 61 namespace blink { |
63 | 62 |
64 static const CSSPropertyID& textDecorationPropertyForEditing() | 63 static const CSSPropertyID& textDecorationPropertyForEditing() |
65 { | 64 { |
66 static const CSSPropertyID property = RuntimeEnabledFeatures::css3TextDecora
tionsEnabled() ? CSSPropertyTextDecorationLine : CSSPropertyTextDecoration; | 65 static const CSSPropertyID property = RuntimeEnabledFeatures::css3TextDecora
tionsEnabled() ? CSSPropertyTextDecorationLine : CSSPropertyTextDecoration; |
67 return property; | 66 return property; |
68 } | 67 } |
69 | 68 |
70 // Editing style properties must be preserved during editing operation. | 69 // Editing style properties must be preserved during editing operation. |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 | 818 |
820 if (extractedStyle) | 819 if (extractedStyle) |
821 extractedStyle->setProperty(propertyID, inlineStyle->getPropertyValu
e(propertyID), inlineStyle->propertyIsImportant(propertyID)); | 820 extractedStyle->setProperty(propertyID, inlineStyle->getPropertyValu
e(propertyID), inlineStyle->propertyIsImportant(propertyID)); |
822 } | 821 } |
823 | 822 |
824 return conflictingProperties && !conflictingProperties->isEmpty(); | 823 return conflictingProperties && !conflictingProperties->isEmpty(); |
825 } | 824 } |
826 | 825 |
827 static const HeapVector<Member<HTMLElementEquivalent>>& htmlElementEquivalents() | 826 static const HeapVector<Member<HTMLElementEquivalent>>& htmlElementEquivalents() |
828 { | 827 { |
829 DEFINE_STATIC_LOCAL(HeapVector<Member<HTMLElementEquivalent>>, HTMLElementEq
uivalents, (new HeapVector<Member<HTMLElementEquivalent>>)); | 828 DEFINE_STATIC_LOCAL(PersistentHeapVector<Member<HTMLElementEquivalent>>, HTM
LElementEquivalents, ()); |
830 if (!HTMLElementEquivalents.size()) { | 829 if (!HTMLElementEquivalents.size()) { |
831 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyF
ontWeight, CSSValueBold, HTMLNames::bTag)); | 830 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyF
ontWeight, CSSValueBold, HTMLNames::bTag)); |
832 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyF
ontWeight, CSSValueBold, HTMLNames::strongTag)); | 831 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyF
ontWeight, CSSValueBold, HTMLNames::strongTag)); |
833 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyV
erticalAlign, CSSValueSub, HTMLNames::subTag)); | 832 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyV
erticalAlign, CSSValueSub, HTMLNames::subTag)); |
834 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyV
erticalAlign, CSSValueSuper, HTMLNames::supTag)); | 833 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyV
erticalAlign, CSSValueSuper, HTMLNames::supTag)); |
835 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyF
ontStyle, CSSValueItalic, HTMLNames::iTag)); | 834 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyF
ontStyle, CSSValueItalic, HTMLNames::iTag)); |
836 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyF
ontStyle, CSSValueItalic, HTMLNames::emTag)); | 835 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyF
ontStyle, CSSValueItalic, HTMLNames::emTag)); |
837 | 836 |
838 HTMLElementEquivalents.append(HTMLTextDecorationEquivalent::create(CSSVa
lueUnderline, HTMLNames::uTag)); | 837 HTMLElementEquivalents.append(HTMLTextDecorationEquivalent::create(CSSVa
lueUnderline, HTMLNames::uTag)); |
839 HTMLElementEquivalents.append(HTMLTextDecorationEquivalent::create(CSSVa
lueLineThrough, HTMLNames::sTag)); | 838 HTMLElementEquivalents.append(HTMLTextDecorationEquivalent::create(CSSVa
lueLineThrough, HTMLNames::sTag)); |
(...skipping 17 matching lines...) Expand all Loading... |
857 if (extractedStyle) | 856 if (extractedStyle) |
858 equivalent->addToStyle(element, extractedStyle); | 857 equivalent->addToStyle(element, extractedStyle); |
859 return true; | 858 return true; |
860 } | 859 } |
861 } | 860 } |
862 return false; | 861 return false; |
863 } | 862 } |
864 | 863 |
865 static const HeapVector<Member<HTMLAttributeEquivalent>>& htmlAttributeEquivalen
ts() | 864 static const HeapVector<Member<HTMLAttributeEquivalent>>& htmlAttributeEquivalen
ts() |
866 { | 865 { |
867 DEFINE_STATIC_LOCAL(HeapVector<Member<HTMLAttributeEquivalent>>, HTMLAttribu
teEquivalents, (new HeapVector<Member<HTMLAttributeEquivalent>>)); | 866 DEFINE_STATIC_LOCAL(PersistentHeapVector<Member<HTMLAttributeEquivalent>>, H
TMLAttributeEquivalents, ()); |
868 if (!HTMLAttributeEquivalents.size()) { | 867 if (!HTMLAttributeEquivalents.size()) { |
869 // elementIsStyledSpanOrHTMLEquivalent depends on the fact each HTMLAttr
iuteEquivalent matches exactly one attribute | 868 // elementIsStyledSpanOrHTMLEquivalent depends on the fact each HTMLAttr
iuteEquivalent matches exactly one attribute |
870 // of exactly one element except dirAttr. | 869 // of exactly one element except dirAttr. |
871 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create(CSSPrope
rtyColor, HTMLNames::fontTag, HTMLNames::colorAttr)); | 870 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create(CSSPrope
rtyColor, HTMLNames::fontTag, HTMLNames::colorAttr)); |
872 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create(CSSPrope
rtyFontFamily, HTMLNames::fontTag, HTMLNames::faceAttr)); | 871 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create(CSSPrope
rtyFontFamily, HTMLNames::fontTag, HTMLNames::faceAttr)); |
873 HTMLAttributeEquivalents.append(HTMLFontSizeEquivalent::create()); | 872 HTMLAttributeEquivalents.append(HTMLFontSizeEquivalent::create()); |
874 | 873 |
875 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create(CSSPrope
rtyDirection, HTMLNames::dirAttr)); | 874 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create(CSSPrope
rtyDirection, HTMLNames::dirAttr)); |
876 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create(CSSPrope
rtyUnicodeBidi, HTMLNames::dirAttr)); | 875 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create(CSSPrope
rtyUnicodeBidi, HTMLNames::dirAttr)); |
877 } | 876 } |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(node),
EditingStyle::DoNotOverrideValues, | 1123 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(node),
EditingStyle::DoNotOverrideValues, |
1125 EditingStyle::EditingPropertiesInEffect); | 1124 EditingStyle::EditingPropertiesInEffect); |
1126 } | 1125 } |
1127 } | 1126 } |
1128 | 1127 |
1129 return wrappingStyle.release(); | 1128 return wrappingStyle.release(); |
1130 } | 1129 } |
1131 | 1130 |
1132 static void mergeTextDecorationValues(CSSValueList* mergedValue, const CSSValueL
ist* valueToMerge) | 1131 static void mergeTextDecorationValues(CSSValueList* mergedValue, const CSSValueL
ist* valueToMerge) |
1133 { | 1132 { |
1134 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::create
Identifier(CSSValueUnderline))); | 1133 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, underline, (CSSPrimi
tiveValue::createIdentifier(CSSValueUnderline))); |
1135 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::crea
teIdentifier(CSSValueLineThrough))); | 1134 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CSSPri
mitiveValue::createIdentifier(CSSValueLineThrough))); |
1136 if (valueToMerge->hasValue(&underline) && !mergedValue->hasValue(&underline)
) | 1135 if (valueToMerge->hasValue(underline) && !mergedValue->hasValue(underline)) |
1137 mergedValue->append(&underline); | 1136 mergedValue->append(underline); |
1138 | 1137 |
1139 if (valueToMerge->hasValue(&lineThrough) && !mergedValue->hasValue(&lineThro
ugh)) | 1138 if (valueToMerge->hasValue(lineThrough) && !mergedValue->hasValue(lineThroug
h)) |
1140 mergedValue->append(&lineThrough); | 1139 mergedValue->append(lineThrough); |
1141 } | 1140 } |
1142 | 1141 |
1143 void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride
Mode mode) | 1142 void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride
Mode mode) |
1144 { | 1143 { |
1145 if (!style) | 1144 if (!style) |
1146 return; | 1145 return; |
1147 | 1146 |
1148 if (!m_mutableStyle) { | 1147 if (!m_mutableStyle) { |
1149 m_mutableStyle = style->mutableCopy(); | 1148 m_mutableStyle = style->mutableCopy(); |
1150 return; | 1149 return; |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); | 1517 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); |
1519 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { | 1518 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { |
1520 style->removeProperty(CSSPropertyFontStyle); | 1519 style->removeProperty(CSSPropertyFontStyle); |
1521 m_applyItalic = true; | 1520 m_applyItalic = true; |
1522 } | 1521 } |
1523 | 1522 |
1524 // Assuming reconcileTextDecorationProperties has been called, there should
not be -webkit-text-decorations-in-effect | 1523 // Assuming reconcileTextDecorationProperties has been called, there should
not be -webkit-text-decorations-in-effect |
1525 // Furthermore, text-decoration: none has been trimmed so that text-decorati
on property is always a CSSValueList. | 1524 // Furthermore, text-decoration: none has been trimmed so that text-decorati
on property is always a CSSValueList. |
1526 RawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(textDecorationP
ropertyForEditing()); | 1525 RawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(textDecorationP
ropertyForEditing()); |
1527 if (textDecoration && textDecoration->isValueList()) { | 1526 if (textDecoration && textDecoration->isValueList()) { |
1528 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::cr
eateIdentifier(CSSValueUnderline))); | 1527 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, underline, (CSSP
rimitiveValue::createIdentifier(CSSValueUnderline))); |
1529 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::
createIdentifier(CSSValueLineThrough))); | 1528 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CS
SPrimitiveValue::createIdentifier(CSSValueLineThrough))); |
1530 RawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDecoration.g
et())->copy(); | 1529 RawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDecoration.g
et())->copy(); |
1531 if (newTextDecoration->removeAll(&underline)) | 1530 if (newTextDecoration->removeAll(underline)) |
1532 m_applyUnderline = true; | 1531 m_applyUnderline = true; |
1533 if (newTextDecoration->removeAll(&lineThrough)) | 1532 if (newTextDecoration->removeAll(lineThrough)) |
1534 m_applyLineThrough = true; | 1533 m_applyLineThrough = true; |
1535 | 1534 |
1536 // If trimTextDecorations, delete underline and line-through | 1535 // If trimTextDecorations, delete underline and line-through |
1537 setTextDecorationProperty(style, newTextDecoration.get(), textDecoration
PropertyForEditing()); | 1536 setTextDecorationProperty(style, newTextDecoration.get(), textDecoration
PropertyForEditing()); |
1538 } | 1537 } |
1539 | 1538 |
1540 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign); | 1539 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign); |
1541 switch (verticalAlign) { | 1540 switch (verticalAlign) { |
1542 case CSSValueSub: | 1541 case CSSValueSub: |
1543 style->removeProperty(CSSPropertyVerticalAlign); | 1542 style->removeProperty(CSSPropertyVerticalAlign); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1724 { | 1723 { |
1725 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1724 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
1726 RawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl
aration::create(ancestor); | 1725 RawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl
aration::create(ancestor); |
1727 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1726 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
1728 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); | 1727 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); |
1729 } | 1728 } |
1730 return nullptr; | 1729 return nullptr; |
1731 } | 1730 } |
1732 | 1731 |
1733 } // namespace blink | 1732 } // namespace blink |
OLD | NEW |