Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text layout & Sliver update & Flow Refactor #454

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
4621d58
feat(text/flow/sliver): more feat merge
pba-cra Aug 10, 2023
c72b037
Delete scroll_physics.dart
andycall Aug 10, 2023
e6f845d
fix: support sliver recommendDeferredLoading
andycall Aug 11, 2023
1988306
chore: fix linter.
andycall Aug 15, 2023
6e2ef2c
fix: fix parent types in widget mode.
andycall Aug 15, 2023
b517eb9
fix(eror): fix flow layout error and sliver feat
pba-cra Aug 17, 2023
2af24c5
Merge branch 'main' into feature/text-flow-sliver-css
pba-cra Aug 17, 2023
be4b1b0
fix(flow): merge fix error logic
pba-cra Aug 17, 2023
3fd95d2
Merge branch 'feature/text-flow-sliver-css' of github.com:openwebf/we…
pba-cra Aug 17, 2023
ca1d418
fix(text): fix text-span to webftextspan error
pba-cra Aug 18, 2023
47798d0
fix(flow): adjustSize null check error
pba-cra Aug 18, 2023
84c0dae
fix(margin&flex): negative margin use error when flex just-content:sp…
pba-cra Aug 26, 2023
704b140
fix(flow/text): flow/flex/text/css error
pba-cra Sep 4, 2023
979b734
feat(text/flow/sliver): more feat merge
pba-cra Aug 10, 2023
3a71602
Delete scroll_physics.dart
andycall Aug 10, 2023
e82c686
fix: support sliver recommendDeferredLoading
andycall Aug 11, 2023
faa2785
chore: fix linter.
andycall Aug 15, 2023
c8d67b3
fix: fix parent types in widget mode.
andycall Aug 15, 2023
434b99b
fix(eror): fix flow layout error and sliver feat
pba-cra Aug 17, 2023
9f1bccf
fix(flow): merge fix error logic
pba-cra Aug 17, 2023
e59845e
fix(text): fix text-span to webftextspan error
pba-cra Aug 18, 2023
89b48cd
fix(flow): adjustSize null check error
pba-cra Aug 18, 2023
0e9d52f
fix(margin&flex): negative margin use error when flex just-content:sp…
pba-cra Aug 26, 2023
637fbcd
fix(flow/text): flow/flex/text/css error
pba-cra Sep 4, 2023
bfbd5a7
Merge branch 'feature/text-flow-sliver-css' of github.com:openwebf/we…
pba-cra Sep 4, 2023
7b170f8
fix(box_model): fix merge error
pba-cra Sep 4, 2023
83f479b
fix: fix assertion when cross render-object tree access size property.
andycall Sep 5, 2023
47441f7
Merge remote-tracking branch 'origin/main' into feature/text-flow-sli…
andycall Sep 18, 2023
2bb279a
Update paragraph.dart
yifei8 Sep 19, 2023
9766c20
Merge remote-tracking branch 'origin/main' into feature/text-flow-sli…
andycall Sep 25, 2023
a4a18ba
Merge remote-tracking branch 'origin/main' into feature/text-flow-sli…
andycall Oct 5, 2023
4acd1f1
fix: flutter 3.13 compact.
andycall Oct 5, 2023
a794e1d
chore: reformat and pretty.
andycall Oct 6, 2023
2922bfc
chore: rename happyVisualOverflow to happenVisualOverflow.
andycall Oct 6, 2023
16495fb
Merge remote-tracking branch 'origin/main' into feature/text-flow-sli…
andycall Dec 27, 2023
bd087d8
fix: fix compile error.
andycall Dec 27, 2023
15ed55b
Merge branch 'main' of github.com:openwebf/webf into feature/text-flo…
devjiangzhou Jan 21, 2024
94f2b73
fix: css flow snapshots
devjiangzhou Jan 22, 2024
89a125d
fix: Baseline rule
May 3, 2024
c4ee464
Merge branch 'main' of github.com:openwebf/webf into feature/text-flo…
May 30, 2024
6d0298c
chore: merge main into TextLayout
May 30, 2024
6e5104b
Merge branch 'main' into feature/text-flow-sliver-css
devjiangzhou Jun 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified integration_tests/snapshots/css/css-flow/blocks.ts.11a2f8281.png
Binary file modified integration_tests/snapshots/css/css-flow/blocks.ts.24b616ae1.png
Binary file modified integration_tests/snapshots/css/css-flow/blocks.ts.3b2912e01.png
Binary file modified integration_tests/snapshots/dom/elements/pre.ts.3745c23b1.png
294 changes: 294 additions & 0 deletions integration_tests/specs/css/css-text/line-join.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
describe('Text Line Join', () => {
it('works with pre span', async () => {
let p = createElement(
'p',
{
xmlns: 'http://www.w3.org/1999/xhtml',
style: {
direction: 'ltr',
},
},
[
createElement(
'String',
{
style: {},
},
[createText(`Begin `)]
),
createText(` pre text.`)
]
);
document.body.appendChild(p);
await snapshot();
});

it('works with pre span and second line break', async () => {
let p = createElement(
'p',
{
xmlns: 'http://www.w3.org/1999/xhtml',
style: {
direction: 'ltr',
},
},
[
createElement(
'Strong',
{
style: {},
},
[createText(`pre text, `)]
),
createText(`this is very long long long line to build break. `)
]
);
document.body.appendChild(p);
await snapshot();
});

it('works with pre span and first line break', async () => {
let p = createElement(
'p',
{
xmlns: 'http://www.w3.org/1999/xhtml',
style: {
direction: 'ltr',
},
},
[
createElement(
'Strong',
{
style: {},
},
[
createText(`Begin, his is very long long long line to build break, `),
createText(`pre text.`),
]
),
]
);
document.body.appendChild(p);
await snapshot();
});

it('works with more text join', async () => {
let p = createElement(
'p',
{
xmlns: 'http://www.w3.org/1999/xhtml',
style: {
direction: 'ltr',
},
},
[
createElement(
'Strong',
{
style: {},
},
[
createText(`A text with `),
createText(`B text.`),
createText(`C text. Join next text.`),
createText(`pre text.`)],
),
]
);
document.body.appendChild(p);
await snapshot();
});

it('works with inlineBlock', async () => {
let p = createElement(
'p',
{
xmlns: 'http://www.w3.org/1999/xhtml',
style: {
direction: 'ltr',
},
},
[
createElement('div', {
style: {
'background-color': 'green',
height: '20px',
width: '20px',
'box-sizing': 'border-box',
display: 'inline-block'
},
}),
createElement(
'Strong ',
{
style: {},
},
[
createText(`A text with `),
createText(`B text.`),
createText(`pre text.`)],
),
]
);
document.body.appendChild(p);
await snapshot();
});

it('works with join two inline element', async () => {
let div = createElement(
'div',
{
style: {
width: '100px',
backgroundColor:'#ff2'
},
},
[
createElement('span', {
style: {
},
},[createText(`ffffffffffff`)]),
createElement('span', {
style: {
},
},[createText(`In this article`),]),
]
);
document.body.appendChild(div);
await snapshot();
});

it('works with join two inline element and img', async () => {
let div = createElement(
'div',
{
style: {
width: '100px',
backgroundColor:'#ff2'
},
},
[
createElement('span', {
style: {
},
},[createText(`A`)]),
createElement('span', {
style: {
},
},[
createElement('img', {
src: 'assets/blue15x15.png',
width: '15',
height: '15',
style: {
},
}),
createText(`In this article`),
]),
]
);
document.body.appendChild(div);
await snapshot();
});

it('works with join two inline element and img and more text', async () => {
let div = createElement(
'div',
{
style: {
width: '100px',
backgroundColor:'#ff2'
},
},
[
createElement('span', {
style: {
},
},[createText(`AAA`)]),
createElement('span', {
style: {
},
},[
createElement('img', {
src: 'assets/blue15x15.png',
width: '15',
height: '15',
style: {
},
}),
createText(`In this article`),
]),
]
);
document.body.appendChild(div);
await snapshot();
});

it('works with join two inline element and img and more text', async () => {
let div = createElement(
'div',
{
style: {
width: '100px',
backgroundColor:'#ff2'
},
},
[
createElement('span', {
style: {
},
},[createText(`AAA`)]),
createElement('span', {
style: {
},
},[
createText(`pre text`),
createElement('img', {
src: 'assets/blue15x15.png',
width: '15',
height: '15',
style: {
},
}),
createText(`In this article, test of in the picture`),
]),
]
);
document.body.appendChild(div);
await snapshot();
});

it('works with join two inline element and block', async () => {
let div = createElement(
'div',
{
style: {
width: '100px',
backgroundColor:'#ff2'
},
},
[
createElement('span', {
style: {
},
},[createText(`AAA`)]),
createElement('span', {
style: {
},
},[
createText(`pre text`),
createElement('div', {
width: '15',
height: '15',
style: {
},
}),
createText(`In this article, test of in the picture`),
]),
]
);
document.body.appendChild(div);
await snapshot();
});
});
5 changes: 5 additions & 0 deletions webf/lib/rendering.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export 'src/rendering/resize_observer.dart';
export 'src/rendering/box_model.dart';
export 'src/rendering/replaced.dart';
export 'src/rendering/sliver_list.dart';
export 'src/rendering/resize_observer.dart';
export 'src/rendering/preferred_size.dart';
export 'src/rendering/render_position_holder.dart';
export 'src/rendering/text.dart';
Expand All @@ -29,3 +30,7 @@ export 'src/rendering/paragraph.dart';
export 'src/rendering/line_break.dart';
export 'src/rendering/image.dart';
export 'src/rendering/webf_render_list.dart';
export 'src/rendering/logic_box.dart';

export 'src/rendering/logic_box.dart';

5 changes: 5 additions & 0 deletions webf/lib/src/css/border.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ mixin CSSBorderMixin on RenderStyle {
return Size(border.left + innerSize.width + border.right, border.top + innerSize.height + border.bottom);
}

Size wrapBorderSizeRight(Size innerSize) {
return Size(innerSize.width + border.right,
border.top + innerSize.height + border.bottom);
}

BoxConstraints deflateBorderConstraints(BoxConstraints constraints) {
return constraints.deflate(border);
}
Expand Down
2 changes: 2 additions & 0 deletions webf/lib/src/css/computed_style_declaration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,8 @@ extension VerticalAlignText on VerticalAlign {
return 'top';
case VerticalAlign.bottom:
return 'bottom';
case VerticalAlign.textBottom:
return 'textBottom';
}
}
}
Expand Down
1 change: 1 addition & 0 deletions webf/lib/src/css/css_animation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ mixin CSSAnimationMixin on RenderStyle {

target.dispatchEvent(AnimationEvent(EVENT_ANIMATION_END, animationName: name));
animation.dispose();
_runningAnimation.remove(name);
};

_runningAnimation[name] = animation;
Expand Down
5 changes: 5 additions & 0 deletions webf/lib/src/css/inline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ enum VerticalAlign {
/// Aligns the middle of the element with the baseline plus half the x-height of the parent.
/// @TODO not supported
/// middle,
//
/// Aligns the bottom of the element with the bottom of the parent element's font.
textBottom,
}

mixin CSSInlineMixin on RenderStyle {
Expand All @@ -40,6 +43,8 @@ mixin CSSInlineMixin on RenderStyle {
return VerticalAlign.top;
case BOTTOM:
return VerticalAlign.bottom;
case TEXT_BOTTOM:
return VerticalAlign.textBottom;
}
return VerticalAlign.baseline;
}
Expand Down
1 change: 1 addition & 0 deletions webf/lib/src/css/keywords.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ const String LEFT = 'left';
const String RIGHT = 'right';
const String TOP = 'top';
const String BOTTOM = 'bottom';
const String TEXT_BOTTOM = 'text-bottom';

const String CENTER = 'center';

Expand Down
6 changes: 6 additions & 0 deletions webf/lib/src/css/padding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ mixin CSSPaddingMixin on RenderStyle {
paddingTop.computedValue + innerSize.height + paddingBottom.computedValue);
}

Size wrapPaddingSizeRight(Size innerSize) {
return Size(
innerSize.width + paddingRight.computedValue,
paddingTop.computedValue + innerSize.height + paddingBottom.computedValue
);
}
void debugPaddingProperties(DiagnosticPropertiesBuilder properties) {
properties.add(DiagnosticsProperty('padding', padding));
}
Expand Down
4 changes: 4 additions & 0 deletions webf/lib/src/css/sliver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import 'package:flutter/rendering.dart';
import 'package:webf/css.dart';
import 'package:webf/rendering.dart';

mixin CSSSliverMixin on RenderStyle {
@override
Expand All @@ -13,6 +14,9 @@ mixin CSSSliverMixin on RenderStyle {
set sliverDirection(Axis? value) {
if (_sliverDirection == value) return;
_sliverDirection = value;
if(renderBoxModel!=null && renderBoxModel is RenderSliverListLayout) {
(renderBoxModel as RenderSliverListLayout).refreshAxis();
}
renderBoxModel?.markNeedsLayout();
}

Expand Down
Loading
Loading