[Webkit-unassigned] [Bug 137378] Web Inspector: Highlighted selectors in Rules sidebar break with selectors that contain nested selector lists

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Oct 2 20:09:43 PDT 2014


https://bugs.webkit.org/show_bug.cgi?id=137378





--- Comment #2 from Joseph Pecoraro <joepeck at webkit.org>  2014-10-02 20:09:39 PST ---
Nested selector lists are causing the CSSParser SourceData to be out of whack.

On the protocol, we see the list of selectors is broken at the comma of the nested list:

    "selectorList": {
        "selectors": [".testClass", "a", "span", ":nth-child(n of *", "p)", "bumble", "p"],
        "text": ".testclass, a, span, :nth-child(n of *, p), bumble, p",
        ...
    }

This is because CSSParser is marking the start/ends as it sees commas: (CSSGrammar.y.in)

    at_rule_header_end: { parser->markRuleHeaderEnd(); } ;
    at_selector_end: { parser->markSelectorEnd(); } ;

    selector_list:
        ...
        | selector_list at_selector_end ',' maybe_space before_selector_group_item complex_selector %prec UNIMPORTANT_TOK {
        ...

So if we are doing a nested selector list, we get an errant early markSelectorEnd().

The markStart/End is only used by the Inspector here, so that we can send the exact text from the stylesheet to the frontend. We want this to show the case of the selector. ".testClass" instead of ".testclass". (InspectorStyleSheet.cpp)


    static PassRefPtr<Inspector::Protocol::Array<String>> selectorsFromSource(const CSSRuleSourceData* sourceData, const String& sheetText)
    {
        DEPRECATED_DEFINE_STATIC_LOCAL(JSC::Yarr::RegularExpression, comment, ("/\\*[^]*?\\*/", TextCaseSensitive, JSC::Yarr::MultilineEnabled));
        RefPtr<Inspector::Protocol::Array<String>> result = Inspector::Protocol::Array<String>::create();
>       const SelectorRangeList& ranges = sourceData->selectorRanges;
        for (size_t i = 0, size = ranges.size(); i < size; ++i) {
            const SourceRange& range = ranges.at(i);
            String selector = sheetText.substring(range.start, range.length());

            // We don't want to see any comments in the selector components, only the meaningful parts.
            replace(selector, comment, "");
            result->addItem(selector.stripWhiteSpace());
        }
        return result.release();
    }

    PassRefPtr<Inspector::Protocol::CSS::SelectorList> InspectorStyleSheet::buildObjectForSelectorList(CSSStyleRule* rule)
    {
        ...
>       if (sourceData)
>           selectors = selectorsFromSource(sourceData.get(), m_parsedStyleSheet->text());
>       else {
            selectors = Inspector::Protocol::Array<String>::create();
            const CSSSelectorList& selectorList = rule->styleRule()->selectorList();
            for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(selector))
                selectors->addItem(selector->selectorText());
        }
        ...
    }

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list