94
|
1 |
/*
|
|
2 |
* Copyright (c) 2003 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: Content handler for XHTML content type
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
#include <e32def.h> // To avoid NULL redefine warning (no #ifndef NULL)
|
|
20 |
|
|
21 |
#include "nw_lmgr_box.h"
|
|
22 |
#include "nw_lmgr_rootbox.h"
|
|
23 |
#include "nw_lmgr_marqueebox.h"
|
|
24 |
|
|
25 |
#include "nw_lmgr_verticaltablebox.h"
|
|
26 |
#include "nw_lmgr_verticaltablerowbox.h"
|
|
27 |
#include "nw_lmgr_verticaltablecellbox.h"
|
|
28 |
#include "nw_lmgr_bidiflowbox.h"
|
|
29 |
#include "nw_lmgr_textbox.h"
|
|
30 |
|
|
31 |
#include <f32file.h>
|
|
32 |
#include <flogger.h>
|
|
33 |
|
|
34 |
#include <stddef.h>
|
|
35 |
#include <stdio.h>
|
|
36 |
#include <string.h>
|
|
37 |
|
|
38 |
#include "nwx_string.h"
|
|
39 |
|
|
40 |
#include "nw_xhtml_xhtmlcontenthandleri.h"
|
|
41 |
#include "nw_basicforms_xhtmlformliaison.h"
|
|
42 |
#include "XhtmlTableElementHandlerOOC.h"
|
|
43 |
#include "nw_basictables_trelementhandler.h"
|
|
44 |
#include "nw_basictables_cellelementhandler.h"
|
|
45 |
#include "nw_xhtml_textelementhandler.h"
|
|
46 |
#include "nw_text_coretextelementhandler.h"
|
|
47 |
#include "nw_xhtml_pielementhandler.h"
|
|
48 |
#include "nw_image_imgelementhandler.h"
|
|
49 |
#include "nw_hed_documentroot.h"
|
|
50 |
#include "nw_hed_inumbercollectori.h"
|
|
51 |
#include "nw_lmgr_bidiflowbox.h"
|
|
52 |
#include "nw_dom_domvisitor.h"
|
|
53 |
#include <nw_tinydom.h>
|
|
54 |
#include <nw_dom_element.h>
|
|
55 |
#include <nw_dom_document.h>
|
|
56 |
#include "nw_adt_segmentedvector.h"
|
|
57 |
#include "nw_adt_resizableobjectvector.h"
|
|
58 |
#include "nw_adt_mapiterator.h"
|
|
59 |
#include <nw_xmlp_xmlp2wbxml.h>
|
|
60 |
#include "nw_htmlp_to_wbxml.h"
|
|
61 |
#include "nwx_url_utils.h"
|
|
62 |
#include "nwx_string.h"
|
|
63 |
#include "nwx_logger.h"
|
|
64 |
#include "nw_hed_context.h"
|
|
65 |
#include "NW_Text_Abstract.h"
|
|
66 |
#include "nw_text_ucs2.h"
|
|
67 |
#include "nw_xhtml_xhtmlentityset.h"
|
|
68 |
#include "nwx_ctx.h"
|
|
69 |
#include "nw_hed_documentroot.h"
|
|
70 |
#include "HEDDocumentListener.h"
|
|
71 |
#include "nw_xhtml_xhtml_1_0_tokens.h"
|
|
72 |
#include "nw_hed_domhelper.h"
|
|
73 |
#include "nw_msg_messagedispatcher.h"
|
|
74 |
#include "nw_markup_numbercollector.h"
|
|
75 |
//R->ul #include "urlloader_urlloaderint.h"
|
|
76 |
#include "nwx_osu_file.h"
|
|
77 |
#include "nw_hed_hedeventhandler.h"
|
|
78 |
#include "nw_lmgr_activecontainerbox.h"
|
|
79 |
#include "nwx_http_defs.h"
|
|
80 |
#include "nwx_settings.h"
|
|
81 |
//#include "nw_ecma_contenthandler.h"
|
|
82 |
#include "MapElementList.h"
|
|
83 |
#include "nw_lmgr_simplepropertylist.h"
|
|
84 |
#include "BrsrStatusCodes.h"
|
|
85 |
#include "nwx_statuscodeconvert.h"
|
|
86 |
#include <flogger.h>
|
|
87 |
#include "nw_markup_wbxmlmodule.h"
|
|
88 |
|
|
89 |
#include "nw_structure_scriptelementhandler.h"
|
|
90 |
#include "XhtmlObjectElementHandlerOOCi.h"
|
|
91 |
#include "XHTMLMessageListener.h"
|
|
92 |
#include <bodypart.h>
|
|
93 |
#include "MVCShell.h"
|
|
94 |
#include "BrCtl.h"
|
|
95 |
|
|
96 |
#include <stddef.h>
|
|
97 |
#include "CReferrerHelper.h"
|
|
98 |
#include "CSSVariableStyleSheet.h"
|
|
99 |
|
|
100 |
// MODULE DATA STRUCTURES
|
|
101 |
|
|
102 |
/* ------------------------------------------------------------------------- *
|
|
103 |
class definition
|
|
104 |
* ------------------------------------------------------------------------- */
|
|
105 |
/* ------------------------------------------------------------------------- *
|
|
106 |
forward method declarations
|
|
107 |
* ------------------------------------------------------------------------- */
|
|
108 |
static
|
|
109 |
TBrowserStatusCode
|
|
110 |
NW_XHTML_ContentHandler_MetaRefreshTimerCallback (void* timerData);
|
|
111 |
|
|
112 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
113 |
|
|
114 |
|
|
115 |
static
|
|
116 |
NW_LMgr_ContainerBox_t*
|
|
117 |
NW_XHTML_ContentHandler_GetContainerSpecialCase ( NW_DOM_Node_t* node,
|
|
118 |
NW_DOM_Node_t* parentNode,
|
|
119 |
NW_LMgr_ContainerBox_t* containerBox)
|
|
120 |
{
|
|
121 |
NW_ASSERT (parentNode);
|
|
122 |
NW_ASSERT (node);
|
|
123 |
NW_ASSERT (containerBox);
|
|
124 |
|
|
125 |
// special handling for form inside table
|
|
126 |
NW_Uint16 token = NW_HED_DomHelper_GetElementToken (parentNode);
|
|
127 |
if (token == NW_XHTML_ElementToken_form)
|
|
128 |
{
|
|
129 |
// if chunk cuts after form
|
|
130 |
token = NW_HED_DomHelper_GetElementToken (node);
|
|
131 |
if (token == NW_XHTML_ElementToken_tr ||
|
|
132 |
token == NW_XHTML_ElementToken_td ||
|
|
133 |
token == NW_XHTML_ElementToken_th)
|
|
134 |
{
|
|
135 |
containerBox = NW_LMgr_Box_GetParent(containerBox);
|
|
136 |
}
|
|
137 |
else
|
|
138 |
{
|
|
139 |
NW_Uint32 type = NW_DOM_Node_getNodeType(node);
|
|
140 |
// special handling for text node is under form and form is under table, th, tr
|
|
141 |
if (type == NW_DOM_TEXT_NODE)
|
|
142 |
{
|
|
143 |
NW_DOM_Node_t* tempNode = NW_DOM_Node_getParentNode(parentNode);
|
|
144 |
token = NW_HED_DomHelper_GetElementToken (tempNode);
|
|
145 |
if (token == NW_XHTML_ElementToken_tr ||
|
|
146 |
token == NW_XHTML_ElementToken_th ||
|
|
147 |
token == NW_XHTML_ElementToken_table)
|
|
148 |
{
|
|
149 |
containerBox = NW_LMgr_Box_GetParent(containerBox);
|
|
150 |
}
|
|
151 |
}
|
|
152 |
}
|
|
153 |
}
|
|
154 |
else if (token == NW_XHTML_ElementToken_table)
|
|
155 |
{
|
|
156 |
// if chunk cuts above form
|
|
157 |
token = NW_HED_DomHelper_GetElementToken (node);
|
|
158 |
if (token == NW_XHTML_ElementToken_form)
|
|
159 |
{
|
|
160 |
containerBox = NW_LMgr_Box_GetParent(containerBox);
|
|
161 |
}
|
|
162 |
} // end of if (token == NW_XHTML_ElementToken_form)
|
|
163 |
|
|
164 |
return containerBox;
|
|
165 |
}
|
|
166 |
|
|
167 |
static
|
|
168 |
NW_DOM_Node_t*
|
|
169 |
NW_XHTML_ContentHandler_GetParentNodeSpecialCase ( NW_DOM_Node_t* node,
|
|
170 |
NW_DOM_Node_t* parentNode,
|
|
171 |
NW_Bool* formInTable)
|
|
172 |
{
|
|
173 |
NW_ASSERT (parentNode);
|
|
174 |
NW_ASSERT (node);
|
|
175 |
|
|
176 |
NW_Uint16 token = NW_HED_DomHelper_GetElementToken (parentNode);
|
|
177 |
if (token == NW_XHTML_ElementToken_form)
|
|
178 |
{
|
|
179 |
// special handling for form inside table
|
|
180 |
token = NW_HED_DomHelper_GetElementToken (node);
|
|
181 |
if (token == NW_XHTML_ElementToken_tr ||
|
|
182 |
token == NW_XHTML_ElementToken_td ||
|
|
183 |
token == NW_XHTML_ElementToken_th)
|
|
184 |
{
|
|
185 |
parentNode = NW_DOM_Node_getParentNode(parentNode);
|
|
186 |
}
|
|
187 |
else
|
|
188 |
{
|
|
189 |
NW_Uint32 type = NW_DOM_Node_getNodeType(node);
|
|
190 |
// special handling for text node is under form and form is under table, th, tr
|
|
191 |
if (type == NW_DOM_TEXT_NODE)
|
|
192 |
{
|
|
193 |
NW_DOM_Node_t* tempNode = NW_DOM_Node_getParentNode(parentNode);
|
|
194 |
token = NW_HED_DomHelper_GetElementToken (tempNode);
|
|
195 |
if (token == NW_XHTML_ElementToken_tr ||
|
|
196 |
token == NW_XHTML_ElementToken_th ||
|
|
197 |
token == NW_XHTML_ElementToken_table)
|
|
198 |
{
|
|
199 |
parentNode = tempNode;
|
|
200 |
}
|
|
201 |
}
|
|
202 |
}
|
|
203 |
}
|
|
204 |
else if (token == NW_XHTML_ElementToken_table)
|
|
205 |
{
|
|
206 |
// if chunk cuts above form
|
|
207 |
token = NW_HED_DomHelper_GetElementToken (node);
|
|
208 |
if (token == NW_XHTML_ElementToken_form)
|
|
209 |
{
|
|
210 |
*formInTable = NW_TRUE;
|
|
211 |
}
|
|
212 |
} // end of if (token == NW_XHTML_ElementToken_form)
|
|
213 |
|
|
214 |
return parentNode;
|
|
215 |
}
|
|
216 |
|
|
217 |
static
|
|
218 |
TBrowserStatusCode
|
|
219 |
NW_XHTML_ContentHandler_GetContainerBox ( NW_DOM_Node_t* lastDomNode,
|
|
220 |
NW_DOM_Node_t* currentDomNode,
|
|
221 |
NW_LMgr_ContainerBox_t** containerBox,
|
|
222 |
NW_LMgr_ContainerBox_t* parentBox )
|
|
223 |
{
|
|
224 |
NW_ASSERT (lastDomNode);
|
|
225 |
NW_ASSERT (currentDomNode);
|
|
226 |
NW_ASSERT (parentBox);
|
|
227 |
|
|
228 |
// used to track the levels up in the box tree to find the right container box
|
|
229 |
NW_LMgr_Box_t* lastBox;
|
|
230 |
|
|
231 |
// check the levels of the current parent node and the last dom node
|
|
232 |
NW_DOM_Node_t* currentParentNode = NW_DOM_Node_getParentNode(currentDomNode);
|
|
233 |
lastBox = (NW_LMgr_Box_t *)parentBox ;
|
|
234 |
|
|
235 |
// if the currentDomNode's ancestor is the last node, then return the lastContainerBox
|
|
236 |
// this can happen when last dom node's children arrives in the next chunk
|
|
237 |
if (currentParentNode == lastDomNode)
|
|
238 |
{
|
|
239 |
// get the last box from the box tree
|
|
240 |
do
|
|
241 |
{
|
|
242 |
NW_ADT_Vector_Metric_t numChildren = NW_LMgr_ContainerBox_GetChildCount(NW_LMgr_ContainerBoxOf(lastBox ));
|
|
243 |
// if the box has no children , then break , it could be a box or a last container box
|
|
244 |
if (numChildren == 0 )
|
|
245 |
{
|
|
246 |
break;
|
|
247 |
}
|
|
248 |
// get the last box in the level
|
|
249 |
numChildren --;
|
|
250 |
lastBox = NW_LMgr_ContainerBox_GetChild(NW_LMgr_ContainerBoxOf(lastBox), numChildren );
|
|
251 |
}
|
|
252 |
while (NW_Object_IsInstanceOf (lastBox, &NW_LMgr_ContainerBox_Class));
|
|
253 |
|
|
254 |
// if the last box is not an instance of container box , find the parent box
|
|
255 |
// of the last box
|
|
256 |
NW_LMgr_ContainerBox_t* lastContainerBox;
|
|
257 |
if (!NW_Object_IsInstanceOf (lastBox, &NW_LMgr_ContainerBox_Class))
|
|
258 |
{
|
|
259 |
lastContainerBox = NW_LMgr_Box_GetParent(lastBox );
|
|
260 |
}
|
|
261 |
else
|
|
262 |
{
|
|
263 |
lastContainerBox = NW_LMgr_ContainerBoxOf(lastBox );
|
|
264 |
}
|
|
265 |
|
|
266 |
// special handling for form inside table
|
|
267 |
*containerBox = NW_XHTML_ContentHandler_GetContainerSpecialCase( currentDomNode,
|
|
268 |
currentParentNode,
|
|
269 |
lastContainerBox);
|
|
270 |
}
|
|
271 |
else
|
|
272 |
{
|
|
273 |
// if the container box is not in the parent hirerchy
|
|
274 |
NW_Bool formInsideTable = NW_FALSE;
|
|
275 |
currentParentNode = NW_XHTML_ContentHandler_GetParentNodeSpecialCase (currentDomNode,
|
|
276 |
currentParentNode,
|
|
277 |
&formInsideTable);
|
|
278 |
|
|
279 |
// traverse the last branch of the box tree
|
|
280 |
NW_Bool found = NW_FALSE;
|
|
281 |
do
|
|
282 |
{
|
|
283 |
NW_LMgr_PropertyValue_t value;
|
|
284 |
value.object = NULL;
|
|
285 |
(void)NW_LMgr_Box_GetPropertyValue(lastBox, NW_CSS_Prop_elementId, NW_CSS_ValueType_Object, &value);
|
|
286 |
if (value.object)
|
|
287 |
{
|
|
288 |
NW_DOM_ElementNode_t* elementNode = (NW_DOM_ElementNode_t*)value.object;
|
|
289 |
if (elementNode == currentParentNode)
|
|
290 |
{
|
|
291 |
found = NW_TRUE;
|
|
292 |
break;
|
|
293 |
}
|
|
294 |
}
|
|
295 |
|
|
296 |
NW_ADT_Vector_Metric_t numChildren = NW_LMgr_ContainerBox_GetChildCount(NW_LMgr_ContainerBoxOf(lastBox ));
|
|
297 |
if (numChildren == 0 )
|
|
298 |
{
|
|
299 |
break;
|
|
300 |
}
|
|
301 |
numChildren --;
|
|
302 |
lastBox = NW_LMgr_ContainerBox_GetChild(NW_LMgr_ContainerBoxOf(lastBox), numChildren );
|
|
303 |
}
|
|
304 |
while (NW_Object_IsInstanceOf (lastBox, &NW_LMgr_ContainerBox_Class));
|
|
305 |
|
|
306 |
// could be the case when header occupies first chunk
|
|
307 |
if (!found)
|
|
308 |
{
|
|
309 |
NW_LMgr_Box_t* rootBox = NW_LMgr_BoxOf(NW_LMgr_Box_GetParent(parentBox));
|
|
310 |
NW_ASSERT(NW_Object_IsInstanceOf (rootBox, &NW_LMgr_RootBox_Class));
|
|
311 |
NW_LMgr_Box_t* bodyBox = NW_LMgr_RootBox_GetBody(NW_LMgr_RootBoxOf(rootBox));
|
|
312 |
if (!bodyBox)
|
|
313 |
{
|
|
314 |
*containerBox = NW_LMgr_ContainerBoxOf(NW_LMgr_ContainerBox_GetChild(NW_LMgr_ContainerBoxOf(rootBox), 0));
|
|
315 |
}
|
|
316 |
else
|
|
317 |
{
|
|
318 |
*containerBox = NW_LMgr_ContainerBoxOf(bodyBox);
|
|
319 |
}
|
|
320 |
}
|
|
321 |
else
|
|
322 |
{
|
|
323 |
if (formInsideTable)
|
|
324 |
{
|
|
325 |
// if form is under table, attach form to the parent box of table box
|
|
326 |
*containerBox = NW_LMgr_Box_GetParent(lastBox);
|
|
327 |
}
|
|
328 |
else
|
|
329 |
{
|
|
330 |
*containerBox = NW_LMgr_ContainerBoxOf(lastBox);
|
|
331 |
}
|
|
332 |
}
|
|
333 |
} // end of if (currentParentNode == lastDomNode)
|
|
334 |
|
|
335 |
return KBrsrSuccess;
|
|
336 |
}
|
|
337 |
|
|
338 |
static
|
|
339 |
TBrowserStatusCode
|
|
340 |
NW_XHTML_ContentHandler_CreatePartialBoxTree (NW_XHTML_ContentHandler_t* thisObj,
|
|
341 |
NW_LMgr_Box_t** boxTree)
|
|
342 |
{
|
|
343 |
NW_DOM_Node_t* domNode = NULL;
|
|
344 |
NW_DOM_Node_t* lastDomNode;
|
|
345 |
const NW_XHTML_ElementHandler_t* elementHandler;
|
|
346 |
NW_cXML_DOM_DOMVisitor_t * domDOMVisitor = NULL;
|
|
347 |
|
|
348 |
NW_LOG0( NW_LOG_LEVEL2, "NW_XHTML_ContentHandler_CreatePartialBoxTree START" );
|
|
349 |
|
|
350 |
NW_TRY (status)
|
|
351 |
{
|
|
352 |
if (thisObj->prevInitializedDomNode == 0)
|
|
353 |
NW_THROW_SUCCESS(status);
|
|
354 |
|
|
355 |
// if there are new nodes to create the box tree
|
|
356 |
domDOMVisitor =
|
|
357 |
NW_cXML_DOM_DOMVisitor_New( NW_HED_DomTree_GetRootNode( thisObj->domTree));
|
|
358 |
NW_THROW_ON_NULL( domDOMVisitor, status, KBrsrOutOfMemory );
|
|
359 |
|
|
360 |
// skip DOM nodes for which boxes were created (of the previous chunks)
|
|
361 |
domDOMVisitor->currentNode = thisObj->prevInitializedDomNode;
|
|
362 |
lastDomNode = thisObj->prevInitializedDomNode;
|
|
363 |
|
|
364 |
#ifdef _DEBUG1
|
|
365 |
|
|
366 |
NW_LMgr_Box_DumpBoxTree1((NW_LMgr_Box_t*)*boxTree);
|
|
367 |
#endif
|
|
368 |
|
|
369 |
// get the next dom node - this will be the first node of the new chunk
|
|
370 |
domNode = NW_cXML_DOM_DOMVisitor_Next( domDOMVisitor, NW_DOM_ELEMENT_NODE |
|
|
371 |
NW_DOM_TEXT_NODE | NW_DOM_PROCESSING_INSTRUCTION_NODE );
|
|
372 |
|
|
373 |
if (domNode == 0) // no new domNode to create a tree
|
|
374 |
NW_THROW_SUCCESS(status);
|
|
375 |
|
|
376 |
do
|
|
377 |
{
|
|
378 |
NW_LMgr_ContainerBox_t* containerBox = NULL;
|
|
379 |
|
|
380 |
// find the correspoding container box for the dom node
|
|
381 |
(void)NW_XHTML_ContentHandler_GetContainerBox(lastDomNode, domNode, &containerBox, NW_LMgr_ContainerBoxOf(*boxTree));
|
|
382 |
NW_ASSERT(containerBox != NULL);
|
|
383 |
NW_ASSERT(NW_Object_IsInstanceOf (containerBox, &NW_LMgr_ContainerBox_Class));
|
|
384 |
NW_ASSERT(!NW_Object_IsInstanceOf (containerBox, &NW_LMgr_RootBox_Class));
|
|
385 |
|
|
386 |
// create the box tree for the subtree
|
|
387 |
// all the siblings can use the container box to create the box tree
|
|
388 |
// traverse the sibling nodes and create the box tree for the sibling nodes.
|
|
389 |
// skip the siblings and all its child nodes
|
|
390 |
NW_DOM_Node_t* prevDomNode = domNode;
|
|
391 |
|
|
392 |
for (;domNode != NULL ;domNode = NW_DOM_Node_getNextSibling (domNode))
|
|
393 |
{
|
|
394 |
NW_Uint32 type = NW_DOM_Node_getNodeType(domNode);
|
|
395 |
thisObj->prevInitializedDomNode = domNode ;
|
|
396 |
if (type == NW_DOM_TEXT_NODE)
|
|
397 |
{
|
|
398 |
NW_DOM_Node_t* parentNode = NW_DOM_Node_getParentNode(domNode);
|
|
399 |
NW_Uint16 token = NW_HED_DomHelper_GetElementToken (parentNode);
|
|
400 |
|
|
401 |
if (token == NW_XHTML_ElementToken_table ||
|
|
402 |
token == NW_XHTML_ElementToken_tr ||
|
|
403 |
token == NW_XHTML_ElementToken_th)
|
|
404 |
{
|
|
405 |
// special handling for text node under table, th, tr
|
|
406 |
lastDomNode = domNode;
|
|
407 |
continue;
|
|
408 |
}
|
|
409 |
else if (token == NW_XHTML_ElementToken_form &&
|
|
410 |
(NW_Object_IsInstanceOf (containerBox, &NW_LMgr_VerticalTableBox_Class) ||
|
|
411 |
NW_Object_IsInstanceOf (containerBox, &NW_LMgr_VerticalTableRowBox_Class)))
|
|
412 |
{
|
|
413 |
// special handling for text node under form in dom tree
|
|
414 |
// text node is under table, th, tr in box tree
|
|
415 |
lastDomNode = domNode;
|
|
416 |
continue;
|
|
417 |
}
|
|
418 |
}
|
|
419 |
elementHandler = NW_XHTML_ContentHandler_GetElementHandler (thisObj,
|
|
420 |
(NW_DOM_ElementNode_t*) domNode);
|
|
421 |
NW_ASSERT(elementHandler != NULL);
|
|
422 |
|
|
423 |
status = NW_XHTML_ElementHandler_CreateBoxTree (elementHandler,
|
|
424 |
thisObj,
|
|
425 |
domNode,
|
|
426 |
containerBox);
|
|
427 |
_NW_THROW_ON_ERROR(status);
|
|
428 |
lastDomNode = domNode;
|
|
429 |
} // end of for (;domNode != NULL
|
|
430 |
|
|
431 |
// go up the hirarchy and process all the dom nodes and all its children
|
|
432 |
do
|
|
433 |
{
|
|
434 |
prevDomNode = NW_DOM_Node_getParentNode(prevDomNode);
|
|
435 |
if (prevDomNode && NW_DOM_Node_getNextSibling (prevDomNode))
|
|
436 |
{
|
|
437 |
domNode = NW_DOM_Node_getNextSibling (prevDomNode);
|
|
438 |
break;
|
|
439 |
}
|
|
440 |
}
|
|
441 |
while (prevDomNode);
|
|
442 |
|
|
443 |
#ifdef _DEBUG1
|
|
444 |
|
|
445 |
NW_LMgr_Box_DumpBoxTree((NW_LMgr_Box_t*)*boxTree);
|
|
446 |
#endif
|
|
447 |
|
|
448 |
}
|
|
449 |
while (domNode);
|
|
450 |
} // end NW_TRY
|
|
451 |
NW_CATCH (status)
|
|
452 |
{}
|
|
453 |
NW_FINALLY
|
|
454 |
{
|
|
455 |
if (domDOMVisitor)
|
|
456 |
{
|
|
457 |
NW_Object_Delete (domDOMVisitor);
|
|
458 |
}
|
|
459 |
NW_LOG0( NW_LOG_LEVEL2, "NW_XHTML_ContentHandler_CreatePartialBoxTree END" );
|
|
460 |
return status;
|
|
461 |
}
|
|
462 |
NW_END_TRY
|
|
463 |
}
|
|
464 |
|
|
465 |
|
|
466 |
/* ------------------------------------------------------------------------- *
|
|
467 |
private methods
|
|
468 |
* ------------------------------------------------------------------------- */
|
|
469 |
// -----------------------------------------------------------------------------
|
|
470 |
TBrowserStatusCode
|
|
471 |
NW_XHTML_ContentHandler_CreatePartialDocument( NW_XHTML_ContentHandler_t* contentHandler,
|
|
472 |
NW_Url_Resp_t* response, NW_Bool isFirst )
|
|
473 |
{
|
|
474 |
NW_Buffer_t* domBuffer;
|
|
475 |
NW_Uint32 line = 0;
|
|
476 |
TBrowserStatusCode status;
|
|
477 |
NW_Uint32 codePageSwitchCount = 0;
|
|
478 |
NW_Int32 lastValid = -1;
|
|
479 |
NW_Bool encodingFound;
|
|
480 |
void* WBXMLEncStrTbl = NULL;
|
|
481 |
|
|
482 |
NW_LOG0(NW_LOG_LEVEL2, "NW_XHTML_ContentHandler_CreatePartialDocument");
|
|
483 |
|
|
484 |
status = _NW_HED_CompositeContentHandler_ComputeEncoding(NW_HED_CompositeContentHandlerOf(contentHandler),
|
|
485 |
response, &encodingFound);
|
|
486 |
if (status != KBrsrSuccess)
|
|
487 |
{
|
|
488 |
return status;
|
|
489 |
}
|
|
490 |
|
|
491 |
if(response->contentLocationString != NULL)
|
|
492 |
{
|
|
493 |
contentHandler->contentLocation = NW_Str_CvtFromAscii((char *)response->contentLocationString);
|
|
494 |
if(contentHandler->contentLocation == NULL)
|
|
495 |
{
|
|
496 |
return KBrsrOutOfMemory;
|
|
497 |
}
|
|
498 |
}
|
|
499 |
|
|
500 |
/* Change done to support saved deck */
|
|
501 |
if ((0 == NW_Asc_stricmp((char*)HTTP_text_vnd_wap_wml_string,
|
|
502 |
(char*)response->contentTypeString)) ||
|
|
503 |
(0 == NW_Asc_stricmp((char*)HTTP_application_xhtml_xml_string,
|
|
504 |
(char*)response->contentTypeString)) ||
|
|
505 |
(0 == NW_Asc_stricmp((char*)HTTP_application_vnd_wap_xhtml_xml_string,
|
|
506 |
(char*)response->contentTypeString)) ||
|
|
507 |
(0 == NW_Asc_stricmp((char*)HTTP_text_html_string,
|
|
508 |
(char*)response->contentTypeString)) ||
|
|
509 |
(0 == NW_Asc_stricmp((char*)HTTP_application_vnd_wap_wml_plus_xml_string,
|
|
510 |
(char*)response->contentTypeString)))
|
|
511 |
{
|
|
512 |
NW_HED_CharsetConvContext ctx;
|
|
513 |
ctx.contentHandler = NW_HED_CompositeContentHandlerOf( contentHandler );
|
|
514 |
ctx.response = response;
|
|
515 |
|
|
516 |
NW_LOG0(NW_LOG_LEVEL2, "CreateDocument: before NW_HTMLP_SegToWbxml ");
|
|
517 |
|
|
518 |
NW_Bool detectEncoding = (encodingFound) ? NW_FALSE : NW_TRUE;
|
|
519 |
status = NW_HTMLP_SegToWbxml( response->body, response->charset,
|
|
520 |
response->byteOrder,
|
|
521 |
&domBuffer, &line, NW_xhtml_1_0_PublicId,
|
|
522 |
NW_HTMLP_Get_ElementTableCount(),
|
|
523 |
NW_HTMLP_Get_ElementDescriptionTable(),
|
|
524 |
NW_FALSE, /* consume spaces */
|
|
525 |
detectEncoding, /* need to detect charset */
|
|
526 |
isFirst, /* is this the first segment of a document? */
|
|
527 |
NW_FALSE, /* is this the last segment of a document? */
|
|
528 |
&lastValid,
|
|
529 |
&(contentHandler->htmlpParser) ,
|
|
530 |
&codePageSwitchCount,
|
|
531 |
&ctx,
|
|
532 |
NW_HED_CompositeContentHandler_CharConvCB,
|
|
533 |
&WBXMLEncStrTbl,
|
|
534 |
NW_FALSE);
|
|
535 |
if ( status == KBrsrBufferTooSmall )
|
|
536 |
{
|
|
537 |
NW_LOG0(NW_LOG_LEVEL2, "CreatePartialDocument: NW_HTMLP_SegToWbxml returns KBrsrBufferTooSmall.");
|
|
538 |
return status;
|
|
539 |
}
|
|
540 |
if (BRSR_STAT_IS_FAILURE(status))
|
|
541 |
{
|
|
542 |
NW_LOG1(NW_LOG_LEVEL1, "!!!CreatePartialDocument: NW_HTMLP_SegToWbxml: BadContent: SegToWbxml failure. status: %d", status);
|
|
543 |
NW_Buffer_Free(domBuffer);
|
|
544 |
return KBrsrXhtmlBadContent;
|
|
545 |
}
|
|
546 |
if (domBuffer)
|
|
547 |
{
|
|
548 |
NW_LOG1(NW_LOG_LEVEL2, "CreatePartialDocument: NW_HTMLP_SegToWbxml succeeds, domBuffer length: %d", domBuffer->length);
|
|
549 |
}
|
|
550 |
}
|
|
551 |
else
|
|
552 |
{
|
|
553 |
/* init our domBuffer */
|
|
554 |
domBuffer = NW_Buffer_New(0);
|
|
555 |
|
|
556 |
if (domBuffer != NULL)
|
|
557 |
{
|
|
558 |
domBuffer->allocatedLength = response->body->allocatedLength;
|
|
559 |
domBuffer->length = response->body->length;
|
|
560 |
domBuffer->data = response->body->data;
|
|
561 |
|
|
562 |
/* This block is only used to switch the byte order of domBuffer. Each time the
|
|
563 |
function NW_HED_DomTree_New is called, the byte order of domBuffer is changed.
|
|
564 |
For a saved page, the domBuffer saved in the byte order after the change when
|
|
565 |
this page was loaded from web. So this order is wrong when call function
|
|
566 |
NW_HED_DomTree_New below. Thus we call NW_HED_DomTree_New here to change the
|
|
567 |
byte order back for saved page loading */
|
|
568 |
contentHandler->domTree = NW_HED_DomTree_New (domBuffer, response->charset,
|
|
569 |
NW_xhtml_1_0_PublicId,WBXMLEncStrTbl);
|
|
570 |
|
|
571 |
if (contentHandler->domTree != NULL)
|
|
572 |
{
|
|
573 |
/* Orphan the Buffer so it isn't deleted then delete the temp DomTree */
|
|
574 |
domBuffer = NW_HED_DomTree_OrphanDomBuffer (contentHandler->domTree);
|
|
575 |
|
|
576 |
NW_HED_DomTree_Delete (contentHandler->domTree);
|
|
577 |
contentHandler->domTree = NULL;
|
|
578 |
}
|
|
579 |
/* end of the byte order switch */
|
|
580 |
|
|
581 |
delete response->body;
|
|
582 |
response->body = NULL;
|
|
583 |
}
|
|
584 |
else
|
|
585 |
{
|
|
586 |
return KBrsrOutOfMemory;
|
|
587 |
}
|
|
588 |
}
|
|
589 |
|
|
590 |
/* build the DOM tree */
|
|
591 |
if (lastValid == -1)
|
|
592 |
{
|
|
593 |
contentHandler->domTree = NW_HED_DomTree_New (domBuffer,
|
|
594 |
response->charset,
|
|
595 |
NW_xhtml_1_0_PublicId,WBXMLEncStrTbl
|
|
596 |
);
|
|
597 |
NW_LOG0(NW_LOG_LEVEL2, "CreatePartialDocument: after NW_HED_DomTree_New ");
|
|
598 |
}
|
|
599 |
else
|
|
600 |
{
|
|
601 |
if (isFirst)
|
|
602 |
{
|
|
603 |
NW_HED_DomTree_Delete (contentHandler->domTree);
|
|
604 |
contentHandler->domTree = NULL;
|
|
605 |
}
|
|
606 |
status = NW_HED_DomTree_Append (&(contentHandler->domTree),
|
|
607 |
domBuffer,
|
|
608 |
HTTP_iso_10646_ucs_2,
|
|
609 |
NW_xhtml_1_0_PublicId,
|
|
610 |
codePageSwitchCount,
|
|
611 |
lastValid,
|
|
612 |
WBXMLEncStrTbl
|
|
613 |
);
|
|
614 |
NW_LOG1(NW_LOG_LEVEL2, "CreatePartialDocument: after NW_HED_DomTree_Append, status: %x", status);
|
|
615 |
}
|
|
616 |
|
|
617 |
// set override the status if NW_HED_DomTree_New was called and failed
|
|
618 |
if (contentHandler->domTree == NULL && status == KBrsrSuccess)
|
|
619 |
{
|
|
620 |
NW_LOG0(NW_LOG_LEVEL1, "!!!NW_XHTML_ContentHandler_CreatePartialDocument: BadContent: NULL domTree with success status after NW_HED_DomTree_Append ");
|
|
621 |
status = KBrsrXhtmlBadContent;
|
|
622 |
}
|
|
623 |
|
|
624 |
/* init the domHelper */
|
|
625 |
contentHandler->domHelper.entitySet =
|
|
626 |
NW_HED_EntitySetOf (&NW_XHTML_EntitySet);
|
|
627 |
contentHandler->domHelper.context = NULL;
|
|
628 |
contentHandler->domHelper.resolvePlainTextVariablesAndEntities = NW_TRUE;
|
|
629 |
|
|
630 |
/* find the body element, if it exists */
|
|
631 |
if (contentHandler->domTree != NULL && status == KBrsrSuccess)
|
|
632 |
{
|
|
633 |
contentHandler->baseElement =
|
|
634 |
NW_HED_DomHelper_FindElement (&(contentHandler->domHelper),
|
|
635 |
NW_HED_DomTree_GetRootNode(contentHandler->domTree),
|
|
636 |
3, NW_XHTML_ElementToken_base, 0, NULL);
|
|
637 |
}
|
|
638 |
else
|
|
639 |
{
|
|
640 |
NW_LOG1(NW_LOG_LEVEL2, "!!CreatePartialDocument: DOM Tree creation/appending failed, status: %x", status);
|
|
641 |
}
|
|
642 |
|
|
643 |
/* print the domTree */
|
|
644 |
#ifdef _DEBUG1
|
|
645 |
if (status == KBrsrSuccess)
|
|
646 |
{
|
|
647 |
NW_HED_DomHelper_PrintTree
|
|
648 |
(&contentHandler->domHelper,
|
|
649 |
NW_HED_DomTree_GetRootNode (contentHandler->domTree));
|
|
650 |
}
|
|
651 |
#endif
|
|
652 |
|
|
653 |
return status;
|
|
654 |
}
|
|
655 |
|
|
656 |
static
|
|
657 |
TBrowserStatusCode
|
|
658 |
NW_XHTML_ContentHandler_AppendPartialDocument( NW_XHTML_ContentHandler_t* contentHandler,
|
|
659 |
NW_Url_Resp_t* response)
|
|
660 |
{
|
|
661 |
return NW_XHTML_ContentHandler_CreatePartialDocument( contentHandler, response, NW_FALSE );
|
|
662 |
}
|
|
663 |
|
|
664 |
/* ------------------------------------------------------------------------- */
|
|
665 |
static
|
|
666 |
TBrowserStatusCode
|
|
667 |
NW_XHTML_ContentHandler_InitializeElementHandlers( NW_XHTML_ContentHandler_t* thisObj )
|
|
668 |
{
|
|
669 |
NW_cXML_DOM_DOMVisitor_t* domDOMVisitor = NULL;
|
|
670 |
NW_DOM_Node_t* domNode = NULL;
|
|
671 |
NW_DOM_Node_t* prevToLast = NULL;
|
|
672 |
|
|
673 |
NW_ASSERT( thisObj != NULL );
|
|
674 |
|
|
675 |
NW_TRY (status)
|
|
676 |
{
|
|
677 |
// should not crash browser even if domTree is not valid for some reason.
|
|
678 |
if (!thisObj->domTree)
|
|
679 |
NW_LOG0(NW_LOG_LEVEL1, "!!!NW_XHTML_ContentHandler_InitializeElementHandlers: BadContent: domTree NULL");
|
|
680 |
NW_THROW_ON_NULL( thisObj->domTree, status, KBrsrXhtmlBadContent );
|
|
681 |
// create the DOMVisitor object on the document and use it to traverse the
|
|
682 |
// tree
|
|
683 |
domDOMVisitor = NW_cXML_DOM_DOMVisitor_New( NW_HED_DomTree_GetRootNode( thisObj->domTree ) );
|
|
684 |
NW_THROW_ON_NULL( domDOMVisitor, status, KBrsrOutOfMemory );
|
|
685 |
|
|
686 |
NW_LOG0(NW_LOG_LEVEL2, "====== ! NW_XHTML_ContentHandler_Initialize: before while loop ");
|
|
687 |
|
|
688 |
// initialize DOMVisitor to last node of the previous chunk as we do not
|
|
689 |
// want to initialize already visited DOM nodes
|
|
690 |
domDOMVisitor->currentNode = thisObj->lastInitializedDomNode;
|
|
691 |
|
|
692 |
while ( ( domNode = NW_cXML_DOM_DOMVisitor_Next( domDOMVisitor,
|
|
693 |
NW_DOM_ELEMENT_NODE |
|
|
694 |
NW_DOM_TEXT_NODE |
|
|
695 |
NW_DOM_PROCESSING_INSTRUCTION_NODE ) )
|
|
696 |
!= NULL )
|
|
697 |
{
|
|
698 |
const NW_XHTML_ElementHandler_t * elementHandler;
|
|
699 |
|
|
700 |
// skip the elements up to the skipToNode, if found set skipToNode to NULL
|
|
701 |
if (thisObj->skipToNode != NULL )
|
|
702 |
{
|
|
703 |
|
|
704 |
NW_DOM_Node_t* parentNode;
|
|
705 |
parentNode = NW_DOM_Node_getParentNode((NW_DOM_Node_t*) domNode) ;
|
|
706 |
|
|
707 |
if (thisObj->skipToNode == parentNode )
|
|
708 |
{
|
|
709 |
continue;
|
|
710 |
}
|
|
711 |
else
|
|
712 |
{
|
|
713 |
thisObj->skipToNode = NULL;
|
|
714 |
}
|
|
715 |
}
|
|
716 |
// set iBodyIsPresent to true if we hit the <body> tag
|
|
717 |
if( !thisObj->iBodyIsPresent && NW_DOM_Node_getNodeType ((NW_DOM_Node_t*) domNode ) == NW_DOM_ELEMENT_NODE )
|
|
718 |
{
|
|
719 |
if( NW_HED_DomHelper_GetElementToken (domNode) == NW_XHTML_ElementToken_body )
|
|
720 |
{
|
|
721 |
//
|
|
722 |
thisObj->iBodyIsPresent = NW_TRUE;
|
|
723 |
}
|
|
724 |
}
|
|
725 |
|
|
726 |
prevToLast = thisObj->lastInitializedDomNode;
|
|
727 |
thisObj->lastInitializedDomNode = domNode;
|
|
728 |
|
|
729 |
// get the ElementHandler for the element - if there is no ElementHandler,
|
|
730 |
// we must ignore the element and continue our traversal
|
|
731 |
elementHandler = NW_XHTML_ContentHandler_GetElementHandler(
|
|
732 |
thisObj, (NW_DOM_ElementNode_t*) domNode );
|
|
733 |
|
|
734 |
if ( elementHandler == NULL )
|
|
735 |
{
|
|
736 |
continue;
|
|
737 |
}
|
|
738 |
|
|
739 |
// initialize the element
|
|
740 |
status = NW_XHTML_ElementHandler_Initialize(
|
|
741 |
elementHandler, thisObj, (NW_DOM_ElementNode_t*)domNode );
|
|
742 |
NW_THROW_ON( status, KBrsrOutOfMemory );
|
|
743 |
|
|
744 |
// stopInitEH is a special flag used to stop initializing element
|
|
745 |
// handlers. It is set by NW_XHTML_ElementHandler_NextSiblingExists(),
|
|
746 |
// which is called by several of the ElementHandler_Initialize() methods.
|
|
747 |
if (thisObj->stopInitEH)
|
|
748 |
{
|
|
749 |
break;
|
|
750 |
}
|
|
751 |
} // end while...
|
|
752 |
|
|
753 |
|
|
754 |
if (thisObj->stopInitEH)
|
|
755 |
{
|
|
756 |
// in case select is cut between chunks, leave it processed in the next chunk
|
|
757 |
thisObj->stopInitEH = NW_FALSE;
|
|
758 |
|
|
759 |
if(!thisObj->lastChunk)
|
|
760 |
{
|
|
761 |
// Special handling for certain elements; leave their processing to the
|
|
762 |
// next chunk. Set lastInitializedDomNode to be the node right before,
|
|
763 |
// either sibling or parent. Note, this is used in conjunction with
|
|
764 |
// stopInitEH flag set by NW_XHTML_ElementHandler_NextSiblingExists(),
|
|
765 |
// which is called by several of the ElementHandler_Initialize() methods.
|
|
766 |
NW_Uint16 token = NW_HED_DomHelper_GetElementToken (thisObj->lastInitializedDomNode);
|
|
767 |
if (token == NW_XHTML_ElementToken_style ||
|
|
768 |
token == NW_XHTML_ElementToken_title ||
|
|
769 |
token == NW_XHTML_ElementToken_script ||
|
|
770 |
token == NW_XHTML_ElementToken_select ||
|
|
771 |
token == NW_XHTML_ElementToken_object ||
|
|
772 |
token == NW_XHTML_ElementToken_map ||
|
|
773 |
token == NW_XHTML_ElementToken_textarea ||
|
|
774 |
token == NW_XHTML_ElementToken_table ||
|
|
775 |
token == NW_XHTML_ElementToken_a)
|
|
776 |
{
|
|
777 |
thisObj->lastInitializedDomNode = prevToLast;
|
|
778 |
}
|
|
779 |
}
|
|
780 |
}
|
|
781 |
|
|
782 |
NW_LOG0(NW_LOG_LEVEL2, "===== ! NW_XHTML_ContentHandler_Initialize: after while loop ");
|
|
783 |
}
|
|
784 |
NW_CATCH (status )
|
|
785 |
{}
|
|
786 |
NW_FINALLY
|
|
787 |
{
|
|
788 |
NW_Object_Delete (domDOMVisitor);
|
|
789 |
return status;
|
|
790 |
}
|
|
791 |
NW_END_TRY
|
|
792 |
}
|
|
793 |
|
|
794 |
/* ------------------------------------------------------------------------- */
|
|
795 |
static
|
|
796 |
NW_Text_t*
|
|
797 |
NW_XHTML_ContentHandler_UnEscapeText (const NW_Text_t* text)
|
|
798 |
{
|
|
799 |
NW_Ucs2* origText = NULL;
|
|
800 |
NW_Bool freeOrigText = NW_FALSE;
|
|
801 |
NW_Ucs2* escapedText = NULL;
|
|
802 |
|
|
803 |
NW_ASSERT (text != NULL);
|
|
804 |
|
|
805 |
/* get the ucs2 string from text */
|
|
806 |
NW_THROWIF_NULL (origText = NW_Text_GetUCS2Buffer (text, NW_Text_Flags_NullTerminated |
|
|
807 |
NW_Text_Flags_Aligned, NULL, &freeOrigText));
|
|
808 |
|
|
809 |
/* unescape the text */
|
|
810 |
NW_THROWIF_NULL (escapedText = NW_Str_New(NW_Url_UnEscapeStringLen(origText)));
|
|
811 |
NW_Url_UnEscapeString(origText, escapedText);
|
|
812 |
|
|
813 |
if (freeOrigText == NW_TRUE)
|
|
814 |
{
|
|
815 |
NW_Str_Delete (origText);
|
|
816 |
}
|
|
817 |
|
|
818 |
/* create a new text item */
|
|
819 |
return (NW_Text_t*) NW_Text_UCS2_New ((void*) escapedText, 0, NW_Text_Flags_TakeOwnership);
|
|
820 |
|
|
821 |
NW_CATCH_ERROR
|
|
822 |
if (freeOrigText == NW_TRUE)
|
|
823 |
{
|
|
824 |
NW_Str_Delete (origText);
|
|
825 |
}
|
|
826 |
|
|
827 |
NW_Str_Delete (escapedText);
|
|
828 |
|
|
829 |
return NULL;
|
|
830 |
}
|
|
831 |
|
|
832 |
// -----------------------------------------------------------------------------
|
|
833 |
TBrowserStatusCode
|
|
834 |
NW_XHTML_ContentHandler_ShowFragment (NW_XHTML_ContentHandler_t* thisObj,
|
|
835 |
const NW_Text_t* fragment)
|
|
836 |
{
|
|
837 |
NW_HED_DocumentRoot_t* docRoot = NULL;
|
|
838 |
NW_Bool mustCallCompleted = NW_FALSE;
|
|
839 |
TBrowserStatusCode status = KBrsrFailure;
|
|
840 |
|
|
841 |
docRoot = (NW_HED_DocumentRoot_t*) NW_HED_DocumentNode_GetRootNode (thisObj);
|
|
842 |
NW_THROWIF_NULL (docRoot);
|
|
843 |
|
|
844 |
/* notify the docRoot that we are performing an intra-document navigation */
|
|
845 |
NW_THROWIF_ERROR (status = NW_HED_DocumentRoot_HandleIntraPageNavigationStarted (docRoot));
|
|
846 |
mustCallCompleted = NW_TRUE;
|
|
847 |
|
|
848 |
/* navigate to the fragment */
|
|
849 |
if (fragment != NULL)
|
|
850 |
{
|
|
851 |
NW_LMgr_Box_t* boxTree;
|
|
852 |
NW_Text_t* frag = NULL;
|
|
853 |
|
|
854 |
/* unescape the fragment */
|
|
855 |
frag = NW_XHTML_ContentHandler_UnEscapeText (fragment);
|
|
856 |
|
|
857 |
/* show the box */
|
|
858 |
status = NW_HED_DocumentNode_GetBoxTree (thisObj, &boxTree);
|
|
859 |
status = docRoot->documentListener->ShowNamedBox (boxTree, frag);
|
|
860 |
NW_Object_Delete (frag);
|
|
861 |
|
|
862 |
if (status != KBrsrSuccess && status != KBrsrNotFound)
|
|
863 |
{
|
|
864 |
NW_HED_DocumentNode_HandleError (thisObj, NULL,
|
|
865 |
BRSR_STAT_CLASS_GENERAL, (NW_WaeError_t) status);
|
|
866 |
}
|
|
867 |
NW_THROWIF_ERROR(status);
|
|
868 |
}
|
|
869 |
|
|
870 |
/* "navigate" to the top */
|
|
871 |
/* TODO see if there is a better way to "scroll" to the top */
|
|
872 |
else
|
|
873 |
{
|
|
874 |
(void) NW_HED_DocumentNode_NodeChanged (thisObj, NULL);
|
|
875 |
}
|
|
876 |
|
|
877 |
/* notify the docRoot that we are done navigating */
|
|
878 |
NW_HED_DocumentRoot_HandleIntraPageNavigationCompleted (docRoot);
|
|
879 |
|
|
880 |
return KBrsrSuccess;
|
|
881 |
|
|
882 |
NW_CATCH_ERROR
|
|
883 |
if (mustCallCompleted == NW_TRUE)
|
|
884 |
{
|
|
885 |
NW_HED_DocumentRoot_HandleIntraPageNavigationCompleted (docRoot);
|
|
886 |
}
|
|
887 |
|
|
888 |
return status;
|
|
889 |
}
|
|
890 |
|
|
891 |
// -----------------------------------------------------------------------------
|
|
892 |
static
|
|
893 |
TBrowserStatusCode
|
|
894 |
NW_XHTML_ContentHandler_GetFragment (NW_XHTML_ContentHandler_t* thisObj,
|
|
895 |
const NW_Text_t* url,
|
|
896 |
const NW_Text_t** fragment)
|
|
897 |
{
|
|
898 |
TBrowserStatusCode status = KBrsrFailure;
|
|
899 |
const NW_Ucs2* urlStorage = NULL;
|
|
900 |
NW_Text_Length_t urlLength;
|
|
901 |
NW_Uint8 urlFreeNeeded = NW_FALSE;
|
|
902 |
NW_Ucs2* fragmentStorage = NULL;
|
|
903 |
const NW_Ucs2* currentUrlStorage = NULL;
|
|
904 |
NW_Ucs2* urlBase = NULL;
|
|
905 |
NW_Ucs2* currentUrlBase = NULL;
|
|
906 |
NW_Int32 match;
|
|
907 |
|
|
908 |
/* pram check */
|
|
909 |
NW_THROWIF_NULL (url);
|
|
910 |
NW_THROWIF_NULL (fragment);
|
|
911 |
|
|
912 |
*fragment = NULL;
|
|
913 |
|
|
914 |
/* get the base urls */
|
|
915 |
NW_THROWIF_NULL (urlStorage = NW_Text_GetUCS2Buffer (url, NW_Text_Flags_Aligned,
|
|
916 |
&urlLength, &urlFreeNeeded));
|
|
917 |
|
|
918 |
if (NW_XHTML_ContentHandler_IsSaveddeck(thisObj))
|
|
919 |
{
|
|
920 |
NW_THROWIF_NULL (currentUrlStorage = NW_HED_UrlResponse_GetRawUrl (
|
|
921 |
NW_HED_ContentHandler_GetUrlResponse (thisObj)));
|
|
922 |
}
|
|
923 |
else
|
|
924 |
{
|
|
925 |
NW_THROWIF_NULL (currentUrlStorage = NW_HED_UrlRequest_GetRawUrl (
|
|
926 |
NW_HED_ContentHandler_GetUrlRequest (thisObj)));
|
|
927 |
}
|
|
928 |
|
|
929 |
NW_THROWIF_ERROR (status = NW_Url_GetBase(urlStorage, &urlBase));
|
|
930 |
NW_THROWIF_ERROR (status = NW_Url_GetBase(currentUrlStorage, ¤tUrlBase));
|
|
931 |
|
|
932 |
/* compare the current url with the specified */
|
|
933 |
match = (NW_Str_Strlen (currentUrlBase) != NW_Str_Strlen (urlBase)) || NW_Str_Strncmp (currentUrlBase, urlBase, NW_Str_Strlen (currentUrlStorage));
|
|
934 |
|
|
935 |
/* create the fragment Text object */
|
|
936 |
if (match == 0)
|
|
937 |
{
|
|
938 |
if (NW_Url_GetFragId (urlStorage, &fragmentStorage, 0) == KBrsrSuccess)
|
|
939 |
{
|
|
940 |
*fragment = (NW_Text_t*)
|
|
941 |
NW_Text_UCS2_New (fragmentStorage, 0, NW_Text_Flags_TakeOwnership);
|
|
942 |
}
|
|
943 |
|
|
944 |
/*
|
|
945 |
** else the frag is missing. In this case we want to show the page's default
|
|
946 |
** fragment (the top of the page). This is done by returning a null fragment
|
|
947 |
** with a return value of KBrsrSuccess.
|
|
948 |
*/
|
|
949 |
}
|
|
950 |
|
|
951 |
/* the url bases do not match so return failure */
|
|
952 |
else
|
|
953 |
{
|
|
954 |
NW_Mem_Free (fragmentStorage);
|
|
955 |
|
|
956 |
status = KBrsrFailure;
|
|
957 |
NW_THROW_ERROR();
|
|
958 |
}
|
|
959 |
|
|
960 |
/* clean up after us */
|
|
961 |
if (urlFreeNeeded)
|
|
962 |
{
|
|
963 |
NW_Mem_Free ((NW_Ucs2*) urlStorage);
|
|
964 |
urlFreeNeeded = NW_FALSE;
|
|
965 |
}
|
|
966 |
|
|
967 |
NW_Mem_Free ((NW_Ucs2*) urlBase);
|
|
968 |
NW_Mem_Free ((NW_Ucs2*) currentUrlBase);
|
|
969 |
|
|
970 |
return KBrsrSuccess;
|
|
971 |
|
|
972 |
NW_CATCH_ERROR
|
|
973 |
if (urlFreeNeeded)
|
|
974 |
{
|
|
975 |
NW_Mem_Free ((NW_Ucs2*) urlStorage);
|
|
976 |
}
|
|
977 |
|
|
978 |
NW_Mem_Free (fragmentStorage);
|
|
979 |
NW_Mem_Free ((NW_Ucs2*) urlBase);
|
|
980 |
NW_Mem_Free ((NW_Ucs2*) currentUrlBase);
|
|
981 |
|
|
982 |
return status;
|
|
983 |
}
|
|
984 |
|
|
985 |
// -----------------------------------------------------------------------------
|
|
986 |
static
|
|
987 |
TBrowserStatusCode
|
|
988 |
NW_XHTML_ContentHandler_LoadFragment (NW_XHTML_ContentHandler_t* thisObj,
|
|
989 |
NW_HED_UrlRequest_t* urlRequest)
|
|
990 |
{
|
|
991 |
NW_HED_DocumentRoot_t* docRoot = NULL;
|
|
992 |
NW_HED_HistoryStack_t* history = NULL;
|
|
993 |
NW_HED_HistoryEntry_t* entry = NULL;
|
|
994 |
NW_HED_HistoryEntry_t* currentEntry = NULL;
|
|
995 |
const NW_Text_t* url = NULL;
|
|
996 |
const NW_Text_t* fragment = NULL;
|
|
997 |
TBrowserStatusCode status = KBrsrFailure;
|
|
998 |
|
|
999 |
docRoot = (NW_HED_DocumentRoot_t*) NW_HED_DocumentNode_GetRootNode (thisObj);
|
|
1000 |
NW_THROWIF_NULL (docRoot);
|
|
1001 |
|
|
1002 |
NW_THROWIF_NULL (history = NW_HED_DocumentRoot_GetHistoryStack (docRoot));
|
|
1003 |
|
|
1004 |
/*
|
|
1005 |
** get the fragment, an error will be thrown if the url's base doesn't match the
|
|
1006 |
** base of the url used to load this content handler.
|
|
1007 |
*/
|
|
1008 |
NW_THROWIF_NULL (url = NW_HED_UrlRequest_GetUrl (urlRequest));
|
|
1009 |
NW_THROWIF_ERROR (status = NW_XHTML_ContentHandler_GetFragment (thisObj, url,
|
|
1010 |
(const NW_Text_t**) & fragment));
|
|
1011 |
|
|
1012 |
/* urls that don't contain a fragment shouldn't be handled internally. */
|
|
1013 |
if (fragment == NULL)
|
|
1014 |
{
|
|
1015 |
status = KBrsrFailure;
|
|
1016 |
NW_THROW_ERROR ();
|
|
1017 |
}
|
|
1018 |
|
|
1019 |
/* show the frag */
|
|
1020 |
status = NW_XHTML_ContentHandler_ShowFragment (thisObj, fragment);
|
|
1021 |
if (status != KBrsrNotFound)
|
|
1022 |
{
|
|
1023 |
|
|
1024 |
NW_THROWIF_ERROR(status);
|
|
1025 |
|
|
1026 |
/* add history entry */
|
|
1027 |
if (NW_HED_UrlRequest_IsHistoricRequest (urlRequest) == NW_FALSE)
|
|
1028 |
{
|
|
1029 |
NW_THROWIF_NULL (entry = NW_HED_ContentHandler_CreateIntraDocumentHistoryEntry (thisObj,
|
|
1030 |
url, url));
|
|
1031 |
NW_THROWIF_ERROR (status = NW_HED_HistoryStack_PushEntry (history, entry));
|
|
1032 |
entry = NULL;
|
|
1033 |
|
|
1034 |
NW_Object_Delete (urlRequest);
|
|
1035 |
urlRequest = NULL;
|
|
1036 |
}
|
|
1037 |
|
|
1038 |
/* update the content handler to point to the associated history entry */
|
|
1039 |
NW_THROWIF_NULL (currentEntry = NW_HED_HistoryStack_GetEntry (history,
|
|
1040 |
NW_HED_HistoryStack_Direction_Current));
|
|
1041 |
NW_THROWIF_ERROR (status = NW_HED_ContentHandler_SetAssociatedHistoryEntry (
|
|
1042 |
thisObj, currentEntry));
|
|
1043 |
|
|
1044 |
}
|
|
1045 |
|
|
1046 |
NW_Object_Delete ((NW_Text_t*) fragment);
|
|
1047 |
|
|
1048 |
return KBrsrSuccess;
|
|
1049 |
|
|
1050 |
NW_CATCH_ERROR
|
|
1051 |
NW_Object_Delete ((NW_Text_t*) fragment);
|
|
1052 |
NW_Object_Delete (entry);
|
|
1053 |
|
|
1054 |
return status;
|
|
1055 |
}
|
|
1056 |
|
|
1057 |
// -----------------------------------------------------------------------------
|
|
1058 |
static
|
|
1059 |
TBrowserStatusCode
|
|
1060 |
NW_XHTML_ContentHandler_DeleteFormLiaison (NW_XHTML_ContentHandler_t* thisObj)
|
|
1061 |
{
|
|
1062 |
NW_ADT_Vector_Metric_t nodeCtxSize = NW_ADT_Vector_GetSize(thisObj->nodeContexts);
|
|
1063 |
for (NW_ADT_Vector_Metric_t i = 0 ; i < nodeCtxSize; i++)
|
|
1064 |
{
|
|
1065 |
NW_XHTML_Form_Node_Context_t* formCtx =
|
|
1066 |
*(NW_XHTML_Form_Node_Context_t**)NW_ADT_Vector_ElementAt
|
|
1067 |
(thisObj->nodeContexts, i);
|
|
1068 |
NW_XHTML_FormLiaison_t* formLiaison = (NW_XHTML_FormLiaison_t*)formCtx->formLiaison;
|
|
1069 |
NW_Object_Delete(formLiaison);
|
|
1070 |
formCtx->formLiaison = NULL;
|
|
1071 |
delete formCtx ;
|
|
1072 |
}
|
|
1073 |
return KBrsrSuccess;
|
|
1074 |
}
|
|
1075 |
|
|
1076 |
// -----------------------------------------------------------------------------
|
|
1077 |
static
|
|
1078 |
TBrowserStatusCode
|
|
1079 |
NW_XHTML_ContentHandler_RestoreControlSet (NW_XHTML_ContentHandler_t* thisObj)
|
|
1080 |
{
|
|
1081 |
NW_HED_DocumentRoot_t* documentRoot;
|
|
1082 |
NW_HED_HistoryEntry_t* entry;
|
|
1083 |
NW_Object_Dynamic_t* controlValueSet;
|
|
1084 |
const NW_HED_UrlRequest_t *urlReq;
|
|
1085 |
|
|
1086 |
documentRoot =
|
|
1087 |
(NW_HED_DocumentRoot_t*) NW_HED_DocumentNode_GetRootNode (thisObj);
|
|
1088 |
NW_THROWIF_NULL (documentRoot);
|
|
1089 |
|
|
1090 |
NW_THROWIF_NULL (entry = NW_HED_HistoryStack_GetEntry (documentRoot->historyStack,
|
|
1091 |
NW_HED_HistoryStack_Direction_Current));
|
|
1092 |
|
|
1093 |
NW_THROWIF_NULL (urlReq = NW_HED_HistoryEntry_GetUrlRequest (entry));
|
|
1094 |
|
|
1095 |
NW_THROWIF_NULL (thisObj->historyContentData =
|
|
1096 |
NW_HED_HistoryEntry_GetContentDataHolder (entry));
|
|
1097 |
|
|
1098 |
NW_THROWIF_ERROR(NW_Object_Shared_OrphanObject(thisObj->historyContentData,
|
|
1099 |
&controlValueSet));
|
|
1100 |
|
|
1101 |
/*
|
|
1102 |
** clear the cached form values if we are reloading the document,
|
|
1103 |
** otherwise restore them.
|
|
1104 |
*/
|
|
1105 |
if (NW_HED_UrlRequest_GetReason (urlReq) == NW_HED_UrlRequest_Reason_ShellReload)
|
|
1106 |
{
|
|
1107 |
NW_Object_Delete (controlValueSet);
|
|
1108 |
}
|
|
1109 |
else
|
|
1110 |
{
|
|
1111 |
thisObj->controlValueSet = NW_ADT_DynamicVectorOf(controlValueSet);
|
|
1112 |
}
|
|
1113 |
|
|
1114 |
return KBrsrSuccess;
|
|
1115 |
|
|
1116 |
NW_CATCH_ERROR
|
|
1117 |
return KBrsrFailure;
|
|
1118 |
}
|
|
1119 |
|
|
1120 |
// -----------------------------------------------------------------------------
|
|
1121 |
static
|
|
1122 |
NW_HED_Context_t*
|
|
1123 |
NW_XHTML_GetGlobalContext (NW_XHTML_ContentHandler_t* thisObj)
|
|
1124 |
{
|
|
1125 |
#if 1 /* use this one if we want to support wml-variables in xhtml */
|
|
1126 |
NW_HED_DocumentRoot_t* docRoot = NULL;
|
|
1127 |
|
|
1128 |
docRoot = (NW_HED_DocumentRoot_t*) NW_HED_DocumentNode_GetRootNode (thisObj);
|
|
1129 |
|
|
1130 |
return NW_HED_DocumentRoot_GetContext (docRoot, NW_HED_DocumentRoot_ContextGlobalId);
|
|
1131 |
#else /* otherwise use this one */
|
|
1132 |
|
|
1133 |
NW_REQUIRED_PARAM (thisObj);
|
|
1134 |
|
|
1135 |
return NULL;
|
|
1136 |
#endif
|
|
1137 |
|
|
1138 |
}
|
|
1139 |
|
|
1140 |
// -----------------------------------------------------------------------------
|
|
1141 |
static
|
|
1142 |
TBrowserStatusCode
|
|
1143 |
NW_XHTML_ContentHandler_MetaRefreshCreateTimer(NW_XHTML_ContentHandler_t* thisObj)
|
|
1144 |
{
|
|
1145 |
NW_ASSERT(thisObj);
|
|
1146 |
|
|
1147 |
NW_TRY (status)
|
|
1148 |
{
|
|
1149 |
if (thisObj->metaRefreshTimer == NULL)
|
|
1150 |
{
|
|
1151 |
thisObj->metaRefreshTimer =
|
|
1152 |
NW_System_Timer_New(NW_XHTML_ContentHandler_MetaRefreshTimerCallback,
|
|
1153 |
thisObj, (thisObj->metaRefreshSeconds * 1000), NW_FALSE);
|
|
1154 |
NW_THROW_OOM_ON_NULL(thisObj->metaRefreshTimer, status);
|
|
1155 |
}
|
|
1156 |
}
|
|
1157 |
NW_CATCH (status)
|
|
1158 |
{}
|
|
1159 |
NW_FINALLY {
|
|
1160 |
return status;
|
|
1161 |
} NW_END_TRY
|
|
1162 |
}
|
|
1163 |
|
|
1164 |
// -----------------------------------------------------------------------------
|
|
1165 |
static
|
|
1166 |
void
|
|
1167 |
NW_XHTML_ContentHandler_MetaRefreshDestroyTimer(NW_XHTML_ContentHandler_t* thisObj)
|
|
1168 |
{
|
|
1169 |
NW_ASSERT(thisObj);
|
|
1170 |
|
|
1171 |
if (thisObj->metaRefreshTimer != NULL)
|
|
1172 |
{
|
|
1173 |
NW_Object_Delete (thisObj->metaRefreshTimer);
|
|
1174 |
thisObj->metaRefreshTimer = NULL;
|
|
1175 |
}
|
|
1176 |
}
|
|
1177 |
|
|
1178 |
// -----------------------------------------------------------------------------
|
|
1179 |
static
|
|
1180 |
void
|
|
1181 |
NW_XHTML_ContentHandler_MetaRefreshSuspendTimer(NW_XHTML_ContentHandler_t* thisObj)
|
|
1182 |
{
|
|
1183 |
NW_ASSERT(thisObj);
|
|
1184 |
|
|
1185 |
if (thisObj->metaRefreshTimer != NULL)
|
|
1186 |
{
|
|
1187 |
/* return status is ignored */
|
|
1188 |
(void) NW_System_Timer_Stop(thisObj->metaRefreshTimer);
|
|
1189 |
}
|
|
1190 |
}
|
|
1191 |
|
|
1192 |
// -----------------------------------------------------------------------------
|
|
1193 |
static
|
|
1194 |
void
|
|
1195 |
NW_XHTML_ContentHandler_MetaRefreshResumeTimer(NW_XHTML_ContentHandler_t* thisObj)
|
|
1196 |
{
|
|
1197 |
NW_ASSERT(thisObj);
|
|
1198 |
|
|
1199 |
if (thisObj->metaRefreshTimer != NULL)
|
|
1200 |
{
|
|
1201 |
/* return status is ignored */
|
|
1202 |
(void) NW_System_Timer_Resume(thisObj->metaRefreshTimer);
|
|
1203 |
}
|
|
1204 |
}
|
|
1205 |
|
|
1206 |
// -----------------------------------------------------------------------------
|
|
1207 |
static
|
|
1208 |
TBrowserStatusCode
|
|
1209 |
NW_XHTML_ContentHandler_MetaRefreshStartLoad(NW_XHTML_ContentHandler_t* thisObj)
|
|
1210 |
{
|
|
1211 |
NW_HED_DocumentRoot_t* docRoot;
|
|
1212 |
|
|
1213 |
NW_ASSERT(thisObj);
|
|
1214 |
|
|
1215 |
NW_ASSERT(thisObj->metaRefreshResolvedUrl);
|
|
1216 |
|
|
1217 |
NW_TRY (status)
|
|
1218 |
{
|
|
1219 |
docRoot = (NW_HED_DocumentRoot_t*) NW_HED_DocumentNode_GetRootNode(thisObj);
|
|
1220 |
NW_THROWIF_NULL(docRoot);
|
|
1221 |
|
|
1222 |
status = NW_HED_DocumentRoot_StartLoad(docRoot,
|
|
1223 |
NW_HED_DocumentNodeOf(docRoot),
|
|
1224 |
thisObj->metaRefreshResolvedUrl,
|
|
1225 |
thisObj->metaRefreshLoadReason,
|
|
1226 |
NULL,
|
|
1227 |
NW_UrlRequest_Type_Any, NW_CACHE_NOCACHE);
|
|
1228 |
_NW_THROW_ON_ERROR(status);
|
|
1229 |
}
|
|
1230 |
NW_CATCH (status)
|
|
1231 |
{
|
|
1232 |
NW_CATCH_ERROR
|
|
1233 |
if (status != KBrsrSuccess)
|
|
1234 |
{
|
|
1235 |
NW_HED_DocumentNode_HandleError(thisObj,
|
|
1236 |
NW_HED_ContentHandler_GetUrlRequest(thisObj),
|
|
1237 |
BRSR_STAT_CLASS_GENERAL,
|
|
1238 |
(NW_WaeError_t) status);
|
|
1239 |
}
|
|
1240 |
}
|
|
1241 |
NW_FINALLY {
|
|
1242 |
/* metaRefreshResolvedUrl will never be used again. */
|
|
1243 |
if (thisObj->metaRefreshResolvedUrl != NULL)
|
|
1244 |
{
|
|
1245 |
NW_Object_Delete (thisObj->metaRefreshResolvedUrl);
|
|
1246 |
thisObj->metaRefreshResolvedUrl = NULL;
|
|
1247 |
}
|
|
1248 |
return status;
|
|
1249 |
} NW_END_TRY
|
|
1250 |
}
|
|
1251 |
|
|
1252 |
// -----------------------------------------------------------------------------
|
|
1253 |
static
|
|
1254 |
TBrowserStatusCode
|
|
1255 |
NW_XHTML_ContentHandler_MetaRefreshTimerCallback(void* timerData)
|
|
1256 |
{
|
|
1257 |
TBrowserStatusCode status;
|
|
1258 |
NW_XHTML_ContentHandler_t* thisObj;
|
|
1259 |
|
|
1260 |
NW_ASSERT(timerData);
|
|
1261 |
|
|
1262 |
/* cast timerData to aggregate */
|
|
1263 |
thisObj = NW_XHTML_ContentHandlerOf(timerData);
|
|
1264 |
|
|
1265 |
NW_XHTML_ContentHandler_MetaRefreshDestroyTimer(thisObj);
|
|
1266 |
status = NW_XHTML_ContentHandler_MetaRefreshStartLoad(thisObj);
|
|
1267 |
|
|
1268 |
return status;
|
|
1269 |
}
|
|
1270 |
|
|
1271 |
|
|
1272 |
// -----------------------------------------------------------------------------
|
|
1273 |
static
|
|
1274 |
void
|
|
1275 |
NW_XHTML_ContentHandler_ActivateImageMapBox( NW_XHTML_ContentHandler_t* thisObj )
|
|
1276 |
{
|
|
1277 |
NW_ASSERT( thisObj );
|
|
1278 |
|
|
1279 |
// loop through the image map boxes and create area list for each of them
|
|
1280 |
if ( thisObj->imageMapLookupTable )
|
|
1281 |
{
|
|
1282 |
// imageElement list
|
|
1283 |
CMapElementList* mapElementList = (CMapElementList*)thisObj->imageMapLookupTable;
|
|
1284 |
TInt mapElementCount = mapElementList->MapElementCount();
|
|
1285 |
for ( TInt i = 0; i < mapElementCount; i++ )
|
|
1286 |
{
|
|
1287 |
CMapElementEntry* entry = mapElementList->MapElementEntry( i );
|
|
1288 |
|
|
1289 |
// get image map boxes. note that one useMap can hold multiple
|
|
1290 |
// image map boxes.
|
|
1291 |
CImageMapBoxList* imageMapBoxList = entry->ImageMapBoxList();
|
|
1292 |
NW_DOM_ElementNode_t* domNode = entry->DomNode();
|
|
1293 |
// initailaze image map unless either the <img usemap= or
|
|
1294 |
// <map name= is missing.
|
|
1295 |
if ( imageMapBoxList && domNode )
|
|
1296 |
{
|
|
1297 |
TInt imageListCount = imageMapBoxList->Count();
|
|
1298 |
for ( TInt j = 0; j < imageListCount; j++ )
|
|
1299 |
{
|
|
1300 |
// get image element handler
|
|
1301 |
const NW_XHTML_ElementHandler_t* imageElementHandler =
|
|
1302 |
NW_XHTML_ElementHandlerOf( &NW_XHTML_imgElementHandler );
|
|
1303 |
NW_LMgr_ImageMapBox_t* imageMapBox = imageMapBoxList->At( j );
|
|
1304 |
// call create area list on every image boxes unless the image box
|
|
1305 |
// has already been initialized with the area boxes -do not create
|
|
1306 |
// areaboxes twice
|
|
1307 |
if ( !NW_LMgr_ImageMapBox_GetAreaBoxList( imageMapBox ) )
|
|
1308 |
{
|
|
1309 |
// ignore return value
|
|
1310 |
(void)NW_XHTML_imgElementHandler_CreateAreaList(
|
|
1311 |
imageElementHandler, thisObj, domNode, NW_LMgr_BoxOf( imageMapBox ) );
|
|
1312 |
}
|
|
1313 |
}
|
|
1314 |
}
|
|
1315 |
}
|
|
1316 |
}
|
|
1317 |
}
|
|
1318 |
|
|
1319 |
// -----------------------------------------------------------------------------
|
|
1320 |
static
|
|
1321 |
TBrowserStatusCode
|
|
1322 |
NW_XHTML_ContentHandler_DeleteAllElementHandlerInstances(NW_XHTML_ContentHandler_t *thisObj)
|
|
1323 |
{
|
|
1324 |
NW_ADT_MapIterator_t iterator;
|
|
1325 |
|
|
1326 |
NW_Object_Invalidate (&iterator);
|
|
1327 |
|
|
1328 |
NW_TRY (status) {
|
|
1329 |
/* create an iterator */
|
|
1330 |
status = NW_ADT_MapIterator_Initialize (&iterator, thisObj->iElementHandlerMap);
|
|
1331 |
NW_THROW_ON_ERROR (status);
|
|
1332 |
|
|
1333 |
while (NW_ADT_Iterator_HasMoreElements (&iterator)) {
|
|
1334 |
void* key;
|
|
1335 |
CBase* elementHandler;
|
|
1336 |
|
|
1337 |
status = NW_ADT_Iterator_GetNextElement (&iterator, &key);
|
|
1338 |
NW_ASSERT (status == KBrsrSuccess);
|
|
1339 |
|
|
1340 |
status = NW_ADT_Map_Get (thisObj->iElementHandlerMap, &key, &elementHandler);
|
|
1341 |
NW_THROW_ON_ERROR (status);
|
|
1342 |
|
|
1343 |
if (elementHandler) {
|
|
1344 |
delete elementHandler;
|
|
1345 |
}
|
|
1346 |
}
|
|
1347 |
|
|
1348 |
NW_ADT_Map_Clear (thisObj->iElementHandlerMap);
|
|
1349 |
}
|
|
1350 |
|
|
1351 |
NW_CATCH (status) {
|
|
1352 |
}
|
|
1353 |
|
|
1354 |
NW_FINALLY {
|
|
1355 |
NW_Object_Terminate (&iterator);
|
|
1356 |
return status;
|
|
1357 |
} NW_END_TRY
|
|
1358 |
}
|
|
1359 |
|
|
1360 |
// -----------------------------------------------------------------------------
|
|
1361 |
const
|
|
1362 |
NW_XHTML_ContentHandler_Class_t NW_XHTML_ContentHandler_Class =
|
|
1363 |
{
|
|
1364 |
{ /* NW_Object_Core */
|
|
1365 |
/* super */ &NW_HED_CompositeContentHandler_Class,
|
|
1366 |
/* querySecondary */ _NW_Object_Base_QueryInterface
|
|
1367 |
},
|
|
1368 |
{ /* NW_Object_Base */
|
|
1369 |
/* interfaceList */ NW_XHTML_InterfaceList
|
|
1370 |
},
|
|
1371 |
{ /* NW_Object_Dynamic */
|
|
1372 |
/* instanceSize */ sizeof (NW_XHTML_ContentHandler_t),
|
|
1373 |
/* construct */ _NW_XHTML_ContentHandler_Construct,
|
|
1374 |
/* destruct */ _NW_XHTML_ContentHandler_Destruct
|
|
1375 |
},
|
|
1376 |
{ /* NW_HED_DocumentNode */
|
|
1377 |
/* cancel */ _NW_XHTML_ContentHandler_Cancel,
|
|
1378 |
/* partialLoadCallback */ NULL,
|
|
1379 |
/* initialize */ _NW_XHTML_ContentHandler_Initialize,
|
|
1380 |
/* nodeChanged */ _NW_HED_DocumentNode_NodeChanged,
|
|
1381 |
/* getBoxTree */ _NW_HED_ContentHandler_GetBoxTree,
|
|
1382 |
/* processEvent */ _NW_XHTML_ContentHandler_ProcessEvent,
|
|
1383 |
/* handleError */ _NW_HED_DocumentNode_HandleError,
|
|
1384 |
/* suspend */ _NW_XHTML_ContentHandler_Suspend,
|
|
1385 |
/* resume */ _NW_XHTML_CompositeContentHandler_Resume,
|
|
1386 |
/* allLoadsCompleted */ _NW_XHTML_ContentHandler_AllLoadsCompleted,
|
|
1387 |
/* intraPageNavigationCompleted */ _NW_HED_DocumentNode_IntraPageNavigationCompleted,
|
|
1388 |
/* loseFocus */ _NW_XHTML_ContentHandler_LoseFocus,
|
|
1389 |
/* gainFocus */ _NW_XHTML_ContentHandler_GainFocus,
|
|
1390 |
/* handleLoadComplete */ _NW_XHTML_DocumentNode_HandleLoadComplete,
|
|
1391 |
},
|
|
1392 |
{ /* NW_HED_ContentHandler */
|
|
1393 |
/* partialNextChunk */ _NW_XHTML_ContentHandler_PartialNextChunk,
|
|
1394 |
/* getTitle */ _NW_XHTML_ContentHandler_GetTitle,
|
|
1395 |
/* getUrl */ _NW_HED_ContentHandler_GetURL,
|
|
1396 |
/* resolveUrl */ _NW_XHTML_ContentHandler_ResolveURL,
|
|
1397 |
/* createHistoryEntry */ _NW_HED_ContentHandler_CreateHistoryEntry,
|
|
1398 |
/* createIntraHistoryEntry */ _NW_HED_ContentHandler_CreateIntraDocumentHistoryEntry,
|
|
1399 |
/* newUrlResponse */ _NW_HED_ContentHandler_NewUrlResponse,
|
|
1400 |
/* createBoxTree */ _NW_XHTML_ContentHandler_CreateBoxTree,
|
|
1401 |
/* handleRequest */ _NW_XHTML_ContentHandler_HandleRequest,
|
|
1402 |
/* featureQuery */ _NW_HED_ContentHandler_FeatureQuery,
|
|
1403 |
/* responseComplete */ _NW_HED_ContentHandler_ResponseComplete
|
|
1404 |
},
|
|
1405 |
{ /* NW_HED_CompositeContentHandler */
|
|
1406 |
/* documentDisplayed */ _NW_XHTML_ContentHandler_DocumentDisplayed,
|
|
1407 |
},
|
|
1408 |
/* (Kimono has this in Epoc32XhtmlContentHandler) */
|
|
1409 |
{ /* NW_XHTML_ContentHandler */
|
|
1410 |
/* numModules */ 0,
|
|
1411 |
/* modules */ NULL
|
|
1412 |
}
|
|
1413 |
};
|
|
1414 |
|
|
1415 |
// -----------------------------------------------------------------------------
|
|
1416 |
const
|
|
1417 |
NW_Object_Class_t* const NW_XHTML_InterfaceList[] =
|
|
1418 |
{
|
|
1419 |
&NW_XHTML_ContentHandler_NumberCollector_Class,
|
|
1420 |
NULL
|
|
1421 |
};
|
|
1422 |
|
|
1423 |
// -----------------------------------------------------------------------------
|
|
1424 |
const
|
|
1425 |
NW_Markup_NumberCollector_Class_t NW_XHTML_ContentHandler_NumberCollector_Class =
|
|
1426 |
{
|
|
1427 |
{ /* NW_Object_Core */
|
|
1428 |
/* super */ &NW_Markup_NumberCollector_Class,
|
|
1429 |
/* querySecondary */ _NW_Object_Core_QuerySecondary
|
|
1430 |
},
|
|
1431 |
{ /* NW_Object_Secondary */
|
|
1432 |
/* offset */ offsetof (NW_XHTML_ContentHandler_t,
|
|
1433 |
NW_Markup_NumberCollector)
|
|
1434 |
},
|
|
1435 |
{ /* NW_Object_Aggregate */
|
|
1436 |
/* secondaryList */ _NW_Markup_NumberCollector_SecondaryList,
|
|
1437 |
/* construct */ NULL,
|
|
1438 |
/* destruct */ NULL
|
|
1439 |
},
|
|
1440 |
{ /* NW_Markup_NumberCollector */
|
|
1441 |
/* getBoxTree */ _NW_XHTML_ContentHandler_NumberCollector_GetBoxTree,
|
|
1442 |
/* boxIsValid */ _NW_Markup_NumberCollector_BoxIsValid,
|
|
1443 |
/* getHrefAttr */ _NW_XHTML_ContentHandler_NumberCollector_GetHrefAttr,
|
|
1444 |
/* getAltAttr */ _NW_XHTML_ContentHandler_NumberCollector_GetAltAttr
|
|
1445 |
}
|
|
1446 |
};
|
|
1447 |
|
|
1448 |
/* ------------------------------------------------------------------------- *
|
|
1449 |
virtual methods
|
|
1450 |
* ------------------------------------------------------------------------- */
|
|
1451 |
|
|
1452 |
// -----------------------------------------------------------------------------
|
|
1453 |
TBrowserStatusCode
|
|
1454 |
_NW_XHTML_ContentHandler_Construct (NW_Object_Dynamic_t* dynamicObject,
|
|
1455 |
va_list* argp)
|
|
1456 |
{
|
|
1457 |
NW_XHTML_ContentHandler_t* thisObj;
|
|
1458 |
TBrowserStatusCode status;
|
|
1459 |
const NW_HED_UrlRequest_t* urlRequest;
|
|
1460 |
|
|
1461 |
NW_LOG0(NW_LOG_LEVEL2, "NW_XHTML_ContentHandler_Construct START");
|
|
1462 |
/* for convenience */
|
|
1463 |
thisObj = NW_XHTML_ContentHandlerOf (dynamicObject);
|
|
1464 |
|
|
1465 |
/* invoke our superclass constructor */
|
|
1466 |
status = _NW_HED_CompositeContentHandler_Construct (dynamicObject, argp);
|
|
1467 |
if (status != KBrsrSuccess)
|
|
1468 |
{
|
|
1469 |
return status;
|
|
1470 |
}
|
|
1471 |
|
|
1472 |
thisObj->domTree = NULL;
|
|
1473 |
thisObj->title = NULL;
|
|
1474 |
thisObj->baseElement = NULL;
|
|
1475 |
thisObj->contentLocation = NULL;
|
|
1476 |
thisObj->iBodyNode = NULL;
|
|
1477 |
thisObj->nodeContexts = (NW_ADT_DynamicVector_t*)
|
|
1478 |
NW_ADT_ResizableVector_New (sizeof (NW_XHTML_Form_Node_Context_t*),
|
|
1479 |
0, 5);
|
|
1480 |
|
|
1481 |
if (thisObj->nodeContexts == NULL)
|
|
1482 |
{
|
|
1483 |
return KBrsrOutOfMemory;
|
|
1484 |
}
|
|
1485 |
thisObj->iElementHandlerMap = (NW_ADT_Map_t*) NW_ADT_ResizableMap_New (
|
|
1486 |
sizeof(NW_DOM_ElementNode_t*), sizeof(CBase*), 1, 1);
|
|
1487 |
|
|
1488 |
if (thisObj->iElementHandlerMap == NULL)
|
|
1489 |
{
|
|
1490 |
NW_Object_Delete(thisObj->nodeContexts);
|
|
1491 |
thisObj->nodeContexts = NULL;
|
|
1492 |
|
|
1493 |
return KBrsrOutOfMemory;
|
|
1494 |
}
|
|
1495 |
|
|
1496 |
thisObj->processor = NULL;
|
|
1497 |
thisObj->historyContentData = NULL;
|
|
1498 |
thisObj->controlValueSet = NULL;
|
|
1499 |
thisObj->controlSet = NULL;
|
|
1500 |
thisObj->saveddeck = NW_FALSE;
|
|
1501 |
thisObj->histload = NW_FALSE;
|
|
1502 |
thisObj->reload = NW_FALSE;
|
|
1503 |
|
|
1504 |
thisObj->htmlSubset = NW_XHTML_CONTENTHANDLER_IMODEHTMLEXT;
|
|
1505 |
thisObj->metaRefreshSet = NW_FALSE;
|
|
1506 |
thisObj->metaRefreshResolvedUrl = NULL;
|
|
1507 |
thisObj->metaRefreshTimer = NULL;
|
|
1508 |
|
|
1509 |
thisObj->ignoreFramesetElement = NW_FALSE;
|
|
1510 |
thisObj->ignoreBodyElement = NW_FALSE;
|
|
1511 |
thisObj->ignoreNoScriptElement = NW_TRUE;
|
|
1512 |
|
|
1513 |
thisObj->imageMapLookupTable = NULL;
|
|
1514 |
|
|
1515 |
// ZAL: find a better init value
|
|
1516 |
thisObj->lastInitializedDomNode = 0;
|
|
1517 |
|
|
1518 |
thisObj->stopInitEH = NW_FALSE;
|
|
1519 |
thisObj->lastChunk = NW_FALSE;
|
|
1520 |
thisObj->iScriptIsExecuted = NW_FALSE;
|
|
1521 |
thisObj->iScriptIsResumed = NW_FALSE;
|
|
1522 |
|
|
1523 |
//
|
|
1524 |
thisObj->switchBackToNormalLayout = NW_FALSE;
|
|
1525 |
|
|
1526 |
thisObj->formattingComplete = NW_FALSE;
|
|
1527 |
|
|
1528 |
thisObj->scriptLoadComplete = NW_FALSE;
|
|
1529 |
|
|
1530 |
thisObj->iBodyIsPresent = NW_FALSE;
|
|
1531 |
|
|
1532 |
thisObj->metaNoCache = NW_FALSE;
|
|
1533 |
thisObj->metaCacheExpires = NW_FALSE;
|
|
1534 |
thisObj->metaExpiresDate = NULL;
|
|
1535 |
|
|
1536 |
thisObj->iScriptCancelled = NW_FALSE;
|
|
1537 |
thisObj->scriptLoadTransactionIds = (void*)(new RArray<TExternalScriptNode>);
|
|
1538 |
if (!thisObj->scriptLoadTransactionIds)
|
|
1539 |
{
|
|
1540 |
return KBrsrOutOfMemory;
|
|
1541 |
}
|
|
1542 |
|
|
1543 |
thisObj->scriptNodes = (void*)(new RPointerArray<NW_XHTML_Script_Node_Context_t>(1));
|
|
1544 |
if (!thisObj->scriptNodes)
|
|
1545 |
{
|
|
1546 |
return KBrsrOutOfMemory;
|
|
1547 |
}
|
|
1548 |
|
|
1549 |
thisObj->formNodes = (void*)(new RPointerArray<NW_DOM_ElementNode_t>(1));
|
|
1550 |
|
|
1551 |
if (!thisObj->formNodes)
|
|
1552 |
{
|
|
1553 |
return KBrsrOutOfMemory;
|
|
1554 |
}
|
|
1555 |
|
|
1556 |
TRAPD(ret, thisObj->iMessageListener = new (ELeave) TMessageListener (thisObj));
|
|
1557 |
if (ret == KErrNoMemory)
|
|
1558 |
{
|
|
1559 |
return KBrsrOutOfMemory;
|
|
1560 |
}
|
|
1561 |
|
|
1562 |
/*
|
|
1563 |
** reset the global context if the request that created the content-handler
|
|
1564 |
** was started from a shell request, like the goto dialog or
|
|
1565 |
** hotlist dialog. See WML June2000 Specification section 10.4.
|
|
1566 |
*/
|
|
1567 |
urlRequest = va_arg (*argp, NW_HED_UrlRequest_t*);
|
|
1568 |
NW_ASSERT (urlRequest);
|
|
1569 |
NW_ASSERT (NW_Object_IsInstanceOf (urlRequest, &NW_HED_UrlRequest_Class));
|
|
1570 |
|
|
1571 |
if (NW_HED_UrlRequest_GetReason (urlRequest) == NW_HED_UrlRequest_Reason_ShellLoad)
|
|
1572 |
{
|
|
1573 |
NW_HED_Context_t* context;
|
|
1574 |
|
|
1575 |
context = NW_XHTML_GetGlobalContext (thisObj);
|
|
1576 |
|
|
1577 |
NW_HED_Context_Reset (context);
|
|
1578 |
}
|
|
1579 |
|
|
1580 |
/*
|
|
1581 |
* Initialize a local copy of the CCSSVariableStyleSheet. Note that
|
|
1582 |
* if it already exists this will efficiently get a copy of the
|
|
1583 |
* reference. If not then it will be created on the spot.
|
|
1584 |
*/
|
|
1585 |
thisObj->variableStyleSheet = CCSSVariableStyleSheet::CreateSingleton();
|
|
1586 |
|
|
1587 |
NW_LOG0(NW_LOG_LEVEL2, "NW_XHTML_ContentHandler_Construct END");
|
|
1588 |
/* successful completion */
|
|
1589 |
return KBrsrSuccess;
|
|
1590 |
}
|
|
1591 |
|
|
1592 |
// -----------------------------------------------------------------------------
|
|
1593 |
void
|
|
1594 |
_NW_XHTML_ContentHandler_Destruct (NW_Object_Dynamic_t* dynamicObject)
|
|
1595 |
{
|
|
1596 |
NW_XHTML_ContentHandler_t* thisObj;
|
|
1597 |
|
|
1598 |
/* cast the 'object' for convenience */
|
|
1599 |
thisObj = NW_XHTML_ContentHandlerOf (dynamicObject);
|
|
1600 |
|
|
1601 |
if (thisObj->iBodyNode && NW_Settings_GetEcmaScriptEnabled())
|
|
1602 |
{
|
|
1603 |
NW_HED_DocumentRoot_t* documentRoot = (NW_HED_DocumentRoot_t*) NW_HED_DocumentNode_GetRootNode (thisObj);
|
|
1604 |
if (!documentRoot->documentListener->Exiting())
|
|
1605 |
{
|
|
1606 |
#if !defined(__SERIES60_28__) && !defined(__SERIES60_27__)
|
|
1607 |
// Don't execute scripts if the browser is exiting. It will crash
|
|
1608 |
//R->ecma
|
|
1609 |
//NW_Ecma_HandleEvent(documentRoot , thisObj->iBodyNode, thisObj->iBodyNode, NW_Ecma_Evt_OnUnload);
|
|
1610 |
#endif
|
|
1611 |
}
|
|
1612 |
}
|
|
1613 |
|
|
1614 |
NW_XHTML_ContentHandler_DeleteFormLiaison (thisObj);
|
|
1615 |
|
|
1616 |
|
|
1617 |
NW_HED_DomTree_Delete (thisObj->domTree);
|
|
1618 |
thisObj->domTree = NULL;
|
|
1619 |
thisObj->baseElement = NULL;
|
|
1620 |
NW_Str_Delete(thisObj->contentLocation);
|
|
1621 |
NW_Object_Delete (thisObj->title);
|
|
1622 |
thisObj->title = NULL;
|
|
1623 |
thisObj->iScriptIsResumed = NW_FALSE;
|
|
1624 |
|
|
1625 |
// if the document root reference the referrer url from this document
|
|
1626 |
// set it to NULL
|
|
1627 |
NW_HED_DocumentRoot_t* docRoot = (NW_HED_DocumentRoot_t*)
|
|
1628 |
NW_HED_DocumentNode_GetRootNode (thisObj);
|
|
1629 |
const NW_Text_t* referrerUrl = NW_HED_DocumentRoot_GetDocumentReferrer(docRoot);
|
|
1630 |
const NW_HED_UrlResponse_t* urlResponse = NW_HED_ContentHandler_GetUrlResponse( thisObj );
|
|
1631 |
|
|
1632 |
if ( urlResponse && referrerUrl && referrerUrl == NW_HED_UrlResponse_GetUrl( urlResponse ) )
|
|
1633 |
{
|
|
1634 |
NW_HED_DocumentRoot_SetDocumentReferrer(docRoot , NULL);
|
|
1635 |
}
|
|
1636 |
RArray<TExternalScriptNode>* scriptIds = STATIC_CAST(RArray<TExternalScriptNode>*, thisObj->scriptLoadTransactionIds);
|
|
1637 |
if (scriptIds)
|
|
1638 |
{
|
|
1639 |
scriptIds->Close();
|
|
1640 |
delete scriptIds;
|
|
1641 |
}
|
|
1642 |
|
|
1643 |
RPointerArray<NW_XHTML_Script_Node_Context_t>* scriptNodeList = STATIC_CAST(RPointerArray<NW_XHTML_Script_Node_Context_t>*,
|
|
1644 |
thisObj->scriptNodes);
|
|
1645 |
if (scriptNodeList)
|
|
1646 |
{
|
|
1647 |
scriptNodeList->ResetAndDestroy();
|
|
1648 |
scriptNodeList->Close();
|
|
1649 |
delete scriptNodeList;
|
|
1650 |
}
|
|
1651 |
|
|
1652 |
RPointerArray<NW_DOM_ElementNode_t>* formNodes = (RPointerArray<NW_DOM_ElementNode_t>*)thisObj->formNodes;
|
|
1653 |
{
|
|
1654 |
formNodes->Reset();
|
|
1655 |
delete formNodes;
|
|
1656 |
}
|
|
1657 |
|
|
1658 |
|
|
1659 |
NW_Object_Delete (thisObj->nodeContexts);
|
|
1660 |
thisObj->nodeContexts = NULL;
|
|
1661 |
NW_XHTML_ContentHandler_DeleteAllElementHandlerInstances(thisObj);
|
|
1662 |
NW_Object_Delete(thisObj->iElementHandlerMap);
|
|
1663 |
thisObj->iElementHandlerMap = NULL;
|
|
1664 |
|
|
1665 |
NW_Object_Delete (thisObj->processor);
|
|
1666 |
|
|
1667 |
if (thisObj->metaRefreshResolvedUrl != NULL)
|
|
1668 |
{
|
|
1669 |
NW_Object_Delete (thisObj->metaRefreshResolvedUrl);
|
|
1670 |
thisObj->metaRefreshResolvedUrl = NULL;
|
|
1671 |
}
|
|
1672 |
|
|
1673 |
if (thisObj->metaRefreshTimer != NULL)
|
|
1674 |
{
|
|
1675 |
NW_XHTML_ContentHandler_MetaRefreshDestroyTimer(thisObj);
|
|
1676 |
}
|
|
1677 |
|
|
1678 |
/* save any possible form control values to history */
|
|
1679 |
if (thisObj->controlSet != NULL)
|
|
1680 |
{
|
|
1681 |
if (thisObj->historyContentData != NULL)
|
|
1682 |
{
|
|
1683 |
NW_Object_Dynamic_t* controlValueSet;
|
|
1684 |
|
|
1685 |
controlValueSet = (NW_Object_Dynamic_t*)
|
|
1686 |
NW_XHTML_ControlSet_GetValueVector (thisObj->controlSet);
|
|
1687 |
|
|
1688 |
(void) NW_Object_Shared_AdoptObject (thisObj->historyContentData, controlValueSet);
|
|
1689 |
}
|
|
1690 |
|
|
1691 |
NW_Object_Delete (thisObj->controlSet);
|
|
1692 |
}
|
|
1693 |
|
|
1694 |
if (thisObj->controlValueSet != NULL)
|
|
1695 |
{
|
|
1696 |
NW_Object_Delete (thisObj->controlValueSet);
|
|
1697 |
}
|
|
1698 |
|
|
1699 |
if (thisObj->imageMapLookupTable != NULL)
|
|
1700 |
{
|
|
1701 |
delete static_cast<CMapElementList*>(thisObj->imageMapLookupTable);
|
|
1702 |
thisObj->imageMapLookupTable = NULL;
|
|
1703 |
}
|
|
1704 |
|
|
1705 |
NW_Str_Delete(thisObj->metaExpiresDate);
|
|
1706 |
delete thisObj->iMessageListener;
|
|
1707 |
}
|
|
1708 |
|
|
1709 |
// -----------------------------------------------------------------------------
|
|
1710 |
TBrowserStatusCode
|
|
1711 |
_NW_XHTML_ContentHandler_Cancel(NW_HED_DocumentNode_t* documentNode,
|
|
1712 |
NW_HED_CancelType_t cancelType)
|
|
1713 |
{
|
|
1714 |
TBrowserStatusCode status;
|
|
1715 |
NW_XHTML_ContentHandler_t* thisObj;
|
|
1716 |
// parameter assertion block
|
|
1717 |
NW_ASSERT (NW_Object_IsInstanceOf (documentNode,
|
|
1718 |
&NW_XHTML_ContentHandler_Class));
|
|
1719 |
// cast into the 'thisObj' pointer for convenience
|
|
1720 |
thisObj = NW_XHTML_ContentHandlerOf (documentNode);
|
|
1721 |
|
|
1722 |
// stop the META-Refresh timer if it is running
|
|
1723 |
NW_XHTML_ContentHandler_MetaRefreshDestroyTimer(thisObj);
|
|
1724 |
|
|
1725 |
thisObj->iScriptCancelled = NW_TRUE;
|
|
1726 |
// cancel any executing event script
|
|
1727 |
NW_HED_DocumentRoot_t *documentRoot =
|
|
1728 |
(NW_HED_DocumentRoot_t*) NW_HED_DocumentNode_GetRootNode (thisObj);
|
|
1729 |
|
|
1730 |
|
|
1731 |
RArray<TExternalScriptNode>* scriptIds = STATIC_CAST(RArray<TExternalScriptNode>*, thisObj->scriptLoadTransactionIds);
|
|
1732 |
scriptIds->Reset();
|
|
1733 |
|
|
1734 |
if (thisObj->scriptNodes)
|
|
1735 |
{
|
|
1736 |
RPointerArray<NW_XHTML_Script_Node_Context_t>* scriptNodeList = STATIC_CAST(RPointerArray<NW_XHTML_Script_Node_Context_t>*,
|
|
1737 |
thisObj->scriptNodes);
|
|
1738 |
scriptNodeList->ResetAndDestroy();
|
|
1739 |
}
|
|
1740 |
|
|
1741 |
// invoke super class cancel
|
|
1742 |
status = NW_HED_CompositeContentHandler_Class.NW_HED_DocumentNode.
|
|
1743 |
cancel(documentNode, cancelType);
|
|
1744 |
|
|
1745 |
return status;
|
|
1746 |
}
|
|
1747 |
|
|
1748 |
|
|
1749 |
static TBrowserStatusCode NW_HTMLP_NotifyDocCompleteCallBack(void* context,
|
|
1750 |
const NW_Buffer_t* residueWbxml, NW_Uint32 encoding,
|
|
1751 |
NW_Uint32 codePageSwitchCount, NW_Int32 lastValid, void* WBXMLEncStrTbl)
|
|
1752 |
{
|
|
1753 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
1754 |
NW_XHTML_ContentHandler_t* thisObj = (NW_XHTML_ContentHandler_t*) context;
|
|
1755 |
NW_Buffer_t* buffer = (NW_Buffer_t*) residueWbxml;
|
|
1756 |
|
|
1757 |
if (buffer != NULL)
|
|
1758 |
{
|
|
1759 |
if (!thisObj->domTree)
|
|
1760 |
{
|
|
1761 |
thisObj->domTree = NW_HED_DomTree_New(buffer,
|
|
1762 |
(NW_Http_CharSet_t) encoding,
|
|
1763 |
NW_xhtml_1_0_PublicId,
|
|
1764 |
WBXMLEncStrTbl);
|
|
1765 |
|
|
1766 |
/* init the domHelper */
|
|
1767 |
thisObj->domHelper.entitySet = NW_HED_EntitySetOf(&NW_XHTML_EntitySet);
|
|
1768 |
thisObj->domHelper.context = NULL;
|
|
1769 |
thisObj->domHelper.resolvePlainTextVariablesAndEntities = NW_TRUE;
|
|
1770 |
|
|
1771 |
/* find the body element, if it exists */
|
|
1772 |
if (thisObj->domTree != NULL)
|
|
1773 |
{
|
|
1774 |
thisObj->baseElement = NW_HED_DomHelper_FindElement(&(thisObj->domHelper),
|
|
1775 |
NW_HED_DomTree_GetRootNode(thisObj->domTree),
|
|
1776 |
3, NW_XHTML_ElementToken_base, 0, NULL);
|
|
1777 |
}
|
|
1778 |
else
|
|
1779 |
{
|
|
1780 |
status = KBrsrUnexpectedError;
|
|
1781 |
}
|
|
1782 |
}
|
|
1783 |
|
|
1784 |
else
|
|
1785 |
{
|
|
1786 |
status = NW_HED_DomTree_Append(&thisObj->domTree, buffer,
|
|
1787 |
(NW_Http_CharSet_t) encoding, NW_xhtml_1_0_PublicId, codePageSwitchCount,
|
|
1788 |
lastValid, WBXMLEncStrTbl);
|
|
1789 |
}
|
|
1790 |
}
|
|
1791 |
|
|
1792 |
return status;
|
|
1793 |
}
|
|
1794 |
|
|
1795 |
|
|
1796 |
// -----------------------------------------------------------------------------
|
|
1797 |
TBrowserStatusCode
|
|
1798 |
_NW_XHTML_ContentHandler_Initialize(NW_HED_DocumentNode_t* documentNode,
|
|
1799 |
TBrowserStatusCode aInitStatus)
|
|
1800 |
{
|
|
1801 |
NW_XHTML_ContentHandler_t* thisObj;
|
|
1802 |
NW_HED_ContentHandler_t* contentHandler;
|
|
1803 |
const NW_HED_UrlRequest_t* urlRequest;
|
|
1804 |
NW_Uint32 encoding;
|
|
1805 |
void* WBXMLEncStrTbl = NULL;
|
|
1806 |
|
|
1807 |
NW_REQUIRED_PARAM(aInitStatus);
|
|
1808 |
|
|
1809 |
NW_TRY(status)
|
|
1810 |
{
|
|
1811 |
NW_LOG0(NW_LOG_LEVEL2, "_NW_XHTML_ContentHandler_Initialize START");
|
|
1812 |
|
|
1813 |
// cast into the 'thisObj' pointer for convenience
|
|
1814 |
thisObj = NW_XHTML_ContentHandlerOf(documentNode);
|
|
1815 |
|
|
1816 |
NW_LOG0(NW_LOG_LEVEL2,
|
|
1817 |
"in _NW_XHTML_ContentHandler_Initialize documentLoadComplete");
|
|
1818 |
|
|
1819 |
contentHandler = NW_HED_ContentHandlerOf(thisObj);
|
|
1820 |
if ( NW_Asc_stricmp((char*)HTTP_application_xhtml_xml_saved_string,
|
|
1821 |
(char*)contentHandler->response->contentTypeString) == 0 ||
|
|
1822 |
NW_Asc_stricmp((char*)HTTP_application_saved_string,
|
|
1823 |
(char*)contentHandler->response->contentTypeString) == 0 )
|
|
1824 |
{
|
|
1825 |
NW_XHTML_ContentHandler_SetSaveddeck(thisObj, NW_TRUE);
|
|
1826 |
}
|
|
1827 |
|
|
1828 |
urlRequest = NW_HED_ContentHandler_GetUrlRequest(contentHandler);
|
|
1829 |
if(urlRequest != NULL && (NW_HED_UrlRequest_GetReason(urlRequest) == NW_HED_UrlRequest_Reason_ShellPrev))
|
|
1830 |
{
|
|
1831 |
NW_XHTML_ContentHandler_SetHistoryLoad(thisObj, NW_TRUE);
|
|
1832 |
}
|
|
1833 |
|
|
1834 |
if(urlRequest != NULL && (NW_HED_UrlRequest_GetReason(urlRequest) == NW_HED_UrlRequest_Reason_ShellReload))
|
|
1835 |
{
|
|
1836 |
NW_XHTML_ContentHandler_SetReLoad(thisObj, NW_TRUE);
|
|
1837 |
}
|
|
1838 |
|
|
1839 |
|
|
1840 |
// do not call node initialize on the handler if there are external
|
|
1841 |
// script loads pending. If load count > 0 then super class is
|
|
1842 |
// initialized in the function _NW_XHTML_DocumentNode_HandleLoadComplete
|
|
1843 |
|
|
1844 |
|
|
1845 |
// when document loading is complete, let the parser know about it
|
|
1846 |
// as it might have some leftovers to process
|
|
1847 |
if (thisObj->htmlpParser)
|
|
1848 |
{
|
|
1849 |
NW_HTMLP_NotifyDocComplete(thisObj->htmlpParser, &encoding,
|
|
1850 |
&WBXMLEncStrTbl, NW_HTMLP_NotifyDocCompleteCallBack, thisObj);
|
|
1851 |
|
|
1852 |
thisObj->htmlpParser = NULL;
|
|
1853 |
}
|
|
1854 |
|
|
1855 |
// in case select is the last part of page, we always leave it processed in the next chunk
|
|
1856 |
// if there's no more chunk, we still want to process select
|
|
1857 |
thisObj->lastChunk = NW_TRUE;
|
|
1858 |
// make sure we've got the dom tree
|
|
1859 |
if (!thisObj->domTree)
|
|
1860 |
{
|
|
1861 |
NW_LOG0(NW_LOG_LEVEL1, "_NW_XHTML_ContentHandler_Initialize: BadContent error: domTree null");
|
|
1862 |
}
|
|
1863 |
|
|
1864 |
|
|
1865 |
NW_THROW_ON_NULL(thisObj->domTree, status, KBrsrXhtmlBadContent);
|
|
1866 |
|
|
1867 |
status = NW_XHTML_ContentHandler_InitializeElementHandlers( thisObj );
|
|
1868 |
// Do we really wanna jump to the end and leaving out
|
|
1869 |
// initialization if something fails on initelemhandlers?
|
|
1870 |
_NW_THROW_ON_ERROR(status);
|
|
1871 |
|
|
1872 |
|
|
1873 |
NW_Uint16 token = NW_HED_DomHelper_GetElementToken( thisObj->lastInitializedDomNode );
|
|
1874 |
if(token == NW_XHTML_ElementToken_style ||
|
|
1875 |
token == NW_XHTML_ElementToken_title ||
|
|
1876 |
token == NW_XHTML_ElementToken_script ||
|
|
1877 |
token == NW_XHTML_ElementToken_select ||
|
|
1878 |
token == NW_XHTML_ElementToken_object ||
|
|
1879 |
token == NW_XHTML_ElementToken_map ||
|
|
1880 |
token == NW_XHTML_ElementToken_textarea ||
|
|
1881 |
token == NW_XHTML_ElementToken_table ||
|
|
1882 |
token == NW_XHTML_ElementToken_a)
|
|
1883 |
{
|
|
1884 |
|
|
1885 |
NW_HED_DocumentRoot_t* docRoot = NULL;
|
|
1886 |
|
|
1887 |
// set the default priority on this chunk
|
|
1888 |
CActive :: TPriority priorirty = (( CActive::TPriority )( CActive::EPriorityStandard ));
|
|
1889 |
|
|
1890 |
docRoot = ( NW_HED_DocumentRoot_t* ) NW_HED_DocumentNode_GetRootNode( thisObj );
|
|
1891 |
( void ) docRoot->documentListener->DocumentChangedPartial( docRoot, priorirty );
|
|
1892 |
}
|
|
1893 |
|
|
1894 |
// create area list on each image map box
|
|
1895 |
NW_XHTML_ContentHandler_ActivateImageMapBox(thisObj);
|
|
1896 |
|
|
1897 |
// no more partial content comes.
|
|
1898 |
|
|
1899 |
// invalidate prev ecma script context
|
|
1900 |
|
|
1901 |
// invoke our superclass method
|
|
1902 |
|
|
1903 |
status = NW_HED_CompositeContentHandler_Class.NW_HED_DocumentNode.
|
|
1904 |
initialize(documentNode, KBrsrSuccess);
|
|
1905 |
|
|
1906 |
NW_LOG0(NW_LOG_LEVEL2, "_NW_XHTML_ContentHandler_Initialize END");
|
|
1907 |
|
|
1908 |
#ifdef _DEBUG1
|
|
1909 |
if (thisObj->domTree != NULL)
|
|
1910 |
{
|
|
1911 |
NW_HED_DomHelper_PrintTree (&thisObj->domHelper, NW_HED_DomTree_GetRootNode (thisObj->domTree) );
|
|
1912 |
|
|
1913 |
}
|
|
1914 |
#endif
|
|
1915 |
}
|
|
1916 |
NW_CATCH( status )
|
|
1917 |
{
|
|
1918 |
}
|
|
1919 |
NW_FINALLY
|
|
1920 |
{
|
|
1921 |
return status;
|
|
1922 |
}
|
|
1923 |
NW_END_TRY
|
|
1924 |
}
|
|
1925 |
|
|
1926 |
|
|
1927 |
/* ------------------------------------------------------------------------- */
|
|
1928 |
TBrowserStatusCode
|
|
1929 |
_NW_XHTML_ContentHandler_PartialNextChunk( NW_HED_ContentHandler_t* contentHandler,
|
|
1930 |
NW_Int32 chunkIndex, NW_Url_Resp_t* response,
|
|
1931 |
void* context)
|
|
1932 |
{
|
|
1933 |
NW_XHTML_ContentHandler_t* thisObj;
|
|
1934 |
NW_ASSERT( contentHandler != NULL );
|
|
1935 |
NW_LOG1( NW_LOG_LEVEL2, "_NW_XHTML_ContentHandler_PartialNextChunk starts: chunkIndex: %d", chunkIndex);
|
|
1936 |
|
|
1937 |
#ifdef __WINS__
|
|
1938 |
|
|
1939 |
if ( response != NULL && response->body != NULL )
|
|
1940 |
{
|
|
1941 |
char* buffer;
|
|
1942 |
buffer = (char*)malloc( response->body->length + 1 );
|
|
1943 |
if (buffer != NULL)
|
|
1944 |
{
|
|
1945 |
memcpy( (void*)buffer, (const void*)response->body->data, response->body->length );
|
|
1946 |
buffer[ response->body->length ] = 0;
|
|
1947 |
FILE* stream = fopen( "chunks.txt", "a+" ); /* open for reading and appending */
|
|
1948 |
if (stream != NULL)
|
|
1949 |
{
|
|
1950 |
fprintf((FILE*)stream, "\n\n========== Chunk %d ==============\n", chunkIndex );
|
|
1951 |
fprintf((FILE*)stream, "%s", buffer );
|
|
1952 |
fflush((FILE*)stream);
|
|
1953 |
fclose((FILE*)stream);
|
|
1954 |
}
|
|
1955 |
}
|
|
1956 |
free( (void*)buffer);
|
|
1957 |
}
|
|
1958 |
#endif // _WINS_
|
|
1959 |
|
|
1960 |
NW_TRY( status )
|
|
1961 |
{
|
|
1962 |
// set the default priority on this chunk
|
|
1963 |
CActive::TPriority priorirty = ((CActive::TPriority)( CActive::EPriorityLow + 2 ));
|
|
1964 |
NW_HED_DocumentRoot_t* docRoot;
|
|
1965 |
const NW_HED_UrlRequest_t* urlRequest;
|
|
1966 |
// cast into the 'thisObj' pointer for convenience
|
|
1967 |
thisObj = NW_XHTML_ContentHandlerOf( contentHandler );
|
|
1968 |
docRoot = (NW_HED_DocumentRoot_t*) NW_HED_DocumentNode_GetRootNode( thisObj );
|
|
1969 |
NW_Bool oldBodyIsPresent = thisObj->iBodyIsPresent;
|
|
1970 |
// make sure we have a valid response
|
|
1971 |
NW_THROW_ON_NULL( response, status, KBrsrUnexpectedError );
|
|
1972 |
// first chunk.
|
|
1973 |
if ( chunkIndex == 0 )
|
|
1974 |
{
|
|
1975 |
// set body to false
|
|
1976 |
thisObj->iBodyIsPresent = NW_FALSE;
|
|
1977 |
//
|
|
1978 |
NW_Bool disableSmallScreen;
|
|
1979 |
// invoke superclass
|
|
1980 |
status = NW_HED_ContentHandler_Class.NW_HED_ContentHandler.partialNextChunk(
|
|
1981 |
contentHandler, chunkIndex, response, context );
|
|
1982 |
// response has been released by the base class call.
|
|
1983 |
response = NULL;
|
|
1984 |
_NW_THROW_ON_ERROR( status );
|
|
1985 |
|
|
1986 |
// disable ss on xhtml pages.
|
|
1987 |
disableSmallScreen = (NW_Bool)( NW_Asc_stricmp(
|
|
1988 |
(char*)HTTP_application_vnd_wap_xhtml_xml_string,
|
|
1989 |
(char*)contentHandler->response->contentTypeString ) == 0 );
|
|
1990 |
NW_Settings_SetDisableSmallScreenLayout( disableSmallScreen );
|
|
1991 |
|
|
1992 |
// if the current layout is Normal layout or ss is enabled, switch to vertical layout.
|
|
1993 |
if ( !NW_Settings_GetVerticalLayoutEnabled() && !disableSmallScreen )
|
|
1994 |
{
|
|
1995 |
NW_Settings_SetInternalVerticalLayoutEnabled( NW_TRUE );
|
|
1996 |
thisObj->switchBackToNormalLayout = NW_TRUE;
|
|
1997 |
}
|
|
1998 |
|
|
1999 |
// get rid of the old title (if any)
|
|
2000 |
(void) NW_XHTML_ContentHandler_SetTitle( thisObj, NULL );
|
|
2001 |
|
|
2002 |
// get the controlSet from the history
|
|
2003 |
status = NW_XHTML_ContentHandler_RestoreControlSet( thisObj );
|
|
2004 |
_NW_THROW_ON_ERROR( status );
|
|
2005 |
|
|
2006 |
// build the dom tree out of the first chunk
|
|
2007 |
status = NW_XHTML_ContentHandler_CreatePartialDocument( thisObj,
|
|
2008 |
contentHandler->response, NW_TRUE );
|
|
2009 |
_NW_THROW_ON_ERROR( status );
|
|
2010 |
|
|
2011 |
// Must mark as a saved deck before we initialize the element
|
|
2012 |
// handlers and make requests
|
|
2013 |
if( NW_Asc_stricmp((char*)HTTP_application_xhtml_xml_saved_string,
|
|
2014 |
(char*)contentHandler->response->contentTypeString) == 0 ||
|
|
2015 |
NW_Asc_stricmp((char*)HTTP_application_saved_string,
|
|
2016 |
(char*)contentHandler->response->contentTypeString) == 0 )
|
|
2017 |
{
|
|
2018 |
NW_XHTML_ContentHandler_SetSaveddeck(thisObj, NW_TRUE);
|
|
2019 |
}
|
|
2020 |
urlRequest = NW_HED_ContentHandler_GetUrlRequest(contentHandler);
|
|
2021 |
if(urlRequest != NULL && (NW_HED_UrlRequest_GetReason(urlRequest) == NW_HED_UrlRequest_Reason_ShellPrev))
|
|
2022 |
{
|
|
2023 |
NW_XHTML_ContentHandler_SetHistoryLoad(thisObj, NW_TRUE);
|
|
2024 |
}
|
|
2025 |
|
|
2026 |
if(urlRequest != NULL && (NW_HED_UrlRequest_GetReason(urlRequest) == NW_HED_UrlRequest_Reason_ShellReload))
|
|
2027 |
{
|
|
2028 |
NW_XHTML_ContentHandler_SetReLoad(thisObj, NW_TRUE);
|
|
2029 |
}
|
|
2030 |
|
|
2031 |
// initialize partial element handlers
|
|
2032 |
status = NW_XHTML_ContentHandler_InitializeElementHandlers( thisObj );
|
|
2033 |
_NW_THROW_ON_ERROR( status );
|
|
2034 |
}
|
|
2035 |
else if ( chunkIndex != -1 )
|
|
2036 |
{
|
|
2037 |
// build the dom tree out of the chunk
|
|
2038 |
status = NW_XHTML_ContentHandler_AppendPartialDocument( thisObj, response );
|
|
2039 |
_NW_THROW_ON_ERROR( status );
|
|
2040 |
|
|
2041 |
status = NW_XHTML_ContentHandler_InitializeElementHandlers( thisObj );
|
|
2042 |
_NW_THROW_ON_ERROR( status );
|
|
2043 |
}
|
|
2044 |
else
|
|
2045 |
{
|
|
2046 |
// this function musn't be called with the last partial response that has no body.
|
|
2047 |
// Initialize must be called instead
|
|
2048 |
NW_ASSERT( NW_TRUE );
|
|
2049 |
}
|
|
2050 |
// if this is the first chunk where the body is present, then set
|
|
2051 |
// the formatting priority higher
|
|
2052 |
if( !oldBodyIsPresent && thisObj->iBodyIsPresent )
|
|
2053 |
{
|
|
2054 |
// higher priority
|
|
2055 |
priorirty = CActive::EPriorityStandard;
|
|
2056 |
}
|
|
2057 |
// let the shell know about the new partial document so that it can initiate
|
|
2058 |
// update display message.
|
|
2059 |
// if small screen layout is not disabled do not update.
|
|
2060 |
// mobile profile pages do not format correctly when tables span
|
|
2061 |
// chunks.
|
|
2062 |
if( thisObj->iBodyIsPresent && !NW_Settings_GetDisableSmallScreenLayout() )
|
|
2063 |
{
|
|
2064 |
(void)docRoot->documentListener->DocumentChangedPartial( docRoot, priorirty );
|
|
2065 |
}
|
|
2066 |
}
|
|
2067 |
NW_CATCH( status )
|
|
2068 |
{
|
|
2069 |
// special handling for the "need more data" case which means
|
|
2070 |
// that the parser needs more chunks to process the buffer.
|
|
2071 |
// it is not an error case so the status has to be
|
|
2072 |
// modified to success
|
|
2073 |
if ( status == KBrsrBufferTooSmall )
|
|
2074 |
{
|
|
2075 |
status = KBrsrSuccess;
|
|
2076 |
}
|
|
2077 |
}
|
|
2078 |
NW_FINALLY
|
|
2079 |
{
|
|
2080 |
// body ownership is taken by the parser
|
|
2081 |
// free the response
|
|
2082 |
UrlLoader_UrlResponseDelete( response );
|
|
2083 |
NW_LOG1( NW_LOG_LEVEL2, "_NW_XHTML_ContentHandler_PartialNextChunk ends: status: %d", status);
|
|
2084 |
return status;
|
|
2085 |
}
|
|
2086 |
NW_END_TRY
|
|
2087 |
}
|
|
2088 |
|
|
2089 |
|
|
2090 |
// -----------------------------------------------------------------------------
|
|
2091 |
NW_Uint8
|
|
2092 |
_NW_XHTML_ContentHandler_ProcessEvent (NW_HED_DocumentNode_t* documentNode,
|
|
2093 |
NW_LMgr_Box_t* box,
|
|
2094 |
NW_Evt_Event_t* event,
|
|
2095 |
void* context)
|
|
2096 |
{
|
|
2097 |
NW_XHTML_ContentHandler_t* thisObj;
|
|
2098 |
const NW_XHTML_ElementHandler_t* elementHandler;
|
|
2099 |
|
|
2100 |
/* cast the 'object' for convenience */
|
|
2101 |
thisObj = NW_XHTML_ContentHandlerOf (documentNode);
|
|
2102 |
|
|
2103 |
/* the context that was passed in is in reality a 'NW_DOM_Node_t*' - use that
|
|
2104 |
to find the appropriate ElementHandler and invoke its processEvent
|
|
2105 |
method */
|
|
2106 |
elementHandler =
|
|
2107 |
NW_XHTML_ContentHandler_GetElementHandler (NW_XHTML_ContentHandlerOf (documentNode),
|
|
2108 |
(NW_DOM_ElementNode_t*) context);
|
|
2109 |
NW_ASSERT (elementHandler != NULL);
|
|
2110 |
return NW_XHTML_ElementHandler_ProcessEvent (elementHandler, thisObj,
|
|
2111 |
(NW_DOM_ElementNode_t*) context,
|
|
2112 |
box, event);
|
|
2113 |
}
|
|
2114 |
|
|
2115 |
// -----------------------------------------------------------------------------
|
|
2116 |
void
|
|
2117 |
_NW_XHTML_ContentHandler_Suspend (NW_HED_DocumentNode_t* documentNode, NW_Bool aDestroyBoxTree)
|
|
2118 |
{
|
|
2119 |
NW_XHTML_ContentHandler_t* thisObj;
|
|
2120 |
|
|
2121 |
/* parameter assertion block */
|
|
2122 |
NW_ASSERT (NW_Object_IsInstanceOf (documentNode,
|
|
2123 |
&NW_XHTML_ContentHandler_Class));
|
|
2124 |
/* for convenience */
|
|
2125 |
thisObj = NW_XHTML_ContentHandlerOf (documentNode);
|
|
2126 |
|
|
2127 |
/* stop the META-Refresh timer if it is running */
|
|
2128 |
NW_XHTML_ContentHandler_MetaRefreshDestroyTimer(thisObj);
|
|
2129 |
|
|
2130 |
if (thisObj->processor)
|
|
2131 |
{
|
|
2132 |
NW_CSS_Processor_Suspend(thisObj->processor);
|
|
2133 |
}
|
|
2134 |
|
|
2135 |
//reset the script nodes as the boxes in the scriptNode contexts are deleted
|
|
2136 |
if (thisObj->scriptNodes)
|
|
2137 |
{
|
|
2138 |
RPointerArray<NW_XHTML_Script_Node_Context_t>* scriptNodeList = STATIC_CAST(RPointerArray<NW_XHTML_Script_Node_Context_t>*,
|
|
2139 |
thisObj->scriptNodes);
|
|
2140 |
scriptNodeList->ResetAndDestroy();
|
|
2141 |
}
|
|
2142 |
|
|
2143 |
//R->ecma
|
|
2144 |
//NW_HED_DocumentRoot_t* documentRoot = (NW_HED_DocumentRoot_t*) NW_HED_DocumentNode_GetRootNode (thisObj);
|
|
2145 |
//(void) NW_Ecma_InvalidateFormsElements(documentRoot);
|
|
2146 |
|
|
2147 |
/* invoke our superclass */
|
|
2148 |
NW_HED_CompositeContentHandler_Class.NW_HED_DocumentNode.suspend(documentNode, aDestroyBoxTree);
|
|
2149 |
}
|
|
2150 |
//------------------------------------------------------------------------------
|
|
2151 |
void
|
|
2152 |
_NW_XHTML_CompositeContentHandler_Resume (NW_HED_DocumentNode_t* documentNode)
|
|
2153 |
{
|
|
2154 |
NW_XHTML_ContentHandler_t* thisObj;
|
|
2155 |
|
|
2156 |
/* parameter assertion block */
|
|
2157 |
NW_ASSERT (NW_Object_IsInstanceOf (documentNode,
|
|
2158 |
&NW_XHTML_ContentHandler_Class));
|
|
2159 |
/* for convenience */
|
|
2160 |
thisObj = NW_XHTML_ContentHandlerOf (documentNode);
|
|
2161 |
|
|
2162 |
/* invoke our superclass */
|
|
2163 |
NW_HED_CompositeContentHandler_Class.NW_HED_DocumentNode.resume(documentNode);
|
|
2164 |
|
|
2165 |
thisObj->iScriptIsResumed = NW_TRUE;
|
|
2166 |
}
|
|
2167 |
|
|
2168 |
// -----------------------------------------------------------------------------
|
|
2169 |
void
|
|
2170 |
_NW_XHTML_ContentHandler_AllLoadsCompleted (NW_HED_DocumentNode_t* documentNode)
|
|
2171 |
{
|
|
2172 |
NW_XHTML_ContentHandler_t* thisObj;
|
|
2173 |
NW_Msg_Message_t* message = NULL;
|
|
2174 |
NW_Text_t* fragment = NULL;
|
|
2175 |
const NW_Text_t* url = NULL;
|
|
2176 |
|
|
2177 |
/* parameter assertion block */
|
|
2178 |
NW_ASSERT (NW_Object_IsInstanceOf (documentNode,
|
|
2179 |
&NW_XHTML_ContentHandler_Class));
|
|
2180 |
|
|
2181 |
/* call our super class to notify the children */
|
|
2182 |
NW_HED_CompositeContentHandler_Class.NW_HED_DocumentNode.
|
|
2183 |
allLoadsCompleted (documentNode);
|
|
2184 |
|
|
2185 |
/* for convenience */
|
|
2186 |
thisObj = NW_XHTML_ContentHandlerOf (documentNode);
|
|
2187 |
|
|
2188 |
|
|
2189 |
NW_TRY (status)
|
|
2190 |
{
|
|
2191 |
|
|
2192 |
/* get the fragment */
|
|
2193 |
url = NW_HED_UrlRequest_GetUrl (NW_HED_ContentHandler_GetUrlRequest
|
|
2194 |
(thisObj));
|
|
2195 |
status = NW_XHTML_ContentHandler_GetFragment (thisObj, url,
|
|
2196 |
(const NW_Text_t**) & fragment);
|
|
2197 |
|
|
2198 |
/* show the frag */
|
|
2199 |
if ((status == KBrsrSuccess) && (fragment != NULL))
|
|
2200 |
{
|
|
2201 |
/*
|
|
2202 |
** we need to use a message to display the fragment because we need
|
|
2203 |
** to wait until the box-tree is laid out -- which is also done via
|
|
2204 |
** a message.
|
|
2205 |
*/
|
|
2206 |
|
|
2207 |
/* create the message */
|
|
2208 |
message = NW_Msg_Message_New (NW_XHTML_ContentHandler_Msg_ShowFragment,
|
|
2209 |
fragment, NW_TRUE);
|
|
2210 |
NW_THROW_OOM_ON_NULL (message, status);
|
|
2211 |
|
|
2212 |
fragment = NULL;
|
|
2213 |
|
|
2214 |
/* dispatch it */
|
|
2215 |
status = NW_Msg_MessageDispatcher_DispatchMessage (&NW_Msg_MessageDispatcher, message, thisObj->iMessageListener);
|
|
2216 |
NW_THROW_ON_ERROR (status);
|
|
2217 |
|
|
2218 |
message = NULL;
|
|
2219 |
}
|
|
2220 |
}
|
|
2221 |
NW_CATCH (status)
|
|
2222 |
{
|
|
2223 |
NW_Object_Delete (fragment);
|
|
2224 |
NW_Object_Delete (message);
|
|
2225 |
}
|
|
2226 |
NW_FINALLY {
|
|
2227 |
} NW_END_TRY
|
|
2228 |
}
|
|
2229 |
|
|
2230 |
// -----------------------------------------------------------------------------
|
|
2231 |
void
|
|
2232 |
_NW_XHTML_ContentHandler_LoseFocus (NW_HED_DocumentNode_t* documentNode)
|
|
2233 |
{
|
|
2234 |
NW_XHTML_ContentHandler_t* thisObj;
|
|
2235 |
|
|
2236 |
/* parameter assertion block */
|
|
2237 |
NW_ASSERT (NW_Object_IsInstanceOf (documentNode,
|
|
2238 |
&NW_XHTML_ContentHandler_Class));
|
|
2239 |
/* for convenience */
|
|
2240 |
thisObj = NW_XHTML_ContentHandlerOf (documentNode);
|
|
2241 |
|
|
2242 |
/* suspend the META-Refresh timer if it is running */
|
|
2243 |
NW_XHTML_ContentHandler_MetaRefreshSuspendTimer(thisObj);
|
|
2244 |
|
|
2245 |
/* invoke our superclass */
|
|
2246 |
NW_HED_CompositeContentHandler_Class.NW_HED_DocumentNode.loseFocus(documentNode);
|
|
2247 |
}
|
|
2248 |
|
|
2249 |
// -----------------------------------------------------------------------------
|
|
2250 |
void
|
|
2251 |
_NW_XHTML_ContentHandler_GainFocus (NW_HED_DocumentNode_t* documentNode)
|
|
2252 |
{
|
|
2253 |
NW_XHTML_ContentHandler_t* thisObj;
|
|
2254 |
|
|
2255 |
/* parameter assertion block */
|
|
2256 |
NW_ASSERT (NW_Object_IsInstanceOf (documentNode,
|
|
2257 |
&NW_XHTML_ContentHandler_Class));
|
|
2258 |
/* for convenience */
|
|
2259 |
thisObj = NW_XHTML_ContentHandlerOf (documentNode);
|
|
2260 |
|
|
2261 |
|
|
2262 |
/* invoke our superclass */
|
|
2263 |
NW_HED_CompositeContentHandler_Class.NW_HED_DocumentNode.gainFocus(documentNode);
|
|
2264 |
|
|
2265 |
/* resume the META-Refresh timer if it was running */
|
|
2266 |
NW_XHTML_ContentHandler_MetaRefreshResumeTimer(thisObj);
|
|
2267 |
}
|
|
2268 |
|
|
2269 |
// -----------------------------------------------------------------------------
|
|
2270 |
// after loading last chunk of embedded content the function is called
|
|
2271 |
// by documentroot.
|
|
2272 |
// If the transactionId exits in scriptIds list , it is removed from the pendginglist
|
|
2273 |
void
|
|
2274 |
_NW_XHTML_DocumentNode_HandleLoadComplete(NW_HED_DocumentNode_t* documentNode,
|
|
2275 |
const NW_HED_UrlRequest_t *urlRequest,
|
|
2276 |
NW_Int16 errorClass,
|
|
2277 |
TBrowserStatusCode error,
|
|
2278 |
NW_Uint16 /*aTransactionId*/,
|
|
2279 |
void* context )
|
|
2280 |
{
|
|
2281 |
//check if the transaction is a script load request and decrement the counter
|
|
2282 |
NW_REQUIRED_PARAM(urlRequest);
|
|
2283 |
NW_REQUIRED_PARAM(errorClass);
|
|
2284 |
NW_REQUIRED_PARAM(error);
|
|
2285 |
NW_REQUIRED_PARAM(context);
|
|
2286 |
NW_REQUIRED_PARAM(documentNode);
|
|
2287 |
|
|
2288 |
/* parameter assertion block */
|
|
2289 |
NW_ASSERT (NW_Object_IsInstanceOf (documentNode,
|
|
2290 |
&NW_XHTML_ContentHandler_Class));
|
|
2291 |
/* for convenience */
|
|
2292 |
NW_LOG0( NW_LOG_LEVEL2, "NW_XHTML_DocumentNode_HandleLoadComplete Start" );
|
|
2293 |
NW_LOG0( NW_LOG_LEVEL2, "NW_XHTML_DocumentNode_HandleLoadComplete End" );
|
|
2294 |
}
|
|
2295 |
|
|
2296 |
|
|
2297 |
// -----------------------------------------------------------------------------
|
|
2298 |
const NW_Text_t*
|
|
2299 |
_NW_XHTML_ContentHandler_GetTitle (NW_HED_ContentHandler_t* contentHandler)
|
|
2300 |
{
|
|
2301 |
NW_XHTML_ContentHandler_t* thisObj;
|
|
2302 |
|
|
2303 |
/* for convenience */
|
|
2304 |
thisObj = NW_XHTML_ContentHandlerOf (contentHandler);
|
|
2305 |
|
|
2306 |
/* return the title */
|
|
2307 |
return thisObj->title;
|
|
2308 |
}
|
|
2309 |
|
|
2310 |
// -----------------------------------------------------------------------------
|
|
2311 |
TBrowserStatusCode
|
|
2312 |
_NW_XHTML_ContentHandler_ResolveURL (NW_HED_ContentHandler_t* thisObj,
|
|
2313 |
NW_Text_t* url, NW_Text_t** retUrl)
|
|
2314 |
{
|
|
2315 |
NW_Uint8 freeLoadUrl = NW_FALSE;
|
|
2316 |
NW_String_t baseUrl;
|
|
2317 |
NW_String_t href;
|
|
2318 |
NW_String_t contentLoc;
|
|
2319 |
NW_Ucs2* compositeBase = NULL;
|
|
2320 |
NW_DOM_Node_t* baseElement;
|
|
2321 |
NW_Ucs2 *contentLocation = NULL;
|
|
2322 |
void* docUrl = NULL;
|
|
2323 |
const NW_Ucs2* loadUrl = NULL;
|
|
2324 |
NW_Text_UCS2_t* absUrlText = NULL;
|
|
2325 |
NW_Ucs2* absUrl = NULL;
|
|
2326 |
NW_Bool isRelative;
|
|
2327 |
|
|
2328 |
baseUrl.length = 0;
|
|
2329 |
baseUrl.storage = NULL;
|
|
2330 |
|
|
2331 |
href.length = 0;
|
|
2332 |
href.storage = NULL;
|
|
2333 |
contentLoc.length = 0;
|
|
2334 |
contentLoc.storage = NULL;
|
|
2335 |
|
|
2336 |
NW_TRY(status)
|
|
2337 |
{
|
|
2338 |
/* get the url as a ucs2 char string */
|
|
2339 |
loadUrl = NW_Text_GetUCS2Buffer (url, NW_Text_Flags_Aligned, NULL, &freeLoadUrl);
|
|
2340 |
NW_THROW_OOM_ON_NULL((void*)loadUrl, status);
|
|
2341 |
|
|
2342 |
if(!NW_Text_GetCharCount(url))
|
|
2343 |
{
|
|
2344 |
isRelative = NW_TRUE;
|
|
2345 |
}
|
|
2346 |
else
|
|
2347 |
{
|
|
2348 |
/* if the supplied URL is absolute we simply return that */
|
|
2349 |
status = NW_Url_IsRelative (loadUrl, &isRelative);
|
|
2350 |
_NW_THROW_ON_ERROR (status);
|
|
2351 |
}
|
|
2352 |
if ( isRelative == NW_FALSE)
|
|
2353 |
{
|
|
2354 |
if (freeLoadUrl)
|
|
2355 |
{
|
|
2356 |
NW_Mem_Free ((NW_Ucs2*) loadUrl);
|
|
2357 |
}
|
|
2358 |
/*make a deep copy of the text */
|
|
2359 |
*retUrl = NW_Text_Copy(url, NW_TRUE);
|
|
2360 |
NW_THROW_OOM_ON_NULL(*retUrl, status);
|
|
2361 |
NW_Object_Delete (url);
|
|
2362 |
return KBrsrSuccess;
|
|
2363 |
}
|
|
2364 |
|
|
2365 |
/* Get the the document's url. The result is not owned by us. */
|
|
2366 |
docUrl =
|
|
2367 |
NW_HED_UrlResponse_GetUrl( NW_HED_ContentHandler_GetUrlResponse( thisObj ) )->storage;
|
|
2368 |
NW_THROW_OOM_ON_NULL(docUrl, status);
|
|
2369 |
|
|
2370 |
/*
|
|
2371 |
* If the URL was the result of a file operation, then we want the
|
|
2372 |
* response URL rather than
|
|
2373 |
* the request URL. This is to support save-to-file operations. If it wasn't the result of
|
|
2374 |
* a file operation, then the response URL should be the same as the request.
|
|
2375 |
*/
|
|
2376 |
if (NW_Str_Strncmp((const NW_Ucs2*)docUrl, (const NW_Ucs2*)NW_STR("file://"), 7) == 0)
|
|
2377 |
{
|
|
2378 |
docUrl = NW_HED_UrlResponse_GetUrl
|
|
2379 |
(NW_HED_ContentHandler_GetUrlResponse (thisObj))->storage;
|
|
2380 |
NW_THROW_OOM_ON_NULL(docUrl, status);
|
|
2381 |
}
|
|
2382 |
|
|
2383 |
/* get the base url as found in the "base" element */
|
|
2384 |
baseElement = NW_XHTML_ContentHandler_GetBaseElement(thisObj);
|
|
2385 |
|
|
2386 |
/*get the content location id present*/
|
|
2387 |
contentLocation = NW_XHTML_ContentHandler_GetContentLocation(thisObj);
|
|
2388 |
|
|
2389 |
if(contentLocation != NULL && baseElement == NULL)
|
|
2390 |
{
|
|
2391 |
|
|
2392 |
status = StatusCodeConvert(NW_String_ucs2CharToString (&contentLoc, contentLocation, HTTP_iso_10646_ucs_2));
|
|
2393 |
NW_THROW_ON_ERROR (status);
|
|
2394 |
status = NW_Url_IsRelative (contentLocation, &isRelative);
|
|
2395 |
NW_THROW_ON_ERROR (status);
|
|
2396 |
if (isRelative == NW_TRUE)
|
|
2397 |
{
|
|
2398 |
status = NW_Url_RelToAbs ((const NW_Ucs2*)docUrl, (const NW_Ucs2 *) contentLoc.storage,
|
|
2399 |
&compositeBase);
|
|
2400 |
NW_THROW_ON_ERROR (status);
|
|
2401 |
|
|
2402 |
status = NW_HED_DomHelper_CatUcs2String (&baseUrl, compositeBase);
|
|
2403 |
NW_THROW_ON_ERROR (status);
|
|
2404 |
|
|
2405 |
NW_Mem_Free (compositeBase);
|
|
2406 |
compositeBase = NULL;
|
|
2407 |
}
|
|
2408 |
/* otherwise use the base */
|
|
2409 |
else
|
|
2410 |
{
|
|
2411 |
status = NW_HED_DomHelper_CatString (&baseUrl, &contentLoc, HTTP_iso_10646_ucs_2);
|
|
2412 |
NW_THROW_ON_ERROR (status);
|
|
2413 |
}
|
|
2414 |
}
|
|
2415 |
|
|
2416 |
|
|
2417 |
if (baseElement != NULL)
|
|
2418 |
{
|
|
2419 |
status =
|
|
2420 |
NW_HED_DomHelper_GetHTMLAttributeValue
|
|
2421 |
(&((NW_XHTML_ContentHandler_t *) thisObj)->domHelper, baseElement,
|
|
2422 |
NW_XHTML_AttributeToken_href, &href);
|
|
2423 |
|
|
2424 |
if (status == KBrsrSuccess)
|
|
2425 |
{
|
|
2426 |
/*
|
|
2427 |
* if the base element is a relative url the base-url is formed by cat'ing the
|
|
2428 |
* document's url with the base.
|
|
2429 |
*/
|
|
2430 |
status = NW_Url_IsRelative ((const NW_Ucs2*) href.storage, &isRelative);
|
|
2431 |
NW_THROW_ON_ERROR (status);
|
|
2432 |
if (isRelative == NW_TRUE)
|
|
2433 |
{
|
|
2434 |
status = NW_Url_RelToAbs ((const NW_Ucs2*)docUrl, (const NW_Ucs2 *) href.storage,
|
|
2435 |
&compositeBase);
|
|
2436 |
NW_THROW_ON_ERROR (status);
|
|
2437 |
|
|
2438 |
status = NW_HED_DomHelper_CatUcs2String (&baseUrl, compositeBase);
|
|
2439 |
NW_THROW_ON_ERROR (status);
|
|
2440 |
|
|
2441 |
NW_Mem_Free (compositeBase);
|
|
2442 |
compositeBase = NULL;
|
|
2443 |
}
|
|
2444 |
/* otherwise use the base */
|
|
2445 |
else
|
|
2446 |
{
|
|
2447 |
status = NW_HED_DomHelper_CatString (&baseUrl, &href, HTTP_iso_10646_ucs_2);
|
|
2448 |
NW_THROW_ON_ERROR (status);
|
|
2449 |
}
|
|
2450 |
|
|
2451 |
NW_String_deleteStorage (&href);
|
|
2452 |
}
|
|
2453 |
}
|
|
2454 |
|
|
2455 |
/*
|
|
2456 |
* if the base-url is still null just use the document's url as the
|
|
2457 |
* base-url */
|
|
2458 |
if (baseUrl.storage == NULL)
|
|
2459 |
{
|
|
2460 |
status = NW_HED_DomHelper_CatUcs2String (&baseUrl, (const NW_Ucs2*)docUrl);
|
|
2461 |
NW_THROW_ON_ERROR (status);
|
|
2462 |
}
|
|
2463 |
|
|
2464 |
if(!NW_Str_Strlen(loadUrl))
|
|
2465 |
{
|
|
2466 |
absUrl = NW_Str_Newcpy((const NW_Ucs2*) baseUrl.storage);
|
|
2467 |
NW_THROW_OOM_ON_NULL(absUrl, status);
|
|
2468 |
}
|
|
2469 |
else
|
|
2470 |
{
|
|
2471 |
/* construct the absolute URL */
|
|
2472 |
status = NW_Url_RelToAbs ((const NW_Ucs2*) baseUrl.storage, loadUrl, &absUrl);
|
|
2473 |
NW_THROW_ON_ERROR (status);
|
|
2474 |
}
|
|
2475 |
|
|
2476 |
absUrlText = NW_Text_UCS2_New (absUrl, 0, NW_Text_Flags_TakeOwnership);
|
|
2477 |
NW_THROW_OOM_ON_NULL(absUrlText, status);
|
|
2478 |
absUrl = NULL;
|
|
2479 |
|
|
2480 |
/* fall through */
|
|
2481 |
|
|
2482 |
}
|
|
2483 |
|
|
2484 |
NW_CATCH (status)
|
|
2485 |
{ /* empty */
|
|
2486 |
}
|
|
2487 |
|
|
2488 |
NW_FINALLY {
|
|
2489 |
|
|
2490 |
if (freeLoadUrl == NW_TRUE)
|
|
2491 |
{
|
|
2492 |
NW_Mem_Free ((NW_Ucs2*) loadUrl);
|
|
2493 |
}
|
|
2494 |
|
|
2495 |
NW_String_deleteStorage (&baseUrl);
|
|
2496 |
NW_String_deleteStorage (&href);
|
|
2497 |
NW_String_deleteStorage (&contentLoc);
|
|
2498 |
NW_Mem_Free (absUrl);
|
|
2499 |
NW_Mem_Free (compositeBase);
|
|
2500 |
|
|
2501 |
if (status == KBrsrSuccess)
|
|
2502 |
{
|
|
2503 |
NW_Object_Delete (url);
|
|
2504 |
}
|
|
2505 |
|
|
2506 |
*retUrl = (NW_Text_t*) absUrlText;
|
|
2507 |
return status;
|
|
2508 |
}
|
|
2509 |
NW_END_TRY
|
|
2510 |
}
|
|
2511 |
|
|
2512 |
// -----------------------------------------------------------------------------
|
|
2513 |
TBrowserStatusCode
|
|
2514 |
_NW_XHTML_ContentHandler_CreateBoxTree (NW_HED_ContentHandler_t* contentHandler,
|
|
2515 |
NW_LMgr_Box_t** boxTree)
|
|
2516 |
{
|
|
2517 |
NW_XHTML_ContentHandler_t* thisObj;
|
|
2518 |
NW_DOM_Node_t* domNode;
|
|
2519 |
const NW_XHTML_ElementHandler_t* elementHandler;
|
|
2520 |
NW_LMgr_BidiFlowBox_t* bidiFlowBox = NULL;
|
|
2521 |
NW_LMgr_Property_t prop;
|
|
2522 |
|
|
2523 |
/* parameter assertion block */
|
|
2524 |
NW_ASSERT (NW_Object_IsInstanceOf (contentHandler,
|
|
2525 |
&NW_XHTML_ContentHandler_Class));
|
|
2526 |
|
|
2527 |
/* for convenience */
|
|
2528 |
thisObj = NW_XHTML_ContentHandlerOf (contentHandler);
|
|
2529 |
|
|
2530 |
thisObj->ignoreFramesetElement = NW_FALSE;
|
|
2531 |
thisObj->ignoreBodyElement = NW_FALSE;
|
|
2532 |
|
|
2533 |
NW_TRY (status)
|
|
2534 |
{
|
|
2535 |
#ifdef _DEBUG1
|
|
2536 |
NW_HED_DomHelper_PrintTree(&thisObj->domHelper, NW_HED_DomTree_GetRootNode(thisObj->domTree));
|
|
2537 |
#endif
|
|
2538 |
// if the box tree is Not null then update the box tree with the new content
|
|
2539 |
if (*boxTree)
|
|
2540 |
{
|
|
2541 |
|
|
2542 |
status = NW_XHTML_ContentHandler_CreatePartialBoxTree(thisObj, boxTree);
|
|
2543 |
// Set the prevInitializedDom. This denotes the last node for which the
|
|
2544 |
// box tree was created and will be used as a starting point when the
|
|
2545 |
// next chunk comes
|
|
2546 |
_NW_THROW_ON_ERROR(status);
|
|
2547 |
}
|
|
2548 |
else
|
|
2549 |
{
|
|
2550 |
/* create a BidiFlowBox in which to build the box tree */
|
|
2551 |
bidiFlowBox = NW_LMgr_BidiFlowBox_New (1);
|
|
2552 |
NW_THROW_OOM_ON_NULL (bidiFlowBox, status);
|
|
2553 |
|
|
2554 |
/* Set the display property on the container */
|
|
2555 |
prop.type = NW_CSS_ValueType_Token;
|
|
2556 |
prop.value.token = NW_CSS_PropValue_display_block;
|
|
2557 |
NW_LMgr_Box_SetProperty (NW_LMgr_BoxOf (bidiFlowBox),
|
|
2558 |
NW_CSS_Prop_display, &prop);
|
|
2559 |
|
|
2560 |
/* The root node is the so-called document node and is basically
|
|
2561 |
a holder for some general document info such as encoding. */
|
|
2562 |
domNode = NW_HED_DomTree_GetRootNode (thisObj->domTree);
|
|
2563 |
NW_THROW_ON_NULL (domNode, status, KBrsrUnexpectedError);
|
|
2564 |
|
|
2565 |
/* The actual content of the document starts with the root's children. */
|
|
2566 |
for (domNode = NW_DOM_Node_getFirstChild (domNode);
|
|
2567 |
domNode != NULL ;
|
|
2568 |
domNode = NW_DOM_Node_getNextSibling (domNode))
|
|
2569 |
{
|
|
2570 |
thisObj->prevInitializedDomNode = domNode;
|
|
2571 |
|
|
2572 |
elementHandler = NW_XHTML_ContentHandler_GetElementHandler (thisObj,
|
|
2573 |
(NW_DOM_ElementNode_t*) domNode);
|
|
2574 |
NW_ASSERT(elementHandler != NULL);
|
|
2575 |
if (elementHandler != NULL)
|
|
2576 |
{
|
|
2577 |
status = NW_XHTML_ElementHandler_CreateBoxTree (elementHandler,
|
|
2578 |
thisObj,
|
|
2579 |
domNode,
|
|
2580 |
NW_LMgr_ContainerBoxOf(bidiFlowBox));
|
|
2581 |
_NW_THROW_ON_ERROR(status);
|
|
2582 |
}
|
|
2583 |
}
|
|
2584 |
|
|
2585 |
/* next is a little optimization to eliminate excess top-level nesting */
|
|
2586 |
if (NW_LMgr_ContainerBox_GetChildCount(NW_LMgr_ContainerBoxOf(bidiFlowBox))
|
|
2587 |
== 1)
|
|
2588 |
{
|
|
2589 |
NW_LMgr_BidiFlowBox_t* tempFlowBox =
|
|
2590 |
((NW_LMgr_BidiFlowBox_t*)
|
|
2591 |
NW_LMgr_ContainerBox_GetChild(NW_LMgr_ContainerBoxOf(bidiFlowBox), 0));
|
|
2592 |
if (NW_Object_IsClass(tempFlowBox, &NW_LMgr_BidiFlowBox_Class))
|
|
2593 |
{
|
|
2594 |
NW_LMgr_Box_Detach(NW_LMgr_BoxOf(tempFlowBox));
|
|
2595 |
NW_Object_Delete(bidiFlowBox);
|
|
2596 |
bidiFlowBox = tempFlowBox;
|
|
2597 |
}
|
|
2598 |
}
|
|
2599 |
} // else
|
|
2600 |
}
|
|
2601 |
NW_CATCH (status)
|
|
2602 |
{
|
|
2603 |
if (bidiFlowBox)
|
|
2604 |
{
|
|
2605 |
NW_Object_Delete(bidiFlowBox);
|
|
2606 |
bidiFlowBox = NULL;
|
|
2607 |
}
|
|
2608 |
if (status != KBrsrOutOfMemory)
|
|
2609 |
{
|
|
2610 |
// ZAL: changed temporarily to distinguish create box
|
|
2611 |
// tree error from parser errors.
|
|
2612 |
status = KBrsrSavedPageFailed;
|
|
2613 |
}
|
|
2614 |
NW_HED_DocumentNode_HandleError( contentHandler,
|
|
2615 |
NW_HED_ContentHandler_GetUrlRequest(contentHandler),
|
|
2616 |
BRSR_STAT_CLASS_GENERAL, status);
|
|
2617 |
}
|
|
2618 |
NW_FINALLY
|
|
2619 |
{
|
|
2620 |
#ifdef _DEBUG1
|
|
2621 |
NW_HED_DomHelper_PrintTree(&thisObj->domHelper, NW_HED_DomTree_GetRootNode(thisObj->domTree));
|
|
2622 |
#endif
|
|
2623 |
if (bidiFlowBox)
|
|
2624 |
{
|
|
2625 |
*boxTree = NW_LMgr_BoxOf(bidiFlowBox);
|
|
2626 |
}
|
|
2627 |
// if the boxtree creation is exited , then thisObj->prevInitializedDomNode is
|
|
2628 |
// set by the function call NW_XHTML_ContentHandler_BreakBoxTreeCreation(...)
|
|
2629 |
thisObj->prevInitializedDomNode = thisObj->lastInitializedDomNode;
|
|
2630 |
return status;
|
|
2631 |
}
|
|
2632 |
NW_END_TRY
|
|
2633 |
}
|
|
2634 |
|
|
2635 |
// -----------------------------------------------------------------------------
|
|
2636 |
TBrowserStatusCode
|
|
2637 |
_NW_XHTML_ContentHandler_HandleRequest (NW_HED_ContentHandler_t* thisObj,
|
|
2638 |
NW_HED_UrlRequest_t* urlRequest)
|
|
2639 |
{
|
|
2640 |
TBrowserStatusCode status;
|
|
2641 |
|
|
2642 |
NW_ASSERT (NW_HED_UrlRequestOf (urlRequest));
|
|
2643 |
|
|
2644 |
/* don't handle reload requests here */
|
|
2645 |
if (NW_HED_UrlRequest_GetReason (urlRequest) == NW_HED_UrlRequest_Reason_ShellReload)
|
|
2646 |
{
|
|
2647 |
return KBrsrFailure;
|
|
2648 |
}
|
|
2649 |
|
|
2650 |
/* don't handle post requests here */
|
|
2651 |
if (NW_HED_UrlRequest_GetMethod (urlRequest) == NW_URL_METHOD_POST)
|
|
2652 |
{
|
|
2653 |
return KBrsrFailure;
|
|
2654 |
}
|
|
2655 |
|
|
2656 |
/* jump to the fragment if one is provided */
|
|
2657 |
status = NW_XHTML_ContentHandler_LoadFragment (NW_XHTML_ContentHandlerOf (
|
|
2658 |
thisObj), urlRequest);
|
|
2659 |
|
|
2660 |
return status;
|
|
2661 |
}
|
|
2662 |
|
|
2663 |
// -----------------------------------------------------------------------------
|
|
2664 |
TBrowserStatusCode
|
|
2665 |
_NW_XHTML_ContentHandler_DocumentDisplayed (NW_HED_ContentHandler_t* contentHandler)
|
|
2666 |
{
|
|
2667 |
NW_XHTML_ContentHandler_t* thisObj;
|
|
2668 |
|
|
2669 |
/* for convenience */
|
|
2670 |
thisObj = NW_XHTML_ContentHandlerOf (contentHandler);
|
|
2671 |
|
|
2672 |
NW_TRY (status)
|
|
2673 |
{
|
|
2674 |
if (thisObj->metaRefreshSet)
|
|
2675 |
{
|
|
2676 |
// Clear RefreshSet to only allow refresh once, in case URL is
|
|
2677 |
// invalid or some other type of error occurs.
|
|
2678 |
thisObj->metaRefreshSet = FALSE;
|
|
2679 |
if (thisObj->metaRefreshSeconds <= 0)
|
|
2680 |
{
|
|
2681 |
status = NW_XHTML_ContentHandler_MetaRefreshStartLoad(thisObj);
|
|
2682 |
_NW_THROW_ON_ERROR(status);
|
|
2683 |
}
|
|
2684 |
else
|
|
2685 |
{
|
|
2686 |
/* start a timer for the refresh delay */
|
|
2687 |
status = NW_XHTML_ContentHandler_MetaRefreshCreateTimer(thisObj);
|
|
2688 |
_NW_THROW_ON_ERROR(status);
|
|
2689 |
}
|
|
2690 |
}
|
|
2691 |
|
|
2692 |
const NW_Ucs2* rawUrl = NW_HED_UrlRequest_GetRawUrl (NW_HED_ContentHandler_GetUrlRequest(NW_HED_ContentHandlerOf(contentHandler)));
|
|
2693 |
if(thisObj->metaNoCache)
|
|
2694 |
{
|
|
2695 |
//R->ul UrlLoader_ClearItemInCache( rawUrl );
|
|
2696 |
}
|
|
2697 |
|
|
2698 |
if(thisObj->metaCacheExpires == NW_TRUE)
|
|
2699 |
{
|
|
2700 |
//R->ul UrlLoader_SetHeaderInCache(rawUrl, (unsigned char*) expires, thisObj->metaExpiresDate);
|
|
2701 |
}
|
|
2702 |
|
|
2703 |
|
|
2704 |
NW_HED_DocumentRoot_t* docRoot = (NW_HED_DocumentRoot_t*) NW_HED_DocumentNode_GetRootNode (thisObj);
|
|
2705 |
|
|
2706 |
|
|
2707 |
// check the content type of the response
|
|
2708 |
if ( thisObj->switchBackToNormalLayout )
|
|
2709 |
{
|
|
2710 |
// switch back to normal
|
|
2711 |
// but first make sure we have to switch at all as imagine the following case
|
|
2712 |
// 1. original status is normal
|
|
2713 |
// 2. first chunk cames in, we switch to ss mode ( content type is text/html )
|
|
2714 |
// 3. pi element handler disables ss mode ( mobile profile )
|
|
2715 |
// 4. formatting is carried on in normal mode
|
|
2716 |
// 5. execution comes here and we trying to switch to normal mode
|
|
2717 |
// 6. MHEDDocumentListener::SwitchLayout replaces boxes ( tables )
|
|
2718 |
// so all the static table box will be transformed to vertical box eventhough
|
|
2719 |
// we are in normal mode
|
|
2720 |
// so change only if we are really really in ss mode.
|
|
2721 |
NW_Bool smallScreenMode = NW_Settings_GetVerticalLayoutEnabled();
|
|
2722 |
NW_Settings_SetInternalVerticalLayoutEnabled( NW_FALSE );
|
|
2723 |
if ( smallScreenMode )
|
|
2724 |
{
|
|
2725 |
(void) docRoot->documentListener->SwitchLayout (NW_FALSE, NW_TRUE /*reformatBoxTree*/);
|
|
2726 |
|
|
2727 |
NW_CSS_Processor_t* processor = NW_XHTML_ContentHandler_GetCSSProcessor( thisObj );
|
|
2728 |
|
|
2729 |
if ( processor != NULL )
|
|
2730 |
{
|
|
2731 |
NW_CSS_Processor_ProcessPendingLoads( processor );
|
|
2732 |
}
|
|
2733 |
}
|
|
2734 |
thisObj->switchBackToNormalLayout = NW_FALSE;
|
|
2735 |
}
|
|
2736 |
}
|
|
2737 |
NW_CATCH (status)
|
|
2738 |
{}
|
|
2739 |
NW_FINALLY
|
|
2740 |
{
|
|
2741 |
return status;
|
|
2742 |
}
|
|
2743 |
NW_END_TRY
|
|
2744 |
}
|
|
2745 |
|
|
2746 |
/* ------------------------------------------------------------------------- *
|
|
2747 |
final methods
|
|
2748 |
* ------------------------------------------------------------------------- */
|
|
2749 |
|
|
2750 |
// -----------------------------------------------------------------------------
|
|
2751 |
const NW_XHTML_ElementHandler_t*
|
|
2752 |
NW_XHTML_ContentHandler_GetElementHandler (NW_XHTML_ContentHandler_t* contentHandler,
|
|
2753 |
NW_DOM_ElementNode_t* domElement)
|
|
2754 |
{
|
|
2755 |
int i;
|
|
2756 |
int numModules;
|
|
2757 |
|
|
2758 |
// NW_LOG1(NW_LOG_LEVEL2, "contetnHandler: %x", contentHandler );
|
|
2759 |
|
|
2760 |
/* text nodes handled at content handler level */
|
|
2761 |
if (NW_DOM_Node_getNodeType (domElement) == NW_DOM_TEXT_NODE)
|
|
2762 |
{
|
|
2763 |
// NW_LOG1(NW_LOG_LEVEL2, "NW_XHTML_TextElementHandler: %x", &NW_XHTML_TextElementHandler );
|
|
2764 |
return NW_XHTML_ElementHandlerOf (&NW_XHTML_TextElementHandler);
|
|
2765 |
}
|
|
2766 |
|
|
2767 |
/* PI nodes handled at content handler level */
|
|
2768 |
if (NW_DOM_Node_getNodeType (domElement)
|
|
2769 |
== NW_DOM_PROCESSING_INSTRUCTION_NODE)
|
|
2770 |
{
|
|
2771 |
// NW_LOG1(NW_LOG_LEVEL2, "NW_XHTML_PiElementHandler: %x", &NW_XHTML_PiElementHandler );
|
|
2772 |
return NW_XHTML_ElementHandlerOf (&NW_XHTML_PiElementHandler);
|
|
2773 |
}
|
|
2774 |
|
|
2775 |
/* iterate through the module table */
|
|
2776 |
NW_Uint16 tagToken = NW_HED_DomHelper_GetElementToken (domElement);
|
|
2777 |
numModules = NW_XHTML_ContentHandler_GetClassPart (contentHandler).numModules;
|
|
2778 |
for (i = 0; i < numModules; i++)
|
|
2779 |
{
|
|
2780 |
NW_XHTML_ElementHandler_t* elementHandler;
|
|
2781 |
|
|
2782 |
/* query the module for an appropriate ElementHandler */
|
|
2783 |
const NW_Markup_Module_t* module =
|
|
2784 |
NW_XHTML_ContentHandler_GetClassPart (contentHandler).modules[i];
|
|
2785 |
elementHandler = (NW_XHTML_ElementHandler_t*)
|
|
2786 |
NW_Markup_WBXMLModule_GetHandler (module, tagToken);
|
|
2787 |
|
|
2788 |
/* we found one, return it */
|
|
2789 |
if (elementHandler != NULL)
|
|
2790 |
{
|
|
2791 |
// NW_LOG1(NW_LOG_LEVEL2, "ElementHandler: %x", elementHandler );
|
|
2792 |
return elementHandler;
|
|
2793 |
}
|
|
2794 |
}
|
|
2795 |
/* no ElementHandler was found, so we return the generic
|
|
2796 |
ElementHandler - this will at least allow us to traverse the
|
|
2797 |
children of this unknown node */
|
|
2798 |
// NW_LOG1(NW_LOG_LEVEL2, "NW_XHTML_ElementHandler: %x", &NW_XHTML_ElementHandler );
|
|
2799 |
return &NW_XHTML_ElementHandler;
|
|
2800 |
}
|
|
2801 |
|
|
2802 |
// -----------------------------------------------------------------------------
|
|
2803 |
TBrowserStatusCode
|
|
2804 |
NW_XHTML_GetDOMAttribute (NW_XHTML_ContentHandler_t* thisObj,
|
|
2805 |
NW_DOM_ElementNode_t* elementNode,
|
|
2806 |
const NW_Uint16 token, NW_Text_t** text_t)
|
|
2807 |
{
|
|
2808 |
TBrowserStatusCode status;
|
|
2809 |
NW_String_t value;
|
|
2810 |
NW_Text_t *attributeValue = NULL;
|
|
2811 |
|
|
2812 |
/* get the attribute */
|
|
2813 |
status = NW_HED_DomHelper_GetHTMLAttributeValue
|
|
2814 |
(&thisObj->domHelper, elementNode, token, &value);
|
|
2815 |
|
|
2816 |
/* convert it to a NW_Text */
|
|
2817 |
if (status == KBrsrSuccess)
|
|
2818 |
{
|
|
2819 |
attributeValue = NW_Text_New (HTTP_iso_10646_ucs_2, (void*) NW_String_getStorage (&value),
|
|
2820 |
NW_String_getCharCount (&value, HTTP_iso_10646_ucs_2),
|
|
2821 |
(NW_Uint8) (NW_String_getUserOwnsStorage (&value) ? NW_Text_Flags_TakeOwnership : 0));
|
|
2822 |
}
|
|
2823 |
*text_t = attributeValue;
|
|
2824 |
/* return the result */
|
|
2825 |
return status;
|
|
2826 |
}
|
|
2827 |
|
|
2828 |
// -----------------------------------------------------------------------------
|
|
2829 |
NW_Text_t*
|
|
2830 |
NW_XHTML_GetDOMTextNodeData(NW_XHTML_ContentHandler_t* thisObj,
|
|
2831 |
NW_DOM_TextNode_t* textNode)
|
|
2832 |
{
|
|
2833 |
TBrowserStatusCode status;
|
|
2834 |
NW_String_t value;
|
|
2835 |
NW_Text_t *text = NULL;
|
|
2836 |
NW_Uint32 encoding;
|
|
2837 |
|
|
2838 |
NW_REQUIRED_PARAM (thisObj);
|
|
2839 |
NW_ASSERT(textNode != NULL);
|
|
2840 |
|
|
2841 |
/* extract the text from the element */
|
|
2842 |
status = NW_HED_DomHelper_GetText (&thisObj->domHelper, textNode,
|
|
2843 |
NW_TRUE, &value, &encoding);
|
|
2844 |
|
|
2845 |
|
|
2846 |
/* convert it to a NW_Text */
|
|
2847 |
if (status == KBrsrSuccess)
|
|
2848 |
{
|
|
2849 |
NW_Uint8 flag = 0;
|
|
2850 |
|
|
2851 |
if (NW_String_getUserOwnsStorage (&value) == NW_TRUE)
|
|
2852 |
{
|
|
2853 |
flag = NW_Text_Flags_TakeOwnership;
|
|
2854 |
}
|
|
2855 |
|
|
2856 |
text = NW_Text_New (encoding, value.storage, NW_String_getCharCount (&value,
|
|
2857 |
encoding), flag);
|
|
2858 |
}
|
|
2859 |
|
|
2860 |
return text;
|
|
2861 |
}
|
|
2862 |
|
|
2863 |
// -----------------------------------------------------------------------------
|
|
2864 |
TBrowserStatusCode
|
|
2865 |
NW_XHTML_ContentHandler_StartRequest(NW_XHTML_ContentHandler_t* thisObj,
|
|
2866 |
NW_HED_UrlRequest_t* urlRequest,
|
|
2867 |
void* clientData )
|
|
2868 |
{
|
|
2869 |
return NW_XHTML_ContentHandler_StartRequest_tId(thisObj, urlRequest, clientData , NULL);
|
|
2870 |
}
|
|
2871 |
|
|
2872 |
// -----------------------------------------------------------------------------
|
|
2873 |
TBrowserStatusCode
|
|
2874 |
NW_XHTML_ContentHandler_StartRequest_tId(NW_XHTML_ContentHandler_t* thisObj,
|
|
2875 |
NW_HED_UrlRequest_t* urlRequest,
|
|
2876 |
void* clientData , NW_Uint16* aTransationId)
|
|
2877 |
{
|
|
2878 |
TBrowserStatusCode status;
|
|
2879 |
const NW_Ucs2* origUrl = NULL;
|
|
2880 |
NW_Ucs2* escapedUrl = NULL;
|
|
2881 |
NW_Text_t* resolvedUrl = NULL;
|
|
2882 |
NW_Text_t* retUrl = NULL;
|
|
2883 |
NW_HED_DocumentRoot_t* docRoot;
|
|
2884 |
NW_HED_DocumentNode_t* owner = NULL;
|
|
2885 |
NW_Url_Schema_t schema = NW_SCHEMA_INVALID;
|
|
2886 |
NW_Ucs2* resolvedUrlUcs2 = NULL;
|
|
2887 |
CBodyPart* bodyPart = NULL;
|
|
2888 |
TBool isUrlInMultipart = EFalse;
|
|
2889 |
|
|
2890 |
NW_ASSERT (thisObj != NULL);
|
|
2891 |
NW_ASSERT (urlRequest != NULL);
|
|
2892 |
|
|
2893 |
/* get the orig url as a ucs2 string */
|
|
2894 |
status = KBrsrOutOfMemory;
|
|
2895 |
NW_THROWIF_NULL (origUrl = NW_HED_UrlRequest_GetRawUrl (urlRequest));
|
|
2896 |
|
|
2897 |
/* ensure that the url is escaped correctly */
|
|
2898 |
status = KBrsrOutOfMemory;
|
|
2899 |
|
|
2900 |
NW_THROWIF_NULL (escapedUrl = NW_Str_New(NW_Url_EscapeUnwiseLen(origUrl)));
|
|
2901 |
NW_Url_EscapeUnwise(origUrl, escapedUrl);
|
|
2902 |
|
|
2903 |
NW_Url_GetSchemeNoValidation(escapedUrl, &schema);
|
|
2904 |
|
|
2905 |
/* resolve the url */
|
|
2906 |
status = KBrsrOutOfMemory;
|
|
2907 |
resolvedUrl = NW_Text_New (HTTP_iso_10646_ucs_2, escapedUrl, 0, NW_Text_Flags_TakeOwnership);
|
|
2908 |
NW_THROWIF_NULL (resolvedUrl);
|
|
2909 |
escapedUrl = NULL;
|
|
2910 |
|
|
2911 |
|
|
2912 |
if (schema != NW_SCHEMA_WTAI) {
|
|
2913 |
status = NW_HED_ContentHandler_ResolveURL (thisObj, resolvedUrl, &retUrl );
|
|
2914 |
_NW_THROW_ON_ERROR(status);
|
|
2915 |
|
|
2916 |
/* give ownership back to resolvedUrl */
|
|
2917 |
resolvedUrl = retUrl;
|
|
2918 |
retUrl = NULL;
|
|
2919 |
}
|
|
2920 |
|
|
2921 |
/* update the UrlRequest with the resolved url */
|
|
2922 |
NW_THROWIF_ERROR (status = NW_HED_UrlRequest_UpdateUrl (urlRequest, resolvedUrl));
|
|
2923 |
|
|
2924 |
/* issue the request */
|
|
2925 |
docRoot = (NW_HED_DocumentRoot_t*) NW_HED_DocumentNode_GetRootNode (thisObj);
|
|
2926 |
|
|
2927 |
// load owner is the docroot unless this is a non top level request
|
|
2928 |
owner = NW_HED_DocumentNodeOf( docRoot );
|
|
2929 |
if ( NW_HED_UrlRequest_IsTopLevelRequest( urlRequest ) != NW_TRUE )
|
|
2930 |
{
|
|
2931 |
owner = NW_HED_DocumentNodeOf( thisObj );
|
|
2932 |
}
|
|
2933 |
|
|
2934 |
// compare url with body part
|
|
2935 |
NW_Uint8 freeNeeded;
|
|
2936 |
resolvedUrlUcs2 = NW_Text_GetUCS2Buffer( resolvedUrl, NULL, NULL, &freeNeeded);
|
|
2937 |
isUrlInMultipart = _NW_HED_CompositeContentHandler_IsUrlInMultipart(
|
|
2938 |
NW_HED_CompositeContentHandlerOf(thisObj),
|
|
2939 |
resolvedUrlUcs2, &bodyPart );
|
|
2940 |
if( freeNeeded )
|
|
2941 |
{
|
|
2942 |
NW_Mem_Free( resolvedUrlUcs2 );
|
|
2943 |
}
|
|
2944 |
|
|
2945 |
if( isUrlInMultipart )
|
|
2946 |
{
|
|
2947 |
TDataType dataType( bodyPart->ContentType() );
|
|
2948 |
|
|
2949 |
TUint8* charset = (TUint8*) bodyPart->Charset().Ptr();
|
|
2950 |
TInt lenCh = bodyPart->Charset().Length();
|
|
2951 |
CShell* shell = REINTERPRET_CAST(CShell*, NW_Ctx_Get(NW_CTX_BROWSER_APP, 0));
|
|
2952 |
NW_ASSERT(shell);
|
|
2953 |
TInt32 uidInt = shell->GetUidFromCharset( charset, lenCh );
|
|
2954 |
TUid uid = TUid::Uid( uidInt );
|
|
2955 |
//R
|
|
2956 |
/*
|
|
2957 |
CBrCtl* brCtl = shell->BrCtl();
|
|
2958 |
brCtl->LoadDataL( bodyPart->Url(), bodyPart->Body(), dataType, uid,
|
|
2959 |
owner, clientData, NULL, aTransationId,
|
|
2960 |
urlRequest->loadType, urlRequest->method );*/
|
|
2961 |
}
|
|
2962 |
else
|
|
2963 |
{
|
|
2964 |
// Check if SendReferrerHeader is enabled
|
|
2965 |
if ( NW_Settings_GetSendReferrerHeader() && docRoot->referrerUrl != NULL)
|
|
2966 |
{ // Set Referrer Header
|
|
2967 |
NW_Text_Length_t urlLength;
|
|
2968 |
NW_Uint8 urlFreeNeeded = NW_FALSE;
|
|
2969 |
|
|
2970 |
// convert the url to Unicode and get the storage
|
|
2971 |
NW_Ucs2* referrerUrl = (NW_Ucs2*) NW_Text_GetUCS2Buffer (docRoot->referrerUrl,
|
|
2972 |
NW_Text_Flags_NullTerminated | NW_Text_Flags_Aligned,
|
|
2973 |
&urlLength, &urlFreeNeeded);
|
|
2974 |
|
|
2975 |
SetReferrerHeader(urlRequest, referrerUrl);
|
|
2976 |
|
|
2977 |
if (urlFreeNeeded)
|
|
2978 |
{
|
|
2979 |
NW_Mem_Free(referrerUrl);
|
|
2980 |
}
|
|
2981 |
}
|
|
2982 |
|
|
2983 |
status = NW_HED_DocumentRoot_StartRequest_tId (docRoot, owner, urlRequest, clientData , aTransationId);
|
|
2984 |
}
|
|
2985 |
|
|
2986 |
NW_Object_Delete (resolvedUrl);
|
|
2987 |
resolvedUrl = NULL;
|
|
2988 |
|
|
2989 |
return status;
|
|
2990 |
|
|
2991 |
_NW_CATCH:
|
|
2992 |
NW_CATCH_ERROR
|
|
2993 |
NW_Str_Delete (escapedUrl);
|
|
2994 |
NW_Object_Delete (resolvedUrl);
|
|
2995 |
|
|
2996 |
return status;
|
|
2997 |
}
|
|
2998 |
// -----------------------------------------------------------------------------
|
|
2999 |
TBrowserStatusCode
|
|
3000 |
NW_XHTML_ContentHandler_StartLoad(NW_XHTML_ContentHandler_t* thisObj,
|
|
3001 |
const NW_Text_t* url,
|
|
3002 |
NW_Uint8 reason,
|
|
3003 |
void* clientData,
|
|
3004 |
NW_Uint8 loadType)
|
|
3005 |
{
|
|
3006 |
return NW_XHTML_ContentHandler_StartLoad_tId (thisObj, url, reason,
|
|
3007 |
clientData, loadType, NULL);
|
|
3008 |
|
|
3009 |
}
|
|
3010 |
|
|
3011 |
// -----------------------------------------------------------------------------
|
|
3012 |
TBrowserStatusCode
|
|
3013 |
NW_XHTML_ContentHandler_StartLoad_tId (NW_XHTML_ContentHandler_t* thisObj,
|
|
3014 |
const NW_Text_t* url,
|
|
3015 |
NW_Uint8 reason,
|
|
3016 |
void* clientData,
|
|
3017 |
NW_Uint8 loadType, NW_Uint16* aTransationId)
|
|
3018 |
{
|
|
3019 |
|
|
3020 |
NW_HED_UrlRequest_t* request;
|
|
3021 |
|
|
3022 |
NW_ASSERT (thisObj != NULL);
|
|
3023 |
NW_ASSERT (url != NULL);
|
|
3024 |
|
|
3025 |
NW_TRY (status)
|
|
3026 |
{
|
|
3027 |
/* make a UrlRequest */
|
|
3028 |
if (NW_HED_UrlRequest_Reason_DocLoadHead != reason)
|
|
3029 |
{
|
|
3030 |
request = NW_HED_UrlRequest_New (NW_TextOf (url), NW_URL_METHOD_GET, NULL,
|
|
3031 |
NULL, reason, NW_HED_UrlRequest_LoadNormal, loadType);
|
|
3032 |
}
|
|
3033 |
else
|
|
3034 |
{
|
|
3035 |
request = NW_HED_UrlRequest_New(NW_TextOf (url), NW_URL_METHOD_HEAD, NULL,
|
|
3036 |
NULL, reason, NW_HED_UrlRequest_LoadNormal, loadType);
|
|
3037 |
}
|
|
3038 |
|
|
3039 |
NW_THROW_OOM_ON_NULL (request, status);
|
|
3040 |
|
|
3041 |
if (NW_XHTML_ContentHandler_IsSaveddeck(thisObj) &&
|
|
3042 |
NW_HED_UrlRequest_Reason_DocLoadChild == reason &&
|
|
3043 |
// Allow to load a plugin from a saved page, because the user explicitly requested it
|
|
3044 |
loadType != NW_UrlRequest_Type_Plugin)
|
|
3045 |
{
|
|
3046 |
NW_HED_UrlRequest_SetCacheMode(request, NW_CACHE_ONLYCACHE);
|
|
3047 |
}
|
|
3048 |
|
|
3049 |
if(NW_XHTML_ContentHandler_IsHistoryLoad(thisObj) &&
|
|
3050 |
NW_HED_UrlRequest_Reason_DocLoadChild == reason)
|
|
3051 |
{
|
|
3052 |
NW_HED_UrlRequest_SetCacheMode(request, NW_CACHE_HISTPREV);
|
|
3053 |
}
|
|
3054 |
|
|
3055 |
if(NW_XHTML_ContentHandler_IsReLoad(thisObj) &&
|
|
3056 |
NW_HED_UrlRequest_Reason_DocLoadChild == reason)
|
|
3057 |
{
|
|
3058 |
NW_HED_UrlRequest_SetCacheMode(request, NW_CACHE_NOCACHE);
|
|
3059 |
}
|
|
3060 |
|
|
3061 |
/* pass it to StartRequest to be satisfied */
|
|
3062 |
status = NW_XHTML_ContentHandler_StartRequest_tId (thisObj, request, clientData , aTransationId);
|
|
3063 |
_NW_THROW_ON_ERROR (status);
|
|
3064 |
}
|
|
3065 |
NW_CATCH (status)
|
|
3066 |
{
|
|
3067 |
if (request)
|
|
3068 |
{
|
|
3069 |
NW_Object_Delete(request);
|
|
3070 |
}
|
|
3071 |
}
|
|
3072 |
NW_FINALLY {
|
|
3073 |
return status;
|
|
3074 |
} NW_END_TRY
|
|
3075 |
}
|
|
3076 |
|
|
3077 |
// -----------------------------------------------------------------------------
|
|
3078 |
TBrowserStatusCode
|
|
3079 |
NW_XHTML_ContentHandler_SetLoadObserver(NW_XHTML_ContentHandler_t* thisObj,
|
|
3080 |
NW_Uint16 aTransationId,
|
|
3081 |
MHEDLoadObserver* aLoadObserver)
|
|
3082 |
{
|
|
3083 |
NW_HED_DocumentRoot_t* docRoot = (NW_HED_DocumentRoot_t*)
|
|
3084 |
NW_HED_DocumentNode_GetRootNode (thisObj);
|
|
3085 |
|
|
3086 |
return NW_HED_DocumentRoot_SetLoadObserver(docRoot, aTransationId, aLoadObserver);
|
|
3087 |
}
|
|
3088 |
|
|
3089 |
// -----------------------------------------------------------------------------
|
|
3090 |
NW_CSS_Processor_t*
|
|
3091 |
NW_XHTML_ContentHandler_CreateCSSProcessor(NW_XHTML_ContentHandler_t* thisObj)
|
|
3092 |
{
|
|
3093 |
if (thisObj->processor == NULL)
|
|
3094 |
{
|
|
3095 |
thisObj->processor = NW_CSS_Processor_New();
|
|
3096 |
if (thisObj->processor != NULL)
|
|
3097 |
{
|
|
3098 |
NW_CSS_Processor_SetOwner(thisObj->processor, NW_HED_DocumentNodeOf(thisObj));
|
|
3099 |
NW_CSS_Processor_SetDictionary(thisObj->processor,
|
|
3100 |
(NW_WBXML_Dictionary_t *) & NW_XHTML_WBXMLDictionary);
|
|
3101 |
NW_CSS_Processor_SetApplyCSSCallback(thisObj->processor,
|
|
3102 |
NW_XHTML_ElementHandler_ApplyCSSCallback);
|
|
3103 |
thisObj->processor->isSavedDeck = NW_XHTML_ContentHandler_IsSaveddeck(thisObj);
|
|
3104 |
thisObj->processor->isHistLoad = NW_XHTML_ContentHandler_IsHistoryLoad(thisObj);
|
|
3105 |
thisObj->processor->isReLoad = NW_XHTML_ContentHandler_IsReLoad(thisObj);
|
|
3106 |
|
|
3107 |
}
|
|
3108 |
}
|
|
3109 |
return thisObj->processor;
|
|
3110 |
}
|
|
3111 |
|
|
3112 |
// -----------------------------------------------------------------------------
|
|
3113 |
NW_WBXML_Dictionary_t*
|
|
3114 |
NW_XHTML_ContentHandler_GetDictionary(NW_XHTML_ContentHandler_t* contentHandler)
|
|
3115 |
{
|
|
3116 |
NW_REQUIRED_PARAM(contentHandler);
|
|
3117 |
return (NW_WBXML_Dictionary_t *) & NW_XHTML_WBXMLDictionary;
|
|
3118 |
}
|
|
3119 |
|
|
3120 |
// -----------------------------------------------------------------------------
|
|
3121 |
TBrowserStatusCode
|
|
3122 |
NW_XHTML_ContentHandler_AddFormLiaison(
|
|
3123 |
NW_XHTML_ContentHandler_t* contentHandler,
|
|
3124 |
NW_DOM_ElementNode_t* formNode)
|
|
3125 |
{
|
|
3126 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
3127 |
NW_XHTML_FormLiaison_t* formLiaison;
|
|
3128 |
NW_XHTML_ContentHandler_t* thisObj = NW_XHTML_ContentHandlerOf (contentHandler);
|
|
3129 |
|
|
3130 |
/* make sure we have a control set */
|
|
3131 |
if (contentHandler->controlSet == NULL)
|
|
3132 |
{
|
|
3133 |
/* no control set; make sure we have a value set */
|
|
3134 |
if (contentHandler->controlValueSet == NULL)
|
|
3135 |
{
|
|
3136 |
/* no value set; make an empty one */
|
|
3137 |
contentHandler->controlValueSet =
|
|
3138 |
(NW_ADT_DynamicVector_t*) NW_ADT_ResizableObjectVector_New(0, 5);
|
|
3139 |
if (contentHandler->controlValueSet == NULL)
|
|
3140 |
{
|
|
3141 |
return KBrsrOutOfMemory;
|
|
3142 |
}
|
|
3143 |
}
|
|
3144 |
|
|
3145 |
contentHandler->controlSet =
|
|
3146 |
NW_XHTML_ControlSet_New(contentHandler->controlValueSet);
|
|
3147 |
if (contentHandler->controlSet == NULL)
|
|
3148 |
{
|
|
3149 |
return KBrsrOutOfMemory;
|
|
3150 |
}
|
|
3151 |
contentHandler->controlValueSet = NULL; /* controlSet now has ownership */
|
|
3152 |
}
|
|
3153 |
|
|
3154 |
formLiaison = NW_XHTML_FormLiaison_New(formNode,
|
|
3155 |
contentHandler,
|
|
3156 |
contentHandler->controlSet);
|
|
3157 |
if (formLiaison == NULL)
|
|
3158 |
{
|
|
3159 |
return KBrsrOutOfMemory;
|
|
3160 |
}
|
|
3161 |
|
|
3162 |
NW_XHTML_Form_Node_Context_t* formContext = new NW_XHTML_Form_Node_Context_t;
|
|
3163 |
//lint -e{774} Boolean within 'if' always evaluates to False
|
|
3164 |
if (formContext != NULL)
|
|
3165 |
{
|
|
3166 |
formContext->formNode = formNode;
|
|
3167 |
formContext->formLiaison = (NW_FBox_FormLiaison_t*)formLiaison;
|
|
3168 |
|
|
3169 |
// append formContext to nodeContext vector
|
|
3170 |
if (NW_ADT_DynamicVector_InsertAt
|
|
3171 |
(thisObj->nodeContexts, &formContext, NW_ADT_Vector_AtEnd ) == NULL)
|
|
3172 |
{
|
|
3173 |
status = KBrsrOutOfMemory;
|
|
3174 |
}
|
|
3175 |
}
|
|
3176 |
else
|
|
3177 |
{
|
|
3178 |
status = KBrsrOutOfMemory;
|
|
3179 |
}
|
|
3180 |
|
|
3181 |
|
|
3182 |
if (status != KBrsrSuccess)
|
|
3183 |
{
|
|
3184 |
NW_Object_Delete(formLiaison);
|
|
3185 |
}
|
|
3186 |
|
|
3187 |
return status;
|
|
3188 |
}
|
|
3189 |
|
|
3190 |
// -----------------------------------------------------------------------------
|
|
3191 |
NW_FBox_FormLiaison_t*
|
|
3192 |
NW_XHTML_ContentHandler_GetFormLiaison(NW_XHTML_ContentHandler_t* contentHandler,
|
|
3193 |
NW_DOM_ElementNode_t* elementNode)
|
|
3194 |
{
|
|
3195 |
NW_XHTML_FormLiaison_t* formLiaison = NULL;
|
|
3196 |
NW_DOM_ElementNode_t* node = NULL;
|
|
3197 |
NW_XHTML_ContentHandler_t* thisObj = NW_XHTML_ContentHandlerOf (contentHandler);
|
|
3198 |
|
|
3199 |
|
|
3200 |
if (elementNode != NULL)
|
|
3201 |
{
|
|
3202 |
node = NW_XHTML_ContentHandler_GetFormNode(contentHandler,elementNode);
|
|
3203 |
if (node != NULL)
|
|
3204 |
{
|
|
3205 |
//if we found the form, get the associated form liaison */
|
|
3206 |
NW_ADT_Vector_Metric_t nodeCtxSize = NW_ADT_Vector_GetSize(thisObj->nodeContexts);
|
|
3207 |
for (NW_ADT_Vector_Metric_t i = 0 ; i < nodeCtxSize; i++)
|
|
3208 |
{
|
|
3209 |
NW_XHTML_Form_Node_Context_t* formCtx =
|
|
3210 |
*(NW_XHTML_Form_Node_Context_t**)NW_ADT_Vector_ElementAt (thisObj->nodeContexts, i);
|
|
3211 |
if (formCtx->formNode == node )
|
|
3212 |
{
|
|
3213 |
formLiaison = (NW_XHTML_FormLiaison_t*)formCtx->formLiaison;
|
|
3214 |
break;
|
|
3215 |
}
|
|
3216 |
}
|
|
3217 |
}
|
|
3218 |
}
|
|
3219 |
return NW_FBox_FormLiaisonOf(formLiaison);
|
|
3220 |
}
|
|
3221 |
|
|
3222 |
|
|
3223 |
/* ------------------------------------------------------------------------- *
|
|
3224 |
NW_Markup_NumberCollector methods
|
|
3225 |
* ------------------------------------------------------------------------- */
|
|
3226 |
|
|
3227 |
// -----------------------------------------------------------------------------
|
|
3228 |
NW_LMgr_Box_t*
|
|
3229 |
_NW_XHTML_ContentHandler_NumberCollector_GetBoxTree (NW_Markup_NumberCollector_t*
|
|
3230 |
numberCollector)
|
|
3231 |
{
|
|
3232 |
NW_XHTML_ContentHandler_t* thisObj;
|
|
3233 |
NW_LMgr_Box_t* boxTree;
|
|
3234 |
|
|
3235 |
/* parameter assertion block */
|
|
3236 |
NW_ASSERT (NW_Object_IsInstanceOf (numberCollector,
|
|
3237 |
&NW_XHTML_ContentHandler_NumberCollector_Class));
|
|
3238 |
|
|
3239 |
/* for convenience */
|
|
3240 |
thisObj = static_cast<NW_XHTML_ContentHandler_t*>
|
|
3241 |
(NW_Object_Aggregate_GetAggregator (numberCollector));
|
|
3242 |
NW_ASSERT (NW_Object_IsInstanceOf (thisObj, &NW_XHTML_ContentHandler_Class));
|
|
3243 |
|
|
3244 |
/* return the box tree */
|
|
3245 |
(void) NW_HED_DocumentNode_GetBoxTree (thisObj, &boxTree);
|
|
3246 |
return boxTree;
|
|
3247 |
}
|
|
3248 |
|
|
3249 |
/* ------------------------------------------------------------------------- *
|
|
3250 |
NW_Markup_NumberCollector methods
|
|
3251 |
* ------------------------------------------------------------------------- */
|
|
3252 |
|
|
3253 |
|
|
3254 |
// -----------------------------------------------------------------------------
|
|
3255 |
NW_Text_t*
|
|
3256 |
_NW_XHTML_ContentHandler_NumberCollector_GetHrefAttr (NW_Markup_NumberCollector_t*
|
|
3257 |
numberCollector,
|
|
3258 |
NW_LMgr_Box_t* box)
|
|
3259 |
{
|
|
3260 |
NW_XHTML_ContentHandler_t* thisObj;
|
|
3261 |
NW_HED_EventHandler_t* eventHandler = NULL;
|
|
3262 |
NW_DOM_ElementNode_t* elementNode;
|
|
3263 |
NW_Text_t* text = NULL;
|
|
3264 |
NW_Text_t* retUrl = NULL;
|
|
3265 |
|
|
3266 |
/* parameter assertion block */
|
|
3267 |
NW_ASSERT (NW_Object_IsInstanceOf (numberCollector,
|
|
3268 |
&NW_XHTML_ContentHandler_NumberCollector_Class));
|
|
3269 |
NW_ASSERT(NW_Object_IsInstanceOf(box, &NW_LMgr_ActiveContainerBox_Class));
|
|
3270 |
|
|
3271 |
/* for convenience */
|
|
3272 |
thisObj = static_cast<NW_XHTML_ContentHandler_t*>
|
|
3273 |
(NW_Object_Aggregate_GetAggregator (numberCollector));
|
|
3274 |
NW_ASSERT (NW_Object_IsInstanceOf (thisObj, &NW_XHTML_ContentHandler_Class));
|
|
3275 |
|
|
3276 |
|
|
3277 |
eventHandler = (NW_HED_EventHandler_t *)((NW_LMgr_ActiveContainerBoxOf(box))->eventHandler);
|
|
3278 |
elementNode = (NW_DOM_ElementNode_t *)(eventHandler->context);
|
|
3279 |
if(NW_LMgr_ActiveContainerBoxOf(box)->hrefAttr != NULL)
|
|
3280 |
{
|
|
3281 |
text = NW_Text_Copy(NW_LMgr_ActiveContainerBoxOf(box)->hrefAttr, NW_TRUE);
|
|
3282 |
}
|
|
3283 |
else
|
|
3284 |
{
|
|
3285 |
NW_XHTML_GetDOMAttribute (thisObj, elementNode, NW_XHTML_AttributeToken_href, &text);
|
|
3286 |
}
|
|
3287 |
if (text)
|
|
3288 |
{
|
|
3289 |
(void)NW_HED_ContentHandler_ResolveURL ((NW_HED_ContentHandler_t *)thisObj, text, &retUrl);
|
|
3290 |
text = retUrl;
|
|
3291 |
}
|
|
3292 |
return text;
|
|
3293 |
}
|
|
3294 |
|
|
3295 |
// -----------------------------------------------------------------------------
|
|
3296 |
NW_Text_t*
|
|
3297 |
_NW_XHTML_ContentHandler_NumberCollector_GetAltAttr (NW_Markup_NumberCollector_t*
|
|
3298 |
numberCollector,
|
|
3299 |
NW_LMgr_Box_t* box)
|
|
3300 |
{
|
|
3301 |
NW_LMgr_PropertyValue_t value;
|
|
3302 |
NW_XHTML_ContentHandler_t* thisObj;
|
|
3303 |
NW_Text_t* text = NULL;
|
|
3304 |
NW_DOM_ElementNode_t* elementNode;
|
|
3305 |
|
|
3306 |
/* parameter assertion block */
|
|
3307 |
NW_ASSERT (NW_Object_IsInstanceOf (numberCollector,
|
|
3308 |
&NW_XHTML_ContentHandler_NumberCollector_Class));
|
|
3309 |
|
|
3310 |
/* for convenience */
|
|
3311 |
thisObj = static_cast<NW_XHTML_ContentHandler_t*>
|
|
3312 |
(NW_Object_Aggregate_GetAggregator (numberCollector));
|
|
3313 |
NW_ASSERT (NW_Object_IsInstanceOf (thisObj, &NW_XHTML_ContentHandler_Class));
|
|
3314 |
|
|
3315 |
value.object = NULL;
|
|
3316 |
(void)NW_LMgr_Box_GetPropertyValue(box, NW_CSS_Prop_elementId, NW_CSS_ValueType_Object,
|
|
3317 |
&value);
|
|
3318 |
if (value.object)
|
|
3319 |
{
|
|
3320 |
elementNode = (NW_DOM_ElementNode_t *)(value.object);
|
|
3321 |
NW_XHTML_GetDOMAttribute (thisObj, elementNode, NW_XHTML_AttributeToken_alt, &text);
|
|
3322 |
}
|
|
3323 |
return text;
|
|
3324 |
}
|
|
3325 |
|
|
3326 |
// -----------------------------------------------------------------------------
|
|
3327 |
// NW_XHTML_ContentHandler_IsSaveddeck
|
|
3328 |
// Description: Used for cache-only loading for embeded elements in saved file
|
|
3329 |
// (other items were commented in a header).
|
|
3330 |
// Returns: NW_Bool: true if the xhtml content is retrieved from saved deck
|
|
3331 |
// false, otherwise
|
|
3332 |
// -----------------------------------------------------------------------------
|
|
3333 |
//
|
|
3334 |
NW_Bool
|
|
3335 |
NW_XHTML_ContentHandler_IsSaveddeck(const NW_XHTML_ContentHandler_t* thisObj)
|
|
3336 |
{
|
|
3337 |
NW_ASSERT (thisObj);
|
|
3338 |
return thisObj->saveddeck;
|
|
3339 |
}
|
|
3340 |
|
|
3341 |
// -----------------------------------------------------------------------------
|
|
3342 |
// NW_XHTML_ContentHandler_IsHistoryLoad
|
|
3343 |
// Description: Used for setting cache mode for embeded elements
|
|
3344 |
// (other items were commented in a header).
|
|
3345 |
// Returns: NW_Bool: true if the xhtml content is result of history load
|
|
3346 |
// false, otherwise
|
|
3347 |
// -----------------------------------------------------------------------------
|
|
3348 |
//
|
|
3349 |
NW_Bool
|
|
3350 |
NW_XHTML_ContentHandler_IsHistoryLoad(const NW_XHTML_ContentHandler_t* thisObj)
|
|
3351 |
{
|
|
3352 |
NW_ASSERT (thisObj);
|
|
3353 |
return thisObj->histload;
|
|
3354 |
}
|
|
3355 |
|
|
3356 |
|
|
3357 |
// -----------------------------------------------------------------------------
|
|
3358 |
// NW_XHTML_ContentHandler_IsReLoad
|
|
3359 |
// Description: Used for setting cache mode for embeded elements
|
|
3360 |
// (other items were commented in a header).
|
|
3361 |
// Returns: NW_Bool: true if the xhtml content is result of reload
|
|
3362 |
// false, otherwise
|
|
3363 |
// -----------------------------------------------------------------------------
|
|
3364 |
//
|
|
3365 |
NW_Bool
|
|
3366 |
NW_XHTML_ContentHandler_IsReLoad(const NW_XHTML_ContentHandler_t* thisObj)
|
|
3367 |
{
|
|
3368 |
NW_ASSERT (thisObj);
|
|
3369 |
return thisObj->reload;
|
|
3370 |
}
|
|
3371 |
|
|
3372 |
// -----------------------------------------------------------------------------
|
|
3373 |
// NW_XHTML_ContentHandler_SetSaveddeck
|
|
3374 |
// Description: set the saveddeck boolean member
|
|
3375 |
// Returns: TBrowserStatusCode
|
|
3376 |
// -----------------------------------------------------------------------------
|
|
3377 |
//
|
|
3378 |
TBrowserStatusCode
|
|
3379 |
NW_XHTML_ContentHandler_SetSaveddeck(NW_XHTML_ContentHandler_t *thisObj, NW_Bool isSaveddeck)
|
|
3380 |
{
|
|
3381 |
NW_ASSERT (thisObj);
|
|
3382 |
thisObj->saveddeck = isSaveddeck;
|
|
3383 |
return KBrsrSuccess;
|
|
3384 |
}
|
|
3385 |
|
|
3386 |
// -----------------------------------------------------------------------------
|
|
3387 |
// NW_XHTML_ContentHandler_SetHistoryLoad
|
|
3388 |
// Description: set the histload boolean member
|
|
3389 |
// Returns: TBrowserStatusCode
|
|
3390 |
// -----------------------------------------------------------------------------
|
|
3391 |
//
|
|
3392 |
TBrowserStatusCode
|
|
3393 |
NW_XHTML_ContentHandler_SetHistoryLoad(NW_XHTML_ContentHandler_t *thisObj, NW_Bool isHistLoad)
|
|
3394 |
{
|
|
3395 |
NW_ASSERT (thisObj);
|
|
3396 |
thisObj->histload = isHistLoad;
|
|
3397 |
return KBrsrSuccess;
|
|
3398 |
}
|
|
3399 |
|
|
3400 |
// -----------------------------------------------------------------------------
|
|
3401 |
// NW_XHTML_ContentHandler_SetReLoad
|
|
3402 |
// Description: set the reload boolean member
|
|
3403 |
// Returns: TBrowserStatusCode
|
|
3404 |
// -----------------------------------------------------------------------------
|
|
3405 |
//
|
|
3406 |
TBrowserStatusCode
|
|
3407 |
NW_XHTML_ContentHandler_SetReLoad(NW_XHTML_ContentHandler_t *thisObj, NW_Bool isReLoad)
|
|
3408 |
{
|
|
3409 |
NW_ASSERT (thisObj);
|
|
3410 |
thisObj->reload = isReLoad;
|
|
3411 |
return KBrsrSuccess;
|
|
3412 |
}
|
|
3413 |
|
|
3414 |
// -----------------------------------------------------------------------------
|
|
3415 |
// NW_XHTML_ContentHandler_MetaRefreshInitialize
|
|
3416 |
// Description: Initialize the META refresh. If and only if returns success, the
|
|
3417 |
// content handler object will take ownership of and assume responsibility for
|
|
3418 |
// destructing the resolvedUrl object. Once initialized, the content handler
|
|
3419 |
// object performs the META refresh when needed.
|
|
3420 |
// Returns: TBrowserStatusCode
|
|
3421 |
// -----------------------------------------------------------------------------
|
|
3422 |
//
|
|
3423 |
TBrowserStatusCode
|
|
3424 |
NW_XHTML_ContentHandler_MetaRefreshInitialize(NW_XHTML_ContentHandler_t* thisObj,
|
|
3425 |
NW_Int32 seconds,
|
|
3426 |
NW_Text_t* resolvedUrl,
|
|
3427 |
NW_Uint8 loadReason)
|
|
3428 |
{
|
|
3429 |
NW_ASSERT (thisObj);
|
|
3430 |
NW_ASSERT (resolvedUrl);
|
|
3431 |
|
|
3432 |
/* Cannot be set more than once. */
|
|
3433 |
if (thisObj->metaRefreshSet)
|
|
3434 |
{
|
|
3435 |
return KBrsrUnexpectedError;
|
|
3436 |
}
|
|
3437 |
/* Save the variables for later. */
|
|
3438 |
thisObj->metaRefreshSet = NW_TRUE;
|
|
3439 |
thisObj->metaRefreshSeconds = seconds;
|
|
3440 |
thisObj->metaRefreshLoadReason = loadReason;
|
|
3441 |
thisObj->metaRefreshResolvedUrl = resolvedUrl; // We own the object now.
|
|
3442 |
return KBrsrSuccess;
|
|
3443 |
}
|
|
3444 |
|
|
3445 |
// -----------------------------------------------------------------------------
|
|
3446 |
void
|
|
3447 |
NW_XHTML_ContentHandler_SetImageMapLookupTable(NW_XHTML_ContentHandler_t *thisObj,
|
|
3448 |
void* imageMapLookupTable)
|
|
3449 |
{
|
|
3450 |
thisObj->imageMapLookupTable = imageMapLookupTable;
|
|
3451 |
}
|
|
3452 |
|
|
3453 |
// -----------------------------------------------------------------------------
|
|
3454 |
void
|
|
3455 |
NW_XHTML_ContentHandler_SetReferrerUrl(NW_XHTML_ContentHandler_t *thisObj)
|
|
3456 |
{
|
|
3457 |
const NW_Text_t* url =
|
|
3458 |
NW_HED_UrlResponse_GetUrl( NW_HED_ContentHandler_GetUrlResponse(thisObj));
|
|
3459 |
|
|
3460 |
NW_HED_DocumentRoot_t* docRoot = (NW_HED_DocumentRoot_t*)
|
|
3461 |
NW_HED_DocumentNode_GetRootNode (thisObj);
|
|
3462 |
|
|
3463 |
// The HTTP referrer header is being SET only if it is request from http or https.
|
|
3464 |
//If it is any other request then don't set this. For example, link from the static
|
|
3465 |
//file.
|
|
3466 |
|
|
3467 |
if( (NW_Str_Strnicmp((const NW_Ucs2*) url->storage, (const NW_Ucs2*) NW_STR("http:"), 5) == 0) ||
|
|
3468 |
(NW_Str_Strnicmp((const NW_Ucs2*) url->storage, (const NW_Ucs2*) NW_STR("https:"), 6) == 0) )
|
|
3469 |
{
|
|
3470 |
NW_HED_DocumentRoot_SetDocumentReferrer(docRoot , url);
|
|
3471 |
}
|
|
3472 |
else
|
|
3473 |
{
|
|
3474 |
NW_HED_DocumentRoot_SetDocumentReferrer(docRoot , NULL);
|
|
3475 |
}
|
|
3476 |
}
|
|
3477 |
|
|
3478 |
// -----------------------------------------------------------------------------
|
|
3479 |
void*
|
|
3480 |
NW_XHTML_ContentHandler_GetImageMapLookupTable(NW_XHTML_ContentHandler_t *thisObj)
|
|
3481 |
{
|
|
3482 |
return thisObj->imageMapLookupTable;
|
|
3483 |
}
|
|
3484 |
|
|
3485 |
|
|
3486 |
// the function appends the transactionId to a list of pending script load
|
|
3487 |
// requests. The function is called from scriptelementhandler after issuing
|
|
3488 |
// a load request from external scripts
|
|
3489 |
TBrowserStatusCode
|
|
3490 |
NW_XHTML_ContentHandler_AddToPendingScriptTids(NW_XHTML_ContentHandler_t *thisObj, const TExternalScriptNode& aScriptNodeId )
|
|
3491 |
{
|
|
3492 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
3493 |
TBool foundScriptIndex = EFalse;
|
|
3494 |
RArray<TExternalScriptNode>* scriptIds = STATIC_CAST(RArray<TExternalScriptNode>*, thisObj->scriptLoadTransactionIds);
|
|
3495 |
TInt length = scriptIds->Count();
|
|
3496 |
for (TInt index = 0 ; index < length ; index++)
|
|
3497 |
{
|
|
3498 |
TExternalScriptNode& scriptNode = (*scriptIds)[index];
|
|
3499 |
if (scriptNode.iTransactionId == aScriptNodeId.iTransactionId )
|
|
3500 |
{
|
|
3501 |
foundScriptIndex = ETrue;
|
|
3502 |
break;
|
|
3503 |
}
|
|
3504 |
}
|
|
3505 |
|
|
3506 |
|
|
3507 |
// append to the scriptTid list
|
|
3508 |
if (!foundScriptIndex)
|
|
3509 |
{
|
|
3510 |
TInt err = scriptIds->Append(aScriptNodeId);
|
|
3511 |
if ( err != KErrNone)
|
|
3512 |
{
|
|
3513 |
status = (err == KErrNoMemory) ? KBrsrOutOfMemory : KBrsrFailure;
|
|
3514 |
}
|
|
3515 |
}
|
|
3516 |
return status;
|
|
3517 |
}
|
|
3518 |
// the function returns the count of outstanding pending requests for external scripts
|
|
3519 |
NW_Uint8
|
|
3520 |
NW_XHTML_ContentHandler_PendingScriptLoadCount(NW_XHTML_ContentHandler_t *thisObj)
|
|
3521 |
{
|
|
3522 |
RArray<TExternalScriptNode>* scriptIds = STATIC_CAST(RArray<TExternalScriptNode>*, thisObj->scriptLoadTransactionIds);
|
|
3523 |
return (NW_Uint8)scriptIds->Count();
|
|
3524 |
}
|
|
3525 |
// the function checks if the element node depends on the external scripts ,
|
|
3526 |
// To check for dependency , check if there are any external script nodes that were before aElementNode
|
|
3527 |
NW_Bool
|
|
3528 |
NW_XHTML_ContentHandler_IsScriptLoadPending(NW_XHTML_ContentHandler_t *thisObj, NW_DOM_ElementNode_t* aElementNode)
|
|
3529 |
{
|
|
3530 |
NW_Bool depends = NW_FALSE;
|
|
3531 |
RArray<TExternalScriptNode>* scriptIds = STATIC_CAST(RArray<TExternalScriptNode>*, thisObj->scriptLoadTransactionIds);
|
|
3532 |
// if the pending script count is 0 then return NW_FALSE
|
|
3533 |
// check if the first script node in the pending list > aElementNode then return NW_FALSE, else NW_TRUE
|
|
3534 |
if(scriptIds->Count())
|
|
3535 |
{
|
|
3536 |
NW_DOM_ElementNode_t* scriptNode = (*scriptIds)[0].iScriptNode;
|
|
3537 |
if (scriptNode->source_offset > aElementNode->source_offset)
|
|
3538 |
{
|
|
3539 |
depends = NW_FALSE;
|
|
3540 |
}
|
|
3541 |
else
|
|
3542 |
{
|
|
3543 |
depends = NW_TRUE;
|
|
3544 |
}
|
|
3545 |
}
|
|
3546 |
else
|
|
3547 |
{
|
|
3548 |
depends = NW_FALSE;
|
|
3549 |
}
|
|
3550 |
return depends ;
|
|
3551 |
}
|
|
3552 |
// add the form node to the document form nodes list
|
|
3553 |
TBrowserStatusCode
|
|
3554 |
NW_XHTML_ContentHandler_AddFormNodes(NW_XHTML_ContentHandler_t *aThisObj, NW_DOM_ElementNode_t* aElementNode)
|
|
3555 |
{
|
|
3556 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
3557 |
RPointerArray<NW_DOM_ElementNode_t>* formNodes = (RPointerArray<NW_DOM_ElementNode_t>*)aThisObj->formNodes;
|
|
3558 |
TInt err = formNodes->Append(aElementNode);
|
|
3559 |
if ( err != KErrNone)
|
|
3560 |
{
|
|
3561 |
status = (err == KErrNoMemory) ? KBrsrOutOfMemory : KBrsrFailure;
|
|
3562 |
}
|
|
3563 |
return status;
|
|
3564 |
}
|
|
3565 |
|
|
3566 |
// Returns the form node for a given input element node. The mechanism used
|
|
3567 |
// here to find the form node is to search through the array of form nodes in
|
|
3568 |
// reverse, comparing the element's source offset with that of the form node
|
|
3569 |
// until the form node's source offset is <= to the element's source offset.
|
|
3570 |
//
|
|
3571 |
// WARNING:
|
|
3572 |
//
|
|
3573 |
// This approach has a flaw in it. It assumes that the source offset is
|
|
3574 |
// accurate; that all the items are inserted sequentially. However, this is not
|
|
3575 |
// the case for script-generated forms. Script forms get parsed separately as
|
|
3576 |
// though they are separate streams/files. The source offset then ends up being
|
|
3577 |
// relative to the start of the script and not the top-level HTML. Hence, for
|
|
3578 |
// these cases, the source offset is not reliable.
|
|
3579 |
//
|
|
3580 |
// One example use case as of this writing is the delete button of the inbox
|
|
3581 |
// email for www.excite.com wasn't working because it has several forms on the
|
|
3582 |
// page along with a script-generated form.
|
|
3583 |
//
|
|
3584 |
NW_DOM_ElementNode_t*
|
|
3585 |
NW_XHTML_ContentHandler_GetFormNodeFromSourceOffset(
|
|
3586 |
NW_XHTML_ContentHandler_t *aThisObj, NW_DOM_ElementNode_t* aElementNode)
|
|
3587 |
{
|
|
3588 |
NW_DOM_ElementNode_t* node = NULL;
|
|
3589 |
// get all the form nodes in the document
|
|
3590 |
RPointerArray<NW_DOM_ElementNode_t>* formNodes = (RPointerArray<NW_DOM_ElementNode_t>*)aThisObj->formNodes;
|
|
3591 |
// check the under what umberall does the input element fall under
|
|
3592 |
for (TInt nodeIndex = formNodes->Count()-1; nodeIndex >=0; nodeIndex--)
|
|
3593 |
{
|
|
3594 |
// the first formNode to have the offset <= elementNode offset , it is the candidate
|
|
3595 |
NW_DOM_ElementNode_t* formNode = (*formNodes)[nodeIndex];
|
|
3596 |
if(formNode->source_offset <= aElementNode->source_offset)
|
|
3597 |
{
|
|
3598 |
node = formNode;
|
|
3599 |
break;
|
|
3600 |
}
|
|
3601 |
}
|
|
3602 |
return node;
|
|
3603 |
}
|
|
3604 |
|
|
3605 |
// Returns the form node for a given input element node. The mechanism used
|
|
3606 |
// here to find the form nodes is to walk up the DOM tree until the parent
|
|
3607 |
// form node is found.
|
|
3608 |
//
|
|
3609 |
// WARNING:
|
|
3610 |
//
|
|
3611 |
// This approach assumes the DOM tree is accurate with the form node always
|
|
3612 |
// being the parent node of its form elements - as it should be. However,
|
|
3613 |
// under certain circumstances of poorly structured HTML, the current DOM tree
|
|
3614 |
// processing does not place the form node as a parent of the form elements.
|
|
3615 |
//
|
|
3616 |
// One example use case of an incorrect DOM tree as of this writing is from the
|
|
3617 |
// Nokia test suite:
|
|
3618 |
// testsuite.nokia-boston.com/s60accept/cannedSites/fedexCopy/fedex.html
|
|
3619 |
//
|
|
3620 |
NW_DOM_ElementNode_t*
|
|
3621 |
NW_XHTML_ContentHandler_GetFormNodeFromDomTree(
|
|
3622 |
NW_XHTML_ContentHandler_t *aThisObj, NW_DOM_ElementNode_t* aElementNode)
|
|
3623 |
{
|
|
3624 |
NW_REQUIRED_PARAM(aThisObj);
|
|
3625 |
|
|
3626 |
NW_DOM_ElementNode_t* node = aElementNode;
|
|
3627 |
|
|
3628 |
// Walk up the DOM tree until parent form node is found or top is reached.
|
|
3629 |
while (node && (NW_DOM_Node_getNodeToken(node) != NW_XHTML_ElementToken_form))
|
|
3630 |
{
|
|
3631 |
node = NW_DOM_Node_getParentNode(node);
|
|
3632 |
}
|
|
3633 |
return node;
|
|
3634 |
}
|
|
3635 |
|
|
3636 |
// Returns the form node for a given input element node or NULL if none.
|
|
3637 |
// An attempt is made to first get the form node by walking up the DOM tree.
|
|
3638 |
// The DOM tree isn't always accurate (described above); hence, as a backup if
|
|
3639 |
// the form node isn't found by walking up the DOM tree, then a second approach
|
|
3640 |
// is used - search the form node array using source offset. This 2nd approach
|
|
3641 |
// is also not always accruate (described above) and is even less reliable.
|
|
3642 |
//
|
|
3643 |
// Given that both mechanisms of finding the form node do not always work,
|
|
3644 |
// there is the possibility that the wrong form node (or none) will be returned
|
|
3645 |
// for some theoretical poorly structured HTML. If this should arise, the more
|
|
3646 |
// rebust solution is to fix the DOM parsing such that form element nodes are
|
|
3647 |
// always descendants of their form node.
|
|
3648 |
//
|
|
3649 |
NW_DOM_ElementNode_t*
|
|
3650 |
NW_XHTML_ContentHandler_GetFormNode(NW_XHTML_ContentHandler_t *aThisObj, NW_DOM_ElementNode_t* aElementNode)
|
|
3651 |
{
|
|
3652 |
NW_DOM_ElementNode_t* node = NULL;
|
|
3653 |
|
|
3654 |
node = NW_XHTML_ContentHandler_GetFormNodeFromDomTree(aThisObj, aElementNode);
|
|
3655 |
if (!node)
|
|
3656 |
{
|
|
3657 |
node = NW_XHTML_ContentHandler_GetFormNodeFromSourceOffset(aThisObj, aElementNode);
|
|
3658 |
}
|
|
3659 |
return node;
|
|
3660 |
}
|
|
3661 |
|
|
3662 |
// -----------------------------------------------------------------------------
|
|
3663 |
CBase*
|
|
3664 |
NW_XHTML_ContentHandler_GetElementHandlerInstance(NW_XHTML_ContentHandler_t *thisObj,
|
|
3665 |
NW_DOM_ElementNode_t* elementNode)
|
|
3666 |
{
|
|
3667 |
TBrowserStatusCode status;
|
|
3668 |
CBase* value;
|
|
3669 |
|
|
3670 |
NW_ASSERT(thisObj != NULL);
|
|
3671 |
NW_ASSERT(elementNode != NULL);
|
|
3672 |
|
|
3673 |
status = NW_ADT_Map_Get(thisObj->iElementHandlerMap, &elementNode, &value);
|
|
3674 |
|
|
3675 |
if ((status == KBrsrSuccess) && (value != NULL)) {
|
|
3676 |
return value;
|
|
3677 |
}
|
|
3678 |
else {
|
|
3679 |
return NULL;
|
|
3680 |
}
|
|
3681 |
}
|
|
3682 |
|
|
3683 |
// -----------------------------------------------------------------------------
|
|
3684 |
TBrowserStatusCode
|
|
3685 |
NW_XHTML_ContentHandler_SetElementHandlerInstance(NW_XHTML_ContentHandler_t *thisObj,
|
|
3686 |
NW_DOM_ElementNode_t* elementNode, CBase* elementHandler)
|
|
3687 |
{
|
|
3688 |
CBase* oldInstance;
|
|
3689 |
|
|
3690 |
NW_ASSERT(thisObj != NULL);
|
|
3691 |
NW_ASSERT(elementNode != NULL);
|
|
3692 |
|
|
3693 |
// Delete the previous value
|
|
3694 |
oldInstance = NW_XHTML_ContentHandler_GetElementHandlerInstance(thisObj, elementNode);
|
|
3695 |
|
|
3696 |
// Disallow adding an existing context
|
|
3697 |
if (oldInstance == elementHandler) {
|
|
3698 |
return KBrsrSuccess;
|
|
3699 |
}
|
|
3700 |
|
|
3701 |
// Remove the previous context
|
|
3702 |
if (oldInstance) {
|
|
3703 |
(void) NW_ADT_Map_Remove(thisObj->iElementHandlerMap, &elementNode);
|
|
3704 |
|
|
3705 |
delete oldInstance;
|
|
3706 |
}
|
|
3707 |
|
|
3708 |
// Add the context
|
|
3709 |
return NW_ADT_Map_Set(thisObj->iElementHandlerMap, &elementNode, &elementHandler);
|
|
3710 |
}
|
|
3711 |
|
|
3712 |
// -----------------------------------------------------------------------------
|
|
3713 |
// Returns true if the media string passed to it contains one of the supported
|
|
3714 |
// media types, all, handheld, or NULL. The syntax is defined in section 6.13
|
|
3715 |
// of the HTML 4.01 specification.
|
|
3716 |
NW_Bool
|
|
3717 |
NW_XHTML_ContentHandler_AllowableStylesheet(const NW_Ucs2* media, NW_Bool* isHandheld)
|
|
3718 |
{
|
|
3719 |
NW_Bool allowable = NW_FALSE;
|
|
3720 |
|
|
3721 |
NW_ASSERT(isHandheld != NULL);
|
|
3722 |
|
|
3723 |
*isHandheld = NW_FALSE;
|
|
3724 |
|
|
3725 |
// A NULL value is acceptable.
|
|
3726 |
if (media == NULL)
|
|
3727 |
{
|
|
3728 |
return NW_TRUE;
|
|
3729 |
}
|
|
3730 |
|
|
3731 |
do
|
|
3732 |
{
|
|
3733 |
const NW_Ucs2* valueEnd;
|
|
3734 |
NW_Uint32 len;
|
|
3735 |
|
|
3736 |
// Skip leading white space.
|
|
3737 |
while (NW_Str_Isspace(*media))
|
|
3738 |
{
|
|
3739 |
media++;
|
|
3740 |
}
|
|
3741 |
|
|
3742 |
// Scan forward until hit something other than alpha, digit, hyphen.
|
|
3743 |
valueEnd = media;
|
|
3744 |
while (NW_Str_Isalnum(*valueEnd) || (*valueEnd == (NW_Ucs2)'-'))
|
|
3745 |
{
|
|
3746 |
valueEnd++;
|
|
3747 |
}
|
|
3748 |
|
|
3749 |
// Try to match (case insensitive) with one of accepted media type strings.
|
|
3750 |
len = valueEnd - media;
|
|
3751 |
|
|
3752 |
if ((len == 3) && (NW_Str_StrnicmpConst(media, "all", 3) == 0))
|
|
3753 |
{
|
|
3754 |
allowable = NW_TRUE;
|
|
3755 |
}
|
|
3756 |
|
|
3757 |
if ((len == 8) && (NW_Str_StrnicmpConst(media, "handheld", 8) == 0))
|
|
3758 |
{
|
|
3759 |
*isHandheld = NW_TRUE;
|
|
3760 |
allowable = NW_TRUE;
|
|
3761 |
}
|
|
3762 |
|
|
3763 |
// If doesn't match, scan forward for comma and if found repeat.
|
|
3764 |
while (*valueEnd)
|
|
3765 |
{
|
|
3766 |
if (*valueEnd == ',')
|
|
3767 |
{
|
|
3768 |
valueEnd++;
|
|
3769 |
break;
|
|
3770 |
}
|
|
3771 |
|
|
3772 |
valueEnd++;
|
|
3773 |
}
|
|
3774 |
|
|
3775 |
media = valueEnd;
|
|
3776 |
} while (*media);
|
|
3777 |
|
|
3778 |
return allowable;
|
|
3779 |
}
|
|
3780 |
|
|
3781 |
// -----------------------------------------------------------------------------
|
|
3782 |
// Enables mobile profile mode by disabling small screen layout and loading any
|
|
3783 |
// pending external stylesheets.
|
|
3784 |
void NW_XHTML_ContentHandler_EnableMobileProfileMode(NW_XHTML_ContentHandler_t* thisObj)
|
|
3785 |
{
|
|
3786 |
NW_CSS_Processor_t* processor = NULL;
|
|
3787 |
|
|
3788 |
NW_ASSERT(thisObj != NULL);
|
|
3789 |
|
|
3790 |
NW_Settings_SetDisableSmallScreenLayout(NW_TRUE);
|
|
3791 |
|
|
3792 |
processor = NW_XHTML_ContentHandler_GetCSSProcessor(thisObj);
|
|
3793 |
if(processor != NULL)
|
|
3794 |
{
|
|
3795 |
NW_CSS_Processor_ProcessPendingLoads(processor);
|
|
3796 |
}
|
|
3797 |
}
|
|
3798 |
|
|
3799 |
// -----------------------------------------------------------------------------
|
|
3800 |
// Load or queue a request for an external stylesheet.
|
|
3801 |
TBrowserStatusCode
|
|
3802 |
NW_XHTML_ContentHandler_LoadStylesheet(NW_XHTML_ContentHandler_t* thisObj,
|
|
3803 |
const NW_Ucs2* type, const NW_Ucs2* relation, const NW_Ucs2* media,
|
|
3804 |
const NW_Ucs2* url, const NW_Ucs2* charset, const NW_Ucs2* alternate)
|
|
3805 |
{
|
|
3806 |
NW_Bool isHandheld;
|
|
3807 |
NW_Bool allowable;
|
|
3808 |
NW_CSS_Processor_t* processor = NULL;
|
|
3809 |
NW_Text_t* urlText = NULL;
|
|
3810 |
NW_Text_t* resolvedUrl = NULL;
|
|
3811 |
NW_Text_t* charsetText = NULL;
|
|
3812 |
|
|
3813 |
NW_ASSERT(thisObj != NULL);
|
|
3814 |
|
|
3815 |
NW_TRY (status)
|
|
3816 |
{
|
|
3817 |
// Verify that the url isn't NULL.
|
|
3818 |
if (url == NULL)
|
|
3819 |
{
|
|
3820 |
NW_THROW_STATUS(status, KBrsrFailure);
|
|
3821 |
}
|
|
3822 |
|
|
3823 |
// Verify that the type is text/css.
|
|
3824 |
if ((type != NULL) && (NW_Str_StricmpConst(type, "text/css") != 0))
|
|
3825 |
{
|
|
3826 |
NW_THROW_STATUS(status, KBrsrFailure);
|
|
3827 |
}
|
|
3828 |
|
|
3829 |
// Verify that the rel is stylesheet.
|
|
3830 |
if ((relation != NULL) && (NW_Str_StricmpConst(relation, "stylesheet") != 0))
|
|
3831 |
{
|
|
3832 |
NW_THROW_STATUS(status, KBrsrFailure);
|
|
3833 |
}
|
|
3834 |
|
|
3835 |
// Verify that the alternate is no.
|
|
3836 |
if ((alternate != NULL) && (NW_Str_StricmpConst(alternate, "no") != 0))
|
|
3837 |
{
|
|
3838 |
NW_THROW_STATUS(status, KBrsrFailure);
|
|
3839 |
}
|
|
3840 |
|
|
3841 |
// Verify that the media is allowable.
|
|
3842 |
if (media != NULL)
|
|
3843 |
{
|
|
3844 |
allowable = NW_XHTML_ContentHandler_AllowableStylesheet(media, &isHandheld);
|
|
3845 |
|
|
3846 |
if (!allowable)
|
|
3847 |
{
|
|
3848 |
NW_THROW_STATUS(status, KBrsrFailure);
|
|
3849 |
}
|
|
3850 |
|
|
3851 |
// If a "handheld" stylesheet is found switch to mobile profile mode.
|
|
3852 |
if (isHandheld)
|
|
3853 |
{
|
|
3854 |
NW_XHTML_ContentHandler_EnableMobileProfileMode(thisObj);
|
|
3855 |
}
|
|
3856 |
}
|
|
3857 |
|
|
3858 |
// Resolve the url.
|
|
3859 |
urlText = (NW_Text_t*) NW_Text_UCS2_New((void *) url, 0, 0);
|
|
3860 |
NW_THROW_OOM_ON_NULL (urlText, status);
|
|
3861 |
|
|
3862 |
status = NW_HED_ContentHandler_ResolveURL(thisObj, urlText, &resolvedUrl);
|
|
3863 |
NW_THROW_ON_ERROR(status);
|
|
3864 |
urlText = NULL;
|
|
3865 |
|
|
3866 |
// Wrap the charset
|
|
3867 |
if (charset != NULL)
|
|
3868 |
{
|
|
3869 |
charsetText = (NW_Text_t*) NW_Text_UCS2_New((void *) charset, 0, 0);
|
|
3870 |
NW_THROW_OOM_ON_NULL(charsetText, status);
|
|
3871 |
}
|
|
3872 |
|
|
3873 |
// Get the CSS processor
|
|
3874 |
processor = NW_XHTML_ContentHandler_CreateCSSProcessor(thisObj);
|
|
3875 |
NW_THROW_ON_NULL(processor, status, KBrsrUnexpectedError);
|
|
3876 |
|
|
3877 |
// Load or queue the stylesheet request.
|
|
3878 |
status = NW_CSS_Processor_Load(processor, resolvedUrl, charsetText,
|
|
3879 |
NW_XHTML_ContentHandler_IsSaveddeck(thisObj), NW_XHTML_ContentHandler_IsHistoryLoad(thisObj),
|
|
3880 |
NW_XHTML_ContentHandler_IsReLoad(thisObj));
|
|
3881 |
NW_THROW_ON_ERROR(status);
|
|
3882 |
|
|
3883 |
if (resolvedUrl)
|
|
3884 |
{
|
|
3885 |
NW_Object_Delete(resolvedUrl);
|
|
3886 |
}
|
|
3887 |
resolvedUrl = NULL;
|
|
3888 |
charsetText = NULL;
|
|
3889 |
}
|
|
3890 |
|
|
3891 |
NW_CATCH (status)
|
|
3892 |
{
|
|
3893 |
NW_Object_Delete(urlText);
|
|
3894 |
NW_Object_Delete(resolvedUrl);
|
|
3895 |
NW_Object_Delete(charsetText);
|
|
3896 |
}
|
|
3897 |
|
|
3898 |
NW_FINALLY
|
|
3899 |
{
|
|
3900 |
return status;
|
|
3901 |
} NW_END_TRY
|
|
3902 |
}
|
|
3903 |
|
|
3904 |
|
|
3905 |
|
|
3906 |
TBrowserStatusCode
|
|
3907 |
NW_XHTML_ContentHandler_WindowOpen(NW_XHTML_ContentHandler_t* thisObj,
|
|
3908 |
NW_Text_t* url, NW_Text_t* target)
|
|
3909 |
{
|
|
3910 |
NW_HED_DocumentRoot_t* docRoot = NULL;
|
|
3911 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
3912 |
docRoot = (NW_HED_DocumentRoot_t*) NW_HED_DocumentNode_GetRootNode (thisObj);
|
|
3913 |
NW_ASSERT(docRoot != NULL);
|
|
3914 |
NW_Uint32 length;
|
|
3915 |
NW_Bool urlFreeNeeded = NW_FALSE;
|
|
3916 |
NW_Bool targetFreeNeeded = NW_FALSE;
|
|
3917 |
NW_Ucs2* urlStorage = NW_Text_GetUCS2Buffer (url, NW_Text_Flags_Aligned,
|
|
3918 |
&length, &urlFreeNeeded);
|
|
3919 |
NW_Ucs2* targetStorage = NW_Text_GetUCS2Buffer (target, NW_Text_Flags_Aligned,
|
|
3920 |
&length, &targetFreeNeeded);
|
|
3921 |
|
|
3922 |
if (urlStorage == NULL || targetStorage == NULL)
|
|
3923 |
{
|
|
3924 |
status = KBrsrOutOfMemory;
|
|
3925 |
}
|
|
3926 |
else
|
|
3927 |
{
|
|
3928 |
TRAP(status, docRoot->documentListener->WindowOpenL(urlStorage, targetStorage, NW_Ecma_Evt_OnClick));
|
|
3929 |
if (status != KBrsrSuccess)
|
|
3930 |
status = KBrsrOutOfMemory;
|
|
3931 |
}
|
|
3932 |
if (urlFreeNeeded)
|
|
3933 |
{
|
|
3934 |
NW_Mem_Free(urlStorage);
|
|
3935 |
}
|
|
3936 |
if (targetFreeNeeded)
|
|
3937 |
{
|
|
3938 |
NW_Mem_Free(targetStorage);
|
|
3939 |
}
|
|
3940 |
return status;
|
|
3941 |
}
|
|
3942 |
|
|
3943 |
TBrowserStatusCode
|
|
3944 |
NW_XHTML_ContentHandler_WindowOpenAndPost(NW_XHTML_ContentHandler_t* thisObj,
|
|
3945 |
NW_Text_t* url, NW_Text_t* target, NW_Uint8* contentType,
|
|
3946 |
NW_Uint32 contentTypeLength, NW_Uint8* postData, NW_Uint32 postDataLength,
|
|
3947 |
NW_Uint8* boundary)
|
|
3948 |
{
|
|
3949 |
NW_HED_DocumentRoot_t* docRoot = NULL;
|
|
3950 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
3951 |
docRoot = (NW_HED_DocumentRoot_t*) NW_HED_DocumentNode_GetRootNode (thisObj);
|
|
3952 |
NW_ASSERT(docRoot != NULL);
|
|
3953 |
NW_Uint32 length;
|
|
3954 |
NW_Bool urlFreeNeeded = NW_FALSE;
|
|
3955 |
NW_Bool targetFreeNeeded = NW_FALSE;
|
|
3956 |
NW_Ucs2* urlStorage = NW_Text_GetUCS2Buffer (url, NW_Text_Flags_Aligned,
|
|
3957 |
&length, &urlFreeNeeded);
|
|
3958 |
NW_Ucs2* targetStorage = NW_Text_GetUCS2Buffer (target, NW_Text_Flags_Aligned,
|
|
3959 |
&length, &targetFreeNeeded);
|
|
3960 |
|
|
3961 |
if (urlStorage == NULL || targetStorage == NULL)
|
|
3962 |
{
|
|
3963 |
status = KBrsrOutOfMemory;
|
|
3964 |
}
|
|
3965 |
else
|
|
3966 |
{
|
|
3967 |
NW_ASSERT(postData != NULL);
|
|
3968 |
TPtrC8 contentTypePtr (contentType, contentTypeLength);
|
|
3969 |
TPtrC8 postDataPtr (postData, postDataLength);
|
|
3970 |
TPtrC8 boundaryPtr(NULL, 0);
|
|
3971 |
TDesC8* ptrForBoundary = NULL;
|
|
3972 |
if (boundary != NULL)
|
|
3973 |
{
|
|
3974 |
boundaryPtr.Set(boundary, User::StringLength(boundary));
|
|
3975 |
ptrForBoundary = &boundaryPtr;
|
|
3976 |
}
|
|
3977 |
TRAP(status, docRoot->documentListener->WindowOpenAndPostL(urlStorage, targetStorage, NW_Ecma_Evt_OnClick,
|
|
3978 |
TBrCtlDefs::EMethodPost, &contentTypePtr, &postDataPtr, ptrForBoundary, NULL));
|
|
3979 |
if (status != KBrsrSuccess)
|
|
3980 |
status = KBrsrOutOfMemory;
|
|
3981 |
}
|
|
3982 |
if (urlFreeNeeded)
|
|
3983 |
{
|
|
3984 |
NW_Mem_Free(urlStorage);
|
|
3985 |
}
|
|
3986 |
if (targetFreeNeeded)
|
|
3987 |
{
|
|
3988 |
NW_Mem_Free(targetStorage);
|
|
3989 |
}
|
|
3990 |
return status;
|
|
3991 |
}
|
|
3992 |
|
|
3993 |
/*
|
|
3994 |
Get the target in base tag defined in header, this value can be used to decide if to
|
|
3995 |
open a link in a new window or not
|
|
3996 |
*/
|
|
3997 |
void
|
|
3998 |
NW_XHTML_ContentHandler_GetBaseTagTarget (NW_XHTML_ContentHandler_t* contentHandler,
|
|
3999 |
NW_Text_t** targetVal)
|
|
4000 |
{
|
|
4001 |
NW_DOM_Node_t* baseElement;
|
|
4002 |
NW_Text_t* target = NULL;
|
|
4003 |
|
|
4004 |
NW_ASSERT (targetVal);
|
|
4005 |
|
|
4006 |
/* get the base url as found in the "base" element */
|
|
4007 |
baseElement = NW_HED_DomHelper_FindElement (&contentHandler->domHelper, NW_HED_DomTree_GetRootNode (
|
|
4008 |
contentHandler->domTree), 3, NW_XHTML_ElementToken_base, 0, NULL);
|
|
4009 |
|
|
4010 |
if (baseElement != NULL)
|
|
4011 |
{
|
|
4012 |
NW_XHTML_GetDOMAttribute (contentHandler, baseElement, NW_XHTML_AttributeToken_target, &target);
|
|
4013 |
if (target != NULL && target->characterCount == 0)
|
|
4014 |
{
|
|
4015 |
NW_Object_Delete(target);
|
|
4016 |
target = NULL;
|
|
4017 |
}
|
|
4018 |
if (target != NULL)
|
|
4019 |
{
|
|
4020 |
*targetVal = (NW_Text_t*) NW_Text_UCS2_New (target->storage, NW_Text_GetCharCount(target), NW_Text_Flags_TakeOwnership);
|
|
4021 |
}
|
|
4022 |
}
|
|
4023 |
}
|