Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: Source/core/css/MediaValues.cpp

Issue 252743004: A thread safe CSS calc parser for sizes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed CSSCalc tests that assert Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/css/MediaValues.h ('k') | Source/core/css/MediaValuesCached.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « Source/core/css/MediaValues.h ('k') | Source/core/css/MediaValuesCached.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698