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 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 break; | 1133 break; |
1134 if (node.isStyledElement() && !isMailHTMLBlockquoteElement(&node)) { | 1134 if (node.isStyledElement() && !isMailHTMLBlockquoteElement(&node)) { |
1135 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(&node)
, EditingStyle::DoNotOverrideValues, | 1135 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(&node)
, EditingStyle::DoNotOverrideValues, |
1136 EditingStyle::EditingPropertiesInEffect); | 1136 EditingStyle::EditingPropertiesInEffect); |
1137 } | 1137 } |
1138 } | 1138 } |
1139 | 1139 |
1140 return wrappingStyle; | 1140 return wrappingStyle; |
1141 } | 1141 } |
1142 | 1142 |
1143 static CSSValueList* mergeTextDecorationValues(const CSSValueList* mergedValue,
const CSSValueList* valueToMerge) | 1143 static CSSValueList* mergeTextDecorationValues(const CSSValueList& mergedValue,
const CSSValueList& valueToMerge) |
1144 { | 1144 { |
1145 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::create
Identifier(CSSValueUnderline))); | 1145 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::create
Identifier(CSSValueUnderline))); |
1146 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::crea
teIdentifier(CSSValueLineThrough))); | 1146 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::crea
teIdentifier(CSSValueLineThrough))); |
1147 CSSValueList* result = mergedValue->copy(); | 1147 CSSValueList* result = mergedValue.copy(); |
1148 if (valueToMerge->hasValue(underline) && !mergedValue->hasValue(underline)) | 1148 if (valueToMerge.hasValue(underline) && !mergedValue.hasValue(underline)) |
1149 result->append(underline); | 1149 result->append(underline); |
1150 | 1150 |
1151 if (valueToMerge->hasValue(lineThrough) && !mergedValue->hasValue(lineThroug
h)) | 1151 if (valueToMerge.hasValue(lineThrough) && !mergedValue.hasValue(lineThrough)
) |
1152 result->append(lineThrough); | 1152 result->append(lineThrough); |
1153 | 1153 |
1154 return result; | 1154 return result; |
1155 } | 1155 } |
1156 | 1156 |
1157 void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride
Mode mode) | 1157 void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride
Mode mode) |
1158 { | 1158 { |
1159 if (!style) | 1159 if (!style) |
1160 return; | 1160 return; |
1161 | 1161 |
1162 if (!m_mutableStyle) { | 1162 if (!m_mutableStyle) { |
1163 m_mutableStyle = style->mutableCopy(); | 1163 m_mutableStyle = style->mutableCopy(); |
1164 return; | 1164 return; |
1165 } | 1165 } |
1166 | 1166 |
1167 unsigned propertyCount = style->propertyCount(); | 1167 unsigned propertyCount = style->propertyCount(); |
1168 for (unsigned i = 0; i < propertyCount; ++i) { | 1168 for (unsigned i = 0; i < propertyCount; ++i) { |
1169 StylePropertySet::PropertyReference property = style->propertyAt(i); | 1169 StylePropertySet::PropertyReference property = style->propertyAt(i); |
1170 const CSSValue* value = m_mutableStyle->getPropertyCSSValue(property.id(
)); | 1170 const CSSValue* value = m_mutableStyle->getPropertyCSSValue(property.id(
)); |
1171 | 1171 |
1172 // text decorations never override values | 1172 // text decorations never override values |
1173 if ((property.id() == textDecorationPropertyForEditing() || property.id(
) == CSSPropertyWebkitTextDecorationsInEffect) && property.value()->isValueList(
) && value) { | 1173 if ((property.id() == textDecorationPropertyForEditing() || property.id(
) == CSSPropertyWebkitTextDecorationsInEffect) && property.value().isValueList()
&& value) { |
1174 if (value->isValueList()) { | 1174 if (value->isValueList()) { |
1175 CSSValueList* result = mergeTextDecorationValues(toCSSValueList(
value), toCSSValueList(property.value())); | 1175 CSSValueList* result = mergeTextDecorationValues(*toCSSValueList
(value), toCSSValueList(property.value())); |
1176 m_mutableStyle->setProperty(property.id(), result, property.isIm
portant()); | 1176 m_mutableStyle->setProperty(property.id(), result, property.isIm
portant()); |
1177 continue; | 1177 continue; |
1178 } | 1178 } |
1179 value = nullptr; // text-decoration: none is equivalent to not havin
g the property | 1179 value = nullptr; // text-decoration: none is equivalent to not havin
g the property |
1180 } | 1180 } |
1181 | 1181 |
1182 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value)) | 1182 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value)) |
1183 m_mutableStyle->setProperty(property.id(), property.value()->cssText
(), property.isImportant()); | 1183 m_mutableStyle->setProperty(property.id(), property.value().cssText(
), property.isImportant()); |
1184 } | 1184 } |
1185 } | 1185 } |
1186 | 1186 |
1187 static MutableStylePropertySet* styleFromMatchedRulesForElement(Element* element
, unsigned rulesToInclude) | 1187 static MutableStylePropertySet* styleFromMatchedRulesForElement(Element* element
, unsigned rulesToInclude) |
1188 { | 1188 { |
1189 MutableStylePropertySet* style = MutableStylePropertySet::create(HTMLQuirksM
ode); | 1189 MutableStylePropertySet* style = MutableStylePropertySet::create(HTMLQuirksM
ode); |
1190 StyleRuleList* matchedRules = element->document().ensureStyleResolver().styl
eRulesForElement(element, rulesToInclude); | 1190 StyleRuleList* matchedRules = element->document().ensureStyleResolver().styl
eRulesForElement(element, rulesToInclude); |
1191 if (matchedRules) { | 1191 if (matchedRules) { |
1192 for (unsigned i = 0; i < matchedRules->size(); ++i) | 1192 for (unsigned i = 0; i < matchedRules->size(); ++i) |
1193 style->mergeAndOverrideOnConflict(&matchedRules->at(i)->properties()
); | 1193 style->mergeAndOverrideOnConflict(&matchedRules->at(i)->properties()
); |
(...skipping 20 matching lines...) Expand all Loading... |
1214 | 1214 |
1215 // The property value, if it's a percentage, may not reflect the actual comp
uted value. | 1215 // The property value, if it's a percentage, may not reflect the actual comp
uted value. |
1216 // For example: style="height: 1%; overflow: visible;" in quirksmode | 1216 // For example: style="height: 1%; overflow: visible;" in quirksmode |
1217 // FIXME: There are others like this, see <rdar://problem/5195123> Slashdot
copy/paste fidelity problem | 1217 // FIXME: There are others like this, see <rdar://problem/5195123> Slashdot
copy/paste fidelity problem |
1218 CSSComputedStyleDeclaration* computedStyleForElement = CSSComputedStyleDecla
ration::create(element); | 1218 CSSComputedStyleDeclaration* computedStyleForElement = CSSComputedStyleDecla
ration::create(element); |
1219 MutableStylePropertySet* fromComputedStyle = MutableStylePropertySet::create
(HTMLQuirksMode); | 1219 MutableStylePropertySet* fromComputedStyle = MutableStylePropertySet::create
(HTMLQuirksMode); |
1220 { | 1220 { |
1221 unsigned propertyCount = m_mutableStyle->propertyCount(); | 1221 unsigned propertyCount = m_mutableStyle->propertyCount(); |
1222 for (unsigned i = 0; i < propertyCount; ++i) { | 1222 for (unsigned i = 0; i < propertyCount; ++i) { |
1223 StylePropertySet::PropertyReference property = m_mutableStyle->prope
rtyAt(i); | 1223 StylePropertySet::PropertyReference property = m_mutableStyle->prope
rtyAt(i); |
1224 const CSSValue* value = property.value(); | 1224 const CSSValue& value = property.value(); |
1225 if (!value->isPrimitiveValue()) | 1225 if (!value.isPrimitiveValue()) |
1226 continue; | 1226 continue; |
1227 if (toCSSPrimitiveValue(value)->isPercentage()) { | 1227 if (toCSSPrimitiveValue(value).isPercentage()) { |
1228 if (const CSSValue* computedPropertyValue = computedStyleForElem
ent->getPropertyCSSValue(property.id())) | 1228 if (const CSSValue* computedPropertyValue = computedStyleForElem
ent->getPropertyCSSValue(property.id())) |
1229 fromComputedStyle->addRespectingCascade(CSSProperty(property
.id(), *computedPropertyValue)); | 1229 fromComputedStyle->addRespectingCascade(CSSProperty(property
.id(), *computedPropertyValue)); |
1230 } | 1230 } |
1231 } | 1231 } |
1232 } | 1232 } |
1233 m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle); | 1233 m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle); |
1234 } | 1234 } |
1235 | 1235 |
1236 static void removePropertiesInStyle(MutableStylePropertySet* styleToRemoveProper
tiesFrom, StylePropertySet* style) | 1236 static void removePropertiesInStyle(MutableStylePropertySet* styleToRemoveProper
tiesFrom, StylePropertySet* style) |
1237 { | 1237 { |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1757 { | 1757 { |
1758 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1758 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
1759 CSSComputedStyleDeclaration* ancestorStyle = CSSComputedStyleDeclaration
::create(ancestor); | 1759 CSSComputedStyleDeclaration* ancestorStyle = CSSComputedStyleDeclaration
::create(ancestor); |
1760 if (!hasTransparentBackgroundColor(ancestorStyle)) | 1760 if (!hasTransparentBackgroundColor(ancestorStyle)) |
1761 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); | 1761 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); |
1762 } | 1762 } |
1763 return nullptr; | 1763 return nullptr; |
1764 } | 1764 } |
1765 | 1765 |
1766 } // namespace blink | 1766 } // namespace blink |
OLD | NEW |