Changeset 21652 in webkit
- Timestamp:
- May 22, 2007 5:43:11 PM (17 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r21651 r21652 1 2007-05-22 David Hyatt <hyatt@apple.com> 2 3 Fix for bug 13802, background colors can't be reset to default 4 color. Fix the value cssText method to do the right thing for background 5 and background-position values. 6 7 Reviewed by beth 8 9 fast/dom/background-shorthand-csstext.html 10 11 * css/CSSInitialValue.h: 12 (WebCore::CSSInitialValue:::m_implicit): 13 (WebCore::CSSInitialValue::isImplicitInitialValue): 14 * css/CSSMutableStyleDeclaration.cpp: 15 (WebCore::CSSMutableStyleDeclaration::getPropertyValue): 16 (WebCore::CSSMutableStyleDeclaration::getLayeredShorthandValue): 17 * css/CSSMutableStyleDeclaration.h: 18 * css/CSSValue.h: 19 (WebCore::CSSValue::isImplicitInitialValue): 20 * css/cssparser.cpp: 21 (WebCore::CSSParser::parseValue): 22 (WebCore::CSSParser::parseBackgroundShorthand): 23 (WebCore::CSSParser::parseShorthand): 24 1 25 2007-05-22 Darin Adler <darin@apple.com> 2 26 -
trunk/WebCore/css/CSSInitialValue.h
r18850 r21652 30 30 class CSSInitialValue : public CSSValue { 31 31 public: 32 CSSInitialValue(bool implicit) 33 :m_implicit(implicit) 34 {} 35 32 36 virtual unsigned short cssValueType() const; 33 37 virtual String cssText() const; 38 39 virtual bool isImplicitInitialValue() const { return m_implicit; } 40 41 private: 42 bool m_implicit; 34 43 }; 35 44 -
trunk/WebCore/css/CSSMutableStyleDeclaration.cpp
r21224 r21652 29 29 #include "CSSProperty.h" 30 30 #include "CSSStyleSheet.h" 31 #include "CSSValueList.h" 31 32 #include "Document.h" 32 33 #include "ExceptionCode.h" 33 34 #include "StyledElement.h" 35 36 using namespace std; 34 37 35 38 namespace WebCore { … … 82 85 const int properties[2] = { CSS_PROP_BACKGROUND_POSITION_X, 83 86 CSS_PROP_BACKGROUND_POSITION_Y }; 84 return get ShorthandValue(properties, 2);87 return getLayeredShorthandValue(properties, 2); 85 88 } 86 89 case CSS_PROP_BACKGROUND: { 87 const int properties[ 5] = { CSS_PROP_BACKGROUND_IMAGE, CSS_PROP_BACKGROUND_REPEAT,88 CSS_PROP_BACKGROUND_ATTACHMENT, CSS_PROP_BACKGROUND_POSITION ,89 CSS_PROP_BACKGROUND_ COLOR };90 return get ShorthandValue(properties, 5);90 const int properties[6] = { CSS_PROP_BACKGROUND_IMAGE, CSS_PROP_BACKGROUND_REPEAT, 91 CSS_PROP_BACKGROUND_ATTACHMENT, CSS_PROP_BACKGROUND_POSITION_X, 92 CSS_PROP_BACKGROUND_POSITION_Y, CSS_PROP_BACKGROUND_COLOR }; 93 return getLayeredShorthandValue(properties, 6); 91 94 } 92 95 case CSS_PROP_BORDER: { … … 170 173 } 171 174 } 175 return res; 176 } 177 178 String CSSMutableStyleDeclaration::getLayeredShorthandValue(const int* properties, unsigned number) const 179 { 180 String res; 181 unsigned i; 182 unsigned j; 183 184 // Begin by collecting the properties into an array. 185 Vector< RefPtr<CSSValue> > values(number); 186 unsigned numLayers = 0; 187 188 for (i = 0; i < number; ++i) { 189 values[i] = getPropertyCSSValue(properties[i]); 190 if (values[i]) { 191 if (values[i]->isValueList()) { 192 CSSValueList* valueList = static_cast<CSSValueList*>(values[i].get()); 193 numLayers = max(valueList->length(), numLayers); 194 } else 195 numLayers = max(1U, numLayers); 196 } 197 } 198 199 // Now stitch the properties together. Implicit initial values are flagged as such and 200 // can safely be omitted. 201 for (i = 0; i < numLayers; i++) { 202 String layerRes; 203 for (j = 0; j < number; j++) { 204 RefPtr<CSSValue> value; 205 if (values[j]) { 206 if (values[j]->isValueList()) 207 value = static_cast<CSSValueList*>(values[j].get())->item(i); 208 else { 209 value = values[j]; 210 211 // Color only belongs in the last layer. 212 if (properties[j] == CSS_PROP_BACKGROUND_COLOR) { 213 if (i != numLayers - 1) 214 value = 0; 215 } else if (i != 0) // Other singletons only belong in the first layer. 216 value = 0; 217 } 218 } 219 220 if (value && !value->isImplicitInitialValue()) { 221 if (!layerRes.isNull()) 222 layerRes += " "; 223 layerRes += value->cssText(); 224 } 225 } 226 227 if (!layerRes.isNull()) { 228 if (!res.isNull()) 229 res += ", "; 230 res += layerRes; 231 } 232 } 233 172 234 return res; 173 235 } -
trunk/WebCore/css/CSSMutableStyleDeclaration.h
r21224 r21652 105 105 private: 106 106 String getShorthandValue(const int* properties, int number) const; 107 String getLayeredShorthandValue(const int* properties, unsigned number) const; 107 108 String get4Values(const int* properties) const; 108 109 -
trunk/WebCore/css/CSSValue.h
r18874 r21652 47 47 virtual bool isValue() { return true; } 48 48 virtual bool isFontValue() { return false; } 49 virtual bool isImplicitInitialValue() const { return false; } 49 50 }; 50 51 -
trunk/WebCore/css/cssparser.cpp
r21026 r21652 515 515 if (num != 1) 516 516 return false; 517 addProperty(propId, new CSSInitialValue( ), important);517 addProperty(propId, new CSSInitialValue(false), important); 518 518 return true; 519 519 } … … 1554 1554 1555 1555 if (!parsedProperty[i] && properties[i] != CSS_PROP_BACKGROUND_COLOR) { 1556 addBackgroundValue(values[i], new CSSInitialValue( ));1556 addBackgroundValue(values[i], new CSSInitialValue(true)); 1557 1557 if (properties[i] == CSS_PROP_BACKGROUND_POSITION) 1558 addBackgroundValue(positionYValue, new CSSInitialValue( ));1558 addBackgroundValue(positionYValue, new CSSInitialValue(true)); 1559 1559 } 1560 1560 parsedProperty[i] = false; … … 1587 1587 for (i = 0; i < numProperties; ++i) { 1588 1588 if (!parsedProperty[i]) { 1589 addBackgroundValue(values[i], new CSSInitialValue( ));1589 addBackgroundValue(values[i], new CSSInitialValue(true)); 1590 1590 if (properties[i] == CSS_PROP_BACKGROUND_POSITION) 1591 addBackgroundValue(positionYValue, new CSSInitialValue( ));1591 addBackgroundValue(positionYValue, new CSSInitialValue(true)); 1592 1592 } 1593 1593 } … … 1643 1643 for (int i = 0; i < numProperties; ++i) { 1644 1644 if (!fnd[i]) 1645 addProperty(properties[i], new CSSInitialValue( ), important);1645 addProperty(properties[i], new CSSInitialValue(true), important); 1646 1646 } 1647 1647 m_implicitShorthand = false;
Note: See TracChangeset
for help on using the changeset viewer.