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

Side by Side Diff: Source/platform/fonts/FontTraits.h

Issue 1270723002: Improve CSS Style matching spec compliance (Closed) Base URL: git@github.com:drott/blink-crosswalk.git@reimplementMatching
Patch Set: Fix TestExpectations Created 5 years, 4 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
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2014 Google Inc. All rights reserved. 3 * Copyright (C) 2014 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 14 matching lines...) Expand all
25 */ 25 */
26 26
27 #ifndef FontTraits_h 27 #ifndef FontTraits_h
28 #define FontTraits_h 28 #define FontTraits_h
29 29
30 #include "wtf/Assertions.h" 30 #include "wtf/Assertions.h"
31 31
32 namespace blink { 32 namespace blink {
33 33
34 enum FontWeight { 34 enum FontWeight {
35 FontWeight100, 35 FontWeight100 = 0,
36 FontWeight200, 36 FontWeight200 = 1,
37 FontWeight300, 37 FontWeight300 = 2,
38 FontWeight400, 38 FontWeight400 = 3,
39 FontWeight500, 39 FontWeight500 = 4,
40 FontWeight600, 40 FontWeight600 = 5,
41 FontWeight700, 41 FontWeight700 = 6,
42 FontWeight800, 42 FontWeight800 = 7,
43 FontWeight900, 43 FontWeight900 = 8,
44 FontWeightNormal = FontWeight400, 44 FontWeightNormal = FontWeight400,
45 FontWeightBold = FontWeight700 45 FontWeightBold = FontWeight700
46 }; 46 };
47 47
48 // Numeric values matching OS/2 & Windows Metrics usWidthClass table. 48 // Numeric values matching OS/2 & Windows Metrics usWidthClass table.
49 // https://www.microsoft.com/typography/otspec/os2.htm 49 // https://www.microsoft.com/typography/otspec/os2.htm
50 enum FontStretch { 50 enum FontStretch {
51 FontStretchUltraCondensed = 1, 51 FontStretchUltraCondensed = 1,
52 FontStretchExtraCondensed = 2, 52 FontStretchExtraCondensed = 2,
53 FontStretchCondensed = 3, 53 FontStretchCondensed = 3,
54 FontStretchSemiCondensed = 4, 54 FontStretchSemiCondensed = 4,
55 FontStretchNormal = 5, 55 FontStretchNormal = 5,
56 FontStretchSemiExpanded = 6, 56 FontStretchSemiExpanded = 6,
57 FontStretchExpanded = 7, 57 FontStretchExpanded = 7,
58 FontStretchExtraExpanded = 8, 58 FontStretchExtraExpanded = 8,
59 FontStretchUltraExpanded = 9 59 FontStretchUltraExpanded = 9
60 }; 60 };
61 61
62 enum FontStyle { 62 enum FontStyle {
63 FontStyleNormal = 0, 63 FontStyleNormal = 0,
64 FontStyleItalic = 1 64 FontStyleOblique = 1,
65 FontStyleItalic = 2
65 }; 66 };
66 67
67 enum FontVariant { 68 enum FontVariant {
68 FontVariantNormal = 0, 69 FontVariantNormal = 0,
69 FontVariantSmallCaps = 1 70 FontVariantSmallCaps = 1
70 }; 71 };
71 72
72 typedef unsigned FontTraitsBitfield; 73 typedef unsigned FontTraitsBitfield;
73 74
74 struct FontTraits { 75 struct FontTraits {
75 FontTraits(FontStyle style, FontVariant variant, FontWeight weight, FontStre tch stretch) 76 FontTraits(FontStyle style, FontVariant variant, FontWeight weight, FontStre tch stretch)
76 { 77 {
77 m_traits.m_style = style; 78 m_traits.m_style = style;
79 // TODO(drott): crbug.com/516673 Variant is not relevant for font select ion,
80 // should be removed here.
78 m_traits.m_variant = variant; 81 m_traits.m_variant = variant;
79 m_traits.m_weight = weight; 82 m_traits.m_weight = weight;
80 m_traits.m_stretch = stretch; 83 m_traits.m_stretch = stretch;
81 m_traits.m_filler = 0; 84 m_traits.m_filler = 0;
82 ASSERT(!(m_bitfield >> 10)); 85 ASSERT(!(m_bitfield >> 11));
83 } 86 }
84 FontTraits(FontTraitsBitfield bitfield) 87 FontTraits(FontTraitsBitfield bitfield)
85 : m_bitfield(bitfield) 88 : m_bitfield(bitfield)
86 { 89 {
87 ASSERT(!m_traits.m_filler); 90 ASSERT(!m_traits.m_filler);
88 ASSERT(!(m_bitfield >> 10)); 91 ASSERT(!(m_bitfield >> 11));
89 } 92 }
90 FontStyle style() const { return static_cast<FontStyle>(m_traits.m_style); } 93 FontStyle style() const { return static_cast<FontStyle>(m_traits.m_style); }
91 FontVariant variant() const { return static_cast<FontVariant>(m_traits.m_var iant); } 94 FontVariant variant() const { return static_cast<FontVariant>(m_traits.m_var iant); }
92 FontWeight weight() const { return static_cast<FontWeight>(m_traits.m_weight ); } 95 FontWeight weight() const { return static_cast<FontWeight>(m_traits.m_weight ); }
93 FontStretch stretch() const { return static_cast<FontStretch>(m_traits.m_str etch); } 96 FontStretch stretch() const { return static_cast<FontStretch>(m_traits.m_str etch); }
94 FontTraitsBitfield bitfield() const { return m_bitfield; } 97 FontTraitsBitfield bitfield() const { return m_bitfield; }
95 98
96 union { 99 union {
97 struct { 100 struct {
98 unsigned m_style : 1; 101 unsigned m_style : 2;
99 unsigned m_variant : 1; 102 unsigned m_variant : 1;
100 unsigned m_weight : 4; 103 unsigned m_weight : 4;
101 unsigned m_stretch : 4; 104 unsigned m_stretch : 4;
102 unsigned m_filler : 22; 105 unsigned m_filler : 21;
103 } m_traits; 106 } m_traits;
104 FontTraitsBitfield m_bitfield; 107 FontTraitsBitfield m_bitfield;
105 }; 108 };
106 }; 109 };
107 110
108 } // namespace blink 111 } // namespace blink
109 #endif // FontTraits_h 112 #endif // FontTraits_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698