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

Side by Side 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, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/ContainerNode.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/HTMLNames.h" 5 #include "core/HTMLNames.h"
6 #include "core/dom/Document.h" 6 #include "core/dom/Document.h"
7 #include "core/dom/Element.h" 7 #include "core/dom/Element.h"
8 #include "core/dom/ElementTraversal.h" 8 #include "core/dom/ElementTraversal.h"
9 #include "core/dom/NodeComputedStyle.h" 9 #include "core/dom/NodeComputedStyle.h"
10 #include "core/dom/StyleEngine.h" 10 #include "core/dom/StyleEngine.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 305
306 GetDocument().GetElementById("d")->focus(); 306 GetDocument().GetElementById("d")->focus();
307 GetDocument().View()->UpdateAllLifecyclePhases(); 307 GetDocument().View()->UpdateAllLifecyclePhases();
308 308
309 unsigned element_count = 309 unsigned element_count =
310 GetDocument().GetStyleEngine().StyleForElementCount() - start_count; 310 GetDocument().GetStyleEngine().StyleForElementCount() - start_count;
311 311
312 ASSERT_EQ(1U, element_count); 312 ASSERT_EQ(1U, element_count);
313 } 313 }
314 314
315 TEST_F(AffectedByFocusTest, FocusWithinCommonAncestor) {
316 // Check that when changing the focus between 2 elements we don't need a style
317 // recalc for all the ancestors affected by ":focus-within".
318
319 SetHtmlInnerHTML(
320 "<style>div:focus-within { background-color: lime; }</style>"
321 "<div>"
322 " <div>"
323 " <div id=focusme1 tabIndex=1></div>"
324 " <div id=focusme2 tabIndex=2></div>"
325 " <div>"
326 "</div>");
327
328 GetDocument().View()->UpdateAllLifecyclePhases();
329
330 unsigned start_count = GetDocument().GetStyleEngine().StyleForElementCount();
331
332 GetDocument().GetElementById("focusme1")->focus();
333 GetDocument().View()->UpdateAllLifecyclePhases();
334
335 unsigned element_count =
336 GetDocument().GetStyleEngine().StyleForElementCount() - start_count;
337
338 EXPECT_EQ(3U, element_count);
339
340 start_count += element_count;
341
342 GetDocument().GetElementById("focusme2")->focus();
343 GetDocument().View()->UpdateAllLifecyclePhases();
344
345 element_count =
346 GetDocument().GetStyleEngine().StyleForElementCount() - start_count;
347
348 // Only "focusme1" & "focusme2" elements need a recalc thanks to the common
349 // ancestor strategy.
350 EXPECT_EQ(2U, element_count);
351 }
352
315 } // namespace blink 353 } // namespace blink
OLDNEW
« 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