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

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

Issue 603193005: Move the Widget hierarchy to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase upto and resolve r182737 conflict. Created 6 years, 2 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) 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 m_webPlugin->updateVisibility(false); 168 m_webPlugin->updateVisibility(false);
169 169
170 Widget::hide(); 170 Widget::hide();
171 } 171 }
172 172
173 void WebPluginContainerImpl::handleEvent(Event* event) 173 void WebPluginContainerImpl::handleEvent(Event* event)
174 { 174 {
175 if (!m_webPlugin->acceptsInputEvents()) 175 if (!m_webPlugin->acceptsInputEvents())
176 return; 176 return;
177 177
178 RefPtr<WebPluginContainerImpl> protector(this); 178 RefPtrWillBeRawPtr<WebPluginContainerImpl> protect(this);
179 // The events we pass are defined at: 179 // The events we pass are defined at:
180 // http://devedge-temp.mozilla.org/library/manuals/2002/plugin/1.0/struct ures5.html#1000000 180 // http://devedge-temp.mozilla.org/library/manuals/2002/plugin/1.0/struct ures5.html#1000000
181 // Don't take the documentation as truth, however. There are many cases 181 // Don't take the documentation as truth, however. There are many cases
182 // where mozilla behaves differently than the spec. 182 // where mozilla behaves differently than the spec.
183 if (event->isMouseEvent()) 183 if (event->isMouseEvent())
184 handleMouseEvent(toMouseEvent(event)); 184 handleMouseEvent(toMouseEvent(event));
185 else if (event->isWheelEvent()) 185 else if (event->isWheelEvent())
186 handleWheelEvent(toWheelEvent(event)); 186 handleWheelEvent(toWheelEvent(event));
187 else if (event->isKeyboardEvent()) 187 else if (event->isKeyboardEvent())
188 handleKeyboardEvent(toKeyboardEvent(event)); 188 handleKeyboardEvent(toKeyboardEvent(event));
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 if (!frame) 432 if (!frame)
433 return v8::Local<v8::Object>(); 433 return v8::Local<v8::Object>();
434 434
435 if (!frame->script().canExecuteScripts(NotAboutToExecuteScript)) 435 if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
436 return v8::Local<v8::Object>(); 436 return v8::Local<v8::Object>();
437 437
438 ScriptState* scriptState = ScriptState::forMainWorld(frame); 438 ScriptState* scriptState = ScriptState::forMainWorld(frame);
439 if (scriptState->contextIsValid()) 439 if (scriptState->contextIsValid())
440 return v8::Local<v8::Object>(); 440 return v8::Local<v8::Object>();
441 441
442 v8::Handle<v8::Value> v8value = toV8(m_element, scriptState->context()->Glob al(), scriptState->isolate()); 442 v8::Handle<v8::Value> v8value = toV8(m_element.get(), scriptState->context() ->Global(), scriptState->isolate());
443 ASSERT(v8value->IsObject()); 443 ASSERT(v8value->IsObject());
444 444
445 return v8::Handle<v8::Object>::Cast(v8value); 445 return v8::Handle<v8::Object>::Cast(v8value);
446 } 446 }
447 447
448 WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popup sAllowed) 448 WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popup sAllowed)
449 { 449 {
450 LocalFrame* frame = m_element->document().frame(); 450 LocalFrame* frame = m_element->document().frame();
451 if (!frame) 451 if (!frame)
452 return WebString(); 452 return WebString();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 context->setFillColor(Color(0xCC, 0xCC, 0xCC)); 667 context->setFillColor(Color(0xCC, 0xCC, 0xCC));
668 context->fillRect(intersection(horizontalOverhangArea, dirtyRect)); 668 context->fillRect(intersection(horizontalOverhangArea, dirtyRect));
669 context->fillRect(intersection(verticalOverhangArea, dirtyRect)); 669 context->fillRect(intersection(verticalOverhangArea, dirtyRect));
670 context->restore(); 670 context->restore();
671 return true; 671 return true;
672 } 672 }
673 673
674 // Private methods ------------------------------------------------------------- 674 // Private methods -------------------------------------------------------------
675 675
676 WebPluginContainerImpl::WebPluginContainerImpl(HTMLPlugInElement* element, WebPl ugin* webPlugin) 676 WebPluginContainerImpl::WebPluginContainerImpl(HTMLPlugInElement* element, WebPl ugin* webPlugin)
677 #if ENABLE(OILPAN)
678 : m_frame(element->document().frame())
679 #else
680 : FrameDestructionObserver(element->document().frame()) 677 : FrameDestructionObserver(element->document().frame())
681 #endif
682 , m_element(element) 678 , m_element(element)
683 , m_webPlugin(webPlugin) 679 , m_webPlugin(webPlugin)
684 , m_webLayer(0) 680 , m_webLayer(nullptr)
685 , m_touchEventRequestType(TouchEventRequestTypeNone) 681 , m_touchEventRequestType(TouchEventRequestTypeNone)
686 , m_wantsWheelEvents(false) 682 , m_wantsWheelEvents(false)
687 { 683 {
688 } 684 }
689 685
690 WebPluginContainerImpl::~WebPluginContainerImpl() 686 WebPluginContainerImpl::~WebPluginContainerImpl()
691 { 687 {
692 #if ENABLE(OILPAN) 688 #if ENABLE(OILPAN)
693 // The element (and its document) are heap allocated and may 689 // The plugin container must have been disposed of already.
694 // have been finalized by now; unsafe to unregister the touch 690 ASSERT(!m_webPlugin);
695 // event handler at this stage.
696 //
697 // This is acceptable, as the widget will unregister itself if it
698 // is cleanly detached. If an explicit detach doesn't happen, this
699 // container is assumed to have died with the plugin element (and
700 // its document), hence no unregistration step is needed.
701 //
702 m_element = 0;
703 #else 691 #else
704 if (m_touchEventRequestType != TouchEventRequestTypeNone && m_element->docum ent().frameHost()) 692 if (m_touchEventRequestType != TouchEventRequestTypeNone && m_element->docum ent().frameHost())
705 m_element->document().frameHost()->eventHandlerRegistry().didRemoveEvent Handler(*m_element, EventHandlerRegistry::TouchEvent); 693 m_element->document().frameHost()->eventHandlerRegistry().didRemoveEvent Handler(*m_element, EventHandlerRegistry::TouchEvent);
694
695 dispose();
706 #endif 696 #endif
697 }
707 698
699 void WebPluginContainerImpl::dispose()
700 {
708 ScriptForbiddenScope::AllowSuperUnsafeScript thisShouldBeRemoved; 701 ScriptForbiddenScope::AllowSuperUnsafeScript thisShouldBeRemoved;
709 702
710 for (size_t i = 0; i < m_pluginLoadObservers.size(); ++i) 703 for (size_t i = 0; i < m_pluginLoadObservers.size(); ++i)
711 m_pluginLoadObservers[i]->clearPluginContainer(); 704 m_pluginLoadObservers[i]->clearPluginContainer();
712 m_webPlugin->destroy(); 705 m_webPlugin->destroy();
706 m_webPlugin = nullptr;
707
713 if (m_webLayer) 708 if (m_webLayer)
714 GraphicsLayer::unregisterContentsLayer(m_webLayer); 709 GraphicsLayer::unregisterContentsLayer(m_webLayer);
710
711 m_pluginLoadObservers.clear();
712 m_scrollbarGroup.clear();
715 } 713 }
716 714
717 #if ENABLE(OILPAN) 715 #if ENABLE(OILPAN)
718 void WebPluginContainerImpl::detach() 716 void WebPluginContainerImpl::detach()
719 { 717 {
720 if (m_touchEventRequestType != TouchEventRequestTypeNone && m_element->docum ent().frameHost()) 718 if (m_touchEventRequestType != TouchEventRequestTypeNone && m_element->docum ent().frameHost())
721 m_element->document().frameHost()->eventHandlerRegistry().didRemoveEvent Handler(*m_element, EventHandlerRegistry::TouchEvent); 719 m_element->document().frameHost()->eventHandlerRegistry().didRemoveEvent Handler(*m_element, EventHandlerRegistry::TouchEvent);
722 720
723 setWebLayer(0); 721 setWebLayer(0);
724 } 722 }
725 #endif 723 #endif
726 724
725 void WebPluginContainerImpl::trace(Visitor* visitor)
726 {
727 visitor->trace(m_element);
728 FrameDestructionObserver::trace(visitor);
729 PluginView::trace(visitor);
730 }
731
727 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) 732 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event)
728 { 733 {
729 ASSERT(parent()->isFrameView()); 734 ASSERT(parent()->isFrameView());
730 735
731 if (event->isDragEvent()) { 736 if (event->isDragEvent()) {
732 if (m_webPlugin->canProcessDrag()) 737 if (m_webPlugin->canProcessDrag())
733 handleDragEvent(event); 738 handleDragEvent(event);
734 return; 739 return;
735 } 740 }
736 741
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 967
963 return clipRect; 968 return clipRect;
964 } 969 }
965 970
966 bool WebPluginContainerImpl::pluginShouldPersist() const 971 bool WebPluginContainerImpl::pluginShouldPersist() const
967 { 972 {
968 return m_webPlugin->shouldPersist(); 973 return m_webPlugin->shouldPersist();
969 } 974 }
970 975
971 } // namespace blink 976 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698