| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/css/resolver/SharedStyleFinder.h" | 5 #include "core/css/resolver/SharedStyleFinder.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
| 9 #include "core/css/RuleFeature.h" | 9 #include "core/css/RuleFeature.h" |
| 10 #include "core/css/RuleSet.h" | 10 #include "core/css/RuleSet.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 ASSERT_TRUE(a); | 150 ASSERT_TRUE(a); |
| 151 ASSERT_TRUE(b); | 151 ASSERT_TRUE(b); |
| 152 | 152 |
| 153 EXPECT_FALSE(a->IsFocused()); | 153 EXPECT_FALSE(a->IsFocused()); |
| 154 EXPECT_FALSE(b->IsFocused()); | 154 EXPECT_FALSE(b->IsFocused()); |
| 155 | 155 |
| 156 EXPECT_TRUE(MatchesUncommonAttributeRuleSet(*a)); | 156 EXPECT_TRUE(MatchesUncommonAttributeRuleSet(*a)); |
| 157 EXPECT_FALSE(MatchesUncommonAttributeRuleSet(*b)); | 157 EXPECT_FALSE(MatchesUncommonAttributeRuleSet(*b)); |
| 158 } | 158 } |
| 159 | 159 |
| 160 TEST_F(SharedStyleFinderTest, AttributeAffectedByFocusWithin) { |
| 161 SetBodyContent("<div id=a attr></div><div id=b></div>"); |
| 162 |
| 163 AddSelector("[attr]:focus-within"); |
| 164 FinishAddingSelectors(); |
| 165 |
| 166 Element* a = GetDocument().GetElementById("a"); |
| 167 Element* b = GetDocument().GetElementById("b"); |
| 168 |
| 169 ASSERT_TRUE(a); |
| 170 ASSERT_TRUE(b); |
| 171 |
| 172 EXPECT_FALSE(a->HasFocusWithin()); |
| 173 EXPECT_FALSE(b->HasFocusWithin()); |
| 174 |
| 175 EXPECT_TRUE(MatchesUncommonAttributeRuleSet(*a)); |
| 176 EXPECT_FALSE(MatchesUncommonAttributeRuleSet(*b)); |
| 177 } |
| 178 |
| 160 TEST_F(SharedStyleFinderTest, AttributeAffectedByActive) { | 179 TEST_F(SharedStyleFinderTest, AttributeAffectedByActive) { |
| 161 SetBodyContent("<div id=a attr></div><div id=b></div>"); | 180 SetBodyContent("<div id=a attr></div><div id=b></div>"); |
| 162 | 181 |
| 163 AddSelector("[attr]:active"); | 182 AddSelector("[attr]:active"); |
| 164 FinishAddingSelectors(); | 183 FinishAddingSelectors(); |
| 165 | 184 |
| 166 Element* a = GetDocument().GetElementById("a"); | 185 Element* a = GetDocument().GetElementById("a"); |
| 167 Element* b = GetDocument().GetElementById("b"); | 186 Element* b = GetDocument().GetElementById("b"); |
| 168 | 187 |
| 169 ASSERT_TRUE(a); | 188 ASSERT_TRUE(a); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 Element* b = GetDocument().GetElementById("b"); | 228 Element* b = GetDocument().GetElementById("b"); |
| 210 | 229 |
| 211 EXPECT_TRUE(a->AssignedSlot()); | 230 EXPECT_TRUE(a->AssignedSlot()); |
| 212 EXPECT_TRUE(b->AssignedSlot()); | 231 EXPECT_TRUE(b->AssignedSlot()); |
| 213 | 232 |
| 214 EXPECT_FALSE(MatchesUncommonAttributeRuleSet(*a)); | 233 EXPECT_FALSE(MatchesUncommonAttributeRuleSet(*a)); |
| 215 EXPECT_TRUE(MatchesUncommonAttributeRuleSet(*b)); | 234 EXPECT_TRUE(MatchesUncommonAttributeRuleSet(*b)); |
| 216 } | 235 } |
| 217 | 236 |
| 218 } // namespace blink | 237 } // namespace blink |
| OLD | NEW |