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
f2574ba1
Unverified
Commit
f2574ba1
authored
Jul 14, 2023
by
LongCatIsLooong
Committed by
GitHub
Jul 14, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the new rounding hack migration flag in TextPainter (#130548)
parent
d5c724eb
Changes
13
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
112 additions
and
101 deletions
+112
-101
text_painter.dart
packages/flutter/lib/src/painting/text_painter.dart
+2
-5
nav_bar_transition_test.dart
packages/flutter/test/cupertino/nav_bar_transition_test.dart
+72
-72
badge_test.dart
packages/flutter/test/material/badge_test.dart
+5
-3
date_range_picker_test.dart
packages/flutter/test/material/date_range_picker_test.dart
+1
-1
flexible_space_bar_test.dart
packages/flutter/test/material/flexible_space_bar_test.dart
+4
-2
input_decorator_test.dart
packages/flutter/test/material/input_decorator_test.dart
+2
-2
navigation_rail_test.dart
packages/flutter/test/material/navigation_rail_test.dart
+4
-2
outlined_button_test.dart
packages/flutter/test/material/outlined_button_test.dart
+4
-2
tab_bar_theme_test.dart
packages/flutter/test/material/tab_bar_theme_test.dart
+4
-2
tabs_test.dart
packages/flutter/test/material/tabs_test.dart
+3
-1
text_button_test.dart
packages/flutter/test/material/text_button_test.dart
+8
-6
time_picker_test.dart
packages/flutter/test/material/time_picker_test.dart
+2
-2
text_painter_test.dart
packages/flutter/test/painting/text_painter_test.dart
+1
-1
No files found.
packages/flutter/lib/src/painting/text_painter.dart
View file @
f2574ba1
...
...
@@ -278,13 +278,10 @@ class _TextLayout {
// object when it's no logner needed.
ui
.
Paragraph
_paragraph
;
/// Whether to enable the rounding in _applyFloatingPointHack and SkParagraph.
static
const
bool
_shouldApplyFloatingPointHack
=
!
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
);
// TODO(LongCatIsLooong): https://github.com/flutter/flutter/issues/31707
// remove this hack as well as the flooring in `layout`.
@pragma
(
'vm:prefer-inline'
)
static
double
_applyFloatingPointHack
(
double
layoutValue
)
=>
_shouldApplyFloatingPointHack
?
layoutValue
.
ceilToDouble
()
:
layoutValue
;
static
double
_applyFloatingPointHack
(
double
layoutValue
)
=>
ui
.
ParagraphBuilder
.
shouldDisableRoundingHack
?
layoutValue
:
layoutValue
.
ceilToDouble
()
;
/// Whether this layout has been invalidated and disposed.
///
...
...
@@ -362,7 +359,7 @@ class _TextPainterLayoutCacheWithOffset {
static
double
_contentWidthFor
(
double
minWidth
,
double
maxWidth
,
TextWidthBasis
widthBasis
,
_TextLayout
layout
)
{
// TODO(LongCatIsLooong): remove the rounding when _applyFloatingPointHack
// is removed.
if
(
_TextLayout
.
_shouldApplyFloatingPoint
Hack
)
{
if
(
!
ui
.
ParagraphBuilder
.
shouldDisableRounding
Hack
)
{
minWidth
=
minWidth
.
floorToDouble
();
maxWidth
=
maxWidth
.
floorToDouble
();
}
...
...
packages/flutter/test/cupertino/nav_bar_transition_test.dart
View file @
f2574ba1
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/badge_test.dart
View file @
f2574ba1
...
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
show
ParagraphBuilder
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -50,7 +52,7 @@ void main() {
expect
(
tester
.
getTopLeft
(
find
.
text
(
'0'
)),
const
Offset
(
16
,
-
4
));
final
RenderBox
box
=
tester
.
renderObject
(
find
.
byType
(
Badge
));
final
RRect
rrect
=
const
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
)
final
RRect
rrect
=
ui
.
ParagraphBuilder
.
shouldDisableRoundingHack
?
RRect
.
fromLTRBR
(
12
,
-
4
,
31.5
,
12
,
const
Radius
.
circular
(
8
))
:
RRect
.
fromLTRBR
(
12
,
-
4
,
32
,
12
,
const
Radius
.
circular
(
8
));
expect
(
box
,
paints
..
rrect
(
rrect:
rrect
,
color:
theme
.
colorScheme
.
error
));
...
...
@@ -92,7 +94,7 @@ void main() {
expect
(
tester
.
getTopLeft
(
find
.
text
(
'0'
)),
const
Offset
(
0
,
-
4
));
final
RenderBox
box
=
tester
.
renderObject
(
find
.
byType
(
Badge
));
final
RRect
rrect
=
const
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
)
final
RRect
rrect
=
ui
.
ParagraphBuilder
.
shouldDisableRoundingHack
?
RRect
.
fromLTRBR
(-
4
,
-
4
,
15.5
,
12
,
const
Radius
.
circular
(
8
))
:
RRect
.
fromLTRBR
(-
4
,
-
4
,
16
,
12
,
const
Radius
.
circular
(
8
));
expect
(
box
,
paints
..
rrect
(
rrect:
rrect
,
color:
theme
.
colorScheme
.
error
));
...
...
@@ -149,7 +151,7 @@ void main() {
// T = alignment.top
// R = L + '0'.width + padding.width
// B = T + largeSize, R = largeSize/2
final
RRect
rrect
=
const
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
)
final
RRect
rrect
=
ui
.
ParagraphBuilder
.
shouldDisableRoundingHack
?
RRect
.
fromLTRBR
(
12
,
-
4
,
31.5
,
12
,
const
Radius
.
circular
(
8
))
:
RRect
.
fromLTRBR
(
12
,
-
4
,
32
,
12
,
const
Radius
.
circular
(
8
));
expect
(
box
,
paints
..
rrect
(
rrect:
rrect
,
color:
theme
.
colorScheme
.
error
));
...
...
packages/flutter/test/material/date_range_picker_test.dart
View file @
f2574ba1
...
...
@@ -134,7 +134,7 @@ void main() {
);
expect
(
saveButtonBottomLeft
.
dx
,
const
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
)
?
moreOrLessEquals
(
711.6
,
epsilon:
1
e
-
5
)
:
(
800
-
89.0
),
ParagraphBuilder
.
shouldDisableRoundingHack
?
moreOrLessEquals
(
711.6
,
epsilon:
1
e
-
5
)
:
(
800
-
89.0
),
);
expect
(
saveButtonBottomLeft
.
dy
,
helpTextTopLeft
.
dy
);
expect
(
entryButtonBottomLeft
.
dx
,
saveButtonBottomLeft
.
dx
-
48.0
);
...
...
packages/flutter/test/material/flexible_space_bar_test.dart
View file @
f2574ba1
...
...
@@ -7,6 +7,8 @@
@Tags
(<
String
>[
'reduced-test-set'
])
library
;
import
'dart:ui'
as
ui
show
ParagraphBuilder
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -470,7 +472,7 @@ void main() {
),
);
final
double
textWidth
=
const
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
)
final
double
textWidth
=
ui
.
ParagraphBuilder
.
shouldDisableRoundingHack
?
width
:
(
width
/
1.5
).
floorToDouble
()
*
1.5
;
// The title is scaled and transformed to be 1.5 times bigger, when the
...
...
@@ -541,7 +543,7 @@ void main() {
// bottom edge.
const
double
bottomMargin
=
titleFontSize
*
(
expandedTitleScale
-
1
);
final
double
textWidth
=
const
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
)
final
double
textWidth
=
ui
.
ParagraphBuilder
.
shouldDisableRoundingHack
?
collapsedWidth
:
(
collapsedWidth
/
3
).
floorToDouble
()
*
3
;
// The title is scaled and transformed to be 3 times bigger, when the
...
...
packages/flutter/test/material/input_decorator_test.dart
View file @
f2574ba1
...
...
@@ -5928,10 +5928,10 @@ void main() {
}
final
Rect
clipRect
=
arguments
[
0
]
as
Rect
;
// _kFinalLabelScale = 0.75
const
double
width
=
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
)
final
double
width
=
ParagraphBuilder
.
shouldDisableRoundingHack
?
100
/
0.75
:
133.0
;
expect
(
clipRect
,
rectMoreOrLessEquals
(
const
Rect
.
fromLTWH
(
0
,
0
,
width
,
16.0
),
epsilon:
1
e
-
5
));
expect
(
clipRect
,
rectMoreOrLessEquals
(
Rect
.
fromLTWH
(
0
,
0
,
width
,
16.0
),
epsilon:
1
e
-
5
));
return
true
;
}),
);
...
...
packages/flutter/test/material/navigation_rail_test.dart
View file @
f2574ba1
...
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
show
ParagraphBuilder
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
...
...
@@ -583,7 +585,7 @@ void main() {
// Padding at the top of the rail.
const
double
topPadding
=
8.0
;
// Width of a destination.
const
double
destinationWidth
=
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
)
?
125.5
:
126.0
;
final
double
destinationWidth
=
ui
.
ParagraphBuilder
.
shouldDisableRoundingHack
?
125.5
:
126.0
;
// Height of a destination indicator with icon.
const
double
destinationHeight
=
32.0
;
// Space between the indicator and label.
...
...
@@ -858,7 +860,7 @@ void main() {
// Padding at the top of the rail.
const
double
topPadding
=
8.0
;
// Width of a destination.
const
double
destinationWidth
=
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
)
?
125.5
:
126.0
;
final
double
destinationWidth
=
ui
.
ParagraphBuilder
.
shouldDisableRoundingHack
?
125.5
:
126.0
;
// Height of a destination indicator with icon.
const
double
destinationHeight
=
32.0
;
// Space between the indicator and label.
...
...
packages/flutter/test/material/outlined_button_test.dart
View file @
f2574ba1
...
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
show
ParagraphBuilder
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
...
...
@@ -1066,8 +1068,8 @@ void main() {
);
expect
(
tester
.
getSize
(
find
.
byType
(
OutlinedButton
)),
equals
(
const
Size
(
88.0
,
48.0
)));
expect
(
tester
.
getSize
(
find
.
byType
(
Text
)),
const
Size
(
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
)
?
52.5
:
53.0
,
expect
(
tester
.
getSize
(
find
.
byType
(
Text
)),
Size
(
ui
.
ParagraphBuilder
.
shouldDisableRoundingHack
?
52.5
:
53.0
,
18.0
,
));
...
...
packages/flutter/test/material/tab_bar_theme_test.dart
View file @
f2574ba1
...
...
@@ -7,6 +7,8 @@
@Tags
(<
String
>[
'reduced-test-set'
])
library
;
import
'dart:ui'
as
ui
show
ParagraphBuilder
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -607,8 +609,8 @@ void main() {
..
line
(
color:
theme
.
colorScheme
.
primary
,
strokeWidth:
indicatorWeight
,
p1:
const
Offset
(
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
)
?
65.75
:
65.5
,
indicatorY
),
p2:
const
Offset
(
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
)
?
134.25
:
134.5
,
indicatorY
),
p1:
Offset
(
ui
.
ParagraphBuilder
.
shouldDisableRoundingHack
?
65.75
:
65.5
,
indicatorY
),
p2:
Offset
(
ui
.
ParagraphBuilder
.
shouldDisableRoundingHack
?
134.25
:
134.5
,
indicatorY
),
),
);
});
...
...
packages/flutter/test/material/tabs_test.dart
View file @
f2574ba1
...
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
show
ParagraphBuilder
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -489,7 +491,7 @@ void main() {
const
double
indicatorWeight
=
3.0
;
final
RRect
rrect
=
const
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
)
final
RRect
rrect
=
ui
.
ParagraphBuilder
.
shouldDisableRoundingHack
?
RRect
.
fromLTRBAndCorners
(
64.75
,
tabBarBox
.
size
.
height
-
indicatorWeight
,
...
...
packages/flutter/test/material/text_button_test.dart
View file @
f2574ba1
...
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
show
ParagraphBuilder
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
...
...
@@ -618,12 +620,12 @@ void main() {
),
);
const
Size
textButtonSize
=
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
)
?
Size
(
68.5
,
48.0
)
:
Size
(
69.0
,
48.0
);
const
Size
textSize
=
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
)
?
Size
(
52.5
,
18.0
)
:
Size
(
53.0
,
18.0
);
final
Size
textButtonSize
=
ui
.
ParagraphBuilder
.
shouldDisableRoundingHack
?
const
Size
(
68.5
,
48.0
)
:
const
Size
(
69.0
,
48.0
);
final
Size
textSize
=
ui
.
ParagraphBuilder
.
shouldDisableRoundingHack
?
const
Size
(
52.5
,
18.0
)
:
const
Size
(
53.0
,
18.0
);
expect
(
tester
.
getSize
(
find
.
byType
(
TextButton
)),
textButtonSize
);
expect
(
tester
.
getSize
(
find
.
byType
(
Text
)),
textSize
);
...
...
packages/flutter/test/material/time_picker_test.dart
View file @
f2574ba1
...
...
@@ -746,7 +746,7 @@ void main() {
case
MaterialType
.
material2
:
expect
(
tester
.
getTopLeft
(
find
.
text
(
selectTimeString
)),
equals
(
const
Offset
(
154
,
155
)));
expect
(
tester
.
getBottomRight
(
find
.
text
(
selectTimeString
)),
equals
(
const
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
)
?
const
Offset
(
280.5
,
165
)
:
const
Offset
(
281
,
165
),
ParagraphBuilder
.
shouldDisableRoundingHack
?
const
Offset
(
280.5
,
165
)
:
const
Offset
(
281
,
165
),
));
expect
(
tester
.
getBottomRight
(
find
.
text
(
okString
)).
dx
,
644
);
expect
(
tester
.
getBottomLeft
(
find
.
text
(
okString
)).
dx
,
616
);
...
...
@@ -768,7 +768,7 @@ void main() {
switch
(
materialType
)
{
case
MaterialType
.
material2
:
expect
(
tester
.
getTopLeft
(
find
.
text
(
selectTimeString
)),
equals
(
const
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
)
?
const
Offset
(
519.5
,
155
)
:
const
Offset
(
519
,
155
),
ParagraphBuilder
.
shouldDisableRoundingHack
?
const
Offset
(
519.5
,
155
)
:
const
Offset
(
519
,
155
),
));
expect
(
tester
.
getBottomRight
(
find
.
text
(
selectTimeString
)),
equals
(
const
Offset
(
646
,
165
)));
expect
(
tester
.
getBottomLeft
(
find
.
text
(
okString
)).
dx
,
156
);
...
...
packages/flutter/test/painting/text_painter_test.dart
View file @
f2574ba1
...
...
@@ -1509,7 +1509,7 @@ void main() {
});
test
(
'TextPainter line breaking does not round to integers'
,
()
{
if
(!
const
bool
.
hasEnvironment
(
'SKPARAGRAPH_REMOVE_ROUNDING_HACK'
)
)
{
if
(!
ui
.
ParagraphBuilder
.
shouldDisableRoundingHack
)
{
return
;
}
const
double
fontSize
=
1.25
;
...
...
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