Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: Source/core/css/AffectedByFocusTest.cpp

Issue 975933002: Return reference from styleEngine() accessor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/core/css/DragUpdateTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/NodeLayoutStyle.h"
10 #include "core/dom/StyleEngine.h" 10 #include "core/dom/StyleEngine.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 "<div></div>" 203 "<div></div>"
204 "<div></div>" 204 "<div></div>"
205 "<div></div>" 205 "<div></div>"
206 "<div></div>" 206 "<div></div>"
207 "<div></div>" 207 "<div></div>"
208 "<div></div>" 208 "<div></div>"
209 "</div>"); 209 "</div>");
210 210
211 document().view()->updateLayoutAndStyleIfNeededRecursive(); 211 document().view()->updateLayoutAndStyleIfNeededRecursive();
212 212
213 unsigned startCount = document().styleEngine()->resolverAccessCount(); 213 unsigned startCount = document().styleEngine().resolverAccessCount();
214 214
215 document().getElementById("d")->focus(); 215 document().getElementById("d")->focus();
216 document().view()->updateLayoutAndStyleIfNeededRecursive(); 216 document().view()->updateLayoutAndStyleIfNeededRecursive();
217 217
218 unsigned accessCount = document().styleEngine()->resolverAccessCount() - sta rtCount; 218 unsigned accessCount = document().styleEngine().resolverAccessCount() - star tCount;
219 219
220 ASSERT_EQ(1U, accessCount); 220 ASSERT_EQ(1U, accessCount);
221 } 221 }
222 222
223 TEST_F(AffectedByFocusTest, ChildrenOrSiblingsAffectedByFocusUpdate) 223 TEST_F(AffectedByFocusTest, ChildrenOrSiblingsAffectedByFocusUpdate)
224 { 224 {
225 // Check that when focussing the outer div in the document below, you get a 225 // Check that when focussing the outer div in the document below, you get a
226 // style recalc for the whole subtree. 226 // style recalc for the whole subtree.
227 227
228 setHtmlInnerHTML("<style>:focus div { border: 1px solid lime; }</style>" 228 setHtmlInnerHTML("<style>:focus div { border: 1px solid lime; }</style>"
229 "<div id=d tabIndex=1>" 229 "<div id=d tabIndex=1>"
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></div>" 236 "<div></div>"
237 "<div></div>" 237 "<div></div>"
238 "<div></div>" 238 "<div></div>"
239 "<div></div>" 239 "<div></div>"
240 "</div>"); 240 "</div>");
241 241
242 document().view()->updateLayoutAndStyleIfNeededRecursive(); 242 document().view()->updateLayoutAndStyleIfNeededRecursive();
243 243
244 unsigned startCount = document().styleEngine()->resolverAccessCount(); 244 unsigned startCount = document().styleEngine().resolverAccessCount();
245 245
246 document().getElementById("d")->focus(); 246 document().getElementById("d")->focus();
247 document().view()->updateLayoutAndStyleIfNeededRecursive(); 247 document().view()->updateLayoutAndStyleIfNeededRecursive();
248 248
249 unsigned accessCount = document().styleEngine()->resolverAccessCount() - sta rtCount; 249 unsigned accessCount = document().styleEngine().resolverAccessCount() - star tCount;
250 250
251 ASSERT_EQ(11U, accessCount); 251 ASSERT_EQ(11U, accessCount);
252 } 252 }
253 253
254 TEST_F(AffectedByFocusTest, InvalidationSetFocusUpdate) 254 TEST_F(AffectedByFocusTest, InvalidationSetFocusUpdate)
255 { 255 {
256 // Check that when focussing the outer div in the document below, you get a 256 // Check that when focussing the outer div in the document below, you get a
257 // style recalc for the outer div and the class=a div only. 257 // style recalc for the outer div and the class=a div only.
258 258
259 setHtmlInnerHTML("<style>:focus .a { border: 1px solid lime; }</style>" 259 setHtmlInnerHTML("<style>:focus .a { border: 1px solid lime; }</style>"
260 "<div id=d tabIndex=1>" 260 "<div id=d tabIndex=1>"
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></div>" 266 "<div></div>"
267 "<div></div>" 267 "<div></div>"
268 "<div></div>" 268 "<div></div>"
269 "<div></div>" 269 "<div></div>"
270 "<div class='a'></div>" 270 "<div class='a'></div>"
271 "</div>"); 271 "</div>");
272 272
273 document().view()->updateLayoutAndStyleIfNeededRecursive(); 273 document().view()->updateLayoutAndStyleIfNeededRecursive();
274 274
275 unsigned startCount = document().styleEngine()->resolverAccessCount(); 275 unsigned startCount = document().styleEngine().resolverAccessCount();
276 276
277 document().getElementById("d")->focus(); 277 document().getElementById("d")->focus();
278 document().view()->updateLayoutAndStyleIfNeededRecursive(); 278 document().view()->updateLayoutAndStyleIfNeededRecursive();
279 279
280 unsigned accessCount = document().styleEngine()->resolverAccessCount() - sta rtCount; 280 unsigned accessCount = document().styleEngine().resolverAccessCount() - star tCount;
281 281
282 ASSERT_EQ(2U, accessCount); 282 ASSERT_EQ(2U, accessCount);
283 } 283 }
284 284
285 TEST_F(AffectedByFocusTest, NoInvalidationSetFocusUpdate) 285 TEST_F(AffectedByFocusTest, NoInvalidationSetFocusUpdate)
286 { 286 {
287 // Check that when focussing the outer div in the document below, you get a 287 // Check that when focussing the outer div in the document below, you get a
288 // style recalc for the outer div only. The invalidation set for :focus will 288 // style recalc for the outer div only. The invalidation set for :focus will
289 // include 'a', but the id=d div should be affectedByFocus, not childrenOrSi blingsAffectedByFocus. 289 // include 'a', but the id=d div should be affectedByFocus, not childrenOrSi blingsAffectedByFocus.
290 290
291 setHtmlInnerHTML("<style>#nomatch:focus .a { border: 1px solid lime; }</styl e>" 291 setHtmlInnerHTML("<style>#nomatch:focus .a { border: 1px solid lime; }</styl e>"
292 "<div id=d tabIndex=1>" 292 "<div id=d tabIndex=1>"
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></div>" 298 "<div></div>"
299 "<div></div>" 299 "<div></div>"
300 "<div></div>" 300 "<div></div>"
301 "<div></div>" 301 "<div></div>"
302 "<div class='a'></div>" 302 "<div class='a'></div>"
303 "</div>"); 303 "</div>");
304 304
305 document().view()->updateLayoutAndStyleIfNeededRecursive(); 305 document().view()->updateLayoutAndStyleIfNeededRecursive();
306 306
307 unsigned startCount = document().styleEngine()->resolverAccessCount(); 307 unsigned startCount = document().styleEngine().resolverAccessCount();
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() - sta rtCount; 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
OLDNEW
« no previous file with comments | « no previous file | Source/core/css/DragUpdateTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698