ArkUi内源审视修改

Signed-off-by: kangchongtao <kangchongtao@huawei.com>
Change-Id: I9762ef04fc4b5c3a4f924ad0a999401fe976f24d
Signed-off-by: kangchongtao <kangchongtao@huawei.com>
This commit is contained in:
kangchongtao 2022-03-17 19:35:15 +08:00
parent d6b226d4fe
commit 055a53e773
143 changed files with 438 additions and 895 deletions

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@ -24,7 +24,6 @@ config("ace_config") {
"//third_party/zlib",
]
# TODO: should not add here
if (is_standard_system && !use_mingw_win && !use_mac) {
include_dirs += [
"//base/global/resmgr_standard/frameworks/resmgr/include",
@ -75,7 +74,6 @@ config("ace_test_config") {
cflags_cc = []
defines = ace_common_defines
# TODO: should not add here
if (is_standard_system && !use_mingw_win && !use_mac) {
include_dirs += [
"//base/global/resmgr_standard/frameworks/resmgr/include",

View File

@ -308,7 +308,6 @@ void AceAbility::OnStart(const Want& want)
if (rsUiDirector != nullptr) {
rsUiDirector->SetRSSurfaceNode(window->GetSurfaceNode());
// todo regist on size change()
window->RegisterWindowChangeListener(thisAbility);
rsUiDirector->SetUITaskRunner(
@ -351,7 +350,6 @@ void AceAbility::OnStart(const Want& want)
AAFwk::Want want;
want.SetElementName(bundle, ability);
// want.SetParam(Constants::PARAM_FORM_IDENTITY_KEY, std::to_string(formJsInfo_.formId));
this->StartAbility(want);
};
@ -615,7 +613,8 @@ void AceAbility::OnSizeChange(OHOS::Rosen::Rect rect, OHOS::Rosen::WindowSizeCha
LOGE("OnSizeChange: taskExecutor is null.");
return;
}
taskExecutor->PostTask([rect, abilityId = abilityId_, density = density_, reason]() {
taskExecutor->PostTask(
[rect, abilityId = abilityId_, density = density_, reason]() {
uint32_t width = rect.width_;
uint32_t height = rect.height_;
LOGI("AceAbility::OnSizeChange width: %{public}u, height: %{public}u, left: %{public}d, top: %{public}d",
@ -628,12 +627,10 @@ void AceAbility::OnSizeChange(OHOS::Rosen::Rect rect, OHOS::Rosen::WindowSizeCha
return;
}
auto flutterAceView = static_cast<Platform::FlutterAceView*>(container->GetView());
if (!flutterAceView) {
LOGE("flutterAceView is null");
return;
}
flutter::ViewportMetrics metrics;
metrics.physical_width = width;
metrics.physical_height = height;
@ -641,7 +638,8 @@ void AceAbility::OnSizeChange(OHOS::Rosen::Rect rect, OHOS::Rosen::WindowSizeCha
Platform::FlutterAceView::SetViewportMetrics(flutterAceView, metrics);
Platform::FlutterAceView::SurfaceChanged(
flutterAceView, width, height, 0, static_cast<WindowSizeChangeReason>(reason));
}, TaskExecutor::TaskType::PLATFORM);
},
TaskExecutor::TaskType::PLATFORM);
}
void AceAbility::OnModeChange(OHOS::Rosen::WindowMode mode)

View File

@ -314,7 +314,6 @@ void AceContainer::OnActive(int32_t instanceId)
if (front && !container->IsSubContainer()) {
front->OnActive();
}
// TODO: remove it after ability fix onshow lifecyle.
auto context = container->GetPipelineContext();
if (!context) {
return;
@ -334,7 +333,6 @@ void AceContainer::OnInactive(int32_t instanceId)
if (front && !container->IsSubContainer()) {
front->OnInactive();
}
// TODO: remove it after ability fix onshow lifecyle.
auto context = container->GetPipelineContext();
if (!context) {
return;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -109,7 +109,6 @@ void AceFormAbility::LoadFormEnv(const OHOS::AAFwk::Want& want)
} else {
libPath += "/" + nativeLibraryPath;
}
LOGI("napi lib path = %{private}s", libPath.c_str());
Platform::PaContainer::AddLibPath(instanceId_, libPath);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -109,7 +109,6 @@ void AceServiceAbility::OnStart(const OHOS::AAFwk::Want& want)
} else {
libPath += "/" + nativeLibraryPath;
}
LOGI("napi lib path = %{private}s", libPath.c_str());
Platform::PaContainer::AddLibPath(abilityId_, libPath);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -48,7 +48,7 @@ class FileAssetMapping : public fml::Mapping {
public:
FileAssetMapping(std::unique_ptr<uint8_t[]> data, size_t size) : data_(std::move(data)), size_(size) {}
~FileAssetMapping() override {}
~FileAssetMapping() override = default;
size_t GetSize() const override
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -311,7 +311,6 @@ FlutterAceView* FlutterAceView::CreateView(int32_t instanceId, bool useCurrentEv
void FlutterAceView::SurfaceCreated(FlutterAceView* view, OHOS::sptr<OHOS::Rosen::Window> window)
{
LOGI(">>> FlutterAceView::SurfaceCreated, pWnd:%{public}p", &(*window));
if (window == nullptr) {
LOGE("FlutterAceView::SurfaceCreated, window is nullptr");
return;
@ -320,7 +319,7 @@ void FlutterAceView::SurfaceCreated(FlutterAceView* view, OHOS::sptr<OHOS::Rosen
LOGE("FlutterAceView::SurfaceCreated, view is nullptr");
return;
}
LOGI(">>> FlutterAceView::SurfaceCreated, pWnd:%{public}p", &(*window));
auto platformView = view->GetShellHolder()->GetPlatformView();
LOGI("FlutterAceView::SurfaceCreated, GetPlatformView");
if (platformView && !SystemProperties::GetRosenBackendEnabled()) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -319,9 +319,6 @@ inline std::string ToJSONStringInt(std::string sKey, std::string sValue)
}
} // namespace
// -----------------------
// Start JsiPaEngineInstance
// -----------------------
JsiPaEngineInstance::~JsiPaEngineInstance()
{
if (runtime_) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -44,8 +44,7 @@ namespace OHOS::Ace {
class QjsPaEngineInstance final : public AceType, public JsBackendEngineInstance {
public:
explicit QjsPaEngineInstance(const RefPtr<BackendDelegate>& delegate, int32_t instanceId)
: backendDelegate_(delegate), instanceId_(instanceId)
{}
: backendDelegate_(delegate), instanceId_(instanceId) {}
~QjsPaEngineInstance() override;
bool InitJsEnv(

View File

@ -93,7 +93,7 @@ private:
class JsInteractionOperation : public Accessibility::AccessibilityElementOperator {
public:
virtual ~JsInteractionOperation() = default;
// Accessibility overide.
// Accessibility override.
void SearchElementInfoByAccessibilityId(const long elementId, const int requestId,
Accessibility::AccessibilityElementOperatorCallback& callback, const int mode) override;
void SearchElementInfosByText(const long elementId, const std::string& text, const int requestId,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -157,13 +157,11 @@ void* PixelMapOhos::GetRawPixelMapPtr() const
std::string PixelMapOhos::GetId()
{
// TODO: media should generate Id of each [PixelMap] to distinguish different objects
return std::string();
}
std::string PixelMapOhos::GetModifyId()
{
// TODO: media should generate ModifyId of [PixelMap] to distinguish [PixelMap] object after different operations
return std::string();
}

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -39,13 +39,11 @@ public:
std::shared_ptr<UIServiceMgrClient> MockUIServiceMgrClient::GetInstance()
{
if (instance_ == nullptr) {
if (instance_ == nullptr) {
std::shared_ptr<UIServiceMgrClient> client = std::make_shared<MockUIServiceMgrClient>();
if (client != nullptr) {
((MockUIServiceMgrClient *)client.get())->Connect();
}
instance_ = client;
std::shared_ptr<UIServiceMgrClient> client = std::make_shared<MockUIServiceMgrClient>();
if (client != nullptr) {
((MockUIServiceMgrClient *)client.get())->Connect();
}
instance_ = client;
}
return instance_;
}

View File

@ -80,7 +80,7 @@ void SetPhysicalDeviceFonts(bool& physicalDeviceFontsEnabled)
void SetFontBasePath(std::string& basePath)
{
LOGI("Physical devices font base path is %s", basePath.c_str());
LOGI("Set basic path of physical device font");
basePath = basePath.append(DELIMITER);
SkFontMgr_Config_Parser::setFontBasePathCallback(basePath);
}

View File

@ -113,7 +113,6 @@ public:
if (unit_ == DimensionUnit::PX) {
return SystemProperties::Px2Vp(value_);
}
// TODO: add fp and lpx convert.
return 0;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -72,22 +72,22 @@ public:
double Left() const
{
return width_ > 0.0 ? x_ : x_ + width_;
return GreatNotEqual(width_, 0.0) ? x_ : x_ + width_;
}
double Top() const
{
return height_ > 0.0 ? y_ : y_ + height_;
return GreatNotEqual(height_, 0.0) ? y_ : y_ + height_;
}
double Right() const
{
return width_ > 0.0 ? x_ + width_ : x_;
return GreatNotEqual(width_, 0.0) ? x_ + width_ : x_;
}
double Bottom() const
{
return height_ > 0.0 ? y_ + height_ : y_;
return GreatNotEqual(height_, 0.0) ? y_ + height_ : y_;
}
double Width() const
@ -342,16 +342,12 @@ public:
offset.SetX(std::max(0.0, std::min(magnet.Left() - Left(), magnet.Right() - Right())));
} else if (Right() > magnet.Right()) {
offset.SetX(std::min(0.0, std::max(magnet.Left() - Left(), magnet.Right() - Right())));
} else {
// No need to offset.
}
if (Top() < magnet.Top()) {
offset.SetY(std::max(0.0, std::min(magnet.Top() - Top(), magnet.Bottom() - Bottom())));
} else if (Bottom() > magnet.Bottom()) {
offset.SetY(std::min(0.0, std::max(magnet.Top() - Top(), magnet.Bottom() - Bottom())));
} else {
// No need to offset.
}
*this += offset;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -413,7 +413,7 @@ bool Localization::GetHourFormat(bool& isAmPm, bool& hasZero)
return true;
}
LOGE("hour format is unknow[%{public}s]", result.c_str());
LOGE("hour format is unknown[%{public}s]", result.c_str());
return false;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -285,7 +285,7 @@ bool AceResKeyParser::ParseDefaults(const std::string& key, std::vector<KeyParam
std::string AceResKeyParser::GetMccByValue(uint32_t value) const
{
char mccStr[MAX_MCC_MNC_LEN] = {0};
if (sprintf_s(mccStr, MAX_MCC_MNC_LEN, "mcc%03d", value) < 0) {
if (sprintf_s(mccStr, MAX_MCC_MNC_LEN, "mcc%03u", value) < 0) {
LOGE("output mcc exception");
return "";
}
@ -295,7 +295,7 @@ std::string AceResKeyParser::GetMccByValue(uint32_t value) const
std::string AceResKeyParser::GetMncShortLenByValue(uint32_t value) const
{
char mncStr[MAX_MCC_MNC_LEN] = {0};
if (sprintf_s(mncStr, MAX_MCC_MNC_LEN, "mnc%02d", value) < 0) {
if (sprintf_s(mncStr, MAX_MCC_MNC_LEN, "mnc%02u", value) < 0) {
LOGE("output mnc short len exception");
return "";
}
@ -305,7 +305,7 @@ std::string AceResKeyParser::GetMncShortLenByValue(uint32_t value) const
std::string AceResKeyParser::GetMncByValue(uint32_t value) const
{
char mncStr[MAX_MCC_MNC_LEN] = {0};
if (sprintf_s(mncStr, MAX_MCC_MNC_LEN, "mnc%03d", value) < 0) {
if (sprintf_s(mncStr, MAX_MCC_MNC_LEN, "mnc%03u", value) < 0) {
LOGE("output mnc len exception");
return "";
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -64,8 +64,6 @@ void JsonUtilsTest::TearDown()
* @tc.name: JsonUtilsTest001
* @tc.desc: Check json util function for bool type value
* @tc.type: FUNC
* @tc.require: AR000DAQVN
* @tc.author: luoying
*/
HWTEST_F(JsonUtilsTest, JsonUtilsTest001, TestSize.Level1)
{
@ -90,8 +88,6 @@ HWTEST_F(JsonUtilsTest, JsonUtilsTest001, TestSize.Level1)
* @tc.name: JsonUtilsTest002
* @tc.desc: Check json util function for bool type value
* @tc.type: FUNC
* @tc.require: AR000DAQVN
* @tc.author: luoying
*/
HWTEST_F(JsonUtilsTest, JsonUtilsTest002, TestSize.Level1)
{
@ -116,8 +112,6 @@ HWTEST_F(JsonUtilsTest, JsonUtilsTest002, TestSize.Level1)
* @tc.name: JsonUtilsTest003
* @tc.desc: Check json util function for signed integer
* @tc.type: FUNC
* @tc.require: AR000DAQVN
* @tc.author: luoying
*/
HWTEST_F(JsonUtilsTest, JsonUtilsTest003, TestSize.Level1)
{
@ -147,8 +141,6 @@ HWTEST_F(JsonUtilsTest, JsonUtilsTest003, TestSize.Level1)
* @tc.name: JsonUtilsTest004
* @tc.desc: Check json util function for unsigned integer
* @tc.type: FUNC
* @tc.require: AR000DAQVN
* @tc.author: luoying
*/
HWTEST_F(JsonUtilsTest, JsonUtilsTest004, TestSize.Level1)
{
@ -178,8 +170,6 @@ HWTEST_F(JsonUtilsTest, JsonUtilsTest004, TestSize.Level1)
* @tc.name: JsonUtilsTest005
* @tc.desc: Check json util function for decimal number
* @tc.type: FUNC
* @tc.require: AR000DAQVN
* @tc.author: luoying
*/
HWTEST_F(JsonUtilsTest, JsonUtilsTest005, TestSize.Level1)
{
@ -209,8 +199,6 @@ HWTEST_F(JsonUtilsTest, JsonUtilsTest005, TestSize.Level1)
* @tc.name: JsonUtilsTest006
* @tc.desc: Check json util function for string
* @tc.type: FUNC
* @tc.require: AR000DAQVN
* @tc.author: luoying
*/
HWTEST_F(JsonUtilsTest, JsonUtilsTest006, TestSize.Level1)
{
@ -235,8 +223,6 @@ HWTEST_F(JsonUtilsTest, JsonUtilsTest006, TestSize.Level1)
* @tc.name: JsonUtilsTest007
* @tc.desc: Check json util function for empty string
* @tc.type: FUNC
* @tc.require: AR000DAQVN
* @tc.author: luoying
*/
HWTEST_F(JsonUtilsTest, JsonUtilsTest007, TestSize.Level1)
{
@ -261,8 +247,6 @@ HWTEST_F(JsonUtilsTest, JsonUtilsTest007, TestSize.Level1)
* @tc.name: JsonUtilsTest008
* @tc.desc: Check json util function for JsonObject
* @tc.type: FUNC
* @tc.require: AR000DAQVN
* @tc.author: luoying
*/
HWTEST_F(JsonUtilsTest, JsonUtilsTest008, TestSize.Level1)
{
@ -290,8 +274,6 @@ HWTEST_F(JsonUtilsTest, JsonUtilsTest008, TestSize.Level1)
* @tc.name: JsonUtilsTest009
* @tc.desc: Check json util function for incorrect JsonObject
* @tc.type: FUNC
* @tc.require: AR000DAQVN
* @tc.author: luoying
*/
HWTEST_F(JsonUtilsTest, JsonUtilsTest009, TestSize.Level1)
{
@ -317,8 +299,6 @@ HWTEST_F(JsonUtilsTest, JsonUtilsTest009, TestSize.Level1)
* @tc.name: JsonUtilsTest010
* @tc.desc: Check json util function for array
* @tc.type: FUNC
* @tc.require: AR000DAQVN
* @tc.author: luoying
*/
HWTEST_F(JsonUtilsTest, JsonUtilsTest010, TestSize.Level1)
{
@ -347,8 +327,6 @@ HWTEST_F(JsonUtilsTest, JsonUtilsTest010, TestSize.Level1)
* @tc.name: JsonUtilsTest011
* @tc.desc: Check json util function for empty array
* @tc.type: FUNC
* @tc.require: AR000DAQVN
* @tc.author: luoying
*/
HWTEST_F(JsonUtilsTest, JsonUtilsTest011, TestSize.Level1)
{
@ -373,8 +351,6 @@ HWTEST_F(JsonUtilsTest, JsonUtilsTest011, TestSize.Level1)
* @tc.name: JsonUtilsTest012
* @tc.desc: Check json util function for empty test string
* @tc.type: FUNC
* @tc.require: AR000DAQVN
* @tc.author: luoying
*/
HWTEST_F(JsonUtilsTest, JsonUtilsTest012, TestSize.Level1)
{
@ -397,8 +373,6 @@ HWTEST_F(JsonUtilsTest, JsonUtilsTest012, TestSize.Level1)
* @tc.name: JsonUtilsTest013
* @tc.desc: Check json util function for illegal type value
* @tc.type: FUNC
* @tc.require: AR000DAQVN
* @tc.author: luoying
*/
HWTEST_F(JsonUtilsTest, JsonUtilsTest013, TestSize.Level1)
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -107,8 +107,6 @@ void TaskExecutorsTest::GetString(const std::string& task, std::promise<std::str
* @tc.name: TaskExecutorsTest001
* @tc.desc: test synchronous and asynchronous execution of the UI thread
* @tc.type: FUNC
* @tc.require: AR000DACK5 AR000DACK7
* @tc.author: jiangyingjie
*/
HWTEST_F(TaskExecutorsTest, TaskExecutorsTest001, TestSize.Level0)
{
@ -141,8 +139,6 @@ HWTEST_F(TaskExecutorsTest, TaskExecutorsTest001, TestSize.Level0)
* @tc.name: TaskExecutorsTest002
* @tc.desc: test synchronous and asynchronous execution of the PLATFORM thread
* @tc.type: FUNC
* @tc.require: AR000DACK5 AR000DACK7
* @tc.author: jiangyingjie
*/
HWTEST_F(TaskExecutorsTest, TaskExecutorsTest002, TestSize.Level0)
{
@ -176,8 +172,6 @@ HWTEST_F(TaskExecutorsTest, TaskExecutorsTest002, TestSize.Level0)
* @tc.name: TaskExecutorsTest003
* @tc.desc: test synchronous and asynchronous execution of the IO thread
* @tc.type: FUNC
* @tc.require: AR000DACK5 AR000DACK7
* @tc.author: jiangyingjie
*/
HWTEST_F(TaskExecutorsTest, TaskExecutorsTest003, TestSize.Level0)
{
@ -210,8 +204,6 @@ HWTEST_F(TaskExecutorsTest, TaskExecutorsTest003, TestSize.Level0)
* @tc.name: TaskExecutorsTest004
* @tc.desc: test synchronous and asynchronous execution of the JS thread
* @tc.type: FUNC
* @tc.require: AR000DACK5 AR000DACK7
* @tc.author: jiangyingjie
*/
HWTEST_F(TaskExecutorsTest, TaskExecutorsTest004, TestSize.Level0)
{
@ -244,8 +236,6 @@ HWTEST_F(TaskExecutorsTest, TaskExecutorsTest004, TestSize.Level0)
* @tc.name: TaskExecutorsTest005
* @tc.desc: test synchronous and asynchronous execution of the BACKGROUND thread
* @tc.type: FUNC
* @tc.require: AR000DACK5 AR000DACK7 AR000DE7QP
* @tc.author: jiangyingjie
*/
HWTEST_F(TaskExecutorsTest, TaskExecutorsTest005, TestSize.Level0)
{

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@ -23,7 +23,6 @@ template("framework_bridge") {
configs = [ "$ace_root:ace_config" ]
deps = [
# FixMe: link declarative source first to avoid windows preview error
"declarative_frontend:declarative_frontend_$platform",
# bridge source

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -1562,7 +1562,6 @@ bool JsCardParser::ParseSpecialVariable(std::string& value)
bool JsCardParser::GetVariable(std::string& value, const std::unique_ptr<JsonValue>& dataJson)
{
LOGD("GetVariable value :%{private}s dataJson:%{private}s", value.c_str(), dataJson->ToString().c_str());
auto key = value;
if (!repeatJson_->Contains(key) && isRepeat_) {
return false;
@ -1571,6 +1570,7 @@ bool JsCardParser::GetVariable(std::string& value, const std::unique_ptr<JsonVal
if (!dataJson) {
return false;
}
LOGD("GetVariable value :%{private}s dataJson:%{private}s", value.c_str(), dataJson->ToString().c_str());
auto dataValue = dataJson->GetValue(key);
if (isRepeat_) {
dataValue = repeatJson_->GetValue(key);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -119,7 +119,7 @@ bool StandardCodecBufferReader::ReadData(CodecData& resultData)
case BufferDataType::TYPE_OBJECT:
return ReadDataFromByteBuffer<std::string>(byteBufferReader_, resultData);
default:
LOGW("Unknown type, type = %{public}u", static_cast<uint8_t>(type));
LOGW("Unknown type");
return false;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -475,7 +475,6 @@ void DOMButton::PrepareBackDecorationStyle()
}
auto border = backDecoration_->GetBorder();
if (!HasBorderRadiusStyle() || buttonDeclaration_->GetRadiusState()) {
// TODO: only check dimension unit now, should refactor calculate dimension in render.
if (buttonDeclaration_->GetRectRadius().Unit() == border.Top().GetWidth().Unit()) {
backDecoration_->SetBorderRadius(Radius(buttonDeclaration_->GetRectRadius() + border.Top().GetWidth()));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -43,7 +43,7 @@ Gradient ParseGradient(const DOMProgress& progress, const std::string& value)
return gradient;
}
auto gradientValue = gradientJson->GetValue(DOM_VALUES);
if (gradientValue == nullptr || !gradientValue->IsArray() || gradientValue->GetArraySize() <= 0) {
if ((gradientValue == nullptr) || (!gradientValue->IsArray()) || (gradientValue->GetArraySize() <= 0)) {
LOGW("gradientValue json param error");
return gradient;
}

View File

@ -50,6 +50,10 @@ void DOMSelect::ResetInitializedStyle()
void DOMSelect::InitializeStyle()
{
if (!selectComponent_) {
LOGE("selectComponent is null");
return;
}
selectComponent_->InitTheme(GetThemeManager());
theme_ = GetTheme<SelectTheme>();
if (theme_ && selectComponent_) {

View File

@ -164,6 +164,16 @@ void DOMSwitch::PrepareSpecializedComponent()
backDecoration->SetBorderRadius(Radius(BOX_HOVER_RADIUS));
boxComponent_->SetBackDecoration(backDecoration);
}
RefPtr<SwitchTheme> theme = GetTheme<SwitchTheme>();
if (switchChild_->GetShowText()) {
return;
}
if (boxComponent_->GetHeightDimension().Value() < 0.0 && theme) {
boxComponent_->SetHeight(theme->GetHeight().Value(), theme->GetHeight().Unit());
}
if (boxComponent_->GetWidthDimension().Value() < 0.0 && theme) {
boxComponent_->SetWidth(theme->GetWidth().Value(), theme->GetWidth().Unit());
}
}
if (HasCheckedPseudo()) {
PrepareCheckedListener();
@ -185,16 +195,6 @@ void DOMSwitch::PrepareSpecializedComponent()
}
}
#endif
RefPtr<SwitchTheme> theme = GetTheme<SwitchTheme>();
if (switchChild_->GetShowText()) {
return;
}
if (boxComponent_->GetHeightDimension().Value() < 0.0 && theme) {
boxComponent_->SetHeight(theme->GetHeight().Value(), theme->GetHeight().Unit());
}
if (boxComponent_->GetWidthDimension().Value() < 0.0 && theme) {
boxComponent_->SetWidth(theme->GetWidth().Value(), theme->GetWidth().Unit());
}
}
} // namespace OHOS::Ace::Framework

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -74,6 +74,9 @@ RefPtr<ButtonComponent> DOMButtonUtil::CreateComponentAndSetChildAttr(
backDecoration->SetBorderRadius(Radius(BOX_HOVER_RADIUS));
boxComponent->SetBackDecoration(backDecoration);
}
} else {
LOGE("boxComponent is null");
return component;
}
if (LessOrEqual(node.GetHeight().Value(), 0.0)) {
node.SetHeight(theme->GetHeight());
@ -214,19 +217,18 @@ void DOMButtonUtil::SetChildStyle(const RefPtr<BoxComponent>& boxComponent, cons
paddingStyleOperators[paddingOperator].value(value, node, padding);
}
}
auto theme = node.GetTheme<ButtonTheme>();
if (theme) {
component->SetDisabledColor(component->GetBackgroundColor().BlendOpacity(theme->GetBgDisabledAlpha()));
component->SetClickedColor(component->GetBackgroundColor().BlendColor(theme->GetClickedColor()));
if (parentStyle.GetFontSize() != theme->GetTextStyle().GetFontSize()) {
parentStyle.SetAdaptTextSize(parentStyle.GetFontSize(), parentStyle.GetFontSize());
}
}
// set text style to Text child
if (SystemProperties::GetDeviceType() != DeviceType::TV) {
textChild->SetFocusColor(parentStyle.GetTextColor());
}
if (parentStyle.GetFontSize() != theme->GetTextStyle().GetFontSize()) {
parentStyle.SetAdaptTextSize(parentStyle.GetFontSize(), parentStyle.GetFontSize());
}
textChild->SetTextStyle(parentStyle);
auto backDecoration = boxComponent->GetBackDecoration();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -125,10 +125,10 @@ void RevSourceMap::Init(const std::string& sourceMap)
// transform to vector for mapping easily
mappings_ = HandleMappings(mappings_[0]);
// the first bit: the column after transfering.
// the first bit: the column after transferring.
// the second bit: the source file.
// the third bit: the row before transfering.
// the fourth bit: the column before transfering.
// the third bit: the row before transferring.
// the fourth bit: the column before transferring.
// the fifth bit: the variable name.
for (const auto& mapping : mappings_) {
if (mapping == ";") {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -574,6 +574,7 @@ void DeclarativeFrontend::ReplaceJSContent(const std::string& url, const std::st
auto jsEngineInstance = AceType::DynamicCast<Framework::QJSDeclarativeEngine>(jsEngine_);
if (!jsEngineInstance) {
LOGE("jsEngineInstance is null");
return;
}
jsEngineInstance->ReplaceJSContent(url, componentName);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -167,54 +167,6 @@ private:
* methods.
*
* \code{.cpp}
* class TwoDPoint {
* public:
* TwoDPoint(float x, float y) : x_(x), y_(y) {}
* ~TwoDPoint() {}
*
* void SetX(float x) { x_ = x; }
* void SetY(float y) { y_ = y; }
* virtual void Print() { std::cout << "Point(" << x_ << ", " << y_ << ")" << std::endl; }
*
* static void Parse(const JSCallbackInfo& info) {
* JSRef<JSVal> arg = info[0];
* if (arg->IsString()) {
* std::string strArg = arg->ToString();
* TwoDPoint* instance = ParseFromString();
* if (instance) {
* info.SetReturnValue(instance);
* } else {
* JSException::Throw("Error parsing Point2(%s)", strArg.c_str());
* }
* } else {
* JSException::Throw("Point2.Parse: Argument is not a string!");
* }
* }
*
* float GetX() { return x_; }
* float GetY() { return y_; }
* private:
* static TwoDPoint* ParseFromString(const std::string& str) {
* // some parsing code:
* auto [x,y] = Parse(str);
* return new TwoDPoint(x,y);
* }
* float x_;
* float y_;
* };
*
* class ThreeDPoint : public TwoDPoint {
* public:
* ThreeDPoint(float x, float y, float z) : TwoDPoint(x,y) : z_(z) {}
* ~ThreeDPoint() {}
*
* void SetZ(float z) { z_ = z; }
* virtual void Print() override { std::cout << "Point(" << x_ << ", " << y_ << ", " << z_ << ")" << std::endl; }
*
* float GetZ() { return z_; }
* private:
* float z_;
* };
*
* // We are using V8 engine for this example:
* template<typename C>

View File

@ -122,7 +122,7 @@ std::string GetLogContent(
shared_ptr<JsValue> AppLogPrint(
const shared_ptr<JsRuntime>& runtime, JsLogLevel level, const std::vector<shared_ptr<JsValue>>& argv, int32_t argc)
{
// Should have at least 1 parameters.
// Should have at least 1 parameter.
if (argc == 0) {
LOGE("the arg is error");
return runtime->NewUndefined();
@ -778,7 +778,6 @@ RefPtr<JsAcePage> JsiDeclarativeEngineInstance::GetRunningPage(int32_t instanceI
return nullptr;
}
auto engineInstance = jsiEngine->GetEngineInstance();
LOGD("GetRunningPage id:%{public}d instance:%{public}p", instanceId, RawPtr(engineInstance));
if (engineInstance == nullptr) {
LOGE("engineInstance is nullptr");
return nullptr;

View File

@ -239,7 +239,6 @@ void QJSDeclarativeEngine::LoadJs(const std::string& url, const RefPtr<JsAcePage
LOGE("js compilation failed url=[%{public}s]", url.c_str());
return;
}
// Todo: check the fail.
engineInstance_->ExecuteDocumentJS(compiled);
js_std_loop(engineInstance_->GetQJSContext());
}

View File

@ -1,33 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -40,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class SubscriberManager {
constructor() {
this.subscriberById_ = new Map();
@ -1805,7 +1778,6 @@ class View extends NativeView {
}
aboutToContinueRender() {
// do not reset
//this.propsUsedForRender = new Set<string>();
this.isRenderingInProgress = true;
}
onRenderDone() {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -115,7 +115,6 @@ void V8Object::SetPropertyObject(const char* prop, V8Ref<V8Value> value) const
}
V8Object::V8Object() : V8Type() {}
// TODO(cvetan): Make private
V8Object::V8Object(v8::Local<v8::Object> obj) : V8Type(obj) {}
V8Funktion::V8Funktion() {}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -144,11 +144,9 @@ public:
void SetPropertyJsonObject(const char* prop, const char* value) const;
void SetPropertyObject(const char* prop, V8Ref<V8Value> value) const;
// TODO(cvetan): Make private
V8Object(v8::Local<v8::Object> obj);
};
// TODO(cvetan): Rename to V8Function when we get rid of the current V8Function
/**
* @brief A wrapper around v8::Function
*
@ -156,7 +154,6 @@ public:
class V8Funktion : public V8Type<v8::Function> {
public:
V8Funktion();
// TODO(cvetan): Make private
V8Funktion(v8::Local<v8::Function> obj);
~V8Funktion() override = default;

View File

@ -191,7 +191,6 @@ void JsLoadDocument(const v8::FunctionCallbackInfo<v8::Value>& args)
void JsDumpMemoryStats(const v8::FunctionCallbackInfo<v8::Value>& args)
{
// TODO: Implement for v8
LOGD("dumpMemoryStats: Not Implemented for V8. UnSupported");
}
@ -727,7 +726,6 @@ void JsRegisterModules(BindingTarget globalObj, std::string modules)
void JsRegisterViews(BindingTarget globalObj)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
// FIXME These do not belong to views, move somewhere else
globalObj->Set(v8::String::NewFromUtf8(isolate, "loadDocument").ToLocalChecked(),
v8::FunctionTemplate::New(isolate, JsLoadDocument));
globalObj->Set(v8::String::NewFromUtf8(isolate, "dumpMemoryStats").ToLocalChecked(),

View File

@ -346,6 +346,10 @@ void JSButton::JsOnClick(const JSCallbackInfo& info)
func->Execute(info);
};
RefPtr<Gesture> tapGesture = AceType::MakeRefPtr<TapGesture>(DEFAULT_TAP_COUNTS, DEFAULT_TAP_FINGERS);
if (!tapGesture) {
LOGE("tapGesture is null");
return;
}
tapGesture->SetOnActionId(clickId);
auto box = ViewStackProcessor::GetInstance()->GetBoxComponent();
if (tapGesture) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -54,6 +54,6 @@ private:
static RefPtr<CalendarComponentV2> GetComponent();
};
} // namespace HarmonyOS::Ace
} // OHOS::Ace::Framework
#endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_CALENDAR_H

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -19,7 +19,6 @@
#include "base/memory/referenced.h"
#include "bridge/declarative_frontend/engine/bindings_defines.h"
namespace OHOS::Ace::Framework {
class JSCanvasImageData : public Referenced {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -72,13 +72,13 @@ void JSDataPanel::Create(const JSCallbackInfo& info)
return;
}
auto value = item->GetDouble();
if (value <= 0.0) {
if (LessOrEqual(value, 0.0)) {
value = 0.0;
}
valueSum += value;
if (valueSum >= max && max > 0) {
if (GreatOrEqual(valueSum, max) && max > 0) {
value = max - (valueSum - value);
if (value == 0.0) {
if (NearEqual(value, 0.0)) {
break;
}
Segment segment;
@ -92,7 +92,7 @@ void JSDataPanel::Create(const JSCallbackInfo& info)
segment.SetColorType(SegmentStyleType::NONE);
component->AppendSegment(segment);
}
if (max <= 0.0) {
if (LessOrEqual(max, 0.0)) {
max = valueSum;
}
component->SetMaxValue(max);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -58,7 +58,6 @@ void JSFlex::SetJustifyContent(int32_t value)
}
}
} else {
// FIXME: we have a design issue here, setters return void, can not signal error to JS
LOGE("invalid value for justifyContent");
}
}
@ -79,7 +78,6 @@ void JSFlex::SetAlignItems(int32_t value)
}
}
} else {
// FIXME: we have a design issue here, setters return void, can not signal error to JS
LOGE("invalid value for justifyContent");
}
}
@ -97,7 +95,6 @@ void JSFlex::SetAlignContent(int32_t value)
wrap->SetAlignment((WrapAlignment)value);
}
} else {
// FIXME: we have a design issue here, setters return void, can not signal error to JS
LOGE("invalid value for justifyContent");
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -155,6 +155,9 @@ void JSOffscreenRenderingContext::Destructor(JSOffscreenRenderingContext* contex
{
if (context != nullptr) {
context->DecRefCount();
} else {
LOGE("comtext is null");
return;
}
std::lock_guard<std::mutex> lock(mutex_);
offscreenCanvasMap_.erase(context->GetId());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -41,6 +41,10 @@ void JSQRCode::SetQRCodeColor(const JSCallbackInfo& info)
}
auto component = ViewStackProcessor::GetInstance()->GetMainComponent();
auto qrcode = AceType::DynamicCast<OHOS::Ace::QrcodeComponent>(component);
if (!qrcode) {
LOGE("qrcode is null");
return;
}
qrcode->SetQrcodeColor(qrcodeColor);
}
@ -56,6 +60,10 @@ void JSQRCode::SetBackgroundColor(const JSCallbackInfo& info)
}
auto component = ViewStackProcessor::GetInstance()->GetMainComponent();
auto qrcode = AceType::DynamicCast<OHOS::Ace::QrcodeComponent>(component);
if (!qrcode) {
LOGE("qrcode is null");
return;
}
qrcode->SetBackgroundColor(backgroundColor);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -230,7 +230,6 @@ void JSRadio::OnChange(const JSCallbackInfo& args)
void JSRadio::JsOnClick(const JSCallbackInfo& args)
{
// TODO: Add click info.
if (JSViewBindEvent(&CheckableComponent::SetOnClick, args)) {
} else {
LOGW("Failed to bind event");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -67,7 +67,7 @@ void JSRefresh::Create(const JSCallbackInfo& info)
auto jsOffset = paramObject->GetProperty("offset");
Dimension offset;
if (ParseJsDimensionVp(jsOffset, offset)) {
if (offset.Value() <= 0.0) {
if (LessOrEqual(offset.Value(), 0.0)) {
refreshComponent->SetRefreshDistance(theme->GetRefreshDistance());
} else {
refreshComponent->SetRefreshDistance(offset);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -58,7 +58,7 @@ void JSScroll::Create(const JSCallbackInfo& info)
void JSScroll::SetScrollable(int32_t value)
{
if (value >= 0 && value < 4) {
if (value >= 0 && value < 4) { // Number of scrolling methods
auto component = ViewStackProcessor::GetInstance()->GetMainComponent();
auto scrollComponent = AceType::DynamicCast<ScrollComponent>(component);
if (scrollComponent) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -51,6 +51,10 @@ void JSSlidingPanel::Create(const JSCallbackInfo& info)
auto isShow = info[0]->ToBoolean();
auto component = ViewStackProcessor::GetInstance()->GetDisplayComponent();
auto display = AceType::DynamicCast<DisplayComponent>(component);
if (!display) {
LOGE("display is null");
return;
}
display->SetVisible(isShow ? VisibleType::VISIBLE : VisibleType::GONE);
}
}
@ -67,8 +71,6 @@ void JSSlidingPanel::JSBind(BindingTarget globalObj)
JSClass<JSSlidingPanel>::StaticMethod("fullHeight", &JSSlidingPanel::SetFullHeight, opt);
JSClass<JSSlidingPanel>::StaticMethod("halfHeight", &JSSlidingPanel::SetHalfHeight, opt);
JSClass<JSSlidingPanel>::StaticMethod("miniHeight", &JSSlidingPanel::SetMiniHeight, opt);
// box style TODO: missing borderstyle in box.
JSClass<JSSlidingPanel>::StaticMethod("backgroundColor", JsBackgroundColor);
JSClass<JSSlidingPanel>::StaticMethod("border", JsPanelBorder);
JSClass<JSSlidingPanel>::StaticMethod("borderWidth", JsPanelBorderWidth);
@ -309,6 +311,10 @@ void JSSlidingPanel::SetShow(bool isShow)
{
auto component = ViewStackProcessor::GetInstance()->GetDisplayComponent();
auto display = AceType::DynamicCast<DisplayComponent>(component);
if (!display) {
LOGE("display is null");
return;
}
display->SetVisible(isShow ? VisibleType::VISIBLE : VisibleType::GONE);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -59,6 +59,10 @@ void JSSwiper::JsRemoteMessage(const JSCallbackInfo& info)
JSInteractableView::JsRemoteMessage(info, remoteMessageEventId);
auto stack = ViewStackProcessor::GetInstance();
auto swiperComponent = AceType::DynamicCast<SwiperComponent>(stack->GetMainComponent());
if (!swiperComponent) {
LOGE("swiperComponent is null");
return;
}
swiperComponent->SetRemoteMessageEventId(remoteMessageEventId);
}
@ -256,7 +260,6 @@ void JSSwiper::SetCancelSwipeOnOtherAxis(bool cancel)
{
auto component = ViewStackProcessor::GetInstance()->GetMainComponent();
auto swiper = AceType::DynamicCast<OHOS::Ace::SwiperComponent>(component);
// TODO: swiper->SetCancelSwipeOnOtherAxis(cancel) is no longer supported. check whether need this method
}
void JSSwiper::SetIndicatorStyle(const JSCallbackInfo& info)

View File

@ -1248,6 +1248,10 @@ void JSViewAbstract::JsAspectRatio(const JSCallbackInfo& info)
return;
}
auto boxComponent = ViewStackProcessor::GetInstance()->GetBoxComponent();
if (!boxComponent) {
LOGE("boxComponent is null");
return;
}
AnimationOption option = ViewStackProcessor::GetInstance()->GetImplicitAnimationOption();
boxComponent->SetAspectRatio(value, option);
}
@ -1480,6 +1484,10 @@ void JSViewAbstract::JsGeometryTransition(const JSCallbackInfo& info)
return;
}
auto boxComponent = ViewStackProcessor::GetInstance()->GetBoxComponent();
if (!boxComponent) {
LOGE("boxComponent is null");
return;
}
boxComponent->SetGeometryTransitionId(id);
}
@ -1514,6 +1522,10 @@ void JSViewAbstract::JsBorderColor(const JSCallbackInfo& info)
BoxComponentHelper::SetBorderColor(GetBackDecoration(), borderColor, option);
} else {
auto boxComponent = AceType::DynamicCast<BoxComponent>(stack->GetBoxComponent());
if (!boxComponent) {
LOGE("boxComponent is null");
return;
}
boxComponent->GetStateAttributes()->AddAttribute<AnimatableColor>(BoxStateAttribute::BORDER_COLOR,
AnimatableColor(borderColor, option), stack->GetVisualState());
if (!boxComponent->GetStateAttributes()->
@ -1538,6 +1550,10 @@ void JSViewAbstract::JsBackgroundColor(const JSCallbackInfo& info)
auto stack = ViewStackProcessor::GetInstance();
auto boxComponent = stack->GetBoxComponent();
if (!boxComponent) {
LOGE("boxComponent is null");
return;
}
auto option = stack->GetImplicitAnimationOption();
if (!stack->IsVisualStateSet()) {
boxComponent->SetColor(backgroundColor, option);
@ -1885,7 +1901,10 @@ void JSViewAbstract::JsBorder(const JSCallbackInfo& info)
auto stack = ViewStackProcessor::GetInstance();
AnimationOption option = stack->GetImplicitAnimationOption();
auto boxComponent = AceType::DynamicCast<BoxComponent>(stack->GetBoxComponent());
if (!boxComponent) {
LOGE("boxComponent is null");
return;
}
Dimension width;
if (argsPtrItem->Contains("width") && ParseJsonDimensionVp(argsPtrItem->GetValue("width"), width)) {
if (!stack->IsVisualStateSet()) {
@ -1954,6 +1973,10 @@ void JSViewAbstract::JsBorderWidth(const JSCallbackInfo& info)
BoxComponentHelper::SetBorderWidth(GetBackDecoration(), borderWidth, option);
} else {
auto boxComponent = AceType::DynamicCast<BoxComponent>(stack->GetBoxComponent());
if (!boxComponent) {
LOGE("boxComponent is null");
return;
}
boxComponent->GetStateAttributes()->AddAttribute<AnimatableDimension>
(BoxStateAttribute::BORDER_WIDTH, AnimatableDimension(borderWidth, option), stack->GetVisualState());
if (!boxComponent->GetStateAttributes()->
@ -1982,6 +2005,10 @@ void JSViewAbstract::JsBorderRadius(const JSCallbackInfo& info)
SetBorderRadius(borderRadius, option);
} else {
auto boxComponent = AceType::DynamicCast<BoxComponent>(stack->GetBoxComponent());
if (!boxComponent) {
LOGE("boxComponent is null");
return;
}
boxComponent->GetStateAttributes()->AddAttribute<AnimatableDimension>(BoxStateAttribute::BORDER_RADIUS,
AnimatableDimension(borderRadius, option), stack->GetVisualState());
if (!boxComponent->GetStateAttributes()->
@ -2835,6 +2862,10 @@ void JSViewAbstract::JsOnAreaChange(const JSCallbackInfo& info)
func->Execute(oldRect, oldOrigin, rect, origin);
};
auto boxComponent = ViewStackProcessor::GetInstance()->GetBoxComponent();
if (!boxComponent) {
LOGE("boxComponent is null");
return;
}
boxComponent->GetEventExtensions()->GetOnAreaChangeExtension()->AddOnAreaChangeEvent(
std::move(onAreaChangeCallback));
}
@ -2969,6 +3000,10 @@ void JSViewAbstract::JsLinearGradient(const JSCallbackInfo& info)
}
} else {
auto boxComponent = stack->GetBoxComponent();
if (!boxComponent) {
LOGE("boxComponent is null");
return;
}
boxComponent->GetStateAttributes()->AddAttribute<Gradient>
(BoxStateAttribute::GRADIENT, lineGradient, stack->GetVisualState());
if (!boxComponent->GetStateAttributes()->
@ -3037,6 +3072,10 @@ void JSViewAbstract::JsRadialGradient(const JSCallbackInfo& info)
}
} else {
auto boxComponent = stack->GetBoxComponent();
if (!boxComponent) {
LOGE("boxComponent is null");
return;
}
boxComponent->GetStateAttributes()->AddAttribute<Gradient>
(BoxStateAttribute::GRADIENT, radialGradient, stack->GetVisualState());
if (!boxComponent->GetStateAttributes()->
@ -3118,6 +3157,10 @@ void JSViewAbstract::JsSweepGradient(const JSCallbackInfo& info)
}
} else {
auto boxComponent = stack->GetBoxComponent();
if (!boxComponent) {
LOGE("boxComponent is null");
return;
}
boxComponent->GetStateAttributes()->AddAttribute<Gradient>
(BoxStateAttribute::GRADIENT, sweepGradient, stack->GetVisualState());
if (!boxComponent->GetStateAttributes()->
@ -3771,6 +3814,10 @@ void JSViewAbstract::SetBorderStyle(int32_t style)
BoxComponentHelper::SetBorderStyle(GetBackDecoration(), borderStyle);
} else {
auto boxComponent = AceType::DynamicCast<BoxComponent>(stack->GetBoxComponent());
if (!boxComponent) {
LOGE("boxComponent is null");
return;
}
boxComponent->GetStateAttributes()->AddAttribute<BorderStyle>
(BoxStateAttribute::BORDER_STYLE, borderStyle, stack->GetVisualState());
if (!boxComponent->GetStateAttributes()->
@ -4176,6 +4223,10 @@ void JSViewAbstract::JsHoverEffect(const JSCallbackInfo& info)
return;
}
auto boxComponent = ViewStackProcessor::GetInstance()->GetBoxComponent();
if (!boxComponent) {
LOGE("boxComponent is null");
return;
}
boxComponent->SetMouseAnimationType(static_cast<HoverAnimationType>(info[0]->ToNumber<int32_t>()));
}

View File

@ -546,7 +546,7 @@ JSRef<JSVal> LoadWebOnFocusEventToJSValue(const LoadWebOnFocusEvent& eventInfo)
void JSWeb::Create(const JSCallbackInfo& info)
{
if (info.Length() < 1 || !info[0]->IsObject()) {
LOGI("web create error, info is non-valid");
LOGI("web create error, info is invalid");
return;
}
auto paramObject = JSRef<JSObject>::Cast(info[0]);
@ -572,7 +572,7 @@ void JSWeb::Create(const JSCallbackInfo& info)
auto controllerObj = paramObject->GetProperty("controller");
if (!controllerObj->IsObject()) {
LOGI("web create error, controller is non-valid");
LOGI("web create error, controller is invalid");
return;
}
auto controller = JSRef<JSObject>::Cast(controllerObj)->Unwrap<JSWebController>();

View File

@ -37,7 +37,7 @@ void JSXComponent::JSBind(BindingTarget globalObj)
void JSXComponent::Create(const JSCallbackInfo& info)
{
if (info.Length() < 1 || !info[0]->IsObject()) {
LOGI("xcomponent create error, info is non-valid");
LOGI("xcomponent create error, info is invalid");
return;
}
auto paramObject = JSRef<JSObject>::Cast(info[0]);
@ -48,7 +48,7 @@ void JSXComponent::Create(const JSCallbackInfo& info)
auto xcomponentComponent = AceType::MakeRefPtr<OHOS::Ace::XComponentComponent>("xcomponent");
if (!id->IsString()) {
LOGI("xcomponent create error, id is non-valid");
LOGI("xcomponent create error, id is invalid");
return;
}
xcomponentComponent->SetId(id->ToString());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -132,7 +132,7 @@ class AppStorage extends LocalStorage {
* Before deleting a prop from app storage all its subscribers need to
* unsubscribe from the property.
* This method fails and returns false if given property still has subscribers
* Another reason for failing is unkmown property.
* Another reason for failing is unknown property.
*
* @param propName
* @returns false if method failed
@ -207,7 +207,6 @@ class AppStorage extends LocalStorage {
}
public static IsMutable(key: string): boolean {
// FIXME(cvetan): No mechanism for immutable/mutable properties
return true;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -124,7 +124,7 @@ class SubscribableHandler {
}
console.log(`SubscribableHandler: set property '${property.toString()}' to new value'`);
target[property] = newValue;
this.notifyPropertyHasChanged(property.toString(), newValue); // FIXME PropertyKey.toString
this.notifyPropertyHasChanged(property.toString(), newValue);
return true;
break;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -36,7 +36,6 @@ class ObservedPropertyObject<T extends Object> extends ObservedPropertyObjectAbs
super.aboutToBeDeleted();
}
// FIXME
// notification from ObservedObject value one of its
// props has chnaged. Implies the ObservedProperty has changed
// Note: this function gets called when in this case:

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -25,7 +25,7 @@
* decorated variables to share the same instance to a SubscribaleAbstract
* object. Each such decorated variable implementation makes its own
* subscription to the SubscribaleAbstract object. Hence, when both variables
* have unsubscribed the SubscribaleAbstract may do its own de-initilization.,
* have unsubscribed the SubscribaleAbstract may do its own de-initilialization.,
* e.g. release held external resources.
*
* How to extend:

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -141,7 +141,6 @@ abstract class View extends NativeView implements
public aboutToContinueRender(): void {
// do not reset
//this.propsUsedForRender = new Set<string>();
this.isRenderingInProgress = true;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -63,7 +63,7 @@ const nestedObsObjProps = tsuite("Nested Observed Object and Properties", () =>
tcase("Two views having a property referring to a1: ClassA", () => {
// View of property class B, has a propery v1b1
// View of property class B, has a property v1b1
let v1p1b1 = new SubscribingView("v1p1b1");
let p1b1: ObservedPropertyObjectAbstract<ClassB> = new ObservedPropertyObject<ClassB>(new ClassB(new ClassA(47)), v1p1b1, "p1-b1");
let v1p1b1Spy = spyOn(v1p1b1, "propertyHasChanged");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -147,7 +147,7 @@ const testViewState = tsuite("View State", () => {
this.__prop_.set(newValue);
}
// eDSL compiler makes no chnage
// eDSL compiler makes no change
/* private changed to for testing: */ public reg_: string = "initial value"
constructor(compilerAssignedUniqueChildId: string, parent: View,
@ -285,7 +285,7 @@ const testViewState = tsuite("View State", () => {
test(`childView.reg_ unchanged`, childView.reg_ == "forReg Orig");
});
tcase("Simulate an event handler mutating parent's regular (unobserved) varible", () => {
tcase("Simulate an event handler mutating parent's regular (unobserved) variable", () => {
let spyParentPropertyHasChanged = spyOn(parentView, "propertyHasChanged");

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@ -72,7 +72,6 @@ template("js_engine_qjs") {
if (platform == "windows" || platform == "mac") {
defines += [ "ENABLE_JS_DEBUG_PREVIEW" ]
# TODO: should remove this
configs += [ "$ace_flutter_engine_root:flutter_config" ]
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -21,7 +21,6 @@ namespace OHOS::Ace::Framework {
void BadgeBridge::ParseBadgeConfig(JSContext* ctx, JSValue valObject)
{
// TODO: these codes are duplicate, need to refactor.
JSPropertyEnum* pTab = nullptr;
uint32_t len = 0;
if (!CheckAndGetJsProperty(ctx, valObject, &pTab, &len)) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -16,7 +16,6 @@
#include "frameworks/bridge/js_frontend/engine/quickjs/qjs_group_js_bridge.h"
#if defined(WINDOWS_PLATFORM) || defined(MAC_PLATFORM)
// TODO: DO NOT include adapter includes
#include "adapter/preview/entrance/ace_container.h"
#include "core/common/ace_engine.h"
#include "frameworks/bridge/declarative_frontend/engine/quickjs/qjs_declarative_engine_instance.h"
@ -150,7 +149,7 @@ void QuickJsGroupJsBridge::QuickJsPrintException(JSContext* context, int32_t exp
if (JS_IsString(jsMsg)) {
size_t msgLen = 0;
const char* msg = JS_ToCStringLen(context, &msgLen, jsMsg);
if (msg == NULL) {
if (msg == nullptr) {
JS_FreeValue(context, JS_GetException(context));
} else {
expMsg.assign(msg, msgLen);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -521,7 +521,7 @@ void V8GroupJsBridge::TriggerModuleJsCallback(int32_t callbackId, int32_t code,
callbackId);
code = PLUGIN_REQUEST_FAIL;
std::string errorString = std::string("{\"code\":").append(std::to_string(code)).append(",")
.append("\"data\":\"invalid reponse data\"}");
.append("\"data\":\"invalid response data\"}");
callBackResult = v8::String::NewFromUtf8(isolate_, errorString.c_str()).ToLocalChecked();
}
CallModuleJsCallback(callbackId, code, callBackResult);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -359,7 +359,6 @@ void FrontendDelegateImpl::OnInactive()
{
LOGD("JsFrontend OnInactive");
FireAsyncEvent("_root", std::string("\"viewinactive\",null,null"), std::string(""));
// TODO: Deprecated
FireAsyncEvent("_root", std::string("\"viewsuspended\",null,null"), std::string(""));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -61,7 +61,6 @@ inline void TrySaveTargetAndIdNode(const std::string& id, const std::string& tar
}
}
// TODO delete this vector after declaration refactor if finished.
std::vector<std::string> g_declarationNodes =
{ DOM_NODE_TAG_BADGE,
DOM_NODE_TAG_BUTTON,

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@ -48,6 +48,4 @@ config("config_domnode_test") {
group("unittest") {
testonly = true
deps = []
#deps += [ ":DomCardDivTest" ]
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -78,6 +78,7 @@ void SimpleSpringNode::EndToValue(double endValue, double velocity)
auto context = context_.Upgrade();
if (!context) {
LOGE("End to value failed, context is null. index: %{public}d", index_);
return;
}
SpringNode::EndToValue(endValue, velocity);
if (isRunning_) {

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@ -247,7 +247,5 @@ config("config_animation_test") {
group("unittest") {
testonly = true
deps = [
# ":SvgAnimateTest"
]
deps = []
}

View File

@ -39,8 +39,8 @@ namespace {
constexpr int32_t DOUBLE_WIDTH = 2;
constexpr int32_t HOVER_ANIMATION_DURATION = 250;
constexpr float SCALE_DEFAULT = 1.0;
constexpr float SCALE_CHANGED = 1.05;
constexpr float SCALE_DEFAULT = 1.0f;
constexpr float SCALE_CHANGED = 1.05f;
const Color BOARD_CHANGED = Color::FromRGBO(0, 0, 0, 0.05);
const Rosen::RSAnimationTimingCurve SCALE_ANIMATION_TIMING_CURVE =
Rosen::RSAnimationTimingCurve::CreateCubicCurve(0.2f, 0.0f, 0.2f, 1.0f);
@ -507,7 +507,6 @@ bool RosenRenderBox::MaybeRelease()
void RosenRenderBox::UpdateBlurRRect(const SkRRect& rRect, const Offset& offset)
{
// radius of four edge should be same
SkVector radius = rRect.radii(SkRRect::kUpperLeft_Corner);
const SkRect& rect = rRect.rect();
windowBlurRRect_.SetRectWithSimpleRadius(
@ -1101,6 +1100,9 @@ void RosenRenderBox::AnimateMouseHoverEnter()
if (animationType_ == HoverAnimationType::SCALE) {
isHoveredScale = true;
auto rsNode = GetRSNode();
if (!rsNode) {
return;
}
float scaleBegin = SCALE_DEFAULT;
float scaleEnd = SCALE_CHANGED;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -89,7 +89,7 @@ int32_t FocusableGrid::FocusMove(KeyDirection direction)
++nextRow;
nextCol = 0;
}
if (nextRow < 0 || nextCol < 0 || nextRow >= rowCount_ || nextCol >= colCount_) {
if ((nextRow < 0) || (nextCol < 0) || (nextRow >= rowCount_) || (nextCol >= colCount_)) {
return -1;
}
next = GetIndexByGrid(nextRow, nextCol);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -74,17 +74,17 @@ public:
bool IsTight() const
{
return minSize_.Width() >= maxSize_.Width() && minSize_.Height() >= maxSize_.Height();
return (minSize_.Width() >= maxSize_.Width()) && (minSize_.Height() >= maxSize_.Height());
}
bool IsWidthValid() const
{
return maxSize_.Width() >= minSize_.Width() && maxSize_.Width() > 0.0;
return (maxSize_.Width() >= minSize_.Width()) && (maxSize_.Width() > 0.0);
}
bool IsHeightValid() const
{
return maxSize_.Height() >= minSize_.Height() && maxSize_.Height() > 0.0;
return (maxSize_.Height() >= minSize_.Height()) && (maxSize_.Height() > 0.0);
}
Size Constrain(Size size) const

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -16,8 +16,6 @@
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_PAINTER_FLUTTER_SVG_PAINTER_H
#define FOUNDATION_ACE_FRAMEWORKS_CORE_PAINTER_FLUTTER_SVG_PAINTER_H
#include "flutter/lib/ui/painting/canvas.h"
#include "flutter/lib/ui/painting/paint.h"
#include "include/core/SkPaint.h"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -329,7 +329,7 @@ RefPtr<ClipPath> ClipPath::CreateShape(const std::string& value)
break;
}
default: {
LOGE("basic shape type is none or invalid, clipPath value is %{public}s", data.c_str());
LOGE("basic shape type is none or invalid");
break;
}
}

View File

@ -87,11 +87,11 @@ void CustomDialogElement::ShowDialog()
// use accessibility node already created with dom node in JS app
baseDialog->SetCustomDialogId(StringUtils::StringToInt(GetId()));
#if defined(WINDOWS_PLATFORM) || defined(MAC_PLATFORM)
auto mananger = context->GetAccessibilityManager();
if (mananger) {
auto node = mananger->GetAccessibilityNodeById(StringUtils::StringToInt(GetId()));
auto manager = context->GetAccessibilityManager();
if (manager) {
auto node = manager->GetAccessibilityNodeById(StringUtils::StringToInt(GetId()));
node->SetZIndexToChild(stackElement->GetChildrenSize());
mananger->ClearNodeRectInfo(node, isPopDialog_);
manager->ClearNodeRectInfo(node, isPopDialog_);
}
#endif
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -34,6 +34,7 @@ constexpr int32_t CIRCLE_NUMBER = 50;
constexpr float SHADOW_BLUR_RADIUS = 5.0f;
constexpr double DIAMETER_TO_THICKNESS_RATIO = 0.12;
constexpr double FIXED_WIDTH = 1.0;
constexpr int32_t SEGMENT_MAX_NUMBER = 9;
} // namespace
@ -580,7 +581,7 @@ void FlutterRenderPercentageDataPanel::PaintLinearProgress(RenderContext& contex
segmentSize = static_cast<double>(segment.size());
}
for (uint32_t i = 0; i < segment.size(); i++) {
if (segment[i].GetValue() == 0.0) {
if (NearEqual(segment[i].GetValue(), 0.0)) {
segmentSize -= 1;
}
}
@ -595,15 +596,15 @@ void FlutterRenderPercentageDataPanel::PaintLinearProgress(RenderContext& contex
auto valueSum = 0.0;
PaintBackground(context, offset, totalWidth, height);
for (uint32_t i = 0; i < segment.size(); i++) {
if (i == 0 && segment[0].GetValue() == 0.0) {
if (i == 0 && NearEqual(segment[0].GetValue(), 0.0)) {
for (uint32_t j = 0; j < segment.size(); j++) {
if (segment[j].GetValue() != 0.0 && i == 0) {
if (!NearEqual(segment[j].GetValue(), 0.0) && i == 0) {
i = j;
}
}
}
auto segmentWidth = segment[i].GetValue();
if (segmentWidth == 0.0) {
if (NearEqual(segmentWidth, 0.0)) {
continue;
}
valueSum += segmentWidth;
@ -617,7 +618,7 @@ void FlutterRenderPercentageDataPanel::PaintLinearProgress(RenderContext& contex
PaintColorSegment(context, offset, segmentWidth * scaleMaxValue, widthSegment, height, segmentStartColor,
segmentEndColor, isFull, isStart);
widthSegment += segment[i].GetValue() * scaleMaxValue;
if (isFull && segment.size() == 9) {
if (isFull && segment.size() == SEGMENT_MAX_NUMBER) {
return;
}
PaintSpace(context, offset, spaceWidth, widthSegment, height);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -200,7 +200,7 @@ void RenderProgressDataPanel::PrepareAnimation()
animationTime = animationDuring_.count() * SECOND_TO_MILLISECOND;
}
if (animationTime < MIN_TRANSITION_TIME || previousPercentValue_ == 100.0) {
if (animationTime < MIN_TRANSITION_TIME || NearEqual(previousPercentValue_, 100.0)) {
animationTime = MIN_TRANSITION_TIME;
} else if (animationTime > MAX_TRANSITION_TIME) {
animationTime = MAX_TRANSITION_TIME;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -560,7 +560,7 @@ void RosenRenderPercentageDataPanel::PaintLinearProgress(RenderContext& context,
segmentSize = static_cast<double>(segment.size());
}
for (uint32_t i = 0; i < segment.size(); i++) {
if (segment[i].GetValue() == 0.0) {
if (NearEqual(segment[i].GetValue(), 0.0)) {
segmentSize -= 1;
}
}
@ -573,7 +573,7 @@ void RosenRenderPercentageDataPanel::PaintLinearProgress(RenderContext& context,
PaintBackground(context, offset, totalWidth, height);
for (uint32_t i = 0; i < segment.size(); i++) {
auto segmentWidth = segment[i].GetValue();
if (segmentWidth == 0.0) {
if (NearEqual(segmentWidth, 0.0)) {
continue;
}
auto segmentStartColor = segment[i].GetStartColor();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -169,8 +169,6 @@ void DialogModalElement::RegisterTransitionListener()
auto fullSize = render->GetLayoutSize();
auto pageHeight = fullSize.Height();
dialogRender->AnimateTo(pageHeight, false);
} else {
// Do Nothing for other events.
}
});
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -37,8 +37,8 @@ void DragBarElement::OnBlur()
bool DragBarElement::OnKeyEvent(const KeyEvent& keyEvent)
{
if (keyEvent.code == KeyCode::KEY_ENTER || keyEvent.code == KeyCode::KEY_NUMPAD_ENTER ||
keyEvent.code == KeyCode::KEY_SPACE) {
if ((keyEvent.code == KeyCode::KEY_ENTER) || (keyEvent.code == KeyCode::KEY_NUMPAD_ENTER) ||
(keyEvent.code == KeyCode::KEY_SPACE)) {
auto dragBar = AceType::DynamicCast<RenderDragBar>(renderNode_);
if (dragBar) {
dragBar->HandleClick(Offset());

View File

@ -41,7 +41,7 @@ void FormElement::Update()
{
auto form = AceType::DynamicCast<FormComponent>(component_);
if (!form) {
LOGE("could not get form componet for update");
LOGE("could not get form component for update");
return;
}
@ -51,7 +51,7 @@ void FormElement::Update()
info.dimension != cardInfo_.dimension) {
cardInfo_ = info;
} else {
// for update form componet
// for update form component
if (cardInfo_.allowUpate != info.allowUpate) {
cardInfo_.allowUpate = info.allowUpate;
LOGI(" update card allow info:%{public}d", cardInfo_.allowUpate);
@ -375,7 +375,7 @@ void FormElement::CreateCardContainer()
subContainer_->SetFormComponet(component_);
auto form = AceType::DynamicCast<FormComponent>(component_);
if (!form) {
LOGE("form componet is null when try adding nonmatched container to form manager.");
LOGE("form component is null when try adding nonmatched container to form manager.");
return;
}
auto info = form->GetFormRequestionInfo();

View File

@ -187,7 +187,7 @@ void FormManagerDelegate::CreatePlatformResource(const WeakPtr<PipelineContext>&
auto resRegister = weakRes.Upgrade();
auto context = delegate->context_.Upgrade();
if (!resRegister || !context) {
LOGE("resouce register or context is null");
LOGE("resource register or context is null");
delegate->OnFormError("internal error");
return;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -57,6 +57,10 @@ void RenderGestureListener::Update(const RefPtr<Component>& component)
{
RenderProxy::Update(component);
auto gestureComponent = AceType::DynamicCast<GestureListenerComponent>(component);
if (!gestureComponent) {
LOGE("gestureComponent is null");
return;
}
ACE_DCHECK(gestureComponent);
SetRemoteMessageCallback(gestureComponent);
SetOnClickCallback(gestureComponent);

View File

@ -2134,7 +2134,7 @@ bool RenderGridLayout::MoveItemsBackward(int32_t fromRow, int32_t fromColum, int
return true;
}
void RenderGridLayout::UpdateMatrixByIndexStrong(int32_t index, int32_t row, int32_t colum)
void RenderGridLayout::UpdateMatrixByIndexStrong(int32_t index, int32_t row, int32_t column)
{
std::map<int32_t, int32_t> rowMap;
@ -2143,11 +2143,11 @@ void RenderGridLayout::UpdateMatrixByIndexStrong(int32_t index, int32_t row, int
rowMap = rowIter->second;
}
auto indexIter = rowMap.find(colum);
auto indexIter = rowMap.find(column);
if (indexIter != rowMap.end()) {
rowMap[colum] = index;
rowMap[column] = index;
} else {
rowMap.emplace(std::make_pair(colum, index));
rowMap.emplace(std::make_pair(column, index));
}
gridMatrix_[row] = rowMap;
@ -2160,13 +2160,13 @@ void RenderGridLayout::UpdateCurInsertPos(int32_t curInsertRow, int32_t curInser
UpdateMatrixByIndexStrong(CELL_FOR_INSERT, curInsertRowIndex_, curInsertColumnIndex_);
}
int32_t RenderGridLayout::CalIndexForItemByRowAndColum(int32_t row, int32_t colum)
int32_t RenderGridLayout::CalIndexForItemByRowAndColum(int32_t row, int32_t column)
{
int32_t curRow = 0;
int32_t curColum = 0;
int32_t targetIndex = 0;
if (row >= 0 && row < rowCount_ && colum >= 0 && colum < colCount_) {
while (curRow != row || curColum != colum) {
if (row >= 0 && row < rowCount_ && column >= 0 && column < colCount_) {
while (curRow != row || curColum != column) {
GetNextGrid(curRow, curColum);
if (curRow >= rowCount_ || curColum >= colCount_) {
targetIndex = -1;
@ -2219,21 +2219,21 @@ bool RenderGridLayout::SortCellIndex(
bool RenderGridLayout::CalTheFirstEmptyCell(int32_t& rowIndex, int32_t& columIndex, bool ignoreInsert)
{
int32_t row = 0;
int32_t colum = 0;
int32_t column = 0;
int32_t index = -3;
index = GetIndexByGrid(row, colum);
index = GetIndexByGrid(row, column);
while ((-1 != index) && (ignoreInsert || (CELL_FOR_INSERT != index))) {
GetNextGrid(row, colum);
if (row >= rowCount_ || colum >= colCount_) {
GetNextGrid(row, column);
if (row >= rowCount_ || column >= colCount_) {
return false;
}
index = GetIndexByGrid(row, colum);
index = GetIndexByGrid(row, column);
}
rowIndex = row;
columIndex = colum;
columIndex = column;
return true;
}

View File

@ -331,9 +331,9 @@ protected:
// it should be cells which has item in
bool MoveItemsBackward(int32_t fromRow, int32_t fromColum, int32_t toRow, int32_t toColum);
void UpdateMatrixByIndexStrong(int32_t index, int32_t row, int32_t colum);
void UpdateMatrixByIndexStrong(int32_t index, int32_t row, int32_t column);
void UpdateCurInsertPos(int32_t curInsertRow, int32_t curInsertColum);
int32_t CalIndexForItemByRowAndColum(int32_t row, int32_t colum);
int32_t CalIndexForItemByRowAndColum(int32_t row, int32_t column);
// If the first is equal the second, return true, else return false.
bool SortCellIndex(int32_t rowFirst, int32_t columFirst, int32_t rowSecond, int32_t columSecond, bool& firstIsPre);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -405,11 +405,9 @@ bool ListElement::BuildListComponent(const RefPtr<Component>& component)
renderList_->AddListItem(index, itemProxy);
itemProxy->SetHidden(false);
if (accessibilityDisabled_) {
if (accessibilityDisabled_) {
auto renderNode = element->GetRenderNode();
if (renderNode) {
renderNode->SetNeedUpdateAccessibility(false);
}
auto renderNode = element->GetRenderNode();
if (renderNode) {
renderNode->SetNeedUpdateAccessibility(false);
}
}
// recover visible state.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -315,7 +315,7 @@ void RenderListItem::HandleItemEffect(bool isFromRotate)
if (needVibrate_ && lastState_ == ItemState::NEARBY && currentState_ == ItemState::FOCUS && vibrator_) {
vibrator_->Vibrate(VIBRATOR_TYPE_WATCH_CROWN_STRENGTH1);
}
if (rotationVibrate_ && isFromRotate) {
if (rotationVibrate_ && isFromRotate && vibrator_) {
vibrator_->Vibrate(VIBRATOR_TYPE_WATCH_CROWN_STRENGTH1);
}
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -190,7 +190,11 @@ void RenderMarquee::Update(const RefPtr<Component>& component)
value_ = marquee->GetValue();
start_ = marquee->GetPlayerStatus();
auto context = GetContext().Upgrade();
if (context && context->UseLiteStyle()) {
if (!context) {
LOGE("context is null");
return;
}
if (context->UseLiteStyle()) {
// lite loop time is 1000ms, while default marquee loop is 85ms.
scrollAmount_ = marquee->GetScrollAmount() * DEFAULT_MARQUEE_SCROLL_DELAY / 1000;
} else {

View File

@ -125,7 +125,7 @@ void PluginSubContainer::UpdateRootElmentSize()
rootHeight = pluginComponet->GetHeight();
}
if (rootWidth_ == rootWidth && rootHeight == rootHeight) {
if (rootWidth_ == rootWidth && rootHeight_ == rootHeight) {
LOGE("size not changed, should not change");
return;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -297,8 +297,8 @@ void RenderLoadingProgress::SetDragDistance(double distance)
return;
}
curDistance_ = distance;
double precent = (curDistance_ - minDistance_) / (maxDistance_ - minDistance_);
double scale = RING_SCALE_BEGIN + RING_SCALE_RANGE * precent;
double percent = (curDistance_ - minDistance_) / (maxDistance_ - minDistance_);
double scale = RING_SCALE_BEGIN + RING_SCALE_RANGE * percent;
switch (loadingMode_) {
case MODE_LOOP: {
return;
@ -307,11 +307,11 @@ void RenderLoadingProgress::SetDragDistance(double distance)
exitScale_ = 1.0;
exitAlpha_ = 1.0;
dragScale_ = scale;
dragAlpha_ = precent;
dragAlpha_ = percent;
// Update Comet Para when drag distance changed.
CometParam para;
para.alpha = floor(UINT8_MAX * dragAlpha_);
para.angular = DRAG_ANGLE_BEGIN + DRAG_ANGLE_RANGE * precent;
para.angular = DRAG_ANGLE_BEGIN + DRAG_ANGLE_RANGE * percent;
if (para.angular < 0.0) {
para.angular = para.angular + 360.0;
}
@ -323,7 +323,7 @@ void RenderLoadingProgress::SetDragDistance(double distance)
dragScale_ = 1.0;
dragAlpha_ = 1.0;
exitScale_ = scale;
exitAlpha_ = precent;
exitAlpha_ = percent;
break;
}
default: {
@ -385,7 +385,7 @@ void RenderLoadingProgress::UpdateLoadingSize(double diameter)
}
}
void RenderLoadingProgress::CalculateValue(int32_t start, int32_t end, double precent)
void RenderLoadingProgress::CalculateValue(int32_t start, int32_t end, double percent)
{
if (start == end) {
ringWidth_ = NormalizeToPx(MODE_RING_WIDTH[start]);
@ -395,15 +395,15 @@ void RenderLoadingProgress::CalculateValue(int32_t start, int32_t end, double pr
ringBgBlurRadius_ = NormalizeToPx(MODE_RING_BG_BLUR_RADIUS[start]);
} else {
ringWidth_ = NormalizeToPx(MODE_RING_WIDTH[start] +
(MODE_RING_WIDTH[end] - MODE_RING_WIDTH[start]) * precent);
(MODE_RING_WIDTH[end] - MODE_RING_WIDTH[start]) * percent);
cometRadius_ = NormalizeToPx(MODE_COMET_RADIUS[start] +
(MODE_COMET_RADIUS[end] - MODE_COMET_RADIUS[start]) * precent);
(MODE_COMET_RADIUS[end] - MODE_COMET_RADIUS[start]) * percent);
ringBlurRadius_ = NormalizeToPx(MODE_RING_BLUR_RADIUS[start] +
(MODE_RING_BLUR_RADIUS[end] - MODE_RING_BLUR_RADIUS[start]) * precent);
(MODE_RING_BLUR_RADIUS[end] - MODE_RING_BLUR_RADIUS[start]) * percent);
ringBgWidth_ = NormalizeToPx(MODE_RING_BG_WIDTH[start] +
(MODE_RING_BG_WIDTH[end] - MODE_RING_BG_WIDTH[start]) * precent);
(MODE_RING_BG_WIDTH[end] - MODE_RING_BG_WIDTH[start]) * percent);
ringBgBlurRadius_ = NormalizeToPx(MODE_RING_BG_BLUR_RADIUS[start] +
(MODE_RING_BG_BLUR_RADIUS[end] - MODE_RING_BG_BLUR_RADIUS[start]) * precent);
(MODE_RING_BG_BLUR_RADIUS[end] - MODE_RING_BG_BLUR_RADIUS[start]) * percent);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -73,7 +73,7 @@ protected:
void AnimationChanged();
void UpdateLoadingSize(double diameter);
void CalculateValue(int32_t start, int32_t end, double precent = 1.0);
void CalculateValue(int32_t start, int32_t end, double percent = 1.0);
void UpdateRingAnimation();
void UpdateCometAnimation();
void DoCometTailAnimation();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -525,7 +525,7 @@ bool RenderMultiChildScroll::HandleCrashTop()
if (scrollVibrate_ && vibrator_) {
vibrator_->Vibrate(VIBRATOR_TYPE_WATCH_CROWN_STRENGTH3);
}
if (rotationVibrate_ && IsFromRotate()) {
if (rotationVibrate_ && IsFromRotate() && vibrator_) {
vibrator_->Vibrate(VIBRATOR_TYPE_WATCH_CROWN_STRENGTH3);
}
#endif
@ -537,7 +537,7 @@ bool RenderMultiChildScroll::HandleCrashBottom()
if (scrollVibrate_ && vibrator_) {
vibrator_->Vibrate(VIBRATOR_TYPE_WATCH_CROWN_STRENGTH3);
}
if (rotationVibrate_ && IsFromRotate()) {
if (rotationVibrate_ && IsFromRotate() && vibrator_) {
vibrator_->Vibrate(VIBRATOR_TYPE_WATCH_CROWN_STRENGTH3);
}
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -13,12 +13,6 @@
* limitations under the License.
*/
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved.
* Description: Implement RenderScroll.
* Create: 2019/12/25
*/
#include "core/components/scroll/render_scroll.h"
#include "base/geometry/axis.h"
@ -384,18 +378,20 @@ bool RenderScroll::ScrollPageByChild(Offset& delta, int32_t source)
bool RenderScroll::IsOutOfBottomBoundary()
{
if (IsRowReverse()) {
return GetMainOffset(currentOffset_) <= (GetMainSize(viewPort_) - mainScrollExtent_) && ReachMaxCount();
return LessOrEqual(GetMainOffset(currentOffset_), (GetMainSize(viewPort_) - mainScrollExtent_)) &&
ReachMaxCount();
} else {
return GetMainOffset(currentOffset_) >= (mainScrollExtent_ - GetMainSize(viewPort_)) && ReachMaxCount();
return GreatOrEqual(GetMainOffset(currentOffset_), (mainScrollExtent_ - GetMainSize(viewPort_))) &&
ReachMaxCount();
}
}
bool RenderScroll::IsOutOfTopBoundary()
{
if (IsRowReverse()) {
return GetMainOffset(currentOffset_) >= 0.0;
return GreatOrEqual(GetMainOffset(currentOffset_), 0.0);
} else {
return GetMainOffset(currentOffset_) <= 0.0;
return LessOrEqual(GetMainOffset(currentOffset_), 0.0);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -65,6 +65,7 @@ void SelectElement::PerformBuild()
render->SetRawRecognizer(rawRecognizer);
} else {
LOGE("select: can not get render node of select by dynamic cast failed.");
return;
}
RefPtr<SelectComponent> component = AceType::DynamicCast<SelectComponent>(component_);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -26,6 +26,10 @@
namespace OHOS::Ace {
constexpr double SELECT_OPTION_LEFT_LENGTH = 16.0;
constexpr double SELECT_OPTION_TOP_LENGTH = 15.0;
constexpr double SELECT_OPTION_RIGHT_LENGTH = 16.0;
constexpr double SELECT_OPTION_BOTTOM_LENGTH = 15.0;
/**
* SelectTheme defines color and styles of SelectComponent. SelectTheme should be build
* using SelectTheme::Builder.
@ -82,8 +86,8 @@ public:
theme->titleStyle_.SetFontWeight(FontWeight::W500);
theme->titleStyle_.SetTextColor(themeConstants->GetColor(THEME_OHOS_COLOR_TEXT_PRIMARY));
theme->titleStyle_.SetTextDecoration(TextDecoration::NONE);
// this is the const padding needed by emui
theme->optionPadding_ = Edge(16.0, 15.0, 16.0, 15.0, DimensionUnit::VP);
theme->optionPadding_ = Edge(SELECT_OPTION_LEFT_LENGTH, SELECT_OPTION_TOP_LENGTH,
SELECT_OPTION_RIGHT_LENGTH, SELECT_OPTION_BOTTOM_LENGTH, DimensionUnit::VP);
theme->optionInterval_ = theme->isTV_ ? Dimension(6.0, DimensionUnit::VP) : 0.0_vp;
theme->tvFocusTextColor_ = Color(0xE6000000);
theme->tvNormalBackColor_ = Color(0x33FFFFFF);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -324,6 +324,10 @@ bool StageElement::PerformPushPageTransition(const RefPtr<Element>& elementIn, c
transitionIn->SetDeclarativeDirection(TransitionDirection::TRANSITION_IN);
transitionOut->SetDeclarativeDirection(TransitionDirection::TRANSITION_OUT);
}
if (!pageIn || !pageOut) {
LOGE("push page failed. page in / out is null.");
return false;
}
LOGD("notify push page event. page id: in: %{public}d, out: %{public}d", pageIn->GetPageId(), pageOut->GetPageId());
NotifyPageTransitionListeners(TransitionEvent::PUSH_START, pageIn, pageOut);
ACE_SCOPED_TRACE("PUSH_START");
@ -331,10 +335,6 @@ bool StageElement::PerformPushPageTransition(const RefPtr<Element>& elementIn, c
LOGW("init transition failed, skip push transition.");
return false;
}
if (!pageIn || !pageOut) {
LOGE("push page failed. page in / out is null.");
return false;
}
if ((!controllerIn_) || (!controllerOut_)) {
LOGE("push page failed. controller in / out is null.");
return false;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -191,6 +191,7 @@ void SvgDom::ParseIdAttr(const WeakPtr<SvgNode>& weakSvgNode, const std::string&
auto svgNode = weakSvgNode.Upgrade();
if (!svgNode) {
LOGE("ParseIdAttr failed, svgNode is null");
return;
}
svgNode->SetNodeId(value);
svgNode->SetAttr(DOM_ID, value);
@ -202,6 +203,7 @@ void SvgDom::ParseFillAttr(const WeakPtr<SvgNode>& weakSvgNode, const std::strin
auto svgNode = weakSvgNode.Upgrade();
if (!svgNode) {
LOGE("ParseFillAttr failed, svgNode is null");
return;
}
if (fillColor_) {
std::stringstream stream;
@ -218,6 +220,7 @@ void SvgDom::ParseClassAttr(const WeakPtr<SvgNode>& weakSvgNode, const std::stri
auto svgNode = weakSvgNode.Upgrade();
if (!svgNode) {
LOGE("ParseClassAttr failed, svgNode is null");
return;
}
std::vector<std::string> styleNameVector;
StringUtils::SplitStr(value, " ", styleNameVector);
@ -237,6 +240,7 @@ void SvgDom::ParseStyleAttr(const WeakPtr<SvgNode>& weakSvgNode, const std::stri
auto svgNode = weakSvgNode.Upgrade();
if (!svgNode) {
LOGE("ParseStyleAttr failed, svgNode is null");
return;
}
std::vector<std::string> attrPairVector;
StringUtils::SplitStr(value, ";", attrPairVector);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -63,6 +63,9 @@ RefPtr<RenderNode> SvgFilter::CreateRender(
if (renderNode) {
renderNode->Attach(context_);
renderNode->SetSvgRoot(svgContext->GetSvgRoot());
} else {
LOGE("renderNode is null");
return nullptr;
}
for (auto& child : children_) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -63,6 +63,9 @@ RefPtr<RenderNode> SvgPattern::CreateRender(
if (renderNode) {
renderNode->Attach(context_);
renderNode->SetSvgRoot(svgContext->GetSvgRoot());
} else {
LOGE("renderNode is null");
return nullptr;
}
for (auto child : children_) {

View File

@ -561,7 +561,7 @@ void RenderSwiper::InitAccessibilityEventListener()
void RenderSwiper::UpdateIndex(int32_t index)
{
// can't change index when stretch indicator, as stretch direct is single.
if (index >= 0 && stretchRate_ == 0.0) {
if (index >= 0 && NearEqual(stretchRate_, 0.0)) {
if (index >= itemCount_) {
index = itemCount_ - 1;
}
@ -2468,7 +2468,6 @@ void RenderSwiper::DragIndicatorEnd()
void RenderSwiper::DragEdgeStretch(double offset)
{
// different with emui
const double longPressDragStrechLongest = DRAG_STRETCH_LONGEST_DP * scale_;
if (offset >= longPressDragStrechLongest) {
UpdateEdgeStretchRate(DRAG_OFFSET_MAX);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -7,7 +7,7 @@
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License SwiperComponent::Is distributed on an "AS SwiperComponent::Is" BASIS,
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -71,7 +71,6 @@ void BoxCreatorTest::TearDown() {}
* @tc.name: BoxCreator001
* @tc.desc: Verify BoxCreator can create box with all properties.
* @tc.type: FUNC
* @tc.require: AR000DAQTR
*/
HWTEST_F(BoxCreatorTest, BoxCreator001, TestSize.Level1)
{
@ -129,7 +128,6 @@ HWTEST_F(BoxCreatorTest, BoxCreator001, TestSize.Level1)
* @tc.name: BoxCreator002
* @tc.desc: Verify BoxCreator can create box with className only.
* @tc.type: FUNC
* @tc.require: AR000DAQTR
*/
HWTEST_F(BoxCreatorTest, BoxCreator002, TestSize.Level1)
{

Some files were not shown because too many files have changed in this diff Show More