📄 smltime.cpp
字号:
m_ulEndsyncClockValue = ulEndsyncClockValue;
if(pEndsyncID)
{
m_pEndsyncID = new char[strlen(pEndsyncID)+1];
strcpy(m_pEndsyncID, pEndsyncID); /* Flawfinder: ignore */
}
}
#endif
/*
* CSmil1TimelineSeq methods
*/
CSmil1TimelineSeq::CSmil1TimelineSeq(CSmil1Element* pSourceElement,
CSmil1Parser* pParser):
CSmil1TimelineElement(pSourceElement, pParser),
m_nDurationAdded(0)
{
}
void
CSmil1TimelineSeq::addDuration(UINT32 ulDuration,
UINT32 ulDelay,
const char* pID)
{
ASSERT(m_pChildren);
if(!m_bDurationSet)
{
if(m_pSourceElement->m_ulDuration == (UINT32)-1)
{
m_pSourceElement->m_ulDuration = ulDuration;
}
else
{
m_pSourceElement->m_ulDuration += ulDuration;
}
}
m_nDurationAdded++;
if(m_nDurationAdded == m_pChildren->GetCount())
{
m_bDurationSet = TRUE;
if(m_pParent)
{
m_pParent->addDuration(
m_pSourceElement->m_ulDuration,
m_pSourceElement->m_ulDelay, m_pID);
}
if(m_pDependent)
{
//XXXEH- should "m_pSourceElement->m_ulDelay +" be removed, too?
// I can't get any content to hit this line so I'm not going to
// change it. See fix for PR SMIL/13983:
adjustDependentDuration(m_pDependent);
m_pDependent->setDelay(m_pSourceElement->m_ulDelay +
m_pSourceElement->m_ulDuration);
}
// /[SMIL 1.0 Compliance] Fixes PR 23779:
// if a source has event-based timing based on this seq's
// duration, then we need to notify that source that we've
// resolved this value:
if (m_pParser && m_pParser->m_pTimelineElementManager)
{
m_pParser->m_pTimelineElementManager->notify(m_pID);
}
}
}
void
CSmil1TimelineSeq::setDelay(UINT32 ulDelay)
{
if(m_pSourceElement->m_ulBeginOffset != (UINT32)-1)
{
m_pSourceElement->m_ulDelay = ulDelay +
m_pSourceElement->m_ulBeginOffset;
}
else
{
m_pSourceElement->m_ulDelay = ulDelay;
}
//XXXJHUG - we need to prevent overwriting the delay when
// setInitalDelay is called on THIS element, changing this
// bool causes initialDelaySet to return TRUE.
m_bDelaySet = TRUE;
if(m_pChildren && m_pChildren->GetCount() > 0)
{
// set delay on first child of seq
CSmil1TimelineElement* pElement =
(CSmil1TimelineElement*)m_pChildren->GetHead();
pElement->setDelay(m_pSourceElement->m_ulDelay);
}
if (m_pSourceElement->m_ulDuration != (UINT32)-1)
{
setDuration(m_pSourceElement->m_ulDuration);
}
//[SMIL 1.0 Compliance] Helps fix PR 14420 and 23025:
// if a source has event-based timing based on this seq's
// begin time (delay) then we need to notify that source
// that we've resolved this value:
if (m_pParser && m_pParser->m_pTimelineElementManager)
{
m_pParser->m_pTimelineElementManager->notify(m_pID);
}
}
void
CSmil1TimelineSeq::setDuration(UINT32 ulDuration, BOOL bSetFromParent)
{
ASSERT(m_pChildren);
if(!m_bDurationSet)
{
m_pSourceElement->m_ulDuration = ulDuration;
m_bDurationSet = TRUE;
}
UINT32 ulDurationLeft = m_pSourceElement->m_ulDuration;
RepeatTag repeatTag = RepeatUnknown;
CHXSimpleList::Iterator i = m_pChildren->Begin();
for(; i != m_pChildren->End(); ++i)
{
CSmil1TimelineElement* pElement = (CSmil1TimelineElement*)(*i);
if (!setElementDuration(ulDurationLeft, pElement))
{
break;
}
}
if(m_pDependent)
{
adjustDependentDuration(m_pDependent);
m_pDependent->setDelay(m_pSourceElement->m_ulDelay + m_pSourceElement->m_ulDuration);
}
//[SMIL 1.0 comliance] Helps fix PR 14420 and 23025:
if (m_pParser && m_pParser->m_pTimelineElementManager)
{
m_pParser->m_pTimelineElementManager->notify(m_pID);
}
}
void
CSmil1TimelineSeq::setMaxDuration(UINT32 ulMaxDuration)
{
HX_ASSERT(m_pChildren);
m_bMaxDurationSet = TRUE;
m_pSourceElement->m_ulMaxDuration = ulMaxDuration;
if (m_pChildren)
{
CSmil1TimelineElement* pElement = (CSmil1TimelineElement*)m_pChildren->GetHead();
pElement->setMaxDuration(ulMaxDuration);
}
}
void
CSmil1TimelineSeq::adjustDependentDuration(CSmil1TimelineElement* pDependent)
{
if(m_bDurationSet || m_bMaxDurationSet)
{
UINT32 ulDurationLeft = m_bDurationSet?m_pSourceElement->m_ulDuration:
m_pSourceElement->m_ulMaxDuration;
BOOL bAdjusted = FALSE;
RepeatTag repeatTag = RepeatUnknown;
CHXSimpleList::Iterator i = m_pChildren->Begin();
for(; i != m_pChildren->End(); ++i)
{
CSmil1TimelineElement* pElement = (CSmil1TimelineElement*)(*i);
UINT32 ulChildDuration = pElement->getDuration();
if (pElement == pDependent)
{
bAdjusted = TRUE;
}
if (bAdjusted)
{
if (!setElementDuration(ulDurationLeft, pElement))
{
break;
}
}
else
{
if(ulDurationLeft >= ulChildDuration)
{
ulDurationLeft -= ulChildDuration;
}
else
{
ulDurationLeft = 0;
}
}
}
if (!bAdjusted && m_pParent)
{
m_pParent->adjustDependentDuration(pDependent);
}
}
}
BOOL
CSmil1TimelineSeq::setElementDuration(UINT32& ulDurationLeft, CSmil1TimelineElement* pElement)
{
BOOL bContinue = TRUE;
UINT32 ulChildDuration = pElement->getDuration();
RepeatTag repeatTag = pElement->m_pSourceElement->m_pNode->m_repeatTag;
if (repeatTag == RepeatIndefiniteOnMe)
{
pElement->setMaxDuration(ulDurationLeft);
ulDurationLeft = 0;
goto cleanup;
}
else if (repeatTag == RepeatIndefiniteOnGroup)
{
pElement->setMaxDuration(ulDurationLeft);
bContinue = FALSE;
goto cleanup;
}
// no more duration left, take care of the duration of the rest of
// the elements
if (0 == ulDurationLeft)
{
pElement->setDuration(ulDurationLeft, TRUE);
}
// if this is the last child, then enforce the duration whatever
// left
else if (pElement == m_pChildren->GetTail())
{
pElement->setDuration(ulDurationLeft, TRUE);
bContinue = FALSE;
}
// unknown duration, so we apply max. duration here
else if (ulChildDuration == (UINT32)-1)
{
pElement->setMaxDuration(ulDurationLeft);
bContinue = FALSE;
}
else
{
if(ulDurationLeft >= ulChildDuration)
{
ulDurationLeft -= ulChildDuration;
}
else
{
pElement->setDuration(ulDurationLeft, TRUE);
ulDurationLeft = 0;
}
}
cleanup:
return bContinue;
}
/*
* CSmil1TimelineAnchor methods
*/
CSmil1TimelineAnchor::CSmil1TimelineAnchor(CSmil1Element* pSourceElement,
CSmil1Parser* pParser):
CSmil1TimelineElement(pSourceElement, pParser)
, m_nDurationAdded(0)
{
}
CSmil1TimelineAnchor::~CSmil1TimelineAnchor()
{
}
void
CSmil1TimelineAnchor::elementResolved(CSmil1TimelineElement* pEventElement)
{
//XXXEH: shouldn't we be making sure the pEventElement's id
// matches the m_[XXX]EventSourceID? Otherwise, a begin event on one id
// and an end event on another may cause problems...
//First, let's see if we have a begin event to resolve:
if(m_pSourceElement->m_nBeginEventSourceTag == SMILEventSourceBegin)
{
if(pEventElement->m_bDelaySet)
{
//[SMIL 1.0 Compliance] Helps fix 14420:
if (m_bNonEventDelaySet)
{
//Add non-event delay to begin event delay:
m_pSourceElement->m_ulDelay +=
pEventElement->m_pSourceElement->m_ulDelay;
}
else
{
//Just set delay to event delay:
m_pSourceElement->m_ulDelay =
pEventElement->m_pSourceElement->m_ulDelay;
}
m_bNonEventDelaySet = m_bDelaySet = TRUE;
if(m_pChildren)
{
CHXSimpleList::Iterator i = m_pChildren->Begin();
for(; i != m_pChildren->End(); ++i)
{
CSmil1TimelineElement* pElement =
(CSmil1TimelineElement*)(*i);
pElement->setDelay(m_pSourceElement->m_ulDelay);
}
}
}
}
else if(m_pSourceElement->m_nBeginEventSourceTag == SMILEventSourceEnd)
{
if(pEventElement->m_bDurationSet)
{
//[SMIL 1.0 Compliance] Helps fix 14420:
if (m_bNonEventDelaySet)
{
//Add non-event delay to begin event delay:
m_pSourceElement->m_ulDelay +=
pEventElement->m_pSourceElement->m_ulDuration +
pEventElement->m_pSourceElement->m_ulDelay;
}
else
{
//Just set delay to event delay:
m_pSourceElement->m_ulDelay =
pEventElement->m_pSourceElement->m_ulDuration +
pEventElement->m_pSourceElement->m_ulDelay;
}
m_bNonEventDelaySet = m_bDelaySet = TRUE;
if(m_pChildren)
{
CHXSimpleList::Iterator i = m_pChildren->Begin();
for(; i != m_pChildren->End(); ++i)
{
CSmil1TimelineElement* pElement =
(CSmil1TimelineElement*)(*i);
pElement->setDelay(m_pSourceElement->m_ulDelay);
}
}
}
}
else if(m_pSourceElement->m_nBeginEventSourceTag == SMILEventSourceClock)
{
//We want event *BEGIN* plus clock therefor check for m_bDelaySet not
// m_bDurationSet; after all, it's the eventElement's m_ulDelay
// that's used, below:
if(pEventElement->m_bDelaySet)
{
if (m_bNonEventDelaySet)
{
//Add non-event delay to begin event delay + clock val:
m_pSourceElement->m_ulDelay +=
pEventElement->m_pSourceElement->m_ulDelay +
m_pSourceElement->m_ulBeginEventClockValue;
}
else
{
//Just set delay to event delay:
m_pSourceElement->m_ulDelay =
pEventElement->m_pSourceElement->m_ulDelay +
m_pSourceElement->m_ulBeginEventClockValue;
}
m_bNonEventDelaySet = m_bDelaySet = TRUE;
if(m_pChildren)
{
CHXSimpleList::Iterator i = m_pChildren->Begin();
for(; i != m_pChildren->End(); ++i)
{
CSmil1TimelineElement* pElement =
(CSmil1TimelineElement*)(*i);
pElement->setDelay(m_pSourceElement->m_ulDelay);
}
}
}
}
//XXXEH: shouldn't we be making sure the pEventElement's id
// matches the m_[XXX]EventSourceID, otherwise a begin event on one id
// and an end event on another will cause problems.
#if defined(XXXEH_UNTESTED_AND_NOT_EXAMINED_WELL)
if(m_pSourceElement->m_nEndEventSourceTag == SMILEventSourceBegin)
{
if(pEventElement->m_bDelaySet)
{
durationResolved(pEventElement->m_pSourceElement->m_ulDelay);
}
}
else if(m_pSourceElement->m_nEndEventSourceTag == SMILEventSourceEnd)
{
if(pEventElement->m_bDurationSet)
{
durationResolved(pEventElement->getDuration());
}
}
else if(m_pSourceElement->m_nEndEventSourceTag == SMILEventSourceClock)
{
if(pEventElement->m_bDelaySet)
{
durationResolved(pEventElement->m_pSourceElement->m_ulDelay +
m_pSourceElement->m_ulEndEventClockValue);
}
}
#endif // defined(XXXEH_UNTESTED_AND_NOT_EXAMINED_WELL).
}
void
CSmil1TimelineAnchor::durationResolved(UINT32 ulDuration)
{
if(!m_bDurationSet)
{
m_bDurationSet = TRUE;
m_pSourceElement->m_ulDuration = ulDuration;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -