OLD | NEW |
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 Loading... |
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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
| 692 dispose(); |
| 693 #endif |
| 694 } |
| 695 |
| 696 void WebPluginContainerImpl::dispose() |
| 697 { |
704 if (m_touchEventRequestType != TouchEventRequestTypeNone && m_element->docum
ent().frameHost()) | 698 if (m_touchEventRequestType != TouchEventRequestTypeNone && m_element->docum
ent().frameHost()) |
705 m_element->document().frameHost()->eventHandlerRegistry().didRemoveEvent
Handler(*m_element, EventHandlerRegistry::TouchEvent); | 699 m_element->document().frameHost()->eventHandlerRegistry().didRemoveEvent
Handler(*m_element, EventHandlerRegistry::TouchEvent); |
706 #endif | |
707 | 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(); |
| 713 m_element = nullptr; |
715 } | 714 } |
716 | 715 |
717 #if ENABLE(OILPAN) | 716 void WebPluginContainerImpl::trace(Visitor* visitor) |
718 void WebPluginContainerImpl::detach() | |
719 { | 717 { |
720 if (m_touchEventRequestType != TouchEventRequestTypeNone && m_element->docum
ent().frameHost()) | 718 FrameDestructionObserver::trace(visitor); |
721 m_element->document().frameHost()->eventHandlerRegistry().didRemoveEvent
Handler(*m_element, EventHandlerRegistry::TouchEvent); | 719 PluginView::trace(visitor); |
722 | |
723 setWebLayer(0); | |
724 } | 720 } |
725 #endif | |
726 | 721 |
727 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) | 722 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) |
728 { | 723 { |
729 ASSERT(parent()->isFrameView()); | 724 ASSERT(parent()->isFrameView()); |
730 | 725 |
731 if (event->isDragEvent()) { | 726 if (event->isDragEvent()) { |
732 if (m_webPlugin->canProcessDrag()) | 727 if (m_webPlugin->canProcessDrag()) |
733 handleDragEvent(event); | 728 handleDragEvent(event); |
734 return; | 729 return; |
735 } | 730 } |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 | 957 |
963 return clipRect; | 958 return clipRect; |
964 } | 959 } |
965 | 960 |
966 bool WebPluginContainerImpl::pluginShouldPersist() const | 961 bool WebPluginContainerImpl::pluginShouldPersist() const |
967 { | 962 { |
968 return m_webPlugin->shouldPersist(); | 963 return m_webPlugin->shouldPersist(); |
969 } | 964 } |
970 | 965 |
971 } // namespace blink | 966 } // namespace blink |
OLD | NEW |