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

Side by Side Diff: Source/core/layout/LayoutGrid.h

Issue 948343003: Move rendering/RenderGrid to layout/LayoutGrid (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/LayoutBox.cpp ('k') | Source/core/layout/LayoutGrid.cpp » ('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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef RenderGrid_h 26 #ifndef LayoutGrid_h
27 #define RenderGrid_h 27 #define LayoutGrid_h
28 28
29 #include "core/layout/OrderIterator.h" 29 #include "core/layout/OrderIterator.h"
30 #include "core/layout/style/GridResolvedPosition.h" 30 #include "core/layout/style/GridResolvedPosition.h"
31 #include "core/rendering/RenderBlock.h" 31 #include "core/rendering/RenderBlock.h"
32 32
33 namespace blink { 33 namespace blink {
34 34
35 struct GridCoordinate; 35 struct GridCoordinate;
36 struct GridSpan; 36 struct GridSpan;
37 class GridTrack; 37 class GridTrack;
38 class GridItemWithSpan; 38 class GridItemWithSpan;
39 39
40 class RenderGrid final : public RenderBlock { 40 class LayoutGrid final : public RenderBlock {
41 public: 41 public:
42 RenderGrid(Element*); 42 LayoutGrid(Element*);
43 virtual ~RenderGrid(); 43 virtual ~LayoutGrid();
44 44
45 virtual const char* renderName() const override; 45 virtual const char* renderName() const override;
46 46
47 virtual void layoutBlock(bool relayoutChildren) override; 47 virtual void layoutBlock(bool relayoutChildren) override;
48 48
49 virtual bool canCollapseAnonymousBlockChild() const override { return false; } 49 virtual bool canCollapseAnonymousBlockChild() const override { return false; }
50 50
51 void dirtyGrid(); 51 void dirtyGrid();
52 52
53 const Vector<LayoutUnit>& columnPositions() const { return m_columnPositions ; } 53 const Vector<LayoutUnit>& columnPositions() const { return m_columnPositions ; }
54 const Vector<LayoutUnit>& rowPositions() const { return m_rowPositions; } 54 const Vector<LayoutUnit>& rowPositions() const { return m_rowPositions; }
55 55
56 typedef Vector<LayoutBox*, 1> GridCell; 56 typedef Vector<LayoutBox*, 1> GridCell;
57 const GridCell& gridCell(int row, int column) { return m_grid[row][column]; } 57 const GridCell& gridCell(int row, int column) { return m_grid[row][column]; }
58 const Vector<LayoutBox*>& itemsOverflowingGridArea() { return m_gridItemsOve rflowingGridArea; } 58 const Vector<LayoutBox*>& itemsOverflowingGridArea() { return m_gridItemsOve rflowingGridArea; }
59 int paintIndexForGridItem(const LayoutBox* layoutBox) { return m_gridItemsIn dexesMap.get(layoutBox); } 59 int paintIndexForGridItem(const LayoutBox* layoutBox) { return m_gridItemsIn dexesMap.get(layoutBox); }
60 60
61 bool gridIsDirty() const { return m_gridIsDirty; } 61 bool gridIsDirty() const { return m_gridIsDirty; }
62 62
63 typedef void (GridTrack::* AccumulatorGrowFunction)(LayoutUnit); 63 typedef void (GridTrack::* AccumulatorGrowFunction)(LayoutUnit);
64 private: 64 private:
65 virtual bool isOfType(LayoutObjectType type) const override { return type == LayoutObjectRenderGrid || RenderBlock::isOfType(type); } 65 virtual bool isOfType(LayoutObjectType type) const override { return type == LayoutObjectLayoutGrid || RenderBlock::isOfType(type); }
66 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const override; 66 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const override;
67 virtual void computePreferredLogicalWidths() override; 67 virtual void computePreferredLogicalWidths() override;
68 68
69 virtual void addChild(LayoutObject* newChild, LayoutObject* beforeChild = 0) override; 69 virtual void addChild(LayoutObject* newChild, LayoutObject* beforeChild = 0) override;
70 virtual void removeChild(LayoutObject*) override; 70 virtual void removeChild(LayoutObject*) override;
71 71
72 virtual void styleDidChange(StyleDifference, const LayoutStyle*) override; 72 virtual void styleDidChange(StyleDifference, const LayoutStyle*) override;
73 73
74 bool explicitGridDidResize(const LayoutStyle&) const; 74 bool explicitGridDidResize(const LayoutStyle&) const;
75 bool namedGridLinesDefinitionDidChange(const LayoutStyle&) const; 75 bool namedGridLinesDefinitionDidChange(const LayoutStyle&) const;
(...skipping 17 matching lines...) Expand all
93 void placeAutoMajorAxisItemsOnGrid(const Vector<LayoutBox*>&); 93 void placeAutoMajorAxisItemsOnGrid(const Vector<LayoutBox*>&);
94 void placeAutoMajorAxisItemOnGrid(LayoutBox&, std::pair<size_t, size_t>& aut oPlacementCursor); 94 void placeAutoMajorAxisItemOnGrid(LayoutBox&, std::pair<size_t, size_t>& aut oPlacementCursor);
95 GridTrackSizingDirection autoPlacementMajorAxisDirection() const; 95 GridTrackSizingDirection autoPlacementMajorAxisDirection() const;
96 GridTrackSizingDirection autoPlacementMinorAxisDirection() const; 96 GridTrackSizingDirection autoPlacementMinorAxisDirection() const;
97 97
98 void layoutGridItems(); 98 void layoutGridItems();
99 void layoutPositionedObjects(bool relayoutChildren, PositionedLayoutBehavior = DefaultLayout); 99 void layoutPositionedObjects(bool relayoutChildren, PositionedLayoutBehavior = DefaultLayout);
100 void offsetAndBreadthForPositionedChild(const LayoutBox&, GridTrackSizingDir ection, bool startIsAuto, bool endIsAuto, LayoutUnit& offset, LayoutUnit& breadt h); 100 void offsetAndBreadthForPositionedChild(const LayoutBox&, GridTrackSizingDir ection, bool startIsAuto, bool endIsAuto, LayoutUnit& offset, LayoutUnit& breadt h);
101 void populateGridPositions(const GridSizingData&, LayoutUnit availableSpaceF orColumns, LayoutUnit availableSpaceForRows); 101 void populateGridPositions(const GridSizingData&, LayoutUnit availableSpaceF orColumns, LayoutUnit availableSpaceForRows);
102 102
103 typedef LayoutUnit (RenderGrid::* SizingFunction)(LayoutBox&, GridTrackSizin gDirection, Vector<GridTrack>&); 103 typedef LayoutUnit (LayoutGrid::* SizingFunction)(LayoutBox&, GridTrackSizin gDirection, Vector<GridTrack>&);
104 typedef const LayoutUnit& (GridTrack::* AccumulatorGetter)() const; 104 typedef const LayoutUnit& (GridTrack::* AccumulatorGetter)() const;
105 typedef bool (GridTrackSize::* FilterFunction)() const; 105 typedef bool (GridTrackSize::* FilterFunction)() const;
106 void resolveContentBasedTrackSizingFunctionsForNonSpanningItems(GridTrackSiz ingDirection, const GridCoordinate&, LayoutBox& gridItem, GridTrack&, Vector<Gri dTrack>& columnTracks); 106 void resolveContentBasedTrackSizingFunctionsForNonSpanningItems(GridTrackSiz ingDirection, const GridCoordinate&, LayoutBox& gridItem, GridTrack&, Vector<Gri dTrack>& columnTracks);
107 void resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizingDirectio n, GridSizingData&, GridItemWithSpan&, FilterFunction, SizingFunction, Accumulat orGetter, AccumulatorGrowFunction, FilterFunction growAboveMaxBreadthFilterFunct ion = nullptr); 107 void resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizingDirectio n, GridSizingData&, GridItemWithSpan&, FilterFunction, SizingFunction, Accumulat orGetter, AccumulatorGrowFunction, FilterFunction growAboveMaxBreadthFilterFunct ion = nullptr);
108 void distributeSpaceToTracks(Vector<GridTrack*>&, const Vector<GridTrack*>* growBeyondGrowthLimitsTracks, AccumulatorGetter, AccumulatorGrowFunction, GridSi zingData&, LayoutUnit& availableLogicalSpace); 108 void distributeSpaceToTracks(Vector<GridTrack*>&, const Vector<GridTrack*>* growBeyondGrowthLimitsTracks, AccumulatorGetter, AccumulatorGrowFunction, GridSi zingData&, LayoutUnit& availableLogicalSpace);
109 109
110 double computeNormalizedFractionBreadth(Vector<GridTrack>&, const GridSpan& tracksSpan, GridTrackSizingDirection, LayoutUnit availableLogicalSpace) const; 110 double computeNormalizedFractionBreadth(Vector<GridTrack>&, const GridSpan& tracksSpan, GridTrackSizingDirection, LayoutUnit availableLogicalSpace) const;
111 111
112 GridTrackSize gridTrackSize(GridTrackSizingDirection, size_t) const; 112 GridTrackSize gridTrackSize(GridTrackSizingDirection, size_t) const;
113 113
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 return m_grid[0].size(); 155 return m_grid[0].size();
156 } 156 }
157 size_t gridRowCount() const 157 size_t gridRowCount() const
158 { 158 {
159 ASSERT(!gridIsDirty()); 159 ASSERT(!gridIsDirty());
160 return m_grid.size(); 160 return m_grid.size();
161 } 161 }
162 162
163 bool hasDefiniteLogicalSize(GridTrackSizingDirection) const; 163 bool hasDefiniteLogicalSize(GridTrackSizingDirection) const;
164 164
165 typedef Vector<Vector<GridCell> > GridRepresentation; 165 typedef Vector<Vector<GridCell>> GridRepresentation;
166 GridRepresentation m_grid; 166 GridRepresentation m_grid;
167 bool m_gridIsDirty; 167 bool m_gridIsDirty;
168 Vector<LayoutUnit> m_rowPositions; 168 Vector<LayoutUnit> m_rowPositions;
169 Vector<LayoutUnit> m_columnPositions; 169 Vector<LayoutUnit> m_columnPositions;
170 HashMap<const LayoutBox*, GridCoordinate> m_gridItemCoordinate; 170 HashMap<const LayoutBox*, GridCoordinate> m_gridItemCoordinate;
171 OrderIterator m_orderIterator; 171 OrderIterator m_orderIterator;
172 Vector<LayoutBox*> m_gridItemsOverflowingGridArea; 172 Vector<LayoutBox*> m_gridItemsOverflowingGridArea;
173 HashMap<const LayoutBox*, size_t> m_gridItemsIndexesMap; 173 HashMap<const LayoutBox*, size_t> m_gridItemsIndexesMap;
174 }; 174 };
175 175
176 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(RenderGrid, isRenderGrid()); 176 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid());
177 177
178 } // namespace blink 178 } // namespace blink
179 179
180 #endif // RenderGrid_h 180 #endif // LayoutGrid_h
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutBox.cpp ('k') | Source/core/layout/LayoutGrid.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698