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