Skip to content

Commit 47441f7

Browse files
committed
Merge remote-tracking branch 'origin/main' into feature/text-flow-sliver-css
2 parents 83f479b + aafcda7 commit 47441f7

File tree

10 files changed

+117
-10
lines changed

10 files changed

+117
-10
lines changed

bridge/core/html/parser/html_parser.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <utility>
77

8+
#include "core/dom/comment.h"
89
#include "core/dom/document.h"
910
#include "core/dom/element.h"
1011
#include "core/dom/text.h"
@@ -92,6 +93,23 @@ void HTMLParser::traverseHTML(Node* root_node, GumboNode* node) {
9293
} else if (child->type == GUMBO_NODE_TEXT) {
9394
auto* text = context->document()->createTextNode(AtomicString(ctx, child->v.text.text), ASSERT_NO_EXCEPTION());
9495
root_container->AppendChild(text);
96+
} else if (child->type == GUMBO_NODE_WHITESPACE) {
97+
bool isBlankSpace = true;
98+
int nLen = strlen(child->v.text.text);
99+
for (int j = 0; j < nLen; ++j) {
100+
isBlankSpace = child->v.text.text[j] == ' ';
101+
if (!isBlankSpace) {
102+
break;
103+
}
104+
}
105+
106+
if (isBlankSpace) {
107+
if (nLen > 0) {
108+
auto* textNode =
109+
context->document()->createTextNode(AtomicString(ctx, child->v.text.text), ASSERT_NO_EXCEPTION());
110+
root_container->appendChild(textNode, ASSERT_NO_EXCEPTION());
111+
}
112+
}
95113
}
96114
}
97115
}

integration_tests/scripts/html_loader.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,10 @@ const loader = function(source) {
5151
}
5252
})
5353

54-
const htmlString = root.toString().replace(/['\n]/g, function(c){
55-
return {'\n': '','\'': '\\'}[c];
56-
});
57-
5854
return `
5955
describe('HTMLSpec/${testRelativePath}', () => {
6056
// Use html_parse to parser html in html file.
61-
const html_parse = () => __webf_parse_html__(\`${htmlString}\`);
57+
const html_parse = () => __webf_parse_html__(\`${root.toString()}\`);
6258
var index = 0;
6359
const snapshotAction = async () => { await snapshot(null, '${snapshotFilepath}', ${scripts.length === 0 ? 'null' : 'index.toString()'}); index++; };
6460
${isFit ? 'fit' : isXit ? 'xit' : 'it'}("should work", async (done) => {\
Loading

integration_tests/specs/css/css-box/margin_collapse-001-manual.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,5 @@
5050
</body>
5151
<script>
5252
await snapshotAction();
53-
await sleep(0.1);
5453
</script>
5554
</html>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
6+
.emptyStyle:empty {
7+
background: #ff0000;
8+
height: 50px;
9+
width: 300px;
10+
}
11+
</style>
12+
</head>
13+
14+
<body class="emptyStyle">
15+
<p>p</p>
16+
<p class="emptyStyle"></p>
17+
<p>p1</p>
18+
<p class="emptyStyle"> </p>
19+
<p>h1</p>
20+
<h1 class="emptyStyle"> </h1>
21+
<p>h2</p>
22+
<h2 class="emptyStyle"></h2>
23+
<p>h3</p>
24+
<p>h4</p>
25+
<div class="emptyStyle" id="debug"></div>
26+
<div class="empty" id="debug1">xx</div>
27+
<div class="emptyStyle" id="debug"> </div>
28+
<div class="empty" id="debug1">xx11</div>
29+
<div class="emptyStyle" id="debug"><!-- xx --></div>
30+
<div class="empty" id="debug1">xx22</div>
31+
<p class="emptyStyle" id="debug"></p>
32+
<div class="empty" id="debug1">xx33</div>
33+
</body>
34+
</html>

webf/CHANGELOG.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,52 @@
1+
## 0.15.0
2+
3+
This version will support Flutter 3.10.x
4+
5+
**Break Changes**
6+
7+
1. Remove `navigator.connection` API. https://github.com/openwebf/webf/pull/411
8+
9+
**Features**
10+
11+
1. Upgrade Flutter support to 3.10.x. https://github.com/openwebf/webf/pull/345
12+
2. Optimize location API for better performance results. https://github.com/openwebf/webf/pull/420
13+
3. Optimize the size of webf_bridge.xcframework and quickjs.xcframework. https://github.com/openwebf/webf/pull/414
14+
4. Support CSS initial length value. https://github.com/openwebf/webf/pull/421
15+
5. Optimize Element.children() and Document.all() performance. https://github.com/openwebf/webf/pull/424
16+
6. Support base64 format font data in `@font-face` src. https://github.com/openwebf/webf/pull/399
17+
7. Support Element.dir API. https://github.com/openwebf/webf/pull/418
18+
8. Add `<circle />` and `<ellipse>` tags for SVG. https://github.com/openwebf/webf/pull/423
19+
9. Support share customized JS properties in event object. https://github.com/openwebf/webf/pull/427
20+
10. Support `window.pageXOffset` and `window.pageYOffset` API. https://github.com/openwebf/webf/pull/428/files
21+
11. Optimize layout/paint performance when block box size is fixed. https://github.com/openwebf/webf/pull/450
22+
12. Optimize performance when update Element.className. https://github.com/openwebf/webf/pull/452
23+
13. Support CanvasRenderingContext2D.createPattern() API. https://github.com/openwebf/webf/pull/464
24+
25+
**Bug Fixed**
26+
27+
1. Fix use css vars with initial. https://github.com/openwebf/webf/pull/421
28+
2. Fix toggle position: fixed on bodyElement with other fixed elements. https://github.com/openwebf/webf/pull/416
29+
3. Fss nth-child not work. https://github.com/openwebf/webf/pull/417
30+
4. Fix Node.childNodes didn't update when nodes changed. https://github.com/openwebf/webf/pull/419
31+
5. Fix loading fonts cause assertion when remove or attach RenderObjects. https://github.com/openwebf/webf/pull/425
32+
6. Fix percentage width and height not working under inline block box. https://github.com/openwebf/webf/pull/430
33+
7. Fix Node.insertBefore with SVGElement error. https://github.com/openwebf/webf/pull/431
34+
8. Fix cookie delete file error when it's not available. https://github.com/openwebf/webf/pull/429
35+
9. Fix read ANDROID_SDK_HOME before implying to platform defaults. https://github.com/openwebf/webf/pull/422
36+
10. Fix cookie delete file error. https://github.com/openwebf/webf/pull/429
37+
11. Fix percentage width and height not working under inline block box. https://github.com/openwebf/webf/pull/430
38+
12. Fix Node.insertBefore with SVGElement error. https://github.com/openwebf/webf/pull/431
39+
13. Fix DevTool's network panel not working. https://github.com/openwebf/webf/pull/435
40+
14. Losen intl dependency constraint. https://github.com/openwebf/webf/pull/439
41+
15. Fix built-in methods in the event object cannot be overridden. https://github.com/openwebf/webf/pull/443
42+
16. Fix crash when touching pseduo elements. https://github.com/openwebf/webf/pull/445
43+
17. Fix event not responding when multiple flutter engine created. https://github.com/openwebf/webf/pull/451
44+
18. Fix Element.style.cssText API not works. https://github.com/openwebf/webf/pull/455
45+
19. Fix use-of-free crash of shared string property in event object. https://github.com/openwebf/webf/pull/458
46+
20. Fix dynamic build items in WidgetElement. https://github.com/openwebf/webf/pull/461
47+
21. Fix CSS content property have sequences of unicode chars. https://github.com/openwebf/webf/pull/463
48+
22. Fix crash when create unsupported svg element with style. https://github.com/openwebf/webf/pull/465
49+
150
## 0.14.1
251

352
**Features**

webf/lib/src/css/query_selector.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ class SelectorEvaluator extends SelectorVisitor {
183183

184184
// http://dev.w3.org/csswg/selectors-4/#the-empty-pseudo
185185
case 'empty':
186-
return _element!.childNodes.every((n) => !(n is Element || n is TextNode && n.data.isNotEmpty));
186+
return _element!.childNodes.every((n) =>
187+
!(n is Element || (n is TextNode && n.data.isNotEmpty))
188+
);
187189

188190
// http://dev.w3.org/csswg/selectors-4/#the-blank-pseudo
189191
case 'blank':

webf/lib/src/rendering/paragraph.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,10 @@ class WebFRenderParagraph extends RenderBox
294294

295295
/// Compute distance to baseline of last text line
296296
double computeDistanceToLastLineBaseline() {
297-
double lastLineOffset = _lineRenders[_lineRenders.length - 1].lineRect.top;
297+
if (_lineOffset.isEmpty) {
298+
return 0.0;
299+
}
300+
double lastLineOffset = _lineOffset[_lineOffset.length - 1];
298301
ui.LineMetrics lastLineMetrics = _lineMetrics[_lineMetrics.length - 1];
299302

300303
// Use the baseline of the last line as paragraph baseline.

webf/lib/src/rendering/text.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,13 @@ class RenderTextBox extends RenderBox with RenderObjectWithChildMixin<RenderBox>
393393

394394
// ' a b c' => 'a b c'
395395
static String _trimLeftWhitespace(String string) {
396-
return string.replaceAllMapped(_trimLeftWhitespaceReg, (Match m) => '${m[1]}');
396+
String result = string.replaceAllMapped(_trimLeftWhitespaceReg, (Match m) =>
397+
'${m[1]}'
398+
);
399+
if (result.startsWith(' ')) {
400+
return '';
401+
}
402+
return result;
397403
}
398404

399405
// 'a b c ' => 'a b c'

webf/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: webf
22
description: W3C standards-compliant web rendering engine based on Flutter, allowing web applications to run natively on Flutter.
3-
version: 0.15.0-beta.1+1
3+
version: 0.15.0
44
homepage: https://openwebf.com
55

66
environment:

0 commit comments

Comments
 (0)