-
Notifications
You must be signed in to change notification settings - Fork 303
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
Fix/previous blank #886
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
…t prev and next of text node .
… the nextSibling and previousSibling text node so prev and next node require layout.
…xtSibling and previousSibling text node so prev and next node require layout.
kraken/lib/src/rendering/text.dart
Outdated
@@ -84,6 +154,10 @@ class RenderTextBox extends RenderBox | |||
needsLayout = true; | |||
} | |||
|
|||
void markRenderParagraphLyout() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
拼写 typo
kraken/lib/src/rendering/text.dart
Outdated
@@ -136,6 +210,11 @@ class RenderTextBox extends RenderBox | |||
maxHeight: double.infinity); | |||
} | |||
|
|||
// ' a b c \n' => ' a b c ' | |||
String _collapseWhitespace(String string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个方法可以 static
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
kraken/lib/src/css/display.dart
Outdated
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里已经判断了 parent 是否为 RenderFlowLayout,不需要重复判断 parentData 是否为 RenderLayoutParentData 了
kraken/lib/src/css/display.dart
Outdated
|
||
// 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
从语义上来讲直接用 parentData 命名好了,childParentData 感觉是当前 renderBoxModel 的 child
kraken/lib/src/css/position.dart
Outdated
@@ -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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这段给 textNode 标识的 needsLayout 的逻辑是通用的,可以抽离到 renderBoxModel 中
kraken/lib/src/rendering/text.dart
Outdated
return str.endsWith(WHITE_SPACE_CHAR) || str.endsWith(NEW_LINE_CHAR) || str.endsWith(RETURN_CHAR) || str.endsWith(TAB_CHAR); | ||
} | ||
|
||
String get data { |
There was a problem hiding this comment.
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 的私有变量
kraken/lib/src/dom/node.dart
Outdated
@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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里也可以复用公共的 markAdjacentRenderParagraphNeedsLayout
close #740