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

Side by Side Diff: third_party/WebKit/Source/web/WebPagePopupImpl.cpp

Issue 2737193002: Let PagePopupChromeClient schedule frames before attachRootGraphicsLayer. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/web/WebPagePopupImpl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 if (!paintRect.isEmpty()) 122 if (!paintRect.isEmpty())
123 m_popup->widgetClient()->didInvalidateRect(paintRect); 123 m_popup->widgetClient()->didInvalidateRect(paintRect);
124 } 124 }
125 125
126 void scheduleAnimation(FrameViewBase*) override { 126 void scheduleAnimation(FrameViewBase*) override {
127 // Calling scheduleAnimation on m_webView so WebViewTestProxy will call 127 // Calling scheduleAnimation on m_webView so WebViewTestProxy will call
128 // beginFrame. 128 // beginFrame.
129 if (LayoutTestSupport::isRunningLayoutTest()) 129 if (LayoutTestSupport::isRunningLayoutTest())
130 m_popup->m_webView->mainFrameImpl()->frameWidget()->scheduleAnimation(); 130 m_popup->m_webView->mainFrameImpl()->frameWidget()->scheduleAnimation();
131 131
132 if (m_popup->isAcceleratedCompositingActive()) { 132 if (m_popup->m_layerTreeView) {
133 DCHECK(m_popup->m_layerTreeView);
134 m_popup->m_layerTreeView->setNeedsBeginFrame(); 133 m_popup->m_layerTreeView->setNeedsBeginFrame();
135 return; 134 return;
136 } 135 }
137 m_popup->m_widgetClient->scheduleAnimation(); 136 m_popup->m_widgetClient->scheduleAnimation();
138 } 137 }
139 138
140 void attachCompositorAnimationTimeline(CompositorAnimationTimeline* timeline, 139 void attachCompositorAnimationTimeline(CompositorAnimationTimeline* timeline,
141 LocalFrame*) override { 140 LocalFrame*) override {
142 if (m_popup->m_animationHost) 141 if (m_popup->m_animationHost)
143 m_popup->m_animationHost->addTimeline(*timeline); 142 m_popup->m_animationHost->addTimeline(*timeline);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 frame->view()->setTransparent(false); 317 frame->view()->setTransparent(false);
319 if (AXObjectCache* cache = 318 if (AXObjectCache* cache =
320 m_popupClient->ownerElement().document().existingAXObjectCache()) 319 m_popupClient->ownerElement().document().existingAXObjectCache())
321 cache->childrenChanged(&m_popupClient->ownerElement()); 320 cache->childrenChanged(&m_popupClient->ownerElement());
322 321
323 DCHECK(frame->domWindow()); 322 DCHECK(frame->domWindow());
324 PagePopupSupplement::install(*frame, *this, m_popupClient); 323 PagePopupSupplement::install(*frame, *this, m_popupClient);
325 DCHECK_EQ(m_popupClient->ownerElement().document().existingAXObjectCache(), 324 DCHECK_EQ(m_popupClient->ownerElement().document().existingAXObjectCache(),
326 frame->document()->existingAXObjectCache()); 325 frame->document()->existingAXObjectCache());
327 326
327 initializeLayerTreeView();
328
328 RefPtr<SharedBuffer> data = SharedBuffer::create(); 329 RefPtr<SharedBuffer> data = SharedBuffer::create();
329 m_popupClient->writeDocument(data.get()); 330 m_popupClient->writeDocument(data.get());
330 frame->setPageZoomFactor(m_popupClient->zoomFactor()); 331 frame->setPageZoomFactor(m_popupClient->zoomFactor());
331 frame->loader().load(FrameLoadRequest( 332 frame->loader().load(FrameLoadRequest(
332 0, blankURL(), SubstituteData(data, "text/html", "UTF-8", KURL(), 333 0, blankURL(), SubstituteData(data, "text/html", "UTF-8", KURL(),
333 ForceSynchronousLoad))); 334 ForceSynchronousLoad)));
334 return true; 335 return true;
335 } 336 }
336 337
337 void WebPagePopupImpl::postMessage(const String& message) { 338 void WebPagePopupImpl::postMessage(const String& message) {
(...skipping 25 matching lines...) Expand all
363 } 364 }
364 365
365 void WebPagePopupImpl::setWindowRect(const IntRect& rectInScreen) { 366 void WebPagePopupImpl::setWindowRect(const IntRect& rectInScreen) {
366 widgetClient()->setWindowRect(rectInScreen); 367 widgetClient()->setWindowRect(rectInScreen);
367 } 368 }
368 369
369 void WebPagePopupImpl::setRootGraphicsLayer(GraphicsLayer* layer) { 370 void WebPagePopupImpl::setRootGraphicsLayer(GraphicsLayer* layer) {
370 m_rootGraphicsLayer = layer; 371 m_rootGraphicsLayer = layer;
371 m_rootLayer = layer ? layer->platformLayer() : 0; 372 m_rootLayer = layer ? layer->platformLayer() : 0;
372 373
373 setIsAcceleratedCompositingActive(layer); 374 m_isAcceleratedCompositingActive = !!layer;
374 if (m_layerTreeView) { 375 if (m_layerTreeView) {
375 if (m_rootLayer) { 376 if (m_rootLayer) {
376 m_layerTreeView->setRootLayer(*m_rootLayer); 377 m_layerTreeView->setRootLayer(*m_rootLayer);
377 } else { 378 } else {
378 m_layerTreeView->clearRootLayer(); 379 m_layerTreeView->clearRootLayer();
379 } 380 }
380 } 381 }
381 } 382 }
382 383
383 void WebPagePopupImpl::setIsAcceleratedCompositingActive(bool enter) { 384 void WebPagePopupImpl::initializeLayerTreeView() {
384 if (m_isAcceleratedCompositingActive == enter) 385 TRACE_EVENT0("blink", "WebPagePopupImpl::initializeLayerTreeView");
385 return; 386 m_layerTreeView = m_widgetClient->initializeLayerTreeView();
386 387 if (m_layerTreeView) {
387 if (!enter) { 388 m_layerTreeView->setVisible(true);
388 m_isAcceleratedCompositingActive = false; 389 m_animationHost = WTF::makeUnique<CompositorAnimationHost>(
389 } else if (m_layerTreeView) { 390 m_layerTreeView->compositorAnimationHost());
390 m_isAcceleratedCompositingActive = true; 391 m_page->layerTreeViewInitialized(*m_layerTreeView, nullptr);
391 } else { 392 } else {
392 TRACE_EVENT0("blink", 393 m_animationHost = nullptr;
393 "WebPagePopupImpl::setIsAcceleratedCompositingActive(true)");
394
395 m_layerTreeView = m_widgetClient->initializeLayerTreeView();
396 if (m_layerTreeView) {
397 m_layerTreeView->setVisible(true);
398 m_isAcceleratedCompositingActive = true;
399 m_animationHost = WTF::makeUnique<CompositorAnimationHost>(
400 m_layerTreeView->compositorAnimationHost());
401 m_page->layerTreeViewInitialized(*m_layerTreeView, nullptr);
402 } else {
403 m_isAcceleratedCompositingActive = false;
404 m_animationHost = nullptr;
405 }
406 } 394 }
407 } 395 }
408 396
409 void WebPagePopupImpl::beginFrame(double lastFrameTimeMonotonic) { 397 void WebPagePopupImpl::beginFrame(double lastFrameTimeMonotonic) {
410 if (!m_page) 398 if (!m_page)
411 return; 399 return;
412 // FIXME: This should use lastFrameTimeMonotonic but doing so 400 // FIXME: This should use lastFrameTimeMonotonic but doing so
413 // breaks tests. 401 // breaks tests.
414 PageWidgetDelegate::animate(*m_page, monotonicallyIncreasingTime()); 402 PageWidgetDelegate::animate(*m_page, monotonicallyIncreasingTime());
415 } 403 }
416 404
417 void WebPagePopupImpl::willCloseLayerTreeView() { 405 void WebPagePopupImpl::willCloseLayerTreeView() {
418 if (m_page && m_layerTreeView) 406 if (m_page && m_layerTreeView)
419 m_page->willCloseLayerTreeView(*m_layerTreeView, nullptr); 407 m_page->willCloseLayerTreeView(*m_layerTreeView, nullptr);
420 408
421 setIsAcceleratedCompositingActive(false); 409 m_isAcceleratedCompositingActive = false;
422 m_layerTreeView = nullptr; 410 m_layerTreeView = nullptr;
423 m_animationHost = nullptr; 411 m_animationHost = nullptr;
424 } 412 }
425 413
426 void WebPagePopupImpl::updateAllLifecyclePhases() { 414 void WebPagePopupImpl::updateAllLifecyclePhases() {
427 if (!m_page) 415 if (!m_page)
428 return; 416 return;
429 PageWidgetDelegate::updateAllLifecyclePhases( 417 PageWidgetDelegate::updateAllLifecyclePhases(
430 *m_page, *m_page->deprecatedLocalMainFrame()); 418 *m_page, *m_page->deprecatedLocalMainFrame());
431 } 419 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 // A WebPagePopupImpl instance usually has two references. 589 // A WebPagePopupImpl instance usually has two references.
602 // - One owned by the instance itself. It represents the visible widget. 590 // - One owned by the instance itself. It represents the visible widget.
603 // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the 591 // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the
604 // WebPagePopupImpl to close. 592 // WebPagePopupImpl to close.
605 // We need them because the closing operation is asynchronous and the widget 593 // We need them because the closing operation is asynchronous and the widget
606 // can be closed while the WebViewImpl is unaware of it. 594 // can be closed while the WebViewImpl is unaware of it.
607 return adoptRef(new WebPagePopupImpl(client)).leakRef(); 595 return adoptRef(new WebPagePopupImpl(client)).leakRef();
608 } 596 }
609 597
610 } // namespace blink 598 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebPagePopupImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698