| 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 "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/NodeLayoutStyle.h" | 9 #include "core/dom/NodeComputedStyle.h" |
| 10 #include "core/dom/StyleEngine.h" | 10 #include "core/dom/StyleEngine.h" |
| 11 #include "core/frame/FrameView.h" | 11 #include "core/frame/FrameView.h" |
| 12 #include "core/html/HTMLDocument.h" | 12 #include "core/html/HTMLDocument.h" |
| 13 #include "core/html/HTMLElement.h" | 13 #include "core/html/HTMLElement.h" |
| 14 #include "core/testing/DummyPageHolder.h" | 14 #include "core/testing/DummyPageHolder.h" |
| 15 #include <gtest/gtest.h> | 15 #include <gtest/gtest.h> |
| 16 | 16 |
| 17 using namespace blink; | 17 using namespace blink; |
| 18 using namespace HTMLNames; | 18 using namespace HTMLNames; |
| 19 | 19 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 HTMLElement* element = document().body(); | 62 HTMLElement* element = document().body(); |
| 63 | 63 |
| 64 for (; element && i < expectedCount; element = Traversal<HTMLElement>::next(
*element), ++i) { | 64 for (; element && i < expectedCount; element = Traversal<HTMLElement>::next(
*element), ++i) { |
| 65 ASSERT_TRUE(element->hasTagName(expected[i].tag)); | 65 ASSERT_TRUE(element->hasTagName(expected[i].tag)); |
| 66 ASSERT(element->layoutStyle()); | 66 ASSERT(element->computedStyle()); |
| 67 ASSERT_EQ(expected[i].affectedBy, element->layoutStyle()->affectedByFocu
s()); | 67 ASSERT_EQ(expected[i].affectedBy, element->computedStyle()->affectedByFo
cus()); |
| 68 ASSERT_EQ(expected[i].childrenOrSiblingsAffectedBy, element->childrenOrS
iblingsAffectedByFocus()); | 68 ASSERT_EQ(expected[i].childrenOrSiblingsAffectedBy, element->childrenOrS
iblingsAffectedByFocus()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 ASSERT(!element && 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 LayoutStyle and not childrenOrSiblingsAffecte
dByFocus. | 76 // gets the affectedByFocus set on ComputedStyle and not childrenOrSiblingsAffec
tedByFocus. |
| 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 }, |
| 82 { divTag, true, false }, | 82 { divTag, true, false }, |
| 83 { divTag, true, false }, | 83 { divTag, true, false }, |
| 84 { spanTag, true, false } | 84 { spanTag, true, false } |
| 85 }; | 85 }; |
| 86 | 86 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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() - star
tCount; | 312 unsigned accessCount = document().styleEngine().resolverAccessCount() - star
tCount; |
| 313 | 313 |
| 314 ASSERT_EQ(1U, accessCount); | 314 ASSERT_EQ(1U, accessCount); |
| 315 } | 315 } |
| 316 | 316 |
| 317 } // namespace | 317 } // namespace |
| OLD | NEW |