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

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

Issue 220943002: Use invalidation sets for :hover, :active, and :focus. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased. Created 6 years, 8 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
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 "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/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 28 matching lines...) Expand all
39 39
40 PlatformMouseEvent moveEvent(IntPoint(20, 20), IntPoint(20, 20), NoButton, P latformEvent::MouseMoved, 0, false, false, false, false, currentTime()); 40 PlatformMouseEvent moveEvent(IntPoint(20, 20), IntPoint(20, 20), NoButton, P latformEvent::MouseMoved, 0, false, false, false, false, currentTime());
41 document->frame()->eventHandler().handleMouseMoveEvent(moveEvent); 41 document->frame()->eventHandler().handleMouseMoveEvent(moveEvent);
42 document->view()->updateLayoutAndStyleIfNeededRecursive(); 42 document->view()->updateLayoutAndStyleIfNeededRecursive();
43 43
44 unsigned accessCount = document->styleEngine()->resolverAccessCount() - star tCount; 44 unsigned accessCount = document->styleEngine()->resolverAccessCount() - star tCount;
45 45
46 ASSERT_EQ(1U, accessCount); 46 ASSERT_EQ(1U, accessCount);
47 } 47 }
48 48
49 TEST(HoverUpdateTest, ChildrenAffectedByHoverUpdate)
50 {
51 // Check that when hovering the div in the document below, you only get a
52 // style recalc for the hovered element and the class=a span. This requires
53 // supporting a descendant invalidation set for :hover.
54
55 OwnPtr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(IntSize(80 0, 600));
56 HTMLDocument* document = toHTMLDocument(&dummyPageHolder->document());
57 document->documentElement()->setInnerHTML("<style>div {width:100px;height:10 0px} div:hover .a { background-color: green }</style>"
58 "<div>"
59 "<span class='a'></span>"
60 "<span></span>"
61 "<span></span>"
esprehn 2014/04/04 22:48:27 Why not a regular layout test like we did for all
rune 2014/04/08 16:28:25 Because hover/active/focus changes are synchronous
rune 2014/04/10 12:42:12 I've landed removal of the synchronous update for
62 "<span></span>"
63 "</div>", ASSERT_NO_EXCEPTION);
64
65 document->view()->updateLayoutAndStyleIfNeededRecursive();
66 unsigned startCount = document->styleEngine()->resolverAccessCount();
67
68 PlatformMouseEvent moveEvent(IntPoint(20, 20), IntPoint(20, 20), NoButton, P latformEvent::MouseMoved, 0, false, false, false, false, currentTime());
69 document->frame()->eventHandler().handleMouseMoveEvent(moveEvent);
70 document->view()->updateLayoutAndStyleIfNeededRecursive();
71
72 unsigned accessCount = document->styleEngine()->resolverAccessCount() - star tCount;
73
74 ASSERT_EQ(2U, accessCount);
75 }
76
49 } // namespace 77 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698