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

Side by Side Diff: third_party/WebKit/Source/core/animation/FontWeightConversion.cpp

Issue 2794013002: Fewer reused duplicate symbol names in animation. (Closed)
Patch Set: Addressed review comments. Created 3 years, 8 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/animation/FontWeightConversion.h"
6
7 #include "platform/wtf/MathExtras.h"
8 #include "platform/wtf/StdLibExtras.h"
9
10 namespace blink {
11
12 double fontWeightToDouble(FontWeight fontWeight) {
13 switch (fontWeight) {
14 case FontWeight100:
15 return 100;
16 case FontWeight200:
17 return 200;
18 case FontWeight300:
19 return 300;
20 case FontWeight400:
21 return 400;
22 case FontWeight500:
23 return 500;
24 case FontWeight600:
25 return 600;
26 case FontWeight700:
27 return 700;
28 case FontWeight800:
29 return 800;
30 case FontWeight900:
31 return 900;
32 default:
33 NOTREACHED();
34 return 400;
35 }
36 }
37
38 FontWeight doubleToFontWeight(double value) {
39 static const FontWeight fontWeights[] = {
40 FontWeight100, FontWeight200, FontWeight300, FontWeight400, FontWeight500,
41 FontWeight600, FontWeight700, FontWeight800, FontWeight900,
42 };
43
44 int index = round(value / 100 - 1);
45 int clampedIndex = clampTo<int>(index, 0, WTF_ARRAY_LENGTH(fontWeights) - 1);
46 return fontWeights[clampedIndex];
47 }
48
49 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698