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

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: Get advantage of recomputing the intrinsic size to solve the issues with orthogonal flows. Created 3 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
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 "core/layout/BaselineAlignment.h"
29 #include "core/layout/LayoutBlock.h" 30 #include "core/layout/LayoutBlock.h"
30 #include "core/layout/OrderIterator.h" 31 #include "core/layout/OrderIterator.h"
31 #include "core/style/GridPositionsResolver.h" 32 #include "core/style/GridPositionsResolver.h"
32 #include <memory> 33 #include <memory>
33 34
34 namespace blink { 35 namespace blink {
35 36
36 struct ContentAlignmentData; 37 struct ContentAlignmentData;
37 struct GridArea; 38 struct GridArea;
38 struct GridSpan; 39 struct GridSpan;
39 class GridTrack; 40 class GridTrack;
40 41
41 enum TrackSizeComputationPhase { 42 enum TrackSizeComputationPhase {
42 ResolveIntrinsicMinimums, 43 ResolveIntrinsicMinimums,
43 ResolveContentBasedMinimums, 44 ResolveContentBasedMinimums,
44 ResolveMaxContentMinimums, 45 ResolveMaxContentMinimums,
45 ResolveIntrinsicMaximums, 46 ResolveIntrinsicMaximums,
46 ResolveMaxContentMaximums, 47 ResolveMaxContentMaximums,
47 MaximizeTracks, 48 MaximizeTracks,
48 }; 49 };
49 enum GridAxisPosition { GridAxisStart, GridAxisEnd, GridAxisCenter }; 50 enum GridAxisPosition { GridAxisStart, GridAxisEnd, GridAxisCenter };
51 enum GridAxis { GridRowAxis, GridColumnAxis };
50 52
51 class LayoutGrid final : public LayoutBlock { 53 class LayoutGrid final : public LayoutBlock {
52 public: 54 public:
53 explicit LayoutGrid(Element*); 55 explicit LayoutGrid(Element*);
54 ~LayoutGrid() override; 56 ~LayoutGrid() override;
55 57
56 static LayoutGrid* createAnonymous(Document*); 58 static LayoutGrid* createAnonymous(Document*);
57 const char* name() const override { return "LayoutGrid"; } 59 const char* name() const override { return "LayoutGrid"; }
58 60
59 void layoutBlock(bool relayoutChildren) override; 61 void layoutBlock(bool relayoutChildren) override;
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 void updateAutoMarginsInColumnAxisIfNeeded(LayoutBox&); 313 void updateAutoMarginsInColumnAxisIfNeeded(LayoutBox&);
312 void updateAutoMarginsInRowAxisIfNeeded(LayoutBox&); 314 void updateAutoMarginsInRowAxisIfNeeded(LayoutBox&);
313 315
314 int baselinePosition( 316 int baselinePosition(
315 FontBaseline, 317 FontBaseline,
316 bool firstLine, 318 bool firstLine,
317 LineDirectionMode, 319 LineDirectionMode,
318 LinePositionMode = PositionOnContainingLine) const override; 320 LinePositionMode = PositionOnContainingLine) const override;
319 int firstLineBoxBaseline() const override; 321 int firstLineBoxBaseline() const override;
320 int inlineBlockBaseline(LineDirectionMode) const override; 322 int inlineBlockBaseline(LineDirectionMode) const override;
321 bool isInlineBaselineAlignedChild(const LayoutBox* child) const; 323
324 bool isHorizontalGridAxis(GridAxis) const;
325 bool isParallelToBlockAxisForChild(const LayoutBox&, GridAxis) const;
326 bool isDescentBaselineForChild(const LayoutBox&, GridAxis) const;
327 bool isBaselineAlignmentForChild(const LayoutBox&,
328 GridAxis = GridColumnAxis) const;
329 const BaselineGroup& getBaselineGroupForChild(const LayoutBox&,
330 const GridSizingData&,
331 GridAxis) const;
332
333 LayoutUnit marginOverForChild(const LayoutBox&, GridAxis) const;
334 LayoutUnit logicalAscentForChild(const LayoutBox&, GridAxis) const;
335 LayoutUnit ascentForChild(const LayoutBox&, GridAxis) const;
336 LayoutUnit descentForChild(const LayoutBox&,
337 LayoutUnit ascent,
338 GridAxis) const;
339
340 bool isBaselineContextComputed(GridAxis) const;
341 bool baselineMayAffectIntrinsicWidth() const;
342 bool baselineMayAffectIntrinsicHeight() const;
343 void computeBaselineAlignmentContext(GridSizingData&);
344 void updateBaselineAlignmentContextIfNeeded(LayoutBox&,
345 GridSizingData&,
346 GridAxis);
347
348 LayoutUnit columnAxisBaselineOffsetForChild(const LayoutBox&,
349 const GridSizingData&) const;
350 LayoutUnit rowAxisBaselineOffsetForChild(const LayoutBox&,
351 const GridSizingData&) const;
322 352
323 #if ENABLE(ASSERT) 353 #if ENABLE(ASSERT)
324 bool tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection, 354 bool tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection,
325 GridSizingData&) const; 355 GridSizingData&) const;
326 #endif 356 #endif
327 357
328 LayoutUnit gridGapForDirection(GridTrackSizingDirection, 358 LayoutUnit gridGapForDirection(GridTrackSizingDirection,
329 SizingOperation) const; 359 SizingOperation) const;
330 LayoutUnit guttersSize(const Grid&, 360 LayoutUnit guttersSize(const Grid&,
331 GridTrackSizingDirection, 361 GridTrackSizingDirection,
332 size_t startLine, 362 size_t startLine,
333 size_t span, 363 size_t span,
334 SizingOperation) const; 364 SizingOperation) const;
335 365
336 size_t gridItemSpan(const LayoutBox&, GridTrackSizingDirection); 366 size_t gridItemSpan(const LayoutBox&, GridTrackSizingDirection);
337 bool spanningItemCrossesFlexibleSizedTracks(const GridSpan&, 367 bool spanningItemCrossesFlexibleSizedTracks(const GridSpan&,
338 GridTrackSizingDirection, 368 GridTrackSizingDirection,
339 const GridSizingData&) const; 369 const GridSizingData&) const;
340 370
341 bool isOrthogonalChild(const LayoutBox&) const; 371 bool isOrthogonalChild(const LayoutBox&) const;
342 GridTrackSizingDirection flowAwareDirectionForChild( 372 GridTrackSizingDirection flowAwareDirectionForChild(
343 const LayoutBox&, 373 const LayoutBox&,
344 GridTrackSizingDirection) const; 374 GridTrackSizingDirection) const;
345 375
346 bool cachedHasDefiniteLogicalHeight() const; 376 bool cachedHasDefiniteLogicalHeight() const;
347 377
348 size_t numTracks(GridTrackSizingDirection, const Grid&) const; 378 size_t numTracks(GridTrackSizingDirection, const Grid&) const;
349 379
380 typedef HashMap<unsigned,
381 std::unique_ptr<BaselineContext>,
382 DefaultHash<unsigned>::Hash,
383 WTF::UnsignedWithZeroKeyHashTraits<unsigned>>
384 BaselineContextsMap;
385
386 BaselineContextsMap m_rowAxisAlignmentContext;
387 BaselineContextsMap m_colAxisAlignmentContext;
388
350 // TODO(svillar): move into this class once GridIterator is added. 389 // TODO(svillar): move into this class once GridIterator is added.
351 typedef Vector<Vector<GridCell>> GridAsMatrix; 390 typedef Vector<Vector<GridCell>> GridAsMatrix;
352 class Grid final { 391 class Grid final {
353 public: 392 public:
354 Grid(const LayoutGrid* grid) : m_orderIterator(grid) {} 393 Grid(const LayoutGrid* grid) : m_orderIterator(grid) {}
355 394
356 size_t numTracks(GridTrackSizingDirection) const; 395 size_t numTracks(GridTrackSizingDirection) const;
357 396
358 void ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize); 397 void ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize);
359 void insert(LayoutBox&, const GridArea&); 398 void insert(LayoutBox&, const GridArea&);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 LayoutUnit m_maxContentHeight{-1}; 475 LayoutUnit m_maxContentHeight{-1};
437 476
438 Optional<bool> m_hasDefiniteLogicalHeight; 477 Optional<bool> m_hasDefiniteLogicalHeight;
439 }; 478 };
440 479
441 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid()); 480 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid());
442 481
443 } // namespace blink 482 } // namespace blink
444 483
445 #endif // LayoutGrid_h 484 #endif // LayoutGrid_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698