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

Side by Side Diff: src/plugin/PluginFilter.h

Issue 29331055: Issue #1234 - Remove 'CString' from PluginFilter.* (Closed)
Patch Set: remove TokenSequence Created Feb. 4, 2016, 7:48 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/plugin/PluginFilter.cpp » ('j') | src/plugin/PluginFilter.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 16 matching lines...) Expand all
27 }; 27 };
28 28
29 enum CFilterElementHideAttrType 29 enum CFilterElementHideAttrType
30 { 30 {
31 TYPE_NONE = 0, STYLE, ID, CLASS 31 TYPE_NONE = 0, STYLE, ID, CLASS
32 }; 32 };
33 // ============================================================================ 33 // ============================================================================
34 // CFilterElementHideAttrSelector 34 // CFilterElementHideAttrSelector
35 // ============================================================================ 35 // ============================================================================
36 36
37 class CFilterElementHideAttrSelector 37 struct CFilterElementHideAttrSelector
38 { 38 {
39 CFilterElementHideAttrPos m_pos;
40 CFilterElementHideAttrType m_type;
41 std::wstring m_attr;
42 std::wstring m_value;
39 43
40 public: 44 CFilterElementHideAttrSelector()
41 45 : m_type(TYPE_NONE), m_pos(POS_NONE)
42 CFilterElementHideAttrPos m_pos; 46 {
43 47 }
44 CFilterElementHideAttrType m_type;
45
46 CComBSTR m_bstrAttr;
47 CString m_value;
48
49 CFilterElementHideAttrSelector();
50 CFilterElementHideAttrSelector(const CFilterElementHideAttrSelector& filter);
51 ~CFilterElementHideAttrSelector();
52 }; 48 };
53 49
54 50
55 51
56 // ============================================================================ 52 // ============================================================================
57 // CFilterElementHide 53 // CFilterElementHide
58 // ============================================================================ 54 // ============================================================================
59 class CFilterElementHide 55 class CFilterElementHide
60 { 56 {
61 57
62 public: 58 public:
63 59
64 enum ETraverserComplexType 60 enum ETraverserComplexType
65 { 61 {
66 TRAVERSER_TYPE_PARENT, 62 TRAVERSER_TYPE_PARENT,
67 TRAVERSER_TYPE_IMMEDIATE, 63 TRAVERSER_TYPE_IMMEDIATE,
68 TRAVERSER_TYPE_ERROR 64 TRAVERSER_TYPE_ERROR
69 }; 65 };
70 66
71 67 std::wstring m_filterText;
72 CString m_filterText;
73 68
74 // For domain specific filters only 69 // For domain specific filters only
75 CString m_tagId; 70 std::wstring m_tagId;
76 CString m_tagClassName; 71 std::wstring m_tagClassName;
77 CString m_tag; 72 std::wstring m_tag;
78 73
79 std::vector<CFilterElementHideAttrSelector> m_attributeSelectors; 74 std::vector<CFilterElementHideAttrSelector> m_attributeSelectors;
80 std::shared_ptr<CFilterElementHide> m_predecessor; 75 std::shared_ptr<CFilterElementHide> m_predecessor;
81 76
82 CFilterElementHide(const CString& filterText=""); 77 CFilterElementHide(const std::wstring& filterText = L"");
83 CFilterElementHide(const CFilterElementHide& filter); 78 CFilterElementHide(const CFilterElementHide& filter);
84 ETraverserComplexType m_type; 79 ETraverserComplexType m_type;
85 80
86 bool IsMatchFilterElementHide(IHTMLElement* pEl) const; 81 bool IsMatchFilterElementHide(IHTMLElement* pEl) const;
87 82
88 }; 83 };
89 84
90 // ============================================================================ 85 // ============================================================================
91 // CFilter 86 // CFilter
92 // ============================================================================ 87 // ============================================================================
(...skipping 12 matching lines...) Expand all
105 filterTypeUnknown = 3 100 filterTypeUnknown = 3
106 } filterType; 101 } filterType;
107 102
108 enum EFilterType m_filterType; 103 enum EFilterType m_filterType;
109 bool m_isMatchCase; 104 bool m_isMatchCase;
110 bool m_isFirstParty; 105 bool m_isFirstParty;
111 bool m_isThirdParty; 106 bool m_isThirdParty;
112 bool m_isFromStart; 107 bool m_isFromStart;
113 bool m_isFromEnd; 108 bool m_isFromEnd;
114 int m_hitCount; 109 int m_hitCount;
115 CString m_filterText; 110 std::wstring m_filterText;
116 111
117 CFilter(const CFilter&); 112 CFilter(const CFilter&);
118 CFilter(); 113 CFilter();
119 }; 114 };
120 115
121 // ============================================================================ 116 // ============================================================================
122 // CPluginFilter 117 // CPluginFilter
123 // ============================================================================ 118 // ============================================================================
124 119
125 class CPluginFilter 120 class CPluginFilter
126 { 121 {
127 122
128 private: 123 private:
129 124
130 CString m_dataPath; 125 std::wstring m_dataPath;
131 126
132 // (Tag,Name) -> Filter 127 // (Tag,Name) -> Filter
133 typedef std::multimap<std::pair<CString,CString>, CFilterElementHide> TFilterE lementHideTagsNamed; 128 typedef std::multimap<std::pair<std::wstring, std::wstring>, CFilterElementHid e> TFilterElementHideTagsNamed;
134 129
135 // Tag -> Filter 130 // Tag -> Filter
136 typedef std::multimap<CString, CFilterElementHide> TFilterElementHideTags; 131 typedef std::multimap<std::wstring, CFilterElementHide> TFilterElementHideTags ;
137 132
138 133
139 TFilterElementHideTagsNamed m_elementHideTagsId; 134 TFilterElementHideTagsNamed m_elementHideTagsId;
140 TFilterElementHideTagsNamed m_elementHideTagsClass; 135 TFilterElementHideTagsNamed m_elementHideTagsClass;
141 TFilterElementHideTags m_elementHideTags; 136 TFilterElementHideTags m_elementHideTags;
142 137
143 void ClearFilters(); 138 void ClearFilters();
144 139
145 public: 140 public:
146 CPluginFilter(const CString& dataPath = ""); 141 CPluginFilter(const std::wstring& dataPath = L"");
147 bool LoadHideFilters(std::vector<std::wstring> filters); 142 bool LoadHideFilters(std::vector<std::wstring> filters);
148 bool AddFilterElementHide(CString filter); 143 bool AddFilterElementHide(std::wstring filter);
149 bool IsElementHidden(const std::wstring& tag, IHTMLElement* pEl, const std::ws tring& domain, const std::wstring& indent) const; 144 bool IsElementHidden(const std::wstring& tag, IHTMLElement* pEl, const std::ws tring& domain, const std::wstring& indent) const;
150 HANDLE hideFiltersLoadedEvent; 145 HANDLE hideFiltersLoadedEvent;
151 }; 146 };
152 147
153 148
154 #endif // _PLUGIN_FILTER_H_ 149 #endif // _PLUGIN_FILTER_H_
OLDNEW
« no previous file with comments | « no previous file | src/plugin/PluginFilter.cpp » ('j') | src/plugin/PluginFilter.cpp » ('J')

Powered by Google App Engine
This is Rietveld