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

Side by Side Diff: Source/core/css/AffectedByFocusTest.cpp

Issue 420193007: Use new Traversal<> API more in the code base (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Take feedback into consideration Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/dom/shadow/ShadowRoot.cpp » ('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 "config.h" 5 #include "config.h"
6 #include "core/HTMLNames.h" 6 #include "core/HTMLNames.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/NodeRenderStyle.h" 9 #include "core/dom/NodeRenderStyle.h"
10 #include "core/dom/StyleEngine.h" 10 #include "core/dom/StyleEngine.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 void AffectedByFocusTest::setHtmlInnerHTML(const char* htmlContent) 53 void AffectedByFocusTest::setHtmlInnerHTML(const char* htmlContent)
54 { 54 {
55 document().documentElement()->setInnerHTML(String::fromUTF8(htmlContent), AS SERT_NO_EXCEPTION); 55 document().documentElement()->setInnerHTML(String::fromUTF8(htmlContent), AS SERT_NO_EXCEPTION);
56 document().view()->updateLayoutAndStyleIfNeededRecursive(); 56 document().view()->updateLayoutAndStyleIfNeededRecursive();
57 } 57 }
58 58
59 void AffectedByFocusTest::checkElements(ElementResult expected[], unsigned expec tedCount) const 59 void AffectedByFocusTest::checkElements(ElementResult expected[], unsigned expec tedCount) const
60 { 60 {
61 unsigned i = 0; 61 unsigned i = 0;
62 Element* elm = document().body(); 62 HTMLElement* element = document().body();
63 63
64 for (; elm && i < expectedCount; elm = ElementTraversal::next(*elm), ++i) { 64 for (; element && i < expectedCount; element = Traversal<HTMLElement>::next( *element), ++i) {
65 ASSERT_TRUE(elm->hasTagName(expected[i].tag)); 65 ASSERT_TRUE(element->hasTagName(expected[i].tag));
66 ASSERT(elm->renderStyle()); 66 ASSERT(element->renderStyle());
67 ASSERT_EQ(expected[i].affectedBy, elm->renderStyle()->affectedByFocus()) ; 67 ASSERT_EQ(expected[i].affectedBy, element->renderStyle()->affectedByFocu s());
68 ASSERT_EQ(expected[i].childrenOrSiblingsAffectedBy, elm->childrenOrSibli ngsAffectedByFocus()); 68 ASSERT_EQ(expected[i].childrenOrSiblingsAffectedBy, element->childrenOrS iblingsAffectedByFocus());
69 } 69 }
70 70
71 ASSERT(!elm && i == expectedCount); 71 ASSERT(!element && i == expectedCount);
72 } 72 }
73 73
74 // A global :focus rule in html.css currently causes every single element to be 74 // A global :focus rule in html.css currently causes every single element to be
75 // affectedByFocus. Check that all elements in a document with no :focus rules 75 // affectedByFocus. Check that all elements in a document with no :focus rules
76 // gets the affectedByFocus set on RenderStyle and not childrenOrSiblingsAffecte dByFocus. 76 // gets the affectedByFocus set on RenderStyle and not childrenOrSiblingsAffecte dByFocus.
77 TEST_F(AffectedByFocusTest, UAUniversalFocusRule) 77 TEST_F(AffectedByFocusTest, UAUniversalFocusRule)
78 { 78 {
79 ElementResult expected[] = { 79 ElementResult expected[] = {
80 { bodyTag, true, false }, 80 { bodyTag, true, false },
81 { divTag, true, false }, 81 { divTag, true, false },
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 308
309 document().getElementById("d")->focus(); 309 document().getElementById("d")->focus();
310 document().view()->updateLayoutAndStyleIfNeededRecursive(); 310 document().view()->updateLayoutAndStyleIfNeededRecursive();
311 311
312 unsigned accessCount = document().styleEngine()->resolverAccessCount() - sta rtCount; 312 unsigned accessCount = document().styleEngine()->resolverAccessCount() - sta rtCount;
313 313
314 ASSERT_EQ(1U, accessCount); 314 ASSERT_EQ(1U, accessCount);
315 } 315 }
316 316
317 } // namespace 317 } // namespace
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/shadow/ShadowRoot.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698