# HG changeset patch # User Stefan Karlsson # Date 1269862035 -3600 # Node ID 960a2a4c7f0391637de1cf08b95883dbde317835 # Parent 2b524de5b49b3128e485561008645fe9063c8396# Parent 3dbb0284a087e3a61c5457308f7eb40400c945c0 Merge. diff -r 2b524de5b49b -r 960a2a4c7f03 .hgtags --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgtags Mon Mar 29 12:27:15 2010 +0100 @@ -0,0 +1,3 @@ +c8a366e5628567e5bedc545a84cae4c44dedf25e PDK_3.0.a +f177fdcb8b3a2c16b8ceaaf15eb5117c4bf707b9 PDK_3.0.b +63ded8f948005459888a2777ef37068b7a2c96d2 dummy diff -r 2b524de5b49b -r 960a2a4c7f03 browserutilities/downloadmgr/DownloadMgrServEng/Inc/HttpDownloadManagerServerEngine.h --- a/browserutilities/downloadmgr/DownloadMgrServEng/Inc/HttpDownloadManagerServerEngine.h Sun Mar 28 16:38:31 2010 +0100 +++ b/browserutilities/downloadmgr/DownloadMgrServEng/Inc/HttpDownloadManagerServerEngine.h Mon Mar 29 12:27:15 2010 +0100 @@ -156,7 +156,7 @@ * @param ?arg1 ?description * @return ?description */ - EXPORT_C TInt ActiveDownloads() const; + IMPORT_C TInt ActiveDownloads() const; /** * Calculates the total size of all on-going downloads in the diff -r 2b524de5b49b -r 960a2a4c7f03 webengine/osswebengine/JavaScriptCore/kjs/internal.h --- a/webengine/osswebengine/JavaScriptCore/kjs/internal.h Sun Mar 28 16:38:31 2010 +0100 +++ b/webengine/osswebengine/JavaScriptCore/kjs/internal.h Mon Mar 29 12:27:15 2010 +0100 @@ -66,7 +66,7 @@ class NumberImp : public JSCell { friend class ConstantValues; - friend JSValue *jsNumberCell(double); + IMPORT friend JSValue *jsNumberCell(double); public: double value() const { return val; } diff -r 2b524de5b49b -r 960a2a4c7f03 webengine/webkitutils/rt_gesturehelper/src/gesturerecogniser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/webengine/webkitutils/rt_gesturehelper/src/gesturerecogniser.cpp Mon Mar 29 12:27:15 2010 +0100 @@ -0,0 +1,224 @@ +/* +* Copyright (c) 2008 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: Gesture helper implementation +* +*/ + + +#include "gesturerecogniser.h" + +#include + +#include "gesturedefs.h" +#include "rt_gestureobserver.h" +#include "pointarray.h" +#include "utils.h" + +using namespace RT_GestureHelper; + +/** + * Vector class (math) + */ +NONSHARABLE_CLASS( TVector ) + { +public: + /** + * Constructor + * @param aFrom starting point of the vector + * @param aTo ending point of the vector + */ + TVector( const TPoint& aFrom, const TPoint& aTo ) + : iX( aTo.iX - aFrom.iX ), + iY( aTo.iY - aFrom.iY ) + { + } + + /** @return angle of the vector */ + TReal Angle() const + { + TReal angle = 0; + TReal length = Length(); + if ( length != 0 ) + { + Math::ACos( angle, iX / Length() ); + if ( iY < 0 ) + { + angle = 2 * KPi - angle; + } + } + return Degrees( angle ); + } + + /** @return length of the vector */ + TReal Length() const + { + TReal length = 0; + Math::Sqrt( length, iX * iX + iY * iY ); + return length; + } + +private: + /** @return radians in degrees */ + inline TReal Degrees( TReal aRadians ) const + { + return aRadians * 180 / KPi; + } + +public: + /// x coordinate that represent the vector + TReal iX; + /// y coordinate that represent the vector + TReal iY; + }; + +inline TPoint LastPoint( const TPointArray& aPoints ) + { + __ASSERT_DEBUG( aPoints.Count() > 0, Panic( EGesturePanicIllegalLogic ) ); + return aPoints[ aPoints.Count() - 1 ] ; + } + +/** + * @return Length of the gesture in points + */ +inline TReal GestureLength( const TPointArray& aPoints ) + { + return TVector( aPoints[0], LastPoint( aPoints ) ).Length(); + } + +/** + * @return ETrue if aAngleUnderTest is almost aAngle + * Closeness of the angles is controlled by KAngleTolerance + */ +static TBool IsNear( TReal aAngleUnderTest, TReal aAngle ) + { + return aAngle - KAngleTolerance <= aAngleUnderTest && + aAngleUnderTest <= aAngle + KAngleTolerance; + } + +/** + * @return the angle as a direction flags of TGesture + */ +inline TGestureCode Direction( TReal aAngle ) + { + TGestureCode direction = EGestureUnknown; + + if ( IsNear( aAngle, 90.0 ) ) + { + direction = EGestureSwipeDown; + } + else if ( IsNear( aAngle, 180.0 ) ) + { + direction = EGestureSwipeLeft; + } + else if ( IsNear( aAngle, 270.0 ) ) + { + direction = EGestureSwipeUp; + } + else if ( 360.0 - KAngleTolerance <= aAngle || aAngle <= KAngleTolerance ) + { + direction = EGestureSwipeRight; + } + else // for lint warning + { + // unknown angle + } + + return direction; + } + +/** @return direction between points */ +inline TGestureCode Direction( const TPoint& aFromPoint, const TPoint& aToPoint ) + { + return Direction( TVector( aFromPoint, aToPoint ).Angle() ); + } + +/** @return overall direction between points */ +static TGestureCode GeneralDirection( const TPointArray& aPoints ) + { + // If the start and end points are too close to each other, direction + // is undefined + if ( ToleranceRect( aPoints[0] ).Contains( LastPoint( aPoints ) ) ) + { + return EGestureUnknown; + } + return Direction( aPoints[0], LastPoint( aPoints ) ); + } + +// function type to get a point in the point array +typedef TPoint (TPointArray::*PointByIndexFunc)( TInt aIndex ) const; + +/// @return latest point outside tolerance area or KErrNotFound if not point outside it +TInt LatestCertainPointIndex( const TPointArray& aPoints, PointByIndexFunc aPointByIndex ) + { + __ASSERT_DEBUG( aPoints.Count() > 0, Panic( EGesturePanicIllegalLogic ) ); + + int i = aPoints.Count(); + TRect toleranceRect = ToleranceRect( (aPoints.*aPointByIndex)( aPoints.Count() - 1 ) ); + // Find out the first point from the end of the array + // that is not contained in the tolerance rect. + while( 0 <= --i ) + { + // if the point does not belong inside tolerance rect, it is the first point + // outside the rect + if( !toleranceRect.Contains( (aPoints.*aPointByIndex)(i) ) ) + { + break; + } + } + return i; + } + +/** @return last direction of dragging */ +inline TGestureCode LastDirection( const TPointArray& aPoints ) + { + TInt latestPointIndex = LatestCertainPointIndex( aPoints, &TPointArray::operator[] ); + if ( KErrNotFound != latestPointIndex ) + { + return Direction( aPoints[latestPointIndex], LastPoint( aPoints ) ); + } + // no points were outside the rect, and hence the direction is unknown + return EGestureUnknown; + } + +/** + * @return ETrue if points for a tap event + */ +inline TBool IsTap( const TPointArray& aPoints ) + { + return KErrNotFound == LatestCertainPointIndex( aPoints, &TPointArray::Raw ); + } + +// ---------------------------------------------------------------------------- +// Return gesture code of a gesture formed by a sequence of points +// ---------------------------------------------------------------------------- +// +TGestureCode TGestureRecogniser::GestureCode( const TPointArray& aPoints ) const + { + __ASSERT_DEBUG( aPoints.Count() > 0, Panic( EGesturePanicIllegalLogic ) ); + + // tap needs to be treated separately, because recognising that needs to consider + // raw points (and not points in which x or y axis has been filtered out) + if ( IsTap( aPoints ) ) + { + return EGestureTap; + } + + TGestureCode direction = GeneralDirection( aPoints ); + // if last direction is opposite of the general one, user has cancelled a swipe + if ( direction != LastDirection( aPoints ) ) + { + direction = EGestureUnknown; + } + return direction; + }