本文整理汇总了C++中HTMLMediaElement::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLMediaElement::setAttribute方法的具体用法?C++ HTMLMediaElement::setAttribute怎么用?C++ HTMLMediaElement::setAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLMediaElement
的用法示例。
在下文中一共展示了HTMLMediaElement::setAttribute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createDocumentStructure
void MediaDocumentParser::createDocumentStructure()
{
ExceptionCode ec;
RefPtr<Element> rootElement = document()->createElement(htmlTag, false);
document()->appendChild(rootElement, ec);
static_cast<HTMLHtmlElement*>(rootElement.get())->insertedByParser();
if (document()->frame())
document()->frame()->loader()->dispatchDocumentElementAvailable();
RefPtr<Element> body = document()->createElement(bodyTag, false);
body->setAttribute(styleAttr, "background-color: rgb(38,38,38);");
rootElement->appendChild(body, ec);
RefPtr<Element> mediaElement = document()->createElement(videoTag, false);
m_mediaElement = static_cast<HTMLVideoElement*>(mediaElement.get());
m_mediaElement->setAttribute(controlsAttr, "");
m_mediaElement->setAttribute(autoplayAttr, "");
m_mediaElement->setAttribute(styleAttr, "margin: auto; position: absolute; top: 0; right: 0; bottom: 0; left: 0;");
m_mediaElement->setAttribute(nameAttr, "media");
m_mediaElement->setSrc(document()->url());
body->appendChild(mediaElement, ec);
Frame* frame = document()->frame();
if (!frame)
return;
frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(DoNotBufferData);
}
示例2: createDocumentStructure
void MediaTokenizer::createDocumentStructure()
{
ExceptionCode ec;
RefPtr<Element> rootElement = m_doc->createElementNS(xhtmlNamespaceURI, "html", ec);
m_doc->appendChild(rootElement, ec);
RefPtr<Element> body = m_doc->createElementNS(xhtmlNamespaceURI, "body", ec);
body->setAttribute(styleAttr, "background-color: rgb(38,38,38);");
rootElement->appendChild(body, ec);
RefPtr<Element> mediaElement = m_doc->createElementNS(xhtmlNamespaceURI, "video", ec);
m_mediaElement = static_cast<HTMLVideoElement*>(mediaElement.get());
m_mediaElement->setAttribute(controlsAttr, "");
m_mediaElement->setAttribute(autoplayAttr, "");
m_mediaElement->setAttribute(styleAttr, "margin: auto; position: absolute; top: 0; right: 0; bottom: 0; left: 0;");
m_mediaElement->setAttribute(nameAttr, "media");
m_mediaElement->setSrc(m_doc->url());
body->appendChild(mediaElement, ec);
Frame* frame = m_doc->frame();
if (!frame)
return;
frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(false);
}
示例3: createDocumentStructure
void MediaDocumentParser::createDocumentStructure()
{
Ref<Element> rootElement = document()->createElement(htmlTag, false);
document()->appendChild(rootElement.copyRef(), IGNORE_EXCEPTION);
document()->setCSSTarget(rootElement.ptr());
downcast<HTMLHtmlElement>(rootElement.get()).insertedByParser();
if (document()->frame())
document()->frame()->injectUserScripts(InjectAtDocumentStart);
#if PLATFORM(IOS)
Ref<Element> headElement = document()->createElement(headTag, false);
rootElement->appendChild(headElement.copyRef(), IGNORE_EXCEPTION);
Ref<Element> metaElement = document()->createElement(metaTag, false);
metaElement->setAttribute(nameAttr, "viewport");
metaElement->setAttribute(contentAttr, "width=device-width,initial-scale=1,user-scalable=no");
headElement->appendChild(WTFMove(metaElement), IGNORE_EXCEPTION);
#endif
Ref<Element> body = document()->createElement(bodyTag, false);
rootElement->appendChild(body.copyRef(), IGNORE_EXCEPTION);
Ref<Element> mediaElement = document()->createElement(videoTag, false);
m_mediaElement = downcast<HTMLVideoElement>(mediaElement.ptr());
m_mediaElement->setAttribute(controlsAttr, emptyAtom);
m_mediaElement->setAttribute(autoplayAttr, emptyAtom);
m_mediaElement->setAttribute(nameAttr, "media");
StringBuilder elementStyle;
elementStyle.appendLiteral("max-width: 100%; max-height: 100%;");
#if PLATFORM(IOS)
elementStyle.appendLiteral("width: 100%; height: 100%;");
#endif
m_mediaElement->setAttribute(styleAttr, elementStyle.toString());
Ref<Element> sourceElement = document()->createElement(sourceTag, false);
HTMLSourceElement& source = downcast<HTMLSourceElement>(sourceElement.get());
source.setSrc(document()->url());
if (DocumentLoader* loader = document()->loader())
source.setType(loader->responseMIMEType());
m_mediaElement->appendChild(WTFMove(sourceElement), IGNORE_EXCEPTION);
body->appendChild(WTFMove(mediaElement), IGNORE_EXCEPTION);
Frame* frame = document()->frame();
if (!frame)
return;
frame->loader().activeDocumentLoader()->setMainResourceDataBufferingPolicy(DoNotBufferData);
frame->loader().setOutgoingReferrer(frame->document()->completeURL(m_outgoingReferrer));
}
示例4: createDocumentStructure
void MediaDocumentParser::createDocumentStructure()
{
RefPtr<Element> rootElement = document()->createElement(htmlTag, false);
document()->appendChild(rootElement, IGNORE_EXCEPTION);
document()->setCSSTarget(rootElement.get());
toHTMLHtmlElement(rootElement.get())->insertedByParser();
if (document()->frame())
document()->frame()->injectUserScripts(InjectAtDocumentStart);
RefPtr<Element> body = document()->createElement(bodyTag, false);
rootElement->appendChild(body, IGNORE_EXCEPTION);
RefPtr<Element> mediaElement = document()->createElement(videoTag, false);
m_mediaElement = toHTMLVideoElement(mediaElement.get());
m_mediaElement->setAttribute(controlsAttr, "");
m_mediaElement->setAttribute(autoplayAttr, "");
m_mediaElement->setAttribute(nameAttr, "media");
StringBuilder elementStyle;
elementStyle.appendLiteral("max-width: 100%; max-height: 100%;");
#if PLATFORM(IOS)
elementStyle.appendLiteral("width: 100%; height: 100%;");
#endif
m_mediaElement->setAttribute(styleAttr, elementStyle.toString());
RefPtr<Element> sourceElement = document()->createElement(sourceTag, false);
HTMLSourceElement& source = toHTMLSourceElement(*sourceElement);
source.setSrc(document()->url());
if (DocumentLoader* loader = document()->loader())
source.setType(loader->responseMIMEType());
m_mediaElement->appendChild(sourceElement, IGNORE_EXCEPTION);
body->appendChild(mediaElement, IGNORE_EXCEPTION);
Frame* frame = document()->frame();
if (!frame)
return;
frame->loader().activeDocumentLoader()->setMainResourceDataBufferingPolicy(DoNotBufferData);
}
示例5: resizeSourceDimensions
void MediaPlayerPrivate::resizeSourceDimensions()
{
if (!m_webCorePlayer)
return;
HTMLMediaElement* client = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient());
if (!client || !client->isVideo())
return;
RenderObject* o = client->renderer();
if (!o)
return;
// If we have an HTMLVideoElement but the source has no video, then we need to resize the media element.
if (!hasVideo()) {
IntRect rect = o->enclosingBox()->contentBoxRect();
static const int playbookMinAudioElementWidth = 300;
static const int playbookMinAudioElementHeight = 32;
// If the rect dimensions are less than the allowed minimum, use the minimum instead.
int newWidth = max(rect.width(), playbookMinAudioElementWidth);
int newHeight = max(rect.height(), playbookMinAudioElementHeight);
char attrString[12];
sprintf(attrString, "%d", newWidth);
client->setAttribute(HTMLNames::widthAttr, attrString);
sprintf(attrString, "%d", newHeight);
client->setAttribute(HTMLNames::heightAttr, attrString);
}
// If we don't know what the width and height of the video source is, then we need to set it to something sane.
if (m_platformPlayer->sourceWidth() && m_platformPlayer->sourceHeight())
return;
IntRect rect = o->enclosingBox()->contentBoxRect();
m_platformPlayer->setSourceDimension(rect.width(), rect.height());
}
示例6: createDocumentStructure
void MediaDocumentParser::createDocumentStructure()
{
RefPtr<Element> rootElement = document()->createElement(htmlTag, false);
document()->appendChild(rootElement, IGNORE_EXCEPTION);
document()->setCSSTarget(rootElement.get());
static_cast<HTMLHtmlElement*>(rootElement.get())->insertedByParser();
if (document()->frame())
document()->frame()->loader()->dispatchDocumentElementAvailable();
RefPtr<Element> body = document()->createElement(bodyTag, false);
rootElement->appendChild(body, IGNORE_EXCEPTION);
RefPtr<Element> mediaElement = document()->createElement(videoTag, false);
m_mediaElement = static_cast<HTMLVideoElement*>(mediaElement.get());
m_mediaElement->setAttribute(controlsAttr, "");
m_mediaElement->setAttribute(autoplayAttr, "");
m_mediaElement->setAttribute(nameAttr, "media");
RefPtr<Element> sourceElement = document()->createElement(sourceTag, false);
HTMLSourceElement* source = static_cast<HTMLSourceElement*>(sourceElement.get());
source->setSrc(document()->url());
if (DocumentLoader* loader = document()->loader())
source->setType(loader->responseMIMEType());
m_mediaElement->appendChild(sourceElement, IGNORE_EXCEPTION);
body->appendChild(mediaElement, IGNORE_EXCEPTION);
Frame* frame = document()->frame();
if (!frame)
return;
frame->loader()->activeDocumentLoader()->setMainResourceDataBufferingPolicy(DoNotBufferData);
}
示例7: setJSHTMLMediaElementSrc
void setJSHTMLMediaElementSrc(ExecState* exec, JSObject* thisObject, JSValue value)
{
JSHTMLMediaElement* castedThis = static_cast<JSHTMLMediaElement*>(thisObject);
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(castedThis->impl());
imp->setAttribute(WebCore::HTMLNames::srcAttr, valueToStringWithNullCheck(exec, value));
}