diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/build')
14 files changed, 137 insertions, 41 deletions
diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/css_properties.py b/chromium/third_party/blink/renderer/build/scripts/core/css/css_properties.py index 65ab0e5dcaa..66b3f9d5f50 100755 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/css_properties.py +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/css_properties.py @@ -354,6 +354,10 @@ class CSSProperties(object): ] @property + def properties_by_name(self): + return self._properties_by_name + + @property def properties_by_id(self): return self._properties_by_id diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/make_style_shorthands.py b/chromium/third_party/blink/renderer/build/scripts/core/css/make_style_shorthands.py index a3cab6f8bb4..1799cd5a153 100755 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/make_style_shorthands.py +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/make_style_shorthands.py @@ -34,6 +34,67 @@ from name_utilities import enum_key_for_css_property, id_for_css_property import template_expander +def collect_runtime_flags(properties): + """Returns a list of unique runtime flags used by the properties""" + flags = {p['runtime_flag'] for p in properties if p['runtime_flag']} + return sorted(flags) + + +class Expansion(object): + """A specific (longhand) expansion of a shorthand. + + A shorthand may have multiple expansions, because some of the longhands + might be behind runtime flags. + + The enabled_mask represents which flags are enabled/disabled for this + specific expansion. For example, if flags contains three elements, + and enabled_mask is 0b100, then flags[0] is disabled, flags[1] is disabled, + and flags[2] is enabled. This information is used to produce the correct + list of longhands corresponding to the runtime flags that are enabled/ + disabled. + """ + + def __init__(self, longhands, flags, enabled_mask): + super(Expansion, self).__init__() + self._longhands = longhands + self._flags = flags + self._enabled_mask = enabled_mask + + def is_enabled(self, flag): + return (1 << self._flags.index(flag)) & self._enabled_mask + + @property + def is_empty(self): + return len(self.enabled_longhands) == 0 + + @property + def enabled_longhands(self): + include = lambda longhand: not longhand[ + 'runtime_flag'] or self.is_enabled(longhand['runtime_flag']) + return filter(include, self._longhands) + + @property + def index(self): + return self._enabled_mask + + @property + def flags(self): + return [ + dict(name=flag, enabled=self.is_enabled(flag)) + for flag in self._flags + ] + + +def create_expansions(longhands): + flags = collect_runtime_flags(longhands) + expansions = map(lambda mask: Expansion(longhands, flags, mask), + range(1 << len(flags))) + assert len(expansions) > 0 + # We generate 2^N expansions for N flags, so enforce some limit. + assert len(flags) <= 4, 'Too many runtime flags for a single shorthand' + return expansions + + class StylePropertyShorthandWriter(json5_generator.Writer): class_name = 'StylePropertyShorthand' _FILE_BASENAME = 'style_property_shorthand' @@ -57,6 +118,11 @@ class StylePropertyShorthandWriter(json5_generator.Writer): property_['longhands']) property_['longhand_property_ids'] = map(id_for_css_property, property_['longhands']) + + longhands = map( + lambda name: json5_properties.properties_by_name[name], + property_['longhands']) + property_['expansions'] = create_expansions(longhands) for longhand_enum_key in property_['longhand_enum_keys']: self._longhand_dictionary[longhand_enum_key].append(property_) diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/style_builder_functions.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/style_builder_functions.tmpl index 17f94e9efac..52c3ee74f5e 100644 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/style_builder_functions.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/style_builder_functions.tmpl @@ -359,8 +359,10 @@ To<Longhand>(resolved_property).{{apply_call}}; map.insert(identifier, CounterDirectives()).stored_value->value; {% if action == 'Reset' %} directives.SetResetValue(counter_value); - {% else %} + {% elif action == 'Increment' %} directives.AddIncrementValue(counter_value); + {% else %} + directives.SetSetValue(counter_value); {% endif %} } DCHECK(!map.IsEmpty()); diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/templates/css_value_id_mappings_generated.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/css_value_id_mappings_generated.h.tmpl index a45c640e686..b0ae312b4e3 100644 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/templates/css_value_id_mappings_generated.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/css_value_id_mappings_generated.h.tmpl @@ -6,7 +6,8 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_VALUE_ID_MAPPINGS_GENERATED_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_VALUE_ID_MAPPINGS_GENERATED_H_ -#include "base/logging.h" +#include "base/notreached.h" +#include "base/check_op.h" #include "third_party/blink/renderer/core/css_value_keywords.h" #include "third_party/blink/renderer/core/style/computed_style_base_constants.h" {% for path in include_paths %} diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/templates/style_property_shorthand.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/style_property_shorthand.cc.tmpl index 56d58053aa6..9d5c8a9d298 100644 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/templates/style_property_shorthand.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/style_property_shorthand.cc.tmpl @@ -26,51 +26,72 @@ #include "base/stl_util.h" // for base::size() #include "third_party/blink/renderer/platform/runtime_enabled_features.h" -#include "third_party/blink/renderer/platform/wtf/hash_map.h" -#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h" + +{% macro define_shorthand(property, expansion) -%} + static const CSSProperty* longhands[] = { + {% for longhand in expansion.enabled_longhands %} + &Get{{longhand.property_id}}(), + {% endfor %} + }; + + static const StylePropertyShorthand shorthand( + CSSPropertyID::{{property.enum_key}}, longhands, base::size(longhands)); +{%- endmacro %} namespace blink { {% for property in properties %} + {% set function_prefix = property.name.to_lower_camel_case() %} + {% for expansion in property.expansions[1:] %} -const StylePropertyShorthand& {{property.name.to_lower_camel_case()}}Shorthand() { - static const CSSProperty* longhands[] = { - {% for longhand_id in property.longhand_property_ids %} - &Get{{longhand_id}}(), +static const StylePropertyShorthand* {{function_prefix}}Shorthand{{expansion.index}}() { + {% for flag in expansion.flags %} + if ({{flag.enabled and '!' or ''}}RuntimeEnabledFeatures::{{flag.name}}Enabled()) + return nullptr; {% endfor %} - }; - DEFINE_STATIC_LOCAL(const StylePropertyShorthand, shorthand, - (CSSPropertyID::{{property.enum_key}}, longhands, base::size(longhands))); - return shorthand; + {{define_shorthand(property, expansion)}} + return &shorthand; } -{% endfor %} + {% endfor %} -// TODO(ericwilligers): Retire this when offset-position and offset-anchor ship -const StylePropertyShorthand& offsetShorthandWithoutPositionAnchor() { - static const CSSProperty* offsetProperties[] = { - &GetCSSPropertyOffsetPath(), - &GetCSSPropertyOffsetDistance(), - &GetCSSPropertyOffsetRotate(), - }; - DEFINE_STATIC_LOCAL(const StylePropertyShorthand, offsetLonghands, (CSSPropertyID::kOffset, offsetProperties, base::size(offsetProperties))); - return offsetLonghands; +const StylePropertyShorthand& {{function_prefix}}Shorthand() { + {% if property.expansions|length > 1 %} + {% for expansion in property.expansions[1:] %} + if (const auto* s = {{function_prefix}}Shorthand{{expansion.index}}()) + return *s; + {% endfor %} + + {% endif %} + {% if property.expansions[0].flags %} + {% for flag in property.expansions[0].flags %} + DCHECK({{not flag.enabled and '!' or ''}}RuntimeEnabledFeatures::{{flag.name}}Enabled()); + {% endfor %} + + {% endif %} + {# Note: only expansions[0] can be empty #} + {% if property.expansions[0].is_empty %} + static StylePropertyShorthand empty_shorthand; + return empty_shorthand; + {% else %} + {{define_shorthand(property, property.expansions[0])}} + return shorthand; + {% endif %} } +{% endfor %} // Returns an empty list if the property is not a shorthand const StylePropertyShorthand& shorthandForProperty(CSSPropertyID propertyID) { // FIXME: We shouldn't switch between shorthand/not shorthand based on a runtime flag - static StylePropertyShorthand emptyShorthand; + static StylePropertyShorthand empty_shorthand; - if (propertyID == CSSPropertyID::kOffset && - !RuntimeEnabledFeatures::CSSOffsetPositionAnchorEnabled()) - return offsetShorthandWithoutPositionAnchor(); switch (propertyID) { {% for property in properties %} + {% set function_prefix = property.name.to_lower_camel_case() %} case CSSPropertyID::{{property.enum_key}}: - return {{property.name.to_lower_camel_case()}}Shorthand(); + return {{function_prefix}}Shorthand(); {% endfor %} default: { - return emptyShorthand; + return empty_shorthand; } } } diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/templates/style_property_shorthand.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/style_property_shorthand.h.tmpl index f33388f4f95..baed5f9be98 100644 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/templates/style_property_shorthand.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/style_property_shorthand.h.tmpl @@ -32,18 +32,17 @@ namespace blink { class StylePropertyShorthand { - USING_FAST_MALLOC(StylePropertyShorthand); public: constexpr StylePropertyShorthand() - : properties_(0), + : properties_(nullptr), length_(0), shorthand_id_(CSSPropertyID::kInvalid) {} constexpr StylePropertyShorthand(CSSPropertyID id, const CSSProperty** properties, - unsigned numProperties) + unsigned num_properties) : properties_(properties), - length_(numProperties), + length_(num_properties), shorthand_id_(id) {} const CSSProperty** properties() const { return properties_; } @@ -60,7 +59,6 @@ class StylePropertyShorthand { const StylePropertyShorthand& {{property.name.to_lower_camel_case()}}Shorthand(); {% endfor %} -const StylePropertyShorthand& animationShorthandForParsing(); const StylePropertyShorthand& transitionShorthandForParsing(); // Returns an empty list if the property is not a shorthand. diff --git a/chromium/third_party/blink/renderer/build/scripts/core/style/make_computed_style_base.py b/chromium/third_party/blink/renderer/build/scripts/core/style/make_computed_style_base.py index f929043bbaf..2c6dc43d45c 100755 --- a/chromium/third_party/blink/renderer/build/scripts/core/style/make_computed_style_base.py +++ b/chromium/third_party/blink/renderer/build/scripts/core/style/make_computed_style_base.py @@ -40,7 +40,6 @@ ALIGNMENT_ORDER = [ 'Vector<GridTrackSize>', 'Vector<AtomicString>', 'GridPosition', - 'GapLength', 'AtomicString', 'scoped_refptr', 'Persistent', @@ -52,6 +51,7 @@ ALIGNMENT_ORDER = [ 'IntrinsicLength', 'TextDecorationThickness', # Aligns like float + 'base::Optional<Length>', 'StyleOffsetRotation', 'TransformOrigin', 'ScrollPadding', @@ -70,6 +70,7 @@ ALIGNMENT_ORDER = [ 'BorderValue', 'StyleColor', 'Color', + 'CSSValueID', 'LayoutUnit', 'LineClampValue', 'OutlineValue', diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/element_factory.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/element_factory.cc.tmpl index eb1fd35ec87..dc3f44c5b10 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/element_factory.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/element_factory.cc.tmpl @@ -30,7 +30,7 @@ static {{namespace}}FunctionMap* g_{{namespace|lower}}_constructors = nullptr; static {{namespace}}Element* {{namespace}}{{tag.name.to_upper_camel_case()}}Constructor( Document& document, const CreateElementFlags flags) { {% if tag.runtimeEnabled %} - if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled(&document)) + if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled(document.GetExecutionContext())) return MakeGarbageCollected<{{fallback_interface}}>({{cpp_namespace}}::{{tag|symbol}}Tag, document); {% endif %} return MakeGarbageCollected<{{tag.interface}}>( diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.cc.tmpl index ea03ce43776..1fe22782470 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.cc.tmpl @@ -44,7 +44,7 @@ HTMLElementType htmlElementTypeForTag(const AtomicString& tagName, const Documen {% for tag in tags|sort %} {% if tag.runtimeEnabled %} if (tagName == "{{tag.name}}") { - if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled(document)) { + if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled(document->GetExecutionContext())) { return HTMLElementType::kHTMLUnknownElement; } } diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/instrumenting_probes_impl.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/instrumenting_probes_impl.cc.tmpl index c9c1de31ec7..e703c4eed1f 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/instrumenting_probes_impl.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/instrumenting_probes_impl.cc.tmpl @@ -78,7 +78,7 @@ void {{sink_class}}::Remove{{agent}}({{class_name}}* agent) { {% endfor -%} -void {{sink_class}}::Trace(Visitor* visitor) +void {{sink_class}}::Trace(Visitor* visitor) const { {% for agent in agents %} {% set getter_name = agent | to_snake_case %} diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/internal_settings_generated.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/internal_settings_generated.cc.tmpl index eca77c487df..e6e4336a365 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/internal_settings_generated.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/internal_settings_generated.cc.tmpl @@ -32,7 +32,7 @@ void InternalSettingsGenerated::set{{setting.name.to_upper_camel_case()}}({{sett } {% endfor %} -void InternalSettingsGenerated::Trace(Visitor* visitor) { +void InternalSettingsGenerated::Trace(Visitor* visitor) const { visitor->Trace(page_); ScriptWrappable::Trace(visitor); } diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/internal_settings_generated.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/internal_settings_generated.h.tmpl index eb7b9f283d1..90e41fb8162 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/internal_settings_generated.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/internal_settings_generated.h.tmpl @@ -27,7 +27,7 @@ class InternalSettingsGenerated : public ScriptWrappable { void set{{setting.name.to_upper_camel_case()}}({{setting.type|to_passing_type}} {{setting.name}}); {% endfor %} - void Trace(Visitor*) override; + void Trace(Visitor*) const override; private: Member<Page> page_; diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/probe_sink.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/probe_sink.h.tmpl index 163e9e1e23d..0cc0ba0d2a6 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/probe_sink.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/probe_sink.h.tmpl @@ -37,7 +37,7 @@ class {{export_symbol}} {{sink_class}} final : public GarbageCollected<{{sink_cl {{sink_class}} (const {{sink_class}}&) = delete; {{sink_class}}& operator=(const {{sink_class}}&) = delete; - void Trace(Visitor*); + void Trace(Visitor*) const; {% for agent in agents %} {% set class_name = agent | agent_name_to_class %} diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/web_origin_trials.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/web_origin_trials.cc.tmpl index 83a54424e3c..bc00adf7a34 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/web_origin_trials.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/web_origin_trials.cc.tmpl @@ -16,13 +16,16 @@ bool WebOriginTrials::isTrialEnabled(const WebDocument* web_document, const WebS if (!web_document) return false; if (!origin_trials::IsTrialValid(trial)) return false; + Document* document = *web_document; for (OriginTrialFeature feature : origin_trials::FeaturesForTrial(trial)) { switch (feature) { {% for feature in features %} {% if feature.origin_trial_feature_name %} case OriginTrialFeature::k{{feature.name}}: - if (!RuntimeEnabledFeatures::{{feature.name}}Enabled(*web_document)) + if (!RuntimeEnabledFeatures::{{feature.name}}Enabled( + document->GetExecutionContext())) { return false; + } break; {% endif %} {% endfor %} |