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

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

Issue 144373002: [CSS Shapes] Basic shapes' computed position should be a horizontal and vertical offset (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add FAIL test for intermediate result Created 6 years, 9 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
« no previous file with comments | « Source/core/css/BasicShapeFunctions.cpp ('k') | Source/core/rendering/style/BasicShapes.cpp » ('j') | 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 Adobe Systems Incorporated. All rights reserved. 2 * Copyright (C) 2012 Adobe Systems Incorporated. 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above 8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following 9 * copyright notice, this list of conditions and the following
10 * disclaimer. 10 * disclaimer.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 Length m_width; 122 Length m_width;
123 Length m_height; 123 Length m_height;
124 Length m_cornerRadiusX; 124 Length m_cornerRadiusX;
125 Length m_cornerRadiusY; 125 Length m_cornerRadiusY;
126 }; 126 };
127 127
128 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeRectangle); 128 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeRectangle);
129 129
130 class BasicShapeCenterCoordinate { 130 class BasicShapeCenterCoordinate {
131 public: 131 public:
132 enum Keyword { 132 enum Direction {
133 None, 133 TopLeft,
134 Top, 134 BottomRight
135 Right,
136 Bottom,
137 Left
138 }; 135 };
139 BasicShapeCenterCoordinate() : m_keyword(None), m_length(Undefined) { } 136 BasicShapeCenterCoordinate()
140 explicit BasicShapeCenterCoordinate(Length length) : m_keyword(None), m_leng th(length) { } 137 : m_direction(TopLeft)
141 BasicShapeCenterCoordinate(Keyword keyword, Length length) : m_keyword(keywo rd), m_length(length) { } 138 , m_length(Undefined)
142 BasicShapeCenterCoordinate(const BasicShapeCenterCoordinate& other) : m_keyw ord(other.keyword()), m_length(other.length()) { } 139 {
143 bool operator==(const BasicShapeCenterCoordinate& other) const { return m_ke yword == other.m_keyword && m_length == other.m_length; } 140 updateComputedLength();
141 }
144 142
145 Keyword keyword() const { return m_keyword; } 143 BasicShapeCenterCoordinate(Direction direction, Length length)
144 : m_direction(direction)
145 , m_length(length)
146 {
147 updateComputedLength();
148 }
149
150 BasicShapeCenterCoordinate(const BasicShapeCenterCoordinate& other)
151 : m_direction(other.direction())
152 , m_length(other.length())
153 , m_computedLength(other.m_computedLength)
154 {
155 }
156
157 bool operator==(const BasicShapeCenterCoordinate& other) const { return m_di rection == other.m_direction && m_length == other.m_length && m_computedLength = = other.m_computedLength; }
158
159 Direction direction() const { return m_direction; }
146 const Length& length() const { return m_length; } 160 const Length& length() const { return m_length; }
147 161 const Length& computedLength() const { return m_computedLength; }
148 bool canBlend(const BasicShapeCenterCoordinate& other) const
149 {
150 // FIXME determine how to interpolate between keywords. See issue 330248 .
151 return m_keyword == None && other.keyword() == None;
152 }
153 162
154 BasicShapeCenterCoordinate blend(const BasicShapeCenterCoordinate& other, do uble progress) const 163 BasicShapeCenterCoordinate blend(const BasicShapeCenterCoordinate& other, do uble progress) const
155 { 164 {
156 if (m_keyword != None || other.keyword() != None) 165 return BasicShapeCenterCoordinate(TopLeft, m_computedLength.blend(other. m_computedLength, progress, ValueRangeAll));
157 return BasicShapeCenterCoordinate(other);
158
159 return BasicShapeCenterCoordinate(m_length.blend(other.length(), progres s, ValueRangeAll));
160 } 166 }
161 167
162 private: 168 private:
163 Keyword m_keyword; 169 Direction m_direction;
164 Length m_length; 170 Length m_length;
171 Length m_computedLength;
172
173 void updateComputedLength();
165 }; 174 };
166 175
167 class BasicShapeRadius { 176 class BasicShapeRadius {
168 public: 177 public:
169 enum Type { 178 enum Type {
170 Value, 179 Value,
171 ClosestSide, 180 ClosestSide,
172 FarthestSide 181 FarthestSide
173 }; 182 };
174 BasicShapeRadius() : m_value(Undefined), m_type(ClosestSide) { } 183 BasicShapeRadius() : m_value(Undefined), m_type(ClosestSide) { }
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 LengthSize m_topLeftRadius; 436 LengthSize m_topLeftRadius;
428 LengthSize m_topRightRadius; 437 LengthSize m_topRightRadius;
429 LengthSize m_bottomRightRadius; 438 LengthSize m_bottomRightRadius;
430 LengthSize m_bottomLeftRadius; 439 LengthSize m_bottomLeftRadius;
431 }; 440 };
432 441
433 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeInset); 442 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeInset);
434 443
435 } 444 }
436 #endif 445 #endif
OLDNEW
« no previous file with comments | « Source/core/css/BasicShapeFunctions.cpp ('k') | Source/core/rendering/style/BasicShapes.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698