webengine/osswebengine/WebKit/s60/webview/WebFrame.cpp
branchRCL_3
changeset 49 919f36ff910f
parent 48 79859ed3eea9
equal deleted inserted replaced
48:79859ed3eea9 49:919f36ff910f
    39 
    39 
    40 #include "HTMLNames.h"
    40 #include "HTMLNames.h"
    41 #include "GraphicsContext.h"
    41 #include "GraphicsContext.h"
    42 #include "HTMLFormElement.h"
    42 #include "HTMLFormElement.h"
    43 #include "ResourceRequest.h"
    43 #include "ResourceRequest.h"
    44 #include "WebKitLogger.h"
    44 #include "webkitlogger.h"
    45 #include "WebUtil.h"
    45 #include "webutil.h"
    46 #include "PluginSkin.h"
    46 #include "PluginSkin.h"
    47 #include "PluginHandler.h"
    47 #include "PluginHandler.h"
    48 #include "kjs_proxy.h"
    48 #include "kjs_proxy.h"
    49 #if PLATFORM(SYMBIAN)
    49 #if PLATFORM(SYMBIAN)
    50 #include "oom.h"
    50 #include "oom.h"
   278 DocumentLoader* WebFrame::documentLoader()
   278 DocumentLoader* WebFrame::documentLoader()
   279 {
   279 {
   280     return frameLoader()->documentLoader();
   280     return frameLoader()->documentLoader();
   281 }
   281 }
   282 
   282 
   283 void WebFrame::notifyPluginsOfScrolling()
   283 void WebFrame::notifyPluginsOfPositionChange()
   284 {
   284 {    
   285     setpluginToScroll(true);
   285     PluginHandler* plghandler = StaticObjectsContainer::instance()->pluginHandler();
   286     Frame* coreFrame = core(this);
   286     WTF::HashSet<PluginSkin*> pluginObjs = plghandler->pluginObjects();
   287     for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) {
   287     for(WTF::HashSet<PluginSkin*>::iterator it = pluginObjs.begin() ;  it != pluginObjs.end() ; ++it ) {
   288         PassRefPtr<HTMLCollection> objects = frame->document()->objects();       
   288         PluginSkin* plg = static_cast<PluginSkin*> (*it);
   289         for (Node* n = objects->firstItem(); n; n = objects->nextItem()) 
   289         WebFrame* plgWebFrame = plg->getWebFrame();
   290             notifyPluginOfScrolling(n->renderer());             
   290         CBrCtl*   plbrCtl = control(plg->frame());
   291 
   291         CBrCtl*   pgbrCtl = control(this);
   292         PassRefPtr<HTMLCollection> embeds = frame->document()->embeds();       
   292 
   293         for (Node* n = embeds->firstItem(); n; n = embeds->nextItem()) 
   293         if(plbrCtl == pgbrCtl)
   294             notifyPluginOfScrolling(n->renderer()); 
   294             {
   295 
   295             notifyPluginOfPositionChange(static_cast<PluginSkin*> (*it));   
   296         }
   296             }
   297     setpluginToScroll(false);
   297     }
   298 }
   298 }
   299 
   299 
   300 void WebFrame::notifyPluginOfScrolling(RenderObject* renderer)
   300 void WebFrame::notifyPluginOfPositionChange(PluginSkin* plg)
   301 {        
   301 {        
   302     MWebCoreObjectWidget* view = widget(renderer);
       
   303     //Don't repaint the plugin objects if Browser is in PageView mode
   302     //Don't repaint the plugin objects if Browser is in PageView mode
   304     if (view) {
   303     if (plg) {
   305         view->positionChanged();
   304         plg->positionChanged();
   306         TRect r = m_view->toDocCoords(static_cast<PluginSkin*>(view)->getPluginWinRect());
   305         TRect r = m_view->toDocCoords(plg->getPluginWinRect());
   307         m_view->topView()->scheduleRepaint(r);
   306         m_view->topView()->scheduleRepaint(r);
   308     }
   307     }
   309 }
   308 }
   310 
   309 
   311 PluginSkin* WebFrame::focusedPlugin()
   310 PluginSkin* WebFrame::focusedPlugin()
   443     return frame->bridge()->frame();
   442     return frame->bridge()->frame();
   444 }
   443 }
   445 
   444 
   446 WebFrame* kit(Frame* frame)
   445 WebFrame* kit(Frame* frame)
   447 {
   446 {
   448     return frame ? ((WebFrameBridge *)frame->bridge())->webFrame(): NULL;
   447     if( frame && frame->bridge() )    
       
   448     	return  ((WebFrameBridge *)frame->bridge())->webFrame();
       
   449     return NULL;	
   449 }
   450 }
   450 
   451 
   451 WebView *kit(Page* page)
   452 WebView *kit(Page* page)
   452 {
   453 {
   453     return page ? static_cast<WebChromeClient*>(page->chrome()->client())->webView() : 0;
   454     return page ? static_cast<WebChromeClient*>(page->chrome()->client())->webView() : 0;
   514     }
   515     }
   515     return result;
   516     return result;
   516 }
   517 }
   517 
   518 
   518 void WebFrame::makeVisiblePlugins(TBool visible)
   519 void WebFrame::makeVisiblePlugins(TBool visible)
   519 {
   520 {    
   520     MWebCoreObjectWidget* view = NULL;
   521     MWebCoreObjectWidget* view = NULL;  
   521     int pluginCount = 0;
   522     Frame* coreFrame = core(this); 
   522     Frame* coreFrame = core(this);
   523     PluginSkin* plg = 0; 
   523     PluginSkin* ptr = 0;
   524     for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) { 
   524     for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) {
   525     
   525 
   526         PassRefPtr<HTMLCollection> objects = frame->document()->objects();      
   526         PassRefPtr<HTMLCollection> objects = frame->document()->objects();     
   527         for (Node* n = objects->firstItem(); n; n = objects->nextItem()) { 
   527         for (Node* n = objects->firstItem(); n; n = objects->nextItem()) {
   528             view = widget(n);  
       
   529             if (view) { 
       
   530                 plg = static_cast<PluginSkin*>(view); 
       
   531                 plg->makeVisible(visible);
       
   532             } 
       
   533         } 
       
   534         PassRefPtr<HTMLCollection> embeds = frame->document()->embeds();        
       
   535         for (Node* n = embeds->firstItem(); n; n = embeds->nextItem()) { 
   528             view = widget(n); 
   536             view = widget(n); 
   529             if (view) {
   537             if (view) { 
   530                 ptr = static_cast<PluginSkin*>(view);
   538                 plg = static_cast<PluginSkin*>(view); 
   531                 ptr->makeVisible(visible);
   539                 plg->makeVisible(visible);
   532             }
   540             } 
   533         }
       
   534         PassRefPtr<HTMLCollection> embeds = frame->document()->embeds();       
       
   535         for (Node* n = embeds->firstItem(); n; n = embeds->nextItem()) {
       
   536             view = widget(n);
       
   537             if (view) {
       
   538                 ptr = static_cast<PluginSkin*>(view);
       
   539                 ptr->makeVisible(visible);
       
   540             }
       
   541         }
   541         }
   542     }
   542     }
   543 }
   543 }
   544 
   544 
   545 
   545 
   557 {
   557 {
   558     IntPoint pt = m_view->viewCoordsInFrameCoords(viewPt);
   558     IntPoint pt = m_view->viewCoordsInFrameCoords(viewPt);
   559     
   559     
   560     Frame* coreFrame = core(this);
   560     Frame* coreFrame = core(this);
   561 
   561 
   562 	int dist = 99999999;
   562 	unsigned int dist = 0xFFFFFFFF;
   563 	Node* result = 0;
   563 	Node* result = 0;
   564 	//for (Node* n=links->firstItem(); n; n=links->nextItem()) {
   564 	//for (Node* n=links->firstItem(); n; n=links->nextItem()) {
   565 	for(Node* n = coreFrame->document(); n != 0; n = n->traverseNextNode()) {
   565 	for(Node* n = coreFrame->document(); n != 0; n = n->traverseNextNode()) {
   566         if(n->isFocusable() || n->hasTagName(areaTag)) {
   566         if(n->isFocusable() || n->hasTagName(areaTag)) {
   567 			IntRect r = n->getRect();
   567 			IntRect r = n->getRect();
   571 				break;
   571 				break;
   572 			}
   572 			}
   573 			
   573 			
   574 			int x = xInRect(r, pt.x());
   574 			int x = xInRect(r, pt.x());
   575 			int y = yInRect(r, pt.y());
   575 			int y = yInRect(r, pt.y());
   576 			int d = (pt.x() - x) * (pt.x() - x) + (pt.y() - y) * (pt.y() - y);
   576 			unsigned int d = (pt.x() - x) * (pt.x() - x) + (pt.y() - y) * (pt.y() - y);
   577 			if (dist > d) {
   577 			if (dist > d) {
   578 				dist = d;
   578 				dist = d;
   579 				result = n;
   579 				result = n;
   580 			}
   580 			}
   581         }
   581         }
   582 	}
   582 	}
   583 	
   583 	
   584     // check if we are close enough and calcualte with zoom factor. 
   584     // check if we are close enough and calcualte with zoom factor. 
   585     if (dist< (400/m_view->topView()->scalingFactor() * 100)) {
   585     if (result && dist< (400/m_view->topView()->scalingFactor() * 100)) {
   586         IntRect r = result->getRect();
   586         IntRect r = result->getRect();
   587         r.inflate(-2);
   587         r.inflate(-2);
   588         TPoint docPos(xInRect(r, pt.x()), yInRect(r, pt.y()));
   588         TPoint docPos(xInRect(r, pt.x()), yInRect(r, pt.y()));
   589         newPos = m_view->frameCoordsInViewCoords(docPos);
   589         newPos = m_view->frameCoordsInViewCoords(docPos);
   590         return result;        
   590         return result;        
   591     }
   591     }
   592     
   592     
   593     return 0;
   593     return 0;
   594 }
   594 }
   595 
   595 
       
   596 void WebFrame::ScrollOrPinchStatus(bool status)
       
   597 {
       
   598     PluginHandler* plghandler = StaticObjectsContainer::instance()->pluginHandler();
       
   599        WTF::HashSet<PluginSkin*> pluginObjs = plghandler->pluginObjects();
       
   600        for(WTF::HashSet<PluginSkin*>::iterator it = pluginObjs.begin() ;  it != pluginObjs.end() ; ++it )
       
   601            {
       
   602            PluginSkin* plg = static_cast<PluginSkin*> (*it);
       
   603            WebFrame* plgWebFrame = plg->getWebFrame();
       
   604            CBrCtl*   plbrCtl = control(plg->frame());
       
   605            CBrCtl*   pgbrCtl = control(this);
       
   606 
       
   607            if(plbrCtl == pgbrCtl)
       
   608                {
       
   609                plg->NotifyPluginsForScrollOrPinch(status);
       
   610                }
       
   611        }
       
   612 
       
   613 
       
   614 }
       
   615 
       
   616 void WebFrame::notifyPluginFocusChangeEvent(TBool visible)
       
   617 {
       
   618     MWebCoreObjectWidget* view = NULL;  
       
   619     Frame* coreFrame = core(this); 
       
   620     
       
   621     for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) { 
       
   622    
       
   623         PassRefPtr<HTMLCollection> objects = frame->document()->objects();      
       
   624         for (Node* n = objects->firstItem(); n; n = objects->nextItem()) { 
       
   625             view = widget(n);  
       
   626             if (view && static_cast<PluginSkin*>(view)->isFlashPlugin()) { 
       
   627                 if(visible)
       
   628                     static_cast<PluginSkin*>(view)->HandleGainingForeground();
       
   629                 else
       
   630                     static_cast<PluginSkin*>(view)->HandleLosingForeground();
       
   631             } 
       
   632         } 
       
   633         
       
   634         PassRefPtr<HTMLCollection> embeds = frame->document()->embeds();        
       
   635         for (Node* n = embeds->firstItem(); n; n = embeds->nextItem()) { 
       
   636             view = widget(n); 
       
   637             if (view && static_cast<PluginSkin*>(view)->isFlashPlugin()) { 
       
   638                 if(visible)
       
   639                     static_cast<PluginSkin*>(view)->HandleGainingForeground();
       
   640                 else
       
   641                     static_cast<PluginSkin*>(view)->HandleLosingForeground();
       
   642             } 
       
   643         }
       
   644     }
       
   645         
       
   646 }
       
   647 
       
   648 void WebFrame::reCreatePlugins()
       
   649 {
       
   650     MWebCoreObjectWidget* view = NULL;  
       
   651     Frame* coreFrame = core(this); 
       
   652     PluginSkin* plg = 0; 
       
   653     for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) { 
       
   654    
       
   655         PassRefPtr<HTMLCollection> objects = frame->document()->objects();      
       
   656         for (Node* n = objects->firstItem(); n; n = objects->nextItem()) { 
       
   657             view = widget(n);  
       
   658             if (view) { 
       
   659                 plg = static_cast<PluginSkin*>(view); 
       
   660                 plg->reCreatePlugin(); 
       
   661             } 
       
   662         } 
       
   663         PassRefPtr<HTMLCollection> embeds = frame->document()->embeds();        
       
   664         for (Node* n = embeds->firstItem(); n; n = embeds->nextItem()) { 
       
   665             view = widget(n); 
       
   666             if (view) { 
       
   667                 plg = static_cast<PluginSkin*>(view); 
       
   668                 plg->reCreatePlugin(); 
       
   669             } 
       
   670         }
       
   671     }
       
   672 }
       
   673 
   596 // END OF FILE
   674 // END OF FILE