Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/StyleBuilderConverter.cpp

Issue 2755493004: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in core/css/ (Closed)
Patch Set: Worked on Review Comments done Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
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
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 return alignmentData; 566 return alignmentData;
567 } 567 }
568 568
569 GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(StyleResolverState&, 569 GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(StyleResolverState&,
570 const CSSValue& value) { 570 const CSSValue& value) {
571 const CSSValueList& list = toCSSValueList(value); 571 const CSSValueList& list = toCSSValueList(value);
572 572
573 ASSERT(list.length() >= 1); 573 DCHECK_GE(list.length(), static_cast<unsigned>(1));
tkent 2017/03/28 14:44:56 static_cast<unsigned>(1) -> 1u
nikhil.sahni 2017/03/30 12:17:58 Done.
574 const CSSIdentifierValue& first = toCSSIdentifierValue(list.item(0)); 574 const CSSIdentifierValue& first = toCSSIdentifierValue(list.item(0));
575 const CSSIdentifierValue* second = 575 const CSSIdentifierValue* second =
576 list.length() == 2 ? &toCSSIdentifierValue(list.item(1)) : nullptr; 576 list.length() == 2 ? &toCSSIdentifierValue(list.item(1)) : nullptr;
577 577
578 switch (first.getValueID()) { 578 switch (first.getValueID()) {
579 case CSSValueRow: 579 case CSSValueRow:
580 if (second && second->getValueID() == CSSValueDense) 580 if (second && second->getValueID() == CSSValueDense)
581 return AutoFlowRowDense; 581 return AutoFlowRowDense;
582 return AutoFlowRow; 582 return AutoFlowRow;
583 case CSSValueColumn: 583 case CSSValueColumn:
584 if (second && second->getValueID() == CSSValueDense) 584 if (second && second->getValueID() == CSSValueDense)
585 return AutoFlowColumnDense; 585 return AutoFlowColumnDense;
586 return AutoFlowColumn; 586 return AutoFlowColumn;
587 case CSSValueDense: 587 case CSSValueDense:
588 if (second && second->getValueID() == CSSValueColumn) 588 if (second && second->getValueID() == CSSValueColumn)
589 return AutoFlowColumnDense; 589 return AutoFlowColumnDense;
590 return AutoFlowRowDense; 590 return AutoFlowRowDense;
591 default: 591 default:
592 ASSERT_NOT_REACHED(); 592 NOTREACHED();
593 return ComputedStyle::initialGridAutoFlow(); 593 return ComputedStyle::initialGridAutoFlow();
594 } 594 }
595 } 595 }
596 596
597 GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&, 597 GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&,
598 const CSSValue& value) { 598 const CSSValue& value) {
599 // We accept the specification's grammar: 599 // We accept the specification's grammar:
600 // 'auto' | [ <integer> || <custom-ident> ] | 600 // 'auto' | [ <integer> || <custom-ident> ] |
601 // [ span && [ <integer> || <custom-ident> ] ] | <custom-ident> 601 // [ span && [ <integer> || <custom-ident> ] ] | <custom-ident>
602 602
603 GridPosition position; 603 GridPosition position;
604 604
605 if (value.isCustomIdentValue()) { 605 if (value.isCustomIdentValue()) {
606 position.setNamedGridArea(toCSSCustomIdentValue(value).value()); 606 position.setNamedGridArea(toCSSCustomIdentValue(value).value());
607 return position; 607 return position;
608 } 608 }
609 609
610 if (value.isIdentifierValue()) { 610 if (value.isIdentifierValue()) {
611 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueAuto); 611 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueAuto);
612 return position; 612 return position;
613 } 613 }
614 614
615 const CSSValueList& values = toCSSValueList(value); 615 const CSSValueList& values = toCSSValueList(value);
616 ASSERT(values.length()); 616 DCHECK(values.length());
617 617
618 bool isSpanPosition = false; 618 bool isSpanPosition = false;
619 // The specification makes the <integer> optional, in which case it default to 619 // The specification makes the <integer> optional, in which case it default to
620 // '1'. 620 // '1'.
621 int gridLineNumber = 1; 621 int gridLineNumber = 1;
622 AtomicString gridLineName; 622 AtomicString gridLineName;
623 623
624 auto it = values.begin(); 624 auto it = values.begin();
625 const CSSValue* currentValue = it->get(); 625 const CSSValue* currentValue = it->get();
626 if (currentValue->isIdentifierValue() && 626 if (currentValue->isIdentifierValue() &&
627 toCSSIdentifierValue(currentValue)->getValueID() == CSSValueSpan) { 627 toCSSIdentifierValue(currentValue)->getValueID() == CSSValueSpan) {
628 isSpanPosition = true; 628 isSpanPosition = true;
629 ++it; 629 ++it;
630 currentValue = it != values.end() ? it->get() : nullptr; 630 currentValue = it != values.end() ? it->get() : nullptr;
631 } 631 }
632 632
633 if (currentValue && currentValue->isPrimitiveValue() && 633 if (currentValue && currentValue->isPrimitiveValue() &&
634 toCSSPrimitiveValue(currentValue)->isNumber()) { 634 toCSSPrimitiveValue(currentValue)->isNumber()) {
635 gridLineNumber = toCSSPrimitiveValue(currentValue)->getIntValue(); 635 gridLineNumber = toCSSPrimitiveValue(currentValue)->getIntValue();
636 ++it; 636 ++it;
637 currentValue = it != values.end() ? it->get() : nullptr; 637 currentValue = it != values.end() ? it->get() : nullptr;
638 } 638 }
639 639
640 if (currentValue && currentValue->isCustomIdentValue()) { 640 if (currentValue && currentValue->isCustomIdentValue()) {
641 gridLineName = toCSSCustomIdentValue(currentValue)->value(); 641 gridLineName = toCSSCustomIdentValue(currentValue)->value();
642 ++it; 642 ++it;
643 } 643 }
644 644
645 ASSERT(it == values.end()); 645 DCHECK_EQ(it, values.end());
646 if (isSpanPosition) 646 if (isSpanPosition)
647 position.setSpanPosition(gridLineNumber, gridLineName); 647 position.setSpanPosition(gridLineNumber, gridLineName);
648 else 648 else
649 position.setExplicitPosition(gridLineNumber, gridLineName); 649 position.setExplicitPosition(gridLineNumber, gridLineName);
650 650
651 return position; 651 return position;
652 } 652 }
653 653
654 GridTrackSize StyleBuilderConverter::convertGridTrackSize( 654 GridTrackSize StyleBuilderConverter::convertGridTrackSize(
655 StyleResolverState& state, 655 StyleResolverState& state,
(...skipping 12 matching lines...) Expand all
668 GridLength minTrackBreadth(convertGridTrackBreadth(state, function.item(0))); 668 GridLength minTrackBreadth(convertGridTrackBreadth(state, function.item(0)));
669 GridLength maxTrackBreadth(convertGridTrackBreadth(state, function.item(1))); 669 GridLength maxTrackBreadth(convertGridTrackBreadth(state, function.item(1)));
670 return GridTrackSize(minTrackBreadth, maxTrackBreadth); 670 return GridTrackSize(minTrackBreadth, maxTrackBreadth);
671 } 671 }
672 672
673 static void convertGridLineNamesList( 673 static void convertGridLineNamesList(
674 const CSSValue& value, 674 const CSSValue& value,
675 size_t currentNamedGridLine, 675 size_t currentNamedGridLine,
676 NamedGridLinesMap& namedGridLines, 676 NamedGridLinesMap& namedGridLines,
677 OrderedNamedGridLines& orderedNamedGridLines) { 677 OrderedNamedGridLines& orderedNamedGridLines) {
678 ASSERT(value.isGridLineNamesValue()); 678 DCHECK(value.isGridLineNamesValue());
679 679
680 for (auto& namedGridLineValue : toCSSValueList(value)) { 680 for (auto& namedGridLineValue : toCSSValueList(value)) {
681 String namedGridLine = toCSSCustomIdentValue(*namedGridLineValue).value(); 681 String namedGridLine = toCSSCustomIdentValue(*namedGridLineValue).value();
682 NamedGridLinesMap::AddResult result = 682 NamedGridLinesMap::AddResult result =
683 namedGridLines.insert(namedGridLine, Vector<size_t>()); 683 namedGridLines.insert(namedGridLine, Vector<size_t>());
684 result.storedValue->value.push_back(currentNamedGridLine); 684 result.storedValue->value.push_back(currentNamedGridLine);
685 OrderedNamedGridLines::AddResult orderedInsertionResult = 685 OrderedNamedGridLines::AddResult orderedInsertionResult =
686 orderedNamedGridLines.insert(currentNamedGridLine, Vector<String>()); 686 orderedNamedGridLines.insert(currentNamedGridLine, Vector<String>());
687 orderedInsertionResult.storedValue->value.push_back(namedGridLine); 687 orderedInsertionResult.storedValue->value.push_back(namedGridLine);
688 } 688 }
(...skipping 30 matching lines...) Expand all
719 719
720 size_t currentNamedGridLine = 0; 720 size_t currentNamedGridLine = 0;
721 for (auto currValue : toCSSValueList(value)) { 721 for (auto currValue : toCSSValueList(value)) {
722 if (currValue->isGridLineNamesValue()) { 722 if (currValue->isGridLineNamesValue()) {
723 convertGridLineNamesList(*currValue, currentNamedGridLine, namedGridLines, 723 convertGridLineNamesList(*currValue, currentNamedGridLine, namedGridLines,
724 orderedNamedGridLines); 724 orderedNamedGridLines);
725 continue; 725 continue;
726 } 726 }
727 727
728 if (currValue->isGridAutoRepeatValue()) { 728 if (currValue->isGridAutoRepeatValue()) {
729 ASSERT(autoRepeatTrackSizes.isEmpty()); 729 DCHECK(autoRepeatTrackSizes.isEmpty());
730 size_t autoRepeatIndex = 0; 730 size_t autoRepeatIndex = 0;
731 CSSValueID autoRepeatID = 731 CSSValueID autoRepeatID =
732 toCSSGridAutoRepeatValue(currValue.get())->autoRepeatID(); 732 toCSSGridAutoRepeatValue(currValue.get())->autoRepeatID();
733 ASSERT(autoRepeatID == CSSValueAutoFill || 733 DCHECK(autoRepeatID == CSSValueAutoFill ||
734 autoRepeatID == CSSValueAutoFit); 734 autoRepeatID == CSSValueAutoFit);
735 autoRepeatType = autoRepeatID == CSSValueAutoFill ? AutoFill : AutoFit; 735 autoRepeatType = autoRepeatID == CSSValueAutoFill ? AutoFill : AutoFit;
736 for (auto autoRepeatValue : toCSSValueList(*currValue)) { 736 for (auto autoRepeatValue : toCSSValueList(*currValue)) {
737 if (autoRepeatValue->isGridLineNamesValue()) { 737 if (autoRepeatValue->isGridLineNamesValue()) {
738 convertGridLineNamesList(*autoRepeatValue, autoRepeatIndex, 738 convertGridLineNamesList(*autoRepeatValue, autoRepeatIndex,
739 autoRepeatNamedGridLines, 739 autoRepeatNamedGridLines,
740 autoRepeatOrderedNamedGridLines); 740 autoRepeatOrderedNamedGridLines);
741 continue; 741 continue;
742 } 742 }
743 ++autoRepeatIndex; 743 ++autoRepeatIndex;
744 autoRepeatTrackSizes.push_back( 744 autoRepeatTrackSizes.push_back(
745 convertGridTrackSize(state, *autoRepeatValue)); 745 convertGridTrackSize(state, *autoRepeatValue));
746 } 746 }
747 autoRepeatInsertionPoint = currentNamedGridLine++; 747 autoRepeatInsertionPoint = currentNamedGridLine++;
748 continue; 748 continue;
749 } 749 }
750 750
751 ++currentNamedGridLine; 751 ++currentNamedGridLine;
752 trackSizes.push_back(convertGridTrackSize(state, *currValue)); 752 trackSizes.push_back(convertGridTrackSize(state, *currValue));
753 } 753 }
754 754
755 // The parser should have rejected any <track-list> without any <track-size> 755 // The parser should have rejected any <track-list> without any <track-size>
756 // as this is not conformant to the syntax. 756 // as this is not conformant to the syntax.
757 ASSERT(!trackSizes.isEmpty() || !autoRepeatTrackSizes.isEmpty()); 757 DCHECK(!trackSizes.isEmpty() || !autoRepeatTrackSizes.isEmpty());
758 } 758 }
759 759
760 void StyleBuilderConverter::convertOrderedNamedGridLinesMapToNamedGridLinesMap( 760 void StyleBuilderConverter::convertOrderedNamedGridLinesMapToNamedGridLinesMap(
761 const OrderedNamedGridLines& orderedNamedGridLines, 761 const OrderedNamedGridLines& orderedNamedGridLines,
762 NamedGridLinesMap& namedGridLines) { 762 NamedGridLinesMap& namedGridLines) {
763 ASSERT(namedGridLines.size() == 0); 763 DCHECK_EQ(namedGridLines.size(), static_cast<unsigned>(0));
tkent 2017/03/28 14:44:56 static_cast<unsigned>(0) -> 0u
nikhil.sahni 2017/03/30 12:17:59 Done.
764 764
765 if (orderedNamedGridLines.size() == 0) 765 if (orderedNamedGridLines.size() == 0)
766 return; 766 return;
767 767
768 for (auto& orderedNamedGridLine : orderedNamedGridLines) { 768 for (auto& orderedNamedGridLine : orderedNamedGridLines) {
769 for (auto& lineName : orderedNamedGridLine.value) { 769 for (auto& lineName : orderedNamedGridLine.value) {
770 NamedGridLinesMap::AddResult startResult = 770 NamedGridLinesMap::AddResult startResult =
771 namedGridLines.insert(lineName, Vector<size_t>()); 771 namedGridLines.insert(lineName, Vector<size_t>());
772 startResult.storedValue->value.push_back(orderedNamedGridLine.key); 772 startResult.storedValue->value.push_back(orderedNamedGridLine.key);
773 } 773 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 case CSSValueWebkitMaxContent: 840 case CSSValueWebkitMaxContent:
841 return Length(MaxContent); 841 return Length(MaxContent);
842 case CSSValueWebkitFillAvailable: 842 case CSSValueWebkitFillAvailable:
843 return Length(FillAvailable); 843 return Length(FillAvailable);
844 case CSSValueWebkitFitContent: 844 case CSSValueWebkitFitContent:
845 case CSSValueFitContent: 845 case CSSValueFitContent:
846 return Length(FitContent); 846 return Length(FitContent);
847 case CSSValueAuto: 847 case CSSValueAuto:
848 return Length(Auto); 848 return Length(Auto);
849 default: 849 default:
850 ASSERT_NOT_REACHED(); 850 NOTREACHED();
851 return Length(); 851 return Length();
852 } 852 }
853 } 853 }
854 854
855 Length StyleBuilderConverter::convertLengthMaxSizing(StyleResolverState& state, 855 Length StyleBuilderConverter::convertLengthMaxSizing(StyleResolverState& state,
856 const CSSValue& value) { 856 const CSSValue& value) {
857 if (value.isIdentifierValue() && 857 if (value.isIdentifierValue() &&
858 toCSSIdentifierValue(value).getValueID() == CSSValueNone) 858 toCSSIdentifierValue(value).getValueID() == CSSValueNone)
859 return Length(MaxSizeNone); 859 return Length(MaxSizeNone);
860 return convertLengthSizing(state, value); 860 return convertLengthSizing(state, value);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 } 907 }
908 908
909 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNormal); 909 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNormal);
910 return ComputedStyle::initialLineHeight(); 910 return ComputedStyle::initialLineHeight();
911 } 911 }
912 912
913 float StyleBuilderConverter::convertNumberOrPercentage( 913 float StyleBuilderConverter::convertNumberOrPercentage(
914 StyleResolverState& state, 914 StyleResolverState& state,
915 const CSSValue& value) { 915 const CSSValue& value) {
916 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 916 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
917 ASSERT(primitiveValue.isNumber() || primitiveValue.isPercentage()); 917 DCHECK(primitiveValue.isNumber() || primitiveValue.isPercentage());
918 if (primitiveValue.isNumber()) 918 if (primitiveValue.isNumber())
919 return primitiveValue.getFloatValue(); 919 return primitiveValue.getFloatValue();
920 return primitiveValue.getFloatValue() / 100.0f; 920 return primitiveValue.getFloatValue() / 100.0f;
921 } 921 }
922 922
923 StyleOffsetRotation StyleBuilderConverter::convertOffsetRotate( 923 StyleOffsetRotation StyleBuilderConverter::convertOffsetRotate(
924 StyleResolverState&, 924 StyleResolverState&,
925 const CSSValue& value) { 925 const CSSValue& value) {
926 return convertOffsetRotate(value); 926 return convertOffsetRotate(value);
927 } 927 }
928 928
929 StyleOffsetRotation StyleBuilderConverter::convertOffsetRotate( 929 StyleOffsetRotation StyleBuilderConverter::convertOffsetRotate(
930 const CSSValue& value) { 930 const CSSValue& value) {
931 StyleOffsetRotation result(0, OffsetRotationFixed); 931 StyleOffsetRotation result(0, OffsetRotationFixed);
932 932
933 const CSSValueList& list = toCSSValueList(value); 933 const CSSValueList& list = toCSSValueList(value);
934 ASSERT(list.length() == 1 || list.length() == 2); 934 DCHECK(list.length() == 1 || list.length() == 2);
935 for (const auto& item : list) { 935 for (const auto& item : list) {
936 if (item->isIdentifierValue() && 936 if (item->isIdentifierValue() &&
937 toCSSIdentifierValue(*item).getValueID() == CSSValueAuto) { 937 toCSSIdentifierValue(*item).getValueID() == CSSValueAuto) {
938 result.type = OffsetRotationAuto; 938 result.type = OffsetRotationAuto;
939 } else if (item->isIdentifierValue() && 939 } else if (item->isIdentifierValue() &&
940 toCSSIdentifierValue(*item).getValueID() == CSSValueReverse) { 940 toCSSIdentifierValue(*item).getValueID() == CSSValueReverse) {
941 result.type = OffsetRotationAuto; 941 result.type = OffsetRotationAuto;
942 result.angle = clampTo<float>(result.angle + 180); 942 result.angle = clampTo<float>(result.angle + 180);
943 } else { 943 } else {
944 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(*item); 944 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(*item);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 case CSSValueFill: 991 case CSSValueFill:
992 return orderTypeList.length() > 1 ? PaintOrderFillMarkersStroke 992 return orderTypeList.length() > 1 ? PaintOrderFillMarkersStroke
993 : PaintOrderFillStrokeMarkers; 993 : PaintOrderFillStrokeMarkers;
994 case CSSValueStroke: 994 case CSSValueStroke:
995 return orderTypeList.length() > 1 ? PaintOrderStrokeMarkersFill 995 return orderTypeList.length() > 1 ? PaintOrderStrokeMarkersFill
996 : PaintOrderStrokeFillMarkers; 996 : PaintOrderStrokeFillMarkers;
997 case CSSValueMarkers: 997 case CSSValueMarkers:
998 return orderTypeList.length() > 1 ? PaintOrderMarkersStrokeFill 998 return orderTypeList.length() > 1 ? PaintOrderMarkersStrokeFill
999 : PaintOrderMarkersFillStroke; 999 : PaintOrderMarkersFillStroke;
1000 default: 1000 default:
1001 ASSERT_NOT_REACHED(); 1001 NOTREACHED();
1002 return PaintOrderNormal; 1002 return PaintOrderNormal;
1003 } 1003 }
1004 } 1004 }
1005 1005
1006 return PaintOrderNormal; 1006 return PaintOrderNormal;
1007 } 1007 }
1008 1008
1009 Length StyleBuilderConverter::convertQuirkyLength(StyleResolverState& state, 1009 Length StyleBuilderConverter::convertQuirkyLength(StyleResolverState& state,
1010 const CSSValue& value) { 1010 const CSSValue& value) {
1011 Length length = convertLengthOrAuto(state, value); 1011 Length length = convertLengthOrAuto(state, value);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 if (value.isBasicShapeValue()) { 1124 if (value.isBasicShapeValue()) {
1125 shape = basicShapeForValue(state, value); 1125 shape = basicShapeForValue(state, value);
1126 } else { 1126 } else {
1127 cssBox = toCSSIdentifierValue(value).convertTo<CSSBoxType>(); 1127 cssBox = toCSSIdentifierValue(value).convertTo<CSSBoxType>();
1128 } 1128 }
1129 } 1129 }
1130 1130
1131 if (shape) 1131 if (shape)
1132 return ShapeValue::createShapeValue(shape.release(), cssBox); 1132 return ShapeValue::createShapeValue(shape.release(), cssBox);
1133 1133
1134 ASSERT(cssBox != BoxMissing); 1134 DCHECK_NE(cssBox, BoxMissing);
1135 return ShapeValue::createBoxShapeValue(cssBox); 1135 return ShapeValue::createBoxShapeValue(cssBox);
1136 } 1136 }
1137 1137
1138 float StyleBuilderConverter::convertSpacing(StyleResolverState& state, 1138 float StyleBuilderConverter::convertSpacing(StyleResolverState& state,
1139 const CSSValue& value) { 1139 const CSSValue& value) {
1140 if (value.isIdentifierValue() && 1140 if (value.isIdentifierValue() &&
1141 toCSSIdentifierValue(value).getValueID() == CSSValueNormal) 1141 toCSSIdentifierValue(value).getValueID() == CSSValueNormal)
1142 return 0; 1142 return 0;
1143 return toCSSPrimitiveValue(value).computeLength<float>( 1143 return toCSSPrimitiveValue(value).computeLength<float>(
1144 state.cssToLengthConversionData()); 1144 state.cssToLengthConversionData());
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 } 1271 }
1272 1272
1273 PassRefPtr<TranslateTransformOperation> StyleBuilderConverter::convertTranslate( 1273 PassRefPtr<TranslateTransformOperation> StyleBuilderConverter::convertTranslate(
1274 StyleResolverState& state, 1274 StyleResolverState& state,
1275 const CSSValue& value) { 1275 const CSSValue& value) {
1276 if (value.isIdentifierValue()) { 1276 if (value.isIdentifierValue()) {
1277 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); 1277 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone);
1278 return nullptr; 1278 return nullptr;
1279 } 1279 }
1280 const CSSValueList& list = toCSSValueList(value); 1280 const CSSValueList& list = toCSSValueList(value);
1281 ASSERT(list.length() <= 3); 1281 DCHECK_LE(list.length(), static_cast<unsigned>(3));
tkent 2017/03/28 14:44:56 static_cast<unsigned>(3) -> 3u
nikhil.sahni 2017/03/30 12:17:58 Done.
1282 Length tx = convertLength(state, list.item(0)); 1282 Length tx = convertLength(state, list.item(0));
1283 Length ty(0, Fixed); 1283 Length ty(0, Fixed);
1284 double tz = 0; 1284 double tz = 0;
1285 if (list.length() >= 2) 1285 if (list.length() >= 2)
1286 ty = convertLength(state, list.item(1)); 1286 ty = convertLength(state, list.item(1));
1287 if (list.length() == 3) 1287 if (list.length() == 3)
1288 tz = toCSSPrimitiveValue(list.item(2)) 1288 tz = toCSSPrimitiveValue(list.item(2))
1289 .computeLength<double>(state.cssToLengthConversionData()); 1289 .computeLength<double>(state.cssToLengthConversionData());
1290 1290
1291 return TranslateTransformOperation::create(tx, ty, tz, 1291 return TranslateTransformOperation::create(tx, ty, tz,
1292 TransformOperation::Translate3D); 1292 TransformOperation::Translate3D);
1293 } 1293 }
1294 1294
1295 Rotation StyleBuilderConverter::convertRotation(const CSSValue& value) { 1295 Rotation StyleBuilderConverter::convertRotation(const CSSValue& value) {
1296 if (value.isIdentifierValue()) { 1296 if (value.isIdentifierValue()) {
1297 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); 1297 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone);
1298 return Rotation(FloatPoint3D(0, 0, 1), 0); 1298 return Rotation(FloatPoint3D(0, 0, 1), 0);
1299 } 1299 }
1300 1300
1301 const CSSValueList& list = toCSSValueList(value); 1301 const CSSValueList& list = toCSSValueList(value);
1302 ASSERT(list.length() == 1 || list.length() == 4); 1302 DCHECK(list.length() == 1 || list.length() == 4);
1303 double x = 0; 1303 double x = 0;
1304 double y = 0; 1304 double y = 0;
1305 double z = 1; 1305 double z = 1;
1306 if (list.length() == 4) { 1306 if (list.length() == 4) {
1307 x = toCSSPrimitiveValue(list.item(0)).getDoubleValue(); 1307 x = toCSSPrimitiveValue(list.item(0)).getDoubleValue();
1308 y = toCSSPrimitiveValue(list.item(1)).getDoubleValue(); 1308 y = toCSSPrimitiveValue(list.item(1)).getDoubleValue();
1309 z = toCSSPrimitiveValue(list.item(2)).getDoubleValue(); 1309 z = toCSSPrimitiveValue(list.item(2)).getDoubleValue();
1310 } 1310 }
1311 double angle = 1311 double angle =
1312 toCSSPrimitiveValue(list.item(list.length() - 1)).computeDegrees(); 1312 toCSSPrimitiveValue(list.item(list.length() - 1)).computeDegrees();
(...skipping 14 matching lines...) Expand all
1327 1327
1328 PassRefPtr<ScaleTransformOperation> StyleBuilderConverter::convertScale( 1328 PassRefPtr<ScaleTransformOperation> StyleBuilderConverter::convertScale(
1329 StyleResolverState& state, 1329 StyleResolverState& state,
1330 const CSSValue& value) { 1330 const CSSValue& value) {
1331 if (value.isIdentifierValue()) { 1331 if (value.isIdentifierValue()) {
1332 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); 1332 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone);
1333 return nullptr; 1333 return nullptr;
1334 } 1334 }
1335 1335
1336 const CSSValueList& list = toCSSValueList(value); 1336 const CSSValueList& list = toCSSValueList(value);
1337 ASSERT(list.length() <= 3); 1337 DCHECK_LE(list.length(), static_cast<unsigned>(3));
tkent 2017/03/28 14:44:56 static_cast<unsigned>(3) -> 3u
nikhil.sahni 2017/03/30 12:17:58 Done.
1338 double sx = toCSSPrimitiveValue(list.item(0)).getDoubleValue(); 1338 double sx = toCSSPrimitiveValue(list.item(0)).getDoubleValue();
1339 double sy = 1; 1339 double sy = 1;
1340 double sz = 1; 1340 double sz = 1;
1341 if (list.length() >= 2) 1341 if (list.length() >= 2)
1342 sy = toCSSPrimitiveValue(list.item(1)).getDoubleValue(); 1342 sy = toCSSPrimitiveValue(list.item(1)).getDoubleValue();
1343 if (list.length() == 3) 1343 if (list.length() == 3)
1344 sz = toCSSPrimitiveValue(list.item(2)).getDoubleValue(); 1344 sz = toCSSPrimitiveValue(list.item(2)).getDoubleValue();
1345 1345
1346 return ScaleTransformOperation::create(sx, sy, sz, 1346 return ScaleTransformOperation::create(sx, sy, sz,
1347 TransformOperation::Scale3D); 1347 TransformOperation::Scale3D);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 } 1401 }
1402 1402
1403 const CSSValue& StyleBuilderConverter::convertRegisteredPropertyValue( 1403 const CSSValue& StyleBuilderConverter::convertRegisteredPropertyValue(
1404 const StyleResolverState& state, 1404 const StyleResolverState& state,
1405 const CSSValue& value) { 1405 const CSSValue& value) {
1406 return computeRegisteredPropertyValue(state.cssToLengthConversionData(), 1406 return computeRegisteredPropertyValue(state.cssToLengthConversionData(),
1407 value); 1407 value);
1408 } 1408 }
1409 1409
1410 } // namespace blink 1410 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698