| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 176 |
| 177 ElemHide_SelectorList* ElemHide::GetUnconditionalSelectors() const | 177 ElemHide_SelectorList* ElemHide::GetUnconditionalSelectors() const |
| 178 { | 178 { |
| 179 if (!mUnconditionalSelectorsCache) | 179 if (!mUnconditionalSelectorsCache) |
| 180 { | 180 { |
| 181 mUnconditionalSelectorsCache = | 181 mUnconditionalSelectorsCache = |
| 182 intrusive_ptr<ElemHide_SelectorList>(new ElemHide_SelectorList(), false); | 182 intrusive_ptr<ElemHide_SelectorList>(new ElemHide_SelectorList(), false); |
| 183 annotate_address(mUnconditionalSelectorsCache.get(), "ElemHide_SelectorList"
); | 183 annotate_address(mUnconditionalSelectorsCache.get(), "ElemHide_SelectorList"
); |
| 184 for (const auto& unconditional : mUnconditionalSelectors) | 184 for (const auto& unconditional : mUnconditionalSelectors) |
| 185 { | 185 { |
| 186 if (!(unconditional.is_deleted() || unconditional.is_invalid())) | 186 auto entry = mFilters.find(unconditional.second->GetText()); |
| 187 { | 187 if (entry) |
| 188 auto entry = mFilters.find(unconditional.second->GetText()); | 188 mUnconditionalSelectorsCache->push_back(entry->second); |
| 189 if (entry) | |
| 190 mUnconditionalSelectorsCache->push_back(entry->second); | |
| 191 } | |
| 192 } | 189 } |
| 193 } | 190 } |
| 194 return intrusive_ptr<ElemHide_SelectorList>(mUnconditionalSelectorsCache).rele
ase(); | 191 return intrusive_ptr<ElemHide_SelectorList>(mUnconditionalSelectorsCache).rele
ase(); |
| 195 } | 192 } |
| 196 | 193 |
| 197 ElemHide_SelectorList* ElemHide::GetSelectorsForDomain(const String& domain, | 194 ElemHide_SelectorList* ElemHide::GetSelectorsForDomain(const String& domain, |
| 198 Criteria criteria) const | 195 Criteria criteria) const |
| 199 { | 196 { |
| 200 intrusive_ptr<ElemHide_SelectorList> selectors(new ElemHide_SelectorList(), fa
lse); | 197 intrusive_ptr<ElemHide_SelectorList> selectors(new ElemHide_SelectorList(), fa
lse); |
| 201 annotate_address(selectors.get(), "ElemHide_SelectorList"); | 198 annotate_address(selectors.get(), "ElemHide_SelectorList"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 214 while (true) | 211 while (true) |
| 215 { | 212 { |
| 216 if (specificOnly && currentDomain.empty()) | 213 if (specificOnly && currentDomain.empty()) |
| 217 break; | 214 break; |
| 218 | 215 |
| 219 auto filters = mFiltersByDomain.find(currentDomain); | 216 auto filters = mFiltersByDomain.find(currentDomain); |
| 220 if (filters) | 217 if (filters) |
| 221 { | 218 { |
| 222 for (const auto& entry : filters->second) | 219 for (const auto& entry : filters->second) |
| 223 { | 220 { |
| 224 if (entry.first.is_invalid() || entry.first.is_deleted()) | |
| 225 continue; | |
| 226 | |
| 227 if (seenFilters.find(entry.first)) | 221 if (seenFilters.find(entry.first)) |
| 228 continue; | 222 continue; |
| 229 seenFilters.insert(entry.first); | 223 seenFilters.insert(entry.first); |
| 230 | 224 |
| 231 auto filter = entry.second; | 225 auto filter = entry.second; |
| 232 if (filter && !GetException(*filter, docDomain)) | 226 if (filter && !GetException(*filter, docDomain)) |
| 233 selectors->push_back(filter); | 227 selectors->push_back(filter); |
| 234 } | 228 } |
| 235 } | 229 } |
| 236 | 230 |
| 237 if (currentDomain.empty()) | 231 if (currentDomain.empty()) |
| 238 break; | 232 break; |
| 239 | 233 |
| 240 auto nextDot = currentDomain.find(u'.'); | 234 auto nextDot = currentDomain.find(u'.'); |
| 241 currentDomain = nextDot == String::npos ? | 235 currentDomain = nextDot == String::npos ? |
| 242 u""_str : DependentString(currentDomain, nextDot + 1); | 236 u""_str : DependentString(currentDomain, nextDot + 1); |
| 243 } | 237 } |
| 244 | 238 |
| 245 return selectors.release(); | 239 return selectors.release(); |
| 246 } | 240 } |
| OLD | NEW |