haikuwebkit/LayoutTests/inspector/css
Patrick Angle 8e9b7a21d6 Web Inspector: Style rules declared after a rule whose selector has over 8192 components are not shown correctly
https://bugs.webkit.org/show_bug.cgi?id=229218

Reviewed by Devin Rousso.

Source/WebCore:

Test: inspector/css/getMatchedStylesForNodeLargeSelectors.html

CSS rules are limited to 8192 selector components in WebCore, and when more components are present the rule is
split into multiple `StyleRule` instances. This meant Web Inspector could not reliably resolve a `StyleRule`
back to its source data, which we do to enable things like editing, as well as to make sure we show the un-split
selector in the Styles sidebar of the Elements tab. Previously, the presences of multiple `StyleRule`s for a
single source data declaration was not accounted for, which meant that rules after the split rules would show a
mix of style information from the actual rule as well as a rule some number of declarations later in the same
style sheet. This is resolved by marking `StyleRule`s that have been split and marking the last of the split
rules. This allows us to then forgo incrementing the index for looking up raw declarations until we encounter
the last rule from a split `StyleRule`.

 * css/StyleRule.cpp:
(WebCore::StyleRule::StyleRule):
(WebCore::StyleRule::createForSplitting):
(WebCore::StyleRule::splitIntoMultipleRulesWithMaximumSelectorComponentCount const):

* css/StyleRule.h:
- Added two members to track rules that are split into multiple rules due to exceeding the 8192 component limit
for selectors in order to determine later which rules are effectively duplicates of each other. We use two
members here, one to track that the rule was split from a larger authored rule (`m_isSplitRule`), and one to
mark the last rule split from a given rule (`m_isLastRuleInSplitRule`). The second member prevents situations
where we might otherwise accidentally continue iterating into a list of `StyleRule` where two large authored
rules that had to be split are present next to each other in an ordered collection of `StyleRule`.

* inspector/InspectorStyleSheet.cpp:
(WebCore::selectorsFromSource):
- Use a vector of `CSSSelector`s for specificity information since we now collect selectors from potentially
multiple `CSSStyleRule`s.

(WebCore::InspectorStyleSheet::cssStyleRulesSplitFromSameRule):
- Find any neighboring CSSStyleRules that were split from the same original rule based on the order of rules as
well as the new flags in `StyleRule`

(WebCore::InspectorStyleSheet::selectorsForCSSStyleRule):
- Find all selectors for a given CSSStyleRule, including other `CSSStyleRule`s split from the same rule in a
style sheet.

(WebCore::InspectorStyleSheet::buildObjectForSelectorList):
- Use all CSSSelectors from for the CSSStyleRule and other rules that were split from the same rule in a style
sheet.

(WebCore::InspectorStyleSheet::ruleSourceDataFor const):
(WebCore::InspectorStyleSheet::ruleIndexByStyle const):
- When looking up an index to get rule source data, make sure we don't overcount split rules.

* inspector/InspectorStyleSheet.h:

LayoutTests:

Test very large (8192 individual component) selectors to ensure surrounding styles are correctly resolved.

* inspector/css/getMatchedStylesForNodeLargeSelectors-expected.txt: Added.
* inspector/css/getMatchedStylesForNodeLargeSelectors.html: Added.


Canonical link: https://commits.webkit.org/240769@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281354 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-21 00:35:46 +00:00
..
resources
add-css-property-expected.txt Web Inspector: Styles: toggling selected properties may cause data corruption 2018-12-15 10:03:19 +00:00
add-css-property.html Web Inspector: Uncaught Exception: Missing node for given nodeId 2019-12-07 06:06:27 +00:00
add-rule-expected.txt Web Inspector: rename CSS.StyleSheetOrigin.Regular to CSS.StyleSheetOrigin.Author to match the spec 2020-05-14 02:34:39 +00:00
add-rule.html Web Inspector: rename CSS.StyleSheetOrigin.Regular to CSS.StyleSheetOrigin.Author to match the spec 2020-05-14 02:34:39 +00:00
createStyleSheet-expected.txt Web Inspector: Separate creating a style sheet from adding a new rule in the protocol 2015-08-28 17:59:27 +00:00
createStyleSheet.html Web Inspector: rename frontend managers to be more consistent with backend agents 2018-10-02 22:14:52 +00:00
css-property-expected.txt Web Inspector: Styles: refactor properties/allProperties/visibleProperties/allVisibleProperties 2019-01-23 01:46:01 +00:00
css-property.html Web Inspector: Uncaught Exception: Missing node for given nodeId 2019-12-07 06:06:27 +00:00
findVariableNames-expected.txt Web Inspector: Styles panel slow to render when inspecting node with many inherited CSS variables 2021-06-08 15:57:00 +00:00
findVariableNames.html Web Inspector: Styles panel slow to render when inspecting node with many inherited CSS variables 2021-06-08 15:57:00 +00:00
force-page-appearance-expected.txt Web Inspector: Add support for forcing color scheme appearance in DOM tree. 2018-11-27 21:16:07 +00:00
force-page-appearance.html Web Inspector: Uncaught Exception: Missing node for given nodeId 2019-12-07 06:06:27 +00:00
generateCSSRuleString-expected.txt Web Inspector: "Copy Rule" menu item does not propagate comments properly 2019-08-24 18:21:04 +00:00
generateCSSRuleString.html Web Inspector: Uncaught Exception: Missing node for given nodeId 2019-12-07 06:06:27 +00:00
get-system-fonts-expected.txt Web Inspector: Fix some typos and style in LayoutTests/inspector 2016-12-21 18:52:28 +00:00
get-system-fonts.html Web Inspector: Slow open time enumerating system fonts (FontCache::systemFontFamilies) 2018-01-03 20:17:12 +00:00
getAllStyleSheets-expected.txt Unreviewed. Update test expectations after https://bugs.webkit.org/show_bug.cgi?id=170279. 2017-03-31 00:51:51 +00:00
getAllStyleSheets.html REGRESSION (r261109): [ Mac ] inspector/css/getAllStyleSheets.html is failing 2020-05-04 23:22:43 +00:00
getComputedPrimaryFontForNode-expected.txt Web Inspector: Show current properties for font in new Elements sidebar Font panel 2020-12-10 19:09:00 +00:00
getComputedPrimaryFontForNode.html Web Inspector: Show current properties for font in new Elements sidebar Font panel 2020-12-10 19:09:00 +00:00
getComputedStyleForNode-expected.txt Web Inspector: Elements: Computed: show shorthand properties in addition to longhand ones 2019-10-12 03:40:42 +00:00
getComputedStyleForNode.html Web Inspector: Elements: Computed: show shorthand properties in addition to longhand ones 2019-10-12 03:40:42 +00:00
getMatchedStylesForNode-expected.txt REGRESSION (r266288): Web Inspector: ::marker shows on every element now 2021-03-03 17:59:27 +00:00
getMatchedStylesForNode.html Web Inspector: front-end shouldn't change the order of User Style Sheet rules 2020-05-14 19:28:41 +00:00
getMatchedStylesForNodeLargeSelectors-expected.txt Web Inspector: Style rules declared after a rule whose selector has over 8192 components are not shown correctly 2021-08-21 00:35:46 +00:00
getMatchedStylesForNodeLargeSelectors.html Web Inspector: Style rules declared after a rule whose selector has over 8192 components are not shown correctly 2021-08-21 00:35:46 +00:00
getMatchedStylesForNodeMarkerPseudoId-expected.txt REGRESSION (r266288): Web Inspector: ::marker shows on every element now 2021-03-03 17:59:27 +00:00
getMatchedStylesForNodeMarkerPseudoId.html REGRESSION (r266288): Web Inspector: ::marker shows on every element now 2021-03-03 17:59:27 +00:00
getSupportedCSSProperties-expected.txt Web Inspector: generate CSSKeywordCompletions from backend values 2018-09-17 22:43:11 +00:00
getSupportedCSSProperties.html Web Inspector: generate CSSKeywordCompletions from backend values 2018-09-17 22:43:11 +00:00
manager-preferredInspectorStyleSheetForFrame-expected.txt REGRESSION(r206133): LayoutTest inspector/css/manager-preferredInspectorStyleSheetForFrame.html is a flaky failure 2017-01-12 05:56:46 +00:00
manager-preferredInspectorStyleSheetForFrame.html Web Inspector: rename frontend managers to be more consistent with backend agents 2018-10-02 22:14:52 +00:00
matched-style-properties-expected.txt
matched-style-properties.html Web Inspector: Uncaught Exception: Missing node for given nodeId 2019-12-07 06:06:27 +00:00
modify-css-property-expected.txt Web Inspector: Styles: fix race conditions when editing 2019-02-04 23:30:49 +00:00
modify-css-property-race-expected.txt Web Inspector: Styles: PropertiesChanged shouldn't fire when old and new text are both empty 2019-02-06 06:54:43 +00:00
modify-css-property-race.html Web Inspector: Uncaught Exception: Missing node for given nodeId 2019-12-07 06:06:27 +00:00
modify-css-property.html Web Inspector: Uncaught Exception: Missing node for given nodeId 2019-12-07 06:06:27 +00:00
modify-inline-style-expected.txt Web Inspector: Styles: valid values in style attributes are reported as unsupported property values 2019-02-15 23:44:15 +00:00
modify-inline-style.html Web Inspector: Uncaught Exception: Missing node for given nodeId 2019-12-07 06:06:27 +00:00
modify-rule-selector-expected.txt Remove trailing spaces from expected.txt files (excluding WPT for now since that contains too many) 2020-09-27 02:15:19 +00:00
modify-rule-selector.html Web Inspector: Uncaught Exception: Missing node for given nodeId 2019-12-07 06:06:27 +00:00
node-styles-refreshed-expected.txt REGRESSION(r243264): Web Inspector: Style pane doesn't update after toggling CSS class 2020-09-02 06:57:07 +00:00
node-styles-refreshed.html REGRESSION(r243264): Web Inspector: Style pane doesn't update after toggling CSS class 2020-09-02 06:57:07 +00:00
nodeLayoutContextTypeChanged-expected.txt Web Inspector: Display all CSS grids on page in Layout panel 2021-02-10 20:02:54 +00:00
nodeLayoutContextTypeChanged.html Web Inspector: Display all CSS grids on page in Layout panel 2021-02-10 20:02:54 +00:00
overridden-property-expected.txt Web Inspector: CSS variables not handled as case sensitive 2021-06-14 20:01:30 +00:00
overridden-property.html Web Inspector: CSS variables not handled as case sensitive 2021-06-14 20:01:30 +00:00
pseudo-creation-expected.txt Unreviewed, rolling out r251261. 2019-10-24 00:05:58 +00:00
pseudo-creation.html Unreviewed, rolling out r251261. 2019-10-24 00:05:58 +00:00
pseudo-element-matches-expected.txt Remove unused JS and CSS files of media controls 2021-03-22 22:17:49 +00:00
pseudo-element-matches-for-pseudo-element-node-expected.txt Handle custom identifiers and strings separately, so we can quote strings correctly consistently 2021-06-07 02:39:33 +00:00
pseudo-element-matches-for-pseudo-element-node.html Web Inspector: Uncaught Exception: Missing node for given nodeId 2019-12-07 06:06:27 +00:00
pseudo-element-matches.html Remove unused JS and CSS files of media controls 2021-03-22 22:17:49 +00:00
resolve-variable-value-expected.txt Web Inspector: Styles: variable swatch not shown for var() with a fallback 2019-08-05 23:40:40 +00:00
resolve-variable-value.html Web Inspector: Uncaught Exception: Missing node for given nodeId 2019-12-07 06:06:27 +00:00
selector-specificity-expected.txt Give pseudo elements the correct specificity 2014-11-06 22:07:19 +00:00
selector-specificity.html Web Inspector: Uncaught Exception: Missing node for given nodeId 2019-12-07 06:06:27 +00:00
setLayoutContextTypeChangedMode-expected.txt Web Inspector: Add `CSS.setLayoutContextTypeChangedMode` for getting information about all layout contexts 2021-02-09 03:30:17 +00:00
setLayoutContextTypeChangedMode.html Web Inspector: Add `CSS.setLayoutContextTypeChangedMode` for getting information about all layout contexts 2021-02-09 03:30:17 +00:00
shadow-scoped-style-expected.txt Unreviewed test gardening after r243229. 2019-03-20 23:36:06 +00:00
shadow-scoped-style.html Web Inspector: Uncaught Exception: Missing node for given nodeId 2019-12-07 06:06:27 +00:00
stylesheet-events-basic-expected.txt Web Inspector: Implement tracking of active stylesheets in the frontend 2015-08-26 23:48:49 +00:00
stylesheet-events-basic.html Web Inspector: rename frontend managers to be more consistent with backend agents 2018-10-02 22:14:52 +00:00
stylesheet-events-imports-expected.txt Web Inspector: Implement tracking of active stylesheets in the frontend 2015-08-26 23:48:49 +00:00
stylesheet-events-imports.html Web Inspector: rename frontend managers to be more consistent with backend agents 2018-10-02 22:14:52 +00:00
stylesheet-events-inspector-stylesheet-expected.txt Web Inspector: Separate creating a style sheet from adding a new rule in the protocol 2015-08-28 17:59:27 +00:00
stylesheet-events-inspector-stylesheet.html Web Inspector: rename frontend managers to be more consistent with backend agents 2018-10-02 22:14:52 +00:00
stylesheet-events-multiple-documents-expected.txt Web Inspector: Implement tracking of active stylesheets in the frontend 2015-08-26 23:48:49 +00:00
stylesheet-events-multiple-documents.html Web Inspector: rename frontend managers to be more consistent with backend agents 2018-10-02 22:14:52 +00:00
stylesheet-with-mutations-expected.txt Web Inspector: Crash inspecting styles of element with mutated stylesheet 2015-02-12 20:47:10 +00:00
stylesheet-with-mutations.html Web Inspector: Uncaught Exception: Missing node for given nodeId 2019-12-07 06:06:27 +00:00
usedCSSVariables-expected.txt Web Inspector: Styles panel slow to render when inspecting node with many inherited CSS variables 2021-06-08 15:57:00 +00:00
usedCSSVariables.html Web Inspector: Styles panel slow to render when inspecting node with many inherited CSS variables 2021-06-08 15:57:00 +00:00