Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: Source/WebCore/editing/EditingStyle.cpp

Issue 8493001: Merge 99067 - REGRESSION(r96870): WebKit generates background: transparent on blogger.com (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/912/
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/WebCore/ChangeLog ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 CSSValue* value = property.value(); 1049 CSSValue* value = property.value();
1050 if (value->cssValueType() == CSSValue::CSS_PRIMITIVE_VALUE) 1050 if (value->cssValueType() == CSSValue::CSS_PRIMITIVE_VALUE)
1051 if (static_cast<CSSPrimitiveValue*>(value)->primitiveType() == C SSPrimitiveValue::CSS_PERCENTAGE) 1051 if (static_cast<CSSPrimitiveValue*>(value)->primitiveType() == C SSPrimitiveValue::CSS_PERCENTAGE)
1052 if (RefPtr<CSSValue> computedPropertyValue = computedStyleFo rElement->getPropertyCSSValue(property.id())) 1052 if (RefPtr<CSSValue> computedPropertyValue = computedStyleFo rElement->getPropertyCSSValue(property.id()))
1053 fromComputedStyle->addParsedProperty(CSSProperty(propert y.id(), computedPropertyValue)); 1053 fromComputedStyle->addParsedProperty(CSSProperty(propert y.id(), computedPropertyValue));
1054 } 1054 }
1055 } 1055 }
1056 m_mutableStyle->merge(fromComputedStyle.get()); 1056 m_mutableStyle->merge(fromComputedStyle.get());
1057 } 1057 }
1058 1058
1059 static void removePropertiesInStyle(CSSMutableStyleDeclaration* styleToRemovePro pertiesFrom, CSSMutableStyleDeclaration* style)
1060 {
1061 Vector<int> propertiesToRemove(style->length());
1062 size_t i = 0;
1063 CSSMutableStyleDeclaration::const_iterator end = style->end();
1064 for (CSSMutableStyleDeclaration::const_iterator it = style->begin(); it != e nd; ++it, ++i)
1065 propertiesToRemove[i] = it->id();
1066
1067 styleToRemovePropertiesFrom->removePropertiesInSet(propertiesToRemove.data() , propertiesToRemove.size());
1068 }
1069
1059 void EditingStyle::removeStyleFromRulesAndContext(StyledElement* element, Node* context) 1070 void EditingStyle::removeStyleFromRulesAndContext(StyledElement* element, Node* context)
1060 { 1071 {
1061 ASSERT(element); 1072 ASSERT(element);
1062 if (!m_mutableStyle) 1073 if (!m_mutableStyle)
1063 return; 1074 return;
1064 1075
1065 // 1. Remove style from matched rules because style remain without repeating it in inline style declaration 1076 // 1. Remove style from matched rules because style remain without repeating it in inline style declaration
1066 RefPtr<CSSMutableStyleDeclaration> styleFromMatchedRules = styleFromMatchedR ulesForElement(element, CSSStyleSelector::AllButEmptyCSSRules); 1077 RefPtr<CSSMutableStyleDeclaration> styleFromMatchedRules = styleFromMatchedR ulesForElement(element, CSSStyleSelector::AllButEmptyCSSRules);
1067 if (styleFromMatchedRules && styleFromMatchedRules->length()) 1078 if (styleFromMatchedRules && styleFromMatchedRules->length())
1068 m_mutableStyle = getPropertiesNotIn(m_mutableStyle.get(), styleFromMatch edRules.get()); 1079 m_mutableStyle = getPropertiesNotIn(m_mutableStyle.get(), styleFromMatch edRules.get());
1069 1080
1070 // 2. Remove style present in context and not overriden by matched rules. 1081 // 2. Remove style present in context and not overriden by matched rules.
1071 RefPtr<EditingStyle> computedStyle = EditingStyle::create(context, EditingIn heritablePropertiesAndBackgroundColorInEffect); 1082 RefPtr<EditingStyle> computedStyle = EditingStyle::create(context, EditingIn heritablePropertiesAndBackgroundColorInEffect);
1072 if (computedStyle->m_mutableStyle) { 1083 if (computedStyle->m_mutableStyle) {
1073 computedStyle->removePropertiesInElementDefaultStyle(element); 1084 if (!computedStyle->m_mutableStyle->getPropertyCSSValue(CSSPropertyBackg roundColor))
1085 computedStyle->m_mutableStyle->setProperty(CSSPropertyBackgroundColo r, CSSValueTransparent);
1086
1087 removePropertiesInStyle(computedStyle->m_mutableStyle.get(), styleFromMa tchedRules.get());
1074 m_mutableStyle = getPropertiesNotIn(m_mutableStyle.get(), computedStyle- >m_mutableStyle.get()); 1088 m_mutableStyle = getPropertiesNotIn(m_mutableStyle.get(), computedStyle- >m_mutableStyle.get());
1075 } 1089 }
1076 1090
1077 // 3. If this element is a span and has display: inline or float: none, remo ve them unless they are overriden by rules. 1091 // 3. If this element is a span and has display: inline or float: none, remo ve them unless they are overriden by rules.
1078 // These rules are added by serialization code to wrap text nodes. 1092 // These rules are added by serialization code to wrap text nodes.
1079 if (isStyleSpanOrSpanWithOnlyStyleAttribute(element)) { 1093 if (isStyleSpanOrSpanWithOnlyStyleAttribute(element)) {
1080 if (!styleFromMatchedRules->getPropertyCSSValue(CSSPropertyDisplay) && g etIdentifierValue(m_mutableStyle.get(), CSSPropertyDisplay) == CSSValueInline) 1094 if (!styleFromMatchedRules->getPropertyCSSValue(CSSPropertyDisplay) && g etIdentifierValue(m_mutableStyle.get(), CSSPropertyDisplay) == CSSValueInline)
1081 m_mutableStyle->removeProperty(CSSPropertyDisplay); 1095 m_mutableStyle->removeProperty(CSSPropertyDisplay);
1082 if (!styleFromMatchedRules->getPropertyCSSValue(CSSPropertyFloat) && get IdentifierValue(m_mutableStyle.get(), CSSPropertyFloat) == CSSValueNone) 1096 if (!styleFromMatchedRules->getPropertyCSSValue(CSSPropertyFloat) && get IdentifierValue(m_mutableStyle.get(), CSSPropertyFloat) == CSSValueNone)
1083 m_mutableStyle->removeProperty(CSSPropertyFloat); 1097 m_mutableStyle->removeProperty(CSSPropertyFloat);
1084 } 1098 }
1085 } 1099 }
1086 1100
1087 void EditingStyle::removePropertiesInElementDefaultStyle(Element* element) 1101 void EditingStyle::removePropertiesInElementDefaultStyle(Element* element)
1088 { 1102 {
1089 if (!m_mutableStyle || !m_mutableStyle->length()) 1103 if (!m_mutableStyle || !m_mutableStyle->length())
1090 return; 1104 return;
1091 1105
1092 RefPtr<CSSMutableStyleDeclaration> defaultStyle = styleFromMatchedRulesForEl ement(element, CSSStyleSelector::UAAndUserCSSRules); 1106 RefPtr<CSSMutableStyleDeclaration> defaultStyle = styleFromMatchedRulesForEl ement(element, CSSStyleSelector::UAAndUserCSSRules);
1093 1107
1094 Vector<int> propertiesToRemove(defaultStyle->length()); 1108 removePropertiesInStyle(m_mutableStyle.get(), defaultStyle.get());
1095 size_t i = 0;
1096 CSSMutableStyleDeclaration::const_iterator end = defaultStyle->end();
1097 for (CSSMutableStyleDeclaration::const_iterator it = defaultStyle->begin(); it != end; ++it, ++i)
1098 propertiesToRemove[i] = it->id();
1099
1100 m_mutableStyle->removePropertiesInSet(propertiesToRemove.data(), propertiesT oRemove.size());
1101 } 1109 }
1102 1110
1103 void EditingStyle::forceInline() 1111 void EditingStyle::forceInline()
1104 { 1112 {
1105 if (!m_mutableStyle) 1113 if (!m_mutableStyle)
1106 m_mutableStyle = CSSMutableStyleDeclaration::create(); 1114 m_mutableStyle = CSSMutableStyleDeclaration::create();
1107 const bool propertyIsImportant = true; 1115 const bool propertyIsImportant = true;
1108 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm portant); 1116 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm portant);
1109 } 1117 }
1110 1118
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 { 1430 {
1423 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 1431 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
1424 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = computedStyle(ancest or); 1432 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = computedStyle(ancest or);
1425 if (!hasTransparentBackgroundColor(ancestorStyle.get())) 1433 if (!hasTransparentBackgroundColor(ancestorStyle.get()))
1426 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); 1434 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor );
1427 } 1435 }
1428 return 0; 1436 return 0;
1429 } 1437 }
1430 1438
1431 } 1439 }
OLDNEW
« no previous file with comments | « Source/WebCore/ChangeLog ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698