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

Delta Between Two Patch Sets: compiled/CSSPropertyFilter.h

Issue 29333474: Issue 4125 - [emscripten] Convert filter classes to C++ (Closed)
Left Patch Set: How with CSS property filters Created Jan. 20, 2016, 1:12 p.m.
Right Patch Set: Addressed comments from Patch Set 28 Created March 21, 2017, 10:04 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « compiled/BlockingFilter.cpp ('k') | compiled/CSSPropertyFilter.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #ifndef ADBLOCK_PLUS_CSS_PROPERTY_FILTER_H 1 #pragma once
2 #define ADBLOCK_PLUS_CSS_PROPERTY_FILTER_H
3 2
4 #include <cstddef> 3 #include <cstddef>
5 #include <string>
6 4
7 #include "Filter.h" 5 #include "Filter.h"
8 #include "ElemHideBase.h" 6 #include "ElemHideBase.h"
9 7
10 class CSSPropertyFilter: public ElemHideBase 8 struct CSSPropertyFilterData
11 { 9 {
12 private: 10 String::size_type mPrefixEnd;
13 std::u16string regexp; 11 String::size_type mRegexpStart;
14 std::u16string prefix; 12 String::size_type mRegexpEnd;
15 std::u16string suffix; 13 String::size_type mSuffixStart;
16 public: 14
17 CSSPropertyFilter(const std::u16string& text, const std::u16string& domains, 15 const DependentString GetSelectorPrefix(const String& text,
18 const std::u16string& selector, const std::u16string& regexpSource, 16 String::size_type selectorStart) const
19 const std::u16string& prefix, const std::u16string& suffix);
20 Type GetType() const;
21 const std::u16string GetRegExpString()
22 { 17 {
23 return regexp; 18 return DependentString(text, selectorStart, mPrefixEnd - selectorStart);
24 } 19 }
25 const std::u16string GetSelectorPrefix() 20
21 const DependentString GetRegExpSource(const String& text) const
26 { 22 {
27 return prefix; 23 return DependentString(text, mRegexpStart, mRegexpEnd - mRegexpStart);
28 } 24 }
29 const std::u16string GetSelectorSuffix() 25
26 const DependentString GetSelectorSuffix(const String& text) const
30 { 27 {
31 return suffix; 28 return DependentString(text, mSuffixStart);
32 } 29 }
33 }; 30 };
34 31
35 #endif 32 struct ElemHideData : ElemHideBaseData, CSSPropertyFilterData
33 {
34 };
35
36 class CSSPropertyFilter: public ElemHideBase
37 {
38 protected:
39 CSSPropertyFilterData mPropertyData;
40 public:
41 explicit CSSPropertyFilter(const String& text, const ElemHideData& data);
42 EMSCRIPTEN_KEEPALIVE OwnedString GetRegExpString() const;
43 EMSCRIPTEN_KEEPALIVE const DependentString GetSelectorPrefix() const
44 {
45 return mPropertyData.GetSelectorPrefix(mText, mData.mSelectorStart);
46 }
47 EMSCRIPTEN_KEEPALIVE const DependentString GetSelectorSuffix() const
48 {
49 return mPropertyData.GetSelectorSuffix(mText);
50 }
51 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld