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

Side by Side Diff: Source/core/css/CSSPrimitiveValue.h

Issue 345903005: calc expressions should support time, angle and frequency values. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated patch Created 6 years, 5 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/CSSCalculationValue.cpp ('k') | Source/core/css/CSSPrimitiveValue.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 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 return adoptRefWillBeNoop(quirkValue); 266 return adoptRefWillBeNoop(quirkValue);
267 } 267 }
268 268
269 ~CSSPrimitiveValue(); 269 ~CSSPrimitiveValue();
270 270
271 void cleanup(); 271 void cleanup();
272 272
273 UnitType primitiveType() const; 273 UnitType primitiveType() const;
274 274
275 double computeDegrees(); 275 double computeDegrees();
276 276 double computeSeconds();
277 enum TimeUnit { Seconds, Milliseconds };
278 template <typename T, TimeUnit timeUnit> T computeTime()
279 {
280 if (timeUnit == Seconds && m_primitiveUnitType == CSS_S)
281 return getValue<T>();
282 if (timeUnit == Seconds && m_primitiveUnitType == CSS_MS)
283 return getValue<T>() / 1000;
284 if (timeUnit == Milliseconds && m_primitiveUnitType == CSS_MS)
285 return getValue<T>();
286 if (timeUnit == Milliseconds && m_primitiveUnitType == CSS_S)
287 return getValue<T>() * 1000;
288 ASSERT_NOT_REACHED();
289 return 0;
290 }
291 277
292 /* 278 /*
293 * Computes a length in pixels out of the given CSSValue 279 * Computes a length in pixels out of the given CSSValue
294 * 280 *
295 * The metrics have to be a bit different for screen and printer output. 281 * The metrics have to be a bit different for screen and printer output.
296 * For screen output we assume 1 inch == 72 px, for printer we assume 300 dp i 282 * For screen output we assume 1 inch == 72 px, for printer we assume 300 dp i
297 * 283 *
298 * this is screen/printer dependent, so we probably need a config option for this, 284 * this is screen/printer dependent, so we probably need a config option for this,
299 * and some tool to calibrate. 285 * and some tool to calibrate.
300 */ 286 */
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 } m_value; 411 } m_value;
426 }; 412 };
427 413
428 typedef CSSPrimitiveValue::CSSLengthArray CSSLengthArray; 414 typedef CSSPrimitiveValue::CSSLengthArray CSSLengthArray;
429 415
430 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); 416 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue());
431 417
432 } // namespace blink 418 } // namespace blink
433 419
434 #endif // CSSPrimitiveValue_h 420 #endif // CSSPrimitiveValue_h
OLDNEW
« no previous file with comments | « Source/core/css/CSSCalculationValue.cpp ('k') | Source/core/css/CSSPrimitiveValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698