blob: 116573e6a1d7910db92523982377a302ec839067 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
{% from 'macros.tmpl' import license %}
{{license()}}
#include "platform/RuntimeEnabledFeatures.h"
#include "wtf/Assertions.h"
#include "wtf/text/WTFString.h"
namespace {
bool caseInsensitiveEqual(const std::string& a, const std::string& b)
{
if (a.size() != b.size())
return false;
for (size_t i = 0; i < a.size(); ++i) {
if (tolower(a[i]) != tolower(b[i]))
return false;
}
return true;
}
} // namespace
namespace blink {
RuntimeEnabledFeatures::Backup::Backup()
:
{% for feature in standard_features %}
{%+ if not loop.first %}, {% endif -%}m_{{feature.first_lowered_name}}(RuntimeEnabledFeatures::{{feature.first_lowered_name}}Enabled())
{% endfor %}
{
}
void RuntimeEnabledFeatures::Backup::restore()
{
{% for feature in standard_features %}
RuntimeEnabledFeatures::set{{feature.name}}Enabled(m_{{feature.first_lowered_name}});
{% endfor %}
}
{% for feature_set in feature_sets %}
void RuntimeEnabledFeatures::set{{feature_set|capitalize}}FeaturesEnabled(bool enable)
{
{% for feature in features if feature.status == feature_set %}
set{{feature.name}}Enabled(enable);
{% endfor %}
}
{% endfor %}
void RuntimeEnabledFeatures::setFeatureEnabledFromString(const std::string& name, bool isEnabled)
{
{% for feature in standard_features %}
if (caseInsensitiveEqual(name, "{{feature.name}}")) {
set{{feature.name}}Enabled(isEnabled);
return;
}
{% endfor %}
WTF_LOG_ERROR("RuntimeEnabledFeature not recognized: %s", name.c_str());
}
{% for feature in standard_features %}
bool RuntimeEnabledFeatures::is{{feature.name}}Enabled = {{'true' if feature.status == 'stable' else 'false'}};
{% endfor %}
} // namespace blink
|