webengine/osswebengine/WebKit/s60/webview/WebFepTextEditor.cpp
changeset 10 a359256acfc6
parent 1 7c90e6132015
child 11 c8a366e56285
equal deleted inserted replaced
5:10e98eab6f85 10:a359256acfc6
    28 #include "WebTextFormatMask.h"
    28 #include "WebTextFormatMask.h"
    29 #include "WebView.h"
    29 #include "WebView.h"
    30 #include "WebFrame.h"
    30 #include "WebFrame.h"
    31 #include "Page.h"
    31 #include "Page.h"
    32 #include "FocusController.h"
    32 #include "FocusController.h"
       
    33 #include "WebFrameView.h"
    33 
    34 
    34 #include "Frame.h"
    35 #include "Frame.h"
    35 #include "Editor.h"
    36 #include "Editor.h"
    36 #include "HtmlNames.h"
    37 #include "HtmlNames.h"
    37 #include "EventHandler.h"
    38 #include "EventHandler.h"
    58     User::Panic(KPanicCat,aPanic);
    59     User::Panic(KPanicCat,aPanic);
    59     }
    60     }
    60 
    61 
    61 // -----------------------------------------------------------------------------
    62 // -----------------------------------------------------------------------------
    62 // CWebFepTextEditor
    63 // CWebFepTextEditor
    63 // 
    64 //
    64 // 
    65 //
    65 // -----------------------------------------------------------------------------
    66 // -----------------------------------------------------------------------------
    66 CWebFepTextEditor::CWebFepTextEditor(WebView* aView)
    67 CWebFepTextEditor::CWebFepTextEditor(WebView* aView)
    67     : m_webView(aView),
    68     : m_webView(aView),
    68       m_textFormatMask(NULL),
    69       m_textFormatMask(NULL),
    69       m_inlineEditText(NULL)
    70       m_inlineEditText(NULL)
    81 	EnableCcpu(ETrue);
    82 	EnableCcpu(ETrue);
    82 }
    83 }
    83 
    84 
    84 // -----------------------------------------------------------------------------
    85 // -----------------------------------------------------------------------------
    85 // ~CWebFepTextEditor
    86 // ~CWebFepTextEditor
    86 // 
    87 //
    87 // 
    88 //
    88 // -----------------------------------------------------------------------------
    89 // -----------------------------------------------------------------------------
    89 CWebFepTextEditor::~CWebFepTextEditor()
    90 CWebFepTextEditor::~CWebFepTextEditor()
    90     {
    91     {
    91     delete m_state;
    92     delete m_state;
    92     delete m_inlineEditText;
    93     delete m_inlineEditText;
    94 	delete m_ExtendedInputCapabilities;
    95 	delete m_ExtendedInputCapabilities;
    95     }
    96     }
    96 
    97 
    97 // -----------------------------------------------------------------------------
    98 // -----------------------------------------------------------------------------
    98 // CreateTextFormatMask
    99 // CreateTextFormatMask
    99 // 
   100 //
   100 // 
   101 //
   101 // -----------------------------------------------------------------------------
   102 // -----------------------------------------------------------------------------
   102 void CWebFepTextEditor::CreateTextFormatMask()
   103 void CWebFepTextEditor::CreateTextFormatMask()
   103 {
   104 {
   104     if (!m_textFormatMask) {        
   105     if (!m_textFormatMask) {
   105         Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   106         Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   106         if (frame &&
   107         if (frame &&
   107             frame->document() &&
   108             frame->document() &&
   108             frame->document()->focusedNode()) {                
   109             frame->document()->focusedNode()) {
   109             RenderStyle* s = frame->document()->focusedNode()->renderStyle();      
   110             RenderStyle* s = frame->document()->focusedNode()->renderStyle();
   110             if (s && 
   111             if (s &&
   111             	(!s->wapInputFormat().isEmpty() || s->wapInputRequired())){            
   112             	(!s->wapInputFormat().isEmpty() || s->wapInputRequired())){
   112                 m_textFormatMask = new WebTextFormatMask(s->wapInputFormat(), s->wapInputRequired());
   113                 m_textFormatMask = new WebTextFormatMask(s->wapInputFormat(), s->wapInputRequired());
   113             }
   114             }
   114         }
   115         }
   115     }
   116     }
   116 }              
   117 }
   117 
   118 
   118 // -----------------------------------------------------------------------------
   119 // -----------------------------------------------------------------------------
   119 // UpdateEditingMode
   120 // UpdateEditingMode
   120 // 
   121 //
   121 // 
   122 //
   122 // -----------------------------------------------------------------------------
   123 // -----------------------------------------------------------------------------
   123 void CWebFepTextEditor::UpdateEditingMode()
   124 void CWebFepTextEditor::UpdateEditingMode()
   124 {        
   125 {
       
   126     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
       
   127     if (frame) {
       
   128         Node *node = frame->document()->focusedNode(); 
       
   129         if (frame && frame->document() && node) {
       
   130             if (node->hasTagName(HTMLNames::inputTag) 
       
   131                     && (static_cast<HTMLInputElement*>(node)->inputType() == HTMLInputElement::PASSWORD) 
       
   132                         && !static_cast<HTMLInputElement*>(node)->readOnly()) {            
       
   133                 // Set the state as if it was the CEikSecretEditor
       
   134                 CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
       
   135                 if (state) {
       
   136                     state->SetFlags( EAknEditorFlagNoLRNavigation |
       
   137                                         EAknEditorFlagLatinInputModesOnly |
       
   138                                         EAknEditorFlagNoT9 |
       
   139                                         EAknEditorFlagUseSCTNumericCharmap );
       
   140                     state->SetDefaultInputMode(EAknEditorSecretAlphaInputMode);
       
   141                     state->SetCurrentInputMode(EAknEditorSecretAlphaInputMode);
       
   142                     state->SetPermittedCases(EAknEditorLowerCase|EAknEditorUpperCase);
       
   143                     state->SetCurrentCase(EAknEditorLowerCase);
       
   144                     state->SetPermittedInputModes(EAknEditorSecretAlphaInputMode | EAknEditorNumericInputMode);
       
   145                     state->SetDefaultCase(EAknEditorLowerCase);
       
   146                     state->SetSpecialCharacterTableResourceId(R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_LATIN_ONLY);
       
   147                     state->SetNumericKeymap(EAknEditorPlainNumberModeKeymap);
       
   148                 }
       
   149             }
       
   150             else {
       
   151                     CreateTextFormatMask();
       
   152                     TUint currentCase ( EAknEditorLowerCase ) ;
       
   153                     TUint permittedCase ( EAknEditorAllCaseModes ) ;
       
   154                     TUint inputMode( EAknEditorNullInputMode );
       
   155                     TUint permittedInputModes( EAknEditorAllInputModes );
       
   156                     TUint flags( EAknEditorFlagDefault );
       
   157                     TUint numericKeyMap( EAknEditorStandardNumberModeKeymap );
       
   158     
       
   159                     if (GetStateFromFormatMask(currentCase, permittedCase, inputMode, permittedInputModes, flags, numericKeyMap)) {
       
   160                         UpdateFlagsState(flags);
       
   161                         UpdateInputModeState(inputMode, permittedInputModes, numericKeyMap);
       
   162                         UpdateCaseState(currentCase, permittedCase);
       
   163                     }
       
   164                     else {
       
   165                         CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
       
   166                         if (state) {
       
   167                             state->SetDefaultCase(EAknEditorLowerCase);
       
   168                             state->SetPermittedInputModes(EAknEditorAllInputModes);
       
   169                             state->SetPermittedCases(EAknEditorAllCaseModes);//allow everything
       
   170                         }
       
   171                     }
       
   172             }
       
   173         }
       
   174     }   // End of if (frame)
       
   175 }
       
   176 
       
   177 // -----------------------------------------------------------------------------
       
   178 // CancelEditingMode
       
   179 //
       
   180 //
       
   181 // -----------------------------------------------------------------------------
       
   182 void CWebFepTextEditor::CancelEditingMode()
       
   183     {
       
   184     delete m_textFormatMask;
       
   185     m_textFormatMask = NULL;
       
   186 
       
   187     delete m_inlineEditText;
       
   188     m_inlineEditText = NULL;
       
   189 
       
   190     UpdateInputModeState(EAknEditorNullInputMode, EAknEditorAllInputModes,EAknEditorStandardNumberModeKeymap);
       
   191     UpdateFlagsState(EAknEditorFlagDefault);        
       
   192     UpdateCaseState(EAknEditorLowerCase, EAknEditorAllCaseModes);
       
   193 
       
   194     CancelFepInlineEdit();
       
   195     }
       
   196 
       
   197 // -----------------------------------------------------------------------------
       
   198 // ActivatePenInputRequest
       
   199 //
       
   200 //
       
   201 // -----------------------------------------------------------------------------
       
   202 void CWebFepTextEditor::ActivatePenInputRequest()
       
   203 {
       
   204     CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
       
   205     if ( state ) {
       
   206         TRAP_IGNORE( state->ReportAknEdStateEventL(MAknEdStateObserver::EAknActivatePenInputRequest ) );
       
   207     }
       
   208 }
       
   209 
       
   210 // -----------------------------------------------------------------------------
       
   211 // DeactivatePenInputRequest
       
   212 //
       
   213 //
       
   214 // -----------------------------------------------------------------------------
       
   215 void CWebFepTextEditor::DeactivatePenInputRequest()
       
   216     {
       
   217     }
       
   218 
       
   219 // -----------------------------------------------------------------------------
       
   220 // InputCapabilities
       
   221 //
       
   222 //
       
   223 // -----------------------------------------------------------------------------
       
   224 TCoeInputCapabilities CWebFepTextEditor::InputCapabilities()
       
   225 {
   125     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   226     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   126     if (frame) {
   227     if (frame) {
   127         SelectionController* sc = frame->selectionController();
   228         SelectionController* sc = frame->selectionController();
   128         if (sc && sc->isContentEditable() && sc->isInPasswordField()) {       
   229         if (sc && sc->isContentEditable()) {
   129             
   230 
   130             // Set the state as if it was the CEikSecretEditor
   231             // Set up the input capabilities, based on the <input> box
   131             CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));  
   232             TUint caps = TCoeInputCapabilities::ENavigation;
   132             if (state) {
   233 
   133                 state->SetFlags( EAknEditorFlagNoLRNavigation |
   234             if ( sc->isInPasswordField() ) {
   134                                         EAknEditorFlagLatinInputModesOnly |
   235                 caps |= TCoeInputCapabilities::ESecretText;
   135                                         EAknEditorFlagNoT9 |
   236                 UpdateFlagsState(EAknEditorFlagNoT9);
   136                                         EAknEditorFlagUseSCTNumericCharmap );
       
   137 
       
   138                 state->SetDefaultInputMode(EAknEditorSecretAlphaInputMode);
       
   139                 state->SetCurrentInputMode(EAknEditorSecretAlphaInputMode);
       
   140                 state->SetPermittedCases(EAknEditorLowerCase|EAknEditorUpperCase);
       
   141                 state->SetCurrentCase(EAknEditorLowerCase);    
       
   142                 state->SetPermittedInputModes(EAknEditorSecretAlphaInputMode | EAknEditorNumericInputMode);
       
   143                 state->SetDefaultCase(EAknEditorLowerCase);
       
   144                 state->SetSpecialCharacterTableResourceId(R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_LATIN_ONLY);    
       
   145                 state->SetNumericKeymap(EAknEditorPlainNumberModeKeymap);
       
   146             }
       
   147             
       
   148         }
       
   149         else {       
       
   150             
       
   151             CreateTextFormatMask();
       
   152             
       
   153             TUint currentCase ( EAknEditorLowerCase ) ;
       
   154             TUint permittedCase ( EAknEditorAllCaseModes ) ;
       
   155             TUint inputMode( EAknEditorNullInputMode );
       
   156             TUint permittedInputModes( EAknEditorAllInputModes );            
       
   157             TUint flags( EAknEditorFlagDefault ); 
       
   158             TUint numericKeyMap( EAknEditorStandardNumberModeKeymap ); 
       
   159 
       
   160             if (GetStateFromFormatMask(currentCase, permittedCase, inputMode, permittedInputModes, flags, numericKeyMap)) {             
       
   161                 UpdateFlagsState(flags);
       
   162                 UpdateInputModeState(inputMode, permittedInputModes, numericKeyMap);
       
   163                 UpdateCaseState(currentCase, permittedCase);                 
       
   164             }
   237             }
   165             else {
   238             else {
   166                 CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));  
   239 
   167                 if (state) {
   240                 CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
   168                     state->SetPermittedInputModes(EAknEditorAllInputModes);
   241                 if ( state ) {
   169                     state->SetPermittedCases(EAknEditorAllCaseModes);//allow everything
       
   170                 }
       
   171             }
       
   172         }
       
   173     }   // End of if (frame)
       
   174 }
       
   175     
       
   176 // -----------------------------------------------------------------------------
       
   177 // CancelEditingMode
       
   178 // 
       
   179 // 
       
   180 // -----------------------------------------------------------------------------
       
   181 void CWebFepTextEditor::CancelEditingMode()
       
   182     {        
       
   183     delete m_textFormatMask;
       
   184     m_textFormatMask = NULL;
       
   185 
       
   186     delete m_inlineEditText;    
       
   187     m_inlineEditText = NULL;    
       
   188 
       
   189     UpdateFlagsState(EAknEditorFlagDefault);
       
   190     UpdateInputModeState(EAknEditorNullInputMode, EAknEditorAllInputModes,EAknEditorStandardNumberModeKeymap);
       
   191     UpdateCaseState(EAknEditorLowerCase, EAknEditorAllCaseModes);            
       
   192     
       
   193     CancelFepInlineEdit();
       
   194     }
       
   195     
       
   196 // -----------------------------------------------------------------------------
       
   197 // ActivatePenInputRequest
       
   198 // 
       
   199 // 
       
   200 // -----------------------------------------------------------------------------
       
   201 void CWebFepTextEditor::ActivatePenInputRequest()
       
   202 { 
       
   203     CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));                
       
   204     if ( state ) {                    
       
   205         TRAP_IGNORE( state->ReportAknEdStateEventL(MAknEdStateObserver::EAknActivatePenInputRequest ) );
       
   206     }    
       
   207 }
       
   208 
       
   209 // -----------------------------------------------------------------------------
       
   210 // DeactivatePenInputRequest
       
   211 // 
       
   212 // 
       
   213 // -----------------------------------------------------------------------------
       
   214 void CWebFepTextEditor::DeactivatePenInputRequest()
       
   215     {        
       
   216     }
       
   217 
       
   218 // -----------------------------------------------------------------------------
       
   219 // InputCapabilities
       
   220 // 
       
   221 // 
       
   222 // -----------------------------------------------------------------------------
       
   223 TCoeInputCapabilities CWebFepTextEditor::InputCapabilities()    
       
   224 {
       
   225     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
       
   226     if (frame) {
       
   227         SelectionController* sc = frame->selectionController();
       
   228         if (sc && sc->isContentEditable()) {       
       
   229 
       
   230             // Set up the input capabilities, based on the <input> box
       
   231             TUint caps = TCoeInputCapabilities::ENavigation;                
       
   232             
       
   233             if ( sc->isInPasswordField() ) {           
       
   234                 caps |= TCoeInputCapabilities::ESecretText;                            
       
   235             }
       
   236             else {
       
   237              
       
   238                 CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));                
       
   239                 if ( state ) {                    
       
   240                     if ( state->PermittedInputModes() == EAknEditorNumericInputMode ) {
   242                     if ( state->PermittedInputModes() == EAknEditorNumericInputMode ) {
   241                         caps |= (TCoeInputCapabilities::EWesternNumericIntegerPositive |
   243                         caps |= (TCoeInputCapabilities::EWesternNumericIntegerPositive |
   242                                  TCoeInputCapabilities::EWesternNumericIntegerNegative)| 
   244                                  TCoeInputCapabilities::EWesternNumericIntegerNegative)|
   243                                  TCoeInputCapabilities::EAllText;
   245                                  TCoeInputCapabilities::EAllText;
   244                     }        
   246                     }
   245                     else if (  state->PermittedInputModes() == EAknEditorTextInputMode ) {            
   247                     else if (  state->PermittedInputModes() == EAknEditorTextInputMode ) {
   246                         caps |= TCoeInputCapabilities::EWesternAlphabetic;
   248                         caps |= TCoeInputCapabilities::EWesternAlphabetic;
   247                     }
   249                     }
   248                     else if (  state->PermittedInputModes() == (EAknEditorTextInputMode | EAknEditorNumericInputMode) ) {            
   250                     else if (  state->PermittedInputModes() == (EAknEditorTextInputMode | EAknEditorNumericInputMode) ) {
   249                         caps |= (TCoeInputCapabilities::EWesternNumericIntegerPositive |
   251                         caps |= (TCoeInputCapabilities::EWesternNumericIntegerPositive |
   250                                  TCoeInputCapabilities::EWesternNumericIntegerNegative |
   252                                  TCoeInputCapabilities::EWesternNumericIntegerNegative |
   251                                  TCoeInputCapabilities::EWesternAlphabetic);
   253                                  TCoeInputCapabilities::EWesternAlphabetic);
   252                     }
   254                     }
   253                     else {
   255                     else {
   254                         caps |=  TCoeInputCapabilities::EAllText;         
   256                         caps |=  TCoeInputCapabilities::EAllText;
   255                     }            
   257                     }
   256                 }
   258                 }
   257             }
   259             }
   258 
   260 
   259             // Set up the extended input capabilities, based on dir="rtl".
   261             // Set up the extended input capabilities, based on dir="rtl".
   260             // EInputEditorAlignXXX flags are only valid for 5.0+ platform.
   262             // EInputEditorAlignXXX flags are only valid for 5.0+ platform.
   268 #endif
   270 #endif
   269             // Set up the ObjectProvider, so ExtendedInputCapablities can be called by FEP.
   271             // Set up the ObjectProvider, so ExtendedInputCapablities can be called by FEP.
   270             // MObjectProvider callback method MopSupplyObject().
   272             // MObjectProvider callback method MopSupplyObject().
   271             TCoeInputCapabilities inputCaps( caps, this, NULL, TUid::Uid(0x100056de), this );
   273             TCoeInputCapabilities inputCaps( caps, this, NULL, TUid::Uid(0x100056de), this );
   272             inputCaps.SetObjectProvider( this );
   274             inputCaps.SetObjectProvider( this );
   273             
   275 
   274             return inputCaps;
   276             return inputCaps;
   275         }
   277         }
   276     }
   278     }
   277 
   279 
   278     // Empty input capabilities
   280     // Empty input capabilities
   282     return emptyCaps;
   284     return emptyCaps;
   283 }
   285 }
   284 
   286 
   285 
   287 
   286 ////////////////////////////////////////////////////////////////////////////////
   288 ////////////////////////////////////////////////////////////////////////////////
   287 // from MCoeFepAwareTextEditor  
   289 // from MCoeFepAwareTextEditor
   288 //
   290 //
   289 
   291 
   290 // -----------------------------------------------------------------------------
   292 // -----------------------------------------------------------------------------
   291 // StartFepInlineEditL
   293 // StartFepInlineEditL
   292 // 
   294 //
   293 // 
   295 //
   294 // -----------------------------------------------------------------------------
   296 // -----------------------------------------------------------------------------
   295 void CWebFepTextEditor::StartFepInlineEditL(
   297 void CWebFepTextEditor::StartFepInlineEditL(
   296       const TDesC& aInitialInlineText,
   298       const TDesC& aInitialInlineText,
   297       TInt /*aPositionOfInsertionPointInInlineText*/,
   299       TInt /*aPositionOfInsertionPointInInlineText*/,
   298       TBool /*aCursorVisibility*/,
   300       TBool /*aCursorVisibility*/,
   299       const MFormCustomDraw*,
   301       const MFormCustomDraw*,
   300       MFepInlineTextFormatRetriever&,
   302       MFepInlineTextFormatRetriever&,
   301       MFepPointerEventHandlerDuringInlineEdit& /*aPointerEventHandlerDuringInlineEdit*/)
   303       MFepPointerEventHandlerDuringInlineEdit& /*aPointerEventHandlerDuringInlineEdit*/)
   302 {    
   304 {
   303     CCoeEnv::Static()->ForEachFepObserverCall(FepObserverHandleStartOfTransactionL);              
   305     CCoeEnv::Static()->ForEachFepObserverCall(FepObserverHandleStartOfTransactionL);
   304     ClearInlineText();        
   306     ClearInlineText();
   305     UpdateInlineText(aInitialInlineText);       
   307     UpdateInlineText(aInitialInlineText);
   306 }
   308 }
   307 
   309 
   308 // -----------------------------------------------------------------------------
   310 // -----------------------------------------------------------------------------
   309 // UpdateFepInlineTextL
   311 // UpdateFepInlineTextL
   310 // 
   312 //
   311 // 
   313 //
   312 // -----------------------------------------------------------------------------
   314 // -----------------------------------------------------------------------------
   313 void CWebFepTextEditor::UpdateFepInlineTextL( const TDesC& aNewInlineText,
   315 void CWebFepTextEditor::UpdateFepInlineTextL( const TDesC& aNewInlineText,
   314 								TInt /*aPositionOfInsertionPointInInlineText*/ )
   316 								TInt /*aPositionOfInsertionPointInInlineText*/ )
   315 {        
   317 {
   316     ClearInlineText();        
   318     ClearInlineText();
   317     UpdateInlineText(aNewInlineText);       
   319     UpdateInlineText(aNewInlineText);
   318 }
   320 }
   319 
   321 
   320 // -----------------------------------------------------------------------------
   322 // -----------------------------------------------------------------------------
   321 // SetInlineEditingCursorVisibilityL
   323 // SetInlineEditingCursorVisibilityL
   322 // 
   324 //
   323 // 
   325 //
   324 // -----------------------------------------------------------------------------
   326 // -----------------------------------------------------------------------------
   325 void CWebFepTextEditor::SetInlineEditingCursorVisibilityL(TBool /*aCursorVisibility*/)
   327 void CWebFepTextEditor::SetInlineEditingCursorVisibilityL(TBool /*aCursorVisibility*/)
   326 {
   328 {
   327 }
   329 }
   328 
   330 
   329 // -----------------------------------------------------------------------------
   331 // -----------------------------------------------------------------------------
   330 // CancelFepInlineEdit
   332 // CancelFepInlineEdit
   331 // 
   333 //
   332 // 
   334 //
   333 // -----------------------------------------------------------------------------
   335 // -----------------------------------------------------------------------------
   334 void CWebFepTextEditor::CancelFepInlineEdit()
   336 void CWebFepTextEditor::CancelFepInlineEdit()
   335 {
   337 {
   336 }
   338 }
   337 
   339 
   338 // -----------------------------------------------------------------------------
   340 // -----------------------------------------------------------------------------
   339 // DocumentLengthForFep
   341 // DocumentLengthForFep
   340 // 
   342 //
   341 // 
   343 //
   342 // -----------------------------------------------------------------------------
   344 // -----------------------------------------------------------------------------
   343 TInt CWebFepTextEditor::DocumentLengthForFep() const
   345 TInt CWebFepTextEditor::DocumentLengthForFep() const
   344 {
   346 {
   345     TInt length = 0;
   347     TInt length = 0;
   346     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   348     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   356             HTMLTextAreaElement* ie = static_cast<HTMLTextAreaElement*>(frame->document()->focusedNode());
   358             HTMLTextAreaElement* ie = static_cast<HTMLTextAreaElement*>(frame->document()->focusedNode());
   357             length = ie->value().length();
   359             length = ie->value().length();
   358         }
   360         }
   359     }
   361     }
   360 
   362 
   361     return length;    
   363     return length;
   362 }
   364 }
   363 
   365 
   364 // -----------------------------------------------------------------------------
   366 // -----------------------------------------------------------------------------
   365 // DocumentMaximumLengthForFep
   367 // DocumentMaximumLengthForFep
   366 // 
   368 //
   367 // 
   369 //
   368 // -----------------------------------------------------------------------------
   370 // -----------------------------------------------------------------------------
   369 TInt CWebFepTextEditor::DocumentMaximumLengthForFep() const
   371 TInt CWebFepTextEditor::DocumentMaximumLengthForFep() const
   370 {       
   372 {
   371     TInt length = KMaxTInt;       
   373     TInt length = KMaxTInt;
   372 
   374 
   373     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   375     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   374     if (frame &&
   376     if (frame &&
   375         frame->document() &&
   377         frame->document() &&
   376         frame->document()->focusedNode() &&
   378         frame->document()->focusedNode() &&
   377         frame->document()->focusedNode()->hasTagName(HTMLNames::inputTag) ) {                   
   379         frame->document()->focusedNode()->hasTagName(HTMLNames::inputTag) ) {
   378         length = static_cast<HTMLInputElement*>(frame->document()->focusedNode())->maxLength();
   380         length = static_cast<HTMLInputElement*>(frame->document()->focusedNode())->maxLength();
   379     }
   381     }
   380 
   382 
   381 	// Override the length if a text format mask is set
   383 	// Override the length if a text format mask is set
   382 	if ( m_textFormatMask && m_textFormatMask->getMultitude() > 0 )
   384 	if ( m_textFormatMask && m_textFormatMask->getMultitude() > 0 )
   386     return length;
   388     return length;
   387 }
   389 }
   388 
   390 
   389 // -----------------------------------------------------------------------------
   391 // -----------------------------------------------------------------------------
   390 // SetCursorSelectionForFepL
   392 // SetCursorSelectionForFepL
   391 // 
   393 //
   392 // 
   394 //
   393 // -----------------------------------------------------------------------------
   395 // -----------------------------------------------------------------------------
   394 void CWebFepTextEditor::SetCursorSelectionForFepL(const TCursorSelection& aCursorSelection)
   396 void CWebFepTextEditor::SetCursorSelectionForFepL(const TCursorSelection& aCursorSelection)
   395 {    
   397 {
   396     // The other part of the rather hackish way to check if we are at the end of the editing field
   398     // The other part of the rather hackish way to check if we are at the end of the editing field
   397     // see WebEditorClient::handleKeypress
   399     // see WebEditorClient::handleKeypress
   398     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   400     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   399     if ( frame ) {           
   401     if ( frame ) {
   400         SelectionController* sc = frame->selectionController();
   402         SelectionController* sc = frame->selectionController();
   401         Node* editNode = sc->base().node();
   403         Node* editNode = sc->base().node();
   402         if ( IsTextAreaFocused() ) {
   404         if ( IsTextAreaFocused() ) {
       
   405             while(editNode && !editNode->isTextNode()){
       
   406                 editNode = editNode->previousSibling();
       
   407             }
   403 			TInt position( aCursorSelection.iAnchorPos );
   408 			TInt position( aCursorSelection.iAnchorPos );
   404 			TInt offset( 0 );
   409 			TInt offset( 0 );
       
   410             TInt extentoffset   = 0;
   405 			if ( editNode ) {
   411 			if ( editNode ) {
   406 				editNode = findTextNodeForCurPos( editNode, position );
   412 				editNode = findTextNodeForCurPos( editNode, position );
   407 				if ( aCursorSelection.iAnchorPos > position ) {
   413 		    if(aCursorSelection.iAnchorPos >= position) {
   408 					offset = aCursorSelection.iAnchorPos - position;
   414                 offset = aCursorSelection.iAnchorPos - position;
   409 				}
   415                 extentoffset = aCursorSelection.iCursorPos - position;
   410 				Position base( editNode, offset );
   416             }
   411 				Position extent( editNode, offset );
   417             extentoffset = extentoffset < 0 ? 0 : extentoffset; 
   412 				sc->moveTo( base, extent, DOWNSTREAM );
   418             Position base( editNode, offset );
       
   419 			Position extent(editNode,extentoffset);
       
   420 			sc->moveTo( base, extent, DOWNSTREAM );
   413 			}
   421 			}
   414 		}
   422 		}
   415 		else if ( editNode && editNode->isTextNode() ) { 
   423 		else if ( editNode && editNode->isTextNode() ) {
   416 			Position base( sc->baseNode(), aCursorSelection.iAnchorPos );
   424 			Position base( sc->baseNode(), aCursorSelection.iAnchorPos );
   417 			Position extent( sc->baseNode(), aCursorSelection.iCursorPos );
   425 			Position extent( sc->baseNode(), aCursorSelection.iCursorPos );
   418 			sc->moveTo( base, extent, DOWNSTREAM );   
   426 			sc->moveTo( base, extent, DOWNSTREAM );
   419 		}
   427 		}
   420 		HandleUpdateCursor();
   428 		HandleUpdateCursor();
   421     }
   429     }
   422 }
   430 }
   423 
   431 
   424 // -----------------------------------------------------------------------------
   432 // -----------------------------------------------------------------------------
   425 // GetCursorSelectionForFep
   433 // GetCursorSelectionForFep
   426 // 
   434 //
   427 // 
   435 //
   428 // -----------------------------------------------------------------------------
   436 // -----------------------------------------------------------------------------
   429 void CWebFepTextEditor::GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const
   437 void CWebFepTextEditor::GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const
   430 {
   438 {
   431     aCursorSelection.SetSelection(0,0);
   439     aCursorSelection.SetSelection(0,0);
   432     
   440 
   433     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   441     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   434     if ( frame ) {           
   442     if ( frame ) {
   435         SelectionController* sc = frame->selectionController();
   443         SelectionController* sc = frame->selectionController();
   436         Node* editNode = sc->base().node();
   444         Node* editNode = sc->base().node();
   437 		if ( frame && frame->document()->focusedNode() ) {
   445 		if ( frame && frame->document()->focusedNode() ) {
   438 			if ( IsTextAreaFocused() ) {
   446 			if ( IsTextAreaFocused() ) {
       
   447                 HTMLTextAreaElement* ie = static_cast<HTMLTextAreaElement*>(frame->document()->focusedNode());                                                 
       
   448                 while(editNode && !editNode->isTextNode())
       
   449                     editNode = editNode->previousSibling();
   439 				TInt len( 0 );
   450 				TInt len( 0 );
   440 				if ( editNode ) {
   451 				if ( editNode ) {
   441 					findPrevSiblingTextLen( editNode, len );  
   452 					findPrevSiblingTextLen( editNode, len );
   442 				}
   453 				}
   443 				aCursorSelection.SetSelection( sc->baseOffset() + len,
   454 				aCursorSelection.SetSelection( ((sc->baseOffset()+len > ie->value().length()) ? 0 : sc->baseOffset()+len),
   444 											   sc->extentOffset() + len );
   455                                                   ((sc->extentOffset()+len > ie->value().length()) ? 0 : sc->baseOffset()+len));
   445 			}
   456 			}
   446 			else {
   457 			else {
   447 				aCursorSelection.SetSelection(sc->baseOffset(), sc->extentOffset());       
   458 				aCursorSelection.SetSelection(sc->baseOffset(), sc->extentOffset());
   448 			}
   459 			}
   449 		}
   460 		}
   450 	}
   461 	}
   451 }
   462 }
   452 
   463 
   453 // -----------------------------------------------------------------------------
   464 // -----------------------------------------------------------------------------
   454 // GetEditorContentForFep
   465 // GetEditorContentForFep
   455 // 
   466 //
   456 // 
   467 //
   457 // -----------------------------------------------------------------------------
   468 // -----------------------------------------------------------------------------
   458 void CWebFepTextEditor::GetEditorContentForFep( TDes& aEditorContent,
   469 void CWebFepTextEditor::GetEditorContentForFep( TDes& aEditorContent,
   459 												TInt aDocumentPosition,
   470 												TInt aDocumentPosition,
   460 												TInt aLengthToRetrieve ) const
   471 												TInt aLengthToRetrieve ) const
   461 {    
   472 {
   462     aEditorContent = KNullDesC;   	   // KNullDesC has length 0
   473     aEditorContent = KNullDesC;   	   // KNullDesC has length 0
   463 
   474 
   464     if (aLengthToRetrieve == 0) {
   475     if (aLengthToRetrieve == 0) {
   465         return;
   476         return;
   466     }
   477     }
   467         
   478 
   468     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   479     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   469     if (frame &&
   480     if (frame &&
   470         frame->document() &&
   481         frame->document() &&
   471         frame->document()->focusedNode()) {
   482         frame->document()->focusedNode()) {
   472 
   483 
   477         else if (frame->document()->focusedNode()->hasTagName(HTMLNames::textareaTag)) {
   488         else if (frame->document()->focusedNode()->hasTagName(HTMLNames::textareaTag)) {
   478             HTMLTextAreaElement* ie = static_cast<HTMLTextAreaElement*>(frame->document()->focusedNode());
   489             HTMLTextAreaElement* ie = static_cast<HTMLTextAreaElement*>(frame->document()->focusedNode());
   479             // Convert the newline to paragraph separator, because the FEP
   490             // Convert the newline to paragraph separator, because the FEP
   480             // input editors (vkb, etc) ignore newline
   491             // input editors (vkb, etc) ignore newline
   481             String str(ie->value().substring(aDocumentPosition, aLengthToRetrieve));
   492             String str(ie->value().substring(aDocumentPosition, aLengthToRetrieve));
   482             str.replace(EKeyLineFeed, CEditableText::EParagraphDelimiter);  
   493             str.replace(EKeyLineFeed, CEditableText::EParagraphDelimiter);
   483             aEditorContent = str;        
   494             aEditorContent = str;
   484         }
   495         }
   485     }
   496     }
   486 }
   497 }
   487 
   498 
   488 // -----------------------------------------------------------------------------
   499 // -----------------------------------------------------------------------------
   489 // GetFormatForFep
   500 // GetFormatForFep
   490 // 
   501 //
   491 // 
   502 //
   492 // -----------------------------------------------------------------------------
   503 // -----------------------------------------------------------------------------
   493 void CWebFepTextEditor::GetFormatForFep(TCharFormat& /*aFormat*/,TInt /*aDocumentPosition*/) const
   504 void CWebFepTextEditor::GetFormatForFep(TCharFormat& /*aFormat*/,TInt /*aDocumentPosition*/) const
   494 {         
   505 {
   495 }
   506 }
   496 
   507 
   497 // -----------------------------------------------------------------------------
   508 // -----------------------------------------------------------------------------
   498 // GetScreenCoordinatesForFepL
   509 // GetScreenCoordinatesForFepL
   499 // 
   510 //
   500 // 
   511 //
   501 // -----------------------------------------------------------------------------
   512 // -----------------------------------------------------------------------------
   502 void CWebFepTextEditor::GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLine,
   513 void CWebFepTextEditor::GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLine,
   503                                                     TInt& aHeight,
   514                                                     TInt& aHeight,
   504                                                     TInt& aAscent,
   515                                                     TInt& aAscent,
   505                                                     TInt aDocumentPosition) const
   516                                                     TInt aDocumentPosition) const
   506 {
   517 {
   507 Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   518 Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   508 if (frame &&
   519 if (frame &&
   509     frame->document() &&
   520     frame->document() &&
   510     frame->document()->focusedNode()){
   521     frame->document()->focusedNode()){
   511     if ( frame->document()->focusedNode()->hasTagName(HTMLNames::inputTag) || 
   522     if ( frame->document()->focusedNode()->hasTagName(HTMLNames::inputTag) ||
   512 		 frame->document()->focusedNode()->hasTagName(HTMLNames::textareaTag)){
   523 		 frame->document()->focusedNode()->hasTagName(HTMLNames::textareaTag)){
   513 		HTMLGenericFormElement*  ie = static_cast<HTMLGenericFormElement*>(frame->document()->focusedNode());	
   524 		HTMLGenericFormElement*  ie = static_cast<HTMLGenericFormElement*>(frame->document()->focusedNode());
   514 		SelectionController* sc = frame->selectionController();
   525 		SelectionController* sc = frame->selectionController();
   515 		int xPos(0);
   526 		int xPos(0);
   516 		int yPos(0);
   527 		int yPos(0);
   517 		if ( sc ){
   528 		if ( sc ){
   518 			IntRect rect = sc->caretRect(); 
   529 			IntRect rect = sc->caretRect();
   519 			xPos = rect.x();     
   530 			Node* editNode = sc->focusNode();
   520 			yPos = rect.y();
   531 			TPoint viewPoint = kit(frame)->frameView()->frameCoordsInViewCoords(editNode->getRect().Rect().iBr);
   521 			yPos +=  m_webView->brCtl()->PositionRelativeToScreen().iY;
   532 			xPos = viewPoint.iX;
   522 			Node* editNode = sc->focusNode();	
   533 			yPos = viewPoint.iY;
   523 			String str;
   534 			String str;
   524 			if ( editNode &&
   535 			if ( editNode &&
   525 				 editNode->isTextNode() ) {
   536 				 editNode->isTextNode() ) {
   526 				WebCore::Text* aText = (WebCore::Text*)editNode;
   537 				WebCore::Text* aText = (WebCore::Text*)editNode;
   527 				str = aText->data();
   538 				str = aText->data();
   529 				TInt position = aDocumentPosition - ( str.reverseFind(KBlankDesC(), aDocumentPosition )+1);
   540 				TInt position = aDocumentPosition - ( str.reverseFind(KBlankDesC(), aDocumentPosition )+1);
   530 				String word(str);
   541 				String word(str);
   531 				if( position > 0 ){
   542 				if( position > 0 ){
   532 					word = str.left( position );
   543 					word = str.left( position );
   533 					}
   544 					}
   534 				RenderStyle* s = frame->document()->focusedNode()->renderStyle(); 	
   545 				RenderStyle* s = frame->document()->focusedNode()->renderStyle();
   535 				PlatformFontCache* cache = StaticObjectsContainer::instance()->fontCache();
   546 				PlatformFontCache* cache = StaticObjectsContainer::instance()->fontCache();
   536 				CFont* sFont =  cache->zoomedFont( s->fontDescription(), cache->fontZoomFactor());
   547 				CFont* sFont =  cache->zoomedFont( s->fontDescription(), cache->fontZoomFactor());
   537 				TInt sizePix =	sFont->MeasureText( word.des() );
   548 				TInt sizePix =	sFont->MeasureText( word.des() );
   538 				xPos -= sizePix;	
   549 				xPos -= sizePix;
   539 				}		
   550 				}
   540 			}
   551 			}
   541 		aLeftSideOfBaseLine.SetXY( xPos,yPos );              
   552 		aLeftSideOfBaseLine.SetXY( xPos,yPos );
   542 		}
   553 		}
   543 	}
   554 	}
   544 	aAscent = 0;
   555 	aAscent = 0;
   545 	aHeight = 0;
   556 	aHeight = 0;
   546 }
   557 }
   547 
   558 
   548 // -----------------------------------------------------------------------------
   559 // -----------------------------------------------------------------------------
   549 // DoCommitFepInlineEditL
   560 // DoCommitFepInlineEditL
   550 // 
   561 //
   551 // 
   562 //
   552 // -----------------------------------------------------------------------------
   563 // -----------------------------------------------------------------------------
   553 void CWebFepTextEditor::DoCommitFepInlineEditL()
   564 void CWebFepTextEditor::DoCommitFepInlineEditL()
   554 {                    
   565 {
   555     ClearInlineText();     
   566     ClearInlineText();
   556 
   567 
   557     if (m_inlineEditText && DocumentLengthForFep() < DocumentMaximumLengthForFep()) {
   568     if (m_inlineEditText && DocumentLengthForFep() < DocumentMaximumLengthForFep()) {
   558         Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   569         Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   559         if (frame){
   570         if (frame){
   560             frame->editor()->insertTextWithoutSendingTextEvent(String(*m_inlineEditText), false);
   571             if(IsWapMaskedModeInput(frame)) {
   561         }
   572                 HandleMaskedInsertText(frame, (String(*m_inlineEditText)));
   562     }
   573             }
   563     
   574             else {
       
   575                 frame->editor()->insertTextWithoutSendingTextEvent(String(*m_inlineEditText), false);  
       
   576             }
       
   577         }
       
   578     }
   564     //delete the m_inlineEditText since text is commited
   579     //delete the m_inlineEditText since text is commited
   565     delete m_inlineEditText;    
   580     delete m_inlineEditText;
   566     m_inlineEditText = NULL;    
   581     m_inlineEditText = NULL;
   567 
   582 
   568     HandleUpdateCursor();
   583     HandleUpdateCursor();
   569     UpdateEditingMode();
   584     UpdateEditingMode();
   570 }
   585 }
   571 
   586 
   572 // -----------------------------------------------------------------------------
   587 // -----------------------------------------------------------------------------
   573 // Extension1
   588 // Extension1
   574 // 
   589 //
   575 // 
   590 //
   576 // -----------------------------------------------------------------------------
   591 // -----------------------------------------------------------------------------
   577 MCoeFepAwareTextEditor_Extension1* CWebFepTextEditor::Extension1(TBool& aSetToTrue)
   592 MCoeFepAwareTextEditor_Extension1* CWebFepTextEditor::Extension1(TBool& aSetToTrue)
   578 {
   593 {
   579     aSetToTrue=ETrue;
   594     aSetToTrue=ETrue;
   580     return STATIC_CAST(MCoeFepAwareTextEditor_Extension1*, this);
   595     return STATIC_CAST(MCoeFepAwareTextEditor_Extension1*, this);
   581 }
   596 }
   582 
   597 
   583 // -----------------------------------------------------------------------------
   598 // -----------------------------------------------------------------------------
   584 // MCoeFepAwareTextEditor_Reserved_2
   599 // MCoeFepAwareTextEditor_Reserved_2
   585 // 
   600 //
   586 // 
   601 //
   587 // -----------------------------------------------------------------------------
   602 // -----------------------------------------------------------------------------
   588 void CWebFepTextEditor::MCoeFepAwareTextEditor_Reserved_2()
   603 void CWebFepTextEditor::MCoeFepAwareTextEditor_Reserved_2()
   589 {
   604 {
   590 }
   605 }
   591            
   606 
   592 ////////////////////////////////////////////////////////////////////////////////
   607 ////////////////////////////////////////////////////////////////////////////////
   593 // from MCoeFepAwareTextEditor_Extension1
   608 // from MCoeFepAwareTextEditor_Extension1
   594 
   609 
   595 // -----------------------------------------------------------------------------
   610 // -----------------------------------------------------------------------------
   596 // SetStateTransferingOwnershipL
   611 // SetStateTransferingOwnershipL
   597 // 
   612 //
   598 // 
   613 //
   599 // -----------------------------------------------------------------------------
   614 // -----------------------------------------------------------------------------
   600 void CWebFepTextEditor::SetStateTransferingOwnershipL(CState* aState, TUid /*aTypeSafetyUid*/)
   615 void CWebFepTextEditor::SetStateTransferingOwnershipL(CState* aState, TUid /*aTypeSafetyUid*/)
   601 {
   616 {
   602     delete m_state;
   617     delete m_state;
   603     m_state = aState;    
   618     m_state = aState;
   604 }
   619 }
   605 
   620 
   606 // -----------------------------------------------------------------------------
   621 // -----------------------------------------------------------------------------
   607 // State
   622 // State
   608 // 
   623 //
   609 // 
   624 //
   610 // -----------------------------------------------------------------------------
   625 // -----------------------------------------------------------------------------
   611 MCoeFepAwareTextEditor_Extension1::CState* CWebFepTextEditor::State(TUid /*aTypeSafetyUid*/)
   626 MCoeFepAwareTextEditor_Extension1::CState* CWebFepTextEditor::State(TUid /*aTypeSafetyUid*/)
   612 {
   627 {
   613     if (!m_state) {
   628     if (!m_state) {
   614         CAknEdwinState* state = new CAknEdwinState();
   629         CAknEdwinState* state = new CAknEdwinState();
   618     return m_state;
   633     return m_state;
   619 }
   634 }
   620 
   635 
   621 // -----------------------------------------------------------------------------
   636 // -----------------------------------------------------------------------------
   622 // StartFepInlineEditL
   637 // StartFepInlineEditL
   623 // 
   638 //
   624 // 
   639 //
   625 // -----------------------------------------------------------------------------
   640 // -----------------------------------------------------------------------------
   626 void CWebFepTextEditor::StartFepInlineEditL(
   641 void CWebFepTextEditor::StartFepInlineEditL(
   627         TBool& aSetToTrue, 
   642         TBool& aSetToTrue,
   628         const TCursorSelection& aCursorSelection, 
   643         const TCursorSelection& aCursorSelection,
   629         const TDesC& aInitialInlineText, 
   644         const TDesC& aInitialInlineText,
   630         TInt aPositionOfInsertionPointInInlineText, 
   645         TInt aPositionOfInsertionPointInInlineText,
   631         TBool aCursorVisibility, 
   646         TBool aCursorVisibility,
   632         const MFormCustomDraw* aCustomDraw, 
   647         const MFormCustomDraw* aCustomDraw,
   633         MFepInlineTextFormatRetriever& aInlineTextFormatRetriever, 
   648         MFepInlineTextFormatRetriever& aInlineTextFormatRetriever,
   634         MFepPointerEventHandlerDuringInlineEdit& aPointerEventHandlerDuringInlineEdit)
   649         MFepPointerEventHandlerDuringInlineEdit& aPointerEventHandlerDuringInlineEdit)
   635 {
   650 {
   636     aSetToTrue=ETrue;
   651     aSetToTrue=ETrue;
   637     SetCursorSelectionForFepL(aCursorSelection);
   652     SetCursorSelectionForFepL(aCursorSelection);
   638     StartFepInlineEditL(aInitialInlineText, aPositionOfInsertionPointInInlineText, aCursorVisibility, aCustomDraw, aInlineTextFormatRetriever, aPointerEventHandlerDuringInlineEdit);
   653     StartFepInlineEditL(aInitialInlineText, aPositionOfInsertionPointInInlineText, aCursorVisibility, aCustomDraw, aInlineTextFormatRetriever, aPointerEventHandlerDuringInlineEdit);
   639 }
   654 }
   640 
   655 
   641 // -----------------------------------------------------------------------------
   656 // -----------------------------------------------------------------------------
   642 // SetCursorType
   657 // SetCursorType
   643 // 
   658 //
   644 // 
   659 //
   645 // -----------------------------------------------------------------------------
   660 // -----------------------------------------------------------------------------
   646 void CWebFepTextEditor::SetCursorType(TBool& /*aSetToTrue*/, const TTextCursor& /*aTextCursor*/)
   661 void CWebFepTextEditor::SetCursorType(TBool& /*aSetToTrue*/, const TTextCursor& /*aTextCursor*/)
   647 {
   662 {
   648 }
   663 }
   649 
   664 
   650 ////////////////////////////////////////////////////////////////////////////////
   665 ////////////////////////////////////////////////////////////////////////////////
   651 // from TCoeInputCapabilities::MCoeFepSpecificExtensions
   666 // from TCoeInputCapabilities::MCoeFepSpecificExtensions
   652 
   667 
   653 // -----------------------------------------------------------------------------
   668 // -----------------------------------------------------------------------------
   654 // IsValidCharacter
   669 // IsValidCharacter
   655 // 
   670 //
   656 // 
   671 //
   657 // -----------------------------------------------------------------------------
   672 // -----------------------------------------------------------------------------
   658 TBool CWebFepTextEditor::IsValidCharacter(TInt aChar)
   673 TBool CWebFepTextEditor::IsValidCharacter(TInt aChar)
   659 {
   674 {
   660      return ETrue;
   675      return ETrue;
   661 }
   676 }
   662  
   677 
   663 ////////////////////////////////////////////////////////////////////////////////
   678 ////////////////////////////////////////////////////////////////////////////////
   664 // from MObjectProvider
   679 // from MObjectProvider
   665 
   680 
   666 // -----------------------------------------------------------------------------
   681 // -----------------------------------------------------------------------------
   667 // MopSupplyObject
   682 // MopSupplyObject
   675         return aId.MakePtr( m_ExtendedInputCapabilities );
   690         return aId.MakePtr( m_ExtendedInputCapabilities );
   676     }
   691     }
   677 
   692 
   678     return aId.Null();
   693     return aId.Null();
   679 }
   694 }
   680  
   695 
   681 
   696 
   682 ////////////////////////////////////////////////////////////////////////////////
   697 ////////////////////////////////////////////////////////////////////////////////
   683 // New public methods
   698 // New public methods
   684 //
   699 //
   685 
   700 
   686 // -----------------------------------------------------------------------------
   701 // -----------------------------------------------------------------------------
   687 // UpdateFlagsState
   702 // UpdateFlagsState
   688 // 
   703 //
   689 // 
   704 //
   690 // -----------------------------------------------------------------------------
   705 // -----------------------------------------------------------------------------
   691 void CWebFepTextEditor::UpdateFlagsState(TUint flags)
   706 void CWebFepTextEditor::UpdateFlagsState(TUint flags)
   692 {    
   707 {
   693     CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));        
   708     CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
   694     
   709 
   695     if ( IsTextAreaFocused() ) {
   710     if ( IsTextAreaFocused() ) {
   696     	// If in a TextArea, allow "enter" key presses to be newline/paragraph
   711     	// If in a TextArea, allow "enter" key presses to be newline/paragraph
   697     	state->SetFlags( flags | EAknEditorFlagUseSCTNumericCharmap 
   712     	state->SetFlags( flags | EAknEditorFlagUseSCTNumericCharmap
   698     					 | EAknEditorFlagAllowEntersWithScrollDown );
   713     					 | EAknEditorFlagAllowEntersWithScrollDown );
   699     	}
   714     	}
   700     else {
   715     else {
   701         state->SetFlags(flags | EAknEditorFlagUseSCTNumericCharmap);
   716         state->SetFlags(flags | EAknEditorFlagUseSCTNumericCharmap);
   702     	}
   717     	}
   703     
   718 
   704     state->ReportAknEdStateEventL(MAknEdStateObserver::EAknEdwinStateFlagsUpdate);
   719     state->ReportAknEdStateEventL(MAknEdStateObserver::EAknEdwinStateFlagsUpdate);
   705 }
   720 }
   706 
   721 
   707 // -----------------------------------------------------------------------------
   722 // -----------------------------------------------------------------------------
   708 // UpdateInputModeState
   723 // UpdateInputModeState
   709 // 
   724 //
   710 // 
   725 //
   711 // -----------------------------------------------------------------------------
   726 // -----------------------------------------------------------------------------
   712 void CWebFepTextEditor::UpdateInputModeState(TUint inputMode, TUint permittedInputModes, TUint numericKeyMap)
   727 void CWebFepTextEditor::UpdateInputModeState(TUint inputMode, TUint permittedInputModes, TUint numericKeyMap)
   713 {  
   728 {
   714 
   729 
   715     CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));        
   730     CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
   716     
   731 
   717     if (permittedInputModes != EAknEditorNumericInputMode) {
   732     if (permittedInputModes != EAknEditorNumericInputMode) {
   718         EVariantFlag variant = AknLayoutUtils::Variant();
   733         EVariantFlag variant = AknLayoutUtils::Variant();
   719         if (variant == EApacVariant) {
   734         if (variant == EApacVariant) {
   720               permittedInputModes |= EAknEditorTextInputMode |
   735               permittedInputModes |= EAknEditorTextInputMode |
   721               EAknEditorHalfWidthTextInputMode | EAknEditorFullWidthTextInputMode |
   736               EAknEditorHalfWidthTextInputMode | EAknEditorFullWidthTextInputMode |
   722               EAknEditorKatakanaInputMode | EAknEditorFullWidthKatakanaInputMode |
   737               EAknEditorKatakanaInputMode | EAknEditorFullWidthKatakanaInputMode |
   723               EAknEditorHiraganaKanjiInputMode | EAknEditorHiraganaInputMode;
   738               EAknEditorHiraganaKanjiInputMode | EAknEditorHiraganaInputMode;
   724             
   739 
   725         }
   740         }
   726     }
   741     }
   727     
   742 
   728     state->SetDefaultInputMode(inputMode);             
   743     state->SetDefaultInputMode(inputMode);
   729     state->SetCurrentInputMode(inputMode);    
   744     state->SetCurrentInputMode(inputMode);
   730     state->SetPermittedInputModes(permittedInputModes);                 
   745     state->SetPermittedInputModes(permittedInputModes);
   731     state->SetNumericKeymap(static_cast<TAknEditorNumericKeymap>(numericKeyMap));
   746     state->SetNumericKeymap(static_cast<TAknEditorNumericKeymap>(numericKeyMap));
   732 
   747     state->ReportAknEdStateEventL(MAknEdStateObserver::EAknEdwinStateInputModeUpdate);
   733     state->ReportAknEdStateEventL(MAknEdStateObserver::EAknEdwinStateInputModeUpdate);        
       
   734 
       
   735 }
   748 }
   736 
   749 
   737 // -----------------------------------------------------------------------------
   750 // -----------------------------------------------------------------------------
   738 // UpdateCaseState
   751 // UpdateCaseState
   739 // 
   752 //
   740 // 
   753 //
   741 // -----------------------------------------------------------------------------
   754 // -----------------------------------------------------------------------------
   742 void CWebFepTextEditor::UpdateCaseState(TUint currentCase, TUint permittedCase)
   755 void CWebFepTextEditor::UpdateCaseState(TUint currentCase, TUint permittedCase)
   743 {    
   756 {
   744     CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));        
   757     CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
   745 
   758 
   746     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   759     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   747     if (frame){
   760     if (frame){
   748 
   761 
   749         if (frame->editor()->canEditRichly()) {
   762         if (frame->editor()->canEditRichly()) {
   750             state->SetDefaultCase(EAknEditorTextCase);                    
   763             state->SetDefaultCase(EAknEditorTextCase);
   751         }
   764         }
   752         else {
   765         else {
   753             state->SetDefaultCase(currentCase);
   766             state->SetDefaultCase(currentCase);
   754             state->SetCurrentCase(currentCase);
   767             state->SetCurrentCase(currentCase);
   755             state->SetPermittedCases(permittedCase);        
   768             state->SetPermittedCases(permittedCase);
   756         }    
   769         }
   757     }
   770     }
   758     
   771 
   759     state->ReportAknEdStateEventL(MAknEdStateObserver::EAknEdwinStateCaseModeUpdate);        
   772     state->ReportAknEdStateEventL(MAknEdStateObserver::EAknEdwinStateCaseModeUpdate);
   760 }
   773 }
   761 
   774 
   762 // -----------------------------------------------------------------------------
   775 // -----------------------------------------------------------------------------
   763 // HandleUpdateCursor
   776 // HandleUpdateCursor
   764 //
   777 //
   765 // 
   778 //
   766 // -----------------------------------------------------------------------------
   779 // -----------------------------------------------------------------------------
   767 void CWebFepTextEditor::HandleUpdateCursor()
   780 void CWebFepTextEditor::HandleUpdateCursor()
   768 {
   781 {
   769     // ReportAknEdStateEventL, for events see aknedstsobs.h
   782     // ReportAknEdStateEventL, for events see aknedstsobs.h
   770     // MAknEdStateObserver::EAknCursorPositionChanged 
   783     // MAknEdStateObserver::EAknCursorPositionChanged
   771     
   784 
   772     CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));                
   785     CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
   773     if ( state ) {                    
   786     if ( state ) {
   774         TRAP_IGNORE( state->ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged ) );
   787         TRAP_IGNORE( state->ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged ) );
   775     }
   788     }
   776 }
   789 }
   777 
   790 
   778 // -----------------------------------------------------------------------------
   791 // -----------------------------------------------------------------------------
   779 // GetStateFromFormatMask
   792 // GetStateFromFormatMask
   780 // 
   793 //
   781 // 
   794 //
   782 // -----------------------------------------------------------------------------
   795 // -----------------------------------------------------------------------------
   783 bool CWebFepTextEditor::GetStateFromFormatMask(TUint& currentCase,
   796 bool CWebFepTextEditor::GetStateFromFormatMask(TUint& currentCase,
   784                                                 TUint& permittedCase,
   797                                                 TUint& permittedCase,
   785                                                 TUint& inputMode,
   798                                                 TUint& inputMode,
   786                                                 TUint& permittedInputModes,
   799                                                 TUint& permittedInputModes,
   787                                                 TUint& flags,
   800                                                 TUint& flags,
   788                                                 TUint& numericKeyMap)
   801                                                 TUint& numericKeyMap)
   789 {
   802 {
   790     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();    
   803     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   791     if (frame && m_textFormatMask) {
   804     if (frame && m_textFormatMask) {
   792     
   805 
   793         TInt cursorpos = DocumentLengthForFep();        
   806         TInt cursorpos = DocumentLengthForFep();
   794         TInputFormatMaskType fm = m_textFormatMask->getInputFormatMaskType(frame, cursorpos);        
   807         TInputFormatMaskType fm = m_textFormatMask->getInputFormatMaskType(frame, cursorpos);
   795 
   808         if (!cursorpos) {
       
   809             while(fm == EStatic) {
       
   810                 fm = m_textFormatMask->getInputFormatMaskType(frame, ++cursorpos); 
       
   811             }
       
   812         }
       
   813         setSCTAvailability(true);
   796         switch( fm ) {
   814         switch( fm ) {
   797             case ELeUpSymPuc:       //A any upper case letter or symbolic
   815             case ELeUpSymPuc:       //A any upper case letter or symbolic
   798                 flags = EAknEditorFlagNoT9 | EAknEditorFlagFixedCase;
   816                 flags = EAknEditorFlagNoT9 | EAknEditorFlagFixedCase;
   799                 currentCase = EAknEditorUpperCase; 
   817                 currentCase = EAknEditorUpperCase;
   800                 permittedCase = EAknEditorUpperCase;                                    
   818                 permittedCase = EAknEditorUpperCase;
   801                 inputMode = EAknEditorTextInputMode;
   819                 inputMode = EAknEditorTextInputMode;
   802                 permittedInputModes = EAknEditorTextInputMode;
   820                 permittedInputModes = EAknEditorTextInputMode;
   803             break;
   821             break;
   804             case ELeLoSymPuc:       //a any lower case letter or symbolic
   822             case ELeLoSymPuc:       //a any lower case letter or symbolic
   805                 flags = EAknEditorFlagNoT9 | EAknEditorFlagFixedCase;
   823                 flags = EAknEditorFlagNoT9 | EAknEditorFlagFixedCase;
   806                 currentCase = EAknEditorLowerCase;
   824                 currentCase = EAknEditorLowerCase;
   807                 permittedCase= EAknEditorLowerCase;                        
   825                 permittedCase= EAknEditorLowerCase;
   808                 inputMode = EAknEditorTextInputMode;
   826                 inputMode = EAknEditorTextInputMode;
   809                 permittedInputModes= EAknEditorTextInputMode;
   827                 permittedInputModes= EAknEditorTextInputMode;
   810             break;
   828             break;
   811             case ELeUpNumSymPuc:    //X any upper case, number or symbolic
   829             case ELeUpNumSymPuc:    //X any upper case, number or symbolic
   812                 flags = EAknEditorFlagNoT9 | EAknEditorFlagFixedCase;
   830                 flags = EAknEditorFlagNoT9 | EAknEditorFlagFixedCase;
   813                 currentCase = EAknEditorUpperCase;
   831                 currentCase = EAknEditorUpperCase;
   814                 permittedCase= EAknEditorUpperCase;                        
   832                 permittedCase= EAknEditorUpperCase;
   815                 inputMode = EAknEditorTextInputMode;
   833                 inputMode = EAknEditorTextInputMode;
   816                 permittedInputModes= EAknEditorTextInputMode;
   834                 permittedInputModes= EAknEditorTextInputMode;
   817             break;
   835             break;
   818             case ELeLoNumSymPuc:    //x any lower case, number or symbolic
   836             case ELeLoNumSymPuc:    //x any lower case, number or symbolic
   819                 flags = EAknEditorFlagNoT9 | EAknEditorFlagFixedCase;
   837                 flags = EAknEditorFlagNoT9 | EAknEditorFlagFixedCase;
   821                 permittedCase= EAknEditorLowerCase;
   839                 permittedCase= EAknEditorLowerCase;
   822                 inputMode = EAknEditorTextInputMode;
   840                 inputMode = EAknEditorTextInputMode;
   823                 permittedInputModes= EAknEditorTextInputMode | EAknEditorNumericInputMode;
   841                 permittedInputModes= EAknEditorTextInputMode | EAknEditorNumericInputMode;
   824             break;
   842             break;
   825             case EAnyLow:           //m any lower character can be changed to upper
   843             case EAnyLow:           //m any lower character can be changed to upper
       
   844                 flags = EAknEditorFlagNoT9;
   826                 currentCase = EAknEditorLowerCase;
   845                 currentCase = EAknEditorLowerCase;
   827                 permittedCase= EAknEditorAllCaseModes;
   846                 permittedCase= EAknEditorAllCaseModes;
   828                 inputMode = EAknEditorTextInputMode;
   847                 inputMode = EAknEditorTextInputMode;
   829                 permittedInputModes= EAknEditorAllInputModes;
   848                 permittedInputModes= EAknEditorAllInputModes;
   830             break;          
   849             break;
   831             case EAnyUpper:         //M any upper character can be changed to lower
   850             case EAnyUpper:         //M any upper character can be changed to lower
   832                 currentCase = EAknEditorUpperCase; 
   851                 flags = EAknEditorFlagNoT9;
       
   852                 currentCase = EAknEditorUpperCase;
   833                 permittedCase= EAknEditorAllCaseModes;
   853                 permittedCase= EAknEditorAllCaseModes;
   834                 inputMode = EAknEditorTextInputMode;
   854                 inputMode = EAknEditorTextInputMode;
   835                 permittedInputModes= EAknEditorAllInputModes;
   855                 permittedInputModes= EAknEditorAllInputModes;
   836             break;
   856             break;
   837             case ENumSymPuc:        //n any number or symbolic
   857             case ENumSymPuc:        //n any number or symbolic
   838                 flags = EAknEditorFlagNoT9;
   858                 flags = EAknEditorFlagNoT9;
   839                 currentCase = EAknEditorUpperCase;
   859                 currentCase = EAknEditorUpperCase;
   840                 permittedCase = EAknEditorAllCaseModes;
   860                 permittedCase = EAknEditorAllCaseModes;
   841                 inputMode = EAknEditorNumericInputMode;    
   861                 inputMode = EAknEditorNumericInputMode;
   842                 permittedInputModes= EAknEditorAllInputModes;        
   862                 permittedInputModes= EAknEditorAllInputModes;
   843             break;
   863             break;
   844             case ENumChar:          //N any number
   864             case ENumChar:          //N any number
   845                 flags = EAknEditorFlagNoT9;
   865                 flags = EAknEditorFlagNoT9;
   846                 currentCase = EAknEditorUpperCase;
   866                 currentCase = EAknEditorUpperCase;
   847                 permittedCase = EAknEditorAllCaseModes;
   867                 permittedCase = EAknEditorAllCaseModes;
   848                 inputMode = EAknEditorNumericInputMode;    
   868                 inputMode = EAknEditorNumericInputMode;
   849                 permittedInputModes= EAknEditorNumericInputMode;   
   869                 permittedInputModes= EAknEditorNumericInputMode;
       
   870                 numericKeyMap = EAknEditorPlainNumberModeKeymap;
       
   871                 setSCTAvailability(false);
   850             break;
   872             break;
   851             case EStatic:           
   873             case EStatic:
   852                 return EFalse;
   874                 return EFalse;
   853             break;
   875             break;
   854             case ENoFormat: 
   876             case ENoFormat:
   855                 return EFalse;
   877                 return EFalse;
   856             break;                    
   878             break;
   857             default:
   879             default:
   858             return EFalse;        
   880             return EFalse;
   859         }    
   881         }
   860         
   882 
   861         return ETrue;                
   883         return ETrue;
   862     }
   884     }
   863 
   885 
   864     return EFalse;                
   886     return EFalse;
   865 }
   887 }
   866 
   888 
   867 // -----------------------------------------------------------------------------
   889 // -----------------------------------------------------------------------------
   868 // validateTextFormat
   890 // validateTextFormat
   869 // 
   891 //
   870 // 
   892 //
   871 // -----------------------------------------------------------------------------
   893 // -----------------------------------------------------------------------------
   872 bool CWebFepTextEditor::validateTextFormat()
   894 bool CWebFepTextEditor::validateTextFormat()
   873 {
   895 {
   874     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   896     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   875     if (!frame || !frame->document()->focusedNode())
   897     if (!frame || !frame->document()->focusedNode())
   876         return true;
   898         return true;
   877 
   899 
   878     RenderStyle* s = frame->document()->focusedNode()->renderStyle();      
   900     RenderStyle* s = frame->document()->focusedNode()->renderStyle();
   879     if (!m_textFormatMask) {            
   901     if (!m_textFormatMask) {
   880         return true;
   902         return true;
   881     }
   903     }
   882         
   904 
   883     Node* n = frame->document()->focusedNode();
   905     Node* n = frame->document()->focusedNode();
   884     if (n->hasTagName(HTMLNames::inputTag)) {
   906     if (n->hasTagName(HTMLNames::inputTag)) {
   885         HTMLInputElement* input = static_cast<HTMLInputElement*>(n);
   907         HTMLInputElement* input = static_cast<HTMLInputElement*>(n);
   886         WebTextFormatMask::ErrorBlock eb;
   908         WebTextFormatMask::ErrorBlock eb;
   887         CSSStyleDeclaration* style = input->style();
   909         CSSStyleDeclaration* style = input->style();
   888         ExceptionCode ec = 0;     
   910         ExceptionCode ec = 0;
   889         
   911 
   890         String inputColor = style->getPropertyValue(CSS_PROP_COLOR); 
   912         String inputColor = style->getPropertyValue(CSS_PROP_COLOR);
   891         if ( inputColor.lower() != "red" )
   913         if ( inputColor.lower() != "red" )
   892         {
   914         {
   893             m_inputTextColor = inputColor; 
   915             m_inputTextColor = inputColor;
   894         }
   916         }
   895         
   917 
   896         if (!m_textFormatMask->checkText(input->value(), eb)) {
   918         if (!m_textFormatMask->checkText(input->value(), eb)) {
   897             style->setProperty(CSS_PROP_COLOR, "red", false, ec);
   919             style->setProperty(CSS_PROP_COLOR, "red", false, ec);
   898             return false;
   920             return false;
   899         }
   921         }
   900         else 
   922         else
   901         {
   923         {
   902             style->setProperty(CSS_PROP_COLOR, m_inputTextColor, false, ec);
   924             style->setProperty(CSS_PROP_COLOR, m_inputTextColor, false, ec);
   903             CancelEditingMode();
   925             CancelEditingMode();
   904             return true; 
   926             return true;
   905         }
   927         }
   906     }
   928     }
   907     else if ( n->hasTagName(HTMLNames::textareaTag)) {
   929     else if ( n->hasTagName(HTMLNames::textareaTag)) {
   908         CancelEditingMode();
   930         CancelEditingMode();
   909     }
   931     }
   910     
   932 
   911     return true;
   933     return true;
   912 }
   934 }
   913 
   935 
   914 // -----------------------------------------------------------------------------
   936 // -----------------------------------------------------------------------------
   915 // IsDirectionRTL
   937 // IsDirectionRTL
   938 
   960 
   939 #if defined(BRDO_BROWSER_50_FF)
   961 #if defined(BRDO_BROWSER_50_FF)
   940 // -----------------------------------------------------------------------------
   962 // -----------------------------------------------------------------------------
   941 // SetAlignment
   963 // SetAlignment
   942 // The EInputEditorAlignXXX flags are only supported in 5.0+ platforms
   964 // The EInputEditorAlignXXX flags are only supported in 5.0+ platforms
   943 // 
   965 //
   944 // -----------------------------------------------------------------------------
   966 // -----------------------------------------------------------------------------
   945 void CWebFepTextEditor::SetAlignment(CAknExtendedInputCapabilities::TInputCapabilities aAlignment)
   967 void CWebFepTextEditor::SetAlignment(CAknExtendedInputCapabilities::TInputCapabilities aAlignment)
   946 {
   968 {
   947     if ( !m_ExtendedInputCapabilities ) {
   969     if ( !m_ExtendedInputCapabilities ) {
   948         return;
   970         return;
   949     }
   971     }
   950     
   972 
   951     // Clear the old alignment
   973     // Clear the old alignment
   952     TUint capabilities = m_ExtendedInputCapabilities->Capabilities();
   974     TUint capabilities = m_ExtendedInputCapabilities->Capabilities();
   953     capabilities &= ~( CAknExtendedInputCapabilities::KAknEditorAlignMask );
   975     capabilities &= ~( CAknExtendedInputCapabilities::KAknEditorAlignMask );
   954 
   976 
   955     // Set the new alignment
   977     // Set the new alignment
   958 }
   980 }
   959 #endif
   981 #endif
   960 
   982 
   961 // -----------------------------------------------------------------------------
   983 // -----------------------------------------------------------------------------
   962 // UpdateInlineText
   984 // UpdateInlineText
   963 // 
   985 //
   964 // 
   986 //
   965 // -----------------------------------------------------------------------------
   987 // -----------------------------------------------------------------------------
   966 void CWebFepTextEditor::UpdateInlineText(const TDesC& aText)
   988 void CWebFepTextEditor::UpdateInlineText(const TDesC& aText)
   967 {                
   989 {
   968     delete m_inlineEditText;    
   990     delete m_inlineEditText;
   969     m_inlineEditText = NULL;    
   991     m_inlineEditText = NULL;
   970     
   992 
   971     if (DocumentLengthForFep() >= DocumentMaximumLengthForFep()) 
   993     if (DocumentLengthForFep() >= DocumentMaximumLengthForFep())
   972         return;
   994         return;
   973 
   995 
   974     m_inlineEditText = aText.Alloc();      
   996     m_inlineEditText = aText.Alloc();
   975     
   997 
   976     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   998     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   977     
   999 
   978     if (!frame)
  1000     if (!frame)
   979         return;
  1001         return;
   980     
  1002 
   981     
  1003 
   982     RenderStyle* r = NULL;
  1004     RenderStyle* r = NULL;
   983     if ( Node *n  = frame->selectionController()->selection().start().node() ) {
  1005     if ( Node *n  = frame->selectionController()->selection().start().node() ) {
   984         r = n->renderStyle();
  1006         r = n->renderStyle();
   985     }
  1007     }
   986       
  1008 
   987     bool textSecurity = r && r->textSecurity() != TSNONE;
  1009     bool textSecurity = r && r->textSecurity() != TSNONE;
   988 
  1010 
   989     RefPtr<CSSMutableStyleDeclaration> oldStyle;
  1011     RefPtr<CSSMutableStyleDeclaration> oldStyle;
   990     if (textSecurity) {    
  1012     if (textSecurity) {
   991         oldStyle = frame->typingStyle();
  1013         oldStyle = frame->typingStyle();
   992         RefPtr<CSSMutableStyleDeclaration> style = new CSSMutableStyleDeclaration;
  1014         RefPtr<CSSMutableStyleDeclaration> style = new CSSMutableStyleDeclaration;
   993         style->setProperty(CSS_PROP__WEBKIT_TEXT_SECURITY, CSS_VAL_NONE);
  1015         style->setProperty(CSS_PROP__WEBKIT_TEXT_SECURITY, CSS_VAL_NONE);
   994         frame->computeAndSetTypingStyle(style.get(), EditActionTyping);
  1016         frame->computeAndSetTypingStyle(style.get(), EditActionTyping);
   995     }
  1017     }
   996         
  1018 
   997     frame->editor()->insertTextWithoutSendingTextEvent(String(*m_inlineEditText), false);
  1019     if(!DocumentLengthForFep() && IsWapMaskedModeInput(frame)) {
   998         
  1020         HandleMaskedInsertText(frame, String(*m_inlineEditText));
       
  1021     }
       
  1022     else {
       
  1023         frame->editor()->insertTextWithoutSendingTextEvent(String(*m_inlineEditText), false);
       
  1024     }
       
  1025 
   999     if (textSecurity) {
  1026     if (textSecurity) {
  1000         if (oldStyle)
  1027         if (oldStyle)
  1001             frame->setTypingStyle(oldStyle.get());
  1028             frame->setTypingStyle(oldStyle.get());
  1002         else
  1029         else
  1003             frame->clearTypingStyle();
  1030             frame->clearTypingStyle();
  1004     }
  1031     }
  1005 }
  1032 }
  1006 
  1033 
  1007 // -----------------------------------------------------------------------------
  1034 // -----------------------------------------------------------------------------
  1008 // ClearInlineText
  1035 // ClearInlineText
  1009 // 
  1036 //
  1010 // 
  1037 //
  1011 // -----------------------------------------------------------------------------
  1038 // -----------------------------------------------------------------------------
  1012 void CWebFepTextEditor::ClearInlineText()
  1039 void CWebFepTextEditor::ClearInlineText()
  1013 {
  1040 {
  1014     TInt oldlen = m_inlineEditText ? m_inlineEditText->Length() : 0;
  1041     TInt oldlen = m_inlineEditText ? m_inlineEditText->Length() : 0;
  1015 
  1042 
  1016     TKeyEvent keyEvent = { EKeyBackspace, EKeyBackspace, 0, 0 };    
  1043     TKeyEvent keyEvent = { EKeyBackspace, EKeyBackspace, 0, 0 };
  1017     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
  1044     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
  1018     if (frame) {    
  1045     if (frame) {
  1019         while ( oldlen-- ) {
  1046         while ( oldlen-- ) {
  1020             frame->editor()->deleteWithDirection(SelectionController::BACKWARD,
  1047             frame->editor()->deleteWithDirection(SelectionController::BACKWARD,
  1021                                                  CharacterGranularity, false, true);
  1048                                                  CharacterGranularity, false, true);
  1022         }
  1049         }
  1023     }
  1050     }
  1024 }
  1051 }
  1025 
  1052 
  1026 // -----------------------------------------------------------------------------
  1053 // -----------------------------------------------------------------------------
  1027 // IsTextAreaFocused
  1054 // IsTextAreaFocused
  1028 // 
  1055 //
  1029 // 
  1056 //
  1030 // -----------------------------------------------------------------------------
  1057 // -----------------------------------------------------------------------------
  1031 bool CWebFepTextEditor::IsTextAreaFocused() const
  1058 bool CWebFepTextEditor::IsTextAreaFocused() const
  1032 {
  1059 {
  1033     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
  1060     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
  1034     return ( frame && frame->document()->focusedNode() &&
  1061     return ( frame && frame->document()->focusedNode() &&
  1035     		 frame->document()->focusedNode()->hasTagName(HTMLNames::textareaTag));
  1062     		 frame->document()->focusedNode()->hasTagName(HTMLNames::textareaTag));
  1036 }
  1063 }
  1037 
  1064 
  1038 // -----------------------------------------------------------------------------
  1065 // -----------------------------------------------------------------------------
  1039 // CcpuIsFocused
  1066 // CcpuIsFocused
  1040 // 
  1067 //
  1041 // 
  1068 //
  1042 // -----------------------------------------------------------------------------
  1069 // -----------------------------------------------------------------------------
  1043 TBool CWebFepTextEditor::CcpuIsFocused() const
  1070 TBool CWebFepTextEditor::CcpuIsFocused() const
  1044 {
  1071 {
  1045     return ETrue;
  1072     return ETrue;
  1046 }
  1073 }
  1047     
  1074 
  1048 // -----------------------------------------------------------------------------
  1075 // -----------------------------------------------------------------------------
  1049 // CcpuCanCut
  1076 // CcpuCanCut
  1050 // 
  1077 //
  1051 // 
  1078 //
  1052 // -----------------------------------------------------------------------------
  1079 // -----------------------------------------------------------------------------
  1053 TBool CWebFepTextEditor::CcpuCanCut() const
  1080 TBool CWebFepTextEditor::CcpuCanCut() const
  1054 {
  1081 {
  1055     TCursorSelection selection;
  1082     TCursorSelection selection;
  1056     GetCursorSelectionForFep(selection);    
  1083     GetCursorSelectionForFep(selection);
  1057     return selection.Length();
  1084     return selection.Length();
  1058 }
  1085 }
  1059 
  1086 
  1060 // -----------------------------------------------------------------------------
  1087 // -----------------------------------------------------------------------------
  1061 // CcpuCutL
  1088 // CcpuCutL
  1062 // 
  1089 //
  1063 // 
  1090 //
  1064 // -----------------------------------------------------------------------------
  1091 // -----------------------------------------------------------------------------
  1065 void CWebFepTextEditor::CcpuCutL()
  1092 void CWebFepTextEditor::CcpuCutL()
  1066 {
  1093 {
  1067     PlaceDataOnClipboardL();
  1094     PlaceDataOnClipboardL();
  1068     TCursorSelection selection;
  1095     TCursorSelection selection;
  1069     GetCursorSelectionForFep(selection);    
  1096     GetCursorSelectionForFep(selection);
  1070 }
  1097 }
  1071     
  1098 
  1072 // -----------------------------------------------------------------------------
  1099 // -----------------------------------------------------------------------------
  1073 // CcpuCanCopy
  1100 // CcpuCanCopy
  1074 // 
  1101 //
  1075 // 
  1102 //
  1076 // -----------------------------------------------------------------------------
  1103 // -----------------------------------------------------------------------------
  1077 TBool CWebFepTextEditor::CcpuCanCopy() const
  1104 TBool CWebFepTextEditor::CcpuCanCopy() const
  1078 {
  1105 {
  1079     TCursorSelection selection;
  1106     TCursorSelection selection;
  1080     GetCursorSelectionForFep(selection);    
  1107     GetCursorSelectionForFep(selection);
  1081     return selection.Length();
  1108     return selection.Length();
  1082 }
  1109 }
  1083     
  1110 
  1084 // -----------------------------------------------------------------------------
  1111 // -----------------------------------------------------------------------------
  1085 // CcpuCopyL
  1112 // CcpuCopyL
  1086 // 
  1113 //
  1087 // 
  1114 //
  1088 // -----------------------------------------------------------------------------
  1115 // -----------------------------------------------------------------------------
  1089 void CWebFepTextEditor::CcpuCopyL()
  1116 void CWebFepTextEditor::CcpuCopyL()
  1090 {
  1117 {
  1091     PlaceDataOnClipboardL();
  1118     PlaceDataOnClipboardL();
  1092 }
  1119 }
  1093     
  1120 
  1094 // -----------------------------------------------------------------------------
  1121 // -----------------------------------------------------------------------------
  1095 // CcpuCanPaste
  1122 // CcpuCanPaste
  1096 // 
  1123 //
  1097 // 
  1124 //
  1098 // -----------------------------------------------------------------------------
  1125 // -----------------------------------------------------------------------------
  1099 TBool CWebFepTextEditor::CcpuCanPaste() const
  1126 TBool CWebFepTextEditor::CcpuCanPaste() const
  1100 {
  1127 {
  1101     TRAPD(err, DoCcpuCanPasteL());
  1128     TRAPD(err, DoCcpuCanPasteL());
  1102     return err == KErrNone;
  1129     return err == KErrNone;
  1103 }
  1130 }
  1104     
  1131 
  1105 // -----------------------------------------------------------------------------
  1132 // -----------------------------------------------------------------------------
  1106 // CcpuPasteL
  1133 // CcpuPasteL
  1107 // 
  1134 //
  1108 // 
  1135 //
  1109 // -----------------------------------------------------------------------------
  1136 // -----------------------------------------------------------------------------
  1110 void CWebFepTextEditor::CcpuPasteL() 
  1137 void CWebFepTextEditor::CcpuPasteL()
  1111 {
  1138 {
  1112     RetrieveDataFromClipboardL();   
  1139     RetrieveDataFromClipboardL();
  1113 }
  1140 }
  1114         
  1141 
  1115 // -----------------------------------------------------------------------------
  1142 // -----------------------------------------------------------------------------
  1116 // DoCcpuCanPasteL
  1143 // DoCcpuCanPasteL
  1117 // 
  1144 //
  1118 // 
  1145 //
  1119 // -----------------------------------------------------------------------------
  1146 // -----------------------------------------------------------------------------
  1120 void  CWebFepTextEditor::DoCcpuCanPasteL() const
  1147 void  CWebFepTextEditor::DoCcpuCanPasteL() const
  1121 {
  1148 {
  1122     CClipboard* cb=CClipboard::NewForReadingL(CCoeEnv::Static()->FsSession());
  1149     CClipboard* cb=CClipboard::NewForReadingL(CCoeEnv::Static()->FsSession());
  1123     CleanupStack::PushL(cb);
  1150     CleanupStack::PushL(cb);
  1124     TStreamId streamId=cb->StreamDictionary().At(KClipboardUidTypePlainText);
  1151     TStreamId streamId=cb->StreamDictionary().At(KClipboardUidTypePlainText);
  1125     if (streamId==KNullStreamId)
  1152     if (streamId==KNullStreamId)
  1126         User::Leave(KErrNotFound);
  1153         User::Leave(KErrNotFound);
  1127     CleanupStack::PopAndDestroy(); // allowedChars, cb
  1154     CleanupStack::PopAndDestroy(); // allowedChars, cb
  1128 }    
  1155 }
  1129     
  1156 
  1130 // -----------------------------------------------------------------------------
  1157 // -----------------------------------------------------------------------------
  1131 // PlaceDataOnClipboardL
  1158 // PlaceDataOnClipboardL
  1132 // 
  1159 //
  1133 // 
  1160 //
  1134 // -----------------------------------------------------------------------------
  1161 // -----------------------------------------------------------------------------
  1135 void CWebFepTextEditor::PlaceDataOnClipboardL()
  1162 void CWebFepTextEditor::PlaceDataOnClipboardL()
  1136 {
  1163 {
  1137     CancelFepInlineEdit();
  1164     CancelFepInlineEdit();
  1138     CClipboard* cb=CClipboard::NewForWritingLC(CCoeEnv::Static()->FsSession());
  1165     CClipboard* cb=CClipboard::NewForWritingLC(CCoeEnv::Static()->FsSession());
  1141     CleanupStack::PopAndDestroy();
  1168     CleanupStack::PopAndDestroy();
  1142 }
  1169 }
  1143 
  1170 
  1144 // -----------------------------------------------------------------------------
  1171 // -----------------------------------------------------------------------------
  1145 // CopyToStoreL
  1172 // CopyToStoreL
  1146 // 
  1173 //
  1147 // 
  1174 //
  1148 // -----------------------------------------------------------------------------
  1175 // -----------------------------------------------------------------------------
  1149 void CWebFepTextEditor::CopyToStoreL(CStreamStore& aStore,CStreamDictionary& aDict)
  1176 void CWebFepTextEditor::CopyToStoreL(CStreamStore& aStore,CStreamDictionary& aDict)
  1150 {
  1177 {
  1151 	if ( DocumentLengthForFep()== 0)
  1178 	if ( DocumentLengthForFep()== 0)
  1152 		return ;
  1179 		return ;
  1153     TCursorSelection selection;
  1180     TCursorSelection selection;
  1154     GetCursorSelectionForFep(selection);
  1181     GetCursorSelectionForFep(selection);
  1155 	
  1182 
  1156 	HBufC* buf = HBufC::NewLC(512);
  1183 	HBufC* buf = HBufC::NewLC(512);
  1157 	TPtr ptr(buf->Des());
  1184 	TPtr ptr(buf->Des());
  1158 			
  1185 
  1159     GetEditorContentForFep(ptr,0,DocumentLengthForFep());
  1186     GetEditorContentForFep(ptr,0,DocumentLengthForFep());
  1160     CPlainText* text = CPlainText::NewL(CPlainText::EFlatStorage);	
  1187     CPlainText* text = CPlainText::NewL(CPlainText::EFlatStorage);
  1161 	
  1188 
  1162 	text->InsertL(0,*buf);	
  1189 	text->InsertL(0,*buf);
  1163 	text->CopyToStoreL(aStore, aDict, selection.LowerPos(), selection.Length());
  1190 	text->CopyToStoreL(aStore, aDict, selection.LowerPos(), selection.Length());
  1164 	
  1191 
  1165 	delete text;
  1192 	delete text;
  1166     CleanupStack::PopAndDestroy();	
  1193     CleanupStack::PopAndDestroy();
  1167 }
  1194 }
  1168 
  1195 
  1169 // -----------------------------------------------------------------------------
  1196 // -----------------------------------------------------------------------------
  1170 // RetrieveDataFromClipboardL
  1197 // HandleMaskedInsertText
  1171 // 
  1198 // 
  1172 // 
  1199 // 
       
  1200 // -----------------------------------------------------------------------------
       
  1201 void CWebFepTextEditor::HandleMaskedInsertText(WebCore::Frame *frame, const String& text)
       
  1202 {
       
  1203     TInt pos = DocumentLengthForFep();
       
  1204     if (!pos) {
       
  1205         while(m_textFormatMask->getInputFormatMaskType(frame, pos) == EStatic) {
       
  1206             MaskStatic* ms = static_cast<MaskStatic*>(m_textFormatMask->getMask(pos));
       
  1207             UChar mask(ms->getStatic());
       
  1208             frame->editor()->insertTextWithoutSendingTextEvent(String(&mask,1), false);
       
  1209             ++pos;
       
  1210         }
       
  1211         frame->editor()->insertTextWithoutSendingTextEvent(text, false);
       
  1212     }
       
  1213     else {
       
  1214         frame->editor()->insertTextWithoutSendingTextEvent(text, false);
       
  1215         while(m_textFormatMask->getInputFormatMaskType(frame, ++pos) == EStatic) {
       
  1216             TCursorSelection selection;
       
  1217             GetCursorSelectionForFep(selection);
       
  1218             const TInt cursorPos=selection.LowerPos();
       
  1219             if (cursorPos>=pos) {
       
  1220                 MaskStatic* ms = static_cast<MaskStatic*>(m_textFormatMask->getMask(pos));
       
  1221                 UChar mask(ms->getStatic());
       
  1222                 frame->editor()->insertTextWithoutSendingTextEvent(String(&mask,1), false);
       
  1223             }
       
  1224         }
       
  1225     }
       
  1226 }
       
  1227 
       
  1228 // -----------------------------------------------------------------------------
       
  1229 // HandleMaskedDeleteText
       
  1230 //
       
  1231 //  
       
  1232 // -----------------------------------------------------------------------------
       
  1233 void CWebFepTextEditor::HandleMaskedDeleteText(WebCore::Frame* frame)
       
  1234 {
       
  1235     TCursorSelection selection;
       
  1236     GetCursorSelectionForFep(selection);
       
  1237     TInt cursorPos=selection.LowerPos();
       
  1238 
       
  1239     if (cursorPos == DocumentLengthForFep()) {
       
  1240         while (m_textFormatMask->getInputFormatMaskType(frame, --cursorPos) == EStatic) {
       
  1241             frame->editor()->deleteWithDirection(SelectionController::BACKWARD,
       
  1242                     CharacterGranularity, false, true);
       
  1243         }
       
  1244     }
       
  1245     if (cursorPos >=0)
       
  1246         frame->editor()->deleteWithDirection(SelectionController::BACKWARD,
       
  1247                 CharacterGranularity, false, true);
       
  1248 }
       
  1249 
       
  1250 // -----------------------------------------------------------------------------
       
  1251 // IsWapMaskedModeInput
       
  1252 //
       
  1253 //  
       
  1254 // -----------------------------------------------------------------------------
       
  1255 bool CWebFepTextEditor::IsWapMaskedModeInput(WebCore::Frame* frame)
       
  1256 {
       
  1257     bool maskedInput(false);
       
  1258     if (m_textFormatMask && frame->document() && frame->document()->focusedNode()) { 
       
  1259         RenderStyle* s = frame->document()->focusedNode()->renderStyle();
       
  1260         if (s && (!s->wapInputFormat().isEmpty() || s->wapInputRequired())){            
       
  1261             maskedInput = true;
       
  1262         }
       
  1263     }
       
  1264     return maskedInput;
       
  1265 }
       
  1266 
       
  1267 // -----------------------------------------------------------------------------
       
  1268 // RetrieveDataFromClipboardL
       
  1269 //
       
  1270 //
  1173 // -----------------------------------------------------------------------------
  1271 // -----------------------------------------------------------------------------
  1174 void CWebFepTextEditor::RetrieveDataFromClipboardL()
  1272 void CWebFepTextEditor::RetrieveDataFromClipboardL()
  1175 {
  1273 {
  1176     m_webView->fepTextEditor()->CancelFepInlineEdit();
  1274     m_webView->fepTextEditor()->CancelFepInlineEdit();
  1177     CClipboard* cb=NULL;
  1275     CClipboard* cb=NULL;
  1178     TRAPD(err,cb=CClipboard::NewForReadingL(CCoeEnv::Static()->FsSession()));
  1276     TRAPD(err,cb=CClipboard::NewForReadingL(CCoeEnv::Static()->FsSession()));
  1179     CleanupStack::PushL(cb);
  1277     CleanupStack::PushL(cb);
  1180     User::LeaveIfError(err);
  1278     User::LeaveIfError(err);
  1181     TStreamId streamId=cb->StreamDictionary().At(KClipboardUidTypePlainText);
  1279     TStreamId streamId=cb->StreamDictionary().At(KClipboardUidTypePlainText);
  1182     PasteFromStoreL(cb->Store(), cb->StreamDictionary());
  1280     PasteFromStoreL(cb->Store(), cb->StreamDictionary());
  1183     CleanupStack::PopAndDestroy();  // cb    
  1281     CleanupStack::PopAndDestroy();  // cb
  1184 }
  1282 }
  1185         
  1283 
  1186 // -----------------------------------------------------------------------------
  1284 // -----------------------------------------------------------------------------
  1187 // PasteFromStoreL
  1285 // PasteFromStoreL
  1188 // 
  1286 //
  1189 // 
  1287 //
  1190 // -----------------------------------------------------------------------------
  1288 // -----------------------------------------------------------------------------
  1191 void CWebFepTextEditor::PasteFromStoreL(CStreamStore& aStore,CStreamDictionary& aDict)
  1289 void CWebFepTextEditor::PasteFromStoreL(CStreamStore& aStore,CStreamDictionary& aDict)
  1192 {
  1290 {
  1193     //Read the content into Text
  1291     //Read the content into Text
  1194     CancelFepInlineEdit();
  1292     CancelFepInlineEdit();
  1195     TStreamId streamId=aDict.At(KClipboardUidTypePlainText);
  1293     TStreamId streamId=aDict.At(KClipboardUidTypePlainText);
  1196     TCursorSelection selection;
  1294     TCursorSelection selection;
  1197     GetCursorSelectionForFep(selection);
  1295     GetCursorSelectionForFep(selection);
  1198     const TInt cursorPos=selection.LowerPos();
  1296     const TInt cursorPos=selection.LowerPos();
  1199     
  1297 
  1200 	HBufC* buf1 = HBufC::NewLC(512);
  1298 	HBufC* buf1 = HBufC::NewLC(512);
  1201 	TPtr ptr1(buf1->Des());
  1299 	TPtr ptr1(buf1->Des());
  1202 	
  1300 
  1203 	CPlainText* text = CPlainText::NewL(CPlainText::EFlatStorage);	
  1301 	CPlainText* text = CPlainText::NewL(CPlainText::EFlatStorage);
  1204 	
  1302 
  1205     GetEditorContentForFep(ptr1,0,DocumentLengthForFep());    
  1303     GetEditorContentForFep(ptr1,0,DocumentLengthForFep());
  1206     
  1304 
  1207     text->InsertL(0,*buf1);
  1305     text->InsertL(0,*buf1);
  1208         
  1306 
  1209     TInt charPasted = text->PasteFromStoreL(aStore,aDict,cursorPos);
  1307     TInt charPasted = text->PasteFromStoreL(aStore,aDict,cursorPos);
  1210     
  1308 
  1211     HBufC* buf = HBufC::NewLC(512);
  1309     HBufC* buf = HBufC::NewLC(512);
  1212     TPtr ptr(buf->Des());
  1310     TPtr ptr(buf->Des());
  1213     text->Extract(ptr,cursorPos,charPasted);      
  1311     text->Extract(ptr,cursorPos,charPasted);
  1214     
  1312 
  1215     //remove Paragraph Delimiter
  1313     //remove Paragraph Delimiter
  1216     TInt position = ptr.Mid(0).LocateReverse(TChar(CEditableText::EParagraphDelimiter));
  1314     TInt position = ptr.Mid(0).LocateReverse(TChar(CEditableText::EParagraphDelimiter));
  1217     while (position != KErrNotFound ){
  1315     while (position != KErrNotFound ){
  1218         ptr.Delete( position, 1 );
  1316         ptr.Delete( position, 1 );
  1219         position = ptr.Left(position).LocateReverse(TChar(CEditableText::EParagraphDelimiter));
  1317         position = ptr.Left(position).LocateReverse(TChar(CEditableText::EParagraphDelimiter));
  1220         }           
  1318         }
  1221     
  1319 
  1222     Frame* frame = m_webView->page()->mainFrame();
  1320     Frame* frame = m_webView->page()->mainFrame();
  1223 	frame = m_webView->page()->focusController()->focusedOrMainFrame();
  1321 	frame = m_webView->page()->focusController()->focusedOrMainFrame();
  1224     frame->editor()->insertTextWithoutSendingTextEvent(String(ptr), false);
  1322     frame->editor()->insertTextWithoutSendingTextEvent(String(ptr), false);
  1225     
  1323 
  1226     delete text;
  1324     delete text;
  1227     CleanupStack::PopAndDestroy(2);
  1325     CleanupStack::PopAndDestroy(2);
  1228 }
  1326 }
  1229 
  1327 
  1230 // -----------------------------------------------------------------------------
  1328 // -----------------------------------------------------------------------------
  1231 // EnableCcpu
  1329 // EnableCcpu
  1232 // 
  1330 //
  1233 // 
  1331 //
  1234 // -----------------------------------------------------------------------------
  1332 // -----------------------------------------------------------------------------
  1235 void CWebFepTextEditor::EnableCcpu(TBool aSupport)
  1333 void CWebFepTextEditor::EnableCcpu(TBool aSupport)
  1236 {
  1334 {
  1237     CAknEdwinState* edwinState = static_cast<CAknEdwinState*>(this->State(KNullUid));
  1335     CAknEdwinState* edwinState = static_cast<CAknEdwinState*>(this->State(KNullUid));
  1238     if(aSupport)
  1336     if(aSupport)
  1239         {
  1337         {
  1240         edwinState->SetCcpuState(this);    
  1338         edwinState->SetCcpuState(this);
  1241         }
  1339         }
  1242     else
  1340     else
  1243         {
  1341         {
  1244         edwinState->SetCcpuState(NULL);
  1342         edwinState->SetCcpuState(NULL);
  1245         }       
  1343         }
  1246 }
  1344 }
  1247 
  1345 
  1248 // -----------------------------------------------------------------------------
  1346 // -----------------------------------------------------------------------------
  1249 // findPrevSiblingTextLen
  1347 // findPrevSiblingTextLen
  1250 // 
  1348 //
  1251 // Walk the previous text nodes and add up the len of each text node, so we can
  1349 // Walk the previous text nodes and add up the len of each text node, so we can
  1252 // calculate the total length from first text node to current text node cursor
  1350 // calculate the total length from first text node to current text node cursor
  1253 // position.
  1351 // position.
  1254 // NOTES:
  1352 // NOTES:
  1255 // 1. Each "inserted" newline creates a new node.
  1353 // 1. Each "inserted" newline creates a new node.
  1293 	for ( ; aNode; aNode=aNode->nextSibling() ) {
  1391 	for ( ; aNode; aNode=aNode->nextSibling() ) {
  1294 		if ( aNode && aNode->isTextNode() ) {
  1392 		if ( aNode && aNode->isTextNode() ) {
  1295 			WebCore::Text* aText = (WebCore::Text*)aNode;
  1393 			WebCore::Text* aText = (WebCore::Text*)aNode;
  1296 			str = aText->data();
  1394 			str = aText->data();
  1297 			len +=  str.length();
  1395 			len +=  str.length();
  1298 			if ( len >= aPos ) {
  1396 			if ( len > aPos ) {
  1299 				// We found the text node at aPos, calculate the length of all
  1397 				// We found the text node at aPos, calculate the length of all
  1300 				// previous text nodes
  1398 				// previous text nodes
  1301 				retNode = aNode;
  1399 				retNode = aNode;
  1302 				aPos = len - str.length();
  1400 				aPos = len - str.length();
  1303 				break;
  1401 				break;
  1305 		}
  1403 		}
  1306 	}
  1404 	}
  1307 
  1405 
  1308 	return retNode;
  1406 	return retNode;
  1309 }
  1407 }
       
  1408 
       
  1409 // -----------------------------------------------------------------------------
       
  1410 // SetSCTAvailability
       
  1411 //
       
  1412 // Set availibility of the special character table. 
       
  1413 // -----------------------------------------------------------------------------
       
  1414 void CWebFepTextEditor::setSCTAvailability(bool aAvailable)
       
  1415 {
       
  1416     if (m_ExtendedInputCapabilities) {
       
  1417         TUint capabilities = m_ExtendedInputCapabilities->Capabilities();
       
  1418         if (!aAvailable) {
       
  1419             capabilities |= CAknExtendedInputCapabilities::EDisableSCT;
       
  1420         }
       
  1421         else {
       
  1422             capabilities &= ~(CAknExtendedInputCapabilities::EDisableSCT);
       
  1423         }
       
  1424         m_ExtendedInputCapabilities->SetCapabilities(capabilities);
       
  1425     }
       
  1426 }
       
  1427