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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 convertGenericFamily(toCSSIdentifierValue(value).getValueID()); | 203 convertGenericFamily(toCSSIdentifierValue(value).getValueID()); |
204 familyName = state.fontBuilder().genericFontFamilyName(genericFamily); | 204 familyName = state.fontBuilder().genericFontFamilyName(genericFamily); |
205 } | 205 } |
206 | 206 |
207 return !familyName.isEmpty(); | 207 return !familyName.isEmpty(); |
208 } | 208 } |
209 | 209 |
210 FontDescription::FamilyDescription StyleBuilderConverter::convertFontFamily( | 210 FontDescription::FamilyDescription StyleBuilderConverter::convertFontFamily( |
211 StyleResolverState& state, | 211 StyleResolverState& state, |
212 const CSSValue& value) { | 212 const CSSValue& value) { |
213 ASSERT(value.isValueList()); | 213 DCHECK(value.isValueList()); |
214 | 214 |
215 FontDescription::FamilyDescription desc(FontDescription::NoFamily); | 215 FontDescription::FamilyDescription desc(FontDescription::NoFamily); |
216 FontFamily* currFamily = nullptr; | 216 FontFamily* currFamily = nullptr; |
217 | 217 |
218 for (auto& family : toCSSValueList(value)) { | 218 for (auto& family : toCSSValueList(value)) { |
219 FontDescription::GenericFamilyType genericFamily = | 219 FontDescription::GenericFamilyType genericFamily = |
220 FontDescription::NoFamily; | 220 FontDescription::NoFamily; |
221 AtomicString familyName; | 221 AtomicString familyName; |
222 | 222 |
223 if (!convertFontFamilyName(state, *family, genericFamily, familyName)) | 223 if (!convertFontFamilyName(state, *family, genericFamily, familyName)) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 static float computeFontSize(StyleResolverState& state, | 278 static float computeFontSize(StyleResolverState& state, |
279 const CSSPrimitiveValue& primitiveValue, | 279 const CSSPrimitiveValue& primitiveValue, |
280 const FontDescription::Size& parentSize) { | 280 const FontDescription::Size& parentSize) { |
281 if (primitiveValue.isLength()) | 281 if (primitiveValue.isLength()) |
282 return primitiveValue.computeLength<float>(state.fontSizeConversionData()); | 282 return primitiveValue.computeLength<float>(state.fontSizeConversionData()); |
283 if (primitiveValue.isCalculatedPercentageWithLength()) | 283 if (primitiveValue.isCalculatedPercentageWithLength()) |
284 return primitiveValue.cssCalcValue() | 284 return primitiveValue.cssCalcValue() |
285 ->toCalcValue(state.fontSizeConversionData()) | 285 ->toCalcValue(state.fontSizeConversionData()) |
286 ->evaluate(parentSize.value); | 286 ->evaluate(parentSize.value); |
287 | 287 |
288 ASSERT_NOT_REACHED(); | 288 NOTREACHED(); |
289 return 0; | 289 return 0; |
290 } | 290 } |
291 | 291 |
292 FontDescription::Size StyleBuilderConverter::convertFontSize( | 292 FontDescription::Size StyleBuilderConverter::convertFontSize( |
293 StyleResolverState& state, | 293 StyleResolverState& state, |
294 const CSSValue& value) { | 294 const CSSValue& value) { |
295 FontDescription::Size parentSize(0, 0.0f, false); | 295 FontDescription::Size parentSize(0, 0.0f, false); |
296 | 296 |
297 // FIXME: Find out when parentStyle could be 0? | 297 // FIXME: Find out when parentStyle could be 0? |
298 if (state.parentStyle()) | 298 if (state.parentStyle()) |
299 parentSize = state.parentFontDescription().getSize(); | 299 parentSize = state.parentFontDescription().getSize(); |
300 | 300 |
301 if (value.isIdentifierValue()) { | 301 if (value.isIdentifierValue()) { |
302 CSSValueID valueID = toCSSIdentifierValue(value).getValueID(); | 302 CSSValueID valueID = toCSSIdentifierValue(value).getValueID(); |
303 if (FontSize::isValidValueID(valueID)) | 303 if (FontSize::isValidValueID(valueID)) |
304 return FontDescription::Size(FontSize::keywordSize(valueID), 0.0f, false); | 304 return FontDescription::Size(FontSize::keywordSize(valueID), 0.0f, false); |
305 if (valueID == CSSValueSmaller) | 305 if (valueID == CSSValueSmaller) |
306 return FontDescription::smallerSize(parentSize); | 306 return FontDescription::smallerSize(parentSize); |
307 if (valueID == CSSValueLarger) | 307 if (valueID == CSSValueLarger) |
308 return FontDescription::largerSize(parentSize); | 308 return FontDescription::largerSize(parentSize); |
309 ASSERT_NOT_REACHED(); | 309 NOTREACHED(); |
310 return FontBuilder::initialSize(); | 310 return FontBuilder::initialSize(); |
311 } | 311 } |
312 | 312 |
313 bool parentIsAbsoluteSize = state.parentFontDescription().isAbsoluteSize(); | 313 bool parentIsAbsoluteSize = state.parentFontDescription().isAbsoluteSize(); |
314 | 314 |
315 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 315 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
316 if (primitiveValue.isPercentage()) | 316 if (primitiveValue.isPercentage()) |
317 return FontDescription::Size( | 317 return FontDescription::Size( |
318 0, (primitiveValue.getFloatValue() * parentSize.value / 100.0f), | 318 0, (primitiveValue.getFloatValue() * parentSize.value / 100.0f), |
319 parentIsAbsoluteSize); | 319 parentIsAbsoluteSize); |
320 | 320 |
321 return FontDescription::Size( | 321 return FontDescription::Size( |
322 0, computeFontSize(state, primitiveValue, parentSize), | 322 0, computeFontSize(state, primitiveValue, parentSize), |
323 parentIsAbsoluteSize || !primitiveValue.isFontRelativeLength()); | 323 parentIsAbsoluteSize || !primitiveValue.isFontRelativeLength()); |
324 } | 324 } |
325 | 325 |
326 float StyleBuilderConverter::convertFontSizeAdjust(StyleResolverState& state, | 326 float StyleBuilderConverter::convertFontSizeAdjust(StyleResolverState& state, |
327 const CSSValue& value) { | 327 const CSSValue& value) { |
328 if (value.isIdentifierValue() && | 328 if (value.isIdentifierValue() && |
329 toCSSIdentifierValue(value).getValueID() == CSSValueNone) | 329 toCSSIdentifierValue(value).getValueID() == CSSValueNone) |
330 return FontBuilder::initialSizeAdjust(); | 330 return FontBuilder::initialSizeAdjust(); |
331 | 331 |
332 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 332 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
333 ASSERT(primitiveValue.isNumber()); | 333 DCHECK(primitiveValue.isNumber()); |
334 return primitiveValue.getFloatValue(); | 334 return primitiveValue.getFloatValue(); |
335 } | 335 } |
336 | 336 |
337 double StyleBuilderConverter::convertValueToNumber( | 337 double StyleBuilderConverter::convertValueToNumber( |
338 const CSSFunctionValue* filter, | 338 const CSSFunctionValue* filter, |
339 const CSSPrimitiveValue* value) { | 339 const CSSPrimitiveValue* value) { |
340 switch (filter->functionType()) { | 340 switch (filter->functionType()) { |
341 case CSSValueGrayscale: | 341 case CSSValueGrayscale: |
342 case CSSValueSepia: | 342 case CSSValueSepia: |
343 case CSSValueSaturate: | 343 case CSSValueSaturate: |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 case CSSValueHistoricalLigatures: | 431 case CSSValueHistoricalLigatures: |
432 ligatures.historical = FontDescription::EnabledLigaturesState; | 432 ligatures.historical = FontDescription::EnabledLigaturesState; |
433 break; | 433 break; |
434 case CSSValueNoContextual: | 434 case CSSValueNoContextual: |
435 ligatures.contextual = FontDescription::DisabledLigaturesState; | 435 ligatures.contextual = FontDescription::DisabledLigaturesState; |
436 break; | 436 break; |
437 case CSSValueContextual: | 437 case CSSValueContextual: |
438 ligatures.contextual = FontDescription::EnabledLigaturesState; | 438 ligatures.contextual = FontDescription::EnabledLigaturesState; |
439 break; | 439 break; |
440 default: | 440 default: |
441 ASSERT_NOT_REACHED(); | 441 NOTREACHED(); |
442 break; | 442 break; |
443 } | 443 } |
444 } | 444 } |
445 return ligatures; | 445 return ligatures; |
446 } | 446 } |
447 | 447 |
448 SECURITY_DCHECK(value.isIdentifierValue()); | 448 SECURITY_DCHECK(value.isIdentifierValue()); |
449 if (toCSSIdentifierValue(value).getValueID() == CSSValueNone) { | 449 if (toCSSIdentifierValue(value).getValueID() == CSSValueNone) { |
450 return FontDescription::VariantLigatures( | 450 return FontDescription::VariantLigatures( |
451 FontDescription::DisabledLigaturesState); | 451 FontDescription::DisabledLigaturesState); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 case CSSValueStackedFractions: | 485 case CSSValueStackedFractions: |
486 variantNumeric.setNumericFraction(FontVariantNumeric::StackedFractions); | 486 variantNumeric.setNumericFraction(FontVariantNumeric::StackedFractions); |
487 break; | 487 break; |
488 case CSSValueOrdinal: | 488 case CSSValueOrdinal: |
489 variantNumeric.setOrdinal(FontVariantNumeric::OrdinalOn); | 489 variantNumeric.setOrdinal(FontVariantNumeric::OrdinalOn); |
490 break; | 490 break; |
491 case CSSValueSlashedZero: | 491 case CSSValueSlashedZero: |
492 variantNumeric.setSlashedZero(FontVariantNumeric::SlashedZeroOn); | 492 variantNumeric.setSlashedZero(FontVariantNumeric::SlashedZeroOn); |
493 break; | 493 break; |
494 default: | 494 default: |
495 ASSERT_NOT_REACHED(); | 495 NOTREACHED(); |
496 break; | 496 break; |
497 } | 497 } |
498 } | 498 } |
499 return variantNumeric; | 499 return variantNumeric; |
500 } | 500 } |
501 | 501 |
502 StyleSelfAlignmentData StyleBuilderConverter::convertSelfOrDefaultAlignmentData( | 502 StyleSelfAlignmentData StyleBuilderConverter::convertSelfOrDefaultAlignmentData( |
503 StyleResolverState&, | 503 StyleResolverState&, |
504 const CSSValue& value) { | 504 const CSSValue& value) { |
505 StyleSelfAlignmentData alignmentData = ComputedStyle::initialSelfAlignment(); | 505 StyleSelfAlignmentData alignmentData = ComputedStyle::initialSelfAlignment(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 case CSSValueSpaceAround: | 541 case CSSValueSpaceAround: |
542 alignmentData.setDistribution( | 542 alignmentData.setDistribution( |
543 identifierValue.convertTo<ContentDistributionType>()); | 543 identifierValue.convertTo<ContentDistributionType>()); |
544 break; | 544 break; |
545 case CSSValueFlexStart: | 545 case CSSValueFlexStart: |
546 case CSSValueFlexEnd: | 546 case CSSValueFlexEnd: |
547 case CSSValueCenter: | 547 case CSSValueCenter: |
548 alignmentData.setPosition(identifierValue.convertTo<ContentPosition>()); | 548 alignmentData.setPosition(identifierValue.convertTo<ContentPosition>()); |
549 break; | 549 break; |
550 default: | 550 default: |
551 ASSERT_NOT_REACHED(); | 551 NOTREACHED(); |
552 } | 552 } |
553 return alignmentData; | 553 return alignmentData; |
554 } | 554 } |
555 const CSSContentDistributionValue& contentValue = | 555 const CSSContentDistributionValue& contentValue = |
556 toCSSContentDistributionValue(value); | 556 toCSSContentDistributionValue(value); |
557 if (contentValue.distribution()->getValueID() != CSSValueInvalid) | 557 if (contentValue.distribution()->getValueID() != CSSValueInvalid) |
558 alignmentData.setDistribution( | 558 alignmentData.setDistribution( |
559 contentValue.distribution()->convertTo<ContentDistributionType>()); | 559 contentValue.distribution()->convertTo<ContentDistributionType>()); |
560 if (contentValue.position()->getValueID() != CSSValueInvalid) | 560 if (contentValue.position()->getValueID() != CSSValueInvalid) |
561 alignmentData.setPosition( | 561 alignmentData.setPosition( |
562 contentValue.position()->convertTo<ContentPosition>()); | 562 contentValue.position()->convertTo<ContentPosition>()); |
563 if (contentValue.overflow()->getValueID() != CSSValueInvalid) | 563 if (contentValue.overflow()->getValueID() != CSSValueInvalid) |
564 alignmentData.setOverflow( | 564 alignmentData.setOverflow( |
565 contentValue.overflow()->convertTo<OverflowAlignment>()); | 565 contentValue.overflow()->convertTo<OverflowAlignment>()); |
566 | 566 |
567 return alignmentData; | 567 return alignmentData; |
568 } | 568 } |
569 | 569 |
570 GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(StyleResolverState&, | 570 GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(StyleResolverState&, |
571 const CSSValue& value) { | 571 const CSSValue& value) { |
572 const CSSValueList& list = toCSSValueList(value); | 572 const CSSValueList& list = toCSSValueList(value); |
573 | 573 |
574 ASSERT(list.length() >= 1); | 574 DCHECK_GE(list.length(), 1u); |
575 const CSSIdentifierValue& first = toCSSIdentifierValue(list.item(0)); | 575 const CSSIdentifierValue& first = toCSSIdentifierValue(list.item(0)); |
576 const CSSIdentifierValue* second = | 576 const CSSIdentifierValue* second = |
577 list.length() == 2 ? &toCSSIdentifierValue(list.item(1)) : nullptr; | 577 list.length() == 2 ? &toCSSIdentifierValue(list.item(1)) : nullptr; |
578 | 578 |
579 switch (first.getValueID()) { | 579 switch (first.getValueID()) { |
580 case CSSValueRow: | 580 case CSSValueRow: |
581 if (second && second->getValueID() == CSSValueDense) | 581 if (second && second->getValueID() == CSSValueDense) |
582 return AutoFlowRowDense; | 582 return AutoFlowRowDense; |
583 return AutoFlowRow; | 583 return AutoFlowRow; |
584 case CSSValueColumn: | 584 case CSSValueColumn: |
585 if (second && second->getValueID() == CSSValueDense) | 585 if (second && second->getValueID() == CSSValueDense) |
586 return AutoFlowColumnDense; | 586 return AutoFlowColumnDense; |
587 return AutoFlowColumn; | 587 return AutoFlowColumn; |
588 case CSSValueDense: | 588 case CSSValueDense: |
589 if (second && second->getValueID() == CSSValueColumn) | 589 if (second && second->getValueID() == CSSValueColumn) |
590 return AutoFlowColumnDense; | 590 return AutoFlowColumnDense; |
591 return AutoFlowRowDense; | 591 return AutoFlowRowDense; |
592 default: | 592 default: |
593 ASSERT_NOT_REACHED(); | 593 NOTREACHED(); |
594 return ComputedStyle::initialGridAutoFlow(); | 594 return ComputedStyle::initialGridAutoFlow(); |
595 } | 595 } |
596 } | 596 } |
597 | 597 |
598 GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&, | 598 GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&, |
599 const CSSValue& value) { | 599 const CSSValue& value) { |
600 // We accept the specification's grammar: | 600 // We accept the specification's grammar: |
601 // 'auto' | [ <integer> || <custom-ident> ] | | 601 // 'auto' | [ <integer> || <custom-ident> ] | |
602 // [ span && [ <integer> || <custom-ident> ] ] | <custom-ident> | 602 // [ span && [ <integer> || <custom-ident> ] ] | <custom-ident> |
603 | 603 |
604 GridPosition position; | 604 GridPosition position; |
605 | 605 |
606 if (value.isCustomIdentValue()) { | 606 if (value.isCustomIdentValue()) { |
607 position.setNamedGridArea(toCSSCustomIdentValue(value).value()); | 607 position.setNamedGridArea(toCSSCustomIdentValue(value).value()); |
608 return position; | 608 return position; |
609 } | 609 } |
610 | 610 |
611 if (value.isIdentifierValue()) { | 611 if (value.isIdentifierValue()) { |
612 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueAuto); | 612 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueAuto); |
613 return position; | 613 return position; |
614 } | 614 } |
615 | 615 |
616 const CSSValueList& values = toCSSValueList(value); | 616 const CSSValueList& values = toCSSValueList(value); |
617 ASSERT(values.length()); | 617 DCHECK(values.length()); |
618 | 618 |
619 bool isSpanPosition = false; | 619 bool isSpanPosition = false; |
620 // The specification makes the <integer> optional, in which case it default to | 620 // The specification makes the <integer> optional, in which case it default to |
621 // '1'. | 621 // '1'. |
622 int gridLineNumber = 1; | 622 int gridLineNumber = 1; |
623 AtomicString gridLineName; | 623 AtomicString gridLineName; |
624 | 624 |
625 auto it = values.begin(); | 625 auto it = values.begin(); |
626 const CSSValue* currentValue = it->get(); | 626 const CSSValue* currentValue = it->get(); |
627 if (currentValue->isIdentifierValue() && | 627 if (currentValue->isIdentifierValue() && |
628 toCSSIdentifierValue(currentValue)->getValueID() == CSSValueSpan) { | 628 toCSSIdentifierValue(currentValue)->getValueID() == CSSValueSpan) { |
629 isSpanPosition = true; | 629 isSpanPosition = true; |
630 ++it; | 630 ++it; |
631 currentValue = it != values.end() ? it->get() : nullptr; | 631 currentValue = it != values.end() ? it->get() : nullptr; |
632 } | 632 } |
633 | 633 |
634 if (currentValue && currentValue->isPrimitiveValue() && | 634 if (currentValue && currentValue->isPrimitiveValue() && |
635 toCSSPrimitiveValue(currentValue)->isNumber()) { | 635 toCSSPrimitiveValue(currentValue)->isNumber()) { |
636 gridLineNumber = toCSSPrimitiveValue(currentValue)->getIntValue(); | 636 gridLineNumber = toCSSPrimitiveValue(currentValue)->getIntValue(); |
637 ++it; | 637 ++it; |
638 currentValue = it != values.end() ? it->get() : nullptr; | 638 currentValue = it != values.end() ? it->get() : nullptr; |
639 } | 639 } |
640 | 640 |
641 if (currentValue && currentValue->isCustomIdentValue()) { | 641 if (currentValue && currentValue->isCustomIdentValue()) { |
642 gridLineName = toCSSCustomIdentValue(currentValue)->value(); | 642 gridLineName = toCSSCustomIdentValue(currentValue)->value(); |
643 ++it; | 643 ++it; |
644 } | 644 } |
645 | 645 |
646 ASSERT(it == values.end()); | 646 DCHECK_EQ(it, values.end()); |
647 if (isSpanPosition) | 647 if (isSpanPosition) |
648 position.setSpanPosition(gridLineNumber, gridLineName); | 648 position.setSpanPosition(gridLineNumber, gridLineName); |
649 else | 649 else |
650 position.setExplicitPosition(gridLineNumber, gridLineName); | 650 position.setExplicitPosition(gridLineNumber, gridLineName); |
651 | 651 |
652 return position; | 652 return position; |
653 } | 653 } |
654 | 654 |
655 GridTrackSize StyleBuilderConverter::convertGridTrackSize( | 655 GridTrackSize StyleBuilderConverter::convertGridTrackSize( |
656 StyleResolverState& state, | 656 StyleResolverState& state, |
(...skipping 12 matching lines...) Expand all Loading... |
669 GridLength minTrackBreadth(convertGridTrackBreadth(state, function.item(0))); | 669 GridLength minTrackBreadth(convertGridTrackBreadth(state, function.item(0))); |
670 GridLength maxTrackBreadth(convertGridTrackBreadth(state, function.item(1))); | 670 GridLength maxTrackBreadth(convertGridTrackBreadth(state, function.item(1))); |
671 return GridTrackSize(minTrackBreadth, maxTrackBreadth); | 671 return GridTrackSize(minTrackBreadth, maxTrackBreadth); |
672 } | 672 } |
673 | 673 |
674 static void convertGridLineNamesList( | 674 static void convertGridLineNamesList( |
675 const CSSValue& value, | 675 const CSSValue& value, |
676 size_t currentNamedGridLine, | 676 size_t currentNamedGridLine, |
677 NamedGridLinesMap& namedGridLines, | 677 NamedGridLinesMap& namedGridLines, |
678 OrderedNamedGridLines& orderedNamedGridLines) { | 678 OrderedNamedGridLines& orderedNamedGridLines) { |
679 ASSERT(value.isGridLineNamesValue()); | 679 DCHECK(value.isGridLineNamesValue()); |
680 | 680 |
681 for (auto& namedGridLineValue : toCSSValueList(value)) { | 681 for (auto& namedGridLineValue : toCSSValueList(value)) { |
682 String namedGridLine = toCSSCustomIdentValue(*namedGridLineValue).value(); | 682 String namedGridLine = toCSSCustomIdentValue(*namedGridLineValue).value(); |
683 NamedGridLinesMap::AddResult result = | 683 NamedGridLinesMap::AddResult result = |
684 namedGridLines.insert(namedGridLine, Vector<size_t>()); | 684 namedGridLines.insert(namedGridLine, Vector<size_t>()); |
685 result.storedValue->value.push_back(currentNamedGridLine); | 685 result.storedValue->value.push_back(currentNamedGridLine); |
686 OrderedNamedGridLines::AddResult orderedInsertionResult = | 686 OrderedNamedGridLines::AddResult orderedInsertionResult = |
687 orderedNamedGridLines.insert(currentNamedGridLine, Vector<String>()); | 687 orderedNamedGridLines.insert(currentNamedGridLine, Vector<String>()); |
688 orderedInsertionResult.storedValue->value.push_back(namedGridLine); | 688 orderedInsertionResult.storedValue->value.push_back(namedGridLine); |
689 } | 689 } |
(...skipping 30 matching lines...) Expand all Loading... |
720 | 720 |
721 size_t currentNamedGridLine = 0; | 721 size_t currentNamedGridLine = 0; |
722 for (auto currValue : toCSSValueList(value)) { | 722 for (auto currValue : toCSSValueList(value)) { |
723 if (currValue->isGridLineNamesValue()) { | 723 if (currValue->isGridLineNamesValue()) { |
724 convertGridLineNamesList(*currValue, currentNamedGridLine, namedGridLines, | 724 convertGridLineNamesList(*currValue, currentNamedGridLine, namedGridLines, |
725 orderedNamedGridLines); | 725 orderedNamedGridLines); |
726 continue; | 726 continue; |
727 } | 727 } |
728 | 728 |
729 if (currValue->isGridAutoRepeatValue()) { | 729 if (currValue->isGridAutoRepeatValue()) { |
730 ASSERT(autoRepeatTrackSizes.isEmpty()); | 730 DCHECK(autoRepeatTrackSizes.isEmpty()); |
731 size_t autoRepeatIndex = 0; | 731 size_t autoRepeatIndex = 0; |
732 CSSValueID autoRepeatID = | 732 CSSValueID autoRepeatID = |
733 toCSSGridAutoRepeatValue(currValue.get())->autoRepeatID(); | 733 toCSSGridAutoRepeatValue(currValue.get())->autoRepeatID(); |
734 ASSERT(autoRepeatID == CSSValueAutoFill || | 734 DCHECK(autoRepeatID == CSSValueAutoFill || |
735 autoRepeatID == CSSValueAutoFit); | 735 autoRepeatID == CSSValueAutoFit); |
736 autoRepeatType = autoRepeatID == CSSValueAutoFill ? AutoFill : AutoFit; | 736 autoRepeatType = autoRepeatID == CSSValueAutoFill ? AutoFill : AutoFit; |
737 for (auto autoRepeatValue : toCSSValueList(*currValue)) { | 737 for (auto autoRepeatValue : toCSSValueList(*currValue)) { |
738 if (autoRepeatValue->isGridLineNamesValue()) { | 738 if (autoRepeatValue->isGridLineNamesValue()) { |
739 convertGridLineNamesList(*autoRepeatValue, autoRepeatIndex, | 739 convertGridLineNamesList(*autoRepeatValue, autoRepeatIndex, |
740 autoRepeatNamedGridLines, | 740 autoRepeatNamedGridLines, |
741 autoRepeatOrderedNamedGridLines); | 741 autoRepeatOrderedNamedGridLines); |
742 continue; | 742 continue; |
743 } | 743 } |
744 ++autoRepeatIndex; | 744 ++autoRepeatIndex; |
745 autoRepeatTrackSizes.push_back( | 745 autoRepeatTrackSizes.push_back( |
746 convertGridTrackSize(state, *autoRepeatValue)); | 746 convertGridTrackSize(state, *autoRepeatValue)); |
747 } | 747 } |
748 autoRepeatInsertionPoint = currentNamedGridLine++; | 748 autoRepeatInsertionPoint = currentNamedGridLine++; |
749 continue; | 749 continue; |
750 } | 750 } |
751 | 751 |
752 ++currentNamedGridLine; | 752 ++currentNamedGridLine; |
753 trackSizes.push_back(convertGridTrackSize(state, *currValue)); | 753 trackSizes.push_back(convertGridTrackSize(state, *currValue)); |
754 } | 754 } |
755 | 755 |
756 // The parser should have rejected any <track-list> without any <track-size> | 756 // The parser should have rejected any <track-list> without any <track-size> |
757 // as this is not conformant to the syntax. | 757 // as this is not conformant to the syntax. |
758 ASSERT(!trackSizes.isEmpty() || !autoRepeatTrackSizes.isEmpty()); | 758 DCHECK(!trackSizes.isEmpty() || !autoRepeatTrackSizes.isEmpty()); |
759 } | 759 } |
760 | 760 |
761 void StyleBuilderConverter::convertOrderedNamedGridLinesMapToNamedGridLinesMap( | 761 void StyleBuilderConverter::convertOrderedNamedGridLinesMapToNamedGridLinesMap( |
762 const OrderedNamedGridLines& orderedNamedGridLines, | 762 const OrderedNamedGridLines& orderedNamedGridLines, |
763 NamedGridLinesMap& namedGridLines) { | 763 NamedGridLinesMap& namedGridLines) { |
764 ASSERT(namedGridLines.size() == 0); | 764 DCHECK_EQ(namedGridLines.size(), 0u); |
765 | 765 |
766 if (orderedNamedGridLines.size() == 0) | 766 if (orderedNamedGridLines.size() == 0) |
767 return; | 767 return; |
768 | 768 |
769 for (auto& orderedNamedGridLine : orderedNamedGridLines) { | 769 for (auto& orderedNamedGridLine : orderedNamedGridLines) { |
770 for (auto& lineName : orderedNamedGridLine.value) { | 770 for (auto& lineName : orderedNamedGridLine.value) { |
771 NamedGridLinesMap::AddResult startResult = | 771 NamedGridLinesMap::AddResult startResult = |
772 namedGridLines.insert(lineName, Vector<size_t>()); | 772 namedGridLines.insert(lineName, Vector<size_t>()); |
773 startResult.storedValue->value.push_back(orderedNamedGridLine.key); | 773 startResult.storedValue->value.push_back(orderedNamedGridLine.key); |
774 } | 774 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 case CSSValueWebkitMaxContent: | 841 case CSSValueWebkitMaxContent: |
842 return Length(MaxContent); | 842 return Length(MaxContent); |
843 case CSSValueWebkitFillAvailable: | 843 case CSSValueWebkitFillAvailable: |
844 return Length(FillAvailable); | 844 return Length(FillAvailable); |
845 case CSSValueWebkitFitContent: | 845 case CSSValueWebkitFitContent: |
846 case CSSValueFitContent: | 846 case CSSValueFitContent: |
847 return Length(FitContent); | 847 return Length(FitContent); |
848 case CSSValueAuto: | 848 case CSSValueAuto: |
849 return Length(Auto); | 849 return Length(Auto); |
850 default: | 850 default: |
851 ASSERT_NOT_REACHED(); | 851 NOTREACHED(); |
852 return Length(); | 852 return Length(); |
853 } | 853 } |
854 } | 854 } |
855 | 855 |
856 Length StyleBuilderConverter::convertLengthMaxSizing(StyleResolverState& state, | 856 Length StyleBuilderConverter::convertLengthMaxSizing(StyleResolverState& state, |
857 const CSSValue& value) { | 857 const CSSValue& value) { |
858 if (value.isIdentifierValue() && | 858 if (value.isIdentifierValue() && |
859 toCSSIdentifierValue(value).getValueID() == CSSValueNone) | 859 toCSSIdentifierValue(value).getValueID() == CSSValueNone) |
860 return Length(MaxSizeNone); | 860 return Length(MaxSizeNone); |
861 return convertLengthSizing(state, value); | 861 return convertLengthSizing(state, value); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 } | 908 } |
909 | 909 |
910 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNormal); | 910 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNormal); |
911 return ComputedStyle::initialLineHeight(); | 911 return ComputedStyle::initialLineHeight(); |
912 } | 912 } |
913 | 913 |
914 float StyleBuilderConverter::convertNumberOrPercentage( | 914 float StyleBuilderConverter::convertNumberOrPercentage( |
915 StyleResolverState& state, | 915 StyleResolverState& state, |
916 const CSSValue& value) { | 916 const CSSValue& value) { |
917 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 917 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
918 ASSERT(primitiveValue.isNumber() || primitiveValue.isPercentage()); | 918 DCHECK(primitiveValue.isNumber() || primitiveValue.isPercentage()); |
919 if (primitiveValue.isNumber()) | 919 if (primitiveValue.isNumber()) |
920 return primitiveValue.getFloatValue(); | 920 return primitiveValue.getFloatValue(); |
921 return primitiveValue.getFloatValue() / 100.0f; | 921 return primitiveValue.getFloatValue() / 100.0f; |
922 } | 922 } |
923 | 923 |
924 StyleOffsetRotation StyleBuilderConverter::convertOffsetRotate( | 924 StyleOffsetRotation StyleBuilderConverter::convertOffsetRotate( |
925 StyleResolverState&, | 925 StyleResolverState&, |
926 const CSSValue& value) { | 926 const CSSValue& value) { |
927 return convertOffsetRotate(value); | 927 return convertOffsetRotate(value); |
928 } | 928 } |
929 | 929 |
930 StyleOffsetRotation StyleBuilderConverter::convertOffsetRotate( | 930 StyleOffsetRotation StyleBuilderConverter::convertOffsetRotate( |
931 const CSSValue& value) { | 931 const CSSValue& value) { |
932 StyleOffsetRotation result(0, OffsetRotationFixed); | 932 StyleOffsetRotation result(0, OffsetRotationFixed); |
933 | 933 |
934 const CSSValueList& list = toCSSValueList(value); | 934 const CSSValueList& list = toCSSValueList(value); |
935 ASSERT(list.length() == 1 || list.length() == 2); | 935 DCHECK(list.length() == 1 || list.length() == 2); |
936 for (const auto& item : list) { | 936 for (const auto& item : list) { |
937 if (item->isIdentifierValue() && | 937 if (item->isIdentifierValue() && |
938 toCSSIdentifierValue(*item).getValueID() == CSSValueAuto) { | 938 toCSSIdentifierValue(*item).getValueID() == CSSValueAuto) { |
939 result.type = OffsetRotationAuto; | 939 result.type = OffsetRotationAuto; |
940 } else if (item->isIdentifierValue() && | 940 } else if (item->isIdentifierValue() && |
941 toCSSIdentifierValue(*item).getValueID() == CSSValueReverse) { | 941 toCSSIdentifierValue(*item).getValueID() == CSSValueReverse) { |
942 result.type = OffsetRotationAuto; | 942 result.type = OffsetRotationAuto; |
943 result.angle = clampTo<float>(result.angle + 180); | 943 result.angle = clampTo<float>(result.angle + 180); |
944 } else { | 944 } else { |
945 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(*item); | 945 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(*item); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 case CSSValueFill: | 992 case CSSValueFill: |
993 return orderTypeList.length() > 1 ? PaintOrderFillMarkersStroke | 993 return orderTypeList.length() > 1 ? PaintOrderFillMarkersStroke |
994 : PaintOrderFillStrokeMarkers; | 994 : PaintOrderFillStrokeMarkers; |
995 case CSSValueStroke: | 995 case CSSValueStroke: |
996 return orderTypeList.length() > 1 ? PaintOrderStrokeMarkersFill | 996 return orderTypeList.length() > 1 ? PaintOrderStrokeMarkersFill |
997 : PaintOrderStrokeFillMarkers; | 997 : PaintOrderStrokeFillMarkers; |
998 case CSSValueMarkers: | 998 case CSSValueMarkers: |
999 return orderTypeList.length() > 1 ? PaintOrderMarkersStrokeFill | 999 return orderTypeList.length() > 1 ? PaintOrderMarkersStrokeFill |
1000 : PaintOrderMarkersFillStroke; | 1000 : PaintOrderMarkersFillStroke; |
1001 default: | 1001 default: |
1002 ASSERT_NOT_REACHED(); | 1002 NOTREACHED(); |
1003 return PaintOrderNormal; | 1003 return PaintOrderNormal; |
1004 } | 1004 } |
1005 } | 1005 } |
1006 | 1006 |
1007 return PaintOrderNormal; | 1007 return PaintOrderNormal; |
1008 } | 1008 } |
1009 | 1009 |
1010 Length StyleBuilderConverter::convertQuirkyLength(StyleResolverState& state, | 1010 Length StyleBuilderConverter::convertQuirkyLength(StyleResolverState& state, |
1011 const CSSValue& value) { | 1011 const CSSValue& value) { |
1012 Length length = convertLengthOrAuto(state, value); | 1012 Length length = convertLengthOrAuto(state, value); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 if (value.isBasicShapeValue()) { | 1125 if (value.isBasicShapeValue()) { |
1126 shape = basicShapeForValue(state, value); | 1126 shape = basicShapeForValue(state, value); |
1127 } else { | 1127 } else { |
1128 cssBox = toCSSIdentifierValue(value).convertTo<CSSBoxType>(); | 1128 cssBox = toCSSIdentifierValue(value).convertTo<CSSBoxType>(); |
1129 } | 1129 } |
1130 } | 1130 } |
1131 | 1131 |
1132 if (shape) | 1132 if (shape) |
1133 return ShapeValue::createShapeValue(shape.release(), cssBox); | 1133 return ShapeValue::createShapeValue(shape.release(), cssBox); |
1134 | 1134 |
1135 ASSERT(cssBox != BoxMissing); | 1135 DCHECK_NE(cssBox, BoxMissing); |
1136 return ShapeValue::createBoxShapeValue(cssBox); | 1136 return ShapeValue::createBoxShapeValue(cssBox); |
1137 } | 1137 } |
1138 | 1138 |
1139 float StyleBuilderConverter::convertSpacing(StyleResolverState& state, | 1139 float StyleBuilderConverter::convertSpacing(StyleResolverState& state, |
1140 const CSSValue& value) { | 1140 const CSSValue& value) { |
1141 if (value.isIdentifierValue() && | 1141 if (value.isIdentifierValue() && |
1142 toCSSIdentifierValue(value).getValueID() == CSSValueNormal) | 1142 toCSSIdentifierValue(value).getValueID() == CSSValueNormal) |
1143 return 0; | 1143 return 0; |
1144 return toCSSPrimitiveValue(value).computeLength<float>( | 1144 return toCSSPrimitiveValue(value).computeLength<float>( |
1145 state.cssToLengthConversionData()); | 1145 state.cssToLengthConversionData()); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1272 } | 1272 } |
1273 | 1273 |
1274 PassRefPtr<TranslateTransformOperation> StyleBuilderConverter::convertTranslate( | 1274 PassRefPtr<TranslateTransformOperation> StyleBuilderConverter::convertTranslate( |
1275 StyleResolverState& state, | 1275 StyleResolverState& state, |
1276 const CSSValue& value) { | 1276 const CSSValue& value) { |
1277 if (value.isIdentifierValue()) { | 1277 if (value.isIdentifierValue()) { |
1278 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); | 1278 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
1279 return nullptr; | 1279 return nullptr; |
1280 } | 1280 } |
1281 const CSSValueList& list = toCSSValueList(value); | 1281 const CSSValueList& list = toCSSValueList(value); |
1282 ASSERT(list.length() <= 3); | 1282 DCHECK_LE(list.length(), 3u); |
1283 Length tx = convertLength(state, list.item(0)); | 1283 Length tx = convertLength(state, list.item(0)); |
1284 Length ty(0, Fixed); | 1284 Length ty(0, Fixed); |
1285 double tz = 0; | 1285 double tz = 0; |
1286 if (list.length() >= 2) | 1286 if (list.length() >= 2) |
1287 ty = convertLength(state, list.item(1)); | 1287 ty = convertLength(state, list.item(1)); |
1288 if (list.length() == 3) | 1288 if (list.length() == 3) |
1289 tz = toCSSPrimitiveValue(list.item(2)) | 1289 tz = toCSSPrimitiveValue(list.item(2)) |
1290 .computeLength<double>(state.cssToLengthConversionData()); | 1290 .computeLength<double>(state.cssToLengthConversionData()); |
1291 | 1291 |
1292 return TranslateTransformOperation::create(tx, ty, tz, | 1292 return TranslateTransformOperation::create(tx, ty, tz, |
1293 TransformOperation::Translate3D); | 1293 TransformOperation::Translate3D); |
1294 } | 1294 } |
1295 | 1295 |
1296 Rotation StyleBuilderConverter::convertRotation(const CSSValue& value) { | 1296 Rotation StyleBuilderConverter::convertRotation(const CSSValue& value) { |
1297 if (value.isIdentifierValue()) { | 1297 if (value.isIdentifierValue()) { |
1298 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); | 1298 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
1299 return Rotation(FloatPoint3D(0, 0, 1), 0); | 1299 return Rotation(FloatPoint3D(0, 0, 1), 0); |
1300 } | 1300 } |
1301 | 1301 |
1302 const CSSValueList& list = toCSSValueList(value); | 1302 const CSSValueList& list = toCSSValueList(value); |
1303 ASSERT(list.length() == 1 || list.length() == 4); | 1303 DCHECK(list.length() == 1 || list.length() == 4); |
1304 double x = 0; | 1304 double x = 0; |
1305 double y = 0; | 1305 double y = 0; |
1306 double z = 1; | 1306 double z = 1; |
1307 if (list.length() == 4) { | 1307 if (list.length() == 4) { |
1308 x = toCSSPrimitiveValue(list.item(0)).getDoubleValue(); | 1308 x = toCSSPrimitiveValue(list.item(0)).getDoubleValue(); |
1309 y = toCSSPrimitiveValue(list.item(1)).getDoubleValue(); | 1309 y = toCSSPrimitiveValue(list.item(1)).getDoubleValue(); |
1310 z = toCSSPrimitiveValue(list.item(2)).getDoubleValue(); | 1310 z = toCSSPrimitiveValue(list.item(2)).getDoubleValue(); |
1311 } | 1311 } |
1312 double angle = | 1312 double angle = |
1313 toCSSPrimitiveValue(list.item(list.length() - 1)).computeDegrees(); | 1313 toCSSPrimitiveValue(list.item(list.length() - 1)).computeDegrees(); |
(...skipping 14 matching lines...) Expand all Loading... |
1328 | 1328 |
1329 PassRefPtr<ScaleTransformOperation> StyleBuilderConverter::convertScale( | 1329 PassRefPtr<ScaleTransformOperation> StyleBuilderConverter::convertScale( |
1330 StyleResolverState& state, | 1330 StyleResolverState& state, |
1331 const CSSValue& value) { | 1331 const CSSValue& value) { |
1332 if (value.isIdentifierValue()) { | 1332 if (value.isIdentifierValue()) { |
1333 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); | 1333 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
1334 return nullptr; | 1334 return nullptr; |
1335 } | 1335 } |
1336 | 1336 |
1337 const CSSValueList& list = toCSSValueList(value); | 1337 const CSSValueList& list = toCSSValueList(value); |
1338 ASSERT(list.length() <= 3); | 1338 DCHECK_LE(list.length(), 3u); |
1339 double sx = toCSSPrimitiveValue(list.item(0)).getDoubleValue(); | 1339 double sx = toCSSPrimitiveValue(list.item(0)).getDoubleValue(); |
1340 double sy = 1; | 1340 double sy = 1; |
1341 double sz = 1; | 1341 double sz = 1; |
1342 if (list.length() >= 2) | 1342 if (list.length() >= 2) |
1343 sy = toCSSPrimitiveValue(list.item(1)).getDoubleValue(); | 1343 sy = toCSSPrimitiveValue(list.item(1)).getDoubleValue(); |
1344 if (list.length() == 3) | 1344 if (list.length() == 3) |
1345 sz = toCSSPrimitiveValue(list.item(2)).getDoubleValue(); | 1345 sz = toCSSPrimitiveValue(list.item(2)).getDoubleValue(); |
1346 | 1346 |
1347 return ScaleTransformOperation::create(sx, sy, sz, | 1347 return ScaleTransformOperation::create(sx, sy, sz, |
1348 TransformOperation::Scale3D); | 1348 TransformOperation::Scale3D); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 } | 1402 } |
1403 | 1403 |
1404 const CSSValue& StyleBuilderConverter::convertRegisteredPropertyValue( | 1404 const CSSValue& StyleBuilderConverter::convertRegisteredPropertyValue( |
1405 const StyleResolverState& state, | 1405 const StyleResolverState& state, |
1406 const CSSValue& value) { | 1406 const CSSValue& value) { |
1407 return computeRegisteredPropertyValue(state.cssToLengthConversionData(), | 1407 return computeRegisteredPropertyValue(state.cssToLengthConversionData(), |
1408 value); | 1408 value); |
1409 } | 1409 } |
1410 | 1410 |
1411 } // namespace blink | 1411 } // namespace blink |
OLD | NEW |