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

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

Issue 1249553002: CSSValue Immediates: Add move operators to CSSPrimitiveValue (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cssvalue_patch_3_tagged_ptrs_with_copy_ops_mv_operators_ref_primvalue
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/CSSParser.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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 m_propertyVector = toMutableStylePropertySet(other).m_propertyVector; 130 m_propertyVector = toMutableStylePropertySet(other).m_propertyVector;
131 } else { 131 } else {
132 m_propertyVector.reserveInitialCapacity(other.propertyCount()); 132 m_propertyVector.reserveInitialCapacity(other.propertyCount());
133 for (unsigned i = 0; i < other.propertyCount(); ++i) 133 for (unsigned i = 0; i < other.propertyCount(); ++i)
134 m_propertyVector.uncheckedAppend(other.propertyAt(i).toCSSProperty() ); 134 m_propertyVector.uncheckedAppend(other.propertyAt(i).toCSSProperty() );
135 } 135 }
136 } 136 }
137 137
138 String StylePropertySet::getPropertyValue(CSSPropertyID propertyID) const 138 String StylePropertySet::getPropertyValue(CSSPropertyID propertyID) const
139 { 139 {
140 NullableCSSValue value = getPropertyCSSValue(propertyID); 140 const NullableCSSValue& value = getPropertyCSSValue(propertyID);
141 if (value) 141 if (value)
142 return value->cssText(); 142 return value->cssText();
143 143
144 return StylePropertySerializer(*this).getPropertyValue(propertyID); 144 return StylePropertySerializer(*this).getPropertyValue(propertyID);
145 } 145 }
146 146
147 NullableCSSValue StylePropertySet::getPropertyCSSValue(CSSPropertyID propertyID) const 147 const NullableCSSValue StylePropertySet::getPropertyCSSValue(CSSPropertyID prope rtyID) const
148 { 148 {
149 int foundPropertyIndex = findPropertyIndex(propertyID); 149 int foundPropertyIndex = findPropertyIndex(propertyID);
150 if (foundPropertyIndex == -1) 150 if (foundPropertyIndex == -1)
151 return nullptr; 151 return nullptr;
152 return propertyAt(foundPropertyIndex).value(); 152 return *reinterpret_cast<const NullableCSSValue*>(&propertyAt(foundPropertyI ndex).value());
153 } 153 }
154 154
155 DEFINE_TRACE(StylePropertySet) 155 DEFINE_TRACE(StylePropertySet)
156 { 156 {
157 if (m_isMutable) 157 if (m_isMutable)
158 toMutableStylePropertySet(this)->traceAfterDispatch(visitor); 158 toMutableStylePropertySet(this)->traceAfterDispatch(visitor);
159 else 159 else
160 toImmutableStylePropertySet(this)->traceAfterDispatch(visitor); 160 toImmutableStylePropertySet(this)->traceAfterDispatch(visitor);
161 } 161 }
162 162
(...skipping 80 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, const CSSPri mitiveValue& prpValue, bool important)
254 {
255 setProperty(propertyID, *reinterpret_cast<const CSSValue*>(&prpValue), impor tant);
256 }
257
253 void MutableStylePropertySet::setProperty(CSSPropertyID propertyID, const CSSVal ue& prpValue, bool important) 258 void MutableStylePropertySet::setProperty(CSSPropertyID propertyID, const CSSVal ue& prpValue, bool important)
254 { 259 {
255 StylePropertyShorthand shorthand = shorthandForProperty(propertyID); 260 StylePropertyShorthand shorthand = shorthandForProperty(propertyID);
256 if (!shorthand.length()) { 261 if (!shorthand.length()) {
257 setProperty(CSSProperty(propertyID, prpValue, important)); 262 setProperty(CSSProperty(propertyID, prpValue, important));
258 return; 263 return;
259 } 264 }
260 265
261 removePropertiesInSet(shorthand.properties(), shorthand.length()); 266 removePropertiesInSet(shorthand.properties(), shorthand.length());
262 267
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 PassRefPtrWillBeRawPtr<MutableStylePropertySet> StylePropertySet::mutableCopy() const 432 PassRefPtrWillBeRawPtr<MutableStylePropertySet> StylePropertySet::mutableCopy() const
428 { 433 {
429 return adoptRefWillBeNoop(new MutableStylePropertySet(*this)); 434 return adoptRefWillBeNoop(new MutableStylePropertySet(*this));
430 } 435 }
431 436
432 PassRefPtrWillBeRawPtr<MutableStylePropertySet> StylePropertySet::copyProperties InSet(const Vector<CSSPropertyID>& properties) const 437 PassRefPtrWillBeRawPtr<MutableStylePropertySet> StylePropertySet::copyProperties InSet(const Vector<CSSPropertyID>& properties) const
433 { 438 {
434 WillBeHeapVector<CSSProperty, 256> list; 439 WillBeHeapVector<CSSProperty, 256> list;
435 list.reserveInitialCapacity(properties.size()); 440 list.reserveInitialCapacity(properties.size());
436 for (unsigned i = 0; i < properties.size(); ++i) { 441 for (unsigned i = 0; i < properties.size(); ++i) {
437 NullableCSSValue value = getPropertyCSSValue(properties[i]); 442 const NullableCSSValue& value = getPropertyCSSValue(properties[i]);
438 if (value) 443 if (value)
439 list.append(CSSProperty(properties[i], *value, false)); 444 list.append(CSSProperty(properties[i], *value, false));
440 } 445 }
441 return MutableStylePropertySet::create(list.data(), list.size()); 446 return MutableStylePropertySet::create(list.data(), list.size());
442 } 447 }
443 448
444 CSSStyleDeclaration* MutableStylePropertySet::ensureCSSStyleDeclaration() 449 CSSStyleDeclaration* MutableStylePropertySet::ensureCSSStyleDeclaration()
445 { 450 {
446 // FIXME: get rid of this weirdness of a CSSStyleDeclaration inside of a 451 // FIXME: get rid of this weirdness of a CSSStyleDeclaration inside of a
447 // style property set. 452 // style property set.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 { 513 {
509 return adoptRefWillBeNoop(new MutableStylePropertySet(cssParserMode)); 514 return adoptRefWillBeNoop(new MutableStylePropertySet(cssParserMode));
510 } 515 }
511 516
512 PassRefPtrWillBeRawPtr<MutableStylePropertySet> MutableStylePropertySet::create( const CSSProperty* properties, unsigned count) 517 PassRefPtrWillBeRawPtr<MutableStylePropertySet> MutableStylePropertySet::create( const CSSProperty* properties, unsigned count)
513 { 518 {
514 return adoptRefWillBeNoop(new MutableStylePropertySet(properties, count)); 519 return adoptRefWillBeNoop(new MutableStylePropertySet(properties, count));
515 } 520 }
516 521
517 } // namespace blink 522 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/StylePropertySet.h ('k') | Source/core/css/parser/CSSParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698