Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
25219277
Commit
25219277
authored
Feb 25, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix TextSpan's operator==
We forgot to compare the lengths of the lists.
parent
d1154c25
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
13 deletions
+46
-13
text_painter.dart
packages/flutter/lib/src/painting/text_painter.dart
+16
-13
text_span_test.dart
packages/flutter/test/painting/text_span_test.dart
+30
-0
No files found.
packages/flutter/lib/src/painting/text_painter.dart
View file @
25219277
...
...
@@ -8,6 +8,19 @@ import 'basic_types.dart';
import
'text_editing.dart'
;
import
'text_style.dart'
;
// TODO(abarth): Should this be somewhere more general?
bool
_deepEquals
(
List
<
Object
>
a
,
List
<
Object
>
b
)
{
if
(
a
==
null
)
return
b
==
null
;
if
(
b
==
null
||
a
.
length
!=
b
.
length
)
return
false
;
for
(
int
i
=
0
;
i
<
a
.
length
;
++
i
)
{
if
(
a
[
i
]
!=
b
[
i
])
return
false
;
}
return
true
;
}
/// An immutable span of text.
class
TextSpan
{
const
TextSpan
({
...
...
@@ -74,19 +87,9 @@ class TextSpan {
if
(
other
is
!
TextSpan
)
return
false
;
final
TextSpan
typedOther
=
other
;
if
(
typedOther
.
text
!=
text
)
return
false
;
if
(
typedOther
.
style
!=
style
)
return
false
;
if
((
typedOther
.
children
==
null
)
!=
(
children
==
null
))
return
false
;
if
(
children
!=
null
)
{
for
(
int
i
=
0
;
i
<
children
.
length
;
++
i
)
{
if
(
typedOther
.
children
[
i
]
!=
children
[
i
])
return
false
;
}
}
return
true
;
return
typedOther
.
text
==
text
&&
typedOther
.
style
==
style
&&
_deepEquals
(
typedOther
.
children
,
children
);
}
int
get
hashCode
=>
hashValues
(
style
,
text
,
hashList
(
children
));
}
...
...
packages/flutter/test/painting/text_span_test.dart
0 → 100644
View file @
25219277
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/painting.dart'
;
import
'package:test/test.dart'
;
void
main
(
)
{
test
(
"TextSpan equals"
,
()
{
TextSpan
a1
=
new
TextSpan
(
text:
'a'
);
TextSpan
a2
=
new
TextSpan
(
text:
'a'
);
TextSpan
b1
=
new
TextSpan
(
children:
<
TextSpan
>[
a1
]);
TextSpan
b2
=
new
TextSpan
(
children:
<
TextSpan
>[
a2
]);
TextSpan
c1
=
new
TextSpan
();
TextSpan
c2
=
new
TextSpan
();
expect
(
a1
==
a2
,
isTrue
);
expect
(
b1
==
b2
,
isTrue
);
expect
(
c1
==
c2
,
isTrue
);
expect
(
a1
==
b2
,
isFalse
);
expect
(
b1
==
c2
,
isFalse
);
expect
(
c1
==
a2
,
isFalse
);
expect
(
a1
==
c2
,
isFalse
);
expect
(
b1
==
a2
,
isFalse
);
expect
(
c1
==
b2
,
isFalse
);
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment