Commit a46b62e9 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Create an empty StyleSheetList for moreStyleSheets.

We created a StyleSheetList connected to the TreeScope which would
create a second StyleSheetList for the scope-attached sheets which
messed up the active stylesheets causing crashes.

Bug: 819483
Change-Id: Ib24bee538a27a64b5a8206e32334d4324629d5af
Reviewed-on: https://chromium-review.googlesource.com/964326
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarRakina Zata Amni <rakina@chromium.org>
Reviewed-by: default avatarTakayoshi Kochi <kochi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543654}
parent aa2bc556
......@@ -2,6 +2,7 @@
<!-- TODO(rakina): move to WPT once spec is finalized -->
<script src = '../../resources/testharness.js'></script>
<script src = '../../resources/testharnessreport.js'></script>
<style>dummy {}</style>
<section id="firstSection">
<div>
......@@ -38,6 +39,10 @@ const blueShadowSpan = secondDiv.children[2];
const whiteShadowSpan = secondDiv.children[3];
const yellowShadowSpan = secondDiv.children[4];
test(() => {
assert_equals(document.moreStyleSheets.length, 0);
}, "document.moreStyleSheets should initially have length 0.");
test(() => {
// Style sheets can be created
const greenStyleSheet = new CSSStyleSheet(greenStyleText);
......@@ -283,4 +288,3 @@ test(() => {
assert_equals(getComputedStyle(yellowIframeSpan).color, "rgb(0, 0, 0)");
}, 'Constructed stylesheet can be used and modified in multiple Documents');
</script>
......@@ -31,6 +31,11 @@ namespace blink {
using namespace HTMLNames;
StyleSheetList* StyleSheetList::Create() {
DCHECK(RuntimeEnabledFeatures::ConstructableStylesheetsEnabled());
return new StyleSheetList();
}
StyleSheetList* StyleSheetList::Create(
const HeapVector<Member<CSSStyleSheet>>& style_sheet_vector,
ExceptionState& exception_state) {
......@@ -38,7 +43,6 @@ StyleSheetList* StyleSheetList::Create(
exception_state.ThrowTypeError("Illegal constructor");
return nullptr;
}
return new StyleSheetList(style_sheet_vector);
}
......
......@@ -37,6 +37,7 @@ class CORE_EXPORT StyleSheetList final : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
static StyleSheetList* Create();
static StyleSheetList* Create(const HeapVector<Member<CSSStyleSheet>>&,
ExceptionState&);
......@@ -60,6 +61,7 @@ class CORE_EXPORT StyleSheetList final : public ScriptWrappable {
private:
explicit StyleSheetList(const HeapVector<Member<CSSStyleSheet>>&);
explicit StyleSheetList(TreeScope*);
StyleSheetList() {}
const HeapVector<TraceWrapperMember<StyleSheet>>& StyleSheets() const;
Member<TreeScope> tree_scope_;
......
......@@ -327,7 +327,7 @@ bool TreeScope::HasMoreStyleSheets() const {
StyleSheetList& TreeScope::MoreStyleSheets() {
if (!more_style_sheets_)
SetMoreStyleSheets(StyleSheetList::Create(this));
SetMoreStyleSheets(StyleSheetList::Create());
return *more_style_sheets_;
}
......
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