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
7b678ff3
Commit
7b678ff3
authored
Aug 07, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #495 from abarth/rationalize_text
Rationalize text
parents
888bdd7a
2f3af49b
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
51 additions
and
46 deletions
+51
-46
align_items.dart
packages/flutter/example/rendering/align_items.dart
+4
-4
baseline.dart
packages/flutter/example/rendering/baseline.dart
+5
-5
interactive_flex.dart
packages/flutter/example/rendering/interactive_flex.dart
+2
-2
justify_content.dart
packages/flutter/example/rendering/justify_content.dart
+1
-1
render_paragraph.dart
packages/flutter/example/rendering/render_paragraph.dart
+2
-2
touch_demo.dart
packages/flutter/example/rendering/touch_demo.dart
+1
-1
paragraph.dart
packages/flutter/lib/rendering/paragraph.dart
+15
-16
basic.dart
packages/flutter/lib/widgets/basic.dart
+21
-15
No files found.
packages/flutter/example/rendering/align_items.dart
View file @
7b678ff3
...
...
@@ -18,25 +18,25 @@ void main() {
for
(
FlexAlignItems
alignItems
in
FlexAlignItems
.
values
)
{
TextStyle
style
=
const
TextStyle
(
color:
const
Color
(
0xFF000000
));
RenderParagraph
paragraph
=
new
RenderParagraph
(
new
InlineStyle
(
style
,
[
new
Inline
Text
(
"
${alignItems}
"
)]));
RenderParagraph
paragraph
=
new
RenderParagraph
(
new
RenderStyled
(
style
,
[
new
Render
Text
(
"
${alignItems}
"
)]));
table
.
add
(
new
RenderPadding
(
child:
paragraph
,
padding:
new
EdgeDims
.
only
(
top:
20.0
)));
var
row
=
new
RenderFlex
(
alignItems:
alignItems
,
textBaseline:
TextBaseline
.
alphabetic
);
style
=
new
TextStyle
(
fontSize:
15.0
,
color:
const
Color
(
0xFF000000
));
row
.
add
(
new
RenderDecoratedBox
(
decoration:
new
BoxDecoration
(
backgroundColor:
const
Color
(
0x7FFFCCCC
)),
child:
new
RenderParagraph
(
new
InlineStyle
(
style
,
[
new
Inline
Text
(
'foo foo foo'
)]))
child:
new
RenderParagraph
(
new
RenderStyled
(
style
,
[
new
Render
Text
(
'foo foo foo'
)]))
));
style
=
new
TextStyle
(
fontSize:
10.0
,
color:
const
Color
(
0xFF000000
));
row
.
add
(
new
RenderDecoratedBox
(
decoration:
new
BoxDecoration
(
backgroundColor:
const
Color
(
0x7FCCFFCC
)),
child:
new
RenderParagraph
(
new
InlineStyle
(
style
,
[
new
Inline
Text
(
'foo foo foo'
)]))
child:
new
RenderParagraph
(
new
RenderStyled
(
style
,
[
new
Render
Text
(
'foo foo foo'
)]))
));
var
subrow
=
new
RenderFlex
(
alignItems:
alignItems
,
textBaseline:
TextBaseline
.
alphabetic
);
style
=
new
TextStyle
(
fontSize:
25.0
,
color:
const
Color
(
0xFF000000
));
subrow
.
add
(
new
RenderDecoratedBox
(
decoration:
new
BoxDecoration
(
backgroundColor:
const
Color
(
0x7FCCCCFF
)),
child:
new
RenderParagraph
(
new
InlineStyle
(
style
,
[
new
Inline
Text
(
'foo foo foo foo'
)]))
child:
new
RenderParagraph
(
new
RenderStyled
(
style
,
[
new
Render
Text
(
'foo foo foo foo'
)]))
));
subrow
.
add
(
new
RenderSolidColorBox
(
const
Color
(
0x7FCCFFFF
),
desiredSize:
new
Size
(
30.0
,
40.0
)));
row
.
add
(
subrow
);
...
...
packages/flutter/example/rendering/baseline.dart
View file @
7b678ff3
...
...
@@ -13,19 +13,19 @@ import 'package:sky/rendering/sky_binding.dart';
RenderBox
getBox
(
double
lh
)
{
RenderParagraph
paragraph
=
new
RenderParagraph
(
new
InlineStyle
(
new
RenderStyled
(
new
TextStyle
(
color:
const
Color
(
0xFF0000A0
)
),
[
new
Inline
Text
(
'test'
),
new
InlineStyle
(
new
Render
Text
(
'test'
),
new
RenderStyled
(
new
TextStyle
(
fontFamily:
'serif'
,
fontSize:
50.0
,
height:
lh
),
[
new
Inline
Text
(
'مرحبا Hello'
)]
[
new
Render
Text
(
'مرحبا Hello'
)]
)
]
)
...
...
packages/flutter/example/rendering/interactive_flex.dart
View file @
7b678ff3
...
...
@@ -84,9 +84,9 @@ porchetta bacon kevin meatball meatloaf pig beef ribs chicken. Brisket ribeye
andouille leberkas capicola meatloaf. Chicken pig ball tip pork picanha bresaola
alcatra. Pork pork belly alcatra, flank chuck drumstick biltong doner jowl.
Pancetta meatball tongue tenderloin rump tail jowl boudin."""
;
var
text
=
new
InlineStyle
(
var
text
=
new
RenderStyled
(
new
TextStyle
(
color:
const
Color
(
0xFF009900
)),
[
new
Inline
Text
(
meatyString
)]);
[
new
Render
Text
(
meatyString
)]);
padding
=
new
RenderPadding
(
padding:
const
EdgeDims
.
all
(
10.0
),
child:
new
RenderParagraph
(
text
));
...
...
packages/flutter/example/rendering/justify_content.dart
View file @
7b678ff3
...
...
@@ -21,7 +21,7 @@ void main() {
var
table
=
new
RenderFlex
(
direction:
FlexDirection
.
vertical
);
void
addRow
(
FlexJustifyContent
justify
)
{
RenderParagraph
paragraph
=
new
RenderParagraph
(
new
InlineStyle
(
style
,
[
new
Inline
Text
(
"
${justify}
"
)]));
RenderParagraph
paragraph
=
new
RenderParagraph
(
new
RenderStyled
(
style
,
[
new
Render
Text
(
"
${justify}
"
)]));
table
.
add
(
new
RenderPadding
(
child:
paragraph
,
padding:
new
EdgeDims
.
only
(
top:
20.0
)));
var
row
=
new
RenderFlex
(
direction:
FlexDirection
.
horizontal
);
row
.
add
(
new
RenderSolidColorBox
(
const
Color
(
0xFFFFCCCC
),
desiredSize:
new
Size
(
80.0
,
60.0
)));
...
...
packages/flutter/example/rendering/render_paragraph.dart
View file @
7b678ff3
...
...
@@ -32,9 +32,9 @@ andouille leberkas capicola meatloaf. Chicken pig ball tip pork picanha bresaola
alcatra. Pork pork belly alcatra, flank chuck drumstick biltong doner jowl.
Pancetta meatball tongue tenderloin rump tail jowl boudin."""
;
var
text
=
new
InlineStyle
(
var
text
=
new
RenderStyled
(
new
TextStyle
(
color:
const
Color
(
0xFF009900
)),
[
new
Inline
Text
(
meatyString
)]);
[
new
Render
Text
(
meatyString
)]);
child
=
new
RenderDecoratedBox
(
decoration:
new
BoxDecoration
(
backgroundColor:
const
Color
(
0xFFFFFFFF
)),
child:
new
RenderParagraph
(
text
)
...
...
packages/flutter/example/rendering/touch_demo.dart
View file @
7b678ff3
...
...
@@ -80,7 +80,7 @@ class RenderTouchDemo extends RenderBox {
}
void
main
(
)
{
var
paragraph
=
new
RenderParagraph
(
new
Inline
Text
(
"Touch me!"
));
var
paragraph
=
new
RenderParagraph
(
new
Render
Text
(
"Touch me!"
));
var
stack
=
new
RenderStack
(
children:
[
new
RenderTouchDemo
(),
paragraph
,
...
...
packages/flutter/lib/rendering/paragraph.dart
View file @
7b678ff3
...
...
@@ -8,7 +8,7 @@ import 'package:sky/painting/text_style.dart';
import
'package:sky/rendering/box.dart'
;
import
'package:sky/rendering/object.dart'
;
abstract
class
InlineBas
e
{
abstract
class
RenderInlin
e
{
sky
.
Node
_toDOM
(
sky
.
Document
owner
);
String
toString
([
String
prefix
=
''
]);
...
...
@@ -16,8 +16,8 @@ abstract class InlineBase {
}
}
class
InlineText
extends
InlineBas
e
{
Inline
Text
(
this
.
text
)
{
class
RenderText
extends
RenderInlin
e
{
Render
Text
(
this
.
text
)
{
assert
(
text
!=
null
);
}
...
...
@@ -27,25 +27,25 @@ class InlineText extends InlineBase {
return
owner
.
createText
(
text
);
}
bool
operator
==(
other
)
=>
other
is
Inline
Text
&&
text
==
other
.
text
;
bool
operator
==(
other
)
=>
other
is
Render
Text
&&
text
==
other
.
text
;
int
get
hashCode
=>
text
.
hashCode
;
String
toString
([
String
prefix
=
''
])
=>
'
${prefix}
InlineText: "
${text}
"'
;
}
class
InlineStyle
extends
InlineBas
e
{
InlineStyle
(
this
.
style
,
this
.
children
)
{
class
RenderStyled
extends
RenderInlin
e
{
RenderStyled
(
this
.
style
,
this
.
children
)
{
assert
(
style
!=
null
);
assert
(
children
!=
null
);
}
final
TextStyle
style
;
final
List
<
InlineBas
e
>
children
;
final
List
<
RenderInlin
e
>
children
;
sky
.
Node
_toDOM
(
sky
.
Document
owner
)
{
sky
.
Element
parent
=
owner
.
createElement
(
't'
);
style
.
applyToCSSStyle
(
parent
.
style
);
for
(
InlineBas
e
child
in
children
)
{
for
(
RenderInlin
e
child
in
children
)
{
parent
.
appendChild
(
child
.
_toDOM
(
owner
));
}
return
parent
;
...
...
@@ -58,7 +58,7 @@ class InlineStyle extends InlineBase {
bool
operator
==(
other
)
{
if
(
identical
(
this
,
other
))
return
true
;
if
(
other
is
!
InlineStyle
if
(
other
is
!
RenderStyled
||
style
!=
other
.
style
||
children
.
length
!=
other
.
children
.
length
)
return
false
;
...
...
@@ -72,7 +72,7 @@ class InlineStyle extends InlineBase {
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
style
.
hashCode
;
for
(
InlineBas
e
child
in
children
)
for
(
RenderInlin
e
child
in
children
)
value
=
37
*
value
+
child
.
hashCode
;
return
value
;
}
...
...
@@ -82,7 +82,7 @@ class InlineStyle extends InlineBase {
result
.
add
(
'
${prefix}
InlineStyle:'
);
var
indent
=
'
${prefix}
'
;
result
.
add
(
'
${style.toString(indent)}
'
);
for
(
InlineBas
e
child
in
children
)
{
for
(
RenderInlin
e
child
in
children
)
{
result
.
add
(
child
.
toString
(
indent
));
}
return
result
.
join
(
'
\n
'
);
...
...
@@ -102,9 +102,8 @@ double _applyFloatingPointHack(double layoutValue) {
class
RenderParagraph
extends
RenderBox
{
RenderParagraph
(
InlineBase
inlineValu
e
)
{
RenderParagraph
(
this
.
_inlin
e
)
{
_layoutRoot
.
rootElement
=
_document
.
createElement
(
'p'
);
inline
=
inlineValue
;
}
final
sky
.
Document
_document
=
new
sky
.
Document
();
...
...
@@ -112,9 +111,9 @@ class RenderParagraph extends RenderBox {
BoxConstraints
_constraintsForCurrentLayout
;
// when null, we don't have a current layout
InlineBas
e
_inline
;
InlineBas
e
get
inline
=>
_inline
;
void
set
inline
(
InlineBas
e
value
)
{
RenderInlin
e
_inline
;
RenderInlin
e
get
inline
=>
_inline
;
void
set
inline
(
RenderInlin
e
value
)
{
if
(
_inline
==
value
)
return
;
_inline
=
value
;
...
...
packages/flutter/lib/widgets/basic.dart
View file @
7b678ff3
...
...
@@ -445,17 +445,17 @@ class Flexible extends ParentDataNode {
:
super
(
child
,
new
FlexBoxParentData
()..
flex
=
flex
,
key:
key
);
}
class
Inline
extends
LeafRenderObjectWrapper
{
Inline
({
Key
key
,
this
.
text
})
:
super
(
key:
key
);
class
Paragraph
extends
LeafRenderObjectWrapper
{
Paragraph
({
Key
key
,
this
.
inline
})
:
super
(
key:
key
);
final
InlineBase
text
;
final
RenderInline
inline
;
RenderParagraph
createNode
()
=>
new
RenderParagraph
(
text
);
RenderParagraph
createNode
()
=>
new
RenderParagraph
(
inline
);
RenderParagraph
get
root
=>
super
.
root
;
void
syncRenderObject
(
Widget
old
)
{
super
.
syncRenderObject
(
old
);
root
.
inline
=
text
;
root
.
inline
=
inline
;
}
}
...
...
@@ -463,20 +463,26 @@ class StyledText extends Component {
// elements ::= "string" | [<text-style> <elements>*]
// Where "string" is text to display and text-style is an instance of
// TextStyle. The text-style applies to all of the elements that follow.
StyledText
({
this
.
elements
,
Key
key
})
:
super
(
key:
key
);
StyledText
({
this
.
elements
,
Key
key
})
:
super
(
key:
key
)
{
assert
(
_toInline
(
elements
)
!=
null
);
}
final
dynamic
elements
;
InlineBas
e
_toInline
(
dynamic
element
)
{
RenderInlin
e
_toInline
(
dynamic
element
)
{
if
(
element
is
String
)
return
new
InlineText
(
element
);
if
(
element
is
Iterable
&&
element
.
first
is
TextStyle
)
return
new
InlineStyle
(
element
.
first
,
element
.
skip
(
1
).
map
(
_toInline
).
toList
());
throw
new
ArgumentError
(
"invalid elements"
);
return
new
RenderText
(
element
);
if
(
element
is
Iterable
)
{
dynamic
first
=
element
.
first
;
if
(
first
is
!
TextStyle
)
throw
new
ArgumentError
(
"First element of Iterable is a
${first.runtimeType}
not a TextStyle"
);
return
new
RenderStyled
(
first
,
element
.
skip
(
1
).
map
(
_toInline
).
toList
());
}
throw
new
ArgumentError
(
"Element is
${element.runtimeType}
not a String or an Iterable"
);
}
Widget
build
()
{
return
new
Inline
(
text
:
_toInline
(
elements
));
return
new
Paragraph
(
inline
:
_toInline
(
elements
));
}
}
...
...
@@ -487,7 +493,7 @@ class Text extends Component {
final
TextStyle
style
;
Widget
build
()
{
InlineBase
text
=
new
Inline
Text
(
data
);
RenderInline
inline
=
new
Render
Text
(
data
);
TextStyle
defaultStyle
=
DefaultTextStyle
.
of
(
this
);
TextStyle
combinedStyle
;
if
(
defaultStyle
!=
null
)
{
...
...
@@ -499,8 +505,8 @@ class Text extends Component {
combinedStyle
=
style
;
}
if
(
combinedStyle
!=
null
)
text
=
new
InlineStyle
(
combinedStyle
,
[
text
]);
return
new
Inline
(
text:
text
);
inline
=
new
RenderStyled
(
combinedStyle
,
[
inline
]);
return
new
Paragraph
(
inline:
inline
);
}
}
...
...
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