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

Side by Side Diff: Source/core/rendering/style/GridPosition.h

Issue 13992003: Add support for parsing <grid-line> that includes a 'span' (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed the change to match the specification Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderGrid.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef GridPosition_h 31 #ifndef GridPosition_h
32 #define GridPosition_h 32 #define GridPosition_h
33 33
34 namespace WebCore { 34 namespace WebCore {
35 35
36 enum GridPositionType { 36 enum GridPositionType {
37 AutoPosition, 37 AutoPosition,
38 IntegerPosition 38 IntegerPosition,
39 SpanPosition
39 }; 40 };
40 41
41 class GridPosition { 42 class GridPosition {
42 public: 43 public:
43 GridPosition() 44 GridPosition()
44 : m_type(AutoPosition) 45 : m_type(AutoPosition)
45 , m_integerPosition(0) 46 , m_integerPosition(0)
46 { 47 {
47 } 48 }
48 49
49 bool isPositive() const { return integerPosition() > 0; } 50 bool isPositive() const { return integerPosition() > 0; }
50 51
51 GridPositionType type() const { return m_type; } 52 GridPositionType type() const { return m_type; }
52 bool isAuto() const { return m_type == AutoPosition; } 53 bool isAuto() const { return m_type == AutoPosition; }
54 bool isInteger() const { return m_type == IntegerPosition; }
55 bool isSpan() const { return m_type == SpanPosition; }
53 56
54 void setIntegerPosition(int position) 57 void setIntegerPosition(int position)
55 { 58 {
56 m_type = IntegerPosition; 59 m_type = IntegerPosition;
57 m_integerPosition = position; 60 m_integerPosition = position;
58 } 61 }
59 62
63 // 'span' values cannot be negative, yet we reuse the <integer> position whi ch can
64 // be. This means that we have to convert the span position to an integer, l osing
65 // some precision here. It shouldn't be an issue in practice though.
66 void setSpanPosition(int position)
67 {
68 m_type = SpanPosition;
69 m_integerPosition = position;
70 }
71
60 int integerPosition() const 72 int integerPosition() const
61 { 73 {
62 ASSERT(type() == IntegerPosition); 74 ASSERT(type() == IntegerPosition);
63 return m_integerPosition; 75 return m_integerPosition;
64 } 76 }
65 77
78 int spanPosition() const
79 {
80 ASSERT(type() == SpanPosition);
81 return m_integerPosition;
82 }
83
66 bool operator==(const GridPosition& other) const 84 bool operator==(const GridPosition& other) const
67 { 85 {
68 return m_type == other.m_type && m_integerPosition == other.m_integerPos ition; 86 return m_type == other.m_type && m_integerPosition == other.m_integerPos ition;
69 } 87 }
70 88
71 private: 89 private:
72 GridPositionType m_type; 90 GridPositionType m_type;
73 int m_integerPosition; 91 int m_integerPosition;
74 }; 92 };
75 93
76 } // namespace WebCore 94 } // namespace WebCore
77 95
78 #endif // GridPosition_h 96 #endif // GridPosition_h
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderGrid.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698