Summary: X-link: https://github.com/facebook/react-native/pull/41390 Pull Request resolved: https://github.com/facebook/yoga/pull/1460 Yoga passes `MeasureMode`/`YGMeasureMode` to express constraints in how a box should be measured, given definite or indefinite available space. This is modeled after Android [MeasureSpec](https://developer.android.com/reference/android/view/View.MeasureSpec), with a table above `calculateLayoutImpl()` explaining the CSS terms they map to. This can be confusing when flipping between the spec, and code. This switches internal usages to the CSS terms, but leaves around `YGMeasureMode` since it is the public API passed to measure functions. Reviewed By: joevilches Differential Revision: D51068417 fbshipit-source-id: 0a76266a4e7e0cc39996164607229c3c41de2818
53 lines
1.2 KiB
C++
53 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <yoga/config/Config.h>
|
|
#include <yoga/debug/AssertFatal.h>
|
|
#include <yoga/debug/Log.h>
|
|
#include <yoga/node/Node.h>
|
|
|
|
namespace facebook::yoga {
|
|
|
|
[[noreturn]] void fatalWithMessage(const char* message) {
|
|
#if defined(__cpp_exceptions)
|
|
throw std::logic_error(message);
|
|
#else
|
|
std::terminate();
|
|
#endif
|
|
}
|
|
|
|
void assertFatal(const bool condition, const char* message) {
|
|
if (!condition) {
|
|
yoga::log(LogLevel::Fatal, "%s\n", message);
|
|
fatalWithMessage(message);
|
|
}
|
|
}
|
|
|
|
void assertFatalWithNode(
|
|
const yoga::Node* const node,
|
|
const bool condition,
|
|
const char* message) {
|
|
if (!condition) {
|
|
yoga::log(node, LogLevel::Fatal, "%s\n", message);
|
|
fatalWithMessage(message);
|
|
}
|
|
}
|
|
|
|
void assertFatalWithConfig(
|
|
const yoga::Config* const config,
|
|
const bool condition,
|
|
const char* message) {
|
|
if (!condition) {
|
|
yoga::log(config, LogLevel::Fatal, "%s\n", message);
|
|
fatalWithMessage(message);
|
|
}
|
|
}
|
|
|
|
} // namespace facebook::yoga
|