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