Commit e4df9c61 authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

Remove Important[Author,User,UA]Ranges

This was only needed for the pre-CSSCacade path, and can be now
be removed.

Change-Id: Ib4e93b1ac142abcddeb15f78be616efc75801e1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2299340
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790146}
parent fdd4a770
...@@ -209,11 +209,6 @@ class CORE_EXPORT MatchResult { ...@@ -209,11 +209,6 @@ class CORE_EXPORT MatchResult {
void Reset(); void Reset();
private: private:
friend class ImportantUserRanges;
friend class ImportantUserRangeIterator;
friend class ImportantAuthorRanges;
friend class ImportantAuthorRangeIterator;
MatchedPropertiesVector matched_properties_; MatchedPropertiesVector matched_properties_;
Vector<unsigned, 16> user_range_ends_; Vector<unsigned, 16> user_range_ends_;
Vector<unsigned, 16> author_range_ends_; Vector<unsigned, 16> author_range_ends_;
...@@ -224,112 +219,6 @@ class CORE_EXPORT MatchResult { ...@@ -224,112 +219,6 @@ class CORE_EXPORT MatchResult {
DISALLOW_COPY_AND_ASSIGN(MatchResult); DISALLOW_COPY_AND_ASSIGN(MatchResult);
}; };
class ImportantUserRangeIterator {
STACK_ALLOCATED();
public:
ImportantUserRangeIterator(const MatchResult& result, int end_index)
: result_(result), end_index_(end_index) {}
MatchedPropertiesRange operator*() const {
unsigned range_end = result_.user_range_ends_[end_index_];
unsigned range_begin = end_index_
? result_.user_range_ends_[end_index_ - 1]
: result_.ua_range_end_;
return MatchedPropertiesRange(
result_.GetMatchedProperties().begin() + range_begin,
result_.GetMatchedProperties().begin() + range_end);
}
ImportantUserRangeIterator& operator++() {
--end_index_;
return *this;
}
bool operator==(const ImportantUserRangeIterator& other) const {
return end_index_ == other.end_index_ && &result_ == &other.result_;
}
bool operator!=(const ImportantUserRangeIterator& other) const {
return !(*this == other);
}
private:
const MatchResult& result_;
unsigned end_index_;
};
class ImportantUserRanges {
STACK_ALLOCATED();
public:
explicit ImportantUserRanges(const MatchResult& result) : result_(result) {}
ImportantUserRangeIterator begin() const {
return ImportantUserRangeIterator(result_,
result_.user_range_ends_.size() - 1);
}
ImportantUserRangeIterator end() const {
return ImportantUserRangeIterator(result_, -1);
}
private:
const MatchResult& result_;
};
class ImportantAuthorRangeIterator {
STACK_ALLOCATED();
public:
ImportantAuthorRangeIterator(const MatchResult& result, int end_index)
: result_(result), end_index_(end_index) {}
MatchedPropertiesRange operator*() const {
unsigned range_end = result_.author_range_ends_[end_index_];
unsigned range_begin = end_index_
? result_.author_range_ends_[end_index_ - 1]
: (result_.user_range_ends_.IsEmpty()
? result_.ua_range_end_
: result_.user_range_ends_.back());
return MatchedPropertiesRange(
result_.GetMatchedProperties().begin() + range_begin,
result_.GetMatchedProperties().begin() + range_end);
}
ImportantAuthorRangeIterator& operator++() {
--end_index_;
return *this;
}
bool operator==(const ImportantAuthorRangeIterator& other) const {
return end_index_ == other.end_index_ && &result_ == &other.result_;
}
bool operator!=(const ImportantAuthorRangeIterator& other) const {
return !(*this == other);
}
private:
const MatchResult& result_;
unsigned end_index_;
};
class ImportantAuthorRanges {
STACK_ALLOCATED();
public:
explicit ImportantAuthorRanges(const MatchResult& result) : result_(result) {}
ImportantAuthorRangeIterator begin() const {
return ImportantAuthorRangeIterator(result_,
result_.author_range_ends_.size() - 1);
}
ImportantAuthorRangeIterator end() const {
return ImportantAuthorRangeIterator(result_, -1);
}
private:
const MatchResult& result_;
};
inline bool operator==(const MatchedProperties& a, const MatchedProperties& b) { inline bool operator==(const MatchedProperties& a, const MatchedProperties& b) {
return a.properties == b.properties && return a.properties == b.properties &&
a.types_.link_match_type == b.types_.link_match_type; a.types_.link_match_type == b.types_.link_match_type;
......
...@@ -66,11 +66,6 @@ TEST_F(MatchResultTest, UARules) { ...@@ -66,11 +66,6 @@ TEST_F(MatchResultTest, UARules) {
TestMatchedPropertiesRange(result.UaRules(), 2, ua_sets); TestMatchedPropertiesRange(result.UaRules(), 2, ua_sets);
TestMatchedPropertiesRange(result.UserRules(), 0, nullptr); TestMatchedPropertiesRange(result.UserRules(), 0, nullptr);
TestMatchedPropertiesRange(result.AuthorRules(), 0, nullptr); TestMatchedPropertiesRange(result.AuthorRules(), 0, nullptr);
ImportantAuthorRanges importantAuthor(result);
EXPECT_EQ(importantAuthor.end(), importantAuthor.begin());
ImportantUserRanges importantUser(result);
EXPECT_EQ(importantUser.end(), importantUser.begin());
} }
TEST_F(MatchResultTest, UserRules) { TEST_F(MatchResultTest, UserRules) {
...@@ -88,11 +83,6 @@ TEST_F(MatchResultTest, UserRules) { ...@@ -88,11 +83,6 @@ TEST_F(MatchResultTest, UserRules) {
TestMatchedPropertiesRange(result.UaRules(), 0, nullptr); TestMatchedPropertiesRange(result.UaRules(), 0, nullptr);
TestMatchedPropertiesRange(result.UserRules(), 2, user_sets); TestMatchedPropertiesRange(result.UserRules(), 2, user_sets);
TestMatchedPropertiesRange(result.AuthorRules(), 0, nullptr); TestMatchedPropertiesRange(result.AuthorRules(), 0, nullptr);
ImportantAuthorRanges importantAuthor(result);
EXPECT_EQ(importantAuthor.end(), importantAuthor.begin());
ImportantUserRanges importantUser(result);
EXPECT_EQ(importantUser.end(), ++importantUser.begin());
} }
TEST_F(MatchResultTest, AuthorRules) { TEST_F(MatchResultTest, AuthorRules) {
...@@ -110,11 +100,6 @@ TEST_F(MatchResultTest, AuthorRules) { ...@@ -110,11 +100,6 @@ TEST_F(MatchResultTest, AuthorRules) {
TestMatchedPropertiesRange(result.UaRules(), 0, nullptr); TestMatchedPropertiesRange(result.UaRules(), 0, nullptr);
TestMatchedPropertiesRange(result.UserRules(), 0, nullptr); TestMatchedPropertiesRange(result.UserRules(), 0, nullptr);
TestMatchedPropertiesRange(result.AuthorRules(), 2, author_sets); TestMatchedPropertiesRange(result.AuthorRules(), 2, author_sets);
ImportantAuthorRanges importantAuthor(result);
EXPECT_EQ(importantAuthor.end(), ++importantAuthor.begin());
ImportantUserRanges importantUser(result);
EXPECT_EQ(importantUser.end(), importantUser.begin());
} }
TEST_F(MatchResultTest, AllRules) { TEST_F(MatchResultTest, AllRules) {
...@@ -143,11 +128,6 @@ TEST_F(MatchResultTest, AllRules) { ...@@ -143,11 +128,6 @@ TEST_F(MatchResultTest, AllRules) {
TestMatchedPropertiesRange(result.UaRules(), 2, ua_sets); TestMatchedPropertiesRange(result.UaRules(), 2, ua_sets);
TestMatchedPropertiesRange(result.UserRules(), 2, user_sets); TestMatchedPropertiesRange(result.UserRules(), 2, user_sets);
TestMatchedPropertiesRange(result.AuthorRules(), 2, author_sets); TestMatchedPropertiesRange(result.AuthorRules(), 2, author_sets);
ImportantAuthorRanges importantAuthor(result);
EXPECT_EQ(importantAuthor.end(), ++importantAuthor.begin());
ImportantUserRanges importantUser(result);
EXPECT_EQ(importantUser.end(), ++importantUser.begin());
} }
TEST_F(MatchResultTest, AuthorRulesMultipleScopes) { TEST_F(MatchResultTest, AuthorRulesMultipleScopes) {
...@@ -171,22 +151,6 @@ TEST_F(MatchResultTest, AuthorRulesMultipleScopes) { ...@@ -171,22 +151,6 @@ TEST_F(MatchResultTest, AuthorRulesMultipleScopes) {
TestMatchedPropertiesRange(result.UaRules(), 0, nullptr); TestMatchedPropertiesRange(result.UaRules(), 0, nullptr);
TestMatchedPropertiesRange(result.UserRules(), 0, nullptr); TestMatchedPropertiesRange(result.UserRules(), 0, nullptr);
TestMatchedPropertiesRange(result.AuthorRules(), 4, author_sets); TestMatchedPropertiesRange(result.AuthorRules(), 4, author_sets);
ImportantAuthorRanges importantAuthor(result);
auto iter = importantAuthor.begin();
EXPECT_NE(importantAuthor.end(), iter);
TestMatchedPropertiesRange(*iter, 2, &author_sets[2]);
++iter;
EXPECT_NE(importantAuthor.end(), iter);
TestMatchedPropertiesRange(*iter, 2, author_sets);
++iter;
EXPECT_EQ(importantAuthor.end(), iter);
ImportantUserRanges importantUser(result);
EXPECT_EQ(importantUser.end(), importantUser.begin());
} }
TEST_F(MatchResultTest, AllRulesMultipleScopes) { TEST_F(MatchResultTest, AllRulesMultipleScopes) {
...@@ -219,22 +183,6 @@ TEST_F(MatchResultTest, AllRulesMultipleScopes) { ...@@ -219,22 +183,6 @@ TEST_F(MatchResultTest, AllRulesMultipleScopes) {
TestMatchedPropertiesRange(result.UaRules(), 2, ua_sets); TestMatchedPropertiesRange(result.UaRules(), 2, ua_sets);
TestMatchedPropertiesRange(result.UserRules(), 2, user_sets); TestMatchedPropertiesRange(result.UserRules(), 2, user_sets);
TestMatchedPropertiesRange(result.AuthorRules(), 4, author_sets); TestMatchedPropertiesRange(result.AuthorRules(), 4, author_sets);
ImportantAuthorRanges importantAuthor(result);
ImportantAuthorRangeIterator iter = importantAuthor.begin();
EXPECT_NE(importantAuthor.end(), iter);
TestMatchedPropertiesRange(*iter, 2, &author_sets[2]);
++iter;
EXPECT_NE(importantAuthor.end(), iter);
TestMatchedPropertiesRange(*iter, 2, author_sets);
++iter;
EXPECT_EQ(importantAuthor.end(), iter);
ImportantUserRanges importantUser(result);
EXPECT_EQ(importantUser.end(), ++importantUser.begin());
} }
TEST_F(MatchResultTest, CascadeOriginUserAgent) { TEST_F(MatchResultTest, CascadeOriginUserAgent) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment