OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/dom/StyleEngine.h" | 5 #include "core/dom/StyleEngine.h" |
6 | 6 |
7 #include "core/css/StyleSheetContents.h" | 7 #include "core/css/StyleSheetContents.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/dom/NodeComputedStyle.h" | 9 #include "core/dom/NodeComputedStyle.h" |
10 #include "core/dom/shadow/ShadowRootInit.h" | 10 #include "core/dom/shadow/ShadowRootInit.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 void StyleEngineTest::SetUp() { | 43 void StyleEngineTest::SetUp() { |
44 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); | 44 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); |
45 } | 45 } |
46 | 46 |
47 StyleEngineTest::RuleSetInvalidation | 47 StyleEngineTest::RuleSetInvalidation |
48 StyleEngineTest::scheduleInvalidationsForRules(TreeScope& treeScope, | 48 StyleEngineTest::scheduleInvalidationsForRules(TreeScope& treeScope, |
49 const String& cssText) { | 49 const String& cssText) { |
50 StyleSheetContents* sheet = | 50 StyleSheetContents* sheet = |
51 StyleSheetContents::create(CSSParserContext(HTMLStandardMode, nullptr)); | 51 StyleSheetContents::create(CSSParserContext(HTMLStandardMode, nullptr)); |
52 sheet->parseString(cssText); | 52 sheet->parseString(cssText); |
53 HeapVector<Member<RuleSet>> ruleSets; | 53 HeapHashSet<Member<RuleSet>> ruleSets; |
54 RuleSet& ruleSet = sheet->ensureRuleSet(MediaQueryEvaluator(), | 54 RuleSet& ruleSet = sheet->ensureRuleSet(MediaQueryEvaluator(), |
55 RuleHasDocumentSecurityOrigin); | 55 RuleHasDocumentSecurityOrigin); |
56 ruleSet.compactRulesIfNeeded(); | 56 ruleSet.compactRulesIfNeeded(); |
57 if (ruleSet.needsFullRecalcForRuleSetInvalidation()) | 57 if (ruleSet.needsFullRecalcForRuleSetInvalidation()) |
58 return RuleSetInvalidationFullRecalc; | 58 return RuleSetInvalidationFullRecalc; |
59 ruleSets.append(&ruleSet); | 59 ruleSets.add(&ruleSet); |
60 styleEngine().scheduleInvalidationsForRuleSets(treeScope, ruleSets); | 60 styleEngine().scheduleInvalidationsForRuleSets(treeScope, ruleSets); |
61 return RuleSetInvalidationsScheduled; | 61 return RuleSetInvalidationsScheduled; |
62 } | 62 } |
63 | 63 |
64 TEST_F(StyleEngineTest, DocumentDirtyAfterInject) { | 64 TEST_F(StyleEngineTest, DocumentDirtyAfterInject) { |
65 StyleSheetContents* parsedSheet = | 65 StyleSheetContents* parsedSheet = |
66 StyleSheetContents::create(CSSParserContext(document(), nullptr)); | 66 StyleSheetContents::create(CSSParserContext(document(), nullptr)); |
67 parsedSheet->parseString("div {}"); | 67 parsedSheet->parseString("div {}"); |
68 styleEngine().injectAuthorSheet(parsedSheet); | 68 styleEngine().injectAuthorSheet(parsedSheet); |
69 document().view()->updateAllLifecyclePhases(); | 69 document().view()->updateAllLifecyclePhases(); |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 unsigned afterCount = styleEngine().styleForElementCount(); | 368 unsigned afterCount = styleEngine().styleForElementCount(); |
369 // TODO(rune@opera.com): Should be 0 for ruleset based invalidations. | 369 // TODO(rune@opera.com): Should be 0 for ruleset based invalidations. |
370 EXPECT_EQ(8u, afterCount - beforeCount); | 370 EXPECT_EQ(8u, afterCount - beforeCount); |
371 | 371 |
372 ASSERT_TRUE(t1->computedStyle()); | 372 ASSERT_TRUE(t1->computedStyle()); |
373 EXPECT_EQ(makeRGB(0, 128, 0), | 373 EXPECT_EQ(makeRGB(0, 128, 0), |
374 t1->computedStyle()->visitedDependentColor(CSSPropertyColor)); | 374 t1->computedStyle()->visitedDependentColor(CSSPropertyColor)); |
375 } | 375 } |
376 | 376 |
377 } // namespace blink | 377 } // namespace blink |
OLD | NEW |