当前位置: 首页>>代码示例>>C++>>正文


C++ HTMLMediaElement::setAttribute方法代码示例

本文整理汇总了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);
}
开发者ID:1833183060,项目名称:wke,代码行数:33,代码来源:MediaDocument.cpp

示例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);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:29,代码来源:MediaDocument.cpp

示例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));
}
开发者ID:valbok,项目名称:WebKitForWayland,代码行数:55,代码来源:MediaDocument.cpp

示例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);
}
开发者ID:Wrichik1999,项目名称:webkit,代码行数:44,代码来源:MediaDocument.cpp

示例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());
}
开发者ID:,项目名称:,代码行数:39,代码来源:

示例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);
}
开发者ID:,项目名称:,代码行数:37,代码来源:

示例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));
}
开发者ID:13W,项目名称:phantomjs,代码行数:6,代码来源:JSHTMLMediaElement.cpp


注:本文中的HTMLMediaElement::setAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。