HTMLIFrameElement.cpp [plain text]
#include "config.h"
#include "HTMLIFrameElement.h"
#include "CSSPropertyNames.h"
#include "DOMTokenList.h"
#include "Frame.h"
#include "HTMLDocument.h"
#include "HTMLNames.h"
#include "RenderIFrame.h"
#include "ScriptableDocumentParser.h"
namespace WebCore {
using namespace HTMLNames;
inline HTMLIFrameElement::HTMLIFrameElement(const QualifiedName& tagName, Document& document)
: HTMLFrameElementBase(tagName, document)
{
ASSERT(hasTagName(iframeTag));
}
Ref<HTMLIFrameElement> HTMLIFrameElement::create(const QualifiedName& tagName, Document& document)
{
return adoptRef(*new HTMLIFrameElement(tagName, document));
}
DOMTokenList& HTMLIFrameElement::sandbox()
{
if (!m_sandbox)
m_sandbox = std::make_unique<DOMTokenList>(*this, sandboxAttr, [](StringView token) {
return SecurityContext::isSupportedSandboxPolicy(token);
});
return *m_sandbox;
}
bool HTMLIFrameElement::isPresentationAttribute(const QualifiedName& name) const
{
if (name == widthAttr || name == heightAttr || name == alignAttr || name == frameborderAttr)
return true;
return HTMLFrameElementBase::isPresentationAttribute(name);
}
void HTMLIFrameElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStyleProperties& 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) {
if (m_sandbox)
m_sandbox->associatedAttributeValueChanged(value);
String invalidTokens;
setSandboxFlags(value.isNull() ? SandboxNone : SecurityContext::parseSandboxPolicy(value, invalidTokens));
if (!invalidTokens.isNull())
document().addConsoleMessage(MessageSource::Other, MessageLevel::Error, "Error while parsing the 'sandbox' attribute: " + invalidTokens);
} else
HTMLFrameElementBase::parseAttribute(name, value);
}
bool HTMLIFrameElement::rendererIsNeeded(const RenderStyle& style)
{
return isURLAllowed() && style.display() != NONE;
}
RenderPtr<RenderElement> HTMLIFrameElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
{
return createRenderer<RenderIFrame>(*this, WTFMove(style));
}
}