chromium/third_party/blink/renderer/core/inspector/invalidation_set_to_selector_map.h

// 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.

#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_INSPECTOR_INVALIDATION_SET_TO_SELECTOR_MAP_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_INSPECTOR_INVALIDATION_SET_TO_SELECTOR_MAP_H_

#include "third_party/blink/renderer/core/css/style_rule.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_map.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_set.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"

namespace blink {

class InvalidationSet;
class StyleEngine;
class StyleRule;

// Implements a back-mapping from InvalidationSet entries to the selectors that
// placed them there, for use in diagnostic traces.
// Only active while the appropriate tracing configuration is enabled.
class CORE_EXPORT InvalidationSetToSelectorMap final
    : public GarbageCollected<InvalidationSetToSelectorMap> {};

}  // namespace blink

namespace WTF {

// These two HashTraits specializations are needed so that
// HeapHashSet<Member<IndexedSelector>> will do value-wise comparisons instead
// of pointer-wise comparisons.
template <>
struct HashTraits<blink::InvalidationSetToSelectorMap::IndexedSelector>
    : TwoFieldsHashTraits<
          blink::InvalidationSetToSelectorMap::IndexedSelector,
          &blink::InvalidationSetToSelectorMap::IndexedSelector::style_rule_,
          &blink::InvalidationSetToSelectorMap::IndexedSelector::
              selector_index_> {};

template <>
struct HashTraits<
    blink::Member<blink::InvalidationSetToSelectorMap::IndexedSelector>>
    : MemberHashTraits<blink::InvalidationSetToSelectorMap::IndexedSelector> {};

}  // namespace WTF

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_INSPECTOR_INVALIDATION_SET_TO_SELECTOR_MAP_H_