HTMLIFrameElement.cpp [plain text]
#include "config.h"
#include "HTMLIFrameElement.h"
#include "Attribute.h"
#include "CSSPropertyNames.h"
#include "Frame.h"
#include "HTMLDocument.h"
#include "HTMLNames.h"
#include "NodeRenderingContext.h"
#include "RenderIFrame.h"
#include "ScriptableDocumentParser.h"
#include <wtf/text/TextPosition.h>
namespace WebCore {
using namespace HTMLNames;
inline HTMLIFrameElement::HTMLIFrameElement(const QualifiedName& tagName, Document* document)
: HTMLFrameElementBase(tagName, document)
{
ASSERT(hasTagName(iframeTag));
setHasCustomStyleCallbacks();
}
PassRefPtr<HTMLIFrameElement> HTMLIFrameElement::create(const QualifiedName& tagName, Document* document)
{
return adoptRef(new HTMLIFrameElement(tagName, document));
}
bool HTMLIFrameElement::isPresentationAttribute(const QualifiedName& name) const
{
if (name == widthAttr || name == heightAttr || name == alignAttr || name == frameborderAttr || name == seamlessAttr)
return true;
return HTMLFrameElementBase::isPresentationAttribute(name);
}
void HTMLIFrameElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style)
{
if (name == widthAttr)
addHTMLLengthToStyle(style, CSSPropertyWidth, value);
else if (name == heightAttr)
addHTMLLengthToStyle(style, CSSPropertyHeight, value);
else if (name == alignAttr)
applyAlignmentAttributeToStyle(value, style);
else if (name == frameborderAttr) {
if (!value.toInt()) {
addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderWidth, 0, CSSPrimitiveValue::CSS_PX);
}
} else
HTMLFrameElementBase::collectStyleForPresentationAttribute(name, value, style);
}
void HTMLIFrameElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (name == sandboxAttr) {
String invalidTokens;
setSandboxFlags(value.isNull() ? SandboxNone : SecurityContext::parseSandboxPolicy(value, invalidTokens));
if (!invalidTokens.isNull())
document()->addConsoleMessage(OtherMessageSource, ErrorMessageLevel, "Error while parsing the 'sandbox' attribute: " + invalidTokens);
} else if (name == seamlessAttr) {
if (contentDocument())
contentDocument()->styleResolverChanged(DeferRecalcStyle);
} else
HTMLFrameElementBase::parseAttribute(name, value);
}
bool HTMLIFrameElement::rendererIsNeeded(const NodeRenderingContext& context)
{
return isURLAllowed() && context.style()->display() != NONE;
}
RenderObject* HTMLIFrameElement::createRenderer(RenderArena* arena, RenderStyle*)
{
return new (arena) RenderIFrame(this);
}
bool HTMLIFrameElement::shouldDisplaySeamlessly() const
{
return contentDocument() && contentDocument()->shouldDisplaySeamlesslyWithParent();
}
void HTMLIFrameElement::didRecalcStyle(StyleChange styleChange)
{
if (!shouldDisplaySeamlessly())
return;
Document* childDocument = contentDocument();
if (styleChange >= Inherit || childDocument->childNeedsStyleRecalc() || childDocument->needsStyleRecalc())
contentDocument()->recalcStyle(styleChange);
}
#if ENABLE(MICRODATA)
String HTMLIFrameElement::itemValueText() const
{
return getURLAttribute(srcAttr);
}
void HTMLIFrameElement::setItemValueText(const String& value, ExceptionCode&)
{
setAttribute(srcAttr, value);
}
#endif
}