diff -r 000000000000 -r dd21522fd290 webengine/osswebengine/WebKit/s60/misc/WebTabbedNavigation.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/webengine/osswebengine/WebKit/s60/misc/WebTabbedNavigation.cpp Mon Mar 30 12:54:55 2009 +0300 @@ -0,0 +1,321 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Frame in webkit side +* +*/ + +#include "config.h" +#include <../bidi.h> +#include +#include +#include "WebTabbedNavigation.h" +#include "WebUtil.h" +#include "Document.h" +#include "Frame.h" +#include "HTMLNames.h" +#include "FrameTree.h" +#include "BrCtlDefs.h" +#include "WebCursor.h" +#include "StaticObjectsContainer.h" +#include "Page.h" +#include "WebView.h" +#include "WebFrame.h" +#include "WebFrameView.h" +#include +#include "EventHandler.h" +#include "webkitlogger.h" +#include "FocusController.h" +#include "RenderListBox.h" +#include "HTMLSelectElement.h" + +using namespace WebCore; +using namespace HTMLNames; + +const int KMaxJumpPercent = 90; +const int KScrollWhenNotFound = 5; + +WebTabbedNavigation::WebTabbedNavigation(WebView* webView) +{ + m_webView = webView; + clear(); +} + +WebTabbedNavigation::~WebTabbedNavigation() +{ +} + +void WebTabbedNavigation::clear() +{ + // Different initialization for mirrored layouts? + m_selectedElementRect.SetRect(0, 0, m_webView->Rect().Width(), 0); + m_initializedForPage = false; + m_firstNavigationOnPage = true; + m_focusPosition = TPoint(0,0); + m_node = NULL; +} + +void WebTabbedNavigation::initializeForPage() +{ + if (!m_initializedForPage) { + if (navigate(0, 1)) { + m_initializedForPage = true; + m_firstNavigationOnPage = false; + } + } +} + + +bool WebTabbedNavigation::navigate(int horizontalDir, int verticalDir) +{ + if (handleSelectElementScrolling(m_webView, verticalDir)) { + StaticObjectsContainer::instance()->webCursor()->cursorUpdate(true); + return true; + } + bool ret = m_firstNavigationOnPage; + Frame* focusedFrame = m_webView->page()->focusController()->focusedFrame(); + if (focusedFrame == NULL) focusedFrame = m_webView->page()->mainFrame(); + if (focusedFrame->document()) { + Node* focusNode = focusedFrame->document()->focusedNode(); + if (focusNode) { + m_node = focusNode; + m_selectedElementRect = focusNode->getRect().Rect(); + Frame* frame = focusNode->document()->frame(); + m_selectedElementRect = TRect(kit(frame)->frameView()->frameCoordsInViewCoords(m_selectedElementRect.iTl), + kit(frame)->frameView()->frameCoordsInViewCoords(m_selectedElementRect.iBr)); + } + } + TPoint oldFocusPoint(m_focusPosition); + // Move the focus to the edge of the current object + if (horizontalDir == -1) { + m_focusPosition.iX = m_selectedElementRect.iTl.iX; + } + else if (horizontalDir == 1) { + m_focusPosition.iX = m_selectedElementRect.iBr.iX; + } + if (verticalDir == -1) { + m_focusPosition.iY = m_selectedElementRect.iTl.iY; + } + else if (verticalDir == 1) { + m_focusPosition.iY = m_selectedElementRect.iBr.iY; + } + wkDebug()<<"WebTabbedNavigation::navigate. x = "<(e->renderer()); + HTMLSelectElement* selectElement = static_cast( e ); + IntRect itemRect = render->itemRect(0, 0, 0); + TPoint cursorPoint(StaticObjectsContainer::instance()->webCursor()->position()); + int gap = (20 * m_webView->scalingFactor()) / 100; + cursorPoint.iX = max(m_focusPosition.iX, m_selectedElementRect.iTl.iX + gap); + cursorPoint.iX = std::min(cursorPoint.iX, m_selectedElementRect.iBr.iX - gap); + if (verticalDir == -1) { + cursorPoint.iY -= (itemRect.height() * m_webView->scalingFactor()) / 125; + } + if (cursorPoint != StaticObjectsContainer::instance()->webCursor()->position()) { + StaticObjectsContainer::instance()->webCursor()->setPosition(cursorPoint); + } + } + } + } + TPointerEvent event; + event.iPosition = StaticObjectsContainer::instance()->webCursor()->position(); + event.iModifiers = 0; + event.iType = TPointerEvent::EMove; + core(m_webView->mainFrame())->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event)); + wkDebug()<<"Focus position x = "<