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

Side by Side Diff: Source/platform/Length.h

Issue 82083002: Move viewport unit resolution to style recalc time (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: fix compile on mac Created 7 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 unified diff | Download patch
OLDNEW
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 17 matching lines...) Expand all
28 #include "wtf/Assertions.h" 28 #include "wtf/Assertions.h"
29 #include "wtf/FastAllocBase.h" 29 #include "wtf/FastAllocBase.h"
30 #include "wtf/Forward.h" 30 #include "wtf/Forward.h"
31 #include "wtf/HashMap.h" 31 #include "wtf/HashMap.h"
32 #include "wtf/MathExtras.h" 32 #include "wtf/MathExtras.h"
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 // FIXME: This enum makes it hard to tell in general what values may be
39 // appropriate for any given Length.
38 enum LengthType { 40 enum LengthType {
39 Auto, Percent, Fixed, 41 Auto, Percent, Fixed,
40 Intrinsic, MinIntrinsic, 42 Intrinsic, MinIntrinsic,
41 MinContent, MaxContent, FillAvailable, FitContent, 43 MinContent, MaxContent, FillAvailable, FitContent,
42 Calculated, 44 Calculated,
43 ViewportPercentageWidth, ViewportPercentageHeight, ViewportPercentageMin, Vi ewportPercentageMax, 45 ExtendToZoom, DeviceWidth, DeviceHeight,
johnme 2013/12/18 12:04:15 I'm probably missing something, but why did you ad
Timothy Loh 2013/12/23 06:28:16 See other comments about vw/vh meaning. This seem
44 ExtendToZoom,
45 Undefined 46 Undefined
46 }; 47 };
47 48
48 enum ValueRange { 49 enum ValueRange {
49 ValueRangeAll, 50 ValueRangeAll,
50 ValueRangeNonNegative 51 ValueRangeNonNegative
51 }; 52 };
52 53
53 class CalculationValue; 54 class CalculationValue;
54 55
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 223
223 return getFloatValue() < 0; 224 return getFloatValue() < 0;
224 } 225 }
225 226
226 bool isAuto() const { return type() == Auto; } 227 bool isAuto() const { return type() == Auto; }
227 bool isPercent() const { return type() == Percent || type() == Calculated; } 228 bool isPercent() const { return type() == Percent || type() == Calculated; }
228 bool isFixed() const { return type() == Fixed; } 229 bool isFixed() const { return type() == Fixed; }
229 bool isIntrinsicOrAuto() const { return type() == Auto || isLegacyIntrinsic( ) || isIntrinsic(); } 230 bool isIntrinsicOrAuto() const { return type() == Auto || isLegacyIntrinsic( ) || isIntrinsic(); }
230 bool isLegacyIntrinsic() const { return type() == Intrinsic || type() == Min Intrinsic; } 231 bool isLegacyIntrinsic() const { return type() == Intrinsic || type() == Min Intrinsic; }
231 bool isIntrinsic() const { return type() == MinContent || type() == MaxConte nt || type() == FillAvailable || type() == FitContent; } 232 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(); } 233 bool isSpecified() const { return type() == Fixed || type() == Percent || ty pe() == Calculated; }
233 bool isSpecifiedOrIntrinsic() const { return isSpecified() || isIntrinsic(); } 234 bool isSpecifiedOrIntrinsic() const { return isSpecified() || isIntrinsic(); }
234 bool isCalculated() const { return type() == Calculated; } 235 bool isCalculated() const { return type() == Calculated; }
235 bool isCalculatedEqual(const Length&) const; 236 bool isCalculatedEqual(const Length&) const;
236 bool isMinContent() const { return type() == MinContent; } 237 bool isMinContent() const { return type() == MinContent; }
237 bool isMaxContent() const { return type() == MaxContent; } 238 bool isMaxContent() const { return type() == MaxContent; }
238 bool isFillAvailable() const { return type() == FillAvailable; } 239 bool isFillAvailable() const { return type() == FillAvailable; }
239 bool isFitContent() const { return type() == FitContent; } 240 bool isFitContent() const { return type() == FitContent; }
240 241
241 Length blend(const Length& from, double progress, ValueRange range) const 242 Length blend(const Length& from, double progress, ValueRange range) const
242 { 243 {
(...skipping 27 matching lines...) Expand all
270 return Length(blendedValue, resultType); 271 return Length(blendedValue, resultType);
271 } 272 }
272 273
273 float getFloatValue() const 274 float getFloatValue() const
274 { 275 {
275 ASSERT(!isUndefined()); 276 ASSERT(!isUndefined());
276 return m_isFloat ? m_floatValue : m_intValue; 277 return m_isFloat ? m_floatValue : m_intValue;
277 } 278 }
278 float nonNanCalculatedValue(int maxValue) const; 279 float nonNanCalculatedValue(int maxValue) const;
279 280
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: 281 private:
291 int getIntValue() const 282 int getIntValue() const
292 { 283 {
293 ASSERT(!isUndefined()); 284 ASSERT(!isUndefined());
294 return m_isFloat ? static_cast<int>(m_floatValue) : m_intValue; 285 return m_isFloat ? static_cast<int>(m_floatValue) : m_intValue;
295 } 286 }
296 void initFromLength(const Length& length) 287 void initFromLength(const Length& length)
297 { 288 {
298 memcpy(this, &length, sizeof(Length)); 289 memcpy(this, &length, sizeof(Length));
299 290
(...skipping 18 matching lines...) Expand all
318 bool m_quirk; 309 bool m_quirk;
319 unsigned char m_type; 310 unsigned char m_type;
320 bool m_isFloat; 311 bool m_isFloat;
321 }; 312 };
322 313
323 PLATFORM_EXPORT Vector<Length> parseHTMLAreaElementCoords(const String&); 314 PLATFORM_EXPORT Vector<Length> parseHTMLAreaElementCoords(const String&);
324 315
325 } // namespace WebCore 316 } // namespace WebCore
326 317
327 #endif // Length_h 318 #endif // Length_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698