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

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

Issue 1407633003: [css-grid] Implementation of Baseline Self-Alignment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improving the skipped tesst by solving some rounding issues Created 3 years, 8 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
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 LayoutGrid_h 26 #ifndef LayoutGrid_h
27 #define LayoutGrid_h 27 #define LayoutGrid_h
28 28
29 #include <memory>
30 #include "core/layout/BaselineAlignment.h"
29 #include "core/layout/Grid.h" 31 #include "core/layout/Grid.h"
30 #include "core/layout/GridTrackSizingAlgorithm.h" 32 #include "core/layout/GridTrackSizingAlgorithm.h"
31 #include "core/layout/LayoutBlock.h" 33 #include "core/layout/LayoutBlock.h"
32 #include "core/layout/OrderIterator.h" 34 #include "core/layout/OrderIterator.h"
33 #include "core/style/GridPositionsResolver.h" 35 #include "core/style/GridPositionsResolver.h"
34 #include <memory>
35 36
36 namespace blink { 37 namespace blink {
37 38
38 struct ContentAlignmentData; 39 struct ContentAlignmentData;
39 struct GridArea; 40 struct GridArea;
40 struct GridSpan; 41 struct GridSpan;
41 42
42 enum GridAxisPosition { GridAxisStart, GridAxisEnd, GridAxisCenter }; 43 enum GridAxisPosition { GridAxisStart, GridAxisEnd, GridAxisCenter };
44 enum GridAxis { GridRowAxis, GridColumnAxis };
43 45
44 class LayoutGrid final : public LayoutBlock { 46 class LayoutGrid final : public LayoutBlock {
45 public: 47 public:
46 explicit LayoutGrid(Element*); 48 explicit LayoutGrid(Element*);
47 ~LayoutGrid() override; 49 ~LayoutGrid() override;
48 50
49 static LayoutGrid* createAnonymous(Document*); 51 static LayoutGrid* createAnonymous(Document*);
50 const char* name() const override { return "LayoutGrid"; } 52 const char* name() const override { return "LayoutGrid"; }
51 53
52 void layoutBlock(bool relayoutChildren) override; 54 void layoutBlock(bool relayoutChildren) override;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 90
89 // TODO(svillar): We need these for the GridTrackSizingAlgorithm. Let's figure 91 // TODO(svillar): We need these for the GridTrackSizingAlgorithm. Let's figure
90 // it out how to remove this dependency. 92 // it out how to remove this dependency.
91 LayoutUnit guttersSize(const Grid&, 93 LayoutUnit guttersSize(const Grid&,
92 GridTrackSizingDirection, 94 GridTrackSizingDirection,
93 size_t startLine, 95 size_t startLine,
94 size_t span, 96 size_t span,
95 SizingOperation) const; 97 SizingOperation) const;
96 bool cachedHasDefiniteLogicalHeight() const; 98 bool cachedHasDefiniteLogicalHeight() const;
97 bool isOrthogonalChild(const LayoutBox&) const; 99 bool isOrthogonalChild(const LayoutBox&) const;
100 bool isBaselineContextComputed(GridAxis) const;
101 bool isBaselineAlignmentForChild(const LayoutBox&,
102 GridAxis = GridColumnAxis) const;
103 const BaselineGroup& getBaselineGroupForChild(const LayoutBox&,
104 GridAxis) const;
98 105
99 protected: 106 protected:
100 ItemPosition selfAlignmentNormalBehavior( 107 ItemPosition selfAlignmentNormalBehavior(
101 const LayoutBox* child = nullptr) const override { 108 const LayoutBox* child = nullptr) const override {
102 DCHECK(child); 109 DCHECK(child);
103 return child->isLayoutReplaced() ? ItemPositionStart : ItemPositionStretch; 110 return child->isLayoutReplaced() ? ItemPositionStart : ItemPositionStretch;
104 } 111 }
105 112
106 private: 113 private:
107 bool isOfType(LayoutObjectType type) const override { 114 bool isOfType(LayoutObjectType type) const override {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 void updateAutoMarginsInColumnAxisIfNeeded(LayoutBox&); 230 void updateAutoMarginsInColumnAxisIfNeeded(LayoutBox&);
224 void updateAutoMarginsInRowAxisIfNeeded(LayoutBox&); 231 void updateAutoMarginsInRowAxisIfNeeded(LayoutBox&);
225 232
226 int baselinePosition( 233 int baselinePosition(
227 FontBaseline, 234 FontBaseline,
228 bool firstLine, 235 bool firstLine,
229 LineDirectionMode, 236 LineDirectionMode,
230 LinePositionMode = PositionOnContainingLine) const override; 237 LinePositionMode = PositionOnContainingLine) const override;
231 int firstLineBoxBaseline() const override; 238 int firstLineBoxBaseline() const override;
232 int inlineBlockBaseline(LineDirectionMode) const override; 239 int inlineBlockBaseline(LineDirectionMode) const override;
233 bool isInlineBaselineAlignedChild(const LayoutBox* child) const; 240
241 bool isHorizontalGridAxis(GridAxis) const;
242 bool isParallelToBlockAxisForChild(const LayoutBox&, GridAxis) const;
243 bool isDescentBaselineForChild(const LayoutBox&, GridAxis) const;
244
245 LayoutUnit marginOverForChild(const LayoutBox&, GridAxis) const;
246 LayoutUnit marginUnderForChild(const LayoutBox&, GridAxis) const;
247 LayoutUnit logicalAscentForChild(const LayoutBox&, GridAxis) const;
248 LayoutUnit ascentForChild(const LayoutBox&, GridAxis) const;
249 LayoutUnit descentForChild(const LayoutBox&,
250 LayoutUnit ascent,
251 GridAxis) const;
252
253 bool baselineMayAffectIntrinsicWidth() const;
254 bool baselineMayAffectIntrinsicHeight() const;
255 void computeBaselineAlignmentContext();
256 void updateBaselineAlignmentContextIfNeeded(LayoutBox&, GridAxis);
257
258 LayoutUnit columnAxisBaselineOffsetForChild(const LayoutBox&) const;
259 LayoutUnit rowAxisBaselineOffsetForChild(const LayoutBox&) const;
234 260
235 LayoutUnit gridGapForDirection(GridTrackSizingDirection, 261 LayoutUnit gridGapForDirection(GridTrackSizingDirection,
236 SizingOperation) const; 262 SizingOperation) const;
237 263
238 size_t gridItemSpan(const LayoutBox&, GridTrackSizingDirection); 264 size_t gridItemSpan(const LayoutBox&, GridTrackSizingDirection);
239 265
240 GridTrackSizingDirection flowAwareDirectionForChild( 266 GridTrackSizingDirection flowAwareDirectionForChild(
241 const LayoutBox&, 267 const LayoutBox&,
242 GridTrackSizingDirection) const; 268 GridTrackSizingDirection) const;
243 269
244 size_t numTracks(GridTrackSizingDirection, const Grid&) const; 270 size_t numTracks(GridTrackSizingDirection, const Grid&) const;
245 271
272 typedef HashMap<unsigned,
273 std::unique_ptr<BaselineContext>,
274 DefaultHash<unsigned>::Hash,
275 WTF::UnsignedWithZeroKeyHashTraits<unsigned>>
276 BaselineContextsMap;
277
278 BaselineContextsMap m_rowAxisAlignmentContext;
279 BaselineContextsMap m_colAxisAlignmentContext;
280
246 Grid m_grid; 281 Grid m_grid;
247 GridTrackSizingAlgorithm m_trackSizingAlgorithm; 282 GridTrackSizingAlgorithm m_trackSizingAlgorithm;
248 283
249 Vector<LayoutUnit> m_rowPositions; 284 Vector<LayoutUnit> m_rowPositions;
250 Vector<LayoutUnit> m_columnPositions; 285 Vector<LayoutUnit> m_columnPositions;
251 LayoutUnit m_offsetBetweenColumns; 286 LayoutUnit m_offsetBetweenColumns;
252 LayoutUnit m_offsetBetweenRows; 287 LayoutUnit m_offsetBetweenRows;
253 Vector<LayoutBox*> m_gridItemsOverflowingGridArea; 288 Vector<LayoutBox*> m_gridItemsOverflowingGridArea;
254 289
255 LayoutUnit m_minContentHeight{-1}; 290 LayoutUnit m_minContentHeight{-1};
256 LayoutUnit m_maxContentHeight{-1}; 291 LayoutUnit m_maxContentHeight{-1};
257 292
258 Optional<bool> m_hasDefiniteLogicalHeight; 293 Optional<bool> m_hasDefiniteLogicalHeight;
259 }; 294 };
260 295
261 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid()); 296 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid());
262 297
263 } // namespace blink 298 } // namespace blink
264 299
265 #endif // LayoutGrid_h 300 #endif // LayoutGrid_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutGrid.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698