HTMLStyleElement.cpp [plain text]
#include "config.h"
#include "HTMLStyleElement.h"
#include "Document.h"
#include "HTMLNames.h"
namespace WebCore {
using namespace HTMLNames;
HTMLStyleElement::HTMLStyleElement(Document* doc)
: HTMLElement(styleTag, doc)
, m_loading(false)
, m_createdByParser(false)
{
}
void HTMLStyleElement::parseMappedAttribute(MappedAttribute *attr)
{
if (attr->name() == mediaAttr)
m_media = attr->value().domString().lower();
else if (attr->name() == titleAttr && m_sheet)
m_sheet->setTitle(attr->value());
else
HTMLElement::parseMappedAttribute(attr);
}
void HTMLStyleElement::finishParsingChildren()
{
StyleElement::sheet(this);
m_createdByParser = false;
HTMLElement::finishParsingChildren();
}
void HTMLStyleElement::insertedIntoDocument()
{
HTMLElement::insertedIntoDocument();
if (!m_createdByParser)
StyleElement::insertedIntoDocument(document(), this);
}
void HTMLStyleElement::removedFromDocument()
{
HTMLElement::removedFromDocument();
StyleElement::removedFromDocument(document());
}
void HTMLStyleElement::childrenChanged(bool changedByParser)
{
StyleElement::process(this);
HTMLElement::childrenChanged(changedByParser);
}
StyleSheet* HTMLStyleElement::sheet()
{
return StyleElement::sheet(this);
}
bool HTMLStyleElement::isLoading() const
{
if (m_loading)
return true;
if (!m_sheet)
return false;
return static_cast<CSSStyleSheet *>(m_sheet.get())->isLoading();
}
bool HTMLStyleElement::sheetLoaded()
{
if (!isLoading()) {
document()->removePendingSheet();
return true;
}
return false;
}
bool HTMLStyleElement::disabled() const
{
return !getAttribute(disabledAttr).isNull();
}
void HTMLStyleElement::setDisabled(bool disabled)
{
setAttribute(disabledAttr, disabled ? "" : 0);
}
const AtomicString& HTMLStyleElement::media() const
{
return getAttribute(mediaAttr);
}
void HTMLStyleElement::setMedia(const AtomicString &value)
{
setAttribute(mediaAttr, value);
}
const AtomicString& HTMLStyleElement::type() const
{
return getAttribute(typeAttr);
}
void HTMLStyleElement::setType(const AtomicString &value)
{
setAttribute(typeAttr, value);
}
}