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

Side by Side Diff: third_party/WebKit/Source/web/tests/FrameTestHelpers.cpp

Issue 2036403002: Always use the WebFrameWidget when attaching the root graphics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adding comments Created 4 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 else 85 else
86 testing::exitRunLoop(); 86 testing::exitRunLoop();
87 } 87 }
88 88
89 TestWebFrameClient* defaultWebFrameClient() 89 TestWebFrameClient* defaultWebFrameClient()
90 { 90 {
91 DEFINE_STATIC_LOCAL(TestWebFrameClient, client, ()); 91 DEFINE_STATIC_LOCAL(TestWebFrameClient, client, ());
92 return &client; 92 return &client;
93 } 93 }
94 94
95 TestWebWidgetClient* defaultWebWidgetClient()
96 {
97 DEFINE_STATIC_LOCAL(TestWebWidgetClient, client, ());
98 return &client;
99 }
100
95 TestWebViewClient* defaultWebViewClient() 101 TestWebViewClient* defaultWebViewClient()
96 { 102 {
97 DEFINE_STATIC_LOCAL(TestWebViewClient, client, ()); 103 DEFINE_STATIC_LOCAL(TestWebViewClient, client, ());
98 return &client; 104 return &client;
99 } 105 }
100 106
101 // |uniqueName| is normally calculated in a somewhat complicated way by the 107 // |uniqueName| is normally calculated in a somewhat complicated way by the
102 // FrameTree class, but for test purposes the approximation below should be 108 // FrameTree class, but for test purposes the approximation below should be
103 // close enough. 109 // close enough.
104 String nameToUniqueName(const String& name) 110 String nameToUniqueName(const String& name)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 WebMouseEvent result; 164 WebMouseEvent result;
159 result.type = type; 165 result.type = type;
160 result.x = result.windowX = result.globalX = point.x(); 166 result.x = result.windowX = result.globalX = point.x();
161 result.y = result.windowX = result.globalX = point.y(); 167 result.y = result.windowX = result.globalX = point.y();
162 result.modifiers = modifiers; 168 result.modifiers = modifiers;
163 result.button = button; 169 result.button = button;
164 result.clickCount = 1; 170 result.clickCount = 1;
165 return result; 171 return result;
166 } 172 }
167 173
168 WebLocalFrame* createLocalChild(WebRemoteFrame* parent, const WebString& name, W ebFrameClient* client, WebFrame* previousSibling, const WebFrameOwnerProperties& properties) 174 WebLocalFrame* createLocalChild(WebRemoteFrame* parent, const WebString& name, W ebFrameClient* client, WebWidgetClient* widgetClient, WebFrame* previousSibling, const WebFrameOwnerProperties& properties)
169 { 175 {
170 if (!client) 176 if (!client)
171 client = defaultWebFrameClient(); 177 client = defaultWebFrameClient();
172 178
173 return parent->createLocalChild(WebTreeScopeType::Document, name, nameToUniq ueName(name), WebSandboxFlags::None, client, previousSibling, properties, nullpt r); 179 WebLocalFrame* frame = parent->createLocalChild(WebTreeScopeType::Document, name, nameToUniqueName(name), WebSandboxFlags::None, client, previousSibling, pr operties, nullptr);
180
181 if (!widgetClient)
182 widgetClient = defaultWebWidgetClient();
183 WebFrameWidget::create(widgetClient, frame);
184
185 return frame;
174 } 186 }
175 187
176 WebRemoteFrame* createRemoteChild(WebRemoteFrame* parent, WebRemoteFrameClient* client, const WebString& name) 188 WebRemoteFrame* createRemoteChild(WebRemoteFrame* parent, WebRemoteFrameClient* client, const WebString& name)
177 { 189 {
178 return parent->createRemoteChild(WebTreeScopeType::Document, name, nameToUni queName(name), WebSandboxFlags::None, client, nullptr); 190 return parent->createRemoteChild(WebTreeScopeType::Document, name, nameToUni queName(name), WebSandboxFlags::None, client, nullptr);
179 } 191 }
180 192
181 WebViewHelper::WebViewHelper(SettingOverrider* settingOverrider) 193 WebViewHelper::WebViewHelper(SettingOverrider* settingOverrider)
182 : m_webView(nullptr) 194 : m_webView(nullptr)
183 , m_webViewWidget(nullptr)
184 , m_settingOverrider(settingOverrider) 195 , m_settingOverrider(settingOverrider)
185 { 196 {
186 } 197 }
187 198
188 WebViewHelper::~WebViewHelper() 199 WebViewHelper::~WebViewHelper()
189 { 200 {
190 reset(); 201 reset();
191 } 202 }
192 203
193 WebViewImpl* WebViewHelper::initializeWithOpener(WebFrame* opener, bool enableJa vascript, TestWebFrameClient* webFrameClient, TestWebViewClient* webViewClient, TestWebWidgetClient* webWidgetClient, void (*updateSettingsFunc)(WebSettings*)) 204 WebViewImpl* WebViewHelper::initializeWithOpener(WebFrame* opener, bool enableJa vascript, TestWebFrameClient* webFrameClient, TestWebViewClient* webViewClient, TestWebWidgetClient* webWidgetClient, void (*updateSettingsFunc)(WebSettings*))
(...skipping 20 matching lines...) Expand all
214 else 225 else
215 m_webView->settings()->setDeviceSupportsMouse(false); 226 m_webView->settings()->setDeviceSupportsMouse(false);
216 if (m_settingOverrider) 227 if (m_settingOverrider)
217 m_settingOverrider->overrideSettings(m_webView->settings()); 228 m_settingOverrider->overrideSettings(m_webView->settings());
218 m_webView->setDeviceScaleFactor(webViewClient->screenInfo().deviceScaleFacto r); 229 m_webView->setDeviceScaleFactor(webViewClient->screenInfo().deviceScaleFacto r);
219 m_webView->setDefaultPageScaleLimits(1, 4); 230 m_webView->setDefaultPageScaleLimits(1, 4);
220 WebLocalFrame* frame = WebLocalFrameImpl::create(WebTreeScopeType::Document, webFrameClient, opener); 231 WebLocalFrame* frame = WebLocalFrameImpl::create(WebTreeScopeType::Document, webFrameClient, opener);
221 m_webView->setMainFrame(frame); 232 m_webView->setMainFrame(frame);
222 // TODO(dcheng): The main frame widget currently has a special case. 233 // TODO(dcheng): The main frame widget currently has a special case.
223 // Eliminate this once WebView is no longer a WebWidget. 234 // Eliminate this once WebView is no longer a WebWidget.
224 m_webViewWidget = blink::WebFrameWidget::create(webWidgetClient, m_webView, frame); 235 blink::WebFrameWidget::create(webWidgetClient, m_webView, frame);
225 236
226 m_testWebViewClient = webViewClient; 237 m_testWebViewClient = webViewClient;
227 238
228 return m_webView; 239 return m_webView;
229 } 240 }
230 241
231 WebViewImpl* WebViewHelper::initialize(bool enableJavascript, TestWebFrameClient * webFrameClient, TestWebViewClient* webViewClient, TestWebWidgetClient* webWidg etClient, void (*updateSettingsFunc)(WebSettings*)) 242 WebViewImpl* WebViewHelper::initialize(bool enableJavascript, TestWebFrameClient * webFrameClient, TestWebViewClient* webViewClient, TestWebWidgetClient* webWidg etClient, void (*updateSettingsFunc)(WebSettings*))
232 { 243 {
233 return initializeWithOpener(nullptr, enableJavascript, webFrameClient, webVi ewClient, webWidgetClient, updateSettingsFunc); 244 return initializeWithOpener(nullptr, enableJavascript, webFrameClient, webVi ewClient, webWidgetClient, updateSettingsFunc);
234 } 245 }
235 246
236 WebViewImpl* WebViewHelper::initializeAndLoad(const std::string& url, bool enabl eJavascript, TestWebFrameClient* webFrameClient, TestWebViewClient* webViewClien t, TestWebWidgetClient* webWidgetClient, void (*updateSettingsFunc)(WebSettings* )) 247 WebViewImpl* WebViewHelper::initializeAndLoad(const std::string& url, bool enabl eJavascript, TestWebFrameClient* webFrameClient, TestWebViewClient* webViewClien t, TestWebWidgetClient* webWidgetClient, void (*updateSettingsFunc)(WebSettings* ))
237 { 248 {
238 initialize(enableJavascript, webFrameClient, webViewClient, webWidgetClient, updateSettingsFunc); 249 initialize(enableJavascript, webFrameClient, webViewClient, webWidgetClient, updateSettingsFunc);
239 250
240 loadFrame(webView()->mainFrame(), url); 251 loadFrame(webView()->mainFrame(), url);
241 252
242 return webViewImpl(); 253 return webViewImpl();
243 } 254 }
244 255
245 void WebViewHelper::reset() 256 void WebViewHelper::reset()
246 { 257 {
247 if (m_webViewWidget) {
248 m_webViewWidget->close();
249 m_webViewWidget = nullptr;
250 }
251 if (m_webView) { 258 if (m_webView) {
252 DCHECK(m_webView->mainFrame()->isWebRemoteFrame() || !testClientForFrame (m_webView->mainFrame())->isLoading()); 259 DCHECK(m_webView->mainFrame()->isWebRemoteFrame() || !testClientForFrame (m_webView->mainFrame())->isLoading());
253 m_webView->willCloseLayerTreeView(); 260 m_webView->willCloseLayerTreeView();
254 m_webView->close(); 261 m_webView->close();
255 m_webView = nullptr; 262 m_webView = nullptr;
256 } 263 }
257 } 264 }
258 265
259 void WebViewHelper::resize(WebSize size) 266 void WebViewHelper::resize(WebSize size)
260 { 267 {
261 m_testWebViewClient->clearAnimationScheduled(); 268 m_testWebViewClient->clearAnimationScheduled();
262 webViewImpl()->resize(size); 269 webViewImpl()->resize(size);
263 EXPECT_FALSE(m_testWebViewClient->animationScheduled()); 270 EXPECT_FALSE(m_testWebViewClient->animationScheduled());
264 m_testWebViewClient->clearAnimationScheduled(); 271 m_testWebViewClient->clearAnimationScheduled();
265 } 272 }
266 273
267 TestWebFrameClient::TestWebFrameClient() 274 TestWebFrameClient::TestWebFrameClient()
268 { 275 {
269 } 276 }
270 277
271 WebFrame* TestWebFrameClient::createChildFrame(WebLocalFrame* parent, WebTreeSco peType scope, const WebString& name, const WebString& uniqueName, WebSandboxFlag s sandboxFlags, const WebFrameOwnerProperties& frameOwnerProperties) 278 WebFrame* TestWebFrameClient::createChildFrame(WebLocalFrame* parent, WebTreeSco peType scope, const WebString& name, const WebString& uniqueName, WebSandboxFlag s sandboxFlags, const WebFrameOwnerProperties& frameOwnerProperties)
272 { 279 {
273 WebFrame* frame = WebLocalFrame::create(scope, this); 280 WebFrame* frame = WebLocalFrame::create(scope, this);
274 parent->appendChild(frame); 281 parent->appendChild(frame);
275 return frame; 282 return frame;
276 } 283 }
277 284
278 void TestWebFrameClient::frameDetached(WebFrame* frame, DetachType type) 285 void TestWebFrameClient::frameDetached(WebLocalFrame* frame, DetachType type)
279 { 286 {
280 if (type == DetachType::Remove && frame->parent()) 287 if (type == DetachType::Remove && frame->parent())
281 frame->parent()->removeChild(frame); 288 frame->parent()->removeChild(frame);
289
290 if (frame->frameWidget())
291 frame->frameWidget()->close();
292
282 frame->close(); 293 frame->close();
283 } 294 }
284 295
285 void TestWebFrameClient::didStartLoading(bool) 296 void TestWebFrameClient::didStartLoading(bool)
286 { 297 {
287 ++m_loadsInProgress; 298 ++m_loadsInProgress;
288 } 299 }
289 300
290 void TestWebFrameClient::didStopLoading() 301 void TestWebFrameClient::didStopLoading()
291 { 302 {
(...skipping 11 matching lines...) Expand all
303 if (type == DetachType::Remove && m_frame->parent()) 314 if (type == DetachType::Remove && m_frame->parent())
304 m_frame->parent()->removeChild(m_frame); 315 m_frame->parent()->removeChild(m_frame);
305 m_frame->close(); 316 m_frame->close();
306 } 317 }
307 318
308 void TestWebViewClient::initializeLayerTreeView() 319 void TestWebViewClient::initializeLayerTreeView()
309 { 320 {
310 m_layerTreeView = wrapUnique(new WebLayerTreeViewImplForTesting); 321 m_layerTreeView = wrapUnique(new WebLayerTreeViewImplForTesting);
311 } 322 }
312 323
324 void TestWebViewWidgetClient::initializeLayerTreeView()
325 {
326 m_testWebViewClient->initializeLayerTreeView();
327 }
328
329 WebLayerTreeView* TestWebViewWidgetClient::layerTreeView()
330 {
331 return m_testWebViewClient->layerTreeView();
332 }
333
334 void TestWebViewWidgetClient::scheduleAnimation()
335 {
336 m_testWebViewClient->scheduleAnimation();
337 }
338
313 } // namespace FrameTestHelpers 339 } // namespace FrameTestHelpers
314 } // namespace blink 340 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698