2017-01-02 02:22:45 -08:00
|
|
|
/**
|
2022-10-04 13:59:32 -07:00
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
2017-01-02 02:22:45 -08:00
|
|
|
*
|
2018-02-16 18:24:55 -08:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2018-01-19 11:25:26 -08:00
|
|
|
*
|
|
|
|
* @format
|
2017-01-02 02:22:45 -08:00
|
|
|
*/
|
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
global.getMeasureCounter = function (Yoga, cb, staticWidth, staticHeight) {
|
|
|
|
let counter = 0;
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2018-01-19 11:25:26 -08:00
|
|
|
return {
|
2022-12-28 01:27:12 -08:00
|
|
|
inc: function (width, widthMode, height, heightMode) {
|
2018-01-19 11:25:26 -08:00
|
|
|
counter += 1;
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2018-01-19 11:25:26 -08:00
|
|
|
return cb
|
|
|
|
? cb(width, widthMode, height, heightMode)
|
2022-12-28 01:27:12 -08:00
|
|
|
: { width: staticWidth, height: staticHeight };
|
2018-01-19 11:25:26 -08:00
|
|
|
},
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
get: function () {
|
2018-01-19 11:25:26 -08:00
|
|
|
return counter;
|
|
|
|
},
|
|
|
|
};
|
2017-01-02 02:22:45 -08:00
|
|
|
};
|
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
global.getMeasureCounterMax = function (Yoga) {
|
|
|
|
return getMeasureCounter(Yoga, (width, widthMode, height, heightMode) => {
|
|
|
|
const measuredWidth =
|
|
|
|
widthMode === Yoga.MEASURE_MODE_UNDEFINED ? 10 : width;
|
|
|
|
const measuredHeight =
|
2018-01-19 11:25:26 -08:00
|
|
|
heightMode === Yoga.MEASURE_MODE_UNDEFINED ? 10 : height;
|
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
return { width: measuredWidth, height: measuredHeight };
|
2018-01-19 11:25:26 -08:00
|
|
|
});
|
|
|
|
};
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
global.getMeasureCounterMin = function (Yoga) {
|
|
|
|
return getMeasureCounter(Yoga, (width, widthMode, height, heightMode) => {
|
|
|
|
const measuredWidth =
|
2018-01-19 11:25:26 -08:00
|
|
|
widthMode === Yoga.MEASURE_MODE_UNDEFINED ||
|
|
|
|
(widthMode == Yoga.MEASURE_MODE_AT_MOST && width > 10)
|
|
|
|
? 10
|
|
|
|
: width;
|
2022-12-28 01:27:12 -08:00
|
|
|
const measuredHeight =
|
2018-01-19 11:25:26 -08:00
|
|
|
heightMode === Yoga.MEASURE_MODE_UNDEFINED ||
|
|
|
|
(heightMode == Yoga.MEASURE_MODE_AT_MOST && height > 10)
|
|
|
|
? 10
|
|
|
|
: height;
|
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
return { width: measuredWidth, height: measuredHeight };
|
2018-01-19 11:25:26 -08:00
|
|
|
});
|
2017-01-02 02:22:45 -08:00
|
|
|
};
|