Consider shorthands when removing equivalent properties from styles As part of some editing operations, like removing line-breaks, a DOM node may get merged into a different inline-block, hence inserted in a different parent. This operation normally wants the node's original inline style to be preserved, but we want to avoid redundant properties based on the inheritance from its new parent. The RemoveRedundantStylesAndKeepStyleSpanInline method implemented in the ReplaceSelectionCommand class takes care of the logic to analyze how the new inheritance affects to the node's style. For inline styles, it basically uses the RemoveStyleFromRulesAndContext method from the EditingStyle class. The root cause of the bug comes from the GetPropertiesNotIn() method and how it chooses the properties to remove from the CSSPropertyValueSet instance. The current implementation just iterates along the registered longhand properties, comparing their values with the respective properties in the new node's parent. However, this logic doesn't consider whether the properties' value come from a shorthand declaration in the original style. The bug is only reproducible when inspecting the serialized DOM after executing the editing operation, as it's done in the WPT editing tests, which fail only in chrome, described in the bug report. We only have hit by the bug when we implemented the "white-space" property as a shorthand, as part of the CSS Text L4 spec, which is correct, but we need to consider it when reconstructing the DOM tree after certain editing operations. The proposed solution is to define a new method in the CSSPropertyValueSet to remove the equivalent properties; in the case of the ones getting their value from a shorthand, they are only removed if all its associated longhands are equivalent. This function will be only used, for now, in the inline-style reconstruction logic performed as part of the ReplaceSelectionCommand operations. We may want to apply it to other editing-related operations in the future, and perhaps it'd make sense to integrate it in the common RemoveEquivalentProperties method of the CSSPropertyValueSet class. Bug: 483903178 Change-Id: I0b72dc6a32c8e5be5fceb5df5a802e85e9fe4a46 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7511015 Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org> Reviewed-by: Stephen Chenney <schenney@chromium.org> Reviewed-by: Dan Clark <daniec@microsoft.com> Commit-Queue: Javier Fernandez <jfernandez@igalia.com> Cr-Commit-Position: refs/heads/main@{#1592297}
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.
The project's web site is https://www.chromium.org.
To check out the source code locally, don't use git clone! Instead, follow the instructions on how to get the code.
Documentation in the source is rooted in docs/README.md.
Learn how to Get Around the Chromium Source Code Directory Structure.
For historical reasons, there are some small top level directories. Now the guidance is that new top level directories are for product (e.g. Chrome, Android WebView, Ash). Even if these products have multiple executables, the code should be in subdirectories of the product.
If you found a bug, please file it at https://crbug.com/new.