void ElementRuleCollector::appendCSSOMWrapperForRule(StyleRule* rule)
{
    // FIXME: There should be no codepath that creates a CSSOMWrapper without a parent stylesheet or rule because
    // then that codepath can lead to the CSSStyleSheet contents not getting correctly copied when the rule is modified
    // through the wrapper (e.g. rule.selectorText="div"). Right now, the inspector uses the pointers for identity though,
    // so calling CSSStyleSheet->willMutateRules breaks the inspector.
    CSSStyleSheet* sheet = m_includeStyleSheet == IncludeStyleSheetInCSSOMWrapper ? findStyleSheet(m_context.element()->document().styleEngine(), rule) : 0;
    RefPtr<CSSRule> cssRule = rule->createCSSOMWrapper(sheet);
    if (sheet)
        sheet->registerExtraChildRuleCSSOMWrapper(cssRule);
    ensureRuleList()->rules().append(cssRule);
}
Exemplo n.º 2
0
void ElementRuleCollector::appendCSSOMWrapperForRule(CSSStyleSheet* parentStyleSheet, StyleRule* rule)
{
    // |parentStyleSheet| is 0 if and only if the |rule| is coming from User Agent. In this case,
    // it is safe to create CSSOM wrappers without parentStyleSheets as they will be used only
    // by inspector which will not try to edit them.
    RefPtrWillBeRawPtr<CSSRule> cssRule = nullptr;
    if (parentStyleSheet)
        cssRule = findStyleRule(parentStyleSheet, rule);
    else
        cssRule = rule->createCSSOMWrapper();
    ASSERT(!parentStyleSheet || cssRule);
    ensureRuleList()->rules().append(cssRule);
}
Exemplo n.º 3
0
void ElementRuleCollector::sortAndTransferMatchedRules()
{
    const StyleResolverState& state = m_state;

    if (!m_matchedRules || m_matchedRules->isEmpty())
        return;

    sortMatchedRules();

    Vector<const RuleData*, 32>& matchedRules = *m_matchedRules;
    if (m_mode == SelectorChecker::CollectingRules) {
        for (unsigned i = 0; i < matchedRules.size(); ++i)
            ensureRuleList()->rules().append(matchedRules[i]->rule()->createCSSOMWrapper());
        return;
    }

    // Now transfer the set of matched rules over to our list of declarations.
    for (unsigned i = 0; i < matchedRules.size(); i++) {
        if (state.style() && matchedRules[i]->containsUncommonAttributeSelector())
            state.style()->setUnique();
        m_result.addMatchedProperties(matchedRules[i]->rule()->properties(), matchedRules[i]->rule(), matchedRules[i]->linkMatchType(), matchedRules[i]->propertyWhitelistType(m_matchingUARules));
    }
}