OLD | NEW |
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 namespace blink { | 45 namespace blink { |
46 | 46 |
47 class RotateTransformOperation; | 47 class RotateTransformOperation; |
48 class TranslateTransformOperation; | 48 class TranslateTransformOperation; |
49 class ScaleTransformOperation; | 49 class ScaleTransformOperation; |
50 | 50 |
51 // Note that we assume the parser only allows valid CSSValue types. | 51 // Note that we assume the parser only allows valid CSSValue types. |
52 class StyleBuilderConverter { | 52 class StyleBuilderConverter { |
53 STATIC_ONLY(StyleBuilderConverter); | 53 STATIC_ONLY(StyleBuilderConverter); |
54 public: | 54 public: |
55 static PassRefPtr<StyleReflection> convertBoxReflect(StyleResolverState&, CS
SValue*); | 55 static PassRefPtr<StyleReflection> convertBoxReflect(StyleResolverState&, co
nst CSSValue&); |
56 static AtomicString convertFragmentIdentifier(StyleResolverState&, CSSValue*
); | 56 static AtomicString convertFragmentIdentifier(StyleResolverState&, const CSS
Value&); |
57 static Color convertColor(StyleResolverState&, CSSValue*, bool forVisitedLin
k = false); | 57 static Color convertColor(StyleResolverState&, const CSSValue&, bool forVisi
tedLink = false); |
58 template <typename T> static T convertComputedLength(StyleResolverState&, CS
SValue*); | 58 template <typename T> static T convertComputedLength(StyleResolverState&, co
nst CSSValue&); |
59 static LengthBox convertClip(StyleResolverState&, CSSValue*); | 59 static LengthBox convertClip(StyleResolverState&, const CSSValue&); |
60 template <typename T> static T convertFlags(StyleResolverState&, CSSValue*); | 60 template <typename T> static T convertFlags(StyleResolverState&, const CSSVa
lue&); |
61 static FontDescription::FamilyDescription convertFontFamily(StyleResolverSta
te&, CSSValue*); | 61 static FontDescription::FamilyDescription convertFontFamily(StyleResolverSta
te&, const CSSValue&); |
62 static PassRefPtr<FontFeatureSettings> convertFontFeatureSettings(StyleResol
verState&, CSSValue*); | 62 static PassRefPtr<FontFeatureSettings> convertFontFeatureSettings(StyleResol
verState&, const CSSValue&); |
63 static FontDescription::Size convertFontSize(StyleResolverState&, CSSValue*)
; | 63 static FontDescription::Size convertFontSize(StyleResolverState&, const CSSV
alue&); |
64 static float convertFontSizeAdjust(StyleResolverState&, CSSValue*); | 64 static float convertFontSizeAdjust(StyleResolverState&, const CSSValue&); |
65 static FontWeight convertFontWeight(StyleResolverState&, CSSValue*); | 65 static FontWeight convertFontWeight(StyleResolverState&, const CSSValue&); |
66 static FontDescription::VariantLigatures convertFontVariantLigatures(StyleRe
solverState&, CSSValue*); | 66 static FontDescription::VariantLigatures convertFontVariantLigatures(StyleRe
solverState&, const CSSValue&); |
67 static EGlyphOrientation convertGlyphOrientation(StyleResolverState&, CSSVal
ue*); | 67 static EGlyphOrientation convertGlyphOrientation(StyleResolverState&, const
CSSValue&); |
68 static StyleSelfAlignmentData convertSelfOrDefaultAlignmentData(StyleResolve
rState&, CSSValue*); | 68 static StyleSelfAlignmentData convertSelfOrDefaultAlignmentData(StyleResolve
rState&, const CSSValue&); |
69 static StyleContentAlignmentData convertContentAlignmentData(StyleResolverSt
ate&, CSSValue*); | 69 static StyleContentAlignmentData convertContentAlignmentData(StyleResolverSt
ate&, const CSSValue&); |
70 static GridAutoFlow convertGridAutoFlow(StyleResolverState&, CSSValue*); | 70 static GridAutoFlow convertGridAutoFlow(StyleResolverState&, const CSSValue&
); |
71 static GridPosition convertGridPosition(StyleResolverState&, CSSValue*); | 71 static GridPosition convertGridPosition(StyleResolverState&, const CSSValue&
); |
72 static GridTrackSize convertGridTrackSize(StyleResolverState&, CSSValue*); | 72 static GridTrackSize convertGridTrackSize(StyleResolverState&, const CSSValu
e&); |
73 template <typename T> static T convertLineWidth(StyleResolverState&, CSSValu
e*); | 73 template <typename T> static T convertLineWidth(StyleResolverState&, const C
SSValue&); |
74 static Length convertLength(const StyleResolverState&, CSSValue*); | 74 static Length convertLength(const StyleResolverState&, const CSSValue&); |
75 static UnzoomedLength convertUnzoomedLength(const StyleResolverState&, CSSVa
lue*); | 75 static UnzoomedLength convertUnzoomedLength(const StyleResolverState&, const
CSSValue&); |
76 static Length convertLengthOrAuto(const StyleResolverState&, CSSValue*); | 76 static Length convertLengthOrAuto(const StyleResolverState&, const CSSValue&
); |
77 static Length convertLengthSizing(StyleResolverState&, CSSValue*); | 77 static Length convertLengthSizing(StyleResolverState&, const CSSValue&); |
78 static Length convertLengthMaxSizing(StyleResolverState&, CSSValue*); | 78 static Length convertLengthMaxSizing(StyleResolverState&, const CSSValue&); |
79 static TabSize convertLengthOrTabSpaces(StyleResolverState&, CSSValue*); | 79 static TabSize convertLengthOrTabSpaces(StyleResolverState&, const CSSValue&
); |
80 static Length convertLineHeight(StyleResolverState&, CSSValue*); | 80 static Length convertLineHeight(StyleResolverState&, const CSSValue&); |
81 static float convertNumberOrPercentage(StyleResolverState&, CSSValue*); | 81 static float convertNumberOrPercentage(StyleResolverState&, const CSSValue&)
; |
82 static LengthPoint convertPosition(StyleResolverState&, CSSValue*); | 82 static LengthPoint convertPosition(StyleResolverState&, const CSSValue&); |
83 static float convertPerspective(StyleResolverState&, CSSValue*); | 83 static float convertPerspective(StyleResolverState&, const CSSValue&); |
84 static LengthPoint convertPerspectiveOrigin(StyleResolverState&, CSSValue*); | 84 static LengthPoint convertPerspectiveOrigin(StyleResolverState&, const CSSVa
lue&); |
85 static Length convertQuirkyLength(StyleResolverState&, CSSValue*); | 85 static Length convertQuirkyLength(StyleResolverState&, const CSSValue&); |
86 static PassRefPtr<QuotesData> convertQuotes(StyleResolverState&, CSSValue*); | 86 static PassRefPtr<QuotesData> convertQuotes(StyleResolverState&, const CSSVa
lue&); |
87 static LengthSize convertRadius(StyleResolverState&, CSSValue*); | 87 static LengthSize convertRadius(StyleResolverState&, const CSSValue&); |
88 static EPaintOrder convertPaintOrder(StyleResolverState&, CSSValue*); | 88 static EPaintOrder convertPaintOrder(StyleResolverState&, const CSSValue&); |
89 static PassRefPtr<ShadowList> convertShadow(StyleResolverState&, CSSValue*); | 89 static PassRefPtr<ShadowList> convertShadow(StyleResolverState&, const CSSVa
lue&); |
90 static PassRefPtrWillBeRawPtr<ShapeValue> convertShapeValue(StyleResolverSta
te&, CSSValue*); | 90 static PassRefPtrWillBeRawPtr<ShapeValue> convertShapeValue(StyleResolverSta
te&, const CSSValue&); |
91 static float convertSpacing(StyleResolverState&, CSSValue*); | 91 static float convertSpacing(StyleResolverState&, const CSSValue&); |
92 template <CSSValueID IdForNone> static AtomicString convertString(StyleResol
verState&, CSSValue*); | 92 template <CSSValueID IdForNone> static AtomicString convertString(StyleResol
verState&, const CSSValue&); |
93 static PassRefPtr<SVGDashArray> convertStrokeDasharray(StyleResolverState&,
CSSValue*); | 93 static PassRefPtr<SVGDashArray> convertStrokeDasharray(StyleResolverState&,
const CSSValue&); |
94 static StyleColor convertStyleColor(StyleResolverState&, CSSValue*, bool for
VisitedLink = false); | 94 static StyleColor convertStyleColor(StyleResolverState&, const CSSValue&, bo
ol forVisitedLink = false); |
95 static float convertTextStrokeWidth(StyleResolverState&, CSSValue*); | 95 static float convertTextStrokeWidth(StyleResolverState&, const CSSValue&); |
96 static TransformOrigin convertTransformOrigin(StyleResolverState&, CSSValue*
); | 96 static TransformOrigin convertTransformOrigin(StyleResolverState&, const CSS
Value&); |
97 | 97 |
98 static void convertGridTrackList(CSSValue*, Vector<GridTrackSize>&, NamedGri
dLinesMap&, OrderedNamedGridLines&, StyleResolverState&); | 98 static void convertGridTrackList(const CSSValue&, Vector<GridTrackSize>&, Na
medGridLinesMap&, OrderedNamedGridLines&, StyleResolverState&); |
99 static void createImplicitNamedGridLinesFromGridArea(const NamedGridAreaMap&
, NamedGridLinesMap&, GridTrackSizingDirection); | 99 static void createImplicitNamedGridLinesFromGridArea(const NamedGridAreaMap&
, NamedGridLinesMap&, GridTrackSizingDirection); |
100 static void convertOrderedNamedGridLinesMapToNamedGridLinesMap(const Ordered
NamedGridLines&, NamedGridLinesMap&); | 100 static void convertOrderedNamedGridLinesMapToNamedGridLinesMap(const Ordered
NamedGridLines&, NamedGridLinesMap&); |
101 | 101 |
102 static ScrollSnapPoints convertSnapPoints(StyleResolverState&, CSSValue*); | 102 static ScrollSnapPoints convertSnapPoints(StyleResolverState&, const CSSValu
e&); |
103 static Vector<LengthPoint> convertSnapCoordinates(StyleResolverState&, CSSVa
lue*); | 103 static Vector<LengthPoint> convertSnapCoordinates(StyleResolverState&, const
CSSValue&); |
104 static LengthPoint convertSnapDestination(StyleResolverState&, CSSValue*); | 104 static LengthPoint convertSnapDestination(StyleResolverState&, const CSSValu
e&); |
105 static PassRefPtr<TranslateTransformOperation> convertTranslate(StyleResolve
rState&, CSSValue*); | 105 static PassRefPtr<TranslateTransformOperation> convertTranslate(StyleResolve
rState&, const CSSValue&); |
106 static PassRefPtr<RotateTransformOperation> convertRotate(StyleResolverState
&, CSSValue*); | 106 static PassRefPtr<RotateTransformOperation> convertRotate(StyleResolverState
&, const CSSValue&); |
107 static PassRefPtr<ScaleTransformOperation> convertScale(StyleResolverState&,
CSSValue*); | 107 static PassRefPtr<ScaleTransformOperation> convertScale(StyleResolverState&,
const CSSValue&); |
108 static RespectImageOrientationEnum convertImageOrientation(StyleResolverStat
e&, CSSValue*); | 108 static RespectImageOrientationEnum convertImageOrientation(StyleResolverStat
e&, const CSSValue&); |
109 }; | 109 }; |
110 | 110 |
111 template <typename T> | 111 template <typename T> |
112 T StyleBuilderConverter::convertComputedLength(StyleResolverState& state, CSSVal
ue* value) | 112 T StyleBuilderConverter::convertComputedLength(StyleResolverState& state, const
CSSValue& value) |
113 { | 113 { |
114 return toCSSPrimitiveValue(value)->computeLength<T>(state.cssToLengthConvers
ionData()); | 114 return toCSSPrimitiveValue(value).computeLength<T>(state.cssToLengthConversi
onData()); |
115 } | 115 } |
116 | 116 |
117 template <typename T> | 117 template <typename T> |
118 T StyleBuilderConverter::convertFlags(StyleResolverState& state, CSSValue* value
) | 118 T StyleBuilderConverter::convertFlags(StyleResolverState& state, const CSSValue&
value) |
119 { | 119 { |
120 T flags = static_cast<T>(0); | 120 T flags = static_cast<T>(0); |
121 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() ==
CSSValueNone) | 121 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == C
SSValueNone) |
122 return flags; | 122 return flags; |
123 for (auto& flagValue : toCSSValueList(*value)) | 123 for (auto& flagValue : toCSSValueList(value)) |
124 flags |= toCSSPrimitiveValue(*flagValue); | 124 flags |= toCSSPrimitiveValue(*flagValue); |
125 return flags; | 125 return flags; |
126 } | 126 } |
127 | 127 |
128 template <typename T> | 128 template <typename T> |
129 T StyleBuilderConverter::convertLineWidth(StyleResolverState& state, CSSValue* v
alue) | 129 T StyleBuilderConverter::convertLineWidth(StyleResolverState& state, const CSSVa
lue& value) |
130 { | 130 { |
131 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 131 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
132 CSSValueID valueID = primitiveValue->getValueID(); | 132 CSSValueID valueID = primitiveValue.getValueID(); |
133 if (valueID == CSSValueThin) | 133 if (valueID == CSSValueThin) |
134 return 1; | 134 return 1; |
135 if (valueID == CSSValueMedium) | 135 if (valueID == CSSValueMedium) |
136 return 3; | 136 return 3; |
137 if (valueID == CSSValueThick) | 137 if (valueID == CSSValueThick) |
138 return 5; | 138 return 5; |
139 if (valueID == CSSValueInvalid) { | 139 if (valueID == CSSValueInvalid) { |
140 // Any original result that was >= 1 should not be allowed to fall below
1. | 140 // Any original result that was >= 1 should not be allowed to fall below
1. |
141 // This keeps border lines from vanishing. | 141 // This keeps border lines from vanishing. |
142 T result = primitiveValue->computeLength<T>(state.cssToLengthConversionD
ata()); | 142 T result = primitiveValue.computeLength<T>(state.cssToLengthConversionDa
ta()); |
143 if (state.style()->effectiveZoom() < 1.0f && result < 1.0) { | 143 if (state.style()->effectiveZoom() < 1.0f && result < 1.0) { |
144 T originalLength = primitiveValue->computeLength<T>(state.cssToLengt
hConversionData().copyWithAdjustedZoom(1.0)); | 144 T originalLength = primitiveValue.computeLength<T>(state.cssToLength
ConversionData().copyWithAdjustedZoom(1.0)); |
145 if (originalLength >= 1.0) | 145 if (originalLength >= 1.0) |
146 return 1.0; | 146 return 1.0; |
147 } | 147 } |
148 return result; | 148 return result; |
149 } | 149 } |
150 ASSERT_NOT_REACHED(); | 150 ASSERT_NOT_REACHED(); |
151 return 0; | 151 return 0; |
152 } | 152 } |
153 | 153 |
154 template <CSSValueID IdForNone> | 154 template <CSSValueID IdForNone> |
155 AtomicString StyleBuilderConverter::convertString(StyleResolverState&, CSSValue*
value) | 155 AtomicString StyleBuilderConverter::convertString(StyleResolverState&, const CSS
Value& value) |
156 { | 156 { |
157 if (value->isStringValue()) | 157 if (value.isStringValue()) |
158 return AtomicString(toCSSStringValue(value)->value()); | 158 return AtomicString(toCSSStringValue(value).value()); |
159 ASSERT(toCSSPrimitiveValue(value)->getValueID() == IdForNone); | 159 ASSERT(toCSSPrimitiveValue(value).getValueID() == IdForNone); |
160 return nullAtom; | 160 return nullAtom; |
161 } | 161 } |
162 | 162 |
163 } // namespace blink | 163 } // namespace blink |
164 | 164 |
165 #endif | 165 #endif |
OLD | NEW |