Fixed Nabi issues N_SE-50613, N_SE-49431, N_SE-50779, N_SE-50601, N_SE-50559
[apps/osp/Internet.git] / src / IntMainForm.cpp
index 7936809..072e148 100644 (file)
@@ -68,8 +68,8 @@ static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_pres
 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
-static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
-static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
+static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP =L"00_icon_favorite_off_74x74.png";
+static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"00_icon_favorite_on_74x74.png";
 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
 static const wchar_t* IDS_APPID = L"AppID";
 static const wchar_t* IDS_KEY = L"key";
@@ -144,6 +144,7 @@ static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
 
+static const wchar_t* APPCONTROL_OPERATION_ID_IMAGE_VIEWER = L"http://tizen.org/appcontrol/operation/view";
 MainForm::MainForm(void)
 {
        __isLongPressedDone = false;
@@ -485,10 +486,9 @@ MainForm::InitWebControl()
        else
        {
                r = AddControl(__pWebViewer);
-
                if (IsFailed(r))
                {
-                       delete __pWebViewer;
+                       __pWebViewer->Destroy();
                        __pWebViewer = null;
                        AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
                        return r;
@@ -741,6 +741,19 @@ MainForm::InitFooter(void)
        __pReaderBtn->SetShowState(false);
 
        //      __pFooterPanel->Invalidate(true);
+       if(__isKeypadOpened == false && __pAddressbar && __pAddressbar->GetShowState() == false)
+       {
+//             AppLog("asdasdasdasda");
+               __pFooterPanel->SetShowState(true);
+       }
+       else if(__pAddressbar == null)
+       {
+               __pFooterPanel->SetShowState(true);
+       }
+       else
+               __pFooterPanel->SetShowState(false);
+
+       SetAddressbarMode(GetAddressbarMode());
        AppLogDebug("MainForm::InitFooter exit");
        return E_SUCCESS;
 }
@@ -824,6 +837,7 @@ result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
        __pImageMenu->SetMaxVisibleItemsCount(4);
        __pImageMenu->AddActionEventListener(*this);
        SetControlAlwaysOnTop(*__pImageMenu, true);
+       __pImageMenu->SetFocusable(true);
 
        CATCH: return r;
 }
@@ -860,6 +874,7 @@ MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
        __pImageMenu->SetMaxVisibleItemsCount(3);
        __pImageMenu->AddActionEventListener(*this);
        SetControlAlwaysOnTop(*__pImageMenu, true);
+       __pImageMenu->SetFocusable(true);
 
        CATCH: return r;
 
@@ -869,6 +884,7 @@ result
 MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
 {
        result r = E_SUCCESS;
+       bool clipboardAvailable = true;
        ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
 
        AppLog("MainForm::InitSelectTextContextMenu clicked on text");
@@ -877,6 +893,8 @@ MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOpt
                delete __pImageMenu;
                __pImageMenu = null;
        }
+//     Point q(0,0);
+//     __pWebViewer->GetBlockRange(p,q);
 
        if(p.y < 150)
        {
@@ -887,6 +905,39 @@ MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOpt
        {
                direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
        }
+
+
+       Clipboard* pClipboard = Clipboard::GetInstance();
+
+       if(pClipboard == null)
+       {
+               clipboardAvailable = false;
+       }
+       else
+       {
+               // Retrieves a latest item
+               ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
+
+               if(pItem == null)
+               {
+                       clipboardAvailable = false;
+               }
+               else
+               {
+                       //Gets data from the clipboard item
+                       String* pString = dynamic_cast<String*>(pItem->GetData());
+
+                       if(pString == null)
+                       {
+                               clipboardAvailable = false;
+                       }
+               }
+       }
+       if(clipboardAvailable == false && onlyPasteOption == true)
+       {
+               return E_FAILURE;
+       }
+
        __pImageMenu = new (std::nothrow) ContextMenu();
        r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
        TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
@@ -895,7 +946,7 @@ MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOpt
        {
                r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
        }
-       if (pasteOption || onlyPasteOption)
+       if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
        {
                r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
        }
@@ -908,6 +959,7 @@ MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOpt
        __pImageMenu->SetMaxVisibleItemsCount(3);
        __pImageMenu->AddActionEventListener(*this);
        SetControlAlwaysOnTop(*__pImageMenu, true);
+       __pImageMenu->SetFocusable(true);
 
        CATCH: return r;
 
@@ -917,6 +969,7 @@ result
 MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
 {
        result r = E_SUCCESS;
+       bool clipboardAvailable = true;
        ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
 
        AppLog("MainForm::InitSelectTextContextMenu clicked on text");
@@ -925,25 +978,71 @@ MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPa
                delete __pImageMenu;
                __pImageMenu = null;
        }
-
+//     FloatPoint q(0.0,0.0);
+//             __pWebViewer->GetBlockRange(p,q);
        if(p.y < 150)
        {
                p.y = p.y + 50;
                direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
        }
+       else if(__pWebViewer != null && (p.y > (__pWebViewer->GetHeight() + __pWebViewer->GetY())))
+       {
+               p.y = __pWebViewer->GetHeight() + __pWebViewer->GetY();
+       }
        else
        {
+               if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
+               {
+                       AppLog("asdasdafdsfdgfd");
+                       p.y = p.y - 50;
+               }
                direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
        }
+
+
+       Clipboard* pClipboard = Clipboard::GetInstance();
+
+       if(pClipboard == null)
+       {
+               clipboardAvailable = false;
+       }
+       else
+       {
+               // Retrieves a latest item
+               ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
+
+               if(pItem == null)
+               {
+                       clipboardAvailable = false;
+               }
+               else
+               {
+                       //Gets data from the clipboard item
+                       String* pString = dynamic_cast<String*>(pItem->GetData());
+
+                       if(pString == null)
+                       {
+                               clipboardAvailable = false;
+                       }
+               }
+       }
+       if(clipboardAvailable == false && onlyPasteOption == true)
+       {
+               return E_FAILURE;
+       }
        __pImageMenu = new (std::nothrow) ContextMenu();
        r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
        TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
 
+
+
+
+
        if(onlyPasteOption == false)
        {
                r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
        }
-       if (pasteOption || onlyPasteOption)
+       if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
        {
                r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
        }
@@ -956,6 +1055,7 @@ MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPa
        __pImageMenu->SetMaxVisibleItemsCount(3);
        __pImageMenu->AddActionEventListener(*this);
        SetControlAlwaysOnTop(*__pImageMenu, true);
+       __pImageMenu->SetFocusable(true);
 
        CATCH: return r;
 
@@ -988,6 +1088,11 @@ MainForm::InitFindWordPanel(void)
                                delete pBitmap;
                        }
                }
+               if(__pAddressbar)
+                       __pAddressbar->SetShowState(false);
+
+               if(__isKeypadOpened == false)
+                       __pFooterPanel->SetShowState(true);
                return r;
        }
 
@@ -1111,7 +1216,7 @@ MainForm::InitFindWordPanel(void)
        }
 
        __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
-       if (__pFindWordCountLabel == null)
+       if (__pFindWordCountLabelRightToLeft == null)
        {
                AppLogException("There is some problem in the xml file. Please check.");
                return E_FAILURE;
@@ -1392,22 +1497,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                        pApp = UiApp::GetInstance();
                        if (pApp != null)
                        {
-                               RemoveOrientationEventListener(*this);
-
-                               if(__pAddressbar)
-                               {
-                                       __pAddressbar->SetAddressbarEventListener(null);
-                               }
-
-                               if(__pWebViewer)
-                               {
-                                       __pWebViewer->RemoveTouchEventListener(*this);
-                                       __pWebViewer->SetWebUiEventListenerF(null);
-                                       __pWebViewer->SetWebKeypadEventListener(null);
-                                       __pWebViewer->SetTextSearchListener(null);
-                                       __pWebViewer->SetLoadingListener(null);
-                               }
-                               r = pApp->Terminate();
+                               r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
                                if (IsFailed(r))
                                {
                                        AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
@@ -1431,22 +1521,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                                pApp = UiApp::GetInstance();
                                if (pApp != null)
                                {
-                                       RemoveOrientationEventListener(*this);
-
-                                       if(__pAddressbar)
-                                       {
-                                               __pAddressbar->SetAddressbarEventListener(null);
-                                       }
-
-                                       if(__pWebViewer)
-                                       {
-                                               __pWebViewer->RemoveTouchEventListener(*this);
-                                               __pWebViewer->SetWebUiEventListenerF(null);
-                                               __pWebViewer->SetWebKeypadEventListener(null);
-                                               __pWebViewer->SetTextSearchListener(null);
-                                               __pWebViewer->SetLoadingListener(null);
-                                       }
-                                       r = pApp->Terminate();
+                                       r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
                                        if (IsFailed(r))
                                        {
                                                AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
@@ -1466,22 +1541,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                                        pApp = UiApp::GetInstance();
                                        if (pApp != null)
                                        {
-                                               RemoveOrientationEventListener(*this);
-
-                                               if(__pAddressbar)
-                                               {
-                                                       __pAddressbar->SetAddressbarEventListener(null);
-                                               }
-
-                                               if(__pWebViewer)
-                                               {
-                                                       __pWebViewer->RemoveTouchEventListener(*this);
-                                                       __pWebViewer->SetWebUiEventListenerF(null);
-                                                       __pWebViewer->SetWebKeypadEventListener(null);
-                                                       __pWebViewer->SetTextSearchListener(null);
-                                                       __pWebViewer->SetLoadingListener(null);
-                                               }
-                                               r = pApp->Terminate();
+                                               r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
                                                if (IsFailed(r))
                                                {
                                                        AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
@@ -1519,29 +1579,14 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                                                        pApp = UiApp::GetInstance();
                                                        if (pApp != null)
                                                        {
-
-                                                               RemoveOrientationEventListener(*this);
-
-                                                               if(__pAddressbar)
-                                                               {
-                                                                       __pAddressbar->SetAddressbarEventListener(null);
-                                                               }
-
-                                                               if(__pWebViewer)
-                                                               {
-                                                                       __pWebViewer->RemoveTouchEventListener(*this);
-                                                                       __pWebViewer->SetWebUiEventListenerF(null);
-                                                                       __pWebViewer->SetWebKeypadEventListener(null);
-                                                                       __pWebViewer->SetTextSearchListener(null);
-                                                                       __pWebViewer->SetLoadingListener(null);
-                                                               }
-                                                               r = pApp->Terminate();
+                                                               r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
                                                                return;
                                                        }
                                                }
                                                else
                                                {
-                                                       r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
+                                                       r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
+//                                                     r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
                                                        if (IsFailed(r))
                                                        {
                                                                AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
@@ -1908,7 +1953,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                                __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
                                __pOptionMenu->SetMaxVisibleItemsCount(6);
                        }
-                       if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
+                       if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
                        {
                                AppLog(" Orientation landscape");
                                __pOptionMenu->SetMaxVisibleItemsCount(5);
@@ -2038,7 +2083,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                __pFindWordNext->SetEnabled(false);
                __pFindWordPrev->SetEnabled(false);
                __pFindWordCountLabel->SetText(L"0/0");
-               __pWebViewer->SearchText(L"aaaabbbbcccc",true);
+               __pWebViewer->SearchTextAllAsync(L"",true);
                AppLog("akjshdasd 1");
                if(__isKeypadOpened == false)
                        __pFooterPanel->SetShowState(true);
@@ -2185,7 +2230,6 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                                {
                                        __pNotification->SetPositionDiff(0);
                                }
-
                                __pNotification->ShowNotification();
                        }
                }
@@ -2193,7 +2237,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                {
                        int __modalMsgBoxResult;
                        MessageBox* pMsgBox = new MessageBox();
-                       pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
+                       pMsgBox->Construct(CommonUtil::GetString(L"IDS_IMGE_POP_UNABLE_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_IMGE_POP_UNABLE_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
                        pMsgBox->ShowAndWait(__modalMsgBoxResult);
                        delete pMsgBox;
                        pMsgBox = null;
@@ -2258,6 +2302,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                        {
                                return;
                        }
+                       pNewWindowInfo->isJavascriptInitiated = true;
                        result r = E_SUCCESS;
                        SceneManager* pSceneManager = SceneManager::GetInstance();
                        if (pSceneManager == NULL)
@@ -2464,6 +2509,10 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                        String nameElement = __pHitElementResult->GetAttributeValue(L"name");
                        String tagElement  = __pHitElementResult->GetTagName();
                        AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
+                       String str = L"document.getElementsByName('";
+                       str.Append(nameElement);
+                       str.Append("').length");
+                       String* pCount = __pWebViewer->EvaluateJavascriptN(str);
 
                        String script;
                        if(idElement.GetLength() != 0)
@@ -2476,9 +2525,9 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                                script.Append(*pString);
                                script.Append("\");");
                        }
-                       else if (nameElement.GetLength() != 0)
+                       else if (nameElement.GetLength() != 0 && pCount->Equals("1",false) == true)
                        {
-                               script = L"function insertAtCursor(myField, myValue) {  if (document.selection) {   document.getElementByName(myField)[0].focus();   sel = document.selection.createRange();   sel.text = myValue;  }   else if (myField.selectionStart || myField.selectionStart == '0'){   var startPos = myField.selectionStart;   var endPos = myField.selectionEnd;   myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length);   } else {    document.getElementByName(myField)[0].value += myValue;   }  } ";
+                               script = L"function insertAtCursor(myField, myValue) {  if (document.selection) {   myField.focus();   sel = document.selection.createRange();   sel.text = myValue;  }   else if (myField.selectionStart || myField.selectionStart == '0'){   var startPos = myField.selectionStart;   var endPos = myField.selectionEnd;   myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length);   } else {    myField.value += myValue;   }  } ";
                                script.Append("insertAtCursor(document.getElementsByName('");
                                script.Append(nameElement);
                                script.Append("')[0],");
@@ -2486,7 +2535,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                                script.Append(*pString);
                                script.Append("\");");
                        }
-                       else//adding for twitter post page
+                       else if(tagElement.GetLength() != 0) //adding for twitter post page
                        {
                                script = L"function insertAtCursor(myField, myValue) {  if (document.selection) {   document.getElementsByTagName(myField)[0].focus();   sel = document.selection.createRange();   sel.text = myValue;  }   else if (myField.selectionStart || myField.selectionStart == '0'){   var startPos = myField.selectionStart;   var endPos = myField.selectionEnd;   myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length);   } else {    document.getElementsByTagName(myField)[0].value += myValue;   }  } ";
                                script.Append("insertAtCursor(document.getElementsByTagName('");
@@ -2499,6 +2548,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                        AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
                        String* pStr = __pWebViewer->EvaluateJavascriptN(script);
                        delete pStr;
+                       delete pCount;
                }
                delete pItem;
        }
@@ -2525,7 +2575,8 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
 //             LoadUrl(url);
                if (__pWebViewer != null && __pAddressbar != null)
                {
-                       __pWebViewer->Reload();
+                       LoadUrl(url);
+                       //__pWebViewer->Reload();
                        SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
                }
 
@@ -2575,6 +2626,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
 void
 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
 {
+       AppLog("MainForm::OnFormBackRequested entered");
        result r = E_FAILURE;
        if(__pImageMenu && __pImageMenu->GetShowState() == true)
        {
@@ -2585,28 +2637,13 @@ MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
        {
                __pWebViewer->GoBack();
        }
-       else if(__pWindowInfo->isJavascriptInitiated == false)
+       else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
        {
                UiApp* pApp = null;
                pApp = UiApp::GetInstance();
                if (pApp != null)
                {
-                       RemoveOrientationEventListener(*this);
-
-                       if(__pAddressbar)
-                       {
-                               __pAddressbar->SetAddressbarEventListener(null);
-                       }
-
-                       if(__pWebViewer)
-                       {
-                               __pWebViewer->RemoveTouchEventListener(*this);
-                               __pWebViewer->SetWebUiEventListenerF(null);
-                               __pWebViewer->SetWebKeypadEventListener(null);
-                               __pWebViewer->SetTextSearchListener(null);
-                               __pWebViewer->SetLoadingListener(null);
-                       }
-                       r = pApp->Terminate();
+                       r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
                        if (IsFailed(r))
                        {
                                AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
@@ -2630,22 +2667,7 @@ MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
                        pApp = UiApp::GetInstance();
                        if (pApp != null)
                        {
-                               RemoveOrientationEventListener(*this);
-
-                               if(__pAddressbar)
-                               {
-                                       __pAddressbar->SetAddressbarEventListener(null);
-                               }
-
-                               if(__pWebViewer)
-                               {
-                                       __pWebViewer->RemoveTouchEventListener(*this);
-                                       __pWebViewer->SetWebUiEventListenerF(null);
-                                       __pWebViewer->SetWebKeypadEventListener(null);
-                                       __pWebViewer->SetTextSearchListener(null);
-                                       __pWebViewer->SetLoadingListener(null);
-                               }
-                               r = pApp->Terminate();
+                               r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
                                if (IsFailed(r))
                                {
                                        AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
@@ -2665,22 +2687,7 @@ MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
                                pApp = UiApp::GetInstance();
                                if (pApp != null)
                                {
-                                       RemoveOrientationEventListener(*this);
-
-                                       if(__pAddressbar)
-                                       {
-                                               __pAddressbar->SetAddressbarEventListener(null);
-                                       }
-
-                                       if(__pWebViewer)
-                                       {
-                                               __pWebViewer->RemoveTouchEventListener(*this);
-                                               __pWebViewer->SetWebUiEventListenerF(null);
-                                               __pWebViewer->SetWebKeypadEventListener(null);
-                                               __pWebViewer->SetTextSearchListener(null);
-                                               __pWebViewer->SetLoadingListener(null);
-                                       }
-                                       r = pApp->Terminate();
+                                       r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
                                        if (IsFailed(r))
                                        {
                                                AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
@@ -2690,7 +2697,7 @@ MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
                        }
                        else
                        {
-                               if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
+                               if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
                                {
                                        r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
                                        if (IsFailed(r))
@@ -2718,28 +2725,14 @@ MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
                                                pApp = UiApp::GetInstance();
                                                if (pApp != null)
                                                {
-                                                       RemoveOrientationEventListener(*this);
-
-                                                       if(__pAddressbar)
-                                                       {
-                                                               __pAddressbar->SetAddressbarEventListener(null);
-                                                       }
-
-                                                       if(__pWebViewer)
-                                                       {
-                                                               __pWebViewer->RemoveTouchEventListener(*this);
-                                                               __pWebViewer->SetWebUiEventListenerF(null);
-                                                               __pWebViewer->SetWebKeypadEventListener(null);
-                                                               __pWebViewer->SetTextSearchListener(null);
-                                                               __pWebViewer->SetLoadingListener(null);
-                                                       }
-                                                       r = pApp->Terminate();
+                                                       r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
                                                        return;
                                                }
                                        }
                                        else
                                        {
-                                               r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
+                                               if(pWindowInfo != null)
+                                                       r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
                                                if (IsFailed(r))
                                                {
                                                        AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
@@ -2748,9 +2741,24 @@ MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
                                        }
                                        break;
                                }
+//                             else if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == false)
+//                             {
+//                                     UiApp* pApp = null;
+//                                     pApp = UiApp::GetInstance();
+//                                     if (pApp != null)
+//                                     {
+//                                             r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
+//                                             if (IsFailed(r))
+//                                             {
+//                                                     AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
+//                                                     return;
+//                                             }
+//                                     }
+//                             }
                        }
                }
        }
+       AppLog("MainForm::OnFormBackRequested exit");
 }
 
 void
@@ -2820,12 +2828,16 @@ MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
                else if(__pWindowInfo->pageUrl.GetLength() > 0 && __pWindowInfo->isAppcontrolTriggered == true)
                {
                        LoadUrl(__pWindowInfo->pageUrl);
+                       __pWindowInfo->isAppcontrolTriggered = false;
                }
-               else if (__pWindowInfo->isJavascriptInitiated == true)
+               else if (__pWindowInfo->isJavascriptInitiated == true && __pWindowInfo->isFirstLaunch == true)
                {
+                       __pWindowInfo->isFirstLaunch = false;
                        AppLog("Called");
                        InitWebControl();
                        __pWindowInfo->pCurrentWeb = __pWebViewer;
+                       if(__pWindowInfo->pageUrl.GetLength() > 0)
+                               LoadUrl(__pWindowInfo->pageUrl);
                }
        }
 
@@ -2942,13 +2954,18 @@ MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
                pCanvas->DrawBitmap(Point(0,0),*pBitmap);
                delete pBitmap;
        }
-       if(__pWebViewer != null && __pWindowInfo != null)
+       if(__pWebViewer != null && __pWindowInfo != null && __pWindowInfo->pWebCanvasBitmap != null)
                pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
 
        WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
-       WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
+       if (__pFooterPanel)
+       {
+               WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
+       }
        delete pCanvas;
        delete pWebCanvas;
+       if(__pAddressbar)
+               __pAddressbar->SetShowState(false);
        AppLog("Coming here");
 }
 
@@ -3311,7 +3328,7 @@ MainForm::OnLoadingCompleted(void)
 void
 MainForm::OnEstimatedProgress(int progress)
 {
-       AppLogDebug("MainForm::OnEstimatedProgress entered");
+       AppLogDebug("MainForm::OnEstimatedProgress entered %d",progress);
 
        if (progress < DEFAULT_PROGRESS_PERCENTAGE)
                progress = DEFAULT_PROGRESS_PERCENTAGE;
@@ -3440,6 +3457,33 @@ MainForm::OnFocusGained(const Tizen::Ui::Control& source)
                __pAddressbar->SetShowState(true);
                __pAddressbar->SetAddressbarURLFocus();
        }
+       if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
+       {
+               __currentSearchStr = L"";
+               __currentWordIndex = 0;
+               __maxOccurrances = 0;
+
+               if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
+               {
+                       __pFindWordEditField->SetText(L"");
+                       __pFindWordEditField->HideKeypad();
+                       __pFindWordControl->SetShowState(false);
+                       __pFindWordCountLabel->SetText(L"0/0");
+               }
+               else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
+               {
+                       __pFindWordEditFieldRightToLeft->SetText(L"");
+                       __pFindWordEditFieldRightToLeft->HideKeypad();
+                       __pFindWordControl->SetShowState(false);
+                       __pFindWordCountLabelRightToLeft->SetText(L"0/0");
+               }
+
+               __pFindWordNext->SetEnabled(false);
+               __pFindWordPrev->SetEnabled(false);
+
+               __pWebViewer->SearchTextAllAsync(L"",true);
+               __pFindWordControl->SetShowState(false);
+       }
        RelayoutControls(false);
 }
 
@@ -3483,25 +3527,7 @@ MainForm::OnBackClicked(/*const Addressbar& addBar*/)
                pApp = UiApp::GetInstance();
                if (pApp != null)
                {
-
-                       RemoveOrientationEventListener(*this);
-
-                       if(__pAddressbar)
-                       {
-                               __pAddressbar->SetAddressbarEventListener(null);
-                       }
-
-                       if(__pWebViewer)
-                       {
-                               __pWebViewer->RemoveTouchEventListener(*this);
-                               __pWebViewer->SetWebUiEventListenerF(null);
-                               __pWebViewer->SetWebKeypadEventListener(null);
-                               __pWebViewer->SetTextSearchListener(null);
-                               __pWebViewer->SetLoadingListener(null);
-                       }
-
-
-                       r = pApp->Terminate();
+                       r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
                        if (IsFailed(r))
                        {
                                AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
@@ -3525,24 +3551,7 @@ MainForm::OnBackClicked(/*const Addressbar& addBar*/)
                        pApp = UiApp::GetInstance();
                        if (pApp != null)
                        {
-                               RemoveOrientationEventListener(*this);
-
-                               if(__pAddressbar)
-                               {
-                                       __pAddressbar->SetAddressbarEventListener(null);
-                               }
-
-                               if(__pWebViewer)
-                               {
-                                       __pWebViewer->RemoveTouchEventListener(*this);
-                                       __pWebViewer->SetWebUiEventListenerF(null);
-                                       __pWebViewer->SetWebKeypadEventListener(null);
-                                       __pWebViewer->SetTextSearchListener(null);
-                                       __pWebViewer->SetLoadingListener(null);
-                               }
-
-
-                               r = pApp->Terminate();
+                               r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
                                if (IsFailed(r))
                                {
                                        AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
@@ -3562,24 +3571,7 @@ MainForm::OnBackClicked(/*const Addressbar& addBar*/)
                                pApp = UiApp::GetInstance();
                                if (pApp != null)
                                {
-                                       RemoveOrientationEventListener(*this);
-
-                                       if(__pAddressbar)
-                                       {
-                                               __pAddressbar->SetAddressbarEventListener(null);
-                                       }
-
-                                       if(__pWebViewer)
-                                       {
-                                               __pWebViewer->RemoveTouchEventListener(*this);
-                                               __pWebViewer->SetWebUiEventListenerF(null);
-                                               __pWebViewer->SetWebKeypadEventListener(null);
-                                               __pWebViewer->SetTextSearchListener(null);
-                                               __pWebViewer->SetLoadingListener(null);
-                                       }
-
-
-                                       r = pApp->Terminate();
+                                       r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
                                        if (IsFailed(r))
                                        {
                                                AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
@@ -3615,24 +3607,7 @@ MainForm::OnBackClicked(/*const Addressbar& addBar*/)
                                        pApp = UiApp::GetInstance();
                                        if (pApp != null)
                                        {
-                                               RemoveOrientationEventListener(*this);
-
-                                               if(__pAddressbar)
-                                               {
-                                                       __pAddressbar->SetAddressbarEventListener(null);
-                                               }
-
-                                               if(__pWebViewer)
-                                               {
-                                                       __pWebViewer->RemoveTouchEventListener(*this);
-                                                       __pWebViewer->SetWebUiEventListenerF(null);
-                                                       __pWebViewer->SetWebKeypadEventListener(null);
-                                                       __pWebViewer->SetTextSearchListener(null);
-                                                       __pWebViewer->SetLoadingListener(null);
-                                               }
-
-
-                                               r = pApp->Terminate();
+                                               r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
                                                return;
                                        }
 
@@ -3642,30 +3617,14 @@ MainForm::OnBackClicked(/*const Addressbar& addBar*/)
                                        pApp = UiApp::GetInstance();
                                        if (pApp != null)
                                        {
-                                               RemoveOrientationEventListener(*this);
-
-                                               if(__pAddressbar)
-                                               {
-                                                       __pAddressbar->SetAddressbarEventListener(null);
-                                               }
-
-                                               if(__pWebViewer)
-                                               {
-                                                       __pWebViewer->RemoveTouchEventListener(*this);
-                                                       __pWebViewer->SetWebUiEventListenerF(null);
-                                                       __pWebViewer->SetWebKeypadEventListener(null);
-                                                       __pWebViewer->SetTextSearchListener(null);
-                                                       __pWebViewer->SetLoadingListener(null);
-                                               }
-
-
-                                               r = pApp->Terminate();
+                                               r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
                                                return;
                                        }
                                }
                                else
                                {
-                                       r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
+                                       r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
+//                                     r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
                                        if (IsFailed(r))
                                        {
                                                AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
@@ -3769,6 +3728,12 @@ void
 MainForm::OnClipboardClosed(const Addressbar& addBar)
 {
        AppLog("XYZ::MainForm::OnClipboardClosed");
+       if (__pFooterPanel && __pAddressbar->GetShowState() == false)
+       {
+               AppLog("akjshdasd 3");
+               __pFooterPanel->SetShowState(true);
+       }
+       __isKeypadOpened = false;
        RelayoutControls(false);
 }
 
@@ -3781,6 +3746,11 @@ MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
                AppLog("akjshdasd 3");
                __pFooterPanel->SetShowState(true);
        }
+       __isKeypadOpened = false;
+       if(__pNotification && __pNotification->GetShowState())
+       {
+               __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
+       }
 
        RelayoutControls(false,footerState);
 }
@@ -3789,12 +3759,18 @@ void
 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
 {
        AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
+       __isKeypadOpened = true;
+       if(__pNotification && __pNotification->GetShowState())
+       {
+               __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
+       }
        RelayoutControls(false);
 }
 
 void
 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
 {
+       __isKeypadOpened = true;
        __pFooterPanel->SetShowState(false);
 }
 
@@ -3815,6 +3791,7 @@ MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
                if (__pWebViewer != null)
                {
                        __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
+                       AppLog("MainForm::OnPageTitleReceived url %ls",__pWindowInfo->pageUrl.GetPointer());
                }
        }
        if (__pAddressbar != null && __pWebViewer != null)
@@ -3842,7 +3819,8 @@ MainForm::UpdateFavicon(void)
                        if (url.GetHost().GetLength() == 0)
                        {
                                Uri webUrl;
-                               webUrl.SetUri(__pWebViewer->GetUrl());
+                               if(__pWebViewer)
+                                       webUrl.SetUri(__pWebViewer->GetUrl());
                                result r = url.SetHost(webUrl.GetHost());
                                if(IsFailed(r))
                                {
@@ -3853,7 +3831,8 @@ MainForm::UpdateFavicon(void)
                        if (url.GetScheme().GetLength() == 0)
                        {
                                Uri webUrl;
-                               webUrl.SetUri(__pWebViewer->GetUrl());
+                               if(__pWebViewer)
+                                       webUrl.SetUri(__pWebViewer->GetUrl());
                                url.SetScheme(webUrl.GetScheme());
                        }
                        __pWindowInfo->faviconUrl = url.ToString();
@@ -3998,9 +3977,10 @@ MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
 void
 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
 {
-       if(__isLongPressedDone == false)
-               return;
        AppLog("MainForm::OnWebPageBlockSelected");
+//     if(__isLongPressedDone == false)
+//             return;
+
        if (__pHitElementResult != null)
        {
                delete __pHitElementResult;
@@ -4012,11 +3992,11 @@ MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint
                AppLog("MainForm::OnWebPageBlockSelected web not null");
                __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
 
-               if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
+               if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
                {
                        AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
                        __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
-                       if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
+                       if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
                        {
                                __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
                        }
@@ -4040,15 +4020,26 @@ MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint
                AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
                __currentSelectedStr = __pWebViewer->GetTextFromBlock();
                AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
+               if(tagName.Equals(L"TEXTAREA",false) == true)
+               {
+                       AppLog("Tagnameseemstobe TEXTAREA");
+               }
+               else if(tagName.Equals(L"INPUT",false) == true)
+               {
+                       AppLog("Tagnameseemstobe INPUT");
+               }
 
-               if (((tagName.CompareTo(L"INPUT") == 0)  || tagName.CompareTo(L"TEXTAREA") == 0) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
+               if (((tagName.Equals(L"INPUT",false) == true)  || tagName.Equals(L"TEXTAREA",false) == true) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
                {
                        AppLog("MainForm::OnWebPageBlockSelected show paste option");
 
                        InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),true);
-                       __pImageMenu->SetShowState(true);
-                       __pImageMenu->Show();
-                       __pImageMenu->Invalidate(true);
+                       if(__pImageMenu)
+                       {
+                               __pImageMenu->SetShowState(true);
+                               __pImageMenu->Show();
+                               __pImageMenu->Invalidate(true);
+                       }
                }
                else /*if(__isLongPressedDone == true)*/
                {
@@ -4060,9 +4051,12 @@ MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint
                                __currentSelectedStr = __pHitElementResult->GetUrl();
                        }
                        InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),false);
-                       __pImageMenu->SetShowState(true);
-                       __pImageMenu->Show();
-                       __pImageMenu->Invalidate(true);
+                       if(__pImageMenu)
+                       {
+                               __pImageMenu->SetShowState(true);
+                               __pImageMenu->Show();
+                               __pImageMenu->Invalidate(true);
+                       }
                }
 
                AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
@@ -4081,6 +4075,7 @@ MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
 Web*
 MainForm::OnWebWindowCreateRequested(void)
 {
+       AppLog("MainForm::OnWebWindowCreateRequested entered");
        WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
 
        if (pNewWindowInfo == null)
@@ -4117,6 +4112,97 @@ MainForm::OnWebWindowCreateRequested(void)
        return pNewWindowInfo->pCurrentWeb;
 }
 
+void MainForm::OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source)
+{
+       AppLog("OnWebWindowCloseRequested");
+       ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       WindowInfo* pWindowInfo = null;
+       WindowInfo* pNewWindowInfo = null;
+       int totalCount = 0;
+       UiApp* pApp = null;
+       result r = E_FAILURE;
+
+       if (pAllWindowList != null)
+       {
+               totalCount = pAllWindowList->GetCount();
+       }
+
+       for (int count = 0; count < totalCount; count++)
+       {
+               pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
+               if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID)
+               {
+                       r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
+                       if (IsFailed(r))
+                       {
+                               AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
+                               return;
+                       }
+
+                       r = pAllWindowList->RemoveAt(count, true);
+
+                       if(count > 0)
+                       {
+                               pNewWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
+                       }
+                       else if(pAllWindowList->GetCount() > 0)
+                       {
+                               pNewWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
+                       }
+                       else
+                       {
+                               WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
+
+                               if (pNewWindowInfo == null)
+                               {
+                                       return;
+                               }
+                               result r = E_SUCCESS;
+                               SceneManager* pSceneManager = SceneManager::GetInstance();
+                               if (pSceneManager == NULL)
+                               {
+                                       return;
+                               }
+                               ArrayList* pArgList = new(std::nothrow) ArrayList();
+                               if (pArgList == NULL)
+                               {
+                                       return;
+                               }
+                               r = pArgList->Construct();
+                               if (r == E_SUCCESS)
+                               {
+                                       pArgList->Add(*pNewWindowInfo);
+                                       result r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
+                                       if (pArgList != null)
+                                       {
+                                               delete pArgList;
+                                               pArgList = null;
+                                       }
+                                       if(IsFailed(r))
+                                       {
+                                               AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
+                                               return;
+                                       }
+                               }
+
+                               pApp = UiApp::GetInstance();
+                               if (pApp != null)
+                               {
+                                       r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
+                                       return;
+                               }
+
+                       }
+                       r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
+
+                       __pWindowInfo = null;
+                       break;
+               }
+       }
+
+}
+
 void
 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
 {
@@ -4144,15 +4230,16 @@ MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
                __webControlHeight -= __pFooterPanel->GetHeight();
 
                __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
+               __webControlHeight = __webControlHeight + 12;
        }
        if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
        {
-               if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight + 12 )
+               if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight )
                {
                }
                else
                {
-                       __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
+                       __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight );
                        AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight);
                        __pWebViewer->Invalidate(false);
                }
@@ -4193,7 +4280,7 @@ MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
                        __pFindWordPanelRightToLeft->SetShowState(true);
 
                        __pFindWordClear->SetShowState(false);
-//                     __pFindWordCountLabel->SetShowState(false);
+                       __pFindWordCountLabel->SetShowState(false);
                        __pFindWordEditField->SetShowState(false);
 
                        __pFindWordClearRightToLeft->SetShowState(true);
@@ -4272,8 +4359,12 @@ MainForm::StartWordSearch()
 
        __pFindWordPrev->SetEnabled(false);
        String *pCountStr = null;
-       result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
-       AppLog("Search Result %s",GetErrorMessage(r));
+       if (__pWebViewer)
+       {
+               result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
+               AppLog("Search Result %s",GetErrorMessage(r));
+       }
+
        /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/"  + __currentSearchStr + "/gi).length;");
        if (pCountStr != null)
        {
@@ -4291,21 +4382,38 @@ void MainForm::OnTextFound(int totalCount, int currentOrdinal)
        AppLog("MainForm::OnTextFound totalCount %d",totalCount);
        AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
 
-       if(totalCount == -1 || totalCount == 0)
+       if(totalCount <= 9)
        {
-               __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
-               __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
-//             return;
+               if (__pFindWordCountLabel)
+               {
+                       __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
+               }
+               if (__pFindWordEditField)
+               {
+                       __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
+               }
        }
-       else if(totalCount > 100)
+       else if(totalCount >= 100)
        {
-               __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
-               __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
+               if (__pFindWordCountLabel)
+               {
+                       __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
+               }
+               if (__pFindWordEditField)
+               {
+                       __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
+               }
        }
        else
        {
-               __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
-               __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
+               if (__pFindWordCountLabel)
+               {
+                       __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
+               }
+               if (__pFindWordEditField)
+               {
+                       __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
+               }
        }
 
        __maxOccurrances = totalCount;
@@ -4333,7 +4441,7 @@ void MainForm::OnTextFound(int totalCount, int currentOrdinal)
                return;
        }
 
-       if (totalCount == 1)
+       if (totalCount == 1 || totalCount == currentOrdinal)
        {
                __pFindWordNext->SetEnabled(false);
        }
@@ -4352,16 +4460,20 @@ void MainForm::OnTextFound(int totalCount, int currentOrdinal)
        __pFindWordCountLabel->Invalidate(false);
        __pFindWordCountLabel->Invalidate(false);
        }
-       else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
+       else if (__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
        {
                __pFindWordCountLabelRightToLeft->SetText(countStr);
                __pFindWordCountLabelRightToLeft->Invalidate(false);
                __pFindWordCountLabelRightToLeft->Invalidate(false);
        }
-       //FindNextWord(true);
-       //Update the controls
-       __pFindWordNext->Invalidate(false);
-       __pFindWordPrev->Invalidate(false);
+       if (__pFindWordNext)
+       {
+               __pFindWordNext->Invalidate(false);
+       }
+       if (__pFindWordPrev)
+       {
+               __pFindWordPrev->Invalidate(false);
+       }
 
 }
 
@@ -4484,12 +4596,28 @@ MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
 void
 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
 {
+       AppLog("abcde::MainForm::OnWebKeypadClosed");
        AppLog("xyz::MainForm::OnWebKeypadClosed");
        AppLog("akjshdasd 4");
        __pFooterPanel->SetShowState(true);
 //     OnAddressBarKeypadClosed(*__pAddressbar);
        RelayoutControls(false);
        __isKeypadOpened = false;
+
+
+       if(__pImageMenu && __pImageMenu->GetShowState() == true)
+       {
+               AppLog("abcde: imagemenu visible.");
+               Point p(0,0);
+               Point q(0,0);
+               __pWebViewer->GetBlockRange(p,q);
+               if (p == Point(0,0) && q == Point(0,0))
+                       return;
+
+               __pImageMenu->SetAnchorPosition(p);
+               __pImageMenu->Show();
+               Invalidate(true);
+       }
 }
 
 void
@@ -4526,7 +4654,7 @@ MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPositi
 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
 {
        AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
-       if(TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
+       if(TouchEventManager::GetInstance() && TouchEventManager::GetInstance()->GetTouchInfoListN() && TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
        {
                AppLog("Returning because of more than one touch point.");
                return;
@@ -4593,7 +4721,7 @@ void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen:
 
                __isLongPressedDone = true;
                result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
-               if (((tagName.CompareTo(L"INPUT") == 0)  || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0  && type.CompareTo(L"submit") !=0/*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
+               if (((tagName.Equals(L"INPUT",false) == true)  || tagName.Equals(L"TEXTAREA",false) == true) && innerHtml.GetLength() == 0  && type.Equals(L"submit",false) !=true && type.Equals(L"range",false) !=true/*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.Equals(L"",false) == true && r == E_INVALID_ARG)
                {
                        AppLog("MainForm::OnWebPageBlockSelected show paste option");
 
@@ -4672,7 +4800,7 @@ MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEven
                __pFindWordNext->SetEnabled(false);
                __pFindWordPrev->SetEnabled(false);
 
-               __pWebViewer->SearchText(L"aaaabbbbcccc",true);
+               __pWebViewer->SearchTextAllAsync(L"",true);
                __pFindWordControl->SetShowState(false);
        }
        AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState());
@@ -4734,7 +4862,7 @@ MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::Ori
 
        if(__pOptionMenu && __pOptionMenu->GetShowState() == true)
        {
-               if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
+               if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
                {
                        AppLog(" Orientation landscape");
                        __pOptionMenu->SetMaxVisibleItemsCount(5);
@@ -5371,7 +5499,6 @@ MainForm::ShowIndicatorNotification(const String& messageText, const String& con
        Tizen::Shell::NotificationManager notiMgr;
        notiMgr.Construct();
        notiMgr.NotifyOngoingActivity(request);
-
        AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
        return;
 }
@@ -5778,7 +5905,7 @@ MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
                        __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
                        __pOptionMenu->SetMaxVisibleItemsCount(6);
                }
-               if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
+               if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
                {
                        AppLog(" Orientation landscape");
                        __pOptionMenu->SetMaxVisibleItemsCount(5);
@@ -5793,8 +5920,13 @@ MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
                delete pBitmap;
        }
        AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
+       if(__pAddressbar)
+               __pAddressbar->SetShowState(false);
+       SetFocus();
+       __pFooterPanel->SetShowState(true);
        result r = __pOptionMenu->SetShowState(true);
        AppLog("ajsghd %s",GetErrorMessage(r));
+       RelayoutControls(false);
        __pOptionMenu->Invalidate(true);
        __pOptionMenu->Show();