| Index: compiled/ElemHide.h | 
| =================================================================== | 
| new file mode 100644 | 
| --- /dev/null | 
| +++ b/compiled/ElemHide.h | 
| @@ -0,0 +1,102 @@ | 
| +/* | 
| + * 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/>. | 
| + */ | 
| + | 
| +/** | 
| + * @fileOverview Element hiding implementation. | 
| + */ | 
| + | 
| +#pragma once | 
| + | 
| +#include <unordered_map> | 
| +#include <vector> | 
| + | 
| +#include "bindings/runtime.h" | 
| +#include "intrusive_ptr.h" | 
| +#include "StringMap.h" | 
| +#include "filter/Filter.h" | 
| +#include "filter/ElemHideBase.h" | 
| +#include "filter/ElemHideException.h" | 
| + | 
| +class _ElemHide_SelectorList : public ref_counted | 
| +{ | 
| +  std::vector<ElemHideBasePtr> mSelectors; | 
| +public: | 
| +  size_t BINDINGS_EXPORTED GetSelectorCount() const | 
| +  { | 
| +    return mSelectors.size(); | 
| +  } | 
| +  DependentString BINDINGS_EXPORTED SelectorAt(size_t idx) const; | 
| +  const String& BINDINGS_EXPORTED FilterKeyAt(size_t idx) const; | 
| + | 
| +  void push_back(ElemHideBasePtr filter) | 
| +  { | 
| +    mSelectors.push_back(filter); | 
| +  } | 
| + | 
| +  void append(const _ElemHide_SelectorList* list) | 
| +  { | 
| +    mSelectors.insert(mSelectors.end(), | 
| +                      list->mSelectors.cbegin(), list->mSelectors.cend()); | 
| +  } | 
| +}; | 
| + | 
| +class ElemHide : public ref_counted | 
| +{ | 
| +  // All filters. Key is filter text. Exception filters excluded. | 
| +  StringMap<ElemHideBasePtr> mFilters; | 
| +  // StringMap is non copyable. std::unordered_map<> it is | 
| +  // Filters by domain. Key is domain. Subkey is filter text. | 
| +  StringMap<std::unordered_map<DependentString,ElemHideBasePtr,StringHash>> mFiltersByDomain; | 
| + | 
| +  // Exceptions. The key is the selector. | 
| +  StringMap<std::vector<ElemHideExceptionPtr>> mExceptions; | 
| +  // Known exceptions. Filter text as keys. | 
| +  StringSet mKnownExceptions; | 
| + | 
| +  // Unconditional selectors. Filter text as key | 
| +  StringSet mUnconditionalSelectors; | 
| + | 
| +  mutable intrusive_ptr<_ElemHide_SelectorList> mUnconditionalSelectorsCache; | 
| + | 
| +  static ElemHide* mInstance; | 
| +public: | 
| +  enum Criteria | 
| +  { | 
| +    ALL_MATCHING = 0, | 
| +    NO_UNCONDITIONAL = 1, | 
| +    SPECIFIC_ONLY = 2, | 
| +  }; | 
| + | 
| +  static ElemHide* BINDINGS_EXPORTED GetInstance() | 
| +  { | 
| +    return mInstance; | 
| +  } | 
| + | 
| +  void BINDINGS_EXPORTED Clear(); | 
| +  void BINDINGS_EXPORTED Add(ElemHideBase& filter); | 
| +  void BINDINGS_EXPORTED Remove(ElemHideBase& filter); | 
| + | 
| +  _ElemHide_SelectorList* BINDINGS_EXPORTED GetSelectorsForDomain(const String& domain, Criteria criteria) const; | 
| +  _ElemHide_SelectorList* BINDINGS_EXPORTED GetUnconditionalSelectors() const; | 
| + | 
| +  ElemHideException* BINDINGS_EXPORTED GetException(const ElemHideBase& filter, | 
| +                                                    DependentString& docDomain) const; | 
| + | 
| +private: | 
| +  void AddToFiltersByDomain(ElemHideBase& filter); | 
| +}; | 
| + | 
|  |