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/css/ActiveStyleSheets.h" | 5 #include "core/css/ActiveStyleSheets.h" |
6 | 6 |
7 #include "core/css/CSSStyleSheet.h" | 7 #include "core/css/CSSStyleSheet.h" |
8 #include "core/css/MediaQueryEvaluator.h" | 8 #include "core/css/MediaQueryEvaluator.h" |
9 #include "core/css/StyleSheetContents.h" | 9 #include "core/css/StyleSheetContents.h" |
10 #include "core/css/StyleSheetList.h" | 10 #include "core/css/StyleSheetList.h" |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 oldSheets.push_back(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); | 321 oldSheets.push_back(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); |
322 | 322 |
323 newSheets.push_back(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); | 323 newSheets.push_back(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); |
324 newSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); | 324 newSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); |
325 | 325 |
326 EXPECT_EQ(NoActiveSheetsChanged, | 326 EXPECT_EQ(NoActiveSheetsChanged, |
327 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); | 327 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); |
328 EXPECT_EQ(0u, changedRuleSets.size()); | 328 EXPECT_EQ(0u, changedRuleSets.size()); |
329 } | 329 } |
330 | 330 |
| 331 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_DisableAndAppend) { |
| 332 ActiveStyleSheetVector oldSheets; |
| 333 ActiveStyleSheetVector newSheets; |
| 334 HeapHashSet<Member<RuleSet>> changedRuleSets; |
| 335 |
| 336 CSSStyleSheet* sheet1 = createSheet(); |
| 337 CSSStyleSheet* sheet2 = createSheet(); |
| 338 |
| 339 oldSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); |
| 340 newSheets.push_back(std::make_pair(sheet1, nullptr)); |
| 341 newSheets.push_back(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); |
| 342 |
| 343 EXPECT_EQ(ActiveSheetsChanged, |
| 344 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); |
| 345 EXPECT_EQ(2u, changedRuleSets.size()); |
| 346 } |
| 347 |
331 TEST_F(ApplyRulesetsTest, AddUniversalRuleToDocument) { | 348 TEST_F(ApplyRulesetsTest, AddUniversalRuleToDocument) { |
332 document().view()->updateAllLifecyclePhases(); | 349 document().view()->updateAllLifecyclePhases(); |
333 | 350 |
334 CSSStyleSheet* sheet = createSheet("body * { color:red }"); | 351 CSSStyleSheet* sheet = createSheet("body * { color:red }"); |
335 | 352 |
336 ActiveStyleSheetVector newStyleSheets; | 353 ActiveStyleSheetVector newStyleSheets; |
337 newStyleSheets.push_back( | 354 newStyleSheets.push_back( |
338 std::make_pair(sheet, &sheet->contents()->ruleSet())); | 355 std::make_pair(sheet, &sheet->contents()->ruleSet())); |
339 | 356 |
340 styleEngine().applyRuleSetChanges(document(), ActiveStyleSheetVector(), | 357 styleEngine().applyRuleSetChanges(document(), ActiveStyleSheetVector(), |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 ActiveStyleSheetVector oldStyleSheets; | 477 ActiveStyleSheetVector oldStyleSheets; |
461 oldStyleSheets.push_back( | 478 oldStyleSheets.push_back( |
462 std::make_pair(cssSheet, &cssSheet->contents()->ruleSet())); | 479 std::make_pair(cssSheet, &cssSheet->contents()->ruleSet())); |
463 styleEngine().applyRuleSetChanges(shadowRoot, oldStyleSheets, | 480 styleEngine().applyRuleSetChanges(shadowRoot, oldStyleSheets, |
464 ActiveStyleSheetVector()); | 481 ActiveStyleSheetVector()); |
465 | 482 |
466 EXPECT_TRUE(styleEngine().treeBoundaryCrossingScopes().isEmpty()); | 483 EXPECT_TRUE(styleEngine().treeBoundaryCrossingScopes().isEmpty()); |
467 } | 484 } |
468 | 485 |
469 } // namespace blink | 486 } // namespace blink |
OLD | NEW |