TEST_F(RuleFeatureSetTest, contentPseudo)
{
    updateInvalidationSets(".a ::content .b");
    updateInvalidationSets(".a .c");

    InvalidationLists invalidationLists;
    collectInvalidationSetsForClass(invalidationLists, "a");
    expectClassInvalidation("c", invalidationLists.descendants);

    updateInvalidationSets(".a .b");

    invalidationLists.descendants.clear();
    collectInvalidationSetsForClass(invalidationLists, "a");
    expectClassesInvalidation("b", "c", invalidationLists.descendants);
}
TEST_F(RuleFeatureSetTest, tagName)
{
    updateInvalidationSets(":valid e");

    InvalidationLists invalidationLists;
    collectInvalidationSetsForPseudoClass(invalidationLists, CSSSelector::PseudoValid);
    expectTagNameInvalidation("e", invalidationLists.descendants);
}
TEST_F(RuleFeatureSetTest, pseudoClass)
{
    updateInvalidationSets(":valid");

    InvalidationLists invalidationLists;
    collectInvalidationSetsForPseudoClass(invalidationLists, CSSSelector::PseudoValid);
    expectSelfInvalidation(invalidationLists.descendants);
}
TEST_F(RuleFeatureSetTest, attribute)
{
    updateInvalidationSets("[c] [d]");

    InvalidationLists invalidationLists;
    collectInvalidationSetsForAttribute(invalidationLists, QualifiedName("", "c", ""));
    expectAttributeInvalidation("d", invalidationLists.descendants);
}
TEST_F(RuleFeatureSetTest, id)
{
    updateInvalidationSets("#a #b");

    InvalidationLists invalidationLists;
    collectInvalidationSetsForId(invalidationLists, "a");
    expectIdInvalidation("b", invalidationLists.descendants);
}
TEST_F(RuleFeatureSetTest, descendantSiblingAny)
{
    updateInvalidationSets(".u .v ~ :-webkit-any(.w, .x)");

    InvalidationLists invalidationLists;
    collectInvalidationSetsForClass(invalidationLists, "u");
    expectClassesInvalidation("w", "x", invalidationLists.descendants);
    expectNoInvalidation(invalidationLists.siblings);
}
TEST_F(RuleFeatureSetTest, any)
{
    updateInvalidationSets(":-webkit-any(.w, .x)");

    InvalidationLists invalidationLists;
    collectInvalidationSetsForClass(invalidationLists, "w");
    expectSelfInvalidation(invalidationLists.descendants);
    expectNoInvalidation(invalidationLists.siblings);
}
TEST_F(RuleFeatureSetTest, anySibling)
{
    updateInvalidationSets(":-webkit-any(.q, .r) ~ .s .t");

    InvalidationLists invalidationLists;
    collectInvalidationSetsForClass(invalidationLists, "q");
    expectNoInvalidation(invalidationLists.descendants);
    expectSiblingDescendantInvalidation(UINT_MAX, "s", "t", invalidationLists.siblings);
}
TEST_F(RuleFeatureSetTest, interleavedDescendantSibling6)
{
    updateInvalidationSets(".k > .l ~ .m + .n .o + .p");

    InvalidationLists invalidationLists;
    collectInvalidationSetsForClass(invalidationLists, "k");
    expectClassInvalidation("p", invalidationLists.descendants);
    expectNoInvalidation(invalidationLists.siblings);
}
TEST_F(RuleFeatureSetTest, interleavedDescendantSibling5)
{
    updateInvalidationSets(".l ~ .m + .n .o + .p");

    InvalidationLists invalidationLists;
    collectInvalidationSetsForClass(invalidationLists, "l");
    expectNoInvalidation(invalidationLists.descendants);
    expectSiblingDescendantInvalidation(UINT_MAX, "n", "p", invalidationLists.siblings);
}
TEST_F(RuleFeatureSetTest, interleavedDescendantSibling2)
{
    updateInvalidationSets(".o + .p");

    InvalidationLists invalidationLists;
    collectInvalidationSetsForClass(invalidationLists, "o");
    expectNoInvalidation(invalidationLists.descendants);
    expectSiblingInvalidation(1, "p", invalidationLists.siblings);
}
示例#12
0
void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData)
{
    updateInvalidationSets(ruleData);

    FeatureMetadata metadata;
    collectFeaturesFromSelector(ruleData.selector(), metadata);
    m_metadata.add(metadata);

    if (metadata.foundSiblingSelector)
        siblingRules.append(RuleFeature(ruleData.rule(), ruleData.selectorIndex(), ruleData.hasDocumentSecurityOrigin()));
    if (ruleData.containsUncommonAttributeSelector())
        uncommonAttributeRules.append(RuleFeature(ruleData.rule(), ruleData.selectorIndex(), ruleData.hasDocumentSecurityOrigin()));
}
示例#13
0
void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData)
{
    FeatureMetadata metadata;
    InvalidationSetMode mode = UseSubtreeStyleChange;
    if (m_targetedStyleRecalcEnabled)
        mode = updateInvalidationSets(ruleData.selector());

    collectFeaturesFromSelector(ruleData.selector(), metadata, mode);
    m_metadata.add(metadata);

    if (metadata.foundSiblingSelector)
        siblingRules.append(RuleFeature(ruleData.rule(), ruleData.selectorIndex(), ruleData.hasDocumentSecurityOrigin()));
    if (ruleData.containsUncommonAttributeSelector())
        uncommonAttributeRules.append(RuleFeature(ruleData.rule(), ruleData.selectorIndex(), ruleData.hasDocumentSecurityOrigin()));
}