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

Side by Side Diff: Source/web/tests/WebDocumentTest.cpp

Issue 290563007: Defer style recalc when inserting extension stylesheets. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Avoid Android crash Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/StyleEngine.cpp ('k') | Source/web/web.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
7 #include "public/web/WebDocument.h"
8
9 #include "CSSPropertyNames.h"
10 #include "core/dom/Document.h"
11 #include "core/dom/NodeRenderStyle.h"
12 #include "core/frame/LocalFrame.h"
13 #include "core/html/HTMLElement.h"
14 #include "core/rendering/style/RenderStyle.h"
15 #include "platform/graphics/Color.h"
16 #include "web/tests/FrameTestHelpers.h"
17
18 #include <gtest/gtest.h>
19
20 using WebCore::Color;
21 using WebCore::Document;
22 using WebCore::HTMLElement;
23 using WebCore::RenderStyle;
24 using blink::FrameTestHelpers::WebViewHelper;
25 using blink::WebDocument;
26
27 namespace {
28
29 TEST(WebDocumentTest, InsertStyleSheet)
30 {
31 WebViewHelper webViewHelper;
32 webViewHelper.initializeAndLoad("about:blank");
rune 2014/05/21 12:18:18 See https://code.google.com/p/chromium/issues/deta
33
34 WebDocument webDoc = webViewHelper.webView()->mainFrame()->document();
35 Document* coreDoc = webViewHelper.webViewImpl()->page()->mainFrame()->docume nt();
36
37 webDoc.insertStyleSheet("body { color: green }");
38
39 // Check insertStyleSheet did not cause a synchronous style recalc.
40 unsigned accessCount = coreDoc->styleEngine()->resolverAccessCount();
41 ASSERT_EQ(0U, accessCount);
42
43 HTMLElement* bodyElement = coreDoc->body();
44 ASSERT(bodyElement);
45
46 RenderStyle* style = bodyElement->renderStyle();
47 ASSERT(style);
48
49 // Inserted stylesheet not yet applied.
50 ASSERT_EQ(Color(0, 0, 0), style->visitedDependentColor(WebCore::CSSPropertyC olor));
51
52 // Apply inserted stylesheet.
53 coreDoc->updateRenderTreeIfNeeded();
54
55 style = bodyElement->renderStyle();
56 ASSERT(style);
57
58 // Inserted stylesheet applied.
59 ASSERT_EQ(Color(0, 128, 0), style->visitedDependentColor(WebCore::CSSPropert yColor));
60 }
61
62 }
OLDNEW
« no previous file with comments | « Source/core/dom/StyleEngine.cpp ('k') | Source/web/web.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698