Commit 3671071c authored by Christoph Schwering's avatar Christoph Schwering Committed by Commit Bot

[Autofill] Shifted match field input types two bits to the right.

The MatchFieldTypes enum starts at 1<<2 instead of 1<<0 temporarily.
Since the lowest two bits are used nowhere at the moment, and
MatchFieldTypes will be shifted to the right once the PatternProvider
is launched, we can shift the values in the JSON to the right, and
shift them to the left only at load time in order to match the
MatchFieldTypes enum.

This CL also changes the compression algorithm from gzip to brotli,
which saves about 18% space.

Bug: 1140775
Change-Id: I171d4b67391da7b7934993fd7611a8acecce7fdd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2489080Reviewed-by: default avatarMatthias Körber <koerber@google.com>
Commit-Queue: Christoph Schwering <schwering@google.com>
Cr-Commit-Position: refs/heads/master@{#820795}
parent 7b18dda1
...@@ -60,6 +60,10 @@ bool ParseMatchingPattern(PatternProvider::Map& patterns, ...@@ -60,6 +60,10 @@ bool ParseMatchingPattern(PatternProvider::Map& patterns,
new_pattern.match_field_input_types = match_field_input_types.value(); new_pattern.match_field_input_types = match_field_input_types.value();
new_pattern.language = language; new_pattern.language = language;
// Shift to the right to match the MatchFieldTypes enum, which temporarily
// starts at 1<<2 instead of 1<<0.
new_pattern.match_field_input_types <<= 2;
std::vector<MatchingPattern>* pattern_list = &patterns[field_type][language]; std::vector<MatchingPattern>* pattern_list = &patterns[field_type][language];
pattern_list->push_back(new_pattern); pattern_list->push_back(new_pattern);
......
...@@ -94,7 +94,7 @@ TEST(PatternConfigurationParserTest, WellFormedParsedCorrectly) { ...@@ -94,7 +94,7 @@ TEST(PatternConfigurationParserTest, WellFormedParsedCorrectly) {
ASSERT_EQ("fr", pattern->language); ASSERT_EQ("fr", pattern->language);
ASSERT_NEAR(2.0, pattern->positive_score, 1e-6); ASSERT_NEAR(2.0, pattern->positive_score, 1e-6);
ASSERT_EQ(2, pattern->match_field_attributes); ASSERT_EQ(2, pattern->match_field_attributes);
ASSERT_EQ(3, pattern->match_field_input_types); ASSERT_EQ(3 << 2, pattern->match_field_input_types);
} }
// Test that the parser does not return anything if some |MatchingPattern| // Test that the parser does not return anything if some |MatchingPattern|
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<grit-part> <grit-part>
<include name="IDR_AUTOFILL_REGEX_JSON" file="../autofill/core/browser/pattern_provider/resources/regex_patterns.json" type="BINDATA" compress="gzip" /> <include name="IDR_AUTOFILL_REGEX_JSON" file="../autofill/core/browser/pattern_provider/resources/regex_patterns.json" type="BINDATA" compress="brotli" />
</grit-part> </grit-part>
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