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

Side by Side Diff: Source/core/rendering/style/GridPosition.h

Issue 166623002: [CSS Grid Layout] Introduce an explicit type for resolved grid positions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix compilation issue Created 6 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 24 matching lines...) Expand all
35 35
36 namespace WebCore { 36 namespace WebCore {
37 37
38 enum GridPositionType { 38 enum GridPositionType {
39 AutoPosition, 39 AutoPosition,
40 ExplicitPosition, // [ <integer> || <string> ] 40 ExplicitPosition, // [ <integer> || <string> ]
41 SpanPosition, // span && [ <integer> || <string> ] 41 SpanPosition, // span && [ <integer> || <string> ]
42 NamedGridAreaPosition // <ident> 42 NamedGridAreaPosition // <ident>
43 }; 43 };
44 44
45 enum GridPositionSide {
46 ColumnStartSide,
47 ColumnEndSide,
48 RowStartSide,
49 RowEndSide
50 };
51
52 class GridPosition { 45 class GridPosition {
53 public: 46 public:
54 GridPosition() 47 GridPosition()
55 : m_type(AutoPosition) 48 : m_type(AutoPosition)
56 , m_integerPosition(0) 49 , m_integerPosition(0)
57 { 50 {
58 } 51 }
59 52
60 static size_t adjustGridPositionForAfterEndSide(size_t resolvedPosition)
61 {
62 return resolvedPosition ? resolvedPosition - 1 : 0;
63 }
64
65 static size_t adjustGridPositionForSide(size_t resolvedPosition, GridPositio nSide side)
66 {
67 // An item finishing on the N-th line belongs to the N-1-th cell.
68 if (side == ColumnEndSide || side == RowEndSide)
69 return adjustGridPositionForAfterEndSide(resolvedPosition);
70
71 return resolvedPosition;
72 }
73
74 bool isPositive() const { return integerPosition() > 0; } 53 bool isPositive() const { return integerPosition() > 0; }
75 54
76 GridPositionType type() const { return m_type; } 55 GridPositionType type() const { return m_type; }
77 bool isAuto() const { return m_type == AutoPosition; } 56 bool isAuto() const { return m_type == AutoPosition; }
78 bool isSpan() const { return m_type == SpanPosition; } 57 bool isSpan() const { return m_type == SpanPosition; }
79 bool isNamedGridArea() const { return m_type == NamedGridAreaPosition; } 58 bool isNamedGridArea() const { return m_type == NamedGridAreaPosition; }
80 59
81 void setExplicitPosition(int position, const String& namedGridLine) 60 void setExplicitPosition(int position, const String& namedGridLine)
82 { 61 {
83 m_type = ExplicitPosition; 62 m_type = ExplicitPosition;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 115 }
137 private: 116 private:
138 GridPositionType m_type; 117 GridPositionType m_type;
139 int m_integerPosition; 118 int m_integerPosition;
140 String m_namedGridLine; 119 String m_namedGridLine;
141 }; 120 };
142 121
143 } // namespace WebCore 122 } // namespace WebCore
144 123
145 #endif // GridPosition_h 124 #endif // GridPosition_h
OLDNEW
« no previous file with comments | « Source/core/rendering/style/GridCoordinate.h ('k') | Source/core/rendering/style/GridResolvedPosition.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698