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