From 8b37dd75262ceef33407acff27f6f05fb9d6ff21 Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Fri, 8 Jan 2016 09:10:53 -0800 Subject: [PATCH] Add equality to textStyle and co --- sky/engine/core/dart/text.dart | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/sky/engine/core/dart/text.dart b/sky/engine/core/dart/text.dart index 795ef4eacbf..ac832aadbc7 100644 --- a/sky/engine/core/dart/text.dart +++ b/sky/engine/core/dart/text.dart @@ -284,6 +284,27 @@ class TextStyle { final double _wordSpacing; final double _lineHeight; + bool operator ==(dynamic other) { + if (identical(this, other)) + return true; + if (other is! TextStyle) + return false; + final TextStyle typedOther = other; + if (_fontFamily != typedOther._fontFamily || + _fontSize != typedOther._fontSize || + _letterSpacing != typedOther._letterSpacing || + _wordSpacing != typedOther._wordSpacing || + _lineHeight != typedOther._lineHeight) + return false; + for (int index = 0; index < _encoded.length; index += 1) { + if (_encoded[index] != typedOther._encoded[index]) + return false; + } + return true; + } + + int get hashCode => hashValues(hashList(_encoded), _fontFamily, _fontSize, _letterSpacing, _wordSpacing, _lineHeight); + String toString() { return 'TextStyle(${_encoded[0]}|' 'color: ${ _encoded[0] & 0x001 == 0x001 ? new Color(_encoded[1]) : "unspecified"}, ' @@ -343,6 +364,23 @@ class ParagraphStyle { final Int32List _encoded; final double _lineHeight; + bool operator ==(dynamic other) { + if (identical(this, other)) + return true; + if (other is! ParagraphStyle) + return false; + final ParagraphStyle typedOther = other; + if (_lineHeight != typedOther._lineHeight) + return false; + for (int index = 0; index < _encoded.length; index += 1) { + if (_encoded[index] != typedOther._encoded[index]) + return false; + } + return true; + } + + int get hashCode => hashValues(hashList(_encoded), _lineHeight); + String toString() { return 'ParagraphStyle(' 'textAlign: ${ _encoded[0] & 0x1 == 0x1 ? TextAlign.values[_encoded[1]] : "unspecified"}, '