webengine/osswebengine/WebCore/platform/symbian/StaticObjectsContainer.cpp
changeset 0 dd21522fd290
child 8 7c90e6132015
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "config.h"
       
    20 #include <../bidi.h>            // work around for multiple bidi.h files
       
    21 #include "StaticObjectsContainer.h"
       
    22 #include "Brctl.h"
       
    23 #include "AtomicString.h"
       
    24 #include "PlatformFontCache.h"
       
    25 #include "PictographSymbian.h"
       
    26 #include "FontCache.h"
       
    27 #include "FormFillController.h"
       
    28 #include "ResourceLoaderDelegate.h"
       
    29 #include "webkitLogger.h"
       
    30 #include "brctldefs.h"
       
    31 #include "WebIconDatabase.h"
       
    32 #include "WebSurface.h"
       
    33 #include "WebCursor.h"
       
    34 #include "PluginHandler.h"
       
    35 #include "WebCannedImages.h"
       
    36 #include "OOMHandler.h"
       
    37 #include "SharedTimer.h"
       
    38 #include <eikenv.h>
       
    39 
       
    40 const TInt KLowResolutionDpi = 130;
       
    41 const TInt KMediumResolutionDpi = 200;
       
    42 
       
    43 namespace WebCore {
       
    44 
       
    45 StaticObjectsContainer* StaticObjectsContainer::gInstance = 0;
       
    46 
       
    47 StaticObjectsContainer::StaticObjectsContainer() : 
       
    48      m_fontCache(0)
       
    49     ,m_formFillController(0)
       
    50     ,m_pictograph(NULL)
       
    51     ,m_resourceLoaderDelegate(NULL)
       
    52     ,m_stream(NULL)
       
    53     ,m_icondatabase(NULL)
       
    54     ,m_rendertarget(NULL)
       
    55     ,m_cursor(NULL)
       
    56     ,m_cannedimg(NULL)
       
    57     ,m_pluginhandler(NULL)
       
    58     ,m_refcount(0)
       
    59     ,m_capabilities(0)
       
    60     ,m_oomHandler(0)
       
    61     ,m_fullScreenMode(false)
       
    62 {
       
    63     // Check the device resolution
       
    64     CEikonEnv* eikEnv = CEikonEnv::Static();
       
    65     if( eikEnv ) {
       
    66         CWsScreenDevice& screenDev = *eikEnv->ScreenDevice();
       
    67 
       
    68         TUint dpi = screenDev.VerticalTwipsToPixels(KTwipsPerInch);
       
    69 
       
    70         if( dpi <= KLowResolutionDpi ) {
       
    71             m_screenRes = ELowScreenResolution;
       
    72         }
       
    73         else if( dpi > KLowResolutionDpi && dpi <= KMediumResolutionDpi ) {
       
    74             m_screenRes = EMediumScreenResolution;
       
    75         }
       
    76         else {
       
    77             m_screenRes = EHighScreenResolution;
       
    78         }
       
    79     }
       
    80     m_oomHandler = new OOMHandler();
       
    81 }
       
    82 
       
    83 StaticObjectsContainer::~StaticObjectsContainer()
       
    84 {
       
    85     delete m_oomHandler;
       
    86     delete m_fontCache;
       
    87     delete m_formFillController;
       
    88     delete m_pictograph;
       
    89     delete m_resourceLoaderDelegate;
       
    90     delete m_stream;
       
    91     delete m_icondatabase;
       
    92     delete m_rendertarget;
       
    93     delete m_cannedimg;
       
    94     delete m_cursor;
       
    95     delete m_pluginhandler;
       
    96     gInstance = NULL;
       
    97     shutdownSharedTimer();
       
    98 }
       
    99 
       
   100 StaticObjectsContainer* StaticObjectsContainer::instance()
       
   101 {
       
   102     if( !gInstance )
       
   103         gInstance = new (ELeave) StaticObjectsContainer;
       
   104     return gInstance;
       
   105 }
       
   106 
       
   107 PictographSymbian* StaticObjectsContainer::pictograph()
       
   108 {
       
   109     if (!m_pictograph)
       
   110         {        
       
   111         m_pictograph = new PictographSymbian();
       
   112         }
       
   113     return m_pictograph;
       
   114 }
       
   115 
       
   116 PlatformFontCache* StaticObjectsContainer::fontCache()
       
   117 {
       
   118     if( !m_fontCache )
       
   119         {
       
   120         m_fontCache = new PlatformFontCache();
       
   121         // tot:fixme. find out why platforminit is not called by the core
       
   122         FontCache::platformInit();
       
   123         }
       
   124 
       
   125     return m_fontCache;
       
   126 }
       
   127 
       
   128 FormFillController* StaticObjectsContainer::formFillController()
       
   129 {
       
   130     if(!m_formFillController)
       
   131         m_formFillController = new FormFillController();
       
   132 
       
   133     return m_formFillController;
       
   134 }
       
   135 
       
   136 RFs& StaticObjectsContainer::fsSession()
       
   137 {
       
   138     return CEikonEnv::Static()->FsSession();
       
   139 }
       
   140 
       
   141 ResourceLoaderDelegate* StaticObjectsContainer::resourceLoaderDelegate()
       
   142 {
       
   143     if (!m_resourceLoaderDelegate) {
       
   144         m_resourceLoaderDelegate = new ResourceLoaderDelegate;
       
   145     }
       
   146     return m_resourceLoaderDelegate; 
       
   147 }
       
   148 
       
   149 LogStream& StaticObjectsContainer::logStream()
       
   150 {
       
   151     if(!m_stream)
       
   152         m_stream = new LogStream();
       
   153     return *m_stream;
       
   154 }
       
   155 
       
   156 
       
   157 WebIconDatabase* StaticObjectsContainer::sharedIconDatabase()
       
   158 {
       
   159     if (!m_icondatabase) {
       
   160         m_icondatabase = new WebIconDatabase();
       
   161         m_icondatabase->openSharedDatabase();
       
   162     }
       
   163     return m_icondatabase;
       
   164 }
       
   165 
       
   166 WebSurface* StaticObjectsContainer::webSurface()
       
   167 {
       
   168     if (!m_rendertarget) {
       
   169         m_rendertarget = WebSurface::NewL();
       
   170     }
       
   171     return m_rendertarget;
       
   172 }
       
   173 
       
   174 WebCursor* StaticObjectsContainer::webCursor()
       
   175 {
       
   176     if (!m_cursor) {
       
   177         m_cursor = WebCursor::NewL();
       
   178     }
       
   179     return m_cursor;
       
   180 }
       
   181 
       
   182 WebCannedImages* StaticObjectsContainer::webCannedImages()
       
   183 {
       
   184     if (!m_cannedimg) {
       
   185         m_cannedimg = WebCannedImages::NewL();
       
   186     }
       
   187     return m_cannedimg;
       
   188 }
       
   189 
       
   190 PluginHandler* StaticObjectsContainer::pluginHandler()
       
   191 {
       
   192     if (!m_pluginhandler) {
       
   193         //tot:fixme 
       
   194         TBool enablePlugin = ETrue;
       
   195         m_pluginhandler = PluginHandler::NewL(enablePlugin);
       
   196     }
       
   197     return m_pluginhandler;
       
   198 }
       
   199 
       
   200 CBrCtl* StaticObjectsContainer::brctl() const
       
   201 {
       
   202     if (m_activeBrCtls.size() > 0)
       
   203         return m_activeBrCtls[0];
       
   204     return NULL;        
       
   205 }
       
   206 
       
   207 const Vector<CBrCtl*>& StaticObjectsContainer::activeBrowserControls() const
       
   208 {
       
   209     return m_activeBrCtls;
       
   210 }
       
   211 
       
   212 void StaticObjectsContainer::ref(CBrCtl& brctl)              
       
   213 { 
       
   214     m_refcount++; 
       
   215     m_activeBrCtls.append(&brctl);
       
   216 }
       
   217 
       
   218 void StaticObjectsContainer::deref(CBrCtl& brctl)            
       
   219 { 
       
   220     for (int i = 0; i < m_activeBrCtls.size(); i++) {
       
   221         if (m_activeBrCtls[i] == &brctl) {
       
   222             m_activeBrCtls.remove(i);
       
   223             break;
       
   224         }
       
   225     }
       
   226     if( --m_refcount==0 ) 
       
   227         delete this; 
       
   228 }
       
   229 
       
   230 void StaticObjectsContainer::setFullScreenMode(bool mode)
       
   231 {
       
   232     m_fullScreenMode = mode;
       
   233 }
       
   234 
       
   235 bool StaticObjectsContainer::fullScreenMode(void){
       
   236     return m_fullScreenMode;
       
   237 }
       
   238 }
       
   239 
       
   240 // END OF FILE