Chromium Code Reviews| Index: third_party/WebKit/Source/core/style/GridCoordinate.h |
| diff --git a/third_party/WebKit/Source/core/style/GridCoordinate.h b/third_party/WebKit/Source/core/style/GridCoordinate.h |
| index bd1592f545e972c8a90b04c2ccdb6dff4efb3f72..ad9514db219500ea09a0e55f6a6eb5c3063303d6 100644 |
| --- a/third_party/WebKit/Source/core/style/GridCoordinate.h |
| +++ b/third_party/WebKit/Source/core/style/GridCoordinate.h |
| @@ -50,6 +50,11 @@ struct GridSpan { |
| USING_FAST_MALLOC(GridSpan); |
| public: |
| + static GridSpan untranslatedGridSpan(int resolvedInitialPosition, int resolvedFinalPosition) |
|
jfernandez
2015/12/18 14:33:21
I find the 'unstranslated" concept a bit obscure.
Manuel Rego
2015/12/18 22:42:30
Untranslated is only used during the code to resol
|
| + { |
| + return GridSpan(resolvedInitialPosition, resolvedFinalPosition, Untranslated); |
| + } |
| + |
| static GridSpan definiteGridSpan(size_t resolvedInitialPosition, size_t resolvedFinalPosition) |
| { |
| return GridSpan(resolvedInitialPosition, resolvedFinalPosition, Definite); |
| @@ -72,16 +77,29 @@ public: |
| return m_resolvedFinalPosition - m_resolvedInitialPosition; |
| } |
| + int untranslatedResolvedInitialPosition() const |
| + { |
| + ASSERT(m_type == Untranslated); |
| + return m_resolvedInitialPosition; |
| + } |
| + |
| + int untranslatedResolvedFinalPosition() const |
| + { |
| + ASSERT(m_type == Untranslated); |
| + return m_resolvedFinalPosition; |
| + } |
| + |
| size_t resolvedInitialPosition() const |
| { |
| ASSERT(isDefinite()); |
| + ASSERT(m_resolvedInitialPosition >= 0); |
| return m_resolvedInitialPosition; |
| } |
| size_t resolvedFinalPosition() const |
| { |
| ASSERT(isDefinite()); |
| - ASSERT(m_resolvedFinalPosition); |
| + ASSERT(m_resolvedFinalPosition > 0); |
| return m_resolvedFinalPosition; |
| } |
| @@ -112,20 +130,51 @@ public: |
| return m_type == Definite; |
| } |
| + bool isIndefinite() const |
| + { |
| + return m_type == Indefinite; |
| + } |
|
svillar
2015/12/18 13:08:30
I don't like this API because is super-confusing.
Manuel Rego
2015/12/18 22:42:30
I agree this is confusing.
So I've changed the po
|
| + |
| + void translate(size_t offset) |
| + { |
| + ASSERT(m_type == Untranslated); |
| + |
| + m_type = Definite; |
| + m_resolvedInitialPosition += offset; |
| + m_resolvedFinalPosition += offset; |
| + |
|
svillar
2015/12/18 13:08:30
Looks like it's missing the kGridMaxTrack checks?
Manuel Rego
2015/12/18 22:42:30
I don't think we need them here.
We've already the
|
| + ASSERT(m_resolvedInitialPosition >= 0); |
| + ASSERT(m_resolvedFinalPosition > 0); |
|
jfernandez
2015/12/18 14:33:21
I don't get the purpose of these asserts. If 'offs
Manuel Rego
2015/12/18 22:42:30
I think you're missing the fact that m_resolvedIni
|
| + } |
| + |
| private: |
| - enum GridSpanType {Definite, Indefinite}; |
| + enum GridSpanType {Untranslated, Definite, Indefinite}; |
| - GridSpan(size_t resolvedInitialPosition, size_t resolvedFinalPosition, GridSpanType type) |
| - : m_resolvedInitialPosition(std::min(resolvedInitialPosition, kGridMaxTracks - 1)) |
| - , m_resolvedFinalPosition(std::min(resolvedFinalPosition, kGridMaxTracks)) |
| - , m_type(type) |
| + GridSpan(int resolvedInitialPosition, int resolvedFinalPosition, GridSpanType type) |
| + : m_type(type) |
| { |
| +#if ENABLE(ASSERT) |
| ASSERT(resolvedInitialPosition < resolvedFinalPosition); |
| + if (type == Definite) { |
| + ASSERT(resolvedInitialPosition >= 0); |
| + ASSERT(resolvedFinalPosition > 0); |
| + } |
| +#endif |
| + |
| + if (resolvedInitialPosition >= 0) |
| + m_resolvedInitialPosition = std::min(resolvedInitialPosition, static_cast<int>(kGridMaxTracks) - 1); |
|
svillar
2015/12/18 13:08:30
Just convert kGridMaxTracks to int and remove the
jfernandez
2015/12/18 14:33:21
I think many other casts have been added because o
Manuel Rego
2015/12/18 22:42:30
Done.
Manuel Rego
2015/12/18 22:42:30
I've converted it to int so I think we don't have
|
| + else |
| + m_resolvedInitialPosition = std::max(resolvedInitialPosition, -static_cast<int>(kGridMaxTracks)); |
| + |
| + if (resolvedFinalPosition >= 0) |
| + m_resolvedFinalPosition = std::min(resolvedFinalPosition, static_cast<int>(kGridMaxTracks)); |
| + else |
| + m_resolvedFinalPosition = std::max(resolvedFinalPosition, -static_cast<int>(kGridMaxTracks) + 1); |
| } |
| - size_t m_resolvedInitialPosition; |
| - size_t m_resolvedFinalPosition; |
| + int m_resolvedInitialPosition; |
| + int m_resolvedFinalPosition; |
| GridSpanType m_type; |
| }; |