84 TDisplayMode mode = m_transparentPlugin ? EColor16MA : WebCore::StaticObjectsContainer::instance()->webSurface()->displayMode(); |
88 TDisplayMode mode = m_transparentPlugin ? EColor16MA : WebCore::StaticObjectsContainer::instance()->webSurface()->displayMode(); |
85 m_bitmap->Create(TSize(0,0), mode); |
89 m_bitmap->Create(TSize(0,0), mode); |
86 } |
90 } |
87 // Add the focus/foreground observer |
91 // Add the focus/foreground observer |
88 ControlEnv()->AddForegroundObserverL( *this ) ; |
92 ControlEnv()->AddForegroundObserverL( *this ) ; |
|
93 m_pluginHasBitmap = false; |
|
94 m_pausedBitmap = NULL; |
|
95 m_BitmapSupported = false; |
89 } |
96 } |
90 |
97 |
91 // ----------------------------------------------------------------------------- |
98 // ----------------------------------------------------------------------------- |
92 // PluginWin::~PluginWin |
99 // PluginWin::~PluginWin |
93 // Deconstructor. |
100 // Deconstructor. |
94 // ----------------------------------------------------------------------------- |
101 // ----------------------------------------------------------------------------- |
95 // |
102 // |
96 PluginWin::~PluginWin() |
103 PluginWin::~PluginWin() |
97 { |
104 { |
|
105 PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler(); |
|
106 |
|
107 int index = pluginHandler->getVisiblePlugins().Find(m_pluginskin); |
|
108 if (index != KErrNotFound) |
|
109 pluginHandler->getVisiblePlugins().Remove(index); |
98 |
110 |
99 TRAP_IGNORE( setPluginFocusL( EFalse ) ); |
111 TRAP_IGNORE( setPluginFocusL( EFalse ) ); |
100 |
112 |
101 // Remove the foreground observer |
113 // Remove the foreground observer |
102 ControlEnv()->RemoveForegroundObserver( *this ); |
114 ControlEnv()->RemoveForegroundObserver( *this ); |
103 delete m_bitmap; |
115 delete m_bitmap; |
|
116 if (m_pausedBitmap) |
|
117 { |
|
118 delete m_pausedBitmap; |
|
119 } |
104 } |
120 } |
105 |
121 |
106 // ----------------------------------------------------------------------------- |
122 // ----------------------------------------------------------------------------- |
107 // PluginWin::NewL |
123 // PluginWin::NewL |
108 // Two-phased constructor. |
124 // Two-phased constructor. |
706 m_notifier->NotifyL( MPluginNotifier::EPluginPause, (void*)0 ); |
750 m_notifier->NotifyL( MPluginNotifier::EPluginPause, (void*)0 ); |
707 } |
751 } |
708 } |
752 } |
709 } |
753 } |
710 |
754 |
|
755 TBool PluginWin::IsCollectBitmapSupported () |
|
756 { |
|
757 if(m_notifier) { |
|
758 m_BitmapSupported = m_notifier->NotifyL( MPluginNotifier::ECollectBitmapSupported, (void*)0 ) ; |
|
759 } |
|
760 return m_BitmapSupported; |
|
761 } |
|
762 |
|
763 |
|
764 void PluginWin::GetBitmapFromPlugin (bool status) |
|
765 { |
|
766 if(m_notifier) { |
|
767 if (status) { |
|
768 //if plugin fails to send bitmap even though the "ECollectBitmapSupported" |
|
769 CBrCtl* brCtl = control(m_pluginskin->frame()); |
|
770 WebView* view = brCtl->webView(); |
|
771 |
|
772 if(view && view->isPinchZoom()) |
|
773 m_PluginInvisibleOnPinchZoom = ETrue; |
|
774 m_notifier->NotifyL( MPluginNotifier::ECollectBitmap, (void*)1 ); |
|
775 |
|
776 //if Notify CollectBitmap failed to send bitmap to SetBitmapFromPlugin, |
|
777 //Then forcefully make the plugin window invisible for pinch zoom |
|
778 if(m_PluginInvisibleOnPinchZoom) |
|
779 { |
|
780 m_PluginInvisibleOnPinchZoom = EFalse; |
|
781 if (IsVisible()) |
|
782 { |
|
783 MakeVisible(false); |
|
784 } |
|
785 } |
|
786 } |
|
787 else { |
|
788 m_notifier->NotifyL( MPluginNotifier::ECollectBitmap, (void*)0 ); |
|
789 |
|
790 m_pluginHasBitmap = 0; |
|
791 if(m_pausedBitmap) |
|
792 { |
|
793 delete m_pausedBitmap; |
|
794 m_pausedBitmap = NULL; |
|
795 } |
|
796 } |
|
797 } |
|
798 } |
|
799 |
|
800 |
711 void PluginWin::HandlePointerEventFromPluginL(const TPointerEvent& aEvent) |
801 void PluginWin::HandlePointerEventFromPluginL(const TPointerEvent& aEvent) |
712 { |
802 { |
713 CBrCtl* brCtl = control(m_pluginskin->frame()); |
803 CBrCtl* brCtl = control(m_pluginskin->frame()); |
714 WebView* view = brCtl->webView(); |
804 WebView* view = brCtl->webView(); |
715 TPointerEvent event(aEvent); |
805 #ifdef BRDO_MULTITOUCH_ENABLED_FF |
|
806 if (aEvent.IsAdvancedPointerEvent()) { |
|
807 TAdvancedPointerEvent tadvp = *(static_cast<const TAdvancedPointerEvent *>(&aEvent)); |
|
808 if (!StaticObjectsContainer::instance()->isPluginFullscreen()) { |
|
809 tadvp.iPosition = aEvent.iPosition - view->PositionRelativeToScreen(); |
|
810 } |
|
811 view->pointerEventHandler()->HandlePointerEventL(tadvp); |
|
812 } |
|
813 else { |
|
814 #endif |
|
815 TPointerEvent event(aEvent); |
|
816 if (!StaticObjectsContainer::instance()->isPluginFullscreen()) { |
|
817 event.iPosition = aEvent.iPosition - view->PositionRelativeToScreen(); |
|
818 } |
|
819 view->pointerEventHandler()->HandlePointerEventL(event); |
|
820 #ifdef BRDO_MULTITOUCH_ENABLED_FF |
|
821 } |
|
822 #endif |
|
823 } |
|
824 |
|
825 |
|
826 TBool PluginWin::HandleGesture(const TStmGestureEvent& aEvent) |
|
827 { |
|
828 TBool ret = EFalse; |
716 |
829 |
717 if (!StaticObjectsContainer::instance()->isPluginFullscreen()) { |
830 TGestureEvent eventForPlugin; |
718 event.iPosition = aEvent.iPosition - view->PositionRelativeToScreen(); |
831 switch(aEvent.Code()) |
719 } |
832 { |
720 view->pointerEventHandler()->HandlePointerEventL(event); |
833 case EGestureUidUnknown : |
721 } |
834 eventForPlugin.SetCode(EGestureUnknown); |
722 |
835 break; |
723 |
836 case EGestureUidTouch : |
724 TBool PluginWin::HandleGesture(const TGestureEvent& aEvent) |
837 eventForPlugin.SetCode(EGestureStart); |
725 { |
838 break; |
726 TBool ret = EFalse; |
839 case EGestureUidTap : |
|
840 if(aEvent.Type() == ETapTypeSingle) |
|
841 eventForPlugin.SetCode(EGestureTap); |
|
842 else |
|
843 eventForPlugin.SetCode(EGestureDoubleTap); |
|
844 break; |
|
845 case EGestureUidLongPress : |
|
846 eventForPlugin.SetCode(EGestureLongTap); |
|
847 break; |
|
848 case EGestureUidPan : |
|
849 eventForPlugin.SetCode(EGestureDrag); |
|
850 break; |
|
851 case EGestureUidRelease : |
|
852 eventForPlugin.SetCode(EGestureReleased); |
|
853 break; |
|
854 case EGestureUidFlick : |
|
855 eventForPlugin.SetCode(EGestureFlick); |
|
856 break; |
|
857 case EGestureUidPinch : |
|
858 eventForPlugin.SetCode(EGesturePinch); |
|
859 break; |
|
860 default : |
|
861 break; |
|
862 |
|
863 } |
|
864 |
|
865 |
|
866 |
727 if (m_control) { |
867 if (m_control) { |
728 TGestureEvent gestEvent(aEvent); |
|
729 CBrCtl* brCtl = control(m_pluginskin->frame()); |
868 CBrCtl* brCtl = control(m_pluginskin->frame()); |
730 WebView* view = brCtl->webView(); |
869 WebView* view = brCtl->webView(); |
731 TPoint newPos = aEvent.CurrentPos(); |
870 TPoint newPos = aEvent.CurrentPos(); |
732 TPoint startPos = aEvent.StartPos(); |
871 // Not sure plugins need the start position of the gesture. Not inlcuded in the new struct |
|
872 TPoint startPos = aEvent.CurrentPos(); |
733 TPoint viewPos = view->PositionRelativeToScreen(); |
873 TPoint viewPos = view->PositionRelativeToScreen(); |
734 TPoint ctrlPos = m_control->PositionRelativeToScreen(); |
874 TPoint ctrlPos = m_control->PositionRelativeToScreen(); |
735 |
875 |
736 if (!StaticObjectsContainer::instance()->isPluginFullscreen()) { |
876 if (!StaticObjectsContainer::instance()->isPluginFullscreen()) { |
737 // adjust the position to make it relative to top left corner of |
877 // adjust the position to make it relative to top left corner of |
738 newPos += viewPos; |
878 newPos += viewPos; |
739 startPos += viewPos; |
879 startPos += viewPos; |
740 gestEvent.SetCurrentPos(newPos); |
880 } |
741 gestEvent.SetStartPos(startPos); |
881 eventForPlugin.SetCurrentPos(newPos); |
742 } |
882 eventForPlugin.SetStartPos(startPos); |
743 |
883 if (StaticObjectsContainer::instance()->isPluginFullscreen() || |
744 if (StaticObjectsContainer::instance()->isPluginFullscreen() || |
|
745 m_control->Rect().Contains(newPos - ctrlPos)) { |
884 m_control->Rect().Contains(newPos - ctrlPos)) { |
746 NPEvent event; |
885 NPEvent event; |
747 NPEventPointer ev; |
886 NPEventPointer ev; |
748 event.event = ENppEventPointer; |
887 event.event = ENppEventPointer; |
749 ev.reserved = &gestEvent; |
888 ev.reserved = &eventForPlugin; |
750 ev.pointerEvent = NULL; |
889 ev.pointerEvent = NULL; |
751 event.param = &ev; |
890 event.param = &ev; |
752 ret = m_pluginskin->getNPPluginFucs()->event(m_pluginskin->getNPP(), |
891 ret = m_pluginskin->getNPPluginFucs()->event(m_pluginskin->getNPP(), |
753 static_cast<void*>(&event)); |
892 static_cast<void*>(&event)); |
754 } |
893 } |
755 } |
894 } |
756 else if(!m_windowedPlugin && m_pluginskin->getNPPluginFucs() && m_pluginskin->getNPPluginFucs()->event){ |
895 else if(!m_windowedPlugin && m_pluginskin->getNPPluginFucs() && m_pluginskin->getNPPluginFucs()->event){ |
757 TRect cliprect = m_pluginskin->getClipRect(); |
896 TRect cliprect = m_pluginskin->getClipRect(); |
758 TPoint newpos = aEvent.CurrentPos(); |
897 TPoint newPos = aEvent.CurrentPos(); |
759 if(cliprect.Contains(newpos)){ |
898 eventForPlugin.SetCurrentPos(newPos); |
760 TGestureEvent gestEvent(aEvent); |
899 eventForPlugin.SetCurrentPos(newPos); |
|
900 |
|
901 if(cliprect.Contains(newPos)){ |
761 NPEvent event; |
902 NPEvent event; |
762 NPEventPointer ev; |
903 NPEventPointer ev; |
763 event.event = ENppEventPointer; |
904 event.event = ENppEventPointer; |
764 ev.reserved = &gestEvent; |
905 ev.reserved = &eventForPlugin; |
765 ev.pointerEvent = NULL; |
906 ev.pointerEvent = NULL; |
766 event.param = &ev; |
907 event.param = &ev; |
767 ret = m_pluginskin->getNPPluginFucs()->event(m_pluginskin->getNPP(), |
908 ret = m_pluginskin->getNPPluginFucs()->event(m_pluginskin->getNPP(), |
768 static_cast<void*>(&event)); |
909 static_cast<void*>(&event)); |
769 } |
910 } |
770 } |
911 } |
771 return ret; |
912 return ret; |
772 |
913 |
773 } |
914 } |
|
915 |
|
916 bool PluginWin::containsPoint(WebView& view, const TPoint& pt) |
|
917 { |
|
918 if (m_control) { |
|
919 if (StaticObjectsContainer::instance()->isPluginFullscreen()) { |
|
920 return true; |
|
921 } |
|
922 else { |
|
923 TPoint point = pt; |
|
924 TPoint viewPos = view.PositionRelativeToScreen(); |
|
925 TPoint ctrlPos = m_control->PositionRelativeToScreen(); |
|
926 point += viewPos; |
|
927 return m_control->Rect().Contains(point - ctrlPos); |
|
928 } |
|
929 } |
|
930 else |
|
931 return false; |
|
932 } |
|
933 // ----------------------------------------------------------------------------- |
|
934 // PluginWin::SetBitmapFromPlugin |
|
935 // Plugin video is captured in CFBsBitmap and handle is passed to plugin window |
|
936 // Duplicate the bitmap handle and use it to draw while Panning or Pinch zoom |
|
937 // ----------------------------------------------------------------------------- |
|
938 void PluginWin::SetBitmapFromPlugin(TInt aHandle) |
|
939 { |
|
940 m_PluginInvisibleOnPinchZoom = EFalse; |
|
941 |
|
942 if (aHandle) |
|
943 { |
|
944 if (m_pausedBitmap) |
|
945 { |
|
946 delete m_pausedBitmap; |
|
947 m_pausedBitmap = NULL; |
|
948 } |
|
949 m_pausedBitmap = new (ELeave) CFbsBitmap(); |
|
950 TInt dupStatus = m_pausedBitmap->Duplicate(aHandle); |
|
951 if(dupStatus == KErrNone) |
|
952 { |
|
953 m_pluginHasBitmap = true; |
|
954 |
|
955 |
|
956 if (IsVisible()) |
|
957 { |
|
958 MakeVisible(false); |
|
959 } |
|
960 //setPluginFocusL(false); |
|
961 drawBitmapToWebCoreContext(); |
|
962 } |
|
963 } |
|
964 else |
|
965 { |
|
966 if(m_pausedBitmap) |
|
967 { |
|
968 delete m_pausedBitmap; |
|
969 m_pausedBitmap = NULL; |
|
970 } |
|
971 m_pluginHasBitmap = false; |
|
972 } |
|
973 } |
|
974 |
|
975 void PluginWin::ClearPluginBitmap() |
|
976 { |
|
977 if(m_pausedBitmap) |
|
978 { |
|
979 delete m_pausedBitmap; |
|
980 m_pausedBitmap = NULL; |
|
981 m_pluginHasBitmap = false; //clearing plugin bitmap |
|
982 } |
|
983 } |
|
984 |
|
985 void PluginWin::drawBitmapToWebCoreContext() |
|
986 { |
|
987 CBrCtl* brCtl = control(m_pluginskin->frame()); |
|
988 WebView* view = brCtl->webView(); |
|
989 WebCoreGraphicsContext* context = view->getGraphicsContext(); |
|
990 CFbsBitGc& gc = context->gc(); |
|
991 TRect plWinRect(m_pluginskin->getPluginWinRect()); |
|
992 |
|
993 TRect oldcontextrect = context->clippingRect(); |
|
994 TRect clippingRect = context->clippingRect(); |
|
995 |
|
996 // save the gc state |
|
997 TWebCoreSavedContext saved(context->save()); |
|
998 |
|
999 if(plWinRect != clippingRect) |
|
1000 { |
|
1001 context->setClippingRect(plWinRect); |
|
1002 } |
|
1003 gc.DrawBitmap(plWinRect, m_pausedBitmap); |
|
1004 context->restore(saved); |
|
1005 } |
|
1006 |
|
1007 // Notify Plugins about the change in Access Point during Upgrade / Downgrade |
|
1008 void PluginWin::notifyAPChange(void* ap) |
|
1009 { |
|
1010 if (m_notifier) { |
|
1011 m_notifier->NotifyL( MPluginNotifier::EAccesPointChanged, ap ); |
|
1012 } |
|
1013 } |