chromium/third_party/blink/renderer/core/css/invalidation/rule_invalidation_data_visitor.cc

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/core/css/invalidation/rule_invalidation_data_visitor.h"

#include "third_party/blink/renderer/core/css/css_selector_list.h"
#include "third_party/blink/renderer/core/css/style_scope.h"
#include "third_party/blink/renderer/core/inspector/invalidation_set_to_selector_map.h"

namespace blink {

namespace {

bool SupportsInvalidation(CSSSelector::MatchType match) {}

bool SupportsInvalidation(CSSSelector::PseudoType type) {}

bool SupportsInvalidationWithSelectorList(CSSSelector::PseudoType pseudo) {}

bool RequiresSubtreeInvalidation(const CSSSelector& selector) {}

// Creates a copy of an InvalidationSet by combining an empty InvalidationSet
// (of the same type) with the specified InvalidationSet.
//
// See also InvalidationSet::Combine.
scoped_refptr<InvalidationSet> CopyInvalidationSet(
    const InvalidationSet& invalidation_set) {}

}  // anonymous namespace

template <RuleInvalidationDataVisitorType VisitorType>
RuleInvalidationDataVisitor<VisitorType>::RuleInvalidationDataVisitor(
    RuleInvalidationDataType& rule_invalidation_data)
    :{}

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::InvalidationSetFeatures::Merge(
    const InvalidationSetFeatures& other) {}

template <RuleInvalidationDataVisitorType VisitorType>
bool RuleInvalidationDataVisitor<
    VisitorType>::InvalidationSetFeatures::HasFeatures() const {}

template <RuleInvalidationDataVisitorType VisitorType>
bool RuleInvalidationDataVisitor<
    VisitorType>::InvalidationSetFeatures::HasIdClassOrAttribute() const {}

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::InvalidationSetFeatures::
    NarrowToFeatures(const InvalidationSetFeatures& other) {}

template <RuleInvalidationDataVisitorType VisitorType>
SelectorPreMatch
RuleInvalidationDataVisitor<VisitorType>::CollectFeaturesFromSelector(
    const CSSSelector& selector,
    const StyleScope* style_scope) {}

template <RuleInvalidationDataVisitorType VisitorType>
SelectorPreMatch
RuleInvalidationDataVisitor<VisitorType>::CollectMetadataFromSelector(
    const CSSSelector& selector,
    unsigned max_direct_adjacent_selectors,
    FeatureMetadata& metadata) {}

// Update all invalidation sets for a given selector (potentially in the
// given @scope). See UpdateInvalidationSetsForComplex() for details.
template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::UpdateInvalidationSets(
    const CSSSelector& selector,
    const StyleScope* style_scope) {}

// Update all invalidation sets for a given CSS selector; this is usually
// called for the entire selector at top level, but can also end up calling
// itself recursively if any of the selectors contain selector lists
// (e.g. for :not() or :has()).
template <RuleInvalidationDataVisitorType VisitorType>
RuleInvalidationDataVisitor<VisitorType>::FeatureInvalidationType
RuleInvalidationDataVisitor<VisitorType>::UpdateInvalidationSetsForComplex(
    const CSSSelector& complex,
    bool in_nth_child,
    const StyleScope* style_scope,
    InvalidationSetFeatures& features,
    PositionType position,
    CSSSelector::PseudoType pseudo_type) {}

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::UpdateFeaturesFromCombinator(
    CSSSelector::RelationType combinator,
    const CSSSelector* last_compound_in_adjacent_chain,
    InvalidationSetFeatures& last_compound_in_adjacent_chain_features,
    InvalidationSetFeatures*& sibling_features,
    InvalidationSetFeatures& descendant_features,
    bool for_logical_combination_in_has,
    bool in_nth_child) {}

// A rule like @scope (.a) { .b {} } needs features equivalent to
// :is (.a .b, .a.b), because the scope established by @scope *includes* the
// scoping root. This function provides .a.b, i.e. the second part of the :is().
// The first part is handled by `AddFeaturesToInvalidationSetsForStyleScope`.
template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::UpdateFeaturesFromStyleScope(
    const StyleScope& style_scope,
    InvalidationSetFeatures& descendant_features) {}

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::
    ExtractInvalidationSetFeaturesFromSimpleSelector(
        const CSSSelector& selector,
        InvalidationSetFeatures& features) {}

// Extract invalidation set features and return a pointer to the the last
// simple selector of the compound, or nullptr if one of the selectors
// RequiresSubtreeInvalidation().
//
// It also deals with inserting self-invalidation entries for the compound
// itself, so it is not a pure “extract“ despite the name.
template <RuleInvalidationDataVisitorType VisitorType>
const CSSSelector* RuleInvalidationDataVisitor<VisitorType>::
    ExtractInvalidationSetFeaturesFromCompound(
        const CSSSelector& compound,
        InvalidationSetFeatures& features,
        PositionType position,
        bool for_logical_combination_in_has,
        bool in_nth_child) {}

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::
    ExtractInvalidationSetFeaturesFromSelectorList(
        const CSSSelector& simple_selector,
        bool in_nth_child,
        InvalidationSetFeatures& features,
        PositionType position) {}

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::AddFeaturesToInvalidationSets(
    const CSSSelector& selector,
    bool in_nth_child,
    InvalidationSetFeatures* sibling_features,
    InvalidationSetFeatures& descendant_features) {}

template <RuleInvalidationDataVisitorType VisitorType>
const CSSSelector* RuleInvalidationDataVisitor<VisitorType>::
    AddFeaturesToInvalidationSetsForCompoundSelector(
        const CSSSelector& compound,
        bool in_nth_child,
        InvalidationSetFeatures* sibling_features,
        InvalidationSetFeatures& descendant_features) {}

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::
    AddFeaturesToInvalidationSetsForSimpleSelector(
        const CSSSelector& simple_selector,
        const CSSSelector& compound,
        bool in_nth_child,
        InvalidationSetFeatures* sibling_features,
        InvalidationSetFeatures& descendant_features) {}

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::
    AddFeaturesToInvalidationSetsForSelectorList(
        const CSSSelector& simple_selector,
        bool in_nth_child,
        InvalidationSetFeatures* sibling_features,
        InvalidationSetFeatures& descendant_features) {}

// See also UpdateFeaturesFromStyleScope.
template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::
    AddFeaturesToInvalidationSetsForStyleScope(
        const StyleScope& style_scope,
        InvalidationSetFeatures& descendant_features) {}

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::
    AddFeaturesToUniversalSiblingInvalidationSet(
        const InvalidationSetFeatures& sibling_features,
        const InvalidationSetFeatures& descendant_features) {}

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::
    AddValuesInComplexSelectorInsideIsWhereNot(
        const CSSSelector* selector_first) {}

template <RuleInvalidationDataVisitorType VisitorType>
bool RuleInvalidationDataVisitor<VisitorType>::
    AddValueOfSimpleSelectorInHasArgument(const CSSSelector& selector) {}

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::CollectValuesInHasArgument(
    const CSSSelector& has_pseudo_class) {}

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::
    AddFeaturesToInvalidationSetsForHasPseudoClass(
        const CSSSelector& pseudo_has,
        const CSSSelector* compound_containing_has,
        InvalidationSetFeatures* sibling_features,
        InvalidationSetFeatures& descendant_features,
        bool in_nth_child) {}

// Context for adding features for a compound selector in a logical combination
// inside :has(). This struct provides these information so that the features
// can be added correctly for the compound in logical combination.
// - needs_skip_adding_features:
//     - whether adding features needs to be skipped.
// - needs_update_features:
//     - whether updating features is needed.
// - last_compound_in_adjacent_chain:
//     - last compound in adjacent chain used for updating features.
// - use_indirect_adjacent_combinator_for_updating_features:
//     - whether we need to use adjacent combinator for updating features.
// Please check the comments in the constructor for more details.
template <RuleInvalidationDataVisitorType VisitorType>
struct RuleInvalidationDataVisitor<VisitorType>::
    AddFeaturesToInvalidationSetsForLogicalCombinationInHasContext {};

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::
    AddFeaturesToInvalidationSetsForLogicalCombinationInHas(
        const CSSSelector& logical_combination,
        const CSSSelector* compound_containing_has,
        InvalidationSetFeatures* sibling_features,
        InvalidationSetFeatures& descendant_features,
        CSSSelector::RelationType previous_combinator,
        AddFeaturesMethodForLogicalCombinationInHas add_features_method) {}

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::
    UpdateFeaturesFromCombinatorForLogicalCombinationInHas(
        CSSSelector::RelationType combinator,
        const CSSSelector* last_compound_in_adjacent_chain,
        InvalidationSetFeatures& last_compound_in_adjacent_chain_features,
        InvalidationSetFeatures*& sibling_features,
        InvalidationSetFeatures& descendant_features) {}

template <RuleInvalidationDataVisitorType VisitorType>
const CSSSelector* RuleInvalidationDataVisitor<VisitorType>::
    SkipAddingAndGetLastInCompoundForLogicalCombinationInHas(
        const CSSSelector* compound_in_logical_combination,
        const CSSSelector* compound_containing_has,
        InvalidationSetFeatures* sibling_features,
        InvalidationSetFeatures& descendant_features,
        CSSSelector::RelationType previous_combinator,
        AddFeaturesMethodForLogicalCombinationInHas add_features_method) {}

template <RuleInvalidationDataVisitorType VisitorType>
const CSSSelector* RuleInvalidationDataVisitor<VisitorType>::
    AddFeaturesAndGetLastInCompoundForLogicalCombinationInHas(
        const CSSSelector* compound_in_logical_combination,
        const CSSSelector* compound_containing_has,
        InvalidationSetFeatures* sibling_features,
        InvalidationSetFeatures& descendant_features,
        CSSSelector::RelationType previous_combinator,
        AddFeaturesMethodForLogicalCombinationInHas add_features_method) {}

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::
    MarkInvalidationSetsWithinNthChild(const CSSSelector& selector,
                                       bool in_nth_child) {}

template <RuleInvalidationDataVisitorType VisitorType>
RuleInvalidationDataVisitor<VisitorType>::InvalidationSetType*
RuleInvalidationDataVisitor<VisitorType>::InvalidationSetForSimpleSelector(
    const CSSSelector& selector,
    InvalidationType type,
    PositionType position,
    bool in_nth_child) {}

template <RuleInvalidationDataVisitorType VisitorType>
RuleInvalidationDataVisitor<VisitorType>::InvalidationSetType*
RuleInvalidationDataVisitor<VisitorType>::EnsureClassInvalidationSet(
    const AtomicString& class_name,
    InvalidationType type,
    PositionType position,
    bool in_nth_child) {}

template <RuleInvalidationDataVisitorType VisitorType>
RuleInvalidationDataVisitor<VisitorType>::InvalidationSetType*
RuleInvalidationDataVisitor<VisitorType>::EnsureAttributeInvalidationSet(
    const AtomicString& attribute_name,
    InvalidationType type,
    PositionType position,
    bool in_nth_child) {}

template <RuleInvalidationDataVisitorType VisitorType>
RuleInvalidationDataVisitor<VisitorType>::InvalidationSetType*
RuleInvalidationDataVisitor<VisitorType>::EnsureIdInvalidationSet(
    const AtomicString& id,
    InvalidationType type,
    PositionType position,
    bool in_nth_child) {}

template <RuleInvalidationDataVisitorType VisitorType>
RuleInvalidationDataVisitor<VisitorType>::InvalidationSetType*
RuleInvalidationDataVisitor<VisitorType>::EnsurePseudoInvalidationSet(
    CSSSelector::PseudoType pseudo_type,
    InvalidationType type,
    PositionType position,
    bool in_nth_child) {}

template <RuleInvalidationDataVisitorType VisitorType>
RuleInvalidationDataVisitor<VisitorType>::InvalidationSetType*
RuleInvalidationDataVisitor<VisitorType>::EnsureInvalidationSet(
    InvalidationSetMapType& map,
    const AtomicString& key,
    InvalidationType type,
    PositionType position,
    bool in_nth_child) {}

template <RuleInvalidationDataVisitorType VisitorType>
RuleInvalidationDataVisitor<VisitorType>::InvalidationSetType*
RuleInvalidationDataVisitor<VisitorType>::EnsureInvalidationSet(
    PseudoTypeInvalidationSetMapType& map,
    CSSSelector::PseudoType key,
    InvalidationType type,
    PositionType position,
    bool in_nth_child) {}

template <RuleInvalidationDataVisitorType VisitorType>
RuleInvalidationDataVisitor<VisitorType>::SiblingInvalidationSetType*
RuleInvalidationDataVisitor<
    VisitorType>::EnsureUniversalSiblingInvalidationSet() {}

template <RuleInvalidationDataVisitorType VisitorType>
RuleInvalidationDataVisitor<VisitorType>::SiblingInvalidationSetType*
RuleInvalidationDataVisitor<VisitorType>::EnsureNthInvalidationSet() {}

// Add features extracted from the rightmost compound selector to descendant
// invalidation sets for features found in other compound selectors.
//
// We use descendant invalidation for descendants, sibling invalidation for
// siblings and their subtrees.
//
// As we encounter a descendant type of combinator, the features only need to be
// checked against descendants in the same subtree only. features.adjacent is
// set to false, and we start adding features to the descendant invalidation
// set.
template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::AddFeaturesToInvalidationSet(
    InvalidationSetType* invalidation_set,
    const InvalidationSetFeatures& features) {}

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::SetWholeSubtreeInvalid(
    InvalidationSetType* invalidation_set) {}

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::SetInvalidatesSelf(
    InvalidationSetType* invalidation_set) {}

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::SetInvalidatesNth(
    InvalidationSetType* invalidation_set) {}

template <RuleInvalidationDataVisitorType VisitorType>
void RuleInvalidationDataVisitor<VisitorType>::UpdateMaxDirectAdjacentSelectors(
    SiblingInvalidationSetType* invalidation_set,
    unsigned value) {}

template <RuleInvalidationDataVisitorType VisitorType>
bool RuleInvalidationDataVisitor<VisitorType>::
    InsertIntoSelfInvalidationBloomFilter(const AtomicString& value, int salt) {}

template <RuleInvalidationDataVisitorType VisitorType>
RuleInvalidationDataVisitor<VisitorType>::InvalidationSetType*
RuleInvalidationDataVisitor<VisitorType>::
    EnsureSiblingDescendantInvalidationSet(
        SiblingInvalidationSetType* invalidation_set) {}

template <RuleInvalidationDataVisitorType VisitorType>
InvalidationSet&
RuleInvalidationDataVisitor<VisitorType>::EnsureMutableInvalidationSet(
    InvalidationType type,
    PositionType position,
    bool in_nth_child,
    scoped_refptr<InvalidationSet>& invalidation_set) {}

template class RuleInvalidationDataVisitor<
    RuleInvalidationDataVisitorType::kBuilder>;
template class RuleInvalidationDataVisitor<
    RuleInvalidationDataVisitorType::kTracer>;

}  // namespace blink