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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 | 295 |
296 newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); | 296 newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); |
297 newSheets.append(std::make_pair(sheet3, &sheet3->contents()->ruleSet())); | 297 newSheets.append(std::make_pair(sheet3, &sheet3->contents()->ruleSet())); |
298 | 298 |
299 EXPECT_EQ(ActiveSheetsChanged, | 299 EXPECT_EQ(ActiveSheetsChanged, |
300 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); | 300 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); |
301 ASSERT_EQ(1u, changedRuleSets.size()); | 301 ASSERT_EQ(1u, changedRuleSets.size()); |
302 EXPECT_EQ(&sheet3->contents()->ruleSet(), changedRuleSets[0]); | 302 EXPECT_EQ(&sheet3->contents()->ruleSet(), changedRuleSets[0]); |
303 } | 303 } |
304 | 304 |
| 305 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_ReorderedImportSheets) { |
| 306 ActiveStyleSheetVector oldSheets; |
| 307 ActiveStyleSheetVector newSheets; |
| 308 HeapVector<Member<RuleSet>> changedRuleSets; |
| 309 |
| 310 CSSStyleSheet* sheet1 = createSheet(); |
| 311 CSSStyleSheet* sheet2 = createSheet(); |
| 312 |
| 313 // It is possible to have CSSStyleSheet pointers re-orderered for html imports |
| 314 // because their documents, and hence their stylesheets are persisted on |
| 315 // remove / insert. This test is here to show that the active sheet comparison |
| 316 // is not able to see that anything changed. |
| 317 // |
| 318 // Imports are handled by forcing re-append and recalc of the document scope |
| 319 // when html imports are removed. |
| 320 oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); |
| 321 oldSheets.append(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); |
| 322 |
| 323 newSheets.append(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); |
| 324 newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); |
| 325 |
| 326 EXPECT_EQ(NoActiveSheetsChanged, |
| 327 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); |
| 328 EXPECT_EQ(0u, changedRuleSets.size()); |
| 329 } |
| 330 |
305 TEST_F(ApplyRulesetsTest, AddUniversalRuleToDocument) { | 331 TEST_F(ApplyRulesetsTest, AddUniversalRuleToDocument) { |
306 document().view()->updateAllLifecyclePhases(); | 332 document().view()->updateAllLifecyclePhases(); |
307 | 333 |
308 CSSStyleSheet* sheet = createSheet("body * { color:red }"); | 334 CSSStyleSheet* sheet = createSheet("body * { color:red }"); |
309 | 335 |
310 ActiveStyleSheetVector newStyleSheets; | 336 ActiveStyleSheetVector newStyleSheets; |
311 newStyleSheets.append(std::make_pair(sheet, &sheet->contents()->ruleSet())); | 337 newStyleSheets.append(std::make_pair(sheet, &sheet->contents()->ruleSet())); |
312 | 338 |
313 styleEngine().applyRuleSetChanges(document(), ActiveStyleSheetVector(), | 339 styleEngine().applyRuleSetChanges(document(), ActiveStyleSheetVector(), |
314 newStyleSheets); | 340 newStyleSheets); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 ActiveStyleSheetVector oldStyleSheets; | 451 ActiveStyleSheetVector oldStyleSheets; |
426 oldStyleSheets.append( | 452 oldStyleSheets.append( |
427 std::make_pair(cssSheet, &cssSheet->contents()->ruleSet())); | 453 std::make_pair(cssSheet, &cssSheet->contents()->ruleSet())); |
428 styleEngine().applyRuleSetChanges(shadowRoot, oldStyleSheets, | 454 styleEngine().applyRuleSetChanges(shadowRoot, oldStyleSheets, |
429 ActiveStyleSheetVector()); | 455 ActiveStyleSheetVector()); |
430 | 456 |
431 EXPECT_TRUE(styleEngine().treeBoundaryCrossingScopes().isEmpty()); | 457 EXPECT_TRUE(styleEngine().treeBoundaryCrossingScopes().isEmpty()); |
432 } | 458 } |
433 | 459 |
434 } // namespace blink | 460 } // namespace blink |
OLD | NEW |