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

Fix/previous blank #886

Merged
merged 31 commits into from
Dec 23, 2021
Merged

Fix/previous blank #886

merged 31 commits into from
Dec 23, 2021

Conversation

answershuto
Copy link
Member

close #740

Base automatically changed from feat-css-style-sheet to main November 19, 2021 14:03
Copy link
Member

@wssgcg1213 wssgcg1213 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@answershuto answershuto changed the title Fix/previous blank [WIP]Fix/previous blank Nov 25, 2021
@answershuto answershuto changed the title [WIP]Fix/previous blank Fix/previous blank Dec 22, 2021
@@ -84,6 +154,10 @@ class RenderTextBox extends RenderBox
needsLayout = true;
}

void markRenderParagraphLyout() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

拼写 typo

@@ -136,6 +210,11 @@ class RenderTextBox extends RenderBox
maxHeight: double.infinity);
}

// ' a b c \n' => ' a b c '
String _collapseWhitespace(String string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个方法可以 static

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

wssgcg1213
wssgcg1213 previously approved these changes Dec 23, 2021
renderBoxModel?.markNeedsLayout();

// The display changes of the node may affect the whitespace of the nextSibling and previousSibling text node so prev and next node require layout.
if (renderBoxModel?.parent != null && renderBoxModel?.parent is RenderFlowLayout && renderBoxModel?.parentData is RenderLayoutParentData) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里已经判断了 parent 是否为 RenderFlowLayout,不需要重复判断 parentData 是否为 RenderLayoutParentData 了


// The display changes of the node may affect the whitespace of the nextSibling and previousSibling text node so prev and next node require layout.
if (renderBoxModel?.parent != null && renderBoxModel?.parent is RenderFlowLayout && renderBoxModel?.parentData is RenderLayoutParentData) {
RenderLayoutParentData childParentData = renderBoxModel?.parentData as RenderLayoutParentData;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

从语义上来讲直接用 parentData 命名好了,childParentData 感觉是当前 renderBoxModel 的 child

@@ -99,6 +99,17 @@ mixin CSSPositionMixin on RenderStyle {
_markParentNeedsLayout();
// Position change may affect transformed display
// https://www.w3.org/TR/css-display-3/#transformations

// The position changes of the node may affect the whitespace of the nextSibling and previousSibling text node so prev and next node require layout.
if (renderBoxModel?.parent != null && renderBoxModel?.parent is RenderFlowLayout && renderBoxModel?.parentData is RenderLayoutParentData) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段给 textNode 标识的 needsLayout 的逻辑是通用的,可以抽离到 renderBoxModel 中

return str.endsWith(WHITE_SPACE_CHAR) || str.endsWith(NEW_LINE_CHAR) || str.endsWith(RETURN_CHAR) || str.endsWith(TAB_CHAR);
}

String get data {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 data 应该只会给 _renderParagraph 内部使用不对外暴露,建议与 originData 对调一下,originData 改成 data,这个 data 改成辟如 _trimmedData 的私有变量

@mustCallSuper
void willDetachRenderer() {
// The node detach may affect the whitespace of the nextSibling and previousSibling text node so prev and next node require layout.
if (parentNode != null && parentNode?.renderer is RenderFlowLayout && renderer?.parentData is RenderLayoutParentData) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里也可以复用公共的 markAdjacentRenderParagraphNeedsLayout

@answershuto answershuto merged commit 28f43c3 into main Dec 23, 2021
@answershuto answershuto deleted the fix/previous_blank branch December 23, 2021 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vue 中不在其它容器中的文本前面会被添加空格
4 participants