예제 #1
0
void StyleScopeResolver::matchHostRules(const Element* element, Vector<RuleSet*>& matchedRules)
{
    if (m_atHostRules.isEmpty())
        return;

    ElementShadow* shadow = element->shadow();
    if (!shadow)
        return;

    // FIXME(99827): https://bugs.webkit.org/show_bug.cgi?id=99827
    // add a new flag to ElementShadow and cache whether any @host @-rules are
    // applied to the element or not. So we can quickly exit this method
    // by using the flag.
    for (ShadowRoot* shadowRoot = shadow->youngestShadowRoot(); shadowRoot; shadowRoot = shadowRoot->olderShadowRoot()) { 
        if (RuleSet* ruleSet = atHostRuleSetFor(shadowRoot))
            matchedRules.append(ruleSet);
        if (!shadowRoot->hasShadowInsertionPoint())
            break;
    }
}
예제 #2
0
bool StyleScopeResolver::styleSharingCandidateMatchesHostRules(const Element* element)
{
    if (m_atHostRules.isEmpty())
        return false;

    ElementShadow* shadow = element->shadow();
    if (!shadow)
        return false;

    // FIXME(99827): https://bugs.webkit.org/show_bug.cgi?id=99827
    // add a new flag to ElementShadow and cache whether any@host @-rules are
    // applied to the element or not. So we can avoid always traversing
    // shadow roots.
    for (ShadowRoot* shadowRoot = shadow->youngestShadowRoot(); shadowRoot; shadowRoot = shadowRoot->olderShadowRoot()) {
        if (atHostRuleSetFor(shadowRoot))
            return true;

        if (!shadowRoot->hasShadowInsertionPoint())
            break;
    }
    return false;
}