Esempio n. 1
0
JSValue* JSHTMLSourceElement::getValueProperty(ExecState* exec, int token) const
{
    switch (token) {
    case SrcAttrNum: {
        HTMLSourceElement* imp = static_cast<HTMLSourceElement*>(impl());
        return jsString(exec, imp->src());
    }
    case TypeAttrNum: {
        HTMLSourceElement* imp = static_cast<HTMLSourceElement*>(impl());
        return jsString(exec, imp->type());
    }
    case MediaAttrNum: {
        HTMLSourceElement* imp = static_cast<HTMLSourceElement*>(impl());
        return jsString(exec, imp->media());
    }
    case ConstructorAttrNum:
        return getConstructor(exec);
    }
    return 0;
}
Esempio n. 2
0
String HTMLMediaElement::pickMedia()
{
    // 3.14.9.2. Location of the media resource
    String mediaSrc = getAttribute(srcAttr);
    if (mediaSrc.isEmpty()) {
        for (Node* n = firstChild(); n; n = n->nextSibling()) {
            if (n->hasTagName(sourceTag)) {
                HTMLSourceElement* source = static_cast<HTMLSourceElement*>(n);
                if (!source->hasAttribute(srcAttr))
                    continue; 
                if (source->hasAttribute(mediaAttr)) {
                    MediaQueryEvaluator screenEval("screen", document()->frame(), renderer() ? renderer()->style() : 0);
                    RefPtr<MediaList> media = MediaList::createAllowingDescriptionSyntax(source->media());
                    if (!screenEval.eval(media.get()))
                        continue;
                }
                if (source->hasAttribute(typeAttr)) {
                    String type = source->type().stripWhiteSpace();

                    // "type" can have parameters after a semi-colon, strip them before checking with the type registry
                    int semi = type.find(';');
                    if (semi != -1)
                        type = type.left(semi).stripWhiteSpace();

                    if (!MIMETypeRegistry::isSupportedMediaMIMEType(type))
                        continue;
                }
                mediaSrc = source->src().string();
                break;
            }
        }
    }
    if (!mediaSrc.isEmpty())
        mediaSrc = document()->completeURL(mediaSrc).string();
    return mediaSrc;
}
static v8::Handle<v8::Value> mediaAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    HTMLSourceElement* imp = V8HTMLSourceElement::toNative(info.Holder());
    return v8String(imp->media(), info.GetIsolate());
}
Esempio n. 4
0
 static v8::Handle<v8::Value> mediaAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) {
   INC_STATS("DOM.HTMLSourceElement.media._get");
   HTMLSourceElement* imp = V8HTMLSourceElement::toNative(info.Holder());
   return v8String(imp->media());
 }