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 19 matching lines...) Expand all Loading... | |
30 #include "core/css/BasicShapeFunctions.h" | 30 #include "core/css/BasicShapeFunctions.h" |
31 #include "core/css/CSSBasicShapeValues.h" | 31 #include "core/css/CSSBasicShapeValues.h" |
32 #include "core/css/CSSContentDistributionValue.h" | 32 #include "core/css/CSSContentDistributionValue.h" |
33 #include "core/css/CSSFontFeatureValue.h" | 33 #include "core/css/CSSFontFeatureValue.h" |
34 #include "core/css/CSSFunctionValue.h" | 34 #include "core/css/CSSFunctionValue.h" |
35 #include "core/css/CSSGridLineNamesValue.h" | 35 #include "core/css/CSSGridLineNamesValue.h" |
36 #include "core/css/CSSPrimitiveValueMappings.h" | 36 #include "core/css/CSSPrimitiveValueMappings.h" |
37 #include "core/css/CSSQuadValue.h" | 37 #include "core/css/CSSQuadValue.h" |
38 #include "core/css/CSSReflectValue.h" | 38 #include "core/css/CSSReflectValue.h" |
39 #include "core/css/CSSShadowValue.h" | 39 #include "core/css/CSSShadowValue.h" |
40 #include "core/css/CSSStringValue.h" | |
41 #include "core/css/CSSURIValue.h" | |
40 #include "core/css/CSSValuePair.h" | 42 #include "core/css/CSSValuePair.h" |
41 #include "core/svg/SVGElement.h" | 43 #include "core/svg/SVGElement.h" |
42 #include "core/svg/SVGURIReference.h" | 44 #include "core/svg/SVGURIReference.h" |
43 #include "platform/transforms/RotateTransformOperation.h" | 45 #include "platform/transforms/RotateTransformOperation.h" |
44 #include "platform/transforms/ScaleTransformOperation.h" | 46 #include "platform/transforms/ScaleTransformOperation.h" |
45 #include "platform/transforms/TranslateTransformOperation.h" | 47 #include "platform/transforms/TranslateTransformOperation.h" |
46 | 48 |
47 namespace blink { | 49 namespace blink { |
48 | 50 |
49 namespace { | 51 namespace { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 } | 88 } |
87 | 89 |
88 Color StyleBuilderConverter::convertColor(StyleResolverState& state, CSSValue* v alue, bool forVisitedLink) | 90 Color StyleBuilderConverter::convertColor(StyleResolverState& state, CSSValue* v alue, bool forVisitedLink) |
89 { | 91 { |
90 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 92 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
91 return state.document().textLinkColors().colorFromPrimitiveValue(primitiveVa lue, state.style()->color(), forVisitedLink); | 93 return state.document().textLinkColors().colorFromPrimitiveValue(primitiveVa lue, state.style()->color(), forVisitedLink); |
92 } | 94 } |
93 | 95 |
94 AtomicString StyleBuilderConverter::convertFragmentIdentifier(StyleResolverState & state, CSSValue* value) | 96 AtomicString StyleBuilderConverter::convertFragmentIdentifier(StyleResolverState & state, CSSValue* value) |
95 { | 97 { |
96 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 98 if (value->isURIValue()) |
97 if (primitiveValue->isURI()) | 99 return SVGURIReference::fragmentIdentifierFromIRIString(toCSSURIValue(va lue)->value(), state.element()->treeScope()); |
98 return SVGURIReference::fragmentIdentifierFromIRIString(primitiveValue-> getStringValue(), state.element()->treeScope()); | |
99 return nullAtom; | 100 return nullAtom; |
100 } | 101 } |
101 | 102 |
102 LengthBox StyleBuilderConverter::convertClip(StyleResolverState& state, CSSValue * value) | 103 LengthBox StyleBuilderConverter::convertClip(StyleResolverState& state, CSSValue * value) |
103 { | 104 { |
104 RefPtrWillBeRawPtr<CSSQuadValue> rect = toCSSQuadValue(value); | 105 RefPtrWillBeRawPtr<CSSQuadValue> rect = toCSSQuadValue(value); |
105 | 106 |
106 return LengthBox(convertLengthOrAuto(state, rect->top()), | 107 return LengthBox(convertLengthOrAuto(state, rect->top()), |
107 convertLengthOrAuto(state, rect->right()), | 108 convertLengthOrAuto(state, rect->right()), |
108 convertLengthOrAuto(state, rect->bottom()), | 109 convertLengthOrAuto(state, rect->bottom()), |
(...skipping 15 matching lines...) Expand all Loading... | |
124 return FontDescription::FantasyFamily; | 125 return FontDescription::FantasyFamily; |
125 case CSSValueMonospace: | 126 case CSSValueMonospace: |
126 return FontDescription::MonospaceFamily; | 127 return FontDescription::MonospaceFamily; |
127 case CSSValueWebkitPictograph: | 128 case CSSValueWebkitPictograph: |
128 return FontDescription::PictographFamily; | 129 return FontDescription::PictographFamily; |
129 default: | 130 default: |
130 return FontDescription::NoFamily; | 131 return FontDescription::NoFamily; |
131 } | 132 } |
132 } | 133 } |
133 | 134 |
134 static bool convertFontFamilyName(StyleResolverState& state, CSSPrimitiveValue* primitiveValue, | 135 static bool convertFontFamilyName(StyleResolverState& state, CSSValue& value, |
135 FontDescription::GenericFamilyType& genericFamily, AtomicString& familyName) | 136 FontDescription::GenericFamilyType& genericFamily, AtomicString& familyName) |
136 { | 137 { |
137 if (primitiveValue->isCustomIdent()) { | 138 if (value.isCustomIdentValue()) { |
138 genericFamily = FontDescription::NoFamily; | 139 genericFamily = FontDescription::NoFamily; |
139 familyName = AtomicString(primitiveValue->getStringValue()); | 140 familyName = AtomicString(toCSSCustomIdentValue(value).value()); |
140 } else if (state.document().settings()) { | 141 } else if (state.document().settings()) { |
141 genericFamily = convertGenericFamily(primitiveValue->getValueID()); | 142 genericFamily = convertGenericFamily(toCSSPrimitiveValue(value).getValue ID()); |
142 familyName = state.fontBuilder().genericFontFamilyName(genericFamily); | 143 familyName = state.fontBuilder().genericFontFamilyName(genericFamily); |
143 } | 144 } |
144 | 145 |
145 return !familyName.isEmpty(); | 146 return !familyName.isEmpty(); |
146 } | 147 } |
147 | 148 |
148 FontDescription::FamilyDescription StyleBuilderConverter::convertFontFamily(Styl eResolverState& state, CSSValue* value) | 149 FontDescription::FamilyDescription StyleBuilderConverter::convertFontFamily(Styl eResolverState& state, CSSValue* value) |
149 { | 150 { |
150 ASSERT(value->isValueList()); | 151 ASSERT(value->isValueList()); |
151 | 152 |
152 FontDescription::FamilyDescription desc(FontDescription::NoFamily); | 153 FontDescription::FamilyDescription desc(FontDescription::NoFamily); |
153 FontFamily* currFamily = nullptr; | 154 FontFamily* currFamily = nullptr; |
154 | 155 |
155 for (auto& family : toCSSValueList(*value)) { | 156 for (auto& family : toCSSValueList(*value)) { |
156 FontDescription::GenericFamilyType genericFamily = FontDescription::NoFa mily; | 157 FontDescription::GenericFamilyType genericFamily = FontDescription::NoFa mily; |
157 AtomicString familyName; | 158 AtomicString familyName; |
158 | 159 |
159 if (!convertFontFamilyName(state, toCSSPrimitiveValue(family.get()), gen ericFamily, familyName)) | 160 if (!convertFontFamilyName(state, *family, genericFamily, familyName)) |
160 continue; | 161 continue; |
161 | 162 |
162 if (!currFamily) { | 163 if (!currFamily) { |
163 currFamily = &desc.family; | 164 currFamily = &desc.family; |
164 } else { | 165 } else { |
165 RefPtr<SharedFontFamily> newFamily = SharedFontFamily::create(); | 166 RefPtr<SharedFontFamily> newFamily = SharedFontFamily::create(); |
166 currFamily->appendFamily(newFamily); | 167 currFamily->appendFamily(newFamily); |
167 currFamily = newFamily.get(); | 168 currFamily = newFamily.get(); |
168 } | 169 } |
169 | 170 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 } | 410 } |
410 } | 411 } |
411 | 412 |
412 GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&, CSS Value* value) | 413 GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&, CSS Value* value) |
413 { | 414 { |
414 // We accept the specification's grammar: | 415 // We accept the specification's grammar: |
415 // 'auto' | [ <integer> || <custom-ident> ] | [ span && [ <integer> || <cust om-ident> ] ] | <custom-ident> | 416 // 'auto' | [ <integer> || <custom-ident> ] | [ span && [ <integer> || <cust om-ident> ] ] | <custom-ident> |
416 | 417 |
417 GridPosition position; | 418 GridPosition position; |
418 | 419 |
419 if (value->isPrimitiveValue()) { | 420 if (value->isCustomIdentValue()) { |
420 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
421 // We translate <custom-ident> to <string> during parsing as it | 421 // We translate <custom-ident> to <string> during parsing as it |
422 // makes handling it more simple. | 422 // makes handling it more simple. |
423 if (primitiveValue->isCustomIdent()) { | 423 position.setNamedGridArea(toCSSCustomIdentValue(value)->value()); |
424 position.setNamedGridArea(primitiveValue->getStringValue()); | |
425 return position; | |
426 } | |
427 | |
428 ASSERT(primitiveValue->getValueID() == CSSValueAuto); | |
429 return position; | 424 return position; |
430 } | 425 } |
431 | 426 |
427 if (value->isPrimitiveValue()) { | |
428 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueAuto); | |
429 return position; | |
430 } | |
431 | |
432 CSSValueList* values = toCSSValueList(value); | 432 CSSValueList* values = toCSSValueList(value); |
433 ASSERT(values->length()); | 433 ASSERT(values->length()); |
434 | 434 |
435 bool isSpanPosition = false; | 435 bool isSpanPosition = false; |
436 // The specification makes the <integer> optional, in which case it default to '1'. | 436 // The specification makes the <integer> optional, in which case it default to '1'. |
437 int gridLineNumber = 1; | 437 int gridLineNumber = 1; |
438 String gridLineName; | 438 String gridLineName; |
439 | 439 |
440 auto it = values->begin(); | 440 auto it = values->begin(); |
441 CSSPrimitiveValue* currentValue = toCSSPrimitiveValue(it->get()); | 441 CSSValue* currentValue = it->get(); |
442 if (currentValue->getValueID() == CSSValueSpan) { | 442 if (currentValue->isPrimitiveValue() && toCSSPrimitiveValue(currentValue)->g etValueID() == CSSValueSpan) { |
443 isSpanPosition = true; | 443 isSpanPosition = true; |
444 ++it; | 444 ++it; |
445 currentValue = it != values->end() ? toCSSPrimitiveValue(it->get()) : nu llptr; | 445 currentValue = it != values->end() ? it->get() : nullptr; |
446 } | 446 } |
447 | 447 |
448 if (currentValue && currentValue->isNumber()) { | 448 if (currentValue && currentValue->isPrimitiveValue() && toCSSPrimitiveValue( currentValue)->isNumber()) { |
449 gridLineNumber = currentValue->getIntValue(); | 449 gridLineNumber = toCSSPrimitiveValue(currentValue)->getIntValue(); |
450 ++it; | 450 ++it; |
451 currentValue = it != values->end() ? toCSSPrimitiveValue(it->get()) : nu llptr; | 451 currentValue = it != values->end() ? it->get() : nullptr; |
452 } | 452 } |
453 | 453 |
454 if (currentValue && currentValue->isCustomIdent()) { | 454 if (currentValue && currentValue->isCustomIdentValue()) { |
455 gridLineName = currentValue->getStringValue(); | 455 gridLineName = toCSSCustomIdentValue(currentValue)->value(); |
456 ++it; | 456 ++it; |
457 } | 457 } |
458 | 458 |
459 ASSERT(it == values->end()); | 459 ASSERT(it == values->end()); |
460 if (isSpanPosition) | 460 if (isSpanPosition) |
461 position.setSpanPosition(gridLineNumber, gridLineName); | 461 position.setSpanPosition(gridLineNumber, gridLineName); |
462 else | 462 else |
463 position.setExplicitPosition(gridLineNumber, gridLineName); | 463 position.setExplicitPosition(gridLineNumber, gridLineName); |
464 | 464 |
465 return position; | 465 return position; |
(...skipping 15 matching lines...) Expand all Loading... | |
481 { | 481 { |
482 if (value->isPrimitiveValue()) { | 482 if (value->isPrimitiveValue()) { |
483 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone); | 483 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone); |
484 return; | 484 return; |
485 } | 485 } |
486 | 486 |
487 size_t currentNamedGridLine = 0; | 487 size_t currentNamedGridLine = 0; |
488 for (auto& currValue : *toCSSValueList(value)) { | 488 for (auto& currValue : *toCSSValueList(value)) { |
489 if (currValue->isGridLineNamesValue()) { | 489 if (currValue->isGridLineNamesValue()) { |
490 for (auto& namedGridLineValue : toCSSGridLineNamesValue(*currValue)) { | 490 for (auto& namedGridLineValue : toCSSGridLineNamesValue(*currValue)) { |
491 ASSERT(toCSSPrimitiveValue(namedGridLineValue.get())->isCustomId ent()); | 491 ASSERT(namedGridLineValue->isCustomIdentValue()); |
Timothy Loh
2015/10/02 05:35:25
no need to assert, the conversionbelow checks
sashab
2015/10/02 06:07:54
Good point, thanks. :)
| |
492 String namedGridLine = toCSSPrimitiveValue(namedGridLineValue.ge t())->getStringValue(); | 492 String namedGridLine = toCSSCustomIdentValue(*namedGridLineValue ).value(); |
493 NamedGridLinesMap::AddResult result = namedGridLines.add(namedGr idLine, Vector<size_t>()); | 493 NamedGridLinesMap::AddResult result = namedGridLines.add(namedGr idLine, Vector<size_t>()); |
494 result.storedValue->value.append(currentNamedGridLine); | 494 result.storedValue->value.append(currentNamedGridLine); |
495 OrderedNamedGridLines::AddResult orderedInsertionResult = ordere dNamedGridLines.add(currentNamedGridLine, Vector<String>()); | 495 OrderedNamedGridLines::AddResult orderedInsertionResult = ordere dNamedGridLines.add(currentNamedGridLine, Vector<String>()); |
496 orderedInsertionResult.storedValue->value.append(namedGridLine); | 496 orderedInsertionResult.storedValue->value.append(namedGridLine); |
497 } | 497 } |
498 continue; | 498 continue; |
499 } | 499 } |
500 | 500 |
501 ++currentNamedGridLine; | 501 ++currentNamedGridLine; |
502 trackSizes.append(convertGridTrackSize(state, currValue.get())); | 502 trackSizes.append(convertGridTrackSize(state, currValue.get())); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
741 length.setQuirk(toCSSPrimitiveValue(value)->isQuirkyEms()); | 741 length.setQuirk(toCSSPrimitiveValue(value)->isQuirkyEms()); |
742 return length; | 742 return length; |
743 } | 743 } |
744 | 744 |
745 PassRefPtr<QuotesData> StyleBuilderConverter::convertQuotes(StyleResolverState&, CSSValue* value) | 745 PassRefPtr<QuotesData> StyleBuilderConverter::convertQuotes(StyleResolverState&, CSSValue* value) |
746 { | 746 { |
747 if (value->isValueList()) { | 747 if (value->isValueList()) { |
748 CSSValueList* list = toCSSValueList(value); | 748 CSSValueList* list = toCSSValueList(value); |
749 RefPtr<QuotesData> quotes = QuotesData::create(); | 749 RefPtr<QuotesData> quotes = QuotesData::create(); |
750 for (size_t i = 0; i < list->length(); i += 2) { | 750 for (size_t i = 0; i < list->length(); i += 2) { |
751 CSSValue* first = list->item(i); | 751 String startQuote = toCSSStringValue(list->item(i))->value(); |
752 CSSValue* second = list->item(i + 1); | 752 String endQuote = toCSSStringValue(list->item(i + 1))->value(); |
753 ASSERT(toCSSPrimitiveValue(first)->isString()); | |
754 ASSERT(toCSSPrimitiveValue(second)->isString()); | |
755 String startQuote = toCSSPrimitiveValue(first)->getStringValue(); | |
756 String endQuote = toCSSPrimitiveValue(second)->getStringValue(); | |
757 quotes->addPair(std::make_pair(startQuote, endQuote)); | 753 quotes->addPair(std::make_pair(startQuote, endQuote)); |
758 } | 754 } |
759 return quotes.release(); | 755 return quotes.release(); |
760 } | 756 } |
761 ASSERT(value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueNone); | 757 ASSERT(value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueNone); |
762 return QuotesData::create(); | 758 return QuotesData::create(); |
763 } | 759 } |
764 | 760 |
765 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, CSSVa lue* value) | 761 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, CSSVa lue* value) |
766 { | 762 { |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
968 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale 3D); | 964 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale 3D); |
969 } | 965 } |
970 | 966 |
971 RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation(Style ResolverState& state, CSSValue* value) | 967 RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation(Style ResolverState& state, CSSValue* value) |
972 { | 968 { |
973 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 969 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
974 return primitiveValue->getValueID() == CSSValueFromImage ? RespectImageOrien tation : DoNotRespectImageOrientation; | 970 return primitiveValue->getValueID() == CSSValueFromImage ? RespectImageOrien tation : DoNotRespectImageOrientation; |
975 } | 971 } |
976 | 972 |
977 } // namespace blink | 973 } // namespace blink |
OLD | NEW |