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

Unified Diff: Source/core/css/DragUpdateTest.cpp

Issue 140053005: Use LocalStyleChange for updating :-webkit-drag. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed review issue. Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/rendering/RenderObject.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/DragUpdateTest.cpp
diff --git a/Source/core/css/DragUpdateTest.cpp b/Source/core/css/DragUpdateTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5542887984e7b0dec9f6d5c52bd7fb0acebce525
--- /dev/null
+++ b/Source/core/css/DragUpdateTest.cpp
@@ -0,0 +1,69 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/dom/Element.h"
+#include "core/frame/FrameView.h"
+#include "core/html/HTMLDocument.h"
+#include "core/html/HTMLElement.h"
+#include "core/testing/DummyPageHolder.h"
+#include <gtest/gtest.h>
+
+using namespace WebCore;
+
+namespace {
+
+TEST(DragUpdateTest, AffectedByDragUpdate)
+{
+ // Check that when dragging the div in the document below, you only get a
+ // single element style recalc.
+
+ OwnPtr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
+ HTMLDocument* document = toHTMLDocument(&dummyPageHolder->document());
+ document->documentElement()->setInnerHTML("<style>div {width:100px;height:100px} div:-webkit-drag { background-color: green }</style>"
+ "<div>"
+ "<span></span>"
+ "<span></span>"
+ "<span></span>"
+ "<span></span>"
+ "</div>", ASSERT_NO_EXCEPTION);
+
+ document->view()->updateLayoutAndStyleIfNeededRecursive();
+ unsigned startCount = document->styleEngine()->resolverAccessCount();
+
+ document->documentElement()->renderer()->updateDragState(true);
+ document->view()->updateLayoutAndStyleIfNeededRecursive();
+
+ unsigned accessCount = document->styleEngine()->resolverAccessCount() - startCount;
+
+ ASSERT_EQ(1U, accessCount);
+}
+
+TEST(DragUpdateTest, ChildrenAffectedByDragUpdate)
+{
+ // Check that when dragging the div in the document below, you get a
+ // full subtree style recalc.
+
+ OwnPtr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
+ HTMLDocument* document = toHTMLDocument(&dummyPageHolder->document());
+ document->documentElement()->setInnerHTML("<style>div {width:100px;height:100px} div:-webkit-drag span { background-color: green }</style>"
+ "<div>"
+ "<span></span>"
+ "<span></span>"
+ "<span></span>"
+ "<span></span>"
+ "</div>", ASSERT_NO_EXCEPTION);
+
+ document->updateLayout();
+ unsigned startCount = document->styleEngine()->resolverAccessCount();
+
+ document->documentElement()->renderer()->updateDragState(true);
+ document->updateLayout();
+
+ unsigned accessCount = document->styleEngine()->resolverAccessCount() - startCount;
+
+ ASSERT_EQ(5U, accessCount);
+}
+
+} // namespace
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/rendering/RenderObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698