diff options
Diffstat (limited to 'Source/WebCore/rendering/style/GridPosition.h')
-rw-r--r-- | Source/WebCore/rendering/style/GridPosition.h | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/Source/WebCore/rendering/style/GridPosition.h b/Source/WebCore/rendering/style/GridPosition.h index 5a276144e..7190c4c6e 100644 --- a/Source/WebCore/rendering/style/GridPosition.h +++ b/Source/WebCore/rendering/style/GridPosition.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2012 Google Inc. All rights reserved. + * Copyright (C) 2013, 2014 Igalia S.L. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -28,13 +29,15 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef GridPosition_h -#define GridPosition_h +#pragma once #include <wtf/text/WTFString.h> namespace WebCore { +// Recommended maximum size for both explicit and implicit grids. +const int kGridMaxTracks = 1000000; + enum GridPositionType { AutoPosition, ExplicitPosition, // [ <integer> || <string> ] @@ -42,6 +45,13 @@ enum GridPositionType { NamedGridAreaPosition // <ident> }; +enum GridPositionSide { + ColumnStartSide, + ColumnEndSide, + RowStartSide, + RowEndSide +}; + class GridPosition { public: GridPosition() @@ -60,17 +70,23 @@ public: void setExplicitPosition(int position, const String& namedGridLine) { m_type = ExplicitPosition; - m_integerPosition = position; + setIntegerPosition(position); m_namedGridLine = namedGridLine; } + void setAutoPosition() + { + m_type = AutoPosition; + m_integerPosition = 0; + } + // 'span' values cannot be negative, yet we reuse the <integer> position which can // be. This means that we have to convert the span position to an integer, losing // some precision here. It shouldn't be an issue in practice though. void setSpanPosition(int position, const String& namedGridLine) { m_type = SpanPosition; - m_integerPosition = position; + setIntegerPosition(position); m_namedGridLine = namedGridLine; } @@ -100,19 +116,23 @@ public: bool operator==(const GridPosition& other) const { - return m_type == other.m_type && m_integerPosition == other.m_integerPosition; + return m_type == other.m_type && m_integerPosition == other.m_integerPosition && m_namedGridLine == other.m_namedGridLine; } bool shouldBeResolvedAgainstOppositePosition() const { return isAuto() || isSpan(); } + private: + void setIntegerPosition(int integerPosition) + { + m_integerPosition = clampTo(integerPosition, -kGridMaxTracks, kGridMaxTracks); + } + GridPositionType m_type; int m_integerPosition; String m_namedGridLine; }; } // namespace WebCore - -#endif // GridPosition_h |