|     24  |     24  | 
|     25 #include "Widget.h" |     25 #include "Widget.h" | 
|     26 #include "WidgetFuncs.h" |     26 #include "WidgetFuncs.h" | 
|     27 #include "WidgetCallbacks.h" |     27 #include "WidgetCallbacks.h" | 
|     28 #include "WidgetEventHandler.h" |     28 #include "WidgetEventHandler.h" | 
|         |     29 #include "WidgetJSObjectProtector.h" | 
|     29 #include "Wrt.h" |     30 #include "Wrt.h" | 
|     30  |     31  | 
|     31 // EXTERNAL DATA STRUCTURES |     32 // EXTERNAL DATA STRUCTURES | 
|     32  |     33  | 
|     33 // EXTERNAL FUNCTION PROTOTYPES |     34 // EXTERNAL FUNCTION PROTOTYPES | 
|     46 using namespace KJS; |     47 using namespace KJS; | 
|     47 const ClassInfo JSWidget::info = { "JSWidget", 0, &WidgetTable, 0 }; |     48 const ClassInfo JSWidget::info = { "JSWidget", 0, &WidgetTable, 0 }; | 
|     48  |     49  | 
|     49 // ============================= LOCAL FUNCTIONS =============================== |     50 // ============================= LOCAL FUNCTIONS =============================== | 
|     50 /* |     51 /* | 
|     51 @begin WidgetTable 16 |     52 @begin WidgetTable 17 | 
|     52     openApplication JSWidget::openApplication DontDelete|Function 1 |     53     openApplication JSWidget::openApplication DontDelete|Function 1 | 
|     53     openURL JSWidget::openURL DontDelete|Function 1 |     54     openURL JSWidget::openURL DontDelete|Function 1 | 
|     54     preferenceForKey JSWidget::preferenceForKey DontDelete|Function 1 |     55     preferenceForKey JSWidget::preferenceForKey DontDelete|Function 1 | 
|     55     prepareForTransition JSWidget::prepareForTransition DontDelete|Function 1 |     56     prepareForTransition JSWidget::prepareForTransition DontDelete|Function 1 | 
|     56     performTransition JSWidget::performTransition DontDelete|Function 0 |     57     performTransition JSWidget::performTransition DontDelete|Function 0 | 
|     57     setPreferenceForKey JSWidget::setPreferenceForKey DontDelete|Function 2 |     58     setPreferenceForKey JSWidget::setPreferenceForKey DontDelete|Function 2 | 
|     58     setNavigationEnabled JSWidget::setNavigationEnabled DontDelete|Function 1 |     59     setNavigationEnabled JSWidget::setNavigationEnabled DontDelete|Function 1 | 
|         |     60     setNavigationType JSWidget::setNavigationType DontDelete|Function 1 | 
|     59     identifier JSWidget::identifier DontDelete|ReadOnly |     61     identifier JSWidget::identifier DontDelete|ReadOnly | 
|     60     onhide JSWidget::onhide DontDelete|ReadOnly |     62     onhide JSWidget::onhide DontDelete|ReadOnly | 
|     61     onremove JSWidget::onremove DontDelete|ReadOnly |     63     onremove JSWidget::onremove DontDelete|ReadOnly | 
|     62     onshow  JSWidget::onshow DontDelete|ReadOnly |     64     onshow  JSWidget::onshow DontDelete|ReadOnly | 
|     63     onexit  JSWidget::onexit DontDelete|ReadOnly |     65     onexit  JSWidget::onexit DontDelete|ReadOnly | 
|     74 // JSWidget::JSWidget |     76 // JSWidget::JSWidget | 
|     75 // |     77 // | 
|     76 // |     78 // | 
|     77 // |     79 // | 
|     78 // ---------------------------------------------------------------------------- |     80 // ---------------------------------------------------------------------------- | 
|     79 JSWidget::JSWidget(MJSWidgetCallbacks* aWidgetCallbacks) : |     81 JSWidget::JSWidget(MJSWidgetCallbacks* aWidgetCallbacks, MJSObjectProtector* aProtector) : | 
|     80                     JSObject(), |     82                     JSObject(), | 
|     81                     d(new WidgetPrivate(aWidgetCallbacks,0,0,0,0)) |     83                     d(new WidgetPrivate(aWidgetCallbacks,0,0,0,0, aProtector)) | 
|     82 { |     84 { | 
|     83 } |     85 } | 
|     84  |     86  | 
|     85 // ---------------------------------------------------------------------------- |     87 // ---------------------------------------------------------------------------- | 
|     86 // JSWidget::~JSWidget |     88 // JSWidget::~JSWidget | 
|    163         case preferenceForKey: |    165         case preferenceForKey: | 
|    164         case prepareForTransition: |    166         case prepareForTransition: | 
|    165         case performTransition: |    167         case performTransition: | 
|    166         case setPreferenceForKey: |    168         case setPreferenceForKey: | 
|    167         case setNavigationEnabled: |    169         case setNavigationEnabled: | 
|         |    170         case setNavigationType: | 
|    168         case setDisplayLandscape: |    171         case setDisplayLandscape: | 
|    169         case setDisplayPortrait: { |    172         case setDisplayPortrait: { | 
|    170             JSWidgetFunc *wf = new JSWidgetFunc(exec,token,d->m_callbacks); |    173             JSWidgetFunc *wf = new JSWidgetFunc(exec,token,d->m_callbacks); | 
|    171             return wf; |    174             return wf; | 
|    172         } |    175         } | 
|    209     if (entry) { |    212     if (entry) { | 
|    210         switch( entry->value ) { |    213         switch( entry->value ) { | 
|    211             case onhide: { |    214             case onhide: { | 
|    212                 delete d->m_hideCallback; |    215                 delete d->m_hideCallback; | 
|    213                 d->m_hideCallback = NULL; |    216                 d->m_hideCallback = NULL; | 
|    214                 d->m_hideCallback = new WidgetEventHandler(value, exec->lexicalInterpreter()->globalExec()); |    217                 d->m_hideCallback = new WidgetEventHandler(value, exec->lexicalInterpreter()->globalExec(), d->m_protector); | 
|    215                 break; |    218                 break; | 
|    216             } |    219             } | 
|    217             case onshow: { |    220             case onshow: { | 
|    218                 delete d->m_showCallback; |    221                 delete d->m_showCallback; | 
|    219                 d->m_showCallback = NULL; |    222                 d->m_showCallback = NULL; | 
|    220                 d->m_showCallback = new WidgetEventHandler(value, exec->lexicalInterpreter()->globalExec()); |    223                 d->m_showCallback = new WidgetEventHandler(value, exec->lexicalInterpreter()->globalExec(), d->m_protector); | 
|    221                 // fire the onShow if the SetVisibilty was called before the onShowCallback was created |    224                 // fire the onShow if the SetVisibilty was called before the onShowCallback was created | 
|    222                 if (d->m_visibility) { |    225                 if (d->m_visibility) { | 
|    223                     d->m_visibility = !d->m_visibility; |    226                     d->m_visibility = !d->m_visibility; | 
|    224                     setVisibility(!d->m_visibility); |    227                     setVisibility(!d->m_visibility); | 
|    225                 } |    228                 } | 
|    226                 break; |    229                 break; | 
|    227             } |    230             } | 
|    228             case onexit: { |    231             case onexit: { | 
|    229                 delete d->m_exitCallback; |    232                 delete d->m_exitCallback; | 
|    230                 d->m_exitCallback = NULL; |    233                 d->m_exitCallback = NULL; | 
|    231                 d->m_exitCallback = new WidgetEventHandler(value, exec->lexicalInterpreter()->globalExec()); |    234                 d->m_exitCallback = new WidgetEventHandler(value, exec->lexicalInterpreter()->globalExec(), d->m_protector); | 
|    232                 break; |    235                 break; | 
|    233             } |    236             } | 
|    234             default: |    237             default: | 
|    235                 break; |    238                 break; | 
|    236         } |    239         } |