Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format

# ignore-this-changeset
This commit is contained in:
Sylvestre Ledru
2018-11-30 11:46:48 +01:00
parent 93e0058268
commit e5a134f73a
10591 changed files with 1454100 additions and 1738928 deletions

View File

@@ -28,30 +28,22 @@ namespace dom {
//----------------------------------------------------------------------
HTMLBodyElement::~HTMLBodyElement()
{
}
HTMLBodyElement::~HTMLBodyElement() {}
JSObject*
HTMLBodyElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
{
JSObject* HTMLBodyElement::WrapNode(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
return HTMLBodyElement_Binding::Wrap(aCx, this, aGivenProto);
}
NS_IMPL_ELEMENT_CLONE(HTMLBodyElement)
bool
HTMLBodyElement::ParseAttribute(int32_t aNamespaceID,
nsAtom* aAttribute,
const nsAString& aValue,
nsIPrincipal* aMaybeScriptedPrincipal,
nsAttrValue& aResult)
{
bool HTMLBodyElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,
nsIPrincipal* aMaybeScriptedPrincipal,
nsAttrValue& aResult) {
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsGkAtoms::bgcolor ||
aAttribute == nsGkAtoms::text ||
aAttribute == nsGkAtoms::link ||
aAttribute == nsGkAtoms::alink ||
if (aAttribute == nsGkAtoms::bgcolor || aAttribute == nsGkAtoms::text ||
aAttribute == nsGkAtoms::link || aAttribute == nsGkAtoms::alink ||
aAttribute == nsGkAtoms::vlink) {
return aResult.ParseColor(aValue);
}
@@ -65,17 +57,14 @@ HTMLBodyElement::ParseAttribute(int32_t aNamespaceID,
}
}
return nsGenericHTMLElement::ParseBackgroundAttribute(aNamespaceID,
aAttribute, aValue,
aResult) ||
return nsGenericHTMLElement::ParseBackgroundAttribute(
aNamespaceID, aAttribute, aValue, aResult) ||
nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aMaybeScriptedPrincipal, aResult);
}
void
HTMLBodyElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
MappedDeclarations& aDecls)
{
void HTMLBodyElement::MapAttributesIntoRule(
const nsMappedAttributes* aAttributes, MappedDeclarations& aDecls) {
// This is the one place where we try to set the same property
// multiple times in presentation attributes. Servo does not support
// querying if a property is set (because that is O(n) behavior
@@ -84,7 +73,7 @@ HTMLBodyElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
// we set it to (which is used when handling margin
// attributes from the containing frame element)
int32_t bodyMarginWidth = -1;
int32_t bodyMarginWidth = -1;
int32_t bodyMarginHeight = -1;
int32_t bodyTopMargin = -1;
int32_t bodyBottomMargin = -1;
@@ -99,8 +88,10 @@ HTMLBodyElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (bodyMarginWidth < 0) {
bodyMarginWidth = 0;
}
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_left, (float)bodyMarginWidth);
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_right, (float)bodyMarginWidth);
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_left,
(float)bodyMarginWidth);
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_right,
(float)bodyMarginWidth);
}
value = aAttributes->GetAttr(nsGkAtoms::marginheight);
@@ -109,11 +100,13 @@ HTMLBodyElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (bodyMarginHeight < 0) {
bodyMarginHeight = 0;
}
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_top, (float)bodyMarginHeight);
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_bottom, (float)bodyMarginHeight);
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_top,
(float)bodyMarginHeight);
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_bottom,
(float)bodyMarginHeight);
}
// topmargin (IE-attribute)
// topmargin (IE-attribute)
if (bodyMarginHeight == -1) {
value = aAttributes->GetAttr(nsGkAtoms::topmargin);
if (value && value->Type() == nsAttrValue::eInteger) {
@@ -121,10 +114,11 @@ HTMLBodyElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (bodyTopMargin < 0) {
bodyTopMargin = 0;
}
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_top, (float)bodyTopMargin);
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_top,
(float)bodyTopMargin);
}
}
// bottommargin (IE-attribute)
// bottommargin (IE-attribute)
if (bodyMarginHeight == -1) {
value = aAttributes->GetAttr(nsGkAtoms::bottommargin);
@@ -133,11 +127,12 @@ HTMLBodyElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (bodyBottomMargin < 0) {
bodyBottomMargin = 0;
}
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_bottom, (float)bodyBottomMargin);
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_bottom,
(float)bodyBottomMargin);
}
}
// leftmargin (IE-attribute)
// leftmargin (IE-attribute)
if (bodyMarginWidth == -1) {
value = aAttributes->GetAttr(nsGkAtoms::leftmargin);
if (value && value->Type() == nsAttrValue::eInteger) {
@@ -145,10 +140,11 @@ HTMLBodyElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (bodyLeftMargin < 0) {
bodyLeftMargin = 0;
}
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_left, (float)bodyLeftMargin);
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_left,
(float)bodyLeftMargin);
}
}
// rightmargin (IE-attribute)
// rightmargin (IE-attribute)
if (bodyMarginWidth == -1) {
value = aAttributes->GetAttr(nsGkAtoms::rightmargin);
if (value && value->Type() == nsAttrValue::eInteger) {
@@ -156,42 +152,48 @@ HTMLBodyElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (bodyRightMargin < 0) {
bodyRightMargin = 0;
}
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_right, (float)bodyRightMargin);
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_right,
(float)bodyRightMargin);
}
}
// if marginwidth or marginheight is set in the <frame> and not set in the <body>
// reflect them as margin in the <body>
// if marginwidth or marginheight is set in the <frame> and not set in the
// <body> reflect them as margin in the <body>
if (bodyMarginWidth == -1 || bodyMarginHeight == -1) {
nsCOMPtr<nsIDocShell> docShell(aDecls.Document()->GetDocShell());
if (docShell) {
nscoord frameMarginWidth=-1; // default value
nscoord frameMarginHeight=-1; // default value
docShell->GetMarginWidth(&frameMarginWidth); // -1 indicates not set
nscoord frameMarginWidth = -1; // default value
nscoord frameMarginHeight = -1; // default value
docShell->GetMarginWidth(&frameMarginWidth); // -1 indicates not set
docShell->GetMarginHeight(&frameMarginHeight);
if (bodyMarginWidth == -1 && frameMarginWidth >= 0) {
if (bodyLeftMargin == -1) {
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_left, (float)frameMarginWidth);
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_left,
(float)frameMarginWidth);
}
if (bodyRightMargin == -1) {
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_right, (float)frameMarginWidth);
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_right,
(float)frameMarginWidth);
}
}
if (bodyMarginHeight == -1 && frameMarginHeight >= 0) {
if (bodyTopMargin == -1) {
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_top, (float)frameMarginHeight);
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_top,
(float)frameMarginHeight);
}
if (bodyBottomMargin == -1) {
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_bottom, (float)frameMarginHeight);
aDecls.SetPixelValueIfUnset(eCSSProperty_margin_bottom,
(float)frameMarginHeight);
}
}
}
}
// When display if first asked for, go ahead and get our colors set up.
if (nsHTMLStyleSheet* styleSheet = aDecls.Document()->GetAttributeStyleSheet()) {
if (nsHTMLStyleSheet* styleSheet =
aDecls.Document()->GetAttributeStyleSheet()) {
nscolor color;
value = aAttributes->GetAttr(nsGkAtoms::link);
if (value && value->GetColorValue(color)) {
@@ -222,41 +224,36 @@ HTMLBodyElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aDecls);
}
nsMapRuleToAttributesFunc
HTMLBodyElement::GetAttributeMappingFunction() const
{
nsMapRuleToAttributesFunc HTMLBodyElement::GetAttributeMappingFunction() const {
return &MapAttributesIntoRule;
}
NS_IMETHODIMP_(bool)
HTMLBodyElement::IsAttributeMapped(const nsAtom* aAttribute) const
{
HTMLBodyElement::IsAttributeMapped(const nsAtom* aAttribute) const {
static const MappedAttributeEntry attributes[] = {
{ nsGkAtoms::link },
{ nsGkAtoms::vlink },
{ nsGkAtoms::alink },
{ nsGkAtoms::text },
{ nsGkAtoms::marginwidth },
{ nsGkAtoms::marginheight },
{ nsGkAtoms::topmargin },
{ nsGkAtoms::rightmargin },
{ nsGkAtoms::bottommargin },
{ nsGkAtoms::leftmargin },
{ nullptr },
{nsGkAtoms::link},
{nsGkAtoms::vlink},
{nsGkAtoms::alink},
{nsGkAtoms::text},
{nsGkAtoms::marginwidth},
{nsGkAtoms::marginheight},
{nsGkAtoms::topmargin},
{nsGkAtoms::rightmargin},
{nsGkAtoms::bottommargin},
{nsGkAtoms::leftmargin},
{nullptr},
};
static const MappedAttributeEntry* const map[] = {
attributes,
sCommonAttributeMap,
sBackgroundAttributeMap,
attributes,
sCommonAttributeMap,
sBackgroundAttributeMap,
};
return FindAttributeDependence(aAttribute, map);
}
already_AddRefed<TextEditor>
HTMLBodyElement::GetAssociatedEditor()
{
already_AddRefed<TextEditor> HTMLBodyElement::GetAssociatedEditor() {
RefPtr<TextEditor> textEditor = GetTextEditorInternal();
if (textEditor) {
return textEditor.forget();
@@ -282,37 +279,31 @@ HTMLBodyElement::GetAssociatedEditor()
return htmlEditor.forget();
}
bool
HTMLBodyElement::IsEventAttributeNameInternal(nsAtom *aName)
{
return nsContentUtils::IsEventAttributeName(aName,
EventNameType_HTML |
EventNameType_HTMLBodyOrFramesetOnly);
bool HTMLBodyElement::IsEventAttributeNameInternal(nsAtom* aName) {
return nsContentUtils::IsEventAttributeName(
aName, EventNameType_HTML | EventNameType_HTMLBodyOrFramesetOnly);
}
nsresult
HTMLBodyElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent)
{
nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
aBindingParent);
nsresult HTMLBodyElement::BindToTree(nsIDocument* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
NS_ENSURE_SUCCESS(rv, rv);
return mAttrs.ForceMapped(this, OwnerDoc());
}
nsresult
HTMLBodyElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
const nsAttrValue* aValue,
const nsAttrValue* aOldValue,
nsIPrincipal* aSubjectPrincipal,
bool aNotify)
{
nsresult rv = nsGenericHTMLElement::AfterSetAttr(aNameSpaceID,
aName, aValue, aOldValue,
aSubjectPrincipal, aNotify);
nsresult HTMLBodyElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
const nsAttrValue* aValue,
const nsAttrValue* aOldValue,
nsIPrincipal* aSubjectPrincipal,
bool aNotify) {
nsresult rv = nsGenericHTMLElement::AfterSetAttr(
aNameSpaceID, aName, aValue, aOldValue, aSubjectPrincipal, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
// if the last mapped attribute was removed, don't clear the
// nsMappedAttributes, our style can still depend on the containing frame element
// nsMappedAttributes, our style can still depend on the containing frame
// element
if (!aValue && IsAttributeMapped(aName)) {
nsresult rv = mAttrs.ForceMapped(this, OwnerDoc());
NS_ENSURE_SUCCESS(rv, rv);
@@ -321,40 +312,37 @@ HTMLBodyElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
return NS_OK;
}
#define EVENT(name_, id_, type_, struct_) /* nothing; handled by the superclass */
#define EVENT(name_, id_, type_, \
struct_) /* nothing; handled by the superclass */
// nsGenericHTMLElement::GetOnError returns
// already_AddRefed<EventHandlerNonNull> while other getters return
// EventHandlerNonNull*, so allow passing in the type to use here.
#define WINDOW_EVENT_HELPER(name_, type_) \
type_* \
HTMLBodyElement::GetOn##name_() \
{ \
if (nsPIDOMWindowInner* win = OwnerDoc()->GetInnerWindow()) { \
nsGlobalWindowInner* globalWin = nsGlobalWindowInner::Cast(win); \
return globalWin->GetOn##name_(); \
} \
return nullptr; \
} \
void \
HTMLBodyElement::SetOn##name_(type_* handler) \
{ \
nsPIDOMWindowInner* win = OwnerDoc()->GetInnerWindow(); \
if (!win) { \
return; \
} \
\
nsGlobalWindowInner* globalWin = nsGlobalWindowInner::Cast(win); \
return globalWin->SetOn##name_(handler); \
#define WINDOW_EVENT_HELPER(name_, type_) \
type_* HTMLBodyElement::GetOn##name_() { \
if (nsPIDOMWindowInner* win = OwnerDoc()->GetInnerWindow()) { \
nsGlobalWindowInner* globalWin = nsGlobalWindowInner::Cast(win); \
return globalWin->GetOn##name_(); \
} \
return nullptr; \
} \
void HTMLBodyElement::SetOn##name_(type_* handler) { \
nsPIDOMWindowInner* win = OwnerDoc()->GetInnerWindow(); \
if (!win) { \
return; \
} \
\
nsGlobalWindowInner* globalWin = nsGlobalWindowInner::Cast(win); \
return globalWin->SetOn##name_(handler); \
}
#define WINDOW_EVENT(name_, id_, type_, struct_) \
#define WINDOW_EVENT(name_, id_, type_, struct_) \
WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
#define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
#define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
WINDOW_EVENT_HELPER(name_, OnBeforeUnloadEventHandlerNonNull)
#include "mozilla/EventNameList.h" // IWYU pragma: keep
#include "mozilla/EventNameList.h" // IWYU pragma: keep
#undef BEFOREUNLOAD_EVENT
#undef WINDOW_EVENT
#undef WINDOW_EVENT_HELPER
#undef EVENT
} // namespace dom
} // namespace mozilla
} // namespace dom
} // namespace mozilla