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: Handles object tags in XHTML documents.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
#include <e32std.h>
|
|
20 |
#include <e32def.h>
|
|
21 |
#include <webkit.rsg>
|
|
22 |
|
|
23 |
#include "nw_xhtml_xhtmlcontenthandler.h"
|
|
24 |
#include "nw_xhtml_elementhandler.h"
|
|
25 |
//#include "nw_ecma_contenthandler.h"
|
|
26 |
#include "nw_evt_accesskeyevent.h"
|
|
27 |
#include "nw_evt_activateevent.h"
|
|
28 |
#include "nw_evt_openviewerevent.h"
|
|
29 |
#include "nw_evt_focusevent.h"
|
|
30 |
#include "nw_hed_documentroot.h"
|
|
31 |
#include "HEDDocumentListener.h"
|
|
32 |
#include "nw_hed_hedeventhandler.h"
|
|
33 |
#include "nw_lmgr_animatedimagebox.h"
|
|
34 |
#include "nw_lmgr_propertylist.h"
|
|
35 |
#include "LMgrObjectBoxOOC.h"
|
|
36 |
#include "nw_lmgr_rootbox.h"
|
|
37 |
#include "nw_image_cannedimages.h"
|
|
38 |
#include "nw_image_virtualimage.h"
|
|
39 |
#include "nwx_settings.h"
|
|
40 |
#include "PluginContentHandlerOOC.h"
|
|
41 |
#include "LMgrObjectBox.h"
|
|
42 |
#include "PluginContentHandler.h"
|
|
43 |
#include "ObjectUtils.h"
|
|
44 |
#include "PluginHandler.h"
|
|
45 |
#include "StringUtils.h"
|
|
46 |
#include "ObjectDialog.h"
|
|
47 |
#include "XhtmlObjectElementHandler.h"
|
|
48 |
#include "nwx_http_defs.h"
|
|
49 |
#include "urlloader_urlresponse.h"
|
|
50 |
|
|
51 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
52 |
|
|
53 |
// -----------------------------------------------------------------------------
|
|
54 |
// CXHTMLObjectElementHandler::CXHTMLObjectElementHandler
|
|
55 |
//
|
|
56 |
// C++ default constructor can NOT contain any code, that
|
|
57 |
// might leave.
|
|
58 |
// -----------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
CXHTMLObjectElementHandler::CXHTMLObjectElementHandler(const NW_XHTML_ElementHandler_t* aElementHandler,
|
|
61 |
NW_XHTML_ContentHandler_t* aContentHandler, NW_DOM_ElementNode_t* aElementNode)
|
|
62 |
{
|
|
63 |
NW_ASSERT(aElementHandler != NULL);
|
|
64 |
NW_ASSERT(aContentHandler != NULL);
|
|
65 |
NW_ASSERT(aElementNode != NULL);
|
|
66 |
|
|
67 |
iElementHandler = aElementHandler;
|
|
68 |
iContentHandler = aContentHandler;
|
|
69 |
iElementNode = aElementNode;
|
|
70 |
|
|
71 |
iLoadedHandlerType = ObjectUtils::EHandlerAny;
|
|
72 |
}
|
|
73 |
|
|
74 |
// -----------------------------------------------------------------------------
|
|
75 |
// CXHTMLObjectElementHandler::ConstructL
|
|
76 |
//
|
|
77 |
// Symbian 2nd phase constructor can leave.
|
|
78 |
// -----------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
void CXHTMLObjectElementHandler::ConstructL(void)
|
|
81 |
{
|
|
82 |
}
|
|
83 |
|
|
84 |
// -----------------------------------------------------------------------------
|
|
85 |
// CXHTMLObjectElementHandler::~CXHTMLObjectElementHandler
|
|
86 |
//
|
|
87 |
// Deconstructor.
|
|
88 |
// -----------------------------------------------------------------------------
|
|
89 |
//
|
|
90 |
CXHTMLObjectElementHandler::~CXHTMLObjectElementHandler()
|
|
91 |
{
|
|
92 |
// Clear the listener so this isn't notified when the box is destroyed,
|
|
93 |
// since this instance will no longer be valid.
|
|
94 |
if (iObjectBox)
|
|
95 |
{
|
|
96 |
NW_LMgr_ObjectBox_GetObjectBox(*iObjectBox)->RemoveBoxDestructionListener(this);
|
|
97 |
}
|
|
98 |
if (iTransactionId)
|
|
99 |
{
|
|
100 |
NW_XHTML_ContentHandler_SetLoadObserver(iContentHandler, iTransactionId, NULL);
|
|
101 |
}
|
|
102 |
|
|
103 |
delete iContentType;
|
|
104 |
delete iContentLength;
|
|
105 |
}
|
|
106 |
|
|
107 |
// -----------------------------------------------------------------------------
|
|
108 |
// CXHTMLObjectElementHandler::NewL
|
|
109 |
// Two-phased constructor.
|
|
110 |
// -----------------------------------------------------------------------------
|
|
111 |
//
|
|
112 |
CXHTMLObjectElementHandler* CXHTMLObjectElementHandler::NewL(const NW_XHTML_ElementHandler_t*
|
|
113 |
aElementHandler, NW_XHTML_ContentHandler_t* aContentHandler,
|
|
114 |
NW_DOM_ElementNode_t* aElementNode)
|
|
115 |
{
|
|
116 |
CXHTMLObjectElementHandler* self = new(ELeave) CXHTMLObjectElementHandler(aElementHandler,
|
|
117 |
aContentHandler, aElementNode);
|
|
118 |
|
|
119 |
CleanupStack::PushL(self);
|
|
120 |
self->ConstructL();
|
|
121 |
CleanupStack::Pop();
|
|
122 |
|
|
123 |
return self;
|
|
124 |
}
|
|
125 |
|
|
126 |
// -----------------------------------------------------------------------------
|
|
127 |
// CPluginContentHandler::Destroyed
|
|
128 |
//
|
|
129 |
// Recieves notifications when the box has been destroyed.
|
|
130 |
// -----------------------------------------------------------------------------
|
|
131 |
//
|
|
132 |
void CXHTMLObjectElementHandler::Destroyed()
|
|
133 |
{
|
|
134 |
// Forget about the destroyed box.
|
|
135 |
iObjectBox = NULL;
|
|
136 |
}
|
|
137 |
|
|
138 |
// -----------------------------------------------------------------------------
|
|
139 |
// CXHTMLObjectElementHandler::HeadCompleted
|
|
140 |
//
|
|
141 |
// Passes a HEAD response to the observer.
|
|
142 |
// -----------------------------------------------------------------------------
|
|
143 |
//
|
|
144 |
void CXHTMLObjectElementHandler::HeadCompleted(TUint16 aTransactionId,
|
|
145 |
const NW_Url_Resp_t& aResponse, const NW_HED_UrlRequest_t& /*aUrlRequest*/,
|
|
146 |
void* /*aClientData*/)
|
|
147 |
{
|
|
148 |
NW_Ucs2* temp = NULL;
|
|
149 |
|
|
150 |
NW_TRY (status)
|
|
151 |
{
|
|
152 |
NW_XHTML_ContentHandler_SetLoadObserver(iContentHandler, aTransactionId, NULL);
|
|
153 |
iTransactionId = 0;
|
|
154 |
// Ensure iObjectBox isn't NULL.
|
|
155 |
NW_THROW_ON_NULL(iObjectBox, status, KBrsrUnexpectedError);
|
|
156 |
|
|
157 |
// Allow the server to override iContentType if it was never set from
|
|
158 |
// the type attribute or it was set but set to a type that isn't supported
|
|
159 |
// (this give the server a chance to set the type if a valid type wasn't
|
|
160 |
// set in the tag).
|
|
161 |
/*//R->embed
|
|
162 |
if (!iContentType || !ObjectUtils::IsSupported(iContentType,
|
|
163 |
NULL, ObjectUtils::EHandlerAny))
|
|
164 |
{
|
|
165 |
NW_THROW_ON_NULL(aResponse.contentTypeString, status, KBrsrUnexpectedError);
|
|
166 |
|
|
167 |
temp = StringUtils::CopyAsciiToUsc2(aResponse.contentTypeString);
|
|
168 |
NW_THROW_OOM_ON_NULL(temp, status);
|
|
169 |
|
|
170 |
delete iContentType;
|
|
171 |
iContentType = NULL;
|
|
172 |
|
|
173 |
iContentType = HBufC16::New(User::StringLength(temp));
|
|
174 |
NW_THROW_OOM_ON_NULL(iContentType, status);
|
|
175 |
|
|
176 |
iContentType->Des().Append(temp, User::StringLength(temp));
|
|
177 |
|
|
178 |
delete temp;
|
|
179 |
temp = NULL;
|
|
180 |
}
|
|
181 |
*/
|
|
182 |
// Extract and set the new content-length.
|
|
183 |
TUint kiloLen = aResponse.contentLength / 1024;
|
|
184 |
|
|
185 |
status = StringUtils::ConvertUintToUcs2(kiloLen > 0 ? kiloLen: 1, &temp);
|
|
186 |
NW_THROW_ON_ERROR(status);
|
|
187 |
|
|
188 |
delete iContentLength;
|
|
189 |
iContentLength = NULL;
|
|
190 |
|
|
191 |
iContentLength = HBufC16::New(User::StringLength(temp));
|
|
192 |
NW_THROW_OOM_ON_NULL(iContentLength, status);
|
|
193 |
|
|
194 |
iContentLength->Des().Append(temp, User::StringLength(temp));
|
|
195 |
|
|
196 |
delete temp;
|
|
197 |
temp = NULL;
|
|
198 |
|
|
199 |
// Apply the new values as properties.
|
|
200 |
ApplyInfoProperties(*iObjectBox);
|
|
201 |
|
|
202 |
// This flag is set now that it has a valid content type and size. The
|
|
203 |
// flag is used later to skip any future validating head request that may
|
|
204 |
// normally be done when the box tree is created.
|
|
205 |
iObjectInfoValidated = ETrue;
|
|
206 |
|
|
207 |
// Set the place holder text to "Unsupported" if the verified content-type
|
|
208 |
// isn't supported by a plugin or external-app.
|
|
209 |
/*//R->embed
|
|
210 |
if (!ObjectUtils::IsSupported(iContentType, NULL, ObjectUtils::EHandlerAny))
|
|
211 |
{
|
|
212 |
status = SetPlaceHolderText(*iObjectBox, R_XHTML_OBJECT_UNSUPPORTED);
|
|
213 |
NW_THROW_ON_ERROR(status);
|
|
214 |
}
|
|
215 |
*/
|
|
216 |
}
|
|
217 |
|
|
218 |
NW_CATCH (status)
|
|
219 |
{
|
|
220 |
delete temp;
|
|
221 |
}
|
|
222 |
|
|
223 |
NW_FINALLY
|
|
224 |
{
|
|
225 |
} NW_END_TRY
|
|
226 |
}
|
|
227 |
|
|
228 |
// -----------------------------------------------------------------------------
|
|
229 |
// CXHTMLObjectElementHandler::ChunkReceived
|
|
230 |
//
|
|
231 |
// Passes a chunk of a response to the observer.
|
|
232 |
// -----------------------------------------------------------------------------
|
|
233 |
//
|
|
234 |
void CXHTMLObjectElementHandler::ChunkReceived(TUint16 /*aTransactionId*/, TUint32 /*aChunkIndex*/,
|
|
235 |
const NW_Url_Resp_t& /*aResponse*/, const NW_HED_UrlRequest_t& /*aUrlRequest*/,
|
|
236 |
void* /*aClientData*/)
|
|
237 |
{
|
|
238 |
}
|
|
239 |
|
|
240 |
// -----------------------------------------------------------------------------
|
|
241 |
// CXHTMLObjectElementHandler::LoadCompleted
|
|
242 |
//
|
|
243 |
// Called when a response completes successfully or in error.
|
|
244 |
// -----------------------------------------------------------------------------
|
|
245 |
//
|
|
246 |
void CXHTMLObjectElementHandler::LoadCompleted(TInt16 /*aStatusClass*/, TBrowserStatusCode aStatus,
|
|
247 |
TUint16 aTransactionId, const NW_HED_UrlRequest_t& /*aUrlRequest*/,
|
|
248 |
void* /*aClientData*/)
|
|
249 |
{
|
|
250 |
NW_XHTML_ContentHandler_SetLoadObserver(iContentHandler, aTransactionId, NULL);
|
|
251 |
iTransactionId = 0;
|
|
252 |
|
|
253 |
if (iObjectBox)
|
|
254 |
{
|
|
255 |
// Reset the place holder upon a successful load of a resouce for an external application.
|
|
256 |
if ((aStatus == KBrsrSuccess) && (iLoadedHandlerType == ObjectUtils::EHandlerExternalApp))
|
|
257 |
{
|
|
258 |
CLMgrObjectBox* theBox = NULL;
|
|
259 |
theBox = NW_LMgr_ObjectBox_GetObjectBox(*iObjectBox);
|
|
260 |
if (!theBox || (theBox->IsShowingPlaceHolder()))
|
|
261 |
{
|
|
262 |
(void) SetPlaceHolderText(*iObjectBox, R_XHTML_OBJECT_SELECT_TO_DOWNLOAD);
|
|
263 |
}
|
|
264 |
}
|
|
265 |
|
|
266 |
// Reset the place holder upon failure -- unless this was an image load, or plugin was already
|
|
267 |
else if (aStatus != KBrsrSuccess)
|
|
268 |
{
|
|
269 |
CLMgrObjectBox* theBox = NULL;
|
|
270 |
theBox = NW_LMgr_ObjectBox_GetObjectBox(*iObjectBox);
|
|
271 |
if (!theBox || (theBox->IsShowingPlaceHolder()))
|
|
272 |
{
|
|
273 |
(void) SetPlaceHolderText(*iObjectBox, R_XHTML_OBJECT_UNSUPPORTED);
|
|
274 |
}
|
|
275 |
}
|
|
276 |
}
|
|
277 |
|
|
278 |
iIsDownloading = EFalse;
|
|
279 |
}
|
|
280 |
|
|
281 |
// -----------------------------------------------------------------------------
|
|
282 |
// CXHTMLObjectElementHandler::Initialize
|
|
283 |
//
|
|
284 |
// Initializes the ElementHandler.
|
|
285 |
// -----------------------------------------------------------------------------
|
|
286 |
//
|
|
287 |
TBrowserStatusCode CXHTMLObjectElementHandler::Initialize(void)
|
|
288 |
{
|
|
289 |
TDesC* type = NULL;
|
|
290 |
TDesC* data = NULL;
|
|
291 |
|
|
292 |
NW_TRY (status)
|
|
293 |
{
|
|
294 |
// If this element is the last element in the chunk and this isn't the
|
|
295 |
// last chunk then initialize it later. This only applies to objects not embeds,
|
|
296 |
// since embed elements don't have children elements.
|
|
297 |
NW_Uint16 element = NW_HED_DomHelper_GetElementToken(iElementNode);
|
|
298 |
|
|
299 |
if ((element == NW_XHTML_ElementToken_object) &&
|
|
300 |
(!NW_XHTML_ElementHandler_NextSiblingExists(iContentHandler, iElementNode, NW_TRUE)))
|
|
301 |
{
|
|
302 |
NW_THROW_SUCCESS (status);
|
|
303 |
}
|
|
304 |
|
|
305 |
if (iSelectedElementNode)
|
|
306 |
{
|
|
307 |
NW_THROW_SUCCESS (status);
|
|
308 |
}
|
|
309 |
|
|
310 |
|
|
311 |
// Determine which element node will be used. See comment on SelectElement...
|
|
312 |
status = SelectElement();
|
|
313 |
NW_THROW_ON_ERROR(status);
|
|
314 |
|
|
315 |
// Get the mime-type and url
|
|
316 |
(void) GetTypeAttribute(&type);
|
|
317 |
(void) GetSrcAttribute(&data);
|
|
318 |
/*//R->embed
|
|
319 |
if (type || data)
|
|
320 |
{
|
|
321 |
// Load it now if it is an image unless a plugin can also handle it.
|
|
322 |
if (!ObjectUtils::IsSupported(type, data, ObjectUtils::EHandlerPlugin))
|
|
323 |
{
|
|
324 |
if (ObjectUtils::IsSupported(type, data, ObjectUtils::EHandlerImage))
|
|
325 |
{
|
|
326 |
(void) LoadObjectResource(type, data, ObjectUtils::EHandlerImage);
|
|
327 |
}
|
|
328 |
}
|
|
329 |
}
|
|
330 |
*/
|
|
331 |
// If it gets to here it has processed a valid object element. skipToNode
|
|
332 |
// is set so any embedded elements are skipped.
|
|
333 |
iContentHandler->skipToNode = NW_DOM_Node_getNextSibling(iElementNode);
|
|
334 |
}
|
|
335 |
|
|
336 |
NW_CATCH (status)
|
|
337 |
{
|
|
338 |
}
|
|
339 |
|
|
340 |
NW_FINALLY
|
|
341 |
{
|
|
342 |
delete type;
|
|
343 |
delete data;
|
|
344 |
|
|
345 |
return status;
|
|
346 |
} NW_END_TRY
|
|
347 |
}
|
|
348 |
|
|
349 |
// -----------------------------------------------------------------------------
|
|
350 |
// CXHTMLObjectElementHandler::CreateBoxTree
|
|
351 |
//
|
|
352 |
// Creates the box-tree associated with the tag.
|
|
353 |
// -----------------------------------------------------------------------------
|
|
354 |
//
|
|
355 |
TBrowserStatusCode CXHTMLObjectElementHandler::CreateBoxTree(NW_LMgr_ContainerBox_t& /*aParentBox*/)
|
|
356 |
{
|
|
357 |
NW_HED_DocumentRoot_t* documentRoot = NULL;
|
|
358 |
NW_HED_ContentHandler_t* contentHandler = NULL;
|
|
359 |
NW_LMgr_RootBox_t* rootBox = NULL;
|
|
360 |
NW_LMgr_EventHandler_t* eventHandler = NULL;
|
|
361 |
NW_LMgr_Box_t* objectBox = NULL;
|
|
362 |
NW_LMgr_Box_t* tempBox = NULL;
|
|
363 |
NW_LMgr_Box_t* innerBox = NULL;
|
|
364 |
NW_Image_AbstractImage_t* image = NULL;
|
|
365 |
TDesC* contentType = NULL;
|
|
366 |
TDesC* data = NULL;
|
|
367 |
TBool safeToDeleteObjectBox = ETrue;
|
|
368 |
TBool isImage = EFalse;
|
|
369 |
TBrowserStatusCode status = 0;
|
|
370 |
/*
|
|
371 |
NW_TRY (status)
|
|
372 |
{
|
|
373 |
// If this element is the last element in the chunk and this isn't the
|
|
374 |
// last chunk then initialize it later. This only applies to objects not embeds,
|
|
375 |
// since embed elements don't have children elements.
|
|
376 |
NW_Uint16 element = NW_HED_DomHelper_GetElementToken(iElementNode);
|
|
377 |
|
|
378 |
if ((element == NW_XHTML_ElementToken_object) &&
|
|
379 |
(!NW_XHTML_ElementHandler_NextSiblingExists(iContentHandler, iElementNode, NW_FALSE)))
|
|
380 |
{
|
|
381 |
NW_THROW_SUCCESS (status);
|
|
382 |
}
|
|
383 |
|
|
384 |
// Get the associated content handler if any
|
|
385 |
contentHandler = AssociatedContentHandler();
|
|
386 |
|
|
387 |
// Get the root box
|
|
388 |
documentRoot = (NW_HED_DocumentRoot_t*) NW_HED_DocumentNode_GetRootNode(iContentHandler);
|
|
389 |
rootBox = NW_HED_DocumentRoot_GetRootBox(documentRoot);
|
|
390 |
|
|
391 |
// Get the content-type and url.
|
|
392 |
if (iObjectInfoValidated)
|
|
393 |
{
|
|
394 |
contentType = iContentType->Alloc();
|
|
395 |
NW_THROW_OOM_ON_NULL(contentType, status);
|
|
396 |
}
|
|
397 |
else
|
|
398 |
{
|
|
399 |
(void) GetTypeAttribute(&contentType);
|
|
400 |
}
|
|
401 |
|
|
402 |
(void) GetSrcAttribute(&data);
|
|
403 |
|
|
404 |
// If the content-type is a supported image type and a plugin can't handle it
|
|
405 |
// then create a ImageBox to support the object.
|
|
406 |
|
|
407 |
|
|
408 |
if (!ObjectUtils::IsSupported(contentType, data, ObjectUtils::EHandlerPlugin) &&
|
|
409 |
ObjectUtils::IsSupported(contentType, data, ObjectUtils::EHandlerImage))
|
|
410 |
{
|
|
411 |
isImage = ETrue;
|
|
412 |
// Get the image box from the ImageCH_Epoc32ContentHandler.
|
|
413 |
if (contentHandler)
|
|
414 |
{
|
|
415 |
status = NW_HED_DocumentNode_GetBoxTree(contentHandler, &objectBox);
|
|
416 |
NW_THROW_ON_ERROR(status);
|
|
417 |
|
|
418 |
// Don't allow this box to be deleted because it is owned by
|
|
419 |
// a ImageCH_Epoc32ContentHandler.
|
|
420 |
safeToDeleteObjectBox = EFalse;
|
|
421 |
}
|
|
422 |
|
|
423 |
// Otherwise create a place holder image that will be used by the
|
|
424 |
// ImageCH_Epoc32ContentHandler to display the image once it loads.
|
|
425 |
else
|
|
426 |
{
|
|
427 |
const NW_Image_AbstractImage_t* cannedImage;
|
|
428 |
|
|
429 |
cannedImage = (NW_Image_AbstractImage_t*) NW_Image_CannedImages_GetImage(
|
|
430 |
rootBox->cannedImages, NW_Image_Missing);
|
|
431 |
NW_THROW_ON_NULL((void*) cannedImage, status, KBrsrUnexpectedError);
|
|
432 |
|
|
433 |
image = (NW_Image_AbstractImage_t*) NW_Image_Virtual_New(
|
|
434 |
const_cast<NW_Image_AbstractImage_t*>(cannedImage));
|
|
435 |
NW_THROW_OOM_ON_NULL(image, status);
|
|
436 |
|
|
437 |
objectBox = (NW_LMgr_Box_t*) NW_LMgr_AnimatedImageBox_New(0,
|
|
438 |
image, NULL, NW_TRUE);
|
|
439 |
NW_THROW_OOM_ON_NULL(objectBox, status);
|
|
440 |
image = NULL;
|
|
441 |
}
|
|
442 |
}
|
|
443 |
|
|
444 |
// Otherwise create a CLMgrObjectBox to support the object.
|
|
445 |
else
|
|
446 |
{
|
|
447 |
if (!InHyperLink())
|
|
448 |
{
|
|
449 |
// Create an eventHandler to process events targeted at this box
|
|
450 |
eventHandler = (NW_LMgr_EventHandler_t*) NW_HED_EventHandler_New(
|
|
451 |
NW_HED_DocumentNodeOf(iContentHandler), iElementNode);
|
|
452 |
NW_THROW_OOM_ON_NULL(eventHandler, status);
|
|
453 |
}
|
|
454 |
|
|
455 |
status = CLMgrObjectBox::NewBox(eventHandler, &objectBox, &innerBox);
|
|
456 |
NW_THROW_ON_ERROR(status);
|
|
457 |
|
|
458 |
eventHandler = NULL;
|
|
459 |
|
|
460 |
// Save the content-type. This will be used later in ApplyInfoProperties
|
|
461 |
// to set the content-type property. This step is skipped if the content
|
|
462 |
// type has already been validated.
|
|
463 |
if (contentType && !iObjectInfoValidated)
|
|
464 |
{
|
|
465 |
delete iContentType;
|
|
466 |
iContentType = NULL;
|
|
467 |
|
|
468 |
iContentType = HBufC::New(contentType->Length());
|
|
469 |
NW_THROW_OOM_ON_NULL(iContentType, status);
|
|
470 |
|
|
471 |
iContentType->Des().Append(*contentType);
|
|
472 |
}
|
|
473 |
|
|
474 |
// Set the object box
|
|
475 |
iObjectBox = innerBox;
|
|
476 |
|
|
477 |
// Add the element handler as box destruction listener.
|
|
478 |
TRAPD(err, NW_LMgr_ObjectBox_GetObjectBox(*iObjectBox)->AddBoxDestructionListenerL(this));
|
|
479 |
NW_THROW_ON_TRAP_ERROR(err, status);
|
|
480 |
|
|
481 |
// If a content handler is already present just place the new CLMgrObjectBox
|
|
482 |
// (innerBox) in an active state by clearing the place holder.
|
|
483 |
|
|
484 |
if (contentHandler)
|
|
485 |
{
|
|
486 |
|
|
487 |
if (NW_Object_IsInstanceOf(contentHandler, &NW_Plugin_ContentHandler_Class))
|
|
488 |
{
|
|
489 |
NW_Plugin_ContentHandler_t* pluginContentHandler = NULL;
|
|
490 |
|
|
491 |
// Pass the object box to the plugin content handler.
|
|
492 |
pluginContentHandler = (NW_Plugin_ContentHandler_t*) contentHandler;
|
|
493 |
pluginContentHandler->iContentHandler->SetObjectBox(*innerBox);
|
|
494 |
|
|
495 |
// Removes the place holder which clears the box so the PluginInst
|
|
496 |
// can draw into it.
|
|
497 |
RemovePlaceHolder(*innerBox);
|
|
498 |
}
|
|
499 |
}
|
|
500 |
|
|
501 |
// Otherwise set the place holder and request the object's info.
|
|
502 |
else
|
|
503 |
{
|
|
504 |
// If data or both content type and data are missing then this object
|
|
505 |
// is unsupported.
|
|
506 |
if (!data || (!contentType && !data))
|
|
507 |
{
|
|
508 |
status = SetPlaceHolderText(*innerBox, R_XHTML_OBJECT_UNSUPPORTED);
|
|
509 |
NW_THROW_ON_ERROR(status);
|
|
510 |
}
|
|
511 |
|
|
512 |
// Otherwise set the place holder text and fetch the object's info.
|
|
513 |
else
|
|
514 |
{
|
|
515 |
// Set the place holder text to "Select to Download"
|
|
516 |
status = SetPlaceHolderText(*innerBox, R_XHTML_OBJECT_SELECT_TO_DOWNLOAD);
|
|
517 |
NW_THROW_ON_ERROR(status);
|
|
518 |
|
|
519 |
// Fetch the object's information if it hasn't already been validated.
|
|
520 |
// This occurs when a element handler is "resumed" from being previously
|
|
521 |
// "suspended".
|
|
522 |
|
|
523 |
if (!iObjectInfoValidated)
|
|
524 |
{
|
|
525 |
// Errors are purposely ignored to allow the box-tree to be created even
|
|
526 |
// if information about an object can't be fetched.
|
|
527 |
|
|
528 |
if (ObjectUtils::IsSupported(contentType, data, ObjectUtils::EHandlerPlugin) &&
|
|
529 |
NW_Settings_GetImagesEnabled())
|
|
530 |
{
|
|
531 |
// Set the place holder text to "Select to Download"
|
|
532 |
status = SetPlaceHolderText(*innerBox, R_XHTML_OBJECT_DOWNLOADING);
|
|
533 |
NW_THROW_ON_ERROR(status);
|
|
534 |
iObjectInfoValidated = ETrue;
|
|
535 |
ApplyInfoProperties(*iObjectBox);
|
|
536 |
LoadObjectResource(contentType, data, ObjectUtils::EHandlerPlugin);
|
|
537 |
}
|
|
538 |
else
|
|
539 |
{
|
|
540 |
(void) LoadObjectInfo();
|
|
541 |
}
|
|
542 |
}
|
|
543 |
else
|
|
544 |
{
|
|
545 |
// Set the place holder text to "Unsupported" if the verified content-type
|
|
546 |
// isn't supported by a plugin or external-app.
|
|
547 |
if (!ObjectUtils::IsSupported(iContentType, NULL, ObjectUtils::EHandlerAny))
|
|
548 |
{
|
|
549 |
status = SetPlaceHolderText(*iObjectBox, R_XHTML_OBJECT_UNSUPPORTED);
|
|
550 |
NW_THROW_ON_ERROR(status);
|
|
551 |
}
|
|
552 |
}
|
|
553 |
|
|
554 |
}
|
|
555 |
}
|
|
556 |
|
|
557 |
// TODO: If it is dealing with a object tag with a type but no data attribute then
|
|
558 |
// we need to do some funny things here.
|
|
559 |
//
|
|
560 |
// Create a buffer with the "inline" data (the param
|
|
561 |
// elements) and to make a normal load request. The request's url is of the form
|
|
562 |
// "buffer:url" where the data is provided in the POST body. The load is
|
|
563 |
// handled by a new scheme handler, the "buffer" handler. The handler would
|
|
564 |
// simply create a "response" that contains the buffer and some appropriate
|
|
565 |
// header values. The response is then handled as a normal plugin response --
|
|
566 |
// meaning a CPluginContentHandler is created, etc.
|
|
567 |
}
|
|
568 |
|
|
569 |
// Attach the active box to the provided parent box.
|
|
570 |
status = NW_LMgr_ContainerBox_AddChild(&aParentBox, objectBox);
|
|
571 |
_NW_THROW_ON_ERROR(status);
|
|
572 |
|
|
573 |
// This is done to prevent a double delete now that parentBox owns innerBox.
|
|
574 |
tempBox = (NW_LMgr_Box_t*) objectBox;
|
|
575 |
objectBox = NULL;
|
|
576 |
|
|
577 |
// Apply common attributes and styles, ignore non-out-of-memory errors.
|
|
578 |
// This includes the NW_CSS_Prop_elementId prop which is used by the Plugin content
|
|
579 |
// handler to find this box later on.
|
|
580 |
if (isImage)
|
|
581 |
{
|
|
582 |
status = NW_XHTML_ElementHandler_ApplyStyles(iElementHandler, iContentHandler,
|
|
583 |
iElementNode, &tempBox, NULL);
|
|
584 |
NW_THROW_ON(status, KBrsrOutOfMemory);
|
|
585 |
}
|
|
586 |
else
|
|
587 |
{
|
|
588 |
status = NW_XHTML_ElementHandler_ApplyStyles(iElementHandler, iContentHandler,
|
|
589 |
iSelectedElementNode, &tempBox, NULL);
|
|
590 |
NW_THROW_ON(status, KBrsrOutOfMemory);
|
|
591 |
}
|
|
592 |
}
|
|
593 |
|
|
594 |
NW_CATCH (status)
|
|
595 |
{
|
|
596 |
if (safeToDeleteObjectBox)
|
|
597 |
{
|
|
598 |
NW_Object_Delete(objectBox);
|
|
599 |
}
|
|
600 |
NW_Object_Delete(eventHandler);
|
|
601 |
NW_Object_Delete(image);
|
|
602 |
}
|
|
603 |
|
|
604 |
NW_FINALLY
|
|
605 |
{
|
|
606 |
delete contentType;
|
|
607 |
contentType = NULL;
|
|
608 |
|
|
609 |
delete data;
|
|
610 |
data = NULL;
|
|
611 |
|
|
612 |
return status;
|
|
613 |
} NW_END_TRY
|
|
614 |
*/
|
|
615 |
return status;
|
|
616 |
}
|
|
617 |
|
|
618 |
// -----------------------------------------------------------------------------
|
|
619 |
// CXHTMLObjectElementHandler::ProcessEvent
|
|
620 |
//
|
|
621 |
// Processes events targeted at boxes created by the ElementHandler.
|
|
622 |
// -----------------------------------------------------------------------------
|
|
623 |
//
|
|
624 |
NW_Uint8 CXHTMLObjectElementHandler::ProcessEvent(const NW_LMgr_Box_t& aBox,
|
|
625 |
const NW_Evt_Event_t& aEvent)
|
|
626 |
{
|
|
627 |
NW_HED_ContentHandler_t* pluginContentHandler = NULL;
|
|
628 |
TDesC* standby = NULL;
|
|
629 |
TDesC* type = NULL;
|
|
630 |
TDesC* url = NULL;
|
|
631 |
NW_Uint8 absorbed = NW_LMgr_EventNotAbsorbed;
|
|
632 |
const NW_Object_Class_t* eventClass = NULL;
|
|
633 |
NW_LMgr_Box_t* objectBox = NULL;
|
|
634 |
|
|
635 |
NW_TRY (status)
|
|
636 |
{
|
|
637 |
// Let the associated content handler process it if one is available.
|
|
638 |
pluginContentHandler = AssociatedContentHandler();
|
|
639 |
if (pluginContentHandler)
|
|
640 |
{
|
|
641 |
absorbed = NW_HED_DocumentNode_ProcessEvent(pluginContentHandler,
|
|
642 |
&aBox, &aEvent, NULL);
|
|
643 |
|
|
644 |
if (absorbed == NW_LMgr_EventAbsorbed)
|
|
645 |
{
|
|
646 |
NW_THROW_SUCCESS(status);
|
|
647 |
}
|
|
648 |
}
|
|
649 |
|
|
650 |
eventClass = NW_Object_Core_GetClass(&aEvent);
|
|
651 |
|
|
652 |
// Just absorb focus events.
|
|
653 |
if (eventClass == &NW_Evt_FocusEvent_Class)
|
|
654 |
{
|
|
655 |
absorbed = NW_LMgr_EventAbsorbed;
|
|
656 |
}
|
|
657 |
|
|
658 |
// Upon activation load the resource.
|
|
659 |
else if ((eventClass == &NW_Evt_OpenViewerEvent_Class) ||
|
|
660 |
(eventClass == &NW_Evt_ActivateEvent_Class) ||
|
|
661 |
(eventClass == &NW_Evt_AccessKeyEvent_Class))
|
|
662 |
{
|
|
663 |
ObjectUtils::THandlerType handlerType = ObjectUtils::EHandlerAny;
|
|
664 |
NW_HED_DocumentRoot_t* docRoot = NULL;
|
|
665 |
|
|
666 |
docRoot = (NW_HED_DocumentRoot_t*) NW_HED_DocumentNode_GetRootNode(
|
|
667 |
iContentHandler);
|
|
668 |
|
|
669 |
// Let Ecma script try to handle it first
|
|
670 |
//R->ecma
|
|
671 |
//status = NW_Ecma_HandleEvent(docRoot, iSelectedElementNode, iSelectedElementNode,
|
|
672 |
// NW_Ecma_Evt_OnClick);
|
|
673 |
if(status == KBrsrSuccess)
|
|
674 |
{
|
|
675 |
absorbed = NW_LMgr_EventAbsorbed;
|
|
676 |
NW_THROW_SUCCESS(status);
|
|
677 |
}
|
|
678 |
|
|
679 |
// Get the CLMgrObjectBox associated with this event.
|
|
680 |
objectBox = CLMgrObjectBox::FindObjectBox(aBox);
|
|
681 |
//R->embed NW_ASSERT(objectBox != NULL);
|
|
682 |
NW_THROW_ON_NULL(objectBox, status, KBrsrUnexpectedError);
|
|
683 |
|
|
684 |
// If download is in progress, don't start another download.
|
|
685 |
if (iIsDownloading)
|
|
686 |
{
|
|
687 |
absorbed = NW_LMgr_EventAbsorbed;
|
|
688 |
//R-embed TRAP(status, ObjectDialog::DisplayDownloadingErrorL( docRoot ));
|
|
689 |
NW_THROW_SUCCESS(status);
|
|
690 |
}
|
|
691 |
|
|
692 |
// Get the resource's content-type from the CSS property.
|
|
693 |
// Its ok if GetTextProperty returns NULL.
|
|
694 |
type = CLMgrObjectBox::GetTextProperty(*objectBox, NW_CSS_Prop_contentType);
|
|
695 |
|
|
696 |
// Get the resource's url
|
|
697 |
// Its ok if GetSrcAttribute fails.
|
|
698 |
(void) GetSrcAttribute(&url);
|
|
699 |
|
|
700 |
// Show the Object Download dialog unless this is an OpenViewer event.
|
|
701 |
if (eventClass != &NW_Evt_OpenViewerEvent_Class)
|
|
702 |
{
|
|
703 |
NW_HED_AppServices_t* appServices = (NW_HED_AppServices_t*)
|
|
704 |
NW_HED_DocumentRoot_GetAppServices(docRoot);
|
|
705 |
|
|
706 |
if (!appServices->objectDialog.ShowObjectDialog())
|
|
707 |
{
|
|
708 |
// The user canceled the download so just absorb the event.
|
|
709 |
absorbed = NW_LMgr_EventAbsorbed;
|
|
710 |
NW_THROW_SUCCESS(status);
|
|
711 |
}
|
|
712 |
|
|
713 |
// If the content can be handled by both an external app and plugin show a dialog
|
|
714 |
// to allow the user choose which to open it in.
|
|
715 |
//R->embed
|
|
716 |
/*
|
|
717 |
if (ObjectUtils::IsSupported(type, url, ObjectUtils::EHandlerPlugin) &&
|
|
718 |
ObjectUtils::IsSupported(type, url, ObjectUtils::EHandlerExternalApp))
|
|
719 |
{
|
|
720 |
TRAP(status, handlerType = ObjectDialog::SelectViewerL( docRoot ));
|
|
721 |
NW_THROW_ON_ERROR(status);
|
|
722 |
}
|
|
723 |
*/
|
|
724 |
}
|
|
725 |
|
|
726 |
|
|
727 |
// Otherwise its a is an OpenViewer event so the dialog isn't needed.
|
|
728 |
else
|
|
729 |
{
|
|
730 |
// Force it to open the resouce in an external application.
|
|
731 |
handlerType = ObjectUtils::EHandlerExternalApp;
|
|
732 |
}
|
|
733 |
|
|
734 |
// Load the object's resource.
|
|
735 |
status = LoadObjectResource(type, url, handlerType);
|
|
736 |
NW_THROW_ON_ERROR(status);
|
|
737 |
|
|
738 |
CLMgrObjectBox* theBox = NULL;
|
|
739 |
objectBox = CLMgrObjectBox::FindObjectBox(aBox);
|
|
740 |
if (objectBox)
|
|
741 |
{
|
|
742 |
theBox = NW_LMgr_ObjectBox_GetObjectBox(*objectBox);
|
|
743 |
}
|
|
744 |
if (!theBox || (theBox->IsShowingPlaceHolder()))
|
|
745 |
{
|
|
746 |
// Upon success set the place holder text to "Downloading Data" or the standby text.
|
|
747 |
status = GetAttribute(NW_XHTML_AttributeToken_standby, &standby);
|
|
748 |
|
|
749 |
if (status == KBrsrSuccess)
|
|
750 |
{
|
|
751 |
status = SetPlaceHolderText(*objectBox, *standby);
|
|
752 |
NW_THROW_ON_ERROR(status);
|
|
753 |
|
|
754 |
delete standby;
|
|
755 |
standby = NULL;
|
|
756 |
}
|
|
757 |
else
|
|
758 |
{
|
|
759 |
status = SetPlaceHolderText(*objectBox, R_XHTML_OBJECT_DOWNLOADING);
|
|
760 |
NW_THROW_ON_ERROR(status);
|
|
761 |
}
|
|
762 |
}
|
|
763 |
absorbed = NW_LMgr_EventAbsorbed;
|
|
764 |
}
|
|
765 |
|
|
766 |
|
|
767 |
// Otherwise ignore the event.
|
|
768 |
else
|
|
769 |
{
|
|
770 |
absorbed = NW_LMgr_EventNotAbsorbed;
|
|
771 |
}
|
|
772 |
}
|
|
773 |
|
|
774 |
NW_CATCH (status)
|
|
775 |
{
|
|
776 |
absorbed = NW_LMgr_EventNotAbsorbed;
|
|
777 |
}
|
|
778 |
|
|
779 |
NW_FINALLY
|
|
780 |
{
|
|
781 |
delete type;
|
|
782 |
delete url;
|
|
783 |
|
|
784 |
return absorbed;
|
|
785 |
} NW_END_TRY
|
|
786 |
}
|
|
787 |
|
|
788 |
// -----------------------------------------------------------------------------
|
|
789 |
// CXHTMLObjectElementHandler::ElementNode
|
|
790 |
//
|
|
791 |
// This is a special purpose method to get the element node
|
|
792 |
// associated with this handler.
|
|
793 |
// -----------------------------------------------------------------------------
|
|
794 |
//
|
|
795 |
const NW_DOM_ElementNode_t* CXHTMLObjectElementHandler::ElementNode(void) const
|
|
796 |
{
|
|
797 |
return iElementNode;
|
|
798 |
}
|
|
799 |
|
|
800 |
// -----------------------------------------------------------------------------
|
|
801 |
// CXHTMLObjectElementHandler::SelectedElementNode
|
|
802 |
//
|
|
803 |
// This is a special purpose method to get the "selected" element.
|
|
804 |
// See the comment on SelectElement.
|
|
805 |
// -----------------------------------------------------------------------------
|
|
806 |
//
|
|
807 |
const NW_DOM_ElementNode_t* CXHTMLObjectElementHandler::SelectedElementNode(void) const
|
|
808 |
{
|
|
809 |
return iSelectedElementNode;
|
|
810 |
}
|
|
811 |
|
|
812 |
// -----------------------------------------------------------------------------
|
|
813 |
// CXHTMLObjectElementHandler::ApplyInfoProperties
|
|
814 |
//
|
|
815 |
// Applies the content type and length properties on the given box. This is
|
|
816 |
// used in the download dialog box.
|
|
817 |
// -----------------------------------------------------------------------------
|
|
818 |
//
|
|
819 |
TBrowserStatusCode CXHTMLObjectElementHandler::ApplyInfoProperties(NW_LMgr_Box_t& aBox)
|
|
820 |
{
|
|
821 |
NW_Text_t* text = NULL;
|
|
822 |
NW_LMgr_Property_t prop;
|
|
823 |
|
|
824 |
NW_TRY (status)
|
|
825 |
{
|
|
826 |
if (iContentType)
|
|
827 |
{
|
|
828 |
text = NW_Text_New(HTTP_iso_10646_ucs_2, (void*) iContentType->Ptr(),
|
|
829 |
iContentType->Length(), NW_Text_Flags_Copy);
|
|
830 |
NW_THROW_OOM_ON_NULL(text, status);
|
|
831 |
|
|
832 |
prop.type = NW_CSS_ValueType_Text;
|
|
833 |
prop.value.object = text;
|
|
834 |
status = NW_LMgr_Box_SetProperty(&aBox, NW_CSS_Prop_contentType, &prop);
|
|
835 |
NW_THROW_ON_ERROR(status);
|
|
836 |
|
|
837 |
text = NULL;
|
|
838 |
}
|
|
839 |
|
|
840 |
if (iContentLength)
|
|
841 |
{
|
|
842 |
text = NW_Text_New(HTTP_iso_10646_ucs_2, (void*) iContentLength->Ptr(),
|
|
843 |
iContentLength->Length(), NW_Text_Flags_Copy);
|
|
844 |
NW_THROW_OOM_ON_NULL(text, status);
|
|
845 |
|
|
846 |
prop.type = NW_CSS_ValueType_Text;
|
|
847 |
prop.value.object = text;
|
|
848 |
status = NW_LMgr_Box_SetProperty(&aBox, NW_CSS_Prop_contentLength, &prop);
|
|
849 |
NW_THROW_ON_ERROR(status);
|
|
850 |
|
|
851 |
text = NULL;
|
|
852 |
}
|
|
853 |
}
|
|
854 |
|
|
855 |
NW_CATCH (status)
|
|
856 |
{
|
|
857 |
NW_Object_Delete(text);
|
|
858 |
}
|
|
859 |
|
|
860 |
NW_FINALLY
|
|
861 |
{
|
|
862 |
return status;
|
|
863 |
} NW_END_TRY
|
|
864 |
}
|
|
865 |
|
|
866 |
// -----------------------------------------------------------------------------
|
|
867 |
// CXHTMLObjectElementHandler::LoadObjectResource
|
|
868 |
//
|
|
869 |
// Loads the resource associated with object tag.
|
|
870 |
// -----------------------------------------------------------------------------
|
|
871 |
//
|
|
872 |
TBrowserStatusCode CXHTMLObjectElementHandler::LoadObjectResource(const TDesC* aType,
|
|
873 |
const TDesC* aUrl, ObjectUtils::THandlerType aHandlerType)
|
|
874 |
{
|
|
875 |
NW_Text_t* url = NULL;
|
|
876 |
NW_Uint8 loadType = NW_UrlRequest_Type_Any;
|
|
877 |
NW_Uint8 reason = NW_HED_UrlRequest_Reason_DocLoad;
|
|
878 |
void* context = NULL;
|
|
879 |
TUint16 transactionId;
|
|
880 |
|
|
881 |
NW_TRY (status)
|
|
882 |
{
|
|
883 |
// Throw an not found error if aUrl is NULL.
|
|
884 |
NW_THROW_ON_NULL(aUrl, status, KBrsrNotFound);
|
|
885 |
|
|
886 |
url = NW_Text_New(HTTP_iso_10646_ucs_2, (void*) aUrl->Ptr(),
|
|
887 |
aUrl->Length(), NW_Text_Flags_Copy);
|
|
888 |
NW_THROW_OOM_ON_NULL(url, status);
|
|
889 |
|
|
890 |
// If aHandlerType is "any" determine the handler type by querying ObjectUtils.
|
|
891 |
// The querying order is significate (plugin, image, external).
|
|
892 |
/* //R->embed
|
|
893 |
if (aHandlerType == ObjectUtils::EHandlerAny)
|
|
894 |
{
|
|
895 |
if (ObjectUtils::IsSupported(aType, aUrl, ObjectUtils::EHandlerPlugin))
|
|
896 |
{
|
|
897 |
aHandlerType = ObjectUtils::EHandlerPlugin;
|
|
898 |
}
|
|
899 |
else if (ObjectUtils::IsSupported(aType, aUrl, ObjectUtils::EHandlerImage))
|
|
900 |
{
|
|
901 |
aHandlerType = ObjectUtils::EHandlerImage;
|
|
902 |
}
|
|
903 |
else if (ObjectUtils::IsSupported(aType, aUrl, ObjectUtils::EHandlerExternalApp))
|
|
904 |
{
|
|
905 |
aHandlerType = ObjectUtils::EHandlerExternalApp;
|
|
906 |
}
|
|
907 |
}
|
|
908 |
*/
|
|
909 |
// The content can be handled by the internal image infrastructure so set up
|
|
910 |
// the load so the response is directed to a NW_LMgr_ImageCH_Epoc32ContentHandler.
|
|
911 |
if (aHandlerType == ObjectUtils::EHandlerImage)
|
|
912 |
{
|
|
913 |
iLoadedHandlerType = ObjectUtils::EHandlerImage;
|
|
914 |
loadType = NW_UrlRequest_Type_Image;
|
|
915 |
reason = NW_HED_UrlRequest_Reason_DocLoadChild;
|
|
916 |
context = STATIC_CAST(void*, iElementNode);
|
|
917 |
|
|
918 |
status = NW_XHTML_ContentHandler_StartLoad_tId(iContentHandler, url,
|
|
919 |
reason, context, loadType, &transactionId);
|
|
920 |
NW_THROW_ON_ERROR(status);
|
|
921 |
}
|
|
922 |
|
|
923 |
// The content can be handled by a plugin so set up the load so the response
|
|
924 |
// is directed to a CPluginContentHandler.
|
|
925 |
else if (aHandlerType == ObjectUtils::EHandlerPlugin)
|
|
926 |
{
|
|
927 |
iLoadedHandlerType = ObjectUtils::EHandlerPlugin;
|
|
928 |
loadType = NW_UrlRequest_Type_Plugin;
|
|
929 |
reason = NW_HED_UrlRequest_Reason_DocLoadChild;
|
|
930 |
context = STATIC_CAST(void*, iElementNode);
|
|
931 |
|
|
932 |
status = NW_XHTML_ContentHandler_StartLoad_tId(iContentHandler, url,
|
|
933 |
reason, context, loadType, &transactionId);
|
|
934 |
NW_THROW_ON_ERROR(status);
|
|
935 |
}
|
|
936 |
|
|
937 |
// The content can be handled by an external application so set up the load so the
|
|
938 |
// response is directed to the external app infrastructure.
|
|
939 |
else if (aHandlerType == ObjectUtils::EHandlerExternalApp)
|
|
940 |
{
|
|
941 |
iLoadedHandlerType = ObjectUtils::EHandlerExternalApp;
|
|
942 |
loadType = NW_UrlRequest_Type_Any;
|
|
943 |
reason = NW_HED_UrlRequest_Reason_DocLoad;
|
|
944 |
context = NULL;
|
|
945 |
|
|
946 |
// create a new url header
|
|
947 |
TUint8* expectedContentType = NULL;
|
|
948 |
status = StringUtils::ConvertPtrUsc2ToAscii(TPtrC(*aType), &expectedContentType);
|
|
949 |
User::LeaveIfError(status);
|
|
950 |
CleanupStack::PushL(expectedContentType);
|
|
951 |
//R NW_Http_Header_t* header = UrlLoader_HeadersNew(NULL, NULL,
|
|
952 |
// NULL, NULL, 0, expectedContentType);
|
|
953 |
NW_Http_Header_t* header = NULL;
|
|
954 |
CleanupStack::PopAndDestroy(1); //expectedContentType
|
|
955 |
// create url request
|
|
956 |
NW_HED_UrlRequest_t* request;
|
|
957 |
|
|
958 |
request = NW_HED_UrlRequest_New (NW_TextOf (url), NW_URL_METHOD_GET, header,
|
|
959 |
NULL, reason, NW_HED_UrlRequest_LoadNormal,
|
|
960 |
loadType);
|
|
961 |
|
|
962 |
NW_THROW_OOM_ON_NULL (request, status);
|
|
963 |
|
|
964 |
if (NW_XHTML_ContentHandler_IsSaveddeck(iContentHandler) &&
|
|
965 |
NW_HED_UrlRequest_Reason_DocLoadChild == reason &&
|
|
966 |
// Allow to load a plugin from a saved page, because the user explicitly requested it
|
|
967 |
loadType != NW_UrlRequest_Type_Plugin)
|
|
968 |
{
|
|
969 |
NW_HED_UrlRequest_SetCacheMode(request, NW_CACHE_ONLYCACHE);
|
|
970 |
}
|
|
971 |
|
|
972 |
if (NW_XHTML_ContentHandler_IsHistoryLoad(iContentHandler) &&
|
|
973 |
NW_HED_UrlRequest_Reason_DocLoadChild == reason)
|
|
974 |
{
|
|
975 |
NW_HED_UrlRequest_SetCacheMode(request, NW_CACHE_HISTPREV);
|
|
976 |
}
|
|
977 |
|
|
978 |
/* pass it to StartRequest to be satisfied */
|
|
979 |
status = NW_XHTML_ContentHandler_StartRequest_tId (iContentHandler, request, context, &transactionId);
|
|
980 |
NW_THROW_ON_ERROR (status);
|
|
981 |
}
|
|
982 |
// Otherwise don't load it
|
|
983 |
else
|
|
984 |
{
|
|
985 |
NW_THROW_SUCCESS(status);
|
|
986 |
}
|
|
987 |
|
|
988 |
// Set this as the load observer
|
|
989 |
status = NW_XHTML_ContentHandler_SetLoadObserver(iContentHandler, transactionId, this);
|
|
990 |
iTransactionId = transactionId;
|
|
991 |
NW_THROW_ON_ERROR(status);
|
|
992 |
|
|
993 |
iIsDownloading = ETrue;
|
|
994 |
}
|
|
995 |
|
|
996 |
NW_CATCH (status)
|
|
997 |
{
|
|
998 |
}
|
|
999 |
|
|
1000 |
NW_FINALLY
|
|
1001 |
{
|
|
1002 |
NW_Object_Delete(url);
|
|
1003 |
|
|
1004 |
return status;
|
|
1005 |
} NW_END_TRY
|
|
1006 |
}
|
|
1007 |
|
|
1008 |
// -----------------------------------------------------------------------------
|
|
1009 |
// CXHTMLObjectElementHandler::LoadObjectInfo
|
|
1010 |
//
|
|
1011 |
// Loads the HEAD information of the resource associated with object tag.
|
|
1012 |
// -----------------------------------------------------------------------------
|
|
1013 |
//
|
|
1014 |
TBrowserStatusCode CXHTMLObjectElementHandler::LoadObjectInfo(void)
|
|
1015 |
{
|
|
1016 |
NW_Text_UCS2_t url;
|
|
1017 |
TDesC* urlDes = NULL;
|
|
1018 |
|
|
1019 |
NW_TRY (status)
|
|
1020 |
{
|
|
1021 |
// Prevent network connections from "saved" pages.
|
|
1022 |
if (NW_XHTML_ContentHandler_IsSaveddeck(iContentHandler))
|
|
1023 |
{
|
|
1024 |
if (iContentType)
|
|
1025 |
{
|
|
1026 |
iObjectInfoValidated = ETrue;
|
|
1027 |
ApplyInfoProperties(*iObjectBox);
|
|
1028 |
}
|
|
1029 |
NW_THROW_SUCCESS(status);
|
|
1030 |
}
|
|
1031 |
|
|
1032 |
// Extract the data attribute.
|
|
1033 |
status = GetSrcAttribute(&urlDes);
|
|
1034 |
NW_THROW_ON_ERROR(status);
|
|
1035 |
|
|
1036 |
status = NW_Text_UCS2_Initialize(&url, (void*) urlDes->Ptr(),
|
|
1037 |
urlDes->Length(), 0);
|
|
1038 |
NW_THROW_ON_ERROR(status);
|
|
1039 |
|
|
1040 |
// Start a HEAD request for the url.
|
|
1041 |
TUint16 transactionId;
|
|
1042 |
|
|
1043 |
status = NW_XHTML_ContentHandler_StartLoad_tId(iContentHandler, (NW_Text_t*) &url,
|
|
1044 |
NW_HED_UrlRequest_Reason_DocLoadHead, NULL, NW_UrlRequest_Type_Plugin, &transactionId);
|
|
1045 |
NW_THROW_ON_ERROR(status);
|
|
1046 |
|
|
1047 |
// Set this as the load observer
|
|
1048 |
status = NW_XHTML_ContentHandler_SetLoadObserver(iContentHandler, transactionId, this);
|
|
1049 |
iTransactionId = transactionId;
|
|
1050 |
NW_THROW_ON_ERROR(status);
|
|
1051 |
}
|
|
1052 |
|
|
1053 |
NW_CATCH (status)
|
|
1054 |
{
|
|
1055 |
}
|
|
1056 |
|
|
1057 |
NW_FINALLY
|
|
1058 |
{
|
|
1059 |
delete urlDes;
|
|
1060 |
return status;
|
|
1061 |
} NW_END_TRY
|
|
1062 |
}
|
|
1063 |
|
|
1064 |
// -----------------------------------------------------------------------------
|
|
1065 |
// CXHTMLObjectElementHandler::AssociatedContentHandler
|
|
1066 |
//
|
|
1067 |
// Returns the associated content handler or NULL if one isn't found.
|
|
1068 |
// -----------------------------------------------------------------------------
|
|
1069 |
//
|
|
1070 |
NW_HED_ContentHandler_t* CXHTMLObjectElementHandler::AssociatedContentHandler(void)
|
|
1071 |
{
|
|
1072 |
NW_HED_CompositeNode_t* compositeNode = NULL;
|
|
1073 |
|
|
1074 |
compositeNode = (NW_HED_CompositeNode_t*) NW_Object_QueryAggregate(
|
|
1075 |
iContentHandler, &NW_HED_CompositeNode_Class);
|
|
1076 |
|
|
1077 |
return (NW_HED_ContentHandler_t*) NW_HED_CompositeNode_LookupChild(compositeNode,
|
|
1078 |
iElementNode);
|
|
1079 |
}
|
|
1080 |
|
|
1081 |
// -----------------------------------------------------------------------------
|
|
1082 |
// CXHTMLObjectElementHandler::SetPlaceHolderText
|
|
1083 |
//
|
|
1084 |
// Set the place-holder text to the given descriptor.
|
|
1085 |
// -----------------------------------------------------------------------------
|
|
1086 |
//
|
|
1087 |
TBrowserStatusCode CXHTMLObjectElementHandler::SetPlaceHolderText(
|
|
1088 |
NW_LMgr_Box_t& aObjectBox, const TDesC& aPlaceHolderText)
|
|
1089 |
{
|
|
1090 |
CLMgrObjectBox* objectBox = NULL;
|
|
1091 |
|
|
1092 |
// Set the place holder text.
|
|
1093 |
objectBox = NW_LMgr_ObjectBox_GetObjectBox((NW_LMgr_ObjectBox_t&) aObjectBox);
|
|
1094 |
NW_ASSERT(objectBox != NULL);
|
|
1095 |
|
|
1096 |
TRAPD(err, objectBox->SetPlaceHolderTextL(aPlaceHolderText));
|
|
1097 |
return err;
|
|
1098 |
}
|
|
1099 |
|
|
1100 |
// -----------------------------------------------------------------------------
|
|
1101 |
// CXHTMLObjectElementHandler::SetPlaceHolderTextL
|
|
1102 |
//
|
|
1103 |
// Set the place-holder text to the given resource id.
|
|
1104 |
// -----------------------------------------------------------------------------
|
|
1105 |
//
|
|
1106 |
TBrowserStatusCode CXHTMLObjectElementHandler::SetPlaceHolderText(
|
|
1107 |
NW_LMgr_Box_t& aObjectBox, TInt aResourceId)
|
|
1108 |
{
|
|
1109 |
CLMgrObjectBox* objectBox = NULL;
|
|
1110 |
|
|
1111 |
// Set the place holder text.
|
|
1112 |
objectBox = NW_LMgr_ObjectBox_GetObjectBox((NW_LMgr_ObjectBox_t&) aObjectBox);
|
|
1113 |
NW_ASSERT(objectBox != NULL);
|
|
1114 |
|
|
1115 |
TRAPD(err, objectBox->SetPlaceHolderTextL(aResourceId));
|
|
1116 |
return(err);
|
|
1117 |
}
|
|
1118 |
|
|
1119 |
// -----------------------------------------------------------------------------
|
|
1120 |
// CXHTMLObjectElementHandler::RemovePlaceHolder
|
|
1121 |
//
|
|
1122 |
// Removes the place holder -- puts the ObjectBox in the active state.
|
|
1123 |
// -----------------------------------------------------------------------------
|
|
1124 |
//
|
|
1125 |
void CXHTMLObjectElementHandler::RemovePlaceHolder(NW_LMgr_Box_t& aObjectBox)
|
|
1126 |
{
|
|
1127 |
CLMgrObjectBox* objectBox;
|
|
1128 |
|
|
1129 |
// Remove the place holder
|
|
1130 |
objectBox = NW_LMgr_ObjectBox_GetObjectBox((NW_LMgr_ObjectBox_t&) aObjectBox);
|
|
1131 |
NW_ASSERT(objectBox != NULL);
|
|
1132 |
|
|
1133 |
objectBox->RemovePlaceHolder();
|
|
1134 |
}
|
|
1135 |
|
|
1136 |
// -----------------------------------------------------------------------------
|
|
1137 |
// CXHTMLObjectElementHandler::SelectElement
|
|
1138 |
//
|
|
1139 |
// Embedded resources are specified in an xhtml document using the object tag.
|
|
1140 |
// This tag can be very simple to quite complex. Below are a couple of examples.
|
|
1141 |
// This method determines if iElementNode or one of its descendants can be selected
|
|
1142 |
// and displayed. Once an element is selected it is stored in iSelectedElementNode.
|
|
1143 |
// iSelectedElementNode is used in GetAttribute to extract attribute values from
|
|
1144 |
// the selected element.
|
|
1145 |
//
|
|
1146 |
// Selects *** if type-a is supported.
|
|
1147 |
// <object data="some-url" type="type-a" /> ***
|
|
1148 |
//
|
|
1149 |
// Selects *** if type-a isn't supported and type-b is.
|
|
1150 |
// <object data="some-url" type="type-a">
|
|
1151 |
// <object data="some-other-url" type="type-b" /> ***
|
|
1152 |
// </object>
|
|
1153 |
//
|
|
1154 |
// Selects *** if type-a, type-b, and type-c aren't supported.
|
|
1155 |
// <object data="some-url" type="type-a">
|
|
1156 |
// <param name="name-a" value="value-a" />
|
|
1157 |
// <param name="name-b" value="value-b" />
|
|
1158 |
// <object data="some-other-url" type="type-b">
|
|
1159 |
// <object data="some-other-url" type="type-c">
|
|
1160 |
// <param name="name-a" value="value-a" />
|
|
1161 |
// <param name="name-b" value="value-b" />
|
|
1162 |
// <img src="some-other-url" /> ***
|
|
1163 |
// </object>
|
|
1164 |
// </object>
|
|
1165 |
// </object>
|
|
1166 |
//
|
|
1167 |
// Selects *** if application/x-shockwave-flash is supported.
|
|
1168 |
// <object>
|
|
1169 |
// <embed src="stocksnapshot.swf" quality="high" salign="lt" bgcolor="#ffffff"
|
|
1170 |
// width="785" height="550" name="construct" align=""
|
|
1171 |
// type="application/x-shockwave-flash" /> ***
|
|
1172 |
// </object>
|
|
1173 |
//
|
|
1174 |
// Selects *** if application/x-shockwave-flash is supported.
|
|
1175 |
// <object data="stocksnapshot.swf" type="application/x-shockwave-flash"> ***
|
|
1176 |
// <param name="movie" value="/images/flash/landing.swf?conf=/data/landing.xml" />
|
|
1177 |
// <param name="quality" value="high" />
|
|
1178 |
// <param name="salign" value="lt" />
|
|
1179 |
// <param name="bgcolor" value="#ffffff" />
|
|
1180 |
// <embed src="stocksnapshot.swf" quality="high" salign="lt" bgcolor="#ffffff"
|
|
1181 |
// width="785" height="550" name="construct" align=""
|
|
1182 |
// type="application/x-shockwave-flash" />
|
|
1183 |
// </object>
|
|
1184 |
// -----------------------------------------------------------------------------
|
|
1185 |
//
|
|
1186 |
TBrowserStatusCode CXHTMLObjectElementHandler::SelectElement(void)
|
|
1187 |
{
|
|
1188 |
NW_DOM_Node_t* node = NULL;
|
|
1189 |
TDesC* type = NULL;
|
|
1190 |
TDesC* data = NULL;
|
|
1191 |
|
|
1192 |
NW_TRY (status)
|
|
1193 |
{
|
|
1194 |
// Start checking from iElementNode
|
|
1195 |
node = iElementNode;
|
|
1196 |
|
|
1197 |
while (node)
|
|
1198 |
{
|
|
1199 |
iSelectedElementNode = node;
|
|
1200 |
|
|
1201 |
// Get the type and data attributes of this element.
|
|
1202 |
(void) GetTypeAttribute(&type);
|
|
1203 |
(void) GetSrcAttribute(&data);
|
|
1204 |
|
|
1205 |
if (data)
|
|
1206 |
{
|
|
1207 |
// If it is supported then its done.
|
|
1208 |
//R->embed
|
|
1209 |
//if (ObjectUtils::IsSupported(type, data, ObjectUtils::EHandlerAny))
|
|
1210 |
// {
|
|
1211 |
// NW_THROW_SUCCESS(status);
|
|
1212 |
// }
|
|
1213 |
}
|
|
1214 |
|
|
1215 |
// Delete the type and data.
|
|
1216 |
delete type;
|
|
1217 |
type = NULL;
|
|
1218 |
delete data;
|
|
1219 |
data = NULL;
|
|
1220 |
|
|
1221 |
// Find the first child that is either an object or embed.
|
|
1222 |
NW_DOM_Node_t* childNode;
|
|
1223 |
|
|
1224 |
childNode = NW_DOM_Node_getFirstChild(node);
|
|
1225 |
node = NULL;
|
|
1226 |
|
|
1227 |
while (childNode)
|
|
1228 |
{
|
|
1229 |
switch (NW_HED_DomHelper_GetElementToken(childNode))
|
|
1230 |
{
|
|
1231 |
case NW_XHTML_ElementToken_object:
|
|
1232 |
case NW_XHTML_ElementToken_embed:
|
|
1233 |
node = childNode;
|
|
1234 |
childNode = NULL;
|
|
1235 |
break;
|
|
1236 |
|
|
1237 |
default:
|
|
1238 |
childNode = NW_DOM_Node_getNextSibling(childNode);
|
|
1239 |
break;
|
|
1240 |
}
|
|
1241 |
}
|
|
1242 |
}
|
|
1243 |
|
|
1244 |
// None of the elements are supported.
|
|
1245 |
//
|
|
1246 |
// Note: iSelectedElementNode is not cleared because because the UI
|
|
1247 |
// spec states that if none of the elements are supported then for
|
|
1248 |
// the purpose of displaying the box it should use the last element.
|
|
1249 |
}
|
|
1250 |
|
|
1251 |
/* Not currently used...
|
|
1252 |
NW_CATCH (status)
|
|
1253 |
{
|
|
1254 |
// In case of an error, just set iSelectedElementNode to iElementNode.
|
|
1255 |
// This is probably the best state to be in if some problem occurs.
|
|
1256 |
iSelectedElementNode = iElementNode;
|
|
1257 |
}
|
|
1258 |
*/
|
|
1259 |
|
|
1260 |
NW_FINALLY
|
|
1261 |
{
|
|
1262 |
delete type;
|
|
1263 |
delete data;
|
|
1264 |
|
|
1265 |
return status;
|
|
1266 |
} NW_END_TRY
|
|
1267 |
}
|
|
1268 |
|
|
1269 |
// -----------------------------------------------------------------------------
|
|
1270 |
// CXHTMLObjectElementHandler::GetAttribute
|
|
1271 |
//
|
|
1272 |
// Gets the value of the given attribute as a descriptor.
|
|
1273 |
// -----------------------------------------------------------------------------
|
|
1274 |
//
|
|
1275 |
TBrowserStatusCode CXHTMLObjectElementHandler::GetAttribute(TInt16 aToken, TDesC** aValue)
|
|
1276 |
{
|
|
1277 |
NW_Text_t* temp = NULL;
|
|
1278 |
HBufC* value = NULL;
|
|
1279 |
|
|
1280 |
NW_ASSERT(aValue != NULL);
|
|
1281 |
NW_ASSERT(iSelectedElementNode != NULL);
|
|
1282 |
|
|
1283 |
NW_TRY (status)
|
|
1284 |
{
|
|
1285 |
*aValue = NULL;
|
|
1286 |
|
|
1287 |
// Get the attribute
|
|
1288 |
status = NW_XHTML_GetDOMAttribute(iContentHandler, iSelectedElementNode, aToken, &temp);
|
|
1289 |
_NW_THROW_ON_ERROR(status);
|
|
1290 |
|
|
1291 |
// Copy the result into a TDes.
|
|
1292 |
value = HBufC::New(temp->characterCount + 1);
|
|
1293 |
NW_THROW_OOM_ON_NULL(value, status);
|
|
1294 |
|
|
1295 |
value->Des().Append((const TUint16*) temp->storage, temp->characterCount);
|
|
1296 |
value->Des().ZeroTerminate();
|
|
1297 |
}
|
|
1298 |
|
|
1299 |
NW_CATCH (status)
|
|
1300 |
{
|
|
1301 |
delete value;
|
|
1302 |
value = NULL;
|
|
1303 |
}
|
|
1304 |
|
|
1305 |
NW_FINALLY
|
|
1306 |
{
|
|
1307 |
NW_Object_Delete(temp);
|
|
1308 |
|
|
1309 |
*aValue = value;
|
|
1310 |
return status;
|
|
1311 |
} NW_END_TRY
|
|
1312 |
}
|
|
1313 |
|
|
1314 |
|
|
1315 |
// -----------------------------------------------------------------------------
|
|
1316 |
// CXHTMLObjectElementHandler::GetSrcAttribute
|
|
1317 |
//
|
|
1318 |
// Gets the value of the source attribute as a descriptor.
|
|
1319 |
// -----------------------------------------------------------------------------
|
|
1320 |
//
|
|
1321 |
TBrowserStatusCode CXHTMLObjectElementHandler::GetSrcAttribute(TDesC** aValue)
|
|
1322 |
{
|
|
1323 |
TDesC* value = NULL;
|
|
1324 |
TInt16 token;
|
|
1325 |
NW_Uint16 element;
|
|
1326 |
|
|
1327 |
NW_ASSERT(aValue != NULL);
|
|
1328 |
NW_ASSERT(iSelectedElementNode != NULL);
|
|
1329 |
|
|
1330 |
NW_TRY (status)
|
|
1331 |
{
|
|
1332 |
*aValue = NULL;
|
|
1333 |
|
|
1334 |
// If this isn't an embed or object tag, throw "no string".
|
|
1335 |
element = NW_HED_DomHelper_GetElementToken(iSelectedElementNode);
|
|
1336 |
if ((element != NW_XHTML_ElementToken_embed) && (element != NW_XHTML_ElementToken_object))
|
|
1337 |
{
|
|
1338 |
NW_THROW_STATUS(status, KBrsrDomNoStringReturned);
|
|
1339 |
}
|
|
1340 |
|
|
1341 |
// Try each source variation, "data", "src" and "href".
|
|
1342 |
token = 0;
|
|
1343 |
for (int i = 0; i < 3; i++)
|
|
1344 |
{
|
|
1345 |
switch (token)
|
|
1346 |
{
|
|
1347 |
case NW_XHTML_AttributeToken_data:
|
|
1348 |
token = NW_XHTML_AttributeToken_src;
|
|
1349 |
break;
|
|
1350 |
|
|
1351 |
case NW_XHTML_AttributeToken_src:
|
|
1352 |
token = NW_XHTML_AttributeToken_href;
|
|
1353 |
break;
|
|
1354 |
|
|
1355 |
default:
|
|
1356 |
token = NW_XHTML_AttributeToken_data;
|
|
1357 |
break;
|
|
1358 |
}
|
|
1359 |
|
|
1360 |
// Retry the request with a new variant.
|
|
1361 |
status = GetAttribute(token, &value);
|
|
1362 |
if (status == KBrsrSuccess)
|
|
1363 |
{
|
|
1364 |
// Found a valid variant.
|
|
1365 |
break;
|
|
1366 |
}
|
|
1367 |
}
|
|
1368 |
|
|
1369 |
// If none of the source variations were found try using the object's
|
|
1370 |
// param elements.
|
|
1371 |
if (!value)
|
|
1372 |
{
|
|
1373 |
status = GetObjectAttributeMapSrc(&value);
|
|
1374 |
_NW_THROW_ON_ERROR(status);
|
|
1375 |
}
|
|
1376 |
}
|
|
1377 |
|
|
1378 |
NW_CATCH (status)
|
|
1379 |
{
|
|
1380 |
delete value;
|
|
1381 |
value = NULL;
|
|
1382 |
}
|
|
1383 |
|
|
1384 |
NW_FINALLY
|
|
1385 |
{
|
|
1386 |
*aValue = value;
|
|
1387 |
return status;
|
|
1388 |
} NW_END_TRY
|
|
1389 |
}
|
|
1390 |
|
|
1391 |
|
|
1392 |
// -----------------------------------------------------------------------------
|
|
1393 |
// CXHTMLObjectElementHandler::GetTypeAttribute
|
|
1394 |
//
|
|
1395 |
// Gets the value of the content-type attribute as a descriptor.
|
|
1396 |
// -----------------------------------------------------------------------------
|
|
1397 |
//
|
|
1398 |
TBrowserStatusCode CXHTMLObjectElementHandler::GetTypeAttribute(TDesC** aValue)
|
|
1399 |
{
|
|
1400 |
TDesC* value = NULL;
|
|
1401 |
TDesC* classId = NULL;
|
|
1402 |
|
|
1403 |
NW_ASSERT(aValue != NULL);
|
|
1404 |
NW_ASSERT(iSelectedElementNode != NULL);
|
|
1405 |
|
|
1406 |
NW_TRY (status)
|
|
1407 |
{
|
|
1408 |
// Try to get the type from the attribute.
|
|
1409 |
status = GetAttribute(NW_XHTML_AttributeToken_type, &value);
|
|
1410 |
|
|
1411 |
// If not found try to derive it from the ClassId
|
|
1412 |
/* //R->embed
|
|
1413 |
if (status != KBrsrSuccess)
|
|
1414 |
{
|
|
1415 |
// Get the ClassId attribute
|
|
1416 |
status = GetAttribute(NW_XHTML_AttributeToken_classid, &classId);
|
|
1417 |
_NW_THROW_ON_ERROR(status);
|
|
1418 |
|
|
1419 |
// Look up the cooresponding content-type
|
|
1420 |
value = ObjectUtils::GetAssociatedContentType(*classId);
|
|
1421 |
NW_THROW_ON_NULL(value, status, KBrsrDomNoStringReturned)
|
|
1422 |
}
|
|
1423 |
*/
|
|
1424 |
}
|
|
1425 |
|
|
1426 |
NW_CATCH (status)
|
|
1427 |
{
|
|
1428 |
delete value;
|
|
1429 |
value = NULL;
|
|
1430 |
}
|
|
1431 |
|
|
1432 |
NW_FINALLY
|
|
1433 |
{
|
|
1434 |
delete classId;
|
|
1435 |
classId = NULL;
|
|
1436 |
|
|
1437 |
*aValue = value;
|
|
1438 |
return status;
|
|
1439 |
} NW_END_TRY
|
|
1440 |
}
|
|
1441 |
|
|
1442 |
|
|
1443 |
// -----------------------------------------------------------------------------
|
|
1444 |
// CXHTMLObjectElementHandler::GetObjectAttributeMapSrc
|
|
1445 |
//
|
|
1446 |
// Gets the value of the source attribute by using the classId attribute,
|
|
1447 |
// the cooresponding param element and the object attribute mappings table.
|
|
1448 |
// -----------------------------------------------------------------------------
|
|
1449 |
//
|
|
1450 |
TBrowserStatusCode CXHTMLObjectElementHandler::GetObjectAttributeMapSrc(TDesC** aValue)
|
|
1451 |
{
|
|
1452 |
NW_Text_t* temp = NULL;
|
|
1453 |
TDesC* classId = NULL;
|
|
1454 |
TDesC* value = NULL;
|
|
1455 |
TDesC* paramName = NULL;
|
|
1456 |
|
|
1457 |
NW_ASSERT(aValue != NULL);
|
|
1458 |
NW_ASSERT(iSelectedElementNode != NULL);
|
|
1459 |
|
|
1460 |
NW_TRY (status)
|
|
1461 |
{
|
|
1462 |
*aValue = NULL;
|
|
1463 |
|
|
1464 |
// If this isn't an object tag, throw "no string".
|
|
1465 |
NW_Uint16 element;
|
|
1466 |
|
|
1467 |
element = NW_HED_DomHelper_GetElementToken(iSelectedElementNode);
|
|
1468 |
if (element != NW_XHTML_ElementToken_object)
|
|
1469 |
{
|
|
1470 |
//R->embed NW_THROW_STATUS(status, KBrsrDomNoStringReturned);
|
|
1471 |
}
|
|
1472 |
|
|
1473 |
// Get the ClassId attribute.
|
|
1474 |
status = GetAttribute(NW_XHTML_AttributeToken_classid, &classId);
|
|
1475 |
_NW_THROW_ON_ERROR(status);
|
|
1476 |
|
|
1477 |
// Look up the cooresponding param name.
|
|
1478 |
//R->embed paramName = ObjectUtils::GetAssociatedSourceParamName(*classId);
|
|
1479 |
NW_THROW_OOM_ON_NULL(paramName, status);
|
|
1480 |
|
|
1481 |
delete classId;
|
|
1482 |
classId = NULL;
|
|
1483 |
|
|
1484 |
// Search for an child param element with a "name" of srcParamName
|
|
1485 |
// and copy its "value" attribute into value.
|
|
1486 |
TPtrC16 paramNamePtr(*paramName);
|
|
1487 |
NW_DOM_Node_t* paramElement;
|
|
1488 |
NW_String_t nameValue;
|
|
1489 |
|
|
1490 |
nameValue.storage = (NW_Byte *) paramNamePtr.Ptr();
|
|
1491 |
nameValue.length = paramNamePtr.Size() + sizeof(TInt16);
|
|
1492 |
|
|
1493 |
paramElement = NW_HED_DomHelper_FindElement (&iContentHandler->domHelper,
|
|
1494 |
iSelectedElementNode, 1, NW_XHTML_ElementToken_param,
|
|
1495 |
NW_XHTML_AttributeToken_name, &nameValue);
|
|
1496 |
|
|
1497 |
if (paramElement)
|
|
1498 |
{
|
|
1499 |
status = NW_XHTML_GetDOMAttribute(iContentHandler, paramElement,
|
|
1500 |
NW_XHTML_AttributeToken_value, &temp);
|
|
1501 |
_NW_THROW_ON_ERROR(status);
|
|
1502 |
|
|
1503 |
// Copy the result into a TDes.
|
|
1504 |
value = HBufC::New(temp->characterCount + 1);
|
|
1505 |
NW_THROW_OOM_ON_NULL(value, status);
|
|
1506 |
|
|
1507 |
((HBufC*) value)->Des().Append((const TUint16*) temp->storage, temp->characterCount);
|
|
1508 |
((HBufC*) value)->Des().ZeroTerminate();
|
|
1509 |
|
|
1510 |
NW_Object_Delete(temp);
|
|
1511 |
temp = NULL;
|
|
1512 |
}
|
|
1513 |
|
|
1514 |
// Otherwise value is left NULL...
|
|
1515 |
|
|
1516 |
delete paramName;
|
|
1517 |
paramName = NULL;
|
|
1518 |
}
|
|
1519 |
|
|
1520 |
NW_CATCH (status)
|
|
1521 |
{
|
|
1522 |
NW_Object_Delete(temp);
|
|
1523 |
temp = NULL;
|
|
1524 |
|
|
1525 |
delete classId;
|
|
1526 |
classId = NULL;
|
|
1527 |
|
|
1528 |
delete paramName;
|
|
1529 |
paramName = NULL;
|
|
1530 |
|
|
1531 |
delete value;
|
|
1532 |
value = NULL;
|
|
1533 |
}
|
|
1534 |
|
|
1535 |
NW_FINALLY
|
|
1536 |
{
|
|
1537 |
*aValue = value;
|
|
1538 |
return status;
|
|
1539 |
} NW_END_TRY
|
|
1540 |
}
|
|
1541 |
|
|
1542 |
// -----------------------------------------------------------------------------
|
|
1543 |
// CXHTMLObjectElementHandler::InHyperLink
|
|
1544 |
//
|
|
1545 |
// Returns if the <object> element is enclosed within a hyperlink
|
|
1546 |
// -----------------------------------------------------------------------------
|
|
1547 |
//
|
|
1548 |
TBool CXHTMLObjectElementHandler::InHyperLink()
|
|
1549 |
{
|
|
1550 |
NW_DOM_ElementNode_t* node = iElementNode;
|
|
1551 |
while (node != NULL && NW_HED_DomHelper_GetElementToken(node) != NW_XHTML_ElementToken_a)
|
|
1552 |
{
|
|
1553 |
node = NW_DOM_Node_getParentNode(node);
|
|
1554 |
}
|
|
1555 |
return (node != NULL);
|
|
1556 |
}
|
|
1557 |
|