| 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" | |
| 10 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 11 #include "core/html/HTMLElement.h" | |
| 12 #include "core/testing/DummyPageHolder.h" | 10 #include "core/testing/DummyPageHolder.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 12 |
| 15 namespace blink { | 13 namespace blink { |
| 16 | 14 |
| 17 class StyleEngineTest : public ::testing::Test { | 15 class StyleEngineTest : public ::testing::Test { |
| 18 protected: | 16 protected: |
| 19 void SetUp() override; | 17 void SetUp() override; |
| 20 | 18 |
| 21 Document& document() { return m_dummyPageHolder->document(); } | 19 Document& document() { return m_dummyPageHolder->document(); } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 35 TEST_F(StyleEngineTest, DocumentDirtyAfterInject) | 33 TEST_F(StyleEngineTest, DocumentDirtyAfterInject) |
| 36 { | 34 { |
| 37 RefPtrWillBeRawPtr<StyleSheetContents> parsedSheet = StyleSheetContents::cre
ate(CSSParserContext(document(), nullptr)); | 35 RefPtrWillBeRawPtr<StyleSheetContents> parsedSheet = StyleSheetContents::cre
ate(CSSParserContext(document(), nullptr)); |
| 38 parsedSheet->parseString("div {}"); | 36 parsedSheet->parseString("div {}"); |
| 39 styleEngine().injectAuthorSheet(parsedSheet); | 37 styleEngine().injectAuthorSheet(parsedSheet); |
| 40 document().view()->updateAllLifecyclePhases(); | 38 document().view()->updateAllLifecyclePhases(); |
| 41 | 39 |
| 42 EXPECT_TRUE(isDocumentStyleSheetCollectionClean()); | 40 EXPECT_TRUE(isDocumentStyleSheetCollectionClean()); |
| 43 } | 41 } |
| 44 | 42 |
| 45 TEST_F(StyleEngineTest, AnalyzedInject) | |
| 46 { | |
| 47 document().body()->setInnerHTML("<style>div { color: red }</style><div id='t
1'>Green</div><div></div>", ASSERT_NO_EXCEPTION); | |
| 48 document().view()->updateAllLifecyclePhases(); | |
| 49 | |
| 50 Element* t1 = document().getElementById("t1"); | |
| 51 ASSERT_TRUE(t1); | |
| 52 ASSERT_TRUE(t1->computedStyle()); | |
| 53 EXPECT_EQ(makeRGB(255, 0, 0), t1->computedStyle()->visitedDependentColor(CSS
PropertyColor)); | |
| 54 | |
| 55 unsigned beforeCount = styleEngine().styleForElementCount(); | |
| 56 | |
| 57 RefPtrWillBeRawPtr<StyleSheetContents> parsedSheet = StyleSheetContents::cre
ate(CSSParserContext(document(), nullptr)); | |
| 58 parsedSheet->parseString("#t1 { color: green }"); | |
| 59 styleEngine().injectAuthorSheet(parsedSheet); | |
| 60 document().view()->updateAllLifecyclePhases(); | |
| 61 | |
| 62 unsigned afterCount = styleEngine().styleForElementCount(); | |
| 63 EXPECT_EQ(1u, afterCount - beforeCount); | |
| 64 | |
| 65 ASSERT_TRUE(t1->computedStyle()); | |
| 66 EXPECT_EQ(makeRGB(0, 128, 0), t1->computedStyle()->visitedDependentColor(CSS
PropertyColor)); | |
| 67 } | |
| 68 | |
| 69 } // namespace blink | 43 } // namespace blink |
| OLD | NEW |