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

Side by Side Diff: Source/core/rendering/RenderGrid.cpp

Issue 17601010: [CSS Grid Layout] Rename grid placement properties (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: missing webposed/ changes Created 7 years, 5 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
« no previous file with comments | « Source/core/rendering/RenderGrid.h ('k') | Source/core/rendering/style/RenderStyle.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 return style()->gridDefinitionColumns().size(); 433 return style()->gridDefinitionColumns().size();
434 } 434 }
435 435
436 size_t RenderGrid::explicitGridRowCount() const 436 size_t RenderGrid::explicitGridRowCount() const
437 { 437 {
438 return style()->gridDefinitionRows().size(); 438 return style()->gridDefinitionRows().size();
439 } 439 }
440 440
441 size_t RenderGrid::explicitGridSizeForSide(GridPositionSide side) const 441 size_t RenderGrid::explicitGridSizeForSide(GridPositionSide side) const
442 { 442 {
443 return (side == StartSide || side == EndSide) ? explicitGridColumnCount() : explicitGridRowCount(); 443 return (side == ColumnStartSide || side == ColumnEndSide) ? explicitGridColu mnCount() : explicitGridRowCount();
444 } 444 }
445 445
446 size_t RenderGrid::maximumIndexInDirection(TrackSizingDirection direction) const 446 size_t RenderGrid::maximumIndexInDirection(TrackSizingDirection direction) const
447 { 447 {
448 size_t maximumIndex = std::max<size_t>(1, (direction == ForColumns) ? explic itGridColumnCount() : explicitGridRowCount()); 448 size_t maximumIndex = std::max<size_t>(1, (direction == ForColumns) ? explic itGridColumnCount() : explicitGridRowCount());
449 449
450 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { 450 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) {
451 // This function bypasses the cache (cachedGridCoordinate()) as it is us ed to build it. 451 // This function bypasses the cache (cachedGridCoordinate()) as it is us ed to build it.
452 OwnPtr<GridSpan> positions = resolveGridPositionsFromStyle(child, direct ion); 452 OwnPtr<GridSpan> positions = resolveGridPositionsFromStyle(child, direct ion);
453 453
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 816
817 RenderGrid::GridSpan RenderGrid::resolveGridPositionsFromAutoPlacementPosition(c onst RenderBox*, TrackSizingDirection, size_t initialPosition) const 817 RenderGrid::GridSpan RenderGrid::resolveGridPositionsFromAutoPlacementPosition(c onst RenderBox*, TrackSizingDirection, size_t initialPosition) const
818 { 818 {
819 // FIXME: We don't support spanning with auto positions yet. Once we do, thi s is wrong. Also we should make 819 // FIXME: We don't support spanning with auto positions yet. Once we do, thi s is wrong. Also we should make
820 // sure the grid can accomodate the new item as we only grow 1 position in a given direction. 820 // sure the grid can accomodate the new item as we only grow 1 position in a given direction.
821 return GridSpan(initialPosition, initialPosition); 821 return GridSpan(initialPosition, initialPosition);
822 } 822 }
823 823
824 PassOwnPtr<RenderGrid::GridSpan> RenderGrid::resolveGridPositionsFromStyle(const RenderBox* gridItem, TrackSizingDirection direction) const 824 PassOwnPtr<RenderGrid::GridSpan> RenderGrid::resolveGridPositionsFromStyle(const RenderBox* gridItem, TrackSizingDirection direction) const
825 { 825 {
826 const GridPosition& initialPosition = (direction == ForColumns) ? gridItem-> style()->gridStart() : gridItem->style()->gridBefore(); 826 const GridPosition& initialPosition = (direction == ForColumns) ? gridItem-> style()->gridColumnStart() : gridItem->style()->gridRowStart();
827 const GridPositionSide initialPositionSide = (direction == ForColumns) ? Sta rtSide : BeforeSide; 827 const GridPositionSide initialPositionSide = (direction == ForColumns) ? Col umnStartSide : RowStartSide;
828 const GridPosition& finalPosition = (direction == ForColumns) ? gridItem->st yle()->gridEnd() : gridItem->style()->gridAfter(); 828 const GridPosition& finalPosition = (direction == ForColumns) ? gridItem->st yle()->gridColumnEnd() : gridItem->style()->gridRowEnd();
829 const GridPositionSide finalPositionSide = (direction == ForColumns) ? EndSi de : AfterSide; 829 const GridPositionSide finalPositionSide = (direction == ForColumns) ? Colum nEndSide : RowEndSide;
830 830
831 // We should NEVER see both spans as they should have been handled during st yle resolve. 831 // We should NEVER see both spans as they should have been handled during st yle resolve.
832 ASSERT(!initialPosition.isSpan() || !finalPosition.isSpan()); 832 ASSERT(!initialPosition.isSpan() || !finalPosition.isSpan());
833 833
834 if (initialPosition.isAuto() && finalPosition.isAuto()) { 834 if (initialPosition.isAuto() && finalPosition.isAuto()) {
835 if (style()->gridAutoFlow() == AutoFlowNone) 835 if (style()->gridAutoFlow() == AutoFlowNone)
836 return adoptPtr(new GridSpan(0, 0)); 836 return adoptPtr(new GridSpan(0, 0));
837 837
838 // We can't get our grid positions without running the auto placement al gorithm. 838 // We can't get our grid positions without running the auto placement al gorithm.
839 return nullptr; 839 return nullptr;
(...skipping 17 matching lines...) Expand all
857 // If 'grid-after' specifies a line at or before that specified by 'grid-bef ore', it computes to 'span 1'. 857 // If 'grid-after' specifies a line at or before that specified by 'grid-bef ore', it computes to 'span 1'.
858 if (resolvedFinalPosition < resolvedInitialPosition) 858 if (resolvedFinalPosition < resolvedInitialPosition)
859 resolvedFinalPosition = resolvedInitialPosition; 859 resolvedFinalPosition = resolvedInitialPosition;
860 860
861 return adoptPtr(new GridSpan(resolvedInitialPosition, resolvedFinalPosition) ); 861 return adoptPtr(new GridSpan(resolvedInitialPosition, resolvedFinalPosition) );
862 } 862 }
863 863
864 static size_t adjustGridPositionForSide(size_t resolvedPosition, GridPositionSid e side) 864 static size_t adjustGridPositionForSide(size_t resolvedPosition, GridPositionSid e side)
865 { 865 {
866 // An item finishing on the N-th line belongs to the N-1-th cell. 866 // An item finishing on the N-th line belongs to the N-1-th cell.
867 if (side == EndSide || side == AfterSide) 867 if (side == ColumnEndSide || side == RowEndSide)
868 return resolvedPosition ? resolvedPosition - 1 : 0; 868 return resolvedPosition ? resolvedPosition - 1 : 0;
869 869
870 return resolvedPosition; 870 return resolvedPosition;
871 } 871 }
872 872
873 size_t RenderGrid::resolveNamedGridLinePositionFromStyle(const GridPosition& pos ition, GridPositionSide side) const 873 size_t RenderGrid::resolveNamedGridLinePositionFromStyle(const GridPosition& pos ition, GridPositionSide side) const
874 { 874 {
875 ASSERT(!position.namedGridLine().isNull()); 875 ASSERT(!position.namedGridLine().isNull());
876 876
877 const NamedGridLinesMap& gridLinesNames = (side == StartSide || side == EndS ide) ? style()->namedGridColumnLines() : style()->namedGridRowLines(); 877 const NamedGridLinesMap& gridLinesNames = (side == ColumnStartSide || side = = ColumnEndSide) ? style()->namedGridColumnLines() : style()->namedGridRowLines( );
878 NamedGridLinesMap::const_iterator it = gridLinesNames.find(position.namedGri dLine()); 878 NamedGridLinesMap::const_iterator it = gridLinesNames.find(position.namedGri dLine());
879 if (it == gridLinesNames.end()) { 879 if (it == gridLinesNames.end()) {
880 if (position.isPositive()) 880 if (position.isPositive())
881 return 0; 881 return 0;
882 const size_t lastLine = explicitGridSizeForSide(side); 882 const size_t lastLine = explicitGridSizeForSide(side);
883 return adjustGridPositionForSide(lastLine, side); 883 return adjustGridPositionForSide(lastLine, side);
884 } 884 }
885 885
886 size_t namedGridLineIndex; 886 size_t namedGridLineIndex;
887 if (position.isPositive()) 887 if (position.isPositive())
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 { 931 {
932 if (position.isAuto()) 932 if (position.isAuto())
933 return GridSpan::create(resolvedOppositePosition, resolvedOppositePositi on); 933 return GridSpan::create(resolvedOppositePosition, resolvedOppositePositi on);
934 934
935 ASSERT(position.isSpan()); 935 ASSERT(position.isSpan());
936 ASSERT(position.spanPosition() > 0); 936 ASSERT(position.spanPosition() > 0);
937 937
938 // 'span 1' is contained inside a single grid track regardless of the direct ion. 938 // 'span 1' is contained inside a single grid track regardless of the direct ion.
939 // That's why the CSS span value is one more than the offset we apply. 939 // That's why the CSS span value is one more than the offset we apply.
940 size_t positionOffset = position.spanPosition() - 1; 940 size_t positionOffset = position.spanPosition() - 1;
941 if (side == StartSide || side == BeforeSide) { 941 if (side == ColumnStartSide || side == RowStartSide) {
942 size_t initialResolvedPosition = std::max<int>(0, resolvedOppositePositi on - positionOffset); 942 size_t initialResolvedPosition = std::max<int>(0, resolvedOppositePositi on - positionOffset);
943 return GridSpan::create(initialResolvedPosition, resolvedOppositePositio n); 943 return GridSpan::create(initialResolvedPosition, resolvedOppositePositio n);
944 } 944 }
945 945
946 return GridSpan::create(resolvedOppositePosition, resolvedOppositePosition + positionOffset); 946 return GridSpan::create(resolvedOppositePosition, resolvedOppositePosition + positionOffset);
947 } 947 }
948 948
949 LayoutUnit RenderGrid::gridAreaBreadthForChild(const RenderBox* child, TrackSizi ngDirection direction, const Vector<GridTrack>& tracks) const 949 LayoutUnit RenderGrid::gridAreaBreadthForChild(const RenderBox* child, TrackSizi ngDirection direction, const Vector<GridTrack>& tracks) const
950 { 950 {
951 const GridCoordinate& coordinate = cachedGridCoordinate(child); 951 const GridCoordinate& coordinate = cachedGridCoordinate(child);
(...skipping 27 matching lines...) Expand all
979 if (isOutOfFlowPositioned()) 979 if (isOutOfFlowPositioned())
980 return "RenderGrid (positioned)"; 980 return "RenderGrid (positioned)";
981 if (isAnonymous()) 981 if (isAnonymous())
982 return "RenderGrid (generated)"; 982 return "RenderGrid (generated)";
983 if (isRelPositioned()) 983 if (isRelPositioned())
984 return "RenderGrid (relative positioned)"; 984 return "RenderGrid (relative positioned)";
985 return "RenderGrid"; 985 return "RenderGrid";
986 } 986 }
987 987
988 } // namespace WebCore 988 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderGrid.h ('k') | Source/core/rendering/style/RenderStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698