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/Element.h" | 6 #include "core/dom/Element.h" |
7 #include "core/dom/ElementTraversal.h" | 7 #include "core/dom/ElementTraversal.h" |
8 #include "core/dom/NodeComputedStyle.h" | 8 #include "core/dom/NodeComputedStyle.h" |
9 #include "core/dom/StyleEngine.h" | 9 #include "core/dom/StyleEngine.h" |
10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 "<div></div>" | 199 "<div></div>" |
200 "<div></div>" | 200 "<div></div>" |
201 "<div></div>" | 201 "<div></div>" |
202 "<div></div>" | 202 "<div></div>" |
203 "<div></div>" | 203 "<div></div>" |
204 "<div></div>" | 204 "<div></div>" |
205 "</div>"); | 205 "</div>"); |
206 | 206 |
207 document().view()->updateAllLifecyclePhases(); | 207 document().view()->updateAllLifecyclePhases(); |
208 | 208 |
209 unsigned startCount = document().styleEngine().resolverAccessCount(); | 209 unsigned startCount = document().styleEngine().styleForElementCount(); |
210 | 210 |
211 document().getElementById("d")->focus(); | 211 document().getElementById("d")->focus(); |
212 document().view()->updateAllLifecyclePhases(); | 212 document().view()->updateAllLifecyclePhases(); |
213 | 213 |
214 unsigned accessCount = document().styleEngine().resolverAccessCount() - star
tCount; | 214 unsigned elementCount = document().styleEngine().styleForElementCount() - st
artCount; |
215 | 215 |
216 ASSERT_EQ(1U, accessCount); | 216 ASSERT_EQ(1U, elementCount); |
217 } | 217 } |
218 | 218 |
219 TEST_F(AffectedByFocusTest, ChildrenOrSiblingsAffectedByFocusUpdate) | 219 TEST_F(AffectedByFocusTest, ChildrenOrSiblingsAffectedByFocusUpdate) |
220 { | 220 { |
221 // Check that when focussing the outer div in the document below, you get a | 221 // Check that when focussing the outer div in the document below, you get a |
222 // style recalc for the whole subtree. | 222 // style recalc for the whole subtree. |
223 | 223 |
224 setHtmlInnerHTML("<style>:focus div { border: 1px solid lime; }</style>" | 224 setHtmlInnerHTML("<style>:focus div { border: 1px solid lime; }</style>" |
225 "<div id=d tabIndex=1>" | 225 "<div id=d tabIndex=1>" |
226 "<div></div>" | 226 "<div></div>" |
227 "<div></div>" | 227 "<div></div>" |
228 "<div></div>" | 228 "<div></div>" |
229 "<div></div>" | 229 "<div></div>" |
230 "<div></div>" | 230 "<div></div>" |
231 "<div></div>" | 231 "<div></div>" |
232 "<div></div>" | 232 "<div></div>" |
233 "<div></div>" | 233 "<div></div>" |
234 "<div></div>" | 234 "<div></div>" |
235 "<div></div>" | 235 "<div></div>" |
236 "</div>"); | 236 "</div>"); |
237 | 237 |
238 document().view()->updateAllLifecyclePhases(); | 238 document().view()->updateAllLifecyclePhases(); |
239 | 239 |
240 unsigned startCount = document().styleEngine().resolverAccessCount(); | 240 unsigned startCount = document().styleEngine().styleForElementCount(); |
241 | 241 |
242 document().getElementById("d")->focus(); | 242 document().getElementById("d")->focus(); |
243 document().view()->updateAllLifecyclePhases(); | 243 document().view()->updateAllLifecyclePhases(); |
244 | 244 |
245 unsigned accessCount = document().styleEngine().resolverAccessCount() - star
tCount; | 245 unsigned elementCount = document().styleEngine().styleForElementCount() - st
artCount; |
246 | 246 |
247 ASSERT_EQ(11U, accessCount); | 247 ASSERT_EQ(11U, elementCount); |
248 } | 248 } |
249 | 249 |
250 TEST_F(AffectedByFocusTest, InvalidationSetFocusUpdate) | 250 TEST_F(AffectedByFocusTest, InvalidationSetFocusUpdate) |
251 { | 251 { |
252 // Check that when focussing the outer div in the document below, you get a | 252 // Check that when focussing the outer div in the document below, you get a |
253 // style recalc for the outer div and the class=a div only. | 253 // style recalc for the outer div and the class=a div only. |
254 | 254 |
255 setHtmlInnerHTML("<style>:focus .a { border: 1px solid lime; }</style>" | 255 setHtmlInnerHTML("<style>:focus .a { border: 1px solid lime; }</style>" |
256 "<div id=d tabIndex=1>" | 256 "<div id=d tabIndex=1>" |
257 "<div></div>" | 257 "<div></div>" |
258 "<div></div>" | 258 "<div></div>" |
259 "<div></div>" | 259 "<div></div>" |
260 "<div></div>" | 260 "<div></div>" |
261 "<div></div>" | 261 "<div></div>" |
262 "<div></div>" | 262 "<div></div>" |
263 "<div></div>" | 263 "<div></div>" |
264 "<div></div>" | 264 "<div></div>" |
265 "<div></div>" | 265 "<div></div>" |
266 "<div class='a'></div>" | 266 "<div class='a'></div>" |
267 "</div>"); | 267 "</div>"); |
268 | 268 |
269 document().view()->updateAllLifecyclePhases(); | 269 document().view()->updateAllLifecyclePhases(); |
270 | 270 |
271 unsigned startCount = document().styleEngine().resolverAccessCount(); | 271 unsigned startCount = document().styleEngine().styleForElementCount(); |
272 | 272 |
273 document().getElementById("d")->focus(); | 273 document().getElementById("d")->focus(); |
274 document().view()->updateAllLifecyclePhases(); | 274 document().view()->updateAllLifecyclePhases(); |
275 | 275 |
276 unsigned accessCount = document().styleEngine().resolverAccessCount() - star
tCount; | 276 unsigned elementCount = document().styleEngine().styleForElementCount() - st
artCount; |
277 | 277 |
278 ASSERT_EQ(2U, accessCount); | 278 ASSERT_EQ(2U, elementCount); |
279 } | 279 } |
280 | 280 |
281 TEST_F(AffectedByFocusTest, NoInvalidationSetFocusUpdate) | 281 TEST_F(AffectedByFocusTest, NoInvalidationSetFocusUpdate) |
282 { | 282 { |
283 // Check that when focussing the outer div in the document below, you get a | 283 // Check that when focussing the outer div in the document below, you get a |
284 // style recalc for the outer div only. The invalidation set for :focus will | 284 // style recalc for the outer div only. The invalidation set for :focus will |
285 // include 'a', but the id=d div should be affectedByFocus, not childrenOrSi
blingsAffectedByFocus. | 285 // include 'a', but the id=d div should be affectedByFocus, not childrenOrSi
blingsAffectedByFocus. |
286 | 286 |
287 setHtmlInnerHTML("<style>#nomatch:focus .a { border: 1px solid lime; }</styl
e>" | 287 setHtmlInnerHTML("<style>#nomatch:focus .a { border: 1px solid lime; }</styl
e>" |
288 "<div id=d tabIndex=1>" | 288 "<div id=d tabIndex=1>" |
289 "<div></div>" | 289 "<div></div>" |
290 "<div></div>" | 290 "<div></div>" |
291 "<div></div>" | 291 "<div></div>" |
292 "<div></div>" | 292 "<div></div>" |
293 "<div></div>" | 293 "<div></div>" |
294 "<div></div>" | 294 "<div></div>" |
295 "<div></div>" | 295 "<div></div>" |
296 "<div></div>" | 296 "<div></div>" |
297 "<div></div>" | 297 "<div></div>" |
298 "<div class='a'></div>" | 298 "<div class='a'></div>" |
299 "</div>"); | 299 "</div>"); |
300 | 300 |
301 document().view()->updateAllLifecyclePhases(); | 301 document().view()->updateAllLifecyclePhases(); |
302 | 302 |
303 unsigned startCount = document().styleEngine().resolverAccessCount(); | 303 unsigned startCount = document().styleEngine().styleForElementCount(); |
304 | 304 |
305 document().getElementById("d")->focus(); | 305 document().getElementById("d")->focus(); |
306 document().view()->updateAllLifecyclePhases(); | 306 document().view()->updateAllLifecyclePhases(); |
307 | 307 |
308 unsigned accessCount = document().styleEngine().resolverAccessCount() - star
tCount; | 308 unsigned elementCount = document().styleEngine().styleForElementCount() - st
artCount; |
309 | 309 |
310 ASSERT_EQ(1U, accessCount); | 310 ASSERT_EQ(1U, elementCount); |
311 } | 311 } |
312 | 312 |
313 } // namespace blink | 313 } // namespace blink |
OLD | NEW |