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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 if (value.isBasicShapeValue()) | 135 if (value.isBasicShapeValue()) |
136 return ShapeClipPathOperation::create(basicShapeForValue(state, value)); | 136 return ShapeClipPathOperation::create(basicShapeForValue(state, value)); |
137 if (value.isURIValue()) { | 137 if (value.isURIValue()) { |
138 SVGURLReferenceResolver resolver(toCSSURIValue(value).value(), | 138 SVGURLReferenceResolver resolver(toCSSURIValue(value).value(), |
139 state.document()); | 139 state.document()); |
140 // If the reference is non-local, then the fragment will remain as a | 140 // If the reference is non-local, then the fragment will remain as a |
141 // null string, which makes the element lookup fail. | 141 // null string, which makes the element lookup fail. |
142 AtomicString fragmentIdentifier; | 142 AtomicString fragmentIdentifier; |
143 if (resolver.isLocal()) | 143 if (resolver.isLocal()) |
144 fragmentIdentifier = resolver.fragmentIdentifier(); | 144 fragmentIdentifier = resolver.fragmentIdentifier(); |
145 // TODO(fs): Doesn't work with forward or external SVG references (crbug.com
/391604, crbug.com/109212, ...) | 145 // TODO(fs): Doesn't work with forward or external SVG references |
| 146 // (crbug.com/391604, crbug.com/109212, ...) |
146 return ReferenceClipPathOperation::create(toCSSURIValue(value).value(), | 147 return ReferenceClipPathOperation::create(toCSSURIValue(value).value(), |
147 fragmentIdentifier); | 148 fragmentIdentifier); |
148 } | 149 } |
149 DCHECK(value.isIdentifierValue() && | 150 DCHECK(value.isIdentifierValue() && |
150 toCSSIdentifierValue(value).getValueID() == CSSValueNone); | 151 toCSSIdentifierValue(value).getValueID() == CSSValueNone); |
151 return nullptr; | 152 return nullptr; |
152 } | 153 } |
153 | 154 |
154 FilterOperations StyleBuilderConverter::convertFilterOperations( | 155 FilterOperations StyleBuilderConverter::convertFilterOperations( |
155 StyleResolverState& state, | 156 StyleResolverState& state, |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 return AutoFlowRowDense; | 526 return AutoFlowRowDense; |
526 default: | 527 default: |
527 ASSERT_NOT_REACHED(); | 528 ASSERT_NOT_REACHED(); |
528 return ComputedStyle::initialGridAutoFlow(); | 529 return ComputedStyle::initialGridAutoFlow(); |
529 } | 530 } |
530 } | 531 } |
531 | 532 |
532 GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&, | 533 GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&, |
533 const CSSValue& value) { | 534 const CSSValue& value) { |
534 // We accept the specification's grammar: | 535 // We accept the specification's grammar: |
535 // 'auto' | [ <integer> || <custom-ident> ] | [ span && [ <integer> || <custom
-ident> ] ] | <custom-ident> | 536 // 'auto' | [ <integer> || <custom-ident> ] | |
| 537 // [ span && [ <integer> || <custom-ident> ] ] | <custom-ident> |
536 | 538 |
537 GridPosition position; | 539 GridPosition position; |
538 | 540 |
539 if (value.isCustomIdentValue()) { | 541 if (value.isCustomIdentValue()) { |
540 // We translate <custom-ident> to <string> during parsing as it | 542 // We translate <custom-ident> to <string> during parsing as it |
541 // makes handling it more simple. | 543 // makes handling it more simple. |
542 position.setNamedGridArea(toCSSCustomIdentValue(value).value()); | 544 position.setNamedGridArea(toCSSCustomIdentValue(value).value()); |
543 return position; | 545 return position; |
544 } | 546 } |
545 | 547 |
546 if (value.isIdentifierValue()) { | 548 if (value.isIdentifierValue()) { |
547 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueAuto); | 549 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueAuto); |
548 return position; | 550 return position; |
549 } | 551 } |
550 | 552 |
551 const CSSValueList& values = toCSSValueList(value); | 553 const CSSValueList& values = toCSSValueList(value); |
552 ASSERT(values.length()); | 554 ASSERT(values.length()); |
553 | 555 |
554 bool isSpanPosition = false; | 556 bool isSpanPosition = false; |
555 // The specification makes the <integer> optional, in which case it default to
'1'. | 557 // The specification makes the <integer> optional, in which case it default to |
| 558 // '1'. |
556 int gridLineNumber = 1; | 559 int gridLineNumber = 1; |
557 AtomicString gridLineName; | 560 AtomicString gridLineName; |
558 | 561 |
559 auto it = values.begin(); | 562 auto it = values.begin(); |
560 const CSSValue* currentValue = it->get(); | 563 const CSSValue* currentValue = it->get(); |
561 if (currentValue->isIdentifierValue() && | 564 if (currentValue->isIdentifierValue() && |
562 toCSSIdentifierValue(currentValue)->getValueID() == CSSValueSpan) { | 565 toCSSIdentifierValue(currentValue)->getValueID() == CSSValueSpan) { |
563 isSpanPosition = true; | 566 isSpanPosition = true; |
564 ++it; | 567 ++it; |
565 currentValue = it != values.end() ? it->get() : nullptr; | 568 currentValue = it != values.end() ? it->get() : nullptr; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 convertGridTrackSize(state, *autoRepeatValue)); | 683 convertGridTrackSize(state, *autoRepeatValue)); |
681 } | 684 } |
682 autoRepeatInsertionPoint = currentNamedGridLine++; | 685 autoRepeatInsertionPoint = currentNamedGridLine++; |
683 continue; | 686 continue; |
684 } | 687 } |
685 | 688 |
686 ++currentNamedGridLine; | 689 ++currentNamedGridLine; |
687 trackSizes.append(convertGridTrackSize(state, *currValue)); | 690 trackSizes.append(convertGridTrackSize(state, *currValue)); |
688 } | 691 } |
689 | 692 |
690 // The parser should have rejected any <track-list> without any <track-size> a
s | 693 // The parser should have rejected any <track-list> without any <track-size> |
691 // this is not conformant to the syntax. | 694 // as this is not conformant to the syntax. |
692 ASSERT(!trackSizes.isEmpty() || !autoRepeatTrackSizes.isEmpty()); | 695 ASSERT(!trackSizes.isEmpty() || !autoRepeatTrackSizes.isEmpty()); |
693 } | 696 } |
694 | 697 |
695 void StyleBuilderConverter::convertOrderedNamedGridLinesMapToNamedGridLinesMap( | 698 void StyleBuilderConverter::convertOrderedNamedGridLinesMapToNamedGridLinesMap( |
696 const OrderedNamedGridLines& orderedNamedGridLines, | 699 const OrderedNamedGridLines& orderedNamedGridLines, |
697 NamedGridLinesMap& namedGridLines) { | 700 NamedGridLinesMap& namedGridLines) { |
698 ASSERT(namedGridLines.size() == 0); | 701 ASSERT(namedGridLines.size() == 0); |
699 | 702 |
700 if (orderedNamedGridLines.size() == 0) | 703 if (orderedNamedGridLines.size() == 0) |
701 return; | 704 return; |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 const CSSValue& value) { | 1258 const CSSValue& value) { |
1256 if (value.isPathValue()) | 1259 if (value.isPathValue()) |
1257 return toCSSPathValue(value).stylePath(); | 1260 return toCSSPathValue(value).stylePath(); |
1258 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); | 1261 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
1259 return nullptr; | 1262 return nullptr; |
1260 } | 1263 } |
1261 | 1264 |
1262 const CSSValue& StyleBuilderConverter::convertRegisteredPropertyValue( | 1265 const CSSValue& StyleBuilderConverter::convertRegisteredPropertyValue( |
1263 const StyleResolverState& state, | 1266 const StyleResolverState& state, |
1264 const CSSValue& value) { | 1267 const CSSValue& value) { |
1265 // TODO(timloh): Images and transform-function values can also contain lengths
. | 1268 // TODO(timloh): Images and transform-function values can also contain |
| 1269 // lengths. |
1266 if (value.isValueList()) { | 1270 if (value.isValueList()) { |
1267 CSSValueList* newList = CSSValueList::createSpaceSeparated(); | 1271 CSSValueList* newList = CSSValueList::createSpaceSeparated(); |
1268 for (const CSSValue* innerValue : toCSSValueList(value)) | 1272 for (const CSSValue* innerValue : toCSSValueList(value)) |
1269 newList->append(convertRegisteredPropertyValue(state, *innerValue)); | 1273 newList->append(convertRegisteredPropertyValue(state, *innerValue)); |
1270 return *newList; | 1274 return *newList; |
1271 } | 1275 } |
1272 | 1276 |
1273 if (value.isPrimitiveValue()) { | 1277 if (value.isPrimitiveValue()) { |
1274 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 1278 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
1275 if (primitiveValue.isCalculated() || | 1279 if (primitiveValue.isCalculated() || |
1276 CSSPrimitiveValue::isRelativeUnit( | 1280 CSSPrimitiveValue::isRelativeUnit( |
1277 primitiveValue.typeWithCalcResolved())) { | 1281 primitiveValue.typeWithCalcResolved())) { |
1278 // Instead of the actual zoom, use 1 to avoid potential rounding errors | 1282 // Instead of the actual zoom, use 1 to avoid potential rounding errors |
1279 Length length = primitiveValue.convertToLength( | 1283 Length length = primitiveValue.convertToLength( |
1280 state.cssToLengthConversionData().copyWithAdjustedZoom(1)); | 1284 state.cssToLengthConversionData().copyWithAdjustedZoom(1)); |
1281 return *CSSPrimitiveValue::create(length, 1); | 1285 return *CSSPrimitiveValue::create(length, 1); |
1282 } | 1286 } |
1283 } | 1287 } |
1284 return value; | 1288 return value; |
1285 } | 1289 } |
1286 | 1290 |
1287 } // namespace blink | 1291 } // namespace blink |
OLD | NEW |