Fabric: Equality operators for AttributedString and derivatives

Summary: We will need this eventually.

Reviewed By: mdvacca

Differential Revision: D9799852

fbshipit-source-id: 0411e2f41540273c80f425e04c877fe51b9b2374
This commit is contained in:
Valentin Shergin
2018-09-14 15:16:59 -07:00
committed by Facebook Github Bot
parent 4eb9b40979
commit e663b1ed59
4 changed files with 104 additions and 0 deletions

View File

@@ -53,6 +53,66 @@ void TextAttributes::apply(TextAttributes textAttributes) {
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
);
}
bool TextAttributes::operator!=(const TextAttributes &rhs) const {
return !(*this == rhs);
}
#pragma mark - DebugStringConvertible
SharedDebugStringConvertibleList TextAttributes::getDebugProps() const {