Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/plugin/PluginFilter.h

Issue 5316782940225536: Issue 1557 - Update to the recent libadblockplus to reduce additional updates in the logic later. (Closed)
Patch Set: only rebase Created Jan. 28, 2015, 1:20 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/plugin/AdblockPlusDomTraverser.cpp ('k') | src/plugin/PluginFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/plugin/PluginFilter.h
diff --git a/src/plugin/PluginFilter.h b/src/plugin/PluginFilter.h
index 8a45202ead894f29890df9702c08eee37e19da36..4cba774340d3ad6fe861fa097aad82ceb0b58403 100644
--- a/src/plugin/PluginFilter.h
+++ b/src/plugin/PluginFilter.h
@@ -15,177 +15,158 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _PLUGIN_FILTER_H_
-#define _PLUGIN_FILTER_H_
-
-
-#include "PluginTypedef.h"
-#include <memory>
-
-enum CFilterElementHideAttrPos
-{
- POS_NONE = 0, STARTING, ENDING, ANYWHERE, EXACT
-};
-
-enum CFilterElementHideAttrType
-{
- TYPE_NONE = 0, STYLE, ID, CLASS
-};
-// ============================================================================
-// CFilterElementHideAttrSelector
-// ============================================================================
-
-class CFilterElementHideAttrSelector
-{
-
-public:
-
- CFilterElementHideAttrPos m_pos;
-
- CFilterElementHideAttrType m_type;
-
- CComBSTR m_bstrAttr;
- CString m_value;
-
- CFilterElementHideAttrSelector();
- CFilterElementHideAttrSelector(const CFilterElementHideAttrSelector& filter);
- ~CFilterElementHideAttrSelector();
-};
-
-
-
-// ============================================================================
-// CFilterElementHide
-// ============================================================================
-class CFilterElementHide
-{
-
-public:
-
- enum ETraverserComplexType
- {
- TRAVERSER_TYPE_PARENT,
- TRAVERSER_TYPE_IMMEDIATE,
- TRAVERSER_TYPE_ERROR
- };
-
-
- CString m_filterText;
-
- // For domain specific filters only
- CString m_tagId;
- CString m_tagClassName;
- CString m_tag;
-
- std::vector<CFilterElementHideAttrSelector> m_attributeSelectors;
- std::shared_ptr<CFilterElementHide> m_predecessor;
-
- CFilterElementHide(const CString& filterText="");
- CFilterElementHide(const CFilterElementHide& filter);
- ETraverserComplexType m_type;
-
- bool IsMatchFilterElementHide(IHTMLElement* pEl) const;
-
-};
-
-// ============================================================================
-// CFilter
-// ============================================================================
-
-class CFilter
-{
-
-public:
-
- enum EContentType
- {
- contentTypeUnknown = 0,
- contentTypeOther = 1,
- contentTypeScript = 2,
- contentTypeImage = 4,
- contentTypeStyleSheet = 8,
- contentTypeObject = 16,
- contentTypeSubdocument = 32,
- contentTypeDocument = 64,
- contentTypeBackground = 256,
- contentTypeXbl = 512,
- contentTypePing = 1024,
- contentTypeXmlHttpRequest = 2048,
- contentTypeObjectSubrequest = 4096,
- contentTypeDtd = 8192,
- contentTypeAny = 65535
- } contentType;
-
- enum EFilterType
- {
- filterTypeBlocking = 0,
- filterTypeWhiteList = 1,
- filterTypeElementHide = 2,
- filterTypeUnknown = 3
- } filterType;
-
- int m_contentType;
- enum EFilterType m_filterType;
- bool m_isMatchCase;
- bool m_isFirstParty;
- bool m_isThirdParty;
- bool m_isFromStart;
- bool m_isFromEnd;
- int m_hitCount;
- CString m_filterText;
-
- CFilter(const CFilter&);
- CFilter();
-};
-
-// ============================================================================
-// CPluginFilter
-// ============================================================================
-
-class CPluginFilter
-{
-
-private:
-
- CString m_dataPath;
-
- std::map<int, CString> m_contentMapText;
-
- typedef std::map<DWORD, CFilter> TFilterMap;
- typedef std::vector<CFilter> TFilterMapDefault;
-
- // (Tag,Name) -> Filter
- typedef std::multimap<std::pair<CString,CString>, CFilterElementHide> TFilterElementHideTagsNamed;
-
- // Tag -> Filter
- typedef std::multimap<CString, CFilterElementHide> TFilterElementHideTags;
-
-
- TFilterElementHideTagsNamed m_elementHideTagsId;
- TFilterElementHideTagsNamed m_elementHideTagsClass;
- TFilterElementHideTags m_elementHideTags;
-
- TFilterMap m_filterMap[2][2];
- TFilterMapDefault m_filterMapDefault[2];
-
- void ClearFilters();
-
-public:
-
- CPluginFilter(const CString& dataPath = "");
-
- bool LoadHideFilters(std::vector<std::wstring> filters);
-
- bool AddFilterElementHide(CString filter);
-
-
- bool IsElementHidden(const std::wstring& tag, IHTMLElement* pEl, const std::wstring& domain, const std::wstring& indent) const;
-
-
- bool ShouldBlock(const std::wstring& src, int contentType, const std::wstring& domain, bool addDebug=false) const;
-
- HANDLE hideFiltersLoadedEvent;
-};
-
-
-#endif // _PLUGIN_FILTER_H_
+#ifndef _PLUGIN_FILTER_H_
+#define _PLUGIN_FILTER_H_
+
+
+#include "PluginTypedef.h"
+#include <memory>
+#include <AdblockPlus/FilterEngine.h>
+
+enum CFilterElementHideAttrPos
+{
+ POS_NONE = 0, STARTING, ENDING, ANYWHERE, EXACT
+};
+
+enum CFilterElementHideAttrType
+{
+ TYPE_NONE = 0, STYLE, ID, CLASS
+};
+// ============================================================================
+// CFilterElementHideAttrSelector
+// ============================================================================
+
+class CFilterElementHideAttrSelector
+{
+
+public:
+
+ CFilterElementHideAttrPos m_pos;
+
+ CFilterElementHideAttrType m_type;
+
+ CComBSTR m_bstrAttr;
+ CString m_value;
+
+ CFilterElementHideAttrSelector();
+ CFilterElementHideAttrSelector(const CFilterElementHideAttrSelector& filter);
+ ~CFilterElementHideAttrSelector();
+};
+
+
+
+// ============================================================================
+// CFilterElementHide
+// ============================================================================
+class CFilterElementHide
+{
+
+public:
+
+ enum ETraverserComplexType
+ {
+ TRAVERSER_TYPE_PARENT,
+ TRAVERSER_TYPE_IMMEDIATE,
+ TRAVERSER_TYPE_ERROR
+ };
+
+
+ CString m_filterText;
+
+ // For domain specific filters only
+ CString m_tagId;
+ CString m_tagClassName;
+ CString m_tag;
+
+ std::vector<CFilterElementHideAttrSelector> m_attributeSelectors;
+ std::shared_ptr<CFilterElementHide> m_predecessor;
+
+ CFilterElementHide(const CString& filterText="");
+ CFilterElementHide(const CFilterElementHide& filter);
+ ETraverserComplexType m_type;
+
+ bool IsMatchFilterElementHide(IHTMLElement* pEl) const;
+
+};
+
+// ============================================================================
+// CFilter
+// ============================================================================
+
+class CFilter
+{
+
+public:
+
+
+ enum EFilterType
+ {
+ filterTypeBlocking = 0,
+ filterTypeWhiteList = 1,
+ filterTypeElementHide = 2,
+ filterTypeUnknown = 3
+ } filterType;
+
+ AdblockPlus::FilterEngine::ContentType m_contentType;
+ enum EFilterType m_filterType;
+ bool m_isMatchCase;
+ bool m_isFirstParty;
+ bool m_isThirdParty;
+ bool m_isFromStart;
+ bool m_isFromEnd;
+ int m_hitCount;
+ CString m_filterText;
+
+ CFilter(const CFilter&);
+ CFilter();
+};
+
+// ============================================================================
+// CPluginFilter
+// ============================================================================
+
+class CPluginFilter
+{
+
+private:
+
+ CString m_dataPath;
+
+ typedef std::map<DWORD, CFilter> TFilterMap;
+ typedef std::vector<CFilter> TFilterMapDefault;
+
+ // (Tag,Name) -> Filter
+ typedef std::multimap<std::pair<CString,CString>, CFilterElementHide> TFilterElementHideTagsNamed;
+
+ // Tag -> Filter
+ typedef std::multimap<CString, CFilterElementHide> TFilterElementHideTags;
+
+
+ TFilterElementHideTagsNamed m_elementHideTagsId;
+ TFilterElementHideTagsNamed m_elementHideTagsClass;
+ TFilterElementHideTags m_elementHideTags;
+
+ TFilterMap m_filterMap[2][2];
+ TFilterMapDefault m_filterMapDefault[2];
+
+ void ClearFilters();
+
+public:
+
+ CPluginFilter(const CString& dataPath = "");
+
+ bool LoadHideFilters(std::vector<std::wstring> filters);
+
+ bool AddFilterElementHide(CString filter);
+
+
+ bool IsElementHidden(const std::wstring& tag, IHTMLElement* pEl, const std::wstring& domain, const std::wstring& indent) const;
+
+
+ bool ShouldBlock(const std::wstring& src, AdblockPlus::FilterEngine::ContentType contentType, const std::wstring& domain, bool addDebug=false) const;
+
+ HANDLE hideFiltersLoadedEvent;
+};
+
+
+#endif // _PLUGIN_FILTER_H_
« no previous file with comments | « src/plugin/AdblockPlusDomTraverser.cpp ('k') | src/plugin/PluginFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld