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 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 if (serializedAsShorthand) | 280 if (serializedAsShorthand) |
281 continue; | 281 continue; |
282 | 282 |
283 result.append(getPropertyText(propertyID, property.value()->cssText(), p
roperty.isImportant(), numDecls++)); | 283 result.append(getPropertyText(propertyID, property.value()->cssText(), p
roperty.isImportant(), numDecls++)); |
284 } | 284 } |
285 | 285 |
286 ASSERT(!numDecls ^ !result.isEmpty()); | 286 ASSERT(!numDecls ^ !result.isEmpty()); |
287 return result.toString(); | 287 return result.toString(); |
288 } | 288 } |
289 | 289 |
290 // As per css-cascade, shorthands do not expand longhands to the value | |
291 // "initial", except when the shorthand is set to "initial", instead | |
292 // setting "missing" sub-properties to their initial values. This means | |
293 // that a shorthand can never represent a list of subproperties where | |
294 // some are "initial" and some are not, and so serialization should | |
295 // always fail in these cases (as per cssom). However we currently use | |
296 // "initial" instead of the initial values for certain shorthands, so | |
297 // these are special-cased here. | |
298 // TODO(timloh): Don't use "initial" in shorthands and remove this | |
299 // special-casing | |
300 static bool allowInitialInShorthand(CSSPropertyID propertyID) | |
301 { | |
302 switch (propertyID) { | |
303 case CSSPropertyBorder: | |
304 case CSSPropertyBorderTop: | |
305 case CSSPropertyBorderRight: | |
306 case CSSPropertyBorderBottom: | |
307 case CSSPropertyBorderLeft: | |
308 case CSSPropertyOutline: | |
309 case CSSPropertyColumnRule: | |
310 case CSSPropertyColumns: | |
311 case CSSPropertyFlex: | |
312 case CSSPropertyFlexFlow: | |
313 case CSSPropertyGridColumn: | |
314 case CSSPropertyGridRow: | |
315 case CSSPropertyGridArea: | |
316 case CSSPropertyGridGap: | |
317 case CSSPropertyMotion: | |
318 case CSSPropertyWebkitMarginCollapse: | |
319 case CSSPropertyListStyle: | |
320 case CSSPropertyWebkitTextEmphasis: | |
321 case CSSPropertyWebkitTextStroke: | |
322 return true; | |
323 default: | |
324 return false; | |
325 } | |
326 } | |
327 | |
328 // TODO(timloh): This should go away eventually, see crbug.com/471917 | |
329 static bool allowImplicitInitialInShorthand(CSSPropertyID propertyID) | |
330 { | |
331 return propertyID == CSSPropertyBackground || propertyID == CSSPropertyWebki
tMask; | |
332 } | |
333 | |
334 String StylePropertySerializer::commonShorthandChecks(const StylePropertyShortha
nd& shorthand) const | 290 String StylePropertySerializer::commonShorthandChecks(const StylePropertyShortha
nd& shorthand) const |
335 { | 291 { |
336 int longhandCount = shorthand.length(); | 292 int longhandCount = shorthand.length(); |
337 DCHECK_LE(longhandCount, 17); | 293 DCHECK_LE(longhandCount, 17); |
338 const CSSValue* longhands[17] = {}; | 294 const CSSValue* longhands[17] = {}; |
339 | 295 |
340 bool hasImportant = false; | 296 bool hasImportant = false; |
341 bool hasNonImportant = false; | 297 bool hasNonImportant = false; |
342 | 298 |
343 for (int i = 0; i < longhandCount; i++) { | 299 for (int i = 0; i < longhandCount; i++) { |
(...skipping 22 matching lines...) Expand all Loading... |
366 break; | 322 break; |
367 } | 323 } |
368 } | 324 } |
369 if (success) { | 325 if (success) { |
370 if (longhands[0]->isPendingSubstitutionValue()) | 326 if (longhands[0]->isPendingSubstitutionValue()) |
371 return toCSSPendingSubstitutionValue(longhands[0])->shorthandVal
ue()->cssText(); | 327 return toCSSPendingSubstitutionValue(longhands[0])->shorthandVal
ue()->cssText(); |
372 return longhands[0]->cssText(); | 328 return longhands[0]->cssText(); |
373 } | 329 } |
374 } | 330 } |
375 | 331 |
376 bool allowInitial = allowInitialInShorthand(shorthand.id()); | 332 bool allowInitial = false; |
377 bool allowImplicitInitial = allowInitial || allowImplicitInitialInShorthand(
shorthand.id()); | 333 bool allowImplicitInitial = true; |
378 for (int i = 0; i < longhandCount; i++) { | 334 for (int i = 0; i < longhandCount; i++) { |
379 const CSSValue& value = *longhands[i]; | 335 const CSSValue& value = *longhands[i]; |
380 if (value.isImplicitInitialValue()) { | 336 if (value.isImplicitInitialValue()) { |
381 if (allowImplicitInitial) | 337 if (allowImplicitInitial) |
382 continue; | 338 continue; |
383 return emptyString(); | 339 return emptyString(); |
384 } | 340 } |
385 if (!allowInitial && value.isInitialValue()) | 341 if (!allowInitial && value.isInitialValue()) |
386 return emptyString(); | 342 return emptyString(); |
387 // TODO(timloh): This should also check unset | 343 // TODO(timloh): This should also check unset |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 builder.append(", "); | 826 builder.append(", "); |
871 | 827 |
872 const CSSValue& xValue = repeatXList ? repeatXList->item(i % repeatXList
->length()) : repeatX; | 828 const CSSValue& xValue = repeatXList ? repeatXList->item(i % repeatXList
->length()) : repeatX; |
873 const CSSValue& yValue = repeatYList ? repeatYList->item(i % repeatYList
->length()) : repeatY; | 829 const CSSValue& yValue = repeatYList ? repeatYList->item(i % repeatYList
->length()) : repeatY; |
874 appendBackgroundRepeatValue(builder, xValue, yValue); | 830 appendBackgroundRepeatValue(builder, xValue, yValue); |
875 } | 831 } |
876 return builder.toString(); | 832 return builder.toString(); |
877 } | 833 } |
878 | 834 |
879 } // namespace blink | 835 } // namespace blink |
OLD | NEW |