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

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

Issue 1652093002: Support reviving a disposed plugin container. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename m_inDispose to m_isDisposed Created 4 years, 10 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/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 * Copyright (C) 2014 Opera Software ASA. All rights reserved. 3 * Copyright (C) 2014 Opera Software ASA. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 260
261 Widget::setParent(widget); 261 Widget::setParent(widget);
262 if (widget) 262 if (widget)
263 reportGeometry(); 263 reportGeometry();
264 else if (m_webPlugin) 264 else if (m_webPlugin)
265 m_webPlugin->containerDidDetachFromParent(); 265 m_webPlugin->containerDidDetachFromParent();
266 } 266 }
267 267
268 void WebPluginContainerImpl::setPlugin(WebPlugin* plugin) 268 void WebPluginContainerImpl::setPlugin(WebPlugin* plugin)
269 { 269 {
270 RELEASE_ASSERT(!m_inDispose); 270 if (plugin == m_webPlugin)
271 if (plugin != m_webPlugin) { 271 return;
272 m_element->resetInstance(); 272
273 m_webPlugin = plugin; 273 m_element->resetInstance();
274 } 274 m_webPlugin = plugin;
275 m_isDisposed = false;
275 } 276 }
276 277
277 float WebPluginContainerImpl::deviceScaleFactor() 278 float WebPluginContainerImpl::deviceScaleFactor()
278 { 279 {
279 Page* page = m_element->document().page(); 280 Page* page = m_element->document().page();
280 if (!page) 281 if (!page)
281 return 1.0; 282 return 1.0;
282 return page->deviceScaleFactor(); 283 return page->deviceScaleFactor();
283 } 284 }
284 285
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 FrameLoadRequest frameRequest(frame->document(), request.toResourceRequest() , target); 502 FrameLoadRequest frameRequest(frame->document(), request.toResourceRequest() , target);
502 frame->loader().load(frameRequest); 503 frame->loader().load(frameRequest);
503 } 504 }
504 505
505 bool WebPluginContainerImpl::isRectTopmost(const WebRect& rect) 506 bool WebPluginContainerImpl::isRectTopmost(const WebRect& rect)
506 { 507 {
507 // Disallow access to the frame during dispose(), because it is not guarante ed to 508 // Disallow access to the frame during dispose(), because it is not guarante ed to
508 // be valid memory once this object has started disposal. In particular, we might be being 509 // be valid memory once this object has started disposal. In particular, we might be being
509 // disposed because the frame has already be deleted and then something else dropped the 510 // disposed because the frame has already be deleted and then something else dropped the
510 // last reference to the this object. 511 // last reference to the this object.
511 if (m_inDispose || !m_element) 512 if (m_isDisposed || !m_element)
512 return false; 513 return false;
513 514
514 LocalFrame* frame = m_element->document().frame(); 515 LocalFrame* frame = m_element->document().frame();
515 if (!frame) 516 if (!frame)
516 return false; 517 return false;
517 518
518 IntRect documentRect(x() + rect.x, y() + rect.y, rect.width, rect.height); 519 IntRect documentRect(x() + rect.x, y() + rect.y, rect.width, rect.height);
519 // hitTestResultAtPoint() takes a padding rectangle. 520 // hitTestResultAtPoint() takes a padding rectangle.
520 // FIXME: We'll be off by 1 when the width or height is even. 521 // FIXME: We'll be off by 1 when the width or height is even.
521 LayoutPoint center = documentRect.center(); 522 LayoutPoint center = documentRect.center();
522 // Make the rect we're checking (the point surrounded by padding rects) cont ained inside the requested rect. (Note that -1/2 is 0.) 523 // Make the rect we're checking (the point surrounded by padding rects) cont ained inside the requested rect. (Note that -1/2 is 0.)
523 LayoutSize padding((documentRect.width() - 1) / 2, (documentRect.height() - 1) / 2); 524 LayoutSize padding((documentRect.width() - 1) / 2, (documentRect.height() - 1) / 2);
524 HitTestResult result = frame->eventHandler().hitTestResultAtPoint(center, Hi tTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ListBased, pad ding); 525 HitTestResult result = frame->eventHandler().hitTestResultAtPoint(center, Hi tTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ListBased, pad ding);
525 const HitTestResult::NodeSet& nodes = result.listBasedTestResult(); 526 const HitTestResult::NodeSet& nodes = result.listBasedTestResult();
526 if (nodes.size() != 1) 527 if (nodes.size() != 1)
527 return false; 528 return false;
528 return nodes.first().get() == m_element; 529 return nodes.first().get() == m_element;
529 } 530 }
530 531
531 void WebPluginContainerImpl::requestTouchEventType(TouchEventRequestType request Type) 532 void WebPluginContainerImpl::requestTouchEventType(TouchEventRequestType request Type)
532 { 533 {
533 if (m_touchEventRequestType == requestType) 534 if (m_touchEventRequestType == requestType || !m_element)
534 return; 535 return;
535 536
536 if (m_element->document().frameHost()) { 537 if (m_element->document().frameHost()) {
537 EventHandlerRegistry& registry = m_element->document().frameHost()->even tHandlerRegistry(); 538 EventHandlerRegistry& registry = m_element->document().frameHost()->even tHandlerRegistry();
538 if (requestType != TouchEventRequestTypeNone && m_touchEventRequestType == TouchEventRequestTypeNone) 539 if (requestType != TouchEventRequestTypeNone && m_touchEventRequestType == TouchEventRequestTypeNone)
539 registry.didAddEventHandler(*m_element, EventHandlerRegistry::TouchE vent); 540 registry.didAddEventHandler(*m_element, EventHandlerRegistry::TouchE vent);
540 else if (requestType == TouchEventRequestTypeNone && m_touchEventRequest Type != TouchEventRequestTypeNone) 541 else if (requestType == TouchEventRequestTypeNone && m_touchEventRequest Type != TouchEventRequestTypeNone)
541 registry.didRemoveEventHandler(*m_element, EventHandlerRegistry::Tou chEvent); 542 registry.didRemoveEventHandler(*m_element, EventHandlerRegistry::Tou chEvent);
542 } 543 }
543 m_touchEventRequestType = requestType; 544 m_touchEventRequestType = requestType;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 677
677 // Private methods ------------------------------------------------------------- 678 // Private methods -------------------------------------------------------------
678 679
679 WebPluginContainerImpl::WebPluginContainerImpl(HTMLPlugInElement* element, WebPl ugin* webPlugin) 680 WebPluginContainerImpl::WebPluginContainerImpl(HTMLPlugInElement* element, WebPl ugin* webPlugin)
680 : LocalFrameLifecycleObserver(element->document().frame()) 681 : LocalFrameLifecycleObserver(element->document().frame())
681 , m_element(element) 682 , m_element(element)
682 , m_webPlugin(webPlugin) 683 , m_webPlugin(webPlugin)
683 , m_webLayer(nullptr) 684 , m_webLayer(nullptr)
684 , m_touchEventRequestType(TouchEventRequestTypeNone) 685 , m_touchEventRequestType(TouchEventRequestTypeNone)
685 , m_wantsWheelEvents(false) 686 , m_wantsWheelEvents(false)
686 , m_inDispose(false) 687 , m_isDisposed(false)
687 { 688 {
688 #if ENABLE(OILPAN) 689 #if ENABLE(OILPAN)
689 ThreadState::current()->registerPreFinalizer(this); 690 ThreadState::current()->registerPreFinalizer(this);
690 #endif 691 #endif
691 } 692 }
692 693
693 WebPluginContainerImpl::~WebPluginContainerImpl() 694 WebPluginContainerImpl::~WebPluginContainerImpl()
694 { 695 {
695 #if ENABLE(OILPAN) 696 #if ENABLE(OILPAN)
696 // The plugin container must have been disposed of by now. 697 // The plugin container must have been disposed of by now.
697 ASSERT(!m_webPlugin); 698 ASSERT(!m_webPlugin);
698 #else 699 #else
699 dispose(); 700 dispose();
700 #endif 701 #endif
701 } 702 }
702 703
703 void WebPluginContainerImpl::dispose() 704 void WebPluginContainerImpl::dispose()
704 { 705 {
705 m_inDispose = true; 706 m_isDisposed = true;
706 707
707 if (m_element && m_touchEventRequestType != TouchEventRequestTypeNone && m_e lement->document().frameHost()) 708 requestTouchEventType(TouchEventRequestTypeNone);
708 m_element->document().frameHost()->eventHandlerRegistry().didRemoveEvent Handler(*m_element, EventHandlerRegistry::TouchEvent);
709 709
710 if (m_webPlugin) { 710 if (m_webPlugin) {
711 RELEASE_ASSERT(!m_webPlugin->container() || m_webPlugin->container() == this); 711 RELEASE_ASSERT(!m_webPlugin->container() || m_webPlugin->container() == this);
712 m_webPlugin->destroy(); 712 m_webPlugin->destroy();
713 m_webPlugin = nullptr; 713 m_webPlugin = nullptr;
714 } 714 }
715 715
716 if (m_webLayer) { 716 if (m_webLayer) {
717 GraphicsLayer::unregisterContentsLayer(m_webLayer); 717 GraphicsLayer::unregisterContentsLayer(m_webLayer);
718 m_webLayer = nullptr; 718 m_webLayer = nullptr;
719 } 719 }
720
721 m_element = nullptr;
722 } 720 }
723 721
724 DEFINE_TRACE(WebPluginContainerImpl) 722 DEFINE_TRACE(WebPluginContainerImpl)
725 { 723 {
726 visitor->trace(m_element); 724 visitor->trace(m_element);
727 LocalFrameLifecycleObserver::trace(visitor); 725 LocalFrameLifecycleObserver::trace(visitor);
728 PluginView::trace(visitor); 726 PluginView::trace(visitor);
729 } 727 }
730 728
731 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) 729 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event)
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 // frame view. 957 // frame view.
960 computeClipRectsForPlugin(m_element, windowRect, clipRect, unobscuredRec t); 958 computeClipRectsForPlugin(m_element, windowRect, clipRect, unobscuredRec t);
961 } 959 }
962 getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects); 960 getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects);
963 // Convert to the plugin position. 961 // Convert to the plugin position.
964 for (size_t i = 0; i < cutOutRects.size(); i++) 962 for (size_t i = 0; i < cutOutRects.size(); i++)
965 cutOutRects[i].move(-frameRect().x(), -frameRect().y()); 963 cutOutRects[i].move(-frameRect().x(), -frameRect().y());
966 } 964 }
967 965
968 } // namespace blink 966 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebPluginContainerImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698