HTMLIFrameElement.cpp [plain text]
#include "config.h"
#include "HTMLIFrameElement.h"
#include "CSSPropertyNames.h"
#include "Frame.h"
#include "HTMLDocument.h"
#include "HTMLNames.h"
#include "RenderPartObject.h"
namespace WebCore {
using namespace HTMLNames;
HTMLIFrameElement::HTMLIFrameElement(Document* doc)
: HTMLFrameElementBase(iframeTag, doc)
{
}
bool HTMLIFrameElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
{
if (attrName == widthAttr || attrName == heightAttr) {
result = eUniversal;
return false;
}
if (attrName == alignAttr) {
result = eReplaced; return false;
}
if (attrName == frameborderAttr) {
result = eReplaced;
return false;
}
return HTMLFrameElementBase::mapToEntry(attrName, result);
}
void HTMLIFrameElement::parseMappedAttribute(MappedAttribute *attr)
{
if (attr->name() == widthAttr)
addCSSLength(attr, CSS_PROP_WIDTH, attr->value());
else if (attr->name() == heightAttr)
addCSSLength(attr, CSS_PROP_HEIGHT, attr->value());
else if (attr->name() == alignAttr)
addHTMLAlignment(attr);
else if (attr->name() == nameAttr) {
String newNameAttr = attr->value();
if (inDocument() && document()->isHTMLDocument()) {
HTMLDocument* doc = static_cast<HTMLDocument* >(document());
doc->removeDocExtraNamedItem(oldNameAttr);
doc->addDocExtraNamedItem(newNameAttr);
}
oldNameAttr = newNameAttr;
} else if (attr->name() == frameborderAttr) {
if (!attr->isNull() && !attr->value().toInt())
addCSSLength(attr, CSS_PROP_BORDER_WIDTH, "0");
} else
HTMLFrameElementBase::parseMappedAttribute(attr);
}
bool HTMLIFrameElement::rendererIsNeeded(RenderStyle* style)
{
return isURLAllowed(m_URL) && style->display() != NONE;
}
RenderObject* HTMLIFrameElement::createRenderer(RenderArena* arena, RenderStyle*)
{
return new (arena) RenderPartObject(this);
}
void HTMLIFrameElement::insertedIntoDocument()
{
if (document()->isHTMLDocument()) {
HTMLDocument* doc = static_cast<HTMLDocument*>(document());
doc->addDocExtraNamedItem(oldNameAttr);
}
HTMLFrameElementBase::insertedIntoDocument();
}
void HTMLIFrameElement::removedFromDocument()
{
if (document()->isHTMLDocument()) {
HTMLDocument* doc = static_cast<HTMLDocument*>(document());
doc->removeDocExtraNamedItem(oldNameAttr);
}
HTMLFrameElementBase::removedFromDocument();
}
void HTMLIFrameElement::attach()
{
HTMLFrameElementBase::attach();
if (RenderPartObject* renderPartObject = static_cast<RenderPartObject*>(renderer()))
renderPartObject->updateWidget(false);
}
bool HTMLIFrameElement::isURLAttribute(Attribute* attr) const
{
return attr->name() == srcAttr;
}
String HTMLIFrameElement::align() const
{
return getAttribute(alignAttr);
}
void HTMLIFrameElement::setAlign(const String &value)
{
setAttribute(alignAttr, value);
}
String HTMLIFrameElement::height() const
{
return getAttribute(heightAttr);
}
void HTMLIFrameElement::setHeight(const String &value)
{
setAttribute(heightAttr, value);
}
String HTMLIFrameElement::width() const
{
return getAttribute(widthAttr);
}
void HTMLIFrameElement::setWidth(const String &value)
{
setAttribute(widthAttr, value);
}
}