2 * This file is part of the DOM implementation for KDE.
4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
5 * (C) 1999 Antti Koivisto (koivisto@kde.org)
6 * (C) 2000 Simon Hausmann (hausmann@kde.org)
7 * (C) 2001 Dirk Mueller (mueller@kde.org)
8 * Copyright (C) 2004, 2006 Apple Computer, Inc.
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details.
20 * You should have received a copy of the GNU Library General Public License
21 * along with this library; see the file COPYING.LIB. If not, write to
22 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 * Boston, MA 02111-1307, USA.
26 #include "HTMLIFrameElement.h"
28 #include "CSSPropertyNames.h"
30 #include "FrameTree.h"
31 #include "HTMLDocument.h"
32 #include "HTMLNames.h"
34 #include "RenderPartObject.h"
38 using namespace HTMLNames;
40 HTMLIFrameElement::HTMLIFrameElement(Document* doc)
41 : HTMLFrameElement(iframeTag, doc)
43 m_frameBorder = false;
46 HTMLIFrameElement::~HTMLIFrameElement()
50 bool HTMLIFrameElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
52 if (attrName == widthAttr || attrName == heightAttr) {
57 if (attrName == alignAttr) {
58 result = eReplaced; // Share with <img> since the alignment behavior is the same.
62 return HTMLFrameElement::mapToEntry(attrName, result);
65 void HTMLIFrameElement::parseMappedAttribute(MappedAttribute *attr)
67 if (attr->name() == widthAttr)
68 addCSSLength(attr, CSS_PROP_WIDTH, attr->value());
69 else if (attr->name() == heightAttr)
70 addCSSLength(attr, CSS_PROP_HEIGHT, attr->value());
71 else if (attr->name() == alignAttr)
72 addHTMLAlignment(attr);
73 else if (attr->name() == nameAttr) {
74 String newNameAttr = attr->value();
75 if (inDocument() && document()->isHTMLDocument()) {
76 HTMLDocument *doc = static_cast<HTMLDocument *>(document());
77 doc->removeDocExtraNamedItem(oldNameAttr);
78 doc->addDocExtraNamedItem(newNameAttr);
80 oldNameAttr = newNameAttr;
82 HTMLFrameElement::parseMappedAttribute(attr);
85 void HTMLIFrameElement::insertedIntoDocument()
87 HTMLFrameElement::insertedIntoDocument();
89 if (document()->isHTMLDocument()) {
90 HTMLDocument *doc = static_cast<HTMLDocument *>(document());
91 doc->addDocExtraNamedItem(oldNameAttr);
97 void HTMLIFrameElement::willRemove()
99 if (Frame* frame = contentFrame()) {
100 frame->disconnectOwnerElement();
101 frame->frameDetached();
102 ASSERT(!contentFrame());
105 HTMLElement::willRemove();
108 void HTMLIFrameElement::removedFromDocument()
110 if (document()->isHTMLDocument()) {
111 HTMLDocument *doc = static_cast<HTMLDocument *>(document());
112 doc->removeDocExtraNamedItem(oldNameAttr);
115 HTMLFrameElement::removedFromDocument();
118 bool HTMLIFrameElement::rendererIsNeeded(RenderStyle *style)
120 // Don't ignore display: none the way frame does.
121 return isURLAllowed(m_URL) && style->display() != NONE;
124 RenderObject *HTMLIFrameElement::createRenderer(RenderArena *arena, RenderStyle *style)
126 return new (arena) RenderPartObject(this);
129 void HTMLIFrameElement::attach()
131 HTMLFrameElement::attach();
133 if (RenderPartObject* renderPart = static_cast<RenderPartObject*>(renderer())) {
134 if (contentFrame()) {
135 renderPart->setWidget(contentFrame()->view());
136 renderPart->updateWidget();
141 void HTMLIFrameElement::detach()
143 HTMLElement::detach();
146 bool HTMLIFrameElement::isURLAttribute(Attribute *attr) const
148 return attr->name() == srcAttr;
151 String HTMLIFrameElement::align() const
153 return getAttribute(alignAttr);
156 void HTMLIFrameElement::setAlign(const String &value)
158 setAttribute(alignAttr, value);
161 String HTMLIFrameElement::height() const
163 return getAttribute(heightAttr);
166 void HTMLIFrameElement::setHeight(const String &value)
168 setAttribute(heightAttr, value);
171 String HTMLIFrameElement::width() const
173 return getAttribute(widthAttr);
176 void HTMLIFrameElement::setWidth(const String &value)
178 setAttribute(widthAttr, value);