mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 07:01:24 +00:00
commit
d58b1097ac
@ -2238,22 +2238,6 @@ bool AceContainer::IsTransparentBg() const
|
||||
return bgColor == Color::TRANSPARENT || bgOpacity == transparentOpacity;
|
||||
}
|
||||
|
||||
bool AceContainer::ParseThemeConfig(const std::string& themeConfig)
|
||||
{
|
||||
std::regex pattern("\"font\":(\\d+)");
|
||||
std::smatch match;
|
||||
if (std::regex_search(themeConfig, match, pattern)) {
|
||||
std::string fontValue = match[1].str();
|
||||
if (fontValue.length() > 1) {
|
||||
LOGE("ParseThemeConfig error value");
|
||||
return false;
|
||||
}
|
||||
int font = std::stoi(fontValue);
|
||||
return font == 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void AceContainer::SetWindowStyle(int32_t instanceId, WindowModal windowModal, ColorScheme colorScheme)
|
||||
{
|
||||
auto container = AceType::DynamicCast<AceContainer>(AceEngine::Get().GetContainer(instanceId));
|
||||
|
@ -315,8 +315,6 @@ public:
|
||||
|
||||
void SetLocalStorage(NativeReference* storage, const std::shared_ptr<OHOS::AbilityRuntime::Context>& context);
|
||||
|
||||
bool ParseThemeConfig(const std::string& themeConfig);
|
||||
|
||||
void CheckAndSetFontFamily() override;
|
||||
|
||||
void OnFinish()
|
||||
|
@ -15,8 +15,10 @@
|
||||
|
||||
#include "core/components/common/properties/color.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <regex>
|
||||
|
||||
#include "base/utils/utils.h"
|
||||
#include "core/common/resource/resource_manager.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
@ -91,7 +93,15 @@ Color Color::FromString(std::string colorStr, uint32_t maskAlpha, Color defaultC
|
||||
newColorStr += c;
|
||||
newColorStr += c;
|
||||
}
|
||||
auto value = stoul(newColorStr, nullptr, COLOR_STRING_BASE);
|
||||
char* end = nullptr;
|
||||
unsigned long int value = strtoul(newColorStr.c_str(), &end, COLOR_STRING_BASE);
|
||||
if (errno == ERANGE) {
|
||||
LOGF("%{public}s is out of range.", newColorStr.c_str());
|
||||
abort();
|
||||
}
|
||||
if (value == 0 && end == newColorStr.c_str()) {
|
||||
LOGW("input %{public}s can not be converted to number, use default color:0x00000000.", newColorStr.c_str());
|
||||
}
|
||||
if (newColorStr.length() < COLOR_STRING_SIZE_STANDARD) {
|
||||
// no alpha specified, set alpha to 0xff
|
||||
value |= maskAlpha;
|
||||
@ -441,7 +451,15 @@ bool Color::MatchColorWithMagic(std::string& colorStr, uint32_t maskAlpha, Color
|
||||
return false;
|
||||
}
|
||||
colorStr.erase(0, 1);
|
||||
auto value = stoul(colorStr, nullptr, COLOR_STRING_BASE);
|
||||
char* end = nullptr;
|
||||
unsigned long int value = strtoul(colorStr.c_str(), &end, COLOR_STRING_BASE);
|
||||
if (errno == ERANGE) {
|
||||
LOGF("%{public}s is out of range.", colorStr.c_str());
|
||||
abort();
|
||||
}
|
||||
if (value == 0 && end == colorStr.c_str()) {
|
||||
LOGW("input %{public}s can not be converted to number, use default color:0x00000000.", colorStr.c_str());
|
||||
}
|
||||
if (colorStr.length() < COLOR_STRING_SIZE_STANDARD) {
|
||||
// no alpha specified, set alpha to 0xff
|
||||
value |= maskAlpha;
|
||||
@ -465,7 +483,16 @@ bool Color::MatchColorWithMagicMini(std::string& colorStr, uint32_t maskAlpha, C
|
||||
newColorStr += c;
|
||||
newColorStr += c;
|
||||
}
|
||||
auto value = stoul(newColorStr, nullptr, COLOR_STRING_BASE);
|
||||
char* end = nullptr;
|
||||
unsigned long int value = strtoul(newColorStr.c_str(), &end, COLOR_STRING_BASE);
|
||||
if (errno == ERANGE) {
|
||||
LOGF("%{public}s is out of range.", newColorStr.c_str());
|
||||
abort();
|
||||
}
|
||||
if (value == 0 && end == newColorStr.c_str()) {
|
||||
LOGW("input %{public}s can not be converted to number, use default color:0x00000000.", newColorStr.c_str());
|
||||
}
|
||||
|
||||
if (newColorStr.length() < COLOR_STRING_SIZE_STANDARD) {
|
||||
// no alpha specified, set alpha to 0xff
|
||||
value |= maskAlpha;
|
||||
|
@ -14,7 +14,8 @@
|
||||
*/
|
||||
|
||||
#include "core/pipeline/pipeline_context.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include "base/utils/utils.h"
|
||||
|
||||
#ifdef ENABLE_ROSEN_BACKEND
|
||||
#include "render_service_base/include/platform/common/rs_system_properties.h"
|
||||
@ -3526,7 +3527,12 @@ void PipelineContext::RestoreNodeInfo(std::unique_ptr<JsonValue> nodeInfo)
|
||||
while (child->IsValid()) {
|
||||
auto key = child->GetKey();
|
||||
auto value = child->GetString();
|
||||
restoreNodeInfo_.try_emplace(std::stoi(key), value);
|
||||
int vital = std::atoi(key.c_str());
|
||||
if (vital == 0) {
|
||||
LOGF("input %{public}s can not be converted to number.", key.c_str());
|
||||
abort();
|
||||
}
|
||||
restoreNodeInfo_.try_emplace(vital, value);
|
||||
child = child->GetNext();
|
||||
}
|
||||
}
|
||||
|
@ -473,7 +473,12 @@ void ParseCurveInfo(const std::string& curveString, std::string& curveTypeString
|
||||
if (param == "false" || param == "end") {
|
||||
param = "0.000000";
|
||||
}
|
||||
curveValue.emplace_back(std::stof(param));
|
||||
char* end = nullptr;
|
||||
float value = strtof(param.c_str(), &end);
|
||||
if (end == param.c_str() || errno == ERANGE) {
|
||||
LOGW("%{public}s can not be converted to float or is out of range.", param.c_str());
|
||||
}
|
||||
curveValue.emplace_back(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,11 +14,14 @@
|
||||
*/
|
||||
#include "style_modifier.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "frame_information.h"
|
||||
#include "node_model.h"
|
||||
#include "node_transition.h"
|
||||
#include "waterflow_section_option.h"
|
||||
|
||||
#include "base/utils/utils.h"
|
||||
#include "bridge/common/utils/utils.h"
|
||||
|
||||
namespace OHOS::Ace::NodeModel {
|
||||
@ -309,7 +312,16 @@ uint32_t StringToColorInt(const char* string, uint32_t defaultValue = 0)
|
||||
if (std::regex_match(colorStr, matches, COLOR_WITH_MAGIC)) {
|
||||
colorStr.erase(0, 1);
|
||||
constexpr int colorNumFormat = 16;
|
||||
auto value = stoul(colorStr, nullptr, colorNumFormat);
|
||||
char* end = nullptr;
|
||||
unsigned long int value = strtoul(colorStr.c_str(), &end, colorNumFormat);
|
||||
if (errno == ERANGE) {
|
||||
LOGF("%{public}s is out of range.", colorStr.c_str());
|
||||
abort();
|
||||
}
|
||||
if (value == 0 && end == colorStr.c_str()) {
|
||||
LOGW("input %{public}s can not covert to number, use default color:0x00000000" , colorStr.c_str());
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
return defaultValue;
|
||||
|
Loading…
Reference in New Issue
Block a user