| 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 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; | 38 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; |
| 39 | 39 |
| 40 Persistent<Document> m_document; | 40 Persistent<Document> m_document; |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 void AffectedByFocusTest::SetUp() { | 43 void AffectedByFocusTest::SetUp() { |
| 44 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); | 44 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); |
| 45 m_document = &m_dummyPageHolder->document(); | 45 m_document = &m_dummyPageHolder->document(); |
| 46 ASSERT(m_document); | 46 DCHECK(m_document); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void AffectedByFocusTest::setHtmlInnerHTML(const char* htmlContent) { | 49 void AffectedByFocusTest::setHtmlInnerHTML(const char* htmlContent) { |
| 50 document().documentElement()->setInnerHTML(String::fromUTF8(htmlContent)); | 50 document().documentElement()->setInnerHTML(String::fromUTF8(htmlContent)); |
| 51 document().view()->updateAllLifecyclePhases(); | 51 document().view()->updateAllLifecyclePhases(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void AffectedByFocusTest::checkElements(ElementResult expected[], | 54 void AffectedByFocusTest::checkElements(ElementResult expected[], |
| 55 unsigned expectedCount) const { | 55 unsigned expectedCount) const { |
| 56 unsigned i = 0; | 56 unsigned i = 0; |
| 57 HTMLElement* element = document().body(); | 57 HTMLElement* element = document().body(); |
| 58 | 58 |
| 59 for (; element && i < expectedCount; | 59 for (; element && i < expectedCount; |
| 60 element = Traversal<HTMLElement>::next(*element), ++i) { | 60 element = Traversal<HTMLElement>::next(*element), ++i) { |
| 61 ASSERT_TRUE(element->hasTagName(expected[i].tag)); | 61 ASSERT_TRUE(element->hasTagName(expected[i].tag)); |
| 62 ASSERT(element->computedStyle()); | 62 DCHECK(element->computedStyle()); |
| 63 ASSERT_EQ(expected[i].affectedBy, | 63 ASSERT_EQ(expected[i].affectedBy, |
| 64 element->computedStyle()->affectedByFocus()); | 64 element->computedStyle()->affectedByFocus()); |
| 65 ASSERT_EQ(expected[i].childrenOrSiblingsAffectedBy, | 65 ASSERT_EQ(expected[i].childrenOrSiblingsAffectedBy, |
| 66 element->childrenOrSiblingsAffectedByFocus()); | 66 element->childrenOrSiblingsAffectedByFocus()); |
| 67 } | 67 } |
| 68 | 68 |
| 69 ASSERT(!element && i == expectedCount); | 69 DCHECK(!element); |
| 70 DCHECK_EQ(i, expectedCount); |
| 70 } | 71 } |
| 71 | 72 |
| 72 // A global :focus rule in html.css currently causes every single element to be | 73 // A global :focus rule in html.css currently causes every single element to be |
| 73 // affectedByFocus. Check that all elements in a document with no :focus rules | 74 // affectedByFocus. Check that all elements in a document with no :focus rules |
| 74 // gets the affectedByFocus set on ComputedStyle and not | 75 // gets the affectedByFocus set on ComputedStyle and not |
| 75 // childrenOrSiblingsAffectedByFocus. | 76 // childrenOrSiblingsAffectedByFocus. |
| 76 TEST_F(AffectedByFocusTest, UAUniversalFocusRule) { | 77 TEST_F(AffectedByFocusTest, UAUniversalFocusRule) { |
| 77 ElementResult expected[] = {{bodyTag, true, false}, | 78 ElementResult expected[] = {{bodyTag, true, false}, |
| 78 {divTag, true, false}, | 79 {divTag, true, false}, |
| 79 {divTag, true, false}, | 80 {divTag, true, false}, |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 document().getElementById("d")->focus(); | 306 document().getElementById("d")->focus(); |
| 306 document().view()->updateAllLifecyclePhases(); | 307 document().view()->updateAllLifecyclePhases(); |
| 307 | 308 |
| 308 unsigned elementCount = | 309 unsigned elementCount = |
| 309 document().styleEngine().styleForElementCount() - startCount; | 310 document().styleEngine().styleForElementCount() - startCount; |
| 310 | 311 |
| 311 ASSERT_EQ(1U, elementCount); | 312 ASSERT_EQ(1U, elementCount); |
| 312 } | 313 } |
| 313 | 314 |
| 314 } // namespace blink | 315 } // namespace blink |
| OLD | NEW |