| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> | 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> |
| 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
| 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
| 6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. | 6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. |
| 7 * Copyright (C) 2015 Google Inc. All rights reserved. | 7 * Copyright (C) 2015 Google Inc. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Lesser General Public | 10 * modify it under the terms of the GNU Lesser General Public |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 return minMaxTrackBreadths; | 737 return minMaxTrackBreadths; |
| 738 } | 738 } |
| 739 ASSERT_NOT_REACHED(); | 739 ASSERT_NOT_REACHED(); |
| 740 return nullptr; | 740 return nullptr; |
| 741 } | 741 } |
| 742 | 742 |
| 743 class OrderedNamedLinesCollector { | 743 class OrderedNamedLinesCollector { |
| 744 STACK_ALLOCATED(); | 744 STACK_ALLOCATED(); |
| 745 WTF_MAKE_NONCOPYABLE(OrderedNamedLinesCollector); | 745 WTF_MAKE_NONCOPYABLE(OrderedNamedLinesCollector); |
| 746 public: | 746 public: |
| 747 OrderedNamedLinesCollector(const ComputedStyle& style, bool isRowAxis, size_
t repetitions) | 747 OrderedNamedLinesCollector(const ComputedStyle& style, bool isRowAxis, size_
t autoRepeatTracksCount) |
| 748 : m_orderedNamedGridLines(isRowAxis ? style.orderedNamedGridColumnLines(
) : style.orderedNamedGridRowLines()) | 748 : m_orderedNamedGridLines(isRowAxis ? style.orderedNamedGridColumnLines(
) : style.orderedNamedGridRowLines()) |
| 749 , m_orderedNamedAutoRepeatGridLines(isRowAxis ? style.autoRepeatOrderedN
amedGridColumnLines() : style.autoRepeatOrderedNamedGridRowLines()) | 749 , m_orderedNamedAutoRepeatGridLines(isRowAxis ? style.autoRepeatOrderedN
amedGridColumnLines() : style.autoRepeatOrderedNamedGridRowLines()) |
| 750 , m_insertionPoint(isRowAxis ? style.gridAutoRepeatColumnsInsertionPoint
() : style.gridAutoRepeatRowsInsertionPoint()) | 750 , m_insertionPoint(isRowAxis ? style.gridAutoRepeatColumnsInsertionPoint
() : style.gridAutoRepeatRowsInsertionPoint()) |
| 751 , m_repetitions(repetitions) | 751 , m_autoRepeatTotalTracks(autoRepeatTracksCount) |
| 752 , m_autoRepeatTrackListLength(isRowAxis ? style.gridAutoRepeatColumns().
size() : style.gridAutoRepeatRows().size()) |
| 752 { | 753 { |
| 753 } | 754 } |
| 754 | 755 |
| 755 bool isEmpty() const { return m_orderedNamedGridLines.isEmpty() && m_ordered
NamedAutoRepeatGridLines.isEmpty(); } | 756 bool isEmpty() const { return m_orderedNamedGridLines.isEmpty() && m_ordered
NamedAutoRepeatGridLines.isEmpty(); } |
| 756 void collectLineNamesForIndex(CSSGridLineNamesValue&, size_t index) const; | 757 void collectLineNamesForIndex(CSSGridLineNamesValue&, size_t index) const; |
| 757 | 758 |
| 758 private: | 759 private: |
| 759 | 760 |
| 760 enum NamedLinesType { NamedLines, AutoRepeatNamedLines }; | 761 enum NamedLinesType { NamedLines, AutoRepeatNamedLines }; |
| 761 void appendLines(CSSGridLineNamesValue&, size_t index, NamedLinesType) const
; | 762 void appendLines(CSSGridLineNamesValue&, size_t index, NamedLinesType) const
; |
| 762 | 763 |
| 763 const OrderedNamedGridLines& m_orderedNamedGridLines; | 764 const OrderedNamedGridLines& m_orderedNamedGridLines; |
| 764 const OrderedNamedGridLines& m_orderedNamedAutoRepeatGridLines; | 765 const OrderedNamedGridLines& m_orderedNamedAutoRepeatGridLines; |
| 765 size_t m_insertionPoint; | 766 size_t m_insertionPoint; |
| 766 size_t m_repetitions; | 767 size_t m_autoRepeatTotalTracks; |
| 768 size_t m_autoRepeatTrackListLength; |
| 767 }; | 769 }; |
| 768 | 770 |
| 769 void OrderedNamedLinesCollector::appendLines(CSSGridLineNamesValue& lineNamesVal
ue, size_t index, NamedLinesType type) const | 771 void OrderedNamedLinesCollector::appendLines(CSSGridLineNamesValue& lineNamesVal
ue, size_t index, NamedLinesType type) const |
| 770 { | 772 { |
| 771 auto iter = type == NamedLines ? m_orderedNamedGridLines.find(index) : m_ord
eredNamedAutoRepeatGridLines.find(index); | 773 auto iter = type == NamedLines ? m_orderedNamedGridLines.find(index) : m_ord
eredNamedAutoRepeatGridLines.find(index); |
| 772 auto endIter = type == NamedLines ? m_orderedNamedGridLines.end() : m_ordere
dNamedAutoRepeatGridLines.end(); | 774 auto endIter = type == NamedLines ? m_orderedNamedGridLines.end() : m_ordere
dNamedAutoRepeatGridLines.end(); |
| 773 if (iter == endIter) | 775 if (iter == endIter) |
| 774 return; | 776 return; |
| 775 | 777 |
| 776 for (auto lineName : iter->value) | 778 for (auto lineName : iter->value) |
| 777 lineNamesValue.append(*CSSCustomIdentValue::create(lineName)); | 779 lineNamesValue.append(*CSSCustomIdentValue::create(lineName)); |
| 778 } | 780 } |
| 779 | 781 |
| 780 void OrderedNamedLinesCollector::collectLineNamesForIndex(CSSGridLineNamesValue&
lineNamesValue, size_t i) const | 782 void OrderedNamedLinesCollector::collectLineNamesForIndex(CSSGridLineNamesValue&
lineNamesValue, size_t i) const |
| 781 { | 783 { |
| 782 DCHECK(!isEmpty()); | 784 DCHECK(!isEmpty()); |
| 783 if (m_orderedNamedAutoRepeatGridLines.isEmpty() || i < m_insertionPoint) { | 785 if (m_orderedNamedAutoRepeatGridLines.isEmpty() || i < m_insertionPoint) { |
| 784 appendLines(lineNamesValue, i, NamedLines); | 786 appendLines(lineNamesValue, i, NamedLines); |
| 785 return; | 787 return; |
| 786 } | 788 } |
| 787 | 789 |
| 788 DCHECK(m_repetitions); | 790 DCHECK(m_autoRepeatTotalTracks); |
| 789 if (i > m_insertionPoint + m_repetitions) { | 791 |
| 790 appendLines(lineNamesValue, i - (m_repetitions - 1), NamedLines); | 792 if (i > m_insertionPoint + m_autoRepeatTotalTracks) { |
| 793 appendLines(lineNamesValue, i - (m_autoRepeatTotalTracks - 1), NamedLine
s); |
| 791 return; | 794 return; |
| 792 } | 795 } |
| 793 | 796 |
| 794 if (i == m_insertionPoint) { | 797 if (i == m_insertionPoint) { |
| 795 appendLines(lineNamesValue, i, NamedLines); | 798 appendLines(lineNamesValue, i, NamedLines); |
| 796 appendLines(lineNamesValue, 0, AutoRepeatNamedLines); | 799 appendLines(lineNamesValue, 0, AutoRepeatNamedLines); |
| 797 return; | 800 return; |
| 798 } | 801 } |
| 799 | 802 |
| 800 if (i == m_insertionPoint + m_repetitions) { | 803 if (i == m_insertionPoint + m_autoRepeatTotalTracks) { |
| 801 appendLines(lineNamesValue, 1, AutoRepeatNamedLines); | 804 appendLines(lineNamesValue, m_autoRepeatTrackListLength, AutoRepeatNamed
Lines); |
| 802 appendLines(lineNamesValue, m_insertionPoint + 1, NamedLines); | 805 appendLines(lineNamesValue, m_insertionPoint + 1, NamedLines); |
| 803 return; | 806 return; |
| 804 } | 807 } |
| 805 | 808 |
| 806 appendLines(lineNamesValue, 1, AutoRepeatNamedLines); | 809 size_t autoRepeatIndexInFirstRepetition = (i - m_insertionPoint) % m_autoRep
eatTrackListLength; |
| 807 appendLines(lineNamesValue, 0, AutoRepeatNamedLines); | 810 if (!autoRepeatIndexInFirstRepetition && i > m_insertionPoint) |
| 811 appendLines(lineNamesValue, m_autoRepeatTrackListLength, AutoRepeatNamed
Lines); |
| 812 appendLines(lineNamesValue, autoRepeatIndexInFirstRepetition, AutoRepeatName
dLines); |
| 808 } | 813 } |
| 809 | 814 |
| 810 static void addValuesForNamedGridLinesAtIndex(OrderedNamedLinesCollector& collec
tor, size_t i, CSSValueList& list) | 815 static void addValuesForNamedGridLinesAtIndex(OrderedNamedLinesCollector& collec
tor, size_t i, CSSValueList& list) |
| 811 { | 816 { |
| 812 if (collector.isEmpty()) | 817 if (collector.isEmpty()) |
| 813 return; | 818 return; |
| 814 | 819 |
| 815 CSSGridLineNamesValue* lineNames = CSSGridLineNamesValue::create(); | 820 CSSGridLineNamesValue* lineNames = CSSGridLineNamesValue::create(); |
| 816 collector.collectLineNamesForIndex(*lineNames, i); | 821 collector.collectLineNamesForIndex(*lineNames, i); |
| 817 if (lineNames->length()) | 822 if (lineNames->length()) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 830 if (isLayoutGrid && trackListIsEmpty) { | 835 if (isLayoutGrid && trackListIsEmpty) { |
| 831 // For grids we should consider every listed track, whether implicitly o
r explicitly | 836 // For grids we should consider every listed track, whether implicitly o
r explicitly |
| 832 // created. Empty grids have a sole grid line per axis. | 837 // created. Empty grids have a sole grid line per axis. |
| 833 auto& positions = isRowAxis ? toLayoutGrid(layoutObject)->columnPosition
s() : toLayoutGrid(layoutObject)->rowPositions(); | 838 auto& positions = isRowAxis ? toLayoutGrid(layoutObject)->columnPosition
s() : toLayoutGrid(layoutObject)->rowPositions(); |
| 834 trackListIsEmpty = positions.size() == 1; | 839 trackListIsEmpty = positions.size() == 1; |
| 835 } | 840 } |
| 836 | 841 |
| 837 if (trackListIsEmpty) | 842 if (trackListIsEmpty) |
| 838 return CSSPrimitiveValue::createIdentifier(CSSValueNone); | 843 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
| 839 | 844 |
| 840 size_t repetitions = isLayoutGrid ? toLayoutGrid(layoutObject)->autoRepeatCo
untForDirection(direction) : 0; | 845 size_t autoRepeatTotalTracks = isLayoutGrid ? toLayoutGrid(layoutObject)->au
toRepeatCountForDirection(direction) : 0; |
| 841 OrderedNamedLinesCollector collector(style, isRowAxis, repetitions); | 846 OrderedNamedLinesCollector collector(style, isRowAxis, autoRepeatTotalTracks
); |
| 842 CSSValueList* list = CSSValueList::createSpaceSeparated(); | 847 CSSValueList* list = CSSValueList::createSpaceSeparated(); |
| 843 size_t insertionIndex; | 848 size_t insertionIndex; |
| 844 if (isLayoutGrid) { | 849 if (isLayoutGrid) { |
| 845 const auto* grid = toLayoutGrid(layoutObject); | 850 const auto* grid = toLayoutGrid(layoutObject); |
| 846 Vector<LayoutUnit> computedTrackSizes = grid->trackSizesForComputedStyle
(direction); | 851 Vector<LayoutUnit> computedTrackSizes = grid->trackSizesForComputedStyle
(direction); |
| 847 size_t numTracks = computedTrackSizes.size(); | 852 size_t numTracks = computedTrackSizes.size(); |
| 848 | 853 |
| 849 for (size_t i = 0; i < numTracks; ++i) { | 854 for (size_t i = 0; i < numTracks; ++i) { |
| 850 addValuesForNamedGridLinesAtIndex(collector, i, *list); | 855 addValuesForNamedGridLinesAtIndex(collector, i, *list); |
| 851 list->append(*zoomAdjustedPixelValue(computedTrackSizes[i], style)); | 856 list->append(*zoomAdjustedPixelValue(computedTrackSizes[i], style)); |
| (...skipping 2154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3006 case CSSPropertyAll: | 3011 case CSSPropertyAll: |
| 3007 return nullptr; | 3012 return nullptr; |
| 3008 default: | 3013 default: |
| 3009 break; | 3014 break; |
| 3010 } | 3015 } |
| 3011 ASSERT_NOT_REACHED(); | 3016 ASSERT_NOT_REACHED(); |
| 3012 return nullptr; | 3017 return nullptr; |
| 3013 } | 3018 } |
| 3014 | 3019 |
| 3015 } // namespace blink | 3020 } // namespace blink |
| OLD | NEW |