Commit 678e108d authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

[@property] Avoid crash with non-matching 'media' attribute

The RuleSet of an ActiveStyleSheet can be nullptr for non-matching
media (see StyleEngine::RuleSetForSheet), hence we can't DCHECK that
it exists.

Bug: 1085994
Change-Id: Iac7f746045f46ad7752b30cccce8b6f403cf19b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2214537Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771897}
parent fe7e8baa
...@@ -1642,10 +1642,9 @@ void StyleEngine::ApplyRuleSetChanges( ...@@ -1642,10 +1642,9 @@ void StyleEngine::ApplyRuleSetChanges(
if (tree_scope.RootNode().IsDocumentNode()) { if (tree_scope.RootNode().IsDocumentNode()) {
PropertyRegistration::RemoveDeclaredProperties(GetDocument()); PropertyRegistration::RemoveDeclaredProperties(GetDocument());
for (auto* it = new_style_sheets.begin(); it != new_style_sheets.end(); for (const ActiveStyleSheet& active_sheet : new_style_sheets) {
it++) { if (RuleSet* rule_set = active_sheet.second)
DCHECK(it->second); AddPropertyRules(*rule_set);
AddPropertyRules(*it->second);
} }
} }
} }
......
<!DOCTYPE html>
<html class="test-wait">
<link rel="help" href="https://crbug.com/1085994">
<style id="style">
@property --x {
syntax: "<length>";
inherits: false;
initial-value: 0px;
}
</style>
<script>
document.documentElement.offsetTop;
style.setAttribute('media', 'braille');
document.documentElement.className = '';
</script>
<p>
PASS if no crash
</p>
</html>
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