| 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/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" | 
|  | 11 #include "core/html/HTMLElement.h" | 
| 10 #include "core/testing/DummyPageHolder.h" | 12 #include "core/testing/DummyPageHolder.h" | 
| 11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" | 
| 12 | 14 | 
| 13 namespace blink { | 15 namespace blink { | 
| 14 | 16 | 
| 15 class StyleEngineTest : public ::testing::Test { | 17 class StyleEngineTest : public ::testing::Test { | 
| 16 protected: | 18 protected: | 
| 17     void SetUp() override; | 19     void SetUp() override; | 
| 18 | 20 | 
| 19     Document& document() { return m_dummyPageHolder->document(); } | 21     Document& document() { return m_dummyPageHolder->document(); } | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 33 TEST_F(StyleEngineTest, DocumentDirtyAfterInject) | 35 TEST_F(StyleEngineTest, DocumentDirtyAfterInject) | 
| 34 { | 36 { | 
| 35     RefPtrWillBeRawPtr<StyleSheetContents> parsedSheet = StyleSheetContents::cre
    ate(CSSParserContext(document(), nullptr)); | 37     RefPtrWillBeRawPtr<StyleSheetContents> parsedSheet = StyleSheetContents::cre
    ate(CSSParserContext(document(), nullptr)); | 
| 36     parsedSheet->parseString("div {}"); | 38     parsedSheet->parseString("div {}"); | 
| 37     styleEngine().injectAuthorSheet(parsedSheet); | 39     styleEngine().injectAuthorSheet(parsedSheet); | 
| 38     document().view()->updateAllLifecyclePhases(); | 40     document().view()->updateAllLifecyclePhases(); | 
| 39 | 41 | 
| 40     EXPECT_TRUE(isDocumentStyleSheetCollectionClean()); | 42     EXPECT_TRUE(isDocumentStyleSheetCollectionClean()); | 
| 41 } | 43 } | 
| 42 | 44 | 
|  | 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 | 
| 43 } // namespace blink | 69 } // namespace blink | 
| OLD | NEW | 
|---|