Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(534)

Unified Diff: third_party/WebKit/Source/core/css/invalidation/StyleInvalidatorTest.cpp

Issue 2699883002: Add type selector invalidation set for ruleset invalidations. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/invalidation/StyleInvalidatorTest.cpp
diff --git a/third_party/WebKit/Source/core/css/invalidation/StyleInvalidatorTest.cpp b/third_party/WebKit/Source/core/css/invalidation/StyleInvalidatorTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..42e3d3c465e1a8861bf67a045877131e0ec8f30a
--- /dev/null
+++ b/third_party/WebKit/Source/core/css/invalidation/StyleInvalidatorTest.cpp
@@ -0,0 +1,63 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/css/invalidation/StyleInvalidator.h"
+
+#include "core/dom/StyleEngine.h"
+#include "core/frame/FrameView.h"
+#include "core/html/HTMLElement.h"
+#include "core/testing/DummyPageHolder.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+class StyleInvalidatorTest : public ::testing::Test {
+ protected:
+ void SetUp() override;
+
+ Document& document() { return m_dummyPageHolder->document(); }
+ StyleEngine& styleEngine() { return document().styleEngine(); }
+ StyleInvalidator& styleInvalidator() {
+ return document().styleEngine().styleInvalidator();
+ }
+
+ private:
+ std::unique_ptr<DummyPageHolder> m_dummyPageHolder;
+};
+
+void StyleInvalidatorTest::SetUp() {
+ m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
+}
+
+TEST_F(StyleInvalidatorTest, ScheduleOnDocumentNode) {
+ document().body()->setInnerHTML(
+ "<div id='d'></div><i id='i'></i><span></span>");
+ document().view()->updateAllLifecyclePhases();
+
+ unsigned beforeCount = styleEngine().styleForElementCount();
+
+ RefPtr<DescendantInvalidationSet> set = DescendantInvalidationSet::create();
+ set->addTagName("div");
+ set->addTagName("span");
+
+ InvalidationLists lists;
+ lists.descendants.push_back(set);
+ styleInvalidator().scheduleInvalidationSetsForNode(lists, document());
+
+ EXPECT_TRUE(document().needsStyleInvalidation());
+ EXPECT_FALSE(document().childNeedsStyleInvalidation());
+
+ styleInvalidator().invalidate(document());
+
+ EXPECT_FALSE(document().needsStyleInvalidation());
+ EXPECT_FALSE(document().childNeedsStyleInvalidation());
+ EXPECT_FALSE(document().needsStyleRecalc());
+ EXPECT_TRUE(document().childNeedsStyleRecalc());
+
+ document().view()->updateAllLifecyclePhases();
+ unsigned afterCount = styleEngine().styleForElementCount();
+ EXPECT_EQ(2u, afterCount - beforeCount);
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/css/invalidation/StyleInvalidator.cpp ('k') | third_party/WebKit/Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698