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 |