| 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/css/parser/CSSParserContext.h" | 8 #include "core/css/parser/CSSParserContext.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/dom/NodeComputedStyle.h" | 10 #include "core/dom/NodeComputedStyle.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 const String& cssText) { | 50 const String& cssText) { |
| 51 StyleSheetContents* sheet = | 51 StyleSheetContents* sheet = |
| 52 StyleSheetContents::create(CSSParserContext::create(HTMLStandardMode)); | 52 StyleSheetContents::create(CSSParserContext::create(HTMLStandardMode)); |
| 53 sheet->parseString(cssText); | 53 sheet->parseString(cssText); |
| 54 HeapHashSet<Member<RuleSet>> ruleSets; | 54 HeapHashSet<Member<RuleSet>> ruleSets; |
| 55 RuleSet& ruleSet = sheet->ensureRuleSet(MediaQueryEvaluator(), | 55 RuleSet& ruleSet = sheet->ensureRuleSet(MediaQueryEvaluator(), |
| 56 RuleHasDocumentSecurityOrigin); | 56 RuleHasDocumentSecurityOrigin); |
| 57 ruleSet.compactRulesIfNeeded(); | 57 ruleSet.compactRulesIfNeeded(); |
| 58 if (ruleSet.needsFullRecalcForRuleSetInvalidation()) | 58 if (ruleSet.needsFullRecalcForRuleSetInvalidation()) |
| 59 return RuleSetInvalidationFullRecalc; | 59 return RuleSetInvalidationFullRecalc; |
| 60 ruleSets.add(&ruleSet); | 60 ruleSets.insert(&ruleSet); |
| 61 styleEngine().scheduleInvalidationsForRuleSets(treeScope, ruleSets); | 61 styleEngine().scheduleInvalidationsForRuleSets(treeScope, ruleSets); |
| 62 return RuleSetInvalidationsScheduled; | 62 return RuleSetInvalidationsScheduled; |
| 63 } | 63 } |
| 64 | 64 |
| 65 TEST_F(StyleEngineTest, DocumentDirtyAfterInject) { | 65 TEST_F(StyleEngineTest, DocumentDirtyAfterInject) { |
| 66 StyleSheetContents* parsedSheet = | 66 StyleSheetContents* parsedSheet = |
| 67 StyleSheetContents::create(CSSParserContext::create(document())); | 67 StyleSheetContents::create(CSSParserContext::create(document())); |
| 68 parsedSheet->parseString("div {}"); | 68 parsedSheet->parseString("div {}"); |
| 69 styleEngine().injectAuthorSheet(parsedSheet); | 69 styleEngine().injectAuthorSheet(parsedSheet); |
| 70 document().view()->updateAllLifecyclePhases(); | 70 document().view()->updateAllLifecyclePhases(); |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 | 367 |
| 368 unsigned afterCount = styleEngine().styleForElementCount(); | 368 unsigned afterCount = styleEngine().styleForElementCount(); |
| 369 EXPECT_EQ(0u, afterCount - beforeCount); | 369 EXPECT_EQ(0u, afterCount - beforeCount); |
| 370 | 370 |
| 371 ASSERT_TRUE(t1->computedStyle()); | 371 ASSERT_TRUE(t1->computedStyle()); |
| 372 EXPECT_EQ(makeRGB(0, 128, 0), | 372 EXPECT_EQ(makeRGB(0, 128, 0), |
| 373 t1->computedStyle()->visitedDependentColor(CSSPropertyColor)); | 373 t1->computedStyle()->visitedDependentColor(CSSPropertyColor)); |
| 374 } | 374 } |
| 375 | 375 |
| 376 } // namespace blink | 376 } // namespace blink |
| OLD | NEW |