OLD | NEW |
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 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 55 } |
56 | 56 |
57 bool UnicodeRangeSet::contains(UChar32 c) const | 57 bool UnicodeRangeSet::contains(UChar32 c) const |
58 { | 58 { |
59 if (isEntireRange()) | 59 if (isEntireRange()) |
60 return true; | 60 return true; |
61 Vector<UnicodeRange>::const_iterator it = std::lower_bound(m_ranges.begin(),
m_ranges.end(), c); | 61 Vector<UnicodeRange>::const_iterator it = std::lower_bound(m_ranges.begin(),
m_ranges.end(), c); |
62 return it != m_ranges.end() && it->contains(c); | 62 return it != m_ranges.end() && it->contains(c); |
63 } | 63 } |
64 | 64 |
| 65 bool UnicodeRangeSet::contains(const FontDataRange& range) const |
| 66 { |
| 67 for (auto it = m_ranges.begin(); it != m_ranges.end(); ++it) { |
| 68 if (*it == range) |
| 69 return true; |
| 70 } |
| 71 return false; |
| 72 } |
| 73 |
65 bool UnicodeRangeSet::intersectsWith(const String& text) const | 74 bool UnicodeRangeSet::intersectsWith(const String& text) const |
66 { | 75 { |
67 if (text.isEmpty()) | 76 if (text.isEmpty()) |
68 return false; | 77 return false; |
69 if (isEntireRange()) | 78 if (isEntireRange()) |
70 return true; | 79 return true; |
71 if (text.is8Bit() && m_ranges[0].from() >= 0x100) | 80 if (text.is8Bit() && m_ranges[0].from() >= 0x100) |
72 return false; | 81 return false; |
73 | 82 |
74 unsigned index = 0; | 83 unsigned index = 0; |
75 while (index < text.length()) { | 84 while (index < text.length()) { |
76 UChar32 c = text.characterStartingAt(index); | 85 UChar32 c = text.characterStartingAt(index); |
77 index += U16_LENGTH(c); | 86 index += U16_LENGTH(c); |
78 if (contains(c)) | 87 if (contains(c)) |
79 return true; | 88 return true; |
80 } | 89 } |
81 return false; | 90 return false; |
82 } | 91 } |
83 | 92 |
84 bool UnicodeRangeSet::operator==(const UnicodeRangeSet& other) const | |
85 { | |
86 if (m_ranges.size() == 0 && other.size() == 0) | |
87 return true; | |
88 if (m_ranges.size() != other.size()) { | |
89 return false; | |
90 } | |
91 bool equal = true; | |
92 for (size_t i = 0; i < m_ranges.size(); ++i) { | |
93 equal = equal && m_ranges[i] == other.m_ranges[i]; | |
94 } | |
95 return equal; | |
96 } | 93 } |
97 } | |
OLD | NEW |