| OLD | NEW |
| 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 | 6 |
| 7 #include "public/web/WebDocument.h" | 7 #include "public/web/WebDocument.h" |
| 8 | 8 |
| 9 #include "core/CSSPropertyNames.h" | 9 #include "core/CSSPropertyNames.h" |
| 10 #include "core/dom/NodeRenderStyle.h" | 10 #include "core/dom/NodeRenderStyle.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 webDoc.insertStyleSheet("body { color: green }"); | 35 webDoc.insertStyleSheet("body { color: green }"); |
| 36 | 36 |
| 37 // Check insertStyleSheet did not cause a synchronous style recalc. | 37 // Check insertStyleSheet did not cause a synchronous style recalc. |
| 38 unsigned accessCount = coreDoc->styleEngine()->resolverAccessCount(); | 38 unsigned accessCount = coreDoc->styleEngine()->resolverAccessCount(); |
| 39 ASSERT_EQ(0U, accessCount); | 39 ASSERT_EQ(0U, accessCount); |
| 40 | 40 |
| 41 HTMLElement* bodyElement = coreDoc->body(); | 41 HTMLElement* bodyElement = coreDoc->body(); |
| 42 ASSERT(bodyElement); | 42 ASSERT(bodyElement); |
| 43 | 43 |
| 44 RenderStyle* style = bodyElement->renderStyle(); | 44 const RenderStyle* style = bodyElement->renderStyle(); |
| 45 ASSERT(style); | 45 ASSERT(style); |
| 46 | 46 |
| 47 // Inserted stylesheet not yet applied. | 47 // Inserted stylesheet not yet applied. |
| 48 ASSERT_EQ(Color(0, 0, 0), style->visitedDependentColor(CSSPropertyColor)); | 48 ASSERT_EQ(Color(0, 0, 0), style->visitedDependentColor(CSSPropertyColor)); |
| 49 | 49 |
| 50 // Apply inserted stylesheet. | 50 // Apply inserted stylesheet. |
| 51 coreDoc->updateRenderTreeIfNeeded(); | 51 coreDoc->updateRenderTreeIfNeeded(); |
| 52 | 52 |
| 53 style = bodyElement->renderStyle(); | 53 style = bodyElement->renderStyle(); |
| 54 ASSERT(style); | 54 ASSERT(style); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 66 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + cssURL), WebString::f
romUTF8(cssURL)); | 66 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + cssURL), WebString::f
romUTF8(cssURL)); |
| 67 | 67 |
| 68 WebViewHelper webViewHelper; | 68 WebViewHelper webViewHelper; |
| 69 webViewHelper.initializeAndLoad(baseURL + htmlURL); | 69 webViewHelper.initializeAndLoad(baseURL + htmlURL); |
| 70 | 70 |
| 71 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 71 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 72 Document* coreDoc = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr
ame())->document(); | 72 Document* coreDoc = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr
ame())->document(); |
| 73 Element* transitionElement = coreDoc->getElementById("foo"); | 73 Element* transitionElement = coreDoc->getElementById("foo"); |
| 74 ASSERT(transitionElement); | 74 ASSERT(transitionElement); |
| 75 | 75 |
| 76 RenderStyle* transitionStyle = transitionElement->renderStyle(); | 76 const RenderStyle* transitionStyle = transitionElement->renderStyle(); |
| 77 ASSERT(transitionStyle); | 77 ASSERT(transitionStyle); |
| 78 | 78 |
| 79 HTMLElement* bodyElement = coreDoc->body(); | 79 HTMLElement* bodyElement = coreDoc->body(); |
| 80 ASSERT(bodyElement); | 80 ASSERT(bodyElement); |
| 81 | 81 |
| 82 RenderStyle* bodyStyle = bodyElement->renderStyle(); | 82 const RenderStyle* bodyStyle = bodyElement->renderStyle(); |
| 83 ASSERT(bodyStyle); | 83 ASSERT(bodyStyle); |
| 84 // The transition_exit.css stylesheet should not have been applied at this p
oint. | 84 // The transition_exit.css stylesheet should not have been applied at this p
oint. |
| 85 ASSERT_EQ(Color(0, 0, 0), bodyStyle->visitedDependentColor(CSSPropertyColor)
); | 85 ASSERT_EQ(Color(0, 0, 0), bodyStyle->visitedDependentColor(CSSPropertyColor)
); |
| 86 | 86 |
| 87 frame->document().beginExitTransition("#foo", false); | 87 frame->document().beginExitTransition("#foo", false); |
| 88 | 88 |
| 89 // Make sure the stylesheet load request gets processed. | 89 // Make sure the stylesheet load request gets processed. |
| 90 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame); | 90 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame); |
| 91 coreDoc->updateRenderTreeIfNeeded(); | 91 coreDoc->updateRenderTreeIfNeeded(); |
| 92 | 92 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 111 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + cssURL), WebString::f
romUTF8(cssURL)); | 111 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + cssURL), WebString::f
romUTF8(cssURL)); |
| 112 | 112 |
| 113 WebViewHelper webViewHelper; | 113 WebViewHelper webViewHelper; |
| 114 webViewHelper.initializeAndLoad(baseURL + htmlURL); | 114 webViewHelper.initializeAndLoad(baseURL + htmlURL); |
| 115 | 115 |
| 116 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 116 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 117 Document* coreDoc = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr
ame())->document(); | 117 Document* coreDoc = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr
ame())->document(); |
| 118 Element* transitionElement = coreDoc->getElementById("foo"); | 118 Element* transitionElement = coreDoc->getElementById("foo"); |
| 119 ASSERT(transitionElement); | 119 ASSERT(transitionElement); |
| 120 | 120 |
| 121 RenderStyle* transitionStyle = transitionElement->renderStyle(); | 121 const RenderStyle* transitionStyle = transitionElement->renderStyle(); |
| 122 ASSERT(transitionStyle); | 122 ASSERT(transitionStyle); |
| 123 | 123 |
| 124 HTMLElement* bodyElement = coreDoc->body(); | 124 HTMLElement* bodyElement = coreDoc->body(); |
| 125 ASSERT(bodyElement); | 125 ASSERT(bodyElement); |
| 126 | 126 |
| 127 RenderStyle* bodyStyle = bodyElement->renderStyle(); | 127 const RenderStyle* bodyStyle = bodyElement->renderStyle(); |
| 128 ASSERT(bodyStyle); | 128 ASSERT(bodyStyle); |
| 129 // The transition_exit.css stylesheet should not have been applied at this p
oint. | 129 // The transition_exit.css stylesheet should not have been applied at this p
oint. |
| 130 ASSERT_EQ(Color(0, 0, 0), bodyStyle->visitedDependentColor(CSSPropertyColor)
); | 130 ASSERT_EQ(Color(0, 0, 0), bodyStyle->visitedDependentColor(CSSPropertyColor)
); |
| 131 | 131 |
| 132 frame->document().beginExitTransition("#foo", true); | 132 frame->document().beginExitTransition("#foo", true); |
| 133 | 133 |
| 134 // Make sure the stylesheet load request gets processed. | 134 // Make sure the stylesheet load request gets processed. |
| 135 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame); | 135 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame); |
| 136 coreDoc->updateRenderTreeIfNeeded(); | 136 coreDoc->updateRenderTreeIfNeeded(); |
| 137 | 137 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 154 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + htmlURL), WebString::
fromUTF8(htmlURL)); | 154 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + htmlURL), WebString::
fromUTF8(htmlURL)); |
| 155 | 155 |
| 156 WebViewHelper webViewHelper; | 156 WebViewHelper webViewHelper; |
| 157 webViewHelper.initializeAndLoad(baseURL + htmlURL); | 157 webViewHelper.initializeAndLoad(baseURL + htmlURL); |
| 158 | 158 |
| 159 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 159 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 160 Document* coreDoc = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr
ame())->document(); | 160 Document* coreDoc = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr
ame())->document(); |
| 161 Element* transitionElement = coreDoc->getElementById("foo"); | 161 Element* transitionElement = coreDoc->getElementById("foo"); |
| 162 ASSERT(transitionElement); | 162 ASSERT(transitionElement); |
| 163 | 163 |
| 164 RenderStyle* transitionStyle = transitionElement->renderStyle(); | 164 const RenderStyle* transitionStyle = transitionElement->renderStyle(); |
| 165 ASSERT(transitionStyle); | 165 ASSERT(transitionStyle); |
| 166 EXPECT_EQ(transitionStyle->opacity(), 1); | 166 EXPECT_EQ(transitionStyle->opacity(), 1); |
| 167 | 167 |
| 168 // Hide transition elements | 168 // Hide transition elements |
| 169 frame->document().hideTransitionElements("#foo"); | 169 frame->document().hideTransitionElements("#foo"); |
| 170 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame); | 170 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame); |
| 171 coreDoc->updateRenderTreeIfNeeded(); | 171 coreDoc->updateRenderTreeIfNeeded(); |
| 172 transitionStyle = transitionElement->renderStyle(); | 172 transitionStyle = transitionElement->renderStyle(); |
| 173 ASSERT_TRUE(transitionStyle); | 173 ASSERT_TRUE(transitionStyle); |
| 174 EXPECT_EQ(transitionStyle->opacity(), 0); | 174 EXPECT_EQ(transitionStyle->opacity(), 0); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 200 ASSERT_FALSE(coreDoc->isTransitionDocument()); | 200 ASSERT_FALSE(coreDoc->isTransitionDocument()); |
| 201 | 201 |
| 202 frame->document().setIsTransitionDocument(true); | 202 frame->document().setIsTransitionDocument(true); |
| 203 ASSERT_TRUE(coreDoc->isTransitionDocument()); | 203 ASSERT_TRUE(coreDoc->isTransitionDocument()); |
| 204 | 204 |
| 205 frame->document().setIsTransitionDocument(false); | 205 frame->document().setIsTransitionDocument(false); |
| 206 ASSERT_FALSE(coreDoc->isTransitionDocument()); | 206 ASSERT_FALSE(coreDoc->isTransitionDocument()); |
| 207 } | 207 } |
| 208 | 208 |
| 209 } | 209 } |
| OLD | NEW |