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

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

Issue 1529083006: [css-grid] Initial support for implicit grid before explicit grid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply suggested changes Created 5 years 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
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..fb1727ee2bbc6ca89fce8e578b06005e282173b3 100644
--- a/third_party/WebKit/Source/core/style/GridCoordinate.h
+++ b/third_party/WebKit/Source/core/style/GridCoordinate.h
@@ -41,7 +41,7 @@
namespace blink {
// Recommended maximum size for both explicit and implicit grids.
-const size_t kGridMaxTracks = 1000000;
+const int kGridMaxTracks = 1000000;
// A span in a single direction (either rows or columns). Note that |resolvedInitialPosition|
// and |resolvedFinalPosition| are grid lines' indexes.
@@ -50,9 +50,14 @@ struct GridSpan {
USING_FAST_MALLOC(GridSpan);
public:
- static GridSpan definiteGridSpan(size_t resolvedInitialPosition, size_t resolvedFinalPosition)
+ static GridSpan untranslatedDefiniteGridSpan(int resolvedInitialPosition, int resolvedFinalPosition)
{
- return GridSpan(resolvedInitialPosition, resolvedFinalPosition, Definite);
+ return GridSpan(resolvedInitialPosition, resolvedFinalPosition, UntranslatedDefinite);
+ }
+
+ static GridSpan translatedDefiniteGridSpan(size_t resolvedInitialPosition, size_t resolvedFinalPosition)
+ {
+ return GridSpan(resolvedInitialPosition, resolvedFinalPosition, TranslatedDefinite);
}
svillar 2016/01/04 09:10:06 I don't think we need these. Why don't we make the
Manuel Rego 2016/01/04 10:00:11 The main reason to have these static methods (whic
static GridSpan indefiniteGridSpan()
@@ -67,21 +72,34 @@ public:
size_t integerSpan() const
{
- ASSERT(isDefinite());
+ ASSERT(isTranslatedDefinite());
ASSERT(m_resolvedFinalPosition > m_resolvedInitialPosition);
return m_resolvedFinalPosition - m_resolvedInitialPosition;
}
+ int untranslatedResolvedInitialPosition() const
+ {
+ ASSERT(m_type == UntranslatedDefinite);
+ return m_resolvedInitialPosition;
+ }
+
+ int untranslatedResolvedFinalPosition() const
+ {
+ ASSERT(m_type == UntranslatedDefinite);
+ return m_resolvedFinalPosition;
+ }
+
size_t resolvedInitialPosition() const
{
- ASSERT(isDefinite());
+ ASSERT(isTranslatedDefinite());
+ ASSERT(m_resolvedInitialPosition >= 0);
return m_resolvedInitialPosition;
}
size_t resolvedFinalPosition() const
{
- ASSERT(isDefinite());
- ASSERT(m_resolvedFinalPosition);
+ ASSERT(isTranslatedDefinite());
+ ASSERT(m_resolvedFinalPosition > 0);
return m_resolvedFinalPosition;
}
@@ -97,35 +115,66 @@ public:
GridSpanIterator begin() const
{
- ASSERT(isDefinite());
+ ASSERT(isTranslatedDefinite());
return m_resolvedInitialPosition;
}
GridSpanIterator end() const
{
- ASSERT(isDefinite());
+ ASSERT(isTranslatedDefinite());
return m_resolvedFinalPosition;
}
- bool isDefinite() const
+ bool isTranslatedDefinite() const
{
- return m_type == Definite;
+ return m_type == TranslatedDefinite;
+ }
+
+ bool isIndefinite() const
+ {
+ return m_type == Indefinite;
+ }
+
+ void translate(size_t offset)
+ {
+ ASSERT(m_type == UntranslatedDefinite);
+
+ m_type = TranslatedDefinite;
+ m_resolvedInitialPosition += offset;
+ m_resolvedFinalPosition += offset;
+
+ ASSERT(m_resolvedInitialPosition >= 0);
+ ASSERT(m_resolvedFinalPosition > 0);
}
private:
- enum GridSpanType {Definite, Indefinite};
+ enum GridSpanType {UntranslatedDefinite, TranslatedDefinite, 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 == TranslatedDefinite) {
+ ASSERT(resolvedInitialPosition >= 0);
+ ASSERT(resolvedFinalPosition > 0);
+ }
+#endif
+
+ if (resolvedInitialPosition >= 0)
+ m_resolvedInitialPosition = std::min(resolvedInitialPosition, kGridMaxTracks - 1);
+ else
+ m_resolvedInitialPosition = std::max(resolvedInitialPosition, -kGridMaxTracks);
+
+ if (resolvedFinalPosition >= 0)
+ m_resolvedFinalPosition = std::min(resolvedFinalPosition, kGridMaxTracks);
+ else
+ m_resolvedFinalPosition = std::max(resolvedFinalPosition, -kGridMaxTracks + 1);
}
- size_t m_resolvedInitialPosition;
- size_t m_resolvedFinalPosition;
+ int m_resolvedInitialPosition;
+ int m_resolvedFinalPosition;
GridSpanType m_type;
};
« no previous file with comments | « third_party/WebKit/Source/core/paint/GridPainter.cpp ('k') | third_party/WebKit/Source/core/style/GridResolvedPosition.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698