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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/UnicodeRangeSet.cpp

Issue 1806653002: Shape unicode-range: font faces in only one iteration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update UnicodeRangeSetTests to RefPtrtr, rm copy constructor and test Created 4 years, 9 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) 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
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
74 bool UnicodeRangeSet::intersectsWith(const String& text) const 65 bool UnicodeRangeSet::intersectsWith(const String& text) const
75 { 66 {
76 if (text.isEmpty()) 67 if (text.isEmpty())
77 return false; 68 return false;
78 if (isEntireRange()) 69 if (isEntireRange())
79 return true; 70 return true;
80 if (text.is8Bit() && m_ranges[0].from() >= 0x100) 71 if (text.is8Bit() && m_ranges[0].from() >= 0x100)
81 return false; 72 return false;
82 73
83 unsigned index = 0; 74 unsigned index = 0;
84 while (index < text.length()) { 75 while (index < text.length()) {
85 UChar32 c = text.characterStartingAt(index); 76 UChar32 c = text.characterStartingAt(index);
86 index += U16_LENGTH(c); 77 index += U16_LENGTH(c);
87 if (contains(c)) 78 if (contains(c))
88 return true; 79 return true;
89 } 80 }
90 return false; 81 return false;
91 } 82 }
92 83
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;
93 } 96 }
97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698