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

Delete default constructor for MediaQueryEvaluator.

It always returns true for every media query. Make sure it's not used
by accident. The LocalFrame was available for all uses of it in tests.

Change-Id: If99c0ac3251c0cbf775d39e292758d7c246d410a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2230481Reviewed-by: default avatarAnders Hartvoll Ruud <andruud@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775046}
parent 1027c702
...@@ -24,12 +24,12 @@ namespace blink { ...@@ -24,12 +24,12 @@ namespace blink {
class ActiveStyleSheetsTest : public PageTestBase { class ActiveStyleSheetsTest : public PageTestBase {
protected: protected:
static CSSStyleSheet* CreateSheet(const String& css_text = String()) { CSSStyleSheet* CreateSheet(const String& css_text = String()) {
auto* contents = MakeGarbageCollected<StyleSheetContents>( auto* contents = MakeGarbageCollected<StyleSheetContents>(
MakeGarbageCollected<CSSParserContext>( MakeGarbageCollected<CSSParserContext>(
kHTMLStandardMode, SecureContextMode::kInsecureContext)); kHTMLStandardMode, SecureContextMode::kInsecureContext));
contents->ParseString(css_text); contents->ParseString(css_text);
contents->EnsureRuleSet(MediaQueryEvaluator(), contents->EnsureRuleSet(MediaQueryEvaluator(GetDocument().GetFrame()),
kRuleHasDocumentSecurityOrigin); kRuleHasDocumentSecurityOrigin);
return MakeGarbageCollected<CSSStyleSheet>(contents); return MakeGarbageCollected<CSSStyleSheet>(contents);
} }
...@@ -123,8 +123,9 @@ TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_Mutated) { ...@@ -123,8 +123,9 @@ TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_Mutated) {
std::make_pair(sheet3, &sheet3->Contents()->GetRuleSet())); std::make_pair(sheet3, &sheet3->Contents()->GetRuleSet()));
sheet2->Contents()->ClearRuleSet(); sheet2->Contents()->ClearRuleSet();
sheet2->Contents()->EnsureRuleSet(MediaQueryEvaluator(), sheet2->Contents()->EnsureRuleSet(
kRuleHasDocumentSecurityOrigin); MediaQueryEvaluator(GetDocument().GetFrame()),
kRuleHasDocumentSecurityOrigin);
EXPECT_NE(old_sheets[1].second, &sheet2->Contents()->GetRuleSet()); EXPECT_NE(old_sheets[1].second, &sheet2->Contents()->GetRuleSet());
...@@ -404,7 +405,7 @@ TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_AddRemoveNonMatchingMQ) { ...@@ -404,7 +405,7 @@ TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_AddRemoveNonMatchingMQ) {
scoped_refptr<MediaQuerySet> mq = scoped_refptr<MediaQuerySet> mq =
MediaQueryParser::ParseMediaQuerySet("(min-width: 9000px)", nullptr); MediaQueryParser::ParseMediaQuerySet("(min-width: 9000px)", nullptr);
sheet1->SetMediaQueries(mq); sheet1->SetMediaQueries(mq);
sheet1->MatchesMediaQueries(MediaQueryEvaluator()); sheet1->MatchesMediaQueries(MediaQueryEvaluator(GetDocument().GetFrame()));
new_sheets.push_back(std::make_pair(sheet1, nullptr)); new_sheets.push_back(std::make_pair(sheet1, nullptr));
......
...@@ -49,7 +49,7 @@ CSSRuleList* TestStyleSheet::CssRules() { ...@@ -49,7 +49,7 @@ CSSRuleList* TestStyleSheet::CssRules() {
RuleSet& TestStyleSheet::GetRuleSet() { RuleSet& TestStyleSheet::GetRuleSet() {
RuleSet& rule_set = style_sheet_->Contents()->EnsureRuleSet( RuleSet& rule_set = style_sheet_->Contents()->EnsureRuleSet(
MediaQueryEvaluator(), kRuleHasNoSpecialState); MediaQueryEvaluator(document_->GetFrame()), kRuleHasNoSpecialState);
rule_set.CompactRulesIfNeeded(); rule_set.CompactRulesIfNeeded();
return rule_set; return rule_set;
} }
......
...@@ -60,8 +60,7 @@ class CORE_EXPORT MediaQueryEvaluator final ...@@ -60,8 +60,7 @@ class CORE_EXPORT MediaQueryEvaluator final
public: public:
static void Init(); static void Init();
// Creates evaluator which evaluates to true for all media queries. MediaQueryEvaluator() = delete;
MediaQueryEvaluator() = default;
// Creates evaluator which evaluates only simple media queries // Creates evaluator which evaluates only simple media queries
// Evaluator returns true for acceptedMediaType and returns true for any media // Evaluator returns true for acceptedMediaType and returns true for any media
......
...@@ -285,8 +285,8 @@ class StyleCascadeTest : public PageTestBase, ...@@ -285,8 +285,8 @@ class StyleCascadeTest : public PageTestBase,
CSSStyleSheet* sheet = CSSStyleSheet* sheet =
CSSStyleSheet::Create(GetDocument(), init, exception_state); CSSStyleSheet::Create(GetDocument(), init, exception_state);
sheet->replaceSync(css_text, exception_state); sheet->replaceSync(css_text, exception_state);
sheet->Contents()->EnsureRuleSet(MediaQueryEvaluator(), sheet->Contents()->EnsureRuleSet(
kRuleHasNoSpecialState); MediaQueryEvaluator(GetDocument().GetFrame()), kRuleHasNoSpecialState);
return sheet; return sheet;
} }
......
...@@ -88,8 +88,9 @@ StyleEngineTest::ScheduleInvalidationsForRules(TreeScope& tree_scope, ...@@ -88,8 +88,9 @@ StyleEngineTest::ScheduleInvalidationsForRules(TreeScope& tree_scope,
kHTMLStandardMode, SecureContextMode::kInsecureContext)); kHTMLStandardMode, SecureContextMode::kInsecureContext));
sheet->ParseString(css_text); sheet->ParseString(css_text);
HeapHashSet<Member<RuleSet>> rule_sets; HeapHashSet<Member<RuleSet>> rule_sets;
RuleSet& rule_set = sheet->EnsureRuleSet(MediaQueryEvaluator(), RuleSet& rule_set =
kRuleHasDocumentSecurityOrigin); sheet->EnsureRuleSet(MediaQueryEvaluator(GetDocument().GetFrame()),
kRuleHasDocumentSecurityOrigin);
rule_set.CompactRulesIfNeeded(); rule_set.CompactRulesIfNeeded();
if (rule_set.NeedsFullRecalcForRuleSetInvalidation()) if (rule_set.NeedsFullRecalcForRuleSetInvalidation())
return kRuleSetInvalidationFullRecalc; return kRuleSetInvalidationFullRecalc;
......
...@@ -151,7 +151,8 @@ TEST_F(CSSStyleSheetResourceTest, ...@@ -151,7 +151,8 @@ TEST_F(CSSStyleSheetResourceTest,
contents->CheckLoaded(); contents->CheckLoaded();
EXPECT_TRUE(contents->IsCacheableForResource()); EXPECT_TRUE(contents->IsCacheableForResource());
contents->EnsureRuleSet(MediaQueryEvaluator(), kRuleHasNoSpecialState); contents->EnsureRuleSet(MediaQueryEvaluator(GetDocument().GetFrame()),
kRuleHasNoSpecialState);
EXPECT_TRUE(contents->HasRuleSet()); EXPECT_TRUE(contents->HasRuleSet());
css_resource->SaveParsedStyleSheet(contents); css_resource->SaveParsedStyleSheet(contents);
......
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