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

Side by Side Diff: compiled/Filter.cpp

Issue 29383799: Issue 4988 - [emscripten] Adjust API for Element Hiding Emulation filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Created March 14, 2017, 2:42 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
OLDNEW
1 #include "Filter.h" 1 #include "Filter.h"
2 #include "CommentFilter.h" 2 #include "CommentFilter.h"
3 #include "InvalidFilter.h" 3 #include "InvalidFilter.h"
4 #include "RegExpFilter.h" 4 #include "RegExpFilter.h"
5 #include "BlockingFilter.h" 5 #include "BlockingFilter.h"
6 #include "WhitelistFilter.h" 6 #include "WhitelistFilter.h"
7 #include "ElemHideBase.h" 7 #include "ElemHideBase.h"
8 #include "ElemHideFilter.h" 8 #include "ElemHideFilter.h"
9 #include "ElemHideException.h" 9 #include "ElemHideException.h"
10 #include "CSSPropertyFilter.h" 10 #include "ElemHideEmulationFilter.h"
11 #include "StringMap.h" 11 #include "StringMap.h"
12 12
13 namespace 13 namespace
14 { 14 {
15 StringMap<Filter*> knownFilters(8192); 15 StringMap<Filter*> knownFilters(8192);
16 16
17 void NormalizeWhitespace(DependentString& text) 17 void NormalizeWhitespace(DependentString& text)
18 { 18 {
19 String::size_type start = 0; 19 String::size_type start = 0;
20 String::size_type end = text.length(); 20 String::size_type end = text.length();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 break; 116 break;
117 case Filter::Type::WHITELIST: 117 case Filter::Type::WHITELIST:
118 filter = new WhitelistFilter(text, data.regexp); 118 filter = new WhitelistFilter(text, data.regexp);
119 break; 119 break;
120 case Filter::Type::ELEMHIDE: 120 case Filter::Type::ELEMHIDE:
121 filter = new ElemHideFilter(text, data.elemhide); 121 filter = new ElemHideFilter(text, data.elemhide);
122 break; 122 break;
123 case Filter::Type::ELEMHIDEEXCEPTION: 123 case Filter::Type::ELEMHIDEEXCEPTION:
124 filter = new ElemHideException(text, data.elemhide); 124 filter = new ElemHideException(text, data.elemhide);
125 break; 125 break;
126 case Filter::Type::CSSPROPERTY: 126 case Filter::Type::ELEMHIDEEMULATION:
127 filter = new CSSPropertyFilter(text, data.elemhide); 127 filter = new ElemHideEmulationFilter(text, data.elemhide);
128 if (static_cast<CSSPropertyFilter*>(filter.get())->IsGeneric()) 128 if (static_cast<ElemHideEmulationFilter*>(filter.get())->IsGeneric())
129 filter = new InvalidFilter(text, u"filter_cssproperty_nodomain"_str); 129 filter = new InvalidFilter(text, u"filter_elemhideemulation_nodomain"_st r);
130 break; 130 break;
131 default: 131 default:
132 // This should never happen but just in case 132 // This should never happen but just in case
133 return nullptr; 133 return nullptr;
134 } 134 }
135 135
136 // This is a hack: we looked up the entry using text but create it using 136 // This is a hack: we looked up the entry using text but create it using
137 // filter->mText. This works because both are equal at this point. However, 137 // filter->mText. This works because both are equal at this point. However,
138 // text refers to a temporary buffer which will go away. 138 // text refers to a temporary buffer which will go away.
139 enter_context("Adding to known filters"); 139 enter_context("Adding to known filters");
140 knownFilter.assign(filter->mText, filter.get()); 140 knownFilter.assign(filter->mText, filter.get());
141 exit_context(); 141 exit_context();
142 142
143 return filter.release(); 143 return filter.release();
144 } 144 }
OLDNEW

Powered by Google App Engine
This is Rietveld