Summary: X-link: https://github.com/facebook/litho/pull/976 Pull Request resolved: https://github.com/facebook/yoga/pull/1586 X-link: https://github.com/facebook/react-native/pull/43299 Add the React Clang Tidy config to Yoga, run the auto fixes, and make some manual mechanical tweaks. Notably, the automatic changes to the infra for generating a Yoga tree from JSON capture make it 70% faster. Before: {F1463947076} After: {F1463946802} This also cleans up all the no-op shallow const parameters in headers. {F1463943386} Not all checks are available in all environments, but that is okay, as Clang Tidy will gracefully skip them. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D54461054 fbshipit-source-id: dbd2d9ce51afd3174d1f2c6d439fa7d08baff46f
90 lines
2.3 KiB
C++
90 lines
2.3 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.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <bitset>
|
|
|
|
#include <yoga/Yoga.h>
|
|
#include <yoga/enums/Errata.h>
|
|
#include <yoga/enums/ExperimentalFeature.h>
|
|
#include <yoga/enums/LogLevel.h>
|
|
|
|
// Tag struct used to form the opaque YGConfigRef for the public C API
|
|
struct YGConfig {};
|
|
|
|
namespace facebook::yoga {
|
|
|
|
class Config;
|
|
class Node;
|
|
|
|
using ExperimentalFeatureSet = std::bitset<ordinalCount<ExperimentalFeature>()>;
|
|
|
|
// Whether moving a node from an old to new config should dirty previously
|
|
// calculated layout results.
|
|
bool configUpdateInvalidatesLayout(
|
|
const Config& oldConfig,
|
|
const Config& newConfig);
|
|
|
|
class YG_EXPORT Config : public ::YGConfig {
|
|
public:
|
|
explicit Config(YGLogger logger) : logger_{logger} {}
|
|
|
|
void setUseWebDefaults(bool useWebDefaults);
|
|
bool useWebDefaults() const;
|
|
|
|
void setExperimentalFeatureEnabled(ExperimentalFeature feature, bool enabled);
|
|
bool isExperimentalFeatureEnabled(ExperimentalFeature feature) const;
|
|
ExperimentalFeatureSet getEnabledExperiments() const;
|
|
|
|
void setErrata(Errata errata);
|
|
void addErrata(Errata errata);
|
|
void removeErrata(Errata errata);
|
|
Errata getErrata() const;
|
|
bool hasErrata(Errata errata) const;
|
|
|
|
void setPointScaleFactor(float pointScaleFactor);
|
|
float getPointScaleFactor() const;
|
|
|
|
void setContext(void* context);
|
|
void* getContext() const;
|
|
|
|
void setLogger(YGLogger logger);
|
|
void log(
|
|
const yoga::Node* node,
|
|
LogLevel logLevel,
|
|
const char* format,
|
|
va_list args) const;
|
|
|
|
void setCloneNodeCallback(YGCloneNodeFunc cloneNode);
|
|
YGNodeRef
|
|
cloneNode(YGNodeConstRef node, YGNodeConstRef owner, size_t childIndex) const;
|
|
|
|
static const Config& getDefault();
|
|
|
|
private:
|
|
YGCloneNodeFunc cloneNodeCallback_{nullptr};
|
|
YGLogger logger_{};
|
|
|
|
bool useWebDefaults_ : 1 = false;
|
|
|
|
ExperimentalFeatureSet experimentalFeatures_{};
|
|
Errata errata_ = Errata::None;
|
|
float pointScaleFactor_ = 1.0f;
|
|
void* context_ = nullptr;
|
|
};
|
|
|
|
inline Config* resolveRef(const YGConfigRef ref) {
|
|
return static_cast<Config*>(ref);
|
|
}
|
|
|
|
inline const Config* resolveRef(const YGConfigConstRef ref) {
|
|
return static_cast<const Config*>(ref);
|
|
}
|
|
|
|
} // namespace facebook::yoga
|