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

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

Issue 1233363002: CSSValue Immediates: Replace CSSPrimitiveValue usage with const references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cssvalue_patch_4_attempt_2
Patch Set: Rebase Created 5 years, 4 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
« no previous file with comments | « Source/core/css/StylePropertySerializer.h ('k') | Source/core/css/StylePropertySet.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 return nullptr; 135 return nullptr;
136 StylePropertySerializer::PropertyValueForSerializer value = propertyAt(index ); 136 StylePropertySerializer::PropertyValueForSerializer value = propertyAt(index );
137 return value.value(); 137 return value.value();
138 } 138 }
139 139
140 String StylePropertySerializer::StylePropertySetForSerializer::getPropertyValue( CSSPropertyID propertyID) const 140 String StylePropertySerializer::StylePropertySetForSerializer::getPropertyValue( CSSPropertyID propertyID) const
141 { 141 {
142 if (!hasExpandedAllProperty()) 142 if (!hasExpandedAllProperty())
143 return m_propertySet.getPropertyValue(propertyID); 143 return m_propertySet.getPropertyValue(propertyID);
144 144
145 const NullableCSSValue value = getPropertyCSSValue(propertyID); 145 const NullableCSSValue& value = getPropertyCSSValue(propertyID);
146 if (!value) 146 if (!value)
147 return String(); 147 return String();
148 return value->cssText(); 148 return value->cssText();
149 } 149 }
150 150
151 bool StylePropertySerializer::StylePropertySetForSerializer::isPropertyImplicit( CSSPropertyID propertyID) const 151 bool StylePropertySerializer::StylePropertySetForSerializer::isPropertyImplicit( CSSPropertyID propertyID) const
152 { 152 {
153 int index = findPropertyIndex(propertyID); 153 int index = findPropertyIndex(propertyID);
154 if (index == -1) 154 if (index == -1)
155 return false; 155 return false;
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 return getLayeredShorthandValue(webkitMaskPositionShorthand()); 442 return getLayeredShorthandValue(webkitMaskPositionShorthand());
443 case CSSPropertyWebkitMaskRepeat: 443 case CSSPropertyWebkitMaskRepeat:
444 return getLayeredShorthandValue(webkitMaskRepeatShorthand()); 444 return getLayeredShorthandValue(webkitMaskRepeatShorthand());
445 case CSSPropertyWebkitMask: 445 case CSSPropertyWebkitMask:
446 return getLayeredShorthandValue(webkitMaskShorthand()); 446 return getLayeredShorthandValue(webkitMaskShorthand());
447 case CSSPropertyWebkitTextEmphasis: 447 case CSSPropertyWebkitTextEmphasis:
448 return getShorthandValue(webkitTextEmphasisShorthand()); 448 return getShorthandValue(webkitTextEmphasisShorthand());
449 case CSSPropertyWebkitTextStroke: 449 case CSSPropertyWebkitTextStroke:
450 return getShorthandValue(webkitTextStrokeShorthand()); 450 return getShorthandValue(webkitTextStrokeShorthand());
451 case CSSPropertyMarker: { 451 case CSSPropertyMarker: {
452 if (const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSS PropertyMarkerStart)) 452 if (const NullableCSSValue& value = m_propertySet.getPropertyCSSValue(CS SPropertyMarkerStart))
453 return value->cssText(); 453 return value->cssText();
454 return String(); 454 return String();
455 } 455 }
456 case CSSPropertyBorderRadius: 456 case CSSPropertyBorderRadius:
457 return get4Values(borderRadiusShorthand()); 457 return get4Values(borderRadiusShorthand());
458 default: 458 default:
459 return String(); 459 return String();
460 } 460 }
461 } 461 }
462 462
463 String StylePropertySerializer::borderSpacingValue(const StylePropertyShorthand& shorthand) const 463 String StylePropertySerializer::borderSpacingValue(const StylePropertyShorthand& shorthand) const
464 { 464 {
465 const NullableCSSValue horizontalValue = m_propertySet.getPropertyCSSValue(s horthand.properties()[0]); 465 const NullableCSSValue& horizontalValue = m_propertySet.getPropertyCSSValue( shorthand.properties()[0]);
466 const NullableCSSValue verticalValue = m_propertySet.getPropertyCSSValue(sho rthand.properties()[1]); 466 const NullableCSSValue& verticalValue = m_propertySet.getPropertyCSSValue(sh orthand.properties()[1]);
467 467
468 // While standard border-spacing property does not allow specifying border-s pacing-vertical without 468 // While standard border-spacing property does not allow specifying border-s pacing-vertical without
469 // specifying border-spacing-horizontal <http://www.w3.org/TR/CSS21/tables.h tml#separated-borders>, 469 // specifying border-spacing-horizontal <http://www.w3.org/TR/CSS21/tables.h tml#separated-borders>,
470 // -webkit-border-spacing-vertical can be set without -webkit-border-spacing -horizontal. 470 // -webkit-border-spacing-vertical can be set without -webkit-border-spacing -horizontal.
471 if (!horizontalValue || !verticalValue) 471 if (!horizontalValue || !verticalValue)
472 return String(); 472 return String();
473 473
474 String horizontalValueCSSText = horizontalValue->cssText(); 474 String horizontalValueCSSText = horizontalValue->cssText();
475 String verticalValueCSSText = verticalValue->cssText(); 475 String verticalValueCSSText = verticalValue->cssText();
476 if (horizontalValueCSSText == verticalValueCSSText) 476 if (horizontalValueCSSText == verticalValueCSSText)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 commonValue = String(); 515 commonValue = String();
516 } 516 }
517 517
518 String StylePropertySerializer::fontValue() const 518 String StylePropertySerializer::fontValue() const
519 { 519 {
520 int fontSizePropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFontS ize); 520 int fontSizePropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFontS ize);
521 int fontFamilyPropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFon tFamily); 521 int fontFamilyPropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFon tFamily);
522 if (fontSizePropertyIndex == -1 || fontFamilyPropertyIndex == -1) 522 if (fontSizePropertyIndex == -1 || fontFamilyPropertyIndex == -1)
523 return emptyString(); 523 return emptyString();
524 524
525 PropertyValueForSerializer fontSizeProperty = m_propertySet.propertyAt(fontS izePropertyIndex); 525 const PropertyValueForSerializer& fontSizeProperty = m_propertySet.propertyA t(fontSizePropertyIndex);
526 PropertyValueForSerializer fontFamilyProperty = m_propertySet.propertyAt(fon tFamilyPropertyIndex); 526 const PropertyValueForSerializer& fontFamilyProperty = m_propertySet.propert yAt(fontFamilyPropertyIndex);
527 527
528 String commonValue = fontSizeProperty.value().cssText(); 528 String commonValue = fontSizeProperty.value().cssText();
529 StringBuilder result; 529 StringBuilder result;
530 appendFontLonghandValueIfNotNormal(CSSPropertyFontStyle, result, commonValue ); 530 appendFontLonghandValueIfNotNormal(CSSPropertyFontStyle, result, commonValue );
531 appendFontLonghandValueIfNotNormal(CSSPropertyFontVariant, result, commonVal ue); 531 appendFontLonghandValueIfNotNormal(CSSPropertyFontVariant, result, commonVal ue);
532 appendFontLonghandValueIfNotNormal(CSSPropertyFontWeight, result, commonValu e); 532 appendFontLonghandValueIfNotNormal(CSSPropertyFontWeight, result, commonValu e);
533 appendFontLonghandValueIfNotNormal(CSSPropertyFontStretch, result, commonVal ue); 533 appendFontLonghandValueIfNotNormal(CSSPropertyFontStretch, result, commonVal ue);
534 if (!result.isEmpty()) 534 if (!result.isEmpty())
535 result.append(' '); 535 result.append(' ');
536 result.append(fontSizeProperty.value().cssText()); 536 result.append(fontSizeProperty.value().cssText());
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 return commonValue->cssText(); 720 return commonValue->cssText();
721 721
722 return result.toString(); 722 return result.toString();
723 } 723 }
724 724
725 String StylePropertySerializer::getShorthandValue(const StylePropertyShorthand& shorthand, String separator) const 725 String StylePropertySerializer::getShorthandValue(const StylePropertyShorthand& shorthand, String separator) const
726 { 726 {
727 String commonValue; 727 String commonValue;
728 StringBuilder result; 728 StringBuilder result;
729 for (unsigned i = 0; i < shorthand.length(); ++i) { 729 for (unsigned i = 0; i < shorthand.length(); ++i) {
730 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(shortha nd.properties()[i]); 730 const NullableCSSValue& value = m_propertySet.getPropertyCSSValue(shorth and.properties()[i]);
731 if (!value) 731 if (!value)
732 return String(); 732 return String();
733 String valueText = value->cssText(); 733 String valueText = value->cssText();
734 if (!i) 734 if (!i)
735 commonValue = valueText; 735 commonValue = valueText;
736 else if (!commonValue.isNull() && commonValue != valueText) 736 else if (!commonValue.isNull() && commonValue != valueText)
737 commonValue = String(); 737 commonValue = String();
738 if (value->isInitialValue()) 738 if (value->isInitialValue())
739 continue; 739 continue;
740 if (!result.isEmpty()) 740 if (!result.isEmpty())
741 result.append(separator); 741 result.append(separator);
742 result.append(valueText); 742 result.append(valueText);
743 } 743 }
744 if (isInitialOrInherit(commonValue)) 744 if (isInitialOrInherit(commonValue))
745 return commonValue; 745 return commonValue;
746 return result.toString(); 746 return result.toString();
747 } 747 }
748 748
749 // only returns a non-null value if all properties have the same, non-null value 749 // only returns a non-null value if all properties have the same, non-null value
750 String StylePropertySerializer::getCommonValue(const StylePropertyShorthand& sho rthand) const 750 String StylePropertySerializer::getCommonValue(const StylePropertyShorthand& sho rthand) const
751 { 751 {
752 String res; 752 String res;
753 bool lastPropertyWasImportant = false; 753 bool lastPropertyWasImportant = false;
754 for (unsigned i = 0; i < shorthand.length(); ++i) { 754 for (unsigned i = 0; i < shorthand.length(); ++i) {
755 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(shortha nd.properties()[i]); 755 const NullableCSSValue& value = m_propertySet.getPropertyCSSValue(shorth and.properties()[i]);
756 // FIXME: CSSInitialValue::cssText should generate the right value. 756 // FIXME: CSSInitialValue::cssText should generate the right value.
757 if (!value) 757 if (!value)
758 return String(); 758 return String();
759 String text = value->cssText(); 759 String text = value->cssText();
760 if (text.isNull()) 760 if (text.isNull())
761 return String(); 761 return String();
762 if (res.isNull()) 762 if (res.isNull())
763 res = text; 763 res = text;
764 else if (res != text) 764 else if (res != text)
765 return String(); 765 return String();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 } 797 }
798 if (isInitialOrInherit(commonValue)) 798 if (isInitialOrInherit(commonValue))
799 return commonValue; 799 return commonValue;
800 return result.isEmpty() ? String() : result.toString(); 800 return result.isEmpty() ? String() : result.toString();
801 } 801 }
802 802
803 static void appendBackgroundRepeatValue(StringBuilder& builder, const CSSValue& repeatXCSSValue, const CSSValue& repeatYCSSValue) 803 static void appendBackgroundRepeatValue(StringBuilder& builder, const CSSValue& repeatXCSSValue, const CSSValue& repeatYCSSValue)
804 { 804 {
805 // FIXME: Ensure initial values do not appear in CSS_VALUE_LISTS. 805 // FIXME: Ensure initial values do not appear in CSS_VALUE_LISTS.
806 CSSPrimitiveValue initialRepeatValue = CSSPrimitiveValue::create(CSSValueRep eat); 806 CSSPrimitiveValue initialRepeatValue = CSSPrimitiveValue::create(CSSValueRep eat);
807 const CSSPrimitiveValue repeatX = repeatXCSSValue.isInitialValue() ? initial RepeatValue : toCSSPrimitiveValue(repeatXCSSValue); 807 const CSSPrimitiveValue& repeatX = repeatXCSSValue.isInitialValue() ? initia lRepeatValue : toCSSPrimitiveValue(repeatXCSSValue);
808 const CSSPrimitiveValue repeatY = repeatYCSSValue.isInitialValue() ? initial RepeatValue : toCSSPrimitiveValue(repeatYCSSValue); 808 const CSSPrimitiveValue& repeatY = repeatYCSSValue.isInitialValue() ? initia lRepeatValue : toCSSPrimitiveValue(repeatYCSSValue);
809 CSSValueID repeatXValueId = repeatX.getValueID(); 809 CSSValueID repeatXValueId = repeatX.getValueID();
810 CSSValueID repeatYValueId = repeatY.getValueID(); 810 CSSValueID repeatYValueId = repeatY.getValueID();
811 if (repeatXValueId == repeatYValueId) { 811 if (repeatXValueId == repeatYValueId) {
812 builder.append(repeatX.cssText()); 812 builder.append(repeatX.cssText());
813 } else if (repeatXValueId == CSSValueNoRepeat && repeatYValueId == CSSValueR epeat) { 813 } else if (repeatXValueId == CSSValueNoRepeat && repeatYValueId == CSSValueR epeat) {
814 builder.appendLiteral("repeat-y"); 814 builder.appendLiteral("repeat-y");
815 } else if (repeatXValueId == CSSValueRepeat && repeatYValueId == CSSValueNoR epeat) { 815 } else if (repeatXValueId == CSSValueRepeat && repeatYValueId == CSSValueNoR epeat) {
816 builder.appendLiteral("repeat-x"); 816 builder.appendLiteral("repeat-x");
817 } else { 817 } else {
818 builder.append(repeatX.cssText()); 818 builder.append(repeatX.cssText());
819 builder.appendLiteral(" "); 819 builder.appendLiteral(" ");
820 builder.append(repeatY.cssText()); 820 builder.append(repeatY.cssText());
821 } 821 }
822 } 822 }
823 823
824 String StylePropertySerializer::backgroundRepeatPropertyValue() const 824 String StylePropertySerializer::backgroundRepeatPropertyValue() const
825 { 825 {
826 const NullableCSSValue repeatX = m_propertySet.getPropertyCSSValue(CSSProper tyBackgroundRepeatX); 826 const NullableCSSValue& repeatX = m_propertySet.getPropertyCSSValue(CSSPrope rtyBackgroundRepeatX);
827 const NullableCSSValue repeatY = m_propertySet.getPropertyCSSValue(CSSProper tyBackgroundRepeatY); 827 const NullableCSSValue& repeatY = m_propertySet.getPropertyCSSValue(CSSPrope rtyBackgroundRepeatY);
828 if (!repeatX || !repeatY) 828 if (!repeatX || !repeatY)
829 return String(); 829 return String();
830 if (m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX) != m_pro pertySet.propertyIsImportant(CSSPropertyBackgroundRepeatY)) 830 if (m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX) != m_pro pertySet.propertyIsImportant(CSSPropertyBackgroundRepeatY))
831 return String(); 831 return String();
832 if ((repeatX->isInitialValue() && repeatY->isInitialValue()) || (repeatX->is InheritedValue() && repeatY->isInheritedValue())) 832 if ((repeatX->isInitialValue() && repeatY->isInitialValue()) || (repeatX->is InheritedValue() && repeatY->isInheritedValue()))
833 return repeatX->cssText(); 833 return repeatX->cssText();
834 834
835 const CSSValueList* repeatXList = 0; 835 const CSSValueList* repeatXList = 0;
836 int repeatXLength = 1; 836 int repeatXLength = 1;
837 if (repeatX->isValueList()) { 837 if (repeatX->isValueList()) {
(...skipping 27 matching lines...) Expand all
865 865
866 void StylePropertySerializer::appendBackgroundPropertyAsText(StringBuilder& resu lt, unsigned& numDecls) const 866 void StylePropertySerializer::appendBackgroundPropertyAsText(StringBuilder& resu lt, unsigned& numDecls) const
867 { 867 {
868 if (isPropertyShorthandAvailable(backgroundShorthand())) { 868 if (isPropertyShorthandAvailable(backgroundShorthand())) {
869 String backgroundValue = getPropertyValue(CSSPropertyBackground); 869 String backgroundValue = getPropertyValue(CSSPropertyBackground);
870 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou ndImage); 870 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou ndImage);
871 result.append(getPropertyText(CSSPropertyBackground, backgroundValue, is Important, numDecls++)); 871 result.append(getPropertyText(CSSPropertyBackground, backgroundValue, is Important, numDecls++));
872 return; 872 return;
873 } 873 }
874 if (shorthandHasOnlyInitialOrInheritedValue(backgroundShorthand())) { 874 if (shorthandHasOnlyInitialOrInheritedValue(backgroundShorthand())) {
875 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSSProp ertyBackgroundImage); 875 const NullableCSSValue& value = m_propertySet.getPropertyCSSValue(CSSPro pertyBackgroundImage);
876 ASSERT(value); 876 ASSERT(value);
877 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou ndImage); 877 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou ndImage);
878 result.append(getPropertyText(CSSPropertyBackground, value->cssText(), i sImportant, numDecls++)); 878 result.append(getPropertyText(CSSPropertyBackground, value->cssText(), i sImportant, numDecls++));
879 return; 879 return;
880 } 880 }
881 881
882 // backgroundShorthandProperty without layered shorhand properties 882 // backgroundShorthandProperty without layered shorhand properties
883 const CSSPropertyID backgroundPropertyIds[] = { 883 const CSSPropertyID backgroundPropertyIds[] = {
884 CSSPropertyBackgroundImage, 884 CSSPropertyBackgroundImage,
885 CSSPropertyBackgroundAttachment, 885 CSSPropertyBackgroundAttachment,
886 CSSPropertyBackgroundColor, 886 CSSPropertyBackgroundColor,
887 CSSPropertyBackgroundSize, 887 CSSPropertyBackgroundSize,
888 CSSPropertyBackgroundOrigin, 888 CSSPropertyBackgroundOrigin,
889 CSSPropertyBackgroundClip 889 CSSPropertyBackgroundClip
890 }; 890 };
891 891
892 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(backgroundPropertyIds); ++i) { 892 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(backgroundPropertyIds); ++i) {
893 CSSPropertyID propertyID = backgroundPropertyIds[i]; 893 CSSPropertyID propertyID = backgroundPropertyIds[i];
894 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(propert yID); 894 const NullableCSSValue& value = m_propertySet.getPropertyCSSValue(proper tyID);
895 if (!value) 895 if (!value)
896 continue; 896 continue;
897 result.append(getPropertyText(propertyID, value->cssText(), m_propertySe t.propertyIsImportant(propertyID), numDecls++)); 897 result.append(getPropertyText(propertyID, value->cssText(), m_propertySe t.propertyIsImportant(propertyID), numDecls++));
898 } 898 }
899 899
900 // FIXME: This is a not-so-nice way to turn x/y positions into single backgr ound-position in output. 900 // FIXME: This is a not-so-nice way to turn x/y positions into single backgr ound-position in output.
901 // It is required because background-position-x/y are non-standard propertie s and WebKit generated output 901 // It is required because background-position-x/y are non-standard propertie s and WebKit generated output
902 // would not work in Firefox (<rdar://problem/5143183>) 902 // would not work in Firefox (<rdar://problem/5143183>)
903 // It would be a better solution if background-position was CSS_PAIR. 903 // It would be a better solution if background-position was CSS_PAIR.
904 if (shorthandHasOnlyInitialOrInheritedValue(backgroundPositionShorthand())) { 904 if (shorthandHasOnlyInitialOrInheritedValue(backgroundPositionShorthand())) {
905 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSSProp ertyBackgroundPositionX); 905 const NullableCSSValue& value = m_propertySet.getPropertyCSSValue(CSSPro pertyBackgroundPositionX);
906 ASSERT(value); 906 ASSERT(value);
907 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou ndPositionX); 907 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou ndPositionX);
908 result.append(getPropertyText(CSSPropertyBackgroundPosition, value->cssT ext(), isImportant, numDecls++)); 908 result.append(getPropertyText(CSSPropertyBackgroundPosition, value->cssT ext(), isImportant, numDecls++));
909 } else if (isPropertyShorthandAvailable(backgroundPositionShorthand())) { 909 } else if (isPropertyShorthandAvailable(backgroundPositionShorthand())) {
910 String positionValue = m_propertySet.getPropertyValue(CSSPropertyBackgro undPosition); 910 String positionValue = m_propertySet.getPropertyValue(CSSPropertyBackgro undPosition);
911 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou ndPositionX); 911 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou ndPositionX);
912 if (!positionValue.isNull()) 912 if (!positionValue.isNull())
913 result.append(getPropertyText(CSSPropertyBackgroundPosition, positio nValue, isImportant, numDecls++)); 913 result.append(getPropertyText(CSSPropertyBackgroundPosition, positio nValue, isImportant, numDecls++));
914 } else { 914 } else {
915 // should check background-position-x or background-position-y. 915 // should check background-position-x or background-position-y.
916 if (const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSS PropertyBackgroundPositionX)) { 916 if (const NullableCSSValue& value = m_propertySet.getPropertyCSSValue(CS SPropertyBackgroundPositionX)) {
917 if (value && !value->isImplicitInitialValue()) { 917 if (value && !value->isImplicitInitialValue()) {
918 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty BackgroundPositionX); 918 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty BackgroundPositionX);
919 result.append(getPropertyText(CSSPropertyBackgroundPositionX, va lue->cssText(), isImportant, numDecls++)); 919 result.append(getPropertyText(CSSPropertyBackgroundPositionX, va lue->cssText(), isImportant, numDecls++));
920 } 920 }
921 } 921 }
922 if (const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSS PropertyBackgroundPositionY)) { 922 if (const NullableCSSValue& value = m_propertySet.getPropertyCSSValue(CS SPropertyBackgroundPositionY)) {
923 if (value && !value->isImplicitInitialValue()) { 923 if (value && !value->isImplicitInitialValue()) {
924 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty BackgroundPositionY); 924 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty BackgroundPositionY);
925 result.append(getPropertyText(CSSPropertyBackgroundPositionY, va lue->cssText(), isImportant, numDecls++)); 925 result.append(getPropertyText(CSSPropertyBackgroundPositionY, va lue->cssText(), isImportant, numDecls++));
926 } 926 }
927 } 927 }
928 } 928 }
929 929
930 String repeatValue = m_propertySet.getPropertyValue(CSSPropertyBackgroundRep eat); 930 String repeatValue = m_propertySet.getPropertyValue(CSSPropertyBackgroundRep eat);
931 if (!repeatValue.isNull()) 931 if (!repeatValue.isNull())
932 result.append(getPropertyText(CSSPropertyBackgroundRepeat, repeatValue, m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX), numDecls++)); 932 result.append(getPropertyText(CSSPropertyBackgroundRepeat, repeatValue, m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX), numDecls++));
933 } 933 }
934 934
935 bool StylePropertySerializer::isPropertyShorthandAvailable(const StylePropertySh orthand& shorthand) const 935 bool StylePropertySerializer::isPropertyShorthandAvailable(const StylePropertySh orthand& shorthand) const
936 { 936 {
937 ASSERT(shorthand.length() > 0); 937 ASSERT(shorthand.length() > 0);
938 938
939 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[ 0]); 939 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[ 0]);
940 for (unsigned i = 0; i < shorthand.length(); ++i) { 940 for (unsigned i = 0; i < shorthand.length(); ++i) {
941 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(shortha nd.properties()[i]); 941 const NullableCSSValue& value = m_propertySet.getPropertyCSSValue(shorth and.properties()[i]);
942 if (!value || (value->isInitialValue() && !value->isImplicitInitialValue ()) || value->isInheritedValue()) 942 if (!value || (value->isInitialValue() && !value->isImplicitInitialValue ()) || value->isInheritedValue())
943 return false; 943 return false;
944 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie s()[i])) 944 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie s()[i]))
945 return false; 945 return false;
946 } 946 }
947 return true; 947 return true;
948 } 948 }
949 949
950 bool StylePropertySerializer::shorthandHasOnlyInitialOrInheritedValue(const Styl ePropertyShorthand& shorthand) const 950 bool StylePropertySerializer::shorthandHasOnlyInitialOrInheritedValue(const Styl ePropertyShorthand& shorthand) const
951 { 951 {
952 ASSERT(shorthand.length() > 0); 952 ASSERT(shorthand.length() > 0);
953 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[ 0]); 953 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[ 0]);
954 bool isInitialValue = true; 954 bool isInitialValue = true;
955 bool isInheritedValue = true; 955 bool isInheritedValue = true;
956 for (unsigned i = 0; i < shorthand.length(); ++i) { 956 for (unsigned i = 0; i < shorthand.length(); ++i) {
957 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(shortha nd.properties()[i]); 957 const NullableCSSValue& value = m_propertySet.getPropertyCSSValue(shorth and.properties()[i]);
958 if (!value) 958 if (!value)
959 return false; 959 return false;
960 if (!value->isInitialValue()) 960 if (!value->isInitialValue())
961 isInitialValue = false; 961 isInitialValue = false;
962 if (!value->isInheritedValue()) 962 if (!value->isInheritedValue())
963 isInheritedValue = false; 963 isInheritedValue = false;
964 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie s()[i])) 964 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie s()[i]))
965 return false; 965 return false;
966 } 966 }
967 return isInitialValue || isInheritedValue; 967 return isInitialValue || isInheritedValue;
968 } 968 }
969 969
970 } 970 }
OLDNEW
« no previous file with comments | « Source/core/css/StylePropertySerializer.h ('k') | Source/core/css/StylePropertySet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698