This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-Qt/doric/yoga/YGConfig.cpp
2021-05-20 18:27:45 +08:00

45 lines
1.1 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "YGConfig.h"
YGConfig::YGConfig(YGLogger logger) : cloneNodeCallback_{nullptr} {
logger_.noContext = logger;
loggerUsesContext_ = false;
}
void YGConfig::log(
YGConfig* config,
YGNode* node,
YGLogLevel logLevel,
void* logContext,
const char* format,
va_list args) {
if (loggerUsesContext_) {
logger_.withContext(config, node, logLevel, logContext, format, args);
} else {
logger_.noContext(config, node, logLevel, format, args);
}
}
YGNodeRef YGConfig::cloneNode(
YGNodeRef node,
YGNodeRef owner,
int childIndex,
void* cloneContext) {
YGNodeRef clone = nullptr;
if (cloneNodeCallback_.noContext != nullptr) {
clone = cloneNodeUsesContext_
? cloneNodeCallback_.withContext(node, owner, childIndex, cloneContext)
: cloneNodeCallback_.noContext(node, owner, childIndex);
}
if (clone == nullptr) {
clone = YGNodeClone(node);
}
return clone;
}