94
|
1 |
/*
|
|
2 |
* Copyright (c) 2003-2004 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: Handles the display of the box tree
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
//lint -save -e578 -e1707 static assumed for operator new, Declaration of symbol hides symbol
|
|
21 |
#include <e32def.h> // To avoid NULL redefine warning (no #ifndef NULL)
|
|
22 |
#include <aknappui.h>
|
|
23 |
#include <aknmessagequerydialog.h>
|
|
24 |
#include <apgcli.h>
|
|
25 |
#include <badesca.h>
|
|
26 |
#include <eiksbfrm.h>
|
|
27 |
#include <eikspane.h>
|
|
28 |
#include <FeatMgr.h>
|
|
29 |
#include <f32file.h>
|
|
30 |
#include <flogger.h>
|
|
31 |
#include <stddef.h>
|
|
32 |
|
|
33 |
#include <CenRepNotifyHandler.h>
|
|
34 |
#include <centralrepository.h>
|
|
35 |
#include <httpcachemanagerinternalcrkeys.h>
|
|
36 |
|
|
37 |
#include <stringloader.h>
|
|
38 |
#include <webkit.rsg>
|
|
39 |
|
|
40 |
#include <brctlinterface.h>
|
|
41 |
|
|
42 |
#include "BoxFormatHandler.h"
|
|
43 |
#include "BoxRender.h"
|
|
44 |
#include "BrCtl.h"
|
|
45 |
#include "BrsrStatusCodes.h"
|
|
46 |
#include "CBrowserSettings.h"
|
|
47 |
#include "GDIDeviceContext.h"
|
|
48 |
#include "LMgrMarkerText.h"
|
|
49 |
#include "LMgrMarkerImage.h"
|
|
50 |
#include "LMgrAnonBlock.h"
|
|
51 |
#include "LMgrObjectBoxOOC.h"
|
|
52 |
#include "LMgrObjectBox.h"
|
|
53 |
#include "MVCScroll.h"
|
|
54 |
#include "MVCShell.h"
|
|
55 |
#include "MVCView.h"
|
|
56 |
#include "MVCViewAsyncInit.h"
|
|
57 |
#include "MVCViewListener.h"
|
|
58 |
#include "nw_adt_resizablevector.h"
|
|
59 |
#include "nwx_cleanup_epoc32.h"
|
|
60 |
#include "nwx_ctx.h"
|
|
61 |
#include "nwx_defs_symbian.h"
|
|
62 |
#include "nw_evt_accesskeyevent.h"
|
|
63 |
#include "nw_evt_activateevent.h"
|
|
64 |
#include "nw_evt_clearfieldevent.h"
|
|
65 |
#include "nw_evt_controlkeyevent.h"
|
|
66 |
#include "nw_evt_fontsizechangeevent.h"
|
|
67 |
#include "nw_evt_focusevent.h"
|
|
68 |
#include "nw_evt_keyevent.h"
|
|
69 |
#include "nw_evt_openviewerevent.h"
|
|
70 |
#include "nw_evt_scrollevent.h"
|
|
71 |
#include "nw_evt_tabevent.h"
|
|
72 |
#include "nw_evt_unicodekeyevent.h"
|
|
73 |
#include "nw_fbox_buttonbox.h"
|
|
74 |
#include "nw_fbox_inputbox.h"
|
|
75 |
#include "nw_fbox_formbox.h"
|
|
76 |
#include "nw_fbox_formboxutils.h"
|
|
77 |
#include "nw_fbox_checkbox.h"
|
|
78 |
#include "nw_fbox_WmlFormattedEditor.h"
|
|
79 |
#include "nw_fbox_radiobox.h"
|
|
80 |
#include "nw_fbox_epoc32inputskin.h"
|
|
81 |
#include "nw_fbox_selectbox.h"
|
|
82 |
#include "nw_fbox_textareabox.h"
|
|
83 |
#include "nw_fbox_imagebuttonbox.h"
|
|
84 |
#include "nw_fbox_fileselectionbox.h"
|
|
85 |
#include "nw_hed_documentroot.h"
|
|
86 |
#include "nw_hed_iimageviewer.h"
|
|
87 |
#include "nw_image_epoc32simpleimage.h"
|
|
88 |
#include "nw_image_virtualimage.h"
|
|
89 |
#include "nw_lmgr_imagebox.h"
|
|
90 |
#include "nw_lmgr_animatedimagebox.h"
|
|
91 |
#include "nw_lmgr_box.h"
|
|
92 |
#include "nw_lmgr_boxvisitor.h"
|
|
93 |
#include "nw_lmgr_cssproperties.h"
|
|
94 |
#include "nw_lmgr_activecontainerbox.h"
|
|
95 |
#include "nw_lmgr_statictablecellbox.h"
|
|
96 |
#include "nw_lmgr_verticaltablecellbox.h"
|
|
97 |
#include "nw_lmgr_rootbox.h"
|
|
98 |
#include "nw_lmgr_areabox.h"
|
|
99 |
#include "nw_lmgr_accesskey.h"
|
|
100 |
#include "nw_lmgr_eventhandler.h"
|
|
101 |
#include "nw_lmgr_textbox.h"
|
|
102 |
#include "nw_lmgr_slavepropertylist.h"
|
|
103 |
#include "nw_lmgr_simplepropertylist.h"
|
|
104 |
#include "nw_lmgr_verticaltablebox.h"
|
|
105 |
#include "nw_lmgr_statictablebox.h"
|
|
106 |
#include "nw_lmgr_imagemapbox.h"
|
|
107 |
#include "nw_lmgr_animatedimagebox.h"
|
|
108 |
#include "nw_lmgr_areabox.h"
|
|
109 |
#include "nw_object_object.h"
|
|
110 |
#include "nw_system_optionlist.h"
|
|
111 |
#include "nw_xhtml_savetophonebkevent.h"
|
|
112 |
#include "nw_xhtml_xhtmlcontenthandler.h"
|
|
113 |
#include "nw_xhtml_attributepropertytable.h"
|
|
114 |
#include "nwx_http_defs.h"
|
|
115 |
#include "nwx_logger.h"
|
|
116 |
#include "nwx_math.h"
|
|
117 |
#include "nwx_settings.h"
|
|
118 |
|
|
119 |
#include "TEncodingMapping.h"
|
|
120 |
#include "urlloader_urlloaderint.h"
|
|
121 |
|
|
122 |
#include "HistoryController.h"
|
|
123 |
#include "WmlInterface.h"
|
|
124 |
//lint -restore
|
|
125 |
#include "pagescaler.h"
|
|
126 |
|
|
127 |
#include "nw_lmgr_posflowbox.h"
|
|
128 |
|
|
129 |
#ifdef __WINS__
|
|
130 |
#ifdef _DEBUG
|
|
131 |
//#define _DEBUG_LOG
|
|
132 |
#ifdef _DEBUG_LOG
|
|
133 |
NW_LMGR_EXPORT
|
|
134 |
TBrowserStatusCode
|
|
135 |
NW_LMgr_Box_DumpBoxTree(NW_LMgr_Box_t* box);
|
|
136 |
#endif /* DEBUG_LOG */
|
|
137 |
#endif /* DEBUG */
|
|
138 |
#endif /* WINS */
|
|
139 |
|
|
140 |
//CONSTANT
|
|
141 |
const TInt KPeriodicTimerStartInterval2Sec(750000);
|
|
142 |
// ============================= PRIVATE FUNCTIONS ===============================
|
|
143 |
NW_Bool
|
|
144 |
CView::ProcessFontSizeChangeEvent ()
|
|
145 |
{
|
|
146 |
iDeviceContext->SetFontSizeLevel();
|
|
147 |
|
|
148 |
return NW_TRUE;
|
|
149 |
}
|
|
150 |
|
|
151 |
NW_GDI_Rectangle_t
|
|
152 |
CView::GetBoxDisplayBounds(NW_LMgr_Box_t* aBox )
|
|
153 |
{
|
|
154 |
NW_GDI_Rectangle_t boxBounds;
|
|
155 |
|
|
156 |
if (NW_Object_IsClass( aBox, &NW_LMgr_AreaBox_Class))
|
|
157 |
{
|
|
158 |
boxBounds = NW_LMgr_AreaBox_GetBounds( aBox );
|
|
159 |
}
|
|
160 |
else
|
|
161 |
{
|
|
162 |
boxBounds = NW_LMgr_Box_GetDisplayBounds( aBox );
|
|
163 |
}
|
|
164 |
return boxBounds;
|
|
165 |
}
|
|
166 |
|
|
167 |
void
|
|
168 |
CView::SetBoxFormatBounds( NW_LMgr_Box_t* aBox, NW_GDI_Rectangle_t aBoxBounds )
|
|
169 |
{
|
|
170 |
if (NW_Object_IsClass( aBox, &NW_LMgr_AreaBox_Class))
|
|
171 |
{
|
|
172 |
// set area box is not supported
|
|
173 |
NW_ASSERT( 0 );
|
|
174 |
}
|
|
175 |
else
|
|
176 |
{
|
|
177 |
NW_LMgr_Box_SetFormatBounds( aBox, aBoxBounds );
|
|
178 |
}
|
|
179 |
}
|
|
180 |
|
|
181 |
/*
|
|
182 |
This is a fix for version 2.8. For 3.0, we have to do more check for the position absolute, otherwise, it will break the
|
|
183 |
absolute position.
|
|
184 |
*/
|
|
185 |
void CView::GetParentBox(NW_LMgr_Box_t* parentBox, NW_LMgr_Box_t** pReturnedParentBox)
|
|
186 |
{
|
|
187 |
if(parentBox == NULL) {
|
|
188 |
return;
|
|
189 |
}
|
|
190 |
|
|
191 |
if (NW_Object_IsInstanceOf(parentBox, &NW_LMgr_FlowBox_Class))
|
|
192 |
{
|
|
193 |
if(*pReturnedParentBox == NULL) {
|
|
194 |
*pReturnedParentBox = parentBox;
|
|
195 |
}
|
|
196 |
}
|
|
197 |
|
|
198 |
if (NW_Object_IsClass(parentBox, &NW_LMgr_StaticTableCellBox_Class) ||
|
|
199 |
NW_Object_IsClass(parentBox, &NW_LMgr_VerticalTableCellBox_Class))
|
|
200 |
{
|
|
201 |
*pReturnedParentBox = parentBox;
|
|
202 |
return;
|
|
203 |
} else {
|
|
204 |
//continue to find parent
|
|
205 |
parentBox = (NW_LMgr_Box_t*)NW_LMgr_Box_GetParent(parentBox);
|
|
206 |
if(parentBox != NULL) {
|
|
207 |
GetParentBox(parentBox, pReturnedParentBox);
|
|
208 |
}
|
|
209 |
}
|
|
210 |
}
|
|
211 |
// -----------------------------------------------------------------------------
|
|
212 |
TBrowserStatusCode
|
|
213 |
CView::HandleFormattingComplete ()
|
|
214 |
{
|
|
215 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
216 |
iRootBox->calculateExtents = NW_TRUE;
|
|
217 |
iCreateTabList = NW_FALSE;
|
|
218 |
|
|
219 |
NW_LMgr_RootBox_InvalidateCache (iRootBox );
|
|
220 |
// if the user has not tabbed to any tab item
|
|
221 |
if (GetActiveBoxId() == 0)
|
|
222 |
{
|
|
223 |
if (((iInitialDocPosition.x != 0) && (iInitialDocPosition.x != RIGHT_ORIGIN))
|
|
224 |
|| (iInitialDocPosition.y !=0))
|
|
225 |
{
|
|
226 |
SetOrigin (&iInitialDocPosition);
|
|
227 |
}
|
|
228 |
|
|
229 |
// initialActiveBoxId is either the activeBoxId from history or is the first tab index
|
|
230 |
status = GotoActiveBox (iInitialActiveBoxId);
|
|
231 |
if ( iAnchorName != NULL && iInitialActiveBoxId == 0 )
|
|
232 |
{
|
|
233 |
NW_LMgr_Box_t* targetBox = NULL;
|
|
234 |
NW_LMgr_Box_t* box = NULL;
|
|
235 |
NW_LMgr_BoxVisitor_t boxVisitor;
|
|
236 |
NW_LMgr_Property_t prop;
|
|
237 |
|
|
238 |
/* find the named box */
|
|
239 |
|
|
240 |
NW_LMgr_BoxVisitor_Initialize (&boxVisitor, (NW_LMgr_Box_t *)iRootBox);
|
|
241 |
(void) NW_LMgr_BoxVisitor_SetCurrentBox (&boxVisitor, (NW_LMgr_Box_t *)iRootBox);
|
|
242 |
|
|
243 |
|
|
244 |
while ((box = NW_LMgr_BoxVisitor_NextBox (&boxVisitor, NULL)) != NULL)
|
|
245 |
{
|
|
246 |
status = NW_LMgr_Box_GetProperty(box, NW_CSS_Prop_boxName, &prop);
|
|
247 |
|
|
248 |
if ((status == KBrsrSuccess) && (prop.type == NW_CSS_ValueType_Text))
|
|
249 |
{
|
|
250 |
if (!NW_Text_Compare (iAnchorName, prop.value.object))
|
|
251 |
{
|
|
252 |
targetBox = box;
|
|
253 |
break;
|
|
254 |
}
|
|
255 |
}
|
|
256 |
}
|
|
257 |
|
|
258 |
if (targetBox != NULL)
|
|
259 |
{
|
|
260 |
(void) JumpToLink (box, NW_FALSE);
|
|
261 |
}
|
|
262 |
|
|
263 |
(void) Draw(NW_TRUE);
|
|
264 |
NW_Object_Delete(iAnchorName);
|
|
265 |
iAnchorName = NULL;
|
|
266 |
|
|
267 |
}
|
|
268 |
}
|
|
269 |
else
|
|
270 |
{
|
|
271 |
status = Draw (NW_TRUE);
|
|
272 |
}
|
|
273 |
for( TInt n=0; n<iListeners.Count(); n++ )
|
|
274 |
{
|
|
275 |
iListeners[n]->FormattingComplete();
|
|
276 |
}
|
|
277 |
return status;
|
|
278 |
}
|
|
279 |
|
|
280 |
/* ------------------------------------------------------------------------- */
|
|
281 |
//lint --e{578} (Warning -- Declaration of symbol 'index' hides symbol 'index(const char *, int)' (line 75, file Q:\EPOC32\INCLUDE\LIBC\string.h))
|
|
282 |
TBrowserStatusCode CView::GetBoxTabIndex (NW_LMgr_Box_t* box, NW_ADT_Vector_Metric_t* index)
|
|
283 |
{
|
|
284 |
NW_Int32 i;
|
|
285 |
NW_ADT_Vector_Metric_t size;
|
|
286 |
NW_LMgr_Box_t* tempBox;
|
|
287 |
NW_LMgr_RootBox_t* rootBox = iRootBox;
|
|
288 |
NW_GDI_Rectangle_t tempBoxBounds;
|
|
289 |
NW_GDI_Rectangle_t boxBounds;
|
|
290 |
NW_Bool isPageRTL = NW_LMgr_RootBox_IsPageRTL(rootBox);
|
|
291 |
NW_Bool smallScreenOn = NW_LMgr_RootBox_GetSmallScreenOn( iRootBox );
|
|
292 |
|
|
293 |
NW_ASSERT(box != NULL);
|
|
294 |
*index = NW_ADT_Vector_AtEnd;
|
|
295 |
|
|
296 |
size = NW_ADT_Vector_GetSize( iTabList );
|
|
297 |
|
|
298 |
// if a box is about to be added to the tab list the second time -so it's already in the list
|
|
299 |
// we need to delete it from the list as this time, then box might have different x y which
|
|
300 |
// requires different index to return with.
|
|
301 |
i = 0;
|
|
302 |
while( i < size )
|
|
303 |
{
|
|
304 |
tempBox = (NW_LMgr_Box_t*)*NW_ADT_Vector_ElementAt( iTabList,
|
|
305 |
(NW_ADT_Vector_Metric_t)i);
|
|
306 |
// check if the box is duplicated
|
|
307 |
if( tempBox == box )
|
|
308 |
{
|
|
309 |
NW_ADT_DynamicVector_RemoveAt( iTabList, (NW_ADT_Vector_Metric_t)i );
|
|
310 |
break;
|
|
311 |
}
|
|
312 |
// check if this is a image map box 'cause it appends the area boxes into the list
|
|
313 |
// instead of the image map box - only in normal mode
|
|
314 |
else if( NW_Object_IsClass(box, &NW_LMgr_ImageMapBox_Class) == NW_TRUE &&
|
|
315 |
smallScreenOn == NW_FALSE )
|
|
316 |
{
|
|
317 |
//
|
|
318 |
NW_ADT_Vector_Metric_t arrayIndex;
|
|
319 |
NW_ADT_Vector_Metric_t elementSize;
|
|
320 |
NW_LMgr_Box_t* areaBox = NULL;
|
|
321 |
NW_ADT_DynamicVector_t* areaBoxArray =
|
|
322 |
NW_LMgr_ImageMapBox_GetAreaBoxList( NW_LMgr_ImageMapBoxOf( box ) );
|
|
323 |
if( areaBoxArray )
|
|
324 |
{
|
|
325 |
// find the index of the node vector
|
|
326 |
elementSize = NW_ADT_Vector_GetSize(areaBoxArray);
|
|
327 |
|
|
328 |
// loop through all the area boxes in the array and check if the box has already
|
|
329 |
// been added
|
|
330 |
for( arrayIndex = 0; arrayIndex < elementSize; arrayIndex++ )
|
|
331 |
{
|
|
332 |
areaBox = *(NW_LMgr_Box_t**)NW_ADT_Vector_ElementAt( areaBoxArray, arrayIndex );
|
|
333 |
if( tempBox == areaBox )
|
|
334 |
{
|
|
335 |
NW_ADT_DynamicVector_RemoveAt( iTabList, (NW_ADT_Vector_Metric_t)i );
|
|
336 |
// set size variable
|
|
337 |
size = NW_ADT_Vector_GetSize( iTabList );
|
|
338 |
// get the next box with the same index ( the result of the delete )
|
|
339 |
i--;
|
|
340 |
break;
|
|
341 |
}
|
|
342 |
}
|
|
343 |
}
|
|
344 |
}
|
|
345 |
i++;
|
|
346 |
}
|
|
347 |
|
|
348 |
size = NW_ADT_Vector_GetSize( iTabList );
|
|
349 |
CMVCScroll* scrollView = static_cast<CMVCScroll*>(GetScroll());
|
|
350 |
NW_LMgr_Box_t* siblingBox = scrollView->GetFirstSiblingBox(box);
|
|
351 |
boxBounds = NW_LMgr_Box_GetDisplayBounds(siblingBox);
|
|
352 |
|
|
353 |
for( i = size - 1; i >= 0; i-- )
|
|
354 |
{
|
|
355 |
tempBox = (NW_LMgr_Box_t*)*NW_ADT_Vector_ElementAt(iTabList,
|
|
356 |
(NW_ADT_Vector_Metric_t)i);
|
|
357 |
siblingBox = scrollView->GetFirstSiblingBox( NW_LMgr_BoxOf(tempBox) );
|
|
358 |
tempBoxBounds = GetBoxDisplayBounds( siblingBox );
|
|
359 |
|
|
360 |
// rule of inserting: first check y so that links on the same line go right after each other
|
|
361 |
// and then check x to keep the order within the line
|
|
362 |
|
|
363 |
// crossing rectangles tells us if those two boxes are in the same line
|
|
364 |
NW_GDI_Rectangle_t boxRect;
|
|
365 |
NW_GDI_Rectangle_t tempBoxRect;
|
|
366 |
|
|
367 |
// x does not matter as we are only interested in y.
|
|
368 |
|
|
369 |
// set fake x and width. we must set the same x, width values on those two boxes though.
|
|
370 |
boxRect.point.x = tempBoxRect.point.x = 0;
|
|
371 |
boxRect.dimension.width = tempBoxRect.dimension.width = 10;
|
|
372 |
// set real y, height values
|
|
373 |
boxRect.point.y = boxBounds.point.y;
|
|
374 |
boxRect.dimension.height = boxBounds.dimension.height;
|
|
375 |
tempBoxRect.point.y = tempBoxBounds.point.y;
|
|
376 |
tempBoxRect.dimension.height = tempBoxBounds.dimension.height;
|
|
377 |
|
|
378 |
if( NW_GDI_Rectangle_Cross( &boxRect, &tempBoxRect, NULL ) )
|
|
379 |
{
|
|
380 |
// same line
|
|
381 |
|
|
382 |
// on right to left pages the x has to be decreasing as you jump
|
|
383 |
// from link to link within the line.
|
|
384 |
if( !isPageRTL )
|
|
385 |
{
|
|
386 |
if( boxBounds.point.x > tempBoxBounds.point.x ||
|
|
387 |
(boxBounds.point.x == tempBoxBounds.point.x &&
|
|
388 |
boxBounds.point.y > tempBoxBounds.point.y) )
|
|
389 |
{
|
|
390 |
*index = (NW_ADT_Vector_Metric_t)( i + 1 );
|
|
391 |
break;
|
|
392 |
}
|
|
393 |
else if( i == 0 )
|
|
394 |
{
|
|
395 |
// the candiate is above even the first box
|
|
396 |
*index = 0;
|
|
397 |
break;
|
|
398 |
}
|
|
399 |
}
|
|
400 |
// rtl
|
|
401 |
else
|
|
402 |
{
|
|
403 |
if( boxBounds.point.x < tempBoxBounds.point.x ||
|
|
404 |
(boxBounds.point.x == tempBoxBounds.point.x &&
|
|
405 |
boxBounds.point.y > tempBoxBounds.point.y) )
|
|
406 |
{
|
|
407 |
*index = (NW_ADT_Vector_Metric_t)( i + 1 );
|
|
408 |
break;
|
|
409 |
}
|
|
410 |
else if( i == 0 )
|
|
411 |
{
|
|
412 |
// the candiate is above even the first box
|
|
413 |
*index = 0;
|
|
414 |
break;
|
|
415 |
}
|
|
416 |
}
|
|
417 |
}
|
|
418 |
else if( boxBounds.point.y > tempBoxBounds.point.y )
|
|
419 |
{
|
|
420 |
// the box is right below the tempbox.
|
|
421 |
*index = (NW_ADT_Vector_Metric_t)( i + 1 );
|
|
422 |
break;
|
|
423 |
}
|
|
424 |
else if( i == 0 )
|
|
425 |
{
|
|
426 |
// the candiate is above even the first box
|
|
427 |
*index = 0;
|
|
428 |
break;
|
|
429 |
}
|
|
430 |
else
|
|
431 |
{
|
|
432 |
// not on the same line but above, keep going
|
|
433 |
}
|
|
434 |
}
|
|
435 |
return KBrsrSuccess;
|
|
436 |
}
|
|
437 |
|
|
438 |
/* ------------------------------------------------------------------------- */
|
|
439 |
TBool CView::ValidateAddedIndex(NW_LMgr_Box_t* aBox, NW_LMgr_Box_t* aMasterBox)
|
|
440 |
{
|
|
441 |
NW_GDI_Rectangle_t boxBounds = GetBoxDisplayBounds(aMasterBox);
|
|
442 |
// If master box is not visible, do not add to tab index
|
|
443 |
// Break box now has a width of 1. Don't add to tab index if there are only break boxes
|
|
444 |
if ( boxBounds.dimension.width == 0 || boxBounds.dimension.height == 0)
|
|
445 |
{
|
|
446 |
return EFalse;
|
|
447 |
}
|
|
448 |
|
|
449 |
// If all the boxes associated with this box are not visible, don't add to tab index
|
|
450 |
NW_LMgr_BoxVisitor_t boxVisitor;
|
|
451 |
NW_LMgr_Box_t* visitedBox;
|
|
452 |
NW_LMgr_BoxVisitor_Initialize (&boxVisitor, aBox);
|
|
453 |
while((visitedBox = NW_LMgr_BoxVisitor_NextBox (&boxVisitor, NULL)) != NULL)
|
|
454 |
{
|
|
455 |
boxBounds = GetBoxDisplayBounds(visitedBox);
|
|
456 |
if (NW_Object_IsInstanceOf(visitedBox, &NW_LMgr_ContainerBox_Class))
|
|
457 |
{
|
|
458 |
continue;
|
|
459 |
}
|
|
460 |
|
|
461 |
if (( boxBounds.dimension.width != 0 || boxBounds.dimension.height != 0) &&
|
|
462 |
!NW_Object_IsInstanceOf(visitedBox, &NW_LMgr_BreakBox_Class))
|
|
463 |
{
|
|
464 |
// Found a visible box
|
|
465 |
return ETrue;;
|
|
466 |
}
|
|
467 |
}
|
|
468 |
NW_LMgr_BoxVisitor_Initialize (&boxVisitor, aMasterBox);
|
|
469 |
while((visitedBox = NW_LMgr_BoxVisitor_NextBox (&boxVisitor, NULL)) != NULL)
|
|
470 |
{
|
|
471 |
boxBounds = GetBoxDisplayBounds(visitedBox);
|
|
472 |
if (NW_Object_IsInstanceOf(visitedBox, &NW_LMgr_ContainerBox_Class))
|
|
473 |
{
|
|
474 |
continue;
|
|
475 |
}
|
|
476 |
if ((boxBounds.dimension.width != 0 && boxBounds.dimension.height != 0) &&
|
|
477 |
!NW_Object_IsInstanceOf(visitedBox, &NW_LMgr_BreakBox_Class))
|
|
478 |
{
|
|
479 |
// Found a visible box
|
|
480 |
return ETrue;;
|
|
481 |
}
|
|
482 |
}
|
|
483 |
return EFalse;
|
|
484 |
}
|
|
485 |
|
|
486 |
/* ------------------------------------------------------------------------- */
|
|
487 |
TBrowserStatusCode
|
|
488 |
CView::AppendTabItem (NW_LMgr_Box_t* aBox)
|
|
489 |
{
|
|
490 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
491 |
//lint --e{578} (Warning -- Declaration of symbol 'index' hides symbol 'index(const char *, int)' (line 75, file Q:\EPOC32\INCLUDE\LIBC\string.h))
|
|
492 |
NW_ADT_Vector_Metric_t index = 0;
|
|
493 |
NW_LMgr_Property_t prop;
|
|
494 |
NW_LMgr_Box_t* box = aBox;
|
|
495 |
|
|
496 |
if (box->propList && NW_Object_IsInstanceOf(box->propList, &NW_LMgr_SlavePropertyList_Class))
|
|
497 |
{
|
|
498 |
// this is a slave, get the master box as we MUST NOT add slave box to the tablist
|
|
499 |
// Slave boxes are destroyed when box tree is collaped. Collapse can happen multiple times while
|
|
500 |
// the page is being loaded and if we added slave boxes to the tablist, then we would end up having
|
|
501 |
// invalid pointers in the tablist after each collapse.
|
|
502 |
NW_LMgr_Box_t* masterBox = NW_LMgr_SlavePropertyList_GetMasterBox( box->propList );
|
|
503 |
if( !masterBox )
|
|
504 |
{
|
|
505 |
return KBrsrUnexpectedError;
|
|
506 |
}
|
|
507 |
box = masterBox;
|
|
508 |
}
|
|
509 |
// Add the new box only if there is something visible for this active box
|
|
510 |
if (!ValidateAddedIndex(aBox, box))
|
|
511 |
{
|
|
512 |
return KBrsrSuccess;
|
|
513 |
}
|
|
514 |
// set available accesskey
|
|
515 |
status = NW_LMgr_Box_GetPropertyFromList(box, NW_CSS_Prop_accesskey, &prop);
|
|
516 |
|
|
517 |
if (status == KBrsrSuccess)
|
|
518 |
{
|
|
519 |
(void) NW_LMgr_AccessKey_SetAvailableKey (NW_LMgr_AccessKeyOf (prop.value.object),
|
|
520 |
iTabList);
|
|
521 |
}
|
|
522 |
// ignore duplicated boxes
|
|
523 |
if( GetBoxTabIndex (box, &index) == KBrsrSuccess )
|
|
524 |
{
|
|
525 |
// if the box is an image map box, and we are in normal layout mode, then we want to
|
|
526 |
// add the image map's area boxes to the tab list instead of the image map box itself
|
|
527 |
// if we are in small screen mode, we will add the image map box to the tab list
|
|
528 |
if ((NW_Object_IsClass(box, &NW_LMgr_ImageMapBox_Class) == NW_TRUE) &&
|
|
529 |
( !NW_LMgr_RootBox_GetSmallScreenOn( iRootBox ) ))
|
|
530 |
{
|
|
531 |
NW_ADT_Vector_Metric_t arrayIndex;
|
|
532 |
NW_ADT_Vector_Metric_t elementSize;
|
|
533 |
NW_LMgr_AreaBox_t* areaBox = NULL;
|
|
534 |
|
|
535 |
NW_LMgr_ImageMapBox_t* imageMapBox = (NW_LMgr_ImageMapBox_t*)box;
|
|
536 |
NW_ADT_DynamicVector_t* areaBoxArray = NW_LMgr_ImageMapBox_GetAreaBoxList(imageMapBox);
|
|
537 |
|
|
538 |
// It is possible to have an ImageMapBox with no AreaBoxArray
|
|
539 |
// This happens when the usemap id is not present anywhere in the document
|
|
540 |
if (areaBoxArray)
|
|
541 |
{
|
|
542 |
// find the index of the node vector
|
|
543 |
elementSize = NW_ADT_Vector_GetSize(areaBoxArray);
|
|
544 |
|
|
545 |
// loop through all the area boxes in the array and instert them into the tab list
|
|
546 |
int offset = 0;
|
|
547 |
for (arrayIndex = 0; arrayIndex < elementSize; arrayIndex++)
|
|
548 |
{
|
|
549 |
areaBox = *(NW_LMgr_AreaBox_t**)NW_ADT_Vector_ElementAt (areaBoxArray, arrayIndex);
|
|
550 |
|
|
551 |
//
|
|
552 |
if( index != NW_ADT_Vector_AtEnd )
|
|
553 |
{
|
|
554 |
offset = arrayIndex;
|
|
555 |
}
|
|
556 |
if (NW_ADT_DynamicVector_InsertAt (iTabList,
|
|
557 |
&areaBox, (NW_ADT_Vector_Metric_t)(index + offset) ) == NULL)
|
|
558 |
{
|
|
559 |
return KBrsrOutOfMemory;
|
|
560 |
}
|
|
561 |
}
|
|
562 |
}
|
|
563 |
}
|
|
564 |
else
|
|
565 |
{
|
|
566 |
if( NW_ADT_DynamicVector_InsertAt (iTabList, &box, index) == NULL )
|
|
567 |
{
|
|
568 |
return KBrsrOutOfMemory;
|
|
569 |
}
|
|
570 |
}
|
|
571 |
}
|
|
572 |
return KBrsrSuccess;
|
|
573 |
}
|
|
574 |
|
|
575 |
TBrowserStatusCode
|
|
576 |
CView::SetupTableFormat ( NW_Bool /*relayoutEvent*/ )
|
|
577 |
{
|
|
578 |
// no need to visit the box tree and format tables in Small Screen Mode
|
|
579 |
// since we do not have any tables in this mode
|
|
580 |
if( NW_LMgr_RootBox_GetSmallScreenOn( iRootBox ) )
|
|
581 |
{
|
|
582 |
return KBrsrNotFound;
|
|
583 |
}
|
|
584 |
|
|
585 |
NW_Bool foundTable = NW_FALSE;
|
|
586 |
NW_LMgr_BoxVisitor_t boxVisitor;
|
|
587 |
NW_LMgr_Box_t* child = NULL;
|
|
588 |
NW_Uint8 skipChildren = NW_FALSE;
|
|
589 |
|
|
590 |
NW_LMgr_BoxVisitor_Initialize(&boxVisitor, NW_LMgr_BoxOf(iRootBox));
|
|
591 |
|
|
592 |
while( ( child = NW_LMgr_BoxVisitor_NextBox( &boxVisitor, &skipChildren ) ) != NULL )
|
|
593 |
{
|
|
594 |
if( NW_Object_IsInstanceOf( child, &NW_LMgr_StaticTableBox_Class ) == NW_TRUE )
|
|
595 |
{
|
|
596 |
// set maximum/minimum pass on tables
|
|
597 |
NW_LMgr_StaticTableBox_SetAutomaticTableWidthPass( NW_LMgr_StaticTableBoxOf( child ), NW_LMgr_StaticTableBox_AutomaticWidth_MaximumPass );
|
|
598 |
foundTable = NW_TRUE;
|
|
599 |
}
|
|
600 |
}
|
|
601 |
|
|
602 |
// first check if the page has table at all as if it doesn't have, then no layout is needed at all
|
|
603 |
if( foundTable == NW_TRUE )
|
|
604 |
{
|
|
605 |
((CLMgr_BoxFormatHandler*)(iBoxFormatHandler))->SetBackgroundFormat();
|
|
606 |
}
|
|
607 |
else
|
|
608 |
{
|
|
609 |
return KBrsrNotFound;
|
|
610 |
}
|
|
611 |
|
|
612 |
return KBrsrSuccess;
|
|
613 |
}
|
|
614 |
|
|
615 |
// -----------------------------------------------------------------------------
|
|
616 |
TBrowserStatusCode
|
|
617 |
CView::UpdateScrollBars () const
|
|
618 |
{
|
|
619 |
NW_GDI_Dimension2D_t canvasSize;
|
|
620 |
TBrowserStatusCode status = NW_LMgr_RootBox_GetExtents (iRootBox, &canvasSize);
|
|
621 |
if (status != KBrsrSuccess)
|
|
622 |
{
|
|
623 |
return status;
|
|
624 |
}
|
|
625 |
iWmlControl->WKWmlInterface()->updateScrollbars(canvasSize.height, Rect().Height(), iDeviceContext->Origin()->y,
|
|
626 |
canvasSize.width, Rect().Width(), iDeviceContext->Origin()->x);
|
|
627 |
return KBrsrSuccess;
|
|
628 |
}
|
|
629 |
|
|
630 |
// -----------------------------------------------------------------------------
|
|
631 |
NW_Bool
|
|
632 |
CView::ProcessTabEvent (const NW_Evt_TabEvent_t* tabEvent)
|
|
633 |
{
|
|
634 |
TBool noBoxVisible;
|
|
635 |
TBool returnVal = EFalse;
|
|
636 |
CMVCScroll* scroll;
|
|
637 |
|
|
638 |
/* parameter assertion block */
|
|
639 |
NW_ASSERT (tabEvent != NULL);
|
|
640 |
|
|
641 |
scroll = static_cast<CMVCScroll*>(iScroll);
|
|
642 |
|
|
643 |
switch (NW_Evt_TabEvent_GetDirection (tabEvent))
|
|
644 |
{
|
|
645 |
case NW_Evt_TabEvent_Direction_Up:
|
|
646 |
case NW_Evt_TabEvent_Direction_Left:
|
|
647 |
returnVal = scroll->TabBackward (&noBoxVisible);
|
|
648 |
break;
|
|
649 |
|
|
650 |
case NW_Evt_TabEvent_Direction_Down:
|
|
651 |
case NW_Evt_TabEvent_Direction_Right:
|
|
652 |
returnVal = scroll->TabForward (NW_FALSE/* not new page */, &noBoxVisible);
|
|
653 |
break;
|
|
654 |
}
|
|
655 |
|
|
656 |
/* we didn't absorb the event */
|
|
657 |
return (NW_Bool)returnVal;
|
|
658 |
}
|
|
659 |
|
|
660 |
// -----------------------------------------------------------------------------
|
|
661 |
NW_Bool
|
|
662 |
CView::ProcessScrollEvent (const NW_Evt_ScrollEvent_t* scrollEvent)
|
|
663 |
{
|
|
664 |
NW_GDI_Point2D_t origin;
|
|
665 |
NW_Uint16 delta;
|
|
666 |
|
|
667 |
/* parameter assertion block */
|
|
668 |
NW_ASSERT (scrollEvent != NULL);
|
|
669 |
|
|
670 |
origin = *(iDeviceContext->Origin());
|
|
671 |
delta = NW_Evt_ScrollEvent_GetAmount(scrollEvent);
|
|
672 |
switch (NW_Evt_ScrollEvent_GetDirection (scrollEvent))
|
|
673 |
{
|
|
674 |
case NW_Evt_ScrollEvent_Direction_Left:
|
|
675 |
origin.x = (NW_GDI_Metric_t) (origin.x - delta);
|
|
676 |
break;
|
|
677 |
|
|
678 |
case NW_Evt_ScrollEvent_Direction_Right:
|
|
679 |
origin.x = (NW_GDI_Metric_t) (origin.x + delta);
|
|
680 |
break;
|
|
681 |
|
|
682 |
case NW_Evt_ScrollEvent_Direction_Up:
|
|
683 |
origin.y = (NW_GDI_Metric_t) (origin.y - delta);
|
|
684 |
break;
|
|
685 |
|
|
686 |
case NW_Evt_ScrollEvent_Direction_Down:
|
|
687 |
origin.y = (NW_GDI_Metric_t) (origin.y + delta);
|
|
688 |
break;
|
|
689 |
|
|
690 |
default:
|
|
691 |
/* we didn't absorb the event */
|
|
692 |
return NW_FALSE;
|
|
693 |
}
|
|
694 |
|
|
695 |
/* */
|
|
696 |
TBrowserStatusCode status = SetOrigin (&origin);
|
|
697 |
NW_ASSERT (status == KBrsrSuccess);
|
|
698 |
|
|
699 |
/* we absorbed the event */
|
|
700 |
return NW_TRUE;
|
|
701 |
}
|
|
702 |
|
|
703 |
// -----------------------------------------------------------------------------
|
|
704 |
void
|
|
705 |
CView::DeleteOptionItems ()
|
|
706 |
{
|
|
707 |
//lint --e{578} (Warning -- Declaration of symbol 'index' hides symbol 'index(const char *, int)' (line 75, file Q:\EPOC32\INCLUDE\LIBC\string.h))
|
|
708 |
NW_ADT_Vector_Metric_t index;
|
|
709 |
NW_ADT_Vector_Metric_t size;
|
|
710 |
|
|
711 |
if (iOptionItemList == NULL)
|
|
712 |
{
|
|
713 |
return;
|
|
714 |
}
|
|
715 |
size = NW_ADT_Vector_GetSize(iOptionItemList);
|
|
716 |
if (size == 0 )
|
|
717 |
{
|
|
718 |
NW_Object_Delete(iOptionItemList);
|
|
719 |
iOptionItemList = NULL;
|
|
720 |
return;
|
|
721 |
}
|
|
722 |
|
|
723 |
for(index =0;index<size; index++)
|
|
724 |
{
|
|
725 |
NW_Ucs2 *str = *(NW_Ucs2 **)
|
|
726 |
NW_ADT_Vector_ElementAt (iOptionItemList, index);
|
|
727 |
NW_Mem_Free(str);
|
|
728 |
}
|
|
729 |
|
|
730 |
NW_Object_Delete(iOptionItemList);
|
|
731 |
iOptionItemList = NULL;
|
|
732 |
return;
|
|
733 |
}
|
|
734 |
|
|
735 |
// ============================= PUBLIC FUNCTIONS ===============================
|
|
736 |
void
|
|
737 |
CView::UpdateCBAs () const
|
|
738 |
{
|
|
739 |
NW_AppServices_SoftKeyAPI_t* softKeyAPI;
|
|
740 |
NW_HED_AppServices_t* appServices;
|
|
741 |
NW_LMgr_RootBox_t* rootBox = iRootBox;
|
|
742 |
|
|
743 |
appServices = NW_LMgr_RootBox_GetAppServices (rootBox);
|
|
744 |
softKeyAPI = &(appServices->softKeyApi);
|
|
745 |
|
|
746 |
if (softKeyAPI->setLeft != NULL)
|
|
747 |
{
|
|
748 |
softKeyAPI->setLeft(NW_SOFTKEY_OK); // NW_SOFTKEY_OK parameter is here just because of API
|
|
749 |
}
|
|
750 |
}
|
|
751 |
|
|
752 |
// ----------------------------------------------------------------------------
|
|
753 |
TBrowserStatusCode CView::InputInvalid(void* aCEpoc32View, TInt aMin)
|
|
754 |
{
|
|
755 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
756 |
TRAPD(err, status = InputInvalidL(aCEpoc32View, aMin));
|
|
757 |
if (err != KErrNone)
|
|
758 |
return KBrsrFailure;
|
|
759 |
return status;
|
|
760 |
}
|
|
761 |
// ----------------------------------------------------------------------------
|
|
762 |
TBrowserStatusCode CView::InputInvalidL(void* aCEpoc32View, TInt aMin)
|
|
763 |
{
|
|
764 |
HBufC* message = NULL;
|
|
765 |
|
|
766 |
if (aMin == 1)
|
|
767 |
{
|
|
768 |
// We only require one char
|
|
769 |
message = StringLoader::LoadLC(R_TEXT_INPUT_REQ);
|
|
770 |
}
|
|
771 |
else
|
|
772 |
{
|
|
773 |
TBuf<8> aMinStr;
|
|
774 |
aMinStr.Format(_L("%U"),aMin);
|
|
775 |
// We require a minimum number of chars
|
|
776 |
message = StringLoader::LoadLC(R_TEXT_MORE_INPUT_REQ,aMinStr);
|
|
777 |
}
|
|
778 |
|
|
779 |
TRAPD (err, ((CView*)aCEpoc32View)->iBrCtl->brCtlDialogsProvider()->DialogNoteL(message->Des()));
|
|
780 |
|
|
781 |
// Clean up the memory
|
|
782 |
CleanupStack::PopAndDestroy(1); // message
|
|
783 |
|
|
784 |
return (( err == KErrNone) ? KBrsrSuccess : KBrsrFailure);
|
|
785 |
}
|
|
786 |
|
|
787 |
// ----------------------------------------------------------------------------
|
|
788 |
TBrowserStatusCode
|
|
789 |
CView::InitializeTree (NW_LMgr_RootBox_t *rootBox, TBool isFormatingBoxTree)
|
|
790 |
{
|
|
791 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
792 |
|
|
793 |
// CView::IBoxTreeListener_FormattingComplete takes care of
|
|
794 |
// the following clean-ups in case of background formatting
|
|
795 |
if( !((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->BackgroundFormat() )
|
|
796 |
{
|
|
797 |
/* Clear the rendering cache */
|
|
798 |
NW_LMgr_RootBox_InvalidateCache(rootBox);
|
|
799 |
|
|
800 |
/* Clear the float context vectors */
|
|
801 |
(void) NW_ADT_DynamicVector_Clear(rootBox->placedFloats);
|
|
802 |
(void) NW_ADT_DynamicVector_Clear(rootBox->pendingFloats);
|
|
803 |
(void) NW_ADT_DynamicVector_Clear(rootBox->positionedAbsObjects);
|
|
804 |
rootBox->iPositionedBoxesPlaced = NW_FALSE;
|
|
805 |
|
|
806 |
/* We'll have to recalculate the extents */
|
|
807 |
NW_Mem_memset(&(rootBox->extents), 0, sizeof(NW_GDI_Rectangle_t));
|
|
808 |
NW_Mem_memset(&(rootBox->scrollRange), 0, sizeof(NW_GDI_Rectangle_t));
|
|
809 |
NW_LMgr_RootBox_ExtendsCalculationNeeded(rootBox);
|
|
810 |
NW_LMgr_RootBox_SetBody(rootBox, NULL);
|
|
811 |
|
|
812 |
// set formatting bounds
|
|
813 |
|
|
814 |
// Below four lines should go away once container box sets the height of rootbox
|
|
815 |
// to be equal to its height. Currently the height of rootbox is increased to
|
|
816 |
// the amount equal to the initial height + the height of inner container box.
|
|
817 |
// Where as it should be increased to be equal to the height of inner container box.
|
|
818 |
NW_GDI_Rectangle_t displayBounds;
|
|
819 |
|
|
820 |
displayBounds = *(iDeviceContext->DisplayBounds());
|
|
821 |
displayBounds.point.x = 0;
|
|
822 |
displayBounds.point.y = 0;
|
|
823 |
displayBounds.dimension.height = 0;
|
|
824 |
NW_LMgr_Box_SetFormatBounds( NW_LMgr_BoxOf( rootBox ), displayBounds );
|
|
825 |
}
|
|
826 |
|
|
827 |
/* Set the font on the rootbox */
|
|
828 |
status = NW_LMgr_Box_ApplyFontProps(NW_LMgr_BoxOf(rootBox));
|
|
829 |
|
|
830 |
/* by default, the blink timer is off */
|
|
831 |
rootBox->isBlinking = NW_FALSE;
|
|
832 |
|
|
833 |
// Reset the formatbounds when the browser is in NSM or in SSM and it has grid mode tables.
|
|
834 |
// The bounds need to be reset in order to correctly layout boxes in static cell boxes.
|
|
835 |
if( !NW_LMgr_RootBox_GetSmallScreenOn( iRootBox ) || (rootBox->iHasGridModeTables &&
|
|
836 |
isFormatingBoxTree))
|
|
837 |
{
|
|
838 |
NW_LMgr_BoxVisitor_t visitor;
|
|
839 |
NW_LMgr_Box_t* child = NULL;
|
|
840 |
|
|
841 |
NW_LMgr_BoxVisitor_Initialize(&visitor, NW_LMgr_BoxOf(rootBox));
|
|
842 |
|
|
843 |
/* Iterate through all children */
|
|
844 |
child = NW_LMgr_BoxVisitor_NextBox(&visitor, NULL);
|
|
845 |
while ((child = NW_LMgr_BoxVisitor_NextBox(&visitor, NULL)) != NULL)
|
|
846 |
{
|
|
847 |
/* Initialize the coordinates */
|
|
848 |
NW_GDI_Rectangle_t boxBounds = NW_LMgr_Box_GetFormatBounds( child );
|
|
849 |
|
|
850 |
NW_Mem_memset(&(boxBounds), 0, sizeof(NW_GDI_Rectangle_t));
|
|
851 |
NW_LMgr_Box_SetFormatBounds( child, boxBounds );
|
|
852 |
|
|
853 |
|
|
854 |
/* Clean up any flows */
|
|
855 |
if (NW_Object_IsInstanceOf(child, &NW_LMgr_BidiFlowBox_Class))
|
|
856 |
{
|
|
857 |
status = ((CLMgr_BoxFormatHandler*)(iBoxFormatHandler))->InitializeBox(NW_LMgr_BidiFlowBoxOf(child));
|
|
858 |
}
|
|
859 |
|
|
860 |
if (NW_Object_IsClass(child, &NW_LMgr_ContainerBox_Class) ||
|
|
861 |
NW_Object_IsClass(child, &NW_LMgr_ActiveContainerBox_Class))
|
|
862 |
{
|
|
863 |
status = NW_LMgr_ContainerBox_Initialize(NW_LMgr_ContainerBoxOf(child));
|
|
864 |
}
|
|
865 |
|
|
866 |
if (NW_Object_IsClass(child, &NW_LMgr_MarqueeBox_Class))
|
|
867 |
{
|
|
868 |
status = NW_LMgr_MarqueeBox_Initialize(NW_LMgr_MarqueeBoxOf(child));
|
|
869 |
}
|
|
870 |
if (status != KBrsrSuccess)
|
|
871 |
break;
|
|
872 |
}
|
|
873 |
}
|
|
874 |
|
|
875 |
return status;
|
|
876 |
}
|
|
877 |
|
|
878 |
/* ------------------------------------------------------------------------- */
|
|
879 |
TBrowserStatusCode
|
|
880 |
CView::SetDisplayExtents (NW_GDI_Rectangle_t* displayExtents)
|
|
881 |
{
|
|
882 |
CGDIDeviceContext* deviceContext = GetDeviceContext ();
|
|
883 |
|
|
884 |
if (!deviceContext)
|
|
885 |
{
|
|
886 |
return KBrsrFailure;
|
|
887 |
}
|
|
888 |
|
|
889 |
deviceContext->SetDisplayBounds( displayExtents);
|
|
890 |
return KBrsrSuccess;
|
|
891 |
}
|
|
892 |
|
|
893 |
// -----------------------------------------------------------------------------
|
|
894 |
TBrowserStatusCode
|
|
895 |
CView::Collapse( NW_LMgr_FlowBox_t* containingFlow, NW_Bool collapseAnonymous )
|
|
896 |
{
|
|
897 |
return ((CLMgr_BoxFormatHandler*)(iBoxFormatHandler))->Collapse( containingFlow, collapseAnonymous );
|
|
898 |
}
|
|
899 |
|
|
900 |
// -----------------------------------------------------------------------------
|
|
901 |
TBrowserStatusCode
|
|
902 |
CView::FormatBoxTree(NW_Bool createTabList)
|
|
903 |
{
|
|
904 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
905 |
|
|
906 |
NW_LOG0( NW_LOG_LEVEL2, "CView::FormatBoxTree START" );
|
|
907 |
|
|
908 |
// check to see if we have any children in our box tree, if not, then there is nothing to
|
|
909 |
// format and we just want to return success.
|
|
910 |
NW_LMgr_Box_t* child = NW_LMgr_ContainerBox_GetChild(NW_LMgr_ContainerBoxOf(iRootBox), 0);
|
|
911 |
if( !child )
|
|
912 |
{
|
|
913 |
return KBrsrSuccess;
|
|
914 |
}
|
|
915 |
// cancel any format in progress
|
|
916 |
((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->Cancel();
|
|
917 |
|
|
918 |
// clear tablist
|
|
919 |
if( createTabList )
|
|
920 |
{
|
|
921 |
(void) NW_ADT_DynamicVector_Clear(iTabList);
|
|
922 |
}
|
|
923 |
iCreateTabList = createTabList;
|
|
924 |
|
|
925 |
// check if background format is needed
|
|
926 |
status = SetupTableFormat (NW_TRUE);
|
|
927 |
|
|
928 |
if( status != KBrsrNotFound )
|
|
929 |
{
|
|
930 |
// ignore KBrsrNotFound error as it indicates that there in no table in the page
|
|
931 |
if (status != KBrsrSuccess)
|
|
932 |
{
|
|
933 |
return status;
|
|
934 |
}
|
|
935 |
}
|
|
936 |
status = KBrsrSuccess;
|
|
937 |
|
|
938 |
// Initialize the tree
|
|
939 |
status = InitializeTree (iRootBox, ETrue);
|
|
940 |
if (status != KBrsrSuccess)
|
|
941 |
{
|
|
942 |
return status;
|
|
943 |
}
|
|
944 |
|
|
945 |
// start formatting
|
|
946 |
TRAPD(err, ((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->PartialFormatL( iFormatPriority ));
|
|
947 |
if( err != KErrNone )
|
|
948 |
{
|
|
949 |
return KBrsrFailure;
|
|
950 |
}
|
|
951 |
((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->PageLoadCompleted();
|
|
952 |
|
|
953 |
#ifdef _DEBUG_LOG
|
|
954 |
// dump the box tree
|
|
955 |
if (iRootBox)
|
|
956 |
{
|
|
957 |
NW_LMgr_Box_DumpBoxTree (NW_LMgr_BoxOf(iRootBox));
|
|
958 |
}
|
|
959 |
#endif // DEBUG
|
|
960 |
|
|
961 |
NW_LOG0( NW_LOG_LEVEL2, "CView::FormatBoxTree END" );
|
|
962 |
return status;
|
|
963 |
}
|
|
964 |
|
|
965 |
// -----------------------------------------------------------------------------
|
|
966 |
void
|
|
967 |
CView::DisableAnimation()
|
|
968 |
{
|
|
969 |
NW_LMgr_Box_t* child = NULL;
|
|
970 |
NW_LMgr_BoxVisitor_t visitor;
|
|
971 |
|
|
972 |
NW_LMgr_BoxVisitor_Initialize(&visitor, NW_LMgr_BoxOf(iRootBox));
|
|
973 |
|
|
974 |
while( ( child = NW_LMgr_BoxVisitor_NextBox( &visitor, NULL) ) != NULL )
|
|
975 |
{
|
|
976 |
if( NW_Object_IsInstanceOf( child, &NW_LMgr_AnimatedImageBox_Class ) == NW_TRUE )
|
|
977 |
{
|
|
978 |
NW_LMgr_AnimatedImageBox_Suspend (NW_LMgr_AnimatedImageBoxOf(child));
|
|
979 |
}
|
|
980 |
}
|
|
981 |
}
|
|
982 |
|
|
983 |
// -----------------------------------------------------------------------------
|
|
984 |
void
|
|
985 |
CView::EnableAnimation()
|
|
986 |
{
|
|
987 |
NW_LMgr_Box_t* child = NULL;
|
|
988 |
NW_LMgr_BoxVisitor_t visitor;
|
|
989 |
|
|
990 |
NW_LMgr_BoxVisitor_Initialize(&visitor, NW_LMgr_BoxOf(iRootBox));
|
|
991 |
|
|
992 |
while( ( child = NW_LMgr_BoxVisitor_NextBox( &visitor, NULL ) ) != NULL )
|
|
993 |
{
|
|
994 |
if( NW_Object_IsInstanceOf( child, &NW_LMgr_AnimatedImageBox_Class ) == NW_TRUE )
|
|
995 |
{
|
|
996 |
NW_LMgr_AnimatedImageBox_Resume (NW_LMgr_AnimatedImageBoxOf(child));
|
|
997 |
}
|
|
998 |
}
|
|
999 |
}
|
|
1000 |
|
|
1001 |
// -----------------------------------------------------------------------------
|
|
1002 |
TBrowserStatusCode
|
|
1003 |
CView::SwitchToImageMapView ()
|
|
1004 |
{
|
|
1005 |
NW_LMgr_RootBox_t* newRootBox = NULL;
|
|
1006 |
NW_LMgr_Box_t* newImageMapBox = NULL;
|
|
1007 |
NW_LMgr_BidiFlowBox_t* newBidiFlowBox = NULL;
|
|
1008 |
LMgrAnonBlock_t* newAnonBlockBox = NULL;
|
|
1009 |
NW_AppServices_SoftKeyAPI_t* softKeyAPI = NULL;
|
|
1010 |
NW_LMgr_Property_t prop;
|
|
1011 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
1012 |
|
|
1013 |
// set the image map view flag to true
|
|
1014 |
iIsImageMapView = NW_TRUE;
|
|
1015 |
|
|
1016 |
// disable any animation
|
|
1017 |
DisableAnimation();
|
|
1018 |
|
|
1019 |
// set the current box as the "focus" box on the root box
|
|
1020 |
// this helps us save the state for when we switch back to the normal view
|
|
1021 |
NW_LMgr_RootBox_SetFocusBox(iRootBox, iCurrentBox);
|
|
1022 |
|
|
1023 |
status = NW_LMgr_RootBox_Copy (iRootBox, &newRootBox);
|
|
1024 |
if (status != KBrsrSuccess)
|
|
1025 |
{
|
|
1026 |
return status;
|
|
1027 |
}
|
|
1028 |
|
|
1029 |
// add the new root box to the root box array
|
|
1030 |
TRAPD( ret, iRootBoxArray->AppendL(newRootBox) );
|
|
1031 |
if( ret == KErrNoMemory )
|
|
1032 |
{
|
|
1033 |
return KBrsrOutOfMemory;
|
|
1034 |
}
|
|
1035 |
|
|
1036 |
// set the "current" root box to be the new root box
|
|
1037 |
iRootBox = newRootBox;
|
|
1038 |
|
|
1039 |
// change root box associated with the box format handler
|
|
1040 |
((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->SetRootBox(NW_LMgr_BoxOf(iRootBox));
|
|
1041 |
|
|
1042 |
// set the box tree listener for the new root box (always returns success)
|
|
1043 |
status = NW_LMgr_RootBox_SetBoxTreeListener (iRootBox, this);
|
|
1044 |
|
|
1045 |
// make sure the rootbox has the focus at the beginning
|
|
1046 |
NW_LMgr_RootBox_GainFocus(iRootBox);
|
|
1047 |
|
|
1048 |
// create a BidiFlowBox in which to build the box tree
|
|
1049 |
newBidiFlowBox = NW_LMgr_BidiFlowBox_New (1);
|
|
1050 |
if (!newBidiFlowBox)
|
|
1051 |
{
|
|
1052 |
return KBrsrOutOfMemory;
|
|
1053 |
}
|
|
1054 |
|
|
1055 |
// set the display property on the bidi flow box
|
|
1056 |
prop.type = NW_CSS_ValueType_Token;
|
|
1057 |
prop.value.token = NW_CSS_PropValue_display_block;
|
|
1058 |
NW_LMgr_Box_SetProperty (NW_LMgr_BoxOf (newBidiFlowBox),
|
|
1059 |
NW_CSS_Prop_display, &prop);
|
|
1060 |
|
|
1061 |
prop.value.token = NW_CSS_PropValue_flags_bodyElement;
|
|
1062 |
status = NW_LMgr_Box_SetProperty(NW_LMgr_BoxOf (newBidiFlowBox), NW_CSS_Prop_flags, &prop);
|
|
1063 |
|
|
1064 |
prop.type = NW_CSS_ValueType_Px;
|
|
1065 |
prop.value.integer = 2;
|
|
1066 |
NW_LMgr_Box_SetProperty (NW_LMgr_BoxOf(newBidiFlowBox), NW_CSS_Prop_margin, &prop);
|
|
1067 |
|
|
1068 |
// create a new anon block that will contain our imagemap box since the image map cannot
|
|
1069 |
// exist outside a block
|
|
1070 |
newAnonBlockBox = LMgrAnonBlock_New(0);
|
|
1071 |
if (!newAnonBlockBox)
|
|
1072 |
{
|
|
1073 |
return KBrsrOutOfMemory;
|
|
1074 |
}
|
|
1075 |
|
|
1076 |
// get the image map box by copying the current box
|
|
1077 |
status = NW_LMgr_ImageMapBox_Copy(iCurrentBox, &newImageMapBox);
|
|
1078 |
if (status != KBrsrSuccess)
|
|
1079 |
{
|
|
1080 |
return status;
|
|
1081 |
}
|
|
1082 |
|
|
1083 |
// Add the image map box to the new anon container box
|
|
1084 |
status = NW_LMgr_ContainerBox_AddChild(NW_LMgr_ContainerBoxOf(newAnonBlockBox),
|
|
1085 |
newImageMapBox);
|
|
1086 |
if (status != KBrsrSuccess)
|
|
1087 |
{
|
|
1088 |
return status;
|
|
1089 |
}
|
|
1090 |
|
|
1091 |
// Insert the anon block box into the box tree
|
|
1092 |
status = NW_LMgr_ContainerBox_InsertChildAt(NW_LMgr_ContainerBoxOf(newBidiFlowBox),
|
|
1093 |
NW_LMgr_BoxOf(newAnonBlockBox),
|
|
1094 |
0);
|
|
1095 |
if (status != KBrsrSuccess)
|
|
1096 |
{
|
|
1097 |
return status;
|
|
1098 |
}
|
|
1099 |
|
|
1100 |
// Set the display property on the anon block box
|
|
1101 |
prop.type = NW_CSS_ValueType_Token;
|
|
1102 |
prop.value.token = NW_CSS_PropValue_display_block;
|
|
1103 |
status = NW_LMgr_Box_SetProperty(NW_LMgr_BoxOf(newAnonBlockBox),
|
|
1104 |
NW_CSS_Prop_display, &prop);
|
|
1105 |
if (status != KBrsrSuccess)
|
|
1106 |
{
|
|
1107 |
return status;
|
|
1108 |
}
|
|
1109 |
|
|
1110 |
// switch to normal screen mode
|
|
1111 |
NW_Settings_SetInternalVerticalLayoutEnabled( NW_FALSE );
|
|
1112 |
|
|
1113 |
// set the current box to point to the new image map box
|
|
1114 |
iCurrentBox = newImageMapBox;
|
|
1115 |
|
|
1116 |
// set the current box as the "focus" box on the root box
|
|
1117 |
NW_LMgr_RootBox_SetFocusBox(iRootBox, iCurrentBox);
|
|
1118 |
|
|
1119 |
// set the box tree on the view
|
|
1120 |
status = SetBoxTree (NW_LMgr_BoxOf(newBidiFlowBox));
|
|
1121 |
if (status != KBrsrSuccess)
|
|
1122 |
{
|
|
1123 |
return status;
|
|
1124 |
}
|
|
1125 |
|
|
1126 |
((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->ClearFormattingContext();
|
|
1127 |
((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->Cancel();
|
|
1128 |
|
|
1129 |
// this will actually perform switch to normal screen mode
|
|
1130 |
status = SwitchVerticalLayout (NW_TRUE, NW_TRUE);
|
|
1131 |
if (status != KBrsrSuccess)
|
|
1132 |
{
|
|
1133 |
return status;
|
|
1134 |
}
|
|
1135 |
|
|
1136 |
// ping the softkeys api, it doesn't matter which key and
|
|
1137 |
// options we are setting, we just want to trigger CommandSetResourceIdL
|
|
1138 |
// off the BrowserContentView to be called
|
|
1139 |
// this will trigger the code that switches the changing of the right
|
|
1140 |
// key to Back when we are in image map mode
|
|
1141 |
softKeyAPI = &(iRootBox->appServices->softKeyApi);
|
|
1142 |
NW_ASSERT(softKeyAPI != NULL);
|
|
1143 |
|
|
1144 |
if (softKeyAPI->setLeft != NULL)
|
|
1145 |
{
|
|
1146 |
softKeyAPI->setLeft(NW_SOFTKEY_OK); // this could be anything
|
|
1147 |
}
|
|
1148 |
// Inform all observers that returning from image map view
|
|
1149 |
// This is important because we need to inform Flash plugin to not show itself
|
|
1150 |
TInt count = iStateChangeObserver.Count();
|
|
1151 |
for (TInt i = 0; i < count; i++)
|
|
1152 |
{
|
|
1153 |
iStateChangeObserver[i]->StateChanged(TBrCtlDefs::EStateImageMapView,ETrue);
|
|
1154 |
}
|
|
1155 |
|
|
1156 |
return status;
|
|
1157 |
}
|
|
1158 |
|
|
1159 |
// -----------------------------------------------------------------------------
|
|
1160 |
TBrowserStatusCode
|
|
1161 |
CView::SwitchFromImageMapView ()
|
|
1162 |
{
|
|
1163 |
NW_AppServices_SoftKeyAPI_t* softKeyAPI = NULL;
|
|
1164 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
1165 |
|
|
1166 |
// set the image map view flag to false
|
|
1167 |
iIsImageMapView = NW_FALSE;
|
|
1168 |
|
|
1169 |
// find the size of the root box array
|
|
1170 |
TInt size = iRootBoxArray->Count();
|
|
1171 |
NW_ASSERT (size == 2);
|
|
1172 |
|
|
1173 |
// retrieve the original root box (index position should be 0)
|
|
1174 |
iRootBox = iRootBoxArray->At(0);
|
|
1175 |
NW_ASSERT(iRootBox);
|
|
1176 |
|
|
1177 |
// change root box associated with the box format handler
|
|
1178 |
((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->SetRootBox(NW_LMgr_BoxOf(iRootBox));
|
|
1179 |
|
|
1180 |
// set the box tree listener for the original root box // always returns success
|
|
1181 |
status = NW_LMgr_RootBox_SetBoxTreeListener (iRootBox, this);
|
|
1182 |
|
|
1183 |
// make sure the rootbox has the focus at the beginning
|
|
1184 |
NW_LMgr_RootBox_GainFocus(iRootBox);
|
|
1185 |
|
|
1186 |
NW_LMgr_Box_t* boxTree = NW_LMgr_ContainerBox_GetChild(NW_LMgr_ContainerBoxOf(iRootBox), 0);
|
|
1187 |
NW_ASSERT(boxTree);
|
|
1188 |
|
|
1189 |
// set the current box to point to the focused box in the box tree
|
|
1190 |
iCurrentBox = NW_LMgr_RootBox_GetFocusBox(iRootBox);
|
|
1191 |
|
|
1192 |
// set the focus box to NULL
|
|
1193 |
NW_LMgr_RootBox_SetFocusBox(iRootBox, NULL);
|
|
1194 |
|
|
1195 |
// Check to see the status of the external layout switch flag because it
|
|
1196 |
// is possible that the user changed the layout mode while in the
|
|
1197 |
// image map view
|
|
1198 |
if (iExternalLayoutSwitch)
|
|
1199 |
{
|
|
1200 |
// if the user changed the layout, call switch vertical layout to reformat the box tree
|
|
1201 |
// and make sure that we switch tables as well
|
|
1202 |
status = SwitchVerticalLayout (NW_TRUE, NW_TRUE);
|
|
1203 |
if (status != KBrsrSuccess)
|
|
1204 |
{
|
|
1205 |
return status;
|
|
1206 |
}
|
|
1207 |
}
|
|
1208 |
else
|
|
1209 |
{
|
|
1210 |
// if the user hasn't changed the layout, switch back to vertical layout mode
|
|
1211 |
NW_Settings_SetInternalVerticalLayoutEnabled( NW_TRUE );
|
|
1212 |
|
|
1213 |
// this will actually perform switch to the vertical layout mode, but since we
|
|
1214 |
// are passing in NW_FALSE for the third parameter, we will not switch the tables
|
|
1215 |
status = SwitchVerticalLayout (NW_TRUE, NW_FALSE);
|
|
1216 |
if (status != KBrsrSuccess)
|
|
1217 |
{
|
|
1218 |
return status;
|
|
1219 |
}
|
|
1220 |
}
|
|
1221 |
|
|
1222 |
// remove and delete the image map box tree
|
|
1223 |
NW_LMgr_RootBox_t* oldRootBox = iRootBoxArray->At( size - 1 );
|
|
1224 |
if (!oldRootBox)
|
|
1225 |
{
|
|
1226 |
return KBrsrFailure;
|
|
1227 |
}
|
|
1228 |
|
|
1229 |
NW_LMgr_Box_t* oldBoxTree = NW_LMgr_RootBox_GetFocusBox(oldRootBox);
|
|
1230 |
if (!oldBoxTree)
|
|
1231 |
{
|
|
1232 |
return KBrsrFailure;
|
|
1233 |
}
|
|
1234 |
|
|
1235 |
// delete image map box tree
|
|
1236 |
NW_Object_Delete (oldBoxTree);
|
|
1237 |
oldBoxTree = NULL;
|
|
1238 |
|
|
1239 |
// delete the root box
|
|
1240 |
iRootBoxArray->Delete( size - 1 );
|
|
1241 |
NW_Object_Delete (oldRootBox);
|
|
1242 |
|
|
1243 |
// ping the softkeys api, it doesn't matter which key and
|
|
1244 |
// options we are setting, we just want to trigger CommandSetResourceIdL
|
|
1245 |
// off the BrowserContentView to be called
|
|
1246 |
// this will trigger the code that switches the changing of the right
|
|
1247 |
// key what ever is appropriate when we are in normal mode
|
|
1248 |
softKeyAPI = &(iRootBox->appServices->softKeyApi);
|
|
1249 |
NW_ASSERT(softKeyAPI != NULL);
|
|
1250 |
|
|
1251 |
if (softKeyAPI->setLeft != NULL)
|
|
1252 |
{
|
|
1253 |
softKeyAPI->setLeft(NW_SOFTKEY_OK); // this could be anything
|
|
1254 |
}
|
|
1255 |
|
|
1256 |
iExternalLayoutSwitch = NW_FALSE;
|
|
1257 |
|
|
1258 |
// enable any animation
|
|
1259 |
EnableAnimation();
|
|
1260 |
|
|
1261 |
// Inform all observers that returning from image map view
|
|
1262 |
// This is important because we need to inform Flash plugin to show itself again
|
|
1263 |
TInt count = iStateChangeObserver.Count();
|
|
1264 |
for (TInt i = 0; i < count; i++)
|
|
1265 |
{
|
|
1266 |
iStateChangeObserver[i]->StateChanged(TBrCtlDefs::EStateImageMapView, EFalse);
|
|
1267 |
}
|
|
1268 |
|
|
1269 |
return status;
|
|
1270 |
}
|
|
1271 |
|
|
1272 |
// -----------------------------------------------------------------------------
|
|
1273 |
void
|
|
1274 |
CView::ExternalLayoutSwitch ()
|
|
1275 |
{
|
|
1276 |
if (iIsImageMapView)
|
|
1277 |
{
|
|
1278 |
iExternalLayoutSwitch = NW_TRUE;
|
|
1279 |
}
|
|
1280 |
}
|
|
1281 |
|
|
1282 |
// -----------------------------------------------------------------------------
|
|
1283 |
TBrowserStatusCode
|
|
1284 |
CView::SetOrigin (NW_GDI_Point2D_t* origin)
|
|
1285 |
{
|
|
1286 |
const NW_GDI_Dimension2D_t* displaySize;
|
|
1287 |
NW_GDI_Dimension2D_t canvasSize;
|
|
1288 |
NW_GDI_Dimension2D_t scrollRange;
|
|
1289 |
NW_GDI_Point2D_t oldOrigin;
|
|
1290 |
|
|
1291 |
// get the display and canvas size
|
|
1292 |
displaySize =
|
|
1293 |
&(iDeviceContext->DisplayBounds()->dimension);
|
|
1294 |
TBrowserStatusCode status = NW_LMgr_RootBox_GetExtents (iRootBox, &canvasSize);
|
|
1295 |
NW_ASSERT (status == KBrsrSuccess);
|
|
1296 |
|
|
1297 |
/* make sure that the speicified origin does not extend us beyond the
|
|
1298 |
canvas size */
|
|
1299 |
if (origin->x + displaySize->width > canvasSize.width)
|
|
1300 |
{
|
|
1301 |
origin->x = (NW_GDI_Metric_t) (canvasSize.width - displaySize->width);
|
|
1302 |
}
|
|
1303 |
|
|
1304 |
|
|
1305 |
if (origin->x < 0)
|
|
1306 |
{
|
|
1307 |
origin->x = 0;
|
|
1308 |
}
|
|
1309 |
|
|
1310 |
NW_LMgr_RootBox_GetScrollRange(NW_LMgr_RootBoxOf(iRootBox), &scrollRange);
|
|
1311 |
if (((canvasSize.width - origin->x) > scrollRange.width) &&
|
|
1312 |
NW_LMgr_RootBox_IsPageRTL(NW_LMgr_RootBoxOf(iRootBox)))
|
|
1313 |
{
|
|
1314 |
origin->x = canvasSize.width - scrollRange.width;
|
|
1315 |
}
|
|
1316 |
|
|
1317 |
if (origin->y + displaySize->height > canvasSize.height)
|
|
1318 |
{
|
|
1319 |
origin->y = (NW_GDI_Metric_t) (canvasSize.height - displaySize->height);
|
|
1320 |
}
|
|
1321 |
|
|
1322 |
if (origin->y < 0)
|
|
1323 |
{
|
|
1324 |
origin->y = 0;
|
|
1325 |
}
|
|
1326 |
|
|
1327 |
oldOrigin = *(iDeviceContext->Origin());
|
|
1328 |
|
|
1329 |
// set the origin of the DeviceContext
|
|
1330 |
if ((oldOrigin.x != origin->x) || (oldOrigin.y != origin->y))
|
|
1331 |
{
|
|
1332 |
NW_LMgr_RootBox_InvalidateCache(iRootBox);
|
|
1333 |
iDeviceContext->SetOrigin (origin);
|
|
1334 |
// update the rootBox about the change in orgin)
|
|
1335 |
NW_LMgr_RootBox_OriginChanged(iRootBox, (NW_GDI_Point2D_t*)(&oldOrigin));
|
|
1336 |
}
|
|
1337 |
return KBrsrSuccess;
|
|
1338 |
}
|
|
1339 |
|
|
1340 |
// -------------------------------------------------------------------------
|
|
1341 |
// box is a flow box, go ahead formatting the subtree of the box
|
|
1342 |
//
|
|
1343 |
// take out CView::Draw function call from ReformatBox function;
|
|
1344 |
// using NW_LMgr_IBoxTreeListener_RedrawDisplay instead, reason:
|
|
1345 |
// imageCH calls ReformatBox for each virtual image;
|
|
1346 |
// in turn CView::Draw is called for each virtual image if CView::Draw is called inside ReformatBox;
|
|
1347 |
// shell will control this situation if many View_Draw msg sent
|
|
1348 |
// thus CView::Draw called once for a group of virtual images which shares one simple image
|
|
1349 |
// -------------------------------------------------------------------------
|
|
1350 |
TBrowserStatusCode
|
|
1351 |
CView::ReformatBox (NW_LMgr_Box_t* box)
|
|
1352 |
{
|
|
1353 |
|
|
1354 |
NW_LMgr_BoxVisitor_t visitor;
|
|
1355 |
NW_LMgr_Box_t* child = NULL;
|
|
1356 |
NW_LMgr_Box_t* parentBox = NULL;
|
|
1357 |
NW_LMgr_Box_t* flowBox = NULL;
|
|
1358 |
NW_GDI_Rectangle_t childBounds;
|
|
1359 |
NW_GDI_Rectangle_t flowBounds;
|
|
1360 |
NW_GDI_Metric_t oldHeight;
|
|
1361 |
NW_GDI_Metric_t newHeight;
|
|
1362 |
NW_ADT_DynamicVector_t* backupPlacedFloats = NULL;
|
|
1363 |
NW_ADT_DynamicVector_t* backupPendingFloats = NULL;
|
|
1364 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
1365 |
NW_Bool createTabList;
|
|
1366 |
CLMgr_BoxFormatHandler* tempBoxFormatHandler= NULL;
|
|
1367 |
TInt ret = KErrNone;
|
|
1368 |
|
|
1369 |
// We try to find out the containing flow box */
|
|
1370 |
parentBox = box;
|
|
1371 |
|
|
1372 |
//if the parent is a bidiflowbox, we continue to check if there is still tabel cell box as a parent, if not,
|
|
1373 |
//we still keep this bidiflowbox as parent
|
|
1374 |
NW_LMgr_Box_t* returnedParentBox = NULL;
|
|
1375 |
GetParentBox(parentBox, &returnedParentBox);
|
|
1376 |
if(returnedParentBox != NULL) {
|
|
1377 |
parentBox = returnedParentBox;
|
|
1378 |
}
|
|
1379 |
|
|
1380 |
/* The parent box should be an instance of the flow box */
|
|
1381 |
flowBox = parentBox;
|
|
1382 |
NW_ASSERT (NW_Object_IsInstanceOf(flowBox, &NW_LMgr_FlowBox_Class));
|
|
1383 |
|
|
1384 |
/*
|
|
1385 |
** iSuppressDupReformats is true when a virtual image with more than
|
|
1386 |
** one image observer is notifying its observers that it has been "opened".
|
|
1387 |
** When iPendingReformatBox matches this box's parent then it can safely
|
|
1388 |
** skip this reformat because this box will be reformatted when
|
|
1389 |
** iPendingReformatBox is formatted -- either the box has a different parent-
|
|
1390 |
** flow-box or the box is associated with the last image observer.
|
|
1391 |
**
|
|
1392 |
** This helps speed up the special case when an image is duplicated many times
|
|
1393 |
** within the same document.
|
|
1394 |
*/
|
|
1395 |
if(iSuppressDupReformats != NW_Image_AbstractImage_SuppressDupReformats_Default)
|
|
1396 |
{
|
|
1397 |
if (iPendingReformatBox != flowBox && iPendingReformatBox != box)
|
|
1398 |
{
|
|
1399 |
// If flowBox is inside iPendingReformatBox, then forget flowBox and format only iPendingFormatBox
|
|
1400 |
NW_LMgr_Box_t* parent =(NW_LMgr_Box_t*) NW_LMgr_Box_GetParent(flowBox);
|
|
1401 |
while (parent != NULL && parent != iPendingReformatBox)
|
|
1402 |
{
|
|
1403 |
parent = (NW_LMgr_Box_t*)NW_LMgr_Box_GetParent(parent);
|
|
1404 |
}
|
|
1405 |
if (iPendingReformatBox && parent == iPendingReformatBox)
|
|
1406 |
{
|
|
1407 |
iSuppressDupReformats = NW_Image_AbstractImage_SuppressDupReformats_Stop;
|
|
1408 |
flowBox = iPendingReformatBox;
|
|
1409 |
iPendingReformatBox = NULL;
|
|
1410 |
}
|
|
1411 |
else
|
|
1412 |
{
|
|
1413 |
if (iPendingReformatBox)
|
|
1414 |
{
|
|
1415 |
NW_Int16 state = iSuppressDupReformats;
|
|
1416 |
iSuppressDupReformats = NW_Image_AbstractImage_SuppressDupReformats_Stop;
|
|
1417 |
ReformatBox (iPendingReformatBox);
|
|
1418 |
iSuppressDupReformats = state;
|
|
1419 |
}
|
|
1420 |
iPendingReformatBox = flowBox;
|
|
1421 |
}
|
|
1422 |
}
|
|
1423 |
|
|
1424 |
|
|
1425 |
if (iSuppressDupReformats != NW_Image_AbstractImage_SuppressDupReformats_Stop)
|
|
1426 |
goto finish;
|
|
1427 |
|
|
1428 |
iSuppressDupReformats = NW_Image_AbstractImage_SuppressDupReformats_Default;
|
|
1429 |
|
|
1430 |
}
|
|
1431 |
|
|
1432 |
flowBounds = NW_LMgr_Box_GetFormatBounds(flowBox);
|
|
1433 |
|
|
1434 |
// get the current height of the flow box since after formatting the
|
|
1435 |
// height will change
|
|
1436 |
oldHeight = flowBounds.dimension.height;
|
|
1437 |
|
|
1438 |
// collapse the contents of this flow box, since it will be reformatted
|
|
1439 |
status = Collapse (NW_LMgr_FlowBoxOf(flowBox), NW_FALSE);
|
|
1440 |
NW_LOG0(NW_LOG_LEVEL2, "CView::Collapse passed");
|
|
1441 |
if (status != KBrsrSuccess)
|
|
1442 |
{
|
|
1443 |
goto finish;
|
|
1444 |
}
|
|
1445 |
|
|
1446 |
/* Initialize the visitor to flowBox */
|
|
1447 |
NW_LMgr_BoxVisitor_Initialize(&visitor, flowBox);
|
|
1448 |
|
|
1449 |
child = NW_LMgr_BoxVisitor_NextBox(&visitor, 0);
|
|
1450 |
|
|
1451 |
/* Set the font on the rootbox */
|
|
1452 |
status = NW_LMgr_Box_ApplyFontProps(NW_LMgr_BoxOf(child));
|
|
1453 |
NW_LOG0(NW_LOG_LEVEL2, "NW_LMgr_Box_ApplyFontProps passed");
|
|
1454 |
if (status != KBrsrSuccess)
|
|
1455 |
{
|
|
1456 |
goto finish;
|
|
1457 |
}
|
|
1458 |
|
|
1459 |
// floats needs to be removed from the rootbox while the re-layout is
|
|
1460 |
// formatting the subtree as the formatting code cannot cope with
|
|
1461 |
// the case where only a subtree is being formatted but the
|
|
1462 |
// float lists include boxes from the entire tree.
|
|
1463 |
// This is a quick fix on 2.1 showstopper and it has to be
|
|
1464 |
// reviewed and find a better solution (fixing the format code)
|
|
1465 |
|
|
1466 |
// save placed and pending floats
|
|
1467 |
backupPlacedFloats = iRootBox->placedFloats;
|
|
1468 |
iRootBox->placedFloats = (NW_ADT_DynamicVector_t*)
|
|
1469 |
NW_ADT_ResizableVector_New(sizeof (NW_LMgr_Box_t*), 0, 5 );
|
|
1470 |
if (!iRootBox->placedFloats)
|
|
1471 |
{
|
|
1472 |
status = KBrsrOutOfMemory;
|
|
1473 |
goto finish;
|
|
1474 |
}
|
|
1475 |
|
|
1476 |
backupPendingFloats = iRootBox->pendingFloats;
|
|
1477 |
iRootBox->pendingFloats = (NW_ADT_DynamicVector_t*)
|
|
1478 |
NW_ADT_ResizableVector_New(sizeof (NW_LMgr_Box_t*), 0, 5 );
|
|
1479 |
if (!iRootBox->pendingFloats)
|
|
1480 |
{
|
|
1481 |
status = KBrsrOutOfMemory;
|
|
1482 |
goto finish;
|
|
1483 |
}
|
|
1484 |
|
|
1485 |
while ((child = NW_LMgr_BoxVisitor_NextBox(&visitor,0)) != NULL)
|
|
1486 |
{
|
|
1487 |
if (box != NULL && NW_Object_IsInstanceOf(child, &NW_LMgr_PosFlowBox_Class))
|
|
1488 |
{
|
|
1489 |
NW_Bool skip = NW_TRUE;
|
|
1490 |
child = NW_LMgr_BoxVisitor_NextBox( &visitor, &skip);
|
|
1491 |
if (child == NULL)
|
|
1492 |
{
|
|
1493 |
break;
|
|
1494 |
}
|
|
1495 |
}
|
|
1496 |
/* Initialize the coordinates */
|
|
1497 |
NW_Mem_memset( &childBounds, 0, sizeof(NW_GDI_Rectangle_t));
|
|
1498 |
|
|
1499 |
SetBoxFormatBounds( child, childBounds );
|
|
1500 |
NW_LMgr_Box_UpdateDisplayBounds( child, childBounds );
|
|
1501 |
/* Clean up any flows */
|
|
1502 |
if (NW_Object_IsInstanceOf(child, &NW_LMgr_BidiFlowBox_Class) ||
|
|
1503 |
NW_Object_IsClass(child, &NW_LMgr_StaticTableCellBox_Class))
|
|
1504 |
{
|
|
1505 |
status = ((CLMgr_BoxFormatHandler*)(iBoxFormatHandler))->InitializeBox(NW_LMgr_BidiFlowBoxOf(child));
|
|
1506 |
if (status != KBrsrSuccess)
|
|
1507 |
{
|
|
1508 |
goto finish;
|
|
1509 |
}
|
|
1510 |
}
|
|
1511 |
|
|
1512 |
if ( !NW_Object_IsInstanceOf(box, &NW_LMgr_PosFlowBox_Class) &&
|
|
1513 |
(NW_Object_IsClass(child, &NW_LMgr_ContainerBox_Class) ||
|
|
1514 |
NW_Object_IsClass(child, &NW_LMgr_ActiveContainerBox_Class) ) )
|
|
1515 |
{
|
|
1516 |
status = NW_LMgr_ContainerBox_Initialize(NW_LMgr_ContainerBoxOf(child));
|
|
1517 |
if (status != KBrsrSuccess)
|
|
1518 |
{
|
|
1519 |
goto finish;
|
|
1520 |
}
|
|
1521 |
}
|
|
1522 |
}
|
|
1523 |
NW_LOG0(NW_LOG_LEVEL2, "child = NW_LMgr_BoxVisitor_NextBox passed");
|
|
1524 |
/* because of KBrsrLmgrFormatOverflow, don't check on status;
|
|
1525 |
* is this ok for SSL?
|
|
1526 |
*/
|
|
1527 |
|
|
1528 |
// create a boxFormatHandler and format the flowBox
|
|
1529 |
TRAP(ret, tempBoxFormatHandler = CLMgr_BoxFormatHandler::NewL(flowBox, ETrue));
|
|
1530 |
if (!tempBoxFormatHandler)
|
|
1531 |
{
|
|
1532 |
status = KBrsrOutOfMemory;
|
|
1533 |
goto finish;
|
|
1534 |
}
|
|
1535 |
|
|
1536 |
#ifdef _DEBUG_LOG
|
|
1537 |
//#pragma message(__LINE__" WARNING: The following code crashes on a sar segment test of 10Kb or greater.\n")
|
|
1538 |
/* dump the box tree */
|
|
1539 |
NW_LOG0(NW_LOG_LEVEL3, "[LMgr: ReformatBox method: before PartialFormatL]");
|
|
1540 |
NW_LMgr_Box_DumpBoxTree (flowBox);
|
|
1541 |
#endif
|
|
1542 |
|
|
1543 |
// we do not want the tab list to be appended on selective formatting
|
|
1544 |
createTabList = iCreateTabList ;
|
|
1545 |
iCreateTabList = NW_FALSE;
|
|
1546 |
TRAPD(ret1,tempBoxFormatHandler->PartialFormatL( iFormatPriority ));
|
|
1547 |
// set the flag
|
|
1548 |
iCreateTabList = createTabList;
|
|
1549 |
NW_LOG0(NW_LOG_LEVEL2, "PartialFormatL passed");
|
|
1550 |
if (ret1 != KErrNone)
|
|
1551 |
{
|
|
1552 |
status = KBrsrFailure;
|
|
1553 |
}
|
|
1554 |
tempBoxFormatHandler->PageLoadCompleted();
|
|
1555 |
NW_LOG0(NW_LOG_LEVEL2, "PageLoadCompleted passed");
|
|
1556 |
delete tempBoxFormatHandler;
|
|
1557 |
|
|
1558 |
if (status != KBrsrSuccess)
|
|
1559 |
{
|
|
1560 |
goto finish;
|
|
1561 |
}
|
|
1562 |
|
|
1563 |
#ifdef _DEBUG_LOG
|
|
1564 |
/* dump the box tree */
|
|
1565 |
NW_LOG0(NW_LOG_LEVEL3, "[LMgr: ReformatBox method: after PartialFormatL]");
|
|
1566 |
NW_LMgr_Box_DumpBoxTree (flowBox);
|
|
1567 |
#endif
|
|
1568 |
|
|
1569 |
flowBounds = NW_LMgr_Box_GetFormatBounds(flowBox);
|
|
1570 |
newHeight = flowBounds.dimension.height;
|
|
1571 |
|
|
1572 |
// If we are formatting a positioned box - do not shift the rest of the tree
|
|
1573 |
// If we are formatting an image inside a positioned box, shift only the sub-tree up to the positioned box
|
|
1574 |
// If we are formatting an image that is a sibling of a positioned box - skip the positioned box when shifting the box tree
|
|
1575 |
if (oldHeight != newHeight && (!NW_Object_IsInstanceOf(flowBox, &NW_LMgr_PosFlowBox_Class)))
|
|
1576 |
{
|
|
1577 |
// Now we want to adjust heigtht of all parent boxes affected
|
|
1578 |
parentBox = (NW_LMgr_Box_t*)NW_LMgr_Box_GetParent(flowBox);
|
|
1579 |
|
|
1580 |
while (parentBox != NULL && !NW_Object_IsInstanceOf(parentBox, &NW_LMgr_PosFlowBox_Class))
|
|
1581 |
{
|
|
1582 |
NW_GDI_Rectangle_t boxBounds = NW_LMgr_Box_GetFormatBounds( parentBox );
|
|
1583 |
if (oldHeight < newHeight)
|
|
1584 |
{
|
|
1585 |
boxBounds.dimension.height = (NW_GDI_Metric_t) (boxBounds.dimension.height +
|
|
1586 |
(newHeight - oldHeight));
|
|
1587 |
}
|
|
1588 |
else
|
|
1589 |
{
|
|
1590 |
boxBounds.dimension.height = (NW_GDI_Metric_t)(boxBounds.dimension.height -
|
|
1591 |
(oldHeight - newHeight));
|
|
1592 |
}
|
|
1593 |
NW_LMgr_Box_SetFormatBounds( parentBox, boxBounds );
|
|
1594 |
NW_LMgr_Box_UpdateDisplayBounds( parentBox, boxBounds );
|
|
1595 |
parentBox = (NW_LMgr_Box_t*)NW_LMgr_Box_GetParent(NW_LMgr_BoxOf(parentBox));
|
|
1596 |
}
|
|
1597 |
|
|
1598 |
// update rootbox
|
|
1599 |
iRootBox->calculateExtents = NW_TRUE;
|
|
1600 |
|
|
1601 |
if (!NW_Object_IsInstanceOf(parentBox, &NW_LMgr_PosFlowBox_Class))
|
|
1602 |
{
|
|
1603 |
// Now we want to adjust the y parameter of all the lower boxes
|
|
1604 |
|
|
1605 |
// Initialize the Box Visitor to current FlowBox
|
|
1606 |
NW_LMgr_BoxVisitor_Initialize(&visitor, NW_LMgr_BoxOf(iRootBox));
|
|
1607 |
visitor.currentBox = flowBox;
|
|
1608 |
// Skip children of this Flow Box and go to the next box in the tree
|
|
1609 |
NW_Bool skipChildren = NW_TRUE;
|
|
1610 |
child = NW_LMgr_BoxVisitor_NextBox(&visitor,&skipChildren);
|
|
1611 |
while (child != NULL)
|
|
1612 |
{
|
|
1613 |
// Do not shift nested absolute positioned boxes
|
|
1614 |
if (NW_Object_IsInstanceOf(child, &NW_LMgr_PosFlowBox_Class))
|
|
1615 |
{
|
|
1616 |
NW_Bool skip = NW_TRUE;
|
|
1617 |
child = NW_LMgr_BoxVisitor_NextBox(&visitor, &skip);
|
|
1618 |
continue;
|
|
1619 |
}
|
|
1620 |
childBounds = NW_LMgr_Box_GetFormatBounds(child);
|
|
1621 |
|
|
1622 |
if (oldHeight < newHeight)
|
|
1623 |
{
|
|
1624 |
childBounds.point.y = (NW_GDI_Metric_t)
|
|
1625 |
(childBounds.point.y + (newHeight - oldHeight));
|
|
1626 |
}
|
|
1627 |
else
|
|
1628 |
{
|
|
1629 |
childBounds.point.y = (NW_GDI_Metric_t)
|
|
1630 |
(childBounds.point.y - (oldHeight - newHeight));
|
|
1631 |
}
|
|
1632 |
SetBoxFormatBounds( child, childBounds );
|
|
1633 |
NW_LMgr_Box_UpdateDisplayBounds( child, childBounds );
|
|
1634 |
|
|
1635 |
child = NW_LMgr_BoxVisitor_NextBox(&visitor,0);
|
|
1636 |
}
|
|
1637 |
}
|
|
1638 |
else
|
|
1639 |
{
|
|
1640 |
// If the vertical position was specified from the bottom, the positioned sub-tree
|
|
1641 |
// has to be adjusted, to maintain the correct bottom position
|
|
1642 |
if (NW_LMgr_PosFlowBoxOf(parentBox)->iHasBottom)
|
|
1643 |
{
|
|
1644 |
// Initialize the Box Visitor to current FlowBox
|
|
1645 |
NW_LMgr_BoxVisitor_Initialize(&visitor, NW_LMgr_BoxOf(flowBox));
|
|
1646 |
// Skip children of this Flow Box and go to the next box in the tree
|
|
1647 |
NW_Bool skipChildren = NW_FALSE;
|
|
1648 |
child = NW_LMgr_BoxVisitor_NextBox(&visitor,&skipChildren);
|
|
1649 |
while (child != NULL)
|
|
1650 |
{
|
|
1651 |
// Do not shift nested absolute positioned boxes
|
|
1652 |
if (NW_Object_IsInstanceOf(child, &NW_LMgr_PosFlowBox_Class))
|
|
1653 |
{
|
|
1654 |
NW_Bool skip = NW_TRUE;
|
|
1655 |
child = NW_LMgr_BoxVisitor_NextBox(&visitor, &skip);
|
|
1656 |
continue;
|
|
1657 |
}
|
|
1658 |
childBounds = NW_LMgr_Box_GetFormatBounds(child);
|
|
1659 |
|
|
1660 |
childBounds.point.y = (NW_GDI_Metric_t)
|
|
1661 |
(childBounds.point.y - (newHeight - oldHeight));
|
|
1662 |
SetBoxFormatBounds( child, childBounds );
|
|
1663 |
NW_LMgr_Box_UpdateDisplayBounds( child, childBounds );
|
|
1664 |
child = NW_LMgr_BoxVisitor_NextBox(&visitor, &skipChildren);
|
|
1665 |
}
|
|
1666 |
}
|
|
1667 |
}
|
|
1668 |
}
|
|
1669 |
NW_LOG0(NW_LOG_LEVEL2, "height update passed");
|
|
1670 |
|
|
1671 |
// DrawNow msg sent
|
|
1672 |
(void)RedrawDisplay( NW_FALSE );
|
|
1673 |
|
|
1674 |
#ifdef _DEBUG_LOG
|
|
1675 |
/* dump the box tree */
|
|
1676 |
NW_LOG0(NW_LOG_LEVEL3, "[LMgr: End ReformatBox method]");
|
|
1677 |
NW_LMgr_Box_DumpBoxTree (NW_LMgr_BoxOf(iRootBox));
|
|
1678 |
#endif
|
|
1679 |
|
|
1680 |
finish:
|
|
1681 |
// restore both placed and pending floats ( see comments above)
|
|
1682 |
if( backupPlacedFloats )
|
|
1683 |
{
|
|
1684 |
NW_Object_Delete( iRootBox->placedFloats);
|
|
1685 |
iRootBox->placedFloats = backupPlacedFloats;
|
|
1686 |
}
|
|
1687 |
|
|
1688 |
if( backupPendingFloats )
|
|
1689 |
{
|
|
1690 |
NW_Object_Delete( iRootBox->pendingFloats);
|
|
1691 |
iRootBox->pendingFloats = backupPendingFloats;
|
|
1692 |
}
|
|
1693 |
|
|
1694 |
/* successful completion */
|
|
1695 |
NW_LOG0(NW_LOG_LEVEL2, "CView::ReformatBox passed");
|
|
1696 |
return status;
|
|
1697 |
}
|
|
1698 |
|
|
1699 |
|
|
1700 |
/* ------------------------------------------------------------------------- */
|
|
1701 |
TBrowserStatusCode
|
|
1702 |
CView::FormatPartial ()
|
|
1703 |
{
|
|
1704 |
|
|
1705 |
TBrowserStatusCode status =KBrsrSuccess;
|
|
1706 |
NW_LOG0(NW_LOG_LEVEL2, "CView::FormatPartial START");
|
|
1707 |
|
|
1708 |
//TODO handle leave
|
|
1709 |
TRAPD(err, ((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->PartialFormatL( iFormatPriority ));
|
|
1710 |
NW_GDI_Rectangle_t boxBounds = NW_LMgr_Box_GetFormatBounds( NW_LMgr_BoxOf( iRootBox ) );
|
|
1711 |
|
|
1712 |
iRootBox->extents.dimension.height = boxBounds.dimension.height;
|
|
1713 |
UpdateScrollBars ();
|
|
1714 |
NW_LOG0(NW_LOG_LEVEL2, "PartialFormatL passed");
|
|
1715 |
if(err != KErrNone)
|
|
1716 |
{
|
|
1717 |
status = KBrsrFailure;
|
|
1718 |
}
|
|
1719 |
NW_LOG0(NW_LOG_LEVEL2, "CView::FormatPartial END");
|
|
1720 |
return status;
|
|
1721 |
}
|
|
1722 |
|
|
1723 |
/* ------------------------------------------------------------------------- */
|
|
1724 |
/* return NULL in non-split case
|
|
1725 |
*/
|
|
1726 |
NW_LMgr_Box_t*
|
|
1727 |
CView::GetNextSiblingBox (const NW_LMgr_Box_t* box)
|
|
1728 |
{
|
|
1729 |
NW_LMgr_Box_t *siblingBox = NULL;
|
|
1730 |
NW_LMgr_PropertyList_t* propList;
|
|
1731 |
NW_LMgr_Property_t prop;
|
|
1732 |
|
|
1733 |
NW_ASSERT(box != NULL);
|
|
1734 |
|
|
1735 |
propList = NW_LMgr_Box_PropListGet(box);
|
|
1736 |
if( propList )
|
|
1737 |
{
|
|
1738 |
prop.value.object = NULL;
|
|
1739 |
(void)NW_LMgr_PropertyList_Get(propList, NW_CSS_Prop_sibling, &prop);
|
|
1740 |
if(prop.value.object != NULL)
|
|
1741 |
{
|
|
1742 |
siblingBox = NW_LMgr_BoxOf(prop.value.object);
|
|
1743 |
}
|
|
1744 |
else
|
|
1745 |
/* If it's null, it means non-split case */
|
|
1746 |
{
|
|
1747 |
siblingBox = NULL;
|
|
1748 |
}
|
|
1749 |
}
|
|
1750 |
else
|
|
1751 |
{
|
|
1752 |
siblingBox = NULL;
|
|
1753 |
}
|
|
1754 |
|
|
1755 |
return siblingBox;
|
|
1756 |
}
|
|
1757 |
|
|
1758 |
/* ------------------------------------------------------------------------- *
|
|
1759 |
public/protected static methods
|
|
1760 |
* ------------------------------------------------------------------------- */
|
|
1761 |
|
|
1762 |
// -----------------------------------------------------------------------------
|
|
1763 |
NW_LMgr_Box_t*
|
|
1764 |
CView::GetNextEventListener (NW_LMgr_BoxVisitor_t* boxVisitor)
|
|
1765 |
{
|
|
1766 |
NW_LMgr_Box_t* box = NULL;
|
|
1767 |
NW_GDI_Rectangle_t boxBounds;
|
|
1768 |
|
|
1769 |
while ((box = NW_LMgr_BoxVisitor_NextBox (boxVisitor, NULL)) != NULL)
|
|
1770 |
{
|
|
1771 |
NW_LMgr_IEventListener_t* eventListener;
|
|
1772 |
|
|
1773 |
/* we are only looking for boxes implementing the NW_LMgr_IEventListener
|
|
1774 |
interface */
|
|
1775 |
eventListener = static_cast<NW_LMgr_IEventListener_t*>(NW_Object_QueryInterface (box, &NW_LMgr_IEventListener_Class));
|
|
1776 |
if (eventListener == NULL)
|
|
1777 |
{
|
|
1778 |
continue;
|
|
1779 |
}
|
|
1780 |
|
|
1781 |
/* If activeContainerBox has zero length or zero width, we skip this
|
|
1782 |
activeContainerBox. This happens when activeContaninerBox only has
|
|
1783 |
one breakBox child */
|
|
1784 |
if (NW_Object_IsInstanceOf (box, &NW_LMgr_ActiveContainerBox_Class))
|
|
1785 |
{
|
|
1786 |
boxBounds = NW_LMgr_Box_GetDisplayBounds(box);
|
|
1787 |
if (boxBounds.dimension.width == 0 || boxBounds.dimension.height == 0)
|
|
1788 |
{
|
|
1789 |
continue;
|
|
1790 |
}
|
|
1791 |
}
|
|
1792 |
return (box);
|
|
1793 |
}
|
|
1794 |
return (NULL);
|
|
1795 |
}
|
|
1796 |
|
|
1797 |
/* ------------------------------------------------------------------------- *
|
|
1798 |
NW_Object_Dynamic methods
|
|
1799 |
* ------------------------------------------------------------------------- */
|
|
1800 |
// -----------------------------------------------------------------------------
|
|
1801 |
// CView::CView
|
|
1802 |
// C++ default constructor can NOT contain any code, that might leave.
|
|
1803 |
// -----------------------------------------------------------------------------
|
|
1804 |
CView::CView (CBrCtl* aBrCtl) :
|
|
1805 |
iVScrollPosition(0), iFormatPriority( ((CActive::TPriority)( CActive::EPriorityLow + 2 )) )
|
|
1806 |
{
|
|
1807 |
iBrCtl = aBrCtl;
|
|
1808 |
iDrag = EFalse;
|
|
1809 |
}
|
|
1810 |
|
|
1811 |
// -----------------------------------------------------------------------------
|
|
1812 |
// CView::ConstructL
|
|
1813 |
// Symbian 2nd phase constructor can leave.
|
|
1814 |
// -----------------------------------------------------------------------------
|
|
1815 |
void CView::ConstructL (CCoeControl* aParent, TRect& aRect, CWmlControl* aWmlControl )
|
|
1816 |
{
|
|
1817 |
static const NW_GDI_Metric_t sVScrollAmt = 18;
|
|
1818 |
static const NW_GDI_Metric_t sHScrollAmt = 18;
|
|
1819 |
static const NW_GDI_Metric_t sVVisibleAmt = 10;
|
|
1820 |
static const NW_GDI_Metric_t sHVisibleAmt = 10;
|
|
1821 |
CGDIDeviceContext* deviceContext = NULL;
|
|
1822 |
void* graphicsContext = NULL;
|
|
1823 |
NW_GDI_Rectangle_t displayBounds = { {0,0},{0,0} };
|
|
1824 |
NW_HED_AppServices_t* appServices = NULL;
|
|
1825 |
|
|
1826 |
CreateWindowL( aParent );
|
|
1827 |
SetMopParent( aParent );
|
|
1828 |
|
|
1829 |
iWmlControl = aWmlControl;
|
|
1830 |
|
|
1831 |
// create a bitmap to be used offscreen
|
|
1832 |
CreateOffscreenBitmapL( Rect() );
|
|
1833 |
|
|
1834 |
// create root box array
|
|
1835 |
iRootBoxArray = new (ELeave) CArrayPtrFlat<NW_LMgr_RootBox_t>(2);
|
|
1836 |
|
|
1837 |
iSuppressDupReformats = NW_Image_AbstractImage_SuppressDupReformats_Default;
|
|
1838 |
// create the rootBox
|
|
1839 |
iRootBox = NW_LMgr_RootBox_New (appServices);
|
|
1840 |
User::LeaveIfNull(iRootBox);
|
|
1841 |
|
|
1842 |
iRootBoxArray->AppendL(iRootBox);
|
|
1843 |
// observer small screen and text wrap settings
|
|
1844 |
//CBrowserSettings::Instance()->SetObserver( this,
|
|
1845 |
// EVerticalLayoutEnabled|EDisableSmallScreenLayout|ETextWrapEnabled );
|
|
1846 |
|
|
1847 |
iBoxFormatHandler = (void*)CLMgr_BoxFormatHandler::NewL(NW_LMgr_BoxOf(iRootBox ), EFalse);
|
|
1848 |
|
|
1849 |
(void) NW_LMgr_RootBox_SetBoxTreeListener (iRootBox, this);
|
|
1850 |
|
|
1851 |
/* Make sure the rootbox has the focus at the beginning */
|
|
1852 |
NW_LMgr_RootBox_GainFocus(iRootBox);
|
|
1853 |
|
|
1854 |
iTabList = (NW_ADT_DynamicVector_t*)
|
|
1855 |
NW_ADT_ResizableVector_New (sizeof(NW_LMgr_Box_t), 10, 5 );
|
|
1856 |
iOptionItemList = NULL;
|
|
1857 |
|
|
1858 |
/* Deleted in destruct */
|
|
1859 |
iScroll = CMVCScroll::NewL(this);
|
|
1860 |
|
|
1861 |
iMaxScrollAmt.width = 0;
|
|
1862 |
iMaxScrollAmt.height = 0;
|
|
1863 |
iScrollAmt.width = sHScrollAmt;
|
|
1864 |
iScrollAmt.height = sVScrollAmt;
|
|
1865 |
iVisibleAmt.width = sHVisibleAmt;
|
|
1866 |
iVisibleAmt.height = sVVisibleAmt;
|
|
1867 |
|
|
1868 |
iCreateTabList = NW_FALSE;
|
|
1869 |
|
|
1870 |
iIsImageMapView = NW_FALSE;
|
|
1871 |
iExternalLayoutSwitch = NW_FALSE;
|
|
1872 |
|
|
1873 |
// create the deviceContext
|
|
1874 |
graphicsContext = iBitmapContext;
|
|
1875 |
deviceContext = CGDIDeviceContext::NewL (graphicsContext, this);
|
|
1876 |
// ignore err
|
|
1877 |
NW_ASSERT ( deviceContext!= NULL);
|
|
1878 |
|
|
1879 |
/* set bounds */
|
|
1880 |
deviceContext->SetDisplayBounds( &displayBounds);
|
|
1881 |
|
|
1882 |
/* set the DeviceContext on ourselves */
|
|
1883 |
TBrowserStatusCode status = CView::SetDeviceContext (deviceContext);
|
|
1884 |
NW_ASSERT (status == KBrsrSuccess);
|
|
1885 |
|
|
1886 |
// create SharedDataClient and ask for a couple of notifications
|
|
1887 |
iRepository = CRepository::NewL(KCRUidCacheManager);
|
|
1888 |
iNotifyHandler = CCenRepNotifyHandler::NewL(*this, *iRepository, CCenRepNotifyHandler::EIntKey, (TUint32)KCacheManagerHttpCacheEnabled);
|
|
1889 |
iNotifyHandler->StartListeningL();
|
|
1890 |
|
|
1891 |
if (FeatureManager::FeatureSupported(KFeatureIdJapanesePicto))
|
|
1892 |
{
|
|
1893 |
iPictographInterface = CAknPictographInterface::NewL( *this, *this );
|
|
1894 |
}
|
|
1895 |
else
|
|
1896 |
{
|
|
1897 |
iPictographInterface = NULL;
|
|
1898 |
}
|
|
1899 |
iViewAsyncInit = CViewAsyncInit::NewL();
|
|
1900 |
|
|
1901 |
InitializePageScalerL();
|
|
1902 |
|
|
1903 |
SetRect(aRect);
|
|
1904 |
|
|
1905 |
if (AknLayoutUtils::PenEnabled())
|
|
1906 |
{
|
|
1907 |
DrawableWindow()->SetPointerGrab(ETrue);
|
|
1908 |
EnableDragEvents();
|
|
1909 |
}
|
|
1910 |
|
|
1911 |
iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityHigh);
|
|
1912 |
|
|
1913 |
ActivateL();
|
|
1914 |
}
|
|
1915 |
|
|
1916 |
// -----------------------------------------------------------------------------
|
|
1917 |
// CView::NewL
|
|
1918 |
// Two-phased constructor.
|
|
1919 |
// -----------------------------------------------------------------------------
|
|
1920 |
CView* CView::NewL (CCoeControl* aParent,
|
|
1921 |
CBrCtl* aBrCtl, TRect& aRect, CWmlControl* aWmlControl )
|
|
1922 |
{
|
|
1923 |
CView* epocView = new (ELeave) CView(aBrCtl);
|
|
1924 |
|
|
1925 |
CleanupStack::PushL(epocView);
|
|
1926 |
epocView->ConstructL(aParent, aRect, aWmlControl );
|
|
1927 |
CleanupStack::Pop(); // epocView
|
|
1928 |
return epocView;
|
|
1929 |
}
|
|
1930 |
|
|
1931 |
//-----------------------------------------------------------------------------
|
|
1932 |
// Destructor
|
|
1933 |
CView::~CView()
|
|
1934 |
{
|
|
1935 |
if(iPeriodicTimer)
|
|
1936 |
{
|
|
1937 |
// Calling Cancel without checking if the timer is active is safe
|
|
1938 |
iPeriodicTimer->Cancel();
|
|
1939 |
delete iPeriodicTimer;
|
|
1940 |
}
|
|
1941 |
// remove observer
|
|
1942 |
//CBrowserSettings::Instance()->RemoveObserver();
|
|
1943 |
|
|
1944 |
if(iNotifyHandler)
|
|
1945 |
{
|
|
1946 |
iNotifyHandler->StopListening();
|
|
1947 |
}
|
|
1948 |
delete iNotifyHandler;
|
|
1949 |
delete iRepository;
|
|
1950 |
if (iAnchorName != NULL)
|
|
1951 |
{
|
|
1952 |
NW_Object_Delete(iAnchorName);
|
|
1953 |
iAnchorName = NULL;
|
|
1954 |
|
|
1955 |
}
|
|
1956 |
if (iScroll != NULL)
|
|
1957 |
{
|
|
1958 |
delete iScroll;
|
|
1959 |
iScroll = NULL;
|
|
1960 |
}
|
|
1961 |
|
|
1962 |
if (iPageScaler != NULL)
|
|
1963 |
{
|
|
1964 |
delete iPageScaler;
|
|
1965 |
iPageScaler = NULL;
|
|
1966 |
}
|
|
1967 |
|
|
1968 |
delete (CLMgr_BoxFormatHandler*)iBoxFormatHandler;
|
|
1969 |
|
|
1970 |
if (iRootBoxArray != NULL)
|
|
1971 |
{
|
|
1972 |
for (TInt i = 0; i < iRootBoxArray->Count(); i++)
|
|
1973 |
{
|
|
1974 |
NW_LMgr_RootBox_t* rootBox = iRootBoxArray->At(i);
|
|
1975 |
NW_ASSERT(rootBox);
|
|
1976 |
|
|
1977 |
NW_Object_Delete(rootBox);
|
|
1978 |
}
|
|
1979 |
iRootBoxArray->Reset();
|
|
1980 |
delete iRootBoxArray;
|
|
1981 |
}
|
|
1982 |
|
|
1983 |
delete iDeviceContext;
|
|
1984 |
NW_Object_Delete (iTabList);
|
|
1985 |
DeleteOptionItems ();
|
|
1986 |
|
|
1987 |
delete iBitmapContext;
|
|
1988 |
delete iBitmapDevice;
|
|
1989 |
delete iOffscreenBitmap;
|
|
1990 |
delete iPictographInterface;
|
|
1991 |
iViewFocusObserver.Reset();
|
|
1992 |
iStateChangeObserver.Reset();
|
|
1993 |
|
|
1994 |
if (iViewAsyncInit)
|
|
1995 |
{
|
|
1996 |
iViewAsyncInit->Cancel();
|
|
1997 |
delete iViewAsyncInit;
|
|
1998 |
}
|
|
1999 |
|
|
2000 |
NW_Cleanup();
|
|
2001 |
|
|
2002 |
CloseSTDLIB();
|
|
2003 |
}
|
|
2004 |
|
|
2005 |
/* ------------------------------------------------------------------------- *
|
|
2006 |
methods
|
|
2007 |
* ------------------------------------------------------------------------- */
|
|
2008 |
|
|
2009 |
// -----------------------------------------------------------------------------
|
|
2010 |
TBrowserStatusCode
|
|
2011 |
CView::SetBoxTree (const NW_LMgr_Box_t* boxTree)
|
|
2012 |
{
|
|
2013 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
2014 |
TBool errOccur = ETrue;
|
|
2015 |
NW_GDI_Point2D_t origin;
|
|
2016 |
|
|
2017 |
NW_LOG0( NW_LOG_LEVEL2, "CView::SetBoxTree START" );
|
|
2018 |
|
|
2019 |
/* remove any pre-existing box tree */
|
|
2020 |
if (boxTree == NULL)
|
|
2021 |
{
|
|
2022 |
iDocumentFinished = EFalse;
|
|
2023 |
iPageScaler->DocumentStarted();
|
|
2024 |
|
|
2025 |
NW_LOG0( NW_LOG_LEVEL2, "CView::CreateTabIndexList boxTree == NULL" );
|
|
2026 |
/* unset the currentBox */
|
|
2027 |
iCurrentBox = NULL;
|
|
2028 |
// we do this only for WML or the first chunk
|
|
2029 |
if (iOptionItemList != NULL)
|
|
2030 |
{
|
|
2031 |
DeleteOptionItems ();
|
|
2032 |
}
|
|
2033 |
(void) NW_ADT_DynamicVector_Clear (iTabList);
|
|
2034 |
iCreateTabList = NW_TRUE;
|
|
2035 |
|
|
2036 |
/* reset the DeviceContext origin */
|
|
2037 |
NW_Mem_memset (&origin, 0, sizeof origin);
|
|
2038 |
iDeviceContext->SetOrigin (&origin);
|
|
2039 |
|
|
2040 |
/* remove any pre-existing box tree */
|
|
2041 |
status =
|
|
2042 |
NW_LMgr_ContainerBox_RemoveChildren (NW_LMgr_ContainerBoxOf (iRootBox));
|
|
2043 |
NW_ASSERT (status == KBrsrSuccess);
|
|
2044 |
NW_LMgr_RootBox_SetBody(iRootBox, NULL);
|
|
2045 |
}
|
|
2046 |
|
|
2047 |
// get the document box tree and insert it into the RootBox
|
|
2048 |
if(boxTree != NULL && NW_LMgr_Box_GetParent (boxTree) == NULL)
|
|
2049 |
{
|
|
2050 |
status =
|
|
2051 |
NW_LMgr_ContainerBox_AddChild (NW_LMgr_ContainerBoxOf (iRootBox),
|
|
2052 |
NW_LMgr_BoxOf(boxTree));
|
|
2053 |
NW_ASSERT (status == KBrsrSuccess);
|
|
2054 |
}
|
|
2055 |
|
|
2056 |
NW_LMgr_Box_t* rootBox = NW_LMgr_BoxOf (iRootBox);
|
|
2057 |
NW_ASSERT(rootBox);
|
|
2058 |
if (rootBox) {} // fix warning
|
|
2059 |
|
|
2060 |
NW_LOG0(NW_LOG_LEVEL3, "[LMgr: Before box tree formatting... in CView::SetBoxTree()]");
|
|
2061 |
#ifdef _DEBUG_LOG
|
|
2062 |
|
|
2063 |
NW_LMgr_Box_DumpBoxTree (NW_LMgr_BoxOf(iRootBox));
|
|
2064 |
#endif
|
|
2065 |
|
|
2066 |
/* different formatting for partial render */
|
|
2067 |
if ( boxTree == NULL || !iRootBox->partialRender ||
|
|
2068 |
( iRootBox->partialRender && iRootBox->renderingState == NW_LMgr_RootBox_RenderFirstChunk ) )
|
|
2069 |
{
|
|
2070 |
NW_LOG0(NW_LOG_LEVEL3, "[LMgr: Start box tree formatting...]");
|
|
2071 |
// Initialize the tree
|
|
2072 |
status = InitializeTree (iRootBox, EFalse);
|
|
2073 |
NW_LOG0( NW_LOG_LEVEL2, "CView::InitializeTree passed" );
|
|
2074 |
if (status != KBrsrSuccess)
|
|
2075 |
{
|
|
2076 |
goto finish;
|
|
2077 |
}
|
|
2078 |
|
|
2079 |
// Do the layout
|
|
2080 |
if( boxTree )
|
|
2081 |
{
|
|
2082 |
status = SetupTableFormat (NW_FALSE);
|
|
2083 |
NW_LOG0( NW_LOG_LEVEL2, "SetupTableFormat passed" );
|
|
2084 |
|
|
2085 |
if( status != KBrsrNotFound )
|
|
2086 |
{
|
|
2087 |
// ignore KBrsrNotFound error as it indicates that there in no table in the page
|
|
2088 |
if (status != KBrsrSuccess)
|
|
2089 |
{
|
|
2090 |
goto finish;
|
|
2091 |
}
|
|
2092 |
}
|
|
2093 |
|
|
2094 |
status = KBrsrSuccess;
|
|
2095 |
|
|
2096 |
if( iOptionItemList )
|
|
2097 |
{
|
|
2098 |
DeleteOptionItems ();
|
|
2099 |
}
|
|
2100 |
(void) NW_ADT_DynamicVector_Clear( iTabList );
|
|
2101 |
iCreateTabList = NW_TRUE;
|
|
2102 |
// clear any prev formatting context for the first chunk
|
|
2103 |
((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->ClearFormattingContext();
|
|
2104 |
TRAPD( err ,((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->PartialFormatL( iFormatPriority ));
|
|
2105 |
|
|
2106 |
NW_LOG0( NW_LOG_LEVEL2, "PartialFormatL passed" );
|
|
2107 |
|
|
2108 |
if(err != KErrNone)
|
|
2109 |
{
|
|
2110 |
status = KBrsrFailure;
|
|
2111 |
goto finish;
|
|
2112 |
}
|
|
2113 |
}
|
|
2114 |
NW_ASSERT(status == KBrsrSuccess);
|
|
2115 |
#ifdef _DEBUG_LOG
|
|
2116 |
/* dump the box tree */
|
|
2117 |
NW_LOG0(NW_LOG_LEVEL3, "[LMgr: End box tree formatting... in CView::SetBoxTree()]");
|
|
2118 |
NW_LMgr_Box_DumpBoxTree (NW_LMgr_BoxOf(iRootBox));
|
|
2119 |
#endif
|
|
2120 |
|
|
2121 |
}
|
|
2122 |
else
|
|
2123 |
{
|
|
2124 |
FormatPartial();
|
|
2125 |
NW_LOG0( NW_LOG_LEVEL2, "CView::FormatPartial passed" );
|
|
2126 |
|
|
2127 |
#ifdef _DEBUG_LOG
|
|
2128 |
/* dump the box tree */
|
|
2129 |
NW_LOG0(NW_LOG_LEVEL3, "[LMgr: End box tree partial formatting...]");
|
|
2130 |
NW_LMgr_Box_DumpBoxTree (NW_LMgr_BoxOf(iRootBox));
|
|
2131 |
#endif
|
|
2132 |
|
|
2133 |
} // end of if ( boxTree == NULL ||
|
|
2134 |
/* when markupComplete, has to call partial Format again */
|
|
2135 |
if (iRootBox->renderingState == NW_LMgr_RootBox_RenderComplete)
|
|
2136 |
{
|
|
2137 |
NW_LMgr_RootBox_InvalidateCache(iRootBox);
|
|
2138 |
((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->PageLoadCompleted();
|
|
2139 |
NW_LOG0( NW_LOG_LEVEL2, "PageLoadCompleted passed" );
|
|
2140 |
}
|
|
2141 |
|
|
2142 |
errOccur = EFalse;
|
|
2143 |
|
|
2144 |
finish:
|
|
2145 |
if (errOccur)
|
|
2146 |
{
|
|
2147 |
HandleError (status);
|
|
2148 |
if (status != KBrsrOutOfMemory)
|
|
2149 |
{
|
|
2150 |
status = KBrsrUnexpectedError;
|
|
2151 |
}
|
|
2152 |
}
|
|
2153 |
|
|
2154 |
NW_LOG0( NW_LOG_LEVEL2, "CView::SetBoxTree END" );
|
|
2155 |
|
|
2156 |
return status;
|
|
2157 |
}
|
|
2158 |
|
|
2159 |
// -----------------------------------------------------------------------------
|
|
2160 |
TBrowserStatusCode
|
|
2161 |
CView::Draw (const NW_Bool drawNow)
|
|
2162 |
{
|
|
2163 |
NW_GDI_Rectangle_t oldClip;
|
|
2164 |
NW_GDI_Color_t oldBgColor = NW_GDI_Color_White;
|
|
2165 |
NW_GDI_Color_t bgColor = NW_GDI_Color_White; /* White is the default background */
|
|
2166 |
NW_LMgr_Property_t bodyColor;
|
|
2167 |
NW_LMgr_Box_t *bodyBox = NULL;
|
|
2168 |
NW_GDI_PaintMode_t oldPaintMode;
|
|
2169 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
2170 |
|
|
2171 |
if(NW_LMgr_ContainerBox_GetChildCount(NW_LMgr_ContainerBoxOf(iRootBox)) == 0)
|
|
2172 |
{
|
|
2173 |
UpdateScrollBars ();
|
|
2174 |
return KBrsrSuccess;
|
|
2175 |
}
|
|
2176 |
NW_LOG0( NW_LOG_LEVEL2, "CView::Draw START" );
|
|
2177 |
|
|
2178 |
/* Get the body, if there is one */
|
|
2179 |
bodyBox = NW_LMgr_RootBox_GetBody(iRootBox);
|
|
2180 |
|
|
2181 |
/* If there is a body element, does it have background-color set? */
|
|
2182 |
if (bodyBox != NULL)
|
|
2183 |
{
|
|
2184 |
bodyColor.type = NW_CSS_ValueType_Token;
|
|
2185 |
bodyColor.value.token = NW_CSS_PropValue_transparent;
|
|
2186 |
if (NW_LMgr_Box_GetProperty(bodyBox, NW_CSS_Prop_backgroundColor, &bodyColor) == KBrsrSuccess)
|
|
2187 |
{
|
|
2188 |
if (bodyColor.type == NW_CSS_ValueType_Color)
|
|
2189 |
{
|
|
2190 |
bgColor = bodyColor.value.integer;
|
|
2191 |
}
|
|
2192 |
}
|
|
2193 |
}
|
|
2194 |
|
|
2195 |
oldClip = iDeviceContext->ClipRect();
|
|
2196 |
oldBgColor = iDeviceContext->BackgroundColor();
|
|
2197 |
oldPaintMode = iDeviceContext->PaintMode();
|
|
2198 |
|
|
2199 |
NW_GDI_Rectangle_t viewBounds;
|
|
2200 |
NW_GDI_Rectangle_t maxBounds;
|
|
2201 |
|
|
2202 |
/* Set the clip */
|
|
2203 |
viewBounds = *(iDeviceContext->DisplayBounds());
|
|
2204 |
viewBounds.point = *(iDeviceContext->Origin());
|
|
2205 |
iDeviceContext->SetClipRect(&viewBounds);
|
|
2206 |
|
|
2207 |
/* This is our initial clip */
|
|
2208 |
maxBounds.point.x = maxBounds.point.y = 0;
|
|
2209 |
maxBounds.dimension.width = 0x7fff;
|
|
2210 |
maxBounds.dimension.height = 0x7fffffff;
|
|
2211 |
|
|
2212 |
iDeviceContext->SetBackgroundColor(bgColor);
|
|
2213 |
iDeviceContext->SetPaintMode(NW_GDI_PaintMode_Copy);
|
|
2214 |
/* clear the view */
|
|
2215 |
iDeviceContext->PreDraw();
|
|
2216 |
|
|
2217 |
/* draw the box tree */
|
|
2218 |
if (iCurrentBox != NULL &&
|
|
2219 |
IsBoxVisible (iCurrentBox, &viewBounds))
|
|
2220 |
{
|
|
2221 |
/* if the current box is visible enough(at least several pixels),
|
|
2222 |
hilight it */
|
|
2223 |
status = NW_LMgr_Box_Render((NW_LMgr_Box_t*) iRootBox,
|
|
2224 |
iDeviceContext, &maxBounds,
|
|
2225 |
iCurrentBox, 0, NULL, NULL, iRootBox );
|
|
2226 |
}
|
|
2227 |
else
|
|
2228 |
{
|
|
2229 |
/* otherwise dehilight it */
|
|
2230 |
status = NW_LMgr_Box_Render((NW_LMgr_Box_t*) iRootBox,
|
|
2231 |
iDeviceContext, &maxBounds,
|
|
2232 |
NULL, 0, NULL, NULL, iRootBox );
|
|
2233 |
}
|
|
2234 |
if (status == KBrsrOutOfMemory)
|
|
2235 |
{
|
|
2236 |
goto finish;
|
|
2237 |
}
|
|
2238 |
status = DrawPositionedBoxes();
|
|
2239 |
if (status != KBrsrSuccess)
|
|
2240 |
{
|
|
2241 |
goto finish;
|
|
2242 |
}
|
|
2243 |
/* update the scroll bars */
|
|
2244 |
status = UpdateScrollBars ();
|
|
2245 |
|
|
2246 |
/* invalidate the view */
|
|
2247 |
iDeviceContext->PostDraw (drawNow);
|
|
2248 |
|
|
2249 |
finish:
|
|
2250 |
iDeviceContext->SetClipRect(&oldClip);
|
|
2251 |
iDeviceContext->SetBackgroundColor(oldBgColor);
|
|
2252 |
iDeviceContext->SetPaintMode(oldPaintMode);
|
|
2253 |
|
|
2254 |
NW_LOG0( NW_LOG_LEVEL2, "CView::Draw passed" );
|
|
2255 |
return KBrsrSuccess;
|
|
2256 |
}
|
|
2257 |
|
|
2258 |
// -----------------------------------------------------------------------------
|
|
2259 |
NW_Bool
|
|
2260 |
CView::DispatchEvent (const NW_Evt_Event_t* event)
|
|
2261 |
{
|
|
2262 |
NW_LMgr_Box_t* box = NULL;
|
|
2263 |
NW_GDI_Rectangle_t viewBounds;
|
|
2264 |
|
|
2265 |
// Parameter assertion block
|
|
2266 |
NW_ASSERT (event != NULL);
|
|
2267 |
|
|
2268 |
// Initialize the viewBounds
|
|
2269 |
viewBounds = *(iDeviceContext->DisplayBounds());
|
|
2270 |
viewBounds.point = *(iDeviceContext->Origin());
|
|
2271 |
|
|
2272 |
// Starting at our current box, we must traverse the box hierarchy looking
|
|
2273 |
// for a box implementing the NW_LMgr_IEventListener interface that is
|
|
2274 |
// willing to absorb the event
|
|
2275 |
for (box = iCurrentBox; box != NULL; box = (NW_LMgr_Box_t*)NW_LMgr_Box_GetParent(box))
|
|
2276 |
{
|
|
2277 |
NW_LMgr_IEventListener_t* eventListener;
|
|
2278 |
|
|
2279 |
// Before we dispatch the activateEvent, do a few checks
|
|
2280 |
if (NW_Object_IsInstanceOf(event, &NW_Evt_ActivateEvent_Class))
|
|
2281 |
{
|
|
2282 |
// If the current box is not visible, then we do not dispatch
|
|
2283 |
// the activate event and simply return false. This is a good
|
|
2284 |
// behaviour for small devices which do not have Tab and Enter keys.
|
|
2285 |
if (!IsBoxVisible(box, &viewBounds))
|
|
2286 |
{
|
|
2287 |
return NW_FALSE;
|
|
2288 |
}
|
|
2289 |
|
|
2290 |
}
|
|
2291 |
|
|
2292 |
if (NW_Object_IsInstanceOf(event, &NW_Evt_ActivateEvent_Class) ||
|
|
2293 |
NW_Object_IsInstanceOf(event, &NW_Evt_UnicodeKeyEvent_Class))
|
|
2294 |
{
|
|
2295 |
// If the current box is an InputBox and capabilities is set to
|
|
2296 |
// ECapabilityDisableInputAndPlugins, then do not dispatch the
|
|
2297 |
// event and simply return false
|
|
2298 |
if (NW_Object_IsInstanceOf(box, &NW_FBox_InputBox_Class) &&
|
|
2299 |
(iBrCtl->capabilities() & TBrCtlDefs::ECapabilityDisableInputAndPlugins))
|
|
2300 |
{
|
|
2301 |
return NW_FALSE;
|
|
2302 |
}
|
|
2303 |
}
|
|
2304 |
|
|
2305 |
|
|
2306 |
// If the box implements IEventListener, allow it to process the event
|
|
2307 |
eventListener = static_cast<NW_LMgr_IEventListener_t*>(NW_Object_QueryInterface (box, &NW_LMgr_IEventListener_Class));
|
|
2308 |
if (eventListener != NULL)
|
|
2309 |
{
|
|
2310 |
// The activate event is not forwarded to form boxes if a context switch
|
|
2311 |
// is in progress. This prevents the form from launching auxiliary
|
|
2312 |
// dialogs during a context switch.
|
|
2313 |
if (NW_Object_IsInstanceOf (event, &NW_Evt_ActivateEvent_Class) &&
|
|
2314 |
NW_Object_IsInstanceOf(box, &NW_FBox_FormBox_Class))
|
|
2315 |
{
|
|
2316 |
NW_HED_DocumentRoot_t* docRoot = NW_FBox_FormBoxUtils_GetDocRoot(NW_LMgr_BoxOf(box));
|
|
2317 |
NW_ASSERT(docRoot != NULL);
|
|
2318 |
if (NW_HED_DocumentRoot_IsContextSwitchPending(docRoot))
|
|
2319 |
{
|
|
2320 |
return NW_FALSE;
|
|
2321 |
}
|
|
2322 |
}
|
|
2323 |
if (NW_LMgr_IEventListener_ProcessEvent (eventListener, event))
|
|
2324 |
{
|
|
2325 |
return NW_TRUE;
|
|
2326 |
}
|
|
2327 |
}
|
|
2328 |
} // end of for (box = iCurrent...
|
|
2329 |
|
|
2330 |
// The event was not absorbed by the boxTree
|
|
2331 |
return NW_FALSE;
|
|
2332 |
}
|
|
2333 |
|
|
2334 |
// -----------------------------------------------------------------------------
|
|
2335 |
// this function comes from old View.cpp
|
|
2336 |
NW_Bool
|
|
2337 |
CView::EpocProcessEvent (const NW_Evt_Event_t* event)
|
|
2338 |
{
|
|
2339 |
NW_LMgr_ContainerBox_t* containerRootBox = NULL;
|
|
2340 |
|
|
2341 |
// parameter assertion block
|
|
2342 |
NW_ASSERT (event != NULL);
|
|
2343 |
|
|
2344 |
// * TODO: if the event received causes focus to leave an input box, send
|
|
2345 |
// * a de-activate event to that input box before propagating the original
|
|
2346 |
// * event
|
|
2347 |
// *
|
|
2348 |
containerRootBox = NW_LMgr_ContainerBoxOf(iRootBox);
|
|
2349 |
|
|
2350 |
if(NW_LMgr_ContainerBox_GetChildCount(containerRootBox) == 0)
|
|
2351 |
{
|
|
2352 |
return NW_FALSE;
|
|
2353 |
}
|
|
2354 |
|
|
2355 |
// first try to pawn the event off on the boxTree
|
|
2356 |
if (DispatchEvent (event))
|
|
2357 |
{
|
|
2358 |
return NW_TRUE;
|
|
2359 |
}
|
|
2360 |
|
|
2361 |
if (NW_Object_Core_GetClass (event) == &NW_Evt_TabEvent_Class)
|
|
2362 |
{
|
|
2363 |
return ProcessTabEvent (NW_Evt_TabEventOf (event));
|
|
2364 |
}
|
|
2365 |
else if (NW_Object_Core_GetClass (event) == &NW_Evt_ScrollEvent_Class)
|
|
2366 |
{
|
|
2367 |
return ProcessScrollEvent (NW_Evt_ScrollEventOf (event));
|
|
2368 |
}
|
|
2369 |
|
|
2370 |
// we didn't absorb the event
|
|
2371 |
return NW_FALSE;
|
|
2372 |
}
|
|
2373 |
|
|
2374 |
// -----------------------------------------------------------------------------
|
|
2375 |
TBrowserStatusCode
|
|
2376 |
CView::CreateTabIndexList ()
|
|
2377 |
{
|
|
2378 |
NW_LMgr_BoxVisitor_t boxVisitor;
|
|
2379 |
NW_LMgr_Box_t* box;
|
|
2380 |
|
|
2381 |
// we do this only for WML or the first chunk
|
|
2382 |
if (iOptionItemList != NULL)
|
|
2383 |
{
|
|
2384 |
DeleteOptionItems ();
|
|
2385 |
}
|
|
2386 |
|
|
2387 |
/* initialize the boxVisitor */
|
|
2388 |
NW_LMgr_BoxVisitor_Initialize (&boxVisitor, NW_LMgr_BoxOf (iRootBox));
|
|
2389 |
// start the boxVistor at the last formatted box of the previous chunk
|
|
2390 |
|
|
2391 |
while ((box = NW_LMgr_BoxVisitor_NextBox (&boxVisitor, NULL)) != NULL)
|
|
2392 |
{
|
|
2393 |
NW_LMgr_IEventListener_t* eventListener;
|
|
2394 |
|
|
2395 |
// we are only looking for boxes implementing the NW_LMgr_IEventListener interface
|
|
2396 |
eventListener = static_cast<NW_LMgr_IEventListener_t*>(NW_Object_QueryInterface (box,
|
|
2397 |
&NW_LMgr_IEventListener_Class));
|
|
2398 |
|
|
2399 |
if (!eventListener)
|
|
2400 |
{
|
|
2401 |
continue;
|
|
2402 |
}
|
|
2403 |
AppendTabItem (box);
|
|
2404 |
}
|
|
2405 |
return KBrsrSuccess;
|
|
2406 |
}
|
|
2407 |
|
|
2408 |
// -----------------------------------------------------------------------------
|
|
2409 |
NW_Bool
|
|
2410 |
CView::ScrollAfterCurrentBox (const NW_LMgr_Box_t* box,
|
|
2411 |
NW_Bool scrollMaxAmt)
|
|
2412 |
{
|
|
2413 |
NW_Int32 scrollDelta = 0;
|
|
2414 |
NW_Bool scrolled = NW_FALSE;
|
|
2415 |
NW_Evt_ScrollEvent_t scrollEvent;
|
|
2416 |
NW_Evt_ScrollEvent_Direction_t scrollDir;
|
|
2417 |
|
|
2418 |
/* parameter assertion block */
|
|
2419 |
NW_ASSERT (box != NULL);
|
|
2420 |
|
|
2421 |
if (GetXScrollAmt (box, &scrollDelta, &scrollDir, scrollMaxAmt))
|
|
2422 |
{
|
|
2423 |
if (scrollDelta > 0)
|
|
2424 |
{
|
|
2425 |
NW_Evt_ScrollEvent_Initialize (&scrollEvent,
|
|
2426 |
scrollDir,
|
|
2427 |
(NW_Uint16)scrollDelta);
|
|
2428 |
scrolled = ProcessEvent (NW_Evt_EventOf(&scrollEvent));
|
|
2429 |
}
|
|
2430 |
}
|
|
2431 |
|
|
2432 |
if (GetYScrollAmt (box, &scrollDelta, &scrollDir, scrollMaxAmt))
|
|
2433 |
{
|
|
2434 |
if (scrollDelta > 0)
|
|
2435 |
{
|
|
2436 |
NW_Evt_ScrollEvent_Initialize (&scrollEvent,
|
|
2437 |
scrollDir,
|
|
2438 |
(NW_Uint16)scrollDelta);
|
|
2439 |
scrolled = ProcessScrollEvent (NW_Evt_ScrollEventOf (&scrollEvent));
|
|
2440 |
}
|
|
2441 |
}
|
|
2442 |
|
|
2443 |
return scrolled;
|
|
2444 |
}
|
|
2445 |
|
|
2446 |
// -----------------------------------------------------------------------------
|
|
2447 |
TBrowserStatusCode
|
|
2448 |
CView::JumpToLink (const NW_LMgr_Box_t* box,
|
|
2449 |
NW_Bool scrollMaxAmt)
|
|
2450 |
{
|
|
2451 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
2452 |
NW_Bool aboveVisible = NW_TRUE;
|
|
2453 |
NW_Bool aboveCurrent = NW_TRUE;
|
|
2454 |
NW_GDI_Rectangle_t boxBounds;
|
|
2455 |
NW_GDI_Rectangle_t activeBoxBounds;
|
|
2456 |
NW_LMgr_Box_t* prevBox = NULL;
|
|
2457 |
NW_LMgr_Box_t* activeBox = NULL;
|
|
2458 |
NW_GDI_Rectangle_t viewBounds;
|
|
2459 |
NW_LMgr_BoxVisitor_t boxVisitor;
|
|
2460 |
NW_Int32 scrollDelta = 0;
|
|
2461 |
NW_Evt_ScrollEvent_t scrollEvent;
|
|
2462 |
NW_Evt_ScrollEvent_Direction_t scrollDir;
|
|
2463 |
|
|
2464 |
// parameter assertion block
|
|
2465 |
NW_ASSERT (box != NULL);
|
|
2466 |
NW_ASSERT (iRootBox != NULL);
|
|
2467 |
|
|
2468 |
// Handle intra-page hyperlink.
|
|
2469 |
// If the target box is within the view, don't scroll.
|
|
2470 |
// Otherwise, scroll the target box to the top of the view.
|
|
2471 |
if (GetXScrollAmt (box, &scrollDelta, &scrollDir, scrollMaxAmt))
|
|
2472 |
{
|
|
2473 |
if (scrollDelta > 0)
|
|
2474 |
{
|
|
2475 |
status = NW_Evt_ScrollEvent_Initialize (&scrollEvent,
|
|
2476 |
scrollDir,
|
|
2477 |
(NW_Uint16)scrollDelta);
|
|
2478 |
if (status != KBrsrSuccess)
|
|
2479 |
{
|
|
2480 |
return status;
|
|
2481 |
}
|
|
2482 |
|
|
2483 |
(void) ProcessEvent ( NW_Evt_EventOf(&scrollEvent) );
|
|
2484 |
}
|
|
2485 |
}
|
|
2486 |
|
|
2487 |
if (GetYScrollAmt (box, &scrollDelta, &scrollDir, scrollMaxAmt))
|
|
2488 |
{
|
|
2489 |
if (scrollDelta > 0)
|
|
2490 |
{
|
|
2491 |
status = NW_Evt_ScrollEvent_Initialize (&scrollEvent,
|
|
2492 |
scrollDir,
|
|
2493 |
(NW_Uint16)scrollDelta);
|
|
2494 |
if (status != KBrsrSuccess)
|
|
2495 |
{
|
|
2496 |
return status;
|
|
2497 |
}
|
|
2498 |
(void) ProcessEvent ( NW_Evt_EventOf(&scrollEvent) );
|
|
2499 |
}
|
|
2500 |
}
|
|
2501 |
|
|
2502 |
NW_LMgr_BoxVisitor_Initialize (&boxVisitor, (NW_LMgr_Box_t*) iRootBox);
|
|
2503 |
|
|
2504 |
// initialize the viewBounds
|
|
2505 |
viewBounds = *(iDeviceContext->DisplayBounds());
|
|
2506 |
viewBounds.point = *(iDeviceContext->Origin());
|
|
2507 |
|
|
2508 |
// Find the most appropriate active box in the new view
|
|
2509 |
// so it can become the new currentBox.
|
|
2510 |
|
|
2511 |
// If the target box is active, it's automatically the best choice.
|
|
2512 |
if (NW_Object_QueryInterface (box, &NW_LMgr_IEventListener_Class) != NULL)
|
|
2513 |
{
|
|
2514 |
activeBox = (NW_LMgr_Box_t*) box;
|
|
2515 |
}
|
|
2516 |
else
|
|
2517 |
{
|
|
2518 |
// If the target box is further down than the current box,
|
|
2519 |
// the current box is the initial candidate.
|
|
2520 |
if (scrollDir == NW_Evt_ScrollEvent_Direction_Down)
|
|
2521 |
{
|
|
2522 |
// If we jumped here from another page, it's possible that
|
|
2523 |
// currentBox isn't set. If that's the case, start from the target box.
|
|
2524 |
if (iCurrentBox == NULL)
|
|
2525 |
{
|
|
2526 |
boxBounds = GetBoxDisplayBounds(NW_LMgr_BoxOf(box));
|
|
2527 |
}
|
|
2528 |
else
|
|
2529 |
{
|
|
2530 |
boxBounds = GetBoxDisplayBounds(iCurrentBox);
|
|
2531 |
}
|
|
2532 |
|
|
2533 |
do
|
|
2534 |
{
|
|
2535 |
activeBox = GetNextEventListener (&boxVisitor);
|
|
2536 |
|
|
2537 |
if (!activeBox)
|
|
2538 |
{
|
|
2539 |
return KBrsrNotFound;
|
|
2540 |
}
|
|
2541 |
|
|
2542 |
activeBoxBounds = GetBoxDisplayBounds(activeBox);
|
|
2543 |
|
|
2544 |
if (activeBoxBounds.point.y >= boxBounds.point.y)
|
|
2545 |
{
|
|
2546 |
aboveCurrent = NW_FALSE;
|
|
2547 |
}
|
|
2548 |
}
|
|
2549 |
while (aboveCurrent || activeBoxBounds.point.x < boxBounds.point.x);
|
|
2550 |
}
|
|
2551 |
// If the target box is further up than the current box,
|
|
2552 |
// the first box on the page is the initial candidate.
|
|
2553 |
else
|
|
2554 |
{
|
|
2555 |
activeBox = GetNextEventListener (&boxVisitor);
|
|
2556 |
if (!activeBox)
|
|
2557 |
{
|
|
2558 |
return KBrsrNotFound;
|
|
2559 |
}
|
|
2560 |
}
|
|
2561 |
|
|
2562 |
prevBox = activeBox;
|
|
2563 |
|
|
2564 |
NW_ASSERT (activeBox != NULL);
|
|
2565 |
|
|
2566 |
boxBounds = GetBoxDisplayBounds(NW_LMgr_BoxOf(box));
|
|
2567 |
|
|
2568 |
|
|
2569 |
// Starting with the initial candidate,
|
|
2570 |
// find the first active box in the new view.
|
|
2571 |
do
|
|
2572 |
{
|
|
2573 |
activeBoxBounds = GetBoxDisplayBounds(activeBox);
|
|
2574 |
|
|
2575 |
if (activeBoxBounds.point.y > boxBounds.point.y)
|
|
2576 |
{
|
|
2577 |
aboveVisible = NW_FALSE;
|
|
2578 |
}
|
|
2579 |
|
|
2580 |
// Keep track of the last active box before the visible area.
|
|
2581 |
// The focus will move there in the case where
|
|
2582 |
// there's no active box in the new view itself.
|
|
2583 |
if (aboveVisible || (prevBox == NULL))
|
|
2584 |
{
|
|
2585 |
prevBox = activeBox;
|
|
2586 |
}
|
|
2587 |
|
|
2588 |
if (NW_LMgr_Box_GetVisibleBounds(activeBox, NULL) &&
|
|
2589 |
IsBoxVisible (activeBox, &viewBounds))
|
|
2590 |
{
|
|
2591 |
break;
|
|
2592 |
}
|
|
2593 |
|
|
2594 |
activeBox = GetNextEventListener (&boxVisitor);
|
|
2595 |
}
|
|
2596 |
while (activeBox);
|
|
2597 |
}
|
|
2598 |
|
|
2599 |
if (!activeBox)
|
|
2600 |
{
|
|
2601 |
activeBox = prevBox;
|
|
2602 |
}
|
|
2603 |
|
|
2604 |
// If we jumped here from another page, sometimes currentBox isn't set.
|
|
2605 |
// It's possible that the active box isn't highlighted.
|
|
2606 |
// Make sure it gets highlighted.
|
|
2607 |
if (iCurrentBox == NULL)
|
|
2608 |
{
|
|
2609 |
iCurrentBox = activeBox;
|
|
2610 |
NW_LMgr_Box_SetHasFocus (NW_LMgr_BoxOf(iCurrentBox), NW_TRUE);
|
|
2611 |
status = NW_LMgr_Box_Refresh(activeBox);
|
|
2612 |
if (status != KBrsrSuccess)
|
|
2613 |
{
|
|
2614 |
return status;
|
|
2615 |
}
|
|
2616 |
}
|
|
2617 |
else
|
|
2618 |
{
|
|
2619 |
if (iCurrentBox != activeBox)
|
|
2620 |
{
|
|
2621 |
prevBox = iCurrentBox;
|
|
2622 |
iCurrentBox = activeBox;
|
|
2623 |
NW_LMgr_Box_SetHasFocus (NW_LMgr_BoxOf(iCurrentBox), NW_TRUE);
|
|
2624 |
NW_LMgr_Box_SetHasFocus (NW_LMgr_BoxOf(prevBox), NW_FALSE);
|
|
2625 |
status = NW_LMgr_Box_Refresh(prevBox);
|
|
2626 |
if (status != KBrsrSuccess)
|
|
2627 |
{
|
|
2628 |
return status;
|
|
2629 |
}
|
|
2630 |
}
|
|
2631 |
}
|
|
2632 |
|
|
2633 |
return status;
|
|
2634 |
}
|
|
2635 |
|
|
2636 |
// -----------------------------------------------------------------------------
|
|
2637 |
TBrowserStatusCode CView::SetAnchorName (NW_Text_t *anchorName)
|
|
2638 |
{
|
|
2639 |
|
|
2640 |
if (anchorName == NULL)
|
|
2641 |
return KBrsrFailure;
|
|
2642 |
|
|
2643 |
TBool state = ((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->GetFormattingComplete();
|
|
2644 |
|
|
2645 |
if (!state)
|
|
2646 |
{
|
|
2647 |
if (iAnchorName != NULL)
|
|
2648 |
{
|
|
2649 |
NW_Object_Delete(iAnchorName);
|
|
2650 |
iAnchorName = NULL;
|
|
2651 |
|
|
2652 |
}
|
|
2653 |
|
|
2654 |
iAnchorName = NW_Text_New( HTTP_iso_10646_ucs_2, anchorName->storage,
|
|
2655 |
anchorName->characterCount, NW_Text_Flags_Copy );
|
|
2656 |
|
|
2657 |
if (!iAnchorName)
|
|
2658 |
{
|
|
2659 |
return KBrsrOutOfMemory;
|
|
2660 |
}
|
|
2661 |
}
|
|
2662 |
|
|
2663 |
else
|
|
2664 |
{
|
|
2665 |
|
|
2666 |
TBrowserStatusCode status;
|
|
2667 |
NW_LMgr_Box_t* targetBox = NULL;
|
|
2668 |
NW_LMgr_Box_t* box = NULL;
|
|
2669 |
NW_LMgr_BoxVisitor_t boxVisitor;
|
|
2670 |
NW_LMgr_Property_t prop;
|
|
2671 |
|
|
2672 |
|
|
2673 |
/* find the named box */
|
|
2674 |
|
|
2675 |
NW_LMgr_BoxVisitor_Initialize (&boxVisitor, (NW_LMgr_Box_t *)iRootBox);
|
|
2676 |
(void) NW_LMgr_BoxVisitor_SetCurrentBox (&boxVisitor, (NW_LMgr_Box_t *)iRootBox);
|
|
2677 |
|
|
2678 |
|
|
2679 |
while ((box = NW_LMgr_BoxVisitor_NextBox (&boxVisitor, NULL)) != NULL)
|
|
2680 |
{
|
|
2681 |
status = NW_LMgr_Box_GetProperty(box, NW_CSS_Prop_boxName, &prop);
|
|
2682 |
|
|
2683 |
if ((status == KBrsrSuccess) && (prop.type == NW_CSS_ValueType_Text))
|
|
2684 |
{
|
|
2685 |
if (!NW_Text_Compare (anchorName, prop.value.object))
|
|
2686 |
{
|
|
2687 |
targetBox = box;
|
|
2688 |
break;
|
|
2689 |
}
|
|
2690 |
}
|
|
2691 |
}
|
|
2692 |
|
|
2693 |
if (targetBox != NULL)
|
|
2694 |
{
|
|
2695 |
(void) JumpToLink (box, NW_FALSE);
|
|
2696 |
}
|
|
2697 |
|
|
2698 |
}
|
|
2699 |
|
|
2700 |
return KBrsrSuccess;
|
|
2701 |
}
|
|
2702 |
|
|
2703 |
void CView::ContentSize(TSize& aContentSize)
|
|
2704 |
{
|
|
2705 |
if (iRootBox)
|
|
2706 |
{
|
|
2707 |
aContentSize.iWidth = iRootBox->extents.dimension.width;
|
|
2708 |
aContentSize.iHeight = iRootBox->extents.dimension.height;
|
|
2709 |
}
|
|
2710 |
}
|
|
2711 |
|
|
2712 |
|
|
2713 |
NW_Bool
|
|
2714 |
CView::IsBoxVisible (const NW_LMgr_Box_t* box,
|
|
2715 |
NW_GDI_Rectangle_t* bounds) const
|
|
2716 |
{
|
|
2717 |
NW_GDI_Rectangle_t boxBounds;
|
|
2718 |
NW_GDI_Rectangle_t overlap;
|
|
2719 |
const NW_LMgr_Box_t* siblingBox;
|
|
2720 |
|
|
2721 |
/* parameter assertion block */
|
|
2722 |
NW_ASSERT (box != NULL);
|
|
2723 |
|
|
2724 |
siblingBox = box;
|
|
2725 |
/* go through sibling chain to see if any of them visible */
|
|
2726 |
do
|
|
2727 |
{
|
|
2728 |
CView* view = const_cast<CView*>(this);
|
|
2729 |
boxBounds = view->GetBoxDisplayBounds((NW_LMgr_Box_t*)siblingBox);
|
|
2730 |
|
|
2731 |
/* below check handles the case where the box is at least has sHVisibleAmt and sVVisibleAmt
|
|
2732 |
* inside the display bounds
|
|
2733 |
*/
|
|
2734 |
if (NW_GDI_Rectangle_Cross(&boxBounds, bounds, &overlap))
|
|
2735 |
{
|
|
2736 |
if ((overlap.dimension.width >= iVisibleAmt.width) &&
|
|
2737 |
(overlap.dimension.height >= iVisibleAmt.height))
|
|
2738 |
{
|
|
2739 |
return NW_TRUE;
|
|
2740 |
}
|
|
2741 |
// the overlap width and height are less than the visible amount
|
|
2742 |
// in some cases the box might be smaller than the visible amount
|
|
2743 |
// then we want to check that if the overlap dimension and width
|
|
2744 |
// are same as the overlap
|
|
2745 |
else if ((overlap.dimension.width == boxBounds.dimension.width) &&
|
|
2746 |
(overlap.dimension.height == boxBounds.dimension.height))
|
|
2747 |
{
|
|
2748 |
return NW_TRUE;
|
|
2749 |
}
|
|
2750 |
}
|
|
2751 |
|
|
2752 |
siblingBox = view->GetNextSiblingBox (siblingBox);
|
|
2753 |
|
|
2754 |
}
|
|
2755 |
while (siblingBox != NULL && siblingBox != box);
|
|
2756 |
|
|
2757 |
return NW_FALSE;
|
|
2758 |
}
|
|
2759 |
|
|
2760 |
// -----------------------------------------------------------------------------
|
|
2761 |
NW_LMgr_Box_t*
|
|
2762 |
CView::GetInFocusBox () const
|
|
2763 |
{
|
|
2764 |
NW_GDI_Rectangle_t viewBounds;
|
|
2765 |
|
|
2766 |
/* initialize the viewBounds */
|
|
2767 |
viewBounds = *(iDeviceContext->DisplayBounds());
|
|
2768 |
viewBounds.point = *(iDeviceContext->Origin());
|
|
2769 |
|
|
2770 |
if (iCurrentBox != NULL &&
|
|
2771 |
IsBoxVisible (iCurrentBox, &viewBounds))
|
|
2772 |
{
|
|
2773 |
return iCurrentBox;
|
|
2774 |
}
|
|
2775 |
else
|
|
2776 |
{
|
|
2777 |
return NULL;
|
|
2778 |
}
|
|
2779 |
}
|
|
2780 |
|
|
2781 |
// -----------------------------------------------------------------------------
|
|
2782 |
TBrowserStatusCode
|
|
2783 |
CView::ForceCurrentBox (NW_LMgr_Box_t* newBox,
|
|
2784 |
NW_Bool isNewPage,
|
|
2785 |
NW_Bool isRefreshNeeded )
|
|
2786 |
{
|
|
2787 |
NW_Evt_FocusEvent_t focusEvent;
|
|
2788 |
NW_LMgr_Box_t *prevBox = NULL;
|
|
2789 |
NW_LMgr_Box_t *tempBox = NULL;
|
|
2790 |
NW_Uint8 absorbed = !NW_LMgr_EventAbsorbed;
|
|
2791 |
NW_LMgr_Property_t prop, propNew;
|
|
2792 |
NW_LMgr_PropertyList_t *propList, *masterPropList;
|
|
2793 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
2794 |
if (iCurrentBox != newBox)
|
|
2795 |
{
|
|
2796 |
if ( isNewPage )
|
|
2797 |
{
|
|
2798 |
iCurrentBox = newBox;
|
|
2799 |
return status;
|
|
2800 |
}
|
|
2801 |
|
|
2802 |
if (iCurrentBox != NULL)
|
|
2803 |
{
|
|
2804 |
NW_Evt_FocusEvent_Initialize(&focusEvent, NW_FALSE);
|
|
2805 |
absorbed = ProcessEvent ( NW_Evt_EventOf(&focusEvent) );
|
|
2806 |
if (absorbed)
|
|
2807 |
{
|
|
2808 |
prevBox = iCurrentBox;
|
|
2809 |
iCurrentBox = newBox;
|
|
2810 |
// do not refresh unless it is needed
|
|
2811 |
if ( isRefreshNeeded )
|
|
2812 |
{
|
|
2813 |
// the following code deals with split and non-split boxes
|
|
2814 |
propList = NULL;
|
|
2815 |
prop.value.object = NULL;
|
|
2816 |
masterPropList = NW_LMgr_Box_PropListGet( prevBox );
|
|
2817 |
|
|
2818 |
// first check if we are on a master or a slave box
|
|
2819 |
if ( NW_Object_IsInstanceOf( masterPropList, &NW_LMgr_SlavePropertyList_Class ) )
|
|
2820 |
{
|
|
2821 |
// this is a slave, get the master's property list
|
|
2822 |
tempBox = NW_LMgr_SlavePropertyList_GetMasterBox( masterPropList );
|
|
2823 |
(void)NW_LMgr_Box_GetProperty( tempBox, NW_CSS_Prop_sibling, &prop );
|
|
2824 |
|
|
2825 |
// refresh master: dehighlight it
|
|
2826 |
status = NW_LMgr_Box_Refresh(tempBox);
|
|
2827 |
if (status != KBrsrSuccess)
|
|
2828 |
{
|
|
2829 |
return status;
|
|
2830 |
}
|
|
2831 |
}
|
|
2832 |
else
|
|
2833 |
{
|
|
2834 |
(void)NW_LMgr_Box_GetProperty( prevBox, NW_CSS_Prop_sibling, &prop );
|
|
2835 |
// refresh the non-split box: dehighlight it
|
|
2836 |
status = NW_LMgr_Box_Refresh(prevBox);
|
|
2837 |
if (status != KBrsrSuccess)
|
|
2838 |
{
|
|
2839 |
return status;
|
|
2840 |
}
|
|
2841 |
}
|
|
2842 |
|
|
2843 |
// get the next to the master box
|
|
2844 |
if ( prop.value.object != NULL )
|
|
2845 |
{
|
|
2846 |
tempBox = NW_LMgr_BoxOf( prop.value.object );
|
|
2847 |
if ( tempBox != NULL )
|
|
2848 |
{
|
|
2849 |
// this must be a slave property list
|
|
2850 |
propList = NW_LMgr_Box_PropListGet( tempBox );
|
|
2851 |
}
|
|
2852 |
}
|
|
2853 |
// split case
|
|
2854 |
if ( propList )
|
|
2855 |
{
|
|
2856 |
// at this point tempbox holds the box next to the master, let's go through the chain
|
|
2857 |
do
|
|
2858 |
{
|
|
2859 |
// refresh slave box: dehighlight it
|
|
2860 |
status = NW_LMgr_Box_Refresh(tempBox);
|
|
2861 |
if (status != KBrsrSuccess)
|
|
2862 |
{
|
|
2863 |
return status;
|
|
2864 |
}
|
|
2865 |
// get the next box
|
|
2866 |
tempBox = NW_LMgr_SlavePropertyList_GetSiblingBox( propList );
|
|
2867 |
propList = NW_LMgr_Box_PropListGet( tempBox );
|
|
2868 |
// NW_LMgr_SimplePropertyList_Class means that we are on the master box again.
|
|
2869 |
}
|
|
2870 |
while (!NW_Object_IsClass ( propList, &NW_LMgr_SimplePropertyList_Class ) );
|
|
2871 |
}
|
|
2872 |
} // End of: the following code deals with split and non-split boxes
|
|
2873 |
}
|
|
2874 |
else
|
|
2875 |
{
|
|
2876 |
return KBrsrFailure;
|
|
2877 |
}
|
|
2878 |
} // End of: if(iCurrentBox != NULL)
|
|
2879 |
|
|
2880 |
if (newBox != NULL)
|
|
2881 |
{
|
|
2882 |
iCurrentBox = newBox;
|
|
2883 |
|
|
2884 |
NW_Evt_FocusEvent_Initialize(&focusEvent, NW_TRUE);
|
|
2885 |
(void) ProcessEvent ( NW_Evt_EventOf(&focusEvent) );
|
|
2886 |
|
|
2887 |
// After changing the focus if iCurrentBox has changed
|
|
2888 |
// set that as the newBox
|
|
2889 |
if(newBox != iCurrentBox)
|
|
2890 |
{
|
|
2891 |
newBox = iCurrentBox;
|
|
2892 |
}
|
|
2893 |
|
|
2894 |
// do not refresh unless it is needed
|
|
2895 |
if ( isRefreshNeeded )
|
|
2896 |
{
|
|
2897 |
// the following code deals with split and non-split boxes
|
|
2898 |
propList = NULL;
|
|
2899 |
propNew.value.object = NULL;
|
|
2900 |
masterPropList = NW_LMgr_Box_PropListGet( iCurrentBox );
|
|
2901 |
// first check if we are on a master or a slave box
|
|
2902 |
if ( NW_Object_IsInstanceOf( masterPropList, &NW_LMgr_SlavePropertyList_Class ) )
|
|
2903 |
{
|
|
2904 |
// this is a slave, get the master's property list
|
|
2905 |
tempBox = NW_LMgr_SlavePropertyList_GetMasterBox( masterPropList );
|
|
2906 |
(void)NW_LMgr_Box_GetProperty( tempBox, NW_CSS_Prop_sibling, &propNew );
|
|
2907 |
// refresh the master: highlight it. Has to set it to be the currentBox.
|
|
2908 |
iCurrentBox = tempBox;
|
|
2909 |
status = NW_LMgr_Box_Refresh(tempBox);
|
|
2910 |
if (status != KBrsrSuccess)
|
|
2911 |
{
|
|
2912 |
return status;
|
|
2913 |
}
|
|
2914 |
}
|
|
2915 |
else
|
|
2916 |
{
|
|
2917 |
(void)NW_LMgr_Box_GetProperty( iCurrentBox, NW_CSS_Prop_sibling, &propNew );
|
|
2918 |
// refresh the non-split box: highlight it
|
|
2919 |
status = NW_LMgr_Box_Refresh(iCurrentBox);
|
|
2920 |
if (status != KBrsrSuccess)
|
|
2921 |
{
|
|
2922 |
return status;
|
|
2923 |
}
|
|
2924 |
}
|
|
2925 |
|
|
2926 |
// get the next to the master box
|
|
2927 |
if ( propNew.value.object != NULL )
|
|
2928 |
{
|
|
2929 |
tempBox = NW_LMgr_BoxOf( propNew.value.object );
|
|
2930 |
if ( tempBox != NULL )
|
|
2931 |
{
|
|
2932 |
// this must be a slave property list
|
|
2933 |
propList = NW_LMgr_Box_PropListGet( tempBox );
|
|
2934 |
}
|
|
2935 |
}
|
|
2936 |
// split case
|
|
2937 |
if ( propList )
|
|
2938 |
{
|
|
2939 |
// at this point tempbox holds the box next to the master, let's go through the chain
|
|
2940 |
do
|
|
2941 |
{
|
|
2942 |
// refresh slave box: highlight it. Has to set it to be the currentBox.
|
|
2943 |
iCurrentBox = tempBox;
|
|
2944 |
status = NW_LMgr_Box_Refresh(tempBox);
|
|
2945 |
if (status != KBrsrSuccess)
|
|
2946 |
{
|
|
2947 |
return status;
|
|
2948 |
}
|
|
2949 |
// get the next box
|
|
2950 |
tempBox = NW_LMgr_SlavePropertyList_GetSiblingBox( propList );
|
|
2951 |
propList = NW_LMgr_Box_PropListGet( tempBox );
|
|
2952 |
// NW_LMgr_SimplePropertyList_Class means that we are on the master box again.
|
|
2953 |
}
|
|
2954 |
while ( propList != NULL && !NW_Object_IsClass ( propList, &NW_LMgr_SimplePropertyList_Class ) );
|
|
2955 |
}
|
|
2956 |
}
|
|
2957 |
// set currentBox back to be newBox
|
|
2958 |
iCurrentBox = newBox;
|
|
2959 |
} // End of: if (newBox != NULL)
|
|
2960 |
} // End of: if(iCurrentBox != newBox)
|
|
2961 |
|
|
2962 |
return status;
|
|
2963 |
}
|
|
2964 |
|
|
2965 |
// -----------------------------------------------------------------------------
|
|
2966 |
void*
|
|
2967 |
CView::GetScroll () const
|
|
2968 |
{
|
|
2969 |
if (iScroll != NULL)
|
|
2970 |
{
|
|
2971 |
return iScroll;
|
|
2972 |
}
|
|
2973 |
else
|
|
2974 |
{
|
|
2975 |
return NULL;
|
|
2976 |
}
|
|
2977 |
}
|
|
2978 |
|
|
2979 |
// -----------------------------------------------------------------------------
|
|
2980 |
TBrowserStatusCode
|
|
2981 |
CView::SetListener (MViewListener* viewListener)
|
|
2982 |
{
|
|
2983 |
/* install the view listener */
|
|
2984 |
TInt status = iListeners.Append( viewListener );
|
|
2985 |
return status == KErrNone ? KBrsrSuccess : KBrsrFailure;
|
|
2986 |
}
|
|
2987 |
|
|
2988 |
// -----------------------------------------------------------------------------
|
|
2989 |
TBrowserStatusCode
|
|
2990 |
CView::SetDeviceContext (CGDIDeviceContext* deviceContext)
|
|
2991 |
{
|
|
2992 |
NW_GDI_Rectangle_t displayBounds;
|
|
2993 |
NW_LMgr_Box_t* rootBox = NULL;
|
|
2994 |
|
|
2995 |
/* parameter assertion block */
|
|
2996 |
NW_ASSERT (deviceContext != NULL) ;
|
|
2997 |
|
|
2998 |
|
|
2999 |
iDeviceContext = deviceContext;
|
|
3000 |
displayBounds = *(iDeviceContext->DisplayBounds());
|
|
3001 |
|
|
3002 |
rootBox = NW_LMgr_BoxOf (iRootBox);
|
|
3003 |
|
|
3004 |
(void) NW_Mem_memset (&displayBounds.point, 0, sizeof (displayBounds.dimension));
|
|
3005 |
NW_LMgr_Box_SetFormatBounds( NW_LMgr_BoxOf( rootBox ), displayBounds);
|
|
3006 |
return KBrsrSuccess;
|
|
3007 |
}
|
|
3008 |
|
|
3009 |
|
|
3010 |
// -----------------------------------------------------------------------------
|
|
3011 |
NW_Bool
|
|
3012 |
CView::GetXScrollAmt (const NW_LMgr_Box_t* box,
|
|
3013 |
NW_Int32* scrollDelta,
|
|
3014 |
NW_Evt_ScrollEvent_Direction_t* scrollDir,
|
|
3015 |
NW_Bool scrollMaxAmt) const
|
|
3016 |
{
|
|
3017 |
NW_GDI_Rectangle_t boxBounds;
|
|
3018 |
NW_GDI_Rectangle_t viewBounds;
|
|
3019 |
|
|
3020 |
/* parameter assertion block */
|
|
3021 |
NW_ASSERT (box != NULL);
|
|
3022 |
|
|
3023 |
/* initialize the viewBounds */
|
|
3024 |
viewBounds = *(iDeviceContext->DisplayBounds());
|
|
3025 |
viewBounds.point = *(iDeviceContext->Origin());
|
|
3026 |
|
|
3027 |
*scrollDelta = 0;
|
|
3028 |
*scrollDir = NW_Evt_ScrollEvent_Direction_Left;
|
|
3029 |
|
|
3030 |
if (!NW_LMgr_Box_GetVisibleBounds(box, &boxBounds))
|
|
3031 |
{
|
|
3032 |
return NW_FALSE;
|
|
3033 |
}
|
|
3034 |
|
|
3035 |
if ((boxBounds.point.x + boxBounds.dimension.width) >=
|
|
3036 |
(viewBounds.point.x + viewBounds.dimension.width))
|
|
3037 |
{
|
|
3038 |
|
|
3039 |
*scrollDelta = (boxBounds.point.x + boxBounds.dimension.width)
|
|
3040 |
- (viewBounds.dimension.width + viewBounds.point.x) + 1;
|
|
3041 |
|
|
3042 |
if (boxBounds.dimension.width >= viewBounds.dimension.width)
|
|
3043 |
*scrollDelta = boxBounds.point.x - viewBounds.point.x + 1;
|
|
3044 |
|
|
3045 |
*scrollDir = NW_Evt_ScrollEvent_Direction_Right;
|
|
3046 |
}
|
|
3047 |
|
|
3048 |
if (boxBounds.point.x < viewBounds.point.x)
|
|
3049 |
{
|
|
3050 |
*scrollDelta = viewBounds.point.x - boxBounds.point.x + 1;
|
|
3051 |
*scrollDir = NW_Evt_ScrollEvent_Direction_Left;
|
|
3052 |
}
|
|
3053 |
|
|
3054 |
if (*scrollDelta > 0)
|
|
3055 |
{
|
|
3056 |
/* Scroll amount may not exceed specified maximum.
|
|
3057 |
* If we are jumping to the target box (hyperlink) there is no limit.
|
|
3058 |
*/
|
|
3059 |
if ((scrollMaxAmt) && (iMaxScrollAmt.width != 0) &&
|
|
3060 |
( *scrollDelta > iMaxScrollAmt.width))
|
|
3061 |
{
|
|
3062 |
*scrollDelta = iMaxScrollAmt.width;
|
|
3063 |
}
|
|
3064 |
return NW_TRUE;
|
|
3065 |
}
|
|
3066 |
|
|
3067 |
return NW_FALSE;
|
|
3068 |
}
|
|
3069 |
|
|
3070 |
|
|
3071 |
// -----------------------------------------------------------------------------
|
|
3072 |
NW_Bool
|
|
3073 |
CView::GetYScrollAmt (const NW_LMgr_Box_t* box,
|
|
3074 |
NW_Int32* scrollDelta,
|
|
3075 |
NW_Evt_ScrollEvent_Direction_t* scrollDir,
|
|
3076 |
NW_Bool scrollMaxAmt) const
|
|
3077 |
{
|
|
3078 |
NW_GDI_Rectangle_t boxBounds;
|
|
3079 |
NW_GDI_Rectangle_t viewBounds;
|
|
3080 |
|
|
3081 |
/* parameter assertion block */
|
|
3082 |
NW_ASSERT (box != NULL);
|
|
3083 |
|
|
3084 |
/* initialize the viewBounds */
|
|
3085 |
viewBounds = *(iDeviceContext->DisplayBounds());
|
|
3086 |
viewBounds.point = *(iDeviceContext->Origin());
|
|
3087 |
|
|
3088 |
CView* view = const_cast<CView*>(this);
|
|
3089 |
boxBounds = view->GetBoxDisplayBounds(NW_LMgr_BoxOf(box));
|
|
3090 |
|
|
3091 |
*scrollDelta = 0;
|
|
3092 |
*scrollDir = NW_Evt_ScrollEvent_Direction_Down;
|
|
3093 |
|
|
3094 |
/* Scroll down calculations for scrolling to target box */
|
|
3095 |
if (scrollMaxAmt)
|
|
3096 |
{
|
|
3097 |
if ((boxBounds.point.y + boxBounds.dimension.height) >
|
|
3098 |
(viewBounds.point.y + viewBounds.dimension.height))
|
|
3099 |
{
|
|
3100 |
|
|
3101 |
*scrollDelta = (boxBounds.point.y + boxBounds.dimension.height)
|
|
3102 |
- (viewBounds.point.y + viewBounds.dimension.height) + 1;
|
|
3103 |
if (boxBounds.dimension.height >= viewBounds.dimension.height)
|
|
3104 |
{
|
|
3105 |
*scrollDelta = boxBounds.point.y - viewBounds.point.y + 1;
|
|
3106 |
}
|
|
3107 |
*scrollDir = NW_Evt_ScrollEvent_Direction_Down;
|
|
3108 |
}
|
|
3109 |
}
|
|
3110 |
/* Jump to target box (hyperlink). If target box is not in the current view,
|
|
3111 |
* calculate scroll amount that will bring it to the top of the new view.
|
|
3112 |
*/
|
|
3113 |
else
|
|
3114 |
{
|
|
3115 |
*scrollDelta = boxBounds.point.y - viewBounds.point.y;
|
|
3116 |
}
|
|
3117 |
|
|
3118 |
/* Scroll up calculations same for scrolling or hyperlink. */
|
|
3119 |
if (boxBounds.point.y <= viewBounds.point.y)
|
|
3120 |
{
|
|
3121 |
*scrollDelta = viewBounds.point.y - boxBounds.point.y + 1;
|
|
3122 |
*scrollDir = NW_Evt_ScrollEvent_Direction_Up;
|
|
3123 |
}
|
|
3124 |
|
|
3125 |
if (*scrollDelta > 0)
|
|
3126 |
{
|
|
3127 |
/* Scroll amount may not exceed specified maximum.
|
|
3128 |
* If we are jumping to the target box (hyperlink) there is no limit.
|
|
3129 |
*/
|
|
3130 |
if ((scrollMaxAmt) && (iMaxScrollAmt.height != 0) &&
|
|
3131 |
( *scrollDelta > iMaxScrollAmt.height))
|
|
3132 |
{
|
|
3133 |
*scrollDelta = iMaxScrollAmt.height;
|
|
3134 |
}
|
|
3135 |
return NW_TRUE;
|
|
3136 |
}
|
|
3137 |
return NW_FALSE;
|
|
3138 |
}
|
|
3139 |
|
|
3140 |
// -----------------------------------------------------------------------------
|
|
3141 |
NW_Bool
|
|
3142 |
CView::ProcessAccessKey (const NW_Evt_KeyEvent_t* event)
|
|
3143 |
{
|
|
3144 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
3145 |
NW_ADT_Vector_Metric_t numTabItems;
|
|
3146 |
//lint --e{578} (Warning -- Declaration of symbol 'index' hides symbol 'index(const char *, int)' (line 75, file Q:\EPOC32\INCLUDE\LIBC\string.h))
|
|
3147 |
NW_ADT_Vector_Metric_t index;
|
|
3148 |
NW_Uint32 keyVal;
|
|
3149 |
|
|
3150 |
// according to the xhtml i-mode UI spec, neither # nor *
|
|
3151 |
// should be accepted as access key in small screen mode
|
|
3152 |
if ( NW_Object_IsInstanceOf(event, &NW_Evt_UnicodeKeyEvent_Class) )
|
|
3153 |
{
|
|
3154 |
keyVal = (NW_Uint32)NW_Evt_UnicodeKeyEvent_GetKeyVal(event);
|
|
3155 |
}
|
|
3156 |
else
|
|
3157 |
{
|
|
3158 |
keyVal = (NW_Uint32)NW_Evt_ControlKeyEvent_GetKeyVal(event);
|
|
3159 |
}
|
|
3160 |
// so do not absorb the event unless we are in normal mode
|
|
3161 |
if ( NW_LMgr_RootBox_GetSmallScreenOn( iRootBox ) &&
|
|
3162 |
( keyVal == '#' || keyVal == '*' ) )
|
|
3163 |
{
|
|
3164 |
return NW_FALSE;
|
|
3165 |
}
|
|
3166 |
if (NW_LMgr_ContainerBox_GetChildCount(NW_LMgr_ContainerBoxOf(iRootBox)) == 0)
|
|
3167 |
{
|
|
3168 |
return NW_FALSE;
|
|
3169 |
}
|
|
3170 |
|
|
3171 |
numTabItems = NW_ADT_Vector_GetSize(iTabList);
|
|
3172 |
|
|
3173 |
for (index = 0; index < numTabItems; index++)
|
|
3174 |
{
|
|
3175 |
NW_LMgr_Box_t* box;
|
|
3176 |
NW_LMgr_Property_t prop;
|
|
3177 |
NW_LMgr_AccessKey_t* ak;
|
|
3178 |
NW_Evt_AccessKeyEvent_t accessKeyEvent;
|
|
3179 |
NW_Bool isControlKey;
|
|
3180 |
NW_Bool eventAbsorbed = NW_TRUE;
|
|
3181 |
NW_LMgr_IEventListener_t* eventListener;
|
|
3182 |
|
|
3183 |
box = *(NW_LMgr_Box_t**) NW_ADT_Vector_ElementAt (iTabList, index);
|
|
3184 |
|
|
3185 |
// We need to process access keys differently for image map boxes, since the
|
|
3186 |
// access keys apply to the area tags within the image map box
|
|
3187 |
if (NW_Object_IsClass(box, &NW_LMgr_ImageMapBox_Class))
|
|
3188 |
{
|
|
3189 |
NW_ADT_DynamicVector_t* areaBoxArray = NW_LMgr_ImageMapBox_GetAreaBoxList((NW_LMgr_ImageMapBox_t*) box);
|
|
3190 |
|
|
3191 |
if (areaBoxArray)
|
|
3192 |
{
|
|
3193 |
NW_ADT_Vector_Metric_t elementSize = NW_ADT_Vector_GetSize(areaBoxArray);
|
|
3194 |
|
|
3195 |
NW_LMgr_AreaBox_t* areaBox = NULL;
|
|
3196 |
|
|
3197 |
for (NW_ADT_Vector_Metric_t arrayIndex = 0; arrayIndex < elementSize; arrayIndex++)
|
|
3198 |
{
|
|
3199 |
areaBox = *(NW_LMgr_AreaBox_t**)NW_ADT_Vector_ElementAt (areaBoxArray, arrayIndex);
|
|
3200 |
|
|
3201 |
status = NW_LMgr_Box_GetPropertyFromList((NW_LMgr_Box_t*)areaBox, NW_CSS_Prop_accesskey, &prop);
|
|
3202 |
|
|
3203 |
if (status == KBrsrSuccess)
|
|
3204 |
{
|
|
3205 |
ak = NW_LMgr_AccessKeyOf(prop.value.object);
|
|
3206 |
|
|
3207 |
if (NW_Object_IsInstanceOf(event, &NW_Evt_UnicodeKeyEvent_Class))
|
|
3208 |
{
|
|
3209 |
isControlKey = NW_FALSE;
|
|
3210 |
keyVal = (NW_Uint32)NW_Evt_UnicodeKeyEvent_GetKeyVal(event);
|
|
3211 |
}
|
|
3212 |
else
|
|
3213 |
{
|
|
3214 |
isControlKey = NW_TRUE;
|
|
3215 |
keyVal = (NW_Uint32)NW_Evt_ControlKeyEvent_GetKeyVal(event);
|
|
3216 |
}
|
|
3217 |
|
|
3218 |
if (NW_LMgr_AccessKey_MatchKey(ak, keyVal, isControlKey))
|
|
3219 |
{
|
|
3220 |
// Note that we are jumping to the ImageMapBox
|
|
3221 |
(void) JumpToLink (box, NW_TRUE);
|
|
3222 |
NW_Evt_AccessKeyEvent_Initialize(&accessKeyEvent);
|
|
3223 |
|
|
3224 |
eventAbsorbed = NW_FALSE;
|
|
3225 |
eventListener = static_cast<NW_LMgr_IEventListener_t*>(NW_Object_QueryInterface (areaBox, &NW_LMgr_IEventListener_Class));
|
|
3226 |
if (eventListener != NULL)
|
|
3227 |
{
|
|
3228 |
eventAbsorbed =
|
|
3229 |
NW_LMgr_IEventListener_ProcessEvent (eventListener, &accessKeyEvent);
|
|
3230 |
}
|
|
3231 |
}
|
|
3232 |
}
|
|
3233 |
}
|
|
3234 |
}
|
|
3235 |
}
|
|
3236 |
else
|
|
3237 |
{
|
|
3238 |
status = NW_LMgr_Box_GetPropertyFromList(box, NW_CSS_Prop_accesskey, &prop);
|
|
3239 |
if (status != KBrsrSuccess)
|
|
3240 |
{
|
|
3241 |
continue;
|
|
3242 |
}
|
|
3243 |
|
|
3244 |
ak = NW_LMgr_AccessKeyOf(prop.value.object);
|
|
3245 |
|
|
3246 |
if (NW_Object_IsInstanceOf(event, &NW_Evt_UnicodeKeyEvent_Class))
|
|
3247 |
{
|
|
3248 |
isControlKey = NW_FALSE;
|
|
3249 |
keyVal = (NW_Uint32)
|
|
3250 |
NW_Evt_UnicodeKeyEvent_GetKeyVal(event);
|
|
3251 |
}
|
|
3252 |
else
|
|
3253 |
{
|
|
3254 |
isControlKey = NW_TRUE;
|
|
3255 |
keyVal = (NW_Uint32)
|
|
3256 |
NW_Evt_ControlKeyEvent_GetKeyVal(event);
|
|
3257 |
}
|
|
3258 |
|
|
3259 |
if (!NW_LMgr_AccessKey_MatchKey(ak, keyVal, isControlKey))
|
|
3260 |
{
|
|
3261 |
continue;
|
|
3262 |
}
|
|
3263 |
|
|
3264 |
(void) JumpToLink (box, NW_TRUE);
|
|
3265 |
NW_Evt_AccessKeyEvent_Initialize(&accessKeyEvent);
|
|
3266 |
|
|
3267 |
eventAbsorbed = NW_FALSE;
|
|
3268 |
eventListener = static_cast<NW_LMgr_IEventListener_t*>(NW_Object_QueryInterface (box, &NW_LMgr_IEventListener_Class));
|
|
3269 |
if (eventListener != NULL)
|
|
3270 |
{
|
|
3271 |
// The AccessKey event is not forwarded to form boxes if a context switch
|
|
3272 |
// is in progress. This prevents the form from launching auxiliary
|
|
3273 |
// dialogs during a context switch.
|
|
3274 |
if (NW_Object_IsInstanceOf(box, &NW_FBox_FormBox_Class))
|
|
3275 |
{
|
|
3276 |
NW_HED_DocumentRoot_t* docRoot = NW_FBox_FormBoxUtils_GetDocRoot(NW_LMgr_BoxOf(box));
|
|
3277 |
NW_ASSERT(docRoot != NULL);
|
|
3278 |
if (NW_HED_DocumentRoot_IsContextSwitchPending(docRoot))
|
|
3279 |
{
|
|
3280 |
return NW_FALSE;
|
|
3281 |
}
|
|
3282 |
}
|
|
3283 |
eventAbsorbed =
|
|
3284 |
NW_LMgr_IEventListener_ProcessEvent (eventListener, &accessKeyEvent);
|
|
3285 |
}
|
|
3286 |
}
|
|
3287 |
|
|
3288 |
if (eventAbsorbed)
|
|
3289 |
{
|
|
3290 |
(void) Draw (NW_TRUE);
|
|
3291 |
}
|
|
3292 |
return eventAbsorbed;
|
|
3293 |
}
|
|
3294 |
|
|
3295 |
return NW_FALSE;
|
|
3296 |
}
|
|
3297 |
// -----------------------------------------------------------------------------
|
|
3298 |
NW_Bool
|
|
3299 |
CView::HandleGNavigation (NW_Uint32 tabIndex)
|
|
3300 |
{
|
|
3301 |
NW_LMgr_Box_t* box = NULL;
|
|
3302 |
NW_Evt_AccessKeyEvent_t accessKeyEvent;
|
|
3303 |
NW_Bool eventAbsorbed;
|
|
3304 |
NW_LMgr_IEventListener_t* eventListener;
|
|
3305 |
|
|
3306 |
if ( (NW_ADT_Vector_Metric_t) tabIndex >=
|
|
3307 |
NW_ADT_Vector_GetSize(iTabList))
|
|
3308 |
{
|
|
3309 |
return NW_FALSE;
|
|
3310 |
}
|
|
3311 |
|
|
3312 |
box = *(NW_LMgr_Box_t**) NW_ADT_Vector_ElementAt (iTabList,
|
|
3313 |
(NW_ADT_Vector_Metric_t) tabIndex);
|
|
3314 |
if (box == NULL)
|
|
3315 |
{
|
|
3316 |
return NW_FALSE;
|
|
3317 |
}
|
|
3318 |
(void) ForceCurrentBox (box, NW_FALSE /* not new page */, NW_TRUE);
|
|
3319 |
NW_Evt_AccessKeyEvent_Initialize(&accessKeyEvent);
|
|
3320 |
|
|
3321 |
eventAbsorbed = NW_FALSE;
|
|
3322 |
eventListener = static_cast<NW_LMgr_IEventListener_t*>(NW_Object_QueryInterface (box, &NW_LMgr_IEventListener_Class));
|
|
3323 |
if (eventListener != NULL)
|
|
3324 |
{
|
|
3325 |
eventAbsorbed =
|
|
3326 |
NW_LMgr_IEventListener_ProcessEvent (eventListener, &accessKeyEvent);
|
|
3327 |
}
|
|
3328 |
|
|
3329 |
if (eventAbsorbed)
|
|
3330 |
{
|
|
3331 |
(void) Draw (NW_TRUE);
|
|
3332 |
}
|
|
3333 |
|
|
3334 |
return eventAbsorbed;
|
|
3335 |
}
|
|
3336 |
|
|
3337 |
// -----------------------------------------------------------------------------
|
|
3338 |
void
|
|
3339 |
CView::HandleError (TBrowserStatusCode status)
|
|
3340 |
{
|
|
3341 |
for( TInt n=0; n<iListeners.Count(); n++ )
|
|
3342 |
{
|
|
3343 |
iListeners[n]->HandleError (status);
|
|
3344 |
}
|
|
3345 |
}
|
|
3346 |
|
|
3347 |
|
|
3348 |
/* ------------------------------------------------------------------------- *
|
|
3349 |
IBoxTreeListener implementation
|
|
3350 |
* ------------------------------------------------------------------------- */
|
|
3351 |
|
|
3352 |
// -----------------------------------------------------------------------------
|
|
3353 |
void
|
|
3354 |
CView::BoxTreeDestroyed ()
|
|
3355 |
{
|
|
3356 |
((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->ClearFormattingContext();
|
|
3357 |
|
|
3358 |
iCurrentBox = NULL;
|
|
3359 |
NW_LMgr_RootBox_SetBody(iRootBox, NULL);
|
|
3360 |
(void) NW_ADT_DynamicVector_Clear(iTabList);
|
|
3361 |
iCreateTabList = NW_TRUE;
|
|
3362 |
(void) NW_ADT_DynamicVector_Clear(iRootBox->iOutOfViewListeners);
|
|
3363 |
iRootBox->iYScrollChange = 0;
|
|
3364 |
}
|
|
3365 |
|
|
3366 |
// -----------------------------------------------------------------------------
|
|
3367 |
TBrowserStatusCode
|
|
3368 |
CView::BoxTreeListenerAppendTabItem (NW_LMgr_Box_t* box)
|
|
3369 |
{
|
|
3370 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
3371 |
|
|
3372 |
if (iCreateTabList )
|
|
3373 |
{
|
|
3374 |
status = AppendTabItem (box);
|
|
3375 |
}
|
|
3376 |
|
|
3377 |
return status;
|
|
3378 |
}
|
|
3379 |
|
|
3380 |
// -----------------------------------------------------------------------------
|
|
3381 |
void
|
|
3382 |
CView::FormattingComplete ()
|
|
3383 |
{
|
|
3384 |
|
|
3385 |
TRAP_IGNORE( iPageScaler->DocumentChangedL() );
|
|
3386 |
iDocumentFinished = ETrue;
|
|
3387 |
iPageScaler->DocumentCompleted();
|
|
3388 |
|
|
3389 |
// we need to handle the return status here
|
|
3390 |
if ( !((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->BackgroundFormat() )
|
|
3391 |
{
|
|
3392 |
(void) HandleFormattingComplete ();
|
|
3393 |
NW_LMgr_RootBox_ExtendsCalculationNeeded( iRootBox );
|
|
3394 |
(void) NW_LMgr_Box_UpdateContainerBodyBox (iRootBox );
|
|
3395 |
}
|
|
3396 |
else
|
|
3397 |
{
|
|
3398 |
// end of background format.
|
|
3399 |
// Clear the rendering cache
|
|
3400 |
NW_LMgr_RootBox_InvalidateCache( iRootBox );
|
|
3401 |
|
|
3402 |
// Clear the float context vectors
|
|
3403 |
(void) NW_ADT_DynamicVector_Clear(iRootBox->placedFloats);
|
|
3404 |
(void) NW_ADT_DynamicVector_Clear(iRootBox->pendingFloats);
|
|
3405 |
|
|
3406 |
// We'll have to recalculate the extents
|
|
3407 |
NW_Mem_memset(&(iRootBox->extents), 0, sizeof(NW_GDI_Rectangle_t));
|
|
3408 |
NW_Mem_memset(&(iRootBox->scrollRange), 0, sizeof(NW_GDI_Rectangle_t));
|
|
3409 |
NW_LMgr_RootBox_ExtendsCalculationNeeded( iRootBox );
|
|
3410 |
NW_LMgr_RootBox_SetBody( iRootBox, NULL );
|
|
3411 |
}
|
|
3412 |
|
|
3413 |
#ifdef __WINS__
|
|
3414 |
#ifdef _DEBUG
|
|
3415 |
NW_LMgr_Box_DumpBoxTree (NW_LMgr_BoxOf(iRootBox));
|
|
3416 |
#endif
|
|
3417 |
#endif
|
|
3418 |
|
|
3419 |
}
|
|
3420 |
|
|
3421 |
// -----------------------------------------------------------------------------
|
|
3422 |
void
|
|
3423 |
CView::StartCSSApply ()
|
|
3424 |
{
|
|
3425 |
// cancel outstanding format and clear the tablist
|
|
3426 |
((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->Cancel();
|
|
3427 |
|
|
3428 |
// clear tablist
|
|
3429 |
(void) NW_ADT_DynamicVector_Clear( iTabList );
|
|
3430 |
iCreateTabList = NW_TRUE;
|
|
3431 |
// css might delete current box
|
|
3432 |
iCurrentBox = NULL;
|
|
3433 |
}
|
|
3434 |
|
|
3435 |
// -----------------------------------------------------------------------------
|
|
3436 |
TBrowserStatusCode
|
|
3437 |
CView::Relayout(NW_Bool createTabList)
|
|
3438 |
{
|
|
3439 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
3440 |
|
|
3441 |
status = Collapse( NULL, NW_FALSE );
|
|
3442 |
if (status != KBrsrSuccess)
|
|
3443 |
{
|
|
3444 |
return status;
|
|
3445 |
}
|
|
3446 |
|
|
3447 |
status = FormatBoxTree( createTabList );
|
|
3448 |
|
|
3449 |
return status;
|
|
3450 |
}
|
|
3451 |
|
|
3452 |
|
|
3453 |
// -----------------------------------------------------------------------------
|
|
3454 |
NW_ADT_Vector_Metric_t
|
|
3455 |
CView::GetActiveBoxId()
|
|
3456 |
{
|
|
3457 |
//lint --e{578} (Warning -- Declaration of symbol 'index' hides symbol 'index(const char *, int)' (line 75, file Q:\EPOC32\INCLUDE\LIBC\string.h))
|
|
3458 |
NW_ADT_Vector_Metric_t index = 0;
|
|
3459 |
NW_Uint16 size = 0;
|
|
3460 |
|
|
3461 |
if (iCurrentBox == NULL)
|
|
3462 |
{
|
|
3463 |
return 0;
|
|
3464 |
}
|
|
3465 |
size = NW_ADT_Vector_GetSize(iTabList);
|
|
3466 |
|
|
3467 |
for (index = 0; index < size; index++)
|
|
3468 |
{
|
|
3469 |
NW_LMgr_Box_t* box = NULL;
|
|
3470 |
|
|
3471 |
box = (NW_LMgr_Box_t*) * NW_ADT_Vector_ElementAt(iTabList, index);
|
|
3472 |
if ((box) && (iCurrentBox == box))
|
|
3473 |
return index;
|
|
3474 |
}
|
|
3475 |
return 0;
|
|
3476 |
}
|
|
3477 |
|
|
3478 |
NW_LMgr_Box_t*
|
|
3479 |
CView::GetVisibleBox () const
|
|
3480 |
{
|
|
3481 |
NW_ADT_Vector_Metric_t i, size;
|
|
3482 |
NW_LMgr_Box_t* box;
|
|
3483 |
NW_GDI_Rectangle_t viewBounds;
|
|
3484 |
|
|
3485 |
size = NW_ADT_Vector_GetSize(iTabList);
|
|
3486 |
/* initialize the viewBounds */
|
|
3487 |
viewBounds = *(iDeviceContext->DisplayBounds());
|
|
3488 |
viewBounds.point = *(iDeviceContext->Origin());
|
|
3489 |
|
|
3490 |
for (i = 0; i < size; i++)
|
|
3491 |
{
|
|
3492 |
box = (NW_LMgr_Box_t*) * NW_ADT_Vector_ElementAt(iTabList,
|
|
3493 |
(NW_ADT_Vector_Metric_t)i);
|
|
3494 |
if ( (IsBoxVisible(box, &viewBounds)) && !(IsZeroBox(box)) )
|
|
3495 |
return box;
|
|
3496 |
}
|
|
3497 |
return NULL;
|
|
3498 |
}
|
|
3499 |
|
|
3500 |
NW_LMgr_Box_t*
|
|
3501 |
CView::GetVisibleBoxReverse () const
|
|
3502 |
{
|
|
3503 |
TInt i, size;
|
|
3504 |
NW_LMgr_Box_t* box;
|
|
3505 |
NW_GDI_Rectangle_t viewBounds;
|
|
3506 |
|
|
3507 |
size = NW_ADT_Vector_GetSize(iTabList);
|
|
3508 |
/* initialize the viewBounds */
|
|
3509 |
viewBounds = *(iDeviceContext->DisplayBounds());
|
|
3510 |
viewBounds.point = *(iDeviceContext->Origin());
|
|
3511 |
|
|
3512 |
for (i = size - 1; i >= 0 ; i--)
|
|
3513 |
{
|
|
3514 |
box = (NW_LMgr_Box_t*) * NW_ADT_Vector_ElementAt(iTabList,
|
|
3515 |
(NW_ADT_Vector_Metric_t)i);
|
|
3516 |
if ( (IsBoxVisible(box, &viewBounds)) && !(IsZeroBox(box)) )
|
|
3517 |
return box;
|
|
3518 |
}
|
|
3519 |
return NULL;
|
|
3520 |
}
|
|
3521 |
|
|
3522 |
// -----------------------------------------------------------------------------
|
|
3523 |
NW_LMgr_Box_t*
|
|
3524 |
CView::GetLastVisibleBox () const
|
|
3525 |
{
|
|
3526 |
NW_ADT_Vector_Metric_t i, size;
|
|
3527 |
NW_LMgr_Box_t* box = NULL;
|
|
3528 |
NW_LMgr_Box_t* tmpBox;
|
|
3529 |
NW_GDI_Rectangle_t viewBounds;
|
|
3530 |
|
|
3531 |
size = NW_ADT_Vector_GetSize(NW_ADT_VectorOf(iTabList));
|
|
3532 |
/* initialize the viewBounds */
|
|
3533 |
viewBounds = *(iDeviceContext->DisplayBounds());
|
|
3534 |
viewBounds.point = *(iDeviceContext->Origin());
|
|
3535 |
|
|
3536 |
for (i = 0; i < size; i++)
|
|
3537 |
{
|
|
3538 |
tmpBox = (NW_LMgr_Box_t*) * NW_ADT_Vector_ElementAt(iTabList,
|
|
3539 |
(NW_ADT_Vector_Metric_t)i);
|
|
3540 |
if (IsBoxVisible (tmpBox, &viewBounds))
|
|
3541 |
{
|
|
3542 |
box = tmpBox;
|
|
3543 |
}
|
|
3544 |
}
|
|
3545 |
return box;
|
|
3546 |
}
|
|
3547 |
|
|
3548 |
// -----------------------------------------------------------------------------
|
|
3549 |
TBrowserStatusCode
|
|
3550 |
CView::GotoActiveBox(NW_ADT_Vector_Metric_t activeBoxId)
|
|
3551 |
{
|
|
3552 |
NW_LMgr_Box_t* box = NULL;
|
|
3553 |
TBool noBoxVisible = EFalse;
|
|
3554 |
|
|
3555 |
void ** element;
|
|
3556 |
CMVCScroll* scroll = static_cast<CMVCScroll*>(iScroll);
|
|
3557 |
|
|
3558 |
iCurrentBox = NULL;
|
|
3559 |
if ((activeBoxId == 0) || (activeBoxId >= NW_ADT_Vector_GetSize(iTabList)))
|
|
3560 |
{
|
|
3561 |
scroll->TabForward(NW_TRUE /* new page */, &noBoxVisible);
|
|
3562 |
}
|
|
3563 |
else
|
|
3564 |
{
|
|
3565 |
element = NW_ADT_Vector_ElementAt(iTabList, activeBoxId);
|
|
3566 |
if (element != NULL)
|
|
3567 |
{
|
|
3568 |
box = (NW_LMgr_Box_t*) * element;
|
|
3569 |
/* if necessary, scroll the box into the view */
|
|
3570 |
(void) JumpToLink (box, NW_TRUE);
|
|
3571 |
}
|
|
3572 |
else
|
|
3573 |
{
|
|
3574 |
scroll->TabForward(NW_TRUE /* new page */, &noBoxVisible);
|
|
3575 |
}
|
|
3576 |
}
|
|
3577 |
|
|
3578 |
if (noBoxVisible)
|
|
3579 |
{
|
|
3580 |
/* first box is not visible. try to get one*/
|
|
3581 |
box = GetVisibleBox ();
|
|
3582 |
if (box != NULL)
|
|
3583 |
{
|
|
3584 |
(void) ForceCurrentBox (box, NW_TRUE, NW_TRUE );
|
|
3585 |
}
|
|
3586 |
}
|
|
3587 |
|
|
3588 |
return Draw (NW_TRUE);
|
|
3589 |
}
|
|
3590 |
|
|
3591 |
|
|
3592 |
// -----------------------------------------------------------------------------
|
|
3593 |
TBrowserStatusCode
|
|
3594 |
CView::GotoBox(NW_LMgr_Box_t* aBox)
|
|
3595 |
{
|
|
3596 |
TBrowserStatusCode status = KBrsrNotFound;
|
|
3597 |
if (aBox != NULL)
|
|
3598 |
{
|
|
3599 |
NW_Bool found = NW_FALSE;
|
|
3600 |
NW_LMgr_Box_t* box = NULL;
|
|
3601 |
//lint --e{578} (Warning -- Declaration of symbol 'index' hides symbol 'index(const char *, int)' (line 75, file Q:\EPOC32\INCLUDE\LIBC\string.h))
|
|
3602 |
NW_ADT_Vector_Metric_t index ;
|
|
3603 |
NW_ADT_Vector_t* tabListVector = NW_ADT_VectorOf( iTabList );
|
|
3604 |
NW_Uint16 size = NW_ADT_Vector_GetSize( tabListVector );
|
|
3605 |
for ( index = 0; index < size; index++ )
|
|
3606 |
{
|
|
3607 |
box = (NW_LMgr_Box_t*) * NW_ADT_Vector_ElementAt( tabListVector, index );
|
|
3608 |
|
|
3609 |
if ( aBox == box )
|
|
3610 |
{
|
|
3611 |
found = NW_TRUE;
|
|
3612 |
break;
|
|
3613 |
}
|
|
3614 |
}
|
|
3615 |
if (found)
|
|
3616 |
{
|
|
3617 |
status = KBrsrSuccess;
|
|
3618 |
(void) GotoActiveBox (index);
|
|
3619 |
}
|
|
3620 |
}
|
|
3621 |
|
|
3622 |
return status;
|
|
3623 |
}
|
|
3624 |
|
|
3625 |
// this function comes from old View.cpp
|
|
3626 |
TBrowserStatusCode
|
|
3627 |
CView::SwitchVerticalLayout (NW_Bool aFormatBoxTree,
|
|
3628 |
NW_Bool aSwitchBox)
|
|
3629 |
{
|
|
3630 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
3631 |
NW_LMgr_BoxVisitor_t boxVisitor;
|
|
3632 |
NW_LMgr_Box_t* box = NULL;
|
|
3633 |
NW_GDI_Point2D_t origin;
|
|
3634 |
|
|
3635 |
// cancel any existing formatting
|
|
3636 |
((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->Cancel();
|
|
3637 |
|
|
3638 |
origin.x = 0;
|
|
3639 |
origin.y = 0;
|
|
3640 |
iDeviceContext->SetOrigin (&origin);
|
|
3641 |
|
|
3642 |
// if the box is an image map box, then we want to highlight the first area box when
|
|
3643 |
// we switch layout modes
|
|
3644 |
box = GetCurrentBox ();
|
|
3645 |
if (box)
|
|
3646 |
{
|
|
3647 |
if (NW_Object_IsClass(box, &NW_LMgr_ImageMapBox_Class))
|
|
3648 |
{
|
|
3649 |
NW_ADT_DynamicVector_t* areaBoxList = NW_LMgr_ImageMapBox_GetAreaBoxList (NW_LMgr_ImageMapBoxOf(box));
|
|
3650 |
|
|
3651 |
if (areaBoxList)
|
|
3652 |
{
|
|
3653 |
NW_ADT_Vector_Metric_t elementSize = NW_ADT_Vector_GetSize(areaBoxList);
|
|
3654 |
|
|
3655 |
if ( elementSize > 0 )
|
|
3656 |
{
|
|
3657 |
NW_LMgr_AreaBox_t* areaBox = *(NW_LMgr_AreaBox_t**)
|
|
3658 |
NW_ADT_Vector_ElementAt (areaBoxList, 0);
|
|
3659 |
|
|
3660 |
if (areaBox)
|
|
3661 |
{
|
|
3662 |
// not set focus to true on AreaBox
|
|
3663 |
// setCurrentBox() will take care of it
|
|
3664 |
iCurrentBox = NW_LMgr_BoxOf(areaBox);
|
|
3665 |
|
|
3666 |
NW_LMgr_Box_SetHasFocus (NW_LMgr_BoxOf(box), NW_FALSE);
|
|
3667 |
}
|
|
3668 |
}
|
|
3669 |
}
|
|
3670 |
}
|
|
3671 |
// if the box is an area box, then we want to highlight the parent image map box when
|
|
3672 |
// we switch layout modes
|
|
3673 |
else if (NW_Object_IsClass(box, &NW_LMgr_AreaBox_Class))
|
|
3674 |
{
|
|
3675 |
NW_LMgr_ImageMapBox_t* imageMapBox = NW_LMgr_AreaBox_GetParentImageMapBox(box);
|
|
3676 |
|
|
3677 |
if (imageMapBox)
|
|
3678 |
{
|
|
3679 |
iCurrentBox = NW_LMgr_BoxOf(imageMapBox);
|
|
3680 |
NW_LMgr_Box_SetHasFocus (NW_LMgr_BoxOf(imageMapBox), NW_TRUE);
|
|
3681 |
|
|
3682 |
NW_LMgr_Box_SetHasFocus (NW_LMgr_BoxOf(box), NW_FALSE);
|
|
3683 |
}
|
|
3684 |
}
|
|
3685 |
}
|
|
3686 |
|
|
3687 |
status = Collapse (NULL, NW_FALSE);
|
|
3688 |
if (status != KBrsrSuccess)
|
|
3689 |
{
|
|
3690 |
return status;
|
|
3691 |
}
|
|
3692 |
|
|
3693 |
/* create the Box Visitor object and use it to traverse the box tree */
|
|
3694 |
status = NW_LMgr_BoxVisitor_Initialize (&boxVisitor, NW_LMgr_BoxOf(iRootBox));
|
|
3695 |
if (status != KBrsrSuccess)
|
|
3696 |
{
|
|
3697 |
return status;
|
|
3698 |
}
|
|
3699 |
|
|
3700 |
/* Iterate through all children */
|
|
3701 |
if (aSwitchBox)
|
|
3702 |
{
|
|
3703 |
while ((box = NW_LMgr_BoxVisitor_NextBox(&boxVisitor, 0)) != NULL)
|
|
3704 |
{
|
|
3705 |
NW_LMgr_Box_t * newBox = NW_LMgr_VerticalTableBox_SwitchBox(box);
|
|
3706 |
if (newBox)
|
|
3707 |
{
|
|
3708 |
boxVisitor.currentBox = newBox;
|
|
3709 |
if (NW_Object_IsInstanceOf(newBox, &NW_LMgr_StaticTableBox_Class))
|
|
3710 |
{
|
|
3711 |
NW_XHTML_AttributePropertyTable_ApplyGridModeTableStyle(newBox);
|
|
3712 |
}
|
|
3713 |
}
|
|
3714 |
else
|
|
3715 |
{
|
|
3716 |
// Apply grid mode related styles to static table boxes.
|
|
3717 |
if (NW_Object_IsInstanceOf(box, &NW_LMgr_StaticTableBox_Class))
|
|
3718 |
{
|
|
3719 |
NW_XHTML_AttributePropertyTable_ApplyGridModeTableStyle(box);
|
|
3720 |
}
|
|
3721 |
}
|
|
3722 |
}
|
|
3723 |
|
|
3724 |
}
|
|
3725 |
|
|
3726 |
if (aFormatBoxTree)
|
|
3727 |
{
|
|
3728 |
status = FormatBoxTree (NW_TRUE);
|
|
3729 |
if (status != KBrsrSuccess)
|
|
3730 |
{
|
|
3731 |
return status;
|
|
3732 |
}
|
|
3733 |
status = Draw (NW_TRUE);
|
|
3734 |
if (status != KBrsrSuccess)
|
|
3735 |
{
|
|
3736 |
return status;
|
|
3737 |
}
|
|
3738 |
}
|
|
3739 |
|
|
3740 |
return status;
|
|
3741 |
}
|
|
3742 |
|
|
3743 |
// -----------------------------------------------------------------------------
|
|
3744 |
TBrowserStatusCode
|
|
3745 |
CView::Cancel ()
|
|
3746 |
{
|
|
3747 |
((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->Cancel();
|
|
3748 |
return KBrsrSuccess;
|
|
3749 |
}
|
|
3750 |
|
|
3751 |
TBrowserStatusCode
|
|
3752 |
CView::UpdateHScrollBar () const
|
|
3753 |
{
|
|
3754 |
NW_GDI_Dimension2D_t canvasSize;
|
|
3755 |
NW_GDI_Dimension2D_t extents;
|
|
3756 |
NW_GDI_Dimension2D_t size;
|
|
3757 |
NW_GDI_Metric_t originX;
|
|
3758 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
3759 |
|
|
3760 |
status = NW_LMgr_RootBox_GetExtents (iRootBox, &extents);
|
|
3761 |
if (status != KBrsrSuccess)
|
|
3762 |
{
|
|
3763 |
return status;
|
|
3764 |
}
|
|
3765 |
|
|
3766 |
originX = (NW_GDI_Metric_t)(iDeviceContext->Origin()->x);
|
|
3767 |
/* Shift coordinates to 0 scrollRange will always be smaller or identical to the extents. */
|
|
3768 |
if (NW_LMgr_RootBox_IsPageRTL(NW_LMgr_RootBoxOf(iRootBox)))
|
|
3769 |
{
|
|
3770 |
/* get range */
|
|
3771 |
status = NW_LMgr_RootBox_GetScrollRange (iRootBox, &canvasSize);
|
|
3772 |
if (status != KBrsrSuccess)
|
|
3773 |
{
|
|
3774 |
return status;
|
|
3775 |
}
|
|
3776 |
|
|
3777 |
originX = originX + canvasSize.width - extents.width;
|
|
3778 |
if (originX < 0)
|
|
3779 |
{
|
|
3780 |
originX = 0;
|
|
3781 |
}
|
|
3782 |
|
|
3783 |
size = canvasSize;
|
|
3784 |
}
|
|
3785 |
else
|
|
3786 |
{
|
|
3787 |
size = extents;
|
|
3788 |
}
|
|
3789 |
|
|
3790 |
// UI should fix it first.
|
|
3791 |
// if( !NW_LMgr_RootBox_GetSmallScreenOn( iRootBox ) )
|
|
3792 |
{
|
|
3793 |
CView* view = const_cast<CView*>(this);
|
|
3794 |
TInt err;
|
|
3795 |
TRAP (err, view->UpdateScrollBarsL (CEikScrollBar::EHorizontal, originX, size.width));
|
|
3796 |
}
|
|
3797 |
|
|
3798 |
/* successful completion */
|
|
3799 |
return KBrsrSuccess;
|
|
3800 |
}
|
|
3801 |
|
|
3802 |
/* ------------------------------------------------------------------------- */
|
|
3803 |
TBrowserStatusCode
|
|
3804 |
CView::UpdateVScrollBar () const
|
|
3805 |
{
|
|
3806 |
NW_GDI_Dimension2D_t canvasSize;
|
|
3807 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
3808 |
|
|
3809 |
/* get range */
|
|
3810 |
status = NW_LMgr_RootBox_GetExtents (iRootBox, &canvasSize);
|
|
3811 |
if (status != KBrsrSuccess)
|
|
3812 |
{
|
|
3813 |
return status;
|
|
3814 |
}
|
|
3815 |
|
|
3816 |
CView* view = const_cast<CView*>(this);
|
|
3817 |
TInt err;
|
|
3818 |
TRAP (err, view->UpdateScrollBarsL (CEikScrollBar::EVertical, iDeviceContext->Origin()->y , canvasSize.height));
|
|
3819 |
|
|
3820 |
/* successful completion */
|
|
3821 |
return KBrsrSuccess;
|
|
3822 |
}
|
|
3823 |
|
|
3824 |
//-----------------------------------------------------------------------------
|
|
3825 |
void
|
|
3826 |
CView::Draw(const TRect& aRect) const
|
|
3827 |
{
|
|
3828 |
CWindowGc& gc = SystemGc();
|
|
3829 |
CEikBorderedControl::Draw( aRect );
|
|
3830 |
|
|
3831 |
// put offscreen bitmap onto the screen
|
|
3832 |
gc.BitBlt( Rect().iTl, iOffscreenBitmap );
|
|
3833 |
}
|
|
3834 |
|
|
3835 |
//-----------------------------------------------------------------------------
|
|
3836 |
void
|
|
3837 |
CView::DrawHistory( CFbsBitGc& aGc, const TRect& aDocumentAreaToDraw ) const
|
|
3838 |
{
|
|
3839 |
// put offscreen bitmap onto the screen
|
|
3840 |
aGc.BitBlt( aDocumentAreaToDraw.iTl, iOffscreenBitmap );
|
|
3841 |
}
|
|
3842 |
|
|
3843 |
/* ------------------------------------------------------------------------- */
|
|
3844 |
void
|
|
3845 |
CView::EpocDrawNow (NW_Bool drawNow)
|
|
3846 |
{
|
|
3847 |
if (drawNow)
|
|
3848 |
DrawNow ();
|
|
3849 |
else
|
|
3850 |
DrawDeferred ();
|
|
3851 |
}
|
|
3852 |
|
|
3853 |
/* ------------------------------------------------------------------------- *
|
|
3854 |
IBoxTreeListener implementation
|
|
3855 |
* ------------------------------------------------------------------------- */
|
|
3856 |
void
|
|
3857 |
CView::EnableSuppressDupReformats (NW_Int16 state)
|
|
3858 |
{
|
|
3859 |
iSuppressDupReformats = state;
|
|
3860 |
if (state == NW_Image_AbstractImage_SuppressDupReformats_Start)
|
|
3861 |
iPendingReformatBox = NULL;
|
|
3862 |
iForceReformatNeeded = NW_FALSE;
|
|
3863 |
}
|
|
3864 |
|
|
3865 |
// -----------------------------------------------------------------------------
|
|
3866 |
TBrowserStatusCode
|
|
3867 |
CView::BoxTreeListenerRelayout (NW_Bool createTabList)
|
|
3868 |
{
|
|
3869 |
/* get the listener and send a relayout request */
|
|
3870 |
return iShell->SendRelayoutMsg (createTabList);
|
|
3871 |
}
|
|
3872 |
|
|
3873 |
/* ------------------------------------------------------------------------- */
|
|
3874 |
TBrowserStatusCode
|
|
3875 |
CView::Refresh (NW_LMgr_Box_t* box)
|
|
3876 |
{
|
|
3877 |
CGDIDeviceContext* deviceContext;
|
|
3878 |
NW_LMgr_Box_t *currentBox;
|
|
3879 |
NW_GDI_Rectangle_t origClip;
|
|
3880 |
NW_GDI_Color_t origBgColor;
|
|
3881 |
NW_GDI_Color_t bgColor = NW_GDI_Color_White;
|
|
3882 |
NW_LMgr_Property_t bodyColor;
|
|
3883 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
3884 |
|
|
3885 |
/* parameter assertion block */
|
|
3886 |
NW_ASSERT (NW_Object_IsInstanceOf (box, &NW_LMgr_Box_Class));
|
|
3887 |
|
|
3888 |
if (IsImageMapView() && (box != NW_LMgr_RootBox_GetFocusBox (iRootBox)))
|
|
3889 |
{
|
|
3890 |
box = NW_LMgr_RootBox_GetFocusBox (iRootBox);
|
|
3891 |
}
|
|
3892 |
|
|
3893 |
deviceContext = iDeviceContext;
|
|
3894 |
|
|
3895 |
/* Save the initial clip and bg color*/
|
|
3896 |
origClip = deviceContext->ClipRect();
|
|
3897 |
origBgColor = deviceContext->BackgroundColor();
|
|
3898 |
|
|
3899 |
NW_GDI_Rectangle_t clipRect;
|
|
3900 |
NW_GDI_Rectangle_t viewBounds;
|
|
3901 |
NW_Uint8 flags = 0;
|
|
3902 |
|
|
3903 |
/* initialize the viewBounds */
|
|
3904 |
viewBounds = *(deviceContext->DisplayBounds());
|
|
3905 |
viewBounds.point = (*deviceContext->Origin());
|
|
3906 |
|
|
3907 |
NW_GDI_Rectangle_t boxBounds = NW_LMgr_Box_GetDisplayBounds(box);
|
|
3908 |
|
|
3909 |
if (NW_GDI_Rectangle_Cross(&viewBounds, &boxBounds, &clipRect))
|
|
3910 |
{
|
|
3911 |
/* Get the current box */
|
|
3912 |
currentBox = NW_LMgr_RootBox_GetCurrentBox( iRootBox );
|
|
3913 |
/* Set the new clip */
|
|
3914 |
deviceContext->SetClipRect( &clipRect );
|
|
3915 |
|
|
3916 |
bodyColor.type = NW_CSS_ValueType_Token;
|
|
3917 |
bodyColor.value.token = NW_CSS_PropValue_transparent;
|
|
3918 |
(void)NW_LMgr_Box_GetProperty(box, NW_CSS_Prop_backgroundColor, &bodyColor);
|
|
3919 |
if (bodyColor.type == NW_CSS_ValueType_Color)
|
|
3920 |
{
|
|
3921 |
bgColor = bodyColor.value.integer;
|
|
3922 |
}
|
|
3923 |
deviceContext->SetBackgroundColor( bgColor );
|
|
3924 |
|
|
3925 |
/* Clear the area */
|
|
3926 |
deviceContext->PreDraw ();
|
|
3927 |
|
|
3928 |
/* Draw the background */
|
|
3929 |
status = NW_LMgr_Box_DrawBackground (box, box->parent, deviceContext);
|
|
3930 |
if (status != KBrsrSuccess)
|
|
3931 |
{
|
|
3932 |
goto finish;
|
|
3933 |
}
|
|
3934 |
|
|
3935 |
if ( NW_Object_IsClass( box, &NW_LMgr_AnimatedImageBox_Class) )
|
|
3936 |
{
|
|
3937 |
flags = (NW_Uint8)NW_LMgr_Box_Flags_DrawFloats;
|
|
3938 |
}
|
|
3939 |
else if ( NW_Object_IsDerivedFrom( box, &NW_LMgr_ImgContainerBox_Class) )
|
|
3940 |
{
|
|
3941 |
if ( NW_LMgr_ImgContainerBox_ImageIsBroken( box ) == NW_FALSE )
|
|
3942 |
{
|
|
3943 |
flags = (NW_Uint8)NW_LMgr_Box_Flags_DrawFloats;
|
|
3944 |
}
|
|
3945 |
}
|
|
3946 |
//R->embed
|
|
3947 |
//else if ( ObjectUtils::IsObjectBox(*box, EFalse) )
|
|
3948 |
// {
|
|
3949 |
// flags = (NW_Uint8)NW_LMgr_Box_Flags_DrawFloats;
|
|
3950 |
// }
|
|
3951 |
|
|
3952 |
/* Render the box and its descendants */
|
|
3953 |
/* Adjust crop if parent has it set */
|
|
3954 |
NW_LMgr_Box_t* tempBox = NULL;
|
|
3955 |
NW_GDI_Rectangle_t newClip = viewBounds;
|
|
3956 |
|
|
3957 |
if ( !NW_LMgr_RootBox_GetSmallScreenOn( iRootBox ) )
|
|
3958 |
{
|
|
3959 |
tempBox = NW_LMgr_BoxOf( box->parent );
|
|
3960 |
/* EXPENSIVE OPERATION:Needs to be reevaluated */
|
|
3961 |
do
|
|
3962 |
{
|
|
3963 |
if ( NW_Object_IsInstanceOf( tempBox, &NW_LMgr_StaticTableCellBox_Class ) )
|
|
3964 |
{
|
|
3965 |
newClip = NW_LMgr_StaticTableCellBoxOf(tempBox)->cellClip;
|
|
3966 |
break;
|
|
3967 |
}
|
|
3968 |
tempBox = NW_LMgr_BoxOf(tempBox->parent);
|
|
3969 |
}
|
|
3970 |
while ( tempBox != NULL );
|
|
3971 |
}
|
|
3972 |
// Find out if the box or the parent is in focus
|
|
3973 |
NW_Bool hasFocus;
|
|
3974 |
// check if childbox is the current box
|
|
3975 |
hasFocus = ( currentBox == box );
|
|
3976 |
if ( !hasFocus )
|
|
3977 |
{
|
|
3978 |
// if the currentBox is a container, then check its childern to see if 'box' is
|
|
3979 |
// one of them.
|
|
3980 |
if ( currentBox && NW_Object_IsDerivedFrom( currentBox, &NW_LMgr_ContainerBox_Class) )
|
|
3981 |
{
|
|
3982 |
//
|
|
3983 |
NW_LMgr_BoxVisitor_t boxVisitor;
|
|
3984 |
|
|
3985 |
NW_LMgr_BoxVisitor_Initialize( &boxVisitor, (NW_LMgr_Box_t*)currentBox );
|
|
3986 |
while ( ( tempBox = NW_LMgr_BoxVisitor_NextBox( &boxVisitor, NULL ) ) != NULL )
|
|
3987 |
{
|
|
3988 |
//
|
|
3989 |
if ( box == tempBox )
|
|
3990 |
{
|
|
3991 |
hasFocus = NW_TRUE;
|
|
3992 |
break;
|
|
3993 |
}
|
|
3994 |
}
|
|
3995 |
}
|
|
3996 |
}
|
|
3997 |
flags = (NW_Uint8)NW_LMgr_Box_Flags_DrawFloats;
|
|
3998 |
status = BoxRender_Render (box, deviceContext, &newClip, currentBox, flags, hasFocus,
|
|
3999 |
iRootBox );
|
|
4000 |
if (status != KBrsrSuccess)
|
|
4001 |
{
|
|
4002 |
goto finish;
|
|
4003 |
}
|
|
4004 |
|
|
4005 |
/* Invalidate the box area */
|
|
4006 |
deviceContext->PostDraw (NW_FALSE);
|
|
4007 |
}
|
|
4008 |
if (!NW_Object_IsInstanceOf(box, &NW_LMgr_PosFlowBox_Class))
|
|
4009 |
{
|
|
4010 |
DrawPositionedBoxes();
|
|
4011 |
}
|
|
4012 |
|
|
4013 |
finish:
|
|
4014 |
/* Reset the clip */
|
|
4015 |
deviceContext->SetClipRect ( &origClip);
|
|
4016 |
deviceContext->SetBackgroundColor( origBgColor );
|
|
4017 |
|
|
4018 |
return status;
|
|
4019 |
}
|
|
4020 |
|
|
4021 |
/* ------------------------------------------------------------------------- */
|
|
4022 |
TBrowserStatusCode
|
|
4023 |
CView::RedrawDisplay (NW_Bool drawNow)
|
|
4024 |
{
|
|
4025 |
/* get the listener and send a redraw request */
|
|
4026 |
return iShell->SendRedrawMsg (drawNow);
|
|
4027 |
}
|
|
4028 |
|
|
4029 |
const NW_GDI_Point2D_t*
|
|
4030 |
CView::GetOrigin ()
|
|
4031 |
{
|
|
4032 |
return iDeviceContext->Origin();
|
|
4033 |
}
|
|
4034 |
|
|
4035 |
//-----------------------------------------------------------------------------
|
|
4036 |
// functions from Epoc32View
|
|
4037 |
//-----------------------------------------------------------------------------
|
|
4038 |
NW_Bool
|
|
4039 |
CView::ProcessEvent (const NW_Evt_Event_t* event)
|
|
4040 |
{
|
|
4041 |
CMVCScroll* scroll;
|
|
4042 |
|
|
4043 |
// parameter assertion block
|
|
4044 |
NW_ASSERT (event != NULL);
|
|
4045 |
|
|
4046 |
scroll = (CMVCScroll*)iScroll;
|
|
4047 |
|
|
4048 |
if ( EpocProcessEvent(event) )
|
|
4049 |
{
|
|
4050 |
return NW_TRUE;
|
|
4051 |
}
|
|
4052 |
|
|
4053 |
if (NW_Object_IsClass(event, &NW_Evt_FontSizeChangeEvent_Class))
|
|
4054 |
{
|
|
4055 |
return ProcessFontSizeChangeEvent ();
|
|
4056 |
}
|
|
4057 |
|
|
4058 |
if (NW_Object_IsClass(event, &NW_Evt_UnicodeKeyEvent_Class))
|
|
4059 |
{
|
|
4060 |
NW_Bool absorbed = NW_FALSE;
|
|
4061 |
|
|
4062 |
// long keypress -> access key handling
|
|
4063 |
absorbed = ProcessAccessKey( NW_Evt_KeyEventOf(event) );
|
|
4064 |
NW_Evt_ControlKeyType_t controlKey = NW_Evt_ControlKeyType_None;
|
|
4065 |
// short keypress -> home/end functionality
|
|
4066 |
if(!absorbed)
|
|
4067 |
{
|
|
4068 |
|
|
4069 |
if ( controlKey != NW_Evt_ControlKeyType_None )
|
|
4070 |
{
|
|
4071 |
absorbed = (NW_Bool)scroll->ScrollPage( controlKey );
|
|
4072 |
// refresh if absorbed
|
|
4073 |
if ( absorbed )
|
|
4074 |
{
|
|
4075 |
(void)Draw( NW_TRUE );
|
|
4076 |
}
|
|
4077 |
}
|
|
4078 |
}
|
|
4079 |
return absorbed;
|
|
4080 |
}
|
|
4081 |
|
|
4082 |
// our superclass didn't want to take responsibility of the event so we must
|
|
4083 |
// try to do something with it
|
|
4084 |
if (NW_Object_IsInstanceOf (event, &NW_Evt_ControlKeyEvent_Class))
|
|
4085 |
{
|
|
4086 |
NW_Evt_ControlKeyType_t key;
|
|
4087 |
|
|
4088 |
// we really only care about a handful of key events
|
|
4089 |
key = NW_Evt_ControlKeyEvent_GetKeyVal (event);
|
|
4090 |
if (key != NW_Evt_ControlKeyType_Left && key != NW_Evt_ControlKeyType_Right &&
|
|
4091 |
key != NW_Evt_ControlKeyType_Up && key != NW_Evt_ControlKeyType_Down)
|
|
4092 |
{
|
|
4093 |
return NW_FALSE;
|
|
4094 |
}
|
|
4095 |
if ( !NW_LMgr_RootBox_GetSmallScreenOn( iRootBox ) )
|
|
4096 |
{
|
|
4097 |
return (NW_Bool)scroll->ProcessControlKey(key);
|
|
4098 |
}
|
|
4099 |
else
|
|
4100 |
{
|
|
4101 |
// Process keys for vertical layout
|
|
4102 |
return (NW_Bool)scroll->ProcessControlKeyVL(key);
|
|
4103 |
}
|
|
4104 |
}
|
|
4105 |
|
|
4106 |
return NW_FALSE;
|
|
4107 |
}
|
|
4108 |
|
|
4109 |
//-----------------------------------------------------------------------------
|
|
4110 |
// functions from CEpoc32View, Epoc32ViewCallbacks
|
|
4111 |
//-----------------------------------------------------------------------------
|
|
4112 |
void
|
|
4113 |
CView::SwitchVerticalLayout()
|
|
4114 |
{
|
|
4115 |
/* If the page is WML or XHTML, don't switch mode */
|
|
4116 |
if (NW_Settings_GetDisableSmallScreenLayout())
|
|
4117 |
{
|
|
4118 |
return ;
|
|
4119 |
}
|
|
4120 |
|
|
4121 |
if (NW_Object_IsInstanceOf (iShell->GetDocumentRoot()->childNode, &NW_XHTML_ContentHandler_Class))
|
|
4122 |
{
|
|
4123 |
ExternalLayoutSwitch ();
|
|
4124 |
|
|
4125 |
if (IsImageMapView())
|
|
4126 |
{
|
|
4127 |
SwitchFromImageMapView();
|
|
4128 |
}
|
|
4129 |
else
|
|
4130 |
{
|
|
4131 |
SwitchVerticalLayout (NW_TRUE, NW_TRUE);
|
|
4132 |
}
|
|
4133 |
}
|
|
4134 |
|
|
4135 |
/* In case we change from vertical mode to normal mode, we want to load all the images
|
|
4136 |
that we did not load in vertical mode since they were too small
|
|
4137 |
*/
|
|
4138 |
if ( !NW_LMgr_RootBox_GetSmallScreenOn( iRootBox ) )
|
|
4139 |
{
|
|
4140 |
if (NW_Object_IsInstanceOf (iShell->GetDocumentRoot()->childNode, &NW_XHTML_ContentHandler_Class))
|
|
4141 |
{
|
|
4142 |
NW_CSS_Processor_t* processor = NW_XHTML_ContentHandler_GetCSSProcessor(
|
|
4143 |
NW_XHTML_ContentHandlerOf (iShell->GetDocumentRoot()->childNode));
|
|
4144 |
if (processor != NULL)
|
|
4145 |
{
|
|
4146 |
NW_CSS_Processor_ProcessPendingLoads(processor);
|
|
4147 |
}
|
|
4148 |
}
|
|
4149 |
if (NW_Settings_GetImagesEnabled())
|
|
4150 |
{
|
|
4151 |
NW_HED_DocumentRoot_ShowImages (iShell->GetDocumentRoot());
|
|
4152 |
}
|
|
4153 |
}
|
|
4154 |
}
|
|
4155 |
|
|
4156 |
TKeyResponse
|
|
4157 |
CView::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
|
|
4158 |
{
|
|
4159 |
if (aType != EEventKey)
|
|
4160 |
return EKeyWasNotConsumed;
|
|
4161 |
|
|
4162 |
TKeyResponse retVal = EKeyWasNotConsumed;
|
|
4163 |
|
|
4164 |
retVal = DoHandleControlKeysL(aKeyEvent);
|
|
4165 |
if (retVal == EKeyWasConsumed)
|
|
4166 |
return retVal;
|
|
4167 |
|
|
4168 |
NW_Bool isLongKeypress = ((aKeyEvent.iRepeats == 1) && (iLastRepeats == 0)); // Long Keypress
|
|
4169 |
iLastRepeats = aKeyEvent.iRepeats;
|
|
4170 |
|
|
4171 |
NW_Bool absorbed = NW_FALSE;
|
|
4172 |
NW_Evt_UnicodeKeyEvent_t keyEvent;
|
|
4173 |
|
|
4174 |
switch ((NW_Ucs2)aKeyEvent.iCode)
|
|
4175 |
{
|
|
4176 |
case '0':
|
|
4177 |
case '1':
|
|
4178 |
case '2':
|
|
4179 |
case '3':
|
|
4180 |
case '4':
|
|
4181 |
case '5':
|
|
4182 |
case '6':
|
|
4183 |
case '7':
|
|
4184 |
case '8':
|
|
4185 |
case '9':
|
|
4186 |
{
|
|
4187 |
break;
|
|
4188 |
}
|
|
4189 |
case '*': // fall through
|
|
4190 |
case '#':
|
|
4191 |
{
|
|
4192 |
// *(home) and #(end) shortcuts work on both small
|
|
4193 |
// and normal mode
|
|
4194 |
// process short *,# key event
|
|
4195 |
break;
|
|
4196 |
}
|
|
4197 |
default:
|
|
4198 |
{
|
|
4199 |
//return EKeyWasNotConsumed; for qwerty functionality
|
|
4200 |
}
|
|
4201 |
}
|
|
4202 |
|
|
4203 |
TBrowserStatusCode status = NW_Evt_UnicodeKeyEvent_Initialize(&keyEvent, (NW_Ucs2)aKeyEvent.iCode);
|
|
4204 |
if (status == KBrsrSuccess)
|
|
4205 |
{
|
|
4206 |
if (isLongKeypress)
|
|
4207 |
{
|
|
4208 |
NW_Evt_KeyEvent_SetLongPress(&keyEvent);
|
|
4209 |
}
|
|
4210 |
absorbed = ProcessEvent ( NW_Evt_EventOf(&keyEvent) );
|
|
4211 |
}
|
|
4212 |
|
|
4213 |
return (absorbed == NW_FALSE) ? EKeyWasNotConsumed : EKeyWasConsumed;
|
|
4214 |
}
|
|
4215 |
|
|
4216 |
//-----------------------------------------------------------------------------
|
|
4217 |
void CView::HandlePointerEventL(const TPointerEvent& aPointerEvent)
|
|
4218 |
{
|
|
4219 |
switch (aPointerEvent.iType) {
|
|
4220 |
case TPointerEvent::EButton1Down:
|
|
4221 |
iLastPosition = aPointerEvent.iPosition;
|
|
4222 |
iDrag = EFalse;
|
|
4223 |
break;
|
|
4224 |
case TPointerEvent::EDrag:
|
|
4225 |
TPoint currPosition;
|
|
4226 |
TPoint nextPosition;
|
|
4227 |
nextPosition = iLastPosition - aPointerEvent.iPosition;
|
|
4228 |
iLastPosition = aPointerEvent.iPosition;
|
|
4229 |
|
|
4230 |
if(nextPosition.iX || nextPosition.iY)
|
|
4231 |
{
|
|
4232 |
currPosition.iX = iDeviceContext->Origin()->x;
|
|
4233 |
currPosition.iY = iDeviceContext->Origin()->y;
|
|
4234 |
ScrollTo(currPosition+nextPosition);
|
|
4235 |
|
|
4236 |
//This is for Drag event
|
|
4237 |
//Introducing 10 pixel offset. This is introduced to tackle problem that occurs if user clicks
|
|
4238 |
//link but still causes a very small pixel move. This gives a small difference in previous
|
|
4239 |
//and next position. As a side effect iDrag will be true and request will not be sent even if
|
|
4240 |
//there is very small pixel difference.
|
|
4241 |
//Following logic tries to handle such scenario.
|
|
4242 |
TInt nOffset = 10;
|
|
4243 |
TBool bXOffset = ((nextPosition.iX > nOffset) || (nextPosition.iX < -nOffset));
|
|
4244 |
TBool bYOffset = ((nextPosition.iY > nOffset) || (nextPosition.iY < -nOffset));
|
|
4245 |
if(bXOffset || bYOffset)
|
|
4246 |
{
|
|
4247 |
iDrag = ETrue;
|
|
4248 |
}
|
|
4249 |
}
|
|
4250 |
break;
|
|
4251 |
}
|
|
4252 |
|
|
4253 |
NW_ADT_Vector_Metric_t i;
|
|
4254 |
NW_ADT_Vector_Metric_t size = NW_ADT_Vector_GetSize( iTabList );
|
|
4255 |
i = 0;
|
|
4256 |
TBool activeInputBox = iCurrentBox && NW_Object_IsInstanceOf(iCurrentBox, &NW_FBox_InputBox_Class) &&
|
|
4257 |
NW_FBox_InputBox_IsActive( iCurrentBox );
|
|
4258 |
TBool found = EFalse;
|
|
4259 |
TPoint point = aPointerEvent.iPosition + (TPoint(iDeviceContext->Origin()->x, iDeviceContext->Origin()->y));
|
|
4260 |
for( i = 0; i < size; i++ )
|
|
4261 |
{
|
|
4262 |
NW_LMgr_Box_t* tempBox = (NW_LMgr_Box_t*)*NW_ADT_Vector_ElementAt( iTabList, (NW_ADT_Vector_Metric_t)i);
|
|
4263 |
NW_GDI_Rectangle_t boxRect = GetBoxDisplayBounds(tempBox);
|
|
4264 |
TRect rect(TPoint(boxRect.point.x, boxRect.point.y), TSize(boxRect.dimension.width, boxRect.dimension.height));
|
|
4265 |
if (rect.Contains(point))
|
|
4266 |
{
|
|
4267 |
found = ETrue;
|
|
4268 |
}
|
|
4269 |
else
|
|
4270 |
{
|
|
4271 |
NW_LMgr_Property_t prop;
|
|
4272 |
NW_LMgr_Box_t* box = tempBox;
|
|
4273 |
TBool done = EFalse;
|
|
4274 |
while(!done)
|
|
4275 |
{
|
|
4276 |
prop.value.object = NULL;
|
|
4277 |
if (NW_LMgr_Box_GetProperty( box, NW_CSS_Prop_sibling, &prop ) == KBrsrSuccess)
|
|
4278 |
{
|
|
4279 |
if ( prop.value.object != NULL && prop.value.object != tempBox )
|
|
4280 |
{
|
|
4281 |
box = NW_LMgr_BoxOf( prop.value.object );
|
|
4282 |
boxRect = GetBoxDisplayBounds(box);
|
|
4283 |
rect.SetRect(TPoint(boxRect.point.x, boxRect.point.y), TSize(boxRect.dimension.width, boxRect.dimension.height));
|
|
4284 |
if (rect.Contains(point))
|
|
4285 |
{
|
|
4286 |
found = ETrue;
|
|
4287 |
break;
|
|
4288 |
}
|
|
4289 |
}
|
|
4290 |
else
|
|
4291 |
{
|
|
4292 |
done = ETrue;
|
|
4293 |
}
|
|
4294 |
}
|
|
4295 |
else
|
|
4296 |
{
|
|
4297 |
done = ETrue;
|
|
4298 |
}
|
|
4299 |
}
|
|
4300 |
}
|
|
4301 |
|
|
4302 |
if (found)
|
|
4303 |
{
|
|
4304 |
if (tempBox != iCurrentBox)
|
|
4305 |
{
|
|
4306 |
iShouldActivate = EFalse;
|
|
4307 |
}
|
|
4308 |
if (aPointerEvent.iType == TPointerEvent::EButton1Down)
|
|
4309 |
{
|
|
4310 |
iShouldActivate = ETrue;
|
|
4311 |
}
|
|
4312 |
if (tempBox != iCurrentBox)
|
|
4313 |
{
|
|
4314 |
if (activeInputBox)
|
|
4315 |
{
|
|
4316 |
if (!InputElementEditComplete( NW_TRUE ))
|
|
4317 |
{
|
|
4318 |
iShouldActivate = EFalse;
|
|
4319 |
break;
|
|
4320 |
}
|
|
4321 |
}
|
|
4322 |
NW_LMgr_Box_SetHasFocus (iCurrentBox, NW_FALSE);
|
|
4323 |
NW_LMgr_Box_SetHasFocus (tempBox, NW_TRUE);
|
|
4324 |
SetCurrentBox(tempBox);
|
|
4325 |
NW_LMgr_RootBox_SetFocusBox(iRootBox, tempBox);
|
|
4326 |
Draw (NW_TRUE /*DrawNow*/);
|
|
4327 |
}
|
|
4328 |
if ((aPointerEvent.iType == TPointerEvent::EButton1Up) && (iShouldActivate))
|
|
4329 |
{
|
|
4330 |
if((!iDrag))
|
|
4331 |
{
|
|
4332 |
if(!iPeriodicTimer->IsActive() )
|
|
4333 |
{
|
|
4334 |
iPeriodicTimer->Start(KPeriodicTimerStartInterval2Sec, NULL, TCallBack(PeriodicTimerCallBack, this));
|
|
4335 |
}
|
|
4336 |
else
|
|
4337 |
{
|
|
4338 |
continue;
|
|
4339 |
}
|
|
4340 |
NW_Evt_ActivateEvent_t actEvent;
|
|
4341 |
NW_Evt_ActivateEvent_Initialize (&actEvent);
|
|
4342 |
ProcessEvent (NW_Evt_EventOf(&actEvent));
|
|
4343 |
}
|
|
4344 |
}
|
|
4345 |
break;
|
|
4346 |
}
|
|
4347 |
}
|
|
4348 |
if (!found) // Clicked or dragged on an empty area
|
|
4349 |
{
|
|
4350 |
iShouldActivate = EFalse;
|
|
4351 |
if (activeInputBox)
|
|
4352 |
{
|
|
4353 |
InputElementEditComplete( NW_TRUE );
|
|
4354 |
}
|
|
4355 |
}
|
|
4356 |
}
|
|
4357 |
|
|
4358 |
//-----------------------------------------------------------------------------
|
|
4359 |
void
|
|
4360 |
CView::FocusChanged (TDrawNow aDrawNow)
|
|
4361 |
{
|
|
4362 |
if (IsFocused())
|
|
4363 |
{
|
|
4364 |
iShell->GainFocus();
|
|
4365 |
}
|
|
4366 |
else
|
|
4367 |
// control is about losing the focus
|
|
4368 |
{
|
|
4369 |
iShell->LoseFocus();
|
|
4370 |
}
|
|
4371 |
// Inform all focus observers that the focus changed.
|
|
4372 |
// This is important because we need to inform Flash plugin to stop playing
|
|
4373 |
// when the browser is in the background
|
|
4374 |
TInt count = iViewFocusObserver.Count();
|
|
4375 |
for (TInt i = 0; i < count; i++)
|
|
4376 |
{
|
|
4377 |
//iViewFocusObserver[i]->ViewFocusChanged(IsFocused());
|
|
4378 |
}
|
|
4379 |
|
|
4380 |
CEikBorderedControl::FocusChanged(aDrawNow);
|
|
4381 |
}
|
|
4382 |
|
|
4383 |
// -------------------------------------------------------------------------
|
|
4384 |
void CView::SetFormattingPriority( CActive::TPriority aPriority )
|
|
4385 |
{
|
|
4386 |
iFormatPriority = aPriority;
|
|
4387 |
}
|
|
4388 |
|
|
4389 |
// -------------------------------------------------------------------------
|
|
4390 |
TInt CView::AppendFocusObserver(MViewFocusObserver* aViewFocusObserver)
|
|
4391 |
{
|
|
4392 |
NW_ASSERT(aViewFocusObserver != NULL);
|
|
4393 |
return iViewFocusObserver.Append(aViewFocusObserver);
|
|
4394 |
}
|
|
4395 |
|
|
4396 |
// -------------------------------------------------------------------------
|
|
4397 |
void CView::RemoveFocusObserver(MViewFocusObserver* aViewFocusObserver)
|
|
4398 |
{
|
|
4399 |
NW_ASSERT(aViewFocusObserver != NULL);
|
|
4400 |
TInt i = iViewFocusObserver.Find(aViewFocusObserver);
|
|
4401 |
if (i != KErrNotFound)
|
|
4402 |
{
|
|
4403 |
iViewFocusObserver.Remove(i);
|
|
4404 |
}
|
|
4405 |
}
|
|
4406 |
|
|
4407 |
// -------------------------------------------------------------------------
|
|
4408 |
TInt CView::AddStateChangeObserver(MBrCtlStateChangeObserver* aBrCtlStateChangeObserver)
|
|
4409 |
{
|
|
4410 |
NW_ASSERT(aBrCtlStateChangeObserver != NULL);
|
|
4411 |
return iStateChangeObserver.Append(aBrCtlStateChangeObserver);
|
|
4412 |
}
|
|
4413 |
|
|
4414 |
// -------------------------------------------------------------------------
|
|
4415 |
void CView::RemoveStateChangeObserver(MBrCtlStateChangeObserver* aBrCtlStateChangeObserver)
|
|
4416 |
{
|
|
4417 |
NW_ASSERT(aBrCtlStateChangeObserver != NULL);
|
|
4418 |
TInt i = iStateChangeObserver.Find(aBrCtlStateChangeObserver);
|
|
4419 |
if (i != KErrNotFound)
|
|
4420 |
{
|
|
4421 |
iStateChangeObserver.Remove(i);
|
|
4422 |
}
|
|
4423 |
}
|
|
4424 |
|
|
4425 |
//-----------------------------------------------------------------------------
|
|
4426 |
TKeyResponse
|
|
4427 |
CView::DoHandleControlKeysL(const TKeyEvent& aKeyEvent)
|
|
4428 |
{
|
|
4429 |
TKeyResponse keyConsumed = EKeyWasNotConsumed;
|
|
4430 |
NW_Evt_ControlKeyEvent_t controlKeyEvent;
|
|
4431 |
NW_Evt_ControlKeyType_t controlKeyVal;
|
|
4432 |
|
|
4433 |
controlKeyVal = NW_Evt_ControlKeyType_None;
|
|
4434 |
|
|
4435 |
switch (aKeyEvent.iCode)
|
|
4436 |
{
|
|
4437 |
case EKeyLeftArrow:
|
|
4438 |
controlKeyVal = NW_Evt_ControlKeyType_Left;
|
|
4439 |
break;
|
|
4440 |
|
|
4441 |
case EKeyRightArrow:
|
|
4442 |
controlKeyVal = NW_Evt_ControlKeyType_Right;
|
|
4443 |
break;
|
|
4444 |
|
|
4445 |
case EKeyUpArrow:
|
|
4446 |
controlKeyVal = NW_Evt_ControlKeyType_Up;
|
|
4447 |
break;
|
|
4448 |
|
|
4449 |
case EKeyDownArrow:
|
|
4450 |
controlKeyVal = NW_Evt_ControlKeyType_Down;
|
|
4451 |
break;
|
|
4452 |
|
|
4453 |
case EKeyEnter:
|
|
4454 |
case EKeyDevice3:
|
|
4455 |
{
|
|
4456 |
NW_Evt_ActivateEvent_t actEvent;
|
|
4457 |
NW_Evt_ActivateEvent_Initialize (&actEvent);
|
|
4458 |
|
|
4459 |
if ( ProcessEvent (NW_Evt_EventOf(&actEvent)) )
|
|
4460 |
{
|
|
4461 |
keyConsumed = EKeyWasConsumed;
|
|
4462 |
}
|
|
4463 |
break;
|
|
4464 |
}
|
|
4465 |
|
|
4466 |
default:
|
|
4467 |
return keyConsumed;
|
|
4468 |
}
|
|
4469 |
if (controlKeyVal != NW_Evt_ControlKeyType_None)
|
|
4470 |
{
|
|
4471 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
4472 |
|
|
4473 |
status = NW_Evt_ControlKeyEvent_Initialize (&controlKeyEvent, controlKeyVal);
|
|
4474 |
if (status != KBrsrSuccess)
|
|
4475 |
{
|
|
4476 |
return keyConsumed;
|
|
4477 |
}
|
|
4478 |
NW_GDI_Rectangle_t viewBoundsOld, viewBoundsNew;
|
|
4479 |
viewBoundsOld = *iDeviceContext->DisplayBounds();
|
|
4480 |
viewBoundsOld.point = *iDeviceContext->Origin();
|
|
4481 |
|
|
4482 |
if ( ProcessEvent (NW_Evt_EventOf(&controlKeyEvent)) )
|
|
4483 |
{
|
|
4484 |
viewBoundsNew = *iDeviceContext->DisplayBounds();
|
|
4485 |
viewBoundsNew.point = *iDeviceContext->Origin();
|
|
4486 |
|
|
4487 |
/* scroll happened*/
|
|
4488 |
if (viewBoundsNew.point.y != viewBoundsOld.point.y || viewBoundsNew.point.x != viewBoundsOld.point.x)
|
|
4489 |
{
|
|
4490 |
status = Draw (NW_TRUE /*DrawNow*/);
|
|
4491 |
NW_ASSERT(status == KBrsrSuccess);
|
|
4492 |
}
|
|
4493 |
|
|
4494 |
return EKeyWasConsumed;
|
|
4495 |
}
|
|
4496 |
}
|
|
4497 |
return keyConsumed;
|
|
4498 |
}
|
|
4499 |
|
|
4500 |
//-----------------------------------------------------------------------------
|
|
4501 |
void
|
|
4502 |
CView::SizeChanged()
|
|
4503 |
{
|
|
4504 |
const TRect rect(Rect());
|
|
4505 |
NW_GDI_Rectangle_t rbDisplayBounds;
|
|
4506 |
NW_LMgr_BoxVisitor_t visitor;
|
|
4507 |
NW_LMgr_Box_t* child = NULL;
|
|
4508 |
|
|
4509 |
rbDisplayBounds.point.x = (NW_GDI_Metric_t)rect.iTl.iX;
|
|
4510 |
rbDisplayBounds.point.y = (NW_GDI_Metric_t)rect.iTl.iY;
|
|
4511 |
rbDisplayBounds.dimension.height = (NW_GDI_Metric_t)rect.Height();
|
|
4512 |
rbDisplayBounds.dimension.width = (NW_GDI_Metric_t)rect.Width();
|
|
4513 |
|
|
4514 |
TRAPD(err, CreateOffscreenBitmapL( Rect() ));
|
|
4515 |
if (err != KErrNone)
|
|
4516 |
{
|
|
4517 |
return ;
|
|
4518 |
}
|
|
4519 |
|
|
4520 |
// IKZ - it is not good to set GC directly to OOC class - may be we shall implement a setter
|
|
4521 |
iDeviceContext->SetGraphicsContext( (void*)iBitmapContext );
|
|
4522 |
|
|
4523 |
const NW_GDI_Rectangle_t* oldDisplayBounds = iDeviceContext->DisplayBounds();
|
|
4524 |
|
|
4525 |
if (rbDisplayBounds.point.x != oldDisplayBounds->point.x ||
|
|
4526 |
rbDisplayBounds.point.y != oldDisplayBounds->point.y ||
|
|
4527 |
rbDisplayBounds.dimension.height != oldDisplayBounds->dimension.height ||
|
|
4528 |
rbDisplayBounds.dimension.width != oldDisplayBounds->dimension.width )
|
|
4529 |
{
|
|
4530 |
// We need to protect against the case where the StatusPane changed due to an embedded app.
|
|
4531 |
// When that happens, we compute all the clipRects based on the wrong size.
|
|
4532 |
NW_LMgr_RootBox_InvalidateCache (iRootBox);
|
|
4533 |
}
|
|
4534 |
|
|
4535 |
// if the width of the rect has changed, we want to reformat the box tree
|
|
4536 |
if (rbDisplayBounds.dimension.width != oldDisplayBounds->dimension.width )
|
|
4537 |
{
|
|
4538 |
// cancel any existing formatting
|
|
4539 |
((CLMgr_BoxFormatHandler*)iBoxFormatHandler)->Cancel();
|
|
4540 |
|
|
4541 |
NW_GDI_Point2D_t origin = *(iDeviceContext->Origin());
|
|
4542 |
origin.x = 0;
|
|
4543 |
origin.y = 0;
|
|
4544 |
iDeviceContext->SetOrigin (&origin);
|
|
4545 |
|
|
4546 |
iDeviceContext->SetDisplayBounds(&rbDisplayBounds);
|
|
4547 |
// Iterate through all children and initialize the box bounds to 0
|
|
4548 |
NW_LMgr_BoxVisitor_Initialize(&visitor, NW_LMgr_BoxOf(iRootBox));
|
|
4549 |
|
|
4550 |
child = NW_LMgr_BoxVisitor_NextBox(&visitor, NULL);
|
|
4551 |
// Initialize the coordinates
|
|
4552 |
NW_GDI_Rectangle_t boxBounds; // = NW_LMgr_Box_GetFormatBounds( child );
|
|
4553 |
|
|
4554 |
NW_Mem_memset(&(boxBounds), 0, sizeof(NW_GDI_Rectangle_t));
|
|
4555 |
while ((child = NW_LMgr_BoxVisitor_NextBox(&visitor, NULL)) != NULL)
|
|
4556 |
{
|
|
4557 |
NW_LMgr_Box_SetFormatBounds( child, boxBounds );
|
|
4558 |
NW_LMgr_Box_UpdateDisplayBounds( child, boxBounds );
|
|
4559 |
}
|
|
4560 |
|
|
4561 |
(void) Collapse (NULL, NW_FALSE);
|
|
4562 |
|
|
4563 |
(void) FormatBoxTree (NW_TRUE);
|
|
4564 |
|
|
4565 |
}
|
|
4566 |
|
|
4567 |
SetDisplayExtents(&rbDisplayBounds);
|
|
4568 |
|
|
4569 |
(void) Draw (NW_TRUE /*DrawNow*/);
|
|
4570 |
}
|
|
4571 |
|
|
4572 |
/* ------------------------------------------------------------------------- */
|
|
4573 |
void
|
|
4574 |
CView::SetAppServices (void* appServices)
|
|
4575 |
{
|
|
4576 |
iRootBox->appServices = (NW_HED_AppServices_t*) appServices;
|
|
4577 |
iDeviceContext->SetFontSizeLevel( (TGDIDeviceContextFontSizeLevel)NW_Settings_GetFontSizeLevel() );
|
|
4578 |
}
|
|
4579 |
|
|
4580 |
//-----------------------------------------------------------------------------
|
|
4581 |
void CView::SetShell(CShell* shell)
|
|
4582 |
{
|
|
4583 |
iShell = shell;
|
|
4584 |
}
|
|
4585 |
|
|
4586 |
//-----------------------------------------------------------------------------
|
|
4587 |
void CView::DoScrollL(const TInt16 /*aScrollDirection*/, const TUint32 /*aScrollDelta*/ )
|
|
4588 |
{}
|
|
4589 |
|
|
4590 |
//-----------------------------------------------------------------------------
|
|
4591 |
TBrCtlDefs::TBrCtlElementType CView::GetFocusedElementType()
|
|
4592 |
{
|
|
4593 |
TBrCtlDefs::TBrCtlElementType retVal = TBrCtlDefs::EElementNone;
|
|
4594 |
NW_LMgr_Box_t* currentBox = iCurrentBox;
|
|
4595 |
NW_GDI_Rectangle_t viewBounds;
|
|
4596 |
|
|
4597 |
viewBounds = *iDeviceContext->DisplayBounds();
|
|
4598 |
viewBounds.point = *iDeviceContext->Origin();
|
|
4599 |
NW_GDI_Rectangle_t boxBounds = NW_LMgr_Box_GetDisplayBounds( currentBox );
|
|
4600 |
|
|
4601 |
if ( currentBox == NULL || !NW_GDI_Rectangle_Cross(&viewBounds, &boxBounds, NULL))
|
|
4602 |
{
|
|
4603 |
/* if there is no current box or it it not visible */
|
|
4604 |
retVal = TBrCtlDefs::EElementNone;
|
|
4605 |
}
|
|
4606 |
else if ( NW_Object_IsInstanceOf(currentBox, &NW_LMgr_ActiveContainerBox_Class) )
|
|
4607 |
{
|
|
4608 |
if (NW_LMgr_ActiveContainerBox_GetActionType(currentBox) == NW_LMgr_ActionType_SendMail)
|
|
4609 |
{
|
|
4610 |
retVal = TBrCtlDefs::EElementMailtoAnchor;
|
|
4611 |
}
|
|
4612 |
else if (NW_LMgr_ActiveContainerBox_GetActionType(currentBox) == NW_LMgr_ActionType_DialNumber)
|
|
4613 |
{
|
|
4614 |
retVal = TBrCtlDefs::EElementTelAnchor;
|
|
4615 |
}
|
|
4616 |
else
|
|
4617 |
{
|
|
4618 |
retVal = TBrCtlDefs::EElementAnchor;
|
|
4619 |
}
|
|
4620 |
}
|
|
4621 |
else if ( NW_Object_IsInstanceOf(currentBox, &NW_FBox_RadioBox_Class) )
|
|
4622 |
{
|
|
4623 |
NW_Bool state = NW_FBox_CheckBox_GetState(NW_FBox_CheckBoxOf(currentBox));
|
|
4624 |
if (state == NW_TRUE)
|
|
4625 |
{
|
|
4626 |
retVal = TBrCtlDefs::EElementRadioButtonSelected;
|
|
4627 |
}
|
|
4628 |
else
|
|
4629 |
{
|
|
4630 |
retVal = TBrCtlDefs::EElementRadioButtonUnSelected;
|
|
4631 |
}
|
|
4632 |
}
|
|
4633 |
else if ( NW_Object_IsInstanceOf(currentBox, &NW_FBox_CheckBox_Class) )
|
|
4634 |
{
|
|
4635 |
NW_Bool state = NW_FBox_CheckBox_GetState(NW_FBox_CheckBoxOf(currentBox));
|
|
4636 |
if (state == NW_TRUE)
|
|
4637 |
{
|
|
4638 |
retVal = TBrCtlDefs::EElementCheckBoxChecked;
|
|
4639 |
}
|
|
4640 |
else
|
|
4641 |
{
|
|
4642 |
retVal = TBrCtlDefs::EElementCheckBoxUnChecked;
|
|
4643 |
}
|
|
4644 |
}
|
|
4645 |
else if ( NW_Object_IsInstanceOf(currentBox, &NW_FBox_ButtonBox_Class) )
|
|
4646 |
{
|
|
4647 |
retVal = TBrCtlDefs::EElementButton;
|
|
4648 |
}
|
|
4649 |
else if ( NW_Object_IsInstanceOf(currentBox, &NW_FBox_InputBox_Class) )
|
|
4650 |
{
|
|
4651 |
if ( NW_FBox_InputBox_IsActive( currentBox ) )
|
|
4652 |
{
|
|
4653 |
retVal = TBrCtlDefs::EElementActivatedInputBox;
|
|
4654 |
}
|
|
4655 |
else
|
|
4656 |
{
|
|
4657 |
retVal = TBrCtlDefs::EElementInputBox;
|
|
4658 |
}
|
|
4659 |
}
|
|
4660 |
else if ( NW_Object_IsInstanceOf(currentBox, &NW_FBox_SelectBox_Class) )
|
|
4661 |
{
|
|
4662 |
retVal = TBrCtlDefs::EElementSelectBox;
|
|
4663 |
}
|
|
4664 |
else if ( NW_Object_IsInstanceOf(currentBox, &NW_FBox_TextAreaBox_Class) )
|
|
4665 |
{
|
|
4666 |
retVal = TBrCtlDefs::EElementTextAreaBox;
|
|
4667 |
}
|
|
4668 |
else if ( NW_Object_IsInstanceOf(currentBox, &NW_FBox_FileSelectionBox_Class) )
|
|
4669 |
{
|
|
4670 |
if ( NW_FBox_FileSelectionBox_HasContent( NW_FBox_FileSelectionBoxOf( currentBox ) ) )
|
|
4671 |
{
|
|
4672 |
retVal = TBrCtlDefs::EElementFileSelectionBoxWithContent;
|
|
4673 |
}
|
|
4674 |
else
|
|
4675 |
{
|
|
4676 |
retVal = TBrCtlDefs::EElementFileSelectionBoxNoContent;
|
|
4677 |
}
|
|
4678 |
}
|
|
4679 |
else if ( NW_Object_IsInstanceOf(currentBox, &NW_LMgr_AreaBox_Class) &&
|
|
4680 |
IsImageMapView())
|
|
4681 |
{
|
|
4682 |
retVal = TBrCtlDefs::EElementAreaBox;
|
|
4683 |
}
|
|
4684 |
|
|
4685 |
return retVal;
|
|
4686 |
}
|
|
4687 |
|
|
4688 |
//-----------------------------------------------------------------------------
|
|
4689 |
NW_Bool
|
|
4690 |
CView::InputElementEditComplete( TBool aInputConfirmed )
|
|
4691 |
{
|
|
4692 |
NW_Evt_ControlKeyEvent_t event;
|
|
4693 |
|
|
4694 |
if ( aInputConfirmed )
|
|
4695 |
{
|
|
4696 |
NW_Evt_ControlKeyEvent_Initialize(&event, NW_Evt_ControlKeyType_SoftA );
|
|
4697 |
}
|
|
4698 |
else
|
|
4699 |
{
|
|
4700 |
NW_Evt_ControlKeyEvent_Initialize(&event, NW_Evt_ControlKeyType_SoftB );
|
|
4701 |
}
|
|
4702 |
|
|
4703 |
return ProcessEvent( NW_Evt_EventOf(&event) );
|
|
4704 |
}
|
|
4705 |
|
|
4706 |
//-----------------------------------------------------------------------------
|
|
4707 |
|
|
4708 |
void
|
|
4709 |
CView::HandleNotifyString(TUint32 /*aKeyId*/, const TDesC16& /*aValue*/)
|
|
4710 |
{
|
|
4711 |
}
|
|
4712 |
|
|
4713 |
//-----------------------------------------------------------------------------
|
|
4714 |
void
|
|
4715 |
CView::DrawPictographsInText(CBitmapContext& aGc,
|
|
4716 |
const CFont& aFont,
|
|
4717 |
const TDesC& aText,
|
|
4718 |
const TPoint& aPosition)
|
|
4719 |
{
|
|
4720 |
if (iPictographInterface)
|
|
4721 |
{
|
|
4722 |
iPictographInterface->Interface()->DrawPictographsInText(aGc, aFont, aText, aPosition);
|
|
4723 |
}
|
|
4724 |
}
|
|
4725 |
|
|
4726 |
//-----------------------------------------------------------------------------
|
|
4727 |
void
|
|
4728 |
CView::DrawPictographArea()
|
|
4729 |
{
|
|
4730 |
Draw (NW_TRUE);
|
|
4731 |
}
|
|
4732 |
|
|
4733 |
//-----------------------------------------------------------------------------
|
|
4734 |
|
|
4735 |
// Any slow browser initialization can happen here
|
|
4736 |
void CView::AsyncInit()
|
|
4737 |
{
|
|
4738 |
TInt ret;
|
|
4739 |
TRAP(ret, AsyncInitL());
|
|
4740 |
}
|
|
4741 |
|
|
4742 |
// Delete entries in a given directory
|
|
4743 |
void CView::DeleteDirectoryEntriesL(RFs& aRfs, TPtrC16& aFilePath)
|
|
4744 |
{
|
|
4745 |
TInt ret = aRfs.MkDirAll(aFilePath);
|
|
4746 |
// If temp directory was already created, creating it will fail, so go ahead and empty the entries
|
|
4747 |
if (ret == KErrAlreadyExists)
|
|
4748 |
{
|
|
4749 |
CDir* dir;
|
|
4750 |
ret = aRfs.GetDir(aFilePath, KEntryAttNormal, ESortNone, dir);
|
|
4751 |
if (ret == KErrNone)
|
|
4752 |
{
|
|
4753 |
CleanupStack::PushL(dir);
|
|
4754 |
TInt entryCount = dir->Count();
|
|
4755 |
TInt i;
|
|
4756 |
TTime theTime;
|
|
4757 |
theTime.HomeTime();
|
|
4758 |
for (i = entryCount - 1; i >= 0; i--)
|
|
4759 |
{
|
|
4760 |
TEntry entry = (*dir)[i];
|
|
4761 |
if (theTime.DaysFrom(entry.iModified).Int() >= 1)
|
|
4762 |
{
|
|
4763 |
HBufC* fullFileName = HBufC::NewL(aFilePath.Length() + entry.iName.Length() + 1);
|
|
4764 |
CleanupStack::PushL(fullFileName);
|
|
4765 |
fullFileName->Des().Copy(aFilePath);
|
|
4766 |
fullFileName->Des().Append(entry.iName);
|
|
4767 |
aRfs.Delete(*fullFileName);
|
|
4768 |
CleanupStack::PopAndDestroy(); // fullFileName
|
|
4769 |
}
|
|
4770 |
}
|
|
4771 |
CleanupStack::PopAndDestroy(); // dir
|
|
4772 |
}
|
|
4773 |
}
|
|
4774 |
}
|
|
4775 |
|
|
4776 |
// Any slow browser initialization can happen here
|
|
4777 |
void CView::AsyncInitL()
|
|
4778 |
{
|
|
4779 |
#ifndef FEATURE_MEMORY_PROFILE
|
|
4780 |
TUint16* filePath = NW_Settings_GetTempFilesPath();
|
|
4781 |
if (filePath != NULL)
|
|
4782 |
{
|
|
4783 |
TPtrC filePathPtr(filePath);
|
|
4784 |
CleanupStack::PushL(filePath);
|
|
4785 |
RFs rfs;
|
|
4786 |
User::LeaveIfError(rfs.Connect());
|
|
4787 |
CleanupClosePushL(rfs);
|
|
4788 |
DeleteDirectoryEntriesL(rfs, filePathPtr);
|
|
4789 |
filePath[0] = NW_Settings_GetMMCDrive();
|
|
4790 |
DeleteDirectoryEntriesL(rfs, filePathPtr);
|
|
4791 |
CleanupStack::PopAndDestroy(2); // rfs, filePath
|
|
4792 |
}
|
|
4793 |
#endif
|
|
4794 |
|
|
4795 |
}
|
|
4796 |
|
|
4797 |
//-----------------------------------------------------------------------------
|
|
4798 |
|
|
4799 |
void
|
|
4800 |
CView::HandleActivationEvent()
|
|
4801 |
{
|
|
4802 |
NW_Evt_ActivateEvent_t activateEvent;
|
|
4803 |
|
|
4804 |
NW_Evt_ActivateEvent_Initialize(&activateEvent);
|
|
4805 |
|
|
4806 |
(void) ProcessEvent( NW_Evt_EventOf(&activateEvent) );
|
|
4807 |
(void) Draw (NW_TRUE /*DrawNow */);
|
|
4808 |
}
|
|
4809 |
|
|
4810 |
//-----------------------------------------------------------------------------
|
|
4811 |
void
|
|
4812 |
CView::GenerateAndProcessEvent(const TKimonoEventType& aEvent)
|
|
4813 |
{
|
|
4814 |
switch (aEvent)
|
|
4815 |
{
|
|
4816 |
case EKmEvAddToPhoneBook:
|
|
4817 |
{
|
|
4818 |
NW_XHTML_SaveToPhoneBkEvent_t saveToPbEvent;
|
|
4819 |
NW_XHTML_SaveToPhoneBkEvent_Initialize(&saveToPbEvent);
|
|
4820 |
(void) ProcessEvent (NW_Evt_EventOf(&saveToPbEvent));
|
|
4821 |
break;
|
|
4822 |
}
|
|
4823 |
case EKmEvMakeCall:
|
|
4824 |
{
|
|
4825 |
NW_Evt_ActivateEvent_t actEvent;
|
|
4826 |
NW_Evt_ActivateEvent_Initialize (&actEvent);
|
|
4827 |
(void) ProcessEvent (NW_Evt_EventOf(&actEvent));
|
|
4828 |
break;
|
|
4829 |
}
|
|
4830 |
case EKmEvOpenToExternalApp:
|
|
4831 |
{
|
|
4832 |
NW_Evt_OpenViewerEvent_t openViewerEvent;
|
|
4833 |
NW_Evt_OpenViewerEvent_Initialize (&openViewerEvent);
|
|
4834 |
(void) ProcessEvent (NW_Evt_EventOf(&openViewerEvent));
|
|
4835 |
break;
|
|
4836 |
}
|
|
4837 |
case EKmEvDownloadObject:
|
|
4838 |
{
|
|
4839 |
NW_Evt_OpenViewerEvent_t openViewerEvent;
|
|
4840 |
NW_Evt_OpenViewerEvent_Initialize (&openViewerEvent);
|
|
4841 |
(void) ProcessEvent (NW_Evt_EventOf(&openViewerEvent));
|
|
4842 |
break;
|
|
4843 |
}
|
|
4844 |
case EKmEvRemoveFileName:
|
|
4845 |
{
|
|
4846 |
NW_Evt_ClearFieldEvent_t clearFieldEvent;
|
|
4847 |
NW_Evt_ClearFieldEvent_Initialize (&clearFieldEvent);
|
|
4848 |
(void) ProcessEvent (NW_Evt_EventOf(&clearFieldEvent));
|
|
4849 |
break;
|
|
4850 |
}
|
|
4851 |
default:
|
|
4852 |
{
|
|
4853 |
break;
|
|
4854 |
}
|
|
4855 |
}
|
|
4856 |
}
|
|
4857 |
|
|
4858 |
// -----------------------------------------------------------------------------
|
|
4859 |
// CView::SetBrowserSettingL
|
|
4860 |
// This method takes two parameters, the setting you wish to 'set' and the value
|
|
4861 |
// you wish to change the setting to. This method will call methods off the
|
|
4862 |
// CBrowserSettings class which will change the cached preferences and if we are
|
|
4863 |
// a stand-alone browser instance, it will persist the setting by writing the new
|
|
4864 |
// value to the browser's ini file. If any other action needs to take place as
|
|
4865 |
// a result of the setting change, that code should be placed here.
|
|
4866 |
// -----------------------------------------------------------------------------
|
|
4867 |
void CView::SetBrowserSettingL(TUint aSetting, TUint value)
|
|
4868 |
{
|
|
4869 |
switch (aSetting)
|
|
4870 |
{
|
|
4871 |
case TBrCtlDefs::ESettingsSmallScreen:
|
|
4872 |
{
|
|
4873 |
NW_Settings_SetVerticalLayoutEnabled((NW_Bool)value);
|
|
4874 |
SwitchVerticalLayout();
|
|
4875 |
|
|
4876 |
break;
|
|
4877 |
}
|
|
4878 |
case TBrCtlDefs::ESettingsAutoLoadImages:
|
|
4879 |
{
|
|
4880 |
NW_Settings_SetImagesEnabled((NW_Bool)value);
|
|
4881 |
|
|
4882 |
break;
|
|
4883 |
}
|
|
4884 |
case TBrCtlDefs::ESettingsFontSize:
|
|
4885 |
{
|
|
4886 |
NW_Settings_SetFontSizeLevel((NW_Uint8)value);
|
|
4887 |
|
|
4888 |
NW_Evt_FontSizeChangeEvent_t fontSizeChangeEvent;
|
|
4889 |
NW_Evt_FontSizeChangeEvent_Initialize (&fontSizeChangeEvent, (NW_Evt_FontSizeChangeEvent_FontLevel_t)value);
|
|
4890 |
(void) ProcessEvent (NW_Evt_EventOf(&fontSizeChangeEvent));
|
|
4891 |
|
|
4892 |
break;
|
|
4893 |
}
|
|
4894 |
case TBrCtlDefs::ESettingsTextWrapEnabled:
|
|
4895 |
{
|
|
4896 |
NW_Settings_SetTextWrapEnabled((NW_Bool)value);
|
|
4897 |
|
|
4898 |
NW_GDI_Point2D_t origin;
|
|
4899 |
Relayout (NW_FALSE);
|
|
4900 |
origin = *(iDeviceContext->Origin());
|
|
4901 |
SetOrigin (&origin);
|
|
4902 |
(void) Draw (NW_TRUE /*DrawNow */);
|
|
4903 |
|
|
4904 |
break;
|
|
4905 |
}
|
|
4906 |
case TBrCtlDefs::ESettingsCookiesEnabled:
|
|
4907 |
{
|
|
4908 |
NW_Settings_SetCookiesEnabled((NW_Bool)value);
|
|
4909 |
|
|
4910 |
//UrlLoader_ChangeFilterLoadStatusL(ECookieFilter, (NW_Bool)value);
|
|
4911 |
|
|
4912 |
break;
|
|
4913 |
}
|
|
4914 |
case TBrCtlDefs::ESettingsEmbedded:
|
|
4915 |
{
|
|
4916 |
NW_Settings_SetIsBrowserEmbedded((NW_Bool)value);
|
|
4917 |
|
|
4918 |
break;
|
|
4919 |
}
|
|
4920 |
case TBrCtlDefs::ESettingsCSSFetchEnabled:
|
|
4921 |
{
|
|
4922 |
NW_Settings_SetCSSFetchEnabled((NW_Bool)value);
|
|
4923 |
|
|
4924 |
break;
|
|
4925 |
}
|
|
4926 |
case TBrCtlDefs::ESettingsECMAScriptEnabled:
|
|
4927 |
{
|
|
4928 |
NW_Settings_SetEcmaScriptEnabled((NW_Bool)value);
|
|
4929 |
|
|
4930 |
break;
|
|
4931 |
}
|
|
4932 |
case TBrCtlDefs::ESettingsIMEINotifyEnabled:
|
|
4933 |
{
|
|
4934 |
NW_Settings_SetIMEINotifyEnabled((NW_Bool)value);
|
|
4935 |
|
|
4936 |
break;
|
|
4937 |
}
|
|
4938 |
case TBrCtlDefs::ESettingsSendRefererHeader:
|
|
4939 |
{
|
|
4940 |
NW_Settings_SetSendReferrerHeader((NW_Bool)value);
|
|
4941 |
|
|
4942 |
break;
|
|
4943 |
}
|
|
4944 |
case TBrCtlDefs::ESettingsCharacterset:
|
|
4945 |
{
|
|
4946 |
// value is the UID of the charset converter. We don't save it in the settings
|
|
4947 |
iShell->CharacterSetChangedL(value);
|
|
4948 |
TUint16 internalEncoding = EAutomatic;
|
|
4949 |
TInt i;
|
|
4950 |
for (i = 0; supportedCharset[i].uid != 0; i++)
|
|
4951 |
{
|
|
4952 |
if (supportedCharset[i].uid == value)
|
|
4953 |
{
|
|
4954 |
internalEncoding = supportedCharset[i].internalEncoding;
|
|
4955 |
break;
|
|
4956 |
}
|
|
4957 |
}
|
|
4958 |
NW_Settings_SetEncoding(internalEncoding);
|
|
4959 |
break;
|
|
4960 |
}
|
|
4961 |
case TBrCtlDefs::ESettingsSecurityWarnings:
|
|
4962 |
{
|
|
4963 |
NW_Settings_SetHttpSecurityWarnings((NW_Bool)value);
|
|
4964 |
|
|
4965 |
break;
|
|
4966 |
}
|
|
4967 |
case TBrCtlDefs::ESettingsApId:
|
|
4968 |
{
|
|
4969 |
NW_Settings_SetIAPId(value);
|
|
4970 |
//UrlLoader_SetIAPid(value);
|
|
4971 |
|
|
4972 |
break;
|
|
4973 |
}
|
|
4974 |
default:
|
|
4975 |
{
|
|
4976 |
// OK - some settings not of interest to us here
|
|
4977 |
break;
|
|
4978 |
}
|
|
4979 |
}
|
|
4980 |
}
|
|
4981 |
|
|
4982 |
// -----------------------------------------------------------------------------
|
|
4983 |
// CView::GetBrowserSettingL
|
|
4984 |
// This method takes one parameter and that is the setting you wish to retrieve
|
|
4985 |
// the value of. GetBrowserSettingL will then call methods off the CBrowserSettings
|
|
4986 |
// class to return the current value of the setting.
|
|
4987 |
// -----------------------------------------------------------------------------
|
|
4988 |
TUint CView::GetBrowserSettingL(TUint aSetting) const
|
|
4989 |
{
|
|
4990 |
TUint returnValue = 0;
|
|
4991 |
|
|
4992 |
switch (aSetting)
|
|
4993 |
{
|
|
4994 |
case TBrCtlDefs::ESettingsSmallScreen:
|
|
4995 |
returnValue = (TUint)NW_Settings_GetVerticalLayoutEnabled();
|
|
4996 |
break;
|
|
4997 |
|
|
4998 |
case TBrCtlDefs::ESettingsAutoLoadImages:
|
|
4999 |
returnValue = (TUint)NW_Settings_GetImagesEnabled();
|
|
5000 |
break;
|
|
5001 |
|
|
5002 |
case TBrCtlDefs::ESettingsFontSize:
|
|
5003 |
returnValue = (TUint)NW_Settings_GetFontSizeLevel();
|
|
5004 |
break;
|
|
5005 |
|
|
5006 |
case TBrCtlDefs::ESettingsTextWrapEnabled:
|
|
5007 |
returnValue = (TUint)NW_Settings_GetTextWrapEnabled();
|
|
5008 |
break;
|
|
5009 |
|
|
5010 |
case TBrCtlDefs::ESettingsCookiesEnabled:
|
|
5011 |
returnValue = (TUint)NW_Settings_GetCookiesEnabled();
|
|
5012 |
break;
|
|
5013 |
|
|
5014 |
case TBrCtlDefs::ESettingsEmbedded:
|
|
5015 |
returnValue = (TUint)CBrowserSettings::Instance()->GetIsBrowserEmbedded();
|
|
5016 |
break;
|
|
5017 |
|
|
5018 |
case TBrCtlDefs::ESettingsCSSFetchEnabled:
|
|
5019 |
returnValue = (TUint)NW_Settings_GetCSSFetchEnabled();
|
|
5020 |
break;
|
|
5021 |
|
|
5022 |
case TBrCtlDefs::ESettingsECMAScriptEnabled:
|
|
5023 |
returnValue = (TUint)NW_Settings_GetEcmaScriptEnabled();
|
|
5024 |
break;
|
|
5025 |
|
|
5026 |
case TBrCtlDefs::ESettingsIMEINotifyEnabled:
|
|
5027 |
returnValue = (TUint)NW_Settings_GetIMEINotifyEnabled();
|
|
5028 |
break;
|
|
5029 |
|
|
5030 |
case TBrCtlDefs::ESettingsSendRefererHeader:
|
|
5031 |
returnValue = (TUint)NW_Settings_GetSendReferrerHeader();
|
|
5032 |
break;
|
|
5033 |
|
|
5034 |
case TBrCtlDefs::ESettingsSecurityWarnings:
|
|
5035 |
returnValue = (TUint)NW_Settings_GetHttpSecurityWarnings();
|
|
5036 |
break;
|
|
5037 |
|
|
5038 |
case TBrCtlDefs::ESettingsApId:
|
|
5039 |
returnValue = (TUint)NW_Settings_GetIAPId();
|
|
5040 |
break;
|
|
5041 |
|
|
5042 |
default:
|
|
5043 |
// if the user has not specified one of the above settings, then we
|
|
5044 |
// need to leave
|
|
5045 |
User::Leave(KErrArgument);
|
|
5046 |
break;
|
|
5047 |
}
|
|
5048 |
|
|
5049 |
return returnValue;
|
|
5050 |
}
|
|
5051 |
|
|
5052 |
//-----------------------------------------------------------------------------
|
|
5053 |
void CView::BrowserSettingChanged( enum TBrowserSetting aBrowserSetting )
|
|
5054 |
{
|
|
5055 |
// let the rootbox know about it
|
|
5056 |
if ( iRootBox )
|
|
5057 |
{
|
|
5058 |
switch ( aBrowserSetting )
|
|
5059 |
{
|
|
5060 |
case EVerticalLayoutEnabled:
|
|
5061 |
case EDisableSmallScreenLayout:
|
|
5062 |
{
|
|
5063 |
NW_LMgr_RootBox_SetSmallScreenOn( iRootBox, NW_Settings_GetVerticalLayoutEnabled() );
|
|
5064 |
break;
|
|
5065 |
}
|
|
5066 |
case ETextWrapEnabled:
|
|
5067 |
{
|
|
5068 |
NW_LMgr_RootBox_SetWrapEnabled( iRootBox, NW_Settings_GetTextWrapEnabled() );
|
|
5069 |
break;
|
|
5070 |
}
|
|
5071 |
default:
|
|
5072 |
{
|
|
5073 |
// no default implementation
|
|
5074 |
break;
|
|
5075 |
}
|
|
5076 |
}
|
|
5077 |
}
|
|
5078 |
}
|
|
5079 |
|
|
5080 |
//-----------------------------------------------------------------------------
|
|
5081 |
CArrayFixFlat<TBrCtlImageCarrier>*
|
|
5082 |
CView::GetPageImagesL()
|
|
5083 |
{
|
|
5084 |
NW_ADT_DynamicVector_t* images = (NW_ADT_DynamicVector_t*)
|
|
5085 |
NW_ADT_ResizableVector_New(sizeof(NW_HED_ViewImageList_Entry_t), 10, 5 );
|
|
5086 |
|
|
5087 |
if (images == NULL)
|
|
5088 |
{
|
|
5089 |
User::LeaveNoMemory();
|
|
5090 |
}
|
|
5091 |
|
|
5092 |
// NW_HED_ViewImageList_Entry_t
|
|
5093 |
NW_HED_DocumentRoot_t* root = iShell->GetDocumentRoot();
|
|
5094 |
NW_ASSERT(root != NULL);
|
|
5095 |
|
|
5096 |
// Since we're not checking status, status shows up as an unused variable
|
|
5097 |
// warning. Removed declaration of status until CCC decides to actually
|
|
5098 |
// use it.
|
|
5099 |
if (IsImageMapView())
|
|
5100 |
{
|
|
5101 |
GetViewImageList(images);
|
|
5102 |
}
|
|
5103 |
else
|
|
5104 |
{
|
|
5105 |
NW_HED_DocumentRoot_GetViewImageList(root, images);
|
|
5106 |
}
|
|
5107 |
|
|
5108 |
CArrayFixFlat<TBrCtlImageCarrier>* array = new(ELeave) CArrayFixFlat<TBrCtlImageCarrier>(5);
|
|
5109 |
CleanupStack::PushL(array);
|
|
5110 |
|
|
5111 |
NW_ADT_Vector_Metric_t i;
|
|
5112 |
NW_ADT_Vector_Metric_t size = NW_ADT_Vector_GetSize(images);
|
|
5113 |
|
|
5114 |
for (i = 0; i < size; i++)
|
|
5115 |
{
|
|
5116 |
NW_HED_ViewImageList_Entry_t* entry =
|
|
5117 |
(NW_HED_ViewImageList_Entry_t*)NW_ADT_Vector_ElementAt(images, i);
|
|
5118 |
|
|
5119 |
TPtrC8 rawData( entry->rawData, entry->rawDataLen );
|
|
5120 |
|
|
5121 |
TPtrC url( NULL, 0 );
|
|
5122 |
if (entry->url != NULL)
|
|
5123 |
{
|
|
5124 |
url.Set( entry->url );
|
|
5125 |
}
|
|
5126 |
|
|
5127 |
TPtrC altText( NULL, 0 );
|
|
5128 |
if (entry->altText != NULL)
|
|
5129 |
{
|
|
5130 |
altText.Set( entry->altText );
|
|
5131 |
}
|
|
5132 |
|
|
5133 |
TBrCtlImageType type = EImageTypeAny;
|
|
5134 |
|
|
5135 |
switch (entry->imageType)
|
|
5136 |
{
|
|
5137 |
case ERecognizedImage:
|
|
5138 |
case EUnsupportedImage:
|
|
5139 |
type = EImageTypeAny;
|
|
5140 |
break;
|
|
5141 |
case EWbmpImage:
|
|
5142 |
type = EImageTypeWbmp;
|
|
5143 |
break;
|
|
5144 |
case EOtaImage:
|
|
5145 |
type = EImageTypeOta;
|
|
5146 |
break;
|
|
5147 |
default:
|
|
5148 |
break;
|
|
5149 |
}
|
|
5150 |
|
|
5151 |
TPtrC contentType( NULL, 0 );
|
|
5152 |
if(entry->contentType != NULL)
|
|
5153 |
{
|
|
5154 |
contentType.Set(entry->contentType);
|
|
5155 |
}
|
|
5156 |
TBrCtlImageCarrier carrier (rawData, url, altText, type, contentType);
|
|
5157 |
array->AppendL(carrier);
|
|
5158 |
}
|
|
5159 |
|
|
5160 |
CleanupStack::Pop(); // array
|
|
5161 |
NW_Object_Delete(images);
|
|
5162 |
|
|
5163 |
return array;
|
|
5164 |
}
|
|
5165 |
|
|
5166 |
//-----------------------------------------------------------------------------
|
|
5167 |
// UpdateScrollBarsL
|
|
5168 |
//
|
|
5169 |
// If the BrCtl supports scrollBars (ECapabilityDisplayScrollBar) we display
|
|
5170 |
// and handle the scrollBars within the BrowserEngine and inform the
|
|
5171 |
// BrCtlLayoutObserver listener. If the BrCtrl doesn't support scrollBars, we
|
|
5172 |
// only inform the BrCtlLayoutObserver listener that a scroll event occurred.
|
|
5173 |
//-----------------------------------------------------------------------------
|
|
5174 |
void
|
|
5175 |
CView::UpdateScrollBarsL(CEikScrollBar::TOrientation aOrientation,
|
|
5176 |
const TInt aThumbPos,
|
|
5177 |
const TInt aScrollSpan )
|
|
5178 |
{
|
|
5179 |
TInt document = aScrollSpan; // Span of the web page
|
|
5180 |
TInt display = 0; // Span of the display
|
|
5181 |
TInt displayPos = aThumbPos; // Position of the display within the web page
|
|
5182 |
|
|
5183 |
// Set layout
|
|
5184 |
NW_LMgr_RootBox_t* rootBox;
|
|
5185 |
rootBox = iRootBox;
|
|
5186 |
|
|
5187 |
// Get the BrCtl scrolling provider, if we have it. Can be NULL, if
|
|
5188 |
// then the parent app is providing the scrolling, supported through the
|
|
5189 |
// BrCtlLayoutObserver events.
|
|
5190 |
/* ScrollingProvider* brCtlScrolling = iBrCtl->scrollingProvider();
|
|
5191 |
*/
|
|
5192 |
// Page direction
|
|
5193 |
if ( NW_LMgr_RootBox_IsPageRTL( rootBox ) )
|
|
5194 |
{
|
|
5195 |
// Right to left page
|
|
5196 |
/* if (brCtlScrolling)
|
|
5197 |
{
|
|
5198 |
// iWmlControl->WKWmlInterface()->WKScrollingProviderNotifyLayoutChange(EOriginTopRight);
|
|
5199 |
}
|
|
5200 |
*/ iBrCtl->brCtlLayoutObserver()->NotifyLayoutChange( EOriginTopRight );
|
|
5201 |
}
|
|
5202 |
else
|
|
5203 |
{
|
|
5204 |
// Left to right page
|
|
5205 |
/* if (brCtlScrolling)
|
|
5206 |
{
|
|
5207 |
// iWmlControl->WKWmlInterface()->WKScrollingProviderNotifyLayoutChange(EOriginTopLeft);
|
|
5208 |
}
|
|
5209 |
*/ iBrCtl->brCtlLayoutObserver()->NotifyLayoutChange( EOriginTopLeft );
|
|
5210 |
}
|
|
5211 |
|
|
5212 |
// Page orientation
|
|
5213 |
if ( aOrientation == CEikScrollBar::EHorizontal )
|
|
5214 |
{
|
|
5215 |
// Horizontal scrollbar
|
|
5216 |
display = Rect().Width();
|
|
5217 |
|
|
5218 |
// Small (Narrow) Screen Mode
|
|
5219 |
if ( NW_LMgr_RootBox_GetSmallScreenOn( iRootBox ) )
|
|
5220 |
{
|
|
5221 |
document = display;
|
|
5222 |
}
|
|
5223 |
|
|
5224 |
/* if (brCtlScrolling)
|
|
5225 |
{
|
|
5226 |
// iWmlControl->WKWmlInterface()->WKSetScrollingProviderUpdateHScrollBarL(document, display, displayPos);
|
|
5227 |
}
|
|
5228 |
*/ iBrCtl->brCtlLayoutObserver()->UpdateBrowserHScrollBarL(document, display, displayPos );
|
|
5229 |
}
|
|
5230 |
else
|
|
5231 |
{
|
|
5232 |
// Vertical scrollbar
|
|
5233 |
display = Rect().Height();
|
|
5234 |
/* if (brCtlScrolling)
|
|
5235 |
{
|
|
5236 |
// iWmlControl->WKWmlInterface()->WKSetScrollingProviderUpdateVScrollBarL(document, display, displayPos);
|
|
5237 |
}
|
|
5238 |
*/ iBrCtl->brCtlLayoutObserver()->UpdateBrowserVScrollBarL(document, display, displayPos );
|
|
5239 |
}
|
|
5240 |
}
|
|
5241 |
|
|
5242 |
//-----------------------------------------------------------------------------
|
|
5243 |
TInt
|
|
5244 |
CView::CountComponentControls() const
|
|
5245 |
{
|
|
5246 |
TInt componentControls = 0;
|
|
5247 |
|
|
5248 |
// If there's an active input element on the screen - draw it
|
|
5249 |
// because of T9 underline
|
|
5250 |
NW_LMgr_Box_t* currentBox = iCurrentBox;
|
|
5251 |
|
|
5252 |
if (NW_Object_IsInstanceOf(currentBox, &NW_FBox_InputBox_Class) &&
|
|
5253 |
NW_FBox_InputBox_IsActive( currentBox ))
|
|
5254 |
{
|
|
5255 |
NW_FBox_FormBox_t* formBox = NW_FBox_FormBoxOf(currentBox);
|
|
5256 |
|
|
5257 |
NW_FBox_Epoc32InputSkin_t* inputSkin = (NW_FBox_Epoc32InputSkin_t*) NW_FBox_FormBox_GetSkin(formBox);
|
|
5258 |
|
|
5259 |
CCoeControl* inputElement = (CCoeControl*)inputSkin->cppEpoc32InputBox;
|
|
5260 |
if (inputElement)
|
|
5261 |
{
|
|
5262 |
componentControls++;
|
|
5263 |
}
|
|
5264 |
}
|
|
5265 |
|
|
5266 |
return componentControls;
|
|
5267 |
}
|
|
5268 |
|
|
5269 |
//-----------------------------------------------------------------------------
|
|
5270 |
CCoeControl*
|
|
5271 |
CView::ComponentControl(TInt /*aIndex*/) const
|
|
5272 |
{
|
|
5273 |
NW_LMgr_Box_t* currentBox = iCurrentBox;
|
|
5274 |
|
|
5275 |
if (NW_Object_IsInstanceOf(currentBox, &NW_FBox_InputBox_Class) &&
|
|
5276 |
NW_FBox_InputBox_IsActive( currentBox ))
|
|
5277 |
{
|
|
5278 |
NW_FBox_FormBox_t* formBox = NW_FBox_FormBoxOf(currentBox);
|
|
5279 |
|
|
5280 |
NW_FBox_Epoc32InputSkin_t* inputSkin = (NW_FBox_Epoc32InputSkin_t*) NW_FBox_FormBox_GetSkin(formBox);
|
|
5281 |
|
|
5282 |
CCoeControl* inputElement = (CCoeControl*)inputSkin->cppEpoc32InputBox;
|
|
5283 |
if (inputElement)
|
|
5284 |
{
|
|
5285 |
return inputElement;
|
|
5286 |
}
|
|
5287 |
}
|
|
5288 |
|
|
5289 |
return NULL;
|
|
5290 |
}
|
|
5291 |
|
|
5292 |
//-----------------------------------------------------------------------------
|
|
5293 |
void
|
|
5294 |
CView::CreateOffscreenBitmapL( const TRect& aRect )
|
|
5295 |
{
|
|
5296 |
delete iBitmapContext;
|
|
5297 |
iBitmapContext = NULL;
|
|
5298 |
delete iBitmapDevice;
|
|
5299 |
iBitmapDevice = NULL;
|
|
5300 |
delete iOffscreenBitmap;
|
|
5301 |
iOffscreenBitmap = NULL;
|
|
5302 |
|
|
5303 |
// create a bitmap to be used offscreen
|
|
5304 |
iOffscreenBitmap = new (ELeave) CFbsBitmap();
|
|
5305 |
User::LeaveIfError( iOffscreenBitmap->Create( TSize( aRect.Width(), aRect.Height() ), EColor4K ) );
|
|
5306 |
|
|
5307 |
// create and offscreen device and context
|
|
5308 |
iBitmapDevice = CFbsBitmapDevice::NewL( iOffscreenBitmap );
|
|
5309 |
User::LeaveIfError( iBitmapDevice->CreateBitmapContext( iBitmapContext ) );
|
|
5310 |
}
|
|
5311 |
|
|
5312 |
//-----------------------------------------------------------------------------
|
|
5313 |
void
|
|
5314 |
CView::HandleResourceChange(TInt aType)
|
|
5315 |
{
|
|
5316 |
if (aType == KEikMessageColorSchemeChange)
|
|
5317 |
{
|
|
5318 |
(void) Draw (NW_TRUE /*DrawNow */);
|
|
5319 |
DrawNow();
|
|
5320 |
}
|
|
5321 |
}
|
|
5322 |
|
|
5323 |
|
|
5324 |
//-----------------------------------------------------------------------------
|
|
5325 |
// Return the number of active elements in the page
|
|
5326 |
// This is used by the UI to decide if to display CANCEL on the right softkey
|
|
5327 |
// when an object is activated
|
|
5328 |
//-----------------------------------------------------------------------------
|
|
5329 |
TUint
|
|
5330 |
CView::GetActiveElements()
|
|
5331 |
{
|
|
5332 |
return iTabList->size;
|
|
5333 |
}
|
|
5334 |
|
|
5335 |
// -------------------------------------------------------------------------
|
|
5336 |
// CView::GetViewImageList
|
|
5337 |
// -------------------------------------------------------------------------
|
|
5338 |
void
|
|
5339 |
CView::GetViewImageList(void* aDynamicVector)
|
|
5340 |
{
|
|
5341 |
NW_LMgr_ImageMapBox_t* imageMapBox = NULL;
|
|
5342 |
NW_Image_Epoc32Simple_t* image = NULL;
|
|
5343 |
NW_Image_Virtual_t* virtualImage = NULL;
|
|
5344 |
NW_HED_ViewImageList_Entry_t* entry = NULL;
|
|
5345 |
NW_ADT_DynamicVector_t* dynamicVector = NULL;
|
|
5346 |
NW_LMgr_RootBox_t* rootBox = NULL;
|
|
5347 |
NW_LMgr_Box_t* currentBox = NULL;
|
|
5348 |
|
|
5349 |
dynamicVector = (NW_ADT_DynamicVector_t*)aDynamicVector;
|
|
5350 |
rootBox = iRootBox;
|
|
5351 |
NW_ASSERT(rootBox);
|
|
5352 |
|
|
5353 |
currentBox = rootBox->focusBox;
|
|
5354 |
|
|
5355 |
// in this case the current box should be an area box
|
|
5356 |
if (currentBox && NW_Object_IsClass(currentBox, &NW_LMgr_ImageMapBox_Class))
|
|
5357 |
{
|
|
5358 |
imageMapBox = NW_LMgr_ImageMapBoxOf(currentBox);
|
|
5359 |
NW_ASSERT(imageMapBox);
|
|
5360 |
|
|
5361 |
virtualImage = (NW_Image_Virtual_t*)imageMapBox->super.super.virtualImage;
|
|
5362 |
NW_ASSERT(virtualImage);
|
|
5363 |
|
|
5364 |
image = NW_Image_Epoc32SimpleOf (virtualImage->image);
|
|
5365 |
|
|
5366 |
/* Save the text object in the dynamicVector */
|
|
5367 |
entry = (NW_HED_ViewImageList_Entry_t*)NW_ADT_DynamicVector_InsertAt(dynamicVector, NULL,
|
|
5368 |
NW_ADT_Vector_AtEnd);
|
|
5369 |
if (entry)
|
|
5370 |
{
|
|
5371 |
entry->rawData = (NW_Byte*)image->rawData;
|
|
5372 |
entry->rawDataLen = image->rawDataLength;
|
|
5373 |
entry->imageType = image->imageType;
|
|
5374 |
|
|
5375 |
if (imageMapBox->iUrl)
|
|
5376 |
{
|
|
5377 |
entry->url = (NW_Ucs2*)imageMapBox->iUrl->storage;
|
|
5378 |
}
|
|
5379 |
else
|
|
5380 |
{
|
|
5381 |
entry->url = NULL;
|
|
5382 |
}
|
|
5383 |
|
|
5384 |
if (imageMapBox->super.super.altText)
|
|
5385 |
{
|
|
5386 |
entry->altText = (NW_Ucs2*)imageMapBox->super.super.altText->storage;
|
|
5387 |
}
|
|
5388 |
else
|
|
5389 |
{
|
|
5390 |
entry->altText = NULL;
|
|
5391 |
}
|
|
5392 |
}
|
|
5393 |
}
|
|
5394 |
}
|
|
5395 |
|
|
5396 |
NW_Bool
|
|
5397 |
|
|
5398 |
CView::IsZeroBox (const NW_LMgr_Box_t* box) const
|
|
5399 |
|
|
5400 |
{
|
|
5401 |
NW_GDI_Rectangle_t boxBounds;
|
|
5402 |
|
|
5403 |
/* parameter assertion block */
|
|
5404 |
NW_ASSERT (box != NULL);
|
|
5405 |
|
|
5406 |
CView* view = const_cast<CView*>(this);
|
|
5407 |
boxBounds = view->GetBoxDisplayBounds(NW_LMgr_BoxOf(box));
|
|
5408 |
|
|
5409 |
if ((boxBounds.point.y == 0) &&
|
|
5410 |
(boxBounds.point.x == 0) &&
|
|
5411 |
|
|
5412 |
(boxBounds.dimension.height == 0) &&
|
|
5413 |
(boxBounds.dimension.height == 0))
|
|
5414 |
{
|
|
5415 |
NW_LOG0(NW_LOG_LEVEL4, "[CView::IsZeroBox Error! (0.0; 0x0) box in the iTabList]");
|
|
5416 |
|
|
5417 |
return NW_TRUE;
|
|
5418 |
|
|
5419 |
}
|
|
5420 |
return NW_FALSE;
|
|
5421 |
}
|
|
5422 |
|
|
5423 |
//-------------------------------------------------------------------------------
|
|
5424 |
// DrawDocumentPart ( from MPageScalerCallback )
|
|
5425 |
//
|
|
5426 |
//
|
|
5427 |
//-------------------------------------------------------------------------------
|
|
5428 |
void CView::DrawDocumentPart(
|
|
5429 |
CFbsBitGc& aGc,
|
|
5430 |
CFbsBitmap* /*aBitmap*/,
|
|
5431 |
const TRect& aDocumentAreaToDraw )
|
|
5432 |
{
|
|
5433 |
TRect drawRect( aDocumentAreaToDraw ) ;
|
|
5434 |
DrawHistory( aGc, drawRect );
|
|
5435 |
}
|
|
5436 |
|
|
5437 |
//-------------------------------------------------------------------------------
|
|
5438 |
// DocumentViewport ( from MPageScalerCallback )
|
|
5439 |
//
|
|
5440 |
//
|
|
5441 |
//-------------------------------------------------------------------------------
|
|
5442 |
TRect CView::DocumentViewport()
|
|
5443 |
{
|
|
5444 |
return Rect();
|
|
5445 |
}
|
|
5446 |
|
|
5447 |
//-------------------------------------------------------------------------------
|
|
5448 |
// ScaledPageChanged ( from MPageScalerCallback )
|
|
5449 |
//
|
|
5450 |
//
|
|
5451 |
//-------------------------------------------------------------------------------
|
|
5452 |
void CView::ScaledPageChanged(
|
|
5453 |
const TRect& /*aRect*/,
|
|
5454 |
TBool aFullScreen,
|
|
5455 |
TBool aScroll )
|
|
5456 |
{
|
|
5457 |
HistoryControllerInterface* historyController = &( iWmlControl->HistoryController() );
|
|
5458 |
if ( historyController->historyViewEnabled() && iDocumentFinished && !aScroll && aFullScreen)
|
|
5459 |
{
|
|
5460 |
// update the history with new bitmap
|
|
5461 |
CFbsBitmap* scaledPage = iPageScaler->ScaledPage();
|
|
5462 |
if(scaledPage)
|
|
5463 |
{
|
|
5464 |
// Get the browser control rect
|
|
5465 |
TRAP_IGNORE( iWmlControl->HistoryController().updateHistoryEntryThumbnailL(scaledPage));
|
|
5466 |
// ignore err since we will use the default image
|
|
5467 |
}
|
|
5468 |
|
|
5469 |
}
|
|
5470 |
}
|
|
5471 |
|
|
5472 |
//-------------------------------------------------------------------------------
|
|
5473 |
// DocumentSize ( from MPageScalerCallback )
|
|
5474 |
//
|
|
5475 |
//
|
|
5476 |
//-------------------------------------------------------------------------------
|
|
5477 |
TSize CView::DocumentSize()
|
|
5478 |
{
|
|
5479 |
TSize contentSize;
|
|
5480 |
ContentSize( contentSize );
|
|
5481 |
return contentSize;
|
|
5482 |
}
|
|
5483 |
|
|
5484 |
|
|
5485 |
//-------------------------------------------------------------------------------
|
|
5486 |
// InitializePageScalerL
|
|
5487 |
//
|
|
5488 |
//-------------------------------------------------------------------------------
|
|
5489 |
void CView::InitializePageScalerL()
|
|
5490 |
{
|
|
5491 |
TBool lowQuality = !( iBrCtl->capabilities() & TBrCtlDefs::ECapabilityGraphicalHistory );
|
|
5492 |
iPageScaler = CPageScaler::NewL( *this, EColor64K, lowQuality );
|
|
5493 |
iPageScaler->SetVisible( EFalse );
|
|
5494 |
iBrCtl->setWmlPageScaler( *iPageScaler );
|
|
5495 |
}
|
|
5496 |
|
|
5497 |
|
|
5498 |
//-------------------------------------------------------------------------------
|
|
5499 |
// DrawPositionedBoxes
|
|
5500 |
//
|
|
5501 |
//-------------------------------------------------------------------------------
|
|
5502 |
TBrowserStatusCode CView::DrawPositionedBoxes()
|
|
5503 |
{
|
|
5504 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
5505 |
if (!iRootBox->iPositionedBoxesPlaced)
|
|
5506 |
return status;
|
|
5507 |
NW_ADT_DynamicVector_t *positionedObjects = iRootBox->positionedAbsObjects;
|
|
5508 |
TInt count = NW_ADT_Vector_GetSize(positionedObjects);
|
|
5509 |
TUint16 index;
|
|
5510 |
NW_LMgr_Box_t* positionedBox;
|
|
5511 |
for (index = 0; index < count; index++)
|
|
5512 |
{
|
|
5513 |
positionedBox = *(NW_LMgr_Box_t**) NW_ADT_Vector_ElementAt (positionedObjects, index);
|
|
5514 |
Refresh(positionedBox);
|
|
5515 |
}
|
|
5516 |
return status;
|
|
5517 |
}
|
|
5518 |
|
|
5519 |
NW_Bool CView::FormatPositionedBoxes ()
|
|
5520 |
{
|
|
5521 |
|
|
5522 |
NW_LMgr_Box_t *positionedBox;
|
|
5523 |
NW_LMgr_PosFlowBox_t* tempPositionedBox;
|
|
5524 |
NW_ADT_DynamicVector_t *positionedObjects = iRootBox->positionedAbsObjects;
|
|
5525 |
// Place the positioned boxes only once
|
|
5526 |
if (iRootBox->iPositionedBoxesPlaced)
|
|
5527 |
return NW_FALSE;
|
|
5528 |
|
|
5529 |
//handle positioned boxes
|
|
5530 |
NW_ADT_Vector_Metric_t posCount, index;
|
|
5531 |
posCount = NW_ADT_Vector_GetSize(positionedObjects);
|
|
5532 |
for (index = 0; index < NW_ADT_Vector_GetSize(positionedObjects); index++)
|
|
5533 |
{
|
|
5534 |
positionedBox = *(NW_LMgr_Box_t**) NW_ADT_Vector_ElementAt (positionedObjects, index);
|
|
5535 |
if (!NW_Object_IsInstanceOf(positionedBox, &NW_LMgr_PosFlowBox_Class))
|
|
5536 |
{
|
|
5537 |
NW_ASSERT(0); // should never happen
|
|
5538 |
break;
|
|
5539 |
}
|
|
5540 |
ReformatBox(positionedBox);
|
|
5541 |
tempPositionedBox = (NW_LMgr_PosFlowBox_t*)positionedBox;
|
|
5542 |
if( (tempPositionedBox != NULL) &&
|
|
5543 |
(NW_Object_IsInstanceOf(tempPositionedBox, &NW_LMgr_PosFlowBox_Class) ) &&
|
|
5544 |
(tempPositionedBox->iContainingBlock != NULL) &&
|
|
5545 |
NW_Object_IsInstanceOf(tempPositionedBox->iContainingBlock, &NW_LMgr_Box_Class) )
|
|
5546 |
{
|
|
5547 |
|
|
5548 |
NW_LMgr_PosFlowBox_HandlePostFormat((NW_LMgr_PosFlowBox_t*)positionedBox);
|
|
5549 |
}
|
|
5550 |
}
|
|
5551 |
iRootBox->iPositionedBoxesPlaced = NW_TRUE;
|
|
5552 |
return (posCount > 0);
|
|
5553 |
|
|
5554 |
//return TRUE;
|
|
5555 |
}
|
|
5556 |
|
|
5557 |
void CView::ScrollTo(TPoint aPoint)
|
|
5558 |
{
|
|
5559 |
NW_GDI_Point2D_t origin;
|
|
5560 |
origin.x = aPoint.iX;
|
|
5561 |
origin.y = aPoint.iY;
|
|
5562 |
if (iCurrentBox && NW_Object_IsInstanceOf(iCurrentBox, &NW_FBox_InputBox_Class) &&
|
|
5563 |
NW_FBox_InputBox_IsActive( iCurrentBox ))
|
|
5564 |
{
|
|
5565 |
if (!InputElementEditComplete( NW_TRUE ))
|
|
5566 |
{
|
|
5567 |
return;
|
|
5568 |
}
|
|
5569 |
}
|
|
5570 |
TBool scrollDown = aPoint.iY > iDeviceContext->Origin()->y;
|
|
5571 |
SetOrigin(&origin);
|
|
5572 |
GetDeviceContext()->SetOrigin(&origin);
|
|
5573 |
// Is box still visible?
|
|
5574 |
TRect rect(0, 0, 0, 0);
|
|
5575 |
NW_GDI_Rectangle_t displayBounds;
|
|
5576 |
displayBounds = *(iDeviceContext->DisplayBounds());
|
|
5577 |
displayBounds.point = *(iDeviceContext->Origin());
|
|
5578 |
if (!iCurrentBox || !IsBoxVisible(iCurrentBox, &displayBounds))
|
|
5579 |
{
|
|
5580 |
NW_LMgr_Box_t* box;
|
|
5581 |
if (scrollDown)
|
|
5582 |
{
|
|
5583 |
box = GetVisibleBox();
|
|
5584 |
}
|
|
5585 |
else
|
|
5586 |
{
|
|
5587 |
box = GetVisibleBoxReverse();
|
|
5588 |
}
|
|
5589 |
if (box)
|
|
5590 |
{
|
|
5591 |
NW_LMgr_Box_SetHasFocus (iCurrentBox, NW_FALSE);
|
|
5592 |
NW_LMgr_Box_SetHasFocus (box, NW_TRUE);
|
|
5593 |
SetCurrentBox(box);
|
|
5594 |
NW_LMgr_RootBox_SetFocusBox(iRootBox, box);
|
|
5595 |
}
|
|
5596 |
}
|
|
5597 |
Draw(NW_TRUE);
|
|
5598 |
}
|
|
5599 |
|
|
5600 |
void CView::CancelPeriodicTimer()
|
|
5601 |
{
|
|
5602 |
if(iPeriodicTimer)
|
|
5603 |
iPeriodicTimer->Cancel();
|
|
5604 |
}
|
|
5605 |
|
|
5606 |
TInt CView::PeriodicTimerCallBack(TAny* aAny)
|
|
5607 |
{
|
|
5608 |
CView* self = static_cast<CView*>( aAny );
|
|
5609 |
self->CancelPeriodicTimer();
|
|
5610 |
return KErrNone;
|
|
5611 |
}
|
|
5612 |
// ============================ MEMBER FUNCTIONS ===============================
|