Chromium Code Reviews| 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 Copyright (C) 2012 Motorola Mobility, Inc. All rights reserved. | 6 Copyright (C) 2012 Motorola Mobility, Inc. All rights reserved. |
| 7 | 7 |
| 8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
| 9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
| 10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 | 31 |
| 32 int intValueForLength(const Length& length, int maximumValue) { | 32 int intValueForLength(const Length& length, int maximumValue) { |
| 33 return valueForLength(length, LayoutUnit(maximumValue)).toInt(); | 33 return valueForLength(length, LayoutUnit(maximumValue)).toInt(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 float floatValueForLength(const Length& length, float maximumValue) { | 36 float floatValueForLength(const Length& length, float maximumValue) { |
| 37 switch (length.type()) { | 37 switch (length.type()) { |
| 38 case Fixed: | 38 case Fixed: |
| 39 return length.getFloatValue(); | 39 return length.getFloatValue(); |
| 40 case Percent: | 40 case Percent: |
| 41 return static_cast<float>(maximumValue * length.percent() / 100.0f); | 41 return clampTo<float>(maximumValue * length.percent() / 100.0f); |
|
eae
2017/01/03 04:37:30
clampTo is significantly more expensive than a sta
alancutter (OOO until 2018)
2017/01/03 05:17:02
The performance impact of this is a bit scary actu
| |
| 42 case FillAvailable: | 42 case FillAvailable: |
| 43 case Auto: | 43 case Auto: |
| 44 return static_cast<float>(maximumValue); | 44 return maximumValue; |
| 45 case Calculated: | 45 case Calculated: |
| 46 return length.nonNanCalculatedValue(LayoutUnit(maximumValue)); | 46 return length.nonNanCalculatedValue(LayoutUnit(maximumValue)); |
| 47 case MinContent: | 47 case MinContent: |
| 48 case MaxContent: | 48 case MaxContent: |
| 49 case FitContent: | 49 case FitContent: |
| 50 case ExtendToZoom: | 50 case ExtendToZoom: |
| 51 case DeviceWidth: | 51 case DeviceWidth: |
| 52 case DeviceHeight: | 52 case DeviceHeight: |
| 53 case MaxSizeNone: | 53 case MaxSizeNone: |
| 54 ASSERT_NOT_REACHED(); | 54 ASSERT_NOT_REACHED(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 floatValueForLength(lengthSize.height(), boxSize.height())); | 124 floatValueForLength(lengthSize.height(), boxSize.height())); |
| 125 } | 125 } |
| 126 | 126 |
| 127 FloatPoint floatPointForLengthPoint(const LengthPoint& LengthPoint, | 127 FloatPoint floatPointForLengthPoint(const LengthPoint& LengthPoint, |
| 128 const FloatSize& boxSize) { | 128 const FloatSize& boxSize) { |
| 129 return FloatPoint(floatValueForLength(LengthPoint.x(), boxSize.width()), | 129 return FloatPoint(floatValueForLength(LengthPoint.x(), boxSize.width()), |
| 130 floatValueForLength(LengthPoint.y(), boxSize.height())); | 130 floatValueForLength(LengthPoint.y(), boxSize.height())); |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace blink | 133 } // namespace blink |
| OLD | NEW |