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

Side by Side Diff: third_party/WebKit/Source/core/css/StylePropertySerializer.cpp

Issue 1405293012: [Variables] Enable get/setProperty and similar APIs from the CSSOM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use static_assert. Created 5 years 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
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 Apple Inc. All r ights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights 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.
11 * 11 *
12 * This library is distributed in the hope that it will be useful, 12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details. 15 * Library General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU Library General Public License 17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to 18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA. 20 * Boston, MA 02110-1301, USA.
21 */ 21 */
22 22
23 #include "config.h" 23 #include "config.h"
24 #include "core/css/StylePropertySerializer.h" 24 #include "core/css/StylePropertySerializer.h"
25 25
26 #include "core/CSSValueKeywords.h" 26 #include "core/CSSValueKeywords.h"
27 #include "core/StylePropertyShorthand.h" 27 #include "core/StylePropertyShorthand.h"
28 #include "core/css/CSSCustomPropertyDeclaration.h"
28 #include "core/css/CSSPropertyMetadata.h" 29 #include "core/css/CSSPropertyMetadata.h"
29 #include "core/css/CSSValuePool.h" 30 #include "core/css/CSSValuePool.h"
30 #include "wtf/BitArray.h" 31 #include "wtf/BitArray.h"
31 #include "wtf/text/StringBuilder.h" 32 #include "wtf/text/StringBuilder.h"
32 33
33 namespace blink { 34 namespace blink {
34 35
35 static bool isInitialOrInherit(const String& value) 36 static bool isInitialOrInherit(const String& value)
36 { 37 {
37 DEFINE_STATIC_LOCAL(String, initial, ("initial")); 38 DEFINE_STATIC_LOCAL(String, initial, ("initial"));
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 return false; 170 return false;
170 StylePropertySerializer::PropertyValueForSerializer value = propertyAt(index ); 171 StylePropertySerializer::PropertyValueForSerializer value = propertyAt(index );
171 return value.isImportant(); 172 return value.isImportant();
172 } 173 }
173 174
174 StylePropertySerializer::StylePropertySerializer(const StylePropertySet& propert ies) 175 StylePropertySerializer::StylePropertySerializer(const StylePropertySet& propert ies)
175 : m_propertySet(properties) 176 : m_propertySet(properties)
176 { 177 {
177 } 178 }
178 179
180 String StylePropertySerializer::getCustomPropertyText(const PropertyValueForSeri alizer& property, bool isNotFirstDecl) const
181 {
182 ASSERT(property.id() == CSSPropertyVariable);
183 StringBuilder result;
184 if (isNotFirstDecl)
185 result.append(' ');
186 const CSSCustomPropertyDeclaration* value = toCSSCustomPropertyDeclaration(p roperty.value());
187 result.append(value->name());
188 result.appendLiteral(": ");
189 result.append(value->customCSSText());
190 if (property.isImportant())
191 result.appendLiteral(" !important");
192 result.append(';');
193 return result.toString();
194 }
195
179 String StylePropertySerializer::getPropertyText(CSSPropertyID propertyID, const String& value, bool isImportant, bool isNotFirstDecl) const 196 String StylePropertySerializer::getPropertyText(CSSPropertyID propertyID, const String& value, bool isImportant, bool isNotFirstDecl) const
180 { 197 {
181 StringBuilder result; 198 StringBuilder result;
182 if (isNotFirstDecl) 199 if (isNotFirstDecl)
183 result.append(' '); 200 result.append(' ');
184 result.append(getPropertyName(propertyID)); 201 result.append(getPropertyName(propertyID));
185 result.appendLiteral(": "); 202 result.appendLiteral(": ");
186 result.append(value); 203 result.append(value);
187 if (isImportant) 204 if (isImportant)
188 result.appendLiteral(" !important"); 205 result.appendLiteral(" !important");
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 case CSSPropertyWebkitMaskPositionY: 353 case CSSPropertyWebkitMaskPositionY:
337 case CSSPropertyWebkitMaskRepeatX: 354 case CSSPropertyWebkitMaskRepeatX:
338 case CSSPropertyWebkitMaskRepeatY: 355 case CSSPropertyWebkitMaskRepeatY:
339 case CSSPropertyWebkitMaskImage: 356 case CSSPropertyWebkitMaskImage:
340 case CSSPropertyWebkitMaskRepeat: 357 case CSSPropertyWebkitMaskRepeat:
341 case CSSPropertyWebkitMaskPosition: 358 case CSSPropertyWebkitMaskPosition:
342 case CSSPropertyWebkitMaskClip: 359 case CSSPropertyWebkitMaskClip:
343 case CSSPropertyWebkitMaskOrigin: 360 case CSSPropertyWebkitMaskOrigin:
344 shorthandPropertyID = CSSPropertyWebkitMask; 361 shorthandPropertyID = CSSPropertyWebkitMask;
345 break; 362 break;
363 case CSSPropertyVariable:
364 result.append(getCustomPropertyText(property, numDecls++));
365 continue;
346 case CSSPropertyAll: 366 case CSSPropertyAll:
347 result.append(getPropertyText(propertyID, property.value()->cssText( ), property.isImportant(), numDecls++)); 367 result.append(getPropertyText(propertyID, property.value()->cssText( ), property.isImportant(), numDecls++));
348 continue; 368 continue;
349 default: 369 default:
350 break; 370 break;
351 } 371 }
352 372
353 unsigned shortPropertyIndex = shorthandPropertyID - firstCSSProperty; 373 unsigned shortPropertyIndex = shorthandPropertyID - firstCSSProperty;
354 if (shorthandPropertyID) { 374 if (shorthandPropertyID) {
355 if (shorthandPropertyUsed.get(shortPropertyIndex)) 375 if (shorthandPropertyUsed.get(shortPropertyIndex))
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 isInitialValue = false; 991 isInitialValue = false;
972 if (!value->isInheritedValue()) 992 if (!value->isInheritedValue())
973 isInheritedValue = false; 993 isInheritedValue = false;
974 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie s()[i])) 994 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie s()[i]))
975 return false; 995 return false;
976 } 996 }
977 return isInitialValue || isInheritedValue; 997 return isInitialValue || isInheritedValue;
978 } 998 }
979 999
980 } 1000 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/StylePropertySerializer.h ('k') | third_party/WebKit/Source/core/css/StylePropertySet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698