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

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

Issue 2566403003: Migrate WTF::Vector::append() to ::push_back() [part 3 of N] (Closed)
Patch Set: Created 4 years 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 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 const CSSValue& value, 632 const CSSValue& value,
633 size_t currentNamedGridLine, 633 size_t currentNamedGridLine,
634 NamedGridLinesMap& namedGridLines, 634 NamedGridLinesMap& namedGridLines,
635 OrderedNamedGridLines& orderedNamedGridLines) { 635 OrderedNamedGridLines& orderedNamedGridLines) {
636 ASSERT(value.isGridLineNamesValue()); 636 ASSERT(value.isGridLineNamesValue());
637 637
638 for (auto& namedGridLineValue : toCSSValueList(value)) { 638 for (auto& namedGridLineValue : toCSSValueList(value)) {
639 String namedGridLine = toCSSCustomIdentValue(*namedGridLineValue).value(); 639 String namedGridLine = toCSSCustomIdentValue(*namedGridLineValue).value();
640 NamedGridLinesMap::AddResult result = 640 NamedGridLinesMap::AddResult result =
641 namedGridLines.add(namedGridLine, Vector<size_t>()); 641 namedGridLines.add(namedGridLine, Vector<size_t>());
642 result.storedValue->value.append(currentNamedGridLine); 642 result.storedValue->value.push_back(currentNamedGridLine);
643 OrderedNamedGridLines::AddResult orderedInsertionResult = 643 OrderedNamedGridLines::AddResult orderedInsertionResult =
644 orderedNamedGridLines.add(currentNamedGridLine, Vector<String>()); 644 orderedNamedGridLines.add(currentNamedGridLine, Vector<String>());
645 orderedInsertionResult.storedValue->value.append(namedGridLine); 645 orderedInsertionResult.storedValue->value.push_back(namedGridLine);
646 } 646 }
647 } 647 }
648 648
649 Vector<GridTrackSize> StyleBuilderConverter::convertGridTrackSizeList( 649 Vector<GridTrackSize> StyleBuilderConverter::convertGridTrackSizeList(
650 StyleResolverState& state, 650 StyleResolverState& state,
651 const CSSValue& value) { 651 const CSSValue& value) {
652 DCHECK(value.isValueList()); 652 DCHECK(value.isValueList());
653 Vector<GridTrackSize> trackSizes; 653 Vector<GridTrackSize> trackSizes;
654 for (auto& currValue : toCSSValueList(value)) { 654 for (auto& currValue : toCSSValueList(value)) {
655 DCHECK(!currValue->isGridLineNamesValue()); 655 DCHECK(!currValue->isGridLineNamesValue());
656 DCHECK(!currValue->isGridAutoRepeatValue()); 656 DCHECK(!currValue->isGridAutoRepeatValue());
657 trackSizes.append(convertGridTrackSize(state, *currValue)); 657 trackSizes.push_back(convertGridTrackSize(state, *currValue));
658 } 658 }
659 return trackSizes; 659 return trackSizes;
660 } 660 }
661 661
662 void StyleBuilderConverter::convertGridTrackList( 662 void StyleBuilderConverter::convertGridTrackList(
663 const CSSValue& value, 663 const CSSValue& value,
664 Vector<GridTrackSize>& trackSizes, 664 Vector<GridTrackSize>& trackSizes,
665 NamedGridLinesMap& namedGridLines, 665 NamedGridLinesMap& namedGridLines,
666 OrderedNamedGridLines& orderedNamedGridLines, 666 OrderedNamedGridLines& orderedNamedGridLines,
667 Vector<GridTrackSize>& autoRepeatTrackSizes, 667 Vector<GridTrackSize>& autoRepeatTrackSizes,
(...skipping 24 matching lines...) Expand all
692 autoRepeatID == CSSValueAutoFit); 692 autoRepeatID == CSSValueAutoFit);
693 autoRepeatType = autoRepeatID == CSSValueAutoFill ? AutoFill : AutoFit; 693 autoRepeatType = autoRepeatID == CSSValueAutoFill ? AutoFill : AutoFit;
694 for (auto autoRepeatValue : toCSSValueList(*currValue)) { 694 for (auto autoRepeatValue : toCSSValueList(*currValue)) {
695 if (autoRepeatValue->isGridLineNamesValue()) { 695 if (autoRepeatValue->isGridLineNamesValue()) {
696 convertGridLineNamesList(*autoRepeatValue, autoRepeatIndex, 696 convertGridLineNamesList(*autoRepeatValue, autoRepeatIndex,
697 autoRepeatNamedGridLines, 697 autoRepeatNamedGridLines,
698 autoRepeatOrderedNamedGridLines); 698 autoRepeatOrderedNamedGridLines);
699 continue; 699 continue;
700 } 700 }
701 ++autoRepeatIndex; 701 ++autoRepeatIndex;
702 autoRepeatTrackSizes.append( 702 autoRepeatTrackSizes.push_back(
703 convertGridTrackSize(state, *autoRepeatValue)); 703 convertGridTrackSize(state, *autoRepeatValue));
704 } 704 }
705 autoRepeatInsertionPoint = currentNamedGridLine++; 705 autoRepeatInsertionPoint = currentNamedGridLine++;
706 continue; 706 continue;
707 } 707 }
708 708
709 ++currentNamedGridLine; 709 ++currentNamedGridLine;
710 trackSizes.append(convertGridTrackSize(state, *currValue)); 710 trackSizes.push_back(convertGridTrackSize(state, *currValue));
711 } 711 }
712 712
713 // The parser should have rejected any <track-list> without any <track-size> 713 // The parser should have rejected any <track-list> without any <track-size>
714 // as this is not conformant to the syntax. 714 // as this is not conformant to the syntax.
715 ASSERT(!trackSizes.isEmpty() || !autoRepeatTrackSizes.isEmpty()); 715 ASSERT(!trackSizes.isEmpty() || !autoRepeatTrackSizes.isEmpty());
716 } 716 }
717 717
718 void StyleBuilderConverter::convertOrderedNamedGridLinesMapToNamedGridLinesMap( 718 void StyleBuilderConverter::convertOrderedNamedGridLinesMapToNamedGridLinesMap(
719 const OrderedNamedGridLines& orderedNamedGridLines, 719 const OrderedNamedGridLines& orderedNamedGridLines,
720 NamedGridLinesMap& namedGridLines) { 720 NamedGridLinesMap& namedGridLines) {
721 ASSERT(namedGridLines.size() == 0); 721 ASSERT(namedGridLines.size() == 0);
722 722
723 if (orderedNamedGridLines.size() == 0) 723 if (orderedNamedGridLines.size() == 0)
724 return; 724 return;
725 725
726 for (auto& orderedNamedGridLine : orderedNamedGridLines) { 726 for (auto& orderedNamedGridLine : orderedNamedGridLines) {
727 for (auto& lineName : orderedNamedGridLine.value) { 727 for (auto& lineName : orderedNamedGridLine.value) {
728 NamedGridLinesMap::AddResult startResult = 728 NamedGridLinesMap::AddResult startResult =
729 namedGridLines.add(lineName, Vector<size_t>()); 729 namedGridLines.add(lineName, Vector<size_t>());
730 startResult.storedValue->value.append(orderedNamedGridLine.key); 730 startResult.storedValue->value.push_back(orderedNamedGridLine.key);
731 } 731 }
732 } 732 }
733 733
734 for (auto& namedGridLine : namedGridLines) { 734 for (auto& namedGridLine : namedGridLines) {
735 Vector<size_t> gridLineIndexes = namedGridLine.value; 735 Vector<size_t> gridLineIndexes = namedGridLine.value;
736 std::sort(gridLineIndexes.begin(), gridLineIndexes.end()); 736 std::sort(gridLineIndexes.begin(), gridLineIndexes.end());
737 } 737 }
738 } 738 }
739 739
740 void StyleBuilderConverter::createImplicitNamedGridLinesFromGridArea( 740 void StyleBuilderConverter::createImplicitNamedGridLinesFromGridArea(
741 const NamedGridAreaMap& namedGridAreas, 741 const NamedGridAreaMap& namedGridAreas,
742 NamedGridLinesMap& namedGridLines, 742 NamedGridLinesMap& namedGridLines,
743 GridTrackSizingDirection direction) { 743 GridTrackSizingDirection direction) {
744 for (const auto& namedGridAreaEntry : namedGridAreas) { 744 for (const auto& namedGridAreaEntry : namedGridAreas) {
745 GridSpan areaSpan = direction == ForRows ? namedGridAreaEntry.value.rows 745 GridSpan areaSpan = direction == ForRows ? namedGridAreaEntry.value.rows
746 : namedGridAreaEntry.value.columns; 746 : namedGridAreaEntry.value.columns;
747 { 747 {
748 NamedGridLinesMap::AddResult startResult = namedGridLines.add( 748 NamedGridLinesMap::AddResult startResult = namedGridLines.add(
749 namedGridAreaEntry.key + "-start", Vector<size_t>()); 749 namedGridAreaEntry.key + "-start", Vector<size_t>());
750 startResult.storedValue->value.append(areaSpan.startLine()); 750 startResult.storedValue->value.push_back(areaSpan.startLine());
751 std::sort(startResult.storedValue->value.begin(), 751 std::sort(startResult.storedValue->value.begin(),
752 startResult.storedValue->value.end()); 752 startResult.storedValue->value.end());
753 } 753 }
754 { 754 {
755 NamedGridLinesMap::AddResult endResult = 755 NamedGridLinesMap::AddResult endResult =
756 namedGridLines.add(namedGridAreaEntry.key + "-end", Vector<size_t>()); 756 namedGridLines.add(namedGridAreaEntry.key + "-end", Vector<size_t>());
757 endResult.storedValue->value.append(areaSpan.endLine()); 757 endResult.storedValue->value.push_back(areaSpan.endLine());
758 std::sort(endResult.storedValue->value.begin(), 758 std::sort(endResult.storedValue->value.begin(),
759 endResult.storedValue->value.end()); 759 endResult.storedValue->value.end());
760 } 760 }
761 } 761 }
762 } 762 }
763 763
764 Length StyleBuilderConverter::convertLength(const StyleResolverState& state, 764 Length StyleBuilderConverter::convertLength(const StyleResolverState& state,
765 const CSSValue& value) { 765 const CSSValue& value) {
766 return toCSSPrimitiveValue(value).convertToLength( 766 return toCSSPrimitiveValue(value).convertToLength(
767 state.cssToLengthConversionData()); 767 state.cssToLengthConversionData());
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 // Instead of the actual zoom, use 1 to avoid potential rounding errors 1295 // Instead of the actual zoom, use 1 to avoid potential rounding errors
1296 Length length = primitiveValue.convertToLength( 1296 Length length = primitiveValue.convertToLength(
1297 state.cssToLengthConversionData().copyWithAdjustedZoom(1)); 1297 state.cssToLengthConversionData().copyWithAdjustedZoom(1));
1298 return *CSSPrimitiveValue::create(length, 1); 1298 return *CSSPrimitiveValue::create(length, 1);
1299 } 1299 }
1300 } 1300 }
1301 return value; 1301 return value;
1302 } 1302 }
1303 1303
1304 } // namespace blink 1304 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698