| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/css/MediaValues.h" | 6 #include "core/css/MediaValues.h" |
| 7 | 7 |
| 8 #include "core/css/CSSHelper.h" | 8 #include "core/css/CSSHelper.h" |
| 9 #include "core/css/MediaValuesCached.h" | 9 #include "core/css/MediaValuesCached.h" |
| 10 #include "core/css/MediaValuesDynamic.h" | 10 #include "core/css/MediaValuesDynamic.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // FIXME: We should also try to determine if we know we have a mouse. | 131 // FIXME: We should also try to determine if we know we have a mouse. |
| 132 // When we do this, we'll also need to differentiate between known not to | 132 // When we do this, we'll also need to differentiate between known not to |
| 133 // have mouse or touch screen (NoPointer) and unknown (UnknownPointer). | 133 // have mouse or touch screen (NoPointer) and unknown (UnknownPointer). |
| 134 // We could also take into account other preferences like accessibility | 134 // We could also take into account other preferences like accessibility |
| 135 // settings to decide which of the available pointers should be considered | 135 // settings to decide which of the available pointers should be considered |
| 136 // "primary". | 136 // "primary". |
| 137 | 137 |
| 138 return MediaValues::UnknownPointer; | 138 return MediaValues::UnknownPointer; |
| 139 } | 139 } |
| 140 | 140 |
| 141 bool MediaValues::computeLength(double value, CSSPrimitiveValue::UnitTypes type,
unsigned defaultFontSize, unsigned viewportWidth, unsigned viewportHeight, int&
result) | 141 bool MediaValues::computeLengthImpl(double value, CSSPrimitiveValue::UnitTypes t
ype, unsigned defaultFontSize, unsigned viewportWidth, unsigned viewportHeight,
double& result) |
| 142 { | 142 { |
| 143 // The logic in this function is duplicated from CSSPrimitiveValue::computeL
engthDouble | 143 // The logic in this function is duplicated from CSSPrimitiveValue::computeL
engthDouble |
| 144 // because MediaValues::computeLength needs nearly identical logic, but we h
aven't found a way to make | 144 // because MediaValues::computeLength needs nearly identical logic, but we h
aven't found a way to make |
| 145 // CSSPrimitiveValue::computeLengthDouble more generic (to solve both cases)
without hurting performance. | 145 // CSSPrimitiveValue::computeLengthDouble more generic (to solve both cases)
without hurting performance. |
| 146 | 146 |
| 147 // FIXME - Unite the logic here with CSSPrimitiveValue in a performant way. | 147 // FIXME - Unite the logic here with CSSPrimitiveValue in a performant way. |
| 148 double factor = 0; | 148 double factor = 0; |
| 149 switch (type) { | 149 switch (type) { |
| 150 case CSSPrimitiveValue::CSS_EMS: | 150 case CSSPrimitiveValue::CSS_EMS: |
| 151 case CSSPrimitiveValue::CSS_REMS: | 151 case CSSPrimitiveValue::CSS_REMS: |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 case CSSPrimitiveValue::CSS_PT: | 189 case CSSPrimitiveValue::CSS_PT: |
| 190 factor = cssPixelsPerPoint; | 190 factor = cssPixelsPerPoint; |
| 191 break; | 191 break; |
| 192 case CSSPrimitiveValue::CSS_PC: | 192 case CSSPrimitiveValue::CSS_PC: |
| 193 factor = cssPixelsPerPica; | 193 factor = cssPixelsPerPica; |
| 194 break; | 194 break; |
| 195 default: | 195 default: |
| 196 return false; | 196 return false; |
| 197 } | 197 } |
| 198 | 198 |
| 199 result = value * factor; |
| 200 return true; |
| 201 |
| 199 ASSERT(factor > 0); | 202 ASSERT(factor > 0); |
| 200 result = roundForImpreciseConversion<int>(value*factor); | |
| 201 return true; | |
| 202 } | 203 } |
| 203 | 204 |
| 204 } // namespace | 205 } // namespace |
| OLD | NEW |