webengine/osswebengine/WebKit/s60/webview/WebFepTextEditor.cpp
branchRCL_3
changeset 93 79859ed3eea9
parent 92 e1bea15f9a39
child 94 919f36ff910f
equal deleted inserted replaced
92:e1bea15f9a39 93:79859ed3eea9
    13 *
    13 *
    14 * Description:   WebFepTextEditor.cpp
    14 * Description:   WebFepTextEditor.cpp
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
       
    19 
       
    20 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    18 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    21 #include <txtetext_internal.h>
    19 #include <txtetext_internal.h>
    22 #include <txtclipboard.h>
    20 #include <txtclipboard.h>
    23 #include <txtetext_internal.h>
    21 #include <txtetext_internal.h>
    24 #endif
    22 #endif
    38 #include "FocusController.h"
    36 #include "FocusController.h"
    39 #include "WebFrameView.h"
    37 #include "WebFrameView.h"
    40 
    38 
    41 #include "Frame.h"
    39 #include "Frame.h"
    42 #include "Editor.h"
    40 #include "Editor.h"
    43 #include "HtmlNames.h"
    41 #include "HTMLNames.h"
    44 #include "EventHandler.h"
    42 #include "EventHandler.h"
    45 #include "HtmlInputElement.h"
    43 #include "HTMLInputElement.h"
    46 #include "HtmlTextAreaElement.h"
    44 #include "HTMLTextAreaElement.h"
    47 #include "PlatformKeyboardEvent.h"
    45 #include "PlatformKeyboardEvent.h"
    48 #include "CSSPropertyNames.h"
    46 #include "CSSPropertyNames.h"
    49 #include "CSSValueKeywords.h"
    47 #include "CSSValueKeywords.h"
    50 
    48 
    51 #include <coemain.h>
    49 #include <coemain.h>
    52 #include <eikpanic.h>
    50 #include <eikpanic.h>
    53 #include <aknedsts.h>
    51 #include <aknedsts.h>
    54 #include <aknutils.h>
    52 #include <AknUtils.h>
    55 #include "Text.h"
    53 #include "Text.h"
    56 
       
    57 #include <e32const.h>
       
    58 
       
    59 #define KLineEnterChar 0x21b2
       
    60 
    54 
    61 using namespace WebCore;
    55 using namespace WebCore;
    62 
    56 
    63 static const int kInfinite = -1;
    57 static const int kInfinite = -1;
    64 _LIT(KBlankDesC," ");
    58 _LIT(KBlankDesC," ");
    75 //
    69 //
    76 // -----------------------------------------------------------------------------
    70 // -----------------------------------------------------------------------------
    77 CWebFepTextEditor::CWebFepTextEditor(WebView* aView)
    71 CWebFepTextEditor::CWebFepTextEditor(WebView* aView)
    78     : m_webView(aView),
    72     : m_webView(aView),
    79       m_textFormatMask(NULL),
    73       m_textFormatMask(NULL),
    80       m_inlineEditText(NULL),
    74       m_inlineEditText(NULL)
    81       m_longKeyPress(EFalse),
       
    82       m_inlineTextEditingStarted(EFalse)
       
    83 {
    75 {
    84     // Set up the extended capabilities
    76     // Set up the extended capabilities
    85     TRAP_IGNORE(
    77     TRAP_IGNORE(
    86         m_ExtendedInputCapabilities = CAknExtendedInputCapabilities::NewL();
    78         m_ExtendedInputCapabilities = CAknExtendedInputCapabilities::NewL();
    87         );
    79         );
    89     // Set alignment on m_ExtendedInputCapabilities, yes it checks if NULL
    81     // Set alignment on m_ExtendedInputCapabilities, yes it checks if NULL
    90     // The EInputEditorAlignXXX flags are defined for 5.0+ platforms
    82     // The EInputEditorAlignXXX flags are defined for 5.0+ platforms
    91 #if defined(BRDO_BROWSER_50_FF)
    83 #if defined(BRDO_BROWSER_50_FF)
    92     SetAlignment( CAknExtendedInputCapabilities::EInputEditorAlignBidi );
    84     SetAlignment( CAknExtendedInputCapabilities::EInputEditorAlignBidi );
    93 #endif
    85 #endif
    94     TRAP_IGNORE( EnableCcpuL() );
    86 	EnableCcpu(ETrue);
    95 }
    87 }
    96 
    88 
    97 // -----------------------------------------------------------------------------
    89 // -----------------------------------------------------------------------------
    98 // ~CWebFepTextEditor
    90 // ~CWebFepTextEditor
    99 //
    91 //
   103     {
    95     {
   104     delete m_state;
    96     delete m_state;
   105     delete m_inlineEditText;
    97     delete m_inlineEditText;
   106     delete m_textFormatMask;
    98     delete m_textFormatMask;
   107 	delete m_ExtendedInputCapabilities;
    99 	delete m_ExtendedInputCapabilities;
   108 	delete m_CcpuSupport;
       
   109     }
   100     }
   110 
   101 
   111 // -----------------------------------------------------------------------------
   102 // -----------------------------------------------------------------------------
   112 // CreateTextFormatMask
   103 // CreateTextFormatMask
   113 //
   104 //
   136 // -----------------------------------------------------------------------------
   127 // -----------------------------------------------------------------------------
   137 void CWebFepTextEditor::UpdateEditingMode()
   128 void CWebFepTextEditor::UpdateEditingMode()
   138 {
   129 {
   139     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   130     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   140     if (frame) {
   131     if (frame) {
   141         Node *node = frame->document()->focusedNode(); 
   132         Node *node = frame->document()->focusedNode();
   142         if (frame && frame->document() && node) {
   133         if (frame && frame->document() && node) {
   143             if (node->hasTagName(HTMLNames::inputTag) 
   134             if (node->hasTagName(HTMLNames::inputTag)
   144                     && (static_cast<HTMLInputElement*>(node)->inputType() == HTMLInputElement::PASSWORD) 
   135                     && (static_cast<HTMLInputElement*>(node)->inputType() == HTMLInputElement::PASSWORD)
   145                         && !static_cast<HTMLInputElement*>(node)->readOnly()) {            
   136                         && !static_cast<HTMLInputElement*>(node)->readOnly()) {
   146                 // Set the state as if it was the CEikSecretEditor
   137                 // Set the state as if it was the CEikSecretEditor
   147                 CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
   138                 CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
   148                 if (state) {
   139                 if (state) {
   149                     state->SetFlags( EAknEditorFlagNoLRNavigation |
   140                     state->SetFlags( EAknEditorFlagNoLRNavigation |
   150                                         EAknEditorFlagLatinInputModesOnly |
   141                                         EAknEditorFlagLatinInputModesOnly |
   151                                         EAknEditorFlagNoT9 |
   142                                         EAknEditorFlagNoT9 |
   152                                         EAknEditorFlagUseSCTNumericCharmap |
   143                                         EAknEditorFlagUseSCTNumericCharmap );
   153                                         EAknEditorFlagNoLRNavigation);                    
       
   154                     state->SetDefaultInputMode(EAknEditorSecretAlphaInputMode);
   144                     state->SetDefaultInputMode(EAknEditorSecretAlphaInputMode);
   155                     state->SetCurrentInputMode(EAknEditorSecretAlphaInputMode);
   145                     state->SetCurrentInputMode(EAknEditorSecretAlphaInputMode);
   156                     state->SetPermittedCases(EAknEditorLowerCase|EAknEditorUpperCase);
   146                     state->SetPermittedCases(EAknEditorLowerCase|EAknEditorUpperCase);
   157                     state->SetCurrentCase(EAknEditorLowerCase);
   147                     state->SetCurrentCase(EAknEditorLowerCase);
   158                     state->SetPermittedInputModes(EAknEditorSecretAlphaInputMode | EAknEditorNumericInputMode);
   148                     state->SetPermittedInputModes(EAknEditorSecretAlphaInputMode | EAknEditorNumericInputMode);
   159                     state->SetDefaultCase(EAknEditorLowerCase);
   149                     state->SetDefaultCase(EAknEditorLowerCase);
   160                     state->SetSpecialCharacterTableResourceId(R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_LATIN_ONLY);
   150                     state->SetSpecialCharacterTableResourceId(R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_LATIN_ONLY);
   161                     state->SetNumericKeymap(EAknEditorStandardNumberModeKeymap);
   151                     state->SetNumericKeymap(EAknEditorPlainNumberModeKeymap);
   162                     state->SetCcpuState(NULL);
       
   163                     TRAP_IGNORE( state->ReportAknEdStateEventL(MAknEdStateObserver::EAknEdwinStateFlagsUpdate ) );
       
   164                 }
   152                 }
   165             }
   153             }
   166             else {
   154             else {
   167                     CreateTextFormatMask();
   155                     CreateTextFormatMask();
   168                     TUint currentCase ( EAknEditorLowerCase ) ;
   156                     TUint currentCase ( EAknEditorLowerCase ) ;
   169                     TUint permittedCase ( EAknEditorAllCaseModes ) ;
   157                     TUint permittedCase ( EAknEditorAllCaseModes ) ;
   170                     TUint inputMode( EAknEditorNullInputMode );
   158                     TUint inputMode( EAknEditorNullInputMode );
   171                     TUint permittedInputModes( EAknEditorAllInputModes );
   159                     TUint permittedInputModes( EAknEditorAllInputModes );
   172 #ifdef BRDO_MULTITOUCH_ENABLED_FF
       
   173                     TUint flags( EAknEditorFlagDefault | EAknEditorFlagSelectionVisible );
       
   174 #else
       
   175                     TUint flags( EAknEditorFlagDefault );
   160                     TUint flags( EAknEditorFlagDefault );
   176 #endif
       
   177                     TUint numericKeyMap( EAknEditorStandardNumberModeKeymap );
   161                     TUint numericKeyMap( EAknEditorStandardNumberModeKeymap );
   178     
   162 
   179                     if (GetStateFromFormatMask(currentCase, permittedCase, inputMode, permittedInputModes, flags, numericKeyMap)) {
   163                     if (GetStateFromFormatMask(currentCase, permittedCase, inputMode, permittedInputModes, flags, numericKeyMap)) {
   180                         UpdateFlagsState(flags);
   164                         UpdateFlagsState(flags);
   181                         UpdateInputModeState(inputMode, permittedInputModes, numericKeyMap);
   165                         UpdateInputModeState(inputMode, permittedInputModes, numericKeyMap);
   182                         UpdateCaseState(currentCase, permittedCase);
   166                         UpdateCaseState(currentCase, permittedCase);
   183                     }
   167                     }
   185                         CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
   169                         CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
   186                         if (state) {
   170                         if (state) {
   187                             state->SetDefaultCase(EAknEditorLowerCase);
   171                             state->SetDefaultCase(EAknEditorLowerCase);
   188                             state->SetPermittedInputModes(EAknEditorAllInputModes);
   172                             state->SetPermittedInputModes(EAknEditorAllInputModes);
   189                             state->SetPermittedCases(EAknEditorAllCaseModes);//allow everything
   173                             state->SetPermittedCases(EAknEditorAllCaseModes);//allow everything
   190                             state->SetCcpuState(this);
       
   191                         }
   174                         }
   192                     }
   175                     }
   193             }
   176             }
   194         }
   177         }
   195     }   // End of if (frame)
   178     }   // End of if (frame)
   205     delete m_textFormatMask;
   188     delete m_textFormatMask;
   206     m_textFormatMask = NULL;
   189     m_textFormatMask = NULL;
   207 
   190 
   208     delete m_inlineEditText;
   191     delete m_inlineEditText;
   209     m_inlineEditText = NULL;
   192     m_inlineEditText = NULL;
   210     
       
   211     m_longKeyPress = EFalse ;
       
   212 
   193 
   213     UpdateInputModeState(EAknEditorNullInputMode, EAknEditorAllInputModes,EAknEditorStandardNumberModeKeymap);
   194     UpdateInputModeState(EAknEditorNullInputMode, EAknEditorAllInputModes,EAknEditorStandardNumberModeKeymap);
   214     UpdateFlagsState(EAknEditorFlagDefault);        
   195     UpdateFlagsState(EAknEditorFlagDefault);
   215     UpdateCaseState(EAknEditorLowerCase, EAknEditorAllCaseModes);
   196     UpdateCaseState(EAknEditorLowerCase, EAknEditorAllCaseModes);
   216 
   197 
   217     CancelFepInlineEdit();
   198     CancelFepInlineEdit();
   218     }
   199     }
   219 
   200 
   254             // Set up the input capabilities, based on the <input> box
   235             // Set up the input capabilities, based on the <input> box
   255             TUint caps = TCoeInputCapabilities::ENavigation;
   236             TUint caps = TCoeInputCapabilities::ENavigation;
   256 
   237 
   257             if ( sc->isInPasswordField() ) {
   238             if ( sc->isInPasswordField() ) {
   258                 caps |= TCoeInputCapabilities::ESecretText;
   239                 caps |= TCoeInputCapabilities::ESecretText;
   259                 UpdateFlagsState(EAknEditorFlagNoT9 | EAknEditorFlagLatinInputModesOnly);
   240                 UpdateFlagsState(EAknEditorFlagNoT9);
   260             }
   241             }
   261             else {
   242             else {
   262 
   243 
   263                 CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
   244                 CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
   264                 if ( state ) {
   245                 if ( state ) {
   325       MFepInlineTextFormatRetriever&,
   306       MFepInlineTextFormatRetriever&,
   326       MFepPointerEventHandlerDuringInlineEdit& /*aPointerEventHandlerDuringInlineEdit*/)
   307       MFepPointerEventHandlerDuringInlineEdit& /*aPointerEventHandlerDuringInlineEdit*/)
   327 {
   308 {
   328     CCoeEnv::Static()->ForEachFepObserverCall(FepObserverHandleStartOfTransactionL);
   309     CCoeEnv::Static()->ForEachFepObserverCall(FepObserverHandleStartOfTransactionL);
   329     ClearInlineText();
   310     ClearInlineText();
   330     m_inlineTextEditingStarted= ETrue;
       
   331     UpdateInlineText(aInitialInlineText);
   311     UpdateInlineText(aInitialInlineText);
   332 }
   312 }
   333 
   313 
   334 // -----------------------------------------------------------------------------
   314 // -----------------------------------------------------------------------------
   335 // UpdateFepInlineTextL
   315 // UpdateFepInlineTextL
   357 //
   337 //
   358 //
   338 //
   359 // -----------------------------------------------------------------------------
   339 // -----------------------------------------------------------------------------
   360 void CWebFepTextEditor::CancelFepInlineEdit()
   340 void CWebFepTextEditor::CancelFepInlineEdit()
   361 {
   341 {
   362     if (IsTextAreaFocused()||IsInputElementFocused()) {
       
   363         if (m_inlineEditText && DocumentLengthForFep() < DocumentMaximumLengthForFep()) {
       
   364             HBufC* tempBuf = HBufC::NewLC(DocumentLengthForFep());
       
   365             TPtr ptr(tempBuf->Des());
       
   366             GetEditorContentForFep(ptr, 0, DocumentLengthForFep());
       
   367             TInt position = ptr.Locate(KLineEnterChar);
       
   368             if(position != KErrNotFound){
       
   369                 TRAP_IGNORE(m_webView->fepTextEditor()->DoCommitFepInlineEditL());
       
   370                 Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
       
   371 				if(frame){
       
   372                 	frame->editor()->execCommand("BackwardDelete");
       
   373 				}
       
   374             }
       
   375             CleanupStack::PopAndDestroy();
       
   376         }
       
   377     }
       
   378 }
   342 }
   379 
   343 
   380 // -----------------------------------------------------------------------------
   344 // -----------------------------------------------------------------------------
   381 // DocumentLengthForFep
   345 // DocumentLengthForFep
   382 //
   346 //
   422 
   386 
   423 	// Override the length if a text format mask is set
   387 	// Override the length if a text format mask is set
   424 	if ( m_textFormatMask && m_textFormatMask->getMultitude() > 0 )
   388 	if ( m_textFormatMask && m_textFormatMask->getMultitude() > 0 )
   425         length = m_textFormatMask->getMultitude();
   389         length = m_textFormatMask->getMultitude();
   426 
   390 
   427     if (IsLongKeyPress() && 
       
   428         (KMaxTInt != length))
       
   429         length += 1 ;
       
   430     // TextArea node has no member function maxLength(), so return KMaxTInt
   391     // TextArea node has no member function maxLength(), so return KMaxTInt
   431     return length;
   392     return length;
   432 }
   393 }
   433 
   394 
   434 // -----------------------------------------------------------------------------
   395 // -----------------------------------------------------------------------------
   440 {
   401 {
   441     // The other part of the rather hackish way to check if we are at the end of the editing field
   402     // The other part of the rather hackish way to check if we are at the end of the editing field
   442     // see WebEditorClient::handleKeypress
   403     // see WebEditorClient::handleKeypress
   443     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   404     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   444     Node*  focusedNode = frame->document()->focusedNode();
   405     Node*  focusedNode = frame->document()->focusedNode();
   445     if ( focusedNode ) {
   406     if ( frame && focusedNode) {
   446         TInt lowPos = aCursorSelection.LowerPos();
   407         TInt lowPos = aCursorSelection.LowerPos();
   447         TInt highPos = aCursorSelection.HigherPos();
   408         TInt highPos = aCursorSelection.HigherPos();
   448         if (focusedNode->hasTagName(HTMLNames::textareaTag)) {
   409         if (focusedNode->hasTagName(HTMLNames::textareaTag)) {
   449             HTMLTextAreaElement* textArea = static_cast<HTMLTextAreaElement*>(focusedNode);
   410             HTMLTextAreaElement* textArea = static_cast<HTMLTextAreaElement*>(focusedNode);
   450             textArea->setSelectionRange(lowPos, highPos);
   411             textArea->setSelectionRange(lowPos, highPos);
   467 {
   428 {
   468     aCursorSelection.SetSelection(0,0);
   429     aCursorSelection.SetSelection(0,0);
   469 
   430 
   470     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   431     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
   471     Node*  focusedNode = frame->document()->focusedNode();
   432     Node*  focusedNode = frame->document()->focusedNode();
   472     if (focusedNode) {
   433     if (frame && focusedNode) {
   473         if (focusedNode->hasTagName(HTMLNames::textareaTag)) {
   434         if (focusedNode->hasTagName(HTMLNames::textareaTag)) {
   474             HTMLTextAreaElement* textArea = static_cast<HTMLTextAreaElement*>(focusedNode);
   435             HTMLTextAreaElement* textArea = static_cast<HTMLTextAreaElement*>(focusedNode);
   475             TInt anchorPos = textArea->selectionStart();
   436             TInt anchorPos = textArea->selectionStart();
   476             TInt cursorPos = textArea->selectionEnd();
   437             TInt cursorPos = textArea->selectionEnd();
   477             aCursorSelection.SetSelection(cursorPos, anchorPos);
   438             aCursorSelection.SetSelection(cursorPos, anchorPos);
   550 		int xPos(0);
   511 		int xPos(0);
   551 		int yPos(0);
   512 		int yPos(0);
   552 		if ( sc ){
   513 		if ( sc ){
   553 			IntRect rect = sc->caretRect();
   514 			IntRect rect = sc->caretRect();
   554 			Node* editNode = sc->focusNode();
   515 			Node* editNode = sc->focusNode();
   555 			if ( editNode && editNode->isTextNode() ) {
   516 			TPoint viewPoint = kit(frame)->frameView()->frameCoordsInViewCoords(editNode->getRect().Rect().iBr);
   556                 TPoint viewPoint = kit(frame)->frameView()->frameCoordsInViewCoords(editNode->getRect().Rect().iBr);
   517 			xPos = viewPoint.iX;
   557 	            xPos = viewPoint.iX;
   518 			yPos = viewPoint.iY;
   558 	            yPos = frame->document()->focusedNode()->getRect().bottomLeft().y() + rect.height();
   519 			String str;
   559 	            
   520 			if ( editNode &&
   560 	            String str;				
   521 				 editNode->isTextNode() ) {
   561 	            WebCore::Text* aText = (WebCore::Text*)editNode;
   522 				WebCore::Text* aText = (WebCore::Text*)editNode;
   562 				str = aText->data();
   523 				str = aText->data();
   563 				aDocumentPosition =  aText->length();
   524 				aDocumentPosition =  aText->length();
   564 				TInt position = aDocumentPosition - ( str.reverseFind(KBlankDesC(), aDocumentPosition )+1);
   525 				TInt position = aDocumentPosition - ( str.reverseFind(KBlankDesC(), aDocumentPosition )+1);
   565 				String word(str);
   526 				String word(str);
   566 				if( position > 0 ){
   527 				if( position > 0 ){
   594         if (frame){
   555         if (frame){
   595             if(IsWapMaskedModeInput(frame)) {
   556             if(IsWapMaskedModeInput(frame)) {
   596                 HandleMaskedInsertText(frame, (String(*m_inlineEditText)));
   557                 HandleMaskedInsertText(frame, (String(*m_inlineEditText)));
   597             }
   558             }
   598             else {
   559             else {
   599                 frame->editor()->insertTextWithoutSendingTextEvent(String(*m_inlineEditText), false);  
   560                 frame->editor()->insertTextWithoutSendingTextEvent(String(*m_inlineEditText), false);
   600             }
   561             }
   601         }
   562         }
   602     }
   563     }
   603     //delete the m_inlineEditText since text is commited
   564     //delete the m_inlineEditText since text is commited
   604     delete m_inlineEditText;
   565     delete m_inlineEditText;
   605     m_inlineEditText = NULL;
   566     m_inlineEditText = NULL;
   606     
       
   607     m_longKeyPress = EFalse;
       
   608     m_inlineTextEditingStarted= EFalse;
       
   609 
   567 
   610     HandleUpdateCursor();
   568     HandleUpdateCursor();
   611     UpdateEditingMode();
   569     UpdateEditingMode();
   612 }
   570 }
   613 
   571 
   675         MFepInlineTextFormatRetriever& aInlineTextFormatRetriever,
   633         MFepInlineTextFormatRetriever& aInlineTextFormatRetriever,
   676         MFepPointerEventHandlerDuringInlineEdit& aPointerEventHandlerDuringInlineEdit)
   634         MFepPointerEventHandlerDuringInlineEdit& aPointerEventHandlerDuringInlineEdit)
   677 {
   635 {
   678     aSetToTrue=ETrue;
   636     aSetToTrue=ETrue;
   679     SetCursorSelectionForFepL(aCursorSelection);
   637     SetCursorSelectionForFepL(aCursorSelection);
   680     m_longKeyPress = ETrue ;
       
   681     StartFepInlineEditL(aInitialInlineText, aPositionOfInsertionPointInInlineText, aCursorVisibility, aCustomDraw, aInlineTextFormatRetriever, aPointerEventHandlerDuringInlineEdit);
   638     StartFepInlineEditL(aInitialInlineText, aPositionOfInsertionPointInInlineText, aCursorVisibility, aCustomDraw, aInlineTextFormatRetriever, aPointerEventHandlerDuringInlineEdit);
   682 }
   639 }
   683 
   640 
   684 // -----------------------------------------------------------------------------
   641 // -----------------------------------------------------------------------------
   685 // SetCursorType
   642 // SetCursorType
   734 void CWebFepTextEditor::UpdateFlagsState(TUint flags)
   691 void CWebFepTextEditor::UpdateFlagsState(TUint flags)
   735 {
   692 {
   736     CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
   693     CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
   737 
   694 
   738     if ( IsTextAreaFocused() ) {
   695     if ( IsTextAreaFocused() ) {
   739 #ifdef BRDO_MULTITOUCH_ENABLED_FF
       
   740     	// If in a TextArea, allow "enter" key presses to be newline/paragraph
   696     	// If in a TextArea, allow "enter" key presses to be newline/paragraph
   741     	state->SetFlags( flags | EAknEditorFlagUseSCTNumericCharmap
   697     	state->SetFlags( flags | EAknEditorFlagUseSCTNumericCharmap
   742      | EAknEditorFlagAllowEntersWithScrollDown | EAknEditorFlagSelectionVisible );
   698     					 | EAknEditorFlagAllowEntersWithScrollDown );
   743 #else
       
   744       state->SetFlags( flags | EAknEditorFlagUseSCTNumericCharmap
       
   745             | EAknEditorFlagAllowEntersWithScrollDown );
       
   746 #endif
       
   747     	}
   699     	}
   748     else {
   700     else {
   749 #ifdef BRDO_MULTITOUCH_ENABLED_FF
   701         state->SetFlags(flags | EAknEditorFlagUseSCTNumericCharmap);
   750         state->SetFlags(flags | EAknEditorFlagUseSCTNumericCharmap | EAknEditorFlagSelectionVisible);
       
   751 #else
       
   752         state->SetFlags(flags | EAknEditorFlagUseSCTNumericCharmap );
       
   753 #endif
       
   754     	}
   702     	}
   755 
   703 
   756     state->ReportAknEdStateEventL(MAknEdStateObserver::EAknEdwinStateFlagsUpdate);
   704     state->ReportAknEdStateEventL(MAknEdStateObserver::EAknEdwinStateFlagsUpdate);
   757     if (m_CcpuSupport)
       
   758     {
       
   759         TRAP_IGNORE(m_CcpuSupport->HandleFocusChangeL());
       
   760     }
       
   761 }
   705 }
   762 
   706 
   763 // -----------------------------------------------------------------------------
   707 // -----------------------------------------------------------------------------
   764 // UpdateInputModeState
   708 // UpdateInputModeState
   765 //
   709 //
   783 
   727 
   784     state->SetDefaultInputMode(inputMode);
   728     state->SetDefaultInputMode(inputMode);
   785     state->SetCurrentInputMode(inputMode);
   729     state->SetCurrentInputMode(inputMode);
   786     state->SetPermittedInputModes(permittedInputModes);
   730     state->SetPermittedInputModes(permittedInputModes);
   787     state->SetNumericKeymap(static_cast<TAknEditorNumericKeymap>(numericKeyMap));
   731     state->SetNumericKeymap(static_cast<TAknEditorNumericKeymap>(numericKeyMap));
       
   732     state->ReportAknEdStateEventL(MAknEdStateObserver::EAknSyncEdwinState);
   788     state->ReportAknEdStateEventL(MAknEdStateObserver::EAknEdwinStateInputModeUpdate);
   733     state->ReportAknEdStateEventL(MAknEdStateObserver::EAknEdwinStateInputModeUpdate);
   789 }
   734 }
   790 
   735 
   791 // -----------------------------------------------------------------------------
   736 // -----------------------------------------------------------------------------
   792 // UpdateCaseState
   737 // UpdateCaseState
   824     // MAknEdStateObserver::EAknCursorPositionChanged
   769     // MAknEdStateObserver::EAknCursorPositionChanged
   825 
   770 
   826     CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
   771     CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
   827     if ( state ) {
   772     if ( state ) {
   828         TRAP_IGNORE( state->ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged ) );
   773         TRAP_IGNORE( state->ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged ) );
   829 		if (m_CcpuSupport)
       
   830 		{
       
   831 			TRAP_IGNORE(m_CcpuSupport->HandleSelectionChangeL());
       
   832 		}
       
   833     }
   774     }
   834 }
   775 }
   835 
   776 
   836 // -----------------------------------------------------------------------------
   777 // -----------------------------------------------------------------------------
   837 // GetStateFromFormatMask
   778 // GetStateFromFormatMask
   850 
   791 
   851         TInt cursorpos = DocumentLengthForFep();
   792         TInt cursorpos = DocumentLengthForFep();
   852         TInputFormatMaskType fm = m_textFormatMask->getInputFormatMaskType(frame, cursorpos);
   793         TInputFormatMaskType fm = m_textFormatMask->getInputFormatMaskType(frame, cursorpos);
   853         if (!cursorpos) {
   794         if (!cursorpos) {
   854             while(fm == EStatic) {
   795             while(fm == EStatic) {
   855                 fm = m_textFormatMask->getInputFormatMaskType(frame, ++cursorpos); 
   796                 fm = m_textFormatMask->getInputFormatMaskType(frame, ++cursorpos);
   856             }
   797             }
   857         }
   798         }
   858         setSCTAvailability(true);
   799         setSCTAvailability(true);
   859         CAknEdwinState* state = static_cast<CAknEdwinState*>(State(KNullUid));
       
   860         switch( fm ) {
   800         switch( fm ) {
   861             case ELeUpSymPuc:       //A any upper case letter or symbolic
   801             case ELeUpSymPuc:       //A any upper case letter or symbolic
   862                 flags = EAknEditorFlagNoT9 | EAknEditorFlagFixedCase;
   802                 flags = EAknEditorFlagNoT9 | EAknEditorFlagFixedCase;
   863                 currentCase = EAknEditorUpperCase;
   803                 currentCase = EAknEditorUpperCase;
   864                 permittedCase = EAknEditorUpperCase;
   804                 permittedCase = EAknEditorUpperCase;
   874             break;
   814             break;
   875             case ELeUpNumSymPuc:    //X any upper case, number or symbolic
   815             case ELeUpNumSymPuc:    //X any upper case, number or symbolic
   876                 flags = EAknEditorFlagNoT9 | EAknEditorFlagFixedCase;
   816                 flags = EAknEditorFlagNoT9 | EAknEditorFlagFixedCase;
   877                 currentCase = EAknEditorUpperCase;
   817                 currentCase = EAknEditorUpperCase;
   878                 permittedCase= EAknEditorUpperCase;
   818                 permittedCase= EAknEditorUpperCase;
   879                 inputMode = state->CurrentInputMode();
   819                 inputMode = EAknEditorTextInputMode;
   880                 permittedInputModes= EAknEditorTextInputMode;
   820                 permittedInputModes= EAknEditorTextInputMode;
   881             break;
   821             break;
   882             case ELeLoNumSymPuc:    //x any lower case, number or symbolic
   822             case ELeLoNumSymPuc:    //x any lower case, number or symbolic
   883                 flags = EAknEditorFlagNoT9 | EAknEditorFlagFixedCase;
   823                 flags = EAknEditorFlagNoT9 | EAknEditorFlagFixedCase;
   884                 currentCase = EAknEditorLowerCase;
   824                 currentCase = EAknEditorLowerCase;
   885                 permittedCase= EAknEditorLowerCase;
   825                 permittedCase= EAknEditorLowerCase;
   886                 inputMode = state->CurrentInputMode();
   826                 inputMode = EAknEditorTextInputMode;
   887                 permittedInputModes= EAknEditorTextInputMode | EAknEditorNumericInputMode;
   827                 permittedInputModes= EAknEditorTextInputMode | EAknEditorNumericInputMode;
   888             break;
   828             break;
   889             case EAnyLow:           //m any lower character can be changed to upper
   829             case EAnyLow:           //m any lower character can be changed to upper
   890                 flags = EAknEditorFlagNoT9;
   830                 flags = EAknEditorFlagNoT9;
   891                 currentCase = EAknEditorLowerCase;
   831                 currentCase = EAknEditorLowerCase;
   926             return EFalse;
   866             return EFalse;
   927         }
   867         }
   928 
   868 
   929         return ETrue;
   869         return ETrue;
   930     }
   870     }
   931 	else {
       
   932     setSCTAvailability(true);
       
   933     }
       
   934 
   871 
   935     return EFalse;
   872     return EFalse;
   936 }
   873 }
   937 
   874 
   938 // -----------------------------------------------------------------------------
   875 // -----------------------------------------------------------------------------
   966 
   903 
   967         if (!m_textFormatMask->checkText(input->value(), eb)) {
   904         if (!m_textFormatMask->checkText(input->value(), eb)) {
   968             style->setProperty(CSS_PROP_COLOR, "red", false, ec);
   905             style->setProperty(CSS_PROP_COLOR, "red", false, ec);
   969             return false;
   906             return false;
   970         }
   907         }
   971         else if ( m_textFormatMask->acceptAll() )
       
   972         {
       
   973             return true;
       
   974         }
       
   975         else
   908         else
   976         {
   909         {
   977             style->setProperty(CSS_PROP_COLOR, m_inputTextColor, false, ec);
   910             style->setProperty(CSS_PROP_COLOR, m_inputTextColor, false, ec);
   978             UpdateEditingMode();
   911             CancelEditingMode();
   979             return true;
   912             return true;
   980         }
   913         }
   981     }
   914     }
   982     else if ( n->hasTagName(HTMLNames::textareaTag)) {
   915     else if ( n->hasTagName(HTMLNames::textareaTag)) {
   983         CancelEditingMode();
   916         CancelEditingMode();
  1120 //
  1053 //
  1121 //
  1054 //
  1122 // -----------------------------------------------------------------------------
  1055 // -----------------------------------------------------------------------------
  1123 TBool CWebFepTextEditor::CcpuIsFocused() const
  1056 TBool CWebFepTextEditor::CcpuIsFocused() const
  1124 {
  1057 {
  1125     return (IsTextAreaFocused() || IsInputElementFocused());
  1058     return ETrue;
  1126 }
  1059 }
  1127 
  1060 
  1128 // -----------------------------------------------------------------------------
  1061 // -----------------------------------------------------------------------------
  1129 // CcpuCanCut
  1062 // CcpuCanCut
  1130 //
  1063 //
  1132 // -----------------------------------------------------------------------------
  1065 // -----------------------------------------------------------------------------
  1133 TBool CWebFepTextEditor::CcpuCanCut() const
  1066 TBool CWebFepTextEditor::CcpuCanCut() const
  1134 {
  1067 {
  1135     TCursorSelection selection;
  1068     TCursorSelection selection;
  1136     GetCursorSelectionForFep(selection);
  1069     GetCursorSelectionForFep(selection);
  1137     return m_CcpuSupport && selection.Length();
  1070     return selection.Length();
  1138 }
  1071 }
  1139 
  1072 
  1140 // -----------------------------------------------------------------------------
  1073 // -----------------------------------------------------------------------------
  1141 // CcpuCutL
  1074 // CcpuCutL
  1142 //
  1075 //
  1145 void CWebFepTextEditor::CcpuCutL()
  1078 void CWebFepTextEditor::CcpuCutL()
  1146 {
  1079 {
  1147     PlaceDataOnClipboardL();
  1080     PlaceDataOnClipboardL();
  1148     TCursorSelection selection;
  1081     TCursorSelection selection;
  1149     GetCursorSelectionForFep(selection);
  1082     GetCursorSelectionForFep(selection);
  1150     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
       
  1151     if (frame) {      
       
  1152         frame->editor()->deleteWithDirection(SelectionController::BACKWARD,
       
  1153             CharacterGranularity, false, true);
       
  1154         }
       
  1155     HandleUpdateCursor();
       
  1156 }
  1083 }
  1157 
  1084 
  1158 // -----------------------------------------------------------------------------
  1085 // -----------------------------------------------------------------------------
  1159 // CcpuCanCopy
  1086 // CcpuCanCopy
  1160 //
  1087 //
  1162 // -----------------------------------------------------------------------------
  1089 // -----------------------------------------------------------------------------
  1163 TBool CWebFepTextEditor::CcpuCanCopy() const
  1090 TBool CWebFepTextEditor::CcpuCanCopy() const
  1164 {
  1091 {
  1165     TCursorSelection selection;
  1092     TCursorSelection selection;
  1166     GetCursorSelectionForFep(selection);
  1093     GetCursorSelectionForFep(selection);
  1167     return m_CcpuSupport && selection.Length();
  1094     return selection.Length();
  1168 }
  1095 }
  1169 
  1096 
  1170 // -----------------------------------------------------------------------------
  1097 // -----------------------------------------------------------------------------
  1171 // CcpuCopyL
  1098 // CcpuCopyL
  1172 //
  1099 //
  1173 //
  1100 //
  1174 // -----------------------------------------------------------------------------
  1101 // -----------------------------------------------------------------------------
  1175 void CWebFepTextEditor::CcpuCopyL()
  1102 void CWebFepTextEditor::CcpuCopyL()
  1176 {
  1103 {
  1177     PlaceDataOnClipboardL();
  1104     PlaceDataOnClipboardL();
  1178     if (m_CcpuSupport)
       
  1179        m_CcpuSupport->HandleSelectionChangeL();
       
  1180 }
  1105 }
  1181 
  1106 
  1182 // -----------------------------------------------------------------------------
  1107 // -----------------------------------------------------------------------------
  1183 // CcpuCanPaste
  1108 // CcpuCanPaste
  1184 //
  1109 //
  1185 //
  1110 //
  1186 // -----------------------------------------------------------------------------
  1111 // -----------------------------------------------------------------------------
  1187 TBool CWebFepTextEditor::CcpuCanPaste() const
  1112 TBool CWebFepTextEditor::CcpuCanPaste() const
  1188 {
  1113 {
  1189     TRAPD(err, DoCcpuCanPasteL());
  1114     TRAPD(err, DoCcpuCanPasteL());
  1190     return (err == KErrNone) && m_CcpuSupport;
  1115     return err == KErrNone;
  1191 }
  1116 }
  1192 
  1117 
  1193 // -----------------------------------------------------------------------------
  1118 // -----------------------------------------------------------------------------
  1194 // CcpuPasteL
  1119 // CcpuPasteL
  1195 //
  1120 //
  1204 // DoCcpuCanPasteL
  1129 // DoCcpuCanPasteL
  1205 //
  1130 //
  1206 //
  1131 //
  1207 // -----------------------------------------------------------------------------
  1132 // -----------------------------------------------------------------------------
  1208 void  CWebFepTextEditor::DoCcpuCanPasteL() const
  1133 void  CWebFepTextEditor::DoCcpuCanPasteL() const
  1209 {
  1134 { 
  1210     CClipboard* cb=CClipboard::NewForReadingL(CCoeEnv::Static()->FsSession());
  1135     CClipboard* cb=CClipboard::NewForReadingL(CCoeEnv::Static()->FsSession());
  1211     CleanupStack::PushL(cb);
  1136     CleanupStack::PushL(cb);
  1212     TStreamId streamId=cb->StreamDictionary().At(KClipboardUidTypePlainText);
  1137     TStreamId streamId=cb->StreamDictionary().At(KClipboardUidTypePlainText);
  1213     if (streamId==KNullStreamId)
  1138     if (streamId==KNullStreamId)
  1214         User::Leave(KErrNotFound);
  1139         User::Leave(KErrNotFound);
  1255     CleanupStack::PopAndDestroy();
  1180     CleanupStack::PopAndDestroy();
  1256 }
  1181 }
  1257 
  1182 
  1258 // -----------------------------------------------------------------------------
  1183 // -----------------------------------------------------------------------------
  1259 // HandleMaskedInsertText
  1184 // HandleMaskedInsertText
  1260 // 
  1185 //
  1261 // 
  1186 //
  1262 // -----------------------------------------------------------------------------
  1187 // -----------------------------------------------------------------------------
  1263 void CWebFepTextEditor::HandleMaskedInsertText(WebCore::Frame *frame, const String& text)
  1188 void CWebFepTextEditor::HandleMaskedInsertText(WebCore::Frame *frame, const String& text)
  1264 {
  1189 {
  1265     TInt pos = DocumentLengthForFep();
  1190     TInt pos = DocumentLengthForFep();
  1266     if (!pos) {
  1191     if (!pos) {
  1288 }
  1213 }
  1289 
  1214 
  1290 // -----------------------------------------------------------------------------
  1215 // -----------------------------------------------------------------------------
  1291 // HandleMaskedDeleteText
  1216 // HandleMaskedDeleteText
  1292 //
  1217 //
  1293 //  
  1218 //
  1294 // -----------------------------------------------------------------------------
  1219 // -----------------------------------------------------------------------------
  1295 void CWebFepTextEditor::HandleMaskedDeleteText(WebCore::Frame* frame)
  1220 void CWebFepTextEditor::HandleMaskedDeleteText(WebCore::Frame* frame)
  1296 {
  1221 {
  1297     TCursorSelection selection;
  1222     TCursorSelection selection;
  1298     GetCursorSelectionForFep(selection);
  1223     GetCursorSelectionForFep(selection);
  1310 }
  1235 }
  1311 
  1236 
  1312 // -----------------------------------------------------------------------------
  1237 // -----------------------------------------------------------------------------
  1313 // IsWapMaskedModeInput
  1238 // IsWapMaskedModeInput
  1314 //
  1239 //
  1315 //  
  1240 //
  1316 // -----------------------------------------------------------------------------
  1241 // -----------------------------------------------------------------------------
  1317 bool CWebFepTextEditor::IsWapMaskedModeInput(WebCore::Frame* frame)
  1242 bool CWebFepTextEditor::IsWapMaskedModeInput(WebCore::Frame* frame)
  1318 {
  1243 {
  1319     bool maskedInput(false);
  1244     bool maskedInput(false);
  1320     if (m_textFormatMask && frame->document() && frame->document()->focusedNode()) { 
  1245     if (m_textFormatMask && frame->document() && frame->document()->focusedNode()) {
  1321         RenderStyle* s = frame->document()->focusedNode()->renderStyle();
  1246         RenderStyle* s = frame->document()->focusedNode()->renderStyle();
  1322         if (s && (!s->wapInputFormat().isEmpty() || s->wapInputRequired())){            
  1247         if (s && (!s->wapInputFormat().isEmpty() || s->wapInputRequired())){
  1323             maskedInput = true;
  1248             maskedInput = true;
  1324         }
  1249         }
  1325     }
  1250     }
  1326     return maskedInput;
  1251     return maskedInput;
  1327 }
  1252 }
  1391 // -----------------------------------------------------------------------------
  1316 // -----------------------------------------------------------------------------
  1392 // EnableCcpu
  1317 // EnableCcpu
  1393 //
  1318 //
  1394 //
  1319 //
  1395 // -----------------------------------------------------------------------------
  1320 // -----------------------------------------------------------------------------
  1396 void CWebFepTextEditor::EnableCcpuL()
  1321 void CWebFepTextEditor::EnableCcpu(TBool aSupport)
  1397 {
  1322 {
  1398     CAknCcpuSupport* ccpu = NULL;
       
  1399     CAknEdwinState* edwinState = static_cast<CAknEdwinState*>(this->State(KNullUid));
  1323     CAknEdwinState* edwinState = static_cast<CAknEdwinState*>(this->State(KNullUid));
  1400     if ( edwinState && edwinState->MenuBar() && edwinState->MenuBar()->IsDisplayed() )
  1324     if(aSupport)
  1401         {
  1325         {
  1402         return;
  1326         edwinState->SetCcpuState(this);
  1403         }
  1327         }
  1404     ccpu = new(ELeave) CAknCcpuSupport(this);
  1328     else
  1405     ccpu->SetMopParent(this);
       
  1406     CleanupStack::PushL(ccpu);
       
  1407     ccpu->ConstructL();
       
  1408     CleanupStack::Pop(ccpu);
       
  1409     delete m_CcpuSupport;
       
  1410     m_CcpuSupport = ccpu;
       
  1411     if (edwinState)
       
  1412         {
  1329         {
  1413         edwinState->SetCcpuState(this);    
  1330         edwinState->SetCcpuState(NULL);
  1414         edwinState->SetMenu();
  1331         }
  1415         if (edwinState->MenuBar())
       
  1416             edwinState->MenuBar()->SetEditMenuObserver( m_CcpuSupport );
       
  1417         }        
       
  1418 }
  1332 }
  1419 
  1333 
  1420 // -----------------------------------------------------------------------------
  1334 // -----------------------------------------------------------------------------
  1421 // findPrevSiblingTextLen
  1335 // findPrevSiblingTextLen
  1422 //
  1336 //
  1481 }
  1395 }
  1482 
  1396 
  1483 // -----------------------------------------------------------------------------
  1397 // -----------------------------------------------------------------------------
  1484 // SetSCTAvailability
  1398 // SetSCTAvailability
  1485 //
  1399 //
  1486 // Set availibility of the special character table. 
  1400 // Set availibility of the special character table.
  1487 // -----------------------------------------------------------------------------
  1401 // -----------------------------------------------------------------------------
  1488 void CWebFepTextEditor::setSCTAvailability(bool aAvailable)
  1402 void CWebFepTextEditor::setSCTAvailability(bool aAvailable)
  1489 {
  1403 {
  1490     if (m_ExtendedInputCapabilities) {
  1404     if (m_ExtendedInputCapabilities) {
  1491         TUint capabilities = m_ExtendedInputCapabilities->Capabilities();
  1405         TUint capabilities = m_ExtendedInputCapabilities->Capabilities();
  1497         }
  1411         }
  1498         m_ExtendedInputCapabilities->SetCapabilities(capabilities);
  1412         m_ExtendedInputCapabilities->SetCapabilities(capabilities);
  1499     }
  1413     }
  1500 }
  1414 }
  1501 
  1415 
  1502 // -----------------------------------------------------------------------------
       
  1503 // IsLongKeyPress
       
  1504 //
       
  1505 // Called to know the status of the key pressed 
       
  1506 // -----------------------------------------------------------------------------
       
  1507 TBool CWebFepTextEditor::IsLongKeyPress() const
       
  1508     {
       
  1509     return m_longKeyPress ;	
       
  1510     }
       
  1511 
       
  1512 TBool CWebFepTextEditor::IsInputElementFocused() const
       
  1513     {
       
  1514     Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame();
       
  1515     return ( frame && frame->document()->focusedNode() &&
       
  1516              frame->document()->focusedNode()->hasTagName(HTMLNames::inputTag));
       
  1517     }
       
  1518 
       
  1519 void CWebFepTextEditor::ReportEventL()
       
  1520     {
       
  1521     m_ExtendedInputCapabilities->ReportEventL(CAknExtendedInputCapabilities::
       
  1522                         MAknEventObserver::EPointerEventReceived, NULL );
       
  1523     }
       
  1524 
       
  1525 TBool CWebFepTextEditor::inlineTextEditingStarted()
       
  1526     {
       
  1527     return m_inlineTextEditingStarted; 
       
  1528     }
       
  1529