chromium/third_party/blink/renderer/core/css/style_scope_data.h

// Copyright 2023 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_CSS_STYLE_SCOPE_DATA_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_STYLE_SCOPE_DATA_H_

#include <optional>

#include "third_party/blink/renderer/core/dom/element_rare_data_field.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/member.h"

namespace blink {

class StyleScope;

// Implicit @scope rules are scoped to the parent element of the owner node of
// the stylesheet that defined the @scope rule. Each such parent element holds
// a StyleScopeData instance, with references back to the StyleScopes that
// are "triggered" by that element.
//
// This can be used to quickly determine if a given StyleScope is triggered
// by an Element (a check that would otherwise potentially be expensive, due
// to a single StyleSheetContents/StyleScope being shared by multiple
// CSSStyleSheets).
class StyleScopeData final : public GarbageCollected<StyleScopeData>,
                             public ElementRareDataField {};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_STYLE_SCOPE_DATA_H_