summaryrefslogtreecommitdiffstats
path: root/WebCore/html/HTMLEmbedElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/html/HTMLEmbedElement.cpp')
-rw-r--r--WebCore/html/HTMLEmbedElement.cpp163
1 files changed, 89 insertions, 74 deletions
diff --git a/WebCore/html/HTMLEmbedElement.cpp b/WebCore/html/HTMLEmbedElement.cpp
index eb449fc..7ffe3b1 100644
--- a/WebCore/html/HTMLEmbedElement.cpp
+++ b/WebCore/html/HTMLEmbedElement.cpp
@@ -1,11 +1,9 @@
-/**
- * This file is part of the DOM implementation for KDE.
- *
+/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Stefan Schimanski (1Stein@gmx.de)
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
- * Copyright (C) 2007 Trolltech ASA
+ * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -22,24 +20,28 @@
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
+
#include "config.h"
#include "HTMLEmbedElement.h"
#include "CSSHelper.h"
#include "CSSPropertyNames.h"
#include "Frame.h"
-#include "FrameView.h"
#include "HTMLDocument.h"
-#include "HTMLObjectElement.h"
+#include "HTMLImageLoader.h"
#include "HTMLNames.h"
+#include "HTMLObjectElement.h"
+#include "RenderImage.h"
#include "RenderPartObject.h"
+#include "RenderWidget.h"
+#include "ScriptController.h"
namespace WebCore {
using namespace HTMLNames;
HTMLEmbedElement::HTMLEmbedElement(Document* doc)
- : HTMLPlugInElement(embedTag, doc)
+ : HTMLPlugInImageElement(embedTag, doc)
, m_needWidgetUpdate(false)
{
}
@@ -48,52 +50,36 @@ HTMLEmbedElement::~HTMLEmbedElement()
{
#ifdef ANDROID_FIX
// addressing webkit bug, http://bugs.webkit.org/show_bug.cgi?id=16512
- // ensure the oldNameAttr and oldIdAttr are removed from HTMLDocument's NameCountMap
+ // ensure that m_name is removed from HTMLDocument's NameCountMap
if (oldNameIdCount && document()->isHTMLDocument()) {
HTMLDocument* doc = static_cast<HTMLDocument*>(document());
- doc->removeNamedItem(oldNameAttr);
+ doc->removeNamedItem(m_name);
}
#endif
-
-#if USE(JAVASCRIPTCORE_BINDINGS)
- // m_instance should have been cleaned up in detach().
- ASSERT(!m_instance);
-#endif
}
-#if USE(JAVASCRIPTCORE_BINDINGS)
static inline RenderWidget* findWidgetRenderer(const Node* n)
{
if (!n->renderer())
do
n = n->parentNode();
while (n && !n->hasTagName(objectTag));
-
- return (n && n->renderer() && n->renderer()->isWidget())
- ? static_cast<RenderWidget*>(n->renderer()) : 0;
+
+ if (n && n->renderer() && n->renderer()->isWidget())
+ return static_cast<RenderWidget*>(n->renderer());
+
+ return 0;
}
-
-KJS::Bindings::Instance *HTMLEmbedElement::getInstance() const
-{
- Frame* frame = document()->frame();
- if (!frame)
- return 0;
- if (m_instance)
- return m_instance.get();
-
+RenderWidget* HTMLEmbedElement::renderWidgetForJSBindings() const
+{
RenderWidget* renderWidget = findWidgetRenderer(this);
if (renderWidget && !renderWidget->widget()) {
document()->updateLayoutIgnorePendingStylesheets();
renderWidget = findWidgetRenderer(this);
}
-
- if (renderWidget && renderWidget->widget())
- m_instance = frame->createScriptInstanceForWidget(renderWidget->widget());
-
- return m_instance.get();
+ return renderWidget;
}
-#endif
bool HTMLEmbedElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
{
@@ -107,42 +93,54 @@ bool HTMLEmbedElement::mapToEntry(const QualifiedName& attrName, MappedAttribute
void HTMLEmbedElement::parseMappedAttribute(MappedAttribute* attr)
{
- String val = attr->value();
+ const AtomicString& value = attr->value();
if (attr->name() == typeAttr) {
- m_serviceType = val.lower();
+ m_serviceType = value.string().lower();
int pos = m_serviceType.find(";");
if (pos != -1)
m_serviceType = m_serviceType.left(pos);
- } else if (attr->name() == codeAttr || attr->name() == srcAttr)
- url = parseURL(val).deprecatedString();
- else if (attr->name() == pluginpageAttr || attr->name() == pluginspageAttr)
- m_pluginPage = val;
+ if (!isImageType() && m_imageLoader)
+ m_imageLoader.clear();
+ } else if (attr->name() == codeAttr)
+ m_url = parseURL(value.string());
+ else if (attr->name() == srcAttr) {
+ m_url = parseURL(value.string());
+ if (renderer() && isImageType()) {
+ if (!m_imageLoader)
+ m_imageLoader.set(new HTMLImageLoader(this));
+ m_imageLoader->updateFromElement();
+ }
+ } else if (attr->name() == pluginpageAttr || attr->name() == pluginspageAttr)
+ m_pluginPage = value;
else if (attr->name() == hiddenAttr) {
- if (val.lower() == "yes" || val.lower() == "true") {
- // FIXME: Not dynamic, but it's not really important that such a rarely-used
- // feature work dynamically.
- addCSSLength(attr, CSS_PROP_WIDTH, "0");
- addCSSLength(attr, CSS_PROP_HEIGHT, "0");
+ if (equalIgnoringCase(value.string(), "yes") || equalIgnoringCase(value.string(), "true")) {
+ // FIXME: Not dynamic, since we add this but don't remove it, but it may be OK for now
+ // that this rarely-used attribute won't work properly if you remove it.
+ addCSSLength(attr, CSSPropertyWidth, "0");
+ addCSSLength(attr, CSSPropertyHeight, "0");
}
} else if (attr->name() == nameAttr) {
if (inDocument() && document()->isHTMLDocument()) {
- HTMLDocument* doc = static_cast<HTMLDocument*>(document());
- doc->removeNamedItem(oldNameAttr);
- doc->addNamedItem(val);
+ HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
+ document->removeNamedItem(m_name);
+ document->addNamedItem(value);
}
- oldNameAttr = val;
+ m_name = value;
} else
HTMLPlugInElement::parseMappedAttribute(attr);
}
-bool HTMLEmbedElement::rendererIsNeeded(RenderStyle *style)
+bool HTMLEmbedElement::rendererIsNeeded(RenderStyle* style)
{
- Frame *frame = document()->frame();
+ if (isImageType())
+ return HTMLPlugInElement::rendererIsNeeded(style);
+
+ Frame* frame = document()->frame();
if (!frame)
return false;
- Node *p = parentNode();
+ Node* p = parentNode();
if (p && p->hasTagName(objectTag)) {
ASSERT(p->renderer());
return false;
@@ -151,43 +149,51 @@ bool HTMLEmbedElement::rendererIsNeeded(RenderStyle *style)
return true;
}
-RenderObject *HTMLEmbedElement::createRenderer(RenderArena *arena, RenderStyle *style)
+RenderObject* HTMLEmbedElement::createRenderer(RenderArena* arena, RenderStyle* style)
{
+ if (isImageType())
+ return new (arena) RenderImage(this);
return new (arena) RenderPartObject(this);
}
void HTMLEmbedElement::attach()
{
m_needWidgetUpdate = true;
- queuePostAttachCallback(&HTMLPlugInElement::updateWidgetCallback, this);
+
+ bool isImage = isImageType();
+
+ if (!isImage)
+ queuePostAttachCallback(&HTMLPlugInElement::updateWidgetCallback, this);
+
HTMLPlugInElement::attach();
-}
-void HTMLEmbedElement::detach()
-{
-#if USE(JAVASCRIPTCORE_BINDINGS)
- m_instance = 0;
-#endif
- HTMLPlugInElement::detach();
+ if (isImage && renderer()) {
+ if (!m_imageLoader)
+ m_imageLoader.set(new HTMLImageLoader(this));
+ m_imageLoader->updateFromElement();
+
+ if (renderer())
+ static_cast<RenderImage*>(renderer())->setCachedImage(m_imageLoader->image());
+ }
}
void HTMLEmbedElement::updateWidget()
{
- if (m_needWidgetUpdate && renderer())
+ document()->updateRendering();
+ if (m_needWidgetUpdate && renderer() && !isImageType())
static_cast<RenderPartObject*>(renderer())->updateWidget(true);
}
void HTMLEmbedElement::insertedIntoDocument()
{
- if (document()->isHTMLDocument()) {
- HTMLDocument *doc = static_cast<HTMLDocument *>(document());
- doc->addNamedItem(oldNameAttr);
+ if (document()->isHTMLDocument())
+ static_cast<HTMLDocument*>(document())->addNamedItem(m_name);
#ifdef ANDROID_FIX
- // addressing webkit bug, http://bugs.webkit.org/show_bug.cgi?id=16512
- // ensure the oldNameAttr and oldIdAttr are removed from HTMLDocument's NameCountMap
+ // addressing webkit bug, http://bugs.webkit.org/show_bug.cgi?id=16512
+ // ensure that m_name is removed from HTMLDocument's NameCountMap
+ if (document()->isHTMLDocument())
oldNameIdCount++;
#endif
- }
String width = getAttribute(widthAttr);
String height = getAttribute(heightAttr);
@@ -208,15 +214,14 @@ void HTMLEmbedElement::insertedIntoDocument()
void HTMLEmbedElement::removedFromDocument()
{
- if (document()->isHTMLDocument()) {
- HTMLDocument *doc = static_cast<HTMLDocument *>(document());
- doc->removeNamedItem(oldNameAttr);
+ if (document()->isHTMLDocument())
+ static_cast<HTMLDocument*>(document())->removeNamedItem(m_name);
#ifdef ANDROID_FIX
// addressing webkit bug, http://bugs.webkit.org/show_bug.cgi?id=16512
- // ensure the oldNameAttr and oldIdAttr are removed from HTMLDocument's NameCountMap
+ // ensure that m_name is removed from HTMLDocument's NameCountMap
+ if (document()->isHTMLDocument())
oldNameIdCount--;
#endif
- }
HTMLPlugInElement::removedFromDocument();
}
@@ -234,11 +239,16 @@ void HTMLEmbedElement::attributeChanged(Attribute* attr, bool preserveDecls)
}
}
-bool HTMLEmbedElement::isURLAttribute(Attribute *attr) const
+bool HTMLEmbedElement::isURLAttribute(Attribute* attr) const
{
return attr->name() == srcAttr;
}
+const QualifiedName& HTMLEmbedElement::imageSourceAttributeName() const
+{
+ return srcAttr;
+}
+
String HTMLEmbedElement::src() const
{
return getAttribute(srcAttr);
@@ -259,4 +269,9 @@ void HTMLEmbedElement::setType(const String& value)
setAttribute(typeAttr, value);
}
+void HTMLEmbedElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+ urls.append(src());
+}
+
}