本文整理汇总了C++中TextTrackCue类的典型用法代码示例。如果您正苦于以下问题:C++ TextTrackCue类的具体用法?C++ TextTrackCue怎么用?C++ TextTrackCue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextTrackCue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
bool TextTrack::hasCue(VTTCue* cue, VTTCue::CueMatchRules match)
{
if (cue->startTime() < 0 || cue->endTime() < 0)
return false;
if (!m_cues || !m_cues->length())
return false;
size_t searchStart = 0;
size_t searchEnd = m_cues->length();
while (1) {
ASSERT(searchStart <= m_cues->length());
ASSERT(searchEnd <= m_cues->length());
TextTrackCue* existingCue;
// Cues in the TextTrackCueList are maintained in start time order.
if (searchStart == searchEnd) {
if (!searchStart)
return false;
// If there is more than one cue with the same start time, back up to first one so we
// consider all of them.
while (searchStart >= 2 && cue->startTime() == m_cues->item(searchStart - 2)->startTime())
--searchStart;
bool firstCompare = true;
while (1) {
if (!firstCompare)
++searchStart;
firstCompare = false;
if (searchStart > m_cues->length())
return false;
existingCue = m_cues->item(searchStart - 1);
if (!cue->isRenderable())
continue;
if (!existingCue || cue->startTime() > existingCue->startTime())
return false;
if (!toVTTCue(existingCue)->isEqual(*cue, match))
continue;
return true;
}
}
size_t index = (searchStart + searchEnd) / 2;
existingCue = m_cues->item(index);
if (cue->startTime() < existingCue->startTime() || (match != VTTCue::IgnoreDuration && cue->startTime() == existingCue->startTime() && cue->endTime() > existingCue->endTime()))
searchEnd = index;
else
searchStart = index + 1;
}
ASSERT_NOT_REACHED();
return false;
}
示例2: ASSERT
void TextTrack::setMode(const AtomicString& mode)
{
ASSERT(mode == disabledKeyword() || mode == hiddenKeyword() || mode == showingKeyword());
// On setting, if the new value isn't equal to what the attribute would currently
// return, the new value must be processed as follows ...
if (m_mode == mode)
return;
// If mode changes to disabled, remove this track's cues from the client
// because they will no longer be accessible from the cues() function.
if (mode == disabledKeyword() && m_client && m_cues)
m_client->textTrackRemoveCues(this, m_cues.get());
if (mode != showingKeyword() && m_cues) {
for (size_t i = 0; i < m_cues->length(); ++i) {
TextTrackCue* cue = m_cues->item(i);
if (cue->isRenderable())
toVTTCue(cue)->removeDisplayTree();
}
}
m_mode = mode;
if (m_client)
m_client->textTrackModeChanged(this);
}
示例3:
bool TextTrackCue::operator==(const TextTrackCue& cue) const
{
if (cueType() != cue.cueType())
return false;
if (m_endTime != cue.endTime())
return false;
if (m_startTime != cue.startTime())
return false;
if (m_content != cue.text())
return false;
if (m_settings != cue.cueSettings())
return false;
if (m_id != cue.id())
return false;
if (m_textPosition != cue.position())
return false;
if (m_linePosition != cue.line())
return false;
if (m_cueSize != cue.size())
return false;
if (align() != cue.align())
return false;
return true;
}
示例4: isEqual
bool TextTrackCue::isEqual(const TextTrackCue& cue, CueMatchRules match) const
{
if (cueType() != cue.cueType())
return false;
if (match != IgnoreDuration && m_endTime != cue.endTime())
return false;
if (m_startTime != cue.startTime())
return false;
if (m_content != cue.text())
return false;
if (m_settings != cue.cueSettings())
return false;
if (m_id != cue.id())
return false;
if (m_textPosition != cue.position())
return false;
if (m_linePosition != cue.line())
return false;
if (m_cueSize != cue.size())
return false;
if (align() != cue.align())
return false;
return true;
}
示例5: createTextTrackDisplay
void MediaControlRootElement::updateTextTrackDisplay()
{
if (!m_textDisplayContainer)
createTextTrackDisplay();
CueList activeCues = toParentMediaElement(m_textDisplayContainer)->currentlyActiveCues();
m_textTrackDisplay->removeChildren();
bool nothingToDisplay = true;
for (size_t i = 0; i < activeCues.size(); ++i) {
TextTrackCue* cue = activeCues[i].data();
ASSERT(cue->isActive());
if (!cue->track() || cue->track()->mode() != TextTrack::SHOWING)
continue;
String cueText = cue->text();
if (!cueText.isEmpty()) {
if (!nothingToDisplay)
m_textTrackDisplay->appendChild(document()->createElement(HTMLNames::brTag, false), ASSERT_NO_EXCEPTION);
m_textTrackDisplay->appendChild(document()->createTextNode(cueText), ASSERT_NO_EXCEPTION);
nothingToDisplay = false;
}
}
if (!nothingToDisplay)
m_textDisplayContainer->show();
else
m_textDisplayContainer->hide();
}
示例6: toParentMediaElement
void MediaControlTextTrackContainerElement::updateSizes(bool forceUpdate)
{
HTMLMediaElement* mediaElement = toParentMediaElement(this);
if (!mediaElement)
return;
if (!document()->page())
return;
IntRect videoBox;
if (!mediaElement->renderer() || !mediaElement->renderer()->isVideo())
return;
videoBox = toRenderVideo(mediaElement->renderer())->videoBox();
if (!forceUpdate && m_videoDisplaySize == videoBox)
return;
m_videoDisplaySize = videoBox;
float smallestDimension = std::min(m_videoDisplaySize.size().height(), m_videoDisplaySize.size().width());
float fontSize = smallestDimension * 0.05f;
if (fontSize != m_fontSize) {
m_fontSize = fontSize;
setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px");
}
CueList activeCues = mediaElement->currentlyActiveCues();
for (size_t i = 0; i < activeCues.size(); ++i) {
TextTrackCue* cue = activeCues[i].data();
cue->videoSizeDidChange(m_videoDisplaySize.size());
}
}
示例7: setInlineStyleProperty
void MediaControlTextTrackContainerElement::updateTimerFired(Timer<MediaControlTextTrackContainerElement>*)
{
if (!document().page())
return;
if (m_textTrackRepresentation) {
setInlineStyleProperty(CSSPropertyWidth, m_videoDisplaySize.size().width(), CSSPrimitiveValue::CSS_PX);
setInlineStyleProperty(CSSPropertyHeight, m_videoDisplaySize.size().height(), CSSPrimitiveValue::CSS_PX);
}
HTMLMediaElement* mediaElement = parentMediaElement(this);
if (!mediaElement)
return;
float smallestDimension = std::min(m_videoDisplaySize.size().height(), m_videoDisplaySize.size().width());
float fontScale = document().page()->group().captionPreferences()->captionFontSizeScaleAndImportance(m_fontSizeIsImportant);
m_fontSize = lroundf(smallestDimension * fontScale);
CueList activeCues = mediaElement->currentlyActiveCues();
for (size_t i = 0; i < activeCues.size(); ++i) {
TextTrackCue* cue = activeCues[i].data();
cue->setFontSize(m_fontSize, m_videoDisplaySize.size(), m_fontSizeIsImportant);
}
updateDisplay();
}
示例8: cueContentsMatch
bool TextTrackCue::cueContentsMatch(const TextTrackCue& cue) const
{
if (cueType() != cue.cueType())
return false;
if (id() != cue.id())
return false;
return true;
}
示例9: hasEquivalentStartTime
bool TextTrackCue::hasEquivalentStartTime(const TextTrackCue& cue) const
{
MediaTime startTimeVariance = MediaTime::zeroTime();
if (track())
startTimeVariance = track()->startTimeVariance();
else if (cue.track())
startTimeVariance = cue.track()->startTimeVariance();
return abs(abs(startMediaTime()) - abs(cue.startMediaTime())) <= startTimeVariance;
}
示例10: isEqual
bool TextTrackCue::isEqual(const TextTrackCue& cue, TextTrackCue::CueMatchRules match) const
{
if (cueType() != cue.cueType())
return false;
if (match != IgnoreDuration && endMediaTime() != cue.endMediaTime())
return false;
if (!hasEquivalentStartTime(cue))
return false;
if (!cueContentsMatch(cue))
return false;
return true;
}
示例11: ASSERT_GC_OBJECT_INHERITS
void JSTextTrackCue::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
JSTextTrackCue* jsTextTrackCue = jsCast<JSTextTrackCue*>(cell);
ASSERT_GC_OBJECT_INHERITS(jsTextTrackCue, &s_info);
COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
ASSERT(jsTextTrackCue->structure()->typeInfo().overridesVisitChildren());
Base::visitChildren(jsTextTrackCue, visitor);
// Mark the cue's track root if it has one.
TextTrackCue* textTrackCue = static_cast<TextTrackCue*>(jsTextTrackCue->impl());
if (TextTrack* textTrack = textTrackCue->track())
visitor.addOpaqueRoot(root(textTrack));
textTrackCue->visitJSEventListeners(visitor);
}
示例12: SetDirty
void
TextTrack::RemoveCue(TextTrackCue& aCue, ErrorResult& aRv)
{
aCue.SetActive(false);
mCueList->RemoveCue(aCue, aRv);
aCue.SetTrack(nullptr);
if (mTextTrackList) {
HTMLMediaElement* mediaElement = mTextTrackList->GetMediaElement();
if (mediaElement) {
mediaElement->NotifyCueRemoved(aCue);
}
}
SetDirty();
}
示例13: isEqual
bool TextTrackCueGeneric::isEqual(const TextTrackCue& cue, TextTrackCue::CueMatchRules match) const
{
// Do not call the parent class isEqual here, because we are not cueType() == VTTCue,
// and will fail that equality test.
if (!TextTrackCue::isEqual(cue, match))
return false;
if (cue.cueType() != TextTrackCue::Generic)
return false;
const TextTrackCueGeneric* other = static_cast<const TextTrackCueGeneric*>(&cue);
if (m_baseFontSizeRelativeToVideoHeight != other->baseFontSizeRelativeToVideoHeight())
return false;
if (m_fontSizeMultiplier != other->fontSizeMultiplier())
return false;
if (m_fontName != other->fontName())
return false;
if (m_foregroundColor != other->foregroundColor())
return false;
if (m_backgroundColor != other->backgroundColor())
return false;
return true;
}
示例14: cueContentsMatch
bool DataCue::cueContentsMatch(const TextTrackCue& cue) const
{
if (cue.cueType() != TextTrackCue::Data)
return false;
const DataCue* dataCue = toDataCue(&cue);
RefPtr<ArrayBuffer> otherData = dataCue->data();
if ((otherData && !m_data) || (!otherData && m_data))
return false;
if (m_data && m_data->byteLength() != otherData->byteLength())
return false;
if (m_data && m_data->data() && memcmp(m_data->data(), otherData->data(), m_data->byteLength()))
return false;
const SerializedPlatformRepresentation* otherPlatformValue = dataCue->platformValue();
if ((otherPlatformValue && !m_platformValue) || (!otherPlatformValue && m_platformValue))
return false;
if (m_platformValue && !m_platformValue->isEqual(*otherPlatformValue))
return false;
JSC::JSValue thisValue = valueOrNull();
JSC::JSValue otherValue = dataCue->valueOrNull();
if ((otherValue && !thisValue) || (!otherValue && thisValue))
return false;
if (!JSC::JSValue::strictEqual(nullptr, thisValue, otherValue))
return false;
return true;
}
示例15:
NS_IMETHODIMP
WebVTTListener::OnCue(JS::Handle<JS::Value> aCue, JSContext* aCx)
{
if (!aCue.isObject()) {
return NS_ERROR_FAILURE;
}
TextTrackCue* cue = nullptr;
nsresult rv = UNWRAP_OBJECT(VTTCue, &aCue.toObject(), cue);
NS_ENSURE_SUCCESS(rv, rv);
cue->SetTrackElement(mElement);
mElement->mTrack->AddCue(*cue);
return NS_OK;
}