| 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 "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
| 6 #include "sky/engine/core/css/MediaValues.h" | 6 #include "sky/engine/core/css/MediaValues.h" |
| 7 | 7 |
| 8 #include "sky/engine/core/css/CSSHelper.h" | 8 #include "sky/engine/core/css/CSSHelper.h" |
| 9 #include "sky/engine/core/css/MediaValuesCached.h" | 9 #include "sky/engine/core/css/MediaValuesCached.h" |
| 10 #include "sky/engine/core/css/MediaValuesDynamic.h" | 10 #include "sky/engine/core/css/MediaValuesDynamic.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 bool MediaValues::computeLengthImpl(double value, CSSPrimitiveValue::UnitType ty
pe, unsigned defaultFontSize, unsigned viewportWidth, unsigned viewportHeight, d
ouble& result) | 129 bool MediaValues::computeLengthImpl(double value, CSSPrimitiveValue::UnitType ty
pe, unsigned defaultFontSize, unsigned viewportWidth, unsigned viewportHeight, d
ouble& result) |
| 130 { | 130 { |
| 131 // The logic in this function is duplicated from CSSPrimitiveValue::computeL
engthDouble | 131 // The logic in this function is duplicated from CSSPrimitiveValue::computeL
engthDouble |
| 132 // because MediaValues::computeLength needs nearly identical logic, but we h
aven't found a way to make | 132 // because MediaValues::computeLength needs nearly identical logic, but we h
aven't found a way to make |
| 133 // CSSPrimitiveValue::computeLengthDouble more generic (to solve both cases)
without hurting performance. | 133 // CSSPrimitiveValue::computeLengthDouble more generic (to solve both cases)
without hurting performance. |
| 134 | 134 |
| 135 // FIXME - Unite the logic here with CSSPrimitiveValue in a performant way. | 135 // FIXME - Unite the logic here with CSSPrimitiveValue in a performant way. |
| 136 double factor = 0; | 136 double factor = 0; |
| 137 switch (type) { | 137 switch (type) { |
| 138 case CSSPrimitiveValue::CSS_EMS: | 138 case CSSPrimitiveValue::CSS_EMS: |
| 139 case CSSPrimitiveValue::CSS_REMS: | |
| 140 factor = defaultFontSize; | 139 factor = defaultFontSize; |
| 141 break; | 140 break; |
| 142 case CSSPrimitiveValue::CSS_PX: | 141 case CSSPrimitiveValue::CSS_PX: |
| 143 factor = 1; | 142 factor = 1; |
| 144 break; | 143 break; |
| 145 case CSSPrimitiveValue::CSS_EXS: | 144 case CSSPrimitiveValue::CSS_EXS: |
| 146 // FIXME: We have a bug right now where the zoom will be applied twice t
o EX units. | 145 // FIXME: We have a bug right now where the zoom will be applied twice t
o EX units. |
| 147 // FIXME: We don't seem to be able to cache fontMetrics related values. | 146 // FIXME: We don't seem to be able to cache fontMetrics related values. |
| 148 // Trying to access them is triggering some sort of microtask. Serving t
he spec's default instead. | 147 // Trying to access them is triggering some sort of microtask. Serving t
he spec's default instead. |
| 149 factor = defaultFontSize / 2.0; | 148 factor = defaultFontSize / 2.0; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 } | 189 } |
| 191 | 190 |
| 192 LocalFrame* MediaValues::frameFrom(Document& document) | 191 LocalFrame* MediaValues::frameFrom(Document& document) |
| 193 { | 192 { |
| 194 Document* executingDocument = document.importsController() ? document.import
sController()->master() : &document; | 193 Document* executingDocument = document.importsController() ? document.import
sController()->master() : &document; |
| 195 ASSERT(executingDocument); | 194 ASSERT(executingDocument); |
| 196 return executingDocument->frame(); | 195 return executingDocument->frame(); |
| 197 } | 196 } |
| 198 | 197 |
| 199 } // namespace | 198 } // namespace |
| OLD | NEW |