--- a/webengine/osswebengine/WebKit/s60/webview/WebPointerEventHandler.cpp Mon Jan 18 21:20:18 2010 +0200
+++ b/webengine/osswebengine/WebKit/s60/webview/WebPointerEventHandler.cpp Tue Feb 02 00:56:45 2010 +0200
@@ -11,7 +11,7 @@
*
* Contributors:
*
-* Description:
+* Description:
*
*/
@@ -64,11 +64,12 @@
#include "CSSStyleSelector.h"
#include "CSSValueKeywords.h"
#include "Settings.h"
+#include "WebGestureInterface.h"
+#include "WebPagePinchZoomHandler.h"
#include "WebKitLogger.h"
using namespace WebCore;
using namespace EventNames;
-using namespace RT_GestureHelper;
static const int KMinScrollAndTapInterval = 200000; // 200 ms
static const int KDoubleTapMinActivationInterval = 100000; // 100 ms
@@ -97,7 +98,8 @@
m_isHighlighted(false),
m_highlightedNode(NULL),
m_buttonDownTimer( this, &WebPointerEventHandler::buttonDownTimerCB ),
- m_ignoreTap(false)
+ m_ignoreTap(false),
+ m_gestureInterface(NULL)
{
}
@@ -106,7 +108,7 @@
//-----------------------------------------------------------------------------
WebPointerEventHandler::~WebPointerEventHandler()
{
- delete m_gestureHelper;
+ delete m_gestureInterface;
delete m_waiter;
}
@@ -115,130 +117,115 @@
//-----------------------------------------------------------------------------
void WebPointerEventHandler::ConstructL()
{
-#ifdef BRDO_USE_GESTURE_HELPER
- m_gestureHelper = CGestureHelper::NewL( *this );
- m_gestureHelper->SetDoubleTapEnabled(true);
- m_gestureHelper->SetHoldingEnabled(false);
+#ifdef BRDO_USE_GESTURE_HELPER
+ m_gestureInterface = WebGestureInterface::NewL(m_webview);
#else
- m_gestureHelper = NULL;
-#endif
+ m_gestureInterface = NULL;
+#endif
m_waiter = new(ELeave) CActiveSchedulerWait();
}
-/**
- * EGestureStart is sent on touch down
- * EGestureReleased is sent on touch up
- * EGestureTap = touch down + touch up - events sent: EGestureStart, EGestureTap
- * EGestureReleased
- * EGestureDrag = touch down + "move" - events sent: EGestureStart, EGestureDrag
- * EGestureDoubleTap = 2 * (touch down + touch up) - events sent EGestureStart,
- * EGestureDoubleTap, EGestureReleased
- * EGestureLongTap = touch down + "long touch" - events sent: EGestureStart,
- * EGestureLongTap
- * EGestureSwipe<Up/Down/Left/Right> - drag + touch up, where movements is
- * close to particular direction - event sent: EGestureSwipe,
- * EGestureReleased
- * EGestureFlick - "fast" drag + touch up - events sent: EGestureFlick,
- * EGestureReleased
- * EGestureDrop - drag + touch up, !(EGestureSwipe || EGestureFlick) - events
- * sent: EGestureDrop, EGestureReleased
- */
-void WebPointerEventHandler::HandleGestureL( const TGestureEvent& aEvent )
+
+
+// ======================================================================
+// WebPointerEventHandler::HandleGestureEventL
+// ======================================================================
+void WebPointerEventHandler::HandleGestureEventL(const TStmGestureEvent& aGesture)
{
- TGestureCode gtype = aEvent.Code(EAxisBoth);
-
+ TStmGestureUid uid = aGesture.Code();
+
+ if (m_webview->pinchZoomHandler()->isPinchActive() && uid != stmGesture::EGestureUidPinch)
+ return;
+
TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
-
+
PluginSkin* plugin = m_webview->mainFrame()->focusedPlugin();
if (plugin && plugin->pluginWin()) {
- if (plugin->pluginWin()->HandleGesture(aEvent)) {
+ if (plugin->pluginWin()->HandleGesture(aGesture)) {
if(!plugin->isActive())
plugin->activate();
- return;
- }
+ return;
+ }
}
- updateCursor(aEvent.CurrentPos());
+
+ updateCursor(aGesture.CurrentPos());
if (IS_TABBED_NAVIGATION) {
- m_webview->tabbedNavigation()->updateCursorPosition(aEvent.CurrentPos());
+ m_webview->tabbedNavigation()->updateCursorPosition(aGesture.CurrentPos());
}
- switch (gtype) {
- // sent on touch down
- case EGestureStart:
- {
- if (m_webview->viewIsScrolling()) {
- m_ignoreTap = true;
- m_webview->pageScrollHandler()->handleTouchDownGH(aEvent);
- }
- else {
- handleTouchDownL(aEvent);
- }
- break;
- }
-
- // sent on tap
- case EGestureTap:
- {
- if (!m_ignoreTap) {
- handleTapL(aEvent);
- }
- break;
- }
-
- // sent on double tap
- case EGestureDoubleTap:
- {
- handleDoubleTap(aEvent);
- break;
- }
-
- // sent on long tap
- case EGestureLongTap:
- {
- break;
- }
+
+
+ switch(uid) {
+ case stmGesture::EGestureUidTouch:
+ {
+ if (m_webview->viewIsScrolling()) {
+ m_ignoreTap = true;
+ m_webview->pageScrollHandler()->handleTouchDownGH(aGesture);
+ }
+ else {
+ handleTouchDownL(aGesture);
+ }
+ break;
+ }
+
+
+ case stmGesture::EGestureUidTap:
+ {
+ if (aGesture.Type() == stmGesture::ETapTypeSingle) {
+ if (!m_ignoreTap) {
+ handleTapL(aGesture);
+ }
+ }
+ else {
+ handleDoubleTap(aGesture);
+ }
+
+ break;
+ }
- // sent on touch up after drag
- case EGestureDrop:
- case EGestureFlick:
- case EGestureSwipeLeft:
- case EGestureSwipeRight:
- case EGestureSwipeUp:
- case EGestureSwipeDown:
- {
- m_ignoreTap = false;
- if (!IS_NAVIGATION_NONE) {
- handleTouchUp(aEvent);
- }
- else {
- Frame* frm = m_webview->page()->focusController()->focusedOrMainFrame();
- m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Up, m_highlightPos, frm);
- }
- break;
- }
- // sent on move
- case EGestureDrag:
- {
- handleMove(aEvent);
- break;
- }
-
- // sent on touch up after tap double tap and long tap
- case EGestureReleased:
- {
- m_ignoreTap = false;
- handleTouchUp(aEvent);
- break;
- }
+ case stmGesture::EGestureUidRelease:
+ {
+ m_ignoreTap = false;
+ handleTouchUp(aGesture);
+ break;
+ }
+
+ case stmGesture::EGestureUidPan:
+ {
+ handleMove(aGesture);
+ break;
+ }
+ case stmGesture::EGestureUidFlick:
+ {
+ m_ignoreTap = false;
+ if (!IS_NAVIGATION_NONE) {
+ handleTouchUp(aGesture);
+ }
+ else {
+ Frame* frm = m_webview->page()->focusController()->focusedOrMainFrame();
+ m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Up, m_highlightPos, frm);
+ }
+ break;
+ }
+
+ case stmGesture::EGestureUidPinch:
+ {
+ handlePinchZoomL(aGesture);
+ break;
+ }
+ default:
+ break;
+
}
+ return;
}
// ======================================================================
// WebPointerEventHandler::handleTap
// ======================================================================
-void WebPointerEventHandler::handleTapL(const TGestureEvent& aEvent)
+void WebPointerEventHandler::handleTapL(const TStmGestureEvent& aGesture)
{
m_buttonDownTimer.stop();
- m_lastTapEvent = m_currentEvent;
+ m_lastTapEvent = m_currentEvent;
if(!m_webview->inPageViewMode()){
doTapL();
}
@@ -246,12 +233,12 @@
// ======================================================================
// WebPointerEventHandler::handleDoubleTap
//======================================================================
-void WebPointerEventHandler::handleDoubleTap(const TGestureEvent& aEvent)
+void WebPointerEventHandler::handleDoubleTap(const TStmGestureEvent& aGesture)
{
if ( !m_webview->viewIsScrolling() &&
(m_webview->brCtl()->capabilities() & TBrCtlDefs::ECapabilityFitToScreen)) {
if (m_isHighlighted){
- dehighlight();
+ dehighlight();
}
m_webview->setZoomLevelAdaptively();
}
@@ -263,20 +250,20 @@
// ======================================================================
// WebPointerEventHandler::handleTouchDownL
//======================================================================
-void WebPointerEventHandler::handleTouchDownL(const TGestureEvent& aEvent)
+void WebPointerEventHandler::handleTouchDownL(const TStmGestureEvent& aGesture)
{
TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
PluginSkin* pluginToActivate = pluginHandler->pluginToActivate();
m_buttonDownEvent = m_currentEvent;
- m_highlightPos = aEvent.CurrentPos();
-
+ m_highlightPos = aGesture.CurrentPos();
+
if ( !m_buttonDownTimer.isActive() && !m_webview->inPageViewMode()){
- m_buttonDownTimer.startOneShot(0.1f);
+ m_buttonDownTimer.startOneShot(0.1f);
}
if (!IS_NAVIGATION_NONE) {
- m_webview->pageScrollHandler()->handleTouchDownGH(aEvent);
+ m_webview->pageScrollHandler()->handleTouchDownGH(aGesture);
}
if ( TBrCtlDefs::EElementActivatedObjectBox == elType) {
@@ -290,43 +277,43 @@
}
}
}
-
+
/*
- * After introducing "link selection" pointer down action is done in
- * buttondown timer callback. When "down" gesture event is arrived we start
- * timer end exit, so gesture helper is ready to deliver next gesture event.
- * Meanwhile the processing of the first gesture event hasn't been finished yet.
- * The gesture helper doesn't "know" about our plans to handle the event inside
- * timer callback and only way for us to "tell" about this is to stop RunL()
- * of CGestureEventSender (HandleGestureL() is inside it) and finish buttondown
- * timer callback first.
- */
+ * After introducing "link selection" pointer down action is done in
+ * buttondown timer callback. When "down" gesture event is arrived we start
+ * timer end exit, so gesture helper is ready to deliver next gesture event.
+ * Meanwhile the processing of the first gesture event hasn't been finished yet.
+ * The gesture helper doesn't "know" about our plans to handle the event inside
+ * timer callback and only way for us to "tell" about this is to stop RunL()
+ * of CGestureEventSender (HandleGestureL() is inside it) and finish buttondown
+ * timer callback first.
+ */
if ( m_buttonDownTimer.isActive()){
- m_waiter->Start();
+ m_waiter->Start();
}
}
// ======================================================================
-// WebPointerEventHandler::handleTouchUp
+// WebPointerEventHandler::handleTouchUp
// ======================================================================
-void WebPointerEventHandler::handleTouchUp(const TGestureEvent& aEvent)
+void WebPointerEventHandler::handleTouchUp(const TStmGestureEvent& aGesture)
{
m_highlightPos = TPoint(-1,-1);
m_highlightedNode = NULL;
PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
pluginHandler->setPluginToActivate(NULL);
if (!IS_NAVIGATION_NONE) {
- m_webview->pageScrollHandler()->handleTouchUpGH(aEvent);
+ m_webview->pageScrollHandler()->handleTouchUpGH(aGesture);
}
}
// ======================================================================
// WebPointerEventHandler::handleMoveL
// ======================================================================
-void WebPointerEventHandler::handleMove(const TGestureEvent& aEvent)
+void WebPointerEventHandler::handleMove(const TStmGestureEvent& aGesture)
{
TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
- TPoint curPos = aEvent.CurrentPos();
+ TPoint curPos = aGesture.CurrentPos();
PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
pluginHandler->setPluginToActivate(NULL);
m_buttonDownTimer.stop();
@@ -336,8 +323,8 @@
}
else {
HandleHighlightChange(curPos);
-
- m_webview->pageScrollHandler()->handleScrollingGH(aEvent);
+
+ m_webview->pageScrollHandler()->handleScrollingGH(aGesture);
}
}
@@ -348,11 +335,11 @@
void WebPointerEventHandler::HandlePointerEventL(const TPointerEvent& aPointerEvent)
{
m_currentEvent = aPointerEvent;
-
- if (m_webview->isSynchRequestPending()) {
+
+ if (m_webview->isSynchRequestPending()) {
return;
}
-
+
// Handle graphical history - should never happen, as HistoryView handles this event by itself
if ( m_webview->brCtl()->historyHandler()->historyController()->historyView()) {
return;
@@ -363,19 +350,10 @@
m_webview->formFillPopup()->HandlePointerEventL(aPointerEvent);
return;
}
-
- if (!m_webview->inPageViewMode()) {
- if (aPointerEvent.iType == TPointerEvent::EButton1Down) {
- m_webview->GetContainerWindow().EnablePointerMoveBuffer();
- }
- else if (aPointerEvent.iType == TPointerEvent::EButton1Up) {
- m_webview->GetContainerWindow().DisablePointerMoveBuffer();
- }
- }
#ifdef BRDO_USE_GESTURE_HELPER
- m_gestureHelper->HandlePointerEventL(aPointerEvent);
-#endif
+ m_gestureInterface->HandlePointerEventL(aPointerEvent);
+#endif
}
//-----------------------------------------------------------------------------
@@ -417,20 +395,20 @@
TBrCtlDefs::TBrCtlElementType elType = TBrCtlDefs::EElementNone;
Frame* coreFrame = core(m_webview->mainFrame());
WebCursor* cursor = StaticObjectsContainer::instance()->webCursor();
-
+
TPointerEvent event;
TPoint pos = cursor->position();
WebFrame* wfrm = cursor->getFrameAtPoint(pos);
Frame* frm = core(wfrm);
TPoint pt(wfrm->frameView()->viewCoordsInFrameCoords(pos));
TPoint nodePoint;
-
+
Element* eventNode = frm->document()->elementFromPoint(pt.iX, pt.iY);
-
+
if (m_isHighlighted){
- dehighlight();
+ dehighlight();
}
-
+
m_highlightedNode = NULL;
Node* retNode = 0;
@@ -438,10 +416,12 @@
if (elType == TBrCtlDefs::EElementNone) {
Node* n = wfrm->getClosestAnchorElement(cursor->position(), pos);
- if (n) {
+ if (n) {
wfrm = cursor->getFrameAtPoint(pos);
frm = core(wfrm);
- eventNode = frm->document()->elementFromPoint(pos.iX, pos.iY);
+ //eventNode = frm->document()->elementFromPoint(pos.iX, pos.iY);
+ TPoint newPos(wfrm->frameView()->viewCoordsInFrameCoords(pos));
+ eventNode = frm->document()->elementFromPoint(newPos.iX, newPos.iY);
frm->bridge()->getTypeFromElement(eventNode, elType, elRect, retNode);
TPoint nodePoint = n->getRect().Rect().Center();
m_offset = (pt.iX- nodePoint.iX)*(pt.iX- nodePoint.iX) +
@@ -486,7 +466,7 @@
{
TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
Frame* coreFrame = core(m_webview->mainFrame());
-
+
#ifdef BRDO_TOUCH_ENABLED_FF
if (m_isHighlighted)
{
@@ -497,25 +477,25 @@
}
}
#endif // BRDO_TOUCH_ENABLED_FF
-
+
if (!IS_NAVIGATION_NONE) {
m_webview->sendMouseEventToEngine(TPointerEvent::EMove, m_highlightPos, coreFrame);
}
-
+
/*
- * We assume that if element visibility has been changed
- * between "up" and "down" that means that some node event
- * listener (onMouseOver etc) handling happened and we don't
+ * We assume that if element visibility has been changed
+ * between "up" and "down" that means that some node event
+ * listener (onMouseOver etc) handling happened and we don't
* want to send a click (mouse press + mouse release) event.
* The exception is editable element, since we want VKB anyway
*/
if (!IS_NAVIGATION_NONE &&
- elType != TBrCtlDefs::EElementActivatedInputBox &&
- elType != TBrCtlDefs::EElementTextAreaBox &&
+ elType != TBrCtlDefs::EElementActivatedInputBox &&
+ elType != TBrCtlDefs::EElementTextAreaBox &&
m_webview->page()->chrome()->client()->elementVisibilityChangedByMouse()) {
return;
}
-
+
m_lastTapEvent.iPosition = m_buttonDownEvent.iPosition;
m_lastTapEvent.iType = TPointerEvent::EButton1Up;
m_lastTapEvent.iModifiers = 0;
@@ -558,10 +538,10 @@
Frame* frm = m_webview->page()->focusController()->focusedOrMainFrame();
m_webview->sendMouseEventToEngine(TPointerEvent::EMove, m_highlightPos, frm);
-
+
m_highlightedNode = NULL;
-
- m_webview->syncRepaint();
+
+ m_webview->syncRepaint();
}
@@ -605,17 +585,17 @@
void WebPointerEventHandler::buttonDownTimerCB(Timer<WebPointerEventHandler>* t)
{
m_buttonDownTimer.stop();
-
+
Frame* coreFrame = core(m_webview->mainFrame());
TPointerEvent event;
-
+
TBrCtlDefs::TBrCtlElementType elType = highlitableElement();
-
+
if (!isHighlitableElement(elType)) {
elType = TBrCtlDefs::EElementNone;
}
m_isHighlighted = (m_highlightedNode != NULL) && (elType != TBrCtlDefs::EElementNone) ;
-
+
/*
* Tabbed navigation might already set the focused node.
* If it's the same as m_highlightedNode FocuseController::setFocusedNode()
@@ -624,24 +604,24 @@
* set it through FocuseController::setFocusedNode()
*/
if (IS_TABBED_NAVIGATION &&
- elType == TBrCtlDefs::EElementInputBox ||
+ elType == TBrCtlDefs::EElementInputBox ||
elType == TBrCtlDefs::EElementTextAreaBox) {
coreFrame->document()->setFocusedNode(NULL);
}
-
+
if (!IS_NAVIGATION_NONE) {
m_webview->page()->chrome()->client()->setElementVisibilityChanged(false);
- //to initiate hover
+ //to initiate hover
if (m_isHighlighted) {
setFocusRing();
}
-
+
}
else {
m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Down, m_highlightPos, coreFrame);
}
-
- if (m_waiter->IsStarted()) {
+
+ if (m_waiter->IsStarted()) {
m_waiter->AsyncStop();
}
}
@@ -660,7 +640,7 @@
if (m_webview->showCursor()) {
cursor->resetTransparency();
m_webview->setShowCursor(false);
- cursor->cursorUpdate(false);
+ cursor->cursorUpdate(false);
}
}
}
@@ -675,7 +655,7 @@
RenderStyle* style = new (e->document()->renderArena()) RenderStyle(*rs);
Color col(0xffaaaaff);
- style->ref();
+ style->ref();
style->setOutlineColor(col);
style->setOutlineStyle(DOTTED, true);
style->setOutlineWidth(4);
@@ -684,3 +664,15 @@
style->deref(e->document()->renderArena());
e->setChanged();
}
+
+//-----------------------------------------------------------------------------
+// WebPointerEventHandler::handlePinchZoom
+//----------------------------------------------------------------------------
+void WebPointerEventHandler::handlePinchZoomL(const TStmGestureEvent& aGesture)
+{
+ //dehighlight anything which is highlighted already
+ if (m_isHighlighted){
+ dehighlight();
+ }
+ m_webview->pinchZoomHandler()->handlePinchGestureEventL(aGesture);
+}