blob: 61d5dc8ddfe20f7b74c242acbb19488a8a6c24a4 [file] [log] [blame]
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/macros.h"
#include "third_party/blink/renderer/core/css/rule_feature_set.h"
namespace blink {
class Document;
class RuleSet;
// A per Document collection of CSS metadata used for style matching and
// invalidation. The data is aggregated from author rulesets from all TreeScopes
// in the whole Document as well as UA stylesheets and watched selectors which
// apply to elements in all TreeScopes.
// TODO( We would like to move as much of this data as
// possible to the ScopedStyleResolver as possible to avoid full reconstruction
// of these rulesets on shadow tree changes. See
class CSSGlobalRuleSet : public GarbageCollectedFinalized<CSSGlobalRuleSet> {
static CSSGlobalRuleSet* Create() {
return MakeGarbageCollected<CSSGlobalRuleSet>();
CSSGlobalRuleSet() = default;
void Dispose();
void InitWatchedSelectorsRuleSet(Document&);
void MarkDirty() { is_dirty_ = true; }
bool IsDirty() const { return is_dirty_; }
void Update(Document&);
const RuleFeatureSet& GetRuleFeatureSet() const {
return features_;
RuleSet* WatchedSelectorsRuleSet() const {
return watched_selectors_rule_set_;
bool HasFullscreenUAStyle() const { return has_fullscreen_ua_style_; }
void Trace(blink::Visitor*);
// Constructed from rules in all TreeScopes including UA style and style
// injected from extensions.
RuleFeatureSet features_;
// Rules injected from extensions.
Member<RuleSet> watched_selectors_rule_set_;
bool has_fullscreen_ua_style_ = false;
bool is_dirty_ = true;
} // namespace blink