提交 3ceb5dc0 编写于 作者: H Hixie

[Effen] Start removing 'position'.

This creates a new RenderNode class that does positioning.
It then creates an fn Container class that uses it just to position things at 0,0 at the full extent of the container.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1128103009
上级 e97a10ed
......@@ -97,22 +97,13 @@ class Drawer extends AnimatedComponent {
static final Style _maskStyle = new Style('''
background-color: black;
will-change: opacity;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;'''
will-change: opacity;'''
);
static final Style _contentStyle = new Style('''
background-color: ${Grey[50]};
will-change: transform;
position: absolute;
width: ${_kWidth}px;
top: 0;
left: 0;
bottom: 0;'''
width: ${_kWidth}px;'''
);
List<UINode> children;
......@@ -152,7 +143,7 @@ class Drawer extends AnimatedComponent {
level: level);
return new EventListenerNode(
new Container(
new FillStackContainer(
style: _style,
children: [ mask, content ]
),
......
......@@ -593,6 +593,42 @@ class FlexContainer extends SkyElementWrapper {
}
}
class FillStackContainer extends SkyElementWrapper {
RenderCSSStack _root;
RenderCSSStack _createNode() => new RenderCSSStack(this);
static final FillStackContainer _emptyContainer = new FillStackContainer();
SkyNodeWrapper get _emptyNode => _emptyContainer;
FillStackContainer({
Object key,
List<UINode> children,
Style style,
String inlineStyle
}) : super(
key: key,
children: _positionNodesToFill(children),
style: style,
inlineStyle: inlineStyle
);
static StackParentData _fillParentData = new StackParentData()
..top = 0.0
..left = 0.0
..right = 0.0
..bottom = 0.0;
static List<UINode> _positionNodesToFill(List<UINode> input) {
if (input == null)
return null;
return input.map((node) {
return new ParentDataNode(node, _fillParentData);
}).toList();
}
}
class TextFragment extends SkyElementWrapper {
RenderCSSInline _root;
......
......@@ -398,6 +398,63 @@ class RenderCSSFlex extends RenderCSSContainer {
}
class StackParentData extends CSSParentData {
double top;
double left;
double right;
double bottom;
void merge(StackParentData other) {
if (other.top != null)
top = other.top;
if (other.left != null)
left = other.left;
if (other.right != null)
right = other.right;
if (other.bottom != null)
bottom = other.bottom;
super.merge(other);
}
}
class RenderCSSStack extends RenderCSSContainer {
RenderCSSStack(debug) : super(debug);
void setupPos(RenderNode child) {
if (child.parentData is! StackParentData)
child.parentData = new StackParentData();
}
static final Style _displayPosition = new Style._addToCache('transform:translateX(0);position:relative');
String stylesToClasses(List<Style> styles) {
return super.stylesToClasses(styles) + ' ' + _displayPosition._className;
}
void markNeedsLayout() {
super.markNeedsLayout();
// pretend we did the layout:
RenderCSS child = _firstChild;
while (child != null) {
assert(child.parentData is StackParentData);
var style = 'position:absolute;';
if (child.parentData.top != null)
style += 'top:${child.parentData.top};';
if (child.parentData.left != null)
style += 'left:${child.parentData.left};';
if (child.parentData.right != null)
style += 'right:${child.parentData.right};';
if (child.parentData.bottom != null)
style += 'bottom:${child.parentData.bottom};';
child._additionalStylesFromParent = style;
child._updateInlineStyleAttribute();
child = child.parentData.nextSibling;
}
}
}
class RenderCSSParagraph extends RenderCSSContainer {
RenderCSSParagraph(debug) : super(debug);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册