summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/css
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-07-16 11:45:35 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-07-17 08:59:23 +0000
commit552906b0f222c5d5dd11b9fd73829d510980461a (patch)
tree3a11e6ed0538a81dd83b20cf3a4783e297f26d91 /chromium/third_party/blink/renderer/core/css
parent1b05827804eaf047779b597718c03e7d38344261 (diff)
downloadqtwebengine-chromium-552906b0f222c5d5dd11b9fd73829d510980461a.tar.gz
BASELINE: Update Chromium to 83.0.4103.122
Change-Id: Ie3a82f5bb0076eec2a7c6a6162326b4301ee291e Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/core/css')
-rw-r--r--chromium/third_party/blink/renderer/core/css/BUILD.gn25
-rw-r--r--chromium/third_party/blink/renderer/core/css/OWNERS1
-rw-r--r--chromium/third_party/blink/renderer/core/css/abstract_property_set_css_style_declaration.cc28
-rw-r--r--chromium/third_party/blink/renderer/core/css/abstract_property_set_css_style_declaration.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/active_style_sheets.cc18
-rw-r--r--chromium/third_party/blink/renderer/core/css/active_style_sheets.h3
-rw-r--r--chromium/third_party/blink/renderer/core/css/active_style_sheets_test.cc13
-rw-r--r--chromium/third_party/blink/renderer/core/css/affected_by_pseudo_test.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/css.dict4
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_axis_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_basic_shape_values.cc12
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_basic_shape_values.h8
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_border_image_slice_value.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_border_image_slice_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_color_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_computed_style_declaration.cc44
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_computed_style_declaration.h6
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_computed_style_declaration_test.cc8
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_content_distribution_value.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_content_distribution_value.h3
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_counter_value.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_counter_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_crossfade_value.cc22
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_crossfade_value.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_cursor_image_value.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_cursor_image_value.h3
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_custom_ident_value.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_custom_ident_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_custom_property_declaration.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_custom_property_declaration.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_default_style_sheets.cc18
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_default_style_sheets.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_font_face.cc12
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_font_face.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_font_face_rule.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_font_face_rule.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_font_face_source.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_font_face_source.h10
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_font_face_src_value.cc6
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_font_face_src_value.h12
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_font_family_value.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_font_family_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_font_feature_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_font_selector.cc15
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_font_selector.h10
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_font_style_range_value.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_font_style_range_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_font_variation_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_function_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_global_rule_set.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_global_rule_set.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_gradient_value.cc30
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_gradient_value.h85
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_grid_auto_repeat_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_grid_integer_repeat_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_grid_line_names_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_grid_template_areas_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_grouping_rule.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_grouping_rule.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_identifier_value.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_identifier_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_image_generator_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_image_set_value.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_image_set_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_image_value.cc18
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_image_value.h46
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_import_rule.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_import_rule.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_inherited_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_initial_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_invalid_variable_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_keyframe_rule.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_keyframe_rule.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_keyframe_shorthand_value.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_keyframe_shorthand_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_keyframes_rule.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_keyframes_rule.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_layout_function_value.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_layout_function_value.h3
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_light_dark_color_pair.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_math_expression_node.cc61
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_math_expression_node.h19
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_math_function_value.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_math_function_value.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_media_rule.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_media_rule.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_namespace_rule.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_namespace_rule.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_numeric_literal_value.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_numeric_literal_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_page_rule.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_page_rule.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_page_rule_test.cc11
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_paint_image_generator.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_paint_value.cc69
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_paint_value.h10
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_paint_value_test.cc20
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_path_value.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_path_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_pending_interpolation_value.cc19
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_pending_interpolation_value.h61
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_pending_interpolation_value_test.cc54
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_pending_substitution_value.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_pending_substitution_value.h9
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_primitive_value.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_primitive_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_primitive_value_mappings.h51
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_properties.json5484
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_properties_ranking.json58
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_property_equality.cc8
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_property_name.h8
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_property_name_test.cc26
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_property_rule.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_property_rule.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_property_source_data.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_property_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_property_value_set.cc25
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_property_value_set.h48
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_quad_value.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_quad_value.h16
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_ray_value.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_ray_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_reflect_value.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_reflect_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_rule.cc36
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_rule.h36
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_rule_list.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_segmented_font_face.cc69
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_segmented_font_face.h11
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_selector.cc29
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_selector.h10
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_selector_watch.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_selector_watch.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_selector_watch_test.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_shadow_value.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_shadow_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_string_value.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_string_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_style_declaration.cc46
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_style_declaration.h17
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_style_rule.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_style_rule.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_style_sheet.cc43
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_style_sheet.h14
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_style_sheet.idl10
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_style_sheet_test.cc78
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_syntax_definition.cc48
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_syntax_definition.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_test_helpers.cc14
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_test_helpers.h3
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_timing_function_value.h11
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_to_length_conversion_data.cc6
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_to_length_conversion_data.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_unicode_range_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_unset_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_uri_value.cc19
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_uri_value.h10
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_uri_value_test.cc6
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_value.cc20
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_value.h35
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_value_keywords.json538
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_value_list.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_value_list.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_value_pair.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_value_pair.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_value_pool.cc17
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_value_pool.h11
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_variable_data.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_variable_reference_value.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_variable_reference_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_viewport_rule.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_viewport_rule.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map.cc160
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map.h6
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map_test.cc54
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/cross_thread_color_value.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/cross_thread_unsupported_value.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_keyword_value.idl5
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_math_invert.idl2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_math_max.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_math_max.idl5
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_math_min.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_math_min.idl5
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_math_negate.idl2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_math_product.idl5
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_math_sum.idl5
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_matrix_component.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_matrix_component.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_matrix_component.idl4
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_numeric_array.h6
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_numeric_array.idl3
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_numeric_type.idl11
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc8
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_numeric_value.h8
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_perspective.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_perspective.idl5
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_position_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_position_value.idl5
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_resource_value.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_rotate.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_rotate.idl7
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_scale.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_scale.idl5
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_skew.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_skew.idl5
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_skew_x.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_skew_x.idl7
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_skew_y.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_skew_y.idl7
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_style_image_value.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_style_image_value.h3
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_style_value.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_style_variable_reference_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_transform_value.cc8
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_transform_value.h10
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_transform_value.idl3
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_translate.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_translate.idl7
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_unit_value.idl3
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_unparsed_value.cc13
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_unparsed_value.h15
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_unparsed_value.idl2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_color_value.cc15
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_color_value.h7
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_color_value_test.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_style_value.h20
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_url_image_value.cc5
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_url_image_value.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/css_variable_reference_value.idl3
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/declared_style_property_map.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/inline_style_property_map.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/inline_style_property_map_test.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_deferred_image.cc6
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_deferred_image.h7
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map.cc6
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map_test.cc6
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/prepopulated_computed_style_property_map.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/prepopulated_computed_style_property_map.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/prepopulated_computed_style_property_map_test.cc38
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/style_property_map.cc11
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/style_property_map.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/style_property_map.idl2
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/style_property_map_read_only_main_thread.cc10
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/style_value_factory.cc25
-rw-r--r--chromium/third_party/blink/renderer/core/css/document_style_sheet_collection.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/document_style_sheet_collector.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/document_style_sheet_collector.h3
-rw-r--r--chromium/third_party/blink/renderer/core/css/dom_window_css.cc5
-rw-r--r--chromium/third_party/blink/renderer/core/css/dom_window_css.h3
-rw-r--r--chromium/third_party/blink/renderer/core/css/drag_update_test.cc20
-rw-r--r--chromium/third_party/blink/renderer/core/css/element_rule_collector.cc26
-rw-r--r--chromium/third_party/blink/renderer/core/css/element_rule_collector.h10
-rw-r--r--chromium/third_party/blink/renderer/core/css/font_face.cc83
-rw-r--r--chromium/third_party/blink/renderer/core/css/font_face.h11
-rw-r--r--chromium/third_party/blink/renderer/core/css/font_face.idl8
-rw-r--r--chromium/third_party/blink/renderer/core/css/font_face_cache.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/font_face_cache.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/font_face_cache_test.cc6
-rw-r--r--chromium/third_party/blink/renderer/core/css/font_face_set.cc10
-rw-r--r--chromium/third_party/blink/renderer/core/css/font_face_set.h24
-rw-r--r--chromium/third_party/blink/renderer/core/css/font_face_set_document.cc28
-rw-r--r--chromium/third_party/blink/renderer/core/css/font_face_set_document.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/font_face_set_load_event.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/font_face_set_load_event.h5
-rw-r--r--chromium/third_party/blink/renderer/core/css/font_face_set_load_event.idl2
-rw-r--r--chromium/third_party/blink/renderer/core/css/font_face_set_worker.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/font_face_source.h3
-rw-r--r--chromium/third_party/blink/renderer/core/css/fullscreen.css7
-rw-r--r--chromium/third_party/blink/renderer/core/css/inline_css_style_declaration.cc5
-rw-r--r--chromium/third_party/blink/renderer/core/css/inline_css_style_declaration.h10
-rw-r--r--chromium/third_party/blink/renderer/core/css/invalidation/invalidation_set.cc10
-rw-r--r--chromium/third_party/blink/renderer/core/css/invalidation/invalidation_set_test.cc10
-rw-r--r--chromium/third_party/blink/renderer/core/css/invalidation/pending_invalidations.cc1
-rw-r--r--chromium/third_party/blink/renderer/core/css/invalidation/pending_invalidations.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/invalidation/pending_invalidations_test.cc13
-rw-r--r--chromium/third_party/blink/renderer/core/css/invalidation/style_invalidator_test.cc10
-rw-r--r--chromium/third_party/blink/renderer/core/css/local_font_face_source.cc20
-rw-r--r--chromium/third_party/blink/renderer/core/css/local_font_face_source.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/mathml.css30
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_feature_names.json52
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_feature_overrides.cc19
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_list.cc39
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_list.h29
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_list.idl6
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_query_evaluator.cc36
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_query_evaluator.h6
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_query_evaluator_test.cc5
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_query_exp.cc42
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_query_exp.h6
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_query_list.cc10
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_query_list.h10
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_query_list_event.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_query_list_event.idl4
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_query_list_listener.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_query_list_test.cc5
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_query_matcher.cc8
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_query_matcher.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_query_matcher_test.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_query_set_test.cc27
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_value_change.h19
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_values.cc9
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_values.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_values_dynamic.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/media_values_dynamic.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/offscreen_font_selector.cc8
-rw-r--r--chromium/third_party/blink/renderer/core/css/offscreen_font_selector.h6
-rw-r--r--chromium/third_party/blink/renderer/core/css/page_rule_collector.cc6
-rw-r--r--chromium/third_party/blink/renderer/core/css/page_rule_collector.h6
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/at_rule_descriptor_parser.cc31
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css.proto985
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_lazy_parsing_state.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_lazy_parsing_state.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_lazy_property_parser_impl.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_parser.cc24
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_parser.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_parser_context.cc40
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_parser_context.h32
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_parser_fast_paths.cc21
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_parser_impl.cc29
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_parser_impl.h10
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_parser_selector.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_parser_token.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_parser_token.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_property_parser.cc57
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_property_parser.h6
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_property_parser_helpers.cc481
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_property_parser_helpers.h52
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_property_parser_test.cc22
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_proto_converter.cc9
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_selector_parser.cc64
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_selector_parser.h9
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_selector_parser_test.cc17
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_supports_parser.cc262
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_supports_parser.h108
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/css_supports_parser_test.cc390
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/font_variant_east_asian_parser.h24
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/font_variant_ligatures_parser.h6
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/font_variant_numeric_parser.h10
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/media_condition_test.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/media_query_parser.cc47
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/media_query_parser.h25
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/sizes_attribute_parser.cc16
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/sizes_attribute_parser.h7
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/sizes_attribute_parser_test.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/sizes_math_function_parser.cc14
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/sizes_math_function_parser.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/parser/sizes_math_function_parser_test.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/computed_style_utils.cc283
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/computed_style_utils.h15
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/css_direction_aware_resolver.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/css_direction_aware_resolver.h1
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/css_parsing_utils.cc394
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/css_parsing_utils.h65
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/css_parsing_utils_test.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/css_property.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/css_property.h38
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/css_property_ref.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/css_property_ref.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/css_property_test.cc19
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/css_unresolved_property.h13
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/longhand.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property.cc6
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property_test.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc876
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/longhands/variable.h3
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/shorthand.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/properties/shorthands/shorthands_custom.cc116
-rw-r--r--chromium/third_party/blink/renderer/core/css/property_registration.cc17
-rw-r--r--chromium/third_party/blink/renderer/core/css/property_registration.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/property_registry.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/property_set_css_style_declaration.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/property_set_css_style_declaration.h8
-rw-r--r--chromium/third_party/blink/renderer/core/css/pseudo_style_request.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/remote_font_face_source.cc247
-rw-r--r--chromium/third_party/blink/renderer/core/css/remote_font_face_source.h27
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/cascade_expansion.cc189
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/cascade_expansion.h143
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/cascade_expansion_test.cc636
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/cascade_filter.h101
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/cascade_filter_test.cc121
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/cascade_interpolations.h61
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/cascade_interpolations_test.cc46
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/cascade_map.cc70
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/cascade_map.h58
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/cascade_map_test.cc230
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/cascade_origin.h38
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/cascade_priority.h107
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/cascade_priority_test.cc249
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/cascade_resolver.cc72
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/cascade_resolver.h115
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/css_property_priority.h25
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/css_variable_animator.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/css_variable_resolver.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/css_variable_resolver.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/css_variable_resolver_test.cc8
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/element_resolve_context.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/element_resolve_context.h6
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/element_style_resources.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/element_style_resources.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/font_builder.cc50
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/font_builder.h13
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/font_builder_test.cc11
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/font_style_resolver.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/match_request.h6
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/match_result.cc31
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/match_result.h67
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/match_result_test.cc236
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/matched_properties_cache.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/matched_properties_cache.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/media_query_result.h16
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/scoped_style_resolver.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/scoped_style_resolver.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/selector_filter_parent_scope.h9
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/selector_filter_parent_scope_test.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/style_adjuster.cc197
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/style_adjuster_test.cc16
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/style_animator.cc78
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/style_animator.h53
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc96
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/style_builder_converter.h19
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/style_cascade.cc663
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/style_cascade.h491
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/style_cascade_test.cc1225
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/style_resolver.cc1053
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/style_resolver.h43
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/style_resolver_state.cc8
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/style_resolver_state.h34
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/style_resolver_test.cc126
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/style_rule_usage_tracker.cc15
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/style_rule_usage_tracker.h7
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/viewport_style_resolver.cc12
-rw-r--r--chromium/third_party/blink/renderer/core/css/resolver/viewport_style_resolver.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/rule_feature_set.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/css/rule_feature_set.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/rule_feature_set_test.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/rule_set.cc58
-rw-r--r--chromium/third_party/blink/renderer/core/css/rule_set.h15
-rw-r--r--chromium/third_party/blink/renderer/core/css/rule_set_test.cc9
-rw-r--r--chromium/third_party/blink/renderer/core/css/selector_checker.cc81
-rw-r--r--chromium/third_party/blink/renderer/core/css/selector_checker.h67
-rw-r--r--chromium/third_party/blink/renderer/core/css/selector_filter.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/css/selector_filter.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/selector_query.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/selector_query_test.cc8
-rw-r--r--chromium/third_party/blink/renderer/core/css/shadow_tree_style_sheet_collection.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_attribute_mutation_scope.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_change_reason.cc1
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_change_reason.h1
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_color.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_element.cc14
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_element.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_element_test.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_engine.cc306
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_engine.h49
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_engine_test.cc563
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_environment_variables_test.cc6
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_media.cc9
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_media.h6
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_media.idl2
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_property_serializer.cc5
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_property_serializer.h6
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_recalc_root.cc15
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_rule.cc20
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_rule.h33
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_rule_css_style_declaration.cc11
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_rule_css_style_declaration.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_rule_import.cc9
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_rule_import.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_rule_keyframe.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_rule_keyframe.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_rule_namespace.h6
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_sheet_candidate.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_sheet_candidate.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_sheet_collection.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_sheet_collection.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_sheet_contents.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_sheet_contents.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_sheet_list.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_sheet_list.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/style_traversal_root.h2
-rw-r--r--chromium/third_party/blink/renderer/core/css/svg.css7
-rw-r--r--chromium/third_party/blink/renderer/core/css/threaded/font_object_threaded_test.cc6
-rw-r--r--chromium/third_party/blink/renderer/core/css/threaded/text_renderer_threaded_test.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/css/tree_scope_style_sheet_collection.cc6
-rw-r--r--chromium/third_party/blink/renderer/core/css/tree_scope_style_sheet_collection.h4
-rw-r--r--chromium/third_party/blink/renderer/core/css/vision_deficiency.cc73
-rw-r--r--chromium/third_party/blink/renderer/core/css/vision_deficiency.h26
-rw-r--r--chromium/third_party/blink/renderer/core/css/webxr_overlay.css26
490 files changed, 10978 insertions, 6095 deletions
diff --git a/chromium/third_party/blink/renderer/core/css/BUILD.gn b/chromium/third_party/blink/renderer/core/css/BUILD.gn
index bda1f9c8be2..183fd3f3789 100644
--- a/chromium/third_party/blink/renderer/core/css/BUILD.gn
+++ b/chromium/third_party/blink/renderer/core/css/BUILD.gn
@@ -128,8 +128,6 @@ blink_core_sources("css") {
"css_paint_value.h",
"css_path_value.cc",
"css_path_value.h",
- "css_pending_interpolation_value.cc",
- "css_pending_interpolation_value.h",
"css_pending_substitution_value.cc",
"css_pending_substitution_value.h",
"css_primitive_value.cc",
@@ -368,6 +366,7 @@ blink_core_sources("css") {
"media_query_list_listener.h",
"media_query_matcher.cc",
"media_query_matcher.h",
+ "media_value_change.h",
"media_values.cc",
"media_values.h",
"media_values_cached.cc",
@@ -468,6 +467,16 @@ blink_core_sources("css") {
"pseudo_style_request.h",
"remote_font_face_source.cc",
"remote_font_face_source.h",
+ "resolver/cascade_expansion.cc",
+ "resolver/cascade_expansion.h",
+ "resolver/cascade_filter.h",
+ "resolver/cascade_interpolations.h",
+ "resolver/cascade_map.cc",
+ "resolver/cascade_map.h",
+ "resolver/cascade_origin.h",
+ "resolver/cascade_priority.h",
+ "resolver/cascade_resolver.cc",
+ "resolver/cascade_resolver.h",
"resolver/css_property_priority.h",
"resolver/css_to_style_map.cc",
"resolver/css_to_style_map.h",
@@ -497,8 +506,6 @@ blink_core_sources("css") {
"resolver/selector_filter_parent_scope.h",
"resolver/style_adjuster.cc",
"resolver/style_adjuster.h",
- "resolver/style_animator.cc",
- "resolver/style_animator.h",
"resolver/style_builder.cc",
"resolver/style_builder.h",
"resolver/style_builder_converter.cc",
@@ -580,6 +587,8 @@ blink_core_sources("css") {
"style_traversal_root.h",
"tree_scope_style_sheet_collection.cc",
"tree_scope_style_sheet_collection.h",
+ "vision_deficiency.cc",
+ "vision_deficiency.h",
"zoom_adjusted_pixel_value.h",
]
}
@@ -596,7 +605,6 @@ blink_core_tests("unit_tests") {
"css_math_expression_node_test.cc",
"css_page_rule_test.cc",
"css_paint_value_test.cc",
- "css_pending_interpolation_value_test.cc",
"css_primitive_value_test.cc",
"css_property_name_test.cc",
"css_property_value_set_test.cc",
@@ -605,6 +613,7 @@ blink_core_tests("unit_tests") {
"css_style_declaration_test.cc",
"css_style_sheet_test.cc",
"css_syntax_string_parser_test.cc",
+ "cssom/computed_style_property_map_test.cc",
"cssom/cross_thread_style_value_test.cc",
"cssom/css_math_invert_test.cc",
"cssom/css_math_negate_test.cc",
@@ -636,6 +645,7 @@ blink_core_tests("unit_tests") {
"parser/css_parser_token_test.cc",
"parser/css_property_parser_test.cc",
"parser/css_selector_parser_test.cc",
+ "parser/css_supports_parser_test.cc",
"parser/css_tokenizer_test.cc",
"parser/media_condition_test.cc",
"parser/sizes_attribute_parser_test.cc",
@@ -645,6 +655,11 @@ blink_core_tests("unit_tests") {
"properties/css_property_ref_test.cc",
"properties/css_property_test.cc",
"properties/longhands/custom_property_test.cc",
+ "resolver/cascade_expansion_test.cc",
+ "resolver/cascade_filter_test.cc",
+ "resolver/cascade_interpolations_test.cc",
+ "resolver/cascade_map_test.cc",
+ "resolver/cascade_priority_test.cc",
"resolver/css_variable_data_test.cc",
"resolver/css_variable_resolver_test.cc",
"resolver/font_builder_test.cc",
diff --git a/chromium/third_party/blink/renderer/core/css/OWNERS b/chromium/third_party/blink/renderer/core/css/OWNERS
index d1eb1c37ec5..a007a39a025 100644
--- a/chromium/third_party/blink/renderer/core/css/OWNERS
+++ b/chromium/third_party/blink/renderer/core/css/OWNERS
@@ -2,6 +2,7 @@ alancutter@chromium.org
andruud@chromium.org
ericwilligers@chromium.org
futhark@chromium.org
+xiaochengh@chromium.org
# TEAM: layout-dev@chromium.org
# COMPONENT: Blink>CSS
diff --git a/chromium/third_party/blink/renderer/core/css/abstract_property_set_css_style_declaration.cc b/chromium/third_party/blink/renderer/core/css/abstract_property_set_css_style_declaration.cc
index 71b74cf2c96..99fcc338130 100644
--- a/chromium/third_party/blink/renderer/core/css/abstract_property_set_css_style_declaration.cc
+++ b/chromium/third_party/blink/renderer/core/css/abstract_property_set_css_style_declaration.cc
@@ -70,7 +70,8 @@ void AbstractPropertySetCSSStyleDeclaration::setCSSText(
String AbstractPropertySetCSSStyleDeclaration::getPropertyValue(
const String& property_name) {
- CSSPropertyID property_id = cssPropertyID(property_name);
+ CSSPropertyID property_id =
+ cssPropertyID(GetExecutionContext(), property_name);
if (!isValidCSSPropertyID(property_id))
return String();
if (property_id == CSSPropertyID::kVariable)
@@ -80,7 +81,8 @@ String AbstractPropertySetCSSStyleDeclaration::getPropertyValue(
String AbstractPropertySetCSSStyleDeclaration::getPropertyPriority(
const String& property_name) {
- CSSPropertyID property_id = cssPropertyID(property_name);
+ CSSPropertyID property_id =
+ cssPropertyID(GetExecutionContext(), property_name);
if (!isValidCSSPropertyID(property_id))
return String();
@@ -94,7 +96,8 @@ String AbstractPropertySetCSSStyleDeclaration::getPropertyPriority(
String AbstractPropertySetCSSStyleDeclaration::GetPropertyShorthand(
const String& property_name) {
- CSSPropertyID property_id = cssPropertyID(property_name);
+ CSSPropertyID property_id =
+ cssPropertyID(GetExecutionContext(), property_name);
// Custom properties don't have shorthands, so we can ignore them here.
if (!isValidCSSPropertyID(property_id) ||
@@ -108,7 +111,8 @@ String AbstractPropertySetCSSStyleDeclaration::GetPropertyShorthand(
bool AbstractPropertySetCSSStyleDeclaration::IsPropertyImplicit(
const String& property_name) {
- CSSPropertyID property_id = cssPropertyID(property_name);
+ CSSPropertyID property_id =
+ cssPropertyID(GetExecutionContext(), property_name);
// Custom properties don't have shorthands, so we can ignore them here.
if (property_id < firstCSSProperty)
@@ -122,7 +126,8 @@ void AbstractPropertySetCSSStyleDeclaration::setProperty(
const String& value,
const String& priority,
ExceptionState& exception_state) {
- CSSPropertyID property_id = unresolvedCSSPropertyID(property_name);
+ CSSPropertyID property_id =
+ unresolvedCSSPropertyID(execution_context, property_name);
if (!isValidCSSPropertyID(property_id))
return;
@@ -138,7 +143,8 @@ void AbstractPropertySetCSSStyleDeclaration::setProperty(
String AbstractPropertySetCSSStyleDeclaration::removeProperty(
const String& property_name,
ExceptionState& exception_state) {
- CSSPropertyID property_id = cssPropertyID(property_name);
+ CSSPropertyID property_id =
+ cssPropertyID(GetExecutionContext(), property_name);
if (!isValidCSSPropertyID(property_id))
return String();
@@ -170,7 +176,8 @@ AbstractPropertySetCSSStyleDeclaration::GetPropertyCSSValueInternal(
const CSSValue*
AbstractPropertySetCSSStyleDeclaration::GetPropertyCSSValueInternal(
AtomicString custom_property_name) {
- DCHECK_EQ(CSSPropertyID::kVariable, cssPropertyID(custom_property_name));
+ DCHECK_EQ(CSSPropertyID::kVariable,
+ cssPropertyID(GetExecutionContext(), custom_property_name));
return PropertySet().GetPropertyCSSValue(custom_property_name);
}
@@ -212,11 +219,6 @@ void AbstractPropertySetCSSStyleDeclaration::SetPropertyInternal(
if (!did_change)
return;
- Element* parent = ParentElement();
- if (parent) {
- parent->GetDocument().GetStyleEngine().AttributeChangedForElement(
- html_names::kStyleAttr, *parent);
- }
mutation_scope.EnqueueMutationRecord();
}
@@ -233,7 +235,7 @@ bool AbstractPropertySetCSSStyleDeclaration::CssPropertyMatches(
return PropertySet().PropertyMatches(property_id, property_value);
}
-void AbstractPropertySetCSSStyleDeclaration::Trace(blink::Visitor* visitor) {
+void AbstractPropertySetCSSStyleDeclaration::Trace(Visitor* visitor) {
CSSStyleDeclaration::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/abstract_property_set_css_style_declaration.h b/chromium/third_party/blink/renderer/core/css/abstract_property_set_css_style_declaration.h
index e6e7d68239f..2d4ce8c5cc4 100644
--- a/chromium/third_party/blink/renderer/core/css/abstract_property_set_css_style_declaration.h
+++ b/chromium/third_party/blink/renderer/core/css/abstract_property_set_css_style_declaration.h
@@ -42,8 +42,10 @@ class AbstractPropertySetCSSStyleDeclaration : public CSSStyleDeclaration {
public:
virtual Element* ParentElement() const { return nullptr; }
StyleSheetContents* ContextStyleSheet() const;
+ AbstractPropertySetCSSStyleDeclaration(ExecutionContext* context)
+ : CSSStyleDeclaration(context) {}
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
CSSRule* parentRule() const override { return nullptr; }
diff --git a/chromium/third_party/blink/renderer/core/css/active_style_sheets.cc b/chromium/third_party/blink/renderer/core/css/active_style_sheets.cc
index 1359ffeda38..3c9209e0847 100644
--- a/chromium/third_party/blink/renderer/core/css/active_style_sheets.cc
+++ b/chromium/third_party/blink/renderer/core/css/active_style_sheets.cc
@@ -124,22 +124,4 @@ ActiveSheetsChange CompareActiveStyleSheets(
: kActiveSheetsChanged;
}
-bool ClearMediaQueryDependentRuleSets(
- const ActiveStyleSheetVector& active_style_sheets) {
- bool needs_active_style_update = false;
- for (const auto& active_sheet : active_style_sheets) {
- if (const MediaQuerySet* media_queries =
- active_sheet.first->MediaQueries()) {
- if (!media_queries->QueryVector().IsEmpty())
- needs_active_style_update = true;
- }
- StyleSheetContents* contents = active_sheet.first->Contents();
- if (contents->HasMediaQueries()) {
- needs_active_style_update = true;
- contents->ClearRuleSet();
- }
- }
- return needs_active_style_update;
-}
-
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/active_style_sheets.h b/chromium/third_party/blink/renderer/core/css/active_style_sheets.h
index 42fdcf28225..47f3ae5d58c 100644
--- a/chromium/third_party/blink/renderer/core/css/active_style_sheets.h
+++ b/chromium/third_party/blink/renderer/core/css/active_style_sheets.h
@@ -27,9 +27,6 @@ CompareActiveStyleSheets(const ActiveStyleSheetVector& old_style_sheets,
const ActiveStyleSheetVector& new_style_sheets,
HeapHashSet<Member<RuleSet>>& changed_rule_sets);
-bool ClearMediaQueryDependentRuleSets(
- const ActiveStyleSheetVector& active_style_sheets);
-
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_ACTIVE_STYLE_SHEETS_H_
diff --git a/chromium/third_party/blink/renderer/core/css/active_style_sheets_test.cc b/chromium/third_party/blink/renderer/core/css/active_style_sheets_test.cc
index eb111cd6ea6..4f38ad0a53a 100644
--- a/chromium/third_party/blink/renderer/core/css/active_style_sheets_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/active_style_sheets_test.cc
@@ -6,6 +6,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_shadow_root_init.h"
#include "third_party/blink/renderer/core/css/css_style_sheet.h"
#include "third_party/blink/renderer/core/css/media_query_evaluator.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_context.h"
@@ -14,7 +15,6 @@
#include "third_party/blink/renderer/core/css/style_sheet_contents.h"
#include "third_party/blink/renderer/core/css/style_sheet_list.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
-#include "third_party/blink/renderer/core/dom/shadow_root_init.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
@@ -402,7 +402,7 @@ TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_AddRemoveNonMatchingMQ) {
CSSStyleSheet* sheet1 = CreateSheet();
scoped_refptr<MediaQuerySet> mq =
- MediaQueryParser::ParseMediaQuerySet("(min-width: 9000px)");
+ MediaQueryParser::ParseMediaQuerySet("(min-width: 9000px)", nullptr);
sheet1->SetMediaQueries(mq);
sheet1->MatchesMediaQueries(MediaQueryEvaluator());
@@ -436,7 +436,7 @@ TEST_F(ApplyRulesetsTest, AddUniversalRuleToDocument) {
}
TEST_F(ApplyRulesetsTest, AddUniversalRuleToShadowTree) {
- GetDocument().body()->SetInnerHTMLFromString("<div id=host></div>");
+ GetDocument().body()->setInnerHTML("<div id=host></div>");
Element* host = GetElementById("host");
ASSERT_TRUE(host);
@@ -475,7 +475,7 @@ TEST_F(ApplyRulesetsTest, AddFontFaceRuleToDocument) {
}
TEST_F(ApplyRulesetsTest, AddFontFaceRuleToShadowTree) {
- GetDocument().body()->SetInnerHTMLFromString("<div id=host></div>");
+ GetDocument().body()->setInnerHTML("<div id=host></div>");
Element* host = GetElementById("host");
ASSERT_TRUE(host);
@@ -500,14 +500,13 @@ TEST_F(ApplyRulesetsTest, AddFontFaceRuleToShadowTree) {
}
TEST_F(ApplyRulesetsTest, RemoveSheetFromShadowTree) {
- GetDocument().body()->SetInnerHTMLFromString("<div id=host></div>");
+ GetDocument().body()->setInnerHTML("<div id=host></div>");
Element* host = GetElementById("host");
ASSERT_TRUE(host);
ShadowRoot& shadow_root =
host->AttachShadowRootInternal(ShadowRootType::kOpen);
- shadow_root.SetInnerHTMLFromString(
- "<style>::slotted(#dummy){color:pink}</style>");
+ shadow_root.setInnerHTML("<style>::slotted(#dummy){color:pink}</style>");
UpdateAllLifecyclePhasesForTest();
EXPECT_TRUE(GetStyleEngine().TreeBoundaryCrossingScopes().IsEmpty());
diff --git a/chromium/third_party/blink/renderer/core/css/affected_by_pseudo_test.cc b/chromium/third_party/blink/renderer/core/css/affected_by_pseudo_test.cc
index 13e12573a9b..60f1e2bc241 100644
--- a/chromium/third_party/blink/renderer/core/css/affected_by_pseudo_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/affected_by_pseudo_test.cc
@@ -29,8 +29,7 @@ class AffectedByPseudoTest : public PageTestBase {
};
void AffectedByPseudoTest::SetHtmlInnerHTML(const char* html_content) {
- GetDocument().documentElement()->SetInnerHTMLFromString(
- String::FromUTF8(html_content));
+ GetDocument().documentElement()->setInnerHTML(String::FromUTF8(html_content));
UpdateAllLifecyclePhasesForTest();
}
diff --git a/chromium/third_party/blink/renderer/core/css/css.dict b/chromium/third_party/blink/renderer/core/css/css.dict
index 10741b6011f..25069da47a2 100644
--- a/chromium/third_party/blink/renderer/core/css/css.dict
+++ b/chromium/third_party/blink/renderer/core/css/css.dict
@@ -923,6 +923,9 @@
"fieldtext"
"canvas"
"canvastext"
+"jis-b5"
+"jis-b4"
+"hidden-matchable"
# at-rules
"@charset"
@@ -1354,6 +1357,7 @@
"stroke-repeat"
"stroke-size"
"stroke-width"
+"subtree-visibility"
"suffix"
"symbols"
"system"
diff --git a/chromium/third_party/blink/renderer/core/css/css_axis_value.h b/chromium/third_party/blink/renderer/core/css/css_axis_value.h
index 910f55f5601..70017c2f9b2 100644
--- a/chromium/third_party/blink/renderer/core/css/css_axis_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_axis_value.h
@@ -25,7 +25,7 @@ class CSSAxisValue : public CSSValueList {
double Z() const;
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValueList::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_basic_shape_values.cc b/chromium/third_party/blink/renderer/core/css/css_basic_shape_values.cc
index 8c8aa51739e..2de790b7acb 100644
--- a/chromium/third_party/blink/renderer/core/css/css_basic_shape_values.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_basic_shape_values.cc
@@ -143,7 +143,8 @@ bool CSSBasicShapeCircleValue::Equals(
DataEquivalent(radius_, other.radius_);
}
-void CSSBasicShapeCircleValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSBasicShapeCircleValue::TraceAfterDispatch(
+ blink::Visitor* visitor) const {
visitor->Trace(center_x_);
visitor->Trace(center_y_);
visitor->Trace(radius_);
@@ -226,7 +227,8 @@ bool CSSBasicShapeEllipseValue::Equals(
DataEquivalent(radius_y_, other.radius_y_);
}
-void CSSBasicShapeEllipseValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSBasicShapeEllipseValue::TraceAfterDispatch(
+ blink::Visitor* visitor) const {
visitor->Trace(center_x_);
visitor->Trace(center_y_);
visitor->Trace(radius_x_);
@@ -287,7 +289,8 @@ bool CSSBasicShapePolygonValue::Equals(
return CompareCSSValueVector(values_, other.values_);
}
-void CSSBasicShapePolygonValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSBasicShapePolygonValue::TraceAfterDispatch(
+ blink::Visitor* visitor) const {
visitor->Trace(values_);
CSSValue::TraceAfterDispatch(visitor);
}
@@ -435,7 +438,8 @@ bool CSSBasicShapeInsetValue::Equals(
DataEquivalent(bottom_left_radius_, other.bottom_left_radius_);
}
-void CSSBasicShapeInsetValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSBasicShapeInsetValue::TraceAfterDispatch(
+ blink::Visitor* visitor) const {
visitor->Trace(top_);
visitor->Trace(right_);
visitor->Trace(bottom_);
diff --git a/chromium/third_party/blink/renderer/core/css/css_basic_shape_values.h b/chromium/third_party/blink/renderer/core/css/css_basic_shape_values.h
index 027d2841bfa..bfadef67f45 100644
--- a/chromium/third_party/blink/renderer/core/css/css_basic_shape_values.h
+++ b/chromium/third_party/blink/renderer/core/css/css_basic_shape_values.h
@@ -58,7 +58,7 @@ class CSSBasicShapeCircleValue final : public CSSValue {
void SetCenterY(CSSValue* center_y) { center_y_ = center_y; }
void SetRadius(CSSValue* radius) { radius_ = radius; }
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
Member<CSSValue> center_x_;
@@ -84,7 +84,7 @@ class CSSBasicShapeEllipseValue final : public CSSValue {
void SetRadiusX(CSSValue* radius_x) { radius_x_ = radius_x; }
void SetRadiusY(CSSValue* radius_y) { radius_y_ = radius_y; }
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
Member<CSSValue> center_x_;
@@ -116,7 +116,7 @@ class CSSBasicShapePolygonValue final : public CSSValue {
String CustomCSSText() const;
bool Equals(const CSSBasicShapePolygonValue&) const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
HeapVector<Member<CSSPrimitiveValue>> values_;
@@ -180,7 +180,7 @@ class CSSBasicShapeInsetValue final : public CSSValue {
String CustomCSSText() const;
bool Equals(const CSSBasicShapeInsetValue&) const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
Member<CSSPrimitiveValue> top_;
diff --git a/chromium/third_party/blink/renderer/core/css/css_border_image_slice_value.cc b/chromium/third_party/blink/renderer/core/css/css_border_image_slice_value.cc
index a762bdeb656..d18e899527c 100644
--- a/chromium/third_party/blink/renderer/core/css/css_border_image_slice_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_border_image_slice_value.cc
@@ -51,7 +51,8 @@ bool CSSBorderImageSliceValue::Equals(
return fill_ == other.fill_ && DataEquivalent(slices_, other.slices_);
}
-void CSSBorderImageSliceValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSBorderImageSliceValue::TraceAfterDispatch(
+ blink::Visitor* visitor) const {
visitor->Trace(slices_);
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_border_image_slice_value.h b/chromium/third_party/blink/renderer/core/css/css_border_image_slice_value.h
index 27468d6ac8b..6438b0c97a6 100644
--- a/chromium/third_party/blink/renderer/core/css/css_border_image_slice_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_border_image_slice_value.h
@@ -46,7 +46,7 @@ class CSSBorderImageSliceValue : public CSSValue {
bool Equals(const CSSBorderImageSliceValue&) const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
// These four values are used to make "cuts" in the border image. They can be
diff --git a/chromium/third_party/blink/renderer/core/css/css_color_value.h b/chromium/third_party/blink/renderer/core/css/css_color_value.h
index c752b9a4189..2b4d16bd070 100644
--- a/chromium/third_party/blink/renderer/core/css/css_color_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_color_value.h
@@ -32,7 +32,7 @@ class CORE_EXPORT CSSColorValue : public CSSValue {
return color_ == other.color_;
}
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_computed_style_declaration.cc b/chromium/third_party/blink/renderer/core/css/css_computed_style_declaration.cc
index 729b37a3af3..4df6327a8ee 100644
--- a/chromium/third_party/blink/renderer/core/css/css_computed_style_declaration.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_computed_style_declaration.cc
@@ -157,9 +157,7 @@ const CSSPropertyID kComputedPropertyArray[] = {
CSSPropertyID::kRowGap, CSSPropertyID::kWebkitHighlight,
CSSPropertyID::kHyphens, CSSPropertyID::kWebkitHyphenateCharacter,
CSSPropertyID::kWebkitLineBreak, CSSPropertyID::kWebkitLineClamp,
- CSSPropertyID::kWebkitLocale, CSSPropertyID::kWebkitMarginBeforeCollapse,
- CSSPropertyID::kWebkitMarginAfterCollapse,
- CSSPropertyID::kWebkitMaskBoxImage,
+ CSSPropertyID::kWebkitLocale, CSSPropertyID::kWebkitMaskBoxImage,
CSSPropertyID::kWebkitMaskBoxImageOutset,
CSSPropertyID::kWebkitMaskBoxImageRepeat,
CSSPropertyID::kWebkitMaskBoxImageSlice,
@@ -205,7 +203,7 @@ const CSSPropertyID kComputedPropertyArray[] = {
CSSPropertyID::kCy, CSSPropertyID::kX, CSSPropertyID::kY, CSSPropertyID::kR,
CSSPropertyID::kRx, CSSPropertyID::kRy, CSSPropertyID::kTranslate,
CSSPropertyID::kRotate, CSSPropertyID::kScale, CSSPropertyID::kCaretColor,
- CSSPropertyID::kLineBreak};
+ CSSPropertyID::kLineBreak, CSSPropertyID::kMathStyle};
CSSValueID CssIdentifierForFontSizeKeyword(int keyword_size) {
DCHECK_NE(keyword_size, 0);
@@ -228,11 +226,13 @@ void LogUnimplementedPropertyID(const CSSProperty& property) {
} // namespace
const Vector<const CSSProperty*>&
-CSSComputedStyleDeclaration::ComputableProperties() {
+CSSComputedStyleDeclaration::ComputableProperties(
+ const ExecutionContext* execution_context) {
DEFINE_STATIC_LOCAL(Vector<const CSSProperty*>, properties, ());
if (properties.IsEmpty()) {
CSSProperty::FilterWebExposedCSSPropertiesIntoVector(
- kComputedPropertyArray, base::size(kComputedPropertyArray), properties);
+ execution_context, kComputedPropertyArray,
+ base::size(kComputedPropertyArray), properties);
}
return properties;
}
@@ -241,7 +241,8 @@ CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(
Node* n,
bool allow_visited_style,
const String& pseudo_element_name)
- : node_(n),
+ : CSSStyleDeclaration(n ? n->GetExecutionContext() : nullptr),
+ node_(n),
pseudo_element_specifier_(
CSSSelector::ParsePseudoId(pseudo_element_name)),
allow_visited_style_(allow_visited_style) {}
@@ -250,7 +251,8 @@ CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration() = default;
String CSSComputedStyleDeclaration::cssText() const {
StringBuilder result;
- static const Vector<const CSSProperty*>& properties = ComputableProperties();
+ static const Vector<const CSSProperty*>& properties =
+ ComputableProperties(GetExecutionContext());
for (unsigned i = 0; i < properties.size(); i++) {
if (i)
@@ -277,7 +279,7 @@ CSSComputedStyleDeclaration::GetFontSizeCSSValuePreferringKeyword() const {
if (!node_)
return nullptr;
- node_->GetDocument().UpdateStyleAndLayout();
+ node_->GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kEditing);
const ComputedStyle* style =
node_->EnsureComputedStyle(pseudo_element_specifier_);
@@ -387,7 +389,8 @@ const CSSValue* CSSComputedStyleDeclaration::GetPropertyCSSValue(
CSSProperty::Get(property_name.Id()).IsLayoutDependentProperty();
if (is_layout_dependent_property ||
document.GetStyleEngine().HasViewportDependentMediaQueries()) {
- owner->GetDocument().UpdateStyleAndLayout();
+ owner->GetDocument().UpdateStyleAndLayout(
+ DocumentUpdateReason::kJavaScript);
// The style recalc could have caused the styled node to be discarded or
// replaced if it was a PseudoElement so we need to update it.
styled_node = StyledNode();
@@ -408,7 +411,8 @@ const CSSValue* CSSComputedStyleDeclaration::GetPropertyCSSValue(
const ComputedStyle* style = ComputeComputedStyle();
if (property_class.IsLayoutDependent(style, layout_object)) {
- document.UpdateStyleAndLayoutForNode(styled_node);
+ document.UpdateStyleAndLayoutForNode(styled_node,
+ DocumentUpdateReason::kJavaScript);
styled_node = StyledNode();
style = ComputeComputedStyle();
layout_object = StyledLayoutObject();
@@ -444,14 +448,15 @@ String CSSComputedStyleDeclaration::GetPropertyValue(
unsigned CSSComputedStyleDeclaration::length() const {
if (!node_ || !node_->InActiveDocument())
return 0;
- return ComputableProperties().size();
+ return ComputableProperties(GetExecutionContext()).size();
}
String CSSComputedStyleDeclaration::item(unsigned i) const {
if (i >= length())
return "";
- return ComputableProperties()[i]->GetPropertyNameString();
+ return ComputableProperties(GetExecutionContext())[i]
+ ->GetPropertyNameString();
}
bool CSSComputedStyleDeclaration::CssPropertyMatches(
@@ -461,7 +466,8 @@ bool CSSComputedStyleDeclaration::CssPropertyMatches(
(property_value.IsPrimitiveValue() ||
property_value.IsIdentifierValue()) &&
node_) {
- node_->GetDocument().UpdateStyleAndLayout();
+ // This is only used by editing code.
+ node_->GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kEditing);
const ComputedStyle* style =
node_->EnsureComputedStyle(pseudo_element_specifier_);
if (style && style->GetFontDescription().KeywordSize()) {
@@ -478,7 +484,7 @@ bool CSSComputedStyleDeclaration::CssPropertyMatches(
MutableCSSPropertyValueSet* CSSComputedStyleDeclaration::CopyProperties()
const {
- return CopyPropertiesInSet(ComputableProperties());
+ return CopyPropertiesInSet(ComputableProperties(GetExecutionContext()));
}
MutableCSSPropertyValueSet* CSSComputedStyleDeclaration::CopyPropertiesInSet(
@@ -501,7 +507,8 @@ CSSRule* CSSComputedStyleDeclaration::parentRule() const {
String CSSComputedStyleDeclaration::getPropertyValue(
const String& property_name) {
- CSSPropertyID property_id = cssPropertyID(property_name);
+ CSSPropertyID property_id =
+ cssPropertyID(GetExecutionContext(), property_name);
if (!isValidCSSPropertyID(property_id))
return String();
if (property_id == CSSPropertyID::kVariable) {
@@ -561,7 +568,8 @@ const CSSValue* CSSComputedStyleDeclaration::GetPropertyCSSValueInternal(
const CSSValue* CSSComputedStyleDeclaration::GetPropertyCSSValueInternal(
AtomicString custom_property_name) {
- DCHECK_EQ(CSSPropertyID::kVariable, cssPropertyID(custom_property_name));
+ DCHECK_EQ(CSSPropertyID::kVariable,
+ cssPropertyID(GetExecutionContext(), custom_property_name));
return GetPropertyCSSValue(custom_property_name);
}
@@ -584,7 +592,7 @@ void CSSComputedStyleDeclaration::SetPropertyInternal(
"' property is read-only.");
}
-void CSSComputedStyleDeclaration::Trace(blink::Visitor* visitor) {
+void CSSComputedStyleDeclaration::Trace(Visitor* visitor) {
visitor->Trace(node_);
CSSStyleDeclaration::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_computed_style_declaration.h b/chromium/third_party/blink/renderer/core/css/css_computed_style_declaration.h
index 0b699ed9794..e0a5730871c 100644
--- a/chromium/third_party/blink/renderer/core/css/css_computed_style_declaration.h
+++ b/chromium/third_party/blink/renderer/core/css/css_computed_style_declaration.h
@@ -34,6 +34,7 @@
namespace blink {
class ExceptionState;
+class ExecutionContext;
class LayoutObject;
class MutableCSSPropertyValueSet;
class Node;
@@ -42,7 +43,8 @@ class ComputedStyle;
class CORE_EXPORT CSSComputedStyleDeclaration final
: public CSSStyleDeclaration {
public:
- static const Vector<const CSSProperty*>& ComputableProperties();
+ static const Vector<const CSSProperty*>& ComputableProperties(
+ const ExecutionContext*);
CSSComputedStyleDeclaration(Node*,
bool allow_visited_style = false,
@@ -69,7 +71,7 @@ class CORE_EXPORT CSSComputedStyleDeclaration final
unsigned length() const override;
String item(unsigned index) const override;
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
// The styled node is either the node passed into getComputedStyle, or the
diff --git a/chromium/third_party/blink/renderer/core/css/css_computed_style_declaration_test.cc b/chromium/third_party/blink/renderer/core/css/css_computed_style_declaration_test.cc
index 31e4f24b328..88479844002 100644
--- a/chromium/third_party/blink/renderer/core/css/css_computed_style_declaration_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_computed_style_declaration_test.cc
@@ -13,7 +13,7 @@ namespace blink {
class CSSComputedStyleDeclarationTest : public PageTestBase {};
TEST_F(CSSComputedStyleDeclarationTest, CleanAncestorsNoRecalc) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<div id=dirty></div>
<div>
<div id=target style='color:green'></div>
@@ -34,7 +34,7 @@ TEST_F(CSSComputedStyleDeclarationTest, CleanAncestorsNoRecalc) {
}
TEST_F(CSSComputedStyleDeclarationTest, CleanShadowAncestorsNoRecalc) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<div id=dirty></div>
<div id=host></div>
)HTML");
@@ -43,7 +43,7 @@ TEST_F(CSSComputedStyleDeclarationTest, CleanShadowAncestorsNoRecalc) {
ShadowRoot& shadow_root =
host->AttachShadowRootInternal(ShadowRootType::kOpen);
- shadow_root.SetInnerHTMLFromString(R"HTML(
+ shadow_root.setInnerHTML(R"HTML(
<div id=target style='color:green'></div>
)HTML");
@@ -62,7 +62,7 @@ TEST_F(CSSComputedStyleDeclarationTest, CleanShadowAncestorsNoRecalc) {
}
TEST_F(CSSComputedStyleDeclarationTest, NeedsAdjacentStyleRecalc) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
#a + #b { color: green }
</style>
diff --git a/chromium/third_party/blink/renderer/core/css/css_content_distribution_value.cc b/chromium/third_party/blink/renderer/core/css/css_content_distribution_value.cc
index ec16589d085..e0c21b841b0 100644
--- a/chromium/third_party/blink/renderer/core/css/css_content_distribution_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_content_distribution_value.cc
@@ -19,8 +19,6 @@ CSSContentDistributionValue::CSSContentDistributionValue(
position_(position),
overflow_(overflow) {}
-CSSContentDistributionValue::~CSSContentDistributionValue() = default;
-
String CSSContentDistributionValue::CustomCSSText() const {
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
diff --git a/chromium/third_party/blink/renderer/core/css/css_content_distribution_value.h b/chromium/third_party/blink/renderer/core/css/css_content_distribution_value.h
index 5254d95649d..6b96107d732 100644
--- a/chromium/third_party/blink/renderer/core/css/css_content_distribution_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_content_distribution_value.h
@@ -19,7 +19,6 @@ class CSSContentDistributionValue : public CSSValue {
CSSContentDistributionValue(CSSValueID distribution,
CSSValueID position,
CSSValueID overflow);
- ~CSSContentDistributionValue();
CSSValueID Distribution() const { return distribution_; }
@@ -31,7 +30,7 @@ class CSSContentDistributionValue : public CSSValue {
bool Equals(const CSSContentDistributionValue&) const;
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_counter_value.cc b/chromium/third_party/blink/renderer/core/css/css_counter_value.cc
index af96186fe2d..34f1f796232 100644
--- a/chromium/third_party/blink/renderer/core/css/css_counter_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_counter_value.cc
@@ -33,7 +33,7 @@ String CSSCounterValue::CustomCSSText() const {
return result.ToString();
}
-void CSSCounterValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSCounterValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(identifier_);
visitor->Trace(list_style_);
visitor->Trace(separator_);
diff --git a/chromium/third_party/blink/renderer/core/css/css_counter_value.h b/chromium/third_party/blink/renderer/core/css/css_counter_value.h
index 6c5e9b6866e..004b56844de 100644
--- a/chromium/third_party/blink/renderer/core/css/css_counter_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_counter_value.h
@@ -52,7 +52,7 @@ class CSSCounterValue : public CSSValue {
String CustomCSSText() const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
Member<CSSCustomIdentValue> identifier_; // string
diff --git a/chromium/third_party/blink/renderer/core/css/css_crossfade_value.cc b/chromium/third_party/blink/renderer/core/css/css_crossfade_value.cc
index 171afb923b5..5051a541852 100644
--- a/chromium/third_party/blink/renderer/core/css/css_crossfade_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_crossfade_value.cc
@@ -176,14 +176,12 @@ FloatSize CSSCrossfadeValue::FixedSize(
FloatSize from_image_size(from_image->Size());
FloatSize to_image_size(to_image->Size());
- if (from_image->IsSVGImage()) {
- from_image_size =
- ToSVGImage(from_image)->ConcreteObjectSize(default_object_size);
+ if (auto* from_svg_image = DynamicTo<SVGImage>(from_image)) {
+ from_image_size = from_svg_image->ConcreteObjectSize(default_object_size);
}
- if (to_image->IsSVGImage()) {
- to_image_size =
- ToSVGImage(to_image)->ConcreteObjectSize(default_object_size);
+ if (auto* to_svg_image = DynamicTo<SVGImage>(to_image)) {
+ to_image_size = to_svg_image->ConcreteObjectSize(default_object_size);
}
// Rounding issues can cause transitions between images of equal size to
@@ -252,13 +250,13 @@ scoped_refptr<Image> CSSCrossfadeValue::GetImage(
scoped_refptr<Image> from_image_ref(from_image);
scoped_refptr<Image> to_image_ref(to_image);
- if (from_image->IsSVGImage()) {
- from_image_ref = SVGImageForContainer::Create(
- ToSVGImage(from_image), size, 1, UrlForCSSValue(*from_value_));
+ if (auto* from_svg_image = DynamicTo<SVGImage>(from_image)) {
+ from_image_ref = SVGImageForContainer::Create(from_svg_image, size, 1,
+ UrlForCSSValue(*from_value_));
}
- if (to_image->IsSVGImage()) {
- to_image_ref = SVGImageForContainer::Create(ToSVGImage(to_image), size, 1,
+ if (auto* to_svg_image = DynamicTo<SVGImage>(to_image)) {
+ to_image_ref = SVGImageForContainer::Create(to_svg_image, size, 1,
UrlForCSSValue(*to_value_));
}
@@ -311,7 +309,7 @@ bool CSSCrossfadeValue::Equals(const CSSCrossfadeValue& other) const {
DataEquivalent(percentage_value_, other.percentage_value_);
}
-void CSSCrossfadeValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSCrossfadeValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(from_value_);
visitor->Trace(to_value_);
visitor->Trace(percentage_value_);
diff --git a/chromium/third_party/blink/renderer/core/css/css_crossfade_value.h b/chromium/third_party/blink/renderer/core/css/css_crossfade_value.h
index 3b0e9ed9aa1..35bc6bb011d 100644
--- a/chromium/third_party/blink/renderer/core/css/css_crossfade_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_crossfade_value.h
@@ -71,7 +71,7 @@ class CORE_EXPORT CSSCrossfadeValue final : public CSSImageGeneratorValue {
CSSCrossfadeValue* ComputedCSSValue(const ComputedStyle&,
bool allow_visited_style);
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
void Dispose();
@@ -84,7 +84,7 @@ class CORE_EXPORT CSSCrossfadeValue final : public CSSImageGeneratorValue {
: owner_value_(owner_value), ready_(false) {}
~CrossfadeSubimageObserverProxy() override = default;
- void Trace(blink::Visitor* visitor) { visitor->Trace(owner_value_); }
+ void Trace(Visitor* visitor) { visitor->Trace(owner_value_); }
void ImageChanged(ImageResourceContent*, CanDeferInvalidation) override;
bool WillRenderImage() override;
diff --git a/chromium/third_party/blink/renderer/core/css/css_cursor_image_value.cc b/chromium/third_party/blink/renderer/core/css/css_cursor_image_value.cc
index fd8abed813f..913c7b602b4 100644
--- a/chromium/third_party/blink/renderer/core/css/css_cursor_image_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_cursor_image_value.cc
@@ -38,8 +38,6 @@ CSSCursorImageValue::CSSCursorImageValue(const CSSValue& image_value,
DCHECK(image_value.IsImageValue() || image_value.IsImageSetValue());
}
-CSSCursorImageValue::~CSSCursorImageValue() = default;
-
String CSSCursorImageValue::CustomCSSText() const {
StringBuilder result;
result.Append(image_value_->CssText());
@@ -59,7 +57,7 @@ bool CSSCursorImageValue::Equals(const CSSCursorImageValue& other) const {
DataEquivalent(image_value_, other.image_value_);
}
-void CSSCursorImageValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSCursorImageValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(image_value_);
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_cursor_image_value.h b/chromium/third_party/blink/renderer/core/css/css_cursor_image_value.h
index 14b39797ba1..8fd4c478274 100644
--- a/chromium/third_party/blink/renderer/core/css/css_cursor_image_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_cursor_image_value.h
@@ -34,7 +34,6 @@ class CSSCursorImageValue : public CSSValue {
CSSCursorImageValue(const CSSValue& image_value,
bool hot_spot_specified,
const IntPoint& hot_spot);
- ~CSSCursorImageValue();
bool HotSpotSpecified() const { return hot_spot_specified_; }
const IntPoint& HotSpot() const { return hot_spot_; }
@@ -44,7 +43,7 @@ class CSSCursorImageValue : public CSSValue {
bool Equals(const CSSCursorImageValue&) const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
Member<const CSSValue> image_value_;
diff --git a/chromium/third_party/blink/renderer/core/css/css_custom_ident_value.cc b/chromium/third_party/blink/renderer/core/css/css_custom_ident_value.cc
index 257cc010d9e..b3927288c98 100644
--- a/chromium/third_party/blink/renderer/core/css/css_custom_ident_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_custom_ident_value.cc
@@ -31,7 +31,7 @@ String CSSCustomIdentValue::CustomCSSText() const {
return builder.ToString();
}
-void CSSCustomIdentValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSCustomIdentValue::TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_custom_ident_value.h b/chromium/third_party/blink/renderer/core/css/css_custom_ident_value.h
index d60d893ba43..0179c94cdc2 100644
--- a/chromium/third_party/blink/renderer/core/css/css_custom_ident_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_custom_ident_value.h
@@ -36,7 +36,7 @@ class CORE_EXPORT CSSCustomIdentValue : public CSSValue {
: string_ == other.string_;
}
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
AtomicString string_;
diff --git a/chromium/third_party/blink/renderer/core/css/css_custom_property_declaration.cc b/chromium/third_party/blink/renderer/core/css/css_custom_property_declaration.cc
index f0e2f8732a1..887cbed4537 100644
--- a/chromium/third_party/blink/renderer/core/css/css_custom_property_declaration.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_custom_property_declaration.cc
@@ -8,7 +8,8 @@
namespace blink {
-void CSSCustomPropertyDeclaration::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSCustomPropertyDeclaration::TraceAfterDispatch(
+ blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_custom_property_declaration.h b/chromium/third_party/blink/renderer/core/css/css_custom_property_declaration.h
index 57cbd75d1fc..f7d09e70029 100644
--- a/chromium/third_party/blink/renderer/core/css/css_custom_property_declaration.h
+++ b/chromium/third_party/blink/renderer/core/css/css_custom_property_declaration.h
@@ -50,7 +50,7 @@ class CORE_EXPORT CSSCustomPropertyDeclaration : public CSSValue {
return this == &other;
}
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
const AtomicString name_;
diff --git a/chromium/third_party/blink/renderer/core/css/css_default_style_sheets.cc b/chromium/third_party/blink/renderer/core/css/css_default_style_sheets.cc
index 99aa87f59c7..35b4ac04a48 100644
--- a/chromium/third_party/blink/renderer/core/css/css_default_style_sheets.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_default_style_sheets.cc
@@ -128,6 +128,7 @@ void CSSDefaultStyleSheets::PrepareForLeakDetection() {
media_controls_style_sheet_.Clear();
text_track_style_sheet_.Clear();
fullscreen_style_sheet_.Clear();
+ webxr_overlay_style_sheet_.Clear();
// Recreate the default style sheet to clean up possible SVG resources.
String default_rules = UncompressResourceAsASCIIString(IDR_UASTYLE_HTML_CSS) +
LayoutTheme::GetTheme().ExtraDefaultStyleSheet();
@@ -282,6 +283,20 @@ void CSSDefaultStyleSheets::SetMediaControlsStyleSheetLoader(
media_controls_style_sheet_loader_.swap(loader);
}
+bool CSSDefaultStyleSheets::EnsureDefaultStyleSheetForXrOverlay() {
+ if (webxr_overlay_style_sheet_)
+ return false;
+
+ webxr_overlay_style_sheet_ = ParseUASheet(
+ UncompressResourceAsASCIIString(IDR_UASTYLE_WEBXR_OVERLAY_CSS));
+ default_style_->AddRulesFromSheet(webxr_overlay_style_sheet_, ScreenEval());
+ default_print_style_->AddRulesFromSheet(webxr_overlay_style_sheet_,
+ PrintEval());
+ default_forced_color_style_->AddRulesFromSheet(webxr_overlay_style_sheet_,
+ ForcedColorsEval());
+ return true;
+}
+
void CSSDefaultStyleSheets::EnsureDefaultStyleSheetForFullscreen() {
if (fullscreen_style_sheet_)
return;
@@ -295,7 +310,7 @@ void CSSDefaultStyleSheets::EnsureDefaultStyleSheetForFullscreen() {
ScreenEval());
}
-void CSSDefaultStyleSheets::Trace(blink::Visitor* visitor) {
+void CSSDefaultStyleSheets::Trace(Visitor* visitor) {
visitor->Trace(default_style_);
visitor->Trace(default_quirks_style_);
visitor->Trace(default_print_style_);
@@ -311,6 +326,7 @@ void CSSDefaultStyleSheets::Trace(blink::Visitor* visitor) {
visitor->Trace(media_controls_style_sheet_);
visitor->Trace(text_track_style_sheet_);
visitor->Trace(fullscreen_style_sheet_);
+ visitor->Trace(webxr_overlay_style_sheet_);
}
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/css_default_style_sheets.h b/chromium/third_party/blink/renderer/core/css/css_default_style_sheets.h
index 7efd4b60cda..d46f6d86a1a 100644
--- a/chromium/third_party/blink/renderer/core/css/css_default_style_sheets.h
+++ b/chromium/third_party/blink/renderer/core/css/css_default_style_sheets.h
@@ -44,6 +44,7 @@ class CSSDefaultStyleSheets final
CSSDefaultStyleSheets();
bool EnsureDefaultStyleSheetsForElement(const Element&);
+ bool EnsureDefaultStyleSheetForXrOverlay();
void EnsureDefaultStyleSheetForFullscreen();
RuleSet* DefaultStyle() { return default_style_.Get(); }
@@ -87,7 +88,7 @@ class CSSDefaultStyleSheets final
return media_controls_style_sheet_loader_.get();
}
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
void InitializeDefaultStyles();
@@ -108,6 +109,7 @@ class CSSDefaultStyleSheets final
Member<StyleSheetContents> media_controls_style_sheet_;
Member<StyleSheetContents> text_track_style_sheet_;
Member<StyleSheetContents> fullscreen_style_sheet_;
+ Member<StyleSheetContents> webxr_overlay_style_sheet_;
std::unique_ptr<UAStyleSheetLoader> media_controls_style_sheet_loader_;
DISALLOW_COPY_AND_ASSIGN(CSSDefaultStyleSheets);
diff --git a/chromium/third_party/blink/renderer/core/css/css_font_face.cc b/chromium/third_party/blink/renderer/core/css/css_font_face.cc
index 6824c185f60..8794978bc9b 100644
--- a/chromium/third_party/blink/renderer/core/css/css_font_face.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_font_face.cc
@@ -32,6 +32,7 @@
#include "third_party/blink/renderer/core/css/font_face_set_document.h"
#include "third_party/blink/renderer/core/css/font_face_set_worker.h"
#include "third_party/blink/renderer/core/css/remote_font_face_source.h"
+#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/platform/fonts/font_description.h"
#include "third_party/blink/renderer/platform/fonts/simple_font_data.h"
@@ -214,9 +215,12 @@ void CSSFontFace::SetLoadStatus(FontFace::LoadStatusType new_status) {
if (segmented_font_faces_.IsEmpty() || !font_face_->GetExecutionContext())
return;
- if (auto* document = DynamicTo<Document>(font_face_->GetExecutionContext())) {
- if (new_status == FontFace::kLoading)
- FontFaceSetDocument::From(*document)->BeginFontLoading(font_face_);
+ if (auto* window =
+ DynamicTo<LocalDOMWindow>(font_face_->GetExecutionContext())) {
+ if (new_status == FontFace::kLoading) {
+ FontFaceSetDocument::From(*window->document())
+ ->BeginFontLoading(font_face_);
+ }
} else if (auto* scope = DynamicTo<WorkerGlobalScope>(
font_face_->GetExecutionContext())) {
if (new_status == FontFace::kLoading)
@@ -224,7 +228,7 @@ void CSSFontFace::SetLoadStatus(FontFace::LoadStatusType new_status) {
}
}
-void CSSFontFace::Trace(blink::Visitor* visitor) {
+void CSSFontFace::Trace(Visitor* visitor) {
visitor->Trace(segmented_font_faces_);
visitor->Trace(sources_);
visitor->Trace(font_face_);
diff --git a/chromium/third_party/blink/renderer/core/css/css_font_face.h b/chromium/third_party/blink/renderer/core/css/css_font_face.h
index 9f7f7bd14c6..1c725193245 100644
--- a/chromium/third_party/blink/renderer/core/css/css_font_face.h
+++ b/chromium/third_party/blink/renderer/core/css/css_font_face.h
@@ -82,7 +82,7 @@ class CORE_EXPORT CSSFontFace final : public GarbageCollected<CSSFontFace> {
bool HadBlankText() { return IsValid() && sources_.front()->HadBlankText(); }
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
void SetLoadStatus(FontFace::LoadStatusType);
diff --git a/chromium/third_party/blink/renderer/core/css/css_font_face_rule.cc b/chromium/third_party/blink/renderer/core/css/css_font_face_rule.cc
index b3bab3958d1..5e01733b0ba 100644
--- a/chromium/third_party/blink/renderer/core/css/css_font_face_rule.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_font_face_rule.cc
@@ -62,7 +62,7 @@ void CSSFontFaceRule::Reattach(StyleRuleBase* rule) {
properties_cssom_wrapper_->Reattach(font_face_rule_->MutableProperties());
}
-void CSSFontFaceRule::Trace(blink::Visitor* visitor) {
+void CSSFontFaceRule::Trace(Visitor* visitor) {
visitor->Trace(font_face_rule_);
visitor->Trace(properties_cssom_wrapper_);
CSSRule::Trace(visitor);
diff --git a/chromium/third_party/blink/renderer/core/css/css_font_face_rule.h b/chromium/third_party/blink/renderer/core/css/css_font_face_rule.h
index ddb5d457350..6db949a54f4 100644
--- a/chromium/third_party/blink/renderer/core/css/css_font_face_rule.h
+++ b/chromium/third_party/blink/renderer/core/css/css_font_face_rule.h
@@ -46,7 +46,7 @@ class CSSFontFaceRule final : public CSSRule {
StyleRuleFontFace* StyleRule() const { return font_face_rule_.Get(); }
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
CSSRule::Type type() const override { return kFontFaceRule; }
diff --git a/chromium/third_party/blink/renderer/core/css/css_font_face_source.cc b/chromium/third_party/blink/renderer/core/css/css_font_face_source.cc
index b89ad0455aa..50844267eac 100644
--- a/chromium/third_party/blink/renderer/core/css/css_font_face_source.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_font_face_source.cc
@@ -84,7 +84,7 @@ scoped_refptr<SimpleFontData> CSSFontFaceSource::GetFontData(
void CSSFontFaceSource::PruneOldestIfNeeded() {
if (font_cache_key_age.size() > kMaxCachedFontData) {
DCHECK_EQ(font_cache_key_age.size() - 1, kMaxCachedFontData);
- FontCacheKey& key = font_cache_key_age.back();
+ const FontCacheKey& key = font_cache_key_age.back();
auto font_data_entry = font_data_table_.Take(key);
font_cache_key_age.pop_back();
DCHECK_EQ(font_cache_key_age.size(), kMaxCachedFontData);
diff --git a/chromium/third_party/blink/renderer/core/css/css_font_face_source.h b/chromium/third_party/blink/renderer/core/css/css_font_face_source.h
index 7c898d8426c..c0d4dcf95b3 100644
--- a/chromium/third_party/blink/renderer/core/css/css_font_face_source.h
+++ b/chromium/third_party/blink/renderer/core/css/css_font_face_source.h
@@ -74,7 +74,7 @@ class CORE_EXPORT CSSFontFaceSource
virtual bool HadBlankText() { return false; }
virtual void PaintRequested() {}
- virtual void Trace(blink::Visitor* visitor) {}
+ virtual void Trace(Visitor* visitor) {}
protected:
CSSFontFaceSource() = default;
@@ -85,12 +85,8 @@ class CORE_EXPORT CSSFontFaceSource
private:
void PruneOldestIfNeeded();
- using FontDataTable = HashMap<FontCacheKey,
- scoped_refptr<SimpleFontData>,
- FontCacheKeyHash,
- FontCacheKeyTraits>;
- using FontCacheKeyAgeList =
- LinkedHashSet<FontCacheKey, FontCacheKeyHash, FontCacheKeyTraits>;
+ using FontDataTable = HashMap<FontCacheKey, scoped_refptr<SimpleFontData>>;
+ using FontCacheKeyAgeList = LinkedHashSet<FontCacheKey>;
FontDataTable font_data_table_;
FontCacheKeyAgeList font_cache_key_age;
diff --git a/chromium/third_party/blink/renderer/core/css/css_font_face_src_value.cc b/chromium/third_party/blink/renderer/core/css/css_font_face_src_value.cc
index f63019f8f2b..75f347ac69e 100644
--- a/chromium/third_party/blink/renderer/core/css/css_font_face_src_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_font_face_src_value.cc
@@ -90,7 +90,7 @@ FontResource& CSSFontFaceSrcValue::Fetch(ExecutionContext* context,
resource_request.SetReferrerString(referrer_.referrer);
ResourceLoaderOptions options;
options.initiator_info.name = fetch_initiator_type_names::kCSS;
- FetchParameters params(resource_request, options);
+ FetchParameters params(std::move(resource_request), options);
if (base::FeatureList::IsEnabled(
features::kWebFontsCacheAwareTimeoutAdaption)) {
params.SetCacheAwareLoadingEnabled(kIsCacheAwareLoadingEnabled);
@@ -137,7 +137,9 @@ void CSSFontFaceSrcValue::RestoreCachedResourceIfNeeded(
fetched_->GetResource()->Options().content_security_policy_option);
context->Fetcher()->EmulateLoadStartedForInspector(
fetched_->GetResource(), KURL(resource_url),
- mojom::RequestContextType::FONT, fetch_initiator_type_names::kCSS);
+ mojom::RequestContextType::FONT,
+ network::mojom::RequestDestination::kFont,
+ fetch_initiator_type_names::kCSS);
}
bool CSSFontFaceSrcValue::Equals(const CSSFontFaceSrcValue& other) const {
diff --git a/chromium/third_party/blink/renderer/core/css/css_font_face_src_value.h b/chromium/third_party/blink/renderer/core/css/css_font_face_src_value.h
index 437e88d7fd7..b51006a53bc 100644
--- a/chromium/third_party/blink/renderer/core/css/css_font_face_src_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_font_face_src_value.h
@@ -44,7 +44,7 @@ class CORE_EXPORT CSSFontFaceSrcValue : public CSSValue {
const String& specified_resource,
const String& absolute_resource,
const Referrer& referrer,
- ContentSecurityPolicyDisposition should_check_content_security_policy,
+ network::mojom::CSPDisposition should_check_content_security_policy,
OriginClean origin_clean) {
return MakeGarbageCollected<CSSFontFaceSrcValue>(
specified_resource, absolute_resource, referrer, false,
@@ -52,7 +52,7 @@ class CORE_EXPORT CSSFontFaceSrcValue : public CSSValue {
}
static CSSFontFaceSrcValue* CreateLocal(
const String& absolute_resource,
- ContentSecurityPolicyDisposition should_check_content_security_policy,
+ network::mojom::CSPDisposition should_check_content_security_policy,
OriginClean origin_clean) {
return MakeGarbageCollected<CSSFontFaceSrcValue>(
g_empty_string, absolute_resource, Referrer(), true,
@@ -64,7 +64,7 @@ class CORE_EXPORT CSSFontFaceSrcValue : public CSSValue {
const String& absolute_resource,
const Referrer& referrer,
bool local,
- ContentSecurityPolicyDisposition should_check_content_security_policy,
+ network::mojom::CSPDisposition should_check_content_security_policy,
OriginClean origin_clean)
: CSSValue(kFontFaceSrcClass),
absolute_resource_(absolute_resource),
@@ -91,7 +91,7 @@ class CORE_EXPORT CSSFontFaceSrcValue : public CSSValue {
bool Equals(const CSSFontFaceSrcValue&) const;
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(fetched_);
CSSValue::TraceAfterDispatch(visitor);
}
@@ -104,7 +104,7 @@ class CORE_EXPORT CSSFontFaceSrcValue : public CSSValue {
String format_;
const Referrer referrer_;
const bool is_local_;
- const ContentSecurityPolicyDisposition should_check_content_security_policy_;
+ const network::mojom::CSPDisposition should_check_content_security_policy_;
const OriginClean origin_clean_;
class FontResourceHelper : public GarbageCollected<FontResourceHelper>,
@@ -117,7 +117,7 @@ class CORE_EXPORT CSSFontFaceSrcValue : public CSSValue {
SetResource(resource, task_runner);
}
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
FontResourceClient::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_font_family_value.cc b/chromium/third_party/blink/renderer/core/css/css_font_family_value.cc
index 99e4f96e486..e503a32a530 100644
--- a/chromium/third_party/blink/renderer/core/css/css_font_family_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_font_family_value.cc
@@ -29,7 +29,7 @@ String CSSFontFamilyValue::CustomCSSText() const {
return SerializeFontFamily(string_);
}
-void CSSFontFamilyValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSFontFamilyValue::TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_font_family_value.h b/chromium/third_party/blink/renderer/core/css/css_font_family_value.h
index 197efeb0512..0b2dfb03765 100644
--- a/chromium/third_party/blink/renderer/core/css/css_font_family_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_font_family_value.h
@@ -25,7 +25,7 @@ class CORE_EXPORT CSSFontFamilyValue : public CSSValue {
return string_ == other.string_;
}
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
friend class CSSValuePool;
diff --git a/chromium/third_party/blink/renderer/core/css/css_font_feature_value.h b/chromium/third_party/blink/renderer/core/css/css_font_feature_value.h
index aa7db9ed283..3eb15cdd55c 100644
--- a/chromium/third_party/blink/renderer/core/css/css_font_feature_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_font_feature_value.h
@@ -42,7 +42,7 @@ class CSSFontFeatureValue : public CSSValue {
bool Equals(const CSSFontFeatureValue&) const;
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_font_selector.cc b/chromium/third_party/blink/renderer/core/css/css_font_selector.cc
index 1859ab2c578..7708bc41cfa 100644
--- a/chromium/third_party/blink/renderer/core/css/css_font_selector.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_font_selector.cc
@@ -168,7 +168,20 @@ void CSSFontSelector::ReportFailedFontFamilyMatch(
font_family_name);
}
-void CSSFontSelector::Trace(blink::Visitor* visitor) {
+void CSSFontSelector::ReportSuccessfulLocalFontMatch(
+ const AtomicString& font_name) {
+ DCHECK(document_);
+ document_->GetFontMatchingMetrics()->ReportSuccessfulLocalFontMatch(
+ font_name);
+}
+
+void CSSFontSelector::ReportFailedLocalFontMatch(
+ const AtomicString& font_name) {
+ DCHECK(document_);
+ document_->GetFontMatchingMetrics()->ReportFailedLocalFontMatch(font_name);
+}
+
+void CSSFontSelector::Trace(Visitor* visitor) {
visitor->Trace(document_);
visitor->Trace(font_face_cache_);
visitor->Trace(clients_);
diff --git a/chromium/third_party/blink/renderer/core/css/css_font_selector.h b/chromium/third_party/blink/renderer/core/css/css_font_selector.h
index cfcdacf4dae..62baf6b8639 100644
--- a/chromium/third_party/blink/renderer/core/css/css_font_selector.h
+++ b/chromium/third_party/blink/renderer/core/css/css_font_selector.h
@@ -55,6 +55,10 @@ class CORE_EXPORT CSSFontSelector : public FontSelector {
void ReportFailedFontFamilyMatch(
const AtomicString& font_family_name) override;
+ void ReportSuccessfulLocalFontMatch(const AtomicString& font_name) override;
+
+ void ReportFailedLocalFontMatch(const AtomicString& font_name) override;
+
scoped_refptr<FontData> GetFontData(const FontDescription&,
const AtomicString&) override;
void WillUseFontData(const FontDescription&,
@@ -74,7 +78,9 @@ class CORE_EXPORT CSSFontSelector : public FontSelector {
void RegisterForInvalidationCallbacks(FontSelectorClient*) override;
void UnregisterForInvalidationCallbacks(FontSelectorClient*) override;
- ExecutionContext* GetExecutionContext() const override { return document_; }
+ ExecutionContext* GetExecutionContext() const override {
+ return document_ ? document_->GetExecutionContext() : nullptr;
+ }
FontFaceCache* GetFontFaceCache() override { return &font_face_cache_; }
const GenericFontFamilySettings& GetGenericFontFamilySettings() const {
@@ -82,7 +88,7 @@ class CORE_EXPORT CSSFontSelector : public FontSelector {
}
void UpdateGenericFontFamilySettings(Document&);
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
protected:
void DispatchInvalidationCallbacks();
diff --git a/chromium/third_party/blink/renderer/core/css/css_font_style_range_value.cc b/chromium/third_party/blink/renderer/core/css/css_font_style_range_value.cc
index 17e54db1193..336ac799cad 100644
--- a/chromium/third_party/blink/renderer/core/css/css_font_style_range_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_font_style_range_value.cc
@@ -48,7 +48,7 @@ bool CSSFontStyleRangeValue::Equals(const CSSFontStyleRangeValue& other) const {
*oblique_values_ == *other.oblique_values_;
}
-void CSSFontStyleRangeValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSFontStyleRangeValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(font_style_value_);
visitor->Trace(oblique_values_);
CSSValue::TraceAfterDispatch(visitor);
diff --git a/chromium/third_party/blink/renderer/core/css/css_font_style_range_value.h b/chromium/third_party/blink/renderer/core/css/css_font_style_range_value.h
index 0427b30b7dc..a68c764ee6e 100644
--- a/chromium/third_party/blink/renderer/core/css/css_font_style_range_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_font_style_range_value.h
@@ -55,7 +55,7 @@ class CSSFontStyleRangeValue final : public CSSValue {
bool Equals(const CSSFontStyleRangeValue&) const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
Member<const CSSIdentifierValue> font_style_value_;
diff --git a/chromium/third_party/blink/renderer/core/css/css_font_variation_value.h b/chromium/third_party/blink/renderer/core/css/css_font_variation_value.h
index bce8e1dd992..5488e515b1b 100644
--- a/chromium/third_party/blink/renderer/core/css/css_font_variation_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_font_variation_value.h
@@ -22,7 +22,7 @@ class CSSFontVariationValue : public CSSValue {
bool Equals(const CSSFontVariationValue&) const;
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_function_value.h b/chromium/third_party/blink/renderer/core/css/css_function_value.h
index 2ecd2e5eb17..2ce074cba83 100644
--- a/chromium/third_party/blink/renderer/core/css/css_function_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_function_value.h
@@ -23,7 +23,7 @@ class CSSFunctionValue : public CSSValueList {
}
CSSValueID FunctionType() const { return value_id_; }
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValueList::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_global_rule_set.cc b/chromium/third_party/blink/renderer/core/css/css_global_rule_set.cc
index b727d8caf33..6d2707464c7 100644
--- a/chromium/third_party/blink/renderer/core/css/css_global_rule_set.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_global_rule_set.cc
@@ -60,7 +60,7 @@ void CSSGlobalRuleSet::Dispose() {
is_dirty_ = true;
}
-void CSSGlobalRuleSet::Trace(blink::Visitor* visitor) {
+void CSSGlobalRuleSet::Trace(Visitor* visitor) {
visitor->Trace(watched_selectors_rule_set_);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_global_rule_set.h b/chromium/third_party/blink/renderer/core/css/css_global_rule_set.h
index c45dc4075ca..db894a07540 100644
--- a/chromium/third_party/blink/renderer/core/css/css_global_rule_set.h
+++ b/chromium/third_party/blink/renderer/core/css/css_global_rule_set.h
@@ -41,7 +41,7 @@ class CSSGlobalRuleSet final : public GarbageCollected<CSSGlobalRuleSet> {
}
bool HasFullscreenUAStyle() const { return has_fullscreen_ua_style_; }
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
// Constructed from rules in all TreeScopes including UA style and style
diff --git a/chromium/third_party/blink/renderer/core/css/css_gradient_value.cc b/chromium/third_party/blink/renderer/core/css/css_gradient_value.cc
index 2ecac6e8760..14af20c6624 100644
--- a/chromium/third_party/blink/renderer/core/css/css_gradient_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_gradient_value.cc
@@ -48,6 +48,7 @@
#include "third_party/blink/renderer/platform/graphics/gradient_generated_image.h"
#include "third_party/blink/renderer/platform/graphics/image.h"
#include "third_party/blink/renderer/platform/graphics/skia/skia_utils.h"
+#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
@@ -107,7 +108,7 @@ bool CSSGradientColorStop::IsCacheable() const {
!To<CSSNumericLiteralValue>(*offset_).IsFontRelativeLength();
}
-void CSSGradientColorStop::Trace(blink::Visitor* visitor) {
+void CSSGradientColorStop::Trace(Visitor* visitor) {
visitor->Trace(offset_);
visitor->Trace(color_);
}
@@ -341,7 +342,6 @@ void CSSGradientValue::AddComputedStops(
case CSSValueID::kWebkitLink:
case CSSValueID::kWebkitActivelink:
case CSSValueID::kWebkitFocusRingColor:
- case CSSValueID::kInternalRootColor:
break;
case CSSValueID::kCurrentcolor:
if (allow_visited_style) {
@@ -390,7 +390,8 @@ bool NormalizeAndAddStops(const Vector<GradientStop>& stops,
const float first_offset = stops.front().offset;
const float last_offset = stops.back().offset;
- const float span = last_offset - first_offset;
+ const float span =
+ std::min(last_offset - first_offset, std::numeric_limits<float>::max());
if (fabs(span) < std::numeric_limits<float>::epsilon()) {
// All stops are coincident -> use a single clamped offset value.
@@ -410,7 +411,9 @@ bool NormalizeAndAddStops(const Vector<GradientStop>& stops,
DCHECK_GT(span, 0);
for (wtf_size_t i = 0; i < stops.size(); ++i) {
- const float normalized_offset = (stops[i].offset - first_offset) / span;
+ const auto relative_offset = std::min(stops[i].offset - first_offset,
+ std::numeric_limits<float>::max()),
+ normalized_offset = relative_offset / span;
// stop offsets should be monotonically increasing in [0 , 1]
DCHECK_GE(normalized_offset, 0);
@@ -772,7 +775,7 @@ Vector<Color> CSSGradientValue::GetStopColors(
return stop_colors;
}
-void CSSGradientValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSGradientValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(stops_);
CSSImageGeneratorValue::TraceAfterDispatch(visitor);
}
@@ -1004,12 +1007,15 @@ scoped_refptr<Gradient> CSSLinearGradientValue::CreateGradient(
}
bool CSSLinearGradientValue::Equals(const CSSLinearGradientValue& other) const {
- if (gradient_type_ == kCSSDeprecatedLinearGradient)
- return other.gradient_type_ == gradient_type_ &&
- DataEquivalent(first_x_, other.first_x_) &&
+ if (gradient_type_ != other.gradient_type_)
+ return false;
+
+ if (gradient_type_ == kCSSDeprecatedLinearGradient) {
+ return DataEquivalent(first_x_, other.first_x_) &&
DataEquivalent(first_y_, other.first_y_) &&
DataEquivalent(second_x_, other.second_x_) &&
DataEquivalent(second_y_, other.second_y_) && stops_ == other.stops_;
+ }
if (repeating_ != other.repeating_)
return false;
@@ -1045,7 +1051,7 @@ CSSLinearGradientValue* CSSLinearGradientValue::ComputedCSSValue(
return result;
}
-void CSSLinearGradientValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSLinearGradientValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(first_x_);
visitor->Trace(first_y_);
visitor->Trace(second_x_);
@@ -1442,7 +1448,7 @@ CSSRadialGradientValue* CSSRadialGradientValue::ComputedCSSValue(
return result;
}
-void CSSRadialGradientValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSRadialGradientValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(first_x_);
visitor->Trace(first_y_);
visitor->Trace(second_x_);
@@ -1516,13 +1522,13 @@ bool CSSConicGradientValue::Equals(const CSSConicGradientValue& other) const {
CSSConicGradientValue* CSSConicGradientValue::ComputedCSSValue(
const ComputedStyle& style,
bool allow_visited_style) {
- CSSConicGradientValue* result = CSSConicGradientValue::Create(
+ auto* result = MakeGarbageCollected<CSSConicGradientValue>(
x_, y_, from_angle_, repeating_ ? kRepeating : kNonRepeating);
result->AddComputedStops(style, allow_visited_style, stops_);
return result;
}
-void CSSConicGradientValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSConicGradientValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(x_);
visitor->Trace(y_);
visitor->Trace(from_angle_);
diff --git a/chromium/third_party/blink/renderer/core/css/css_gradient_value.h b/chromium/third_party/blink/renderer/core/css/css_gradient_value.h
index b31412a80de..54f88df9102 100644
--- a/chromium/third_party/blink/renderer/core/css/css_gradient_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_gradient_value.h
@@ -74,7 +74,7 @@ struct CSSGradientColorStop {
bool IsCacheable() const;
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
Member<const CSSPrimitiveValue> offset_; // percentage | length | angle
Member<const CSSValue> color_;
@@ -119,7 +119,7 @@ class CSSGradientValue : public CSSImageGeneratorValue {
Vector<Color> GetStopColors(const Document&, const ComputedStyle&) const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
struct GradientDesc;
@@ -183,7 +183,7 @@ class CSSLinearGradientValue final : public CSSGradientValue {
CSSLinearGradientValue* ComputedCSSValue(const ComputedStyle&,
bool allow_visited_style);
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
// Any of these may be null.
@@ -196,33 +196,6 @@ class CSSLinearGradientValue final : public CSSGradientValue {
class CSSRadialGradientValue final : public CSSGradientValue {
public:
- static CSSGradientValue* Create(
- const CSSValue* first_x,
- const CSSValue* first_y,
- const CSSPrimitiveValue* first_radius,
- const CSSValue* second_x,
- const CSSValue* second_y,
- const CSSPrimitiveValue* second_radius,
- CSSGradientRepeat repeat,
- CSSGradientType gradient_type = kCSSRadialGradient) {
- return MakeGarbageCollected<CSSRadialGradientValue>(
- first_x, first_y, first_radius, second_x, second_y, second_radius,
- nullptr, nullptr, nullptr, nullptr, repeat, gradient_type);
- }
-
- static CSSGradientValue* Create(const CSSValue* center_x,
- const CSSValue* center_y,
- const CSSIdentifierValue* shape,
- const CSSIdentifierValue* sizing_behavior,
- const CSSPrimitiveValue* horizontal_size,
- const CSSPrimitiveValue* vertical_size,
- CSSGradientRepeat repeat,
- CSSGradientType gradient_type) {
- return MakeGarbageCollected<CSSRadialGradientValue>(
- center_x, center_y, nullptr, center_x, center_y, nullptr, shape,
- sizing_behavior, horizontal_size, vertical_size, repeat, gradient_type);
- }
-
CSSRadialGradientValue(const CSSValue* first_x,
const CSSValue* first_y,
const CSSPrimitiveValue* first_radius,
@@ -247,6 +220,46 @@ class CSSRadialGradientValue final : public CSSGradientValue {
end_horizontal_size_(horizontal_size),
end_vertical_size_(vertical_size) {}
+ CSSRadialGradientValue(const CSSValue* first_x,
+ const CSSValue* first_y,
+ const CSSPrimitiveValue* first_radius,
+ const CSSValue* second_x,
+ const CSSValue* second_y,
+ const CSSPrimitiveValue* second_radius,
+ CSSGradientRepeat repeat,
+ CSSGradientType gradient_type = kCSSRadialGradient)
+ : CSSGradientValue(kRadialGradientClass, repeat, gradient_type),
+ first_x_(first_x),
+ first_y_(first_y),
+ second_x_(second_x),
+ second_y_(second_y),
+ first_radius_(first_radius),
+ second_radius_(second_radius),
+ shape_(nullptr),
+ sizing_behavior_(nullptr),
+ end_horizontal_size_(nullptr),
+ end_vertical_size_(nullptr) {}
+
+ CSSRadialGradientValue(const CSSValue* center_x,
+ const CSSValue* center_y,
+ const CSSIdentifierValue* shape,
+ const CSSIdentifierValue* sizing_behavior,
+ const CSSPrimitiveValue* horizontal_size,
+ const CSSPrimitiveValue* vertical_size,
+ CSSGradientRepeat repeat,
+ CSSGradientType gradient_type)
+ : CSSGradientValue(kRadialGradientClass, repeat, gradient_type),
+ first_x_(center_x),
+ first_y_(center_y),
+ second_x_(center_x),
+ second_y_(center_y),
+ first_radius_(nullptr),
+ second_radius_(nullptr),
+ shape_(shape),
+ sizing_behavior_(sizing_behavior),
+ end_horizontal_size_(horizontal_size),
+ end_vertical_size_(vertical_size) {}
+
String CustomCSSText() const;
void SetShape(CSSIdentifierValue* val) { shape_ = val; }
@@ -268,7 +281,7 @@ class CSSRadialGradientValue final : public CSSGradientValue {
CSSRadialGradientValue* ComputedCSSValue(const ComputedStyle&,
bool allow_visited_style);
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
// Any of these may be null.
@@ -292,14 +305,6 @@ class CSSRadialGradientValue final : public CSSGradientValue {
class CSSConicGradientValue final : public CSSGradientValue {
public:
- static CSSConicGradientValue* Create(const CSSValue* x,
- const CSSValue* y,
- const CSSPrimitiveValue* from_angle,
- CSSGradientRepeat repeat) {
- return MakeGarbageCollected<CSSConicGradientValue>(x, y, from_angle,
- repeat);
- }
-
CSSConicGradientValue(const CSSValue* x,
const CSSValue* y,
const CSSPrimitiveValue* from_angle,
@@ -322,7 +327,7 @@ class CSSConicGradientValue final : public CSSGradientValue {
CSSConicGradientValue* ComputedCSSValue(const ComputedStyle&,
bool allow_visited_style);
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
// Any of these may be null.
diff --git a/chromium/third_party/blink/renderer/core/css/css_grid_auto_repeat_value.h b/chromium/third_party/blink/renderer/core/css/css_grid_auto_repeat_value.h
index 93f2f907582..44dd00b644b 100644
--- a/chromium/third_party/blink/renderer/core/css/css_grid_auto_repeat_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_grid_auto_repeat_value.h
@@ -38,7 +38,7 @@ class CSSGridAutoRepeatValue : public CSSValueList {
CSSValueID AutoRepeatID() const { return auto_repeat_id_; }
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValueList::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_grid_integer_repeat_value.h b/chromium/third_party/blink/renderer/core/css/css_grid_integer_repeat_value.h
index 0e862020831..e7b5c8b5627 100644
--- a/chromium/third_party/blink/renderer/core/css/css_grid_integer_repeat_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_grid_integer_repeat_value.h
@@ -33,7 +33,7 @@ class CSSGridIntegerRepeatValue : public CSSValueList {
size_t Repetitions() const { return repetitions_; }
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValueList::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_grid_line_names_value.h b/chromium/third_party/blink/renderer/core/css/css_grid_line_names_value.h
index 8fa3bfb2245..2986ed8fc33 100644
--- a/chromium/third_party/blink/renderer/core/css/css_grid_line_names_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_grid_line_names_value.h
@@ -43,7 +43,7 @@ class CSSGridLineNamesValue : public CSSValueList {
String CustomCSSText() const;
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValueList::TraceAfterDispatch(visitor);
}
};
diff --git a/chromium/third_party/blink/renderer/core/css/css_grid_template_areas_value.h b/chromium/third_party/blink/renderer/core/css/css_grid_template_areas_value.h
index a847793d299..69e7b35f552 100644
--- a/chromium/third_party/blink/renderer/core/css/css_grid_template_areas_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_grid_template_areas_value.h
@@ -54,7 +54,7 @@ class CSSGridTemplateAreasValue : public CSSValue {
bool Equals(const CSSGridTemplateAreasValue&) const;
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_grouping_rule.cc b/chromium/third_party/blink/renderer/core/css/css_grouping_rule.cc
index 89df799a8f8..34a76e9d048 100644
--- a/chromium/third_party/blink/renderer/core/css/css_grouping_rule.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_grouping_rule.cc
@@ -166,7 +166,7 @@ void CSSGroupingRule::Reattach(StyleRuleBase* rule) {
}
}
-void CSSGroupingRule::Trace(blink::Visitor* visitor) {
+void CSSGroupingRule::Trace(Visitor* visitor) {
CSSRule::Trace(visitor);
visitor->Trace(child_rule_cssom_wrappers_);
visitor->Trace(group_rule_);
diff --git a/chromium/third_party/blink/renderer/core/css/css_grouping_rule.h b/chromium/third_party/blink/renderer/core/css/css_grouping_rule.h
index a404726ceb0..a23859069c8 100644
--- a/chromium/third_party/blink/renderer/core/css/css_grouping_rule.h
+++ b/chromium/third_party/blink/renderer/core/css/css_grouping_rule.h
@@ -52,7 +52,7 @@ class CSSGroupingRule : public CSSRule {
unsigned length() const;
CSSRule* Item(unsigned index) const;
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
protected:
CSSGroupingRule(StyleRuleGroup* group_rule, CSSStyleSheet* parent);
diff --git a/chromium/third_party/blink/renderer/core/css/css_identifier_value.cc b/chromium/third_party/blink/renderer/core/css/css_identifier_value.cc
index 90096e591e2..0498875affd 100644
--- a/chromium/third_party/blink/renderer/core/css/css_identifier_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_identifier_value.cc
@@ -57,13 +57,13 @@ CSSIdentifierValue::CSSIdentifierValue(const Length& length)
case Length::kCalculated:
case Length::kDeviceWidth:
case Length::kDeviceHeight:
- case Length::kMaxSizeNone:
+ case Length::kNone:
NOTREACHED();
break;
}
}
-void CSSIdentifierValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSIdentifierValue::TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_identifier_value.h b/chromium/third_party/blink/renderer/core/css/css_identifier_value.h
index 669b9a42b22..585a5ec06f1 100644
--- a/chromium/third_party/blink/renderer/core/css/css_identifier_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_identifier_value.h
@@ -59,7 +59,7 @@ class CORE_EXPORT CSSIdentifierValue : public CSSValue {
return CssValueIDToPlatformEnum<T>(value_id_);
}
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
CSSValueID value_id_;
diff --git a/chromium/third_party/blink/renderer/core/css/css_image_generator_value.h b/chromium/third_party/blink/renderer/core/css/css_image_generator_value.h
index 94180496d71..2d6f9b3fa22 100644
--- a/chromium/third_party/blink/renderer/core/css/css_image_generator_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_image_generator_value.h
@@ -108,7 +108,7 @@ class CORE_EXPORT CSSImageGeneratorValue : public CSSValue {
bool IsUsingCustomProperty(const AtomicString& custom_property_name,
const Document&) const;
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_image_set_value.cc b/chromium/third_party/blink/renderer/core/css/css_image_set_value.cc
index 5e1fd09a024..6a9f23a83df 100644
--- a/chromium/third_party/blink/renderer/core/css/css_image_set_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_image_set_value.cc
@@ -120,7 +120,7 @@ StyleImage* CSSImageSetValue::CacheImage(
options.initiator_info.name = parser_mode_ == kUASheetMode
? fetch_initiator_type_names::kUacss
: fetch_initiator_type_names::kCSS;
- FetchParameters params(resource_request, options);
+ FetchParameters params(std::move(resource_request), options);
if (cross_origin != kCrossOriginAttributeNotSet) {
params.SetCrossOriginAccessControl(document.GetSecurityOrigin(),
@@ -174,7 +174,7 @@ bool CSSImageSetValue::HasFailedOrCanceledSubresources() const {
return true;
}
-void CSSImageSetValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSImageSetValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(cached_image_);
CSSValueList::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_image_set_value.h b/chromium/third_party/blink/renderer/core/css/css_image_set_value.h
index de879b89b1e..846cebf49a0 100644
--- a/chromium/third_party/blink/renderer/core/css/css_image_set_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_image_set_value.h
@@ -65,7 +65,7 @@ class CSSImageSetValue : public CSSValueList {
bool HasFailedOrCanceledSubresources() const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
protected:
ImageWithScale BestImageForScaleFactor(float scale_factor);
diff --git a/chromium/third_party/blink/renderer/core/css/css_image_value.cc b/chromium/third_party/blink/renderer/core/css/css_image_value.cc
index 06f072c9188..118e1179436 100644
--- a/chromium/third_party/blink/renderer/core/css/css_image_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_image_value.cc
@@ -20,6 +20,7 @@
#include "third_party/blink/renderer/core/css/css_image_value.h"
+#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/web/web_local_frame_client.h"
#include "third_party/blink/renderer/core/css/css_markup.h"
#include "third_party/blink/renderer/core/dom/document.h"
@@ -32,6 +33,7 @@
#include "third_party/blink/renderer/platform/loader/fetch/fetch_parameters.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_loader_options.h"
+#include "third_party/blink/renderer/platform/network/network_state_notifier.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/weborigin/security_policy.h"
@@ -40,8 +42,8 @@ namespace blink {
CSSImageValue::CSSImageValue(const AtomicString& raw_value,
const KURL& url,
const Referrer& referrer,
- StyleImage* image,
- OriginClean origin_clean)
+ OriginClean origin_clean,
+ StyleImage* image)
: CSSValue(kImageClass),
relative_url_(raw_value),
referrer_(referrer),
@@ -73,7 +75,7 @@ StyleImage* CSSImageValue::CacheImage(
options.initiator_info.name = initiator_name_.IsEmpty()
? fetch_initiator_type_names::kCSS
: initiator_name_;
- FetchParameters params(resource_request, options);
+ FetchParameters params(std::move(resource_request), options);
if (cross_origin != kCrossOriginAttributeNotSet) {
params.SetCrossOriginAccessControl(document.GetSecurityOrigin(),
@@ -92,6 +94,14 @@ StyleImage* CSSImageValue::CacheImage(
params.SetLazyImageDeferred();
}
+ if (base::FeatureList::IsEnabled(blink::features::kSubresourceRedirect) &&
+ params.Url().ProtocolIsInHTTPFamily() &&
+ GetNetworkStateNotifier().SaveDataEnabled()) {
+ auto& resource_request = params.MutableResourceRequest();
+ resource_request.SetPreviewsState(resource_request.GetPreviewsState() |
+ WebURLRequest::kSubresourceRedirectOn);
+ }
+
if (origin_clean_ != OriginClean::kTrue)
params.SetFromOriginDirtyStyleSheet(true);
@@ -140,7 +150,7 @@ bool CSSImageValue::KnownToBeOpaque(const Document& document,
: false;
}
-void CSSImageValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSImageValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(cached_image_);
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_image_value.h b/chromium/third_party/blink/renderer/core/css/css_image_value.h
index b8ab4d34e76..39469eeb232 100644
--- a/chromium/third_party/blink/renderer/core/css/css_image_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_image_value.h
@@ -39,42 +39,11 @@ class ComputedStyle;
class CORE_EXPORT CSSImageValue : public CSSValue {
public:
- static CSSImageValue* Create(const KURL& url,
- OriginClean origin_clean,
- StyleImage* image = nullptr) {
- return Create(url.GetString(), url, Referrer(), origin_clean, image);
- }
- static CSSImageValue* Create(const AtomicString& relative_url,
- const KURL& absolute_url,
- OriginClean origin_clean,
- StyleImage* image = nullptr) {
- return Create(relative_url, absolute_url, Referrer(), origin_clean, image);
- }
- static CSSImageValue* Create(const String& raw_value,
- const KURL& url,
- const Referrer& referrer,
- OriginClean origin_clean,
- StyleImage* image = nullptr) {
- return Create(AtomicString(raw_value), url, referrer, origin_clean, image);
- }
- static CSSImageValue* Create(const AtomicString& raw_value,
- const KURL& url,
- const Referrer& referrer,
- OriginClean origin_clean,
- StyleImage* image = nullptr) {
- return MakeGarbageCollected<CSSImageValue>(raw_value, url, referrer, image,
- origin_clean);
- }
- static CSSImageValue* Create(const AtomicString& absolute_url,
- OriginClean origin_clean) {
- return MakeGarbageCollected<CSSImageValue>(absolute_url, origin_clean);
- }
-
CSSImageValue(const AtomicString& raw_value,
const KURL&,
const Referrer&,
- StyleImage*,
- OriginClean origin_clean);
+ OriginClean origin_clean,
+ StyleImage* image = nullptr);
CSSImageValue(const AtomicString& absolute_url, OriginClean origin_clean);
~CSSImageValue();
@@ -104,17 +73,20 @@ class CORE_EXPORT CSSImageValue : public CSSValue {
bool KnownToBeOpaque(const Document&, const ComputedStyle&) const;
CSSImageValue* ValueWithURLMadeAbsolute() const {
- return Create(KURL(absolute_url_), origin_clean_, cached_image_.Get());
+ return MakeGarbageCollected<CSSImageValue>(
+ absolute_url_, KURL(absolute_url_), Referrer(), origin_clean_,
+ cached_image_.Get());
}
CSSImageValue* Clone() const {
- return Create(relative_url_, KURL(absolute_url_), origin_clean_,
- cached_image_.Get());
+ return MakeGarbageCollected<CSSImageValue>(
+ relative_url_, KURL(absolute_url_), Referrer(), origin_clean_,
+ cached_image_.Get());
}
void SetInitiator(const AtomicString& name) { initiator_name_ = name; }
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
void RestoreCachedResourceIfNeeded(const Document&) const;
private:
diff --git a/chromium/third_party/blink/renderer/core/css/css_import_rule.cc b/chromium/third_party/blink/renderer/core/css/css_import_rule.cc
index 9413dd71dbe..685275588ec 100644
--- a/chromium/third_party/blink/renderer/core/css/css_import_rule.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_import_rule.cc
@@ -84,7 +84,7 @@ void CSSImportRule::Reattach(StyleRuleBase*) {
NOTREACHED();
}
-void CSSImportRule::Trace(blink::Visitor* visitor) {
+void CSSImportRule::Trace(Visitor* visitor) {
visitor->Trace(import_rule_);
visitor->Trace(media_cssom_wrapper_);
visitor->Trace(style_sheet_cssom_wrapper_);
diff --git a/chromium/third_party/blink/renderer/core/css/css_import_rule.h b/chromium/third_party/blink/renderer/core/css/css_import_rule.h
index 495482badeb..9ea04d4d3d7 100644
--- a/chromium/third_party/blink/renderer/core/css/css_import_rule.h
+++ b/chromium/third_party/blink/renderer/core/css/css_import_rule.h
@@ -45,7 +45,7 @@ class CSSImportRule final : public CSSRule {
MediaList* media() const;
CSSStyleSheet* styleSheet() const;
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
CSSRule::Type type() const override { return kImportRule; }
diff --git a/chromium/third_party/blink/renderer/core/css/css_inherited_value.h b/chromium/third_party/blink/renderer/core/css/css_inherited_value.h
index e9d9352259b..b249c963243 100644
--- a/chromium/third_party/blink/renderer/core/css/css_inherited_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_inherited_value.h
@@ -39,7 +39,7 @@ class CORE_EXPORT CSSInheritedValue : public CSSValue {
bool Equals(const CSSInheritedValue&) const { return true; }
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_initial_value.h b/chromium/third_party/blink/renderer/core/css/css_initial_value.h
index ef3e4194b42..0e2aebdbeb1 100644
--- a/chromium/third_party/blink/renderer/core/css/css_initial_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_initial_value.h
@@ -38,7 +38,7 @@ class CORE_EXPORT CSSInitialValue : public CSSValue {
bool Equals(const CSSInitialValue&) const { return true; }
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_invalid_variable_value.h b/chromium/third_party/blink/renderer/core/css/css_invalid_variable_value.h
index 504244f1209..eb40dcbc02e 100644
--- a/chromium/third_party/blink/renderer/core/css/css_invalid_variable_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_invalid_variable_value.h
@@ -23,7 +23,7 @@ class CORE_EXPORT CSSInvalidVariableValue : public CSSValue {
bool Equals(const CSSInvalidVariableValue&) const { return true; }
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_keyframe_rule.cc b/chromium/third_party/blink/renderer/core/css/css_keyframe_rule.cc
index c17bbbf3d0d..0887f7a2d14 100644
--- a/chromium/third_party/blink/renderer/core/css/css_keyframe_rule.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_keyframe_rule.cc
@@ -69,7 +69,7 @@ void CSSKeyframeRule::Reattach(StyleRuleBase*) {
NOTREACHED();
}
-void CSSKeyframeRule::Trace(blink::Visitor* visitor) {
+void CSSKeyframeRule::Trace(Visitor* visitor) {
visitor->Trace(keyframe_);
visitor->Trace(properties_cssom_wrapper_);
CSSRule::Trace(visitor);
diff --git a/chromium/third_party/blink/renderer/core/css/css_keyframe_rule.h b/chromium/third_party/blink/renderer/core/css/css_keyframe_rule.h
index 70e5fcb015c..56fcc1053eb 100644
--- a/chromium/third_party/blink/renderer/core/css/css_keyframe_rule.h
+++ b/chromium/third_party/blink/renderer/core/css/css_keyframe_rule.h
@@ -52,7 +52,7 @@ class CSSKeyframeRule final : public CSSRule {
CSSStyleDeclaration* style() const;
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
CSSRule::Type type() const override { return kKeyframeRule; }
diff --git a/chromium/third_party/blink/renderer/core/css/css_keyframe_shorthand_value.cc b/chromium/third_party/blink/renderer/core/css/css_keyframe_shorthand_value.cc
index 7311cb6aa55..6196eeffbcb 100644
--- a/chromium/third_party/blink/renderer/core/css/css_keyframe_shorthand_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_keyframe_shorthand_value.cc
@@ -43,7 +43,8 @@ String CSSKeyframeShorthandValue::CustomCSSText() const {
return properties_->GetPropertyValue(shorthand_);
}
-void CSSKeyframeShorthandValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSKeyframeShorthandValue::TraceAfterDispatch(
+ blink::Visitor* visitor) const {
visitor->Trace(properties_);
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_keyframe_shorthand_value.h b/chromium/third_party/blink/renderer/core/css/css_keyframe_shorthand_value.h
index 43f849f4553..d1ea40020a2 100644
--- a/chromium/third_party/blink/renderer/core/css/css_keyframe_shorthand_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_keyframe_shorthand_value.h
@@ -45,7 +45,7 @@ class CSSKeyframeShorthandValue : public CSSValue {
return shorthand_ == other.shorthand_ && properties_ == other.properties_;
}
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
// The shorthand property that these longhands belonged to.
diff --git a/chromium/third_party/blink/renderer/core/css/css_keyframes_rule.cc b/chromium/third_party/blink/renderer/core/css/css_keyframes_rule.cc
index ef11909d71e..734b890df4a 100644
--- a/chromium/third_party/blink/renderer/core/css/css_keyframes_rule.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_keyframes_rule.cc
@@ -74,7 +74,7 @@ int StyleRuleKeyframes::FindKeyframeIndex(const String& key) const {
return -1;
}
-void StyleRuleKeyframes::TraceAfterDispatch(blink::Visitor* visitor) {
+void StyleRuleKeyframes::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(keyframes_);
StyleRuleBase::TraceAfterDispatch(visitor);
}
@@ -200,7 +200,7 @@ void CSSKeyframesRule::Reattach(StyleRuleBase* rule) {
keyframes_rule_ = To<StyleRuleKeyframes>(rule);
}
-void CSSKeyframesRule::Trace(blink::Visitor* visitor) {
+void CSSKeyframesRule::Trace(Visitor* visitor) {
CSSRule::Trace(visitor);
visitor->Trace(child_rule_cssom_wrappers_);
visitor->Trace(keyframes_rule_);
diff --git a/chromium/third_party/blink/renderer/core/css/css_keyframes_rule.h b/chromium/third_party/blink/renderer/core/css/css_keyframes_rule.h
index a17f15ef4a4..4313c2ea27a 100644
--- a/chromium/third_party/blink/renderer/core/css/css_keyframes_rule.h
+++ b/chromium/third_party/blink/renderer/core/css/css_keyframes_rule.h
@@ -64,7 +64,7 @@ class StyleRuleKeyframes final : public StyleRuleBase {
return MakeGarbageCollected<StyleRuleKeyframes>(*this);
}
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
void StyleChanged() { version_++; }
unsigned Version() const { return version_; }
@@ -114,7 +114,7 @@ class CSSKeyframesRule final : public CSSRule {
void StyleChanged() { keyframes_rule_->StyleChanged(); }
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
CSSRule::Type type() const override { return kKeyframesRule; }
diff --git a/chromium/third_party/blink/renderer/core/css/css_layout_function_value.cc b/chromium/third_party/blink/renderer/core/css/css_layout_function_value.cc
index 4bebf888ce5..ada6eafc779 100644
--- a/chromium/third_party/blink/renderer/core/css/css_layout_function_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_layout_function_value.cc
@@ -14,8 +14,6 @@ CSSLayoutFunctionValue::CSSLayoutFunctionValue(CSSCustomIdentValue* name,
bool is_inline)
: CSSValue(kLayoutFunctionClass), name_(name), is_inline_(is_inline) {}
-CSSLayoutFunctionValue::~CSSLayoutFunctionValue() = default;
-
String CSSLayoutFunctionValue::CustomCSSText() const {
StringBuilder result;
if (is_inline_)
@@ -34,7 +32,7 @@ bool CSSLayoutFunctionValue::Equals(const CSSLayoutFunctionValue& other) const {
return GetName() == other.GetName() && IsInline() == other.IsInline();
}
-void CSSLayoutFunctionValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSLayoutFunctionValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(name_);
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_layout_function_value.h b/chromium/third_party/blink/renderer/core/css/css_layout_function_value.h
index e3dc3760b7f..853110df141 100644
--- a/chromium/third_party/blink/renderer/core/css/css_layout_function_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_layout_function_value.h
@@ -19,14 +19,13 @@ namespace cssvalue {
class CSSLayoutFunctionValue : public CSSValue {
public:
CSSLayoutFunctionValue(CSSCustomIdentValue* name, bool is_inline);
- ~CSSLayoutFunctionValue();
String CustomCSSText() const;
AtomicString GetName() const;
bool IsInline() const { return is_inline_; }
bool Equals(const CSSLayoutFunctionValue&) const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
Member<CSSCustomIdentValue> name_;
diff --git a/chromium/third_party/blink/renderer/core/css/css_light_dark_color_pair.h b/chromium/third_party/blink/renderer/core/css/css_light_dark_color_pair.h
index 84737f5e29c..994dc1b35fa 100644
--- a/chromium/third_party/blink/renderer/core/css/css_light_dark_color_pair.h
+++ b/chromium/third_party/blink/renderer/core/css/css_light_dark_color_pair.h
@@ -14,7 +14,7 @@ class CORE_EXPORT CSSLightDarkColorPair : public CSSValuePair {
CSSLightDarkColorPair(const CSSValue* first, const CSSValue* second)
: CSSValuePair(kLightDarkColorPairClass, first, second) {}
String CustomCSSText() const;
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValuePair::TraceAfterDispatch(visitor);
}
};
diff --git a/chromium/third_party/blink/renderer/core/css/css_math_expression_node.cc b/chromium/third_party/blink/renderer/core/css/css_math_expression_node.cc
index 4e6fa5e20e4..b274e03e1fe 100644
--- a/chromium/third_party/blink/renderer/core/css/css_math_expression_node.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_math_expression_node.cc
@@ -147,7 +147,9 @@ CSSMathExpressionNumericLiteral* CSSMathExpressionNumericLiteral::Create(
CSSMathExpressionNumericLiteral::CSSMathExpressionNumericLiteral(
const CSSNumericLiteralValue* value,
bool is_integer)
- : CSSMathExpressionNode(UnitCategory(value->GetType()), is_integer),
+ : CSSMathExpressionNode(UnitCategory(value->GetType()),
+ is_integer,
+ false /* has_comparisons*/),
value_(value) {}
bool CSSMathExpressionNumericLiteral::IsZero() const {
@@ -269,7 +271,7 @@ bool CSSMathExpressionNumericLiteral::IsComputationallyIndependent() const {
return value_->IsComputationallyIndependent();
}
-void CSSMathExpressionNumericLiteral::Trace(blink::Visitor* visitor) {
+void CSSMathExpressionNumericLiteral::Trace(Visitor* visitor) {
visitor->Trace(value_);
CSSMathExpressionNode::Trace(visitor);
}
@@ -473,8 +475,10 @@ CSSMathExpressionBinaryOperation::CSSMathExpressionBinaryOperation(
const CSSMathExpressionNode* right_side,
CSSMathOperator op,
CalculationCategory category)
- : CSSMathExpressionNode(category,
- IsIntegerResult(left_side, right_side, op)),
+ : CSSMathExpressionNode(
+ category,
+ IsIntegerResult(left_side, right_side, op),
+ left_side->HasComparisons() || right_side->HasComparisons()),
left_side_(left_side),
right_side_(right_side),
operator_(op) {}
@@ -735,7 +739,7 @@ CSSPrimitiveValue::UnitType CSSMathExpressionBinaryOperation::ResolvedUnitType()
return CSSPrimitiveValue::UnitType::kUnknown;
}
-void CSSMathExpressionBinaryOperation::Trace(blink::Visitor* visitor) {
+void CSSMathExpressionBinaryOperation::Trace(Visitor* visitor) {
visitor->Trace(left_side_);
visitor->Trace(right_side_);
CSSMathExpressionNode::Trace(visitor);
@@ -816,11 +820,13 @@ CSSMathExpressionVariadicOperation::CSSMathExpressionVariadicOperation(
bool is_integer_result,
Operands&& operands,
CSSMathOperator op)
- : CSSMathExpressionNode(category, is_integer_result),
+ : CSSMathExpressionNode(category,
+ is_integer_result,
+ true /* has_comparisons */),
operands_(std::move(operands)),
operator_(op) {}
-void CSSMathExpressionVariadicOperation::Trace(blink::Visitor* visitor) {
+void CSSMathExpressionVariadicOperation::Trace(Visitor* visitor) {
visitor->Trace(operands_);
CSSMathExpressionNode::Trace(visitor);
}
@@ -926,7 +932,7 @@ CSSMathExpressionVariadicOperation::ToCalculationExpression(
const CSSToLengthConversionData& data) const {
Vector<scoped_refptr<const CalculationExpressionNode>> operands;
operands.ReserveCapacity(operands_.size());
- for (const auto operand : operands_)
+ for (const auto& operand : operands_)
operands.push_back(operand->ToCalculationExpression(data));
auto expression_type = operator_ == CSSMathOperator::kMin
? CalculationExpressionComparisonNode::Type::kMin
@@ -977,6 +983,9 @@ bool CSSMathExpressionVariadicOperation::operator==(
CSSPrimitiveValue::UnitType
CSSMathExpressionVariadicOperation::ResolvedUnitType() const {
+ if (Category() == kCalcNumber)
+ return CSSPrimitiveValue::UnitType::kNumber;
+
CSSPrimitiveValue::UnitType result = operands_.front()->ResolvedUnitType();
if (result == CSSPrimitiveValue::UnitType::kUnknown)
return CSSPrimitiveValue::UnitType::kUnknown;
@@ -1083,8 +1092,14 @@ class CSSMathExpressionNodeParser {
auto* nested = CSSMathExpressionVariadicOperation::Create(
{val_operand, max_operand}, CSSMathOperator::kMin);
+ if (!nested)
+ return nullptr;
+
auto* result = CSSMathExpressionVariadicOperation::Create(
{min_operand, nested}, CSSMathOperator::kMax);
+ if (!result)
+ return nullptr;
+
result->SetIsClamp();
return result;
}
@@ -1123,22 +1138,20 @@ class CSSMathExpressionNodeParser {
return result;
}
- if (RuntimeEnabledFeatures::CSSComparisonFunctionsEnabled()) {
- if (tokens.Peek().GetType() == kFunctionToken) {
- CSSValueID function_id = tokens.Peek().FunctionId();
- CSSParserTokenRange inner_range = tokens.ConsumeBlock();
- tokens.ConsumeWhitespace();
- inner_range.ConsumeWhitespace();
- switch (function_id) {
- case CSSValueID::kMin:
- return ParseMinOrMax(inner_range, CSSMathOperator::kMin, depth);
- case CSSValueID::kMax:
- return ParseMinOrMax(inner_range, CSSMathOperator::kMax, depth);
- case CSSValueID::kClamp:
- return ParseClamp(inner_range, depth);
- default:
- break;
- }
+ if (tokens.Peek().GetType() == kFunctionToken) {
+ CSSValueID function_id = tokens.Peek().FunctionId();
+ CSSParserTokenRange inner_range = tokens.ConsumeBlock();
+ tokens.ConsumeWhitespace();
+ inner_range.ConsumeWhitespace();
+ switch (function_id) {
+ case CSSValueID::kMin:
+ return ParseMinOrMax(inner_range, CSSMathOperator::kMin, depth);
+ case CSSValueID::kMax:
+ return ParseMinOrMax(inner_range, CSSMathOperator::kMax, depth);
+ case CSSValueID::kClamp:
+ return ParseClamp(inner_range, depth);
+ default:
+ break;
}
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_math_expression_node.h b/chromium/third_party/blink/renderer/core/css/css_math_expression_node.h
index ce486ec1732..b1e932b61dc 100644
--- a/chromium/third_party/blink/renderer/core/css/css_math_expression_node.h
+++ b/chromium/third_party/blink/renderer/core/css/css_math_expression_node.h
@@ -136,6 +136,8 @@ class CORE_EXPORT CSSMathExpressionNode
bool IsNestedCalc() const { return is_nested_calc_; }
void SetIsNestedCalc() { is_nested_calc_ = true; }
+ bool HasComparisons() const { return has_comparisons_; }
+
#if DCHECK_IS_ON()
// There's a subtle issue in comparing two percentages, e.g., min(10%, 20%).
// It doesn't always resolve into 10%, because the reference value may be
@@ -144,17 +146,22 @@ class CORE_EXPORT CSSMathExpressionNode
virtual bool InvolvesPercentageComparisons() const = 0;
#endif
- virtual void Trace(blink::Visitor* visitor) {}
+ virtual void Trace(Visitor* visitor) {}
protected:
- CSSMathExpressionNode(CalculationCategory category, bool is_integer)
- : category_(category), is_integer_(is_integer) {
+ CSSMathExpressionNode(CalculationCategory category,
+ bool is_integer,
+ bool has_comparisons)
+ : category_(category),
+ is_integer_(is_integer),
+ has_comparisons_(has_comparisons) {
DCHECK_NE(category, kCalcOther);
}
CalculationCategory category_;
bool is_integer_;
bool is_nested_calc_ = false;
+ bool has_comparisons_;
};
class CORE_EXPORT CSSMathExpressionNumericLiteral final
@@ -190,7 +197,7 @@ class CORE_EXPORT CSSMathExpressionNumericLiteral final
bool IsComputationallyIndependent() const final;
bool operator==(const CSSMathExpressionNode& other) const final;
CSSPrimitiveValue::UnitType ResolvedUnitType() const final;
- void Trace(blink::Visitor* visitor) final;
+ void Trace(Visitor* visitor) final;
#if DCHECK_IS_ON()
bool InvolvesPercentageComparisons() const final;
@@ -248,7 +255,7 @@ class CORE_EXPORT CSSMathExpressionBinaryOperation final
String CustomCSSText() const final;
bool operator==(const CSSMathExpressionNode& exp) const final;
CSSPrimitiveValue::UnitType ResolvedUnitType() const final;
- void Trace(blink::Visitor* visitor) final;
+ void Trace(Visitor* visitor) final;
#if DCHECK_IS_ON()
bool InvolvesPercentageComparisons() const final;
@@ -316,7 +323,7 @@ class CSSMathExpressionVariadicOperation final : public CSSMathExpressionNode {
bool IsComputationallyIndependent() const final;
bool operator==(const CSSMathExpressionNode& other) const final;
CSSPrimitiveValue::UnitType ResolvedUnitType() const final;
- void Trace(blink::Visitor* visitor) final;
+ void Trace(Visitor* visitor) final;
#if DCHECK_IS_ON()
bool InvolvesPercentageComparisons() const final;
diff --git a/chromium/third_party/blink/renderer/core/css/css_math_function_value.cc b/chromium/third_party/blink/renderer/core/css/css_math_function_value.cc
index 49986ea7099..7df858df8df 100644
--- a/chromium/third_party/blink/renderer/core/css/css_math_function_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_math_function_value.cc
@@ -17,7 +17,7 @@ struct SameSizeAsCSSMathFunctionValue : CSSPrimitiveValue {
};
ASSERT_SIZE(CSSMathFunctionValue, SameSizeAsCSSMathFunctionValue);
-void CSSMathFunctionValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSMathFunctionValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(expression_);
CSSPrimitiveValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_math_function_value.h b/chromium/third_party/blink/renderer/core/css/css_math_function_value.h
index 73316aa2244..b098693ac2d 100644
--- a/chromium/third_party/blink/renderer/core/css/css_math_function_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_math_function_value.h
@@ -88,7 +88,9 @@ class CORE_EXPORT CSSMathFunctionValue : public CSSPrimitiveValue {
String CustomCSSText() const;
bool Equals(const CSSMathFunctionValue& other) const;
- void TraceAfterDispatch(blink::Visitor* visitor);
+ bool HasComparisons() const { return expression_->HasComparisons(); }
+
+ void TraceAfterDispatch(blink::Visitor* visitor) const;
private:
bool IsNonNegative() const { return is_non_negative_math_function_; }
diff --git a/chromium/third_party/blink/renderer/core/css/css_media_rule.cc b/chromium/third_party/blink/renderer/core/css/css_media_rule.cc
index 0376f057120..5faf76aff09 100644
--- a/chromium/third_party/blink/renderer/core/css/css_media_rule.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_media_rule.cc
@@ -71,7 +71,7 @@ void CSSMediaRule::Reattach(StyleRuleBase* rule) {
media_cssom_wrapper_->Reattach(MediaQueries());
}
-void CSSMediaRule::Trace(blink::Visitor* visitor) {
+void CSSMediaRule::Trace(Visitor* visitor) {
visitor->Trace(media_cssom_wrapper_);
CSSConditionRule::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_media_rule.h b/chromium/third_party/blink/renderer/core/css/css_media_rule.h
index ebb6fd1531e..50f9702c144 100644
--- a/chromium/third_party/blink/renderer/core/css/css_media_rule.h
+++ b/chromium/third_party/blink/renderer/core/css/css_media_rule.h
@@ -44,7 +44,7 @@ class CSSMediaRule final : public CSSConditionRule {
MediaList* media() const;
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
CSSRule::Type type() const override { return kMediaRule; }
diff --git a/chromium/third_party/blink/renderer/core/css/css_namespace_rule.cc b/chromium/third_party/blink/renderer/core/css/css_namespace_rule.cc
index 637c00aaccd..0a61e2ff288 100644
--- a/chromium/third_party/blink/renderer/core/css/css_namespace_rule.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_namespace_rule.cc
@@ -36,7 +36,7 @@ AtomicString CSSNamespaceRule::prefix() const {
return namespace_rule_->Prefix();
}
-void CSSNamespaceRule::Trace(blink::Visitor* visitor) {
+void CSSNamespaceRule::Trace(Visitor* visitor) {
visitor->Trace(namespace_rule_);
CSSRule::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_namespace_rule.h b/chromium/third_party/blink/renderer/core/css/css_namespace_rule.h
index 7f20d9e986e..e0091f8399f 100644
--- a/chromium/third_party/blink/renderer/core/css/css_namespace_rule.h
+++ b/chromium/third_party/blink/renderer/core/css/css_namespace_rule.h
@@ -25,7 +25,7 @@ class CSSNamespaceRule final : public CSSRule {
AtomicString namespaceURI() const;
AtomicString prefix() const;
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
CSSRule::Type type() const override { return kNamespaceRule; }
diff --git a/chromium/third_party/blink/renderer/core/css/css_numeric_literal_value.cc b/chromium/third_party/blink/renderer/core/css/css_numeric_literal_value.cc
index 368f0797ee5..41e34deda2e 100644
--- a/chromium/third_party/blink/renderer/core/css/css_numeric_literal_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_numeric_literal_value.cc
@@ -17,7 +17,7 @@ struct SameSizeAsCSSNumericLiteralValue : CSSPrimitiveValue {
};
ASSERT_SIZE(CSSNumericLiteralValue, SameSizeAsCSSNumericLiteralValue);
-void CSSNumericLiteralValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSNumericLiteralValue::TraceAfterDispatch(blink::Visitor* visitor) const {
CSSPrimitiveValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_numeric_literal_value.h b/chromium/third_party/blink/renderer/core/css/css_numeric_literal_value.h
index 640873434aa..d07cbeaf4fc 100644
--- a/chromium/third_party/blink/renderer/core/css/css_numeric_literal_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_numeric_literal_value.h
@@ -63,7 +63,7 @@ class CORE_EXPORT CSSNumericLiteralValue : public CSSPrimitiveValue {
String CustomCSSText() const;
bool Equals(const CSSNumericLiteralValue& other) const;
- void TraceAfterDispatch(blink::Visitor* visitor);
+ void TraceAfterDispatch(blink::Visitor* visitor) const;
private:
double num_;
diff --git a/chromium/third_party/blink/renderer/core/css/css_page_rule.cc b/chromium/third_party/blink/renderer/core/css/css_page_rule.cc
index bcac8e854af..6367cb9ad82 100644
--- a/chromium/third_party/blink/renderer/core/css/css_page_rule.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_page_rule.cc
@@ -97,7 +97,7 @@ void CSSPageRule::Reattach(StyleRuleBase* rule) {
properties_cssom_wrapper_->Reattach(page_rule_->MutableProperties());
}
-void CSSPageRule::Trace(blink::Visitor* visitor) {
+void CSSPageRule::Trace(Visitor* visitor) {
visitor->Trace(page_rule_);
visitor->Trace(properties_cssom_wrapper_);
CSSRule::Trace(visitor);
diff --git a/chromium/third_party/blink/renderer/core/css/css_page_rule.h b/chromium/third_party/blink/renderer/core/css/css_page_rule.h
index 650b48c382b..036a147cbd7 100644
--- a/chromium/third_party/blink/renderer/core/css/css_page_rule.h
+++ b/chromium/third_party/blink/renderer/core/css/css_page_rule.h
@@ -49,7 +49,7 @@ class CORE_EXPORT CSSPageRule final : public CSSRule {
String selectorText() const;
void setSelectorText(const ExecutionContext*, const String&);
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
CSSRule::Type type() const override { return kPageRule; }
diff --git a/chromium/third_party/blink/renderer/core/css/css_page_rule_test.cc b/chromium/third_party/blink/renderer/core/css/css_page_rule_test.cc
index 9682ef70d62..98332f42628 100644
--- a/chromium/third_party/blink/renderer/core/css/css_page_rule_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_page_rule_test.cc
@@ -6,7 +6,7 @@
#include "third_party/blink/renderer/core/css/css_rule_list.h"
#include "third_party/blink/renderer/core/css/css_test_helpers.h"
-#include "third_party/blink/renderer/core/dom/document.h"
+#include "third_party/blink/renderer/core/testing/null_execution_context.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -36,21 +36,22 @@ TEST(CSSPageRule, selectorText) {
auto* page_rule = To<CSSPageRule>(sheet.CssRules()->item(0));
EXPECT_EQ(":left", page_rule->selectorText());
+ auto* context = MakeGarbageCollected<NullExecutionContext>();
// set invalid page selector.
- page_rule->setSelectorText(&sheet.GetDocument(), ":hover");
+ page_rule->setSelectorText(context, ":hover");
EXPECT_EQ(":left", page_rule->selectorText());
// set invalid page selector.
- page_rule->setSelectorText(&sheet.GetDocument(), "right { bla");
+ page_rule->setSelectorText(context, "right { bla");
EXPECT_EQ(":left", page_rule->selectorText());
// set page pseudo class selector.
- page_rule->setSelectorText(&sheet.GetDocument(), ":right");
+ page_rule->setSelectorText(context, ":right");
EXPECT_EQ(":right", page_rule->selectorText());
// set page type selector.
- page_rule->setSelectorText(&sheet.GetDocument(), "namedpage");
+ page_rule->setSelectorText(context, "namedpage");
EXPECT_EQ("namedpage", page_rule->selectorText());
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_paint_image_generator.h b/chromium/third_party/blink/renderer/core/css/css_paint_image_generator.h
index e3449d7b945..39e0a0839d0 100644
--- a/chromium/third_party/blink/renderer/core/css/css_paint_image_generator.h
+++ b/chromium/third_party/blink/renderer/core/css/css_paint_image_generator.h
@@ -32,7 +32,7 @@ class CORE_EXPORT CSSPaintImageGenerator
virtual ~Observer() = default;
virtual void PaintImageGeneratorReady() = 0;
- virtual void Trace(blink::Visitor* visitor) {}
+ virtual void Trace(Visitor* visitor) {}
};
static CSSPaintImageGenerator* Create(const String& name,
@@ -62,7 +62,7 @@ class CORE_EXPORT CSSPaintImageGenerator
virtual bool IsImageGeneratorReady() const = 0;
virtual int WorkletId() const = 0;
- virtual void Trace(blink::Visitor* visitor) {}
+ virtual void Trace(Visitor* visitor) {}
};
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/css_paint_value.cc b/chromium/third_party/blink/renderer/core/css/css_paint_value.cc
index e2571f0dc67..0a997825dfc 100644
--- a/chromium/third_party/blink/renderer/core/css/css_paint_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_paint_value.cc
@@ -21,14 +21,19 @@
namespace blink {
-CSSPaintValue::CSSPaintValue(CSSCustomIdentValue* name)
+CSSPaintValue::CSSPaintValue(CSSCustomIdentValue* name,
+ bool threaded_compositing_enabled)
: CSSImageGeneratorValue(kPaintClass),
name_(name),
paint_image_generator_observer_(MakeGarbageCollected<Observer>(this)),
off_thread_paint_state_(
- RuntimeEnabledFeatures::OffMainThreadCSSPaintEnabled()
- ? OffThreadPaintState::kUnknown
- : OffThreadPaintState::kMainThread) {}
+ (!threaded_compositing_enabled ||
+ !RuntimeEnabledFeatures::OffMainThreadCSSPaintEnabled())
+ ? OffThreadPaintState::kMainThread
+ : OffThreadPaintState::kUnknown) {}
+
+CSSPaintValue::CSSPaintValue(CSSCustomIdentValue* name)
+ : CSSPaintValue(name, Thread::CompositorThread()) {}
CSSPaintValue::CSSPaintValue(
CSSCustomIdentValue* name,
@@ -57,34 +62,38 @@ String CSSPaintValue::GetName() const {
const Vector<CSSPropertyID>* CSSPaintValue::NativeInvalidationProperties(
const Document& document) const {
- if (!generators_.Contains(&document))
+ const CSSPaintImageGenerator* generator = generators_.at(&document);
+ if (!generator)
return nullptr;
- return &(generators_.at(&document)->NativeInvalidationProperties());
+ return &generator->NativeInvalidationProperties();
}
const Vector<AtomicString>* CSSPaintValue::CustomInvalidationProperties(
const Document& document) const {
- if (!generators_.Contains(&document))
+ const CSSPaintImageGenerator* generator = generators_.at(&document);
+ if (!generator)
return nullptr;
- return &(generators_.at(&document)->CustomInvalidationProperties());
+ return &generator->CustomInvalidationProperties();
}
bool CSSPaintValue::IsUsingCustomProperty(
const AtomicString& custom_property_name,
const Document& document) const {
- if (!generators_.Contains(&document) ||
- !generators_.at(&document)->IsImageGeneratorReady())
+ const CSSPaintImageGenerator* generator = generators_.at(&document);
+ if (!generator || !generator->IsImageGeneratorReady())
return false;
- return generators_.at(&document)->CustomInvalidationProperties().Contains(
+ return generator->CustomInvalidationProperties().Contains(
custom_property_name);
}
-void CSSPaintValue::CreateGeneratorForTesting(const Document& document) {
- if (!generators_.Contains(&document)) {
- generators_.insert(
- &document, CSSPaintImageGenerator::Create(
- GetName(), document, paint_image_generator_observer_));
+CSSPaintImageGenerator& CSSPaintValue::EnsureGenerator(
+ const Document& document) {
+ auto& generator = generators_.insert(&document, nullptr).stored_value->value;
+ if (!generator) {
+ generator = CSSPaintImageGenerator::Create(GetName(), document,
+ paint_image_generator_observer_);
}
+ return *generator;
}
scoped_refptr<Image> CSSPaintValue::GetImage(
@@ -97,16 +106,12 @@ scoped_refptr<Image> CSSPaintValue::GetImage(
if (style.InsideLink() != EInsideLink::kNotInsideLink)
return nullptr;
- if (!generators_.Contains(&document)) {
- generators_.insert(
- &document, CSSPaintImageGenerator::Create(
- GetName(), document, paint_image_generator_observer_));
- }
+ CSSPaintImageGenerator& generator = EnsureGenerator(document);
// If the generator isn't ready yet, we have nothing to paint. Our
// |paint_image_generator_observer_| will cause us to be called again once the
// generator is ready.
- if (!generators_.at(&document)->IsImageGeneratorReady())
+ if (!generator.IsImageGeneratorReady())
return nullptr;
if (!ParseInputArguments(document))
@@ -138,10 +143,10 @@ scoped_refptr<Image> CSSPaintValue::GetImage(
// ElementId, then create one for it.
layout_object.GetMutableForPainting().EnsureId();
- Vector<CSSPropertyID> native_properties =
- generators_.at(&document)->NativeInvalidationProperties();
- Vector<AtomicString> custom_properties =
- generators_.at(&document)->CustomInvalidationProperties();
+ const Vector<CSSPropertyID>& native_properties =
+ generator.NativeInvalidationProperties();
+ const Vector<AtomicString>& custom_properties =
+ generator.CustomInvalidationProperties();
float zoom = layout_object.StyleRef().EffectiveZoom();
CompositorPaintWorkletInput::PropertyKeys input_property_keys;
auto style_data = PaintWorkletStylePropertyMap::BuildCrossThreadData(
@@ -161,16 +166,15 @@ scoped_refptr<Image> CSSPaintValue::GetImage(
scoped_refptr<PaintWorkletInput> input =
base::MakeRefCounted<PaintWorkletInput>(
GetName(), target_size, zoom, device_scale_factor,
- generators_.at(&document)->WorkletId(),
- std::move(style_data.value()),
+ generator.WorkletId(), std::move(style_data.value()),
std::move(cross_thread_input_arguments),
std::move(input_property_keys));
return PaintWorkletDeferredImage::Create(std::move(input), target_size);
}
}
- return generators_.at(&document)->Paint(
- client, target_size, parsed_input_arguments_, device_scale_factor);
+ return generator.Paint(client, target_size, parsed_input_arguments_,
+ device_scale_factor);
}
void CSSPaintValue::BuildInputArgumentValues(
@@ -236,7 +240,8 @@ void CSSPaintValue::PaintImageGeneratorReady() {
bool CSSPaintValue::KnownToBeOpaque(const Document& document,
const ComputedStyle&) const {
- return generators_.at(&document) && !generators_.at(&document)->HasAlpha();
+ const CSSPaintImageGenerator* generator = generators_.at(&document);
+ return generator && !generator->HasAlpha();
}
bool CSSPaintValue::Equals(const CSSPaintValue& other) const {
@@ -244,7 +249,7 @@ bool CSSPaintValue::Equals(const CSSPaintValue& other) const {
CustomCSSText() == other.CustomCSSText();
}
-void CSSPaintValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSPaintValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(name_);
visitor->Trace(generators_);
visitor->Trace(paint_image_generator_observer_);
diff --git a/chromium/third_party/blink/renderer/core/css/css_paint_value.h b/chromium/third_party/blink/renderer/core/css/css_paint_value.h
index fcf98c8a0ed..06d1cced1e7 100644
--- a/chromium/third_party/blink/renderer/core/css/css_paint_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_paint_value.h
@@ -20,6 +20,7 @@ namespace blink {
class CORE_EXPORT CSSPaintValue : public CSSImageGeneratorValue {
public:
explicit CSSPaintValue(CSSCustomIdentValue* name);
+ CSSPaintValue(CSSCustomIdentValue* name, bool threaded_compositing_enabled);
CSSPaintValue(CSSCustomIdentValue* name,
Vector<scoped_refptr<CSSVariableData>>&);
~CSSPaintValue();
@@ -65,10 +66,12 @@ class CORE_EXPORT CSSPaintValue : public CSSImageGeneratorValue {
bool IsUsingCustomProperty(const AtomicString& custom_property_name,
const Document&) const;
- void CreateGeneratorForTesting(const Document& document);
+ void CreateGeneratorForTesting(const Document& document) {
+ EnsureGenerator(document);
+ }
unsigned NumberOfGeneratorsForTesting() const { return generators_.size(); }
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
class Observer final : public CSSPaintImageGenerator::Observer {
@@ -76,7 +79,7 @@ class CORE_EXPORT CSSPaintValue : public CSSImageGeneratorValue {
explicit Observer(CSSPaintValue* owner_value) : owner_value_(owner_value) {}
~Observer() override = default;
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(owner_value_);
CSSPaintImageGenerator::Observer::Trace(visitor);
}
@@ -88,6 +91,7 @@ class CORE_EXPORT CSSPaintValue : public CSSImageGeneratorValue {
DISALLOW_COPY_AND_ASSIGN(Observer);
};
+ CSSPaintImageGenerator& EnsureGenerator(const Document&);
void PaintImageGeneratorReady();
bool ParseInputArguments(const Document&);
diff --git a/chromium/third_party/blink/renderer/core/css/css_paint_value_test.cc b/chromium/third_party/blink/renderer/core/css/css_paint_value_test.cc
index 702fb41eb57..2b4fb80a730 100644
--- a/chromium/third_party/blink/renderer/core/css/css_paint_value_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_paint_value_test.cc
@@ -89,7 +89,7 @@ TEST_P(CSSPaintValueTest, ReportingCompositedUMA) {
const ComputedStyle& style = *target->Style();
auto* ident = MakeGarbageCollected<CSSCustomIdentValue>("testpainter");
- CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident);
+ CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident, true);
// Mark the generator as ready - GetImage should succeed when
// OffMainThreadCSSPaint is enabled.
ON_CALL(*mock_generator, IsImageGeneratorReady()).WillByDefault(Return(true));
@@ -135,7 +135,7 @@ TEST_P(CSSPaintValueTest, ReportingNonCompositedUMA) {
LayoutObject* target = GetLayoutObjectByElementId("target");
auto style = ComputedStyle::Create();
auto* ident = MakeGarbageCollected<CSSCustomIdentValue>("testpainter");
- CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident);
+ CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident, true);
StyleGeneratedImage* style_image =
MakeGarbageCollected<StyleGeneratedImage>(*paint_value);
style->SetBorderImageSource(style_image);
@@ -187,7 +187,7 @@ TEST_P(CSSPaintValueTest, DelayPaintUntilGeneratorReady) {
const ComputedStyle& style = *target->Style();
auto* ident = MakeGarbageCollected<CSSCustomIdentValue>("testpainter");
- CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident);
+ CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident, true);
// Initially the generator is not ready, so GetImage should fail (and no paint
// should happen).
@@ -220,7 +220,7 @@ TEST_P(CSSPaintValueTest, GetImageCalledOnMultipleDocuments) {
const ComputedStyle& style = *target->Style();
auto* ident = MakeGarbageCollected<CSSCustomIdentValue>("testpainter");
- CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident);
+ CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident, true);
EXPECT_EQ(paint_value->NumberOfGeneratorsForTesting(), 0u);
paint_value->GetImage(*target, GetDocument(), style, target_size);
@@ -238,7 +238,7 @@ TEST_P(CSSPaintValueTest, NativeInvalidationPropertiesWithNoGenerator) {
SetBodyInnerHTML(R"HTML(<div id="target"></div>)HTML");
auto* ident = MakeGarbageCollected<CSSCustomIdentValue>("testpainter");
- CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident);
+ CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident, true);
EXPECT_EQ(paint_value->NumberOfGeneratorsForTesting(), 0u);
// There is no generator, so returning a nullptr.
@@ -249,7 +249,7 @@ TEST_P(CSSPaintValueTest, CustomInvalidationPropertiesWithNoGenerator) {
SetBodyInnerHTML(R"HTML(<div id="target"></div>)HTML");
auto* ident = MakeGarbageCollected<CSSCustomIdentValue>("testpainter");
- CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident);
+ CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident, true);
EXPECT_EQ(paint_value->NumberOfGeneratorsForTesting(), 0u);
// There is no generator, so returning a nullptr.
@@ -278,7 +278,7 @@ TEST_P(CSSPaintValueTest, PrintingMustFallbackToMainThread) {
const ComputedStyle& style = *target->Style();
auto* ident = MakeGarbageCollected<CSSCustomIdentValue>("testpainter");
- CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident);
+ CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident, true);
ON_CALL(*mock_generator, IsImageGeneratorReady()).WillByDefault(Return(true));
// This PW can be composited, so we should only fall back to main once, in
@@ -319,7 +319,7 @@ TEST_P(CSSPaintValueTest, DoNotPaintForLink) {
ASSERT_NE(style.InsideLink(), EInsideLink::kNotInsideLink);
auto* ident = MakeGarbageCollected<CSSCustomIdentValue>("linkpainter");
- CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident);
+ CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident, true);
EXPECT_FALSE(paint_value->GetImage(*target, GetDocument(), style,
FloatSize(100, 100)));
}
@@ -347,14 +347,14 @@ TEST_P(CSSPaintValueTest, DoNotPaintWhenAncestorHasLink) {
ASSERT_NE(style.InsideLink(), EInsideLink::kNotInsideLink);
auto* ident = MakeGarbageCollected<CSSCustomIdentValue>("linkpainter");
- CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident);
+ CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident, true);
EXPECT_FALSE(paint_value->GetImage(*target, GetDocument(), style,
FloatSize(100, 100)));
}
TEST_P(CSSPaintValueTest, BuildInputArgumentValuesNotCrash) {
auto* ident = MakeGarbageCollected<CSSCustomIdentValue>("testpainter");
- CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident);
+ CSSPaintValue* paint_value = MakeGarbageCollected<CSSPaintValue>(ident, true);
ASSERT_EQ(paint_value->GetParsedInputArgumentsForTesting(), nullptr);
Vector<std::unique_ptr<CrossThreadStyleValue>> cross_thread_input_arguments;
diff --git a/chromium/third_party/blink/renderer/core/css/css_path_value.cc b/chromium/third_party/blink/renderer/core/css/css_path_value.cc
index 9e8982f54cd..3c1ae0b679d 100644
--- a/chromium/third_party/blink/renderer/core/css/css_path_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_path_value.cc
@@ -53,7 +53,7 @@ bool CSSPathValue::Equals(const CSSPathValue& other) const {
return ByteStream() == other.ByteStream();
}
-void CSSPathValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSPathValue::TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_path_value.h b/chromium/third_party/blink/renderer/core/css/css_path_value.h
index 6ff0f908a7a..ee3d8128071 100644
--- a/chromium/third_party/blink/renderer/core/css/css_path_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_path_value.h
@@ -33,7 +33,7 @@ class CSSPathValue : public CSSValue {
bool Equals(const CSSPathValue&) const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
const SVGPathByteStream& ByteStream() const {
return style_path_->ByteStream();
diff --git a/chromium/third_party/blink/renderer/core/css/css_pending_interpolation_value.cc b/chromium/third_party/blink/renderer/core/css/css_pending_interpolation_value.cc
deleted file mode 100644
index d9756e104f9..00000000000
--- a/chromium/third_party/blink/renderer/core/css/css_pending_interpolation_value.cc
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "third_party/blink/renderer/core/css/css_pending_interpolation_value.h"
-#include "third_party/blink/renderer/core/css/css_value_pool.h"
-
-namespace blink {
-namespace cssvalue {
-
-CSSPendingInterpolationValue* CSSPendingInterpolationValue::Create(Type type) {
- return CssValuePool().PendingInterpolationValue(type);
-}
-
-CSSPendingInterpolationValue::CSSPendingInterpolationValue(Type type)
- : CSSValue(kPendingInterpolationClass), type_(type) {}
-
-} // namespace cssvalue
-} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/css_pending_interpolation_value.h b/chromium/third_party/blink/renderer/core/css/css_pending_interpolation_value.h
deleted file mode 100644
index cc8ee8371e6..00000000000
--- a/chromium/third_party/blink/renderer/core/css/css_pending_interpolation_value.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_PENDING_INTERPOLATION_VALUE_H_
-#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_PENDING_INTERPOLATION_VALUE_H_
-
-#include "third_party/blink/renderer/core/css/css_property_name.h"
-#include "third_party/blink/renderer/core/css/css_value.h"
-#include "third_party/blink/renderer/platform/wtf/casting.h"
-
-namespace blink {
-
-namespace cssvalue {
-
-// A CSSPendingInterpolationValue represents a value which we don't yet know
-// what is, but we know that it's the result of an ongoing interpolation.
-// It is a way for interpolations to participate in the cascade, without
-// knowing the exact value cascade-time.
-//
-// See StyleCascade::Animator for more information.
-class CORE_EXPORT CSSPendingInterpolationValue : public CSSValue {
- public:
- enum class Type {
- kCSSProperty,
- kPresentationAttribute,
- };
-
- static CSSPendingInterpolationValue* Create(Type);
- CSSPendingInterpolationValue(Type);
-
- bool IsCSSProperty() const { return type_ == Type::kCSSProperty; }
- bool IsPresentationAttribute() const {
- return type_ == Type::kPresentationAttribute;
- }
- bool Equals(const CSSPendingInterpolationValue& v) const {
- return type_ == v.type_;
- }
-
- String CustomCSSText() const { return ""; }
-
- void TraceAfterDispatch(blink::Visitor* visitor) {
- CSSValue::TraceAfterDispatch(visitor);
- }
-
- private:
- Type type_;
-};
-
-} // namespace cssvalue
-
-template <>
-struct DowncastTraits<cssvalue::CSSPendingInterpolationValue> {
- static bool AllowFrom(const CSSValue& value) {
- return value.IsPendingInterpolationValue();
- }
-};
-
-} // namespace blink
-
-#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_PENDING_INTERPOLATION_VALUE_H_
diff --git a/chromium/third_party/blink/renderer/core/css/css_pending_interpolation_value_test.cc b/chromium/third_party/blink/renderer/core/css/css_pending_interpolation_value_test.cc
deleted file mode 100644
index 649b2864377..00000000000
--- a/chromium/third_party/blink/renderer/core/css/css_pending_interpolation_value_test.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "third_party/blink/renderer/core/css/css_pending_interpolation_value.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/blink/renderer/core/css/css_test_helpers.h"
-#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
-
-namespace blink {
-namespace {
-
-using Type = cssvalue::CSSPendingInterpolationValue::Type;
-
-cssvalue::CSSPendingInterpolationValue* Create(Type type) {
- return cssvalue::CSSPendingInterpolationValue::Create(type);
-}
-
-TEST(CSSPendingInterpolationValueTest, Create) {
- EXPECT_TRUE(Create(Type::kCSSProperty));
- EXPECT_TRUE(Create(Type::kPresentationAttribute));
-}
-
-TEST(CSSPendingInterpolationValueTest, Pool) {
- const auto* value1 = Create(Type::kCSSProperty);
- const auto* value2 = Create(Type::kCSSProperty);
- const auto* value3 = Create(Type::kPresentationAttribute);
- const auto* value4 = Create(Type::kPresentationAttribute);
- EXPECT_EQ(value1, value2);
- EXPECT_EQ(value3, value4);
- EXPECT_NE(value1, value4);
-}
-
-TEST(CSSPendingInterpolationValueTest, Equals) {
- const auto* value1 = Create(Type::kCSSProperty);
- const auto* value2 = Create(Type::kCSSProperty);
- const auto* value3 = Create(Type::kPresentationAttribute);
- const auto* value4 = Create(Type::kPresentationAttribute);
- EXPECT_TRUE(value1->Equals(*value2));
- EXPECT_TRUE(value2->Equals(*value1));
- EXPECT_TRUE(value3->Equals(*value4));
- EXPECT_TRUE(value4->Equals(*value3));
- EXPECT_FALSE(value1->Equals(*value4));
- EXPECT_FALSE(value4->Equals(*value1));
-}
-
-TEST(CSSPendingInterpolationValueTest, CustomCSSText) {
- EXPECT_EQ("", Create(Type::kCSSProperty)->CustomCSSText());
- EXPECT_EQ("", Create(Type::kPresentationAttribute)->CustomCSSText());
-}
-
-} // namespace
-} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/css_pending_substitution_value.cc b/chromium/third_party/blink/renderer/core/css/css_pending_substitution_value.cc
index c2a141e970c..40bf775cf6a 100644
--- a/chromium/third_party/blink/renderer/core/css/css_pending_substitution_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_pending_substitution_value.cc
@@ -7,7 +7,8 @@
namespace blink {
namespace cssvalue {
-void CSSPendingSubstitutionValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSPendingSubstitutionValue::TraceAfterDispatch(
+ blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
visitor->Trace(shorthand_value_);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_pending_substitution_value.h b/chromium/third_party/blink/renderer/core/css/css_pending_substitution_value.h
index 70b27184c0c..7af6162f99a 100644
--- a/chromium/third_party/blink/renderer/core/css/css_pending_substitution_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_pending_substitution_value.h
@@ -15,13 +15,6 @@ namespace cssvalue {
class CSSPendingSubstitutionValue : public CSSValue {
public:
- static CSSPendingSubstitutionValue* Create(
- CSSPropertyID shorthand_property_id,
- CSSVariableReferenceValue* shorthand_value) {
- return MakeGarbageCollected<CSSPendingSubstitutionValue>(
- shorthand_property_id, shorthand_value);
- }
-
CSSPendingSubstitutionValue(CSSPropertyID shorthand_property_id,
CSSVariableReferenceValue* shorthand_value)
: CSSValue(kPendingSubstitutionValueClass),
@@ -39,7 +32,7 @@ class CSSPendingSubstitutionValue : public CSSValue {
}
String CustomCSSText() const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
CSSPropertyID shorthand_property_id_;
diff --git a/chromium/third_party/blink/renderer/core/css/css_primitive_value.cc b/chromium/third_party/blink/renderer/core/css/css_primitive_value.cc
index 62f98677db1..0c6378150cd 100644
--- a/chromium/third_party/blink/renderer/core/css/css_primitive_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_primitive_value.cc
@@ -553,7 +553,7 @@ String CSSPrimitiveValue::CustomCSSText() const {
return To<CSSNumericLiteralValue>(this)->CustomCSSText();
}
-void CSSPrimitiveValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSPrimitiveValue::TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_primitive_value.h b/chromium/third_party/blink/renderer/core/css/css_primitive_value.h
index b1eb925177d..2cfe667e733 100644
--- a/chromium/third_party/blink/renderer/core/css/css_primitive_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_primitive_value.h
@@ -248,7 +248,7 @@ class CORE_EXPORT CSSPrimitiveValue : public CSSValue {
String CustomCSSText() const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
static UnitType CanonicalUnitTypeForCategory(UnitCategory);
static double ConversionToCanonicalUnitsScaleFactor(UnitType);
diff --git a/chromium/third_party/blink/renderer/core/css/css_primitive_value_mappings.h b/chromium/third_party/blink/renderer/core/css/css_primitive_value_mappings.h
index e49b90bfff3..21bba087219 100644
--- a/chromium/third_party/blink/renderer/core/css/css_primitive_value_mappings.h
+++ b/chromium/third_party/blink/renderer/core/css/css_primitive_value_mappings.h
@@ -226,6 +226,9 @@ inline CSSIdentifierValue::CSSIdentifierValue(ControlPart e)
case kNoControlPart:
value_id_ = CSSValueID::kNone;
break;
+ case kAutoPart:
+ value_id_ = CSSValueID::kAuto;
+ break;
case kCheckboxPart:
value_id_ = CSSValueID::kCheckbox;
break;
@@ -305,8 +308,10 @@ template <>
inline ControlPart CSSIdentifierValue::ConvertTo() const {
if (value_id_ == CSSValueID::kNone)
return kNoControlPart;
+ if (value_id_ == CSSValueID::kAuto)
+ return kAutoPart;
return ControlPart(static_cast<int>(value_id_) -
- static_cast<int>(CSSValueID::kCheckbox) + 1);
+ static_cast<int>(CSSValueID::kCheckbox) + kCheckboxPart);
}
template <>
@@ -1425,31 +1430,31 @@ template <>
inline TouchAction CSSIdentifierValue::ConvertTo() const {
switch (value_id_) {
case CSSValueID::kNone:
- return TouchAction::kTouchActionNone;
+ return TouchAction::kNone;
case CSSValueID::kAuto:
- return TouchAction::kTouchActionAuto;
+ return TouchAction::kAuto;
case CSSValueID::kPanLeft:
- return TouchAction::kTouchActionPanLeft;
+ return TouchAction::kPanLeft;
case CSSValueID::kPanRight:
- return TouchAction::kTouchActionPanRight;
+ return TouchAction::kPanRight;
case CSSValueID::kPanX:
- return TouchAction::kTouchActionPanX;
+ return TouchAction::kPanX;
case CSSValueID::kPanUp:
- return TouchAction::kTouchActionPanUp;
+ return TouchAction::kPanUp;
case CSSValueID::kPanDown:
- return TouchAction::kTouchActionPanDown;
+ return TouchAction::kPanDown;
case CSSValueID::kPanY:
- return TouchAction::kTouchActionPanY;
+ return TouchAction::kPanY;
case CSSValueID::kManipulation:
- return TouchAction::kTouchActionManipulation;
+ return TouchAction::kManipulation;
case CSSValueID::kPinchZoom:
- return TouchAction::kTouchActionPinchZoom;
+ return TouchAction::kPinchZoom;
default:
break;
}
NOTREACHED();
- return TouchAction::kTouchActionNone;
+ return TouchAction::kNone;
}
template <>
@@ -1756,16 +1761,17 @@ inline OverflowAlignment CSSIdentifierValue::ConvertTo() const {
}
template <>
-inline CSSIdentifierValue::CSSIdentifierValue(ScrollBehavior behavior)
+inline CSSIdentifierValue::CSSIdentifierValue(
+ mojom::blink::ScrollBehavior behavior)
: CSSValue(kIdentifierClass) {
switch (behavior) {
- case kScrollBehaviorAuto:
+ case mojom::blink::ScrollBehavior::kAuto:
value_id_ = CSSValueID::kAuto;
break;
- case kScrollBehaviorSmooth:
+ case mojom::blink::ScrollBehavior::kSmooth:
value_id_ = CSSValueID::kSmooth;
break;
- case kScrollBehaviorInstant:
+ case mojom::blink::ScrollBehavior::kInstant:
// Behavior 'instant' is only allowed in ScrollOptions arguments passed to
// CSSOM scroll APIs.
NOTREACHED();
@@ -1773,17 +1779,17 @@ inline CSSIdentifierValue::CSSIdentifierValue(ScrollBehavior behavior)
}
template <>
-inline ScrollBehavior CSSIdentifierValue::ConvertTo() const {
+inline mojom::blink::ScrollBehavior CSSIdentifierValue::ConvertTo() const {
switch (GetValueID()) {
case CSSValueID::kAuto:
- return kScrollBehaviorAuto;
+ return mojom::blink::ScrollBehavior::kAuto;
case CSSValueID::kSmooth:
- return kScrollBehaviorSmooth;
+ return mojom::blink::ScrollBehavior::kSmooth;
default:
break;
}
NOTREACHED();
- return kScrollBehaviorAuto;
+ return mojom::blink::ScrollBehavior::kAuto;
}
template <>
@@ -1951,6 +1957,9 @@ inline CSSIdentifierValue::CSSIdentifierValue(TextUnderlinePosition position)
case kTextUnderlinePositionAuto:
value_id_ = CSSValueID::kAuto;
break;
+ case kTextUnderlinePositionFromFont:
+ value_id_ = CSSValueID::kFromFont;
+ break;
case kTextUnderlinePositionUnder:
value_id_ = CSSValueID::kUnder;
break;
@@ -1968,6 +1977,8 @@ inline TextUnderlinePosition CSSIdentifierValue::ConvertTo() const {
switch (GetValueID()) {
case CSSValueID::kAuto:
return kTextUnderlinePositionAuto;
+ case CSSValueID::kFromFont:
+ return kTextUnderlinePositionFromFont;
case CSSValueID::kUnder:
return kTextUnderlinePositionUnder;
case CSSValueID::kLeft:
diff --git a/chromium/third_party/blink/renderer/core/css/css_properties.json5 b/chromium/third_party/blink/renderer/core/css/css_properties.json5
index 277d775e0c2..6ec7f584d08 100644
--- a/chromium/third_party/blink/renderer/core/css/css_properties.json5
+++ b/chromium/third_party/blink/renderer/core/css/css_properties.json5
@@ -354,12 +354,32 @@
physical_group: {
valid_type: "str",
valid_values: ["border", "border-color", "border-style", "border-width",
- "inset", "intrinsic-size", "margin", "max-size",
+ "inset", "margin", "max-size",
"min-size", "overflow", "padding", "scroll-margin",
"scroll-padding", "size", "visited-border-color"],
}
},
+ // - surrogate_for: "other-property"
+ //
+ // A surrogate is a property which acts like another property. Unlike an
+ // alias (which is resolved as parse-time), a surrogate exists alongside
+ // the original in the parsed rule, and in the cascade.
+ //
+ // However, surrogates modify the same fields on ComputedStyle. Examples of
+ // surrogates are:
+ //
+ // * -webkit-writing-mode (surrogate of writing-mode)
+ // * inline-size (surrogate for width, or height)
+ // * All css-logical propeties in general
+ //
+ // Note that for properties that use direction_aware_options,
+ // 'surrogate_for' should not be set, as the mapping is determined at
+ // run-time (depending og e.g. 'direction').
+ surrogate_for: {
+ valid_type: "str",
+ },
+
// - priority: "High"
// The priority level for computing the property. Valid values are
// "Animation" (highest), "High" and "Low". Properties with the same
@@ -404,6 +424,30 @@
default: false,
valid_type: "bool",
},
+
+ // - valid_for_first_letter: true
+ //
+ // https://drafts.csswg.org/css-pseudo-4/#first-letter-styling
+ valid_for_first_letter: {
+ default: false,
+ valid_type: "bool",
+ },
+
+ // - valid_for_cue: true
+ //
+ // https://w3c.github.io/webvtt/#the-cue-pseudo-element
+ valid_for_cue: {
+ default: false,
+ valid_type: "bool",
+ },
+
+ // - valid_for_marker: true
+ //
+ // https://drafts.csswg.org/css-pseudo-4/#marker-pseudo
+ valid_for_marker: {
+ default: false,
+ valid_type: "bool",
+ },
},
// Members in the data objects should appear in the same order as in the
@@ -422,6 +466,7 @@
priority: "Animation",
typedom_types: ["Time"],
separator: ",",
+ valid_for_marker: true,
},
{
name: "animation-direction",
@@ -435,6 +480,7 @@
},
priority: "Animation",
separator: ",",
+ valid_for_marker: true,
},
{
name: "animation-duration",
@@ -447,6 +493,7 @@
priority: "Animation",
typedom_types: ["Time"],
separator: ",",
+ valid_for_marker: true,
},
{
name: "animation-fill-mode",
@@ -459,6 +506,7 @@
keywords: ["none", "forwards", "backwards", "both"],
typedom_types: ["Keyword"],
separator: ",",
+ valid_for_marker: true,
},
{
name: "animation-iteration-count",
@@ -473,6 +521,7 @@
keywords: ["infinite"],
typedom_types: ["Keyword", "Number"],
separator: ",",
+ valid_for_marker: true,
},
{
name: "animation-name",
@@ -484,7 +533,8 @@
priority: "Animation",
keywords: ["none"],
typedom_types: ["Keyword"],
- separator: ","
+ separator: ",",
+ valid_for_marker: true,
},
{
name: "animation-play-state",
@@ -497,6 +547,7 @@
keywords: ["running", "paused"],
typedom_types: ["Keyword"],
separator: ",",
+ valid_for_marker: true,
},
{
name: "animation-timing-function",
@@ -521,6 +572,7 @@
],
typedom_types: ["Keyword"],
separator: ",",
+ valid_for_marker: true,
},
{
name: "transition-delay",
@@ -532,6 +584,7 @@
priority: "Animation",
typedom_types: ["Time"],
separator: ",",
+ valid_for_marker: true,
},
{
name: "transition-duration",
@@ -543,6 +596,7 @@
attribute: "Duration",
},
priority: "Animation",
+ valid_for_marker: true,
},
{
name: "transition-property",
@@ -553,7 +607,8 @@
},
priority: "Animation",
keywords: ["none"],
- typedom_types: ["Keyword"]
+ typedom_types: ["Keyword"],
+ valid_for_marker: true,
},
{
name: "transition-timing-function",
@@ -577,6 +632,7 @@
"step-end"],
typedom_types: ["Keyword"],
separator: ",",
+ valid_for_marker: true,
},
// High Priority and all other font properties.
@@ -598,6 +654,9 @@
keywords: ["currentcolor"],
typedom_types: ["Keyword"],
affected_by_forced_colors: true,
+ valid_for_first_letter: true,
+ valid_for_cue: true,
+ valid_for_marker: true,
},
{
name: "direction",
@@ -612,6 +671,7 @@
type_name: "TextDirection",
style_builder_custom_functions: ["value"],
priority: "High",
+ valid_for_marker: true,
},
{
name: "font-family",
@@ -623,6 +683,9 @@
type_name: "FontDescription::FamilyDescription",
converter: "ConvertFontFamily",
priority: "High",
+ valid_for_first_letter: true,
+ valid_for_cue: true,
+ valid_for_marker: true,
},
{
name: "font-kerning",
@@ -634,6 +697,8 @@
priority: "High",
keywords: ["auto", "normal", "none"],
typedom_types: ["Keyword"],
+ valid_for_first_letter: true,
+ valid_for_marker: true,
},
{
name: "font-optical-sizing",
@@ -644,7 +709,9 @@
type_name: "OpticalSizing",
priority: "High",
keywords: ["auto", "none"],
- typedom_types: ["Keyword"]
+ typedom_types: ["Keyword"],
+ valid_for_first_letter: true,
+ valid_for_marker: true,
},
{
name: "font-size",
@@ -657,7 +724,10 @@
converter: "ConvertFontSize",
priority: "High",
keywords: ["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "xxx-large", "larger", "smaller", "-webkit-xxx-large"],
- typedom_types: ["Keyword", "Length", "Percentage"]
+ typedom_types: ["Keyword", "Length", "Percentage"],
+ valid_for_first_letter: true,
+ valid_for_cue: true,
+ valid_for_marker: true,
},
{
name: "font-size-adjust",
@@ -670,7 +740,9 @@
converter: "ConvertFontSizeAdjust",
priority: "High",
keywords: ["none"],
- typedom_types: ["Keyword", "Number"]
+ typedom_types: ["Keyword", "Number"],
+ valid_for_first_letter: true,
+ valid_for_marker: true,
},
{
name: "font-stretch",
@@ -685,7 +757,10 @@
"normal", "ultra-condensed", "extra-condensed", "condensed",
"semi-condensed", "semi-expanded", "expanded", "extra-expanded", "ultra-expanded"
],
- typedom_types: ["Keyword", "Percentage"]
+ typedom_types: ["Keyword", "Percentage"],
+ valid_for_first_letter: true,
+ valid_for_cue: true,
+ valid_for_marker: true,
},
{
name: "font-style",
@@ -698,6 +773,9 @@
priority: "High",
keywords: ["normal", "italic", "oblique"],
typedom_types: ["Keyword"],
+ valid_for_first_letter: true,
+ valid_for_cue: true,
+ valid_for_marker: true,
},
{
name: "font-variant-ligatures",
@@ -715,6 +793,8 @@
"no-contextual"
],
typedom_types: ["Keyword"],
+ valid_for_first_letter: true,
+ valid_for_marker: true,
},
{
name: "font-variant-caps",
@@ -729,6 +809,8 @@
"all-petite-caps", "unicase", "titling-caps"
],
typedom_types: ["Keyword"],
+ valid_for_first_letter: true,
+ valid_for_marker: true,
},
{
name: "font-variant-east-asian",
@@ -743,6 +825,8 @@
"traditional", "full-width", "proportional-width", "ruby"
],
typedom_types: ["Keyword"],
+ valid_for_first_letter: true,
+ valid_for_marker: true,
},
{
name: "font-variant-numeric",
@@ -758,6 +842,8 @@
"slashed-zero"
],
typedom_types: ["Keyword"],
+ valid_for_first_letter: true,
+ valid_for_marker: true,
},
{
name: "font-weight",
@@ -770,7 +856,10 @@
converter: "ConvertFontWeight",
priority: "High",
keywords: ["normal", "bold", "bolder", "lighter"],
- typedom_types: ["Keyword", "Number"]
+ typedom_types: ["Keyword", "Number"],
+ valid_for_first_letter: true,
+ valid_for_cue: true,
+ valid_for_marker: true,
},
{
name: "font-feature-settings",
@@ -783,6 +872,8 @@
priority: "High",
keywords: ["normal"],
typedom_types: ["Keyword"],
+ valid_for_first_letter: true,
+ valid_for_marker: true,
},
{
name: "font-variation-settings",
@@ -794,7 +885,10 @@
converter: "ConvertFontVariationSettings",
priority: "High",
keywords: ["normal"],
- typedom_types: ["Keyword"]
+ typedom_types: ["Keyword"],
+ valid_for_first_letter: true,
+ valid_for_cue: true,
+ valid_for_marker: true,
},
{
name: "-webkit-font-smoothing",
@@ -803,6 +897,7 @@
font: true,
type_name: "FontSmoothingMode",
priority: "High",
+ valid_for_first_letter: true,
},
{
name: "forced-color-adjust",
@@ -864,6 +959,7 @@
type_name: "WritingMode",
style_builder_custom_functions: ["value"],
priority: "High",
+ surrogate_for: "writing-mode",
},
{
name: "text-rendering",
@@ -924,6 +1020,19 @@
converter: "ConvertSelfOrDefaultAlignmentData",
},
{
+ name: "aspect-ratio",
+ property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"],
+ interpolable: false,
+ field_group: "box",
+ field_template: "external",
+ keywords: ["auto"],
+ default_value: "base::nullopt",
+ type_name: "base::Optional<IntSize>",
+ converter: "ConvertAspectRatio",
+ include_paths: ["third_party/blink/renderer/platform/geometry/length_size.h"],
+ runtime_flag: "CSSAspectRatioProperty"
+ },
+ {
name: "backdrop-filter",
property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"],
interpolable: true,
@@ -958,6 +1067,8 @@
style_builder_template_args: {
fill_type: "Attachment",
},
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "background-blend-mode",
@@ -974,6 +1085,7 @@
fill_type: "BlendMode",
fill_type_getter: "GetBlendMode",
},
+ valid_for_first_letter: true,
},
{
name: "background-clip",
@@ -985,6 +1097,8 @@
style_builder_template_args: {
fill_type: "Clip",
},
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "background-color",
@@ -1004,6 +1118,8 @@
initial_color: "ComputedStyleInitialValues::InitialBackgroundColor",
},
affected_by_forced_colors: true,
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "background-image",
@@ -1017,6 +1133,8 @@
fill_type: "Image",
fill_type_getter: "GetImage",
},
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "background-origin",
@@ -1028,6 +1146,8 @@
style_builder_template_args: {
fill_type: "Origin",
},
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "background-position-x",
@@ -1037,6 +1157,8 @@
style_builder_template_args: {
fill_type: "PositionX",
},
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "background-position-y",
@@ -1046,6 +1168,8 @@
style_builder_template_args: {
fill_type: "PositionY",
},
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "background-repeat-x",
@@ -1053,6 +1177,8 @@
style_builder_template_args: {
fill_type: "RepeatX",
},
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "background-repeat-y",
@@ -1060,6 +1186,8 @@
style_builder_template_args: {
fill_type: "RepeatY",
},
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "background-size",
@@ -1072,6 +1200,8 @@
style_builder_template_args: {
fill_type: "Size",
},
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "baseline-shift",
@@ -1097,6 +1227,7 @@
converter: "ConvertStyleColor",
style_builder_template: "color",
affected_by_forced_colors: true,
+ valid_for_first_letter: true,
},
{
name: "border-bottom-left-radius",
@@ -1109,6 +1240,7 @@
type_name: "LengthSize",
converter: "ConvertRadius",
typedom_types: ["Length", "Percentage"],
+ valid_for_first_letter: true,
},
{
name: "border-bottom-right-radius",
@@ -1121,6 +1253,7 @@
type_name: "LengthSize",
converter: "ConvertRadius",
typedom_types: ["Length", "Percentage"],
+ valid_for_first_letter: true,
},
{
name: "border-bottom-style",
@@ -1134,6 +1267,7 @@
typedom_types: ["Keyword"],
default_value: "none",
type_name: "EBorderStyle",
+ valid_for_first_letter: true,
},
{
name: "border-bottom-width",
@@ -1148,6 +1282,7 @@
type_name: "LayoutUnit",
computed_style_custom_functions: ["getter", "setter"],
converter: "ConvertBorderWidth",
+ valid_for_first_letter: true,
},
{
name: "border-collapse",
@@ -1168,6 +1303,7 @@
style_builder_template_args: {
modifier_type: "Outset",
},
+ valid_for_first_letter: true,
},
{
name: "border-image-repeat",
@@ -1178,6 +1314,7 @@
style_builder_template_args: {
modifier_type: "Repeat",
},
+ valid_for_first_letter: true,
},
{
name: "border-image-slice",
@@ -1188,6 +1325,7 @@
style_builder_template_args: {
modifier_type: "Slice",
},
+ valid_for_first_letter: true,
},
{
name: "border-image-source",
@@ -1196,6 +1334,7 @@
keywords: ["none"],
typedom_types: ["Keyword", "Image"],
style_builder_custom_functions: ["value"],
+ valid_for_first_letter: true,
},
{
name: "border-image-width",
@@ -1207,6 +1346,7 @@
style_builder_template_args: {
modifier_type: "Width",
},
+ valid_for_first_letter: true,
},
{
name: "border-left-color",
@@ -1223,6 +1363,7 @@
converter: "ConvertStyleColor",
style_builder_template: "color",
affected_by_forced_colors: true,
+ valid_for_first_letter: true,
},
{
name: "border-left-style",
@@ -1236,6 +1377,7 @@
typedom_types: ["Keyword"],
default_value: "none",
type_name: "EBorderStyle",
+ valid_for_first_letter: true,
},
{
name: "border-left-width",
@@ -1250,6 +1392,7 @@
type_name: "LayoutUnit",
computed_style_custom_functions: ["getter", "setter"],
converter: "ConvertBorderWidth",
+ valid_for_first_letter: true,
},
{
name: "border-right-color",
@@ -1266,6 +1409,7 @@
converter: "ConvertStyleColor",
style_builder_template: "color",
affected_by_forced_colors: true,
+ valid_for_first_letter: true,
},
{
name: "border-right-style",
@@ -1279,6 +1423,7 @@
typedom_types: ["Keyword"],
default_value: "none",
type_name: "EBorderStyle",
+ valid_for_first_letter: true,
},
{
name: "border-right-width",
@@ -1293,6 +1438,7 @@
type_name: "LayoutUnit",
computed_style_custom_functions: ["getter", "setter"],
converter: "ConvertBorderWidth",
+ valid_for_first_letter: true,
},
{
name: "border-top-color",
@@ -1309,6 +1455,7 @@
converter: "ConvertStyleColor",
style_builder_template: "color",
affected_by_forced_colors: true,
+ valid_for_first_letter: true,
},
{
name: "border-top-left-radius",
@@ -1321,6 +1468,7 @@
type_name: "LengthSize",
converter: "ConvertRadius",
typedom_types: ["Length", "Percentage"],
+ valid_for_first_letter: true,
},
{
name: "border-top-right-radius",
@@ -1333,6 +1481,7 @@
type_name: "LengthSize",
converter: "ConvertRadius",
typedom_types: ["Length", "Percentage"],
+ valid_for_first_letter: true,
},
{
name: "border-top-style",
@@ -1346,6 +1495,7 @@
typedom_types: ["Keyword"],
default_value: "none",
type_name: "EBorderStyle",
+ valid_for_first_letter: true,
},
{
name: "border-top-width",
@@ -1360,6 +1510,7 @@
type_name: "LayoutUnit",
computed_style_custom_functions: ["getter", "setter"],
converter: "ConvertBorderWidth",
+ valid_for_first_letter: true,
},
{
name: "bottom",
@@ -1387,6 +1538,7 @@
keywords: ["none"],
typedom_types: ["Keyword"],
affected_by_forced_colors: true,
+ valid_for_first_letter: true,
},
{
name: "box-sizing",
@@ -1572,6 +1724,19 @@
typedom_types: ["Keyword"],
},
{
+ name: "contain-intrinsic-size",
+ property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"],
+ interpolable: true,
+ field_group: "box",
+ field_template: "external",
+ keywords: ["auto"],
+ default_value: "LengthSize(Length::Auto(), Length::Auto())",
+ type_name: "LengthSize",
+ converter: "ConvertIntrinsicSize",
+ include_paths: ["third_party/blink/renderer/platform/geometry/length_size.h"],
+ runtime_flag: "CSSIntrinsicSize"
+ },
+ {
name: "content",
property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"],
field_group: "*",
@@ -1583,6 +1748,7 @@
type_name: "ContentData",
computed_style_custom_functions: ["getter", "setter"],
style_builder_custom_functions: ["initial", "inherit", "value"],
+ valid_for_marker: true,
},
{
name: "counter-increment",
@@ -1783,6 +1949,7 @@
default_value: "none",
name_for_methods: "Floating",
type_name: "EFloat",
+ valid_for_first_letter: true,
},
{
name: "flood-color",
@@ -1975,56 +2142,12 @@
runtime_flag: "ImageOrientation",
field_group: "*",
field_template: "primitive",
- default_value: "false",
+ default_value: "true",
name_for_methods: "RespectImageOrientation",
type_name: "bool",
converter: "ConvertImageOrientation",
},
{
- name: "intrinsic-block-size",
- property_methods: ["ParseSingleValue"],
- direction_aware_options: {
- resolver: "block",
- physical_group: "intrinsic-size"
- },
- runtime_flag: "CSSIntrinsicSize"
- },
- {
- name: "intrinsic-height",
- property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"],
- interpolable: true,
- field_group: "box",
- field_template: "external",
- keywords: ["auto", "legacy"],
- default_value: "IntrinsicLength()",
- type_name: "IntrinsicLength",
- converter: "ConvertIntrinsicLength",
- include_paths: ["third_party/blink/renderer/core/style/intrinsic_length.h"],
- runtime_flag: "CSSIntrinsicSize"
- },
- {
- name: "intrinsic-inline-size",
- property_methods: ["ParseSingleValue"],
- direction_aware_options: {
- resolver: "inline",
- physical_group: "intrinsic-size"
- },
- runtime_flag: "CSSIntrinsicSize"
- },
- {
- name: "intrinsic-width",
- property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"],
- interpolable: true,
- field_group: "box",
- field_template: "external",
- keywords: ["auto", "legacy"],
- default_value: "IntrinsicLength()",
- type_name: "IntrinsicLength",
- converter: "ConvertIntrinsicLength",
- include_paths: ["third_party/blink/renderer/core/style/intrinsic_length.h"],
- runtime_flag: "CSSIntrinsicSize"
- },
- {
name: "isolation",
property_methods: ["CSSValueFromComputedStyleInternal"],
field_group: "*",
@@ -2082,7 +2205,8 @@
inherited: true,
converter: "ConvertSpacing",
keywords: ["normal"],
- typedom_types: ["Keyword", "Length"]
+ typedom_types: ["Keyword", "Length"],
+ valid_for_first_letter: true,
},
{
name: "lighting-color",
@@ -2105,7 +2229,9 @@
computed_style_custom_functions: ["getter"],
converter: "ConvertLineHeight",
keywords: ["normal"],
- typedom_types: ["Keyword", "Length", "Number", "Percentage"]
+ typedom_types: ["Keyword", "Length", "Number", "Percentage"],
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "line-height-step",
@@ -2177,7 +2303,8 @@
converter: "ConvertQuirkyLength",
computed_style_custom_functions: ["setter"],
keywords: ["auto"],
- typedom_types: ["Keyword", "Length", "Percentage"]
+ typedom_types: ["Keyword", "Length", "Percentage"],
+ valid_for_first_letter: true,
},
{
name: "margin-left",
@@ -2190,7 +2317,8 @@
converter: "ConvertQuirkyLength",
computed_style_custom_functions: ["setter"],
keywords: ["auto"],
- typedom_types: ["Keyword", "Length", "Percentage"]
+ typedom_types: ["Keyword", "Length", "Percentage"],
+ valid_for_first_letter: true,
},
{
name: "margin-right",
@@ -2203,7 +2331,8 @@
converter: "ConvertQuirkyLength",
computed_style_custom_functions: ["setter"],
keywords: ["auto"],
- typedom_types: ["Keyword", "Length", "Percentage"]
+ typedom_types: ["Keyword", "Length", "Percentage"],
+ valid_for_first_letter: true,
},
{
name: "margin-top",
@@ -2216,7 +2345,8 @@
converter: "ConvertQuirkyLength",
computed_style_custom_functions: ["setter"],
keywords: ["auto"],
- typedom_types: ["Keyword", "Length", "Percentage"]
+ typedom_types: ["Keyword", "Length", "Percentage"],
+ valid_for_first_letter: true,
},
{
name: "marker-end",
@@ -2271,6 +2401,17 @@
keywords: ["luminance", "alpha"],
typedom_types: ["Keyword"]
},
+ // TODO(rbuis): should be moved to high priority later.
+ {
+ name: "math-style",
+ property_methods: ["CSSValueFromComputedStyleInternal"],
+ field_template: "keyword",
+ inherited: true,
+ keywords: ["inline", "display"],
+ typedom_types: ["Keyword"],
+ default_value: "inline",
+ runtime_flag: "CSSMathStyle"
+ },
{
name: "max-height",
property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"],
@@ -2278,7 +2419,7 @@
interpolable: true,
field_group: "box",
field_template: "<length>",
- default_value: "Length::MaxSizeNone()",
+ default_value: "Length::None()",
converter: "ConvertLengthMaxSizing",
keywords: ["none"],
typedom_types: ["Keyword", "Length", "Percentage"]
@@ -2290,7 +2431,7 @@
interpolable: true,
field_group: "box",
field_template: "<length>",
- default_value: "Length::MaxSizeNone()",
+ default_value: "Length::None()",
converter: "ConvertLengthMaxSizing",
keywords: ["none"],
typedom_types: ["Keyword", "Length", "Percentage"]
@@ -2430,7 +2571,9 @@
default_value: "1.0",
type_name: "float",
computed_style_custom_functions: ["setter"],
- typedom_types: ["Number"]
+ typedom_types: ["Number"],
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "order",
@@ -2444,6 +2587,17 @@
typedom_types: ["Number"]
},
{
+ // This property is used for testing with origin trial intergration only.
+ // It should never be web-exposed.
+ name: "origin-trial-test-property",
+ property_methods: ["CSSValueFromComputedStyleInternal"],
+ field_template: "keyword",
+ default_value: "normal",
+ keywords: ["normal", "none"],
+ typedom_types: ["Keyword"],
+ runtime_flag: "OriginTrialsSampleAPI"
+ },
+ {
name: "orphans",
property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"],
interpolable: true,
@@ -2470,6 +2624,7 @@
converter: "ConvertStyleColor",
style_builder_template: "color",
affected_by_forced_colors: true,
+ valid_for_cue: true,
},
{
name: "outline-offset",
@@ -2482,6 +2637,7 @@
computed_style_custom_functions: ["getter"],
converter: "ConvertComputedLength<int>",
typedom_types: ["Length"],
+ valid_for_cue: true,
},
{
name: "outline-style",
@@ -2496,6 +2652,7 @@
default_value: "none",
type_name: "EBorderStyle",
style_builder_custom_functions: ["initial", "inherit", "value"],
+ valid_for_cue: true,
},
{
name: "outline-width",
@@ -2510,6 +2667,7 @@
converter: "ConvertLineWidth<unsigned short>",
keywords: ["thin", "medium", "thick"],
typedom_types: ["Keyword", "Length"],
+ valid_for_cue: true,
},
{
name: "overflow-anchor",
@@ -2612,7 +2770,8 @@
default_value: "Length::Fixed()",
converter: "ConvertLength",
computed_style_custom_functions: ["setter"],
- typedom_types: ["Keyword", "Length", "Percentage"]
+ typedom_types: ["Keyword", "Length", "Percentage"],
+ valid_for_first_letter: true,
},
{
name: "padding-left",
@@ -2624,7 +2783,8 @@
default_value: "Length::Fixed()",
converter: "ConvertLength",
computed_style_custom_functions: ["setter"],
- typedom_types: ["Keyword", "Length", "Percentage"]
+ typedom_types: ["Keyword", "Length", "Percentage"],
+ valid_for_first_letter: true,
},
{
name: "padding-right",
@@ -2636,7 +2796,8 @@
default_value: "Length::Fixed()",
converter: "ConvertLength",
computed_style_custom_functions: ["setter"],
- typedom_types: ["Keyword", "Length", "Percentage"]
+ typedom_types: ["Keyword", "Length", "Percentage"],
+ valid_for_first_letter: true,
},
{
name: "padding-top",
@@ -2648,7 +2809,20 @@
default_value: "Length::Fixed()",
converter: "ConvertLength",
computed_style_custom_functions: ["setter"],
- typedom_types: ["Keyword", "Length", "Percentage"]
+ typedom_types: ["Keyword", "Length", "Percentage"],
+ valid_for_first_letter: true,
+ },
+ {
+ name: "page",
+ field_group: "*",
+ property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"],
+ converter: "ConvertPage",
+ type_name: "AtomicString",
+ default_value: "AtomicString()",
+ field_template: "external",
+ keywords: ["auto"],
+ typedom_types: ["Keyword"],
+ runtime_flag: "NamedPages"
},
{
name: "paint-order",
@@ -2724,18 +2898,13 @@
typedom_types: ["Keyword"]
},
{
- name: "render-subtree",
+ name: "subtree-visibility",
property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"],
- field_group: "*",
- field_size: 3,
- field_template: "multi_keyword",
- keywords: ["none", "invisible", "skip-activation", "skip-viewport-activation"],
- default_value: "none",
- name_for_methods: "RenderSubtree",
- type_name: "RenderSubtreeFlags",
- converter: "ConvertFlags<RenderSubtreeFlags>",
+ field_template: "keyword",
+ keywords: ["visible", "auto", "hidden", "hidden-matchable"],
+ default_value: "visible",
typedom_types: ["Keyword"],
- runtime_flag: "CSSRenderSubtree"
+ runtime_flag: "CSSSubtreeVisibility"
},
{
name: "resize",
@@ -2792,8 +2961,8 @@
field_group: "*",
field_size: 2, // FIXME: Convert this to a keyword field
field_template: "primitive",
- default_value: "kScrollBehaviorAuto",
- type_name: "ScrollBehavior",
+ default_value: "mojom::blink::ScrollBehavior::kAuto",
+ type_name: "mojom::blink::ScrollBehavior",
keywords: ["auto", "smooth"],
typedom_types: ["Keyword"],
},
@@ -3238,6 +3407,7 @@
typedom_types: ["Keyword"],
default_value: "none",
name_for_methods: "TextCombine",
+ valid_for_marker: true,
},
{
name: "text-decoration-color",
@@ -3253,6 +3423,8 @@
converter: "ConvertStyleColor",
style_builder_template: "color",
affected_by_forced_colors: true,
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "text-decoration-line",
@@ -3265,6 +3437,8 @@
name_for_methods: "TextDecoration",
type_name: "TextDecoration",
converter: "ConvertFlags<TextDecoration>",
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "text-decoration-skip-ink",
@@ -3275,6 +3449,8 @@
keywords: ["none", "auto"],
typedom_types: ["Keyword"],
default_value: "auto",
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "text-decoration-style",
@@ -3284,6 +3460,8 @@
keywords: ["solid", "double", "dotted", "dashed", "wavy"],
typedom_types: ["Keyword"],
default_value: "solid",
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "text-indent",
@@ -3308,7 +3486,8 @@
default_value: "auto",
getter: "GetTextJustify",
type_name: "TextJustify",
- typedom_types: ["Keyword"]
+ typedom_types: ["Keyword"],
+ valid_for_first_letter: true,
},
{
name: "text-overflow",
@@ -3334,6 +3513,8 @@
keywords: ["none"],
typedom_types: ["Keyword"],
affected_by_forced_colors: true,
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "text-size-adjust",
@@ -3359,20 +3540,22 @@
keywords: ["capitalize", "uppercase", "lowercase", "none"],
typedom_types: ["Keyword"],
default_value: "none",
+ valid_for_first_letter: true,
},
{
name: "text-underline-position",
property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"],
inherited: true,
field_group: "*",
- field_size: 3,
+ field_size: 4,
field_template: "primitive",
default_value: "kTextUnderlinePositionAuto",
name_for_methods: "TextUnderlinePosition",
type_name: "unsigned",
converter: "ConvertTextUnderlinePosition",
- keywords: ["auto", "under", "left", "right"],
+ keywords: ["auto", "from-font", "under", "left", "right"],
typedom_types: ["Keyword"],
+ valid_for_first_letter: true,
},
{
name: "top",
@@ -3393,7 +3576,7 @@
field_size: 6, // FIXME: Make this use "kTouchActionBits".
field_template: "primitive",
include_paths: ["third_party/blink/renderer/platform/graphics/touch_action.h"],
- default_value: "TouchAction::kTouchActionAuto",
+ default_value: "TouchAction::kAuto",
type_name: "TouchAction",
converter: "ConvertFlags<blink::TouchAction>",
keywords: ["auto", "none", "pan-x", "pan-left", "pan-right", "pan-y", "pan-up", "pan-down", "pinch-zoom", "manipulation"],
@@ -3501,6 +3684,7 @@
typedom_types: ["Keyword"],
default_value: "normal",
type_name: "UnicodeBidi",
+ valid_for_marker: true,
},
{
name: "vector-effect",
@@ -3516,6 +3700,7 @@
style_builder_custom_functions: ["inherit", "value"],
typedom_types: ["Keyword", "Length", "Percentage"],
keywords: ["baseline", "sub", "super", "text-top", "text-bottom", "middle"],
+ valid_for_first_letter: true,
},
{
name: "visibility",
@@ -3527,6 +3712,8 @@
keywords: ["visible", "hidden", "collapse"],
typedom_types: ["Keyword"],
default_value: "visible",
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "x",
@@ -3575,11 +3762,13 @@
name_for_methods: "HorizontalBorderSpacing",
type_name: "short",
converter: "ConvertComputedLength<short>",
+ valid_for_first_letter: true,
},
{
name: "-webkit-border-image",
property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"],
style_builder_custom_functions: ["value"],
+ valid_for_first_letter: true,
},
{
name: "-webkit-border-vertical-spacing",
@@ -3592,6 +3781,7 @@
name_for_methods: "VerticalBorderSpacing",
type_name: "short",
converter: "ConvertComputedLength<short>",
+ valid_for_first_letter: true,
},
// For valid values of box-align see
// http://www.w3.org/TR/2009/WD-css3-flexbox-20090723/#alignment
@@ -3822,36 +4012,6 @@
type_name: "int",
},
{
- name: "-webkit-margin-after-collapse",
- property_methods: ["CSSValueFromComputedStyleInternal"],
- field_group: "*",
- field_template: "keyword",
- keywords: ["collapse", "separate", "discard"],
- default_value: "collapse",
- type_name: "EMarginCollapse",
- },
- {
- name: "-webkit-margin-before-collapse",
- property_methods: ["CSSValueFromComputedStyleInternal"],
- field_group: "*",
- field_template: "keyword",
- keywords: ["collapse", "separate", "discard"],
- default_value: "collapse",
- type_name: "EMarginCollapse",
- },
- {
- name: "-webkit-margin-bottom-collapse",
- property_methods: ["CSSValueFromComputedStyleInternal"],
- name_for_methods: "MarginAfterCollapse",
- type_name: "EMarginCollapse",
- },
- {
- name: "-webkit-margin-top-collapse",
- property_methods: ["CSSValueFromComputedStyleInternal"],
- name_for_methods: "MarginBeforeCollapse",
- type_name: "EMarginCollapse",
- },
- {
name: "-webkit-mask-box-image-outset",
property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"],
interpolable: true,
@@ -4159,6 +4319,8 @@
],
typedom_types: ["Keyword"],
default_value: "normal",
+ valid_for_cue: true,
+ valid_for_marker: true,
},
{
name: "widows",
@@ -4211,7 +4373,8 @@
converter: "ConvertSpacing",
keywords: ["normal"],
typedom_types: ["normal"],
- typedom_types: ["Keyword", "Length"]
+ typedom_types: ["Keyword", "Length"],
+ valid_for_first_letter: true,
},
{
name: "z-index",
@@ -4297,7 +4460,8 @@
physical_group: "margin",
},
typedom_types: ["Length", "Percentage"],
- keywords: ["auto"]
+ keywords: ["auto"],
+ valid_for_first_letter: true,
},
{
name: "margin-inline-end",
@@ -4308,7 +4472,8 @@
physical_group: "margin",
},
typedom_types: ["Length", "Percentage"],
- keywords: ["auto"]
+ keywords: ["auto"],
+ valid_for_first_letter: true,
},
{
name: "margin-block-start",
@@ -4319,7 +4484,8 @@
physical_group: "margin",
},
typedom_types: ["Length", "Percentage"],
- keywords: ["auto"]
+ keywords: ["auto"],
+ valid_for_first_letter: true,
},
{
name: "margin-block-end",
@@ -4330,7 +4496,8 @@
physical_group: "margin",
},
typedom_types: ["Length", "Percentage"],
- keywords: ["auto"]
+ keywords: ["auto"],
+ valid_for_first_letter: true,
},
{
name: "padding-inline-start",
@@ -4379,6 +4546,7 @@
resolver: "inline-start",
physical_group: "border-width",
},
+ valid_for_first_letter: true,
},
{
name: "border-inline-start-style",
@@ -4386,6 +4554,7 @@
resolver: "inline-start",
physical_group: "border-style",
},
+ valid_for_first_letter: true,
},
{
name: "border-inline-start-color",
@@ -4394,6 +4563,7 @@
resolver: "inline-start",
physical_group: "border-color",
},
+ valid_for_first_letter: true,
},
{
name: "border-inline-end-width",
@@ -4402,6 +4572,7 @@
resolver: "inline-end",
physical_group: "border-width",
},
+ valid_for_first_letter: true,
},
{
name: "border-inline-end-style",
@@ -4409,6 +4580,7 @@
resolver: "inline-end",
physical_group: "border-style",
},
+ valid_for_first_letter: true,
},
{
name: "border-inline-end-color",
@@ -4417,6 +4589,7 @@
resolver: "inline-end",
physical_group: "border-color",
},
+ valid_for_first_letter: true,
},
{
name: "border-block-start-width",
@@ -4425,6 +4598,7 @@
resolver: "block-start",
physical_group: "border-width",
},
+ valid_for_first_letter: true,
},
{
name: "border-block-start-style",
@@ -4432,6 +4606,7 @@
resolver: "block-start",
physical_group: "border-style",
},
+ valid_for_first_letter: true,
},
{
name: "border-block-start-color",
@@ -4440,6 +4615,7 @@
resolver: "block-start",
physical_group: "border-color",
},
+ valid_for_first_letter: true,
},
{
name: "border-block-end-width",
@@ -4448,6 +4624,7 @@
resolver: "block-end",
physical_group: "border-width",
},
+ valid_for_first_letter: true,
},
{
name: "border-block-end-style",
@@ -4455,6 +4632,7 @@
resolver: "block-end",
physical_group: "border-style",
},
+ valid_for_first_letter: true,
},
{
name: "border-block-end-color",
@@ -4463,6 +4641,7 @@
resolver: "block-end",
physical_group: "border-color",
},
+ valid_for_first_letter: true,
},
{
name: "inset-inline-start",
@@ -4621,11 +4800,6 @@
style_builder_template: "empty",
},
{
- name: "page",
- property_methods: ["ParseSingleValue"],
- style_builder_template: "empty",
- },
- {
name: "-webkit-font-size-delta",
property_methods: ["ParseSingleValue"],
style_builder_template: "empty",
@@ -5033,12 +5207,6 @@
runtime_flag: "CSSLogical",
},
{
- name: "intrinsic-size",
- longhands: ["intrinsic-width", "intrinsic-height"],
- property_methods: ["ParseShorthand", "CSSValueFromComputedStyleInternal"],
- runtime_flag: "CSSIntrinsicSize"
- },
- {
name: "list-style",
longhands: ["list-style-position", "list-style-image", "list-style-type"],
property_methods: ["ParseShorthand", "CSSValueFromComputedStyleInternal"],
@@ -5215,13 +5383,6 @@
property_methods: ["ParseShorthand", "CSSValueFromComputedStyleInternal"],
},
{
- name: "-webkit-margin-collapse",
- longhands: [
- "-webkit-margin-before-collapse", "-webkit-margin-after-collapse"
- ],
- property_methods: ["ParseShorthand"],
- },
- {
name: "-webkit-mask",
longhands: [
"-webkit-mask-image", "-webkit-mask-position-x",
@@ -5274,6 +5435,10 @@
computed_style_custom_functions: ["getter", "setter"],
style_builder_custom_functions: ["initial", "inherit", "value"],
priority: "High",
+ affected_by_forced_colors: true,
+ valid_for_first_letter: true,
+ valid_for_cue: true,
+ valid_for_marker: true,
},
{
name: "-internal-visited-caret-color",
@@ -5304,6 +5469,7 @@
computed_style_custom_functions: ["getter","setter"],
converter: "ConvertStyleColor",
style_builder_template: "visited_color",
+ affected_by_forced_colors: true,
},
{
name: "-internal-visited-background-color",
@@ -5320,6 +5486,9 @@
style_builder_template_args: {
initial_color: "ComputedStyleInitialValues::InitialBackgroundColor",
},
+ affected_by_forced_colors: true,
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "-internal-visited-border-left-color",
@@ -5333,6 +5502,8 @@
computed_style_custom_functions: ["getter", "setter"],
converter: "ConvertStyleColor",
style_builder_template: "visited_color",
+ affected_by_forced_colors: true,
+ valid_for_first_letter: true,
},
{
name: "-internal-visited-border-right-color",
@@ -5346,6 +5517,8 @@
computed_style_custom_functions: ["getter", "setter"],
converter: "ConvertStyleColor",
style_builder_template: "visited_color",
+ affected_by_forced_colors: true,
+ valid_for_first_letter: true,
},
{
name: "-internal-visited-border-top-color",
@@ -5359,6 +5532,8 @@
computed_style_custom_functions: ["getter", "setter"],
converter: "ConvertStyleColor",
style_builder_template: "visited_color",
+ affected_by_forced_colors: true,
+ valid_for_first_letter: true,
},
{
name: "-internal-visited-border-bottom-color",
@@ -5372,6 +5547,8 @@
computed_style_custom_functions: ["getter", "setter"],
converter: "ConvertStyleColor",
style_builder_template: "visited_color",
+ affected_by_forced_colors: true,
+ valid_for_first_letter: true,
},
{
name: "-internal-visited-border-inline-start-color",
@@ -5381,6 +5558,7 @@
resolver: "inline-start",
physical_group: "visited-border-color",
},
+ valid_for_first_letter: true,
},
{
name: "-internal-visited-border-inline-end-color",
@@ -5390,6 +5568,7 @@
resolver: "inline-end",
physical_group: "visited-border-color",
},
+ valid_for_first_letter: true,
},
{
name: "-internal-visited-border-block-start-color",
@@ -5399,6 +5578,7 @@
resolver: "block-start",
physical_group: "visited-border-color",
},
+ valid_for_first_letter: true,
},
{
name: "-internal-visited-border-block-end-color",
@@ -5408,6 +5588,7 @@
resolver: "block-end",
physical_group: "visited-border-color",
},
+ valid_for_first_letter: true,
},
{
name: "-internal-visited-fill",
@@ -5419,6 +5600,7 @@
setter: "SetInternalVisitedFillPaint",
getter: "FillPaint",
converter: "ConvertSVGPaint",
+ affected_by_forced_colors: true,
},
{
name: "-internal-visited-outline-color",
@@ -5432,6 +5614,8 @@
computed_style_custom_functions: ["getter", "setter"],
converter: "ConvertStyleColor",
style_builder_template: "visited_color",
+ affected_by_forced_colors: true,
+ valid_for_cue: true,
},
{
name: "-internal-visited-stroke",
@@ -5443,6 +5627,7 @@
setter: "SetInternalVisitedStrokePaint",
getter: "StrokePaint",
converter: "ConvertSVGPaint",
+ affected_by_forced_colors: true,
},
{
name: "-internal-visited-text-decoration-color",
@@ -5456,6 +5641,9 @@
computed_style_custom_functions: ["getter", "setter"],
converter: "ConvertStyleColor",
style_builder_template: "visited_color",
+ affected_by_forced_colors: true,
+ valid_for_first_letter: true,
+ valid_for_cue: true,
},
{
name: "-internal-visited-text-emphasis-color",
@@ -5473,6 +5661,7 @@
style_builder_template_args: {
initial_color: "StyleColor::CurrentColor",
},
+ affected_by_forced_colors: true,
},
{
name: "-internal-visited-text-fill-color",
@@ -5518,6 +5707,29 @@
field_group: "*",
priority: "High",
style_builder_custom_functions: ["initial", "inherit", "value"],
+ surrogate_for: "zoom",
+ },
+
+ // Name: -internal-empty-line-height:
+ // Value: none | fabricated
+ // If the element is inline or contains visible text, this property has
+ // no effect.
+ //
+ // 'none'
+ // The box's intrinsic height is 0, and it defines no baseline.
+ // 'fabricated'
+ // The box has intrinsic height and baseline, computed from the current
+ // font metrics.
+ {
+ name: "-internal-empty-line-height",
+ property_methods: ["ParseSingleValue" ],
+ inherited: false,
+ field_group: "*",
+ field_template: "primitive",
+ type_name: "bool",
+ default_value: "false",
+ name_for_methods: "HasLineIfEmpty",
+ converter: "ConvertInternalEmptyLineHeight",
},
// Aliases; these map to the same CSSPropertyID
diff --git a/chromium/third_party/blink/renderer/core/css/css_properties_ranking.json5 b/chromium/third_party/blink/renderer/core/css/css_properties_ranking.json5
index b954fa18522..92919e7e046 100644
--- a/chromium/third_party/blink/renderer/core/css/css_properties_ranking.json5
+++ b/chromium/third_party/blink/renderer/core/css/css_properties_ranking.json5
@@ -380,7 +380,6 @@
"-webkit-padding-end",
"column-rule-width",
"vector-effect",
- "-webkit-margin-top-collapse",
"background-repeat-y",
"text-orientation",
"-webkit-text-emphasis-color",
@@ -464,12 +463,10 @@
"transform-box",
"-webkit-mask-box-image-width",
"scroll-padding-left",
- "-webkit-margin-after-collapse",
"-webkit-mask-box-image-source",
"-webkit-mask-box-image-repeat",
"-webkit-mask-box-image-slice",
"-webkit-mask-box-image-outset",
- "-webkit-margin-before-collapse",
"-webkit-column-rule-color",
"font-variation-settings",
"max-inline-size",
@@ -484,7 +481,6 @@
"scroll-snap-margin",
"-webkit-box-flex-group",
"-webkit-column-break-after",
- "-webkit-margin-bottom-collapse",
"scroll-padding-bottom",
"scroll-padding-right",
"scroll-snap-margin-top",
@@ -511,7 +507,6 @@
"scroll-snap-margin-inline-start",
"place-items",
"place-self",
- "-webkit-margin-collapse",
"-webkit-column-rule-width",
"font-optical-sizing",
"-webkit-border-end-color",
@@ -698,7 +693,8 @@
"border-inline-width",
"inset-block-start",
"syntax",
- "render-subtree",
+ "subtree-visibility",
+ "origin-trial-test-property",
],
"properties": {}
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_property_equality.cc b/chromium/third_party/blink/renderer/core/css/css_property_equality.cc
index da0c5c74ec0..6146932fc66 100644
--- a/chromium/third_party/blink/renderer/core/css/css_property_equality.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_property_equality.cc
@@ -383,10 +383,10 @@ bool CSSPropertyEquality::PropertiesEqual(const PropertyHandle& property,
case CSSPropertyID::kZIndex:
return a.HasAutoZIndex() == b.HasAutoZIndex() &&
(a.HasAutoZIndex() || a.ZIndex() == b.ZIndex());
- case CSSPropertyID::kIntrinsicWidth:
- return a.IntrinsicWidth() == b.IntrinsicWidth();
- case CSSPropertyID::kIntrinsicHeight:
- return a.IntrinsicHeight() == b.IntrinsicHeight();
+ case CSSPropertyID::kContainIntrinsicSize:
+ return a.ContainIntrinsicSize() == b.ContainIntrinsicSize();
+ case CSSPropertyID::kAspectRatio:
+ return a.AspectRatio() == b.AspectRatio();
default:
NOTREACHED();
return true;
diff --git a/chromium/third_party/blink/renderer/core/css/css_property_name.h b/chromium/third_party/blink/renderer/core/css/css_property_name.h
index 64d34c47200..e8f7a46a250 100644
--- a/chromium/third_party/blink/renderer/core/css/css_property_name.h
+++ b/chromium/third_party/blink/renderer/core/css/css_property_name.h
@@ -12,6 +12,8 @@
namespace blink {
+class ExecutionContext;
+
// This class may be used to represent the name of any valid CSS property,
// including custom properties.
class CORE_EXPORT CSSPropertyName {
@@ -29,8 +31,10 @@ class CORE_EXPORT CSSPropertyName {
DCHECK(!custom_property_name.IsNull());
}
- static base::Optional<CSSPropertyName> From(const String& value) {
- const CSSPropertyID property_id = cssPropertyID(value);
+ static base::Optional<CSSPropertyName> From(
+ const ExecutionContext* execution_context,
+ const String& value) {
+ const CSSPropertyID property_id = cssPropertyID(execution_context, value);
if (property_id == CSSPropertyID::kInvalid)
return base::nullopt;
if (property_id == CSSPropertyID::kVariable)
diff --git a/chromium/third_party/blink/renderer/core/css/css_property_name_test.cc b/chromium/third_party/blink/renderer/core/css/css_property_name_test.cc
index 771484377bb..b3d5b72728e 100644
--- a/chromium/third_party/blink/renderer/core/css/css_property_name_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_property_name_test.cc
@@ -3,13 +3,13 @@
// found in the LICENSE file.
#include "third_party/blink/renderer/core/css/css_property_name.h"
-#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/css/properties/css_property.h"
+#include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h"
namespace blink {
-class CSSPropertyNameTest : public testing::Test {
+class CSSPropertyNameTest : public PageTestBase {
public:
CSSPropertyName Empty() const {
return CSSPropertyName(CSSPropertyName::kEmptyValue);
@@ -61,14 +61,20 @@ TEST_F(CSSPropertyNameTest, OperatorEquals) {
}
TEST_F(CSSPropertyNameTest, From) {
- EXPECT_TRUE(CSSPropertyName::From("color"));
- EXPECT_TRUE(CSSPropertyName::From("--x"));
- EXPECT_FALSE(CSSPropertyName::From("notaproperty"));
- EXPECT_FALSE(CSSPropertyName::From("-not-a-property"));
-
- EXPECT_EQ(*CSSPropertyName::From("color"),
- CSSPropertyName(CSSPropertyID::kColor));
- EXPECT_EQ(*CSSPropertyName::From("--x"), CSSPropertyName("--x"));
+ EXPECT_TRUE(
+ CSSPropertyName::From(GetDocument().GetExecutionContext(), "color"));
+ EXPECT_TRUE(
+ CSSPropertyName::From(GetDocument().GetExecutionContext(), "--x"));
+ EXPECT_FALSE(CSSPropertyName::From(GetDocument().GetExecutionContext(),
+ "notaproperty"));
+ EXPECT_FALSE(CSSPropertyName::From(GetDocument().GetExecutionContext(),
+ "-not-a-property"));
+
+ EXPECT_EQ(
+ *CSSPropertyName::From(GetDocument().GetExecutionContext(), "color"),
+ CSSPropertyName(CSSPropertyID::kColor));
+ EXPECT_EQ(*CSSPropertyName::From(GetDocument().GetExecutionContext(), "--x"),
+ CSSPropertyName("--x"));
}
TEST_F(CSSPropertyNameTest, FromNativeCSSProperty) {
diff --git a/chromium/third_party/blink/renderer/core/css/css_property_rule.cc b/chromium/third_party/blink/renderer/core/css/css_property_rule.cc
index 643b1e86cb3..8910daf28af 100644
--- a/chromium/third_party/blink/renderer/core/css/css_property_rule.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_property_rule.cc
@@ -40,7 +40,7 @@ void CSSPropertyRule::Reattach(StyleRuleBase* rule) {
properties_cssom_wrapper_->Reattach(property_rule_->MutableProperties());
}
-void CSSPropertyRule::Trace(blink::Visitor* visitor) {
+void CSSPropertyRule::Trace(Visitor* visitor) {
visitor->Trace(property_rule_);
visitor->Trace(properties_cssom_wrapper_);
CSSRule::Trace(visitor);
diff --git a/chromium/third_party/blink/renderer/core/css/css_property_rule.h b/chromium/third_party/blink/renderer/core/css/css_property_rule.h
index e977bb35fdc..2b5f55aea45 100644
--- a/chromium/third_party/blink/renderer/core/css/css_property_rule.h
+++ b/chromium/third_party/blink/renderer/core/css/css_property_rule.h
@@ -27,7 +27,7 @@ class CSSPropertyRule final : public CSSRule {
CSSStyleDeclaration* style() const;
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
CSSRule::Type type() const override { return kPropertyRule; }
diff --git a/chromium/third_party/blink/renderer/core/css/css_property_source_data.h b/chromium/third_party/blink/renderer/core/css/css_property_source_data.h
index f7dac058925..f33d3c6a593 100644
--- a/chromium/third_party/blink/renderer/core/css/css_property_source_data.h
+++ b/chromium/third_party/blink/renderer/core/css/css_property_source_data.h
@@ -86,7 +86,7 @@ namespace blink {
class CSSRuleSourceData final : public GarbageCollected<CSSRuleSourceData> {
public:
explicit CSSRuleSourceData(StyleRule::RuleType type) : type(type) {}
- void Trace(blink::Visitor* visitor) { visitor->Trace(child_rules); }
+ void Trace(Visitor* visitor) { visitor->Trace(child_rules); }
bool HasProperties() const {
return type == StyleRule::kStyle || type == StyleRule::kFontFace ||
diff --git a/chromium/third_party/blink/renderer/core/css/css_property_value.h b/chromium/third_party/blink/renderer/core/css/css_property_value.h
index 730ddf8eb2d..dc8f65aebc0 100644
--- a/chromium/third_party/blink/renderer/core/css/css_property_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_property_value.h
@@ -95,7 +95,7 @@ class CORE_EXPORT CSSPropertyValue {
bool operator==(const CSSPropertyValue& other) const;
- void Trace(blink::Visitor* visitor) { visitor->Trace(value_); }
+ void Trace(Visitor* visitor) { visitor->Trace(value_); }
private:
CSSPropertyValueMetadata metadata_;
diff --git a/chromium/third_party/blink/renderer/core/css/css_property_value_set.cc b/chromium/third_party/blink/renderer/core/css/css_property_value_set.cc
index 2b5940ed826..94d083ccecb 100644
--- a/chromium/third_party/blink/renderer/core/css/css_property_value_set.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_property_value_set.cc
@@ -33,6 +33,7 @@
#include "third_party/blink/renderer/core/style_property_shorthand.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
+#include "third_party/blink/renderer/platform/wtf/size_assertions.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#ifndef NDEBUG
@@ -105,8 +106,6 @@ ImmutableCSSPropertyValueSet::ImmutableCSSPropertyValueSet(
}
}
-ImmutableCSSPropertyValueSet::~ImmutableCSSPropertyValueSet() = default;
-
// Convert property into an uint16_t for comparison with metadata's property id
// to avoid the compiler converting it to an int multiple times in a loop.
static uint16_t GetConvertedCSSPropertyID(CSSPropertyID property_id) {
@@ -171,7 +170,8 @@ template CORE_EXPORT int ImmutableCSSPropertyValueSet::FindPropertyIndex(
template CORE_EXPORT int ImmutableCSSPropertyValueSet::FindPropertyIndex(
AtRuleDescriptorID) const;
-void ImmutableCSSPropertyValueSet::TraceAfterDispatch(blink::Visitor* visitor) {
+void ImmutableCSSPropertyValueSet::TraceAfterDispatch(
+ blink::Visitor* visitor) const {
const Member<const CSSValue>* values = ValueArray();
for (unsigned i = 0; i < array_size_; i++)
visitor->Trace(values[i]);
@@ -247,7 +247,7 @@ template CORE_EXPORT const CSSValue* CSSPropertyValueSet::GetPropertyCSSValue<
template CORE_EXPORT const CSSValue*
CSSPropertyValueSet::GetPropertyCSSValue<AtomicString>(AtomicString) const;
-void CSSPropertyValueSet::Trace(blink::Visitor* visitor) {
+void CSSPropertyValueSet::Trace(Visitor* visitor) {
if (is_mutable_)
To<MutableCSSPropertyValueSet>(this)->TraceAfterDispatch(visitor);
else
@@ -604,7 +604,8 @@ MutableCSSPropertyValueSet* CSSPropertyValueSet::CopyPropertiesInSet(
list.size());
}
-CSSStyleDeclaration* MutableCSSPropertyValueSet::EnsureCSSStyleDeclaration() {
+CSSStyleDeclaration* MutableCSSPropertyValueSet::EnsureCSSStyleDeclaration(
+ ExecutionContext* execution_context) {
// FIXME: get rid of this weirdness of a CSSStyleDeclaration inside of a
// style property set.
if (cssom_wrapper_) {
@@ -613,7 +614,8 @@ CSSStyleDeclaration* MutableCSSPropertyValueSet::EnsureCSSStyleDeclaration() {
DCHECK(!cssom_wrapper_->ParentElement());
return cssom_wrapper_.Get();
}
- cssom_wrapper_ = MakeGarbageCollected<PropertySetCSSStyleDeclaration>(*this);
+ cssom_wrapper_ = MakeGarbageCollected<PropertySetCSSStyleDeclaration>(
+ execution_context, *this);
return cssom_wrapper_.Get();
}
@@ -637,7 +639,8 @@ template CORE_EXPORT int MutableCSSPropertyValueSet::FindPropertyIndex(
template CORE_EXPORT int MutableCSSPropertyValueSet::FindPropertyIndex(
AtomicString) const;
-void MutableCSSPropertyValueSet::TraceAfterDispatch(blink::Visitor* visitor) {
+void MutableCSSPropertyValueSet::TraceAfterDispatch(
+ blink::Visitor* visitor) const {
visitor->Trace(cssom_wrapper_);
visitor->Trace(property_vector_);
CSSPropertyValueSet::TraceAfterDispatch(visitor);
@@ -654,11 +657,9 @@ unsigned CSSPropertyValueSet::AverageSizeInBytes() {
// See the function above if you need to update this.
struct SameSizeAsCSSPropertyValueSet final
: public GarbageCollected<SameSizeAsCSSPropertyValueSet> {
- unsigned bitfield;
+ uint32_t bitfield;
};
-static_assert(sizeof(CSSPropertyValueSet) ==
- sizeof(SameSizeAsCSSPropertyValueSet),
- "CSSPropertyValueSet should stay small");
+ASSERT_SIZE(CSSPropertyValueSet, SameSizeAsCSSPropertyValueSet);
#ifndef NDEBUG
void CSSPropertyValueSet::ShowStyle() {
@@ -666,6 +667,6 @@ void CSSPropertyValueSet::ShowStyle() {
}
#endif
-void CSSLazyPropertyParser::Trace(blink::Visitor* visitor) {}
+void CSSLazyPropertyParser::Trace(Visitor* visitor) {}
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/css_property_value_set.h b/chromium/third_party/blink/renderer/core/css/css_property_value_set.h
index a16b05b588f..303fc5dccda 100644
--- a/chromium/third_party/blink/renderer/core/css/css_property_value_set.h
+++ b/chromium/third_party/blink/renderer/core/css/css_property_value_set.h
@@ -37,6 +37,7 @@
namespace blink {
class CSSStyleDeclaration;
+class ExecutionContext;
class ImmutableCSSPropertyValueSet;
class MutableCSSPropertyValueSet;
class StyleSheetContents;
@@ -81,7 +82,7 @@ class CORE_EXPORT CSSPropertyValueSet
private:
const CSSValue& PropertyValue() const;
- Member<const CSSPropertyValueSet> property_set_;
+ const CSSPropertyValueSet* property_set_;
unsigned index_;
};
@@ -137,29 +138,28 @@ class CORE_EXPORT CSSPropertyValueSet
bool PropertyMatches(CSSPropertyID, const CSSValue&) const;
- void Trace(blink::Visitor*);
- void TraceAfterDispatch(blink::Visitor* visitor) {}
+ void Trace(Visitor*);
+ void TraceAfterDispatch(blink::Visitor* visitor) const {}
protected:
enum { kMaxArraySize = (1 << 28) - 1 };
- CSSPropertyValueSet(CSSParserMode css_parser_mode)
- : css_parser_mode_(css_parser_mode), is_mutable_(true), array_size_(0) {}
+ explicit CSSPropertyValueSet(CSSParserMode css_parser_mode)
+ : array_size_(0), css_parser_mode_(css_parser_mode), is_mutable_(true) {}
CSSPropertyValueSet(CSSParserMode css_parser_mode,
unsigned immutable_array_size)
- : css_parser_mode_(css_parser_mode), is_mutable_(false) {
- // Avoid min()/max() from std here in the header, because that would require
- // inclusion of <algorithm>, which is slow to compile.
- if (immutable_array_size < unsigned(kMaxArraySize))
- array_size_ = immutable_array_size;
- else
- array_size_ = unsigned(kMaxArraySize);
- }
-
- unsigned css_parser_mode_ : 3;
- mutable unsigned is_mutable_ : 1;
- unsigned array_size_ : 28;
+ // Avoid min()/max() from std here in the header, because that would
+ // require inclusion of <algorithm>, which is slow to compile.
+ : array_size_((immutable_array_size < unsigned(kMaxArraySize))
+ ? immutable_array_size
+ : unsigned(kMaxArraySize)),
+ css_parser_mode_(css_parser_mode),
+ is_mutable_(false) {}
+
+ const uint32_t array_size_ : 28;
+ const uint32_t css_parser_mode_ : 3;
+ const uint32_t is_mutable_ : 1;
friend class PropertySetCSSStyleDeclaration;
DISALLOW_COPY_AND_ASSIGN(CSSPropertyValueSet);
@@ -171,7 +171,7 @@ class CSSLazyPropertyParser : public GarbageCollected<CSSLazyPropertyParser> {
CSSLazyPropertyParser() = default;
virtual ~CSSLazyPropertyParser() = default;
virtual CSSPropertyValueSet* ParseProperties() = 0;
- virtual void Trace(blink::Visitor*);
+ virtual void Trace(Visitor*);
DISALLOW_COPY_AND_ASSIGN(CSSLazyPropertyParser);
};
@@ -182,7 +182,6 @@ class CORE_EXPORT ALIGNAS(alignof(Member<const CSSValue>))
ImmutableCSSPropertyValueSet(const CSSPropertyValue*,
unsigned count,
CSSParserMode);
- ~ImmutableCSSPropertyValueSet();
static ImmutableCSSPropertyValueSet*
Create(const CSSPropertyValue* properties, unsigned count, CSSParserMode);
@@ -195,7 +194,7 @@ class CORE_EXPORT ALIGNAS(alignof(Member<const CSSValue>))
template <typename T> // CSSPropertyID or AtomicString
int FindPropertyIndex(T property) const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
};
inline const Member<const CSSValue>* ImmutableCSSPropertyValueSet::ValueArray()
@@ -277,12 +276,13 @@ class CORE_EXPORT MutableCSSPropertyValueSet : public CSSPropertyValueSet {
SecureContextMode,
StyleSheetContents* context_style_sheet);
- CSSStyleDeclaration* EnsureCSSStyleDeclaration();
+ CSSStyleDeclaration* EnsureCSSStyleDeclaration(
+ ExecutionContext* execution_context);
template <typename T> // CSSPropertyID or AtomicString
int FindPropertyIndex(T property) const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
bool RemovePropertyAtIndex(int, String* return_text);
@@ -309,7 +309,7 @@ struct DowncastTraits<MutableCSSPropertyValueSet> {
inline const CSSPropertyValueMetadata&
CSSPropertyValueSet::PropertyReference::PropertyMetadata() const {
if (auto* mutable_property_set =
- DynamicTo<MutableCSSPropertyValueSet>(property_set_.Get())) {
+ DynamicTo<MutableCSSPropertyValueSet>(property_set_)) {
return mutable_property_set->property_vector_.at(index_).Metadata();
}
return To<ImmutableCSSPropertyValueSet>(*property_set_)
@@ -319,7 +319,7 @@ CSSPropertyValueSet::PropertyReference::PropertyMetadata() const {
inline const CSSValue& CSSPropertyValueSet::PropertyReference::PropertyValue()
const {
if (auto* mutable_property_set =
- DynamicTo<MutableCSSPropertyValueSet>(property_set_.Get())) {
+ DynamicTo<MutableCSSPropertyValueSet>(property_set_)) {
return *mutable_property_set->property_vector_.at(index_).Value();
}
return *To<ImmutableCSSPropertyValueSet>(*property_set_).ValueArray()[index_];
diff --git a/chromium/third_party/blink/renderer/core/css/css_quad_value.cc b/chromium/third_party/blink/renderer/core/css/css_quad_value.cc
index 21a7c604baa..5ecec7e7d35 100644
--- a/chromium/third_party/blink/renderer/core/css/css_quad_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_quad_value.cc
@@ -37,7 +37,7 @@ String CSSQuadValue::CustomCSSText() const {
return result.ToString();
}
-void CSSQuadValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSQuadValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(top_);
visitor->Trace(right_);
visitor->Trace(bottom_);
diff --git a/chromium/third_party/blink/renderer/core/css/css_quad_value.h b/chromium/third_party/blink/renderer/core/css/css_quad_value.h
index 0f5c9c7ef26..711b74bdce7 100644
--- a/chromium/third_party/blink/renderer/core/css/css_quad_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_quad_value.h
@@ -32,12 +32,6 @@ class CORE_EXPORT CSSQuadValue : public CSSValue {
public:
enum TypeForSerialization { kSerializeAsRect, kSerializeAsQuad };
- static CSSQuadValue* Create(CSSValue* value,
- TypeForSerialization serialization_type) {
- return MakeGarbageCollected<CSSQuadValue>(value, value, value, value,
- serialization_type);
- }
-
CSSQuadValue(CSSValue* top,
CSSValue* right,
CSSValue* bottom,
@@ -50,6 +44,14 @@ class CORE_EXPORT CSSQuadValue : public CSSValue {
bottom_(bottom),
left_(left) {}
+ CSSQuadValue(CSSValue* value, TypeForSerialization serialization_type)
+ : CSSValue(kQuadClass),
+ serialization_type_(serialization_type),
+ top_(value),
+ right_(value),
+ bottom_(value),
+ left_(value) {}
+
CSSValue* Top() const { return top_.Get(); }
CSSValue* Right() const { return right_.Get(); }
CSSValue* Bottom() const { return bottom_.Get(); }
@@ -66,7 +68,7 @@ class CORE_EXPORT CSSQuadValue : public CSSValue {
DataEquivalent(bottom_, other.bottom_);
}
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
TypeForSerialization serialization_type_;
diff --git a/chromium/third_party/blink/renderer/core/css/css_ray_value.cc b/chromium/third_party/blink/renderer/core/css/css_ray_value.cc
index d54da15730c..65fac431d66 100644
--- a/chromium/third_party/blink/renderer/core/css/css_ray_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_ray_value.cc
@@ -36,7 +36,7 @@ bool CSSRayValue::Equals(const CSSRayValue& other) const {
DataEquivalent(contain_, other.contain_);
}
-void CSSRayValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSRayValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(angle_);
visitor->Trace(size_);
visitor->Trace(contain_);
diff --git a/chromium/third_party/blink/renderer/core/css/css_ray_value.h b/chromium/third_party/blink/renderer/core/css/css_ray_value.h
index dd642cd7777..ea27a1dcd4f 100644
--- a/chromium/third_party/blink/renderer/core/css/css_ray_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_ray_value.h
@@ -29,7 +29,7 @@ class CSSRayValue : public CSSValue {
bool Equals(const CSSRayValue&) const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
Member<const CSSPrimitiveValue> angle_;
diff --git a/chromium/third_party/blink/renderer/core/css/css_reflect_value.cc b/chromium/third_party/blink/renderer/core/css/css_reflect_value.cc
index 7974b2364fe..4d92d4296c5 100644
--- a/chromium/third_party/blink/renderer/core/css/css_reflect_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_reflect_value.cc
@@ -44,7 +44,7 @@ bool CSSReflectValue::Equals(const CSSReflectValue& other) const {
DataEquivalent(mask_, other.mask_);
}
-void CSSReflectValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSReflectValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(direction_);
visitor->Trace(offset_);
visitor->Trace(mask_);
diff --git a/chromium/third_party/blink/renderer/core/css/css_reflect_value.h b/chromium/third_party/blink/renderer/core/css/css_reflect_value.h
index 50e206b421a..1b6e5749a59 100644
--- a/chromium/third_party/blink/renderer/core/css/css_reflect_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_reflect_value.h
@@ -55,7 +55,7 @@ class CSSReflectValue : public CSSValue {
bool Equals(const CSSReflectValue&) const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
Member<CSSIdentifierValue> direction_;
diff --git a/chromium/third_party/blink/renderer/core/css/css_rule.cc b/chromium/third_party/blink/renderer/core/css/css_rule.cc
index 15d3d4da2a2..9559c41c90f 100644
--- a/chromium/third_party/blink/renderer/core/css/css_rule.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_rule.cc
@@ -31,12 +31,21 @@ struct SameSizeAsCSSRule : public GarbageCollected<SameSizeAsCSSRule>,
public ScriptWrappable {
~SameSizeAsCSSRule() override;
unsigned char bitfields;
- void* pointer_union;
+ Member<ScriptWrappable> member;
+#if !DCHECK_IS_ON()
+ static_assert(sizeof(Member<ScriptWrappable>) == sizeof(void*),
+ "Increasing size of Member increases size of CSSRule");
+#endif // DCHECK_IS_ON()
};
static_assert(sizeof(CSSRule) == sizeof(SameSizeAsCSSRule),
"CSSRule should stay small");
+CSSRule::CSSRule(CSSStyleSheet* parent)
+ : has_cached_selector_text_(false),
+ parent_is_rule_(false),
+ parent_(parent) {}
+
const CSSParserContext* CSSRule::ParserContext(
SecureContextMode secure_context_mode) const {
CSSStyleSheet* style_sheet = parentStyleSheet();
@@ -46,25 +55,26 @@ const CSSParserContext* CSSRule::ParserContext(
void CSSRule::SetParentStyleSheet(CSSStyleSheet* style_sheet) {
parent_is_rule_ = false;
- parent_style_sheet_ = style_sheet;
- MarkingVisitor::WriteBarrier(parent_style_sheet_);
+ parent_ = style_sheet;
}
void CSSRule::SetParentRule(CSSRule* rule) {
parent_is_rule_ = true;
- parent_rule_ = rule;
- MarkingVisitor::WriteBarrier(parent_rule_);
+ parent_ = rule;
}
-void CSSRule::Trace(blink::Visitor* visitor) {
- // This makes the parent link strong, which is different from the
- // pre-oilpan world, where the parent link is mysteriously zeroed under
- // some circumstances.
- if (parent_is_rule_)
- visitor->Trace(parent_rule_);
- else
- visitor->Trace(parent_style_sheet_);
+void CSSRule::Trace(Visitor* visitor) {
+ visitor->Trace(parent_);
ScriptWrappable::Trace(visitor);
}
+bool CSSRule::VerifyParentIsCSSRule() const {
+ return !parent_ || parent_->GetWrapperTypeInfo()->IsSubclass(
+ CSSRule::GetStaticWrapperTypeInfo());
+}
+bool CSSRule::VerifyParentIsCSSStyleSheet() const {
+ return !parent_ || parent_->GetWrapperTypeInfo()->IsSubclass(
+ CSSStyleSheet::GetStaticWrapperTypeInfo());
+}
+
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/css_rule.h b/chromium/third_party/blink/renderer/core/css/css_rule.h
index 32b28627ece..c7e81d9efde 100644
--- a/chromium/third_party/blink/renderer/core/css/css_rule.h
+++ b/chromium/third_party/blink/renderer/core/css/css_rule.h
@@ -71,26 +71,23 @@ class CORE_EXPORT CSSRule : public ScriptWrappable {
void SetParentRule(CSSRule*);
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
CSSStyleSheet* parentStyleSheet() const {
if (parent_is_rule_)
- return parent_rule_ ? parent_rule_->parentStyleSheet() : nullptr;
- return parent_style_sheet_;
+ return parent_ ? ParentAsCSSRule()->parentStyleSheet() : nullptr;
+ return ParentAsCSSStyleSheet();
}
CSSRule* parentRule() const {
- return parent_is_rule_ ? parent_rule_ : nullptr;
+ return parent_is_rule_ ? ParentAsCSSRule() : nullptr;
}
// The CSSOM spec states that "setting the cssText attribute must do nothing."
void setCSSText(const String&) {}
protected:
- CSSRule(CSSStyleSheet* parent)
- : has_cached_selector_text_(false),
- parent_is_rule_(false),
- parent_style_sheet_(parent) {}
+ CSSRule(CSSStyleSheet* parent);
bool HasCachedSelectorText() const { return has_cached_selector_text_; }
void SetHasCachedSelectorText(bool has_cached_selector_text) const {
@@ -100,14 +97,27 @@ class CORE_EXPORT CSSRule : public ScriptWrappable {
const CSSParserContext* ParserContext(SecureContextMode) const;
private:
+ bool VerifyParentIsCSSRule() const;
+ bool VerifyParentIsCSSStyleSheet() const;
+
+ CSSRule* ParentAsCSSRule() const {
+ DCHECK(parent_is_rule_);
+ DCHECK(VerifyParentIsCSSRule());
+ return reinterpret_cast<CSSRule*>(parent_.Get());
+ }
+ CSSStyleSheet* ParentAsCSSStyleSheet() const {
+ DCHECK(!parent_is_rule_);
+ DCHECK(VerifyParentIsCSSStyleSheet());
+ return reinterpret_cast<CSSStyleSheet*>(parent_.Get());
+ }
+
mutable unsigned char has_cached_selector_text_ : 1;
unsigned char parent_is_rule_ : 1;
- // These should be Members, but no Members in unions.
- union {
- CSSRule* parent_rule_;
- CSSStyleSheet* parent_style_sheet_;
- };
+ // parent_ should reference either CSSRule or CSSStyleSheet (both are
+ // descendants of ScriptWrappable). This field should only be accessed
+ // via the getters above (ParentAsCSSRule and ParentAsCSSStyleSheet).
+ Member<ScriptWrappable> parent_;
};
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/css_rule_list.h b/chromium/third_party/blink/renderer/core/css/css_rule_list.h
index f677ac956e9..52fce745177 100644
--- a/chromium/third_party/blink/renderer/core/css/css_rule_list.h
+++ b/chromium/third_party/blink/renderer/core/css/css_rule_list.h
@@ -56,7 +56,7 @@ class LiveCSSRuleList final : public CSSRuleList {
public:
LiveCSSRuleList(Rule* rule) : rule_(rule) {}
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(rule_);
CSSRuleList::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_segmented_font_face.cc b/chromium/third_party/blink/renderer/core/css/css_segmented_font_face.cc
index 3a67864fc52..d5294ee7a9e 100644
--- a/chromium/third_party/blink/renderer/core/css/css_segmented_font_face.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_segmented_font_face.cc
@@ -33,11 +33,22 @@
#include "third_party/blink/renderer/platform/fonts/segmented_font_data.h"
#include "third_party/blink/renderer/platform/fonts/simple_font_data.h"
+// See comment below in CSSSegmentedFontFace::GetFontData - the cache from
+// CSSSegmentedFontFace (which represents a group of @font-face declarations
+// with identical FontSelectionCapabilities but differing by unicode-range) to
+// FontData/SegmentedFontData, (i.e. the actual font blobs that can be used for
+// shaping and painting retrieved from a CSSFontFaceSource) is usually small
+// (less than a dozen, up to tens) for non-animation-cases, but grows fast to
+// thousands when animating variable font parameters. Set a limit until we start
+// dropping cache entries in animation scenarios.
+static constexpr size_t kFontDataTableMaxSize = 250;
+
namespace blink {
CSSSegmentedFontFace::CSSSegmentedFontFace(
FontSelectionCapabilities font_selection_capabilities)
: font_selection_capabilities_(font_selection_capabilities),
+ font_data_table_(kFontDataTableMaxSize),
first_non_css_connected_face_(font_faces_.end()),
approximate_character_count_(0) {}
@@ -45,10 +56,10 @@ CSSSegmentedFontFace::~CSSSegmentedFontFace() = default;
void CSSSegmentedFontFace::PruneTable() {
// Make sure the glyph page tree prunes out all uses of this custom font.
- if (font_data_table_.IsEmpty())
+ if (!font_data_table_.size())
return;
- font_data_table_.clear();
+ font_data_table_.Clear();
}
bool CSSSegmentedFontFace::IsValid() const {
@@ -71,10 +82,11 @@ void CSSSegmentedFontFace::AddFontFace(FontFace* font_face,
if (css_connected) {
font_faces_.InsertBefore(first_non_css_connected_face_, font_face);
} else {
- // This is the only place in Blink that is using addReturnIterator.
- FontFaceList::iterator iterator = font_faces_.AddReturnIterator(font_face);
- if (first_non_css_connected_face_ == font_faces_.end())
- first_non_css_connected_face_ = iterator;
+ FontFaceList::AddResult result = font_faces_.insert(font_face);
+ if (first_non_css_connected_face_ == font_faces_.end()) {
+ --first_non_css_connected_face_;
+ DCHECK_EQ(result.stored_value, &*first_non_css_connected_face_);
+ }
}
}
@@ -102,16 +114,26 @@ scoped_refptr<FontData> CSSSegmentedFontFace::GetFontData(
FontCacheKey key = font_description.CacheKey(
FontFaceCreationParams(), is_unique_match, font_selection_request);
- scoped_refptr<SegmentedFontData>& font_data =
- font_data_table_.insert(key, nullptr).stored_value->value;
- if (font_data && font_data->NumFaces()) {
- // No release, we have a reference to an object in the cache which should
- // retain the ref count it has.
- return font_data;
- }
-
- if (!font_data)
- font_data = SegmentedFontData::Create();
+ // font_data_table_ caches FontData and SegmentedFontData instances, which
+ // provide SimpleFontData objects containing FontPlatformData objects. In the
+ // case of variable font animations, the variable instance SkTypeface is
+ // contained in these FontPlatformData objects. In other words, this cache
+ // stores the recently used variable font instances during a variable font
+ // animation. The cache reflects in how many different sizes, synthetic styles
+ // (bold / italic synthetic versions), or for variable fonts, in how many
+ // variable instances (stretch/style/weightand font-variation-setings
+ // variations) the font is instantiated. In non animation scenarios, there is
+ // usually only a small number of FontData/SegmentedFontData instances created
+ // per CSSSegmentedFontFace. Whereas in variable font animations, this number
+ // grows rapidly.
+ scoped_refptr<SegmentedFontData>* cached_font_data =
+ font_data_table_.Get(key);
+ if (cached_font_data && (*cached_font_data) &&
+ (*cached_font_data)->NumFaces())
+ return *cached_font_data;
+
+ scoped_refptr<SegmentedFontData> created_font_data;
+ created_font_data = SegmentedFontData::Create();
FontDescription requested_font_description(font_description);
if (!font_selection_capabilities_.HasRange()) {
@@ -131,18 +153,21 @@ scoped_refptr<FontData> CSSSegmentedFontFace::GetFontData(
(*it)->CssFontFace()->GetFontData(requested_font_description)) {
DCHECK(!face_font_data->IsSegmented());
if (face_font_data->IsCustomFont()) {
- font_data->AppendFace(base::AdoptRef(new FontDataForRangeSet(
+ created_font_data->AppendFace(base::AdoptRef(new FontDataForRangeSet(
std::move(face_font_data), (*it)->CssFontFace()->Ranges())));
} else {
- font_data->AppendFace(base::AdoptRef(new FontDataForRangeSetFromCache(
- std::move(face_font_data), (*it)->CssFontFace()->Ranges())));
+ created_font_data->AppendFace(
+ base::AdoptRef(new FontDataForRangeSetFromCache(
+ std::move(face_font_data), (*it)->CssFontFace()->Ranges())));
}
}
}
- if (font_data->NumFaces()) {
+ if (created_font_data->NumFaces()) {
+ scoped_refptr<SegmentedFontData> put_to_cache(created_font_data);
+ font_data_table_.Put(std::move(key), std::move(put_to_cache));
// No release, we have a reference to an object in the cache which should
// retain the ref count it has.
- return font_data;
+ return created_font_data;
}
return nullptr;
@@ -192,7 +217,7 @@ void CSSSegmentedFontFace::Match(const String& text,
}
}
-void CSSSegmentedFontFace::Trace(blink::Visitor* visitor) {
+void CSSSegmentedFontFace::Trace(Visitor* visitor) {
visitor->Trace(first_non_css_connected_face_);
visitor->Trace(font_faces_);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_segmented_font_face.h b/chromium/third_party/blink/renderer/core/css/css_segmented_font_face.h
index fad468a96b4..75933f47f7c 100644
--- a/chromium/third_party/blink/renderer/core/css/css_segmented_font_face.h
+++ b/chromium/third_party/blink/renderer/core/css/css_segmented_font_face.h
@@ -31,7 +31,7 @@
#include "third_party/blink/renderer/platform/fonts/segmented_font_data.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
-#include "third_party/blink/renderer/platform/wtf/hash_map.h"
+#include "third_party/blink/renderer/platform/wtf/lru_cache.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
@@ -70,7 +70,7 @@ class CSSSegmentedFontFace final
return approximate_character_count_;
}
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
void PruneTable();
@@ -79,11 +79,10 @@ class CSSSegmentedFontFace final
using FontFaceList = HeapListHashSet<Member<FontFace>>;
FontSelectionCapabilities font_selection_capabilities_;
- HashMap<FontCacheKey,
- scoped_refptr<SegmentedFontData>,
- FontCacheKeyHash,
- FontCacheKeyTraits>
+
+ WTF::LruCache<FontCacheKey, scoped_refptr<SegmentedFontData>>
font_data_table_;
+
// All non-CSS-connected FontFaces are stored after the CSS-connected ones.
FontFaceList font_faces_;
FontFaceList::iterator first_non_css_connected_face_;
diff --git a/chromium/third_party/blink/renderer/core/css/css_selector.cc b/chromium/third_party/blink/renderer/core/css/css_selector.cc
index df7bb9aa9fe..fdda0d6e98b 100644
--- a/chromium/third_party/blink/renderer/core/css/css_selector.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_selector.cc
@@ -297,7 +297,7 @@ PseudoId CSSSelector::GetPseudoId(PseudoType type) {
case kPseudoSlotted:
case kPseudoVideoPersistent:
case kPseudoVideoPersistentAncestor:
- case kPseudoXrImmersiveDomOverlay:
+ case kPseudoXrOverlay:
return kPseudoIdNone;
}
@@ -331,8 +331,6 @@ const static NameToPseudoStruct kPseudoTypeWithoutArgumentsMap[] = {
{"-internal-video-persistent", CSSSelector::kPseudoVideoPersistent},
{"-internal-video-persistent-ancestor",
CSSSelector::kPseudoVideoPersistentAncestor},
- {"-internal-xr-immersive-dom-overlay",
- CSSSelector::kPseudoXrImmersiveDomOverlay},
{"-webkit-any-link", CSSSelector::kPseudoWebkitAnyLink},
{"-webkit-autofill", CSSSelector::kPseudoAutofill},
{"-webkit-drag", CSSSelector::kPseudoDrag},
@@ -410,6 +408,7 @@ const static NameToPseudoStruct kPseudoTypeWithoutArgumentsMap[] = {
{"vertical", CSSSelector::kPseudoVertical},
{"visited", CSSSelector::kPseudoVisited},
{"window-inactive", CSSSelector::kPseudoWindowInactive},
+ {"xr-overlay", CSSSelector::kPseudoXrOverlay},
};
const static NameToPseudoStruct kPseudoTypeWithArgumentsMap[] = {
@@ -597,7 +596,6 @@ void CSSSelector::UpdatePseudoType(const AtomicString& value,
case kPseudoSpatialNavigationInterest:
case kPseudoVideoPersistent:
case kPseudoVideoPersistentAncestor:
- case kPseudoXrImmersiveDomOverlay:
if (mode != kUASheetMode) {
pseudo_type_ = kPseudoUnknown;
break;
@@ -673,6 +671,7 @@ void CSSSelector::UpdatePseudoType(const AtomicString& value,
case kPseudoVisited:
case kPseudoWebkitAnyLink:
case kPseudoWindowInactive:
+ case kPseudoXrOverlay:
if (match_ != kPseudoClass)
pseudo_type_ = kPseudoUnknown;
break;
@@ -787,7 +786,7 @@ const CSSSelector* CSSSelector::SerializeCompound(
case kPseudoLang:
case kPseudoState:
builder.Append('(');
- builder.Append(simple_selector->Argument());
+ SerializeIdentifier(simple_selector->Argument(), builder);
builder.Append(')');
break;
case kPseudoNot:
@@ -804,13 +803,19 @@ const CSSSelector* CSSSelector::SerializeCompound(
}
} else if (simple_selector->match_ == kPseudoElement) {
builder.Append("::");
- builder.Append(simple_selector->SerializingValue());
+ SerializeIdentifier(simple_selector->SerializingValue(), builder);
switch (simple_selector->GetPseudoType()) {
- case kPseudoPart:
- builder.Append('(');
- builder.Append(simple_selector->Argument());
+ case kPseudoPart: {
+ char separator = '(';
+ for (AtomicString part : *simple_selector->PartNames()) {
+ builder.Append(separator);
+ if (separator == '(')
+ separator = ' ';
+ SerializeIdentifier(part, builder);
+ }
builder.Append(')');
break;
+ }
default:
break;
}
@@ -1211,4 +1216,10 @@ bool CSSSelector::RareData::MatchNth(unsigned unsigned_count) {
return (NthBValue() - count) % (-NthAValue()) == 0;
}
+void CSSSelector::SetPartNames(
+ std::unique_ptr<Vector<AtomicString>> part_names) {
+ CreateRareData();
+ data_.rare_data_->part_names_ = std::move(part_names);
+}
+
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/css_selector.h b/chromium/third_party/blink/renderer/core/css/css_selector.h
index 3e30168b202..4e63bd24291 100644
--- a/chromium/third_party/blink/renderer/core/css/css_selector.h
+++ b/chromium/third_party/blink/renderer/core/css/css_selector.h
@@ -231,9 +231,10 @@ class CORE_EXPORT CSSSelector {
kPseudoPictureInPicture,
kPseudoInRange,
kPseudoOutOfRange,
+ kPseudoXrOverlay,
// Pseudo elements in UA ShadowRoots. Available in any stylesheets.
kPseudoWebKitCustomElement,
- // Pseudo elements in UA ShadowRoots. Availble only in UA stylesheets.
+ // Pseudo elements in UA ShadowRoots. Available only in UA stylesheets.
kPseudoBlinkInternalElement,
kPseudoCue,
kPseudoFutureCue,
@@ -253,7 +254,6 @@ class CORE_EXPORT CSSSelector {
kPseudoSlotted,
kPseudoVideoPersistent,
kPseudoVideoPersistentAncestor,
- kPseudoXrImmersiveDomOverlay,
};
enum AttributeMatchType {
@@ -303,6 +303,9 @@ class CORE_EXPORT CSSSelector {
const CSSSelectorList* SelectorList() const {
return has_rare_data_ ? data_.rare_data_->selector_list_.get() : nullptr;
}
+ const Vector<AtomicString>* PartNames() const {
+ return has_rare_data_ ? data_.rare_data_->part_names_.get() : nullptr;
+ }
#ifndef NDEBUG
void Show() const;
@@ -314,6 +317,7 @@ class CORE_EXPORT CSSSelector {
void SetAttribute(const QualifiedName&, AttributeMatchType);
void SetArgument(const AtomicString&);
void SetSelectorList(std::unique_ptr<CSSSelectorList>);
+ void SetPartNames(std::unique_ptr<Vector<AtomicString>>);
void SetNth(int a, int b);
bool MatchNth(unsigned count) const;
@@ -448,6 +452,8 @@ class CORE_EXPORT CSSSelector {
AtomicString argument_; // Used for :contains, :lang, :nth-*
std::unique_ptr<CSSSelectorList>
selector_list_; // Used for :-webkit-any and :not
+ std::unique_ptr<Vector<AtomicString>>
+ part_names_; // Used for ::part() selectors.
private:
RareData(const AtomicString& value);
diff --git a/chromium/third_party/blink/renderer/core/css/css_selector_watch.cc b/chromium/third_party/blink/renderer/core/css/css_selector_watch.cc
index 6e143c94af0..44e63a470b9 100644
--- a/chromium/third_party/blink/renderer/core/css/css_selector_watch.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_selector_watch.cc
@@ -171,7 +171,7 @@ void CSSSelectorWatch::WatchCSSSelectors(const Vector<String>& selectors) {
GetSupplementable()->GetStyleEngine().WatchedSelectorsChanged();
}
-void CSSSelectorWatch::Trace(blink::Visitor* visitor) {
+void CSSSelectorWatch::Trace(Visitor* visitor) {
visitor->Trace(watched_callback_selectors_);
Supplement<Document>::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_selector_watch.h b/chromium/third_party/blink/renderer/core/css/css_selector_watch.h
index 16df789b574..059fd4c0138 100644
--- a/chromium/third_party/blink/renderer/core/css/css_selector_watch.h
+++ b/chromium/third_party/blink/renderer/core/css/css_selector_watch.h
@@ -64,7 +64,7 @@ class CORE_EXPORT CSSSelectorWatch final
void UpdateSelectorMatches(const Vector<String>& removed_selectors,
const Vector<String>& added_selectors);
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
void CallbackSelectorChangeTimerFired(TimerBase*);
diff --git a/chromium/third_party/blink/renderer/core/css/css_selector_watch_test.cc b/chromium/third_party/blink/renderer/core/css/css_selector_watch_test.cc
index 55351d77d3e..46e58f5f810 100644
--- a/chromium/third_party/blink/renderer/core/css/css_selector_watch_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_selector_watch_test.cc
@@ -33,7 +33,7 @@ void CSSSelectorWatchTest::ClearAddedRemoved(CSSSelectorWatch& watch) {
}
TEST_F(CSSSelectorWatchTest, RecalcOnDocumentChange) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<div>
<span id='x' class='a'></span>
<span id='y' class='b'><span></span></span>
diff --git a/chromium/third_party/blink/renderer/core/css/css_shadow_value.cc b/chromium/third_party/blink/renderer/core/css/css_shadow_value.cc
index 49972caaba0..5ac6c6b49a3 100644
--- a/chromium/third_party/blink/renderer/core/css/css_shadow_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_shadow_value.cc
@@ -77,7 +77,7 @@ bool CSSShadowValue::Equals(const CSSShadowValue& other) const {
DataEquivalent(style, other.style);
}
-void CSSShadowValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSShadowValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(x);
visitor->Trace(y);
visitor->Trace(blur);
diff --git a/chromium/third_party/blink/renderer/core/css/css_shadow_value.h b/chromium/third_party/blink/renderer/core/css/css_shadow_value.h
index 34223f84e0c..9cd0d954129 100644
--- a/chromium/third_party/blink/renderer/core/css/css_shadow_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_shadow_value.h
@@ -52,7 +52,7 @@ class CORE_EXPORT CSSShadowValue : public CSSValue {
Member<CSSIdentifierValue> style;
Member<CSSValue> color;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
};
template <>
diff --git a/chromium/third_party/blink/renderer/core/css/css_string_value.cc b/chromium/third_party/blink/renderer/core/css/css_string_value.cc
index b98811386e8..3795a102590 100644
--- a/chromium/third_party/blink/renderer/core/css/css_string_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_string_value.cc
@@ -16,7 +16,7 @@ String CSSStringValue::CustomCSSText() const {
return SerializeString(string_);
}
-void CSSStringValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSStringValue::TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_string_value.h b/chromium/third_party/blink/renderer/core/css/css_string_value.h
index b2b71ee05f3..2641f37aa26 100644
--- a/chromium/third_party/blink/renderer/core/css/css_string_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_string_value.h
@@ -23,7 +23,7 @@ class CSSStringValue : public CSSValue {
return string_ == other.string_;
}
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
String string_;
diff --git a/chromium/third_party/blink/renderer/core/css/css_style_declaration.cc b/chromium/third_party/blink/renderer/core/css/css_style_declaration.cc
index 697a1b6eb9c..5ab57f1fb4e 100644
--- a/chromium/third_party/blink/renderer/core/css/css_style_declaration.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_style_declaration.cc
@@ -78,7 +78,8 @@ bool HasCSSPropertyNamePrefix(const AtomicString& property_name,
return false;
}
-CSSPropertyID ParseCSSPropertyID(const AtomicString& property_name) {
+CSSPropertyID ParseCSSPropertyID(const ExecutionContext* execution_context,
+ const AtomicString& property_name) {
unsigned length = property_name.length();
if (!length)
return CSSPropertyID::kInvalid;
@@ -117,7 +118,7 @@ CSSPropertyID ParseCSSPropertyID(const AtomicString& property_name) {
return CSSPropertyID::kInvalid;
String prop_name = builder.ToString();
- return unresolvedCSSPropertyID(prop_name);
+ return unresolvedCSSPropertyID(execution_context, prop_name);
}
// When getting properties on CSSStyleDeclarations, the name used from
@@ -129,28 +130,36 @@ CSSPropertyID ParseCSSPropertyID(const AtomicString& property_name) {
// Example: 'backgroundPositionY' -> 'background-position-y'
//
// Also, certain prefixes such as 'css-' are stripped.
-CSSPropertyID CssPropertyInfo(const AtomicString& name) {
+CSSPropertyID CssPropertyInfo(const ExecutionContext* execution_context,
+ const AtomicString& name) {
typedef HashMap<String, CSSPropertyID> CSSPropertyIDMap;
DEFINE_STATIC_LOCAL(CSSPropertyIDMap, map, ());
CSSPropertyIDMap::iterator iter = map.find(name);
if (iter != map.end())
return iter->value;
- CSSPropertyID unresolved_property = ParseCSSPropertyID(name);
+ CSSPropertyID unresolved_property =
+ ParseCSSPropertyID(execution_context, name);
if (unresolved_property == CSSPropertyID::kVariable)
unresolved_property = CSSPropertyID::kInvalid;
map.insert(name, unresolved_property);
DCHECK(!isValidCSSPropertyID(unresolved_property) ||
CSSProperty::Get(resolveCSSPropertyID(unresolved_property))
- .IsWebExposed());
+ .IsWebExposed(execution_context));
return unresolved_property;
}
} // namespace
+void CSSStyleDeclaration::Trace(Visitor* visitor) {
+ ExecutionContextClient::Trace(visitor);
+ ScriptWrappable::Trace(visitor);
+}
+
String CSSStyleDeclaration::AnonymousNamedGetter(const AtomicString& name) {
// Search the style declaration.
- CSSPropertyID unresolved_property = CssPropertyInfo(name);
+ CSSPropertyID unresolved_property =
+ CssPropertyInfo(GetExecutionContext(), name);
// Do not handle non-property names.
if (!isValidCSSPropertyID(unresolved_property))
@@ -159,16 +168,17 @@ String CSSStyleDeclaration::AnonymousNamedGetter(const AtomicString& name) {
return GetPropertyValueInternal(resolveCSSPropertyID(unresolved_property));
}
-bool CSSStyleDeclaration::AnonymousNamedSetter(ScriptState* script_state,
- const AtomicString& name,
- const String& value) {
+NamedPropertySetterResult CSSStyleDeclaration::AnonymousNamedSetter(
+ ScriptState* script_state,
+ const AtomicString& name,
+ const String& value) {
const ExecutionContext* execution_context =
ExecutionContext::From(script_state);
if (!execution_context)
- return false;
- CSSPropertyID unresolved_property = CssPropertyInfo(name);
+ return NamedPropertySetterResult::kDidNotIntercept;
+ CSSPropertyID unresolved_property = CssPropertyInfo(execution_context, name);
if (!isValidCSSPropertyID(unresolved_property))
- return false;
+ return NamedPropertySetterResult::kDidNotIntercept;
// We create the ExceptionState manually due to performance issues: adding
// [RaisesException] to the IDL causes the bindings layer to expensively
// create a std::string to set the ExceptionState's |property_name| argument,
@@ -182,8 +192,8 @@ bool CSSStyleDeclaration::AnonymousNamedSetter(ScriptState* script_state,
execution_context->GetSecureContextMode(),
exception_state);
if (exception_state.HadException())
- return false;
- return true;
+ return NamedPropertySetterResult::kIntercepted;
+ return NamedPropertySetterResult::kIntercepted;
}
void CSSStyleDeclaration::NamedPropertyEnumerator(Vector<String>& names,
@@ -191,17 +201,19 @@ void CSSStyleDeclaration::NamedPropertyEnumerator(Vector<String>& names,
typedef Vector<String, numCSSProperties - 1> PreAllocatedPropertyVector;
DEFINE_STATIC_LOCAL(PreAllocatedPropertyVector, property_names, ());
+ const ExecutionContext* execution_context = GetExecutionContext();
+
if (property_names.IsEmpty()) {
for (CSSPropertyID property_id : CSSPropertyIDList()) {
const CSSProperty& property_class =
CSSProperty::Get(resolveCSSPropertyID(property_id));
- if (property_class.IsWebExposed())
+ if (property_class.IsWebExposed(execution_context))
property_names.push_back(property_class.GetJSPropertyName());
}
for (CSSPropertyID property_id : kCSSPropertyAliasList) {
const CSSUnresolvedProperty* property_class =
CSSUnresolvedProperty::GetAliasProperty(property_id);
- if (property_class->IsWebExposed())
+ if (property_class->IsWebExposed(execution_context))
property_names.push_back(property_class->GetJSPropertyName());
}
std::sort(property_names.begin(), property_names.end(),
@@ -212,7 +224,7 @@ void CSSStyleDeclaration::NamedPropertyEnumerator(Vector<String>& names,
bool CSSStyleDeclaration::NamedPropertyQuery(const AtomicString& name,
ExceptionState&) {
- return isValidCSSPropertyID(CssPropertyInfo(name));
+ return isValidCSSPropertyID(CssPropertyInfo(GetExecutionContext(), name));
}
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/css_style_declaration.h b/chromium/third_party/blink/renderer/core/css/css_style_declaration.h
index 8292a45eda3..ad53e5b954a 100644
--- a/chromium/third_party/blink/renderer/core/css/css_style_declaration.h
+++ b/chromium/third_party/blink/renderer/core/css/css_style_declaration.h
@@ -25,7 +25,9 @@
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
+#include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
+#include "third_party/blink/renderer/platform/bindings/v8_binding.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
@@ -37,12 +39,16 @@ class CSSValue;
class ExceptionState;
enum class SecureContextMode;
-class CORE_EXPORT CSSStyleDeclaration : public ScriptWrappable {
+class CORE_EXPORT CSSStyleDeclaration : public ScriptWrappable,
+ public ExecutionContextClient {
DEFINE_WRAPPERTYPEINFO();
+ USING_GARBAGE_COLLECTED_MIXIN(CSSStyleDeclaration);
public:
~CSSStyleDeclaration() override = default;
+ void Trace(Visitor* visitor) override;
+
virtual CSSRule* parentRule() const = 0;
String cssFloat() { return GetPropertyValueInternal(CSSPropertyID::kFloat); }
void setCSSFloat(const ExecutionContext* execution_context,
@@ -93,14 +99,15 @@ class CORE_EXPORT CSSStyleDeclaration : public ScriptWrappable {
// Note: AnonymousNamedSetter() can end up throwing an exception via
// SetPropertyInternal() even though it does not take an |ExceptionState| as
// an argument (see bug 829408).
- bool AnonymousNamedSetter(ScriptState*,
- const AtomicString& name,
- const String& value);
+ NamedPropertySetterResult AnonymousNamedSetter(ScriptState*,
+ const AtomicString& name,
+ const String& value);
void NamedPropertyEnumerator(Vector<String>& names, ExceptionState&);
bool NamedPropertyQuery(const AtomicString&, ExceptionState&);
protected:
- CSSStyleDeclaration() = default;
+ CSSStyleDeclaration(ExecutionContext* context)
+ : ExecutionContextClient(context) {}
private:
DISALLOW_COPY_AND_ASSIGN(CSSStyleDeclaration);
diff --git a/chromium/third_party/blink/renderer/core/css/css_style_rule.cc b/chromium/third_party/blink/renderer/core/css/css_style_rule.cc
index b612a98bd0e..0cfed7f3602 100644
--- a/chromium/third_party/blink/renderer/core/css/css_style_rule.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_style_rule.cc
@@ -110,7 +110,7 @@ void CSSStyleRule::Reattach(StyleRuleBase* rule) {
properties_cssom_wrapper_->Reattach(style_rule_->MutableProperties());
}
-void CSSStyleRule::Trace(blink::Visitor* visitor) {
+void CSSStyleRule::Trace(Visitor* visitor) {
visitor->Trace(style_rule_);
visitor->Trace(properties_cssom_wrapper_);
visitor->Trace(style_map_);
diff --git a/chromium/third_party/blink/renderer/core/css/css_style_rule.h b/chromium/third_party/blink/renderer/core/css/css_style_rule.h
index 1ede742db9d..a4e648bb88a 100644
--- a/chromium/third_party/blink/renderer/core/css/css_style_rule.h
+++ b/chromium/third_party/blink/renderer/core/css/css_style_rule.h
@@ -54,7 +54,7 @@ class CORE_EXPORT CSSStyleRule final : public CSSRule {
// FIXME: Not CSSOM. Remove.
StyleRule* GetStyleRule() const { return style_rule_.Get(); }
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
CSSRule::Type type() const override { return kStyleRule; }
diff --git a/chromium/third_party/blink/renderer/core/css/css_style_sheet.cc b/chromium/third_party/blink/renderer/core/css/css_style_sheet.cc
index 0a7e0f3a169..096dc2743b7 100644
--- a/chromium/third_party/blink/renderer/core/css/css_style_sheet.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_style_sheet.cc
@@ -24,9 +24,9 @@
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_css_style_sheet_init.h"
#include "third_party/blink/renderer/core/css/css_import_rule.h"
#include "third_party/blink/renderer/core/css/css_rule_list.h"
-#include "third_party/blink/renderer/core/css/css_style_sheet_init.h"
#include "third_party/blink/renderer/core/css/media_list.h"
#include "third_party/blink/renderer/core/css/parser/css_parser.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_context.h"
@@ -55,7 +55,7 @@ class StyleSheetCSSRuleList final : public CSSRuleList {
public:
StyleSheetCSSRuleList(CSSStyleSheet* sheet) : style_sheet_(sheet) {}
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(style_sheet_);
CSSRuleList::Trace(visitor);
}
@@ -106,10 +106,12 @@ CSSStyleSheet* CSSStyleSheet::Create(Document& document,
sheet->ClearOwnerRule();
contents->RegisterClient(sheet);
scoped_refptr<MediaQuerySet> media_query_set;
- if (options->media().IsString())
- media_query_set = MediaQuerySet::Create(options->media().GetAsString());
- else
+ if (options->media().IsString()) {
+ media_query_set = MediaQuerySet::Create(options->media().GetAsString(),
+ document.GetExecutionContext());
+ } else {
media_query_set = options->media().GetAsMediaList()->Queries()->Copy();
+ }
auto* media_list = MakeGarbageCollected<MediaList>(
media_query_set, const_cast<CSSStyleSheet*>(sheet));
sheet->SetMedia(media_list);
@@ -450,17 +452,21 @@ int CSSStyleSheet::addRule(const String& selector,
}
ScriptPromise CSSStyleSheet::replace(ScriptState* script_state,
- const String& text,
- ExceptionState& exception_state) {
+ const String& text) {
if (!is_constructed_) {
- exception_state.ThrowDOMException(
- DOMExceptionCode::kNotAllowedError,
- "Can't call replace on non-constructed CSSStyleSheets.");
+ return ScriptPromise::RejectWithDOMException(
+ script_state,
+ MakeGarbageCollected<DOMException>(
+ DOMExceptionCode::kNotAllowedError,
+ "Can't call replace on non-constructed CSSStyleSheets."));
}
// Parses the text synchronously, loads import rules asynchronously.
- SetText(text, true /* allow_import_rules */, exception_state);
+ SetText(text, true /* allow_import_rules */, nullptr);
if (!IsLoading())
return ScriptPromise::Cast(script_state, ToV8(this, script_state));
+ // We're loading a stylesheet that contains @import rules. This is deprecated.
+ Deprecation::CountDeprecation(OwnerDocument(),
+ WebFeature::kCssStyleSheetReplaceWithImport);
resolver_ = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
return resolver_->Promise();
}
@@ -468,11 +474,11 @@ ScriptPromise CSSStyleSheet::replace(ScriptState* script_state,
void CSSStyleSheet::replaceSync(const String& text,
ExceptionState& exception_state) {
if (!is_constructed_) {
- exception_state.ThrowDOMException(
+ return exception_state.ThrowDOMException(
DOMExceptionCode::kNotAllowedError,
"Can't call replaceSync on non-constructed CSSStyleSheets.");
}
- SetText(text, false /* allow_import_rules */, exception_state);
+ SetText(text, false /* allow_import_rules */, &exception_state);
}
void CSSStyleSheet::ResolveReplacePromiseIfNeeded(bool load_error_occured) {
@@ -565,16 +571,17 @@ void CSSStyleSheet::SetLoadCompleted(bool completed) {
void CSSStyleSheet::SetText(const String& text,
bool allow_import_rules,
- ExceptionState& exception_state) {
+ ExceptionState* exception_state) {
child_rule_cssom_wrappers_.clear();
CSSStyleSheet::RuleMutationScope mutation_scope(this);
contents_->ClearRules();
if (contents_->ParseString(text, allow_import_rules) ==
ParseSheetResult::kHasUnallowedImportRule) {
- exception_state.ThrowDOMException(DOMExceptionCode::kNotAllowedError,
- "@import rules are not allowed when "
- "creating stylesheet synchronously.");
+ DCHECK(exception_state);
+ exception_state->ThrowDOMException(DOMExceptionCode::kNotAllowedError,
+ "@import rules are not allowed when "
+ "creating stylesheet synchronously.");
}
}
@@ -621,7 +628,7 @@ bool CSSStyleSheet::CanBeActivated(
return true;
}
-void CSSStyleSheet::Trace(blink::Visitor* visitor) {
+void CSSStyleSheet::Trace(Visitor* visitor) {
visitor->Trace(contents_);
visitor->Trace(owner_node_);
visitor->Trace(owner_rule_);
diff --git a/chromium/third_party/blink/renderer/core/css/css_style_sheet.h b/chromium/third_party/blink/renderer/core/css/css_style_sheet.h
index e6dbe47fb96..84d53558a22 100644
--- a/chromium/third_party/blink/renderer/core/css/css_style_sheet.h
+++ b/chromium/third_party/blink/renderer/core/css/css_style_sheet.h
@@ -100,9 +100,7 @@ class CORE_EXPORT CSSStyleSheet final : public StyleSheet {
deleteRule(index, exception_state);
}
- ScriptPromise replace(ScriptState* script_state,
- const String& text,
- ExceptionState&);
+ ScriptPromise replace(ScriptState* script_state, const String& text);
void replaceSync(const String& text, ExceptionState&);
void ResolveReplacePromiseIfNeeded(bool load_error_occured);
@@ -160,7 +158,7 @@ class CORE_EXPORT CSSStyleSheet final : public StyleSheet {
~RuleMutationScope();
private:
- Member<CSSStyleSheet> style_sheet_;
+ CSSStyleSheet* style_sheet_;
DISALLOW_COPY_AND_ASSIGN(RuleMutationScope);
};
@@ -176,7 +174,7 @@ class CORE_EXPORT CSSStyleSheet final : public StyleSheet {
~InspectorMutationScope();
private:
- Member<CSSStyleSheet> style_sheet_;
+ CSSStyleSheet* style_sheet_;
DISALLOW_COPY_AND_ASSIGN(InspectorMutationScope);
};
@@ -191,7 +189,9 @@ class CORE_EXPORT CSSStyleSheet final : public StyleSheet {
bool SheetLoaded();
bool LoadCompleted() const { return load_completed_; }
void StartLoadingDynamicSheet();
- void SetText(const String&, bool allow_import_rules, ExceptionState&);
+ // If `allow_import_rules` is false, an ExceptionState pointer must be
+ // provided, otherwise it can be null.
+ void SetText(const String&, bool allow_import_rules, ExceptionState*);
void SetMedia(MediaList*);
void SetAlternateFromConstructor(bool);
bool CanBeActivated(const String& current_preferrable_name) const;
@@ -202,7 +202,7 @@ class CORE_EXPORT CSSStyleSheet final : public StyleSheet {
bool IsConstructed() { return is_constructed_; }
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
bool IsAlternate() const;
diff --git a/chromium/third_party/blink/renderer/core/css/css_style_sheet.idl b/chromium/third_party/blink/renderer/core/css/css_style_sheet.idl
index 94b6f421d26..7f075cfe7fb 100644
--- a/chromium/third_party/blink/renderer/core/css/css_style_sheet.idl
+++ b/chromium/third_party/blink/renderer/core/css/css_style_sheet.idl
@@ -21,21 +21,19 @@
// https://drafts.csswg.org/cssom/#the-cssstylesheet-interface
[
- ConstructorCallWith=Document,
- RaisesException=Constructor,
- Constructor(optional CSSStyleSheetInit options),
Exposed=Window
] interface CSSStyleSheet : StyleSheet {
+ [CallWith=Document, RaisesException] constructor(optional CSSStyleSheetInit options = {});
readonly attribute CSSRule? ownerRule;
[SameObject, RaisesException] readonly attribute CSSRuleList cssRules;
[RaisesException] unsigned long insertRule(DOMString rule, optional unsigned long index = 0);
[RaisesException] void deleteRule(unsigned long index);
- [MeasureAs=CSSStyleSheetReplace, CallWith=ScriptState, RaisesException] Promise<CSSStyleSheet> replace(DOMString text);
+ [MeasureAs=CSSStyleSheetReplace, CallWith=ScriptState] Promise<CSSStyleSheet> replace(DOMString text);
[MeasureAs=CSSStyleSheetReplaceSync, RaisesException] void replaceSync(DOMString text);
// Non-standard APIs
[MeasureAs=CSSStyleSheetRules, RaisesException] readonly attribute CSSRuleList rules;
- [MeasureAs=CSSStyleSheetAddRule, RaisesException] long addRule([DefaultValue=Undefined] optional DOMString selector, [DefaultValue=Undefined] optional DOMString style, optional unsigned long index);
- [MeasureAs=CSSStyleSheetRemoveRule, RaisesException] void removeRule([DefaultValue=Undefined] optional unsigned long index);
+ [MeasureAs=CSSStyleSheetAddRule, RaisesException] long addRule(optional DOMString selector = "undefined", optional DOMString style = "undefined", optional unsigned long index);
+ [MeasureAs=CSSStyleSheetRemoveRule, RaisesException] void removeRule(optional unsigned long index = 0);
};
diff --git a/chromium/third_party/blink/renderer/core/css/css_style_sheet_test.cc b/chromium/third_party/blink/renderer/core/css/css_style_sheet_test.cc
index d008ae92ffe..2ecb48e21a4 100644
--- a/chromium/third_party/blink/renderer/core/css/css_style_sheet_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_style_sheet_test.cc
@@ -11,10 +11,14 @@
#include "third_party/blink/renderer/bindings/core/v8/script_value.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_css_style_sheet.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_css_style_sheet_init.h"
+#include "third_party/blink/renderer/core/css/css_rule.h"
#include "third_party/blink/renderer/core/css/css_rule_list.h"
-#include "third_party/blink/renderer/core/css/css_style_sheet_init.h"
#include "third_party/blink/renderer/core/css/media_list.h"
+#include "third_party/blink/renderer/core/css/style_sheet_contents.h"
+#include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
+#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
namespace blink {
@@ -64,7 +68,7 @@ TEST_F(CSSStyleSheetTest,
EXPECT_EQ(sheet->ownerNode(), nullptr);
EXPECT_EQ(sheet->ownerRule(), nullptr);
EXPECT_EQ(sheet->media()->length(), 2U);
- EXPECT_EQ(sheet->media()->mediaText(), init->media().GetAsString());
+ EXPECT_EQ(sheet->media()->mediaText(nullptr), init->media().GetAsString());
EXPECT_EQ(sheet->title(), init->title());
EXPECT_TRUE(sheet->AlternateFromConstructor());
EXPECT_TRUE(sheet->disabled());
@@ -99,4 +103,74 @@ TEST_F(CSSStyleSheetTest,
EXPECT_EQ(shadow_b.AdoptedStyleSheets().size(), 1u);
}
+TEST_F(CSSStyleSheetTest, AdoptedStyleSheetMediaQueryEvalChange) {
+ SetBodyInnerHTML("<div id=green></div><div id=blue></div>");
+
+ Element* green = GetDocument().getElementById("green");
+ Element* blue = GetDocument().getElementById("blue");
+
+ CSSStyleSheetInit* init = CSSStyleSheetInit::Create();
+ CSSStyleSheet* sheet =
+ CSSStyleSheet::Create(GetDocument(), init, ASSERT_NO_EXCEPTION);
+ sheet->replaceSync(
+ "@media (max-width: 300px) {#green{color:green}} @media "
+ "(prefers-reduced-motion: reduce) {#blue{color:blue}}",
+ ASSERT_NO_EXCEPTION);
+
+ HeapVector<Member<CSSStyleSheet>> empty_adopted_sheets;
+ HeapVector<Member<CSSStyleSheet>> adopted_sheets;
+ adopted_sheets.push_back(sheet);
+
+ GetDocument().SetAdoptedStyleSheets(adopted_sheets);
+ UpdateAllLifecyclePhasesForTest();
+
+ ASSERT_TRUE(sheet->Contents());
+ ASSERT_TRUE(sheet->Contents()->HasRuleSet());
+ RuleSet* rule_set = &sheet->Contents()->GetRuleSet();
+
+ EXPECT_EQ(Color::kBlack, green->GetComputedStyle()->VisitedDependentColor(
+ GetCSSPropertyColor()));
+
+ GetDocument().SetAdoptedStyleSheets(empty_adopted_sheets);
+ UpdateAllLifecyclePhasesForTest();
+
+ ASSERT_TRUE(sheet->Contents()->HasRuleSet());
+ EXPECT_EQ(rule_set, &sheet->Contents()->GetRuleSet());
+ EXPECT_EQ(Color::kBlack, green->GetComputedStyle()->VisitedDependentColor(
+ GetCSSPropertyColor()));
+
+ GetDocument().View()->SetLayoutSizeFixedToFrameSize(false);
+ GetDocument().View()->SetLayoutSize(IntSize(200, 500));
+ UpdateAllLifecyclePhasesForTest();
+
+ GetDocument().SetAdoptedStyleSheets(adopted_sheets);
+ UpdateAllLifecyclePhasesForTest();
+
+ ASSERT_TRUE(sheet->Contents()->HasRuleSet());
+ EXPECT_NE(rule_set, &sheet->Contents()->GetRuleSet());
+ EXPECT_EQ(
+ MakeRGB(0, 128, 0),
+ green->GetComputedStyle()->VisitedDependentColor(GetCSSPropertyColor()));
+ EXPECT_EQ(Color::kBlack, blue->GetComputedStyle()->VisitedDependentColor(
+ GetCSSPropertyColor()));
+
+ GetDocument().SetAdoptedStyleSheets(empty_adopted_sheets);
+ GetDocument().GetSettings()->SetPrefersReducedMotion(true);
+ UpdateAllLifecyclePhasesForTest();
+
+ EXPECT_EQ(Color::kBlack, green->GetComputedStyle()->VisitedDependentColor(
+ GetCSSPropertyColor()));
+ EXPECT_EQ(Color::kBlack, blue->GetComputedStyle()->VisitedDependentColor(
+ GetCSSPropertyColor()));
+
+ GetDocument().SetAdoptedStyleSheets(adopted_sheets);
+ UpdateAllLifecyclePhasesForTest();
+
+ EXPECT_EQ(
+ MakeRGB(0, 128, 0),
+ green->GetComputedStyle()->VisitedDependentColor(GetCSSPropertyColor()));
+ EXPECT_EQ(MakeRGB(0, 0, 255), blue->GetComputedStyle()->VisitedDependentColor(
+ GetCSSPropertyColor()));
+}
+
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/css_syntax_definition.cc b/chromium/third_party/blink/renderer/core/css/css_syntax_definition.cc
index 70fd25fc121..1a3977717f2 100644
--- a/chromium/third_party/blink/renderer/core/css/css_syntax_definition.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_syntax_definition.cc
@@ -42,7 +42,7 @@ bool CouldConsumeReservedKeyword(CSSParserTokenRange range) {
const CSSValue* ConsumeSingleType(const CSSSyntaxComponent& syntax,
CSSParserTokenRange& range,
- const CSSParserContext* context) {
+ const CSSParserContext& context) {
switch (syntax.GetType()) {
case CSSSyntaxType::kIdent:
if (range.Peek().GetType() == kIdentToken &&
@@ -52,46 +52,54 @@ const CSSValue* ConsumeSingleType(const CSSSyntaxComponent& syntax,
AtomicString(syntax.GetString()));
}
return nullptr;
- case CSSSyntaxType::kLength:
+ case CSSSyntaxType::kLength: {
+ CSSParserContext::ParserModeOverridingScope scope(context,
+ kHTMLStandardMode);
return css_property_parser_helpers::ConsumeLength(
- range, kHTMLStandardMode, ValueRange::kValueRangeAll);
+ range, context, ValueRange::kValueRangeAll);
+ }
case CSSSyntaxType::kNumber:
return css_property_parser_helpers::ConsumeNumber(
- range, ValueRange::kValueRangeAll);
+ range, context, ValueRange::kValueRangeAll);
case CSSSyntaxType::kPercentage:
return css_property_parser_helpers::ConsumePercent(
- range, ValueRange::kValueRangeAll);
- case CSSSyntaxType::kLengthPercentage:
+ range, context, ValueRange::kValueRangeAll);
+ case CSSSyntaxType::kLengthPercentage: {
+ CSSParserContext::ParserModeOverridingScope scope(context,
+ kHTMLStandardMode);
return css_property_parser_helpers::ConsumeLengthOrPercent(
- range, kHTMLStandardMode, ValueRange::kValueRangeAll);
- case CSSSyntaxType::kColor:
- return css_property_parser_helpers::ConsumeColor(range,
- kHTMLStandardMode);
+ range, context, ValueRange::kValueRangeAll);
+ }
+ case CSSSyntaxType::kColor: {
+ CSSParserContext::ParserModeOverridingScope scope(context,
+ kHTMLStandardMode);
+ return css_property_parser_helpers::ConsumeColor(range, context);
+ }
case CSSSyntaxType::kImage:
return css_property_parser_helpers::ConsumeImage(range, context);
case CSSSyntaxType::kUrl:
return css_property_parser_helpers::ConsumeUrl(range, context);
case CSSSyntaxType::kInteger:
- return css_property_parser_helpers::ConsumeIntegerOrNumberCalc(range);
+ return css_property_parser_helpers::ConsumeIntegerOrNumberCalc(range,
+ context);
case CSSSyntaxType::kAngle:
return css_property_parser_helpers::ConsumeAngle(
range, context, base::Optional<WebFeature>());
case CSSSyntaxType::kTime:
return css_property_parser_helpers::ConsumeTime(
- range, ValueRange::kValueRangeAll);
+ range, context, ValueRange::kValueRangeAll);
case CSSSyntaxType::kResolution:
return css_property_parser_helpers::ConsumeResolution(range);
case CSSSyntaxType::kTransformFunction:
- return css_property_parser_helpers::ConsumeTransformValue(range,
- *context);
+ return css_property_parser_helpers::ConsumeTransformValue(range, context);
case CSSSyntaxType::kTransformList:
- return css_property_parser_helpers::ConsumeTransformList(range, *context);
+ return css_property_parser_helpers::ConsumeTransformList(range, context);
case CSSSyntaxType::kCustomIdent:
// TODO(crbug.com/579788): Implement 'revert'.
// TODO(crbug.com/882285): Make 'default' invalid as <custom-ident>.
if (IsReservedIdentToken(range.Peek()))
return nullptr;
- return css_property_parser_helpers::ConsumeCustomIdent(range, *context);
+ return css_property_parser_helpers::ConsumeCustomIdent(range, context);
default:
NOTREACHED();
return nullptr;
@@ -100,7 +108,7 @@ const CSSValue* ConsumeSingleType(const CSSSyntaxComponent& syntax,
const CSSValue* ConsumeSyntaxComponent(const CSSSyntaxComponent& syntax,
CSSParserTokenRange range,
- const CSSParserContext* context) {
+ const CSSParserContext& context) {
// CSS-wide keywords are already handled by the CSSPropertyParser
if (syntax.GetRepeat() == CSSSyntaxRepeat::kSpaceSeparated) {
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
@@ -132,7 +140,7 @@ const CSSValue* ConsumeSyntaxComponent(const CSSSyntaxComponent& syntax,
} // namespace
const CSSValue* CSSSyntaxDefinition::Parse(CSSParserTokenRange range,
- const CSSParserContext* context,
+ const CSSParserContext& context,
bool is_animation_tainted) const {
if (IsTokenStream()) {
// TODO(crbug.com/579788): Implement 'revert'.
@@ -140,7 +148,7 @@ const CSSValue* CSSSyntaxDefinition::Parse(CSSParserTokenRange range,
if (CouldConsumeReservedKeyword(range))
return nullptr;
return CSSVariableParser::ParseRegisteredPropertyValue(
- range, *context, false, is_animation_tainted);
+ range, context, false, is_animation_tainted);
}
range.ConsumeWhitespace();
for (const CSSSyntaxComponent& component : syntax_components_) {
@@ -148,7 +156,7 @@ const CSSValue* CSSSyntaxDefinition::Parse(CSSParserTokenRange range,
ConsumeSyntaxComponent(component, range, context))
return result;
}
- return CSSVariableParser::ParseRegisteredPropertyValue(range, *context, true,
+ return CSSVariableParser::ParseRegisteredPropertyValue(range, context, true,
is_animation_tainted);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_syntax_definition.h b/chromium/third_party/blink/renderer/core/css/css_syntax_definition.h
index 98f778510b1..60a2308039d 100644
--- a/chromium/third_party/blink/renderer/core/css/css_syntax_definition.h
+++ b/chromium/third_party/blink/renderer/core/css/css_syntax_definition.h
@@ -17,7 +17,7 @@ class CSSValue;
class CORE_EXPORT CSSSyntaxDefinition {
public:
const CSSValue* Parse(CSSParserTokenRange,
- const CSSParserContext*,
+ const CSSParserContext&,
bool is_animation_tainted) const;
bool IsTokenStream() const {
return syntax_components_.size() == 1 &&
diff --git a/chromium/third_party/blink/renderer/core/css/css_test_helpers.cc b/chromium/third_party/blink/renderer/core/css/css_test_helpers.cc
index fabc8ce438b..874c1d50e6d 100644
--- a/chromium/third_party/blink/renderer/core/css/css_test_helpers.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_test_helpers.cc
@@ -5,6 +5,7 @@
#include "third_party/blink/renderer/core/css/css_test_helpers.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_property_definition.h"
#include "third_party/blink/renderer/core/css/css_custom_ident_value.h"
#include "third_party/blink/renderer/core/css/css_rule_list.h"
#include "third_party/blink/renderer/core/css/css_style_sheet.h"
@@ -15,7 +16,6 @@
#include "third_party/blink/renderer/core/css/parser/css_tokenizer.h"
#include "third_party/blink/renderer/core/css/properties/css_property_ref.h"
#include "third_party/blink/renderer/core/css/properties/longhand.h"
-#include "third_party/blink/renderer/core/css/property_definition.h"
#include "third_party/blink/renderer/core/css/property_registration.h"
#include "third_party/blink/renderer/core/css/property_registry.h"
#include "third_party/blink/renderer/core/css/rule_set.h"
@@ -73,8 +73,8 @@ void RegisterProperty(Document& document,
property_definition->setSyntax(syntax);
property_definition->setInitialValue(initial_value);
property_definition->setInherits(is_inherited);
- PropertyRegistration::registerProperty(&document, property_definition,
- exception_state);
+ PropertyRegistration::registerProperty(document.GetExecutionContext(),
+ property_definition, exception_state);
ASSERT_FALSE(exception_state.HadException());
}
@@ -107,5 +107,13 @@ const CSSValue* ParseLonghand(Document& document,
return longhand->ParseSingleValue(range, *context, local_context);
}
+const CSSPropertyValueSet* ParseDeclarationBlock(const String& block_text,
+ CSSParserMode mode) {
+ auto* set = MakeGarbageCollected<MutableCSSPropertyValueSet>(mode);
+ set->ParseDeclarationList(block_text, SecureContextMode::kSecureContext,
+ nullptr);
+ return set;
+}
+
} // namespace css_test_helpers
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/css_test_helpers.h b/chromium/third_party/blink/renderer/core/css/css_test_helpers.h
index 3a9c1efc4dd..9b220f7659c 100644
--- a/chromium/third_party/blink/renderer/core/css/css_test_helpers.h
+++ b/chromium/third_party/blink/renderer/core/css/css_test_helpers.h
@@ -54,6 +54,9 @@ const CSSValue* CreateCustomIdent(AtomicString);
const CSSValue* ParseLonghand(Document& document,
const CSSProperty&,
const String& value);
+const CSSPropertyValueSet* ParseDeclarationBlock(
+ const String& block_text,
+ CSSParserMode mode = kHTMLStandardMode);
} // namespace css_test_helpers
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/css_timing_function_value.h b/chromium/third_party/blink/renderer/core/css/css_timing_function_value.h
index 5cab5ad10fe..26e09608ef6 100644
--- a/chromium/third_party/blink/renderer/core/css/css_timing_function_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_timing_function_value.h
@@ -53,7 +53,7 @@ class CSSCubicBezierTimingFunctionValue : public CSSValue {
bool Equals(const CSSCubicBezierTimingFunctionValue&) const;
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
@@ -66,13 +66,6 @@ class CSSCubicBezierTimingFunctionValue : public CSSValue {
class CSSStepsTimingFunctionValue : public CSSValue {
public:
- static CSSStepsTimingFunctionValue* Create(
- int steps,
- StepsTimingFunction::StepPosition step_position) {
- return MakeGarbageCollected<CSSStepsTimingFunctionValue>(steps,
- step_position);
- }
-
CSSStepsTimingFunctionValue(int steps,
StepsTimingFunction::StepPosition step_position)
: CSSValue(kStepsTimingFunctionClass),
@@ -88,7 +81,7 @@ class CSSStepsTimingFunctionValue : public CSSValue {
bool Equals(const CSSStepsTimingFunctionValue&) const;
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_to_length_conversion_data.cc b/chromium/third_party/blink/renderer/core/css/css_to_length_conversion_data.cc
index 13008d87853..f7c4f68e909 100644
--- a/chromium/third_party/blink/renderer/core/css/css_to_length_conversion_data.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_to_length_conversion_data.cc
@@ -121,6 +121,12 @@ double CSSToLengthConversionData::ViewportMaxPercent() const {
return std::max(viewport_size_.Width(), viewport_size_.Height()) / 100;
}
+float CSSToLengthConversionData::EmFontSize() const {
+ if (style_)
+ const_cast<ComputedStyle*>(style_)->SetHasEmUnits();
+ return font_sizes_.Em();
+}
+
float CSSToLengthConversionData::RemFontSize() const {
if (style_)
const_cast<ComputedStyle*>(style_)->SetHasRemUnits();
diff --git a/chromium/third_party/blink/renderer/core/css/css_to_length_conversion_data.h b/chromium/third_party/blink/renderer/core/css/css_to_length_conversion_data.h
index 9af029c517e..cad9d5eaad8 100644
--- a/chromium/third_party/blink/renderer/core/css/css_to_length_conversion_data.h
+++ b/chromium/third_party/blink/renderer/core/css/css_to_length_conversion_data.h
@@ -46,7 +46,7 @@ class LayoutView;
class Font;
class CORE_EXPORT CSSToLengthConversionData {
- DISALLOW_NEW();
+ STACK_ALLOCATED();
public:
class CORE_EXPORT FontSizes {
@@ -97,7 +97,7 @@ class CORE_EXPORT CSSToLengthConversionData {
float Zoom() const { return zoom_; }
- float EmFontSize() const { return font_sizes_.Em(); }
+ float EmFontSize() const;
float RemFontSize() const;
float ExFontSize() const;
float ChFontSize() const;
diff --git a/chromium/third_party/blink/renderer/core/css/css_unicode_range_value.h b/chromium/third_party/blink/renderer/core/css/css_unicode_range_value.h
index 506c0806947..4db1508cd36 100644
--- a/chromium/third_party/blink/renderer/core/css/css_unicode_range_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_unicode_range_value.h
@@ -45,7 +45,7 @@ class CSSUnicodeRangeValue : public CSSValue {
bool Equals(const CSSUnicodeRangeValue&) const;
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_unset_value.h b/chromium/third_party/blink/renderer/core/css/css_unset_value.h
index 91f23e06e35..dfbf7a8fd84 100644
--- a/chromium/third_party/blink/renderer/core/css/css_unset_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_unset_value.h
@@ -26,7 +26,7 @@ class CORE_EXPORT CSSUnsetValue : public CSSValue {
bool Equals(const CSSUnsetValue&) const { return true; }
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
}
};
diff --git a/chromium/third_party/blink/renderer/core/css/css_uri_value.cc b/chromium/third_party/blink/renderer/core/css/css_uri_value.cc
index b1078fefcde..18e3b74e0f2 100644
--- a/chromium/third_party/blink/renderer/core/css/css_uri_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_uri_value.cc
@@ -19,6 +19,9 @@ CSSURIValue::CSSURIValue(const AtomicString& relative_url,
is_local_(relative_url.StartsWith('#')),
absolute_url_(absolute_url) {}
+CSSURIValue::CSSURIValue(const AtomicString& absolute_url)
+ : CSSURIValue(absolute_url, absolute_url) {}
+
CSSURIValue::CSSURIValue(const AtomicString& relative_url, const KURL& url)
: CSSURIValue(relative_url, AtomicString(url.GetString())) {}
@@ -31,8 +34,6 @@ SVGResource* CSSURIValue::EnsureResourceReference() const {
}
void CSSURIValue::ReResolveUrl(const Document& document) const {
- if (is_local_)
- return;
KURL url = document.CompleteURL(relative_url_);
AtomicString url_string(url.GetString());
if (url_string == absolute_url_)
@@ -46,8 +47,8 @@ String CSSURIValue::CustomCSSText() const {
}
AtomicString CSSURIValue::FragmentIdentifier() const {
- if (is_local_)
- return AtomicString(relative_url_.GetString().Substring(1));
+ // Always use KURL's FragmentIdentifier to ensure that we're handling the
+ // fragment in a consistent manner.
return AtomicString(AbsoluteUrl().FragmentIdentifier());
}
@@ -72,13 +73,15 @@ bool CSSURIValue::Equals(const CSSURIValue& other) const {
CSSURIValue* CSSURIValue::ValueWithURLMadeAbsolute(
const KURL& base_url,
const WTF::TextEncoding& charset) const {
- if (!charset.IsValid())
- return Create(AtomicString(KURL(base_url, relative_url_).GetString()));
- return Create(
+ if (!charset.IsValid()) {
+ return MakeGarbageCollected<CSSURIValue>(
+ AtomicString(KURL(base_url, relative_url_).GetString()));
+ }
+ return MakeGarbageCollected<CSSURIValue>(
AtomicString(KURL(base_url, relative_url_, charset).GetString()));
}
-void CSSURIValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSURIValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(resource_);
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_uri_value.h b/chromium/third_party/blink/renderer/core/css/css_uri_value.h
index e49901fdbe9..909779e4796 100644
--- a/chromium/third_party/blink/renderer/core/css/css_uri_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_uri_value.h
@@ -20,16 +20,10 @@ namespace cssvalue {
class CORE_EXPORT CSSURIValue : public CSSValue {
public:
- static CSSURIValue* Create(const String& relative_url, const KURL& url) {
- return MakeGarbageCollected<CSSURIValue>(AtomicString(relative_url), url);
- }
- static CSSURIValue* Create(const AtomicString& absolute_url) {
- return MakeGarbageCollected<CSSURIValue>(absolute_url, absolute_url);
- }
-
CSSURIValue(const AtomicString&, const KURL&);
CSSURIValue(const AtomicString& relative_url,
const AtomicString& absolute_url);
+ CSSURIValue(const AtomicString& absolute_url);
~CSSURIValue();
SVGResource* EnsureResourceReference() const;
@@ -49,7 +43,7 @@ class CORE_EXPORT CSSURIValue : public CSSValue {
CSSURIValue* ValueWithURLMadeAbsolute(const KURL& base_url,
const WTF::TextEncoding&) const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
KURL AbsoluteUrl() const;
diff --git a/chromium/third_party/blink/renderer/core/css/css_uri_value_test.cc b/chromium/third_party/blink/renderer/core/css/css_uri_value_test.cc
index 3b04a119ff7..05d7251525e 100644
--- a/chromium/third_party/blink/renderer/core/css/css_uri_value_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_uri_value_test.cc
@@ -12,15 +12,15 @@ namespace blink {
namespace {
TEST(CSSURIValueTest, ValueWithURLMadeAbsolute) {
- cssvalue::CSSURIValue* rel =
- cssvalue::CSSURIValue::Create("a", KURL("http://foo.com/a"));
+ cssvalue::CSSURIValue* rel = MakeGarbageCollected<cssvalue::CSSURIValue>(
+ "a", KURL("http://foo.com/a"));
cssvalue::CSSURIValue* abs = rel->ValueWithURLMadeAbsolute(
KURL("http://bar.com"), WTF::TextEncoding());
EXPECT_EQ("url(\"http://bar.com/a\")", abs->CssText());
}
TEST(CSSURIValueTest, AlreadyAbsoluteURLMadeAbsolute) {
- cssvalue::CSSURIValue* rel = cssvalue::CSSURIValue::Create(
+ cssvalue::CSSURIValue* rel = MakeGarbageCollected<cssvalue::CSSURIValue>(
"http://baz.com/a", KURL("http://baz.com/a"));
cssvalue::CSSURIValue* abs = rel->ValueWithURLMadeAbsolute(
KURL("http://bar.com"), WTF::TextEncoding());
diff --git a/chromium/third_party/blink/renderer/core/css/css_value.cc b/chromium/third_party/blink/renderer/core/css/css_value.cc
index 17c495769db..d849ce2795d 100644
--- a/chromium/third_party/blink/renderer/core/css/css_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_value.cc
@@ -60,7 +60,6 @@
#include "third_party/blink/renderer/core/css/css_numeric_literal_value.h"
#include "third_party/blink/renderer/core/css/css_paint_value.h"
#include "third_party/blink/renderer/core/css/css_path_value.h"
-#include "third_party/blink/renderer/core/css/css_pending_interpolation_value.h"
#include "third_party/blink/renderer/core/css/css_pending_substitution_value.h"
#include "third_party/blink/renderer/core/css/css_primitive_value.h"
#include "third_party/blink/renderer/core/css/css_quad_value.h"
@@ -81,7 +80,7 @@
namespace blink {
struct SameSizeAsCSSValue final : public GarbageCollected<SameSizeAsCSSValue> {
- uint32_t bitfields;
+ char bitfields[sizeof(uint16_t) + sizeof(uint8_t)];
};
ASSERT_SIZE(CSSValue, SameSizeAsCSSValue);
@@ -100,7 +99,7 @@ CSSValue* CSSValue::Create(const Length& value, float zoom) {
return CSSPrimitiveValue::CreateFromLength(value, zoom);
case Length::kDeviceWidth:
case Length::kDeviceHeight:
- case Length::kMaxSizeNone:
+ case Length::kNone:
NOTREACHED();
break;
}
@@ -262,9 +261,6 @@ bool CSSValue::operator==(const CSSValue& other) const {
case kCSSContentDistributionClass:
return CompareCSSValues<cssvalue::CSSContentDistributionValue>(*this,
other);
- case kPendingInterpolationClass:
- return CompareCSSValues<cssvalue::CSSPendingInterpolationValue>(*this,
- other);
case kCustomPropertyDeclarationClass:
return CompareCSSValues<CSSCustomPropertyDeclaration>(*this, other);
case kVariableReferenceClass:
@@ -382,8 +378,6 @@ String CSSValue::CssText() const {
return To<CSSImageSetValue>(this)->CustomCSSText();
case kCSSContentDistributionClass:
return To<cssvalue::CSSContentDistributionValue>(this)->CustomCSSText();
- case kPendingInterpolationClass:
- return To<cssvalue::CSSPendingInterpolationValue>(this)->CustomCSSText();
case kVariableReferenceClass:
return To<CSSVariableReferenceValue>(this)->CustomCSSText();
case kCustomPropertyDeclarationClass:
@@ -552,10 +546,6 @@ void CSSValue::FinalizeGarbageCollectedObject() {
To<cssvalue::CSSContentDistributionValue>(this)
->~CSSContentDistributionValue();
return;
- case kPendingInterpolationClass:
- To<cssvalue::CSSPendingInterpolationValue>(this)
- ->~CSSPendingInterpolationValue();
- return;
case kVariableReferenceClass:
To<CSSVariableReferenceValue>(this)->~CSSVariableReferenceValue();
return;
@@ -576,7 +566,7 @@ void CSSValue::FinalizeGarbageCollectedObject() {
NOTREACHED();
}
-void CSSValue::Trace(blink::Visitor* visitor) {
+void CSSValue::Trace(Visitor* visitor) {
switch (GetClassType()) {
case kAxisClass:
To<cssvalue::CSSAxisValue>(this)->TraceAfterDispatch(visitor);
@@ -729,10 +719,6 @@ void CSSValue::Trace(blink::Visitor* visitor) {
To<cssvalue::CSSContentDistributionValue>(this)->TraceAfterDispatch(
visitor);
return;
- case kPendingInterpolationClass:
- To<cssvalue::CSSPendingInterpolationValue>(this)->TraceAfterDispatch(
- visitor);
- return;
case kVariableReferenceClass:
To<CSSVariableReferenceValue>(this)->TraceAfterDispatch(visitor);
return;
diff --git a/chromium/third_party/blink/renderer/core/css/css_value.h b/chromium/third_party/blink/renderer/core/css/css_value.h
index 94a011c3dbc..db205280304 100644
--- a/chromium/third_party/blink/renderer/core/css/css_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_value.h
@@ -143,9 +143,6 @@ class CORE_EXPORT CSSValue : public GarbageCollected<CSSValue> {
bool IsContentDistributionValue() const {
return class_type_ == kCSSContentDistributionClass;
}
- bool IsPendingInterpolationValue() const {
- return class_type_ == kPendingInterpolationClass;
- }
bool IsUnicodeRangeValue() const { return class_type_ == kUnicodeRangeClass; }
bool IsGridLineNamesValue() const {
return class_type_ == kGridLineNamesClass;
@@ -183,8 +180,8 @@ class CORE_EXPORT CSSValue : public GarbageCollected<CSSValue> {
bool operator==(const CSSValue&) const;
void FinalizeGarbageCollectedObject();
- void TraceAfterDispatch(blink::Visitor* visitor) {}
- void Trace(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor* visitor) const {}
+ void Trace(Visitor*);
// ~CSSValue should be public, because non-public ~CSSValue causes C2248
// error: 'blink::CSSValue::~CSSValue' : cannot access protected member
@@ -193,7 +190,6 @@ class CORE_EXPORT CSSValue : public GarbageCollected<CSSValue> {
~CSSValue() = default;
protected:
- static const size_t kClassTypeBits = 6;
enum ClassType {
kNumericLiteralClass,
kMathFunctionClass,
@@ -255,7 +251,6 @@ class CORE_EXPORT CSSValue : public GarbageCollected<CSSValue> {
kCSSContentDistributionClass,
- kPendingInterpolationClass,
kKeyframeShorthandClass,
// List class types must appear after ValueListClass.
@@ -276,8 +271,8 @@ class CORE_EXPORT CSSValue : public GarbageCollected<CSSValue> {
explicit CSSValue(ClassType class_type)
: numeric_literal_unit_type_(0),
- value_list_separator_(kSpaceSeparator),
is_non_negative_math_function_(false),
+ value_list_separator_(kSpaceSeparator),
allows_negative_percentage_reference_(false),
class_type_(class_type) {}
@@ -287,18 +282,30 @@ class CORE_EXPORT CSSValue : public GarbageCollected<CSSValue> {
protected:
// The bits in this section are only used by specific subclasses but kept here
// to maximize struct packing.
+ // The bits are ordered and split into groups to such that from the
+ // perspective of each subclass, each field is a separate memory location.
+ // Using NOLINT here allows to use uint8_t as bitfield type which reduces
+ // size of CSSValue from 4 bytes to 3 bytes.
// CSSNumericLiteralValue bits:
- unsigned numeric_literal_unit_type_ : 7; // CSSPrimitiveValue::UnitType
+ // This field hold CSSPrimitiveValue::UnitType.
+ uint8_t numeric_literal_unit_type_ : 7; // NOLINT
- unsigned value_list_separator_ : kValueListSeparatorBits;
+ // CSSMathFunctionValue:
+ uint8_t is_non_negative_math_function_ : 1; // NOLINT
+
+ // Force a new memory location. This will make TSAN treat the 2 fields above
+ // this line as a separate memory location than the 2 fields below it.
+ char : 0;
+
+ // CSSNumericLiteralValue bits:
+ uint8_t value_list_separator_ : kValueListSeparatorBits; // NOLINT
- // CSSMathFunctionValue
- unsigned is_non_negative_math_function_ : 1;
- unsigned allows_negative_percentage_reference_ : 1;
+ // CSSMathFunctionValue:
+ uint8_t allows_negative_percentage_reference_ : 1; // NOLINT
private:
- unsigned class_type_ : kClassTypeBits; // ClassType
+ const uint8_t class_type_; // ClassType
};
template <typename CSSValueType, wtf_size_t inlineCapacity>
diff --git a/chromium/third_party/blink/renderer/core/css/css_value_keywords.json5 b/chromium/third_party/blink/renderer/core/css/css_value_keywords.json5
index eefc9a0ace0..3b7a8b92b34 100644
--- a/chromium/third_party/blink/renderer/core/css/css_value_keywords.json5
+++ b/chromium/third_party/blink/renderer/core/css/css_value_keywords.json5
@@ -145,7 +145,6 @@
"fantasy",
"monospace",
"-webkit-body",
- "-webkit-pictograph",
//
// font-display
@@ -228,9 +227,6 @@
// Value used to implement the behavior in:
// https://quirks.spec.whatwg.org/#the-tables-inherit-color-from-body-quirk
"-internal-quirk-inherit",
- // The default color value for the root element. Using a keyword to account
- // for different values for different color schemes like dark mode.
- "-internal-root-color",
//
// background-repeat
//
@@ -480,6 +476,8 @@
"-webkit-isolate",
"-webkit-isolate-override",
"-webkit-plaintext",
+ "jis-b5",
+ "jis-b4",
"landscape",
"ledger",
"legal",
@@ -507,6 +505,12 @@
"wavy",
"-webkit-nowrap",
+ //
+ // math-style
+ //
+ // inline
+ "display",
+
// CSS3 Values
// box-align
"stretch",
@@ -619,12 +623,12 @@
// auto
// none
- //
- // -webkit-margin-collapse
- //
- // collapse
- // separate
- "discard",
+ // text-underline-position
+ // auto
+ "from-font",
+ // under
+ // left
+ // right
//
// word-break
@@ -1217,9 +1221,15 @@
// none
"back-button",
- // render-subtree
- "invisible",
- "skip-activation",
- "skip-viewport-activation",
+ // subtree-visibility
+ "hidden-matchable",
+
+ // -internal-empty-line-height
+ // none
+ "fabricated",
+
+ // @supports selector(...)
+ // https://drafts.csswg.org/css-conditional-4/#typedef-supports-selector-fn
+ "selector",
],
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_value_list.cc b/chromium/third_party/blink/renderer/core/css/css_value_list.cc
index 1e02ae2d2bc..fb8bf14737f 100644
--- a/chromium/third_party/blink/renderer/core/css/css_value_list.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_value_list.cc
@@ -138,7 +138,7 @@ void CSSValueList::ReResolveUrl(const Document& document) const {
value->ReResolveUrl(document);
}
-void CSSValueList::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSValueList::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(values_);
CSSValue::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_value_list.h b/chromium/third_party/blink/renderer/core/css/css_value_list.h
index 6883efc8223..eb63aff480e 100644
--- a/chromium/third_party/blink/renderer/core/css/css_value_list.h
+++ b/chromium/third_party/blink/renderer/core/css/css_value_list.h
@@ -75,7 +75,7 @@ class CORE_EXPORT CSSValueList : public CSSValue {
bool MayContainUrl() const;
void ReResolveUrl(const Document&) const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
HeapVector<Member<const CSSValue>, 4> values_;
diff --git a/chromium/third_party/blink/renderer/core/css/css_value_pair.cc b/chromium/third_party/blink/renderer/core/css/css_value_pair.cc
index 3ca5de6b848..820b646b483 100644
--- a/chromium/third_party/blink/renderer/core/css/css_value_pair.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_value_pair.cc
@@ -6,7 +6,7 @@
namespace blink {
-void CSSValuePair::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSValuePair::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(first_);
visitor->Trace(second_);
CSSValue::TraceAfterDispatch(visitor);
diff --git a/chromium/third_party/blink/renderer/core/css/css_value_pair.h b/chromium/third_party/blink/renderer/core/css/css_value_pair.h
index 2cd6b476e46..db0081bff0e 100644
--- a/chromium/third_party/blink/renderer/core/css/css_value_pair.h
+++ b/chromium/third_party/blink/renderer/core/css/css_value_pair.h
@@ -64,7 +64,7 @@ class CORE_EXPORT CSSValuePair : public CSSValue {
DataEquivalent(second_, other.second_);
}
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
protected:
CSSValuePair(ClassType class_type,
diff --git a/chromium/third_party/blink/renderer/core/css/css_value_pool.cc b/chromium/third_party/blink/renderer/core/css/css_value_pool.cc
index 16c7f3e6303..1d62b641b68 100644
--- a/chromium/third_party/blink/renderer/core/css/css_value_pool.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_value_pool.cc
@@ -52,32 +52,17 @@ CSSValuePool::CSSValuePool()
MakeGarbageCollected<cssvalue::CSSColorValue>(Color::kWhite)),
color_black_(
MakeGarbageCollected<cssvalue::CSSColorValue>(Color::kBlack)) {
- {
- using Value = cssvalue::CSSPendingInterpolationValue;
- using Type = cssvalue::CSSPendingInterpolationValue::Type;
- pending_interpolation_values_[0] =
- MakeGarbageCollected<Value>(Type::kCSSProperty);
- pending_interpolation_values_[1] =
- MakeGarbageCollected<Value>(Type::kPresentationAttribute);
- static_assert(static_cast<size_t>(Type::kCSSProperty) == 0u,
- "kCSSProperty must be 0");
- static_assert(static_cast<size_t>(Type::kPresentationAttribute) == 1u,
- "kPresentationAttribute must be 1");
- }
-
identifier_value_cache_.resize(numCSSValueKeywords);
pixel_value_cache_.resize(kMaximumCacheableIntegerValue + 1);
percent_value_cache_.resize(kMaximumCacheableIntegerValue + 1);
number_value_cache_.resize(kMaximumCacheableIntegerValue + 1);
}
-void CSSValuePool::Trace(blink::Visitor* visitor) {
+void CSSValuePool::Trace(Visitor* visitor) {
visitor->Trace(inherited_value_);
visitor->Trace(initial_value_);
visitor->Trace(unset_value_);
visitor->Trace(invalid_variable_value_);
- visitor->Trace(pending_interpolation_values_[0]);
- visitor->Trace(pending_interpolation_values_[1]);
visitor->Trace(color_transparent_);
visitor->Trace(color_white_);
visitor->Trace(color_black_);
diff --git a/chromium/third_party/blink/renderer/core/css/css_value_pool.h b/chromium/third_party/blink/renderer/core/css/css_value_pool.h
index 10d55b77ac1..c2fb257666c 100644
--- a/chromium/third_party/blink/renderer/core/css/css_value_pool.h
+++ b/chromium/third_party/blink/renderer/core/css/css_value_pool.h
@@ -38,7 +38,6 @@
#include "third_party/blink/renderer/core/css/css_initial_value.h"
#include "third_party/blink/renderer/core/css/css_invalid_variable_value.h"
#include "third_party/blink/renderer/core/css/css_numeric_literal_value.h"
-#include "third_party/blink/renderer/core/css/css_pending_interpolation_value.h"
#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/core/css/css_unset_value.h"
#include "third_party/blink/renderer/core/css/css_value_list.h"
@@ -56,7 +55,6 @@ class CORE_EXPORT CSSValuePool final : public GarbageCollected<CSSValuePool> {
static const int kMaximumCacheableIntegerValue = 255;
using CSSColorValue = cssvalue::CSSColorValue;
using CSSUnsetValue = cssvalue::CSSUnsetValue;
- using CSSPendingInterpolationValue = cssvalue::CSSPendingInterpolationValue;
using ColorValueCache = HeapHashMap<unsigned, Member<CSSColorValue>>;
static const unsigned kMaximumColorCacheSize = 512;
using FontFaceValueCache =
@@ -76,12 +74,6 @@ class CORE_EXPORT CSSValuePool final : public GarbageCollected<CSSValuePool> {
CSSInvalidVariableValue* InvalidVariableValue() {
return invalid_variable_value_;
}
- CSSPendingInterpolationValue* PendingInterpolationValue(
- CSSPendingInterpolationValue::Type type) {
- DCHECK_GE(static_cast<size_t>(type), 0u);
- DCHECK_LE(static_cast<size_t>(type), 1u);
- return pending_interpolation_values_[static_cast<size_t>(type)];
- }
// Vector caches.
CSSIdentifierValue* IdentifierCacheValue(CSSValueID ident) {
@@ -135,7 +127,7 @@ class CORE_EXPORT CSSValuePool final : public GarbageCollected<CSSValuePool> {
return font_face_value_cache_.insert(string, nullptr);
}
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
// Cached individual values.
@@ -143,7 +135,6 @@ class CORE_EXPORT CSSValuePool final : public GarbageCollected<CSSValuePool> {
Member<CSSInitialValue> initial_value_;
Member<CSSUnsetValue> unset_value_;
Member<CSSInvalidVariableValue> invalid_variable_value_;
- Member<CSSPendingInterpolationValue> pending_interpolation_values_[2];
Member<CSSColorValue> color_transparent_;
Member<CSSColorValue> color_white_;
Member<CSSColorValue> color_black_;
diff --git a/chromium/third_party/blink/renderer/core/css/css_variable_data.cc b/chromium/third_party/blink/renderer/core/css/css_variable_data.cc
index 68f6a166b11..303a387cf38 100644
--- a/chromium/third_party/blink/renderer/core/css/css_variable_data.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_variable_data.cc
@@ -96,7 +96,8 @@ const CSSValue* CSSVariableData::ParseForSyntax(
DCHECK(!NeedsVariableResolution());
// TODO(timloh): This probably needs a proper parser context for
// relative URL resolution.
- return syntax.Parse(TokenRange(), StrictCSSParserContext(secure_context_mode),
+ return syntax.Parse(TokenRange(),
+ *StrictCSSParserContext(secure_context_mode),
is_animation_tainted_);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_variable_reference_value.cc b/chromium/third_party/blink/renderer/core/css/css_variable_reference_value.cc
index 859749f4de8..699091f049d 100644
--- a/chromium/third_party/blink/renderer/core/css/css_variable_reference_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_variable_reference_value.cc
@@ -6,7 +6,8 @@
namespace blink {
-void CSSVariableReferenceValue::TraceAfterDispatch(blink::Visitor* visitor) {
+void CSSVariableReferenceValue::TraceAfterDispatch(
+ blink::Visitor* visitor) const {
CSSValue::TraceAfterDispatch(visitor);
visitor->Trace(parser_context_);
}
diff --git a/chromium/third_party/blink/renderer/core/css/css_variable_reference_value.h b/chromium/third_party/blink/renderer/core/css/css_variable_reference_value.h
index 7ec8b2dcb26..d3dcf20d374 100644
--- a/chromium/third_party/blink/renderer/core/css/css_variable_reference_value.h
+++ b/chromium/third_party/blink/renderer/core/css/css_variable_reference_value.h
@@ -38,7 +38,7 @@ class CSSVariableReferenceValue : public CSSValue {
}
String CustomCSSText() const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
scoped_refptr<CSSVariableData> data_;
diff --git a/chromium/third_party/blink/renderer/core/css/css_viewport_rule.cc b/chromium/third_party/blink/renderer/core/css/css_viewport_rule.cc
index 1449477e2c4..90a2ce21992 100644
--- a/chromium/third_party/blink/renderer/core/css/css_viewport_rule.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_viewport_rule.cc
@@ -75,7 +75,7 @@ void CSSViewportRule::Reattach(StyleRuleBase* rule) {
properties_cssom_wrapper_->Reattach(viewport_rule_->MutableProperties());
}
-void CSSViewportRule::Trace(blink::Visitor* visitor) {
+void CSSViewportRule::Trace(Visitor* visitor) {
visitor->Trace(viewport_rule_);
visitor->Trace(properties_cssom_wrapper_);
CSSRule::Trace(visitor);
diff --git a/chromium/third_party/blink/renderer/core/css/css_viewport_rule.h b/chromium/third_party/blink/renderer/core/css/css_viewport_rule.h
index 96c503884ba..1806a6739f6 100644
--- a/chromium/third_party/blink/renderer/core/css/css_viewport_rule.h
+++ b/chromium/third_party/blink/renderer/core/css/css_viewport_rule.h
@@ -53,7 +53,7 @@ class CSSViewportRule final : public CSSRule {
CSSStyleDeclaration* style() const;
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
CSSRule::Type type() const override { return kViewportRule; }
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map.cc b/chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map.cc
index 8ae6921ecdf..aacccd53811 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map.cc
@@ -10,161 +10,24 @@
#include "third_party/blink/renderer/core/css/css_identifier_value.h"
#include "third_party/blink/renderer/core/css/css_numeric_literal_value.h"
#include "third_party/blink/renderer/core/css/css_variable_data.h"
+#include "third_party/blink/renderer/core/css/properties/computed_style_utils.h"
#include "third_party/blink/renderer/core/css/properties/css_property_ref.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/pseudo_element.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
-#include "third_party/blink/renderer/platform/transforms/matrix_3d_transform_operation.h"
-#include "third_party/blink/renderer/platform/transforms/matrix_transform_operation.h"
-#include "third_party/blink/renderer/platform/transforms/perspective_transform_operation.h"
-#include "third_party/blink/renderer/platform/transforms/skew_transform_operation.h"
namespace blink {
namespace {
-// We collapse functions like translateX into translate, since we will reify
-// them as a translate anyway.
-const CSSValue* ComputedTransformComponent(const TransformOperation& operation,
- float zoom) {
- switch (operation.GetType()) {
- case TransformOperation::kScaleX:
- case TransformOperation::kScaleY:
- case TransformOperation::kScaleZ:
- case TransformOperation::kScale:
- case TransformOperation::kScale3D: {
- const auto& scale = ToScaleTransformOperation(operation);
- CSSFunctionValue* result = MakeGarbageCollected<CSSFunctionValue>(
- operation.Is3DOperation() ? CSSValueID::kScale3d
- : CSSValueID::kScale);
- result->Append(*CSSNumericLiteralValue::Create(
- scale.X(), CSSPrimitiveValue::UnitType::kNumber));
- result->Append(*CSSNumericLiteralValue::Create(
- scale.Y(), CSSPrimitiveValue::UnitType::kNumber));
- if (operation.Is3DOperation()) {
- result->Append(*CSSNumericLiteralValue::Create(
- scale.Z(), CSSPrimitiveValue::UnitType::kNumber));
- }
- return result;
- }
- case TransformOperation::kTranslateX:
- case TransformOperation::kTranslateY:
- case TransformOperation::kTranslateZ:
- case TransformOperation::kTranslate:
- case TransformOperation::kTranslate3D: {
- const auto& translate = ToTranslateTransformOperation(operation);
- CSSFunctionValue* result = MakeGarbageCollected<CSSFunctionValue>(
- operation.Is3DOperation() ? CSSValueID::kTranslate3d
- : CSSValueID::kTranslate);
- result->Append(*CSSPrimitiveValue::CreateFromLength(translate.X(), zoom));
- result->Append(*CSSPrimitiveValue::CreateFromLength(translate.Y(), zoom));
- if (operation.Is3DOperation()) {
- result->Append(*CSSNumericLiteralValue::Create(
- translate.Z(), CSSPrimitiveValue::UnitType::kPixels));
- }
- return result;
- }
- case TransformOperation::kRotateX:
- case TransformOperation::kRotateY:
- case TransformOperation::kRotate3D: {
- const auto& rotate = ToRotateTransformOperation(operation);
- CSSFunctionValue* result =
- MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kRotate3d);
- result->Append(*CSSNumericLiteralValue::Create(
- rotate.X(), CSSPrimitiveValue::UnitType::kNumber));
- result->Append(*CSSNumericLiteralValue::Create(
- rotate.Y(), CSSPrimitiveValue::UnitType::kNumber));
- result->Append(*CSSNumericLiteralValue::Create(
- rotate.Z(), CSSPrimitiveValue::UnitType::kNumber));
- result->Append(*CSSNumericLiteralValue::Create(
- rotate.Angle(), CSSPrimitiveValue::UnitType::kDegrees));
- return result;
- }
- case TransformOperation::kRotate: {
- const auto& rotate = ToRotateTransformOperation(operation);
- auto* result =
- MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kRotate);
- result->Append(*CSSNumericLiteralValue::Create(
- rotate.Angle(), CSSPrimitiveValue::UnitType::kDegrees));
- return result;
- }
- case TransformOperation::kSkewX: {
- const auto& skew = ToSkewTransformOperation(operation);
- auto* result = MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kSkewX);
- result->Append(*CSSNumericLiteralValue::Create(
- skew.AngleX(), CSSPrimitiveValue::UnitType::kDegrees));
- return result;
- }
- case TransformOperation::kSkewY: {
- const auto& skew = ToSkewTransformOperation(operation);
- auto* result = MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kSkewY);
- result->Append(*CSSNumericLiteralValue::Create(
- skew.AngleY(), CSSPrimitiveValue::UnitType::kDegrees));
- return result;
- }
- case TransformOperation::kSkew: {
- const auto& skew = ToSkewTransformOperation(operation);
- auto* result = MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kSkew);
- result->Append(*CSSNumericLiteralValue::Create(
- skew.AngleX(), CSSPrimitiveValue::UnitType::kDegrees));
- result->Append(*CSSNumericLiteralValue::Create(
- skew.AngleY(), CSSPrimitiveValue::UnitType::kDegrees));
- return result;
- }
- case TransformOperation::kPerspective: {
- const auto& perspective = ToPerspectiveTransformOperation(operation);
- auto* result =
- MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kPerspective);
- result->Append(*CSSNumericLiteralValue::Create(
- perspective.Perspective(), CSSPrimitiveValue::UnitType::kPixels));
- return result;
- }
- case TransformOperation::kMatrix: {
- const auto& matrix = ToMatrixTransformOperation(operation).Matrix();
- auto* result =
- MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kMatrix);
- double values[6] = {matrix.A(), matrix.B(), matrix.C(),
- matrix.D(), matrix.E(), matrix.F()};
- for (double value : values) {
- result->Append(*CSSNumericLiteralValue::Create(
- value, CSSPrimitiveValue::UnitType::kNumber));
- }
- return result;
- }
- case TransformOperation::kMatrix3D: {
- const auto& matrix = ToMatrix3DTransformOperation(operation).Matrix();
- CSSFunctionValue* result =
- MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kMatrix3d);
- double values[16] = {
- matrix.M11(), matrix.M12(), matrix.M13(), matrix.M14(),
- matrix.M21(), matrix.M22(), matrix.M23(), matrix.M24(),
- matrix.M31(), matrix.M32(), matrix.M33(), matrix.M34(),
- matrix.M41(), matrix.M42(), matrix.M43(), matrix.M44()};
- for (double value : values) {
- result->Append(*CSSNumericLiteralValue::Create(
- value, CSSPrimitiveValue::UnitType::kNumber));
- }
- return result;
- }
- case TransformOperation::kInterpolated:
- // TODO(816803): The computed value in this case is not fully spec'd
- // See https://github.com/w3c/css-houdini-drafts/issues/425
- return CSSIdentifierValue::Create(CSSValueID::kNone);
- default:
- // The remaining operations are unsupported.
- NOTREACHED();
- return CSSIdentifierValue::Create(CSSValueID::kNone);
- }
-}
-
const CSSValue* ComputedTransform(const ComputedStyle& style) {
if (style.Transform().Operations().size() == 0)
return CSSIdentifierValue::Create(CSSValueID::kNone);
CSSValueList* components = CSSValueList::CreateSpaceSeparated();
for (const auto& operation : style.Transform().Operations()) {
- components->Append(
- *ComputedTransformComponent(*operation, style.EffectiveZoom()));
+ components->Append(*ComputedStyleUtils::ValueForTransformOperation(
+ *operation, style.EffectiveZoom()));
}
return components;
}
@@ -177,9 +40,12 @@ unsigned int ComputedStylePropertyMap::size() const {
return 0;
DCHECK(StyledNode());
- return CSSComputedStyleDeclaration::ComputableProperties().size() +
+ const Document& document = StyledNode()->GetDocument();
+ return CSSComputedStyleDeclaration::ComputableProperties(
+ StyledNode()->GetExecutionContext())
+ .size() +
ComputedStyleCSSValueMapping::GetVariables(
- *style, StyledNode()->GetDocument().GetPropertyRegistry())
+ *style, document.GetPropertyRegistry())
.size();
}
@@ -242,6 +108,8 @@ const CSSValue* ComputedStylePropertyMap::GetProperty(
switch (property_id) {
case CSSPropertyID::kTransform:
return ComputedTransform(*style);
+ case CSSPropertyID::kLineHeight:
+ return ComputedStyleUtils::ComputedValueForLineHeight(*style);
default:
return CSSProperty::Get(property_id)
.CSSValueFromComputedStyle(*style, nullptr /* layout_object */,
@@ -265,11 +133,14 @@ void ComputedStylePropertyMap::ForEachProperty(
if (!style)
return;
+ DCHECK(StyledNode());
+ const Document& document = StyledNode()->GetDocument();
// Have to sort by all properties by code point, so we have to store
// them in a buffer first.
HeapVector<std::pair<CSSPropertyName, Member<const CSSValue>>> values;
for (const CSSProperty* property :
- CSSComputedStyleDeclaration::ComputableProperties()) {
+ CSSComputedStyleDeclaration::ComputableProperties(
+ StyledNode()->GetExecutionContext())) {
DCHECK(property);
DCHECK(!property->IDEquals(CSSPropertyID::kVariable));
const CSSValue* value = property->CSSValueFromComputedStyle(
@@ -278,8 +149,7 @@ void ComputedStylePropertyMap::ForEachProperty(
values.emplace_back(CSSPropertyName(property->PropertyID()), value);
}
- PropertyRegistry* registry =
- StyledNode()->GetDocument().GetPropertyRegistry();
+ const PropertyRegistry* registry = document.GetPropertyRegistry();
for (const auto& name_value :
ComputedStyleCSSValueMapping::GetVariables(*style, registry)) {
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map.h b/chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map.h
index bf4b583ec76..53733de72fa 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map.h
@@ -25,16 +25,12 @@ namespace blink {
class CORE_EXPORT ComputedStylePropertyMap
: public StylePropertyMapReadOnlyMainThread {
public:
- static ComputedStylePropertyMap* Create(Node* node) {
- return MakeGarbageCollected<ComputedStylePropertyMap>(node);
- }
-
ComputedStylePropertyMap(Node* node, const String& pseudo_element = String())
: StylePropertyMapReadOnlyMainThread(),
pseudo_id_(CSSSelector::ParsePseudoId(pseudo_element)),
node_(node) {}
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(node_);
StylePropertyMapReadOnlyMainThread::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map_test.cc b/chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map_test.cc
new file mode 100644
index 00000000000..946ad25258d
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map_test.cc
@@ -0,0 +1,54 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/blink/renderer/core/css/cssom/computed_style_property_map.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/blink/renderer/core/html/html_element.h"
+#include "third_party/blink/renderer/core/testing/page_test_base.h"
+
+namespace blink {
+
+class ComputedStylePropertyMapTest : public PageTestBase {
+ public:
+ ComputedStylePropertyMapTest() = default;
+
+ protected:
+ ComputedStylePropertyMap* SetBodyStyle(const AtomicString& style) {
+ GetDocument().body()->setAttribute(html_names::kStyleAttr, style);
+ UpdateAllLifecyclePhasesForTest();
+ return MakeGarbageCollected<ComputedStylePropertyMap>(GetDocument().body());
+ }
+};
+
+TEST_F(ComputedStylePropertyMapTest, TransformMatrixZoom) {
+ ComputedStylePropertyMap* map =
+ SetBodyStyle("transform:matrix(1, 0, 0, 1, 100, 100);zoom:2");
+ CSSStyleValue* style_value = map->get(GetDocument().GetExecutionContext(),
+ "transform", ASSERT_NO_EXCEPTION);
+ ASSERT_TRUE(style_value);
+ EXPECT_EQ("matrix(1, 0, 0, 1, 100, 100)", style_value->toString());
+}
+
+TEST_F(ComputedStylePropertyMapTest, TransformMatrix3DZoom) {
+ ComputedStylePropertyMap* map = SetBodyStyle(
+ "transform:matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 100, 100, 100, "
+ "1);zoom:2");
+ CSSStyleValue* style_value = map->get(GetDocument().GetExecutionContext(),
+ "transform", ASSERT_NO_EXCEPTION);
+ ASSERT_TRUE(style_value);
+ EXPECT_EQ("matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 100, 100, 100, 1)",
+ style_value->toString());
+}
+
+TEST_F(ComputedStylePropertyMapTest, TransformPerspectiveZoom) {
+ ComputedStylePropertyMap* map =
+ SetBodyStyle("transform:perspective(100px);zoom:2");
+ CSSStyleValue* style_value = map->get(GetDocument().GetExecutionContext(),
+ "transform", ASSERT_NO_EXCEPTION);
+ ASSERT_TRUE(style_value);
+ EXPECT_EQ("perspective(100px)", style_value->toString());
+}
+
+} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/cross_thread_color_value.cc b/chromium/third_party/blink/renderer/core/css/cssom/cross_thread_color_value.cc
index 99270832ef3..8e0c4853759 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/cross_thread_color_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/cross_thread_color_value.cc
@@ -9,7 +9,7 @@
namespace blink {
CSSStyleValue* CrossThreadColorValue::ToCSSStyleValue() {
- return CSSUnsupportedColorValue::Create(value_);
+ return MakeGarbageCollected<CSSUnsupportedColorValue>(value_);
}
bool CrossThreadColorValue::operator==(
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/cross_thread_unsupported_value.cc b/chromium/third_party/blink/renderer/core/css/cssom/cross_thread_unsupported_value.cc
index 657fc347847..756e2ab2740 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/cross_thread_unsupported_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/cross_thread_unsupported_value.cc
@@ -9,7 +9,7 @@
namespace blink {
CSSStyleValue* CrossThreadUnsupportedValue::ToCSSStyleValue() {
- return CSSUnsupportedStyleValue::Create(std::move(value_.IsolatedCopy()));
+ return MakeGarbageCollected<CSSUnsupportedStyleValue>(value_.IsolatedCopy());
}
bool CrossThreadUnsupportedValue::operator==(
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_keyword_value.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_keyword_value.idl
index 31f6b51730d..0185871c3f6 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_keyword_value.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_keyword_value.idl
@@ -6,9 +6,8 @@
// example "initial".
// https://drafts.css-houdini.org/css-typed-om/#keywordvalue-objects
[
- Constructor(CSSOMString keyword),
- Exposed=(Window,LayoutWorklet,PaintWorklet),
- RaisesException=Constructor
+ Exposed=(Window,LayoutWorklet,PaintWorklet)
] interface CSSKeywordValue : CSSStyleValue {
+ [RaisesException] constructor(CSSOMString keyword);
[RaisesException=Setter] attribute CSSOMString value;
};
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_math_invert.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_math_invert.idl
index c165677b6c5..5217cd9db71 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_math_invert.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_math_invert.idl
@@ -5,8 +5,8 @@
// Represents the inverse a CSSNumericValue.
// https://drafts.css-houdini.org/css-typed-om/#cssmathinvert
[
- Constructor(CSSNumberish arg),
Exposed=(Window,LayoutWorklet,PaintWorklet)
] interface CSSMathInvert : CSSMathValue {
+ constructor(CSSNumberish arg);
readonly attribute CSSNumberish value;
};
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_math_max.cc b/chromium/third_party/blink/renderer/core/css/cssom/css_math_max.cc
index 80f6e206f99..328225ead56 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_math_max.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_math_max.cc
@@ -71,9 +71,6 @@ void CSSMathMax::BuildCSSText(Nested, ParenLess, StringBuilder& result) const {
}
CSSMathExpressionNode* CSSMathMax::ToCalcExpressionNode() const {
- if (!RuntimeEnabledFeatures::CSSComparisonFunctionsEnabled())
- return nullptr;
-
CSSMathExpressionVariadicOperation::Operands operands;
operands.ReserveCapacity(NumericValues().size());
for (const auto& value : NumericValues()) {
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_math_max.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_math_max.idl
index 4a29b526ffd..d8f8a89d886 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_math_max.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_math_max.idl
@@ -5,9 +5,8 @@
// Represents the maximum of one or more CSSNumericValues.
// https://drafts.css-houdini.org/css-typed-om/#cssmathsum
[
- Constructor(CSSNumberish... args),
- Exposed=(Window,LayoutWorklet,PaintWorklet),
- RaisesException=Constructor
+ Exposed=(Window,LayoutWorklet,PaintWorklet)
] interface CSSMathMax : CSSMathValue {
+ [RaisesException] constructor(CSSNumberish... args);
readonly attribute CSSNumericArray values;
};
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_math_min.cc b/chromium/third_party/blink/renderer/core/css/cssom/css_math_min.cc
index 7b8d0f8666f..cff5f907f7b 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_math_min.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_math_min.cc
@@ -70,9 +70,6 @@ void CSSMathMin::BuildCSSText(Nested, ParenLess, StringBuilder& result) const {
}
CSSMathExpressionNode* CSSMathMin::ToCalcExpressionNode() const {
- if (!RuntimeEnabledFeatures::CSSComparisonFunctionsEnabled())
- return nullptr;
-
CSSMathExpressionVariadicOperation::Operands operands;
operands.ReserveCapacity(NumericValues().size());
for (const auto& value : NumericValues()) {
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_math_min.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_math_min.idl
index fd8fbb1d2f8..075499cdcd5 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_math_min.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_math_min.idl
@@ -5,9 +5,8 @@
// Represents the minimum of one or more CSSNumericValues.
// https://drafts.css-houdini.org/css-typed-om/#cssmathsum
[
- Constructor(CSSNumberish... args),
- Exposed=(Window,LayoutWorklet,PaintWorklet),
- RaisesException=Constructor
+ Exposed=(Window,LayoutWorklet,PaintWorklet)
] interface CSSMathMin : CSSMathValue {
+ [RaisesException] constructor(CSSNumberish... args);
readonly attribute CSSNumericArray values;
};
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_math_negate.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_math_negate.idl
index 69095537e37..aa2ef47788b 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_math_negate.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_math_negate.idl
@@ -5,8 +5,8 @@
// Represents the negation of a CSSNumericValue.
// https://drafts.css-houdini.org/css-typed-om/#cssmathnegate
[
- Constructor(CSSNumberish arg),
Exposed=(Window,LayoutWorklet,PaintWorklet)
] interface CSSMathNegate : CSSMathValue {
+ constructor(CSSNumberish arg);
readonly attribute CSSNumberish value;
};
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_math_product.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_math_product.idl
index f4c4471331d..abd367d66c5 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_math_product.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_math_product.idl
@@ -5,9 +5,8 @@
// Represents the product of one or more CSSNumericValues.
// https://drafts.css-houdini.org/css-typed-om/#cssmathsub
[
- Constructor(CSSNumberish... args),
- Exposed=(Window,LayoutWorklet,PaintWorklet),
- RaisesException=Constructor
+ Exposed=(Window,LayoutWorklet,PaintWorklet)
] interface CSSMathProduct : CSSMathValue {
+ [RaisesException] constructor(CSSNumberish... args);
readonly attribute CSSNumericArray values;
};
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_math_sum.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_math_sum.idl
index 72b8cb82e9f..dcc74e288be 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_math_sum.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_math_sum.idl
@@ -5,9 +5,8 @@
// Represents the sum of one or more CSSNumericValues.
// https://drafts.css-houdini.org/css-typed-om/#cssmathsum
[
- Constructor(CSSNumberish... args),
- Exposed=(Window,LayoutWorklet,PaintWorklet),
- RaisesException=Constructor
+ Exposed=(Window,LayoutWorklet,PaintWorklet)
] interface CSSMathSum : CSSMathValue {
+ [RaisesException] constructor(CSSNumberish... args);
readonly attribute CSSNumericArray values;
};
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_matrix_component.cc b/chromium/third_party/blink/renderer/core/css/cssom/css_matrix_component.cc
index d6545b6621c..a9e15538810 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_matrix_component.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_matrix_component.cc
@@ -4,9 +4,9 @@
#include "third_party/blink/renderer/core/css/cssom/css_matrix_component.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_css_matrix_component_options.h"
#include "third_party/blink/renderer/core/css/css_numeric_literal_value.h"
#include "third_party/blink/renderer/core/css/css_primitive_value.h"
-#include "third_party/blink/renderer/core/css/cssom/css_matrix_component_options.h"
#include "third_party/blink/renderer/core/geometry/dom_matrix.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_matrix_component.h b/chromium/third_party/blink/renderer/core/css/cssom/css_matrix_component.h
index e60ebefee2c..4f6287a7f17 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_matrix_component.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_matrix_component.h
@@ -41,7 +41,7 @@ class CORE_EXPORT CSSMatrixComponent final : public CSSTransformComponent {
TransformComponentType GetType() const final { return kMatrixType; }
const CSSFunctionValue* ToCSSValue() const final;
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(matrix_);
CSSTransformComponent::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_matrix_component.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_matrix_component.idl
index 530e42f1402..6c304bffd84 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_matrix_component.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_matrix_component.idl
@@ -6,9 +6,9 @@
// "transform".
// Spec: https://drafts.css-houdini.org/css-typed-om/#cssmatrixcomponent
[
- Constructor(DOMMatrixReadOnly matrix,
- optional CSSMatrixComponentOptions options),
Exposed=(Window,LayoutWorklet,PaintWorklet)
] interface CSSMatrixComponent : CSSTransformComponent {
+ constructor(DOMMatrixReadOnly matrix,
+ optional CSSMatrixComponentOptions options = {});
attribute DOMMatrix matrix;
};
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_array.h b/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_array.h
index 529f6a463ba..181c3882d76 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_array.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_array.h
@@ -15,10 +15,6 @@ class CORE_EXPORT CSSNumericArray final : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
- // blink internal
- static CSSNumericArray* Create(CSSNumericValueVector values) {
- return MakeGarbageCollected<CSSNumericArray>(std::move(values));
- }
static CSSNumericArray* FromNumberishes(
const HeapVector<CSSNumberish>& values) {
return MakeGarbageCollected<CSSNumericArray>(
@@ -28,7 +24,7 @@ class CORE_EXPORT CSSNumericArray final : public ScriptWrappable {
explicit CSSNumericArray(CSSNumericValueVector values)
: values_(std::move(values)) {}
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(values_);
ScriptWrappable::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_array.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_array.idl
index 402d98c6720..ae6e651369d 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_array.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_array.idl
@@ -5,8 +5,7 @@
// Represents the sum of one or more CSSNumericValues.
// https://drafts.css-houdini.org/css-typed-om/#cssmathsum
[
- Exposed=(Window,LayoutWorklet,PaintWorklet),
- RaisesException=Constructor
+ Exposed=(Window,LayoutWorklet,PaintWorklet)
] interface CSSNumericArray {
iterable<CSSNumericValue>;
readonly attribute unsigned long length;
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_type.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_type.idl
index e539ea80e9a..24abf9ddd70 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_type.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_type.idl
@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-[
- Exposed=(Window,LayoutWorklet,PaintWorklet)
-] enum CSSNumericBaseType {
+// https://drafts.css-houdini.org/css-typed-om/#enumdef-cssnumericbasetype
+enum CSSNumericBaseType {
"length",
"angle",
"time",
@@ -14,10 +13,8 @@
"percent",
};
-// https://drafts.css-houdini.org/css-typed-om/#cssnumerictype
-[
- Exposed=(Window,LayoutWorklet,PaintWorklet)
-] dictionary CSSNumericType {
+// https://drafts.css-houdini.org/css-typed-om/#dictdef-cssnumerictype
+dictionary CSSNumericType {
long length;
long angle;
long time;
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc b/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc
index 2b0c4e3f499..56a1526b9e0 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc
@@ -6,6 +6,7 @@
#include <numeric>
+#include "third_party/blink/renderer/bindings/core/v8/v8_css_numeric_type.h"
#include "third_party/blink/renderer/core/css/css_math_expression_node.h"
#include "third_party/blink/renderer/core/css/css_math_function_value.h"
#include "third_party/blink/renderer/core/css/css_primitive_value.h"
@@ -251,10 +252,9 @@ CSSNumericValue* CSSNumericValue::parse(const String& css_text,
case kFunctionToken:
if (range.Peek().FunctionId() == CSSValueID::kCalc ||
range.Peek().FunctionId() == CSSValueID::kWebkitCalc ||
- (RuntimeEnabledFeatures::CSSComparisonFunctionsEnabled() &&
- (range.Peek().FunctionId() == CSSValueID::kMin ||
- range.Peek().FunctionId() == CSSValueID::kMax ||
- range.Peek().FunctionId() == CSSValueID::kClamp))) {
+ range.Peek().FunctionId() == CSSValueID::kMin ||
+ range.Peek().FunctionId() == CSSValueID::kMax ||
+ range.Peek().FunctionId() == CSSValueID::kClamp) {
CSSMathExpressionNode* expression =
CSSMathExpressionNode::ParseCalc(range);
if (expression)
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_value.h b/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_value.h
index 066261868cd..15d9723b565 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_value.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_numeric_value.h
@@ -10,7 +10,6 @@
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/css/css_primitive_value.h"
#include "third_party/blink/renderer/core/css/cssom/css_numeric_sum_value.h"
-#include "third_party/blink/renderer/core/css/cssom/css_numeric_type.h"
#include "third_party/blink/renderer/core/css/cssom/css_numeric_value_type.h"
#include "third_party/blink/renderer/core/css/cssom/css_style_value.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
@@ -18,12 +17,13 @@
namespace blink {
+class CSSMathExpressionNode;
+class CSSMathSum;
+class CSSNumericType;
+class CSSNumericValue;
class CSSUnitValue;
class ExceptionState;
-class CSSMathExpressionNode;
-class CSSNumericValue;
-class CSSMathSum;
using CSSNumberish = DoubleOrCSSNumericValue;
using CSSNumericValueVector = HeapVector<Member<CSSNumericValue>>;
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_perspective.h b/chromium/third_party/blink/renderer/core/css/cssom/css_perspective.h
index ff15be0e46a..fed2a88ed39 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_perspective.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_perspective.h
@@ -45,7 +45,7 @@ class CORE_EXPORT CSSPerspective final : public CSSTransformComponent {
TransformComponentType GetType() const final { return kPerspectiveType; }
const CSSFunctionValue* ToCSSValue() const final;
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(length_);
CSSTransformComponent::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_perspective.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_perspective.idl
index 9cba1d1f123..0e763fc3e37 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_perspective.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_perspective.idl
@@ -6,9 +6,8 @@
// like "transform".
// Spec: https://drafts.css-houdini.org/css-typed-om/#cssperspective
[
- Constructor(CSSNumericValue length),
- Exposed=(Window,LayoutWorklet,PaintWorklet),
- RaisesException=Constructor
+ Exposed=(Window,LayoutWorklet,PaintWorklet)
] interface CSSPerspective : CSSTransformComponent {
+ [RaisesException] constructor(CSSNumericValue length);
[RaisesException=Setter] attribute CSSNumericValue length;
};
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_position_value.h b/chromium/third_party/blink/renderer/core/css/cssom/css_position_value.h
index 4d9d1ac5d93..464e1e37700 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_position_value.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_position_value.h
@@ -42,7 +42,7 @@ class CORE_EXPORT CSSPositionValue final : public CSSStyleValue {
const CSSValue* ToCSSValue() const final;
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(x_);
visitor->Trace(y_);
CSSStyleValue::Trace(visitor);
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_position_value.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_position_value.idl
index 3954abba2d5..6d12b1dd02d 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_position_value.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_position_value.idl
@@ -6,10 +6,9 @@
// background-position.
// Spec: https://drafts.css-houdini.org/css-typed-om/#positionvalue-objects
[
- Constructor(CSSNumericValue x, CSSNumericValue y),
- Exposed=(Window,LayoutWorklet,PaintWorklet),
- RaisesException=Constructor
+ Exposed=(Window,LayoutWorklet,PaintWorklet)
] interface CSSPositionValue : CSSStyleValue {
+ [RaisesException] constructor(CSSNumericValue x, CSSNumericValue y);
[RaisesException=Setter] attribute CSSNumericValue x;
[RaisesException=Setter] attribute CSSNumericValue y;
};
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_resource_value.h b/chromium/third_party/blink/renderer/core/css/cssom/css_resource_value.h
index b08ae0a20d6..e7e3f46401e 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_resource_value.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_resource_value.h
@@ -32,9 +32,7 @@ class CORE_EXPORT CSSResourceValue : public CSSStyleValue {
}
}
- void Trace(blink::Visitor* visitor) override {
- CSSStyleValue::Trace(visitor);
- }
+ void Trace(Visitor* visitor) override { CSSStyleValue::Trace(visitor); }
protected:
CSSResourceValue() = default;
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_rotate.h b/chromium/third_party/blink/renderer/core/css/cssom/css_rotate.h
index f0a5f04a575..cf22fa2e433 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_rotate.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_rotate.h
@@ -60,7 +60,7 @@ class CORE_EXPORT CSSRotate final : public CSSTransformComponent {
TransformComponentType GetType() const final { return kRotationType; }
const CSSFunctionValue* ToCSSValue() const final;
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(angle_);
visitor->Trace(x_);
visitor->Trace(y_);
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_rotate.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_rotate.idl
index 1b19a86e0e0..2340f4604bb 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_rotate.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_rotate.idl
@@ -6,11 +6,10 @@
// "transform".
// Spec: https://drafts.css-houdini.org/css-typed-om/#cssrotate
[
- Constructor(CSSNumericValue angleValue),
- Constructor(CSSNumberish x, CSSNumberish y, CSSNumberish z, CSSNumericValue angle),
- Exposed=(Window,LayoutWorklet,PaintWorklet),
- RaisesException=Constructor
+ Exposed=(Window,LayoutWorklet,PaintWorklet)
] interface CSSRotate : CSSTransformComponent {
+ [RaisesException] constructor(CSSNumericValue angleValue);
+ [RaisesException] constructor(CSSNumberish x, CSSNumberish y, CSSNumberish z, CSSNumericValue angle);
[RaisesException=Setter] attribute CSSNumericValue angle;
[RaisesException=Setter] attribute CSSNumberish x;
[RaisesException=Setter] attribute CSSNumberish y;
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_scale.h b/chromium/third_party/blink/renderer/core/css/cssom/css_scale.h
index e564e330d76..43c1adf6c5d 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_scale.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_scale.h
@@ -62,7 +62,7 @@ class CORE_EXPORT CSSScale final : public CSSTransformComponent {
TransformComponentType GetType() const final { return kScaleType; }
const CSSFunctionValue* ToCSSValue() const final;
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(x_);
visitor->Trace(y_);
visitor->Trace(z_);
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_scale.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_scale.idl
index 2644e70bb61..7294deea0e5 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_scale.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_scale.idl
@@ -6,10 +6,9 @@
// "transform".
// Spec: https://drafts.css-houdini.org/css-typed-om/#cssscale
[
- Constructor(CSSNumberish x, CSSNumberish y, optional CSSNumberish z),
- Exposed=(Window,LayoutWorklet,PaintWorklet),
- RaisesException=Constructor
+ Exposed=(Window,LayoutWorklet,PaintWorklet)
] interface CSSScale : CSSTransformComponent {
+ [RaisesException] constructor(CSSNumberish x, CSSNumberish y, optional CSSNumberish z);
[RaisesException=Setter] attribute CSSNumberish x;
[RaisesException=Setter] attribute CSSNumberish y;
[RaisesException=Setter] attribute CSSNumberish z;
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_skew.h b/chromium/third_party/blink/renderer/core/css/cssom/css_skew.h
index 9fddbe91471..2b0bf78633f 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_skew.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_skew.h
@@ -49,7 +49,7 @@ class CORE_EXPORT CSSSkew final : public CSSTransformComponent {
TransformComponentType GetType() const override { return kSkewType; }
const CSSFunctionValue* ToCSSValue() const override;
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(ax_);
visitor->Trace(ay_);
CSSTransformComponent::Trace(visitor);
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_skew.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_skew.idl
index 8aed33f0326..15e91f5d5f5 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_skew.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_skew.idl
@@ -6,10 +6,9 @@
// "transform".
// Spec: https://drafts.css-houdini.org/css-typed-om/#cssskew
[
- Constructor(CSSNumericValue ax, CSSNumericValue ay),
- Exposed=(Window,LayoutWorklet,PaintWorklet),
- RaisesException=Constructor
+ Exposed=(Window,LayoutWorklet,PaintWorklet)
] interface CSSSkew : CSSTransformComponent {
+ [RaisesException] constructor(CSSNumericValue ax, CSSNumericValue ay);
[RaisesException=Setter] attribute CSSNumericValue ax;
[RaisesException=Setter] attribute CSSNumericValue ay;
};
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_skew_x.h b/chromium/third_party/blink/renderer/core/css/cssom/css_skew_x.h
index 7e16aac2c3e..73b55695173 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_skew_x.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_skew_x.h
@@ -47,7 +47,7 @@ class CORE_EXPORT CSSSkewX final : public CSSTransformComponent {
TransformComponentType GetType() const override { return kSkewXType; }
const CSSFunctionValue* ToCSSValue() const override;
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(ax_);
CSSTransformComponent::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_skew_x.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_skew_x.idl
index fc08ea50bf3..a342b898baf 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_skew_x.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_skew_x.idl
@@ -6,9 +6,8 @@
// "transform".
// Spec: https://drafts.css-houdini.org/css-typed-om/#cssskewx
[
- Constructor(CSSNumericValue ax),
- Exposed=(Window, Worker, PaintWorklet, LayoutWorklet),
- RaisesException=Constructor]
-interface CSSSkewX : CSSTransformComponent {
+ Exposed=(Window, Worker, PaintWorklet, LayoutWorklet)
+] interface CSSSkewX : CSSTransformComponent {
+ [RaisesException] constructor(CSSNumericValue ax);
[RaisesException=Setter] attribute CSSNumericValue ax;
};
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_skew_y.h b/chromium/third_party/blink/renderer/core/css/cssom/css_skew_y.h
index 10378a73b9a..1d7bc3257d3 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_skew_y.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_skew_y.h
@@ -47,7 +47,7 @@ class CORE_EXPORT CSSSkewY final : public CSSTransformComponent {
TransformComponentType GetType() const override { return kSkewYType; }
const CSSFunctionValue* ToCSSValue() const override;
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(ay_);
CSSTransformComponent::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_skew_y.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_skew_y.idl
index eea0517cc41..5c3130ca7ac 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_skew_y.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_skew_y.idl
@@ -6,9 +6,8 @@
// "transform".
// Spec: https://drafts.css-houdini.org/css-typed-om/#cssskewy
[
- Constructor(CSSNumericValue ay),
- Exposed=(Window, Worker, PaintWorklet, LayoutWorklet),
- RaisesException=Constructor]
-interface CSSSkewY : CSSTransformComponent {
+ Exposed=(Window, Worker, PaintWorklet, LayoutWorklet)
+] interface CSSSkewY : CSSTransformComponent {
+ [RaisesException] constructor(CSSNumericValue ay);
[RaisesException=Setter] attribute CSSNumericValue ay;
};
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_style_image_value.cc b/chromium/third_party/blink/renderer/core/css/cssom/css_style_image_value.cc
index cf9e080f1ad..2348a398c4e 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_style_image_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_style_image_value.cc
@@ -34,7 +34,8 @@ double CSSStyleImageValue::intrinsicRatio(bool& is_null) const {
}
FloatSize CSSStyleImageValue::ElementSize(
- const FloatSize& default_object_size) const {
+ const FloatSize& default_object_size,
+ const RespectImageOrientationEnum) const {
bool not_used;
return FloatSize(intrinsicWidth(not_used), intrinsicHeight(not_used));
}
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_style_image_value.h b/chromium/third_party/blink/renderer/core/css/cssom/css_style_image_value.h
index 77e9d0e5275..1731aa9ee8c 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_style_image_value.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_style_image_value.h
@@ -30,7 +30,8 @@ class CORE_EXPORT CSSStyleImageValue : public CSSResourceValue,
// CanvasImageSource
bool IsCSSImageValue() const final { return true; }
bool WouldTaintOrigin() const final { return true; }
- FloatSize ElementSize(const FloatSize& default_object_size) const final;
+ FloatSize ElementSize(const FloatSize& default_object_size,
+ const RespectImageOrientationEnum) const final;
protected:
CSSStyleImageValue() = default;
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_style_value.cc b/chromium/third_party/blink/renderer/core/css/cssom/css_style_value.cc
index 53dd6b1c279..5e26e4e55f9 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_style_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_style_value.cc
@@ -24,7 +24,8 @@ CSSStyleValueVector ParseCSSStyleValue(
const String& property_name,
const String& value,
ExceptionState& exception_state) {
- const CSSPropertyID property_id = cssPropertyID(property_name);
+ const CSSPropertyID property_id =
+ cssPropertyID(execution_context, property_name);
if (property_id == CSSPropertyID::kInvalid) {
exception_state.ThrowTypeError("Invalid property name");
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_style_variable_reference_value.h b/chromium/third_party/blink/renderer/core/css/cssom/css_style_variable_reference_value.h
index 2173b0cef9a..74b8914e3c0 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_style_variable_reference_value.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_style_variable_reference_value.h
@@ -42,7 +42,7 @@ class CORE_EXPORT CSSStyleVariableReferenceValue final
CSSUnparsedValue* fallback() { return fallback_.Get(); }
const CSSUnparsedValue* fallback() const { return fallback_.Get(); }
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(fallback_);
ScriptWrappable::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_transform_value.cc b/chromium/third_party/blink/renderer/core/css/cssom/css_transform_value.cc
index 4876fa3337d..53b81acb115 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_transform_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_transform_value.cc
@@ -77,25 +77,25 @@ const CSSValue* CSSTransformValue::ToCSSValue() const {
return transform_css_value;
}
-bool CSSTransformValue::AnonymousIndexedSetter(
+IndexedPropertySetterResult CSSTransformValue::AnonymousIndexedSetter(
unsigned index,
const Member<CSSTransformComponent> component,
ExceptionState& exception_state) {
if (index < transform_components_.size()) {
transform_components_[index] = component;
- return true;
+ return IndexedPropertySetterResult::kIntercepted;
}
if (index == transform_components_.size()) {
transform_components_.push_back(component);
- return true;
+ return IndexedPropertySetterResult::kIntercepted;
}
exception_state.ThrowRangeError(
ExceptionMessages::IndexOutsideRange<unsigned>(
"index", index, 0, ExceptionMessages::kInclusiveBound,
transform_components_.size(), ExceptionMessages::kInclusiveBound));
- return false;
+ return IndexedPropertySetterResult::kIntercepted;
}
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_transform_value.h b/chromium/third_party/blink/renderer/core/css/cssom/css_transform_value.h
index c7bcc5a4103..7cfb9f5e02b 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_transform_value.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_transform_value.h
@@ -10,6 +10,7 @@
#include "third_party/blink/renderer/core/css/cssom/css_style_value.h"
#include "third_party/blink/renderer/core/css/cssom/css_transform_component.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
+#include "third_party/blink/renderer/platform/bindings/v8_binding.h"
#include "third_party/blink/renderer/platform/heap/heap_allocator.h"
namespace blink {
@@ -45,13 +46,14 @@ class CORE_EXPORT CSSTransformValue final : public CSSStyleValue {
CSSTransformComponent* AnonymousIndexedGetter(wtf_size_t index) {
return transform_components_.at(index);
}
- bool AnonymousIndexedSetter(unsigned,
- const Member<CSSTransformComponent>,
- ExceptionState&);
+ IndexedPropertySetterResult AnonymousIndexedSetter(
+ unsigned,
+ const Member<CSSTransformComponent>,
+ ExceptionState&);
wtf_size_t length() const { return transform_components_.size(); }
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(transform_components_);
CSSStyleValue::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_transform_value.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_transform_value.idl
index 7c654d1180a..96b6f2a8736 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_transform_value.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_transform_value.idl
@@ -3,10 +3,9 @@
// found in the LICENSE file.
[
- Constructor(sequence<CSSTransformComponent> transforms),
- RaisesException=Constructor,
Exposed=(Window,LayoutWorklet,PaintWorklet)
] interface CSSTransformValue : CSSStyleValue {
+ [RaisesException] constructor(sequence<CSSTransformComponent> transforms);
iterable<CSSTransformComponent>;
readonly attribute unsigned long length;
getter CSSTransformComponent (unsigned long index);
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_translate.h b/chromium/third_party/blink/renderer/core/css/cssom/css_translate.h
index e28fa08ee1c..24bc55a7ff1 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_translate.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_translate.h
@@ -59,7 +59,7 @@ class CORE_EXPORT CSSTranslate final : public CSSTransformComponent {
TransformComponentType GetType() const final { return kTranslationType; }
const CSSFunctionValue* ToCSSValue() const final;
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(x_);
visitor->Trace(y_);
visitor->Trace(z_);
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_translate.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_translate.idl
index 51f2ce9e6de..33c7adb9df9 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_translate.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_translate.idl
@@ -6,11 +6,10 @@
// like "transform".
// Spec: https://drafts.css-houdini.org/css-typed-om/#csstranslate
[
- Constructor(CSSNumericValue x, CSSNumericValue y,
- optional CSSNumericValue z),
- Exposed=(Window,LayoutWorklet,PaintWorklet),
- RaisesException=Constructor
+ Exposed=(Window,LayoutWorklet,PaintWorklet)
] interface CSSTranslate : CSSTransformComponent {
+ [RaisesException] constructor(CSSNumericValue x, CSSNumericValue y,
+ optional CSSNumericValue z);
[RaisesException=Setter] attribute CSSNumericValue x;
[RaisesException=Setter] attribute CSSNumericValue y;
[RaisesException=Setter] attribute CSSNumericValue z;
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_unit_value.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_unit_value.idl
index b0be5d7bdfd..92aa8035ae6 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_unit_value.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_unit_value.idl
@@ -6,10 +6,9 @@
// unit (or a naked number or percentage).
// https://drafts.css-houdini.org/css-typed-om/#cssunitvalue
[
- Constructor(double value, CSSOMString unit),
- RaisesException=Constructor,
Exposed=(Window,LayoutWorklet,PaintWorklet)
] interface CSSUnitValue : CSSNumericValue {
+ [RaisesException] constructor(double value, CSSOMString unit);
attribute double value;
readonly attribute CSSOMString unit;
};
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_unparsed_value.cc b/chromium/third_party/blink/renderer/core/css/cssom/css_unparsed_value.cc
index 8d7badb9cac..48193970239 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_unparsed_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_unparsed_value.cc
@@ -94,24 +94,25 @@ CSSUnparsedSegment CSSUnparsedValue::AnonymousIndexedGetter(
return {};
}
-bool CSSUnparsedValue::AnonymousIndexedSetter(unsigned index,
- const CSSUnparsedSegment& segment,
- ExceptionState& exception_state) {
+IndexedPropertySetterResult CSSUnparsedValue::AnonymousIndexedSetter(
+ unsigned index,
+ const CSSUnparsedSegment& segment,
+ ExceptionState& exception_state) {
if (index < tokens_.size()) {
tokens_[index] = segment;
- return true;
+ return IndexedPropertySetterResult::kIntercepted;
}
if (index == tokens_.size()) {
tokens_.push_back(segment);
- return true;
+ return IndexedPropertySetterResult::kIntercepted;
}
exception_state.ThrowRangeError(
ExceptionMessages::IndexOutsideRange<unsigned>(
"index", index, 0, ExceptionMessages::kInclusiveBound, tokens_.size(),
ExceptionMessages::kInclusiveBound));
- return false;
+ return IndexedPropertySetterResult::kIntercepted;
}
const CSSValue* CSSUnparsedValue::ToCSSValue() const {
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_unparsed_value.h b/chromium/third_party/blink/renderer/core/css/cssom/css_unparsed_value.h
index 7c87b475f86..f567216c372 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_unparsed_value.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_unparsed_value.h
@@ -47,10 +47,19 @@ class CORE_EXPORT CSSUnparsedValue final : public CSSStyleValue {
StyleValueType GetType() const override { return kUnparsedType; }
+ void AnonymousIndexedGetter(uint32_t index,
+ CSSUnparsedSegment& return_value,
+ ExceptionState& exception_state) const {
+ return_value = AnonymousIndexedGetter(index, exception_state);
+ }
+ // TODO(crbug.com/1050474): Remove the following 2-arguments version once the
+ // migration to the new bindings generator is done. The current policy is
+ // that return value of IDL union type is returned by argument. This policy
+ // may change when we implement IDL union types with GarbageCollected classes.
CSSUnparsedSegment AnonymousIndexedGetter(unsigned, ExceptionState&) const;
- bool AnonymousIndexedSetter(unsigned,
- const CSSUnparsedSegment&,
- ExceptionState&);
+ IndexedPropertySetterResult AnonymousIndexedSetter(unsigned,
+ const CSSUnparsedSegment&,
+ ExceptionState&);
wtf_size_t length() const { return tokens_.size(); }
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_unparsed_value.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_unparsed_value.idl
index 685c20f086c..40696ca7940 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_unparsed_value.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_unparsed_value.idl
@@ -6,9 +6,9 @@
// They represent a list of string fragments and variable references.
// Spec: https://drafts.css-houdini.org/css-typed-om/#unparsedvalue-objects
[
- Constructor(sequence<CSSUnparsedSegment> members),
Exposed=(Window,LayoutWorklet,PaintWorklet)
] interface CSSUnparsedValue : CSSStyleValue {
+ constructor(sequence<CSSUnparsedSegment> members);
iterable<CSSUnparsedSegment>;
readonly attribute unsigned long length;
[RaisesException] getter CSSUnparsedSegment (unsigned long index);
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_color_value.cc b/chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_color_value.cc
index 1a10dbe3d52..f94b593c1c3 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_color_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_color_value.cc
@@ -17,21 +17,6 @@
namespace blink {
-CSSUnsupportedColorValue* CSSUnsupportedColorValue::Create(Color color) {
- return MakeGarbageCollected<CSSUnsupportedColorValue>(color);
-}
-
-CSSUnsupportedColorValue* CSSUnsupportedColorValue::Create(
- const CSSPropertyName& name,
- Color color) {
- return MakeGarbageCollected<CSSUnsupportedColorValue>(name, color);
-}
-
-CSSUnsupportedColorValue* CSSUnsupportedColorValue::FromCSSValue(
- const cssvalue::CSSColorValue& color_value) {
- return MakeGarbageCollected<CSSUnsupportedColorValue>(color_value.Value());
-}
-
Color CSSUnsupportedColorValue::Value() const {
return color_value_;
}
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_color_value.h b/chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_color_value.h
index afe63a5ad49..4e23e45b943 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_color_value.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_color_value.h
@@ -21,11 +21,6 @@ namespace blink {
class CORE_EXPORT CSSUnsupportedColorValue final
: public CSSUnsupportedStyleValue {
public:
- static CSSUnsupportedColorValue* Create(Color color);
- static CSSUnsupportedColorValue* Create(const CSSPropertyName& name,
- Color color);
- static CSSUnsupportedColorValue* FromCSSValue(const cssvalue::CSSColorValue&);
-
explicit CSSUnsupportedColorValue(Color color)
: CSSUnsupportedStyleValue(
cssvalue::CSSColorValue::SerializeAsCSSComponentValue(color)),
@@ -35,6 +30,8 @@ class CORE_EXPORT CSSUnsupportedColorValue final
name,
cssvalue::CSSColorValue::SerializeAsCSSComponentValue(color)),
color_value_(color) {}
+ explicit CSSUnsupportedColorValue(const cssvalue::CSSColorValue& color_value)
+ : CSSUnsupportedColorValue(color_value.Value()) {}
StyleValueType GetType() const override { return kUnsupportedColorType; }
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_color_value_test.cc b/chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_color_value_test.cc
index b501a3b2e29..b83e40cbf50 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_color_value_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_color_value_test.cc
@@ -10,7 +10,7 @@ namespace blink {
TEST(CSSUnsupportedColorValueTest, CreateColorStyleValue) {
CSSStyleValue* style_value =
- CSSUnsupportedColorValue::Create(Color(0, 255, 0));
+ MakeGarbageCollected<CSSUnsupportedColorValue>(Color(0, 255, 0));
EXPECT_EQ(style_value->GetType(),
CSSStyleValue::StyleValueType::kUnsupportedColorType);
@@ -26,7 +26,7 @@ TEST(CSSUnsupportedColorValueTest, CreateColorStyleValue) {
TEST(CSSUnsupportedColorValueTest, ColorStyleValueToString) {
CSSUnsupportedColorValue* style_value =
- CSSUnsupportedColorValue::Create(Color(0, 255, 0));
+ MakeGarbageCollected<CSSUnsupportedColorValue>(Color(0, 255, 0));
EXPECT_TRUE(style_value);
EXPECT_EQ(
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_style_value.h b/chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_style_value.h
index c43d1303a6c..751ddda529c 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_style_value.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_unsupported_style_value.h
@@ -26,27 +26,15 @@ namespace blink {
class CORE_EXPORT CSSUnsupportedStyleValue : public CSSStyleValue {
public:
- static CSSUnsupportedStyleValue* Create(const CSSValue& value) {
- return MakeGarbageCollected<CSSUnsupportedStyleValue>(value.CssText());
- }
- static CSSUnsupportedStyleValue* Create(const String& css_text) {
- return MakeGarbageCollected<CSSUnsupportedStyleValue>(css_text);
- }
- static CSSUnsupportedStyleValue* Create(const CSSPropertyName& name,
- const String& css_text) {
- return MakeGarbageCollected<CSSUnsupportedStyleValue>(name, css_text);
- }
- static CSSUnsupportedStyleValue* Create(const CSSPropertyName& name,
- const CSSValue& value) {
- return MakeGarbageCollected<CSSUnsupportedStyleValue>(name,
- value.CssText());
- }
-
CSSUnsupportedStyleValue(const String& css_text) { SetCSSText(css_text); }
CSSUnsupportedStyleValue(const CSSPropertyName& name, const String& css_text)
: name_(name) {
SetCSSText(css_text);
}
+ CSSUnsupportedStyleValue(const CSSPropertyName& name, const CSSValue& value)
+ : name_(name) {
+ SetCSSText(value.CssText());
+ }
StyleValueType GetType() const override {
return StyleValueType::kUnknownType;
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_url_image_value.cc b/chromium/third_party/blink/renderer/core/css/cssom/css_url_image_value.cc
index 922cd34ec61..4130f1cca56 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_url_image_value.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_url_image_value.cc
@@ -20,8 +20,9 @@ base::Optional<IntSize> CSSURLImageValue::IntrinsicSize() const {
DCHECK(!value_->IsCachePending());
ImageResourceContent* resource_content = value_->CachedImage()->CachedImage();
+
return resource_content
- ? resource_content->IntrinsicSize(kDoNotRespectImageOrientation)
+ ? resource_content->IntrinsicSize(kRespectImageOrientation)
: IntSize(0, 0);
}
@@ -58,7 +59,7 @@ const CSSValue* CSSURLImageValue::ToCSSValue() const {
return value_;
}
-void CSSURLImageValue::Trace(blink::Visitor* visitor) {
+void CSSURLImageValue::Trace(Visitor* visitor) {
visitor->Trace(value_);
CSSStyleImageValue::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_url_image_value.h b/chromium/third_party/blink/renderer/core/css/cssom/css_url_image_value.h
index f8ca0aa20d8..a941d43fb33 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_url_image_value.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_url_image_value.h
@@ -32,7 +32,7 @@ class CORE_EXPORT CSSURLImageValue final : public CSSStyleImageValue {
StyleValueType GetType() const final { return kURLImageType; }
const CSSValue* ToCSSValue() const final;
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
scoped_refptr<Image> GetImage() const;
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/css_variable_reference_value.idl b/chromium/third_party/blink/renderer/core/css/cssom/css_variable_reference_value.idl
index ca4677386dd..1fc1325d779 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/css_variable_reference_value.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/css_variable_reference_value.idl
@@ -5,11 +5,10 @@
// Represents a CSS var() reference in a CSS value.
// Spec: https://drafts.css-houdini.org/css-typed-om/#cssvariablereferencevalue
[
- Constructor(CSSOMString variable, optional CSSUnparsedValue? fallback = null),
Exposed=(Window,LayoutWorklet,PaintWorklet),
- RaisesException=Constructor,
ImplementedAs=CSSStyleVariableReferenceValue
] interface CSSVariableReferenceValue {
+ [RaisesException] constructor(CSSOMString variable, optional CSSUnparsedValue? fallback = null);
[RaisesException=Setter] attribute CSSOMString variable;
readonly attribute CSSUnparsedValue? fallback;
};
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/declared_style_property_map.h b/chromium/third_party/blink/renderer/core/css/cssom/declared_style_property_map.h
index f0757b7453f..4bb264af0b5 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/declared_style_property_map.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/declared_style_property_map.h
@@ -24,7 +24,7 @@ class CORE_EXPORT DeclaredStylePropertyMap final : public StylePropertyMap {
public:
explicit DeclaredStylePropertyMap(CSSStyleRule* owner_rule);
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(owner_rule_);
StylePropertyMap::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/inline_style_property_map.h b/chromium/third_party/blink/renderer/core/css/cssom/inline_style_property_map.h
index 40969db6e14..1c02dd570c5 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/inline_style_property_map.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/inline_style_property_map.h
@@ -16,7 +16,7 @@ class CORE_EXPORT InlineStylePropertyMap final : public StylePropertyMap {
explicit InlineStylePropertyMap(Element* owner_element)
: owner_element_(owner_element) {}
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(owner_element_);
StylePropertyMap::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/inline_style_property_map_test.cc b/chromium/third_party/blink/renderer/core/css/cssom/inline_style_property_map_test.cc
index 87412c21f99..6ee90aaba8d 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/inline_style_property_map_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/inline_style_property_map_test.cc
@@ -29,7 +29,7 @@ TEST(InlineStylePropertyMapTest, PendingSubstitutionValueCrash) {
div->SetInlineStyleProperty(property_id, "var(--dummy)");
const StylePropertyShorthand& longhands = shorthandForProperty(property_id);
for (unsigned i = 0; i < longhands.length(); i++) {
- map.get(document,
+ map.get(document->GetExecutionContext(),
longhands.properties()[i]->GetCSSPropertyName().ToAtomicString(),
ASSERT_NO_EXCEPTION);
}
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_deferred_image.cc b/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_deferred_image.cc
index f37d073af4f..35a58b2dcd2 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_deferred_image.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_deferred_image.cc
@@ -37,7 +37,8 @@ void PaintWorkletDeferredImage::Draw(cc::PaintCanvas* canvas,
}
void PaintWorkletDeferredImage::DrawTile(GraphicsContext& context,
- const FloatRect& src_rect) {
+ const FloatRect& src_rect,
+ RespectImageOrientationEnum) {
DrawInternal(context.Canvas(), FloatRect(), src_rect, context.FillFlags(),
kClampImageToSourceRect, image_);
}
@@ -45,7 +46,8 @@ void PaintWorkletDeferredImage::DrawTile(GraphicsContext& context,
sk_sp<PaintShader> PaintWorkletDeferredImage::CreateShader(
const FloatRect& tile_rect,
const SkMatrix* pattern_matrix,
- const FloatRect& src_rect) {
+ const FloatRect& src_rect,
+ RespectImageOrientationEnum) {
SkRect tile = SkRect::MakeXYWH(tile_rect.X(), tile_rect.Y(),
tile_rect.Width(), tile_rect.Height());
sk_sp<PaintShader> shader = PaintShader::MakeImage(
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_deferred_image.h b/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_deferred_image.h
index 11429a243ba..d82c56208fe 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_deferred_image.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_deferred_image.h
@@ -38,10 +38,13 @@ class CORE_EXPORT PaintWorkletDeferredImage : public GeneratedImage {
RespectImageOrientationEnum,
ImageClampingMode,
ImageDecodingMode) override;
- void DrawTile(GraphicsContext&, const FloatRect&) override;
+ void DrawTile(GraphicsContext&,
+ const FloatRect&,
+ RespectImageOrientationEnum) override;
sk_sp<cc::PaintShader> CreateShader(const FloatRect& tile_rect,
const SkMatrix* pattern_matrix,
- const FloatRect& src_rect) final;
+ const FloatRect& src_rect,
+ RespectImageOrientationEnum) final;
private:
PaintWorkletDeferredImage(scoped_refptr<PaintWorkletInput> input,
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map.cc b/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map.cc
index c50b855c43b..d9259c4f9fd 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map.cc
@@ -46,7 +46,7 @@ class PaintWorkletStylePropertyMapIterationSource final
return true;
}
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(values_);
PairIterable<String, CSSStyleValueVector>::IterationSource::Trace(visitor);
}
@@ -172,7 +172,7 @@ CSSStyleValueVector PaintWorkletStylePropertyMap::getAll(
const ExecutionContext* execution_context,
const String& property_name,
ExceptionState& exception_state) const {
- CSSPropertyID property_id = cssPropertyID(property_name);
+ CSSPropertyID property_id = cssPropertyID(execution_context, property_name);
if (property_id == CSSPropertyID::kInvalid) {
exception_state.ThrowTypeError("Invalid propertyName: " + property_name);
return CSSStyleValueVector();
@@ -209,7 +209,7 @@ PaintWorkletStylePropertyMap::StartIteration(ScriptState* script_state,
result);
}
-void PaintWorkletStylePropertyMap::Trace(blink::Visitor* visitor) {
+void PaintWorkletStylePropertyMap::Trace(Visitor* visitor) {
StylePropertyMapReadOnly::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map.h b/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map.h
index 67349970ad4..f76a0658c50 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map.h
@@ -65,7 +65,7 @@ class CORE_EXPORT PaintWorkletStylePropertyMap
unsigned int size() const override;
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
const CrossThreadData& StyleMapDataForTest() const { return data_; }
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map_test.cc b/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map_test.cc
index 5c84570058a..d8e1fdad55f 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map_test.cc
@@ -115,7 +115,7 @@ TEST_F(PaintWorkletStylePropertyMapTest, UnregisteredCustomProperty) {
Vector<CSSPropertyID> native_properties;
Vector<AtomicString> custom_properties({"--x"});
- GetDocument().documentElement()->SetInnerHTMLFromString(
+ GetDocument().documentElement()->setInnerHTML(
"<div id='target' style='--x:50'></div>");
UpdateAllLifecyclePhasesForTest();
@@ -162,7 +162,7 @@ TEST_F(PaintWorkletStylePropertyMapTest, SupportedCrossThreadData) {
css_test_helpers::RegisterProperty(GetDocument(), "--gar", "<color>",
"rgb(0, 255, 0)", false);
- GetDocument().documentElement()->SetInnerHTMLFromString(
+ GetDocument().documentElement()->setInnerHTML(
"<div id='target' style='--foo:10px; --bar:15; --gar:rgb(255, 0, "
"0)'></div>");
UpdateAllLifecyclePhasesForTest();
@@ -208,7 +208,7 @@ TEST_F(PaintWorkletStylePropertyMapTest, UnsupportedCrossThreadData) {
css_test_helpers::RegisterProperty(GetDocument(), "--loo", "test", "test",
false);
- GetDocument().documentElement()->SetInnerHTMLFromString(
+ GetDocument().documentElement()->setInnerHTML(
"<div id='target' style='--foo:url(https://crbug.com/); "
"--bar:15;'></div>");
UpdateAllLifecyclePhasesForTest();
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/prepopulated_computed_style_property_map.cc b/chromium/third_party/blink/renderer/core/css/cssom/prepopulated_computed_style_property_map.cc
index 0351536b7e4..f8699198e9a 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/prepopulated_computed_style_property_map.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/prepopulated_computed_style_property_map.cc
@@ -121,7 +121,7 @@ String PrepopulatedComputedStylePropertyMap::SerializationForShorthand(
return "";
}
-void PrepopulatedComputedStylePropertyMap::Trace(blink::Visitor* visitor) {
+void PrepopulatedComputedStylePropertyMap::Trace(Visitor* visitor) {
visitor->Trace(native_values_);
visitor->Trace(custom_values_);
StylePropertyMapReadOnlyMainThread::Trace(visitor);
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/prepopulated_computed_style_property_map.h b/chromium/third_party/blink/renderer/core/css/cssom/prepopulated_computed_style_property_map.h
index 88b52b13f2e..6da8bd700df 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/prepopulated_computed_style_property_map.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/prepopulated_computed_style_property_map.h
@@ -39,7 +39,7 @@ class CORE_EXPORT PrepopulatedComputedStylePropertyMap
void UpdateStyle(const Document&, const ComputedStyle&);
unsigned size() const override;
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
protected:
const CSSValue* GetProperty(CSSPropertyID) const override;
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/prepopulated_computed_style_property_map_test.cc b/chromium/third_party/blink/renderer/core/css/cssom/prepopulated_computed_style_property_map_test.cc
index 72cb0bf289f..d69a8b53e21 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/prepopulated_computed_style_property_map_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/prepopulated_computed_style_property_map_test.cc
@@ -19,8 +19,8 @@ class PrepopulatedComputedStylePropertyMapTest : public PageTestBase {
PrepopulatedComputedStylePropertyMapTest() = default;
void SetElementWithStyle(const String& value) {
- GetDocument().body()->SetInnerHTMLFromString("<div id='target' style='" +
- value + "'></div>");
+ GetDocument().body()->setInnerHTML("<div id='target' style='" + value +
+ "'></div>");
UpdateAllLifecyclePhasesForTest();
}
@@ -63,24 +63,27 @@ TEST_F(PrepopulatedComputedStylePropertyMapTest, NativePropertyAccessors) {
DummyExceptionStateForTesting exception_state;
- map->get(&GetDocument(), "color", exception_state);
+ map->get(GetDocument().GetExecutionContext(), "color", exception_state);
EXPECT_FALSE(exception_state.HadException());
- map->has(&GetDocument(), "color", exception_state);
+ map->has(GetDocument().GetExecutionContext(), "color", exception_state);
EXPECT_FALSE(exception_state.HadException());
- map->getAll(&GetDocument(), "color", exception_state);
+ map->getAll(GetDocument().GetExecutionContext(), "color", exception_state);
EXPECT_FALSE(exception_state.HadException());
- map->get(&GetDocument(), "align-contents", exception_state);
+ map->get(GetDocument().GetExecutionContext(), "align-contents",
+ exception_state);
EXPECT_TRUE(exception_state.HadException());
exception_state.ClearException();
- map->has(&GetDocument(), "align-contents", exception_state);
+ map->has(GetDocument().GetExecutionContext(), "align-contents",
+ exception_state);
EXPECT_TRUE(exception_state.HadException());
exception_state.ClearException();
- map->getAll(&GetDocument(), "align-contents", exception_state);
+ map->getAll(GetDocument().GetExecutionContext(), "align-contents",
+ exception_state);
EXPECT_TRUE(exception_state.HadException());
exception_state.ClearException();
}
@@ -99,29 +102,34 @@ TEST_F(PrepopulatedComputedStylePropertyMapTest, CustomPropertyAccessors) {
DummyExceptionStateForTesting exception_state;
- const CSSStyleValue* foo = map->get(&GetDocument(), "--foo", exception_state);
+ const CSSStyleValue* foo =
+ map->get(GetDocument().GetExecutionContext(), "--foo", exception_state);
ASSERT_NE(nullptr, foo);
ASSERT_EQ(CSSStyleValue::kUnparsedType, foo->GetType());
EXPECT_FALSE(exception_state.HadException());
- EXPECT_EQ(true, map->has(&GetDocument(), "--foo", exception_state));
+ EXPECT_EQ(true, map->has(GetDocument().GetExecutionContext(), "--foo",
+ exception_state));
EXPECT_FALSE(exception_state.HadException());
- CSSStyleValueVector fooAll =
- map->getAll(&GetDocument(), "--foo", exception_state);
+ CSSStyleValueVector fooAll = map->getAll(GetDocument().GetExecutionContext(),
+ "--foo", exception_state);
EXPECT_EQ(1U, fooAll.size());
ASSERT_NE(nullptr, fooAll[0]);
ASSERT_EQ(CSSStyleValue::kUnparsedType, fooAll[0]->GetType());
EXPECT_FALSE(exception_state.HadException());
- EXPECT_EQ(nullptr, map->get(&GetDocument(), "--quix", exception_state));
+ EXPECT_EQ(nullptr, map->get(GetDocument().GetExecutionContext(), "--quix",
+ exception_state));
EXPECT_FALSE(exception_state.HadException());
- EXPECT_EQ(false, map->has(&GetDocument(), "--quix", exception_state));
+ EXPECT_EQ(false, map->has(GetDocument().GetExecutionContext(), "--quix",
+ exception_state));
EXPECT_FALSE(exception_state.HadException());
EXPECT_EQ(CSSStyleValueVector(),
- map->getAll(&GetDocument(), "--quix", exception_state));
+ map->getAll(GetDocument().GetExecutionContext(), "--quix",
+ exception_state));
EXPECT_FALSE(exception_state.HadException());
}
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/style_property_map.cc b/chromium/third_party/blink/renderer/core/css/cssom/style_property_map.cc
index 8c174cab389..6f20d0983f4 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/style_property_map.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/style_property_map.cc
@@ -254,7 +254,8 @@ void StylePropertyMap::set(const ExecutionContext* execution_context,
const String& property_name,
const HeapVector<CSSStyleValueOrString>& values,
ExceptionState& exception_state) {
- const CSSPropertyID property_id = cssPropertyID(property_name);
+ const CSSPropertyID property_id =
+ cssPropertyID(execution_context, property_name);
if (property_id == CSSPropertyID::kInvalid) {
exception_state.ThrowTypeError("Invalid propertyName: " + property_name);
return;
@@ -318,7 +319,8 @@ void StylePropertyMap::append(const ExecutionContext* execution_context,
if (values.IsEmpty())
return;
- const CSSPropertyID property_id = cssPropertyID(property_name);
+ const CSSPropertyID property_id =
+ cssPropertyID(execution_context, property_name);
if (property_id == CSSPropertyID::kInvalid) {
exception_state.ThrowTypeError("Invalid propertyName: " + property_name);
@@ -360,9 +362,10 @@ void StylePropertyMap::append(const ExecutionContext* execution_context,
SetProperty(property_id, *current_value);
}
-void StylePropertyMap::remove(const String& property_name,
+void StylePropertyMap::remove(const ExecutionContext* execution_context,
+ const String& property_name,
ExceptionState& exception_state) {
- CSSPropertyID property_id = cssPropertyID(property_name);
+ CSSPropertyID property_id = cssPropertyID(execution_context, property_name);
if (property_id == CSSPropertyID::kInvalid) {
exception_state.ThrowTypeError("Invalid property name: " + property_name);
return;
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/style_property_map.h b/chromium/third_party/blink/renderer/core/css/cssom/style_property_map.h
index 6bbc19bb0f2..6b9e16cb42f 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/style_property_map.h
+++ b/chromium/third_party/blink/renderer/core/css/cssom/style_property_map.h
@@ -27,7 +27,9 @@ class CORE_EXPORT StylePropertyMap : public StylePropertyMapReadOnlyMainThread {
const String& property_name,
const HeapVector<CSSStyleValueOrString>& values,
ExceptionState&);
- void remove(const String& property_name, ExceptionState&);
+ void remove(const ExecutionContext*,
+ const String& property_name,
+ ExceptionState&);
void clear();
protected:
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/style_property_map.idl b/chromium/third_party/blink/renderer/core/css/cssom/style_property_map.idl
index 775ab0b0cb0..f4d358419dc 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/style_property_map.idl
+++ b/chromium/third_party/blink/renderer/core/css/cssom/style_property_map.idl
@@ -10,6 +10,6 @@
// TODO(https://crbug.com/838890): DOMString should be CSSOMString
[RaisesException, CallWith=ExecutionContext] void set(CSSOMString property, (CSSStyleValue or DOMString)... values);
[RaisesException, CallWith=ExecutionContext] void append(CSSOMString property, (CSSStyleValue or DOMString)... values);
- [RaisesException, ImplementedAs=remove] void delete(CSSOMString property);
+ [RaisesException, CallWith=ExecutionContext, ImplementedAs=remove] void delete(CSSOMString property);
void clear();
};
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/style_property_map_read_only_main_thread.cc b/chromium/third_party/blink/renderer/core/css/cssom/style_property_map_read_only_main_thread.cc
index 3499347c498..c5471a9b66b 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/style_property_map_read_only_main_thread.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/style_property_map_read_only_main_thread.cc
@@ -45,7 +45,7 @@ class StylePropertyMapIterationSource final
return true;
}
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(values_);
PairIterable<String, CSSStyleValueVector>::IterationSource::Trace(visitor);
}
@@ -62,7 +62,8 @@ CSSStyleValue* StylePropertyMapReadOnlyMainThread::get(
const ExecutionContext* execution_context,
const String& property_name,
ExceptionState& exception_state) const {
- base::Optional<CSSPropertyName> name = CSSPropertyName::From(property_name);
+ base::Optional<CSSPropertyName> name =
+ CSSPropertyName::From(execution_context, property_name);
if (!name) {
exception_state.ThrowTypeError("Invalid propertyName: " + property_name);
@@ -94,7 +95,8 @@ CSSStyleValueVector StylePropertyMapReadOnlyMainThread::getAll(
const ExecutionContext* execution_context,
const String& property_name,
ExceptionState& exception_state) const {
- base::Optional<CSSPropertyName> name = CSSPropertyName::From(property_name);
+ base::Optional<CSSPropertyName> name =
+ CSSPropertyName::From(execution_context, property_name);
if (!name) {
exception_state.ThrowTypeError("Invalid propertyName: " + property_name);
@@ -145,7 +147,7 @@ CSSStyleValue* StylePropertyMapReadOnlyMainThread::GetShorthandProperty(
const auto serialization = SerializationForShorthand(property);
if (serialization.IsEmpty())
return nullptr;
- return CSSUnsupportedStyleValue::Create(
+ return MakeGarbageCollected<CSSUnsupportedStyleValue>(
CSSPropertyName(property.PropertyID()), serialization);
}
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/style_value_factory.cc b/chromium/third_party/blink/renderer/core/css/cssom/style_value_factory.cc
index f9c43847b3b..ed6ac6fd33d 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/style_value_factory.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/style_value_factory.cc
@@ -56,7 +56,7 @@ CSSStyleValue* CreateStyleValue(const CSSValue& value) {
if (auto* primitive_value = DynamicTo<CSSPrimitiveValue>(value))
return CSSNumericValue::FromCSSValue(*primitive_value);
if (auto* color_value = DynamicTo<cssvalue::CSSColorValue>(value))
- return CSSUnsupportedColorValue::FromCSSValue(*color_value);
+ return MakeGarbageCollected<CSSUnsupportedColorValue>(*color_value);
if (auto* image_value = DynamicTo<CSSImageValue>(value))
return MakeGarbageCollected<CSSURLImageValue>(*image_value->Clone());
return nullptr;
@@ -106,8 +106,8 @@ CSSStyleValue* CreateStyleValueWithPropertyInternal(CSSPropertyID property_id,
if (identifier_value &&
identifier_value->GetValueID() == CSSValueID::kCurrentcolor)
return CSSKeywordValue::Create("currentcolor");
- return CSSUnsupportedStyleValue::Create(CSSPropertyName(property_id),
- value);
+ return MakeGarbageCollected<CSSUnsupportedStyleValue>(
+ CSSPropertyName(property_id), value);
}
case CSSPropertyID::kContain: {
if (value.IsIdentifierValue())
@@ -228,8 +228,8 @@ CSSStyleValue* CreateStyleValueWithProperty(CSSPropertyID property_id,
if (!CSSOMTypes::IsPropertySupported(property_id)) {
DCHECK_NE(property_id, CSSPropertyID::kVariable);
- return CSSUnsupportedStyleValue::Create(CSSPropertyName(property_id),
- value);
+ return MakeGarbageCollected<CSSUnsupportedStyleValue>(
+ CSSPropertyName(property_id), value);
}
CSSStyleValue* style_value =
@@ -242,7 +242,8 @@ CSSStyleValue* CreateStyleValueWithProperty(CSSPropertyID property_id,
CSSStyleValueVector UnsupportedCSSValue(const CSSPropertyName& name,
const CSSValue& value) {
CSSStyleValueVector style_value_vector;
- style_value_vector.push_back(CSSUnsupportedStyleValue::Create(name, value));
+ style_value_vector.push_back(
+ MakeGarbageCollected<CSSUnsupportedStyleValue>(name, value));
return style_value_vector;
}
@@ -278,7 +279,7 @@ CSSStyleValueVector StyleValueFactory::FromString(
// Shorthands are not yet supported.
CSSStyleValueVector result;
- result.push_back(CSSUnsupportedStyleValue::Create(
+ result.push_back(MakeGarbageCollected<CSSUnsupportedStyleValue>(
CSSPropertyName(property_id), css_text));
return result;
}
@@ -304,7 +305,7 @@ CSSStyleValue* StyleValueFactory::CssValueToStyleValue(
CSSStyleValue* style_value =
CreateStyleValueWithProperty(name.Id(), css_value);
if (!style_value)
- return CSSUnsupportedStyleValue::Create(name, css_value);
+ return MakeGarbageCollected<CSSUnsupportedStyleValue>(name, css_value);
return style_value;
}
@@ -385,10 +386,12 @@ CSSStyleValueVector StyleValueFactory::CssValueToStyleValueVector(
const CSSValue& css_value) {
CSSStyleValueVector style_value_vector;
- if (CSSStyleValue* value = CreateStyleValueWithoutProperty(css_value))
+ if (CSSStyleValue* value = CreateStyleValueWithoutProperty(css_value)) {
style_value_vector.push_back(value);
- else
- style_value_vector.push_back(CSSUnsupportedStyleValue::Create(css_value));
+ } else {
+ style_value_vector.push_back(
+ MakeGarbageCollected<CSSUnsupportedStyleValue>(css_value.CssText()));
+ }
return style_value_vector;
}
diff --git a/chromium/third_party/blink/renderer/core/css/document_style_sheet_collection.h b/chromium/third_party/blink/renderer/core/css/document_style_sheet_collection.h
index c2c0c993cf7..881dfbb9c49 100644
--- a/chromium/third_party/blink/renderer/core/css/document_style_sheet_collection.h
+++ b/chromium/third_party/blink/renderer/core/css/document_style_sheet_collection.h
@@ -50,7 +50,7 @@ class DocumentStyleSheetCollection final
DocumentStyleSheetCollector&);
void CollectViewportRules(ViewportStyleResolver&);
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
TreeScopeStyleSheetCollection::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/document_style_sheet_collector.cc b/chromium/third_party/blink/renderer/core/css/document_style_sheet_collector.cc
index 089bc33e2ef..3028abd3348 100644
--- a/chromium/third_party/blink/renderer/core/css/document_style_sheet_collector.cc
+++ b/chromium/third_party/blink/renderer/core/css/document_style_sheet_collector.cc
@@ -43,8 +43,6 @@ DocumentStyleSheetCollector::DocumentStyleSheetCollector(
style_sheets_for_style_sheet_list_(sheets_for_list),
visited_documents_(visited_documents) {}
-DocumentStyleSheetCollector::~DocumentStyleSheetCollector() = default;
-
void DocumentStyleSheetCollector::AppendActiveStyleSheet(
const ActiveStyleSheet& sheet) {
DCHECK(collection_);
diff --git a/chromium/third_party/blink/renderer/core/css/document_style_sheet_collector.h b/chromium/third_party/blink/renderer/core/css/document_style_sheet_collector.h
index 7bd33f73c98..bb6f4a928f4 100644
--- a/chromium/third_party/blink/renderer/core/css/document_style_sheet_collector.h
+++ b/chromium/third_party/blink/renderer/core/css/document_style_sheet_collector.h
@@ -50,7 +50,6 @@ class DocumentStyleSheetCollector {
DocumentStyleSheetCollector(StyleSheetCollection*,
HeapVector<Member<StyleSheet>>*,
HeapHashSet<Member<Document>>*);
- ~DocumentStyleSheetCollector();
void AppendActiveStyleSheet(const ActiveStyleSheet&);
void AppendSheetForList(StyleSheet*);
@@ -61,7 +60,7 @@ class DocumentStyleSheetCollector {
void WillVisit(Document* document) { visited_documents_->insert(document); }
private:
- Member<StyleSheetCollection> collection_;
+ StyleSheetCollection* collection_;
HeapVector<Member<StyleSheet>>* style_sheets_for_style_sheet_list_;
HeapHashSet<Member<Document>>* visited_documents_;
};
diff --git a/chromium/third_party/blink/renderer/core/css/dom_window_css.cc b/chromium/third_party/blink/renderer/core/css/dom_window_css.cc
index 1f83329c0b4..d3133caa4b7 100644
--- a/chromium/third_party/blink/renderer/core/css/dom_window_css.cc
+++ b/chromium/third_party/blink/renderer/core/css/dom_window_css.cc
@@ -43,7 +43,8 @@ namespace blink {
bool DOMWindowCSS::supports(const ExecutionContext* execution_context,
const String& property,
const String& value) {
- CSSPropertyID unresolved_property = unresolvedCSSPropertyID(property);
+ CSSPropertyID unresolved_property =
+ unresolvedCSSPropertyID(execution_context, property);
if (unresolved_property == CSSPropertyID::kInvalid)
return false;
if (unresolved_property == CSSPropertyID::kVariable) {
@@ -59,7 +60,7 @@ bool DOMWindowCSS::supports(const ExecutionContext* execution_context,
#if DCHECK_IS_ON()
DCHECK(CSSProperty::Get(resolveCSSPropertyID(unresolved_property))
- .IsWebExposed());
+ .IsWebExposed(execution_context));
#endif
// This will return false when !important is present
diff --git a/chromium/third_party/blink/renderer/core/css/dom_window_css.h b/chromium/third_party/blink/renderer/core/css/dom_window_css.h
index dd39a14ce5e..5e97263b191 100644
--- a/chromium/third_party/blink/renderer/core/css/dom_window_css.h
+++ b/chromium/third_party/blink/renderer/core/css/dom_window_css.h
@@ -30,6 +30,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_DOM_WINDOW_CSS_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_DOM_WINDOW_CSS_H_
+#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
@@ -38,7 +39,7 @@ namespace blink {
class ExecutionContext;
-class DOMWindowCSS : public ScriptWrappable {
+class CORE_EXPORT DOMWindowCSS : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
diff --git a/chromium/third_party/blink/renderer/core/css/drag_update_test.cc b/chromium/third_party/blink/renderer/core/css/drag_update_test.cc
index 5f884f83607..99bee956462 100644
--- a/chromium/third_party/blink/renderer/core/css/drag_update_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/drag_update_test.cc
@@ -18,7 +18,7 @@ TEST(DragUpdateTest, AffectedByDragUpdate) {
auto dummy_page_holder = std::make_unique<DummyPageHolder>(IntSize(800, 600));
Document& document = dummy_page_holder->GetDocument();
- document.documentElement()->SetInnerHTMLFromString(R"HTML(
+ document.documentElement()->setInnerHTML(R"HTML(
<style>div {width:100px;height:100px} div:-webkit-drag {
background-color: green }</style>
<div id='div'>
@@ -29,13 +29,11 @@ TEST(DragUpdateTest, AffectedByDragUpdate) {
</div>
)HTML");
- document.View()->UpdateAllLifecyclePhases(
- DocumentLifecycle::LifecycleUpdateReason::kTest);
+ document.View()->UpdateAllLifecyclePhases(DocumentUpdateReason::kTest);
unsigned start_count = document.GetStyleEngine().StyleForElementCount();
document.getElementById("div")->SetDragged(true);
- document.View()->UpdateAllLifecyclePhases(
- DocumentLifecycle::LifecycleUpdateReason::kTest);
+ document.View()->UpdateAllLifecyclePhases(DocumentUpdateReason::kTest);
unsigned element_count =
document.GetStyleEngine().StyleForElementCount() - start_count;
@@ -49,7 +47,7 @@ TEST(DragUpdateTest, ChildAffectedByDragUpdate) {
auto dummy_page_holder = std::make_unique<DummyPageHolder>(IntSize(800, 600));
Document& document = dummy_page_holder->GetDocument();
- document.documentElement()->SetInnerHTMLFromString(R"HTML(
+ document.documentElement()->setInnerHTML(R"HTML(
<style>div {width:100px;height:100px} div:-webkit-drag .drag {
background-color: green }</style>
<div id='div'>
@@ -60,11 +58,11 @@ TEST(DragUpdateTest, ChildAffectedByDragUpdate) {
</div>
)HTML");
- document.UpdateStyleAndLayout();
+ document.UpdateStyleAndLayout(DocumentUpdateReason::kTest);
unsigned start_count = document.GetStyleEngine().StyleForElementCount();
document.getElementById("div")->SetDragged(true);
- document.UpdateStyleAndLayout();
+ document.UpdateStyleAndLayout(DocumentUpdateReason::kTest);
unsigned element_count =
document.GetStyleEngine().StyleForElementCount() - start_count;
@@ -78,7 +76,7 @@ TEST(DragUpdateTest, SiblingAffectedByDragUpdate) {
auto dummy_page_holder = std::make_unique<DummyPageHolder>(IntSize(800, 600));
Document& document = dummy_page_holder->GetDocument();
- document.documentElement()->SetInnerHTMLFromString(R"HTML(
+ document.documentElement()->setInnerHTML(R"HTML(
<style>div {width:100px;height:100px} div:-webkit-drag + .drag {
background-color: green }</style>
<div id='div'>
@@ -90,11 +88,11 @@ TEST(DragUpdateTest, SiblingAffectedByDragUpdate) {
<span class='drag'></span>
)HTML");
- document.UpdateStyleAndLayout();
+ document.UpdateStyleAndLayout(DocumentUpdateReason::kTest);
unsigned start_count = document.GetStyleEngine().StyleForElementCount();
document.getElementById("div")->SetDragged(true);
- document.UpdateStyleAndLayout();
+ document.UpdateStyleAndLayout(DocumentUpdateReason::kTest);
unsigned element_count =
document.GetStyleEngine().StyleForElementCount() - start_count;
diff --git a/chromium/third_party/blink/renderer/core/css/element_rule_collector.cc b/chromium/third_party/blink/renderer/core/css/element_rule_collector.cc
index e76a9e60d33..84e0377e7d4 100644
--- a/chromium/third_party/blink/renderer/core/css/element_rule_collector.cc
+++ b/chromium/third_party/blink/renderer/core/css/element_rule_collector.cc
@@ -48,9 +48,22 @@
namespace blink {
+namespace {
+
+unsigned AdjustLinkMatchType(EInsideLink inside_link,
+ unsigned link_match_type) {
+ if (inside_link == EInsideLink::kNotInsideLink)
+ return CSSSelector::kMatchLink;
+ return link_match_type;
+}
+
+} // namespace
+
ElementRuleCollector::ElementRuleCollector(const ElementResolveContext& context,
const SelectorFilter& filter,
- ComputedStyle* style)
+ MatchResult& result,
+ ComputedStyle* style,
+ EInsideLink inside_link)
: context_(context),
selector_filter_(filter),
style_(style),
@@ -60,7 +73,9 @@ ElementRuleCollector::ElementRuleCollector(const ElementResolveContext& context,
selector_filter_.ParentStackIsConsistent(context.ParentNode())),
same_origin_only_(false),
matching_ua_rules_(false),
- include_empty_rules_(false) {}
+ include_empty_rules_(false),
+ inside_link_(inside_link),
+ result_(result) {}
ElementRuleCollector::~ElementRuleCollector() = default;
@@ -99,7 +114,9 @@ void ElementRuleCollector::AddElementStyleProperties(
bool is_cacheable) {
if (!property_set)
return;
- result_.AddMatchedProperties(property_set);
+ auto link_match_type = static_cast<unsigned>(CSSSelector::kMatchAll);
+ result_.AddMatchedProperties(
+ property_set, AdjustLinkMatchType(inside_link_, link_match_type));
if (!is_cacheable)
result_.SetIsCacheable(false);
}
@@ -326,7 +343,8 @@ void ElementRuleCollector::SortAndTransferMatchedRules() {
for (unsigned i = 0; i < matched_rules_.size(); i++) {
const RuleData* rule_data = matched_rules_[i].GetRuleData();
result_.AddMatchedProperties(
- &rule_data->Rule()->Properties(), rule_data->LinkMatchType(),
+ &rule_data->Rule()->Properties(),
+ AdjustLinkMatchType(inside_link_, rule_data->LinkMatchType()),
rule_data->GetValidPropertyFilter(matching_ua_rules_));
}
}
diff --git a/chromium/third_party/blink/renderer/core/css/element_rule_collector.h b/chromium/third_party/blink/renderer/core/css/element_rule_collector.h
index 31444ad2754..a98fc111be3 100644
--- a/chromium/third_party/blink/renderer/core/css/element_rule_collector.h
+++ b/chromium/third_party/blink/renderer/core/css/element_rule_collector.h
@@ -31,6 +31,7 @@
#include "third_party/blink/renderer/core/css/resolver/match_request.h"
#include "third_party/blink/renderer/core/css/resolver/match_result.h"
#include "third_party/blink/renderer/core/css/selector_checker.h"
+#include "third_party/blink/renderer/core/style/computed_style_base_constants.h"
#include "third_party/blink/renderer/platform/wtf/ref_counted.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
@@ -75,7 +76,7 @@ class MatchedRule {
return GetRuleData()->Specificity() + specificity_;
}
const CSSStyleSheet* ParentStyleSheet() const { return parent_style_sheet_; }
- void Trace(blink::Visitor* visitor) {
+ void Trace(Visitor* visitor) {
visitor->Trace(parent_style_sheet_);
visitor->Trace(rule_data_);
}
@@ -109,7 +110,9 @@ class ElementRuleCollector {
public:
ElementRuleCollector(const ElementResolveContext&,
const SelectorFilter&,
- ComputedStyle* = nullptr);
+ MatchResult&,
+ ComputedStyle*,
+ EInsideLink);
~ElementRuleCollector();
void SetMode(SelectorChecker::Mode mode) { mode_ = mode; }
@@ -188,13 +191,14 @@ class ElementRuleCollector {
bool same_origin_only_;
bool matching_ua_rules_;
bool include_empty_rules_;
+ EInsideLink inside_link_;
HeapVector<MatchedRule, 32> matched_rules_;
// Output.
Member<RuleIndexList> css_rule_list_;
Member<StyleRuleList> style_rule_list_;
- MatchResult result_;
+ MatchResult& result_;
DISALLOW_COPY_AND_ASSIGN(ElementRuleCollector);
};
diff --git a/chromium/third_party/blink/renderer/core/css/font_face.cc b/chromium/third_party/blink/renderer/core/css/font_face.cc
index 978de58faad..1a11168bd2f 100644
--- a/chromium/third_party/blink/renderer/core/css/font_face.cc
+++ b/chromium/third_party/blink/renderer/core/css/font_face.cc
@@ -32,6 +32,7 @@
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/bindings/core/v8/string_or_array_buffer_or_array_buffer_view.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_font_face_descriptors.h"
#include "third_party/blink/renderer/core/css/binary_data_font_face_source.h"
#include "third_party/blink/renderer/core/css/css_font_face.h"
#include "third_party/blink/renderer/core/css/css_font_face_src_value.h"
@@ -42,7 +43,6 @@
#include "third_party/blink/renderer/core/css/css_property_value_set.h"
#include "third_party/blink/renderer/core/css/css_unicode_range_value.h"
#include "third_party/blink/renderer/core/css/css_value_list.h"
-#include "third_party/blink/renderer/core/css/font_face_descriptors.h"
#include "third_party/blink/renderer/core/css/local_font_face_source.h"
#include "third_party/blink/renderer/core/css/offscreen_font_selector.h"
#include "third_party/blink/renderer/core/css/parser/at_rule_descriptor_parser.h"
@@ -54,6 +54,7 @@
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
+#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
@@ -76,9 +77,9 @@ const CSSValue* ParseCSSValue(const ExecutionContext* context,
const String& value,
AtRuleDescriptorID descriptor_id) {
CSSParserContext* parser_context =
- IsA<Document>(context)
- ? MakeGarbageCollected<CSSParserContext>(*To<Document>(context))
- : MakeGarbageCollected<CSSParserContext>(*context);
+ context->IsDocument() ? MakeGarbageCollected<CSSParserContext>(
+ *To<LocalDOMWindow>(context)->document())
+ : MakeGarbageCollected<CSSParserContext>(*context);
return AtRuleDescriptorParser::ParseFontFaceDescriptor(descriptor_id, value,
*parser_context);
}
@@ -171,7 +172,8 @@ FontFace* FontFace::Create(Document* document,
if (!src || !src->IsValueList())
return nullptr;
- FontFace* font_face = MakeGarbageCollected<FontFace>(document);
+ FontFace* font_face =
+ MakeGarbageCollected<FontFace>(document->GetExecutionContext());
if (font_face->SetFamilyValue(*family) &&
font_face->SetPropertyFromStyle(properties,
@@ -190,19 +192,19 @@ FontFace* FontFace::Create(Document* document,
AtRuleDescriptorID::FontDisplay) &&
font_face->GetFontSelectionCapabilities().IsValid() &&
!font_face->family().IsEmpty()) {
- font_face->InitCSSFontFace(document, *src);
+ font_face->InitCSSFontFace(document->GetExecutionContext(), *src);
return font_face;
}
return nullptr;
}
FontFace::FontFace(ExecutionContext* context)
- : ContextClient(context), status_(kUnloaded) {}
+ : ExecutionContextClient(context), status_(kUnloaded) {}
FontFace::FontFace(ExecutionContext* context,
const AtomicString& family,
const FontFaceDescriptors* descriptors)
- : ContextClient(context), family_(family), status_(kUnloaded) {
+ : ExecutionContextClient(context), family_(family), status_(kUnloaded) {
SetPropertyFromString(context, descriptors->style(),
AtRuleDescriptorID::FontStyle);
SetPropertyFromString(context, descriptors->weight(),
@@ -380,9 +382,6 @@ bool FontFace::SetFamilyValue(const CSSValue& value) {
case CSSValueID::kMonospace:
family = font_family_names::kWebkitMonospace;
break;
- case CSSValueID::kWebkitPictograph:
- family = font_family_names::kWebkitPictograph;
- break;
default:
return false;
}
@@ -463,7 +462,7 @@ void FontFace::SetError(DOMException* error) {
ScriptPromise FontFace::FontStatusPromise(ScriptState* script_state) {
if (!loaded_property_) {
loaded_property_ = MakeGarbageCollected<LoadedProperty>(
- ExecutionContext::From(script_state), this, LoadedProperty::kLoaded);
+ ExecutionContext::From(script_state));
if (status_ == kLoaded)
loaded_property_->Resolve(this);
else if (status_ == kError)
@@ -475,6 +474,7 @@ ScriptPromise FontFace::FontStatusPromise(ScriptState* script_state) {
ScriptPromise FontFace::load(ScriptState* script_state) {
if (status_ == kUnloaded)
css_font_face_->Load();
+ DidBeginImperativeLoad();
return FontStatusPromise(script_state);
}
@@ -556,8 +556,17 @@ FontSelectionCapabilities FontFace::GetFontSelectionCapabilities() const {
return normal_capabilities;
if (!stretch_from->IsPercentage() || !stretch_to->IsPercentage())
return normal_capabilities;
- capabilities.width = {FontSelectionValue(stretch_from->GetFloatValue()),
- FontSelectionValue(stretch_to->GetFloatValue())};
+ // https://drafts.csswg.org/css-fonts/#font-prop-desc
+ // "User agents must swap the computed value of the startpoint and
+ // endpoint of the range in order to forbid decreasing ranges."
+ if (stretch_from->GetFloatValue() < stretch_to->GetFloatValue()) {
+ capabilities.width = {FontSelectionValue(stretch_from->GetFloatValue()),
+ FontSelectionValue(stretch_to->GetFloatValue())};
+ } else {
+ capabilities.width = {
+ FontSelectionValue(stretch_to->GetFloatValue()),
+ FontSelectionValue(stretch_from->GetFloatValue())};
+ }
} else if (auto* stretch_primitive_value =
DynamicTo<CSSPrimitiveValue>(stretch_.Get())) {
float stretch_value = stretch_primitive_value->GetFloatValue();
@@ -610,9 +619,18 @@ FontSelectionCapabilities FontFace::GetFontSelectionCapabilities() const {
To<CSSPrimitiveValue>(range_value->GetObliqueValues()->Item(0));
const auto& range_end =
To<CSSPrimitiveValue>(range_value->GetObliqueValues()->Item(1));
- capabilities.slope = {
- FontSelectionValue(range_start.GetFloatValue()),
- FontSelectionValue(range_end.GetFloatValue())};
+ // https://drafts.csswg.org/css-fonts/#font-prop-desc
+ // "User agents must swap the computed value of the startpoint and
+ // endpoint of the range in order to forbid decreasing ranges."
+ if (range_start.GetFloatValue() < range_end.GetFloatValue()) {
+ capabilities.slope = {
+ FontSelectionValue(range_start.GetFloatValue()),
+ FontSelectionValue(range_end.GetFloatValue())};
+ } else {
+ capabilities.slope = {
+ FontSelectionValue(range_end.GetFloatValue()),
+ FontSelectionValue(range_start.GetFloatValue())};
+ }
}
}
}
@@ -655,8 +673,17 @@ FontSelectionCapabilities FontFace::GetFontSelectionCapabilities() const {
if (!weight_from->IsNumber() || !weight_to->IsNumber() ||
weight_from->GetFloatValue() < 1 || weight_to->GetFloatValue() > 1000)
return normal_capabilities;
- capabilities.weight = {FontSelectionValue(weight_from->GetFloatValue()),
- FontSelectionValue(weight_to->GetFloatValue())};
+ // https://drafts.csswg.org/css-fonts/#font-prop-desc
+ // "User agents must swap the computed value of the startpoint and
+ // endpoint of the range in order to forbid decreasing ranges."
+ if (weight_from->GetFloatValue() < weight_to->GetFloatValue()) {
+ capabilities.weight = {FontSelectionValue(weight_from->GetFloatValue()),
+ FontSelectionValue(weight_to->GetFloatValue())};
+ } else {
+ capabilities.weight = {
+ FontSelectionValue(weight_to->GetFloatValue()),
+ FontSelectionValue(weight_from->GetFloatValue())};
+ }
} else if (auto* weight_primitive_value =
DynamicTo<CSSPrimitiveValue>(weight_.Get())) {
float weight_value = weight_primitive_value->GetFloatValue();
@@ -683,8 +710,9 @@ bool ContextAllowsDownload(ExecutionContext* context) {
if (!context) {
return false;
}
- if (const Document* document = DynamicTo<Document>(context)) {
- const Settings* settings = document->GetSettings();
+ if (const auto* window = DynamicTo<LocalDOMWindow>(context)) {
+ const Settings* settings =
+ window->GetFrame() ? window->GetFrame()->GetSettings() : nullptr;
return settings && settings->GetDownloadableBinaryFontsEnabled();
}
// TODO(fserb): ideally, we would like to have the settings value available
@@ -708,8 +736,8 @@ void FontFace::InitCSSFontFace(ExecutionContext* context, const CSSValue& src) {
const CSSFontFaceSrcValue& item = To<CSSFontFaceSrcValue>(src_list.Item(i));
FontSelector* font_selector = nullptr;
- if (auto* document = DynamicTo<Document>(context)) {
- font_selector = document->GetStyleEngine().GetFontSelector();
+ if (auto* window = DynamicTo<LocalDOMWindow>(context)) {
+ font_selector = window->document()->GetStyleEngine().GetFontSelector();
} else if (auto* scope = DynamicTo<WorkerGlobalScope>(context)) {
font_selector = scope->GetFontSelector();
} else {
@@ -756,7 +784,7 @@ void FontFace::InitCSSFontFace(const unsigned char* data, size_t size) {
css_font_face_->AddSource(source);
}
-void FontFace::Trace(blink::Visitor* visitor) {
+void FontFace::Trace(Visitor* visitor) {
visitor->Trace(style_);
visitor->Trace(weight_);
visitor->Trace(stretch_);
@@ -769,7 +797,7 @@ void FontFace::Trace(blink::Visitor* visitor) {
visitor->Trace(css_font_face_);
visitor->Trace(callbacks_);
ScriptWrappable::Trace(visitor);
- ContextClient::Trace(visitor);
+ ExecutionContextClient::Trace(visitor);
}
bool FontFace::HadBlankText() const {
@@ -784,4 +812,9 @@ FontDisplay FontFace::GetFontDisplay() const {
return CSSValueToFontDisplay(display_.Get());
}
+void FontFace::DidBeginImperativeLoad() {
+ if (GetDocument())
+ GetDocument()->GetFontPreloadManager().ImperativeFontLoadingStarted(this);
+}
+
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/font_face.h b/chromium/third_party/blink/renderer/core/css/font_face.h
index b6ac8235889..b7eb9d0725e 100644
--- a/chromium/third_party/blink/renderer/core/css/font_face.h
+++ b/chromium/third_party/blink/renderer/core/css/font_face.h
@@ -39,7 +39,7 @@
#include "third_party/blink/renderer/core/css/font_display.h"
#include "third_party/blink/renderer/core/css/parser/at_rule_descriptors.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
-#include "third_party/blink/renderer/core/execution_context/context_lifecycle_observer.h"
+#include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/fonts/font_selection_types.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
@@ -59,7 +59,7 @@ class StyleRuleFontFace;
class CORE_EXPORT FontFace : public ScriptWrappable,
public ActiveScriptWrappable<FontFace>,
- public ContextClient {
+ public ExecutionContextClient {
DEFINE_WRAPPERTYPEINFO();
USING_GARBAGE_COLLECTED_MIXIN(FontFace);
@@ -115,7 +115,7 @@ class CORE_EXPORT FontFace : public ScriptWrappable,
size_t ApproximateBlankCharacterCount() const;
FontDisplay GetFontDisplay() const;
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
bool HadBlankText() const;
@@ -124,11 +124,13 @@ class CORE_EXPORT FontFace : public ScriptWrappable,
virtual ~LoadFontCallback() = default;
virtual void NotifyLoaded(FontFace*) = 0;
virtual void NotifyError(FontFace*) = 0;
- void Trace(blink::Visitor* visitor) override {}
+ void Trace(Visitor* visitor) override {}
};
void LoadWithCallback(LoadFontCallback*);
void AddCallback(LoadFontCallback*);
+ void DidBeginImperativeLoad();
+
// ScriptWrappable:
bool HasPendingActivity() const final;
@@ -159,7 +161,6 @@ class CORE_EXPORT FontFace : public ScriptWrappable,
void RunCallbacks();
using LoadedProperty = ScriptPromiseProperty<Member<FontFace>,
- Member<FontFace>,
Member<DOMException>>;
AtomicString family_;
diff --git a/chromium/third_party/blink/renderer/core/css/font_face.idl b/chromium/third_party/blink/renderer/core/css/font_face.idl
index 3487e4d2386..90baf8a8b66 100644
--- a/chromium/third_party/blink/renderer/core/css/font_face.idl
+++ b/chromium/third_party/blink/renderer/core/css/font_face.idl
@@ -39,12 +39,10 @@ enum FontFaceLoadStatus {
[
ActiveScriptWrappable,
- Exposed=(Window,Worker),
- // FIXME: This should be (DOMString or BinaryData), where BinaryData is typedef of (ArrayBuffer or ArrayBufferView)
- Constructor(DOMString family, (DOMString or ArrayBuffer or ArrayBufferView) source, optional FontFaceDescriptors descriptors),
- ConstructorCallWith=ExecutionContext,
- MeasureAs=FontFaceConstructor
+ Exposed=(Window,Worker)
] interface FontFace {
+ // FIXME: This should be (DOMString or BinaryData), where BinaryData is typedef of (ArrayBuffer or ArrayBufferView)
+ [CallWith=ExecutionContext, MeasureAs=FontFaceConstructor] constructor(DOMString family, (DOMString or ArrayBuffer or ArrayBufferView) source, optional FontFaceDescriptors descriptors = {});
[RaisesException=Setter, SetterCallWith=ExecutionContext] attribute DOMString family;
[RaisesException=Setter, SetterCallWith=ExecutionContext] attribute DOMString style;
[RaisesException=Setter, SetterCallWith=ExecutionContext] attribute DOMString weight;
diff --git a/chromium/third_party/blink/renderer/core/css/font_face_cache.cc b/chromium/third_party/blink/renderer/core/css/font_face_cache.cc
index 7d1e21737d3..2f978936161 100644
--- a/chromium/third_party/blink/renderer/core/css/font_face_cache.cc
+++ b/chromium/third_party/blink/renderer/core/css/font_face_cache.cc
@@ -214,7 +214,7 @@ size_t FontFaceCache::GetNumSegmentedFacesForTesting() {
return count;
}
-void FontFaceCache::Trace(blink::Visitor* visitor) {
+void FontFaceCache::Trace(Visitor* visitor) {
visitor->Trace(segmented_faces_);
visitor->Trace(font_selection_query_cache_);
visitor->Trace(style_rule_to_font_face_);
diff --git a/chromium/third_party/blink/renderer/core/css/font_face_cache.h b/chromium/third_party/blink/renderer/core/css/font_face_cache.h
index cfec05eee93..3253979d209 100644
--- a/chromium/third_party/blink/renderer/core/css/font_face_cache.h
+++ b/chromium/third_party/blink/renderer/core/css/font_face_cache.h
@@ -69,7 +69,7 @@ class CORE_EXPORT FontFaceCache final {
unsigned Version() const { return version_; }
void IncrementVersion();
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
// Two lookup accelerating cashes are needed: For the font selection
diff --git a/chromium/third_party/blink/renderer/core/css/font_face_cache_test.cc b/chromium/third_party/blink/renderer/core/css/font_face_cache_test.cc
index 8937f200d5a..1c05906fd6a 100644
--- a/chromium/third_party/blink/renderer/core/css/font_face_cache_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/font_face_cache_test.cc
@@ -43,7 +43,7 @@ class FontFaceCacheTest : public PageTestBase {
FontFaceCache cache_;
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
protected:
const AtomicString kFontNameForTesting{"Arial"};
@@ -64,7 +64,7 @@ void FontFaceCacheTest::AppendTestFaceForCapabilities(const CSSValue& stretch,
CSSFontFamilyValue* family_name =
CSSFontFamilyValue::Create(kFontNameForTesting);
CSSFontFaceSrcValue* src = CSSFontFaceSrcValue::CreateLocal(
- kFontNameForTesting, kDoNotCheckContentSecurityPolicy,
+ kFontNameForTesting, network::mojom::CSPDisposition::DO_NOT_CHECK,
OriginClean::kTrue);
CSSValueList* src_value_list = CSSValueList::CreateCommaSeparated();
src_value_list->Append(*src);
@@ -494,7 +494,7 @@ TEST_F(FontFaceCacheTest, ObliqueRangeMatching) {
FontSelectionRange({FontSelectionValue(30), FontSelectionValue(35)}));
}
-void FontFaceCacheTest::Trace(blink::Visitor* visitor) {
+void FontFaceCacheTest::Trace(Visitor* visitor) {
visitor->Trace(cache_);
}
diff --git a/chromium/third_party/blink/renderer/core/css/font_face_set.cc b/chromium/third_party/blink/renderer/core/css/font_face_set.cc
index 7c1d4d832ed..c137ca35c91 100644
--- a/chromium/third_party/blink/renderer/core/css/font_face_set.cc
+++ b/chromium/third_party/blink/renderer/core/css/font_face_set.cc
@@ -106,13 +106,13 @@ bool FontFaceSet::hasForBinding(ScriptState*,
IsCSSConnectedFontFace(font_face);
}
-void FontFaceSet::Trace(blink::Visitor* visitor) {
+void FontFaceSet::Trace(Visitor* visitor) {
visitor->Trace(non_css_connected_faces_);
visitor->Trace(loading_fonts_);
visitor->Trace(loaded_fonts_);
visitor->Trace(failed_fonts_);
visitor->Trace(ready_);
- ContextClient::Trace(visitor);
+ ExecutionContextClient::Trace(visitor);
EventTargetWithInlineData::Trace(visitor);
FontFace::LoadFontCallback::Trace(visitor);
}
@@ -152,8 +152,10 @@ void FontFaceSet::LoadFontPromiseResolver::LoadFonts() {
return;
}
- for (wtf_size_t i = 0; i < font_faces_.size(); i++)
+ for (wtf_size_t i = 0; i < font_faces_.size(); i++) {
font_faces_[i]->LoadWithCallback(this);
+ font_faces_[i]->DidBeginImperativeLoad();
+ }
}
ScriptPromise FontFaceSet::load(ScriptState* script_state,
@@ -273,7 +275,7 @@ void FontFaceSet::LoadFontPromiseResolver::NotifyError(FontFace* font_face) {
}
}
-void FontFaceSet::LoadFontPromiseResolver::Trace(blink::Visitor* visitor) {
+void FontFaceSet::LoadFontPromiseResolver::Trace(Visitor* visitor) {
visitor->Trace(font_faces_);
visitor->Trace(resolver_);
LoadFontCallback::Trace(visitor);
diff --git a/chromium/third_party/blink/renderer/core/css/font_face_set.h b/chromium/third_party/blink/renderer/core/css/font_face_set.h
index f71d240add9..17a41e25578 100644
--- a/chromium/third_party/blink/renderer/core/css/font_face_set.h
+++ b/chromium/third_party/blink/renderer/core/css/font_face_set.h
@@ -14,7 +14,7 @@
#include "third_party/blink/renderer/core/css/font_face.h"
#include "third_party/blink/renderer/core/dom/events/event_listener.h"
#include "third_party/blink/renderer/core/dom/events/event_target.h"
-#include "third_party/blink/renderer/core/execution_context/context_lifecycle_observer.h"
+#include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/fonts/font_selector.h"
@@ -31,17 +31,15 @@ class FontFaceCache;
using FontFaceSetIterable = SetlikeIterable<Member<FontFace>>;
class CORE_EXPORT FontFaceSet : public EventTargetWithInlineData,
- public ContextClient,
+ public ExecutionContextClient,
public FontFaceSetIterable,
public FontFace::LoadFontCallback {
DEFINE_WRAPPERTYPEINFO();
public:
FontFaceSet(ExecutionContext& context)
- : ContextClient(&context),
- ready_(MakeGarbageCollected<ReadyProperty>(GetExecutionContext(),
- this,
- ReadyProperty::kReady)) {}
+ : ExecutionContextClient(&context),
+ ready_(MakeGarbageCollected<ReadyProperty>(GetExecutionContext())) {}
~FontFaceSet() override = default;
DEFINE_ATTRIBUTE_EVENT_LISTENER(loading, kLoading)
@@ -53,7 +51,7 @@ class CORE_EXPORT FontFaceSet : public EventTargetWithInlineData,
virtual ScriptPromise ready(ScriptState*) = 0;
ExecutionContext* GetExecutionContext() const override {
- return ContextClient::GetExecutionContext();
+ return ExecutionContextClient::GetExecutionContext();
}
const AtomicString& InterfaceName() const override {
@@ -70,7 +68,7 @@ class CORE_EXPORT FontFaceSet : public EventTargetWithInlineData,
wtf_size_t size() const;
virtual AtomicString status() const = 0;
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
protected:
static const int kDefaultFontSize;
@@ -94,7 +92,6 @@ class CORE_EXPORT FontFaceSet : public EventTargetWithInlineData,
void FireDoneEvent();
using ReadyProperty = ScriptPromiseProperty<Member<FontFaceSet>,
- Member<FontFaceSet>,
Member<DOMException>>;
bool is_loading_ = false;
@@ -115,7 +112,7 @@ class CORE_EXPORT FontFaceSet : public EventTargetWithInlineData,
Member<FontFace>&,
ExceptionState&) override;
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(font_faces_);
FontFaceSetIterable::IterationSource::Trace(visitor);
}
@@ -131,11 +128,6 @@ class CORE_EXPORT FontFaceSet : public EventTargetWithInlineData,
USING_GARBAGE_COLLECTED_MIXIN(LoadFontPromiseResolver);
public:
- static LoadFontPromiseResolver* Create(FontFaceArray faces,
- ScriptState* script_state) {
- return MakeGarbageCollected<LoadFontPromiseResolver>(faces, script_state);
- }
-
LoadFontPromiseResolver(FontFaceArray faces, ScriptState* script_state)
: num_loading_(faces.size()),
error_occured_(false),
@@ -149,7 +141,7 @@ class CORE_EXPORT FontFaceSet : public EventTargetWithInlineData,
void NotifyLoaded(FontFace*) override;
void NotifyError(FontFace*) override;
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
HeapVector<Member<FontFace>> font_faces_;
diff --git a/chromium/third_party/blink/renderer/core/css/font_face_set_document.cc b/chromium/third_party/blink/renderer/core/css/font_face_set_document.cc
index 4abf570d9b1..21d0ebce61f 100644
--- a/chromium/third_party/blink/renderer/core/css/font_face_set_document.cc
+++ b/chromium/third_party/blink/renderer/core/css/font_face_set_document.cc
@@ -25,6 +25,7 @@
#include "third_party/blink/renderer/core/css/font_face_set_document.h"
+#include "base/metrics/histogram_functions.h"
#include "third_party/blink/renderer/bindings/core/v8/dictionary.h"
#include "third_party/blink/renderer/core/css/css_font_selector.h"
#include "third_party/blink/renderer/core/css/css_property_value_set.h"
@@ -36,12 +37,12 @@
#include "third_party/blink/renderer/core/css/resolver/style_resolver.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/dom/document.h"
+#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
-#include "third_party/blink/renderer/platform/instrumentation/histogram.h"
namespace blink {
@@ -49,14 +50,14 @@ namespace blink {
const char FontFaceSetDocument::kSupplementName[] = "FontFaceSetDocument";
FontFaceSetDocument::FontFaceSetDocument(Document& document)
- : FontFaceSet(document), Supplement<Document>(document) {
-}
+ : FontFaceSet(*document.GetExecutionContext()),
+ Supplement<Document>(document) {}
FontFaceSetDocument::~FontFaceSetDocument() = default;
bool FontFaceSetDocument::InActiveContext() const {
ExecutionContext* context = GetExecutionContext();
- return context && To<Document>(context)->IsActive();
+ return context && To<LocalDOMWindow>(context)->document()->IsActive();
}
@@ -103,7 +104,7 @@ ScriptPromise FontFaceSetDocument::ready(ScriptState* script_state) {
// changes and/or layout operations that may cause another font loads.
// So synchronously update style and layout here.
// This may trigger font loads, and replace |ready_| with a new Promise.
- GetDocument()->UpdateStyleAndLayout();
+ GetDocument()->UpdateStyleAndLayout(DocumentUpdateReason::kJavaScript);
}
return ready_->Promise(script_state->World());
}
@@ -156,8 +157,7 @@ bool FontFaceSetDocument::ResolveFontStyle(const String& font_string,
auto* font_selector = GetDocument()->GetStyleEngine().GetFontSelector();
FontDescription description =
FontStyleResolver::ComputeFont(*parsed_style, font_selector);
- font = Font(description);
- font.Update(font_selector);
+ font = Font(description, font_selector);
return true;
}
@@ -173,14 +173,16 @@ bool FontFaceSetDocument::ResolveFontStyle(const String& font_string,
style->SetFontDescription(default_font_description);
- style->GetFont().Update(style->GetFont().GetFontSelector());
-
GetDocument()->UpdateActiveStyle();
GetDocument()->EnsureStyleResolver().ComputeFont(
*GetDocument()->documentElement(), style.get(), *parsed_style);
font = style->GetFont();
- font.Update(GetFontSelector());
+
+ // StyleResolver::ComputeFont() should have set the document's FontSelector
+ // to |style|.
+ DCHECK_EQ(font.GetFontSelector(), GetFontSelector());
+
return true;
}
@@ -208,7 +210,7 @@ size_t FontFaceSetDocument::ApproximateBlankCharacterCount(Document& document) {
return 0;
}
-void FontFaceSetDocument::Trace(blink::Visitor* visitor) {
+void FontFaceSetDocument::Trace(Visitor* visitor) {
Supplement<Document>::Trace(visitor);
FontFaceSet::Trace(visitor);
}
@@ -224,9 +226,7 @@ void FontFaceSetDocument::FontLoadHistogram::UpdateStatus(FontFace* font_face) {
void FontFaceSetDocument::FontLoadHistogram::Record() {
if (status_ == kHadBlankText || status_ == kDidNotHaveBlankText) {
- DEFINE_STATIC_LOCAL(EnumerationHistogram, had_blank_text_histogram,
- ("WebFont.HadBlankText", 2));
- had_blank_text_histogram.Count(status_ == kHadBlankText ? 1 : 0);
+ base::UmaHistogramBoolean("WebFont.HadBlankText", status_ == kHadBlankText);
status_ = kReported;
}
}
diff --git a/chromium/third_party/blink/renderer/core/css/font_face_set_document.h b/chromium/third_party/blink/renderer/core/css/font_face_set_document.h
index 3def99aa7ea..5ee0f4d01da 100644
--- a/chromium/third_party/blink/renderer/core/css/font_face_set_document.h
+++ b/chromium/third_party/blink/renderer/core/css/font_face_set_document.h
@@ -70,7 +70,7 @@ class CORE_EXPORT FontFaceSetDocument final : public FontFaceSet,
static void DidLayout(Document&);
static size_t ApproximateBlankCharacterCount(Document&);
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
protected:
bool InActiveContext() const override;
diff --git a/chromium/third_party/blink/renderer/core/css/font_face_set_load_event.cc b/chromium/third_party/blink/renderer/core/css/font_face_set_load_event.cc
index 7ecec065917..f1b44491aa5 100644
--- a/chromium/third_party/blink/renderer/core/css/font_face_set_load_event.cc
+++ b/chromium/third_party/blink/renderer/core/css/font_face_set_load_event.cc
@@ -30,6 +30,7 @@
#include "third_party/blink/renderer/core/css/font_face_set_load_event.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_font_face_set_load_event_init.h"
#include "third_party/blink/renderer/core/event_interface_names.h"
namespace blink {
@@ -49,7 +50,7 @@ const AtomicString& FontFaceSetLoadEvent::InterfaceName() const {
return event_interface_names::kFontFaceSetLoadEvent;
}
-void FontFaceSetLoadEvent::Trace(blink::Visitor* visitor) {
+void FontFaceSetLoadEvent::Trace(Visitor* visitor) {
visitor->Trace(fontfaces_);
Event::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/font_face_set_load_event.h b/chromium/third_party/blink/renderer/core/css/font_face_set_load_event.h
index ca012ca0c24..4f332c15eb3 100644
--- a/chromium/third_party/blink/renderer/core/css/font_face_set_load_event.h
+++ b/chromium/third_party/blink/renderer/core/css/font_face_set_load_event.h
@@ -33,11 +33,12 @@
#include "base/memory/scoped_refptr.h"
#include "third_party/blink/renderer/core/css/font_face.h"
-#include "third_party/blink/renderer/core/css/font_face_set_load_event_init.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
namespace blink {
+class FontFaceSetLoadEventInit;
+
class FontFaceSetLoadEvent final : public Event {
DEFINE_WRAPPERTYPEINFO();
@@ -62,7 +63,7 @@ class FontFaceSetLoadEvent final : public Event {
const AtomicString& InterfaceName() const override;
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
FontFaceArray fontfaces_;
diff --git a/chromium/third_party/blink/renderer/core/css/font_face_set_load_event.idl b/chromium/third_party/blink/renderer/core/css/font_face_set_load_event.idl
index 59da6a5c39b..a85f1cbeec4 100644
--- a/chromium/third_party/blink/renderer/core/css/font_face_set_load_event.idl
+++ b/chromium/third_party/blink/renderer/core/css/font_face_set_load_event.idl
@@ -31,9 +31,9 @@
// https://drafts.csswg.org/css-font-loading/#fontfacesetloadevent
[
- Constructor(DOMString type, optional FontFaceSetLoadEventInit eventInitDict),
// TODO(loonybear): Exposed=(Window,Worker)
Exposed=Window
] interface FontFaceSetLoadEvent : Event {
+ constructor(DOMString type, optional FontFaceSetLoadEventInit eventInitDict = {});
[SameObject] readonly attribute FrozenArray<FontFace> fontfaces;
};
diff --git a/chromium/third_party/blink/renderer/core/css/font_face_set_worker.cc b/chromium/third_party/blink/renderer/core/css/font_face_set_worker.cc
index 6135290fc34..00350f89d2a 100644
--- a/chromium/third_party/blink/renderer/core/css/font_face_set_worker.cc
+++ b/chromium/third_party/blink/renderer/core/css/font_face_set_worker.cc
@@ -97,8 +97,7 @@ bool FontFaceSetWorker::ResolveFontStyle(const String& font_string,
FontDescription description = FontStyleResolver::ComputeFont(
*parsed_style, GetWorker()->GetFontSelector());
- font = Font(description);
- font.Update(GetWorker()->GetFontSelector());
+ font = Font(description, GetWorker()->GetFontSelector());
return true;
}
diff --git a/chromium/third_party/blink/renderer/core/css/font_face_source.h b/chromium/third_party/blink/renderer/core/css/font_face_source.h
index 02a8d197b00..ac53642711a 100644
--- a/chromium/third_party/blink/renderer/core/css/font_face_source.h
+++ b/chromium/third_party/blink/renderer/core/css/font_face_source.h
@@ -6,6 +6,7 @@
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_FONT_FACE_SOURCE_H_
#include "base/memory/scoped_refptr.h"
+#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
@@ -15,7 +16,7 @@ class Document;
class FontFaceSet;
class WorkerGlobalScope;
-class FontFaceSource {
+class CORE_EXPORT FontFaceSource {
STATIC_ONLY(FontFaceSource);
public:
diff --git a/chromium/third_party/blink/renderer/core/css/fullscreen.css b/chromium/third_party/blink/renderer/core/css/fullscreen.css
index 7ed4f7704cc..a0982cad72b 100644
--- a/chromium/third_party/blink/renderer/core/css/fullscreen.css
+++ b/chromium/third_party/blink/renderer/core/css/fullscreen.css
@@ -65,10 +65,3 @@ iframe:fullscreen {
background-color: black !important;
z-index: 2147483647 !important;
}
-
-/* WebXR DOM Overlay for handheld AR needs a transparent background for both the
- fullscreened element and its backdrop. */
-:-internal-xr-immersive-dom-overlay :fullscreen,
-:-internal-xr-immersive-dom-overlay :fullscreen::backdrop {
- background-color: rgba(0,0,0,0) !important;
-}
diff --git a/chromium/third_party/blink/renderer/core/css/inline_css_style_declaration.cc b/chromium/third_party/blink/renderer/core/css/inline_css_style_declaration.cc
index 77cf6154914..08c14c61351 100644
--- a/chromium/third_party/blink/renderer/core/css/inline_css_style_declaration.cc
+++ b/chromium/third_party/blink/renderer/core/css/inline_css_style_declaration.cc
@@ -41,9 +41,6 @@ void InlineCSSStyleDeclaration::DidMutate(MutationType type) {
return;
parent_element_->ClearMutableInlineStyleIfEmpty();
- parent_element_->SetNeedsStyleRecalc(
- kLocalStyleChange, StyleChangeReasonForTracing::Create(
- style_change_reason::kInlineCSSStyleMutated));
parent_element_->InvalidateStyleAttribute();
StyleAttributeMutationScope(this).DidInvalidateStyleAttr();
}
@@ -53,7 +50,7 @@ CSSStyleSheet* InlineCSSStyleDeclaration::ParentStyleSheet() const {
: nullptr;
}
-void InlineCSSStyleDeclaration::Trace(blink::Visitor* visitor) {
+void InlineCSSStyleDeclaration::Trace(Visitor* visitor) {
visitor->Trace(parent_element_);
AbstractPropertySetCSSStyleDeclaration::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/inline_css_style_declaration.h b/chromium/third_party/blink/renderer/core/css/inline_css_style_declaration.h
index 127c9d8944d..85f004cfdfa 100644
--- a/chromium/third_party/blink/renderer/core/css/inline_css_style_declaration.h
+++ b/chromium/third_party/blink/renderer/core/css/inline_css_style_declaration.h
@@ -27,18 +27,20 @@
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_INLINE_CSS_STYLE_DECLARATION_H_
#include "third_party/blink/renderer/core/css/abstract_property_set_css_style_declaration.h"
+#include "third_party/blink/renderer/core/dom/document.h"
+#include "third_party/blink/renderer/core/dom/element.h"
namespace blink {
-class Element;
-
class InlineCSSStyleDeclaration final
: public AbstractPropertySetCSSStyleDeclaration {
public:
explicit InlineCSSStyleDeclaration(Element* parent_element)
- : parent_element_(parent_element) {}
+ : AbstractPropertySetCSSStyleDeclaration(
+ parent_element ? parent_element->GetExecutionContext() : nullptr),
+ parent_element_(parent_element) {}
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
MutableCSSPropertyValueSet& PropertySet() const override;
diff --git a/chromium/third_party/blink/renderer/core/css/invalidation/invalidation_set.cc b/chromium/third_party/blink/renderer/core/css/invalidation/invalidation_set.cc
index e73fe97dc50..108a3417d3d 100644
--- a/chromium/third_party/blink/renderer/core/css/invalidation/invalidation_set.cc
+++ b/chromium/third_party/blink/renderer/core/css/invalidation/invalidation_set.cc
@@ -366,11 +366,11 @@ void InvalidationSet::ToTracedValue(TracedValue* value) const {
#ifndef NDEBUG
void InvalidationSet::Show() const {
- auto value = std::make_unique<TracedValue>();
- value->BeginArray("InvalidationSet");
- ToTracedValue(value.get());
- value->EndArray();
- fprintf(stderr, "%s\n", value->ToString().Ascii().c_str());
+ TracedValueJSON value;
+ value.BeginArray("InvalidationSet");
+ ToTracedValue(&value);
+ value.EndArray();
+ LOG(ERROR) << value.ToJSON().Ascii();
}
#endif // NDEBUG
diff --git a/chromium/third_party/blink/renderer/core/css/invalidation/invalidation_set_test.cc b/chromium/third_party/blink/renderer/core/css/invalidation/invalidation_set_test.cc
index de9261c178b..b17fc85138c 100644
--- a/chromium/third_party/blink/renderer/core/css/invalidation/invalidation_set_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/invalidation/invalidation_set_test.cc
@@ -264,9 +264,8 @@ TEST(InvalidationSetTest, Backing_GetHashSet) {
TEST(InvalidationSetTest, ClassInvalidatesElement) {
auto dummy_page_holder = std::make_unique<DummyPageHolder>(IntSize(800, 600));
auto& document = dummy_page_holder->GetDocument();
- document.body()->SetInnerHTMLFromString("<div id=test class='a b'>");
- document.View()->UpdateAllLifecyclePhases(
- DocumentLifecycle::LifecycleUpdateReason::kTest);
+ document.body()->setInnerHTML("<div id=test class='a b'>");
+ document.View()->UpdateAllLifecyclePhases(DocumentUpdateReason::kTest);
Element* element = document.getElementById("test");
ASSERT_TRUE(element);
@@ -290,9 +289,8 @@ TEST(InvalidationSetTest, ClassInvalidatesElement) {
TEST(InvalidationSetTest, AttributeInvalidatesElement) {
auto dummy_page_holder = std::make_unique<DummyPageHolder>(IntSize(800, 600));
auto& document = dummy_page_holder->GetDocument();
- document.body()->SetInnerHTMLFromString("<div id=test a b>");
- document.View()->UpdateAllLifecyclePhases(
- DocumentLifecycle::LifecycleUpdateReason::kTest);
+ document.body()->setInnerHTML("<div id=test a b>");
+ document.View()->UpdateAllLifecyclePhases(DocumentUpdateReason::kTest);
Element* element = document.getElementById("test");
ASSERT_TRUE(element);
diff --git a/chromium/third_party/blink/renderer/core/css/invalidation/pending_invalidations.cc b/chromium/third_party/blink/renderer/core/css/invalidation/pending_invalidations.cc
index 678a929e4a3..9453376b596 100644
--- a/chromium/third_party/blink/renderer/core/css/invalidation/pending_invalidations.cc
+++ b/chromium/third_party/blink/renderer/core/css/invalidation/pending_invalidations.cc
@@ -26,6 +26,7 @@ void PendingInvalidations::ScheduleInvalidationSetsForNode(
const InvalidationLists& invalidation_lists,
ContainerNode& node) {
DCHECK(node.InActiveDocument());
+ DCHECK(!node.GetDocument().InStyleRecalc());
bool requires_descendant_invalidation = false;
if (node.GetStyleChangeType() < kSubtreeStyleChange) {
diff --git a/chromium/third_party/blink/renderer/core/css/invalidation/pending_invalidations.h b/chromium/third_party/blink/renderer/core/css/invalidation/pending_invalidations.h
index 6090c79df0c..798d166581a 100644
--- a/chromium/third_party/blink/renderer/core/css/invalidation/pending_invalidations.h
+++ b/chromium/third_party/blink/renderer/core/css/invalidation/pending_invalidations.h
@@ -81,9 +81,7 @@ class CORE_EXPORT PendingInvalidations {
PendingInvalidationMap& GetPendingInvalidationMap() {
return pending_invalidation_map_;
}
- void Trace(blink::Visitor* visitor) {
- visitor->Trace(pending_invalidation_map_);
- }
+ void Trace(Visitor* visitor) { visitor->Trace(pending_invalidation_map_); }
private:
NodeInvalidationSets& EnsurePendingInvalidations(ContainerNode&);
diff --git a/chromium/third_party/blink/renderer/core/css/invalidation/pending_invalidations_test.cc b/chromium/third_party/blink/renderer/core/css/invalidation/pending_invalidations_test.cc
index fe8dbcfccfb..6529bfdd074 100644
--- a/chromium/third_party/blink/renderer/core/css/invalidation/pending_invalidations_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/invalidation/pending_invalidations_test.cc
@@ -31,10 +31,9 @@ void PendingInvalidationsTest::SetUp() {
}
TEST_F(PendingInvalidationsTest, ScheduleOnDocumentNode) {
- GetDocument().body()->SetInnerHTMLFromString(
+ GetDocument().body()->setInnerHTML(
"<div id='d'></div><i id='i'></i><span></span>");
- GetDocument().View()->UpdateAllLifecyclePhases(
- DocumentLifecycle::LifecycleUpdateReason::kTest);
+ GetDocument().View()->UpdateAllLifecyclePhases(DocumentUpdateReason::kTest);
unsigned before_count = GetStyleEngine().StyleForElementCount();
@@ -58,14 +57,13 @@ TEST_F(PendingInvalidationsTest, ScheduleOnDocumentNode) {
EXPECT_FALSE(GetDocument().NeedsStyleRecalc());
EXPECT_TRUE(GetStyleEngine().NeedsStyleRecalc());
- GetDocument().View()->UpdateAllLifecyclePhases(
- DocumentLifecycle::LifecycleUpdateReason::kTest);
+ GetDocument().View()->UpdateAllLifecyclePhases(DocumentUpdateReason::kTest);
unsigned after_count = GetStyleEngine().StyleForElementCount();
EXPECT_EQ(2u, after_count - before_count);
}
TEST_F(PendingInvalidationsTest, DescendantInvalidationOnDisplayNone) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
#a { display: none }
.a .b { color: green }
@@ -76,8 +74,7 @@ TEST_F(PendingInvalidationsTest, DescendantInvalidationOnDisplayNone) {
</div>
)HTML");
- GetDocument().View()->UpdateAllLifecyclePhases(
- DocumentLifecycle::LifecycleUpdateReason::kTest);
+ GetDocument().View()->UpdateAllLifecyclePhases(DocumentUpdateReason::kTest);
// We skip scheduling descendant invalidations on display:none elements.
GetDocument().getElementById("a")->setAttribute(html_names::kClassAttr, "a");
diff --git a/chromium/third_party/blink/renderer/core/css/invalidation/style_invalidator_test.cc b/chromium/third_party/blink/renderer/core/css/invalidation/style_invalidator_test.cc
index ed8c8d7df20..e1daed984c0 100644
--- a/chromium/third_party/blink/renderer/core/css/invalidation/style_invalidator_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/invalidation/style_invalidator_test.cc
@@ -25,7 +25,7 @@ class StyleInvalidatorTest : public testing::Test {
};
TEST_F(StyleInvalidatorTest, SkipDisplayNone) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<div id="root">
<div style="display:none">
<div class="a"></div>
@@ -34,8 +34,7 @@ TEST_F(StyleInvalidatorTest, SkipDisplayNone) {
</div>
)HTML");
- GetDocument().View()->UpdateAllLifecyclePhases(
- DocumentLifecycle::LifecycleUpdateReason::kTest);
+ GetDocument().View()->UpdateAllLifecyclePhases(DocumentUpdateReason::kTest);
PendingInvalidations pending;
{
@@ -54,7 +53,7 @@ TEST_F(StyleInvalidatorTest, SkipDisplayNone) {
}
TEST_F(StyleInvalidatorTest, SkipDisplayNoneClearPendingNth) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<div id="none" style="display:none">
<div class="a"></div>
<div class="a"></div>
@@ -64,8 +63,7 @@ TEST_F(StyleInvalidatorTest, SkipDisplayNoneClearPendingNth) {
</div>
)HTML");
- GetDocument().View()->UpdateAllLifecyclePhases(
- DocumentLifecycle::LifecycleUpdateReason::kTest);
+ GetDocument().View()->UpdateAllLifecyclePhases(DocumentUpdateReason::kTest);
PendingInvalidations pending;
{
diff --git a/chromium/third_party/blink/renderer/core/css/local_font_face_source.cc b/chromium/third_party/blink/renderer/core/css/local_font_face_source.cc
index d3dfe3edc73..38d08f4d909 100644
--- a/chromium/third_party/blink/renderer/core/css/local_font_face_source.cc
+++ b/chromium/third_party/blink/renderer/core/css/local_font_face_source.cc
@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/core/css/local_font_face_source.h"
+#include "base/metrics/histogram_functions.h"
#include "build/build_config.h"
#include "third_party/blink/renderer/core/css/css_custom_font_data.h"
#include "third_party/blink/renderer/core/css/css_font_face.h"
@@ -14,7 +15,6 @@
#include "third_party/blink/renderer/platform/fonts/font_unique_name_lookup.h"
#include "third_party/blink/renderer/platform/fonts/simple_font_data.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
-#include "third_party/blink/renderer/platform/instrumentation/histogram.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
namespace blink {
@@ -38,8 +38,16 @@ bool LocalFontFaceSource::IsLocalNonBlocking() const {
bool LocalFontFaceSource::IsLocalFontAvailable(
const FontDescription& font_description) const {
- return FontCache::GetFontCache()->IsPlatformFontUniqueNameMatchAvailable(
- font_description, font_name_);
+ // TODO(crbug.com/1027158): Remove metrics code after metrics collected.
+ // TODO(crbug.com/1025945): Properly handle Windows prior to 10 and Android.
+ bool font_available =
+ FontCache::GetFontCache()->IsPlatformFontUniqueNameMatchAvailable(
+ font_description, font_name_);
+ if (font_available)
+ font_selector_->ReportSuccessfulLocalFontMatch(font_name_);
+ else
+ font_selector_->ReportFailedLocalFontMatch(font_name_);
+ return font_available;
}
scoped_refptr<SimpleFontData>
@@ -130,12 +138,10 @@ void LocalFontFaceSource::LocalFontHistograms::Record(bool load_success) {
if (reported_)
return;
reported_ = true;
- DEFINE_STATIC_LOCAL(EnumerationHistogram, local_font_used_histogram,
- ("WebFont.LocalFontUsed", 2));
- local_font_used_histogram.Count(load_success ? 1 : 0);
+ base::UmaHistogramBoolean("WebFont.LocalFontUsed", load_success);
}
-void LocalFontFaceSource::Trace(blink::Visitor* visitor) {
+void LocalFontFaceSource::Trace(Visitor* visitor) {
visitor->Trace(face_);
visitor->Trace(font_selector_);
CSSFontFaceSource::Trace(visitor);
diff --git a/chromium/third_party/blink/renderer/core/css/local_font_face_source.h b/chromium/third_party/blink/renderer/core/css/local_font_face_source.h
index 8dc55e00610..2e2dbe30b35 100644
--- a/chromium/third_party/blink/renderer/core/css/local_font_face_source.h
+++ b/chromium/third_party/blink/renderer/core/css/local_font_face_source.h
@@ -44,7 +44,7 @@ class LocalFontFaceSource final : public CSSFontFaceSource,
void BeginLoadIfNeeded() override;
- void Trace(blink::Visitor* visitor) override;
+ void Trace(Visitor* visitor) override;
void NotifyFontUniqueNameLookupReady();
diff --git a/chromium/third_party/blink/renderer/core/css/mathml.css b/chromium/third_party/blink/renderer/core/css/mathml.css
index 514a4621f75..5adc7b167ce 100644
--- a/chromium/third_party/blink/renderer/core/css/mathml.css
+++ b/chromium/third_party/blink/renderer/core/css/mathml.css
@@ -29,11 +29,11 @@
/* By default, we only display the MathML formulas without any formatting other than the one specified by the display attribute. */
math {
- display: inline;
+ display: inline-math;
}
math[display="block"] {
- display: block;
+ display: math;
text-align: center;
}
@@ -46,13 +46,25 @@ math[display="block"] {
outline: auto 1px -webkit-focus-ring-color;
}
-/* We hide the PresentationExpression constructions that are children of a <semantics> element.
- http://www.w3.org/TR/MathML/appendixa.html#parsing_PresentationExpression */
-semantics > mi, semantics > mn, semantics > mo, semantics > mtext, semantics > mspace, semantics > ms, semantics > maligngroup, semantics > malignmark, semantics > mrow, semantics > mfrac, semantics > msqrt, semantics > mroot, semantics > mstyle, semantics > merror, semantics > mpadded, semantics > mphantom, semantics > mfenced, semantics > menclose, semantics > msub, semantics > msup, semantics > msubsup, semantics > munder, semantics > mover, semantics > munderover, semantics > mmultiscripts, semantics > mtable, semantics > mstack, semantics > mlongdiv, semantics > maction {
- display: none;
+maction, merror, mfrac, mphantom, mrow, mspace, mstyle
+{
+ display: math;
}
-/* However, we display all the annotations. */
-annotation, annotation-xml {
- display: inline-block;
+mphantom {
+ visibility: hidden;
+}
+
+merror {
+ color: red;
+ background-color: lightYellow;
+}
+
+mspace {
+ overflow: hidden !important;
+}
+
+mfrac {
+ padding-inline-start: 1px;
+ padding-inline-end: 1px;
}
diff --git a/chromium/third_party/blink/renderer/core/css/media_feature_names.json5 b/chromium/third_party/blink/renderer/core/css/media_feature_names.json5
index b78aa49241e..cd214bc0f89 100644
--- a/chromium/third_party/blink/renderer/core/css/media_feature_names.json5
+++ b/chromium/third_party/blink/renderer/core/css/media_feature_names.json5
@@ -49,6 +49,8 @@
"min-width",
"min-resolution",
"navigation-controls",
+ // This feature only exists to test out origin-trial infrastructure.
+ "origin-trial-test",
"pointer",
"prefers-color-scheme",
"prefers-reduced-motion",
diff --git a/chromium/third_party/blink/renderer/core/css/media_feature_overrides.cc b/chromium/third_party/blink/renderer/core/css/media_feature_overrides.cc
index c6a0850d57b..fb953f83f6b 100644
--- a/chromium/third_party/blink/renderer/core/css/media_feature_overrides.cc
+++ b/chromium/third_party/blink/renderer/core/css/media_feature_overrides.cc
@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/core/css/media_feature_overrides.h"
+#include "third_party/blink/renderer/core/css/parser/css_parser_context.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_token_range.h"
#include "third_party/blink/renderer/core/css/parser/css_tokenizer.h"
@@ -14,7 +15,23 @@ void MediaFeatureOverrides::SetOverride(const AtomicString& feature,
CSSTokenizer tokenizer(value_string);
const auto tokens = tokenizer.TokenizeToEOF();
CSSParserTokenRange range(tokens);
- auto value = MediaQueryExp::Create(feature, range).ExpValue();
+
+ // TODO(xiaochengh): This is a fake CSSParserContext that only passes
+ // down the CSSParserMode. Plumb the real CSSParserContext through, so that
+ // web features can be counted correctly.
+ const CSSParserContext* fake_context = MakeGarbageCollected<CSSParserContext>(
+ kHTMLStandardMode, SecureContextMode::kInsecureContext);
+
+ // MediaFeatureOverrides are used to emulate various media feature values.
+ // These don't need to pass an ExecutionContext, since the parsing of
+ // the actual CSS will determine whether or not the emulated values will come
+ // into play (i.e. if you can parse an origin trial enabled feature, you
+ // will never ask for the emulated override value).
+ // Note that once a real CSSParserContext is plumbed through we can use its
+ // Document to get the ExecutionContext so the extra parameter should be
+ // removed.
+ auto value =
+ MediaQueryExp::Create(feature, range, *fake_context, nullptr).ExpValue();
if (value.IsValid())
overrides_.Set(feature, value);
diff --git a/chromium/third_party/blink/renderer/core/css/media_list.cc b/chromium/third_party/blink/renderer/core/css/media_list.cc
index b2b2456075e..2e25f0fde73 100644
--- a/chromium/third_party/blink/renderer/core/css/media_list.cc
+++ b/chromium/third_party/blink/renderer/core/css/media_list.cc
@@ -57,15 +57,18 @@ MediaQuerySet::MediaQuerySet(const MediaQuerySet& o)
queries_[i] = o.queries_[i]->Copy();
}
-scoped_refptr<MediaQuerySet> MediaQuerySet::Create(const String& media_string) {
+scoped_refptr<MediaQuerySet> MediaQuerySet::Create(
+ const String& media_string,
+ const ExecutionContext* execution_context) {
if (media_string.IsEmpty())
return MediaQuerySet::Create();
- return MediaQueryParser::ParseMediaQuerySet(media_string);
+ return MediaQueryParser::ParseMediaQuerySet(media_string, execution_context);
}
-bool MediaQuerySet::Set(const String& media_string) {
- scoped_refptr<MediaQuerySet> result = Create(media_string);
+bool MediaQuerySet::Set(const String& media_string,
+ const ExecutionContext* execution_context) {
+ scoped_refptr<MediaQuerySet> result = Create(media_string, execution_context);
// TODO(keishi) Changed DCHECK to CHECK for crbug.com/699269 diagnosis
for (const auto& query : result->queries_) {
CHECK(query);
@@ -74,11 +77,12 @@ bool MediaQuerySet::Set(const String& media_string) {
return true;
}
-bool MediaQuerySet::Add(const String& query_string) {
+bool MediaQuerySet::Add(const String& query_string,
+ const ExecutionContext* execution_context) {
// To "parse a media query" for a given string means to follow "the parse
// a media query list" steps and return "null" if more than one media query
// is returned, or else the returned media query.
- scoped_refptr<MediaQuerySet> result = Create(query_string);
+ scoped_refptr<MediaQuerySet> result = Create(query_string, execution_context);
// Only continue if exactly one media query is found, as described above.
if (result->queries_.size() != 1)
@@ -100,11 +104,13 @@ bool MediaQuerySet::Add(const String& query_string) {
return true;
}
-bool MediaQuerySet::Remove(const String& query_string_to_remove) {
+bool MediaQuerySet::Remove(const String& query_string_to_remove,
+ const ExecutionContext* execution_context) {
// To "parse a media query" for a given string means to follow "the parse
// a media query list" steps and return "null" if more than one media query
// is returned, or else the returned media query.
- scoped_refptr<MediaQuerySet> result = Create(query_string_to_remove);
+ scoped_refptr<MediaQuerySet> result =
+ Create(query_string_to_remove, execution_context);
// Only continue if exactly one media query is found, as described above.
if (result->queries_.size() != 1)
@@ -161,10 +167,11 @@ MediaList::MediaList(scoped_refptr<MediaQuerySet> media_queries,
parent_style_sheet_(nullptr),
parent_rule_(parent_rule) {}
-void MediaList::setMediaText(const String& value) {
+void MediaList::setMediaText(const ExecutionContext* execution_context,
+ const String& value) {
CSSStyleSheet::RuleMutationScope mutation_scope(parent_rule_);
- media_queries_->Set(value);
+ media_queries_->Set(value, execution_context);
if (parent_style_sheet_)
parent_style_sheet_->DidMutate();
@@ -178,11 +185,12 @@ String MediaList::item(unsigned index) const {
return String();
}
-void MediaList::deleteMedium(const String& medium,
+void MediaList::deleteMedium(const ExecutionContext* execution_context,
+ const String& medium,
ExceptionState& exception_state) {
CSSStyleSheet::RuleMutationScope mutation_scope(parent_rule_);
- bool success = media_queries_->Remove(medium);
+ bool success = media_queries_->Remove(medium, execution_context);
if (!success) {
exception_state.ThrowDOMException(DOMExceptionCode::kNotFoundError,
"Failed to delete '" + medium + "'.");
@@ -192,10 +200,11 @@ void MediaList::deleteMedium(const String& medium,
parent_style_sheet_->DidMutate();
}
-void MediaList::appendMedium(const String& medium) {
+void MediaList::appendMedium(const ExecutionContext* execution_context,
+ const String& medium) {
CSSStyleSheet::RuleMutationScope mutation_scope(parent_rule_);
- bool added = media_queries_->Add(medium);
+ bool added = media_queries_->Add(medium, execution_context);
if (!added)
return;
@@ -212,7 +221,7 @@ void MediaList::Reattach(scoped_refptr<MediaQuerySet> media_queries) {
media_queries_ = media_queries;
}
-void MediaList::Trace(blink::Visitor* visitor) {
+void MediaList::Trace(Visitor* visitor) {
visitor->Trace(parent_style_sheet_);
visitor->Trace(parent_rule_);
ScriptWrappable::Trace(visitor);
diff --git a/chromium/third_party/blink/renderer/core/css/media_list.h b/chromium/third_party/blink/renderer/core/css/media_list.h
index e9f697b132b..61781552ee5 100644
--- a/chromium/third_party/blink/renderer/core/css/media_list.h
+++ b/chromium/third_party/blink/renderer/core/css/media_list.h
@@ -35,6 +35,7 @@ namespace blink {
class CSSRule;
class CSSStyleSheet;
class ExceptionState;
+class ExecutionContext;
class MediaList;
class MediaQuery;
@@ -43,11 +44,12 @@ class CORE_EXPORT MediaQuerySet : public RefCounted<MediaQuerySet> {
static scoped_refptr<MediaQuerySet> Create() {
return base::AdoptRef(new MediaQuerySet());
}
- static scoped_refptr<MediaQuerySet> Create(const String& media_string);
+ static scoped_refptr<MediaQuerySet> Create(const String& media_string,
+ const ExecutionContext*);
- bool Set(const String&);
- bool Add(const String&);
- bool Remove(const String&);
+ bool Set(const String&, const ExecutionContext*);
+ bool Add(const String&, const ExecutionContext*);
+ bool Remove(const String&, const ExecutionContext*);
void AddMediaQuery(std::unique_ptr<MediaQuery>);
@@ -77,11 +79,18 @@ class MediaList final : public ScriptWrappable {
unsigned length() const { return media_queries_->QueryVector().size(); }
String item(unsigned index) const;
- void deleteMedium(const String& old_medium, ExceptionState&);
- void appendMedium(const String& new_medium);
-
- String mediaText() const { return media_queries_->MediaText(); }
- void setMediaText(const String&);
+ void deleteMedium(const ExecutionContext*,
+ const String& old_medium,
+ ExceptionState&);
+ void appendMedium(const ExecutionContext*, const String& new_medium);
+
+ // Note that this getter doesn't require the ExecutionContext, but the
+ // attribute is marked as [CallWith=ExecutionContext] so that the setter can
+ // have access to the ExecutionContext.
+ String mediaText(const ExecutionContext*) const {
+ return media_queries_->MediaText();
+ }
+ void setMediaText(const ExecutionContext*, const String&);
// Not part of CSSOM.
CSSRule* ParentRule() const { return parent_rule_; }
@@ -91,7 +100,7 @@ class MediaList final : public ScriptWrappable {
void Reattach(scoped_refptr<MediaQuerySet>);
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
scoped_refptr<MediaQuerySet> media_queries_;
diff --git a/chromium/third_party/blink/renderer/core/css/media_list.idl b/chromium/third_party/blink/renderer/core/css/media_list.idl
index 6b33f759b76..dc9484d94d0 100644
--- a/chromium/third_party/blink/renderer/core/css/media_list.idl
+++ b/chromium/third_party/blink/renderer/core/css/media_list.idl
@@ -28,9 +28,9 @@
[
Exposed=Window
] interface MediaList {
- stringifier attribute [TreatNullAs=EmptyString] DOMString mediaText;
+ [CallWith=ExecutionContext] stringifier attribute [TreatNullAs=EmptyString] DOMString mediaText;
readonly attribute unsigned long length;
[Measure] getter DOMString? item(unsigned long index);
- void appendMedium(DOMString medium);
- [RaisesException] void deleteMedium(DOMString medium);
+ [CallWith=ExecutionContext] void appendMedium(DOMString medium);
+ [CallWith=ExecutionContext, RaisesException] void deleteMedium(DOMString medium);
};
diff --git a/chromium/third_party/blink/renderer/core/css/media_query_evaluator.cc b/chromium/third_party/blink/renderer/core/css/media_query_evaluator.cc
index ae21ebd3dcf..1a091ab8789 100644
--- a/chromium/third_party/blink/renderer/core/css/media_query_evaluator.cc
+++ b/chromium/third_party/blink/renderer/core/css/media_query_evaluator.cc
@@ -84,7 +84,7 @@ MediaQueryEvaluator::MediaQueryEvaluator(
MediaQueryEvaluator::~MediaQueryEvaluator() = default;
-void MediaQueryEvaluator::Trace(blink::Visitor* visitor) {
+void MediaQueryEvaluator::Trace(Visitor* visitor) {
visitor->Trace(media_values_);
}
@@ -101,9 +101,8 @@ const String MediaQueryEvaluator::MediaType() const {
bool MediaQueryEvaluator::MediaTypeMatch(
const String& media_type_to_match) const {
return media_type_to_match.IsEmpty() ||
- DeprecatedEqualIgnoringCase(media_type_to_match,
- media_type_names::kAll) ||
- DeprecatedEqualIgnoringCase(media_type_to_match, MediaType());
+ EqualIgnoringASCIICase(media_type_to_match, media_type_names::kAll) ||
+ EqualIgnoringASCIICase(media_type_to_match, MediaType());
}
static bool ApplyRestrictor(MediaQuery::RestrictorType r, bool value) {
@@ -158,6 +157,15 @@ bool MediaQueryEvaluator::Eval(
return result;
}
+bool MediaQueryEvaluator::DidResultsChange(
+ const MediaQueryResultList& results) const {
+ for (auto& result : results) {
+ if (Eval(result.Expression()) != result.Result())
+ return true;
+ }
+ return false;
+}
+
template <typename T>
bool CompareValue(T a, T b, MediaFeaturePrefix op) {
switch (op) {
@@ -323,11 +331,11 @@ static bool EvalResolution(const MediaQueryExpValue& value,
// this method only got called if this media type matches the one defined
// in the query. Thus, if if the document's media type is "print", the
// media type of the query will either be "print" or "all".
- if (DeprecatedEqualIgnoringCase(media_values.MediaType(),
- media_type_names::kScreen)) {
+ if (EqualIgnoringASCIICase(media_values.MediaType(),
+ media_type_names::kScreen)) {
actual_resolution = clampTo<float>(media_values.DevicePixelRatio());
- } else if (DeprecatedEqualIgnoringCase(media_values.MediaType(),
- media_type_names::kPrint)) {
+ } else if (EqualIgnoringASCIICase(media_values.MediaType(),
+ media_type_names::kPrint)) {
// The resolution of images while printing should not depend on the DPI
// of the screen. Until we support proper ways of querying this info
// we use 300px which is considered minimum for current printers.
@@ -687,6 +695,15 @@ static bool AnyHoverMediaFeatureEval(const MediaQueryExpValue& value,
}
}
+static bool OriginTrialTestMediaFeatureEval(const MediaQueryExpValue& value,
+ MediaFeaturePrefix,
+ const MediaValues& media_values) {
+ // The test feature only supports a 'no-value' parsing. So if we've gotten
+ // to this point it will always match.
+ DCHECK(!value.IsValid());
+ return true;
+}
+
static bool PointerMediaFeatureEval(const MediaQueryExpValue& value,
MediaFeaturePrefix,
const MediaValues& media_values) {
@@ -769,8 +786,7 @@ static bool ScanMediaFeatureEval(const MediaQueryExpValue& value,
MediaFeaturePrefix,
const MediaValues& media_values) {
// Scan only applies to 'tv' media.
- if (!DeprecatedEqualIgnoringCase(media_values.MediaType(),
- media_type_names::kTv))
+ if (!EqualIgnoringASCIICase(media_values.MediaType(), media_type_names::kTv))
return false;
if (!value.IsValid())
diff --git a/chromium/third_party/blink/renderer/core/css/media_query_evaluator.h b/chromium/third_party/blink/renderer/core/css/media_query_evaluator.h
index 570e0ff096b..2d9e016d8fe 100644
--- a/chromium/third_party/blink/renderer/core/css/media_query_evaluator.h
+++ b/chromium/third_party/blink/renderer/core/css/media_query_evaluator.h
@@ -94,7 +94,11 @@ class CORE_EXPORT MediaQueryEvaluator final
// Evaluates media query subexpression, ie "and (media-feature: value)" part.
bool Eval(const MediaQueryExp&) const;
- void Trace(blink::Visitor*);
+ // Returns true if any of the expressions in the results lists changed its
+ // evaluation.
+ bool DidResultsChange(const MediaQueryResultList& results) const;
+
+ void Trace(Visitor*);
private:
const String MediaType() const;
diff --git a/chromium/third_party/blink/renderer/core/css/media_query_evaluator_test.cc b/chromium/third_party/blink/renderer/core/css/media_query_evaluator_test.cc
index e7bfdefb089..998370f4203 100644
--- a/chromium/third_party/blink/renderer/core/css/media_query_evaluator_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/media_query_evaluator_test.cc
@@ -210,7 +210,7 @@ void TestMQEvaluator(MediaQueryEvaluatorTestCase* test_cases,
query_set = MediaQueryParser::ParseMediaQuerySetInMode(
CSSParserTokenRange(
CSSTokenizer(test_cases[i].input).TokenizeToEOF()),
- mode);
+ mode, nullptr);
}
EXPECT_EQ(test_cases[i].output, media_query_evaluator.Eval(*query_set))
<< "Query: " << test_cases[i].input;
@@ -300,7 +300,8 @@ TEST(MediaQueryEvaluatorTest, DynamicNoView) {
page_holder.reset();
ASSERT_EQ(nullptr, frame->View());
MediaQueryEvaluator media_query_evaluator(frame);
- scoped_refptr<MediaQuerySet> query_set = MediaQuerySet::Create("foobar");
+ scoped_refptr<MediaQuerySet> query_set =
+ MediaQuerySet::Create("foobar", nullptr);
EXPECT_FALSE(media_query_evaluator.Eval(*query_set));
}
diff --git a/chromium/third_party/blink/renderer/core/css/media_query_exp.cc b/chromium/third_party/blink/renderer/core/css/media_query_exp.cc
index 3600f2f55b0..37d0f166736 100644
--- a/chromium/third_party/blink/renderer/core/css/media_query_exp.cc
+++ b/chromium/third_party/blink/renderer/core/css/media_query_exp.cc
@@ -32,6 +32,7 @@
#include "third_party/blink/renderer/core/css/css_math_expression_node.h"
#include "third_party/blink/renderer/core/css/css_math_function_value.h"
#include "third_party/blink/renderer/core/css/css_numeric_literal_value.h"
+#include "third_party/blink/renderer/core/css/parser/css_parser_context.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_token_range.h"
#include "third_party/blink/renderer/core/css/parser/css_property_parser_helpers.h"
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
@@ -80,11 +81,9 @@ static inline bool FeatureWithValidIdent(const String& media_feature,
ident == CSSValueID::kRec2020;
}
- if (RuntimeEnabledFeatures::MediaQueryPrefersColorSchemeEnabled()) {
- if (media_feature == media_feature_names::kPrefersColorSchemeMediaFeature) {
- return ident == CSSValueID::kNoPreference || ident == CSSValueID::kDark ||
- ident == CSSValueID::kLight;
- }
+ if (media_feature == media_feature_names::kPrefersColorSchemeMediaFeature) {
+ return ident == CSSValueID::kNoPreference || ident == CSSValueID::kDark ||
+ ident == CSSValueID::kLight;
}
if (media_feature == media_feature_names::kPrefersReducedMotionMediaFeature)
@@ -186,7 +185,9 @@ static inline bool FeatureWithAspectRatio(const String& media_feature) {
media_feature == kMaxDeviceAspectRatioMediaFeature;
}
-static inline bool FeatureWithoutValue(const String& media_feature) {
+static inline bool FeatureWithoutValue(
+ const String& media_feature,
+ const ExecutionContext* execution_context) {
// Media features that are prefixed by min/max cannot be used without a value.
return media_feature == media_feature_names::kMonochromeMediaFeature ||
media_feature == media_feature_names::kColorMediaFeature ||
@@ -208,15 +209,22 @@ static inline bool FeatureWithoutValue(const String& media_feature) {
media_feature == media_feature_names::kResolutionMediaFeature ||
media_feature == media_feature_names::kDisplayModeMediaFeature ||
media_feature == media_feature_names::kScanMediaFeature ||
- media_feature == media_feature_names::kShapeMediaFeature ||
+ (media_feature == media_feature_names::kShapeMediaFeature &&
+ RuntimeEnabledFeatures::MediaQueryShapeEnabled()) ||
media_feature == media_feature_names::kColorGamutMediaFeature ||
media_feature == media_feature_names::kImmersiveMediaFeature ||
media_feature ==
media_feature_names::kPrefersColorSchemeMediaFeature ||
media_feature ==
media_feature_names::kPrefersReducedMotionMediaFeature ||
- media_feature == media_feature_names::kForcedColorsMediaFeature ||
- media_feature == media_feature_names::kNavigationControlsMediaFeature;
+ (media_feature == media_feature_names::kForcedColorsMediaFeature &&
+ RuntimeEnabledFeatures::ForcedColorsEnabled()) ||
+ (media_feature ==
+ media_feature_names::kNavigationControlsMediaFeature &&
+ RuntimeEnabledFeatures::MediaQueryNavigationControlsEnabled()) ||
+ (media_feature == media_feature_names::kOriginTrialTestMediaFeature &&
+ RuntimeEnabledFeatures::OriginTrialsSampleAPIEnabled(
+ execution_context));
}
bool MediaQueryExp::IsViewportDependent() const {
@@ -259,22 +267,26 @@ MediaQueryExp::MediaQueryExp(const String& media_feature,
: media_feature_(media_feature), exp_value_(exp_value) {}
MediaQueryExp MediaQueryExp::Create(const String& media_feature,
- CSSParserTokenRange& range) {
+ CSSParserTokenRange& range,
+ const CSSParserContext& context,
+ const ExecutionContext* execution_context) {
DCHECK(!media_feature.IsNull());
MediaQueryExpValue exp_value;
String lower_media_feature =
AttemptStaticStringCreation(media_feature.LowerASCII());
+ CSSParserContext::ParserModeOverridingScope scope(context, kHTMLStandardMode);
+
CSSPrimitiveValue* value =
- css_property_parser_helpers::ConsumeInteger(range, 0);
+ css_property_parser_helpers::ConsumeInteger(range, context, 0);
if (!value && !FeatureExpectingPositiveInteger(lower_media_feature) &&
!FeatureWithAspectRatio(lower_media_feature)) {
- value = css_property_parser_helpers::ConsumeNumber(range,
+ value = css_property_parser_helpers::ConsumeNumber(range, context,
kValueRangeNonNegative);
}
if (!value) {
- value = css_property_parser_helpers::ConsumeLength(range, kHTMLStandardMode,
+ value = css_property_parser_helpers::ConsumeLength(range, context,
kValueRangeNonNegative);
}
if (!value)
@@ -290,7 +302,7 @@ MediaQueryExp MediaQueryExp::Create(const String& media_feature,
exp_value.is_id = true;
return MediaQueryExp(lower_media_feature, exp_value);
}
- if (FeatureWithoutValue(lower_media_feature)) {
+ if (FeatureWithoutValue(lower_media_feature, execution_context)) {
// Valid, creates a MediaQueryExp with an 'invalid' MediaQueryExpValue
return MediaQueryExp(lower_media_feature, exp_value);
}
@@ -305,7 +317,7 @@ MediaQueryExp MediaQueryExp::Create(const String& media_feature,
if (!css_property_parser_helpers::ConsumeSlashIncludingWhitespace(range))
return Invalid();
CSSPrimitiveValue* denominator =
- css_property_parser_helpers::ConsumePositiveInteger(range);
+ css_property_parser_helpers::ConsumePositiveInteger(range, context);
if (!denominator)
return Invalid();
diff --git a/chromium/third_party/blink/renderer/core/css/media_query_exp.h b/chromium/third_party/blink/renderer/core/css/media_query_exp.h
index 7650002aefa..f579b0204e7 100644
--- a/chromium/third_party/blink/renderer/core/css/media_query_exp.h
+++ b/chromium/third_party/blink/renderer/core/css/media_query_exp.h
@@ -38,7 +38,9 @@
namespace blink {
+class CSSParserContext;
class CSSParserTokenRange;
+class ExecutionContext;
struct MediaQueryExpValue {
DISALLOW_NEW();
@@ -82,7 +84,9 @@ class CORE_EXPORT MediaQueryExp {
public:
// Returns an invalid MediaQueryExp if the arguments are invalid.
static MediaQueryExp Create(const String& media_feature,
- CSSParserTokenRange&);
+ CSSParserTokenRange&,
+ const CSSParserContext&,
+ const ExecutionContext*);
static MediaQueryExp Invalid() {
return MediaQueryExp(String(), MediaQueryExpValue());
}
diff --git a/chromium/third_party/blink/renderer/core/css/media_query_list.cc b/chromium/third_party/blink/renderer/core/css/media_query_list.cc
index cfce0042be6..8bd1ff1f1ab 100644
--- a/chromium/third_party/blink/renderer/core/css/media_query_list.cc
+++ b/chromium/third_party/blink/renderer/core/css/media_query_list.cc
@@ -30,7 +30,7 @@ namespace blink {
MediaQueryList::MediaQueryList(ExecutionContext* context,
MediaQueryMatcher* matcher,
scoped_refptr<MediaQuerySet> media)
- : ContextLifecycleObserver(context),
+ : ExecutionContextLifecycleObserver(context),
matcher_(matcher),
media_(media),
matches_dirty_(true),
@@ -72,7 +72,7 @@ bool MediaQueryList::HasPendingActivity() const {
(listeners_.size() || HasEventListeners(event_type_names::kChange));
}
-void MediaQueryList::ContextDestroyed(ExecutionContext*) {
+void MediaQueryList::ContextDestroyed() {
listeners_.clear();
RemoveAllEventListeners();
}
@@ -102,11 +102,11 @@ bool MediaQueryList::matches() {
return matches_;
}
-void MediaQueryList::Trace(blink::Visitor* visitor) {
+void MediaQueryList::Trace(Visitor* visitor) {
visitor->Trace(matcher_);
visitor->Trace(listeners_);
EventTargetWithInlineData::Trace(visitor);
- ContextLifecycleObserver::Trace(visitor);
+ ExecutionContextLifecycleObserver::Trace(visitor);
}
const AtomicString& MediaQueryList::InterfaceName() const {
@@ -114,7 +114,7 @@ const AtomicString& MediaQueryList::InterfaceName() const {
}
ExecutionContext* MediaQueryList::GetExecutionContext() const {
- return ContextLifecycleObserver::GetExecutionContext();
+ return ExecutionContextLifecycleObserver::GetExecutionContext();
}
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/media_query_list.h b/chromium/third_party/blink/renderer/core/css/media_query_list.h
index 1d5b593a070..c09f4fcc05b 100644
--- a/chromium/third_party/blink/renderer/core/css/media_query_list.h
+++ b/chromium/third_party/blink/renderer/core/css/media_query_list.h
@@ -24,7 +24,7 @@
#include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/dom/events/event_target.h"
-#include "third_party/blink/renderer/core/execution_context/context_lifecycle_observer.h"
+#include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
@@ -45,7 +45,7 @@ class MediaQuerySet;
class CORE_EXPORT MediaQueryList final
: public EventTargetWithInlineData,
public ActiveScriptWrappable<MediaQueryList>,
- public ContextLifecycleObserver {
+ public ExecutionContextLifecycleObserver {
DEFINE_WRAPPERTYPEINFO();
USING_GARBAGE_COLLECTED_MIXIN(MediaQueryList);
@@ -74,13 +74,13 @@ class CORE_EXPORT MediaQueryList final
bool MediaFeaturesChanged(
HeapVector<Member<MediaQueryListListener>>* listeners_to_notify);
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
// From ScriptWrappable
bool HasPendingActivity() const final;
- // From ContextLifecycleObserver
- void ContextDestroyed(ExecutionContext*) override;
+ // From ExecutionContextLifecycleObserver
+ void ContextDestroyed() override;
const AtomicString& InterfaceName() const override;
ExecutionContext* GetExecutionContext() const override;
diff --git a/chromium/third_party/blink/renderer/core/css/media_query_list_event.h b/chromium/third_party/blink/renderer/core/css/media_query_list_event.h
index f09b3f7053f..f9c0643b0b2 100644
--- a/chromium/third_party/blink/renderer/core/css/media_query_list_event.h
+++ b/chromium/third_party/blink/renderer/core/css/media_query_list_event.h
@@ -5,8 +5,8 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_MEDIA_QUERY_LIST_EVENT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_MEDIA_QUERY_LIST_EVENT_H_
+#include "third_party/blink/renderer/bindings/core/v8/v8_media_query_list_event_init.h"
#include "third_party/blink/renderer/core/css/media_query_list.h"
-#include "third_party/blink/renderer/core/css/media_query_list_event_init.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/event_interface_names.h"
@@ -65,7 +65,7 @@ class MediaQueryListEvent final : public Event {
return true;
}
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
Event::Trace(visitor);
visitor->Trace(media_query_list_);
}
diff --git a/chromium/third_party/blink/renderer/core/css/media_query_list_event.idl b/chromium/third_party/blink/renderer/core/css/media_query_list_event.idl
index fdc30d5f4fb..2a2ae62692e 100644
--- a/chromium/third_party/blink/renderer/core/css/media_query_list_event.idl
+++ b/chromium/third_party/blink/renderer/core/css/media_query_list_event.idl
@@ -5,9 +5,9 @@
// https://drafts.csswg.org/cssom-view/#mediaquerylistevent
[
- Exposed=Window,
- Constructor(DOMString type, optional MediaQueryListEventInit eventInitDict)
+ Exposed=Window
] interface MediaQueryListEvent : Event {
+ constructor(DOMString type, optional MediaQueryListEventInit eventInitDict = {});
readonly attribute DOMString media;
readonly attribute boolean matches;
};
diff --git a/chromium/third_party/blink/renderer/core/css/media_query_list_listener.h b/chromium/third_party/blink/renderer/core/css/media_query_list_listener.h
index b589a88ea73..d448990a9ce 100644
--- a/chromium/third_party/blink/renderer/core/css/media_query_list_listener.h
+++ b/chromium/third_party/blink/renderer/core/css/media_query_list_listener.h
@@ -32,7 +32,7 @@ class CORE_EXPORT MediaQueryListListener
public:
virtual void NotifyMediaQueryChanged() = 0;
- virtual void Trace(blink::Visitor* visitor) {}
+ virtual void Trace(Visitor* visitor) {}
protected:
MediaQueryListListener();
diff --git a/chromium/third_party/blink/renderer/core/css/media_query_list_test.cc b/chromium/third_party/blink/renderer/core/css/media_query_list_test.cc
index 68cdeaa9580..85d8002d66b 100644
--- a/chromium/third_party/blink/renderer/core/css/media_query_list_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/media_query_list_test.cc
@@ -25,10 +25,11 @@ class TestListener : public MediaQueryListListener {
TEST(MediaQueryListTest, CrashInStop) {
auto* document = MakeGarbageCollected<Document>();
auto* list = MakeGarbageCollected<MediaQueryList>(
- document, MakeGarbageCollected<MediaQueryMatcher>(*document),
+ document->GetExecutionContext(),
+ MakeGarbageCollected<MediaQueryMatcher>(*document),
MediaQuerySet::Create());
list->AddListener(MakeGarbageCollected<TestListener>());
- list->ContextDestroyed(document);
+ list->ContextDestroyed();
// This test passes if it's not crashed.
}
diff --git a/chromium/third_party/blink/renderer/core/css/media_query_matcher.cc b/chromium/third_party/blink/renderer/core/css/media_query_matcher.cc
index e532d32634f..d3685e88d86 100644
--- a/chromium/third_party/blink/renderer/core/css/media_query_matcher.cc
+++ b/chromium/third_party/blink/renderer/core/css/media_query_matcher.cc
@@ -71,8 +71,10 @@ MediaQueryList* MediaQueryMatcher::MatchMedia(const String& query) {
if (!document_)
return nullptr;
- scoped_refptr<MediaQuerySet> media = MediaQuerySet::Create(query);
- return MakeGarbageCollected<MediaQueryList>(document_, this, media);
+ scoped_refptr<MediaQuerySet> media =
+ MediaQuerySet::Create(query, document_->GetExecutionContext());
+ return MakeGarbageCollected<MediaQueryList>(document_->GetExecutionContext(),
+ this, media);
}
void MediaQueryMatcher::AddMediaQueryList(MediaQueryList* query) {
@@ -126,7 +128,7 @@ void MediaQueryMatcher::ViewportChanged() {
document_->EnqueueMediaQueryChangeListeners(listeners_to_notify);
}
-void MediaQueryMatcher::Trace(blink::Visitor* visitor) {
+void MediaQueryMatcher::Trace(Visitor* visitor) {
visitor->Trace(document_);
visitor->Trace(evaluator_);
visitor->Trace(media_lists_);
diff --git a/chromium/third_party/blink/renderer/core/css/media_query_matcher.h b/chromium/third_party/blink/renderer/core/css/media_query_matcher.h
index 818119762de..63412b1895d 100644
--- a/chromium/third_party/blink/renderer/core/css/media_query_matcher.h
+++ b/chromium/third_party/blink/renderer/core/css/media_query_matcher.h
@@ -42,8 +42,6 @@ class MediaQuerySet;
class CORE_EXPORT MediaQueryMatcher final
: public GarbageCollected<MediaQueryMatcher> {
public:
- static MediaQueryMatcher* Create(Document&);
-
explicit MediaQueryMatcher(Document&);
~MediaQueryMatcher();
@@ -61,7 +59,7 @@ class CORE_EXPORT MediaQueryMatcher final
void ViewportChanged();
bool Evaluate(const MediaQuerySet*);
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
MediaQueryEvaluator* CreateEvaluator() const;
diff --git a/chromium/third_party/blink/renderer/core/css/media_query_matcher_test.cc b/chromium/third_party/blink/renderer/core/css/media_query_matcher_test.cc
index 76cba48fc9b..4d3cef4436c 100644
--- a/chromium/third_party/blink/renderer/core/css/media_query_matcher_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/media_query_matcher_test.cc
@@ -17,7 +17,7 @@ TEST(MediaQueryMatcherTest, LostFrame) {
auto* matcher =
MakeGarbageCollected<MediaQueryMatcher>(page_holder->GetDocument());
scoped_refptr<MediaQuerySet> query_set =
- MediaQuerySet::Create(media_type_names::kAll);
+ MediaQuerySet::Create(media_type_names::kAll, nullptr);
ASSERT_TRUE(matcher->Evaluate(query_set.get()));
matcher->DocumentDetached();
diff --git a/chromium/third_party/blink/renderer/core/css/media_query_set_test.cc b/chromium/third_party/blink/renderer/core/css/media_query_set_test.cc
index 603ae1dec74..fc00218599b 100644
--- a/chromium/third_party/blink/renderer/core/css/media_query_set_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/media_query_set_test.cc
@@ -6,6 +6,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/css/media_list.h"
+#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
namespace blink {
@@ -184,7 +185,31 @@ TEST(MediaQuerySetTest, Basic) {
for (unsigned i = 0; test_cases[i].input; ++i) {
scoped_refptr<MediaQuerySet> query_set =
- MediaQuerySet::Create(test_cases[i].input);
+ MediaQuerySet::Create(test_cases[i].input, nullptr);
+ TestMediaQuery(test_cases[i], *query_set);
+ }
+}
+
+TEST(MediaQuerySetTest, BehindRuntimeFlag) {
+ ScopedMediaQueryShapeForTest shape_flag(false);
+ ScopedForcedColorsForTest forced_colors_flag(false);
+ ScopedMediaQueryNavigationControlsForTest navigation_controls_flag(false);
+
+ // The first string represents the input string, the second string represents
+ // the output string.
+ MediaQuerySetTestCase test_cases[] = {
+ {"(shape)", "not all"},
+ {"(forced-colors)", "not all"},
+ {"(navigation-controls)", "not all"},
+ {"(shape: rect)", "not all"},
+ {"(forced-colors: none)", "not all"},
+ {"(navigation-controls: none)", "not all"},
+ {nullptr, nullptr} // Do not remove the terminator line.
+ };
+
+ for (unsigned i = 0; test_cases[i].input; ++i) {
+ scoped_refptr<MediaQuerySet> query_set =
+ MediaQuerySet::Create(test_cases[i].input, nullptr);
TestMediaQuery(test_cases[i], *query_set);
}
}
diff --git a/chromium/third_party/blink/renderer/core/css/media_value_change.h b/chromium/third_party/blink/renderer/core/css/media_value_change.h
new file mode 100644
index 00000000000..4f161cc725f
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/media_value_change.h
@@ -0,0 +1,19 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_MEDIA_VALUE_CHANGE_H_
+#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_MEDIA_VALUE_CHANGE_H_
+
+namespace blink {
+
+enum class MediaValueChange {
+ // Viewport or device size changed. width/height/device-width/device-height.
+ kSize,
+ // Any other value which affect media query evaluations changed.
+ kOther,
+};
+
+} // namespace blink
+
+#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_MEDIA_VALUE_CHANGE_H_
diff --git a/chromium/third_party/blink/renderer/core/css/media_values.cc b/chromium/third_party/blink/renderer/core/css/media_values.cc
index f7c0484a11e..3ff366de0a8 100644
--- a/chromium/third_party/blink/renderer/core/css/media_values.cc
+++ b/chromium/third_party/blink/renderer/core/css/media_values.cc
@@ -20,7 +20,6 @@
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/page.h"
-#include "third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.h"
#include "third_party/blink/renderer/platform/graphics/color_space_gamut.h"
namespace blink {
@@ -139,13 +138,7 @@ blink::mojom::DisplayMode MediaValues::CalculateDisplayMode(LocalFrame* frame) {
}
bool MediaValues::CalculateThreeDEnabled(LocalFrame* frame) {
- DCHECK(frame);
- DCHECK(frame->ContentLayoutObject());
- DCHECK(frame->ContentLayoutObject()->Compositor());
- bool three_d_enabled = false;
- if (LayoutView* view = frame->ContentLayoutObject())
- three_d_enabled = view->Compositor()->HasAcceleratedCompositing();
- return three_d_enabled;
+ return frame->GetPage()->GetSettings().GetAcceleratedCompositingEnabled();
}
bool MediaValues::CalculateInImmersiveMode(LocalFrame* frame) {
diff --git a/chromium/third_party/blink/renderer/core/css/media_values.h b/chromium/third_party/blink/renderer/core/css/media_values.h
index 22d46d54110..9a774e643a6 100644
--- a/chromium/third_party/blink/renderer/core/css/media_values.h
+++ b/chromium/third_party/blink/renderer/core/css/media_values.h
@@ -28,7 +28,7 @@ PreferredColorScheme CSSValueIDToPreferredColorScheme(CSSValueID id);
class CORE_EXPORT MediaValues : public GarbageCollected<MediaValues> {
public:
virtual ~MediaValues() = default;
- virtual void Trace(blink::Visitor* visitor) {}
+ virtual void Trace(Visitor* visitor) {}
static MediaValues* CreateDynamicIfFrameExists(LocalFrame*);
virtual MediaValues* Copy() const = 0;
diff --git a/chromium/third_party/blink/renderer/core/css/media_values_dynamic.cc b/chromium/third_party/blink/renderer/core/css/media_values_dynamic.cc
index 6a1035ea3a5..0b80c39984c 100644
--- a/chromium/third_party/blink/renderer/core/css/media_values_dynamic.cc
+++ b/chromium/third_party/blink/renderer/core/css/media_values_dynamic.cc
@@ -168,7 +168,7 @@ bool MediaValuesDynamic::HasValues() const {
return frame_;
}
-void MediaValuesDynamic::Trace(blink::Visitor* visitor) {
+void MediaValuesDynamic::Trace(Visitor* visitor) {
visitor->Trace(frame_);
MediaValues::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/media_values_dynamic.h b/chromium/third_party/blink/renderer/core/css/media_values_dynamic.h
index 8b73c573a91..779a9fb4b8d 100644
--- a/chromium/third_party/blink/renderer/core/css/media_values_dynamic.h
+++ b/chromium/third_party/blink/renderer/core/css/media_values_dynamic.h
@@ -56,7 +56,7 @@ class CORE_EXPORT MediaValuesDynamic : public MediaValues {
bool HasValues() const override;
void OverrideViewportDimensions(double width, double height) override;
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
protected:
Member<LocalFrame> frame_;
diff --git a/chromium/third_party/blink/renderer/core/css/offscreen_font_selector.cc b/chromium/third_party/blink/renderer/core/css/offscreen_font_selector.cc
index 892abac0870..2042a1618e6 100644
--- a/chromium/third_party/blink/renderer/core/css/offscreen_font_selector.cc
+++ b/chromium/third_party/blink/renderer/core/css/offscreen_font_selector.cc
@@ -93,6 +93,12 @@ void OffscreenFontSelector::ReportSuccessfulFontFamilyMatch(
void OffscreenFontSelector::ReportFailedFontFamilyMatch(
const AtomicString& font_family_name) {}
+void OffscreenFontSelector::ReportSuccessfulLocalFontMatch(
+ const AtomicString& font_name) {}
+
+void OffscreenFontSelector::ReportFailedLocalFontMatch(
+ const AtomicString& font_name) {}
+
void OffscreenFontSelector::FontCacheInvalidated() {
font_face_cache_.IncrementVersion();
}
@@ -101,7 +107,7 @@ void OffscreenFontSelector::FontFaceInvalidated() {
FontCacheInvalidated();
}
-void OffscreenFontSelector::Trace(blink::Visitor* visitor) {
+void OffscreenFontSelector::Trace(Visitor* visitor) {
visitor->Trace(execution_context_);
visitor->Trace(font_face_cache_);
FontSelector::Trace(visitor);
diff --git a/chromium/third_party/blink/renderer/core/css/offscreen_font_selector.h b/chromium/third_party/blink/renderer/core/css/offscreen_font_selector.h
index e28be16abcb..0a32bc74468 100644
--- a/chromium/third_party/blink/renderer/core/css/offscreen_font_selector.h
+++ b/chromium/third_party/blink/renderer/core/css/offscreen_font_selector.h
@@ -34,6 +34,10 @@ class CORE_EXPORT OffscreenFontSelector : public FontSelector {
void ReportFailedFontFamilyMatch(
const AtomicString& font_family_name) override;
+ void ReportSuccessfulLocalFontMatch(const AtomicString& font_name) override;
+
+ void ReportFailedLocalFontMatch(const AtomicString& font_name) override;
+
scoped_refptr<FontData> GetFontData(const FontDescription&,
const AtomicString&) override;
void WillUseFontData(const FontDescription&,
@@ -65,7 +69,7 @@ class CORE_EXPORT OffscreenFontSelector : public FontSelector {
return execution_context_;
}
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
protected:
void DispatchInvalidationCallbacks();
diff --git a/chromium/third_party/blink/renderer/core/css/page_rule_collector.cc b/chromium/third_party/blink/renderer/core/css/page_rule_collector.cc
index ff844b883dd..0b20fc696dc 100644
--- a/chromium/third_party/blink/renderer/core/css/page_rule_collector.cc
+++ b/chromium/third_party/blink/renderer/core/css/page_rule_collector.cc
@@ -64,10 +64,12 @@ String PageRuleCollector::PageName(int /* pageIndex */) const {
}
PageRuleCollector::PageRuleCollector(const ComputedStyle* root_element_style,
- int page_index)
+ int page_index,
+ MatchResult& match_result)
: is_left_page_(IsLeftPage(root_element_style, page_index)),
is_first_page_(IsFirstPage(page_index)),
- page_name_(PageName(page_index)) {}
+ page_name_(PageName(page_index)),
+ result_(match_result) {}
void PageRuleCollector::MatchPageRules(RuleSet* rules) {
if (!rules)
diff --git a/chromium/third_party/blink/renderer/core/css/page_rule_collector.h b/chromium/third_party/blink/renderer/core/css/page_rule_collector.h
index 065618bdcc1..f8fe90eb998 100644
--- a/chromium/third_party/blink/renderer/core/css/page_rule_collector.h
+++ b/chromium/third_party/blink/renderer/core/css/page_rule_collector.h
@@ -34,7 +34,9 @@ class PageRuleCollector {
STACK_ALLOCATED();
public:
- PageRuleCollector(const ComputedStyle* root_element_style, int page_index);
+ PageRuleCollector(const ComputedStyle* root_element_style,
+ int page_index,
+ MatchResult&);
void MatchPageRules(RuleSet* rules);
const MatchResult& MatchedResult() { return result_; }
@@ -59,7 +61,7 @@ class PageRuleCollector {
const bool is_first_page_;
const String page_name_;
- MatchResult result_;
+ MatchResult& result_;
};
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/parser/at_rule_descriptor_parser.cc b/chromium/third_party/blink/renderer/core/css/parser/at_rule_descriptor_parser.cc
index ac9e91b9b56..78f9ce32541 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/at_rule_descriptor_parser.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/at_rule_descriptor_parser.cc
@@ -73,7 +73,7 @@ CSSValueList* ConsumeFontFaceUnicodeRange(CSSParserTokenRange& range) {
CSSValue* ConsumeFontFaceSrcURI(CSSParserTokenRange& range,
const CSSParserContext& context) {
String url =
- css_property_parser_helpers::ConsumeUrlAsStringView(range, &context)
+ css_property_parser_helpers::ConsumeUrlAsStringView(range, context)
.ToString();
if (url.IsNull())
return nullptr;
@@ -101,7 +101,7 @@ CSSValue* ConsumeFontFaceSrcLocal(CSSParserTokenRange& range,
const CSSParserContext& context) {
CSSParserTokenRange args =
css_property_parser_helpers::ConsumeFunction(range);
- ContentSecurityPolicyDisposition should_check_content_security_policy =
+ network::mojom::CSPDisposition should_check_content_security_policy =
context.ShouldCheckContentSecurityPolicy();
if (args.Peek().GetType() == kStringToken) {
const CSSParserToken& arg = args.ConsumeIncludingWhitespace();
@@ -165,23 +165,30 @@ CSSValue* AtRuleDescriptorParser::ParseFontFaceDescriptor(
case AtRuleDescriptorID::FontDisplay:
parsed_value = ConsumeFontDisplay(range);
break;
- case AtRuleDescriptorID::FontStretch:
- parsed_value =
- css_parsing_utils::ConsumeFontStretch(range, kCSSFontFaceRuleMode);
+ case AtRuleDescriptorID::FontStretch: {
+ CSSParserContext::ParserModeOverridingScope scope(context,
+ kCSSFontFaceRuleMode);
+ parsed_value = css_parsing_utils::ConsumeFontStretch(range, context);
break;
- case AtRuleDescriptorID::FontStyle:
- parsed_value =
- css_parsing_utils::ConsumeFontStyle(range, kCSSFontFaceRuleMode);
+ }
+ case AtRuleDescriptorID::FontStyle: {
+ CSSParserContext::ParserModeOverridingScope scope(context,
+ kCSSFontFaceRuleMode);
+ parsed_value = css_parsing_utils::ConsumeFontStyle(range, context);
break;
+ }
case AtRuleDescriptorID::FontVariant:
parsed_value = ConsumeFontVariantList(range);
break;
- case AtRuleDescriptorID::FontWeight:
- parsed_value =
- css_parsing_utils::ConsumeFontWeight(range, kCSSFontFaceRuleMode);
+ case AtRuleDescriptorID::FontWeight: {
+ CSSParserContext::ParserModeOverridingScope scope(context,
+ kCSSFontFaceRuleMode);
+ parsed_value = css_parsing_utils::ConsumeFontWeight(range, context);
break;
+ }
case AtRuleDescriptorID::FontFeatureSettings:
- parsed_value = css_parsing_utils::ConsumeFontFeatureSettings(range);
+ parsed_value =
+ css_parsing_utils::ConsumeFontFeatureSettings(range, context);
break;
default:
break;
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css.proto b/chromium/third_party/blink/renderer/core/css/parser/css.proto
index 8f3dcbf5979..973f7c865ad 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css.proto
+++ b/chromium/third_party/blink/renderer/core/css/parser/css.proto
@@ -952,501 +952,496 @@ message Property {
_WEBKIT_MASK_POSITION_X = 65;
_WEBKIT_MASK_POSITION_Y = 66;
OUTLINE_STYLE = 67;
- _WEBKIT_MARGIN_BOTTOM_COLLAPSE = 68;
- COLOR_INTERPOLATION_FILTERS = 69;
- FONT_VARIANT = 70;
- _WEBKIT_ANIMATION_FILL_MODE = 71;
- BORDER_RIGHT = 72;
- VISIBILITY = 73;
- TRANSFORM_BOX = 74;
- FONT_VARIANT_CAPS = 75;
- _EPUB_TEXT_EMPHASIS_COLOR = 76;
- _WEBKIT_BORDER_BEFORE_STYLE = 77;
- RESIZE = 78;
- _WEBKIT_RTL_ORDERING = 79;
- _WEBKIT_BOX_ORDINAL_GROUP = 80;
- PAINT_ORDER = 81;
- STROKE_LINECAP = 82;
- ANIMATION_DIRECTION = 83;
- _WEBKIT_FONT_FEATURE_SETTINGS = 84;
- BORDER_TOP_LEFT_RADIUS = 85;
- _WEBKIT_COLUMN_WIDTH = 86;
- _WEBKIT_BOX_ALIGN = 87;
- _WEBKIT_PADDING_AFTER = 88;
- COLUMN_WIDTH = 89;
- LIST_STYLE = 90;
- _WEBKIT_MASK_REPEAT_Y = 91;
- _WEBKIT_MARGIN_BEFORE_COLLAPSE = 92;
- STROKE = 93;
- TEXT_DECORATION_LINE = 94;
- _WEBKIT_BACKGROUND_SIZE = 95;
- _WEBKIT_MASK_REPEAT_X = 96;
- PADDING_BOTTOM = 97;
- FONT_STYLE = 98;
- _WEBKIT_TRANSITION_DELAY = 99;
- BACKGROUND_REPEAT = 100;
- FLEX_BASIS = 101;
- BORDER_IMAGE_SLICE = 102;
- _WEBKIT_TRANSFORM_ORIGIN = 103;
- SCROLL_BOUNDARY_BEHAVIOR_X = 104;
- SCROLL_BOUNDARY_BEHAVIOR_Y = 105;
- VECTOR_EFFECT = 106;
- _WEBKIT_ANIMATION_TIMING_FUNCTION = 107;
- _WEBKIT_BORDER_AFTER_STYLE = 108;
- _WEBKIT_PERSPECTIVE_ORIGIN_X = 109;
- _WEBKIT_PERSPECTIVE_ORIGIN_Y = 110;
- INLINE_SIZE = 111;
- OUTLINE = 112;
- FONT_DISPLAY = 113;
- _WEBKIT_BORDER_BEFORE = 114;
- BORDER_IMAGE_SOURCE = 115;
- TRANSITION_DURATION = 116;
- SCROLL_PADDING_TOP = 117;
- ORDER = 118;
- _WEBKIT_BOX_ORIENT = 119;
- COUNTER_RESET = 120;
- COLOR_RENDERING = 121;
- FLEX_DIRECTION = 122;
- _WEBKIT_TEXT_STROKE_WIDTH = 123;
- FONT_VARIANT_NUMERIC = 124;
- SCROLL_MARGIN_BLOCK_END = 125;
- MIN_HEIGHT = 126;
- SCROLL_PADDING_INLINE_START = 127;
- _WEBKIT_MASK_BOX_IMAGE = 128;
- LEFT = 129;
- _WEBKIT_MASK = 130;
- _WEBKIT_BORDER_AFTER_WIDTH = 131;
- STROKE_WIDTH = 132;
- _WEBKIT_BOX_DECORATION_BREAK = 133;
- _WEBKIT_MASK_POSITION = 134;
- BACKGROUND_ORIGIN = 135;
- _WEBKIT_BORDER_START_COLOR = 136;
- FONT_STRETCH = 137;
- _WEBKIT_BACKGROUND_CLIP = 138;
- SCROLL_MARGIN_TOP = 139;
- _WEBKIT_BORDER_HORIZONTAL_SPACING = 140;
- BORDER_RADIUS = 141;
- FLEX = 142;
- TEXT_INDENT = 143;
- HYPHENS = 144;
- COLUMN_RULE_WIDTH = 145;
- _WEBKIT_MARGIN_AFTER = 146;
- _EPUB_CAPTION_SIDE = 147;
- BREAK_AFTER = 148;
- TEXT_TRANSFORM = 149;
- TOUCH_ACTION = 150;
- FONT_SIZE = 151;
- _WEBKIT_ANIMATION_NAME = 152;
- SCROLL_PADDING_INLINE = 153;
- OFFSET_PATH = 154;
- SCROLL_MARGIN = 155;
- PADDING_TOP = 156;
- SCROLL_SNAP_ALIGN = 157;
- _WEBKIT_TEXT_COMBINE = 158;
- _WEBKIT_FLEX_SHRINK = 159;
- RX = 160;
- RY = 161;
- CONTENT = 162;
- PADDING_RIGHT = 163;
- _WEBKIT_TRANSFORM = 164;
- MARKER_MID = 165;
- _WEBKIT_MIN_LOGICAL_WIDTH = 166;
- CLIP_RULE = 167;
- FONT_FAMILY = 168;
- SCROLL_SNAP_TYPE = 169;
- TEXT_DECORATION_SKIP_INK = 170;
- TRANSITION = 171;
- FILTER = 172;
- BORDER_RIGHT_WIDTH = 173;
- _WEBKIT_FLEX_DIRECTION = 174;
- _WEBKIT_MASK_COMPOSITE = 175;
- MIX_BLEND_MODE = 176;
- COLOR_INTERPOLATION = 177;
- BORDER_TOP_STYLE = 178;
- FILL_OPACITY = 179;
- MARKER_START = 180;
- BORDER_BOTTOM_WIDTH = 181;
- _WEBKIT_TEXT_EMPHASIS = 182;
- GRID_AREA = 183;
- SIZE = 184;
- BACKGROUND_CLIP = 185;
- _WEBKIT_TEXT_FILL_COLOR = 186;
- TOP = 187;
- _WEBKIT_BOX_REFLECT = 188;
- BORDER_WIDTH = 189;
- OFFSET_ANCHOR = 190;
- MAX_INLINE_SIZE = 191;
- _WEBKIT_COLUMN_RULE_STYLE = 192;
- _WEBKIT_COLUMN_COUNT = 193;
- ANIMATION_PLAY_STATE = 194;
- PADDING = 195;
- DOMINANT_BASELINE = 196;
- BACKGROUND_ATTACHMENT = 197;
- _WEBKIT_BOX_SIZING = 198;
- _WEBKIT_BOX_FLEX = 199;
- TEXT_ORIENTATION = 200;
- BACKGROUND_POSITION = 201;
- _WEBKIT_BORDER_START_WIDTH = 202;
- _EPUB_TEXT_EMPHASIS_STYLE = 203;
- ISOLATION = 204;
- _EPUB_TEXT_ORIENTATION = 205;
- _WEBKIT_BORDER_BOTTOM_RIGHT_RADIUS = 206;
- R = 207;
- BORDER_LEFT_WIDTH = 208;
- GRID_COLUMN_END = 209;
- BACKGROUND_BLEND_MODE = 210;
- VERTICAL_ALIGN = 211;
- CLIP = 212;
- GRID_AUTO_ROWS = 213;
- OFFSET_ROTATE = 214;
- MARGIN_LEFT = 215;
- ANIMATION_NAME = 216;
- TEXT_DECORATION = 217;
- BORDER = 218;
- _WEBKIT_TRANSITION_TIMING_FUNCTION = 219;
- MARGIN_BOTTOM = 220;
- UNICODE_RANGE = 221;
- ANIMATION = 222;
- _WEBKIT_SHAPE_MARGIN = 223;
- FONT_WEIGHT = 224;
- SHAPE_MARGIN = 225;
- MASK_TYPE = 226;
- SCROLL_PADDING = 227;
- MIN_INLINE_SIZE = 228;
- OBJECT_POSITION = 229;
- PAGE_BREAK_AFTER = 230;
- _WEBKIT_MASK_CLIP = 231;
- WHITE_SPACE = 232;
- _WEBKIT_BORDER_AFTER_COLOR = 233;
- _WEBKIT_MAX_LOGICAL_WIDTH = 234;
- _WEBKIT_BORDER_BEFORE_COLOR = 235;
- FONT_KERNING = 236;
- _EPUB_WORD_BREAK = 237;
- CLEAR = 238;
- ANIMATION_TIMING_FUNCTION = 239;
- _WEBKIT_BORDER_RADIUS = 240;
- SCROLL_PADDING_RIGHT = 241;
- _WEBKIT_TEXT_DECORATIONS_IN_EFFECT = 242;
- _WEBKIT_ANIMATION_DIRECTION = 243;
- JUSTIFY_SELF = 244;
- TRANSITION_TIMING_FUNCTION = 245;
- SCROLL_SNAP_STOP = 246;
- COUNTER_INCREMENT = 247;
- _WEBKIT_TRANSFORM_STYLE = 248;
- GRID_AUTO_COLUMNS = 249;
- _WEBKIT_ALIGN_CONTENT = 250;
- FONT = 251;
- FLEX_WRAP = 252;
- GRID_ROW_START = 253;
- LIST_STYLE_IMAGE = 254;
- _WEBKIT_TAP_HIGHLIGHT_COLOR = 255;
- _WEBKIT_TEXT_EMPHASIS_COLOR = 256;
- BORDER_LEFT = 257;
- _WEBKIT_BORDER_END_COLOR = 258;
- COLUMNS = 259;
- BOX_SHADOW = 260;
- _WEBKIT_FLEX_WRAP = 261;
- ALIGN_SELF = 262;
- BORDER_BOTTOM = 263;
- BORDER_SPACING = 264;
- _WEBKIT_COLUMN_SPAN = 265;
- GRID_ROW_END = 266;
- _WEBKIT_BORDER_END = 267;
- PERSPECTIVE_ORIGIN = 268;
- PAGE_BREAK_INSIDE = 269;
- ORPHANS = 270;
- _WEBKIT_BORDER_START_STYLE = 271;
- SCROLL_BEHAVIOR = 272;
- COLUMN_SPAN = 273;
- _WEBKIT_HYPHENATE_CHARACTER = 274;
- COLUMN_FILL = 275;
- TAB_SIZE = 276;
- CONTAIN = 277;
- X = 278;
- GRID_ROW = 279;
- BORDER_BOTTOM_RIGHT_RADIUS = 280;
- LINE_HEIGHT = 281;
- STROKE_LINEJOIN = 282;
- TEXT_ALIGN_LAST = 283;
- OFFSET_POSITION = 284;
- WORD_SPACING = 285;
- TRANSFORM_STYLE = 286;
- _WEBKIT_APP_REGION = 287;
- _WEBKIT_BORDER_END_STYLE = 288;
- _WEBKIT_TRANSFORM_ORIGIN_Z = 289;
- _WEBKIT_TRANSFORM_ORIGIN_X = 290;
- _WEBKIT_TRANSFORM_ORIGIN_Y = 291;
- BACKGROUND_REPEAT_X = 292;
- BACKGROUND_REPEAT_Y = 293;
- BORDER_BOTTOM_COLOR = 294;
- _WEBKIT_RUBY_POSITION = 295;
- _WEBKIT_LOGICAL_WIDTH = 296;
- TEXT_JUSTIFY = 297;
- SCROLL_MARGIN_INLINE_START = 298;
- CAPTION_SIDE = 299;
- MASK_SOURCE_TYPE = 300;
- _WEBKIT_MASK_BOX_IMAGE_SLICE = 301;
- _WEBKIT_BORDER_IMAGE = 302;
- TEXT_SIZE_ADJUST = 303;
- _WEBKIT_TEXT_SECURITY = 304;
- _EPUB_WRITING_MODE = 305;
- GRID_TEMPLATE = 306;
- _WEBKIT_MASK_BOX_IMAGE_REPEAT = 307;
- _WEBKIT_MASK_REPEAT = 308;
- _WEBKIT_JUSTIFY_CONTENT = 309;
- BASELINE_SHIFT = 310;
- BORDER_IMAGE = 311;
- TEXT_DECORATION_COLOR = 312;
- COLOR = 313;
- SHAPE_IMAGE_THRESHOLD = 314;
- SHAPE_RENDERING = 315;
- CY = 316;
- CX = 317;
- _WEBKIT_USER_MODIFY = 318;
- OFFSET_DISTANCE = 319;
- _WEBKIT_BORDER_BOTTOM_LEFT_RADIUS = 320;
- SPEAK = 321;
- BORDER_BOTTOM_LEFT_RADIUS = 322;
- _WEBKIT_COLUMN_BREAK_AFTER = 323;
- _WEBKIT_FONT_SMOOTHING = 324;
- _WEBKIT_MAX_LOGICAL_HEIGHT = 325;
- _WEBKIT_LINE_BREAK = 326;
- FILL_RULE = 327;
- _WEBKIT_MARGIN_START = 328;
- MIN_WIDTH = 329;
- _EPUB_TEXT_COMBINE = 330;
- BREAK_BEFORE = 331;
- CARET_COLOR = 332;
- EMPTY_CELLS = 333;
- DIRECTION = 334;
- CLIP_PATH = 335;
- JUSTIFY_CONTENT = 336;
- SCROLL_PADDING_BLOCK_END = 337;
- Z_INDEX = 338;
- BACKGROUND_POSITION_Y = 339;
- TEXT_DECORATION_STYLE = 340;
- GRID_TEMPLATE_AREAS = 341;
- _WEBKIT_MIN_LOGICAL_HEIGHT = 342;
- FONT_SIZE_ADJUST = 343;
- SCROLL_PADDING_BLOCK = 344;
- OVERFLOW_ANCHOR = 345;
- CURSOR = 346;
- SCROLL_MARGIN_BLOCK_START = 347;
- _WEBKIT_MASK_BOX_IMAGE_SOURCE = 348;
- MARGIN = 349;
- _WEBKIT_ANIMATION = 350;
- LETTER_SPACING = 351;
- ORIENTATION = 352;
- WILL_CHANGE = 353;
- _WEBKIT_HIGHLIGHT = 354;
- TRANSFORM_ORIGIN = 355;
- FONT_VARIANT_LIGATURES = 356;
- _WEBKIT_ANIMATION_DURATION = 357;
- _WEBKIT_MASK_ORIGIN = 358;
- _WEBKIT_CLIP_PATH = 359;
- WORD_BREAK = 360;
- TABLE_LAYOUT = 361;
- TEXT_OVERFLOW = 362;
- _WEBKIT_LOCALE = 363;
- _WEBKIT_FLEX = 364;
- GRID_AUTO_FLOW = 365;
- BORDER_TOP_RIGHT_RADIUS = 366;
- BORDER_IMAGE_OUTSET = 367;
- PLACE_ITEMS = 368;
- BORDER_LEFT_COLOR = 369;
- FONT_VARIATION_SETTINGS = 370;
- BORDER_RIGHT_COLOR = 371;
- MIN_ZOOM = 372;
- SCROLL_MARGIN_INLINE = 373;
- _WEBKIT_BORDER_BEFORE_WIDTH = 374;
- BACKFACE_VISIBILITY = 375;
- BACKGROUND_IMAGE = 376;
- _WEBKIT_TRANSITION_PROPERTY = 377;
- WRITING_MODE = 378;
- STROKE_OPACITY = 379;
- _WEBKIT_MARGIN_COLLAPSE = 380;
- BOX_SIZING = 381;
- MARGIN_TOP = 382;
- COLUMN_RULE_COLOR = 383;
- Y = 384;
- POSITION = 385;
- SCROLL_MARGIN_BOTTOM = 386;
- LIST_STYLE_POSITION = 387;
- _WEBKIT_BOX_PACK = 388;
- SCROLL_PADDING_INLINE_END = 389;
- QUOTES = 390;
- BORDER_TOP = 391;
- SCROLL_PADDING_LEFT = 392;
- _WEBKIT_TRANSITION = 393;
- _WEBKIT_COLUMN_BREAK_BEFORE = 394;
- LIGHTING_COLOR = 395;
- BACKGROUND_SIZE = 396;
- _WEBKIT_PADDING_BEFORE = 397;
- _WEBKIT_BORDER_TOP_LEFT_RADIUS = 398;
- FLOOD_OPACITY = 399;
- LINE_HEIGHT_STEP = 400;
- _WEBKIT_MASK_SIZE = 401;
- TEXT_ALIGN = 402;
- _WEBKIT_FILTER = 403;
- WORD_WRAP = 404;
- MAX_ZOOM = 405;
- GRID = 406;
- BACKGROUND = 407;
- HEIGHT = 408;
- GRID_COLUMN_START = 409;
- ANIMATION_FILL_MODE = 410;
- ROTATE = 411;
- MARKER_END = 412;
- D = 413;
- JUSTIFY_ITEMS = 414;
- ZOOM = 415;
- SCROLL_PADDING_BLOCK_START = 416;
- _WEBKIT_MARGIN_TOP_COLLAPSE = 417;
- PAGE = 418;
- RIGHT = 419;
- USER_SELECT = 420;
- MARGIN_RIGHT = 421;
- MARKER = 422;
- LINE_BREAK = 423;
- _WEBKIT_MARGIN_END = 424;
- _WEBKIT_TRANSITION_DURATION = 425;
- _WEBKIT_WRITING_MODE = 426;
- BORDER_TOP_WIDTH = 427;
- BOTTOM = 428;
- PLACE_CONTENT = 429;
- _WEBKIT_SHAPE_IMAGE_THRESHOLD = 430;
- _WEBKIT_USER_DRAG = 431;
- _WEBKIT_BORDER_VERTICAL_SPACING = 432;
- _WEBKIT_COLUMN_GAP = 433;
- _WEBKIT_OPACITY = 434;
- BACKGROUND_COLOR = 435;
- COLUMN_GAP = 436;
- SHAPE_OUTSIDE = 437;
- _WEBKIT_PADDING_END = 438;
- _WEBKIT_BORDER_START = 439;
- ANIMATION_DELAY = 440;
- UNICODE_BIDI = 441;
- TEXT_SHADOW = 442;
- _WEBKIT_BOX_DIRECTION = 443;
- IMAGE_RENDERING = 444;
- SRC = 445;
- GAP = 446;
- GRID_GAP = 447;
- POINTER_EVENTS = 448;
- BORDER_IMAGE_WIDTH = 449;
- MIN_BLOCK_SIZE = 450;
- TRANSITION_PROPERTY = 451;
- _WEBKIT_MASK_IMAGE = 452;
- FLOAT = 453;
- MAX_HEIGHT = 454;
- OUTLINE_OFFSET = 455;
- _WEBKIT_BOX_SHADOW = 456;
- OVERFLOW_WRAP = 457;
- BLOCK_SIZE = 458;
- TRANSFORM = 459;
- PLACE_SELF = 460;
- WIDTH = 461;
- STROKE_MITERLIMIT = 462;
- STOP_OPACITY = 463;
- BORDER_TOP_COLOR = 464;
- TRANSLATE = 465;
- OBJECT_FIT = 466;
- _WEBKIT_MASK_BOX_IMAGE_WIDTH = 467;
- _WEBKIT_BACKGROUND_ORIGIN = 468;
- _WEBKIT_ALIGN_ITEMS = 469;
- TRANSITION_DELAY = 470;
- SCROLL_MARGIN_LEFT = 471;
- BORDER_STYLE = 472;
- ANIMATION_ITERATION_COUNT = 473;
- _WEBKIT_MARGIN_AFTER_COLLAPSE = 474;
+ COLOR_INTERPOLATION_FILTERS = 68;
+ FONT_VARIANT = 69;
+ _WEBKIT_ANIMATION_FILL_MODE = 70;
+ BORDER_RIGHT = 71;
+ VISIBILITY = 72;
+ TRANSFORM_BOX = 73;
+ FONT_VARIANT_CAPS = 74;
+ _EPUB_TEXT_EMPHASIS_COLOR = 75;
+ _WEBKIT_BORDER_BEFORE_STYLE = 76;
+ RESIZE = 77;
+ _WEBKIT_RTL_ORDERING = 78;
+ _WEBKIT_BOX_ORDINAL_GROUP = 79;
+ PAINT_ORDER = 80;
+ STROKE_LINECAP = 81;
+ ANIMATION_DIRECTION = 82;
+ _WEBKIT_FONT_FEATURE_SETTINGS = 83;
+ BORDER_TOP_LEFT_RADIUS = 84;
+ _WEBKIT_COLUMN_WIDTH = 85;
+ _WEBKIT_BOX_ALIGN = 86;
+ _WEBKIT_PADDING_AFTER = 87;
+ COLUMN_WIDTH = 88;
+ LIST_STYLE = 89;
+ _WEBKIT_MASK_REPEAT_Y = 90;
+ STROKE = 91;
+ TEXT_DECORATION_LINE = 92;
+ _WEBKIT_BACKGROUND_SIZE = 93;
+ _WEBKIT_MASK_REPEAT_X = 94;
+ PADDING_BOTTOM = 95;
+ FONT_STYLE = 96;
+ _WEBKIT_TRANSITION_DELAY = 97;
+ BACKGROUND_REPEAT = 98;
+ FLEX_BASIS = 99;
+ BORDER_IMAGE_SLICE = 100;
+ _WEBKIT_TRANSFORM_ORIGIN = 101;
+ SCROLL_BOUNDARY_BEHAVIOR_X = 102;
+ SCROLL_BOUNDARY_BEHAVIOR_Y = 103;
+ VECTOR_EFFECT = 104;
+ _WEBKIT_ANIMATION_TIMING_FUNCTION = 105;
+ _WEBKIT_BORDER_AFTER_STYLE = 106;
+ _WEBKIT_PERSPECTIVE_ORIGIN_X = 107;
+ _WEBKIT_PERSPECTIVE_ORIGIN_Y = 108;
+ INLINE_SIZE = 109;
+ OUTLINE = 110;
+ FONT_DISPLAY = 111;
+ _WEBKIT_BORDER_BEFORE = 112;
+ BORDER_IMAGE_SOURCE = 113;
+ TRANSITION_DURATION = 114;
+ SCROLL_PADDING_TOP = 115;
+ ORDER = 116;
+ _WEBKIT_BOX_ORIENT = 117;
+ COUNTER_RESET = 118;
+ COLOR_RENDERING = 119;
+ FLEX_DIRECTION = 120;
+ _WEBKIT_TEXT_STROKE_WIDTH = 121;
+ FONT_VARIANT_NUMERIC = 122;
+ SCROLL_MARGIN_BLOCK_END = 123;
+ MIN_HEIGHT = 124;
+ SCROLL_PADDING_INLINE_START = 125;
+ _WEBKIT_MASK_BOX_IMAGE = 126;
+ LEFT = 127;
+ _WEBKIT_MASK = 128;
+ _WEBKIT_BORDER_AFTER_WIDTH = 129;
+ STROKE_WIDTH = 130;
+ _WEBKIT_BOX_DECORATION_BREAK = 131;
+ _WEBKIT_MASK_POSITION = 132;
+ BACKGROUND_ORIGIN = 133;
+ _WEBKIT_BORDER_START_COLOR = 134;
+ FONT_STRETCH = 135;
+ _WEBKIT_BACKGROUND_CLIP = 136;
+ SCROLL_MARGIN_TOP = 137;
+ _WEBKIT_BORDER_HORIZONTAL_SPACING = 138;
+ BORDER_RADIUS = 139;
+ FLEX = 140;
+ TEXT_INDENT = 141;
+ HYPHENS = 142;
+ COLUMN_RULE_WIDTH = 143;
+ _WEBKIT_MARGIN_AFTER = 144;
+ _EPUB_CAPTION_SIDE = 145;
+ BREAK_AFTER = 146;
+ TEXT_TRANSFORM = 147;
+ TOUCH_ACTION = 148;
+ FONT_SIZE = 149;
+ _WEBKIT_ANIMATION_NAME = 150;
+ SCROLL_PADDING_INLINE = 151;
+ OFFSET_PATH = 152;
+ SCROLL_MARGIN = 153;
+ PADDING_TOP = 154;
+ SCROLL_SNAP_ALIGN = 155;
+ _WEBKIT_TEXT_COMBINE = 156;
+ _WEBKIT_FLEX_SHRINK = 157;
+ RX = 158;
+ RY = 159;
+ CONTENT = 160;
+ PADDING_RIGHT = 161;
+ _WEBKIT_TRANSFORM = 162;
+ MARKER_MID = 163;
+ _WEBKIT_MIN_LOGICAL_WIDTH = 164;
+ CLIP_RULE = 165;
+ FONT_FAMILY = 166;
+ SCROLL_SNAP_TYPE = 167;
+ TEXT_DECORATION_SKIP_INK = 168;
+ TRANSITION = 169;
+ FILTER = 170;
+ BORDER_RIGHT_WIDTH = 171;
+ _WEBKIT_FLEX_DIRECTION = 172;
+ _WEBKIT_MASK_COMPOSITE = 173;
+ MIX_BLEND_MODE = 174;
+ COLOR_INTERPOLATION = 175;
+ BORDER_TOP_STYLE = 176;
+ FILL_OPACITY = 177;
+ MARKER_START = 178;
+ BORDER_BOTTOM_WIDTH = 179;
+ _WEBKIT_TEXT_EMPHASIS = 180;
+ GRID_AREA = 181;
+ SIZE = 182;
+ BACKGROUND_CLIP = 183;
+ _WEBKIT_TEXT_FILL_COLOR = 184;
+ TOP = 185;
+ _WEBKIT_BOX_REFLECT = 186;
+ BORDER_WIDTH = 187;
+ OFFSET_ANCHOR = 188;
+ MAX_INLINE_SIZE = 189;
+ _WEBKIT_COLUMN_RULE_STYLE = 190;
+ _WEBKIT_COLUMN_COUNT = 191;
+ ANIMATION_PLAY_STATE = 192;
+ PADDING = 193;
+ DOMINANT_BASELINE = 194;
+ BACKGROUND_ATTACHMENT = 195;
+ _WEBKIT_BOX_SIZING = 196;
+ _WEBKIT_BOX_FLEX = 197;
+ TEXT_ORIENTATION = 198;
+ BACKGROUND_POSITION = 199;
+ _WEBKIT_BORDER_START_WIDTH = 200;
+ _EPUB_TEXT_EMPHASIS_STYLE = 201;
+ ISOLATION = 202;
+ _EPUB_TEXT_ORIENTATION = 203;
+ _WEBKIT_BORDER_BOTTOM_RIGHT_RADIUS = 204;
+ R = 205;
+ BORDER_LEFT_WIDTH = 206;
+ GRID_COLUMN_END = 207;
+ BACKGROUND_BLEND_MODE = 208;
+ VERTICAL_ALIGN = 209;
+ CLIP = 210;
+ GRID_AUTO_ROWS = 211;
+ OFFSET_ROTATE = 212;
+ MARGIN_LEFT = 213;
+ ANIMATION_NAME = 214;
+ TEXT_DECORATION = 215;
+ BORDER = 216;
+ _WEBKIT_TRANSITION_TIMING_FUNCTION = 217;
+ MARGIN_BOTTOM = 218;
+ UNICODE_RANGE = 219;
+ ANIMATION = 220;
+ _WEBKIT_SHAPE_MARGIN = 221;
+ FONT_WEIGHT = 222;
+ SHAPE_MARGIN = 223;
+ MASK_TYPE = 224;
+ SCROLL_PADDING = 225;
+ MIN_INLINE_SIZE = 226;
+ OBJECT_POSITION = 227;
+ PAGE_BREAK_AFTER = 228;
+ _WEBKIT_MASK_CLIP = 229;
+ WHITE_SPACE = 230;
+ _WEBKIT_BORDER_AFTER_COLOR = 231;
+ _WEBKIT_MAX_LOGICAL_WIDTH = 232;
+ _WEBKIT_BORDER_BEFORE_COLOR = 233;
+ FONT_KERNING = 234;
+ _EPUB_WORD_BREAK = 235;
+ CLEAR = 236;
+ ANIMATION_TIMING_FUNCTION = 237;
+ _WEBKIT_BORDER_RADIUS = 238;
+ SCROLL_PADDING_RIGHT = 239;
+ _WEBKIT_TEXT_DECORATIONS_IN_EFFECT = 240;
+ _WEBKIT_ANIMATION_DIRECTION = 241;
+ JUSTIFY_SELF = 242;
+ TRANSITION_TIMING_FUNCTION = 243;
+ SCROLL_SNAP_STOP = 244;
+ COUNTER_INCREMENT = 245;
+ _WEBKIT_TRANSFORM_STYLE = 246;
+ GRID_AUTO_COLUMNS = 247;
+ _WEBKIT_ALIGN_CONTENT = 248;
+ FONT = 249;
+ FLEX_WRAP = 250;
+ GRID_ROW_START = 251;
+ LIST_STYLE_IMAGE = 252;
+ _WEBKIT_TAP_HIGHLIGHT_COLOR = 253;
+ _WEBKIT_TEXT_EMPHASIS_COLOR = 254;
+ BORDER_LEFT = 255;
+ _WEBKIT_BORDER_END_COLOR = 256;
+ COLUMNS = 257;
+ BOX_SHADOW = 258;
+ _WEBKIT_FLEX_WRAP = 259;
+ ALIGN_SELF = 260;
+ BORDER_BOTTOM = 261;
+ BORDER_SPACING = 262;
+ _WEBKIT_COLUMN_SPAN = 263;
+ GRID_ROW_END = 264;
+ _WEBKIT_BORDER_END = 265;
+ PERSPECTIVE_ORIGIN = 266;
+ PAGE_BREAK_INSIDE = 267;
+ ORPHANS = 268;
+ _WEBKIT_BORDER_START_STYLE = 269;
+ SCROLL_BEHAVIOR = 270;
+ COLUMN_SPAN = 271;
+ _WEBKIT_HYPHENATE_CHARACTER = 272;
+ COLUMN_FILL = 273;
+ TAB_SIZE = 274;
+ CONTAIN = 275;
+ X = 276;
+ GRID_ROW = 277;
+ BORDER_BOTTOM_RIGHT_RADIUS = 278;
+ LINE_HEIGHT = 279;
+ STROKE_LINEJOIN = 280;
+ TEXT_ALIGN_LAST = 281;
+ OFFSET_POSITION = 282;
+ WORD_SPACING = 283;
+ TRANSFORM_STYLE = 284;
+ _WEBKIT_APP_REGION = 285;
+ _WEBKIT_BORDER_END_STYLE = 286;
+ _WEBKIT_TRANSFORM_ORIGIN_Z = 287;
+ _WEBKIT_TRANSFORM_ORIGIN_X = 288;
+ _WEBKIT_TRANSFORM_ORIGIN_Y = 289;
+ BACKGROUND_REPEAT_X = 290;
+ BACKGROUND_REPEAT_Y = 291;
+ BORDER_BOTTOM_COLOR = 292;
+ _WEBKIT_RUBY_POSITION = 293;
+ _WEBKIT_LOGICAL_WIDTH = 294;
+ TEXT_JUSTIFY = 295;
+ SCROLL_MARGIN_INLINE_START = 296;
+ CAPTION_SIDE = 297;
+ MASK_SOURCE_TYPE = 298;
+ _WEBKIT_MASK_BOX_IMAGE_SLICE = 299;
+ _WEBKIT_BORDER_IMAGE = 300;
+ TEXT_SIZE_ADJUST = 301;
+ _WEBKIT_TEXT_SECURITY = 302;
+ _EPUB_WRITING_MODE = 303;
+ GRID_TEMPLATE = 304;
+ _WEBKIT_MASK_BOX_IMAGE_REPEAT = 305;
+ _WEBKIT_MASK_REPEAT = 306;
+ _WEBKIT_JUSTIFY_CONTENT = 307;
+ BASELINE_SHIFT = 308;
+ BORDER_IMAGE = 309;
+ TEXT_DECORATION_COLOR = 310;
+ COLOR = 311;
+ SHAPE_IMAGE_THRESHOLD = 312;
+ SHAPE_RENDERING = 313;
+ CY = 314;
+ CX = 315;
+ _WEBKIT_USER_MODIFY = 316;
+ OFFSET_DISTANCE = 317;
+ _WEBKIT_BORDER_BOTTOM_LEFT_RADIUS = 318;
+ SPEAK = 319;
+ BORDER_BOTTOM_LEFT_RADIUS = 320;
+ _WEBKIT_COLUMN_BREAK_AFTER = 321;
+ _WEBKIT_FONT_SMOOTHING = 322;
+ _WEBKIT_MAX_LOGICAL_HEIGHT = 323;
+ _WEBKIT_LINE_BREAK = 324;
+ FILL_RULE = 325;
+ _WEBKIT_MARGIN_START = 326;
+ MIN_WIDTH = 327;
+ _EPUB_TEXT_COMBINE = 328;
+ BREAK_BEFORE = 329;
+ CARET_COLOR = 330;
+ EMPTY_CELLS = 331;
+ DIRECTION = 332;
+ CLIP_PATH = 333;
+ JUSTIFY_CONTENT = 334;
+ SCROLL_PADDING_BLOCK_END = 335;
+ Z_INDEX = 336;
+ BACKGROUND_POSITION_Y = 337;
+ TEXT_DECORATION_STYLE = 338;
+ GRID_TEMPLATE_AREAS = 339;
+ _WEBKIT_MIN_LOGICAL_HEIGHT = 340;
+ FONT_SIZE_ADJUST = 341;
+ SCROLL_PADDING_BLOCK = 342;
+ OVERFLOW_ANCHOR = 343;
+ CURSOR = 344;
+ SCROLL_MARGIN_BLOCK_START = 345;
+ _WEBKIT_MASK_BOX_IMAGE_SOURCE = 346;
+ MARGIN = 347;
+ _WEBKIT_ANIMATION = 348;
+ LETTER_SPACING = 349;
+ ORIENTATION = 350;
+ WILL_CHANGE = 351;
+ _WEBKIT_HIGHLIGHT = 352;
+ TRANSFORM_ORIGIN = 353;
+ FONT_VARIANT_LIGATURES = 354;
+ _WEBKIT_ANIMATION_DURATION = 355;
+ _WEBKIT_MASK_ORIGIN = 356;
+ _WEBKIT_CLIP_PATH = 357;
+ WORD_BREAK = 358;
+ TABLE_LAYOUT = 359;
+ TEXT_OVERFLOW = 360;
+ _WEBKIT_LOCALE = 361;
+ _WEBKIT_FLEX = 362;
+ GRID_AUTO_FLOW = 363;
+ BORDER_TOP_RIGHT_RADIUS = 364;
+ BORDER_IMAGE_OUTSET = 365;
+ PLACE_ITEMS = 366;
+ BORDER_LEFT_COLOR = 367;
+ FONT_VARIATION_SETTINGS = 368;
+ BORDER_RIGHT_COLOR = 369;
+ MIN_ZOOM = 370;
+ SCROLL_MARGIN_INLINE = 371;
+ _WEBKIT_BORDER_BEFORE_WIDTH = 372;
+ BACKFACE_VISIBILITY = 373;
+ BACKGROUND_IMAGE = 374;
+ _WEBKIT_TRANSITION_PROPERTY = 375;
+ WRITING_MODE = 376;
+ STROKE_OPACITY = 377;
+ BOX_SIZING = 378;
+ MARGIN_TOP = 379;
+ COLUMN_RULE_COLOR = 380;
+ Y = 381;
+ POSITION = 382;
+ SCROLL_MARGIN_BOTTOM = 383;
+ LIST_STYLE_POSITION = 384;
+ _WEBKIT_BOX_PACK = 385;
+ SCROLL_PADDING_INLINE_END = 386;
+ QUOTES = 387;
+ BORDER_TOP = 388;
+ SCROLL_PADDING_LEFT = 389;
+ _WEBKIT_TRANSITION = 390;
+ _WEBKIT_COLUMN_BREAK_BEFORE = 391;
+ LIGHTING_COLOR = 392;
+ BACKGROUND_SIZE = 393;
+ _WEBKIT_PADDING_BEFORE = 394;
+ _WEBKIT_BORDER_TOP_LEFT_RADIUS = 395;
+ FLOOD_OPACITY = 396;
+ LINE_HEIGHT_STEP = 397;
+ _WEBKIT_MASK_SIZE = 398;
+ TEXT_ALIGN = 399;
+ _WEBKIT_FILTER = 400;
+ WORD_WRAP = 401;
+ MAX_ZOOM = 402;
+ GRID = 403;
+ BACKGROUND = 404;
+ HEIGHT = 405;
+ GRID_COLUMN_START = 406;
+ ANIMATION_FILL_MODE = 407;
+ ROTATE = 408;
+ MARKER_END = 409;
+ D = 410;
+ JUSTIFY_ITEMS = 411;
+ ZOOM = 412;
+ SCROLL_PADDING_BLOCK_START = 413;
+ PAGE = 414;
+ RIGHT = 415;
+ USER_SELECT = 416;
+ MARGIN_RIGHT = 417;
+ MARKER = 418;
+ LINE_BREAK = 419;
+ _WEBKIT_MARGIN_END = 420;
+ _WEBKIT_TRANSITION_DURATION = 421;
+ _WEBKIT_WRITING_MODE = 422;
+ BORDER_TOP_WIDTH = 423;
+ BOTTOM = 424;
+ PLACE_CONTENT = 425;
+ _WEBKIT_SHAPE_IMAGE_THRESHOLD = 426;
+ _WEBKIT_USER_DRAG = 427;
+ _WEBKIT_BORDER_VERTICAL_SPACING = 428;
+ _WEBKIT_COLUMN_GAP = 429;
+ _WEBKIT_OPACITY = 430;
+ BACKGROUND_COLOR = 431;
+ COLUMN_GAP = 432;
+ SHAPE_OUTSIDE = 433;
+ _WEBKIT_PADDING_END = 434;
+ _WEBKIT_BORDER_START = 435;
+ ANIMATION_DELAY = 436;
+ UNICODE_BIDI = 437;
+ TEXT_SHADOW = 438;
+ _WEBKIT_BOX_DIRECTION = 439;
+ IMAGE_RENDERING = 440;
+ SRC = 441;
+ GAP = 442;
+ GRID_GAP = 443;
+ POINTER_EVENTS = 444;
+ BORDER_IMAGE_WIDTH = 445;
+ MIN_BLOCK_SIZE = 446;
+ TRANSITION_PROPERTY = 447;
+ _WEBKIT_MASK_IMAGE = 448;
+ FLOAT = 449;
+ MAX_HEIGHT = 450;
+ OUTLINE_OFFSET = 451;
+ _WEBKIT_BOX_SHADOW = 452;
+ OVERFLOW_WRAP = 453;
+ BLOCK_SIZE = 454;
+ TRANSFORM = 455;
+ PLACE_SELF = 456;
+ WIDTH = 457;
+ STROKE_MITERLIMIT = 458;
+ STOP_OPACITY = 459;
+ BORDER_TOP_COLOR = 460;
+ TRANSLATE = 461;
+ OBJECT_FIT = 462;
+ _WEBKIT_MASK_BOX_IMAGE_WIDTH = 463;
+ _WEBKIT_BACKGROUND_ORIGIN = 464;
+ _WEBKIT_ALIGN_ITEMS = 465;
+ TRANSITION_DELAY = 466;
+ SCROLL_MARGIN_LEFT = 467;
+ BORDER_STYLE = 468;
+ ANIMATION_ITERATION_COUNT = 469;
// Should be named OVERFLOW but can't because a macro uses this. Needs two
// underscores for Windows.
- __OVERFLOW = 475;
- USER_ZOOM = 476;
- _WEBKIT_BORDER_TOP_RIGHT_RADIUS = 477;
- GRID_TEMPLATE_COLUMNS = 478;
- _WEBKIT_ALIGN_SELF = 479;
- _WEBKIT_PERSPECTIVE_ORIGIN = 480;
- COLUMN_RULE_STYLE = 481;
- DISPLAY = 482;
- _WEBKIT_COLUMN_RULE_WIDTH = 483;
- BORDER_COLOR = 484;
- _WEBKIT_FLEX_BASIS = 485;
- STROKE_DASHOFFSET = 486;
- _WEBKIT_TEXT_SIZE_ADJUST = 487;
- SCROLL_BOUNDARY_BEHAVIOR = 488;
- _WEBKIT_TEXT_STROKE = 489;
- WIDOWS = 490;
- FILL = 491;
- OVERFLOW_Y = 492;
- OVERFLOW_X = 493;
- OPACITY = 494;
- _WEBKIT_PERSPECTIVE = 495;
- _WEBKIT_TEXT_STROKE_COLOR = 496;
- SCROLL_MARGIN_INLINE_END = 497;
- SCALE = 498;
- _WEBKIT_TEXT_ORIENTATION = 499;
- _WEBKIT_MASK_BOX_IMAGE_OUTSET = 500;
- ALIGN_CONTENT = 501;
- _WEBKIT_BORDER_END_WIDTH = 502;
- BORDER_BOTTOM_STYLE = 503;
- MASK = 504;
- BACKGROUND_POSITION_X = 505;
- _EPUB_TEXT_TRANSFORM = 506;
- STOP_COLOR = 507;
- STROKE_DASHARRAY = 508;
- _WEBKIT_LINE_CLAMP = 509;
- MARGIN_BLOCK_START = 510;
- MARGIN_BLOCK_END = 511;
- MARGIN_INLINE_START = 512;
- MARGIN_INLINE_END = 513;
- PADDING_BLOCK_START = 514;
- PADDING_BLOCK_END = 515;
- PADDING_INLINE_START = 516;
- PADDING_INLINE_END = 517;
- BORDER_BLOCK_START_WIDTH = 518;
- BORDER_BLOCK_START_STYLE = 519;
- BORDER_BLOCK_START_COLOR = 520;
- BORDER_BLOCK_END_WIDTH = 521;
- BORDER_BLOCK_END_STYLE = 522;
- BORDER_BLOCK_END_COLOR = 523;
- BORDER_INLINE_START_WIDTH = 524;
- BORDER_INLINE_START_STYLE = 525;
- BORDER_INLINE_START_COLOR = 526;
- BORDER_INLINE_END_WIDTH = 527;
- BORDER_INLINE_END_STYLE = 528;
- BORDER_INLINE_END_COLOR = 529;
- BORDER_BLOCK_START = 530;
- BORDER_BLOCK_END = 531;
- BORDER_INLINE_START = 532;
- BORDER_INLINE_END = 533;
- MARGIN_BLOCK = 534;
- MARGIN_INLINE = 535;
- PADDING_BLOCK = 536;
- PADDING_INLINE = 537;
- BORDER_BLOCK_WIDTH = 538;
- BORDER_BLOCK_STYLE = 539;
- BORDER_BLOCK_COLOR = 540;
- BORDER_INLINE_WIDTH = 541;
- BORDER_INLINE_STYLE = 542;
- BORDER_INLINE_COLOR = 543;
- BORDER_BLOCK = 544;
- BORDER_INLINE = 545;
- INSET_BLOCK_START = 546;
- INSET_BLOCK_END = 547;
- INSET_BLOCK = 548;
- INSET_INLINE_START = 549;
- INSET_INLINE_END = 550;
- INSET_INLINE = 551;
- INSET = 552;
- OVERFLOW_BLOCK = 553;
- OVERFLOW_INLINE = 554;
- FORCED_COLOR_ADJUST = 555;
- OVERSCROLL_BEHAVIOR_INLINE = 556;
- OVERSCROLL_BEHAVIOR_BLOCK = 557;
- OVERSCROLL_BEHAVIOR_X = 558;
- OVERSCROLL_BEHAVIOR_Y = 559;
- INVALID_PROPERTY = 560;
+ __OVERFLOW = 470;
+ USER_ZOOM = 471;
+ _WEBKIT_BORDER_TOP_RIGHT_RADIUS = 472;
+ GRID_TEMPLATE_COLUMNS = 473;
+ _WEBKIT_ALIGN_SELF = 474;
+ _WEBKIT_PERSPECTIVE_ORIGIN = 475;
+ COLUMN_RULE_STYLE = 476;
+ DISPLAY = 477;
+ _WEBKIT_COLUMN_RULE_WIDTH = 478;
+ BORDER_COLOR = 479;
+ _WEBKIT_FLEX_BASIS = 480;
+ STROKE_DASHOFFSET = 481;
+ _WEBKIT_TEXT_SIZE_ADJUST = 482;
+ SCROLL_BOUNDARY_BEHAVIOR = 483;
+ _WEBKIT_TEXT_STROKE = 484;
+ WIDOWS = 485;
+ FILL = 486;
+ OVERFLOW_Y = 487;
+ OVERFLOW_X = 488;
+ OPACITY = 489;
+ _WEBKIT_PERSPECTIVE = 490;
+ _WEBKIT_TEXT_STROKE_COLOR = 491;
+ SCROLL_MARGIN_INLINE_END = 492;
+ SCALE = 493;
+ _WEBKIT_TEXT_ORIENTATION = 494;
+ _WEBKIT_MASK_BOX_IMAGE_OUTSET = 495;
+ ALIGN_CONTENT = 496;
+ _WEBKIT_BORDER_END_WIDTH = 497;
+ BORDER_BOTTOM_STYLE = 498;
+ MASK = 499;
+ BACKGROUND_POSITION_X = 500;
+ _EPUB_TEXT_TRANSFORM = 501;
+ STOP_COLOR = 502;
+ STROKE_DASHARRAY = 503;
+ _WEBKIT_LINE_CLAMP = 504;
+ MARGIN_BLOCK_START = 505;
+ MARGIN_BLOCK_END = 506;
+ MARGIN_INLINE_START = 507;
+ MARGIN_INLINE_END = 508;
+ PADDING_BLOCK_START = 509;
+ PADDING_BLOCK_END = 510;
+ PADDING_INLINE_START = 511;
+ PADDING_INLINE_END = 512;
+ BORDER_BLOCK_START_WIDTH = 513;
+ BORDER_BLOCK_START_STYLE = 514;
+ BORDER_BLOCK_START_COLOR = 515;
+ BORDER_BLOCK_END_WIDTH = 516;
+ BORDER_BLOCK_END_STYLE = 517;
+ BORDER_BLOCK_END_COLOR = 518;
+ BORDER_INLINE_START_WIDTH = 519;
+ BORDER_INLINE_START_STYLE = 520;
+ BORDER_INLINE_START_COLOR = 521;
+ BORDER_INLINE_END_WIDTH = 522;
+ BORDER_INLINE_END_STYLE = 523;
+ BORDER_INLINE_END_COLOR = 524;
+ BORDER_BLOCK_START = 525;
+ BORDER_BLOCK_END = 526;
+ BORDER_INLINE_START = 527;
+ BORDER_INLINE_END = 528;
+ MARGIN_BLOCK = 529;
+ MARGIN_INLINE = 530;
+ PADDING_BLOCK = 531;
+ PADDING_INLINE = 532;
+ BORDER_BLOCK_WIDTH = 533;
+ BORDER_BLOCK_STYLE = 534;
+ BORDER_BLOCK_COLOR = 535;
+ BORDER_INLINE_WIDTH = 536;
+ BORDER_INLINE_STYLE = 537;
+ BORDER_INLINE_COLOR = 538;
+ BORDER_BLOCK = 539;
+ BORDER_INLINE = 540;
+ INSET_BLOCK_START = 541;
+ INSET_BLOCK_END = 542;
+ INSET_BLOCK = 543;
+ INSET_INLINE_START = 544;
+ INSET_INLINE_END = 545;
+ INSET_INLINE = 546;
+ INSET = 547;
+ OVERFLOW_BLOCK = 548;
+ OVERFLOW_INLINE = 549;
+ FORCED_COLOR_ADJUST = 550;
+ OVERSCROLL_BEHAVIOR_INLINE = 551;
+ OVERSCROLL_BEHAVIOR_BLOCK = 552;
+ OVERSCROLL_BEHAVIOR_X = 553;
+ OVERSCROLL_BEHAVIOR_Y = 554;
+ INVALID_PROPERTY = 555;
}
required NameId name_id = 1;
}
@@ -2383,7 +2378,9 @@ message PropertyAndValue {
SMOOTH = 757;
JUMP_START = 758;
NO_DRAG = 759;
- INVALID_VALUE = 760;
+ JIS_B5 = 760;
+ JIS_B4 = 761;
+ INVALID_VALUE = 762;
};
optional ValueId value_id = 4;
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_lazy_parsing_state.cc b/chromium/third_party/blink/renderer/core/css/parser/css_lazy_parsing_state.cc
index 2d4ad53c69c..d4c77529916 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_lazy_parsing_state.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_lazy_parsing_state.cc
@@ -36,7 +36,7 @@ const CSSParserContext* CSSLazyParsingState::Context() {
return context_;
}
-void CSSLazyParsingState::Trace(blink::Visitor* visitor) {
+void CSSLazyParsingState::Trace(Visitor* visitor) {
visitor->Trace(owning_contents_);
visitor->Trace(document_);
visitor->Trace(context_);
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_lazy_parsing_state.h b/chromium/third_party/blink/renderer/core/css/parser/css_lazy_parsing_state.h
index 19f486bb983..f892be65c7b 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_lazy_parsing_state.h
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_lazy_parsing_state.h
@@ -30,7 +30,7 @@ class CSSLazyParsingState final : public GarbageCollected<CSSLazyParsingState> {
const CSSParserContext* Context();
const String& SheetText() const { return sheet_text_; }
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
Member<const CSSParserContext> context_;
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_lazy_property_parser_impl.h b/chromium/third_party/blink/renderer/core/css/parser/css_lazy_property_parser_impl.h
index 2d9670e3b0a..afbf2a9c6bc 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_lazy_property_parser_impl.h
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_lazy_property_parser_impl.h
@@ -21,7 +21,7 @@ class CSSLazyPropertyParserImpl : public CSSLazyPropertyParser {
// CSSLazyPropertyParser:
CSSPropertyValueSet* ParseProperties() override;
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(lazy_state_);
CSSLazyPropertyParser::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_parser.cc b/chromium/third_party/blink/renderer/core/css/parser/css_parser.cc
index 22e5721e50b..37d310b53ff 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_parser.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_parser.cc
@@ -11,6 +11,7 @@
#include "third_party/blink/renderer/core/css/parser/css_parser_fast_paths.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_impl.h"
#include "third_party/blink/renderer/core/css/parser/css_property_parser.h"
+#include "third_party/blink/renderer/core/css/parser/css_property_parser_helpers.h"
#include "third_party/blink/renderer/core/css/parser/css_selector_parser.h"
#include "third_party/blink/renderer/core/css/parser/css_supports_parser.h"
#include "third_party/blink/renderer/core/css/parser/css_tokenizer.h"
@@ -216,7 +217,8 @@ bool CSSParser::ParseSupportsCondition(const String& condition,
CSSParserImpl parser(StrictCSSParserContext(secure_context_mode));
return CSSSupportsParser::SupportsCondition(
CSSParserTokenRange(tokens), parser,
- CSSSupportsParser::kForWindowCSS) == CSSSupportsParser::kSupported;
+ CSSSupportsParser::Mode::kForWindowCSS) ==
+ CSSSupportsParser::Result::kSupported;
}
bool CSSParser::ParseColor(Color& color, const String& string, bool strict) {
@@ -258,14 +260,6 @@ bool CSSParser::ParseSystemColor(Color& color,
if (!StyleColor::IsSystemColor(id))
return false;
- if (!RuntimeEnabledFeatures::LinkSystemColorsEnabled() &&
- (id == CSSValueID::kLinktext || id == CSSValueID::kVisitedtext)) {
- return false;
- } else if (!RuntimeEnabledFeatures::NewSystemColorsEnabled() &&
- (id == CSSValueID::kActivetext || id == CSSValueID::kField ||
- id == CSSValueID::kFieldtext)) {
- return false;
- }
color = LayoutTheme::GetTheme().SystemColor(id, color_scheme);
return true;
}
@@ -282,4 +276,16 @@ const CSSValue* CSSParser::ParseFontFaceDescriptor(
return value;
}
+CSSPrimitiveValue* CSSParser::ParseLengthPercentage(
+ const String& string,
+ const CSSParserContext* context) {
+ if (string.IsEmpty() || !context)
+ return nullptr;
+ CSSTokenizer tokenizer(string);
+ const auto tokens = tokenizer.TokenizeToEOF();
+ CSSParserTokenRange range(tokens);
+ return css_property_parser_helpers::ConsumeLengthOrPercent(range, *context,
+ kValueRangeAll);
+}
+
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_parser.h b/chromium/third_party/blink/renderer/core/css/parser/css_parser.h
index 6de5b9be336..df51b7f0142 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_parser.h
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_parser.h
@@ -23,6 +23,7 @@ class StyleRuleBase;
class StyleRuleKeyframe;
class StyleSheetContents;
class CSSValue;
+class CSSPrimitiveValue;
enum class ParseSheetResult;
enum class SecureContextMode;
@@ -112,6 +113,9 @@ class CORE_EXPORT CSSParser {
const String&,
CSSParserObserver&);
+ static CSSPrimitiveValue* ParseLengthPercentage(const String&,
+ const CSSParserContext*);
+
private:
static MutableCSSPropertyValueSet::SetResult ParseValue(
MutableCSSPropertyValueSet*,
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_parser_context.cc b/chromium/third_party/blink/renderer/core/css/parser/css_parser_context.cc
index 8f0f74637ad..3976f68094f 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_parser_context.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_parser_context.cc
@@ -13,7 +13,9 @@
#include "third_party/blink/renderer/core/feature_policy/layout_animations_policy.h"
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.h"
#include "third_party/blink/renderer/core/frame/deprecation.h"
+#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/settings.h"
+#include "third_party/blink/renderer/core/html/html_document.h"
#include "third_party/blink/renderer/core/html/imports/html_imports_controller.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/page/page.h"
@@ -85,7 +87,7 @@ CSSParserContext::CSSParserContext(CSSParserMode mode,
false,
false,
secure_context_mode,
- kDoNotCheckContentSecurityPolicy,
+ network::mojom::CSPDisposition::DO_NOT_CHECK,
use_counter_document,
ResourceFetchRestriction::kNone) {}
@@ -118,15 +120,16 @@ CSSParserContext::CSSParserContext(
profile,
Referrer(base_url_override.StrippedForUseAsReferrer(),
referrer_policy_override),
- document.IsHTMLDocument(),
+ IsA<HTMLDocument>(document),
document.GetSettings()
? document.GetSettings()
->GetUseLegacyBackgroundSizeShorthandBehavior()
: false,
document.GetSecureContextMode(),
- ContentSecurityPolicy::ShouldBypassMainWorld(&document)
- ? kDoNotCheckContentSecurityPolicy
- : kCheckContentSecurityPolicy,
+ ContentSecurityPolicy::ShouldBypassMainWorld(
+ document.GetExecutionContext())
+ ? network::mojom::CSPDisposition::DO_NOT_CHECK
+ : network::mojom::CSPDisposition::CHECK,
&document,
resource_fetch_restriction) {}
@@ -143,9 +146,11 @@ CSSParserContext::CSSParserContext(const ExecutionContext& context)
false,
context.GetSecureContextMode(),
ContentSecurityPolicy::ShouldBypassMainWorld(&context)
- ? kDoNotCheckContentSecurityPolicy
- : kCheckContentSecurityPolicy,
- DynamicTo<Document>(context),
+ ? network::mojom::CSPDisposition::DO_NOT_CHECK
+ : network::mojom::CSPDisposition::CHECK,
+ IsA<LocalDOMWindow>(&context)
+ ? To<LocalDOMWindow>(context).document()
+ : nullptr,
ResourceFetchRestriction::kNone) {}
CSSParserContext::CSSParserContext(
@@ -159,7 +164,7 @@ CSSParserContext::CSSParserContext(
bool is_html_document,
bool use_legacy_background_size_shorthand_behavior,
SecureContextMode secure_context_mode,
- ContentSecurityPolicyDisposition policy_disposition,
+ network::mojom::CSPDisposition policy_disposition,
const Document* use_counter_document,
enum ResourceFetchRestriction resource_fetch_restriction)
: base_url_(base_url),
@@ -188,6 +193,8 @@ bool CSSParserContext::operator==(const CSSParserContext& other) const {
resource_fetch_restriction_ == other.resource_fetch_restriction_;
}
+// TODO(xiaochengh): This function never returns null. Change it to return a
+// const reference to avoid confusion.
const CSSParserContext* StrictCSSParserContext(
SecureContextMode secure_context_mode) {
DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<Persistent<CSSParserContext>>,
@@ -244,6 +251,16 @@ bool CSSParserContext::IsDocumentHandleEqual(const Document* other) const {
return document_.Get() == other;
}
+const Document* CSSParserContext::GetDocument() const {
+ return document_.Get();
+}
+
+// Fuzzers may execution CSS parsing code without a Document being available,
+// thus this method can return null.
+const ExecutionContext* CSSParserContext::GetExecutionContext() const {
+ return (document_.Get()) ? document_.Get()->GetExecutionContext() : nullptr;
+}
+
void CSSParserContext::ReportLayoutAnimationsViolationIfNeeded(
const StyleRuleKeyframe& rule) const {
if (!document_)
@@ -252,7 +269,8 @@ void CSSParserContext::ReportLayoutAnimationsViolationIfNeeded(
const CSSProperty& property = rule.Properties().PropertyAt(i).Property();
if (!LayoutAnimationsPolicy::AffectedCSSProperties().Contains(&property))
continue;
- LayoutAnimationsPolicy::ReportViolation(property, *document_);
+ LayoutAnimationsPolicy::ReportViolation(property,
+ *document_->GetExecutionContext());
}
}
@@ -267,7 +285,7 @@ bool CSSParserContext::IsForMarkupSanitization() const {
return document_ && document_->IsForMarkupSanitization();
}
-void CSSParserContext::Trace(blink::Visitor* visitor) {
+void CSSParserContext::Trace(Visitor* visitor) {
visitor->Trace(document_);
}
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_parser_context.h b/chromium/third_party/blink/renderer/core/css/parser/css_parser_context.h
index 28a2da4cfc2..b9d230e1ed3 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_parser_context.h
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_parser_context.h
@@ -37,8 +37,8 @@ class CORE_EXPORT CSSParserContext final
// FIXME: This constructor shouldn't exist if we properly piped the UseCounter
// through the CSS subsystem. Currently the UseCounter life time is too crazy
// and we need a way to override it.
- CSSParserContext(const CSSParserContext* other,
- const Document* use_counter_document = nullptr);
+ explicit CSSParserContext(const CSSParserContext* other,
+ const Document* use_counter_document = nullptr);
CSSParserContext(const CSSParserContext* other,
const KURL& base_url_override,
@@ -73,7 +73,7 @@ class CORE_EXPORT CSSParserContext final
bool is_html_document,
bool use_legacy_background_size_shorthand_behavior,
SecureContextMode,
- ContentSecurityPolicyDisposition,
+ network::mojom::CSPDisposition,
const Document* use_counter_document,
ResourceFetchRestriction resource_fetch_restriction);
@@ -119,8 +119,10 @@ class CORE_EXPORT CSSParserContext final
void CountDeprecation(WebFeature) const;
bool IsUseCounterRecordingEnabled() const { return document_; }
bool IsDocumentHandleEqual(const Document* other) const;
+ const Document* GetDocument() const;
+ const ExecutionContext* GetExecutionContext() const;
- ContentSecurityPolicyDisposition ShouldCheckContentSecurityPolicy() const {
+ network::mojom::CSPDisposition ShouldCheckContentSecurityPolicy() const {
return should_check_content_security_policy_;
}
@@ -135,12 +137,30 @@ class CORE_EXPORT CSSParserContext final
bool IsForMarkupSanitization() const;
- void Trace(blink::Visitor*);
+ // Overrides |mode_| of a CSSParserContext within the scope, allowing us to
+ // switching parsing mode while parsing different parts of a style sheet.
+ // TODO(xiaochengh): This isn't the right approach, as it breaks the
+ // immutability of CSSParserContext. We should introduce some local context.
+ class ParserModeOverridingScope {
+ STACK_ALLOCATED();
+
+ public:
+ ParserModeOverridingScope(const CSSParserContext& context,
+ CSSParserMode mode)
+ : mode_reset_(const_cast<CSSParserMode*>(&context.mode_), mode) {}
+
+ private:
+ base::AutoReset<CSSParserMode> mode_reset_;
+ };
+
+ void Trace(Visitor*);
private:
+ friend class ParserModeOverridingScope;
+
KURL base_url_;
- ContentSecurityPolicyDisposition should_check_content_security_policy_;
+ network::mojom::CSPDisposition should_check_content_security_policy_;
// If true, allows reading and modifying of the CSS rules.
// https://drafts.csswg.org/cssom/#concept-css-style-sheet-origin-clean-flag
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_parser_fast_paths.cc b/chromium/third_party/blink/renderer/core/css/parser/css_parser_fast_paths.cc
index 8a2621d5f9a..faf3e61ee94 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_parser_fast_paths.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_parser_fast_paths.cc
@@ -643,6 +643,10 @@ bool CSSParserFastPaths::IsValidKeywordPropertyAndValue(
case CSSPropertyID::kMaskType:
return value_id == CSSValueID::kLuminance ||
value_id == CSSValueID::kAlpha;
+ case CSSPropertyID::kMathStyle:
+ DCHECK(RuntimeEnabledFeatures::CSSMathStyleEnabled());
+ return value_id == CSSValueID::kInline ||
+ value_id == CSSValueID::kDisplay;
case CSSPropertyID::kObjectFit:
return value_id == CSSValueID::kFill ||
value_id == CSSValueID::kContain ||
@@ -792,7 +796,7 @@ bool CSSParserFastPaths::IsValidKeywordPropertyAndValue(
case CSSPropertyID::kWebkitAppearance:
return (value_id >= CSSValueID::kCheckbox &&
value_id <= CSSValueID::kTextarea) ||
- value_id == CSSValueID::kNone;
+ value_id == CSSValueID::kNone || value_id == CSSValueID::kAuto;
case CSSPropertyID::kBackfaceVisibility:
return value_id == CSSValueID::kVisible ||
value_id == CSSValueID::kHidden;
@@ -905,13 +909,6 @@ bool CSSParserFastPaths::IsValidKeywordPropertyAndValue(
value_id == CSSValueID::kNormal ||
value_id == CSSValueID::kStrict ||
value_id == CSSValueID::kAfterWhiteSpace;
- case CSSPropertyID::kWebkitMarginAfterCollapse:
- case CSSPropertyID::kWebkitMarginBeforeCollapse:
- case CSSPropertyID::kWebkitMarginBottomCollapse:
- case CSSPropertyID::kWebkitMarginTopCollapse:
- return value_id == CSSValueID::kCollapse ||
- value_id == CSSValueID::kSeparate ||
- value_id == CSSValueID::kDiscard;
case CSSPropertyID::kWebkitPrintColorAdjust:
return value_id == CSSValueID::kExact || value_id == CSSValueID::kEconomy;
case CSSPropertyID::kWebkitRtlOrdering:
@@ -970,6 +967,8 @@ bool CSSParserFastPaths::IsValidKeywordPropertyAndValue(
case CSSPropertyID::kOverscrollBehaviorY:
return value_id == CSSValueID::kAuto ||
value_id == CSSValueID::kContain || value_id == CSSValueID::kNone;
+ case CSSPropertyID::kOriginTrialTestProperty:
+ return value_id == CSSValueID::kNormal || value_id == CSSValueID::kNone;
default:
NOTREACHED();
return false;
@@ -1009,6 +1008,7 @@ bool CSSParserFastPaths::IsKeywordPropertyID(CSSPropertyID property_id) {
case CSSPropertyID::kListStylePosition:
case CSSPropertyID::kListStyleType:
case CSSPropertyID::kMaskType:
+ case CSSPropertyID::kMathStyle:
case CSSPropertyID::kObjectFit:
case CSSPropertyID::kOutlineStyle:
case CSSPropertyID::kOverflowAnchor:
@@ -1069,10 +1069,6 @@ bool CSSParserFastPaths::IsKeywordPropertyID(CSSPropertyID property_id) {
case CSSPropertyID::kWebkitFontSmoothing:
case CSSPropertyID::kLineBreak:
case CSSPropertyID::kWebkitLineBreak:
- case CSSPropertyID::kWebkitMarginAfterCollapse:
- case CSSPropertyID::kWebkitMarginBeforeCollapse:
- case CSSPropertyID::kWebkitMarginBottomCollapse:
- case CSSPropertyID::kWebkitMarginTopCollapse:
case CSSPropertyID::kWebkitPrintColorAdjust:
case CSSPropertyID::kWebkitRtlOrdering:
case CSSPropertyID::kWebkitRubyPosition:
@@ -1088,6 +1084,7 @@ bool CSSParserFastPaths::IsKeywordPropertyID(CSSPropertyID property_id) {
case CSSPropertyID::kWordBreak:
case CSSPropertyID::kWritingMode:
case CSSPropertyID::kScrollSnapStop:
+ case CSSPropertyID::kOriginTrialTestProperty:
return true;
default:
return false;
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_parser_impl.cc b/chromium/third_party/blink/renderer/core/css/parser/css_parser_impl.cc
index 69c969f6211..bf766c0312a 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_parser_impl.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_parser_impl.cc
@@ -65,7 +65,10 @@ AtomicString ConsumeStringOrURI(CSSParserTokenStream& stream) {
CSSParserImpl::CSSParserImpl(const CSSParserContext* context,
StyleSheetContents* style_sheet)
- : context_(context), style_sheet_(style_sheet), observer_(nullptr) {}
+ : context_(context),
+ style_sheet_(style_sheet),
+ observer_(nullptr),
+ lazy_state_(nullptr) {}
MutableCSSPropertyValueSet::SetResult CSSParserImpl::ParseValue(
MutableCSSPropertyValueSet* declaration,
@@ -635,7 +638,9 @@ StyleRuleImport* CSSParserImpl::ConsumeImportRule(
}
return MakeGarbageCollected<StyleRuleImport>(
- uri, MediaQueryParser::ParseMediaQuerySet(prelude),
+ uri,
+ MediaQueryParser::ParseMediaQuerySet(prelude,
+ context_->GetExecutionContext()),
context_->IsOriginClean() ? OriginClean::kTrue : OriginClean::kFalse);
}
@@ -668,7 +673,8 @@ StyleRuleMedia* CSSParserImpl::ConsumeMediaRule(
if (style_sheet_)
style_sheet_->SetHasMediaQueries();
- const auto media = MediaQueryParser::ParseMediaQuerySet(prelude);
+ const auto media = MediaQueryParser::ParseMediaQuerySet(
+ prelude, context_->GetExecutionContext());
ConsumeRuleList(block, kRegularRuleList,
[&rules](StyleRuleBase* rule) { rules.push_back(rule); });
@@ -683,10 +689,9 @@ StyleRuleSupports* CSSParserImpl::ConsumeSupportsRule(
const CSSParserTokenRange prelude,
const RangeOffset& prelude_offset,
CSSParserTokenStream& block) {
- CSSSupportsParser::SupportsResult supported =
- CSSSupportsParser::SupportsCondition(prelude, *this,
- CSSSupportsParser::kForAtRule);
- if (supported == CSSSupportsParser::kInvalid)
+ CSSSupportsParser::Result supported = CSSSupportsParser::SupportsCondition(
+ prelude, *this, CSSSupportsParser::Mode::kForAtRule);
+ if (supported == CSSSupportsParser::Result::kParseFailure)
return nullptr; // Parse error, invalid @supports condition
if (observer_) {
@@ -704,8 +709,9 @@ StyleRuleSupports* CSSParserImpl::ConsumeSupportsRule(
if (observer_)
observer_->EndRuleBody(block.Offset());
- return MakeGarbageCollected<StyleRuleSupports>(prelude_serialized, supported,
- rules);
+ return MakeGarbageCollected<StyleRuleSupports>(
+ prelude_serialized, supported == CSSSupportsParser::Result::kSupported,
+ rules);
}
StyleRuleViewport* CSSParserImpl::ConsumeViewportRule(
@@ -836,7 +842,7 @@ StyleRuleProperty* CSSParserImpl::ConsumePropertyRule(
}
ConsumeDeclarationList(block, StyleRule::kProperty);
- return StyleRuleProperty::Create(
+ return MakeGarbageCollected<StyleRuleProperty>(
name, CreateCSSPropertyValueSet(parsed_properties_, context_->Mode()));
}
@@ -1003,7 +1009,8 @@ void CSSParserImpl::ConsumeDeclaration(CSSParserTokenRange range,
AtRuleDescriptorParser::ParseAtRule(atrule_id, range, *context_,
parsed_properties_);
} else {
- unresolved_property = lhs.ParseAsUnresolvedCSSPropertyID(context_->Mode());
+ unresolved_property = lhs.ParseAsUnresolvedCSSPropertyID(
+ context_->GetExecutionContext(), context_->Mode());
}
// @rules other than FontFace still handled with legacy code.
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_parser_impl.h b/chromium/third_party/blink/renderer/core/css/parser/css_parser_impl.h
index 6f1fa33bb69..055faedfc23 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_parser_impl.h
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_parser_impl.h
@@ -8,6 +8,7 @@
#include <memory>
#include "base/macros.h"
+#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/core/css/css_property_source_data.h"
#include "third_party/blink/renderer/core/css/css_property_value.h"
@@ -44,7 +45,7 @@ enum class ParseSheetResult {
kHasUnallowedImportRule,
};
-class CSSParserImpl {
+class CORE_EXPORT CSSParserImpl {
STACK_ALLOCATED();
public:
@@ -115,6 +116,7 @@ class CSSParserImpl {
static std::unique_ptr<Vector<double>> ParseKeyframeKeyList(const String&);
bool SupportsDeclaration(CSSParserTokenRange&);
+ const CSSParserContext* GetContext() const { return context_; }
static void ParseDeclarationListForInspector(const String&,
const CSSParserContext*,
@@ -198,13 +200,13 @@ class CSSParserImpl {
// FIXME: Investigate using a smaller inline buffer
HeapVector<CSSPropertyValue, 256> parsed_properties_;
- Member<const CSSParserContext> context_;
- Member<StyleSheetContents> style_sheet_;
+ const CSSParserContext* context_;
+ StyleSheetContents* style_sheet_;
// For the inspector
CSSParserObserver* observer_;
- Member<CSSLazyParsingState> lazy_state_;
+ CSSLazyParsingState* lazy_state_;
DISALLOW_COPY_AND_ASSIGN(CSSParserImpl);
};
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_parser_selector.h b/chromium/third_party/blink/renderer/core/css/parser/css_parser_selector.h
index 341013ccb9e..9ea94a4761a 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_parser_selector.h
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_parser_selector.h
@@ -54,6 +54,9 @@ class CORE_EXPORT CSSParserSelector {
selector_->SetAttribute(value, match_type);
}
void SetArgument(const AtomicString& value) { selector_->SetArgument(value); }
+ void SetPartNames(std::unique_ptr<Vector<AtomicString>> part_names) {
+ selector_->SetPartNames(std::move(part_names));
+ }
void SetNth(int a, int b) { selector_->SetNth(a, b); }
void SetMatch(CSSSelector::MatchType value) { selector_->SetMatch(value); }
void SetRelation(CSSSelector::RelationType value) {
@@ -80,6 +83,7 @@ class CORE_EXPORT CSSParserSelector {
void AdoptSelectorVector(
Vector<std::unique_ptr<CSSParserSelector>>& selector_vector);
void SetSelectorList(std::unique_ptr<CSSSelectorList>);
+ void SetAtomics(std::unique_ptr<CSSSelectorList>);
bool IsHostPseudoSelector() const;
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_parser_token.cc b/chromium/third_party/blink/renderer/core/css/parser/css_parser_token.cc
index 39a17b852c2..6f85bf2fca0 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_parser_token.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_parser_token.cc
@@ -87,9 +87,10 @@ double CSSParserToken::NumericValue() const {
}
CSSPropertyID CSSParserToken::ParseAsUnresolvedCSSPropertyID(
+ const ExecutionContext* execution_context,
CSSParserMode mode) const {
DCHECK_EQ(type_, static_cast<unsigned>(kIdentToken));
- return UnresolvedCSSPropertyID(Value(), mode);
+ return UnresolvedCSSPropertyID(execution_context, Value(), mode);
}
AtRuleDescriptorID CSSParserToken::ParseAsAtRuleDescriptorID() const {
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_parser_token.h b/chromium/third_party/blink/renderer/core/css/parser/css_parser_token.h
index a626f9030af..c094ae05276 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_parser_token.h
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_parser_token.h
@@ -14,6 +14,7 @@
namespace blink {
+class ExecutionContext;
enum class CSSValueID;
enum CSSParserTokenType {
@@ -149,6 +150,7 @@ class CORE_EXPORT CSSParserToken {
bool HasStringBacking() const;
CSSPropertyID ParseAsUnresolvedCSSPropertyID(
+ const ExecutionContext* execution_context,
CSSParserMode mode = kHTMLStandardMode) const;
AtRuleDescriptorID ParseAsAtRuleDescriptorID() const;
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_property_parser.cc b/chromium/third_party/blink/renderer/core/css/parser/css_property_parser.cc
index 1f6e911c2f1..1365fb4c828 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_property_parser.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_property_parser.cc
@@ -157,7 +157,8 @@ bool CSSPropertyParser::ParseValueStart(CSSPropertyID unresolved_property,
if (is_shorthand) {
const cssvalue::CSSPendingSubstitutionValue& pending_value =
- *cssvalue::CSSPendingSubstitutionValue::Create(property_id, variable);
+ *MakeGarbageCollected<cssvalue::CSSPendingSubstitutionValue>(
+ property_id, variable);
css_property_parser_helpers::AddExpandedPropertyForValue(
property_id, pending_value, important, *parsed_properties_);
} else {
@@ -170,16 +171,19 @@ bool CSSPropertyParser::ParseValueStart(CSSPropertyID unresolved_property,
return false;
}
-static inline bool IsExposedInMode(const CSSProperty& property,
+static inline bool IsExposedInMode(const ExecutionContext* execution_context,
+ const CSSProperty& property,
CSSParserMode mode) {
- return mode == kUASheetMode ? property.IsUAExposed()
- : property.IsWebExposed();
+ return mode == kUASheetMode ? property.IsUAExposed(execution_context)
+ : property.IsWebExposed(execution_context);
}
template <typename CharacterType>
-static CSSPropertyID UnresolvedCSSPropertyID(const CharacterType* property_name,
- unsigned length,
- CSSParserMode mode) {
+static CSSPropertyID UnresolvedCSSPropertyID(
+ const ExecutionContext* execution_context,
+ const CharacterType* property_name,
+ unsigned length,
+ CSSParserMode mode) {
if (length == 0)
return CSSPropertyID::kInvalid;
if (length >= 2 && property_name[0] == '-' && property_name[1] == '-')
@@ -204,23 +208,30 @@ static CSSPropertyID UnresolvedCSSPropertyID(const CharacterType* property_name,
CSSPropertyID property_id = static_cast<CSSPropertyID>(hash_table_entry->id);
const CSSProperty& property =
CSSProperty::Get(resolveCSSPropertyID(property_id));
- bool exposed = IsExposedInMode(property, mode);
+ bool exposed = IsExposedInMode(execution_context, property, mode);
return exposed ? property_id : CSSPropertyID::kInvalid;
}
-CSSPropertyID unresolvedCSSPropertyID(const String& string) {
+CSSPropertyID unresolvedCSSPropertyID(const ExecutionContext* execution_context,
+ const String& string) {
unsigned length = string.length();
CSSParserMode mode = kHTMLStandardMode;
return string.Is8Bit()
- ? UnresolvedCSSPropertyID(string.Characters8(), length, mode)
- : UnresolvedCSSPropertyID(string.Characters16(), length, mode);
+ ? UnresolvedCSSPropertyID(execution_context, string.Characters8(),
+ length, mode)
+ : UnresolvedCSSPropertyID(execution_context, string.Characters16(),
+ length, mode);
}
-CSSPropertyID UnresolvedCSSPropertyID(StringView string, CSSParserMode mode) {
+CSSPropertyID UnresolvedCSSPropertyID(const ExecutionContext* execution_context,
+ StringView string,
+ CSSParserMode mode) {
unsigned length = string.length();
return string.Is8Bit()
- ? UnresolvedCSSPropertyID(string.Characters8(), length, mode)
- : UnresolvedCSSPropertyID(string.Characters16(), length, mode);
+ ? UnresolvedCSSPropertyID(execution_context, string.Characters8(),
+ length, mode)
+ : UnresolvedCSSPropertyID(execution_context, string.Characters16(),
+ length, mode);
}
template <typename CharacterType>
@@ -278,7 +289,7 @@ bool CSSPropertyParser::ConsumeCSSWideKeyword(CSSPropertyID unresolved_property,
static CSSValue* ConsumeSingleViewportDescriptor(
CSSParserTokenRange& range,
CSSPropertyID prop_id,
- CSSParserMode css_parser_mode) {
+ const CSSParserContext& context) {
CSSValueID id = range.Peek().Id();
switch (prop_id) {
case CSSPropertyID::kMinWidth:
@@ -288,18 +299,18 @@ static CSSValue* ConsumeSingleViewportDescriptor(
if (id == CSSValueID::kAuto || id == CSSValueID::kInternalExtendToZoom)
return ConsumeIdent(range);
return css_property_parser_helpers::ConsumeLengthOrPercent(
- range, css_parser_mode, kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
case CSSPropertyID::kMinZoom:
case CSSPropertyID::kMaxZoom:
case CSSPropertyID::kZoom: {
if (id == CSSValueID::kAuto)
return ConsumeIdent(range);
CSSValue* parsed_value = css_property_parser_helpers::ConsumeNumber(
- range, kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
if (parsed_value)
return parsed_value;
return css_property_parser_helpers::ConsumePercent(
- range, kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
}
case CSSPropertyID::kUserZoom:
return ConsumeIdent<CSSValueID::kZoom, CSSValueID::kFixed>(range);
@@ -326,13 +337,13 @@ bool CSSPropertyParser::ParseViewportDescriptor(CSSPropertyID prop_id,
switch (prop_id) {
case CSSPropertyID::kWidth: {
CSSValue* min_width = ConsumeSingleViewportDescriptor(
- range_, CSSPropertyID::kMinWidth, context_->Mode());
+ range_, CSSPropertyID::kMinWidth, *context_);
if (!min_width)
return false;
CSSValue* max_width = min_width;
if (!range_.AtEnd()) {
max_width = ConsumeSingleViewportDescriptor(
- range_, CSSPropertyID::kMaxWidth, context_->Mode());
+ range_, CSSPropertyID::kMaxWidth, *context_);
}
if (!max_width || !range_.AtEnd())
return false;
@@ -346,13 +357,13 @@ bool CSSPropertyParser::ParseViewportDescriptor(CSSPropertyID prop_id,
}
case CSSPropertyID::kHeight: {
CSSValue* min_height = ConsumeSingleViewportDescriptor(
- range_, CSSPropertyID::kMinHeight, context_->Mode());
+ range_, CSSPropertyID::kMinHeight, *context_);
if (!min_height)
return false;
CSSValue* max_height = min_height;
if (!range_.AtEnd()) {
max_height = ConsumeSingleViewportDescriptor(
- range_, CSSPropertyID::kMaxHeight, context_->Mode());
+ range_, CSSPropertyID::kMaxHeight, *context_);
}
if (!max_height || !range_.AtEnd())
return false;
@@ -375,7 +386,7 @@ bool CSSPropertyParser::ParseViewportDescriptor(CSSPropertyID prop_id,
case CSSPropertyID::kUserZoom:
case CSSPropertyID::kOrientation: {
CSSValue* parsed_value =
- ConsumeSingleViewportDescriptor(range_, prop_id, context_->Mode());
+ ConsumeSingleViewportDescriptor(range_, prop_id, *context_);
if (!parsed_value || !range_.AtEnd())
return false;
AddProperty(prop_id, CSSPropertyID::kInvalid, *parsed_value, important,
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_property_parser.h b/chromium/third_party/blink/renderer/core/css/parser/css_property_parser.h
index d4989ede007..2090b9ec5a8 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_property_parser.h
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_property_parser.h
@@ -36,6 +36,7 @@ namespace blink {
class CSSPropertyValue;
class CSSValue;
+class ExecutionContext;
// Inputs: PropertyID, isImportant bool, CSSParserTokenRange.
// Outputs: Vector of CSSProperties
@@ -71,13 +72,14 @@ class CORE_EXPORT CSSPropertyParser {
private:
// Inputs:
CSSParserTokenRange range_;
- Member<const CSSParserContext> context_;
+ const CSSParserContext* context_;
// Outputs:
HeapVector<CSSPropertyValue, 256>* parsed_properties_;
DISALLOW_COPY_AND_ASSIGN(CSSPropertyParser);
};
-CSSPropertyID UnresolvedCSSPropertyID(StringView,
+CSSPropertyID UnresolvedCSSPropertyID(const ExecutionContext*,
+ StringView,
CSSParserMode mode = kHTMLStandardMode);
CSSValueID CssValueKeywordID(StringView);
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_property_parser_helpers.cc b/chromium/third_party/blink/renderer/core/css/parser/css_property_parser_helpers.cc
index c091695c955..c2034ea64b7 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_property_parser_helpers.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_property_parser_helpers.cc
@@ -31,6 +31,7 @@
#include "third_party/blink/renderer/core/css/style_color.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/style_property_shorthand.h"
+#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
@@ -44,12 +45,12 @@ namespace {
bool AddCSSPaintArgument(
const Vector<CSSParserToken>& tokens,
Vector<scoped_refptr<CSSVariableData>>* const variable_data,
- const CSSParserContext* context) {
+ const CSSParserContext& context) {
CSSParserTokenRange token_range(tokens);
if (!token_range.AtEnd()) {
scoped_refptr<CSSVariableData> unparsed_css_variable_data =
- CSSVariableData::Create(token_range, false, false, context->BaseURL(),
- context->Charset());
+ CSSVariableData::Create(token_range, false, false, context.BaseURL(),
+ context.Charset());
if (unparsed_css_variable_data.get()) {
variable_data->push_back(std::move(unparsed_css_variable_data));
return true;
@@ -97,7 +98,7 @@ CSSFunctionValue* ConsumeFilterFunction(CSSParserTokenRange& range,
if (filter_type == CSSValueID::kDropShadow) {
parsed_value = css_parsing_utils::ParseSingleShadow(
- args, context.Mode(), css_parsing_utils::AllowInsetAndSpread::kForbid);
+ args, context, css_parsing_utils::AllowInsetAndSpread::kForbid);
} else {
if (args.AtEnd()) {
context.Count(WebFeature::kCSSFilterFunctionNoArguments);
@@ -105,25 +106,27 @@ CSSFunctionValue* ConsumeFilterFunction(CSSParserTokenRange& range,
}
if (filter_type == CSSValueID::kBrightness) {
// FIXME (crbug.com/397061): Support calc expressions like calc(10% + 0.5)
- parsed_value =
- css_property_parser_helpers::ConsumePercent(args, kValueRangeAll);
+ parsed_value = css_property_parser_helpers::ConsumePercent(
+ args, context, kValueRangeAll);
if (!parsed_value) {
parsed_value = css_property_parser_helpers::ConsumeNumber(
- args, kValueRangeNonNegative);
+ args, context, kValueRangeNonNegative);
}
} else if (filter_type == CSSValueID::kHueRotate) {
parsed_value = css_property_parser_helpers::ConsumeAngle(
- args, &context, WebFeature::kUnitlessZeroAngleFilter);
+ args, context, WebFeature::kUnitlessZeroAngleFilter);
} else if (filter_type == CSSValueID::kBlur) {
+ CSSParserContext::ParserModeOverridingScope scope(context,
+ kHTMLStandardMode);
parsed_value = css_property_parser_helpers::ConsumeLength(
- args, kHTMLStandardMode, kValueRangeNonNegative);
+ args, context, kValueRangeNonNegative);
} else {
// FIXME (crbug.com/397061): Support calc expressions like calc(10% + 0.5)
parsed_value = css_property_parser_helpers::ConsumePercent(
- args, kValueRangeNonNegative);
+ args, context, kValueRangeNonNegative);
if (!parsed_value) {
parsed_value = css_property_parser_helpers::ConsumeNumber(
- args, kValueRangeNonNegative);
+ args, context, kValueRangeNonNegative);
}
if (parsed_value && filter_type != CSSValueID::kSaturate &&
filter_type != CSSValueID::kContrast) {
@@ -189,47 +192,52 @@ class MathFunctionParser {
STACK_ALLOCATED();
public:
- explicit MathFunctionParser(CSSParserTokenRange& range,
- ValueRange value_range = kValueRangeAll)
+ MathFunctionParser(CSSParserTokenRange& range,
+ const CSSParserContext& context,
+ ValueRange value_range)
: source_range_(range), range_(range) {
const CSSParserToken& token = range.Peek();
- if (token.FunctionId() == CSSValueID::kCalc ||
- token.FunctionId() == CSSValueID::kWebkitCalc) {
- calc_value_ = CSSMathFunctionValue::Create(
- CSSMathExpressionNode::ParseCalc(ConsumeFunction(range_)),
- value_range);
- return;
- }
-
- if (RuntimeEnabledFeatures::CSSComparisonFunctionsEnabled()) {
- switch (token.FunctionId()) {
- case CSSValueID::kMin:
- calc_value_ = CSSMathFunctionValue::Create(
- CSSMathExpressionNode::ParseMin(ConsumeFunction(range_)),
- value_range);
- return;
- case CSSValueID::kMax:
- calc_value_ = CSSMathFunctionValue::Create(
- CSSMathExpressionNode::ParseMax(ConsumeFunction(range_)),
- value_range);
- return;
- case CSSValueID::kClamp:
- calc_value_ = CSSMathFunctionValue::Create(
- CSSMathExpressionNode::ParseClamp(ConsumeFunction(range_)),
- value_range);
- return;
- default:
- break;
- }
+ switch (token.FunctionId()) {
+ case CSSValueID::kCalc:
+ case CSSValueID::kWebkitCalc:
+ calc_value_ = CSSMathFunctionValue::Create(
+ CSSMathExpressionNode::ParseCalc(ConsumeFunction(range_)),
+ value_range);
+ break;
+ case CSSValueID::kMin:
+ calc_value_ = CSSMathFunctionValue::Create(
+ CSSMathExpressionNode::ParseMin(ConsumeFunction(range_)),
+ value_range);
+ break;
+ case CSSValueID::kMax:
+ calc_value_ = CSSMathFunctionValue::Create(
+ CSSMathExpressionNode::ParseMax(ConsumeFunction(range_)),
+ value_range);
+ break;
+ case CSSValueID::kClamp:
+ calc_value_ = CSSMathFunctionValue::Create(
+ CSSMathExpressionNode::ParseClamp(ConsumeFunction(range_)),
+ value_range);
+ break;
+ default:
+ break;
}
+ if (calc_value_ && calc_value_->HasComparisons())
+ context.Count(WebFeature::kCSSComparisonFunctions);
}
+ explicit MathFunctionParser(CSSParserTokenRange& range,
+ const CSSParserContext& context)
+ : MathFunctionParser(range, context, kValueRangeAll) {}
+
const CSSMathFunctionValue* Value() const { return calc_value_; }
CSSMathFunctionValue* ConsumeValue() {
if (!calc_value_)
return nullptr;
source_range_ = range_;
- return calc_value_.Release();
+ CSSMathFunctionValue* result = calc_value_;
+ calc_value_ = nullptr;
+ return result;
}
CSSPrimitiveValue* ConsumeRoundedInt() {
@@ -264,10 +272,11 @@ class MathFunctionParser {
private:
CSSParserTokenRange& source_range_;
CSSParserTokenRange range_;
- Member<CSSMathFunctionValue> calc_value_;
+ CSSMathFunctionValue* calc_value_ = nullptr;
};
CSSPrimitiveValue* ConsumeInteger(CSSParserTokenRange& range,
+ const CSSParserContext& context,
double minimum_value) {
const CSSParserToken& token = range.Peek();
if (token.GetType() == kNumberToken) {
@@ -278,7 +287,7 @@ CSSPrimitiveValue* ConsumeInteger(CSSParserTokenRange& range,
range.ConsumeIncludingWhitespace().NumericValue(),
CSSPrimitiveValue::UnitType::kInteger);
}
- MathFunctionParser math_parser(range);
+ MathFunctionParser math_parser(range, context);
if (const CSSMathFunctionValue* math_value = math_parser.Value()) {
if (!RuntimeEnabledFeatures::CSSCalcAsIntEnabled() && !math_value->IsInt())
return nullptr;
@@ -305,13 +314,14 @@ CSSPrimitiveValue* ConsumeInteger(CSSParserTokenRange& range,
// function with this behavior allows us to implement [1] gradually.
//
// [1] https://drafts.csswg.org/css-values-4/#calc-type-checking
-CSSPrimitiveValue* ConsumeIntegerOrNumberCalc(CSSParserTokenRange& range) {
+CSSPrimitiveValue* ConsumeIntegerOrNumberCalc(CSSParserTokenRange& range,
+ const CSSParserContext& context) {
CSSParserTokenRange int_range(range);
- if (CSSPrimitiveValue* value = ConsumeInteger(int_range)) {
+ if (CSSPrimitiveValue* value = ConsumeInteger(int_range, context)) {
range = int_range;
return value;
}
- MathFunctionParser math_parser(range);
+ MathFunctionParser math_parser(range, context);
if (const CSSMathFunctionValue* calculation = math_parser.Value()) {
if (calculation->Category() != kCalcNumber)
return nullptr;
@@ -320,21 +330,25 @@ CSSPrimitiveValue* ConsumeIntegerOrNumberCalc(CSSParserTokenRange& range) {
return nullptr;
}
-CSSPrimitiveValue* ConsumePositiveInteger(CSSParserTokenRange& range) {
- return ConsumeInteger(range, 1);
+CSSPrimitiveValue* ConsumePositiveInteger(CSSParserTokenRange& range,
+ const CSSParserContext& context) {
+ return ConsumeInteger(range, context, 1);
}
-bool ConsumeNumberRaw(CSSParserTokenRange& range, double& result) {
+bool ConsumeNumberRaw(CSSParserTokenRange& range,
+ const CSSParserContext& context,
+ double& result) {
if (range.Peek().GetType() == kNumberToken) {
result = range.ConsumeIncludingWhitespace().NumericValue();
return true;
}
- MathFunctionParser math_parser(range, kValueRangeAll);
+ MathFunctionParser math_parser(range, context, kValueRangeAll);
return math_parser.ConsumeNumberRaw(result);
}
// TODO(timloh): Work out if this can just call consumeNumberRaw
CSSPrimitiveValue* ConsumeNumber(CSSParserTokenRange& range,
+ const CSSParserContext& context,
ValueRange value_range) {
const CSSParserToken& token = range.Peek();
if (token.GetType() == kNumberToken) {
@@ -343,7 +357,7 @@ CSSPrimitiveValue* ConsumeNumber(CSSParserTokenRange& range,
return CSSNumericLiteralValue::Create(
range.ConsumeIncludingWhitespace().NumericValue(), token.GetUnitType());
}
- MathFunctionParser math_parser(range, kValueRangeAll);
+ MathFunctionParser math_parser(range, context, kValueRangeAll);
if (const CSSMathFunctionValue* calculation = math_parser.Value()) {
// TODO(rwlbuis) Calcs should not be subject to parse time range checks.
// spec: https://drafts.csswg.org/css-values-3/#calc-range
@@ -364,14 +378,14 @@ inline bool ShouldAcceptUnitlessLength(double value,
}
CSSPrimitiveValue* ConsumeLength(CSSParserTokenRange& range,
- CSSParserMode css_parser_mode,
+ const CSSParserContext& context,
ValueRange value_range,
UnitlessQuirk unitless) {
const CSSParserToken& token = range.Peek();
if (token.GetType() == kDimensionToken) {
switch (token.GetUnitType()) {
case CSSPrimitiveValue::UnitType::kQuirkyEms:
- if (css_parser_mode != kUASheetMode)
+ if (context.Mode() != kUASheetMode)
return nullptr;
FALLTHROUGH;
case CSSPrimitiveValue::UnitType::kEms:
@@ -400,26 +414,27 @@ CSSPrimitiveValue* ConsumeLength(CSSParserTokenRange& range,
range.ConsumeIncludingWhitespace().NumericValue(), token.GetUnitType());
}
if (token.GetType() == kNumberToken) {
- if (!ShouldAcceptUnitlessLength(token.NumericValue(), css_parser_mode,
+ if (!ShouldAcceptUnitlessLength(token.NumericValue(), context.Mode(),
unitless) ||
(value_range == kValueRangeNonNegative && token.NumericValue() < 0))
return nullptr;
CSSPrimitiveValue::UnitType unit_type =
CSSPrimitiveValue::UnitType::kPixels;
- if (css_parser_mode == kSVGAttributeMode)
+ if (context.Mode() == kSVGAttributeMode)
unit_type = CSSPrimitiveValue::UnitType::kUserUnits;
return CSSNumericLiteralValue::Create(
range.ConsumeIncludingWhitespace().NumericValue(), unit_type);
}
- if (css_parser_mode == kSVGAttributeMode)
+ if (context.Mode() == kSVGAttributeMode)
return nullptr;
- MathFunctionParser math_parser(range, value_range);
+ MathFunctionParser math_parser(range, context, value_range);
if (math_parser.Value() && math_parser.Value()->Category() == kCalcLength)
return math_parser.ConsumeValue();
return nullptr;
}
CSSPrimitiveValue* ConsumePercent(CSSParserTokenRange& range,
+ const CSSParserContext& context,
ValueRange value_range) {
const CSSParserToken& token = range.Peek();
if (token.GetType() == kPercentageToken) {
@@ -429,7 +444,7 @@ CSSPrimitiveValue* ConsumePercent(CSSParserTokenRange& range,
range.ConsumeIncludingWhitespace().NumericValue(),
CSSPrimitiveValue::UnitType::kPercentage);
}
- MathFunctionParser math_parser(range, value_range);
+ MathFunctionParser math_parser(range, context, value_range);
if (const CSSMathFunctionValue* calculation = math_parser.Value()) {
if (calculation->Category() == kCalcPercent)
return math_parser.ConsumeValue();
@@ -437,11 +452,14 @@ CSSPrimitiveValue* ConsumePercent(CSSParserTokenRange& range,
return nullptr;
}
-CSSPrimitiveValue* ConsumeAlphaValue(CSSParserTokenRange& range) {
- if (CSSPrimitiveValue* value = ConsumeNumber(range, kValueRangeAll)) {
+CSSPrimitiveValue* ConsumeAlphaValue(CSSParserTokenRange& range,
+ const CSSParserContext& context) {
+ if (CSSPrimitiveValue* value =
+ ConsumeNumber(range, context, kValueRangeAll)) {
return value;
}
- if (CSSPrimitiveValue* value = ConsumePercent(range, kValueRangeAll)) {
+ if (CSSPrimitiveValue* value =
+ ConsumePercent(range, context, kValueRangeAll)) {
return CSSNumericLiteralValue::Create(value->GetDoubleValue() / 100.0,
CSSPrimitiveValue::UnitType::kNumber);
}
@@ -465,17 +483,17 @@ bool CanConsumeCalcValue(CalculationCategory category,
}
CSSPrimitiveValue* ConsumeLengthOrPercent(CSSParserTokenRange& range,
- CSSParserMode css_parser_mode,
+ const CSSParserContext& context,
ValueRange value_range,
UnitlessQuirk unitless) {
const CSSParserToken& token = range.Peek();
if (token.GetType() == kDimensionToken || token.GetType() == kNumberToken)
- return ConsumeLength(range, css_parser_mode, value_range, unitless);
+ return ConsumeLength(range, context, value_range, unitless);
if (token.GetType() == kPercentageToken)
- return ConsumePercent(range, value_range);
- MathFunctionParser math_parser(range, value_range);
+ return ConsumePercent(range, context, value_range);
+ MathFunctionParser math_parser(range, context, value_range);
if (const CSSMathFunctionValue* calculation = math_parser.Value()) {
- if (CanConsumeCalcValue(calculation->Category(), css_parser_mode))
+ if (CanConsumeCalcValue(calculation->Category(), context.Mode()))
return math_parser.ConsumeValue();
}
return nullptr;
@@ -510,8 +528,9 @@ CSSPrimitiveValue* ConsumeSVGGeometryPropertyLength(
CSSParserTokenRange& range,
const CSSParserContext& context,
ValueRange value_range) {
- CSSPrimitiveValue* value = ConsumeLengthOrPercent(
- range, kSVGAttributeMode, value_range, UnitlessQuirk::kForbid);
+ CSSParserContext::ParserModeOverridingScope scope(context, kSVGAttributeMode);
+ CSSPrimitiveValue* value = ConsumeLengthOrPercent(range, context, value_range,
+ UnitlessQuirk::kForbid);
if (IsNonZeroUserUnitsValue(value))
context.Count(WebFeature::kSVGGeometryPropertyHasNonZeroUnitlessValue);
return value;
@@ -522,18 +541,15 @@ CSSPrimitiveValue* ConsumeGradientLengthOrPercent(
const CSSParserContext& context,
ValueRange value_range,
UnitlessQuirk unitless) {
- return ConsumeLengthOrPercent(range, context.Mode(), value_range, unitless);
+ return ConsumeLengthOrPercent(range, context, value_range, unitless);
}
CSSPrimitiveValue* ConsumeAngle(
CSSParserTokenRange& range,
- const CSSParserContext* context,
+ const CSSParserContext& context,
base::Optional<WebFeature> unitless_zero_feature,
double minimum_value,
double maximum_value) {
- // Ensure that we have a context for counting the
- // unitless_zero_feature if it is requested.
- DCHECK(context || !unitless_zero_feature);
const CSSParserToken& token = range.Peek();
if (token.GetType() == kDimensionToken) {
switch (token.GetUnitType()) {
@@ -551,11 +567,11 @@ CSSPrimitiveValue* ConsumeAngle(
if (token.GetType() == kNumberToken && token.NumericValue() == 0 &&
unitless_zero_feature) {
range.ConsumeIncludingWhitespace();
- context->Count(*unitless_zero_feature);
+ context.Count(*unitless_zero_feature);
return CSSNumericLiteralValue::Create(
0, CSSPrimitiveValue::UnitType::kDegrees);
}
- MathFunctionParser math_parser(range, kValueRangeAll);
+ MathFunctionParser math_parser(range, context, kValueRangeAll);
if (const CSSMathFunctionValue* calculation = math_parser.Value()) {
if (calculation->Category() != kCalcAngle)
return nullptr;
@@ -576,7 +592,7 @@ CSSPrimitiveValue* ConsumeAngle(
CSSPrimitiveValue* ConsumeAngle(
CSSParserTokenRange& range,
- const CSSParserContext* context,
+ const CSSParserContext& context,
base::Optional<WebFeature> unitless_zero_feature) {
return ConsumeAngle(range, context, std::move(unitless_zero_feature),
std::numeric_limits<double>::lowest(),
@@ -584,6 +600,7 @@ CSSPrimitiveValue* ConsumeAngle(
}
CSSPrimitiveValue* ConsumeTime(CSSParserTokenRange& range,
+ const CSSParserContext& context,
ValueRange value_range) {
const CSSParserToken& token = range.Peek();
if (token.GetType() == kDimensionToken) {
@@ -597,7 +614,7 @@ CSSPrimitiveValue* ConsumeTime(CSSParserTokenRange& range,
token.GetUnitType());
return nullptr;
}
- MathFunctionParser math_parser(range, value_range);
+ MathFunctionParser math_parser(range, context, value_range);
if (const CSSMathFunctionValue* calculation = math_parser.Value()) {
if (calculation->Category() == kCalcTime)
return math_parser.ConsumeValue();
@@ -667,7 +684,7 @@ CSSStringValue* ConsumeString(CSSParserTokenRange& range) {
}
StringView ConsumeUrlAsStringView(CSSParserTokenRange& range,
- const CSSParserContext* context) {
+ const CSSParserContext& context) {
StringView url;
const CSSParserToken& token = range.Peek();
if (token.GetType() == kUrlToken) {
@@ -688,7 +705,7 @@ StringView ConsumeUrlAsStringView(CSSParserTokenRange& range,
// Invalidate the URL if only data URLs are allowed and the protocol is not
// data.
if (!url.IsNull() &&
- context->ResourceFetchRestriction() ==
+ context.ResourceFetchRestriction() ==
ResourceFetchRestriction::kOnlyDataUrls &&
!ProtocolIs(url.ToString(), "data")) {
// The StringView must be instantiated with an empty string otherwise the
@@ -701,13 +718,13 @@ StringView ConsumeUrlAsStringView(CSSParserTokenRange& range,
}
cssvalue::CSSURIValue* ConsumeUrl(CSSParserTokenRange& range,
- const CSSParserContext* context) {
+ const CSSParserContext& context) {
StringView url = ConsumeUrlAsStringView(range, context);
if (url.IsNull())
return nullptr;
- String url_string = url.ToString();
- return cssvalue::CSSURIValue::Create(url_string,
- context->CompleteURL(url_string));
+ AtomicString url_string(url.ToString());
+ return MakeGarbageCollected<cssvalue::CSSURIValue>(
+ url_string, context.CompleteURL(url_string));
}
static int ClampRGBComponent(const CSSPrimitiveValue& value) {
@@ -719,13 +736,16 @@ static int ClampRGBComponent(const CSSPrimitiveValue& value) {
return clampTo<int>(round(result), 0, 255);
}
-static bool ParseRGBParameters(CSSParserTokenRange& range, RGBA32& result) {
+static bool ParseRGBParameters(CSSParserTokenRange& range,
+ const CSSParserContext& context,
+ RGBA32& result) {
DCHECK(range.Peek().FunctionId() == CSSValueID::kRgb ||
range.Peek().FunctionId() == CSSValueID::kRgba);
CSSParserTokenRange args = ConsumeFunction(range);
- CSSPrimitiveValue* color_parameter = ConsumeNumber(args, kValueRangeAll);
+ CSSPrimitiveValue* color_parameter =
+ ConsumeNumber(args, context, kValueRangeAll);
if (!color_parameter)
- color_parameter = ConsumePercent(args, kValueRangeAll);
+ color_parameter = ConsumePercent(args, context, kValueRangeAll);
if (!color_parameter)
return false;
const bool is_percent = color_parameter->IsPercentage();
@@ -740,8 +760,8 @@ static bool ParseRGBParameters(CSSParserTokenRange& range, RGBA32& result) {
} else if (requires_commas || args.AtEnd()) {
return false;
}
- color_parameter = is_percent ? ConsumePercent(args, kValueRangeAll)
- : ConsumeNumber(args, kValueRangeAll);
+ color_parameter = is_percent ? ConsumePercent(args, context, kValueRangeAll)
+ : ConsumeNumber(args, context, kValueRangeAll);
if (!color_parameter)
return false;
color_array[i] = ClampRGBComponent(*color_parameter);
@@ -754,8 +774,9 @@ static bool ParseRGBParameters(CSSParserTokenRange& range, RGBA32& result) {
return false;
if (comma_consumed || slash_consumed) {
double alpha;
- if (!ConsumeNumberRaw(args, alpha)) {
- CSSPrimitiveValue* alpha_percent = ConsumePercent(args, kValueRangeAll);
+ if (!ConsumeNumberRaw(args, context, alpha)) {
+ CSSPrimitiveValue* alpha_percent =
+ ConsumePercent(args, context, kValueRangeAll);
if (!alpha_percent)
return false;
else
@@ -772,14 +793,16 @@ static bool ParseRGBParameters(CSSParserTokenRange& range, RGBA32& result) {
return args.AtEnd();
}
-static bool ParseHSLParameters(CSSParserTokenRange& range, RGBA32& result) {
+static bool ParseHSLParameters(CSSParserTokenRange& range,
+ const CSSParserContext& context,
+ RGBA32& result) {
DCHECK(range.Peek().FunctionId() == CSSValueID::kHsl ||
range.Peek().FunctionId() == CSSValueID::kHsla);
CSSParserTokenRange args = ConsumeFunction(range);
- CSSPrimitiveValue* hsl_value = ConsumeAngle(args, nullptr, base::nullopt);
+ CSSPrimitiveValue* hsl_value = ConsumeAngle(args, context, base::nullopt);
double angle_value;
if (!hsl_value) {
- hsl_value = ConsumeNumber(args, kValueRangeAll);
+ hsl_value = ConsumeNumber(args, context, kValueRangeAll);
if (!hsl_value)
return false;
angle_value = hsl_value->GetDoubleValue();
@@ -797,7 +820,7 @@ static bool ParseHSLParameters(CSSParserTokenRange& range, RGBA32& result) {
} else if (requires_commas || args.AtEnd()) {
return false;
}
- hsl_value = ConsumePercent(args, kValueRangeAll);
+ hsl_value = ConsumePercent(args, context, kValueRangeAll);
if (!hsl_value)
return false;
double double_value = hsl_value->GetDoubleValue();
@@ -812,8 +835,9 @@ static bool ParseHSLParameters(CSSParserTokenRange& range, RGBA32& result) {
(slash_consumed && requires_commas))
return false;
if (comma_consumed || slash_consumed) {
- if (!ConsumeNumberRaw(args, alpha)) {
- CSSPrimitiveValue* alpha_percent = ConsumePercent(args, kValueRangeAll);
+ if (!ConsumeNumberRaw(args, context, alpha)) {
+ CSSPrimitiveValue* alpha_percent =
+ ConsumePercent(args, context, kValueRangeAll);
if (!alpha_percent)
return false;
else
@@ -861,82 +885,76 @@ static bool ParseHexColor(CSSParserTokenRange& range,
return true;
}
-static bool ParseColorFunction(CSSParserTokenRange& range, RGBA32& result) {
+static bool ParseColorFunction(CSSParserTokenRange& range,
+ const CSSParserContext& context,
+ RGBA32& result) {
CSSValueID function_id = range.Peek().FunctionId();
if (function_id < CSSValueID::kRgb || function_id > CSSValueID::kHsla)
return false;
CSSParserTokenRange color_range = range;
if ((function_id <= CSSValueID::kRgba &&
- !ParseRGBParameters(color_range, result)) ||
+ !ParseRGBParameters(color_range, context, result)) ||
(function_id >= CSSValueID::kHsl &&
- !ParseHSLParameters(color_range, result)))
+ !ParseHSLParameters(color_range, context, result)))
return false;
range = color_range;
return true;
}
-static CSSLightDarkColorPair* ParseLightDarkColor(CSSParserTokenRange& range,
- CSSParserMode mode) {
+static CSSLightDarkColorPair* ParseLightDarkColor(
+ CSSParserTokenRange& range,
+ const CSSParserContext& context) {
if (range.Peek().FunctionId() != CSSValueID::kInternalLightDarkColor)
return nullptr;
- if (!isValueAllowedInMode(CSSValueID::kInternalLightDarkColor, mode))
+ if (!isValueAllowedInMode(CSSValueID::kInternalLightDarkColor,
+ context.Mode()))
return nullptr;
+ CSSParserContext::ParserModeOverridingScope scope(context, kUASheetMode);
CSSParserTokenRange args = ConsumeFunction(range);
- CSSValue* light_color = ConsumeColor(args, kUASheetMode);
+ CSSValue* light_color = ConsumeColor(args, context);
if (!light_color || !ConsumeCommaIncludingWhitespace(args))
return nullptr;
- CSSValue* dark_color = ConsumeColor(args, kUASheetMode);
+ CSSValue* dark_color = ConsumeColor(args, context);
if (!dark_color || !args.AtEnd())
return nullptr;
return MakeGarbageCollected<CSSLightDarkColorPair>(light_color, dark_color);
}
CSSValue* ConsumeColor(CSSParserTokenRange& range,
- CSSParserMode css_parser_mode,
+ const CSSParserContext& context,
bool accept_quirky_colors) {
CSSValueID id = range.Peek().Id();
if (StyleColor::IsColorKeyword(id)) {
- if (!isValueAllowedInMode(id, css_parser_mode))
+ if (!isValueAllowedInMode(id, context.Mode()))
return nullptr;
CSSIdentifierValue* color = ConsumeIdent(range);
- if (!RuntimeEnabledFeatures::LinkSystemColorsEnabled() &&
- (color->GetValueID() == CSSValueID::kLinktext ||
- color->GetValueID() == CSSValueID::kVisitedtext)) {
- return nullptr;
- } else if (!RuntimeEnabledFeatures::NewSystemColorsEnabled() &&
- (id == CSSValueID::kActivetext || id == CSSValueID::kField ||
- id == CSSValueID::kFieldtext)) {
- return nullptr;
- }
return color;
}
RGBA32 color = Color::kTransparent;
if (!ParseHexColor(range, color, accept_quirky_colors) &&
- !ParseColorFunction(range, color)) {
- return ParseLightDarkColor(range, css_parser_mode);
+ !ParseColorFunction(range, context, color)) {
+ return ParseLightDarkColor(range, context);
}
return cssvalue::CSSColorValue::Create(color);
}
CSSValue* ConsumeLineWidth(CSSParserTokenRange& range,
- CSSParserMode css_parser_mode,
+ const CSSParserContext& context,
UnitlessQuirk unitless) {
CSSValueID id = range.Peek().Id();
if (id == CSSValueID::kThin || id == CSSValueID::kMedium ||
id == CSSValueID::kThick)
return ConsumeIdent(range);
- return ConsumeLength(range, css_parser_mode, kValueRangeNonNegative,
- unitless);
+ return ConsumeLength(range, context, kValueRangeNonNegative, unitless);
}
static CSSValue* ConsumePositionComponent(CSSParserTokenRange& range,
- CSSParserMode css_parser_mode,
+ const CSSParserContext& context,
UnitlessQuirk unitless,
bool& horizontal_edge,
bool& vertical_edge) {
if (range.Peek().GetType() != kIdentToken)
- return ConsumeLengthOrPercent(range, css_parser_mode, kValueRangeAll,
- unitless);
+ return ConsumeLengthOrPercent(range, context, kValueRangeAll, unitless);
CSSValueID id = range.Peek().Id();
if (id == CSSValueID::kLeft || id == CSSValueID::kRight) {
@@ -1047,7 +1065,7 @@ bool ConsumePosition(CSSParserTokenRange& range,
CSSValue*& result_y) {
bool horizontal_edge = false;
bool vertical_edge = false;
- CSSValue* value1 = ConsumePositionComponent(range, context.Mode(), unitless,
+ CSSValue* value1 = ConsumePositionComponent(range, context, unitless,
horizontal_edge, vertical_edge);
if (!value1)
return false;
@@ -1055,7 +1073,7 @@ bool ConsumePosition(CSSParserTokenRange& range,
horizontal_edge = true;
CSSParserTokenRange range_after_first_consume = range;
- CSSValue* value2 = ConsumePositionComponent(range, context.Mode(), unitless,
+ CSSValue* value2 = ConsumePositionComponent(range, context, unitless,
horizontal_edge, vertical_edge);
if (!value2) {
PositionFromOneValue(value1, result_x, result_y);
@@ -1072,9 +1090,10 @@ bool ConsumePosition(CSSParserTokenRange& range,
!!identifier_value2 != (range.Peek().GetType() == kIdentToken) &&
(identifier_value2
? identifier_value2->GetValueID()
- : identifier_value1->GetValueID()) != CSSValueID::kCenter)
- value3 = ConsumePositionComponent(range, context.Mode(), unitless,
- horizontal_edge, vertical_edge);
+ : identifier_value1->GetValueID()) != CSSValueID::kCenter) {
+ value3 = ConsumePositionComponent(range, context, unitless, horizontal_edge,
+ vertical_edge);
+ }
if (!value3) {
if (vertical_edge && !value2->IsIdentifierValue()) {
range = range_after_first_consume;
@@ -1089,9 +1108,10 @@ bool ConsumePosition(CSSParserTokenRange& range,
auto* identifier_value3 = DynamicTo<CSSIdentifierValue>(value3);
if (identifier_value3 &&
identifier_value3->GetValueID() != CSSValueID::kCenter &&
- range.Peek().GetType() != kIdentToken)
- value4 = ConsumePositionComponent(range, context.Mode(), unitless,
- horizontal_edge, vertical_edge);
+ range.Peek().GetType() != kIdentToken) {
+ value4 = ConsumePositionComponent(range, context, unitless, horizontal_edge,
+ vertical_edge);
+ }
if (!value4) {
if (!three_value_position) {
@@ -1135,25 +1155,25 @@ CSSValuePair* ConsumePosition(CSSParserTokenRange& range,
}
bool ConsumeOneOrTwoValuedPosition(CSSParserTokenRange& range,
- CSSParserMode css_parser_mode,
+ const CSSParserContext& context,
UnitlessQuirk unitless,
CSSValue*& result_x,
CSSValue*& result_y) {
bool horizontal_edge = false;
bool vertical_edge = false;
- CSSValue* value1 = ConsumePositionComponent(range, css_parser_mode, unitless,
+ CSSValue* value1 = ConsumePositionComponent(range, context, unitless,
horizontal_edge, vertical_edge);
if (!value1)
return false;
if (!value1->IsIdentifierValue())
horizontal_edge = true;
- if (vertical_edge && ConsumeLengthOrPercent(range, css_parser_mode,
- kValueRangeAll, unitless)) {
+ if (vertical_edge &&
+ ConsumeLengthOrPercent(range, context, kValueRangeAll, unitless)) {
// <length-percentage> is not permitted after top | bottom.
return false;
}
- CSSValue* value2 = ConsumePositionComponent(range, css_parser_mode, unitless,
+ CSSValue* value2 = ConsumePositionComponent(range, context, unitless,
horizontal_edge, vertical_edge);
if (!value2) {
PositionFromOneValue(value1, result_x, result_y);
@@ -1171,8 +1191,7 @@ bool ConsumeBorderShorthand(CSSParserTokenRange& range,
while (!result_width || !result_style || !result_color) {
if (!result_width) {
result_width = css_property_parser_helpers::ConsumeLineWidth(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kForbid);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kForbid);
if (result_width)
continue;
}
@@ -1184,8 +1203,7 @@ bool ConsumeBorderShorthand(CSSParserTokenRange& range,
continue;
}
if (!result_color) {
- result_color =
- css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ result_color = css_property_parser_helpers::ConsumeColor(range, context);
if (result_color)
continue;
}
@@ -1207,6 +1225,7 @@ bool ConsumeBorderShorthand(CSSParserTokenRange& range,
// This should go away once we drop support for -webkit-gradient
static CSSPrimitiveValue* ConsumeDeprecatedGradientPoint(
CSSParserTokenRange& args,
+ const CSSParserContext& context,
bool horizontal) {
if (args.Peek().GetType() == kIdentToken) {
if ((horizontal && ConsumeIdent<CSSValueID::kLeft>(args)) ||
@@ -1222,25 +1241,25 @@ static CSSPrimitiveValue* ConsumeDeprecatedGradientPoint(
50., CSSPrimitiveValue::UnitType::kPercentage);
return nullptr;
}
- CSSPrimitiveValue* result = ConsumePercent(args, kValueRangeAll);
+ CSSPrimitiveValue* result = ConsumePercent(args, context, kValueRangeAll);
if (!result)
- result = ConsumeNumber(args, kValueRangeAll);
+ result = ConsumeNumber(args, context, kValueRangeAll);
return result;
}
// Used to parse colors for -webkit-gradient(...).
static CSSValue* ConsumeDeprecatedGradientStopColor(
CSSParserTokenRange& args,
- CSSParserMode css_parser_mode) {
+ const CSSParserContext& context) {
if (args.Peek().Id() == CSSValueID::kCurrentcolor)
return nullptr;
- return ConsumeColor(args, css_parser_mode);
+ return ConsumeColor(args, context);
}
static bool ConsumeDeprecatedGradientColorStop(
CSSParserTokenRange& range,
cssvalue::CSSGradientColorStop& stop,
- CSSParserMode css_parser_mode) {
+ const CSSParserContext& context) {
CSSValueID id = range.Peek().FunctionId();
if (id != CSSValueID::kFrom && id != CSSValueID::kTo &&
id != CSSValueID::kColorStop)
@@ -1252,9 +1271,10 @@ static bool ConsumeDeprecatedGradientColorStop(
position = (id == CSSValueID::kFrom) ? 0 : 1;
} else {
DCHECK(id == CSSValueID::kColorStop);
- if (CSSPrimitiveValue* percent_value = ConsumePercent(args, kValueRangeAll))
+ if (CSSPrimitiveValue* percent_value =
+ ConsumePercent(args, context, kValueRangeAll))
position = percent_value->GetDoubleValue() / 100.0;
- else if (!ConsumeNumberRaw(args, position))
+ else if (!ConsumeNumberRaw(args, context, position))
return false;
if (!ConsumeCommaIncludingWhitespace(args))
@@ -1263,12 +1283,12 @@ static bool ConsumeDeprecatedGradientColorStop(
stop.offset_ = CSSNumericLiteralValue::Create(
position, CSSPrimitiveValue::UnitType::kNumber);
- stop.color_ = ConsumeDeprecatedGradientStopColor(args, css_parser_mode);
+ stop.color_ = ConsumeDeprecatedGradientStopColor(args, context);
return stop.color_ && args.AtEnd();
}
static CSSValue* ConsumeDeprecatedGradient(CSSParserTokenRange& args,
- CSSParserMode css_parser_mode) {
+ const CSSParserContext& context) {
CSSValueID id = args.ConsumeIncludingWhitespace().Id();
if (id != CSSValueID::kRadial && id != CSSValueID::kLinear)
return nullptr;
@@ -1276,11 +1296,12 @@ static CSSValue* ConsumeDeprecatedGradient(CSSParserTokenRange& args,
if (!ConsumeCommaIncludingWhitespace(args))
return nullptr;
- const CSSPrimitiveValue* first_x = ConsumeDeprecatedGradientPoint(args, true);
+ const CSSPrimitiveValue* first_x =
+ ConsumeDeprecatedGradientPoint(args, context, true);
if (!first_x)
return nullptr;
const CSSPrimitiveValue* first_y =
- ConsumeDeprecatedGradientPoint(args, false);
+ ConsumeDeprecatedGradientPoint(args, context, false);
if (!first_y)
return nullptr;
if (!ConsumeCommaIncludingWhitespace(args))
@@ -1289,17 +1310,17 @@ static CSSValue* ConsumeDeprecatedGradient(CSSParserTokenRange& args,
// For radial gradients only, we now expect a numeric radius.
const CSSPrimitiveValue* first_radius = nullptr;
if (id == CSSValueID::kRadial) {
- first_radius = ConsumeNumber(args, kValueRangeNonNegative);
+ first_radius = ConsumeNumber(args, context, kValueRangeNonNegative);
if (!first_radius || !ConsumeCommaIncludingWhitespace(args))
return nullptr;
}
const CSSPrimitiveValue* second_x =
- ConsumeDeprecatedGradientPoint(args, true);
+ ConsumeDeprecatedGradientPoint(args, context, true);
if (!second_x)
return nullptr;
const CSSPrimitiveValue* second_y =
- ConsumeDeprecatedGradientPoint(args, false);
+ ConsumeDeprecatedGradientPoint(args, context, false);
if (!second_y)
return nullptr;
@@ -1308,24 +1329,24 @@ static CSSValue* ConsumeDeprecatedGradient(CSSParserTokenRange& args,
if (id == CSSValueID::kRadial) {
if (!ConsumeCommaIncludingWhitespace(args))
return nullptr;
- second_radius = ConsumeNumber(args, kValueRangeNonNegative);
+ second_radius = ConsumeNumber(args, context, kValueRangeNonNegative);
if (!second_radius)
return nullptr;
}
- cssvalue::CSSGradientValue* result =
- (id == CSSValueID::kRadial)
- ? cssvalue::CSSRadialGradientValue::Create(
- first_x, first_y, first_radius, second_x, second_y,
- second_radius, cssvalue::kNonRepeating,
- cssvalue::kCSSDeprecatedRadialGradient)
- : MakeGarbageCollected<cssvalue::CSSLinearGradientValue>(
- first_x, first_y, second_x, second_y, nullptr,
- cssvalue::kNonRepeating,
- cssvalue::kCSSDeprecatedLinearGradient);
+ cssvalue::CSSGradientValue* result;
+ if (id == CSSValueID::kRadial) {
+ result = MakeGarbageCollected<cssvalue::CSSRadialGradientValue>(
+ first_x, first_y, first_radius, second_x, second_y, second_radius,
+ cssvalue::kNonRepeating, cssvalue::kCSSDeprecatedRadialGradient);
+ } else {
+ result = MakeGarbageCollected<cssvalue::CSSLinearGradientValue>(
+ first_x, first_y, second_x, second_y, nullptr, cssvalue::kNonRepeating,
+ cssvalue::kCSSDeprecatedLinearGradient);
+ }
cssvalue::CSSGradientColorStop stop;
while (ConsumeCommaIncludingWhitespace(args)) {
- if (!ConsumeDeprecatedGradientColorStop(args, stop, css_parser_mode))
+ if (!ConsumeDeprecatedGradientColorStop(args, stop, context))
return nullptr;
result->AddStop(stop);
}
@@ -1340,12 +1361,11 @@ static CSSPrimitiveValue* ConsumeGradientAngleOrPercent(
UnitlessQuirk) {
const CSSParserToken& token = range.Peek();
if (token.GetType() == kDimensionToken || token.GetType() == kNumberToken) {
- return ConsumeAngle(range, &context,
- WebFeature::kUnitlessZeroAngleGradient);
+ return ConsumeAngle(range, context, WebFeature::kUnitlessZeroAngleGradient);
}
if (token.GetType() == kPercentageToken)
- return ConsumePercent(range, value_range);
- MathFunctionParser math_parser(range, value_range);
+ return ConsumePercent(range, context, value_range);
+ MathFunctionParser math_parser(range, context, value_range);
if (const CSSMathFunctionValue* calculation = math_parser.Value()) {
CalculationCategory category = calculation->Category();
// TODO(fs): Add and support kCalcPercentAngle?
@@ -1373,7 +1393,7 @@ static bool ConsumeGradientColorStops(CSSParserTokenRange& range,
bool previous_stop_was_color_hint = true;
do {
cssvalue::CSSGradientColorStop stop;
- stop.color_ = ConsumeColor(range, context.Mode());
+ stop.color_ = ConsumeColor(range, context);
// Two hints in a row are not allowed.
if (!stop.color_ && (!supports_color_hints || previous_stop_was_color_hint))
return false;
@@ -1408,8 +1428,8 @@ static CSSValue* ConsumeDeprecatedRadialGradient(
cssvalue::CSSGradientRepeat repeating) {
CSSValue* center_x = nullptr;
CSSValue* center_y = nullptr;
- ConsumeOneOrTwoValuedPosition(args, context.Mode(), UnitlessQuirk::kForbid,
- center_x, center_y);
+ ConsumeOneOrTwoValuedPosition(args, context, UnitlessQuirk::kForbid, center_x,
+ center_y);
if ((center_x || center_y) && !ConsumeCommaIncludingWhitespace(args))
return nullptr;
@@ -1427,10 +1447,10 @@ static CSSValue* ConsumeDeprecatedRadialGradient(
const CSSPrimitiveValue* vertical_size = nullptr;
if (!shape && !size_keyword) {
horizontal_size =
- ConsumeLengthOrPercent(args, context.Mode(), kValueRangeNonNegative);
+ ConsumeLengthOrPercent(args, context, kValueRangeNonNegative);
if (horizontal_size) {
vertical_size =
- ConsumeLengthOrPercent(args, context.Mode(), kValueRangeNonNegative);
+ ConsumeLengthOrPercent(args, context, kValueRangeNonNegative);
if (!vertical_size)
return nullptr;
ConsumeCommaIncludingWhitespace(args);
@@ -1439,9 +1459,10 @@ static CSSValue* ConsumeDeprecatedRadialGradient(
ConsumeCommaIncludingWhitespace(args);
}
- cssvalue::CSSGradientValue* result = cssvalue::CSSRadialGradientValue::Create(
- center_x, center_y, shape, size_keyword, horizontal_size, vertical_size,
- repeating, cssvalue::kCSSPrefixedRadialGradient);
+ cssvalue::CSSGradientValue* result =
+ MakeGarbageCollected<cssvalue::CSSRadialGradientValue>(
+ center_x, center_y, shape, size_keyword, horizontal_size,
+ vertical_size, repeating, cssvalue::kCSSPrefixedRadialGradient);
return ConsumeGradientColorStops(args, context, result,
ConsumeGradientLengthOrPercent)
? result
@@ -1479,14 +1500,13 @@ static CSSValue* ConsumeRadialGradient(CSSParserTokenRange& args,
}
} else {
CSSPrimitiveValue* center =
- ConsumeLengthOrPercent(args, context.Mode(), kValueRangeNonNegative);
+ ConsumeLengthOrPercent(args, context, kValueRangeNonNegative);
if (!center)
break;
if (horizontal_size)
return nullptr;
horizontal_size = center;
- center =
- ConsumeLengthOrPercent(args, context.Mode(), kValueRangeNonNegative);
+ center = ConsumeLengthOrPercent(args, context, kValueRangeNonNegative);
if (center) {
vertical_size = center;
++i;
@@ -1530,9 +1550,10 @@ static CSSValue* ConsumeRadialGradient(CSSParserTokenRange& args,
return nullptr;
}
- cssvalue::CSSGradientValue* result = cssvalue::CSSRadialGradientValue::Create(
- center_x, center_y, shape, size_keyword, horizontal_size, vertical_size,
- repeating, cssvalue::kCSSRadialGradient);
+ cssvalue::CSSGradientValue* result =
+ MakeGarbageCollected<cssvalue::CSSRadialGradientValue>(
+ center_x, center_y, shape, size_keyword, horizontal_size,
+ vertical_size, repeating, cssvalue::kCSSRadialGradient);
return ConsumeGradientColorStops(args, context, result,
ConsumeGradientLengthOrPercent)
? result
@@ -1546,7 +1567,7 @@ static CSSValue* ConsumeLinearGradient(
cssvalue::CSSGradientType gradient_type) {
bool expect_comma = true;
const CSSPrimitiveValue* angle =
- ConsumeAngle(args, &context, WebFeature::kUnitlessZeroAngleGradient);
+ ConsumeAngle(args, context, WebFeature::kUnitlessZeroAngleGradient);
const CSSIdentifierValue* end_x = nullptr;
const CSSIdentifierValue* end_y = nullptr;
if (!angle) {
@@ -1584,7 +1605,7 @@ static CSSValue* ConsumeConicGradient(CSSParserTokenRange& args,
cssvalue::CSSGradientRepeat repeating) {
const CSSPrimitiveValue* from_angle = nullptr;
if (ConsumeIdent<CSSValueID::kFrom>(args)) {
- if (!(from_angle = ConsumeAngle(args, &context,
+ if (!(from_angle = ConsumeAngle(args, context,
WebFeature::kUnitlessZeroAngleGradient)))
return nullptr;
}
@@ -1603,7 +1624,7 @@ static CSSValue* ConsumeConicGradient(CSSParserTokenRange& args,
return nullptr;
}
- cssvalue::CSSGradientValue* result = cssvalue::CSSConicGradientValue::Create(
+ auto* result = MakeGarbageCollected<cssvalue::CSSConicGradientValue>(
center_x, center_y, from_angle, repeating);
return ConsumeGradientColorStops(args, context, result,
ConsumeGradientAngleOrPercent)
@@ -1612,13 +1633,14 @@ static CSSValue* ConsumeConicGradient(CSSParserTokenRange& args,
}
CSSValue* ConsumeImageOrNone(CSSParserTokenRange& range,
- const CSSParserContext* context) {
+ const CSSParserContext& context) {
if (range.Peek().Id() == CSSValueID::kNone)
return ConsumeIdent(range);
return ConsumeImage(range, context);
}
-CSSValue* ConsumeAxis(CSSParserTokenRange& range) {
+CSSValue* ConsumeAxis(CSSParserTokenRange& range,
+ const CSSParserContext& context) {
CSSValueID axis_id = range.Peek().Id();
if (axis_id == CSSValueID::kX || axis_id == CSSValueID::kY ||
axis_id == CSSValueID::kZ) {
@@ -1626,12 +1648,12 @@ CSSValue* ConsumeAxis(CSSParserTokenRange& range) {
return MakeGarbageCollected<cssvalue::CSSAxisValue>(axis_id);
}
- CSSValue* x_dimension =
- css_property_parser_helpers::ConsumeNumber(range, kValueRangeAll);
- CSSValue* y_dimension =
- css_property_parser_helpers::ConsumeNumber(range, kValueRangeAll);
- CSSValue* z_dimension =
- css_property_parser_helpers::ConsumeNumber(range, kValueRangeAll);
+ CSSValue* x_dimension = css_property_parser_helpers::ConsumeNumber(
+ range, context, kValueRangeAll);
+ CSSValue* y_dimension = css_property_parser_helpers::ConsumeNumber(
+ range, context, kValueRangeAll);
+ CSSValue* z_dimension = css_property_parser_helpers::ConsumeNumber(
+ range, context, kValueRangeAll);
if (!x_dimension || !y_dimension || !z_dimension)
return nullptr;
double x = To<CSSPrimitiveValue>(x_dimension)->GetDoubleValue();
@@ -1641,7 +1663,7 @@ CSSValue* ConsumeAxis(CSSParserTokenRange& range) {
}
static CSSValue* ConsumeCrossFade(CSSParserTokenRange& args,
- const CSSParserContext* context) {
+ const CSSParserContext& context) {
CSSValue* from_image_value = ConsumeImageOrNone(args, context);
if (!from_image_value || !ConsumeCommaIncludingWhitespace(args))
return nullptr;
@@ -1650,12 +1672,13 @@ static CSSValue* ConsumeCrossFade(CSSParserTokenRange& args,
return nullptr;
CSSPrimitiveValue* percentage = nullptr;
- if (CSSPrimitiveValue* percent_value = ConsumePercent(args, kValueRangeAll))
+ if (CSSPrimitiveValue* percent_value =
+ ConsumePercent(args, context, kValueRangeAll))
percentage = CSSNumericLiteralValue::Create(
clampTo<double>(percent_value->GetDoubleValue() / 100.0, 0, 1),
CSSPrimitiveValue::UnitType::kNumber);
else if (CSSPrimitiveValue* number_value =
- ConsumeNumber(args, kValueRangeAll))
+ ConsumeNumber(args, context, kValueRangeAll))
percentage = CSSNumericLiteralValue::Create(
clampTo<double>(number_value->GetDoubleValue(), 0, 1),
CSSPrimitiveValue::UnitType::kNumber);
@@ -1667,9 +1690,9 @@ static CSSValue* ConsumeCrossFade(CSSParserTokenRange& args,
}
static CSSValue* ConsumePaint(CSSParserTokenRange& args,
- const CSSParserContext* context) {
+ const CSSParserContext& context) {
const CSSParserToken& name_token = args.ConsumeIncludingWhitespace();
- CSSCustomIdentValue* name = ConsumeCustomIdentWithToken(name_token, *context);
+ CSSCustomIdentValue* name = ConsumeCustomIdentWithToken(name_token, context);
if (!name)
return nullptr;
@@ -1708,48 +1731,48 @@ static CSSValue* ConsumePaint(CSSParserTokenRange& args,
}
static CSSValue* ConsumeGeneratedImage(CSSParserTokenRange& range,
- const CSSParserContext* context) {
+ const CSSParserContext& context) {
CSSValueID id = range.Peek().FunctionId();
CSSParserTokenRange range_copy = range;
CSSParserTokenRange args = ConsumeFunction(range_copy);
CSSValue* result = nullptr;
if (id == CSSValueID::kRadialGradient) {
- result = ConsumeRadialGradient(args, *context, cssvalue::kNonRepeating);
+ result = ConsumeRadialGradient(args, context, cssvalue::kNonRepeating);
} else if (id == CSSValueID::kRepeatingRadialGradient) {
- result = ConsumeRadialGradient(args, *context, cssvalue::kRepeating);
+ result = ConsumeRadialGradient(args, context, cssvalue::kRepeating);
} else if (id == CSSValueID::kWebkitLinearGradient) {
- context->Count(WebFeature::kDeprecatedWebKitLinearGradient);
- result = ConsumeLinearGradient(args, *context, cssvalue::kNonRepeating,
+ context.Count(WebFeature::kDeprecatedWebKitLinearGradient);
+ result = ConsumeLinearGradient(args, context, cssvalue::kNonRepeating,
cssvalue::kCSSPrefixedLinearGradient);
} else if (id == CSSValueID::kWebkitRepeatingLinearGradient) {
- context->Count(WebFeature::kDeprecatedWebKitRepeatingLinearGradient);
- result = ConsumeLinearGradient(args, *context, cssvalue::kRepeating,
+ context.Count(WebFeature::kDeprecatedWebKitRepeatingLinearGradient);
+ result = ConsumeLinearGradient(args, context, cssvalue::kRepeating,
cssvalue::kCSSPrefixedLinearGradient);
} else if (id == CSSValueID::kRepeatingLinearGradient) {
- result = ConsumeLinearGradient(args, *context, cssvalue::kRepeating,
+ result = ConsumeLinearGradient(args, context, cssvalue::kRepeating,
cssvalue::kCSSLinearGradient);
} else if (id == CSSValueID::kLinearGradient) {
- result = ConsumeLinearGradient(args, *context, cssvalue::kNonRepeating,
+ result = ConsumeLinearGradient(args, context, cssvalue::kNonRepeating,
cssvalue::kCSSLinearGradient);
} else if (id == CSSValueID::kWebkitGradient) {
- context->Count(WebFeature::kDeprecatedWebKitGradient);
- result = ConsumeDeprecatedGradient(args, context->Mode());
+ context.Count(WebFeature::kDeprecatedWebKitGradient);
+ result = ConsumeDeprecatedGradient(args, context);
} else if (id == CSSValueID::kWebkitRadialGradient) {
- context->Count(WebFeature::kDeprecatedWebKitRadialGradient);
- result = ConsumeDeprecatedRadialGradient(args, *context,
- cssvalue::kNonRepeating);
+ context.Count(WebFeature::kDeprecatedWebKitRadialGradient);
+ result =
+ ConsumeDeprecatedRadialGradient(args, context, cssvalue::kNonRepeating);
} else if (id == CSSValueID::kWebkitRepeatingRadialGradient) {
- context->Count(WebFeature::kDeprecatedWebKitRepeatingRadialGradient);
+ context.Count(WebFeature::kDeprecatedWebKitRepeatingRadialGradient);
result =
- ConsumeDeprecatedRadialGradient(args, *context, cssvalue::kRepeating);
+ ConsumeDeprecatedRadialGradient(args, context, cssvalue::kRepeating);
} else if (id == CSSValueID::kConicGradient) {
- result = ConsumeConicGradient(args, *context, cssvalue::kNonRepeating);
+ result = ConsumeConicGradient(args, context, cssvalue::kNonRepeating);
} else if (id == CSSValueID::kRepeatingConicGradient) {
- result = ConsumeConicGradient(args, *context, cssvalue::kRepeating);
+ result = ConsumeConicGradient(args, context, cssvalue::kRepeating);
} else if (id == CSSValueID::kWebkitCrossFade) {
result = ConsumeCrossFade(args, context);
} else if (id == CSSValueID::kPaint) {
- result = context->IsSecureContext() ? ConsumePaint(args, context) : nullptr;
+ result = context.IsSecureContext() ? ConsumePaint(args, context) : nullptr;
}
if (!result || !args.AtEnd())
return nullptr;
@@ -1761,7 +1784,7 @@ static CSSValue* ConsumeGeneratedImage(CSSParserTokenRange& range,
feature = WebFeature::kCSSPaintFunction;
else
feature = WebFeature::kCSSGradient;
- context->Count(feature);
+ context.Count(feature);
range = range_copy;
return result;
@@ -1769,18 +1792,18 @@ static CSSValue* ConsumeGeneratedImage(CSSParserTokenRange& range,
static CSSValue* CreateCSSImageValueWithReferrer(
const AtomicString& raw_value,
- const CSSParserContext* context) {
- CSSValue* image_value = CSSImageValue::Create(
- raw_value, context->CompleteURL(raw_value), context->GetReferrer(),
- context->IsOriginClean() ? OriginClean::kTrue : OriginClean::kFalse);
+ const CSSParserContext& context) {
+ CSSValue* image_value = MakeGarbageCollected<CSSImageValue>(
+ raw_value, context.CompleteURL(raw_value), context.GetReferrer(),
+ context.IsOriginClean() ? OriginClean::kTrue : OriginClean::kFalse);
return image_value;
}
static CSSValue* ConsumeImageSet(CSSParserTokenRange& range,
- const CSSParserContext* context) {
+ const CSSParserContext& context) {
CSSParserTokenRange range_copy = range;
CSSParserTokenRange args = ConsumeFunction(range_copy);
- auto* image_set = MakeGarbageCollected<CSSImageSetValue>(context->Mode());
+ auto* image_set = MakeGarbageCollected<CSSImageSetValue>(context.Mode());
do {
AtomicString url_value =
ConsumeUrlAsStringView(args, context).ToAtomicString();
@@ -1824,7 +1847,7 @@ static bool IsGeneratedImage(CSSValueID id) {
}
CSSValue* ConsumeImage(CSSParserTokenRange& range,
- const CSSParserContext* context,
+ const CSSParserContext& context,
ConsumeGeneratedImagePolicy generated_image) {
AtomicString uri = ConsumeUrlAsStringView(range, context).ToAtomicString();
if (!uri.IsNull())
@@ -1912,7 +1935,7 @@ CSSValue* ConsumeFilterFunctionList(CSSParserTokenRange& range,
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
do {
- CSSValue* filter_value = ConsumeUrl(range, &context);
+ CSSValue* filter_value = ConsumeUrl(range, context);
if (!filter_value) {
filter_value = ConsumeFilterFunction(range, context);
if (!filter_value)
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_property_parser_helpers.h b/chromium/third_party/blink/renderer/core/css/parser/css_property_parser_helpers.h
index 90e4e387eb4..45c628c090a 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_property_parser_helpers.h
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_property_parser_helpers.h
@@ -49,20 +49,30 @@ enum class UnitlessQuirk { kAllow, kForbid };
CSSPrimitiveValue* ConsumeInteger(
CSSParserTokenRange&,
+ const CSSParserContext&,
double minimum_value = -std::numeric_limits<double>::max());
-CSSPrimitiveValue* ConsumeIntegerOrNumberCalc(CSSParserTokenRange&);
-CSSPrimitiveValue* ConsumePositiveInteger(CSSParserTokenRange&);
-bool ConsumeNumberRaw(CSSParserTokenRange&, double& result);
-CSSPrimitiveValue* ConsumeNumber(CSSParserTokenRange&, ValueRange);
+CSSPrimitiveValue* ConsumeIntegerOrNumberCalc(CSSParserTokenRange&,
+ const CSSParserContext&);
+CSSPrimitiveValue* ConsumePositiveInteger(CSSParserTokenRange&,
+ const CSSParserContext&);
+bool ConsumeNumberRaw(CSSParserTokenRange&,
+ const CSSParserContext& context,
+ double& result);
+CSSPrimitiveValue* ConsumeNumber(CSSParserTokenRange&,
+ const CSSParserContext&,
+ ValueRange);
CSSPrimitiveValue* ConsumeLength(CSSParserTokenRange&,
- CSSParserMode,
+ const CSSParserContext&,
ValueRange,
UnitlessQuirk = UnitlessQuirk::kForbid);
-CSSPrimitiveValue* ConsumePercent(CSSParserTokenRange&, ValueRange);
-CSSPrimitiveValue* ConsumeAlphaValue(CSSParserTokenRange&);
+CSSPrimitiveValue* ConsumePercent(CSSParserTokenRange&,
+ const CSSParserContext&,
+ ValueRange);
+CSSPrimitiveValue* ConsumeAlphaValue(CSSParserTokenRange&,
+ const CSSParserContext&);
CSSPrimitiveValue* ConsumeLengthOrPercent(
CSSParserTokenRange&,
- CSSParserMode,
+ const CSSParserContext&,
ValueRange,
UnitlessQuirk = UnitlessQuirk::kForbid);
CSSPrimitiveValue* ConsumeSVGGeometryPropertyLength(CSSParserTokenRange&,
@@ -71,15 +81,17 @@ CSSPrimitiveValue* ConsumeSVGGeometryPropertyLength(CSSParserTokenRange&,
CSSPrimitiveValue* ConsumeAngle(
CSSParserTokenRange&,
- const CSSParserContext*,
+ const CSSParserContext&,
base::Optional<WebFeature> unitless_zero_feature);
CSSPrimitiveValue* ConsumeAngle(
CSSParserTokenRange&,
- const CSSParserContext*,
+ const CSSParserContext&,
base::Optional<WebFeature> unitless_zero_feature,
double minimum_value,
double maximum_value);
-CSSPrimitiveValue* ConsumeTime(CSSParserTokenRange&, ValueRange);
+CSSPrimitiveValue* ConsumeTime(CSSParserTokenRange&,
+ const CSSParserContext&,
+ ValueRange);
CSSPrimitiveValue* ConsumeResolution(CSSParserTokenRange&);
CSSIdentifierValue* ConsumeIdent(CSSParserTokenRange&);
@@ -95,15 +107,17 @@ CSSCustomIdentValue* ConsumeCustomIdent(CSSParserTokenRange&,
const CSSParserContext&);
CSSStringValue* ConsumeString(CSSParserTokenRange&);
StringView ConsumeUrlAsStringView(CSSParserTokenRange&,
- const CSSParserContext*);
+ const CSSParserContext&);
cssvalue::CSSURIValue* ConsumeUrl(CSSParserTokenRange&,
- const CSSParserContext*);
+ const CSSParserContext&);
CSSValue* ConsumeColor(CSSParserTokenRange&,
- CSSParserMode,
+ const CSSParserContext&,
bool accept_quirky_colors = false);
-CSSValue* ConsumeLineWidth(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk);
+CSSValue* ConsumeLineWidth(CSSParserTokenRange&,
+ const CSSParserContext&,
+ UnitlessQuirk);
CSSValuePair* ConsumePosition(CSSParserTokenRange&,
const CSSParserContext&,
@@ -116,7 +130,7 @@ bool ConsumePosition(CSSParserTokenRange&,
CSSValue*& result_x,
CSSValue*& result_y);
bool ConsumeOneOrTwoValuedPosition(CSSParserTokenRange&,
- CSSParserMode,
+ const CSSParserContext&,
UnitlessQuirk,
CSSValue*& result_x,
CSSValue*& result_y);
@@ -130,11 +144,11 @@ enum class ConsumeGeneratedImagePolicy { kAllow, kForbid };
CSSValue* ConsumeImage(
CSSParserTokenRange&,
- const CSSParserContext*,
+ const CSSParserContext&,
ConsumeGeneratedImagePolicy = ConsumeGeneratedImagePolicy::kAllow);
-CSSValue* ConsumeImageOrNone(CSSParserTokenRange&, const CSSParserContext*);
+CSSValue* ConsumeImageOrNone(CSSParserTokenRange&, const CSSParserContext&);
-CSSValue* ConsumeAxis(CSSParserTokenRange&);
+CSSValue* ConsumeAxis(CSSParserTokenRange&, const CSSParserContext& context);
bool IsCSSWideKeyword(StringView);
bool IsRevertKeyword(StringView);
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_property_parser_test.cc b/chromium/third_party/blink/renderer/core/css/parser/css_property_parser_test.cc
index 83e602857dd..edd37e2658e 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_property_parser_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_property_parser_test.cc
@@ -378,7 +378,7 @@ TEST(CSSPropertyParserTest, GradientUseCount) {
Page::InsertOrdinaryPageForTesting(&dummy_page_holder->GetPage());
WebFeature feature = WebFeature::kCSSGradient;
EXPECT_FALSE(document.IsUseCounted(feature));
- document.documentElement()->SetInnerHTMLFromString(
+ document.documentElement()->setInnerHTML(
"<style>* { background-image: linear-gradient(red, blue); }</style>");
EXPECT_TRUE(document.IsUseCounted(feature));
}
@@ -387,10 +387,10 @@ TEST(CSSPropertyParserTest, PaintUseCount) {
auto dummy_page_holder = std::make_unique<DummyPageHolder>(IntSize(800, 600));
Document& document = dummy_page_holder->GetDocument();
Page::InsertOrdinaryPageForTesting(&dummy_page_holder->GetPage());
- document.SetSecureContextStateForTesting(SecureContextState::kSecure);
+ document.SetSecureContextModeForTesting(SecureContextMode::kSecureContext);
WebFeature feature = WebFeature::kCSSPaintFunction;
EXPECT_FALSE(document.IsUseCounted(feature));
- document.documentElement()->SetInnerHTMLFromString(
+ document.documentElement()->setInnerHTML(
"<style>span { background-image: paint(geometry); }</style>");
EXPECT_TRUE(document.IsUseCounted(feature));
}
@@ -401,7 +401,7 @@ TEST(CSSPropertyParserTest, CrossFadeUseCount) {
Page::InsertOrdinaryPageForTesting(&dummy_page_holder->GetPage());
WebFeature feature = WebFeature::kWebkitCrossFade;
EXPECT_FALSE(document.IsUseCounted(feature));
- document.documentElement()->SetInnerHTMLFromString(
+ document.documentElement()->setInnerHTML(
"<style>div { background-image: -webkit-cross-fade(url('from.png'), "
"url('to.png'), 0.2); }</style>");
EXPECT_TRUE(document.IsUseCounted(feature));
@@ -415,7 +415,7 @@ TEST(CSSPropertyParserTest, TwoValueOverflowOverlayCount) {
WebFeature feature2 = WebFeature::kTwoValuedOverflow;
EXPECT_FALSE(document.IsUseCounted(feature));
EXPECT_FALSE(document.IsUseCounted(feature2));
- document.documentElement()->SetInnerHTMLFromString(
+ document.documentElement()->setInnerHTML(
"<div style=\"height: 10px; width: 10px; overflow: overlay overlay;\">"
"<div style=\"height: 50px; width: 50px;\"></div></div>");
EXPECT_TRUE(document.IsUseCounted(feature));
@@ -430,7 +430,7 @@ TEST(CSSPropertyParserTest, OneValueOverflowOverlayCount) {
WebFeature feature2 = WebFeature::kTwoValuedOverflow;
EXPECT_FALSE(document.IsUseCounted(feature));
EXPECT_FALSE(document.IsUseCounted(feature2));
- document.documentElement()->SetInnerHTMLFromString(
+ document.documentElement()->setInnerHTML(
"<div style=\"height: 10px; width: 10px; overflow: overlay;\">"
"<div style=\"height: 50px; width: 50px;\"></div></div>");
EXPECT_TRUE(document.IsUseCounted(feature));
@@ -445,7 +445,7 @@ TEST(CSSPropertyParserTest, OverflowXOverlayCount) {
WebFeature feature2 = WebFeature::kTwoValuedOverflow;
EXPECT_FALSE(document.IsUseCounted(feature));
EXPECT_FALSE(document.IsUseCounted(feature2));
- document.documentElement()->SetInnerHTMLFromString(
+ document.documentElement()->setInnerHTML(
"<div style=\"height: 10px; width: 10px; overflow-x: overlay;\">"
"<div style=\"height: 50px; width: 50px;\"></div></div>");
EXPECT_TRUE(document.IsUseCounted(feature));
@@ -460,7 +460,7 @@ TEST(CSSPropertyParserTest, OverflowYOverlayCount) {
WebFeature feature2 = WebFeature::kTwoValuedOverflow;
EXPECT_FALSE(document.IsUseCounted(feature));
EXPECT_FALSE(document.IsUseCounted(feature2));
- document.documentElement()->SetInnerHTMLFromString(
+ document.documentElement()->setInnerHTML(
"<div style=\"height: 10px; width: 10px; overflow-y: overlay;\">"
"<div style=\"height: 50px; width: 50px;\"></div></div>");
EXPECT_TRUE(document.IsUseCounted(feature));
@@ -475,7 +475,7 @@ TEST(CSSPropertyParserTest, OverflowFirstValueOverlayCount) {
WebFeature feature2 = WebFeature::kTwoValuedOverflow;
EXPECT_FALSE(document.IsUseCounted(feature));
EXPECT_FALSE(document.IsUseCounted(feature2));
- document.documentElement()->SetInnerHTMLFromString(
+ document.documentElement()->setInnerHTML(
"<div style=\"height: 10px; width: 10px; overflow: overlay scroll;\">"
"<div style=\"height: 50px; width: 50px;\"></div></div>");
EXPECT_TRUE(document.IsUseCounted(feature));
@@ -490,7 +490,7 @@ TEST(CSSPropertyParserTest, OverflowSecondValueOverlayCount) {
WebFeature feature2 = WebFeature::kTwoValuedOverflow;
EXPECT_FALSE(document.IsUseCounted(feature));
EXPECT_FALSE(document.IsUseCounted(feature2));
- document.documentElement()->SetInnerHTMLFromString(
+ document.documentElement()->setInnerHTML(
"<div style=\"height: 10px; width: 10px; overflow: scroll overlay;\">"
"<div style=\"height: 50px; width: 50px;\"></div></div>");
EXPECT_TRUE(document.IsUseCounted(feature));
@@ -615,7 +615,7 @@ TEST_F(CSSPropertyUseCounterTest, CSSPropertyCyUnitlessUseCount) {
TEST_F(CSSPropertyUseCounterTest, UnitlessPresentationAttributesNotCounted) {
WebFeature feature = WebFeature::kSVGGeometryPropertyHasNonZeroUnitlessValue;
EXPECT_FALSE(IsCounted(feature));
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<svg>
<rect x="42" y="42" rx="42" ry="42"/>
<circle cx="42" cy="42" r="42"/>
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_proto_converter.cc b/chromium/third_party/blink/renderer/core/css/parser/css_proto_converter.cc
index 6a7eb90c89c..50fa91463a0 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_proto_converter.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_proto_converter.cc
@@ -38,7 +38,6 @@ const std::string Converter::kPseudoLookupTable[] = {
"-internal-spatial-navigation-focus",
"-internal-video-persistent",
"-internal-video-persistent-ancestor",
- "-internal-xr-immersive-dom-overlay",
"-webkit-any-link",
"-webkit-autofill",
"-webkit-drag",
@@ -121,6 +120,7 @@ const std::string Converter::kPseudoLookupTable[] = {
"nth-last-of-type",
"nth-of-type",
"slotted",
+ "xr-overlay",
"INVALID_PSEUDO_VALUE"};
const std::string Converter::kMediaTypeLookupTable[] = {
@@ -956,6 +956,8 @@ const std::string Converter::kValueLookupTable[] = {
"smooth",
"jump-start",
"no-drag",
+ "jis-b5",
+ "jis-b4",
"INVALID_VALUE",
};
@@ -1028,7 +1030,6 @@ const std::string Converter::kPropertyLookupTable[] = {
"-webkit-mask-position-x",
"-webkit-mask-position-y",
"outline-style",
- "-webkit-margin-bottom-collapse",
"color-interpolation-filters",
"font-variant",
"-webkit-animation-fill-mode",
@@ -1052,7 +1053,6 @@ const std::string Converter::kPropertyLookupTable[] = {
"column-width",
"list-style",
"-webkit-mask-repeat-y",
- "-webkit-margin-before-collapse",
"stroke",
"text-decoration-line",
"-webkit-background-size",
@@ -1340,7 +1340,6 @@ const std::string Converter::kPropertyLookupTable[] = {
"-webkit-transition-property",
"writing-mode",
"stroke-opacity",
- "-webkit-margin-collapse",
"box-sizing",
"margin-top",
"column-rule-color",
@@ -1377,7 +1376,6 @@ const std::string Converter::kPropertyLookupTable[] = {
"justify-items",
"zoom",
"scroll-padding-block-start",
- "-webkit-margin-top-collapse",
"page",
"right",
"user-select",
@@ -1434,7 +1432,6 @@ const std::string Converter::kPropertyLookupTable[] = {
"scroll-margin-left",
"border-style",
"animation-iteration-count",
- "-webkit-margin-after-collapse",
"overflow",
"user-zoom",
"-webkit-border-top-right-radius",
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_selector_parser.cc b/chromium/third_party/blink/renderer/core/css/parser/css_selector_parser.cc
index ca9550f30d8..4831273c13a 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_selector_parser.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_selector_parser.cc
@@ -52,6 +52,22 @@ CSSSelectorList CSSSelectorParser::ConsumeSelector(
return result;
}
+// static
+bool CSSSelectorParser::SupportsComplexSelector(
+ CSSParserTokenRange range,
+ const CSSParserContext* context) {
+ range.ConsumeWhitespace();
+ CSSSelectorParser parser(context, nullptr);
+ auto parser_selector = parser.ConsumeComplexSelector(range);
+ if (parser.failed_parsing_ || !range.AtEnd() || !parser_selector)
+ return false;
+ auto complex_selector = parser_selector->ReleaseSelector();
+ DCHECK(complex_selector);
+ if (ContainsUnknownWebkitPseudoElements(*complex_selector.get()))
+ return false;
+ return true;
+}
+
CSSSelectorParser::CSSSelectorParser(const CSSParserContext* context,
StyleSheetContents* style_sheet)
: context_(context), style_sheet_(style_sheet) {}
@@ -148,10 +164,10 @@ unsigned ExtractCompoundFlags(const CSSParserSelector& simple_selector,
return kHasContentPseudoElement;
if (simple_selector.GetPseudoType() == CSSSelector::kPseudoShadow)
return 0;
- // TODO(futhark@chromium.org): crbug.com/578131
- // The UASheetMode check is a work-around to allow this selector in
- // mediaControls(New).css:
- // input[type="range" i]::-webkit-media-slider-container > div {
+ // We don't restrict what follows custom ::-webkit-* pseudo elements in UA
+ // sheets. We currently use selectors in mediaControls.css like this:
+ //
+ // video::-webkit-media-text-track-region-container.scrolling
if (parser_mode == kUASheetMode &&
simple_selector.GetPseudoType() ==
CSSSelector::kPseudoWebKitCustomElement)
@@ -405,15 +421,16 @@ bool CSSSelectorParser::ConsumeName(CSSParserTokenRange& range,
if (range.Peek().GetType() != kDelimiterToken ||
range.Peek().Delimiter() != '|')
return true;
- range.Consume();
namespace_prefix =
name == CSSSelector::UniversalSelectorAtom() ? g_star_atom : name;
- const CSSParserToken& name_token = range.Consume();
- if (name_token.GetType() == kIdentToken) {
- name = name_token.Value().ToAtomicString();
- } else if (name_token.GetType() == kDelimiterToken &&
- name_token.Delimiter() == '*') {
+ if (range.Peek(1).GetType() == kIdentToken) {
+ range.Consume();
+ name = range.Consume().Value().ToAtomicString();
+ } else if (range.Peek(1).GetType() == kDelimiterToken &&
+ range.Peek(1).Delimiter() == '*') {
+ range.Consume();
+ range.Consume();
name = CSSSelector::UniversalSelectorAtom();
} else {
name = g_null_atom;
@@ -615,14 +632,24 @@ std::unique_ptr<CSSParserSelector> CSSSelectorParser::ConsumePseudo(
selector->AdoptSelectorVector(selector_vector);
return selector;
}
- case CSSSelector::kPseudoState:
- case CSSSelector::kPseudoPart: {
+ case CSSSelector::kPseudoState: {
const CSSParserToken& ident = block.ConsumeIncludingWhitespace();
if (ident.GetType() != kIdentToken || !block.AtEnd())
return nullptr;
selector->SetArgument(ident.Value().ToAtomicString());
return selector;
}
+ case CSSSelector::kPseudoPart: {
+ Vector<AtomicString> parts;
+ do {
+ const CSSParserToken& ident = block.ConsumeIncludingWhitespace();
+ if (ident.GetType() != kIdentToken)
+ return nullptr;
+ parts.push_back(ident.Value().ToAtomicString());
+ } while (!block.AtEnd());
+ selector->SetPartNames(std::make_unique<Vector<AtomicString>>(parts));
+ return selector;
+ }
case CSSSelector::kPseudoSlotted: {
DisallowPseudoElementsScope scope(this);
@@ -1187,4 +1214,17 @@ void CSSSelectorParser::RecordUsageAndDeprecations(
}
}
+bool CSSSelectorParser::ContainsUnknownWebkitPseudoElements(
+ const CSSSelector& complex_selector) {
+ for (const CSSSelector* current = &complex_selector; current;
+ current = current->TagHistory()) {
+ if (current->GetPseudoType() != CSSSelector::kPseudoWebKitCustomElement)
+ continue;
+ WebFeature feature = FeatureForWebKitCustomPseudoElement(current->Value());
+ if (feature == WebFeature::kCSSSelectorWebkitUnknownPseudo)
+ return true;
+ }
+ return false;
+}
+
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_selector_parser.h b/chromium/third_party/blink/renderer/core/css/parser/css_selector_parser.h
index b1a8442a5ab..efddcb43400 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_selector_parser.h
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_selector_parser.h
@@ -35,6 +35,9 @@ class CORE_EXPORT CSSSelectorParser {
static bool ConsumeANPlusB(CSSParserTokenRange&, std::pair<int, int>&);
+ static bool SupportsComplexSelector(CSSParserTokenRange,
+ const CSSParserContext*);
+
private:
CSSSelectorParser(const CSSParserContext*, StyleSheetContents*);
@@ -80,9 +83,11 @@ class CORE_EXPORT CSSSelectorParser {
SplitCompoundAtImplicitShadowCrossingCombinator(
std::unique_ptr<CSSParserSelector> compound_selector);
void RecordUsageAndDeprecations(const CSSSelectorList&);
+ static bool ContainsUnknownWebkitPseudoElements(
+ const CSSSelector& complex_selector);
- Member<const CSSParserContext> context_;
- Member<const StyleSheetContents> style_sheet_;
+ const CSSParserContext* context_;
+ const StyleSheetContents* style_sheet_;
bool failed_parsing_ = false;
bool disallow_pseudo_elements_ = false;
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_selector_parser_test.cc b/chromium/third_party/blink/renderer/core/css/parser/css_selector_parser_test.cc
index 19c40798228..ae5410b08a0 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_selector_parser_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_selector_parser_test.cc
@@ -287,6 +287,23 @@ TEST(CSSSelectorParserTest, UnresolvedNamespacePrefix) {
}
}
+TEST(CSSSelectorParserTest, UnexpectedPipe) {
+ const char* test_cases[] = {"div | .c", "| div", " | div"};
+
+ auto* context = MakeGarbageCollected<CSSParserContext>(
+ kHTMLStandardMode, SecureContextMode::kInsecureContext);
+ auto* sheet = MakeGarbageCollected<StyleSheetContents>(context);
+
+ for (auto* test_case : test_cases) {
+ CSSTokenizer tokenizer(test_case);
+ const auto tokens = tokenizer.TokenizeToEOF();
+ CSSParserTokenRange range(tokens);
+ CSSSelectorList list =
+ CSSSelectorParser::ParseSelector(range, context, sheet);
+ EXPECT_FALSE(list.IsValid());
+ }
+}
+
TEST(CSSSelectorParserTest, SerializedUniversal) {
const char* test_cases[][2] = {
{"*::-webkit-volume-slider", "::-webkit-volume-slider"},
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_supports_parser.cc b/chromium/third_party/blink/renderer/core/css/parser/css_supports_parser.cc
index 43f19506156..7b2a4478c64 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_supports_parser.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_supports_parser.cc
@@ -5,105 +5,209 @@
#include "third_party/blink/renderer/core/css/parser/css_supports_parser.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_impl.h"
+#include "third_party/blink/renderer/core/css/parser/css_selector_parser.h"
+#include "third_party/blink/renderer/core/css_value_keywords.h"
+#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
namespace blink {
-CSSSupportsParser::SupportsResult CSSSupportsParser::SupportsCondition(
+namespace {
+
+// The result kUnknown must be converted to 'false' if passed to a context
+// which requires a boolean value.
+// TODO(crbug.com/1052274): This is supposed to happen at the top-level,
+// but currently happens on ConsumeGeneralEnclosed's result.
+CSSSupportsParser::Result EvalUnknown(CSSSupportsParser::Result result) {
+ return result == CSSSupportsParser::Result::kUnknown
+ ? CSSSupportsParser::Result::kUnsupported
+ : result;
+}
+
+// https://drafts.csswg.org/css-syntax/#typedef-any-value
+bool IsNextTokenAllowedForAnyValue(CSSParserTokenRange& range) {
+ switch (range.Peek().GetType()) {
+ case kBadStringToken:
+ case kEOFToken:
+ case kBadUrlToken:
+ return false;
+ case kRightParenthesisToken:
+ case kRightBracketToken:
+ case kRightBraceToken:
+ return range.Peek().GetBlockType() == CSSParserToken::kBlockEnd;
+ default:
+ return true;
+ }
+}
+
+// https://drafts.csswg.org/css-syntax/#typedef-any-value
+bool ConsumeAnyValue(CSSParserTokenRange& range) {
+ DCHECK(!range.AtEnd());
+ while (IsNextTokenAllowedForAnyValue(range))
+ range.Consume();
+ return range.AtEnd();
+}
+
+} // namespace
+
+CSSSupportsParser::Result CSSSupportsParser::SupportsCondition(
CSSParserTokenRange range,
CSSParserImpl& parser,
- SupportsParsingMode parsing_mode) {
+ Mode mode) {
range.ConsumeWhitespace();
+ CSSParserTokenRange stored_range = range;
CSSSupportsParser supports_parser(parser);
- SupportsResult result = supports_parser.ConsumeCondition(range);
- if (parsing_mode != kForWindowCSS || result != kInvalid)
+ Result result = supports_parser.ConsumeSupportsCondition(range);
+ if (mode != Mode::kForWindowCSS || result != Result::kParseFailure)
return result;
+
// window.CSS.supports requires to parse as-if it was wrapped in parenthesis.
- // The only wrapped production that wouldn't have parsed above is the
- // declaration condition production.
- return supports_parser.ConsumeDeclarationCondition(range);
+ // The only wrapped production that wouldn't have parsed above is
+ // <declaration>.
+ if (stored_range.Peek().GetType() != kIdentToken)
+ return Result::kParseFailure;
+ if (parser.SupportsDeclaration(stored_range))
+ return Result::kSupported;
+ return Result::kUnsupported;
+}
+
+bool CSSSupportsParser::AtIdent(CSSParserTokenRange& range, const char* ident) {
+ return range.Peek().GetType() == kIdentToken &&
+ EqualIgnoringASCIICase(range.Peek().Value(), ident);
+}
+
+bool CSSSupportsParser::ConsumeIfIdent(CSSParserTokenRange& range,
+ const char* ident) {
+ if (!AtIdent(range, ident))
+ return false;
+ range.ConsumeIncludingWhitespace();
+ return true;
+}
+
+// <supports-condition> = not <supports-in-parens>
+// | <supports-in-parens> [ and <supports-in-parens> ]*
+// | <supports-in-parens> [ or <supports-in-parens> ]*
+CSSSupportsParser::Result CSSSupportsParser::ConsumeSupportsCondition(
+ CSSParserTokenRange& range) {
+ // not <supports-in-parens>
+ if (ConsumeIfIdent(range, "not")) {
+ Result result = !ConsumeSupportsInParens(range);
+ return range.AtEnd() ? result : Result::kParseFailure;
+ }
+
+ // <supports-in-parens> [ and <supports-in-parens> ]*
+ // | <supports-in-parens> [ or <supports-in-parens> ]*
+ Result result = ConsumeSupportsInParens(range);
+
+ if (AtIdent(range, "and")) {
+ while (ConsumeIfIdent(range, "and"))
+ result = result & ConsumeSupportsInParens(range);
+ } else if (AtIdent(range, "or")) {
+ while (ConsumeIfIdent(range, "or"))
+ result = result | ConsumeSupportsInParens(range);
+ }
+
+ return range.AtEnd() ? result : Result::kParseFailure;
}
-enum ClauseType { kUnresolved, kConjunction, kDisjunction };
-
-CSSSupportsParser::SupportsResult CSSSupportsParser::ConsumeCondition(
- CSSParserTokenRange range) {
- if (range.Peek().GetType() == kIdentToken)
- return ConsumeNegation(range);
-
- bool result;
- ClauseType clause_type = kUnresolved;
-
- while (true) {
- SupportsResult next_result = ConsumeConditionInParenthesis(range);
- if (next_result == kInvalid)
- return kInvalid;
- bool next_supported = next_result;
- if (clause_type == kUnresolved)
- result = next_supported;
- else if (clause_type == kConjunction)
- result &= next_supported;
- else
- result |= next_supported;
-
- if (range.AtEnd())
- break;
- if (range.ConsumeIncludingWhitespace().GetType() != kWhitespaceToken)
- return kInvalid;
- if (range.AtEnd())
- break;
-
- const CSSParserToken& token = range.Consume();
- if (token.GetType() != kIdentToken)
- return kInvalid;
- if (clause_type == kUnresolved)
- clause_type = token.Value().length() == 3 ? kConjunction : kDisjunction;
- if ((clause_type == kConjunction &&
- !EqualIgnoringASCIICase(token.Value(), "and")) ||
- (clause_type == kDisjunction &&
- !EqualIgnoringASCIICase(token.Value(), "or")))
- return kInvalid;
-
- if (range.ConsumeIncludingWhitespace().GetType() != kWhitespaceToken)
- return kInvalid;
+// <supports-in-parens> = ( <supports-condition> )
+// | <supports-feature>
+// | <general-enclosed>
+CSSSupportsParser::Result CSSSupportsParser::ConsumeSupportsInParens(
+ CSSParserTokenRange& range) {
+ const CSSParserTokenRange stored_range = range;
+
+ // ( <supports-condition> )
+ if (range.Peek().GetType() == kLeftParenthesisToken) {
+ auto block = range.ConsumeBlock();
+ block.ConsumeWhitespace();
+ range.ConsumeWhitespace();
+ Result result = ConsumeSupportsCondition(block);
+ if (result != Result::kParseFailure)
+ return result;
+ // Parsing failed, so try parsing again as <supports-feature>.
+ range = stored_range;
}
- return result ? kSupported : kUnsupported;
+
+ // <supports-feature>
+ Result result = ConsumeSupportsFeature(range);
+ if (result != Result::kParseFailure)
+ return result;
+ // Parsing failed, try again as <general-enclosed>
+ range = stored_range;
+
+ // <general-enclosed>
+ //
+ // TODO(crbug.com/1052274): Support kUnknown beyond this point.
+ //
+ // The result kUnknown is supposed to be evaluated at the top level, but
+ // we have already shipped the behavior of evaluating it here, and Firefox
+ // does the same thing.
+ return EvalUnknown(ConsumeGeneralEnclosed(range));
}
-CSSSupportsParser::SupportsResult CSSSupportsParser::ConsumeNegation(
- CSSParserTokenRange range) {
- DCHECK_EQ(range.Peek().GetType(), kIdentToken);
- if (!EqualIgnoringASCIICase(range.Consume().Value(), "not"))
- return kInvalid;
- if (range.ConsumeIncludingWhitespace().GetType() != kWhitespaceToken)
- return kInvalid;
- SupportsResult result = ConsumeConditionInParenthesis(range);
+// <supports-feature> = <supports-selector-fn> | <supports-decl>
+CSSSupportsParser::Result CSSSupportsParser::ConsumeSupportsFeature(
+ CSSParserTokenRange& range) {
+ const CSSParserTokenRange stored_range = range;
+
+ // <supports-selector-fn>
+ Result result = ConsumeSupportsSelectorFn(range);
+ if (result != Result::kParseFailure)
+ return result;
+ range = stored_range;
+
+ // <supports-decl>
+ return ConsumeSupportsDecl(range);
+}
+
+// <supports-selector-fn> = selector( <complex-selector> )
+CSSSupportsParser::Result CSSSupportsParser::ConsumeSupportsSelectorFn(
+ CSSParserTokenRange& range) {
+ if (!RuntimeEnabledFeatures::CSSSupportsSelectorEnabled())
+ return Result::kParseFailure;
+ if (range.Peek().GetType() != kFunctionToken)
+ return Result::kParseFailure;
+ if (range.Peek().FunctionId() != CSSValueID::kSelector)
+ return Result::kParseFailure;
+ auto block = range.ConsumeBlock();
+ block.ConsumeWhitespace();
range.ConsumeWhitespace();
- if (!range.AtEnd() || result == kInvalid)
- return kInvalid;
- return result ? kUnsupported : kSupported;
+ if (CSSSelectorParser::SupportsComplexSelector(block, parser_.GetContext()))
+ return Result::kSupported;
+ return Result::kUnsupported;
}
-CSSSupportsParser::SupportsResult
-CSSSupportsParser::ConsumeConditionInParenthesis(CSSParserTokenRange& range) {
- if (range.Peek().GetType() == kFunctionToken) {
- range.ConsumeComponentValue();
- return kUnsupported;
- }
+// <supports-decl> = ( <declaration> )
+CSSSupportsParser::Result CSSSupportsParser::ConsumeSupportsDecl(
+ CSSParserTokenRange& range) {
if (range.Peek().GetType() != kLeftParenthesisToken)
- return kInvalid;
- CSSParserTokenRange inner_range = range.ConsumeBlock();
- inner_range.ConsumeWhitespace();
- SupportsResult result = ConsumeCondition(inner_range);
- if (result != kInvalid)
- return result;
- return ConsumeDeclarationCondition(inner_range);
+ return Result::kParseFailure;
+ auto block = range.ConsumeBlock();
+ block.ConsumeWhitespace();
+ range.ConsumeWhitespace();
+ if (block.Peek().GetType() != kIdentToken)
+ return Result::kParseFailure;
+ if (parser_.SupportsDeclaration(block))
+ return Result::kSupported;
+ return Result::kUnsupported;
}
-CSSSupportsParser::SupportsResult
-CSSSupportsParser::ConsumeDeclarationCondition(CSSParserTokenRange& range) {
- if (range.Peek().GetType() != kIdentToken)
- return kUnsupported;
- return parser_.SupportsDeclaration(range) ? kSupported : kUnsupported;
+// <general-enclosed> = [ <function-token> <any-value> ) ]
+// | ( <ident> <any-value> )
+CSSSupportsParser::Result CSSSupportsParser::ConsumeGeneralEnclosed(
+ CSSParserTokenRange& range) {
+ if (range.Peek().GetType() == kFunctionToken ||
+ range.Peek().GetType() == kLeftParenthesisToken) {
+ auto block = range.ConsumeBlock();
+ // Note that <any-value> matches a sequence of one or more tokens, hence the
+ // block-range can't be empty.
+ // https://drafts.csswg.org/css-syntax-3/#typedef-any-value
+ if (block.AtEnd() || !ConsumeAnyValue(block))
+ return Result::kParseFailure;
+ range.ConsumeWhitespace();
+ return Result::kUnknown;
+ }
+ return Result::kParseFailure;
}
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_supports_parser.h b/chromium/third_party/blink/renderer/core/css/parser/css_supports_parser.h
index 698c8c558ac..9f447f5a8f5 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/css_supports_parser.h
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_supports_parser.h
@@ -5,6 +5,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PARSER_CSS_SUPPORTS_PARSER_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PARSER_CSS_SUPPORTS_PARSER_H_
+#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
namespace blink {
@@ -12,29 +13,116 @@ namespace blink {
class CSSParserImpl;
class CSSParserTokenRange;
-class CSSSupportsParser {
+class CORE_EXPORT CSSSupportsParser {
STACK_ALLOCATED();
public:
- enum SupportsResult { kUnsupported = false, kSupported = true, kInvalid };
- enum SupportsParsingMode { kForAtRule, kForWindowCSS };
+ enum class Mode { kForAtRule, kForWindowCSS };
- static SupportsResult SupportsCondition(CSSParserTokenRange,
- CSSParserImpl&,
- SupportsParsingMode);
+ enum class Result {
+ // kUnsupported/kSupported means that we parsed the @supports
+ // successfully, and conclusively determined that we either support or
+ // don't support the feature.
+ kUnsupported,
+ kSupported,
+ // kUnknown is a special value used for productions that only match
+ // <general-enclosed> [1]. See note regarding Kleene 3-valued logic [2]
+ // for explanation of how this is different from kUnsupported.
+ //
+ // [1] https://drafts.csswg.org/css-conditional-3/#at-supports
+ // [2] https://drafts.csswg.org/mediaqueries-4/#evaluating
+ kUnknown,
+ // This is used to signal parse failure in the @supports syntax itself.
+ // This means that for a production like:
+ //
+ // <supports-in-parens> = ( <supports-condition> )
+ // | <supports-feature>
+ // | <general-enclosed>
+ //
+ // If ConsumeSupportsCondition returns a kParseFailure, we'll proceed to
+ // trying the ConsumeGeneralEnclosed branch. Had however
+ // ConsumeSupportsCondition returned kUnsupported, we would consider this a
+ // conclusive answer, and would have returned kUnsupported without trying
+ // any further parsing branches.
+ kParseFailure
+ };
+
+ static Result SupportsCondition(CSSParserTokenRange, CSSParserImpl&, Mode);
private:
+ friend class CSSSupportsParserTest;
+
CSSSupportsParser(CSSParserImpl& parser) : parser_(parser) {}
- SupportsResult ConsumeCondition(CSSParserTokenRange);
- SupportsResult ConsumeNegation(CSSParserTokenRange);
- SupportsResult ConsumeDeclarationCondition(CSSParserTokenRange&);
+ // True if the current token is a kIdentToken with the specified value
+ // (case-insensitive).
+ bool AtIdent(CSSParserTokenRange&, const char*);
+
+ // If the current token is a kIdentToken with the specified value (case
+ // insensitive), consumes the token and returns true.
+ bool ConsumeIfIdent(CSSParserTokenRange&, const char*);
+
+ // Parsing functions follow, as defined by:
+ // https://drafts.csswg.org/css-conditional-3/#typedef-supports-condition
+
+ // <supports-condition> = not <supports-in-parens>
+ // | <supports-in-parens> [ and <supports-in-parens> ]*
+ // | <supports-in-parens> [ or <supports-in-parens> ]*
+ Result ConsumeSupportsCondition(CSSParserTokenRange&);
+
+ // <supports-in-parens> = ( <supports-condition> )
+ // | <supports-feature>
+ // | <general-enclosed>
+ Result ConsumeSupportsInParens(CSSParserTokenRange&);
- SupportsResult ConsumeConditionInParenthesis(CSSParserTokenRange&);
+ // <supports-feature> = <supports-selector-fn> | <supports-decl>
+ Result ConsumeSupportsFeature(CSSParserTokenRange&);
+
+ // <supports-selector-fn> = selector( <complex-selector> )
+ Result ConsumeSupportsSelectorFn(CSSParserTokenRange&);
+
+ // <supports-decl> = ( <declaration> )
+ Result ConsumeSupportsDecl(CSSParserTokenRange&);
+
+ // <general-enclosed>
+ Result ConsumeGeneralEnclosed(CSSParserTokenRange&);
CSSParserImpl& parser_;
};
+inline CSSSupportsParser::Result operator!(CSSSupportsParser::Result result) {
+ using Result = CSSSupportsParser::Result;
+ if (result == Result::kUnsupported)
+ return Result::kSupported;
+ if (result == Result::kSupported)
+ return Result::kUnsupported;
+ return result;
+}
+
+inline CSSSupportsParser::Result operator&(CSSSupportsParser::Result a,
+ CSSSupportsParser::Result b) {
+ using Result = CSSSupportsParser::Result;
+ if (a == Result::kParseFailure || b == Result::kParseFailure)
+ return Result::kParseFailure;
+ if (a == Result::kUnknown && b == Result::kUnknown)
+ return Result::kUnknown;
+ if (a != Result::kSupported || b != Result::kSupported)
+ return Result::kUnsupported;
+ return Result::kSupported;
+}
+
+inline CSSSupportsParser::Result operator|(CSSSupportsParser::Result a,
+ CSSSupportsParser::Result b) {
+ using Result = CSSSupportsParser::Result;
+ if (a == Result::kParseFailure || b == Result::kParseFailure)
+ return Result::kParseFailure;
+ if (a == Result::kSupported || b == Result::kSupported)
+ return Result::kSupported;
+ if (a == Result::kUnknown || b == Result::kUnknown)
+ return Result::kUnknown;
+ return Result::kUnsupported;
+}
+
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PARSER_CSS_SUPPORTS_PARSER_H_
diff --git a/chromium/third_party/blink/renderer/core/css/parser/css_supports_parser_test.cc b/chromium/third_party/blink/renderer/core/css/parser/css_supports_parser_test.cc
new file mode 100644
index 00000000000..04f7b706b78
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/parser/css_supports_parser_test.cc
@@ -0,0 +1,390 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/blink/renderer/core/css/parser/css_supports_parser.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/blink/renderer/core/css/parser/css_parser_context.h"
+#include "third_party/blink/renderer/core/css/parser/css_parser_impl.h"
+#include "third_party/blink/renderer/core/css/parser/css_tokenizer.h"
+#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
+
+namespace blink {
+
+using Result = CSSSupportsParser::Result;
+
+class CSSSupportsParserTest : public testing::Test {
+ public:
+ CSSParserContext* MakeContext() {
+ return MakeGarbageCollected<CSSParserContext>(
+ kHTMLStandardMode, SecureContextMode::kInsecureContext);
+ }
+
+ Vector<CSSParserToken, 32> Tokenize(const String& string) {
+ return CSSTokenizer(string).TokenizeToEOF();
+ }
+
+ Result SupportsCondition(String string, CSSSupportsParser::Mode mode) {
+ CSSParserImpl impl(MakeContext());
+ auto tokens = Tokenize(string);
+ return CSSSupportsParser::SupportsCondition(tokens, impl, mode);
+ }
+
+ Result AtSupports(String string) {
+ return SupportsCondition(string, CSSSupportsParser::Mode::kForAtRule);
+ }
+
+ Result WindowCSSSupports(String string) {
+ return SupportsCondition(string, CSSSupportsParser::Mode::kForWindowCSS);
+ }
+
+ Result ConsumeSupportsCondition(String string) {
+ CSSParserImpl impl(MakeContext());
+ CSSSupportsParser parser(impl);
+ auto tokens = Tokenize(string);
+ CSSParserTokenRange range = tokens;
+ return parser.ConsumeSupportsCondition(range);
+ }
+
+ Result ConsumeSupportsInParens(String string) {
+ CSSParserImpl impl(MakeContext());
+ CSSSupportsParser parser(impl);
+ auto tokens = Tokenize(string);
+ CSSParserTokenRange range = tokens;
+ return parser.ConsumeSupportsInParens(range);
+ }
+
+ Result ConsumeSupportsFeature(String string) {
+ CSSParserImpl impl(MakeContext());
+ CSSSupportsParser parser(impl);
+ auto tokens = Tokenize(string);
+ CSSParserTokenRange range = tokens;
+ return parser.ConsumeSupportsFeature(range);
+ }
+
+ Result ConsumeSupportsSelectorFn(String string) {
+ CSSParserImpl impl(MakeContext());
+ CSSSupportsParser parser(impl);
+ auto tokens = Tokenize(string);
+ CSSParserTokenRange range = tokens;
+ return parser.ConsumeSupportsSelectorFn(range);
+ }
+
+ Result ConsumeSupportsDecl(String string) {
+ CSSParserImpl impl(MakeContext());
+ CSSSupportsParser parser(impl);
+ auto tokens = Tokenize(string);
+ CSSParserTokenRange range = tokens;
+ return parser.ConsumeSupportsDecl(range);
+ }
+
+ Result ConsumeGeneralEnclosed(String string) {
+ CSSParserImpl impl(MakeContext());
+ CSSSupportsParser parser(impl);
+ auto tokens = Tokenize(string);
+ CSSParserTokenRange range = tokens;
+ return parser.ConsumeGeneralEnclosed(range);
+ }
+};
+
+TEST_F(CSSSupportsParserTest, ResultNot) {
+ EXPECT_EQ(Result::kSupported, !Result::kUnsupported);
+ EXPECT_EQ(Result::kUnsupported, !Result::kSupported);
+ EXPECT_EQ(Result::kParseFailure, !Result::kParseFailure);
+ EXPECT_EQ(Result::kUnknown, !Result::kUnknown);
+}
+
+TEST_F(CSSSupportsParserTest, ResultAnd) {
+ EXPECT_EQ(Result::kSupported, Result::kSupported & Result::kSupported);
+ EXPECT_EQ(Result::kUnsupported, Result::kUnsupported & Result::kSupported);
+ EXPECT_EQ(Result::kUnsupported, Result::kSupported & Result::kUnsupported);
+ EXPECT_EQ(Result::kUnsupported, Result::kUnsupported & Result::kUnsupported);
+
+ EXPECT_EQ(Result::kParseFailure, Result::kSupported & Result::kParseFailure);
+ EXPECT_EQ(Result::kParseFailure, Result::kParseFailure & Result::kSupported);
+
+ EXPECT_EQ(Result::kUnknown, Result::kUnknown & Result::kUnknown);
+ EXPECT_EQ(Result::kUnsupported, Result::kSupported & Result::kUnknown);
+ EXPECT_EQ(Result::kUnsupported, Result::kUnknown & Result::kSupported);
+}
+
+TEST_F(CSSSupportsParserTest, ResultOr) {
+ EXPECT_EQ(Result::kSupported, Result::kSupported | Result::kSupported);
+ EXPECT_EQ(Result::kSupported, Result::kUnsupported | Result::kSupported);
+ EXPECT_EQ(Result::kSupported, Result::kSupported | Result::kUnsupported);
+ EXPECT_EQ(Result::kUnsupported, Result::kUnsupported | Result::kUnsupported);
+
+ EXPECT_EQ(Result::kParseFailure, Result::kSupported | Result::kParseFailure);
+ EXPECT_EQ(Result::kParseFailure, Result::kParseFailure | Result::kSupported);
+
+ EXPECT_EQ(Result::kUnknown, Result::kUnknown | Result::kUnknown);
+ EXPECT_EQ(Result::kSupported, Result::kSupported | Result::kUnknown);
+ EXPECT_EQ(Result::kSupported, Result::kUnknown | Result::kSupported);
+}
+
+TEST_F(CSSSupportsParserTest, ConsumeSupportsCondition) {
+ // not <supports-in-parens>
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsCondition("not (asdf:red)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsCondition("(not (color:red))"));
+ EXPECT_EQ(Result::kParseFailure, ConsumeSupportsCondition("nay (color:red)"));
+
+ // <supports-in-parens> [ and <supports-in-parens> ]*
+ EXPECT_EQ(Result::kSupported,
+ ConsumeSupportsCondition("(color:red) and (color:green)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsCondition("(color:red) and (asdf:green)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsCondition("(asdf:red) and (asdf:green)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsCondition(
+ "(color:red) and (color:green) and (asdf:color)"));
+ EXPECT_EQ(Result::kSupported,
+ ConsumeSupportsCondition(
+ "(color:red) and (color:green) and (not (asdf:color))"));
+
+ // <supports-in-parens> [ or <supports-in-parens> ]*
+ EXPECT_EQ(Result::kSupported,
+ ConsumeSupportsCondition("(color:red) or (color:asdf)"));
+ EXPECT_EQ(Result::kSupported,
+ ConsumeSupportsCondition("(color:asdf) or (color:green)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsCondition("(asdf:red) or (asdf:green)"));
+ EXPECT_EQ(
+ Result::kSupported,
+ ConsumeSupportsCondition("(color:red) or (color:green) or (asdf:color)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsCondition(
+ "(color:asdf1) or (color:asdf2) or (asdf:asdf2)"));
+ EXPECT_EQ(Result::kSupported,
+ ConsumeSupportsCondition(
+ "(color:asdf) or (color:ghjk) or (not (asdf:color))"));
+
+ // <supports-feature>
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsCondition("(color:red)"));
+ EXPECT_EQ(Result::kUnsupported, ConsumeSupportsCondition("(color:asdf)"));
+
+ // <general-enclosed>
+ EXPECT_EQ(Result::kUnsupported, ConsumeSupportsCondition("asdf(1)"));
+}
+
+TEST_F(CSSSupportsParserTest, ConsumeSupportsInParens) {
+ // ( <supports-condition> )
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsInParens("(not (asdf:red))"));
+ EXPECT_EQ(Result::kUnsupported, ConsumeSupportsInParens("(not (color:red))"));
+
+ // <supports-feature>
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsInParens("(color:red)"));
+ EXPECT_EQ(Result::kUnsupported, ConsumeSupportsInParens("(color:asdf)"));
+
+ // <general-enclosed>
+ EXPECT_EQ(Result::kUnsupported, ConsumeSupportsInParens("asdf(1)"));
+
+ EXPECT_EQ(Result::kSupported,
+ ConsumeSupportsInParens("(color:red)and (color:green)"));
+ EXPECT_EQ(Result::kSupported,
+ ConsumeSupportsInParens("(color:red)or (color:green)"));
+ {
+ ScopedCSSSupportsSelectorForTest css_supports_selector(true);
+ EXPECT_EQ(Result::kSupported,
+ ConsumeSupportsInParens("selector(div)or (color:green)"));
+ EXPECT_EQ(Result::kSupported,
+ ConsumeSupportsInParens("selector(div)and (color:green)"));
+ }
+}
+
+TEST_F(CSSSupportsParserTest, ConsumeSupportsSelectorFn) {
+ ScopedCSSSupportsSelectorForTest css_supports_selector(true);
+
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsSelectorFn("selector(*)"));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsSelectorFn("selector(*:hover)"));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsSelectorFn("selector(:hover)"));
+ EXPECT_EQ(Result::kSupported,
+ ConsumeSupportsSelectorFn("selector(::before)"));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsSelectorFn("selector(div)"));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsSelectorFn("selector(div"));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsSelectorFn("selector(.a)"));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsSelectorFn("selector(#a)"));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsSelectorFn("selector(div.a)"));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsSelectorFn("selector(div a)"));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsSelectorFn("selector(a > div)"));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsSelectorFn("selector(a ~ div)"));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsSelectorFn("selector(a + div)"));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsSelectorFn("selector(*|a)"));
+ EXPECT_EQ(Result::kSupported,
+ ConsumeSupportsSelectorFn("selector(a + div#test)"));
+ EXPECT_EQ(Result::kSupported,
+ ConsumeSupportsSelectorFn("selector(a + div#test::before)"));
+ EXPECT_EQ(Result::kSupported,
+ ConsumeSupportsSelectorFn("selector(a.cls:hover)"));
+ EXPECT_EQ(Result::kSupported,
+ ConsumeSupportsSelectorFn("selector(a.cls::before)"));
+ EXPECT_EQ(Result::kSupported,
+ ConsumeSupportsSelectorFn("selector(div::-webkit-clear-button)"));
+
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsSelectorFn("selector(div::-webkit-asdf)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsSelectorFn("selector(a + div::-webkit-asdf)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsSelectorFn("selector(div.cls::-webkit-asdf)"));
+
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsSelectorFn("selector(div.~cls)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsSelectorFn("selector(div. ~cls)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsSelectorFn("selector(div .~ cls)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsSelectorFn("selector(div$ cls)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsSelectorFn("selector(div $cls)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsSelectorFn("selector(div $ cls)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsSelectorFn("selector(unknown|a)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsSelectorFn("selector(a::asdf)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsSelectorFn("selector(a:asdf)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsSelectorFn("selector(a, body)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsSelectorFn("selector(*:asdf)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsSelectorFn("selector(*::asdf)"));
+ EXPECT_EQ(Result::kUnsupported, ConsumeSupportsSelectorFn("selector(:asdf)"));
+ EXPECT_EQ(Result::kUnsupported,
+ ConsumeSupportsSelectorFn("selector(::asdf)"));
+
+ EXPECT_EQ(Result::kParseFailure, ConsumeSupportsSelectorFn("#test"));
+ EXPECT_EQ(Result::kParseFailure, ConsumeSupportsSelectorFn("test"));
+ EXPECT_EQ(Result::kParseFailure, ConsumeSupportsSelectorFn("test(1)"));
+}
+
+TEST_F(CSSSupportsParserTest, ConsumeSupportsSelectorFnWithFeatureDisabled) {
+ ScopedCSSSupportsSelectorForTest css_supports_selector(false);
+
+ EXPECT_EQ(Result::kParseFailure, ConsumeSupportsSelectorFn("selector(*)"));
+ EXPECT_EQ(Result::kParseFailure, ConsumeSupportsSelectorFn("selector(div)"));
+ EXPECT_EQ(Result::kParseFailure, ConsumeSupportsSelectorFn("selector(.a)"));
+}
+
+TEST_F(CSSSupportsParserTest, ConsumeSupportsDecl) {
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsDecl("(color:red)"));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsDecl("(color: red)"));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsDecl("(color : red)"));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsDecl("(color :red)"));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsDecl("( color:red )"));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsDecl("(--x:red)"));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsDecl("(--x:\tred) "));
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsDecl("(--x:\tred) \t "));
+ EXPECT_EQ(Result::kSupported,
+ ConsumeSupportsDecl("(color:green !important)"));
+ // For some reason EOF is allowed in place of ')' (everywhere in Blink).
+ // Seems to be the case in Firefox too.
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsDecl("(color:red"));
+
+ EXPECT_EQ(Result::kUnsupported, ConsumeSupportsDecl("(color:asdf)"));
+ EXPECT_EQ(Result::kUnsupported, ConsumeSupportsDecl("(asdf)"));
+ EXPECT_EQ(Result::kUnsupported, ConsumeSupportsDecl("(color)"));
+ EXPECT_EQ(Result::kUnsupported, ConsumeSupportsDecl("(color:)"));
+
+ EXPECT_EQ(Result::kParseFailure, ConsumeSupportsDecl(""));
+ EXPECT_EQ(Result::kParseFailure, ConsumeSupportsDecl("("));
+ EXPECT_EQ(Result::kParseFailure, ConsumeSupportsDecl(")"));
+ EXPECT_EQ(Result::kParseFailure, ConsumeSupportsDecl("()"));
+ EXPECT_EQ(Result::kParseFailure, ConsumeSupportsDecl("color:red)"));
+ EXPECT_EQ(Result::kParseFailure, ConsumeSupportsDecl("color:red"));
+}
+
+TEST_F(CSSSupportsParserTest, ConsumeSupportsFeature) {
+ EXPECT_EQ(Result::kSupported, ConsumeSupportsFeature("(color:red)"));
+
+ {
+ ScopedCSSSupportsSelectorForTest css_supports_selector(true);
+ EXPECT_EQ(Result::kParseFailure, ConsumeSupportsFeature("asdf(1)"));
+ }
+}
+
+TEST_F(CSSSupportsParserTest, ConsumeGeneralEnclosed) {
+ EXPECT_EQ(Result::kUnknown, ConsumeGeneralEnclosed("(asdf)"));
+ EXPECT_EQ(Result::kUnknown, ConsumeGeneralEnclosed("( asdf )"));
+ EXPECT_EQ(Result::kUnknown, ConsumeGeneralEnclosed("(3)"));
+ EXPECT_EQ(Result::kUnknown, ConsumeGeneralEnclosed("max(1, 2)"));
+ EXPECT_EQ(Result::kUnknown, ConsumeGeneralEnclosed("asdf(1, 2)"));
+ EXPECT_EQ(Result::kUnknown, ConsumeGeneralEnclosed("asdf(1, 2)\t"));
+
+ EXPECT_EQ(Result::kParseFailure, ConsumeGeneralEnclosed(""));
+ EXPECT_EQ(Result::kParseFailure, ConsumeGeneralEnclosed("("));
+ EXPECT_EQ(Result::kParseFailure, ConsumeGeneralEnclosed(")"));
+ EXPECT_EQ(Result::kParseFailure, ConsumeGeneralEnclosed("()"));
+ EXPECT_EQ(Result::kParseFailure, ConsumeGeneralEnclosed("color:red"));
+ EXPECT_EQ(Result::kParseFailure, ConsumeGeneralEnclosed("asdf"));
+
+ EXPECT_EQ(Result::kUnknown, ConsumeGeneralEnclosed("(asdf)"));
+ EXPECT_EQ(Result::kUnknown, ConsumeGeneralEnclosed("( asdf )"));
+ EXPECT_EQ(Result::kUnknown, ConsumeGeneralEnclosed("(3)"));
+ EXPECT_EQ(Result::kUnknown, ConsumeGeneralEnclosed("max(1, 2)"));
+ EXPECT_EQ(Result::kUnknown, ConsumeGeneralEnclosed("asdf(1, 2)"));
+ EXPECT_EQ(Result::kUnknown, ConsumeGeneralEnclosed("asdf(1, 2)\t"));
+
+ EXPECT_EQ(Result::kParseFailure, ConsumeGeneralEnclosed(""));
+ EXPECT_EQ(Result::kParseFailure, ConsumeGeneralEnclosed("("));
+ EXPECT_EQ(Result::kParseFailure, ConsumeGeneralEnclosed(")"));
+ EXPECT_EQ(Result::kParseFailure, ConsumeGeneralEnclosed("()"));
+ EXPECT_EQ(Result::kParseFailure, ConsumeGeneralEnclosed("color:red"));
+ EXPECT_EQ(Result::kParseFailure, ConsumeGeneralEnclosed("asdf"));
+
+ // Invalid <any-value>:
+ EXPECT_EQ(Result::kParseFailure, ConsumeGeneralEnclosed("(asdf})"));
+ EXPECT_EQ(Result::kParseFailure, ConsumeGeneralEnclosed("(asd]f)"));
+ EXPECT_EQ(Result::kParseFailure, ConsumeGeneralEnclosed("(\"as\ndf\")"));
+ EXPECT_EQ(Result::kParseFailure, ConsumeGeneralEnclosed("(url(as'df))"));
+
+ // Valid <any-value>
+ EXPECT_EQ(Result::kUnknown, ConsumeGeneralEnclosed("(as;df)"));
+ EXPECT_EQ(Result::kUnknown, ConsumeGeneralEnclosed("(as ! df)"));
+}
+
+TEST_F(CSSSupportsParserTest, AtSupportsCondition) {
+ EXPECT_EQ(Result::kSupported, AtSupports("(--x:red)"));
+ EXPECT_EQ(Result::kSupported, AtSupports("(--x:red) and (color:green)"));
+ EXPECT_EQ(Result::kSupported, AtSupports("(--x:red) or (color:asdf)"));
+ EXPECT_EQ(Result::kSupported,
+ AtSupports("not ((color:gjhk) or (color:asdf))"));
+ EXPECT_EQ(Result::kSupported,
+ AtSupports("(display: none) and ( (display: none) )"));
+
+ EXPECT_EQ(Result::kUnsupported, AtSupports("(color:ghjk) or (color:asdf)"));
+ EXPECT_EQ(Result::kUnsupported, AtSupports("(color:ghjk) or asdf(1)"));
+ EXPECT_EQ(Result::kParseFailure, AtSupports("color:red"));
+ EXPECT_EQ(
+ Result::kParseFailure,
+ AtSupports("(display: none) and (display: block) or (display: inline)"));
+ EXPECT_EQ(Result::kParseFailure,
+ AtSupports("not (display: deadbeef) and (display: block)"));
+ EXPECT_EQ(Result::kParseFailure,
+ AtSupports("(margin: 0) and (display: inline) or (width:1em)"));
+
+ // "and("/"or(" are function tokens, hence not allowed here.
+ EXPECT_EQ(Result::kParseFailure, AtSupports("(left:0) and(top:0)"));
+ EXPECT_EQ(Result::kParseFailure, AtSupports("(left:0) or(top:0)"));
+}
+
+TEST_F(CSSSupportsParserTest, WindowCSSSupportsCondition) {
+ EXPECT_EQ(Result::kSupported, WindowCSSSupports("(--x:red)"));
+ EXPECT_EQ(Result::kSupported, WindowCSSSupports("( --x:red )"));
+ EXPECT_EQ(Result::kSupported,
+ WindowCSSSupports("(--x:red) and (color:green)"));
+ EXPECT_EQ(Result::kSupported, WindowCSSSupports("(--x:red) or (color:asdf)"));
+ EXPECT_EQ(Result::kSupported,
+ WindowCSSSupports("not ((color:gjhk) or (color:asdf))"));
+
+ EXPECT_EQ(Result::kUnsupported,
+ WindowCSSSupports("(color:ghjk) or (color:asdf)"));
+ EXPECT_EQ(Result::kUnsupported, WindowCSSSupports("(color:ghjk) or asdf(1)"));
+ EXPECT_EQ(Result::kSupported, WindowCSSSupports("color:red"));
+}
+
+} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/parser/font_variant_east_asian_parser.h b/chromium/third_party/blink/renderer/core/css/parser/font_variant_east_asian_parser.h
index cd30505863e..d8f4be1589d 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/font_variant_east_asian_parser.h
+++ b/chromium/third_party/blink/renderer/core/css/parser/font_variant_east_asian_parser.h
@@ -55,12 +55,18 @@ class FontVariantEastAsianParser {
CSSValue* FinalizeValue() {
CSSValueList* result = CSSValueList::CreateSpaceSeparated();
- if (east_asian_form_value_)
- result->Append(*east_asian_form_value_.Release());
- if (east_asian_width_value_)
- result->Append(*east_asian_width_value_.Release());
- if (ruby_value_)
- result->Append(*ruby_value_.Release());
+ if (east_asian_form_value_) {
+ result->Append(*east_asian_form_value_);
+ east_asian_form_value_ = nullptr;
+ }
+ if (east_asian_width_value_) {
+ result->Append(*east_asian_width_value_);
+ east_asian_width_value_ = nullptr;
+ }
+ if (ruby_value_) {
+ result->Append(*ruby_value_);
+ ruby_value_ = nullptr;
+ }
if (!result->length())
return CSSIdentifierValue::Create(CSSValueID::kNormal);
@@ -68,9 +74,9 @@ class FontVariantEastAsianParser {
}
private:
- Member<CSSIdentifierValue> east_asian_form_value_;
- Member<CSSIdentifierValue> east_asian_width_value_;
- Member<CSSIdentifierValue> ruby_value_;
+ CSSIdentifierValue* east_asian_form_value_;
+ CSSIdentifierValue* east_asian_width_value_;
+ CSSIdentifierValue* ruby_value_;
};
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/parser/font_variant_ligatures_parser.h b/chromium/third_party/blink/renderer/core/css/parser/font_variant_ligatures_parser.h
index 5a823068751..9da89771349 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/font_variant_ligatures_parser.h
+++ b/chromium/third_party/blink/renderer/core/css/parser/font_variant_ligatures_parser.h
@@ -62,7 +62,9 @@ class FontVariantLigaturesParser {
CSSValue* FinalizeValue() {
if (!result_->length())
return CSSIdentifierValue::Create(CSSValueID::kNormal);
- return result_.Release();
+ CSSValue* result = result_;
+ result_ = nullptr;
+ return result;
}
private:
@@ -70,7 +72,7 @@ class FontVariantLigaturesParser {
bool saw_discretionary_ligatures_value_;
bool saw_historical_ligatures_value_;
bool saw_contextual_ligatures_value_;
- Member<CSSValueList> result_;
+ CSSValueList* result_;
};
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/parser/font_variant_numeric_parser.h b/chromium/third_party/blink/renderer/core/css/parser/font_variant_numeric_parser.h
index 519c321695c..f34b7ae000f 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/font_variant_numeric_parser.h
+++ b/chromium/third_party/blink/renderer/core/css/parser/font_variant_numeric_parser.h
@@ -73,11 +73,11 @@ class FontVariantNumericParser {
}
private:
- Member<CSSIdentifierValue> numeric_figure_;
- Member<CSSIdentifierValue> numeric_spacing_;
- Member<CSSIdentifierValue> numeric_fraction_;
- Member<CSSIdentifierValue> ordinal_;
- Member<CSSIdentifierValue> slashed_zero_;
+ CSSIdentifierValue* numeric_figure_ = nullptr;
+ CSSIdentifierValue* numeric_spacing_ = nullptr;
+ CSSIdentifierValue* numeric_fraction_ = nullptr;
+ CSSIdentifierValue* ordinal_ = nullptr;
+ CSSIdentifierValue* slashed_zero_ = nullptr;
};
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/parser/media_condition_test.cc b/chromium/third_party/blink/renderer/core/css/parser/media_condition_test.cc
index cc8668d3c4b..f76c97e21f1 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/media_condition_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/media_condition_test.cc
@@ -40,7 +40,8 @@ TEST(MediaConditionParserTest, Basic) {
CSSTokenizer tokenizer(test_cases[i].input);
const auto tokens = tokenizer.TokenizeToEOF();
scoped_refptr<MediaQuerySet> media_condition_query_set =
- MediaQueryParser::ParseMediaCondition(CSSParserTokenRange(tokens));
+ MediaQueryParser::ParseMediaCondition(CSSParserTokenRange(tokens),
+ nullptr);
ASSERT_EQ(media_condition_query_set->QueryVector().size(), (unsigned)1);
String query_text = media_condition_query_set->QueryVector()[0]->CssText();
ASSERT_EQ(test_cases[i].output, query_text);
diff --git a/chromium/third_party/blink/renderer/core/css/parser/media_query_parser.cc b/chromium/third_party/blink/renderer/core/css/parser/media_query_parser.cc
index fef2f9cd162..c64ea658fd4 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/media_query_parser.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/media_query_parser.cc
@@ -4,32 +4,41 @@
#include "third_party/blink/renderer/core/css/parser/media_query_parser.h"
+#include "third_party/blink/renderer/core/css/parser/css_parser_context.h"
#include "third_party/blink/renderer/core/css/parser/css_tokenizer.h"
#include "third_party/blink/renderer/core/media_type_names.h"
namespace blink {
scoped_refptr<MediaQuerySet> MediaQueryParser::ParseMediaQuerySet(
- const String& query_string) {
+ const String& query_string,
+ const ExecutionContext* execution_context) {
return ParseMediaQuerySet(
- CSSParserTokenRange(CSSTokenizer(query_string).TokenizeToEOF()));
+ CSSParserTokenRange(CSSTokenizer(query_string).TokenizeToEOF()),
+ execution_context);
}
scoped_refptr<MediaQuerySet> MediaQueryParser::ParseMediaQuerySet(
- CSSParserTokenRange range) {
- return MediaQueryParser(kMediaQuerySetParser, kHTMLStandardMode)
+ CSSParserTokenRange range,
+ const ExecutionContext* execution_context) {
+ return MediaQueryParser(kMediaQuerySetParser, kHTMLStandardMode,
+ execution_context)
.ParseImpl(range);
}
scoped_refptr<MediaQuerySet> MediaQueryParser::ParseMediaQuerySetInMode(
CSSParserTokenRange range,
- CSSParserMode mode) {
- return MediaQueryParser(kMediaQuerySetParser, mode).ParseImpl(range);
+ CSSParserMode mode,
+ const ExecutionContext* execution_context) {
+ return MediaQueryParser(kMediaQuerySetParser, mode, execution_context)
+ .ParseImpl(range);
}
scoped_refptr<MediaQuerySet> MediaQueryParser::ParseMediaCondition(
- CSSParserTokenRange range) {
- return MediaQueryParser(kMediaConditionParser, kHTMLStandardMode)
+ CSSParserTokenRange range,
+ const ExecutionContext* execution_context) {
+ return MediaQueryParser(kMediaConditionParser, kHTMLStandardMode,
+ execution_context)
.ParseImpl(range);
}
@@ -57,10 +66,13 @@ const MediaQueryParser::State MediaQueryParser::kSkipUntilBlockEnd =
&MediaQueryParser::SkipUntilBlockEnd;
const MediaQueryParser::State MediaQueryParser::kDone = &MediaQueryParser::Done;
-MediaQueryParser::MediaQueryParser(ParserType parser_type, CSSParserMode mode)
+MediaQueryParser::MediaQueryParser(ParserType parser_type,
+ CSSParserMode mode,
+ const ExecutionContext* execution_context)
: parser_type_(parser_type),
query_set_(MediaQuerySet::Create()),
- mode_(mode) {
+ mode_(mode),
+ execution_context_(execution_context) {
if (parser_type == kMediaQuerySetParser)
state_ = &MediaQueryParser::ReadRestrictor;
else // MediaConditionParser
@@ -183,7 +195,7 @@ void MediaQueryParser::ReadFeatureColon(CSSParserTokenType type,
else
state_ = kReadFeatureValue;
} else if (type == kRightParenthesisToken || type == kEOFToken) {
- media_query_data_.AddExpression(range);
+ media_query_data_.AddExpression(range, execution_context_);
ReadFeatureEnd(type, token, range);
} else {
state_ = kSkipUntilBlockEnd;
@@ -198,7 +210,7 @@ void MediaQueryParser::ReadFeatureValue(CSSParserTokenType type,
range.Consume();
state_ = kSkipUntilComma;
} else {
- media_query_data_.AddExpression(range);
+ media_query_data_.AddExpression(range, execution_context_);
state_ = kReadFeatureEnd;
}
}
@@ -289,7 +301,10 @@ bool MediaQueryParser::IsMediaFeatureAllowedInMode(
MediaQueryData::MediaQueryData()
: restrictor_(MediaQuery::kNone),
media_type_(media_type_names::kAll),
- media_type_set_(false) {}
+ media_type_set_(false),
+ fake_context_(*MakeGarbageCollected<CSSParserContext>(
+ kHTMLStandardMode,
+ SecureContextMode::kInsecureContext)) {}
void MediaQueryData::Clear() {
restrictor_ = MediaQuery::kNone;
@@ -306,8 +321,10 @@ std::unique_ptr<MediaQuery> MediaQueryData::TakeMediaQuery() {
return media_query;
}
-void MediaQueryData::AddExpression(CSSParserTokenRange& range) {
- expressions_.push_back(MediaQueryExp::Create(media_feature_, range));
+void MediaQueryData::AddExpression(CSSParserTokenRange& range,
+ const ExecutionContext* execution_context) {
+ expressions_.push_back(MediaQueryExp::Create(
+ media_feature_, range, fake_context_, execution_context));
}
bool MediaQueryData::LastExpressionValid() {
diff --git a/chromium/third_party/blink/renderer/core/css/parser/media_query_parser.h b/chromium/third_party/blink/renderer/core/css/parser/media_query_parser.h
index 0da7b89eb18..a956c975641 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/media_query_parser.h
+++ b/chromium/third_party/blink/renderer/core/css/parser/media_query_parser.h
@@ -19,6 +19,7 @@
namespace blink {
class MediaQuerySet;
+class CSSParserContext;
class MediaQueryData {
STACK_ALLOCATED();
@@ -30,10 +31,14 @@ class MediaQueryData {
String media_feature_;
bool media_type_set_;
+ // A fake CSSParserContext for use counter only.
+ // TODO(xiaochengh): Plumb the real CSSParserContext from the document.
+ const CSSParserContext& fake_context_;
+
public:
MediaQueryData();
void Clear();
- void AddExpression(CSSParserTokenRange&);
+ void AddExpression(CSSParserTokenRange&, const ExecutionContext*);
bool LastExpressionValid();
void RemoveLastExpression();
void SetMediaType(const String&);
@@ -57,12 +62,19 @@ class CORE_EXPORT MediaQueryParser {
STACK_ALLOCATED();
public:
- static scoped_refptr<MediaQuerySet> ParseMediaQuerySet(const String&);
- static scoped_refptr<MediaQuerySet> ParseMediaQuerySet(CSSParserTokenRange);
- static scoped_refptr<MediaQuerySet> ParseMediaCondition(CSSParserTokenRange);
+ static scoped_refptr<MediaQuerySet> ParseMediaQuerySet(
+ const String&,
+ const ExecutionContext*);
+ static scoped_refptr<MediaQuerySet> ParseMediaQuerySet(
+ CSSParserTokenRange,
+ const ExecutionContext*);
+ static scoped_refptr<MediaQuerySet> ParseMediaCondition(
+ CSSParserTokenRange,
+ const ExecutionContext*);
static scoped_refptr<MediaQuerySet> ParseMediaQuerySetInMode(
CSSParserTokenRange,
- CSSParserMode);
+ CSSParserMode,
+ const ExecutionContext*);
private:
enum ParserType {
@@ -70,7 +82,7 @@ class CORE_EXPORT MediaQueryParser {
kMediaConditionParser,
};
- MediaQueryParser(ParserType, CSSParserMode);
+ MediaQueryParser(ParserType, CSSParserMode, const ExecutionContext*);
virtual ~MediaQueryParser();
scoped_refptr<MediaQuerySet> ParseImpl(CSSParserTokenRange);
@@ -125,6 +137,7 @@ class CORE_EXPORT MediaQueryParser {
scoped_refptr<MediaQuerySet> query_set_;
MediaQueryBlockWatcher block_watcher_;
CSSParserMode mode_;
+ const ExecutionContext* execution_context_;
const static State kReadRestrictor;
const static State kReadMediaNot;
diff --git a/chromium/third_party/blink/renderer/core/css/parser/sizes_attribute_parser.cc b/chromium/third_party/blink/renderer/core/css/parser/sizes_attribute_parser.cc
index 7a59eb34018..11ad76dae45 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/sizes_attribute_parser.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/sizes_attribute_parser.cc
@@ -11,10 +11,15 @@
namespace blink {
-SizesAttributeParser::SizesAttributeParser(MediaValues* media_values,
- const String& attribute)
- : media_values_(media_values), length_(0), length_was_set_(false) {
- DCHECK(media_values_.Get());
+SizesAttributeParser::SizesAttributeParser(
+ MediaValues* media_values,
+ const String& attribute,
+ const ExecutionContext* execution_context)
+ : media_values_(media_values),
+ execution_context_(execution_context),
+ length_(0),
+ length_was_set_(false) {
+ DCHECK(media_values_);
is_valid_ =
Parse(CSSParserTokenRange(CSSTokenizer(attribute).TokenizeToEOF()));
}
@@ -83,7 +88,8 @@ bool SizesAttributeParser::Parse(CSSParserTokenRange range) {
continue;
scoped_refptr<MediaQuerySet> media_condition =
MediaQueryParser::ParseMediaCondition(
- range.MakeSubRange(media_condition_start, length_token_start));
+ range.MakeSubRange(media_condition_start, length_token_start),
+ execution_context_);
if (!media_condition || !MediaConditionMatches(*media_condition))
continue;
length_ = length;
diff --git a/chromium/third_party/blink/renderer/core/css/parser/sizes_attribute_parser.h b/chromium/third_party/blink/renderer/core/css/parser/sizes_attribute_parser.h
index 3549b57c29a..f0dfbd4569e 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/sizes_attribute_parser.h
+++ b/chromium/third_party/blink/renderer/core/css/parser/sizes_attribute_parser.h
@@ -14,11 +14,13 @@
namespace blink {
+class ExecutionContext;
+
class CORE_EXPORT SizesAttributeParser {
STACK_ALLOCATED();
public:
- SizesAttributeParser(MediaValues*, const String&);
+ SizesAttributeParser(MediaValues*, const String&, const ExecutionContext*);
float length();
@@ -30,7 +32,8 @@ class CORE_EXPORT SizesAttributeParser {
float EffectiveSizeDefaultValue();
scoped_refptr<MediaQuerySet> media_condition_;
- Member<MediaValues> media_values_;
+ MediaValues* media_values_;
+ const ExecutionContext* execution_context_;
float length_;
bool length_was_set_;
bool is_valid_;
diff --git a/chromium/third_party/blink/renderer/core/css/parser/sizes_attribute_parser_test.cc b/chromium/third_party/blink/renderer/core/css/parser/sizes_attribute_parser_test.cc
index bcb5bcd9e49..e6f80eada0f 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/sizes_attribute_parser_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/sizes_attribute_parser_test.cc
@@ -91,7 +91,7 @@ TEST(SizesAttributeParserTest, Basic) {
auto* media_values = MakeGarbageCollected<MediaValuesCached>(data);
for (unsigned i = 0; test_cases[i].input; ++i) {
- SizesAttributeParser parser(media_values, test_cases[i].input);
+ SizesAttributeParser parser(media_values, test_cases[i].input, nullptr);
ASSERT_EQ(test_cases[i].effective_size, parser.length());
}
}
@@ -172,7 +172,7 @@ TEST(SizesAttributeParserTest, FloatViewportWidth) {
auto* media_values = MakeGarbageCollected<MediaValuesCached>(data);
for (unsigned i = 0; test_cases[i].input; ++i) {
- SizesAttributeParser parser(media_values, test_cases[i].input);
+ SizesAttributeParser parser(media_values, test_cases[i].input, nullptr);
ASSERT_EQ(test_cases[i].effective_size, parser.length());
}
}
diff --git a/chromium/third_party/blink/renderer/core/css/parser/sizes_math_function_parser.cc b/chromium/third_party/blink/renderer/core/css/parser/sizes_math_function_parser.cc
index 6daa4598c3c..7dd70a11bf0 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/sizes_math_function_parser.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/sizes_math_function_parser.cc
@@ -117,8 +117,6 @@ bool SizesMathFunctionParser::HandleRightParenthesis(
bool SizesMathFunctionParser::HandleComma(Vector<CSSParserToken>& stack,
const CSSParserToken& token) {
- if (!RuntimeEnabledFeatures::CSSComparisonFunctionsEnabled())
- return false;
// Treat comma as a binary right-associative operation for now, so that
// when reaching the right parenthesis of the function, we can get the
// number of parameters by counting the number of commas.
@@ -180,13 +178,11 @@ bool SizesMathFunctionParser::CalcToReversePolishNotation(
return false;
break;
case kFunctionToken:
- if (RuntimeEnabledFeatures::CSSComparisonFunctionsEnabled()) {
- if (token.FunctionId() == CSSValueID::kMin ||
- token.FunctionId() == CSSValueID::kMax ||
- token.FunctionId() == CSSValueID::kClamp) {
- stack.push_back(token);
- break;
- }
+ if (token.FunctionId() == CSSValueID::kMin ||
+ token.FunctionId() == CSSValueID::kMax ||
+ token.FunctionId() == CSSValueID::kClamp) {
+ stack.push_back(token);
+ break;
}
if (token.FunctionId() != CSSValueID::kCalc)
return false;
diff --git a/chromium/third_party/blink/renderer/core/css/parser/sizes_math_function_parser.h b/chromium/third_party/blink/renderer/core/css/parser/sizes_math_function_parser.h
index de8b146de0c..7c88ea53a82 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/sizes_math_function_parser.h
+++ b/chromium/third_party/blink/renderer/core/css/parser/sizes_math_function_parser.h
@@ -48,7 +48,7 @@ class CORE_EXPORT SizesMathFunctionParser {
void AppendOperator(const CSSParserToken&);
Vector<SizesMathValue> value_list_;
- Member<MediaValues> media_values_;
+ MediaValues* media_values_;
bool is_valid_;
float result_;
};
diff --git a/chromium/third_party/blink/renderer/core/css/parser/sizes_math_function_parser_test.cc b/chromium/third_party/blink/renderer/core/css/parser/sizes_math_function_parser_test.cc
index f6b07c22960..7710f1917e5 100644
--- a/chromium/third_party/blink/renderer/core/css/parser/sizes_math_function_parser_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/parser/sizes_math_function_parser_test.cc
@@ -12,7 +12,6 @@
#include "third_party/blink/renderer/core/css/parser/css_tokenizer.h"
#include "third_party/blink/renderer/core/media_type_names.h"
#include "third_party/blink/renderer/platform/fonts/font.h"
-#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
namespace blink {
@@ -63,8 +62,6 @@ static void VerifyCSSCalc(String text,
}
TEST(SizesMathFunctionParserTest, Basic) {
- ScopedCSSComparisonFunctionsForTest scope(true);
-
SizesCalcTestCase test_cases[] = {
{"calc(500px + 10em)", 660, true, false},
{"calc(500px / 8)", 62.5, true, false},
diff --git a/chromium/third_party/blink/renderer/core/css/properties/computed_style_utils.cc b/chromium/third_party/blink/renderer/core/css/properties/computed_style_utils.cc
index b4ee2719ad6..b876e57eebd 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/computed_style_utils.cc
+++ b/chromium/third_party/blink/renderer/core/css/properties/computed_style_utils.cc
@@ -45,6 +45,10 @@
#include "third_party/blink/renderer/core/style/style_svg_resource.h"
#include "third_party/blink/renderer/core/style_property_shorthand.h"
#include "third_party/blink/renderer/core/svg_element_type_helpers.h"
+#include "third_party/blink/renderer/platform/transforms/matrix_3d_transform_operation.h"
+#include "third_party/blink/renderer/platform/transforms/matrix_transform_operation.h"
+#include "third_party/blink/renderer/platform/transforms/perspective_transform_operation.h"
+#include "third_party/blink/renderer/platform/transforms/skew_transform_operation.h"
namespace blink {
@@ -162,11 +166,10 @@ const CSSValue* ComputedStyleUtils::ValueForFillSize(
return ZoomAdjustedPixelValueForLength(fill_size.size.Width(), style);
}
- CSSValueList* list = CSSValueList::CreateSpaceSeparated();
- list->Append(*ZoomAdjustedPixelValueForLength(fill_size.size.Width(), style));
- list->Append(
- *ZoomAdjustedPixelValueForLength(fill_size.size.Height(), style));
- return list;
+ return MakeGarbageCollected<CSSValuePair>(
+ ZoomAdjustedPixelValueForLength(fill_size.size.Width(), style),
+ ZoomAdjustedPixelValueForLength(fill_size.size.Height(), style),
+ CSSValuePair::kKeepIdenticalValues);
}
const CSSValue* ComputedStyleUtils::BackgroundImageOrWebkitMaskSize(
@@ -286,8 +289,15 @@ const CSSValue* ComputedStyleUtils::BackgroundPositionXOrWebkitMaskPositionX(
const FillLayer* curr_layer) {
CSSValueList* list = CSSValueList::CreateCommaSeparated();
for (; curr_layer; curr_layer = curr_layer->Next()) {
- list->Append(
- *ZoomAdjustedPixelValueForLength(curr_layer->PositionX(), style));
+ const Length& from_edge = curr_layer->PositionX();
+ if (curr_layer->BackgroundXOrigin() == BackgroundEdgeOrigin::kRight) {
+ // TODO(crbug.com/610627): This should use two-value syntax once the
+ // parser accepts it.
+ list->Append(*ZoomAdjustedPixelValueForLength(
+ from_edge.SubtractFromOneHundredPercent(), style));
+ } else {
+ list->Append(*ZoomAdjustedPixelValueForLength(from_edge, style));
+ }
}
return list;
}
@@ -297,8 +307,15 @@ const CSSValue* ComputedStyleUtils::BackgroundPositionYOrWebkitMaskPositionY(
const FillLayer* curr_layer) {
CSSValueList* list = CSSValueList::CreateCommaSeparated();
for (; curr_layer; curr_layer = curr_layer->Next()) {
- list->Append(
- *ZoomAdjustedPixelValueForLength(curr_layer->PositionY(), style));
+ const Length& from_edge = curr_layer->PositionY();
+ if (curr_layer->BackgroundYOrigin() == BackgroundEdgeOrigin::kBottom) {
+ // TODO(crbug.com/610627): This should use two-value syntax once the
+ // parser accepts it.
+ list->Append(*ZoomAdjustedPixelValueForLength(
+ from_edge.SubtractFromOneHundredPercent(), style));
+ } else {
+ list->Append(*ZoomAdjustedPixelValueForLength(from_edge, style));
+ }
}
return list;
}
@@ -738,6 +755,22 @@ CSSValue* ComputedStyleUtils::ValueForLineHeight(const ComputedStyle& style) {
style);
}
+CSSValue* ComputedStyleUtils::ComputedValueForLineHeight(
+ const ComputedStyle& style) {
+ const Length& length = style.LineHeight();
+ if (length.IsNegative())
+ return CSSIdentifierValue::Create(CSSValueID::kNormal);
+
+ if (length.IsPercent()) {
+ return CSSNumericLiteralValue::Create(length.GetFloatValue() / 100.0,
+ CSSPrimitiveValue::UnitType::kNumber);
+ } else {
+ return ZoomAdjustedPixelValue(
+ FloatValueForLength(length, style.GetFontDescription().ComputedSize()),
+ style);
+ }
+}
+
CSSValueID IdentifierForFamily(const AtomicString& family) {
if (family == font_family_names::kWebkitCursive)
return CSSValueID::kCursive;
@@ -745,8 +778,6 @@ CSSValueID IdentifierForFamily(const AtomicString& family) {
return CSSValueID::kFantasy;
if (family == font_family_names::kWebkitMonospace)
return CSSValueID::kMonospace;
- if (family == font_family_names::kWebkitPictograph)
- return CSSValueID::kWebkitPictograph;
if (family == font_family_names::kWebkitSansSerif)
return CSSValueID::kSansSerif;
if (family == font_family_names::kWebkitSerif)
@@ -1485,30 +1516,27 @@ CSSValue* ComputedStyleUtils::ValueForTextDecorationSkipInk(
CSSValue* ComputedStyleUtils::TouchActionFlagsToCSSValue(
TouchAction touch_action) {
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
- if (touch_action == TouchAction::kTouchActionAuto) {
+ if (touch_action == TouchAction::kAuto) {
list->Append(*CSSIdentifierValue::Create(CSSValueID::kAuto));
- } else if (touch_action == TouchAction::kTouchActionNone) {
+ } else if (touch_action == TouchAction::kNone) {
list->Append(*CSSIdentifierValue::Create(CSSValueID::kNone));
- } else if (touch_action == TouchAction::kTouchActionManipulation) {
+ } else if (touch_action == TouchAction::kManipulation) {
list->Append(*CSSIdentifierValue::Create(CSSValueID::kManipulation));
} else {
- if ((touch_action & TouchAction::kTouchActionPanX) ==
- TouchAction::kTouchActionPanX)
+ if ((touch_action & TouchAction::kPanX) == TouchAction::kPanX)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kPanX));
- else if (touch_action & TouchAction::kTouchActionPanLeft)
+ else if ((touch_action & TouchAction::kPanLeft) != TouchAction::kNone)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kPanLeft));
- else if (touch_action & TouchAction::kTouchActionPanRight)
+ else if ((touch_action & TouchAction::kPanRight) != TouchAction::kNone)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kPanRight));
- if ((touch_action & TouchAction::kTouchActionPanY) ==
- TouchAction::kTouchActionPanY)
+ if ((touch_action & TouchAction::kPanY) == TouchAction::kPanY)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kPanY));
- else if (touch_action & TouchAction::kTouchActionPanUp)
+ else if ((touch_action & TouchAction::kPanUp) != TouchAction::kNone)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kPanUp));
- else if (touch_action & TouchAction::kTouchActionPanDown)
+ else if ((touch_action & TouchAction::kPanDown) != TouchAction::kNone)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kPanDown));
- if ((touch_action & TouchAction::kTouchActionPinchZoom) ==
- TouchAction::kTouchActionPinchZoom)
+ if ((touch_action & TouchAction::kPinchZoom) == TouchAction::kPinchZoom)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kPinchZoom));
}
@@ -1620,8 +1648,8 @@ CSSValue* ComputedStyleUtils::CreateTimingFunctionValue(
const TimingFunction* timing_function) {
switch (timing_function->GetType()) {
case TimingFunction::Type::CUBIC_BEZIER: {
- const CubicBezierTimingFunction* bezier_timing_function =
- ToCubicBezierTimingFunction(timing_function);
+ const auto* bezier_timing_function =
+ To<CubicBezierTimingFunction>(timing_function);
if (bezier_timing_function->GetEaseType() !=
CubicBezierTimingFunction::EaseType::CUSTOM) {
CSSValueID value_id = CSSValueID::kInvalid;
@@ -1650,15 +1678,16 @@ CSSValue* ComputedStyleUtils::CreateTimingFunctionValue(
}
case TimingFunction::Type::STEPS: {
- const StepsTimingFunction* steps_timing_function =
- ToStepsTimingFunction(timing_function);
+ const auto* steps_timing_function =
+ To<StepsTimingFunction>(timing_function);
StepsTimingFunction::StepPosition position =
steps_timing_function->GetStepPosition();
int steps = steps_timing_function->NumberOfSteps();
// Canonical form of step timing function is step(n, type) or step(n) even
// if initially parsed as step-start or step-end.
- return cssvalue::CSSStepsTimingFunctionValue::Create(steps, position);
+ return MakeGarbageCollected<cssvalue::CSSStepsTimingFunctionValue>(
+ steps, position);
}
default:
@@ -1700,16 +1729,16 @@ CSSValueList* ComputedStyleUtils::ValuesForBorderRadiusCorner(
return list;
}
-const CSSValue& ComputedStyleUtils::ValueForBorderRadiusCorner(
+CSSValue* ComputedStyleUtils::ValueForBorderRadiusCorner(
const LengthSize& radius,
const ComputedStyle& style) {
- CSSValueList& list = *ValuesForBorderRadiusCorner(radius, style);
- if (list.Item(0) == list.Item(1))
- return list.Item(0);
- return list;
+ return MakeGarbageCollected<CSSValuePair>(
+ ZoomAdjustedPixelValueForLength(radius.Width(), style),
+ ZoomAdjustedPixelValueForLength(radius.Height(), style),
+ CSSValuePair::kDropIdenticalValues);
}
-CSSFunctionValue* ValueForMatrixTransform(
+CSSValue* ComputedStyleUtils::ValueForMatrixTransform(
const TransformationMatrix& transform_param,
const ComputedStyle& style) {
// Take TransformationMatrix by reference and then copy it because VC++
@@ -1777,6 +1806,153 @@ CSSFunctionValue* ValueForMatrixTransform(
return transform_value;
}
+// We collapse functions like translateX into translate, since we will reify
+// them as a translate anyway.
+CSSValue* ComputedStyleUtils::ValueForTransformOperation(
+ const TransformOperation& operation,
+ float zoom) {
+ switch (operation.GetType()) {
+ case TransformOperation::kScaleX:
+ case TransformOperation::kScaleY:
+ case TransformOperation::kScaleZ:
+ case TransformOperation::kScale:
+ case TransformOperation::kScale3D: {
+ const auto& scale = To<ScaleTransformOperation>(operation);
+ CSSFunctionValue* result = MakeGarbageCollected<CSSFunctionValue>(
+ operation.Is3DOperation() ? CSSValueID::kScale3d
+ : CSSValueID::kScale);
+ result->Append(*CSSNumericLiteralValue::Create(
+ scale.X(), CSSPrimitiveValue::UnitType::kNumber));
+ result->Append(*CSSNumericLiteralValue::Create(
+ scale.Y(), CSSPrimitiveValue::UnitType::kNumber));
+ if (operation.Is3DOperation()) {
+ result->Append(*CSSNumericLiteralValue::Create(
+ scale.Z(), CSSPrimitiveValue::UnitType::kNumber));
+ }
+ return result;
+ }
+ case TransformOperation::kTranslateX:
+ case TransformOperation::kTranslateY:
+ case TransformOperation::kTranslateZ:
+ case TransformOperation::kTranslate:
+ case TransformOperation::kTranslate3D: {
+ const auto& translate = To<TranslateTransformOperation>(operation);
+ CSSFunctionValue* result = MakeGarbageCollected<CSSFunctionValue>(
+ operation.Is3DOperation() ? CSSValueID::kTranslate3d
+ : CSSValueID::kTranslate);
+ result->Append(*CSSPrimitiveValue::CreateFromLength(translate.X(), zoom));
+ result->Append(*CSSPrimitiveValue::CreateFromLength(translate.Y(), zoom));
+ if (operation.Is3DOperation()) {
+ // Since this is pixel length, we must unzoom (CreateFromLength above
+ // does the division internally).
+ result->Append(*CSSNumericLiteralValue::Create(
+ translate.Z() / zoom, CSSPrimitiveValue::UnitType::kPixels));
+ }
+ return result;
+ }
+ case TransformOperation::kRotateX:
+ case TransformOperation::kRotateY:
+ case TransformOperation::kRotate3D: {
+ const auto& rotate = To<RotateTransformOperation>(operation);
+ CSSFunctionValue* result =
+ MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kRotate3d);
+ result->Append(*CSSNumericLiteralValue::Create(
+ rotate.X(), CSSPrimitiveValue::UnitType::kNumber));
+ result->Append(*CSSNumericLiteralValue::Create(
+ rotate.Y(), CSSPrimitiveValue::UnitType::kNumber));
+ result->Append(*CSSNumericLiteralValue::Create(
+ rotate.Z(), CSSPrimitiveValue::UnitType::kNumber));
+ result->Append(*CSSNumericLiteralValue::Create(
+ rotate.Angle(), CSSPrimitiveValue::UnitType::kDegrees));
+ return result;
+ }
+ case TransformOperation::kRotate: {
+ const auto& rotate = To<RotateTransformOperation>(operation);
+ auto* result =
+ MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kRotate);
+ result->Append(*CSSNumericLiteralValue::Create(
+ rotate.Angle(), CSSPrimitiveValue::UnitType::kDegrees));
+ return result;
+ }
+ case TransformOperation::kSkewX: {
+ const auto& skew = To<SkewTransformOperation>(operation);
+ auto* result = MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kSkewX);
+ result->Append(*CSSNumericLiteralValue::Create(
+ skew.AngleX(), CSSPrimitiveValue::UnitType::kDegrees));
+ return result;
+ }
+ case TransformOperation::kSkewY: {
+ const auto& skew = To<SkewTransformOperation>(operation);
+ auto* result = MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kSkewY);
+ result->Append(*CSSNumericLiteralValue::Create(
+ skew.AngleY(), CSSPrimitiveValue::UnitType::kDegrees));
+ return result;
+ }
+ case TransformOperation::kSkew: {
+ const auto& skew = To<SkewTransformOperation>(operation);
+ auto* result = MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kSkew);
+ result->Append(*CSSNumericLiteralValue::Create(
+ skew.AngleX(), CSSPrimitiveValue::UnitType::kDegrees));
+ result->Append(*CSSNumericLiteralValue::Create(
+ skew.AngleY(), CSSPrimitiveValue::UnitType::kDegrees));
+ return result;
+ }
+ case TransformOperation::kPerspective: {
+ const auto& perspective = To<PerspectiveTransformOperation>(operation);
+ auto* result =
+ MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kPerspective);
+ result->Append(*CSSNumericLiteralValue::Create(
+ perspective.Perspective() / zoom,
+ CSSPrimitiveValue::UnitType::kPixels));
+ return result;
+ }
+ case TransformOperation::kMatrix: {
+ const auto& matrix = To<MatrixTransformOperation>(operation).Matrix();
+ auto* result =
+ MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kMatrix);
+ // CSS matrix values are returned in column-major order.
+ double values[6] = {matrix.A(), matrix.B(), //
+ matrix.C(), matrix.D(), //
+ // E and F are pixel lengths so unzoom
+ matrix.E() / zoom, matrix.F() / zoom};
+ for (double value : values) {
+ result->Append(*CSSNumericLiteralValue::Create(
+ value, CSSPrimitiveValue::UnitType::kNumber));
+ }
+ return result;
+ }
+ case TransformOperation::kMatrix3D: {
+ const auto& matrix = To<Matrix3DTransformOperation>(operation).Matrix();
+ CSSFunctionValue* result =
+ MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kMatrix3d);
+ // CSS matrix values are returned in column-major order.
+ double values[16] = {
+ // Note that the transformation matrix operates on (Length^3 * R).
+ // Each column contains 3 scalars followed by a reciprocal length
+ // (with a value in 1/px) which must be unzoomed accordingly.
+ matrix.M11(), matrix.M12(), matrix.M13(), matrix.M14() * zoom,
+ matrix.M21(), matrix.M22(), matrix.M23(), matrix.M24() * zoom,
+ matrix.M31(), matrix.M32(), matrix.M33(), matrix.M34() * zoom,
+ // Last column has 3 pixel lengths and a scalar
+ matrix.M41() / zoom, matrix.M42() / zoom, matrix.M43() / zoom,
+ matrix.M44()};
+ for (double value : values) {
+ result->Append(*CSSNumericLiteralValue::Create(
+ value, CSSPrimitiveValue::UnitType::kNumber));
+ }
+ return result;
+ }
+ case TransformOperation::kInterpolated:
+ // TODO(816803): The computed value in this case is not fully spec'd
+ // See https://github.com/w3c/css-houdini-drafts/issues/425
+ return CSSIdentifierValue::Create(CSSValueID::kNone);
+ default:
+ // The remaining operations are unsupported.
+ NOTREACHED();
+ return CSSIdentifierValue::Create(CSSValueID::kNone);
+ }
+}
+
FloatRect ComputedStyleUtils::ReferenceBoxForTransform(
const LayoutObject& layout_object,
UsePixelSnappedBox pixel_snap_box) {
@@ -1857,6 +2033,11 @@ CSSValueID ValueForQuoteType(const QuoteType quote_type) {
CSSValue* ComputedStyleUtils::ValueForContentData(const ComputedStyle& style,
bool allow_visited_style) {
+ if (style.ContentPreventsBoxGeneration())
+ return CSSIdentifierValue::Create(CSSValueID::kNone);
+ if (style.ContentBehavesAsNormal())
+ return CSSIdentifierValue::Create(CSSValueID::kNormal);
+
CSSValueList* outer_list = CSSValueList::CreateSlashSeparated();
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
@@ -1901,12 +2082,7 @@ CSSValue* ComputedStyleUtils::ValueForContentData(const ComputedStyle& style,
NOTREACHED();
}
}
- if (!list->length()) {
- PseudoId pseudoId = style.StyleType();
- if (pseudoId == kPseudoIdBefore || pseudoId == kPseudoIdAfter)
- return CSSIdentifierValue::Create(CSSValueID::kNone);
- return CSSIdentifierValue::Create(CSSValueID::kNormal);
- }
+ DCHECK(list->length());
outer_list->Append(*list);
if (alt_text)
@@ -2041,7 +2217,8 @@ CSSValue* ComputedStyleUtils::AdjustSVGPaintForCurrentColor(
const Color& current_color) {
if (paint.type >= SVG_PAINTTYPE_URI_NONE) {
CSSValueList* values = CSSValueList::CreateSpaceSeparated();
- values->Append(*cssvalue::CSSURIValue::Create(paint.GetUrl()));
+ values->Append(
+ *MakeGarbageCollected<cssvalue::CSSURIValue>(paint.GetUrl()));
if (paint.type == SVG_PAINTTYPE_URI_NONE)
values->Append(*CSSIdentifierValue::Create(CSSValueID::kNone));
else if (paint.type == SVG_PAINTTYPE_URI_CURRENTCOLOR)
@@ -2061,7 +2238,7 @@ CSSValue* ComputedStyleUtils::AdjustSVGPaintForCurrentColor(
CSSValue* ComputedStyleUtils::ValueForSVGResource(
const StyleSVGResource* resource) {
if (resource)
- return cssvalue::CSSURIValue::Create(resource->Url());
+ return MakeGarbageCollected<cssvalue::CSSURIValue>(resource->Url());
return CSSIdentifierValue::Create(CSSValueID::kNone);
}
@@ -2576,24 +2753,4 @@ ComputedStyleUtils::CrossThreadStyleValueFromCSSStyleValue(
}
}
-CSSValuePair* ComputedStyleUtils::ValuesForIntrinsicSizeShorthand(
- const StylePropertyShorthand& shorthand,
- const ComputedStyle& style,
- const LayoutObject* layout_object,
- bool allow_visited_style) {
- const CSSValue* start_value =
- shorthand.properties()[0]->CSSValueFromComputedStyle(style, layout_object,
- allow_visited_style);
- if (!start_value)
- return nullptr;
-
- const CSSValue* end_value =
- shorthand.properties()[1]->CSSValueFromComputedStyle(style, layout_object,
- allow_visited_style);
- if (!end_value)
- end_value = start_value;
- return MakeGarbageCollected<CSSValuePair>(start_value, end_value,
- CSSValuePair::kDropIdenticalValues);
-}
-
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/properties/computed_style_utils.h b/chromium/third_party/blink/renderer/core/css/properties/computed_style_utils.h
index cd53fe3de2b..51fcb47c59f 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/computed_style_utils.h
+++ b/chromium/third_party/blink/renderer/core/css/properties/computed_style_utils.h
@@ -99,6 +99,7 @@ class ComputedStyleUtils {
ValueForContentPositionAndDistributionWithOverflowAlignment(
const StyleContentAlignmentData&);
static CSSValue* ValueForLineHeight(const ComputedStyle&);
+ static CSSValue* ComputedValueForLineHeight(const ComputedStyle&);
static CSSValueList* ValueForFontFamily(const ComputedStyle&);
static CSSPrimitiveValue* ValueForFontSize(const ComputedStyle&);
static CSSPrimitiveValue* ValueForFontStretch(const ComputedStyle&);
@@ -135,8 +136,8 @@ class ComputedStyleUtils {
static CSSValue* ValueForAnimationTimingFunction(const CSSTimingData*);
static CSSValueList* ValuesForBorderRadiusCorner(const LengthSize&,
const ComputedStyle&);
- static const CSSValue& ValueForBorderRadiusCorner(const LengthSize&,
- const ComputedStyle&);
+ static CSSValue* ValueForBorderRadiusCorner(const LengthSize&,
+ const ComputedStyle&);
// TODO(fs): For some properties ('transform') we use the pixel snapped
// border-box as the reference box. In other cases ('transform-origin') we use
// the "unsnapped" border-box. Maybe use the same (the "unsnapped") in both
@@ -145,6 +146,10 @@ class ComputedStyleUtils {
kDontUsePixelSnappedBox,
kUsePixelSnappedBox,
};
+ static CSSValue* ValueForMatrixTransform(const TransformationMatrix&,
+ const ComputedStyle&);
+ static CSSValue* ValueForTransformOperation(const TransformOperation&,
+ float zoom);
static FloatRect ReferenceBoxForTransform(
const LayoutObject&,
UsePixelSnappedBox = kUsePixelSnappedBox);
@@ -214,12 +219,6 @@ class ComputedStyleUtils {
static CSSValue* ValueForGapLength(const GapLength&, const ComputedStyle&);
static std::unique_ptr<CrossThreadStyleValue>
CrossThreadStyleValueFromCSSStyleValue(CSSStyleValue* style_value);
-
- static CSSValuePair* ValuesForIntrinsicSizeShorthand(
- const StylePropertyShorthand&,
- const ComputedStyle&,
- const LayoutObject*,
- bool allow_visited_style);
};
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/properties/css_direction_aware_resolver.cc b/chromium/third_party/blink/renderer/core/css/properties/css_direction_aware_resolver.cc
index d34df6ddfdc..451c66bec37 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/css_direction_aware_resolver.cc
+++ b/chromium/third_party/blink/renderer/core/css/properties/css_direction_aware_resolver.cc
@@ -60,10 +60,6 @@ PhysicalGroup<4> CSSDirectionAwareResolver::InsetGroup() {
return PhysicalGroup<4>(insetShorthand());
}
-PhysicalGroup<2> CSSDirectionAwareResolver::IntrinsicSizeGroup() {
- return PhysicalGroup<2>(intrinsicSizeShorthand());
-}
-
PhysicalGroup<4> CSSDirectionAwareResolver::MarginGroup() {
return PhysicalGroup<4>(marginShorthand());
}
diff --git a/chromium/third_party/blink/renderer/core/css/properties/css_direction_aware_resolver.h b/chromium/third_party/blink/renderer/core/css/properties/css_direction_aware_resolver.h
index cbf4f7a4e22..4340a49a9c1 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/css_direction_aware_resolver.h
+++ b/chromium/third_party/blink/renderer/core/css/properties/css_direction_aware_resolver.h
@@ -36,7 +36,6 @@ class CSSDirectionAwareResolver {
static PhysicalGroup<4> BorderStyleGroup();
static PhysicalGroup<4> BorderWidthGroup();
static PhysicalGroup<4> InsetGroup();
- static PhysicalGroup<2> IntrinsicSizeGroup();
static PhysicalGroup<4> MarginGroup();
static PhysicalGroup<2> MaxSizeGroup();
static PhysicalGroup<2> MinSizeGroup();
diff --git a/chromium/third_party/blink/renderer/core/css/properties/css_parsing_utils.cc b/chromium/third_party/blink/renderer/core/css/properties/css_parsing_utils.cc
index f71c5c321c8..4ede24db6b5 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/css_parsing_utils.cc
+++ b/chromium/third_party/blink/renderer/core/css/properties/css_parsing_utils.cc
@@ -42,6 +42,7 @@
#include "third_party/blink/renderer/core/css/properties/css_property.h"
#include "third_party/blink/renderer/core/css/properties/longhand.h"
#include "third_party/blink/renderer/core/css_value_keywords.h"
+#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/style_property_shorthand.h"
#include "third_party/blink/renderer/core/svg/svg_parsing_error.h"
@@ -122,14 +123,15 @@ CSSValue* ConsumeBaselineKeyword(CSSParserTokenRange& range) {
return baseline;
}
-CSSValue* ConsumeSteps(CSSParserTokenRange& range) {
+CSSValue* ConsumeSteps(CSSParserTokenRange& range,
+ const CSSParserContext& context) {
DCHECK_EQ(range.Peek().FunctionId(), CSSValueID::kSteps);
CSSParserTokenRange range_copy = range;
CSSParserTokenRange args =
css_property_parser_helpers::ConsumeFunction(range_copy);
CSSPrimitiveValue* steps =
- css_property_parser_helpers::ConsumePositiveInteger(args);
+ css_property_parser_helpers::ConsumePositiveInteger(args, context);
if (!steps)
return nullptr;
@@ -176,26 +178,28 @@ CSSValue* ConsumeSteps(CSSParserTokenRange& range) {
}
range = range_copy;
- return cssvalue::CSSStepsTimingFunctionValue::Create(steps->GetIntValue(),
- position);
+ return MakeGarbageCollected<cssvalue::CSSStepsTimingFunctionValue>(
+ steps->GetIntValue(), position);
}
-CSSValue* ConsumeCubicBezier(CSSParserTokenRange& range) {
+CSSValue* ConsumeCubicBezier(CSSParserTokenRange& range,
+ const CSSParserContext& context) {
DCHECK_EQ(range.Peek().FunctionId(), CSSValueID::kCubicBezier);
CSSParserTokenRange range_copy = range;
CSSParserTokenRange args =
css_property_parser_helpers::ConsumeFunction(range_copy);
double x1, y1, x2, y2;
- if (css_property_parser_helpers::ConsumeNumberRaw(args, x1) && x1 >= 0 &&
- x1 <= 1 &&
+ if (css_property_parser_helpers::ConsumeNumberRaw(args, context, x1) &&
+ x1 >= 0 && x1 <= 1 &&
css_property_parser_helpers::ConsumeCommaIncludingWhitespace(args) &&
- css_property_parser_helpers::ConsumeNumberRaw(args, y1) &&
+ css_property_parser_helpers::ConsumeNumberRaw(args, context, y1) &&
css_property_parser_helpers::ConsumeCommaIncludingWhitespace(args) &&
- css_property_parser_helpers::ConsumeNumberRaw(args, x2) && x2 >= 0 &&
- x2 <= 1 &&
+ css_property_parser_helpers::ConsumeNumberRaw(args, context, x2) &&
+ x2 >= 0 && x2 <= 1 &&
css_property_parser_helpers::ConsumeCommaIncludingWhitespace(args) &&
- css_property_parser_helpers::ConsumeNumberRaw(args, y2) && args.AtEnd()) {
+ css_property_parser_helpers::ConsumeNumberRaw(args, context, y2) &&
+ args.AtEnd()) {
range = range_copy;
return MakeGarbageCollected<cssvalue::CSSCubicBezierTimingFunctionValue>(
x1, y1, x2, y2);
@@ -221,13 +225,13 @@ bool ConsumeCSSValueId(CSSParserTokenRange& range, CSSValueID& value) {
}
CSSValue* ConsumeShapeRadius(CSSParserTokenRange& args,
- CSSParserMode css_parser_mode) {
+ const CSSParserContext& context) {
if (css_property_parser_helpers::IdentMatches<CSSValueID::kClosestSide,
CSSValueID::kFarthestSide>(
args.Peek().Id()))
return css_property_parser_helpers::ConsumeIdent(args);
return css_property_parser_helpers::ConsumeLengthOrPercent(
- args, css_parser_mode, kValueRangeNonNegative);
+ args, context, kValueRangeNonNegative);
}
cssvalue::CSSBasicShapeCircleValue* ConsumeBasicShapeCircle(
@@ -236,7 +240,7 @@ cssvalue::CSSBasicShapeCircleValue* ConsumeBasicShapeCircle(
// spec: https://drafts.csswg.org/css-shapes/#supported-basic-shapes
// circle( [<shape-radius>]? [at <position>]? )
auto* shape = MakeGarbageCollected<cssvalue::CSSBasicShapeCircleValue>();
- if (CSSValue* radius = ConsumeShapeRadius(args, context.Mode()))
+ if (CSSValue* radius = ConsumeShapeRadius(args, context))
shape->SetRadius(radius);
if (css_property_parser_helpers::ConsumeIdent<CSSValueID::kAt>(args)) {
CSSValue* center_x = nullptr;
@@ -258,8 +262,8 @@ cssvalue::CSSBasicShapeEllipseValue* ConsumeBasicShapeEllipse(
// ellipse( [<shape-radius>{2}]? [at <position>]? )
auto* shape = MakeGarbageCollected<cssvalue::CSSBasicShapeEllipseValue>();
WebFeature feature = WebFeature::kBasicShapeEllipseNoRadius;
- if (CSSValue* radius_x = ConsumeShapeRadius(args, context.Mode())) {
- CSSValue* radius_y = ConsumeShapeRadius(args, context.Mode());
+ if (CSSValue* radius_x = ConsumeShapeRadius(args, context)) {
+ CSSValue* radius_y = ConsumeShapeRadius(args, context);
if (!radius_y) {
return nullptr;
}
@@ -298,13 +302,13 @@ cssvalue::CSSBasicShapePolygonValue* ConsumeBasicShapePolygon(
do {
CSSPrimitiveValue* x_length =
- css_property_parser_helpers::ConsumeLengthOrPercent(
- args, context.Mode(), kValueRangeAll);
+ css_property_parser_helpers::ConsumeLengthOrPercent(args, context,
+ kValueRangeAll);
if (!x_length)
return nullptr;
CSSPrimitiveValue* y_length =
- css_property_parser_helpers::ConsumeLengthOrPercent(
- args, context.Mode(), kValueRangeAll);
+ css_property_parser_helpers::ConsumeLengthOrPercent(args, context,
+ kValueRangeAll);
if (!y_length)
return nullptr;
shape->AppendPoint(x_length, y_length);
@@ -317,20 +321,20 @@ cssvalue::CSSBasicShapeInsetValue* ConsumeBasicShapeInset(
const CSSParserContext& context) {
auto* shape = MakeGarbageCollected<cssvalue::CSSBasicShapeInsetValue>();
CSSPrimitiveValue* top = css_property_parser_helpers::ConsumeLengthOrPercent(
- args, context.Mode(), kValueRangeAll);
+ args, context, kValueRangeAll);
if (!top)
return nullptr;
CSSPrimitiveValue* right =
- css_property_parser_helpers::ConsumeLengthOrPercent(args, context.Mode(),
+ css_property_parser_helpers::ConsumeLengthOrPercent(args, context,
kValueRangeAll);
CSSPrimitiveValue* bottom = nullptr;
CSSPrimitiveValue* left = nullptr;
if (right) {
bottom = css_property_parser_helpers::ConsumeLengthOrPercent(
- args, context.Mode(), kValueRangeAll);
+ args, context, kValueRangeAll);
if (bottom) {
left = css_property_parser_helpers::ConsumeLengthOrPercent(
- args, context.Mode(), kValueRangeAll);
+ args, context, kValueRangeAll);
}
}
if (left)
@@ -345,8 +349,7 @@ cssvalue::CSSBasicShapeInsetValue* ConsumeBasicShapeInset(
if (css_property_parser_helpers::ConsumeIdent<CSSValueID::kRound>(args)) {
CSSValue* horizontal_radii[4] = {nullptr};
CSSValue* vertical_radii[4] = {nullptr};
- if (!ConsumeRadii(horizontal_radii, vertical_radii, args, context.Mode(),
- false))
+ if (!ConsumeRadii(horizontal_radii, vertical_radii, args, context, false))
return nullptr;
shape->SetTopLeftRadius(MakeGarbageCollected<CSSValuePair>(
horizontal_radii[0], vertical_radii[0],
@@ -365,11 +368,12 @@ cssvalue::CSSBasicShapeInsetValue* ConsumeBasicShapeInset(
}
bool ConsumeNumbers(CSSParserTokenRange& args,
+ const CSSParserContext& context,
CSSFunctionValue*& transform_value,
unsigned number_of_arguments) {
do {
- CSSValue* parsed_value =
- css_property_parser_helpers::ConsumeNumber(args, kValueRangeAll);
+ CSSValue* parsed_value = css_property_parser_helpers::ConsumeNumber(
+ args, context, kValueRangeAll);
if (!parsed_value)
return false;
transform_value->Append(*parsed_value);
@@ -386,10 +390,11 @@ bool ConsumePerspective(CSSParserTokenRange& args,
CSSFunctionValue*& transform_value,
bool use_legacy_parsing) {
CSSPrimitiveValue* parsed_value = css_property_parser_helpers::ConsumeLength(
- args, context.Mode(), kValueRangeNonNegative);
+ args, context, kValueRangeNonNegative);
if (!parsed_value && use_legacy_parsing) {
double perspective;
- if (!css_property_parser_helpers::ConsumeNumberRaw(args, perspective) ||
+ if (!css_property_parser_helpers::ConsumeNumberRaw(args, context,
+ perspective) ||
perspective < 0) {
return false;
}
@@ -404,21 +409,21 @@ bool ConsumePerspective(CSSParserTokenRange& args,
}
bool ConsumeTranslate3d(CSSParserTokenRange& args,
- CSSParserMode css_parser_mode,
+ const CSSParserContext& context,
CSSFunctionValue*& transform_value) {
unsigned number_of_arguments = 2;
CSSValue* parsed_value = nullptr;
do {
parsed_value = css_property_parser_helpers::ConsumeLengthOrPercent(
- args, css_parser_mode, kValueRangeAll);
+ args, context, kValueRangeAll);
if (!parsed_value)
return false;
transform_value->Append(*parsed_value);
if (!css_property_parser_helpers::ConsumeCommaIncludingWhitespace(args))
return false;
} while (--number_of_arguments);
- parsed_value = css_property_parser_helpers::ConsumeLength(
- args, css_parser_mode, kValueRangeAll);
+ parsed_value =
+ css_property_parser_helpers::ConsumeLength(args, context, kValueRangeAll);
if (!parsed_value)
return false;
transform_value->Append(*parsed_value);
@@ -453,13 +458,15 @@ bool IsContentPositionOrLeftOrRightKeyword(CSSValueID id) {
return IsContentPositionKeyword(id) || IsLeftOrRightKeyword(id);
}
-CSSValue* ConsumeScrollOffset(CSSParserTokenRange& range) {
+CSSValue* ConsumeScrollOffset(CSSParserTokenRange& range,
+ const CSSParserContext& context) {
range.ConsumeWhitespace();
if (css_property_parser_helpers::IdentMatches<CSSValueID::kAuto>(
range.Peek().Id()))
return css_property_parser_helpers::ConsumeIdent(range);
+ CSSParserContext::ParserModeOverridingScope scope(context, kHTMLStandardMode);
CSSValue* value = css_property_parser_helpers::ConsumeLengthOrPercent(
- range, kHTMLStandardMode, kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
if (!range.AtEnd())
return nullptr;
return value;
@@ -526,10 +533,11 @@ CSSValue* ConsumeContentDistributionOverflowPosition(
return nullptr;
}
-CSSValue* ConsumeAnimationIterationCount(CSSParserTokenRange& range) {
+CSSValue* ConsumeAnimationIterationCount(CSSParserTokenRange& range,
+ const CSSParserContext& context) {
if (range.Peek().Id() == CSSValueID::kInfinite)
return css_property_parser_helpers::ConsumeIdent(range);
- return css_property_parser_helpers::ConsumeNumber(range,
+ return css_property_parser_helpers::ConsumeNumber(range, context,
kValueRangeNonNegative);
}
@@ -553,7 +561,8 @@ CSSValue* ConsumeAnimationName(CSSParserTokenRange& range,
return css_property_parser_helpers::ConsumeCustomIdent(range, context);
}
-CSSValue* ConsumeAnimationTimingFunction(CSSParserTokenRange& range) {
+CSSValue* ConsumeAnimationTimingFunction(CSSParserTokenRange& range,
+ const CSSParserContext& context) {
CSSValueID id = range.Peek().Id();
if (id == CSSValueID::kEase || id == CSSValueID::kLinear ||
id == CSSValueID::kEaseIn || id == CSSValueID::kEaseOut ||
@@ -563,9 +572,9 @@ CSSValue* ConsumeAnimationTimingFunction(CSSParserTokenRange& range) {
CSSValueID function = range.Peek().FunctionId();
if (function == CSSValueID::kSteps)
- return ConsumeSteps(range);
+ return ConsumeSteps(range, context);
if (function == CSSValueID::kCubicBezier)
- return ConsumeCubicBezier(range);
+ return ConsumeCubicBezier(range, context);
return nullptr;
}
@@ -666,7 +675,7 @@ CSSPrimitiveValue* ConsumeLengthOrPercentCountNegative(
const CSSParserContext& context,
base::Optional<WebFeature> negative_size) {
CSSPrimitiveValue* result = ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeNonNegative,
+ range, context, kValueRangeNonNegative,
css_property_parser_helpers::UnitlessQuirk::kForbid);
if (!result && negative_size)
context.Count(*negative_size);
@@ -790,15 +799,15 @@ CSSValue* ConsumeBackgroundComponent(CSSPropertyID resolved_property,
return ConsumeBackgroundBox(range);
case CSSPropertyID::kBackgroundImage:
case CSSPropertyID::kWebkitMaskImage:
- return css_property_parser_helpers::ConsumeImageOrNone(range, &context);
+ return css_property_parser_helpers::ConsumeImageOrNone(range, context);
case CSSPropertyID::kBackgroundPositionX:
case CSSPropertyID::kWebkitMaskPositionX:
return ConsumePositionLonghand<CSSValueID::kLeft, CSSValueID::kRight>(
- range, context.Mode());
+ range, context);
case CSSPropertyID::kBackgroundPositionY:
case CSSPropertyID::kWebkitMaskPositionY:
return ConsumePositionLonghand<CSSValueID::kTop, CSSValueID::kBottom>(
- range, context.Mode());
+ range, context);
case CSSPropertyID::kBackgroundSize:
return ConsumeBackgroundSize(range, context,
WebFeature::kNegativeBackgroundSize,
@@ -808,7 +817,7 @@ CSSValue* ConsumeBackgroundComponent(CSSPropertyID resolved_property,
WebFeature::kNegativeMaskSize,
ParsingStyle::kNotLegacy);
case CSSPropertyID::kBackgroundColor:
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
case CSSPropertyID::kWebkitMaskClip:
return ConsumePrefixedBackgroundBox(range, AllowTextValue::kAllow);
case CSSPropertyID::kWebkitMaskOrigin:
@@ -1019,7 +1028,7 @@ bool ConsumeBorderImageComponents(CSSParserTokenRange& range,
DefaultFill default_fill) {
do {
if (!source) {
- source = css_property_parser_helpers::ConsumeImageOrNone(range, &context);
+ source = css_property_parser_helpers::ConsumeImageOrNone(range, context);
if (source)
continue;
}
@@ -1029,16 +1038,16 @@ bool ConsumeBorderImageComponents(CSSParserTokenRange& range,
continue;
}
if (!slice) {
- slice = ConsumeBorderImageSlice(range, default_fill);
+ slice = ConsumeBorderImageSlice(range, context, default_fill);
if (slice) {
DCHECK(!width);
DCHECK(!outset);
if (css_property_parser_helpers::ConsumeSlashIncludingWhitespace(
range)) {
- width = ConsumeBorderImageWidth(range);
+ width = ConsumeBorderImageWidth(range, context);
if (css_property_parser_helpers::ConsumeSlashIncludingWhitespace(
range)) {
- outset = ConsumeBorderImageOutset(range);
+ outset = ConsumeBorderImageOutset(range, context);
if (!outset)
return false;
} else if (!width) {
@@ -1067,6 +1076,7 @@ CSSValue* ConsumeBorderImageRepeat(CSSParserTokenRange& range) {
}
CSSValue* ConsumeBorderImageSlice(CSSParserTokenRange& range,
+ const CSSParserContext& context,
DefaultFill default_fill) {
bool fill =
css_property_parser_helpers::ConsumeIdent<CSSValueID::kFill>(range);
@@ -1074,10 +1084,10 @@ CSSValue* ConsumeBorderImageSlice(CSSParserTokenRange& range,
for (size_t index = 0; index < 4; ++index) {
CSSPrimitiveValue* value = css_property_parser_helpers::ConsumePercent(
- range, kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
if (!value) {
value = css_property_parser_helpers::ConsumeNumber(
- range, kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
}
if (!value)
break;
@@ -1100,16 +1110,19 @@ CSSValue* ConsumeBorderImageSlice(CSSParserTokenRange& range,
fill);
}
-CSSValue* ConsumeBorderImageWidth(CSSParserTokenRange& range) {
+CSSValue* ConsumeBorderImageWidth(CSSParserTokenRange& range,
+ const CSSParserContext& context) {
CSSValue* widths[4] = {nullptr};
CSSValue* value = nullptr;
for (size_t index = 0; index < 4; ++index) {
- value = css_property_parser_helpers::ConsumeNumber(range,
+ value = css_property_parser_helpers::ConsumeNumber(range, context,
kValueRangeNonNegative);
if (!value) {
+ CSSParserContext::ParserModeOverridingScope scope(context,
+ kHTMLStandardMode);
value = css_property_parser_helpers::ConsumeLengthOrPercent(
- range, kHTMLStandardMode, kValueRangeNonNegative,
+ range, context, kValueRangeNonNegative,
css_property_parser_helpers::UnitlessQuirk::kForbid);
}
if (!value) {
@@ -1128,16 +1141,19 @@ CSSValue* ConsumeBorderImageWidth(CSSParserTokenRange& range) {
CSSQuadValue::kSerializeAsQuad);
}
-CSSValue* ConsumeBorderImageOutset(CSSParserTokenRange& range) {
+CSSValue* ConsumeBorderImageOutset(CSSParserTokenRange& range,
+ const CSSParserContext& context) {
CSSValue* outsets[4] = {nullptr};
CSSValue* value = nullptr;
for (size_t index = 0; index < 4; ++index) {
- value = css_property_parser_helpers::ConsumeNumber(range,
+ value = css_property_parser_helpers::ConsumeNumber(range, context,
kValueRangeNonNegative);
if (!value) {
+ CSSParserContext::ParserModeOverridingScope scope(context,
+ kHTMLStandardMode);
value = css_property_parser_helpers::ConsumeLength(
- range, kHTMLStandardMode, kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
}
if (!value)
break;
@@ -1154,11 +1170,11 @@ CSSValue* ConsumeBorderImageOutset(CSSParserTokenRange& range) {
CSSValue* ParseBorderRadiusCorner(CSSParserTokenRange& range,
const CSSParserContext& context) {
CSSValue* parsed_value1 = css_property_parser_helpers::ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
if (!parsed_value1)
return nullptr;
CSSValue* parsed_value2 = css_property_parser_helpers::ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
if (!parsed_value2)
parsed_value2 = parsed_value1;
return MakeGarbageCollected<CSSValuePair>(parsed_value1, parsed_value2,
@@ -1176,20 +1192,20 @@ CSSValue* ParseBorderWidthSide(CSSParserTokenRange& range,
allow_quirky_lengths
? css_property_parser_helpers::UnitlessQuirk::kAllow
: css_property_parser_helpers::UnitlessQuirk::kForbid;
- return ConsumeBorderWidth(range, context.Mode(), unitless);
+ return ConsumeBorderWidth(range, context, unitless);
}
CSSValue* ConsumeShadow(CSSParserTokenRange& range,
- CSSParserMode css_parser_mode,
+ const CSSParserContext& context,
AllowInsetAndSpread inset_and_spread) {
if (range.Peek().Id() == CSSValueID::kNone)
return css_property_parser_helpers::ConsumeIdent(range);
return css_property_parser_helpers::ConsumeCommaSeparatedList(
- ParseSingleShadow, range, css_parser_mode, inset_and_spread);
+ ParseSingleShadow, range, context, inset_and_spread);
}
CSSShadowValue* ParseSingleShadow(CSSParserTokenRange& range,
- CSSParserMode css_parser_mode,
+ const CSSParserContext& context,
AllowInsetAndSpread inset_and_spread) {
CSSIdentifierValue* style = nullptr;
CSSValue* color = nullptr;
@@ -1197,47 +1213,46 @@ CSSShadowValue* ParseSingleShadow(CSSParserTokenRange& range,
if (range.AtEnd())
return nullptr;
- color = css_property_parser_helpers::ConsumeColor(range, css_parser_mode);
+ color = css_property_parser_helpers::ConsumeColor(range, context);
if (range.Peek().Id() == CSSValueID::kInset) {
if (inset_and_spread != AllowInsetAndSpread::kAllow)
return nullptr;
style = css_property_parser_helpers::ConsumeIdent(range);
if (!color)
- color = css_property_parser_helpers::ConsumeColor(range, css_parser_mode);
+ color = css_property_parser_helpers::ConsumeColor(range, context);
}
CSSPrimitiveValue* horizontal_offset =
- css_property_parser_helpers::ConsumeLength(range, css_parser_mode,
+ css_property_parser_helpers::ConsumeLength(range, context,
kValueRangeAll);
if (!horizontal_offset)
return nullptr;
CSSPrimitiveValue* vertical_offset =
- css_property_parser_helpers::ConsumeLength(range, css_parser_mode,
+ css_property_parser_helpers::ConsumeLength(range, context,
kValueRangeAll);
if (!vertical_offset)
return nullptr;
CSSPrimitiveValue* blur_radius = css_property_parser_helpers::ConsumeLength(
- range, css_parser_mode, kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
CSSPrimitiveValue* spread_distance = nullptr;
if (blur_radius) {
if (inset_and_spread == AllowInsetAndSpread::kAllow) {
spread_distance = css_property_parser_helpers::ConsumeLength(
- range, css_parser_mode, kValueRangeAll);
+ range, context, kValueRangeAll);
}
}
if (!range.AtEnd()) {
if (!color)
- color = css_property_parser_helpers::ConsumeColor(range, css_parser_mode);
+ color = css_property_parser_helpers::ConsumeColor(range, context);
if (range.Peek().Id() == CSSValueID::kInset) {
if (inset_and_spread != AllowInsetAndSpread::kAllow || style)
return nullptr;
style = css_property_parser_helpers::ConsumeIdent(range);
if (!color) {
- color =
- css_property_parser_helpers::ConsumeColor(range, css_parser_mode);
+ color = css_property_parser_helpers::ConsumeColor(range, context);
}
}
}
@@ -1246,25 +1261,29 @@ CSSShadowValue* ParseSingleShadow(CSSParserTokenRange& range,
spread_distance, style, color);
}
-CSSValue* ConsumeColumnCount(CSSParserTokenRange& range) {
+CSSValue* ConsumeColumnCount(CSSParserTokenRange& range,
+ const CSSParserContext& context) {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_property_parser_helpers::ConsumeIdent(range);
- return css_property_parser_helpers::ConsumePositiveInteger(range);
+ return css_property_parser_helpers::ConsumePositiveInteger(range, context);
}
-CSSValue* ConsumeColumnWidth(CSSParserTokenRange& range) {
+CSSValue* ConsumeColumnWidth(CSSParserTokenRange& range,
+ const CSSParserContext& context) {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_property_parser_helpers::ConsumeIdent(range);
// Always parse lengths in strict mode here, since it would be ambiguous
// otherwise when used in the 'columns' shorthand property.
+ CSSParserContext::ParserModeOverridingScope scope(context, kHTMLStandardMode);
CSSPrimitiveValue* column_width = css_property_parser_helpers::ConsumeLength(
- range, kHTMLStandardMode, kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
if (!column_width)
return nullptr;
return column_width;
}
bool ConsumeColumnWidthOrCount(CSSParserTokenRange& range,
+ const CSSParserContext& context,
CSSValue*& column_width,
CSSValue*& column_count) {
if (range.Peek().Id() == CSSValueID::kAuto) {
@@ -1272,12 +1291,12 @@ bool ConsumeColumnWidthOrCount(CSSParserTokenRange& range,
return true;
}
if (!column_width) {
- column_width = ConsumeColumnWidth(range);
+ column_width = ConsumeColumnWidth(range, context);
if (column_width)
return true;
}
if (!column_count)
- column_count = ConsumeColumnCount(range);
+ column_count = ConsumeColumnCount(range, context);
return column_count;
}
@@ -1286,7 +1305,7 @@ CSSValue* ConsumeGapLength(CSSParserTokenRange& range,
if (range.Peek().Id() == CSSValueID::kNormal)
return css_property_parser_helpers::ConsumeIdent(range);
return css_property_parser_helpers::ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
}
CSSValue* ConsumeCounter(CSSParserTokenRange& range,
@@ -1303,7 +1322,7 @@ CSSValue* ConsumeCounter(CSSParserTokenRange& range,
return nullptr;
int value = default_value;
if (CSSPrimitiveValue* counter_value =
- css_property_parser_helpers::ConsumeInteger(range))
+ css_property_parser_helpers::ConsumeInteger(range, context))
value = clampTo<int>(counter_value->GetDoubleValue());
list->Append(*MakeGarbageCollected<CSSValuePair>(
counter_name,
@@ -1323,20 +1342,20 @@ CSSValue* ConsumeFontSize(CSSParserTokenRange& range,
range.Peek().Id() <= CSSValueID::kWebkitXxxLarge)
return css_property_parser_helpers::ConsumeIdent(range);
return css_property_parser_helpers::ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeNonNegative, unitless);
+ range, context, kValueRangeNonNegative, unitless);
}
CSSValue* ConsumeLineHeight(CSSParserTokenRange& range,
- CSSParserMode css_parser_mode) {
+ const CSSParserContext& context) {
if (range.Peek().Id() == CSSValueID::kNormal)
return css_property_parser_helpers::ConsumeIdent(range);
- CSSPrimitiveValue* line_height =
- css_property_parser_helpers::ConsumeNumber(range, kValueRangeNonNegative);
+ CSSPrimitiveValue* line_height = css_property_parser_helpers::ConsumeNumber(
+ range, context, kValueRangeNonNegative);
if (line_height)
return line_height;
return css_property_parser_helpers::ConsumeLengthOrPercent(
- range, css_parser_mode, kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
}
CSSValueList* ConsumeFontFamily(CSSParserTokenRange& range) {
@@ -1394,12 +1413,13 @@ String ConcatenateFamilyName(CSSParserTokenRange& range) {
return builder.ToString();
}
-CSSValueList* CombineToRangeListOrNull(const CSSPrimitiveValue* range_start,
- const CSSPrimitiveValue* range_end) {
+CSSValueList* CombineToRangeList(const CSSPrimitiveValue* range_start,
+ const CSSPrimitiveValue* range_end) {
DCHECK(range_start);
DCHECK(range_end);
- if (range_end->GetFloatValue() < range_start->GetFloatValue())
- return nullptr;
+ // Reversed ranges are valid, let them pass through here and swap them in
+ // FontFace to keep serialisation of the value as specified.
+ // https://drafts.csswg.org/css-fonts/#font-prop-desc
CSSValueList* value_list = CSSValueList::CreateSpaceSeparated();
value_list->Append(*range_start);
value_list->Append(*range_end);
@@ -1413,7 +1433,7 @@ bool IsAngleWithinLimits(CSSPrimitiveValue* angle) {
}
CSSValue* ConsumeFontStyle(CSSParserTokenRange& range,
- const CSSParserMode& parser_mode) {
+ const CSSParserContext& context) {
if (range.Peek().Id() == CSSValueID::kNormal ||
range.Peek().Id() == CSSValueID::kItalic)
return css_property_parser_helpers::ConsumeIdent(range);
@@ -1425,13 +1445,13 @@ CSSValue* ConsumeFontStyle(CSSParserTokenRange& range,
css_property_parser_helpers::ConsumeIdent<CSSValueID::kOblique>(range);
CSSPrimitiveValue* start_angle = css_property_parser_helpers::ConsumeAngle(
- range, nullptr, base::nullopt, MinObliqueValue(), MaxObliqueValue());
+ range, context, base::nullopt, MinObliqueValue(), MaxObliqueValue());
if (!start_angle)
return oblique_identifier;
if (!IsAngleWithinLimits(start_angle))
return nullptr;
- if (parser_mode != kCSSFontFaceRuleMode || range.AtEnd()) {
+ if (context.Mode() != kCSSFontFaceRuleMode || range.AtEnd()) {
CSSValueList* value_list = CSSValueList::CreateSpaceSeparated();
value_list->Append(*start_angle);
return MakeGarbageCollected<cssvalue::CSSFontStyleRangeValue>(
@@ -1439,11 +1459,11 @@ CSSValue* ConsumeFontStyle(CSSParserTokenRange& range,
}
CSSPrimitiveValue* end_angle = css_property_parser_helpers::ConsumeAngle(
- range, nullptr, base::nullopt, MinObliqueValue(), MaxObliqueValue());
+ range, context, base::nullopt, MinObliqueValue(), MaxObliqueValue());
if (!end_angle || !IsAngleWithinLimits(end_angle))
return nullptr;
- CSSValueList* range_list = CombineToRangeListOrNull(start_angle, end_angle);
+ CSSValueList* range_list = CombineToRangeList(start_angle, end_angle);
if (!range_list)
return nullptr;
return MakeGarbageCollected<cssvalue::CSSFontStyleRangeValue>(
@@ -1460,31 +1480,31 @@ CSSIdentifierValue* ConsumeFontStretchKeywordOnly(CSSParserTokenRange& range) {
}
CSSValue* ConsumeFontStretch(CSSParserTokenRange& range,
- const CSSParserMode& parser_mode) {
+ const CSSParserContext& context) {
CSSIdentifierValue* parsed_keyword = ConsumeFontStretchKeywordOnly(range);
if (parsed_keyword)
return parsed_keyword;
CSSPrimitiveValue* start_percent =
- css_property_parser_helpers::ConsumePercent(range,
+ css_property_parser_helpers::ConsumePercent(range, context,
kValueRangeNonNegative);
if (!start_percent)
return nullptr;
// In a non-font-face context, more than one percentage is not allowed.
- if (parser_mode != kCSSFontFaceRuleMode || range.AtEnd())
+ if (context.Mode() != kCSSFontFaceRuleMode || range.AtEnd())
return start_percent;
CSSPrimitiveValue* end_percent = css_property_parser_helpers::ConsumePercent(
- range, kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
if (!end_percent)
return nullptr;
- return CombineToRangeListOrNull(start_percent, end_percent);
+ return CombineToRangeList(start_percent, end_percent);
}
CSSValue* ConsumeFontWeight(CSSParserTokenRange& range,
- const CSSParserMode& parser_mode) {
+ const CSSParserContext& context) {
const CSSParserToken& token = range.Peek();
if (token.Id() >= CSSValueID::kNormal && token.Id() <= CSSValueID::kLighter)
return css_property_parser_helpers::ConsumeIdent(range);
@@ -1500,8 +1520,8 @@ CSSValue* ConsumeFontWeight(CSSParserTokenRange& range,
(token.NumericValue() < 1 || token.NumericValue() > 1000))
return nullptr;
- CSSPrimitiveValue* start_weight =
- css_property_parser_helpers::ConsumeNumber(range, kValueRangeNonNegative);
+ CSSPrimitiveValue* start_weight = css_property_parser_helpers::ConsumeNumber(
+ range, context, kValueRangeNonNegative);
if (!start_weight || start_weight->GetFloatValue() < 1 ||
start_weight->GetFloatValue() > 1000)
return nullptr;
@@ -1509,24 +1529,26 @@ CSSValue* ConsumeFontWeight(CSSParserTokenRange& range,
// In a non-font-face context, more than one number is not allowed. Return
// what we have. If there is trailing garbage, the AtEnd() check in
// CSSPropertyParser::ParseValueStart will catch that.
- if (parser_mode != kCSSFontFaceRuleMode || range.AtEnd())
+ if (context.Mode() != kCSSFontFaceRuleMode || range.AtEnd())
return start_weight;
- CSSPrimitiveValue* end_weight =
- css_property_parser_helpers::ConsumeNumber(range, kValueRangeNonNegative);
+ CSSPrimitiveValue* end_weight = css_property_parser_helpers::ConsumeNumber(
+ range, context, kValueRangeNonNegative);
if (!end_weight || end_weight->GetFloatValue() < 1 ||
end_weight->GetFloatValue() > 1000)
return nullptr;
- return CombineToRangeListOrNull(start_weight, end_weight);
+ return CombineToRangeList(start_weight, end_weight);
}
-CSSValue* ConsumeFontFeatureSettings(CSSParserTokenRange& range) {
+CSSValue* ConsumeFontFeatureSettings(CSSParserTokenRange& range,
+ const CSSParserContext& context) {
if (range.Peek().Id() == CSSValueID::kNormal)
return css_property_parser_helpers::ConsumeIdent(range);
CSSValueList* settings = CSSValueList::CreateCommaSeparated();
do {
- CSSFontFeatureValue* font_feature_value = ConsumeFontFeatureTag(range);
+ CSSFontFeatureValue* font_feature_value =
+ ConsumeFontFeatureTag(range, context);
if (!font_feature_value)
return nullptr;
settings->Append(*font_feature_value);
@@ -1534,7 +1556,8 @@ CSSValue* ConsumeFontFeatureSettings(CSSParserTokenRange& range) {
return settings;
}
-CSSFontFeatureValue* ConsumeFontFeatureTag(CSSParserTokenRange& range) {
+CSSFontFeatureValue* ConsumeFontFeatureTag(CSSParserTokenRange& range,
+ const CSSParserContext& context) {
// Feature tag name consists of 4-letter characters.
const unsigned kTagNameLength = 4;
@@ -1556,7 +1579,7 @@ CSSFontFeatureValue* ConsumeFontFeatureTag(CSSParserTokenRange& range) {
int tag_value = 1;
// Feature tag values could follow: <integer> | on | off
if (CSSPrimitiveValue* value =
- css_property_parser_helpers::ConsumeInteger(range, 0)) {
+ css_property_parser_helpers::ConsumeInteger(range, context, 0)) {
tag_value = clampTo<int>(value->GetDoubleValue());
} else if (range.Peek().Id() == CSSValueID::kOn ||
range.Peek().Id() == CSSValueID::kOff) {
@@ -1613,7 +1636,7 @@ Vector<String> ParseGridTemplateAreasColumnNames(const String& grid_row_names) {
}
CSSValue* ConsumeGridBreadth(CSSParserTokenRange& range,
- CSSParserMode css_parser_mode) {
+ const CSSParserContext& context) {
const CSSParserToken& token = range.Peek();
if (css_property_parser_helpers::IdentMatches<
CSSValueID::kMinContent, CSSValueID::kMaxContent, CSSValueID::kAuto>(
@@ -1628,18 +1651,18 @@ CSSValue* ConsumeGridBreadth(CSSParserTokenRange& range,
CSSPrimitiveValue::UnitType::kFraction);
}
return css_property_parser_helpers::ConsumeLengthOrPercent(
- range, css_parser_mode, kValueRangeNonNegative,
+ range, context, kValueRangeNonNegative,
css_property_parser_helpers::UnitlessQuirk::kForbid);
}
CSSValue* ConsumeFitContent(CSSParserTokenRange& range,
- CSSParserMode css_parser_mode) {
+ const CSSParserContext& context) {
CSSParserTokenRange range_copy = range;
CSSParserTokenRange args =
css_property_parser_helpers::ConsumeFunction(range_copy);
CSSPrimitiveValue* length =
css_property_parser_helpers::ConsumeLengthOrPercent(
- args, css_parser_mode, kValueRangeNonNegative,
+ args, context, kValueRangeNonNegative,
css_property_parser_helpers::UnitlessQuirk::kAllow);
if (!length || !args.AtEnd())
return nullptr;
@@ -1680,7 +1703,7 @@ bool IsGridTrackFixedSized(const CSSValue& value) {
}
CSSValue* ConsumeGridTrackSize(CSSParserTokenRange& range,
- CSSParserMode css_parser_mode) {
+ const CSSParserContext& context) {
const CSSParserToken& token = range.Peek();
if (css_property_parser_helpers::IdentMatches<CSSValueID::kAuto>(token.Id()))
return css_property_parser_helpers::ConsumeIdent(range);
@@ -1689,7 +1712,7 @@ CSSValue* ConsumeGridTrackSize(CSSParserTokenRange& range,
CSSParserTokenRange range_copy = range;
CSSParserTokenRange args =
css_property_parser_helpers::ConsumeFunction(range_copy);
- CSSValue* min_track_breadth = ConsumeGridBreadth(args, css_parser_mode);
+ CSSValue* min_track_breadth = ConsumeGridBreadth(args, context);
auto* min_track_breadth_primitive_value =
DynamicTo<CSSPrimitiveValue>(min_track_breadth);
if (!min_track_breadth ||
@@ -1697,7 +1720,7 @@ CSSValue* ConsumeGridTrackSize(CSSParserTokenRange& range,
min_track_breadth_primitive_value->IsFlex()) ||
!css_property_parser_helpers::ConsumeCommaIncludingWhitespace(args))
return nullptr;
- CSSValue* max_track_breadth = ConsumeGridBreadth(args, css_parser_mode);
+ CSSValue* max_track_breadth = ConsumeGridBreadth(args, context);
if (!max_track_breadth || !args.AtEnd())
return nullptr;
range = range_copy;
@@ -1708,9 +1731,9 @@ CSSValue* ConsumeGridTrackSize(CSSParserTokenRange& range,
}
if (token.FunctionId() == CSSValueID::kFitContent)
- return ConsumeFitContent(range, css_parser_mode);
+ return ConsumeFitContent(range, context);
- return ConsumeGridBreadth(range, css_parser_mode);
+ return ConsumeGridBreadth(range, context);
}
CSSCustomIdentValue* ConsumeCustomIdentForGridLine(
@@ -1747,7 +1770,6 @@ CSSGridLineNamesValue* ConsumeGridLineNames(
bool ConsumeGridTrackRepeatFunction(CSSParserTokenRange& range,
const CSSParserContext& context,
- CSSParserMode css_parser_mode,
CSSValueList& list,
bool& is_auto_repeat,
bool& all_tracks_are_fixed_sized) {
@@ -1765,7 +1787,7 @@ bool ConsumeGridTrackRepeatFunction(CSSParserTokenRange& range,
} else {
// TODO(rob.buis): a consumeIntegerRaw would be more efficient here.
CSSPrimitiveValue* repetition =
- css_property_parser_helpers::ConsumePositiveInteger(args);
+ css_property_parser_helpers::ConsumePositiveInteger(args, context);
if (!repetition)
return false;
repetitions =
@@ -1780,7 +1802,7 @@ bool ConsumeGridTrackRepeatFunction(CSSParserTokenRange& range,
size_t number_of_tracks = 0;
while (!args.AtEnd()) {
- CSSValue* track_size = ConsumeGridTrackSize(args, css_parser_mode);
+ CSSValue* track_size = ConsumeGridTrackSize(args, context);
if (!track_size)
return false;
if (all_tracks_are_fixed_sized)
@@ -1847,7 +1869,7 @@ bool ConsumeGridTemplateRowsAndAreasAndColumns(bool important,
++row_count;
// Handle template-rows's track-size.
- CSSValue* value = ConsumeGridTrackSize(range, context.Mode());
+ CSSValue* value = ConsumeGridTrackSize(range, context);
if (!value)
value = CSSIdentifierValue::Create(CSSValueID::kAuto);
template_rows_value_list->Append(*value);
@@ -1863,7 +1885,7 @@ bool ConsumeGridTemplateRowsAndAreasAndColumns(bool important,
if (!css_property_parser_helpers::ConsumeSlashIncludingWhitespace(range))
return false;
template_columns = ConsumeGridTrackList(
- range, context, context.Mode(), TrackListType::kGridTemplateNoRepeat);
+ range, context, TrackListType::kGridTemplateNoRepeat);
if (!template_columns || !range.AtEnd())
return false;
} else {
@@ -1884,7 +1906,7 @@ CSSValue* ConsumeGridLine(CSSParserTokenRange& range,
CSSIdentifierValue* span_value = nullptr;
CSSCustomIdentValue* grid_line_name = nullptr;
CSSPrimitiveValue* numeric_value =
- css_property_parser_helpers::ConsumeInteger(range);
+ css_property_parser_helpers::ConsumeInteger(range, context);
if (numeric_value) {
grid_line_name = ConsumeCustomIdentForGridLine(range, context);
span_value =
@@ -1893,14 +1915,18 @@ CSSValue* ConsumeGridLine(CSSParserTokenRange& range,
span_value =
css_property_parser_helpers::ConsumeIdent<CSSValueID::kSpan>(range);
if (span_value) {
- numeric_value = css_property_parser_helpers::ConsumeInteger(range);
+ numeric_value =
+ css_property_parser_helpers::ConsumeInteger(range, context);
grid_line_name = ConsumeCustomIdentForGridLine(range, context);
- if (!numeric_value)
- numeric_value = css_property_parser_helpers::ConsumeInteger(range);
+ if (!numeric_value) {
+ numeric_value =
+ css_property_parser_helpers::ConsumeInteger(range, context);
+ }
} else {
grid_line_name = ConsumeCustomIdentForGridLine(range, context);
if (grid_line_name) {
- numeric_value = css_property_parser_helpers::ConsumeInteger(range);
+ numeric_value =
+ css_property_parser_helpers::ConsumeInteger(range, context);
span_value =
css_property_parser_helpers::ConsumeIdent<CSSValueID::kSpan>(range);
if (!span_value && !numeric_value)
@@ -1938,7 +1964,6 @@ CSSValue* ConsumeGridLine(CSSParserTokenRange& range,
CSSValue* ConsumeGridTrackList(CSSParserTokenRange& range,
const CSSParserContext& context,
- CSSParserMode css_parser_mode,
TrackListType track_list_type) {
bool allow_grid_line_names = track_list_type != TrackListType::kGridAuto;
CSSValueList* values = CSSValueList::CreateSpaceSeparated();
@@ -1956,14 +1981,14 @@ CSSValue* ConsumeGridTrackList(CSSParserTokenRange& range,
if (range.Peek().FunctionId() == CSSValueID::kRepeat) {
if (!allow_repeat)
return nullptr;
- if (!ConsumeGridTrackRepeatFunction(range, context, css_parser_mode,
- *values, is_auto_repeat,
+ if (!ConsumeGridTrackRepeatFunction(range, context, *values,
+ is_auto_repeat,
all_tracks_are_fixed_sized))
return nullptr;
if (is_auto_repeat && seen_auto_repeat)
return nullptr;
seen_auto_repeat = seen_auto_repeat || is_auto_repeat;
- } else if (CSSValue* value = ConsumeGridTrackSize(range, css_parser_mode)) {
+ } else if (CSSValue* value = ConsumeGridTrackSize(range, context)) {
if (all_tracks_are_fixed_sized)
all_tracks_are_fixed_sized = IsGridTrackFixedSized(*value);
values->Append(*value);
@@ -2050,12 +2075,10 @@ bool ParseGridTemplateAreasRow(const String& grid_row_names,
}
CSSValue* ConsumeGridTemplatesRowsOrColumns(CSSParserTokenRange& range,
- const CSSParserContext& context,
- CSSParserMode css_parser_mode) {
+ const CSSParserContext& context) {
if (range.Peek().Id() == CSSValueID::kNone)
return css_property_parser_helpers::ConsumeIdent(range);
- return ConsumeGridTrackList(range, context, css_parser_mode,
- TrackListType::kGridTemplate);
+ return ConsumeGridTrackList(range, context, TrackListType::kGridTemplate);
}
bool ConsumeGridItemPositionShorthand(bool important,
@@ -2110,15 +2133,14 @@ bool ConsumeGridTemplateShorthand(bool important,
// 2- <grid-template-rows> / <grid-template-columns>
if (!template_rows) {
- template_rows = ConsumeGridTrackList(range, context, context.Mode(),
- TrackListType::kGridTemplate);
+ template_rows =
+ ConsumeGridTrackList(range, context, TrackListType::kGridTemplate);
}
if (template_rows) {
if (!css_property_parser_helpers::ConsumeSlashIncludingWhitespace(range))
return false;
- template_columns =
- ConsumeGridTemplatesRowsOrColumns(range, context, context.Mode());
+ template_columns = ConsumeGridTemplatesRowsOrColumns(range, context);
if (!template_columns || !range.AtEnd())
return false;
@@ -2235,7 +2257,7 @@ CSSValue* ConsumeRay(CSSParserTokenRange& range,
while (!function_args.AtEnd()) {
if (!angle) {
angle = css_property_parser_helpers::ConsumeAngle(
- function_args, &context, base::Optional<WebFeature>());
+ function_args, context, base::Optional<WebFeature>());
if (angle)
continue;
}
@@ -2269,7 +2291,7 @@ CSSValue* ConsumeMaxWidthOrHeight(
ValidWidthOrHeightKeyword(range.Peek().Id(), context))
return css_property_parser_helpers::ConsumeIdent(range);
return css_property_parser_helpers::ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeNonNegative, unitless);
+ range, context, kValueRangeNonNegative, unitless);
}
CSSValue* ConsumeWidthOrHeight(
@@ -2280,24 +2302,26 @@ CSSValue* ConsumeWidthOrHeight(
ValidWidthOrHeightKeyword(range.Peek().Id(), context))
return css_property_parser_helpers::ConsumeIdent(range);
return css_property_parser_helpers::ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeNonNegative, unitless);
+ range, context, kValueRangeNonNegative, unitless);
}
CSSValue* ConsumeMarginOrOffset(
CSSParserTokenRange& range,
- CSSParserMode css_parser_mode,
+ const CSSParserContext& context,
css_property_parser_helpers::UnitlessQuirk unitless) {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_property_parser_helpers::ConsumeIdent(range);
return css_property_parser_helpers::ConsumeLengthOrPercent(
- range, css_parser_mode, kValueRangeAll, unitless);
+ range, context, kValueRangeAll, unitless);
}
-CSSValue* ConsumeScrollPadding(CSSParserTokenRange& range) {
+CSSValue* ConsumeScrollPadding(CSSParserTokenRange& range,
+ const CSSParserContext& context) {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_property_parser_helpers::ConsumeIdent(range);
+ CSSParserContext::ParserModeOverridingScope scope(context, kHTMLStandardMode);
return css_property_parser_helpers::ConsumeLengthOrPercent(
- range, kHTMLStandardMode, kValueRangeNonNegative,
+ range, context, kValueRangeNonNegative,
css_property_parser_helpers::UnitlessQuirk::kForbid);
}
@@ -2327,7 +2351,7 @@ CSSValue* ConsumePathOrNone(CSSParserTokenRange& range) {
CSSValue* ConsumeOffsetRotate(CSSParserTokenRange& range,
const CSSParserContext& context) {
CSSValue* angle = css_property_parser_helpers::ConsumeAngle(
- range, &context, base::Optional<WebFeature>());
+ range, context, base::Optional<WebFeature>());
CSSValue* keyword =
css_property_parser_helpers::ConsumeIdent<CSSValueID::kAuto,
CSSValueID::kReverse>(range);
@@ -2336,7 +2360,7 @@ CSSValue* ConsumeOffsetRotate(CSSParserTokenRange& range,
if (!angle) {
angle = css_property_parser_helpers::ConsumeAngle(
- range, &context, base::Optional<WebFeature>());
+ range, context, base::Optional<WebFeature>());
}
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
@@ -2350,7 +2374,7 @@ CSSValue* ConsumeOffsetRotate(CSSParserTokenRange& range,
bool ConsumeRadii(CSSValue* horizontal_radii[4],
CSSValue* vertical_radii[4],
CSSParserTokenRange& range,
- CSSParserMode css_parser_mode,
+ const CSSParserContext& context,
bool use_legacy_parsing) {
unsigned horizontal_value_count = 0;
for (; horizontal_value_count < 4 && !range.AtEnd() &&
@@ -2358,7 +2382,7 @@ bool ConsumeRadii(CSSValue* horizontal_radii[4],
++horizontal_value_count) {
horizontal_radii[horizontal_value_count] =
css_property_parser_helpers::ConsumeLengthOrPercent(
- range, css_parser_mode, kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
if (!horizontal_radii[horizontal_value_count])
return false;
}
@@ -2381,7 +2405,7 @@ bool ConsumeRadii(CSSValue* horizontal_radii[4],
return false;
for (unsigned i = 0; i < 4 && !range.AtEnd(); ++i) {
vertical_radii[i] = css_property_parser_helpers::ConsumeLengthOrPercent(
- range, css_parser_mode, kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
if (!vertical_radii[i])
return false;
}
@@ -2479,14 +2503,14 @@ CSSValue* ConsumeTransformValue(CSSParserTokenRange& range,
case CSSValueID::kSkewY:
case CSSValueID::kSkew:
parsed_value = css_property_parser_helpers::ConsumeAngle(
- args, &context, WebFeature::kUnitlessZeroAngleTransform);
+ args, context, WebFeature::kUnitlessZeroAngleTransform);
if (!parsed_value)
return nullptr;
if (function_id == CSSValueID::kSkew &&
css_property_parser_helpers::ConsumeCommaIncludingWhitespace(args)) {
transform_value->Append(*parsed_value);
parsed_value = css_property_parser_helpers::ConsumeAngle(
- args, &context, WebFeature::kUnitlessZeroAngleTransform);
+ args, context, WebFeature::kUnitlessZeroAngleTransform);
if (!parsed_value)
return nullptr;
}
@@ -2495,15 +2519,15 @@ CSSValue* ConsumeTransformValue(CSSParserTokenRange& range,
case CSSValueID::kScaleY:
case CSSValueID::kScaleZ:
case CSSValueID::kScale:
- parsed_value =
- css_property_parser_helpers::ConsumeNumber(args, kValueRangeAll);
+ parsed_value = css_property_parser_helpers::ConsumeNumber(args, context,
+ kValueRangeAll);
if (!parsed_value)
return nullptr;
if (function_id == CSSValueID::kScale &&
css_property_parser_helpers::ConsumeCommaIncludingWhitespace(args)) {
transform_value->Append(*parsed_value);
- parsed_value =
- css_property_parser_helpers::ConsumeNumber(args, kValueRangeAll);
+ parsed_value = css_property_parser_helpers::ConsumeNumber(
+ args, context, kValueRangeAll);
if (!parsed_value)
return nullptr;
}
@@ -2518,45 +2542,45 @@ CSSValue* ConsumeTransformValue(CSSParserTokenRange& range,
case CSSValueID::kTranslateY:
case CSSValueID::kTranslate:
parsed_value = css_property_parser_helpers::ConsumeLengthOrPercent(
- args, context.Mode(), kValueRangeAll);
+ args, context, kValueRangeAll);
if (!parsed_value)
return nullptr;
if (function_id == CSSValueID::kTranslate &&
css_property_parser_helpers::ConsumeCommaIncludingWhitespace(args)) {
transform_value->Append(*parsed_value);
parsed_value = css_property_parser_helpers::ConsumeLengthOrPercent(
- args, context.Mode(), kValueRangeAll);
+ args, context, kValueRangeAll);
if (!parsed_value)
return nullptr;
}
break;
case CSSValueID::kTranslateZ:
- parsed_value = css_property_parser_helpers::ConsumeLength(
- args, context.Mode(), kValueRangeAll);
+ parsed_value = css_property_parser_helpers::ConsumeLength(args, context,
+ kValueRangeAll);
break;
case CSSValueID::kMatrix:
case CSSValueID::kMatrix3d:
- if (!ConsumeNumbers(args, transform_value,
+ if (!ConsumeNumbers(args, context, transform_value,
(function_id == CSSValueID::kMatrix3d) ? 16 : 6)) {
return nullptr;
}
break;
case CSSValueID::kScale3d:
- if (!ConsumeNumbers(args, transform_value, 3))
+ if (!ConsumeNumbers(args, context, transform_value, 3))
return nullptr;
break;
case CSSValueID::kRotate3d:
- if (!ConsumeNumbers(args, transform_value, 3) ||
+ if (!ConsumeNumbers(args, context, transform_value, 3) ||
!css_property_parser_helpers::ConsumeCommaIncludingWhitespace(args)) {
return nullptr;
}
parsed_value = css_property_parser_helpers::ConsumeAngle(
- args, &context, WebFeature::kUnitlessZeroAngleTransform);
+ args, context, WebFeature::kUnitlessZeroAngleTransform);
if (!parsed_value)
return nullptr;
break;
case CSSValueID::kTranslate3d:
- if (!ConsumeTranslate3d(args, context.Mode(), transform_value))
+ if (!ConsumeTranslate3d(args, context, transform_value))
return nullptr;
break;
default:
@@ -2594,12 +2618,14 @@ CSSValue* ConsumeTransitionProperty(CSSParserTokenRange& range,
return nullptr;
if (token.Id() == CSSValueID::kNone)
return css_property_parser_helpers::ConsumeIdent(range);
- CSSPropertyID unresolved_property = token.ParseAsUnresolvedCSSPropertyID();
+ const auto* execution_context = context.GetExecutionContext();
+ CSSPropertyID unresolved_property =
+ token.ParseAsUnresolvedCSSPropertyID(execution_context);
if (unresolved_property != CSSPropertyID::kInvalid &&
unresolved_property != CSSPropertyID::kVariable) {
#if DCHECK_IS_ON()
DCHECK(CSSProperty::Get(resolveCSSPropertyID(unresolved_property))
- .IsWebExposed());
+ .IsWebExposed(execution_context));
#endif
range.ConsumeIncludingWhitespace();
return MakeGarbageCollected<CSSCustomIdentValue>(unresolved_property);
@@ -2625,15 +2651,15 @@ CSSValue* ConsumeBorderColorSide(CSSParserTokenRange& range,
bool allow_quirky_colors = IsQuirksModeBehavior(context.Mode()) &&
(shorthand == CSSPropertyID::kInvalid ||
shorthand == CSSPropertyID::kBorderColor);
- return css_property_parser_helpers::ConsumeColor(range, context.Mode(),
+ return css_property_parser_helpers::ConsumeColor(range, context,
allow_quirky_colors);
}
CSSValue* ConsumeBorderWidth(
CSSParserTokenRange& range,
- CSSParserMode css_parser_mode,
+ const CSSParserContext& context,
css_property_parser_helpers::UnitlessQuirk unitless) {
- return css_property_parser_helpers::ConsumeLineWidth(range, css_parser_mode,
+ return css_property_parser_helpers::ConsumeLineWidth(range, context,
unitless);
}
@@ -2643,7 +2669,7 @@ CSSValue* ParseSpacing(CSSParserTokenRange& range,
return css_property_parser_helpers::ConsumeIdent(range);
// TODO(timloh): allow <percentage>s in word-spacing.
return css_property_parser_helpers::ConsumeLength(
- range, context.Mode(), kValueRangeAll,
+ range, context, kValueRangeAll,
css_property_parser_helpers::UnitlessQuirk::kAllow);
}
@@ -2652,14 +2678,13 @@ CSSValue* ParsePaintStroke(CSSParserTokenRange& range,
if (range.Peek().Id() == CSSValueID::kNone)
return css_property_parser_helpers::ConsumeIdent(range);
cssvalue::CSSURIValue* url =
- css_property_parser_helpers::ConsumeUrl(range, &context);
+ css_property_parser_helpers::ConsumeUrl(range, context);
if (url) {
CSSValue* parsed_value = nullptr;
if (range.Peek().Id() == CSSValueID::kNone) {
parsed_value = css_property_parser_helpers::ConsumeIdent(range);
} else {
- parsed_value =
- css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ parsed_value = css_property_parser_helpers::ConsumeColor(range, context);
}
if (parsed_value) {
CSSValueList* values = CSSValueList::CreateSpaceSeparated();
@@ -2669,7 +2694,7 @@ CSSValue* ParsePaintStroke(CSSParserTokenRange& range,
}
return url;
}
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
css_property_parser_helpers::UnitlessQuirk UnitlessUnlessShorthand(
@@ -2679,16 +2704,5 @@ css_property_parser_helpers::UnitlessQuirk UnitlessUnlessShorthand(
: css_property_parser_helpers::UnitlessQuirk::kForbid;
}
-CSSValue* ConsumeIntrinsicLength(CSSParserTokenRange& range,
- const CSSParserContext& context) {
- if (css_property_parser_helpers::IdentMatches<CSSValueID::kLegacy,
- CSSValueID::kAuto>(
- range.Peek().Id())) {
- return css_property_parser_helpers::ConsumeIdent(range);
- }
- return css_property_parser_helpers::ConsumeLength(range, context.Mode(),
- kValueRangeNonNegative);
-}
-
} // namespace css_parsing_utils
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/properties/css_parsing_utils.h b/chromium/third_party/blink/renderer/core/css/properties/css_parsing_utils.h
index f95d8e87a3c..1ffeb8471f0 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/css_parsing_utils.h
+++ b/chromium/third_party/blink/renderer/core/css/properties/css_parsing_utils.h
@@ -47,7 +47,7 @@ bool IsSelfPositionOrLeftOrRightKeyword(CSSValueID);
bool IsContentPositionKeyword(CSSValueID);
bool IsContentPositionOrLeftOrRightKeyword(CSSValueID);
-CSSValue* ConsumeScrollOffset(CSSParserTokenRange&);
+CSSValue* ConsumeScrollOffset(CSSParserTokenRange&, const CSSParserContext&);
CSSValue* ConsumeSelfPositionOverflowPosition(CSSParserTokenRange&,
IsPositionKeyword);
CSSValue* ConsumeSimplifiedDefaultPosition(CSSParserTokenRange&,
@@ -59,11 +59,13 @@ CSSValue* ConsumeContentDistributionOverflowPosition(CSSParserTokenRange&,
CSSValue* ConsumeSimplifiedContentPosition(CSSParserTokenRange&,
IsPositionKeyword);
-CSSValue* ConsumeAnimationIterationCount(CSSParserTokenRange&);
+CSSValue* ConsumeAnimationIterationCount(CSSParserTokenRange&,
+ const CSSParserContext&);
CSSValue* ConsumeAnimationName(CSSParserTokenRange&,
const CSSParserContext&,
bool allow_quoted_name);
-CSSValue* ConsumeAnimationTimingFunction(CSSParserTokenRange&);
+CSSValue* ConsumeAnimationTimingFunction(CSSParserTokenRange&,
+ const CSSParserContext&);
bool ConsumeAnimationShorthand(
const StylePropertyShorthand&,
HeapVector<Member<CSSValueList>, kMaxNumAnimationLonghands>&,
@@ -117,9 +119,13 @@ bool ConsumeBorderImageComponents(CSSParserTokenRange&,
CSSValue*& repeat,
DefaultFill);
CSSValue* ConsumeBorderImageRepeat(CSSParserTokenRange&);
-CSSValue* ConsumeBorderImageSlice(CSSParserTokenRange&, DefaultFill);
-CSSValue* ConsumeBorderImageWidth(CSSParserTokenRange&);
-CSSValue* ConsumeBorderImageOutset(CSSParserTokenRange&);
+CSSValue* ConsumeBorderImageSlice(CSSParserTokenRange&,
+ const CSSParserContext&,
+ DefaultFill);
+CSSValue* ConsumeBorderImageWidth(CSSParserTokenRange&,
+ const CSSParserContext&);
+CSSValue* ConsumeBorderImageOutset(CSSParserTokenRange&,
+ const CSSParserContext&);
CSSValue* ParseBorderRadiusCorner(CSSParserTokenRange&,
const CSSParserContext&);
@@ -128,15 +134,18 @@ CSSValue* ParseBorderWidthSide(CSSParserTokenRange&,
const CSSParserLocalContext&);
CSSValue* ConsumeShadow(CSSParserTokenRange&,
- CSSParserMode,
+ const CSSParserContext&,
AllowInsetAndSpread);
CSSShadowValue* ParseSingleShadow(CSSParserTokenRange&,
- CSSParserMode,
+ const CSSParserContext&,
AllowInsetAndSpread);
-CSSValue* ConsumeColumnCount(CSSParserTokenRange&);
-CSSValue* ConsumeColumnWidth(CSSParserTokenRange&);
-bool ConsumeColumnWidthOrCount(CSSParserTokenRange&, CSSValue*&, CSSValue*&);
+CSSValue* ConsumeColumnCount(CSSParserTokenRange&, const CSSParserContext&);
+CSSValue* ConsumeColumnWidth(CSSParserTokenRange&, const CSSParserContext&);
+bool ConsumeColumnWidthOrCount(CSSParserTokenRange&,
+ const CSSParserContext&,
+ CSSValue*&,
+ CSSValue*&);
CSSValue* ConsumeGapLength(CSSParserTokenRange&, const CSSParserContext&);
CSSValue* ConsumeCounter(CSSParserTokenRange&, const CSSParserContext&, int);
@@ -147,32 +156,32 @@ CSSValue* ConsumeFontSize(
css_property_parser_helpers::UnitlessQuirk =
css_property_parser_helpers::UnitlessQuirk::kForbid);
-CSSValue* ConsumeLineHeight(CSSParserTokenRange&, CSSParserMode);
+CSSValue* ConsumeLineHeight(CSSParserTokenRange&, const CSSParserContext&);
CSSValueList* ConsumeFontFamily(CSSParserTokenRange&);
CSSValue* ConsumeGenericFamily(CSSParserTokenRange&);
CSSValue* ConsumeFamilyName(CSSParserTokenRange&);
String ConcatenateFamilyName(CSSParserTokenRange&);
CSSIdentifierValue* ConsumeFontStretchKeywordOnly(CSSParserTokenRange&);
-CSSValue* ConsumeFontStretch(CSSParserTokenRange&, const CSSParserMode&);
-CSSValue* ConsumeFontStyle(CSSParserTokenRange&, const CSSParserMode&);
-CSSValue* ConsumeFontWeight(CSSParserTokenRange&, const CSSParserMode&);
-CSSValue* ConsumeFontFeatureSettings(CSSParserTokenRange&);
-cssvalue::CSSFontFeatureValue* ConsumeFontFeatureTag(CSSParserTokenRange&);
+CSSValue* ConsumeFontStretch(CSSParserTokenRange&, const CSSParserContext&);
+CSSValue* ConsumeFontStyle(CSSParserTokenRange&, const CSSParserContext&);
+CSSValue* ConsumeFontWeight(CSSParserTokenRange&, const CSSParserContext&);
+CSSValue* ConsumeFontFeatureSettings(CSSParserTokenRange&,
+ const CSSParserContext&);
+cssvalue::CSSFontFeatureValue* ConsumeFontFeatureTag(CSSParserTokenRange&,
+ const CSSParserContext&);
CSSIdentifierValue* ConsumeFontVariantCSS21(CSSParserTokenRange&);
CSSValue* ConsumeGridLine(CSSParserTokenRange&, const CSSParserContext&);
CSSValue* ConsumeGridTrackList(CSSParserTokenRange&,
const CSSParserContext&,
- CSSParserMode,
TrackListType);
bool ParseGridTemplateAreasRow(const WTF::String& grid_row_names,
NamedGridAreaMap&,
const size_t row_count,
size_t& column_count);
CSSValue* ConsumeGridTemplatesRowsOrColumns(CSSParserTokenRange&,
- const CSSParserContext&,
- CSSParserMode);
+ const CSSParserContext&);
bool ConsumeGridItemPositionShorthand(bool important,
CSSParserTokenRange&,
const CSSParserContext&,
@@ -205,9 +214,9 @@ CSSValue* ConsumeWidthOrHeight(
css_property_parser_helpers::UnitlessQuirk::kForbid);
CSSValue* ConsumeMarginOrOffset(CSSParserTokenRange&,
- CSSParserMode,
+ const CSSParserContext&,
css_property_parser_helpers::UnitlessQuirk);
-CSSValue* ConsumeScrollPadding(CSSParserTokenRange&);
+CSSValue* ConsumeScrollPadding(CSSParserTokenRange&, const CSSParserContext&);
CSSValue* ConsumeOffsetPath(CSSParserTokenRange&, const CSSParserContext&);
CSSValue* ConsumePathOrNone(CSSParserTokenRange&);
CSSValue* ConsumeOffsetRotate(CSSParserTokenRange&, const CSSParserContext&);
@@ -216,7 +225,7 @@ CSSValue* ConsumeBasicShape(CSSParserTokenRange&, const CSSParserContext&);
bool ConsumeRadii(CSSValue* horizontal_radii[4],
CSSValue* vertical_radii[4],
CSSParserTokenRange&,
- CSSParserMode,
+ const CSSParserContext&,
bool use_legacy_parsing);
CSSValue* ConsumeTextDecorationLine(CSSParserTokenRange&);
@@ -235,7 +244,7 @@ CSSValue* ConsumeBorderColorSide(CSSParserTokenRange&,
const CSSParserContext&,
const CSSParserLocalContext&);
CSSValue* ConsumeBorderWidth(CSSParserTokenRange&,
- CSSParserMode,
+ const CSSParserContext&,
css_property_parser_helpers::UnitlessQuirk);
CSSValue* ParsePaintStroke(CSSParserTokenRange&, const CSSParserContext&);
CSSValue* ParseSpacing(CSSParserTokenRange&, const CSSParserContext&);
@@ -245,7 +254,7 @@ css_property_parser_helpers::UnitlessQuirk UnitlessUnlessShorthand(
template <CSSValueID start, CSSValueID end>
CSSValue* ConsumePositionLonghand(CSSParserTokenRange& range,
- CSSParserMode css_parser_mode) {
+ const CSSParserContext& context) {
if (range.Peek().GetType() == kIdentToken) {
CSSValueID id = range.Peek().Id();
int percent;
@@ -261,12 +270,10 @@ CSSValue* ConsumePositionLonghand(CSSParserTokenRange& range,
return CSSNumericLiteralValue::Create(
percent, CSSPrimitiveValue::UnitType::kPercentage);
}
- return css_property_parser_helpers::ConsumeLengthOrPercent(
- range, css_parser_mode, kValueRangeAll);
+ return css_property_parser_helpers::ConsumeLengthOrPercent(range, context,
+ kValueRangeAll);
}
-CSSValue* ConsumeIntrinsicLength(CSSParserTokenRange&, const CSSParserContext&);
-
} // namespace css_parsing_utils
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/properties/css_parsing_utils_test.cc b/chromium/third_party/blink/renderer/core/css/properties/css_parsing_utils_test.cc
index 7b9aad46a4a..8ac05ca0a7d 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/css_parsing_utils_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/properties/css_parsing_utils_test.cc
@@ -16,7 +16,7 @@ TEST(CSSParsingUtilsTest, BasicShapeUseCount) {
Document& document = dummy_page_holder->GetDocument();
WebFeature feature = WebFeature::kCSSBasicShape;
EXPECT_FALSE(document.IsUseCounted(feature));
- document.documentElement()->SetInnerHTMLFromString(
+ document.documentElement()->setInnerHTML(
"<style>span { shape-outside: circle(); }</style>");
EXPECT_TRUE(document.IsUseCounted(feature));
}
diff --git a/chromium/third_party/blink/renderer/core/css/properties/css_property.cc b/chromium/third_party/blink/renderer/core/css/properties/css_property.cc
index 0c0540f2c19..af17d6cc31b 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/css_property.cc
+++ b/chromium/third_party/blink/renderer/core/css/properties/css_property.cc
@@ -53,12 +53,13 @@ const CSSValue* CSSProperty::CSSValueFromComputedStyle(
}
void CSSProperty::FilterWebExposedCSSPropertiesIntoVector(
+ const ExecutionContext* execution_context,
const CSSPropertyID* properties,
size_t propertyCount,
Vector<const CSSProperty*>& outVector) {
for (unsigned i = 0; i < propertyCount; i++) {
const CSSProperty& property = Get(properties[i]);
- if (property.IsWebExposed())
+ if (property.IsWebExposed(execution_context))
outVector.push_back(&property);
}
}
diff --git a/chromium/third_party/blink/renderer/core/css/properties/css_property.h b/chromium/third_party/blink/renderer/core/css/properties/css_property.h
index a3d418cab44..0ecc8b561ea 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/css_property.h
+++ b/chromium/third_party/blink/renderer/core/css/properties/css_property.h
@@ -19,11 +19,14 @@ namespace blink {
class ComputedStyle;
class CrossThreadStyleValue;
+class ExecutionContext;
class LayoutObject;
class SVGComputedStyle;
class CORE_EXPORT CSSProperty : public CSSUnresolvedProperty {
public:
+ using Flags = uint16_t;
+
static const CSSProperty& Get(CSSPropertyID);
// For backwards compatibility when passing around CSSUnresolvedProperty
@@ -37,6 +40,7 @@ class CORE_EXPORT CSSProperty : public CSSUnresolvedProperty {
bool IDEquals(CSSPropertyID id) const { return PropertyID() == id; }
bool IsResolvedProperty() const override { return true; }
+ Flags GetFlags() const { return flags_; }
bool IsInterpolable() const { return flags_ & kInterpolable; }
bool IsCompositableProperty() const { return flags_ & kCompositableProperty; }
bool IsDescriptor() const { return flags_ & kDescriptor; }
@@ -49,6 +53,11 @@ class CORE_EXPORT CSSProperty : public CSSUnresolvedProperty {
bool IsAffectedByForcedColors() const {
return flags_ & kIsAffectedByForcedColors;
}
+ bool IsValidForFirstLetter() const { return flags_ & kValidForFirstLetter; }
+ bool IsValidForCue() const { return flags_ & kValidForCue; }
+ bool IsValidForMarker() const { return flags_ & kValidForMarker; }
+ bool IsSurrogate() const { return flags_ & kSurrogate; }
+ bool AffectsFont() const { return flags_ & kAffectsFont; }
bool IsRepeated() const { return repetition_separator_ != '\0'; }
char RepetitionSeparator() const { return repetition_separator_; }
@@ -82,13 +91,18 @@ class CORE_EXPORT CSSProperty : public CSSUnresolvedProperty {
}
virtual const CSSProperty* GetVisitedProperty() const { return nullptr; }
virtual const CSSProperty* GetUnvisitedProperty() const { return nullptr; }
+
+ virtual const CSSProperty* SurrogateFor(TextDirection, WritingMode) const {
+ return nullptr;
+ }
+
static void FilterWebExposedCSSPropertiesIntoVector(
+ const ExecutionContext*,
const CSSPropertyID*,
size_t length,
Vector<const CSSProperty*>&);
- protected:
- enum Flag : uint16_t {
+ enum Flag : Flags {
kInterpolable = 1 << 0,
kCompositableProperty = 1 << 1,
kDescriptor = 1 << 2,
@@ -102,11 +116,25 @@ class CORE_EXPORT CSSProperty : public CSSUnresolvedProperty {
// seen by CSSOM, which is represented by the unvisited property).
kVisited = 1 << 7,
kInternal = 1 << 8,
- kIsAffectedByForcedColors = 1 << 9
+ kIsAffectedByForcedColors = 1 << 9,
+ // Animation properties have this flag set. (I.e. longhands of the
+ // 'animation' and 'transition' shorthands).
+ kAnimation = 1 << 10,
+ // https://drafts.csswg.org/css-pseudo-4/#first-letter-styling
+ kValidForFirstLetter = 1 << 11,
+ // https://w3c.github.io/webvtt/#the-cue-pseudo-element
+ kValidForCue = 1 << 12,
+ // https://drafts.csswg.org/css-pseudo-4/#marker-pseudo
+ kValidForMarker = 1 << 13,
+ // A surrogate is a (non-alias) property which acts like another property,
+ // for example -webkit-writing-mode is a surrogate for writing-mode, and
+ // inline-size is a surrogate for either width or height.
+ kSurrogate = 1 << 14,
+ kAffectsFont = 1 << 15,
};
constexpr CSSProperty(CSSPropertyID property_id,
- uint16_t flags,
+ Flags flags,
char repetition_separator)
: CSSUnresolvedProperty(),
property_id_(property_id),
@@ -115,7 +143,7 @@ class CORE_EXPORT CSSProperty : public CSSUnresolvedProperty {
private:
CSSPropertyID property_id_;
- uint16_t flags_;
+ Flags flags_;
char repetition_separator_;
};
diff --git a/chromium/third_party/blink/renderer/core/css/properties/css_property_ref.cc b/chromium/third_party/blink/renderer/core/css/properties/css_property_ref.cc
index bd83e45f25a..0cd1fdcae0a 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/css_property_ref.cc
+++ b/chromium/third_party/blink/renderer/core/css/properties/css_property_ref.cc
@@ -9,7 +9,8 @@
namespace blink {
CSSPropertyRef::CSSPropertyRef(const String& name, const Document& document)
- : property_id_(unresolvedCSSPropertyID(name)) {
+ : property_id_(
+ unresolvedCSSPropertyID(document.GetExecutionContext(), name)) {
if (property_id_ == CSSPropertyID::kVariable)
custom_property_ = CustomProperty(AtomicString(name), document);
}
diff --git a/chromium/third_party/blink/renderer/core/css/properties/css_property_ref.h b/chromium/third_party/blink/renderer/core/css/properties/css_property_ref.h
index 0aead62b8b1..f3e986218fb 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/css_property_ref.h
+++ b/chromium/third_party/blink/renderer/core/css/properties/css_property_ref.h
@@ -66,7 +66,7 @@ class CORE_EXPORT CSSPropertyRef {
return GetProperty();
}
- void Trace(blink::Visitor* visitor) { visitor->Trace(custom_property_); }
+ void Trace(Visitor* visitor) { visitor->Trace(custom_property_); }
private:
CSSPropertyID property_id_;
diff --git a/chromium/third_party/blink/renderer/core/css/properties/css_property_test.cc b/chromium/third_party/blink/renderer/core/css/properties/css_property_test.cc
index a281633b8b1..0ea0edf0642 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/css_property_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/properties/css_property_test.cc
@@ -18,7 +18,8 @@ class CSSPropertyTest : public PageTestBase {};
TEST_F(CSSPropertyTest, VisitedPropertiesAreNotWebExposed) {
for (CSSPropertyID property_id : CSSPropertyIDList()) {
const CSSProperty& property = CSSProperty::Get(property_id);
- EXPECT_TRUE(!property.IsVisited() || !property.IsWebExposed());
+ EXPECT_TRUE(!property.IsVisited() ||
+ !property.IsWebExposed(GetDocument().GetExecutionContext()));
}
}
@@ -40,7 +41,7 @@ TEST_F(CSSPropertyTest, GetUnvisitedPropertyFromVisited) {
TEST_F(CSSPropertyTest, InternalEffectiveZoomNotWebExposed) {
const CSSProperty& property = GetCSSPropertyInternalEffectiveZoom();
- EXPECT_FALSE(property.IsWebExposed());
+ EXPECT_FALSE(property.IsWebExposed(GetDocument().GetExecutionContext()));
}
TEST_F(CSSPropertyTest, InternalEffectiveZoomCanBeParsed) {
@@ -87,4 +88,18 @@ TEST_F(CSSPropertyTest, VisitedPropertiesCanParseValues) {
EXPECT_GT(num_visited, 0u);
}
+TEST_F(CSSPropertyTest, Surrogates) {
+ EXPECT_EQ(&GetCSSPropertyWidth(),
+ GetCSSPropertyInlineSize().SurrogateFor(
+ TextDirection::kLtr, WritingMode::kHorizontalTb));
+ EXPECT_EQ(&GetCSSPropertyHeight(),
+ GetCSSPropertyInlineSize().SurrogateFor(TextDirection::kLtr,
+ WritingMode::kVerticalRl));
+ EXPECT_EQ(&GetCSSPropertyWritingMode(),
+ GetCSSPropertyWebkitWritingMode().SurrogateFor(
+ TextDirection::kLtr, WritingMode::kHorizontalTb));
+ EXPECT_FALSE(GetCSSPropertyWidth().SurrogateFor(TextDirection::kLtr,
+ WritingMode::kHorizontalTb));
+}
+
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/properties/css_unresolved_property.h b/chromium/third_party/blink/renderer/core/css/properties/css_unresolved_property.h
index 9abed9fed82..afeae4ae8c6 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/css_unresolved_property.h
+++ b/chromium/third_party/blink/renderer/core/css/properties/css_unresolved_property.h
@@ -7,6 +7,7 @@
#include "third_party/blink/renderer/core/css/properties/css_exposure.h"
#include "third_party/blink/renderer/core/css/properties/css_property_instances.h"
+#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
@@ -22,6 +23,18 @@ class CORE_EXPORT CSSUnresolvedProperty {
bool IsWebExposed() const { return blink::IsWebExposed(Exposure()); }
bool IsUAExposed() const { return blink::IsUAExposed(Exposure()); }
virtual CSSExposure Exposure() const { return CSSExposure::kWeb; }
+ // Takes origin trial into account
+ bool IsWebExposed(const ExecutionContext* context) const {
+ return blink::IsWebExposed(Exposure(context));
+ }
+ bool IsUAExposed(const ExecutionContext* context) const {
+ return blink::IsUAExposed(Exposure(context));
+ }
+ virtual CSSExposure Exposure(const ExecutionContext* context) const {
+ // css properties that does not override this function should return
+ // the same value as Exposure()
+ return Exposure();
+ }
virtual bool IsResolvedProperty() const { return false; }
virtual const char* GetPropertyName() const {
NOTREACHED();
diff --git a/chromium/third_party/blink/renderer/core/css/properties/longhand.h b/chromium/third_party/blink/renderer/core/css/properties/longhand.h
index 6bdebb7b389..161366cbd83 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/longhand.h
+++ b/chromium/third_party/blink/renderer/core/css/properties/longhand.h
@@ -43,9 +43,7 @@ class Longhand : public CSSProperty {
}
protected:
- constexpr Longhand(CSSPropertyID id,
- uint16_t flags,
- char repetition_separator)
+ constexpr Longhand(CSSPropertyID id, Flags flags, char repetition_separator)
: CSSProperty(id, flags | kLonghand, repetition_separator) {}
};
diff --git a/chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property.cc b/chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property.cc
index 28138d97ff7..8cb1be641d8 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property.cc
+++ b/chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property.cc
@@ -17,7 +17,9 @@ namespace blink {
CustomProperty::CustomProperty(const AtomicString& name,
const Document& document)
- : CustomProperty(name, PropertyRegistration::From(&document, name)) {}
+ : CustomProperty(
+ name,
+ PropertyRegistration::From(document.GetExecutionContext(), name)) {}
CustomProperty::CustomProperty(const AtomicString& name,
const PropertyRegistry* registry)
@@ -186,7 +188,7 @@ const CSSValue* CustomProperty::ParseTyped(
const CSSParserLocalContext& local_context) const {
if (!registration_)
return ParseUntyped(range, context, local_context);
- return registration_->Syntax().Parse(range, &context,
+ return registration_->Syntax().Parse(range, context,
local_context.IsAnimationTainted());
}
diff --git a/chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property.h b/chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property.h
index 87b813e3260..1e498cd35bc 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property.h
+++ b/chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property.h
@@ -49,7 +49,7 @@ class CORE_EXPORT CustomProperty : public Variable {
bool IsRegistered() const { return registration_; }
- void Trace(blink::Visitor* visitor) { visitor->Trace(registration_); }
+ void Trace(Visitor* visitor) { visitor->Trace(registration_); }
private:
CustomProperty(const AtomicString& name,
diff --git a/chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property_test.cc b/chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property_test.cc
index c8f3a61da57..9819322441e 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/properties/longhands/custom_property_test.cc
@@ -24,8 +24,8 @@ namespace {
class CustomPropertyTest : public PageTestBase {
public:
void SetElementWithStyle(const String& value) {
- GetDocument().body()->SetInnerHTMLFromString("<div id='target' style='" +
- value + "'></div>");
+ GetDocument().body()->setInnerHTML("<div id='target' style='" + value +
+ "'></div>");
UpdateAllLifecyclePhasesForTest();
}
diff --git a/chromium/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc b/chromium/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
index f2bb58fe73a..2273c259d3a 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
+++ b/chromium/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
@@ -126,10 +126,10 @@ const CSSValue* AlignmentBaseline::CSSValueFromComputedStyleInternal(
const CSSValue* AnimationDelay::ParseSingleValue(
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_property_parser_helpers::ConsumeCommaSeparatedList(
- css_property_parser_helpers::ConsumeTime, range, kValueRangeAll);
+ css_property_parser_helpers::ConsumeTime, range, context, kValueRangeAll);
}
const CSSValue* AnimationDelay::CSSValueFromComputedStyleInternal(
@@ -185,10 +185,11 @@ const CSSValue* AnimationDirection::InitialValue() const {
const CSSValue* AnimationDuration::ParseSingleValue(
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_property_parser_helpers::ConsumeCommaSeparatedList(
- css_property_parser_helpers::ConsumeTime, range, kValueRangeNonNegative);
+ css_property_parser_helpers::ConsumeTime, range, context,
+ kValueRangeNonNegative);
}
const CSSValue* AnimationDuration::CSSValueFromComputedStyleInternal(
@@ -244,10 +245,10 @@ const CSSValue* AnimationFillMode::InitialValue() const {
const CSSValue* AnimationIterationCount::ParseSingleValue(
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_property_parser_helpers::ConsumeCommaSeparatedList(
- css_parsing_utils::ConsumeAnimationIterationCount, range);
+ css_parsing_utils::ConsumeAnimationIterationCount, range, context);
}
const CSSValue* AnimationIterationCount::CSSValueFromComputedStyleInternal(
@@ -347,10 +348,10 @@ const CSSValue* AnimationPlayState::InitialValue() const {
const CSSValue* AnimationTimingFunction::ParseSingleValue(
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_property_parser_helpers::ConsumeCommaSeparatedList(
- css_parsing_utils::ConsumeAnimationTimingFunction, range);
+ css_parsing_utils::ConsumeAnimationTimingFunction, range, context);
}
const CSSValue* AnimationTimingFunction::CSSValueFromComputedStyleInternal(
@@ -368,6 +369,45 @@ const CSSValue* AnimationTimingFunction::InitialValue() const {
return value;
}
+const CSSValue* AspectRatio::ParseSingleValue(
+ CSSParserTokenRange& range,
+ const CSSParserContext& context,
+ const CSSParserLocalContext&) const {
+ if (range.Peek().Id() == CSSValueID::kAuto)
+ return css_property_parser_helpers::ConsumeIdent(range);
+ CSSValue* width =
+ css_property_parser_helpers::ConsumePositiveInteger(range, context);
+ if (!width)
+ return nullptr;
+ if (!css_property_parser_helpers::ConsumeSlashIncludingWhitespace(range))
+ return nullptr;
+ CSSValue* height =
+ css_property_parser_helpers::ConsumePositiveInteger(range, context);
+ if (!height)
+ return nullptr;
+ CSSValueList* list = CSSValueList::CreateSlashSeparated();
+ list->Append(*width);
+ list->Append(*height);
+ return list;
+}
+
+const CSSValue* AspectRatio::CSSValueFromComputedStyleInternal(
+ const ComputedStyle& style,
+ const SVGComputedStyle&,
+ const LayoutObject* layout_object,
+ bool allow_visited_style) const {
+ auto& ratio = style.AspectRatio();
+ if (!ratio.has_value())
+ return CSSIdentifierValue::Create(CSSValueID::kAuto);
+
+ CSSValueList* list = CSSValueList::CreateSlashSeparated();
+ list->Append(*CSSNumericLiteralValue::Create(
+ ratio->Width(), CSSPrimitiveValue::UnitType::kInteger));
+ list->Append(*CSSNumericLiteralValue::Create(
+ ratio->Height(), CSSPrimitiveValue::UnitType::kInteger));
+ return list;
+}
+
const CSSValue* BackdropFilter::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
@@ -460,7 +500,7 @@ const CSSValue* BackgroundColor::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_property_parser_helpers::ConsumeColor(
- range, context.Mode(), IsQuirksModeBehavior(context.Mode()));
+ range, context, IsQuirksModeBehavior(context.Mode()));
}
const blink::Color BackgroundColor::ColorIncludingFallback(
@@ -489,7 +529,7 @@ const CSSValue* BackgroundImage::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_property_parser_helpers::ConsumeCommaSeparatedList(
- css_property_parser_helpers::ConsumeImageOrNone, range, &context);
+ css_property_parser_helpers::ConsumeImageOrNone, range, context);
}
const CSSValue* BackgroundImage::CSSValueFromComputedStyleInternal(
@@ -531,7 +571,7 @@ const CSSValue* BackgroundPositionX::ParseSingleValue(
return css_property_parser_helpers::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumePositionLonghand<CSSValueID::kLeft,
CSSValueID::kRight>,
- range, context.Mode());
+ range, context);
}
const CSSValue* BackgroundPositionX::CSSValueFromComputedStyleInternal(
@@ -551,7 +591,7 @@ const CSSValue* BackgroundPositionY::ParseSingleValue(
return css_property_parser_helpers::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumePositionLonghand<CSSValueID::kTop,
CSSValueID::kBottom>,
- range, context.Mode());
+ range, context);
}
const CSSValue* BackgroundPositionY::CSSValueFromComputedStyleInternal(
@@ -589,8 +629,9 @@ const CSSValue* BaselineShift::ParseSingleValue(
if (id == CSSValueID::kBaseline || id == CSSValueID::kSub ||
id == CSSValueID::kSuper)
return css_property_parser_helpers::ConsumeIdent(range);
- return css_property_parser_helpers::ConsumeLengthOrPercent(
- range, kSVGAttributeMode, kValueRangeAll);
+ CSSParserContext::ParserModeOverridingScope scope(context, kSVGAttributeMode);
+ return css_property_parser_helpers::ConsumeLengthOrPercent(range, context,
+ kValueRangeAll);
}
const CSSValue* BaselineShift::CSSValueFromComputedStyleInternal(
@@ -662,7 +703,7 @@ const CSSValue* BorderBlockEndColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const CSSValue* BorderBlockEndWidth::ParseSingleValue(
@@ -670,15 +711,14 @@ const CSSValue* BorderBlockEndWidth::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeBorderWidth(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kForbid);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kForbid);
}
const CSSValue* BorderBlockStartColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const CSSValue* BorderBlockStartWidth::ParseSingleValue(
@@ -686,8 +726,7 @@ const CSSValue* BorderBlockStartWidth::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeBorderWidth(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kForbid);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kForbid);
}
const CSSValue* BorderBottomColor::ParseSingleValue(
@@ -730,7 +769,7 @@ const CSSValue* BorderBottomLeftRadius::CSSValueFromComputedStyleInternal(
const SVGComputedStyle&,
const LayoutObject*,
bool allow_visited_style) const {
- return &ComputedStyleUtils::ValueForBorderRadiusCorner(
+ return ComputedStyleUtils::ValueForBorderRadiusCorner(
style.BorderBottomLeftRadius(), style);
}
@@ -746,7 +785,7 @@ const CSSValue* BorderBottomRightRadius::CSSValueFromComputedStyleInternal(
const SVGComputedStyle&,
const LayoutObject*,
bool allow_visited_style) const {
- return &ComputedStyleUtils::ValueForBorderRadiusCorner(
+ return ComputedStyleUtils::ValueForBorderRadiusCorner(
style.BorderBottomRightRadius(), style);
}
const CSSValue* BorderBottomStyle::CSSValueFromComputedStyleInternal(
@@ -784,9 +823,9 @@ const CSSValue* BorderCollapse::CSSValueFromComputedStyleInternal(
const CSSValue* BorderImageOutset::ParseSingleValue(
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeBorderImageOutset(range);
+ return css_parsing_utils::ConsumeBorderImageOutset(range, context);
}
const CSSValue* BorderImageOutset::CSSValueFromComputedStyleInternal(
@@ -799,11 +838,11 @@ const CSSValue* BorderImageOutset::CSSValueFromComputedStyleInternal(
}
const CSSValue* BorderImageOutset::InitialValue() const {
- DEFINE_STATIC_LOCAL(
- const Persistent<CSSQuadValue>, value,
- (CSSQuadValue::Create(CSSNumericLiteralValue::Create(
- 0, CSSPrimitiveValue::UnitType::kInteger),
- CSSQuadValue::kSerializeAsQuad)));
+ DEFINE_STATIC_LOCAL(const Persistent<CSSQuadValue>, value,
+ (MakeGarbageCollected<CSSQuadValue>(
+ CSSNumericLiteralValue::Create(
+ 0, CSSPrimitiveValue::UnitType::kInteger),
+ CSSQuadValue::kSerializeAsQuad)));
return value;
}
@@ -830,10 +869,10 @@ const CSSValue* BorderImageRepeat::InitialValue() const {
const CSSValue* BorderImageSlice::ParseSingleValue(
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeBorderImageSlice(
- range, css_parsing_utils::DefaultFill::kNoFill);
+ range, context, css_parsing_utils::DefaultFill::kNoFill);
}
const CSSValue* BorderImageSlice::CSSValueFromComputedStyleInternal(
@@ -848,7 +887,7 @@ const CSSValue* BorderImageSlice::InitialValue() const {
DEFINE_STATIC_LOCAL(
const Persistent<cssvalue::CSSBorderImageSliceValue>, value,
(MakeGarbageCollected<cssvalue::CSSBorderImageSliceValue>(
- CSSQuadValue::Create(
+ MakeGarbageCollected<CSSQuadValue>(
CSSNumericLiteralValue::Create(
100, CSSPrimitiveValue::UnitType::kPercentage),
CSSQuadValue::kSerializeAsQuad),
@@ -860,7 +899,7 @@ const CSSValue* BorderImageSource::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeImageOrNone(range, &context);
+ return css_property_parser_helpers::ConsumeImageOrNone(range, context);
}
const CSSValue* BorderImageSource::CSSValueFromComputedStyleInternal(
@@ -889,9 +928,9 @@ void BorderImageSource::ApplyValue(StyleResolverState& state,
const CSSValue* BorderImageWidth::ParseSingleValue(
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeBorderImageWidth(range);
+ return css_parsing_utils::ConsumeBorderImageWidth(range, context);
}
const CSSValue* BorderImageWidth::CSSValueFromComputedStyleInternal(
@@ -904,11 +943,11 @@ const CSSValue* BorderImageWidth::CSSValueFromComputedStyleInternal(
}
const CSSValue* BorderImageWidth::InitialValue() const {
- DEFINE_STATIC_LOCAL(
- const Persistent<CSSQuadValue>, value,
- (CSSQuadValue::Create(CSSNumericLiteralValue::Create(
- 1, CSSPrimitiveValue::UnitType::kInteger),
- CSSQuadValue::kSerializeAsQuad)));
+ DEFINE_STATIC_LOCAL(const Persistent<CSSQuadValue>, value,
+ (MakeGarbageCollected<CSSQuadValue>(
+ CSSNumericLiteralValue::Create(
+ 1, CSSPrimitiveValue::UnitType::kInteger),
+ CSSQuadValue::kSerializeAsQuad)));
return value;
}
@@ -916,7 +955,7 @@ const CSSValue* BorderInlineEndColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const CSSValue* BorderInlineEndWidth::ParseSingleValue(
@@ -924,15 +963,14 @@ const CSSValue* BorderInlineEndWidth::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeBorderWidth(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kForbid);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kForbid);
}
const CSSValue* BorderInlineStartColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const CSSValue* BorderInlineStartWidth::ParseSingleValue(
@@ -940,8 +978,7 @@ const CSSValue* BorderInlineStartWidth::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeBorderWidth(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kForbid);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kForbid);
}
const CSSValue* BorderLeftColor::ParseSingleValue(
@@ -1084,7 +1121,7 @@ const CSSValue* BorderTopLeftRadius::CSSValueFromComputedStyleInternal(
const SVGComputedStyle&,
const LayoutObject*,
bool allow_visited_style) const {
- return &ComputedStyleUtils::ValueForBorderRadiusCorner(
+ return ComputedStyleUtils::ValueForBorderRadiusCorner(
style.BorderTopLeftRadius(), style);
}
@@ -1100,7 +1137,7 @@ const CSSValue* BorderTopRightRadius::CSSValueFromComputedStyleInternal(
const SVGComputedStyle&,
const LayoutObject*,
bool allow_visited_style) const {
- return &ComputedStyleUtils::ValueForBorderRadiusCorner(
+ return ComputedStyleUtils::ValueForBorderRadiusCorner(
style.BorderTopRightRadius(), style);
}
@@ -1132,7 +1169,7 @@ const CSSValue* Bottom::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeMarginOrOffset(
- range, context.Mode(),
+ range, context,
css_parsing_utils::UnitlessUnlessShorthand(local_context));
}
@@ -1155,7 +1192,7 @@ const CSSValue* BoxShadow::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeShadow(
- range, context.Mode(), css_parsing_utils::AllowInsetAndSpread::kAllow);
+ range, context, css_parsing_utils::AllowInsetAndSpread::kAllow);
}
const CSSValue* BoxShadow::CSSValueFromComputedStyleInternal(
@@ -1222,7 +1259,7 @@ const CSSValue* CaretColor::ParseSingleValue(
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_property_parser_helpers::ConsumeIdent(range);
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const blink::Color CaretColor::ColorIncludingFallback(
@@ -1277,11 +1314,11 @@ const CSSValue* Clear::CSSValueFromComputedStyleInternal(
namespace {
CSSValue* ConsumeClipComponent(CSSParserTokenRange& range,
- CSSParserMode css_parser_mode) {
+ const CSSParserContext& context) {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_property_parser_helpers::ConsumeIdent(range);
return css_property_parser_helpers::ConsumeLength(
- range, css_parser_mode, kValueRangeAll,
+ range, context, kValueRangeAll,
css_property_parser_helpers::UnitlessQuirk::kAllow);
}
@@ -1299,22 +1336,22 @@ const CSSValue* Clip::ParseSingleValue(CSSParserTokenRange& range,
CSSParserTokenRange args =
css_property_parser_helpers::ConsumeFunction(range);
// rect(t, r, b, l) || rect(t r b l)
- CSSValue* top = ConsumeClipComponent(args, context.Mode());
+ CSSValue* top = ConsumeClipComponent(args, context);
if (!top)
return nullptr;
bool needs_comma =
css_property_parser_helpers::ConsumeCommaIncludingWhitespace(args);
- CSSValue* right = ConsumeClipComponent(args, context.Mode());
+ CSSValue* right = ConsumeClipComponent(args, context);
if (!right ||
(needs_comma &&
!css_property_parser_helpers::ConsumeCommaIncludingWhitespace(args)))
return nullptr;
- CSSValue* bottom = ConsumeClipComponent(args, context.Mode());
+ CSSValue* bottom = ConsumeClipComponent(args, context);
if (!bottom ||
(needs_comma &&
!css_property_parser_helpers::ConsumeCommaIncludingWhitespace(args)))
return nullptr;
- CSSValue* left = ConsumeClipComponent(args, context.Mode());
+ CSSValue* left = ConsumeClipComponent(args, context);
if (!left || !args.AtEnd())
return nullptr;
return MakeGarbageCollected<CSSQuadValue>(top, right, bottom, left,
@@ -1346,7 +1383,7 @@ const CSSValue* ClipPath::ParseSingleValue(CSSParserTokenRange& range,
if (range.Peek().Id() == CSSValueID::kNone)
return css_property_parser_helpers::ConsumeIdent(range);
if (cssvalue::CSSURIValue* url =
- css_property_parser_helpers::ConsumeUrl(range, &context))
+ css_property_parser_helpers::ConsumeUrl(range, context))
return url;
return css_parsing_utils::ConsumeBasicShape(range, context);
}
@@ -1362,8 +1399,8 @@ const CSSValue* ClipPath::CSSValueFromComputedStyleInternal(
style, To<ShapeClipPathOperation>(operation)->GetBasicShape());
}
if (operation->GetType() == ClipPathOperation::REFERENCE) {
- return cssvalue::CSSURIValue::Create(
- To<ReferenceClipPathOperation>(operation)->Url());
+ AtomicString url = To<ReferenceClipPathOperation>(operation)->Url();
+ return MakeGarbageCollected<cssvalue::CSSURIValue>(url);
}
}
return CSSIdentifierValue::Create(CSSValueID::kNone);
@@ -1381,7 +1418,7 @@ const CSSValue* Color::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_property_parser_helpers::ConsumeColor(
- range, context.Mode(), IsQuirksModeBehavior(context.Mode()));
+ range, context, IsQuirksModeBehavior(context.Mode()));
}
const blink::Color Color::ColorIncludingFallback(
@@ -1407,8 +1444,7 @@ void Color::ApplyInitial(StyleResolverState& state) const {
CSSIdentifierValue::Create(CSSValueID::kInitial));
return;
}
- blink::Color color = ComputedStyleInitialValues::InitialColor();
- state.Style()->SetColor(color);
+ state.Style()->SetColor(state.Style()->InitialColorForColorScheme());
}
void Color::ApplyInherit(StyleResolverState& state) const {
@@ -1417,11 +1453,7 @@ void Color::ApplyInherit(StyleResolverState& state) const {
CSSIdentifierValue::Create(CSSValueID::kInherit));
return;
}
- blink::Color color = state.ParentStyle()->GetColor();
- if (state.ParentStyle()->IsColorInternalText())
- state.Style()->SetIsColorInternalText(true);
- else
- state.Style()->SetColor(color);
+ state.Style()->SetColor(state.ParentStyle()->GetColor());
}
void Color::ApplyValue(StyleResolverState& state, const CSSValue& value) const {
@@ -1436,13 +1468,7 @@ void Color::ApplyValue(StyleResolverState& state, const CSSValue& value) const {
ApplyInherit(state);
return;
}
-
- if (identifier_value &&
- identifier_value->GetValueID() == CSSValueID::kInternalRootColor) {
- state.Style()->SetIsColorInternalText(true);
- } else {
- state.Style()->SetColor(StyleBuilderConverter::ConvertColor(state, value));
- }
+ state.Style()->SetColor(StyleBuilderConverter::ConvertColor(state, value));
}
const CSSValue* ColorInterpolation::CSSValueFromComputedStyleInternal(
@@ -1488,11 +1514,11 @@ const CSSValue* ColorScheme::ParseSingleValue(
CSSValueList* values = CSSValueList::CreateSpaceSeparated();
do {
CSSValueID id = range.Peek().Id();
- // 'normal' is handled above, and 'none' is reserved for future use.
+ // 'normal' is handled above, and 'default' is reserved for future use.
// 'revert' is not yet implemented as a keyword, but still skip it for
// compat and interop.
- if (id == CSSValueID::kNormal || id == CSSValueID::kNone ||
- id == CSSValueID::kRevert || id == CSSValueID::kDefault) {
+ if (id == CSSValueID::kNormal || id == CSSValueID::kRevert ||
+ id == CSSValueID::kDefault) {
return nullptr;
}
if (id == CSSValueID::kOnly) {
@@ -1579,7 +1605,7 @@ const CSSValue* ColumnCount::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeColumnCount(range);
+ return css_parsing_utils::ConsumeColumnCount(range, context);
}
const CSSValue* ColumnCount::CSSValueFromComputedStyleInternal(
@@ -1620,7 +1646,7 @@ const CSSValue* ColumnRuleColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const blink::Color ColumnRuleColor::ColorIncludingFallback(
@@ -1654,8 +1680,7 @@ const CSSValue* ColumnRuleWidth::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_property_parser_helpers::ConsumeLineWidth(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kForbid);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kForbid);
}
const CSSValue* ColumnRuleWidth::CSSValueFromComputedStyleInternal(
@@ -1688,7 +1713,7 @@ const CSSValue* ColumnWidth::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeColumnWidth(range);
+ return css_parsing_utils::ConsumeColumnWidth(range, context);
}
const CSSValue* ColumnWidth::CSSValueFromComputedStyleInternal(
@@ -1772,60 +1797,40 @@ const CSSValue* Contain::CSSValueFromComputedStyleInternal(
return list;
}
-const CSSValue* IntrinsicBlockSize::ParseSingleValue(
- CSSParserTokenRange& range,
- const CSSParserContext& context,
- const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeIntrinsicLength(range, context);
-}
-
-const CSSValue* IntrinsicInlineSize::ParseSingleValue(
- CSSParserTokenRange& range,
- const CSSParserContext& context,
- const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeIntrinsicLength(range, context);
-}
-
-const CSSValue* IntrinsicWidth::ParseSingleValue(
+const CSSValue* ContainIntrinsicSize::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeIntrinsicLength(range, context);
-}
-
-const CSSValue* IntrinsicWidth::CSSValueFromComputedStyleInternal(
- const ComputedStyle& style,
- const SVGComputedStyle&,
- const LayoutObject* layout_object,
- bool allow_visited_style) const {
- auto& width = style.IntrinsicWidth();
- if (width.IsLegacy())
- return CSSIdentifierValue::Create(CSSValueID::kLegacy);
- if (width.IsAuto())
- return CSSIdentifierValue::Create(CSSValueID::kAuto);
- return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(width.GetLength(),
- style);
-}
-
-const CSSValue* IntrinsicHeight::ParseSingleValue(
- CSSParserTokenRange& range,
- const CSSParserContext& context,
- const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeIntrinsicLength(range, context);
+ if (range.Peek().Id() == CSSValueID::kAuto)
+ return css_property_parser_helpers::ConsumeIdent(range);
+ CSSValue* width = css_property_parser_helpers::ConsumeLength(
+ range, context, kValueRangeNonNegative);
+ if (!width)
+ return nullptr;
+ CSSValue* height = css_property_parser_helpers::ConsumeLength(
+ range, context, kValueRangeNonNegative);
+ if (!height)
+ height = width;
+ return MakeGarbageCollected<CSSValuePair>(width, height,
+ CSSValuePair::kDropIdenticalValues);
}
-const CSSValue* IntrinsicHeight::CSSValueFromComputedStyleInternal(
+const CSSValue* ContainIntrinsicSize::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const SVGComputedStyle&,
const LayoutObject* layout_object,
bool allow_visited_style) const {
- auto& height = style.IntrinsicHeight();
- if (height.IsLegacy())
- return CSSIdentifierValue::Create(CSSValueID::kLegacy);
- if (height.IsAuto())
+ auto& size = style.ContainIntrinsicSize();
+ if (size.Width().IsAuto()) {
+ DCHECK(size.Height().IsAuto());
return CSSIdentifierValue::Create(CSSValueID::kAuto);
- return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(height.GetLength(),
- style);
+ }
+ return MakeGarbageCollected<CSSValuePair>(
+ ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
+ style.ContainIntrinsicSize().Width(), style),
+ ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
+ style.ContainIntrinsicSize().Height(), style),
+ CSSValuePair::kDropIdenticalValues);
}
namespace {
@@ -1900,7 +1905,7 @@ const CSSValue* Content::ParseSingleValue(CSSParserTokenRange& range,
bool alt_text_present = false;
do {
CSSValue* parsed_value =
- css_property_parser_helpers::ConsumeImage(range, &context);
+ css_property_parser_helpers::ConsumeImage(range, context);
if (!parsed_value) {
parsed_value = css_property_parser_helpers::ConsumeIdent<
CSSValueID::kOpenQuote, CSSValueID::kCloseQuote,
@@ -1968,7 +1973,10 @@ void Content::ApplyValue(StyleResolverState& state,
if (auto* identifier_value = DynamicTo<CSSIdentifierValue>(value)) {
DCHECK(identifier_value->GetValueID() == CSSValueID::kNormal ||
identifier_value->GetValueID() == CSSValueID::kNone);
- state.Style()->SetContent(nullptr);
+ if (identifier_value->GetValueID() == CSSValueID::kNone)
+ state.Style()->SetContent(MakeGarbageCollected<NoneContentData>());
+ else
+ state.Style()->SetContent(nullptr);
return;
}
const CSSValueList& outer_list = To<CSSValueList>(value);
@@ -2096,14 +2104,14 @@ const CSSValue* Cursor::ParseSingleValue(CSSParserTokenRange& range,
CSSValueList* list = nullptr;
while (
CSSValue* image = css_property_parser_helpers::ConsumeImage(
- range, &context,
+ range, context,
css_property_parser_helpers::ConsumeGeneratedImagePolicy::kForbid)) {
double num;
IntPoint hot_spot(-1, -1);
bool hot_spot_specified = false;
- if (css_property_parser_helpers::ConsumeNumberRaw(range, num)) {
+ if (css_property_parser_helpers::ConsumeNumberRaw(range, context, num)) {
hot_spot.SetX(clampTo<int>(num));
- if (!css_property_parser_helpers::ConsumeNumberRaw(range, num))
+ if (!css_property_parser_helpers::ConsumeNumberRaw(range, context, num))
return nullptr;
hot_spot.SetY(clampTo<int>(num));
hot_spot_specified = true;
@@ -2380,7 +2388,7 @@ const CSSValue* FillOpacity::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeAlphaValue(range);
+ return css_property_parser_helpers::ConsumeAlphaValue(range, context);
}
const CSSValue* FillOpacity::CSSValueFromComputedStyleInternal(
@@ -2422,7 +2430,7 @@ const CSSValue* FlexBasis::ParseSingleValue(
if (range.Peek().Id() == CSSValueID::kAuto)
return css_property_parser_helpers::ConsumeIdent(range);
return css_property_parser_helpers::ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
}
const CSSValue* FlexBasis::CSSValueFromComputedStyleInternal(
@@ -2443,9 +2451,9 @@ const CSSValue* FlexDirection::CSSValueFromComputedStyleInternal(
}
const CSSValue* FlexGrow::ParseSingleValue(CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeNumber(range,
+ return css_property_parser_helpers::ConsumeNumber(range, context,
kValueRangeNonNegative);
}
@@ -2460,9 +2468,9 @@ const CSSValue* FlexGrow::CSSValueFromComputedStyleInternal(
const CSSValue* FlexShrink::ParseSingleValue(
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeNumber(range,
+ return css_property_parser_helpers::ConsumeNumber(range, context,
kValueRangeNonNegative);
}
@@ -2497,7 +2505,7 @@ const CSSValue* FloodColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const blink::Color FloodColor::ColorIncludingFallback(
@@ -2522,7 +2530,7 @@ const CSSValue* FloodOpacity::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeAlphaValue(range);
+ return css_property_parser_helpers::ConsumeAlphaValue(range, context);
}
const CSSValue* FloodOpacity::CSSValueFromComputedStyleInternal(
@@ -2551,9 +2559,9 @@ const CSSValue* FontFamily::CSSValueFromComputedStyleInternal(
const CSSValue* FontFeatureSettings::ParseSingleValue(
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeFontFeatureSettings(range);
+ return css_parsing_utils::ConsumeFontFeatureSettings(range, context);
}
const CSSValue* FontFeatureSettings::CSSValueFromComputedStyleInternal(
@@ -2599,7 +2607,7 @@ const CSSValue* FontSizeAdjust::ParseSingleValue(
DCHECK(RuntimeEnabledFeatures::CSSFontSizeAdjustEnabled());
if (range.Peek().Id() == CSSValueID::kNone)
return css_property_parser_helpers::ConsumeIdent(range);
- return css_property_parser_helpers::ConsumeNumber(range,
+ return css_property_parser_helpers::ConsumeNumber(range, context,
kValueRangeNonNegative);
}
@@ -2634,7 +2642,7 @@ const CSSValue* FontStretch::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeFontStretch(range, context.Mode());
+ return css_parsing_utils::ConsumeFontStretch(range, context);
}
const CSSValue* FontStretch::CSSValueFromComputedStyleInternal(
@@ -2649,7 +2657,7 @@ const CSSValue* FontStyle::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeFontStyle(range, context.Mode());
+ return css_parsing_utils::ConsumeFontStyle(range, context);
}
const CSSValue* FontStyle::CSSValueFromComputedStyleInternal(
@@ -2757,7 +2765,8 @@ const CSSValue* FontVariantNumeric::CSSValueFromComputedStyleInternal(
namespace {
cssvalue::CSSFontVariationValue* ConsumeFontVariationTag(
- CSSParserTokenRange& range) {
+ CSSParserTokenRange& range,
+ const CSSParserContext& context) {
// Feature tag name consists of 4-letter characters.
static const wtf_size_t kTagNameLength = 4;
@@ -2777,7 +2786,7 @@ cssvalue::CSSFontVariationValue* ConsumeFontVariationTag(
}
double tag_value = 0;
- if (!css_property_parser_helpers::ConsumeNumberRaw(range, tag_value))
+ if (!css_property_parser_helpers::ConsumeNumberRaw(range, context, tag_value))
return nullptr;
return MakeGarbageCollected<cssvalue::CSSFontVariationValue>(
tag, clampTo<float>(tag_value));
@@ -2794,7 +2803,7 @@ const CSSValue* FontVariationSettings::ParseSingleValue(
CSSValueList* variation_settings = CSSValueList::CreateCommaSeparated();
do {
cssvalue::CSSFontVariationValue* font_variation_value =
- ConsumeFontVariationTag(range);
+ ConsumeFontVariationTag(range, context);
if (!font_variation_value)
return nullptr;
variation_settings->Append(*font_variation_value);
@@ -2826,7 +2835,7 @@ const CSSValue* FontWeight::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeFontWeight(range, context.Mode());
+ return css_parsing_utils::ConsumeFontWeight(range, context);
}
const CSSValue* FontWeight::CSSValueFromComputedStyleInternal(
@@ -2864,7 +2873,8 @@ const CSSValue* InternalEffectiveZoom::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
ValueRange value_range = kValueRangeNonNegative;
- return css_property_parser_helpers::ConsumeNumber(range, value_range);
+ return css_property_parser_helpers::ConsumeNumber(range, context,
+ value_range);
}
void InternalVisitedColor::ApplyInitial(StyleResolverState& state) const {
@@ -2873,8 +2883,8 @@ void InternalVisitedColor::ApplyInitial(StyleResolverState& state) const {
CSSIdentifierValue::Create(CSSValueID::kInitial));
return;
}
- auto color = ComputedStyleInitialValues::InitialColor();
- state.Style()->SetInternalVisitedColor(color);
+ state.Style()->SetInternalVisitedColor(
+ state.Style()->InitialColorForColorScheme());
}
void InternalVisitedColor::ApplyInherit(StyleResolverState& state) const {
@@ -2915,7 +2925,7 @@ const CSSValue* InternalVisitedColor::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_property_parser_helpers::ConsumeColor(
- range, context.Mode(), IsQuirksModeBehavior(context.Mode()));
+ range, context, IsQuirksModeBehavior(context.Mode()));
}
const CSSValue* GridAutoColumns::ParseSingleValue(
@@ -2923,8 +2933,7 @@ const CSSValue* GridAutoColumns::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeGridTrackList(
- range, context, context.Mode(),
- css_parsing_utils::TrackListType::kGridAuto);
+ range, context, css_parsing_utils::TrackListType::kGridAuto);
}
// Specs mention that getComputedStyle() should return the used value of the
@@ -3003,8 +3012,7 @@ const CSSValue* GridAutoRows::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeGridTrackList(
- range, context, context.Mode(),
- css_parsing_utils::TrackListType::kGridAuto);
+ range, context, css_parsing_utils::TrackListType::kGridAuto);
}
const CSSValue* GridAutoRows::CSSValueFromComputedStyleInternal(
@@ -3146,18 +3154,15 @@ void GridTemplateAreas::ApplyValue(StyleResolverState& state,
const NamedGridAreaMap& new_named_grid_areas =
grid_template_areas_value.GridAreaMap();
- NamedGridLinesMap named_grid_column_lines;
- NamedGridLinesMap named_grid_row_lines;
- StyleBuilderConverter::ConvertOrderedNamedGridLinesMapToNamedGridLinesMap(
- state.Style()->OrderedNamedGridColumnLines(), named_grid_column_lines);
- StyleBuilderConverter::ConvertOrderedNamedGridLinesMapToNamedGridLinesMap(
- state.Style()->OrderedNamedGridRowLines(), named_grid_row_lines);
+ NamedGridLinesMap implicit_named_grid_column_lines;
+ NamedGridLinesMap implicit_named_grid_row_lines;
StyleBuilderConverter::CreateImplicitNamedGridLinesFromGridArea(
- new_named_grid_areas, named_grid_column_lines, kForColumns);
+ new_named_grid_areas, implicit_named_grid_column_lines, kForColumns);
StyleBuilderConverter::CreateImplicitNamedGridLinesFromGridArea(
- new_named_grid_areas, named_grid_row_lines, kForRows);
- state.Style()->SetNamedGridColumnLines(named_grid_column_lines);
- state.Style()->SetNamedGridRowLines(named_grid_row_lines);
+ new_named_grid_areas, implicit_named_grid_row_lines, kForRows);
+ state.Style()->SetImplicitNamedGridColumnLines(
+ implicit_named_grid_column_lines);
+ state.Style()->SetImplicitNamedGridRowLines(implicit_named_grid_row_lines);
state.Style()->SetNamedGridArea(new_named_grid_areas);
state.Style()->SetNamedGridAreaRowCount(grid_template_areas_value.RowCount());
@@ -3169,8 +3174,7 @@ const CSSValue* GridTemplateColumns::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeGridTemplatesRowsOrColumns(range, context,
- context.Mode());
+ return css_parsing_utils::ConsumeGridTemplatesRowsOrColumns(range, context);
}
bool GridTemplateColumns::IsLayoutDependent(const ComputedStyle* style,
@@ -3191,8 +3195,7 @@ const CSSValue* GridTemplateRows::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeGridTemplatesRowsOrColumns(range, context,
- context.Mode());
+ return css_parsing_utils::ConsumeGridTemplatesRowsOrColumns(range, context);
}
bool GridTemplateRows::IsLayoutDependent(const ComputedStyle* style,
@@ -3249,11 +3252,8 @@ const CSSValue* ImageOrientation::ParseSingleValue(
DCHECK(RuntimeEnabledFeatures::ImageOrientationEnabled());
if (range.Peek().Id() == CSSValueID::kFromImage)
return css_property_parser_helpers::ConsumeIdent(range);
- if (range.Peek().GetType() != kNumberToken) {
- CSSPrimitiveValue* angle = css_property_parser_helpers::ConsumeAngle(
- range, &context, base::Optional<WebFeature>());
- if (angle && angle->GetDoubleValue() == 0)
- return angle;
+ if (range.Peek().Id() == CSSValueID::kNone) {
+ return css_property_parser_helpers::ConsumeIdent(range);
}
return nullptr;
}
@@ -3265,8 +3265,7 @@ const CSSValue* ImageOrientation::CSSValueFromComputedStyleInternal(
bool allow_visited_style) const {
if (style.RespectImageOrientation() == kRespectImageOrientation)
return CSSIdentifierValue::Create(CSSValueID::kFromImage);
- return CSSNumericLiteralValue::Create(0,
- CSSPrimitiveValue::UnitType::kDegrees);
+ return CSSIdentifierValue::Create(CSSValueID::kNone);
}
const CSSValue* ImageRendering::CSSValueFromComputedStyleInternal(
@@ -3294,8 +3293,7 @@ const CSSValue* InsetBlockEnd::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kForbid);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kForbid);
}
const CSSValue* InsetBlockStart::ParseSingleValue(
@@ -3303,8 +3301,7 @@ const CSSValue* InsetBlockStart::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kForbid);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kForbid);
}
const CSSValue* InsetInlineEnd::ParseSingleValue(
@@ -3312,8 +3309,7 @@ const CSSValue* InsetInlineEnd::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kForbid);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kForbid);
}
const CSSValue* InsetInlineStart::ParseSingleValue(
@@ -3321,8 +3317,7 @@ const CSSValue* InsetInlineStart::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kForbid);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kForbid);
}
const blink::Color InternalVisitedBackgroundColor::ColorIncludingFallback(
@@ -3351,7 +3346,7 @@ const CSSValue* InternalVisitedBackgroundColor::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_property_parser_helpers::ConsumeColor(
- range, context.Mode(), IsQuirksModeBehavior(context.Mode()));
+ range, context, IsQuirksModeBehavior(context.Mode()));
}
const blink::Color InternalVisitedBorderLeftColor::ColorIncludingFallback(
@@ -3487,7 +3482,7 @@ const CSSValue* InternalVisitedColumnRuleColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const blink::Color InternalVisitedOutlineColor::ColorIncludingFallback(
@@ -3525,7 +3520,7 @@ const CSSValue* InternalVisitedTextDecorationColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const blink::Color InternalVisitedTextEmphasisColor::ColorIncludingFallback(
@@ -3540,7 +3535,7 @@ const CSSValue* InternalVisitedTextEmphasisColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const blink::Color InternalVisitedTextFillColor::ColorIncludingFallback(
@@ -3555,7 +3550,7 @@ const CSSValue* InternalVisitedTextFillColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const blink::Color InternalVisitedTextStrokeColor::ColorIncludingFallback(
@@ -3570,7 +3565,7 @@ const CSSValue* InternalVisitedTextStrokeColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const CSSValue* Isolation::CSSValueFromComputedStyleInternal(
@@ -3671,7 +3666,7 @@ const CSSValue* Left::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeMarginOrOffset(
- range, context.Mode(),
+ range, context,
css_parsing_utils::UnitlessUnlessShorthand(local_context));
}
@@ -3710,7 +3705,7 @@ const CSSValue* LightingColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const blink::Color LightingColor::ColorIncludingFallback(
@@ -3743,7 +3738,7 @@ const CSSValue* LineHeight::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeLineHeight(range, context.Mode());
+ return css_parsing_utils::ConsumeLineHeight(range, context);
}
const CSSValue* LineHeight::CSSValueFromComputedStyleInternal(
@@ -3758,7 +3753,7 @@ const CSSValue* LineHeightStep::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeLength(range, context.Mode(),
+ return css_property_parser_helpers::ConsumeLength(range, context,
kValueRangeNonNegative);
}
@@ -3774,7 +3769,7 @@ const CSSValue* ListStyleImage::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeImageOrNone(range, &context);
+ return css_property_parser_helpers::ConsumeImageOrNone(range, context);
}
const CSSValue* ListStyleImage::CSSValueFromComputedStyleInternal(
@@ -3858,8 +3853,7 @@ const CSSValue* MarginBlockEnd::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kForbid);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kForbid);
}
bool MarginBlockStart::IsLayoutDependent(const ComputedStyle* style,
@@ -3872,8 +3866,7 @@ const CSSValue* MarginBlockStart::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kForbid);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kForbid);
}
const CSSValue* MarginBottom::ParseSingleValue(
@@ -3881,8 +3874,7 @@ const CSSValue* MarginBottom::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kAllow);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kAllow);
}
bool MarginBottom::IsLayoutDependent(const ComputedStyle* style,
@@ -3915,8 +3907,7 @@ const CSSValue* MarginInlineEnd::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kForbid);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kForbid);
}
bool MarginInlineStart::IsLayoutDependent(const ComputedStyle* style,
@@ -3929,8 +3920,7 @@ const CSSValue* MarginInlineStart::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kForbid);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kForbid);
}
const CSSValue* MarginLeft::ParseSingleValue(
@@ -3938,8 +3928,7 @@ const CSSValue* MarginLeft::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kAllow);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kAllow);
}
bool MarginLeft::IsLayoutDependent(const ComputedStyle* style,
@@ -3967,8 +3956,7 @@ const CSSValue* MarginRight::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kAllow);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kAllow);
}
bool MarginRight::IsLayoutDependent(const ComputedStyle* style,
@@ -4010,8 +3998,7 @@ const CSSValue* MarginTop::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kAllow);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kAllow);
}
bool MarginTop::IsLayoutDependent(const ComputedStyle* style,
@@ -4039,7 +4026,7 @@ const CSSValue* MarkerEnd::ParseSingleValue(
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kNone)
return css_property_parser_helpers::ConsumeIdent(range);
- return css_property_parser_helpers::ConsumeUrl(range, &context);
+ return css_property_parser_helpers::ConsumeUrl(range, context);
}
const CSSValue* MarkerEnd::CSSValueFromComputedStyleInternal(
@@ -4056,7 +4043,7 @@ const CSSValue* MarkerMid::ParseSingleValue(
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kNone)
return css_property_parser_helpers::ConsumeIdent(range);
- return css_property_parser_helpers::ConsumeUrl(range, &context);
+ return css_property_parser_helpers::ConsumeUrl(range, context);
}
const CSSValue* MarkerMid::CSSValueFromComputedStyleInternal(
@@ -4073,7 +4060,7 @@ const CSSValue* MarkerStart::ParseSingleValue(
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kNone)
return css_property_parser_helpers::ConsumeIdent(range);
- return css_property_parser_helpers::ConsumeUrl(range, &context);
+ return css_property_parser_helpers::ConsumeUrl(range, context);
}
const CSSValue* MarkerStart::CSSValueFromComputedStyleInternal(
@@ -4090,7 +4077,7 @@ const CSSValue* Mask::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kNone)
return css_property_parser_helpers::ConsumeIdent(range);
- return css_property_parser_helpers::ConsumeUrl(range, &context);
+ return css_property_parser_helpers::ConsumeUrl(range, context);
}
const CSSValue* Mask::CSSValueFromComputedStyleInternal(
@@ -4140,6 +4127,14 @@ const CSSValue* MaskType::CSSValueFromComputedStyleInternal(
return CSSIdentifierValue::Create(svg_style.MaskType());
}
+const CSSValue* MathStyle::CSSValueFromComputedStyleInternal(
+ const ComputedStyle& style,
+ const SVGComputedStyle&,
+ const LayoutObject*,
+ bool allow_visited_style) const {
+ return CSSIdentifierValue::Create(style.MathStyle());
+}
+
const CSSValue* MaxBlockSize::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
@@ -4161,7 +4156,7 @@ const CSSValue* MaxHeight::CSSValueFromComputedStyleInternal(
const LayoutObject*,
bool allow_visited_style) const {
const Length& max_height = style.MaxHeight();
- if (max_height.IsMaxSizeNone())
+ if (max_height.IsNone())
return CSSIdentifierValue::Create(CSSValueID::kNone);
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(max_height, style);
}
@@ -4186,7 +4181,7 @@ const CSSValue* MaxWidth::CSSValueFromComputedStyleInternal(
const LayoutObject*,
bool allow_visited_style) const {
const Length& max_width = style.MaxWidth();
- if (max_width.IsMaxSizeNone())
+ if (max_width.IsNone())
return CSSIdentifierValue::Create(CSSValueID::kNone);
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(max_width, style);
}
@@ -4304,8 +4299,8 @@ const CSSValue* OffsetDistance::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeAll);
+ return css_property_parser_helpers::ConsumeLengthOrPercent(range, context,
+ kValueRangeAll);
}
const CSSValue* OffsetDistance::CSSValueFromComputedStyleInternal(
@@ -4381,7 +4376,7 @@ const CSSValue* OffsetRotate::CSSValueFromComputedStyleInternal(
const CSSValue* Opacity::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeAlphaValue(range);
+ return css_property_parser_helpers::ConsumeAlphaValue(range, context);
}
const CSSValue* Opacity::CSSValueFromComputedStyleInternal(
@@ -4396,7 +4391,7 @@ const CSSValue* Opacity::CSSValueFromComputedStyleInternal(
const CSSValue* Order::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeInteger(range);
+ return css_property_parser_helpers::ConsumeInteger(range, context);
}
const CSSValue* Order::CSSValueFromComputedStyleInternal(
@@ -4408,10 +4403,19 @@ const CSSValue* Order::CSSValueFromComputedStyleInternal(
CSSPrimitiveValue::UnitType::kNumber);
}
+const CSSValue* OriginTrialTestProperty::CSSValueFromComputedStyleInternal(
+ const ComputedStyle& style,
+ const SVGComputedStyle&,
+ const LayoutObject*,
+ bool allow_visited_style) const {
+ return CSSIdentifierValue::Create(style.OriginTrialTestProperty());
+ ;
+}
+
const CSSValue* Orphans::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumePositiveInteger(range);
+ return css_property_parser_helpers::ConsumePositiveInteger(range, context);
}
const CSSValue* Orphans::CSSValueFromComputedStyleInternal(
@@ -4430,7 +4434,7 @@ const CSSValue* OutlineColor::ParseSingleValue(
// Allow the special focus color even in HTML Standard parsing mode.
if (range.Peek().Id() == CSSValueID::kWebkitFocusRingColor)
return css_property_parser_helpers::ConsumeIdent(range);
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const blink::Color OutlineColor::ColorIncludingFallback(
@@ -4455,7 +4459,7 @@ const CSSValue* OutlineOffset::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeLength(range, context.Mode(),
+ return css_property_parser_helpers::ConsumeLength(range, context,
kValueRangeAll);
}
@@ -4502,8 +4506,7 @@ const CSSValue* OutlineWidth::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_property_parser_helpers::ConsumeLineWidth(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kForbid);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kForbid);
}
const CSSValue* OutlineWidth::CSSValueFromComputedStyleInternal(
@@ -4572,7 +4575,7 @@ const CSSValue* PaddingBlockEnd::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeNonNegative,
+ range, context, kValueRangeNonNegative,
css_property_parser_helpers::UnitlessQuirk::kForbid);
}
@@ -4586,7 +4589,7 @@ const CSSValue* PaddingBlockStart::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeNonNegative,
+ range, context, kValueRangeNonNegative,
css_property_parser_helpers::UnitlessQuirk::kForbid);
}
@@ -4595,7 +4598,7 @@ const CSSValue* PaddingBottom::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeNonNegative,
+ range, context, kValueRangeNonNegative,
css_property_parser_helpers::UnitlessQuirk::kAllow);
}
@@ -4629,7 +4632,7 @@ const CSSValue* PaddingInlineEnd::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeNonNegative,
+ range, context, kValueRangeNonNegative,
css_property_parser_helpers::UnitlessQuirk::kForbid);
}
@@ -4643,7 +4646,7 @@ const CSSValue* PaddingInlineStart::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeNonNegative,
+ range, context, kValueRangeNonNegative,
css_property_parser_helpers::UnitlessQuirk::kForbid);
}
@@ -4652,7 +4655,7 @@ const CSSValue* PaddingLeft::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeNonNegative,
+ range, context, kValueRangeNonNegative,
css_property_parser_helpers::UnitlessQuirk::kAllow);
}
@@ -4681,7 +4684,7 @@ const CSSValue* PaddingRight::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeNonNegative,
+ range, context, kValueRangeNonNegative,
css_property_parser_helpers::UnitlessQuirk::kAllow);
}
@@ -4710,7 +4713,7 @@ const CSSValue* PaddingTop::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeNonNegative,
+ range, context, kValueRangeNonNegative,
css_property_parser_helpers::UnitlessQuirk::kAllow);
}
@@ -4742,6 +4745,16 @@ const CSSValue* Page::ParseSingleValue(CSSParserTokenRange& range,
return css_property_parser_helpers::ConsumeCustomIdent(range, context);
}
+const CSSValue* Page::CSSValueFromComputedStyleInternal(
+ const ComputedStyle& style,
+ const SVGComputedStyle&,
+ const LayoutObject*,
+ bool allow_visited_style) const {
+ if (style.Page().IsNull())
+ return CSSIdentifierValue::Create(CSSValueID::kAuto);
+ return MakeGarbageCollected<CSSCustomIdentValue>(style.Page());
+}
+
const CSSValue* PaintOrder::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
@@ -4839,11 +4852,12 @@ const CSSValue* Perspective::ParseSingleValue(
if (range.Peek().Id() == CSSValueID::kNone)
return css_property_parser_helpers::ConsumeIdent(range);
CSSPrimitiveValue* parsed_value = css_property_parser_helpers::ConsumeLength(
- range, context.Mode(), kValueRangeAll);
+ range, context, kValueRangeAll);
bool use_legacy_parsing = localContext.UseAliasParsing();
if (!parsed_value && use_legacy_parsing) {
double perspective;
- if (!css_property_parser_helpers::ConsumeNumberRaw(range, perspective))
+ if (!css_property_parser_helpers::ConsumeNumberRaw(range, context,
+ perspective))
return nullptr;
context.Count(WebFeature::kUnitlessPerspectiveInPerspectiveProperty);
parsed_value = CSSNumericLiteralValue::Create(
@@ -4985,60 +4999,6 @@ const CSSValue* R::CSSValueFromComputedStyleInternal(
style);
}
-const CSSValue* RenderSubtree::ParseSingleValue(
- CSSParserTokenRange& range,
- const CSSParserContext& context,
- const CSSParserLocalContext&) const {
- CSSValueID id = range.Peek().Id();
- if (id == CSSValueID::kNone)
- return css_property_parser_helpers::ConsumeIdent(range);
-
- CSSValueList* list = CSSValueList::CreateSpaceSeparated();
- bool has_invisible = false;
- bool has_skip_activation = false;
- bool has_skip_viewport_activation = false;
- while (true) {
- id = range.Peek().Id();
- if (id == CSSValueID::kInvisible && !has_invisible) {
- list->Append(*css_property_parser_helpers::ConsumeIdent(range));
- has_invisible = true;
- } else if (id == CSSValueID::kSkipActivation && !has_skip_activation) {
- list->Append(*css_property_parser_helpers::ConsumeIdent(range));
- has_skip_activation = true;
- } else if (id == CSSValueID::kSkipViewportActivation &&
- !has_skip_viewport_activation) {
- list->Append(*css_property_parser_helpers::ConsumeIdent(range));
- has_skip_viewport_activation = true;
- } else {
- break;
- }
- }
- if (!list->length())
- return nullptr;
- return list;
-}
-
-const CSSValue* RenderSubtree::CSSValueFromComputedStyleInternal(
- const ComputedStyle& style,
- const SVGComputedStyle&,
- const LayoutObject*,
- bool allow_visited_style) const {
- if (style.RenderSubtree() == RenderSubtreeFlags::kNone)
- return CSSIdentifierValue::Create(CSSValueID::kNone);
-
- CSSValueList* list = CSSValueList::CreateSpaceSeparated();
- if (style.RenderSubtreeInvisible())
- list->Append(*CSSIdentifierValue::Create(CSSValueID::kInvisible));
- if (style.RenderSubtreeSkipActivation())
- list->Append(*CSSIdentifierValue::Create(CSSValueID::kSkipActivation));
- if (style.RenderSubtreeSkipViewportActivation()) {
- list->Append(
- *CSSIdentifierValue::Create(CSSValueID::kSkipViewportActivation));
- }
- DCHECK(list->length());
- return list;
-}
-
const CSSValue* Resize::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const SVGComputedStyle&,
@@ -5069,7 +5029,7 @@ const CSSValue* Right::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeMarginOrOffset(
- range, context.Mode(),
+ range, context,
css_parsing_utils::UnitlessUnlessShorthand(local_context));
}
@@ -5099,9 +5059,9 @@ const CSSValue* Rotate::ParseSingleValue(CSSParserTokenRange& range,
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
CSSValue* rotation = css_property_parser_helpers::ConsumeAngle(
- range, &context, base::Optional<WebFeature>());
+ range, context, base::Optional<WebFeature>());
- CSSValue* axis = css_property_parser_helpers::ConsumeAxis(range);
+ CSSValue* axis = css_property_parser_helpers::ConsumeAxis(range, context);
if (axis)
list->Append(*axis);
else if (!rotation)
@@ -5109,7 +5069,7 @@ const CSSValue* Rotate::ParseSingleValue(CSSParserTokenRange& range,
if (!rotation) {
rotation = css_property_parser_helpers::ConsumeAngle(
- range, &context, base::Optional<WebFeature>());
+ range, context, base::Optional<WebFeature>());
if (!rotation)
return nullptr;
}
@@ -5198,19 +5158,19 @@ const CSSValue* Scale::ParseSingleValue(CSSParserTokenRange& range,
if (id == CSSValueID::kNone)
return css_property_parser_helpers::ConsumeIdent(range);
- CSSValue* x_scale =
- css_property_parser_helpers::ConsumeNumber(range, kValueRangeAll);
+ CSSValue* x_scale = css_property_parser_helpers::ConsumeNumber(
+ range, context, kValueRangeAll);
if (!x_scale)
return nullptr;
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
list->Append(*x_scale);
- CSSValue* y_scale =
- css_property_parser_helpers::ConsumeNumber(range, kValueRangeAll);
+ CSSValue* y_scale = css_property_parser_helpers::ConsumeNumber(
+ range, context, kValueRangeAll);
if (y_scale) {
- CSSValue* z_scale =
- css_property_parser_helpers::ConsumeNumber(range, kValueRangeAll);
+ CSSValue* z_scale = css_property_parser_helpers::ConsumeNumber(
+ range, context, kValueRangeAll);
if (z_scale) {
list->Append(*y_scale);
list->Append(*z_scale);
@@ -5318,7 +5278,7 @@ const CSSValue* ScrollMarginBlockEnd::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return ConsumeLength(range, context.Mode(), kValueRangeAll,
+ return ConsumeLength(range, context, kValueRangeAll,
css_property_parser_helpers::UnitlessQuirk::kForbid);
}
@@ -5326,7 +5286,7 @@ const CSSValue* ScrollMarginBlockStart::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return ConsumeLength(range, context.Mode(), kValueRangeAll,
+ return ConsumeLength(range, context, kValueRangeAll,
css_property_parser_helpers::UnitlessQuirk::kForbid);
}
@@ -5334,7 +5294,7 @@ const CSSValue* ScrollMarginBottom::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return ConsumeLength(range, context.Mode(), kValueRangeAll,
+ return ConsumeLength(range, context, kValueRangeAll,
css_property_parser_helpers::UnitlessQuirk::kForbid);
}
@@ -5350,7 +5310,7 @@ const CSSValue* ScrollMarginInlineEnd::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return ConsumeLength(range, context.Mode(), kValueRangeAll,
+ return ConsumeLength(range, context, kValueRangeAll,
css_property_parser_helpers::UnitlessQuirk::kForbid);
}
@@ -5358,7 +5318,7 @@ const CSSValue* ScrollMarginInlineStart::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return ConsumeLength(range, context.Mode(), kValueRangeAll,
+ return ConsumeLength(range, context, kValueRangeAll,
css_property_parser_helpers::UnitlessQuirk::kForbid);
}
@@ -5366,7 +5326,7 @@ const CSSValue* ScrollMarginLeft::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return ConsumeLength(range, context.Mode(), kValueRangeAll,
+ return ConsumeLength(range, context, kValueRangeAll,
css_property_parser_helpers::UnitlessQuirk::kForbid);
}
@@ -5382,7 +5342,7 @@ const CSSValue* ScrollMarginRight::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return ConsumeLength(range, context.Mode(), kValueRangeAll,
+ return ConsumeLength(range, context, kValueRangeAll,
css_property_parser_helpers::UnitlessQuirk::kForbid);
}
@@ -5398,7 +5358,7 @@ const CSSValue* ScrollMarginTop::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return ConsumeLength(range, context.Mode(), kValueRangeAll,
+ return ConsumeLength(range, context, kValueRangeAll,
css_property_parser_helpers::UnitlessQuirk::kForbid);
}
@@ -5414,21 +5374,21 @@ const CSSValue* ScrollPaddingBlockEnd::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeScrollPadding(range);
+ return css_parsing_utils::ConsumeScrollPadding(range, context);
}
const CSSValue* ScrollPaddingBlockStart::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeScrollPadding(range);
+ return css_parsing_utils::ConsumeScrollPadding(range, context);
}
const CSSValue* ScrollPaddingBottom::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeScrollPadding(range);
+ return css_parsing_utils::ConsumeScrollPadding(range, context);
}
const CSSValue* ScrollPaddingBottom::CSSValueFromComputedStyleInternal(
@@ -5444,21 +5404,21 @@ const CSSValue* ScrollPaddingInlineEnd::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeScrollPadding(range);
+ return css_parsing_utils::ConsumeScrollPadding(range, context);
}
const CSSValue* ScrollPaddingInlineStart::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeScrollPadding(range);
+ return css_parsing_utils::ConsumeScrollPadding(range, context);
}
const CSSValue* ScrollPaddingLeft::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeScrollPadding(range);
+ return css_parsing_utils::ConsumeScrollPadding(range, context);
}
const CSSValue* ScrollPaddingLeft::CSSValueFromComputedStyleInternal(
@@ -5474,7 +5434,7 @@ const CSSValue* ScrollPaddingRight::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeScrollPadding(range);
+ return css_parsing_utils::ConsumeScrollPadding(range, context);
}
const CSSValue* ScrollPaddingRight::CSSValueFromComputedStyleInternal(
@@ -5490,7 +5450,7 @@ const CSSValue* ScrollPaddingTop::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeScrollPadding(range);
+ return css_parsing_utils::ConsumeScrollPadding(range, context);
}
const CSSValue* ScrollPaddingTop::CSSValueFromComputedStyleInternal(
@@ -5579,7 +5539,7 @@ const CSSValue* ShapeImageThreshold::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeAlphaValue(range);
+ return css_property_parser_helpers::ConsumeAlphaValue(range, context);
}
const CSSValue* ShapeImageThreshold::CSSValueFromComputedStyleInternal(
@@ -5596,7 +5556,7 @@ const CSSValue* ShapeMargin::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_property_parser_helpers::ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
}
const CSSValue* ShapeMargin::CSSValueFromComputedStyleInternal(
@@ -5612,7 +5572,7 @@ const CSSValue* ShapeOutside::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (CSSValue* image_value =
- css_property_parser_helpers::ConsumeImageOrNone(range, &context))
+ css_property_parser_helpers::ConsumeImageOrNone(range, context))
return image_value;
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
CSSValue* box_value = css_property_parser_helpers::ConsumeShapeBox(range);
@@ -5650,8 +5610,8 @@ const CSSValue* ShapeRendering::CSSValueFromComputedStyleInternal(
static CSSValue* ConsumePageSize(CSSParserTokenRange& range) {
return css_property_parser_helpers::ConsumeIdent<
CSSValueID::kA3, CSSValueID::kA4, CSSValueID::kA5, CSSValueID::kB4,
- CSSValueID::kB5, CSSValueID::kLedger, CSSValueID::kLegal,
- CSSValueID::kLetter>(range);
+ CSSValueID::kB5, CSSValueID::kJisB5, CSSValueID::kJisB4,
+ CSSValueID::kLedger, CSSValueID::kLegal, CSSValueID::kLetter>(range);
}
static float MmToPx(float mm) {
@@ -5672,6 +5632,10 @@ static FloatSize GetPageSizeFromName(const CSSIdentifierValue& page_size_name) {
return FloatSize(MmToPx(176), MmToPx(250));
case CSSValueID::kB4:
return FloatSize(MmToPx(250), MmToPx(353));
+ case CSSValueID::kJisB5:
+ return FloatSize(MmToPx(182), MmToPx(257));
+ case CSSValueID::kJisB4:
+ return FloatSize(MmToPx(257), MmToPx(364));
case CSSValueID::kLetter:
return FloatSize(InchToPx(8.5), InchToPx(11));
case CSSValueID::kLegal:
@@ -5695,9 +5659,9 @@ const CSSValue* Size::ParseSingleValue(CSSParserTokenRange& range,
}
if (CSSValue* width = css_property_parser_helpers::ConsumeLength(
- range, context.Mode(), kValueRangeNonNegative)) {
+ range, context, kValueRangeNonNegative)) {
CSSValue* height = css_property_parser_helpers::ConsumeLength(
- range, context.Mode(), kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
result->Append(*width);
if (height)
result->Append(*height);
@@ -5727,7 +5691,7 @@ void Size::ApplyInherit(StyleResolverState& state) const {}
void Size::ApplyValue(StyleResolverState& state, const CSSValue& value) const {
state.Style()->ResetPageSizeType();
FloatSize size;
- EPageSizeType page_size_type = EPageSizeType::kAuto;
+ PageSizeType page_size_type = PageSizeType::kAuto;
const auto& list = To<CSSValueList>(value);
if (list.length() == 2) {
// <length>{2} | <page-size> <orientation>
@@ -5752,7 +5716,7 @@ void Size::ApplyValue(StyleResolverState& state, const CSSValue& value) const {
if (To<CSSIdentifierValue>(second).GetValueID() == CSSValueID::kLandscape)
size = size.TransposedSize();
}
- page_size_type = EPageSizeType::kResolved;
+ page_size_type = PageSizeType::kFixed;
} else {
DCHECK_EQ(list.length(), 1U);
// <length> | auto | <page-size> | [ portrait | landscape]
@@ -5760,7 +5724,7 @@ void Size::ApplyValue(StyleResolverState& state, const CSSValue& value) const {
auto* first_primitive_value = DynamicTo<CSSPrimitiveValue>(first);
if (first_primitive_value && first_primitive_value->IsLength()) {
// <length>
- page_size_type = EPageSizeType::kResolved;
+ page_size_type = PageSizeType::kFixed;
float width = first_primitive_value->ComputeLength<float>(
state.CssToLengthConversionData().CopyWithAdjustedZoom(1.0));
size = FloatSize(width, width);
@@ -5768,17 +5732,17 @@ void Size::ApplyValue(StyleResolverState& state, const CSSValue& value) const {
const auto& ident = To<CSSIdentifierValue>(first);
switch (ident.GetValueID()) {
case CSSValueID::kAuto:
- page_size_type = EPageSizeType::kAuto;
+ page_size_type = PageSizeType::kAuto;
break;
case CSSValueID::kPortrait:
- page_size_type = EPageSizeType::kPortrait;
+ page_size_type = PageSizeType::kPortrait;
break;
case CSSValueID::kLandscape:
- page_size_type = EPageSizeType::kLandscape;
+ page_size_type = PageSizeType::kLandscape;
break;
default:
// <page-size>
- page_size_type = EPageSizeType::kResolved;
+ page_size_type = PageSizeType::kFixed;
size = GetPageSizeFromName(ident);
}
}
@@ -5799,7 +5763,7 @@ const CSSValue* StopColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const blink::Color StopColor::ColorIncludingFallback(
@@ -5823,7 +5787,7 @@ const CSSValue* StopOpacity::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeAlphaValue(range);
+ return css_property_parser_helpers::ConsumeAlphaValue(range, context);
}
const CSSValue* StopOpacity::CSSValueFromComputedStyleInternal(
@@ -5858,11 +5822,12 @@ const CSSValue* StrokeDasharray::ParseSingleValue(
if (id == CSSValueID::kNone)
return css_property_parser_helpers::ConsumeIdent(range);
+ CSSParserContext::ParserModeOverridingScope scope(context, kSVGAttributeMode);
CSSValueList* dashes = CSSValueList::CreateCommaSeparated();
do {
CSSPrimitiveValue* dash =
css_property_parser_helpers::ConsumeLengthOrPercent(
- range, kSVGAttributeMode, kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
if (!dash ||
(css_property_parser_helpers::ConsumeCommaIncludingWhitespace(range) &&
range.AtEnd()))
@@ -5883,10 +5848,11 @@ const CSSValue* StrokeDasharray::CSSValueFromComputedStyleInternal(
const CSSValue* StrokeDashoffset::ParseSingleValue(
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
+ CSSParserContext::ParserModeOverridingScope scope(context, kSVGAttributeMode);
return css_property_parser_helpers::ConsumeLengthOrPercent(
- range, kSVGAttributeMode, kValueRangeAll,
+ range, context, kValueRangeAll,
css_property_parser_helpers::UnitlessQuirk::kForbid);
}
@@ -5919,7 +5885,7 @@ const CSSValue* StrokeMiterlimit::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeNumber(range,
+ return css_property_parser_helpers::ConsumeNumber(range, context,
kValueRangeNonNegative);
}
@@ -5936,7 +5902,7 @@ const CSSValue* StrokeOpacity::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeAlphaValue(range);
+ return css_property_parser_helpers::ConsumeAlphaValue(range, context);
}
const CSSValue* StrokeOpacity::CSSValueFromComputedStyleInternal(
@@ -5950,10 +5916,11 @@ const CSSValue* StrokeOpacity::CSSValueFromComputedStyleInternal(
const CSSValue* StrokeWidth::ParseSingleValue(
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
+ CSSParserContext::ParserModeOverridingScope scope(context, kSVGAttributeMode);
return css_property_parser_helpers::ConsumeLengthOrPercent(
- range, kSVGAttributeMode, kValueRangeNonNegative,
+ range, context, kValueRangeNonNegative,
css_property_parser_helpers::UnitlessQuirk::kForbid);
}
@@ -5962,22 +5929,44 @@ const CSSValue* StrokeWidth::CSSValueFromComputedStyleInternal(
const SVGComputedStyle& svg_style,
const LayoutObject*,
bool allow_visited_style) const {
- const Length& length = svg_style.StrokeWidth().length();
- if (length.IsFixed()) {
- return CSSNumericLiteralValue::Create(length.Value(),
- CSSPrimitiveValue::UnitType::kPixels);
+ // We store the unzoomed stroke-width value using ConvertUnzoomedLength().
+ // Don't apply zoom here either.
+ return CSSValue::Create(svg_style.StrokeWidth().length(), 1);
+}
+
+const CSSValue* SubtreeVisibility::CSSValueFromComputedStyleInternal(
+ const ComputedStyle& style,
+ const SVGComputedStyle&,
+ const LayoutObject*,
+ bool allow_visited_style) const {
+ return CSSIdentifierValue::Create(style.SubtreeVisibility());
+}
+
+const CSSValue* SubtreeVisibility::ParseSingleValue(
+ CSSParserTokenRange& range,
+ const CSSParserContext& context,
+ const CSSParserLocalContext&) const {
+ auto id = range.Peek().Id();
+ if (id == CSSValueID::kHiddenMatchable &&
+ !RuntimeEnabledFeatures::CSSSubtreeVisibilityHiddenMatchableEnabled()) {
+ return nullptr;
+ }
+ if (!css_property_parser_helpers::IdentMatches<
+ CSSValueID::kVisible, CSSValueID::kAuto, CSSValueID::kHidden,
+ CSSValueID::kHiddenMatchable>(id)) {
+ return nullptr;
}
- return CSSValue::Create(length, style.EffectiveZoom());
+ return css_property_parser_helpers::ConsumeIdent(range);
}
const CSSValue* TabSize::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- CSSPrimitiveValue* parsed_value =
- css_property_parser_helpers::ConsumeNumber(range, kValueRangeNonNegative);
+ CSSPrimitiveValue* parsed_value = css_property_parser_helpers::ConsumeNumber(
+ range, context, kValueRangeNonNegative);
if (parsed_value)
return parsed_value;
- return css_property_parser_helpers::ConsumeLength(range, context.Mode(),
+ return css_property_parser_helpers::ConsumeLength(range, context,
kValueRangeNonNegative);
}
@@ -6063,7 +6052,7 @@ const CSSValue* TextDecorationColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const blink::Color TextDecorationColor::ColorIncludingFallback(
@@ -6129,7 +6118,7 @@ const CSSValue* TextIndent::ParseSingleValue(
do {
if (!length_percentage) {
length_percentage = css_property_parser_helpers::ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeAll,
+ range, context, kValueRangeAll,
css_property_parser_helpers::UnitlessQuirk::kAllow);
if (length_percentage) {
continue;
@@ -6269,7 +6258,7 @@ const CSSValue* TextShadow::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeShadow(
- range, context.Mode(), css_parsing_utils::AllowInsetAndSpread::kForbid);
+ range, context, css_parsing_utils::AllowInsetAndSpread::kForbid);
}
const CSSValue* TextShadow::CSSValueFromComputedStyleInternal(
@@ -6289,7 +6278,7 @@ const CSSValue* TextSizeAdjust::ParseSingleValue(
return css_property_parser_helpers::ConsumeIdent(range);
if (range.Peek().Id() == CSSValueID::kNone)
return css_property_parser_helpers::ConsumeIdent(range);
- return css_property_parser_helpers::ConsumePercent(range,
+ return css_property_parser_helpers::ConsumePercent(range, context,
kValueRangeNonNegative);
}
@@ -6313,7 +6302,8 @@ const CSSValue* TextTransform::CSSValueFromComputedStyleInternal(
return CSSIdentifierValue::Create(style.TextTransform());
}
-// auto | [ under || [ left | right ] ]
+// https://drafts.csswg.org/css-text-decor-4/#text-underline-position-property
+// auto | [ from-font | under ] || [ left | right ] - default: auto
const CSSValue* TextUnderlinePosition::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
@@ -6321,21 +6311,29 @@ const CSSValue* TextUnderlinePosition::ParseSingleValue(
if (range.Peek().Id() == CSSValueID::kAuto)
return css_property_parser_helpers::ConsumeIdent(range);
- CSSIdentifierValue* under_value =
- css_property_parser_helpers::ConsumeIdent<CSSValueID::kUnder>(range);
+ CSSIdentifierValue* from_font_or_under_value =
+ RuntimeEnabledFeatures::UnderlineOffsetThicknessEnabled()
+ ? css_property_parser_helpers::ConsumeIdent<CSSValueID::kFromFont,
+ CSSValueID::kUnder>(range)
+ : css_property_parser_helpers::ConsumeIdent<CSSValueID::kUnder>(
+ range);
CSSIdentifierValue* left_or_right_value =
css_property_parser_helpers::ConsumeIdent<CSSValueID::kLeft,
CSSValueID::kRight>(range);
- if (left_or_right_value && !under_value) {
- under_value =
- css_property_parser_helpers::ConsumeIdent<CSSValueID::kUnder>(range);
+ if (left_or_right_value && !from_font_or_under_value) {
+ from_font_or_under_value =
+ RuntimeEnabledFeatures::UnderlineOffsetThicknessEnabled()
+ ? css_property_parser_helpers::ConsumeIdent<CSSValueID::kFromFont,
+ CSSValueID::kUnder>(
+ range)
+ : css_property_parser_helpers::ConsumeIdent<CSSValueID::kUnder>(
+ range);
}
- if (!under_value && !left_or_right_value) {
+ if (!from_font_or_under_value && !left_or_right_value)
return nullptr;
- }
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
- if (under_value)
- list->Append(*under_value);
+ if (from_font_or_under_value)
+ list->Append(*from_font_or_under_value);
if (left_or_right_value)
list->Append(*left_or_right_value);
return list;
@@ -6349,6 +6347,8 @@ const CSSValue* TextUnderlinePosition::CSSValueFromComputedStyleInternal(
auto text_underline_position = style.TextUnderlinePosition();
if (text_underline_position == kTextUnderlinePositionAuto)
return CSSIdentifierValue::Create(CSSValueID::kAuto);
+ if (text_underline_position == kTextUnderlinePositionFromFont)
+ return CSSIdentifierValue::Create(CSSValueID::kFromFont);
if (text_underline_position == kTextUnderlinePositionUnder)
return CSSIdentifierValue::Create(CSSValueID::kUnder);
if (text_underline_position == kTextUnderlinePositionLeft)
@@ -6357,8 +6357,12 @@ const CSSValue* TextUnderlinePosition::CSSValueFromComputedStyleInternal(
return CSSIdentifierValue::Create(CSSValueID::kRight);
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
- DCHECK(text_underline_position & kTextUnderlinePositionUnder);
- list->Append(*CSSIdentifierValue::Create(CSSValueID::kUnder));
+ if (text_underline_position & kTextUnderlinePositionFromFont) {
+ list->Append(*CSSIdentifierValue::Create(CSSValueID::kFromFont));
+ } else {
+ DCHECK(text_underline_position & kTextUnderlinePositionUnder);
+ list->Append(*CSSIdentifierValue::Create(CSSValueID::kUnder));
+ }
if (text_underline_position & kTextUnderlinePositionLeft)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kLeft));
if (text_underline_position & kTextUnderlinePositionRight)
@@ -6372,7 +6376,7 @@ const CSSValue* Top::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeMarginOrOffset(
- range, context.Mode(),
+ range, context,
css_parsing_utils::UnitlessUnlessShorthand(local_context));
}
@@ -6490,14 +6494,13 @@ const CSSValue* TransformOrigin::ParseSingleValue(
CSSValue* result_x = nullptr;
CSSValue* result_y = nullptr;
if (css_property_parser_helpers::ConsumeOneOrTwoValuedPosition(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kForbid, result_x,
- result_y)) {
+ range, context, css_property_parser_helpers::UnitlessQuirk::kForbid,
+ result_x, result_y)) {
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
list->Append(*result_x);
list->Append(*result_y);
CSSValue* result_z = css_property_parser_helpers::ConsumeLength(
- range, context.Mode(), kValueRangeAll);
+ range, context, kValueRangeAll);
if (result_z)
list->Append(*result_z);
return list;
@@ -6549,10 +6552,10 @@ const CSSValue* TransformStyle::CSSValueFromComputedStyleInternal(
const CSSValue* TransitionDelay::ParseSingleValue(
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_property_parser_helpers::ConsumeCommaSeparatedList(
- css_property_parser_helpers::ConsumeTime, range, kValueRangeAll);
+ css_property_parser_helpers::ConsumeTime, range, context, kValueRangeAll);
}
const CSSValue* TransitionDelay::CSSValueFromComputedStyleInternal(
@@ -6573,10 +6576,11 @@ const CSSValue* TransitionDelay::InitialValue() const {
const CSSValue* TransitionDuration::ParseSingleValue(
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_property_parser_helpers::ConsumeCommaSeparatedList(
- css_property_parser_helpers::ConsumeTime, range, kValueRangeNonNegative);
+ css_property_parser_helpers::ConsumeTime, range, context,
+ kValueRangeNonNegative);
}
const CSSValue* TransitionDuration::CSSValueFromComputedStyleInternal(
@@ -6622,10 +6626,10 @@ const CSSValue* TransitionProperty::InitialValue() const {
const CSSValue* TransitionTimingFunction::ParseSingleValue(
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_property_parser_helpers::ConsumeCommaSeparatedList(
- css_parsing_utils::ConsumeAnimationTimingFunction, range);
+ css_parsing_utils::ConsumeAnimationTimingFunction, range, context);
}
const CSSValue* TransitionTimingFunction::CSSValueFromComputedStyleInternal(
@@ -6653,17 +6657,17 @@ const CSSValue* Translate::ParseSingleValue(
return css_property_parser_helpers::ConsumeIdent(range);
CSSValue* translate_x = css_property_parser_helpers::ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeAll);
+ range, context, kValueRangeAll);
if (!translate_x)
return nullptr;
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
list->Append(*translate_x);
CSSPrimitiveValue* translate_y =
- css_property_parser_helpers::ConsumeLengthOrPercent(range, context.Mode(),
+ css_property_parser_helpers::ConsumeLengthOrPercent(range, context,
kValueRangeAll);
if (translate_y) {
CSSValue* translate_z = css_property_parser_helpers::ConsumeLength(
- range, context.Mode(), kValueRangeAll);
+ range, context, kValueRangeAll);
if (translate_y->IsZero() && !translate_z)
return list;
@@ -6736,7 +6740,7 @@ const CSSValue* VerticalAlign::ParseSingleValue(
range, CSSValueID::kBaseline, CSSValueID::kWebkitBaselineMiddle);
if (!parsed_value) {
parsed_value = css_property_parser_helpers::ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeAll,
+ range, context, kValueRangeAll,
css_property_parser_helpers::UnitlessQuirk::kAllow);
}
return parsed_value;
@@ -6842,7 +6846,7 @@ const CSSValue* WebkitBorderHorizontalSpacing::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeLength(range, context.Mode(),
+ return css_property_parser_helpers::ConsumeLength(range, context,
kValueRangeNonNegative);
}
@@ -6883,7 +6887,7 @@ const CSSValue* WebkitBorderVerticalSpacing::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeLength(range, context.Mode(),
+ return css_property_parser_helpers::ConsumeLength(range, context,
kValueRangeNonNegative);
}
@@ -6923,9 +6927,10 @@ const CSSValue* WebkitBoxDirection::CSSValueFromComputedStyleInternal(
const CSSValue* WebkitBoxFlex::ParseSingleValue(
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeNumber(range, kValueRangeAll);
+ return css_property_parser_helpers::ConsumeNumber(range, context,
+ kValueRangeAll);
}
const CSSValue* WebkitBoxFlex::CSSValueFromComputedStyleInternal(
@@ -6941,7 +6946,7 @@ const CSSValue* WebkitBoxOrdinalGroup::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumePositiveInteger(range);
+ return css_property_parser_helpers::ConsumePositiveInteger(range, context);
}
const CSSValue* WebkitBoxOrdinalGroup::CSSValueFromComputedStyleInternal(
@@ -6985,7 +6990,7 @@ CSSValue* ConsumeReflect(CSSParserTokenRange& range,
CSSNumericLiteralValue::Create(0, CSSPrimitiveValue::UnitType::kPixels);
} else {
offset = ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeAll,
+ range, context, kValueRangeAll,
css_property_parser_helpers::UnitlessQuirk::kForbid);
if (!offset)
return nullptr;
@@ -7024,7 +7029,7 @@ const CSSValue* WebkitFontSizeDelta::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_property_parser_helpers::ConsumeLength(
- range, context.Mode(), kValueRangeAll,
+ range, context, kValueRangeAll,
css_property_parser_helpers::UnitlessQuirk::kAllow);
}
@@ -7087,7 +7092,7 @@ const CSSValue* WebkitLineClamp::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
// When specifying number of lines, don't allow 0 as a valid value.
- return css_property_parser_helpers::ConsumePositiveInteger(range);
+ return css_property_parser_helpers::ConsumePositiveInteger(range, context);
}
const CSSValue* WebkitLineClamp::CSSValueFromComputedStyleInternal(
@@ -7131,43 +7136,11 @@ void WebkitLocale::ApplyValue(StyleResolverState& state,
}
}
-const CSSValue* WebkitMarginAfterCollapse::CSSValueFromComputedStyleInternal(
- const ComputedStyle& style,
- const SVGComputedStyle&,
- const LayoutObject*,
- bool allow_visited_style) const {
- return CSSIdentifierValue::Create(style.MarginAfterCollapse());
-}
-
-const CSSValue* WebkitMarginBeforeCollapse::CSSValueFromComputedStyleInternal(
- const ComputedStyle& style,
- const SVGComputedStyle&,
- const LayoutObject*,
- bool allow_visited_style) const {
- return CSSIdentifierValue::Create(style.MarginBeforeCollapse());
-}
-
-const CSSValue* WebkitMarginBottomCollapse::CSSValueFromComputedStyleInternal(
- const ComputedStyle& style,
- const SVGComputedStyle&,
- const LayoutObject*,
- bool allow_visited_style) const {
- return CSSIdentifierValue::Create(style.MarginAfterCollapse());
-}
-
-const CSSValue* WebkitMarginTopCollapse::CSSValueFromComputedStyleInternal(
- const ComputedStyle& style,
- const SVGComputedStyle&,
- const LayoutObject*,
- bool allow_visited_style) const {
- return CSSIdentifierValue::Create(style.MarginBeforeCollapse());
-}
-
const CSSValue* WebkitMaskBoxImageOutset::ParseSingleValue(
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeBorderImageOutset(range);
+ return css_parsing_utils::ConsumeBorderImageOutset(range, context);
}
const CSSValue* WebkitMaskBoxImageOutset::CSSValueFromComputedStyleInternal(
@@ -7196,10 +7169,10 @@ const CSSValue* WebkitMaskBoxImageRepeat::CSSValueFromComputedStyleInternal(
const CSSValue* WebkitMaskBoxImageSlice::ParseSingleValue(
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeBorderImageSlice(
- range, css_parsing_utils::DefaultFill::kNoFill);
+ range, context, css_parsing_utils::DefaultFill::kNoFill);
}
const CSSValue* WebkitMaskBoxImageSlice::CSSValueFromComputedStyleInternal(
@@ -7214,7 +7187,7 @@ const CSSValue* WebkitMaskBoxImageSource::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeImageOrNone(range, &context);
+ return css_property_parser_helpers::ConsumeImageOrNone(range, context);
}
const CSSValue* WebkitMaskBoxImageSource::CSSValueFromComputedStyleInternal(
@@ -7237,9 +7210,9 @@ void WebkitMaskBoxImageSource::ApplyValue(StyleResolverState& state,
const CSSValue* WebkitMaskBoxImageWidth::ParseSingleValue(
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_parsing_utils::ConsumeBorderImageWidth(range);
+ return css_parsing_utils::ConsumeBorderImageWidth(range, context);
}
const CSSValue* WebkitMaskBoxImageWidth::CSSValueFromComputedStyleInternal(
@@ -7299,7 +7272,7 @@ const CSSValue* WebkitMaskImage::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_property_parser_helpers::ConsumeCommaSeparatedList(
- css_property_parser_helpers::ConsumeImageOrNone, range, &context);
+ css_property_parser_helpers::ConsumeImageOrNone, range, context);
}
const CSSValue* WebkitMaskImage::CSSValueFromComputedStyleInternal(
@@ -7342,7 +7315,7 @@ const CSSValue* WebkitMaskPositionX::ParseSingleValue(
return css_property_parser_helpers::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumePositionLonghand<CSSValueID::kLeft,
CSSValueID::kRight>,
- range, context.Mode());
+ range, context);
}
const CSSValue* WebkitMaskPositionX::CSSValueFromComputedStyleInternal(
@@ -7362,7 +7335,7 @@ const CSSValue* WebkitMaskPositionY::ParseSingleValue(
return css_property_parser_helpers::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumePositionLonghand<CSSValueID::kTop,
CSSValueID::kBottom>,
- range, context.Mode());
+ range, context);
}
const CSSValue* WebkitMaskPositionY::CSSValueFromComputedStyleInternal(
@@ -7398,7 +7371,7 @@ const CSSValue* WebkitPerspectiveOriginX::ParseSingleValue(
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumePositionLonghand<CSSValueID::kLeft,
CSSValueID::kRight>(
- range, context.Mode());
+ range, context);
}
const CSSValue* WebkitPerspectiveOriginY::ParseSingleValue(
@@ -7407,7 +7380,7 @@ const CSSValue* WebkitPerspectiveOriginY::ParseSingleValue(
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumePositionLonghand<CSSValueID::kTop,
CSSValueID::kBottom>(
- range, context.Mode());
+ range, context);
}
const CSSValue* WebkitPrintColorAdjust::CSSValueFromComputedStyleInternal(
@@ -7440,7 +7413,7 @@ const CSSValue* WebkitTapHighlightColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const blink::Color WebkitTapHighlightColor::ColorIncludingFallback(
@@ -7492,7 +7465,7 @@ const CSSValue* WebkitTextEmphasisColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const blink::Color WebkitTextEmphasisColor::ColorIncludingFallback(
@@ -7717,7 +7690,7 @@ const CSSValue* WebkitTextFillColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const blink::Color WebkitTextFillColor::ColorIncludingFallback(
@@ -7764,7 +7737,7 @@ const CSSValue* WebkitTextStrokeColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeColor(range, context.Mode());
+ return css_property_parser_helpers::ConsumeColor(range, context);
}
const blink::Color WebkitTextStrokeColor::ColorIncludingFallback(
@@ -7788,8 +7761,7 @@ const CSSValue* WebkitTextStrokeWidth::ParseSingleValue(
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_property_parser_helpers::ConsumeLineWidth(
- range, context.Mode(),
- css_property_parser_helpers::UnitlessQuirk::kForbid);
+ range, context, css_property_parser_helpers::UnitlessQuirk::kForbid);
}
const CSSValue* WebkitTextStrokeWidth::CSSValueFromComputedStyleInternal(
@@ -7806,7 +7778,7 @@ const CSSValue* WebkitTransformOriginX::ParseSingleValue(
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumePositionLonghand<CSSValueID::kLeft,
CSSValueID::kRight>(
- range, context.Mode());
+ range, context);
}
const CSSValue* WebkitTransformOriginY::ParseSingleValue(
@@ -7815,14 +7787,14 @@ const CSSValue* WebkitTransformOriginY::ParseSingleValue(
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumePositionLonghand<CSSValueID::kTop,
CSSValueID::kBottom>(
- range, context.Mode());
+ range, context);
}
const CSSValue* WebkitTransformOriginZ::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumeLength(range, context.Mode(),
+ return css_property_parser_helpers::ConsumeLength(range, context,
kValueRangeAll);
}
@@ -7867,7 +7839,7 @@ const CSSValue* WhiteSpace::CSSValueFromComputedStyleInternal(
const CSSValue* Widows::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
- return css_property_parser_helpers::ConsumePositiveInteger(range);
+ return css_property_parser_helpers::ConsumePositiveInteger(range, context);
}
const CSSValue* Widows::CSSValueFromComputedStyleInternal(
@@ -7917,13 +7889,13 @@ const CSSValue* WillChange::ParseSingleValue(
while (true) {
if (range.Peek().GetType() != kIdentToken)
return nullptr;
- CSSPropertyID unresolved_property =
- UnresolvedCSSPropertyID(range.Peek().Value());
+ CSSPropertyID unresolved_property = UnresolvedCSSPropertyID(
+ context.GetExecutionContext(), range.Peek().Value());
if (unresolved_property != CSSPropertyID::kInvalid &&
unresolved_property != CSSPropertyID::kVariable) {
#if DCHECK_IS_ON()
DCHECK(CSSProperty::Get(resolveCSSPropertyID(unresolved_property))
- .IsWebExposed());
+ .IsWebExposed(context.GetExecutionContext()));
#endif
// Now "all" is used by both CSSValue and CSSPropertyValue.
// Need to return nullptr when currentValue is CSSPropertyID::kAll.
@@ -8095,7 +8067,7 @@ const CSSValue* ZIndex::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_property_parser_helpers::ConsumeIdent(range);
- return css_property_parser_helpers::ConsumeInteger(range);
+ return css_property_parser_helpers::ConsumeInteger(range, context);
}
const CSSValue* ZIndex::CSSValueFromComputedStyleInternal(
@@ -8118,10 +8090,10 @@ const CSSValue* Zoom::ParseSingleValue(CSSParserTokenRange& range,
zoom =
css_property_parser_helpers::ConsumeIdent<CSSValueID::kNormal>(range);
} else {
- zoom = css_property_parser_helpers::ConsumePercent(range,
+ zoom = css_property_parser_helpers::ConsumePercent(range, context,
kValueRangeNonNegative);
if (!zoom) {
- zoom = css_property_parser_helpers::ConsumeNumber(range,
+ zoom = css_property_parser_helpers::ConsumeNumber(range, context,
kValueRangeNonNegative);
}
}
@@ -8157,5 +8129,13 @@ void Zoom::ApplyValue(StyleResolverState& state, const CSSValue& value) const {
state.SetZoom(StyleBuilderConverter::ConvertZoom(state, value));
}
+const CSSValue* InternalEmptyLineHeight::ParseSingleValue(
+ CSSParserTokenRange& range,
+ const CSSParserContext&,
+ const CSSParserLocalContext&) const {
+ return css_property_parser_helpers::ConsumeIdent<CSSValueID::kFabricated,
+ CSSValueID::kNone>(range);
+}
+
} // namespace css_longhand
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/properties/longhands/variable.h b/chromium/third_party/blink/renderer/core/css/properties/longhands/variable.h
index fd5cd2ec39b..db5c776088c 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/longhands/variable.h
+++ b/chromium/third_party/blink/renderer/core/css/properties/longhands/variable.h
@@ -35,7 +35,8 @@ class CORE_EXPORT Variable : public Longhand {
protected:
constexpr Variable(bool inherited)
: Longhand(CSSPropertyID::kVariable,
- kProperty | (inherited ? kInherited : 0),
+ kProperty | (inherited ? kInherited : 0) |
+ kValidForFirstLetter | kValidForMarker,
'\0') {}
};
diff --git a/chromium/third_party/blink/renderer/core/css/properties/shorthand.h b/chromium/third_party/blink/renderer/core/css/properties/shorthand.h
index a4743b279ae..6970ad40902 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/shorthand.h
+++ b/chromium/third_party/blink/renderer/core/css/properties/shorthand.h
@@ -31,9 +31,7 @@ class Shorthand : public CSSProperty {
}
protected:
- constexpr Shorthand(CSSPropertyID id,
- uint16_t flags,
- char repetition_separator)
+ constexpr Shorthand(CSSPropertyID id, Flags flags, char repetition_separator)
: CSSProperty(id, flags | kShorthand, repetition_separator) {}
};
diff --git a/chromium/third_party/blink/renderer/core/css/properties/shorthands/shorthands_custom.cc b/chromium/third_party/blink/renderer/core/css/properties/shorthands/shorthands_custom.cc
index 914931a252d..657fd78d604 100644
--- a/chromium/third_party/blink/renderer/core/css/properties/shorthands/shorthands_custom.cc
+++ b/chromium/third_party/blink/renderer/core/css/properties/shorthands/shorthands_custom.cc
@@ -43,20 +43,21 @@ CSSValue* ConsumeAnimationValue(CSSPropertyID property,
bool use_legacy_parsing) {
switch (property) {
case CSSPropertyID::kAnimationDelay:
- return css_property_parser_helpers::ConsumeTime(range, kValueRangeAll);
+ return css_property_parser_helpers::ConsumeTime(range, context,
+ kValueRangeAll);
case CSSPropertyID::kAnimationDirection:
return css_property_parser_helpers::ConsumeIdent<
CSSValueID::kNormal, CSSValueID::kAlternate, CSSValueID::kReverse,
CSSValueID::kAlternateReverse>(range);
case CSSPropertyID::kAnimationDuration:
- return css_property_parser_helpers::ConsumeTime(range,
+ return css_property_parser_helpers::ConsumeTime(range, context,
kValueRangeNonNegative);
case CSSPropertyID::kAnimationFillMode:
return css_property_parser_helpers::ConsumeIdent<
CSSValueID::kNone, CSSValueID::kForwards, CSSValueID::kBackwards,
CSSValueID::kBoth>(range);
case CSSPropertyID::kAnimationIterationCount:
- return css_parsing_utils::ConsumeAnimationIterationCount(range);
+ return css_parsing_utils::ConsumeAnimationIterationCount(range, context);
case CSSPropertyID::kAnimationName:
return css_parsing_utils::ConsumeAnimationName(range, context,
use_legacy_parsing);
@@ -65,7 +66,7 @@ CSSValue* ConsumeAnimationValue(CSSPropertyID property,
CSSValueID::kPaused>(
range);
case CSSPropertyID::kAnimationTimingFunction:
- return css_parsing_utils::ConsumeAnimationTimingFunction(range);
+ return css_parsing_utils::ConsumeAnimationTimingFunction(range, context);
default:
NOTREACHED();
return nullptr;
@@ -670,7 +671,7 @@ bool BorderRadius::ParseShorthand(
CSSValue* vertical_radii[4] = {nullptr};
if (!css_parsing_utils::ConsumeRadii(horizontal_radii, vertical_radii, range,
- context.Mode(),
+ context,
local_context.UseAliasParsing()))
return false;
@@ -739,14 +740,14 @@ bool BorderSpacing::ParseShorthand(
const CSSParserLocalContext&,
HeapVector<CSSPropertyValue, 256>& properties) const {
CSSValue* horizontal_spacing =
- ConsumeLength(range, context.Mode(), kValueRangeNonNegative,
+ ConsumeLength(range, context, kValueRangeNonNegative,
css_property_parser_helpers::UnitlessQuirk::kAllow);
if (!horizontal_spacing)
return false;
CSSValue* vertical_spacing = horizontal_spacing;
if (!range.AtEnd()) {
vertical_spacing =
- ConsumeLength(range, context.Mode(), kValueRangeNonNegative,
+ ConsumeLength(range, context, kValueRangeNonNegative,
css_property_parser_helpers::UnitlessQuirk::kAllow);
}
if (!vertical_spacing || !range.AtEnd())
@@ -854,15 +855,15 @@ const CSSValue* ColumnRule::CSSValueFromComputedStyleInternal(
bool Columns::ParseShorthand(
bool important,
CSSParserTokenRange& range,
- const CSSParserContext&,
+ const CSSParserContext& context,
const CSSParserLocalContext&,
HeapVector<CSSPropertyValue, 256>& properties) const {
CSSValue* column_width = nullptr;
CSSValue* column_count = nullptr;
- if (!css_parsing_utils::ConsumeColumnWidthOrCount(range, column_width,
- column_count))
+ if (!css_parsing_utils::ConsumeColumnWidthOrCount(range, context,
+ column_width, column_count))
return false;
- css_parsing_utils::ConsumeColumnWidthOrCount(range, column_width,
+ css_parsing_utils::ConsumeColumnWidthOrCount(range, context, column_width,
column_count);
if (!range.AtEnd())
return false;
@@ -909,7 +910,7 @@ bool Flex::ParseShorthand(bool important,
unsigned index = 0;
while (!range.AtEnd() && index++ < 3) {
double num;
- if (css_property_parser_helpers::ConsumeNumberRaw(range, num)) {
+ if (css_property_parser_helpers::ConsumeNumberRaw(range, context, num)) {
if (num < 0)
return false;
if (flex_grow == kUnsetValue) {
@@ -930,7 +931,7 @@ bool Flex::ParseShorthand(bool important,
flex_basis = css_property_parser_helpers::ConsumeIdent(range);
if (!flex_basis) {
flex_basis = css_property_parser_helpers::ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeNonNegative);
+ range, context, kValueRangeNonNegative);
}
if (index == 2 && !range.AtEnd())
return false;
@@ -1095,7 +1096,7 @@ bool ConsumeFont(bool important,
}
if (!font_style &&
(id == CSSValueID::kItalic || id == CSSValueID::kOblique)) {
- font_style = css_parsing_utils::ConsumeFontStyle(range, context.Mode());
+ font_style = css_parsing_utils::ConsumeFontStyle(range, context);
if (!font_style)
return false;
continue;
@@ -1109,7 +1110,7 @@ bool ConsumeFont(bool important,
continue;
}
if (!font_weight) {
- font_weight = css_parsing_utils::ConsumeFontWeight(range, context.Mode());
+ font_weight = css_parsing_utils::ConsumeFontWeight(range, context);
if (font_weight)
continue;
}
@@ -1182,7 +1183,7 @@ bool ConsumeFont(bool important,
if (css_property_parser_helpers::ConsumeSlashIncludingWhitespace(range)) {
CSSValue* line_height =
- css_parsing_utils::ConsumeLineHeight(range, context.Mode());
+ css_parsing_utils::ConsumeLineHeight(range, context);
if (!line_height)
return false;
css_property_parser_helpers::AddProperty(
@@ -1628,23 +1629,22 @@ bool Grid::ParseShorthand(bool important,
auto_rows_value = CSSInitialValue::Create();
} else {
auto_rows_value = css_parsing_utils::ConsumeGridTrackList(
- range, context, context.Mode(),
- css_parsing_utils::TrackListType::kGridAuto);
+ range, context, css_parsing_utils::TrackListType::kGridAuto);
if (!auto_rows_value)
return false;
if (!css_property_parser_helpers::ConsumeSlashIncludingWhitespace(range))
return false;
}
if (!(template_columns =
- css_parsing_utils::ConsumeGridTemplatesRowsOrColumns(
- range, context, context.Mode())))
+ css_parsing_utils::ConsumeGridTemplatesRowsOrColumns(range,
+ context)))
return false;
template_rows = CSSInitialValue::Create();
auto_columns_value = CSSInitialValue::Create();
} else {
// 3- <grid-template-rows> / [ auto-flow && dense? ] <grid-auto-columns>?
- template_rows = css_parsing_utils::ConsumeGridTemplatesRowsOrColumns(
- range, context, context.Mode());
+ template_rows =
+ css_parsing_utils::ConsumeGridTemplatesRowsOrColumns(range, context);
if (!template_rows)
return false;
if (!css_property_parser_helpers::ConsumeSlashIncludingWhitespace(range))
@@ -1657,8 +1657,7 @@ bool Grid::ParseShorthand(bool important,
auto_columns_value = CSSInitialValue::Create();
} else {
auto_columns_value = css_parsing_utils::ConsumeGridTrackList(
- range, context, context.Mode(),
- css_parsing_utils::TrackListType::kGridAuto);
+ range, context, css_parsing_utils::TrackListType::kGridAuto);
if (!auto_columns_value)
return false;
}
@@ -1923,25 +1922,6 @@ const CSSValue* InsetInline::CSSValueFromComputedStyleInternal(
insetInlineShorthand(), style, layout_object, allow_visited_style);
}
-bool IntrinsicSize::ParseShorthand(
- bool important,
- CSSParserTokenRange& range,
- const CSSParserContext& context,
- const CSSParserLocalContext&,
- HeapVector<CSSPropertyValue, 256>& properties) const {
- return css_property_parser_helpers::ConsumeShorthandVia2Longhands(
- intrinsicSizeShorthand(), important, context, range, properties);
-}
-
-const CSSValue* IntrinsicSize::CSSValueFromComputedStyleInternal(
- const ComputedStyle& style,
- const SVGComputedStyle&,
- const LayoutObject* layout_object,
- bool allow_visited_style) const {
- return ComputedStyleUtils::ValuesForIntrinsicSizeShorthand(
- intrinsicSizeShorthand(), style, layout_object, allow_visited_style);
-}
-
bool ListStyle::ParseShorthand(
bool important,
CSSParserTokenRange& range,
@@ -2165,11 +2145,11 @@ bool Offset::ParseShorthand(
const CSSValue* offset_rotate = nullptr;
if (offset_path) {
offset_distance = css_property_parser_helpers::ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeAll);
+ range, context, kValueRangeAll);
offset_rotate = css_parsing_utils::ConsumeOffsetRotate(range, context);
if (offset_rotate && !offset_distance) {
offset_distance = css_property_parser_helpers::ConsumeLengthOrPercent(
- range, context.Mode(), kValueRangeAll);
+ range, context, kValueRangeAll);
}
}
const CSSValue* offset_anchor = nullptr;
@@ -2784,14 +2764,15 @@ CSSValue* ConsumeTransitionValue(CSSPropertyID property,
bool use_legacy_parsing) {
switch (property) {
case CSSPropertyID::kTransitionDelay:
- return css_property_parser_helpers::ConsumeTime(range, kValueRangeAll);
+ return css_property_parser_helpers::ConsumeTime(range, context,
+ kValueRangeAll);
case CSSPropertyID::kTransitionDuration:
- return css_property_parser_helpers::ConsumeTime(range,
+ return css_property_parser_helpers::ConsumeTime(range, context,
kValueRangeNonNegative);
case CSSPropertyID::kTransitionProperty:
return css_parsing_utils::ConsumeTransitionProperty(range, context);
case CSSPropertyID::kTransitionTimingFunction:
- return css_parsing_utils::ConsumeAnimationTimingFunction(range);
+ return css_parsing_utils::ConsumeAnimationTimingFunction(range, context);
default:
NOTREACHED();
return nullptr;
@@ -2959,45 +2940,6 @@ const CSSValue* WebkitColumnBreakInside::CSSValueFromComputedStyleInternal(
style.BreakInside());
}
-bool WebkitMarginCollapse::ParseShorthand(
- bool important,
- CSSParserTokenRange& range,
- const CSSParserContext& context,
- const CSSParserLocalContext&,
- HeapVector<CSSPropertyValue, 256>& properties) const {
- CSSValueID id = range.ConsumeIncludingWhitespace().Id();
- if (!CSSParserFastPaths::IsValidKeywordPropertyAndValue(
- CSSPropertyID::kWebkitMarginBeforeCollapse, id, context.Mode()))
- return false;
-
- CSSValue* before_collapse = CSSIdentifierValue::Create(id);
- css_property_parser_helpers::AddProperty(
- CSSPropertyID::kWebkitMarginBeforeCollapse,
- CSSPropertyID::kWebkitMarginCollapse, *before_collapse, important,
- css_property_parser_helpers::IsImplicitProperty::kNotImplicit,
- properties);
-
- if (range.AtEnd()) {
- css_property_parser_helpers::AddProperty(
- CSSPropertyID::kWebkitMarginAfterCollapse,
- CSSPropertyID::kWebkitMarginCollapse, *before_collapse, important,
- css_property_parser_helpers::IsImplicitProperty::kNotImplicit,
- properties);
- return true;
- }
-
- id = range.ConsumeIncludingWhitespace().Id();
- if (!CSSParserFastPaths::IsValidKeywordPropertyAndValue(
- CSSPropertyID::kWebkitMarginAfterCollapse, id, context.Mode()))
- return false;
- css_property_parser_helpers::AddProperty(
- CSSPropertyID::kWebkitMarginAfterCollapse,
- CSSPropertyID::kWebkitMarginCollapse, *CSSIdentifierValue::Create(id),
- important, css_property_parser_helpers::IsImplicitProperty::kNotImplicit,
- properties);
- return true;
-}
-
bool WebkitMaskBoxImage::ParseShorthand(
bool important,
CSSParserTokenRange& range,
diff --git a/chromium/third_party/blink/renderer/core/css/property_registration.cc b/chromium/third_party/blink/renderer/core/css/property_registration.cc
index fe76bb0476c..4ac80062d6c 100644
--- a/chromium/third_party/blink/renderer/core/css/property_registration.cc
+++ b/chromium/third_party/blink/renderer/core/css/property_registration.cc
@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/core/css/property_registration.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_property_definition.h"
#include "third_party/blink/renderer/core/animation/css_interpolation_types_map.h"
#include "third_party/blink/renderer/core/css/css_custom_property_declaration.h"
#include "third_party/blink/renderer/core/css/css_identifier_value.h"
@@ -16,7 +17,6 @@
#include "third_party/blink/renderer/core/css/parser/css_parser_context.h"
#include "third_party/blink/renderer/core/css/parser/css_tokenizer.h"
#include "third_party/blink/renderer/core/css/parser/css_variable_parser.h"
-#include "third_party/blink/renderer/core/css/property_definition.h"
#include "third_party/blink/renderer/core/css/property_registry.h"
#include "third_party/blink/renderer/core/css/resolver/style_builder_converter.h"
#include "third_party/blink/renderer/core/css/style_change_reason.h"
@@ -24,16 +24,17 @@
#include "third_party/blink/renderer/core/css/style_rule.h"
#include "third_party/blink/renderer/core/css/style_sheet_contents.h"
#include "third_party/blink/renderer/core/dom/document.h"
+#include "third_party/blink/renderer/core/frame/local_dom_window.h"
namespace blink {
const PropertyRegistration* PropertyRegistration::From(
const ExecutionContext* execution_context,
const AtomicString& property_name) {
- const auto* document = DynamicTo<Document>(execution_context);
- if (!document)
+ const auto* window = DynamicTo<LocalDOMWindow>(execution_context);
+ if (!window)
return nullptr;
- const PropertyRegistry* registry = document->GetPropertyRegistry();
+ const PropertyRegistry* registry = window->document()->GetPropertyRegistry();
return registry ? registry->Registration(property_name) : nullptr;
}
@@ -133,8 +134,8 @@ PropertyRegistration* PropertyRegistration::MaybeCreate(
const CSSParserContext* parser_context =
document.ElementSheet().Contents()->ParserContext();
const bool is_animation_tainted = false;
- initial = syntax->Parse(initial_variable_data->TokenRange(), parser_context,
- is_animation_tainted);
+ initial = syntax->Parse(initial_variable_data->TokenRange(),
+ *parser_context, is_animation_tainted);
if (!initial)
return nullptr;
if (!ComputationallyIndependent(*initial))
@@ -167,7 +168,7 @@ void PropertyRegistration::registerProperty(
return;
}
AtomicString atomic_name(name);
- Document* document = To<Document>(execution_context);
+ Document* document = To<LocalDOMWindow>(execution_context)->document();
PropertyRegistry& registry = *document->GetPropertyRegistry();
if (registry.Registration(atomic_name)) {
exception_state.ThrowDOMException(
@@ -195,7 +196,7 @@ void PropertyRegistration::registerProperty(
const auto tokens = tokenizer.TokenizeToEOF();
bool is_animation_tainted = false;
initial = syntax_definition->Parse(CSSParserTokenRange(tokens),
- parser_context, is_animation_tainted);
+ *parser_context, is_animation_tainted);
if (!initial) {
exception_state.ThrowDOMException(
DOMExceptionCode::kSyntaxError,
diff --git a/chromium/third_party/blink/renderer/core/css/property_registration.h b/chromium/third_party/blink/renderer/core/css/property_registration.h
index 4562c64397b..7bcdc866b22 100644
--- a/chromium/third_party/blink/renderer/core/css/property_registration.h
+++ b/chromium/third_party/blink/renderer/core/css/property_registration.h
@@ -53,7 +53,7 @@ class CORE_EXPORT PropertyRegistration final
return interpolation_types_;
}
- void Trace(blink::Visitor* visitor) { visitor->Trace(initial_); }
+ void Trace(Visitor* visitor) { visitor->Trace(initial_); }
private:
friend class ::blink::PropertyRegistry;
diff --git a/chromium/third_party/blink/renderer/core/css/property_registry.h b/chromium/third_party/blink/renderer/core/css/property_registry.h
index 53bea429eec..ad7769a293f 100644
--- a/chromium/third_party/blink/renderer/core/css/property_registry.h
+++ b/chromium/third_party/blink/renderer/core/css/property_registry.h
@@ -23,7 +23,7 @@ class CORE_EXPORT PropertyRegistry : public GarbageCollected<PropertyRegistry> {
RegistrationMap::const_iterator begin() const;
RegistrationMap::const_iterator end() const;
- void Trace(blink::Visitor* visitor) { visitor->Trace(registrations_); }
+ void Trace(Visitor* visitor) { visitor->Trace(registrations_); }
void MarkReferenced(const AtomicString&) const;
bool WasReferenced(const AtomicString&) const;
diff --git a/chromium/third_party/blink/renderer/core/css/property_set_css_style_declaration.cc b/chromium/third_party/blink/renderer/core/css/property_set_css_style_declaration.cc
index f9c6752cb02..33ab62e21d1 100644
--- a/chromium/third_party/blink/renderer/core/css/property_set_css_style_declaration.cc
+++ b/chromium/third_party/blink/renderer/core/css/property_set_css_style_declaration.cc
@@ -27,7 +27,7 @@
namespace blink {
-void PropertySetCSSStyleDeclaration::Trace(blink::Visitor* visitor) {
+void PropertySetCSSStyleDeclaration::Trace(Visitor* visitor) {
visitor->Trace(property_set_);
AbstractPropertySetCSSStyleDeclaration::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/property_set_css_style_declaration.h b/chromium/third_party/blink/renderer/core/css/property_set_css_style_declaration.h
index 0c1e52f2ceb..2d7ec1b1076 100644
--- a/chromium/third_party/blink/renderer/core/css/property_set_css_style_declaration.h
+++ b/chromium/third_party/blink/renderer/core/css/property_set_css_style_declaration.h
@@ -36,10 +36,12 @@ class MutableCSSPropertyValueSet;
class PropertySetCSSStyleDeclaration
: public AbstractPropertySetCSSStyleDeclaration {
public:
- PropertySetCSSStyleDeclaration(MutableCSSPropertyValueSet& property_set)
- : property_set_(&property_set) {}
+ PropertySetCSSStyleDeclaration(ExecutionContext* execution_context,
+ MutableCSSPropertyValueSet& property_set)
+ : AbstractPropertySetCSSStyleDeclaration(execution_context),
+ property_set_(&property_set) {}
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
protected:
MutableCSSPropertyValueSet& PropertySet() const final {
diff --git a/chromium/third_party/blink/renderer/core/css/pseudo_style_request.h b/chromium/third_party/blink/renderer/core/css/pseudo_style_request.h
index 29c77e87961..857accbd03e 100644
--- a/chromium/third_party/blink/renderer/core/css/pseudo_style_request.h
+++ b/chromium/third_party/blink/renderer/core/css/pseudo_style_request.h
@@ -51,7 +51,7 @@ class PseudoElementStyleRequest {
scrollbar_part(kNoPart),
scrollbar(nullptr) {}
- void Trace(blink::Visitor* visitor) { visitor->Trace(scrollbar); }
+ void Trace(Visitor* visitor) { visitor->Trace(scrollbar); }
// The spec disallows inheritance for ::backdrop.
bool AllowsInheritance(const ComputedStyle* parent_style) const {
diff --git a/chromium/third_party/blink/renderer/core/css/remote_font_face_source.cc b/chromium/third_party/blink/renderer/core/css/remote_font_face_source.cc
index 475ea4d21bc..e00c1c19a0c 100644
--- a/chromium/third_party/blink/renderer/core/css/remote_font_face_source.cc
+++ b/chromium/third_party/blink/renderer/core/css/remote_font_face_source.cc
@@ -4,12 +4,15 @@
#include "third_party/blink/renderer/core/css/remote_font_face_source.h"
+#include "base/metrics/histogram_functions.h"
+#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/feature_policy/feature_policy_feature.mojom-blink.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/public/platform/web_effective_connection_type.h"
#include "third_party/blink/renderer/core/css/css_custom_font_data.h"
#include "third_party/blink/renderer/core/css/css_font_face.h"
#include "third_party/blink/renderer/core/dom/document.h"
+#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame_client.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
@@ -19,65 +22,78 @@
#include "third_party/blink/renderer/platform/fonts/font_description.h"
#include "third_party/blink/renderer/platform/fonts/font_selector.h"
#include "third_party/blink/renderer/platform/fonts/simple_font_data.h"
-#include "third_party/blink/renderer/platform/instrumentation/histogram.h"
+#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_load_priority.h"
#include "third_party/blink/renderer/platform/network/network_state_notifier.h"
namespace blink {
-namespace {
-
-RemoteFontFaceSource::DisplayPeriod ComputePeriod(
- FontDisplay displayValue,
- RemoteFontFaceSource::Phase phase,
- bool is_intervention_triggered) {
- switch (displayValue) {
+RemoteFontFaceSource::DisplayPeriod RemoteFontFaceSource::ComputePeriod()
+ const {
+ switch (display_) {
case kFontDisplayAuto:
- if (is_intervention_triggered)
- return RemoteFontFaceSource::kSwapPeriod;
+ if (is_intervention_triggered_)
+ return kSwapPeriod;
FALLTHROUGH;
case kFontDisplayBlock:
- switch (phase) {
- case RemoteFontFaceSource::kNoLimitExceeded:
- case RemoteFontFaceSource::kShortLimitExceeded:
- return RemoteFontFaceSource::kBlockPeriod;
- case RemoteFontFaceSource::kLongLimitExceeded:
- return RemoteFontFaceSource::kSwapPeriod;
+ switch (phase_) {
+ case kNoLimitExceeded:
+ case kShortLimitExceeded:
+ return kBlockPeriod;
+ case kLongLimitExceeded:
+ return kSwapPeriod;
}
case kFontDisplaySwap:
- return RemoteFontFaceSource::kSwapPeriod;
+ return kSwapPeriod;
case kFontDisplayFallback:
- switch (phase) {
- case RemoteFontFaceSource::kNoLimitExceeded:
- return RemoteFontFaceSource::kBlockPeriod;
- case RemoteFontFaceSource::kShortLimitExceeded:
- return RemoteFontFaceSource::kSwapPeriod;
- case RemoteFontFaceSource::kLongLimitExceeded:
- return RemoteFontFaceSource::kFailurePeriod;
+ switch (phase_) {
+ case kNoLimitExceeded:
+ return kBlockPeriod;
+ case kShortLimitExceeded:
+ return kSwapPeriod;
+ case kLongLimitExceeded:
+ return kFailurePeriod;
+ }
+
+ case kFontDisplayOptional: {
+ const bool use_phase_value =
+ !base::FeatureList::IsEnabled(
+ features::kFontPreloadingDelaysRendering) ||
+ !GetDocument();
+
+ if (use_phase_value) {
+ switch (phase_) {
+ case kNoLimitExceeded:
+ return kBlockPeriod;
+ case kShortLimitExceeded:
+ case kLongLimitExceeded:
+ return kFailurePeriod;
+ }
}
- case kFontDisplayOptional:
- switch (phase) {
- case RemoteFontFaceSource::kNoLimitExceeded:
- return RemoteFontFaceSource::kBlockPeriod;
- case RemoteFontFaceSource::kShortLimitExceeded:
- case RemoteFontFaceSource::kLongLimitExceeded:
- return RemoteFontFaceSource::kFailurePeriod;
+ // We simply skip the block period, as we should never render invisible
+ // fallback for 'font-display: optional'.
+
+ if (GetDocument()->GetFontPreloadManager().RenderingHasBegun()) {
+ if (FinishedFromMemoryCache() ||
+ finished_before_document_rendering_begin_)
+ return kSwapPeriod;
+ return kFailurePeriod;
}
+ return kSwapPeriod;
+ }
case kFontDisplayEnumMax:
NOTREACHED();
break;
}
NOTREACHED();
- return RemoteFontFaceSource::kSwapPeriod;
+ return kSwapPeriod;
}
-} // namespace
-
RemoteFontFaceSource::RemoteFontFaceSource(CSSFontFace* css_font_face,
FontSelector* font_selector,
FontDisplay display)
@@ -89,13 +105,20 @@ RemoteFontFaceSource::RemoteFontFaceSource(CSSFontFace* css_font_face,
font_selector,
ReportOptions::kDoNotReport)),
phase_(kNoLimitExceeded),
- is_intervention_triggered_(ShouldTriggerWebFontsIntervention()) {
+ is_intervention_triggered_(ShouldTriggerWebFontsIntervention()),
+ finished_before_document_rendering_begin_(false) {
DCHECK(face_);
- period_ = ComputePeriod(display_, phase_, is_intervention_triggered_);
+ period_ = ComputePeriod();
}
RemoteFontFaceSource::~RemoteFontFaceSource() = default;
+Document* RemoteFontFaceSource::GetDocument() const {
+ auto* window =
+ DynamicTo<LocalDOMWindow>(font_selector_->GetExecutionContext());
+ return window ? window->document() : nullptr;
+}
+
void RemoteFontFaceSource::Dispose() {
ClearResource();
PruneTable();
@@ -120,8 +143,9 @@ void RemoteFontFaceSource::NotifyFinished(Resource* resource) {
// Prevent promise rejection while shutting down the document.
// See crbug.com/960290
if (execution_context->IsDocument() &&
- To<Document>(execution_context)->IsDetached())
+ To<LocalDOMWindow>(execution_context)->document()->IsDetached()) {
return;
+ }
FontResource* font = ToFontResource(resource);
histograms_.RecordRemoteFont(font);
@@ -131,12 +155,12 @@ void RemoteFontFaceSource::NotifyFinished(Resource* resource) {
// FIXME: Provide more useful message such as OTS rejection reason.
// See crbug.com/97467
if (font->GetStatus() == ResourceStatus::kDecodeError) {
- execution_context->AddConsoleMessage(ConsoleMessage::Create(
+ execution_context->AddConsoleMessage(MakeGarbageCollected<ConsoleMessage>(
mojom::ConsoleMessageSource::kOther,
mojom::ConsoleMessageLevel::kWarning,
"Failed to decode downloaded font: " + font->Url().ElidedString()));
if (font->OtsParsingMessage().length() > 1) {
- execution_context->AddConsoleMessage(ConsoleMessage::Create(
+ execution_context->AddConsoleMessage(MakeGarbageCollected<ConsoleMessage>(
mojom::ConsoleMessageSource::kOther,
mojom::ConsoleMessageLevel::kWarning,
"OTS parsing error: " + font->OtsParsingMessage()));
@@ -146,6 +170,17 @@ void RemoteFontFaceSource::NotifyFinished(Resource* resource) {
ClearResource();
PruneTable();
+
+ if (GetDocument() &&
+ !GetDocument()->GetFontPreloadManager().RenderingHasBegun()) {
+ finished_before_document_rendering_begin_ = true;
+ }
+
+ if (FinishedFromMemoryCache())
+ period_ = kNotApplicablePeriod;
+ else
+ UpdatePeriod();
+
if (face_->FontLoaded(this)) {
font_selector_->FontFaceInvalidated();
@@ -186,8 +221,7 @@ void RemoteFontFaceSource::SetDisplay(FontDisplay display) {
}
void RemoteFontFaceSource::UpdatePeriod() {
- DisplayPeriod new_period =
- ComputePeriod(display_, phase_, is_intervention_triggered_);
+ DisplayPeriod new_period = ComputePeriod();
// Fallback font is invisible iff the font is loading and in the block period.
// Invalidate the font if its fallback visibility has changed.
@@ -204,21 +238,19 @@ void RemoteFontFaceSource::UpdatePeriod() {
FontDisplay RemoteFontFaceSource::GetFontDisplayWithFeaturePolicyCheck(
FontDisplay display,
const FontSelector* font_selector,
- ReportOptions report) const {
+ ReportOptions report_option) const {
ExecutionContext* context = font_selector->GetExecutionContext();
if (display != kFontDisplayFallback && display != kFontDisplayOptional &&
context && context->IsDocument() &&
- !To<Document>(context)->IsFeatureEnabled(
- mojom::FeaturePolicyFeature::kFontDisplay, report)) {
+ !context->IsFeatureEnabled(
+ mojom::blink::DocumentPolicyFeature::kFontDisplay, report_option)) {
return kFontDisplayOptional;
}
return display;
}
bool RemoteFontFaceSource::ShouldTriggerWebFontsIntervention() {
- const auto* document =
- DynamicTo<Document>(font_selector_->GetExecutionContext());
- if (!document)
+ if (!IsA<LocalDOMWindow>(font_selector_->GetExecutionContext()))
return false;
WebEffectiveConnectionType connection_type =
@@ -286,7 +318,7 @@ void RemoteFontFaceSource::BeginLoadIfNeeded() {
if (font->StillNeedsLoad()) {
if (font->IsLowPriorityLoadingAllowedForRemoteFont()) {
font_selector_->GetExecutionContext()->AddConsoleMessage(
- ConsoleMessage::Create(
+ MakeGarbageCollected<ConsoleMessage>(
mojom::ConsoleMessageSource::kIntervention,
mojom::ConsoleMessageLevel::kInfo,
"Slow network is detected. See "
@@ -313,7 +345,7 @@ void RemoteFontFaceSource::BeginLoadIfNeeded() {
face_->DidBeginLoad();
}
-void RemoteFontFaceSource::Trace(blink::Visitor* visitor) {
+void RemoteFontFaceSource::Trace(Visitor* visitor) {
visitor->Trace(face_);
visitor->Trace(font_selector_);
CSSFontFaceSource::Trace(visitor);
@@ -341,13 +373,10 @@ void RemoteFontFaceSource::FontLoadHistograms::LongLimitExceeded() {
void RemoteFontFaceSource::FontLoadHistograms::RecordFallbackTime() {
if (blank_paint_time_.is_null() || blank_paint_time_recorded_)
return;
+ // TODO(https://crbug.com/1049257): This time should be recorded using a more
+ // appropriate UMA helper, since >1% of samples are in the overflow bucket.
base::TimeDelta duration = base::TimeTicks::Now() - blank_paint_time_;
- DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram,
- blank_text_shown_time_histogram,
- ("WebFont.BlankTextShownTime", 0, 10000, 50));
- blank_text_shown_time_histogram.Count(
- base::saturated_cast<base::HistogramBase::Sample>(
- duration.InMilliseconds()));
+ base::UmaHistogramTimes("WebFont.BlankTextShownTime", duration);
blank_paint_time_recorded_ = true;
}
@@ -355,9 +384,7 @@ void RemoteFontFaceSource::FontLoadHistograms::RecordRemoteFont(
const FontResource* font) {
MaySetDataSource(DataSourceForLoadFinish(font));
- DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, cache_hit_histogram,
- ("WebFont.CacheHit", kCacheHitEnumMax));
- cache_hit_histogram.Count(DataSourceMetricsValue());
+ base::UmaHistogramEnumeration("WebFont.CacheHit", DataSourceMetricsValue());
if (data_source_ == kFromDiskCache || data_source_ == kFromNetwork) {
DCHECK(!load_start_time_.is_null());
@@ -383,98 +410,74 @@ void RemoteFontFaceSource::FontLoadHistograms::RecordLoadTimeHistogram(
base::TimeDelta delta) {
CHECK_NE(kFromUnknown, data_source_);
- int duration =
- base::saturated_cast<base::HistogramBase::Sample>(delta.InMilliseconds());
+ // TODO(https://crbug.com/1049257): These times should be recorded using a
+ // more appropriate UMA helper, since >1% of samples are in the overflow
+ // bucket.
if (font->ErrorOccurred()) {
- DEFINE_THREAD_SAFE_STATIC_LOCAL(
- CustomCountHistogram, load_error_histogram,
- ("WebFont.DownloadTime.LoadError", 0, 10000, 50));
- DEFINE_THREAD_SAFE_STATIC_LOCAL(
- CustomCountHistogram, missed_cache_load_error_histogram,
- ("WebFont.MissedCache.DownloadTime.LoadError", 0, 10000, 50));
- load_error_histogram.Count(duration);
- if (data_source_ == kFromNetwork)
- missed_cache_load_error_histogram.Count(duration);
+ base::UmaHistogramTimes("WebFont.DownloadTime.LoadError", delta);
+ if (data_source_ == kFromNetwork) {
+ base::UmaHistogramTimes("WebFont.MissedCache.DownloadTime.LoadError",
+ delta);
+ }
return;
}
size_t size = font->EncodedSize();
if (size < 10 * 1024) {
- DEFINE_THREAD_SAFE_STATIC_LOCAL(
- CustomCountHistogram, under10k_histogram,
- ("WebFont.DownloadTime.0.Under10KB", 0, 10000, 50));
- DEFINE_THREAD_SAFE_STATIC_LOCAL(
- CustomCountHistogram, missed_cache_under10k_histogram,
- ("WebFont.MissedCache.DownloadTime.0.Under10KB", 0, 10000, 50));
- under10k_histogram.Count(duration);
- if (data_source_ == kFromNetwork)
- missed_cache_under10k_histogram.Count(duration);
+ base::UmaHistogramTimes("WebFont.DownloadTime.0.Under10KB", delta);
+ if (data_source_ == kFromNetwork) {
+ base::UmaHistogramTimes("WebFont.MissedCache.DownloadTime.0.Under10KB",
+ delta);
+ }
return;
}
if (size < 50 * 1024) {
- DEFINE_THREAD_SAFE_STATIC_LOCAL(
- CustomCountHistogram, under50k_histogram,
- ("WebFont.DownloadTime.1.10KBTo50KB", 0, 10000, 50));
- DEFINE_THREAD_SAFE_STATIC_LOCAL(
- CustomCountHistogram, missed_cache_under50k_histogram,
- ("WebFont.MissedCache.DownloadTime.1.10KBTo50KB", 0, 10000, 50));
- under50k_histogram.Count(duration);
- if (data_source_ == kFromNetwork)
- missed_cache_under50k_histogram.Count(duration);
+ base::UmaHistogramTimes("WebFont.DownloadTime.1.10KBTo50KB", delta);
+ if (data_source_ == kFromNetwork) {
+ base::UmaHistogramTimes("WebFont.MissedCache.DownloadTime.1.10KBTo50KB",
+ delta);
+ }
return;
}
if (size < 100 * 1024) {
- DEFINE_THREAD_SAFE_STATIC_LOCAL(
- CustomCountHistogram, under100k_histogram,
- ("WebFont.DownloadTime.2.50KBTo100KB", 0, 10000, 50));
- DEFINE_THREAD_SAFE_STATIC_LOCAL(
- CustomCountHistogram, missed_cache_under100k_histogram,
- ("WebFont.MissedCache.DownloadTime.2.50KBTo100KB", 0, 10000, 50));
- under100k_histogram.Count(duration);
- if (data_source_ == kFromNetwork)
- missed_cache_under100k_histogram.Count(duration);
+ base::UmaHistogramTimes("WebFont.DownloadTime.2.50KBTo100KB", delta);
+ if (data_source_ == kFromNetwork) {
+ base::UmaHistogramTimes("WebFont.MissedCache.DownloadTime.2.50KBTo100KB",
+ delta);
+ }
return;
}
if (size < 1024 * 1024) {
- DEFINE_THREAD_SAFE_STATIC_LOCAL(
- CustomCountHistogram, under1mb_histogram,
- ("WebFont.DownloadTime.3.100KBTo1MB", 0, 10000, 50));
- DEFINE_THREAD_SAFE_STATIC_LOCAL(
- CustomCountHistogram, missed_cache_under1mb_histogram,
- ("WebFont.MissedCache.DownloadTime.3.100KBTo1MB", 0, 10000, 50));
- under1mb_histogram.Count(duration);
- if (data_source_ == kFromNetwork)
- missed_cache_under1mb_histogram.Count(duration);
+ base::UmaHistogramTimes("WebFont.DownloadTime.3.100KBTo1MB", delta);
+ if (data_source_ == kFromNetwork) {
+ base::UmaHistogramTimes("WebFont.MissedCache.DownloadTime.3.100KBTo1MB",
+ delta);
+ }
return;
}
- DEFINE_THREAD_SAFE_STATIC_LOCAL(
- CustomCountHistogram, over1mb_histogram,
- ("WebFont.DownloadTime.4.Over1MB", 0, 10000, 50));
- DEFINE_THREAD_SAFE_STATIC_LOCAL(
- CustomCountHistogram, missed_cache_over1mb_histogram,
- ("WebFont.MissedCache.DownloadTime.4.Over1MB", 0, 10000, 50));
- over1mb_histogram.Count(duration);
- if (data_source_ == kFromNetwork)
- missed_cache_over1mb_histogram.Count(duration);
+ base::UmaHistogramTimes("WebFont.DownloadTime.4.Over1MB", delta);
+ if (data_source_ == kFromNetwork) {
+ base::UmaHistogramTimes("WebFont.MissedCache.DownloadTime.4.Over1MB",
+ delta);
+ }
}
RemoteFontFaceSource::FontLoadHistograms::CacheHitMetrics
RemoteFontFaceSource::FontLoadHistograms::DataSourceMetricsValue() {
switch (data_source_) {
case kFromDataURL:
- return kDataUrl;
+ return CacheHitMetrics::kDataUrl;
case kFromMemoryCache:
- return kMemoryHit;
+ return CacheHitMetrics::kMemoryHit;
case kFromDiskCache:
- return kDiskHit;
+ return CacheHitMetrics::kDiskHit;
case kFromNetwork:
- return kMiss;
+ return CacheHitMetrics::kMiss;
case kFromUnknown:
- // Fall through.
- default:
- NOTREACHED();
+ return CacheHitMetrics::kMiss;
}
- return kMiss;
+ NOTREACHED();
+ return CacheHitMetrics::kMiss;
}
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/remote_font_face_source.h b/chromium/third_party/blink/renderer/core/css/remote_font_face_source.h
index fa6a90489e8..5476391da88 100644
--- a/chromium/third_party/blink/renderer/core/css/remote_font_face_source.h
+++ b/chromium/third_party/blink/renderer/core/css/remote_font_face_source.h
@@ -13,6 +13,7 @@
namespace blink {
class CSSFontFace;
+class Document;
class FontSelector;
class FontCustomPlatformData;
@@ -23,9 +24,6 @@ class RemoteFontFaceSource final : public CSSFontFaceSource,
public:
enum Phase { kNoLimitExceeded, kShortLimitExceeded, kLongLimitExceeded };
- // Periods of the Font Display Timeline.
- // https://drafts.csswg.org/css-fonts-4/#font-display-timeline
- enum DisplayPeriod { kBlockPeriod, kSwapPeriod, kFailurePeriod };
RemoteFontFaceSource(CSSFontFace*, FontSelector*, FontDisplay);
~RemoteFontFaceSource() override;
@@ -50,7 +48,7 @@ class RemoteFontFaceSource final : public CSSFontFaceSource,
bool HadBlankText() override { return histograms_.HadBlankText(); }
void PaintRequested() override { histograms_.FallbackFontPainted(period_); }
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
protected:
scoped_refptr<SimpleFontData> CreateFontData(
@@ -60,18 +58,31 @@ class RemoteFontFaceSource final : public CSSFontFaceSource,
const FontDescription&);
private:
+ // Periods of the Font Display Timeline.
+ // https://drafts.csswg.org/css-fonts-4/#font-display-timeline
+ // Note that kNotApplicablePeriod is an implementation detail indicating that
+ // the font is loaded from memory cache synchronously, and hence, made
+ // immediately available. As we never need to use a fallback for it, using
+ // other DisplayPeriod values seem artificial. So we use a special value.
+ enum DisplayPeriod {
+ kBlockPeriod,
+ kSwapPeriod,
+ kFailurePeriod,
+ kNotApplicablePeriod
+ };
+
class FontLoadHistograms {
DISALLOW_NEW();
public:
// Should not change following order in CacheHitMetrics to be used for
// metrics values.
- enum CacheHitMetrics {
+ enum class CacheHitMetrics {
kMiss,
kDiskHit,
kDataUrl,
kMemoryHit,
- kCacheHitEnumMax
+ kMaxValue = kMemoryHit,
};
enum DataSource {
kFromUnknown,
@@ -113,6 +124,9 @@ class RemoteFontFaceSource final : public CSSFontFaceSource,
DataSource data_source_;
};
+ Document* GetDocument() const;
+
+ DisplayPeriod ComputePeriod() const;
void UpdatePeriod();
bool ShouldTriggerWebFontsIntervention();
bool IsLowPriorityLoadingAllowedForRemoteFont() const override;
@@ -132,6 +146,7 @@ class RemoteFontFaceSource final : public CSSFontFaceSource,
DisplayPeriod period_;
FontLoadHistograms histograms_;
bool is_intervention_triggered_;
+ bool finished_before_document_rendering_begin_;
};
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/cascade_expansion.cc b/chromium/third_party/blink/renderer/core/css/resolver/cascade_expansion.cc
new file mode 100644
index 00000000000..fca902cce4d
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/resolver/cascade_expansion.cc
@@ -0,0 +1,189 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/blink/renderer/core/css/resolver/cascade_expansion.h"
+
+#include "third_party/blink/renderer/core/css/resolver/match_result.h"
+#include "third_party/blink/renderer/core/css/rule_set.h"
+
+namespace blink {
+
+namespace {
+
+CascadeFilter AddValidPropertiesFilter(
+ CascadeFilter filter,
+ const MatchedProperties& matched_properties) {
+ switch (static_cast<ValidPropertyFilter>(
+ matched_properties.types_.valid_property_filter)) {
+ case ValidPropertyFilter::kNoFilter:
+ return filter;
+ case ValidPropertyFilter::kCue:
+ return filter.Add(CSSProperty::kValidForCue, false);
+ case ValidPropertyFilter::kFirstLetter:
+ return filter.Add(CSSProperty::kValidForFirstLetter, false);
+ case ValidPropertyFilter::kMarker:
+ return filter.Add(CSSProperty::kValidForMarker, false);
+ }
+}
+
+CascadeFilter AddLinkFilter(CascadeFilter filter,
+ const MatchedProperties& matched_properties) {
+ switch (matched_properties.types_.link_match_type) {
+ case CSSSelector::kMatchVisited:
+ return filter.Add(CSSProperty::kVisited, false);
+ case CSSSelector::kMatchLink:
+ return filter.Add(CSSProperty::kVisited, true);
+ case CSSSelector::kMatchAll:
+ return filter;
+ default:
+ return filter.Add(CSSProperty::kProperty, true);
+ }
+}
+
+CascadeFilter AmendFilter(CascadeFilter filter,
+ const MatchedProperties& matched_properties) {
+ return AddLinkFilter(AddValidPropertiesFilter(filter, matched_properties),
+ matched_properties);
+}
+
+} // anonymous namespace
+
+CascadeExpansion::CascadeExpansion(const MatchedProperties& matched_properties,
+ const Document& document,
+ CascadeFilter filter,
+ size_t matched_properties_index)
+ : document_(document),
+ matched_properties_(matched_properties),
+ size_(matched_properties.properties->PropertyCount()),
+ filter_(AmendFilter(filter, matched_properties)),
+ matched_properties_index_(matched_properties_index) {
+ // We can't handle a MatchResult with more than 0xFFFF MatchedProperties,
+ // or a MatchedProperties object with more than 0xFFFF declarations. If this
+ // happens, we skip right to the end, and emit nothing.
+ if (size_ > kMaxDeclarationIndex + 1 ||
+ matched_properties_index_ > kMaxMatchedPropertiesIndex) {
+ index_ = size_;
+ } else {
+ Next();
+ }
+}
+
+CascadeExpansion::CascadeExpansion(const CascadeExpansion& o)
+ : document_(o.document_),
+ state_(o.state_),
+ matched_properties_(o.matched_properties_),
+ priority_(o.priority_),
+ index_(o.index_),
+ size_(o.size_),
+ filter_(o.filter_),
+ matched_properties_index_(o.matched_properties_index_),
+ id_(o.id_),
+ property_(id_ == CSSPropertyID::kVariable ? &custom_ : o.property_),
+ custom_(o.custom_) {}
+
+void CascadeExpansion::Next() {
+ do {
+ switch (state_) {
+ case State::kInit:
+ AdvanceNormal();
+ break;
+ case State::kNormal:
+ if (ShouldEmitVisited() && AdvanceVisited())
+ break;
+ AdvanceNormal();
+ break;
+ case State::kVisited:
+ AdvanceNormal();
+ break;
+ case State::kAll:
+ AdvanceAll();
+ break;
+ }
+ } while (!AtEnd() && filter_.Rejects(*property_));
+}
+
+bool CascadeExpansion::IsAffectedByAll(CSSPropertyID id) {
+ const CSSProperty& property = CSSProperty::Get(id);
+ return !property.IsShorthand() && property.IsAffectedByAll();
+}
+
+bool CascadeExpansion::ShouldEmitVisited() const {
+ // This check is slightly redundant, as the emitted property would anyway
+ // be skipped by the do-while in Next(). However, it's probably good to avoid
+ // entering State::kVisited at all, if we can avoid it.
+ return !filter_.Rejects(CSSProperty::kVisited, true);
+}
+
+void CascadeExpansion::AdvanceNormal() {
+ state_ = State::kNormal;
+ ++index_;
+ if (AtEnd())
+ return;
+ auto reference = PropertyAt(index_);
+ const auto& metadata = reference.PropertyMetadata();
+ id_ = metadata.property_->PropertyID();
+ priority_ = CascadePriority(
+ matched_properties_.types_.origin, metadata.important_,
+ matched_properties_.types_.tree_order,
+ EncodeMatchResultPosition(matched_properties_index_, index_));
+
+ switch (id_) {
+ case CSSPropertyID::kVariable:
+ custom_ = CustomProperty(reference.Name().ToAtomicString(), document_);
+ property_ = &custom_;
+ break;
+ case CSSPropertyID::kAll:
+ state_ = State::kAll;
+ id_ = firstCSSProperty;
+ property_ = &CSSProperty::Get(id_);
+ // If this DCHECK is triggered, it means firstCSSProperty is not affected
+ // by 'all', and we need a function for figuring out the first property
+ // that _is_ affected by 'all'.
+ DCHECK(IsAffectedByAll(id_));
+ break;
+ default:
+ property_ = metadata.property_;
+ break;
+ }
+
+ DCHECK(property_);
+}
+
+bool CascadeExpansion::AdvanceVisited() {
+ DCHECK(ShouldEmitVisited());
+ DCHECK(property_);
+ const CSSProperty* visited = property_->GetVisitedProperty();
+ if (!visited)
+ return false;
+ property_ = visited;
+ id_ = visited->PropertyID();
+ state_ = State::kVisited;
+ return true;
+}
+
+void CascadeExpansion::AdvanceAll() {
+ state_ = State::kAll;
+
+ int i = static_cast<int>(id_) + 1;
+ int end = kIntLastCSSProperty + 1;
+
+ for (; i < end; ++i) {
+ id_ = convertToCSSPropertyID(i);
+ if (IsAffectedByAll(id_))
+ break;
+ }
+
+ if (i >= end)
+ AdvanceNormal();
+ else
+ property_ = &CSSProperty::Get(id_);
+}
+
+CSSPropertyValueSet::PropertyReference CascadeExpansion::PropertyAt(
+ size_t index) const {
+ DCHECK(!AtEnd());
+ return matched_properties_.properties->PropertyAt(index_);
+}
+
+} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/cascade_expansion.h b/chromium/third_party/blink/renderer/core/css/resolver/cascade_expansion.h
new file mode 100644
index 00000000000..af6d8d2ca56
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/resolver/cascade_expansion.h
@@ -0,0 +1,143 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_EXPANSION_H_
+#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_EXPANSION_H_
+
+#include <limits>
+#include "third_party/blink/renderer/core/css/properties/longhands/custom_property.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_filter.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_origin.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_priority.h"
+#include "third_party/blink/renderer/core/style/computed_style_base_constants.h"
+
+namespace blink {
+
+struct MatchedProperties;
+
+inline uint32_t EncodeMatchResultPosition(uint16_t block,
+ uint16_t declaration) {
+ return (static_cast<uint32_t>(block) << 16) | declaration;
+}
+
+inline size_t DecodeMatchedPropertiesIndex(uint32_t position) {
+ return (position >> 16) & 0xFFFF;
+}
+
+inline size_t DecodeDeclarationIndex(uint32_t position) {
+ return position & 0xFFFF;
+}
+
+// CascadeExpansion takes a declaration block (MatchedProperties) and
+// expands the declarations found into the final list of declarations observed
+// by StyleCascade. It exists to prevent callers to deal with the complexity
+// of the 'all' property, '-internal-visited-' properties, '-internal-ua-'
+// properties, and filtering of both regular declarations and "generated"
+// declarations.
+//
+// For example, for the declaration block:
+//
+// top:1px;
+// all:unset;
+// top:2px;
+//
+// CascadeExpansion would emit:
+//
+// top:1px;
+// animation-delay:unset;
+// animation-direction:unset;
+// /* ... <all longhands affected by 'all'> ... */
+// -webkit-text-emphasis:unset;
+// -webkit-text-stroke:unset;
+// top:2px;
+//
+// In other words, 'all' is expanded into the actual longhands it represents.
+// A similar expansion happens for properties which have companion
+// -internal-visited-* properties (depending on inside-link status).
+//
+// Usage:
+//
+// CascadeExpansion e = ...;
+// for (; !e.AtEnd(); a.Next())
+// DoStuff(e);
+//
+class CORE_EXPORT CascadeExpansion {
+ STACK_ALLOCATED();
+
+ enum class State { kInit, kNormal, kVisited, kAll };
+
+ public:
+ // CascadeExpansion objects which exceed these limits will emit nothing.
+ static constexpr size_t kMaxDeclarationIndex =
+ std::numeric_limits<uint16_t>::max();
+ static constexpr size_t kMaxMatchedPropertiesIndex =
+ std::numeric_limits<uint16_t>::max();
+
+ CascadeExpansion(const MatchedProperties&,
+ const Document&,
+ CascadeFilter,
+ size_t matched_properties_index);
+ // We need an explicit copy constructor, since CascadeExpansion has self-
+ // pointers.
+ CascadeExpansion(const CascadeExpansion& o);
+ void Next();
+ inline bool AtEnd() const { return index_ >= size_; }
+ inline CSSPropertyID Id() const { return id_; }
+ inline CSSPropertyName Name() const {
+ if (id_ != CSSPropertyID::kVariable)
+ return CSSPropertyName(id_);
+ return Property().GetCSSPropertyName();
+ }
+ inline const CSSProperty& Property() const {
+ DCHECK(!AtEnd());
+ return *property_;
+ }
+ inline const CSSValue& Value() const {
+ DCHECK(!AtEnd());
+ return PropertyAt(index_).Value();
+ }
+ inline CascadePriority Priority() const { return priority_; }
+
+ private:
+ static bool IsAffectedByAll(CSSPropertyID);
+
+ bool ShouldEmitVisited() const;
+
+ void AdvanceNormal();
+ bool AdvanceVisited();
+ void AdvanceAll();
+
+ CSSPropertyValueSet::PropertyReference PropertyAt(size_t) const;
+
+ const Document& document_;
+ State state_ = State::kInit;
+ const MatchedProperties& matched_properties_;
+
+ // The priority of the current declaration pointed to by index_. This does
+ // not change for generated declarations.
+ CascadePriority priority_;
+
+ // Index and size of the regular declarations. In other words, index_ will
+ // only move during State::kNormal, and not while expanding 'all', etc. It
+ // will always point to a valid index in matched_properties_ (unless we're
+ // AtEnd()).
+ //
+ // Note that this is initialized to ~0 such that the first call to Next()
+ // (done by the constructor) will produce ~0+1 = 0.
+ size_t index_ = std::numeric_limits<size_t>::max();
+ size_t size_;
+
+ CascadeFilter filter_;
+ const size_t matched_properties_index_;
+
+ // The id/property of the current "virtual" declaration. In other words,
+ // the id/property will be updated when expanding 'all', etc.
+ CSSPropertyID id_ = CSSPropertyID::kInvalid;
+ const CSSProperty* property_ = nullptr;
+ CustomProperty custom_;
+};
+
+} // namespace blink
+
+#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_EXPANSION_H_
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/cascade_expansion_test.cc b/chromium/third_party/blink/renderer/core/css/resolver/cascade_expansion_test.cc
new file mode 100644
index 00000000000..dec485885e1
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/resolver/cascade_expansion_test.cc
@@ -0,0 +1,636 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/blink/renderer/core/css/resolver/cascade_expansion.h"
+
+#include "third_party/blink/renderer/core/css/css_property_value_set.h"
+#include "third_party/blink/renderer/core/css/css_selector.h"
+#include "third_party/blink/renderer/core/css/css_test_helpers.h"
+#include "third_party/blink/renderer/core/css/css_unset_value.h"
+#include "third_party/blink/renderer/core/css/resolver/match_result.h"
+#include "third_party/blink/renderer/core/css/rule_set.h"
+#include "third_party/blink/renderer/core/testing/page_test_base.h"
+#include "third_party/blink/renderer/platform/heap/heap.h"
+
+namespace blink {
+
+using css_test_helpers::ParseDeclarationBlock;
+
+class CascadeExpansionTest : public PageTestBase {
+ public:
+ CascadeExpansion ExpansionAt(const MatchResult& result,
+ size_t i,
+ CascadeFilter filter = CascadeFilter()) {
+ return CascadeExpansion(result.GetMatchedProperties()[i], GetDocument(),
+ filter, i);
+ }
+
+ Vector<CSSPropertyID> AllProperties(CascadeFilter filter = CascadeFilter()) {
+ Vector<CSSPropertyID> all;
+ for (CSSPropertyID id : CSSPropertyIDList()) {
+ const CSSProperty& property = CSSProperty::Get(id);
+ if (property.IsShorthand())
+ continue;
+ if (!property.IsAffectedByAll())
+ continue;
+ if (filter.Rejects(property))
+ continue;
+ all.push_back(id);
+ }
+ return all;
+ }
+};
+
+TEST_F(CascadeExpansionTest, UARules) {
+ MatchResult result;
+ result.AddMatchedProperties(ParseDeclarationBlock("cursor:help;top:1px"));
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ ASSERT_EQ(1u, result.GetMatchedProperties().size());
+
+ auto e = ExpansionAt(result, 0);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kCursor, e.Id());
+ EXPECT_EQ(CascadeOrigin::kUserAgent, e.Priority().GetOrigin());
+ e.Next();
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kTop, e.Id());
+ EXPECT_EQ(CascadeOrigin::kUserAgent, e.Priority().GetOrigin());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+}
+
+TEST_F(CascadeExpansionTest, UserRules) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.AddMatchedProperties(ParseDeclarationBlock("cursor:help"));
+ result.AddMatchedProperties(ParseDeclarationBlock("float:left"));
+ result.FinishAddingUserRules();
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ ASSERT_EQ(2u, result.GetMatchedProperties().size());
+
+ {
+ auto e = ExpansionAt(result, 0);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kCursor, e.Id());
+ EXPECT_EQ(CascadeOrigin::kUser, e.Priority().GetOrigin());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+ }
+
+ {
+ auto e = ExpansionAt(result, 1);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kFloat, e.Id());
+ EXPECT_EQ(CascadeOrigin::kUser, e.Priority().GetOrigin());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+ }
+}
+
+TEST_F(CascadeExpansionTest, AuthorRules) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(ParseDeclarationBlock("cursor:help;top:1px"));
+ result.AddMatchedProperties(ParseDeclarationBlock("float:left"));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ ASSERT_EQ(2u, result.GetMatchedProperties().size());
+
+ {
+ auto e = ExpansionAt(result, 0);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kCursor, e.Id());
+ EXPECT_EQ(CascadeOrigin::kAuthor, e.Priority().GetOrigin());
+ e.Next();
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kTop, e.Id());
+ EXPECT_EQ(CascadeOrigin::kAuthor, e.Priority().GetOrigin());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+ }
+
+ {
+ auto e = ExpansionAt(result, 1);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kFloat, e.Id());
+ EXPECT_EQ(CascadeOrigin::kAuthor, e.Priority().GetOrigin());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+ }
+}
+
+TEST_F(CascadeExpansionTest, AllOriginRules) {
+ MatchResult result;
+ result.AddMatchedProperties(ParseDeclarationBlock("font-size:2px"));
+ result.FinishAddingUARules();
+ result.AddMatchedProperties(ParseDeclarationBlock("cursor:help;top:1px"));
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(ParseDeclarationBlock("left:1px"));
+ result.AddMatchedProperties(ParseDeclarationBlock("float:left"));
+ result.FinishAddingAuthorRulesForTreeScope();
+ result.AddMatchedProperties(ParseDeclarationBlock("bottom:2px"));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ ASSERT_EQ(5u, result.GetMatchedProperties().size());
+
+ {
+ auto e = ExpansionAt(result, 0);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kFontSize, e.Id());
+ EXPECT_EQ(CascadeOrigin::kUserAgent, e.Priority().GetOrigin());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+ }
+
+ {
+ auto e = ExpansionAt(result, 1);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kCursor, e.Id());
+ EXPECT_EQ(CascadeOrigin::kUser, e.Priority().GetOrigin());
+ e.Next();
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kTop, e.Id());
+ EXPECT_EQ(CascadeOrigin::kUser, e.Priority().GetOrigin());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+ }
+
+ {
+ auto e = ExpansionAt(result, 2);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kLeft, e.Id());
+ EXPECT_EQ(CascadeOrigin::kAuthor, e.Priority().GetOrigin());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+ }
+
+ {
+ auto e = ExpansionAt(result, 3);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kFloat, e.Id());
+ EXPECT_EQ(CascadeOrigin::kAuthor, e.Priority().GetOrigin());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+ }
+
+ {
+ auto e = ExpansionAt(result, 4);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kBottom, e.Id());
+ EXPECT_EQ(CascadeOrigin::kAuthor, e.Priority().GetOrigin());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+ }
+}
+
+TEST_F(CascadeExpansionTest, Name) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(ParseDeclarationBlock("--x:1px;--y:2px"));
+ result.AddMatchedProperties(ParseDeclarationBlock("float:left"));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ ASSERT_EQ(2u, result.GetMatchedProperties().size());
+
+ {
+ auto e = ExpansionAt(result, 0);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyName("--x"), e.Name());
+ EXPECT_EQ(CSSPropertyID::kVariable, e.Id());
+ e.Next();
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyName("--y"), e.Name());
+ EXPECT_EQ(CSSPropertyID::kVariable, e.Id());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+ }
+
+ {
+ auto e = ExpansionAt(result, 1);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyName(CSSPropertyID::kFloat), e.Name());
+ EXPECT_EQ(CSSPropertyID::kFloat, e.Id());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+ }
+}
+
+TEST_F(CascadeExpansionTest, Value) {
+ MatchResult result;
+ result.AddMatchedProperties(ParseDeclarationBlock("background-color:red"));
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ ASSERT_EQ(1u, result.GetMatchedProperties().size());
+
+ auto e = ExpansionAt(result, 0);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kBackgroundColor, e.Id());
+ EXPECT_EQ("red", e.Value().CssText());
+ e.Next();
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kInternalVisitedBackgroundColor, e.Id());
+ EXPECT_EQ("red", e.Value().CssText());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+}
+
+TEST_F(CascadeExpansionTest, LinkOmitted) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(ParseDeclarationBlock("color:red"),
+ CSSSelector::kMatchVisited);
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ ASSERT_EQ(1u, result.GetMatchedProperties().size());
+
+ auto e = ExpansionAt(result, 0);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kInternalVisitedColor, e.Id());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+}
+
+TEST_F(CascadeExpansionTest, InternalVisited) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(ParseDeclarationBlock("color:red"));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ ASSERT_EQ(1u, result.GetMatchedProperties().size());
+
+ auto e = ExpansionAt(result, 0);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kColor, e.Id());
+ e.Next();
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kInternalVisitedColor, e.Id());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+}
+
+TEST_F(CascadeExpansionTest, InternalVisitedOmitted) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(ParseDeclarationBlock("color:red"),
+ CSSSelector::kMatchLink);
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ ASSERT_EQ(1u, result.GetMatchedProperties().size());
+
+ auto e = ExpansionAt(result, 0);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kColor, e.Id());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+}
+
+TEST_F(CascadeExpansionTest, InternalVisitedWithTrailer) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(ParseDeclarationBlock("color:red;left:1px"));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ ASSERT_EQ(1u, result.GetMatchedProperties().size());
+
+ auto e = ExpansionAt(result, 0);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kColor, e.Id());
+ e.Next();
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kInternalVisitedColor, e.Id());
+ e.Next();
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kLeft, e.Id());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+}
+
+TEST_F(CascadeExpansionTest, All) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(ParseDeclarationBlock("all:unset"));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ ASSERT_EQ(1u, result.GetMatchedProperties().size());
+
+ auto e = ExpansionAt(result, 0);
+
+ for (CSSPropertyID expected : AllProperties()) {
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(expected, e.Id());
+ e.Next();
+ }
+
+ EXPECT_TRUE(e.AtEnd());
+}
+
+TEST_F(CascadeExpansionTest, InlineAll) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(
+ ParseDeclarationBlock("left:1px;all:unset;right:1px"));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ ASSERT_EQ(1u, result.GetMatchedProperties().size());
+
+ auto e = ExpansionAt(result, 0);
+
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kLeft, e.Id());
+ e.Next();
+
+ for (CSSPropertyID expected : AllProperties()) {
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(expected, e.Id());
+ e.Next();
+ }
+
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kRight, e.Id());
+ e.Next();
+
+ EXPECT_TRUE(e.AtEnd());
+}
+
+TEST_F(CascadeExpansionTest, FilterNormalNonInherited) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(ParseDeclarationBlock("font-size:1px;left:1px"));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ ASSERT_EQ(1u, result.GetMatchedProperties().size());
+
+ CascadeFilter filter(CSSProperty::kInherited, false);
+
+ auto e = ExpansionAt(result, 0, filter);
+
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kFontSize, e.Id());
+ e.Next();
+
+ EXPECT_TRUE(e.AtEnd());
+}
+
+TEST_F(CascadeExpansionTest, FilterInternalVisited) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(ParseDeclarationBlock("color:red"));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ CascadeFilter filter(CSSProperty::kVisited, true);
+
+ ASSERT_EQ(1u, result.GetMatchedProperties().size());
+
+ auto e = ExpansionAt(result, 0, filter);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kColor, e.Id());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+}
+
+TEST_F(CascadeExpansionTest, FilterFirstLetter) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(
+ ParseDeclarationBlock("object-fit:unset;font-size:1px"),
+ CSSSelector::kMatchAll, ValidPropertyFilter::kFirstLetter);
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ auto e = ExpansionAt(result, 0);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kFontSize, e.Id());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+}
+
+TEST_F(CascadeExpansionTest, FilterCue) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(
+ ParseDeclarationBlock("object-fit:unset;font-size:1px"),
+ CSSSelector::kMatchAll, ValidPropertyFilter::kCue);
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ auto e = ExpansionAt(result, 0);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kFontSize, e.Id());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+}
+
+TEST_F(CascadeExpansionTest, FilterMarker) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(
+ ParseDeclarationBlock("object-fit:unset;font-size:1px"),
+ CSSSelector::kMatchAll, ValidPropertyFilter::kMarker);
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ auto e = ExpansionAt(result, 0);
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kFontSize, e.Id());
+ e.Next();
+ EXPECT_TRUE(e.AtEnd());
+}
+
+TEST_F(CascadeExpansionTest, FilterAllNonInherited) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(ParseDeclarationBlock("all:unset"));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ ASSERT_EQ(1u, result.GetMatchedProperties().size());
+
+ CascadeFilter filter(CSSProperty::kInherited, false);
+
+ auto e = ExpansionAt(result, 0, filter);
+
+ for (CSSPropertyID expected : AllProperties(filter)) {
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(expected, e.Id());
+ e.Next();
+ }
+
+ EXPECT_TRUE(e.AtEnd());
+}
+
+TEST_F(CascadeExpansionTest, Importance) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(
+ ParseDeclarationBlock("cursor:help;display:block !important"));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ ASSERT_EQ(1u, result.GetMatchedProperties().size());
+
+ auto e = ExpansionAt(result, 0);
+
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kCursor, e.Id());
+ EXPECT_FALSE(e.Priority().IsImportant());
+ e.Next();
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kDisplay, e.Id());
+ EXPECT_TRUE(e.Priority().IsImportant());
+ e.Next();
+
+ EXPECT_TRUE(e.AtEnd());
+}
+
+TEST_F(CascadeExpansionTest, AllImportance) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(ParseDeclarationBlock("all:unset !important"));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ ASSERT_EQ(1u, result.GetMatchedProperties().size());
+
+ auto e = ExpansionAt(result, 0);
+
+ for (CSSPropertyID expected : AllProperties()) {
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(expected, e.Id());
+ EXPECT_TRUE(e.Priority().IsImportant());
+ e.Next();
+ }
+
+ EXPECT_TRUE(e.AtEnd());
+}
+
+TEST_F(CascadeExpansionTest, AllNonImportance) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(ParseDeclarationBlock("all:unset"));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ ASSERT_EQ(1u, result.GetMatchedProperties().size());
+
+ auto e = ExpansionAt(result, 0);
+
+ for (CSSPropertyID expected : AllProperties()) {
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(expected, e.Id());
+ EXPECT_FALSE(e.Priority().IsImportant());
+ e.Next();
+ }
+
+ EXPECT_TRUE(e.AtEnd());
+}
+
+TEST_F(CascadeExpansionTest, Position) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(ParseDeclarationBlock("left:1px;top:1px"));
+ result.AddMatchedProperties(ParseDeclarationBlock("bottom:1px;right:1px"));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ ASSERT_EQ(2u, result.GetMatchedProperties().size());
+
+ {
+ auto e = ExpansionAt(result, 0);
+
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kLeft, e.Id());
+ EXPECT_EQ(0u, DecodeMatchedPropertiesIndex(e.Priority().GetPosition()));
+ EXPECT_EQ(0u, DecodeDeclarationIndex(e.Priority().GetPosition()));
+ e.Next();
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kTop, e.Id());
+ EXPECT_EQ(0u, DecodeMatchedPropertiesIndex(e.Priority().GetPosition()));
+ EXPECT_EQ(1u, DecodeDeclarationIndex(e.Priority().GetPosition()));
+ e.Next();
+
+ EXPECT_TRUE(e.AtEnd());
+ }
+
+ {
+ auto e = ExpansionAt(result, 1);
+
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kBottom, e.Id());
+ EXPECT_EQ(1u, DecodeMatchedPropertiesIndex(e.Priority().GetPosition()));
+ EXPECT_EQ(0u, DecodeDeclarationIndex(e.Priority().GetPosition()));
+ e.Next();
+ ASSERT_FALSE(e.AtEnd());
+ EXPECT_EQ(CSSPropertyID::kRight, e.Id());
+ EXPECT_EQ(1u, DecodeMatchedPropertiesIndex(e.Priority().GetPosition()));
+ EXPECT_EQ(1u, DecodeDeclarationIndex(e.Priority().GetPosition()));
+ e.Next();
+
+ EXPECT_TRUE(e.AtEnd());
+ }
+}
+
+TEST_F(CascadeExpansionTest, MatchedPropertiesLimit) {
+ constexpr size_t max = std::numeric_limits<uint16_t>::max();
+
+ static_assert(CascadeExpansion::kMaxMatchedPropertiesIndex == max,
+ "Unexpected max. If the limit increased, evaluate whether it "
+ "still makes sense to run this test");
+
+ auto* set = ParseDeclarationBlock("left:1px");
+
+ MatchResult result;
+ for (size_t i = 0; i < max + 3; ++i)
+ result.AddMatchedProperties(set);
+
+ ASSERT_EQ(max + 3u, result.GetMatchedProperties().size());
+
+ for (size_t i = 0; i < max + 1; ++i)
+ EXPECT_FALSE(ExpansionAt(result, i).AtEnd());
+
+ // The indices beyond the max should not yield anything.
+ EXPECT_TRUE(ExpansionAt(result, max + 1).AtEnd());
+ EXPECT_TRUE(ExpansionAt(result, max + 2).AtEnd());
+}
+
+TEST_F(CascadeExpansionTest, MatchedDeclarationsLimit) {
+ constexpr size_t max = std::numeric_limits<uint16_t>::max();
+
+ static_assert(CascadeExpansion::kMaxDeclarationIndex == max,
+ "Unexpected max. If the limit increased, evaluate whether it "
+ "still makes sense to run this test");
+
+ HeapVector<CSSPropertyValue> declarations(max + 2);
+
+ // Actually give the first index a value, such that the initial call to
+ // Next() does not crash.
+ declarations[0] = CSSPropertyValue(GetCSSPropertyColor(),
+ *cssvalue::CSSUnsetValue::Create());
+
+ MatchResult result;
+ result.AddMatchedProperties(ImmutableCSSPropertyValueSet::Create(
+ declarations.data(), max + 1, kHTMLStandardMode));
+ result.AddMatchedProperties(ImmutableCSSPropertyValueSet::Create(
+ declarations.data(), max + 2, kHTMLStandardMode));
+
+ EXPECT_FALSE(ExpansionAt(result, 0).AtEnd());
+ EXPECT_TRUE(ExpansionAt(result, 1).AtEnd());
+}
+
+} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/cascade_filter.h b/chromium/third_party/blink/renderer/core/css/resolver/cascade_filter.h
new file mode 100644
index 00000000000..bef63b8bf39
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/resolver/cascade_filter.h
@@ -0,0 +1,101 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_FILTER_H_
+#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_FILTER_H_
+
+#include "third_party/blink/renderer/core/core_export.h"
+#include "third_party/blink/renderer/core/css/properties/css_property.h"
+
+namespace blink {
+
+// Reject properties with the given flags set or unset.
+//
+// For example, the following applies only inherited properties that don't apply
+// to ::first-letter:
+//
+// CascadeFilter filter;
+// filter = filter.Add(CSSProperty::kInherited, false);
+// filter = filter.Add(CSSProperty::kValidForFirstLetter, true);
+// filter.Reject(GetCSSPropertyColor()); // -> false
+// filter.Reject(GetCSSPropertyDirection()); // -> true
+// filter.Reject(GetCSSPropertyTop()); // -> true
+//
+class CORE_EXPORT CascadeFilter {
+ public:
+ // Empty filter. Rejects nothing.
+ CascadeFilter() = default;
+
+ // Creates a filter with a single rule.
+ //
+ // This is equivalent to:
+ //
+ // CascadeFilter filter;
+ // filter.Add(flag, v);
+ //
+ CascadeFilter(CSSProperty::Flag flag, bool v)
+ : mask_(flag), flags_(v ? flag : 0) {}
+
+ bool operator==(const CascadeFilter& o) const {
+ return mask_ == o.mask_ && flags_ == o.flags_;
+ }
+ bool operator!=(const CascadeFilter& o) const {
+ return mask_ != o.mask_ || flags_ != o.flags_;
+ }
+
+ // Add a given rule to the filter.
+ //
+ // A flag can be rejected when it's either set or unset. For example
+ //
+ // CascadeFilter f1(CSSProperty::kInherited, true); // Rejects inherited
+ // CascadeFilter f2(CSSProperty::kInherited, false); // Rejects non-inherited
+ //
+ // Note that it's not possible to reject both set and unset flags in the same
+ // filter. However, if you wish to reject all properties, you can do so by
+ // using the CSSProperty::kProperty flag.
+ //
+ // Add() will have no effect if there already is a rule for the given flag:
+ //
+ // CascadeFilter filter;
+ // CascadeFilter f1 = filter.Add(CSSProperty::kInherited, true);
+ // CascadeFilter f2 = f1.Add(CSSProperty::kInherited, false);
+ // bool equal = f1 == f2; // true. Second call to Add had to effect.
+ //
+ // If you want to overwrite a previous rule, use Set().
+ CascadeFilter Add(CSSProperty::Flag flag, bool v) const {
+ const CSSProperty::Flags mask = mask_ | flag;
+ const CSSProperty::Flags flags =
+ v ? (flags_ | (flag & ~mask_)) : (flags_ & ~(flag & ~mask_));
+ return CascadeFilter(mask, flags);
+ }
+
+ // Like Add, except overwrites a previous rule for the same flag.
+ CascadeFilter Set(CSSProperty::Flag flag, bool v) const {
+ const CSSProperty::Flags mask = mask_ | flag;
+ const CSSProperty::Flags flags = v ? (flags_ | flag) : (flags_ & ~flag);
+ return CascadeFilter(mask, flags);
+ }
+
+ bool Rejects(const CSSProperty& property) const {
+ return ~(property.GetFlags() ^ flags_) & mask_;
+ }
+
+ bool Rejects(CSSProperty::Flag flag, bool v) const {
+ return ~((v ? flag : 0) ^ flags_) & (mask_ & flag);
+ }
+
+ private:
+ CascadeFilter(CSSProperty::Flags mask, CSSProperty::Flags flags)
+ : mask_(mask), flags_(flags) {}
+ // Specifies which bits are significant in flags_. In other words, mask_
+ // contains a '1' at the corresponding position for each flag seen by
+ // Add().
+ CSSProperty::Flags mask_ = 0;
+ // Contains the flags to exclude. Only bits set in mask_ matter.
+ CSSProperty::Flags flags_ = 0;
+};
+
+} // namespace blink
+
+#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_FILTER_H_
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/cascade_filter_test.cc b/chromium/third_party/blink/renderer/core/css/resolver/cascade_filter_test.cc
new file mode 100644
index 00000000000..2ef0adaa4f6
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/resolver/cascade_filter_test.cc
@@ -0,0 +1,121 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/blink/renderer/core/css/resolver/cascade_filter.h"
+#include <gtest/gtest.h>
+
+namespace blink {
+
+TEST(CascadeFilterTest, FilterNothing) {
+ CascadeFilter filter;
+ EXPECT_FALSE(filter.Rejects(GetCSSPropertyBackgroundColor()));
+ EXPECT_FALSE(filter.Rejects(GetCSSPropertyColor()));
+ EXPECT_FALSE(filter.Rejects(GetCSSPropertyDisplay()));
+ EXPECT_FALSE(filter.Rejects(GetCSSPropertyFloat()));
+ EXPECT_FALSE(filter.Rejects(GetCSSPropertyInternalVisitedColor()));
+}
+
+TEST(CascadeFilterTest, ConstructorBehavesLikeSingleAdd) {
+ EXPECT_EQ(CascadeFilter().Add(CSSProperty::kInherited, true),
+ CascadeFilter(CSSProperty::kInherited, true));
+ EXPECT_EQ(CascadeFilter().Add(CSSProperty::kInherited, false),
+ CascadeFilter(CSSProperty::kInherited, false));
+}
+
+TEST(CascadeFilterTest, Equals) {
+ EXPECT_EQ(CascadeFilter(CSSProperty::kInherited, true),
+ CascadeFilter(CSSProperty::kInherited, true));
+ EXPECT_EQ(CascadeFilter(CSSProperty::kInherited, false),
+ CascadeFilter(CSSProperty::kInherited, false));
+}
+
+TEST(CascadeFilterTest, NotEqualsMask) {
+ EXPECT_NE(CascadeFilter(CSSProperty::kInherited, true),
+ CascadeFilter(CSSProperty::kInherited, false));
+ EXPECT_NE(CascadeFilter(CSSProperty::kInherited, false),
+ CascadeFilter(CSSProperty::kVisited, false));
+ EXPECT_NE(CascadeFilter(CSSProperty::kInherited, false),
+ CascadeFilter(CSSProperty::kInherited, false)
+ .Add(CSSProperty::kVisited, false));
+ EXPECT_NE(CascadeFilter(CSSProperty::kInherited, false), CascadeFilter());
+}
+
+TEST(CascadeFilterTest, FilterInherited) {
+ CascadeFilter filter(CSSProperty::kInherited, true);
+ EXPECT_FALSE(filter.Rejects(GetCSSPropertyBackgroundColor()));
+ EXPECT_TRUE(filter.Rejects(GetCSSPropertyColor()));
+ EXPECT_TRUE(filter.Rejects(GetCSSPropertyFontSize()));
+ EXPECT_FALSE(filter.Rejects(GetCSSPropertyDisplay()));
+ EXPECT_FALSE(filter.Rejects(GetCSSPropertyFloat()));
+ EXPECT_TRUE(filter.Rejects(GetCSSPropertyInternalVisitedColor()));
+}
+
+TEST(CascadeFilterTest, FilterNonInherited) {
+ CascadeFilter filter(CSSProperty::kInherited, false);
+ EXPECT_TRUE(filter.Rejects(GetCSSPropertyBackgroundColor()));
+ EXPECT_FALSE(filter.Rejects(GetCSSPropertyColor()));
+ EXPECT_TRUE(filter.Rejects(GetCSSPropertyDisplay()));
+ EXPECT_TRUE(filter.Rejects(GetCSSPropertyFloat()));
+ EXPECT_FALSE(filter.Rejects(GetCSSPropertyInternalVisitedColor()));
+}
+
+TEST(CascadeFilterTest, FilterVisitedAndInherited) {
+ auto filter = CascadeFilter()
+ .Add(CSSProperty::kVisited, true)
+ .Add(CSSProperty::kInherited, true);
+ EXPECT_FALSE(filter.Rejects(GetCSSPropertyBackgroundColor()));
+ EXPECT_TRUE(filter.Rejects(GetCSSPropertyColor()));
+ EXPECT_FALSE(filter.Rejects(GetCSSPropertyDisplay()));
+ EXPECT_FALSE(filter.Rejects(GetCSSPropertyFloat()));
+ EXPECT_TRUE(filter.Rejects(GetCSSPropertyInternalVisitedBackgroundColor()));
+}
+
+TEST(CascadeFilterTest, FilterVisitedAndNonInherited) {
+ auto filter = CascadeFilter()
+ .Add(CSSProperty::kVisited, true)
+ .Add(CSSProperty::kInherited, false);
+ EXPECT_TRUE(filter.Rejects(GetCSSPropertyBackgroundColor()));
+ EXPECT_FALSE(filter.Rejects(GetCSSPropertyColor()));
+ EXPECT_TRUE(filter.Rejects(GetCSSPropertyDisplay()));
+ EXPECT_TRUE(filter.Rejects(GetCSSPropertyFloat()));
+ EXPECT_TRUE(filter.Rejects(GetCSSPropertyInternalVisitedColor()));
+}
+
+TEST(CascadeFilterTest, RejectFlag) {
+ auto filter = CascadeFilter()
+ .Add(CSSProperty::kVisited, true)
+ .Add(CSSProperty::kInherited, false);
+ EXPECT_TRUE(filter.Rejects(CSSProperty::kVisited, true));
+ EXPECT_TRUE(filter.Rejects(CSSProperty::kInherited, false));
+ EXPECT_FALSE(filter.Rejects(CSSProperty::kVisited, false));
+ EXPECT_FALSE(filter.Rejects(CSSProperty::kInherited, true));
+}
+
+TEST(CascadeFilterTest, AddDoesNotOverwrite) {
+ auto filter = CascadeFilter()
+ .Add(CSSProperty::kVisited, true)
+ .Add(CSSProperty::kInherited, false);
+ EXPECT_TRUE(filter.Rejects(CSSProperty::kVisited, true));
+ EXPECT_TRUE(filter.Rejects(CSSProperty::kInherited, false));
+ filter = filter.Add(CSSProperty::kVisited, false);
+ filter = filter.Add(CSSProperty::kInherited, true);
+ // Add has no effect if flags are already set:
+ EXPECT_TRUE(filter.Rejects(CSSProperty::kVisited, true));
+ EXPECT_TRUE(filter.Rejects(CSSProperty::kInherited, false));
+}
+
+TEST(CascadeFilterTest, SetDoesOverwrite) {
+ auto filter = CascadeFilter()
+ .Add(CSSProperty::kVisited, true)
+ .Add(CSSProperty::kInherited, false);
+ EXPECT_TRUE(filter.Rejects(CSSProperty::kVisited, true));
+ EXPECT_TRUE(filter.Rejects(CSSProperty::kInherited, false));
+ filter = filter.Set(CSSProperty::kVisited, false);
+ filter = filter.Set(CSSProperty::kInherited, true);
+ // Add has no effect if flags are already set:
+ EXPECT_TRUE(filter.Rejects(CSSProperty::kVisited, false));
+ EXPECT_TRUE(filter.Rejects(CSSProperty::kInherited, true));
+}
+
+} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/cascade_interpolations.h b/chromium/third_party/blink/renderer/core/css/resolver/cascade_interpolations.h
new file mode 100644
index 00000000000..a2a9fb2c43d
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/resolver/cascade_interpolations.h
@@ -0,0 +1,61 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_INTERPOLATIONS_H_
+#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_INTERPOLATIONS_H_
+
+#include "third_party/blink/renderer/core/animation/interpolation.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_origin.h"
+#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
+
+namespace blink {
+
+class CORE_EXPORT CascadeInterpolations {
+ STACK_ALLOCATED();
+
+ public:
+ static constexpr size_t kMaxEntryIndex = std::numeric_limits<uint16_t>::max();
+
+ struct Entry {
+ DISALLOW_NEW();
+
+ public:
+ const ActiveInterpolationsMap* map = nullptr;
+ CascadeOrigin origin = CascadeOrigin::kNone;
+ };
+
+ void Add(const ActiveInterpolationsMap* map, CascadeOrigin origin) {
+ DCHECK(map);
+ entries_.push_back(Entry{map, origin});
+ }
+
+ bool IsEmpty() const { return GetEntries().IsEmpty(); }
+
+ const Vector<Entry, 4>& GetEntries() const {
+ using EntryVector = Vector<Entry, 4>;
+ DEFINE_STATIC_LOCAL(EntryVector, empty, ());
+ if (entries_.size() > kMaxEntryIndex + 1)
+ return empty;
+ return entries_;
+ }
+
+ void Reset() { entries_.clear(); }
+
+ private:
+ // We need to add at most four entries (see CSSAnimationUpdate):
+ //
+ // 1. Standard property transitions
+ // 2. Standard property animations
+ // 3. Custom property transitions
+ // 4. Custom property animations
+ //
+ // TODO(andruud): Once regular declarations and interpolations are applied
+ // using the same StyleCascade object, we can store standard and custom
+ // property interpolations together, and use Vector<Entry,2> instead.
+ Vector<Entry, 4> entries_;
+};
+
+} // namespace blink
+
+#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_INTERPOLATIONS_H_
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/cascade_interpolations_test.cc b/chromium/third_party/blink/renderer/core/css/resolver/cascade_interpolations_test.cc
new file mode 100644
index 00000000000..005809de63e
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/resolver/cascade_interpolations_test.cc
@@ -0,0 +1,46 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/blink/renderer/core/css/resolver/cascade_interpolations.h"
+
+#include <gtest/gtest.h>
+
+namespace blink {
+
+TEST(CascadeInterpolationsTest, Limit) {
+ constexpr size_t max = std::numeric_limits<uint16_t>::max();
+
+ static_assert(CascadeInterpolations::kMaxEntryIndex == max,
+ "Unexpected max. If the limit increased, evaluate whether it "
+ "still makes sense to run this test");
+
+ ActiveInterpolationsMap map;
+
+ CascadeInterpolations interpolations;
+ for (size_t i = 0; i <= max; ++i)
+ interpolations.Add(&map, CascadeOrigin::kAuthor);
+
+ // At maximum
+ EXPECT_FALSE(interpolations.IsEmpty());
+
+ interpolations.Add(&map, CascadeOrigin::kAuthor);
+
+ // Maximum + 1
+ EXPECT_TRUE(interpolations.IsEmpty());
+}
+
+TEST(CascadeInterpolationsTest, Reset) {
+ ActiveInterpolationsMap map;
+
+ CascadeInterpolations interpolations;
+ EXPECT_TRUE(interpolations.IsEmpty());
+
+ interpolations.Add(&map, CascadeOrigin::kAuthor);
+ EXPECT_FALSE(interpolations.IsEmpty());
+
+ interpolations.Reset();
+ EXPECT_TRUE(interpolations.IsEmpty());
+}
+
+} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/cascade_map.cc b/chromium/third_party/blink/renderer/core/css/resolver/cascade_map.cc
new file mode 100644
index 00000000000..bfe2770df21
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/resolver/cascade_map.cc
@@ -0,0 +1,70 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/blink/renderer/core/css/resolver/cascade_map.h"
+#include "third_party/blink/renderer/core/css/resolver/css_property_priority.h"
+
+namespace blink {
+
+CascadePriority CascadeMap::At(const CSSPropertyName& name) const {
+ if (name.IsCustomProperty())
+ return custom_properties_.at(name);
+ size_t index = static_cast<size_t>(name.Id());
+ DCHECK_LT(index, static_cast<size_t>(numCSSProperties));
+ return native_property_bits_.test(index)
+ ? reinterpret_cast<const CascadePriority*>(
+ native_properties_)[index]
+ : CascadePriority();
+}
+
+CascadePriority* CascadeMap::Find(const CSSPropertyName& name) {
+ if (name.IsCustomProperty()) {
+ auto iter = custom_properties_.find(name);
+ if (iter != custom_properties_.end())
+ return &iter->value;
+ return nullptr;
+ }
+ size_t index = static_cast<size_t>(name.Id());
+ DCHECK_LT(index, static_cast<size_t>(numCSSProperties));
+ if (!native_property_bits_.test(index))
+ return nullptr;
+ return reinterpret_cast<CascadePriority*>(native_properties_) + index;
+}
+
+void CascadeMap::Add(const CSSPropertyName& name, CascadePriority priority) {
+ if (name.IsCustomProperty()) {
+ DCHECK_NE(CascadeOrigin::kUserAgent, priority.GetOrigin());
+ auto result = custom_properties_.insert(name, priority);
+ if (result.is_new_entry || result.stored_value->value < priority)
+ result.stored_value->value = priority;
+ return;
+ }
+ CSSPropertyID id = name.Id();
+ size_t index = static_cast<size_t>(id);
+ DCHECK_LT(index, static_cast<size_t>(numCSSProperties));
+
+ // Set bit in high_priority_, if appropriate.
+ using HighPriority = CSSPropertyPriorityData<kHighPropertyPriority>;
+ static_assert(static_cast<int>(HighPriority::Last()) < 64,
+ "CascadeMap supports at most 63 high-priority properties");
+ if (HighPriority::PropertyHasPriority(id))
+ high_priority_ |= (1ull << index);
+ CascadePriority* p =
+ reinterpret_cast<CascadePriority*>(native_properties_) + index;
+ if (!native_property_bits_.test(index) || *p < priority) {
+ native_property_bits_.set(index);
+ static_assert(
+ std::is_trivially_destructible<CascadePriority>::value,
+ "~CascadePriority is never called on these CascadePriority objects");
+ new (p) CascadePriority(priority);
+ }
+}
+
+void CascadeMap::Reset() {
+ high_priority_ = 0;
+ native_property_bits_.reset();
+ custom_properties_.clear();
+}
+
+} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/cascade_map.h b/chromium/third_party/blink/renderer/core/css/resolver/cascade_map.h
new file mode 100644
index 00000000000..249ebcbc6cf
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/resolver/cascade_map.h
@@ -0,0 +1,58 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_MAP_H_
+#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_MAP_H_
+
+#include <bitset>
+#include "third_party/blink/renderer/core/css/css_property_name.h"
+#include "third_party/blink/renderer/core/css/css_property_names.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_priority.h"
+#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
+
+namespace blink {
+
+// Optimized map from CSSPropertyNames to CascadePriority.
+//
+// Because using a HashMap for everything is quite expensive in terms of
+// performance, this class stores standard (non-custom) properties in a fixed-
+// size array, and only custom properties are stored in a HashMap.
+class CORE_EXPORT CascadeMap {
+ STACK_ALLOCATED();
+
+ public:
+ // Get the CascadePriority for the given CSSPropertyName. If there is no
+ // entry for the given name, CascadePriority() is returned.
+ CascadePriority At(const CSSPropertyName&) const;
+ // Find the CascadePriority location for a given name, if present. If there
+ // is no entry for the given name, nullptr is returned.
+ //
+ // Note that the returned pointer may accessed to change the stored value.
+ //
+ // Note also that calling Add() invalidates the pointer.
+ CascadePriority* Find(const CSSPropertyName&);
+ // Adds an an entry to the map if the incoming priority is greater than or
+ // equal to the current priority for the same name.
+ void Add(const CSSPropertyName&, CascadePriority);
+ // Added properties with CSSPropertyPriority::kHighPropertyPriority cause the
+ // corresponding high_priority_-bit to be set. This provides a fast way to
+ // check which high-priority properties have been added (if any).
+ uint64_t HighPriorityBits() const { return high_priority_; }
+ // Remove all properties (both native and custom) from the CascadeMap.
+ void Reset();
+
+ private:
+ uint64_t high_priority_ = 0;
+ // For performance reasons, a char-array is used to prevent construction of
+ // CascadePriority objects. A companion std::bitset keeps track of which
+ // properties are initialized.
+ std::bitset<numCSSProperties> native_property_bits_;
+ alignas(CascadePriority) char native_properties_[numCSSProperties *
+ sizeof(CascadePriority)];
+ HashMap<CSSPropertyName, CascadePriority> custom_properties_;
+};
+
+} // namespace blink
+
+#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_MAP_H_
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/cascade_map_test.cc b/chromium/third_party/blink/renderer/core/css/resolver/cascade_map_test.cc
new file mode 100644
index 00000000000..0266bf95007
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/resolver/cascade_map_test.cc
@@ -0,0 +1,230 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/blink/renderer/core/css/resolver/cascade_map.h"
+#include <gtest/gtest.h>
+#include "third_party/blink/renderer/core/css/css_property_name.h"
+#include "third_party/blink/renderer/core/css/css_property_names.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_priority.h"
+#include "third_party/blink/renderer/core/css/resolver/css_property_priority.h"
+
+namespace blink {
+
+namespace {
+
+bool AddTo(CascadeMap& map,
+ const CSSPropertyName& name,
+ CascadePriority priority) {
+ CascadePriority before = map.At(name);
+ map.Add(name, priority);
+ CascadePriority after = map.At(name);
+ return before != after;
+}
+
+} // namespace
+
+TEST(CascadeMapTest, Empty) {
+ CascadeMap map;
+ EXPECT_FALSE(map.Find(CSSPropertyName(AtomicString("--x"))));
+ EXPECT_FALSE(map.Find(CSSPropertyName(AtomicString("--y"))));
+ EXPECT_FALSE(map.Find(CSSPropertyName(CSSPropertyID::kColor)));
+ EXPECT_FALSE(map.Find(CSSPropertyName(CSSPropertyID::kDisplay)));
+}
+
+TEST(CascadeMapTest, AddCustom) {
+ CascadeMap map;
+ CascadePriority user(CascadeOrigin::kUser);
+ CascadePriority author(CascadeOrigin::kAuthor);
+ CSSPropertyName x(AtomicString("--x"));
+ CSSPropertyName y(AtomicString("--y"));
+
+ EXPECT_TRUE(AddTo(map, x, user));
+ EXPECT_TRUE(AddTo(map, x, author));
+ EXPECT_FALSE(AddTo(map, x, author));
+ ASSERT_TRUE(map.Find(x));
+ EXPECT_EQ(author, *map.Find(x));
+
+ EXPECT_FALSE(map.Find(y));
+ EXPECT_TRUE(AddTo(map, y, user));
+
+ // --x should be unchanged.
+ ASSERT_TRUE(map.Find(x));
+ EXPECT_EQ(author, *map.Find(x));
+
+ // --y should exist too.
+ ASSERT_TRUE(map.Find(y));
+ EXPECT_EQ(user, *map.Find(y));
+}
+
+TEST(CascadeMapTest, AddNative) {
+ CascadeMap map;
+ CascadePriority user(CascadeOrigin::kUser);
+ CascadePriority author(CascadeOrigin::kAuthor);
+ CSSPropertyName color(CSSPropertyID::kColor);
+ CSSPropertyName display(CSSPropertyID::kDisplay);
+
+ EXPECT_TRUE(AddTo(map, color, user));
+ EXPECT_TRUE(AddTo(map, color, author));
+ EXPECT_FALSE(AddTo(map, color, author));
+ ASSERT_TRUE(map.Find(color));
+ EXPECT_EQ(author, *map.Find(color));
+
+ EXPECT_FALSE(map.Find(display));
+ EXPECT_TRUE(AddTo(map, display, user));
+
+ // color should be unchanged.
+ ASSERT_TRUE(map.Find(color));
+ EXPECT_EQ(author, *map.Find(color));
+
+ // display should exist too.
+ ASSERT_TRUE(map.Find(display));
+ EXPECT_EQ(user, *map.Find(display));
+}
+
+TEST(CascadeMapTest, FindAndMutateCustom) {
+ CascadeMap map;
+ CascadePriority user(CascadeOrigin::kUser);
+ CascadePriority author(CascadeOrigin::kAuthor);
+ CSSPropertyName x(AtomicString("--x"));
+
+ EXPECT_TRUE(AddTo(map, x, user));
+
+ CascadePriority* p = map.Find(x);
+ ASSERT_TRUE(p);
+ EXPECT_EQ(user, *p);
+
+ *p = author;
+
+ EXPECT_FALSE(AddTo(map, x, author));
+ ASSERT_TRUE(map.Find(x));
+ EXPECT_EQ(author, *map.Find(x));
+}
+
+TEST(CascadeMapTest, FindAndMutateNative) {
+ CascadeMap map;
+ CascadePriority user(CascadeOrigin::kUser);
+ CascadePriority author(CascadeOrigin::kAuthor);
+ CSSPropertyName color(CSSPropertyID::kColor);
+
+ EXPECT_TRUE(AddTo(map, color, user));
+
+ CascadePriority* p = map.Find(color);
+ ASSERT_TRUE(p);
+ EXPECT_EQ(user, *p);
+
+ *p = author;
+
+ EXPECT_FALSE(AddTo(map, color, author));
+ ASSERT_TRUE(map.Find(color));
+ EXPECT_EQ(author, *map.Find(color));
+}
+
+TEST(CascadeMapTest, AtCustom) {
+ CascadeMap map;
+ CascadePriority user(CascadeOrigin::kUser);
+ CascadePriority author(CascadeOrigin::kAuthor);
+ CSSPropertyName x(AtomicString("--x"));
+
+ EXPECT_EQ(CascadePriority(), map.At(x));
+
+ EXPECT_TRUE(AddTo(map, x, user));
+ EXPECT_EQ(user, map.At(x));
+
+ EXPECT_TRUE(AddTo(map, x, author));
+ EXPECT_EQ(author, map.At(x));
+}
+
+TEST(CascadeMapTest, AtNative) {
+ CascadeMap map;
+ CascadePriority user(CascadeOrigin::kUser);
+ CascadePriority author(CascadeOrigin::kAuthor);
+ CSSPropertyName color(CSSPropertyID::kColor);
+
+ EXPECT_EQ(CascadePriority(), map.At(color));
+
+ EXPECT_TRUE(AddTo(map, color, user));
+ EXPECT_EQ(user, map.At(color));
+
+ EXPECT_TRUE(AddTo(map, color, author));
+ EXPECT_EQ(author, map.At(color));
+}
+
+TEST(CascadeMapTest, HighPriorityBits) {
+ CascadeMap map;
+
+ EXPECT_FALSE(map.HighPriorityBits());
+
+ map.Add(CSSPropertyName(CSSPropertyID::kFontSize), CascadeOrigin::kAuthor);
+ EXPECT_EQ(map.HighPriorityBits(),
+ 1ull << static_cast<uint64_t>(CSSPropertyID::kFontSize));
+
+ map.Add(CSSPropertyName(CSSPropertyID::kColor), CascadeOrigin::kAuthor);
+ map.Add(CSSPropertyName(CSSPropertyID::kFontSize), CascadeOrigin::kAuthor);
+ EXPECT_EQ(map.HighPriorityBits(),
+ (1ull << static_cast<uint64_t>(CSSPropertyID::kFontSize)) |
+ (1ull << static_cast<uint64_t>(CSSPropertyID::kColor)));
+}
+
+TEST(CascadeMapTest, AllHighPriorityBits) {
+ CascadeMap map;
+
+ EXPECT_FALSE(map.HighPriorityBits());
+
+ uint64_t expected = 0;
+ for (CSSPropertyID id : CSSPropertyIDList()) {
+ if (CSSPropertyPriorityData<kHighPropertyPriority>::PropertyHasPriority(
+ id)) {
+ map.Add(CSSPropertyName(id), CascadeOrigin::kAuthor);
+ expected |= (1ull << static_cast<uint64_t>(id));
+ }
+ }
+
+ EXPECT_EQ(expected, map.HighPriorityBits());
+}
+
+TEST(CascadeMapTest, LastHighPrio) {
+ CascadeMap map;
+
+ EXPECT_FALSE(map.HighPriorityBits());
+
+ CSSPropertyID last = CSSPropertyPriorityData<kHighPropertyPriority>::Last();
+
+ map.Add(CSSPropertyName(last), CascadeOrigin::kAuthor);
+ EXPECT_EQ(map.HighPriorityBits(), 1ull << static_cast<uint64_t>(last));
+}
+
+TEST(CascadeMapTest, Reset) {
+ CascadeMap map;
+
+ CascadePriority author(CascadeOrigin::kAuthor);
+
+ CSSPropertyName color(CSSPropertyID::kColor);
+ CSSPropertyName x(AtomicString("--x"));
+
+ EXPECT_FALSE(map.Find(color));
+ EXPECT_FALSE(map.Find(x));
+
+ map.Add(color, author);
+ map.Add(x, author);
+
+ EXPECT_EQ(author, map.At(color));
+ EXPECT_EQ(author, map.At(x));
+
+ map.Reset();
+
+ EXPECT_FALSE(map.Find(color));
+ EXPECT_FALSE(map.Find(x));
+}
+
+TEST(CascadeMapTest, ResetHighPrio) {
+ CascadeMap map;
+ EXPECT_FALSE(map.HighPriorityBits());
+ map.Add(CSSPropertyName(CSSPropertyID::kFontSize),
+ CascadePriority(CascadeOrigin::kAuthor));
+ EXPECT_TRUE(map.HighPriorityBits());
+ map.Reset();
+ EXPECT_FALSE(map.HighPriorityBits());
+}
+
+} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/cascade_origin.h b/chromium/third_party/blink/renderer/core/css/resolver/cascade_origin.h
new file mode 100644
index 00000000000..565d5843fe4
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/resolver/cascade_origin.h
@@ -0,0 +1,38 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_ORIGIN_H_
+#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_ORIGIN_H_
+
+#include <cstdint>
+
+namespace blink {
+
+// Represents the origin criteria described by css-cascade [1].
+//
+// [1] https://www.w3.org/TR/css-cascade-3/#cascade-origin
+enum class CascadeOrigin : uint8_t {
+ kNone = 0,
+ kUserAgent = 0b0001,
+ kUser = 0b0010,
+ kAuthor = 0b0011,
+ kAnimation = 0b0100,
+ // The lower four bits of kAuthor, kUser and kUserAgent can be inverted to
+ // efficiently produce a "cascade correct" value when compared with the values
+ // specified in this enum:
+ //
+ // kAuthor important: ~0b0011 == 0b1100 (> kAnimation)
+ // kUser important: ~0b0010 == 0b1101 (> kAuthor important)
+ // kUserAgent important: ~0b0001 == 0b1110 (> kUser important)
+ //
+ // Because kTransition has a higher priority than anything else, it's set to
+ // 0b10000, which is greater than kUserAgent important. Although 0b1111 is
+ // available, we avoid using that such that the fourth bit can be used as
+ // as quick is-important check.
+ kTransition = 0b10000,
+};
+
+} // namespace blink
+
+#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_ORIGIN_H_
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/cascade_priority.h b/chromium/third_party/blink/renderer/core/css/resolver/cascade_priority.h
new file mode 100644
index 00000000000..9a49e2c72d2
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/resolver/cascade_priority.h
@@ -0,0 +1,107 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_PRIORITY_H_
+#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_PRIORITY_H_
+
+#include "base/logging.h"
+#include "third_party/blink/renderer/core/core_export.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_origin.h"
+
+namespace blink {
+
+// The origin and importance criteria are evaluated together [1], hence we
+// encode both into a single integer which will do the right thing when compared
+// to another such encoded integer. See CascadeOrigin for more information on
+// how that works.
+//
+// [1] https://www.w3.org/TR/css-cascade-3/#cascade-origin
+inline uint64_t EncodeOriginImportance(CascadeOrigin origin, bool important) {
+ uint8_t important_xor = (static_cast<uint8_t>(!important) - 1) & 0xF;
+ return static_cast<uint64_t>(origin) ^ important_xor;
+}
+
+// Tree order bits are flipped for important declarations to reverse the
+// priority [1].
+//
+// [1] https://drafts.csswg.org/css-scoping/#shadow-cascading
+inline uint64_t EncodeTreeOrder(uint16_t tree_order, bool important) {
+ uint16_t important_xor = static_cast<uint16_t>(!important) - 1;
+ return static_cast<uint64_t>(tree_order) ^ important_xor;
+}
+
+// The CascadePriority class encapsulates a subset of the cascading criteria
+// described by css-cascade [1], and provides a way to compare priorities
+// quickly by encoding all the information in a single integer.
+//
+// It encompasses, from most significant to least significant:
+// Origin/importance; tree order, which is a number representing the
+// shadow-including tree order [2]; position, which contains the index (or
+// indices) required to lookup a declaration in the underlying structure (e.g. a
+// MatchResult); and finally generation, which is a monotonically increasing
+// number generated by StyleCascade for each call to StyleCascade::Apply.
+//
+// [1] https://drafts.csswg.org/css-cascade/#cascading
+// [2] https://drafts.csswg.org/css-scoping/#shadow-cascading
+class CORE_EXPORT CascadePriority {
+ public:
+ // The declaration is important if this bit is set on the encoded priority.
+ static constexpr uint64_t kImportantBit = 55;
+ static constexpr uint64_t kOriginImportanceOffset = 52;
+ static constexpr uint64_t kTreeOrderOffset = 36;
+
+ CascadePriority() : bits_(0) {}
+ CascadePriority(CascadeOrigin origin)
+ : CascadePriority(origin, false, 0, 0) {}
+ CascadePriority(CascadeOrigin origin, bool important)
+ : CascadePriority(origin, important, 0, 0) {}
+ CascadePriority(CascadeOrigin origin, bool important, uint16_t tree_order)
+ : CascadePriority(origin, important, tree_order, 0) {}
+ // For an explanation of 'tree_order', see css-scoping:
+ // https://drafts.csswg.org/css-scoping/#shadow-cascading
+ CascadePriority(CascadeOrigin origin,
+ bool important,
+ uint16_t tree_order,
+ uint32_t position)
+ : bits_(static_cast<uint64_t>(position) << 4 |
+ EncodeTreeOrder(tree_order, important) << kTreeOrderOffset |
+ EncodeOriginImportance(origin, important)
+ << kOriginImportanceOffset) {}
+ // See StyleCascade.generation_.
+ CascadePriority(CascadePriority o, uint8_t generation)
+ : bits_((o.bits_ & ~static_cast<uint8_t>(0xF)) | generation) {
+ DCHECK_LE(generation, 0xF);
+ }
+
+ bool IsImportant() const { return (bits_ >> kImportantBit) & 1; }
+ CascadeOrigin GetOrigin() const {
+ uint64_t important_xor = (((~bits_ >> kImportantBit) & 1) - 1) & 0xF;
+ return static_cast<CascadeOrigin>((bits_ >> kOriginImportanceOffset) ^
+ important_xor);
+ }
+ bool HasOrigin() const { return GetOrigin() != CascadeOrigin::kNone; }
+ uint32_t GetPosition() const { return (bits_ >> 4) & 0xFFFFFFFF; }
+ uint8_t GetGeneration() const { return bits_ & 0xF; }
+
+ bool operator>=(const CascadePriority& o) const { return bits_ >= o.bits_; }
+ bool operator<(const CascadePriority& o) const { return bits_ < o.bits_; }
+ bool operator==(const CascadePriority& o) const { return bits_ == o.bits_; }
+ bool operator!=(const CascadePriority& o) const { return bits_ != o.bits_; }
+
+ private:
+ friend class StyleCascade;
+ friend class StyleCascadeTest;
+
+ CascadePriority(uint64_t bits) : bits_(bits) {}
+
+ // Bit 0-3 : generation
+ // Bit 4-35: position
+ // Bit 36-51: tree_order (encoded)
+ // Bit 52-59: origin/importance (encoded)
+ uint64_t bits_;
+};
+
+} // namespace blink
+
+#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_PRIORITY_H_
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/cascade_priority_test.cc b/chromium/third_party/blink/renderer/core/css/resolver/cascade_priority_test.cc
new file mode 100644
index 00000000000..ddf587267ee
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/resolver/cascade_priority_test.cc
@@ -0,0 +1,249 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/blink/renderer/core/css/resolver/cascade_priority.h"
+#include <gtest/gtest.h>
+
+namespace blink {
+
+namespace {
+
+CascadePriority AuthorPriority(uint16_t tree_order, uint32_t position) {
+ return CascadePriority(CascadeOrigin::kAuthor, false, tree_order, position);
+}
+
+CascadePriority ImportantAuthorPriority(uint16_t tree_order,
+ uint32_t position) {
+ return CascadePriority(CascadeOrigin::kAuthor, true, tree_order, position);
+}
+
+} // namespace
+
+TEST(CascadePriorityTest, EncodeOriginImportance) {
+ using Origin = CascadeOrigin;
+ EXPECT_EQ(0b00001ull, EncodeOriginImportance(Origin::kUserAgent, false));
+ EXPECT_EQ(0b00010ull, EncodeOriginImportance(Origin::kUser, false));
+ EXPECT_EQ(0b00011ull, EncodeOriginImportance(Origin::kAuthor, false));
+ EXPECT_EQ(0b00100ull, EncodeOriginImportance(Origin::kAnimation, false));
+ EXPECT_EQ(0b01100ull, EncodeOriginImportance(Origin::kAuthor, true));
+ EXPECT_EQ(0b01101ull, EncodeOriginImportance(Origin::kUser, true));
+ EXPECT_EQ(0b01110ull, EncodeOriginImportance(Origin::kUserAgent, true));
+ EXPECT_EQ(0b10000ull, EncodeOriginImportance(Origin::kTransition, false));
+}
+
+TEST(CascadePriorityTest, OriginOperators) {
+ std::vector<CascadePriority> priority = {
+ CascadePriority(CascadeOrigin::kTransition, false, 0, 0),
+ CascadePriority(CascadeOrigin::kAnimation, false, 0, 0),
+ CascadePriority(CascadeOrigin::kAuthor, false, 0, 0),
+ CascadePriority(CascadeOrigin::kUser, false, 0, 0),
+ CascadePriority(CascadeOrigin::kUserAgent, false, 0, 0),
+ CascadePriority(CascadeOrigin::kNone, false, 0, 0)};
+
+ for (size_t i = 0; i < priority.size(); ++i) {
+ for (size_t j = i; j < priority.size(); ++j) {
+ EXPECT_GE(priority[i], priority[j]);
+ EXPECT_FALSE(priority[i] < priority[j]);
+ }
+ }
+
+ for (size_t i = 0; i < priority.size(); ++i) {
+ for (size_t j = i + 1; j < priority.size(); ++j) {
+ EXPECT_LT(priority[j], priority[i]);
+ EXPECT_FALSE(priority[j] >= priority[i]);
+ }
+ }
+
+ for (CascadePriority priority : priority)
+ EXPECT_EQ(priority, priority);
+
+ for (size_t i = 0; i < priority.size(); ++i) {
+ for (size_t j = 0; j < priority.size(); ++j) {
+ if (i == j)
+ continue;
+ EXPECT_NE(priority[i], priority[j]);
+ }
+ }
+}
+
+TEST(CascadePriorityTest, OriginImportance) {
+ std::vector<CascadePriority> priority = {
+ CascadePriority(CascadeOrigin::kTransition, false, 0, 0),
+ CascadePriority(CascadeOrigin::kUserAgent, true, 0, 0),
+ CascadePriority(CascadeOrigin::kUser, true, 0, 0),
+ CascadePriority(CascadeOrigin::kAuthor, true, 0, 0),
+ CascadePriority(CascadeOrigin::kAnimation, false, 0, 0),
+ CascadePriority(CascadeOrigin::kAuthor, false, 0, 0),
+ CascadePriority(CascadeOrigin::kUser, false, 0, 0),
+ CascadePriority(CascadeOrigin::kUserAgent, false, 0, 0),
+ CascadePriority(CascadeOrigin::kNone, false, 0, 0)};
+
+ for (size_t i = 0; i < priority.size(); ++i) {
+ for (size_t j = i; j < priority.size(); ++j)
+ EXPECT_GE(priority[i], priority[j]);
+ }
+}
+
+TEST(CascadePriorityTest, IsImportant) {
+ using Priority = CascadePriority;
+ using Origin = CascadeOrigin;
+
+ EXPECT_FALSE(Priority(Origin::kUserAgent, false, 0, 0).IsImportant());
+ EXPECT_FALSE(Priority(Origin::kUser, false, 0, 0).IsImportant());
+ EXPECT_FALSE(Priority(Origin::kAuthor, false, 0, 0).IsImportant());
+ EXPECT_FALSE(Priority(Origin::kAnimation, false, 0, 0).IsImportant());
+ EXPECT_FALSE(Priority(Origin::kTransition, false, 0, 0).IsImportant());
+ EXPECT_FALSE(Priority(Origin::kAuthor, false, 1024, 2048).IsImportant());
+
+ EXPECT_TRUE(Priority(Origin::kUserAgent, true, 0, 0).IsImportant());
+ EXPECT_TRUE(Priority(Origin::kUser, true, 0, 0).IsImportant());
+ EXPECT_TRUE(Priority(Origin::kAuthor, true, 0, 0).IsImportant());
+ EXPECT_TRUE(Priority(Origin::kAnimation, true, 0, 0).IsImportant());
+ EXPECT_TRUE(Priority(Origin::kTransition, true, 0, 0).IsImportant());
+ EXPECT_TRUE(Priority(Origin::kAuthor, true, 1024, 2048).IsImportant());
+}
+
+static std::vector<CascadeOrigin> all_origins = {
+ CascadeOrigin::kUserAgent, CascadeOrigin::kUser, CascadeOrigin::kAuthor,
+ CascadeOrigin::kTransition, CascadeOrigin::kAnimation};
+
+TEST(CascadePriorityTest, GetOrigin) {
+ for (CascadeOrigin origin : all_origins)
+ EXPECT_EQ(CascadePriority(origin, false, 0, 0).GetOrigin(), origin);
+
+ for (CascadeOrigin origin : all_origins) {
+ if (origin == CascadeOrigin::kAnimation)
+ continue;
+ if (origin == CascadeOrigin::kTransition)
+ continue;
+ EXPECT_EQ(CascadePriority(origin, true, 0, 0).GetOrigin(), origin);
+ }
+}
+
+TEST(CascadePriorityTest, HasOrigin) {
+ for (CascadeOrigin origin : all_origins) {
+ if (origin != CascadeOrigin::kNone)
+ EXPECT_TRUE(CascadePriority(origin).HasOrigin());
+ else
+ EXPECT_FALSE(CascadePriority(origin).HasOrigin());
+ }
+ EXPECT_FALSE(CascadePriority().HasOrigin());
+}
+
+TEST(CascadePriorityTest, EncodeTreeOrder) {
+ EXPECT_EQ(0ull, EncodeTreeOrder(0, false));
+ EXPECT_EQ(1ull, EncodeTreeOrder(1, false));
+ EXPECT_EQ(2ull, EncodeTreeOrder(2, false));
+ EXPECT_EQ(100ull, EncodeTreeOrder(100, false));
+ EXPECT_EQ(0xFFFFull, EncodeTreeOrder(0xFFFF, false));
+
+ EXPECT_EQ(0ull ^ 0xFFFF, EncodeTreeOrder(0, true));
+ EXPECT_EQ(1ull ^ 0xFFFF, EncodeTreeOrder(1, true));
+ EXPECT_EQ(2ull ^ 0xFFFF, EncodeTreeOrder(2, true));
+ EXPECT_EQ(100ull ^ 0xFFFF, EncodeTreeOrder(100, true));
+ EXPECT_EQ(0xFFFFull ^ 0xFFFF, EncodeTreeOrder(0xFFFF, true));
+}
+
+TEST(CascadePriorityTest, TreeOrder) {
+ using Priority = CascadePriority;
+ CascadeOrigin origin = CascadeOrigin::kAuthor;
+ EXPECT_GE(Priority(origin, false, 1), Priority(origin, false, 0));
+ EXPECT_GE(Priority(origin, false, 7), Priority(origin, false, 6));
+ EXPECT_GE(Priority(origin, false, 42), Priority(origin, false, 42));
+ EXPECT_FALSE(Priority(origin, false, 1) >= Priority(origin, false, 8));
+}
+
+TEST(CascadePriorityTest, TreeOrderImportant) {
+ using Priority = CascadePriority;
+ CascadeOrigin origin = CascadeOrigin::kAuthor;
+ EXPECT_GE(Priority(origin, true, 0), Priority(origin, true, 1));
+ EXPECT_GE(Priority(origin, true, 6), Priority(origin, true, 7));
+ EXPECT_GE(Priority(origin, true, 42), Priority(origin, true, 42));
+ EXPECT_FALSE(Priority(origin, true, 8) >= Priority(origin, true, 1));
+}
+
+TEST(CascadePriorityTest, TreeOrderDifferentOrigin) {
+ using Priority = CascadePriority;
+ // Tree order does not matter if the origin is different.
+ CascadeOrigin author = CascadeOrigin::kAuthor;
+ CascadeOrigin transition = CascadeOrigin::kTransition;
+ EXPECT_GE(Priority(transition, 1), Priority(author, 42));
+ EXPECT_GE(Priority(transition, 1), Priority(author, 1));
+}
+
+TEST(CascadePriorityTest, Position) {
+ // AuthorPriority(tree_order, position)
+ EXPECT_GE(AuthorPriority(0, 0), AuthorPriority(0, 0));
+ EXPECT_GE(AuthorPriority(0, 1), AuthorPriority(0, 1));
+ EXPECT_GE(AuthorPriority(0, 1), AuthorPriority(0, 0));
+ EXPECT_GE(AuthorPriority(0, 2), AuthorPriority(0, 1));
+ EXPECT_GE(AuthorPriority(0, 0xFFFFFFFF), AuthorPriority(0, 0xFFFFFFFE));
+ EXPECT_FALSE(AuthorPriority(0, 2) >= AuthorPriority(0, 3));
+}
+
+TEST(CascadePriorityTest, PositionAndTreeOrder) {
+ // AuthorPriority(tree_order, position)
+ EXPECT_GE(AuthorPriority(1, 0), AuthorPriority(0, 0));
+ EXPECT_GE(AuthorPriority(1, 1), AuthorPriority(0, 1));
+ EXPECT_GE(AuthorPriority(1, 1), AuthorPriority(0, 3));
+ EXPECT_GE(AuthorPriority(1, 2), AuthorPriority(0, 0xFFFFFFFF));
+}
+
+TEST(CascadePriorityTest, PositionAndOrigin) {
+ // [Important]AuthorPriority(tree_order, position)
+ EXPECT_GE(ImportantAuthorPriority(0, 0), AuthorPriority(0, 0));
+ EXPECT_GE(ImportantAuthorPriority(0, 1), AuthorPriority(0, 1));
+ EXPECT_GE(ImportantAuthorPriority(0, 1), AuthorPriority(0, 3));
+ EXPECT_GE(ImportantAuthorPriority(0, 2), AuthorPriority(0, 0xFFFFFFFF));
+}
+
+TEST(CascadePriorityTest, Generation) {
+ CascadePriority ua(CascadeOrigin::kUserAgent);
+ CascadePriority author(CascadeOrigin::kAuthor);
+
+ EXPECT_EQ(author, author);
+ EXPECT_GE(CascadePriority(author, 1), author);
+ EXPECT_GE(CascadePriority(author, 2), CascadePriority(author, 1));
+ EXPECT_EQ(CascadePriority(author, 2), CascadePriority(author, 2));
+
+ EXPECT_LT(ua, author);
+ EXPECT_LT(CascadePriority(ua, 1), author);
+ EXPECT_LT(CascadePriority(ua, 2), CascadePriority(author, 1));
+ EXPECT_LT(CascadePriority(ua, 2), CascadePriority(author, 2));
+ EXPECT_LT(CascadePriority(ua, 2), CascadePriority(author, 3));
+}
+
+TEST(CascadePriorityTest, GenerationOverwrite) {
+ CascadePriority ua(CascadeOrigin::kUserAgent);
+
+ for (int8_t g = 0; g < 16; ++g) {
+ ua = CascadePriority(ua, g);
+ EXPECT_EQ(g, ua.GetGeneration());
+ }
+
+ for (int8_t g = 15; g >= 0; --g) {
+ ua = CascadePriority(ua, g);
+ EXPECT_EQ(g, ua.GetGeneration());
+ }
+}
+
+TEST(CascadePriorityTest, PositionEncoding) {
+ // Test 0b0, 0b1, 0b11, 0b111, etc.
+ uint32_t pos = 0;
+ do {
+ // AuthorPriority(tree_order, position)
+ ASSERT_EQ(pos, AuthorPriority(0, pos).GetPosition());
+ pos = (pos << 1) | 1;
+ } while (pos != ~static_cast<uint32_t>(0));
+
+ // Test 0b1, 0b10, 0b100, etc
+ pos = 1;
+ do {
+ // AuthorPriority(tree_order, position)
+ ASSERT_EQ(pos, AuthorPriority(0, pos).GetPosition());
+ pos <<= 1;
+ } while (pos != ~static_cast<uint32_t>(1) << 31);
+}
+
+} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/cascade_resolver.cc b/chromium/third_party/blink/renderer/core/css/resolver/cascade_resolver.cc
new file mode 100644
index 00000000000..55865460fa8
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/resolver/cascade_resolver.cc
@@ -0,0 +1,72 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/blink/renderer/core/css/resolver/cascade_resolver.h"
+
+#include "third_party/blink/renderer/core/animation/css/css_animations.h"
+#include "third_party/blink/renderer/core/css/css_variable_data.h"
+#include "third_party/blink/renderer/core/css/properties/css_property.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_priority.h"
+
+namespace blink {
+
+bool CascadeResolver::IsLocked(const CSSProperty& property) const {
+ return IsLocked(property.GetCSSPropertyName());
+}
+
+bool CascadeResolver::IsLocked(const CSSPropertyName& name) const {
+ return stack_.Contains(name);
+}
+
+bool CascadeResolver::AllowSubstitution(CSSVariableData* data) const {
+ if (data && data->IsAnimationTainted() && stack_.size()) {
+ const CSSPropertyName& name = stack_.back();
+ if (name.IsCustomProperty())
+ return true;
+ const CSSProperty& property = CSSProperty::Get(name.Id());
+ return !CSSAnimations::IsAnimationAffectingProperty(property);
+ }
+ return true;
+}
+
+void CascadeResolver::MarkUnapplied(CascadePriority* priority) const {
+ DCHECK(priority);
+ *priority = CascadePriority(*priority, 0);
+}
+
+void CascadeResolver::MarkApplied(CascadePriority* priority) const {
+ DCHECK(priority);
+ *priority = CascadePriority(*priority, generation_);
+}
+
+bool CascadeResolver::DetectCycle(const CSSProperty& property) {
+ wtf_size_t index = stack_.Find(property.GetCSSPropertyName());
+ if (index == kNotFound)
+ return false;
+ cycle_depth_ = std::min(cycle_depth_, index);
+ return true;
+}
+
+bool CascadeResolver::InCycle() const {
+ return cycle_depth_ != kNotFound;
+}
+
+CascadeResolver::AutoLock::AutoLock(const CSSProperty& property,
+ CascadeResolver& resolver)
+ : AutoLock(property.GetCSSPropertyName(), resolver) {}
+
+CascadeResolver::AutoLock::AutoLock(const CSSPropertyName& name,
+ CascadeResolver& resolver)
+ : resolver_(resolver) {
+ DCHECK(!resolver.IsLocked(name));
+ resolver_.stack_.push_back(name);
+}
+
+CascadeResolver::AutoLock::~AutoLock() {
+ resolver_.stack_.pop_back();
+ if (resolver_.stack_.size() <= resolver_.cycle_depth_)
+ resolver_.cycle_depth_ = kNotFound;
+}
+
+} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/cascade_resolver.h b/chromium/third_party/blink/renderer/core/css/resolver/cascade_resolver.h
new file mode 100644
index 00000000000..165f6334ab3
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/resolver/cascade_resolver.h
@@ -0,0 +1,115 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_RESOLVER_H_
+#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_RESOLVER_H_
+
+#include "third_party/blink/renderer/core/core_export.h"
+#include "third_party/blink/renderer/core/css/css_property_name.h"
+#include "third_party/blink/renderer/core/css/properties/css_property.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_filter.h"
+#include "third_party/blink/renderer/core/css/rule_set.h"
+
+namespace blink {
+
+class CascadePriority;
+class CSSProperty;
+class CSSVariableData;
+
+namespace cssvalue {
+
+class CSSPendingSubstitutionValue;
+
+} // namespace cssvalue
+
+// CascadeResolver is an object passed on the stack during Apply. Its most
+// important job is to detect cycles during Apply (in general, keep track of
+// which properties we're currently applying).
+class CORE_EXPORT CascadeResolver {
+ STACK_ALLOCATED();
+
+ public:
+ // TODO(crbug.com/985047): Probably use a HashMap for this.
+ using NameStack = Vector<CSSPropertyName, 8>;
+
+ // A 'locked' property is a property we are in the process of applying.
+ // In other words, once a property is locked, locking it again would form
+ // a cycle, and is therefore an error.
+ bool IsLocked(const CSSProperty&) const;
+ bool IsLocked(const CSSPropertyName&) const;
+
+ // We do not allow substitution of animation-tainted values into
+ // an animation-affecting property.
+ //
+ // https://drafts.csswg.org/css-variables/#animation-tainted
+ bool AllowSubstitution(CSSVariableData*) const;
+
+ // Sets the generation of the priority to zero, which has the effect of
+ // marking it as unapplied. (I.e. this can be used to force re-application of
+ // a declaration).
+ void MarkUnapplied(CascadePriority*) const;
+
+ // Sets the generation of the priority to the current generation,
+ // which has the effect of marking it as already applied. (I.e. this can be
+ // used to skip application of a declaration).
+ void MarkApplied(CascadePriority*) const;
+
+ // Automatically locks and unlocks the given property. (See
+ // CascadeResolver::IsLocked).
+ class CORE_EXPORT AutoLock {
+ STACK_ALLOCATED();
+
+ public:
+ AutoLock(const CSSProperty&, CascadeResolver&);
+ AutoLock(const CSSPropertyName&, CascadeResolver&);
+ ~AutoLock();
+
+ private:
+ CascadeResolver& resolver_;
+ };
+
+ private:
+ friend class AutoLock;
+ friend class StyleCascade;
+ friend class TestCascadeResolver;
+
+ CascadeResolver(CascadeFilter filter, uint8_t generation)
+ : filter_(filter), generation_(generation) {}
+
+ // If the given property is already being applied, returns true.
+ // The return value is the same value you would get from InCycle(), and
+ // is just returned for convenience.
+ //
+ // When a cycle has been detected, the CascadeResolver will *persist the cycle
+ // state* (i.e. InCycle() will continue to return true) until we reach
+ // the start of the cycle.
+ //
+ // The cycle state is cleared by ~AutoLock, once we have moved far enough
+ // up the stack.
+ bool DetectCycle(const CSSProperty&);
+ // Returns true whenever the CascadeResolver is in a cycle state.
+ // This DOES NOT detect cycles; the caller must call DetectCycle first.
+ bool InCycle() const;
+
+ NameStack stack_;
+ wtf_size_t cycle_depth_ = kNotFound;
+ CascadeFilter filter_;
+ const uint8_t generation_ = 0;
+
+ // A very simple cache for CSSPendingSubstitutionValues. We cache only the
+ // most recently parsed CSSPendingSubstitutionValue, such that consecutive
+ // calls to ResolvePendingSubstitution with the same value don't need to
+ // do the same parsing job all over again.
+ struct {
+ STACK_ALLOCATED();
+
+ public:
+ const cssvalue::CSSPendingSubstitutionValue* value = nullptr;
+ HeapVector<CSSPropertyValue, 256> parsed_properties;
+ } shorthand_cache_;
+};
+
+} // namespace blink
+
+#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CASCADE_RESOLVER_H_
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/css_property_priority.h b/chromium/third_party/blink/renderer/core/css/resolver/css_property_priority.h
index a77173acd07..6e5676a5756 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/css_property_priority.h
+++ b/chromium/third_party/blink/renderer/core/css/resolver/css_property_priority.h
@@ -29,15 +29,15 @@ class CSSPropertyPriorityData {
STATIC_ONLY(CSSPropertyPriorityData);
public:
- static inline CSSPropertyID First();
- static inline CSSPropertyID Last();
- static inline bool PropertyHasPriority(CSSPropertyID prop) {
+ static constexpr CSSPropertyID First();
+ static constexpr CSSPropertyID Last();
+ static constexpr bool PropertyHasPriority(CSSPropertyID prop) {
return First() <= prop && prop <= Last();
}
};
template <>
-inline CSSPropertyID CSSPropertyPriorityData<kResolveVariables>::First() {
+constexpr CSSPropertyID CSSPropertyPriorityData<kResolveVariables>::First() {
static_assert(
static_cast<int>(CSSPropertyID::kVariable) == kIntFirstCSSProperty - 1,
"CSSPropertyID::kVariable should be directly before the first CSS "
@@ -46,12 +46,12 @@ inline CSSPropertyID CSSPropertyPriorityData<kResolveVariables>::First() {
}
template <>
-inline CSSPropertyID CSSPropertyPriorityData<kResolveVariables>::Last() {
+constexpr CSSPropertyID CSSPropertyPriorityData<kResolveVariables>::Last() {
return CSSPropertyID::kVariable;
}
template <>
-inline CSSPropertyID
+constexpr CSSPropertyID
CSSPropertyPriorityData<kAnimationPropertyPriority>::First() {
static_assert(CSSPropertyID::kAnimationDelay == firstCSSProperty,
"CSSPropertyID::kAnimationDelay should be the first animation "
@@ -60,7 +60,7 @@ CSSPropertyPriorityData<kAnimationPropertyPriority>::First() {
}
template <>
-inline CSSPropertyID
+constexpr CSSPropertyID
CSSPropertyPriorityData<kAnimationPropertyPriority>::Last() {
static_assert(
static_cast<int>(CSSPropertyID::kTransitionTimingFunction) ==
@@ -76,7 +76,8 @@ CSSPropertyPriorityData<kAnimationPropertyPriority>::Last() {
}
template <>
-inline CSSPropertyID CSSPropertyPriorityData<kHighPropertyPriority>::First() {
+constexpr CSSPropertyID
+CSSPropertyPriorityData<kHighPropertyPriority>::First() {
static_assert(
static_cast<int>(CSSPropertyID::kColor) ==
static_cast<int>(CSSPropertyID::kTransitionTimingFunction) + 1,
@@ -85,7 +86,7 @@ inline CSSPropertyID CSSPropertyPriorityData<kHighPropertyPriority>::First() {
}
template <>
-inline CSSPropertyID CSSPropertyPriorityData<kHighPropertyPriority>::Last() {
+constexpr CSSPropertyID CSSPropertyPriorityData<kHighPropertyPriority>::Last() {
static_assert(static_cast<int>(CSSPropertyID::kZoom) ==
static_cast<int>(CSSPropertyID::kColor) + 27,
"CSSPropertyID::kZoom should be the end of the high priority "
@@ -98,7 +99,7 @@ inline CSSPropertyID CSSPropertyPriorityData<kHighPropertyPriority>::Last() {
}
template <>
-inline CSSPropertyID CSSPropertyPriorityData<kLowPropertyPriority>::First() {
+constexpr CSSPropertyID CSSPropertyPriorityData<kLowPropertyPriority>::First() {
static_assert(
static_cast<int>(CSSPropertyID::kAlignContent) ==
static_cast<int>(CSSPropertyID::kZoom) + 1,
@@ -107,11 +108,11 @@ inline CSSPropertyID CSSPropertyPriorityData<kLowPropertyPriority>::First() {
}
template <>
-inline CSSPropertyID CSSPropertyPriorityData<kLowPropertyPriority>::Last() {
+constexpr CSSPropertyID CSSPropertyPriorityData<kLowPropertyPriority>::Last() {
return static_cast<CSSPropertyID>(lastCSSProperty);
}
-inline CSSPropertyPriority PriorityForProperty(CSSPropertyID property) {
+constexpr CSSPropertyPriority PriorityForProperty(CSSPropertyID property) {
if (CSSPropertyPriorityData<kLowPropertyPriority>::PropertyHasPriority(
property)) {
return kLowPropertyPriority;
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/css_variable_animator.cc b/chromium/third_party/blink/renderer/core/css/resolver/css_variable_animator.cc
index 1edd47f7c1e..f137cab9032 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/css_variable_animator.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/css_variable_animator.cc
@@ -70,13 +70,13 @@ void CSSVariableAnimator::Apply(const PropertyHandle& property) {
const ActiveInterpolations& interpolations =
ActiveInterpolationsForCustomProperty(update_, property);
const Interpolation& interpolation = *interpolations.front();
- if (interpolation.IsInvalidatableInterpolation()) {
+ if (IsA<InvalidatableInterpolation>(interpolation)) {
CSSInterpolationTypesMap map(state_.GetDocument().GetPropertyRegistry(),
state_.GetDocument());
CSSInterpolationEnvironment environment(map, state_, this);
InvalidatableInterpolation::ApplyStack(interpolations, environment);
} else {
- ToTransitionInterpolation(interpolation).Apply(state_);
+ To<TransitionInterpolation>(interpolation).Apply(state_);
}
pending_properties_.erase(property);
}
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/css_variable_resolver.cc b/chromium/third_party/blink/renderer/core/css/resolver/css_variable_resolver.cc
index 210bc41cd1b..1ebf7711cdf 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/css_variable_resolver.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/css_variable_resolver.cc
@@ -52,7 +52,7 @@ CSSVariableResolver::Fallback CSSVariableResolver::ResolveFallback(
const CSSParserContext* context =
StrictCSSParserContext(state_.GetDocument().GetSecureContextMode());
const bool is_animation_tainted = false;
- if (!registration->Syntax().Parse(resolved_range, context,
+ if (!registration->Syntax().Parse(resolved_range, *context,
is_animation_tainted))
return Fallback::kFail;
}
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/css_variable_resolver.h b/chromium/third_party/blink/renderer/core/css/resolver/css_variable_resolver.h
index 1df731c3b04..eaa6f3204f9 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/css_variable_resolver.h
+++ b/chromium/third_party/blink/renderer/core/css/resolver/css_variable_resolver.h
@@ -222,7 +222,7 @@ class CORE_EXPORT CSSVariableResolver {
const StyleResolverState& state_;
StyleInheritedVariables* inherited_variables_;
StyleNonInheritedVariables* non_inherited_variables_;
- Member<const PropertyRegistry> registry_;
+ const PropertyRegistry* registry_;
HashSet<AtomicString> variables_seen_;
// Resolution doesn't finish when a cycle is detected. Fallbacks still
// need to be tracked for additional cycles, and invalidation only
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/css_variable_resolver_test.cc b/chromium/third_party/blink/renderer/core/css/resolver/css_variable_resolver_test.cc
index 0b4876c69d2..a5095306bea 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/css_variable_resolver_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/css_variable_resolver_test.cc
@@ -52,7 +52,7 @@ class CSSVariableResolverTest : public PageTestBase {
}
void SetTestHTML(const String& value) {
- GetDocument().body()->SetInnerHTMLFromString(
+ GetDocument().body()->setInnerHTML(
"<style>"
" #target {"
" --main-bg-color: black;"
@@ -129,7 +129,7 @@ class CSSVariableResolverTest : public PageTestBase {
builder.Append("</style>\n");
builder.Append("<div id=target></div>\n");
- GetDocument().body()->SetInnerHTMLFromString(builder.ToString());
+ GetDocument().body()->setInnerHTML(builder.ToString());
UpdateAllLifecyclePhasesForTest();
}
};
@@ -301,7 +301,7 @@ TEST_F(CSSVariableResolverTest, NeedsResolutionClearedByResolver) {
const auto tokens = CSSTokenizer(initial_value_str).TokenizeToEOF();
const auto* context = MakeGarbageCollected<CSSParserContext>(GetDocument());
const CSSValue* initial_value =
- token_syntax->Parse(CSSParserTokenRange(tokens), context, false);
+ token_syntax->Parse(CSSParserTokenRange(tokens), *context, false);
ASSERT_TRUE(initial_value);
ASSERT_TRUE(initial_value->IsVariableReferenceValue());
PropertyRegistration* registration =
@@ -426,7 +426,7 @@ TEST_F(CSSVariableResolverTest, BillionLaughs) {
builder.Append("</style>\n");
builder.Append("<div id=target></div>\n");
- GetDocument().body()->SetInnerHTMLFromString(builder.ToString());
+ GetDocument().body()->setInnerHTML(builder.ToString());
UpdateAllLifecyclePhasesForTest();
Element* target = GetDocument().getElementById("target");
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/element_resolve_context.cc b/chromium/third_party/blink/renderer/core/css/resolver/element_resolve_context.cc
index 3e755ed6cd8..d6b8ea6ef44 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/element_resolve_context.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/element_resolve_context.cc
@@ -32,6 +32,8 @@ namespace blink {
ElementResolveContext::ElementResolveContext(Element& element)
: element_(&element),
+ parent_node_(nullptr),
+ layout_parent_(nullptr),
element_link_state_(
element.GetDocument().GetVisitedLinkState().DetermineLinkState(
element)),
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/element_resolve_context.h b/chromium/third_party/blink/renderer/core/css/resolver/element_resolve_context.h
index d1984700d80..3af63d30b8e 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/element_resolve_context.h
+++ b/chromium/third_party/blink/renderer/core/css/resolver/element_resolve_context.h
@@ -60,9 +60,9 @@ class CORE_EXPORT ElementResolveContext {
}
private:
- Member<Element> element_;
- Member<ContainerNode> parent_node_;
- Member<ContainerNode> layout_parent_;
+ Element* element_;
+ ContainerNode* parent_node_;
+ ContainerNode* layout_parent_;
scoped_refptr<const ComputedStyle> root_element_style_;
EInsideLink element_link_state_;
bool distributed_to_insertion_point_;
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/element_style_resources.cc b/chromium/third_party/blink/renderer/core/css/resolver/element_style_resources.cc
index 2c89c02b6cc..97c4441eea0 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/element_style_resources.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/element_style_resources.cc
@@ -220,8 +220,8 @@ void ElementStyleResources::LoadPendingImages(ComputedStyle* style) {
LoadPendingImage(style, To<StylePendingImage>(background_image),
image_request_optimization);
if (new_image && new_image->IsLazyloadPossiblyDeferred()) {
- LazyImageHelper::StartMonitoring(
- pseudo_element_ ? pseudo_element_ : element_.Get());
+ LazyImageHelper::StartMonitoring(pseudo_element_ ? pseudo_element_
+ : element_);
}
background_layer->SetImage(new_image);
}
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/element_style_resources.h b/chromium/third_party/blink/renderer/core/css/resolver/element_style_resources.h
index a61766b3006..d04897105c5 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/element_style_resources.h
+++ b/chromium/third_party/blink/renderer/core/css/resolver/element_style_resources.h
@@ -88,10 +88,10 @@ class ElementStyleResources {
FetchParameters::ImageRequestOptimization,
CrossOriginAttributeValue = kCrossOriginAttributeNotSet);
- Member<Element> element_;
+ Element* element_;
HashSet<CSSPropertyID> pending_image_properties_;
float device_scale_factor_;
- Member<PseudoElement> pseudo_element_;
+ PseudoElement* pseudo_element_;
DISALLOW_COPY_AND_ASSIGN(ElementStyleResources);
};
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/font_builder.cc b/chromium/third_party/blink/renderer/core/css/resolver/font_builder.cc
index f71b93bbf59..08667ae3f4a 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/font_builder.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/font_builder.cc
@@ -24,6 +24,8 @@
#include "third_party/blink/renderer/core/css/resolver/font_builder.h"
+#include "third_party/blink/renderer/core/css/css_font_selector.h"
+#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/css_value_keywords.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
@@ -35,8 +37,7 @@
namespace blink {
-FontBuilder::FontBuilder(const Document* document)
- : document_(document), flags_(0) {
+FontBuilder::FontBuilder(Document* document) : document_(document), flags_(0) {
DCHECK(!document || document->GetFrame());
}
@@ -95,8 +96,6 @@ AtomicString FontBuilder::GenericFontFamilyName(
return font_family_names::kWebkitCursive;
case FontDescription::kFantasyFamily:
return font_family_names::kWebkitFantasy;
- case FontDescription::kPictographFamily:
- return font_family_names::kWebkitPictograph;
}
}
@@ -255,18 +254,18 @@ float FontBuilder::GetComputedSizeFromSpecifiedSize(
}
void FontBuilder::CheckForGenericFamilyChange(
- const FontDescription& old_description,
+ const FontDescription& parent_description,
FontDescription& new_description) {
DCHECK(document_);
if (new_description.IsAbsoluteSize())
return;
- if (new_description.IsMonospace() == old_description.IsMonospace())
+ if (new_description.IsMonospace() == parent_description.IsMonospace())
return;
// For now, lump all families but monospace together.
if (new_description.GenericFamily() != FontDescription::kMonospaceFamily &&
- old_description.GenericFamily() != FontDescription::kMonospaceFamily)
+ parent_description.GenericFamily() != FontDescription::kMonospaceFamily)
return;
// We know the parent is monospace or the child is monospace, and that font
@@ -285,7 +284,7 @@ void FontBuilder::CheckForGenericFamilyChange(
? static_cast<float>(settings->GetDefaultFixedFontSize()) /
settings->GetDefaultFontSize()
: 1;
- size = old_description.IsMonospace()
+ size = parent_description.IsMonospace()
? new_description.SpecifiedSize() / fixed_scale_factor
: new_description.SpecifiedSize() * fixed_scale_factor;
}
@@ -294,7 +293,8 @@ void FontBuilder::CheckForGenericFamilyChange(
}
void FontBuilder::UpdateSpecifiedSize(FontDescription& font_description,
- const ComputedStyle& style) {
+ const ComputedStyle& style,
+ const ComputedStyle* parent_style) {
float specified_size = font_description.SpecifiedSize();
if (!specified_size && font_description.KeywordSize())
@@ -303,7 +303,12 @@ void FontBuilder::UpdateSpecifiedSize(FontDescription& font_description,
font_description.SetSpecifiedSize(specified_size);
- CheckForGenericFamilyChange(style.GetFontDescription(), font_description);
+ // TODO(crbug.com/1086680): Avoid nullptr parent style.
+ const FontDescription& parent_description =
+ parent_style ? parent_style->GetFontDescription()
+ : style.GetFontDescription();
+
+ CheckForGenericFamilyChange(parent_description, font_description);
}
void FontBuilder::UpdateAdjustedSize(FontDescription& font_description,
@@ -319,8 +324,7 @@ void FontBuilder::UpdateAdjustedSize(FontDescription& font_description,
// FontDescription::EffectiveFontSize.
font_description.SetAdjustedSize(font_description.ComputedSize());
- Font font(font_description);
- font.Update(font_selector);
+ Font font(font_description, font_selector);
const SimpleFontData* font_data = font.PrimaryFont();
@@ -406,8 +410,8 @@ void FontBuilder::UpdateFontDescription(FontDescription& description,
description.SetAdjustedSize(size);
}
-void FontBuilder::CreateFont(FontSelector* font_selector,
- ComputedStyle& style) {
+void FontBuilder::CreateFont(ComputedStyle& style,
+ const ComputedStyle* parent_style) {
DCHECK(document_);
if (!flags_)
@@ -416,18 +420,17 @@ void FontBuilder::CreateFont(FontSelector* font_selector,
FontDescription description = style.GetFontDescription();
UpdateFontDescription(description, style.ComputeFontOrientation());
-
- UpdateSpecifiedSize(description, style);
+ UpdateSpecifiedSize(description, style, parent_style);
UpdateComputedSize(description, style);
+
+ FontSelector* font_selector = document_->GetStyleEngine().GetFontSelector();
UpdateAdjustedSize(description, style, font_selector);
- style.SetFontDescription(description);
- style.GetFont().Update(font_selector);
+ style.SetFontInternal(Font(description, font_selector));
flags_ = 0;
}
-void FontBuilder::CreateFontForDocument(FontSelector* font_selector,
- ComputedStyle& document_style) {
+void FontBuilder::CreateFontForDocument(ComputedStyle& document_style) {
DCHECK(document_);
FontDescription font_description = FontDescription();
font_description.SetLocale(document_style.GetFontDescription().Locale());
@@ -437,12 +440,13 @@ void FontBuilder::CreateFontForDocument(FontSelector* font_selector,
SetSize(font_description,
FontDescription::Size(FontSizeFunctions::InitialKeywordSize(), 0.0f,
false));
- UpdateSpecifiedSize(font_description, document_style);
+ UpdateSpecifiedSize(font_description, document_style, &document_style);
UpdateComputedSize(font_description, document_style);
font_description.SetOrientation(document_style.ComputeFontOrientation());
- document_style.SetFontDescription(font_description);
- document_style.GetFont().Update(font_selector);
+
+ FontSelector* font_selector = document_->GetStyleEngine().GetFontSelector();
+ document_style.SetFontInternal(Font(font_description, font_selector));
}
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/font_builder.h b/chromium/third_party/blink/renderer/core/css/resolver/font_builder.h
index 2021eb1672f..b661f992d9b 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/font_builder.h
+++ b/chromium/third_party/blink/renderer/core/css/resolver/font_builder.h
@@ -42,7 +42,7 @@ class CORE_EXPORT FontBuilder {
STACK_ALLOCATED();
public:
- FontBuilder(const Document*);
+ explicit FontBuilder(Document*);
void SetInitial(float effective_zoom);
@@ -79,9 +79,8 @@ class CORE_EXPORT FontBuilder {
// FIXME: These need to just vend a Font object eventually.
void UpdateFontDescription(FontDescription&,
FontOrientation = FontOrientation::kHorizontal);
- void CreateFont(FontSelector*, ComputedStyle&);
-
- void CreateFontForDocument(FontSelector*, ComputedStyle&);
+ void CreateFont(ComputedStyle&, const ComputedStyle* parent_style);
+ void CreateFontForDocument(ComputedStyle&);
bool FontDirty() const { return flags_; }
@@ -129,7 +128,9 @@ class CORE_EXPORT FontBuilder {
// This function fixes up the default font size if it detects that the current
// generic font family has changed. -dwh
void CheckForGenericFamilyChange(const FontDescription&, FontDescription&);
- void UpdateSpecifiedSize(FontDescription&, const ComputedStyle&);
+ void UpdateSpecifiedSize(FontDescription&,
+ const ComputedStyle&,
+ const ComputedStyle* parent_style);
void UpdateComputedSize(FontDescription&, const ComputedStyle&);
void UpdateAdjustedSize(FontDescription&,
const ComputedStyle&,
@@ -139,7 +140,7 @@ class CORE_EXPORT FontBuilder {
float effective_zoom,
float specified_size);
- Member<const Document> document_;
+ Document* document_;
FontDescription font_description_;
enum class PropertySetFlag {
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/font_builder_test.cc b/chromium/third_party/blink/renderer/core/css/resolver/font_builder_test.cc
index 076628b2578..9aff72b7dd1 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/font_builder_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/font_builder_test.cc
@@ -49,8 +49,7 @@ TEST_F(FontBuilderInitTest, InitialFontSizeNotScaled) {
FontBuilder builder(&GetDocument());
builder.SetInitial(1.0f); // FIXME: Remove unused param.
- builder.CreateFont(GetDocument().GetStyleEngine().GetFontSelector(),
- *initial);
+ builder.CreateFont(*initial, initial.get());
EXPECT_EQ(16.0f, initial->GetFontDescription().ComputedSize());
}
@@ -69,13 +68,15 @@ TEST_P(FontBuilderAdditiveTest, OnlySetValueIsModified) {
FontDescription parent_description;
funcs.set_base_value(parent_description);
+ scoped_refptr<ComputedStyle> parent_style = ComputedStyle::Create();
+ parent_style->SetFontDescription(parent_description);
+
scoped_refptr<ComputedStyle> style = ComputedStyle::Create();
- style->SetFontDescription(parent_description);
+ style->InheritFrom(*parent_style);
FontBuilder font_builder(&GetDocument());
funcs.set_value(font_builder);
- font_builder.CreateFont(GetDocument().GetStyleEngine().GetFontSelector(),
- *style);
+ font_builder.CreateFont(*style, parent_style.get());
FontDescription output_description = style->GetFontDescription();
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/font_style_resolver.cc b/chromium/third_party/blink/renderer/core/css/resolver/font_style_resolver.cc
index e899b8e9cf4..cbac112bb23 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/font_style_resolver.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/font_style_resolver.cc
@@ -18,8 +18,7 @@ FontDescription FontStyleResolver::ComputeFont(
FontBuilder builder(nullptr);
FontDescription fontDescription;
- Font font(fontDescription);
- font.Update(font_selector);
+ Font font(fontDescription, font_selector);
CSSToLengthConversionData::FontSizes fontSizes(10, 10, &font, 1);
CSSToLengthConversionData::ViewportSize viewportSize(0, 0);
CSSToLengthConversionData conversionData(nullptr, fontSizes, viewportSize, 1);
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/match_request.h b/chromium/third_party/blink/renderer/core/css/resolver/match_request.h
index 1a500f48853..e7911422dfc 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/match_request.h
+++ b/chromium/third_party/blink/renderer/core/css/resolver/match_request.h
@@ -53,9 +53,9 @@ class MatchRequest {
rule_set->CompactRulesIfNeeded();
}
- Member<const RuleSet> rule_set;
- Member<const ContainerNode> scope;
- Member<const CSSStyleSheet> style_sheet;
+ const RuleSet* rule_set;
+ const ContainerNode* scope;
+ const CSSStyleSheet* style_sheet;
const unsigned style_sheet_index;
bool is_from_vtt;
};
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/match_result.cc b/chromium/third_party/blink/renderer/core/css/resolver/match_result.cc
index 4391044d6b1..ae05e3e6776 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/match_result.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/match_result.cc
@@ -43,9 +43,7 @@ MatchedProperties::MatchedProperties() {
memset(&types_, 0, sizeof(types_));
}
-MatchedProperties::~MatchedProperties() = default;
-
-void MatchedProperties::Trace(blink::Visitor* visitor) {
+void MatchedProperties::Trace(Visitor* visitor) {
visitor->Trace(properties);
}
@@ -60,17 +58,17 @@ void MatchResult::AddMatchedProperties(
new_properties.types_.valid_property_filter =
static_cast<std::underlying_type_t<ValidPropertyFilter>>(
valid_property_filter);
- // TODO(andruud): MatchedProperties are stored here in reverse order.
- // Reevaluate this when cascade has shipped.
- new_properties.types_.tree_order =
- std::numeric_limits<uint16_t>::max() - current_tree_order_;
+ new_properties.types_.origin = current_origin_;
+ new_properties.types_.tree_order = current_tree_order_;
}
void MatchResult::FinishAddingUARules() {
+ current_origin_ = CascadeOrigin::kUser;
ua_range_end_ = matched_properties_.size();
}
void MatchResult::FinishAddingUserRules() {
+ current_origin_ = CascadeOrigin::kAuthor;
// Don't add empty ranges.
if (user_range_ends_.IsEmpty() &&
ua_range_end_ == matched_properties_.size())
@@ -97,4 +95,23 @@ void MatchResult::FinishAddingAuthorRulesForTreeScope() {
current_tree_order_ = clampTo<uint16_t>(author_range_ends_.size());
}
+MatchedExpansionsRange MatchResult::Expansions(const Document& document,
+ CascadeFilter filter) const {
+ return MatchedExpansionsRange(
+ MatchedExpansionsIterator(matched_properties_.begin(), document, filter,
+ 0),
+ MatchedExpansionsIterator(matched_properties_.end(), document, filter,
+ matched_properties_.size()));
+}
+
+void MatchResult::Reset() {
+ matched_properties_.clear();
+ user_range_ends_.clear();
+ author_range_ends_.clear();
+ ua_range_end_ = 0;
+ is_cacheable_ = true;
+ current_origin_ = CascadeOrigin::kUserAgent;
+ current_tree_order_ = 0;
+}
+
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/match_result.h b/chromium/third_party/blink/renderer/core/css/resolver/match_result.h
index 2a6f8ad74ed..476088ef23e 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/match_result.h
+++ b/chromium/third_party/blink/renderer/core/css/resolver/match_result.h
@@ -26,6 +26,10 @@
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_expansion.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_filter.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_origin.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_priority.h"
#include "third_party/blink/renderer/core/css/rule_set.h"
#include "third_party/blink/renderer/core/css/selector_checker.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
@@ -40,15 +44,15 @@ struct CORE_EXPORT MatchedProperties {
public:
MatchedProperties();
- ~MatchedProperties();
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
Member<CSSPropertyValueSet> properties;
struct Data {
unsigned link_match_type : 2;
unsigned valid_property_filter : 2;
+ CascadeOrigin origin;
// This is approximately equivalent to the 'shadow-including tree order'.
// It can be used to evaluate the 'Shadow Tree' criteria. Note that the
// number stored here is 'local' to each origin (user, author), and is
@@ -95,6 +99,58 @@ class MatchedPropertiesRange {
MatchedPropertiesVector::const_iterator end_;
};
+class MatchedExpansionsIterator {
+ STACK_ALLOCATED();
+ using Iterator = MatchedPropertiesVector::const_iterator;
+
+ public:
+ MatchedExpansionsIterator(Iterator iterator,
+ const Document& document,
+ CascadeFilter filter,
+ size_t index)
+ : iterator_(iterator),
+ document_(document),
+ filter_(filter),
+ index_(index) {}
+
+ void operator++() {
+ iterator_++;
+ index_++;
+ }
+ bool operator==(const MatchedExpansionsIterator& o) const {
+ return iterator_ == o.iterator_;
+ }
+ bool operator!=(const MatchedExpansionsIterator& o) const {
+ return iterator_ != o.iterator_;
+ }
+
+ CascadeExpansion operator*() const {
+ return CascadeExpansion(*iterator_, document_, filter_, index_);
+ }
+
+ private:
+ Iterator iterator_;
+ const Document& document_;
+ CascadeFilter filter_;
+ size_t index_;
+};
+
+class MatchedExpansionsRange {
+ STACK_ALLOCATED();
+
+ public:
+ MatchedExpansionsRange(MatchedExpansionsIterator begin,
+ MatchedExpansionsIterator end)
+ : begin_(begin), end_(end) {}
+
+ MatchedExpansionsIterator begin() const { return begin_; }
+ MatchedExpansionsIterator end() const { return end_; }
+
+ private:
+ MatchedExpansionsIterator begin_;
+ MatchedExpansionsIterator end_;
+};
+
class CORE_EXPORT MatchResult {
STACK_ALLOCATED();
@@ -114,6 +170,8 @@ class CORE_EXPORT MatchResult {
void SetIsCacheable(bool cacheable) { is_cacheable_ = cacheable; }
bool IsCacheable() const { return is_cacheable_; }
+ MatchedExpansionsRange Expansions(const Document&, CascadeFilter) const;
+
MatchedPropertiesRange AllRules() const {
return MatchedPropertiesRange(matched_properties_.begin(),
matched_properties_.end());
@@ -146,6 +204,10 @@ class CORE_EXPORT MatchResult {
return matched_properties_;
}
+ // Reset the MatchResult to its initial state, as if no MatchedProperties
+ // objects were added.
+ void Reset();
+
private:
friend class ImportantUserRanges;
friend class ImportantUserRangeIterator;
@@ -157,6 +219,7 @@ class CORE_EXPORT MatchResult {
Vector<unsigned, 16> author_range_ends_;
unsigned ua_range_end_ = 0;
bool is_cacheable_ = true;
+ CascadeOrigin current_origin_ = CascadeOrigin::kUserAgent;
uint16_t current_tree_order_ = 0;
DISALLOW_COPY_AND_ASSIGN(MatchResult);
};
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/match_result_test.cc b/chromium/third_party/blink/renderer/core/css/resolver/match_result_test.cc
index 8ee20ac3ee8..02a87f62bef 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/match_result_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/match_result_test.cc
@@ -4,13 +4,16 @@
#include "third_party/blink/renderer/core/css/resolver/match_result.h"
-#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/css/css_property_value_set.h"
+#include "third_party/blink/renderer/core/css/css_test_helpers.h"
+#include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
namespace blink {
-class MatchResultTest : public testing::Test {
+using css_test_helpers::ParseDeclarationBlock;
+
+class MatchResultTest : public PageTestBase {
protected:
void SetUp() override;
@@ -23,6 +26,7 @@ class MatchResultTest : public testing::Test {
};
void MatchResultTest::SetUp() {
+ PageTestBase::SetUp();
property_sets =
MakeGarbageCollected<HeapVector<Member<MutableCSSPropertyValueSet>, 8>>();
for (unsigned i = 0; i < 8; i++) {
@@ -39,6 +43,14 @@ void TestMatchedPropertiesRange(const MatchedPropertiesRange& range,
EXPECT_EQ(*expected_sets++, matched_properties.properties);
}
+void TestOriginInRange(const MatchedPropertiesRange& range,
+ int expected_length,
+ CascadeOrigin expected_origin) {
+ EXPECT_EQ(expected_length, range.end() - range.begin());
+ for (const auto& matched_properties : range)
+ EXPECT_EQ(matched_properties.types_.origin, expected_origin);
+}
+
TEST_F(MatchResultTest, UARules) {
const CSSPropertyValueSet* ua_sets[] = {PropertySet(0), PropertySet(1)};
@@ -225,4 +237,224 @@ TEST_F(MatchResultTest, AllRulesMultipleScopes) {
EXPECT_EQ(importantUser.end(), ++importantUser.begin());
}
+TEST_F(MatchResultTest, CascadeOriginUserAgent) {
+ MatchResult result;
+ result.AddMatchedProperties(PropertySet(0));
+ result.AddMatchedProperties(PropertySet(1));
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ TestOriginInRange(result.UaRules(), 2, CascadeOrigin::kUserAgent);
+ TestOriginInRange(result.AllRules(), 2, CascadeOrigin::kUserAgent);
+}
+
+TEST_F(MatchResultTest, CascadeOriginUser) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.AddMatchedProperties(PropertySet(0));
+ result.AddMatchedProperties(PropertySet(1));
+ result.FinishAddingUserRules();
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ TestOriginInRange(result.UserRules(), 2, CascadeOrigin::kUser);
+ TestOriginInRange(result.AllRules(), 2, CascadeOrigin::kUser);
+}
+
+TEST_F(MatchResultTest, CascadeOriginAuthor) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(PropertySet(0));
+ result.AddMatchedProperties(PropertySet(1));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ TestOriginInRange(result.AuthorRules(), 2, CascadeOrigin::kAuthor);
+ TestOriginInRange(result.AllRules(), 2, CascadeOrigin::kAuthor);
+}
+
+TEST_F(MatchResultTest, CascadeOriginAll) {
+ MatchResult result;
+ result.AddMatchedProperties(PropertySet(0));
+ result.FinishAddingUARules();
+ result.AddMatchedProperties(PropertySet(1));
+ result.AddMatchedProperties(PropertySet(2));
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(PropertySet(3));
+ result.AddMatchedProperties(PropertySet(4));
+ result.AddMatchedProperties(PropertySet(5));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ TestOriginInRange(result.UaRules(), 1, CascadeOrigin::kUserAgent);
+ TestOriginInRange(result.UserRules(), 2, CascadeOrigin::kUser);
+ TestOriginInRange(result.AuthorRules(), 3, CascadeOrigin::kAuthor);
+}
+
+TEST_F(MatchResultTest, CascadeOriginAllExceptUserAgent) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.AddMatchedProperties(PropertySet(1));
+ result.AddMatchedProperties(PropertySet(2));
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(PropertySet(3));
+ result.AddMatchedProperties(PropertySet(4));
+ result.AddMatchedProperties(PropertySet(5));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ TestOriginInRange(result.UaRules(), 0, CascadeOrigin::kUserAgent);
+ TestOriginInRange(result.UserRules(), 2, CascadeOrigin::kUser);
+ TestOriginInRange(result.AuthorRules(), 3, CascadeOrigin::kAuthor);
+}
+
+TEST_F(MatchResultTest, CascadeOriginAllExceptUser) {
+ MatchResult result;
+ result.AddMatchedProperties(PropertySet(0));
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(PropertySet(3));
+ result.AddMatchedProperties(PropertySet(4));
+ result.AddMatchedProperties(PropertySet(5));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ TestOriginInRange(result.UaRules(), 1, CascadeOrigin::kUserAgent);
+ TestOriginInRange(result.UserRules(), 0, CascadeOrigin::kUser);
+ TestOriginInRange(result.AuthorRules(), 3, CascadeOrigin::kAuthor);
+}
+
+TEST_F(MatchResultTest, CascadeOriginAllExceptAuthor) {
+ MatchResult result;
+ result.AddMatchedProperties(PropertySet(0));
+ result.FinishAddingUARules();
+ result.AddMatchedProperties(PropertySet(1));
+ result.AddMatchedProperties(PropertySet(2));
+ result.FinishAddingUserRules();
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ TestOriginInRange(result.UaRules(), 1, CascadeOrigin::kUserAgent);
+ TestOriginInRange(result.UserRules(), 2, CascadeOrigin::kUser);
+ TestOriginInRange(result.AuthorRules(), 0, CascadeOrigin::kAuthor);
+}
+
+TEST_F(MatchResultTest, CascadeOriginTreeScopes) {
+ MatchResult result;
+ result.AddMatchedProperties(PropertySet(0));
+ result.FinishAddingUARules();
+ result.AddMatchedProperties(PropertySet(1));
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(PropertySet(2));
+ result.FinishAddingAuthorRulesForTreeScope();
+ result.AddMatchedProperties(PropertySet(3));
+ result.AddMatchedProperties(PropertySet(4));
+ result.FinishAddingAuthorRulesForTreeScope();
+ result.AddMatchedProperties(PropertySet(5));
+ result.AddMatchedProperties(PropertySet(6));
+ result.AddMatchedProperties(PropertySet(7));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ TestOriginInRange(result.UaRules(), 1, CascadeOrigin::kUserAgent);
+ TestOriginInRange(result.UserRules(), 1, CascadeOrigin::kUser);
+ TestOriginInRange(result.AuthorRules(), 6, CascadeOrigin::kAuthor);
+}
+
+TEST_F(MatchResultTest, ExpansionsRange) {
+ MatchResult result;
+ result.AddMatchedProperties(ParseDeclarationBlock("left:1px;all:unset"));
+ result.AddMatchedProperties(ParseDeclarationBlock("color:red"));
+ result.FinishAddingUARules();
+ result.AddMatchedProperties(ParseDeclarationBlock("display:block"));
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(ParseDeclarationBlock("left:unset"));
+ result.AddMatchedProperties(ParseDeclarationBlock("top:unset"));
+ result.AddMatchedProperties(
+ ParseDeclarationBlock("right:unset;bottom:unset"));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ CascadeFilter filter;
+
+ size_t i = 0;
+ size_t size = result.GetMatchedProperties().size();
+ for (auto actual : result.Expansions(GetDocument(), filter)) {
+ ASSERT_LT(i, size);
+ CascadeExpansion expected(result.GetMatchedProperties()[i], GetDocument(),
+ filter, i);
+ EXPECT_EQ(expected.Id(), actual.Id());
+ EXPECT_EQ(expected.Priority(), actual.Priority());
+ EXPECT_EQ(expected.Value(), actual.Value());
+ ++i;
+ }
+
+ EXPECT_EQ(6u, i);
+}
+
+TEST_F(MatchResultTest, EmptyExpansionsRange) {
+ MatchResult result;
+ result.FinishAddingUARules();
+ result.FinishAddingUserRules();
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ CascadeFilter filter;
+ auto range = result.Expansions(GetDocument(), filter);
+ EXPECT_EQ(range.end(), range.begin());
+}
+
+TEST_F(MatchResultTest, Reset) {
+ MatchResult result;
+ result.AddMatchedProperties(PropertySet(0));
+ result.FinishAddingUARules();
+ result.AddMatchedProperties(PropertySet(1));
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(PropertySet(2));
+ result.FinishAddingAuthorRulesForTreeScope();
+ result.AddMatchedProperties(PropertySet(3));
+ result.FinishAddingAuthorRulesForTreeScope();
+ result.AddMatchedProperties(PropertySet(4));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ TestOriginInRange(result.UaRules(), 1, CascadeOrigin::kUserAgent);
+ TestOriginInRange(result.UserRules(), 1, CascadeOrigin::kUser);
+ TestOriginInRange(result.AuthorRules(), 3, CascadeOrigin::kAuthor);
+
+ // Check tree_order of last entry.
+ EXPECT_TRUE(result.HasMatchedProperties());
+ ASSERT_EQ(5u, result.GetMatchedProperties().size());
+ EXPECT_EQ(2u, result.GetMatchedProperties()[4].types_.tree_order);
+
+ EXPECT_TRUE(result.IsCacheable());
+ result.SetIsCacheable(false);
+ EXPECT_FALSE(result.IsCacheable());
+
+ result.Reset();
+
+ EXPECT_TRUE(result.UaRules().IsEmpty());
+ EXPECT_TRUE(result.UserRules().IsEmpty());
+ EXPECT_TRUE(result.AuthorRules().IsEmpty());
+ EXPECT_TRUE(result.AllRules().IsEmpty());
+ EXPECT_TRUE(result.IsCacheable());
+ EXPECT_FALSE(result.GetMatchedProperties().size());
+ EXPECT_FALSE(result.HasMatchedProperties());
+
+ // Add same declarations again.
+ result.AddMatchedProperties(PropertySet(0));
+ result.FinishAddingUARules();
+ result.AddMatchedProperties(PropertySet(1));
+ result.FinishAddingUserRules();
+ result.AddMatchedProperties(PropertySet(2));
+ result.FinishAddingAuthorRulesForTreeScope();
+ result.AddMatchedProperties(PropertySet(3));
+ result.FinishAddingAuthorRulesForTreeScope();
+ result.AddMatchedProperties(PropertySet(4));
+ result.FinishAddingAuthorRulesForTreeScope();
+
+ TestOriginInRange(result.UaRules(), 1, CascadeOrigin::kUserAgent);
+ TestOriginInRange(result.UserRules(), 1, CascadeOrigin::kUser);
+ TestOriginInRange(result.AuthorRules(), 3, CascadeOrigin::kAuthor);
+
+ // Check tree_order of last entry.
+ EXPECT_TRUE(result.HasMatchedProperties());
+ ASSERT_EQ(5u, result.GetMatchedProperties().size());
+ EXPECT_EQ(2u, result.GetMatchedProperties()[4].types_.tree_order);
+
+ EXPECT_TRUE(result.IsCacheable());
+}
+
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/matched_properties_cache.cc b/chromium/third_party/blink/renderer/core/css/resolver/matched_properties_cache.cc
index e47045b6284..08a34b7e55a 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/matched_properties_cache.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/matched_properties_cache.cc
@@ -178,7 +178,7 @@ bool MatchedPropertiesCache::IsCacheable(const StyleResolverState& state) {
return true;
}
-void MatchedPropertiesCache::Trace(blink::Visitor* visitor) {
+void MatchedPropertiesCache::Trace(Visitor* visitor) {
visitor->Trace(cache_);
visitor->RegisterWeakCallbackMethod<
MatchedPropertiesCache,
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/matched_properties_cache.h b/chromium/third_party/blink/renderer/core/css/resolver/matched_properties_cache.h
index 261a4501e61..fd88d23411b 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/matched_properties_cache.h
+++ b/chromium/third_party/blink/renderer/core/css/resolver/matched_properties_cache.h
@@ -52,7 +52,7 @@ class CachedMatchedProperties final
const MatchedPropertiesVector&);
void Clear();
- void Trace(blink::Visitor*) {}
+ void Trace(Visitor*) {}
bool operator==(const MatchedPropertiesVector& properties);
bool operator!=(const MatchedPropertiesVector& properties);
@@ -79,7 +79,7 @@ class CORE_EXPORT MatchedPropertiesCache {
static bool IsCacheable(const StyleResolverState&);
static bool IsStyleCacheable(const ComputedStyle&);
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
// The cache is mapping a hash to a cached entry where the entry is kept as
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/media_query_result.h b/chromium/third_party/blink/renderer/core/css/resolver/media_query_result.h
index 6ff6d379648..6ec50445e86 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/media_query_result.h
+++ b/chromium/third_party/blink/renderer/core/css/resolver/media_query_result.h
@@ -44,6 +44,22 @@ class MediaQueryResult {
bool result_;
};
+class MediaQuerySetResult {
+ DISALLOW_NEW();
+
+ public:
+ MediaQuerySetResult(const MediaQuerySet& media_queries, bool result)
+ : media_queries_(&media_queries), result_(result) {}
+
+ const MediaQuerySet& MediaQueries() const { return *media_queries_; }
+
+ bool Result() const { return result_; }
+
+ private:
+ scoped_refptr<const MediaQuerySet> media_queries_;
+ bool result_;
+};
+
} // namespace blink
#endif
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/scoped_style_resolver.cc b/chromium/third_party/blink/renderer/core/css/resolver/scoped_style_resolver.cc
index f27c2171e2c..0b75dc38e7c 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/scoped_style_resolver.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/scoped_style_resolver.cc
@@ -288,7 +288,7 @@ void ScopedStyleResolver::MatchPageRules(PageRuleCollector& collector) {
collector.MatchPageRules(&sheet->Contents()->GetRuleSet());
}
-void ScopedStyleResolver::Trace(blink::Visitor* visitor) {
+void ScopedStyleResolver::Trace(Visitor* visitor) {
visitor->Trace(scope_);
visitor->Trace(author_style_sheets_);
visitor->Trace(keyframes_rule_map_);
@@ -386,7 +386,7 @@ void ScopedStyleResolver::AddSlottedRules(const RuleSet& author_rules,
parent_style_sheet, sheet_index, slotted_rule_set));
}
-void ScopedStyleResolver::RuleSubSet::Trace(blink::Visitor* visitor) {
+void ScopedStyleResolver::RuleSubSet::Trace(Visitor* visitor) {
visitor->Trace(parent_style_sheet_);
visitor->Trace(rule_set_);
}
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/scoped_style_resolver.h b/chromium/third_party/blink/renderer/core/css/resolver/scoped_style_resolver.h
index 51ed87c6892..ae51e9644af 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/scoped_style_resolver.h
+++ b/chromium/third_party/blink/renderer/core/css/resolver/scoped_style_resolver.h
@@ -88,7 +88,7 @@ class CORE_EXPORT ScopedStyleResolver final
static Element& InvalidationRootForTreeScope(const TreeScope&);
void V0ShadowAddedOnV1Document();
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
void AddTreeBoundaryCrossingRules(const RuleSet&,
@@ -118,7 +118,7 @@ class CORE_EXPORT ScopedStyleResolver final
unsigned parent_index_;
Member<RuleSet> rule_set_;
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
};
using CSSStyleSheetRuleSubSet = HeapVector<Member<RuleSubSet>>;
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/selector_filter_parent_scope.h b/chromium/third_party/blink/renderer/core/css/resolver/selector_filter_parent_scope.h
index 9d98c9d3fc1..598d5c8a684 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/selector_filter_parent_scope.h
+++ b/chromium/third_party/blink/renderer/core/css/resolver/selector_filter_parent_scope.h
@@ -40,11 +40,11 @@ class CORE_EXPORT SelectorFilterParentScope {
void PushAncestors(Element&);
void PopAncestors(Element&);
- Member<Element> parent_;
+ Element* parent_;
bool pushed_ = false;
ScopeType scope_type_;
SelectorFilterParentScope* previous_;
- Member<StyleResolver> resolver_;
+ StyleResolver* resolver_;
static SelectorFilterParentScope* current_scope_;
};
@@ -70,7 +70,10 @@ class CORE_EXPORT SelectorFilterRootScope final
inline SelectorFilterParentScope::SelectorFilterParentScope(
Element* parent,
ScopeType scope_type)
- : parent_(parent), scope_type_(scope_type), previous_(current_scope_) {
+ : parent_(parent),
+ scope_type_(scope_type),
+ previous_(current_scope_),
+ resolver_(nullptr) {
DCHECK(scope_type != ScopeType::kRoot || !parent || !previous_ ||
!previous_->parent_ ||
&parent_->GetDocument() != &previous_->parent_->GetDocument());
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/selector_filter_parent_scope_test.cc b/chromium/third_party/blink/renderer/core/css/resolver/selector_filter_parent_scope_test.cc
index e1c19e8d946..550f016357f 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/selector_filter_parent_scope_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/selector_filter_parent_scope_test.cc
@@ -56,7 +56,7 @@ TEST_F(SelectorFilterParentScopeTest, ParentScope) {
}
TEST_F(SelectorFilterParentScopeTest, RootScope) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<div class=x>
<span id=y></span>
</div>
@@ -84,7 +84,7 @@ TEST_F(SelectorFilterParentScopeTest, RootScope) {
}
TEST_F(SelectorFilterParentScopeTest, ReentrantSVGImageLoading) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
div::before {
content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"></svg>');
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/style_adjuster.cc b/chromium/third_party/blink/renderer/core/css/resolver/style_adjuster.cc
index 46e74fd190c..49f61afb7c4 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/style_adjuster.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/style_adjuster.cc
@@ -50,9 +50,12 @@
#include "third_party/blink/renderer/core/html/html_table_cell_element.h"
#include "third_party/blink/renderer/core/html/media/html_media_element.h"
#include "third_party/blink/renderer/core/html_names.h"
+#include "third_party/blink/renderer/core/layout/layout_list_marker.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/layout/layout_replaced.h"
#include "third_party/blink/renderer/core/layout/layout_theme.h"
+#include "third_party/blink/renderer/core/mathml/mathml_fraction_element.h"
+#include "third_party/blink/renderer/core/mathml/mathml_space_element.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/style/computed_style_constants.h"
#include "third_party/blink/renderer/core/svg/svg_svg_element.h"
@@ -74,7 +77,7 @@ TouchAction AdjustTouchActionForElement(TouchAction touch_action,
element && element == element->GetDocument().documentElement() &&
element->GetDocument().LocalOwner();
if (style.ScrollsOverflow() || is_child_document)
- return touch_action | TouchAction::kTouchActionPan;
+ return touch_action | TouchAction::kPan;
return touch_action;
}
@@ -130,24 +133,28 @@ static bool IsOutermostSVGElement(const Element* element) {
return svg_element && svg_element->IsOutermostSVGSVGElement();
}
-static bool IsAtUAShadowBoundary(const Element* element) {
+static bool IsAtMediaUAShadowBoundary(const Element* element) {
if (!element)
return false;
- if (ContainerNode* parent = element->parentNode())
- return parent->IsShadowRoot() && To<ShadowRoot>(parent)->IsUserAgent();
+ if (ContainerNode* parent = element->parentNode()) {
+ if (auto* shadow_root = DynamicTo<ShadowRoot>(parent))
+ return shadow_root->host().IsMediaElement();
+ }
return false;
}
-// CSS requires text-decoration to be reset at each DOM element for
-// inline blocks, inline tables, UA shadow DOM crossings, floating elements,
-// and absolute or relatively positioned elements. Outermost <svg> roots are
-// considered to be atomic inline-level.
+// CSS requires text-decoration to be reset at each DOM element for inline
+// blocks, inline tables, floating elements, and absolute or relatively
+// positioned elements. Outermost <svg> roots are considered to be atomic
+// inline-level. Media elements have a special rendering where the media
+// controls do not use a proper containing block model which means we need
+// to manually stop text-decorations to apply to text inside media controls.
static bool StopPropagateTextDecorations(const ComputedStyle& style,
const Element* element) {
return style.Display() == EDisplay::kInlineTable ||
style.Display() == EDisplay::kInlineBlock ||
style.Display() == EDisplay::kWebkitInlineBox ||
- IsAtUAShadowBoundary(element) || style.IsFloating() ||
+ IsAtMediaUAShadowBoundary(element) || style.IsFloating() ||
style.HasOutOfFlowPosition() || IsOutermostSVGElement(element) ||
IsA<HTMLRTElement>(element);
}
@@ -197,6 +204,37 @@ static void AdjustStyleForFirstLetter(ComputedStyle& style) {
style.SetPosition(EPosition::kStatic);
}
+static void AdjustStyleForMarker(ComputedStyle& style,
+ const ComputedStyle& parent_style,
+ const Element& parent_element) {
+ if (style.StyleType() != kPseudoIdMarker)
+ return;
+
+ bool is_inside =
+ parent_style.ListStylePosition() == EListStylePosition::kInside ||
+ (IsA<HTMLLIElement>(parent_element) &&
+ !parent_style.IsInsideListElement());
+
+ if (is_inside) {
+ auto margins = LayoutListMarker::InlineMarginsForInside(
+ style, parent_style.GeneratesMarkerImage());
+ style.SetMarginStart(Length::Fixed(margins.first));
+ style.SetMarginEnd(Length::Fixed(margins.second));
+ } else {
+ // Outside list markers should generate a block container.
+ style.SetDisplay(EDisplay::kInlineBlock);
+
+ // Do not break inside the marker, and honor the trailing spaces.
+ style.SetWhiteSpace(EWhiteSpace::kPre);
+
+ // Compute margins for 'outside' during layout, because it requires the
+ // layout size of the marker.
+ // TODO(kojii): absolute position looks more reasonable, and maybe required
+ // in some cases, but this is currently blocked by crbug.com/734554
+ // style.SetPosition(EPosition::kAbsolute);
+ }
+}
+
static void AdjustStyleForHTMLElement(ComputedStyle& style,
HTMLElement& element) {
// <div> and <span> are the most common elements on the web, we skip all the
@@ -204,7 +242,7 @@ static void AdjustStyleForHTMLElement(ComputedStyle& style,
if (IsA<HTMLDivElement>(element) || IsA<HTMLSpanElement>(element))
return;
- if (IsHTMLTableCellElement(element)) {
+ if (IsA<HTMLTableCellElement>(element)) {
if (style.WhiteSpace() == EWhiteSpace::kWebkitNowrap) {
// Figure out if we are really nowrapping or if we should just
// use normal instead. If the width of the cell is fixed, then
@@ -243,7 +281,7 @@ static void AdjustStyleForHTMLElement(ComputedStyle& style,
return;
}
- if (IsHTMLFrameElementBase(element)) {
+ if (IsA<HTMLFrameElementBase>(element)) {
if (style.Display() == EDisplay::kContents) {
style.SetDisplay(EDisplay::kNone);
return;
@@ -296,20 +334,36 @@ static void AdjustStyleForHTMLElement(ComputedStyle& style,
return;
}
- if (IsHTMLPlugInElement(element)) {
+ if (auto* html_plugin_element = DynamicTo<HTMLPlugInElement>(element)) {
style.SetRequiresAcceleratedCompositingForExternalReasons(
- ToHTMLPlugInElement(element).ShouldAccelerate());
+ html_plugin_element->ShouldAccelerate());
if (style.Display() == EDisplay::kContents)
style.SetDisplay(EDisplay::kNone);
return;
}
+ if (IsA<HTMLUListElement>(element) || IsA<HTMLOListElement>(element)) {
+ style.SetIsInsideListElement();
+ return;
+ }
+
+ if (IsA<HTMLSummaryElement>(element)) {
+ // <summary> should be a list item by default, but currently it's a block
+ // and the disclosure symbol is not a ::marker (bug 590014). If an author
+ // specifies 'display: list-item', the <summary> would seem to have two
+ // markers (the real one and the disclosure symbol). To avoid this, compute
+ // to 'display: block'. This adjustment should go away with bug 590014.
+ if (style.Display() == EDisplay::kListItem)
+ style.SetDisplay(EDisplay::kBlock);
+ return;
+ }
+
if (style.Display() == EDisplay::kContents) {
// See https://drafts.csswg.org/css-display/#unbox-html
// Some of these elements are handled with other adjustments above.
if (IsA<HTMLBRElement>(element) || IsA<HTMLWBRElement>(element) ||
IsA<HTMLMeterElement>(element) || IsA<HTMLProgressElement>(element) ||
- IsA<HTMLCanvasElement>(element) || IsHTMLMediaElement(element) ||
+ IsA<HTMLCanvasElement>(element) || IsA<HTMLMediaElement>(element) ||
IsA<HTMLInputElement>(element) || IsA<HTMLTextAreaElement>(element) ||
IsA<HTMLSelectElement>(element)) {
style.SetDisplay(EDisplay::kNone);
@@ -347,12 +401,6 @@ void StyleAdjuster::AdjustOverflow(ComputedStyle& style) {
style.OverflowX() != EOverflow::kVisible) {
style.SetOverflowY(EOverflow::kAuto);
}
-
- // Menulists should have visible overflow
- if (style.Appearance() == kMenulistPart) {
- style.SetOverflowX(EOverflow::kVisible);
- style.SetOverflowY(EOverflow::kVisible);
- }
}
static void AdjustStyleForDisplay(ComputedStyle& style,
@@ -467,7 +515,7 @@ static void AdjustEffectiveTouchAction(ComputedStyle& style,
bool is_layout_object_needed =
element && element->LayoutObjectIsNeeded(style);
- TouchAction element_touch_action = TouchAction::kTouchActionAuto;
+ TouchAction element_touch_action = TouchAction::kAuto;
// Touch actions are only supported by elements that support both the CSS
// width and height properties.
// See https://www.w3.org/TR/pointerevents/#the-touch-action-css-property.
@@ -486,7 +534,7 @@ static void AdjustEffectiveTouchAction(ComputedStyle& style,
// Apply touch action inherited from parent frame.
if (is_child_document && element->GetDocument().GetFrame()) {
inherited_action &=
- TouchAction::kTouchActionPan |
+ TouchAction::kPan |
element->GetDocument().GetFrame()->InheritedEffectiveTouchAction();
}
@@ -500,9 +548,9 @@ static void AdjustEffectiveTouchAction(ComputedStyle& style,
inherited_action =
AdjustTouchActionForElement(inherited_action, style, element);
- TouchAction enforced_by_policy = TouchAction::kTouchActionNone;
+ TouchAction enforced_by_policy = TouchAction::kNone;
if (element->GetDocument().IsVerticalScrollEnforced())
- enforced_by_policy = TouchAction::kTouchActionPanY;
+ enforced_by_policy = TouchAction::kPanY;
// Apply the adjusted parent effective touch actions.
style.SetEffectiveTouchAction((element_touch_action & inherited_action) |
@@ -518,57 +566,22 @@ static void AdjustEffectiveTouchAction(ComputedStyle& style,
}
}
-static void AdjustStateForRenderSubtree(ComputedStyle& style,
- Element* element) {
+static void AdjustStateForSubtreeVisibility(ComputedStyle& style,
+ Element* element) {
if (!element)
return;
-
- bool should_be_invisible = style.RenderSubtreeInvisible();
auto* context = element->GetDisplayLockContext();
-
- // Return early if there's no context and no render-subtree invisible token.
- if (!should_be_invisible && !context)
- return;
-
- // If we're using an attribute version of display locking, then also abort.
- if (context && DisplayLockContext::IsAttributeVersion(context))
+ // The common case for most elements is that we don't have a context and have
+ // the default (visible) subtree-visibility value.
+ if (LIKELY(!context &&
+ style.SubtreeVisibility() == ESubtreeVisibility::kVisible)) {
return;
-
- // Create a context if we need to be invisible.
- if (should_be_invisible && !context) {
- context = &element->EnsureDisplayLockContext(
- DisplayLockContextCreateMethod::kCSS);
- }
- DCHECK(context);
-
- uint16_t activation_mask =
- static_cast<uint16_t>(DisplayLockActivationReason::kAny);
- if (style.RenderSubtreeSkipActivation()) {
- activation_mask = 0;
- } else if (style.RenderSubtreeSkipViewportActivation()) {
- activation_mask &=
- ~static_cast<uint16_t>(DisplayLockActivationReason::kViewport);
}
- // Propagate activatable style to context.
- context->SetActivatable(activation_mask);
-
- if (should_be_invisible) {
- // Add containment to style if we're invisible.
- auto contain =
- style.Contain() | kContainsStyle | kContainsLayout | kContainsSize;
- style.SetContain(contain);
-
- // If we're unlocked and unactivated, then we should lock the context. Note
- // that we do this here, since locking the element means we can skip styling
- // the subtree.
- if (!context->IsLocked() && !context->IsActivated())
- context->StartAcquire();
- } else {
- context->ClearActivated();
- if (context->IsLocked())
- context->StartCommit();
- }
+ if (!context)
+ context = &element->EnsureDisplayLockContext();
+ context->SetRequestedState(style.SubtreeVisibility());
+ context->AdjustElementStyle(&style);
}
void StyleAdjuster::AdjustComputedStyle(StyleResolverState& state,
@@ -608,6 +621,7 @@ void StyleAdjuster::AdjustComputedStyle(StyleResolverState& state,
// We don't adjust the first letter style earlier because we may change the
// display setting in adjustStyeForTagName() above.
AdjustStyleForFirstLetter(style);
+ AdjustStyleForMarker(style, parent_style, state.GetElement());
AdjustStyleForDisplay(style, layout_parent_style,
element ? &element->GetDocument() : nullptr);
@@ -618,35 +632,18 @@ void StyleAdjuster::AdjustComputedStyle(StyleResolverState& state,
style.SetDisplayLayoutCustomParentName(
layout_parent_style.DisplayLayoutCustomName());
}
+
+ bool is_in_main_frame = element && element->GetDocument().IsInMainFrame();
+ // The root element of the main frame has no backdrop, so don't allow
+ // it to have a backdrop filter either.
+ if (is_document_element && is_in_main_frame && style.HasBackdropFilter())
+ style.MutableBackdropFilter().clear();
} else {
AdjustStyleForFirstLetter(style);
}
- if (element &&
- RuntimeEnabledFeatures::DisplayLockingEnabled(
- element->GetExecutionContext()) &&
- element->FastHasAttribute(html_names::kRendersubtreeAttr)) {
- // The element has the rendersubtree attr, so we should add style and
- // layout containment. If the attribute contains "invisible" we should
- // also add size containment.
- Containment contain = kContainsStyle | kContainsLayout;
- SpaceSplitString tokens(
- element->FastGetAttribute(html_names::kRendersubtreeAttr).LowerASCII());
- if (style.ContainsSize() || tokens.Contains("invisible")) {
- contain |= kContainsSize;
- }
- if (style.ContainsPaint())
- contain |= kContainsPaint;
- style.SetContain(contain);
- }
-
- if (RuntimeEnabledFeatures::CSSRenderSubtreeEnabled())
- AdjustStateForRenderSubtree(style, element);
-
- if (style.IsColorInternalText()) {
- style.ResolveInternalTextColor(
- LayoutTheme::GetTheme().RootElementColor(style.UsedColorScheme()));
- }
+ if (RuntimeEnabledFeatures::CSSSubtreeVisibilityEnabled())
+ AdjustStateForSubtreeVisibility(style, element);
// Make sure our z-index value is only applied if the object is positioned.
if (style.GetPosition() == EPosition::kStatic &&
@@ -719,6 +716,18 @@ void StyleAdjuster::AdjustComputedStyle(StyleResolverState& state,
// https://drafts.csswg.org/css-display/#unbox-mathml
style.SetDisplay(EDisplay::kNone);
}
+ if (auto* space = DynamicTo<MathMLSpaceElement>(*element)) {
+ space->AddMathBaselineIfNeeded(style, state.CssToLengthConversionData());
+ } else if (auto* fraction = DynamicTo<MathMLFractionElement>(*element)) {
+ fraction->AddMathFractionBarThicknessIfNeeded(
+ style, state.CssToLengthConversionData());
+ }
+ if (style.GetWritingMode() != WritingMode::kHorizontalTb) {
+ // TODO(rbuis): this will not work with logical CSS properties.
+ // Disable vertical writing-mode for now.
+ style.SetWritingMode(WritingMode::kHorizontalTb);
+ style.UpdateFontOrientation();
+ }
}
// If this node is sticky it marks the creation of a sticky subtree, which we
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/style_adjuster_test.cc b/chromium/third_party/blink/renderer/core/css/resolver/style_adjuster_test.cc
index f2ed5f9c2df..070db9a01a6 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/style_adjuster_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/style_adjuster_test.cc
@@ -31,13 +31,13 @@ TEST_F(StyleAdjusterTest, TouchActionPropagatedAcrossIframes) {
UpdateAllLifecyclePhasesForTest();
Element* target = ChildDocument().getElementById("target");
- EXPECT_EQ(TouchAction::kTouchActionNone,
+ EXPECT_EQ(TouchAction::kNone,
target->GetComputedStyle()->GetEffectiveTouchAction());
Element* owner = GetDocument().getElementById("owner");
owner->setAttribute(html_names::kStyleAttr, "touch-action: auto");
UpdateAllLifecyclePhasesForTest();
- EXPECT_EQ(TouchAction::kTouchActionPinchZoom,
+ EXPECT_EQ(TouchAction::kPinchZoom,
target->GetComputedStyle()->GetEffectiveTouchAction());
}
@@ -53,7 +53,7 @@ TEST_F(StyleAdjusterTest, TouchActionPanningReEnabledByScrollers) {
UpdateAllLifecyclePhasesForTest();
Element* target = GetDocument().getElementById("target");
- EXPECT_EQ(TouchAction::kTouchActionManipulation,
+ EXPECT_EQ(TouchAction::kManipulation,
target->GetComputedStyle()->GetEffectiveTouchAction());
}
@@ -69,20 +69,20 @@ TEST_F(StyleAdjusterTest, TouchActionPropagatedWhenAncestorStyleChanges) {
UpdateAllLifecyclePhasesForTest();
Element* target = GetDocument().getElementById("target");
- EXPECT_EQ(TouchAction::kTouchActionPanX,
+ EXPECT_EQ(TouchAction::kPanX,
target->GetComputedStyle()->GetEffectiveTouchAction());
Element* ancestor = GetDocument().getElementById("ancestor");
ancestor->setAttribute(html_names::kStyleAttr, "touch-action: pan-y");
UpdateAllLifecyclePhasesForTest();
- EXPECT_EQ(TouchAction::kTouchActionPanY,
+ EXPECT_EQ(TouchAction::kPanY,
target->GetComputedStyle()->GetEffectiveTouchAction());
Element* potential_scroller =
GetDocument().getElementById("potential-scroller");
potential_scroller->setAttribute(html_names::kStyleAttr, "overflow: scroll");
UpdateAllLifecyclePhasesForTest();
- EXPECT_EQ(TouchAction::kTouchActionPan,
+ EXPECT_EQ(TouchAction::kPan,
target->GetComputedStyle()->GetEffectiveTouchAction());
}
@@ -97,13 +97,13 @@ TEST_F(StyleAdjusterTest, TouchActionRestrictedByLowerAncestor) {
UpdateAllLifecyclePhasesForTest();
Element* target = GetDocument().getElementById("target");
- EXPECT_EQ(TouchAction::kTouchActionPanRight,
+ EXPECT_EQ(TouchAction::kPanRight,
target->GetComputedStyle()->GetEffectiveTouchAction());
Element* parent = GetDocument().getElementById("parent");
parent->setAttribute(html_names::kStyleAttr, "touch-action: auto");
UpdateAllLifecyclePhasesForTest();
- EXPECT_EQ(TouchAction::kTouchActionPanX,
+ EXPECT_EQ(TouchAction::kPanX,
target->GetComputedStyle()->GetEffectiveTouchAction());
}
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/style_animator.cc b/chromium/third_party/blink/renderer/core/css/resolver/style_animator.cc
deleted file mode 100644
index c9ebb4db1c5..00000000000
--- a/chromium/third_party/blink/renderer/core/css/resolver/style_animator.cc
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "third_party/blink/renderer/core/css/resolver/style_animator.h"
-
-#include "third_party/blink/renderer/core/animation/css_interpolation_environment.h"
-#include "third_party/blink/renderer/core/animation/css_interpolation_types_map.h"
-#include "third_party/blink/renderer/core/animation/invalidatable_interpolation.h"
-#include "third_party/blink/renderer/core/animation/transition_interpolation.h"
-#include "third_party/blink/renderer/core/css/css_pending_interpolation_value.h"
-#include "third_party/blink/renderer/core/css/properties/longhands/custom_property.h"
-
-namespace blink {
-
-namespace {
-
-PropertyHandle ToPropertyHandle(
- const CSSProperty& property,
- const cssvalue::CSSPendingInterpolationValue& value) {
- if (IsA<CustomProperty>(property))
- return PropertyHandle(property.GetPropertyNameAtomicString());
- return PropertyHandle(property, value.IsPresentationAttribute());
-}
-
-const ActiveInterpolations& GetActiveInterpolations(
- const ActiveInterpolationsMap& animations_map,
- const ActiveInterpolationsMap& transitions_map,
- const PropertyHandle& property) {
- // Interpolations will never be found in both animations_map and
- // transitions_map. This condition is ensured by
- // CSSAnimations::CalculateTransitionUpdateForProperty().
- const auto& animation = animations_map.find(property);
- if (animation != animations_map.end()) {
- DCHECK_EQ(transitions_map.find(property), transitions_map.end());
- return animation->value;
- }
- const auto& transition = transitions_map.find(property);
- DCHECK_NE(transition, transitions_map.end());
- return transition->value;
-}
-
-const ActiveInterpolations& GetActiveInterpolations(
- const CSSAnimationUpdate& update,
- const PropertyHandle& property) {
- if (property.IsCSSCustomProperty()) {
- return GetActiveInterpolations(
- update.ActiveInterpolationsForCustomAnimations(),
- update.ActiveInterpolationsForCustomTransitions(), property);
- }
- return GetActiveInterpolations(
- update.ActiveInterpolationsForStandardAnimations(),
- update.ActiveInterpolationsForStandardTransitions(), property);
-}
-
-} // namespace
-
-StyleAnimator::StyleAnimator(StyleResolverState& state, StyleCascade& cascade)
- : state_(state), cascade_(cascade) {}
-
-void StyleAnimator::Apply(const CSSProperty& property,
- const cssvalue::CSSPendingInterpolationValue& value,
- StyleCascade::Resolver& resolver) {
- PropertyHandle property_handle = ToPropertyHandle(property, value);
- const ActiveInterpolations& interpolations =
- GetActiveInterpolations(state_.AnimationUpdate(), property_handle);
- const Interpolation& interpolation = *interpolations.front();
- if (interpolation.IsInvalidatableInterpolation()) {
- CSSInterpolationTypesMap map(state_.GetDocument().GetPropertyRegistry(),
- state_.GetDocument());
- CSSInterpolationEnvironment environment(map, state_, &cascade_, &resolver);
- InvalidatableInterpolation::ApplyStack(interpolations, environment);
- } else {
- ToTransitionInterpolation(interpolation).Apply(state_);
- }
-}
-
-} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/style_animator.h b/chromium/third_party/blink/renderer/core/css/resolver/style_animator.h
deleted file mode 100644
index 5bcbc7f2c41..00000000000
--- a/chromium/third_party/blink/renderer/core/css/resolver/style_animator.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_STYLE_ANIMATOR_H_
-#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_STYLE_ANIMATOR_H_
-
-#include "third_party/blink/renderer/core/animation/interpolation.h"
-#include "third_party/blink/renderer/core/animation/property_handle.h"
-#include "third_party/blink/renderer/core/css/resolver/style_cascade.h"
-
-namespace blink {
-
-class StyleResolverState;
-class StyleCascade;
-
-namespace cssvalue {
-
-class CSSPendingInterpolationValue;
-
-} // namespace cssvalue
-
-// StyleAnimator is a class which knows how to apply active interpolations
-// for given a CSSProperty.
-//
-// When the set of currently animating properties has been determined,
-// a CSSPendingInterpolationValues is added to the cascade for each animating
-// property (see StyleResolver::CascadeInterpolations). Later, when the
-// cascade is applied, an Animator may be provided. That Animator is then
-// responsible for applying the actual interpolated values represented by
-// any CSSPendingInterpolationValues that may (or may not) remain in the
-// cascade. See StyleCascade::Animator for more information.
-//
-// TODO(crbug.com/985051) Evaluate if there's a performance issue here, and
-// if so possibly store active interpolations directly in the cascade.
-class CORE_EXPORT StyleAnimator : public StyleCascade::Animator {
- STACK_ALLOCATED();
-
- public:
- explicit StyleAnimator(StyleResolverState&, StyleCascade&);
-
- void Apply(const CSSProperty&,
- const cssvalue::CSSPendingInterpolationValue&,
- StyleCascade::Resolver&) override;
-
- private:
- StyleResolverState& state_;
- StyleCascade& cascade_;
-};
-
-} // namespace blink
-
-#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_STYLE_ANIMATOR_H_
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc b/chromium/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc
index fe1a6a2de31..b336c49b015 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc
@@ -52,13 +52,10 @@
#include "third_party/blink/renderer/core/css/css_uri_value.h"
#include "third_party/blink/renderer/core/css/parser/css_tokenizer.h"
#include "third_party/blink/renderer/core/css/resolver/filter_operation_resolver.h"
-#include "third_party/blink/renderer/core/css/resolver/style_resolver_state.h"
#include "third_party/blink/renderer/core/css/resolver/transform_builder.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
-#include "third_party/blink/renderer/core/style/computed_style.h"
-#include "third_party/blink/renderer/core/style/intrinsic_length.h"
#include "third_party/blink/renderer/core/style/reference_clip_path_operation.h"
#include "third_party/blink/renderer/core/style/shape_clip_path_operation.h"
#include "third_party/blink/renderer/core/style/style_svg_resource.h"
@@ -130,7 +127,7 @@ scoped_refptr<StyleSVGResource> StyleBuilderConverter::ConvertElementReference(
return nullptr;
SVGResource* resource =
state.GetElementStyleResources().GetSVGResourceFromValue(
- state.GetTreeScope(), *url_value);
+ state.GetElement().OriginatingTreeScope(), *url_value);
return StyleSVGResource::Create(resource, url_value->ValueForSerialization());
}
@@ -152,7 +149,7 @@ scoped_refptr<ClipPathOperation> StyleBuilderConverter::ConvertClipPath(
if (const auto* url_value = DynamicTo<cssvalue::CSSURIValue>(value)) {
SVGResource* resource =
state.GetElementStyleResources().GetSVGResourceFromValue(
- state.GetTreeScope(), *url_value);
+ state.GetElement().OriginatingTreeScope(), *url_value);
// TODO(fs): Doesn't work with external SVG references (crbug.com/109212.)
return ReferenceClipPathOperation::Create(
url_value->ValueForSerialization(), resource);
@@ -190,8 +187,6 @@ static FontDescription::GenericFamilyType ConvertGenericFamily(
return FontDescription::kFantasyFamily;
case CSSValueID::kMonospace:
return FontDescription::kMonospaceFamily;
- case CSSValueID::kWebkitPictograph:
- return FontDescription::kPictographFamily;
default:
return FontDescription::kNoFamily;
}
@@ -940,28 +935,6 @@ void StyleBuilderConverter::ConvertGridTrackList(
DCHECK(!track_sizes.IsEmpty() || !auto_repeat_track_sizes.IsEmpty());
}
-void StyleBuilderConverter::ConvertOrderedNamedGridLinesMapToNamedGridLinesMap(
- const OrderedNamedGridLines& ordered_named_grid_lines,
- NamedGridLinesMap& named_grid_lines) {
- DCHECK_EQ(named_grid_lines.size(), 0u);
-
- if (ordered_named_grid_lines.size() == 0)
- return;
-
- for (auto& ordered_named_grid_line : ordered_named_grid_lines) {
- for (auto& line_name : ordered_named_grid_line.value) {
- NamedGridLinesMap::AddResult start_result =
- named_grid_lines.insert(line_name, Vector<size_t>());
- start_result.stored_value->value.push_back(ordered_named_grid_line.key);
- }
- }
-
- for (auto& named_grid_line : named_grid_lines) {
- Vector<size_t>& grid_line_indexes = named_grid_line.value;
- std::sort(grid_line_indexes.begin(), grid_line_indexes.end());
- }
-}
-
void StyleBuilderConverter::CreateImplicitNamedGridLinesFromGridArea(
const NamedGridAreaMap& named_grid_areas,
NamedGridLinesMap& named_grid_lines,
@@ -1001,8 +974,13 @@ float StyleBuilderConverter::ConvertBorderWidth(StyleResolverState& state,
return 0;
}
const auto& primitive_value = To<CSSPrimitiveValue>(value);
- return primitive_value.ComputeLength<float>(
- state.CssToLengthConversionData());
+ double result =
+ primitive_value.ComputeLength<float>(state.CssToLengthConversionData());
+ double zoomed_result = state.StyleRef().EffectiveZoom() * result;
+ if (zoomed_result > 0.0 && zoomed_result < 1.0)
+ return 1.0;
+ return clampTo<float>(result, defaultMinimumForClamp<float>(),
+ defaultMaximumForClamp<float>());
}
GapLength StyleBuilderConverter::ConvertGapLength(StyleResolverState& state,
@@ -1089,7 +1067,7 @@ Length StyleBuilderConverter::ConvertLengthMaxSizing(StyleResolverState& state,
const CSSValue& value) {
auto* identifier_value = DynamicTo<CSSIdentifierValue>(value);
if (identifier_value && identifier_value->GetValueID() == CSSValueID::kNone)
- return Length::MaxSizeNone();
+ return Length::None();
return ConvertLengthSizing(state, value);
}
@@ -1683,11 +1661,11 @@ scoped_refptr<ScaleTransformOperation> StyleBuilderConverter::ConvertScale(
RespectImageOrientationEnum StyleBuilderConverter::ConvertImageOrientation(
StyleResolverState& state,
const CSSValue& value) {
+ // The default is kFromImage, so branch on the only other valid value, kNone
auto* identifier_value = DynamicTo<CSSIdentifierValue>(value);
- return identifier_value &&
- identifier_value->GetValueID() == CSSValueID::kFromImage
- ? kRespectImageOrientation
- : kDoNotRespectImageOrientation;
+ return identifier_value && identifier_value->GetValueID() == CSSValueID::kNone
+ ? kDoNotRespectImageOrientation
+ : kRespectImageOrientation;
}
scoped_refptr<StylePath> StyleBuilderConverter::ConvertPathOrNone(
@@ -1861,17 +1839,47 @@ StyleBuilderConverter::CssToLengthConversionData(StyleResolverState& state) {
return state.CssToLengthConversionData();
}
-IntrinsicLength StyleBuilderConverter::ConvertIntrinsicLength(
+LengthSize StyleBuilderConverter::ConvertIntrinsicSize(
StyleResolverState& state,
const CSSValue& value) {
auto* identifier_value = DynamicTo<CSSIdentifierValue>(value);
- if (identifier_value) {
- if (identifier_value->GetValueID() == CSSValueID::kLegacy)
- return IntrinsicLength::MakeLegacy();
- if (identifier_value->GetValueID() == CSSValueID::kAuto)
- return IntrinsicLength::MakeAuto();
- }
- return IntrinsicLength::Make(ConvertLength(state, value));
+ if (identifier_value && identifier_value->GetValueID() == CSSValueID::kAuto)
+ return LengthSize(Length::Auto(), Length::Auto());
+ const CSSValuePair& pair = To<CSSValuePair>(value);
+ Length width = ConvertLength(state, pair.First());
+ Length height = ConvertLength(state, pair.Second());
+ return LengthSize(width, height);
+}
+
+base::Optional<IntSize> StyleBuilderConverter::ConvertAspectRatio(
+ StyleResolverState& state,
+ const CSSValue& value) {
+ auto* identifier_value = DynamicTo<CSSIdentifierValue>(value);
+ if (identifier_value && identifier_value->GetValueID() == CSSValueID::kAuto)
+ return base::nullopt;
+ const CSSValueList& list = To<CSSValueList>(value);
+ DCHECK_EQ(list.length(), 2u);
+ int width = To<CSSPrimitiveValue>(list.Item(0)).GetIntValue();
+ int height = To<CSSPrimitiveValue>(list.Item(1)).GetIntValue();
+ return IntSize(width, height);
+}
+
+bool StyleBuilderConverter::ConvertInternalEmptyLineHeight(
+ StyleResolverState&,
+ const CSSValue& value) {
+ auto* identifier_value = DynamicTo<CSSIdentifierValue>(value);
+ return identifier_value &&
+ identifier_value->GetValueID() == CSSValueID::kFabricated;
+}
+
+AtomicString StyleBuilderConverter::ConvertPage(StyleResolverState& state,
+ const CSSValue& value) {
+ if (auto* custom_ident_value = DynamicTo<CSSCustomIdentValue>(value))
+ return AtomicString(custom_ident_value->Value());
+ DCHECK(DynamicTo<CSSIdentifierValue>(value));
+ DCHECK_EQ(DynamicTo<CSSIdentifierValue>(value)->GetValueID(),
+ CSSValueID::kAuto);
+ return AtomicString();
}
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/style_builder_converter.h b/chromium/third_party/blink/renderer/core/css/resolver/style_builder_converter.h
index f83616b2085..d81b23435e1 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/style_builder_converter.h
+++ b/chromium/third_party/blink/renderer/core/css/resolver/style_builder_converter.h
@@ -36,6 +36,8 @@
#include "third_party/blink/renderer/core/css/css_value_list.h"
#include "third_party/blink/renderer/core/css/css_value_pair.h"
#include "third_party/blink/renderer/core/css/css_variable_data.h"
+#include "third_party/blink/renderer/core/css/resolver/style_resolver_state.h"
+#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/style/grid_area.h"
#include "third_party/blink/renderer/core/style/grid_positions_resolver.h"
#include "third_party/blink/renderer/core/style/named_grid_lines_map.h"
@@ -231,9 +233,6 @@ class StyleBuilderConverter {
const NamedGridAreaMap&,
NamedGridLinesMap&,
GridTrackSizingDirection);
- static void ConvertOrderedNamedGridLinesMapToNamedGridLinesMap(
- const OrderedNamedGridLines&,
- NamedGridLinesMap&);
static cc::ScrollSnapType ConvertSnapType(StyleResolverState&,
const CSSValue&);
@@ -272,8 +271,15 @@ class StyleBuilderConverter {
const CSSValue&,
bool is_animation_tainted);
- static IntrinsicLength ConvertIntrinsicLength(StyleResolverState&,
- const CSSValue&);
+ static LengthSize ConvertIntrinsicSize(StyleResolverState&, const CSSValue&);
+
+ static base::Optional<IntSize> ConvertAspectRatio(StyleResolverState&,
+ const CSSValue&);
+
+ static bool ConvertInternalEmptyLineHeight(StyleResolverState& state,
+ const CSSValue& value);
+
+ static AtomicString ConvertPage(StyleResolverState&, const CSSValue&);
private:
static const CSSToLengthConversionData& CssToLengthConversionData(
@@ -322,7 +328,8 @@ T StyleBuilderConverter::ConvertLineWidth(StyleResolverState& state,
// Reference crbug.com/485650 and crbug.com/382483
double result =
primitive_value.ComputeLength<double>(CssToLengthConversionData(state));
- if (result > 0.0 && result < 1.0)
+ double zoomed_result = state.StyleRef().EffectiveZoom() * result;
+ if (zoomed_result > 0.0 && zoomed_result < 1.0)
return 1.0;
return clampTo<T>(RoundForImpreciseConversion<T>(result),
defaultMinimumForClamp<T>(), defaultMaximumForClamp<T>());
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/style_cascade.cc b/chromium/third_party/blink/renderer/core/css/resolver/style_cascade.cc
index 3b0f06df960..1fc9ecbb274 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/style_cascade.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/style_cascade.cc
@@ -13,7 +13,6 @@
#include "third_party/blink/renderer/core/css/css_custom_property_declaration.h"
#include "third_party/blink/renderer/core/css/css_font_selector.h"
#include "third_party/blink/renderer/core/css/css_invalid_variable_value.h"
-#include "third_party/blink/renderer/core/css/css_pending_interpolation_value.h"
#include "third_party/blink/renderer/core/css/css_pending_substitution_value.h"
#include "third_party/blink/renderer/core/css/css_unset_value.h"
#include "third_party/blink/renderer/core/css/css_variable_data.h"
@@ -24,26 +23,23 @@
#include "third_party/blink/renderer/core/css/properties/css_property.h"
#include "third_party/blink/renderer/core/css/properties/css_property_ref.h"
#include "third_party/blink/renderer/core/css/property_registry.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_expansion.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_interpolations.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_resolver.h"
#include "third_party/blink/renderer/core/css/resolver/css_property_priority.h"
#include "third_party/blink/renderer/core/css/resolver/style_builder.h"
#include "third_party/blink/renderer/core/css/resolver/style_resolver_state.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
+#include "third_party/blink/renderer/core/style_property_shorthand.h"
+#include "third_party/blink/renderer/platform/wtf/math_extras.h"
+#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
namespace blink {
namespace {
-class NullAnimator : public StyleCascade::Animator {
- STACK_ALLOCATED();
-
- public:
- void Apply(const CSSProperty&,
- const cssvalue::CSSPendingInterpolationValue&,
- StyleCascade::Resolver&) override {}
-};
-
AtomicString ConsumeVariableName(CSSParserTokenRange& range) {
range.ConsumeWhitespace();
CSSParserToken ident_token = range.ConsumeIncludingWhitespace();
@@ -66,85 +62,91 @@ const CSSValue* Parse(const CSSProperty& property,
context);
}
-constexpr bool IsImportant(StyleCascade::Origin origin) {
- return static_cast<uint8_t>(origin) & StyleCascade::kImportantBit;
+uint32_t EncodeInterpolationPosition(size_t index,
+ bool is_presentation_attribute) {
+ // Our tests currently expect css properties to win over presentation
+ // attributes. Hence, we borrow a bit in the position-uint32_t for this
+ // purpose.
+ return (static_cast<uint32_t>(!is_presentation_attribute) << 16) |
+ static_cast<uint16_t>(index);
}
-static_assert(!IsImportant(StyleCascade::Origin::kNone),
- "Origin::kNone is not important");
-static_assert(!IsImportant(StyleCascade::Origin::kUserAgent),
- "Origin::kUserAgent is not important");
-static_assert(!IsImportant(StyleCascade::Origin::kUser),
- "Origin::kUser is not important");
-static_assert(!IsImportant(StyleCascade::Origin::kAnimation),
- "Origin::kAnimation is not important");
-static_assert(IsImportant(StyleCascade::Origin::kImportantAuthor),
- "Origin::kImportantAuthor is important");
-static_assert(IsImportant(StyleCascade::Origin::kImportantUser),
- "Origin::kImportantUser is important");
-static_assert(IsImportant(StyleCascade::Origin::kImportantUserAgent),
- "Origin::kImportantUserAgent is important");
-static_assert(!IsImportant(StyleCascade::Origin::kTransition),
- "Origin::kTransition is not important");
-
-} // namespace
+size_t DecodeInterpolationIndex(uint32_t position) {
+ return position & 0xFFFF;
+}
-StyleCascade::Priority::Priority(Origin origin, uint16_t tree_order)
- : priority_((static_cast<uint64_t>(origin) << 32) |
- (static_cast<uint64_t>(tree_order) << 16) |
- StyleCascade::kMaxCascadeOrder) {}
+bool DecodeIsPresentationAttribute(uint32_t position) {
+ return (~position >> 16) & 1;
+}
-StyleCascade::Origin StyleCascade::Priority::GetOrigin() const {
- return static_cast<StyleCascade::Origin>((priority_ >> 32) & 0xFF);
+const CSSValue* ValueAt(const MatchResult& result, uint32_t position) {
+ size_t matched_properties_index = DecodeMatchedPropertiesIndex(position);
+ size_t declaration_index = DecodeDeclarationIndex(position);
+ const MatchedPropertiesVector& vector = result.GetMatchedProperties();
+ const CSSPropertyValueSet* set = vector[matched_properties_index].properties;
+ return &set->PropertyAt(declaration_index).Value();
}
-bool StyleCascade::Priority::operator>=(const Priority& other) const {
- uint64_t important_xor = IsImportant(GetOrigin()) ? 0 : (0xFF << 16);
- return (priority_ ^ important_xor) >= (other.priority_ ^ important_xor);
+PropertyHandle ToPropertyHandle(const CSSProperty& property,
+ CascadePriority priority) {
+ if (IsA<CustomProperty>(property))
+ return PropertyHandle(property.GetPropertyNameAtomicString());
+ uint32_t position = priority.GetPosition();
+ return PropertyHandle(property, DecodeIsPresentationAttribute(position));
}
-void StyleCascade::Add(const CSSPropertyName& name,
- const CSSValue* value,
- Priority priority) {
- auto result = cascade_.insert(name, Value());
- if (priority >= result.stored_value->value.GetPriority()) {
- result.stored_value->value =
- Value(value, priority.WithCascadeOrder(++order_));
- }
+} // namespace
+
+MatchResult& StyleCascade::MutableMatchResult() {
+ needs_match_result_analyze_ = true;
+ return match_result_;
}
-void StyleCascade::Apply() {
- NullAnimator animator;
- Apply(animator);
+void StyleCascade::AddInterpolations(const ActiveInterpolationsMap* map,
+ CascadeOrigin origin) {
+ DCHECK(map);
+ needs_interpolations_analyze_ = true;
+ interpolations_.Add(map, origin);
}
-void StyleCascade::Apply(Animator& animator) {
- Resolver resolver(animator);
+void StyleCascade::Apply(CascadeFilter filter) {
+ AnalyzeIfNeeded();
+
+ CascadeResolver resolver(filter, ++generation_);
+
+ // Affects the computed value of 'color', hence needs to happen before
+ // high-priority properties.
+ LookupAndApply(GetCSSPropertyColorScheme(), resolver);
+
+ ApplyWebkitBorderImage(resolver);
+
+ // -webkit-mask-image needs to be applied before -webkit-mask-composite,
+ // otherwise -webkit-mask-composite has no effect.
+ LookupAndApply(GetCSSPropertyWebkitMaskImage(), resolver);
- // TODO(crbug.com/985031): Set bits ::Add-time to know if we need to do this.
ApplyHighPriority(resolver);
- // TODO(crbug.com/985010): Improve with non-destructive Apply.
- while (!cascade_.IsEmpty()) {
- auto iter = cascade_.begin();
- const CSSPropertyName& name = iter->key;
- Apply(name, resolver);
+ ApplyMatchResult(resolver);
+ ApplyInterpolations(resolver);
+
+ if (map_.Find(CSSPropertyName(CSSPropertyID::kWebkitAppearance)) &&
+ !resolver.filter_.Rejects(GetCSSPropertyWebkitAppearance()) &&
+ state_.Style()->HasAppearance()) {
+ state_.Style()->SetHasAuthorBackground(HasAuthorBackground());
+ state_.Style()->SetHasAuthorBorder(HasAuthorBorder());
}
}
-void StyleCascade::RemoveAnimationPriority() {
- using AnimPrio = CSSPropertyPriorityData<kAnimationPropertyPriority>;
- int first = static_cast<int>(AnimPrio::First());
- int last = static_cast<int>(AnimPrio::Last());
- for (int i = first; i <= last; ++i) {
- CSSPropertyName name(convertToCSSPropertyID(i));
- cascade_.erase(name);
- }
+void StyleCascade::Reset() {
+ map_.Reset();
+ match_result_.Reset();
+ interpolations_.Reset();
+ generation_ = 0;
}
const CSSValue* StyleCascade::Resolve(const CSSPropertyName& name,
const CSSValue& value,
- Resolver& resolver) {
+ CascadeResolver& resolver) {
CSSPropertyRef ref(name, state_.GetDocument());
const CSSValue* resolved = Resolve(ref.GetProperty(), value, resolver);
@@ -157,78 +159,295 @@ const CSSValue* StyleCascade::Resolve(const CSSPropertyName& name,
return resolved;
}
-void StyleCascade::ApplyHighPriority(Resolver& resolver) {
- using HighPriority = CSSPropertyPriorityData<kHighPropertyPriority>;
- int first = static_cast<int>(HighPriority::First());
- int last = static_cast<int>(HighPriority::Last());
- for (int i = first; i <= last; ++i)
- Apply(CSSProperty::Get(convertToCSSPropertyID(i)), resolver);
+void StyleCascade::AnalyzeIfNeeded() {
+ if (needs_match_result_analyze_) {
+ AnalyzeMatchResult();
+ needs_match_result_analyze_ = false;
+ }
+ if (needs_interpolations_analyze_) {
+ AnalyzeInterpolations();
+ needs_interpolations_analyze_ = true;
+ }
+}
+
+void StyleCascade::AnalyzeMatchResult() {
+ for (auto e : match_result_.Expansions(GetDocument(), CascadeFilter())) {
+ for (; !e.AtEnd(); e.Next())
+ map_.Add(e.Name(), e.Priority());
+ }
+}
+
+void StyleCascade::AnalyzeInterpolations() {
+ const auto& entries = interpolations_.GetEntries();
+ for (size_t i = 0; i < entries.size(); ++i) {
+ for (const auto& active_interpolation : *entries[i].map) {
+ uint32_t position = EncodeInterpolationPosition(
+ i, active_interpolation.key.IsPresentationAttribute());
+ CascadePriority priority(entries[i].origin, false, 0, position);
+
+ auto name = active_interpolation.key.GetCSSPropertyName();
+ CSSPropertyRef ref(name, GetDocument());
+ DCHECK(ref.IsValid());
+ const CSSProperty& property = ref.GetProperty();
+
+ map_.Add(name, priority);
+
+ // Since an interpolation for an unvisited property also causes an
+ // interpolation of the visited property, add the visited property to
+ // the map as well.
+ // TODO(crbug.com/1062217): Interpolate visited colors separately
+ if (const CSSProperty* visited = property.GetVisitedProperty())
+ map_.Add(visited->GetCSSPropertyName(), priority);
+ }
+ }
+}
+
+void StyleCascade::ApplyHighPriority(CascadeResolver& resolver) {
+ uint64_t bits = map_.HighPriorityBits();
- state_.GetFontBuilder().CreateFont(
- state_.GetDocument().GetStyleEngine().GetFontSelector(),
- state_.StyleRef());
+ if (bits) {
+ using HighPriority = CSSPropertyPriorityData<kHighPropertyPriority>;
+ int first = static_cast<int>(HighPriority::First());
+ int last = static_cast<int>(HighPriority::Last());
+ for (int i = first; i <= last; ++i) {
+ if (bits & (static_cast<uint64_t>(1) << i))
+ LookupAndApply(CSSProperty::Get(convertToCSSPropertyID(i)), resolver);
+ }
+ }
+
+ state_.GetFontBuilder().CreateFont(state_.StyleRef(), state_.ParentStyle());
state_.SetConversionFontSizes(CSSToLengthConversionData::FontSizes(
state_.Style(), state_.RootElementStyle()));
state_.SetConversionZoom(state_.Style()->EffectiveZoom());
+
+ // Force color-scheme sensitive initial color for the document element,
+ // if no value is present in the cascade.
+ //
+ // TODO(crbug.com/1046753): This should be unnecessary when canvastext is
+ // supported.
+ uint64_t color_bit = 1ull << static_cast<uint64_t>(CSSPropertyID::kColor);
+ if (~bits & color_bit) {
+ if (state_.GetElement() == GetDocument().documentElement())
+ state_.Style()->SetColor(state_.Style()->InitialColorForColorScheme());
+ }
}
-void StyleCascade::Apply(const CSSPropertyName& name) {
- NullAnimator animator;
- Resolver resolver(animator);
- Apply(name, resolver);
+void StyleCascade::ApplyWebkitBorderImage(CascadeResolver& resolver) {
+ const CascadePriority* priority =
+ map_.Find(CSSPropertyName(CSSPropertyID::kWebkitBorderImage));
+ if (!priority)
+ return;
+
+ // -webkit-border-image is a surrogate for the border-image (shorthand).
+ // By applying -webkit-border-image first, we avoid having to "partially"
+ // apply -webkit-border-image depending on the border-image-* longhands that
+ // have already been applied.
+ // See also crbug.com/1056600
+ LookupAndApply(GetCSSPropertyWebkitBorderImage(), resolver);
+
+ const auto& shorthand = borderImageShorthand();
+ const CSSProperty** longhands = shorthand.properties();
+ for (unsigned i = 0; i < shorthand.length(); ++i) {
+ const CSSProperty& longhand = *longhands[i];
+ if (CascadePriority* p = map_.Find(longhand.GetCSSPropertyName())) {
+ // If -webkit-border-image has higher priority than a border-image
+ // longhand, we skip applying that longhand.
+ if (*p < *priority)
+ *p = CascadePriority(*p, resolver.generation_);
+ }
+ }
}
-void StyleCascade::Apply(const CSSPropertyName& name, Resolver& resolver) {
- CSSPropertyRef ref(name, state_.GetDocument());
- DCHECK(ref.IsValid());
- Apply(ref.GetProperty(), resolver);
+void StyleCascade::ApplyMatchResult(CascadeResolver& resolver) {
+ for (auto e : match_result_.Expansions(GetDocument(), resolver.filter_)) {
+ for (; !e.AtEnd(); e.Next()) {
+ auto priority = CascadePriority(e.Priority(), resolver.generation_);
+ CascadePriority* p = map_.Find(e.Name());
+ if (!p || *p >= priority)
+ continue;
+ *p = priority;
+ const CSSProperty& property = e.Property();
+ if (property.IsSurrogate()) {
+ ApplySurrogate(property, priority, resolver);
+ continue;
+ }
+ const CSSValue* value = Resolve(property, e.Value(), resolver);
+ StyleBuilder::ApplyProperty(property, state_, *value);
+ }
+ }
}
-void StyleCascade::Apply(const CSSProperty& property, Resolver& resolver) {
- CSSPropertyName name = property.GetCSSPropertyName();
+void StyleCascade::ApplyInterpolations(CascadeResolver& resolver) {
+ const auto& entries = interpolations_.GetEntries();
+ for (size_t i = 0; i < entries.size(); ++i) {
+ const auto& entry = entries[i];
+ ApplyInterpolationMap(*entry.map, entry.origin, i, resolver);
+ }
+}
- DCHECK(!resolver.IsLocked(name));
+void StyleCascade::ApplyInterpolationMap(const ActiveInterpolationsMap& map,
+ CascadeOrigin origin,
+ size_t index,
+ CascadeResolver& resolver) {
+ for (const auto& entry : map) {
+ auto name = entry.key.GetCSSPropertyName();
+ uint32_t position =
+ EncodeInterpolationPosition(index, entry.key.IsPresentationAttribute());
+ CascadePriority priority(origin, false, 0, position);
+ priority = CascadePriority(priority, resolver.generation_);
+
+ CSSPropertyRef ref(name, GetDocument());
+ const CSSProperty& property = ref.GetProperty();
+ if (resolver.filter_.Rejects(property))
+ continue;
+
+ CascadePriority* p = map_.Find(name);
+ if (!p || *p >= priority) {
+ if (p->IsImportant())
+ state_.SetHasImportantOverrides();
+ continue;
+ }
+ *p = priority;
- Value cascaded = cascade_.Take(property.GetCSSPropertyName());
- if (cascaded.IsEmpty())
- return;
+ if (property.IsSurrogate()) {
+ ApplySurrogate(property, priority, resolver);
+ continue;
+ }
- const CSSValue* value = cascaded.GetValue();
+ ApplyInterpolation(property, priority, entry.value, resolver);
+ }
+}
- if (const auto* v =
- DynamicTo<cssvalue::CSSPendingInterpolationValue>(value)) {
- resolver.animator_.Apply(property, *v, resolver);
- return;
+void StyleCascade::ApplyInterpolation(
+ const CSSProperty& property,
+ CascadePriority priority,
+ const ActiveInterpolations& interpolations,
+ CascadeResolver& resolver) {
+ const Interpolation& interpolation = *interpolations.front();
+ if (IsA<InvalidatableInterpolation>(interpolation)) {
+ CSSInterpolationTypesMap map(state_.GetDocument().GetPropertyRegistry(),
+ state_.GetDocument());
+ CSSInterpolationEnvironment environment(map, state_, this, &resolver);
+ InvalidatableInterpolation::ApplyStack(interpolations, environment);
+ } else {
+ To<TransitionInterpolation>(interpolation).Apply(state_);
}
- value = Resolve(property, *value, resolver);
+ if (property.AffectsFont())
+ state_.SetHasFontAffectingAnimation();
- DCHECK(!value->IsVariableReferenceValue());
- DCHECK(!value->IsPendingSubstitutionValue());
- DCHECK(!value->IsPendingInterpolationValue());
+ // Applying a color property interpolation will also unconditionally apply
+ // the -internal-visited- counterpart (see CSSColorInterpolationType::
+ // ApplyStandardPropertyValue). To make sure !important rules in :visited
+ // selectors win over animations, we re-apply the -internal-visited property
+ // if its priority is higher.
+ //
+ // TODO(crbug.com/1062217): Interpolate visited colors separately
+ if (const CSSProperty* visited = property.GetVisitedProperty()) {
+ CascadePriority* visited_priority =
+ map_.Find(visited->GetCSSPropertyName());
+ if (visited_priority && priority < *visited_priority) {
+ DCHECK(visited_priority->IsImportant());
+ state_.SetHasImportantOverrides();
+ // Resetting generation to zero makes it possible to apply the
+ // visited property again.
+ *visited_priority = CascadePriority(*visited_priority, 0);
+ LookupAndApply(*visited, resolver);
+ }
+ }
+}
+
+void StyleCascade::ApplySurrogate(const CSSProperty& surrogate,
+ CascadePriority surrogate_priority,
+ CascadeResolver& resolver) {
+ DCHECK(surrogate.IsSurrogate());
+
+ const CSSProperty& original = SurrogateFor(surrogate);
+ CascadePriority* original_priority = map_.Find(original.GetCSSPropertyName());
+
+ if (original_priority) {
+ if (surrogate_priority < *original_priority) {
+ // The original has a higher priority, so skip the surrogate property.
+ return;
+ }
- if (!resolver.filter_.Add(property, cascaded))
+ // The surrogate has a higher priority, so skip the original property.
+ // The original might have been applied already, but that doesn't matter,
+ // as we're about to overwrite it.
+ resolver.MarkApplied(original_priority);
+ }
+
+ LookupAndApplyValue(surrogate, surrogate_priority, resolver);
+}
+
+void StyleCascade::LookupAndApply(const CSSPropertyName& name,
+ CascadeResolver& resolver) {
+ CSSPropertyRef ref(name, state_.GetDocument());
+ DCHECK(ref.IsValid());
+ LookupAndApply(ref.GetProperty(), resolver);
+}
+
+void StyleCascade::LookupAndApply(const CSSProperty& property,
+ CascadeResolver& resolver) {
+ CSSPropertyName name = property.GetCSSPropertyName();
+ DCHECK(!resolver.IsLocked(name));
+
+ CascadePriority* p = map_.Find(name);
+ if (!p)
return;
+ CascadePriority priority(*p, resolver.generation_);
+ if (*p >= priority)
+ return;
+ *p = priority;
- StyleBuilder::ApplyProperty(property, state_, *value);
+ if (resolver.filter_.Rejects(property))
+ return;
+ if (property.IsSurrogate()) {
+ ApplySurrogate(property, priority, resolver);
+ return;
+ }
+
+ LookupAndApplyValue(property, priority, resolver);
}
-bool StyleCascade::HasValue(const CSSPropertyName& name,
- const CSSValue* value) const {
- auto iter = cascade_.find(name);
- return (iter != cascade_.end()) && (iter->value.GetValue() == value);
+void StyleCascade::LookupAndApplyValue(const CSSProperty& property,
+ CascadePriority priority,
+ CascadeResolver& resolver) {
+ if (priority.GetOrigin() < CascadeOrigin::kAnimation)
+ LookupAndApplyDeclaration(property, priority, resolver);
+ else if (priority.GetOrigin() >= CascadeOrigin::kAnimation)
+ LookupAndApplyInterpolation(property, priority, resolver);
}
-const CSSValue* StyleCascade::GetValue(const CSSPropertyName& name) const {
- auto iter = cascade_.find(name);
- return (iter != cascade_.end()) ? iter->value.GetValue() : nullptr;
+void StyleCascade::LookupAndApplyDeclaration(const CSSProperty& property,
+ CascadePriority priority,
+ CascadeResolver& resolver) {
+ DCHECK(priority.GetOrigin() < CascadeOrigin::kAnimation);
+ const CSSValue* value = ValueAt(match_result_, priority.GetPosition());
+ DCHECK(value);
+ value = Resolve(property, *value, resolver);
+ DCHECK(!value->IsVariableReferenceValue());
+ DCHECK(!value->IsPendingSubstitutionValue());
+ StyleBuilder::ApplyProperty(property, state_, *value);
}
-void StyleCascade::ReplaceValue(const CSSPropertyName& name,
- const CSSValue* value) {
- auto iter = cascade_.find(name);
- if (iter != cascade_.end())
- iter->value = Value(value, iter->value.GetPriority());
+void StyleCascade::LookupAndApplyInterpolation(const CSSProperty& property,
+ CascadePriority priority,
+ CascadeResolver& resolver) {
+ // Interpolations for -internal-visited properties are applied via the
+ // interpolation for the main (unvisited) property, so we don't need to
+ // apply it twice.
+ // TODO(crbug.com/1062217): Interpolate visited colors separately
+ if (property.IsVisited())
+ return;
+ DCHECK(priority.GetOrigin() >= CascadeOrigin::kAnimation);
+ size_t index = DecodeInterpolationIndex(priority.GetPosition());
+ DCHECK_LE(index, interpolations_.GetEntries().size());
+ const ActiveInterpolationsMap& map = *interpolations_.GetEntries()[index].map;
+ PropertyHandle handle = ToPropertyHandle(property, priority);
+ const auto& entry = map.find(handle);
+ DCHECK_NE(entry, map.end());
+ ApplyInterpolation(property, priority, entry->value, resolver);
}
bool StyleCascade::IsRootElement() const {
@@ -274,7 +493,7 @@ StyleCascade::TokenSequence::BuildVariableData() {
const CSSValue* StyleCascade::Resolve(const CSSProperty& property,
const CSSValue& value,
- Resolver& resolver) {
+ CascadeResolver& resolver) {
if (const auto* v = DynamicTo<CSSCustomPropertyDeclaration>(value))
return ResolveCustomProperty(property, *v, resolver);
if (const auto* v = DynamicTo<CSSVariableReferenceValue>(value))
@@ -287,9 +506,9 @@ const CSSValue* StyleCascade::Resolve(const CSSProperty& property,
const CSSValue* StyleCascade::ResolveCustomProperty(
const CSSProperty& property,
const CSSCustomPropertyDeclaration& decl,
- Resolver& resolver) {
+ CascadeResolver& resolver) {
DCHECK(!resolver.IsLocked(property));
- AutoLock lock(property, resolver);
+ CascadeResolver::AutoLock lock(property, resolver);
// TODO(andruud): Don't transport css-wide keywords in this value.
if (!decl.Value())
@@ -306,15 +525,8 @@ const CSSValue* StyleCascade::ResolveCustomProperty(
if (resolver.InCycle())
return CSSInvalidVariableValue::Create();
- if (!data) {
- // TODO(crbug.com/980930): Treat custom properties as unset here,
- // not invalid. This behavior is enforced by WPT, but violates the spec.
- if (const auto* custom_property = DynamicTo<CustomProperty>(property)) {
- if (!custom_property->IsRegistered())
- return CSSInvalidVariableValue::Create();
- }
+ if (!data)
return cssvalue::CSSUnsetValue::Create();
- }
if (data == decl.Value())
return &decl;
@@ -326,13 +538,15 @@ const CSSValue* StyleCascade::ResolveCustomProperty(
const CSSValue* StyleCascade::ResolveVariableReference(
const CSSProperty& property,
const CSSVariableReferenceValue& value,
- Resolver& resolver) {
+ CascadeResolver& resolver) {
DCHECK(!resolver.IsLocked(property));
- AutoLock lock(property, resolver);
+ CascadeResolver::AutoLock lock(property, resolver);
const CSSVariableData* data = value.VariableDataValue();
const CSSParserContext* context = GetParserContext(value);
+ MarkHasVariableReference(property);
+
DCHECK(data);
DCHECK(context);
@@ -349,31 +563,46 @@ const CSSValue* StyleCascade::ResolveVariableReference(
const CSSValue* StyleCascade::ResolvePendingSubstitution(
const CSSProperty& property,
const cssvalue::CSSPendingSubstitutionValue& value,
- Resolver& resolver) {
+ CascadeResolver& resolver) {
DCHECK(!resolver.IsLocked(property));
- AutoLock lock(property, resolver);
+ CascadeResolver::AutoLock lock(property, resolver);
+ CascadePriority priority = map_.At(property.GetCSSPropertyName());
DCHECK_NE(property.PropertyID(), CSSPropertyID::kVariable);
+ DCHECK_NE(priority.GetOrigin(), CascadeOrigin::kNone);
- CSSVariableReferenceValue* shorthand_value = value.ShorthandValue();
- const auto* shorthand_data = shorthand_value->VariableDataValue();
- CSSPropertyID shorthand_property_id = value.ShorthandPropertyId();
+ MarkHasVariableReference(property);
- TokenSequence sequence;
+ // If the previous call to ResolvePendingSubstitution parsed 'value', then
+ // we don't need to do it again.
+ bool is_cached = resolver.shorthand_cache_.value == &value;
- if (!ResolveTokensInto(shorthand_data->Tokens(), resolver, sequence))
- return cssvalue::CSSUnsetValue::Create();
+ if (!is_cached) {
+ CSSVariableReferenceValue* shorthand_value = value.ShorthandValue();
+ const auto* shorthand_data = shorthand_value->VariableDataValue();
+ CSSPropertyID shorthand_property_id = value.ShorthandPropertyId();
- HeapVector<CSSPropertyValue, 256> parsed_properties;
- const bool important = false;
+ TokenSequence sequence;
- if (!CSSPropertyParser::ParseValue(
- shorthand_property_id, important, sequence.TokenRange(),
- shorthand_value->ParserContext(), parsed_properties,
- StyleRule::RuleType::kStyle)) {
- return cssvalue::CSSUnsetValue::Create();
+ if (!ResolveTokensInto(shorthand_data->Tokens(), resolver, sequence))
+ return cssvalue::CSSUnsetValue::Create();
+
+ HeapVector<CSSPropertyValue, 256> parsed_properties;
+ const bool important = false;
+
+ if (!CSSPropertyParser::ParseValue(
+ shorthand_property_id, important, sequence.TokenRange(),
+ shorthand_value->ParserContext(), parsed_properties,
+ StyleRule::RuleType::kStyle)) {
+ return cssvalue::CSSUnsetValue::Create();
+ }
+
+ resolver.shorthand_cache_.value = &value;
+ resolver.shorthand_cache_.parsed_properties = std::move(parsed_properties);
}
+ const auto& parsed_properties = resolver.shorthand_cache_.parsed_properties;
+
// For -internal-visited-properties with CSSPendingSubstitutionValues,
// the inner 'shorthand_property_id' will expand to a set of longhands
// containing the unvisited equivalent. Hence, when parsing the
@@ -382,27 +611,22 @@ const CSSValue* StyleCascade::ResolvePendingSubstitution(
const CSSProperty* unvisited_property =
property.IsVisited() ? property.GetUnvisitedProperty() : &property;
- const CSSValue* result = nullptr;
-
unsigned parsed_properties_count = parsed_properties.size();
for (unsigned i = 0; i < parsed_properties_count; ++i) {
const CSSProperty& longhand = CSSProperty::Get(parsed_properties[i].Id());
- const CSSPropertyName& name = longhand.GetCSSPropertyName();
const CSSValue* parsed = parsed_properties[i].Value();
if (unvisited_property == &longhand)
- result = parsed;
- else if (HasValue(name, &value))
- ReplaceValue(name, parsed);
+ return parsed;
}
- DCHECK(result);
- return result;
+ NOTREACHED();
+ return cssvalue::CSSUnsetValue::Create();
}
scoped_refptr<CSSVariableData> StyleCascade::ResolveVariableData(
CSSVariableData* data,
- Resolver& resolver) {
+ CascadeResolver& resolver) {
DCHECK(data && data->NeedsVariableResolution());
TokenSequence sequence(data);
@@ -414,7 +638,7 @@ scoped_refptr<CSSVariableData> StyleCascade::ResolveVariableData(
}
bool StyleCascade::ResolveTokensInto(CSSParserTokenRange range,
- Resolver& resolver,
+ CascadeResolver& resolver,
TokenSequence& out) {
bool success = true;
while (!range.AtEnd()) {
@@ -430,7 +654,7 @@ bool StyleCascade::ResolveTokensInto(CSSParserTokenRange range,
}
bool StyleCascade::ResolveVarInto(CSSParserTokenRange range,
- Resolver& resolver,
+ CascadeResolver& resolver,
TokenSequence& out) {
AtomicString variable_name = ConsumeVariableName(range);
DCHECK(range.AtEnd() || (range.Peek().GetType() == kCommaToken));
@@ -440,7 +664,7 @@ bool StyleCascade::ResolveVarInto(CSSParserTokenRange range,
// Any custom property referenced (by anything, even just once) in the
// document can currently not be animated on the compositor. Hence we mark
// properties that have been referenced.
- MarkReferenced(property);
+ MarkIsReferenced(property);
if (!resolver.DetectCycle(property)) {
// We are about to substitute var(property). In order to do that, we must
@@ -449,7 +673,7 @@ bool StyleCascade::ResolveVarInto(CSSParserTokenRange range,
// We can however not do this if we're in a cycle. If a cycle is detected
// here, it means we are already resolving 'property', and have discovered
// a reference to 'property' during that resolution.
- Apply(property, resolver);
+ LookupAndApply(property, resolver);
}
// Note that even if we are in a cycle, we must proceed in order to discover
@@ -492,7 +716,7 @@ bool StyleCascade::ResolveVarInto(CSSParserTokenRange range,
}
bool StyleCascade::ResolveEnvInto(CSSParserTokenRange range,
- Resolver& resolver,
+ CascadeResolver& resolver,
TokenSequence& out) {
AtomicString variable_name = ConsumeVariableName(range);
DCHECK(range.AtEnd() || (range.Peek().GetType() == kCommaToken));
@@ -561,87 +785,70 @@ bool StyleCascade::ValidateFallback(const CustomProperty& property,
return property.ParseSingleValue(range, *context, local_context);
}
-void StyleCascade::MarkReferenced(const CustomProperty& property) {
- if (!property.IsInherited())
- state_.Style()->SetHasVariableReferenceFromNonInheritedProperty();
+void StyleCascade::MarkIsReferenced(const CustomProperty& property) {
if (!property.IsRegistered())
return;
const AtomicString& name = property.GetPropertyNameAtomicString();
state_.GetDocument().GetPropertyRegistry()->MarkReferenced(name);
}
-bool StyleCascade::Filter::Add(const CSSProperty& property,
- const Value& value) {
- Priority& slot = GetSlot(property);
- if (value.GetPriority() >= slot) {
- slot = value.GetPriority();
- return true;
- }
- return false;
-}
-
-StyleCascade::Priority& StyleCascade::Filter::GetSlot(
- const CSSProperty& property) {
- // TODO(crbug.com/985043): Ribbonize?
- switch (property.PropertyID()) {
- case CSSPropertyID::kWritingMode:
- case CSSPropertyID::kWebkitWritingMode:
- return writing_mode_;
- case CSSPropertyID::kZoom:
- case CSSPropertyID::kInternalEffectiveZoom:
- return zoom_;
- default:
- none_ = Priority();
- return none_;
- }
-}
-
-bool StyleCascade::Resolver::IsLocked(const CSSProperty& property) const {
- return IsLocked(property.GetCSSPropertyName());
-}
-
-bool StyleCascade::Resolver::IsLocked(const CSSPropertyName& name) const {
- return stack_.Contains(name);
-}
-
-bool StyleCascade::Resolver::AllowSubstitution(CSSVariableData* data) const {
- if (data && data->IsAnimationTainted() && stack_.size()) {
- const CSSPropertyName& name = stack_.back();
- if (name.IsCustomProperty())
- return true;
- const CSSProperty& property = CSSProperty::Get(name.Id());
- return !CSSAnimations::IsAnimationAffectingProperty(property);
- }
- return true;
-}
-
-bool StyleCascade::Resolver::DetectCycle(const CSSProperty& property) {
- wtf_size_t index = stack_.Find(property.GetCSSPropertyName());
- if (index == kNotFound)
- return false;
- cycle_depth_ = std::min(cycle_depth_, index);
- return true;
-}
-
-bool StyleCascade::Resolver::InCycle() const {
- return cycle_depth_ != kNotFound;
-}
-
-StyleCascade::AutoLock::AutoLock(const CSSProperty& property,
- Resolver& resolver)
- : AutoLock(property.GetCSSPropertyName(), resolver) {}
-
-StyleCascade::AutoLock::AutoLock(const CSSPropertyName& name,
- Resolver& resolver)
- : resolver_(resolver) {
- DCHECK(!resolver.IsLocked(name));
- resolver_.stack_.push_back(name);
+void StyleCascade::MarkHasVariableReference(const CSSProperty& property) {
+ if (!property.IsInherited())
+ state_.Style()->SetHasVariableReferenceFromNonInheritedProperty();
}
-StyleCascade::AutoLock::~AutoLock() {
- resolver_.stack_.pop_back();
- if (resolver_.stack_.size() <= resolver_.cycle_depth_)
- resolver_.cycle_depth_ = kNotFound;
+const Document& StyleCascade::GetDocument() const {
+ return state_.GetDocument();
+}
+
+const CSSProperty& StyleCascade::SurrogateFor(
+ const CSSProperty& surrogate) const {
+ DCHECK(surrogate.IsSurrogate());
+ const CSSProperty* original = surrogate.SurrogateFor(
+ state_.Style()->Direction(), state_.Style()->GetWritingMode());
+ DCHECK(original);
+ return *original;
+}
+
+bool StyleCascade::HasAuthorDeclaration(const CSSProperty& property) const {
+ return map_.At(property.GetCSSPropertyName()).GetOrigin() ==
+ CascadeOrigin::kAuthor;
+}
+
+bool StyleCascade::HasAuthorBorder() const {
+ return HasAuthorDeclaration(GetCSSPropertyBorderBottomColor()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderBottomLeftRadius()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderBottomRightRadius()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderBottomStyle()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderBottomWidth()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderImageOutset()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderImageRepeat()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderImageSlice()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderImageSource()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderImageWidth()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderLeftColor()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderLeftStyle()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderLeftWidth()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderRightColor()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderRightStyle()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderRightWidth()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderTopColor()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderTopLeftRadius()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderTopRightRadius()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderTopStyle()) ||
+ HasAuthorDeclaration(GetCSSPropertyBorderTopWidth());
+}
+
+bool StyleCascade::HasAuthorBackground() const {
+ return HasAuthorDeclaration(GetCSSPropertyBackgroundAttachment()) ||
+ HasAuthorDeclaration(GetCSSPropertyBackgroundBlendMode()) ||
+ HasAuthorDeclaration(GetCSSPropertyBackgroundClip()) ||
+ HasAuthorDeclaration(GetCSSPropertyBackgroundColor()) ||
+ HasAuthorDeclaration(GetCSSPropertyBackgroundImage()) ||
+ HasAuthorDeclaration(GetCSSPropertyBackgroundOrigin()) ||
+ HasAuthorDeclaration(GetCSSPropertyBackgroundPositionX()) ||
+ HasAuthorDeclaration(GetCSSPropertyBackgroundPositionY()) ||
+ HasAuthorDeclaration(GetCSSPropertyBackgroundSize());
}
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/style_cascade.h b/chromium/third_party/blink/renderer/core/css/resolver/style_cascade.h
index d6cbce28d14..5b4fe46d901 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/style_cascade.h
+++ b/chromium/third_party/blink/renderer/core/css/resolver/style_cascade.h
@@ -5,15 +5,27 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_STYLE_CASCADE_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_STYLE_CASCADE_H_
+#include "third_party/blink/renderer/core/animation/interpolation.h"
+#include "third_party/blink/renderer/core/css/css_property_id_templates.h"
#include "third_party/blink/renderer/core/css/css_property_name.h"
+#include "third_party/blink/renderer/core/css/css_property_value.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_token.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_token_range.h"
+#include "third_party/blink/renderer/core/css/properties/css_property.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_filter.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_interpolations.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_map.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_origin.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_priority.h"
+#include "third_party/blink/renderer/core/css/resolver/match_result.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/text/text_encoding.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink {
+class CascadeInterpolations;
+class CascadeResolver;
class CSSCustomPropertyDeclaration;
class CSSParserContext;
class CSSProperty;
@@ -21,335 +33,76 @@ class CSSValue;
class CSSVariableData;
class CSSVariableReferenceValue;
class CustomProperty;
+class MatchResult;
class StyleResolverState;
namespace cssvalue {
class CSSPendingSubstitutionValue;
-class CSSPendingInterpolationValue;
} // namespace cssvalue
-// The StyleCascade is responsible for managing cascaded values [1], resolving
-// dependencies between them, and applying the values to the ComputedStyle.
+// StyleCascade analyzes declarations provided by CSS rules and animations,
+// and figures out which declarations should be skipped, and which should be
+// applied (and in which order).
//
-// Its usage pattern is:
-//
-// const CSSPropertyName& name = ...;
-// const CSSValue* value1 = ...;
-// const CSSValue* value2 = ...;
+// Usage:
//
// StyleCascade cascade(state);
-// cascade.Add(name, value1, Priority(Origin::kAuthor));
-// cascade.Add(name, value2, Priority(Origin::kUA));
-// cascade.Apply(); // value1 is applied, value2 is ignored.
+// cascade.MutableMatchResult().AddMatchedProperties(...matched rule...);
+// cascade.MutableMatchResult().AddMatchedProperties(...another rule...);
+// cascade.AddInterpolation(...); // Optional
+// cascade.Apply();
//
// [1] https://drafts.csswg.org/css-cascade/#cascade
class CORE_EXPORT StyleCascade {
STACK_ALLOCATED();
using CSSPendingSubstitutionValue = cssvalue::CSSPendingSubstitutionValue;
- using CSSPendingInterpolationValue = cssvalue::CSSPendingInterpolationValue;
public:
- class Animator;
- class Resolver;
- class AutoLock;
-
StyleCascade(StyleResolverState& state) : state_(state) {}
- static constexpr uint16_t kMaxCascadeOrder = ~static_cast<uint16_t>(0);
-
- // Represents the origin and importance criteria described by css-cascade [1].
- //
- // Higher values are more significant than lower values. The values are
- // chosen such that an important origin can be produced by inverting the bits
- // of the corresponding non-important origin.
- //
- // [1] https://www.w3.org/TR/css-cascade-3/#cascade-origin
- enum class Origin : uint8_t {
- kNone = 0,
- kUserAgent = 0b0001,
- kUser = 0b0010,
- kAuthor = 0b0011,
- kAnimation = 0b0100,
- kImportantAuthor = 0b1100,
- kImportantUser = 0b1101,
- kImportantUserAgent = 0b1110,
- kTransition = 0b10000,
- };
-
- // All important Origins (and only those) must have this bit set. This
- // provides a fast way to check if an Origin is important.
- static constexpr uint8_t kImportantBit = 0b1000;
+ const MatchResult& GetMatchResult() { return match_result_; }
- // The Priority class encapsulates a subset of the cascading criteria
- // described by css-cascade [1], and provides a way to compare priorities.
- //
- // It encompasses, from most significant to least significant: Origin (which
- // includes importance); tree order, which is a number representing the
- // shadow-including tree order [2]; and finally cascade order, which is
- // a monotonically increasing number increased by one every time something
- // is added to the cascade.
+ // Access the MatchResult in order to add declarations to it.
+ // The modifications made will be taken into account during the next call to
+ // Apply.
//
- // The cascade order is initially kMaxCascadeOrder for an instance of
- // Priority; an actual value will be assigned by StyleCascade::Add.
- //
- // [1] https://drafts.csswg.org/css-cascade/#cascading
- // [2] https://drafts.csswg.org/css-scoping/#shadow-cascading
- class CORE_EXPORT Priority {
- DISALLOW_NEW();
-
- public:
- Priority() : Priority(Origin::kNone) {}
- // Deliberately implicit.
- Priority(Origin origin) : Priority(origin, 0) {}
- // For an explanation of 'tree_order', see css-scoping [1].
- // [1] https://drafts.csswg.org/css-scoping/#shadow-cascading
- Priority(Origin, uint16_t tree_order);
-
- Origin GetOrigin() const;
- bool HasOrigin() const { return GetOrigin() != Origin::kNone; }
-
- // This function is used to determine if an incoming Value should win
- // over the Value which already exists in the cascade.
- bool operator>=(const Priority&) const;
-
- // Returns a copy of this Priority, except that the non-important origin
- // has been converted to its important counterpart.
- //
- // Must be used with kUserAgent, kAuthor, and kAuthor only, as importance
- // does not apply to the other origins.
- //
- // https://drafts.csswg.org/css-cascade/#important
- inline Priority AddImportance() const {
- DCHECK_GE(GetOrigin(), Origin::kUserAgent);
- DCHECK_LE(GetOrigin(), Origin::kAuthor);
- // Flip Origin bits, converting non-important to important. We only
- // xor four bits here, because only those bits are in use by
- // k[Important,][User,UserAgent,Author].
- return Priority(priority_ ^ (static_cast<uint64_t>(0b1111) << 32));
- }
-
- private:
- friend class StyleCascade;
- friend class StyleCascadeTest;
-
- Priority(uint64_t priority) : priority_(priority) {}
-
- // Returns a copy of this Priority, with the cascade order set to the
- // specified value.
- //
- // For the purposes of StyleCascade::Add alone, we don't need to store the
- // cascade order at all, since the cascade order is implicit in the order
- // of the calls to ::Add. However, some properties unfortunately require
- // that we store the cascade order and act upon it Apply-time. This is
- // because we have multiple properties that mutate the same field on
- // ComputedStyle, hence the relative ordering must be preserved between
- // them to know which should be applied. (See class Filter).
- inline Priority WithCascadeOrder(uint16_t cascade_order) const {
- return Priority((priority_ & ~0xFFFF) | cascade_order);
- }
-
- // To make Priority comparisons fast, the origin, tree_order and
- // cascade_order are stored in a single uint64_t, as follows:
- //
- // Bit 0-15: cascade_order
- // Bit 16-31: tree_order
- // Bit 32-39: Origin
- //
- // This way, the numeric value of priority_ can be compared directly
- // for all criteria simultaneously.
- uint64_t priority_;
- };
-
- // The Value class simply represents the data we store for each property
- // in the cascade. See StyleCascade::cascade_ field.
- class CORE_EXPORT Value {
- DISALLOW_NEW();
-
- public:
- // The empty Value is needed because we store it in a HashMap.
- Value() = default;
- Value(const CSSValue* value, Priority priority)
- : value_(value), priority_(priority) {}
- bool IsEmpty() const { return !priority_.HasOrigin(); }
- const CSSValue* GetValue() const { return value_; }
- const Priority& GetPriority() const { return priority_; }
- void Trace(blink::Visitor* visitor) { visitor->Trace(value_); }
+ // TODO(andruud): ElementRuleCollector could emit MatchedProperties
+ // directly to the cascade.
+ MatchResult& MutableMatchResult();
- private:
- Member<const CSSValue> value_;
- Priority priority_;
- };
-
- // Add a Value to the cascade. The Value will either become the cascaded
- // value, or be discarded, depending on the Priority of the incoming value
- // vs. the Priority of the existing value.
- void Add(const CSSPropertyName&, const CSSValue*, Priority);
-
- // Applies all values currently in the cascade to the ComputedStyle.
- // Any CSSPendingInterpolationValues present in the cascade will be ignored.
- void Apply();
- // Applies all values currently in the cascade to the ComputedStyle,
- // dispatching any CSSPendingInterpolationValues to the given Animator.
- void Apply(Animator&);
-
- // Removes all kAnimationPropertyPriority properties from the cascade,
- // without applying the properties. This is used when pre-emptively copying
- // the cascade in case there are animations.
+ // Add ActiveInterpolationsMap to the cascade. The interpolations present
+ // in the map will be taken into account during the next call to Apply.
//
- // TODO(crbug.com/985010): Improve with non-destructive Apply.
- void RemoveAnimationPriority();
+ // Note that it's assumed that the incoming ActiveInterpolationsMap outlives
+ // the StyleCascade object.
+ void AddInterpolations(const ActiveInterpolationsMap*, CascadeOrigin);
- // The Filter class is responsible for resolving situations where
- // we have multiple (non-alias) properties in the cascade that mutates the
- // same fields on ComputedStyle.
+ // Applies the current CSS declarations and animations to the
+ // StyleResolverState.
//
- // An example of this is writing-mode and -webkit-writing-mode, which
- // both result in ComputedStyle::SetWritingMode calls.
- //
- // When applying the cascade (applying each property/value pair to the
- // ComputedStyle), the order of the application is in the general case
- // not defined. (It is determined by the iteration order of the HashMap).
- // This means that if both writing-mode and -webkit-writing-mode exist in
- // the cascade, we would get non-deterministic behavior: the application order
- // would not be defined. To fix this, all Values pass through this Filter
- // before being applied.
-
- // The Filter stores the Priority of the Value that was previously applied
- // for a certain 'group' of properties (writing_mode_ is one such group).
- // When we're about to apply a Value, we only actually do so if the call to
- // Filter::Add succeeds. If the call to Filter::Add does not succeed, it means
- // that we have previously added a Value with higher Priority, and that the
- // current Value must be ignored.
-
- // A key difference between discarding Values in the Filter, vs. discarding
- // them cascade-time (StyleCascade::Add), is that we are taking the cascade
- // order into account. This means that, if everything else is equal (origin,
- // tree order), the Value that entered the cascade last wins. This is crucial
- // to resolve situations like writing-mode and -webkit-writing-mode.
-
- // The Filter is also expected to resolve similar difficulties with
- // direction-aware properties in the future, although this is not yet
- // implemented.
- class CORE_EXPORT Filter {
- STACK_ALLOCATED();
-
- public:
- // Attempts to add a given property/value to the Filter. If this returns
- // true, the Value may be applied to the ComputedStyle. If not, it means
- // that we have previously applied a Value with higher Priority, and the
- // current Value must be discarded.
- bool Add(const CSSProperty& property, const Value&);
-
- private:
- Priority& GetSlot(const CSSProperty&);
-
- Priority none_;
- Priority writing_mode_;
- Priority zoom_;
- };
-
- // Resolver is an object passed on a stack during Apply. Its most important
- // job is to detect cycles during Apply (in general, keep track of which
- // properties we're currently applying).
- class CORE_EXPORT Resolver {
- STACK_ALLOCATED();
-
- public:
- // TODO(crbug.com/985047): Probably use a HashMap for this.
- using NameStack = Vector<CSSPropertyName, 8>;
-
- // A 'locked' property is a property we are in the process of applying.
- // In other words, once a property is locked, locking it again would form
- // a cycle, and is therefore an error.
- bool IsLocked(const CSSProperty&) const;
- bool IsLocked(const CSSPropertyName&) const;
-
- // We do not allow substitution of animation-tainted values into
- // an animation-affecting property.
- //
- // https://drafts.csswg.org/css-variables/#animation-tainted
- bool AllowSubstitution(CSSVariableData*) const;
-
- private:
- friend class AutoLock;
- friend class StyleCascade;
- friend class TestCascadeResolver;
-
- Resolver(Animator& animator) : animator_(animator) {}
- // If the given property is already being applied, returns true.
- // The return value is the same value you would get from InCycle(), and
- // is just returned for convenience.
- //
- // When a cycle has been detected, the Resolver will *persist the cycle
- // state* (i.e. InCycle() will continue to return true) until we reach
- // the start of the cycle.
- //
- // The cycle state is cleared by ~AutoLock, once we have moved far enough
- // up the stack.
- bool DetectCycle(const CSSProperty&);
- // Returns true whenever the Resolver is in a cycle state.
- // This DOES NOT detect cycles; the caller must call DetectCycle first.
- bool InCycle() const;
-
- NameStack stack_;
- Animator& animator_;
- wtf_size_t cycle_depth_ = kNotFound;
- Filter filter_;
- };
+ // It is valid to call Apply multiple times (up to 15), and each call may
+ // provide a different filter.
+ void Apply(CascadeFilter = CascadeFilter());
- // Automatically locks and unlocks the given property. (See
- // Resolver::IsLocked).
- class CORE_EXPORT AutoLock {
- STACK_ALLOCATED();
-
- public:
- AutoLock(const CSSProperty&, Resolver&);
- AutoLock(const CSSPropertyName&, Resolver&);
- ~AutoLock();
-
- private:
- Resolver& resolver_;
- };
-
- // Animator & CSSPendingInterpolationValue
- //
- // Blink's way of applying animations poses some difficulty for StyleCascade,
- // as much of the code that applies the animation effects completely bypasses
- // StyleBuilder; it sets the values on ComputedStyle directly. This prevents
- // those values from participating properly in the cascade.
- //
- // At the same time, we don't want to actually create CSSValues for the
- // animation effects, as this is (yet another?) unnecessary conversion, and
- // it produces unwanted GC pressure. To solve this problem, the cascading
- // and application aspects of interpolations are handled *separately*.
- //
- // CSSPendingInterpolationValue represents the cascading aspect of an
- // interpolation: this means that, once we know that an interpolation is
- // active for a given property, we add a CSSPendingInterpolationValue to the
- // cascade (with the appropriate Priority). Apply-time, we then ask the
- // Animator (see StyleAnimator) to actually apply the interpolated value
- // using the interpolation infrastructure.
- class CORE_EXPORT Animator {
- public:
- virtual void Apply(const CSSProperty&,
- const CSSPendingInterpolationValue&,
- Resolver&) = 0;
- };
+ // Resets the cascade to its initial state. Note that this does not undo
+ // any changes already applied to the StyleResolverState/ComputedStyle.
+ void Reset();
- // Applying a CSSPendingInterpolationValue may involve resolving values,
- // since we may be applying a keyframe from e.g. "color: var(--x)" to
- // "color: var(--y)". Hence that code needs an entry point to the resolving
- // process.
+ // Applying interpolations may involve resolving values, since we may be
+ // applying a keyframe from e.g. "color: var(--x)" to "color: var(--y)".
+ // Hence that code needs an entry point to the resolving process.
//
// TODO(crbug.com/985023): This function has an associated const
// violation, which isn't great. (This vilation was not introduced with
// StyleCascade, however).
//
// See documentation the other Resolve* functions for what resolve means.
- const CSSValue* Resolve(const CSSPropertyName&, const CSSValue&, Resolver&);
+ const CSSValue* Resolve(const CSSPropertyName&,
+ const CSSValue&,
+ CascadeResolver&);
private:
friend class TestCascade;
@@ -360,30 +113,67 @@ class CORE_EXPORT StyleCascade {
// https://drafts.csswg.org/css-variables/#long-variables
static const size_t kMaxSubstitutionTokens = 16384;
+ // Before we can Apply the cascade, the MatchResult and CascadeInterpolations
+ // must be Analyzed. This means going through all the declarations, and
+ // adding them to the CascadeMap, which gives us a complete picture of which
+ // declarations won the cascade.
+ //
+ // We analyze only if needed (i.e. if MatchResult or CascadeInterpolations)
+ // has been mutated since the last call to AnalyzeIfNeeded.
+ void AnalyzeIfNeeded();
+ void AnalyzeMatchResult();
+ void AnalyzeInterpolations();
+
// Applies kHighPropertyPriority properties.
//
// In theory, it would be possible for each property/value that contains
// em/ch/etc to dynamically apply font-size (and related properties), but
// in practice, it is very inconvenient to detect these dependencies. Hence,
// we apply font-affecting properties (among others) before all the others.
- void ApplyHighPriority(Resolver&);
+ void ApplyHighPriority(CascadeResolver&);
- // Apply a single property (including any dependencies).
- void Apply(const CSSPropertyName&);
- void Apply(const CSSPropertyName&, Resolver&);
- void Apply(const CSSProperty&, Resolver&);
+ // Applies -webkit-appearance, and excludes -internal-ua-* properties if
+ // we don't have an appearance.
+ void ApplyAppearance(CascadeResolver&);
- // True if the cascade currently holds the provided value for a given
- // property. Note that the value is compared by address.
- bool HasValue(const CSSPropertyName&, const CSSValue*) const;
-
- // Get current cascaded value for the specified property.
- const CSSValue* GetValue(const CSSPropertyName&) const;
-
- // If there is a cascaded value for the specified property, replace it
- // with the incoming value, maintaining the current cascade origin.
- // Has no effect if there is no cascaded value for the property.
- void ReplaceValue(const CSSPropertyName&, const CSSValue*);
+ // Applies -webkit-border-image (if present), and skips any border-image
+ // longhands found with lower priority than -webkit-border-image.
+ //
+ // The -webkit-border-image property is unique (in a bad way), since it's
+ // a surrogate of a shorthand. Therefore it needs special treatment to
+ // behave correctly.
+ void ApplyWebkitBorderImage(CascadeResolver&);
+
+ void ApplyMatchResult(CascadeResolver&);
+ void ApplyInterpolations(CascadeResolver&);
+ void ApplyInterpolationMap(const ActiveInterpolationsMap&,
+ CascadeOrigin,
+ size_t index,
+ CascadeResolver&);
+ void ApplyInterpolation(const CSSProperty&,
+ CascadePriority,
+ const ActiveInterpolations&,
+ CascadeResolver&);
+ // Surrogates (such as css-logical properties) require special handling, since
+ // both the surrogate and the original property exist in the cascade at the
+ // same time. For example, 'inline-size' and 'width' may both exist in the
+ // CascadeMap, and the winner must be determined Apply-time, since we don't
+ // know which physical property 'inline-size' corresponds to before
+ // 'writing-mode' and 'direction' have been applied.
+ void ApplySurrogate(const CSSProperty&, CascadePriority, CascadeResolver&);
+
+ // Looks up a value with random access, and applies it.
+ void LookupAndApply(const CSSPropertyName&, CascadeResolver&);
+ void LookupAndApply(const CSSProperty&, CascadeResolver&);
+ void LookupAndApplyValue(const CSSProperty&,
+ CascadePriority,
+ CascadeResolver&);
+ void LookupAndApplyDeclaration(const CSSProperty&,
+ CascadePriority,
+ CascadeResolver&);
+ void LookupAndApplyInterpolation(const CSSProperty&,
+ CascadePriority,
+ CascadeResolver&);
// Whether or not we are calculating the style for the root element.
// We need to know this to detect cycles with 'rem' units.
@@ -453,19 +243,21 @@ class CORE_EXPORT StyleCascade {
// other words, we must first Apply '--y'. Hence, resolving 'width' will
// Apply '--y' as a side-effect. (This process would then continue to '--x').
- const CSSValue* Resolve(const CSSProperty&, const CSSValue&, Resolver&);
+ const CSSValue* Resolve(const CSSProperty&,
+ const CSSValue&,
+ CascadeResolver&);
const CSSValue* ResolveCustomProperty(const CSSProperty&,
const CSSCustomPropertyDeclaration&,
- Resolver&);
+ CascadeResolver&);
const CSSValue* ResolveVariableReference(const CSSProperty&,
const CSSVariableReferenceValue&,
- Resolver&);
+ CascadeResolver&);
const CSSValue* ResolvePendingSubstitution(const CSSProperty&,
const CSSPendingSubstitutionValue&,
- Resolver&);
+ CascadeResolver&);
scoped_refptr<CSSVariableData> ResolveVariableData(CSSVariableData*,
- Resolver&);
+ CascadeResolver&);
// The Resolve*Into functions either resolve dependencies, append to the
// TokenSequence accordingly, and return true; or it returns false when
@@ -475,9 +267,9 @@ class CORE_EXPORT StyleCascade {
//
// [1] https://drafts.csswg.org/css-variables/#invalid-at-computed-value-time
- bool ResolveTokensInto(CSSParserTokenRange, Resolver&, TokenSequence&);
- bool ResolveVarInto(CSSParserTokenRange, Resolver&, TokenSequence&);
- bool ResolveEnvInto(CSSParserTokenRange, Resolver&, TokenSequence&);
+ bool ResolveTokensInto(CSSParserTokenRange, CascadeResolver&, TokenSequence&);
+ bool ResolveVarInto(CSSParserTokenRange, CascadeResolver&, TokenSequence&);
+ bool ResolveEnvInto(CSSParserTokenRange, CascadeResolver&, TokenSequence&);
CSSVariableData* GetVariableData(const CustomProperty&) const;
CSSVariableData* GetEnvironmentVariable(const AtomicString&) const;
@@ -494,13 +286,66 @@ class CORE_EXPORT StyleCascade {
// https://drafts.css-houdini.org/css-properties-values-api-1/#fallbacks-in-var-references
bool ValidateFallback(const CustomProperty&, CSSParserTokenRange) const;
// Marks the CustomProperty as referenced by something. Needed to avoid
- // animating these custom properties on the compositor, and to disable the
- // matched properties cache in some cases.
- void MarkReferenced(const CustomProperty&);
+ // animating these custom properties on the compositor.
+ void MarkIsReferenced(const CustomProperty&);
+ // Marks a CSSProperty as having a reference to a custom property. Needed to
+ // disable the matched property cache in some cases.
+ void MarkHasVariableReference(const CSSProperty&);
+
+ const Document& GetDocument() const;
+ const CSSProperty& SurrogateFor(const CSSProperty& surrogate) const;
+
+ bool HasAuthorDeclaration(const CSSProperty&) const;
+ bool HasAuthorBorder() const;
+ bool HasAuthorBackground() const;
StyleResolverState& state_;
- HeapHashMap<CSSPropertyName, Value> cascade_;
- uint16_t order_ = 0;
+ MatchResult match_result_;
+ CascadeInterpolations interpolations_;
+ CascadeMap map_;
+ // Generational Apply
+ //
+ // Generation is a number that's incremented by one for each call to Apply
+ // (the first call to Apply has generation 1). When a declaration is applied
+ // to ComputedStyle, the current Apply-generation is stored in the CascadeMap.
+ // In other words, the CascadeMap knows which declarations have already been
+ // applied to ComputedStyle, which makes it possible to avoid applying the
+ // same declaration twice during a single call to Apply:
+ //
+ // For example:
+ //
+ // --x: red;
+ // background-color: var(--x);
+ //
+ // During Apply (generation=1), we linearly traverse the declarations above,
+ // and first apply '--x' to the ComputedStyle. Then, we proceed to
+ // 'background-color', which must first have its dependencies resolved before
+ // we can apply it. This is where we check the current generation stored for
+ // '--x'. If it's equal to the generation associated with the Apply call, we
+ // know that we already applied it. Either something else referenced it before
+ // we did, or it appeared before us in the MatchResult. Either way, we don't
+ // have to apply '--x' again.
+ //
+ // Had the order been reversed, such that the '--x' declaration appeared after
+ // the 'background-color' declaration, we would discover (during resolution of
+ // var(--x), that the current generation of '--x' is _less_ than the
+ // generation associated with the Apply call, hence we need to LookupAndApply
+ // '--x' before applying 'background-color'.
+ //
+ // A secondary benefit to the generational apply mechanic, is that it's
+ // possible to efficiently apply the StyleCascade more than once (perhaps with
+ // a different CascadeFilter for each call), without rebuilding it. By
+ // incrementing generation_, the existing record of what has been applied is
+ // immediately invalidated, and everything will be applied again.
+ //
+ // Note: The maximum generation number is currently 15. This is more than
+ // enough for our needs.
+ uint8_t generation_ = 0;
+
+ bool needs_match_result_analyze_ = false;
+ bool needs_interpolations_analyze_ = false;
+
+ DISALLOW_COPY_AND_ASSIGN(StyleCascade);
};
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/style_cascade_test.cc b/chromium/third_party/blink/renderer/core/css/resolver/style_cascade_test.cc
index d72f04ff789..87269c3ba0d 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/style_cascade_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/style_cascade_test.cc
@@ -6,13 +6,12 @@
#include <vector>
+#include "third_party/blink/renderer/bindings/core/v8/v8_css_style_sheet_init.h"
#include "third_party/blink/renderer/core/animation/css/css_animations.h"
#include "third_party/blink/renderer/core/css/active_style_sheets.h"
#include "third_party/blink/renderer/core/css/css_custom_property_declaration.h"
-#include "third_party/blink/renderer/core/css/css_pending_interpolation_value.h"
#include "third_party/blink/renderer/core/css/css_pending_substitution_value.h"
#include "third_party/blink/renderer/core/css/css_primitive_value.h"
-#include "third_party/blink/renderer/core/css/css_style_sheet_init.h"
#include "third_party/blink/renderer/core/css/css_test_helpers.h"
#include "third_party/blink/renderer/core/css/css_variable_reference_value.h"
#include "third_party/blink/renderer/core/css/document_style_environment_variables.h"
@@ -27,8 +26,12 @@
#include "third_party/blink/renderer/core/css/properties/css_property_ref.h"
#include "third_party/blink/renderer/core/css/properties/longhands/custom_property.h"
#include "third_party/blink/renderer/core/css/property_registry.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_filter.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_interpolations.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_map.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_priority.h"
+#include "third_party/blink/renderer/core/css/resolver/cascade_resolver.h"
#include "third_party/blink/renderer/core/css/resolver/scoped_style_resolver.h"
-#include "third_party/blink/renderer/core/css/resolver/style_animator.h"
#include "third_party/blink/renderer/core/css/resolver/style_resolver.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/css/style_sheet_contents.h"
@@ -41,14 +44,12 @@
namespace blink {
+using css_test_helpers::ParseDeclarationBlock;
using css_test_helpers::RegisterProperty;
-using cssvalue::CSSPendingInterpolationValue;
-using Origin = StyleCascade::Origin;
-using Priority = StyleCascade::Priority;
+using Origin = CascadeOrigin;
+using Priority = CascadePriority;
using UnitType = CSSPrimitiveValue::UnitType;
-enum class AnimationTainted { kYes, kNo };
-
class TestCascade {
STACK_ALLOCATED();
@@ -67,72 +68,33 @@ class TestCascade {
state_.StyleRef().InheritFrom(*parent);
}
- void Add(String name,
- String value,
- Priority priority = Origin::kAuthor,
- AnimationTainted animation_tainted = AnimationTainted::kNo) {
- return Add(*CSSPropertyName::From(name), value, priority,
- animation_tainted);
- }
-
- void Add(const CSSPropertyName& name,
- String value,
- Priority priority = Origin::kAuthor,
- AnimationTainted animation_tainted = AnimationTainted::kNo) {
- HeapVector<CSSPropertyValue, 256> values =
- ParseValues(name, value, animation_tainted);
+ // Note that because of how MatchResult works, declarations must be added
+ // in "origin order", i.e. UserAgent first, then User, then Author.
- for (const CSSPropertyValue& v : values)
- Add(v.Name(), v.Value(), priority);
+ void Add(String block,
+ CascadeOrigin origin = CascadeOrigin::kAuthor,
+ unsigned link_match_type = CSSSelector::kMatchAll) {
+ CSSParserMode mode =
+ origin == CascadeOrigin::kUserAgent ? kUASheetMode : kHTMLStandardMode;
+ Add(ParseDeclarationBlock(block, mode), origin, link_match_type);
}
- void Add(String name,
- const CSSValue* value,
- Priority priority = Origin::kAuthor) {
- Add(*CSSPropertyName::From(name), value, priority);
+ void Add(String name, String value, CascadeOrigin origin = Origin::kAuthor) {
+ Add(name + ":" + value, origin);
}
- void Add(const CSSPropertyName& name,
- const CSSValue* value,
- Priority priority = Origin::kAuthor) {
- DCHECK(CSSPropertyRef(name, GetDocument()).GetProperty().IsLonghand());
- cascade_.Add(name, value, priority);
+ void Add(const CSSPropertyValueSet* set,
+ CascadeOrigin origin = CascadeOrigin::kAuthor,
+ unsigned link_match_type = CSSSelector::kMatchAll) {
+ DCHECK_LE(origin, CascadeOrigin::kAuthor) << "Animations not supported";
+ DCHECK_LE(current_origin_, origin) << "Please add declarations in order";
+ EnsureAtLeast(origin);
+ cascade_.MutableMatchResult().AddMatchedProperties(set, link_match_type);
}
- void Apply(const CSSPropertyName& name) { cascade_.Apply(name); }
- void Apply(String name) { Apply(*CSSPropertyName::From(name)); }
- void Apply() { cascade_.Apply(); }
- void Apply(StyleCascade::Animator& animator) { cascade_.Apply(animator); }
-
- HeapVector<CSSPropertyValue, 256> ParseValues(
- const CSSPropertyName& name,
- String value,
- AnimationTainted animation_tainted) {
- CSSTokenizer tokenizer(value);
- auto tokens = tokenizer.TokenizeToEOF();
- auto* context = MakeGarbageCollected<CSSParserContext>(GetDocument());
- context->SetMode(kUASheetMode); // Allows -internal variables.
-
- HeapVector<CSSPropertyValue, 256> parsed_properties;
-
- bool is_animation_tainted = animation_tainted == AnimationTainted::kYes;
- if (name.Id() == CSSPropertyID::kVariable) {
- // TODO(andruud): Make CSSPropertyParser::ParseValue handle custom props.
- const CSSValue* decl = CSSVariableParser::ParseDeclarationValue(
- name.ToAtomicString(), tokens, is_animation_tainted, *context);
- DCHECK(decl);
- parsed_properties.emplace_back(GetCSSPropertyVariable(), *decl);
- return parsed_properties;
- }
-
- const bool important = false;
-
- bool ok = CSSPropertyParser::ParseValue(name.Id(), important, tokens,
- context, parsed_properties,
- StyleRule::RuleType::kStyle);
- DCHECK(ok);
-
- return parsed_properties;
+ void Apply(CascadeFilter filter = CascadeFilter()) {
+ EnsureAtLeast(CascadeOrigin::kAuthor);
+ cascade_.Apply(filter);
}
String ComputedValue(String name) const {
@@ -145,77 +107,37 @@ class TestCascade {
return value ? value->CssText() : g_null_atom;
}
- bool HasValue(String name, const CSSValue* value) {
- return cascade_.HasValue(*CSSPropertyName::From(name), value);
+ CascadePriority GetPriority(String name) {
+ return GetPriority(
+ *CSSPropertyName::From(GetDocument().GetExecutionContext(), name));
}
- const CSSValue* GetCSSValue(String name) {
- return cascade_.GetValue(*CSSPropertyName::From(name));
+ CascadePriority GetPriority(CSSPropertyName name) {
+ CascadePriority* c = cascade_.map_.Find(name);
+ return c ? *c : CascadePriority();
}
- const String GetValue(String name) {
- const CSSValue* value = GetCSSValue(name);
- // Per spec, CSSPendingSubstitutionValue serializes as an empty string,
- // but for testing purposes it's nice to see the actual value.
- if (const auto* v = DynamicTo<cssvalue::CSSPendingSubstitutionValue>(value))
- return v->ShorthandValue()->CssText();
- if (DynamicTo<CSSPendingInterpolationValue>(value))
- return "<interpolation>";
- return value ? value->CssText() : g_null_atom;
- }
+ CascadeOrigin GetOrigin(String name) { return GetPriority(name).GetOrigin(); }
- CSSAnimationUpdate& CalculateTransitionUpdate() {
+ void CalculateTransitionUpdate() {
CSSAnimations::CalculateTransitionUpdate(
state_.AnimationUpdate(), CSSAnimations::PropertyPass::kCustom,
&state_.GetElement(), *state_.Style());
CSSAnimations::CalculateTransitionUpdate(
state_.AnimationUpdate(), CSSAnimations::PropertyPass::kStandard,
&state_.GetElement(), *state_.Style());
- return state_.AnimationUpdate();
+ AddTransitions();
}
- CSSAnimationUpdate& CalculateAnimationUpdate() {
+ void CalculateAnimationUpdate() {
CSSAnimations::CalculateAnimationUpdate(
state_.AnimationUpdate(), &state_.GetElement(), state_.GetElement(),
*state_.Style(), state_.ParentStyle(),
&GetDocument().EnsureStyleResolver());
- return state_.AnimationUpdate();
- }
-
- void AddAnimations() {
- auto& update = CalculateAnimationUpdate();
- using Type = CSSPendingInterpolationValue::Type;
-
- for (const auto& entry : update.ActiveInterpolationsForCustomAnimations()) {
- auto name = entry.key.GetCSSPropertyName();
- auto* v = CSSPendingInterpolationValue::Create(Type::kCSSProperty);
- Add(name.ToAtomicString(), v);
- }
- for (const auto& entry :
- update.ActiveInterpolationsForStandardAnimations()) {
- auto name = entry.key.GetCSSPropertyName();
- auto* v = CSSPendingInterpolationValue::Create(Type::kCSSProperty);
- Add(name.ToAtomicString(), v);
- }
+ AddAnimations();
}
- void AddTransitions() {
- auto& update = CalculateTransitionUpdate();
- using Type = CSSPendingInterpolationValue::Type;
-
- for (const auto& entry :
- update.ActiveInterpolationsForCustomTransitions()) {
- auto name = entry.key.GetCSSPropertyName();
- auto* v = CSSPendingInterpolationValue::Create(Type::kCSSProperty);
- Add(name.ToAtomicString(), v);
- }
- for (const auto& entry :
- update.ActiveInterpolationsForStandardTransitions()) {
- auto name = entry.key.GetCSSPropertyName();
- auto* v = CSSPendingInterpolationValue::Create(Type::kCSSProperty);
- Add(name.ToAtomicString(), v);
- }
- }
+ void Reset() { cascade_.Reset(); }
private:
Document& GetDocument() const { return state_.GetDocument(); }
@@ -231,6 +153,53 @@ class TestCascade {
return StyleResolver::InitialStyleForElement(document);
}
+ void FinishOrigin() {
+ switch (current_origin_) {
+ case CascadeOrigin::kUserAgent:
+ cascade_.MutableMatchResult().FinishAddingUARules();
+ current_origin_ = CascadeOrigin::kUser;
+ break;
+ case CascadeOrigin::kUser:
+ cascade_.MutableMatchResult().FinishAddingUserRules();
+ current_origin_ = CascadeOrigin::kAuthor;
+ break;
+ case CascadeOrigin::kAuthor:
+ default:
+ NOTREACHED();
+ break;
+ }
+ }
+
+ void EnsureAtLeast(CascadeOrigin origin) {
+ while (current_origin_ < origin)
+ FinishOrigin();
+ }
+
+ void AddAnimations() {
+ const auto& update = state_.AnimationUpdate();
+ if (update.IsEmpty())
+ return;
+ cascade_.AddInterpolations(
+ &update.ActiveInterpolationsForCustomAnimations(),
+ CascadeOrigin::kAnimation);
+ cascade_.AddInterpolations(
+ &update.ActiveInterpolationsForStandardAnimations(),
+ CascadeOrigin::kAnimation);
+ }
+
+ void AddTransitions() {
+ const auto& update = state_.AnimationUpdate();
+ if (update.IsEmpty())
+ return;
+ cascade_.AddInterpolations(
+ &update.ActiveInterpolationsForCustomTransitions(),
+ CascadeOrigin::kTransition);
+ cascade_.AddInterpolations(
+ &update.ActiveInterpolationsForStandardTransitions(),
+ CascadeOrigin::kTransition);
+ }
+
+ CascadeOrigin current_origin_ = CascadeOrigin::kUserAgent;
StyleResolverState state_;
StyleCascade cascade_;
};
@@ -239,22 +208,29 @@ class TestCascadeResolver {
STACK_ALLOCATED();
public:
- TestCascadeResolver(Document& document, StyleAnimator& animator)
- : document_(&document), resolver_(animator) {}
+ explicit TestCascadeResolver(Document& document, uint8_t generation = 0)
+ : document_(document), resolver_(CascadeFilter(), generation) {}
bool InCycle() const { return resolver_.InCycle(); }
bool DetectCycle(String name) {
- CSSPropertyRef ref(name, *document_);
+ CSSPropertyRef ref(name, document_);
DCHECK(ref.IsValid());
const CSSProperty& property = ref.GetProperty();
return resolver_.DetectCycle(property);
}
wtf_size_t CycleDepth() const { return resolver_.cycle_depth_; }
+ void MarkApplied(CascadePriority* priority) {
+ resolver_.MarkApplied(priority);
+ }
+ void MarkUnapplied(CascadePriority* priority) {
+ resolver_.MarkUnapplied(priority);
+ }
+ uint8_t GetGeneration() { return resolver_.generation_; }
private:
friend class TestCascadeAutoLock;
- Member<Document> document_;
- StyleCascade::Resolver resolver_;
+ Document& document_;
+ CascadeResolver resolver_;
};
class TestCascadeAutoLock {
@@ -266,7 +242,7 @@ class TestCascadeAutoLock {
: lock_(name, resolver.resolver_) {}
private:
- StyleCascade::AutoLock lock_;
+ CascadeResolver::AutoLock lock_;
};
class StyleCascadeTest : public PageTestBase, private ScopedCSSCascadeForTest {
@@ -306,15 +282,15 @@ class StyleCascadeTest : public PageTestBase, private ScopedCSSCascadeForTest {
UpdateAllLifecyclePhasesForTest();
}
- Priority AuthorPriority(uint16_t tree_order, uint16_t cascade_order) {
- return Priority(Origin::kAuthor, tree_order)
- .WithCascadeOrder(cascade_order);
- }
-
- Priority ImportantAuthorPriority(uint16_t tree_order,
- uint16_t cascade_order) {
- return Priority(Origin::kImportantAuthor, tree_order)
- .WithCascadeOrder(cascade_order);
+ const MutableCSSPropertyValueSet* AnimationTaintedSet(AtomicString name,
+ String value) {
+ CSSParserMode mode = kHTMLStandardMode;
+ auto* set = MakeGarbageCollected<MutableCSSPropertyValueSet>(mode);
+ set->SetProperty(name, value, /* important */ false,
+ SecureContextMode::kSecureContext,
+ /* context_style_sheet */ nullptr,
+ /* is_animation_tainted */ true);
+ return set;
}
// Temporarily create a CSS Environment Variable.
@@ -334,130 +310,87 @@ class StyleCascadeTest : public PageTestBase, private ScopedCSSCascadeForTest {
return document_->GetStyleEngine().EnsureEnvironmentVariables();
}
- Member<Document> document_;
+ Document* document_;
AtomicString name_;
};
};
-TEST_F(StyleCascadeTest, OriginImportance) {
- EXPECT_EQ(Origin::kImportantUserAgent,
- Priority(Origin::kUserAgent).AddImportance().GetOrigin());
- EXPECT_EQ(Origin::kImportantUser,
- Priority(Origin::kUser).AddImportance().GetOrigin());
- EXPECT_EQ(Origin::kImportantAuthor,
- Priority(Origin::kAuthor).AddImportance().GetOrigin());
-}
-
-TEST_F(StyleCascadeTest, PriorityOrigin) {
- std::vector<Priority> priorities = {
- Origin::kTransition, Origin::kImportantUserAgent,
- Origin::kImportantUser, Origin::kImportantAuthor,
- Origin::kAnimation, Origin::kAuthor,
- Origin::kUser, Origin::kUserAgent,
- Origin::kNone};
-
- for (size_t i = 0; i < priorities.size(); ++i) {
- for (size_t j = i; j < priorities.size(); ++j)
- EXPECT_GE(priorities[i], priorities[j]);
- }
-
- EXPECT_FALSE(Priority(Origin::kUser) >= Priority(Origin::kAuthor));
-}
+TEST_F(StyleCascadeTest, ApplySingle) {
+ TestCascade cascade(GetDocument());
+ cascade.Add("width", "1px", CascadeOrigin::kUserAgent);
+ cascade.Add("width", "2px", CascadeOrigin::kAuthor);
+ cascade.Apply();
-TEST_F(StyleCascadeTest, PriorityHasOrigin) {
- EXPECT_TRUE(Priority(Origin::kTransition).HasOrigin());
- EXPECT_TRUE(Priority(Origin::kAuthor).HasOrigin());
- EXPECT_FALSE(Priority(Origin::kNone).HasOrigin());
+ EXPECT_EQ("2px", cascade.ComputedValue("width"));
}
-TEST_F(StyleCascadeTest, PriorityTreeOrder) {
- Origin origin = Origin::kAuthor;
- EXPECT_GE(Priority(origin, 0), Priority(origin, 1));
- EXPECT_GE(Priority(origin, 6), Priority(origin, 7));
- EXPECT_GE(Priority(origin, 42), Priority(origin, 42));
- EXPECT_FALSE(Priority(origin, 8) >= Priority(origin, 1));
-}
+TEST_F(StyleCascadeTest, ApplyImportance) {
+ TestCascade cascade(GetDocument());
+ cascade.Add("width:1px !important", CascadeOrigin::kUserAgent);
+ cascade.Add("width:2px", CascadeOrigin::kAuthor);
+ cascade.Apply();
-TEST_F(StyleCascadeTest, PriorityTreeOrderImportant) {
- Origin origin = Origin::kImportantAuthor;
- EXPECT_GE(Priority(origin, 1), Priority(origin, 0));
- EXPECT_GE(Priority(origin, 7), Priority(origin, 6));
- EXPECT_GE(Priority(origin, 42), Priority(origin, 42));
- EXPECT_FALSE(Priority(origin, 1) >= Priority(origin, 8));
+ EXPECT_EQ("1px", cascade.ComputedValue("width"));
}
-TEST_F(StyleCascadeTest, PriorityTreeOrderDifferentOrigin) {
- // Tree order does not matter if the origin is different.
- Origin author = Origin::kAuthor;
- Origin transition = Origin::kTransition;
- EXPECT_GE(Priority(transition, 42), Priority(author, 1));
- EXPECT_GE(Priority(transition, 1), Priority(author, 1));
-}
+TEST_F(StyleCascadeTest, ApplyAll) {
+ TestCascade cascade(GetDocument());
+ cascade.Add("width:1px", CascadeOrigin::kUserAgent);
+ cascade.Add("height:1px", CascadeOrigin::kUserAgent);
+ cascade.Add("all:initial", CascadeOrigin::kAuthor);
+ cascade.Apply();
-TEST_F(StyleCascadeTest, PriorityCascadeOrder) {
- // AuthorPriority(tree_order, cascade_order)
- EXPECT_GE(AuthorPriority(0, 0), AuthorPriority(0, 0));
- EXPECT_GE(AuthorPriority(0, 1), AuthorPriority(0, 1));
- EXPECT_GE(AuthorPriority(0, 1), AuthorPriority(0, 0));
- EXPECT_GE(AuthorPriority(0, 2), AuthorPriority(0, 1));
- EXPECT_GE(AuthorPriority(0, 0xFFFF), AuthorPriority(0, 0xFFFE));
- EXPECT_FALSE(AuthorPriority(0, 2) >= AuthorPriority(0, 3));
+ EXPECT_EQ("auto", cascade.ComputedValue("width"));
+ EXPECT_EQ("auto", cascade.ComputedValue("height"));
}
-TEST_F(StyleCascadeTest, PriorityCascadeOrderAndTreeOrder) {
- // AuthorPriority(tree_order, cascade_order)
- EXPECT_GE(AuthorPriority(0, 0), AuthorPriority(1, 0));
- EXPECT_GE(AuthorPriority(0, 1), AuthorPriority(1, 1));
- EXPECT_GE(AuthorPriority(0, 1), AuthorPriority(1, 3));
- EXPECT_GE(AuthorPriority(0, 2), AuthorPriority(1, 0xFFFE));
-}
+TEST_F(StyleCascadeTest, ApplyAllImportance) {
+ TestCascade cascade(GetDocument());
+ cascade.Add("opacity:0.5", CascadeOrigin::kUserAgent);
+ cascade.Add("display:block !important", CascadeOrigin::kUserAgent);
+ cascade.Add("all:initial", CascadeOrigin::kAuthor);
+ cascade.Apply();
-TEST_F(StyleCascadeTest, PriorityCascadeOrderAndOrigin) {
- // [Important]AuthorPriority(tree_order, cascade_order)
- EXPECT_GE(ImportantAuthorPriority(0, 0), AuthorPriority(0, 0));
- EXPECT_GE(ImportantAuthorPriority(0, 1), AuthorPriority(0, 1));
- EXPECT_GE(ImportantAuthorPriority(0, 1), AuthorPriority(0, 3));
- EXPECT_GE(ImportantAuthorPriority(0, 2), AuthorPriority(0, 0xFFFE));
+ EXPECT_EQ("1", cascade.ComputedValue("opacity"));
+ EXPECT_EQ("block", cascade.ComputedValue("display"));
}
-TEST_F(StyleCascadeTest, ApplySingle) {
+TEST_F(StyleCascadeTest, ApplyAllWithPhysicalLonghands) {
TestCascade cascade(GetDocument());
- cascade.Add("width", "2px", Origin::kAuthor);
- cascade.Add("width", "1px", Origin::kUser);
- cascade.Apply("width");
-
- EXPECT_EQ("2px", cascade.ComputedValue("width"));
+ cascade.Add("width:1px", CascadeOrigin::kUserAgent);
+ cascade.Add("height:1px !important", CascadeOrigin::kUserAgent);
+ cascade.Add("all:initial", CascadeOrigin::kAuthor);
+ cascade.Apply();
+ EXPECT_EQ("auto", cascade.ComputedValue("width"));
+ EXPECT_EQ("1px", cascade.ComputedValue("height"));
}
TEST_F(StyleCascadeTest, ApplyCustomProperty) {
TestCascade cascade(GetDocument());
cascade.Add("--x", " 10px ");
cascade.Add("--y", "nope");
- cascade.Apply("--x");
- cascade.Apply("--y");
+ cascade.Apply();
EXPECT_EQ(" 10px ", cascade.ComputedValue("--x"));
EXPECT_EQ("nope", cascade.ComputedValue("--y"));
}
-TEST_F(StyleCascadeTest, Copy) {
- StyleResolverState state(GetDocument(), *GetDocument().body());
-
+TEST_F(StyleCascadeTest, ApplyGenerations) {
TestCascade cascade(GetDocument());
- cascade.Add("--x", "10px");
- cascade.Add("width", "20px");
-
- // Take snapshot of the cascade, pointing to the same StyleResolverState.
- StyleCascade snapshot(cascade.InnerCascade());
- cascade.Add("--x", "0px");
- cascade.Add("width", "1px");
+ cascade.Add("--x:10px");
+ cascade.Add("width:20px");
cascade.Apply();
+ EXPECT_EQ("10px", cascade.ComputedValue("--x"));
+ EXPECT_EQ("20px", cascade.ComputedValue("width"));
- EXPECT_EQ("0px", cascade.ComputedValue("--x"));
- EXPECT_EQ("1px", cascade.ComputedValue("width"));
+ cascade.State().StyleRef().SetWidth(Length::Auto());
+ cascade.State().StyleRef().SetVariableData("--x", nullptr, true);
+ EXPECT_EQ(g_null_atom, cascade.ComputedValue("--x"));
+ EXPECT_EQ("auto", cascade.ComputedValue("width"));
- snapshot.Apply();
+ // Apply again
+ cascade.Apply();
EXPECT_EQ("10px", cascade.ComputedValue("--x"));
EXPECT_EQ("20px", cascade.ComputedValue("width"));
}
@@ -468,8 +401,7 @@ TEST_F(StyleCascadeTest, ApplyCustomPropertyVar) {
TestCascade cascade(GetDocument());
cascade.Add("--x", "yes and var(--y)");
cascade.Add("--y", "no");
- cascade.Apply("--x");
- cascade.Apply("--y");
+ cascade.Apply();
EXPECT_EQ("yes and no", cascade.ComputedValue("--x"));
EXPECT_EQ("no", cascade.ComputedValue("--y"));
@@ -478,10 +410,9 @@ TEST_F(StyleCascadeTest, ApplyCustomPropertyVar) {
// Apply --y first.
{
TestCascade cascade(GetDocument());
- cascade.Add("--x", "yes and var(--y)");
cascade.Add("--y", "no");
- cascade.Apply("--y");
- cascade.Apply("--x");
+ cascade.Add("--x", "yes and var(--y)");
+ cascade.Apply();
EXPECT_EQ("yes and no", cascade.ComputedValue("--x"));
EXPECT_EQ("no", cascade.ComputedValue("--y"));
@@ -491,7 +422,7 @@ TEST_F(StyleCascadeTest, ApplyCustomPropertyVar) {
TEST_F(StyleCascadeTest, InvalidVarReferenceCauseInvalidVariable) {
TestCascade cascade(GetDocument());
cascade.Add("--x", "nope var(--y)");
- cascade.Apply("--x");
+ cascade.Apply();
EXPECT_EQ(g_null_atom, cascade.ComputedValue("--x"));
}
@@ -499,7 +430,7 @@ TEST_F(StyleCascadeTest, InvalidVarReferenceCauseInvalidVariable) {
TEST_F(StyleCascadeTest, ApplyCustomPropertyFallback) {
TestCascade cascade(GetDocument());
cascade.Add("--x", "yes and var(--y,no)");
- cascade.Apply("--x");
+ cascade.Apply();
EXPECT_EQ("yes and no", cascade.ComputedValue("--x"));
}
@@ -530,7 +461,7 @@ TEST_F(StyleCascadeTest, VarInFallback) {
TestCascade cascade(GetDocument());
cascade.Add("--x", "one var(--z,two var(--y))");
cascade.Add("--y", "three");
- cascade.Apply("--x");
+ cascade.Apply();
EXPECT_EQ("one two three", cascade.ComputedValue("--x"));
}
@@ -539,7 +470,7 @@ TEST_F(StyleCascadeTest, VarReferenceInNormalProperty) {
TestCascade cascade(GetDocument());
cascade.Add("--x", "10px");
cascade.Add("width", "var(--x)");
- cascade.Apply("width");
+ cascade.Apply();
EXPECT_EQ("10px", cascade.ComputedValue("width"));
}
@@ -548,7 +479,7 @@ TEST_F(StyleCascadeTest, MultipleVarRefs) {
TestCascade cascade(GetDocument());
cascade.Add("--x", "var(--y) bar var(--y)");
cascade.Add("--y", "foo");
- cascade.Apply("--x");
+ cascade.Apply();
EXPECT_EQ("foo bar foo", cascade.ComputedValue("--x"));
}
@@ -558,7 +489,7 @@ TEST_F(StyleCascadeTest, RegisteredPropertyComputedValue) {
TestCascade cascade(GetDocument());
cascade.Add("--x", "1in");
- cascade.Apply("--x");
+ cascade.Apply();
EXPECT_EQ("96px", cascade.ComputedValue("--x"));
}
@@ -569,8 +500,7 @@ TEST_F(StyleCascadeTest, RegisteredPropertySyntaxErrorCausesInitial) {
TestCascade cascade(GetDocument());
cascade.Add("--x", "#fefefe");
cascade.Add("--y", "var(--x)");
- cascade.Apply("--x");
- cascade.Apply("--y");
+ cascade.Apply();
EXPECT_EQ("10px", cascade.ComputedValue("--x"));
EXPECT_EQ("10px", cascade.ComputedValue("--y"));
@@ -582,7 +512,7 @@ TEST_F(StyleCascadeTest, RegisteredPropertySubstitution) {
TestCascade cascade(GetDocument());
cascade.Add("--x", "1in");
cascade.Add("--y", "var(--x)");
- cascade.Apply("--y");
+ cascade.Apply();
EXPECT_EQ("96px", cascade.ComputedValue("--y"));
}
@@ -630,10 +560,6 @@ TEST_F(StyleCascadeTest, ApplyingPendingSubstitutionFirst) {
cascade.Add("margin", "1px var(--x) 3px 4px");
cascade.Add("--x", "2px");
cascade.Add("margin-right", "5px");
-
- // Apply one of the pending substitution values first. This should not
- // overwrite margin-right's 5px.
- cascade.Apply("margin-left");
cascade.Apply();
EXPECT_EQ("1px", cascade.ComputedValue("margin-top"));
@@ -644,48 +570,20 @@ TEST_F(StyleCascadeTest, ApplyingPendingSubstitutionFirst) {
TEST_F(StyleCascadeTest, ApplyingPendingSubstitutionLast) {
TestCascade cascade(GetDocument());
+ cascade.Add("margin-right", "5px");
cascade.Add("margin", "1px var(--x) 3px 4px");
cascade.Add("--x", "2px");
- cascade.Add("margin-right", "5px");
-
- // Apply margin-right before the others. Applying the pending substitution
- // afterwards should not overwrite margin-right's 5px.
- cascade.Apply("margin-right");
cascade.Apply();
EXPECT_EQ("1px", cascade.ComputedValue("margin-top"));
- EXPECT_EQ("5px", cascade.ComputedValue("margin-right"));
+ EXPECT_EQ("2px", cascade.ComputedValue("margin-right"));
EXPECT_EQ("3px", cascade.ComputedValue("margin-bottom"));
EXPECT_EQ("4px", cascade.ComputedValue("margin-left"));
}
-TEST_F(StyleCascadeTest, ApplyingPendingSubstitutionModifiesCascade) {
- TestCascade cascade(GetDocument());
- cascade.Add("margin", "1px var(--x) 3px 4px");
- cascade.Add("--x", "2px");
- cascade.Add("margin-right", "5px");
-
- // We expect the pending substitution value for all the shorthands,
- // except margin-right.
- EXPECT_EQ("1px var(--x) 3px 4px", cascade.GetValue("margin-top"));
- EXPECT_EQ("5px", cascade.GetValue("margin-right"));
- EXPECT_EQ("1px var(--x) 3px 4px", cascade.GetValue("margin-bottom"));
- EXPECT_EQ("1px var(--x) 3px 4px", cascade.GetValue("margin-left"));
-
- // Apply a pending substitution value should modify the cascade for other
- // longhands with the same pending substitution value.
- cascade.Apply("margin-left");
-
- EXPECT_EQ("1px", cascade.GetValue("margin-top"));
- EXPECT_EQ("5px", cascade.GetValue("margin-right"));
- EXPECT_EQ("3px", cascade.GetValue("margin-bottom"));
- EXPECT_FALSE(cascade.GetValue("margin-left"));
-}
-
TEST_F(StyleCascadeTest, ResolverDetectCycle) {
TestCascade cascade(GetDocument());
- StyleAnimator animator(cascade.State(), cascade.InnerCascade());
- TestCascadeResolver resolver(GetDocument(), animator);
+ TestCascadeResolver resolver(GetDocument());
{
TestCascadeAutoLock lock(CSSPropertyName("--a"), resolver);
@@ -709,8 +607,7 @@ TEST_F(StyleCascadeTest, ResolverDetectCycle) {
TEST_F(StyleCascadeTest, ResolverDetectNoCycle) {
TestCascade cascade(GetDocument());
- StyleAnimator animator(cascade.State(), cascade.InnerCascade());
- TestCascadeResolver resolver(GetDocument(), animator);
+ TestCascadeResolver resolver(GetDocument());
{
TestCascadeAutoLock lock(CSSPropertyName("--a"), resolver);
@@ -734,8 +631,7 @@ TEST_F(StyleCascadeTest, ResolverDetectNoCycle) {
TEST_F(StyleCascadeTest, ResolverDetectCycleSelf) {
TestCascade cascade(GetDocument());
- StyleAnimator animator(cascade.State(), cascade.InnerCascade());
- TestCascadeResolver resolver(GetDocument(), animator);
+ TestCascadeResolver resolver(GetDocument());
{
TestCascadeAutoLock lock(CSSPropertyName("--a"), resolver);
@@ -751,8 +647,7 @@ TEST_F(StyleCascadeTest, ResolverDetectMultiCycle) {
using AutoLock = TestCascadeAutoLock;
TestCascade cascade(GetDocument());
- StyleAnimator animator(cascade.State(), cascade.InnerCascade());
- TestCascadeResolver resolver(GetDocument(), animator);
+ TestCascadeResolver resolver(GetDocument());
{
AutoLock lock(CSSPropertyName("--a"), resolver);
@@ -789,8 +684,7 @@ TEST_F(StyleCascadeTest, ResolverDetectMultiCycleReverse) {
using AutoLock = TestCascadeAutoLock;
TestCascade cascade(GetDocument());
- StyleAnimator animator(cascade.State(), cascade.InnerCascade());
- TestCascadeResolver resolver(GetDocument(), animator);
+ TestCascadeResolver resolver(GetDocument());
{
AutoLock lock(CSSPropertyName("--a"), resolver);
@@ -823,6 +717,37 @@ TEST_F(StyleCascadeTest, ResolverDetectMultiCycleReverse) {
EXPECT_FALSE(resolver.InCycle());
}
+TEST_F(StyleCascadeTest, ResolverMarkApplied) {
+ TestCascadeResolver resolver(GetDocument(), 2);
+
+ CascadePriority priority(CascadeOrigin::kAuthor);
+ EXPECT_EQ(0, priority.GetGeneration());
+
+ resolver.MarkApplied(&priority);
+ EXPECT_EQ(2, priority.GetGeneration());
+
+ // Mark a second time to verify observation of the same generation.
+ resolver.MarkApplied(&priority);
+ EXPECT_EQ(2, priority.GetGeneration());
+}
+
+TEST_F(StyleCascadeTest, ResolverMarkUnapplied) {
+ TestCascadeResolver resolver(GetDocument(), 7);
+
+ CascadePriority priority(CascadeOrigin::kAuthor);
+ EXPECT_EQ(0, priority.GetGeneration());
+
+ resolver.MarkApplied(&priority);
+ EXPECT_EQ(7, priority.GetGeneration());
+
+ resolver.MarkUnapplied(&priority);
+ EXPECT_EQ(0, priority.GetGeneration());
+
+ // Mark a second time to verify observation of the same generation.
+ resolver.MarkUnapplied(&priority);
+ EXPECT_EQ(0, priority.GetGeneration());
+}
+
TEST_F(StyleCascadeTest, BasicCycle) {
TestCascade cascade(GetDocument());
cascade.Add("--a", "foo");
@@ -1066,7 +991,7 @@ TEST_F(StyleCascadeTest, CycleReferencedFromStandardProperty) {
TestCascade cascade(GetDocument());
cascade.Add("--a", "var(--b)");
cascade.Add("--b", "var(--a)");
- cascade.Add("color", "var(--a,green)");
+ cascade.Add("color:var(--a,green)");
cascade.Apply();
EXPECT_FALSE(cascade.ComputedValue("--a"));
@@ -1383,7 +1308,7 @@ TEST_F(StyleCascadeTest, RegisteredExplicitUnset) {
TEST_F(StyleCascadeTest, SubstituteAnimationTaintedInCustomProperty) {
TestCascade cascade(GetDocument());
- cascade.Add("--x", "15px", Origin::kAuthor, AnimationTainted::kYes);
+ cascade.Add(AnimationTaintedSet("--x", "15px"));
cascade.Add("--y", "var(--x)");
cascade.Apply();
EXPECT_EQ("15px", cascade.ComputedValue("--x"));
@@ -1392,7 +1317,7 @@ TEST_F(StyleCascadeTest, SubstituteAnimationTaintedInCustomProperty) {
TEST_F(StyleCascadeTest, SubstituteAnimationTaintedInStandardProperty) {
TestCascade cascade(GetDocument());
- cascade.Add("--x", "15px", Origin::kAuthor, AnimationTainted::kYes);
+ cascade.Add(AnimationTaintedSet("--x", "15px"));
cascade.Add("width", "var(--x)");
cascade.Apply();
EXPECT_EQ("15px", cascade.ComputedValue("--x"));
@@ -1408,7 +1333,7 @@ TEST_F(StyleCascadeTest, SubstituteAnimationTaintedInAnimationProperty) {
EXPECT_EQ("20s", cascade.ComputedValue("--x"));
EXPECT_EQ("20s", cascade.ComputedValue("animation-duration"));
- cascade.Add("--y", "20s", Origin::kAuthor, AnimationTainted::kYes);
+ cascade.Add(AnimationTaintedSet("--y", "20s"));
cascade.Add("animation-duration", "var(--y)");
cascade.Apply();
@@ -1418,7 +1343,7 @@ TEST_F(StyleCascadeTest, SubstituteAnimationTaintedInAnimationProperty) {
TEST_F(StyleCascadeTest, IndirectlyAnimationTainted) {
TestCascade cascade(GetDocument());
- cascade.Add("--x", "20s", Origin::kAuthor, AnimationTainted::kYes);
+ cascade.Add(AnimationTaintedSet("--x", "20s"));
cascade.Add("--y", "var(--x)");
cascade.Add("animation-duration", "var(--y)");
cascade.Apply();
@@ -1430,7 +1355,7 @@ TEST_F(StyleCascadeTest, IndirectlyAnimationTainted) {
TEST_F(StyleCascadeTest, AnimationTaintedFallback) {
TestCascade cascade(GetDocument());
- cascade.Add("--x", "20s", Origin::kAuthor, AnimationTainted::kYes);
+ cascade.Add(AnimationTaintedSet("--x", "20s"));
cascade.Add("animation-duration", "var(--x,1s)");
cascade.Apply();
@@ -1506,33 +1431,50 @@ TEST_F(StyleCascadeTest, ValidEnvInUsedFallback) {
EXPECT_EQ("rgb(255, 0, 0)", cascade.ComputedValue("background-color"));
}
-// An Animator that just records the name of all the properties
-// applied.
-class RecordingAnimator : public StyleCascade::Animator {
- public:
- void Apply(const CSSProperty& property,
- const CSSPendingInterpolationValue&,
- StyleCascade::Resolver& resolver) override {
- record.push_back(property.GetCSSPropertyName());
- }
+TEST_F(StyleCascadeTest, AnimationApplyFilter) {
+ AppendSheet(R"HTML(
+ @keyframes test {
+ from { color: white; background-color: white; }
+ to { color: gray; background-color: gray; }
+ }
+ )HTML");
- Vector<CSSPropertyName> record;
-};
+ TestCascade cascade(GetDocument());
-TEST_F(StyleCascadeTest, AnimatorCalledByPendingInterpolationValue) {
- RegisterProperty(GetDocument(), "--x", "<length>", "0px", false);
+ cascade.Add("animation: test linear 10s -5s");
+ cascade.Add("color:green");
+ cascade.Apply();
- RecordingAnimator animator;
+ cascade.CalculateAnimationUpdate();
+ cascade.Apply(CascadeFilter(CSSProperty::kInherited, true));
- using Type = CSSPendingInterpolationValue::Type;
- TestCascade cascade(GetDocument());
- cascade.Add("--x", CSSPendingInterpolationValue::Create(Type::kCSSProperty));
- cascade.Add("--y", CSSPendingInterpolationValue::Create(Type::kCSSProperty));
+ EXPECT_EQ("rgb(0, 128, 0)", cascade.ComputedValue("color"));
+ EXPECT_EQ("rgb(192, 192, 192)", cascade.ComputedValue("background-color"));
+}
+
+TEST_F(StyleCascadeTest, TransitionApplyFilter) {
+ TestCascade cascade1(GetDocument());
+ cascade1.Add("background-color: white");
+ cascade1.Add("color: white");
+ cascade1.Add("transition: all steps(2, start) 100s");
+ cascade1.Apply();
+
+ // Set the old style on the element, so that the transition
+ // update detects it.
+ GetDocument().body()->SetComputedStyle(cascade1.TakeStyle());
+
+ // Now simulate a new style, with new color values.
+ TestCascade cascade2(GetDocument());
+ cascade2.Add("background-color: gray");
+ cascade2.Add("color: gray");
+ cascade2.Add("transition: all steps(2, start) 100s");
+ cascade2.Apply();
- cascade.Apply(animator);
+ cascade2.CalculateTransitionUpdate();
+ cascade2.Apply(CascadeFilter(CSSProperty::kInherited, true));
- EXPECT_TRUE(animator.record.Contains(*CSSPropertyName::From("--x")));
- EXPECT_TRUE(animator.record.Contains(*CSSPropertyName::From("--y")));
+ EXPECT_EQ("rgb(128, 128, 128)", cascade2.ComputedValue("color"));
+ EXPECT_EQ("rgb(192, 192, 192)", cascade2.ComputedValue("background-color"));
}
TEST_F(StyleCascadeTest, PendingKeyframeAnimation) {
@@ -1551,9 +1493,10 @@ TEST_F(StyleCascadeTest, PendingKeyframeAnimation) {
cascade.Add("animation-duration", "1s");
cascade.Apply();
- cascade.AddAnimations();
+ cascade.CalculateAnimationUpdate();
+ cascade.Apply();
- EXPECT_EQ("<interpolation>", cascade.GetValue("--x"));
+ EXPECT_EQ(CascadeOrigin::kAnimation, cascade.GetPriority("--x").GetOrigin());
}
TEST_F(StyleCascadeTest, PendingKeyframeAnimationApply) {
@@ -1574,11 +1517,10 @@ TEST_F(StyleCascadeTest, PendingKeyframeAnimationApply) {
cascade.Add("animation-delay", "-5s");
cascade.Apply();
- cascade.AddAnimations();
+ cascade.CalculateAnimationUpdate();
+ cascade.Apply();
- EXPECT_EQ("<interpolation>", cascade.GetValue("--x"));
- StyleAnimator animator(cascade.State(), cascade.InnerCascade());
- cascade.Apply(animator);
+ EXPECT_EQ(CascadeOrigin::kAnimation, cascade.GetPriority("--x").GetOrigin());
EXPECT_EQ("15px", cascade.ComputedValue("--x"));
}
@@ -1601,11 +1543,11 @@ TEST_F(StyleCascadeTest, TransitionCausesInterpolationValue) {
cascade2.Add("transition", "--x 1s");
cascade2.Apply();
- // Detects transitions, and adds CSSPendingInterpolationValues
- // to the cascade, as appropriate.
- cascade2.AddTransitions();
+ cascade2.CalculateTransitionUpdate();
+ cascade2.Apply();
- EXPECT_EQ("<interpolation>", cascade2.GetValue("--x"));
+ EXPECT_EQ(CascadeOrigin::kTransition,
+ cascade2.GetPriority("--x").GetOrigin());
}
TEST_F(StyleCascadeTest, TransitionDetectedForChangedFontSize) {
@@ -1629,10 +1571,11 @@ TEST_F(StyleCascadeTest, TransitionDetectedForChangedFontSize) {
cascade2.Add("transition", "--x 1s, width 1s");
cascade2.Apply();
- cascade2.AddTransitions();
+ cascade2.CalculateTransitionUpdate();
+ cascade2.Apply();
- EXPECT_EQ("<interpolation>", cascade2.GetValue("--x"));
- EXPECT_EQ("<interpolation>", cascade2.GetValue("width"));
+ EXPECT_EQ(CascadeOrigin::kTransition, cascade2.GetOrigin("--x"));
+ EXPECT_EQ(CascadeOrigin::kTransition, cascade2.GetOrigin("width"));
EXPECT_EQ("10px", cascade2.ComputedValue("height"));
}
@@ -1654,13 +1597,11 @@ TEST_F(StyleCascadeTest, AnimatingVarReferences) {
cascade.Add("animation-delay", "-5s");
cascade.Apply();
- StyleAnimator animator(cascade.State(), cascade.InnerCascade());
-
- cascade.AddAnimations();
+ cascade.CalculateAnimationUpdate();
cascade.Add("--from", "10px");
cascade.Add("--to", "20px");
cascade.Add("--y", "var(--x)");
- cascade.Apply(animator);
+ cascade.Apply();
EXPECT_EQ("15px", cascade.ComputedValue("--x"));
EXPECT_EQ("15px", cascade.ComputedValue("--y"));
@@ -1682,13 +1623,67 @@ TEST_F(StyleCascadeTest, AnimateStandardProperty) {
cascade.Add("animation-delay", "-5s");
cascade.Apply();
- StyleAnimator animator(cascade.State(), cascade.InnerCascade());
+ cascade.CalculateAnimationUpdate();
+ cascade.Apply();
+
+ EXPECT_EQ(CascadeOrigin::kAnimation, cascade.GetOrigin("width"));
+ EXPECT_EQ("15px", cascade.ComputedValue("width"));
+}
+
+TEST_F(StyleCascadeTest, AuthorImportantWinOverAnimations) {
+ AppendSheet(R"HTML(
+ @keyframes test {
+ from { width: 10px; height: 10px; }
+ to { width: 20px; height: 20px; }
+ }
+ )HTML");
- cascade.AddAnimations();
- EXPECT_EQ("<interpolation>", cascade.GetValue("width"));
+ TestCascade cascade(GetDocument());
+
+ cascade.Add("animation-name", "test");
+ cascade.Add("animation-duration", "10s");
+ cascade.Add("animation-timing-function", "linear");
+ cascade.Add("animation-delay", "-5s");
+ cascade.Add("width:40px");
+ cascade.Add("height:40px !important");
+ cascade.Apply();
+
+ cascade.CalculateAnimationUpdate();
+ cascade.Apply();
+
+ EXPECT_EQ(CascadeOrigin::kAnimation, cascade.GetOrigin("width"));
+ EXPECT_EQ(CascadeOrigin::kAuthor, cascade.GetOrigin("height"));
- cascade.Apply(animator);
EXPECT_EQ("15px", cascade.ComputedValue("width"));
+ EXPECT_EQ("40px", cascade.ComputedValue("height"));
+}
+
+TEST_F(StyleCascadeTest, TransitionsWinOverAuthorImportant) {
+ // First, simulate an "old style".
+ TestCascade cascade1(GetDocument());
+ cascade1.Add("width:10px !important");
+ cascade1.Add("height:10px !important");
+ cascade1.Add("transition:all 1s");
+ cascade1.Apply();
+
+ // Set the old style on the element, so that the animation
+ // update detects it.
+ GetDocument().body()->SetComputedStyle(cascade1.TakeStyle());
+
+ // Now simulate a new style, with a new value for width/height.
+ TestCascade cascade2(GetDocument());
+ cascade2.Add("width:20px !important");
+ cascade2.Add("height:20px !important");
+ cascade2.Add("transition:all 1s");
+ cascade2.Apply();
+
+ cascade2.CalculateTransitionUpdate();
+ cascade2.Apply();
+
+ EXPECT_EQ(CascadeOrigin::kTransition,
+ cascade2.GetPriority("width").GetOrigin());
+ EXPECT_EQ(CascadeOrigin::kTransition,
+ cascade2.GetPriority("height").GetOrigin());
}
TEST_F(StyleCascadeTest, EmRespondsToAnimatedFontSize) {
@@ -1709,13 +1704,11 @@ TEST_F(StyleCascadeTest, EmRespondsToAnimatedFontSize) {
cascade.Add("animation-delay", "-5s");
cascade.Apply();
- StyleAnimator animator(cascade.State(), cascade.InnerCascade());
-
- cascade.AddAnimations();
+ cascade.CalculateAnimationUpdate();
cascade.Add("--x", "2em");
cascade.Add("width", "10em");
- cascade.Apply(animator);
+ cascade.Apply();
EXPECT_EQ("30px", cascade.ComputedValue("--x"));
EXPECT_EQ("150px", cascade.ComputedValue("width"));
}
@@ -1738,13 +1731,11 @@ TEST_F(StyleCascadeTest, AnimateStandardPropertyWithVar) {
cascade.Add("animation-delay", "-5s");
cascade.Apply();
- StyleAnimator animator(cascade.State(), cascade.InnerCascade());
-
- cascade.AddAnimations();
+ cascade.CalculateAnimationUpdate();
cascade.Add("--from", "10px");
cascade.Add("--to", "20px");
- cascade.Apply(animator);
+ cascade.Apply();
EXPECT_EQ("15px", cascade.ComputedValue("width"));
}
@@ -1766,21 +1757,162 @@ TEST_F(StyleCascadeTest, AnimateStandardShorthand) {
cascade.Add("animation-delay", "-5s");
cascade.Apply();
- StyleAnimator animator(cascade.State(), cascade.InnerCascade());
+ cascade.CalculateAnimationUpdate();
+ cascade.Apply();
- cascade.AddAnimations();
- EXPECT_EQ("<interpolation>", cascade.GetValue("margin-top"));
- EXPECT_EQ("<interpolation>", cascade.GetValue("margin-right"));
- EXPECT_EQ("<interpolation>", cascade.GetValue("margin-bottom"));
- EXPECT_EQ("<interpolation>", cascade.GetValue("margin-left"));
+ EXPECT_EQ(CascadeOrigin::kAnimation, cascade.GetOrigin("margin-top"));
+ EXPECT_EQ(CascadeOrigin::kAnimation, cascade.GetOrigin("margin-right"));
+ EXPECT_EQ(CascadeOrigin::kAnimation, cascade.GetOrigin("margin-bottom"));
+ EXPECT_EQ(CascadeOrigin::kAnimation, cascade.GetOrigin("margin-left"));
- cascade.Apply(animator);
EXPECT_EQ("15px", cascade.ComputedValue("margin-top"));
EXPECT_EQ("15px", cascade.ComputedValue("margin-right"));
EXPECT_EQ("15px", cascade.ComputedValue("margin-bottom"));
EXPECT_EQ("15px", cascade.ComputedValue("margin-left"));
}
+TEST_F(StyleCascadeTest, AnimatedVisitedImportantOverride) {
+ AppendSheet(R"HTML(
+ @keyframes test {
+ from { background-color: rgb(100, 100, 100); }
+ to { background-color: rgb(200, 200, 200); }
+ }
+ )HTML");
+
+ TestCascade cascade(GetDocument());
+ cascade.State().Style()->SetInsideLink(EInsideLink::kInsideVisitedLink);
+
+ cascade.Add(ParseDeclarationBlock("background-color:red !important"),
+ CascadeOrigin::kAuthor, CSSSelector::kMatchVisited);
+ cascade.Add("animation-name:test");
+ cascade.Add("animation-duration:10s");
+ cascade.Add("animation-timing-function:linear");
+ cascade.Add("animation-delay:-5s");
+ cascade.Apply();
+
+ cascade.CalculateAnimationUpdate();
+ cascade.Apply();
+ EXPECT_EQ("rgb(150, 150, 150)", cascade.ComputedValue("background-color"));
+
+ auto style = cascade.TakeStyle();
+
+ style->SetInsideLink(EInsideLink::kInsideVisitedLink);
+ EXPECT_EQ(Color(255, 0, 0),
+ style->VisitedDependentColor(GetCSSPropertyBackgroundColor()));
+
+ style->SetInsideLink(EInsideLink::kNotInsideLink);
+ EXPECT_EQ(Color(150, 150, 150),
+ style->VisitedDependentColor(GetCSSPropertyBackgroundColor()));
+}
+
+TEST_F(StyleCascadeTest, AnimatedVisitedHighPrio) {
+ AppendSheet(R"HTML(
+ @keyframes test {
+ from { color: rgb(100, 100, 100); }
+ to { color: rgb(200, 200, 200); }
+ }
+ )HTML");
+
+ TestCascade cascade(GetDocument());
+ cascade.Add("color:red");
+ cascade.Add("animation:test 10s -5s linear");
+ cascade.Apply();
+
+ cascade.CalculateAnimationUpdate();
+ cascade.Apply();
+ EXPECT_EQ("rgb(150, 150, 150)", cascade.ComputedValue("color"));
+
+ auto style = cascade.TakeStyle();
+
+ style->SetInsideLink(EInsideLink::kInsideVisitedLink);
+ EXPECT_EQ(Color(150, 150, 150),
+ style->VisitedDependentColor(GetCSSPropertyColor()));
+
+ style->SetInsideLink(EInsideLink::kNotInsideLink);
+ EXPECT_EQ(Color(150, 150, 150),
+ style->VisitedDependentColor(GetCSSPropertyColor()));
+}
+
+TEST_F(StyleCascadeTest, AnimatedImportantOverrideFlag) {
+ AppendSheet(R"HTML(
+ @keyframes test {
+ from { background-color: white; }
+ to { background-color: gray; }
+ }
+ )HTML");
+
+ TestCascade cascade(GetDocument());
+ cascade.Add("animation:test 10s -5s linear");
+ cascade.Add("background-color: green !important");
+ cascade.Apply();
+ EXPECT_FALSE(cascade.State().HasImportantOverrides());
+
+ cascade.CalculateAnimationUpdate();
+ cascade.Apply();
+ EXPECT_TRUE(cascade.State().HasImportantOverrides());
+}
+
+TEST_F(StyleCascadeTest, AnimatedImportantOverrideNoFlag) {
+ AppendSheet(R"HTML(
+ @keyframes test {
+ from { background-color: white; }
+ to { background-color: gray; }
+ }
+ )HTML");
+
+ TestCascade cascade(GetDocument());
+ cascade.Add("animation:test 10s -5s linear");
+ cascade.Add("color:green !important");
+ cascade.Apply();
+ EXPECT_FALSE(cascade.State().HasImportantOverrides());
+
+ cascade.CalculateAnimationUpdate();
+ cascade.Apply();
+ EXPECT_FALSE(cascade.State().HasImportantOverrides());
+}
+
+TEST_F(StyleCascadeTest, AnimatedImportantOverrideFlagHighPriority) {
+ AppendSheet(R"HTML(
+ @keyframes test {
+ from { color: white; }
+ to { color: gray; }
+ }
+ )HTML");
+
+ // 'color' is a high priority property, and therefore applied by lookup.
+ TestCascade cascade(GetDocument());
+ cascade.Add("animation:test 10s -5s linear");
+ cascade.Add("color:green !important");
+ cascade.Apply();
+ EXPECT_FALSE(cascade.State().HasImportantOverrides());
+
+ cascade.CalculateAnimationUpdate();
+ cascade.Apply();
+ EXPECT_TRUE(cascade.State().HasImportantOverrides());
+}
+
+TEST_F(StyleCascadeTest, AnimatedImportantOverrideFlagVisited) {
+ AppendSheet(R"HTML(
+ @keyframes test {
+ from { background-color: white; }
+ to { background-color: gray; }
+ }
+ )HTML");
+
+ TestCascade cascade(GetDocument());
+ cascade.State().Style()->SetInsideLink(EInsideLink::kInsideVisitedLink);
+
+ cascade.Add(ParseDeclarationBlock("background-color:red !important"),
+ CascadeOrigin::kAuthor, CSSSelector::kMatchVisited);
+ cascade.Add("animation:test 10s -5s linear");
+ cascade.Apply();
+ EXPECT_FALSE(cascade.State().HasImportantOverrides());
+
+ cascade.CalculateAnimationUpdate();
+ cascade.Apply();
+ EXPECT_TRUE(cascade.State().HasImportantOverrides());
+}
+
TEST_F(StyleCascadeTest, AnimatePendingSubstitutionValue) {
RegisterProperty(GetDocument(), "--x", "<length>", "0px", false);
@@ -1799,17 +1931,16 @@ TEST_F(StyleCascadeTest, AnimatePendingSubstitutionValue) {
cascade.Add("animation-delay", "-5s");
cascade.Apply();
- StyleAnimator animator(cascade.State(), cascade.InnerCascade());
-
- cascade.AddAnimations();
+ cascade.CalculateAnimationUpdate();
cascade.Add("--from", "10px");
cascade.Add("--to", "20px");
- EXPECT_EQ("<interpolation>", cascade.GetValue("margin-top"));
- EXPECT_EQ("<interpolation>", cascade.GetValue("margin-right"));
- EXPECT_EQ("<interpolation>", cascade.GetValue("margin-bottom"));
- EXPECT_EQ("<interpolation>", cascade.GetValue("margin-left"));
+ cascade.Apply();
+
+ EXPECT_EQ(CascadeOrigin::kAnimation, cascade.GetOrigin("margin-top"));
+ EXPECT_EQ(CascadeOrigin::kAnimation, cascade.GetOrigin("margin-right"));
+ EXPECT_EQ(CascadeOrigin::kAnimation, cascade.GetOrigin("margin-bottom"));
+ EXPECT_EQ(CascadeOrigin::kAnimation, cascade.GetOrigin("margin-left"));
- cascade.Apply(animator);
EXPECT_EQ("15px", cascade.ComputedValue("margin-top"));
EXPECT_EQ("15px", cascade.ComputedValue("margin-right"));
EXPECT_EQ("15px", cascade.ComputedValue("margin-bottom"));
@@ -1817,7 +1948,7 @@ TEST_F(StyleCascadeTest, AnimatePendingSubstitutionValue) {
}
TEST_F(StyleCascadeTest, ForeignObjectZoomVsEffectiveZoom) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<svg>
<foreignObject id='foreign'></foreignObject>
</svg>
@@ -1828,44 +1959,54 @@ TEST_F(StyleCascadeTest, ForeignObjectZoomVsEffectiveZoom) {
ASSERT_TRUE(foreign_object);
TestCascade cascade(GetDocument(), foreign_object);
-
- cascade.Add("zoom", "200%");
- // TODO(andruud): Can't use CSSPropertyName to get -internal properties
- // yet.
- cascade.Add(CSSPropertyName(CSSPropertyID::kInternalEffectiveZoom),
- "initial");
+ cascade.Add("-internal-effective-zoom:initial !important",
+ CascadeOrigin::kUserAgent);
+ cascade.Add("zoom:200%");
cascade.Apply();
- // If both zoom and -internal-zoom exists in the cascade,
- // -internal-effective-zoom should win.
EXPECT_EQ(1.0f, cascade.TakeStyle()->EffectiveZoom());
}
TEST_F(StyleCascadeTest, ZoomCascadeOrder) {
- CSSPropertyName effective_zoom(CSSPropertyID::kInternalEffectiveZoom);
TestCascade cascade(GetDocument());
- cascade.Add("zoom", "200%");
- cascade.Add(effective_zoom, "initial");
+ cascade.Add("zoom:200%", CascadeOrigin::kUserAgent);
+ cascade.Add("-internal-effective-zoom:initial", CascadeOrigin::kUserAgent);
+ cascade.Apply();
+
+ EXPECT_EQ(1.0f, cascade.TakeStyle()->EffectiveZoom());
+}
+
+TEST_F(StyleCascadeTest, ZoomVsAll) {
+ TestCascade cascade(GetDocument());
+ cascade.Add("zoom:200%", CascadeOrigin::kUserAgent);
+ cascade.Add("all:initial");
+ cascade.Apply();
+
+ EXPECT_EQ(1.0f, cascade.TakeStyle()->EffectiveZoom());
+}
+
+TEST_F(StyleCascadeTest, InternalEffectiveZoomVsAll) {
+ TestCascade cascade(GetDocument());
+ cascade.Add("-internal-effective-zoom:200%", CascadeOrigin::kUserAgent);
+ cascade.Add("all:initial");
cascade.Apply();
EXPECT_EQ(1.0f, cascade.TakeStyle()->EffectiveZoom());
}
TEST_F(StyleCascadeTest, ZoomReversedCascadeOrder) {
- CSSPropertyName effective_zoom(CSSPropertyID::kInternalEffectiveZoom);
TestCascade cascade(GetDocument());
- cascade.Add(effective_zoom, "initial");
- cascade.Add("zoom", "200%");
+ cascade.Add("-internal-effective-zoom:initial", CascadeOrigin::kUserAgent);
+ cascade.Add("zoom:200%", CascadeOrigin::kUserAgent);
cascade.Apply();
EXPECT_EQ(2.0f, cascade.TakeStyle()->EffectiveZoom());
}
-TEST_F(StyleCascadeTest, ZoomPriority) {
- CSSPropertyName effective_zoom(CSSPropertyID::kInternalEffectiveZoom);
+TEST_F(StyleCascadeTest, ZoomImportant) {
TestCascade cascade(GetDocument());
- cascade.Add("zoom", "200%", Origin::kImportantAuthor);
- cascade.Add(effective_zoom, "initial");
+ cascade.Add("zoom:200% !important", CascadeOrigin::kUserAgent);
+ cascade.Add("-internal-effective-zoom:initial", CascadeOrigin::kAuthor);
cascade.Apply();
EXPECT_EQ(2.0f, cascade.TakeStyle()->EffectiveZoom());
@@ -1893,14 +2034,77 @@ TEST_F(StyleCascadeTest, WritingModeReversedCascadeOrder) {
TEST_F(StyleCascadeTest, WritingModePriority) {
TestCascade cascade(GetDocument());
- cascade.Add("writing-mode", "vertical-lr", Origin::kImportantAuthor);
- cascade.Add("-webkit-writing-mode", "vertical-rl", Origin::kAuthor);
+ cascade.Add("writing-mode:vertical-lr !important", Origin::kAuthor);
+ cascade.Add("-webkit-writing-mode:vertical-rl", Origin::kAuthor);
cascade.Apply();
EXPECT_EQ("vertical-lr", cascade.ComputedValue("writing-mode"));
EXPECT_EQ("vertical-lr", cascade.ComputedValue("-webkit-writing-mode"));
}
+TEST_F(StyleCascadeTest, WebkitBorderImageCascadeOrder) {
+ String gradient1("linear-gradient(rgb(0, 0, 0), rgb(0, 128, 0))");
+ String gradient2("linear-gradient(rgb(0, 0, 0), rgb(0, 200, 0))");
+
+ TestCascade cascade(GetDocument());
+ cascade.Add("-webkit-border-image", gradient1 + " round 40 / 10px / 20px",
+ Origin::kAuthor);
+ cascade.Add("border-image-source", gradient2, Origin::kAuthor);
+ cascade.Add("border-image-slice", "20", Origin::kAuthor);
+ cascade.Add("border-image-width", "6px", Origin::kAuthor);
+ cascade.Add("border-image-outset", "4px", Origin::kAuthor);
+ cascade.Add("border-image-repeat", "space", Origin::kAuthor);
+ cascade.Apply();
+
+ EXPECT_EQ(gradient2, cascade.ComputedValue("border-image-source"));
+ EXPECT_EQ("20", cascade.ComputedValue("border-image-slice"));
+ EXPECT_EQ("6px", cascade.ComputedValue("border-image-width"));
+ EXPECT_EQ("4px", cascade.ComputedValue("border-image-outset"));
+ EXPECT_EQ("space", cascade.ComputedValue("border-image-repeat"));
+}
+
+TEST_F(StyleCascadeTest, WebkitBorderImageReverseCascadeOrder) {
+ String gradient1("linear-gradient(rgb(0, 0, 0), rgb(0, 128, 0))");
+ String gradient2("linear-gradient(rgb(0, 0, 0), rgb(0, 200, 0))");
+
+ TestCascade cascade(GetDocument());
+ cascade.Add("border-image-source", gradient2, Origin::kAuthor);
+ cascade.Add("border-image-slice", "20", Origin::kAuthor);
+ cascade.Add("border-image-width", "6px", Origin::kAuthor);
+ cascade.Add("border-image-outset", "4px", Origin::kAuthor);
+ cascade.Add("border-image-repeat", "space", Origin::kAuthor);
+ cascade.Add("-webkit-border-image", gradient1 + " round 40 / 10px / 20px",
+ Origin::kAuthor);
+ cascade.Apply();
+
+ EXPECT_EQ(gradient1, cascade.ComputedValue("border-image-source"));
+ EXPECT_EQ("40 fill", cascade.ComputedValue("border-image-slice"));
+ EXPECT_EQ("10px", cascade.ComputedValue("border-image-width"));
+ EXPECT_EQ("20px", cascade.ComputedValue("border-image-outset"));
+ EXPECT_EQ("round", cascade.ComputedValue("border-image-repeat"));
+}
+
+TEST_F(StyleCascadeTest, WebkitBorderImageMixedOrder) {
+ String gradient1("linear-gradient(rgb(0, 0, 0), rgb(0, 128, 0))");
+ String gradient2("linear-gradient(rgb(0, 0, 0), rgb(0, 200, 0))");
+
+ TestCascade cascade(GetDocument());
+ cascade.Add("border-image-source", gradient2, Origin::kAuthor);
+ cascade.Add("border-image-width", "6px", Origin::kAuthor);
+ cascade.Add("-webkit-border-image", gradient1 + " round 40 / 10px / 20px",
+ Origin::kAuthor);
+ cascade.Add("border-image-slice", "20", Origin::kAuthor);
+ cascade.Add("border-image-outset", "4px", Origin::kAuthor);
+ cascade.Add("border-image-repeat", "space", Origin::kAuthor);
+ cascade.Apply();
+
+ EXPECT_EQ(gradient1, cascade.ComputedValue("border-image-source"));
+ EXPECT_EQ("20", cascade.ComputedValue("border-image-slice"));
+ EXPECT_EQ("10px", cascade.ComputedValue("border-image-width"));
+ EXPECT_EQ("4px", cascade.ComputedValue("border-image-outset"));
+ EXPECT_EQ("space", cascade.ComputedValue("border-image-repeat"));
+}
+
TEST_F(StyleCascadeTest, MarkReferenced) {
RegisterProperty(GetDocument(), "--x", "<length>", "0px", false);
RegisterProperty(GetDocument(), "--y", "<length>", "0px", false);
@@ -1916,15 +2120,63 @@ TEST_F(StyleCascadeTest, MarkReferenced) {
EXPECT_FALSE(registry->WasReferenced("--y"));
}
-TEST_F(StyleCascadeTest, InternalVisitedColorLonghand) {
- CSSPropertyName visited_color(CSSPropertyID::kInternalVisitedColor);
+TEST_F(StyleCascadeTest, MarkHasVariableReferenceLonghand) {
+ TestCascade cascade(GetDocument());
+ cascade.Add("--x", "1px");
+ cascade.Add("width", "var(--x)");
+ cascade.Apply();
+ auto style = cascade.TakeStyle();
+ EXPECT_TRUE(style->HasVariableReferenceFromNonInheritedProperty());
+}
+
+TEST_F(StyleCascadeTest, MarkHasVariableReferenceShorthand) {
+ TestCascade cascade(GetDocument());
+ cascade.Add("--x", "1px");
+ cascade.Add("margin", "var(--x)");
+ cascade.Apply();
+ auto style = cascade.TakeStyle();
+ EXPECT_TRUE(style->HasVariableReferenceFromNonInheritedProperty());
+}
+
+TEST_F(StyleCascadeTest, MarkHasVariableReferenceLonghandMissingVar) {
+ TestCascade cascade(GetDocument());
+ cascade.Add("width", "var(--x)");
+ cascade.Apply();
+ auto style = cascade.TakeStyle();
+ EXPECT_TRUE(style->HasVariableReferenceFromNonInheritedProperty());
+}
+
+TEST_F(StyleCascadeTest, MarkHasVariableReferenceShorthandMissingVar) {
+ TestCascade cascade(GetDocument());
+ cascade.Add("margin", "var(--x)");
+ cascade.Apply();
+ auto style = cascade.TakeStyle();
+ EXPECT_TRUE(style->HasVariableReferenceFromNonInheritedProperty());
+}
+TEST_F(StyleCascadeTest, NoMarkHasVariableReferenceInherited) {
TestCascade cascade(GetDocument());
- cascade.Add(visited_color, "red");
- cascade.Add("color", "green");
+ cascade.Add("color", "var(--x)");
cascade.Apply();
+ auto style = cascade.TakeStyle();
+ EXPECT_FALSE(style->HasVariableReferenceFromNonInheritedProperty());
+}
+
+TEST_F(StyleCascadeTest, NoMarkHasVariableReferenceWithoutVar) {
+ TestCascade cascade(GetDocument());
+ cascade.Add("width", "1px");
+ cascade.Apply();
+ auto style = cascade.TakeStyle();
+ EXPECT_FALSE(style->HasVariableReferenceFromNonInheritedProperty());
+}
+
+TEST_F(StyleCascadeTest, InternalVisitedColorLonghand) {
+ TestCascade cascade(GetDocument());
+ cascade.Add("color:green", CascadeOrigin::kAuthor);
+ cascade.Add("color:red", CascadeOrigin::kAuthor, CSSSelector::kMatchVisited);
cascade.State().Style()->SetInsideLink(EInsideLink::kInsideVisitedLink);
+ cascade.Apply();
EXPECT_EQ("rgb(0, 128, 0)", cascade.ComputedValue("color"));
@@ -1933,37 +2185,210 @@ TEST_F(StyleCascadeTest, InternalVisitedColorLonghand) {
EXPECT_EQ(red, cascade.TakeStyle()->VisitedDependentColor(color));
}
-TEST_F(StyleCascadeTest, VarInInternalVisitedShorthand) {
- CSSPropertyName visited_outline_color(
- CSSPropertyID::kInternalVisitedOutlineColor);
+TEST_F(StyleCascadeTest, VarInInternalVisitedColorShorthand) {
+ TestCascade cascade(GetDocument());
+ cascade.Add("--x:red", CascadeOrigin::kAuthor);
+ cascade.Add("outline:medium solid var(--x)", CascadeOrigin::kAuthor,
+ CSSSelector::kMatchVisited);
+ cascade.Add("outline-color:green", CascadeOrigin::kAuthor,
+ CSSSelector::kMatchLink);
+
+ cascade.State().Style()->SetInsideLink(EInsideLink::kInsideVisitedLink);
+ cascade.Apply();
+
+ EXPECT_EQ("rgb(0, 128, 0)", cascade.ComputedValue("outline-color"));
+
+ Color red(255, 0, 0);
+ const CSSProperty& outline_color = GetCSSPropertyOutlineColor();
+ EXPECT_EQ(red, cascade.TakeStyle()->VisitedDependentColor(outline_color));
+}
+TEST_F(StyleCascadeTest, ApplyWithFilter) {
TestCascade cascade(GetDocument());
- cascade.Add("--x", "green");
- cascade.Add("outline", "medium solid var(--x)");
+ cascade.Add("color", "blue", Origin::kAuthor);
+ cascade.Add("background-color", "green", Origin::kAuthor);
+ cascade.Add("display", "inline", Origin::kAuthor);
+ cascade.Apply();
+ cascade.Add("color", "green", Origin::kAuthor);
+ cascade.Add("background-color", "red", Origin::kAuthor);
+ cascade.Add("display", "block", Origin::kAuthor);
+ cascade.Apply(CascadeFilter(CSSProperty::kInherited, false));
+ EXPECT_EQ("rgb(0, 128, 0)", cascade.ComputedValue("color"));
+ EXPECT_EQ("rgb(0, 128, 0)", cascade.ComputedValue("background-color"));
+ EXPECT_EQ("inline", cascade.ComputedValue("display"));
+}
+
+TEST_F(StyleCascadeTest, HasAuthorBackground) {
+ Vector<String> properties = {"background-attachment"/*, "background-blend-mode",
+ "background-clip", "background-image",
+ "background-origin", "background-position-x",
+ "background-position-y", "background-size"*/};
- // Copy pending substitution value from outline-color to
- // -internal-visited-outline-color, approximating StyleResolver's behavior
- // for :visited declarations.
- const CSSValue* pending_substitution = cascade.GetCSSValue("outline-color");
- ASSERT_TRUE(pending_substitution);
- cascade.Add(visited_outline_color, pending_substitution);
- cascade.Add("outline-color", "red");
+ for (String property : properties) {
+ TestCascade cascade(GetDocument());
+ cascade.Add("-webkit-appearance", "button", Origin::kUserAgent);
+ cascade.Add(property, "unset", Origin::kAuthor);
+ cascade.Apply();
+ EXPECT_TRUE(cascade.TakeStyle()->HasAuthorBackground());
+ }
+}
- // Apply "outline-color" manually first, to ensure that
- // -internal-visited-outline-color is applied afterwards.
- cascade.Apply("outline-color");
+TEST_F(StyleCascadeTest, HasAuthorBorder) {
+ Vector<String> properties = {
+ "border-top-color", "border-right-color",
+ "border-bottom-color", "border-left-color",
+ "border-top-style", "border-right-style",
+ "border-bottom-style", "border-left-style",
+ "border-top-width", "border-right-width",
+ "border-bottom-width", "border-left-width",
+ "border-top-left-radius", "border-top-right-radius",
+ "border-bottom-left-radius", "border-bottom-right-radius",
+ "border-image-source", "border-image-slice",
+ "border-image-width", "border-image-outset",
+ "border-image-repeat"};
+
+ for (String property : properties) {
+ TestCascade cascade(GetDocument());
+ cascade.Add("-webkit-appearance", "button", Origin::kUserAgent);
+ cascade.Add(property, "unset", Origin::kAuthor);
+ cascade.Apply();
+ EXPECT_TRUE(cascade.TakeStyle()->HasAuthorBorder());
+ }
+}
- // When applying -internal-visited-outline-color, it should not modify
- // outline-color.
+TEST_F(StyleCascadeTest, NoAuthorBackgroundOrBorder) {
+ TestCascade cascade(GetDocument());
+ cascade.Add("-webkit-appearance", "button", Origin::kUserAgent);
+ cascade.Add("background-color", "red", Origin::kUserAgent);
+ cascade.Add("border-left-color", "green", Origin::kUserAgent);
+ cascade.Add("background-clip", "padding-box", Origin::kUser);
+ cascade.Add("border-right-color", "green", Origin::kUser);
cascade.Apply();
+ auto style = cascade.TakeStyle();
+ EXPECT_FALSE(style->HasAuthorBackground());
+ EXPECT_FALSE(style->HasAuthorBorder());
+}
- cascade.State().Style()->SetInsideLink(EInsideLink::kInsideVisitedLink);
+TEST_F(StyleCascadeTest, AnalyzeMatchResult) {
+ auto ua = CascadeOrigin::kUserAgent;
+ auto author = CascadeOrigin::kAuthor;
- EXPECT_EQ("rgb(255, 0, 0)", cascade.ComputedValue("outline-color"));
+ TestCascade cascade(GetDocument());
+ cascade.Add("display:none;left:5px", ua);
+ cascade.Add("font-size:1px !important", ua);
+ cascade.Add("display:block;color:red", author);
+ cascade.Add("font-size:3px", author);
+ cascade.Apply();
- Color green(0, 128, 0);
- const CSSProperty& outline_color = GetCSSPropertyOutlineColor();
- EXPECT_EQ(green, cascade.TakeStyle()->VisitedDependentColor(outline_color));
+ EXPECT_EQ(cascade.GetPriority("display").GetOrigin(), author);
+ EXPECT_EQ(cascade.GetPriority("left").GetOrigin(), ua);
+ EXPECT_EQ(cascade.GetPriority("color").GetOrigin(), author);
+ EXPECT_EQ(cascade.GetPriority("font-size").GetOrigin(), ua);
+}
+
+TEST_F(StyleCascadeTest, AnalyzeMatchResultAll) {
+ auto ua = CascadeOrigin::kUserAgent;
+ auto author = CascadeOrigin::kAuthor;
+
+ TestCascade cascade(GetDocument());
+ cascade.Add("display:block", ua);
+ cascade.Add("font-size:1px !important", ua);
+ cascade.Add("all:unset", author);
+ cascade.Apply();
+
+ EXPECT_EQ(cascade.GetPriority("display").GetOrigin(), author);
+ EXPECT_EQ(cascade.GetPriority("font-size").GetOrigin(), ua);
+
+ // Random sample from another property affected by 'all'.
+ EXPECT_EQ(cascade.GetPriority("color").GetOrigin(), author);
+ EXPECT_EQ(cascade.GetPriority("color"), cascade.GetPriority("display"));
+}
+
+TEST_F(StyleCascadeTest, ApplyMatchResultFilter) {
+ TestCascade cascade(GetDocument());
+ cascade.Add("display:block");
+ cascade.Add("color:green");
+ cascade.Add("font-size:3px");
+ cascade.Apply();
+
+ cascade.Add("display:inline");
+ cascade.Add("color:red");
+ cascade.Apply(CascadeFilter(CSSProperty::kInherited, true));
+
+ EXPECT_EQ("inline", cascade.ComputedValue("display"));
+ EXPECT_EQ("rgb(0, 128, 0)", cascade.ComputedValue("color"));
+ EXPECT_EQ("3px", cascade.ComputedValue("font-size"));
+}
+
+TEST_F(StyleCascadeTest, ApplyMatchResultAllFilter) {
+ TestCascade cascade(GetDocument());
+ cascade.Add("color:green");
+ cascade.Add("display:block");
+ cascade.Apply();
+
+ cascade.Add("all:unset");
+ cascade.Apply(CascadeFilter(CSSProperty::kInherited, true));
+
+ EXPECT_EQ("rgb(0, 128, 0)", cascade.ComputedValue("color"));
+ EXPECT_EQ("inline", cascade.ComputedValue("display"));
+}
+
+TEST_F(StyleCascadeTest, MarkHasReferenceLonghand) {
+ TestCascade cascade(GetDocument());
+
+ cascade.Add("--x:red");
+ cascade.Add("background-color:var(--x)");
+ cascade.Apply();
+
+ EXPECT_TRUE(cascade.State()
+ .StyleRef()
+ .HasVariableReferenceFromNonInheritedProperty());
+}
+
+TEST_F(StyleCascadeTest, MarkHasReferenceShorthand) {
+ TestCascade cascade(GetDocument());
+
+ cascade.Add("--x:red");
+ cascade.Add("background:var(--x)");
+ cascade.Apply();
+
+ EXPECT_TRUE(cascade.State()
+ .StyleRef()
+ .HasVariableReferenceFromNonInheritedProperty());
+}
+
+TEST_F(StyleCascadeTest, NoMarkHasReferenceForInherited) {
+ TestCascade cascade(GetDocument());
+
+ cascade.Add("--x:red");
+ cascade.Add("--y:caption");
+ cascade.Add("color:var(--x)");
+ cascade.Add("font:var(--y)");
+ cascade.Apply();
+
+ EXPECT_FALSE(cascade.State()
+ .StyleRef()
+ .HasVariableReferenceFromNonInheritedProperty());
+}
+
+TEST_F(StyleCascadeTest, Reset) {
+ TestCascade cascade(GetDocument());
+
+ EXPECT_EQ(CascadePriority(), cascade.GetPriority("color"));
+ EXPECT_EQ(CascadePriority(), cascade.GetPriority("--x"));
+
+ cascade.Add("color:red");
+ cascade.Add("--x:red");
+ cascade.Apply(); // generation=1
+ cascade.Apply(); // generation=2
+
+ EXPECT_EQ(2u, cascade.GetPriority("color").GetGeneration());
+ EXPECT_EQ(2u, cascade.GetPriority("--x").GetGeneration());
+
+ cascade.Reset();
+
+ EXPECT_EQ(CascadePriority(), cascade.GetPriority("color"));
+ EXPECT_EQ(CascadePriority(), cascade.GetPriority("--x"));
}
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/style_resolver.cc b/chromium/third_party/blink/renderer/core/css/resolver/style_resolver.cc
index f5601fe254d..4b487f15cc4 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/style_resolver.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/style_resolver.cc
@@ -45,7 +45,6 @@
#include "third_party/blink/renderer/core/css/css_identifier_value.h"
#include "third_party/blink/renderer/core/css/css_keyframe_rule.h"
#include "third_party/blink/renderer/core/css/css_keyframes_rule.h"
-#include "third_party/blink/renderer/core/css/css_pending_interpolation_value.h"
#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/core/css/css_property_value_set.h"
#include "third_party/blink/renderer/core/css/css_reflect_value.h"
@@ -68,7 +67,6 @@
#include "third_party/blink/renderer/core/css/resolver/scoped_style_resolver.h"
#include "third_party/blink/renderer/core/css/resolver/selector_filter_parent_scope.h"
#include "third_party/blink/renderer/core/css/resolver/style_adjuster.h"
-#include "third_party/blink/renderer/core/css/resolver/style_animator.h"
#include "third_party/blink/renderer/core/css/resolver/style_builder_converter.h"
#include "third_party/blink/renderer/core/css/resolver/style_resolver_state.h"
#include "third_party/blink/renderer/core/css/resolver/style_resolver_stats.h"
@@ -114,9 +112,15 @@ void SetAnimationUpdateIfNeeded(StyleResolverState& state, Element& element) {
// If any changes to CSS Animations were detected, stash the update away for
// application after the layout object is updated if we're in the appropriate
// scope.
- if (!state.AnimationUpdate().IsEmpty())
- element.EnsureElementAnimations().CssAnimations().SetPendingUpdate(
+ if (!state.AnimationUpdate().IsEmpty()) {
+ auto& element_animations = element.EnsureElementAnimations();
+ element_animations.CssAnimations().SetPendingUpdate(
state.AnimationUpdate());
+ if (state.HasImportantOverrides())
+ element_animations.SetHasImportantOverrides();
+ if (state.HasFontAffectingAnimation())
+ element_animations.SetHasFontAffectingAnimation();
+ }
}
bool HasAnimationsOrTransitions(const StyleResolverState& state) {
@@ -125,6 +129,61 @@ bool HasAnimationsOrTransitions(const StyleResolverState& state) {
state.GetAnimatingElement()->HasAnimations());
}
+bool ShouldComputeBaseComputedStyle(const ComputedStyle* base_computed_style) {
+#if DCHECK_IS_ON()
+ // The invariant in the base computed style optimization is that as long as
+ // |IsAnimationStyleChange| is true, the computed style that would be
+ // generated by the style resolver is equivalent to the one we hold
+ // internally. To ensure this, we always compute a new style here disregarding
+ // the fact that we have a base computed style when DCHECKs are enabled, and
+ // call ValidateBaseComputedStyle() to check that the optimization was sound.
+ return true;
+#else
+ return !base_computed_style;
+#endif // !DCHECK_IS_ON()
+}
+
+// Compare the base computed style with the one we compute to validate that the
+// optimization is sound.
+bool ValidateBaseComputedStyle(const ComputedStyle* base_computed_style,
+ const ComputedStyle& computed_style) {
+#if DCHECK_IS_ON()
+ if (!base_computed_style)
+ return true;
+ // Under certain conditions ComputedStyle::operator==() may return false for
+ // differences that are permitted during an animation.
+ // The FontFaceCache version number may be increased without forcing a style
+ // recalc (see crbug.com/471079).
+ if (!base_computed_style->GetFont().IsFallbackValid())
+ return true;
+ // Images use instance equality rather than value equality (see
+ // crbug.com/781461).
+ for (CSSPropertyID id :
+ {CSSPropertyID::kBackgroundImage, CSSPropertyID::kWebkitMaskImage}) {
+ if (!CSSPropertyEquality::PropertiesEqual(
+ PropertyHandle(CSSProperty::Get(id)), *base_computed_style,
+ computed_style)) {
+ return true;
+ }
+ }
+ return *base_computed_style == computed_style;
+#else
+ return true;
+#endif // DCHECK_IS_ON()
+}
+
+// When force-computing the base computed style for validation purposes,
+// we need to reset the StyleCascade when the base computed style optimization
+// is used. This is because we don't want the computation of the base to
+// populate the cascade, as they are supposed to be empty when the optimization
+// is in use. This is to match the behavior of non-DCHECK builds.
+void MaybeResetCascade(StyleCascade* cascade) {
+#if DCHECK_IS_ON()
+ if (cascade)
+ cascade->Reset();
+#endif // DCHECK_IS_ON()
+}
+
} // namespace
static CSSPropertyValueSet* LeftToRightDeclaration() {
@@ -696,6 +755,8 @@ scoped_refptr<ComputedStyle> StyleResolver::StyleForViewport(
viewport_style->SetOverflowX(EOverflow::kAuto);
viewport_style->SetOverflowY(EOverflow::kAuto);
+ document.GetStyleEngine().ApplyVisionDeficiencyStyle(viewport_style);
+
return viewport_style;
}
@@ -763,79 +824,114 @@ scoped_refptr<ComputedStyle> StyleResolver::StyleForElement(
bool can_cache_animation_base_computed_style =
!default_parent && !default_layout_parent &&
matching_behavior == kMatchAllRules;
- const ComputedStyle* animation_base_computed_style =
- can_cache_animation_base_computed_style
- ? CachedAnimationBaseComputedStyle(state)
- : nullptr;
- if (animation_base_computed_style) {
- state.SetStyle(ComputedStyle::Clone(*animation_base_computed_style));
- if (!state.ParentStyle()) {
- state.SetParentStyle(InitialStyleForElement(GetDocument()));
- state.SetLayoutParentStyle(state.ParentStyle());
- }
- } else {
- if (state.ParentStyle()) {
- scoped_refptr<ComputedStyle> style = ComputedStyle::Create();
- style->InheritFrom(*state.ParentStyle(),
- IsAtShadowBoundary(element)
- ? ComputedStyle::kAtShadowBoundary
- : ComputedStyle::kNotAtShadowBoundary);
- state.SetStyle(std::move(style));
- } else {
- state.SetStyle(InitialStyleForElement(GetDocument()));
- state.SetParentStyle(ComputedStyle::Clone(*state.Style()));
- state.SetLayoutParentStyle(state.ParentStyle());
- if (element != GetDocument().documentElement()) {
- // Strictly, we should only allow the root element to inherit from
- // initial styles, but we allow getComputedStyle() for connected
- // elements outside the flat tree rooted at an unassigned shadow host
- // child, or Shadow DOM V0 insertion points.
- DCHECK(element->IsV0InsertionPoint() ||
- (IsShadowHost(element->parentNode()) &&
- !LayoutTreeBuilderTraversal::ParentElement(*element)));
- state.Style()->SetIsEnsuredOutsideFlatTree();
- }
- }
+ STACK_UNINITIALIZED StyleCascade cascade(state);
+ StyleCascade* cascade_ptr =
+ RuntimeEnabledFeatures::CSSCascadeEnabled() ? &cascade : nullptr;
+
+ ApplyBaseComputedStyle(element, state, cascade_ptr,
+ cascade.MutableMatchResult(), matching_behavior,
+ can_cache_animation_base_computed_style);
+
+ if (ApplyAnimatedStandardProperties(state, cascade_ptr)) {
+ INCREMENT_STYLE_STATS_COUNTER(GetDocument().GetStyleEngine(),
+ styles_animated, 1);
+ StyleAdjuster::AdjustComputedStyle(state, element);
}
- // contenteditable attribute (implemented by -webkit-user-modify) should
- // be propagated from shadow host to distributed node.
- if (state.DistributedToV0InsertionPoint() || element->AssignedSlot()) {
- if (Element* parent = element->parentElement()) {
- if (const ComputedStyle* style_of_shadow_host =
- parent->GetComputedStyle()) {
- state.Style()->SetUserModify(style_of_shadow_host->UserModify());
+ if (IsA<HTMLBodyElement>(*element))
+ GetDocument().GetTextLinkColors().SetTextColor(state.Style()->GetColor());
+
+ SetAnimationUpdateIfNeeded(state, *element);
+
+ if (state.Style()->HasViewportUnits())
+ GetDocument().SetHasViewportUnits();
+
+ if (state.Style()->HasRemUnits())
+ GetDocument().GetStyleEngine().SetUsesRemUnit(true);
+
+ if (state.Style()->HasGlyphRelativeUnits())
+ UseCounter::Count(GetDocument(), WebFeature::kHasGlyphRelativeUnits);
+
+ // Now return the style.
+ return state.TakeStyle();
+}
+
+void StyleResolver::InitStyleAndApplyInheritance(Element& element,
+ StyleResolverState& state) {
+ if (state.ParentStyle()) {
+ scoped_refptr<ComputedStyle> style = ComputedStyle::Create();
+ style->InheritFrom(*state.ParentStyle(),
+ IsAtShadowBoundary(&element)
+ ? ComputedStyle::kAtShadowBoundary
+ : ComputedStyle::kNotAtShadowBoundary);
+ state.SetStyle(std::move(style));
+
+ // contenteditable attribute (implemented by -webkit-user-modify) should
+ // be propagated from shadow host to distributed node.
+ if (state.DistributedToV0InsertionPoint() || element.AssignedSlot()) {
+ if (Element* parent = element.parentElement()) {
+ if (const ComputedStyle* shadow_host_style = parent->GetComputedStyle())
+ state.Style()->SetUserModify(shadow_host_style->UserModify());
}
}
+ } else {
+ state.SetStyle(InitialStyleForElement(GetDocument()));
+ state.SetParentStyle(ComputedStyle::Clone(*state.Style()));
+ state.SetLayoutParentStyle(state.ParentStyle());
+ if (element != GetDocument().documentElement()) {
+ // Strictly, we should only allow the root element to inherit from
+ // initial styles, but we allow getComputedStyle() for connected
+ // elements outside the flat tree rooted at an unassigned shadow host
+ // child, or Shadow DOM V0 insertion points.
+ DCHECK(element.IsV0InsertionPoint() ||
+ (IsShadowHost(element.parentNode()) &&
+ !LayoutTreeBuilderTraversal::ParentElement(element)));
+ state.Style()->SetIsEnsuredOutsideFlatTree();
+ }
}
- if (element->IsLink()) {
+ if (element.IsLink()) {
state.Style()->SetIsLink();
EInsideLink link_state = state.ElementLinkState();
if (link_state != EInsideLink::kNotInsideLink) {
bool force_visited = false;
- probe::ForcePseudoState(element, CSSSelector::kPseudoVisited,
+ probe::ForcePseudoState(&element, CSSSelector::kPseudoVisited,
&force_visited);
if (force_visited)
link_state = EInsideLink::kInsideVisitedLink;
}
state.Style()->SetInsideLink(link_state);
}
+}
+
+void StyleResolver::ApplyBaseComputedStyle(
+ Element* element,
+ StyleResolverState& state,
+ StyleCascade* cascade,
+ MatchResult& match_result,
+ RuleMatchingBehavior matching_behavior,
+ bool can_cache_animation_base_computed_style) {
+ const ComputedStyle* animation_base_computed_style =
+ can_cache_animation_base_computed_style
+ ? CachedAnimationBaseComputedStyle(state)
+ : nullptr;
+
+ if (ShouldComputeBaseComputedStyle(animation_base_computed_style)) {
+ InitStyleAndApplyInheritance(*element, state);
- if (!animation_base_computed_style) {
GetDocument().GetStyleEngine().EnsureUAStyleForElement(*element);
ElementRuleCollector collector(state.ElementContext(), selector_filter_,
- state.Style());
+ match_result, state.Style(),
+ state.Style()->InsideLink());
MatchAllRules(state, collector,
matching_behavior != kMatchAllRulesExcludingSMIL);
// TODO(dominicc): Remove this counter when Issue 590014 is fixed.
if (element->HasTagName(html_names::kSummaryTag)) {
- MatchedPropertiesRange matched_range =
- collector.MatchedResult().AuthorRules();
+ MatchedPropertiesRange matched_range = match_result.AuthorRules();
for (const auto& matched : matched_range) {
const CSSValue* value =
matched.properties->GetPropertyCSSValue(CSSPropertyID::kDisplay);
@@ -866,7 +962,13 @@ scoped_refptr<ComputedStyle> StyleResolver::StyleForElement(
if (state.HasDirAutoAttribute())
state.Style()->SetSelfOrAncestorHasDirAutoAttribute(true);
- ApplyMatchedProperties(state, collector.MatchedResult());
+ if (RuntimeEnabledFeatures::CSSCascadeEnabled()) {
+ DCHECK(cascade);
+ CascadeAndApplyMatchedProperties(state, *cascade);
+ } else {
+ ApplyMatchedProperties(state, match_result);
+ }
+
ApplyCallbackSelectors(state);
// Cache our original display.
@@ -874,39 +976,24 @@ scoped_refptr<ComputedStyle> StyleResolver::StyleForElement(
StyleAdjuster::AdjustComputedStyle(state, element);
- if (can_cache_animation_base_computed_style)
- UpdateAnimationBaseComputedStyle(state);
- } else {
- INCREMENT_STYLE_STATS_COUNTER(GetDocument().GetStyleEngine(),
- base_styles_used, 1);
+ if (can_cache_animation_base_computed_style) {
+ DCHECK(ValidateBaseComputedStyle(animation_base_computed_style,
+ *state.Style()));
+ if (!animation_base_computed_style)
+ UpdateAnimationBaseComputedStyle(state);
+ }
}
- // FIXME: The CSSWG wants to specify that the effects of animations are
- // applied before important rules, but this currently happens here as we
- // require adjustment to have happened before deciding which properties to
- // transition.
- if (ApplyAnimatedStandardProperties(state)) {
+ if (animation_base_computed_style) {
+ state.SetStyle(ComputedStyle::Clone(*animation_base_computed_style));
+ if (!state.ParentStyle()) {
+ state.SetParentStyle(InitialStyleForElement(GetDocument()));
+ state.SetLayoutParentStyle(state.ParentStyle());
+ }
+ MaybeResetCascade(cascade);
INCREMENT_STYLE_STATS_COUNTER(GetDocument().GetStyleEngine(),
- styles_animated, 1);
- StyleAdjuster::AdjustComputedStyle(state, element);
+ base_styles_used, 1);
}
-
- if (IsA<HTMLBodyElement>(*element))
- GetDocument().GetTextLinkColors().SetTextColor(state.Style()->GetColor());
-
- SetAnimationUpdateIfNeeded(state, *element);
-
- if (state.Style()->HasViewportUnits())
- GetDocument().SetHasViewportUnits();
-
- if (state.Style()->HasRemUnits())
- GetDocument().GetStyleEngine().SetUsesRemUnit(true);
-
- if (state.Style()->HasGlyphRelativeUnits())
- UseCounter::Count(GetDocument(), WebFeature::kHasGlyphRelativeUnits);
-
- // Now return the style.
- return state.TakeStyle();
}
CompositorKeyframeValue* StyleResolver::CreateCompositorKeyframeValueSnapshot(
@@ -922,15 +1009,17 @@ CompositorKeyframeValue* StyleResolver::CreateCompositorKeyframeValueSnapshot(
state.SetStyle(ComputedStyle::Clone(base_style));
if (value) {
if (RuntimeEnabledFeatures::CSSCascadeEnabled()) {
- StyleCascade cascade(state);
- auto name = property.GetCSSPropertyName();
- cascade.Add(name, value, StyleCascade::Origin::kAuthor);
+ STACK_UNINITIALIZED StyleCascade cascade(state);
+ auto* set = MakeGarbageCollected<MutableCSSPropertyValueSet>(
+ state.GetParserMode());
+ set->SetProperty(property.GetCSSProperty().PropertyID(), *value);
+ cascade.MutableMatchResult().FinishAddingUARules();
+ cascade.MutableMatchResult().FinishAddingUserRules();
+ cascade.MutableMatchResult().AddMatchedProperties(set);
cascade.Apply();
} else {
StyleBuilder::ApplyProperty(property.GetCSSPropertyName(), state, *value);
- state.GetFontBuilder().CreateFont(
- state.GetDocument().GetStyleEngine().GetFontSelector(),
- state.StyleRef());
+ state.GetFontBuilder().CreateFont(state.StyleRef(), parent_style);
CSSVariableResolver(state).ResolveVariableDefinitions();
}
}
@@ -951,39 +1040,52 @@ bool StyleResolver::PseudoStyleForElementInternal(
const ComputedStyle* animation_base_computed_style =
CachedAnimationBaseComputedStyle(state);
- if (animation_base_computed_style) {
- state.SetStyle(ComputedStyle::Clone(*animation_base_computed_style));
- } else if (pseudo_style_request.AllowsInheritance(state.ParentStyle())) {
- scoped_refptr<ComputedStyle> style = ComputedStyle::Create();
- style->InheritFrom(*state.ParentStyle());
- state.SetStyle(std::move(style));
- } else {
- // ::backdrop inherits from initial styles. All other pseudo elements
- // inherit from their originating element (::before/::after), or originating
- // element descendants (::first-line/::first-letter).
- DCHECK(pseudo_style_request.pseudo_id == kPseudoIdBackdrop);
- state.SetStyle(InitialStyleForElement(GetDocument()));
- state.SetParentStyle(ComputedStyle::Clone(*state.Style()));
- }
-
- state.Style()->SetStyleType(pseudo_style_request.pseudo_id);
-
// Since we don't use pseudo-elements in any of our quirk/print
// user agent rules, don't waste time walking those rules.
- if (!animation_base_computed_style) {
+ STACK_UNINITIALIZED StyleCascade cascade(state);
+ StyleCascade* cascade_ptr =
+ RuntimeEnabledFeatures::CSSCascadeEnabled() ? &cascade : nullptr;
+
+ if (ShouldComputeBaseComputedStyle(animation_base_computed_style)) {
+ if (pseudo_style_request.AllowsInheritance(state.ParentStyle())) {
+ scoped_refptr<ComputedStyle> style = ComputedStyle::Create();
+ style->InheritFrom(*state.ParentStyle());
+ state.SetStyle(std::move(style));
+ } else {
+ // ::backdrop inherits from initial styles. All other pseudo elements
+ // inherit from their originating element (::before/::after), or
+ // originating element descendants (::first-line/::first-letter).
+ DCHECK(pseudo_style_request.pseudo_id == kPseudoIdBackdrop);
+ state.SetStyle(InitialStyleForElement(GetDocument()));
+ state.SetParentStyle(ComputedStyle::Clone(*state.Style()));
+ }
+ state.Style()->SetStyleType(pseudo_style_request.pseudo_id);
+
// Check UA, user and author rules.
ElementRuleCollector collector(state.ElementContext(), selector_filter_,
- state.Style());
+ cascade.MutableMatchResult(), state.Style(),
+ state.Style()->InsideLink());
collector.SetPseudoElementStyleRequest(pseudo_style_request);
// The UA sheet is supposed to set some styles to ::marker pseudo-elements,
// but that would use a slow universal element selector. So instead we apply
// the styles here as an optimization.
if (pseudo_style_request.pseudo_id == kPseudoIdMarker) {
+ // Set 'unicode-bidi: isolate'
state.Style()->SetUnicodeBidi(UnicodeBidi::kIsolate);
- state.Style()->SetFontVariantNumericSpacing(
- FontVariantNumeric::kTabularNums);
+
+ // Set 'font-variant-numeric: tabular-nums'
+ FontVariantNumeric variant_numeric;
+ variant_numeric.SetNumericSpacing(FontVariantNumeric::kTabularNums);
+ state.GetFontBuilder().SetVariantNumeric(variant_numeric);
+ UpdateFont(state);
+
+ // Don't bother matching rules if there is no style for ::marker
+ if (!state.ParentStyle()->HasPseudoElementStyle(kPseudoIdMarker)) {
+ StyleAdjuster::AdjustComputedStyle(state, nullptr);
+ return true;
+ }
}
MatchUARules(collector);
@@ -994,10 +1096,16 @@ bool StyleResolver::PseudoStyleForElementInternal(
if (tracker_)
AddMatchedRulesToTracker(collector);
- if (!collector.MatchedResult().HasMatchedProperties())
+ if (!collector.MatchedResult().HasMatchedProperties()) {
+ StyleAdjuster::AdjustComputedStyle(state, nullptr);
return false;
+ }
+
+ if (RuntimeEnabledFeatures::CSSCascadeEnabled())
+ CascadeAndApplyMatchedProperties(state, cascade);
+ else
+ ApplyMatchedProperties(state, cascade.GetMatchResult());
- ApplyMatchedProperties(state, collector.MatchedResult());
ApplyCallbackSelectors(state);
// Cache our original display.
@@ -1007,14 +1115,20 @@ bool StyleResolver::PseudoStyleForElementInternal(
// in the StyleAdjuster::AdjustComputedStyle code.
StyleAdjuster::AdjustComputedStyle(state, nullptr);
- UpdateAnimationBaseComputedStyle(state);
+ DCHECK(ValidateBaseComputedStyle(animation_base_computed_style,
+ *state.Style()));
+
+ if (!animation_base_computed_style)
+ UpdateAnimationBaseComputedStyle(state);
}
- // FIXME: The CSSWG wants to specify that the effects of animations are
- // applied before important rules, but this currently happens here as we
- // require adjustment to have happened before deciding which properties to
- // transition.
- if (ApplyAnimatedStandardProperties(state))
+ if (animation_base_computed_style) {
+ state.SetStyle(ComputedStyle::Clone(*animation_base_computed_style));
+ state.Style()->SetStyleType(pseudo_style_request.pseudo_id);
+ MaybeResetCascade(cascade_ptr);
+ }
+
+ if (ApplyAnimatedStandardProperties(state, cascade_ptr))
StyleAdjuster::AdjustComputedStyle(state, nullptr);
GetDocument().GetStyleEngine().IncStyleForElementCount();
@@ -1073,7 +1187,10 @@ scoped_refptr<const ComputedStyle> StyleResolver::StyleForPage(int page_index) {
style->InheritFrom(*root_element_style);
state.SetStyle(std::move(style));
- PageRuleCollector collector(root_element_style, page_index);
+ STACK_UNINITIALIZED StyleCascade cascade(state);
+
+ PageRuleCollector collector(root_element_style, page_index,
+ cascade.MutableMatchResult());
collector.MatchPageRules(
CSSDefaultStyleSheets::Instance().DefaultPrintStyle());
@@ -1086,16 +1203,21 @@ scoped_refptr<const ComputedStyle> StyleResolver::StyleForPage(int page_index) {
NeedsApplyPass needs_apply_pass;
const MatchResult& result = collector.MatchedResult();
- ApplyMatchedProperties<kAnimationPropertyPriority, kUpdateNeedsApplyPass>(
- state, result.AllRules(), false, inherited_only, needs_apply_pass);
- ApplyMatchedProperties<kHighPropertyPriority, kCheckNeedsApplyPass>(
- state, result.AllRules(), false, inherited_only, needs_apply_pass);
- // If our font got dirtied, go ahead and update it now.
- UpdateFont(state);
+ if (RuntimeEnabledFeatures::CSSCascadeEnabled()) {
+ cascade.Apply();
+ } else {
+ ApplyMatchedProperties<kAnimationPropertyPriority, kUpdateNeedsApplyPass>(
+ state, result.AllRules(), false, inherited_only, needs_apply_pass);
+ ApplyMatchedProperties<kHighPropertyPriority, kCheckNeedsApplyPass>(
+ state, result.AllRules(), false, inherited_only, needs_apply_pass);
- ApplyMatchedProperties<kLowPropertyPriority, kCheckNeedsApplyPass>(
- state, result.AllRules(), false, inherited_only, needs_apply_pass);
+ // If our font got dirtied, go ahead and update it now.
+ UpdateFont(state);
+
+ ApplyMatchedProperties<kLowPropertyPriority, kCheckNeedsApplyPass>(
+ state, result.AllRules(), false, inherited_only, needs_apply_pass);
+ }
LoadPendingResources(state);
@@ -1146,8 +1268,7 @@ scoped_refptr<const ComputedStyle> StyleResolver::StyleForText(
}
void StyleResolver::UpdateFont(StyleResolverState& state) {
- state.GetFontBuilder().CreateFont(
- GetDocument().GetStyleEngine().GetFontSelector(), state.StyleRef());
+ state.GetFontBuilder().CreateFont(state.StyleRef(), state.ParentStyle());
state.SetConversionFontSizes(CSSToLengthConversionData::FontSizes(
state.Style(), state.RootElementStyle()));
state.SetConversionZoom(state.Style()->EffectiveZoom());
@@ -1162,8 +1283,10 @@ StyleRuleList* StyleResolver::StyleRulesForElement(Element* element,
unsigned rules_to_include) {
DCHECK(element);
StyleResolverState state(GetDocument(), *element);
+ MatchResult match_result;
ElementRuleCollector collector(state.ElementContext(), selector_filter_,
- state.Style());
+ match_result, state.Style(),
+ EInsideLink::kNotInsideLink);
collector.SetMode(SelectorChecker::kCollectingStyleRules);
CollectPseudoRulesForElement(*element, collector, kPseudoIdNone,
rules_to_include);
@@ -1176,8 +1299,10 @@ RuleIndexList* StyleResolver::PseudoCSSRulesForElement(
unsigned rules_to_include) {
DCHECK(element);
StyleResolverState state(GetDocument(), *element);
+ MatchResult match_result;
ElementRuleCollector collector(state.ElementContext(), selector_filter_,
- state.Style());
+ match_result, state.Style(),
+ EInsideLink::kNotInsideLink);
collector.SetMode(SelectorChecker::kCollectingCSSRules);
CollectPseudoRulesForElement(*element, collector, pseudo_id,
rules_to_include);
@@ -1211,7 +1336,9 @@ void StyleResolver::CollectPseudoRulesForElement(
}
}
-bool StyleResolver::ApplyAnimatedStandardProperties(StyleResolverState& state) {
+bool StyleResolver::ApplyAnimatedStandardProperties(
+ StyleResolverState& state,
+ StyleCascade* cascade) {
Element& element = state.GetElement();
// The animating element may be this element, the pseudo element we are
@@ -1222,12 +1349,12 @@ bool StyleResolver::ApplyAnimatedStandardProperties(StyleResolverState& state) {
DCHECK(animating_element == &element || !animating_element ||
animating_element->ParentOrShadowHostElement() == element);
- if (state.Style()->Animations() ||
- (animating_element && animating_element->HasAnimations())) {
- if (!state.IsAnimationInterpolationMapReady())
- CalculateAnimationUpdate(state);
- } else if (!state.Style()->Transitions()) {
+ if (!HasAnimationsOrTransitions(state))
return false;
+
+ if (!state.IsAnimationInterpolationMapReady() ||
+ RuntimeEnabledFeatures::CSSCascadeEnabled()) {
+ CalculateAnimationUpdate(state);
}
CSSAnimations::CalculateCompositorAnimationUpdate(
@@ -1243,36 +1370,43 @@ bool StyleResolver::ApplyAnimatedStandardProperties(StyleResolverState& state) {
if (state.AnimationUpdate().IsEmpty())
return false;
- const ActiveInterpolationsMap& animations_map =
+ const ActiveInterpolationsMap& standard_animations =
state.AnimationUpdate().ActiveInterpolationsForStandardAnimations();
- const ActiveInterpolationsMap& transitions_map =
+ const ActiveInterpolationsMap& standard_transitions =
state.AnimationUpdate().ActiveInterpolationsForStandardTransitions();
+ const ActiveInterpolationsMap& custom_animations =
+ state.AnimationUpdate().ActiveInterpolationsForCustomAnimations();
+ const ActiveInterpolationsMap& custom_transitions =
+ state.AnimationUpdate().ActiveInterpolationsForCustomTransitions();
if (RuntimeEnabledFeatures::CSSCascadeEnabled()) {
- // TODO(crbug.com/985049): Use main cascade.
- //
- // For now, we use a dedicated cascade for animation of standard properties.
- // A StyleCascade is required, because otherwise we can't resolve any var()
- // references that may appear in keyframes. Ultimately, we should use ONE
- // cascade for everything, but this is not yet possible.
- using Origin = StyleCascade::Origin;
- StyleCascade cascade(state);
- StyleAnimator animator(state, cascade);
- CascadeInterpolations(cascade, animations_map, Origin::kAnimation);
- CascadeInterpolations(cascade, transitions_map, Origin::kTransition);
- cascade.Apply(animator);
+ DCHECK(cascade);
+ cascade->AddInterpolations(&standard_animations, CascadeOrigin::kAnimation);
+ cascade->AddInterpolations(&standard_transitions,
+ CascadeOrigin::kTransition);
+ cascade->AddInterpolations(&custom_animations, CascadeOrigin::kAnimation);
+ cascade->AddInterpolations(&custom_transitions, CascadeOrigin::kTransition);
+
+ CascadeFilter filter;
+ if (IsForcedColorsModeEnabled(state))
+ filter = filter.Add(CSSProperty::kIsAffectedByForcedColors, true);
+ if (state.Style()->StyleType() == kPseudoIdMarker)
+ filter = filter.Add(CSSProperty::kValidForMarker, false);
+ filter = filter.Add(CSSProperty::kAnimation, true);
+
+ cascade->Apply(filter);
} else {
ApplyAnimatedStandardProperties<kHighPropertyPriority>(state,
- animations_map);
- ApplyAnimatedStandardProperties<kHighPropertyPriority>(state,
- transitions_map);
+ standard_animations);
+ ApplyAnimatedStandardProperties<kHighPropertyPriority>(
+ state, standard_transitions);
UpdateFont(state);
ApplyAnimatedStandardProperties<kLowPropertyPriority>(state,
- animations_map);
+ standard_animations);
ApplyAnimatedStandardProperties<kLowPropertyPriority>(state,
- transitions_map);
+ standard_transitions);
}
// Start loading resources used by animations.
@@ -1308,6 +1442,23 @@ StyleRuleKeyframes* StyleResolver::FindKeyframesRule(
return nullptr;
}
+static bool PassesPropertyFilter(ValidPropertyFilter valid_property_filter,
+ CSSPropertyID property,
+ const Document& document) {
+ switch (valid_property_filter) {
+ case ValidPropertyFilter::kNoFilter:
+ return true;
+ case ValidPropertyFilter::kFirstLetter:
+ return CSSProperty::Get(property).IsValidForFirstLetter();
+ case ValidPropertyFilter::kCue:
+ return CSSProperty::Get(property).IsValidForCue();
+ case ValidPropertyFilter::kMarker:
+ return CSSProperty::Get(property).IsValidForMarker();
+ }
+ NOTREACHED();
+ return true;
+}
+
template <CSSPropertyPriority priority>
void StyleResolver::ApplyAnimatedStandardProperties(
StyleResolverState& state,
@@ -1328,243 +1479,22 @@ void StyleResolver::ApplyAnimatedStandardProperties(
entry.key.GetCSSProperty().IsAffectedByForcedColors() &&
state.Style()->ForcedColorAdjust() != EForcedColorAdjust::kNone)
continue;
+ if (state.Style()->StyleType() == kPseudoIdMarker &&
+ !PassesPropertyFilter(ValidPropertyFilter::kMarker, property,
+ state.GetDocument()))
+ continue;
const Interpolation& interpolation = *entry.value.front();
- if (interpolation.IsInvalidatableInterpolation()) {
+ if (IsA<InvalidatableInterpolation>(interpolation)) {
CSSInterpolationTypesMap map(state.GetDocument().GetPropertyRegistry(),
state.GetDocument());
CSSInterpolationEnvironment environment(map, state, nullptr);
InvalidatableInterpolation::ApplyStack(entry.value, environment);
} else {
- ToTransitionInterpolation(interpolation).Apply(state);
+ To<TransitionInterpolation>(interpolation).Apply(state);
}
}
}
-static inline bool IsValidCueStyleProperty(CSSPropertyID id) {
- switch (id) {
- case CSSPropertyID::kBackground:
- case CSSPropertyID::kBackgroundAttachment:
- case CSSPropertyID::kBackgroundClip:
- case CSSPropertyID::kBackgroundColor:
- case CSSPropertyID::kBackgroundImage:
- case CSSPropertyID::kBackgroundOrigin:
- case CSSPropertyID::kBackgroundPosition:
- case CSSPropertyID::kBackgroundPositionX:
- case CSSPropertyID::kBackgroundPositionY:
- case CSSPropertyID::kBackgroundRepeat:
- case CSSPropertyID::kBackgroundRepeatX:
- case CSSPropertyID::kBackgroundRepeatY:
- case CSSPropertyID::kBackgroundSize:
- case CSSPropertyID::kColor:
- case CSSPropertyID::kFont:
- case CSSPropertyID::kFontFamily:
- case CSSPropertyID::kFontSize:
- case CSSPropertyID::kFontStretch:
- case CSSPropertyID::kFontStyle:
- case CSSPropertyID::kFontVariant:
- case CSSPropertyID::kFontWeight:
- case CSSPropertyID::kLineHeight:
- case CSSPropertyID::kOpacity:
- case CSSPropertyID::kOutline:
- case CSSPropertyID::kOutlineColor:
- case CSSPropertyID::kOutlineOffset:
- case CSSPropertyID::kOutlineStyle:
- case CSSPropertyID::kOutlineWidth:
- case CSSPropertyID::kVisibility:
- case CSSPropertyID::kWhiteSpace:
- // FIXME: 'text-decoration' shorthand to be handled when available.
- // See https://chromiumcodereview.appspot.com/19516002 for details.
- case CSSPropertyID::kTextDecoration:
- case CSSPropertyID::kTextShadow:
- case CSSPropertyID::kBorderStyle:
- return true;
- case CSSPropertyID::kTextDecorationLine:
- case CSSPropertyID::kTextDecorationStyle:
- case CSSPropertyID::kTextDecorationColor:
- case CSSPropertyID::kTextDecorationSkipInk:
- return true;
- case CSSPropertyID::kFontVariationSettings:
- return true;
- default:
- break;
- }
- return false;
-}
-
-static inline bool IsValidFirstLetterStyleProperty(CSSPropertyID id) {
- switch (id) {
- // Valid ::first-letter properties listed in spec:
- // https://drafts.csswg.org/css-pseudo-4/#first-letter-styling
- case CSSPropertyID::kBackgroundAttachment:
- case CSSPropertyID::kBackgroundBlendMode:
- case CSSPropertyID::kBackgroundClip:
- case CSSPropertyID::kBackgroundColor:
- case CSSPropertyID::kBackgroundImage:
- case CSSPropertyID::kBackgroundOrigin:
- case CSSPropertyID::kBackgroundPosition:
- case CSSPropertyID::kBackgroundPositionX:
- case CSSPropertyID::kBackgroundPositionY:
- case CSSPropertyID::kBackgroundRepeat:
- case CSSPropertyID::kBackgroundRepeatX:
- case CSSPropertyID::kBackgroundRepeatY:
- case CSSPropertyID::kBackgroundSize:
- case CSSPropertyID::kBorderBlockEnd:
- case CSSPropertyID::kBorderBlockEndColor:
- case CSSPropertyID::kBorderBlockEndStyle:
- case CSSPropertyID::kBorderBlockEndWidth:
- case CSSPropertyID::kBorderBlockStart:
- case CSSPropertyID::kBorderBlockStartColor:
- case CSSPropertyID::kBorderBlockStartStyle:
- case CSSPropertyID::kBorderBlockStartWidth:
- case CSSPropertyID::kBorderBottomColor:
- case CSSPropertyID::kBorderBottomLeftRadius:
- case CSSPropertyID::kBorderBottomRightRadius:
- case CSSPropertyID::kBorderBottomStyle:
- case CSSPropertyID::kBorderBottomWidth:
- case CSSPropertyID::kBorderImageOutset:
- case CSSPropertyID::kBorderImageRepeat:
- case CSSPropertyID::kBorderImageSlice:
- case CSSPropertyID::kBorderImageSource:
- case CSSPropertyID::kBorderImageWidth:
- case CSSPropertyID::kBorderInlineEnd:
- case CSSPropertyID::kBorderInlineEndColor:
- case CSSPropertyID::kBorderInlineEndStyle:
- case CSSPropertyID::kBorderInlineEndWidth:
- case CSSPropertyID::kBorderInlineStart:
- case CSSPropertyID::kBorderInlineStartColor:
- case CSSPropertyID::kBorderInlineStartStyle:
- case CSSPropertyID::kBorderInlineStartWidth:
- case CSSPropertyID::kBorderLeftColor:
- case CSSPropertyID::kBorderLeftStyle:
- case CSSPropertyID::kBorderLeftWidth:
- case CSSPropertyID::kBorderRightColor:
- case CSSPropertyID::kBorderRightStyle:
- case CSSPropertyID::kBorderRightWidth:
- case CSSPropertyID::kBorderTopColor:
- case CSSPropertyID::kBorderTopLeftRadius:
- case CSSPropertyID::kBorderTopRightRadius:
- case CSSPropertyID::kBorderTopStyle:
- case CSSPropertyID::kBorderTopWidth:
- case CSSPropertyID::kBoxShadow:
- case CSSPropertyID::kColor:
- case CSSPropertyID::kFloat:
- case CSSPropertyID::kFontFamily:
- case CSSPropertyID::kFontFeatureSettings:
- case CSSPropertyID::kFontKerning:
- case CSSPropertyID::kFontOpticalSizing:
- case CSSPropertyID::kFontSize:
- case CSSPropertyID::kFontSizeAdjust:
- case CSSPropertyID::kFontStretch:
- case CSSPropertyID::kFontStyle:
- case CSSPropertyID::kFontVariant:
- case CSSPropertyID::kFontVariantCaps:
- case CSSPropertyID::kFontVariantLigatures:
- case CSSPropertyID::kFontVariantNumeric:
- case CSSPropertyID::kFontVariantEastAsian:
- case CSSPropertyID::kFontVariationSettings:
- case CSSPropertyID::kFontWeight:
- case CSSPropertyID::kLetterSpacing:
- case CSSPropertyID::kLineHeight:
- case CSSPropertyID::kMarginBlockEnd:
- case CSSPropertyID::kMarginBlockStart:
- case CSSPropertyID::kMarginBottom:
- case CSSPropertyID::kMarginInlineEnd:
- case CSSPropertyID::kMarginInlineStart:
- case CSSPropertyID::kMarginLeft:
- case CSSPropertyID::kMarginRight:
- case CSSPropertyID::kMarginTop:
- case CSSPropertyID::kOpacity:
- case CSSPropertyID::kPaddingBottom:
- case CSSPropertyID::kPaddingLeft:
- case CSSPropertyID::kPaddingRight:
- case CSSPropertyID::kPaddingTop:
- case CSSPropertyID::kTextDecorationColor:
- case CSSPropertyID::kTextDecorationLine:
- case CSSPropertyID::kTextDecorationStyle:
- case CSSPropertyID::kTextDecorationSkipInk:
- case CSSPropertyID::kTextJustify:
- case CSSPropertyID::kTextShadow:
- case CSSPropertyID::kTextTransform:
- case CSSPropertyID::kTextUnderlinePosition:
- case CSSPropertyID::kVerticalAlign:
- case CSSPropertyID::kWebkitBorderHorizontalSpacing:
- case CSSPropertyID::kWebkitBorderImage:
- case CSSPropertyID::kWebkitBorderVerticalSpacing:
- case CSSPropertyID::kWebkitFontSmoothing:
- case CSSPropertyID::kWebkitMarginAfterCollapse:
- case CSSPropertyID::kWebkitMarginBeforeCollapse:
- case CSSPropertyID::kWebkitMarginBottomCollapse:
- case CSSPropertyID::kWebkitMarginCollapse:
- case CSSPropertyID::kWebkitMarginTopCollapse:
- case CSSPropertyID::kWordSpacing:
- return true;
-
- // Not directly specified in spec, but variables should be supported nearly
- // anywhere.
- case CSSPropertyID::kVariable:
- // Properties that we currently support outside of spec.
- case CSSPropertyID::kVisibility:
- return true;
-
- default:
- return false;
- }
-}
-
-static inline bool IsValidMarkerStyleProperty(CSSPropertyID id) {
- switch (id) {
- // Valid ::marker properties listed in spec:
- // https://drafts.csswg.org/css-pseudo-4/#marker-pseudo
- case CSSPropertyID::kColor:
- case CSSPropertyID::kContent:
- case CSSPropertyID::kDirection:
- case CSSPropertyID::kFont:
- case CSSPropertyID::kFontFamily:
- case CSSPropertyID::kFontFeatureSettings:
- case CSSPropertyID::kFontKerning:
- case CSSPropertyID::kFontOpticalSizing:
- case CSSPropertyID::kFontSize:
- case CSSPropertyID::kFontSizeAdjust:
- case CSSPropertyID::kFontStretch:
- case CSSPropertyID::kFontStyle:
- case CSSPropertyID::kFontVariant:
- case CSSPropertyID::kFontVariantCaps:
- case CSSPropertyID::kFontVariantEastAsian:
- case CSSPropertyID::kFontVariantLigatures:
- case CSSPropertyID::kFontVariantNumeric:
- case CSSPropertyID::kFontVariationSettings:
- case CSSPropertyID::kFontWeight:
- case CSSPropertyID::kTextCombineUpright:
- case CSSPropertyID::kUnicodeBidi:
- return true;
-
- // Not directly specified in spec, but variables should be supported nearly
- // anywhere.
- case CSSPropertyID::kVariable:
- return true;
-
- default:
- return false;
- }
-}
-
-static bool PassesPropertyFilter(ValidPropertyFilter valid_property_filter,
- CSSPropertyID property,
- const Document& document) {
- switch (valid_property_filter) {
- case ValidPropertyFilter::kNoFilter:
- return true;
- case ValidPropertyFilter::kFirstLetter:
- return IsValidFirstLetterStyleProperty(property);
- case ValidPropertyFilter::kCue:
- return IsValidCueStyleProperty(property);
- case ValidPropertyFilter::kMarker:
- return IsValidMarkerStyleProperty(property);
- }
- NOTREACHED();
- return true;
-}
-
static inline void ApplyProperty(const CSSProperty& property,
StyleResolverState& state,
const CSSValue& value,
@@ -1710,20 +1640,6 @@ void StyleResolver::ApplyProperties(StyleResolverState& state,
}
}
-static inline unsigned ComputeApplyMask(
- StyleResolverState& state,
- const MatchedProperties& matched_properties) {
- if (state.Style()->InsideLink() == EInsideLink::kNotInsideLink)
- return kApplyMaskRegular;
- static_assert(static_cast<int>(kApplyMaskRegular) ==
- static_cast<int>(CSSSelector::kMatchLink),
- "kApplyMaskRegular and kMatchLink must match");
- static_assert(static_cast<int>(kApplyMaskVisited) ==
- static_cast<int>(CSSSelector::kMatchVisited),
- "kApplyMaskVisited and kMatchVisited must match");
- return matched_properties.types_.link_match_type;
-}
-
template <CSSPropertyPriority priority,
StyleResolver::ShouldUpdateNeedsApplyPass shouldUpdateNeedsApplyPass>
void StyleResolver::ApplyMatchedProperties(StyleResolverState& state,
@@ -1732,6 +1648,8 @@ void StyleResolver::ApplyMatchedProperties(StyleResolverState& state,
bool inherited_only,
NeedsApplyPass& needs_apply_pass,
ForcedColorFilter forced_colors) {
+ DCHECK(!RuntimeEnabledFeatures::CSSCascadeEnabled());
+
if (range.IsEmpty())
return;
@@ -1740,7 +1658,13 @@ void StyleResolver::ApplyMatchedProperties(StyleResolverState& state,
return;
for (const auto& matched_properties : range) {
- const unsigned apply_mask = ComputeApplyMask(state, matched_properties);
+ static_assert(static_cast<int>(kApplyMaskRegular) ==
+ static_cast<int>(CSSSelector::kMatchLink),
+ "kApplyMaskRegular and kMatchLink must match");
+ static_assert(static_cast<int>(kApplyMaskVisited) ==
+ static_cast<int>(CSSSelector::kMatchVisited),
+ "kApplyMaskVisited and kMatchVisited must match");
+ const unsigned apply_mask = matched_properties.types_.link_match_type;
ApplyProperties<priority, shouldUpdateNeedsApplyPass>(
state, matched_properties.properties.Get(), is_important,
inherited_only, needs_apply_pass,
@@ -1809,12 +1733,12 @@ void StyleResolver::ApplyForcedColors(StyleResolverState& state,
ApplyProperty(GetCSSPropertyWebkitTextEmphasisColor(), state, *unset,
apply_mask);
- // Background colors compute to the Window system color for all values
+ // Background colors compute to the Canvas system color for all values
// except for the alpha channel.
RGBA32 prev_bg_color = state.Style()->BackgroundColor().GetColor().Rgb();
RGBA32 sys_bg_color =
LayoutTheme::GetTheme()
- .SystemColor(CSSValueID::kWindow, WebColorScheme::kLight)
+ .SystemColor(CSSValueID::kCanvas, WebColorScheme::kLight)
.Rgb();
ApplyProperty(GetCSSPropertyBackgroundColor(), state,
*cssvalue::CSSColorValue::Create(sys_bg_color), apply_mask);
@@ -1845,6 +1769,27 @@ void StyleResolver::ApplyUaForcedColors(StyleResolverState& state,
needs_apply_pass, force_colors);
}
+bool StyleResolver::CacheSuccess::EffectiveZoomChanged(
+ const ComputedStyle& style) const {
+ if (!cached_matched_properties)
+ return false;
+ return cached_matched_properties->computed_style->EffectiveZoom() !=
+ style.EffectiveZoom();
+}
+
+bool StyleResolver::CacheSuccess::FontChanged(
+ const ComputedStyle& style) const {
+ if (!cached_matched_properties)
+ return false;
+ return cached_matched_properties->computed_style->GetFontDescription() !=
+ style.GetFontDescription();
+}
+
+bool StyleResolver::CacheSuccess::EffectiveZoomOrFontChanged(
+ const ComputedStyle& style) const {
+ return EffectiveZoomChanged(style) || FontChanged(style);
+}
+
StyleResolver::CacheSuccess StyleResolver::ApplyMatchedCache(
StyleResolverState& state,
const MatchResult& match_result) {
@@ -1902,6 +1847,21 @@ StyleResolver::CacheSuccess StyleResolver::ApplyMatchedCache(
cache_hash, cached_matched_properties);
}
+void StyleResolver::MaybeAddToMatchedPropertiesCache(
+ StyleResolverState& state,
+ const CacheSuccess& cache_success,
+ const MatchResult& match_result) {
+ if (!state.IsAnimatingCustomProperties() &&
+ !cache_success.cached_matched_properties && cache_success.cache_hash &&
+ MatchedPropertiesCache::IsCacheable(state)) {
+ INCREMENT_STYLE_STATS_COUNTER(GetDocument().GetStyleEngine(),
+ matched_property_cache_added, 1);
+ matched_properties_cache_.Add(*state.Style(), *state.ParentStyle(),
+ cache_success.cache_hash,
+ match_result.GetMatchedProperties());
+ }
+}
+
void StyleResolver::ApplyCustomProperties(StyleResolverState& state,
const MatchResult& match_result,
const CacheSuccess& cache_success,
@@ -2053,15 +2013,6 @@ void StyleResolver::ApplyMatchedLowPriorityProperties(
ApplyMatchedProperties<kLowPropertyPriority, kCheckNeedsApplyPass>(
state, range, true, apply_inherited_only, needs_apply_pass);
}
- ApplyMatchedProperties<kLowPropertyPriority, kCheckNeedsApplyPass>(
- state, match_result.UaRules(), true, apply_inherited_only,
- needs_apply_pass);
-
- if (IsForcedColorsModeEnabled() &&
- state.Style()->ForcedColorAdjust() != EForcedColorAdjust::kNone) {
- ApplyForcedColors<kLowPropertyPriority>(
- state, match_result, apply_inherited_only, needs_apply_pass);
- }
if (state.Style()->HasAppearance() && !apply_inherited_only) {
// Check whether the final border and background differs from the cached UA
@@ -2073,31 +2024,29 @@ void StyleResolver::ApplyMatchedLowPriorityProperties(
state.Style()->SetHasAuthorBorder(HasAuthorBorder(state));
}
- LoadPendingResources(state);
+ ApplyMatchedProperties<kLowPropertyPriority, kCheckNeedsApplyPass>(
+ state, match_result.UaRules(), true, apply_inherited_only,
+ needs_apply_pass);
- if (!state.IsAnimatingCustomProperties() &&
- !cache_success.cached_matched_properties && cache_success.cache_hash &&
- MatchedPropertiesCache::IsCacheable(state)) {
- INCREMENT_STYLE_STATS_COUNTER(GetDocument().GetStyleEngine(),
- matched_property_cache_added, 1);
- matched_properties_cache_.Add(*state.Style(), *state.ParentStyle(),
- cache_success.cache_hash,
- match_result.GetMatchedProperties());
+ if (IsForcedColorsModeEnabled() &&
+ state.Style()->ForcedColorAdjust() != EForcedColorAdjust::kNone) {
+ ApplyForcedColors<kLowPropertyPriority>(
+ state, match_result, apply_inherited_only, needs_apply_pass);
}
+ LoadPendingResources(state);
+ MaybeAddToMatchedPropertiesCache(state, cache_success, match_result);
+
DCHECK(!state.GetFontBuilder().FontDirty());
}
void StyleResolver::ApplyMatchedProperties(StyleResolverState& state,
const MatchResult& match_result) {
+ DCHECK(!RuntimeEnabledFeatures::CSSCascadeEnabled());
+
INCREMENT_STYLE_STATS_COUNTER(GetDocument().GetStyleEngine(),
matched_property_apply, 1);
- if (RuntimeEnabledFeatures::CSSCascadeEnabled()) {
- CascadeAndApplyMatchedProperties(state, match_result);
- return;
- }
-
CacheSuccess cache_success = ApplyMatchedCache(state, match_result);
bool apply_inherited_only = cache_success.ShouldApplyInheritedOnly();
NeedsApplyPass needs_apply_pass;
@@ -2143,184 +2092,104 @@ void StyleResolver::ApplyMatchedProperties(StyleResolverState& state,
apply_inherited_only, needs_apply_pass);
}
-void StyleResolver::CascadeAndApplyMatchedProperties(
- StyleResolverState& state,
- const MatchResult& match_result) {
- DCHECK(RuntimeEnabledFeatures::CSSCascadeEnabled());
-
- CacheSuccess cache_success = ApplyMatchedCache(state, match_result);
-
- StyleCascade cascade(state);
- CascadeMatchResult(state, cascade, match_result);
-
- // We need to copy the entire cascade before applying, in case there are
- // animations.
- //
- // TODO(crbug.com/985010): Avoid this copy with non-destructive Apply.
- StyleCascade cascade_copy(cascade);
- cascade_copy.RemoveAnimationPriority();
+scoped_refptr<ComputedStyle> StyleResolver::StyleForInterpolations(
+ Element& element,
+ ActiveInterpolationsMap& interpolations) {
+ StyleResolverState state(GetDocument(), element);
+ STACK_UNINITIALIZED StyleCascade cascade(state);
- if (!cache_success.IsFullCacheHit())
+ if (RuntimeEnabledFeatures::CSSCascadeEnabled()) {
+ ApplyBaseComputedStyle(&element, state, &cascade,
+ cascade.MutableMatchResult(), kMatchAllRules, true);
+ cascade.AddInterpolations(&interpolations, CascadeOrigin::kAnimation);
cascade.Apply();
-
- if (HasAnimationsOrTransitions(state)) {
- CalculateAnimationUpdate(state);
-
- // Add animation effects for custom properties to the cascade.
- if (state.IsAnimatingCustomProperties()) {
- cache_success.SetFailed();
- CascadeAnimations(state, cascade_copy);
- CascadeTransitions(state, cascade_copy);
- StyleAnimator animator(state, cascade_copy);
- cascade_copy.Apply(animator);
- }
+ } else {
+ ApplyBaseComputedStyle(&element, state, nullptr /* cascade */,
+ cascade.MutableMatchResult(), kMatchAllRules, true);
+ ApplyAnimatedStandardProperties<kHighPropertyPriority>(state,
+ interpolations);
+ UpdateFont(state);
+ ApplyAnimatedStandardProperties<kLowPropertyPriority>(state,
+ interpolations);
}
- if (cache_success.IsFullCacheHit())
- return;
-
- // TODO(crbug.com/985025): We only support full cache hits for now.
- bool apply_inherited_only = false;
-
- // TODO(crbug.com/985027): Cascade kLowPropertyPriority.
- //
- // Ultimately NeedsApplyPass will be removed, so we don't bother fixing
- // that for this codepath. For now, just always go through the low-priority
- // properties.
- const bool important = true;
- NeedsApplyPass needs_apply_pass;
- needs_apply_pass.Set(kLowPropertyPriority, important);
- needs_apply_pass.Set(kLowPropertyPriority, !important);
- ApplyMatchedLowPriorityProperties(state, match_result, cache_success,
- apply_inherited_only, needs_apply_pass);
+ return state.TakeStyle();
}
-static void CascadeDeclaration(StyleCascade& cascade,
- const CSSPropertyName& name,
- const CSSValue& value,
- StyleCascade::Priority priority,
- unsigned apply_mask) {
- if (apply_mask & kApplyMaskRegular)
- cascade.Add(name, &value, priority);
- if (apply_mask & kApplyMaskVisited) {
- const CSSProperty* visited =
- CSSProperty::Get(name.Id()).GetVisitedProperty();
- if (visited)
- cascade.Add(visited->GetCSSPropertyName(), &value, priority);
- }
-}
-
-// https://drafts.csswg.org/css-cascade/#all-shorthand
-static void CascadeAll(StyleResolverState& state,
- StyleCascade& cascade,
- StyleCascade::Priority priority,
- unsigned apply_mask,
- ValidPropertyFilter filter,
- const CSSValue& value) {
- for (CSSPropertyID property_id : CSSPropertyIDList()) {
- using LowPrioData = CSSPropertyPriorityData<kLowPropertyPriority>;
- if (LowPrioData::PropertyHasPriority(property_id))
- continue;
+void StyleResolver::CascadeAndApplyMatchedProperties(StyleResolverState& state,
+ StyleCascade& cascade) {
+ DCHECK(RuntimeEnabledFeatures::CSSCascadeEnabled());
+ const MatchResult& result = cascade.GetMatchResult();
- const CSSProperty& property = CSSProperty::Get(property_id);
+ CacheSuccess cache_success = ApplyMatchedCache(state, result);
- if (property.IsShorthand())
- continue;
- if (!property.IsAffectedByAll())
- continue;
- if (!PassesPropertyFilter(filter, property_id, state.GetDocument()))
- continue;
+ if (cache_success.IsFullCacheHit())
+ return;
- CascadeDeclaration(cascade, CSSPropertyName(property_id), value, priority,
- apply_mask);
+ if (cache_success.ShouldApplyInheritedOnly()) {
+ cascade.Apply(CascadeFilter(CSSProperty::kInherited, false));
+ if (cache_success.EffectiveZoomOrFontChanged(state.StyleRef()))
+ cascade.Apply(CascadeFilter(CSSProperty::kInherited, true));
+ } else {
+ cascade.Apply();
}
-}
-void StyleResolver::CascadeMatchResult(StyleResolverState& state,
- StyleCascade& cascade,
- const MatchResult& result) {
- DCHECK(RuntimeEnabledFeatures::CSSCascadeEnabled());
+ CascadeAndApplyForcedColors(state, result);
- using Origin = StyleCascade::Origin;
- CascadeRange(state, cascade, result.UaRules(), Origin::kUserAgent);
- CascadeRange(state, cascade, result.AuthorRules(), Origin::kAuthor);
- CascadeRange(state, cascade, result.UserRules(), Origin::kUser);
-}
+ LoadPendingResources(state);
+ MaybeAddToMatchedPropertiesCache(state, cache_success, result);
-void StyleResolver::CascadeRange(StyleResolverState& state,
- StyleCascade& cascade,
- const MatchedPropertiesRange& range,
- StyleCascade::Origin origin) {
- DCHECK(RuntimeEnabledFeatures::CSSCascadeEnabled());
+ DCHECK(!state.GetFontBuilder().FontDirty());
+}
- if (range.IsEmpty())
+void StyleResolver::CascadeAndApplyForcedColors(StyleResolverState& state,
+ const MatchResult& result) {
+ if (!IsForcedColorsModeEnabled())
+ return;
+ if (state.Style()->ForcedColorAdjust() == EForcedColorAdjust::kNone)
return;
- for (const auto& matched_properties : range) {
- auto filter = static_cast<ValidPropertyFilter>(
- matched_properties.types_.valid_property_filter);
- uint16_t tree_order = matched_properties.types_.tree_order;
- unsigned apply_mask = ComputeApplyMask(state, matched_properties);
- const CSSPropertyValueSet* properties = matched_properties.properties.Get();
- unsigned property_count = properties->PropertyCount();
-
- for (unsigned i = 0; i < property_count; ++i) {
- CSSPropertyValueSet::PropertyReference current =
- properties->PropertyAt(i);
- CSSPropertyID property_id = current.Id();
-
- StyleCascade::Priority priority(origin, tree_order);
-
- if (current.IsImportant())
- priority = priority.AddImportance();
-
- if (property_id == CSSPropertyID::kAll) {
- CascadeAll(state, cascade, priority, apply_mask, filter,
- current.Value());
- continue;
- }
-
- using LowPrioData = CSSPropertyPriorityData<kLowPropertyPriority>;
- if (LowPrioData::PropertyHasPriority(property_id))
- continue;
+ Color prev_bg_color = state.Style()->BackgroundColor().GetColor();
- if (!PassesPropertyFilter(filter, property_id, state.GetDocument()))
- continue;
+ STACK_UNINITIALIZED StyleCascade cascade(state);
- CascadeDeclaration(cascade, current.Name(), current.Value(), priority,
- apply_mask);
- }
+ const CSSValue* unset = cssvalue::CSSUnsetValue::Create();
+ const CSSValue* canvas = CSSIdentifierValue::Create(CSSValueID::kCanvas);
+ auto* set =
+ MakeGarbageCollected<MutableCSSPropertyValueSet>(state.GetParserMode());
+ set->SetProperty(CSSPropertyID::kBackgroundColor, *canvas);
+ set->SetProperty(CSSPropertyID::kBorderBottomColor, *unset);
+ set->SetProperty(CSSPropertyID::kBorderLeftColor, *unset);
+ set->SetProperty(CSSPropertyID::kBorderRightColor, *unset);
+ set->SetProperty(CSSPropertyID::kBorderTopColor, *unset);
+ set->SetProperty(CSSPropertyID::kBoxShadow, *unset);
+ set->SetProperty(CSSPropertyID::kColor, *unset);
+ set->SetProperty(CSSPropertyID::kColumnRuleColor, *unset);
+ set->SetProperty(CSSPropertyID::kFill, *unset);
+ set->SetProperty(CSSPropertyID::kOutlineColor, *unset);
+ set->SetProperty(CSSPropertyID::kStroke, *unset);
+ set->SetProperty(CSSPropertyID::kTextDecorationColor, *unset);
+ set->SetProperty(CSSPropertyID::kTextShadow, *unset);
+ set->SetProperty(CSSPropertyID::kWebkitTapHighlightColor, *unset);
+ set->SetProperty(CSSPropertyID::kWebkitTextEmphasisColor, *unset);
+
+ cascade.MutableMatchResult().AddMatchedProperties(set);
+
+ for (const auto& matched_properties : result.UaRules()) {
+ cascade.MutableMatchResult().AddMatchedProperties(
+ matched_properties.properties,
+ matched_properties.types_.link_match_type,
+ static_cast<ValidPropertyFilter>(
+ matched_properties.types_.valid_property_filter));
}
-}
-
-void StyleResolver::CascadeTransitions(StyleResolverState& state,
- StyleCascade& cascade) {
- const auto& update = state.AnimationUpdate();
- const auto& map = update.ActiveInterpolationsForCustomTransitions();
- const auto origin = StyleCascade::Origin::kTransition;
- CascadeInterpolations(cascade, map, origin);
-}
-void StyleResolver::CascadeAnimations(StyleResolverState& state,
- StyleCascade& cascade) {
- const auto& update = state.AnimationUpdate();
- const auto& map = update.ActiveInterpolationsForCustomAnimations();
- const auto origin = StyleCascade::Origin::kAnimation;
- CascadeInterpolations(cascade, map, origin);
-}
+ CascadeFilter filter(CSSProperty::kIsAffectedByForcedColors, false);
+ cascade.Apply(filter);
-void StyleResolver::CascadeInterpolations(StyleCascade& cascade,
- const ActiveInterpolationsMap& map,
- StyleCascade::Origin origin) {
- using Type = cssvalue::CSSPendingInterpolationValue::Type;
- for (const auto& entry : map) {
- auto name = entry.key.GetCSSPropertyName();
- Type type = entry.key.IsPresentationAttribute()
- ? Type::kPresentationAttribute
- : Type::kCSSProperty;
- auto* v = cssvalue::CSSPendingInterpolationValue::Create(type);
- cascade.Add(name, v, origin);
- }
+ Color current_bg_color = state.Style()->BackgroundColor().GetColor();
+ Color bg_color(current_bg_color.Red(), current_bg_color.Green(),
+ current_bg_color.Blue(), prev_bg_color.Alpha());
+ state.Style()->SetBackgroundColor(bg_color);
}
bool StyleResolver::HasAuthorBackground(const StyleResolverState& state) {
@@ -2356,8 +2225,10 @@ void StyleResolver::ApplyCallbackSelectors(StyleResolverState& state) {
if (!watched_selectors_rule_set)
return;
+ MatchResult match_result;
ElementRuleCollector collector(state.ElementContext(), selector_filter_,
- state.Style());
+ match_result, state.Style(),
+ state.Style()->InsideLink());
collector.SetMode(SelectorChecker::kCollectingStyleRules);
collector.SetIncludeEmptyRules(true);
@@ -2404,14 +2275,14 @@ void StyleResolver::ComputeFont(Element& element,
void StyleResolver::UpdateMediaType() {
if (LocalFrameView* view = GetDocument().View()) {
bool was_print = print_media_type_;
- print_media_type_ = DeprecatedEqualIgnoringCase(view->MediaType(),
- media_type_names::kPrint);
+ print_media_type_ =
+ EqualIgnoringASCIICase(view->MediaType(), media_type_names::kPrint);
if (was_print != print_media_type_)
matched_properties_cache_.ClearViewportDependent();
}
}
-void StyleResolver::Trace(blink::Visitor* visitor) {
+void StyleResolver::Trace(Visitor* visitor) {
visitor->Trace(matched_properties_cache_);
visitor->Trace(selector_filter_);
visitor->Trace(document_);
@@ -2422,6 +2293,12 @@ bool StyleResolver::IsForcedColorsModeEnabled() const {
return GetDocument().InForcedColorsMode();
}
+bool StyleResolver::IsForcedColorsModeEnabled(
+ const StyleResolverState& state) const {
+ return IsForcedColorsModeEnabled() &&
+ state.Style()->ForcedColorAdjust() != EForcedColorAdjust::kNone;
+}
+
void StyleResolver::ApplyCascadedColorValue(StyleResolverState& state) {
if (RuntimeEnabledFeatures::CSSCascadeEnabled())
return;
@@ -2435,16 +2312,10 @@ void StyleResolver::ApplyCascadedColorValue(StyleResolverState& state) {
// As per the spec, 'color: currentColor' is treated as 'color:
// inherit'
case CSSValueID::kInherit:
- if (state.ParentStyle()->IsColorInternalText())
- state.Style()->SetIsColorInternalText(true);
- else
- state.Style()->SetColor(state.ParentStyle()->GetColor());
+ state.Style()->SetColor(state.ParentStyle()->GetColor());
break;
case CSSValueID::kInitial:
- state.Style()->SetColor(ComputedStyleInitialValues::InitialColor());
- break;
- case CSSValueID::kInternalRootColor:
- state.Style()->SetIsColorInternalText(true);
+ state.Style()->SetColor(state.Style()->InitialColorForColorScheme());
break;
default:
identifier_value = nullptr;
@@ -2455,6 +2326,8 @@ void StyleResolver::ApplyCascadedColorValue(StyleResolverState& state) {
state.Style()->SetColor(
StyleBuilderConverter::ConvertColor(state, *color_value));
}
+ } else if (state.GetElement() == GetDocument().documentElement()) {
+ state.Style()->SetColor(state.Style()->InitialColorForColorScheme());
}
if (const CSSValue* visited_color_value =
@@ -2473,7 +2346,7 @@ void StyleResolver::ApplyCascadedColorValue(StyleResolverState& state) {
break;
case CSSValueID::kInitial:
state.Style()->SetInternalVisitedColor(
- ComputedStyleInitialValues::InitialColor());
+ state.Style()->InitialColorForColorScheme());
break;
default:
identifier_value = nullptr;
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/style_resolver.h b/chromium/third_party/blink/renderer/core/css/resolver/style_resolver.h
index 452b8a7568b..7f64e22e336 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/style_resolver.h
+++ b/chromium/third_party/blink/renderer/core/css/resolver/style_resolver.h
@@ -132,9 +132,22 @@ class CORE_EXPORT StyleResolver final : public GarbageCollected<StyleResolver> {
static bool HasAuthorBackground(const StyleResolverState&);
- void Trace(blink::Visitor*);
+ scoped_refptr<ComputedStyle> StyleForInterpolations(
+ Element& target,
+ ActiveInterpolationsMap& animations);
+
+ void Trace(Visitor*);
private:
+ void InitStyleAndApplyInheritance(Element& element,
+ StyleResolverState& state);
+ void ApplyBaseComputedStyle(Element* element,
+ StyleResolverState& state,
+ StyleCascade* cascade,
+ MatchResult& match_result,
+ RuleMatchingBehavior matching_behavior,
+ bool can_cache_animation_base_computed_style);
+
// FIXME: This should probably go away, folded into FontBuilder.
void UpdateFont(StyleResolverState&);
@@ -171,7 +184,7 @@ class CORE_EXPORT StyleResolver final : public GarbageCollected<StyleResolver> {
bool is_inherited_cache_hit;
bool is_non_inherited_cache_hit;
unsigned cache_hash;
- Member<const CachedMatchedProperties> cached_matched_properties;
+ const CachedMatchedProperties* cached_matched_properties;
CacheSuccess(bool is_inherited_cache_hit,
bool is_non_inherited_cache_hit,
@@ -192,6 +205,9 @@ class CORE_EXPORT StyleResolver final : public GarbageCollected<StyleResolver> {
is_inherited_cache_hit = false;
is_non_inherited_cache_hit = false;
}
+ bool EffectiveZoomChanged(const ComputedStyle&) const;
+ bool FontChanged(const ComputedStyle&) const;
+ bool EffectiveZoomOrFontChanged(const ComputedStyle&) const;
};
// These flags indicate whether an apply pass for a given CSSPropertyPriority
@@ -221,6 +237,10 @@ class CORE_EXPORT StyleResolver final : public GarbageCollected<StyleResolver> {
};
CacheSuccess ApplyMatchedCache(StyleResolverState&, const MatchResult&);
+ void MaybeAddToMatchedPropertiesCache(StyleResolverState&,
+ const CacheSuccess&,
+ const MatchResult&);
+
void ApplyCustomProperties(StyleResolverState&,
const MatchResult&,
const CacheSuccess&,
@@ -250,25 +270,15 @@ class CORE_EXPORT StyleResolver final : public GarbageCollected<StyleResolver> {
const MatchResult& match_result,
bool apply_inherited_only,
NeedsApplyPass& needs_apply_pass);
+ void CascadeAndApplyForcedColors(StyleResolverState&, const MatchResult&);
void CascadeAndApplyMatchedProperties(StyleResolverState&,
- const MatchResult&);
- void CascadeMatchResult(StyleResolverState&,
- StyleCascade&,
- const MatchResult&);
- void CascadeRange(StyleResolverState&,
- StyleCascade&,
- const MatchedPropertiesRange&,
- StyleCascade::Origin);
- void CascadeTransitions(StyleResolverState&, StyleCascade&);
- void CascadeAnimations(StyleResolverState&, StyleCascade&);
- void CascadeInterpolations(StyleCascade&,
- const ActiveInterpolationsMap&,
- StyleCascade::Origin);
+ StyleCascade& cascade);
void CalculateAnimationUpdate(StyleResolverState&);
- bool ApplyAnimatedStandardProperties(StyleResolverState&);
+ bool ApplyAnimatedStandardProperties(StyleResolverState&,
+ StyleCascade* cascade = nullptr);
void ApplyCallbackSelectors(StyleResolverState&);
@@ -311,6 +321,7 @@ class CORE_EXPORT StyleResolver final : public GarbageCollected<StyleResolver> {
bool WasViewportResized() const { return was_viewport_resized_; }
bool IsForcedColorsModeEnabled() const;
+ bool IsForcedColorsModeEnabled(const StyleResolverState&) const;
MatchedPropertiesCache matched_properties_cache_;
Member<Document> document_;
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/style_resolver_state.cc b/chromium/third_party/blink/renderer/core/css/resolver/style_resolver_state.cc
index 9bdbdd1639f..b2cd50a4809 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/style_resolver_state.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/style_resolver_state.cc
@@ -39,13 +39,15 @@ StyleResolverState::StyleResolverState(
const ComputedStyle* parent_style,
const ComputedStyle* layout_parent_style)
: element_context_(element),
- document_(document),
+ document_(&document),
style_(nullptr),
parent_style_(parent_style),
layout_parent_style_(layout_parent_style),
is_animation_interpolation_map_ready_(false),
is_animating_custom_properties_(false),
has_dir_auto_attribute_(false),
+ cascaded_color_value_(nullptr),
+ cascaded_visited_color_value_(nullptr),
font_builder_(&document),
element_style_resources_(GetElement(),
document.DevicePixelRatio(),
@@ -204,6 +206,10 @@ StyleResolverState::ParsedPropertiesForPendingSubstitutionCache(
return *map;
}
+CSSParserMode StyleResolverState::GetParserMode() const {
+ return GetDocument().InQuirksMode() ? kHTMLQuirksMode : kHTMLStandardMode;
+}
+
const Element* StyleResolverState::GetAnimatingElement() const {
if (animating_element_type_ == AnimatingElementType::kElement)
return &GetElement();
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/style_resolver_state.h b/chromium/third_party/blink/renderer/core/css/resolver/style_resolver_state.h
index b452c08434b..24b06a2a7c5 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/style_resolver_state.h
+++ b/chromium/third_party/blink/renderer/core/css/resolver/style_resolver_state.h
@@ -30,6 +30,7 @@
#include "third_party/blink/renderer/core/css/css_pending_substitution_value.h"
#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/core/css/css_to_length_conversion_data.h"
+#include "third_party/blink/renderer/core/css/parser/css_parser_mode.h"
#include "third_party/blink/renderer/core/css/resolver/css_to_style_map.h"
#include "third_party/blink/renderer/core/css/resolver/element_resolve_context.h"
#include "third_party/blink/renderer/core/css/resolver/element_style_resources.h"
@@ -128,6 +129,27 @@ class CORE_EXPORT StyleResolverState {
is_animating_custom_properties_ = value;
}
+ // Normally, we apply all active animation effects on top of the style created
+ // by regular CSS declarations. However, !important declarations have a
+ // higher priority than animation effects [1]. If StyleCascade skipped
+ // application of some interpolation, it means something else in the cascade
+ // had a higher priority (i.e. it was !important). In this case, we can't
+ // use the base-computed-style optimization, since that code path is unable
+ // to skip any animation effects at all.
+ //
+ // [1] https://drafts.csswg.org/css-cascade-4/#cascade-origin
+ bool HasImportantOverrides() const { return has_important_overrides_; }
+ void SetHasImportantOverrides() { has_important_overrides_ = true; }
+
+ // This flag is set when applying an animation (or transition) for a font
+ // affecting property. When such properties are animated, font-relative
+ // units (e.g. em, ex) in the base style must respond to the animation.
+ // Therefore we can't use the base computed style optimization in such cases.
+ bool HasFontAffectingAnimation() const {
+ return has_font_affecting_animation_;
+ }
+ void SetHasFontAffectingAnimation() { has_font_affecting_animation_ = true; }
+
const Element* GetAnimatingElement() const;
void SetParentStyle(scoped_refptr<const ComputedStyle>);
@@ -192,6 +214,8 @@ class CORE_EXPORT StyleResolverState {
ParsedPropertiesForPendingSubstitutionCache(
const cssvalue::CSSPendingSubstitutionValue&) const;
+ CSSParserMode GetParserMode() const;
+
private:
enum class AnimatingElementType { kElement, kPseudoElement };
@@ -206,7 +230,7 @@ class CORE_EXPORT StyleResolverState {
const ComputedStyle* font_style) const;
ElementResolveContext element_context_;
- Member<Document> document_;
+ Document* document_;
// style_ is the primary output for each element's style resolve.
scoped_refptr<ComputedStyle> style_;
@@ -224,18 +248,20 @@ class CORE_EXPORT StyleResolverState {
CSSAnimationUpdate animation_update_;
bool is_animation_interpolation_map_ready_;
bool is_animating_custom_properties_;
+ bool has_important_overrides_ = false;
+ bool has_font_affecting_animation_ = false;
bool has_dir_auto_attribute_;
- Member<const CSSValue> cascaded_color_value_;
- Member<const CSSValue> cascaded_visited_color_value_;
+ const CSSValue* cascaded_color_value_;
+ const CSSValue* cascaded_visited_color_value_;
FontBuilder font_builder_;
std::unique_ptr<CachedUAStyle> cached_ua_style_;
ElementStyleResources element_style_resources_;
- Member<Element> pseudo_element_;
+ Element* pseudo_element_;
AnimatingElementType animating_element_type_;
mutable HeapHashMap<
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/style_resolver_test.cc b/chromium/third_party/blink/renderer/core/css/resolver/style_resolver_test.cc
index 927e1f143ca..7f9577045f0 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/style_resolver_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/style_resolver_test.cc
@@ -9,17 +9,29 @@
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
+#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/dom/text.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
+#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
namespace blink {
class StyleResolverTest : public PageTestBase {
+ public:
+ scoped_refptr<ComputedStyle> StyleForId(AtomicString id) {
+ Element* element = GetDocument().getElementById(id);
+ StyleResolver* resolver = GetStyleEngine().Resolver();
+ DCHECK(resolver);
+ auto style = resolver->StyleForElement(element);
+ DCHECK(style);
+ return style;
+ }
+
protected:
};
TEST_F(StyleResolverTest, StyleForTextInDisplayNone) {
- GetDocument().documentElement()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().documentElement()->setInnerHTML(R"HTML(
<body style="display:none">Text</body>
)HTML");
@@ -35,7 +47,7 @@ TEST_F(StyleResolverTest, StyleForTextInDisplayNone) {
}
TEST_F(StyleResolverTest, AnimationBaseComputedStyle) {
- GetDocument().documentElement()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().documentElement()->setInnerHTML(R"HTML(
<style>
html { font-size: 10px; }
body { font-size: 20px; }
@@ -52,12 +64,8 @@ TEST_F(StyleResolverTest, AnimationBaseComputedStyle) {
ASSERT_TRUE(resolver->StyleForElement(div));
EXPECT_EQ(20, resolver->StyleForElement(div)->FontSize());
-#if DCHECK_IS_ON()
- EXPECT_FALSE(animations.BaseComputedStyle());
-#else
ASSERT_TRUE(animations.BaseComputedStyle());
EXPECT_EQ(20, animations.BaseComputedStyle()->FontSize());
-#endif
// Getting style with customized parent style should not affect cached
// animation base computed style.
@@ -66,13 +74,111 @@ TEST_F(StyleResolverTest, AnimationBaseComputedStyle) {
EXPECT_EQ(
10,
resolver->StyleForElement(div, parent_style, parent_style)->FontSize());
-#if DCHECK_IS_ON()
- EXPECT_FALSE(animations.BaseComputedStyle());
-#else
ASSERT_TRUE(animations.BaseComputedStyle());
EXPECT_EQ(20, animations.BaseComputedStyle()->FontSize());
-#endif
EXPECT_EQ(20, resolver->StyleForElement(div)->FontSize());
}
+TEST_F(StyleResolverTest, ShadowDOMV0Crash) {
+ GetDocument().documentElement()->setInnerHTML(R"HTML(
+ <style>
+ span { display: contents; }
+ </style>
+ <summary><span id="outer"><span id="inner"></b></b></summary>
+ )HTML");
+
+ Element* outer = GetDocument().getElementById("outer");
+ Element* inner = GetDocument().getElementById("inner");
+ ShadowRoot& outer_root = outer->CreateV0ShadowRootForTesting();
+ ShadowRoot& inner_root = inner->CreateV0ShadowRootForTesting();
+ outer_root.setInnerHTML("<content>");
+ inner_root.setInnerHTML("<span>");
+
+ // Test passes if it doesn't crash.
+ UpdateAllLifecyclePhasesForTest();
+}
+
+TEST_F(StyleResolverTest, HasEmUnits) {
+ GetDocument().documentElement()->setInnerHTML("<div id=div>Test</div>");
+ UpdateAllLifecyclePhasesForTest();
+ EXPECT_FALSE(StyleForId("div")->HasEmUnits());
+
+ GetDocument().documentElement()->setInnerHTML(
+ "<div id=div style='width:1em'>Test</div>");
+ UpdateAllLifecyclePhasesForTest();
+ EXPECT_TRUE(StyleForId("div")->HasEmUnits());
+}
+
+TEST_F(StyleResolverTest, BasePresentIfFontRelativeUnitsAbsent) {
+ GetDocument().documentElement()->setInnerHTML("<div id=div>Test</div>");
+ UpdateAllLifecyclePhasesForTest();
+
+ Element* div = GetDocument().getElementById("div");
+ StyleResolver* resolver = GetStyleEngine().Resolver();
+ ASSERT_TRUE(resolver);
+ ElementAnimations& animations = div->EnsureElementAnimations();
+ animations.SetAnimationStyleChange(true);
+ // We're animating a font affecting property, but we should still be able to
+ // use the base computed style optimization, since no font-relative units
+ // exist in the base.
+ animations.SetHasFontAffectingAnimation();
+
+ EXPECT_TRUE(resolver->StyleForElement(div));
+ EXPECT_TRUE(animations.BaseComputedStyle());
+}
+
+TEST_F(StyleResolverTest, NoCrashWhenAnimatingWithoutCascade) {
+ ScopedCSSCascadeForTest scoped_cascade(false);
+
+ GetDocument().documentElement()->setInnerHTML(R"HTML(
+ <style>
+ @keyframes test {
+ from { width: 10px; }
+ to { width: 20px; }
+ }
+ div {
+ animation: test 1s;
+ }
+ </style>
+ <div id="div">Test</div>
+ )HTML");
+ UpdateAllLifecyclePhasesForTest();
+}
+
+class StyleResolverFontRelativeUnitTest
+ : public testing::WithParamInterface<const char*>,
+ public StyleResolverTest {};
+
+TEST_P(StyleResolverFontRelativeUnitTest, NoBaseIfFontRelativeUnitPresent) {
+ GetDocument().documentElement()->setInnerHTML(
+ String::Format("<div id=div style='width:1%s'>Test</div>", GetParam()));
+ UpdateAllLifecyclePhasesForTest();
+
+ Element* div = GetDocument().getElementById("div");
+ ElementAnimations& animations = div->EnsureElementAnimations();
+ animations.SetAnimationStyleChange(true);
+ animations.SetHasFontAffectingAnimation();
+
+ EXPECT_TRUE(StyleForId("div")->HasFontRelativeUnits());
+ EXPECT_FALSE(animations.BaseComputedStyle());
+}
+
+TEST_P(StyleResolverFontRelativeUnitTest,
+ BasePresentIfNoFontAffectingAnimation) {
+ GetDocument().documentElement()->setInnerHTML(
+ String::Format("<div id=div style='width:1%s'>Test</div>", GetParam()));
+ UpdateAllLifecyclePhasesForTest();
+
+ Element* div = GetDocument().getElementById("div");
+ ElementAnimations& animations = div->EnsureElementAnimations();
+ animations.SetAnimationStyleChange(true);
+
+ EXPECT_TRUE(StyleForId("div")->HasFontRelativeUnits());
+ EXPECT_TRUE(animations.BaseComputedStyle());
+}
+
+INSTANTIATE_TEST_SUITE_P(All,
+ StyleResolverFontRelativeUnitTest,
+ testing::Values("em", "rem", "ex", "ch"));
+
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/style_rule_usage_tracker.cc b/chromium/third_party/blink/renderer/core/css/resolver/style_rule_usage_tracker.cc
index a6fd1ff564a..acdb913c628 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/style_rule_usage_tracker.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/style_rule_usage_tracker.cc
@@ -15,11 +15,22 @@ StyleRuleUsageTracker::RuleListByStyleSheet StyleRuleUsageTracker::TakeDelta() {
return result;
}
+bool StyleRuleUsageTracker::InsertToUsedRulesMap(
+ const CSSStyleSheet* parent_sheet,
+ const StyleRule* rule) {
+ HeapHashSet<Member<const StyleRule>>* set =
+ used_rules_
+ .insert(parent_sheet,
+ MakeGarbageCollected<HeapHashSet<Member<const StyleRule>>>())
+ .stored_value->value;
+ return set->insert(rule).is_new_entry;
+}
+
void StyleRuleUsageTracker::Track(const CSSStyleSheet* parent_sheet,
const StyleRule* rule) {
if (!parent_sheet)
return;
- if (!used_rules_.insert(std::make_pair(parent_sheet, rule)).is_new_entry)
+ if (!InsertToUsedRulesMap(parent_sheet, rule))
return;
auto it = used_rules_delta_.find(parent_sheet);
if (it != used_rules_delta_.end()) {
@@ -31,7 +42,7 @@ void StyleRuleUsageTracker::Track(const CSSStyleSheet* parent_sheet,
}
}
-void StyleRuleUsageTracker::Trace(blink::Visitor* visitor) {
+void StyleRuleUsageTracker::Trace(Visitor* visitor) {
visitor->Trace(used_rules_);
visitor->Trace(used_rules_delta_);
}
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/style_rule_usage_tracker.h b/chromium/third_party/blink/renderer/core/css/resolver/style_rule_usage_tracker.h
index ad0d2b93b5e..d28f7d43763 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/style_rule_usage_tracker.h
+++ b/chromium/third_party/blink/renderer/core/css/resolver/style_rule_usage_tracker.h
@@ -19,10 +19,13 @@ class StyleRuleUsageTracker : public GarbageCollected<StyleRuleUsageTracker> {
void Track(const CSSStyleSheet*, const StyleRule*);
RuleListByStyleSheet TakeDelta();
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
- HeapHashSet<std::pair<Member<const CSSStyleSheet>, Member<const StyleRule>>>
+ bool InsertToUsedRulesMap(const CSSStyleSheet*, const StyleRule*);
+
+ HeapHashMap<Member<const CSSStyleSheet>,
+ Member<HeapHashSet<Member<const StyleRule>>>>
used_rules_;
RuleListByStyleSheet used_rules_delta_;
};
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/viewport_style_resolver.cc b/chromium/third_party/blink/renderer/core/css/resolver/viewport_style_resolver.cc
index a79ba7df190..e7a0ddea13f 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/viewport_style_resolver.cc
+++ b/chromium/third_party/blink/renderer/core/css/resolver/viewport_style_resolver.cc
@@ -358,13 +358,9 @@ void ViewportStyleResolver::InitialViewportChanged() {
if (has_viewport_units_)
needs_update_ = kResolve;
- auto& results = viewport_dependent_media_query_results_;
- for (unsigned i = 0; i < results.size(); i++) {
- if (initial_viewport_medium_->Eval(results[i].Expression()) !=
- results[i].Result()) {
- needs_update_ = kCollectRules;
- break;
- }
+ if (initial_viewport_medium_->DidResultsChange(
+ viewport_dependent_media_query_results_)) {
+ needs_update_ = kCollectRules;
}
if (needs_update_ == kNoUpdate)
return;
@@ -396,7 +392,7 @@ void ViewportStyleResolver::UpdateViewport(
needs_update_ = kNoUpdate;
}
-void ViewportStyleResolver::Trace(blink::Visitor* visitor) {
+void ViewportStyleResolver::Trace(Visitor* visitor) {
visitor->Trace(document_);
visitor->Trace(property_set_);
visitor->Trace(initial_viewport_medium_);
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/viewport_style_resolver.h b/chromium/third_party/blink/renderer/core/css/resolver/viewport_style_resolver.h
index f4c771b1058..aec4e463abc 100644
--- a/chromium/third_party/blink/renderer/core/css/resolver/viewport_style_resolver.h
+++ b/chromium/third_party/blink/renderer/core/css/resolver/viewport_style_resolver.h
@@ -57,7 +57,7 @@ class CORE_EXPORT ViewportStyleResolver final
void CollectViewportRulesFromAuthorSheet(const CSSStyleSheet&);
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
void Reset();
diff --git a/chromium/third_party/blink/renderer/core/css/rule_feature_set.cc b/chromium/third_party/blink/renderer/core/css/rule_feature_set.cc
index 3153b71af7d..fd7c8f3eb08 100644
--- a/chromium/third_party/blink/renderer/core/css/rule_feature_set.cc
+++ b/chromium/third_party/blink/renderer/core/css/rule_feature_set.cc
@@ -171,7 +171,7 @@ bool SupportsInvalidation(CSSSelector::PseudoType type) {
case CSSSelector::kPseudoSlotted:
case CSSSelector::kPseudoVideoPersistent:
case CSSSelector::kPseudoVideoPersistentAncestor:
- case CSSSelector::kPseudoXrImmersiveDomOverlay:
+ case CSSSelector::kPseudoXrOverlay:
return true;
case CSSSelector::kPseudoIs:
case CSSSelector::kPseudoWhere:
@@ -553,7 +553,7 @@ InvalidationSet* RuleFeatureSet::InvalidationSetForSimpleSelector(
case CSSSelector::kPseudoDefined:
case CSSSelector::kPseudoVideoPersistent:
case CSSSelector::kPseudoVideoPersistentAncestor:
- case CSSSelector::kPseudoXrImmersiveDomOverlay:
+ case CSSSelector::kPseudoXrOverlay:
case CSSSelector::kPseudoSpatialNavigationInterest:
case CSSSelector::kPseudoMultiSelectFocus:
return &EnsurePseudoInvalidationSet(selector.GetPseudoType(), type,
diff --git a/chromium/third_party/blink/renderer/core/css/rule_feature_set.h b/chromium/third_party/blink/renderer/core/css/rule_feature_set.h
index c4130255891..84d407eee41 100644
--- a/chromium/third_party/blink/renderer/core/css/rule_feature_set.h
+++ b/chromium/third_party/blink/renderer/core/css/rule_feature_set.h
@@ -99,6 +99,10 @@ class CORE_EXPORT RuleFeatureSet {
MediaQueryResultList& DeviceDependentMediaQueryResults() {
return device_dependent_media_query_results_;
}
+ bool HasMediaQueryResults() const {
+ return !viewport_dependent_media_query_results_.IsEmpty() ||
+ !device_dependent_media_query_results_.IsEmpty();
+ }
// Collect descendant and sibling invalidation sets.
void CollectInvalidationSetsForClass(InvalidationLists&,
diff --git a/chromium/third_party/blink/renderer/core/css/rule_feature_set_test.cc b/chromium/third_party/blink/renderer/core/css/rule_feature_set_test.cc
index 903c783e01d..02ce7c9fdbe 100644
--- a/chromium/third_party/blink/renderer/core/css/rule_feature_set_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/rule_feature_set_test.cc
@@ -31,7 +31,7 @@ class RuleFeatureSetTest : public testing::Test {
html->AppendChild(MakeGarbageCollected<HTMLBodyElement>(*document_));
document_->AppendChild(html);
- document_->body()->SetInnerHTMLFromString("<b><i></i></b>");
+ document_->body()->setInnerHTML("<b><i></i></b>");
}
RuleFeatureSet::SelectorPreMatch CollectFeatures(
diff --git a/chromium/third_party/blink/renderer/core/css/rule_set.cc b/chromium/third_party/blink/renderer/core/css/rule_set.cc
index 6d5d9352aec..b5b09b832f1 100644
--- a/chromium/third_party/blink/renderer/core/css/rule_set.cc
+++ b/chromium/third_party/blink/renderer/core/css/rule_set.cc
@@ -112,6 +112,7 @@ static void ExtractSelectorValues(const CSSSelector* selector,
AtomicString& class_name,
AtomicString& custom_pseudo_element_name,
AtomicString& tag_name,
+ AtomicString& part_name,
CSSSelector::PseudoType& pseudo_type) {
switch (selector->Match()) {
case CSSSelector::kId:
@@ -137,7 +138,6 @@ static void ExtractSelectorValues(const CSSSelector* selector,
case CSSSelector::kPseudoAnyLink:
case CSSSelector::kPseudoFocus:
case CSSSelector::kPseudoPlaceholder:
- case CSSSelector::kPseudoPart:
case CSSSelector::kPseudoHost:
case CSSSelector::kPseudoHostContext:
case CSSSelector::kPseudoSpatialNavigationInterest:
@@ -147,6 +147,9 @@ static void ExtractSelectorValues(const CSSSelector* selector,
case CSSSelector::kPseudoBlinkInternalElement:
custom_pseudo_element_name = selector->Value();
break;
+ case CSSSelector::kPseudoPart:
+ part_name = selector->Value();
+ break;
default:
break;
}
@@ -162,6 +165,7 @@ bool RuleSet::FindBestRuleSetAndAdd(const CSSSelector& component,
AtomicString class_name;
AtomicString custom_pseudo_element_name;
AtomicString tag_name;
+ AtomicString part_name;
CSSSelector::PseudoType pseudo_type = CSSSelector::kPseudoUnknown;
#ifndef NDEBUG
@@ -172,11 +176,11 @@ bool RuleSet::FindBestRuleSetAndAdd(const CSSSelector& component,
for (; it && it->Relation() == CSSSelector::kSubSelector;
it = it->TagHistory()) {
ExtractSelectorValues(it, id, class_name, custom_pseudo_element_name,
- tag_name, pseudo_type);
+ tag_name, part_name, pseudo_type);
}
if (it) {
ExtractSelectorValues(it, id, class_name, custom_pseudo_element_name,
- tag_name, pseudo_type);
+ tag_name, part_name, pseudo_type);
}
// Prefer rule sets in order of most likely to apply infrequently.
@@ -202,6 +206,11 @@ bool RuleSet::FindBestRuleSetAndAdd(const CSSSelector& component,
return true;
}
+ if (!part_name.IsEmpty()) {
+ part_pseudo_rules_.push_back(rule_data);
+ return true;
+ }
+
switch (pseudo_type) {
case CSSSelector::kPseudoCue:
cue_pseudo_rules_.push_back(rule_data);
@@ -231,9 +240,6 @@ bool RuleSet::FindBestRuleSetAndAdd(const CSSSelector& component,
case CSSSelector::kPseudoHostContext:
shadow_host_rules_.push_back(rule_data);
return true;
- case CSSSelector::kPseudoPart:
- part_pseudo_rules_.push_back(rule_data);
- return true;
default:
break;
}
@@ -314,10 +320,7 @@ void RuleSet::AddChildRules(const HeapVector<Member<StyleRuleBase>>& rules,
} else if (auto* page_rule = DynamicTo<StyleRulePage>(rule)) {
AddPageRule(page_rule);
} else if (auto* media_rule = DynamicTo<StyleRuleMedia>(rule)) {
- if (!media_rule->MediaQueries() ||
- medium.Eval(*media_rule->MediaQueries(),
- &features_.ViewportDependentMediaQueryResults(),
- &features_.DeviceDependentMediaQueryResults()))
+ if (MatchMediaForAddRules(medium, media_rule->MediaQueries()))
AddChildRules(media_rule->ChildRules(), medium, add_rule_flags);
} else if (auto* font_face_rule = DynamicTo<StyleRuleFontFace>(rule)) {
AddFontFaceRule(font_face_rule);
@@ -332,6 +335,18 @@ void RuleSet::AddChildRules(const HeapVector<Member<StyleRuleBase>>& rules,
}
}
+bool RuleSet::MatchMediaForAddRules(const MediaQueryEvaluator& evaluator,
+ const MediaQuerySet* media_queries) {
+ if (!media_queries)
+ return true;
+ bool match_media = evaluator.Eval(
+ *media_queries, &features_.ViewportDependentMediaQueryResults(),
+ &features_.DeviceDependentMediaQueryResults());
+ media_query_set_results_.push_back(
+ MediaQuerySetResult(*media_queries, match_media));
+ return match_media;
+}
+
void RuleSet::AddRulesFromSheet(StyleSheetContents* sheet,
const MediaQueryEvaluator& medium,
AddRuleFlags add_rule_flags) {
@@ -344,11 +359,9 @@ void RuleSet::AddRulesFromSheet(StyleSheetContents* sheet,
for (unsigned i = 0; i < import_rules.size(); ++i) {
StyleRuleImport* import_rule = import_rules[i].Get();
if (import_rule->GetStyleSheet() &&
- (!import_rule->MediaQueries() ||
- medium.Eval(*import_rule->MediaQueries(),
- &features_.ViewportDependentMediaQueryResults(),
- &features_.DeviceDependentMediaQueryResults())))
+ MatchMediaForAddRules(medium, import_rule->MediaQueries())) {
AddRulesFromSheet(import_rule->GetStyleSheet(), medium, add_rule_flags);
+ }
}
AddChildRules(sheet->ChildRules(), medium, add_rule_flags);
@@ -407,22 +420,31 @@ void RuleSet::CompactRules() {
slotted_pseudo_element_rules_.ShrinkToFit();
}
-void MinimalRuleData::Trace(blink::Visitor* visitor) {
+bool RuleSet::DidMediaQueryResultsChange(
+ const MediaQueryEvaluator& evaluator) const {
+ for (const auto& result : media_query_set_results_) {
+ if (result.Result() != evaluator.Eval(result.MediaQueries()))
+ return true;
+ }
+ return false;
+}
+
+void MinimalRuleData::Trace(Visitor* visitor) {
visitor->Trace(rule_);
}
-void RuleData::Trace(blink::Visitor* visitor) {
+void RuleData::Trace(Visitor* visitor) {
visitor->Trace(rule_);
}
-void RuleSet::PendingRuleMaps::Trace(blink::Visitor* visitor) {
+void RuleSet::PendingRuleMaps::Trace(Visitor* visitor) {
visitor->Trace(id_rules);
visitor->Trace(class_rules);
visitor->Trace(tag_rules);
visitor->Trace(shadow_pseudo_element_rules);
}
-void RuleSet::Trace(blink::Visitor* visitor) {
+void RuleSet::Trace(Visitor* visitor) {
visitor->Trace(id_rules_);
visitor->Trace(class_rules_);
visitor->Trace(tag_rules_);
diff --git a/chromium/third_party/blink/renderer/core/css/rule_set.h b/chromium/third_party/blink/renderer/core/css/rule_set.h
index b3672077c83..26a1b5f107d 100644
--- a/chromium/third_party/blink/renderer/core/css/rule_set.h
+++ b/chromium/third_party/blink/renderer/core/css/rule_set.h
@@ -30,7 +30,7 @@
#include "third_party/blink/renderer/core/css/resolver/media_query_result.h"
#include "third_party/blink/renderer/core/css/rule_feature_set.h"
#include "third_party/blink/renderer/core/css/style_rule.h"
-#include "third_party/blink/renderer/platform/heap/heap_linked_stack.h"
+#include "third_party/blink/renderer/platform/heap/collection_support/heap_linked_stack.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h"
@@ -68,7 +68,7 @@ class MinimalRuleData {
MinimalRuleData(StyleRule* rule, unsigned selector_index, AddRuleFlags flags)
: rule_(rule), selector_index_(selector_index), flags_(flags) {}
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
Member<StyleRule> rule_;
unsigned selector_index_;
@@ -127,7 +127,7 @@ class CORE_EXPORT RuleData : public GarbageCollected<RuleData> {
return descendant_selector_identifier_hashes_;
}
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
// This number is picked fairly arbitrary. If lowered, be aware that there
// might be sites and extensions using style rules with selector lists
@@ -284,11 +284,13 @@ class CORE_EXPORT RuleSet final : public GarbageCollected<RuleSet> {
HasV0BoundaryCrossingRules();
}
+ bool DidMediaQueryResultsChange(const MediaQueryEvaluator& evaluator) const;
+
#ifndef NDEBUG
void Show() const;
#endif
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
using PendingRuleMap =
@@ -304,6 +306,8 @@ class CORE_EXPORT RuleSet final : public GarbageCollected<RuleSet> {
void AddKeyframesRule(StyleRuleKeyframes*);
void AddPropertyRule(StyleRuleProperty*);
+ bool MatchMediaForAddRules(const MediaQueryEvaluator& evaluator,
+ const MediaQuerySet* media_queries);
void AddChildRules(const HeapVector<Member<StyleRuleBase>>&,
const MediaQueryEvaluator& medium,
AddRuleFlags);
@@ -321,7 +325,7 @@ class CORE_EXPORT RuleSet final : public GarbageCollected<RuleSet> {
PendingRuleMap tag_rules;
PendingRuleMap shadow_pseudo_element_rules;
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
};
PendingRuleMaps* EnsurePendingRules() {
@@ -349,6 +353,7 @@ class CORE_EXPORT RuleSet final : public GarbageCollected<RuleSet> {
HeapVector<MinimalRuleData> deep_combinator_or_shadow_pseudo_rules_;
HeapVector<MinimalRuleData> content_pseudo_element_rules_;
HeapVector<MinimalRuleData> slotted_pseudo_element_rules_;
+ Vector<MediaQuerySetResult> media_query_set_results_;
unsigned rule_count_;
Member<PendingRuleMaps> pending_rules_;
diff --git a/chromium/third_party/blink/renderer/core/css/rule_set_test.cc b/chromium/third_party/blink/renderer/core/css/rule_set_test.cc
index 3e93a91f61e..359b6e9d527 100644
--- a/chromium/third_party/blink/renderer/core/css/rule_set_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/rule_set_test.cc
@@ -307,6 +307,15 @@ TEST(RuleSetTest, findBestRuleSetAndAdd_PseudoWhere) {
}
}
+TEST(RuleSetTest, findBestRuleSetAndAdd_PartPseudoElements) {
+ css_test_helpers::TestStyleSheet sheet;
+
+ sheet.AddCSSRules("::part(dummy):focus, #id::part(dummy) { }");
+ RuleSet& rule_set = sheet.GetRuleSet();
+ const HeapVector<Member<const RuleData>>* rules = rule_set.PartPseudoRules();
+ ASSERT_EQ(2u, rules->size());
+}
+
TEST(RuleSetTest, findBestRuleSetAndAdd_PseudoIsTooLarge) {
// RuleData cannot support selectors at index 8192 or beyond so the expansion
// is limited to this size
diff --git a/chromium/third_party/blink/renderer/core/css/selector_checker.cc b/chromium/third_party/blink/renderer/core/css/selector_checker.cc
index 8227d4192f6..5067dc81ebf 100644
--- a/chromium/third_party/blink/renderer/core/css/selector_checker.cc
+++ b/chromium/third_party/blink/renderer/core/css/selector_checker.cc
@@ -30,6 +30,7 @@
#include "third_party/blink/renderer/core/css/selector_checker.h"
#include "base/auto_reset.h"
+#include "third_party/blink/public/mojom/input/focus_type.mojom-blink.h"
#include "third_party/blink/renderer/core/css/css_selector_list.h"
#include "third_party/blink/renderer/core/css/part_names.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
@@ -101,7 +102,7 @@ static bool MatchesTagName(const Element& element,
const AtomicString& local_name = tag_q_name.LocalName();
if (local_name != CSSSelector::UniversalSelectorAtom() &&
local_name != element.localName()) {
- if (element.IsHTMLElement() || !element.GetDocument().IsHTMLDocument())
+ if (element.IsHTMLElement() || !IsA<HTMLDocument>(element.GetDocument()))
return false;
// Non-html elements in html documents are normalized to their camel-cased
// version during parsing if applicable. Yet, type selectors are lower-cased
@@ -132,7 +133,7 @@ static bool MatchesTagNameForVTT(
if (local_name != CSSSelector::UniversalSelectorAtom() &&
local_name != element.localName()) {
- if (element.IsHTMLElement() || !element.GetDocument().IsHTMLDocument())
+ if (element.IsHTMLElement() || !IsA<HTMLDocument>(element.GetDocument()))
return false;
// Non-html elements in html documents are normalized to their camel-cased
@@ -773,7 +774,7 @@ static bool AnyAttributeMatches(Element& element,
AttributeCollection attributes = element.AttributesWithoutUpdate();
for (const auto& attribute_item : attributes) {
if (!attribute_item.Matches(selector_attr)) {
- if (element.IsHTMLElement() || !element.GetDocument().IsHTMLDocument())
+ if (element.IsHTMLElement() || !IsA<HTMLDocument>(element.GetDocument()))
continue;
// Non-html attributes in html documents are normalized to their camel-
// cased version during parsing if applicable. Yet, attribute selectors
@@ -798,7 +799,7 @@ static bool AnyAttributeMatches(Element& element,
// a case-insensitive manner regardless of whether the case insensitive
// flag is set or not.
bool legacy_case_insensitive =
- element.GetDocument().IsHTMLDocument() &&
+ IsA<HTMLDocument>(element.GetDocument()) &&
!HTMLDocument::IsCaseSensitiveAttribute(selector_attr);
// If case-insensitive, re-check, and count if result differs.
@@ -1249,11 +1250,12 @@ bool SelectorChecker::CheckPseudoClass(const SelectorCheckingContext& context,
case CSSSelector::kPseudoVideoPersistentAncestor:
DCHECK(is_ua_rule_);
return element.ContainsPersistentVideo();
- case CSSSelector::kPseudoXrImmersiveDomOverlay:
- DCHECK(is_ua_rule_);
- // In immersive AR overlay mode, apply a pseudostyle to the root element.
- return element.GetDocument().IsImmersiveArOverlay() &&
- element == element.GetDocument().documentElement();
+ case CSSSelector::kPseudoXrOverlay:
+ // In immersive AR overlay mode, apply a pseudostyle to the DOM Overlay
+ // element. This is the same as the fullscreen element in the current
+ // implementation, but could be different for AR headsets.
+ return element.GetDocument().IsXrOverlay() &&
+ Fullscreen::IsFullscreenElement(element);
case CSSSelector::kPseudoInRange:
return element.IsInRange();
case CSSSelector::kPseudoOutOfRange:
@@ -1271,7 +1273,7 @@ bool SelectorChecker::CheckPseudoClass(const SelectorCheckingContext& context,
return false;
if (context.scope == &element.GetDocument())
return element == element.GetDocument().documentElement();
- if (auto* shadow_root = DynamicTo<ShadowRoot>(context.scope.Get()))
+ if (auto* shadow_root = DynamicTo<ShadowRoot>(context.scope))
return element == shadow_root->host();
return context.scope == &element;
case CSSSelector::kPseudoUnresolved:
@@ -1295,7 +1297,7 @@ bool SelectorChecker::CheckPseudoClass(const SelectorCheckingContext& context,
return MatchesSpatialNavigationInterestPseudoClass(element);
case CSSSelector::kPseudoIsHtml:
DCHECK(is_ua_rule_);
- return element.GetDocument().IsHTMLDocument();
+ return IsA<HTMLDocument>(element.GetDocument());
case CSSSelector::kPseudoListBox:
DCHECK(is_ua_rule_);
return MatchesListBoxPseudoClass(element);
@@ -1394,7 +1396,11 @@ bool SelectorChecker::CheckPseudoElement(const SelectorCheckingContext& context,
}
case CSSSelector::kPseudoPart:
DCHECK(part_names_);
- return part_names_->Contains(selector.Argument());
+ for (const auto& part_name : *selector.PartNames()) {
+ if (!part_names_->Contains(part_name))
+ return false;
+ }
+ return true;
case CSSSelector::kPseudoPlaceholder:
if (ShadowRoot* root = element.ContainingShadowRoot()) {
return root->IsUserAgent() &&
@@ -1611,42 +1617,21 @@ bool SelectorChecker::CheckScrollbarPseudoClass(
return scrollbar_part_ == kBackButtonEndPart ||
scrollbar_part_ == kForwardButtonEndPart ||
scrollbar_part_ == kForwardTrackPart;
- case CSSSelector::kPseudoDoubleButton: {
- WebScrollbarButtonsPlacement buttons_placement =
- scrollbar_->GetTheme().ButtonsPlacement();
- if (scrollbar_part_ == kBackButtonStartPart ||
- scrollbar_part_ == kForwardButtonStartPart ||
- scrollbar_part_ == kBackTrackPart)
- return buttons_placement == kWebScrollbarButtonsPlacementDoubleStart ||
- buttons_placement == kWebScrollbarButtonsPlacementDoubleBoth;
- if (scrollbar_part_ == kBackButtonEndPart ||
- scrollbar_part_ == kForwardButtonEndPart ||
- scrollbar_part_ == kForwardTrackPart)
- return buttons_placement == kWebScrollbarButtonsPlacementDoubleEnd ||
- buttons_placement == kWebScrollbarButtonsPlacementDoubleBoth;
- return false;
- }
- case CSSSelector::kPseudoSingleButton: {
- WebScrollbarButtonsPlacement buttons_placement =
- scrollbar_->GetTheme().ButtonsPlacement();
- if (scrollbar_part_ == kBackButtonStartPart ||
- scrollbar_part_ == kForwardButtonEndPart ||
- scrollbar_part_ == kBackTrackPart ||
- scrollbar_part_ == kForwardTrackPart)
- return buttons_placement == kWebScrollbarButtonsPlacementSingle;
- return false;
- }
- case CSSSelector::kPseudoNoButton: {
- WebScrollbarButtonsPlacement buttons_placement =
- scrollbar_->GetTheme().ButtonsPlacement();
- if (scrollbar_part_ == kBackTrackPart)
- return buttons_placement == kWebScrollbarButtonsPlacementNone ||
- buttons_placement == kWebScrollbarButtonsPlacementDoubleEnd;
- if (scrollbar_part_ == kForwardTrackPart)
- return buttons_placement == kWebScrollbarButtonsPlacementNone ||
- buttons_placement == kWebScrollbarButtonsPlacementDoubleStart;
+ case CSSSelector::kPseudoDoubleButton:
+ // :double-button matches nothing on all platforms.
return false;
- }
+ case CSSSelector::kPseudoSingleButton:
+ if (!scrollbar_->GetTheme().NativeThemeHasButtons())
+ return false;
+ return scrollbar_part_ == kBackButtonStartPart ||
+ scrollbar_part_ == kForwardButtonEndPart ||
+ scrollbar_part_ == kBackTrackPart ||
+ scrollbar_part_ == kForwardTrackPart;
+ case CSSSelector::kPseudoNoButton:
+ if (scrollbar_->GetTheme().NativeThemeHasButtons())
+ return false;
+ return scrollbar_part_ == kBackTrackPart ||
+ scrollbar_part_ == kForwardTrackPart;
case CSSSelector::kPseudoCornerPresent:
return scrollbar_->GetScrollableArea() &&
scrollbar_->GetScrollableArea()->IsScrollCornerVisible();
@@ -1680,7 +1665,7 @@ bool SelectorChecker::MatchesFocusVisiblePseudoClass(const Element& element) {
bool last_focus_from_mouse =
document.GetFrame() &&
document.GetFrame()->Selection().FrameIsFocusedAndActive() &&
- document.LastFocusType() == kWebFocusTypeMouse;
+ document.LastFocusType() == mojom::blink::FocusType::kMouse;
bool had_keyboard_event = document.HadKeyboardEvent();
return (!last_focus_from_mouse || had_keyboard_event ||
diff --git a/chromium/third_party/blink/renderer/core/css/selector_checker.h b/chromium/third_party/blink/renderer/core/css/selector_checker.h
index e4748e49172..e385e97d39a 100644
--- a/chromium/third_party/blink/renderer/core/css/selector_checker.h
+++ b/chromium/third_party/blink/renderer/core/css/selector_checker.h
@@ -48,7 +48,10 @@ class SelectorChecker {
STACK_ALLOCATED();
public:
- enum VisitedMatchType { kVisitedMatchDisabled, kVisitedMatchEnabled };
+ enum VisitedMatchType : uint8_t {
+ kVisitedMatchDisabled,
+ kVisitedMatchEnabled
+ };
enum Mode {
// Used when matching selectors inside style recalc. This mode will set
@@ -83,18 +86,21 @@ class SelectorChecker {
Mode mode = kResolvingStyle;
bool is_ua_rule = false;
ComputedStyle* element_style = nullptr;
- Member<CustomScrollbar> scrollbar = nullptr;
+ CustomScrollbar* scrollbar = nullptr;
ScrollbarPart scrollbar_part = kNoPart;
PartNames* part_names = nullptr;
};
explicit SelectorChecker(const Init& init)
- : mode_(init.mode),
- is_ua_rule_(init.is_ua_rule),
- element_style_(init.element_style),
+ : element_style_(init.element_style),
scrollbar_(init.scrollbar),
+ part_names_(init.part_names),
scrollbar_part_(init.scrollbar_part),
- part_names_(init.part_names) {}
+ mode_(init.mode) {
+#if DCHECK_IS_ON()
+ is_ua_rule_ = init.is_ua_rule;
+#endif
+ }
// Wraps the current element and a CSSSelector and stores some other state of
// the selector matching process.
@@ -105,31 +111,20 @@ class SelectorChecker {
// Initial selector constructor
SelectorCheckingContext(Element* element,
VisitedMatchType visited_match_type)
- : selector(nullptr),
- element(element),
- previous_element(nullptr),
- scope(nullptr),
- visited_match_type(visited_match_type),
- pseudo_id(kPseudoIdNone),
- is_sub_selector(false),
- in_rightmost_compound(true),
- has_scrollbar_pseudo(false),
- has_selection_pseudo(false),
- treat_shadow_host_as_normal_scope(false),
- is_from_vtt(false) {}
-
- const CSSSelector* selector;
- Member<Element> element;
- Member<Element> previous_element;
- Member<const ContainerNode> scope;
+ : element(element), visited_match_type(visited_match_type) {}
+
+ const CSSSelector* selector = nullptr;
+ Element* element = nullptr;
+ Element* previous_element = nullptr;
+ const ContainerNode* scope = nullptr;
VisitedMatchType visited_match_type;
- PseudoId pseudo_id;
- bool is_sub_selector;
- bool in_rightmost_compound;
- bool has_scrollbar_pseudo;
- bool has_selection_pseudo;
- bool treat_shadow_host_as_normal_scope;
- bool is_from_vtt;
+ PseudoId pseudo_id = kPseudoIdNone;
+ bool is_sub_selector = false;
+ bool in_rightmost_compound = true;
+ bool has_scrollbar_pseudo = false;
+ bool has_selection_pseudo = false;
+ bool treat_shadow_host_as_normal_scope = false;
+ bool is_from_vtt = false;
};
struct MatchResult {
@@ -215,12 +210,16 @@ class SelectorChecker {
bool CheckPseudoNot(const SelectorCheckingContext&, MatchResult&) const;
bool CheckPseudoNotForVTT(const SelectorCheckingContext&, MatchResult&) const;
- Mode mode_;
- bool is_ua_rule_;
ComputedStyle* element_style_;
- Member<CustomScrollbar> scrollbar_;
- ScrollbarPart scrollbar_part_;
+ CustomScrollbar* scrollbar_;
PartNames* part_names_;
+ ScrollbarPart scrollbar_part_;
+ Mode mode_;
+#if DCHECK_IS_ON()
+ bool is_ua_rule_;
+#else
+ static constexpr bool is_ua_rule_ = true;
+#endif
DISALLOW_COPY_AND_ASSIGN(SelectorChecker);
};
diff --git a/chromium/third_party/blink/renderer/core/css/selector_filter.cc b/chromium/third_party/blink/renderer/core/css/selector_filter.cc
index 9fb0fb79bf7..64d86ed4bb5 100644
--- a/chromium/third_party/blink/renderer/core/css/selector_filter.cc
+++ b/chromium/third_party/blink/renderer/core/css/selector_filter.cc
@@ -198,11 +198,11 @@ void SelectorFilter::CollectIdentifierHashes(
*hash = 0;
}
-void SelectorFilter::ParentStackFrame::Trace(blink::Visitor* visitor) {
+void SelectorFilter::ParentStackFrame::Trace(Visitor* visitor) {
visitor->Trace(element);
}
-void SelectorFilter::Trace(blink::Visitor* visitor) {
+void SelectorFilter::Trace(Visitor* visitor) {
visitor->Trace(parent_stack_);
}
diff --git a/chromium/third_party/blink/renderer/core/css/selector_filter.h b/chromium/third_party/blink/renderer/core/css/selector_filter.h
index 69d9b975e6d..d911116c19d 100644
--- a/chromium/third_party/blink/renderer/core/css/selector_filter.h
+++ b/chromium/third_party/blink/renderer/core/css/selector_filter.h
@@ -53,7 +53,7 @@ class CORE_EXPORT SelectorFilter {
ParentStackFrame() : element(nullptr) {}
explicit ParentStackFrame(Element& element) : element(&element) {}
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
Member<Element> element;
Vector<unsigned, 4> identifier_hashes;
@@ -75,7 +75,7 @@ class CORE_EXPORT SelectorFilter {
unsigned* identifier_hashes,
unsigned maximum_identifier_count);
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
void PushParentStackFrame(Element& parent);
diff --git a/chromium/third_party/blink/renderer/core/css/selector_query.cc b/chromium/third_party/blink/renderer/core/css/selector_query.cc
index 39140ed8dce..722b751f192 100644
--- a/chromium/third_party/blink/renderer/core/css/selector_query.cc
+++ b/chromium/third_party/blink/renderer/core/css/selector_query.cc
@@ -38,6 +38,7 @@
#include "third_party/blink/renderer/core/dom/nth_index_cache.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/dom/static_node_list.h"
+#include "third_party/blink/renderer/core/html/html_document.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
@@ -172,7 +173,7 @@ inline bool MatchesTagName(const QualifiedName& tag_name,
// version during parsing if applicable. Yet, type selectors are lower-cased
// for selectors in html documents. Compare the upper case converted names
// instead to allow matching SVG elements like foreignObject.
- if (!element.IsHTMLElement() && element.GetDocument().IsHTMLDocument())
+ if (!element.IsHTMLElement() && IsA<HTMLDocument>(element.GetDocument()))
return element.TagQName().LocalNameUpper() == tag_name.LocalNameUpper();
return false;
}
diff --git a/chromium/third_party/blink/renderer/core/css/selector_query_test.cc b/chromium/third_party/blink/renderer/core/css/selector_query_test.cc
index c5cf6131fcc..84cffc1e660 100644
--- a/chromium/third_party/blink/renderer/core/css/selector_query_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/selector_query_test.cc
@@ -67,7 +67,7 @@ TEST(SelectorQueryTest, NotMatchingPseudoElement) {
auto* document = MakeGarbageCollected<Document>();
auto* html = MakeGarbageCollected<HTMLHtmlElement>(*document);
document->AppendChild(html);
- document->documentElement()->SetInnerHTMLFromString(
+ document->documentElement()->setInnerHTML(
"<body><style>span::before { content: 'X' }</style><span></span></body>");
CSSSelectorList selector_list = CSSParser::ParseSelector(
@@ -96,7 +96,7 @@ TEST(SelectorQueryTest, LastOfTypeNotFinishedParsing) {
auto* document = MakeGarbageCollected<HTMLDocument>();
auto* html = MakeGarbageCollected<HTMLHtmlElement>(*document);
document->AppendChild(html);
- document->documentElement()->SetInnerHTMLFromString(
+ document->documentElement()->setInnerHTML(
"<body><p></p><p id=last></p></body>", ASSERT_NO_EXCEPTION);
document->body()->BeginParsingChildren();
@@ -331,7 +331,7 @@ TEST(SelectorQueryTest, QuirksModeSlowPath) {
TEST(SelectorQueryTest, DisconnectedSubtree) {
auto* document = MakeGarbageCollected<HTMLDocument>();
Element* scope = document->CreateRawElement(html_names::kDivTag);
- scope->SetInnerHTMLFromString(R"HTML(
+ scope->setInnerHTML(R"HTML(
<section>
<span id=first>
<span id=A class=A></span>
@@ -360,7 +360,7 @@ TEST(SelectorQueryTest, DisconnectedTreeScope) {
Element* host = document->CreateRawElement(html_names::kDivTag);
ShadowRoot& shadowRoot =
host->AttachShadowRootInternal(ShadowRootType::kOpen);
- shadowRoot.SetInnerHTMLFromString(R"HTML(
+ shadowRoot.setInnerHTML(R"HTML(
<section>
<span id=first>
<span id=A class=A></span>
diff --git a/chromium/third_party/blink/renderer/core/css/shadow_tree_style_sheet_collection.h b/chromium/third_party/blink/renderer/core/css/shadow_tree_style_sheet_collection.h
index 138bf722465..5a9cd376b13 100644
--- a/chromium/third_party/blink/renderer/core/css/shadow_tree_style_sheet_collection.h
+++ b/chromium/third_party/blink/renderer/core/css/shadow_tree_style_sheet_collection.h
@@ -47,7 +47,7 @@ class ShadowTreeStyleSheetCollection final
void UpdateActiveStyleSheets(StyleEngine& master_engine);
bool IsShadowTreeStyleSheetCollection() const final { return true; }
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
TreeScopeStyleSheetCollection::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/style_attribute_mutation_scope.h b/chromium/third_party/blink/renderer/core/css/style_attribute_mutation_scope.h
index 34fd5076832..7a5f8cded52 100644
--- a/chromium/third_party/blink/renderer/core/css/style_attribute_mutation_scope.h
+++ b/chromium/third_party/blink/renderer/core/css/style_attribute_mutation_scope.h
@@ -51,8 +51,8 @@ class StyleAttributeMutationScope {
static bool should_notify_inspector_;
static bool should_deliver_;
- Member<MutationObserverInterestGroup> mutation_recipients_;
- Member<MutationRecord> mutation_;
+ MutationObserverInterestGroup* mutation_recipients_ = nullptr;
+ MutationRecord* mutation_ = nullptr;
AtomicString old_value_;
DISALLOW_COPY_AND_ASSIGN(StyleAttributeMutationScope);
};
diff --git a/chromium/third_party/blink/renderer/core/css/style_change_reason.cc b/chromium/third_party/blink/renderer/core/css/style_change_reason.cc
index c3eeeb35293..9a660dd1f6e 100644
--- a/chromium/third_party/blink/renderer/core/css/style_change_reason.cc
+++ b/chromium/third_party/blink/renderer/core/css/style_change_reason.cc
@@ -27,7 +27,6 @@ const char kFrame[] = "Frame";
const char kFullscreen[] = "Fullscreen";
const char kInheritedStyleChangeFromParentFrame[] =
"InheritedStyleChangeFromParentFrame";
-const char kInline[] = "Inline";
const char kInlineCSSStyleMutated[] =
"Inline CSS style declaration was mutated";
const char kInspector[] = "Inspector";
diff --git a/chromium/third_party/blink/renderer/core/css/style_change_reason.h b/chromium/third_party/blink/renderer/core/css/style_change_reason.h
index dadf17e01d2..bece22e6514 100644
--- a/chromium/third_party/blink/renderer/core/css/style_change_reason.h
+++ b/chromium/third_party/blink/renderer/core/css/style_change_reason.h
@@ -29,7 +29,6 @@ extern const char kFonts[];
extern const char kFullscreen[];
extern const char kFindInvisible[];
extern const char kInheritedStyleChangeFromParentFrame[];
-extern const char kInline[];
extern const char kInlineCSSStyleMutated[];
extern const char kInspector[];
extern const char kInvisibleChange[];
diff --git a/chromium/third_party/blink/renderer/core/css/style_color.cc b/chromium/third_party/blink/renderer/core/css/style_color.cc
index 4f12e871d29..669adf45133 100644
--- a/chromium/third_party/blink/renderer/core/css/style_color.cc
+++ b/chromium/third_party/blink/renderer/core/css/style_color.cc
@@ -40,9 +40,8 @@ bool StyleColor::IsColorKeyword(CSSValueID id) {
// '-internal-inactive-list-box-selection-text'
// '-webkit-focus-ring-color'
// '-internal-quirk-inherit'
- // '-internal-root-color'
//
- return (id >= CSSValueID::kAqua && id <= CSSValueID::kInternalRootColor) ||
+ return (id >= CSSValueID::kAqua && id <= CSSValueID::kInternalQuirkInherit) ||
(id >= CSSValueID::kAliceblue && id <= CSSValueID::kYellowgreen) ||
id == CSSValueID::kMenu;
}
diff --git a/chromium/third_party/blink/renderer/core/css/style_element.cc b/chromium/third_party/blink/renderer/core/css/style_element.cc
index 03ac95e4895..52c653e7cff 100644
--- a/chromium/third_party/blink/renderer/core/css/style_element.cc
+++ b/chromium/third_party/blink/renderer/core/css/style_element.cc
@@ -40,9 +40,9 @@
namespace blink {
static bool IsCSS(const Element& element, const AtomicString& type) {
- return type.IsEmpty() || (element.IsHTMLElement()
- ? DeprecatedEqualIgnoringCase(type, "text/css")
- : (type == "text/css"));
+ return type.IsEmpty() ||
+ (element.IsHTMLElement() ? EqualIgnoringASCIICase(type, "text/css")
+ : (type == "text/css"));
}
StyleElement::StyleElement(Document* document, bool created_by_parser)
@@ -150,8 +150,10 @@ StyleElement::ProcessingResult StyleElement::CreateSheet(Element& element,
if (IsCSS(element, type) && passes_content_security_policy_checks) {
scoped_refptr<MediaQuerySet> media_queries;
const AtomicString& media_string = media();
- if (!media_string.IsEmpty())
- media_queries = MediaQuerySet::Create(media_string);
+ if (!media_string.IsEmpty()) {
+ media_queries =
+ MediaQuerySet::Create(media_string, element.GetExecutionContext());
+ }
loading_ = true;
TextPosition start_position =
start_position_ == TextPosition::BelowRangePosition()
@@ -193,7 +195,7 @@ void StyleElement::StartLoadingDynamicSheet(Document& document) {
document.GetStyleEngine().AddPendingSheet(style_engine_context_);
}
-void StyleElement::Trace(blink::Visitor* visitor) {
+void StyleElement::Trace(Visitor* visitor) {
visitor->Trace(sheet_);
}
diff --git a/chromium/third_party/blink/renderer/core/css/style_element.h b/chromium/third_party/blink/renderer/core/css/style_element.h
index 957a6e23d2c..bb39739da6b 100644
--- a/chromium/third_party/blink/renderer/core/css/style_element.h
+++ b/chromium/third_party/blink/renderer/core/css/style_element.h
@@ -35,7 +35,7 @@ class CORE_EXPORT StyleElement : public GarbageCollectedMixin {
public:
StyleElement(Document*, bool created_by_parser);
virtual ~StyleElement();
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
protected:
enum ProcessingResult { kProcessingSuccessful, kProcessingFatalError };
diff --git a/chromium/third_party/blink/renderer/core/css/style_element_test.cc b/chromium/third_party/blink/renderer/core/css/style_element_test.cc
index 13a2d7e9610..5b37ef79e65 100644
--- a/chromium/third_party/blink/renderer/core/css/style_element_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/style_element_test.cc
@@ -17,7 +17,7 @@ TEST(StyleElementTest, CreateSheetUsesCache) {
auto dummy_page_holder = std::make_unique<DummyPageHolder>(IntSize(800, 600));
Document& document = dummy_page_holder->GetDocument();
- document.documentElement()->SetInnerHTMLFromString(
+ document.documentElement()->setInnerHTML(
"<style id=style>a { top: 0; }</style>");
auto& style_element = To<HTMLStyleElement>(*document.getElementById("style"));
diff --git a/chromium/third_party/blink/renderer/core/css/style_engine.cc b/chromium/third_party/blink/renderer/core/css/style_engine.cc
index e7d64e18e37..4d430870ed3 100644
--- a/chromium/third_party/blink/renderer/core/css/style_engine.cc
+++ b/chromium/third_party/blink/renderer/core/css/style_engine.cc
@@ -36,6 +36,7 @@
#include "third_party/blink/renderer/core/css/css_font_selector.h"
#include "third_party/blink/renderer/core/css/css_identifier_value.h"
#include "third_party/blink/renderer/core/css/css_style_sheet.h"
+#include "third_party/blink/renderer/core/css/css_uri_value.h"
#include "third_party/blink/renderer/core/css/css_value_list.h"
#include "third_party/blink/renderer/core/css/document_style_environment_variables.h"
#include "third_party/blink/renderer/core/css/document_style_sheet_collector.h"
@@ -53,6 +54,7 @@
#include "third_party/blink/renderer/core/css/style_change_reason.h"
#include "third_party/blink/renderer/core/css/style_environment_variables.h"
#include "third_party/blink/renderer/core/css/style_sheet_contents.h"
+#include "third_party/blink/renderer/core/css/vision_deficiency.h"
#include "third_party/blink/renderer/core/display_lock/display_lock_utilities.h"
#include "third_party/blink/renderer/core/dom/document_lifecycle.h"
#include "third_party/blink/renderer/core/dom/element.h"
@@ -75,10 +77,13 @@
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/page/page.h"
+#include "third_party/blink/renderer/core/page/page_popup_controller.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
+#include "third_party/blink/renderer/core/style/filter_operations.h"
#include "third_party/blink/renderer/core/style/style_initial_data.h"
+#include "third_party/blink/renderer/core/svg/svg_resource.h"
#include "third_party/blink/renderer/core/svg/svg_style_element.h"
#include "third_party/blink/renderer/platform/fonts/font_cache.h"
#include "third_party/blink/renderer/platform/fonts/font_selector.h"
@@ -89,6 +94,18 @@
namespace blink {
+namespace {
+
+CSSFontSelector* CreateCSSFontSelectorFor(Document& document) {
+ DCHECK(document.GetFrame());
+ if (UNLIKELY(document.GetFrame()->PagePopupOwner())) {
+ return PagePopupController::CreateCSSFontSelector(document);
+ }
+ return MakeGarbageCollected<CSSFontSelector>(&document);
+}
+
+} // namespace
+
StyleEngine::StyleEngine(Document& document)
: document_(&document),
is_master_(!document.IsHTMLImport()),
@@ -97,18 +114,19 @@ StyleEngine::StyleEngine(Document& document)
if (document.GetFrame()) {
// We don't need to create CSSFontSelector for imported document or
// HTMLTemplateElement's document, because those documents have no frame.
- font_selector_ = MakeGarbageCollected<CSSFontSelector>(&document);
+ font_selector_ = CreateCSSFontSelectorFor(document);
font_selector_->RegisterForInvalidationCallbacks(this);
}
if (document.IsInMainFrame())
viewport_resolver_ = MakeGarbageCollected<ViewportStyleResolver>(document);
if (IsMaster())
global_rule_set_ = MakeGarbageCollected<CSSGlobalRuleSet>();
- if (Platform::Current() && Platform::Current()->ThemeEngine()) {
- preferred_color_scheme_ =
- Platform::Current()->ThemeEngine()->PreferredColorScheme();
- forced_colors_ = Platform::Current()->ThemeEngine()->GetForcedColors();
+ if (auto* settings = GetDocument().GetSettings()) {
+ if (!settings->GetForceDarkModeEnabled())
+ preferred_color_scheme_ = settings->GetPreferredColorScheme();
}
+ if (Platform::Current() && Platform::Current()->ThemeEngine())
+ forced_colors_ = Platform::Current()->ThemeEngine()->GetForcedColors();
}
StyleEngine::~StyleEngine() = default;
@@ -363,6 +381,58 @@ void StyleEngine::AddedCustomElementDefaultStyles(
global_rule_set_->MarkDirty();
}
+namespace {
+
+bool HasMediaQueries(const ActiveStyleSheetVector& active_style_sheets) {
+ for (const auto& active_sheet : active_style_sheets) {
+ if (const MediaQuerySet* media_queries =
+ active_sheet.first->MediaQueries()) {
+ if (!media_queries->QueryVector().IsEmpty())
+ return true;
+ }
+ StyleSheetContents* contents = active_sheet.first->Contents();
+ if (contents->HasMediaQueries())
+ return true;
+ }
+ return false;
+}
+
+bool HasSizeDependentMediaQueries(
+ const ActiveStyleSheetVector& active_style_sheets) {
+ for (const auto& active_sheet : active_style_sheets) {
+ if (active_sheet.first->HasMediaQueryResults())
+ return true;
+ StyleSheetContents* contents = active_sheet.first->Contents();
+ if (!contents->HasRuleSet())
+ continue;
+ if (contents->GetRuleSet().Features().HasMediaQueryResults())
+ return true;
+ }
+ return false;
+}
+
+} // namespace
+
+bool StyleEngine::MediaQueryAffectingValueChanged(
+ const ActiveStyleSheetVector& active_sheets,
+ MediaValueChange change) {
+ if (change == MediaValueChange::kSize)
+ return HasSizeDependentMediaQueries(active_sheets);
+
+ DCHECK(change == MediaValueChange::kOther);
+ return HasMediaQueries(active_sheets);
+}
+
+void StyleEngine::MediaQueryAffectingValueChanged(TreeScope& tree_scope,
+ MediaValueChange change) {
+ auto* collection = StyleSheetCollectionFor(tree_scope);
+ DCHECK(collection);
+ if (MediaQueryAffectingValueChanged(collection->ActiveAuthorStyleSheets(),
+ change)) {
+ SetNeedsActiveStyleUpdate(tree_scope);
+ }
+}
+
void StyleEngine::MediaQueriesChangedInScope(TreeScope& tree_scope) {
if (ScopedStyleResolver* resolver = tree_scope.GetScopedStyleResolver())
resolver->SetNeedsAppendAllSheets();
@@ -387,14 +457,11 @@ bool StyleEngine::ShouldUpdateShadowTreeStyleSheetCollection() const {
}
void StyleEngine::MediaQueryAffectingValueChanged(
- UnorderedTreeScopeSet& tree_scopes) {
+ UnorderedTreeScopeSet& tree_scopes,
+ MediaValueChange change) {
for (TreeScope* tree_scope : tree_scopes) {
DCHECK(tree_scope != document_);
- auto* collection = To<ShadowTreeStyleSheetCollection>(
- StyleSheetCollectionFor(*tree_scope));
- DCHECK(collection);
- if (collection->MediaQueryAffectingValueChanged())
- SetNeedsActiveStyleUpdate(*tree_scope);
+ MediaQueryAffectingValueChanged(*tree_scope, change);
}
}
@@ -407,7 +474,8 @@ void StyleEngine::RemoveTextTrack(TextTrack* text_track) {
}
void StyleEngine::MediaQueryAffectingValueChanged(
- HeapHashSet<Member<TextTrack>>& text_tracks) {
+ HeapHashSet<Member<TextTrack>>& text_tracks,
+ MediaValueChange change) {
if (text_tracks.IsEmpty())
return;
@@ -433,13 +501,12 @@ void StyleEngine::MediaQueryAffectingValueChanged(
}
}
-void StyleEngine::MediaQueryAffectingValueChanged() {
- if (ClearMediaQueryDependentRuleSets(active_user_style_sheets_))
+void StyleEngine::MediaQueryAffectingValueChanged(MediaValueChange change) {
+ if (MediaQueryAffectingValueChanged(active_user_style_sheets_, change))
MarkUserStyleDirty();
- if (GetDocumentStyleSheetCollection().MediaQueryAffectingValueChanged())
- SetNeedsActiveStyleUpdate(GetDocument());
- MediaQueryAffectingValueChanged(active_tree_scopes_);
- MediaQueryAffectingValueChanged(text_tracks_);
+ MediaQueryAffectingValueChanged(GetDocument(), change);
+ MediaQueryAffectingValueChanged(active_tree_scopes_, change);
+ MediaQueryAffectingValueChanged(text_tracks_, change);
if (resolver_)
resolver_->UpdateMediaType();
}
@@ -671,17 +738,24 @@ void StyleEngine::DidDetach() {
environment_variables_ = nullptr;
}
-void StyleEngine::ClearFontCacheAndAddUserFonts() {
+bool StyleEngine::ClearFontCacheAndAddUserFonts() {
+ bool fonts_changed = false;
+
if (font_selector_ &&
- font_selector_->GetFontFaceCache()->ClearCSSConnected() && resolver_) {
- resolver_->InvalidateMatchedPropertiesCache();
+ font_selector_->GetFontFaceCache()->ClearCSSConnected()) {
+ fonts_changed = true;
+ if (resolver_)
+ resolver_->InvalidateMatchedPropertiesCache();
}
// Rebuild the font cache with @font-face rules from user style sheets.
for (unsigned i = 0; i < active_user_style_sheets_.size(); ++i) {
DCHECK(active_user_style_sheets_[i].second);
- AddUserFontFaceRules(*active_user_style_sheets_[i].second);
+ if (AddUserFontFaceRules(*active_user_style_sheets_[i].second))
+ fonts_changed = true;
}
+
+ return fonts_changed;
}
void StyleEngine::UpdateGenericFontFamilySettings() {
@@ -822,6 +896,34 @@ void StyleEngine::CollectScopedStyleFeaturesTo(RuleFeatureSet& features) const {
}
}
+void StyleEngine::InvalidateStyleAndLayoutForFontUpdates() {
+ if (!fonts_need_update_)
+ return;
+
+ DCHECK(RuntimeEnabledFeatures::CSSReducedFontLoadingInvalidationsEnabled());
+ TRACE_EVENT0("blink", "StyleEngine::InvalidateStyleAndLayoutForFontUpdates");
+
+ fonts_need_update_ = false;
+ Element* root = GetDocument().documentElement();
+ if (!root)
+ return;
+
+ {
+ TRACE_EVENT0("blink", "Node::MarkSubtreeNeedsStyleRecalcForFontUpdates");
+ root->MarkSubtreeNeedsStyleRecalcForFontUpdates();
+ }
+
+ if (LayoutObject* root_object = root->GetLayoutObject()) {
+ TRACE_EVENT0("blink", "LayoutObject::InvalidateSubtreeForFontUpdates");
+ root_object->InvalidateSubtreeLayoutForFontUpdates();
+ }
+}
+
+void StyleEngine::MarkFontsNeedUpdate() {
+ fonts_need_update_ = true;
+ GetDocument().ScheduleLayoutTreeUpdateIfNeeded();
+}
+
void StyleEngine::FontsNeedUpdate(FontSelector*) {
if (!GetDocument().IsActive())
return;
@@ -829,17 +931,16 @@ void StyleEngine::FontsNeedUpdate(FontSelector*) {
if (resolver_)
resolver_->InvalidateMatchedPropertiesCache();
MarkViewportStyleDirty();
- MarkAllElementsForStyleRecalc(
- StyleChangeReasonForTracing::Create(style_change_reason::kFonts));
- probe::FontsUpdated(document_, nullptr, String(), nullptr);
-}
-void StyleEngine::SetFontSelector(CSSFontSelector* font_selector) {
- if (font_selector_)
- font_selector_->UnregisterForInvalidationCallbacks(this);
- font_selector_ = font_selector;
- if (font_selector_)
- font_selector_->RegisterForInvalidationCallbacks(this);
+ if (RuntimeEnabledFeatures::CSSReducedFontLoadingInvalidationsEnabled()) {
+ MarkFontsNeedUpdate();
+ } else {
+ MarkAllElementsForStyleRecalc(
+ StyleChangeReasonForTracing::Create(style_change_reason::kFonts));
+ }
+
+ probe::FontsUpdated(document_->GetExecutionContext(), nullptr, String(),
+ nullptr);
}
void StyleEngine::PlatformColorsChanged() {
@@ -852,6 +953,26 @@ void StyleEngine::PlatformColorsChanged() {
bool StyleEngine::ShouldSkipInvalidationFor(const Element& element) const {
if (!element.InActiveDocument())
return true;
+ if (GetDocument().InStyleRecalc()) {
+#if DCHECK_IS_ON()
+ // TODO(futhark): The InStyleRecalc() if-guard above should have been a
+ // DCHECK(!InStyleRecalc()), but there are a couple of cases where we try to
+ // invalidate style from style recalc:
+ //
+ // 1. We may animate the class attribute of an SVG element and change it
+ // during style recalc when applying the animation effect.
+ // 2. We may call SetInlineStyle on elements in a UA shadow tree as part of
+ // style recalc. For instance from HTMLImageFallbackHelper.
+ //
+ // If there are more cases, we need to adjust the DCHECKs below, but ideally
+ // The origin of these invalidations should be fixed.
+ if (!element.IsSVGElement()) {
+ DCHECK(element.ContainingShadowRoot());
+ DCHECK(element.ContainingShadowRoot()->IsUserAgent());
+ }
+#endif // DCHECK_IS_ON()
+ return true;
+ }
if (GetDocument().GetStyleChangeType() == kSubtreeStyleChange)
return true;
Element* root = GetDocument().documentElement();
@@ -1278,6 +1399,15 @@ void StyleEngine::SetHttpDefaultStyle(const String& content) {
SetPreferredStylesheetSetNameIfNotSet(content);
}
+void StyleEngine::EnsureUAStyleForXrOverlay() {
+ DCHECK(IsMaster());
+ DCHECK(global_rule_set_);
+ if (CSSDefaultStyleSheets::Instance().EnsureDefaultStyleSheetForXrOverlay()) {
+ global_rule_set_->MarkDirty();
+ UpdateActiveStyle();
+ }
+}
+
void StyleEngine::EnsureUAStyleForFullscreen() {
DCHECK(IsMaster());
DCHECK(global_rule_set_);
@@ -1310,7 +1440,7 @@ void StyleEngine::InitialStyleChanged() {
// Media queries may rely on the initial font size relative lengths which may
// have changed.
- MediaQueryAffectingValueChanged();
+ MediaQueryAffectingValueChanged(MediaValueChange::kOther);
MarkViewportStyleDirty();
MarkAllElementsForStyleRecalc(
StyleChangeReasonForTracing::Create(style_change_reason::kSettings));
@@ -1385,18 +1515,29 @@ unsigned GetRuleSetFlags(const HeapHashSet<Member<RuleSet>> rule_sets) {
return flags;
}
+bool NeedsFullRecalcForRuleSetChanges(TreeScope& tree_scope,
+ unsigned changed_rule_flags,
+ bool has_rebuilt_font_cache) {
+ if (changed_rule_flags & kFullRecalcRules)
+ return true;
+ if (!tree_scope.RootNode().IsDocumentNode())
+ return false;
+ return (changed_rule_flags & kFontFaceRules) || has_rebuilt_font_cache;
+}
+
} // namespace
void StyleEngine::InvalidateForRuleSetChanges(
TreeScope& tree_scope,
const HeapHashSet<Member<RuleSet>>& changed_rule_sets,
unsigned changed_rule_flags,
- InvalidationScope invalidation_scope) {
+ InvalidationScope invalidation_scope,
+ bool has_rebuilt_font_cache) {
if (tree_scope.GetDocument().HasPendingForcedStyleRecalc())
return;
if (!tree_scope.GetDocument().documentElement())
return;
- if (changed_rule_sets.IsEmpty())
+ if (changed_rule_sets.IsEmpty() && !has_rebuilt_font_cache)
return;
Element& invalidation_root =
@@ -1404,9 +1545,8 @@ void StyleEngine::InvalidateForRuleSetChanges(
if (invalidation_root.GetStyleChangeType() == kSubtreeStyleChange)
return;
- if (changed_rule_flags & kFullRecalcRules ||
- ((changed_rule_flags & kFontFaceRules) &&
- tree_scope.RootNode().IsDocumentNode())) {
+ if (NeedsFullRecalcForRuleSetChanges(tree_scope, changed_rule_flags,
+ has_rebuilt_font_cache)) {
invalidation_root.SetNeedsStyleRecalc(
kSubtreeStyleChange,
StyleChangeReasonForTracing::Create(
@@ -1414,6 +1554,8 @@ void StyleEngine::InvalidateForRuleSetChanges(
return;
}
+ if (changed_rule_sets.IsEmpty())
+ return;
ScheduleInvalidationsForRuleSets(tree_scope, changed_rule_sets,
invalidation_scope);
}
@@ -1439,6 +1581,7 @@ void StyleEngine::ApplyUserRuleSetChanges(
global_rule_set_->MarkDirty();
unsigned changed_rule_flags = GetRuleSetFlags(changed_rule_sets);
+ bool has_rebuilt_font_cache = false;
if (changed_rule_flags & kFontFaceRules) {
if (ScopedStyleResolver* scoped_resolver =
GetDocument().GetScopedStyleResolver()) {
@@ -1449,7 +1592,7 @@ void StyleEngine::ApplyUserRuleSetChanges(
scoped_resolver->SetNeedsAppendAllSheets();
MarkDocumentDirty();
} else {
- ClearFontCacheAndAddUserFonts();
+ has_rebuilt_font_cache = ClearFontCacheAndAddUserFonts();
}
}
@@ -1466,7 +1609,8 @@ void StyleEngine::ApplyUserRuleSetChanges(
}
InvalidateForRuleSetChanges(GetDocument(), changed_rule_sets,
- changed_rule_flags, kInvalidateAllScopes);
+ changed_rule_flags, kInvalidateAllScopes,
+ has_rebuilt_font_cache);
}
void StyleEngine::ApplyRuleSetChanges(
@@ -1514,8 +1658,9 @@ void StyleEngine::ApplyRuleSetChanges(
}
}
+ bool has_rebuilt_font_cache = false;
if (rebuild_font_cache)
- ClearFontCacheAndAddUserFonts();
+ has_rebuilt_font_cache = ClearFontCacheAndAddUserFonts();
unsigned append_start_index = 0;
if (scoped_resolver) {
@@ -1538,7 +1683,43 @@ void StyleEngine::ApplyRuleSetChanges(
}
InvalidateForRuleSetChanges(tree_scope, changed_rule_sets, changed_rule_flags,
- kInvalidateCurrentScope);
+ kInvalidateCurrentScope, has_rebuilt_font_cache);
+}
+
+void StyleEngine::LoadVisionDeficiencyFilter() {
+ VisionDeficiency old_vision_deficiency = vision_deficiency_;
+ vision_deficiency_ = GetDocument().GetPage()->GetVisionDeficiency();
+ if (vision_deficiency_ == old_vision_deficiency)
+ return;
+
+ if (vision_deficiency_ == VisionDeficiency::kNoVisionDeficiency) {
+ vision_deficiency_filter_ = nullptr;
+ } else {
+ AtomicString url = CreateVisionDeficiencyFilterUrl(vision_deficiency_);
+ cssvalue::CSSURIValue css_uri_value(url);
+ SVGResource* svg_resource = css_uri_value.EnsureResourceReference();
+ // Note: The fact that we're using data: URLs here is an
+ // implementation detail. Emulating vision deficiencies should still
+ // work even if the Document's Content-Security-Policy disallows
+ // data: URLs.
+ svg_resource->LoadWithoutCSP(GetDocument());
+ vision_deficiency_filter_ =
+ MakeGarbageCollected<ReferenceFilterOperation>(url, svg_resource);
+ }
+}
+
+void StyleEngine::VisionDeficiencyChanged() {
+ MarkViewportStyleDirty();
+}
+
+void StyleEngine::ApplyVisionDeficiencyStyle(
+ scoped_refptr<ComputedStyle> layout_view_style) {
+ LoadVisionDeficiencyFilter();
+ if (vision_deficiency_filter_) {
+ FilterOperations ops;
+ ops.Operations().push_back(vision_deficiency_filter_);
+ layout_view_style->SetFilter(ops);
+ }
}
const MediaQueryEvaluator& StyleEngine::EnsureMediaQueryEvaluator() {
@@ -1556,35 +1737,24 @@ const MediaQueryEvaluator& StyleEngine::EnsureMediaQueryEvaluator() {
bool StyleEngine::MediaQueryAffectedByViewportChange() {
DCHECK(IsMaster());
DCHECK(global_rule_set_);
- const MediaQueryEvaluator& evaluator = EnsureMediaQueryEvaluator();
- const auto& results = global_rule_set_->GetRuleFeatureSet()
- .ViewportDependentMediaQueryResults();
- for (unsigned i = 0; i < results.size(); ++i) {
- if (evaluator.Eval(results[i].Expression()) != results[i].Result())
- return true;
- }
- return false;
+ return EnsureMediaQueryEvaluator().DidResultsChange(
+ global_rule_set_->GetRuleFeatureSet()
+ .ViewportDependentMediaQueryResults());
}
bool StyleEngine::MediaQueryAffectedByDeviceChange() {
DCHECK(IsMaster());
DCHECK(global_rule_set_);
- const MediaQueryEvaluator& evaluator = EnsureMediaQueryEvaluator();
- const auto& results =
- global_rule_set_->GetRuleFeatureSet().DeviceDependentMediaQueryResults();
- for (unsigned i = 0; i < results.size(); ++i) {
- if (evaluator.Eval(results[i].Expression()) != results[i].Result())
- return true;
- }
- return false;
+ return EnsureMediaQueryEvaluator().DidResultsChange(
+ global_rule_set_->GetRuleFeatureSet().DeviceDependentMediaQueryResults());
}
bool StyleEngine::UpdateRemUnits(const ComputedStyle* old_root_style,
const ComputedStyle* new_root_style) {
if (!new_root_style || !UsesRemUnits())
return false;
- if (!old_root_style ||
- old_root_style->FontSize() != new_root_style->FontSize()) {
+ if (!old_root_style || old_root_style->SpecifiedFontSize() !=
+ new_root_style->SpecifiedFontSize()) {
DCHECK(Resolver());
// Resolved rem units are stored in the matched properties cache so we need
// to make sure to invalidate the cache if the documentElement font size
@@ -1645,7 +1815,7 @@ void StyleEngine::NodeWillBeRemoved(Node& node) {
if (!layout_object)
return;
// Floating or out-of-flow elements do not affect whitespace siblings.
- if (layout_object->IsFloatingOrOutOfFlowPositioned())
+ if (!layout_object->AffectsWhitespaceSiblings())
return;
layout_object = layout_object->Parent();
while (layout_object->IsAnonymous())
@@ -1688,9 +1858,9 @@ void StyleEngine::CollectMatchingUserRules(
}
}
-void StyleEngine::AddUserFontFaceRules(const RuleSet& rule_set) {
+bool StyleEngine::AddUserFontFaceRules(const RuleSet& rule_set) {
if (!font_selector_)
- return;
+ return false;
const HeapVector<Member<StyleRuleFontFace>> font_face_rules =
rule_set.FontFaceRules();
@@ -1700,6 +1870,7 @@ void StyleEngine::AddUserFontFaceRules(const RuleSet& rule_set) {
}
if (resolver_ && font_face_rules.size())
resolver_->InvalidateMatchedPropertiesCache();
+ return font_face_rules.size();
}
void StyleEngine::AddUserKeyframeRules(const RuleSet& rule_set) {
@@ -1950,7 +2121,7 @@ void StyleEngine::UpdateColorScheme() {
forced_colors_ = web_theme_engine->GetForcedColors();
PreferredColorScheme old_preferred_color_scheme = preferred_color_scheme_;
- preferred_color_scheme_ = web_theme_engine->PreferredColorScheme();
+ preferred_color_scheme_ = settings->GetPreferredColorScheme();
if (const auto* overrides =
GetDocument().GetPage()->GetMediaFeatureOverrides()) {
MediaQueryExpValue value = overrides->GetOverride("prefers-color-scheme");
@@ -1960,7 +2131,7 @@ void StyleEngine::UpdateColorScheme() {
bool use_dark_scheme =
preferred_color_scheme_ == PreferredColorScheme::kDark &&
SupportsDarkColorScheme();
- if (!use_dark_scheme && settings->ForceDarkModeEnabled()) {
+ if (!use_dark_scheme && settings->GetForceDarkModeEnabled()) {
// Make sure we don't match (prefers-color-scheme: dark) when forced
// darkening is enabled.
preferred_color_scheme_ = PreferredColorScheme::kNoPreference;
@@ -1998,7 +2169,7 @@ void StyleEngine::UpdateColorSchemeBackground() {
if (auto* root_element = GetDocument().documentElement())
style = root_element->GetComputedStyle();
if (style) {
- if (style->UsedColorScheme() == WebColorScheme::kDark)
+ if (style->UsedColorSchemeForInitialColors() == WebColorScheme::kDark)
use_dark_background = true;
} else if (SupportsDarkColorScheme()) {
use_dark_background = true;
@@ -2046,7 +2217,7 @@ void StyleEngine::PropagateWritingModeAndDirectionToHTMLRoot() {
root_element->PropagateWritingModeAndDirectionFromBody();
}
-void StyleEngine::Trace(blink::Visitor* visitor) {
+void StyleEngine::Trace(Visitor* visitor) {
visitor->Trace(document_);
visitor->Trace(injected_user_style_sheets_);
visitor->Trace(injected_author_style_sheets_);
@@ -2060,6 +2231,7 @@ void StyleEngine::Trace(blink::Visitor* visitor) {
visitor->Trace(active_tree_scopes_);
visitor->Trace(tree_boundary_crossing_scopes_);
visitor->Trace(resolver_);
+ visitor->Trace(vision_deficiency_filter_);
visitor->Trace(viewport_resolver_);
visitor->Trace(media_query_evaluator_);
visitor->Trace(global_rule_set_);
diff --git a/chromium/third_party/blink/renderer/core/css/style_engine.h b/chromium/third_party/blink/renderer/core/css/style_engine.h
index 44e3046e90c..e33a320f61a 100644
--- a/chromium/third_party/blink/renderer/core/css/style_engine.h
+++ b/chromium/third_party/blink/renderer/core/css/style_engine.h
@@ -48,9 +48,11 @@
#include "third_party/blink/renderer/core/css/style_engine_context.h"
#include "third_party/blink/renderer/core/css/style_invalidation_root.h"
#include "third_party/blink/renderer/core/css/style_recalc_root.h"
+#include "third_party/blink/renderer/core/css/vision_deficiency.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/tree_ordered_list.h"
#include "third_party/blink/renderer/core/html/track/text_track.h"
+#include "third_party/blink/renderer/core/style/filter_operations.h"
#include "third_party/blink/renderer/platform/bindings/name_client.h"
#include "third_party/blink/renderer/platform/fonts/font_selector_client.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
@@ -80,7 +82,7 @@ using StyleSheetKey = AtomicString;
// The StyleEngine class manages style-related state for the document. There is
// a 1-1 relationship of Document to StyleEngine. The document calls the
-// StyleEngine when the the document is updated in a way that impacts styles.
+// StyleEngine when the document is updated in a way that impacts styles.
class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
public FontSelectorClient,
public NameClient {
@@ -154,7 +156,7 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
}
RuleSet* RuleSetForSheet(CSSStyleSheet&);
- void MediaQueryAffectingValueChanged();
+ void MediaQueryAffectingValueChanged(MediaValueChange change);
void UpdateActiveStyleSheetsInImport(
StyleEngine& master_engine,
DocumentStyleSheetCollector& parent_collector);
@@ -243,7 +245,6 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
void UpdateLayoutTreeRebuildRoot(ContainerNode* ancestor, Node* dirty_node);
CSSFontSelector* GetFontSelector() { return font_selector_; }
- void SetFontSelector(CSSFontSelector*);
void RemoveFontFaceRules(const HeapVector<Member<const StyleRuleFontFace>>&);
// updateGenericFontFamilySettings is used from WebSettingsImpl.
@@ -268,6 +269,7 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
}
void EnsureUAStyleForFullscreen();
+ void EnsureUAStyleForXrOverlay();
void EnsureUAStyleForElement(const Element&);
void PlatformColorsChanged();
@@ -323,6 +325,10 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
void ApplyUserRuleSetChanges(const ActiveStyleSheetVector& old_style_sheets,
const ActiveStyleSheetVector& new_style_sheets);
+ void VisionDeficiencyChanged();
+ void ApplyVisionDeficiencyStyle(
+ scoped_refptr<ComputedStyle> layout_view_style);
+
void CollectMatchingUserRules(ElementRuleCollector&) const;
void CustomPropertyRegistered();
@@ -344,6 +350,9 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
void MarkViewportStyleDirty();
bool IsViewportStyleDirty() const { return viewport_style_dirty_; }
+ void MarkFontsNeedUpdate();
+ void InvalidateStyleAndLayoutForFontUpdates();
+
StyleRuleKeyframes* KeyframeStylesForAnimation(
const AtomicString& animation_name);
@@ -375,13 +384,15 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
ForcedColors GetForcedColors() const { return forced_colors_; }
void UpdateColorSchemeBackground();
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
const char* NameInHeapSnapshot() const override { return "StyleEngine"; }
private:
// FontSelectorClient implementation.
void FontsNeedUpdate(FontSelector*) override;
+ void LoadVisionDeficiencyFilter();
+
private:
bool NeedsActiveStyleSheetUpdate() const {
return all_tree_scopes_dirty_ || tree_scopes_removed_ ||
@@ -404,8 +415,14 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
typedef HeapHashSet<Member<TreeScope>> UnorderedTreeScopeSet;
- void MediaQueryAffectingValueChanged(UnorderedTreeScopeSet&);
- void MediaQueryAffectingValueChanged(HeapHashSet<Member<TextTrack>>&);
+ bool MediaQueryAffectingValueChanged(const ActiveStyleSheetVector&,
+ MediaValueChange);
+ void MediaQueryAffectingValueChanged(TreeScope&, MediaValueChange);
+ void MediaQueryAffectingValueChanged(UnorderedTreeScopeSet&,
+ MediaValueChange);
+ void MediaQueryAffectingValueChanged(HeapHashSet<Member<TextTrack>>&,
+ MediaValueChange);
+
const RuleFeatureSet& GetRuleFeatureSet() const {
DCHECK(IsMaster());
DCHECK(global_rule_set_);
@@ -447,7 +464,8 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
TreeScope& tree_scope,
const HeapHashSet<Member<RuleSet>>& changed_rule_sets,
unsigned changed_rule_flags,
- InvalidationScope invalidation_scope);
+ InvalidationScope invalidation_scope,
+ bool rebuild_font_cache);
void InvalidateInitialData();
void UpdateViewport();
@@ -461,11 +479,14 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
const MediaQueryEvaluator& EnsureMediaQueryEvaluator();
void UpdateStyleSheetList(TreeScope&);
- void ClearFontCacheAndAddUserFonts();
+ // Returns true if any @font-face rules are added or removed.
+ bool ClearFontCacheAndAddUserFonts();
+
void ClearKeyframeRules() { keyframes_rule_map_.clear(); }
void ClearPropertyRules();
- void AddUserFontFaceRules(const RuleSet&);
+ // Returns true if any @font-face rules are added.
+ bool AddUserFontFaceRules(const RuleSet&);
void AddUserKeyframeRules(const RuleSet&);
void AddUserKeyframeStyle(StyleRuleKeyframes*);
void AddPropertyRules(const RuleSet&);
@@ -528,6 +549,10 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
bool in_layout_tree_rebuild_ = false;
bool in_dom_removal_ = false;
bool viewport_style_dirty_ = false;
+ bool fonts_need_update_ = false;
+
+ VisionDeficiency vision_deficiency_ = VisionDeficiency::kNoVisionDeficiency;
+ Member<ReferenceFilterOperation> vision_deficiency_filter_;
Member<StyleResolver> resolver_;
Member<ViewportStyleResolver> viewport_resolver_;
@@ -577,9 +602,9 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
// scheme is used to opt-out of forced darkening.
Member<const CSSValue> meta_color_scheme_;
- // The preferred color scheme is set in WebThemeEngine, but may be overridden
- // by the ForceDarkMode setting where the preferred_color_scheme_ will be set
- // to kNoPreference to avoid dark styling to be applied before auto darkening.
+ // The preferred color scheme is set in settings, but may be overridden by the
+ // ForceDarkMode setting where the preferred_color_scheme_ will be set to
+ // kNoPreference to avoid dark styling to be applied before auto darkening.
PreferredColorScheme preferred_color_scheme_ =
PreferredColorScheme::kNoPreference;
diff --git a/chromium/third_party/blink/renderer/core/css/style_engine_test.cc b/chromium/third_party/blink/renderer/core/css/style_engine_test.cc
index ea225bc6809..0bab3c371e1 100644
--- a/chromium/third_party/blink/renderer/core/css/style_engine_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/style_engine_test.cc
@@ -13,6 +13,7 @@
#include "third_party/blink/public/platform/web_float_rect.h"
#include "third_party/blink/public/platform/web_theme_engine.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_shadow_root_init.h"
#include "third_party/blink/renderer/core/animation/element_animations.h"
#include "third_party/blink/renderer/core/css/css_font_selector.h"
#include "third_party/blink/renderer/core/css/css_rule_list.h"
@@ -25,7 +26,6 @@
#include "third_party/blink/renderer/core/dom/first_letter_pseudo_element.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
-#include "third_party/blink/renderer/core/dom/shadow_root_init.h"
#include "third_party/blink/renderer/core/dom/slot_assignment_engine.h"
#include "third_party/blink/renderer/core/dom/text.h"
#include "third_party/blink/renderer/core/frame/frame_test_helpers.h"
@@ -65,8 +65,7 @@ class StyleEngineTest : public testing::Test {
// A wrapper to add a reason for UpdateAllLifecyclePhases
void UpdateAllLifecyclePhases() {
- GetDocument().View()->UpdateAllLifecyclePhases(
- DocumentLifecycle::LifecycleUpdateReason::kTest);
+ GetDocument().View()->UpdateAllLifecyclePhases(DocumentUpdateReason::kTest);
}
Node* GetStyleRecalcRoot() {
@@ -110,7 +109,7 @@ TEST_F(StyleEngineTest, DocumentDirtyAfterInject) {
}
TEST_F(StyleEngineTest, AnalyzedInject) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
@font-face {
font-family: 'Cool Font';
@@ -297,7 +296,7 @@ TEST_F(StyleEngineTest, AnalyzedInject) {
auto* style_element = MakeGarbageCollected<HTMLStyleElement>(
GetDocument(), CreateElementFlags());
- style_element->SetInnerHTMLFromString(
+ style_element->setInnerHTML(
"@font-face {"
" font-family: 'Cool Font';"
" src: url(dummy);"
@@ -366,8 +365,7 @@ TEST_F(StyleEngineTest, AnalyzedInject) {
style_element = MakeGarbageCollected<HTMLStyleElement>(GetDocument(),
CreateElementFlags());
- style_element->SetInnerHTMLFromString(
- "@keyframes dummy-animation { from {} to {} }");
+ style_element->setInnerHTML("@keyframes dummy-animation { from {} to {} }");
GetDocument().body()->AppendChild(style_element);
UpdateAllLifecyclePhases();
@@ -621,7 +619,7 @@ TEST_F(StyleEngineTest, AnalyzedInject) {
}
TEST_F(StyleEngineTest, InjectedFontFace) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
@font-face {
font-family: 'Author';
@@ -654,7 +652,7 @@ TEST_F(StyleEngineTest, InjectedFontFace) {
}
TEST_F(StyleEngineTest, IgnoreInvalidPropertyValue) {
- GetDocument().body()->SetInnerHTMLFromString(
+ GetDocument().body()->setInnerHTML(
"<section><div id='t1'>Red</div></section>"
"<style id='s1'>div { color: red; } section div#t1 { color:rgb(0");
UpdateAllLifecyclePhases();
@@ -706,7 +704,7 @@ TEST_F(StyleEngineTest, TextToSheetCache) {
}
TEST_F(StyleEngineTest, RuleSetInvalidationTypeSelectors) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<div>
<span></span>
<div></div>
@@ -752,7 +750,7 @@ TEST_F(StyleEngineTest, RuleSetInvalidationTypeSelectors) {
}
TEST_F(StyleEngineTest, RuleSetInvalidationCustomPseudo) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>progress { -webkit-appearance:none }</style>
<progress></progress>
<div></div><div></div><div></div><div></div><div></div><div></div>
@@ -770,7 +768,7 @@ TEST_F(StyleEngineTest, RuleSetInvalidationCustomPseudo) {
}
TEST_F(StyleEngineTest, RuleSetInvalidationHost) {
- GetDocument().body()->SetInnerHTMLFromString(
+ GetDocument().body()->setInnerHTML(
"<div id=nohost></div><div id=host></div>");
Element* host = GetDocument().getElementById("host");
ASSERT_TRUE(host);
@@ -778,7 +776,7 @@ TEST_F(StyleEngineTest, RuleSetInvalidationHost) {
ShadowRoot& shadow_root =
host->AttachShadowRootInternal(ShadowRootType::kOpen);
- shadow_root.SetInnerHTMLFromString("<div></div><div></div><div></div>");
+ shadow_root.setInnerHTML("<div></div><div></div><div></div>");
UpdateAllLifecyclePhases();
unsigned before_count = GetStyleEngine().StyleForElementCount();
@@ -809,7 +807,7 @@ TEST_F(StyleEngineTest, RuleSetInvalidationHost) {
}
TEST_F(StyleEngineTest, RuleSetInvalidationSlotted) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<div id=host>
<span slot=other class=s1></span>
<span class=s2></span>
@@ -824,7 +822,7 @@ TEST_F(StyleEngineTest, RuleSetInvalidationSlotted) {
ShadowRoot& shadow_root =
host->AttachShadowRootInternal(ShadowRootType::kOpen);
- shadow_root.SetInnerHTMLFromString("<slot name=other></slot><slot></slot>");
+ shadow_root.setInnerHTML("<slot name=other></slot><slot></slot>");
UpdateAllLifecyclePhases();
unsigned before_count = GetStyleEngine().StyleForElementCount();
@@ -845,15 +843,14 @@ TEST_F(StyleEngineTest, RuleSetInvalidationSlotted) {
}
TEST_F(StyleEngineTest, RuleSetInvalidationHostContext) {
- GetDocument().body()->SetInnerHTMLFromString("<div id=host></div>");
+ GetDocument().body()->setInnerHTML("<div id=host></div>");
Element* host = GetDocument().getElementById("host");
ASSERT_TRUE(host);
ShadowRoot& shadow_root =
host->AttachShadowRootInternal(ShadowRootType::kOpen);
- shadow_root.SetInnerHTMLFromString(
- "<div></div><div class=a></div><div></div>");
+ shadow_root.setInnerHTML("<div></div><div class=a></div><div></div>");
UpdateAllLifecyclePhases();
unsigned before_count = GetStyleEngine().StyleForElementCount();
@@ -873,15 +870,14 @@ TEST_F(StyleEngineTest, RuleSetInvalidationHostContext) {
}
TEST_F(StyleEngineTest, RuleSetInvalidationV0BoundaryCrossing) {
- GetDocument().body()->SetInnerHTMLFromString("<div id=host></div>");
+ GetDocument().body()->setInnerHTML("<div id=host></div>");
Element* host = GetDocument().getElementById("host");
ASSERT_TRUE(host);
ShadowRoot& shadow_root =
host->AttachShadowRootInternal(ShadowRootType::kOpen);
- shadow_root.SetInnerHTMLFromString(
- "<div></div><div class=a></div><div></div>");
+ shadow_root.setInnerHTML("<div></div><div class=a></div><div></div>");
UpdateAllLifecyclePhases();
EXPECT_EQ(ScheduleInvalidationsForRules(
@@ -890,7 +886,7 @@ TEST_F(StyleEngineTest, RuleSetInvalidationV0BoundaryCrossing) {
}
TEST_F(StyleEngineTest, HasViewportDependentMediaQueries) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>div {}</style>
<style id='sheet' media='(min-width: 200px)'>
div {}
@@ -915,7 +911,7 @@ TEST_F(StyleEngineTest, HasViewportDependentMediaQueries) {
}
TEST_F(StyleEngineTest, StyleMediaAttributeStyleChange) {
- GetDocument().body()->SetInnerHTMLFromString(
+ GetDocument().body()->setInnerHTML(
"<style id='s1' media='(max-width: 1px)'>#t1 { color: green }</style>"
"<div id='t1'>Green</div><div></div>");
UpdateAllLifecyclePhases();
@@ -941,7 +937,7 @@ TEST_F(StyleEngineTest, StyleMediaAttributeStyleChange) {
}
TEST_F(StyleEngineTest, StyleMediaAttributeNoStyleChange) {
- GetDocument().body()->SetInnerHTMLFromString(
+ GetDocument().body()->setInnerHTML(
"<style id='s1' media='(max-width: 1000px)'>#t1 { color: green }</style>"
"<div id='t1'>Green</div><div></div>");
UpdateAllLifecyclePhases();
@@ -972,7 +968,7 @@ TEST_F(StyleEngineTest, ModifyStyleRuleMatchedPropertiesCache) {
// CSSPropertyValueSet pointers. When a mutable CSSPropertyValueSet is
// modified, the pointer doesn't change, yet the declarations do.
- GetDocument().body()->SetInnerHTMLFromString(
+ GetDocument().body()->setInnerHTML(
"<style id='s1'>#t1 { color: blue }</style>"
"<div id='t1'>Green</div>");
UpdateAllLifecyclePhases();
@@ -996,16 +992,16 @@ TEST_F(StyleEngineTest, ModifyStyleRuleMatchedPropertiesCache) {
// Modify the CSSPropertyValueSet once to make it a mutable set. Subsequent
// modifications will not change the CSSPropertyValueSet pointer and cache
// hash value will be the same.
- style_rule->style()->setProperty(&GetDocument(), "color", "red", "",
- ASSERT_NO_EXCEPTION);
+ style_rule->style()->setProperty(GetDocument().GetExecutionContext(), "color",
+ "red", "", ASSERT_NO_EXCEPTION);
UpdateAllLifecyclePhases();
ASSERT_TRUE(t1->GetComputedStyle());
EXPECT_EQ(MakeRGB(255, 0, 0), t1->GetComputedStyle()->VisitedDependentColor(
GetCSSPropertyColor()));
- style_rule->style()->setProperty(&GetDocument(), "color", "green", "",
- ASSERT_NO_EXCEPTION);
+ style_rule->style()->setProperty(GetDocument().GetExecutionContext(), "color",
+ "green", "", ASSERT_NO_EXCEPTION);
UpdateAllLifecyclePhases();
ASSERT_TRUE(t1->GetComputedStyle());
@@ -1014,7 +1010,7 @@ TEST_F(StyleEngineTest, ModifyStyleRuleMatchedPropertiesCache) {
}
TEST_F(StyleEngineTest, VisitedExplicitInheritanceMatchedPropertiesCache) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
:visited { overflow: inherit }
</style>
@@ -1036,7 +1032,7 @@ TEST_F(StyleEngineTest, VisitedExplicitInheritanceMatchedPropertiesCache) {
}
TEST_F(StyleEngineTest, ScheduleInvalidationAfterSubtreeRecalc) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style id='s1'>
.t1 span { color: green }
.t2 span { color: green }
@@ -1108,8 +1104,8 @@ TEST_F(StyleEngineTest, ScheduleInvalidationAfterSubtreeRecalc) {
EXPECT_FALSE(t2->NeedsStyleInvalidation());
}
-TEST_F(StyleEngineTest, NoScheduledRuleSetInvalidationsOnNewShadow) {
- GetDocument().body()->SetInnerHTMLFromString("<div id='host'></div>");
+TEST_F(StyleEngineTest, ScheduleRuleSetInvalidationsOnNewShadow) {
+ GetDocument().body()->setInnerHTML("<div id='host'></div>");
Element* host = GetDocument().getElementById("host");
ASSERT_TRUE(host);
@@ -1117,7 +1113,7 @@ TEST_F(StyleEngineTest, NoScheduledRuleSetInvalidationsOnNewShadow) {
ShadowRoot& shadow_root =
host->AttachShadowRootInternal(ShadowRootType::kOpen);
- shadow_root.SetInnerHTMLFromString(R"HTML(
+ shadow_root.setInnerHTML(R"HTML(
<style>
span { color: green }
t1 { color: green }
@@ -1127,12 +1123,13 @@ TEST_F(StyleEngineTest, NoScheduledRuleSetInvalidationsOnNewShadow) {
)HTML");
GetStyleEngine().UpdateActiveStyle();
- EXPECT_FALSE(GetDocument().ChildNeedsStyleInvalidation());
+ EXPECT_TRUE(GetDocument().ChildNeedsStyleInvalidation());
EXPECT_FALSE(GetDocument().NeedsStyleInvalidation());
+ EXPECT_TRUE(shadow_root.NeedsStyleInvalidation());
}
TEST_F(StyleEngineTest, EmptyHttpEquivDefaultStyle) {
- GetDocument().body()->SetInnerHTMLFromString(
+ GetDocument().body()->setInnerHTML(
"<style>div { color:pink }</style><div id=container></div>");
UpdateAllLifecyclePhases();
@@ -1140,18 +1137,16 @@ TEST_F(StyleEngineTest, EmptyHttpEquivDefaultStyle) {
Element* container = GetDocument().getElementById("container");
ASSERT_TRUE(container);
- container->SetInnerHTMLFromString(
- "<meta http-equiv='default-style' content=''>");
+ container->setInnerHTML("<meta http-equiv='default-style' content=''>");
EXPECT_FALSE(GetStyleEngine().NeedsActiveStyleUpdate());
- container->SetInnerHTMLFromString(
+ container->setInnerHTML(
"<meta http-equiv='default-style' content='preferred'>");
EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
}
TEST_F(StyleEngineTest, StyleSheetsForStyleSheetList_Document) {
- GetDocument().body()->SetInnerHTMLFromString(
- "<style>span { color: green }</style>");
+ GetDocument().body()->setInnerHTML("<style>span { color: green }</style>");
EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
const auto& sheet_list =
@@ -1159,7 +1154,7 @@ TEST_F(StyleEngineTest, StyleSheetsForStyleSheetList_Document) {
EXPECT_EQ(1u, sheet_list.size());
EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
- GetDocument().body()->SetInnerHTMLFromString(
+ GetDocument().body()->setInnerHTML(
"<style>span { color: green }</style><style>div { color: pink }</style>");
EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
@@ -1174,7 +1169,7 @@ TEST_F(StyleEngineTest, StyleSheetsForStyleSheetList_Document) {
}
TEST_F(StyleEngineTest, StyleSheetsForStyleSheetList_ShadowRoot) {
- GetDocument().body()->SetInnerHTMLFromString("<div id='host'></div>");
+ GetDocument().body()->setInnerHTML("<div id='host'></div>");
Element* host = GetDocument().getElementById("host");
ASSERT_TRUE(host);
@@ -1182,7 +1177,7 @@ TEST_F(StyleEngineTest, StyleSheetsForStyleSheetList_ShadowRoot) {
ShadowRoot& shadow_root =
host->AttachShadowRootInternal(ShadowRootType::kOpen);
- shadow_root.SetInnerHTMLFromString("<style>span { color: green }</style>");
+ shadow_root.setInnerHTML("<style>span { color: green }</style>");
EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
const auto& sheet_list =
@@ -1190,7 +1185,7 @@ TEST_F(StyleEngineTest, StyleSheetsForStyleSheetList_ShadowRoot) {
EXPECT_EQ(1u, sheet_list.size());
EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
- shadow_root.SetInnerHTMLFromString(
+ shadow_root.setInnerHTML(
"<style>span { color: green }</style><style>div { color: pink }</style>");
EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
@@ -1230,7 +1225,7 @@ TEST_F(StyleEngineTest, ViewportDescriptionForZoomDSF) {
WebViewImpl* web_view_impl =
web_view_helper.Initialize(nullptr, nullptr, &client);
web_view_impl->MainFrameWidget()->UpdateAllLifecyclePhases(
- WebWidget::LifecycleUpdateReason::kTest);
+ DocumentUpdateReason::kTest);
Document* document =
To<LocalFrame>(web_view_impl->GetPage()->MainFrame())->GetDocument();
@@ -1244,7 +1239,7 @@ TEST_F(StyleEngineTest, ViewportDescriptionForZoomDSF) {
const float device_scale = 3.5f;
client.set_device_scale_factor(device_scale);
web_view_impl->MainFrameWidget()->UpdateAllLifecyclePhases(
- WebWidget::LifecycleUpdateReason::kTest);
+ DocumentUpdateReason::kTest);
desc = document->GetViewportData().GetViewportDescription();
EXPECT_FLOAT_EQ(device_scale * min_width, desc.min_width.GetFloatValue());
@@ -1254,28 +1249,25 @@ TEST_F(StyleEngineTest, ViewportDescriptionForZoomDSF) {
}
TEST_F(StyleEngineTest, MediaQueryAffectingValueChanged_StyleElementNoMedia) {
- GetDocument().body()->SetInnerHTMLFromString(
- "<style>div{color:pink}</style>");
+ GetDocument().body()->setInnerHTML("<style>div{color:pink}</style>");
UpdateAllLifecyclePhases();
- GetStyleEngine().MediaQueryAffectingValueChanged();
+ GetStyleEngine().MediaQueryAffectingValueChanged(MediaValueChange::kOther);
EXPECT_FALSE(GetStyleEngine().NeedsActiveStyleUpdate());
}
TEST_F(StyleEngineTest,
MediaQueryAffectingValueChanged_StyleElementMediaNoValue) {
- GetDocument().body()->SetInnerHTMLFromString(
- "<style media>div{color:pink}</style>");
+ GetDocument().body()->setInnerHTML("<style media>div{color:pink}</style>");
UpdateAllLifecyclePhases();
- GetStyleEngine().MediaQueryAffectingValueChanged();
+ GetStyleEngine().MediaQueryAffectingValueChanged(MediaValueChange::kOther);
EXPECT_FALSE(GetStyleEngine().NeedsActiveStyleUpdate());
}
TEST_F(StyleEngineTest,
MediaQueryAffectingValueChanged_StyleElementMediaEmpty) {
- GetDocument().body()->SetInnerHTMLFromString(
- "<style media=''>div{color:pink}</style>");
+ GetDocument().body()->setInnerHTML("<style media=''>div{color:pink}</style>");
UpdateAllLifecyclePhases();
- GetStyleEngine().MediaQueryAffectingValueChanged();
+ GetStyleEngine().MediaQueryAffectingValueChanged(MediaValueChange::kOther);
EXPECT_FALSE(GetStyleEngine().NeedsActiveStyleUpdate());
}
@@ -1285,40 +1277,40 @@ TEST_F(StyleEngineTest,
TEST_F(StyleEngineTest,
MediaQueryAffectingValueChanged_StyleElementMediaNoValid) {
- GetDocument().body()->SetInnerHTMLFromString(
+ GetDocument().body()->setInnerHTML(
"<style media=',,'>div{color:pink}</style>");
UpdateAllLifecyclePhases();
- GetStyleEngine().MediaQueryAffectingValueChanged();
+ GetStyleEngine().MediaQueryAffectingValueChanged(MediaValueChange::kOther);
EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
}
TEST_F(StyleEngineTest, MediaQueryAffectingValueChanged_StyleElementMediaAll) {
- GetDocument().body()->SetInnerHTMLFromString(
+ GetDocument().body()->setInnerHTML(
"<style media='all'>div{color:pink}</style>");
UpdateAllLifecyclePhases();
- GetStyleEngine().MediaQueryAffectingValueChanged();
+ GetStyleEngine().MediaQueryAffectingValueChanged(MediaValueChange::kOther);
EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
}
TEST_F(StyleEngineTest,
MediaQueryAffectingValueChanged_StyleElementMediaNotAll) {
- GetDocument().body()->SetInnerHTMLFromString(
+ GetDocument().body()->setInnerHTML(
"<style media='not all'>div{color:pink}</style>");
UpdateAllLifecyclePhases();
- GetStyleEngine().MediaQueryAffectingValueChanged();
+ GetStyleEngine().MediaQueryAffectingValueChanged(MediaValueChange::kOther);
EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
}
TEST_F(StyleEngineTest, MediaQueryAffectingValueChanged_StyleElementMediaType) {
- GetDocument().body()->SetInnerHTMLFromString(
+ GetDocument().body()->setInnerHTML(
"<style media='print'>div{color:pink}</style>");
UpdateAllLifecyclePhases();
- GetStyleEngine().MediaQueryAffectingValueChanged();
+ GetStyleEngine().MediaQueryAffectingValueChanged(MediaValueChange::kOther);
EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
}
TEST_F(StyleEngineTest, EmptyPseudo_RemoveLast) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
.empty:empty + span { color: purple }
</style>
@@ -1340,7 +1332,7 @@ TEST_F(StyleEngineTest, EmptyPseudo_RemoveLast) {
}
TEST_F(StyleEngineTest, EmptyPseudo_RemoveNotLast) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
.empty:empty + span { color: purple }
</style>
@@ -1362,7 +1354,7 @@ TEST_F(StyleEngineTest, EmptyPseudo_RemoveNotLast) {
}
TEST_F(StyleEngineTest, EmptyPseudo_InsertFirst) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
.empty:empty + span { color: purple }
</style>
@@ -1384,7 +1376,7 @@ TEST_F(StyleEngineTest, EmptyPseudo_InsertFirst) {
}
TEST_F(StyleEngineTest, EmptyPseudo_InsertNotFirst) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
.empty:empty + span { color: purple }
</style>
@@ -1406,7 +1398,7 @@ TEST_F(StyleEngineTest, EmptyPseudo_InsertNotFirst) {
}
TEST_F(StyleEngineTest, EmptyPseudo_ModifyTextData_SingleNode) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
.empty:empty + span { color: purple }
</style>
@@ -1439,7 +1431,7 @@ TEST_F(StyleEngineTest, EmptyPseudo_ModifyTextData_SingleNode) {
}
TEST_F(StyleEngineTest, EmptyPseudo_ModifyTextData_HasSiblings) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
.empty:empty + span { color: purple }
</style>
@@ -1470,7 +1462,7 @@ TEST_F(StyleEngineTest, EmptyPseudo_ModifyTextData_HasSiblings) {
}
TEST_F(StyleEngineTest, MediaQueriesChangeDefaultFontSize) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
body { color: red }
@media (max-width: 40em) {
@@ -1493,9 +1485,10 @@ TEST_F(StyleEngineTest, MediaQueriesChangeDefaultFontSize) {
}
TEST_F(StyleEngineTest, MediaQueriesChangeColorScheme) {
- ScopedMediaQueryPrefersColorSchemeForTest feature_scope(true);
+ ColorSchemeHelper color_scheme_helper(GetDocument());
+ color_scheme_helper.SetPreferredColorScheme(PreferredColorScheme::kLight);
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
body { color: red }
@media (prefers-color-scheme: dark) {
@@ -1510,9 +1503,7 @@ TEST_F(StyleEngineTest, MediaQueriesChangeColorScheme) {
GetDocument().body()->GetComputedStyle()->VisitedDependentColor(
GetCSSPropertyColor()));
- ColorSchemeHelper color_scheme_helper;
- color_scheme_helper.SetPreferredColorScheme(GetDocument(),
- PreferredColorScheme::kDark);
+ color_scheme_helper.SetPreferredColorScheme(PreferredColorScheme::kDark);
UpdateAllLifecyclePhases();
EXPECT_EQ(MakeRGB(0, 128, 0),
GetDocument().body()->GetComputedStyle()->VisitedDependentColor(
@@ -1520,14 +1511,11 @@ TEST_F(StyleEngineTest, MediaQueriesChangeColorScheme) {
}
TEST_F(StyleEngineTest, MediaQueriesChangeColorSchemeForcedDarkMode) {
- ScopedMediaQueryPrefersColorSchemeForTest feature_scope(true);
-
GetDocument().GetSettings()->SetForceDarkModeEnabled(true);
- ColorSchemeHelper color_scheme_helper;
- color_scheme_helper.SetPreferredColorScheme(GetDocument(),
- PreferredColorScheme::kDark);
+ ColorSchemeHelper color_scheme_helper(GetDocument());
+ color_scheme_helper.SetPreferredColorScheme(PreferredColorScheme::kDark);
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
@media (prefers-color-scheme: no-preference) {
body { color: green }
@@ -1546,7 +1534,7 @@ TEST_F(StyleEngineTest, MediaQueriesChangeColorSchemeForcedDarkMode) {
}
TEST_F(StyleEngineTest, MediaQueriesChangePrefersReducedMotion) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
body { color: red }
@media (prefers-reduced-motion: reduce) {
@@ -1570,7 +1558,7 @@ TEST_F(StyleEngineTest, MediaQueriesChangePrefersReducedMotion) {
TEST_F(StyleEngineTest, MediaQueriesChangeForcedColors) {
ScopedForcedColorsForTest scoped_feature(true);
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
body {
forced-color-adjust: none;
@@ -1590,7 +1578,7 @@ TEST_F(StyleEngineTest, MediaQueriesChangeForcedColors) {
GetDocument().body()->GetComputedStyle()->VisitedDependentColor(
GetCSSPropertyColor()));
- ColorSchemeHelper color_scheme_helper;
+ ColorSchemeHelper color_scheme_helper(GetDocument());
color_scheme_helper.SetForcedColors(GetDocument(), ForcedColors::kActive);
UpdateAllLifecyclePhases();
EXPECT_EQ(MakeRGB(0, 128, 0),
@@ -1600,7 +1588,7 @@ TEST_F(StyleEngineTest, MediaQueriesChangeForcedColors) {
TEST_F(StyleEngineTest, MediaQueriesChangeForcedColorsAndPreferredColorScheme) {
ScopedForcedColorsForTest scoped_feature(true);
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
body {
forced-color-adjust: none;
@@ -1625,18 +1613,16 @@ TEST_F(StyleEngineTest, MediaQueriesChangeForcedColorsAndPreferredColorScheme) {
)HTML");
// ForcedColors = kNone, PreferredColorScheme = kLight
- ColorSchemeHelper color_scheme_helper;
+ ColorSchemeHelper color_scheme_helper(GetDocument());
color_scheme_helper.SetForcedColors(GetDocument(), ForcedColors::kNone);
- color_scheme_helper.SetPreferredColorScheme(GetDocument(),
- PreferredColorScheme::kLight);
+ color_scheme_helper.SetPreferredColorScheme(PreferredColorScheme::kLight);
UpdateAllLifecyclePhases();
EXPECT_EQ(MakeRGB(255, 0, 0),
GetDocument().body()->GetComputedStyle()->VisitedDependentColor(
GetCSSPropertyColor()));
// ForcedColors = kNone, PreferredColorScheme = kDark
- color_scheme_helper.SetPreferredColorScheme(GetDocument(),
- PreferredColorScheme::kDark);
+ color_scheme_helper.SetPreferredColorScheme(PreferredColorScheme::kDark);
UpdateAllLifecyclePhases();
EXPECT_EQ(MakeRGB(0, 128, 0),
GetDocument().body()->GetComputedStyle()->VisitedDependentColor(
@@ -1651,15 +1637,14 @@ TEST_F(StyleEngineTest, MediaQueriesChangeForcedColorsAndPreferredColorScheme) {
// ForcedColors = kActive, PreferredColorScheme = kNoPreference
color_scheme_helper.SetPreferredColorScheme(
- GetDocument(), PreferredColorScheme::kNoPreference);
+ PreferredColorScheme::kNoPreference);
UpdateAllLifecyclePhases();
EXPECT_EQ(MakeRGB(255, 255, 0),
GetDocument().body()->GetComputedStyle()->VisitedDependentColor(
GetCSSPropertyColor()));
// ForcedColors = kActive, PreferredColorScheme = kLight
- color_scheme_helper.SetPreferredColorScheme(GetDocument(),
- PreferredColorScheme::kLight);
+ color_scheme_helper.SetPreferredColorScheme(PreferredColorScheme::kLight);
UpdateAllLifecyclePhases();
EXPECT_EQ(MakeRGB(0, 0, 255),
GetDocument().body()->GetComputedStyle()->VisitedDependentColor(
@@ -1667,12 +1652,12 @@ TEST_F(StyleEngineTest, MediaQueriesChangeForcedColorsAndPreferredColorScheme) {
}
TEST_F(StyleEngineTest, MediaQueriesColorSchemeOverride) {
- ScopedMediaQueryPrefersColorSchemeForTest feature_scope(true);
-
+ ColorSchemeHelper color_scheme_helper(GetDocument());
+ color_scheme_helper.SetPreferredColorScheme(PreferredColorScheme::kLight);
EXPECT_EQ(PreferredColorScheme::kLight,
- Platform::Current()->ThemeEngine()->PreferredColorScheme());
+ GetDocument().GetSettings()->GetPreferredColorScheme());
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
body { color: red }
@media (prefers-color-scheme: dark) {
@@ -1704,7 +1689,7 @@ TEST_F(StyleEngineTest, MediaQueriesColorSchemeOverride) {
TEST_F(StyleEngineTest, MediaQueriesReducedMotionOverride) {
EXPECT_FALSE(GetDocument().GetSettings()->GetPrefersReducedMotion());
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
body { color: red }
@media (prefers-reduced-motion: reduce) {
@@ -1735,7 +1720,7 @@ TEST_F(StyleEngineTest, MediaQueriesReducedMotionOverride) {
TEST_F(StyleEngineTest, MediaQueriesChangeNavigationControls) {
ScopedMediaQueryNavigationControlsForTest scoped_feature(true);
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
@media (navigation-controls: none) {
body { color: red }
@@ -1761,14 +1746,14 @@ TEST_F(StyleEngineTest, MediaQueriesChangeNavigationControls) {
}
TEST_F(StyleEngineTest, ShadowRootStyleRecalcCrash) {
- GetDocument().body()->SetInnerHTMLFromString("<div id=host></div>");
+ GetDocument().body()->setInnerHTML("<div id=host></div>");
auto* host = To<HTMLElement>(GetDocument().getElementById("host"));
ASSERT_TRUE(host);
ShadowRoot& shadow_root =
host->AttachShadowRootInternal(ShadowRootType::kOpen);
- shadow_root.SetInnerHTMLFromString(R"HTML(
+ shadow_root.setInnerHTML(R"HTML(
<span id=span></span>
<style>
:nth-child(odd) { color: green }
@@ -1783,7 +1768,7 @@ TEST_F(StyleEngineTest, ShadowRootStyleRecalcCrash) {
}
TEST_F(StyleEngineTest, GetComputedStyleOutsideFlatTreeCrash) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
body, div { display: contents }
div::before { display: contents; content: "" }
@@ -1800,7 +1785,7 @@ TEST_F(StyleEngineTest, GetComputedStyleOutsideFlatTreeCrash) {
}
TEST_F(StyleEngineTest, RejectSelectorForPseudoElement) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
div::before { content: "" }
.not-in-filter div::before { color: red }
@@ -1810,10 +1795,13 @@ TEST_F(StyleEngineTest, RejectSelectorForPseudoElement) {
UpdateAllLifecyclePhases();
StyleEngine& engine = GetStyleEngine();
+ // If the Stats() were already enabled, we would not start with 0 counts.
+ EXPECT_FALSE(engine.Stats());
engine.SetStatsEnabled(true);
StyleResolverStats* stats = engine.Stats();
ASSERT_TRUE(stats);
+ EXPECT_EQ(0u, stats->rules_fast_rejected);
Element* div = GetDocument().QuerySelector("div");
ASSERT_TRUE(div);
@@ -1828,7 +1816,7 @@ TEST_F(StyleEngineTest, RejectSelectorForPseudoElement) {
}
TEST_F(StyleEngineTest, MarkForWhitespaceReattachment) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<div id=d1><span></span></div>
<div id=d2><span></span><span></span></div>
<div id=d3><span></span><span></span></div>
@@ -1874,7 +1862,7 @@ TEST_F(StyleEngineTest, MarkForWhitespaceReattachment) {
}
TEST_F(StyleEngineTest, FirstLetterRemoved) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>.fl::first-letter { color: pink }</style>
<div class=fl id=d1><div><span id=f1>A</span></div></div>
<div class=fl id=d2><div><span id=f2>BB</span></div></div>
@@ -1952,8 +1940,7 @@ TEST_F(StyleEngineTest, InitialDataCreation) {
EXPECT_TRUE(data1);
// After a full recalc, we should have the same initial data.
- GetDocument().body()->SetInnerHTMLFromString(
- "<style>* { font-size: 1px; } </style>");
+ GetDocument().body()->setInnerHTML("<style>* { font-size: 1px; } </style>");
EXPECT_TRUE(GetDocument().documentElement()->NeedsStyleRecalc());
EXPECT_TRUE(GetDocument().documentElement()->ChildNeedsStyleRecalc());
UpdateAllLifecyclePhases();
@@ -1969,7 +1956,7 @@ TEST_F(StyleEngineTest, InitialDataCreation) {
}
TEST_F(StyleEngineTest, CSSSelectorEmptyWhitespaceOnlyFail) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>.match:empty { background-color: red }</style>
<div></div>
<div> <span></span></div>
@@ -1977,8 +1964,7 @@ TEST_F(StyleEngineTest, CSSSelectorEmptyWhitespaceOnlyFail) {
<div></div>
<div> <!-- --></div>
)HTML");
- GetDocument().View()->UpdateAllLifecyclePhases(
- DocumentLifecycle::LifecycleUpdateReason::kTest);
+ GetDocument().View()->UpdateAllLifecyclePhases(DocumentUpdateReason::kTest);
EXPECT_FALSE(GetDocument().IsUseCounted(
WebFeature::kCSSSelectorEmptyWhitespaceOnlyFail));
@@ -1990,7 +1976,7 @@ TEST_F(StyleEngineTest, CSSSelectorEmptyWhitespaceOnlyFail) {
auto is_counted = [](Element* element) {
element->setAttribute(blink::html_names::kClassAttr, "match");
element->GetDocument().View()->UpdateAllLifecyclePhases(
- DocumentLifecycle::LifecycleUpdateReason::kTest);
+ DocumentUpdateReason::kTest);
return element->GetDocument().IsUseCounted(
WebFeature::kCSSSelectorEmptyWhitespaceOnlyFail);
};
@@ -2003,7 +1989,7 @@ TEST_F(StyleEngineTest, CSSSelectorEmptyWhitespaceOnlyFail) {
}
TEST_F(StyleEngineTest, EnsuredComputedStyleRecalc) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<div style="display:none">
<div>
<div id="computed">
@@ -2054,8 +2040,8 @@ TEST_F(StyleEngineTest, EnsuredComputedStyleRecalc) {
}
TEST_F(StyleEngineTest, EnsureCustomComputedStyle) {
- GetDocument().body()->SetInnerHTMLFromString("");
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML("");
+ GetDocument().body()->setInnerHTML(R"HTML(
<div id=div>
<progress id=progress>
</div>
@@ -2098,7 +2084,7 @@ TEST_F(StyleEngineTest, EnsureCustomComputedStyle) {
// InvalidateDefaultButtonStyle while the subtree disconnection
// is taking place.
TEST_F(StyleEngineTest, NoCrashWhenMarkingPartiallyRemovedSubtree) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
#foo:default {} /* Needed to enter Element::PseudoStateChanged */
</style>
@@ -2120,7 +2106,7 @@ TEST_F(StyleEngineTest, NoCrashWhenMarkingPartiallyRemovedSubtree) {
// Add some more buttons, to give InvalidateDefaultButtonStyle
// something to do when the original <button> is removed.
- inner->SetInnerHTMLFromString("<button><button>");
+ inner->setInnerHTML("<button><button>");
UpdateAllLifecyclePhases();
form->removeChild(outer);
@@ -2128,9 +2114,8 @@ TEST_F(StyleEngineTest, NoCrashWhenMarkingPartiallyRemovedSubtree) {
TEST_F(StyleEngineTest, ColorSchemeBaseBackgroundChange) {
ScopedCSSColorSchemeForTest enable_color_scheme(true);
- ColorSchemeHelper color_scheme_helper;
- color_scheme_helper.SetPreferredColorScheme(GetDocument(),
- PreferredColorScheme::kDark);
+ ColorSchemeHelper color_scheme_helper(GetDocument());
+ color_scheme_helper.SetPreferredColorScheme(PreferredColorScheme::kDark);
UpdateAllLifecyclePhases();
EXPECT_EQ(Color::kWhite, GetDocument().View()->BaseBackgroundColor());
@@ -2144,6 +2129,10 @@ TEST_F(StyleEngineTest, ColorSchemeBaseBackgroundChange) {
TEST_F(StyleEngineTest, ColorSchemeOverride) {
ScopedCSSColorSchemeForTest enable_color_scheme(true);
+ ScopedCSSColorSchemeUARenderingForTest enable_color_scheme_ua(true);
+
+ ColorSchemeHelper color_scheme_helper(GetDocument());
+ color_scheme_helper.SetPreferredColorScheme(PreferredColorScheme::kLight);
GetDocument().documentElement()->SetInlineStyleProperty(
CSSPropertyID::kColorScheme, "light dark");
@@ -2162,54 +2151,8 @@ TEST_F(StyleEngineTest, ColorSchemeOverride) {
GetDocument().documentElement()->GetComputedStyle()->UsedColorScheme());
}
-TEST_F(StyleEngineTest, InternalRootColor) {
- ScopedCSSColorSchemeForTest enable_color_scheme(true);
- ColorSchemeHelper color_scheme_helper;
- color_scheme_helper.SetPreferredColorScheme(GetDocument(),
- PreferredColorScheme::kDark);
-
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
- <style>
- #container { color-scheme: dark }
- #light { color-scheme: light }
- </style>
- <div id="container">
- <span id="dark">Text</span>
- <span id="light">Text</span>
- </div>
- )HTML");
-
- UpdateAllLifecyclePhases();
-
- auto* container = GetDocument().getElementById("container");
- auto* light = GetDocument().getElementById("light");
- auto* dark = GetDocument().getElementById("dark");
-
- // Initial value of color-scheme is 'light'.
- EXPECT_EQ(
- WebColorScheme::kLight,
- GetDocument().documentElement()->GetComputedStyle()->UsedColorScheme());
- EXPECT_EQ(WebColorScheme::kDark,
- container->GetComputedStyle()->UsedColorScheme());
- // color-scheme:dark inherited from #container.
- EXPECT_EQ(WebColorScheme::kDark, dark->GetComputedStyle()->UsedColorScheme());
- EXPECT_EQ(WebColorScheme::kLight,
- light->GetComputedStyle()->UsedColorScheme());
-
- EXPECT_EQ(Color::kBlack, GetDocument()
- .documentElement()
- ->GetComputedStyle()
- ->VisitedDependentColor(GetCSSPropertyColor()));
- EXPECT_EQ(Color::kWhite, container->GetComputedStyle()->VisitedDependentColor(
- GetCSSPropertyColor()));
- EXPECT_EQ(Color::kWhite, dark->GetComputedStyle()->VisitedDependentColor(
- GetCSSPropertyColor()));
- EXPECT_EQ(Color::kBlack, light->GetComputedStyle()->VisitedDependentColor(
- GetCSSPropertyColor()));
-}
-
TEST_F(StyleEngineTest, PseudoElementBaseComputedStyle) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<style>
@keyframes anim {
from { background-color: white }
@@ -2267,7 +2210,7 @@ TEST_F(StyleEngineTest, NeedsLayoutTreeRebuild) {
}
TEST_F(StyleEngineTest, ForceReattachLayoutTreeStyleRecalcRoot) {
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<div id="outer">
<div id="inner"></div>
</div>
@@ -2306,7 +2249,7 @@ TEST_F(StyleEngineTest, RecalcPropagatedWritingMode) {
TEST_F(StyleEngineTest, GetComputedStyleOutsideFlatTree) {
ScopedFlatTreeStyleRecalcForTest feature_scope(true);
- GetDocument().body()->SetInnerHTMLFromString(
+ GetDocument().body()->setInnerHTML(
R"HTML(<div id="host"><div id="outer"><div id="inner"><div id="innermost"></div></div></div></div>)HTML");
auto* host = GetDocument().getElementById("host");
@@ -2373,7 +2316,7 @@ TEST_F(StyleEngineTest, GetComputedStyleOutsideFlatTree) {
TEST_F(StyleEngineTest, MoveSlottedOutsideFlatTree) {
ScopedFlatTreeStyleRecalcForTest feature_scope(true);
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<div id="host1"><span></span></div>
<div id="host2"></div>
)HTML");
@@ -2384,7 +2327,7 @@ TEST_F(StyleEngineTest, MoveSlottedOutsideFlatTree) {
ShadowRoot& shadow_root =
host1->AttachShadowRootInternal(ShadowRootType::kOpen);
- shadow_root.SetInnerHTMLFromString("<slot></slot>");
+ shadow_root.setInnerHTML("<slot></slot>");
host2->AttachShadowRootInternal(ShadowRootType::kOpen);
UpdateAllLifecyclePhases();
@@ -2399,13 +2342,13 @@ TEST_F(StyleEngineTest, MoveSlottedOutsideFlatTree) {
TEST_F(StyleEngineTest, StyleRecalcRootInShadowTree) {
ScopedFlatTreeStyleRecalcForTest feature_scope(true);
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<div id="host"></div>
)HTML");
Element* host = GetDocument().getElementById("host");
ShadowRoot& shadow_root =
host->AttachShadowRootInternal(ShadowRootType::kOpen);
- shadow_root.SetInnerHTMLFromString("<div><span></span></div>");
+ shadow_root.setInnerHTML("<div><span></span></div>");
UpdateAllLifecyclePhases();
Element* span = To<Element>(shadow_root.firstChild()->firstChild());
@@ -2418,7 +2361,7 @@ TEST_F(StyleEngineTest, StyleRecalcRootInShadowTree) {
TEST_F(StyleEngineTest, StyleRecalcRootOutsideFlatTree) {
ScopedFlatTreeStyleRecalcForTest feature_scope(true);
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<div id="host"><div id="ensured"><span></span></div></div>
<div id="dirty"></div>
)HTML");
@@ -2451,7 +2394,7 @@ TEST_F(StyleEngineTest, StyleRecalcRootOutsideFlatTree) {
TEST_F(StyleEngineTest, RemoveStyleRecalcRootFromFlatTree) {
ScopedFlatTreeStyleRecalcForTest scope(true);
- GetDocument().body()->SetInnerHTMLFromString(R"HTML(
+ GetDocument().body()->setInnerHTML(R"HTML(
<div id=host><span></span></div>
)HTML");
@@ -2460,7 +2403,7 @@ TEST_F(StyleEngineTest, RemoveStyleRecalcRootFromFlatTree) {
ShadowRoot& shadow_root =
host->AttachShadowRootInternal(ShadowRootType::kOpen);
- shadow_root.SetInnerHTMLFromString("<div><slot></slot></div>");
+ shadow_root.setInnerHTML("<div><slot></slot></div>");
UpdateAllLifecyclePhases();
@@ -2484,4 +2427,272 @@ TEST_F(StyleEngineTest, RemoveStyleRecalcRootFromFlatTree) {
EXPECT_FALSE(GetStyleRecalcRoot());
}
+TEST_F(StyleEngineTest, SlottedWithEnsuredStyleOutsideFlatTree) {
+ ScopedFlatTreeStyleRecalcForTest scope(true);
+
+ GetDocument().body()->setInnerHTML(R"HTML(
+ <div id="host"><span></span></div>
+ )HTML");
+
+ auto* host = GetDocument().getElementById("host");
+ auto* span = To<Element>(host->firstChild());
+
+ ShadowRoot& shadow_root =
+ host->AttachShadowRootInternal(ShadowRootType::kOpen);
+ shadow_root.setInnerHTML(R"HTML(
+ <div><slot name="default"></slot></div>
+ )HTML");
+
+ UpdateAllLifecyclePhases();
+
+ // Ensure style outside the flat tree.
+ const ComputedStyle* style = span->EnsureComputedStyle();
+ ASSERT_TRUE(style);
+ EXPECT_TRUE(style->IsEnsuredOutsideFlatTree());
+
+ span->setAttribute("slot", "default");
+ GetDocument().GetSlotAssignmentEngine().RecalcSlotAssignments();
+ EXPECT_EQ(span, GetStyleRecalcRoot());
+ EXPECT_FALSE(span->GetComputedStyle());
+}
+
+TEST_F(StyleEngineTest, RecalcEnsuredStyleOutsideFlatTreeV0) {
+ ScopedFlatTreeStyleRecalcForTest scope(true);
+
+ GetDocument().body()->setInnerHTML(R"HTML(
+ <div id="host"><span></span></div>
+ )HTML");
+
+ auto* host = GetDocument().getElementById("host");
+ auto* span = To<Element>(host->firstChild());
+
+ host->CreateV0ShadowRootForTesting();
+ UpdateAllLifecyclePhases();
+
+ EXPECT_FALSE(span->FlatTreeParentForChildDirty());
+
+ // Ensure style outside the flat tree.
+ const ComputedStyle* style = span->EnsureComputedStyle();
+ ASSERT_TRUE(style);
+ EXPECT_TRUE(style->IsEnsuredOutsideFlatTree());
+ EXPECT_EQ(EDisplay::kInline, style->Display());
+
+ span->SetInlineStyleProperty(CSSPropertyID::kDisplay, "block");
+ EXPECT_FALSE(GetStyleRecalcRoot());
+ EXPECT_FALSE(GetDocument().body()->ChildNeedsStyleRecalc());
+}
+
+TEST_F(StyleEngineTest, ForceReattachRecalcRootAttachShadow) {
+ ScopedFlatTreeStyleRecalcForTest scope(true);
+
+ GetDocument().body()->setInnerHTML(R"HTML(
+ <div id="reattach"></div><div id="host"><span></span></div>
+ )HTML");
+
+ auto* reattach = GetDocument().getElementById("reattach");
+ auto* host = GetDocument().getElementById("host");
+
+ UpdateAllLifecyclePhases();
+
+ reattach->SetForceReattachLayoutTree();
+ EXPECT_FALSE(reattach->NeedsStyleRecalc());
+ EXPECT_EQ(reattach, GetStyleRecalcRoot());
+
+ // Attaching the shadow root will call RemovedFromFlatTree() on the span child
+ // of the host. The style recalc root should still be #reattach.
+ host->AttachShadowRootInternal(ShadowRootType::kOpen);
+ EXPECT_EQ(reattach, GetStyleRecalcRoot());
+}
+
+TEST_F(StyleEngineTest, InitialColorChange) {
+ // Set color scheme to light.
+ ColorSchemeHelper color_scheme_helper(GetDocument());
+ color_scheme_helper.SetPreferredColorScheme(PreferredColorScheme::kLight);
+
+ GetDocument().body()->setInnerHTML(R"HTML(
+ <style>
+ :root { color-scheme: light dark }
+ #initial { color: initial }
+ </style>
+ <div id="initial"></div>
+ )HTML");
+ UpdateAllLifecyclePhases();
+
+ Element* initial = GetDocument().getElementById("initial");
+ ASSERT_TRUE(initial);
+ ASSERT_TRUE(GetDocument().documentElement());
+ const ComputedStyle* document_element_style =
+ GetDocument().documentElement()->GetComputedStyle();
+ ASSERT_TRUE(document_element_style);
+ EXPECT_EQ(Color::kBlack, document_element_style->VisitedDependentColor(
+ GetCSSPropertyColor()));
+
+ const ComputedStyle* initial_style = initial->GetComputedStyle();
+ ASSERT_TRUE(initial_style);
+ EXPECT_EQ(Color::kBlack,
+ initial_style->VisitedDependentColor(GetCSSPropertyColor()));
+
+ // Change color scheme to dark.
+ color_scheme_helper.SetPreferredColorScheme(PreferredColorScheme::kDark);
+ UpdateAllLifecyclePhases();
+
+ document_element_style = GetDocument().documentElement()->GetComputedStyle();
+ ASSERT_TRUE(document_element_style);
+ EXPECT_EQ(Color::kWhite, document_element_style->VisitedDependentColor(
+ GetCSSPropertyColor()));
+
+ initial_style = initial->GetComputedStyle();
+ ASSERT_TRUE(initial_style);
+ EXPECT_EQ(Color::kWhite,
+ initial_style->VisitedDependentColor(GetCSSPropertyColor()));
+}
+
+TEST_F(StyleEngineTest,
+ MediaQueryAffectingValueChanged_InvalidateForChangedSizeQueries) {
+ GetDocument().body()->setInnerHTML(R"HTML(
+ <style>
+ @media (min-width: 1000px) {
+ div { color: green }
+ }
+ </style>
+ <style>
+ @media (min-width: 1200px) {
+ * { color: red }
+ }
+ </style>
+ <style>
+ @media print {
+ * { color: blue }
+ }
+ </style>
+ <div id="green"></div>
+ <span></span>
+ )HTML");
+ UpdateAllLifecyclePhases();
+
+ Element* div = GetDocument().getElementById("green");
+ EXPECT_EQ(Color::kBlack, div->GetComputedStyle()->VisitedDependentColor(
+ GetCSSPropertyColor()));
+
+ unsigned initial_count = GetStyleEngine().StyleForElementCount();
+
+ GetDocument().View()->SetLayoutSizeFixedToFrameSize(false);
+ GetDocument().View()->SetLayoutSize(IntSize(1100, 800));
+ UpdateAllLifecyclePhases();
+
+ // Only the single div element should have its style recomputed.
+ EXPECT_EQ(1u, GetStyleEngine().StyleForElementCount() - initial_count);
+ EXPECT_EQ(MakeRGB(0, 128, 0), div->GetComputedStyle()->VisitedDependentColor(
+ GetCSSPropertyColor()));
+}
+
+TEST_F(StyleEngineTest,
+ MediaQueryAffectingValueChanged_InvalidateForChangedTypeQuery) {
+ GetDocument().body()->setInnerHTML(R"HTML(
+ <style>
+ @media speech {
+ div { color: green }
+ }
+ </style>
+ <style>
+ @media (max-width: 100px) {
+ * { color: red }
+ }
+ </style>
+ <style>
+ @media print {
+ * { color: blue }
+ }
+ </style>
+ <div id="green"></div>
+ <span></span>
+ )HTML");
+ UpdateAllLifecyclePhases();
+
+ Element* div = GetDocument().getElementById("green");
+ EXPECT_EQ(Color::kBlack, div->GetComputedStyle()->VisitedDependentColor(
+ GetCSSPropertyColor()));
+
+ unsigned initial_count = GetStyleEngine().StyleForElementCount();
+
+ GetDocument().GetSettings()->SetMediaTypeOverride("speech");
+ UpdateAllLifecyclePhases();
+
+ // Only the single div element should have its style recomputed.
+ EXPECT_EQ(1u, GetStyleEngine().StyleForElementCount() - initial_count);
+ EXPECT_EQ(MakeRGB(0, 128, 0), div->GetComputedStyle()->VisitedDependentColor(
+ GetCSSPropertyColor()));
+}
+
+TEST_F(StyleEngineTest,
+ MediaQueryAffectingValueChanged_InvalidateForChangedReducedMotionQuery) {
+ GetDocument().body()->setInnerHTML(R"HTML(
+ <style>
+ @media (prefers-reduced-motion: reduce) {
+ div { color: green }
+ }
+ </style>
+ <style>
+ @media (max-width: 100px) {
+ * { color: red }
+ }
+ </style>
+ <style>
+ @media print {
+ * { color: blue }
+ }
+ </style>
+ <div id="green"></div>
+ <span></span>
+ )HTML");
+ UpdateAllLifecyclePhases();
+
+ Element* div = GetDocument().getElementById("green");
+ EXPECT_EQ(Color::kBlack, div->GetComputedStyle()->VisitedDependentColor(
+ GetCSSPropertyColor()));
+
+ unsigned initial_count = GetStyleEngine().StyleForElementCount();
+
+ GetDocument().GetSettings()->SetPrefersReducedMotion(true);
+ UpdateAllLifecyclePhases();
+
+ // Only the single div element should have its style recomputed.
+ EXPECT_EQ(1u, GetStyleEngine().StyleForElementCount() - initial_count);
+ EXPECT_EQ(MakeRGB(0, 128, 0), div->GetComputedStyle()->VisitedDependentColor(
+ GetCSSPropertyColor()));
+}
+
+class ParameterizedStyleEngineTest
+ : public testing::WithParamInterface<bool>,
+ private ScopedCSSReducedFontLoadingInvalidationsForTest,
+ public StyleEngineTest {
+ public:
+ ParameterizedStyleEngineTest()
+ : ScopedCSSReducedFontLoadingInvalidationsForTest(GetParam()) {}
+};
+
+INSTANTIATE_TEST_SUITE_P(All, ParameterizedStyleEngineTest, testing::Bool());
+
+// https://crbug.com/1050564
+TEST_P(ParameterizedStyleEngineTest,
+ MediaAttributeChangeUpdatesFontCacheVersion) {
+ GetDocument().body()->setInnerHTML(R"HTML(
+ <style>
+ @font-face { font-family: custom-font; src: url(fake-font.woff); }
+ </style>
+ <style id=target>
+ .display-none { display: none; }
+ </style>
+ <div style="font-family: custom-font">foo</div>
+ <div class="display-none">bar</div>
+ )HTML");
+ UpdateAllLifecyclePhases();
+
+ Element* target = GetDocument().getElementById("target");
+ target->setAttribute(html_names::kMediaAttr, "print");
+
+ // Shouldn't crash.
+ UpdateAllLifecyclePhases();
+}
+
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/style_environment_variables_test.cc b/chromium/third_party/blink/renderer/core/css/style_environment_variables_test.cc
index 21d16088658..bc8fa6776f3 100644
--- a/chromium/third_party/blink/renderer/core/css/style_environment_variables_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/style_environment_variables_test.cc
@@ -48,9 +48,9 @@ class StyleEnvironmentVariablesTest : public PageTestBase {
void InitializeWithHTML(LocalFrame& frame, const String& html_content) {
// Sets the inner html and runs the document lifecycle.
- frame.GetDocument()->body()->SetInnerHTMLFromString(html_content);
+ frame.GetDocument()->body()->setInnerHTML(html_content);
frame.GetDocument()->View()->UpdateAllLifecyclePhases(
- DocumentLifecycle::LifecycleUpdateReason::kTest);
+ DocumentUpdateReason::kTest);
}
void InitializeTestPageWithVariableNamed(LocalFrame& frame,
@@ -231,7 +231,7 @@ TEST_F(StyleEnvironmentVariablesTest, MultiDocumentInvalidation_FromRoot) {
// Create an empty page that does not use the variable.
auto empty_page = std::make_unique<DummyPageHolder>(IntSize(800, 600));
empty_page->GetDocument().View()->UpdateAllLifecyclePhases(
- DocumentLifecycle::LifecycleUpdateReason::kTest);
+ DocumentUpdateReason::kTest);
StyleEnvironmentVariables::GetRootInstance().SetVariable(kVariableName,
kVariableTestColor);
diff --git a/chromium/third_party/blink/renderer/core/css/style_media.cc b/chromium/third_party/blink/renderer/core/css/style_media.cc
index 55f908545ea..6725fe11f60 100644
--- a/chromium/third_party/blink/renderer/core/css/style_media.cc
+++ b/chromium/third_party/blink/renderer/core/css/style_media.cc
@@ -28,12 +28,13 @@
#include "third_party/blink/renderer/core/css/media_list.h"
#include "third_party/blink/renderer/core/css/media_query_evaluator.h"
#include "third_party/blink/renderer/core/dom/document.h"
+#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
namespace blink {
-StyleMedia::StyleMedia(LocalFrame* frame) : ContextClient(frame) {}
+StyleMedia::StyleMedia(LocalFrame* frame) : ExecutionContextClient(frame) {}
AtomicString StyleMedia::type() const {
LocalFrameView* view = GetFrame() ? GetFrame()->View() : nullptr;
@@ -54,16 +55,16 @@ bool StyleMedia::matchMedium(const String& query) const {
return false;
scoped_refptr<MediaQuerySet> media = MediaQuerySet::Create();
- if (!media->Set(query))
+ if (!media->Set(query, GetFrame()->DomWindow()))
return false;
MediaQueryEvaluator screen_eval(GetFrame());
return screen_eval.Eval(*media);
}
-void StyleMedia::Trace(blink::Visitor* visitor) {
+void StyleMedia::Trace(Visitor* visitor) {
ScriptWrappable::Trace(visitor);
- ContextClient::Trace(visitor);
+ ExecutionContextClient::Trace(visitor);
}
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/style_media.h b/chromium/third_party/blink/renderer/core/css/style_media.h
index e18e562f523..7a16067f560 100644
--- a/chromium/third_party/blink/renderer/core/css/style_media.h
+++ b/chromium/third_party/blink/renderer/core/css/style_media.h
@@ -27,7 +27,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_STYLE_MEDIA_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_STYLE_MEDIA_H_
-#include "third_party/blink/renderer/core/execution_context/context_lifecycle_observer.h"
+#include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
@@ -36,7 +36,7 @@ namespace blink {
class LocalFrame;
-class StyleMedia final : public ScriptWrappable, public ContextClient {
+class StyleMedia final : public ScriptWrappable, public ExecutionContextClient {
DEFINE_WRAPPERTYPEINFO();
USING_GARBAGE_COLLECTED_MIXIN(StyleMedia);
@@ -46,7 +46,7 @@ class StyleMedia final : public ScriptWrappable, public ContextClient {
AtomicString type() const;
bool matchMedium(const String&) const;
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
};
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/style_media.idl b/chromium/third_party/blink/renderer/core/css/style_media.idl
index f87108f5ab1..36b427af621 100644
--- a/chromium/third_party/blink/renderer/core/css/style_media.idl
+++ b/chromium/third_party/blink/renderer/core/css/style_media.idl
@@ -35,5 +35,5 @@
NoInterfaceObject
] interface StyleMedia {
[MeasureAs=StyleMediaType] readonly attribute DOMString type;
- [MeasureAs=StyleMediaMatchMedium] boolean matchMedium([DefaultValue=Undefined] optional DOMString mediaquery);
+ [MeasureAs=StyleMediaMatchMedium] boolean matchMedium(optional DOMString mediaquery = "undefined");
};
diff --git a/chromium/third_party/blink/renderer/core/css/style_property_serializer.cc b/chromium/third_party/blink/renderer/core/css/style_property_serializer.cc
index 1de5c5fad3b..a54cefc8d04 100644
--- a/chromium/third_party/blink/renderer/core/css/style_property_serializer.cc
+++ b/chromium/third_party/blink/renderer/core/css/style_property_serializer.cc
@@ -339,7 +339,6 @@ static bool AllowInitialInShorthand(CSSPropertyID property_id) {
case CSSPropertyID::kListStyle:
case CSSPropertyID::kOffset:
case CSSPropertyID::kTextDecoration:
- case CSSPropertyID::kWebkitMarginCollapse:
case CSSPropertyID::kWebkitMask:
case CSSPropertyID::kWebkitTextEmphasis:
case CSSPropertyID::kWebkitTextStroke:
@@ -522,8 +521,6 @@ String StylePropertySerializer::SerializeShorthand(
return Get2Values(marginInlineShorthand());
case CSSPropertyID::kOffset:
return OffsetValue();
- case CSSPropertyID::kWebkitMarginCollapse:
- return GetShorthandValue(webkitMarginCollapseShorthand());
case CSSPropertyID::kOverflow:
return Get2Values(overflowShorthand());
case CSSPropertyID::kOverscrollBehavior:
@@ -582,8 +579,6 @@ String StylePropertySerializer::SerializeShorthand(
return PageBreakPropertyValue(pageBreakBeforeShorthand());
case CSSPropertyID::kPageBreakInside:
return PageBreakPropertyValue(pageBreakInsideShorthand());
- case CSSPropertyID::kIntrinsicSize:
- return Get2Values(intrinsicSizeShorthand());
default:
return String();
}
diff --git a/chromium/third_party/blink/renderer/core/css/style_property_serializer.h b/chromium/third_party/blink/renderer/core/css/style_property_serializer.h
index 4205dabebbd..4d214d695a5 100644
--- a/chromium/third_party/blink/renderer/core/css/style_property_serializer.h
+++ b/chromium/third_party/blink/renderer/core/css/style_property_serializer.h
@@ -86,7 +86,7 @@ class StylePropertySerializer {
public:
explicit PropertyValueForSerializer(
CSSPropertyValueSet::PropertyReference property)
- : value_(property.Value()),
+ : value_(&property.Value()),
property_(property.Property()),
is_important_(property.IsImportant()),
is_inherited_(property.IsInherited()) {}
@@ -107,7 +107,7 @@ class StylePropertySerializer {
bool IsValid() const { return value_; }
private:
- Member<const CSSValue> value_;
+ const CSSValue* value_;
const CSSProperty& property_;
bool is_important_;
bool is_inherited_;
@@ -129,7 +129,7 @@ class StylePropertySerializer {
const CSSValue* GetPropertyCSSValue(const CSSProperty&) const;
bool IsDescriptorContext() const;
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
bool HasExpandedAllProperty() const {
diff --git a/chromium/third_party/blink/renderer/core/css/style_recalc_root.cc b/chromium/third_party/blink/renderer/core/css/style_recalc_root.cc
index dcc8ed70037..fe2e85a0bba 100644
--- a/chromium/third_party/blink/renderer/core/css/style_recalc_root.cc
+++ b/chromium/third_party/blink/renderer/core/css/style_recalc_root.cc
@@ -6,6 +6,7 @@
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
+#include "third_party/blink/renderer/core/dom/shadow_root_v0.h"
#include "third_party/blink/renderer/core/dom/slot_assignment.h"
#include "third_party/blink/renderer/core/html/html_slot_element.h"
@@ -62,8 +63,15 @@ base::Optional<Member<Element>> FirstFlatTreeAncestorForChildDirty(
if (!root)
return To<Element>(&parent);
if (root->IsV0()) {
- // Fall back to use the parent as the new style recalc root for Shadow DOM
- // V0. It is too complicated to try to find the closest flat tree parent.
+ // The child has already been removed, so we cannot look up its insertion
+ // point directly. Find the insertion point which was part of the ancestor
+ // chain before the removal by checking the child-dirty bits. Since the
+ // recalc root was removed, there is at most one such child-dirty insertion
+ // point.
+ for (const auto& insertion_point : root->V0().DescendantInsertionPoints()) {
+ if (insertion_point->ChildNeedsStyleRecalc())
+ return insertion_point;
+ }
return base::nullopt;
}
if (!root->HasSlotAssignment())
@@ -72,7 +80,7 @@ base::Optional<Member<Element>> FirstFlatTreeAncestorForChildDirty(
// assignment directly. Find the slot which was part of the ancestor chain
// before the removal by checking the child-dirty bits. Since the recalc root
// was removed, there is at most one such child-dirty slot.
- for (const auto slot : root->GetSlotAssignment().Slots()) {
+ for (const auto& slot : root->GetSlotAssignment().Slots()) {
if (slot->ChildNeedsStyleRecalc())
return slot;
}
@@ -123,6 +131,7 @@ void StyleRecalcRoot::RemovedFromFlatTree(const Node& node) {
// make sure we don't have a recalc root outside the flat tree, which is not
// allowed with FlatTreeStyleRecalc enabled.
if (GetRootNode()->NeedsStyleRecalc() ||
+ GetRootNode()->GetForceReattachLayoutTree() ||
GetRootNode()->ChildNeedsStyleRecalc()) {
return;
}
diff --git a/chromium/third_party/blink/renderer/core/css/style_rule.cc b/chromium/third_party/blink/renderer/core/css/style_rule.cc
index 4a99e20558e..1220ed8fd1c 100644
--- a/chromium/third_party/blink/renderer/core/css/style_rule.cc
+++ b/chromium/third_party/blink/renderer/core/css/style_rule.cc
@@ -55,7 +55,7 @@ CSSRule* StyleRuleBase::CreateCSSOMWrapper(CSSRule* parent_rule) const {
return CreateCSSOMWrapper(nullptr, parent_rule);
}
-void StyleRuleBase::Trace(blink::Visitor* visitor) {
+void StyleRuleBase::Trace(Visitor* visitor) {
switch (GetType()) {
case kCharset:
To<StyleRuleCharset>(this)->TraceAfterDispatch(visitor);
@@ -287,7 +287,7 @@ bool StyleRule::HasParsedProperties() const {
return !lazy_property_parser_;
}
-void StyleRule::TraceAfterDispatch(blink::Visitor* visitor) {
+void StyleRule::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(properties_);
visitor->Trace(lazy_property_parser_);
StyleRuleBase::TraceAfterDispatch(visitor);
@@ -312,7 +312,7 @@ MutableCSSPropertyValueSet& StyleRulePage::MutableProperties() {
return *To<MutableCSSPropertyValueSet>(properties_.Get());
}
-void StyleRulePage::TraceAfterDispatch(blink::Visitor* visitor) {
+void StyleRulePage::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(properties_);
StyleRuleBase::TraceAfterDispatch(visitor);
}
@@ -333,7 +333,7 @@ MutableCSSPropertyValueSet& StyleRuleProperty::MutableProperties() {
return *To<MutableCSSPropertyValueSet>(properties_.Get());
}
-void StyleRuleProperty::TraceAfterDispatch(blink::Visitor* visitor) {
+void StyleRuleProperty::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(properties_);
StyleRuleBase::TraceAfterDispatch(visitor);
}
@@ -345,15 +345,13 @@ StyleRuleFontFace::StyleRuleFontFace(const StyleRuleFontFace& font_face_rule)
: StyleRuleBase(font_face_rule),
properties_(font_face_rule.properties_->MutableCopy()) {}
-StyleRuleFontFace::~StyleRuleFontFace() = default;
-
MutableCSSPropertyValueSet& StyleRuleFontFace::MutableProperties() {
if (!properties_->IsMutable())
properties_ = properties_->MutableCopy();
return *To<MutableCSSPropertyValueSet>(properties_.Get());
}
-void StyleRuleFontFace::TraceAfterDispatch(blink::Visitor* visitor) {
+void StyleRuleFontFace::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(properties_);
StyleRuleBase::TraceAfterDispatch(visitor);
}
@@ -378,7 +376,7 @@ void StyleRuleGroup::WrapperRemoveRule(unsigned index) {
child_rules_.EraseAt(index);
}
-void StyleRuleGroup::TraceAfterDispatch(blink::Visitor* visitor) {
+void StyleRuleGroup::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(child_rules_);
StyleRuleBase::TraceAfterDispatch(visitor);
}
@@ -414,7 +412,7 @@ StyleRuleSupports::StyleRuleSupports(
: StyleRuleCondition(kSupports, condition_text, adopt_rules),
condition_is_supported_(condition_is_supported) {}
-void StyleRuleMedia::TraceAfterDispatch(blink::Visitor* visitor) {
+void StyleRuleMedia::TraceAfterDispatch(blink::Visitor* visitor) const {
StyleRuleCondition::TraceAfterDispatch(visitor);
}
@@ -429,15 +427,13 @@ StyleRuleViewport::StyleRuleViewport(const StyleRuleViewport& viewport_rule)
: StyleRuleBase(viewport_rule),
properties_(viewport_rule.properties_->MutableCopy()) {}
-StyleRuleViewport::~StyleRuleViewport() = default;
-
MutableCSSPropertyValueSet& StyleRuleViewport::MutableProperties() {
if (!properties_->IsMutable())
properties_ = properties_->MutableCopy();
return *To<MutableCSSPropertyValueSet>(properties_.Get());
}
-void StyleRuleViewport::TraceAfterDispatch(blink::Visitor* visitor) {
+void StyleRuleViewport::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(properties_);
StyleRuleBase::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/style_rule.h b/chromium/third_party/blink/renderer/core/css/style_rule.h
index feaac3a2c00..a4a11462a2e 100644
--- a/chromium/third_party/blink/renderer/core/css/style_rule.h
+++ b/chromium/third_party/blink/renderer/core/css/style_rule.h
@@ -73,8 +73,8 @@ class CORE_EXPORT StyleRuleBase : public GarbageCollected<StyleRuleBase> {
CSSRule* CreateCSSOMWrapper(CSSStyleSheet* parent_sheet = nullptr) const;
CSSRule* CreateCSSOMWrapper(CSSRule* parent_rule) const;
- void Trace(blink::Visitor*);
- void TraceAfterDispatch(blink::Visitor* visitor) {}
+ void Trace(Visitor*);
+ void TraceAfterDispatch(blink::Visitor* visitor) const {}
void FinalizeGarbageCollectedObject();
// ~StyleRuleBase should be public, because non-public ~StyleRuleBase
@@ -91,7 +91,7 @@ class CORE_EXPORT StyleRuleBase : public GarbageCollected<StyleRuleBase> {
CSSRule* CreateCSSOMWrapper(CSSStyleSheet* parent_sheet,
CSSRule* parent_rule) const;
- unsigned type_ : 5;
+ const uint8_t type_;
};
// A single rule from a stylesheet. Contains a selector list (one or more
@@ -121,7 +121,7 @@ class CORE_EXPORT StyleRule : public StyleRuleBase {
bool PropertiesHaveFailedOrCanceledSubresources() const;
bool ShouldConsiderForMatchingRules(bool include_empty_rules) const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
friend class CSSLazyParsingTest;
@@ -147,7 +147,6 @@ class CORE_EXPORT StyleRuleFontFace : public StyleRuleBase {
public:
StyleRuleFontFace(CSSPropertyValueSet*);
StyleRuleFontFace(const StyleRuleFontFace&);
- ~StyleRuleFontFace();
const CSSPropertyValueSet& Properties() const { return *properties_; }
MutableCSSPropertyValueSet& MutableProperties();
@@ -156,7 +155,7 @@ class CORE_EXPORT StyleRuleFontFace : public StyleRuleBase {
return MakeGarbageCollected<StyleRuleFontFace>(*this);
}
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
Member<CSSPropertyValueSet> properties_; // Cannot be null.
@@ -180,7 +179,7 @@ class StyleRulePage : public StyleRuleBase {
return MakeGarbageCollected<StyleRulePage>(*this);
}
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
Member<CSSPropertyValueSet> properties_; // Cannot be null.
@@ -189,11 +188,6 @@ class StyleRulePage : public StyleRuleBase {
class StyleRuleProperty : public StyleRuleBase {
public:
- static StyleRuleProperty* Create(const String& name,
- CSSPropertyValueSet* properties) {
- return MakeGarbageCollected<StyleRuleProperty>(name, properties);
- }
-
StyleRuleProperty(const String& name, CSSPropertyValueSet*);
StyleRuleProperty(const StyleRuleProperty&);
~StyleRuleProperty();
@@ -206,7 +200,7 @@ class StyleRuleProperty : public StyleRuleBase {
return MakeGarbageCollected<StyleRuleProperty>(*this);
}
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
String name_;
@@ -222,7 +216,7 @@ class CORE_EXPORT StyleRuleGroup : public StyleRuleBase {
void WrapperInsertRule(unsigned, StyleRuleBase*);
void WrapperRemoveRule(unsigned);
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
protected:
StyleRuleGroup(RuleType, HeapVector<Member<StyleRuleBase>>& adopt_rule);
@@ -236,7 +230,7 @@ class CORE_EXPORT StyleRuleCondition : public StyleRuleGroup {
public:
String ConditionText() const { return condition_text_; }
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
StyleRuleGroup::TraceAfterDispatch(visitor);
}
@@ -261,7 +255,7 @@ class CORE_EXPORT StyleRuleMedia : public StyleRuleCondition {
return MakeGarbageCollected<StyleRuleMedia>(*this);
}
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
scoped_refptr<MediaQuerySet> media_queries_;
@@ -279,7 +273,7 @@ class StyleRuleSupports : public StyleRuleCondition {
return MakeGarbageCollected<StyleRuleSupports>(*this);
}
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
StyleRuleCondition::TraceAfterDispatch(visitor);
}
@@ -292,7 +286,6 @@ class StyleRuleViewport : public StyleRuleBase {
public:
explicit StyleRuleViewport(CSSPropertyValueSet*);
explicit StyleRuleViewport(const StyleRuleViewport&);
- ~StyleRuleViewport();
const CSSPropertyValueSet& Properties() const { return *properties_; }
MutableCSSPropertyValueSet& MutableProperties();
@@ -301,7 +294,7 @@ class StyleRuleViewport : public StyleRuleBase {
return MakeGarbageCollected<StyleRuleViewport>(*this);
}
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
Member<CSSPropertyValueSet> properties_; // Cannot be null
@@ -311,7 +304,7 @@ class StyleRuleViewport : public StyleRuleBase {
class StyleRuleCharset : public StyleRuleBase {
public:
StyleRuleCharset() : StyleRuleBase(kCharset) {}
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
StyleRuleBase::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/style_rule_css_style_declaration.cc b/chromium/third_party/blink/renderer/core/css/style_rule_css_style_declaration.cc
index 4b45ec7238c..95e62d4c6ad 100644
--- a/chromium/third_party/blink/renderer/core/css/style_rule_css_style_declaration.cc
+++ b/chromium/third_party/blink/renderer/core/css/style_rule_css_style_declaration.cc
@@ -31,7 +31,14 @@ namespace blink {
StyleRuleCSSStyleDeclaration::StyleRuleCSSStyleDeclaration(
MutableCSSPropertyValueSet& property_set_arg,
CSSRule* parent_rule)
- : PropertySetCSSStyleDeclaration(property_set_arg),
+ : PropertySetCSSStyleDeclaration(
+ const_cast<Document*>(CSSStyleSheet::SingleOwnerDocument(
+ parent_rule->parentStyleSheet()))
+ ? const_cast<Document*>(CSSStyleSheet::SingleOwnerDocument(
+ parent_rule->parentStyleSheet()))
+ ->GetExecutionContext()
+ : nullptr,
+ property_set_arg),
parent_rule_(parent_rule) {}
StyleRuleCSSStyleDeclaration::~StyleRuleCSSStyleDeclaration() = default;
@@ -57,7 +64,7 @@ void StyleRuleCSSStyleDeclaration::Reattach(
property_set_ = &property_set;
}
-void StyleRuleCSSStyleDeclaration::Trace(blink::Visitor* visitor) {
+void StyleRuleCSSStyleDeclaration::Trace(Visitor* visitor) {
visitor->Trace(parent_rule_);
PropertySetCSSStyleDeclaration::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/style_rule_css_style_declaration.h b/chromium/third_party/blink/renderer/core/css/style_rule_css_style_declaration.h
index e3bc6fb5ddf..cbf19455579 100644
--- a/chromium/third_party/blink/renderer/core/css/style_rule_css_style_declaration.h
+++ b/chromium/third_party/blink/renderer/core/css/style_rule_css_style_declaration.h
@@ -40,7 +40,7 @@ class StyleRuleCSSStyleDeclaration : public PropertySetCSSStyleDeclaration {
void Reattach(MutableCSSPropertyValueSet&);
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
protected:
CSSStyleSheet* ParentStyleSheet() const override;
diff --git a/chromium/third_party/blink/renderer/core/css/style_rule_import.cc b/chromium/third_party/blink/renderer/core/css/style_rule_import.cc
index 8493e493442..55a0036c700 100644
--- a/chromium/third_party/blink/renderer/core/css/style_rule_import.cc
+++ b/chromium/third_party/blink/renderer/core/css/style_rule_import.cc
@@ -22,7 +22,6 @@
#include "third_party/blink/renderer/core/css/style_rule_import.h"
-#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/core/css/style_sheet_contents.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/loader/resource/css_style_sheet_resource.h"
@@ -45,7 +44,7 @@ StyleRuleImport::StyleRuleImport(const String& href,
loading_(false),
origin_clean_(origin_clean) {
if (!media_queries_)
- media_queries_ = MediaQuerySet::Create(String());
+ media_queries_ = MediaQuerySet::Create(String(), nullptr);
}
StyleRuleImport::~StyleRuleImport() = default;
@@ -54,7 +53,7 @@ void StyleRuleImport::Dispose() {
style_sheet_client_->Dispose();
}
-void StyleRuleImport::TraceAfterDispatch(blink::Visitor* visitor) {
+void StyleRuleImport::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(style_sheet_client_);
visitor->Trace(parent_style_sheet_);
visitor->Trace(style_sheet_);
@@ -109,9 +108,7 @@ void StyleRuleImport::RequestStyleSheet() {
return;
Document* document_for_origin = document;
- if (base::FeatureList::IsEnabled(
- features::kHtmlImportsRequestInitiatorLock) &&
- document->ImportsController()) {
+ if (document->ImportsController()) {
// For @imports from HTML imported Documents, we use the
// context document for getting origin and ResourceFetcher to use the main
// Document's origin, while using the element document for CompleteURL() to
diff --git a/chromium/third_party/blink/renderer/core/css/style_rule_import.h b/chromium/third_party/blink/renderer/core/css/style_rule_import.h
index 3d9d022e23c..db062f0825a 100644
--- a/chromium/third_party/blink/renderer/core/css/style_rule_import.h
+++ b/chromium/third_party/blink/renderer/core/css/style_rule_import.h
@@ -57,7 +57,7 @@ class StyleRuleImport : public StyleRuleBase {
void RequestStyleSheet();
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
// FIXME: inherit from ResourceClient directly to eliminate back
@@ -80,7 +80,7 @@ class StyleRuleImport : public StyleRuleBase {
String DebugName() const override { return "ImportedStyleSheetClient"; }
- void Trace(blink::Visitor* visitor) override {
+ void Trace(Visitor* visitor) override {
visitor->Trace(owner_rule_);
ResourceClient::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/style_rule_keyframe.cc b/chromium/third_party/blink/renderer/core/css/style_rule_keyframe.cc
index f9aa723aacc..d6881937202 100644
--- a/chromium/third_party/blink/renderer/core/css/style_rule_keyframe.cc
+++ b/chromium/third_party/blink/renderer/core/css/style_rule_keyframe.cc
@@ -63,7 +63,7 @@ String StyleRuleKeyframe::CssText() const {
return result.ToString();
}
-void StyleRuleKeyframe::TraceAfterDispatch(blink::Visitor* visitor) {
+void StyleRuleKeyframe::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(properties_);
StyleRuleBase::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/style_rule_keyframe.h b/chromium/third_party/blink/renderer/core/css/style_rule_keyframe.h
index cb8cac2e614..37493bc9f84 100644
--- a/chromium/third_party/blink/renderer/core/css/style_rule_keyframe.h
+++ b/chromium/third_party/blink/renderer/core/css/style_rule_keyframe.h
@@ -30,7 +30,7 @@ class StyleRuleKeyframe final : public StyleRuleBase {
String CssText() const;
- void TraceAfterDispatch(blink::Visitor*);
+ void TraceAfterDispatch(blink::Visitor*) const;
private:
Member<CSSPropertyValueSet> properties_;
diff --git a/chromium/third_party/blink/renderer/core/css/style_rule_namespace.h b/chromium/third_party/blink/renderer/core/css/style_rule_namespace.h
index 6ae26b469be..b1875ca9fa9 100644
--- a/chromium/third_party/blink/renderer/core/css/style_rule_namespace.h
+++ b/chromium/third_party/blink/renderer/core/css/style_rule_namespace.h
@@ -14,10 +14,6 @@ namespace blink {
// the parser to pass to a stylesheet
class StyleRuleNamespace final : public StyleRuleBase {
public:
- static StyleRuleNamespace* Create(AtomicString prefix, AtomicString uri) {
- return MakeGarbageCollected<StyleRuleNamespace>(prefix, uri);
- }
-
StyleRuleNamespace(AtomicString prefix, AtomicString uri)
: StyleRuleBase(kNamespace), prefix_(prefix), uri_(uri) {}
@@ -28,7 +24,7 @@ class StyleRuleNamespace final : public StyleRuleBase {
AtomicString Prefix() const { return prefix_; }
AtomicString Uri() const { return uri_; }
- void TraceAfterDispatch(blink::Visitor* visitor) {
+ void TraceAfterDispatch(blink::Visitor* visitor) const {
StyleRuleBase::TraceAfterDispatch(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/css/style_sheet_candidate.cc b/chromium/third_party/blink/renderer/core/css/style_sheet_candidate.cc
index 644416a3651..6336519676b 100644
--- a/chromium/third_party/blink/renderer/core/css/style_sheet_candidate.cc
+++ b/chromium/third_party/blink/renderer/core/css/style_sheet_candidate.cc
@@ -29,6 +29,7 @@
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/processing_instruction.h"
+#include "third_party/blink/renderer/core/html/html_document.h"
#include "third_party/blink/renderer/core/html/html_link_element.h"
#include "third_party/blink/renderer/core/html/html_style_element.h"
#include "third_party/blink/renderer/core/html/imports/html_import.h"
@@ -44,7 +45,7 @@ AtomicString StyleSheetCandidate::Title() const {
}
bool StyleSheetCandidate::IsXSL() const {
- return !GetNode().GetDocument().IsHTMLDocument() && type_ == kPi &&
+ return !IsA<HTMLDocument>(GetNode().GetDocument()) && type_ == kPi &&
To<ProcessingInstruction>(GetNode()).IsXSL();
}
diff --git a/chromium/third_party/blink/renderer/core/css/style_sheet_candidate.h b/chromium/third_party/blink/renderer/core/css/style_sheet_candidate.h
index 3f7f645bb4b..e6208bf6439 100644
--- a/chromium/third_party/blink/renderer/core/css/style_sheet_candidate.h
+++ b/chromium/third_party/blink/renderer/core/css/style_sheet_candidate.h
@@ -43,7 +43,7 @@ class StyleSheetCandidate {
public:
enum Type { kHTMLLink, kHTMLStyle, kSVGStyle, kPi, kInvalid };
- StyleSheetCandidate(Node& node) : node_(node), type_(TypeOf(node)) {}
+ StyleSheetCandidate(Node& node) : node_(&node), type_(TypeOf(node)) {}
bool IsXSL() const;
bool IsImport() const;
@@ -64,7 +64,7 @@ class StyleSheetCandidate {
static Type TypeOf(Node&);
- Member<Node> node_;
+ Node* node_;
Type type_;
};
diff --git a/chromium/third_party/blink/renderer/core/css/style_sheet_collection.cc b/chromium/third_party/blink/renderer/core/css/style_sheet_collection.cc
index 0b304623e35..92c1fec1051 100644
--- a/chromium/third_party/blink/renderer/core/css/style_sheet_collection.cc
+++ b/chromium/third_party/blink/renderer/core/css/style_sheet_collection.cc
@@ -62,7 +62,7 @@ void StyleSheetCollection::AppendSheetForList(StyleSheet* sheet) {
style_sheets_for_style_sheet_list_.push_back(sheet);
}
-void StyleSheetCollection::Trace(blink::Visitor* visitor) {
+void StyleSheetCollection::Trace(Visitor* visitor) {
visitor->Trace(active_author_style_sheets_);
visitor->Trace(style_sheets_for_style_sheet_list_);
}
diff --git a/chromium/third_party/blink/renderer/core/css/style_sheet_collection.h b/chromium/third_party/blink/renderer/core/css/style_sheet_collection.h
index 57951be3103..a1f8d3d677d 100644
--- a/chromium/third_party/blink/renderer/core/css/style_sheet_collection.h
+++ b/chromium/third_party/blink/renderer/core/css/style_sheet_collection.h
@@ -65,7 +65,7 @@ class CORE_EXPORT StyleSheetCollection
void AppendSheetForList(StyleSheet*);
void MarkSheetListDirty() { sheet_list_dirty_ = true; }
- virtual void Trace(blink::Visitor*);
+ virtual void Trace(Visitor*);
const char* NameInHeapSnapshot() const override {
return "StyleSheetCollection";
}
diff --git a/chromium/third_party/blink/renderer/core/css/style_sheet_contents.cc b/chromium/third_party/blink/renderer/core/css/style_sheet_contents.cc
index 000e05e1de7..85d3a8e9d08 100644
--- a/chromium/third_party/blink/renderer/core/css/style_sheet_contents.cc
+++ b/chromium/third_party/blink/renderer/core/css/style_sheet_contents.cc
@@ -601,6 +601,8 @@ void StyleSheetContents::ClearReferencedFromResource() {
RuleSet& StyleSheetContents::EnsureRuleSet(const MediaQueryEvaluator& medium,
AddRuleFlags add_rule_flags) {
+ if (rule_set_ && rule_set_->DidMediaQueryResultsChange(medium))
+ rule_set_ = nullptr;
if (!rule_set_) {
rule_set_ = MakeGarbageCollected<RuleSet>();
rule_set_->AddRulesFromSheet(this, medium, add_rule_flags);
@@ -674,7 +676,7 @@ void StyleSheetContents::FindFontFaceRules(
FindFontFaceRulesFromRules(ChildRules(), font_face_rules);
}
-void StyleSheetContents::Trace(blink::Visitor* visitor) {
+void StyleSheetContents::Trace(Visitor* visitor) {
visitor->Trace(owner_rule_);
visitor->Trace(import_rules_);
visitor->Trace(namespace_rules_);
diff --git a/chromium/third_party/blink/renderer/core/css/style_sheet_contents.h b/chromium/third_party/blink/renderer/core/css/style_sheet_contents.h
index c92b55bd7b4..746d80b89b7 100644
--- a/chromium/third_party/blink/renderer/core/css/style_sheet_contents.h
+++ b/chromium/third_party/blink/renderer/core/css/style_sheet_contents.h
@@ -59,6 +59,8 @@ class CORE_EXPORT StyleSheetContents final
StyleSheetContents() = delete;
~StyleSheetContents();
+ // TODO(xiaochengh): |parser_context_| should never be null. Make it return a
+ // const reference here to avoid confusion.
const CSSParserContext* ParserContext() const { return parser_context_; }
const AtomicString& DefaultNamespace() const { return default_namespace_; }
@@ -189,7 +191,7 @@ class CORE_EXPORT StyleSheetContents final
String SourceMapURL() const { return source_map_url_; }
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
StyleSheetContents& operator=(const StyleSheetContents&) = delete;
diff --git a/chromium/third_party/blink/renderer/core/css/style_sheet_list.cc b/chromium/third_party/blink/renderer/core/css/style_sheet_list.cc
index 5df9b07a218..eb9e126c479 100644
--- a/chromium/third_party/blink/renderer/core/css/style_sheet_list.cc
+++ b/chromium/third_party/blink/renderer/core/css/style_sheet_list.cc
@@ -86,7 +86,7 @@ CSSStyleSheet* StyleSheetList::AnonymousNamedGetter(const AtomicString& name) {
return sheet;
}
-void StyleSheetList::Trace(blink::Visitor* visitor) {
+void StyleSheetList::Trace(Visitor* visitor) {
visitor->Trace(tree_scope_);
visitor->Trace(style_sheet_vector_);
ScriptWrappable::Trace(visitor);
diff --git a/chromium/third_party/blink/renderer/core/css/style_sheet_list.h b/chromium/third_party/blink/renderer/core/css/style_sheet_list.h
index dd80ae6122e..88905c866de 100644
--- a/chromium/third_party/blink/renderer/core/css/style_sheet_list.h
+++ b/chromium/third_party/blink/renderer/core/css/style_sheet_list.h
@@ -50,7 +50,7 @@ class CORE_EXPORT StyleSheetList final : public ScriptWrappable {
CSSStyleSheet* AnonymousNamedGetter(const AtomicString&);
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
private:
const HeapVector<Member<StyleSheet>>& StyleSheets() const;
diff --git a/chromium/third_party/blink/renderer/core/css/style_traversal_root.h b/chromium/third_party/blink/renderer/core/css/style_traversal_root.h
index 78440f040f5..83d3a95dbf0 100644
--- a/chromium/third_party/blink/renderer/core/css/style_traversal_root.h
+++ b/chromium/third_party/blink/renderer/core/css/style_traversal_root.h
@@ -46,7 +46,7 @@ class CORE_EXPORT StyleTraversalRoot {
root_type_ = RootType::kSingleRoot;
}
- void Trace(blink::Visitor* visitor) { visitor->Trace(root_node_); }
+ void Trace(Visitor* visitor) { visitor->Trace(root_node_); }
protected:
virtual ~StyleTraversalRoot() = default;
diff --git a/chromium/third_party/blink/renderer/core/css/svg.css b/chromium/third_party/blink/renderer/core/css/svg.css
index 7c8ccbab6c3..f031de7f650 100644
--- a/chromium/third_party/blink/renderer/core/css/svg.css
+++ b/chromium/third_party/blink/renderer/core/css/svg.css
@@ -95,12 +95,15 @@ foreignObject {
https://drafts.csswg.org/css-color-adjust-1/#forced-colors-properties
*/
@media forced-colors {
+ svg:root {
+ color: CanvasText;
+ }
+
svg {
forced-color-adjust: none;
}
- text, foreignObject {
- fill: WindowText;
+ foreignObject {
forced-color-adjust: auto;
}
}
diff --git a/chromium/third_party/blink/renderer/core/css/threaded/font_object_threaded_test.cc b/chromium/third_party/blink/renderer/core/css/threaded/font_object_threaded_test.cc
index e7adb8d968a..98f767dee50 100644
--- a/chromium/third_party/blink/renderer/core/css/threaded/font_object_threaded_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/threaded/font_object_threaded_test.cc
@@ -52,8 +52,7 @@ TSAN_TEST(FontObjectThreadedTest, GetDefaultFontData) {
for (FontDescription::GenericFamilyType family_type :
{FontDescription::kStandardFamily, FontDescription::kSerifFamily,
FontDescription::kSansSerifFamily, FontDescription::kMonospaceFamily,
- FontDescription::kCursiveFamily, FontDescription::kFantasyFamily,
- FontDescription::kPictographFamily}) {
+ FontDescription::kCursiveFamily, FontDescription::kFantasyFamily}) {
FontDescription font_description;
font_description.SetComputedSize(12.0);
font_description.SetLocale(LayoutLocale::Get("en"));
@@ -61,8 +60,6 @@ TSAN_TEST(FontObjectThreadedTest, GetDefaultFontData) {
font_description.SetGenericFamily(family_type);
Font font = Font(font_description);
- font.Update(nullptr);
-
ASSERT_TRUE(font.PrimaryFont());
}
});
@@ -121,7 +118,6 @@ TSAN_TEST(FontObjectThreadedTest, WordShaperTest) {
font_description.SetGenericFamily(FontDescription::kStandardFamily);
Font font = Font(font_description);
- font.Update(nullptr);
ASSERT_TRUE(font.CanShapeWordByWord());
ShapeCache cache;
diff --git a/chromium/third_party/blink/renderer/core/css/threaded/text_renderer_threaded_test.cc b/chromium/third_party/blink/renderer/core/css/threaded/text_renderer_threaded_test.cc
index a5dc9527686..460006ee9d1 100644
--- a/chromium/third_party/blink/renderer/core/css/threaded/text_renderer_threaded_test.cc
+++ b/chromium/third_party/blink/renderer/core/css/threaded/text_renderer_threaded_test.cc
@@ -37,7 +37,6 @@ TSAN_TEST(TextRendererThreadedTest, MeasureText) {
font_description.SetGenericFamily(FontDescription::kStandardFamily);
Font font = Font(font_description);
- font.Update(nullptr);
const SimpleFontData* font_data = font.PrimaryFont();
ASSERT_TRUE(font_data);
@@ -77,7 +76,6 @@ TSAN_TEST(TextRendererThreadedTest, DrawText) {
font_description.SetGenericFamily(FontDescription::kStandardFamily);
Font font = Font(font_description);
- font.Update(nullptr);
FloatPoint location(0, 0);
TextRun text_run(text, 0, 0, TextRun::kAllowTrailingExpansion,
diff --git a/chromium/third_party/blink/renderer/core/css/tree_scope_style_sheet_collection.cc b/chromium/third_party/blink/renderer/core/css/tree_scope_style_sheet_collection.cc
index fed66b88285..738ab2f9d56 100644
--- a/chromium/third_party/blink/renderer/core/css/tree_scope_style_sheet_collection.cc
+++ b/chromium/third_party/blink/renderer/core/css/tree_scope_style_sheet_collection.cc
@@ -50,10 +50,6 @@ void TreeScopeStyleSheetCollection::AddStyleSheetCandidateNode(Node& node) {
style_sheet_candidate_nodes_.Add(&node);
}
-bool TreeScopeStyleSheetCollection::MediaQueryAffectingValueChanged() {
- return ClearMediaQueryDependentRuleSets(active_author_style_sheets_);
-}
-
void TreeScopeStyleSheetCollection::ApplyActiveStyleSheetChanges(
StyleSheetCollection& new_collection) {
GetDocument().GetStyleEngine().ApplyRuleSetChanges(
@@ -89,7 +85,7 @@ void TreeScopeStyleSheetCollection::UpdateStyleSheetList() {
SwapSheetsForSheetList(new_list);
}
-void TreeScopeStyleSheetCollection::Trace(blink::Visitor* visitor) {
+void TreeScopeStyleSheetCollection::Trace(Visitor* visitor) {
visitor->Trace(tree_scope_);
visitor->Trace(style_sheet_candidate_nodes_);
StyleSheetCollection::Trace(visitor);
diff --git a/chromium/third_party/blink/renderer/core/css/tree_scope_style_sheet_collection.h b/chromium/third_party/blink/renderer/core/css/tree_scope_style_sheet_collection.h
index 2236374d8be..e7e28c21fe0 100644
--- a/chromium/third_party/blink/renderer/core/css/tree_scope_style_sheet_collection.h
+++ b/chromium/third_party/blink/renderer/core/css/tree_scope_style_sheet_collection.h
@@ -51,12 +51,10 @@ class CORE_EXPORT TreeScopeStyleSheetCollection : public StyleSheetCollection {
}
bool HasStyleSheets() const;
- bool MediaQueryAffectingValueChanged();
-
virtual bool IsShadowTreeStyleSheetCollection() const { return false; }
void UpdateStyleSheetList();
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
protected:
explicit TreeScopeStyleSheetCollection(TreeScope&);
diff --git a/chromium/third_party/blink/renderer/core/css/vision_deficiency.cc b/chromium/third_party/blink/renderer/core/css/vision_deficiency.cc
new file mode 100644
index 00000000000..6ab3903071e
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/vision_deficiency.cc
@@ -0,0 +1,73 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/blink/renderer/core/css/vision_deficiency.h"
+#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
+
+namespace blink {
+
+AtomicString CreateFilterDataUrl(AtomicString piece) {
+ // clang-format off
+ AtomicString url =
+ "data:image/svg+xml,"
+ "<svg xmlns=\"http://www.w3.org/2000/svg\">"
+ "<filter id=\"f\">" +
+ piece +
+ "</filter>"
+ "</svg>"
+ "#f";
+ // clang-format on
+ return url;
+}
+
+AtomicString CreateVisionDeficiencyFilterUrl(
+ VisionDeficiency vision_deficiency) {
+ // The filter color matrices are based on the following research paper:
+ // Gustavo M. Machado, Manuel M. Oliveira, and Leandro A. F. Fernandes
+ // "A Physiologically-based Model for Simulation of Color Vision Deficiency".
+ // IEEE Transactions on Visualization and Computer Graphics. Volume 15 (2009),
+ // Number 6, November/December 2009. pp. 1291-1298.
+ // https://www.inf.ufrgs.br/~oliveira/pubs_files/CVD_Simulation/CVD_Simulation.html
+ switch (vision_deficiency) {
+ case VisionDeficiency::kAchromatopsia:
+ return CreateFilterDataUrl(
+ "<feColorMatrix values=\""
+ "0.299 0.587 0.114 0.000 0.000 "
+ "0.299 0.587 0.114 0.000 0.000 "
+ "0.299 0.587 0.114 0.000 0.000 "
+ "0.000 0.000 0.000 1.000 0.000 "
+ "\"/>");
+ case VisionDeficiency::kBlurredVision:
+ return CreateFilterDataUrl("<feGaussianBlur stdDeviation=\"2\"/>");
+ case VisionDeficiency::kDeuteranopia:
+ return CreateFilterDataUrl(
+ "<feColorMatrix values=\""
+ " 0.367 0.861 -0.228 0.000 0.000 "
+ " 0.280 0.673 0.047 0.000 0.000 "
+ "-0.012 0.043 0.969 0.000 0.000 "
+ " 0.000 0.000 0.000 1.000 0.000 "
+ "\"/>");
+ case VisionDeficiency::kProtanopia:
+ return CreateFilterDataUrl(
+ "<feColorMatrix values=\""
+ " 0.152 1.053 -0.205 0.000 0.000 "
+ " 0.115 0.786 0.099 0.000 0.000 "
+ "-0.004 -0.048 1.052 0.000 0.000 "
+ " 0.000 0.000 0.000 1.000 0.000 "
+ "\"/>");
+ case VisionDeficiency::kTritanopia:
+ return CreateFilterDataUrl(
+ "<feColorMatrix values=\""
+ " 1.256 -0.077 -0.179 0.000 0.000 "
+ "-0.078 0.931 0.148 0.000 0.000 "
+ " 0.005 0.691 0.304 0.000 0.000 "
+ " 0.000 0.000 0.000 1.000 0.000 "
+ "\"/>");
+ case VisionDeficiency::kNoVisionDeficiency:
+ NOTREACHED();
+ return "";
+ }
+}
+
+} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/css/vision_deficiency.h b/chromium/third_party/blink/renderer/core/css/vision_deficiency.h
new file mode 100644
index 00000000000..84d70757200
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/vision_deficiency.h
@@ -0,0 +1,26 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_VISION_DEFICIENCY_H_
+#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_VISION_DEFICIENCY_H_
+
+#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
+
+namespace blink {
+
+enum class VisionDeficiency {
+ kNoVisionDeficiency,
+ kAchromatopsia,
+ kBlurredVision,
+ kDeuteranopia,
+ kProtanopia,
+ kTritanopia,
+};
+
+AtomicString CreateVisionDeficiencyFilterUrl(
+ VisionDeficiency vision_deficiency);
+
+} // namespace blink
+
+#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_VISION_DEFICIENCY_H_
diff --git a/chromium/third_party/blink/renderer/core/css/webxr_overlay.css b/chromium/third_party/blink/renderer/core/css/webxr_overlay.css
new file mode 100644
index 00000000000..d4f65fb76e1
--- /dev/null
+++ b/chromium/third_party/blink/renderer/core/css/webxr_overlay.css
@@ -0,0 +1,26 @@
+:xr-overlay {
+ /* force a transparent background */
+ background: rgba(0,0,0,0) !important;
+
+ /* act as containing block for descendants */
+ contain: paint !important;
+
+ /* the following styling is identical to :fullscreen */
+ position: fixed !important;
+ top: 0 !important;
+ right: 0 !important;
+ bottom: 0 !important;
+ left: 0 !important;
+ margin: 0 !important;
+ box-sizing: border-box !important;
+ min-width: 0 !important;
+ max-width: none !important;
+ min-height: 0 !important;
+ max-height: none !important;
+ width: 100% !important;
+ height: 100% !important;
+ transform: none !important;
+
+ /* intentionally not !important */
+ object-fit: contain;
+}