Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. | 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. |
| 5 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 5 * Copyright (C) 2013 Intel Corporation. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 return; | 262 return; |
| 263 } | 263 } |
| 264 | 264 |
| 265 removePropertiesInSet(shorthand.properties(), shorthand.length()); | 265 removePropertiesInSet(shorthand.properties(), shorthand.length()); |
| 266 | 266 |
| 267 RefPtrWillBeRawPtr<CSSValue> value = prpValue; | 267 RefPtrWillBeRawPtr<CSSValue> value = prpValue; |
| 268 for (unsigned i = 0; i < shorthand.length(); ++i) | 268 for (unsigned i = 0; i < shorthand.length(); ++i) |
| 269 m_propertyVector.append(CSSProperty(shorthand.properties()[i], value, im portant)); | 269 m_propertyVector.append(CSSProperty(shorthand.properties()[i], value, im portant)); |
| 270 } | 270 } |
| 271 | 271 |
| 272 unsigned getIndexInShorthandVectorForPrefixingVariant(const CSSProperty& propert y, CSSPropertyID prefixingVariant) | |
|
sashab
2015/04/23 05:04:32
This function existed before, but has been deleted
| |
| 273 { | |
| 274 if (!property.isSetFromShorthand()) | |
| 275 return 0; | |
| 276 | |
| 277 CSSPropertyID prefixedShorthand = prefixingVariantForPropertyId(property.sho rthandID()); | |
| 278 Vector<StylePropertyShorthand, 4> shorthands; | |
| 279 getMatchingShorthandsForLonghand(prefixingVariant, &shorthands); | |
| 280 return indexOfShorthandForLonghand(prefixedShorthand, shorthands); | |
| 281 } | |
| 282 | |
| 272 bool MutableStylePropertySet::setProperty(const CSSProperty& property, CSSProper ty* slot) | 283 bool MutableStylePropertySet::setProperty(const CSSProperty& property, CSSProper ty* slot) |
| 273 { | 284 { |
| 274 if (!removeShorthandProperty(property.id())) { | 285 if (!removeShorthandProperty(property.id())) { |
| 275 CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id ()); | 286 CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id ()); |
| 276 if (toReplace && *toReplace == property) | 287 if (toReplace && *toReplace == property) |
| 277 return false; | 288 return false; |
| 278 if (toReplace) { | 289 if (toReplace) { |
| 279 *toReplace = property; | 290 // Clear the important flag if the new property is not important |
| 291 if (toReplace->isImportant() && !property.isImportant()) { | |
| 292 *toReplace = CSSProperty(property.id(), property.value(), false, property.isSetFromShorthand(), getIndexInShorthandVectorForPrefixingVariant(pro perty, prefixingVariantForPropertyId(property.id())), property.metadata().m_impl icit); | |
| 293 } else { | |
| 294 *toReplace = property; | |
| 295 } | |
| 296 setPrefixingVariantProperty(property); | |
| 280 return true; | 297 return true; |
| 281 } | 298 } |
| 282 } | 299 } |
| 283 m_propertyVector.append(property); | 300 m_propertyVector.append(property); |
| 284 return true; | 301 return true; |
| 285 } | 302 } |
| 286 | 303 |
| 287 bool MutableStylePropertySet::setProperty(CSSPropertyID propertyID, CSSValueID i dentifier, bool important) | 304 bool MutableStylePropertySet::setProperty(CSSPropertyID propertyID, CSSValueID i dentifier, bool important) |
| 288 { | 305 { |
| 289 setProperty(CSSProperty(propertyID, cssValuePool().createIdentifierValue(ide ntifier), important)); | 306 setProperty(CSSProperty(propertyID, cssValuePool().createIdentifierValue(ide ntifier), important)); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 307 { | 324 { |
| 308 bool changed = false; | 325 bool changed = false; |
| 309 m_propertyVector.reserveCapacity(m_propertyVector.size() + properties.size() ); | 326 m_propertyVector.reserveCapacity(m_propertyVector.size() + properties.size() ); |
| 310 for (unsigned i = 0; i < properties.size(); ++i) | 327 for (unsigned i = 0; i < properties.size(); ++i) |
| 311 changed |= addParsedProperty(properties[i]); | 328 changed |= addParsedProperty(properties[i]); |
| 312 return changed; | 329 return changed; |
| 313 } | 330 } |
| 314 | 331 |
| 315 bool MutableStylePropertySet::addParsedProperty(const CSSProperty& property) | 332 bool MutableStylePropertySet::addParsedProperty(const CSSProperty& property) |
| 316 { | 333 { |
| 317 // Only add properties that have no !important counterpart present | 334 return setProperty(property); |
| 318 if (!propertyIsImportant(property.id()) || property.isImportant()) | |
| 319 return setProperty(property); | |
| 320 return false; | |
| 321 } | 335 } |
| 322 | 336 |
| 323 String StylePropertySet::asText() const | 337 String StylePropertySet::asText() const |
| 324 { | 338 { |
| 325 return StylePropertySerializer(*this).asText(); | 339 return StylePropertySerializer(*this).asText(); |
| 326 } | 340 } |
| 327 | 341 |
| 328 void MutableStylePropertySet::mergeAndOverrideOnConflict(const StylePropertySet* other) | 342 void MutableStylePropertySet::mergeAndOverrideOnConflict(const StylePropertySet* other) |
| 329 { | 343 { |
| 330 unsigned size = other->propertyCount(); | 344 unsigned size = other->propertyCount(); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 566 result.appendLiteral(": "); | 580 result.appendLiteral(": "); |
| 567 result.append(propertyValue()->cssText()); | 581 result.append(propertyValue()->cssText()); |
| 568 if (isImportant()) | 582 if (isImportant()) |
| 569 result.appendLiteral(" !important"); | 583 result.appendLiteral(" !important"); |
| 570 result.append(';'); | 584 result.append(';'); |
| 571 return result.toString(); | 585 return result.toString(); |
| 572 } | 586 } |
| 573 | 587 |
| 574 | 588 |
| 575 } // namespace blink | 589 } // namespace blink |
| OLD | NEW |