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 |
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() | |
haraken
2014/09/29 14:16:37
Shall we clear m_element in dispose() ?
sof
2014/10/02 14:03:54
Done.
| |
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 FrameDestructionObserver::trace(visitor); | |
728 PluginView::trace(visitor); | |
729 } | |
730 | |
727 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) | 731 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) |
728 { | 732 { |
729 ASSERT(parent()->isFrameView()); | 733 ASSERT(parent()->isFrameView()); |
730 | 734 |
731 if (event->isDragEvent()) { | 735 if (event->isDragEvent()) { |
732 if (m_webPlugin->canProcessDrag()) | 736 if (m_webPlugin->canProcessDrag()) |
733 handleDragEvent(event); | 737 handleDragEvent(event); |
734 return; | 738 return; |
735 } | 739 } |
736 | 740 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
962 | 966 |
963 return clipRect; | 967 return clipRect; |
964 } | 968 } |
965 | 969 |
966 bool WebPluginContainerImpl::pluginShouldPersist() const | 970 bool WebPluginContainerImpl::pluginShouldPersist() const |
967 { | 971 { |
968 return m_webPlugin->shouldPersist(); | 972 return m_webPlugin->shouldPersist(); |
969 } | 973 } |
970 | 974 |
971 } // namespace blink | 975 } // namespace blink |
OLD | NEW |