webengine/osswebengine/WebKit/s60/misc/WebTabbedNavigation.cpp
changeset 10 a359256acfc6
parent 5 10e98eab6f85
child 15 60c5402cb945
--- a/webengine/osswebengine/WebKit/s60/misc/WebTabbedNavigation.cpp	Fri Jul 03 15:54:40 2009 +0100
+++ b/webengine/osswebengine/WebKit/s60/misc/WebTabbedNavigation.cpp	Thu Aug 27 07:44:59 2009 +0300
@@ -107,6 +107,28 @@
         StaticObjectsContainer::instance()->webCursor()->cursorUpdate(true);
         return true;
     }
+    // DOM can be changed so check if we are still inside the document
+    // If not reset tabbed navigation parameters to the closest point in document.
+    TSize contentSize = m_webView->mainFrame()->frameView()->contentSize();
+    TPoint contentPos = m_webView->mainFrame()->frameView()->contentPos();
+    TRect docRect = TRect(contentPos, contentSize - contentPos);
+    if (!docRect.Contains(m_focusPosition)) {
+        TInt viewW = m_webView->Rect().Width();
+        TInt viewH = m_webView->Rect().Height();
+        if (m_focusPosition.iX > contentSize.iWidth || 
+            m_focusPosition.iX < contentPos.iX) {
+            m_focusPosition.iX = (horizontalDir == -1) ? contentPos.iX + viewW : contentPos.iX;
+        }
+        
+        if (m_focusPosition.iY > contentSize.iHeight || 
+            m_focusPosition.iY < contentPos.iY) {
+            m_focusPosition.iY = (verticalDir == -1) ? contentPos.iY + viewH : contentPos.iY;
+        }
+
+        m_selectedElementRect.SetRect(m_focusPosition.iX, m_focusPosition.iY, m_focusPosition.iX, m_focusPosition.iY);
+        m_node = NULL;    
+    }
+    
     bool ret = m_firstNavigationOnPage;
     Frame* focusedFrame = m_webView->page()->focusController()->focusedFrame();
     if (focusedFrame == NULL) focusedFrame = m_webView->page()->mainFrame();
@@ -188,7 +210,7 @@
         f = f->tree()->traverseNext();
     } // while ( f )
     // Remember new selection
-    TPoint contentPos = m_webView->mainFrame()->frameView()->contentPos();
+    contentPos = m_webView->mainFrame()->frameView()->contentPos();
     if (selectedNode) {
         // Found an element to jump to
         m_selectedElementRect = selectedRect;