OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 3 Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
4 Copyright (C) 2011 Rik Cabanier (cabanier@adobe.com) | 4 Copyright (C) 2011 Rik Cabanier (cabanier@adobe.com) |
5 Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. | 5 Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. |
6 | 6 |
7 This library is free software; you can redistribute it and/or | 7 This library is free software; you can redistribute it and/or |
8 modify it under the terms of the GNU Library General Public | 8 modify it under the terms of the GNU Library General Public |
9 License as published by the Free Software Foundation; either | 9 License as published by the Free Software Foundation; either |
10 version 2 of the License, or (at your option) any later version. | 10 version 2 of the License, or (at your option) any later version. |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "wtf/Vector.h" | 33 #include "wtf/Vector.h" |
34 #include <cstring> | 34 #include <cstring> |
35 | 35 |
36 namespace WebCore { | 36 namespace WebCore { |
37 | 37 |
38 enum LengthType { | 38 enum LengthType { |
39 Auto, Percent, Fixed, | 39 Auto, Percent, Fixed, |
40 Intrinsic, MinIntrinsic, | 40 Intrinsic, MinIntrinsic, |
41 MinContent, MaxContent, FillAvailable, FitContent, | 41 MinContent, MaxContent, FillAvailable, FitContent, |
42 Calculated, | 42 Calculated, |
43 ViewportPercentageWidth, ViewportPercentageHeight, ViewportPercentageMin, Vi
ewportPercentageMax, | |
44 ExtendToZoom, | 43 ExtendToZoom, |
45 Undefined | 44 Undefined |
46 }; | 45 }; |
47 | 46 |
48 enum ValueRange { | 47 enum ValueRange { |
49 ValueRangeAll, | 48 ValueRangeAll, |
50 ValueRangeNonNegative | 49 ValueRangeNonNegative |
51 }; | 50 }; |
52 | 51 |
53 class CalculationValue; | 52 class CalculationValue; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 221 |
223 return getFloatValue() < 0; | 222 return getFloatValue() < 0; |
224 } | 223 } |
225 | 224 |
226 bool isAuto() const { return type() == Auto; } | 225 bool isAuto() const { return type() == Auto; } |
227 bool isPercent() const { return type() == Percent || type() == Calculated; } | 226 bool isPercent() const { return type() == Percent || type() == Calculated; } |
228 bool isFixed() const { return type() == Fixed; } | 227 bool isFixed() const { return type() == Fixed; } |
229 bool isIntrinsicOrAuto() const { return type() == Auto || isLegacyIntrinsic(
) || isIntrinsic(); } | 228 bool isIntrinsicOrAuto() const { return type() == Auto || isLegacyIntrinsic(
) || isIntrinsic(); } |
230 bool isLegacyIntrinsic() const { return type() == Intrinsic || type() == Min
Intrinsic; } | 229 bool isLegacyIntrinsic() const { return type() == Intrinsic || type() == Min
Intrinsic; } |
231 bool isIntrinsic() const { return type() == MinContent || type() == MaxConte
nt || type() == FillAvailable || type() == FitContent; } | 230 bool isIntrinsic() const { return type() == MinContent || type() == MaxConte
nt || type() == FillAvailable || type() == FitContent; } |
232 bool isSpecified() const { return type() == Fixed || type() == Percent || ty
pe() == Calculated || isViewportPercentage(); } | 231 bool isSpecified() const { return type() == Fixed || type() == Percent || ty
pe() == Calculated; } |
233 bool isSpecifiedOrIntrinsic() const { return isSpecified() || isIntrinsic();
} | 232 bool isSpecifiedOrIntrinsic() const { return isSpecified() || isIntrinsic();
} |
234 bool isCalculated() const { return type() == Calculated; } | 233 bool isCalculated() const { return type() == Calculated; } |
235 bool isCalculatedEqual(const Length&) const; | 234 bool isCalculatedEqual(const Length&) const; |
236 bool isMinContent() const { return type() == MinContent; } | 235 bool isMinContent() const { return type() == MinContent; } |
237 bool isMaxContent() const { return type() == MaxContent; } | 236 bool isMaxContent() const { return type() == MaxContent; } |
238 bool isFillAvailable() const { return type() == FillAvailable; } | 237 bool isFillAvailable() const { return type() == FillAvailable; } |
239 bool isFitContent() const { return type() == FitContent; } | 238 bool isFitContent() const { return type() == FitContent; } |
240 | 239 |
241 Length blend(const Length& from, double progress, ValueRange range) const | 240 Length blend(const Length& from, double progress, ValueRange range) const |
242 { | 241 { |
(...skipping 27 matching lines...) Expand all Loading... |
270 return Length(blendedValue, resultType); | 269 return Length(blendedValue, resultType); |
271 } | 270 } |
272 | 271 |
273 float getFloatValue() const | 272 float getFloatValue() const |
274 { | 273 { |
275 ASSERT(!isUndefined()); | 274 ASSERT(!isUndefined()); |
276 return m_isFloat ? m_floatValue : m_intValue; | 275 return m_isFloat ? m_floatValue : m_intValue; |
277 } | 276 } |
278 float nonNanCalculatedValue(int maxValue) const; | 277 float nonNanCalculatedValue(int maxValue) const; |
279 | 278 |
280 bool isViewportPercentage() const | |
281 { | |
282 LengthType lengthType = type(); | |
283 return lengthType >= ViewportPercentageWidth && lengthType <= ViewportPe
rcentageMax; | |
284 } | |
285 float viewportPercentageLength() const | |
286 { | |
287 ASSERT(isViewportPercentage()); | |
288 return getFloatValue(); | |
289 } | |
290 private: | 279 private: |
291 int getIntValue() const | 280 int getIntValue() const |
292 { | 281 { |
293 ASSERT(!isUndefined()); | 282 ASSERT(!isUndefined()); |
294 return m_isFloat ? static_cast<int>(m_floatValue) : m_intValue; | 283 return m_isFloat ? static_cast<int>(m_floatValue) : m_intValue; |
295 } | 284 } |
296 void initFromLength(const Length& length) | 285 void initFromLength(const Length& length) |
297 { | 286 { |
298 memcpy(this, &length, sizeof(Length)); | 287 memcpy(this, &length, sizeof(Length)); |
299 | 288 |
(...skipping 18 matching lines...) Expand all Loading... |
318 bool m_quirk; | 307 bool m_quirk; |
319 unsigned char m_type; | 308 unsigned char m_type; |
320 bool m_isFloat; | 309 bool m_isFloat; |
321 }; | 310 }; |
322 | 311 |
323 PLATFORM_EXPORT Vector<Length> parseHTMLAreaElementCoords(const String&); | 312 PLATFORM_EXPORT Vector<Length> parseHTMLAreaElementCoords(const String&); |
324 | 313 |
325 } // namespace WebCore | 314 } // namespace WebCore |
326 | 315 |
327 #endif // Length_h | 316 #endif // Length_h |
OLD | NEW |