Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 #pragma once | |
2 | |
3 #include <emscripten.h> | |
4 | |
5 #include "Filter.h" | |
6 #include "StringMap.h" | |
7 | |
8 #define FILTER_PROPERTY(type, name, getter, setter) \ | |
9 private:\ | |
10 type name;\ | |
11 public:\ | |
12 type EMSCRIPTEN_KEEPALIVE getter() const\ | |
13 {\ | |
14 return name;\ | |
15 }\ | |
16 void EMSCRIPTEN_KEEPALIVE setter(type value)\ | |
17 {\ | |
18 if (name != value)\ | |
19 {\ | |
20 type oldvalue = name;\ | |
21 name = value;\ | |
22 DependentString action(u"filter."_str #name);\ | |
23 EM_ASM_ARGS({\ | |
24 var filter = new (exports[Filter_mapping[$2]])($1);\ | |
25 FilterNotifier.triggerListeners(getStringData($0), filter, $3, $4);\ | |
sergei
2016/06/16 21:16:22
We need to call filter.delete();
See also https://
Wladimir Palant
2016/12/06 10:47:10
We don't. This doesn't create a filter instance, m
| |
26 }, &action, this, GetType(), value, oldvalue);\ | |
27 }\ | |
28 } | |
29 | |
30 class ActiveFilter : public Filter | |
31 { | |
32 protected: | |
33 typedef StringMap<bool> DomainMap; | |
34 typedef StringSet SitekeySet; | |
35 void ParseDomains(const String& domains, String::value_type separator) const; | |
36 void AddSitekey(const String& sitekey) const; | |
37 virtual DomainMap* GetDomains() const; | |
38 virtual SitekeySet* GetSitekeys() const; | |
39 mutable std::unique_ptr<DomainMap> mDomains; | |
40 mutable std::unique_ptr<SitekeySet> mSitekeys; | |
41 private: | |
42 bool mIgnoreTrailingDot; | |
43 public: | |
44 ActiveFilter(const String& text, bool ignoreTrailingDot); | |
45 FILTER_PROPERTY(bool, mDisabled, GetDisabled, SetDisabled); | |
46 FILTER_PROPERTY(unsigned int, mHitCount, GetHitCount, SetHitCount); | |
47 FILTER_PROPERTY(unsigned int, mLastHit, GetLastHit, SetLastHit); | |
48 static void ToLower(DependentString&& str); | |
sergei
2016/06/16 21:16:27
I would prefer to have it separate from this class
Wladimir Palant
2016/12/06 10:47:12
Ok, String::tolower() then.
| |
49 bool EMSCRIPTEN_KEEPALIVE IsActiveOnDomain(DependentString& docDomain, | |
50 const String& sitekey) const; | |
51 bool EMSCRIPTEN_KEEPALIVE IsActiveOnlyOnDomain(DependentString& docDomain) con st; | |
52 bool EMSCRIPTEN_KEEPALIVE IsGeneric() const; | |
53 OwnedString EMSCRIPTEN_KEEPALIVE Serialize() const; | |
sergei
2016/06/16 21:16:23
Could you please add "override", so it's visible t
Wladimir Palant
2016/12/06 10:47:17
It's not a virtual method, hence no "override" her
sergei
2017/01/10 15:57:18
Acknowledged.
| |
54 }; | |
OLD | NEW |