Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web Inspector: Show parent style rules for nested style rules in Styles sidebar #8202

Commits on Jan 6, 2023

  1. Web Inspector: Show parent style rules for nested style rules in Styl…

    …es sidebar
    
    https://bugs.webkit.org/show_bug.cgi?id=250088
    rdar://100522930
    
    Reviewed by Antti Koivisto.
    
    Add basic support for viewing and editing parent style rule selectors for nested style rules. This uses the same
    mechanism we already use for showing parent `@rule`s, including support for editing.
    
    * LayoutTests/inspector/css/getMatchesStylesForNodeNestingStyleGrouping-expected.txt: Added.
    * LayoutTests/inspector/css/getMatchesStylesForNodeNestingStyleGrouping.html: Added.
    
    * LayoutTests/inspector/css/setGroupingHeaderText-expected.txt:
    * LayoutTests/inspector/css/setGroupingHeaderText.html:
    - Add test cases for modifying a parent Style rule's selector via a Grouping on a child nested rule.
    
    * Source/JavaScriptCore/inspector/protocol/CSS.json:
    - Add new "StyleRule" grouping type to represent parent style rules.
    
    * Source/WebCore/WebCore.xcodeproj/project.pbxproj:
    
    * Source/WebCore/css/CSSStyleRule.cpp:
    (WebCore::CSSStyleRule::CSSStyleRule):
    (WebCore::CSSStyleRule::length const):
    (WebCore::CSSStyleRule::item const):
    (WebCore::CSSStyleRule::cssRules const):
    * Source/WebCore/css/CSSStyleRule.h:
    - Add support for getting the nested rules inside a CSSStyleRule.
    
    * Source/WebCore/css/StyleRule.cpp:
    (WebCore::StyleRuleBase::createCSSOMWrapper const):
    * Source/WebCore/css/StyleRule.h:
    - Support creating a wrapper with a CSSStyleRule as a parent.
    
    * Source/WebCore/css/parser/CSSParser.cpp:
    (WebCore::CSSParser::parseSelector):
    * Source/WebCore/css/parser/CSSParser.h:
    - Allow callers to enable nesting syntax for parsing a selector, which is done to verify a selector is valid by Web
    Inspector when editing a nested rule's selector.
    
    * Source/WebCore/inspector/InspectorStyleSheet.cpp:
    (WebCore::flatteningStrategyForStyleRuleType):
    - Style rules can now contain rules, so get rid of the `Commit` strategy and use the existing `CommitSelfThenChildren`
    for style rules instead.
    
    (WebCore::isValidRuleHeaderText):
    - Pass through the nesting mode for parsing selectors.
    
    (WebCore::protocolGroupingTypeForStyleRuleType):
    (WebCore::flattenSourceData):
    - Get rid of `Commit` strategy.
    
    (WebCore::StyleSheetHandler::startRuleHeader):
    - It is no longer invalid to encounter the start of a style rule before encountering the end of the previous style rule.
    
    (WebCore::asCSSRuleList):
    
    (WebCore::InspectorStyleSheet::buildArrayForGroupings):
    - Start with the parent of the passed CSSRule, otherwise every style rule will include itself as a grouping.
    
    (WebCore::isNestedContext):
    (WebCore::InspectorStyleSheet::setRuleHeaderText):
    - Nested rules should allow relevant syntax for selectors.
    
    (WebCore::InspectorStyleSheet::collectFlatRules):
    
    * Source/WebCore/style/InspectorCSSOMWrappers.cpp:
    (WebCore::Style::InspectorCSSOMWrappers::collect):
    - Eagerly create CSSOM wrappers for nested rules.
    
    * Source/WebInspectorUI/UserInterface/Models/CSSGrouping.js:
    (WI.CSSGrouping.prototype.get isStyle):
    (WI.CSSGrouping.prototype.get prefix):
    (WI.CSSGrouping):
    - Nested rules don't have a prefix like `@rule`s do, so provide a null prefix.
    
    * Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:
    (WI.SpreadsheetCSSStyleDeclarationSection.prototype._renderGroupings):
    - Support groupings without a prefix by not prepending the prefix.
    
    Canonical link: https://commits.webkit.org/258555@main
    patrickangle committed Jan 6, 2023
    Configuration menu
    Copy the full SHA
    b5cf192 View commit details
    Browse the repository at this point in the history