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

Side by Side Diff: third_party/WebKit/Source/core/css/FontStyleMatcher.cpp

Issue 2458003002: Remove ASSERT_WITH_SECURITY_IMPLICATION. (Closed)
Patch Set: Minor formatting fix Created 4 years, 1 month 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) 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2015 Google Inc. All rights reserved. 3 * Copyright (C) 2015 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // faces and then normal faces." 50 // faces and then normal faces."
51 // i.e. normal gets the lowest score, oblique gets the highest, italic 51 // i.e. normal gets the lowest score, oblique gets the highest, italic
52 // second best. 52 // second best.
53 {0, 2, 1}, 53 {0, 2, 1},
54 // "If the value of font-style is italic, italic faces are checked first, 54 // "If the value of font-style is italic, italic faces are checked first,
55 // then oblique, then normal faces" 55 // then oblique, then normal faces"
56 // i.e. normal gets the lowest score, oblique is second best, italic 56 // i.e. normal gets the lowest score, oblique is second best, italic
57 // highest. 57 // highest.
58 {0, 1, 2}}; 58 {0, 1, 2}};
59 59
60 ASSERT_WITH_SECURITY_IMPLICATION(desired.style() < FontStyleItalic + 1); 60 SECURITY_DCHECK(desired.style() < FontStyleItalic + 1);
61 ASSERT_WITH_SECURITY_IMPLICATION(candidate.style() < FontStyleItalic + 1); 61 SECURITY_DCHECK(candidate.style() < FontStyleItalic + 1);
62 62
63 return styleScoreLookupTable[desired.style()][candidate.style()]; 63 return styleScoreLookupTable[desired.style()][candidate.style()];
64 } 64 }
65 65
66 static inline unsigned weightScore(FontTraits desired, FontTraits candidate) { 66 static inline unsigned weightScore(FontTraits desired, FontTraits candidate) {
67 static_assert(FontWeight100 == 0 && FontWeight900 - FontWeight100 == 8, 67 static_assert(FontWeight100 == 0 && FontWeight900 - FontWeight100 == 8,
68 "Enumeration values need to match lookup table."); 68 "Enumeration values need to match lookup table.");
69 static const unsigned scoreLookupSize = FontWeight900 + 1; 69 static const unsigned scoreLookupSize = FontWeight900 + 1;
70 // https://drafts.csswg.org/css-fonts/#font-style-matching 70 // https://drafts.csswg.org/css-fonts/#font-style-matching
71 // "..if the desired weight is available that face matches. " 71 // "..if the desired weight is available that face matches. "
(...skipping 17 matching lines...) Expand all
89 // weight are checked in ascending order followed by weights below the 89 // weight are checked in ascending order followed by weights below the
90 // desired weight in descending order until a match is found." 90 // desired weight in descending order until a match is found."
91 {1, 2, 3, 4, 5, 9, 8, 7, 6}, // FontWeight600 desired 91 {1, 2, 3, 4, 5, 9, 8, 7, 6}, // FontWeight600 desired
92 {1, 2, 3, 4, 5, 6, 9, 8, 7}, // FontWeight700 desired 92 {1, 2, 3, 4, 5, 6, 9, 8, 7}, // FontWeight700 desired
93 {1, 2, 3, 4, 5, 6, 7, 9, 8}, // FontWeight800 desired 93 {1, 2, 3, 4, 5, 6, 7, 9, 8}, // FontWeight800 desired
94 {1, 2, 3, 4, 5, 6, 7, 8, 9} // FontWeight900 desired 94 {1, 2, 3, 4, 5, 6, 7, 8, 9} // FontWeight900 desired
95 }; 95 };
96 96
97 unsigned desiredScoresLookup = static_cast<unsigned>(desired.weight()); 97 unsigned desiredScoresLookup = static_cast<unsigned>(desired.weight());
98 unsigned candidateScoreLookup = static_cast<unsigned>(candidate.weight()); 98 unsigned candidateScoreLookup = static_cast<unsigned>(candidate.weight());
99 ASSERT_WITH_SECURITY_IMPLICATION(desiredScoresLookup < scoreLookupSize); 99 SECURITY_DCHECK(desiredScoresLookup < scoreLookupSize);
100 ASSERT_WITH_SECURITY_IMPLICATION(candidateScoreLookup < scoreLookupSize); 100 SECURITY_DCHECK(candidateScoreLookup < scoreLookupSize);
101 101
102 return weightScoreLookup[desiredScoresLookup][candidateScoreLookup]; 102 return weightScoreLookup[desiredScoresLookup][candidateScoreLookup];
103 } 103 }
104 104
105 bool FontStyleMatcher::isCandidateBetter(CSSSegmentedFontFace* candidate, 105 bool FontStyleMatcher::isCandidateBetter(CSSSegmentedFontFace* candidate,
106 CSSSegmentedFontFace* current) { 106 CSSSegmentedFontFace* current) {
107 const FontTraits& candidateTraits = candidate->traits(); 107 const FontTraits& candidateTraits = candidate->traits();
108 const FontTraits& currentTraits = current->traits(); 108 const FontTraits& currentTraits = current->traits();
109 109
110 // According to CSS3 Fonts Font Style matching, there is a precedence for 110 // According to CSS3 Fonts Font Style matching, there is a precedence for
(...skipping 22 matching lines...) Expand all
133 weightComparison = weightScore(m_fontTraits, candidateTraits) - 133 weightComparison = weightScore(m_fontTraits, candidateTraits) -
134 weightScore(m_fontTraits, currentTraits); 134 weightScore(m_fontTraits, currentTraits);
135 135
136 if (weightComparison > 0) 136 if (weightComparison > 0)
137 return true; 137 return true;
138 138
139 return false; 139 return false;
140 } 140 }
141 141
142 } // namespace blink 142 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSImageSetValue.cpp ('k') | third_party/WebKit/Source/core/css/StyleSheetContents.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698