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()) |
Timothy Loh
2016/06/22 00:06:11
Probably need to also check for pending substituti
Andy Mutton
2016/06/24 04:53:26
Done.
| |
402 return emptyString(); | 407 return emptyString(); |
403 } | 408 } |
404 | 409 |
405 return String(); | 410 return String(); |
406 } | 411 } |
407 | 412 |
408 String StylePropertySerializer::getPropertyValue(CSSPropertyID propertyID) const | 413 String StylePropertySerializer::getPropertyValue(CSSPropertyID propertyID) const |
409 { | 414 { |
410 const StylePropertyShorthand& shorthand = shorthandForProperty(propertyID); | 415 const StylePropertyShorthand& shorthand = shorthandForProperty(propertyID); |
411 // TODO(timloh): This is weird, why do we call this with non-shorthands at a ll? | 416 // TODO(timloh): This is weird, why do we call this with non-shorthands at a ll? |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
668 { | 673 { |
669 const unsigned size = shorthand.length(); | 674 const unsigned size = shorthand.length(); |
670 | 675 |
671 // Begin by collecting the properties into a vector. | 676 // Begin by collecting the properties into a vector. |
672 HeapVector<Member<const CSSValue>> values(size); | 677 HeapVector<Member<const CSSValue>> values(size); |
673 // If the below loop succeeds, there should always be at minimum 1 layer. | 678 // If the below loop succeeds, there should always be at minimum 1 layer. |
674 size_t numLayers = 1U; | 679 size_t numLayers = 1U; |
675 | 680 |
676 for (size_t i = 0; i < size; i++) { | 681 for (size_t i = 0; i < size; i++) { |
677 values[i] = m_propertySet.getPropertyCSSValue(shorthand.properties()[i]) ; | 682 values[i] = m_propertySet.getPropertyCSSValue(shorthand.properties()[i]) ; |
683 | |
678 if (values[i]->isBaseValueList()) { | 684 if (values[i]->isBaseValueList()) { |
679 const CSSValueList* valueList = toCSSValueList(values[i]); | 685 const CSSValueList* valueList = toCSSValueList(values[i]); |
680 numLayers = std::max(numLayers, valueList->length()); | 686 numLayers = std::max(numLayers, valueList->length()); |
681 } | 687 } |
682 } | 688 } |
683 | 689 |
684 StringBuilder result; | 690 StringBuilder result; |
685 | 691 |
686 // Now stitch the properties together. Implicit initial values are flagged a s such and | 692 // Now stitch the properties together. Implicit initial values are flagged a s such and |
687 // can safely be omitted. | 693 // can safely be omitted. |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
881 builder.append(", "); | 887 builder.append(", "); |
882 | 888 |
883 const CSSValue& xValue = repeatXList ? repeatXList->item(i % repeatXList ->length()) : repeatX; | 889 const CSSValue& xValue = repeatXList ? repeatXList->item(i % repeatXList ->length()) : repeatX; |
884 const CSSValue& yValue = repeatYList ? repeatYList->item(i % repeatYList ->length()) : repeatY; | 890 const CSSValue& yValue = repeatYList ? repeatYList->item(i % repeatYList ->length()) : repeatY; |
885 appendBackgroundRepeatValue(builder, xValue, yValue); | 891 appendBackgroundRepeatValue(builder, xValue, yValue); |
886 } | 892 } |
887 return builder.toString(); | 893 return builder.toString(); |
888 } | 894 } |
889 | 895 |
890 } // namespace blink | 896 } // namespace blink |
OLD | NEW |