Commit 89540506 authored by Rakina Zata Amni's avatar Rakina Zata Amni Committed by Commit Bot

Only handle CE default styles that have rule sets

Some CE default styles might not have RuleSets, this CL adds some
null checks.

Bug: 895512

Change-Id: I02e0f5070c36c72e8d03ed950d96783506f05c5a
Reviewed-on: https://chromium-review.googlesource.com/c/1343585
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609990}
parent 411e114c
...@@ -215,8 +215,12 @@ static void MatchCustomElementRules(const Element& element, ...@@ -215,8 +215,12 @@ static void MatchCustomElementRules(const Element& element,
element.GetCustomElementDefinition()) { element.GetCustomElementDefinition()) {
if (definition->HasDefaultStyleSheets()) { if (definition->HasDefaultStyleSheets()) {
for (CSSStyleSheet* style : definition->DefaultStyleSheets()) { for (CSSStyleSheet* style : definition->DefaultStyleSheets()) {
collector.CollectMatchingRules(MatchRequest( if (!style)
element.GetDocument().GetStyleEngine().RuleSetForSheet(*style))); continue;
RuleSet* rule_set =
element.GetDocument().GetStyleEngine().RuleSetForSheet(*style);
if (rule_set)
collector.CollectMatchingRules(MatchRequest(rule_set));
} }
} }
} }
...@@ -448,7 +452,6 @@ void StyleResolver::MatchAuthorRules(const Element& element, ...@@ -448,7 +452,6 @@ void StyleResolver::MatchAuthorRules(const Element& element,
MatchAuthorRulesV0(element, collector); MatchAuthorRulesV0(element, collector);
return; return;
} }
MatchHostAndCustomElementRules(element, collector); MatchHostAndCustomElementRules(element, collector);
ScopedStyleResolver* element_scope_resolver = ScopedResolverFor(element); ScopedStyleResolver* element_scope_resolver = ScopedResolverFor(element);
......
...@@ -272,8 +272,10 @@ class CORE_EXPORT StyleEngine final ...@@ -272,8 +272,10 @@ class CORE_EXPORT StyleEngine final
CollectUserStyleFeaturesTo(features); CollectUserStyleFeaturesTo(features);
CollectScopedStyleFeaturesTo(features); CollectScopedStyleFeaturesTo(features);
for (CSSStyleSheet* sheet : custom_element_default_style_sheets_) { for (CSSStyleSheet* sheet : custom_element_default_style_sheets_) {
if (sheet) if (!sheet)
features.Add(RuleSetForSheet(*sheet)->Features()); continue;
if (RuleSet* rule_set = RuleSetForSheet(*sheet))
features.Add(rule_set->Features());
} }
} }
......
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