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

Side by Side Diff: Source/core/css/resolver/StyleBuilderConverter.h

Issue 1164573002: CSSValue Immediates: Change CSSValue to an object instead of a pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * * Redistributions of source code must retain the above copyright 4 * * Redistributions of source code must retain the above copyright
5 * notice, this list of conditions and the following disclaimer. 5 * notice, this list of conditions and the following disclaimer.
6 * * Redistributions in binary form must reproduce the above 6 * * Redistributions in binary form must reproduce the above
7 * copyright notice, this list of conditions and the following disclaimer 7 * copyright notice, this list of conditions and the following disclaimer
8 * in the documentation and/or other materials provided with the 8 * in the documentation and/or other materials provided with the
9 * distribution. 9 * distribution.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 27 matching lines...) Expand all
38 #include "platform/LengthSize.h" 38 #include "platform/LengthSize.h"
39 #include "platform/fonts/FontDescription.h" 39 #include "platform/fonts/FontDescription.h"
40 #include "platform/text/TabSize.h" 40 #include "platform/text/TabSize.h"
41 41
42 namespace blink { 42 namespace blink {
43 43
44 // Note that we assume the parser only allows valid CSSValue types. 44 // Note that we assume the parser only allows valid CSSValue types.
45 45
46 class StyleBuilderConverter { 46 class StyleBuilderConverter {
47 public: 47 public:
48 static PassRefPtr<StyleReflection> convertBoxReflect(StyleResolverState&, CS SValue*); 48 static PassRefPtr<StyleReflection> convertBoxReflect(StyleResolverState&, CS SValue);
49 static AtomicString convertFragmentIdentifier(StyleResolverState&, CSSValue* ); 49 static AtomicString convertFragmentIdentifier(StyleResolverState&, CSSValue) ;
50 static Color convertColor(StyleResolverState&, CSSValue*, bool forVisitedLin k = false); 50 static Color convertColor(StyleResolverState&, CSSValue, bool forVisitedLink = false);
51 template <typename T> static T convertComputedLength(StyleResolverState&, CS SValue*); 51 template <typename T> static T convertComputedLength(StyleResolverState&, CS SValue);
52 static LengthBox convertClip(StyleResolverState&, CSSValue*); 52 static LengthBox convertClip(StyleResolverState&, CSSValue);
53 template <typename T> static T convertFlags(StyleResolverState&, CSSValue*); 53 template <typename T> static T convertFlags(StyleResolverState&, CSSValue);
54 static FontDescription::FamilyDescription convertFontFamily(StyleResolverSta te&, CSSValue*); 54 static FontDescription::FamilyDescription convertFontFamily(StyleResolverSta te&, CSSValue);
55 static PassRefPtr<FontFeatureSettings> convertFontFeatureSettings(StyleResol verState&, CSSValue*); 55 static PassRefPtr<FontFeatureSettings> convertFontFeatureSettings(StyleResol verState&, CSSValue);
56 static FontDescription::Size convertFontSize(StyleResolverState&, CSSValue*) ; 56 static FontDescription::Size convertFontSize(StyleResolverState&, CSSValue);
57 static float convertFontSizeAdjust(StyleResolverState&, CSSValue*); 57 static float convertFontSizeAdjust(StyleResolverState&, CSSValue);
58 static FontWeight convertFontWeight(StyleResolverState&, CSSValue*); 58 static FontWeight convertFontWeight(StyleResolverState&, CSSValue);
59 static FontDescription::VariantLigatures convertFontVariantLigatures(StyleRe solverState&, CSSValue*); 59 static FontDescription::VariantLigatures convertFontVariantLigatures(StyleRe solverState&, CSSValue);
60 static EGlyphOrientation convertGlyphOrientation(StyleResolverState&, CSSVal ue*); 60 static EGlyphOrientation convertGlyphOrientation(StyleResolverState&, CSSVal ue);
61 static StyleSelfAlignmentData convertSelfOrDefaultAlignmentData(StyleResolve rState&, CSSValue*); 61 static StyleSelfAlignmentData convertSelfOrDefaultAlignmentData(StyleResolve rState&, CSSValue);
62 static StyleContentAlignmentData convertContentAlignmentData(StyleResolverSt ate&, CSSValue*); 62 static StyleContentAlignmentData convertContentAlignmentData(StyleResolverSt ate&, CSSValue);
63 static GridAutoFlow convertGridAutoFlow(StyleResolverState&, CSSValue*); 63 static GridAutoFlow convertGridAutoFlow(StyleResolverState&, CSSValue);
64 static GridPosition convertGridPosition(StyleResolverState&, CSSValue*); 64 static GridPosition convertGridPosition(StyleResolverState&, CSSValue);
65 static GridTrackSize convertGridTrackSize(StyleResolverState&, CSSValue*); 65 static GridTrackSize convertGridTrackSize(StyleResolverState&, CSSValue);
66 template <typename T> static T convertLineWidth(StyleResolverState&, CSSValu e*); 66 template <typename T> static T convertLineWidth(StyleResolverState&, CSSValu e);
67 static Length convertLength(const StyleResolverState&, CSSValue*); 67 static Length convertLength(const StyleResolverState&, CSSValue);
68 static UnzoomedLength convertUnzoomedLength(const StyleResolverState&, CSSVa lue*); 68 static UnzoomedLength convertUnzoomedLength(const StyleResolverState&, CSSVa lue);
69 static Length convertLengthOrAuto(const StyleResolverState&, CSSValue*); 69 static Length convertLengthOrAuto(const StyleResolverState&, CSSValue);
70 static Length convertLengthSizing(StyleResolverState&, CSSValue*); 70 static Length convertLengthSizing(StyleResolverState&, CSSValue);
71 static Length convertLengthMaxSizing(StyleResolverState&, CSSValue*); 71 static Length convertLengthMaxSizing(StyleResolverState&, CSSValue);
72 static TabSize convertLengthOrTabSpaces(StyleResolverState&, CSSValue*); 72 static TabSize convertLengthOrTabSpaces(StyleResolverState&, CSSValue);
73 static LineBoxContain convertLineBoxContain(StyleResolverState&, CSSValue*); 73 static LineBoxContain convertLineBoxContain(StyleResolverState&, CSSValue);
74 static Length convertLineHeight(StyleResolverState&, CSSValue*); 74 static Length convertLineHeight(StyleResolverState&, CSSValue);
75 static float convertNumberOrPercentage(StyleResolverState&, CSSValue*); 75 static float convertNumberOrPercentage(StyleResolverState&, CSSValue);
76 static LengthPoint convertObjectPosition(StyleResolverState&, CSSValue*); 76 static LengthPoint convertObjectPosition(StyleResolverState&, CSSValue);
77 static float convertPerspective(StyleResolverState&, CSSValue*); 77 static float convertPerspective(StyleResolverState&, CSSValue);
78 static LengthPoint convertPerspectiveOrigin(StyleResolverState&, CSSValue*); 78 static LengthPoint convertPerspectiveOrigin(StyleResolverState&, CSSValue);
79 static Length convertQuirkyLength(StyleResolverState&, CSSValue*); 79 static Length convertQuirkyLength(StyleResolverState&, CSSValue);
80 static PassRefPtr<QuotesData> convertQuotes(StyleResolverState&, CSSValue*); 80 static PassRefPtr<QuotesData> convertQuotes(StyleResolverState&, CSSValue);
81 static LengthSize convertRadius(StyleResolverState&, CSSValue*); 81 static LengthSize convertRadius(StyleResolverState&, CSSValue);
82 static EPaintOrder convertPaintOrder(StyleResolverState&, CSSValue*); 82 static EPaintOrder convertPaintOrder(StyleResolverState&, CSSValue);
83 static PassRefPtr<ShadowList> convertShadow(StyleResolverState&, CSSValue*); 83 static PassRefPtr<ShadowList> convertShadow(StyleResolverState&, CSSValue);
84 static PassRefPtr<ShapeValue> convertShapeValue(StyleResolverState&, CSSValu e*); 84 static PassRefPtr<ShapeValue> convertShapeValue(StyleResolverState&, CSSValu e);
85 static float convertSpacing(StyleResolverState&, CSSValue*); 85 static float convertSpacing(StyleResolverState&, CSSValue);
86 template <CSSValueID IdForNone> static AtomicString convertString(StyleResol verState&, CSSValue*); 86 template <CSSValueID IdForNone> static AtomicString convertString(StyleResol verState&, CSSValue);
87 static PassRefPtr<SVGDashArray> convertStrokeDasharray(StyleResolverState&, CSSValue*); 87 static PassRefPtr<SVGDashArray> convertStrokeDasharray(StyleResolverState&, CSSValue);
88 static StyleColor convertStyleColor(StyleResolverState&, CSSValue*, bool for VisitedLink = false); 88 static StyleColor convertStyleColor(StyleResolverState&, CSSValue, bool forV isitedLink = false);
89 static Color convertSVGColor(StyleResolverState&, CSSValue*); 89 static Color convertSVGColor(StyleResolverState&, CSSValue);
90 static float convertTextStrokeWidth(StyleResolverState&, CSSValue*); 90 static float convertTextStrokeWidth(StyleResolverState&, CSSValue);
91 static TransformOrigin convertTransformOrigin(StyleResolverState&, CSSValue* ); 91 static TransformOrigin convertTransformOrigin(StyleResolverState&, CSSValue) ;
92 92
93 static bool convertGridTrackList(CSSValue*, Vector<GridTrackSize>&, NamedGri dLinesMap&, OrderedNamedGridLines&, StyleResolverState&); 93 static bool convertGridTrackList(CSSValue, Vector<GridTrackSize>&, NamedGrid LinesMap&, OrderedNamedGridLines&, StyleResolverState&);
94 static void createImplicitNamedGridLinesFromGridArea(const NamedGridAreaMap& , NamedGridLinesMap&, GridTrackSizingDirection); 94 static void createImplicitNamedGridLinesFromGridArea(const NamedGridAreaMap& , NamedGridLinesMap&, GridTrackSizingDirection);
95 static void convertOrderedNamedGridLinesMapToNamedGridLinesMap(const Ordered NamedGridLines&, NamedGridLinesMap&); 95 static void convertOrderedNamedGridLinesMapToNamedGridLinesMap(const Ordered NamedGridLines&, NamedGridLinesMap&);
96 }; 96 };
97 97
98 template <typename T> 98 template <typename T>
99 T StyleBuilderConverter::convertComputedLength(StyleResolverState& state, CSSVal ue* value) 99 T StyleBuilderConverter::convertComputedLength(StyleResolverState& state, CSSVal ue value)
100 { 100 {
101 return toCSSPrimitiveValue(value)->computeLength<T>(state.cssToLengthConvers ionData()); 101 return toCSSPrimitiveValue(value).computeLength<T>(state.cssToLengthConversi onData());
102 } 102 }
103 103
104 template <typename T> 104 template <typename T>
105 T StyleBuilderConverter::convertFlags(StyleResolverState& state, CSSValue* value ) 105 T StyleBuilderConverter::convertFlags(StyleResolverState& state, CSSValue value)
106 { 106 {
107 T flags = static_cast<T>(0); 107 T flags = static_cast<T>(0);
108 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueNone) 108 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == C SSValueNone)
109 return flags; 109 return flags;
110 for (auto& flagValue : toCSSValueList(*value)) 110 for (auto& flagValue : toCSSValueList(value))
111 flags |= toCSSPrimitiveValue(*flagValue); 111 flags |= toCSSPrimitiveValue(flagValue);
112 return flags; 112 return flags;
113 } 113 }
114 114
115 template <typename T> 115 template <typename T>
116 T StyleBuilderConverter::convertLineWidth(StyleResolverState& state, CSSValue* v alue) 116 T StyleBuilderConverter::convertLineWidth(StyleResolverState& state, CSSValue va lue)
117 { 117 {
118 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 118 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
119 CSSValueID valueID = primitiveValue->getValueID(); 119 CSSValueID valueID = primitiveValue.getValueID();
120 if (valueID == CSSValueThin) 120 if (valueID == CSSValueThin)
121 return 1; 121 return 1;
122 if (valueID == CSSValueMedium) 122 if (valueID == CSSValueMedium)
123 return 3; 123 return 3;
124 if (valueID == CSSValueThick) 124 if (valueID == CSSValueThick)
125 return 5; 125 return 5;
126 if (valueID == CSSValueInvalid) { 126 if (valueID == CSSValueInvalid) {
127 // Any original result that was >= 1 should not be allowed to fall below 1. 127 // Any original result that was >= 1 should not be allowed to fall below 1.
128 // This keeps border lines from vanishing. 128 // This keeps border lines from vanishing.
129 T result = primitiveValue->computeLength<T>(state.cssToLengthConversionD ata()); 129 T result = primitiveValue.computeLength<T>(state.cssToLengthConversionDa ta());
130 if (state.style()->effectiveZoom() < 1.0f && result < 1.0) { 130 if (state.style()->effectiveZoom() < 1.0f && result < 1.0) {
131 T originalLength = primitiveValue->computeLength<T>(state.cssToLengt hConversionData().copyWithAdjustedZoom(1.0)); 131 T originalLength = primitiveValue.computeLength<T>(state.cssToLength ConversionData().copyWithAdjustedZoom(1.0));
132 if (originalLength >= 1.0) 132 if (originalLength >= 1.0)
133 return 1.0; 133 return 1.0;
134 } 134 }
135 return result; 135 return result;
136 } 136 }
137 ASSERT_NOT_REACHED(); 137 ASSERT_NOT_REACHED();
138 return 0; 138 return 0;
139 } 139 }
140 140
141 template <CSSValueID IdForNone> 141 template <CSSValueID IdForNone>
142 AtomicString StyleBuilderConverter::convertString(StyleResolverState&, CSSValue* value) 142 AtomicString StyleBuilderConverter::convertString(StyleResolverState&, CSSValue value)
143 { 143 {
144 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 144 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
145 if (primitiveValue->getValueID() == IdForNone) 145 if (primitiveValue.getValueID() == IdForNone)
146 return nullAtom; 146 return nullAtom;
147 return AtomicString(primitiveValue->getStringValue()); 147 return AtomicString(primitiveValue.getStringValue());
148 } 148 }
149 149
150 } // namespace blink 150 } // namespace blink
151 151
152 #endif 152 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698