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