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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 LengthBox StyleBuilderConverter::convertClip(StyleResolverState& state, CSSValue
* value) | 95 LengthBox StyleBuilderConverter::convertClip(StyleResolverState& state, CSSValue
* value) |
96 { | 96 { |
97 Rect* rect = toCSSPrimitiveValue(value)->getRectValue(); | 97 Rect* rect = toCSSPrimitiveValue(value)->getRectValue(); |
98 | 98 |
99 return LengthBox(convertLengthOrAuto(state, rect->top()), | 99 return LengthBox(convertLengthOrAuto(state, rect->top()), |
100 convertLengthOrAuto(state, rect->right()), | 100 convertLengthOrAuto(state, rect->right()), |
101 convertLengthOrAuto(state, rect->bottom()), | 101 convertLengthOrAuto(state, rect->bottom()), |
102 convertLengthOrAuto(state, rect->left())); | 102 convertLengthOrAuto(state, rect->left())); |
103 } | 103 } |
104 | 104 |
| 105 static FontDescription::GenericFamilyType convertGenericFamily(CSSValueID valueI
D) |
| 106 { |
| 107 switch (valueID) { |
| 108 case CSSValueWebkitBody: |
| 109 return FontDescription::StandardFamily; |
| 110 case CSSValueSerif: |
| 111 return FontDescription::SerifFamily; |
| 112 case CSSValueSansSerif: |
| 113 return FontDescription::SansSerifFamily; |
| 114 case CSSValueCursive: |
| 115 return FontDescription::CursiveFamily; |
| 116 case CSSValueFantasy: |
| 117 return FontDescription::FantasyFamily; |
| 118 case CSSValueMonospace: |
| 119 return FontDescription::MonospaceFamily; |
| 120 case CSSValueWebkitPictograph: |
| 121 return FontDescription::PictographFamily; |
| 122 default: |
| 123 return FontDescription::NoFamily; |
| 124 } |
| 125 } |
| 126 |
| 127 static bool convertFontFamilyName(StyleResolverState& state, CSSPrimitiveValue*
primitiveValue, |
| 128 FontDescription::GenericFamilyType& genericFamily, AtomicString& familyName) |
| 129 { |
| 130 if (primitiveValue->isString()) { |
| 131 genericFamily = FontDescription::NoFamily; |
| 132 familyName = AtomicString(primitiveValue->getStringValue()); |
| 133 } else if (state.document().settings()) { |
| 134 genericFamily = convertGenericFamily(primitiveValue->getValueID()); |
| 135 familyName = state.fontBuilder().genericFontFamilyName(genericFamily); |
| 136 } |
| 137 |
| 138 return !familyName.isEmpty(); |
| 139 } |
| 140 |
| 141 FontDescription::FamilyDescription StyleBuilderConverter::convertFontFamily(Styl
eResolverState& state, CSSValue* value) |
| 142 { |
| 143 ASSERT(value->isValueList()); |
| 144 |
| 145 FontDescription::FamilyDescription desc(FontDescription::NoFamily); |
| 146 FontFamily* currFamily = nullptr; |
| 147 |
| 148 for (CSSValueListIterator i = value; i.hasMore(); i.advance()) { |
| 149 CSSValue* item = i.value(); |
| 150 if (!item->isPrimitiveValue()) |
| 151 continue; |
| 152 |
| 153 FontDescription::GenericFamilyType genericFamily = FontDescription::NoFa
mily; |
| 154 AtomicString familyName; |
| 155 |
| 156 if (!convertFontFamilyName(state, toCSSPrimitiveValue(item), genericFami
ly, familyName)) |
| 157 continue; |
| 158 |
| 159 if (!currFamily) { |
| 160 currFamily = &desc.family; |
| 161 } else { |
| 162 RefPtr<SharedFontFamily> newFamily = SharedFontFamily::create(); |
| 163 currFamily->appendFamily(newFamily); |
| 164 currFamily = newFamily.get(); |
| 165 } |
| 166 |
| 167 currFamily->setFamily(familyName); |
| 168 |
| 169 if (genericFamily != FontDescription::NoFamily) |
| 170 desc.genericFamily = genericFamily; |
| 171 } |
| 172 |
| 173 return desc; |
| 174 } |
| 175 |
105 PassRefPtr<FontFeatureSettings> StyleBuilderConverter::convertFontFeatureSetting
s(StyleResolverState& state, CSSValue* value) | 176 PassRefPtr<FontFeatureSettings> StyleBuilderConverter::convertFontFeatureSetting
s(StyleResolverState& state, CSSValue* value) |
106 { | 177 { |
107 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() ==
CSSValueNormal) | 178 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() ==
CSSValueNormal) |
108 return FontBuilder::initialFeatureSettings(); | 179 return FontBuilder::initialFeatureSettings(); |
109 | 180 |
110 CSSValueList* list = toCSSValueList(value); | 181 CSSValueList* list = toCSSValueList(value); |
111 RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create(); | 182 RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create(); |
112 int len = list->length(); | 183 int len = list->length(); |
113 for (int i = 0; i < len; ++i) { | 184 for (int i = 0; i < len; ++i) { |
114 CSSFontFeatureValue* feature = toCSSFontFeatureValue(list->item(i)); | 185 CSSFontFeatureValue* feature = toCSSFontFeatureValue(list->item(i)); |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 { | 686 { |
616 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 687 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
617 if (primitiveValue->getValueID()) { | 688 if (primitiveValue->getValueID()) { |
618 float multiplier = convertLineWidth<float>(state, value); | 689 float multiplier = convertLineWidth<float>(state, value); |
619 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::CSS
_EMS)->computeLength<float>(state.cssToLengthConversionData()); | 690 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::CSS
_EMS)->computeLength<float>(state.cssToLengthConversionData()); |
620 } | 691 } |
621 return primitiveValue->computeLength<float>(state.cssToLengthConversionData(
)); | 692 return primitiveValue->computeLength<float>(state.cssToLengthConversionData(
)); |
622 } | 693 } |
623 | 694 |
624 } // namespace blink | 695 } // namespace blink |
OLD | NEW |