| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 return adoptRef(new CalculationValue(value, range)); | 46 return adoptRef(new CalculationValue(value, range)); |
| 47 } | 47 } |
| 48 | 48 |
| 49 float evaluate(float maxValue) const | 49 float evaluate(float maxValue) const |
| 50 { | 50 { |
| 51 float value = pixels() + percent() / 100 * maxValue; | 51 float value = pixels() + percent() / 100 * maxValue; |
| 52 return (isNonNegative() && value < 0) ? 0 : value; | 52 return (isNonNegative() && value < 0) ? 0 : value; |
| 53 } | 53 } |
| 54 bool operator==(const CalculationValue& o) const { return pixels() == o.pixe
ls() && percent() == o.percent(); } | 54 bool operator==(const CalculationValue& o) const { return pixels() == o.pixe
ls() && percent() == o.percent(); } |
| 55 bool isNonNegative() const { return m_isNonNegative; } | 55 bool isNonNegative() const { return m_isNonNegative; } |
| 56 ValueRange valueRange() const { return m_isNonNegative ? ValueRangeNonNegati
ve : ValueRangeAll; } | 56 ValueRange getValueRange() const { return m_isNonNegative ? ValueRangeNonNeg
ative : ValueRangeAll; } |
| 57 float pixels() const { return m_value.pixels; } | 57 float pixels() const { return m_value.pixels; } |
| 58 float percent() const { return m_value.percent; } | 58 float percent() const { return m_value.percent; } |
| 59 PixelsAndPercent pixelsAndPercent() const { return m_value; } | 59 PixelsAndPercent getPixelsAndPercent() const { return m_value; } |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 CalculationValue(PixelsAndPercent value, ValueRange range) | 62 CalculationValue(PixelsAndPercent value, ValueRange range) |
| 63 : m_value(value) | 63 : m_value(value) |
| 64 , m_isNonNegative(range == ValueRangeNonNegative) | 64 , m_isNonNegative(range == ValueRangeNonNegative) |
| 65 { | 65 { |
| 66 } | 66 } |
| 67 | 67 |
| 68 PixelsAndPercent m_value; | 68 PixelsAndPercent m_value; |
| 69 bool m_isNonNegative; | 69 bool m_isNonNegative; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 } // namespace blink | 72 } // namespace blink |
| 73 | 73 |
| 74 #endif // CalculationValue_h | 74 #endif // CalculationValue_h |
| OLD | NEW |