HTMLFrameSetElement.cpp [plain text]
#include "config.h"
#include "HTMLFrameSetElement.h"
#include "Document.h"
#include "Event.h"
#include "EventNames.h"
#include "HTMLNames.h"
#include "Length.h"
#include "MouseEvent.h"
#include "RenderFrameSet.h"
namespace WebCore {
using namespace EventNames;
using namespace HTMLNames;
HTMLFrameSetElement::HTMLFrameSetElement(Document *doc)
: HTMLElement(framesetTag, doc)
, m_rows(0)
, m_cols(0)
, m_totalRows(1)
, m_totalCols(1)
, m_border(4)
, frameborder(true)
, frameBorderSet(false)
, noresize(false)
{
}
HTMLFrameSetElement::~HTMLFrameSetElement()
{
if (m_rows)
delete [] m_rows;
if (m_cols)
delete [] m_cols;
}
bool HTMLFrameSetElement::checkDTD(const Node* newChild)
{
return newChild->hasTagName(framesetTag) || newChild->hasTagName(frameTag);
}
void HTMLFrameSetElement::parseMappedAttribute(MappedAttribute *attr)
{
if (attr->name() == rowsAttr) {
if (!attr->isNull()) {
if (m_rows) delete [] m_rows;
m_rows = attr->value().toLengthArray(m_totalRows);
setChanged();
}
} else if (attr->name() == colsAttr) {
if (!attr->isNull()) {
delete [] m_cols;
m_cols = attr->value().toLengthArray(m_totalCols);
setChanged();
}
} else if (attr->name() == frameborderAttr) {
if (attr->value().toInt() == 0) {
frameborder = false;
m_border = 0;
}
frameBorderSet = true;
} else if (attr->name() == noresizeAttr) {
noresize = true;
} else if (attr->name() == borderAttr) {
m_border = attr->value().toInt();
if(!m_border)
frameborder = false;
} else if (attr->name() == onloadAttr) {
document()->setHTMLWindowEventListener(loadEvent, attr);
} else if (attr->name() == onbeforeunloadAttr) {
document()->setHTMLWindowEventListener(beforeunloadEvent, attr);
} else if (attr->name() == onunloadAttr) {
document()->setHTMLWindowEventListener(unloadEvent, attr);
} else
HTMLElement::parseMappedAttribute(attr);
}
bool HTMLFrameSetElement::rendererIsNeeded(RenderStyle *style)
{
return style->isStyleAvailable();
}
RenderObject *HTMLFrameSetElement::createRenderer(RenderArena *arena, RenderStyle *style)
{
if (style->contentData())
return RenderObject::createObject(this, style);
return new (arena) RenderFrameSet(this);
}
void HTMLFrameSetElement::attach()
{
HTMLElement* node = static_cast<HTMLElement*>(parentNode());
while (node) {
if (node->hasTagName(framesetTag)) {
HTMLFrameSetElement* frameset = static_cast<HTMLFrameSetElement*>(node);
if(!frameBorderSet) frameborder = frameset->frameBorder();
if(!noresize) noresize = frameset->noResize();
break;
}
node = static_cast<HTMLElement*>(node->parentNode());
}
HTMLElement::attach();
}
void HTMLFrameSetElement::defaultEventHandler(Event* evt)
{
if (evt->isMouseEvent() && !noresize && renderer()) {
static_cast<RenderFrameSet*>(renderer())->userResize(static_cast<MouseEvent*>(evt));
evt->setDefaultHandled();
}
HTMLElement::defaultEventHandler(evt);
}
void HTMLFrameSetElement::recalcStyle(StyleChange ch)
{
if (changed() && renderer()) {
renderer()->setNeedsLayout(true);
setChanged(false);
}
HTMLElement::recalcStyle(ch);
}
String HTMLFrameSetElement::cols() const
{
return getAttribute(colsAttr);
}
void HTMLFrameSetElement::setCols(const String &value)
{
setAttribute(colsAttr, value);
}
String HTMLFrameSetElement::rows() const
{
return getAttribute(rowsAttr);
}
void HTMLFrameSetElement::setRows(const String &value)
{
setAttribute(rowsAttr, value);
}
}