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

Side by Side Diff: third_party/WebKit/Source/core/layout/BaselineAlignment.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
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BaselineAlignment_h
6 #define BaselineAlignment_h
7
8 #include "core/layout/LayoutBox.h"
9
10 namespace blink {
11
12 // These classes are used to implement the Baseline Alignment logica, as
13 // described in the CSS Box Alignment specification.
14 // https://drafts.csswg.org/css-align/#baseline-terms
15
16 // A baseline-sharing group is composed of boxes that participate in
17 // baseline alignment together. This is possible only if they:
18 //
19 // * Share an alignment context along an axis perpendicular to their
20 // baseline alignment axis.
21 // * Have compatible baseline alignment preferences (i.e., the baselines
22 // that want to align are on the same side of the alignment context).
23 class BaselineGroup {
24 public:
25 void update(const LayoutBox&, LayoutUnit ascent, LayoutUnit descent);
26 LayoutUnit maxAscent() const { return m_maxAscent; }
27 LayoutUnit maxDescent() const { return m_maxDescent; }
28 int size() const { return m_items.size(); }
29
30 private:
31 friend class BaselineContext;
32 BaselineGroup(WritingMode blockFlow, ItemPosition childPreference);
33 bool isCompatible(WritingMode, ItemPosition) const;
34 bool isOppositeBlockFlow(WritingMode blockFlow) const;
35 bool isOrthogonalBlockFlow(WritingMode blockFlow) const;
36
37 WritingMode m_blockFlow;
38 ItemPosition m_preference;
39 LayoutUnit m_maxAscent;
40 LayoutUnit m_maxDescent;
41 HashSet<const LayoutBox*> m_items;
42 };
43
44 // Boxes share an alignment context along a particular axis when they
45 // are:
46 //
47 // * table cells in the same row, along the table's row (inline) axis
48 // * table cells in the same column, along the table's column (block)
49 // axis
50 // * grid items in the same row, along the grid's row (inline) axis
51 // * grid items in the same column, along the grid's colum (block) axis
52 // * flex items in the same flex line, along the flex container's main
53 // axis
54 class BaselineContext {
55 public:
56 BaselineContext(const LayoutBox& child,
57 ItemPosition preference,
58 LayoutUnit ascent,
59 LayoutUnit descent);
60 Vector<BaselineGroup>& sharedGroups() { return m_sharedGroups; }
61 const BaselineGroup& getSharedGroup(const LayoutBox& child,
62 ItemPosition preference) const;
63 void updateSharedGroup(const LayoutBox& child,
64 ItemPosition preference,
65 LayoutUnit ascent,
66 LayoutUnit descent);
67
68 private:
69 // TODO Properly implement baseline-group compatibility
70 // See https://github.com/w3c/csswg-drafts/issues/721
71 BaselineGroup& findCompatibleSharedGroup(const LayoutBox& child,
72 ItemPosition preference);
73
74 Vector<BaselineGroup> m_sharedGroups;
75 };
76
77 static inline bool isBaselinePosition(ItemPosition position) {
78 return position == ItemPositionBaseline ||
79 position == ItemPositionLastBaseline;
80 }
81
82 } // namespace blink
83
84 #endif // BaselineContext_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/BUILD.gn ('k') | third_party/WebKit/Source/core/layout/BaselineAlignment.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698