diff -r e1bea15f9a39 -r 79859ed3eea9 webengine/osswebengine/WebKit/s60/plugins/PluginWin.cpp --- a/webengine/osswebengine/WebKit/s60/plugins/PluginWin.cpp Thu Aug 19 10:58:56 2010 +0300 +++ b/webengine/osswebengine/WebKit/s60/plugins/PluginWin.cpp Tue Aug 31 16:17:46 2010 +0300 @@ -23,14 +23,14 @@ #include #include #include -#include +#include #include #include "WebFrame.h" #include "HttpDefs.h" -#include +#include "BrCtlDefs.h" #include "StaticObjectsContainer.h" -#include +#include #include "PluginWin.h" #include "PluginSkin.h" #include "PluginHandler.h" @@ -44,13 +44,9 @@ #include "WebPointerEventHandler.h" #include "WebPageScrollHandler.h" #include "WebKitLogger.h" -#include "WebCoreGraphicsContext.h" - -#include using namespace WebCore; using namespace RT_GestureHelper; -using namespace stmGesture; // CONSTANTS const TInt KPluginGranularity = 3; _LIT(KPath,"c:\\system\\temp\\"); @@ -68,7 +64,7 @@ // PluginWin::PluginWin(PluginSkin* pluginskin) : m_pluginskin(pluginskin) - , m_windowedPlugin(true), m_fullscreen(false), m_windowCreated(false), m_visibilty(false) + , m_windowedPlugin(true), m_fullscreen(false), m_windowCreated(false) { } @@ -90,9 +86,6 @@ } // Add the focus/foreground observer ControlEnv()->AddForegroundObserverL( *this ) ; - m_pluginHasBitmap = false; - m_pausedBitmap = NULL; - m_BitmapSupported = false; } // ----------------------------------------------------------------------------- @@ -102,21 +95,12 @@ // PluginWin::~PluginWin() { - PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler(); - - int index = pluginHandler->getVisiblePlugins().Find(m_pluginskin); - if (index != KErrNotFound) - pluginHandler->getVisiblePlugins().Remove(index); TRAP_IGNORE( setPluginFocusL( EFalse ) ); // Remove the foreground observer ControlEnv()->RemoveForegroundObserver( *this ); delete m_bitmap; - if (m_pausedBitmap) - { - delete m_pausedBitmap; - } } // ----------------------------------------------------------------------------- @@ -236,7 +220,6 @@ cursor->cursorUpdate(EFalse); consumed = ETrue; setPluginFocusL( ETrue ); - m_pluginskin->pluginFocusChanged(ETrue); } else @@ -289,16 +272,12 @@ ret = m_control->OfferKeyEventL( aKeyEvent, aType ); } else if (!m_windowedPlugin && m_pluginskin->getNPPluginFucs() && m_pluginskin->getNPPluginFucs()->event) { - WebCursor* c = StaticObjectsContainer::instance()->webCursor(); - TPoint pt = (c->position()); - pt = m_pluginskin->frame()->frameView()->viewCoordsInFrameCoords(pt); - pt -= m_pluginskin->rect().iTl; NPEvent event; NPEventKey eventKey; event.event = ENppEventKey; eventKey.keyEvent = &aKeyEvent; eventKey.type = aType; - eventKey.reserved = static_cast(&pt); + eventKey.reserved = NULL; event.param = &eventKey; ret = (TKeyResponse)m_pluginskin->getNPPluginFucs()->event(m_pluginskin->getNPP(), static_cast(&event)); } @@ -386,26 +365,10 @@ // void PluginWin::makeVisible( TBool visible ) { - WebView* view = control(m_pluginskin->frame())->webView(); - if(!view) - return; - - if((!m_pluginHasBitmap) && (IsVisible() != visible) && (!view->isPinchZoom())) + if(IsVisible() != visible) { CCoeControl::MakeVisible(visible); } - - PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler(); - int index = pluginHandler->getVisiblePlugins().Find(m_pluginskin); - if (visible && (m_visibilty != visible) && (index == KErrNotFound)) { - pluginHandler->getVisiblePlugins().AppendL(m_pluginskin); - m_visibilty = visible; - } - else if (!visible && (index != KErrNotFound)) { - pluginHandler->getVisiblePlugins().Remove(index); - m_visibilty = visible; - } - NotifyPluginVisible(visible); if (!m_windowedPlugin && m_pluginskin->getNPPluginFucs() && m_pluginskin->getNPPluginFucs()->event) { NPEvent event; @@ -490,11 +453,6 @@ void PluginWin::HandleGainingForeground() { if (m_notifier) { - if(m_pluginHasBitmap) - { - ClearPluginBitmap(); - m_pluginskin->activateVisiblePlugins(); - } TRAP_IGNORE(m_notifier->NotifyL(MPluginNotifier::EApplicationFocusChanged, (void*)1)); } } @@ -576,12 +534,11 @@ } else { WebFrame* mf = (m_pluginskin->frame()); - if (mf && mf->frameView()) { - WebFrameView* fv = mf->frameView(); - TRect rect(Rect()); - rect = TRect(fv->viewCoordsInFrameCoords(Rect().iTl), fv->viewCoordsInFrameCoords(Rect().iBr)); - fv->invalidateRect(rect, drawNow); - } + WebFrameView* fv = mf->frameView(); + TRect rect(Rect()); + rect = TRect(fv->viewCoordsInFrameCoords(Rect().iTl), fv->viewCoordsInFrameCoords(Rect().iBr)); + if (mf && mf->frameView()) + mf->frameView()->invalidateRect(rect, drawNow); } } @@ -609,7 +566,6 @@ TPoint newPos ((aOffset.iX * 100)/zoomlevel, (aOffset.iY * 100)/zoomlevel); c->offsetCursor( aOffset ); mf->frameView()->scrollTo(oldPos + newPos); - view->scrollStatus(false); c->cursorUpdate(EFalse); } @@ -752,124 +708,28 @@ } } -TBool PluginWin::IsCollectBitmapSupported () -{ - if(m_notifier) { - m_BitmapSupported = m_notifier->NotifyL( MPluginNotifier::ECollectBitmapSupported, (void*)0 ) ; - } - return m_BitmapSupported; -} - - -void PluginWin::GetBitmapFromPlugin (bool status) - { - if(m_notifier) { - if (status) { - //if plugin fails to send bitmap even though the "ECollectBitmapSupported" - CBrCtl* brCtl = control(m_pluginskin->frame()); - WebView* view = brCtl->webView(); - - if(view && view->isPinchZoom()) - m_PluginInvisibleOnPinchZoom = ETrue; - m_notifier->NotifyL( MPluginNotifier::ECollectBitmap, (void*)1 ); - - //if Notify CollectBitmap failed to send bitmap to SetBitmapFromPlugin, - //Then forcefully make the plugin window invisible for pinch zoom - if(m_PluginInvisibleOnPinchZoom) - { - m_PluginInvisibleOnPinchZoom = EFalse; - if (IsVisible()) - { - MakeVisible(false); - } - } - } - else { - m_notifier->NotifyL( MPluginNotifier::ECollectBitmap, (void*)0 ); - - m_pluginHasBitmap = 0; - if(m_pausedBitmap) - { - delete m_pausedBitmap; - m_pausedBitmap = NULL; - } - } - } -} - - void PluginWin::HandlePointerEventFromPluginL(const TPointerEvent& aEvent) { CBrCtl* brCtl = control(m_pluginskin->frame()); WebView* view = brCtl->webView(); -#ifdef BRDO_MULTITOUCH_ENABLED_FF - if (aEvent.IsAdvancedPointerEvent()) { - TAdvancedPointerEvent tadvp = *(static_cast(&aEvent)); - if (!StaticObjectsContainer::instance()->isPluginFullscreen()) { - tadvp.iPosition = aEvent.iPosition - view->PositionRelativeToScreen(); - } - view->pointerEventHandler()->HandlePointerEventL(tadvp); + TPointerEvent event(aEvent); + + if (!StaticObjectsContainer::instance()->isPluginFullscreen()) { + event.iPosition = aEvent.iPosition - view->PositionRelativeToScreen(); } - else { -#endif - TPointerEvent event(aEvent); - if (!StaticObjectsContainer::instance()->isPluginFullscreen()) { - event.iPosition = aEvent.iPosition - view->PositionRelativeToScreen(); - } - view->pointerEventHandler()->HandlePointerEventL(event); -#ifdef BRDO_MULTITOUCH_ENABLED_FF - } -#endif + view->pointerEventHandler()->HandlePointerEventL(event); } -TBool PluginWin::HandleGesture(const TStmGestureEvent& aEvent) +TBool PluginWin::HandleGesture(const TGestureEvent& aEvent) { TBool ret = EFalse; - - TGestureEvent eventForPlugin; - switch(aEvent.Code()) - { - case EGestureUidUnknown : - eventForPlugin.SetCode(EGestureUnknown); - break; - case EGestureUidTouch : - eventForPlugin.SetCode(EGestureStart); - break; - case EGestureUidTap : - if(aEvent.Type() == ETapTypeSingle) - eventForPlugin.SetCode(EGestureTap); - else - eventForPlugin.SetCode(EGestureDoubleTap); - break; - case EGestureUidLongPress : - eventForPlugin.SetCode(EGestureLongTap); - break; - case EGestureUidPan : - eventForPlugin.SetCode(EGestureDrag); - break; - case EGestureUidRelease : - eventForPlugin.SetCode(EGestureReleased); - break; - case EGestureUidFlick : - eventForPlugin.SetCode(EGestureFlick); - break; - case EGestureUidPinch : - eventForPlugin.SetCode(EGesturePinch); - break; - default : - break; - - } - - - if (m_control) { + TGestureEvent gestEvent(aEvent); CBrCtl* brCtl = control(m_pluginskin->frame()); WebView* view = brCtl->webView(); TPoint newPos = aEvent.CurrentPos(); - // Not sure plugins need the start position of the gesture. Not inlcuded in the new struct - TPoint startPos = aEvent.CurrentPos(); + TPoint startPos = aEvent.StartPos(); TPoint viewPos = view->PositionRelativeToScreen(); TPoint ctrlPos = m_control->PositionRelativeToScreen(); @@ -877,15 +737,16 @@ // adjust the position to make it relative to top left corner of newPos += viewPos; startPos += viewPos; + gestEvent.SetCurrentPos(newPos); + gestEvent.SetStartPos(startPos); } - eventForPlugin.SetCurrentPos(newPos); - eventForPlugin.SetStartPos(startPos); - if (StaticObjectsContainer::instance()->isPluginFullscreen() || + + if (StaticObjectsContainer::instance()->isPluginFullscreen() || m_control->Rect().Contains(newPos - ctrlPos)) { NPEvent event; NPEventPointer ev; event.event = ENppEventPointer; - ev.reserved = &eventForPlugin; + ev.reserved = &gestEvent; ev.pointerEvent = NULL; event.param = &ev; ret = m_pluginskin->getNPPluginFucs()->event(m_pluginskin->getNPP(), @@ -894,15 +755,13 @@ } else if(!m_windowedPlugin && m_pluginskin->getNPPluginFucs() && m_pluginskin->getNPPluginFucs()->event){ TRect cliprect = m_pluginskin->getClipRect(); - TPoint newPos = aEvent.CurrentPos(); - eventForPlugin.SetCurrentPos(newPos); - eventForPlugin.SetCurrentPos(newPos); - - if(cliprect.Contains(newPos)){ + TPoint newpos = aEvent.CurrentPos(); + if(cliprect.Contains(newpos)){ + TGestureEvent gestEvent(aEvent); NPEvent event; NPEventPointer ev; event.event = ENppEventPointer; - ev.reserved = &eventForPlugin; + ev.reserved = &gestEvent; ev.pointerEvent = NULL; event.param = &ev; ret = m_pluginskin->getNPPluginFucs()->event(m_pluginskin->getNPP(), @@ -912,102 +771,3 @@ return ret; } - -bool PluginWin::containsPoint(WebView& view, const TPoint& pt) -{ - if (m_control) { - if (StaticObjectsContainer::instance()->isPluginFullscreen()) { - return true; - } - else { - TPoint point = pt; - TPoint viewPos = view.PositionRelativeToScreen(); - TPoint ctrlPos = m_control->PositionRelativeToScreen(); - point += viewPos; - return m_control->Rect().Contains(point - ctrlPos); - } - } - else - return false; -} -// ----------------------------------------------------------------------------- -// PluginWin::SetBitmapFromPlugin -// Plugin video is captured in CFBsBitmap and handle is passed to plugin window -// Duplicate the bitmap handle and use it to draw while Panning or Pinch zoom -// ----------------------------------------------------------------------------- -void PluginWin::SetBitmapFromPlugin(TInt aHandle) - { - m_PluginInvisibleOnPinchZoom = EFalse; - - if (aHandle) - { - if (m_pausedBitmap) - { - delete m_pausedBitmap; - m_pausedBitmap = NULL; - } - m_pausedBitmap = new (ELeave) CFbsBitmap(); - TInt dupStatus = m_pausedBitmap->Duplicate(aHandle); - if(dupStatus == KErrNone) - { - m_pluginHasBitmap = true; - - - if (IsVisible()) - { - MakeVisible(false); - } - //setPluginFocusL(false); - drawBitmapToWebCoreContext(); - } - } - else - { - if(m_pausedBitmap) - { - delete m_pausedBitmap; - m_pausedBitmap = NULL; - } - m_pluginHasBitmap = false; - } - } - -void PluginWin::ClearPluginBitmap() - { - if(m_pausedBitmap) - { - delete m_pausedBitmap; - m_pausedBitmap = NULL; - m_pluginHasBitmap = false; //clearing plugin bitmap - } - } - -void PluginWin::drawBitmapToWebCoreContext() - { - CBrCtl* brCtl = control(m_pluginskin->frame()); - WebView* view = brCtl->webView(); - WebCoreGraphicsContext* context = view->getGraphicsContext(); - CFbsBitGc& gc = context->gc(); - TRect plWinRect(m_pluginskin->getPluginWinRect()); - - TRect oldcontextrect = context->clippingRect(); - TRect clippingRect = context->clippingRect(); - - // save the gc state - TWebCoreSavedContext saved(context->save()); - - if(plWinRect != clippingRect) - { - context->setClippingRect(plWinRect); - } - gc.DrawBitmap(plWinRect, m_pausedBitmap); - context->restore(saved); - } - -// Notify Plugins about the change in Access Point during Upgrade / Downgrade -void PluginWin::notifyAPChange(void* ap) -{ - if (m_notifier) { - m_notifier->NotifyL( MPluginNotifier::EAccesPointChanged, ap ); - } -}