OLD | NEW |
---|---|
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 Loading... | |
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 ASSERT_EQ(3U, element_count); | |
rune
2017/04/25 09:27:33
EXPECT_EQ should suffice.
Manuel Rego
2017/04/25 09:37:42
Acknowledged.
| |
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 ASSERT_EQ(2U, element_count); | |
rune
2017/04/25 09:27:33
EXPECT_EQ.
Manuel Rego
2017/04/25 09:37:42
Acknowledged.
| |
351 } | |
352 | |
315 } // namespace blink | 353 } // namespace blink |
OLD | NEW |