webengine/osswebengine/WebCore/platform/symbian/FormFillController.cpp
branchRCL_3
changeset 48 79859ed3eea9
parent 47 e1bea15f9a39
child 49 919f36ff910f
equal deleted inserted replaced
47:e1bea15f9a39 48:79859ed3eea9
    17 
    17 
    18 #include "config.h"
    18 #include "config.h"
    19 #include "FormFillController.h"
    19 #include "FormFillController.h"
    20 #include "Event.h"
    20 #include "Event.h"
    21 #include "Timer.h"
    21 #include "Timer.h"
    22 #include "String.h"
    22 #include "string.h"
    23 #include "HTMLInputElement.h"
    23 #include "HTMLInputElement.h"
    24 #include "HTMLFormElement.h"
    24 #include "HTMLFormElement.h"
    25 #include "FontCache.h"
    25 #include "FontCache.h"
    26 #include "FontPlatformData.h"
    26 #include "FontPlatformData.h"
    27 #include "FormDataStore.h"
    27 #include "FormDataStore.h"
    34 #include "Settings.h"
    34 #include "Settings.h"
    35 #include "FormFillCallback.h"
    35 #include "FormFillCallback.h"
    36 #include "FormFillPopup.h"
    36 #include "FormFillPopup.h"
    37 #include "PlatformFontCache.h"
    37 #include "PlatformFontCache.h"
    38 #include "StaticObjectsContainer.h"
    38 #include "StaticObjectsContainer.h"
    39 #include "FontDescription.h" 
       
    40 
       
    41 #define KMaxZoomFactorForPopup 125 
       
    42 namespace WebCore {
    39 namespace WebCore {
    43 
    40 
    44 static const double kSearchStartTimeout = 0.5f;
    41 static const double kSearchStartTimeout = 0.5f;
    45 
    42 
    46 FormFillController::FormFillController() 
    43 FormFillController::FormFillController() 
    47                     : m_popup(0), m_callback(0), m_inputElement(0), m_formDB(0), m_passwdDB(0)
    44                     : m_popup(0), m_callback(0), m_inputElement(0), m_formDB(0), m_passwdDB(0)
    48 {
    45 {
    49     m_searchTimer = new Timer<FormFillController>(this, FormFillController::fireSearch);
    46     m_searchTimer = new Timer<FormFillController>(this, &FormFillController::fireSearch);
    50 }
    47 }
    51 
    48 
    52 FormFillController::~FormFillController()
    49 FormFillController::~FormFillController()
    53 {
    50 {
    54     delete m_searchTimer;
    51     delete m_searchTimer;
    77 {
    74 {
    78     if(m_results.size() > 0) {
    75     if(m_results.size() > 0) {
    79         // lazily create the popup view
    76         // lazily create the popup view
    80         PlatformFontCache* cache = StaticObjectsContainer::instance()->fontCache();
    77         PlatformFontCache* cache = StaticObjectsContainer::instance()->fontCache();
    81         float zoomFactor =  (float)cache->fontZoomFactor();
    78         float zoomFactor =  (float)cache->fontZoomFactor();
    82         // system font to be used by popup
       
    83 
       
    84         float newFont = 12.0f * zoomFactor /100.0f;
       
    85         FontDescription fd; 
       
    86         fd.setComputedSize(newFont);
       
    87         //If zoom factor is greater than 120 and less than or equals 200, then make it 125 by default. This
       
    88         //will make it selectable not too big.
       
    89         FontPlatformData* font = new FontPlatformData(cache->zoomedFont(fd, (zoomFactor > 120)? KMaxZoomFactorForPopup : zoomFactor));;
       
    90         if(!m_popup) {
    79         if(!m_popup) {
       
    80             // system font to be used by popup
       
    81 
       
    82             float newFont = 12.0f * zoomFactor /100.0f;
       
    83             FontPlatformData* font = FontCache::getDeviceDefaultFont(newFont);
    91             m_popup = m_callback->createFormFillPopup(font->Font());
    84             m_popup = m_callback->createFormFillPopup(font->Font());
    92         }
    85         }
    93         else
       
    94         {
       
    95             m_popup->setFont(font->Font());
       
    96         }
       
    97         delete font; 
       
    98         if (!m_popup) {
    86         if (!m_popup) {
    99             return;
    87             return;
   100         }
    88         }
   101         m_popup->clear();
    89         m_popup->clear();
   102         // fill the popup
    90         // fill the popup
   243                             m_passwdDB = new FormLoginStore();
   231                             m_passwdDB = new FormLoginStore();
   244 
   232 
   245                         // we first check the black list, don't bother the user with
   233                         // we first check the black list, don't bother the user with
   246                         // queries if the realm is in black list
   234                         // queries if the realm is in black list
   247                         if (!m_passwdDB->saveAllowed(realm))
   235                         if (!m_passwdDB->saveAllowed(realm))
   248                             ignorefield = true;
       
   249 
       
   250                         // check if username, password value is missing
       
   251                         if(!passwd->value() || !input->value())
       
   252                             ignorefield = true;
   236                             ignorefield = true;
   253 
   237 
   254                         // if login info is already saved, don't save again
   238                         // if login info is already saved, don't save again
   255                         if (!ignorefield && m_passwdDB->contains(realm, input->name(), input->value(), passwd->name(), passwd->value())) {
   239                         if (!ignorefield && m_passwdDB->contains(realm, input->name(), input->value(), passwd->name(), passwd->value())) {
   256                             ignorefield = true;
   240                             ignorefield = true;