uifw/EikStd/coctlsrc/EIKEDWIN.CPP
branchRCL_3
changeset 19 aecbbf00d063
parent 18 fcdfafb36fe7
child 20 d48ab3b357f1
--- a/uifw/EikStd/coctlsrc/EIKEDWIN.CPP	Thu Aug 19 10:11:06 2010 +0300
+++ b/uifw/EikStd/coctlsrc/EIKEDWIN.CPP	Tue Aug 31 15:28:30 2010 +0300
@@ -102,10 +102,6 @@
 #include "smileycustomwrap.h"
 #include <touchfeedback.h>
 
-// declare function
-void ReadSpecialCharFromSCTL( TPtr& ptr, TInt sctResourceId );
-void ReadSCTHeadPane( TResourceReader& aReader );
-
 GLDEF_C void Panic(TEikEdwinPanic aPanic)
     {
     _LIT(KPanicCat,"EIKON-EDWIN");
@@ -143,7 +139,7 @@
 const TInt KEuroSign = 0x20AC;
 const TInt KSegmSize = 1024;
 
-
+const TInt KMicroSecondsDelay = 500000;
 
 const TInt KNormalAnimPlayTimes = 2;
 const TInt KInfiniteAnimPlayTimes = 0x7ffff;
@@ -151,13 +147,6 @@
 
 const TInt KFullFormatLengthForSmiley = 5000;
 
-const TInt KContentThreshold = 8;
-
-const TInt KNmericSCTLimit( 256 );
-const TInt KTInt16Length( sizeof( TInt16 ) );
-const TInt KTInt32Length( sizeof( TInt32 ) );
-const TInt KTUint32Length( sizeof( TUint32 ) );
-
 //
 // class CEikEdwin::CUndoBuffer
 //
@@ -228,11 +217,6 @@
     {
     friend class CEikEdwin;
 public:
-    // The length of text window
-    const static TInt KMaxSegmentLength = 10000;
-    // The threshold for text window position change
-    const static TInt KSegmentUpdateTrigger = 100;
-    
     static CEikEdwinFepSupport* New(CEikEdwin& aEdwin);
     virtual ~CEikEdwinFepSupport();
     TBool IsHandledByFepL(TPointerEvent::TType aType, TUint aModifiers, TInt aDocumentPosition);
@@ -248,21 +232,7 @@
     // from MCoeFepAwareTextEditor_Extension1
     void SetStateTransferingOwnershipL(CState* aState, TUid aTypeSafetyUid);
     CState* State(TUid aTypeSafetyUid); // this function does *not* transfer ownership
-    
-    // New functions for Touch Input sync performance improvement. A sliding window method is used 
-    // here to show only part of text of editor to Touch Input, so the text sync between Touch input and 
-    // editor can be faster.
-    /**
-     * To update start position of text window according to cursor position. The cursor position has to
-     * be in the visible text window.
-     */
-    void UpdateDocPosOffsetL( TInt aCursorPos );
-
-    /**
-     * To check if FEP wants to get information of whole text, not the text window.
-     */
-    TBool FepRequireWholeTextData() const;
-    
+
 private:
     enum TPointerState
         {
@@ -322,8 +292,6 @@
     MTouchFeedback* iFeedback;
     TBool iSelectionIsCancel;
     TInt iMoveThumbFeedbackNeeded;
-    // record start position of text window
-	TInt iDocPosOffset;
 private:    
     MFepPointerEventHandlerDuringInlineEdit* iPointerEventHandlerDuringInlineEdit; // does not own anything
     SPointerEventInInlineText iLastPointerEventInInlineText;
@@ -552,9 +520,6 @@
     TBool paragraphContainingStartPositionOfInlineTextHasChangedFormat=EFalse;
     TInt numberOfCharactersSuccessfullyDeleted=0;
     TInt numberOfCharactersSuccessfullyInserted=0;
-    
-    iEdwin.ConvertSmileyForDeleteL( selection );
-    
     // handle extended highlights
 
 /* 
@@ -607,10 +572,13 @@
     TRAPD(error,iEdwin.iText->UpdateFepInlineTextL(paragraphContainingStartPositionOfInlineTextHasChangedFormat,numberOfCharactersSuccessfullyDeleted,numberOfCharactersSuccessfullyInserted,iPositionOfInsertionPointInDocument,iPositionOfInlineTextInDocument+aPositionOfInsertionPointInInlineText,aNewInlineText));
     iLengthOfInlineText=numberOfCharactersSuccessfullyInserted;
     UpdateTextViewAfterChangeInInlineTextL(paragraphContainingStartPositionOfInlineTextHasChangedFormat,numberOfCharactersSuccessfullyDeleted,numberOfCharactersSuccessfullyInserted,error);
+    iEdwin.ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate );
     }
 
 void CEikEdwinFepSupport::SetInlineEditingCursorVisibilityL(TBool aCursorVisibility)
     {
+    __ASSERT_ALWAYS(iPositionOfInlineTextInDocument>=0,Panic(EEikPanicBadInlineEditingState7)); // assert that we're currently inline editing
+    __ASSERT_DEBUG((iOriginalSelection.iCursorPos>=0) && (iOriginalSelection.iAnchorPos>=0) && (iPositionOfInsertionPointInDocument>=0) && (iPositionOfInlineTextInDocument>=0) && (iLengthOfInlineText>=0) && (iPointerEventHandlerDuringInlineEdit!=NULL),Panic(EEikPanicBadInlineEditingState8));
     iEdwin.SetCursorVisibilityL(aCursorVisibility);
     iShowCursor = aCursorVisibility;
     }
@@ -656,58 +624,18 @@
 
 TInt CEikEdwinFepSupport::DocumentLengthForFep() const
     {
-    // If the length between text window start position and text end is shorter
-    // than length of text window, return the short length, otherwise return
-    // text window length.
-    if ( !FepRequireWholeTextData() && iEdwin.TextLength() > KMaxSegmentLength )
-        {
-        TInt lengthToEnd( iEdwin.TextLength() - iDocPosOffset );
-        if ( lengthToEnd < KMaxSegmentLength )
-            {
-            return lengthToEnd;
-            }
-        return KMaxSegmentLength;
-        }
     return iEdwin.TextLength();
     }
 
 TInt CEikEdwinFepSupport::DocumentMaximumLengthForFep() const
     {
-    // return the length between textlimit and text window start position
-    if ( !FepRequireWholeTextData() && KMaxSegmentLength < iEdwin.iTextLimit )
-        {
-        return iEdwin.iTextLimit - iDocPosOffset;
-        }
     return iEdwin.iTextLimit;
     }
 
 void CEikEdwinFepSupport::SetCursorSelectionForFepL(const TCursorSelection& aCursorSelection)
     {
-    // if text window is enabled, the pos of parameter selection are relative to
-    // text window start position, so convert them back to actual doc pos.
     TInt cursorPos( aCursorSelection.iCursorPos );
     TInt anchorPos( aCursorSelection.iAnchorPos );
-    TInt textLength( iEdwin.TextLength() );
-    if ( !FepRequireWholeTextData() )
-        {
-        cursorPos += iDocPosOffset;
-        anchorPos += iDocPosOffset;
-        cursorPos = cursorPos > textLength ? textLength : cursorPos;
-        anchorPos = anchorPos > textLength ? textLength : anchorPos;
-        if ( cursorPos != anchorPos )
-            {
-            TCursorSelection select( iEdwin.Selection() );
-            if ( ( anchorPos == iDocPosOffset || anchorPos == iDocPosOffset + 
-                KMaxSegmentLength ) && anchorPos >= select.LowerPos() && 
-                anchorPos <= select.HigherPos() )
-                {
-                anchorPos = cursorPos > anchorPos ? select.LowerPos() : 
-                    select.HigherPos();
-                }
-            }
-        }
-    // Selection position can not be in smiley code string, so check if
-    // the position needs to be changed.
     if ( iEdwin.IsSmileyEnabled() )
         {  
         CSmileyManager* smiley( iEdwin.iEdwinExtension->iSmiley );
@@ -722,66 +650,22 @@
             smiley->HandleSetCursor( cursorPos, anchorPos );
             }
         }
-    iEdwin.SetSelectionL( cursorPos, anchorPos );
-    // Cursor pos is changed, so update text window position.
-	UpdateDocPosOffsetL( cursorPos );
+	iEdwin.SetSelectionL( cursorPos, anchorPos );
     iEdwin.ReportEdwinEventL(MEikEdwinObserver::EEventNavigation);
     }
 
 void CEikEdwinFepSupport::GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const
     {
     aCursorSelection=iEdwin.Selection();
-    // To use text window, FEP can not access text view of editor directly but 
-    // FEP needs to know some information which can not be provided by current 
-    // interface. So use below method to transfer the information to FEP.
-    CAknEdwinState* state( iEdwin.EditorState() );
-    if ( state )
-        {
-        TInt flag( state->Flags() );
-        TTmDocPos docPos;
-        iEdwin.TextView()->GetCursorPos( docPos );
-        if ( docPos.iLeadingEdge )
-            {
-            flag |= EAknEditorFlagCursorLedingEdge;
-            }
-        else
-            {
-            flag &= ~EAknEditorFlagCursorLedingEdge;
-            }
-        state->SetFlags( flag );
-        }
-    // If text window is enabled, convert the actual doc pos to relative doc pos.
-    if ( !FepRequireWholeTextData() )
-        {
-        if ( aCursorSelection.iAnchorPos < iDocPosOffset )
-            {
-            aCursorSelection.iAnchorPos = iDocPosOffset;
-            }
-        else if ( aCursorSelection.iAnchorPos > iDocPosOffset + KMaxSegmentLength )
-            {
-            aCursorSelection.iAnchorPos = iDocPosOffset + KMaxSegmentLength;
-            }
-        aCursorSelection.iCursorPos -= iDocPosOffset;
-        aCursorSelection.iAnchorPos -= iDocPosOffset;
-        }
     }
 
 void CEikEdwinFepSupport::GetEditorContentForFep(TDes& aEditorContent,TInt aDocumentPosition,TInt aLengthToRetrieve) const
     {
-    // If text window is enabled, convert relative doc pos to actual doc pos.
-    if ( !FepRequireWholeTextData() )
-        {
-        aDocumentPosition += iDocPosOffset;
-        }
     TInt length( Min( aLengthToRetrieve, iEdwin.TextLength() - aDocumentPosition ) );
-    if ( !FepRequireWholeTextData() )
-        {
-        length = Min( length, KMaxSegmentLength );
-        }    
     iEdwin.iText->Extract( aEditorContent, aDocumentPosition, length );
-    CSmileyManager* smiley( iEdwin.iEdwinExtension->iSmiley );
-    if ( smiley && smiley->HasSmileyIconsInText() )
-        {        
+    if ( iEdwin.IsSmileyEnabled() )
+        {
+        CSmileyManager* smiley( iEdwin.iEdwinExtension->iSmiley );
         CAknEdwinState* state( iEdwin.EditorState() );
         if ( state )
             {
@@ -789,29 +673,28 @@
             if ( aDocumentPosition >= inlineText.LowerPos() && 
                 aDocumentPosition + length <= inlineText.HigherPos() )
                 {
-                TRAP_IGNORE( smiley->ConvertTextForSmileyL( aDocumentPosition, aEditorContent, 
-                    EFalse ); )
+                iEdwin.iEdwinExtension->iSmiley->ConvertTextForSmileyL(
+                    aDocumentPosition, aEditorContent, EFalse );
                 }
             }
-        // Replace all 'i' following smiley code to invisbile placeholder for
-        // Touch Input can not recognize it as part of smiley code string.
-        TInt smileyEndPos( 0 );
+        TBool prevIsCode( EFalse );
         for ( TInt i( 0 ); i < length; i++ )
             {
             if ( aEditorContent[i] == CSmileyManager::KCompensateChar )
                 {
-                // when 'i' is the first character, it is unkonwn whether it is
-                // part of a smiley code string or not, so we have to use another 
-                // function to decide.
-                if ( ( i > 0 && i < smileyEndPos ) ||
-                     ( i == 0 && smiley->SmileyCodeByPos( aDocumentPosition ) > 0 ) )
+                if ( i == 0 )
+                    {
+                    prevIsCode = ( CSmileyManager::IsSmileyCode( 
+                        smiley->SmileyCodeByPos( aDocumentPosition ) ) );
+                    }
+                if ( prevIsCode )
                     {
                     aEditorContent[i] = CSmileyManager::KPlaceHolder;
                     }
                 }
-            else if ( smiley->IsSmileyCode( aEditorContent[i] ) )
+            else
                 {
-                smileyEndPos = i + smiley->SmileyLength( aDocumentPosition + i );
+                prevIsCode = CSmileyManager::IsSmileyCode( aEditorContent[i] );
                 }
             }
         }
@@ -825,8 +708,6 @@
 
 void CEikEdwinFepSupport::GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLine,TInt& aHeight,TInt& aAscent,TInt aDocumentPosition) const
     {
-    // If text window is enabled, convert relative doc pos to actual doc pos.
-    aDocumentPosition += iDocPosOffset;
     aDocumentPosition %= ( iEdwin.iText->DocumentLength() + 1 );    
     iEdwin.iTextView->DocPosToXyPosL(aDocumentPosition,aLeftSideOfBaseLine);
     aLeftSideOfBaseLine+=iEdwin.DrawableWindow()->InquireOffset(iEdwin.iCoeEnv->RootWin()); // make position "absolute" (i.e. not relative to the window that iEdwin is using) - note that *any* group window can be passed into InquireOffset to return the desired result, it doesn't have to be an ancestor of the window being used by iEdwin (i.e. this line of code does *not* make the assumption that iEdwin is (even indirectly) attached to iCoeEnv->RootWin())
@@ -843,6 +724,7 @@
     {
     __ASSERT_ALWAYS(iPositionOfInlineTextInDocument>=0,Panic(EEikPanicBadInlineEditingState9)); // assert that we're currently inline editing
     __ASSERT_DEBUG((iOriginalSelection.iCursorPos>=0) && (iOriginalSelection.iAnchorPos>=0) && (iPositionOfInsertionPointInDocument>=0) && (iPositionOfInlineTextInDocument>=0) && (iLengthOfInlineText>=0) && (iPointerEventHandlerDuringInlineEdit!=NULL),Panic(EEikPanicBadInlineEditingState10));
+    iEdwin.iEdwinExtension->iInlineEditing = EFalse;
     iCharsInserted = 0;
     iCharsDeleted = 0;
     TBool paragraphContainingStartPositionOfInlineTextHasChangedFormat=EFalse;
@@ -856,9 +738,6 @@
         {
         iEdwin.iUndoStore->SetNewText( select );
         }    
-
-    iEdwin.iEdwinExtension->iInlineEditing = EFalse;
-
     if ( iEdwin.IsSmileyEnabled() )
         {
         CAknEdwinState* state( iEdwin.EditorState() );
@@ -879,14 +758,7 @@
                     }
                 }
             iEdwin.SetAmountToFormatL( EFalse, ETrue );
-
-            CAknEdwinState* edwinState = 
-                    static_cast<CAknEdwinState*>( iEdwin.iEdwinFepSupport->State( KNullUid ) );
-            
-            if ( !( edwinState->Flags() & EAknEditorFlagHideTextView ) )
-                {
-                iEdwin.DrawDeferred();
-                }
+            iEdwin.DrawDeferred();
             }
         }
     iOriginalSelection.SetSelection(-1,-1);
@@ -995,50 +867,6 @@
     {
     }
 
-// Update start position of text window, when cursor pos is out of current 
-// text window or it is in trigger range, the text window position needs to 
-// be changed and notify FEP the text change.
-void CEikEdwinFepSupport::UpdateDocPosOffsetL( TInt aCursorPos )
-    {
-    if ( FepRequireWholeTextData() )
-        {
-        return;
-        }
-    if ( iEdwin.TextLength() > KMaxSegmentLength )
-        {
-        TInt halfSegment( KMaxSegmentLength / 2 );
-        TBool validDocPosOffset( iDocPosOffset >= 0 && aCursorPos > iDocPosOffset &&
-            aCursorPos - iDocPosOffset < KMaxSegmentLength );
-        TBool cursorInHead( validDocPosOffset && 
-            aCursorPos - iDocPosOffset < KSegmentUpdateTrigger );
-        TBool cursorInTail( validDocPosOffset && 
-            iDocPosOffset + KMaxSegmentLength - aCursorPos < KSegmentUpdateTrigger &&
-            iDocPosOffset + KMaxSegmentLength < iEdwin.TextLength() );
-        if  ( !validDocPosOffset || cursorInHead || cursorInTail )
-            {
-            if ( iEdwin.TextLength() - aCursorPos < halfSegment )
-                {
-                iDocPosOffset = iEdwin.TextLength() - KMaxSegmentLength;
-                }
-            else
-                {
-                iDocPosOffset = aCursorPos - halfSegment;
-                iDocPosOffset = iDocPosOffset >= 0 ? iDocPosOffset : 0;
-                }            
-            static_cast<CAknEdwinState*>( State( KNullUid ) )->ReportAknEdStateEventL( 
-                MAknEdStateObserver::EAknCursorPositionChanged );
-            }
-        }
-    }
-
-// Check if FEP set the flag to indicate it wants to get information of whole
-// text, not the text window.
-TBool CEikEdwinFepSupport::FepRequireWholeTextData() const
-    {
-    CAknEdwinState* state( static_cast<CAknEdwinState*>( 
-        const_cast<CEikEdwinFepSupport*>( this )->State(KNullUid) ) );
-    return ( state->Flags() & EAknEditorFlagNeedWholeTextData );
-    }
 
 //
 //  CEikEdwinExtension
@@ -1214,7 +1042,6 @@
         iCenRep->Get(KAknFepClearDirection, iClearDirection);
         }
     iSmileyWrap = new ( ELeave ) CSmileyCustomWrap;
-    iSkinInstance = AknsUtils::SkinInstance();
     }
 
 void CEikEdwin::CEikEdwinExtension::CreateFormExtendedInterfaceProviderIfNeededL()
@@ -1307,23 +1134,23 @@
 // ---------------------------------------------------------------------------
 // CEikEdwin::CEikEdwinExtension::EnableKineticScrollingL
 // ---------------------------------------------------------------------------
-//
-void CEikEdwin::CEikEdwinExtension::EnableKineticScrollingL( CAknPhysics* aPhysics )
+//   
+void CEikEdwin::CEikEdwinExtension::EnableKineticScrollingL()
     {
     iFlags.Set( EKineticScrollingEnabled );
-    EnablePhysicsL( aPhysics );
+    EnablePhysicsL();
     }
 
 // ---------------------------------------------------------------------------
 // CEikEdwin::CEikEdwinExtension::EnablePhysicsL
 // ---------------------------------------------------------------------------
 //   
-void CEikEdwin::CEikEdwinExtension::EnablePhysicsL( CAknPhysics* aPhysics )
+void CEikEdwin::CEikEdwinExtension::EnablePhysicsL()
     {
     if ( iFlags.IsSet( EKineticScrollingEnabled )
         && !iPhysicsHandler && iEdwin->DrawableWindow() )
         {
-        iPhysicsHandler = CAknEdwinPhysicsHandler::NewL( *iEdwin, aPhysics );
+        iPhysicsHandler = CAknEdwinPhysicsHandler::NewL( *iEdwin );
         
         InitPhysicsL();   
         if ( iEdwin->iLayout )
@@ -1760,7 +1587,7 @@
     CreateLayoutL(globalText);
     SetHeightForNumOfLinesL();
     DoCreateCustomDrawL();
-    if ( iEdwinExtension && iEdwinExtension->iSmiley )
+    if ( iEdwinExtension->iSmiley )
         {
         TextLayout()->SetCustomWrap( iEdwinExtension->iSmileyWrap );
         }
@@ -2001,7 +1828,7 @@
         }
     if (iEdwinUserFlags&EDisplayOnly)
         return EKeyWasConsumed;
-    if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
+    if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
         {
         PerformRecordedOperationL();
         }
@@ -2286,7 +2113,6 @@
             const TCursorSelection sel(lower,lower);
             iTextView->SetPendingSelection(sel);
             iTextView->HandleInsertDeleteL(sel,toDelete.Length(),formatHasChanged);
-            cursorPos = lower;
             reportChange=ETrue;
             }
         else if ( replaceSelection ) // All neutral protection cases 
@@ -2349,7 +2175,7 @@
                 formatChange=formatHasChanged;
                 }
             }
-        if ( reportChange && iEdwinExtension && iEdwinExtension->iSmiley )
+        if ( reportChange && iEdwinExtension->iSmiley )
             {
             ConvertTextForSmileyL( TCursorSelection( cursorPos, cursorPos ), 
                 ETrue );          
@@ -2403,11 +2229,11 @@
             }
 InChar: CheckNotReadOnlyL();
         TChar character(code);
-        if ( selectionLength )
+        if ( selectionLength && IsValidNumericCharL(character) )
             {
             TInt pos=DeleteHighlightL(formatHasChanged);
             TRAPD(err,iText->InsertL(pos,character));
-            if ( iEdwinExtension && iEdwinExtension->iSmiley )
+            if ( iEdwinExtension->iSmiley )
                 {
                 iEdwinExtension->iSmiley->HandleInsertL( pos, 1 );
                 ConvertTextForSmileyL( TCursorSelection( pos, pos ), ETrue );
@@ -2427,11 +2253,11 @@
             formatChange=formatHasChanged;
             break;
             }
-        if ( !iTextLimit || TextLength()<iTextLimit )
+        if ( (!iTextLimit || TextLength()<iTextLimit) && IsValidNumericCharL(character) )
             {
             iText->InsertL(CursorPos(),character);
             ClearUndo();
-            if ( iEdwinExtension && iEdwinExtension->iSmiley )
+            if ( iEdwinExtension->iSmiley )
                 {
                 TInt cursorPos( CursorPos() );
                 iEdwinExtension->iSmiley->HandleInsertL( cursorPos, 1 );
@@ -2452,7 +2278,7 @@
         {
         ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate );
         DoReportEventL( MCoeControlObserver::EEventStateChanged );
-        if ( iEdwinExtension && iEdwinExtension->iSmiley )
+        if ( iEdwinExtension->iSmiley )
             {            
             TInt docPos( CursorPos() );
             iEdwinExtension->iSmiley->HandleSetCursor( docPos, 
@@ -2463,7 +2289,7 @@
                 }
             }
         }
-    if ( navigation && iEdwinExtension )
+    if (navigation)
         { 
         iEdwinExtension->iThumbPos = KErrNotFound;
         ReportEdwinEventL(MEikEdwinObserver::EEventNavigation);
@@ -2567,7 +2393,7 @@
              }
          }
     
-    if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
+    if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
         {
         PerformRecordedOperationL();
         }
@@ -2657,11 +2483,8 @@
             }
         
         TBool shouldReturn( EFalse );
-        if ( iEdwinExtension )
-        	{
-			iEdwinExtension->iPhysicsHandler->HandleKineticScrolling(
-                aPointerEvent, shouldReturn );
-        	}
+        iEdwinExtension->iPhysicsHandler->HandleKineticScrolling(
+            aPointerEvent, shouldReturn );
         
         if ( shouldReturn )
             {
@@ -2678,17 +2501,6 @@
         return;
         }
     
-    // If text selection is not visible, don't allow user to select any text
-    // or scroll during selection ( if kinetic scrolling enabled ).
-    if ( kineticScrollingEnabled && iEdwinFepSupport )
-        {
-        CAknEdwinState* edwinState( EditorState() );
-        if ( edwinState && !( edwinState->Flags() & EAknEditorFlagSelectionVisible ) )
-            {
-            return;
-            }
-        }
-    
     const TCursorSelection selection( iTextView->Selection() );
     const TPoint pointerPos( aPointerEvent.iPosition );
     
@@ -2721,7 +2533,7 @@
             } 
         } // Kinetic scrolling not enabled  
     
-    if ( iEdwinExtension && iEdwinExtension->iPtSuppressor->SuppressPointerEvent( aPointerEvent ) )
+    if ( iEdwinExtension->iPtSuppressor->SuppressPointerEvent( aPointerEvent ) )
         {
         return;
         }
@@ -2864,7 +2676,7 @@
             iEdwinInternalFlags&=(~ELeftDownInViewRect);
 
             // We can't open cut-copy-paste menu if dragging started
-            if ( IsReadOnly() && IsSelectionVisible() && IsFocused() && !( kineticScrollingEnabled
+            if ( IsReadOnly() && IsSelectionVisible() && !( kineticScrollingEnabled
                 && iEdwinExtension->iPhysicsHandler->DraggingStarted() ) )
                 {
                 iEdwinFepSupport->iFeedback->InstantFeedback(
@@ -2893,7 +2705,7 @@
                         )
                         {
                         iEdwinFepSupport->iFeedback->InstantFeedback( this,
-                            ETouchFeedbackEdit, ETouchFeedbackVibra,
+                            ETouchFeedbackEditor, ETouchFeedbackVibra,
                             aPointerEvent );
                         }
                     }
@@ -2908,7 +2720,7 @@
                         {
                         iEdwinFepSupport->iFeedback->InstantFeedback(
                             this,
-                            ETouchFeedbackEdit,
+                            ETouchFeedbackEditor,
                             ETouchFeedbackVibra,
                             aPointerEvent );
                         iEdwinFepSupport->iSelectionIsCancel = EFalse;
@@ -2960,10 +2772,7 @@
                 }
             Window().RequestPointerRepeatEvent(KPointerRepeatRate,rect);
             navigation = ETrue;
-            if ( iLayout && !iLayout->IsFormattingBand() )
-                {
-                iEdwinExtension->iThumbPos = KErrNotFound;
-                }
+            iEdwinExtension->iThumbPos = KErrNotFound;
             }
         else if (iEdwinInternalFlags&EDragDouble)
             {
@@ -3057,31 +2866,33 @@
                     // on down event feedback is given if cursor/selection changes
                     if ( paintingPossible && !readOnly || editorWillGetFocus )
                         {
-                        iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackEdit );
+                        iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackBasic );
                         }
                     }
                 else  if ( selectionChanged && 
-                         ( selectionAfter.iAnchorPos != selectionAfter.iCursorPos ) &&
-                         ( ( aPointerEvent.iType == TPointerEvent::EDrag ) ||
+                       ( ( aPointerEvent.iType == TPointerEvent::EDrag ) ||
                          ( aPointerEvent.iType == TPointerEvent::EButtonRepeat ) ) )
                     {
+                    
+                    // selectionAfter.iCursorPos-1 below is because we need to select the previous char
+                    TBool ltr = ( selectionAfter.iCursorPos >= selectionBefore.iCursorPos );
                     TInt readPos = selectionAfter.iCursorPos;
-                    if ( selectionAfter.iCursorPos > selectionAfter.iAnchorPos )
+                    if (ltr && readPos > 0)
                         {
-                        readPos -= 1;//drag backword
+                        readPos -= 1; // read previous char
                         }
-                    TChar currentSelectedChar = Text()->Read( readPos, 1 )[0];
+                    TChar currentSelectedChar = Text()->Read( readPos, 1 )[0]; 
                     TBool isSpace = currentSelectedChar.IsSpace();
-                    TBool isSmiley = CSmileyManager::IsSmileyCode(currentSelectedChar);
-                    TBool isText = currentSelectedChar.IsGraph();
+                    TBool isText = currentSelectedChar.IsAlpha() 
+                                || currentSelectedChar.IsDigit();
                     
                     // case line
                     TInt prevLineNr = TextLayout()->GetLineNumber(selectionBefore.iCursorPos);
                     TInt lineNr = TextLayout()->GetLineNumber(selectionAfter.iCursorPos);
-                    if ( prevLineNr != lineNr )
+                    if ( prevLineNr != lineNr && ( selection.Length() != 0 ) )
                         {
-                        TInt group = currentSelectedChar.GetCategory();
-                        TBool isEmptyLine = ( group == TChar::EZpCategory );
+                        TInt group = ( currentSelectedChar.GetCategory() & 0xF0 );
+                        TBool isEmptyLine = ( group == TChar::ESeparatorGroup );
                         TTouchLogicalFeedback fType = ( isEmptyLine ? 
                             ETouchFeedbackEmptyLineSelection : ETouchFeedbackLineSelection );
                         iEdwinFepSupport->iFeedback->InstantFeedback( this, fType );
@@ -3092,7 +2903,7 @@
                         iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackBlankSelection );
                         }
                     // case text
-                    else if ( isText || isSmiley )    
+                    else if (isText)    
                         {
                         iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackTextSelection );
                         }
@@ -3151,16 +2962,6 @@
                 {
                 TRAP_IGNORE( edwinState->ReportAknEdStateEventL( 
                     MAknEdStateObserver::EAknSyncEdwinState ) );
-                // if text view is already hidden and editor loses focus, display text view.
-				if ( ( edwinState->Flags() & EAknEditorFlagHideTextView ) &&
-                     ( iEdwinExtension && iEdwinExtension->iTextViewHidden ) )
-                    {
-                    iTextView->MakeVisible( ETrue );
-                    edwinState->SetFlags( edwinState->Flags() & 
-                        ~EAknEditorFlagHideTextView );
-                    iEdwinExtension->iTextViewHidden = EFalse;                    
-                    DrawDeferred();
-                    }
                 }
             else
                 {
@@ -3260,7 +3061,7 @@
     DoCreateCustomDrawL(); //  Done after TextView is created so that optimized drawer is constructed
 
     // Create the required formatters according to the editor set-up
-    if ( IsPurePhoneNumberEditor() && iEdwinExtension )
+    if ( IsPurePhoneNumberEditor() )
         {
         if ( phoneNumberGroupingSupported )
             {            
@@ -3269,14 +3070,14 @@
             iEdwinExtension->CreatePurePhoneNumberFormatterL( *iLayout, *iText );
             }
         }
-    else if ( iEdwinExtension )// Make approximation that all other editors have no matches indicator functionality
+    else // Make approximation that all other editors have no matches indicator functionality
         {
         iEdwinExtension->CreateNoMatchesIndicatorFormatterL( *iLayout );
         }
 
     // Rich text editors that have been configured for phone number grouping
     if (iEdwinInternalFlags&ERichText && iEdwinInternalFlags&EPhoneNumberGrouping &&
-        phoneNumberGroupingSupported && iEdwinExtension )
+        phoneNumberGroupingSupported )
         {        
         CAknEdwinState* edwinState = STATIC_CAST( CAknEdwinState*, iEdwinFepSupport->State(KNullUid) );            
         edwinState->SetFlags( edwinState->Flags() | EAknEditorFlagNumberGrouping );                
@@ -3284,7 +3085,7 @@
         }
 
     // Install the custom formatter system if needed
-    if ( iEdwinExtension && iEdwinExtension->FormExtendedInferfaceProvider() )
+    if ( iEdwinExtension->FormExtendedInferfaceProvider() )
         TextLayout()->SetInterfaceProvider( iEdwinExtension->FormExtendedInferfaceProvider() );
 
     UpdateScrollBarsL();
@@ -3422,10 +3223,7 @@
         SetCursorVisibilityL( ETrue );
         }
     // View size changed, Initialize physics here
-    if ( iEdwinExtension )
-    	{
-		iEdwinExtension->InitPhysicsL();   
-    	}
+    iEdwinExtension->InitPhysicsL();        
     }
 
 EXPORT_C TInt CEikEdwin::CountComponentControls() const
@@ -3450,7 +3248,7 @@
     if (!iTextView)
         return;
     const TInt chars=iText->DocumentLength();
-    if ( iEdwinExtension && iEdwinExtension->iSmiley && !iEdwinExtension->iDisableConvertInFormat )
+    if ( iEdwinExtension->iSmiley && !iEdwinExtension->iDisableConvertInFormat )
         {        
         if ( chars > KFullFormatLengthForSmiley )
             {
@@ -3507,7 +3305,7 @@
     if (!iTextView)
         return;
     const TInt chars=iText->DocumentLength();
-    if ( iEdwinExtension && iEdwinExtension->iSmiley && !iEdwinExtension->iDisableConvertInFormat )
+    if ( iEdwinExtension->iSmiley && !iEdwinExtension->iDisableConvertInFormat )
         {        
         if ( chars > KFullFormatLengthForSmiley )
             {
@@ -3581,7 +3379,13 @@
         for (TInt ii=0;ii<count;ii++)
             (*iObserverArray)[ii]->HandleEdwinEventL(this,aEventType);
         }
-    if ( aEventType == MEikEdwinObserver::EEventTextUpdate && iEdwinExtension )
+    if ( aEventType == MEikEdwinObserver::EEventScroll || 
+        aEventType == MEikEdwinObserver::EEventNavigation 
+        )
+        {
+        HandleScrollForSmileyL();        
+        }
+    if ( aEventType == MEikEdwinObserver::EEventTextUpdate )
         {
         iEdwinExtension->iExtendedInputCapabilities->ReportEventL( 
                 CAknExtendedInputCapabilities::
@@ -3637,7 +3441,7 @@
     // CTextView::SetDocPosL will cause textview to be drawn. This could happen 
     // before the drawing of editor. So adding following codes to postpone the action to
     // first drawing of editor.
-    if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
+    if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
         {
         iEdwinExtension->iTempCursorPos = aDocPos;
         iEdwinExtension->iTempSelect = aSelect;
@@ -3657,7 +3461,7 @@
         CreateTextViewL();
     TInt oldPos( CursorPos() );
     TInt docPos( aDocPos );
-    if ( iEdwinExtension && iEdwinExtension->iSmiley )
+    if ( iEdwinExtension->iSmiley )
         {
         iEdwinExtension->iSmiley->HandleSetCursor( oldPos, docPos );
         }
@@ -3674,16 +3478,13 @@
     if ( iEdwinFepSupport && 
         ( aDocPos != oldPos || ( select.Length() > 0 && !aSelect ) ) )
         {
-        // Update text window position for cursor change.
-        iEdwinFepSupport->UpdateDocPosOffsetL( docPos );
         CAknEdwinState* edwinState = static_cast<CAknEdwinState*>( iEdwinFepSupport->State(KNullUid) );
         if ( edwinState )
             {
             TRAP_IGNORE( edwinState->ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged ) );
             }
         }
-	// scrollbar:thumb is displayed on the top when editor set cursor position.
-    iEdwinExtension->iThumbPos = KErrNotFound;    
+        
     UpdateVertScrollBarThumbL();
     UpdateHorizScrollBarThumb();
     }
@@ -3704,7 +3505,7 @@
         }
     if (!iTextView)
         CreateTextViewL();
-    if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
+    if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
         {        
         iEdwinExtension->iTempCursorPos = aCursorPos;
         iEdwinExtension->iTempAnchorPos = aAnchorPos;
@@ -3718,15 +3519,10 @@
     TCursorSelection select( aCursorPos, aAnchorPos );    
     HandleSelectionForSmiley( select );
     iTextView->SetSelectionL( select );
-    if ( iEdwinExtension )
-    	{
-		iEdwinExtension->iThumbPos =  KErrNotFound;
-    	}
+    iEdwinExtension->iThumbPos =  KErrNotFound;
 
     if ( iEdwinFepSupport )
         {
-        // Update text window position for cursor change.
-        iEdwinFepSupport->UpdateDocPosOffsetL( aCursorPos );
         CAknEdwinState* edwinState = static_cast<CAknEdwinState*>( iEdwinFepSupport->State(KNullUid) );
         if ( edwinState )
             {
@@ -3831,10 +3627,7 @@
     else
         CCoeControl::SetContainerWindowL(aParent);
 
-    if ( iEdwinExtension )
-    	{
-		iEdwinExtension->EnablePhysicsL();
-    	}
+    iEdwinExtension->EnablePhysicsL();
     }
 
 EXPORT_C void CEikEdwin::SetContainerWindowL()
@@ -3843,10 +3636,7 @@
     if (!OwnsWindow())
         CreateWindowL();
 
-    if ( iEdwinExtension )
-    	{
-		iEdwinExtension->EnablePhysicsL();
-    	}   
+    iEdwinExtension->EnablePhysicsL();   
     }
 
 EXPORT_C TCoeInputCapabilities CEikEdwin::InputCapabilities() const
@@ -3907,7 +3697,7 @@
     {
     __ASSERT_DEBUG(aLayDoc,Panic(EEikPanicEdwinNoText));
 
-    if ( iEdwinUserFlags&EAvkonEditor && iEdwinExtension )
+    if ((iEdwinUserFlags&EAvkonEditor))
         {
         iLayout=CTextLayout::NewL(aLayDoc,KMaxTInt); // supply real wrapping width later
         iLayout->SetCustomWrap(&(iEdwinExtension->TextWrapper()));
@@ -4082,7 +3872,7 @@
 
 EXPORT_C void CEikEdwin::TrappedDraw(const TRect& aViewRect) const
     {
-    if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
+    if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
         {
         CEikEdwin* edwin( const_cast<CEikEdwin*>( this ) );
         edwin->iEdwinExtension->iDrawInvoked = CEikEdwinExtension::EDrawing;
@@ -4203,7 +3993,7 @@
         }
     TInt oldCursor( CursorPos() );
     TPoint movePoint=iTextView->MoveCursorL( aMovement, aSelect );
-    if ( iEdwinExtension && iEdwinExtension->iSmiley )
+    if ( iEdwinExtension->iSmiley )
         {
         TCursorSelection select( 0, 0 );
         if ( AdjustCursorForSmileyL( oldCursor, select ) )
@@ -4223,8 +4013,6 @@
 
     if ( iEdwinFepSupport )
         {
-        // Update text window position for cursor change.
-        iEdwinFepSupport->UpdateDocPosOffsetL( CursorPos() );
         CAknEdwinState* edwinState = static_cast<CAknEdwinState*>( 
             iEdwinFepSupport->State( KNullUid ) );
         if ( edwinState )
@@ -4242,7 +4030,7 @@
     // Before scrolling into blank space was allowed, but this eventually
     // causes a panic at CTextView::ScrollDisplayL().
     const TInt move=iTextView->ScrollDisplayL(aMovement,CTextLayout::EFDisallowScrollingBlankSpace);
-    if ( move && iEdwinExtension )
+    if (move)
         {
         iEdwinExtension->iThumbPos = KErrNotFound;
         switch (aMovement)
@@ -4297,7 +4085,7 @@
 EXPORT_C TInt CEikEdwin::CursorPos() const
     {
     __ASSERT_DEBUG(iTextView,Panic(EEikPanicEdwinNoView));
-    if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && 
+    if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && 
         iEdwinExtension->iTempCursorPos != KErrNotFound )
         {
         return iEdwinExtension->iTempCursorPos;
@@ -4313,7 +4101,7 @@
     {
     __ASSERT_DEBUG(iTextView,Panic(EEikPanicEdwinNoView));
     TCursorSelection selection( 0, 0 );
-    if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && 
+    if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && 
         iEdwinExtension->iTempCursorPos != KErrNotFound && 
         iEdwinExtension->iTempAnchorPos != KErrNotFound )
         {
@@ -4373,7 +4161,7 @@
             STATIC_CAST(CRichText*,iText)->CancelInsertCharFormat();
         aChanged=iText->DeleteL(aSelection.LowerPos(),length);
         }
-    if ( iEdwinExtension && iEdwinExtension->iSmiley )
+    if ( iEdwinExtension->iSmiley )
         { 
         iEdwinExtension->iSmiley->HandleDeleteL( aSelection.LowerPos(), length );
         }
@@ -4405,7 +4193,7 @@
     	{
         SetAknEditorFlags( edwinState->Flags() | EAknEditorFlagTextCursorVisible );
     	}
-    else if ( iEdwinExtension )
+    else
     	{
     	SetAknEditorFlags( edwinState->Flags() & ~EAknEditorFlagTextCursorVisible );
     	
@@ -4626,7 +4414,7 @@
         select.iCursorPos = iTextLimit;
         }
     TBool hasSmiley( EFalse );
-    if ( iEdwinExtension && iEdwinExtension->iSmiley )
+    if ( iEdwinExtension->iSmiley )
         {
         hasSmiley = iEdwinExtension->iSmiley->HasSmileyIconsInText();
         }
@@ -4712,7 +4500,7 @@
         AknTextUtils::ReplaceCharacters(segmBufPtr, KLineBreakCharacter,
                       TChar(CEditableText::EParagraphDelimiter));
 	    iText->InsertL(oldLength+segmStart,*segmBuf);
-	    if ( iEdwinExtension && iEdwinExtension->iSmiley )
+	    if ( iEdwinExtension->iSmiley )
 	        {
 	        iEdwinExtension->iSmiley->HandleInsertL( oldLength+segmStart, 
 	            insertLength );	        
@@ -4726,7 +4514,7 @@
 	    
 	    CleanupStack::PopAndDestroy(segmBuf);
         TRAP(err,iText->DeleteL(0,oldLength));
-        if ( iEdwinExtension && iEdwinExtension->iSmiley )
+        if ( iEdwinExtension->iSmiley )
             {
             iEdwinExtension->iSmiley->HandleDeleteL( 0, oldLength );
             ConvertTextForSmileyL( TCursorSelection( 0, 
@@ -4736,7 +4524,7 @@
     else
         {
         iText->Reset(); // Duplicates previous behaviour where null pointer argument reset text object
-        if ( iEdwinExtension && iEdwinExtension->iSmiley )
+        if ( iEdwinExtension->iSmiley )
             {
             iEdwinExtension->iSmiley->HandleDeleteL( 0, 
                 iText->DocumentLength() );
@@ -4745,15 +4533,9 @@
 
     CheckRemovePictures(0,iText->DocumentLength());
     CheckValidityOfChars(0,iText->DocumentLength());
-    if ( iEdwinExtension )
-    	{
-		iEdwinExtension->iDisableConvertInFormat = ETrue;
-		}
-	SetAmountToFormatL(ETrue); // performs formatting
-	if ( iEdwinExtension )
-    	{
-		iEdwinExtension->iDisableConvertInFormat = EFalse;
-    	}
+    iEdwinExtension->iDisableConvertInFormat = ETrue;
+    SetAmountToFormatL(ETrue); // performs formatting
+    iEdwinExtension->iDisableConvertInFormat = EFalse;
 	// Update cursor position as CursorWidth() needs that.
     if (IsReadyToDraw())
         {        
@@ -4783,10 +4565,6 @@
             iCcpuSupport->HandleSelectionChangeL();
             }
         }
-    if ( iEdwinExtension )
-    	{
-		iEdwinExtension->iThumbPos = KErrNotFound;
-    	}
     if (IsReadyToDraw())
         {
         UpdateScrollBarsL();
@@ -4797,7 +4575,7 @@
 
 EXPORT_C TCursorSelection CEikEdwin::Selection()    const
     {
-    if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && 
+    if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && 
         iEdwinExtension->iTempCursorPos != KErrNotFound && 
         iEdwinExtension->iTempAnchorPos != KErrNotFound )
         {        
@@ -4852,7 +4630,7 @@
         TRAPD(err,undoneLength=iText->PasteFromStoreL(iUndoStore->Store(),iUndoStore->Dictionary(),lower))
         const TInt cursorPos=iUndoStore->OldCursorPos();
         iTextView->SetPendingSelection(TCursorSelection(cursorPos,cursorPos));
-        if ( iEdwinExtension && iEdwinExtension->iSmiley )
+        if ( iEdwinExtension->iSmiley )
             {
             iEdwinExtension->iSmiley->HandleInsertL( lower, undoneLength );
             ConvertTextForSmileyL( TCursorSelection( lower, undoneLength ), ETrue );
@@ -4930,7 +4708,7 @@
     iText->ImportTextFileL(cursorPos,aFileName,aTextOrganisation);
     TInt insertLength( iText->DocumentLength() - oldLength );
     CheckValidityOfChars( oldLength, insertLength );
-    if ( iEdwinExtension && iEdwinExtension->iSmiley )
+    if ( iEdwinExtension->iSmiley )
         {
         iEdwinExtension->iSmiley->HandleInsertL( cursorPos, insertLength );
         ConvertTextForSmileyL( TCursorSelection( cursorPos, 
@@ -5048,16 +4826,15 @@
         // If we have deleted some text and previous position (before delete) is
         // out of current editor content, we must move back to inside content.
         TInt formattedHeight( iLayout->FormattedHeightInPixels() );
-        if ( prevEndPosition > formattedHeight && iEdwinExtension )
+        if ( prevEndPosition > formattedHeight )
            {
            TInt movement( prevEndPosition - formattedHeight );   
            iEdwinExtension->iPhysicsHandler->MoveScrollIndex( movement );
            }
         }
     
-    if ( reportChange && iEdwinExtension )
-        {
-        iEdwinExtension->iThumbPos = KErrNotFound;
+    if (reportChange)
+        {
         ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate );
         DoReportEventL( MCoeControlObserver::EEventStateChanged );
         NotifyEditorStateObserverOfStateChangeL();
@@ -5106,7 +4883,7 @@
     CPlainText* text( iText );
     TInt start( selection.LowerPos() );
     HBufC* buf( NULL );
-    if ( iEdwinExtension && iEdwinExtension->iSmiley )
+    if ( iEdwinExtension->iSmiley )
         {
         buf = ExtractTextLC( selection );
         text = CPlainText::NewL();
@@ -5118,7 +4895,7 @@
         text->InsertL( start, *buf );                
         }
     text->CopyToStoreL(aStore, aDict, start, selection.Length() );
-    if ( iEdwinExtension && iEdwinExtension->iSmiley )
+    if ( iEdwinExtension->iSmiley )
         {
         CleanupStack::PopAndDestroy( text );    
         CleanupStack::PopAndDestroy( buf );
@@ -5157,7 +4934,7 @@
     iTextView->SetPendingSelection(TCursorSelection(higher,higher));
     selection.iAnchorPos=selection.LowerPos();
     selection.iCursorPos=selection.iAnchorPos+pastedLength;
-    if ( iEdwinExtension && iEdwinExtension->iSmiley )
+    if ( iEdwinExtension->iSmiley )
         {
         iEdwinExtension->iSmiley->HandleInsertL( selection.LowerPos(), 
             selection.Length() );
@@ -5851,13 +5628,7 @@
     
     TRect viewRect( AdjustedViewRect() );
     const TInt formattedLines = Max(1, iLayout->NumFormattedLines());
-    const TInt formattedHeight = iLayout->FormattedHeightInPixels(); 
-	const TBool formattedHeightchanged( iEdwinExtension && 
-		( formattedHeight != iEdwinExtension->iRecordFormattedHeight ) );
-    if ( iEdwinExtension )
-    	{
-        iEdwinExtension->iRecordFormattedHeight = formattedHeight;
-    	}
+    const TInt formattedHeight = iLayout->FormattedHeightInPixels();    
     const TInt viewRectHeight = viewRect.Height();
     const TInt totalChars = iText->DocumentLength();    
     const TInt formattedLength = Min( totalChars, iLayout->FormattedLength() );
@@ -5873,12 +5644,9 @@
         if ( !iLayout->IsFormattingBand() )
             {                        
             aVertModel.iThumbSpan = viewRectHeight;
-            aVertModel.iScrollSpan = formattedHeight; 
-            if ( iEdwinExtension )
-            	{
-				aVertModel.iThumbPosition = iEdwinExtension->iThumbPos;  
-            	} 
-            if ( aVertModel.iThumbPosition == KErrNotFound || formattedHeightchanged )
+            aVertModel.iScrollSpan = formattedHeight;            
+            aVertModel.iThumbPosition = iEdwinExtension->iThumbPos;   
+            if ( aVertModel.iThumbPosition == KErrNotFound )
                 {
                 if ( bottomPos == totalChars )
                     {
@@ -5910,10 +5678,6 @@
             aVertModel.iThumbSpan = bottomPos - topPos;
             aVertModel.iScrollSpan = totalChars;        
             aVertModel.iThumbPosition = topPos;
-            if ( iEdwinExtension )
-            	{
-				iEdwinExtension->iThumbPos = topPos;
-            	}
             }
         return;
         }
@@ -6071,7 +5835,7 @@
         static_cast< const TAknDoubleSpanScrollBarModel* >
             ( iSBFrame->CEikScrollBarFrame::VerticalScrollBar()->Model() );
 
-    if ( iEdwinExtension && ( !iEdwinExtension->iUseRateScroll ) )
+    if ( !iEdwinExtension->iUseRateScroll )
         {
         aVertModel.iScrollSpan = heightBeforeFormat + formattedHeight
             + heightAfterFormat;
@@ -6080,7 +5844,7 @@
 
     // Rate scrolling
 
-    if ( iEdwinExtension && iEdwinExtension->iUseRateScroll )
+    if ( iEdwinExtension->iUseRateScroll )
         {
         TInt heightAboveView = formattedHeightAboveView + heightBeforeFormat;
         TInt heightBelowView = formattedHeightBelowView + heightAfterFormat;
@@ -6133,7 +5897,7 @@
             }
         }
     
-    if ( iEdwinExtension && iEdwinExtension->iUseRateScroll )
+    if ( iEdwinExtension->iUseRateScroll )
         {
         aVertModel.iThumbPosition = anchorThumbPos;
         }
@@ -6141,10 +5905,7 @@
         {
         aVertModel.iThumbPosition = approxTopVisibleLine * avgLineHeight;
         }
-    if ( iEdwinExtension )
-    	{
-		iEdwinExtension->iScrollbarPosition = aVertModel.iThumbPosition; 
-    	}
+    iEdwinExtension->iScrollbarPosition = aVertModel.iThumbPosition; 
     }
 
 // ---------------------------------------------------------------------------
@@ -6164,11 +5925,7 @@
     TInt thumbSpaceAbove = aScrollBar->ThumbPosition();
     TInt thumbSpaceBelow = curScrollSpan - curThumbSpan - thumbSpaceAbove;
 
-    TInt moveOffset = 0;
-    if ( iEdwinExtension )
-    	{
-		moveOffset = thumbSpaceAbove - iEdwinExtension->iScrollbarPosition;
-    	}
+    TInt moveOffset = thumbSpaceAbove - iEdwinExtension->iScrollbarPosition;
 
     const TInt formattedLines = Max( 1, iLayout->NumFormattedLines() );
     const TInt formattedHeight = iLayout->FormattedHeightInPixels();
@@ -6206,6 +5963,7 @@
         {
         return;
         }
+    iEdwinExtension->iScrollbarPosition = thumbSpaceAbove;
 
     // If scrollbar thumb is moved to the beginning or end of scrollbar,
     // ensure that also editor content is moved also exactly to the beginning
@@ -6221,18 +5979,12 @@
         textMovePixels -= KAdditionalPixels;
         }
     
-    if ( iEdwinExtension )
-    	{
-        iEdwinExtension->iScrollbarPosition = thumbSpaceAbove;
-        iEdwinExtension->iScrolledByScrollBar = ETrue;
-        
-        // Actual scrolling is done by calling MoveScrollIndex
-        iEdwinExtension->iPhysicsHandler->MoveScrollIndex( -textMovePixels );
-        iEdwinExtension->iEndBorderExceeded = EFalse; 
-        iEdwinExtension->iStartBorderExceeded = EFalse; 
-        
-        iEdwinExtension->iScrolledByScrollBar = EFalse;
-    	}
+    iEdwinExtension->iScrolledByScrollBar = ETrue;
+    
+    // Actual scrolling is done by calling MoveScrollIndex
+    iEdwinExtension->iPhysicsHandler->MoveScrollIndex( -textMovePixels );
+    
+    iEdwinExtension->iScrolledByScrollBar = EFalse;
     }
 
 EXPORT_C void CEikEdwin::HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType)
@@ -6317,14 +6069,6 @@
             UpdateHorizScrollBarThumb();// can also change horizontally
             }
             break;
-        case EEikScrollThumbReleaseVert:
-            {
-            if ( KineticScrollingEnabled() )
-                {
-                RestoreCursorState();
-                }
-            }
-            break;
         case EEikScrollUp:
         case EEikScrollDown:            
         case EEikScrollPageUp:
@@ -6333,7 +6077,6 @@
             {
             if ( KineticScrollingEnabled() )
                 {
-                StoreCursorState();
                 HandleScrollEventWithPhysics( aScrollBar );
                 break;
                 }
@@ -6354,7 +6097,7 @@
                 TInt bottomPos( iTextView->XyPosToDocPosL( viewRect.iBr ) );
                 TInt visibleRange( bottomPos - topPos );
                 
-                if ( thumbPosition != thumbSpan && iEdwinExtension )                
+                if ( thumbPosition != thumbSpan )                
                     {   
                     TInt scrollRange( totalChars - visibleRange );
                     docPos = ( TInt )( ( TInt64 )( thumbPosition ) * scrollRange
@@ -6380,10 +6123,7 @@
                 docPos = totalChars;
                 yPos = viewRect.iBr.iY;
                 }
-            if ( iEdwinExtension )
-            	{
-				iEdwinExtension->iThumbPos = thumbPosition;
-            	}
+            iEdwinExtension->iThumbPos = thumbPosition;
             TViewYPosQualifier yPosQ;
             yPosQ.SetMakeLineFullyVisible();            
             iTextView->SetViewL( docPos, yPos, yPosQ,
@@ -6754,7 +6494,7 @@
                 {
                 TRAP_IGNORE( iText->DeleteL(aStartPos,1));
                 }
-            if ( iEdwinExtension && iEdwinExtension->iSmiley )
+            if ( iEdwinExtension->iSmiley )
                 {
                 iEdwinExtension->iSmiley->HandleDeleteL( aStartPos, 1 );
                 }
@@ -6905,20 +6645,10 @@
         {
     case KEikDynamicLayoutVariantSwitch:
         {
-        if ( KineticScrollingEnabled() && iEdwinExtension )
-            {
-            iEdwinExtension->iPhysicsHandler->DisableDragging();
-            }
-        if ( iEdwinExtension )
-        	{
-			iEdwinExtension->iThumbPos = KErrNotFound;
-	        iEdwinExtension->iEndBorderExceeded = EFalse; 
-	        iEdwinExtension->iStartBorderExceeded = EFalse; 
-        	}
+        iEdwinExtension->iThumbPos = KErrNotFound;
         SizeChanged();
         if ( !IsReadOnly() && !IsNonFocusing() 
-                && !( iEdwinUserFlags & EDisplayOnly )
-                && !KineticScrollingEnabled() )
+                && !( iEdwinUserFlags & EDisplayOnly ) )
             {
             TInt docPos = CursorPos();
             TRect viewRect( AdjustedViewRect() );
@@ -6954,18 +6684,6 @@
     case KEikInputLanguageChange:
         {
         UpdateCache(KEikInputLanguageChange);
-        TLanguage language = CAknEnv::Static()->SettingCache().InputLanguage(); 
-		if ( language == ELangArabic || language == ELangFarsi || 
-			language == ELangUrdu || language == ELangHebrew )
-			{
-			iEdwinUserFlags &= ~EAvkonEnableSmileySupport;
-			EnableSmileySupportL( EFalse );
-			}
-		else if ( iEdwinExtension->iEnableSmileySupported )
-			{
-			iEdwinUserFlags |= EAvkonEnableSmileySupport;
-			EnableSmileySupportL( ETrue );
-			}
         DoAlignment();
         }
         break;
@@ -7169,13 +6887,13 @@
     else
         {
         formatChanged=iText->DeleteL(lowerPos,length);
-        if ( iEdwinExtension && iEdwinExtension->iSmiley )
+        if ( iEdwinExtension->iSmiley )
             {
             iEdwinExtension->iSmiley->HandleDeleteL( lowerPos, length );
             }
         }
     iText->InsertL(aInsertPos,aText);
-    if ( iEdwinExtension && iEdwinExtension->iSmiley )
+    if ( iEdwinExtension->iSmiley )
         {
         iEdwinExtension->iSmiley->HandleInsertL( aInsertPos, aText.Length() );
         ConvertTextForSmileyL( TCursorSelection( aInsertPos, 
@@ -7638,29 +7356,7 @@
                 break;
             }
 
-	    // get special character table resource ID
-        TInt sctResourceId = state->SpecialCharacterTableResourceId();
-		if ( sctResourceId && ( state->Flags() & EAknEditorFlagUseSCTNumericCharmap ) )
-			{
-		    // numericSCTBuf containing number and special characters
-			HBufC* numericSCTBuf = HBufC::NewLC( KNmericSCTLimit );
-			TPtr numericSCTPtr( numericSCTBuf->Des() );
-			
-			// read number characters and add them to numericSCTBuf
-			HBufC* numberResource = iEikonEnv->AllocReadResourceLC( resId );
-			TPtr numberResPtr( numberResource->Des() );
-			numericSCTPtr.Append( numberResPtr );
-			CleanupStack::PopAndDestroy( numberResource ); // numberResource
-			
-		    // read special characters from SCT by dialog ID
-		    ReadSpecialCharFromSCTL( numericSCTPtr, sctResourceId );
-		    
-		    return numericSCTBuf;
-			}
-		else
-			{
-		    return iEikonEnv->AllocReadResourceLC( resId );
-			}
+        return iEikonEnv->AllocReadResourceLC(resId);
         }
     else
         {
@@ -7680,11 +7376,7 @@
         edwinState = STATIC_CAST(CAknEdwinState*, iEdwinFepSupport->State(KNullUid));
         }
 
-    CAknPictographInterface* pictographInterface = NULL;
-    if ( iEdwinExtension )
-    	{
-		pictographInterface = iEdwinExtension->PictographInterface();
-    	}
+    CAknPictographInterface* pictographInterface = iEdwinExtension->PictographInterface();
     if (edwinState)
         {
         if (FeatureManager::FeatureSupported(KFeatureIdJapanese))
@@ -7865,7 +7557,6 @@
     SetVKBStatus(); 
     if ( aFlag & EAvkonEnableSmileySupport )
         {
-        iEdwinExtension->iEnableSmileySupported = ETrue;
         EnableSmileySupportL( ETrue );
         }
     }
@@ -7876,7 +7567,6 @@
     SetVKBStatus(); 
     if ( aFlag & EAvkonEnableSmileySupport )
         {    
-        iEdwinExtension->iEnableSmileySupported = EFalse;
         EnableSmileySupportL( EFalse );
         }
     }
@@ -8262,10 +7952,7 @@
 
 EXPORT_C void CEikEdwin::SetPictographAnimationCallBack( TCallBack& aCallBack )
     {
-	if ( iEdwinExtension )
-		{
-		iEdwinExtension->SetPictoCallBack( aCallBack );
-		}
+    iEdwinExtension->SetPictoCallBack( aCallBack );
     }
 
 const TCallBack& CEikEdwin::PictographAnimationCallBack() const
@@ -8349,15 +8036,7 @@
     {
     if ( iEdwinExtension && aEnable )
         {
-        iEdwinExtension->EnableKineticScrollingL( NULL );
-        }
-    }
-
-EXPORT_C void CEikEdwin::EnableKineticScrollingL( CAknPhysics* aPhysics )
-    {
-    if ( iEdwinExtension )
-        {
-        iEdwinExtension->EnableKineticScrollingL( aPhysics );
+        iEdwinExtension->EnableKineticScrollingL();
         }
     }
 
@@ -8397,11 +8076,7 @@
     
 void CEikEdwin::SetVKBStatus()
     {
-	TUint cap = 0;
-    if ( iEdwinExtension )
-		{
-		cap = iEdwinExtension->iExtendedInputCapabilities->Capabilities();
-		}
+    TUint cap = iEdwinExtension->iExtendedInputCapabilities->Capabilities();
     if ( iEdwinUserFlags & EAvkonDisableVKB )
         {
         cap |= CAknExtendedInputCapabilities::EInputEditorDisableVKB;    
@@ -8409,11 +8084,8 @@
     else
         {
         cap &= ~CAknExtendedInputCapabilities::EInputEditorDisableVKB;
-        } 
-    if ( iEdwinExtension )
-    	{
-		iEdwinExtension->iExtendedInputCapabilities->SetCapabilities( cap );
-    	}
+        }   
+    iEdwinExtension->iExtendedInputCapabilities->SetCapabilities( cap );
     }
     
 void CEikEdwin::ScrollViewToCursorLineL()
@@ -8445,7 +8117,7 @@
 
 void CEikEdwin::PerformRecordedOperationL()
     {
-    if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw ||
+    if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw ||
         iEdwinExtension->iDrawInvoked == CEikEdwinExtension::EDrawing )
         {        
         if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
@@ -8504,8 +8176,8 @@
         UpdateScrollBarsL();
         scroll = ETrue ;
         }
-    if ( scroll && iEdwinExtension && 
-    		iEdwinExtension->iDrawInvoked != CEikEdwinExtension::EDrawing )
+    if ( scroll && iEdwinExtension->iDrawInvoked != 
+        CEikEdwinExtension::EDrawing )
         {
         ReportEdwinEventL( MEikEdwinObserver::EEventNavigation );
         }
@@ -8518,46 +8190,7 @@
     if ( chinesePopup != ( aNewFlags & EAknEditorFlagChinesePopup ) )
         {
         TRAP_IGNORE( ReportChinesePopupEventL( chinesePopup == 0 ) );
-        }
-    
-    // To reduce power consumption, text view should be hidden when full screen Touch
-    // Input is open and editor is covered by it, for user can not see editor in this 
-    // case. When full screen Touch Input is open, FEP will set flag EAknEditorFlagHideTextView 
-    // to notify editor the text view should be hidden. But we have to check if the feature 
-    // of partial screen input is enabled at the same time, for full screen Touch Input window 
-    // will only occupy part of the screen if the feature is eanbled and editor is still visible 
-    // to user. So editor can only be hidden in such situation: full screen Touch Input is open 
-    // and partial screen feature is disabled.
-    // In the contrary situations (full screen touch input is closed or partial screen 
-    // feature is enabled), text view has to be shown so editor can work as normal.
-    if ( iTextView && iEdwinExtension )
-        {
-        TBool textViewHideEnabled( ( aNewFlags & EAknEditorFlagHideTextView ) &&
-            !( aOldFlags & EAknEditorFlagHideTextView ) );
-
-        TBool textViewHideDisabled( !( aNewFlags & EAknEditorFlagHideTextView ) && 
-            ( aOldFlags & EAknEditorFlagHideTextView ) );
-
-        TBool partialScreenEnabled( ( aNewFlags & EAknEditorFlagEnablePartialScreen ) &&
-            !( aOldFlags & EAknEditorFlagEnablePartialScreen ) );
-
-        TBool partialScreenDisabled( !( aNewFlags & EAknEditorFlagEnablePartialScreen ) && 
-            ( aOldFlags & EAknEditorFlagEnablePartialScreen ) );
-         
-        if ( ( textViewHideEnabled && 
-                !( aNewFlags & EAknEditorFlagEnablePartialScreen ) ) ||
-             ( partialScreenDisabled && ( aNewFlags & EAknEditorFlagHideTextView ) ) )
-            {
-            iTextView->MakeVisible( EFalse );
-            iEdwinExtension->iTextViewHidden = ETrue;
-            }
-        else if ( iEdwinExtension->iTextViewHidden && ( textViewHideDisabled || partialScreenEnabled ) )
-            {
-            iTextView->MakeVisible( ETrue );
-            DrawNow();
-            iEdwinExtension->iTextViewHidden = EFalse;            
-            }
-        }
+        }    
     }
 
 void CEikEdwin::ReportChinesePopupEventL( TBool aChinesePopupOpen )
@@ -8575,29 +8208,24 @@
 // for smiley support
 void CEikEdwin::EnableSmileySupportL( TBool aEnableSmiley )
     {
-    if ( aEnableSmiley && !AknLayoutUtils::LayoutMirrored() && iEdwinExtension )
-        {
-        TLanguage language = CAknEnv::Static()->SettingCache().InputLanguage();
-		if ( language != ELangArabic && language != ELangFarsi && 
-			language != ELangUrdu && language != ELangHebrew )
-			{
-			if ( !iEdwinExtension->iSmiley )
-				{
-				iEdwinExtension->iSmiley = CSmileyManager::NewL( *this );
-				iEdwinExtension->iSmiley->SetAnimationPlayTimes( KNormalAnimPlayTimes );
-				if ( IsReadOnly() || iEdwinUserFlags & EDisplayOnly )
-					{
-					iEdwinExtension->iSmiley->SetAnimationPlayTimes( 
-						KInfiniteAnimPlayTimes );
-					}
-				}        
-			if ( TextLayout() )
-				{
-				TextLayout()->SetCustomWrap( iEdwinExtension->iSmileyWrap );
-				}
-			}
+    if ( aEnableSmiley && !AknLayoutUtils::LayoutMirrored() )
+        {
+        if ( !iEdwinExtension->iSmiley )
+            {
+            iEdwinExtension->iSmiley = CSmileyManager::NewL( *this );
+            iEdwinExtension->iSmiley->SetAnimationPlayTimes( KNormalAnimPlayTimes );
+            if ( IsReadOnly() || iEdwinUserFlags & EDisplayOnly )
+                {
+                iEdwinExtension->iSmiley->SetAnimationPlayTimes( 
+                    KInfiniteAnimPlayTimes );
+                }
+            }        
+        if ( TextLayout() )
+            {
+            TextLayout()->SetCustomWrap( iEdwinExtension->iSmileyWrap );
+            }
         }    
-    else if ( iEdwinExtension )
+    else
         {
         delete iEdwinExtension->iSmiley;
         iEdwinExtension->iSmiley = NULL;
@@ -8610,16 +8238,11 @@
 
 TBool CEikEdwin::IsSmileyEnabled() const
     {
-    TBool ret = EFalse; 
-    if ( iEdwinExtension )
-        {
-        ret = ( iEdwinExtension->iSmiley != NULL );
-        }
-    return ret;
-    }
-
-void CEikEdwin::DrawSmileyInTextL( RRegion& rgn, const TRect& aDrawRect, 
-    CBitmapContext& aGc, CFont& aFont, const TDesC& aText, const TPoint& aPt )
+    return ( iEdwinExtension->iSmiley != NULL );
+    }
+
+void CEikEdwin::DrawSmileyInTextL( CBitmapContext& aGc, CFont& aFont, 
+        const TDesC& aText, const TPoint& aPt )
     {    
     TRect viewRect( AdjustedViewRect() );
     TInt topY( aPt.iY - aFont.AscentInPixels() );
@@ -8646,14 +8269,11 @@
         TInt smileyWidth( aFont.TextWidthInPixels( KSmileyString ) );
         for ( TInt i( 0 ); i < text.Length(); i++ )
             {
-            if ( iEdwinExtension && CSmileyManager::IsSmileyCode( text[i] ) )
+            if ( CSmileyManager::IsSmileyCode( text[i] ) )
                 {
                 TInt x( pt.iX + aFont.TextWidthInPixels( text.Left( i ) ) );
-                TRect clipRect( x, aDrawRect.iTl.iY, x + smileyWidth, 
-                    aDrawRect.iBr.iY ); 
-                rgn.SubRect( clipRect, NULL );
-                TRect iconRect( x, topY, x + smileyWidth, bottomY );
-                iEdwinExtension->iSmiley->DrawIconL( aGc, iconRect, i + pos );
+                TRect rect( x, topY, x + smileyWidth, bottomY );
+                iEdwinExtension->iSmiley->DrawIconL( aGc, rect, i + pos );
                 }
             }
         }
@@ -8662,7 +8282,7 @@
 
 void CEikEdwin::ConvertVisibleTextForSmileyL( TBool aTextToCode )
     {
-    if ( iEdwinExtension && !iEdwinExtension->iSmiley && !iTextView )
+    if ( !iEdwinExtension->iSmiley && !iTextView )
         {
         return;
         }
@@ -8673,7 +8293,7 @@
 void CEikEdwin::ConvertTextForSmileyL( TCursorSelection aSelect, 
     TBool aTextToCode, TBool aRedraw )
     {    
-    if ( iEdwinExtension && iEdwinExtension->iSmiley && !iEdwinExtension->iInlineEditing )
+    if ( iEdwinExtension->iSmiley && !iEdwinExtension->iInlineEditing )
         {
         if ( aTextToCode )
             {
@@ -8693,13 +8313,7 @@
         CleanupStack::PopAndDestroy( buf );
         if ( aRedraw )
             {
-            CAknEdwinState* edwinState = 
-                static_cast<CAknEdwinState*>( iEdwinFepSupport->State( KNullUid ) );
-
-            if ( !( edwinState->Flags() & EAknEditorFlagHideTextView ) )
-                {
-                DrawDeferred();
-                }
+            DrawDeferred();
             }
         }
     }
@@ -8751,7 +8365,7 @@
 
 void CEikEdwin::ConvertSmileyIconToTextL( TInt aStartPos, TDes& aText )
     {
-    if ( iEdwinExtension && iEdwinExtension->iSmiley )
+    if ( iEdwinExtension->iSmiley )
         {
         iEdwinExtension->iSmiley->ConvertTextForSmileyL( aStartPos,
             aText, EFalse );
@@ -8760,7 +8374,7 @@
 
 void CEikEdwin::ExtendedRangeForSmiley( TCursorSelection& aSelect )
     { 
-    if ( iEdwinExtension && iEdwinExtension->iSmiley )
+    if ( iEdwinExtension->iSmiley )
         {
         TInt textLength( TextLength() );
         TInt start = aSelect.LowerPos() - CSmileyManager::KMaxLength;
@@ -8780,7 +8394,7 @@
 
 TBool CEikEdwin::ConvertSmileyForDeleteL( TInt aDocPos, TBool aBackSpace )
     {
-    if ( iEdwinExtension && !iEdwinExtension->iSmiley || ( aDocPos == 0 && aBackSpace ) || 
+    if ( !iEdwinExtension->iSmiley || ( aDocPos == 0 && aBackSpace ) || 
         ( aDocPos == TextLength() && !aBackSpace ) )
         {
         return EFalse;
@@ -8791,7 +8405,9 @@
         checkPos--;
         checkPos = checkPos >= 0 ? checkPos : 0;
         }
-    if ( iEdwinExtension->iSmiley->SmileyCodeByPos( checkPos ) > 0 )
+    if ( CSmileyManager::IsSmileyCode( iEdwinExtension->iSmiley->
+        SmileyCodeByPos( checkPos ) ) && 
+        !iEdwinExtension->iSmiley->IsDisabledSmileyIcon( checkPos ) )
         {
         TInt codeLength( iEdwinExtension->iSmiley->SmileyLength( checkPos ) );
         iEdwinExtension->iSmiley->DisableSmileyIcon( checkPos );
@@ -8816,7 +8432,7 @@
 
 void CEikEdwin::ConvertSmileyForDeleteL( const TCursorSelection &aSelect )
     {
-    if ( iEdwinExtension && !iEdwinExtension->iSmiley )
+    if ( !iEdwinExtension->iSmiley )
         {
         return;
         }
@@ -8842,15 +8458,29 @@
     CleanupStack::PopAndDestroy( buf );
     }
 
+void CEikEdwin::HandleScrollForSmileyL()
+    {
+    if ( !iEdwinExtension->iSmiley )
+        {
+        return;
+        }
+    TCursorSelection select( GetVisibleTextRangeL() );
+    if ( select.LowerPos() != iEdwinExtension->iVisibleRange.LowerPos() ||
+        select.HigherPos() != iEdwinExtension->iVisibleRange.HigherPos() )
+        {
+        iEdwinExtension->iVisibleRange.iCursorPos = select.iCursorPos;
+        iEdwinExtension->iVisibleRange.iAnchorPos = select.iAnchorPos;
+        }
+    iEdwinExtension->iSmiley->SetVisibleRange( select.LowerPos(), 
+        select.Length() );
+    }
+
 TBool CEikEdwin::AdjustCursorForSmileyL( TInt aOldCursor, TCursorSelection& aSelect )
     {
     TBool ret( EFalse );
     TCursorSelection select( Selection() );
     TInt cursor( select.iCursorPos );
-    if ( iEdwinExtension )
-    	{
-		iEdwinExtension->iSmiley->HandleSetCursor( aOldCursor, cursor );
-    	}
+    iEdwinExtension->iSmiley->HandleSetCursor( aOldCursor, cursor );
     if ( cursor != select.iCursorPos )
         {
         if ( select.iAnchorPos == select.iCursorPos )
@@ -8870,11 +8500,28 @@
     return TRect( viewRect.iTl.iX, aRect.iTl.iY, viewRect.iBr.iX, aRect.iBr.iY );
     }
 
+void CEikEdwin::GetClipRegionForSmiley( RRegion& rgn, CFont& aFont, 
+    const TDesC& aText, const TPoint& aPt, const TRect& aDrawRect ) const
+    {
+    TInt smileyWidth( aFont.TextWidthInPixels( KSmileyString ) );
+    TInt topY( aDrawRect.iTl.iY );
+    TInt bottomY( aDrawRect.iBr.iY );
+    for ( TInt i( 0 ); i < aText.Length(); i++ )
+        {
+        if ( CSmileyManager::IsSmileyCode( aText[i] ) )
+            {
+            TInt x( aPt.iX + aFont.TextWidthInPixels( aText.Left( i ) ) );
+            TRect rect( x, topY, x + smileyWidth, bottomY );
+            rgn.SubRect( rect, NULL );
+            }
+        }
+    }
+
 TBool CEikEdwin::AdjustCursorPosByMovementL( TCursorPosition::TMovementType aMovement, 
     TBool aSelect )
     {
     TBool ret( EFalse );
-    if ( iEdwinExtension && iEdwinExtension->iSmiley )
+    if ( iEdwinExtension->iSmiley )
         {
         TInt oldPos( CursorPos() );
         TInt curPos( oldPos );
@@ -8896,34 +8543,20 @@
     return ret;
     }
 
-void CEikEdwin::SetSelectionVisibilityL( TBool aIsVisable )
-    {
-    if ( iEdwinExtension && iEdwinExtension->iSmiley && !aIsVisable )
-        {
-        iTextView->SetSelectionVisibilityL( aIsVisable );
-        HandleSelectionForSmiley( TCursorSelection( 0, 0 ) );
-        }
-    else 
-        {
-        if ( iEdwinExtension && iEdwinExtension->iSmiley )
-            {
-            HandleSelectionForSmiley( Selection() );
-            }
-        iTextView->SetSelectionVisibilityL( aIsVisable );
-        }
-   
+void CEikEdwin::SetSelectionVisibilityL( TBool isVisable )
+    {
+    iTextView->SetSelectionVisibilityL(isVisable);
     CAknEdwinState*edwinState = EditorState();
-    if ( edwinState )
-        {
-        if ( aIsVisable )
-            {
-            SetAknEditorFlags( edwinState->Flags() | EAknEditorFlagSelectionVisible );
-            }
-        else
-            {
-            SetAknEditorFlags( edwinState->Flags() & ~EAknEditorFlagSelectionVisible );
-            }
-        }
+    if( !edwinState )
+    	return;
+    if(isVisable)
+    	{
+        SetAknEditorFlags( edwinState->Flags() | EAknEditorFlagSelectionVisible );
+    	}
+    else
+    	{
+    	SetAknEditorFlags( edwinState->Flags() & ~EAknEditorFlagSelectionVisible );
+    	}
     return;
     }
 TBool CEikEdwin::IsSelectionVisible()
@@ -8941,8 +8574,8 @@
 		
 		TChar::TCategory category = character.GetCategory();
 		
-		if ( !( ( ( category & TChar::ESeparatorGroup ) == TChar::ESeparatorGroup ) ||
-			   ( text[i] >= 0x200B && text[i] <= 0xFFFC ) ) )
+		if ( !((category&TChar::ESeparatorGroup == TChar::ESeparatorGroup) ||
+			   (text[i]>=0x200B && text[i]<=0xFFFC)) )
 			{
 			ret = ETrue;
 			break;
@@ -8971,7 +8604,7 @@
         {
         // We can't move enough, we have exceeded the border
         // (at the beginning or end of the document)
-        if ( aPixelsToScroll != 0 && iEdwinExtension )
+        if ( aPixelsToScroll != 0 )
             {
             if ( aPixelsToScroll < 0 )
                 {
@@ -8995,7 +8628,7 @@
             }
         }
        
-    if ( scrolledPixels != 0 && iEdwinExtension )
+    if ( scrolledPixels != 0 )
         {
         iEdwinExtension->iScrolledDelta = scrolledPixels;
         TRAP_IGNORE( UpdateVertScrollBarThumbL() );
@@ -9023,24 +8656,21 @@
     // After that we have to move to mode where we use ScrollDisplayPixelsL
     // to detect if we exceed border again.
     TBool adjustScrolling( EFalse );
-    if ( iEdwinExtension )
-    	{
-		if ( aPixelsToScroll > 0  && iEdwinExtension->iEndBorderExceeded )
-			{
-			if ( aPixelsToScroll > - iEdwinExtension->iPixelsOutOfBorder )
-				{
-				adjustScrolling = ETrue;
-				}
-			}
-		else if ( aPixelsToScroll < 0 &&  iEdwinExtension->iStartBorderExceeded )
-			{
-			if ( aPixelsToScroll < - iEdwinExtension->iPixelsOutOfBorder )
-				{            
-				adjustScrolling = ETrue;
-				}
-			}
-    	}
-
+    if ( aPixelsToScroll > 0  && iEdwinExtension->iEndBorderExceeded )
+        {
+        if ( aPixelsToScroll > - iEdwinExtension->iPixelsOutOfBorder )
+            {
+            adjustScrolling = ETrue;
+            }
+        }
+    else if ( aPixelsToScroll < 0 &&  iEdwinExtension->iStartBorderExceeded )
+        {
+        if ( aPixelsToScroll < - iEdwinExtension->iPixelsOutOfBorder )
+            {            
+            adjustScrolling = ETrue;
+            }
+        }
+    
     if ( adjustScrolling )
         {
         // we are scrolling over the border, calculate how many
@@ -9053,26 +8683,23 @@
     // We are out of borders. Call scrolling function that supports bounce-effect
     TRAP_IGNORE( iTextView->ScrollDisplayPixelsNoLimitBorderL( aPixelsToScroll ) );
 
-    if ( iEdwinExtension )
-    	{
-		// Update variable that tells how near the border we are.
-		iEdwinExtension->iPixelsOutOfBorder += aPixelsToScroll;
-				   
-		if ( iEdwinExtension->iStartBorderExceeded
-			&& iEdwinExtension->iPixelsOutOfBorder <= 0 )
-			{
-			// We are inside borders, reset flag and tell to caller
-			iEdwinExtension->iStartBorderExceeded = EFalse;
-			aEndOfBounce = ETrue;
-			}
-		else if ( iEdwinExtension->iEndBorderExceeded
-			&& iEdwinExtension->iPixelsOutOfBorder >= 0 )
-			{
-			// we are inside borders, reset flag and tell to caller
-			iEdwinExtension->iEndBorderExceeded = EFalse;
-			aEndOfBounce = ETrue;
-			}
-    	}
+    // Update variable that tells how near the border we are.
+    iEdwinExtension->iPixelsOutOfBorder += aPixelsToScroll;
+               
+    if ( iEdwinExtension->iStartBorderExceeded
+        && iEdwinExtension->iPixelsOutOfBorder <= 0 )
+        {
+        // We are inside borders, reset flag and tell to caller
+        iEdwinExtension->iStartBorderExceeded = EFalse;
+        aEndOfBounce = ETrue;
+        }
+    else if ( iEdwinExtension->iEndBorderExceeded
+        && iEdwinExtension->iPixelsOutOfBorder >= 0 )
+        {
+        // we are inside borders, reset flag and tell to caller
+        iEdwinExtension->iEndBorderExceeded = EFalse;
+        aEndOfBounce = ETrue;
+        }
           
     if ( aPixelsToScroll != 0 )
         {
@@ -9090,12 +8717,7 @@
 //
 TInt CEikEdwin::PixelsOutOfBorder() const
     {
-    TInt ret = 0;
-    if ( iEdwinExtension )
-        {
-        ret = iEdwinExtension->iPixelsOutOfBorder;
-        }
-    return ret;
+    return iEdwinExtension->iPixelsOutOfBorder;
     }
 
 // ---------------------------------------------------------------------------
@@ -9112,10 +8734,7 @@
     // If aEnable is EFalse, Position scrolling mode is in use.
     // If aEnable is ETrue, Rate scrolling mode is in use.
     
-	if ( iEdwinExtension )
-		{
-		iEdwinExtension->iUseRateScroll = aEnable;
-		}
+    iEdwinExtension->iUseRateScroll = aEnable;
     }
 
 // ---------------------------------------------------------------------------
@@ -9125,7 +8744,7 @@
 void CEikEdwin::StoreCursorState()
     {
     CAknEdwinState* state( EditorState() );
-    if ( iEdwinExtension && state && state->Flags() & EAknEditorFlagTextCursorVisible )
+    if ( state && state->Flags() & EAknEditorFlagTextCursorVisible )
         {
         TRAP_IGNORE( SetCursorVisibilityL( EFalse ) );
         iEdwinExtension->iCursorWasVisible = ETrue;
@@ -9138,7 +8757,7 @@
 //
 void CEikEdwin::RestoreCursorState()
     {
-    if ( iEdwinExtension && iEdwinExtension->iCursorWasVisible )
+    if ( iEdwinExtension->iCursorWasVisible )
         {
         TRAP_IGNORE( SetCursorVisibilityL( ETrue ) );
         iEdwinExtension->iCursorWasVisible = EFalse;
@@ -9155,68 +8774,20 @@
     }
 
 
-// ---------------------------------------------------------------------------
-// CEikEdwin::DrawViewBackground
-// ---------------------------------------------------------------------------
-//
-void CEikEdwin::DrawViewBackground( TBool aStart ) const
-    {
-    CWindowGc& gc = SystemGc();
-    RWindow& window = Window();
-
-    if ( aStart )
-        {
-        TRect viewRect( iTextView->ViewRect() );
-        window.Invalidate( viewRect );
-        window.BeginRedraw( viewRect );
-        gc.Activate( window );
-    
-        if ( iEdwinExtension && 
-        		!AknsDrawUtils::DrawBackground( 
-                iEdwinExtension->iSkinInstance, 
-                SkinBackgroundControlContext(),
-                this,
-                gc,
-                viewRect.iTl,
-                viewRect,
-                KAknsDrawParamNoClearUnderImage ) )
-            {
-            gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
-            gc.SetPenStyle( CGraphicsContext::ESolidPen );
-    
-            TRgb dummyColor;
-            TRgb backgroundColor = EditorBackgroundColor( dummyColor ); 
-    
-            gc.SetBrushColor( backgroundColor );
-            gc.SetPenColor( backgroundColor );
-            gc.DrawRect( iTextView->ViewRect() );
-            }
-        }
-    else
-        {
-        gc.Deactivate();
-        window.EndRedraw();
-        }
-    }
-
-
 void CEikEdwin::HandleSelectionForSmiley( TCursorSelection aSelect )
     {
-	if ( iEdwinExtension )
-		{
-		if ( !iEdwinExtension->iSmiley )
-	        {
-	        return;
-	        }
-	    if ( iCustomDrawer )
-	        {
-	        iEdwinExtension->iSmiley->SetHighlightColor( 
-	            iCustomDrawer->SystemColor( TLogicalRgb::ESystemSelectionBackgroundIndex, 
-	                KRgbWhite ) );
-	        }
-	    iEdwinExtension->iSmiley->HandleSelection( aSelect.LowerPos(), 
-	        aSelect.Length() );
-		}
+    if ( !iEdwinExtension->iSmiley )
+        {
+        return;
+        }
+    if ( iCustomDrawer )
+        {
+        iEdwinExtension->iSmiley->SetHighlightColor( 
+            iCustomDrawer->SystemColor( TLogicalRgb::ESystemSelectionBackgroundIndex, 
+                KRgbWhite ) );
+        }
+    iEdwinExtension->iSmiley->HandleSelection( aSelect.LowerPos(), 
+        aSelect.Length() );
     }
 
 // ---------------------------------------------------------------------------
@@ -9228,95 +8799,21 @@
     return iEdwinInternalFlags & ESkipBackgroundDrawer;
     }
 
-
-// ---------------------------------------------------------------------------
-// CEikEdwin::ContentFitsToViewRect
-// ---------------------------------------------------------------------------
-//
-TBool CEikEdwin::ContentFitsToViewRect() const
-    {
-    if ( iLayout && !iLayout->IsFormattingBand() )
-        {
-        if ( iLayout->FormattedHeightInPixels()
-            <= AdjustedViewRect().Height() + KContentThreshold )
-            {
-            return ETrue;
-            }
-        }
-
-    return EFalse;
-    }
-
-
-// ---------------------------------------------------------------------------
-// ReadSpecialCharFromSCTL
-// ---------------------------------------------------------------------------
-//
-void ReadSpecialCharFromSCTL( TPtr& ptr, TInt sctResourceId )
-	{
-	TResourceReader aReader;
-	CCoeEnv::Static()->CreateResourceReaderLC( aReader, sctResourceId );
-	aReader.Advance( KTInt32Length ); // Diaog Flag
-	HBufC* titleBar = aReader.ReadHBufCL(); // title bar
-	// for titleBar useless, release it.
-	delete titleBar;
-	titleBar = NULL;
-	// Page Selector Resource Id, Button Group Container Resource Id
-	aReader.Advance( KTInt32Length + KTInt32Length );
-	TInt lineCount = aReader.ReadInt16(); // line Count
-	for ( TInt ii = 0; ii < lineCount; ii++ )
-		{
-        TInt controlType = aReader.ReadInt16(); // control Type
-	    if ( controlType == EAknCtPopupHeadingPane )
-	    	{
-	        // read HeadPane
-	    	ReadSCTHeadPane( aReader );
-	    	}
-	    else if ( controlType == EAknCtSpecialCharacterMap )
-	    	{
-	        aReader.ReadTPtrC(); // caption text
-			aReader.Advance( KTInt16Length + KTInt32Length ); // captioned control ID, item flags
-			
-			TInt component_count = aReader.ReadInt16();
-			for ( TInt jj = 0; jj < component_count; jj++ )
-				{
-				TInt component_id = aReader.ReadInt16();
-				if ( component_id == EAknSCTLowerCase || component_id == EAknSCTUpperCase ||
-					component_id == EAknSCTNumeric )
-					{
-					HBufC* specialChar = aReader.ReadHBufCL();
-					ptr.Append( specialChar->Des() );
-					delete specialChar;
-					}
-				}
-	    	}
-	    else
-	    	{
-	        break;
-	    	}
-		}
-	CleanupStack::PopAndDestroy(); // aReader
-	}
-
-// ---------------------------------------------------------------------------
-// ReadSCTHeadPane
-// ---------------------------------------------------------------------------
-//
-void ReadSCTHeadPane( TResourceReader& aReader )
-	{
-	aReader.ReadTPtrC(); // caption text
-	// captioned control ID, item flags
-	aReader.Advance( KTInt16Length + KTInt32Length );
-	aReader.ReadTPtrC(); // text of head pane
-	aReader.ReadTPtrC(); // bitmap File Name of head pane
-	// bitmap Id, bitmap Mask Id,animation Id, layout of head pane
-	aReader.Advance( KTInt16Length + KTInt16Length + KTUint32Length + KTUint32Length );
-	aReader.ReadTPtrC(); // trailer
-	aReader.ReadTPtrC(); // bitmap File Name of captioned control
-	// bitmap Id, bitmap Mask Id of captioned control
-	aReader.Advance( KTInt16Length + KTInt16Length );
-	aReader.ReadTPtrC(); // Process ToolTip
-	}
+TBool CEikEdwin::IsValidNumericCharL( TChar aChar )
+    { 
+    TBool ret(ETrue);
+    CAknEdwinState* state = static_cast<CAknEdwinState*>( iEdwinFepSupport->State( KNullUid ) );    
+    if (state && state->CurrentInputMode() == EAknEditorNumericInputMode )
+    	{
+        HBufC* allowedChars = GetAllowedCharsLC();
+        if ( (*allowedChars).Length() > 0 && (*allowedChars).Locate( aChar ) == KErrNotFound )
+            {
+            ret = EFalse;
+            }
+        CleanupStack::PopAndDestroy(1);//allowedChars
+        }
+    return ret;
+    }
 
 // End of File