| Index: compiled/ElemHideEmulation.h |
| =================================================================== |
| new file mode 100644 |
| --- /dev/null |
| +++ b/compiled/ElemHideEmulation.h |
| @@ -0,0 +1,62 @@ |
| +/* |
| + * This file is part of Adblock Plus <https://adblockplus.org/>, |
| + * Copyright (C) 2006-present eyeo GmbH |
| + * |
| + * Adblock Plus is free software: you can redistribute it and/or modify |
| + * it under the terms of the GNU General Public License version 3 as |
| + * published by the Free Software Foundation. |
| + * |
| + * Adblock Plus is distributed in the hope that it will be useful, |
| + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| + * GNU General Public License for more details. |
| + * |
| + * You should have received a copy of the GNU General Public License |
| + * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| + */ |
| + |
| +#pragma once |
| + |
| +#include <vector> |
| + |
| +#include "bindings/runtime.h" |
| +#include "intrusive_ptr.h" |
| +#include "filter/ElemHideBase.h" |
| + |
| +class _ElemHideEmulation_FilterList : public ref_counted |
|
sergei
2017/11/16 09:58:07
IMO it's not a good idea to have names starting wi
hub
2017/11/20 19:16:01
That was part of the "spec" but indeed it conflict
|
| +{ |
| + std::vector<ElemHideBasePtr> mFilters; |
| +public: |
| + size_t BINDINGS_EXPORTED GetFilterCount() const |
| + { |
| + return mFilters.size(); |
| + } |
| + ElemHideBase* BINDINGS_EXPORTED FilterAt(size_t idx) |
| + { |
| + return mFilters[idx].get(); |
| + } |
| + |
| + void push_back(ElemHideBasePtr filter) |
|
sergei
2017/11/16 09:58:07
What about using r-value or l-value reference here
hub
2017/11/20 19:16:01
r-value is impossible: we don't want to move the v
sergei
2018/01/25 16:04:00
Acknowledged. Perhaps we should revisit such metho
hub
2018/01/25 19:05:26
Looking at the use case, move doesn't make sense h
|
| + { |
| + mFilters.push_back(filter); |
| + } |
| + |
| +}; |
| + |
| +class ElemHideEmulation : public ref_counted |
| +{ |
| + StringMap<ElemHideBasePtr> mFilters; |
| + |
| + static ElemHideEmulation* mInstance; |
| + |
| +public: |
| + static ElemHideEmulation* BINDINGS_EXPORTED GetInstance() |
|
sergei
2017/11/16 09:58:07
IMO the growth of usage of the singleton pattern i
hub
2017/11/20 19:16:00
yes.
|
| + { |
| + return mInstance; |
| + } |
| + |
| + void BINDINGS_EXPORTED Add(ElemHideBase&); |
| + void BINDINGS_EXPORTED Remove(ElemHideBase&); |
| + void BINDINGS_EXPORTED Clear(); |
| + _ElemHideEmulation_FilterList* BINDINGS_EXPORTED GetRulesForDomain(DependentString&); |
| +}; |