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

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

Issue 1645433002: Basic implementation of @apply (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix expted.txt for failing test Created 4 years, 9 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
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.
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 const CSSCustomPropertyDeclaration* value = toCSSCustomPropertyDeclaration(p roperty.value()); 185 const CSSCustomPropertyDeclaration* value = toCSSCustomPropertyDeclaration(p roperty.value());
186 result.append(value->name()); 186 result.append(value->name());
187 result.append(':'); 187 result.append(':');
188 result.append(value->customCSSText()); 188 result.append(value->customCSSText());
189 if (property.isImportant()) 189 if (property.isImportant())
190 result.appendLiteral(" !important"); 190 result.appendLiteral(" !important");
191 result.append(';'); 191 result.append(';');
192 return result.toString(); 192 return result.toString();
193 } 193 }
194 194
195 static String getApplyAtRuleText(const CSSValue* value, bool isNotFirstDecl)
196 {
197 StringBuilder result;
198 if (isNotFirstDecl)
199 result.append(' ');
200 result.appendLiteral("@apply ");
201 result.append(toCSSCustomIdentValue(value)->value());
202 result.append(';');
203 return result.toString();
204 }
205
195 String StylePropertySerializer::getPropertyText(CSSPropertyID propertyID, const String& value, bool isImportant, bool isNotFirstDecl) const 206 String StylePropertySerializer::getPropertyText(CSSPropertyID propertyID, const String& value, bool isImportant, bool isNotFirstDecl) const
196 { 207 {
197 StringBuilder result; 208 StringBuilder result;
198 if (isNotFirstDecl) 209 if (isNotFirstDecl)
199 result.append(' '); 210 result.append(' ');
200 result.append(getPropertyName(propertyID)); 211 result.append(getPropertyName(propertyID));
201 result.appendLiteral(": "); 212 result.appendLiteral(": ");
202 result.append(value); 213 result.append(value);
203 if (isImportant) 214 if (isImportant)
204 result.appendLiteral(" !important"); 215 result.appendLiteral(" !important");
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 case CSSPropertyWebkitMaskClip: 371 case CSSPropertyWebkitMaskClip:
361 case CSSPropertyWebkitMaskOrigin: 372 case CSSPropertyWebkitMaskOrigin:
362 shorthandPropertyID = CSSPropertyWebkitMask; 373 shorthandPropertyID = CSSPropertyWebkitMask;
363 break; 374 break;
364 case CSSPropertyVariable: 375 case CSSPropertyVariable:
365 result.append(getCustomPropertyText(property, numDecls++)); 376 result.append(getCustomPropertyText(property, numDecls++));
366 continue; 377 continue;
367 case CSSPropertyAll: 378 case CSSPropertyAll:
368 result.append(getPropertyText(propertyID, property.value()->cssText( ), property.isImportant(), numDecls++)); 379 result.append(getPropertyText(propertyID, property.value()->cssText( ), property.isImportant(), numDecls++));
369 continue; 380 continue;
381 case CSSPropertyApplyAtRule:
382 result.append(getApplyAtRuleText(property.value(), numDecls++));
383 continue;
370 default: 384 default:
371 break; 385 break;
372 } 386 }
373 387
374 unsigned shortPropertyIndex = shorthandPropertyID - firstCSSProperty; 388 unsigned shortPropertyIndex = shorthandPropertyID - firstCSSProperty;
375 if (shorthandPropertyID) { 389 if (shorthandPropertyID) {
376 if (shorthandPropertyUsed.get(shortPropertyIndex)) 390 if (shorthandPropertyUsed.get(shortPropertyIndex))
377 continue; 391 continue;
378 if (!shorthandPropertyAppeared.get(shortPropertyIndex) && value.isNu ll()) 392 if (!shorthandPropertyAppeared.get(shortPropertyIndex) && value.isNu ll())
379 value = m_propertySet.getPropertyValue(shorthandPropertyID); 393 value = m_propertySet.getPropertyValue(shorthandPropertyID);
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 isInitialValue = false; 1010 isInitialValue = false;
997 if (!value->isInheritedValue()) 1011 if (!value->isInheritedValue())
998 isInheritedValue = false; 1012 isInheritedValue = false;
999 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie s()[i])) 1013 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie s()[i]))
1000 return false; 1014 return false;
1001 } 1015 }
1002 return isInitialValue || isInheritedValue; 1016 return isInitialValue || isInheritedValue;
1003 } 1017 }
1004 1018
1005 } // namespace blink 1019 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698