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); }
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); }
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)); }
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); }
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()); }
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); }
void MediaDocumentParser::createDocumentStructure() { ExceptionCode ec; RefPtr<Element> rootElement = document()->createElement(htmlTag, false); document()->appendChild(rootElement, ec); #if ENABLE(OFFLINE_WEB_APPLICATIONS) static_cast<HTMLHtmlElement*>(rootElement.get())->insertedByParser(); #endif 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); #if PLATFORM(BLACKBERRY) && OS(QNX) // Use the name of the media file as the document title if (document()->title().isEmpty()) { const KURL& url = document()->url(); if (url.isValid()) { document()->setTitle(decodeURLEscapeSequences(url.lastPathComponent())); } } RefPtr<Element> div = document()->createElement(divTag, false); div->setAttribute(styleAttr, "margin-top: 40px; text-align: center; vertical-align: center;"); body->appendChild(div, ec); #endif RefPtr<Element> mediaElement = document()->createElement(videoTag, false); m_mediaElement = static_cast<HTMLVideoElement*>(mediaElement.get()); m_mediaElement->setAttribute(controlsAttr, ""); m_mediaElement->setAttribute(autoplayAttr, ""); #if PLATFORM(BLACKBERRY) && OS(QNX) Frame* frameForWidth = document()->frame(); if (!frameForWidth) return; int layoutWidth = frameForWidth->view()->layoutWidth(); char elementWidthAttr[12]; sprintf(elementWidthAttr, "%d", layoutWidth*3/4); // Make the default width 3/4 of the frame width. m_mediaElement->setAttribute(widthAttr, elementWidthAttr); m_mediaElement->setNeedsSourceWidthUpdate(); // So we know to update the element width if we're playing a video and the size comes in with the metadata. #else m_mediaElement->setAttribute(styleAttr, "margin: auto; position: absolute; top: 0; right: 0; bottom: 0; left: 0;"); #endif m_mediaElement->setAttribute(nameAttr, "media"); m_mediaElement->setSrc(document()->url()); #if PLATFORM(BLACKBERRY) && OS(QNX) div->appendChild(mediaElement, ec); #else body->appendChild(mediaElement, ec); #endif Frame* frame = document()->frame(); if (!frame) return; frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(false); }
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)); }