| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 #include "HTMLNames.h" | |
| 7 #include "core/dom/Element.h" | |
| 8 #include "core/dom/ElementTraversal.h" | |
| 9 #include "core/frame/FrameView.h" | |
| 10 #include "core/frame/LocalFrame.h" | |
| 11 #include "core/html/HTMLDocument.h" | |
| 12 #include "core/html/HTMLElement.h" | |
| 13 #include "core/page/EventHandler.h" | |
| 14 #include "core/testing/DummyPageHolder.h" | |
| 15 #include "platform/PlatformMouseEvent.h" | |
| 16 #include <gtest/gtest.h> | |
| 17 | |
| 18 using namespace WebCore; | |
| 19 | |
| 20 namespace { | |
| 21 | |
| 22 TEST(HoverUpdateTest, AffectedByHoverUpdate) | |
| 23 { | |
| 24 // Check that when hovering the div in the document below, you only get a | |
| 25 // single element style recalc. | |
| 26 | |
| 27 OwnPtr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(IntSize(80
0, 600)); | |
| 28 HTMLDocument* document = toHTMLDocument(&dummyPageHolder->document()); | |
| 29 document->documentElement()->setInnerHTML("<style>div {width:100px;height:10
0px} div:hover { background-color: green }</style>" | |
| 30 "<div>" | |
| 31 "<span></span>" | |
| 32 "<span></span>" | |
| 33 "<span></span>" | |
| 34 "<span></span>" | |
| 35 "</div>", ASSERT_NO_EXCEPTION); | |
| 36 | |
| 37 document->view()->updateLayoutAndStyleIfNeededRecursive(); | |
| 38 unsigned startCount = document->styleEngine()->resolverAccessCount(); | |
| 39 | |
| 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); | |
| 42 document->view()->updateLayoutAndStyleIfNeededRecursive(); | |
| 43 | |
| 44 unsigned accessCount = document->styleEngine()->resolverAccessCount() - star
tCount; | |
| 45 | |
| 46 ASSERT_EQ(1U, accessCount); | |
| 47 } | |
| 48 | |
| 49 } // namespace | |
| OLD | NEW |