15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/* 25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (C) 1999 Antti Koivisto (koivisto@kde.org) 45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (C) 2000 Stefan Schimanski (1Stein@gmx.de) 55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved. 65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * This library is free software; you can redistribute it and/or 95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modify it under the terms of the GNU Library General Public 105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * License as published by the Free Software Foundation; either 115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * version 2 of the License, or (at your option) any later version. 125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * This library is distributed in the hope that it will be useful, 145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * but WITHOUT ANY WARRANTY; without even the implied warranty of 155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Library General Public License for more details. 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * You should have received a copy of the GNU Library General Public License 195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * along with this library; see the file COPYING.LIB. If not, write to 205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Boston, MA 02110-1301, USA. 225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */ 235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "config.h" 2553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/html/HTMLObjectElement.h" 265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "HTMLNames.h" 2853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "bindings/v8/ScriptEventListener.h" 2953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/dom/Attribute.h" 30e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles)#include "core/dom/ElementTraversal.h" 3153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/dom/NodeList.h" 3253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/dom/Text.h" 33a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)#include "core/dom/shadow/ShadowRoot.h" 341e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "core/events/ThreadLocalEventNames.h" 35e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles)#include "core/fetch/ImageResource.h" 36bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)#include "core/html/FormDataList.h" 3753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/html/HTMLDocument.h" 3853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/html/HTMLImageLoader.h" 3953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/html/HTMLMetaElement.h" 4053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/html/HTMLParamElement.h" 4153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/html/parser/HTMLParserIdioms.h" 42e08f70592b3fc0d5e68b9b914c9196e813720070Torne (Richard Coles)#include "core/frame/Settings.h" 4353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/plugins/PluginView.h" 4453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/rendering/RenderEmbeddedObject.h" 4551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)#include "platform/MIMETypeRegistry.h" 461e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "platform/Widget.h" 475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)namespace WebCore { 495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)using namespace HTMLNames; 515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 5251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)inline HTMLObjectElement::HTMLObjectElement(Document& document, HTMLFormElement* form, bool createdByParser) 5351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) : HTMLPlugInElement(objectTag, document, createdByParser, ShouldNotPreferPlugInsForImages) 545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) , m_useFallbackContent(false) 555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) setForm(form ? form : findFormAncestor()); 5753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) ScriptWrappable::init(this); 585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)inline HTMLObjectElement::~HTMLObjectElement() 615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 628abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) setForm(0); 635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)PassRefPtr<HTMLObjectElement> HTMLObjectElement::create(Document& document, HTMLFormElement* form, bool createdByParser) 665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 67a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) RefPtr<HTMLObjectElement> element = adoptRef(new HTMLObjectElement(document, form, createdByParser)); 68a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) element->ensureUserAgentShadowRoot(); 69a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) return element.release(); 705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 72c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)RenderWidget* HTMLObjectElement::existingRenderWidget() const 735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return renderPart(); // This will return 0 if the renderer is not a RenderPart. 755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)bool HTMLObjectElement::isPresentationAttribute(const QualifiedName& name) const 785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (name == borderAttr) 805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return true; 81f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) return HTMLPlugInElement::isPresentationAttribute(name); 825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 84926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)void HTMLObjectElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style) 855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 86926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if (name == borderAttr) 87926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) applyBorderAttributeToStyle(value, style); 885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) else 89f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) HTMLPlugInElement::collectStyleForPresentationAttribute(name, value, style); 905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 92926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)void HTMLObjectElement::parseAttribute(const QualifiedName& name, const AtomicString& value) 935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 94926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if (name == formAttr) 955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) formAttributeChanged(); 96926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) else if (name == typeAttr) { 97926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) m_serviceType = value.lower(); 985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) size_t pos = m_serviceType.find(";"); 9906f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles) if (pos != kNotFound) 1005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) m_serviceType = m_serviceType.left(pos); 1015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (renderer()) 1025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) setNeedsWidgetUpdate(true); 103926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } else if (name == dataAttr) { 104926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) m_url = stripLeadingAndTrailingHTMLSpaces(value); 1055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (renderer()) { 1065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) setNeedsWidgetUpdate(true); 1075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (isImageType()) { 1085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!m_imageLoader) 1095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) m_imageLoader = adoptPtr(new HTMLImageLoader(this)); 1105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) m_imageLoader->updateFromElementIgnoringPreviousError(); 1115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 113926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } else if (name == classidAttr) { 114926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) m_classId = value; 1155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (renderer()) 1165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) setNeedsWidgetUpdate(true); 117f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) } else if (name == onbeforeloadAttr) { 1181e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) setAttributeEventListener(EventTypeNames::beforeload, createAttributeEventListener(this, name, value)); 119f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) } else { 120f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) HTMLPlugInElement::parseAttribute(name, value); 121f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) } 1225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 1235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)static void mapDataParamToSrc(Vector<String>* paramNames, Vector<String>* paramValues) 1255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 1265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Some plugins don't understand the "data" attribute of the OBJECT tag (i.e. Real and WMP 1275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // require "src" attribute). 1285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int srcIndex = -1, dataIndex = -1; 1295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) for (unsigned int i = 0; i < paramNames->size(); ++i) { 1305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (equalIgnoringCase((*paramNames)[i], "src")) 1315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) srcIndex = i; 1325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) else if (equalIgnoringCase((*paramNames)[i], "data")) 1335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) dataIndex = i; 1345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 13502772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 1365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (srcIndex == -1 && dataIndex != -1) { 1375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) paramNames->append("src"); 1385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) paramValues->append((*paramValues)[dataIndex]); 1395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 1415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// FIXME: This function should not deal with url or serviceType! 1435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)void HTMLObjectElement::parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType) 1445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 1455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) HashSet<StringImpl*, CaseFoldingHash> uniqueParamNames; 1465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) String urlParameter; 14702772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 1485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Scan the PARAM children and store their name/value pairs. 1495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Get the URL and type from the params if we don't already have them. 1505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) for (Node* child = firstChild(); child; child = child->nextSibling()) { 1515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!child->hasTagName(paramTag)) 1525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) continue; 1535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1548abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) HTMLParamElement* p = toHTMLParamElement(child); 1555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) String name = p->name(); 1565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (name.isEmpty()) 1575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) continue; 1585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) uniqueParamNames.add(name.impl()); 1605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) paramNames.append(p->name()); 1615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) paramValues.append(p->value()); 1625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // FIXME: url adjustment does not belong in this function. 1645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (url.isEmpty() && urlParameter.isEmpty() && (equalIgnoringCase(name, "src") || equalIgnoringCase(name, "movie") || equalIgnoringCase(name, "code") || equalIgnoringCase(name, "url"))) 1655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) urlParameter = stripLeadingAndTrailingHTMLSpaces(p->value()); 1665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // FIXME: serviceType calculation does not belong in this function. 1675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (serviceType.isEmpty() && equalIgnoringCase(name, "type")) { 1685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) serviceType = p->value(); 1695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) size_t pos = serviceType.find(";"); 17006f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles) if (pos != kNotFound) 1715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) serviceType = serviceType.left(pos); 1725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 17402772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 1755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // When OBJECT is used for an applet via Sun's Java plugin, the CODEBASE attribute in the tag 1765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // points to the Java plugin itself (an ActiveX component) while the actual applet CODEBASE is 1775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // in a PARAM tag. See <http://java.sun.com/products/plugin/1.2/docs/tags.html>. This means 1785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // we have to explicitly suppress the tag's CODEBASE attribute if there is none in a PARAM, 1795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // else our Java plugin will misinterpret it. [4004531] 1805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) String codebase; 1815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (MIMETypeRegistry::isJavaAppletMIMEType(serviceType)) { 1825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) codebase = "codebase"; 1835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) uniqueParamNames.add(codebase.impl()); // pretend we found it in a PARAM already 1845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 18502772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 1865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Turn the attributes of the <object> element into arrays, but don't override <param> values. 1875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (hasAttributes()) { 1885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) for (unsigned i = 0; i < attributeCount(); ++i) { 1895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const Attribute* attribute = attributeItem(i); 1905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const AtomicString& name = attribute->name().localName(); 1915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!uniqueParamNames.contains(name.impl())) { 1925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) paramNames.append(name.string()); 1935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) paramValues.append(attribute->value().string()); 1945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 19702772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 1985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) mapDataParamToSrc(¶mNames, ¶mValues); 19902772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 2005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // HTML5 says that an object resource's URL is specified by the object's data 2015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // attribute, not by a param element. However, for compatibility, allow the 2025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // resource's URL to be given by a param named "src", "movie", "code" or "url" 2035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // if we know that resource points to a plug-in. 2045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (url.isEmpty() && !urlParameter.isEmpty()) { 2058abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) KURL completedURL = document().completeURL(urlParameter); 206f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) bool useFallback; 207f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) if (shouldUsePlugin(completedURL, serviceType, false, useFallback)) 2085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) url = urlParameter; 2095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 2115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 21202772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 2135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)bool HTMLObjectElement::hasFallbackContent() const 2145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 2155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) for (Node* child = firstChild(); child; child = child->nextSibling()) { 2165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Ignore whitespace-only text, and <param> tags, any other content is fallback content. 2175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (child->isTextNode()) { 2185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!toText(child)->containsOnlyWhitespace()) 2195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return true; 2205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } else if (!child->hasTagName(paramTag)) 2215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return true; 2225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 2235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return false; 2245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 22502772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 2265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)bool HTMLObjectElement::shouldAllowQuickTimeClassIdQuirk() 2275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 2285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // This site-specific hack maintains compatibility with Mac OS X Wiki Server, 2295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // which embeds QuickTime movies using an object tag containing QuickTime's 2305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // ActiveX classid. Treat this classid as valid only if OS X Server's unique 2315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // 'generator' meta tag is present. Only apply this quirk if there is no 2325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // fallback content, which ensures the quirk will disable itself if Wiki 2335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Server is updated to generate an alternate embed tag as fallback content. 2341e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) if (!document().settings() 2351e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) || !document().settings()->needsSiteSpecificQuirks() 2365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) || hasFallbackContent() 2375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) || !equalIgnoringCase(classId(), "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B")) 2385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return false; 2395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2408abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) RefPtr<NodeList> metaElements = document().getElementsByTagName(HTMLNames::metaTag.localName()); 2415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) unsigned length = metaElements->length(); 2425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) for (unsigned i = 0; i < length; ++i) { 2435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ASSERT(metaElements->item(i)->isHTMLElement()); 2448abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) HTMLMetaElement* metaElement = toHTMLMetaElement(metaElements->item(i)); 2455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (equalIgnoringCase(metaElement->name(), "generator") && metaElement->content().startsWith("Mac OS X Server Web Services Server", false)) 2465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return true; 2475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 24802772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 2495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return false; 2505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 25102772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 2525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)bool HTMLObjectElement::hasValidClassId() 2535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 254f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) if (MIMETypeRegistry::isJavaAppletMIMEType(m_serviceType) && classId().startsWith("java:", false)) 2555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return true; 25602772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 2575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (shouldAllowQuickTimeClassIdQuirk()) 2585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return true; 2595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // HTML5 says that fallback content should be rendered if a non-empty 2615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // classid is specified for which the UA can't find a suitable plug-in. 2625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return classId().isEmpty(); 2635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 2645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// FIXME: This should be unified with HTMLEmbedElement::updateWidget and 266f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)// moved down into HTMLPluginElement.cpp 267a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)void HTMLObjectElement::updateWidgetInternal() 2685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 2695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ASSERT(!renderEmbeddedObject()->showsUnavailablePluginIndicator()); 2705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ASSERT(needsWidgetUpdate()); 2715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) setNeedsWidgetUpdate(false); 2725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // FIXME: This should ASSERT isFinishedParsingChildren() instead. 2735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!isFinishedParsingChildren()) 2745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 275926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 276926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) // FIXME: I'm not sure it's ever possible to get into updateWidget during a 277926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) // removal, but just in case we should avoid loading the frame to prevent 278926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) // security bugs. 27919cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles) if (!SubframeLoadingDisabler::canLoadFrame(*this)) 280926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return; 281926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 2825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) String url = this->url(); 283f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) String serviceType = m_serviceType; 2845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // FIXME: These should be joined into a PluginParameters class. 2865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Vector<String> paramNames; 2875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Vector<String> paramValues; 2885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) parametersForPlugin(paramNames, paramValues, url, serviceType); 2895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Note: url is modified above by parametersForPlugin. 2915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!allowedToLoadFrameURL(url)) 2925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 2935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool fallbackContent = hasFallbackContent(); 2955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) renderEmbeddedObject()->setHasFallbackContent(fallbackContent); 2965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) RefPtr<HTMLObjectElement> protect(this); // beforeload and plugin loading can make arbitrary DOM mutations. 29853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) bool beforeLoadAllowedLoad = dispatchBeforeLoadEvent(url); 2995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!renderer()) // Do not load the plugin if beforeload removed this element or its renderer. 3005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 3015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 302f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) bool success = beforeLoadAllowedLoad && hasValidClassId() && requestObject(url, serviceType, paramNames, paramValues); 3035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!success && fallbackContent) 3045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) renderFallbackContent(); 3055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3078abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)bool HTMLObjectElement::rendererIsNeeded(const RenderStyle& style) 3085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 3095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // FIXME: This check should not be needed, detached documents never render! 310f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) if (!document().frame()) 3115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return false; 312f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) return HTMLPlugInElement::rendererIsNeeded(style); 3135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)Node::InsertionNotificationRequest HTMLObjectElement::insertedInto(ContainerNode* insertionPoint) 3165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 317f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) HTMLPlugInElement::insertedInto(insertionPoint); 3185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) FormAssociatedElement::insertedInto(insertionPoint); 3195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return InsertionDone; 3205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)void HTMLObjectElement::removedFrom(ContainerNode* insertionPoint) 3235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 324f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) HTMLPlugInElement::removedFrom(insertionPoint); 3255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) FormAssociatedElement::removedFrom(insertionPoint); 3265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)void HTMLObjectElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) 3295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 3305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (inDocument() && !useFallbackContent()) { 3315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) setNeedsWidgetUpdate(true); 3325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) setNeedsStyleRecalc(); 3335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 334f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) HTMLPlugInElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); 3355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)bool HTMLObjectElement::isURLAttribute(const Attribute& attribute) const 3385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 339a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) return attribute.name() == codebaseAttr || attribute.name() == dataAttr 340a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) || (attribute.name() == usemapAttr && attribute.value().string()[0] != '#') 341a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) || HTMLPlugInElement::isURLAttribute(attribute); 3425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3448abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)const AtomicString HTMLObjectElement::imageSourceURL() const 3455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 346926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return getAttribute(dataAttr); 3475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 349e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles)// FIXME: Remove this hack. 350e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles)void HTMLObjectElement::reattachFallbackContent() 351e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles){ 352e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles) // This can happen inside of attach() in the middle of a recalcStyle so we need to 353e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles) // reattach synchronously here. 3548abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) if (document().inStyleRecalc()) 355e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles) reattach(); 356e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles) else 357f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) lazyReattachIfAttached(); 358e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles)} 359e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles) 3605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)void HTMLObjectElement::renderFallbackContent() 3615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 3625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (useFallbackContent()) 3635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 36402772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 3655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!inDocument()) 3665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 3675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Before we give up and use fallback content, check to see if this is a MIME type issue. 369fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch if (m_imageLoader && m_imageLoader->image() && m_imageLoader->image()->status() != Resource::LoadError) { 3705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) m_serviceType = m_imageLoader->image()->response().mimeType(); 3715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!isImageType()) { 3725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // If we don't think we have an image type anymore, then clear the image from the loader. 3735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) m_imageLoader->setImage(0); 374e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles) reattachFallbackContent(); 3755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return; 3765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 3775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 3785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) m_useFallbackContent = true; 3805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // FIXME: Style gets recalculated which is suboptimal. 382e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles) reattachFallbackContent(); 3835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 385a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)bool HTMLObjectElement::isExposed() const 38651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 387a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) // http://www.whatwg.org/specs/web-apps/current-work/#exposed 388a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) for (Node* ancestor = parentNode(); ancestor; ancestor = ancestor->parentNode()) { 389a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) if (ancestor->hasTagName(objectTag) && toHTMLObjectElement(ancestor)->isExposed()) 390a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) return false; 39151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) } 392a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) for (Node* node = firstChild(); node; node = NodeTraversal::next(*node, this)) { 393a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) if (node->hasTagName(objectTag) || node->hasTagName(embedTag)) 394a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) return false; 39551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) } 396a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) return true; 39751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 39851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 3995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)bool HTMLObjectElement::containsJavaApplet() const 4005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 4015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (MIMETypeRegistry::isJavaAppletMIMEType(getAttribute(typeAttr))) 4025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return true; 40302772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 40451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) for (Element* child = ElementTraversal::firstWithin(*this); child; child = ElementTraversal::nextSkippingChildren(*child, this)) { 4055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (child->hasTagName(paramTag) 4065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) && equalIgnoringCase(child->getNameAttribute(), "type") 4075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) && MIMETypeRegistry::isJavaAppletMIMEType(child->getAttribute(valueAttr).string())) 4085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return true; 409e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles) if (child->hasTagName(objectTag) && toHTMLObjectElement(child)->containsJavaApplet()) 4105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return true; 4115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (child->hasTagName(appletTag)) 4125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return true; 4135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 41402772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 4155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return false; 4165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)void HTMLObjectElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const 4195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 420f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) HTMLPlugInElement::addSubresourceAttributeURLs(urls); 4215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4228abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) addSubresourceURL(urls, document().completeURL(getAttribute(dataAttr))); 4235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // FIXME: Passing a string that starts with "#" to the completeURL function does 4255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // not seem like it would work. The image element has similar but not identical code. 4265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const AtomicString& useMap = getAttribute(usemapAttr); 4275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (useMap.startsWith('#')) 4288abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) addSubresourceURL(urls, document().completeURL(useMap)); 4295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4311e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)void HTMLObjectElement::didMoveToNewDocument(Document& oldDocument) 4325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 4335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) FormAssociatedElement::didMoveToNewDocument(oldDocument); 434f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) HTMLPlugInElement::didMoveToNewDocument(oldDocument); 4355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)bool HTMLObjectElement::appendFormData(FormDataList& encoding, bool) 4385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 4395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (name().isEmpty()) 4405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return false; 4415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Widget* widget = pluginWidget(); 44353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) if (!widget || !widget->isPluginView()) 4445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return false; 4455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) String value; 44653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) if (!toPluginView(widget)->getFormValue(value)) 4475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return false; 4485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) encoding.appendData(name(), value); 4495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return true; 4505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 452e08f70592b3fc0d5e68b9b914c9196e813720070Torne (Richard Coles)HTMLFormElement* HTMLObjectElement::formOwner() const 4535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){ 4545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return FormAssociatedElement::form(); 4555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 457bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)bool HTMLObjectElement::isInteractiveContent() const 458bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles){ 459bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles) return fastHasAttribute(usemapAttr); 460bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)} 461bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles) 462a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)bool HTMLObjectElement::useFallbackContent() const 463a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles){ 464a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) return HTMLPlugInElement::useFallbackContent() || m_useFallbackContent; 465a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)} 466a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) 4675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 468