Fabric: New `LayoutableShadowNode::measure(...)` which measures the node "outside"
Summary: This diff introduces a new method of `LayoutableShadowNode` called `measure`. The purpose of the method is to measure the node from an "outside" perspective (including paddings and so on). The existing method with the same name (but with slightly different signature) will be renamed to `measureContent` in future diffs. Hense we will have two `measure*` methods: * `measureContent` measures nested content of the node; * `measure` measures the node (outside). This diff also introduces a default implementation of a new measure that uses `layoutTree` under the hood. Measures the node with given layoutConstraints and layoutContext. The size of nested content and the padding should be included, the margin should *not* be included. Changelog: [Internal] Fabric-specific internal change. Reviewed By: JoshuaGross, sammy-SC Differential Revision: D20268047 fbshipit-source-id: 29c28cf16c5afe24f1bfb6e76c42816d4583a8fa
This commit is contained in:
Родитель
90ada5abb1
Коммит
0d33cdf146
|
@ -156,6 +156,21 @@ Size LayoutableShadowNode::measure(LayoutConstraints layoutConstraints) const {
|
|||
return Size();
|
||||
}
|
||||
|
||||
Size LayoutableShadowNode::measure(
|
||||
LayoutContext const &layoutContext,
|
||||
LayoutConstraints const &layoutConstraints) const {
|
||||
auto clonedShadowNode = clone({});
|
||||
auto &layoutableShadowNode =
|
||||
static_cast<LayoutableShadowNode &>(*clonedShadowNode);
|
||||
|
||||
auto localLayoutContext = layoutContext;
|
||||
localLayoutContext.affectedNodes = nullptr;
|
||||
|
||||
layoutableShadowNode.layoutTree(localLayoutContext, layoutConstraints);
|
||||
|
||||
return layoutableShadowNode.getLayoutMetrics().frame.size;
|
||||
}
|
||||
|
||||
Float LayoutableShadowNode::firstBaseline(Size size) const {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -68,6 +68,15 @@ class LayoutableShadowNode : public ShadowNode {
|
|||
*/
|
||||
virtual Size measure(LayoutConstraints layoutConstraints) const;
|
||||
|
||||
/*
|
||||
* Measures the node with given `layoutContext` and `layoutConstraints`.
|
||||
* The size of nested content and the padding should be included, the margin
|
||||
* should *not* be included. Default implementation returns zero size.
|
||||
*/
|
||||
virtual Size measure(
|
||||
LayoutContext const &layoutContext,
|
||||
LayoutConstraints const &layoutConstraints) const;
|
||||
|
||||
/*
|
||||
* Computes layout recursively.
|
||||
* Additional environmental constraints might be provided via `layoutContext`
|
||||
|
|
Загрузка…
Ссылка в новой задаче