static v8::Handle<v8::Value> formAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.HTMLObjectElement.form._get");
    HTMLObjectElement* imp = V8HTMLObjectElement::toNative(info.Holder());
	if (!R_check(imp)) return v8::Handle<v8::Value>(v8::Undefined());
    return toV8(imp->form());
}
static v8::Handle<v8::Value> vspaceAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.HTMLObjectElement.vspace._get");
    HTMLObjectElement* imp = V8HTMLObjectElement::toNative(info.Holder());
	if (!R_check(imp)) return v8::Handle<v8::Value>(v8::Undefined());
    return v8::Integer::New(imp->getIntegralAttribute(WebCore::HTMLNames::vspaceAttr));
}
static v8::Handle<v8::Value> declareAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.HTMLObjectElement.declare._get");
    HTMLObjectElement* imp = V8HTMLObjectElement::toNative(info.Holder());
	if (!R_check(imp)) return v8::Handle<v8::Value>(v8::Undefined());
    return v8Boolean(imp->hasAttribute(WebCore::HTMLNames::declareAttr));
}
示例#4
0
JSValue jsHTMLObjectElementDeclare(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSHTMLObjectElement* castedThis = static_cast<JSHTMLObjectElement*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(castedThis->impl());
    JSValue result = jsBoolean(imp->hasAttribute(WebCore::HTMLNames::declareAttr));
    return result;
}
static void declareAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.HTMLObjectElement.declare._set");
    HTMLObjectElement* imp = V8HTMLObjectElement::toNative(info.Holder());
    bool v = value->BooleanValue();
    imp->setBooleanAttribute(WebCore::HTMLNames::declareAttr, v);
    return;
}
static void vspaceAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.HTMLObjectElement.vspace._set");
    HTMLObjectElement* imp = V8HTMLObjectElement::toNative(info.Holder());
    int v = toInt32(value);
    imp->setIntegralAttribute(WebCore::HTMLNames::vspaceAttr, v);
    return;
}
示例#7
0
JSValue jsHTMLObjectElementValidationMessage(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSHTMLObjectElement* castedThis = static_cast<JSHTMLObjectElement*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(castedThis->impl());
    JSValue result = jsString(exec, imp->validationMessage());
    return result;
}
示例#8
0
JSValue jsHTMLObjectElementValidity(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSHTMLObjectElement* castedThis = static_cast<JSHTMLObjectElement*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(castedThis->impl());
    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->validity()));
    return result;
}
示例#9
0
JSValue jsHTMLObjectElementWillValidate(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSHTMLObjectElement* castedThis = static_cast<JSHTMLObjectElement*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(castedThis->impl());
    JSValue result = jsBoolean(imp->willValidate());
    return result;
}
示例#10
0
JSValue jsHTMLObjectElementWidth(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSHTMLObjectElement* castedThis = static_cast<JSHTMLObjectElement*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(castedThis->impl());
    JSValue result = jsString(exec, imp->getAttribute(WebCore::HTMLNames::widthAttr));
    return result;
}
示例#11
0
JSValue jsHTMLObjectElementVspace(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSHTMLObjectElement* castedThis = static_cast<JSHTMLObjectElement*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(castedThis->impl());
    JSValue result = jsNumber(imp->getIntegralAttribute(WebCore::HTMLNames::vspaceAttr));
    return result;
}
示例#12
0
HTMLObjectElement* HTMLObjectElement::create(Document& document,
                                             HTMLFormElement* form,
                                             bool createdByParser) {
  HTMLObjectElement* element =
      new HTMLObjectElement(document, form, createdByParser);
  element->ensureUserAgentShadowRoot();
  return element;
}
static v8::Handle<v8::Value> contentDocumentAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.HTMLObjectElement.contentDocument._get");
    HTMLObjectElement* imp = V8HTMLObjectElement::toNative(info.Holder());
	if (!R_check(imp)) return v8::Handle<v8::Value>(v8::Undefined());
    if (!V8BindingSecurity::checkNodeSecurity(V8BindingState::Only(), imp->contentDocument()))
    return v8::Handle<v8::Value>();

    return toV8(imp->contentDocument());
}
示例#14
0
EncodedJSValue JSC_HOST_CALL jsHTMLObjectElementPrototypeFunctionCheckValidity(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSHTMLObjectElement::s_info))
        return throwVMTypeError(exec);
    JSHTMLObjectElement* castedThis = static_cast<JSHTMLObjectElement*>(asObject(thisValue));
    HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(castedThis->impl());


    JSC::JSValue result = jsBoolean(imp->checkValidity());
    return JSValue::encode(result);
}
示例#15
0
bool HTMLObjectElement::isExposed() const
{
    // http://www.whatwg.org/specs/web-apps/current-work/#exposed
    for (HTMLObjectElement* ancestor = Traversal<HTMLObjectElement>::firstAncestor(*this); ancestor; ancestor = Traversal<HTMLObjectElement>::firstAncestor(*ancestor)) {
        if (ancestor->isExposed())
            return false;
    }
    for (HTMLElement& element : Traversal<HTMLElement>::descendantsOf(*this)) {
        if (isHTMLObjectElement(element) || isHTMLEmbedElement(element))
            return false;
    }
    return true;
}
示例#16
0
EncodedJSValue JSC_HOST_CALL jsHTMLObjectElementPrototypeFunctionSetCustomValidity(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSHTMLObjectElement::s_info))
        return throwVMTypeError(exec);
    JSHTMLObjectElement* castedThis = static_cast<JSHTMLObjectElement*>(asObject(thisValue));
    HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(castedThis->impl());
    const String& error(valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    imp->setCustomValidity(error);
    return JSValue::encode(jsUndefined());
}
示例#17
0
EncodedJSValue JSC_HOST_CALL jsHTMLObjectElementPrototypeFunctionGetSVGDocument(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSHTMLObjectElement::s_info))
        return throwVMTypeError(exec);
    JSHTMLObjectElement* castedThis = static_cast<JSHTMLObjectElement*>(asObject(thisValue));
    HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(castedThis->impl());
    ExceptionCode ec = 0;
    if (!checkNodeSecurity(exec, imp->getSVGDocument(ec)))
        return JSValue::encode(jsUndefined());


    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->getSVGDocument(ec)));
    setDOMException(exec, ec);
    return JSValue::encode(result);
}
static v8::Handle<v8::Value> getSVGDocumentCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.HTMLObjectElement.getSVGDocument");
    HTMLObjectElement* imp = V8HTMLObjectElement::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    if (!V8BindingSecurity::checkNodeSecurity(V8BindingState::Only(), imp->getSVGDocument(ec)))
        return v8::Handle<v8::Value>();
    RefPtr<SVGDocument> result = imp->getSVGDocument(ec);
    if (UNLIKELY(ec))
        goto fail;
    return toV8(result.release());
    }
    fail:
    V8Proxy::setDOMException(ec);
    return v8::Handle<v8::Value>();
}
示例#19
0
void RenderPartObject::updateWidget(bool onlyCreateNonNetscapePlugins)
{
  String url;
  String serviceType;
  Vector<String> paramNames;
  Vector<String> paramValues;
  Frame* frame = m_view->frame();
  
  if (element()->hasTagName(objectTag)) {

      HTMLObjectElement* o = static_cast<HTMLObjectElement*>(element());

      o->setNeedWidgetUpdate(false);
      if (!o->isFinishedParsingChildren())
        return;
      // Check for a child EMBED tag.
      HTMLEmbedElement* embed = 0;
      for (Node* child = o->firstChild(); child;) {
          if (child->hasTagName(embedTag)) {
              embed = static_cast<HTMLEmbedElement*>(child);
              break;
          } else if (child->hasTagName(objectTag))
              child = child->nextSibling();         // Don't descend into nested OBJECT tags
          else
              child = child->traverseNextNode(o);   // Otherwise descend (EMBEDs may be inside COMMENT tags)
      }
      
      // Use the attributes from the EMBED tag instead of the OBJECT tag including WIDTH and HEIGHT.
      HTMLElement *embedOrObject;
      if (embed) {
          embedOrObject = (HTMLElement *)embed;
          url = embed->url();
          serviceType = embed->serviceType();
      } else
          embedOrObject = (HTMLElement *)o;
      
      // If there was no URL or type defined in EMBED, try the OBJECT tag.
      if (url.isEmpty())
          url = o->m_url;
      if (serviceType.isEmpty())
          serviceType = o->m_serviceType;
      
      HashSet<StringImpl*, CaseFoldingHash> uniqueParamNames;
      
      // Scan the PARAM children.
      // Get the URL and type from the params if we don't already have them.
      // Get the attributes from the params if there is no EMBED tag.
      Node *child = o->firstChild();
      while (child && (url.isEmpty() || serviceType.isEmpty() || !embed)) {
          if (child->hasTagName(paramTag)) {
              HTMLParamElement* p = static_cast<HTMLParamElement*>(child);
              String name = p->name().lower();
              if (url.isEmpty() && (name == "src" || name == "movie" || name == "code" || name == "url"))
                  url = p->value();
              if (serviceType.isEmpty() && name == "type") {
                  serviceType = p->value();
                  int pos = serviceType.find(";");
                  if (pos != -1)
                      serviceType = serviceType.left(pos);
              }
              if (!embed && !name.isEmpty()) {
                  uniqueParamNames.add(p->name().impl());
                  paramNames.append(p->name());
                  paramValues.append(p->value());
              }
          }
          child = child->nextSibling();
      }
      
      // When OBJECT is used for an applet via Sun's Java plugin, the CODEBASE attribute in the tag
      // points to the Java plugin itself (an ActiveX component) while the actual applet CODEBASE is
      // in a PARAM tag. See <http://java.sun.com/products/plugin/1.2/docs/tags.html>. This means
      // we have to explicitly suppress the tag's CODEBASE attribute if there is none in a PARAM,
      // else our Java plugin will misinterpret it. [4004531]
      String codebase;
      if (!embed && MIMETypeRegistry::isJavaAppletMIMEType(serviceType)) {
          codebase = "codebase";
          uniqueParamNames.add(codebase.impl()); // pretend we found it in a PARAM already
      }
      
      // Turn the attributes of either the EMBED tag or OBJECT tag into arrays, but don't override PARAM values.
      NamedAttrMap* attributes = embedOrObject->attributes();
      if (attributes) {
          for (unsigned i = 0; i < attributes->length(); ++i) {
              Attribute* it = attributes->attributeItem(i);
              const AtomicString& name = it->name().localName();
              if (embed || !uniqueParamNames.contains(name.impl())) {
                  paramNames.append(name.string());
                  paramValues.append(it->value().string());
              }
          }
      }
      
      // If we still don't have a type, try to map from a specific CLASSID to a type.
      if (serviceType.isEmpty() && !o->m_classId.isEmpty())
          mapClassIdToServiceType(o->m_classId, serviceType);
      
      if (!isURLAllowed(document(), url))
          return;

      // Find out if we support fallback content.
      m_hasFallbackContent = false;
      for (Node *child = o->firstChild(); child && !m_hasFallbackContent; child = child->nextSibling()) {
          if ((!child->isTextNode() && !child->hasTagName(embedTag) && !child->hasTagName(paramTag)) || // Discount <embed> and <param>
              (child->isTextNode() && !static_cast<Text*>(child)->containsOnlyWhitespace()))
              m_hasFallbackContent = true;
      }
      
      if (onlyCreateNonNetscapePlugins) {
          KURL completedURL;
          if (!url.isEmpty())
              completedURL = frame->loader()->completeURL(url);
        
          if (frame->loader()->client()->objectContentType(completedURL, serviceType) == ObjectContentNetscapePlugin)
              return;
      }
      
      bool success = frame->loader()->requestObject(this, url, AtomicString(o->name()), serviceType, paramNames, paramValues);
      if (!success && m_hasFallbackContent)
          o->renderFallbackContent();
  } else if (element()->hasTagName(embedTag)) {
      HTMLEmbedElement *o = static_cast<HTMLEmbedElement*>(element());
      o->setNeedWidgetUpdate(false);
      url = o->url();
      serviceType = o->serviceType();

      if (url.isEmpty() && serviceType.isEmpty())
          return;
      if (!isURLAllowed(document(), url))
          return;
      
      // add all attributes set on the embed object
      NamedAttrMap* a = o->attributes();
      if (a) {
          for (unsigned i = 0; i < a->length(); ++i) {
              Attribute* it = a->attributeItem(i);
              paramNames.append(it->name().localName().string());
              paramValues.append(it->value().string());
          }
      }
      
      if (onlyCreateNonNetscapePlugins) {
          KURL completedURL;
          if (!url.isEmpty())
              completedURL = frame->loader()->completeURL(url);
          
          if (frame->loader()->client()->objectContentType(completedURL, serviceType) == ObjectContentNetscapePlugin)
              return;
          
      }
      
      frame->loader()->requestObject(this, url, o->getAttribute(nameAttr), serviceType, paramNames, paramValues);
  }
}
示例#20
0
JSValue jsHTMLObjectElementContentDocument(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSHTMLObjectElement* castedThis = static_cast<JSHTMLObjectElement*>(asObject(slotBase));
    HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(castedThis->impl());
    return checkNodeSecurity(exec, imp->contentDocument()) ? toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->contentDocument())) : jsUndefined();
}
示例#21
0
void setJSHTMLObjectElementDeclare(ExecState* exec, JSObject* thisObject, JSValue value)
{
    JSHTMLObjectElement* castedThis = static_cast<JSHTMLObjectElement*>(thisObject);
    HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(castedThis->impl());
    imp->setBooleanAttribute(WebCore::HTMLNames::declareAttr, value.toBoolean(exec));
}
示例#22
0
void setJSHTMLObjectElementVspace(ExecState* exec, JSObject* thisObject, JSValue value)
{
    JSHTMLObjectElement* castedThis = static_cast<JSHTMLObjectElement*>(thisObject);
    HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(castedThis->impl());
    imp->setIntegralAttribute(WebCore::HTMLNames::vspaceAttr, value.toInt32(exec));
}
示例#23
0
void setJSHTMLObjectElementWidth(ExecState* exec, JSObject* thisObject, JSValue value)
{
    JSHTMLObjectElement* castedThis = static_cast<JSHTMLObjectElement*>(thisObject);
    HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(castedThis->impl());
    imp->setAttribute(WebCore::HTMLNames::widthAttr, valueToStringWithNullCheck(exec, value));
}
示例#24
0
JSValue* JSHTMLObjectElement::getValueProperty(ExecState* exec, int token) const
{
    switch (token) {
    case FormAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return toJS(exec, WTF::getPtr(imp->form()));
    }
    case CodeAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return jsString(imp->code());
    }
    case AlignAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return jsString(imp->align());
    }
    case ArchiveAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return jsString(imp->archive());
    }
    case BorderAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return jsString(imp->border());
    }
    case CodeBaseAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return jsString(imp->codeBase());
    }
    case CodeTypeAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return jsString(imp->codeType());
    }
    case DataAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return jsString(imp->data());
    }
    case DeclareAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return jsBoolean(imp->declare());
    }
    case HeightAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return jsString(imp->height());
    }
    case HspaceAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return jsNumber(imp->hspace());
    }
    case NameAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return jsString(imp->name());
    }
    case StandbyAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return jsString(imp->standby());
    }
    case TabIndexAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return jsNumber(imp->tabIndex());
    }
    case TypeAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return jsString(imp->type());
    }
    case UseMapAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return jsString(imp->useMap());
    }
    case VspaceAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return jsNumber(imp->vspace());
    }
    case WidthAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return jsString(imp->width());
    }
    case ContentDocumentAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        return checkNodeSecurity(exec, imp->contentDocument()) ? toJS(exec, WTF::getPtr(imp->contentDocument())) : jsUndefined();
    }
    case ConstructorAttrNum:
        return getConstructor(exec);
    }
    return 0;
}
示例#25
0
void RenderEmbeddedObject::updateWidget(bool onlyCreateNonNetscapePlugins)
{
    if (!m_replacementText.isNull() || !node()) // Check the node in case destroy() has been called.
        return;

    String url;
    String serviceType;
    Vector<String> paramNames;
    Vector<String> paramValues;
    Frame* frame = frameView()->frame();

    // The calls to SubframeLoader::requestObject within this function can result in a plug-in being initialized.
    // This can run cause arbitrary JavaScript to run and may result in this RenderObject being detached from
    // the render tree and destroyed, causing a crash like <rdar://problem/6954546>.  By extending our lifetime
    // artifically to ensure that we remain alive for the duration of plug-in initialization.
    RenderWidgetProtector protector(this);

    if (node()->hasTagName(objectTag)) {
        HTMLObjectElement* objectElement = static_cast<HTMLObjectElement*>(node());

        objectElement->setNeedWidgetUpdate(false);
        if (!objectElement->isFinishedParsingChildren())
          return;

        // Check for a child EMBED tag.
        HTMLEmbedElement* embed = 0;
        for (Node* child = objectElement->firstChild(); child; ) {
            if (child->hasTagName(embedTag)) {
                embed = static_cast<HTMLEmbedElement*>(child);
                break;
            }
            
            if (child->hasTagName(objectTag))
                child = child->nextSibling(); // Don't descend into nested OBJECT tags
            else
                child = child->traverseNextNode(objectElement); // Otherwise descend (EMBEDs may be inside COMMENT tags)
        }

        // Use the attributes from the EMBED tag instead of the OBJECT tag including WIDTH and HEIGHT.
        HTMLElement* embedOrObject;
        if (embed) {
            embedOrObject = embed;
            url = embed->url();
            serviceType = embed->serviceType();
        } else
            embedOrObject = objectElement;

        // If there was no URL or type defined in EMBED, try the OBJECT tag.
        if (url.isEmpty())
            url = objectElement->url();
        if (serviceType.isEmpty())
            serviceType = objectElement->serviceType();

        HashSet<StringImpl*, CaseFoldingHash> uniqueParamNames;

        // Scan the PARAM children.
        // Get the URL and type from the params if we don't already have them.
        // Get the attributes from the params if there is no EMBED tag.
        Node* child = objectElement->firstChild();
        while (child && (url.isEmpty() || serviceType.isEmpty() || !embed)) {
            if (child->hasTagName(paramTag)) {
                HTMLParamElement* p = static_cast<HTMLParamElement*>(child);
                String name = p->name();
                if (url.isEmpty() && (equalIgnoringCase(name, "src") || equalIgnoringCase(name, "movie") || equalIgnoringCase(name, "code") || equalIgnoringCase(name, "url")))
                    url = p->value();
                if (serviceType.isEmpty() && equalIgnoringCase(name, "type")) {
                    serviceType = p->value();
                    int pos = serviceType.find(";");
                    if (pos != -1)
                        serviceType = serviceType.left(pos);
                }
                if (!embed && !name.isEmpty()) {
                    uniqueParamNames.add(name.impl());
                    paramNames.append(p->name());
                    paramValues.append(p->value());
                }
            }
            child = child->nextSibling();
        }

        // When OBJECT is used for an applet via Sun's Java plugin, the CODEBASE attribute in the tag
        // points to the Java plugin itself (an ActiveX component) while the actual applet CODEBASE is
        // in a PARAM tag. See <http://java.sun.com/products/plugin/1.2/docs/tags.html>. This means
        // we have to explicitly suppress the tag's CODEBASE attribute if there is none in a PARAM,
        // else our Java plugin will misinterpret it. [4004531]
        String codebase;
        if (!embed && MIMETypeRegistry::isJavaAppletMIMEType(serviceType)) {
            codebase = "codebase";
            uniqueParamNames.add(codebase.impl()); // pretend we found it in a PARAM already
        }
        
        // Turn the attributes of either the EMBED tag or OBJECT tag into arrays, but don't override PARAM values.
        NamedNodeMap* attributes = embedOrObject->attributes();
        if (attributes) {
            for (unsigned i = 0; i < attributes->length(); ++i) {
                Attribute* it = attributes->attributeItem(i);
                const AtomicString& name = it->name().localName();
                if (embed || !uniqueParamNames.contains(name.impl())) {
                    paramNames.append(name.string());
                    paramValues.append(it->value().string());
                }
            }
        }

        mapDataParamToSrc(&paramNames, &paramValues);

        // If we still don't have a type, try to map from a specific CLASSID to a type.
        if (serviceType.isEmpty())
            serviceType = serviceTypeForClassId(objectElement->classId());

        if (!isURLAllowed(document(), url))
            return;

        // Find out if we support fallback content.
        m_hasFallbackContent = false;
        for (Node* child = objectElement->firstChild(); child && !m_hasFallbackContent; child = child->nextSibling()) {
            if ((!child->isTextNode() && !child->hasTagName(embedTag) && !child->hasTagName(paramTag))  // Discount <embed> and <param>
                || (child->isTextNode() && !static_cast<Text*>(child)->containsOnlyWhitespace()))
                m_hasFallbackContent = true;
        }

        if (onlyCreateNonNetscapePlugins) {
            KURL completedURL;
            if (!url.isEmpty())
                completedURL = frame->loader()->completeURL(url);

            if (frame->loader()->client()->objectContentType(completedURL, serviceType) == ObjectContentNetscapePlugin)
                return;
        }

        bool beforeLoadAllowedLoad = objectElement->dispatchBeforeLoadEvent(url);
        
        // beforeload events can modify the DOM, potentially causing
        // RenderWidget::destroy() to be called.  Ensure we haven't been
        // destroyed before continuing.
        if (!node())
            return;
        
        bool success = beforeLoadAllowedLoad && frame->loader()->subframeLoader()->requestObject(this, url, objectElement->getAttribute(nameAttr), serviceType, paramNames, paramValues);
    
        if (!success && m_hasFallbackContent)
            objectElement->renderFallbackContent();

    } else if (node()->hasTagName(embedTag)) {
        HTMLEmbedElement* embedElement = static_cast<HTMLEmbedElement*>(node());
        embedElement->setNeedWidgetUpdate(false);
        url = embedElement->url();
        serviceType = embedElement->serviceType();

        if (url.isEmpty() && serviceType.isEmpty())
            return;
        if (!isURLAllowed(document(), url))
            return;

        // add all attributes set on the embed object
        NamedNodeMap* attributes = embedElement->attributes();
        if (attributes) {
            for (unsigned i = 0; i < attributes->length(); ++i) {
                Attribute* it = attributes->attributeItem(i);
                paramNames.append(it->name().localName().string());
                paramValues.append(it->value().string());
            }
        }

        if (onlyCreateNonNetscapePlugins) {
            KURL completedURL;
            if (!url.isEmpty())
                completedURL = frame->loader()->completeURL(url);

            if (frame->loader()->client()->objectContentType(completedURL, serviceType) == ObjectContentNetscapePlugin)
                return;
        }

        if (embedElement->dispatchBeforeLoadEvent(url))
            frame->loader()->subframeLoader()->requestObject(this, url, embedElement->getAttribute(nameAttr), serviceType, paramNames, paramValues);
    }
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)        
    else if (node()->hasTagName(videoTag) || node()->hasTagName(audioTag)) {
        HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(node());
        KURL kurl;

        mediaElement->getPluginProxyParams(kurl, paramNames, paramValues);
        mediaElement->setNeedWidgetUpdate(false);
        frame->loader()->subframeLoader()->loadMediaPlayerProxyPlugin(node(), kurl, paramNames, paramValues);
    }
#endif
}
示例#26
0
void JSHTMLObjectElement::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)
{
    switch (token) {
    case CodeAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        imp->setCode(valueToStringWithNullCheck(exec, value));
        break;
    }
    case AlignAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        imp->setAlign(valueToStringWithNullCheck(exec, value));
        break;
    }
    case ArchiveAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        imp->setArchive(valueToStringWithNullCheck(exec, value));
        break;
    }
    case BorderAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        imp->setBorder(valueToStringWithNullCheck(exec, value));
        break;
    }
    case CodeBaseAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        imp->setCodeBase(valueToStringWithNullCheck(exec, value));
        break;
    }
    case CodeTypeAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        imp->setCodeType(valueToStringWithNullCheck(exec, value));
        break;
    }
    case DataAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        imp->setData(valueToStringWithNullCheck(exec, value));
        break;
    }
    case DeclareAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        imp->setDeclare(value->toBoolean(exec));
        break;
    }
    case HeightAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        imp->setHeight(valueToStringWithNullCheck(exec, value));
        break;
    }
    case HspaceAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        imp->setHspace(value->toInt32(exec));
        break;
    }
    case NameAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        imp->setName(valueToStringWithNullCheck(exec, value));
        break;
    }
    case StandbyAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        imp->setStandby(valueToStringWithNullCheck(exec, value));
        break;
    }
    case TabIndexAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        imp->setTabIndex(value->toInt32(exec));
        break;
    }
    case TypeAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        imp->setType(valueToStringWithNullCheck(exec, value));
        break;
    }
    case UseMapAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        imp->setUseMap(valueToStringWithNullCheck(exec, value));
        break;
    }
    case VspaceAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        imp->setVspace(value->toInt32(exec));
        break;
    }
    case WidthAttrNum: {
        HTMLObjectElement* imp = static_cast<HTMLObjectElement*>(impl());

        imp->setWidth(valueToStringWithNullCheck(exec, value));
        break;
    }
    }
}