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

Side by Side Diff: sky/engine/core/rendering/RenderGrid.h

Issue 689853003: Remove CSS Grid Layout and grid media queries. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « sky/engine/core/rendering/RenderBox.cpp ('k') | sky/engine/core/rendering/RenderGrid.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #ifndef RenderGrid_h
27 #define RenderGrid_h
28
29 #include "core/rendering/OrderIterator.h"
30 #include "core/rendering/RenderBlock.h"
31 #include "core/rendering/style/GridResolvedPosition.h"
32
33 namespace blink {
34
35 struct GridCoordinate;
36 struct GridSpan;
37 class GridTrack;
38
39 class RenderGrid final : public RenderBlock {
40 public:
41 RenderGrid(Element*);
42 virtual ~RenderGrid();
43
44 virtual const char* renderName() const override;
45
46 virtual void layoutBlock(bool relayoutChildren) override;
47
48 virtual bool canCollapseAnonymousBlockChild() const override { return false; }
49
50 void dirtyGrid();
51
52 const Vector<LayoutUnit>& columnPositions() const { return m_columnPositions ; }
53 const Vector<LayoutUnit>& rowPositions() const { return m_rowPositions; }
54
55 private:
56 virtual bool isRenderGrid() const override { return true; }
57 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const override;
58 virtual void computePreferredLogicalWidths() override;
59
60 virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0) override;
61 void addChildToIndexesMap(RenderBox*);
62 virtual void removeChild(RenderObject*) override;
63
64 virtual void styleDidChange(StyleDifference, const RenderStyle*) override;
65
66 bool explicitGridDidResize(const RenderStyle*) const;
67 bool namedGridLinesDefinitionDidChange(const RenderStyle*) const;
68
69 class GridIterator;
70 struct GridSizingData;
71 bool gridElementIsShrinkToFit();
72 void computeUsedBreadthOfGridTracks(GridTrackSizingDirection, GridSizingData &);
73 void computeUsedBreadthOfGridTracks(GridTrackSizingDirection, GridSizingData &, LayoutUnit& availableLogicalSpace);
74 LayoutUnit computeUsedBreadthOfMinLength(GridTrackSizingDirection, const Gri dLength&) const;
75 LayoutUnit computeUsedBreadthOfMaxLength(GridTrackSizingDirection, const Gri dLength&, LayoutUnit usedBreadth) const;
76 LayoutUnit computeUsedBreadthOfSpecifiedLength(GridTrackSizingDirection, con st Length&) const;
77 void resolveContentBasedTrackSizingFunctions(GridTrackSizingDirection, GridS izingData&, LayoutUnit& availableLogicalSpace);
78
79 void ensureGridSize(size_t maximumRowIndex, size_t maximumColumnIndex);
80 void insertItemIntoGrid(RenderBox*, const GridCoordinate&);
81 void placeItemsOnGrid();
82 void populateExplicitGridAndOrderIterator();
83 PassOwnPtr<GridCoordinate> createEmptyGridAreaAtSpecifiedPositionsOutsideGri d(const RenderBox*, GridTrackSizingDirection, const GridSpan& specifiedPositions ) const;
84 void placeSpecifiedMajorAxisItemsOnGrid(const Vector<RenderBox*>&);
85 void placeAutoMajorAxisItemsOnGrid(const Vector<RenderBox*>&);
86 void placeAutoMajorAxisItemOnGrid(RenderBox*, std::pair<size_t, size_t>& aut oPlacementCursor);
87 GridTrackSizingDirection autoPlacementMajorAxisDirection() const;
88 GridTrackSizingDirection autoPlacementMinorAxisDirection() const;
89
90 void layoutGridItems();
91 void populateGridPositions(const GridSizingData&);
92
93 typedef LayoutUnit (RenderGrid::* SizingFunction)(RenderBox*, GridTrackSizin gDirection, Vector<GridTrack>&);
94 typedef LayoutUnit (GridTrack::* AccumulatorGetter)() const;
95 typedef void (GridTrack::* AccumulatorGrowFunction)(LayoutUnit);
96 typedef bool (GridTrackSize::* FilterFunction)() const;
97 void resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizingDirectio n, GridSizingData&, RenderBox*, FilterFunction, SizingFunction, AccumulatorGette r, AccumulatorGrowFunction);
98 void distributeSpaceToTracks(Vector<GridTrack*>&, Vector<GridTrack*>* tracks ForGrowthAboveMaxBreadth, AccumulatorGetter, AccumulatorGrowFunction, GridSizing Data&, LayoutUnit& availableLogicalSpace);
99
100 double computeNormalizedFractionBreadth(Vector<GridTrack>&, const GridSpan& tracksSpan, GridTrackSizingDirection, LayoutUnit availableLogicalSpace) const;
101
102 const GridTrackSize& gridTrackSize(GridTrackSizingDirection, size_t) const;
103
104 LayoutUnit logicalHeightForChild(RenderBox*, Vector<GridTrack>&);
105 LayoutUnit minContentForChild(RenderBox*, GridTrackSizingDirection, Vector<G ridTrack>& columnTracks);
106 LayoutUnit maxContentForChild(RenderBox*, GridTrackSizingDirection, Vector<G ridTrack>& columnTracks);
107 LayoutUnit startOfColumnForChild(const RenderBox* child) const;
108 LayoutUnit endOfColumnForChild(const RenderBox* child) const;
109 LayoutUnit columnPositionAlignedWithGridContainerStart(const RenderBox*) con st;
110 LayoutUnit columnPositionAlignedWithGridContainerEnd(const RenderBox*) const ;
111 LayoutUnit centeredColumnPositionForChild(const RenderBox*) const;
112 LayoutUnit columnPositionForChild(const RenderBox*) const;
113 LayoutUnit startOfRowForChild(const RenderBox* child) const;
114 LayoutUnit endOfRowForChild(const RenderBox* child) const;
115 LayoutUnit centeredRowPositionForChild(const RenderBox*) const;
116 LayoutUnit rowPositionForChild(const RenderBox*) const;
117 LayoutPoint findChildLogicalPosition(const RenderBox*) const;
118 GridCoordinate cachedGridCoordinate(const RenderBox*) const;
119
120 LayoutUnit gridAreaBreadthForChild(const RenderBox* child, GridTrackSizingDi rection, const Vector<GridTrack>&) const;
121
122 virtual void paintChildren(PaintInfo&, const LayoutPoint&) override;
123
124 bool gridIsDirty() const { return m_gridIsDirty; }
125
126 #if ENABLE(ASSERT)
127 bool tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection, const Vecto r<GridTrack>&);
128 #endif
129
130 size_t gridItemSpan(const RenderBox*, GridTrackSizingDirection);
131
132 size_t gridColumnCount() const
133 {
134 ASSERT(!gridIsDirty());
135 return m_grid[0].size();
136 }
137 size_t gridRowCount() const
138 {
139 ASSERT(!gridIsDirty());
140 return m_grid.size();
141 }
142
143 typedef Vector<RenderBox*, 1> GridCell;
144 typedef Vector<Vector<GridCell> > GridRepresentation;
145 GridRepresentation m_grid;
146 bool m_gridIsDirty;
147 Vector<LayoutUnit> m_rowPositions;
148 Vector<LayoutUnit> m_columnPositions;
149 HashMap<const RenderBox*, GridCoordinate> m_gridItemCoordinate;
150 OrderIterator m_orderIterator;
151 Vector<RenderBox*> m_gridItemsOverflowingGridArea;
152 HashMap<const RenderBox*, size_t> m_gridItemsIndexesMap;
153 };
154
155 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderGrid, isRenderGrid());
156
157 } // namespace blink
158
159 #endif // RenderGrid_h
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderBox.cpp ('k') | sky/engine/core/rendering/RenderGrid.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698