webengine/osswebengine/WebKit/s60/misc/WebUtil.cpp
changeset 8 7c90e6132015
parent 0 dd21522fd290
child 13 10e98eab6f85
equal deleted inserted replaced
0:dd21522fd290 8:7c90e6132015
    81     if ( e->hasLocalName(linkTag) ) {
    81     if ( e->hasLocalName(linkTag) ) {
    82         elType = TBrCtlDefs::EElementAnchor;
    82         elType = TBrCtlDefs::EElementAnchor;
    83     }
    83     }
    84     else if ( e->hasLocalName(aTag) ) {
    84     else if ( e->hasLocalName(aTag) ) {
    85         elType = TBrCtlDefs::EElementAnchor;
    85         elType = TBrCtlDefs::EElementAnchor;
    86         
    86 
    87         String href = e->getAttribute( hrefAttr );
    87         String href = e->getAttribute( hrefAttr );
    88         if (!href.isNull()) {
    88         if (!href.isNull()) {
    89             
    89 
    90             if( href.startsWith( KTel ) ) {            
    90             if( href.startsWith( KTel ) ) {
    91                 elType = TBrCtlDefs::EElementTelAnchor;
    91                 elType = TBrCtlDefs::EElementTelAnchor;
    92             }
    92             }
    93             else if( href.startsWith( KWtai ) ) {
    93             else if( href.startsWith( KWtai ) ) {
    94             
    94 
    95                 if( href.startsWith( KWtaiMC ) || href.startsWith(KWtaiAP) || href.startsWith(KWtaiSD) ) {
    95                 if( href.startsWith( KWtaiMC ) || href.startsWith(KWtaiAP) || href.startsWith(KWtaiSD) ) {
    96                     elType = TBrCtlDefs::EElementTelAnchor;
    96                     elType = TBrCtlDefs::EElementTelAnchor;
    97                 }                    
    97                 }
    98                     
    98 
    99             }
    99             }
   100             else if( href.startsWith( KMailto ) ) {
   100             else if( href.startsWith( KMailto ) ) {
   101                 elType = TBrCtlDefs::EElementMailtoAnchor;
   101                 elType = TBrCtlDefs::EElementMailtoAnchor;
   102             }
   102             }
   103 
   103 
   104     
   104 
   105         }
   105         }
   106         else if (!e->getAttribute( ctiAttr ).isNull()) {
   106         else if (!e->getAttribute( ctiAttr ).isNull()) {
   107             elType = TBrCtlDefs::EElementTelAnchor;                
   107             elType = TBrCtlDefs::EElementTelAnchor;
   108         }
   108         }
   109         else if( e->hasLocalName(areaTag) ) {        
   109         else if( e->hasLocalName(areaTag) ) {
   110         
   110 
   111             elType = TBrCtlDefs::EElementInputBox;                        
   111             elType = TBrCtlDefs::EElementInputBox;
   112         }
   112         }
   113     }
   113     }
   114     else if (e->isControl()) {
   114     else if (e->isControl()) {
   115         HTMLGenericFormElement* ie = static_cast<HTMLGenericFormElement*>( e );
   115         HTMLGenericFormElement* ie = static_cast<HTMLGenericFormElement*>( e );
   116         // default for form element
   116         // default for form element
   136             else {
   136             else {
   137             elType = TBrCtlDefs::EElementSelectBox;
   137             elType = TBrCtlDefs::EElementSelectBox;
   138             }
   138             }
   139         }
   139         }
   140         else if (ie->type() == "textarea")
   140         else if (ie->type() == "textarea")
   141             elType = TBrCtlDefs::EElementTextAreaBox;            
   141             elType = TBrCtlDefs::EElementTextAreaBox;
   142     }
   142     }
   143     else if( e->hasLocalName(objectTag) || e->hasLocalName(embedTag) ) {
   143     else if( e->hasLocalName(objectTag) || e->hasLocalName(embedTag) ) {
   144         if( e->renderer() && e->renderer()->isWidget() )
   144         if( e->renderer() && e->renderer()->isWidget() )
   145             if(node->active())
   145             if(node->active())
   146                 elType = TBrCtlDefs::EElementActivatedObjectBox;
   146                 elType = TBrCtlDefs::EElementActivatedObjectBox;
   158     return elType;
   158     return elType;
   159 }
   159 }
   160 
   160 
   161 
   161 
   162 WebFrame* frameAndPointUnderCursor(IntPoint& p_, WebView& v_)
   162 WebFrame* frameAndPointUnderCursor(IntPoint& p_, WebView& v_)
   163 {    
   163 {
   164     WebFrameView* mfv = v_.mainFrame()->frameView();
   164     WebFrameView* mfv = v_.mainFrame()->frameView();
   165     p_ = StaticObjectsContainer::instance()->webCursor()->position();
   165     p_ = StaticObjectsContainer::instance()->webCursor()->position();
   166     WebFrame* frame = v_.mainFrame()->frameAtPoint(p_);
   166     WebFrame* frame = v_.mainFrame()->frameAtPoint(p_);
   167     if (!frame) 
   167     if (!frame)
   168         frame = v_.mainFrame();
   168         frame = v_.mainFrame();
   169     IntPoint rc = frame->frameView()->rectInGlobalCoords().iTl;    
   169     IntPoint rc = frame->frameView()->rectInGlobalCoords().iTl;
   170     p_ = frame->frameView()->viewCoordsInFrameCoords(p_);
   170     p_ = frame->frameView()->viewCoordsInFrameCoords(p_);
   171     return frame;
   171     return frame;
   172 }
   172 }
   173 
   173 
   174 String getNodeUrlAtPointInFrame(WebFrame& f_, IntPoint& p_)
   174 String getNodeUrlAtPointInFrame(WebFrame& f_, IntPoint& p_)
   175 {    
   175 {
   176     Document* doc = core(&f_)->document();
   176     Document* doc = core(&f_)->document();
   177     if (doc) {
   177     if (doc) {
   178         Node* node = doc->elementFromPoint(p_.x(), p_.y());
   178         Node* node = doc->elementFromPoint(p_.x(), p_.y());
   179         
   179 
   180         if (node) {
   180         if (node) {
   181             if (node->hasTagName(areaTag)) {
   181             if (node->hasTagName(areaTag)) {
   182                 HTMLElement* e =  static_cast<HTMLElement*>(node);
   182                 HTMLElement* e =  static_cast<HTMLElement*>(node);
   183                 if(!e->getAttribute(hrefAttr).isNull()) {
   183                 if(!e->getAttribute(hrefAttr).isNull()) {
   184                     return e->getAttribute(hrefAttr);
   184                     return e->getAttribute(hrefAttr);
   187             // get the navigable node at this point
   187             // get the navigable node at this point
   188             Node* n = node;
   188             Node* n = node;
   189             for (; n; n = n->parentNode())
   189             for (; n; n = n->parentNode())
   190                 if (n->isFocusable() && n->isElementNode())
   190                 if (n->isFocusable() && n->isElementNode())
   191                     break;
   191                     break;
   192         
   192 
   193             if (n && n->isFocusable() && n->isElementNode()) {
   193             if (n && n->isFocusable() && n->isElementNode()) {
   194                 HTMLElement* e =  static_cast<HTMLElement*>(n);            
   194                 HTMLElement* e =  static_cast<HTMLElement*>(n);
   195                 if (!e->getAttribute(hrefAttr).isNull()) {
   195                 if (!e->getAttribute(hrefAttr).isNull()) {
   196                     return e->getAttribute(hrefAttr);                
   196                     return e->getAttribute(hrefAttr);
   197                 }
   197                 }
   198             }
   198             }
   199         }
   199         }
   200     }
   200     }
   201     return String();   
   201     return String();
   202 }
   202 }
   203 
   203 
   204 
   204 
   205 int imageCountInFrame(WebFrame& wf_, bool visibleOnly_)
   205 int imageCountInFrame(WebFrame& wf_, bool visibleOnly_)
   206 {        
   206 {
   207     int count = 0;
   207     int count = 0;
   208     Frame* f = core(&wf_);
   208     Frame* f = core(&wf_);
   209     
   209 
   210     if (!f || !f->document() || !f->document()->renderer())
   210     if (!f || !f->document() || !f->document()->renderer())
   211         return count;
   211         return count;
   212     
   212 
   213     Document* doc = f->document();    
   213     Document* doc = f->document();
   214     RefPtr<WebCore::HTMLCollection> collection = doc->images();         
   214     RefPtr<WebCore::HTMLCollection> collection = doc->images();
   215 
   215 
   216     FrameView* v = doc->view();
   216     FrameView* v = doc->view();
   217     IntRect r1 = wf_.frameView()->topView()->mainFrame()->frameView()->rect();
   217     IntRect r1 = wf_.frameView()->topView()->mainFrame()->frameView()->rect();
   218 
   218 
   219     for (Node *n = collection->firstItem(); n; n = collection->nextItem()) {
   219     for (Node *n = collection->firstItem(); n; n = collection->nextItem()) {
   220 
   220 
   221         RenderImage* render = static_cast<RenderImage*>(n->renderer());
   221         RenderImage* render = static_cast<RenderImage*>(n->renderer());
   222         if (render) {
   222         if (render) {
   223 
   223 
   224             Image* img = render->image();     
   224             Image* img = render->image();
   225             if (!img->isNull() && img->data()) { 
   225             if (!img->isNull() && img->data()) {
   226                 //if visible only is true, check for intersection
   226                 //if visible only is true, check for intersection
   227                 bool processing = true;                    
   227                 bool processing = true;
   228                 if (visibleOnly_) {
   228                 if (visibleOnly_) {
   229                     IntRect imageRect;
   229                     IntRect imageRect;
   230                     IntPoint tl = wf_.frameView()->frameCoordsInViewCoords(n->getRect().topLeft());
   230                     IntPoint tl = wf_.frameView()->frameCoordsInViewCoords(n->getRect().topLeft());
   231                     IntPoint br = wf_.frameView()->frameCoordsInViewCoords(n->getRect().bottomRight());
   231                     IntPoint br = wf_.frameView()->frameCoordsInViewCoords(n->getRect().bottomRight());
   232                     imageRect.setLocation(tl);
   232                     imageRect.setLocation(tl);
   233                     imageRect.setSize(br-tl);
   233                     imageRect.setSize(br-tl);
   234                     
   234 
   235                     processing = r1.intersects(imageRect);
   235                     processing = r1.intersects(imageRect);
   236                 }
   236                 }
   237                 if (processing) {                    
   237                 if (processing) {
   238                     String alttext = static_cast<HTMLImageElement*>(render->element())->altText();
   238                     String alttext = static_cast<HTMLImageElement*>(render->element())->altText();
   239                     // Check if alttext is "Nokia" or "No_save".
   239                     // Check if alttext is "Nokia" or "No_save".
   240                     // Then do not count
   240                     // Then do not count
   241                     if (!(equalIgnoringCase(alttext, "nokia") || equalIgnoringCase(alttext, "no_save")))
   241                     if (!(equalIgnoringCase(alttext, "nokia") || equalIgnoringCase(alttext, "no_save")))
   242                         ++count;
   242                         ++count;
   247     }
   247     }
   248     return count;
   248     return count;
   249 }
   249 }
   250 
   250 
   251 CArrayFixFlat<TBrCtlImageCarrier>* imagesInFrame(WebFrame& wf_, bool visibleOnly_)
   251 CArrayFixFlat<TBrCtlImageCarrier>* imagesInFrame(WebFrame& wf_, bool visibleOnly_)
   252 {    
   252 {
   253     CArrayFixFlat<TBrCtlImageCarrier>* imglist = new CArrayFixFlat<TBrCtlImageCarrier>(10);
   253     CArrayFixFlat<TBrCtlImageCarrier>* imglist = new CArrayFixFlat<TBrCtlImageCarrier>(10);
   254     Frame* f = core(&wf_);
   254     Frame* f = core(&wf_);
   255     
   255 
   256     if (!f || !f->document() || !f->document()->renderer())
   256     if (!f || !f->document() || !f->document()->renderer())
   257         return imglist;
   257         return imglist;
   258 
   258 
   259     CleanupStack::PushL(imglist);
   259     CleanupStack::PushL(imglist);
   260 
   260 
   261     Document* doc = f->document();    
   261     Document* doc = f->document();
   262     FrameView* v = doc->view();
   262     FrameView* v = doc->view();
   263     IntRect r1 = wf_.frameView()->topView()->mainFrame()->frameView()->rect();
   263     IntRect r1 = wf_.frameView()->topView()->mainFrame()->frameView()->rect();
   264     
   264 
   265 
   265 
   266     RefPtr<WebCore::HTMLCollection> collection = doc->images();         
   266     RefPtr<WebCore::HTMLCollection> collection = doc->images();
   267     for (Node* n = collection->firstItem(); n; n = collection->nextItem()) {
   267     for (Node* n = collection->firstItem(); n; n = collection->nextItem()) {
   268 
   268 
   269         RenderImage* render = static_cast<RenderImage*>(n->renderer());
   269         RenderImage* render = static_cast<RenderImage*>(n->renderer());
   270         if (render) {               
   270         if (render) {
   271             Image* img = render->image();     
   271             Image* img = render->image();
   272             if (!img->isNull() && img->data()) { 
   272             if (!img->isNull() && img->data()) {
   273                 //if visible only is true, check for intersection
   273                 //if visible only is true, check for intersection
   274                 TBool processing = ETrue;                    
   274                 TBool processing = ETrue;
   275                 if (visibleOnly_) {
   275                 if (visibleOnly_) {
   276                     IntRect imageRect;
   276                     IntRect imageRect;
   277                     IntPoint tl = wf_.frameView()->frameCoordsInViewCoords(n->getRect().topLeft());
   277                     IntPoint tl = wf_.frameView()->frameCoordsInViewCoords(n->getRect().topLeft());
   278                     IntPoint br = wf_.frameView()->frameCoordsInViewCoords(n->getRect().bottomRight());
   278                     IntPoint br = wf_.frameView()->frameCoordsInViewCoords(n->getRect().bottomRight());
   279                     imageRect.setLocation(tl);
   279                     imageRect.setLocation(tl);
   280                     imageRect.setSize(br-tl);
   280                     imageRect.setSize(br-tl);
   281                     
   281 
   282                     processing = r1.intersects(imageRect);
   282                     processing = r1.intersects(imageRect);
   283                 }
   283                 }
   284                 if (processing) {                    
   284                 if (processing) {
   285                     String alttext = static_cast<HTMLImageElement*>(render->element())->altText();
   285                     String alttext = static_cast<HTMLImageElement*>(render->element())->altText();
   286                     TBrCtlImageType type = EImageTypeAny; 
   286                     TBrCtlImageType type = EImageTypeAny;
   287                     if (img->getMimeType().find("image/vnd.wap.wbmp") == 0)
   287                     if (img->getMimeType().find("image/vnd.wap.wbmp") == 0)
   288                         type = EImageTypeWbmp; 
   288                         type = EImageTypeWbmp;
   289                     else if (img->getMimeType().find("image/vnd.nokia.ota-bitmap") == 0)
   289                     else if (img->getMimeType().find("image/vnd.nokia.ota-bitmap") == 0)
   290                         type = EImageTypeOta; 
   290                         type = EImageTypeOta;
   291                     //
   291                     //
   292                     TBrCtlImageCarrier tImg(TPtrC8((const TUint8*)img->data()->data(),img->data()->size()), 
   292                     TBrCtlImageCarrier tImg(TPtrC8((const TUint8*)img->data()->data(),img->data()->size()),
   293                         static_cast<HTMLImageElement*>(render->element())->getAttribute(srcAttr),
   293                         static_cast<HTMLImageElement*>(render->element())->getAttribute(srcAttr),
   294                         alttext, type, img->getMimeType());
   294                         alttext, type, img->getMimeType());
   295 
   295 
   296                     // Check if alttext is "Nokia" or "No_save".
   296                     // Check if alttext is "Nokia" or "No_save".
   297                     // Then do not add the image to the list                
   297                     // Then do not add the image to the list
   298                     if (!(equalIgnoringCase(alttext, "nokia") || equalIgnoringCase(alttext, "no_save"))) {
   298                     if (!(equalIgnoringCase(alttext, "nokia") || equalIgnoringCase(alttext, "no_save"))) {
   299                         // Check if this image has been retrieved before.
   299                         // Check if this image has been retrieved before.
   300                         // Image pointer should be the same for similar images
   300                         // Image pointer should be the same for similar images
   301                         TBool imgexists = false;
   301                         TBool imgexists = false;
   302                         for (int i=0; i<imglist->Count();i++) {
   302                         for (int i=0; i<imglist->Count();i++) {
   308 
   308 
   309                         }
   309                         }
   310                         if (!imgexists)
   310                         if (!imgexists)
   311                             imglist->AppendL(tImg);
   311                             imglist->AppendL(tImg);
   312                     }
   312                     }
   313                 }                
   313                 }
   314             }
   314             }
   315         }                        
   315         }
   316     }
   316     }
   317     CleanupStack::Pop(imglist);
   317     CleanupStack::Pop(imglist);
   318     return imglist; 
   318     return imglist;
   319 }
   319 }
   320 
   320 
   321 CArrayFixFlat<TBrCtlSubscribeTo>* findSubscribeToInFrame(WebFrame& wf_)
   321 CArrayFixFlat<TBrCtlSubscribeTo>* findSubscribeToInFrame(WebFrame& wf_)
   322 {
   322 {
   323     CArrayFixFlat<TBrCtlSubscribeTo>* linkList = new CArrayFixFlat<TBrCtlSubscribeTo>(10);
   323     CArrayFixFlat<TBrCtlSubscribeTo>* linkList = new CArrayFixFlat<TBrCtlSubscribeTo>(10);
   324     Frame* f = core(&wf_);
   324     Frame* f = core(&wf_);
   325     
   325 
   326     if (!f || !f->document())
   326     if (!f || !f->document())
   327         return linkList;
   327         return linkList;
   328 
   328 
   329     CleanupStack::PushL(linkList);
   329     CleanupStack::PushL(linkList);
   330     for (Node *n = f->document(); n; n = n->traverseNextNode()) {
   330     for (Node *n = f->document(); n; n = n->traverseNextNode()) {
   331         if (n->isElementNode() && n->hasTagName(linkTag)) {                
   331         if (n->isElementNode() && n->hasTagName(linkTag)) {
   332 
   332 
   333             HTMLElement* e =  static_cast<HTMLElement*>(n);           
   333             HTMLElement* e =  static_cast<HTMLElement*>(n);
   334             String type = e->getAttribute(typeAttr);
   334             String type = e->getAttribute(typeAttr);
   335 
   335 
   336             if (type == "application/rss+xml" || type == "application/atom+xml" || 
   336             if (type == "application/rss+xml" || type == "application/atom+xml" ||
   337                 type == "text/xml" || type == "application/xml") {
   337                 type == "text/xml" || type == "application/xml") {
   338                 String href = e->getAttribute(hrefAttr);
   338                 String href = e->getAttribute(hrefAttr);
   339                 String title = e->getAttribute(titleAttr);
   339                 String title = e->getAttribute(titleAttr);
   340 
   340 
   341                 TBrCtlSubscribeTo item(title.des(), href.des(), 0);       
   341                 TBrCtlSubscribeTo item(title.des(), href.des(), 0);
   342                 linkList->AppendL(item);                
   342                 linkList->AppendL(item);
   343             }
   343             }
   344         }
   344         }
   345     }
   345     }
   346     CleanupStack::Pop(linkList);
   346     CleanupStack::Pop(linkList);
   347     return linkList;
   347     return linkList;
   351 {
   351 {
   352     int ret = KErrNone;
   352     int ret = KErrNone;
   353     TBrCtlImageCarrier* t = NULL;
   353     TBrCtlImageCarrier* t = NULL;
   354     RenderImage *r = renderImageUnderCursor(webView);
   354     RenderImage *r = renderImageUnderCursor(webView);
   355     if (r) {
   355     if (r) {
   356         Image* img = r->image();     
   356         Image* img = r->image();
   357         CachedImage* ci = r->cachedImage();
   357         CachedImage* ci = r->cachedImage();
   358         if( ci && !img->isNull()) {
   358         if( ci && !img->isNull()) {
   359             SharedBuffer* imgData = img->data();
   359             SharedBuffer* imgData = img->data();
   360             if (imgData) {
   360             if (imgData) {
   361                 TPtrC8 rawData((const unsigned char*)(imgData->data()), (imgData->size()));
   361                 TPtrC8 rawData((const unsigned char*)(imgData->data()), (imgData->size()));
   372                             brCtlTtype = EImageTypeWbmp;
   372                             brCtlTtype = EImageTypeWbmp;
   373                         }
   373                         }
   374                         else if ( img->getMimeType().des().Find(KMimeOTA) != KErrNotFound ) {
   374                         else if ( img->getMimeType().des().Find(KMimeOTA) != KErrNotFound ) {
   375                             brCtlTtype = EImageTypeOta;
   375                             brCtlTtype = EImageTypeOta;
   376                         }
   376                         }
   377                         t = new TBrCtlImageCarrier(TPtrC8((const TUint8*)img->data()->data(),img->data()->size()), 
   377                         t = new TBrCtlImageCarrier(TPtrC8((const TUint8*)img->data()->data(),img->data()->size()),
   378                             static_cast<HTMLImageElement*>(r->element())->getAttribute(srcAttr),
   378                             static_cast<HTMLImageElement*>(r->element())->getAttribute(srcAttr),
   379                             alttext, brCtlTtype, img->getMimeType());
   379                             alttext, brCtlTtype, img->getMimeType());
   380                         if (!t) {
   380                         if (!t) {
   381                             ret = KErrNoMemory;
   381                             ret = KErrNoMemory;
   382                         }
   382                         }
   412     RenderImage *r = renderImageUnderCursor(webView);
   412     RenderImage *r = renderImageUnderCursor(webView);
   413     if (r) {
   413     if (r) {
   414         CachedImage* ci = r->cachedImage();
   414         CachedImage* ci = r->cachedImage();
   415         if (ci && ci->status() == CachedResource::Unknown) {
   415         if (ci && ci->status() == CachedResource::Unknown) {
   416             IntPoint p;
   416             IntPoint p;
   417             WebFrame* frame = frameAndPointUnderCursor(p, *webView);            
   417             WebFrame* frame = frameAndPointUnderCursor(p, *webView);
   418             cache()->loader()->load(core(frame)->document()->docLoader(), ci, true);
   418             cache()->loader()->load(core(frame)->document()->docLoader(), ci, true);
   419         }
   419         }
   420     }
   420     }
   421 }
   421 }
   422 
   422 
   426     WebFrame* frame = frameAndPointUnderCursor(p, *webView);
   426     WebFrame* frame = frameAndPointUnderCursor(p, *webView);
   427     Frame* f = core(frame);
   427     Frame* f = core(frame);
   428     RenderImage* render = NULL;
   428     RenderImage* render = NULL;
   429     if (!f || !f->document() || !f->document()->renderer())
   429     if (!f || !f->document() || !f->document()->renderer())
   430         return NULL;
   430         return NULL;
   431     Document* doc = f->document();    
   431     Document* doc = f->document();
   432     FrameView* v = doc->view();
   432     FrameView* v = doc->view();
   433     RefPtr<WebCore::HTMLCollection> collection = doc->images();         
   433     RefPtr<WebCore::HTMLCollection> collection = doc->images();
   434     for (Node* n = collection->firstItem(); n; n = collection->nextItem()) {
   434     for (Node* n = collection->firstItem(); n; n = collection->nextItem()) {
   435         render = static_cast<RenderImage*>(n->renderer());
   435         render = static_cast<RenderImage*>(n->renderer());
   436         if (render) {               
   436         if (render) {
   437             Image* img = render->image();     
   437             Image* img = render->image();
   438             if (!img->isNull()) { 
   438             if (!img->isNull()) {
   439                 //if visible only is true, check for intersection
   439                 //if visible only is true, check for intersection
   440                 if (n->getRect().contains(p)) {
   440                 if (n->getRect().contains(p)) {
   441                     return render;
   441                     return render;
   442                 }                
   442                 }
   443             }
   443             }
   444         }                        
   444         }
   445     }
   445     }
   446     return NULL;
   446     return NULL;
   447 }
   447 }
   448 
   448 
   449 HBufC* generateFrameName()
   449 HBufC* generateFrameName()
   488     item.iFlags = 0;
   488     item.iFlags = 0;
   489     item.iCascadeId = 0;
   489     item.iCascadeId = 0;
   490     menuPane.InsertMenuItemL(item, 0);
   490     menuPane.InsertMenuItemL(item, 0);
   491 }
   491 }
   492 
   492 
   493 int textMultiplier(int fontLevel, int originalSize) 
   493 int textMultiplier(int fontLevel, int originalSize)
   494 {
   494 {
   495     int sizeMultiplier = originalSize;
   495     int sizeMultiplier = originalSize;
   496     switch(fontLevel)
   496     switch(fontLevel)
   497         {
   497         {
   498         case TBrCtlDefs::EFontSizeLevelAllSmall:
   498         case TBrCtlDefs::EFontSizeLevelAllSmall:
   548                     // get the navigable node at this point
   548                     // get the navigable node at this point
   549                     Node* n = node;
   549                     Node* n = node;
   550                     for (; n; n = n->parentNode())
   550                     for (; n; n = n->parentNode())
   551                         if (n->isFocusable() && n->isElementNode())
   551                         if (n->isFocusable() && n->isElementNode())
   552                             break;
   552                             break;
   553         
   553 
   554                     if (n && n->isFocusable() && n->isElementNode()) {
   554                     if (n && n->isFocusable() && n->isElementNode()) {
   555                         HTMLElement* e =  static_cast<HTMLElement*>(n);
   555                         HTMLElement* e =  static_cast<HTMLElement*>(n);
   556                         String tel;
   556                         String tel;
   557                         String email;
   557                         String email;
   558                         String telbook;
   558                         String telbook;
   585                         if (!attr.isNull() && !attr.isEmpty() )
   585                         if (!attr.isNull() && !attr.isEmpty() )
   586                             email = attr;
   586                             email = attr;
   587                         // telbook
   587                         // telbook
   588                         attr = e->getAttribute(telbookAttr);
   588                         attr = e->getAttribute(telbookAttr);
   589                         if (!attr.isNull() && !attr.isEmpty() )
   589                         if (!attr.isNull() && !attr.isEmpty() )
   590                             telbook = attr;            
   590                             telbook = attr;
   591                         // Save to phone book
   591                         // Save to phone book
   592                         String url;            
   592                         String url;
   593                         String makeCallUrlPrefix("wtai://wp/ap;");
   593                         String makeCallUrlPrefix("wtai://wp/ap;");
   594                         char numberNameSeparator = ';';            
   594                         char numberNameSeparator = ';';
   595                         int len = makeCallUrlPrefix.length() + 3; // NULL terminator and ';' separators            
   595                         int len = makeCallUrlPrefix.length() + 3; // NULL terminator and ';' separators
   596                         len += tel.length() + telbook.length() + email.length();            
   596                         len += tel.length() + telbook.length() + email.length();
   597                         //url.reserve(len);            
   597                         //url.reserve(len);
   598                         url = makeCallUrlPrefix;
   598                         url = makeCallUrlPrefix;
   599                         url.append(tel);
   599                         url.append(tel);
   600                         url.append(numberNameSeparator);
   600                         url.append(numberNameSeparator);
   601                         url.append(telbook);
   601                         url.append(telbook);
   602                         url.append(numberNameSeparator);
   602                         url.append(numberNameSeparator);
   621     // All SSL errors are mapped into this one, which gets displayed to the user
   621     // All SSL errors are mapped into this one, which gets displayed to the user
   622     if (err <= SSL_ERROR_BASE && err > SSL_ERROR_BASE - 200 ||
   622     if (err <= SSL_ERROR_BASE && err > SSL_ERROR_BASE - 200 ||
   623         err == KErrHttpCannotEstablishTunnel) {
   623         err == KErrHttpCannotEstablishTunnel) {
   624         return KErrSSLAlertHandshakeFailure;
   624         return KErrSSLAlertHandshakeFailure;
   625     }
   625     }
   626     
   626 
   627     // Deal with DNS lookup errors
   627     // Deal with DNS lookup errors
   628     if ((err <= KErrInet6NoDestination) && (err > (KErrInet6NoDestination - 200))) {
   628     if ((err <= KErrInet6NoDestination) && (err > (KErrInet6NoDestination - 200))) {
   629         return KBrowserHTTP502;
   629         return KBrowserHTTP502;
   630     }
   630     }
   631     
   631 
   632     // Deal with HTTP errors
   632     // Deal with HTTP errors
   633     if (err <= KHttpErrorBase && err > KHttpErrorBase - 200) {
   633     if (err <= KHttpErrorBase && err > KHttpErrorBase - 200) {
   634         // Encode errors
   634         // Encode errors
   635         if (err <= KErrHttpEncodeDefault && err >= KErrHttpEncodeCookie2) {
   635         if (err <= KErrHttpEncodeDefault && err >= KErrHttpEncodeCookie2) {
   636             return KBrowserFailure;
   636             return KBrowserFailure;
   640             err == KErrHttpDecodeUnknownAuthScheme ||
   640             err == KErrHttpDecodeUnknownAuthScheme ||
   641             err == KErrHttpDecodeBasicAuth ||
   641             err == KErrHttpDecodeBasicAuth ||
   642             err == KErrHttpDecodeDigestAuth) {
   642             err == KErrHttpDecodeDigestAuth) {
   643             return KBrowserMissingAuthHeader;
   643             return KBrowserMissingAuthHeader;
   644         }
   644         }
   645         
   645 
   646         // Decode errors
   646         // Decode errors
   647         if (err <= KErrHttpDecodeMalformedDate && err >= KErrHttpDecodeCookie) {
   647         if (err <= KErrHttpDecodeMalformedDate && err >= KErrHttpDecodeCookie) {
   648             return KBrowserBadContent;
   648             return KBrowserBadContent;
   649         }
   649         }
   650         switch (err)
   650         switch (err)
   720 
   720 
   721 
   721 
   722 bool handleSelectElementScrolling(WebView* webView, int tb)
   722 bool handleSelectElementScrolling(WebView* webView, int tb)
   723 {
   723 {
   724     bool ret = false;
   724     bool ret = false;
       
   725     bool isScrollList = false;
   725     if (webView->focusedElementType() == TBrCtlDefs::EElementSelectMultiBox && tb != 0) {
   726     if (webView->focusedElementType() == TBrCtlDefs::EElementSelectMultiBox && tb != 0) {
   726         IntPoint point;
   727         IntPoint point;
   727         WebFrame* frame = frameAndPointUnderCursor(point, *webView);
   728         WebFrame* frame = frameAndPointUnderCursor(point, *webView);
   728         Element* e = core(frame)->document()->elementFromPoint(point.x(), point.y());
   729         Element* e = core(frame)->document()->elementFromPoint(point.x(), point.y());
   729         if (e && e->isControl()) {
   730         if (e && e->isControl()) {
   730             HTMLGenericFormElement* ie = static_cast<HTMLGenericFormElement*>( e );
   731             HTMLGenericFormElement* ie = static_cast<HTMLGenericFormElement*>( e );
   731             if (ie->type() == "select-multiple") {
   732         	if (ie->type() == "select-multiple") {
       
   733         		isScrollList = true;
       
   734         	}
       
   735         	else if (ie->type() == "select-one") {
       
   736         		HTMLSelectElement* theSecletedElement = static_cast<HTMLSelectElement*>( e );
       
   737         		//check if the size is > 1
       
   738         		if (theSecletedElement->size() > 1) {
       
   739         			isScrollList = true;
       
   740         		} //select-one
       
   741         	}
       
   742 
       
   743         	//scroll only for the list which is either multiple or single but with more than one lines
       
   744             if (isScrollList) {
   732                 RenderListBox* render = static_cast<RenderListBox*>(e->renderer());
   745                 RenderListBox* render = static_cast<RenderListBox*>(e->renderer());
   733                 if (render->isScrollable()) {
   746                 if (render->isScrollable()) {
   734                     HTMLSelectElement* selectElement = static_cast<HTMLSelectElement*>( e );
   747                     HTMLSelectElement* selectElement = static_cast<HTMLSelectElement*>( e );
   735                     IntRect r = e->getRect();
   748                     IntRect r = e->getRect();
   736                     int curIndex = render->listIndexAtOffset(point.x() - r.x(), point.y() - r.y());
   749                     int curIndex = render->listIndexAtOffset(point.x() - r.x(), point.y() - r.y());
   765                             TPoint tp(StaticObjectsContainer::instance()->webCursor()->position().iX, StaticObjectsContainer::instance()->webCursor()->position().iY + step);
   778                             TPoint tp(StaticObjectsContainer::instance()->webCursor()->position().iX, StaticObjectsContainer::instance()->webCursor()->position().iY + step);
   766                             StaticObjectsContainer::instance()->webCursor()->updatePositionAndElemType(tp);
   779                             StaticObjectsContainer::instance()->webCursor()->updatePositionAndElemType(tp);
   767                             ret = true;
   780                             ret = true;
   768                         }
   781                         }
   769                     }
   782                     }
   770                 }
   783                 }//isScrollable()
   771             }
   784             }//isScrollList
   772         }
   785         } //isControl
   773     }
   786     } //focusedElementType()
       
   787 
   774     return ret;
   788     return ret;
   775 }    
   789 }
   776 
   790