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

Unified Diff: third_party/WebKit/Source/core/css/AffectedByFocusTest.cpp

Issue 2821303005: [selectors4] Use common ancestor strategy for :focus-within (Closed)
Patch Set: Use EXPECT_EQ instead of ASSERT_EQ Created 3 years, 8 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/ContainerNode.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/AffectedByFocusTest.cpp
diff --git a/third_party/WebKit/Source/core/css/AffectedByFocusTest.cpp b/third_party/WebKit/Source/core/css/AffectedByFocusTest.cpp
index 8ce377046bfd8eaa2ad34b07b3e8270f403236c3..40ef36dc7e5b6a58a7f3f1d82e6a39e644636387 100644
--- a/third_party/WebKit/Source/core/css/AffectedByFocusTest.cpp
+++ b/third_party/WebKit/Source/core/css/AffectedByFocusTest.cpp
@@ -312,4 +312,42 @@ TEST_F(AffectedByFocusTest, NoInvalidationSetFocusUpdate) {
ASSERT_EQ(1U, element_count);
}
+TEST_F(AffectedByFocusTest, FocusWithinCommonAncestor) {
+ // Check that when changing the focus between 2 elements we don't need a style
+ // recalc for all the ancestors affected by ":focus-within".
+
+ SetHtmlInnerHTML(
+ "<style>div:focus-within { background-color: lime; }</style>"
+ "<div>"
+ " <div>"
+ " <div id=focusme1 tabIndex=1></div>"
+ " <div id=focusme2 tabIndex=2></div>"
+ " <div>"
+ "</div>");
+
+ GetDocument().View()->UpdateAllLifecyclePhases();
+
+ unsigned start_count = GetDocument().GetStyleEngine().StyleForElementCount();
+
+ GetDocument().GetElementById("focusme1")->focus();
+ GetDocument().View()->UpdateAllLifecyclePhases();
+
+ unsigned element_count =
+ GetDocument().GetStyleEngine().StyleForElementCount() - start_count;
+
+ EXPECT_EQ(3U, element_count);
+
+ start_count += element_count;
+
+ GetDocument().GetElementById("focusme2")->focus();
+ GetDocument().View()->UpdateAllLifecyclePhases();
+
+ element_count =
+ GetDocument().GetStyleEngine().StyleForElementCount() - start_count;
+
+ // Only "focusme1" & "focusme2" elements need a recalc thanks to the common
+ // ancestor strategy.
+ EXPECT_EQ(2U, element_count);
+}
+
} // namespace blink
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/ContainerNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698