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

Side by Side Diff: Source/core/css/StylePropertySet.cpp

Issue 1238943004: CSSValue Immediates: Replace CSSValue usage with const references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cssvalue_patch_1
Patch Set: Rebase Created 5 years, 4 months 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/core/css/StylePropertySet.h ('k') | Source/core/css/parser/CSSPropertyParser.cpp » ('j') | 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 * (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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 // Setting the value to an empty string just removes the property in both IE and Gecko. 243 // Setting the value to an empty string just removes the property in both IE and Gecko.
244 // Setting it to null seems to produce less consistent results, but we treat it just the same. 244 // Setting it to null seems to produce less consistent results, but we treat it just the same.
245 if (value.isEmpty()) 245 if (value.isEmpty())
246 return removeProperty(resolveCSSPropertyID(unresolvedProperty)); 246 return removeProperty(resolveCSSPropertyID(unresolvedProperty));
247 247
248 // When replacing an existing property value, this moves the property to the end of the list. 248 // When replacing an existing property value, this moves the property to the end of the list.
249 // Firefox preserves the position, and MSIE moves the property to the beginn ing. 249 // Firefox preserves the position, and MSIE moves the property to the beginn ing.
250 return CSSParser::parseValue(this, unresolvedProperty, value, important, css ParserMode(), contextStyleSheet); 250 return CSSParser::parseValue(this, unresolvedProperty, value, important, css ParserMode(), contextStyleSheet);
251 } 251 }
252 252
253 void MutableStylePropertySet::setProperty(CSSPropertyID propertyID, CSSValue prp Value, bool important) 253 void MutableStylePropertySet::setProperty(CSSPropertyID propertyID, const CSSVal ue& prpValue, bool important)
254 { 254 {
255 StylePropertyShorthand shorthand = shorthandForProperty(propertyID); 255 StylePropertyShorthand shorthand = shorthandForProperty(propertyID);
256 if (!shorthand.length()) { 256 if (!shorthand.length()) {
257 setProperty(CSSProperty(propertyID, prpValue, important)); 257 setProperty(CSSProperty(propertyID, prpValue, important));
258 return; 258 return;
259 } 259 }
260 260
261 removePropertiesInSet(shorthand.properties(), shorthand.length()); 261 removePropertiesInSet(shorthand.properties(), shorthand.length());
262 262
263 CSSValue value = prpValue; 263 const CSSValue& value = prpValue;
264 for (unsigned i = 0; i < shorthand.length(); ++i) 264 for (unsigned i = 0; i < shorthand.length(); ++i)
265 m_propertyVector.append(CSSProperty(shorthand.properties()[i], value, im portant)); 265 m_propertyVector.append(CSSProperty(shorthand.properties()[i], value, im portant));
266 } 266 }
267 267
268 bool MutableStylePropertySet::setProperty(const CSSProperty& property, CSSProper ty* slot) 268 bool MutableStylePropertySet::setProperty(const CSSProperty& property, CSSProper ty* slot)
269 { 269 {
270 if (!removeShorthandProperty(property.id())) { 270 if (!removeShorthandProperty(property.id())) {
271 CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id ()); 271 CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id ());
272 if (toReplace && *toReplace == property) 272 if (toReplace && *toReplace == property)
273 return false; 273 return false;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 381 }
382 382
383 CSSProperty* MutableStylePropertySet::findCSSPropertyWithID(CSSPropertyID proper tyID) 383 CSSProperty* MutableStylePropertySet::findCSSPropertyWithID(CSSPropertyID proper tyID)
384 { 384 {
385 int foundPropertyIndex = findPropertyIndex(propertyID); 385 int foundPropertyIndex = findPropertyIndex(propertyID);
386 if (foundPropertyIndex == -1) 386 if (foundPropertyIndex == -1)
387 return 0; 387 return 0;
388 return &m_propertyVector.at(foundPropertyIndex); 388 return &m_propertyVector.at(foundPropertyIndex);
389 } 389 }
390 390
391 bool StylePropertySet::propertyMatches(CSSPropertyID propertyID, const CSSValue propertyValue) const 391 bool StylePropertySet::propertyMatches(CSSPropertyID propertyID, const CSSValue& propertyValue) const
392 { 392 {
393 int foundPropertyIndex = findPropertyIndex(propertyID); 393 int foundPropertyIndex = findPropertyIndex(propertyID);
394 if (foundPropertyIndex == -1) 394 if (foundPropertyIndex == -1)
395 return false; 395 return false;
396 return propertyAt(foundPropertyIndex).value().equals(propertyValue); 396 return propertyAt(foundPropertyIndex).value().equals(propertyValue);
397 } 397 }
398 398
399 void MutableStylePropertySet::removeEquivalentProperties(const StylePropertySet* style) 399 void MutableStylePropertySet::removeEquivalentProperties(const StylePropertySet* style)
400 { 400 {
401 Vector<CSSPropertyID> propertiesToRemove; 401 Vector<CSSPropertyID> propertiesToRemove;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 { 508 {
509 return adoptRefWillBeNoop(new MutableStylePropertySet(cssParserMode)); 509 return adoptRefWillBeNoop(new MutableStylePropertySet(cssParserMode));
510 } 510 }
511 511
512 PassRefPtrWillBeRawPtr<MutableStylePropertySet> MutableStylePropertySet::create( const CSSProperty* properties, unsigned count) 512 PassRefPtrWillBeRawPtr<MutableStylePropertySet> MutableStylePropertySet::create( const CSSProperty* properties, unsigned count)
513 { 513 {
514 return adoptRefWillBeNoop(new MutableStylePropertySet(properties, count)); 514 return adoptRefWillBeNoop(new MutableStylePropertySet(properties, count));
515 } 515 }
516 516
517 } // namespace blink 517 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/StylePropertySet.h ('k') | Source/core/css/parser/CSSPropertyParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698