sm1doc.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:173k
源码类别:

Symbian

开发平台:

C/C++

  1.     //[SMIL 1.0 Compliance] Fixes PR 26473:
  2.     // We want to add in LIFO fashion so inner
  3.     // (nested) anchors will be found first in
  4.     // CSmil1DocumentRenderer::findHyperlinkElement(),
  5.     // below.  In other words, we're giving an
  6.     // effective higher link "z-order" to the
  7.     // decendants of other links.  This used to
  8.     // call AddTail():
  9.     pPlayToAssoc->m_pHyperlinks->AddHead(pAnchor);
  10.                             // If the TLC starts off in double-size or non-original
  11.                             // size, then these anchors can get added AFTER the
  12.                             // SizeChanged call. Therefore, we need to check
  13.                             // here whether or not they need to be scaled.
  14.                             if ((m_topSiteSize.cx != m_topSiteOriginalSize.cx ||
  15.                                  m_topSiteSize.cy != m_topSiteOriginalSize.cy) &&
  16.                                  m_topSiteOriginalSize.cx != 0                 &&
  17.                                  m_topSiteOriginalSize.cy != 0)
  18.                             {
  19.                                 // We are getting added when TLC is already scaled,
  20.                                 // so we need to scale this anchor right off the bat
  21.                                 //
  22.                                 // Compute the absolute scale
  23.                                 double dScaleX = (double) m_topSiteSize.cx / (double) m_topSiteOriginalSize.cx;
  24.                                 double dScaleY = (double) m_topSiteSize.cy / (double) m_topSiteOriginalSize.cy;
  25.                                 // Scale the anchor
  26.                                 pAnchor->rescaleAbsolute(dScaleX, dScaleY);
  27.                             }
  28. }
  29.     }
  30.     bHandleElement = TRUE;
  31. }
  32. pRendererList = (CHXSimpleList*) pPlayToAssoc->m_sourceMap[uStreamNumber];
  33. pRendererList->AddTail(pSourceInfo);
  34. IHXValues* pValues = 0;
  35. IHXBuffer* pPlayToBuffer = 0;
  36. IHXBuffer* pRegionName = 0;
  37. IHXCommonClassFactory* pFactory = m_pParent->getFactory();
  38. if ((HXR_OK == pFactory->CreateInstance(CLSID_IHXValues, (void**)&pValues)) &&
  39.     (HXR_OK == pFactory->CreateInstance(CLSID_IHXBuffer, (void**)&pPlayToBuffer)) &&
  40.     (HXR_OK == pFactory->CreateInstance(CLSID_IHXBuffer, (void**)&pRegionName)))
  41. {     
  42.     pPlayToBuffer->Set((BYTE*)pChildTuner, strlen(pChildTuner)+1);
  43.     pValues->SetPropertyCString("playto", pPlayToBuffer);
  44.     HX_RELEASE(pPlayToBuffer);
  45.     if(pPlayToAssoc->m_regionName.GetLength() > 0)
  46.     {
  47. const char* pName = pPlayToAssoc->m_regionName;
  48. pRegionName->Set((BYTE*)pName, strlen(pName)+1);
  49. pValues->SetPropertyCString("region", pRegionName);
  50.     }
  51.     HX_RELEASE(pRegionName);
  52.     pLayoutStream->SetProperties(pValues);
  53.     pValues->Release();
  54. }
  55. if(!pRegion->m_bImplicitRegion)
  56. {
  57.     addSiteForRenderer(pPlayToAssoc, pSourceInfo, pRenderer, bNoRegion);
  58. }
  59.     }
  60. }
  61. setZOrder();
  62. HX_RELEASE(pLayoutStream);
  63.     }
  64.     else    // non-windowed renderer
  65.     {
  66. pPlayToAssoc = getPlayToAssoc((UINT16)ulGroupIndex, 
  67.     (UINT16)ulTrackIndex);
  68. if(pPlayToAssoc)
  69. {
  70.     SMIL1SourceInfo* pSourceInfo = NULL;
  71.     CHXSimpleList* pRendererList = NULL;
  72.     if (NULL == pPlayToAssoc->m_sourceMap[uStreamNumber])
  73.     {
  74. pPlayToAssoc->m_sourceMap[uStreamNumber] = new CHXSimpleList();
  75. pPlayToAssoc->m_ulDuration = ulDuration - ulDelay;
  76. bHandleElement = TRUE;
  77.     }
  78.     
  79.     pSourceInfo = new SMIL1SourceInfo;
  80.     pSourceInfo->m_pStream = pStream;
  81.     if(pSourceInfo->m_pStream)
  82.     {
  83. pSourceInfo->m_pStream->AddRef();
  84.     }
  85.     pSourceInfo->m_pRenderer = pRenderer;
  86.     if(pSourceInfo->m_pRenderer)
  87.     {
  88. pSourceInfo->m_pRenderer->AddRef();
  89.     }
  90.     pSourceInfo->m_pRendererEventHook = NULL;
  91.     pSourceInfo->m_ulDelay = ulDelay;
  92.     pSourceInfo->m_ulDuration = ulDuration = ulDelay;
  93.     
  94.     pRendererList = (CHXSimpleList*) pPlayToAssoc->m_sourceMap[uStreamNumber];
  95.     pRendererList->AddTail(pSourceInfo);
  96. }
  97.     }
  98.     // update the stream timing if it's been called in handleSourceUpdate()
  99.     if(m_pDeferredSourceMap)
  100.     {
  101. SMIL1DeferredSourceInfo* pDeferredInfo = NULL;
  102. const char* pDeferredID = (const char*)pPlayToAssoc->m_id;
  103. if(m_pDeferredSourceMap->Lookup(pDeferredID,
  104.     (void*&)pDeferredInfo))
  105. {
  106.     CSmil1Element* pThisElement = 
  107. m_pSmilParser->findElement(pDeferredID);
  108.     if(pThisElement &&
  109. pThisElement->m_ulBeginOffset != (UINT32)-1)
  110.     {
  111. if(pDeferredInfo->m_ulDuration > pThisElement->m_ulBeginOffset)
  112. {
  113.     updateStreamTiming(pDeferredID, 
  114. pDeferredInfo->m_ulDuration -
  115. pThisElement->m_ulBeginOffset);
  116. }
  117. else
  118. {
  119.     updateStreamTiming(pDeferredID, 0);
  120. }
  121.     }
  122.     else
  123.     {
  124. updateStreamTiming(pDeferredID, pDeferredInfo->m_ulDuration);
  125.     }
  126. }
  127.     }
  128.     if (bHandleElement)
  129.     {
  130. handleElements();
  131.     }
  132. #if defined(HELIX_FEATURE_SMIL2)
  133. cleanup:
  134. #endif /* defined(HELIX_FEATURE_SMIL2). */
  135.     return rc;
  136. }
  137. #if defined(_UNIX)  &&  (!defined(_BEOS))  &&  defined(USE_XWINDOWS)
  138. XData*  CSmil1DocumentRenderer::InitXVisualSupport(IHXSite* pSite, HXxWindow* pWnd)
  139. {
  140.     // create new XData object
  141.     XData* pxData = new XData();
  142.     // use the pointer to the X display and window
  143.     // conveniently given us by CHXSiteWindowed::HandleEvent
  144.     m_pPixmapDisplay = (Display*) pWnd->display;
  145.     Window window = (Window) pWnd->window; 
  146.     // save ptr to display in XData object also...
  147.     pxData->m_Display = m_pPixmapDisplay;
  148.     // get visual & set depth
  149.     XWindowAttributes attr;
  150.     XGetWindowAttributes(m_pPixmapDisplay, window, &attr);
  151.     // get visual info & depth 
  152.     XVisualInfo visInfoMask;
  153.     memset(&visInfoMask, 0, sizeof(XVisualInfo));
  154.     visInfoMask.visualid = attr.visual->visualid;
  155.     if (m_pVisualInfo)
  156.     {
  157. XFree(m_pVisualInfo);
  158. m_pVisualInfo = NULL;
  159.     }
  160.     int nv;
  161.     m_pVisualInfo  = XGetVisualInfo(m_pPixmapDisplay, VisualIDMask, &visInfoMask, &nv);
  162.     UINT32 nDepth = 32;
  163.     nDepth = (UINT32) m_pVisualInfo->depth;
  164.     // Get Colormap
  165.     pxData->m_colormap = attr.colormap;
  166.     // get bits per pixel information for the best depth we can display
  167.     ULONG32 bitsPerPixel = 32;
  168.     int i, n;
  169.     XPixmapFormatValues *pixmap_formats = XListPixmapFormats(m_pPixmapDisplay, &n);
  170.     if (pixmap_formats) 
  171.     {
  172. for (i = 0; i < n; i++)
  173. {
  174.     if (pixmap_formats[i].depth == nDepth)
  175.     {
  176.         bitsPerPixel = pixmap_formats[i].bits_per_pixel;
  177.     }
  178.  }
  179.     }
  180.     XFree(pixmap_formats);
  181.     // get site size
  182.     HXxSize siteWinSize;
  183.     pSite->GetSize(siteWinSize);
  184.     pxData->m_backgroundBitmapInfoHeader.biSize = sizeof(HXBitmapInfoHeader);  
  185.     pxData->m_backgroundBitmapInfoHeader.biWidth = siteWinSize.cx;
  186.     pxData->m_backgroundBitmapInfoHeader.biHeight = siteWinSize.cy;
  187.     pxData->m_backgroundBitmapInfoHeader.biPlanes = 1; // just seems to be the convention  
  188.     pxData->m_backgroundBitmapInfoHeader.biBitCount = bitsPerPixel;
  189.     HX_ASSERT(pxData->m_backgroundBitmapInfoHeader.biBitCount % 8 == 0);
  190.     // BI_RGB just seems to be the convention 
  191.     switch (pxData->m_backgroundBitmapInfoHeader.biBitCount) 
  192.     {
  193. case 8:
  194. case 24:
  195. case 32:
  196.     pxData->m_backgroundBitmapInfoHeader.biCompression = BI_RGB;
  197.     break;
  198. case 16:
  199.     pxData->m_backgroundBitmapInfoHeader.biCompression = HXCOLOR_RGB565_ID;
  200.     break;
  201. default:
  202.     HX_ASSERT(FALSE);
  203.     }
  204.     pxData->m_backgroundBitmapInfoHeader.biSizeImage = //size of image (bytes):
  205. pxData->m_backgroundBitmapInfoHeader.biWidth * pxData->m_backgroundBitmapInfoHeader.biHeight *  
  206. pxData->m_backgroundBitmapInfoHeader.biBitCount;
  207.     pxData->m_backgroundBitmapInfoHeader.biXPelsPerMeter = 0;   
  208.     pxData->m_backgroundBitmapInfoHeader.biYPelsPerMeter = 0;   
  209.     pxData->m_backgroundBitmapInfoHeader.biClrUsed = 0;  
  210.     pxData->m_backgroundBitmapInfoHeader.biClrImportant = 0;  
  211.     pxData->m_backgroundBitmapInfoHeader.rcolor = m_pVisualInfo->red_mask; 
  212.     pxData->m_backgroundBitmapInfoHeader.gcolor = m_pVisualInfo->green_mask;   
  213.     pxData->m_backgroundBitmapInfoHeader.bcolor = m_pVisualInfo->blue_mask; 
  214.     pxData->m_Pixmap = XCreatePixmap(m_pPixmapDisplay, 
  215.      window,
  216.      pxData->m_backgroundBitmapInfoHeader.biWidth, 
  217.      pxData->m_backgroundBitmapInfoHeader.biHeight, 
  218.      nDepth);
  219.     return pxData;
  220. }
  221. #endif
  222. STDMETHODIMP
  223. CSmil1DocumentRenderer::RendererClosed(IHXRenderer* pRenderer, 
  224.     IHXValues* pInfo)
  225. {
  226.     HX_RESULT rc = HXR_OK;
  227.     UINT32 ulGroupIndex = 0;
  228.     UINT32 ulTrackIndex = 0;
  229.     UINT32 ulStreamNumber = 0;    
  230.     CHXSimpleList* pRendererList = NULL;
  231.     SMIL1PlayToAssoc* pPlayToAssoc = NULL;
  232.     SMIL1SiteInfo* pSiteInfo = NULL;
  233. #if defined(HELIX_FEATURE_SMIL2)
  234.     if (m_pParent->isHigherVersionSmilStreamFromOldSMIL1FF())
  235.     {
  236. HX_ASSERT(m_pParent->m_pNextGenSmilRenderer);
  237. if (m_pParent->m_pNextGenSmilRenderer)
  238. {
  239.     rc = m_pParent->m_pNextGenSmilRenderer->SmilDocRendererClosed(
  240.     pRenderer, pInfo);
  241.     goto cleanup;
  242. }
  243.     }
  244. #endif /* defined(HELIX_FEATURE_SMIL2). */
  245.     pInfo->GetPropertyULONG32("GroupIndex", ulGroupIndex);
  246.     pInfo->GetPropertyULONG32("TrackIndex", ulTrackIndex);
  247.     pInfo->GetPropertyULONG32("StreamNumber", ulStreamNumber);
  248.     if (m_pPlayToAssocList)
  249.     {
  250. pPlayToAssoc = getPlayToAssoc((UINT16)ulGroupIndex, 
  251.       (UINT16)ulTrackIndex);
  252. if (pPlayToAssoc)
  253. {
  254.     pPlayToAssoc->m_sourceMap.Lookup(ulStreamNumber, (void*&) pRendererList);
  255. }
  256.     }
  257.     if (m_pSiteInfoByRendererMap && 
  258. m_pSiteInfoByRendererMap->Lookup(pRenderer, (void*&) pSiteInfo))
  259.     {
  260. RemoveEvents(ulGroupIndex, pSiteInfo->m_pRendererSite);
  261. CSmil1BasicRegion* pRegion = getRegion(pSiteInfo->m_regionID);
  262. showSite(pSiteInfo->m_pRendererSite, FALSE);
  263. // we only want to hide the region if there is no more 
  264. // renderer site shares the same region
  265. if (!pRendererList || pRendererList->GetCount() == 1)
  266. {
  267.     IHXSite* pRegionSite = NULL;
  268.     if (!pRegion->m_bBgColorSet)
  269.     {
  270. pRegionSite = pSiteInfo->m_pRegionSite;
  271.     }    
  272.     showSite(pRegionSite, FALSE);
  273. }
  274. if (pSiteInfo->m_pRendererSite)
  275. {
  276.     m_pSiteMgr->RemoveSite(pSiteInfo->m_pRendererSite);
  277.     pSiteInfo->m_pRendererSite->DetachWatcher();
  278.     
  279.     if(pRegion && pRegion->m_pSite)
  280.     {
  281. pRegion->m_pSite->DestroyChild(pSiteInfo->m_pRendererSite);
  282.     }
  283. }
  284. HX_RELEASE(pSiteInfo->m_pRendererSite);
  285. m_pSiteInfoByRendererMap->RemoveKey((void*)pRenderer);
  286. if(m_pSiteInfoList)
  287. {
  288.     // remove pSiteInfo from list
  289.     LISTPOSITION pos = m_pSiteInfoList->GetHeadPosition();
  290.     while(pos)
  291.     {
  292. SMIL1SiteInfo* pThisSiteInfo = (SMIL1SiteInfo*)
  293.     m_pSiteInfoList->GetAt(pos);
  294. if(pThisSiteInfo == pSiteInfo)
  295. {
  296.     delete pThisSiteInfo;
  297.     m_pSiteInfoList->RemoveAt(pos);
  298.     break;
  299. }
  300. m_pSiteInfoList->GetNext(pos);
  301.     }
  302. }
  303.     }
  304.     if (pPlayToAssoc)
  305.     {
  306. LISTPOSITION    pos;
  307. SMIL1SourceInfo* pSMIL1SourceInfo = NULL;
  308. if (pRendererList)
  309. {
  310.     CHXSimpleList::Iterator  i = pRendererList->Begin();
  311.     for (; i != pRendererList->End(); ++i)
  312.     {
  313. pSMIL1SourceInfo = (SMIL1SourceInfo*) (*i);
  314. if (pSMIL1SourceInfo->m_pRenderer == pRenderer)
  315. {
  316.     pos = pRendererList->Find(pSMIL1SourceInfo);
  317.     pRendererList->RemoveAt(pos);   
  318.     if (pSMIL1SourceInfo->m_pRendererEventHook)
  319.     {
  320. // get to the site manager and set an event hook
  321. IHXEventHookMgr* pHookMgr = NULL;
  322. if(HXR_OK == m_pSiteMgr->QueryInterface(IID_IHXEventHookMgr, 
  323. (void**)&pHookMgr))
  324. {
  325.     pHookMgr->RemoveHook(pSMIL1SourceInfo->m_pRendererEventHook, 
  326.  pSMIL1SourceInfo->m_pRendererEventHook->m_pChannelName, 0);
  327. }
  328. pHookMgr->Release();
  329.     }
  330.     
  331.     HX_RELEASE(pSMIL1SourceInfo->m_pRendererEventHook);
  332.     HX_RELEASE(pSMIL1SourceInfo->m_pStream);
  333.     HX_RELEASE(pSMIL1SourceInfo->m_pRenderer);
  334.     HX_DELETE(pSMIL1SourceInfo);
  335.     break;
  336. }
  337.     }
  338.     if (pRendererList->GetCount())
  339.     {
  340. pSMIL1SourceInfo = (SMIL1SourceInfo*)pRendererList->GetHead();
  341.     
  342. pPlayToAssoc->m_tunerName = pSMIL1SourceInfo->m_tunerName;
  343. pPlayToAssoc->m_childTunerName = pSMIL1SourceInfo->m_childTunerName;
  344. pPlayToAssoc->m_ulDelay = pSMIL1SourceInfo->m_ulDelay;
  345. pPlayToAssoc->m_ulDuration = pSMIL1SourceInfo->m_ulDuration;
  346. pPlayToAssoc->m_pRendererEventHook = pSMIL1SourceInfo->m_pRendererEventHook;
  347.     }
  348. }
  349. if (pPlayToAssoc->m_pSiteInfoList->GetCount() > 0 &&
  350.     pSiteInfo)
  351. {
  352.     pos = pPlayToAssoc->m_pSiteInfoList->Find(pSiteInfo);
  353.     pPlayToAssoc->m_pSiteInfoList->RemoveAt(pos);
  354. }
  355.     }
  356. #if defined(HELIX_FEATURE_SMIL2)
  357. cleanup:
  358. #endif /* defined(HELIX_FEATURE_SMIL2). */
  359.     return rc;
  360. }
  361. HX_RESULT
  362. CSmil1DocumentRenderer::addSiteForRenderer(SMIL1PlayToAssoc* pPlayToAssoc,
  363.   SMIL1SourceInfo* pSMIL1SourceInfo,
  364.   IHXRenderer* pRenderer,
  365.   BOOL bNoRegion)
  366. {
  367.     IHXSite* pRendererSite = 0;
  368.     if(!m_pMISUSSite)
  369.     {
  370. return HXR_UNEXPECTED;
  371.     }
  372.     CSmil1BasicRegion* pRegion = getRegion(pPlayToAssoc->m_playTo);
  373.     HX_ASSERT(pRegion);
  374.     HX_ASSERT(pRegion->m_pSite);
  375.     // now create a child of the parent site
  376.     // to hook to the renderer
  377.     pRegion->m_pSite->CreateChild(pRendererSite);
  378.     HX_ASSERT(pRendererSite);
  379. #ifdef _DEBUGBAB
  380.     char debugStr[256]; /* Flawfinder: ignore */
  381.     sprintf(debugStr, "region %s z-index %ld site: %p renderer site %pn", /* Flawfinder: ignore */
  382. (const char*)pPlayToAssoc->m_playTo,
  383. pRegion->m_lZIndex,
  384. pRegion->m_pSite,
  385. pRendererSite);
  386.     OutputDebugString(debugStr);
  387. #endif
  388.     CSmil1SiteWatcher* pRendererWatch = new CSmil1SiteWatcher(
  389. this, pPlayToAssoc->m_playTo, TRUE);
  390.     pRendererWatch->AddRef();
  391.     pRendererSite->AttachWatcher(pRendererWatch);
  392.     // map renderer site to the renderer
  393.     if(!m_pSiteWatcherMap)
  394.     {
  395. m_pSiteWatcherMap = new CHXMapPtrToPtr;
  396.     }
  397.     (*m_pSiteWatcherMap)[pRendererSite] = pRendererWatch;
  398.     IHXValues* pRendererSiteProps = NULL;
  399.     if (HXR_OK == pRendererSite->QueryInterface
  400.     (IID_IHXValues,
  401.      (void**)&pRendererSiteProps))
  402.     {
  403. CHXBuffer* pTunerValue = new CHXBuffer;
  404. pTunerValue->AddRef();
  405. pTunerValue->Set((UCHAR*)(const char*) pSMIL1SourceInfo->m_childTunerName,
  406.     strlen(pSMIL1SourceInfo->m_childTunerName)+1);
  407. pRendererSiteProps->SetPropertyCString("channel", pTunerValue);
  408. pTunerValue->Release();
  409. pRendererSiteProps->Release();
  410.     }
  411.     // This site needs to be added to the Site Manager!!!
  412.     m_pSiteMgr->AddSite(pRendererSite);
  413.     // hide the site initially
  414.     IHXSite* pRegionSite = NULL;
  415.     if(!pRegion->m_bBgColorSet)
  416.     {
  417. pRegionSite = pRegion->m_pSite;
  418.     }
  419.     if(pSMIL1SourceInfo->m_ulDelay > 0)
  420.     {
  421. // show site after m_ulDelay
  422. showSite(pRendererSite, FALSE);
  423.     }
  424.     else
  425.     {
  426. // show it now, don't wait for first time sync
  427. showSite(pRegionSite, TRUE);
  428. showSite(pRendererSite, TRUE);
  429.     }
  430.     // in any case, stick the event on the list...
  431.     CSmil1ShowSiteEvent* pShowEvent = 
  432. new CSmil1ShowSiteEvent(pPlayToAssoc->m_uGroupIndex,
  433.     pSMIL1SourceInfo->m_ulDelay, pRendererSite, 
  434.     pRegionSite, TRUE);
  435.     insertEvent(pShowEvent);
  436.     // hide site after m_ulDuration if it isn't live
  437.     if(pPlayToAssoc->m_bRemoveSite &&
  438.        !pPlayToAssoc->m_bLiveSource)
  439.     {
  440. CSmil1ShowSiteEvent* pHideEvent = 
  441.     new CSmil1ShowSiteEvent(pPlayToAssoc->m_uGroupIndex,
  442.     pSMIL1SourceInfo->m_ulDuration + pSMIL1SourceInfo->m_ulDelay, 
  443.     pRendererSite, pRegionSite, FALSE);
  444. insertEvent(pHideEvent);
  445.     }
  446.     SMIL1SiteInfo* pSiteInfo = new SMIL1SiteInfo;
  447.     pSiteInfo->m_pRendererSite = pRendererSite;
  448.     pSiteInfo->m_pRegionSite = pRegionSite;
  449.     pSiteInfo->m_uGroupIndex = pPlayToAssoc->m_uGroupIndex;
  450.     pSiteInfo->m_ulDelay = pSMIL1SourceInfo->m_ulDelay;
  451.     pSiteInfo->m_ulDuration = pSMIL1SourceInfo->m_ulDuration + 
  452.       pSMIL1SourceInfo->m_ulDelay;
  453.     pSiteInfo->m_bRemoveSite = pPlayToAssoc->m_bRemoveSite;
  454.     pSiteInfo->m_bNoRegion = bNoRegion;
  455.     pSiteInfo->m_regionID = pPlayToAssoc->m_playTo;
  456.     pSiteInfo->m_pRenderer = pRenderer;
  457.     pPlayToAssoc->m_pSiteInfoList->AddTail(pSiteInfo);
  458.     insertSiteInfo(pSiteInfo);
  459.     m_pSiteInfoByRendererMap->SetAt(pRenderer, 
  460. pSiteInfo);
  461.     return HXR_OK;
  462. }
  463. void
  464. CSmil1DocumentRenderer::insertZOrder(IHXSite* pSite, INT32 lZOrder)
  465. {
  466.     if(!m_pZOrderList)
  467.     {
  468. m_pZOrderList = new CHXSimpleList;
  469.     }
  470.     SMIL1ZOrderInfo* pInfo = new SMIL1ZOrderInfo;
  471.     pInfo->m_pSite = pSite;
  472.     pInfo->m_lZIndex = lZOrder;
  473.     LISTPOSITION lPos = m_pZOrderList->GetHeadPosition();
  474.     LISTPOSITION lPrev = lPos;
  475.     BOOL bInserted = FALSE;
  476.     while(lPos)
  477.     {
  478. SMIL1ZOrderInfo* pThisInfo = (SMIL1ZOrderInfo*)m_pZOrderList->GetNext(lPos);
  479. if(pThisInfo->m_lZIndex > lZOrder)
  480. {
  481.     m_pZOrderList->InsertBefore(lPrev, pInfo);
  482.     bInserted = TRUE;
  483.     break;
  484. }
  485. lPrev = lPos;
  486.     }
  487.     if(!bInserted)
  488.     {
  489. // not inserted, stick it on the end of the list
  490. m_pZOrderList->AddTail(pInfo);
  491.     }
  492. }
  493. /*
  494.  * setZOrder - run through all the channels
  495.  * and set the Z ordering for each
  496.  */
  497. void
  498. CSmil1DocumentRenderer::setZOrder()
  499. {
  500.     if(!m_pRegionMap)
  501.     {
  502. return;
  503.     }
  504.     CHXMapStringToOb::Iterator i = m_pRegionMap->Begin();
  505.     for(; i != m_pRegionMap->End(); ++i)
  506.     {
  507. CSmil1BasicRegion* pRegion = (CSmil1BasicRegion*)(*i);
  508. HXxWindow* pWindow = NULL;
  509. IHXSiteWindowed* pSiteWindowed = NULL;
  510. if(pRegion->m_pSite &&
  511.     HXR_OK == pRegion->m_pSite->QueryInterface(
  512.     IID_IHXSiteWindowed, (void**)&pSiteWindowed))
  513. {
  514.     pWindow = pSiteWindowed->GetWindow();
  515.     if (!pWindow || !pWindow->window)
  516.     {
  517. IHXSite2* pSite2 = 0;
  518. if(HXR_OK == pRegion->m_pSite->QueryInterface(
  519.     IID_IHXSite2, (void**)&pSite2))
  520. {
  521.     pSite2->SetZOrder(pRegion->m_lZIndex);
  522.     pSite2->Release();
  523. }
  524.     }
  525.     else
  526.     {
  527. insertZOrder(pRegion->m_pSite, pRegion->m_lZIndex);
  528.     }
  529.     pSiteWindowed->Release();
  530. }
  531. else
  532. {
  533.     insertZOrder(pRegion->m_pSite, pRegion->m_lZIndex);
  534. }
  535.     }
  536.     if(m_pZOrderList)
  537.     {
  538. INT32 idx = 0;
  539. LISTPOSITION lPos = m_pZOrderList->GetHeadPosition();
  540. while(lPos)
  541. {
  542.     SMIL1ZOrderInfo* pInfo = 
  543. (SMIL1ZOrderInfo*)m_pZOrderList->GetAt(lPos);
  544.     IHXSite2* pSite2 = 0;
  545.     if(pInfo->m_pSite &&
  546. HXR_OK == pInfo->m_pSite->QueryInterface(IID_IHXSite2, 
  547. (void**)&pSite2))
  548.     {
  549. #ifdef _DEBUGBAB
  550. char debugStr[256]; /* Flawfinder: ignore */
  551. sprintf(debugStr, "SMILDocRenderer:: site %p set z-order %ldn", pInfo->m_pSite, idx); /* Flawfinder: ignore */
  552. OutputDebugString(debugStr);
  553. #endif
  554. pSite2->SetZOrder(idx);
  555. pSite2->Release();
  556.     }
  557.     idx++;
  558.     delete pInfo;
  559.     lPos = m_pZOrderList->RemoveAt(lPos);
  560. }
  561. HX_DELETE(m_pZOrderList);
  562.     }
  563. }
  564. /*
  565.  * IHXGroupSink methods
  566.  */
  567. STDMETHODIMP
  568. CSmil1DocumentRenderer::GroupAdded(UINT16 uGroupIndex,
  569. IHXGroup* pGroup)
  570. {
  571.     HX_RESULT rc = HXR_OK;
  572.     SMIL1GroupInfo* pGroupInfo = 0;
  573. #if defined(HELIX_FEATURE_SMIL2)
  574.     if (m_pParent->isHigherVersionSmilStreamFromOldSMIL1FF())
  575.     {
  576. HX_ASSERT(m_pParent->m_pNextGenSmilRenderer);
  577. if (m_pParent->m_pNextGenSmilRenderer)
  578. {
  579.     rc = m_pParent->m_pNextGenSmilRenderer->SmilDocGroupAdded(
  580.     uGroupIndex, pGroup);
  581.     goto cleanup;
  582. }
  583.     }
  584. #endif /* defined(HELIX_FEATURE_SMIL2). */
  585.     if(!m_pGroupInfoMap)
  586.     {
  587. m_pGroupInfoMap = new CHXMapLongToObj;
  588.     }
  589.     // save group info
  590.     if(!m_pGroupInfoMap->Lookup(uGroupIndex, (void*&)pGroupInfo))
  591.     {
  592. IHXPlayer* pPlayer = m_pParent->getPlayer();
  593. IHXGroupManager* pMgr = 0;
  594. UINT32 ulTotalTracks = 0;
  595. if(HXR_OK == pPlayer->QueryInterface(IID_IHXGroupManager, 
  596.     (void**)&pMgr))
  597. {
  598.     IHXGroup* pGroup = NULL;
  599.     IHXGroup2* pGroup2 = NULL;
  600.     if (HXR_OK == pMgr->GetGroup(uGroupIndex, pGroup) &&
  601. HXR_OK == pGroup->QueryInterface(IID_IHXGroup2, (void**)&pGroup2))
  602.     {
  603. IHXValues* pGroupProperties = NULL;
  604. pGroup2->GetPersistentComponentProperties(m_ulPersistentComponentID,
  605.   pGroupProperties);
  606. if(pGroupProperties)
  607. {
  608.     pGroupProperties->GetPropertyULONG32("total_tracks", 
  609. ulTotalTracks);
  610. }
  611. HX_RELEASE(pGroupProperties);
  612.     }
  613.     HX_RELEASE(pGroup2);
  614.     HX_RELEASE(pGroup);
  615. }
  616. HX_RELEASE(pMgr);
  617. pGroupInfo = new SMIL1GroupInfo;
  618. pGroupInfo->m_nTracks = (int)ulTotalTracks;
  619. pGroupInfo->m_nTracksAdded = 0;
  620. pGroupInfo->m_nTrackDurationsSet = 0;
  621. pGroupInfo->m_ulDuration = 0;
  622. (*m_pGroupInfoMap)[uGroupIndex] = pGroupInfo;
  623.     }
  624.     else
  625.     {
  626. pGroupInfo->m_nTracksAdded++;
  627.     }
  628. #if defined(HELIX_FEATURE_SMIL2)
  629. cleanup:
  630. #endif /* defined(HELIX_FEATURE_SMIL2). */
  631.     return rc;
  632. }
  633. STDMETHODIMP
  634. CSmil1DocumentRenderer::GroupRemoved(UINT16 uGroupIndex,
  635.  IHXGroup* pGroup)
  636. {
  637.     HX_RESULT rc = HXR_OK;
  638. #if defined(HELIX_FEATURE_SMIL2)
  639.     if (m_pParent->isHigherVersionSmilStreamFromOldSMIL1FF())
  640.     {
  641. HX_ASSERT(m_pParent->m_pNextGenSmilRenderer);
  642. if (m_pParent->m_pNextGenSmilRenderer)
  643. {
  644.     rc = m_pParent->m_pNextGenSmilRenderer->SmilDocGroupRemoved(
  645.     uGroupIndex, pGroup);
  646.     goto cleanup;
  647. }
  648.     }
  649. #endif /* defined(HELIX_FEATURE_SMIL2). */
  650. #if defined(HELIX_FEATURE_SMIL2)
  651. cleanup:
  652. #endif /* defined(HELIX_FEATURE_SMIL2). */
  653.     return rc;
  654. }
  655. STDMETHODIMP
  656. CSmil1DocumentRenderer::AllGroupsRemoved()
  657. {
  658.     HX_RESULT rc = HXR_NOTIMPL;
  659. #if defined(HELIX_FEATURE_SMIL2)
  660.     if (m_pParent->isHigherVersionSmilStreamFromOldSMIL1FF())
  661.     {
  662. HX_ASSERT(m_pParent->m_pNextGenSmilRenderer);
  663. if (m_pParent->m_pNextGenSmilRenderer)
  664. {
  665.     rc = m_pParent->m_pNextGenSmilRenderer->SmilDocAllGroupsRemoved();
  666.     goto cleanup;
  667. }
  668.     }
  669. #endif /* defined(HELIX_FEATURE_SMIL2). */
  670. #if defined(HELIX_FEATURE_SMIL2)
  671. cleanup:
  672. #endif /* defined(HELIX_FEATURE_SMIL2). */
  673.     return rc;
  674. }
  675. STDMETHODIMP
  676. CSmil1DocumentRenderer::TrackAdded(UINT16 uGroupIndex,
  677.        UINT16 uTrackIndex,
  678.        IHXValues* pTrack)
  679. {
  680.     HX_RESULT rc = HXR_OK;
  681. #if defined(HELIX_FEATURE_SMIL2)
  682.     if (m_pParent->isHigherVersionSmilStreamFromOldSMIL1FF())
  683.     {
  684. HX_ASSERT(m_pParent->m_pNextGenSmilRenderer);
  685. if (m_pParent->m_pNextGenSmilRenderer)
  686. {
  687.     rc = m_pParent->m_pNextGenSmilRenderer->SmilDocTrackAdded(
  688.     uGroupIndex, uTrackIndex, pTrack);
  689.     goto cleanup;
  690. }
  691.     }
  692. #endif /* defined(HELIX_FEATURE_SMIL2). */
  693.     if(pTrack)
  694.     {
  695. IHXBuffer* pBuf = 0;
  696. const char* pID = 0;
  697. const char* pRegionName = 0;
  698. UINT32 ulDelay = 0;
  699. const char* pRepeatID = 0; // /For SHAZAM.
  700. if(HXR_OK == pTrack->GetPropertyCString("id", pBuf))
  701. {
  702.     pID = (const char*)pBuf->GetBuffer();
  703.     pBuf->Release();
  704. }
  705. // /For SHAZAM:
  706. if(HXR_OK == pTrack->GetPropertyCString("repeatid", pBuf))
  707. {
  708.     pRepeatID = (const char*)pBuf->GetBuffer();
  709.     pBuf->Release();
  710. }
  711. if(HXR_OK == pTrack->GetPropertyCString("region", pBuf))
  712. {
  713.     pRegionName = (const char*)pBuf->GetBuffer();
  714.     pBuf->Release();
  715. }
  716. if(HXR_OK == pTrack->GetPropertyCString("playto", pBuf))
  717. {
  718.     const char* pPlayTo = (const char*)pBuf->GetBuffer();
  719.     setPlayToAssoc(uGroupIndex, uTrackIndex, pID, pRepeatID,
  720.     pPlayTo, pRegionName);
  721.     pBuf->Release();
  722. }
  723. else // non-windowed renderer
  724. {
  725.     setPlayToAssoc(uGroupIndex, uTrackIndex, pID, pRepeatID,
  726.     0, pRegionName);
  727. }
  728. SMIL1PlayToAssoc* pAssoc = getPlayToAssoc(uGroupIndex, uTrackIndex);
  729. if(pAssoc)
  730. {
  731.     if(HXR_OK == pTrack->GetPropertyCString("fill", pBuf))
  732.     {
  733. const char* pFill = (const char*)pBuf->GetBuffer();
  734. if(strcmp(pFill, "freeze") == 0)    // default is 'remove'
  735. {
  736.     pAssoc->m_bRemoveSite = FALSE;
  737. }
  738. pBuf->Release();
  739.     }
  740. }
  741. SMIL1GroupInfo* pGroupInfo = 0;
  742. if(m_pGroupInfoMap->Lookup(uGroupIndex, (void*&)pGroupInfo))
  743. {
  744.     pGroupInfo->m_nTracksAdded++;
  745. }
  746.     }
  747. #if defined(HELIX_FEATURE_SMIL2)
  748. cleanup:
  749. #endif /* defined(HELIX_FEATURE_SMIL2). */
  750.     return rc;
  751. }
  752. STDMETHODIMP
  753. CSmil1DocumentRenderer::TrackRemoved(UINT16 uGroupIndex,
  754.  UINT16 uTrackIndex,
  755.  IHXValues* pTrack)
  756. {
  757.     HX_RESULT rc = HXR_NOTIMPL;
  758. #if defined(HELIX_FEATURE_SMIL2)
  759.     if (m_pParent->isHigherVersionSmilStreamFromOldSMIL1FF())
  760.     {
  761. HX_ASSERT(m_pParent->m_pNextGenSmilRenderer);
  762. if (m_pParent->m_pNextGenSmilRenderer)
  763. {
  764.     rc = m_pParent->m_pNextGenSmilRenderer->SmilDocTrackRemoved(
  765.     uGroupIndex, uTrackIndex, pTrack);
  766.     goto cleanup;
  767. }
  768.     }
  769. #endif /* defined(HELIX_FEATURE_SMIL2). */
  770. #if defined(HELIX_FEATURE_SMIL2)
  771. cleanup:
  772. #endif /* defined(HELIX_FEATURE_SMIL2). */
  773.     return rc;
  774. }
  775. STDMETHODIMP
  776. CSmil1DocumentRenderer::TrackStarted(UINT16 uGroupIndex,
  777.  UINT16 uTrackIndex,
  778.  IHXValues* pTrack)
  779. {
  780.     HX_RESULT rc = HXR_NOTIMPL;
  781. #if defined(HELIX_FEATURE_SMIL2)
  782.     if (m_pParent->isHigherVersionSmilStreamFromOldSMIL1FF())
  783.     {
  784. HX_ASSERT(m_pParent->m_pNextGenSmilRenderer);
  785. if (m_pParent->m_pNextGenSmilRenderer)
  786. {
  787.     rc = m_pParent->m_pNextGenSmilRenderer->SmilDocTrackStarted(
  788.     uGroupIndex, uTrackIndex, pTrack);
  789.     goto cleanup;
  790. }
  791.     }
  792. #endif /* defined(HELIX_FEATURE_SMIL2). */
  793.     if(m_bSettingFragment)
  794.     {
  795. // find out if all tracks for this group have been
  796. // added, then go ahead and seek
  797. UINT16 uFragmentGroup = m_pSmilParser->getFragmentGroup(m_pFragment);
  798. if(uFragmentGroup == uGroupIndex)
  799. {
  800.     SMIL1GroupInfo* pGroupInfo = 0;
  801.     m_nFragmentTracks++;
  802.     if(m_pGroupInfoMap->Lookup(uFragmentGroup, (void*&)pGroupInfo))
  803.     {
  804. if(pGroupInfo->m_nTracks == m_nFragmentTracks)
  805. {
  806.     IHXPlayer* pPlayer = m_pParent->getPlayer();
  807.     BOOL bFragFoundAndResolved = TRUE;
  808.     UINT32 ulFragmentOffset = 
  809. m_pSmilParser->getFragmentOffset(m_pFragment,
  810. bFragFoundAndResolved /*<--Passed by reference.*/);
  811.     //If getFragmentOffset() found the fragment and it had
  812.     // a resolved begin time (plus offset) of zero,
  813.     // we used to not seek to 0 even though that's a valid
  814.     // value.
  815.     // (Note: this problem was found while fixing PR 22655.)
  816.     if(bFragFoundAndResolved)
  817.     {
  818. pPlayer->Seek(ulFragmentOffset);
  819.     }
  820.     m_bSettingFragment = FALSE;
  821. }
  822.     }
  823. }
  824.     }
  825. #if defined(HELIX_FEATURE_SMIL2)
  826. cleanup:
  827. #endif /* defined(HELIX_FEATURE_SMIL2). */
  828.     return rc;
  829. }
  830. STDMETHODIMP
  831. CSmil1DocumentRenderer::TrackStopped(UINT16 uGroupIndex,
  832.  UINT16 uTrackIndex,
  833.  IHXValues* pTrack)
  834. {
  835.     HX_RESULT rc = HXR_NOTIMPL;
  836. #if defined(HELIX_FEATURE_SMIL2)
  837.     if (m_pParent->isHigherVersionSmilStreamFromOldSMIL1FF())
  838.     {
  839. HX_ASSERT(m_pParent->m_pNextGenSmilRenderer);
  840. if (m_pParent->m_pNextGenSmilRenderer)
  841. {
  842.     rc = m_pParent->m_pNextGenSmilRenderer->SmilDocTrackStopped(
  843.     uGroupIndex, uTrackIndex, pTrack);
  844.     goto cleanup;
  845. }
  846.     }
  847. #endif /* defined(HELIX_FEATURE_SMIL2). */
  848. #if defined(HELIX_FEATURE_SMIL2)
  849. cleanup:
  850. #endif /* defined(HELIX_FEATURE_SMIL2). */
  851.     return rc;
  852. }
  853. STDMETHODIMP
  854. CSmil1DocumentRenderer::CurrentGroupSet(UINT16 uGroupIndex,
  855.     IHXGroup* pGroup)
  856. {
  857.     HX_RESULT rc = HXR_OK;
  858.     INT16   uPrevGroupIndex = m_uCurrentGroupIndex;
  859. #if defined(HELIX_FEATURE_SMIL2)
  860.     if (m_pParent->isHigherVersionSmilStreamFromOldSMIL1FF())
  861.     {
  862. HX_ASSERT(m_pParent->m_pNextGenSmilRenderer);
  863. if (m_pParent->m_pNextGenSmilRenderer)
  864. {
  865.     rc = m_pParent->m_pNextGenSmilRenderer->SmilDocCurrentGroupSet(
  866.     uGroupIndex, pGroup);
  867.     goto cleanup;
  868. }
  869.     }
  870. #endif /* defined(HELIX_FEATURE_SMIL2). */
  871.     m_uCurrentGroupIndex = (INT16)uGroupIndex;
  872.     m_ulCurrentTime = 0;
  873.     if(uPrevGroupIndex != -1)
  874.     {
  875. m_pSmilParser->resetTimeline();
  876. removeGroupEvents(uPrevGroupIndex);
  877. removeGroupsPlayToAssoc(uPrevGroupIndex);
  878. m_ulEventListPosition = 0;
  879. if(m_pStatusMessage)
  880. {
  881.     m_pStatusMessage->SetStatus(NULL);
  882. }
  883. // hide any "transparent" sites
  884. if(m_pRegionMap)
  885. {
  886.     CHXMapStringToOb::Iterator i = m_pRegionMap->Begin();
  887.     for(; i != m_pRegionMap->End(); ++i)
  888.     {
  889. CSmil1BasicRegion* pRegion = (CSmil1BasicRegion*)(*i);
  890. if(!pRegion->m_bBgColorSet)
  891. {
  892.     showSite(pRegion->m_pSite, FALSE);
  893. }
  894.     }
  895. }
  896.     }
  897.     
  898. #if defined(HELIX_FEATURE_SMIL2)
  899. cleanup:
  900. #endif /* defined(HELIX_FEATURE_SMIL2). */
  901.     return rc;
  902. }
  903. void
  904. CSmil1DocumentRenderer::removeGroupEvents(UINT16 uGroupIndex)
  905. {
  906.     if(m_pEventList)
  907.     {
  908. LISTPOSITION lPos = m_pEventList->GetHeadPosition();
  909. while(lPos)
  910. {
  911.     // handle all events at or before ulTimeValue
  912.     CSmil1LayoutEvent* pEvent = (CSmil1LayoutEvent*)m_pEventList->GetAt(lPos);
  913.     if(pEvent->m_uGroupIndex == uGroupIndex)
  914.     {
  915. delete pEvent;
  916. lPos = m_pEventList->RemoveAt(lPos);
  917.     }
  918. }
  919.     }
  920. }
  921. SMIL1PlayToAssoc*
  922. CSmil1DocumentRenderer::getPlayToAssoc(UINT16 uGroupIndex, UINT16 uTrackIndex)
  923. {
  924.     SMIL1PlayToAssoc* pPlayToAssoc = 0;
  925.     if(m_pPlayToAssocList)
  926.     {
  927. CHXSimpleList::Iterator i;
  928. for(i=m_pPlayToAssocList->Begin();i!=m_pPlayToAssocList->End();++i)
  929. {
  930.     SMIL1PlayToAssoc* pThisAssoc = (SMIL1PlayToAssoc*)(*i);
  931.     if((pThisAssoc->m_uGroupIndex == uGroupIndex) &&
  932.        (pThisAssoc->m_uTrackIndex == uTrackIndex))
  933.     {
  934. pPlayToAssoc = pThisAssoc;
  935. break;
  936.     }
  937. }
  938.     }
  939.     return pPlayToAssoc;
  940. }
  941. SMIL1PlayToAssoc*
  942. CSmil1DocumentRenderer::getPlayToAssoc(const char* pPlayTo)
  943. {
  944.     SMIL1PlayToAssoc* pPlayToAssoc = 0;
  945.     if(m_pPlayToAssocList)
  946.     {
  947. CHXSimpleList::Iterator i;
  948. for(i=m_pPlayToAssocList->Begin();i!=m_pPlayToAssocList->End();++i)
  949. {
  950.     SMIL1PlayToAssoc* pThisAssoc = (SMIL1PlayToAssoc*)(*i);
  951.     if(pThisAssoc->m_playTo == pPlayTo)
  952.     {
  953. pPlayToAssoc = pThisAssoc;
  954. break;
  955.     }
  956. }
  957.     }
  958.     return pPlayToAssoc;
  959. }
  960. void
  961. CSmil1DocumentRenderer::setPlayToAssoc(UINT16 uGroupIndex, UINT16 uTrackIndex, 
  962.     const char* pID,
  963.     const char* pRepeatID, // /For SHAZAM
  964.     const char* pPlayTo,
  965.     const char* pRegionName)
  966. {
  967.     SMIL1PlayToAssoc* pPlayToAssoc = getPlayToAssoc(uGroupIndex, uTrackIndex);
  968.     if(!pPlayToAssoc)
  969.     {
  970. pPlayToAssoc     = new SMIL1PlayToAssoc;
  971. pPlayToAssoc->m_uGroupIndex = uGroupIndex;
  972. pPlayToAssoc->m_uTrackIndex = uTrackIndex;
  973. pPlayToAssoc->m_id     = pID;
  974. pPlayToAssoc->m_repeatid    = pRepeatID;
  975. pPlayToAssoc->m_playTo     = pPlayTo;
  976. pPlayToAssoc->m_ulDelay     = 0;
  977. pPlayToAssoc->m_ulDuration  = 0;
  978. pPlayToAssoc->m_bDurationResolved = FALSE;
  979. pPlayToAssoc->m_bRemoveSite = TRUE; // default is remove
  980. pPlayToAssoc->m_pHyperlinks = new CHXSimpleList;
  981. pPlayToAssoc->m_pRendererEventHook  = NULL;
  982. pPlayToAssoc->m_pSiteInfoList     = new CHXSimpleList;
  983. if(pRegionName)
  984. {
  985.     pPlayToAssoc->m_regionName  = pRegionName;
  986. }
  987. char cTemp[20]; /* Flawfinder: ignore */
  988. ::sprintf(cTemp,"%#010lx",(ULONG32)(void*)pPlayToAssoc); /* Flawfinder: ignore */
  989. pPlayToAssoc->m_tunerName   = (const char*) cTemp;
  990. ::sprintf(cTemp,"%#010lx",(ULONG32)(void*)pPlayToAssoc+1); /* Flawfinder: ignore */
  991. pPlayToAssoc->m_childTunerName = (const char*)cTemp;
  992. // see if the pPlayTo points to a valid CSmil1BasicRegion
  993. BOOL bNoRegion = TRUE;
  994. if(pPlayTo)
  995. {
  996.     CSmil1BasicRegion* pRegion = getRegion(pPlayTo);
  997.     if(pRegion)
  998.     {
  999. bNoRegion = FALSE;
  1000.     }
  1001. }
  1002. if(bNoRegion)
  1003. {
  1004.     // region name is tuner name if it's anonymous
  1005.     pPlayToAssoc->m_playTo = pPlayToAssoc->m_childTunerName;
  1006. }
  1007. else
  1008. {
  1009.     pPlayToAssoc->m_playTo = pPlayTo;
  1010. }
  1011. if(!m_pPlayToAssocList)
  1012. {
  1013.     m_pPlayToAssocList = new CHXSimpleList;
  1014. }
  1015. m_pPlayToAssocList->AddTail(pPlayToAssoc);
  1016.     }
  1017. }
  1018. void 
  1019. CSmil1DocumentRenderer::removeSourcemap(SMIL1PlayToAssoc* pPlayToAssoc)
  1020. {
  1021.     // get to the site manager and remove event hook
  1022.     IHXEventHookMgr* pHookMgr = NULL;
  1023.     m_pSiteMgr->QueryInterface(IID_IHXEventHookMgr, (void**)&pHookMgr);
  1024.     CHXMapLongToObj::Iterator j = pPlayToAssoc->m_sourceMap.Begin();
  1025.     for(; j != pPlayToAssoc->m_sourceMap.End(); ++j)
  1026.     {
  1027. CHXSimpleList* pRendererList = (CHXSimpleList*)(*j);
  1028. CHXSimpleList::Iterator k = pRendererList->Begin();
  1029. for (; k != pRendererList->End(); ++k)
  1030. {
  1031.     SMIL1SourceInfo* pSMIL1SourceInfo = (SMIL1SourceInfo*)(*k);
  1032.     if (pSMIL1SourceInfo->m_pRendererEventHook && pHookMgr)     
  1033.     {
  1034. pHookMgr->RemoveHook(pSMIL1SourceInfo->m_pRendererEventHook, 
  1035.      pSMIL1SourceInfo->m_pRendererEventHook->m_pChannelName, 0);
  1036.     }
  1037.     HX_RELEASE(pSMIL1SourceInfo->m_pRendererEventHook);
  1038.     HX_RELEASE(pSMIL1SourceInfo->m_pStream);
  1039.     HX_RELEASE(pSMIL1SourceInfo->m_pRenderer);
  1040.     HX_DELETE(pSMIL1SourceInfo);
  1041. }
  1042. HX_DELETE(pRendererList);
  1043.     }
  1044.     pPlayToAssoc->m_sourceMap.RemoveAll();
  1045.     HX_RELEASE(pHookMgr);
  1046. }
  1047. void
  1048. CSmil1DocumentRenderer::removeAllPlayToAssoc()
  1049. {
  1050.     if(m_pPlayToAssocList)
  1051.     {
  1052. CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
  1053. for(; i != m_pPlayToAssocList->End(); ++i)
  1054. {
  1055.     SMIL1PlayToAssoc* pPlayToAssoc = (SMIL1PlayToAssoc*)(*i);
  1056.     
  1057.     HX_DELETE(pPlayToAssoc->m_pHyperlinks);
  1058.     
  1059.     removeSourcemap(pPlayToAssoc);
  1060.     if (pPlayToAssoc->m_pSiteInfoList)
  1061.     {
  1062. pPlayToAssoc->m_pSiteInfoList->RemoveAll();
  1063. HX_DELETE(pPlayToAssoc->m_pSiteInfoList);
  1064.     }
  1065.     
  1066.     HX_DELETE(pPlayToAssoc);
  1067. }
  1068.     }
  1069.     HX_DELETE(m_pPlayToAssocList);
  1070. }
  1071. void
  1072. CSmil1DocumentRenderer::removeGroupsPlayToAssoc(UINT16 uGroupIndex)
  1073. {
  1074.     if(m_pPlayToAssocList)
  1075.     {
  1076. CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
  1077. for(; i != m_pPlayToAssocList->End(); ++i)
  1078. {
  1079.     SMIL1PlayToAssoc* pPlayToAssoc = (SMIL1PlayToAssoc*)(*i);
  1080.     
  1081.     /*
  1082.     if the PlayToAssoc has the same group number as the group index,
  1083.     then remove it.
  1084.     */
  1085.     
  1086.     if ( pPlayToAssoc->m_uGroupIndex == uGroupIndex )
  1087.     {
  1088. removeSourcemap(pPlayToAssoc);
  1089. if (pPlayToAssoc->m_pSiteInfoList)
  1090. {
  1091.     pPlayToAssoc->m_pSiteInfoList->RemoveAll();
  1092. }
  1093. break;
  1094.     }     
  1095. }
  1096.     }
  1097. }
  1098. void
  1099. CSmil1DocumentRenderer::showSite(IHXSite* pSite, BOOL bShow)
  1100. {
  1101.     if(pSite)
  1102.     {
  1103. IHXSite2* pSite2 = 0;
  1104. if(HXR_OK == pSite->QueryInterface(IID_IHXSite2,
  1105.     (void**)&pSite2))
  1106. {
  1107.     pSite2->ShowSite(bShow);
  1108.     pSite2->Release();
  1109. }
  1110.     }
  1111. }
  1112. CSmil1AAnchorElement*
  1113. CSmil1DocumentRenderer::findHyperlinkElement(const char* pID,
  1114.     UINT16 uXPos, UINT16 uYPos)
  1115. {
  1116.     // This code is not needed with new windowless site impl. of fullscreen 
  1117.     if (IsFullScreen())
  1118.     {
  1119. IHXSiteWindowless* pSiteWndless = NULL;
  1120. if (m_pMISUSSite)
  1121. {
  1122.     m_pMISUSSite->QueryInterface(IID_IHXSiteWindowless, (void**) &pSiteWndless);
  1123. }
  1124. // need to do this conversion only for the OLD site implementation
  1125. if (m_pMISUSSite && pSiteWndless == NULL)
  1126. {
  1127.     // If we are at full screen, then we need to scale the x and y
  1128.     // mouse locations down to the original size, since for full
  1129.     // screen we do not get a resizeSite.
  1130.     //
  1131.             // Get the current size
  1132.     HXxSize cCurSize;
  1133.     m_pMISUSSite->GetSize(cCurSize);
  1134.             // Scale it down
  1135.     if (cCurSize.cx)
  1136.     {
  1137. uXPos = (UINT16) (uXPos * m_topSiteOriginalSize.cx / cCurSize.cx);
  1138.     }
  1139.     if (cCurSize.cy)
  1140.     {
  1141. uYPos = (UINT16) (uYPos * m_topSiteOriginalSize.cy / cCurSize.cy);
  1142.     }
  1143. }
  1144. HX_RELEASE(pSiteWndless);
  1145.     }
  1146.     CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
  1147.     for(; i != m_pPlayToAssocList->End(); ++i)
  1148.     {
  1149. SMIL1PlayToAssoc* pAssoc = (SMIL1PlayToAssoc*)(*i);
  1150. if(strcmp((const char*)pAssoc->m_playTo, pID) == 0 &&
  1151.    pAssoc->m_uGroupIndex == m_uCurrentGroupIndex &&
  1152.    pAssoc->m_pHyperlinks)
  1153. {
  1154.     if(pAssoc->m_ulDelay == (UINT32)-1)
  1155.     {
  1156. // not resolved yet
  1157. return NULL;
  1158.     }
  1159.     // see if this site is current (visible) now;
  1160.     // if it isn't then no hyperlinks can be active
  1161.     // on that site.
  1162.     if (pAssoc->m_pSiteInfoList)
  1163.     {
  1164. CHXSimpleList::Iterator j = pAssoc->m_pSiteInfoList->Begin();
  1165. for (; j != pAssoc->m_pSiteInfoList->End(); ++j)
  1166. {
  1167.     BOOL bCurrentSite = TRUE; // if no site info, then
  1168. // the site is always current
  1169.     SMIL1SiteInfo* pSiteInfo = (SMIL1SiteInfo*)(*j);
  1170.     if(pSiteInfo->m_bRemoveSite)
  1171.     {
  1172. // /Fix for PR 34836:
  1173. // live sources that have 0 dur, which means they play
  1174. // forever, should have MAX_ULONG32, not 0, used as
  1175. // their dur when calculating whether or not they're
  1176. // visible at the current time:
  1177. ULONG32 ulDur = pAssoc->m_ulDuration;
  1178. if (pAssoc->m_bLiveSource  &&  0 == ulDur)
  1179. {
  1180.     ulDur = (ULONG32)(-1);
  1181. }
  1182. bCurrentSite = m_ulCurrentTime >= pSiteInfo->m_ulDelay &&
  1183.        m_ulCurrentTime <= pSiteInfo->m_ulDelay + 
  1184.        ulDur;
  1185.     }
  1186.     else
  1187.     {
  1188. bCurrentSite = m_ulCurrentTime >= pSiteInfo->m_ulDelay;
  1189.     }
  1190.     
  1191.     if(bCurrentSite)
  1192.     {
  1193. UINT32 ulRelativeTime = m_ulCurrentTime - pAssoc->m_ulDelay;
  1194. CHXSimpleList::Iterator j = pAssoc->m_pHyperlinks->Begin();
  1195. for(; j != pAssoc->m_pHyperlinks->End(); ++j)
  1196. {
  1197.     CSmil1AAnchorElement* pAnchor = (CSmil1AAnchorElement*)(*j);
  1198.     CSmil1BasicRegion* pRegion =
  1199. getRegion(pAssoc->m_playTo);
  1200.     if(pRegion)
  1201.     {
  1202. HXxRect mediaRect;
  1203. mediaRect.left = 0;
  1204. mediaRect.top = 0;
  1205. if(pRegion->m_bMediaSizeSet)
  1206. {
  1207.     mediaRect.right = pRegion->m_mediaSize.cx;
  1208.     mediaRect.bottom = pRegion->m_mediaSize.cy;
  1209. }
  1210. else
  1211. {
  1212.     mediaRect.right = pRegion->m_rect.right;
  1213.     mediaRect.bottom = pRegion->m_rect.bottom;
  1214. }
  1215. if(pAnchor->isCurrentLink(ulRelativeTime, uXPos, uYPos,
  1216.     mediaRect))
  1217. {
  1218.     //Now, we have to see if this points to a
  1219.     // fragment in the current SMIL presentation and,
  1220.     // if so, make sure that the begin time of the
  1221.     // associated element has been resolved.  If not,
  1222.     // we need to ignore the hyperlink for now:
  1223.     const char* pFragment =
  1224.                                         pAnchor->m_href.GetBuffer(2);
  1225.     HX_ASSERT(pFragment);
  1226.     //Only do the following if this is a fragment:
  1227.     if(pFragment && '#' == *pFragment)
  1228.     {
  1229. BOOL bFragFoundAndResolved = TRUE;
  1230. UINT32 ulFragmentOffset = 
  1231. m_pSmilParser->getFragmentOffset(
  1232. &(pFragment[1]),
  1233. /* This is passed by reference: */
  1234. bFragFoundAndResolved); 
  1235. //Fixes PR 22655:
  1236. //Ignore if not found or not yet resolved:
  1237. if(!bFragFoundAndResolved)
  1238. {
  1239.     // begin time not resolved yet
  1240.     return NULL;
  1241. }
  1242.     }
  1243.     return pAnchor;
  1244. }
  1245.     }
  1246. }
  1247.     }
  1248. }
  1249.     }
  1250. }
  1251.     }
  1252.     return NULL;
  1253. }
  1254. HX_RESULT
  1255. CSmil1DocumentRenderer::handleMouseMove(void* pWindow,
  1256. const char* pID,
  1257. UINT16 uXPos, UINT16 uYPos)
  1258. {
  1259.     // since IHXStatusMessage::SetStatus() effectively
  1260.     // results in a mouse move (and I don't want to loop
  1261.     // forever) don't do anything if this mouse move event
  1262.     // has the same xy as the previous mouse move event
  1263.     if(uXPos == m_usOldXPos &&
  1264. uYPos == m_usOldYPos)
  1265.     {
  1266. return HXR_OK;
  1267.     }
  1268.     m_usOldXPos = uXPos;
  1269.     m_usOldYPos = uYPos;
  1270.     HX_RESULT rc = HXR_FAIL;
  1271. #if defined(_WINDOWS)
  1272.     HCURSOR hCurrentCursor = GetCursor();
  1273. #endif
  1274.     CSmil1AAnchorElement* pAnchor = findHyperlinkElement(pID,
  1275. uXPos, uYPos);
  1276.     if(pAnchor)
  1277.     {
  1278. #if defined(_WINDOWS)
  1279. if(hCurrentCursor != m_hHyperlinkCursor)
  1280. {
  1281.     m_bNeedToSetHyperlinkCursor = TRUE;
  1282. }
  1283. #elif defined(_MACINTOSH)
  1284.         if (m_hHyperlinkCursor)
  1285.         {
  1286.     m_bResetCursor = TRUE;
  1287.     ::SetCursor(*m_hHyperlinkCursor);
  1288.         }
  1289. #endif
  1290. #if defined(_UNIX)  &&  (!defined(_BEOS))  &&  defined(USE_XWINDOWS)
  1291. if (m_pDisplay && m_Window && m_hHyperlinkCursor && m_hCurrentCursor != m_hHyperlinkCursor)
  1292. {
  1293.     XDefineCursor(m_pDisplay, m_Window, m_hHyperlinkCursor);
  1294.     m_hCurrentCursor = m_hHyperlinkCursor;
  1295. }
  1296. #endif
  1297. if (m_pStatusMessage)
  1298. {
  1299.     m_pStatusMessage->SetStatus (pAnchor->m_href);
  1300.     m_bStatusMessageSet = TRUE;
  1301. }
  1302. rc = HXR_OK; // handled
  1303.     }
  1304.     else
  1305.     {
  1306. #if defined(_WINDOWS)
  1307. if(hCurrentCursor == m_hHyperlinkCursor)
  1308. {
  1309.     //We need to change it back -- we just moved off of a hyperlink:
  1310.     m_bNeedToSetHyperlinkCursor = FALSE;
  1311. }
  1312. #elif defined(_MACINTOSH)
  1313. if (m_bResetCursor)
  1314. {
  1315.     m_bResetCursor = FALSE;
  1316.     InitCursor();
  1317. }
  1318. #elif defined(_UNIX)  &&  (!defined(_BEOS))  &&  defined(USE_XWINDOWS)
  1319. if (m_pDisplay && m_Window && m_hCurrentCursor == m_hHyperlinkCursor)
  1320. {
  1321.     XUndefineCursor(m_pDisplay, m_Window);
  1322.     m_hCurrentCursor = 0;
  1323. }
  1324. #endif
  1325. if (m_pStatusMessage &&
  1326.     m_bStatusMessageSet)
  1327. {
  1328.     m_pStatusMessage->SetStatus(NULL);
  1329.     m_bStatusMessageSet = FALSE;
  1330. }
  1331.     }
  1332.     return rc;
  1333. }
  1334. BOOL
  1335. CSmil1DocumentRenderer::handleSetCursor()
  1336. {
  1337.     BOOL rc = FALSE;
  1338. #ifdef _WINDOWS
  1339.     if(m_bNeedToSetHyperlinkCursor)
  1340.     {
  1341. // We don't want to overwrite our pre hyperlink cursor
  1342. HCURSOR hTemp = SetCursor(m_hHyperlinkCursor);
  1343. if (hTemp != m_hHyperlinkCursor)
  1344. {
  1345.     m_hPreHyperlinkCursor = hTemp;
  1346. }
  1347. rc = TRUE;
  1348.     }
  1349.     else if (m_hPreHyperlinkCursor)
  1350.     {
  1351. SetCursor(m_hPreHyperlinkCursor);
  1352. m_hPreHyperlinkCursor = NULL;
  1353. rc = TRUE;
  1354.     }
  1355. #endif
  1356.     return rc;
  1357. }
  1358. HX_RESULT
  1359. CSmil1DocumentRenderer::handleLButtonUp(const char* pID,
  1360.     UINT16 uXPos, UINT16 uYPos)
  1361. {
  1362. #if defined(_UNIX)  &&  (!defined(_BEOS))  &&  defined(USE_XWINDOWS)
  1363. //Clear the previously set cursors before leaving this window
  1364.     if(m_Window)
  1365.         XUndefineCursor(m_pDisplay, m_Window);
  1366. #endif
  1367.     HX_RESULT rc = HXR_FAIL;
  1368.     CSmil1AAnchorElement* pAnchor = findHyperlinkElement(pID,
  1369. uXPos, uYPos);
  1370.     if(pAnchor && pAnchor->m_href.GetLength() > 0)
  1371.     {
  1372. if(m_pParent)
  1373. {
  1374.     IHXPlayer* pPlayer = m_pParent->getPlayer();
  1375.     if(pPlayer)
  1376.     {
  1377. const char* pTarget = "_player";
  1378. // if show is 'new' or 'pause', spawn a browser
  1379. if(pAnchor->m_show == "new" ||
  1380.    pAnchor->m_show == "pause")
  1381. {
  1382.     pTarget = 0;
  1383. }
  1384. if(pAnchor->m_href[0] == '#')
  1385. {
  1386.     if (!m_pProcessElementCallback)
  1387.     {
  1388. m_pProcessElementCallback = new ProcessElementCallback();
  1389. m_pProcessElementCallback->m_pOwner = this;
  1390. m_pProcessElementCallback->AddRef();
  1391.     }
  1392.     if (m_pScheduler && !m_pProcessElementCallback->m_bIsCallbackPending)
  1393.     {
  1394. m_pProcessElementCallback->m_elementID = pAnchor->m_href.Mid(1);
  1395. m_pProcessElementCallback->m_bIsCallbackPending = TRUE;
  1396. m_pProcessElementCallback->m_PendingHandle = m_pScheduler->RelativeEnter(m_pProcessElementCallback, 0);
  1397.     }
  1398.     else
  1399.     {
  1400. HX_ASSERT(FALSE);
  1401.     }
  1402. }
  1403. else
  1404. {
  1405.     if(pAnchor->m_show == "pause")
  1406.     {
  1407. pPlayer->Pause();
  1408.     }
  1409.     IHXHyperNavigate* pHyper = 0;
  1410.     if(HXR_OK == pPlayer->QueryInterface(IID_IHXHyperNavigate,
  1411. (void**)&pHyper))
  1412.     {
  1413. CHXString urlString;
  1414. convertURL(pAnchor->m_href, urlString);
  1415. pHyper->GoToURL(urlString, pTarget);
  1416. pHyper->Release();
  1417.     }
  1418. }
  1419.     }
  1420.     rc = HXR_OK;
  1421. }
  1422.     }
  1423.     return rc;
  1424. }
  1425. HX_RESULT
  1426. CSmil1DocumentRenderer::detachSite(IHXSite* pSite)
  1427. {
  1428.     HX_RESULT rc = HXR_OK;
  1429.     // remove site from site info list
  1430.     LISTPOSITION pos = m_pSiteInfoList->GetHeadPosition();
  1431.     while(pos)
  1432.     {
  1433. SMIL1SiteInfo* pSiteInfo = 
  1434.     (SMIL1SiteInfo*)m_pSiteInfoList->GetAt(pos);
  1435. if(pSiteInfo->m_pRendererSite == pSite)
  1436. {
  1437.     CSmil1BasicRegion* pRegion = getRegion(pSiteInfo->m_regionID);
  1438.     if(pRegion)
  1439.     {
  1440. pRegion->m_pSite->DestroyChild(pSite);
  1441.     }
  1442.     m_pSiteInfoList->RemoveAt(pos);
  1443.     // at this time go through the PlayToAssocList list and
  1444.     // change any that reference the soon to be removed 
  1445.     // site info.
  1446.     if (m_pPlayToAssocList)
  1447.     {
  1448. CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
  1449. for (; i!=m_pPlayToAssocList->End(); ++i)
  1450. {
  1451.     SMIL1PlayToAssoc* pPlayToAssoc = (SMIL1PlayToAssoc*)(*i);
  1452.     
  1453.     LISTPOSITION pos = pPlayToAssoc->m_pSiteInfoList->Find(pSiteInfo);
  1454.     pPlayToAssoc->m_pSiteInfoList->RemoveAt(pos);
  1455. }
  1456.     }
  1457.     
  1458.     HX_DELETE(pSiteInfo);
  1459.     break;
  1460. }
  1461. m_pSiteInfoList->GetNext(pos);
  1462.     }
  1463.     return rc;
  1464. }
  1465. HX_RESULT
  1466. CSmil1DocumentRenderer::updateStreamTiming(const char* pElementID,
  1467.   UINT32 ulDuration)
  1468. {
  1469.     HX_RESULT rc = HXR_OK;
  1470.     CSmil1Element* pElement = m_pSmilParser->findElement(pElementID);
  1471.     if(pElement)
  1472.     {
  1473. // find the SMIL1PlayToAssoc associated with this element ID
  1474. SMIL1PlayToAssoc* pPlayToAssoc = NULL;
  1475. if(m_pPlayToAssocList)
  1476. {
  1477.     CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
  1478.     for (; i!=m_pPlayToAssocList->End(); ++i)
  1479.     {
  1480. SMIL1PlayToAssoc* pThisAssoc = (SMIL1PlayToAssoc*)(*i);
  1481. if(pThisAssoc->m_id == (const char*)pElement->m_pNode->m_id)
  1482. {
  1483.     pPlayToAssoc = pThisAssoc;
  1484.     break;
  1485. }
  1486.     }
  1487. }
  1488. if(pPlayToAssoc && 
  1489.    pPlayToAssoc->m_sourceMap.GetCount() > 0)
  1490. {
  1491.     pPlayToAssoc->m_ulDuration = ulDuration;
  1492.     CHXMapLongToObj::Iterator j = pPlayToAssoc->m_sourceMap.Begin();
  1493.     CHXSimpleList* pRendererInfoList = (CHXSimpleList*)(*j);
  1494.     SMIL1SourceInfo* pSourceInfo = (SMIL1SourceInfo*)pRendererInfoList->GetHead();
  1495.     IHXLayoutStream* pLayoutStream = NULL;
  1496.     if(HXR_OK == 
  1497. pSourceInfo->m_pStream->QueryInterface(IID_IHXLayoutStream, 
  1498.     (void**)&pLayoutStream))
  1499.     {
  1500. IHXValues* pStreamProps = NULL;
  1501. if(HXR_OK == pLayoutStream->GetProperties(pStreamProps))
  1502. {
  1503.     pStreamProps->SetPropertyULONG32("duration", ulDuration);
  1504.     pLayoutStream->SetProperties(pStreamProps);
  1505.     pStreamProps->Release();
  1506.     // XXX HP THIS IS NO-OP!!
  1507.     // update delay for subsequent elements
  1508.     //updateStreamDelay(pPlayToAssoc->m_uGroupIndex,
  1509.     //       pPlayToAssoc->m_ulDelay);
  1510. }
  1511. pLayoutStream->Release();
  1512.     }
  1513.     updateSiteEvents(pPlayToAssoc->m_uGroupIndex);
  1514. }
  1515.     }
  1516.     return rc;
  1517. }
  1518. HX_RESULT
  1519. CSmil1DocumentRenderer::updateStreamDelay(UINT16 uGroupIndex,
  1520.  UINT32 ulInitialDelay)
  1521. {
  1522.     HX_RESULT rc = HXR_OK;
  1523.     if(m_pPlayToAssocList)
  1524.     {
  1525. CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
  1526. for (; i!=m_pPlayToAssocList->End(); ++i)
  1527. {
  1528.     SMIL1PlayToAssoc* pPlayToAssoc = (SMIL1PlayToAssoc*)(*i);
  1529.     if(pPlayToAssoc->m_uGroupIndex == uGroupIndex &&
  1530. pPlayToAssoc->m_ulDelay > ulInitialDelay)
  1531.     {
  1532. UINT32 ulNewDelay = pPlayToAssoc->m_ulDelay;
  1533. pPlayToAssoc->m_ulDelay = ulNewDelay;
  1534. if(pPlayToAssoc->m_sourceMap.GetCount() > 0)
  1535. {
  1536.     CHXMapLongToObj::Iterator j = pPlayToAssoc->m_sourceMap.Begin();
  1537.     CHXSimpleList* pRendererList = (CHXSimpleList*)(*j);
  1538.     CHXSimpleList::Iterator k = pRendererList->Begin();
  1539.     for (; k != pRendererList->End(); ++k)
  1540.     {
  1541. SMIL1SourceInfo* pSMIL1SourceInfo = (SMIL1SourceInfo*)(*k);
  1542. IHXLayoutStream* pLayoutStream = NULL;
  1543. if(HXR_OK == 
  1544.     pSMIL1SourceInfo->m_pStream->QueryInterface(
  1545.     IID_IHXLayoutStream,
  1546.     (void**)&pLayoutStream))
  1547. {
  1548.     IHXValues* pStreamProps = NULL;
  1549.     if(HXR_OK == pLayoutStream->GetProperties(
  1550. pStreamProps))
  1551.     {
  1552. pStreamProps->SetPropertyULONG32("delay", 
  1553.     pPlayToAssoc->m_ulDelay);
  1554. pLayoutStream->SetProperties(pStreamProps);
  1555. pStreamProps->Release();
  1556.     }
  1557.     pLayoutStream->Release();
  1558. }
  1559.     }
  1560. }
  1561.     }
  1562. }
  1563.     }
  1564.     return rc;
  1565. }
  1566. HX_RESULT
  1567. CSmil1DocumentRenderer::updateSiteEvents(UINT16 uGroupIndex)
  1568. {
  1569.     HX_RESULT rc = HXR_OK;
  1570.     if(m_pPlayToAssocList)
  1571.     {
  1572. // blow away current events
  1573. removeGroupEvents(uGroupIndex);
  1574. CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
  1575. for (; i!=m_pPlayToAssocList->End(); ++i)
  1576. {
  1577.     SMIL1PlayToAssoc* pPlayToAssoc = (SMIL1PlayToAssoc*)(*i);
  1578.     if(pPlayToAssoc->m_uGroupIndex == uGroupIndex &&
  1579. pPlayToAssoc->m_pSiteInfoList)
  1580.     {
  1581. CHXSimpleList::Iterator j = pPlayToAssoc->m_pSiteInfoList->Begin();
  1582. for (; j != pPlayToAssoc->m_pSiteInfoList->End(); ++j)
  1583. {
  1584.     SMIL1SiteInfo* pSiteInfo = (SMIL1SiteInfo*)(*j);
  1585.     IHXSite* pRegionSite = NULL;
  1586.     CSmil1BasicRegion* pRegion = getRegion(pSiteInfo->m_regionID);
  1587.     if(pRegion && !pRegion->m_bBgColorSet)
  1588.     {
  1589. pRegionSite = pRegion->m_pSite;
  1590.     }
  1591.     pSiteInfo->m_ulDelay = pPlayToAssoc->m_ulDelay;
  1592.     pSiteInfo->m_ulDuration = pPlayToAssoc->m_ulDuration;
  1593.     if(pSiteInfo->m_ulDelay > m_ulCurrentTime)
  1594.     {
  1595. // hide site and schedule show and hide events
  1596. showSite(pSiteInfo->m_pRendererSite, FALSE);
  1597. showSite(pRegionSite, FALSE);
  1598. CSmil1ShowSiteEvent* pShowEvent =
  1599.     new CSmil1ShowSiteEvent(uGroupIndex,
  1600. pSiteInfo->m_ulDelay, pSiteInfo->m_pRendererSite, 
  1601. pRegionSite, TRUE);
  1602. insertEvent(pShowEvent);
  1603. if(pSiteInfo->m_bRemoveSite)
  1604. {
  1605.     CSmil1ShowSiteEvent* pHideEvent =
  1606. new CSmil1ShowSiteEvent(uGroupIndex,
  1607.     pSiteInfo->m_ulDuration + pSiteInfo->m_ulDelay, 
  1608.     pSiteInfo->m_pRendererSite, 
  1609.     pRegionSite, FALSE);
  1610.     insertEvent(pHideEvent);
  1611. }
  1612.     }
  1613.     else if((pSiteInfo->m_ulDelay + pSiteInfo->m_ulDuration)
  1614.     < m_ulCurrentTime)
  1615.     {
  1616. // XXX HP THIS SHOULD NEVER HAPPEN!!
  1617. HX_ASSERT(FALSE);
  1618. // after this site should be hidden
  1619. if(pSiteInfo->m_bRemoveSite)
  1620. {
  1621.     showSite(pSiteInfo->m_pRendererSite, FALSE);
  1622.     showSite(pRegionSite, FALSE);
  1623. }
  1624.     }
  1625.     else
  1626.     {
  1627. // schedule both show and hide events
  1628. // so onPreSeek will get all necessary
  1629. // events
  1630. CSmil1ShowSiteEvent* pShowEvent =
  1631.     new CSmil1ShowSiteEvent(uGroupIndex,
  1632. pSiteInfo->m_ulDelay, pSiteInfo->m_pRendererSite, 
  1633. pRegionSite, TRUE);
  1634. insertEvent(pShowEvent);
  1635. if(pSiteInfo->m_bRemoveSite)
  1636. {
  1637.     CSmil1ShowSiteEvent* pHideEvent =
  1638. new CSmil1ShowSiteEvent(uGroupIndex,
  1639.     pSiteInfo->m_ulDuration + pSiteInfo->m_ulDelay, 
  1640.     pSiteInfo->m_pRendererSite, 
  1641.     pRegionSite, FALSE);
  1642.     insertEvent(pHideEvent);
  1643. }
  1644.     }
  1645. }
  1646.     }
  1647. }
  1648.     }
  1649.     return rc;
  1650. }
  1651.  
  1652. HX_RESULT
  1653. CSmil1DocumentRenderer::seekTo(const char* pElementID)
  1654. {
  1655.     HX_RESULT rc = HXR_OK;
  1656.     CSmil1Element* pElement = m_pSmilParser->findElement(pElementID);
  1657.     if(pElement)
  1658.     {
  1659. HX_VECTOR_DELETE(m_pFragment);
  1660. m_pFragment = new_string(pElementID);
  1661. IHXPlayer* pPlayer = m_pParent->getPlayer();
  1662. IHXGroupManager* pMgr = 0;
  1663. if(HXR_OK == pPlayer->QueryInterface(IID_IHXGroupManager, (void**)&pMgr))
  1664. {
  1665.     UINT16 uFragmentGroup = m_pSmilParser->getFragmentGroup(m_pFragment);
  1666.     if(uFragmentGroup != m_uCurrentGroupIndex)
  1667.     {
  1668. m_bSettingFragment = TRUE;
  1669.      m_nFragmentTracks = 0;
  1670. pMgr->SetCurrentGroup(uFragmentGroup);
  1671.     }
  1672.     else
  1673.     {
  1674. BOOL bFragFoundAndResolved =TRUE;
  1675. UINT32 ulFragmentOffset = 
  1676.     m_pSmilParser->getFragmentOffset(m_pFragment,
  1677.     /* This is passed by reference: */
  1678.     bFragFoundAndResolved); 
  1679. //If getFragmentOffset() failed to find the fragment or
  1680. // found it but it did not yet have a resolved begin time,
  1681. // we used to seek to 0 (the returned value), but now we
  1682. // just don't do a seek:
  1683. // (Note: this problem was found while fixing PR 22655.)
  1684. if(bFragFoundAndResolved)
  1685. {
  1686.     pPlayer->Seek(ulFragmentOffset);
  1687.     pPlayer->Begin();
  1688. }
  1689.     }
  1690.     pMgr->Release();
  1691. }
  1692.     }
  1693.     else
  1694.     {
  1695. rc = HXR_FAIL;
  1696.     }
  1697.     return rc;
  1698. }
  1699. void
  1700. CSmil1DocumentRenderer::resizeRegion(const char* pRegionName,
  1701.     HXxSize* pNewSize)
  1702. {
  1703.     CSmil1BasicRegion* pRegion = getRegion(pRegionName);
  1704.     if(pRegion)
  1705.     {
  1706. pRegion->m_rect.right = pRegion->m_rect.left + pNewSize->cx;
  1707. pRegion->m_rect.bottom = pRegion->m_rect.top + pNewSize->cy;
  1708.     }
  1709. }
  1710. void
  1711. CSmil1DocumentRenderer::repositionRegion(const char* pRegionName,
  1712.       HXxPoint* pNewPosition)
  1713. {
  1714.     CSmil1BasicRegion* pRegion = getRegion(pRegionName);
  1715.     if(pRegion)
  1716.     {
  1717. HXxSize size;
  1718. size.cx = HXxRECT_WIDTH(pRegion->m_rect);
  1719. size.cy = HXxRECT_HEIGHT(pRegion->m_rect);
  1720. pRegion->m_rect.left = pNewPosition->x;
  1721. pRegion->m_rect.top = pNewPosition->y;
  1722. pRegion->m_rect.right = pRegion->m_rect.left + size.cx;
  1723. pRegion->m_rect.bottom = pRegion->m_rect.top + size.cy;
  1724.     }
  1725. }
  1726. /*
  1727.  * IHXValues methods
  1728.  */
  1729. STDMETHODIMP
  1730. CSmil1DocumentRenderer::GetPropertyULONG32      (
  1731.     const char*          pPropertyName,
  1732.     REF(ULONG32)         uPropertyValue)
  1733. {
  1734.     return m_pValues->GetPropertyULONG32(pPropertyName, uPropertyValue);
  1735. }
  1736. STDMETHODIMP
  1737. CSmil1DocumentRenderer::GetPropertyCString     (
  1738. const char*         pPropertyName,
  1739. REF(IHXBuffer*)    pPropertyValue)
  1740. {
  1741.     return m_pValues->GetPropertyCString(pPropertyName, pPropertyValue);
  1742. }
  1743. STDMETHODIMP
  1744. CSmil1DocumentRenderer::SetPropertyULONG32      (
  1745. const char*          pPropertyName,
  1746. ULONG32              uPropertyValue)
  1747. {
  1748.     return m_pValues->SetPropertyULONG32(pPropertyName, uPropertyValue);
  1749. }
  1750. STDMETHODIMP
  1751. CSmil1DocumentRenderer::GetFirstPropertyULONG32   (
  1752. REF(const char*)     pPropertyName,
  1753. REF(ULONG32)         uPropertyValue)
  1754. {
  1755.     return m_pValues->GetFirstPropertyULONG32(pPropertyName, uPropertyValue);
  1756. }
  1757. STDMETHODIMP
  1758. CSmil1DocumentRenderer::GetNextPropertyULONG32   (
  1759. REF(const char*)    pPropertyName,
  1760. REF(ULONG32)        uPropertyValue)
  1761. {
  1762.     return m_pValues->GetNextPropertyULONG32(pPropertyName, uPropertyValue);
  1763. }
  1764. STDMETHODIMP
  1765. CSmil1DocumentRenderer::SetPropertyBuffer     (
  1766. const char*         pPropertyName,
  1767. IHXBuffer*         pPropertyValue)
  1768. {
  1769.     return m_pValues->SetPropertyBuffer(pPropertyName, pPropertyValue);
  1770. }
  1771. STDMETHODIMP
  1772. CSmil1DocumentRenderer::GetPropertyBuffer     (
  1773. const char*         pPropertyName,
  1774. REF(IHXBuffer*)    pPropertyValue)
  1775. {
  1776.     return m_pValues->GetPropertyBuffer(pPropertyName, pPropertyValue);
  1777. }
  1778. STDMETHODIMP
  1779. CSmil1DocumentRenderer::GetFirstPropertyBuffer   (
  1780. REF(const char*)    pPropertyName,
  1781. REF(IHXBuffer*)    pPropertyValue)
  1782. {
  1783.     return m_pValues->GetFirstPropertyBuffer(pPropertyName, pPropertyValue);
  1784. }
  1785. STDMETHODIMP
  1786. CSmil1DocumentRenderer::GetNextPropertyBuffer    (
  1787. REF(const char*)    pPropertyName,
  1788. REF(IHXBuffer*)    pPropertyValue)
  1789. {
  1790.     return m_pValues->GetNextPropertyBuffer(pPropertyName, pPropertyValue);
  1791. }
  1792. STDMETHODIMP
  1793. CSmil1DocumentRenderer::SetPropertyCString     (
  1794. const char*         pPropertyName,
  1795. IHXBuffer*         pPropertyValue)
  1796. {
  1797.     return m_pValues->SetPropertyCString(pPropertyName, pPropertyValue);
  1798. }
  1799. STDMETHODIMP
  1800. CSmil1DocumentRenderer::GetFirstPropertyCString   (
  1801. REF(const char*)    pPropertyName,
  1802. REF(IHXBuffer*)    pPropertyValue)
  1803. {
  1804.     return m_pValues->GetFirstPropertyCString(pPropertyName, pPropertyValue);
  1805. }
  1806. STDMETHODIMP
  1807. CSmil1DocumentRenderer::GetNextPropertyCString    (
  1808. REF(const char*)    pPropertyName,
  1809. REF(IHXBuffer*)    pPropertyValue)
  1810. {
  1811.     return m_pValues->GetNextPropertyCString(pPropertyName, pPropertyValue);
  1812. }
  1813. HX_RESULT
  1814. CSmil1DocumentRenderer::GetElementProperties(UINT16 uGroupID, 
  1815.     UINT16 uTrackID, 
  1816.     REF(IHXValues*) pProperties)
  1817. {
  1818.     HX_RESULT rc = HXR_OK;
  1819.     ElementWithinTag elementWithinTag = WithinUnknown;
  1820.     SMIL1PlayToAssoc* pPlayToAssoc = getPlayToAssoc(uGroupID,
  1821.    uTrackID);
  1822.     if(pPlayToAssoc)
  1823.     {
  1824. elementWithinTag = m_pSmilParser->GetElementWithin(pPlayToAssoc->m_id);
  1825.     }
  1826.     pProperties = new CHXHeader();
  1827.     pProperties->AddRef();
  1828.     pProperties->SetPropertyULONG32("ElementWithinTag", elementWithinTag);
  1829.     return rc;
  1830. }
  1831. HX_RESULT  
  1832. CSmil1DocumentRenderer::GetElementStatus(UINT16     uGroupID,
  1833.          UINT16     uTrackID,
  1834.          UINT32     ulCurrentTime,
  1835.          REF(IHXValues*)   pStatus)
  1836. {
  1837.     HX_RESULT     rc = HXR_OK;
  1838.     CHXSimpleList*     pSiteInfoList = NULL;
  1839.     CSmil1Element*     pElement = NULL;
  1840.     CSmil1ShowSiteEvent*    pCurHideEvent = NULL;
  1841.     SMIL1PlayToAssoc*     pPlayToAssoc = getPlayToAssoc(uGroupID, uTrackID);
  1842.     pStatus = NULL;
  1843.     if (pPlayToAssoc && pPlayToAssoc->m_pSiteInfoList)
  1844.     {
  1845. pSiteInfoList = pPlayToAssoc->m_pSiteInfoList;
  1846.         LISTPOSITION pos = pSiteInfoList->GetHeadPosition();
  1847.         while (pos)
  1848.         {
  1849.             SMIL1SiteInfo* pSiteInfo = (SMIL1SiteInfo*)pSiteInfoList->GetNext(pos);
  1850.             if (pSiteInfo)
  1851.             {
  1852. pCurHideEvent = getShowHideEvent(pSiteInfo->m_pRegionSite,
  1853.  pSiteInfo->m_pRendererSite,
  1854.                                                  FALSE);
  1855. if (pCurHideEvent && pCurHideEvent->m_ulEventTime > ulCurrentTime)
  1856. {
  1857.     pStatus = new CHXHeader();
  1858.     pStatus->AddRef();
  1859.     pStatus->SetPropertyULONG32("Show", 1);
  1860.     break;
  1861. }
  1862.     }
  1863. }
  1864.     }
  1865.     return rc;
  1866. }
  1867. HX_RESULT
  1868. CSmil1DocumentRenderer::AttachElementLayout(UINT16     uGroupID,
  1869.     UINT16     uTrackID,
  1870.     IHXRenderer*   pRenderer,
  1871.     IHXStream*     pStream,
  1872.     IHXValues*     pProps)
  1873. {
  1874.     HX_RESULT rc = HXR_OK;    
  1875.     UINT32 ulDelay = 0;
  1876.     UINT32 ulDuration = 0;
  1877.     IHXLayoutStream* pLayoutStream = NULL;
  1878.     CSmil1BasicRegion* pRegion = NULL;
  1879.     CHXSimpleList* pRendererList = NULL;
  1880.     SMIL1SourceInfo* pSourceInfo = NULL;
  1881.     SMIL1PlayToAssoc* pPlayToAssoc = NULL;
  1882.     // setup the Root layout if it has not
  1883.     // this could happen when the child SMIL gets initialized 
  1884.     // ahead of its parent when switching groups
  1885.     if (m_bSitesDetached)
  1886.     {
  1887. m_bSitesDetached = FALSE;
  1888. rc = setupRootLayout();
  1889. HX_ASSERT(HXR_OK == rc);
  1890.     }
  1891.     pPlayToAssoc = getPlayToAssoc(uGroupID, uTrackID);
  1892.     HX_ASSERT(pPlayToAssoc);
  1893.     pRegion = getRegion(pPlayToAssoc->m_playTo);    
  1894.     if (!pRegion)
  1895.     {
  1896. // phony one up
  1897. HXxRect rect = {0, 0, 0, 0};
  1898. pRegion = new CSmil1BasicRegion(pPlayToAssoc->m_playTo, rect, 0, "hidden", 0, 
  1899.     FALSE, TRUE,
  1900.     //Default to TRUE for width unspecified and
  1901.     // height unspecified:
  1902.     TRUE, TRUE);
  1903. (*m_pRegionMap)[pPlayToAssoc->m_playTo] = pRegion;
  1904.     }
  1905.     if (pStream && pProps)
  1906.     {
  1907. pSourceInfo = new SMIL1SourceInfo;
  1908. pSourceInfo->m_pStream = pStream;
  1909. if(pSourceInfo->m_pStream)
  1910. {
  1911.     pSourceInfo->m_pStream->AddRef();
  1912. }
  1913. pSourceInfo->m_pRenderer = pRenderer;
  1914. if(pSourceInfo->m_pRenderer)
  1915. {
  1916.     pSourceInfo->m_pRenderer->AddRef();
  1917. }
  1918.     
  1919. pProps->GetPropertyULONG32("Delay", ulDelay);
  1920. pProps->GetPropertyULONG32("Duration", ulDuration);
  1921. pSourceInfo->m_ulDelay = ulDelay;
  1922. pSourceInfo->m_ulDuration = ulDuration - ulDelay;
  1923. pRendererList = (CHXSimpleList*) pPlayToAssoc->m_sourceMap[0];
  1924. pRendererList->AddTail(pSourceInfo);
  1925.     }
  1926.     else
  1927.     {
  1928. pRendererList = (CHXSimpleList*)pPlayToAssoc->m_sourceMap[0];
  1929. HX_ASSERT(pRendererList->GetCount() == 1);
  1930. pSourceInfo = (SMIL1SourceInfo*)pRendererList->GetHead();
  1931.     }
  1932.     char cTemp[20]; /* Flawfinder: ignore */
  1933.     ::sprintf(cTemp,"%#010lx",(ULONG32)(void*)pRenderer); /* Flawfinder: ignore */
  1934.     pSourceInfo->m_tunerName   = (const char*) cTemp;
  1935.     ::sprintf(cTemp,"%#010lx",(ULONG32)(void*)pRenderer+1); /* Flawfinder: ignore */
  1936.     pSourceInfo->m_childTunerName = (const char*)cTemp;
  1937.     const char* pChildTuner = pSourceInfo->m_childTunerName;
  1938.     // get to the site manager and set an event hook
  1939.     IHXEventHookMgr* pHookMgr = NULL;
  1940.     if(HXR_OK ==
  1941. m_pSiteMgr->QueryInterface(IID_IHXEventHookMgr, 
  1942. (void**)&pHookMgr))
  1943.     {
  1944. CSmil1EventHook* pChildEventHook = NULL;
  1945. // create event hook for playto
  1946. pChildEventHook = new CSmil1EventHook(this,
  1947.      pPlayToAssoc->m_playTo, pChildTuner, FALSE);
  1948. pChildEventHook->AddRef();
  1949. pHookMgr->AddHook(pChildEventHook, pChildTuner, 0);
  1950. pSourceInfo->m_pRendererEventHook = pChildEventHook;
  1951. pHookMgr->Release();
  1952.     }
  1953.     else
  1954.     {
  1955. pSourceInfo->m_pRendererEventHook = NULL;
  1956.     }
  1957.     pPlayToAssoc->m_tunerName = pSourceInfo->m_tunerName;
  1958.     pPlayToAssoc->m_childTunerName = pSourceInfo->m_childTunerName;
  1959.     pPlayToAssoc->m_pRendererEventHook = pSourceInfo->m_pRendererEventHook;
  1960.     // add hyperlinks
  1961.     CSmil1Element* pElement = m_pSmilParser->findElement(pPlayToAssoc->m_id);
  1962.     if(pElement && pElement->m_pHyperlinks)
  1963.     {
  1964. CHXSimpleList::Iterator i = 
  1965. pElement->m_pHyperlinks->Begin();
  1966. for(; i != pElement->m_pHyperlinks->End(); ++i)
  1967. {
  1968.     CSmil1AAnchorElement* pAnchor = 
  1969. (CSmil1AAnchorElement*)(*i);
  1970.     //[SMIL 1.0 Compliance] Fixes PR 26473:
  1971.     // We want to add in LIFO fashion so inner
  1972.     // (nested) anchors will be found first in
  1973.     // CSmilDocumentRenderer::findHyperlinkElement(),
  1974.     // below.  In other words, we're giving an
  1975.     // effective higher link "z-order" to the
  1976.     // decendants of other links.  This used to
  1977.     // call AddTail():
  1978.     pPlayToAssoc->m_pHyperlinks->AddHead(pAnchor);
  1979. }
  1980.     }
  1981.     IHXValues* pValues = 0;
  1982.     IHXBuffer* pPlayToBuffer = 0;
  1983.     IHXBuffer* pRegionName = 0;
  1984.     IHXCommonClassFactory* pFactory = m_pParent->getFactory();
  1985.     if ((HXR_OK == pFactory->CreateInstance(CLSID_IHXValues, (void**)&pValues)) &&
  1986. (HXR_OK == pFactory->CreateInstance(CLSID_IHXBuffer, (void**)&pPlayToBuffer)) &&
  1987. (HXR_OK == pFactory->CreateInstance(CLSID_IHXBuffer, (void**)&pRegionName)))
  1988.     {     
  1989. pPlayToBuffer->Set((BYTE*)pChildTuner, strlen(pChildTuner)+1);
  1990. pValues->SetPropertyCString("playto", pPlayToBuffer);
  1991. if(pPlayToAssoc->m_regionName.GetLength() > 0)
  1992. {
  1993.     const char* pName = pPlayToAssoc->m_regionName;
  1994.     pRegionName->Set((BYTE*)pName, strlen(pName)+1);
  1995.     pValues->SetPropertyCString("region", pRegionName);
  1996. }
  1997.     }
  1998.     HX_RELEASE(pPlayToBuffer);
  1999.     HX_RELEASE(pRegionName);
  2000.     if (pStream &&
  2001. HXR_OK == pStream->QueryInterface(IID_IHXLayoutStream, (void**)&pLayoutStream))
  2002.     {
  2003. pLayoutStream->SetProperties(pValues);
  2004.     }
  2005.     HX_RELEASE(pLayoutStream);
  2006.     if(!pRegion->m_bImplicitRegion)
  2007.     {
  2008. addSiteForRenderer(pPlayToAssoc, pSourceInfo, pRenderer, FALSE);
  2009.     
  2010. if (!pStream)
  2011. {
  2012.     m_pParent->HandleAttachElementLayout((IUnknown*)pRenderer, pValues);
  2013. }
  2014.     }
  2015.     HX_RELEASE(pValues);
  2016.     return rc;
  2017. }
  2018. HX_RESULT
  2019. CSmil1DocumentRenderer::DetachElementLayout(IUnknown* pLSG)
  2020. {
  2021.     HX_RESULT rc = HXR_OK;
  2022.     return rc;
  2023. }
  2024. HX_RESULT
  2025. CSmil1DocumentRenderer::InitPersistent(UINT32 ulPersistentComponentID,
  2026.       UINT16 uPersistentGroupID,
  2027.       UINT16 uPersistentTrackID,
  2028.       IHXPersistentRenderer* pPersistentParent)
  2029. {
  2030.     m_ulPersistentComponentID = ulPersistentComponentID;
  2031.     m_uPersistentGroupID = uPersistentGroupID;
  2032.     m_uPersistentTrackID = uPersistentTrackID;
  2033.     m_pPersistentParentRenderer = pPersistentParent;
  2034.     HX_ADDREF(m_pPersistentParentRenderer);
  2035.     return HXR_OK;
  2036. }
  2037. BOOL 
  2038. CSmil1DocumentRenderer::IsNestedMetaSupported(UINT16& uSupportedType)
  2039. {
  2040.     BOOL     bResult = TRUE;    
  2041.     UINT32     ulParentPersistentVersion = 0;
  2042.     UINT32     ulParentPersistentMajorVersion = 0;
  2043.     UINT32     ulParentPersistentType = PersistentUnknown;
  2044.     IHXValues*     pProperties = NULL;
  2045.     uSupportedType = 0;
  2046.     if (!m_pPersistentParentRenderer)
  2047.     {
  2048. return bResult;
  2049.     }
  2050.     if (HXR_OK == m_pPersistentParentRenderer->GetPersistentProperties(pProperties))
  2051.     {
  2052. pProperties->GetPropertyULONG32("PersistentType", ulParentPersistentType);
  2053. pProperties->GetPropertyULONG32("PersistentVersion", ulParentPersistentVersion);
  2054. ulParentPersistentMajorVersion = HX_GET_MAJOR_VERSION(ulParentPersistentVersion);
  2055. switch (ulParentPersistentType)
  2056. {
  2057. case PersistentUnknown:
  2058.     bResult = FALSE;
  2059.     break;
  2060. case PersistentRAM:
  2061.     // RP8 SS3 - limited SMIL in RAM support
  2062.     if (ulParentPersistentMajorVersion == 2)
  2063.     {
  2064. m_bInRAM20 = TRUE;
  2065. uSupportedType = 1;
  2066.     }
  2067.     // otherwise - fully nested meta support even though
  2068.     // the parent RAM is 1.0
  2069.     else
  2070.     {
  2071. uSupportedType = 2;
  2072.     }
  2073.     break;
  2074. case PersistentSMIL:
  2075.     if (ulParentPersistentMajorVersion == 1)
  2076.     {
  2077. bResult = FALSE;
  2078.     }
  2079.     else
  2080.     {
  2081. uSupportedType = 2;
  2082.     }
  2083.     break;
  2084. default:
  2085.     break;
  2086. }
  2087.     }
  2088.     HX_RELEASE(pProperties);
  2089.     
  2090.     return bResult;
  2091. }
  2092. void
  2093. CSmil1DocumentRenderer::PersistentDurationSet(UINT32 ulDuration, 
  2094.      UINT32 ulDelay, 
  2095.      BOOL bIsLive)
  2096. {
  2097.     IHXRendererAdviseSink* pRendererAdviseSink = NULL;
  2098.     if (m_pPersistentParentRenderer &&
  2099. HXR_OK == m_pPersistentParentRenderer->QueryInterface(IID_IHXRendererAdviseSink, (void**)&pRendererAdviseSink))
  2100.     {
  2101. pRendererAdviseSink->TrackDurationSet(m_uPersistentGroupID,
  2102.       m_uPersistentTrackID,
  2103.       ulDuration,
  2104.       ulDelay,
  2105.       bIsLive);
  2106.     }
  2107.     HX_RELEASE(pRendererAdviseSink);
  2108.     return;
  2109. }
  2110. /*
  2111.  * CSmil1SiteWatcher methods
  2112.  */
  2113. CSmil1SiteWatcher::CSmil1SiteWatcher(CSmil1DocumentRenderer* 
  2114.     pDoc, const char* pID, BOOL bIsChildSite):
  2115.     m_pDoc(pDoc),
  2116.     m_lRefCount(0),
  2117.     m_id(pID),
  2118.     m_bIsChildSite(bIsChildSite),
  2119.     m_pSite(0),
  2120.     m_bChangingSize(FALSE),
  2121.     m_bFirstSetSize(TRUE)
  2122. {
  2123. #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
  2124.     char szDbgStr[128]; /* Flawfinder: ignore */
  2125.     sprintf(szDbgStr, "CON CSmil1SiteWatcher 0x%08xn", this); /* Flawfinder: ignore */
  2126.     OutputDebugString(szDbgStr);
  2127. #endif
  2128.     if(m_pDoc)
  2129.     {
  2130. m_pDoc->AddRef();
  2131.     }
  2132. }
  2133. CSmil1SiteWatcher::~CSmil1SiteWatcher()
  2134. {
  2135. #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
  2136.     char szDbgStr[128]; /* Flawfinder: ignore */
  2137.     sprintf(szDbgStr, "DES CSmil1SiteWatcher 0x%08xn", this); /* Flawfinder: ignore */
  2138.     OutputDebugString(szDbgStr);
  2139. #endif
  2140.     close();
  2141. }
  2142. HX_RESULT
  2143. CSmil1SiteWatcher::close()
  2144. {
  2145.     HX_RELEASE(m_pDoc);
  2146.     HX_RELEASE(m_pSite);
  2147.     return HXR_OK;
  2148. }
  2149. /*
  2150.  * IUnknown methods
  2151.  */
  2152. STDMETHODIMP
  2153. CSmil1SiteWatcher::QueryInterface(REFIID riid, void** ppvObj)
  2154. {
  2155.     if(IsEqualIID(riid, IID_IUnknown))
  2156.     {
  2157. AddRef();
  2158. *ppvObj = this;
  2159. return HXR_OK;
  2160.     }
  2161.     else if(IsEqualIID(riid, IID_IHXSiteWatcher))
  2162.     {
  2163. AddRef();
  2164. *ppvObj = (IHXSiteWatcher*)this;
  2165. return HXR_OK;
  2166.     }
  2167.     *ppvObj = NULL;
  2168.     return HXR_NOINTERFACE;
  2169. }
  2170. STDMETHODIMP_(ULONG32)
  2171. CSmil1SiteWatcher::AddRef()
  2172. {
  2173.     return InterlockedIncrement(&m_lRefCount);
  2174. }
  2175. STDMETHODIMP_(ULONG32)
  2176. CSmil1SiteWatcher::Release()
  2177. {
  2178.     if(InterlockedDecrement(&m_lRefCount) > 0)
  2179.     {
  2180. return m_lRefCount;
  2181.     }
  2182.     delete this;
  2183.     return 0;
  2184. }
  2185. /*
  2186.  * IHXSiteWatcher methods
  2187.  */
  2188. STDMETHODIMP
  2189. CSmil1SiteWatcher::AttachSite(IHXSite* pSite)
  2190. {
  2191.     m_pSite = pSite;
  2192.     if(m_pSite)
  2193.     {
  2194. m_pSite->AddRef();
  2195.     }
  2196.     return HXR_OK;
  2197. }
  2198. STDMETHODIMP
  2199. CSmil1SiteWatcher::DetachSite()
  2200. {
  2201.     HX_RELEASE(m_pSite);
  2202.     return HXR_OK;
  2203. }
  2204. STDMETHODIMP
  2205. CSmil1SiteWatcher::ChangingPosition(HXxPoint oldPos, REF(HXxPoint) newPos)
  2206. {
  2207.     return HXR_OK;
  2208. }
  2209. STDMETHODIMP
  2210. CSmil1SiteWatcher::ChangingSize(HXxSize oldSize, REF(HXxSize) newSize)
  2211. {
  2212.     if(m_bChangingSize ||
  2213. (newSize.cx == 0 &&
  2214.  newSize.cy == 0))
  2215.     {
  2216. return HXR_OK; // don't change size
  2217.     }
  2218.     CSmil1BasicRegion* pRegion = m_pDoc->getRegion(m_id);
  2219.     if(pRegion)
  2220.     {
  2221. BOOL bResizeRegion = FALSE;
  2222. if(m_bIsChildSite)
  2223. {
  2224.     INT32 lRegionWidth = HXxRECT_WIDTH(pRegion->m_rect);
  2225.     INT32 lRegionHeight = HXxRECT_HEIGHT(pRegion->m_rect);
  2226.     double xScaleFactor = 1.; 
  2227.     double yScaleFactor = 1.; 
  2228.     if (m_pDoc->m_topSiteOriginalSize.cx)
  2229.     {
  2230. xScaleFactor = (double) m_pDoc->m_topSiteSize.cx/(double) m_pDoc->m_topSiteOriginalSize.cx;
  2231.     }
  2232.     if (m_pDoc->m_topSiteOriginalSize.cy)
  2233.     {
  2234. yScaleFactor = (double) m_pDoc->m_topSiteSize.cy/(double) m_pDoc->m_topSiteOriginalSize.cy;
  2235.     }
  2236.     if(m_bFirstSetSize)
  2237.     {
  2238.                 // Clear the flag
  2239.                 m_bFirstSetSize = FALSE;
  2240. pRegion->m_originalMediaSize.cx = newSize.cx;
  2241. pRegion->m_originalMediaSize.cy = newSize.cy;
  2242. if(pRegion->m_rect.right == pRegion->m_rect.left  &&
  2243. //[SMIL 1.0 Compliance] Helps fix PR 16542;
  2244. // only do the following if width="0" or "0%"
  2245. // was not explicitly requested.  The fix for
  2246. // PR 16542 is to treat unspecified dimension values
  2247. // as such and not treat them as 0 (which is a valid
  2248. // value and should not be treated as an unspecified
  2249. // value).
  2250. pRegion->m_bWidthUnspecified)
  2251. {
  2252.     //[SMIL 1.0 compliance] Fixes PR 26038 (horizontal part
  2253.     // of the bug): don't reset the right value to the width
  2254.     // when the right value may include an offset as well.
  2255.     // Set the right value to the new width **plus the left
  2256.     // value**, i.e., no longer assume the left is zero:
  2257.     pRegion->m_rect.right =
  2258.     pRegion->m_rect.left + newSize.cx;
  2259.     pRegion->m_originalRect.right =
  2260.     pRegion->m_rect.left + newSize.cx;
  2261.     lRegionWidth = newSize.cx;
  2262.     //[SMIL 1.0 compliance] more of PR 26038 fix: make sure
  2263.     // to account for left offset in overall layout as well
  2264.     // since the width of the layout includes the offset since
  2265.     // it is a bounding box of all regions:
  2266.     if(m_pDoc->m_ulNoRootLayoutWidth <
  2267.     (UINT32)(pRegion->m_rect.right) )
  2268.     {
  2269. //Only include this region if it is visible:
  2270. if (pRegion->m_rect.right > 0L)
  2271. {
  2272.     m_pDoc->m_ulNoRootLayoutWidth =
  2273.     pRegion->m_rect.right;
  2274. }
  2275.     }
  2276.     //[SMIL 1.0 compliance] Fixes PR 27184:
  2277.     // Always resize region if no size was explicitly
  2278.     // specified for it (not just when the above if () is
  2279.     // entered) otherwise it won't show up:
  2280.     bResizeRegion = TRUE;
  2281. }
  2282. if(pRegion->m_rect.bottom == pRegion->m_rect.top  &&
  2283. //[SMIL 1.0 Compliance] Helps fix PR 16542;
  2284. // only do the following if height="0" or "0%"
  2285. // was not explicitly requested.  The fix for
  2286. // PR 16542 is to treat unspecified dimension values
  2287. // as such and not treat them as 0 (which is a valid
  2288. // value and should not be treated as an unspecified
  2289. // value).
  2290. pRegion->m_bHeightUnspecified)
  2291. {
  2292.     //[SMIL 1.0 compliance] Fixes PR 26038 (vertical part
  2293.     // of the bug): don't reset the bottom value to the
  2294.     // height when the bottom value may include an offset as
  2295.     // well.  Set the bottom value to the new height **plus
  2296.     // the top value**, i.e., no longer assume the top is
  2297.     // zero:
  2298.     pRegion->m_rect.bottom =
  2299.     pRegion->m_rect.top + newSize.cy;
  2300.     pRegion->m_originalRect.bottom =
  2301.     pRegion->m_rect.top + newSize.cy;
  2302.     lRegionHeight = newSize.cy;
  2303.     //[SMIL 1.0 compliance] more of PR 26038 fix: make sure
  2304.     // to account for left offset in overall layout as well
  2305.     // since the width of the layout includes the offset since
  2306.     // it is a bounding box of all regions:
  2307.     if(m_pDoc->m_ulNoRootLayoutHeight <
  2308.     (UINT32)(pRegion->m_rect.bottom) )
  2309.     {
  2310. //Only include this region if it is visible:
  2311. if (pRegion->m_rect.bottom > 0L)
  2312. {
  2313.     m_pDoc->m_ulNoRootLayoutHeight =
  2314.     pRegion->m_rect.bottom;
  2315. }
  2316.     }
  2317.     //[SMIL 1.0 compliance] Fixes PR 27184:
  2318.     // Always resize region if no size was explicitly
  2319.     // specified for it (not just when the above if () is
  2320.     // entered) otherwise it won't show up:
  2321.     bResizeRegion = TRUE;
  2322. }
  2323. pRegion->m_bMediaSizeSet = TRUE;
  2324.     }
  2325.     // check for fit, rescale if necessary
  2326.     if(pRegion->m_fit == "fill")
  2327.     {
  2328. newSize.cx = lRegionWidth;
  2329. newSize.cy = lRegionHeight;
  2330.     }
  2331.     else if(pRegion->m_fit == "meet")
  2332.     {
  2333. // preserve aspect ratio, don't clip
  2334. double dAspectRatio = 0.0;
  2335. if(pRegion->m_originalMediaSize.cy)
  2336. {
  2337.     dAspectRatio = (double)pRegion->m_originalMediaSize.cx /
  2338.     (double)pRegion->m_originalMediaSize.cy;
  2339. }
  2340. // first try to meet region width
  2341. if(dAspectRatio > 0.0)
  2342. {
  2343.     INT32 lTryHeight = (INT32)((double)lRegionWidth / dAspectRatio + 0.5);
  2344.     if(lTryHeight > lRegionHeight)
  2345.     {
  2346. newSize.cx = (INT32)((double)lRegionHeight * dAspectRatio + 0.5);
  2347. newSize.cy = lRegionHeight;
  2348.     }
  2349.     else
  2350.     {
  2351. newSize.cx = lRegionWidth;
  2352. newSize.cy = lTryHeight;
  2353.     }
  2354. }
  2355.     }
  2356.     else if(pRegion->m_fit == "slice")
  2357.     {
  2358. // preserve aspect ratio, OK to clip
  2359. double dAspectRatio = 0.0;
  2360. double dRegionAspectRatio = 0.0;
  2361. if(pRegion->m_originalMediaSize.cy && 
  2362.     pRegion->m_originalMediaSize.cx &&
  2363.     lRegionHeight)
  2364. {
  2365.     dAspectRatio = (double)pRegion->m_originalMediaSize.cx /
  2366.     (double)pRegion->m_originalMediaSize.cy;
  2367.     dRegionAspectRatio = (double)lRegionWidth/(double)lRegionHeight;
  2368. }
  2369. // fit to greater of region height or width
  2370. if(dAspectRatio > 0.0)
  2371. {
  2372.     if(dRegionAspectRatio > dAspectRatio)
  2373.     {
  2374. // the region has a greater aspect ratio than the 
  2375. // media.  Therefore we want to scale the media's
  2376. // height, and set its width = the region's width...
  2377. newSize.cx = lRegionWidth;
  2378. // /First half of Fix for PR 35268: we want to scale
  2379. // the media's height based on the region's width,
  2380. // not on its height:
  2381. newSize.cy = (INT32)((double)lRegionWidth /
  2382.     dAspectRatio + 0.5);
  2383.     }
  2384.     else
  2385.     {
  2386. // set the height = regionHeight && scale the width
  2387. newSize.cy = lRegionHeight;
  2388. // /Other half of Fix for PR 35268: we want to scale
  2389. // the media's width based on the region's height,
  2390. // not on its width:
  2391. newSize.cx = (INT32)((double)lRegionHeight *
  2392.     dAspectRatio + 0.5);
  2393.     }
  2394. }
  2395.     }
  2396.     else if(pRegion->m_fit == "scroll")
  2397.     {
  2398. // keep intrinsic size, draw scroll bars (some day!)
  2399. newSize.cx = (INT32)((double)pRegion->m_originalMediaSize.cx *
  2400.     xScaleFactor + 0.5);
  2401. newSize.cy = (INT32)((double)pRegion->m_originalMediaSize.cy *
  2402.     yScaleFactor + 0.5);
  2403.   IHXValues* pValues = NULL;
  2404.   if ( m_pSite->QueryInterface( IID_IHXValues, (void**) &pValues ) == HXR_OK )
  2405.   {
  2406.       pValues->SetPropertyULONG32("ScrollingSite", 1);
  2407.   }
  2408.     }
  2409.     else if(pRegion->m_fit == "hidden")
  2410.     {
  2411. // keep intrinsic size
  2412. newSize.cx = (INT32)((double)pRegion->m_originalMediaSize.cx *
  2413.     xScaleFactor + 0.5);
  2414. newSize.cy = (INT32)((double)pRegion->m_originalMediaSize.cy *
  2415.     yScaleFactor + 0.5);
  2416.     }
  2417.     pRegion->m_mediaSize.cx = newSize.cx;
  2418.     pRegion->m_mediaSize.cy = newSize.cy;
  2419. }
  2420. else if(!m_pDoc->m_bSiteChangingSize)
  2421. {
  2422.     newSize.cx = HXxRECT_WIDTH(pRegion->m_rect);
  2423.     newSize.cy = HXxRECT_HEIGHT(pRegion->m_rect);
  2424. }
  2425. if(bResizeRegion)
  2426. {
  2427.     HXxSize size;
  2428.     size.cx = HXxRECT_WIDTH(pRegion->m_rect);
  2429.     size.cy = HXxRECT_HEIGHT(pRegion->m_rect);
  2430.     pRegion->m_pSite->SetSize(size);
  2431.             if (!m_pDoc->isRootLayoutWidthSet() ||
  2432.                 !m_pDoc->isRootLayoutHeightSet())
  2433.             {
  2434.                 m_pDoc->setTopLevelSiteSize();
  2435.             }
  2436. }
  2437.     }
  2438. //    char szDbgStr[128];
  2439. //    DEBUGPRINTF(szDbgStr, "tmedia in region %s: ChangingSize((%ld,%ld),(%ld,%ld))n",
  2440. //                (const char*) m_id,
  2441. //                oldSize.cx, oldSize.cy, newSize.cx, newSize.cy);
  2442.     return HXR_OK;
  2443. }
  2444. /*
  2445.  * CSmil1EventHook methods
  2446.  */
  2447. CSmil1EventHook::CSmil1EventHook(CSmil1DocumentRenderer* pDoc,
  2448.        const char* pRegionName,
  2449.        const char* pChannelName,
  2450.        BOOL bNoRegion):
  2451.     m_lRefCount(0),
  2452.     m_pDoc(pDoc),
  2453.     m_pRegionName(NULL),
  2454.     m_pChannelName(NULL),
  2455.     m_bNoRegion(bNoRegion),
  2456.     m_pSite(NULL),
  2457.     m_pSiteWatcher(NULL)
  2458. {
  2459. #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
  2460.     char szDbgStr[128]; /* Flawfinder: ignore */
  2461.     sprintf(szDbgStr, "CON CSmil1EventHook 0x%08xn", this); /* Flawfinder: ignore */
  2462.     OutputDebugString(szDbgStr);
  2463. #endif
  2464.     HX_ASSERT(m_pDoc);
  2465.     HX_ASSERT(pRegionName);
  2466.     HX_ASSERT(pChannelName);
  2467.     m_pDoc->AddRef();
  2468.     m_pRegionName = new_string(pRegionName);
  2469.     m_pChannelName = new_string(pChannelName);
  2470. }
  2471. CSmil1EventHook::~CSmil1EventHook()
  2472. {
  2473. #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
  2474.     char szDbgStr[128]; /* Flawfinder: ignore */
  2475.     sprintf(szDbgStr, "DES CSmil1EventHook 0x%08xn", this); /* Flawfinder: ignore */
  2476.     OutputDebugString(szDbgStr);
  2477. #endif
  2478.     m_pDoc->Release();
  2479.     delete[] m_pRegionName;
  2480.     delete[] m_pChannelName;
  2481. }
  2482. /*
  2483.  * IUnknown methods
  2484.  */
  2485. STDMETHODIMP
  2486. CSmil1EventHook::QueryInterface(REFIID riid, void** ppvObj)
  2487. {
  2488.     if(IsEqualIID(riid, IID_IUnknown))
  2489.     {
  2490. AddRef();
  2491. *ppvObj = this;
  2492. return HXR_OK;
  2493.     }
  2494.     else if(IsEqualIID(riid, IID_IHXEventHook))
  2495.     {
  2496. AddRef();
  2497. *ppvObj = (IHXEventHook*)this;
  2498. return HXR_OK;
  2499.     }
  2500.     *ppvObj = NULL;
  2501.     return HXR_NOINTERFACE;
  2502. }
  2503. STDMETHODIMP_(ULONG32)
  2504. CSmil1EventHook::AddRef()
  2505. {
  2506.     return InterlockedIncrement(&m_lRefCount);
  2507. }
  2508. STDMETHODIMP_(ULONG32)
  2509. CSmil1EventHook::Release()
  2510. {
  2511.     if(InterlockedDecrement(&m_lRefCount) > 0)
  2512.     {
  2513. return m_lRefCount;
  2514.     }
  2515.     delete this;
  2516.     return 0;
  2517. }
  2518. STDMETHODIMP
  2519. CSmil1EventHook::HandleEvent(IHXSite* pSite, HXxEvent* pEvent)
  2520. {
  2521.     HX_RESULT rc = HXR_OK;
  2522.     if(m_pSite == pSite)
  2523.     {
  2524. switch(pEvent->event)
  2525. {
  2526.     case HX_MOUSE_MOVE:
  2527.     case HX_MOUSE_ENTER:
  2528.     case HX_MOUSE_LEAVE:
  2529.     {
  2530. HXxPoint* mousePt = (HXxPoint*) pEvent->param1;
  2531. if(HXR_OK == m_pDoc->handleMouseMove(
  2532.     pEvent->window,
  2533.     m_pRegionName,
  2534.     (INT16)mousePt->x,
  2535.     (INT16)mousePt->y))
  2536. {
  2537.     pEvent->handled = TRUE;
  2538. }
  2539.     }
  2540.     break;
  2541.     case HX_PRIMARY_BUTTON_UP:
  2542.     {
  2543. HXxPoint* mousePt = (HXxPoint*) pEvent->param1;
  2544. if(HXR_OK == m_pDoc->handleLButtonUp(
  2545. m_pRegionName,
  2546. (INT16)mousePt->x,
  2547. (INT16)mousePt->y))
  2548. {
  2549.     pEvent->handled = TRUE;
  2550. }
  2551.     }
  2552.     break;
  2553. #ifdef _WINDOWS
  2554.     case WM_SETCURSOR:
  2555.     {
  2556. pEvent->handled = m_pDoc->handleSetCursor();
  2557.     }
  2558.     break;
  2559. #endif  
  2560.     default:
  2561. break;
  2562. }
  2563.     }
  2564.     return rc;
  2565. }
  2566. STDMETHODIMP
  2567. CSmil1EventHook::SiteAdded(IHXSite* pSite)
  2568. {
  2569.     HX_RESULT rc = HXR_OK;
  2570.     HX_ASSERT(pSite);
  2571.     m_pSite = pSite;
  2572.     m_pSite->AddRef();
  2573.     // add a passive site watcher to get
  2574.     // size and position updates
  2575.     m_pSiteWatcher =
  2576. new CSmil1PassiveSiteWatcher(m_pDoc, m_pRegionName);
  2577.     m_pSiteWatcher->AddRef();
  2578.     
  2579.     IHXSite2* pSite2 = NULL;
  2580.     if(HXR_OK == m_pSite->QueryInterface(IID_IHXSite2, (void**)&pSite2))
  2581.     {
  2582. pSite2->AddPassiveSiteWatcher(m_pSiteWatcher);
  2583. pSite2->Release();
  2584.     }
  2585.     if(m_bNoRegion)
  2586.     {
  2587. m_pDoc->addShowEvents(m_pRegionName, m_pSite);
  2588.     }
  2589.     return rc;
  2590. }
  2591. STDMETHODIMP
  2592. CSmil1EventHook::SiteRemoved(IHXSite* pSite)
  2593. {
  2594.     HX_RESULT rc = HXR_OK;
  2595.     HX_ASSERT(m_pSite == pSite);
  2596.     IHXSite2* pSite2 = NULL;
  2597.     if(m_pSite &&
  2598. HXR_OK == m_pSite->QueryInterface(IID_IHXSite2, (void**)&pSite2))
  2599.     {
  2600. pSite2->RemovePassiveSiteWatcher(m_pSiteWatcher);
  2601. pSite2->Release();
  2602.     }
  2603.     HX_RELEASE(m_pSite);
  2604.     HX_RELEASE(m_pSiteWatcher);
  2605.     return rc;
  2606. }
  2607. /*
  2608.  * CSmil1PassiveSiteWatcher methods
  2609.  */
  2610. CSmil1PassiveSiteWatcher::CSmil1PassiveSiteWatcher(CSmil1DocumentRenderer* pDoc,
  2611.  const char* pRegionName):
  2612.     m_lRefCount(0),
  2613.     m_pDoc(pDoc),
  2614.     m_pRegionName(NULL)
  2615. {
  2616. #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
  2617.     char szDbgStr[128]; /* Flawfinder: ignore */
  2618.     sprintf(szDbgStr, "CON CSmil1EventHook 0x%08xn", this); /* Flawfinder: ignore */
  2619.     OutputDebugString(szDbgStr);
  2620. #endif
  2621.     HX_ASSERT(m_pDoc);
  2622.     HX_ASSERT(pRegionName);
  2623.     m_pDoc->AddRef();
  2624.     m_pRegionName = new_string(pRegionName); 
  2625. }
  2626. CSmil1PassiveSiteWatcher::~CSmil1PassiveSiteWatcher()
  2627. {
  2628. #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
  2629.     char szDbgStr[128]; /* Flawfinder: ignore */
  2630.     sprintf(szDbgStr, "DES CSmil1EventHook 0x%08xn", this); /* Flawfinder: ignore */
  2631.     OutputDebugString(szDbgStr);
  2632. #endif
  2633.     HX_RELEASE(m_pDoc);
  2634.     delete[] m_pRegionName;
  2635. }
  2636. /*
  2637.  * IUnknown methods
  2638.  */
  2639. STDMETHODIMP
  2640. CSmil1PassiveSiteWatcher::QueryInterface(REFIID riid, void** ppvObj)
  2641. {
  2642.     if(IsEqualIID(riid, IID_IUnknown))
  2643.     {
  2644. AddRef();
  2645. *ppvObj = this;
  2646. return HXR_OK;
  2647.     }
  2648.     else if(IsEqualIID(riid, IID_IHXPassiveSiteWatcher))
  2649.     {
  2650. AddRef();
  2651. *ppvObj = (IHXSiteWatcher*)this;
  2652. return HXR_OK;
  2653.     }
  2654.     *ppvObj = NULL;
  2655.     return HXR_NOINTERFACE;
  2656. }
  2657. STDMETHODIMP_(ULONG32)
  2658. CSmil1PassiveSiteWatcher::AddRef()
  2659. {
  2660.     return InterlockedIncrement(&m_lRefCount);
  2661. }
  2662. STDMETHODIMP_(ULONG32)
  2663. CSmil1PassiveSiteWatcher::Release()
  2664. {
  2665.     if(InterlockedDecrement(&m_lRefCount) > 0)
  2666.     {
  2667. return m_lRefCount;
  2668.     }
  2669.     delete this;
  2670.     return 0;
  2671. }
  2672. STDMETHODIMP
  2673. CSmil1PassiveSiteWatcher::PositionChanged(HXxPoint* pPoint)
  2674. {
  2675.     // The passive watcher is only attached to renderer
  2676.     // sites, therefore we really don't want to resize
  2677.     // the region, the regions are scaled and sized 
  2678.     // already.
  2679.     //m_pDoc->repositionRegion(m_pRegionName, pPoint);
  2680.     return HXR_OK;
  2681. }
  2682. STDMETHODIMP
  2683. CSmil1PassiveSiteWatcher::SizeChanged(HXxSize* pSize)
  2684. {
  2685.     // The passive watcher is only attached to renderer
  2686.     // sites, therefore we really don't want to resize
  2687.     // the region, the regions are scaled and sized 
  2688.     // already.
  2689.     //m_pDoc->resizeRegion(m_pRegionName, pSize);
  2690.     return HXR_OK;
  2691. }
  2692. /*
  2693.  * CSmil1SiteUser methods
  2694.  */
  2695. CSmil1SiteUser::CSmil1SiteUser(CSmil1DocumentRenderer* pDoc,
  2696.      HXxColor ulBGColor):
  2697.     m_lRefCount(0),
  2698.     m_pDoc(pDoc),
  2699.     m_ulBGColor(ulBGColor),
  2700.     m_pSite(NULL)
  2701. {
  2702. #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
  2703.     char szDbgStr[128]; /* Flawfinder: ignore */
  2704.     sprintf(szDbgStr, "CON CSmil1SiteUser 0x%08xn", this); /* Flawfinder: ignore */
  2705.     OutputDebugString(szDbgStr);
  2706. #endif
  2707.     HX_ASSERT(m_pDoc);
  2708.     m_pDoc->AddRef();
  2709. }
  2710. CSmil1SiteUser::~CSmil1SiteUser()
  2711. {
  2712. #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
  2713.     char szDbgStr[128]; /* Flawfinder: ignore */
  2714.     sprintf(szDbgStr, "DES CSmil1SiteUser 0x%08xn", this); /* Flawfinder: ignore */
  2715.     OutputDebugString(szDbgStr);
  2716. #endif
  2717.     HX_RELEASE(m_pSite);
  2718.     HX_RELEASE(m_pDoc);
  2719. }
  2720. /*
  2721.  * IUnknown methods
  2722.  */
  2723. STDMETHODIMP
  2724. CSmil1SiteUser::QueryInterface(REFIID riid, void** ppvObj)
  2725. {
  2726.     if(IsEqualIID(riid, IID_IUnknown))
  2727.     {
  2728. AddRef();
  2729. *ppvObj = this;
  2730. return HXR_OK;
  2731.     }
  2732.     else if(IsEqualIID(riid, IID_IHXSiteUser))
  2733.     {
  2734. AddRef();
  2735. *ppvObj = (IHXSiteUser*)this;
  2736. return HXR_OK;
  2737.     }
  2738.     *ppvObj = NULL;
  2739.     return HXR_NOINTERFACE;
  2740. }
  2741. STDMETHODIMP_(ULONG32)
  2742. CSmil1SiteUser::AddRef()
  2743. {
  2744.     return InterlockedIncrement(&m_lRefCount);
  2745. }
  2746. STDMETHODIMP_(ULONG32)
  2747. CSmil1SiteUser::Release()
  2748. {
  2749.     if(InterlockedDecrement(&m_lRefCount) > 0)
  2750.     {
  2751. return m_lRefCount;
  2752.     }
  2753.     delete this;
  2754.     return 0;
  2755. }
  2756. /*
  2757.  * IHXSiteUser methods
  2758.  */
  2759. STDMETHODIMP
  2760. CSmil1SiteUser::AttachSite(IHXSite* /*IN*/ pSite)
  2761. {
  2762.     HX_RESULT rc = HXR_OK;
  2763.     if (m_pSite)
  2764.     {
  2765. return rc;
  2766.     }
  2767.     m_pSite = pSite;
  2768.     m_pSite->AddRef();
  2769.     return rc;
  2770. }
  2771. STDMETHODIMP
  2772. CSmil1SiteUser::DetachSite()
  2773. {
  2774.     HX_RELEASE(m_pSite);
  2775.     return HXR_OK;
  2776. }
  2777. STDMETHODIMP_(BOOL)
  2778. CSmil1SiteUser::NeedsWindowedSites()
  2779. {
  2780.     return FALSE;
  2781. }
  2782. STDMETHODIMP
  2783. CSmil1SiteUser::HandleEvent(HXxEvent* /*IN*/ pEvent)
  2784. {
  2785.     HX_RESULT rc = HXR_OK;
  2786.     pEvent->handled = FALSE;
  2787.     pEvent->result  = 0;
  2788.     switch (pEvent->event)
  2789.     {
  2790. case HX_SURFACE_UPDATE:
  2791. {
  2792.     if(HXR_OK ==
  2793. m_pDoc->HandleSurfaceUpdate(pEvent, m_pSite, m_ulBGColor))
  2794.     {
  2795. pEvent->handled = TRUE;
  2796.     }
  2797. }
  2798. break;
  2799.     }
  2800.     return HXR_OK;
  2801. }
  2802. /*
  2803.  * CSmil1BasicRegion methods
  2804.  */
  2805. CSmil1BasicRegion::CSmil1BasicRegion(const char* pName,
  2806.     HXxRect rect, INT32 lZIndex, const char* pFit,
  2807.     HXxColor ulBgColor, BOOL bBgColorSet, BOOL bImplicitRegion,
  2808.     //[SMIL 1.0 Compliance] Helps fix PR 16542:
  2809.     BOOL bWidthUnspecified, BOOL bHeightUnspecified):
  2810.     m_region(pName),
  2811.     m_rect(rect),
  2812.     m_originalRect(rect),
  2813.     m_pSite(NULL),
  2814.     m_pSiteUser(NULL),
  2815.     m_lZIndex(lZIndex),
  2816.     m_fit(pFit),
  2817.     m_ulBgColor(ulBgColor),
  2818.     m_bBgColorSet(bBgColorSet),
  2819.     m_bMediaSizeSet(FALSE),
  2820.     m_bImplicitRegion(bImplicitRegion)
  2821.     //[SMIL 1.0 Compliance] These helps fix PR 16542:
  2822.     , m_bWidthUnspecified(bWidthUnspecified)
  2823.     , m_bHeightUnspecified(bHeightUnspecified)
  2824. {
  2825. #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
  2826.     char szDbgStr[128]; /* Flawfinder: ignore */
  2827.     sprintf(szDbgStr, "CON CSmil1BasicRegion 0x%08xn", this); /* Flawfinder: ignore */
  2828.     OutputDebugString(szDbgStr);
  2829. #endif
  2830. }
  2831. CSmil1BasicRegion::~CSmil1BasicRegion()
  2832. {
  2833. #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
  2834.     char szDbgStr[128]; /* Flawfinder: ignore */
  2835.     sprintf(szDbgStr, "DES CSmil1BasicRegion 0x%08xn", this); /* Flawfinder: ignore */
  2836.     OutputDebugString(szDbgStr);
  2837. #endif
  2838.     if(m_pSite)
  2839.     {
  2840. m_pSite->DetachUser();
  2841.     }
  2842.     HX_RELEASE(m_pSiteUser);
  2843.     HX_RELEASE(m_pSite);
  2844. }
  2845. // ProcessElementCallback
  2846. ProcessElementCallback::ProcessElementCallback() :
  2847.      m_lRefCount(0)
  2848.     ,m_pOwner(0)
  2849.     ,m_PendingHandle(0)
  2850.     ,m_bIsCallbackPending(FALSE)
  2851. {
  2852. }
  2853. ProcessElementCallback::~ProcessElementCallback()
  2854. {
  2855. }
  2856. /*
  2857.  * IUnknown methods
  2858.  */
  2859. /////////////////////////////////////////////////////////////////////////
  2860. //      Method:
  2861. //              IUnknown::QueryInterface
  2862. //      Purpose:
  2863. //              Implement this to export the interfaces supported by your
  2864. //              object.
  2865. //
  2866. STDMETHODIMP ProcessElementCallback::QueryInterface(REFIID riid, void** ppvObj)
  2867. {
  2868.     if (IsEqualIID(riid, IID_IHXCallback))
  2869.     {
  2870. AddRef();
  2871. *ppvObj = (IHXCallback*)this;
  2872. return HXR_OK;
  2873.     }
  2874.     else if (IsEqualIID(riid, IID_IUnknown))
  2875.     {
  2876. AddRef();
  2877. *ppvObj = this;
  2878. return HXR_OK;
  2879.     }
  2880.     *ppvObj = NULL;
  2881.     return HXR_NOINTERFACE;
  2882. }
  2883. /////////////////////////////////////////////////////////////////////////
  2884. //      Method:
  2885. //              IUnknown::AddRef
  2886. //      Purpose:
  2887. //              Everyone usually implements this the same... feel free to use
  2888. //              this implementation.
  2889. //
  2890. STDMETHODIMP_(ULONG32) ProcessElementCallback::AddRef()
  2891. {
  2892.     return InterlockedIncrement(&m_lRefCount);
  2893. }
  2894. /////////////////////////////////////////////////////////////////////////
  2895. //      Method:
  2896. //              IUnknown::Release
  2897. //      Purpose:
  2898. //              Everyone usually implements this the same... feel free to use
  2899. //              this implementation.
  2900. //
  2901. STDMETHODIMP_(ULONG32) ProcessElementCallback::Release()
  2902. {
  2903.     if (InterlockedDecrement(&m_lRefCount) > 0)
  2904.     {
  2905. return m_lRefCount;
  2906.     }
  2907.     delete this;
  2908.     return 0;
  2909. }
  2910. /*
  2911.  *      IHXCallback methods
  2912.  */
  2913. STDMETHODIMP ProcessElementCallback::Func(void)
  2914. {
  2915.     m_PendingHandle = 0;
  2916.     m_bIsCallbackPending = FALSE;
  2917.     if (m_pOwner && !m_elementID.IsEmpty())
  2918.     {
  2919. m_pOwner->seekTo(m_elementID);
  2920.     }
  2921.     m_elementID.Empty();
  2922.     return HXR_OK;
  2923. }