OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 if (result == Prefix) | 62 if (result == Prefix) |
63 return left; | 63 return left; |
64 if (result == After) | 64 if (result == After) |
65 return right; | 65 return right; |
66 while (left + 1 < right) { | 66 while (left + 1 < right) { |
67 const HTMLEntityTableEntry* probe = halfway(left, right); | 67 const HTMLEntityTableEntry* probe = halfway(left, right); |
68 result = compare(probe, nextCharacter); | 68 result = compare(probe, nextCharacter); |
69 if (result == Before) | 69 if (result == Before) |
70 left = probe; | 70 left = probe; |
71 else { | 71 else { |
72 ASSERT(result == After || result == Prefix); | 72 DCHECK(result == After || result == Prefix); |
73 right = probe; | 73 right = probe; |
74 } | 74 } |
75 } | 75 } |
76 ASSERT(left + 1 == right); | 76 DCHECK_EQ(left + 1, right); |
77 return right; | 77 return right; |
78 } | 78 } |
79 | 79 |
80 const HTMLEntityTableEntry* HTMLEntitySearch::findLast( | 80 const HTMLEntityTableEntry* HTMLEntitySearch::findLast( |
81 UChar nextCharacter) const { | 81 UChar nextCharacter) const { |
82 const HTMLEntityTableEntry* left = m_first; | 82 const HTMLEntityTableEntry* left = m_first; |
83 const HTMLEntityTableEntry* right = m_last; | 83 const HTMLEntityTableEntry* right = m_last; |
84 if (left == right) | 84 if (left == right) |
85 return right; | 85 return right; |
86 CompareResult result = compare(right, nextCharacter); | 86 CompareResult result = compare(right, nextCharacter); |
87 if (result == Prefix) | 87 if (result == Prefix) |
88 return right; | 88 return right; |
89 if (result == Before) | 89 if (result == Before) |
90 return left; | 90 return left; |
91 while (left + 1 < right) { | 91 while (left + 1 < right) { |
92 const HTMLEntityTableEntry* probe = halfway(left, right); | 92 const HTMLEntityTableEntry* probe = halfway(left, right); |
93 result = compare(probe, nextCharacter); | 93 result = compare(probe, nextCharacter); |
94 if (result == After) | 94 if (result == After) |
95 right = probe; | 95 right = probe; |
96 else { | 96 else { |
97 ASSERT(result == Before || result == Prefix); | 97 DCHECK(result == Before || result == Prefix); |
98 left = probe; | 98 left = probe; |
99 } | 99 } |
100 } | 100 } |
101 ASSERT(left + 1 == right); | 101 DCHECK_EQ(left + 1, right); |
102 return left; | 102 return left; |
103 } | 103 } |
104 | 104 |
105 void HTMLEntitySearch::advance(UChar nextCharacter) { | 105 void HTMLEntitySearch::advance(UChar nextCharacter) { |
106 ASSERT(isEntityPrefix()); | 106 DCHECK(isEntityPrefix()); |
107 if (!m_currentLength) { | 107 if (!m_currentLength) { |
108 m_first = HTMLEntityTable::firstEntryStartingWith(nextCharacter); | 108 m_first = HTMLEntityTable::firstEntryStartingWith(nextCharacter); |
109 m_last = HTMLEntityTable::lastEntryStartingWith(nextCharacter); | 109 m_last = HTMLEntityTable::lastEntryStartingWith(nextCharacter); |
110 if (!m_first || !m_last) | 110 if (!m_first || !m_last) |
111 return fail(); | 111 return fail(); |
112 } else { | 112 } else { |
113 m_first = findFirst(nextCharacter); | 113 m_first = findFirst(nextCharacter); |
114 m_last = findLast(nextCharacter); | 114 m_last = findLast(nextCharacter); |
115 if (m_first == m_last && compare(m_first, nextCharacter) != Prefix) | 115 if (m_first == m_last && compare(m_first, nextCharacter) != Prefix) |
116 return fail(); | 116 return fail(); |
117 } | 117 } |
118 ++m_currentLength; | 118 ++m_currentLength; |
119 if (m_first->length != m_currentLength) { | 119 if (m_first->length != m_currentLength) { |
120 return; | 120 return; |
121 } | 121 } |
122 m_mostRecentMatch = m_first; | 122 m_mostRecentMatch = m_first; |
123 } | 123 } |
124 | 124 |
125 } // namespace blink | 125 } // namespace blink |
OLD | NEW |