📄 smltime.cpp
字号:
m_pParser->insertTimelineElement(m_pID,
m_pSourceElement->m_ulDelay);
}
}
//[SMIL 1.0 compliance] Fixes PR 16629; we need to set our duration
// to the event element's end time plus the clock offset:
else if(m_pSourceElement->m_nEndEventSourceTag == SMILEventSourceClock)
{
if(pEventElement->m_bDelaySet)
{
m_bDurationSet = TRUE;
m_pSourceElement->m_ulDuration =
pEventElement->m_pSourceElement->m_ulDelay +
m_pSourceElement->m_ulEndEventClockValue;
m_pParser->insertTimelineElement(m_pID,
m_pSourceElement->m_ulDelay);
}
}
}
#if 0
void
CSmil1TimelineElement::setEvent(SMILEventSourceTag eTag,
SMILSyncAttributeTag aTag,
const char* pEventSourceID,
UINT32 ulEventClockValue)
{
m_eEventSourceTag = eTag;
m_eSyncAttributeTag = aTag;
if(pEventSourceID)
{
m_pEventSourceID = new char[strlen(pEventSourceID)+1];
strcpy(m_pEventSourceID, pEventSourceID); /* Flawfinder: ignore */
if (m_pParser && m_pParser->m_pTimelineElementManager)
{
m_pParser->m_pTimelineElementManager->addNotification(pEventSourceID, this);
}
}
m_ulEventClockValue = ulEventClockValue;
}
#endif
void
CSmil1TimelineElement::addChild(CSmil1TimelineElement* pChild)
{
if(!m_pChildren)
{
m_pChildren = new CHXSimpleList;
}
m_pChildren->AddTail(pChild);
pChild->setParent(this);
}
UINT32
CSmil1TimelineElement::getDuration()
{
return m_pSourceElement->m_ulDuration;
}
UINT32
CSmil1TimelineElement::getDelay()
{
return m_pSourceElement->m_ulDelay;
}
void
CSmil1TimelineElement::dump()
{
}
/*
* CSmil1TimelinePar methods
*/
CSmil1TimelinePar::CSmil1TimelinePar(CSmil1Element* pSourceElement,
CSmil1Parser* pParser):
CSmil1TimelineElement(pSourceElement, pParser),
m_nDurationAdded(0),
m_ulFirstDuration(0),
m_ulLastDuration(0)
{
}
CSmil1TimelinePar::~CSmil1TimelinePar()
{
}
void
CSmil1TimelinePar::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;
}
if (!m_bDelayEvent) //[SMIL 1.0 compliance] helps fix PR 14420.
{
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);
}
}
if (m_pSourceElement->m_ulDuration != (UINT32)-1)
{
setDuration(m_pSourceElement->m_ulDuration);
}
}
else //[SMIL 1.0 compliance] for PR 14420:
// let's not claim that the delay is set when we still
// are awaiting a delay (begin) event; we *do* need to
// add the delay of this to the event's begin offset.
// This is done by setting the new "m_bNonEventDelaySet"
// variable to TRUE and leaving m_bDelaySet to FALSE
// until the ElementResolved() call sets it to true:
{
//Parent calls setDelay before we get to ElementResolved,
// thus m_bDelaySet should never be TRUE if we have a
// delay event:
HX_ASSERT(!m_bDelaySet);
m_bNonEventDelaySet = TRUE; //ElementResolved will look at this.
}
}
void
CSmil1TimelinePar::setDuration(UINT32 ulDuration, BOOL bSetFromParent)
{
m_pSourceElement->m_ulDuration = ulDuration;
m_bDurationSet = TRUE;
if(m_pChildren)
{
CHXSimpleList::Iterator i = m_pChildren->Begin();
for(; i != m_pChildren->End(); ++i)
{
CSmil1TimelineElement* pElement = (CSmil1TimelineElement*)(*i);
pElement->setDuration(m_pSourceElement->m_ulDuration, TRUE);
}
}
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
CSmil1TimelinePar::setMaxDuration(UINT32 ulMaxDuration)
{
HX_ASSERT(m_pChildren);
m_bMaxDurationSet = TRUE;
m_pSourceElement->m_ulMaxDuration = ulMaxDuration;
if (m_pChildren)
{
CHXSimpleList::Iterator i = m_pChildren->Begin();
for(; i != m_pChildren->End(); ++i)
{
CSmil1TimelineElement* pElement = (CSmil1TimelineElement*)(*i);
pElement->setMaxDuration(ulMaxDuration);
}
}
}
void
CSmil1TimelinePar::adjustDependentDuration(CSmil1TimelineElement* pDependent)
{
if (m_pParent)
{
m_pParent->adjustDependentDuration(pDependent);
}
return;
}
void
CSmil1TimelinePar::addDuration(UINT32 ulDuration,
UINT32 ulDelay,
const char* pElementID)
{
if(m_pSourceElement->m_ulDuration == (UINT32)-1)
{
m_pSourceElement->m_ulDuration = ulDuration;
m_ulFirstDuration = ulDuration;
m_ulLastDuration = ulDuration;
}
else
{
m_pSourceElement->m_ulDuration =
(ulDuration > m_pSourceElement->m_ulDuration) ?
ulDuration : m_pSourceElement->m_ulDuration;
if(ulDuration < m_ulFirstDuration)
{
m_ulFirstDuration = ulDuration;
}
if(ulDuration > m_ulLastDuration)
{
m_ulLastDuration = ulDuration;
}
}
m_nDurationAdded++;
if(m_nDurationAdded == m_pChildren->GetCount() &&
!m_bDurationEvent)
{
if(m_pSourceElement->m_nEndsyncEventSourceTag ==
SMILEventSourceFirst)
{
durationResolved(m_ulFirstDuration, TRUE);
}
else if(m_pSourceElement->m_nEndsyncEventSourceTag ==
SMILEventSourceLast)
{
durationResolved(m_ulLastDuration, TRUE);
}
else
{
durationResolved(m_pSourceElement->m_ulDuration, FALSE);
}
}
}
void
CSmil1TimelinePar::elementResolved(CSmil1TimelineElement* pEventElement)
{
//XXXEH: do we really want to check m_bDurationSet and m_bDelaySet...etc.
// first???? (as in old version)
//XXXEH: also, 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,
TRUE);
}
}
else if(m_pSourceElement->m_nEndEventSourceTag == SMILEventSourceEnd)
{
if(pEventElement->m_bDurationSet)
{
durationResolved(pEventElement->getDuration(), TRUE);
}
}
else if(m_pSourceElement->m_nEndEventSourceTag == SMILEventSourceClock)
{
if(pEventElement->m_bDelaySet)
{
durationResolved(pEventElement->m_pSourceElement->m_ulDelay +
m_pSourceElement->m_ulEndEventClockValue, TRUE);
}
}
#endif // defined(XXXEH_UNTESTED_AND_NOT_EXAMINED_WELL).
//[SMIL 1.0 compliance] Helps fix PR 32578:
if (m_pSourceElement->m_nEndsyncEventSourceTag == SMILEventSourceID)
{
if(pEventElement->m_bDurationSet)
{
durationResolved(pEventElement->getDuration(), TRUE);
}
}
}
void
CSmil1TimelinePar::durationResolved(UINT32 ulDuration, BOOL bUpdateChildren)
{
if(!m_bDurationSet)
{
m_bDurationSet = TRUE;
m_pSourceElement->m_ulDuration = ulDuration;
if(m_pParent)
{
m_pParent->addDuration(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);
}
if(bUpdateChildren)
{
CHXSimpleList::Iterator i = m_pChildren->Begin();
for(; i != m_pChildren->End(); ++i)
{
CSmil1TimelineElement* pElement = (CSmil1TimelineElement*)(*i);
pElement->setDuration(m_pSourceElement->m_ulDuration, TRUE);
}
}
}
}
#if 0
void
CSmil1TimelinePar::setEndsync(EndsyncType eType,
const char* pEndsyncID,
UINT32 ulEndsyncClockValue)
{
m_eEndsyncType = eType;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -