webengine/osswebengine/webkit/s60/webview/BrCtlLayoutObserverImpl.cpp
branchRCL_3
changeset 49 919f36ff910f
parent 38 4917f9bf7995
equal deleted inserted replaced
48:79859ed3eea9 49:919f36ff910f
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Handle scrollbar and tab events
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  INCLUDES
       
    20 
       
    21 #include <../bidi.h>
       
    22 #include "BrCtlLayoutObserverImpl.h"
       
    23 #include "WebView.h"
       
    24 #include "WebFrame.h"
       
    25 #include "WebFrameView.h"
       
    26 #include "BrCtl.h"
       
    27 
       
    28 #include "Page.h"
       
    29 #include "FocusController.h"
       
    30 #include "Frame.h"
       
    31 #include <wtf/RefPtr.h>
       
    32 
       
    33 using namespace WebCore;
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CBrCtlLayoutObserver::CBrCtlLayoutObserver
       
    37 // C++ default constructor can NOT contain any code, that
       
    38 // might leave.
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 CBrCtlLayoutObserver::CBrCtlLayoutObserver( WebView* aWebView)
       
    42                   : m_webView(aWebView)
       
    43     {
       
    44 
       
    45     }
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CBrCtlLayoutObserver::NotifyLayoutChange
       
    49 // Inform the layout of the page: right to left or left to right. 
       
    50 // Useful when the application draws the scrollbar itself.
       
    51 // -----------------------------------------------------------------------------
       
    52 //                    
       
    53 void CBrCtlLayoutObserver::NotifyLayoutChange( TBrCtlLayout aNewLayout ) 
       
    54     {
       
    55     if(!m_webView)
       
    56     return;
       
    57 
       
    58     TSize contentSize = m_webView->mainFrame()->frameView()->contentSize();
       
    59 
       
    60     switch(aNewLayout)
       
    61       {
       
    62       case EOriginTopRight:
       
    63            m_webView->mainFrame()->frameView()->scrollTo(TPoint(contentSize.iWidth,0));
       
    64            break;
       
    65 
       
    66      case EOriginTopLeft:
       
    67           {
       
    68           TPoint ptInit(0,0);
       
    69           TPoint ptFromHistory = m_webView->brCtl()->historyHandler()->historyController()->currentEntryPosition();
       
    70           TPoint ptCurr = m_webView->mainFrame()->frameView()->contentPos();
       
    71 
       
    72           if ( ptCurr != ptFromHistory ) {
       
    73               if ( ptInit == ptCurr ) {
       
    74                   m_webView->mainFrame()->frameView()->scrollTo(ptFromHistory);
       
    75                   }
       
    76              else{
       
    77                   m_webView->mainFrame()->frameView()->scrollTo(TPoint(0,0));
       
    78                  }
       
    79             }
       
    80           }
       
    81           break;
       
    82 
       
    83       default:
       
    84           break;
       
    85       }
       
    86     }