Chromium Code Reviews| 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 "HTMLNames.h" | 6 #include "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/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 unsigned startCount = document().styleEngine()->resolverAccessCount(); | 243 unsigned startCount = document().styleEngine()->resolverAccessCount(); |
| 244 | 244 |
| 245 document().getElementById("d")->focus(); | 245 document().getElementById("d")->focus(); |
| 246 document().view()->updateLayoutAndStyleIfNeededRecursive(); | 246 document().view()->updateLayoutAndStyleIfNeededRecursive(); |
| 247 | 247 |
| 248 unsigned accessCount = document().styleEngine()->resolverAccessCount() - sta rtCount; | 248 unsigned accessCount = document().styleEngine()->resolverAccessCount() - sta rtCount; |
| 249 | 249 |
| 250 ASSERT_EQ(11U, accessCount); | 250 ASSERT_EQ(11U, accessCount); |
| 251 } | 251 } |
| 252 | 252 |
| 253 TEST_F(AffectedByFocusTest, InvalidationSetFocusUpdate) | |
| 254 { | |
| 255 // Check that when focussing the outer div in the document below, you get a | |
| 256 // style recalc for the outer div and the class=a div only. | |
| 257 | |
| 258 setHtmlInnerHTML("<style>:focus .a { border: 1px solid lime; }</style>" | |
| 259 "<div id=d tabIndex=1>" | |
| 260 "<div></div>" | |
| 261 "<div></div>" | |
| 262 "<div></div>" | |
| 263 "<div></div>" | |
| 264 "<div></div>" | |
| 265 "<div></div>" | |
| 266 "<div></div>" | |
| 267 "<div></div>" | |
| 268 "<div></div>" | |
| 269 "<div class='a'></div>" | |
| 270 "</div>"); | |
| 271 | |
| 272 document().view()->updateLayoutAndStyleIfNeededRecursive(); | |
| 273 | |
| 274 unsigned startCount = document().styleEngine()->resolverAccessCount(); | |
| 275 | |
| 276 document().getElementById("d")->focus(); | |
| 277 document().view()->updateLayoutAndStyleIfNeededRecursive(); | |
| 278 | |
| 279 unsigned accessCount = document().styleEngine()->resolverAccessCount() - sta rtCount; | |
| 280 | |
| 281 ASSERT_EQ(2U, accessCount); | |
| 282 } | |
| 283 | |
| 284 TEST_F(AffectedByFocusTest, NoInvalidationSetFocusUpdate) | |
| 285 { | |
| 286 // Check that when focussing the outer div in the document below, you get a | |
| 287 // style recalc for the outer div only. The invalidation set for :focus will | |
| 288 // include 'a', but the id=d div should be affectedByFocus, not childrenAffe ctedByFocus. | |
| 289 | |
| 290 setHtmlInnerHTML("<style>#nomatch:focus .a { border: 1px solid lime; }</styl e>" | |
| 291 "<div id=d tabIndex=1>" | |
| 292 "<div></div>" | |
| 293 "<div></div>" | |
| 294 "<div></div>" | |
| 295 "<div></div>" | |
| 296 "<div></div>" | |
|
esprehn
2014/04/04 22:48:27
Can we just write the normal layout tests like we'
rune
2014/04/10 12:42:12
Style update for focus still happens synchronously
| |
| 297 "<div></div>" | |
| 298 "<div></div>" | |
| 299 "<div></div>" | |
| 300 "<div></div>" | |
| 301 "<div class='a'></div>" | |
| 302 "</div>"); | |
| 303 | |
| 304 document().view()->updateLayoutAndStyleIfNeededRecursive(); | |
| 305 | |
| 306 unsigned startCount = document().styleEngine()->resolverAccessCount(); | |
| 307 | |
| 308 document().getElementById("d")->focus(); | |
| 309 document().view()->updateLayoutAndStyleIfNeededRecursive(); | |
| 310 | |
| 311 unsigned accessCount = document().styleEngine()->resolverAccessCount() - sta rtCount; | |
| 312 | |
| 313 ASSERT_EQ(1U, accessCount); | |
| 314 } | |
| 315 | |
| 253 } // namespace | 316 } // namespace |
| OLD | NEW |