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

Unified Diff: Source/core/rendering/style/GridResolvedPosition.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: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/style/GridPosition.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/style/GridResolvedPosition.h
diff --git a/Source/core/rendering/style/GridResolvedPosition.h b/Source/core/rendering/style/GridResolvedPosition.h
new file mode 100644
index 0000000000000000000000000000000000000000..c70cb73ccef795adc3fa2fd9eb5fe4c69782036e
--- /dev/null
+++ b/Source/core/rendering/style/GridResolvedPosition.h
@@ -0,0 +1,71 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GridResolvedPosition_h
+#define GridResolvedPosition_h
+
+#include "core/rendering/style/GridPosition.h"
+
+namespace WebCore {
+
+enum GridPositionSide {
+ ColumnStartSide,
+ ColumnEndSide,
+ RowStartSide,
+ RowEndSide
+};
+
+class GridResolvedPosition {
+public:
+ static size_t adjustGridPositionForAfterEndSide(size_t resolvedPosition)
+ {
+ return resolvedPosition ? resolvedPosition - 1 : 0;
+ }
+
+ static size_t adjustGridPositionForSide(size_t resolvedPosition, GridPositionSide side)
+ {
+ // An item finishing on the N-th line belongs to the N-1-th cell.
+ if (side == ColumnEndSide || side == RowEndSide)
+ return adjustGridPositionForAfterEndSide(resolvedPosition);
+
+ return resolvedPosition;
+ }
+
+ GridResolvedPosition()
+ : m_integerPosition(0)
+ {
+ }
Julien - ping for review 2014/03/06 22:38:02 IMHO we should just not have this constructor and
+
+ GridResolvedPosition(size_t position)
+ : m_integerPosition(position)
+ {
+ }
+
+ GridResolvedPosition(const GridPosition& position, GridPositionSide side)
+ {
+ size_t integerPosition;
+
+ ASSERT(position.integerPosition());
+ integerPosition = position.integerPosition() - 1;
+
+ m_integerPosition = adjustGridPositionForSide(integerPosition, side);
+ }
+
+ size_t integerPosition() const
Julien - ping for review 2014/03/06 22:38:02 Do we need the explicit "integer" in the getter/se
+ {
+ return m_integerPosition;
+ }
+
+ void setIntegerPosition(size_t position)
+ {
+ m_integerPosition = position;
+ }
+
Julien - ping for review 2014/03/06 22:38:02 The current API makes the code very verbose as we
+private:
+ size_t m_integerPosition;
+};
+
+} // namespace WebCore
+
+#endif // GridResolvedPosition_h
« no previous file with comments | « Source/core/rendering/style/GridPosition.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698