Rename LayoutableShadowNode::measure to LayoutableShadowNode::measureContent

Summary:
Changelog: [internal]

Rename `LayoutableShadowNode::measure` to `LayoutableShadowNode::measureContent` and add LayoutContext as parameter.

Pass `LayoutConstraints` by reference rather than value.

Reviewed By: shergin

Differential Revision: D22043727

fbshipit-source-id: b668240c45b658db5b114630b73d7407d35482aa
This commit is contained in:
Samuel Susla
2020-06-17 10:22:32 -07:00
committed by Facebook GitHub Bot
parent 6afc984e81
commit ec9da43de5
13 changed files with 39 additions and 16 deletions
@@ -83,7 +83,9 @@ ImageSource SliderShadowNode::getThumbImageSource() const {
#pragma mark - LayoutableShadowNode
Size SliderShadowNode::measure(LayoutConstraints layoutConstraints) const {
Size SliderShadowNode::measureContent(
LayoutContext const &layoutContext,
LayoutConstraints const &layoutConstraints) const {
if (SliderMeasurementsManager::shouldMeasureSlider()) {
return measurementsManager_->measure(getSurfaceId(), layoutConstraints);
}
@@ -55,7 +55,9 @@ class SliderShadowNode final : public ConcreteViewShadowNode<
#pragma mark - LayoutableShadowNode
Size measure(LayoutConstraints layoutConstraints) const override;
Size measureContent(
LayoutContext const &layoutContext,
LayoutConstraints const &layoutConstraints) const override;
void layout(LayoutContext layoutContext) override;
private:
@@ -21,8 +21,9 @@ void AndroidSwitchShadowNode::setAndroidSwitchMeasurementsManager(
#pragma mark - LayoutableShadowNode
Size AndroidSwitchShadowNode::measure(
LayoutConstraints layoutConstraints) const {
Size AndroidSwitchShadowNode::measureContent(
LayoutContext const &layoutContext,
LayoutConstraints const &layoutConstraints) const {
return measurementsManager_->measure(getSurfaceId(), layoutConstraints);
}
@@ -35,7 +35,9 @@ class AndroidSwitchShadowNode final : public ConcreteViewShadowNode<
#pragma mark - LayoutableShadowNode
Size measure(LayoutConstraints layoutConstraints) const override;
Size measureContent(
LayoutContext const &layoutContext,
LayoutConstraints const &layoutConstraints) const override;
private:
std::shared_ptr<AndroidSwitchMeasurementsManager> measurementsManager_;
@@ -116,9 +116,11 @@ void ParagraphShadowNode::updateStateIfNeeded(Content const &content) {
#pragma mark - LayoutableShadowNode
Size ParagraphShadowNode::measure(LayoutConstraints layoutConstraints) const {
Size ParagraphShadowNode::measureContent(
LayoutContext const &layoutContext,
LayoutConstraints const &layoutConstraints) const {
auto content =
getContentWithMeasuredAttachments(LayoutContext{}, layoutConstraints);
getContentWithMeasuredAttachments(layoutContext, layoutConstraints);
auto attributedString = content.attributedString;
if (attributedString.isEmpty()) {
@@ -62,7 +62,9 @@ class ParagraphShadowNode : public ConcreteViewShadowNode<
#pragma mark - LayoutableShadowNode
void layout(LayoutContext layoutContext) override;
Size measure(LayoutConstraints layoutConstraints) const override;
Size measureContent(
LayoutContext const &layoutContext,
LayoutConstraints const &layoutConstraints) const override;
/*
* Internal representation of the nested content of the node in a format
@@ -165,8 +165,9 @@ void AndroidTextInputShadowNode::updateStateIfNeeded() {
#pragma mark - LayoutableShadowNode
Size AndroidTextInputShadowNode::measure(
LayoutConstraints layoutConstraints) const {
Size AndroidTextInputShadowNode::measureContent(
LayoutContext const &layoutContext,
LayoutConstraints const &layoutConstraints) const {
// Layout is called right after measure.
// Measure is marked as `const`, and `layout` is not; so State can be updated
// during layout, but not during `measure`. If State is out-of-date in layout,
@@ -56,7 +56,9 @@ class AndroidTextInputShadowNode : public ConcreteViewShadowNode<
#pragma mark - LayoutableShadowNode
Size measure(LayoutConstraints layoutConstraints) const override;
Size measureContent(
LayoutContext const &layoutContext,
LayoutConstraints const &layoutConstraints) const override;
void layout(LayoutContext layoutContext) override;
private:
@@ -97,7 +97,9 @@ void TextInputShadowNode::updateStateIfNeeded() {
#pragma mark - LayoutableShadowNode
Size TextInputShadowNode::measure(LayoutConstraints layoutConstraints) const {
Size TextInputShadowNode::measureContent(
LayoutContext const &layoutContext,
LayoutConstraints const &layoutConstraints) const {
return textLayoutManager_
->measure(
attributedStringBoxToMeasure(),
@@ -54,7 +54,9 @@ class TextInputShadowNode : public ConcreteViewShadowNode<
#pragma mark - LayoutableShadowNode
Size measure(LayoutConstraints layoutConstraints) const override;
Size measureContent(
LayoutContext const &layoutContext,
LayoutConstraints const &layoutConstraints) const override;
void layout(LayoutContext layoutContext) override;
private:
@@ -442,7 +442,8 @@ YGSize YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector(
break;
}
auto size = shadowNodeRawPtr->measure({minimumSize, maximumSize});
auto size = shadowNodeRawPtr->measureContent(
LayoutContext{}, {minimumSize, maximumSize});
return YGSize{yogaFloatFromFloat(size.width),
yogaFloatFromFloat(size.height)};
@@ -168,7 +168,9 @@ LayoutableShadowNode::getLayoutableChildNodes() const {
return layoutableChildren;
}
Size LayoutableShadowNode::measure(LayoutConstraints layoutConstraints) const {
Size LayoutableShadowNode::measureContent(
LayoutContext const &layoutContext,
LayoutConstraints const &layoutConstraints) const {
return Size();
}
@@ -76,7 +76,9 @@ class LayoutableShadowNode : public ShadowNode {
* given constrains and relying on possible layout.
* Default implementation returns zero size.
*/
virtual Size measure(LayoutConstraints layoutConstraints) const;
virtual Size measureContent(
LayoutContext const &layoutContext,
LayoutConstraints const &layoutConstraints) const;
/*
* Measures the node with given `layoutContext` and `layoutConstraints`.