2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-10-10 22:50:08 -07:00
|
|
|
|
2013-02-22 16:59:26 -08:00
|
|
|
#include "mozilla/dom/HTMLIFrameElement.h"
|
2013-02-27 07:38:32 -08:00
|
|
|
#include "mozilla/dom/HTMLIFrameElementBinding.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsMappedAttributes.h"
|
2012-09-30 09:40:24 -07:00
|
|
|
#include "nsAttrValueInlines.h"
|
2012-07-27 07:03:27 -07:00
|
|
|
#include "nsError.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsRuleData.h"
|
2007-04-28 09:01:24 -07:00
|
|
|
#include "nsStyleConsts.h"
|
2013-01-23 11:39:03 -08:00
|
|
|
#include "nsContentUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-17 07:13:55 -07:00
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(IFrame)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-22 16:59:26 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-06-19 19:01:40 -07:00
|
|
|
HTMLIFrameElement::HTMLIFrameElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
2013-02-22 16:59:26 -08:00
|
|
|
FromParser aFromParser)
|
2010-08-17 07:13:55 -07:00
|
|
|
: nsGenericHTMLFrameElement(aNodeInfo, aFromParser)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-02-22 16:59:26 -08:00
|
|
|
HTMLIFrameElement::~HTMLIFrameElement()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(HTMLIFrameElement, nsGenericHTMLFrameElement,
|
|
|
|
nsIDOMHTMLIFrameElement)
|
2008-02-21 12:39:20 -08:00
|
|
|
|
2013-02-22 16:59:26 -08:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLIFrameElement)
|
|
|
|
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLIFrameElement, Align, align)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLIFrameElement, FrameBorder, frameborder)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLIFrameElement, Height, height)
|
|
|
|
NS_IMPL_URI_ATTR(HTMLIFrameElement, LongDesc, longdesc)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLIFrameElement, MarginHeight, marginheight)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLIFrameElement, MarginWidth, marginwidth)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLIFrameElement, Name, name)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLIFrameElement, Scrolling, scrolling)
|
|
|
|
NS_IMPL_URI_ATTR(HTMLIFrameElement, Src, src)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLIFrameElement, Width, width)
|
2013-02-25 17:59:33 -08:00
|
|
|
NS_IMPL_BOOL_ATTR(HTMLIFrameElement, AllowFullscreen, allowfullscreen)
|
2013-06-28 20:13:23 -07:00
|
|
|
NS_IMPL_STRING_ATTR(HTMLIFrameElement, Srcdoc, srcdoc)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-04 16:49:57 -07:00
|
|
|
void
|
2013-02-22 16:59:26 -08:00
|
|
|
HTMLIFrameElement::GetItemValueText(nsAString& aValue)
|
2012-06-04 16:49:57 -07:00
|
|
|
{
|
|
|
|
GetSrc(aValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-02-22 16:59:26 -08:00
|
|
|
HTMLIFrameElement::SetItemValueText(const nsAString& aValue)
|
2012-06-04 16:49:57 -07:00
|
|
|
{
|
|
|
|
SetSrc(aValue);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP
|
2013-02-22 16:59:26 -08:00
|
|
|
HTMLIFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return nsGenericHTMLFrameElement::GetContentDocument(aContentDocument);
|
|
|
|
}
|
|
|
|
|
2011-10-15 00:34:31 -07:00
|
|
|
NS_IMETHODIMP
|
2013-02-22 16:59:26 -08:00
|
|
|
HTMLIFrameElement::GetContentWindow(nsIDOMWindow** aContentWindow)
|
2011-10-15 00:34:31 -07:00
|
|
|
{
|
|
|
|
return nsGenericHTMLFrameElement::GetContentWindow(aContentWindow);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2013-02-22 16:59:26 -08:00
|
|
|
HTMLIFrameElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
|
|
|
if (aAttribute == nsGkAtoms::marginwidth) {
|
2011-02-04 11:46:16 -08:00
|
|
|
return aResult.ParseSpecialIntValue(aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (aAttribute == nsGkAtoms::marginheight) {
|
2011-02-04 11:46:16 -08:00
|
|
|
return aResult.ParseSpecialIntValue(aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (aAttribute == nsGkAtoms::width) {
|
2011-02-04 11:46:16 -08:00
|
|
|
return aResult.ParseSpecialIntValue(aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (aAttribute == nsGkAtoms::height) {
|
2011-02-04 11:46:16 -08:00
|
|
|
return aResult.ParseSpecialIntValue(aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (aAttribute == nsGkAtoms::frameborder) {
|
|
|
|
return ParseFrameborderValue(aValue, aResult);
|
|
|
|
}
|
|
|
|
if (aAttribute == nsGkAtoms::scrolling) {
|
|
|
|
return ParseScrollingValue(aValue, aResult);
|
|
|
|
}
|
|
|
|
if (aAttribute == nsGkAtoms::align) {
|
|
|
|
return ParseAlignValue(aValue, aResult);
|
|
|
|
}
|
2013-12-18 13:42:24 -08:00
|
|
|
if (aAttribute == nsGkAtoms::sandbox) {
|
|
|
|
aResult.ParseAtomArray(aValue);
|
|
|
|
return true;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return nsGenericHTMLFrameElement::ParseAttribute(aNamespaceID, aAttribute,
|
|
|
|
aValue, aResult);
|
|
|
|
}
|
|
|
|
|
2013-11-19 11:21:29 -08:00
|
|
|
void
|
|
|
|
HTMLIFrameElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|
|
|
nsRuleData* aData)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2007-10-08 14:58:22 -07:00
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Border)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// frameborder: 0 | 1 (| NO | YES in quirks mode)
|
|
|
|
// If frameborder is 0 or No, set border to 0
|
|
|
|
// else leave it as the value set in html.css
|
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::frameborder);
|
|
|
|
if (value && value->Type() == nsAttrValue::eEnum) {
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t frameborder = value->GetEnumValue();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (NS_STYLE_FRAME_0 == frameborder ||
|
|
|
|
NS_STYLE_FRAME_NO == frameborder ||
|
|
|
|
NS_STYLE_FRAME_OFF == frameborder) {
|
2011-03-17 20:14:31 -07:00
|
|
|
nsCSSValue* borderLeftWidth = aData->ValueForBorderLeftWidthValue();
|
|
|
|
if (borderLeftWidth->GetUnit() == eCSSUnit_Null)
|
|
|
|
borderLeftWidth->SetFloatValue(0.0f, eCSSUnit_Pixel);
|
|
|
|
nsCSSValue* borderRightWidth = aData->ValueForBorderRightWidthValue();
|
|
|
|
if (borderRightWidth->GetUnit() == eCSSUnit_Null)
|
|
|
|
borderRightWidth->SetFloatValue(0.0f, eCSSUnit_Pixel);
|
|
|
|
nsCSSValue* borderTopWidth = aData->ValueForBorderTopWidth();
|
|
|
|
if (borderTopWidth->GetUnit() == eCSSUnit_Null)
|
|
|
|
borderTopWidth->SetFloatValue(0.0f, eCSSUnit_Pixel);
|
|
|
|
nsCSSValue* borderBottomWidth = aData->ValueForBorderBottomWidth();
|
|
|
|
if (borderBottomWidth->GetUnit() == eCSSUnit_Null)
|
|
|
|
borderBottomWidth->SetFloatValue(0.0f, eCSSUnit_Pixel);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-08 14:58:22 -07:00
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// width: value
|
2011-03-17 20:14:31 -07:00
|
|
|
nsCSSValue* width = aData->ValueForWidth();
|
|
|
|
if (width->GetUnit() == eCSSUnit_Null) {
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
|
|
|
|
if (value && value->Type() == nsAttrValue::eInteger)
|
2011-03-17 20:14:31 -07:00
|
|
|
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
2007-03-22 10:30:00 -07:00
|
|
|
else if (value && value->Type() == nsAttrValue::ePercent)
|
2011-03-17 20:14:31 -07:00
|
|
|
width->SetPercentValue(value->GetPercentValue());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// height: value
|
2011-03-17 20:14:31 -07:00
|
|
|
nsCSSValue* height = aData->ValueForHeight();
|
|
|
|
if (height->GetUnit() == eCSSUnit_Null) {
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
|
|
|
|
if (value && value->Type() == nsAttrValue::eInteger)
|
2011-03-17 20:14:31 -07:00
|
|
|
height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
2007-03-22 10:30:00 -07:00
|
|
|
else if (value && value->Type() == nsAttrValue::ePercent)
|
2011-03-17 20:14:31 -07:00
|
|
|
height->SetPercentValue(value->GetPercentValue());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGenericHTMLElement::MapImageAlignAttributeInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHODIMP_(bool)
|
2013-02-22 16:59:26 -08:00
|
|
|
HTMLIFrameElement::IsAttributeMapped(const nsIAtom* aAttribute) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
static const MappedAttributeEntry attributes[] = {
|
|
|
|
{ &nsGkAtoms::width },
|
|
|
|
{ &nsGkAtoms::height },
|
|
|
|
{ &nsGkAtoms::frameborder },
|
2012-07-30 07:20:58 -07:00
|
|
|
{ nullptr },
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
|
|
attributes,
|
|
|
|
sImageAlignAttributeMap,
|
|
|
|
sCommonAttributeMap,
|
|
|
|
};
|
|
|
|
|
2011-12-18 02:09:27 -08:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nsMapRuleToAttributesFunc
|
2013-02-22 16:59:26 -08:00
|
|
|
HTMLIFrameElement::GetAttributeMappingFunction() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return &MapAttributesIntoRule;
|
|
|
|
}
|
|
|
|
|
2013-06-28 20:13:23 -07:00
|
|
|
nsresult
|
|
|
|
HTMLIFrameElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
|
|
nsIAtom* aPrefix, const nsAString& aValue,
|
|
|
|
bool aNotify)
|
|
|
|
{
|
|
|
|
nsresult rv = nsGenericHTMLFrameElement::SetAttr(aNameSpaceID, aName,
|
|
|
|
aPrefix, aValue, aNotify);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::srcdoc) {
|
|
|
|
// Don't propagate error here. The attribute was successfully set, that's
|
|
|
|
// what we should reflect.
|
|
|
|
LoadSrc();
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-20 11:34:32 -07:00
|
|
|
nsresult
|
2013-02-22 16:59:26 -08:00
|
|
|
HTMLIFrameElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
|
|
const nsAttrValue* aValue,
|
|
|
|
bool aNotify)
|
2012-08-20 11:34:32 -07:00
|
|
|
{
|
2013-12-18 13:42:24 -08:00
|
|
|
if (aName == nsGkAtoms::sandbox && aNameSpaceID == kNameSpaceID_None && mFrameLoader) {
|
|
|
|
// If we have an nsFrameLoader, apply the new sandbox flags.
|
|
|
|
// Since this is called after the setter, the sandbox flags have
|
|
|
|
// alreay been updated.
|
|
|
|
mFrameLoader->ApplySandboxFlags(GetSandboxFlags());
|
2012-08-20 11:34:32 -07:00
|
|
|
}
|
2014-01-11 20:05:49 -08:00
|
|
|
return nsGenericHTMLFrameElement::AfterSetAttr(aNameSpaceID, aName, aValue,
|
|
|
|
aNotify);
|
2013-01-23 11:39:03 -08:00
|
|
|
}
|
|
|
|
|
2013-06-28 20:13:23 -07:00
|
|
|
nsresult
|
|
|
|
HTMLIFrameElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
|
|
|
bool aNotify)
|
|
|
|
{
|
|
|
|
// Invoke on the superclass.
|
|
|
|
nsresult rv = nsGenericHTMLFrameElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (aNameSpaceID == kNameSpaceID_None &&
|
|
|
|
aAttribute == nsGkAtoms::srcdoc) {
|
|
|
|
// Fall back to the src attribute, if any
|
|
|
|
LoadSrc();
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-01-23 11:39:03 -08:00
|
|
|
uint32_t
|
2013-02-22 16:59:26 -08:00
|
|
|
HTMLIFrameElement::GetSandboxFlags()
|
2013-01-23 11:39:03 -08:00
|
|
|
{
|
2013-12-19 13:35:25 -08:00
|
|
|
const nsAttrValue* sandboxAttr = GetParsedAttr(nsGkAtoms::sandbox);
|
|
|
|
return nsContentUtils::ParseSandboxAttributeToFlags(sandboxAttr);
|
2012-08-20 11:34:32 -07:00
|
|
|
}
|
2013-02-22 16:59:26 -08:00
|
|
|
|
2013-02-27 07:38:32 -08:00
|
|
|
JSObject*
|
2014-04-08 15:27:17 -07:00
|
|
|
HTMLIFrameElement::WrapNode(JSContext* aCx)
|
2013-02-27 07:38:32 -08:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 15:27:17 -07:00
|
|
|
return HTMLIFrameElementBinding::Wrap(aCx, this);
|
2013-02-27 07:38:32 -08:00
|
|
|
}
|
|
|
|
|
2013-02-22 16:59:26 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|