| 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 "core/css/MediaValues.h" | 5 #include "core/css/MediaValues.h" |
| 6 | 6 |
| 7 #include "core/css/CSSHelper.h" | 7 #include "core/css/CSSHelper.h" |
| 8 #include "core/css/MediaValuesCached.h" | 8 #include "core/css/MediaValuesCached.h" |
| 9 #include "core/css/MediaValuesDynamic.h" | 9 #include "core/css/MediaValuesDynamic.h" |
| 10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 ASSERT(frame && frame->settings()); | 139 ASSERT(frame && frame->settings()); |
| 140 return frame->settings()->availableHoverTypes(); | 140 return frame->settings()->availableHoverTypes(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 bool MediaValues::computeLengthImpl(double value, | 143 bool MediaValues::computeLengthImpl(double value, |
| 144 CSSPrimitiveValue::UnitType type, | 144 CSSPrimitiveValue::UnitType type, |
| 145 unsigned defaultFontSize, | 145 unsigned defaultFontSize, |
| 146 double viewportWidth, | 146 double viewportWidth, |
| 147 double viewportHeight, | 147 double viewportHeight, |
| 148 double& result) { | 148 double& result) { |
| 149 // The logic in this function is duplicated from CSSToLengthConversionData::zo
omedComputedPixels() | 149 // The logic in this function is duplicated from |
| 150 // because MediaValues::computeLength() needs nearly identical logic, but we h
aven't found a way to make | 150 // CSSToLengthConversionData::zoomedComputedPixels() because |
| 151 // CSSToLengthConversionData::zoomedComputedPixels() more generic (to solve bo
th cases) without hurting performance. | 151 // MediaValues::computeLength() needs nearly identical logic, but we haven't |
| 152 | 152 // found a way to make CSSToLengthConversionData::zoomedComputedPixels() more |
| 153 // FIXME - Unite the logic here with CSSToLengthConversionData in a performant
way. | 153 // generic (to solve both cases) without hurting performance. |
| 154 // FIXME - Unite the logic here with CSSToLengthConversionData in a performant |
| 155 // way. |
| 154 switch (type) { | 156 switch (type) { |
| 155 case CSSPrimitiveValue::UnitType::Ems: | 157 case CSSPrimitiveValue::UnitType::Ems: |
| 156 case CSSPrimitiveValue::UnitType::Rems: | 158 case CSSPrimitiveValue::UnitType::Rems: |
| 157 result = value * defaultFontSize; | 159 result = value * defaultFontSize; |
| 158 return true; | 160 return true; |
| 159 case CSSPrimitiveValue::UnitType::Pixels: | 161 case CSSPrimitiveValue::UnitType::Pixels: |
| 160 case CSSPrimitiveValue::UnitType::UserUnits: | 162 case CSSPrimitiveValue::UnitType::UserUnits: |
| 161 result = value; | 163 result = value; |
| 162 return true; | 164 return true; |
| 163 case CSSPrimitiveValue::UnitType::Exs: | 165 case CSSPrimitiveValue::UnitType::Exs: |
| 164 // FIXME: We have a bug right now where the zoom will be applied twice to EX
units. | 166 // FIXME: We have a bug right now where the zoom will be applied twice to EX |
| 167 // units. |
| 165 case CSSPrimitiveValue::UnitType::Chs: | 168 case CSSPrimitiveValue::UnitType::Chs: |
| 166 // FIXME: We don't seem to be able to cache fontMetrics related values. | 169 // FIXME: We don't seem to be able to cache fontMetrics related values. |
| 167 // Trying to access them is triggering some sort of microtask. Serving the
spec's default instead. | 170 // Trying to access them is triggering some sort of microtask. Serving the |
| 171 // spec's default instead. |
| 168 result = (value * defaultFontSize) / 2.0; | 172 result = (value * defaultFontSize) / 2.0; |
| 169 return true; | 173 return true; |
| 170 case CSSPrimitiveValue::UnitType::ViewportWidth: | 174 case CSSPrimitiveValue::UnitType::ViewportWidth: |
| 171 result = (value * viewportWidth) / 100.0; | 175 result = (value * viewportWidth) / 100.0; |
| 172 return true; | 176 return true; |
| 173 case CSSPrimitiveValue::UnitType::ViewportHeight: | 177 case CSSPrimitiveValue::UnitType::ViewportHeight: |
| 174 result = (value * viewportHeight) / 100.0; | 178 result = (value * viewportHeight) / 100.0; |
| 175 return true; | 179 return true; |
| 176 case CSSPrimitiveValue::UnitType::ViewportMin: | 180 case CSSPrimitiveValue::UnitType::ViewportMin: |
| 177 result = (value * std::min(viewportWidth, viewportHeight)) / 100.0; | 181 result = (value * std::min(viewportWidth, viewportHeight)) / 100.0; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 201 | 205 |
| 202 LocalFrame* MediaValues::frameFrom(Document& document) { | 206 LocalFrame* MediaValues::frameFrom(Document& document) { |
| 203 Document* executingDocument = document.importsController() | 207 Document* executingDocument = document.importsController() |
| 204 ? document.importsController()->master() | 208 ? document.importsController()->master() |
| 205 : &document; | 209 : &document; |
| 206 ASSERT(executingDocument); | 210 ASSERT(executingDocument); |
| 207 return executingDocument->frame(); | 211 return executingDocument->frame(); |
| 208 } | 212 } |
| 209 | 213 |
| 210 } // namespace blink | 214 } // namespace blink |
| OLD | NEW |