Skip to content

Commit 040c646

Browse files
authored
Merge pull request #488 from openwebf/revert-434-feat/empty_fix
Revert "fix: fix :empty selector."
2 parents 1cc8a36 + 976a2ba commit 040c646

File tree

8 files changed

+8
-66
lines changed

8 files changed

+8
-66
lines changed

bridge/core/html/parser/html_parser.cc

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

66
#include <utility>
77

8-
#include "core/dom/comment.h"
98
#include "core/dom/document.h"
109
#include "core/dom/element.h"
1110
#include "core/dom/text.h"
@@ -93,23 +92,6 @@ void HTMLParser::traverseHTML(Node* root_node, GumboNode* node) {
9392
} else if (child->type == GUMBO_NODE_TEXT) {
9493
auto* text = context->document()->createTextNode(AtomicString(ctx, child->v.text.text), ASSERT_NO_EXCEPTION());
9594
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-
}
11395
}
11496
}
11597
}

integration_tests/scripts/html_loader.js

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

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,6 @@
5050
</body>
5151
<script>
5252
await snapshotAction();
53+
await sleep(0.1);
5354
</script>
5455
</html>

integration_tests/specs/css/css-empty/empty.html

Lines changed: 0 additions & 34 deletions
This file was deleted.

webf/lib/src/css/query_selector.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,7 @@ 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) =>
187-
!(n is Element || (n is TextNode && n.data.isNotEmpty))
188-
);
186+
return _element!.childNodes.every((n) => !(n is Element || n is TextNode && n.data.isNotEmpty));
189187

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

webf/lib/src/rendering/paragraph.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,6 @@ class WebFRenderParagraph extends RenderBox
241241

242242
/// Compute distance to baseline of last text line
243243
double computeDistanceToLastLineBaseline() {
244-
if (_lineOffset.isEmpty) {
245-
return 0.0;
246-
}
247244
double lastLineOffset = _lineOffset[_lineOffset.length - 1];
248245
ui.LineMetrics lastLineMetrics = _lineMetrics[_lineMetrics.length - 1];
249246

webf/lib/src/rendering/text.dart

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,7 @@ class RenderTextBox extends RenderBox with RenderObjectWithChildMixin<RenderBox>
315315

316316
// ' a b c' => 'a b c'
317317
static String _trimLeftWhitespace(String string) {
318-
String result = string.replaceAllMapped(_trimLeftWhitespaceReg, (Match m) =>
319-
'${m[1]}'
320-
);
321-
if (result.startsWith(' ')) {
322-
return '';
323-
}
324-
return result;
318+
return string.replaceAllMapped(_trimLeftWhitespaceReg, (Match m) => '${m[1]}');
325319
}
326320

327321
// 'a b c ' => 'a b c'

0 commit comments

Comments
 (0)