OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "core/frame/FrameView.h" | 5 #include "core/frame/FrameView.h" |
6 #include "core/layout/api/LayoutViewItem.h" | 6 #include "core/layout/api/LayoutViewItem.h" |
7 #include "core/layout/compositing/CompositedLayerMapping.h" | 7 #include "core/layout/compositing/CompositedLayerMapping.h" |
8 #include "core/layout/compositing/PaintLayerCompositor.h" | 8 #include "core/layout/compositing/PaintLayerCompositor.h" |
9 #include "core/page/Page.h" | 9 #include "core/page/Page.h" |
10 #include "platform/graphics/CompositorMutableProperties.h" | 10 #include "platform/graphics/CompositorMutableProperties.h" |
11 #include "platform/graphics/CompositorMutation.h" | 11 #include "platform/graphics/CompositorMutation.h" |
12 #include "platform/graphics/GraphicsLayer.h" | 12 #include "platform/graphics/GraphicsLayer.h" |
13 #include "platform/testing/URLTestHelpers.h" | 13 #include "platform/testing/URLTestHelpers.h" |
14 #include "public/platform/Platform.h" | 14 #include "public/platform/Platform.h" |
15 #include "public/platform/WebLayer.h" | 15 #include "public/platform/WebLayer.h" |
16 #include "public/platform/WebLayerTreeView.h" | 16 #include "public/platform/WebLayerTreeView.h" |
17 #include "public/platform/WebURLLoaderMockFactory.h" | 17 #include "public/platform/WebURLLoaderMockFactory.h" |
18 #include "public/web/WebCache.h" | 18 #include "public/web/WebCache.h" |
19 #include "public/web/WebSettings.h" | 19 #include "public/web/WebSettings.h" |
20 #include "public/web/WebViewClient.h" | 20 #include "public/web/WebViewClient.h" |
21 #include "web/WebLocalFrameImpl.h" | 21 #include "web/WebLocalFrameImpl.h" |
22 #include "web/WebViewImpl.h" | 22 #include "web/WebViewImpl.h" |
23 #include "web/tests/FrameTestHelpers.h" | 23 #include "web/tests/FrameTestHelpers.h" |
24 #include "wtf/PtrUtil.h" | 24 #include "wtf/PtrUtil.h" |
25 #include <gtest/gtest.h> | 25 #include <gtest/gtest.h> |
26 #include <memory> | 26 #include <memory> |
27 | 27 |
28 namespace blink { | 28 namespace blink { |
29 | 29 |
30 typedef bool TestParamRootLayerScrolling; | |
30 class CompositorWorkerTest | 31 class CompositorWorkerTest |
31 : public testing::Test | 32 : public testing::Test |
32 , public testing::WithParamInterface<FrameTestHelpers::SettingOverrideFuncti on> | 33 , public testing::WithParamInterface<TestParamRootLayerScrolling> { |
33 , public FrameTestHelpers::SettingOverrider { | |
34 | 34 |
35 public: | 35 public: |
36 CompositorWorkerTest() | 36 CompositorWorkerTest() |
37 : m_baseURL("http://www.test.com/") | 37 : m_originalRootLayerScrollingEnabled(RuntimeEnabledFeatures::rootLayerS crollingEnabled()) |
38 , m_helper(this) | 38 , m_enableRootLayerScrolling(GetParam()) |
39 , m_originalCompositorWorkerEnabled(RuntimeEnabledFeatures::compositorWo rkerEnabled()) | |
40 , m_baseURL("http://www.test.com/") | |
39 { | 41 { |
42 RuntimeEnabledFeatures::setRootLayerScrollingEnabled(m_enableRootLayerSc rolling); | |
43 RuntimeEnabledFeatures::setCompositorWorkerEnabled(true); | |
40 } | 44 } |
41 | 45 |
42 void SetUp() override | 46 void SetUp() override |
43 { | 47 { |
44 RuntimeEnabledFeatures::setCompositorWorkerEnabled(true); | |
45 m_helper.initialize(true, nullptr, &m_mockWebViewClient, nullptr, &confi gureSettings); | 48 m_helper.initialize(true, nullptr, &m_mockWebViewClient, nullptr, &confi gureSettings); |
46 webViewImpl()->resize(IntSize(320, 240)); | 49 webViewImpl()->resize(IntSize(320, 240)); |
47 } | 50 } |
48 | 51 |
49 ~CompositorWorkerTest() override | 52 ~CompositorWorkerTest() override |
50 { | 53 { |
51 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); | 54 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); |
52 WebCache::clear(); | 55 WebCache::clear(); |
53 } | |
54 | 56 |
55 void overrideSettings(WebSettings *settings) override | 57 CHECK_EQ(m_enableRootLayerScrolling, RuntimeEnabledFeatures::rootLayerSc rollingEnabled()); |
56 { | 58 CHECK_EQ(true, RuntimeEnabledFeatures::compositorWorkerEnabled()); |
57 GetParam()(settings); | 59 RuntimeEnabledFeatures::setCompositorWorkerEnabled(m_originalCompositorW orkerEnabled); |
60 RuntimeEnabledFeatures::setRootLayerScrollingEnabled(m_originalRootLayer ScrollingEnabled); | |
esprehn
2016/08/25 23:59:24
more manual?
| |
58 } | 61 } |
59 | 62 |
60 void navigateTo(const String& url) | 63 void navigateTo(const String& url) |
61 { | 64 { |
62 FrameTestHelpers::loadFrame(webViewImpl()->mainFrame(), url.utf8().data( )); | 65 FrameTestHelpers::loadFrame(webViewImpl()->mainFrame(), url.utf8().data( )); |
63 } | 66 } |
64 | 67 |
65 void forceFullCompositingUpdate() | 68 void forceFullCompositingUpdate() |
66 { | 69 { |
67 webViewImpl()->updateAllLifecyclePhases(); | 70 webViewImpl()->updateAllLifecyclePhases(); |
68 } | 71 } |
69 | 72 |
70 void registerMockedHttpURLLoad(const std::string& fileName) | 73 void registerMockedHttpURLLoad(const std::string& fileName) |
71 { | 74 { |
72 URLTestHelpers::registerMockedURLFromBaseURL(m_baseURL, WebString::fromU TF8(fileName.c_str())); | 75 URLTestHelpers::registerMockedURLFromBaseURL(m_baseURL, WebString::fromU TF8(fileName.c_str())); |
73 } | 76 } |
74 | 77 |
75 WebLayer* getRootScrollLayer() | 78 WebLayer* getRootScrollLayer() |
76 { | 79 { |
77 Settings* settings = frame()->settings(); | 80 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
78 bool rootLayerScrolls = settings && settings->rootLayerScrolls(); | |
79 if (rootLayerScrolls) { | |
80 DCHECK(frame()); | 81 DCHECK(frame()); |
81 DCHECK(frame()->view()); | 82 DCHECK(frame()->view()); |
82 DCHECK(frame()->view()->layoutViewportScrollableArea()); | 83 DCHECK(frame()->view()->layoutViewportScrollableArea()); |
83 DCHECK(frame()->view()->layoutViewportScrollableArea()->layerForScro lling()); | 84 DCHECK(frame()->view()->layoutViewportScrollableArea()->layerForScro lling()); |
84 return frame()->view()->layoutViewportScrollableArea()->layerForScro lling()->platformLayer(); | 85 return frame()->view()->layoutViewportScrollableArea()->layerForScro lling()->platformLayer(); |
85 } | 86 } |
86 PaintLayerCompositor* compositor = frame()->contentLayoutItem().composit or(); | 87 PaintLayerCompositor* compositor = frame()->contentLayoutItem().composit or(); |
87 DCHECK(compositor); | 88 DCHECK(compositor); |
88 DCHECK(compositor->scrollLayer()); | 89 DCHECK(compositor->scrollLayer()); |
89 | 90 |
90 WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer(); | 91 WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer(); |
91 return webScrollLayer; | 92 return webScrollLayer; |
92 } | 93 } |
93 | 94 |
94 WebViewImpl* webViewImpl() const { return m_helper.webView(); } | 95 WebViewImpl* webViewImpl() const { return m_helper.webView(); } |
95 LocalFrame* frame() const { return m_helper.webView()->mainFrameImpl()->fram e(); } | 96 LocalFrame* frame() const { return m_helper.webView()->mainFrameImpl()->fram e(); } |
96 | 97 |
98 private: | |
99 bool m_originalRootLayerScrollingEnabled; | |
100 bool m_enableRootLayerScrolling; | |
101 bool m_originalCompositorWorkerEnabled; | |
102 | |
97 protected: | 103 protected: |
98 String m_baseURL; | 104 String m_baseURL; |
99 FrameTestHelpers::TestWebViewClient m_mockWebViewClient; | 105 FrameTestHelpers::TestWebViewClient m_mockWebViewClient; |
100 | 106 |
101 private: | 107 private: |
102 static void configureSettings(WebSettings* settings) | 108 static void configureSettings(WebSettings* settings) |
103 { | 109 { |
104 settings->setJavaScriptEnabled(true); | 110 settings->setJavaScriptEnabled(true); |
105 settings->setAcceleratedCompositingEnabled(true); | 111 settings->setAcceleratedCompositingEnabled(true); |
106 settings->setPreferCompositingToLCDTextEnabled(true); | 112 settings->setPreferCompositingToLCDTextEnabled(true); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 } | 147 } |
142 | 148 |
143 static WebLayer* webLayerFromElement(Element* element) | 149 static WebLayer* webLayerFromElement(Element* element) |
144 { | 150 { |
145 CompositedLayerMapping* compositedLayerMapping = mappingFromElement(element) ; | 151 CompositedLayerMapping* compositedLayerMapping = mappingFromElement(element) ; |
146 if (!compositedLayerMapping) | 152 if (!compositedLayerMapping) |
147 return nullptr; | 153 return nullptr; |
148 return webLayerFromGraphicsLayer(compositedLayerMapping->mainGraphicsLayer() ); | 154 return webLayerFromGraphicsLayer(compositedLayerMapping->mainGraphicsLayer() ); |
149 } | 155 } |
150 | 156 |
151 INSTANTIATE_TEST_CASE_P(All, CompositorWorkerTest, ::testing::Values( | 157 INSTANTIATE_TEST_CASE_P(All, CompositorWorkerTest, ::testing::Bool()); |
152 FrameTestHelpers::DefaultSettingOverride, | |
153 FrameTestHelpers::RootLayerScrollsSettingOverride)); | |
154 | 158 |
155 TEST_P(CompositorWorkerTest, plumbingElementIdAndMutableProperties) | 159 TEST_P(CompositorWorkerTest, plumbingElementIdAndMutableProperties) |
156 { | 160 { |
157 registerMockedHttpURLLoad("compositor-proxy-basic.html"); | 161 registerMockedHttpURLLoad("compositor-proxy-basic.html"); |
158 navigateTo(m_baseURL + "compositor-proxy-basic.html"); | 162 navigateTo(m_baseURL + "compositor-proxy-basic.html"); |
159 | 163 |
160 forceFullCompositingUpdate(); | 164 forceFullCompositingUpdate(); |
161 | 165 |
162 Document* document = frame()->document(); | 166 Document* document = frame()->document(); |
163 | 167 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 { | 328 { |
325 const String& transformValue = document->domWindow()->getComputedStyle( proxiedElement, String())->getPropertyValueInternal(CSSPropertyTransform); | 329 const String& transformValue = document->domWindow()->getComputedStyle( proxiedElement, String())->getPropertyValueInternal(CSSPropertyTransform); |
326 EXPECT_EQ("matrix3d(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41, 42, 43, 44)", transformValue); | 330 EXPECT_EQ("matrix3d(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41, 42, 43, 44)", transformValue); |
327 | 331 |
328 const String& opacityValue = document->domWindow()->getComputedStyle(pro xiedElement, String())->getPropertyValueInternal(CSSPropertyOpacity); | 332 const String& opacityValue = document->domWindow()->getComputedStyle(pro xiedElement, String())->getPropertyValueInternal(CSSPropertyOpacity); |
329 EXPECT_EQ("0.8", opacityValue); | 333 EXPECT_EQ("0.8", opacityValue); |
330 } | 334 } |
331 } | 335 } |
332 | 336 |
333 } // namespace blink | 337 } // namespace blink |
OLD | NEW |