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. |
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 "core/css/StylePropertySerializer.h" | 23 #include "core/css/StylePropertySerializer.h" |
24 | 24 |
25 #include "core/CSSValueKeywords.h" | 25 #include "core/CSSValueKeywords.h" |
26 #include "core/StylePropertyShorthand.h" | 26 #include "core/StylePropertyShorthand.h" |
27 #include "core/css/CSSCustomPropertyDeclaration.h" | 27 #include "core/css/CSSCustomPropertyDeclaration.h" |
| 28 #include "core/css/CSSPendingSubstitutionValue.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/StdLibExtras.h" | 31 #include "wtf/StdLibExtras.h" |
31 #include "wtf/text/StringBuilder.h" | 32 #include "wtf/text/StringBuilder.h" |
32 #include <bitset> | 33 #include <bitset> |
33 | 34 |
34 namespace blink { | 35 namespace blink { |
35 | 36 |
36 StylePropertySerializer::StylePropertySetForSerializer::StylePropertySetForSeria
lizer(const StylePropertySet& properties) | 37 StylePropertySerializer::StylePropertySetForSerializer::StylePropertySetForSeria
lizer(const StylePropertySet& properties) |
37 : m_propertySet(&properties) | 38 : m_propertySet(&properties) |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 | 366 |
366 hasImportant |= value.isImportant(); | 367 hasImportant |= value.isImportant(); |
367 hasNonImportant |= !value.isImportant(); | 368 hasNonImportant |= !value.isImportant(); |
368 longhands[i] = value.value(); | 369 longhands[i] = value.value(); |
369 } | 370 } |
370 | 371 |
371 if (hasImportant && hasNonImportant) | 372 if (hasImportant && hasNonImportant) |
372 return emptyString(); | 373 return emptyString(); |
373 | 374 |
374 // TODO(timloh): This should be isCSSWideKeyword() | 375 // TODO(timloh): This should be isCSSWideKeyword() |
375 if (longhands[0]->isInitialValue() || longhands[0]->isInheritedValue()) { | 376 if (longhands[0]->isInitialValue() || longhands[0]->isInheritedValue() |
| 377 || longhands[0]->isPendingSubstitutionValue()) { |
376 bool success = true; | 378 bool success = true; |
377 for (int i = 1; i < longhandCount; i++) { | 379 for (int i = 1; i < longhandCount; i++) { |
378 if (!longhands[i]->equals(*longhands[0])) { | 380 if (!longhands[i]->equals(*longhands[0])) { |
379 // This should just return emptyString() but some shorthands cur
rently | 381 // This should just return emptyString() but some shorthands cur
rently |
380 // allow 'initial' for their longhands. | 382 // allow 'initial' for their longhands. |
381 success = false; | 383 success = false; |
382 break; | 384 break; |
383 } | 385 } |
384 } | 386 } |
385 if (success) | 387 if (success) { |
| 388 if (longhands[0]->isPendingSubstitutionValue()) |
| 389 return toCSSPendingSubstitutionValue(longhands[0])->shorthandVal
ue()->cssText(); |
386 return longhands[0]->cssText(); | 390 return longhands[0]->cssText(); |
| 391 } |
387 } | 392 } |
388 | 393 |
389 bool allowInitial = allowInitialInShorthand(shorthand.id()); | 394 bool allowInitial = allowInitialInShorthand(shorthand.id()); |
390 bool allowImplicitInitial = allowInitial || allowImplicitInitialInShorthand(
shorthand.id()); | 395 bool allowImplicitInitial = allowInitial || allowImplicitInitialInShorthand(
shorthand.id()); |
391 for (int i = 0; i < longhandCount; i++) { | 396 for (int i = 0; i < longhandCount; i++) { |
392 const CSSValue& value = *longhands[i]; | 397 const CSSValue& value = *longhands[i]; |
393 if (value.isImplicitInitialValue()) { | 398 if (value.isImplicitInitialValue()) { |
394 if (allowImplicitInitial) | 399 if (allowImplicitInitial) |
395 continue; | 400 continue; |
396 return emptyString(); | 401 return emptyString(); |
397 } | 402 } |
398 if (!allowInitial && value.isInitialValue()) | 403 if (!allowInitial && value.isInitialValue()) |
399 return emptyString(); | 404 return emptyString(); |
400 // TODO(timloh): This should also check unset | 405 // TODO(timloh): This should also check unset |
401 if (value.isInheritedValue()) | 406 if (value.isInheritedValue() || value.isPendingSubstitutionValue()) |
402 return emptyString(); | 407 return emptyString(); |
403 if (value.isVariableReferenceValue()) | 408 if (value.isVariableReferenceValue()) |
404 return emptyString(); | 409 return emptyString(); |
405 } | 410 } |
406 | 411 |
407 return String(); | 412 return String(); |
408 } | 413 } |
409 | 414 |
410 String StylePropertySerializer::getPropertyValue(CSSPropertyID propertyID) const | 415 String StylePropertySerializer::getPropertyValue(CSSPropertyID propertyID) const |
411 { | 416 { |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 builder.append(", "); | 888 builder.append(", "); |
884 | 889 |
885 const CSSValue& xValue = repeatXList ? repeatXList->item(i % repeatXList
->length()) : repeatX; | 890 const CSSValue& xValue = repeatXList ? repeatXList->item(i % repeatXList
->length()) : repeatX; |
886 const CSSValue& yValue = repeatYList ? repeatYList->item(i % repeatYList
->length()) : repeatY; | 891 const CSSValue& yValue = repeatYList ? repeatYList->item(i % repeatYList
->length()) : repeatY; |
887 appendBackgroundRepeatValue(builder, xValue, yValue); | 892 appendBackgroundRepeatValue(builder, xValue, yValue); |
888 } | 893 } |
889 return builder.toString(); | 894 return builder.toString(); |
890 } | 895 } |
891 | 896 |
892 } // namespace blink | 897 } // namespace blink |
OLD | NEW |