Commit 1744e523 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Remove master references from style code.

The remaining references to master is from dom code apis and branch
names in documentation.

Change-Id: I7a1524ba2bcef3ecac612df6e513a701573e2a11
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2263533Reviewed-by: default avatarAnders Hartvoll Ruud <andruud@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781808}
parent aaf6089b
......@@ -48,7 +48,7 @@ DocumentStyleSheetCollection::DocumentStyleSheetCollection(
}
void DocumentStyleSheetCollection::CollectStyleSheetsFromCandidates(
StyleEngine& master_engine,
StyleEngine& engine,
DocumentStyleSheetCollector& collector) {
CHECK(ThreadState::Current()->IsOnThreadHeap(this));
for (Node* n : style_sheet_candidate_nodes_) {
......@@ -64,7 +64,7 @@ void DocumentStyleSheetCollection::CollectStyleSheetsFromCandidates(
continue;
collector.WillVisit(document);
document->GetStyleEngine().UpdateActiveStyleSheetsInImport(master_engine,
document->GetStyleEngine().UpdateActiveStyleSheetsInImport(engine,
collector);
continue;
}
......@@ -83,7 +83,7 @@ void DocumentStyleSheetCollection::CollectStyleSheetsFromCandidates(
CSSStyleSheet* css_sheet = To<CSSStyleSheet>(sheet);
collector.AppendActiveStyleSheet(
std::make_pair(css_sheet, master_engine.RuleSetForSheet(*css_sheet)));
std::make_pair(css_sheet, engine.RuleSetForSheet(*css_sheet)));
}
if (!GetTreeScope().HasAdoptedStyleSheets())
return;
......@@ -96,12 +96,12 @@ void DocumentStyleSheetCollection::CollectStyleSheetsFromCandidates(
DCHECK_EQ(GetDocument(), sheet->AssociatedDocument());
collector.AppendSheetForList(sheet);
collector.AppendActiveStyleSheet(
std::make_pair(sheet, master_engine.RuleSetForSheet(*sheet)));
std::make_pair(sheet, engine.RuleSetForSheet(*sheet)));
}
}
void DocumentStyleSheetCollection::CollectStyleSheets(
StyleEngine& master_engine,
StyleEngine& engine,
DocumentStyleSheetCollector& collector) {
for (auto& sheet :
GetDocument().GetStyleEngine().InjectedAuthorStyleSheets()) {
......@@ -109,7 +109,7 @@ void DocumentStyleSheetCollection::CollectStyleSheets(
sheet.second,
GetDocument().GetStyleEngine().RuleSetForSheet(*sheet.second)));
}
CollectStyleSheetsFromCandidates(master_engine, collector);
CollectStyleSheetsFromCandidates(engine, collector);
if (CSSStyleSheet* inspector_sheet =
GetDocument().GetStyleEngine().InspectorStyleSheet()) {
collector.AppendActiveStyleSheet(std::make_pair(
......@@ -119,11 +119,11 @@ void DocumentStyleSheetCollection::CollectStyleSheets(
}
void DocumentStyleSheetCollection::UpdateActiveStyleSheets(
StyleEngine& master_engine) {
StyleEngine& engine) {
// StyleSheetCollection is GarbageCollected<>, allocate it on the heap.
auto* collection = MakeGarbageCollected<StyleSheetCollection>();
ActiveDocumentStyleSheetCollector collector(*collection);
CollectStyleSheets(master_engine, collector);
CollectStyleSheets(engine, collector);
ApplyActiveStyleSheetChanges(*collection);
}
......
......@@ -45,9 +45,8 @@ class DocumentStyleSheetCollection final
public:
explicit DocumentStyleSheetCollection(TreeScope&);
void UpdateActiveStyleSheets(StyleEngine& master_engine);
void CollectStyleSheets(StyleEngine& master_engine,
DocumentStyleSheetCollector&);
void UpdateActiveStyleSheets(StyleEngine&);
void CollectStyleSheets(StyleEngine&, DocumentStyleSheetCollector&);
void CollectViewportRules(ViewportStyleResolver&);
void Trace(Visitor* visitor) const override {
......@@ -55,7 +54,7 @@ class DocumentStyleSheetCollection final
}
private:
void CollectStyleSheetsFromCandidates(StyleEngine& master_engine,
void CollectStyleSheetsFromCandidates(StyleEngine&,
DocumentStyleSheetCollector&);
DISALLOW_COPY_AND_ASSIGN(DocumentStyleSheetCollection);
};
......
......@@ -45,7 +45,7 @@ ShadowTreeStyleSheetCollection::ShadowTreeStyleSheetCollection(
: TreeScopeStyleSheetCollection(shadow_root) {}
void ShadowTreeStyleSheetCollection::CollectStyleSheets(
StyleEngine& master_engine,
StyleEngine& engine,
StyleSheetCollection& collection) {
for (Node* n : style_sheet_candidate_nodes_) {
StyleSheetCandidate candidate(*n);
......@@ -59,7 +59,7 @@ void ShadowTreeStyleSheetCollection::CollectStyleSheets(
if (candidate.CanBeActivated(g_null_atom)) {
CSSStyleSheet* css_sheet = To<CSSStyleSheet>(sheet);
collection.AppendActiveStyleSheet(
std::make_pair(css_sheet, master_engine.RuleSetForSheet(*css_sheet)));
std::make_pair(css_sheet, engine.RuleSetForSheet(*css_sheet)));
}
}
if (!GetTreeScope().HasAdoptedStyleSheets())
......@@ -70,15 +70,15 @@ void ShadowTreeStyleSheetCollection::CollectStyleSheets(
continue;
DCHECK_EQ(GetTreeScope().GetDocument(), sheet->AssociatedDocument());
collection.AppendActiveStyleSheet(
std::make_pair(sheet, master_engine.RuleSetForSheet(*sheet)));
std::make_pair(sheet, engine.RuleSetForSheet(*sheet)));
}
}
void ShadowTreeStyleSheetCollection::UpdateActiveStyleSheets(
StyleEngine& master_engine) {
StyleEngine& engine) {
// StyleSheetCollection is GarbageCollected<>, allocate it on the heap.
auto* collection = MakeGarbageCollected<StyleSheetCollection>();
CollectStyleSheets(master_engine, *collection);
CollectStyleSheets(engine, *collection);
ApplyActiveStyleSheetChanges(*collection);
}
......
......@@ -44,7 +44,7 @@ class ShadowTreeStyleSheetCollection final
: public TreeScopeStyleSheetCollection {
public:
explicit ShadowTreeStyleSheetCollection(ShadowRoot&);
void UpdateActiveStyleSheets(StyleEngine& master_engine);
void UpdateActiveStyleSheets(StyleEngine&);
bool IsShadowTreeStyleSheetCollection() const final { return true; }
void Trace(Visitor* visitor) const override {
......@@ -52,7 +52,7 @@ class ShadowTreeStyleSheetCollection final
}
private:
void CollectStyleSheets(StyleEngine& master_engine, StyleSheetCollection&);
void CollectStyleSheets(StyleEngine&, StyleSheetCollection&);
DISALLOW_COPY_AND_ASSIGN(ShadowTreeStyleSheetCollection);
};
......
......@@ -109,7 +109,7 @@ CSSFontSelector* CreateCSSFontSelectorFor(Document& document) {
StyleEngine::StyleEngine(Document& document)
: document_(&document),
is_master_(!document.IsHTMLImport()),
is_html_import_(document.IsHTMLImport()),
document_style_sheet_collection_(
MakeGarbageCollected<DocumentStyleSheetCollection>(document)) {
if (document.GetFrame()) {
......@@ -120,7 +120,7 @@ StyleEngine::StyleEngine(Document& document)
}
if (document.IsInMainFrame())
viewport_resolver_ = MakeGarbageCollected<ViewportStyleResolver>(document);
if (IsMaster())
if (!IsHTMLImport())
global_rule_set_ = MakeGarbageCollected<CSSGlobalRuleSet>();
if (auto* settings = GetDocument().GetSettings()) {
if (!settings->GetForceDarkModeEnabled())
......@@ -133,8 +133,8 @@ StyleEngine::StyleEngine(Document& document)
StyleEngine::~StyleEngine() = default;
inline Document* StyleEngine::Master() {
if (IsMaster())
inline Document* StyleEngine::HTMLImportRootDocument() {
if (!IsHTMLImport())
return document_;
HTMLImportsController* import = GetDocument().ImportsController();
// Document::ImportsController() can return null while executing its
......@@ -173,10 +173,10 @@ TreeScopeStyleSheetCollection* StyleEngine::StyleSheetCollectionFor(
const HeapVector<Member<StyleSheet>>& StyleEngine::StyleSheetsForStyleSheetList(
TreeScope& tree_scope) {
DCHECK(Master());
DCHECK(HTMLImportRootDocument());
TreeScopeStyleSheetCollection& collection =
EnsureStyleSheetCollectionFor(tree_scope);
if (Master()->IsActive())
if (HTMLImportRootDocument()->IsActive())
collection.UpdateStyleSheetList();
return collection.StyleSheetsForStyleSheetList();
}
......@@ -277,7 +277,7 @@ void StyleEngine::RemovePendingSheet(Node& style_sheet_candidate_node,
void StyleEngine::SetNeedsActiveStyleUpdate(TreeScope& tree_scope) {
DCHECK(tree_scope.RootNode().isConnected());
if (GetDocument().IsActive() || !IsMaster())
if (GetDocument().IsActive() || IsHTMLImport())
MarkTreeScopeDirty(tree_scope);
}
......@@ -432,7 +432,7 @@ void StyleEngine::MediaQueriesChangedInScope(TreeScope& tree_scope) {
}
void StyleEngine::WatchedSelectorsChanged() {
DCHECK(IsMaster());
DCHECK(!IsHTMLImport());
DCHECK(global_rule_set_);
global_rule_set_->InitWatchedSelectorsRuleSet(GetDocument());
// TODO(futhark@chromium.org): Should be able to use RuleSetInvalidation here.
......@@ -504,15 +504,15 @@ void StyleEngine::MediaQueryAffectingValueChanged(MediaValueChange change) {
}
void StyleEngine::UpdateActiveStyleSheetsInImport(
StyleEngine& master_engine,
StyleEngine& root_engine,
DocumentStyleSheetCollector& parent_collector) {
DCHECK(RuntimeEnabledFeatures::HTMLImportsEnabled(
GetDocument().GetExecutionContext()));
DCHECK(!IsMaster());
DCHECK(IsHTMLImport());
HeapVector<Member<StyleSheet>> sheets_for_list;
ImportedDocumentStyleSheetCollector subcollector(parent_collector,
sheets_for_list);
GetDocumentStyleSheetCollection().CollectStyleSheets(master_engine,
GetDocumentStyleSheetCollection().CollectStyleSheets(root_engine,
subcollector);
GetDocumentStyleSheetCollection().SwapSheetsForSheetList(sheets_for_list);
......@@ -554,7 +554,7 @@ void StyleEngine::UpdateActiveStyleSheets() {
if (!NeedsActiveStyleSheetUpdate())
return;
DCHECK(IsMaster());
DCHECK(!IsHTMLImport());
DCHECK(!GetDocument().InStyleRecalc());
DCHECK(GetDocument().IsActive());
......@@ -686,7 +686,7 @@ void StyleEngine::CreateResolver() {
void StyleEngine::ClearResolvers() {
DCHECK(!GetDocument().InStyleRecalc());
DCHECK(IsMaster() || !resolver_);
DCHECK(!IsHTMLImport() || !resolver_);
GetDocument().ClearScopedStyleResolver();
for (TreeScope* tree_scope : active_tree_scopes_)
......@@ -1381,7 +1381,7 @@ void StyleEngine::SetHttpDefaultStyle(const String& content) {
}
void StyleEngine::EnsureUAStyleForXrOverlay() {
DCHECK(IsMaster());
DCHECK(!IsHTMLImport());
DCHECK(global_rule_set_);
if (CSSDefaultStyleSheets::Instance().EnsureDefaultStyleSheetForXrOverlay()) {
global_rule_set_->MarkDirty();
......@@ -1390,7 +1390,7 @@ void StyleEngine::EnsureUAStyleForXrOverlay() {
}
void StyleEngine::EnsureUAStyleForFullscreen() {
DCHECK(IsMaster());
DCHECK(!IsHTMLImport());
DCHECK(global_rule_set_);
if (global_rule_set_->HasFullscreenUAStyle())
return;
......@@ -1400,7 +1400,7 @@ void StyleEngine::EnsureUAStyleForFullscreen() {
}
void StyleEngine::EnsureUAStyleForElement(const Element& element) {
DCHECK(IsMaster());
DCHECK(!IsHTMLImport());
DCHECK(global_rule_set_);
if (CSSDefaultStyleSheets::Instance().EnsureDefaultStyleSheetsForElement(
element)) {
......@@ -1410,7 +1410,7 @@ void StyleEngine::EnsureUAStyleForElement(const Element& element) {
}
void StyleEngine::EnsureUAStyleForPseudoElement(PseudoId pseudo_id) {
DCHECK(IsMaster());
DCHECK(!IsHTMLImport());
DCHECK(global_rule_set_);
if (CSSDefaultStyleSheets::Instance()
.EnsureDefaultStyleSheetsForPseudoElement(pseudo_id)) {
......@@ -1420,7 +1420,7 @@ void StyleEngine::EnsureUAStyleForPseudoElement(PseudoId pseudo_id) {
}
bool StyleEngine::HasRulesForId(const AtomicString& id) const {
DCHECK(IsMaster());
DCHECK(!IsHTMLImport());
DCHECK(global_rule_set_);
return global_rule_set_->GetRuleFeatureSet().HasSelectorForId(id);
}
......@@ -1546,7 +1546,7 @@ void StyleEngine::InvalidateInitialData() {
void StyleEngine::ApplyUserRuleSetChanges(
const ActiveStyleSheetVector& old_style_sheets,
const ActiveStyleSheetVector& new_style_sheets) {
DCHECK(IsMaster());
DCHECK(!IsHTMLImport());
DCHECK(global_rule_set_);
HeapHashSet<Member<RuleSet>> changed_rule_sets;
......@@ -1613,7 +1613,7 @@ void StyleEngine::ApplyRuleSetChanges(
TreeScope& tree_scope,
const ActiveStyleSheetVector& old_style_sheets,
const ActiveStyleSheetVector& new_style_sheets) {
DCHECK(IsMaster());
DCHECK(!IsHTMLImport());
DCHECK(global_rule_set_);
HeapHashSet<Member<RuleSet>> changed_rule_sets;
......@@ -1736,7 +1736,7 @@ const MediaQueryEvaluator& StyleEngine::EnsureMediaQueryEvaluator() {
}
bool StyleEngine::MediaQueryAffectedByViewportChange() {
DCHECK(IsMaster());
DCHECK(!IsHTMLImport());
DCHECK(global_rule_set_);
return EnsureMediaQueryEvaluator().DidResultsChange(
global_rule_set_->GetRuleFeatureSet()
......@@ -1744,7 +1744,7 @@ bool StyleEngine::MediaQueryAffectedByViewportChange() {
}
bool StyleEngine::MediaQueryAffectedByDeviceChange() {
DCHECK(IsMaster());
DCHECK(!IsHTMLImport());
DCHECK(global_rule_set_);
return EnsureMediaQueryEvaluator().DidResultsChange(
global_rule_set_->GetRuleFeatureSet().DeviceDependentMediaQueryResults());
......@@ -2054,7 +2054,7 @@ void StyleEngine::ViewportDefiningElementDidChange() {
void StyleEngine::UpdateStyleInvalidationRoot(ContainerNode* ancestor,
Node* dirty_node) {
DCHECK(IsMaster());
DCHECK(!IsHTMLImport());
if (GetDocument().IsActive()) {
if (in_dom_removal_) {
ancestor = nullptr;
......
......@@ -147,7 +147,7 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
WebDocument::kAuthorOrigin);
CSSStyleSheet& EnsureInspectorStyleSheet();
RuleSet* WatchedSelectorsRuleSet() {
DCHECK(IsMaster());
DCHECK(!IsHTMLImport());
DCHECK(global_rule_set_);
return global_rule_set_->WatchedSelectorsRuleSet();
}
......@@ -158,7 +158,7 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
RuleSet* RuleSetForSheet(CSSStyleSheet&);
void MediaQueryAffectingValueChanged(MediaValueChange change);
void UpdateActiveStyleSheetsInImport(
StyleEngine& master_engine,
StyleEngine& root_engine,
DocumentStyleSheetCollector& parent_collector);
void UpdateActiveStyle();
......@@ -231,7 +231,7 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
bool MediaQueryAffectedByViewportChange();
bool MediaQueryAffectedByDeviceChange();
bool HasViewportDependentMediaQueries() {
DCHECK(IsMaster());
DCHECK(!IsHTMLImport());
DCHECK(global_rule_set_);
UpdateActiveStyle();
return !global_rule_set_->GetRuleFeatureSet()
......@@ -410,8 +410,8 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
void MarkTreeScopeDirty(TreeScope&);
void MarkUserStyleDirty();
bool IsMaster() const { return is_master_; }
Document* Master();
bool IsHTMLImport() const { return is_html_import_; }
Document* HTMLImportRootDocument();
Document& GetDocument() const { return *document_; }
typedef HeapHashSet<Member<TreeScope>> UnorderedTreeScopeSet;
......@@ -425,7 +425,7 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
MediaValueChange);
const RuleFeatureSet& GetRuleFeatureSet() const {
DCHECK(IsMaster());
DCHECK(!IsHTMLImport());
DCHECK(global_rule_set_);
return global_rule_set_->GetRuleFeatureSet();
}
......@@ -501,7 +501,9 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
void PropagateWritingModeAndDirectionToHTMLRoot();
Member<Document> document_;
bool is_master_;
// True if this StyleEngine is for an HTML Import document.
bool is_html_import_ = false;
// Tracks the number of currently loading top-level stylesheets. Sheets loaded
// using the @import directive are not included in this count. We use this
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment