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 getIndexInShorthandVector(const CSSProperty& property) | |
| 273 { | |
| 274 if (!property.isSetFromShorthand()) | |
| 275 return 0; | |
| 276 | |
| 277 Vector<StylePropertyShorthand, 4> shorthands; | |
| 278 getMatchingShorthandsForLonghand(property.id(), &shorthands); | |
| 279 return indexOfShorthandForLonghand(property.id(), shorthands); | |
| 280 } | |
| 281 | |
| 272 bool MutableStylePropertySet::setProperty(const CSSProperty& property, CSSProper ty* slot) | 282 bool MutableStylePropertySet::setProperty(const CSSProperty& property, CSSProper ty* slot) |
| 273 { | 283 { |
| 274 if (!removeShorthandProperty(property.id())) { | 284 if (!removeShorthandProperty(property.id())) { |
| 275 CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id ()); | 285 CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id ()); |
| 276 if (toReplace && *toReplace == property) | 286 if (toReplace && *toReplace == property) |
| 277 return false; | 287 return false; |
| 278 if (toReplace) { | 288 if (toReplace) { |
| 279 *toReplace = property; | 289 // Clear the important flag if the new property is not important |
| 290 if (!property.isImportant() && toReplace->isImportant()) { | |
| 291 *toReplace = CSSProperty(property.id(), property.value(), false, property.isSetFromShorthand(), getIndexInShorthandVector(property), property.me tadata().m_implicit); | |
|
Timothy Loh
2015/04/23 05:42:03
Isn't this just the same as the other branch?
sashab
2015/04/23 05:59:05
Oh, nice. Good point :D
| |
| 292 } else { | |
| 293 *toReplace = property; | |
| 294 } | |
| 280 return true; | 295 return true; |
| 281 } | 296 } |
| 282 } | 297 } |
| 283 m_propertyVector.append(property); | 298 m_propertyVector.append(property); |
| 284 return true; | 299 return true; |
| 285 } | 300 } |
| 286 | 301 |
| 287 bool MutableStylePropertySet::setProperty(CSSPropertyID propertyID, CSSValueID i dentifier, bool important) | 302 bool MutableStylePropertySet::setProperty(CSSPropertyID propertyID, CSSValueID i dentifier, bool important) |
| 288 { | 303 { |
| 289 setProperty(CSSProperty(propertyID, cssValuePool().createIdentifierValue(ide ntifier), important)); | 304 setProperty(CSSProperty(propertyID, cssValuePool().createIdentifierValue(ide ntifier), important)); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 307 { | 322 { |
| 308 bool changed = false; | 323 bool changed = false; |
| 309 m_propertyVector.reserveCapacity(m_propertyVector.size() + properties.size() ); | 324 m_propertyVector.reserveCapacity(m_propertyVector.size() + properties.size() ); |
| 310 for (unsigned i = 0; i < properties.size(); ++i) | 325 for (unsigned i = 0; i < properties.size(); ++i) |
| 311 changed |= addParsedProperty(properties[i]); | 326 changed |= addParsedProperty(properties[i]); |
| 312 return changed; | 327 return changed; |
| 313 } | 328 } |
| 314 | 329 |
| 315 bool MutableStylePropertySet::addParsedProperty(const CSSProperty& property) | 330 bool MutableStylePropertySet::addParsedProperty(const CSSProperty& property) |
| 316 { | 331 { |
| 317 // Only add properties that have no !important counterpart present | 332 return setProperty(property); |
| 318 if (!propertyIsImportant(property.id()) || property.isImportant()) | |
| 319 return setProperty(property); | |
| 320 return false; | |
| 321 } | 333 } |
| 322 | 334 |
| 323 String StylePropertySet::asText() const | 335 String StylePropertySet::asText() const |
| 324 { | 336 { |
| 325 return StylePropertySerializer(*this).asText(); | 337 return StylePropertySerializer(*this).asText(); |
| 326 } | 338 } |
| 327 | 339 |
| 328 void MutableStylePropertySet::mergeAndOverrideOnConflict(const StylePropertySet* other) | 340 void MutableStylePropertySet::mergeAndOverrideOnConflict(const StylePropertySet* other) |
| 329 { | 341 { |
| 330 unsigned size = other->propertyCount(); | 342 unsigned size = other->propertyCount(); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 566 result.appendLiteral(": "); | 578 result.appendLiteral(": "); |
| 567 result.append(propertyValue()->cssText()); | 579 result.append(propertyValue()->cssText()); |
| 568 if (isImportant()) | 580 if (isImportant()) |
| 569 result.appendLiteral(" !important"); | 581 result.appendLiteral(" !important"); |
| 570 result.append(';'); | 582 result.append(';'); |
| 571 return result.toString(); | 583 return result.toString(); |
| 572 } | 584 } |
| 573 | 585 |
| 574 | 586 |
| 575 } // namespace blink | 587 } // namespace blink |
| OLD | NEW |