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

Side by Side Diff: Source/web/WebPluginContainerImpl.cpp

Issue 357443005: Oilpan: make shutdown of plugin container objects work better. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Have WebPluginContainerImpl be a FrameDestructionObserver Created 6 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
« no previous file with comments | « Source/web/WebPluginContainerImpl.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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 296
297 // If either of the layers is null we need to switch between hardware 297 // If either of the layers is null we need to switch between hardware
298 // and software compositing. 298 // and software compositing.
299 bool needsCompositingUpdate = !m_webLayer || !layer; 299 bool needsCompositingUpdate = !m_webLayer || !layer;
300 300
301 m_webLayer = layer; 301 m_webLayer = layer;
302 302
303 if (!needsCompositingUpdate) 303 if (!needsCompositingUpdate)
304 return; 304 return;
305 305
306 #if ENABLE(OILPAN)
307 if (!m_element)
308 return;
309 #endif
310
306 m_element->setNeedsCompositingUpdate(); 311 m_element->setNeedsCompositingUpdate();
307 // Being composited or not affects the self painting layer bit 312 // Being composited or not affects the self painting layer bit
308 // on the RenderLayer. 313 // on the RenderLayer.
309 if (RenderPart* renderer = m_element->renderPart()) { 314 if (RenderPart* renderer = m_element->renderPart()) {
310 ASSERT(renderer->hasLayer()); 315 ASSERT(renderer->hasLayer());
311 renderer->layer()->updateSelfPaintingLayer(); 316 renderer->layer()->updateSelfPaintingLayer();
312 } 317 }
313 } 318 }
314 319
315 bool WebPluginContainerImpl::supportsPaginatedPrint() const 320 bool WebPluginContainerImpl::supportsPaginatedPrint() const
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 m_scrollbarGroup->setFrameRect(frameRect()); 424 m_scrollbarGroup->setFrameRect(frameRect());
420 } 425 }
421 } 426 }
422 427
423 void WebPluginContainerImpl::allowScriptObjects() 428 void WebPluginContainerImpl::allowScriptObjects()
424 { 429 {
425 } 430 }
426 431
427 void WebPluginContainerImpl::clearScriptObjects() 432 void WebPluginContainerImpl::clearScriptObjects()
428 { 433 {
429 LocalFrame* frame = m_element->document().frame(); 434 if (!frame())
430 if (!frame)
431 return; 435 return;
432 frame->script().cleanupScriptObjectsForPlugin(this); 436
437 frame()->script().cleanupScriptObjectsForPlugin(this);
433 } 438 }
434 439
435 NPObject* WebPluginContainerImpl::scriptableObjectForElement() 440 NPObject* WebPluginContainerImpl::scriptableObjectForElement()
436 { 441 {
437 return m_element->getNPObject(); 442 return m_element->getNPObject();
438 } 443 }
439 444
440 WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popup sAllowed) 445 WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popup sAllowed)
441 { 446 {
442 LocalFrame* frame = m_element->document().frame(); 447 LocalFrame* frame = m_element->document().frame();
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 context->setFillColor(Color(0xCC, 0xCC, 0xCC)); 651 context->setFillColor(Color(0xCC, 0xCC, 0xCC));
647 context->fillRect(intersection(horizontalOverhangArea, dirtyRect)); 652 context->fillRect(intersection(horizontalOverhangArea, dirtyRect));
648 context->fillRect(intersection(verticalOverhangArea, dirtyRect)); 653 context->fillRect(intersection(verticalOverhangArea, dirtyRect));
649 context->restore(); 654 context->restore();
650 return true; 655 return true;
651 } 656 }
652 657
653 // Private methods ------------------------------------------------------------- 658 // Private methods -------------------------------------------------------------
654 659
655 WebPluginContainerImpl::WebPluginContainerImpl(WebCore::HTMLPlugInElement* eleme nt, WebPlugin* webPlugin) 660 WebPluginContainerImpl::WebPluginContainerImpl(WebCore::HTMLPlugInElement* eleme nt, WebPlugin* webPlugin)
656 : m_element(element) 661 : WebCore::FrameDestructionObserver(element->document().frame())
662 , m_element(element)
657 , m_webPlugin(webPlugin) 663 , m_webPlugin(webPlugin)
658 , m_webLayer(0) 664 , m_webLayer(0)
659 , m_touchEventRequestType(TouchEventRequestTypeNone) 665 , m_touchEventRequestType(TouchEventRequestTypeNone)
660 , m_wantsWheelEvents(false) 666 , m_wantsWheelEvents(false)
661 { 667 {
662 } 668 }
663 669
664 WebPluginContainerImpl::~WebPluginContainerImpl() 670 WebPluginContainerImpl::~WebPluginContainerImpl()
665 { 671 {
672 #if ENABLE(OILPAN)
673 // The element (and its document) are heap allocated and may
674 // have been finalized by now; unsafe to unregister the touch
675 // event handler at this stage.
676 //
677 // This is acceptable, as the widget will unregister itself if it
678 // is cleanly detached. If an explicit detach doesn't happen, this
679 // container is assumed to have died with the plugin element (and
680 // its document), hence no unregistration step is needed.
681 //
682 m_element = 0;
683 #else
666 if (m_touchEventRequestType != TouchEventRequestTypeNone) 684 if (m_touchEventRequestType != TouchEventRequestTypeNone)
667 m_element->document().didRemoveTouchEventHandler(m_element); 685 m_element->document().didRemoveTouchEventHandler(m_element);
686 #endif
668 687
669 for (size_t i = 0; i < m_pluginLoadObservers.size(); ++i) 688 for (size_t i = 0; i < m_pluginLoadObservers.size(); ++i)
670 m_pluginLoadObservers[i]->clearPluginContainer(); 689 m_pluginLoadObservers[i]->clearPluginContainer();
671 m_webPlugin->destroy(); 690 m_webPlugin->destroy();
672 if (m_webLayer) 691 if (m_webLayer)
673 GraphicsLayer::unregisterContentsLayer(m_webLayer); 692 GraphicsLayer::unregisterContentsLayer(m_webLayer);
674 } 693 }
675 694
695 #if ENABLE(OILPAN)
696 void WebPluginContainerImpl::detach()
697 {
698 if (m_touchEventRequestType != TouchEventRequestTypeNone)
699 m_element->document().didRemoveTouchEventHandler(m_element);
700
701 setWebLayer(0);
702 }
703 #endif
704
676 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) 705 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event)
677 { 706 {
678 ASSERT(parent()->isFrameView()); 707 ASSERT(parent()->isFrameView());
679 708
680 if (event->isDragEvent()) { 709 if (event->isDragEvent()) {
681 if (m_webPlugin->canProcessDrag()) 710 if (m_webPlugin->canProcessDrag())
682 handleDragEvent(event); 711 handleDragEvent(event);
683 return; 712 return;
684 } 713 }
685 714
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 940
912 return clipRect; 941 return clipRect;
913 } 942 }
914 943
915 bool WebPluginContainerImpl::pluginShouldPersist() const 944 bool WebPluginContainerImpl::pluginShouldPersist() const
916 { 945 {
917 return m_webPlugin->shouldPersist(); 946 return m_webPlugin->shouldPersist();
918 } 947 }
919 948
920 } // namespace blink 949 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebPluginContainerImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698