Fabric: Enabling clang-format for half of Fabric modules

Summary:
All code styles are terribly ugly. We have the only choise - choise something and embrace it.
This particular code style was borrowed from a neibour Fabric-friendly project because it follows established Facebook guides and respects client-side traditions.

Reviewed By: mdvacca

Differential Revision: D10218598

fbshipit-source-id: 8c4cf6713c07768566dadef479191661c79988f0
This commit is contained in:
Valentin Shergin
2018-10-05 11:03:23 -07:00
committed by Facebook Github Bot
parent 3d31bebbeb
commit 3ad5c9e016
100 changed files with 2589 additions and 1728 deletions
@@ -18,95 +18,131 @@ namespace react {
void TextAttributes::apply(TextAttributes textAttributes) {
// Color
foregroundColor = textAttributes.foregroundColor ? textAttributes.foregroundColor : foregroundColor;
backgroundColor = textAttributes.backgroundColor ? textAttributes.backgroundColor : backgroundColor;
foregroundColor = textAttributes.foregroundColor
? textAttributes.foregroundColor
: foregroundColor;
backgroundColor = textAttributes.backgroundColor
? textAttributes.backgroundColor
: backgroundColor;
opacity = !isnan(textAttributes.opacity) ? textAttributes.opacity : opacity;
// Font
fontFamily = !textAttributes.fontFamily.empty() ? textAttributes.fontFamily : fontFamily;
fontSize = !isnan(textAttributes.fontSize) ? textAttributes.fontSize : fontSize;
fontSizeMultiplier = !isnan(textAttributes.fontSizeMultiplier) ? textAttributes.fontSizeMultiplier : fontSizeMultiplier;
fontWeight = textAttributes.fontWeight.hasValue() ? textAttributes.fontWeight : fontWeight;
fontStyle = textAttributes.fontStyle.hasValue() ? textAttributes.fontStyle : fontStyle;
fontVariant = textAttributes.fontVariant.hasValue() ? textAttributes.fontVariant : fontVariant;
allowFontScaling = textAttributes.allowFontScaling.hasValue() ? textAttributes.allowFontScaling : allowFontScaling;
letterSpacing = !isnan(textAttributes.letterSpacing) ? textAttributes.letterSpacing : letterSpacing;
fontFamily = !textAttributes.fontFamily.empty() ? textAttributes.fontFamily
: fontFamily;
fontSize =
!isnan(textAttributes.fontSize) ? textAttributes.fontSize : fontSize;
fontSizeMultiplier = !isnan(textAttributes.fontSizeMultiplier)
? textAttributes.fontSizeMultiplier
: fontSizeMultiplier;
fontWeight = textAttributes.fontWeight.hasValue() ? textAttributes.fontWeight
: fontWeight;
fontStyle = textAttributes.fontStyle.hasValue() ? textAttributes.fontStyle
: fontStyle;
fontVariant = textAttributes.fontVariant.hasValue()
? textAttributes.fontVariant
: fontVariant;
allowFontScaling = textAttributes.allowFontScaling.hasValue()
? textAttributes.allowFontScaling
: allowFontScaling;
letterSpacing = !isnan(textAttributes.letterSpacing)
? textAttributes.letterSpacing
: letterSpacing;
// Paragraph Styles
lineHeight = !isnan(textAttributes.lineHeight) ? textAttributes.lineHeight : lineHeight;
alignment = textAttributes.alignment.hasValue() ? textAttributes.alignment : alignment;
baseWritingDirection = textAttributes.baseWritingDirection.hasValue() ? textAttributes.baseWritingDirection : baseWritingDirection;
lineHeight = !isnan(textAttributes.lineHeight) ? textAttributes.lineHeight
: lineHeight;
alignment = textAttributes.alignment.hasValue() ? textAttributes.alignment
: alignment;
baseWritingDirection = textAttributes.baseWritingDirection.hasValue()
? textAttributes.baseWritingDirection
: baseWritingDirection;
// Decoration
textDecorationColor = textAttributes.textDecorationColor ? textAttributes.textDecorationColor : textDecorationColor;
textDecorationLineType = textAttributes.textDecorationLineType.hasValue() ? textAttributes.textDecorationLineType : textDecorationLineType;
textDecorationLineStyle = textAttributes.textDecorationLineStyle.hasValue() ? textAttributes.textDecorationLineStyle : textDecorationLineStyle;
textDecorationLinePattern = textAttributes.textDecorationLinePattern.hasValue() ? textAttributes.textDecorationLinePattern : textDecorationLinePattern;
textDecorationColor = textAttributes.textDecorationColor
? textAttributes.textDecorationColor
: textDecorationColor;
textDecorationLineType = textAttributes.textDecorationLineType.hasValue()
? textAttributes.textDecorationLineType
: textDecorationLineType;
textDecorationLineStyle = textAttributes.textDecorationLineStyle.hasValue()
? textAttributes.textDecorationLineStyle
: textDecorationLineStyle;
textDecorationLinePattern =
textAttributes.textDecorationLinePattern.hasValue()
? textAttributes.textDecorationLinePattern
: textDecorationLinePattern;
// Shadow
textShadowOffset = textAttributes.textShadowOffset.hasValue() ? textAttributes.textShadowOffset.value() : textShadowOffset;
textShadowRadius = !isnan(textAttributes.textShadowRadius) ? textAttributes.textShadowRadius : textShadowRadius;
textShadowColor = textAttributes.textShadowColor ? textAttributes.textShadowColor : textShadowColor;
textShadowOffset = textAttributes.textShadowOffset.hasValue()
? textAttributes.textShadowOffset.value()
: textShadowOffset;
textShadowRadius = !isnan(textAttributes.textShadowRadius)
? textAttributes.textShadowRadius
: textShadowRadius;
textShadowColor = textAttributes.textShadowColor
? textAttributes.textShadowColor
: textShadowColor;
// Special
isHighlighted = textAttributes.isHighlighted.hasValue() ? textAttributes.isHighlighted : isHighlighted;
layoutDirection = textAttributes.layoutDirection.hasValue() ? textAttributes.layoutDirection : layoutDirection;
isHighlighted = textAttributes.isHighlighted.hasValue()
? textAttributes.isHighlighted
: isHighlighted;
layoutDirection = textAttributes.layoutDirection.hasValue()
? textAttributes.layoutDirection
: layoutDirection;
}
#pragma mark - Operators
bool TextAttributes::operator==(const TextAttributes &rhs) const {
return
std::tie(
foregroundColor,
backgroundColor,
opacity,
fontFamily,
fontSize,
fontSizeMultiplier,
fontWeight,
fontStyle,
fontVariant,
allowFontScaling,
letterSpacing,
lineHeight,
alignment,
baseWritingDirection,
textDecorationColor,
textDecorationLineType,
textDecorationLineStyle,
textDecorationLinePattern,
textShadowOffset,
textShadowRadius,
textShadowColor,
isHighlighted,
layoutDirection
) ==
std::tie(
rhs.foregroundColor,
rhs.backgroundColor,
rhs.opacity,
rhs.fontFamily,
rhs.fontSize,
rhs.fontSizeMultiplier,
rhs.fontWeight,
rhs.fontStyle,
rhs.fontVariant,
rhs.allowFontScaling,
rhs.letterSpacing,
rhs.lineHeight,
rhs.alignment,
rhs.baseWritingDirection,
rhs.textDecorationColor,
rhs.textDecorationLineType,
rhs.textDecorationLineStyle,
rhs.textDecorationLinePattern,
rhs.textShadowOffset,
rhs.textShadowRadius,
rhs.textShadowColor,
rhs.isHighlighted,
rhs.layoutDirection
);
return std::tie(
foregroundColor,
backgroundColor,
opacity,
fontFamily,
fontSize,
fontSizeMultiplier,
fontWeight,
fontStyle,
fontVariant,
allowFontScaling,
letterSpacing,
lineHeight,
alignment,
baseWritingDirection,
textDecorationColor,
textDecorationLineType,
textDecorationLineStyle,
textDecorationLinePattern,
textShadowOffset,
textShadowRadius,
textShadowColor,
isHighlighted,
layoutDirection) ==
std::tie(
rhs.foregroundColor,
rhs.backgroundColor,
rhs.opacity,
rhs.fontFamily,
rhs.fontSize,
rhs.fontSizeMultiplier,
rhs.fontWeight,
rhs.fontStyle,
rhs.fontVariant,
rhs.allowFontScaling,
rhs.letterSpacing,
rhs.lineHeight,
rhs.alignment,
rhs.baseWritingDirection,
rhs.textDecorationColor,
rhs.textDecorationLineType,
rhs.textDecorationLineStyle,
rhs.textDecorationLinePattern,
rhs.textShadowOffset,
rhs.textShadowRadius,
rhs.textShadowColor,
rhs.isHighlighted,
rhs.layoutDirection);
}
bool TextAttributes::operator!=(const TextAttributes &rhs) const {
@@ -118,40 +154,43 @@ bool TextAttributes::operator!=(const TextAttributes &rhs) const {
#if RN_DEBUG_STRING_CONVERTIBLE
SharedDebugStringConvertibleList TextAttributes::getDebugProps() const {
return {
// Color
debugStringConvertibleItem("backgroundColor", backgroundColor),
debugStringConvertibleItem("foregroundColor", foregroundColor),
debugStringConvertibleItem("opacity", opacity),
// Color
debugStringConvertibleItem("backgroundColor", backgroundColor),
debugStringConvertibleItem("foregroundColor", foregroundColor),
debugStringConvertibleItem("opacity", opacity),
// Font
debugStringConvertibleItem("fontFamily", fontFamily),
debugStringConvertibleItem("fontSize", fontSize),
debugStringConvertibleItem("fontSizeMultiplier", fontSizeMultiplier),
debugStringConvertibleItem("fontWeight", fontWeight),
debugStringConvertibleItem("fontStyle", fontStyle),
debugStringConvertibleItem("fontVariant", fontVariant),
debugStringConvertibleItem("allowFontScaling", allowFontScaling),
debugStringConvertibleItem("letterSpacing", letterSpacing),
// Font
debugStringConvertibleItem("fontFamily", fontFamily),
debugStringConvertibleItem("fontSize", fontSize),
debugStringConvertibleItem("fontSizeMultiplier", fontSizeMultiplier),
debugStringConvertibleItem("fontWeight", fontWeight),
debugStringConvertibleItem("fontStyle", fontStyle),
debugStringConvertibleItem("fontVariant", fontVariant),
debugStringConvertibleItem("allowFontScaling", allowFontScaling),
debugStringConvertibleItem("letterSpacing", letterSpacing),
// Paragraph Styles
debugStringConvertibleItem("lineHeight", lineHeight),
debugStringConvertibleItem("alignment", alignment),
debugStringConvertibleItem("baseWritingDirection", baseWritingDirection),
// Paragraph Styles
debugStringConvertibleItem("lineHeight", lineHeight),
debugStringConvertibleItem("alignment", alignment),
debugStringConvertibleItem("baseWritingDirection", baseWritingDirection),
// Decoration
debugStringConvertibleItem("textDecorationColor", textDecorationColor),
debugStringConvertibleItem("textDecorationLineType", textDecorationLineType),
debugStringConvertibleItem("textDecorationLineStyle", textDecorationLineStyle),
debugStringConvertibleItem("textDecorationLinePattern", textDecorationLinePattern),
// Decoration
debugStringConvertibleItem("textDecorationColor", textDecorationColor),
debugStringConvertibleItem(
"textDecorationLineType", textDecorationLineType),
debugStringConvertibleItem(
"textDecorationLineStyle", textDecorationLineStyle),
debugStringConvertibleItem(
"textDecorationLinePattern", textDecorationLinePattern),
// Shadow
debugStringConvertibleItem("textShadowOffset", textShadowOffset),
debugStringConvertibleItem("textShadowRadius", textShadowRadius),
debugStringConvertibleItem("textShadowColor", textShadowColor),
// Shadow
debugStringConvertibleItem("textShadowOffset", textShadowOffset),
debugStringConvertibleItem("textShadowRadius", textShadowRadius),
debugStringConvertibleItem("textShadowColor", textShadowColor),
// Special
debugStringConvertibleItem("isHighlighted", isHighlighted),
debugStringConvertibleItem("layoutDirection", layoutDirection),
// Special
debugStringConvertibleItem("isHighlighted", isHighlighted),
debugStringConvertibleItem("layoutDirection", layoutDirection),
};
}
#endif