| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 bool FontDataCache::purgeLeastRecentlyUsed(int count) | 118 bool FontDataCache::purgeLeastRecentlyUsed(int count) |
| 119 { | 119 { |
| 120 static bool isPurging; // Guard against reentry when e.g. a deleted FontData
releases its small caps FontData. | 120 static bool isPurging; // Guard against reentry when e.g. a deleted FontData
releases its small caps FontData. |
| 121 if (isPurging) | 121 if (isPurging) |
| 122 return false; | 122 return false; |
| 123 | 123 |
| 124 isPurging = true; | 124 isPurging = true; |
| 125 | 125 |
| 126 Vector<RefPtr<SimpleFontData>, 20> fontDataToDelete; | 126 Vector<RefPtr<SimpleFontData>, 20> fontDataToDelete; |
| 127 ListHashSet<RefPtr<SimpleFontData> >::iterator end = m_inactiveFontData.end(
); | 127 ListHashSet<RefPtr<SimpleFontData>>::iterator end = m_inactiveFontData.end()
; |
| 128 ListHashSet<RefPtr<SimpleFontData> >::iterator it = m_inactiveFontData.begin
(); | 128 ListHashSet<RefPtr<SimpleFontData>>::iterator it = m_inactiveFontData.begin(
); |
| 129 for (int i = 0; i < count && it != end; ++it, ++i) { | 129 for (int i = 0; i < count && it != end; ++it, ++i) { |
| 130 RefPtr<SimpleFontData>& fontData = *it.get(); | 130 RefPtr<SimpleFontData>& fontData = *it.get(); |
| 131 m_cache.remove(fontData->platformData()); | 131 m_cache.remove(fontData->platformData()); |
| 132 // We should not delete SimpleFontData here because deletion can modify
m_inactiveFontData. See http://trac.webkit.org/changeset/44011 | 132 // We should not delete SimpleFontData here because deletion can modify
m_inactiveFontData. See http://trac.webkit.org/changeset/44011 |
| 133 fontDataToDelete.append(fontData); | 133 fontDataToDelete.append(fontData); |
| 134 } | 134 } |
| 135 | 135 |
| 136 if (it == end) { | 136 if (it == end) { |
| 137 // Removed everything | 137 // Removed everything |
| 138 m_inactiveFontData.clear(); | 138 m_inactiveFontData.clear(); |
| 139 } else { | 139 } else { |
| 140 for (int i = 0; i < count; ++i) | 140 for (int i = 0; i < count; ++i) |
| 141 m_inactiveFontData.remove(m_inactiveFontData.begin()); | 141 m_inactiveFontData.remove(m_inactiveFontData.begin()); |
| 142 } | 142 } |
| 143 | 143 |
| 144 bool didWork = fontDataToDelete.size(); | 144 bool didWork = fontDataToDelete.size(); |
| 145 | 145 |
| 146 fontDataToDelete.clear(); | 146 fontDataToDelete.clear(); |
| 147 | 147 |
| 148 isPurging = false; | 148 isPurging = false; |
| 149 | 149 |
| 150 return didWork; | 150 return didWork; |
| 151 } | 151 } |
| 152 | 152 |
| 153 } // namespace blink | 153 } // namespace blink |
| OLD | NEW |