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

Unified Diff: compiled/ElemHideBase.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.
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
Index: compiled/ElemHideBase.cpp
===================================================================
--- a/compiled/ElemHideBase.cpp
+++ b/compiled/ElemHideBase.cpp
@@ -1,10 +1,9 @@
#include "ElemHideBase.h"
-#include "CSSPropertyFilter.h"
#include "StringScanner.h"
namespace
{
void NormalizeWhitespace(DependentString& text, String::size_type& domainsEnd,
String::size_type& selectorStart)
{
// For element hiding filters we only want to remove spaces preceding the
@@ -28,17 +27,17 @@ namespace
text[pos - delta] = text[pos];
}
selectorStart -= delta;
text.reset(text, 0, len - delta);
}
}
-ElemHideBase::ElemHideBase(Type type, const String& text, const ElemHideBaseData& data)
+ElemHideBase::ElemHideBase(Type type, const String& text, const ElemHideData& data)
: ActiveFilter(type, text, false), mData(data)
{
if (mData.HasDomains())
ParseDomains(mData.GetDomainsSource(mText), u',');
}
Filter::Type ElemHideBase::Parse(DependentString& text, ElemHideData& data)
{
@@ -100,42 +99,18 @@ Filter::Type ElemHideBase::Parse(Depende
// We are done validating, now we can normalize whitespace and the domain part
if (seenSpaces)
NormalizeWhitespace(text, data.mDomainsEnd, data.mSelectorStart);
DependentString(text, 0, data.mDomainsEnd).toLower();
if (exception)
return Type::ELEMHIDEEXCEPTION;
- do
- {
- // Is this a CSS property rule maybe?
- DependentString searchString(u"[-abp-properties="_str);
- data.mPrefixEnd = text.find(searchString, data.mSelectorStart);
- if (data.mPrefixEnd == text.npos ||
- data.mPrefixEnd + searchString.length() + 1 >= text.length())
- {
- break;
- }
-
- data.mRegexpStart = data.mPrefixEnd + searchString.length() + 1;
- char16_t quotation = text[data.mRegexpStart - 1];
- if (quotation != u'\'' && quotation != u'"')
- break;
-
- data.mRegexpEnd = text.find(quotation, data.mRegexpStart);
- if (data.mRegexpEnd == text.npos || data.mRegexpEnd + 1 >= text.length() ||
- text[data.mRegexpEnd + 1] != u']')
- {
- break;
- }
-
- data.mSuffixStart = data.mRegexpEnd + 2;
- return Type::CSSPROPERTY;
- } while (false);
+ if (text.find(u"[-abp-properties="_str, data.mSelectorStart) != text.npos)
sergei 2017/03/24 11:59:26 Nit: issue says "[-abp-properties" but here we use
Wladimir Palant 2017/03/25 18:48:19 Nice catch. Actually, what I wrote in the issue ma
Wladimir Palant 2017/03/27 07:58:00 The conclusion is: I've modified the issue, and we
+ return Type::ELEMHIDEEMULATION;
return Type::ELEMHIDE;
}
OwnedString ElemHideBase::GetSelectorDomain() const
{
/* TODO this is inefficient */
OwnedString result;

Powered by Google App Engine
This is Rietveld