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

Unified Diff: third_party/WebKit/Source/core/style/GridTrackSize.h

Issue 2287113004: [css-grid] Implement fit-content track size (Closed)
Patch Set: Patch for landing Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutGrid.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/style/GridTrackSize.h
diff --git a/third_party/WebKit/Source/core/style/GridTrackSize.h b/third_party/WebKit/Source/core/style/GridTrackSize.h
index 9cd614951b61226eb012bae0ef1d4122ff171239..5005aed0e7a8d64b1898cb762a054263930537af 100644
--- a/third_party/WebKit/Source/core/style/GridTrackSize.h
+++ b/third_party/WebKit/Source/core/style/GridTrackSize.h
@@ -38,19 +38,25 @@ namespace blink {
enum GridTrackSizeType {
LengthTrackSizing,
- MinMaxTrackSizing
+ MinMaxTrackSizing,
+ FitContentTrackSizing
};
+// This class represents a <track-size> from the spec. Althought there are 3 different types of
+// <track-size> there is always an equivalent minmax() representation that could represent any of
+// them. The only special case is fit-content(argument) which is similar to minmax(auto, max-content)
+// except that the track size is clamped at argument if it is greater than the auto minimum. At the
+// GridTrackSize level we don't need to worry about clamping so we treat that case exactly as
+// minmax(auto, max-content) althought we store the argument for later use in m_maxTrackBreadth.
class GridTrackSize {
DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
public:
- GridTrackSize(const GridLength& length)
- : m_type(LengthTrackSizing)
- , m_minTrackBreadth(length)
+ GridTrackSize(const GridLength& length, GridTrackSizeType trackSizeType = LengthTrackSizing)
+ : m_type(trackSizeType)
+ , m_minTrackBreadth(trackSizeType == FitContentTrackSizing ? Length(Auto) : length)
, m_maxTrackBreadth(length)
- , m_minTrackBreadthIsMaxContent(false)
- , m_maxTrackBreadthIsMaxContent(false)
{
+ DCHECK(trackSizeType == LengthTrackSizing || trackSizeType == FitContentTrackSizing);
cacheMinMaxTrackBreadthTypes();
}
@@ -58,27 +64,24 @@ public:
: m_type(MinMaxTrackSizing)
, m_minTrackBreadth(minTrackBreadth)
, m_maxTrackBreadth(maxTrackBreadth)
- , m_minTrackBreadthIsMaxContent(false)
- , m_maxTrackBreadthIsMaxContent(false)
{
cacheMinMaxTrackBreadthTypes();
}
- const GridLength& length() const
+ GridLength length() const
{
- ASSERT(m_type == LengthTrackSizing);
- ASSERT(m_minTrackBreadth == m_maxTrackBreadth);
- const GridLength& minTrackBreadth = m_minTrackBreadth;
- return minTrackBreadth;
+ DCHECK(m_type == LengthTrackSizing || m_type == FitContentTrackSizing);
+ DCHECK(m_minTrackBreadth == m_maxTrackBreadth || m_type == FitContentTrackSizing);
+ return m_maxTrackBreadth;
}
- const GridLength& minTrackBreadth() const { return m_minTrackBreadth; }
-
- const GridLength& maxTrackBreadth() const { return m_maxTrackBreadth; }
+ GridLength minTrackBreadth() const { return m_minTrackBreadth; }
+ GridLength maxTrackBreadth() const { return isFitContent() ? GridLength(Length(MaxContent)) : m_maxTrackBreadth; }
GridTrackSizeType type() const { return m_type; }
bool isContentSized() const { return m_minTrackBreadth.isContentSized() || m_maxTrackBreadth.isContentSized(); }
+ bool isFitContent() const { return m_type == FitContentTrackSizing; }
bool operator==(const GridTrackSize& other) const
{
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutGrid.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698